LuCI admin (people, devices, limits, disguise, health, updates, backups) and a personal self-service portal, built as ipk (OpenWrt 24.10) and apk (OpenWrt 25.12) with the OpenWrt SDK. Successor of openwrt-liminal. - install.sh: checks the router, installs AmneziaWG for its firmware, then the release package verified against sha256sums.txt - CI: Prettier, types, tests, committed bundles, ShellCheck, ucode checks; tagged releases build both packages and publish them - Web bundles minified with esbuild (JS and CSS) - README with framed screenshots
This commit is contained in:
commit
a3910f8b97
105 files changed
+22278
No files matched your search
@@ -0,0 +1,20 @@
|
||||
// LuCI's global E() appends array children only one level deep and
|
||||
// stringifies nested arrays ("[object HTMLDivElement]"). This wrapper
|
||||
// flattens children recursively and drops empty values, so components can
|
||||
// compose freely. Modules import it and thereby shadow the global.
|
||||
|
||||
import type { Child } from './luci.d';
|
||||
|
||||
function flatten(c: Child, out: (Node | string)[]): (Node | string)[] {
|
||||
if (c == null || c === false || c === '') return out;
|
||||
if (Array.isArray(c)) c.forEach((x) => flatten(x, out));
|
||||
else out.push(c instanceof Node ? c : String(c));
|
||||
return out;
|
||||
}
|
||||
|
||||
export function E(tag: string, attrs?: Record<string, unknown> | Child, children?: Child): HTMLElement {
|
||||
const luciE = (window as unknown as { E: (t: string, a: Record<string, unknown>, c: Child) => HTMLElement }).E;
|
||||
const isAttrs = attrs != null && typeof attrs === 'object' && !Array.isArray(attrs) && !(attrs instanceof Node);
|
||||
if (!isAttrs && children === undefined) return luciE(tag, {}, flatten(attrs as Child, []));
|
||||
return luciE(tag, (isAttrs ? attrs : {}) as Record<string, unknown>, flatten(children, []));
|
||||
}
|
||||
Reference in new issue
Block a user