Files
dawnline/web/src/admin/luci.d.ts
T
Aemeath 34293fb8e5
Build packages / Version (push) Waiting to run
Dawnline 0.4.0
- Components tab replaces Updates: Dawnline, the AmneziaWG build for this
  firmware (Slava-Shchipunov 2.0 or 2Grey 3.1, Russian translation) and
  the system packages Dawnline adds, each checked, installed, reinstalled
  or rolled back in place, with What's new, versions and an activity log
- Automatic updates: daily check, install at a set time or right away,
  per component; AmneziaWG is left out by default and an automatic run
  never switches its build or generation
- Downloads verified against GitHub's sha256; mirrors are used only when
  GitHub is unreachable and the hash is known
- New installer: checks firmware, clock, space and DNS, lets you pick a
  release, shows the plan and asks first; --dry-run
- New uninstaller removes everything Dawnline added (cron, nft, firewall,
  routing, interfaces, packages it installed); --dry-run
- Works without AmneziaWG on the router: Overview, the setup wizard,
  Health and Components say what is missing and offer to install it
- Overview shows failed health checks as notices with their fix
- People list no longer reads the config from the browser: private keys
  stay on the router; personal links are fetched on demand
- Config changes are serialized under one lock, the nft table loads
  atomically and fails closed, and Dawnline never touches network
  sections it did not create
- The portal never opens system ports, keeps disabled devices disabled,
  rate-limits per address and counts days by the router's clock
- Settings and Diagnostics load their heavy parts in the background
- Release notes are written from the commits since the previous release
- Backend and admin UI split into small single-purpose modules
2026-10-16 02:14:15 +03:00

127 lines
4.1 KiB
TypeScript

// Minimal typings for the parts of the LuCI client SDK (luci.js / ui.js /
// rpc.js / poll.js / dom.js) that Dawnline uses. The module is evaluated by
// LuCI's loader, which injects the `'require'`d classes as these identifiers.
type Child = Node | string | number | null | undefined | false | Child[];
interface ElementAttrs {
[key: string]: unknown;
class?: string;
style?: string;
click?: (ev: MouseEvent) => void;
change?: (ev: Event) => void;
input?: (ev: Event) => void;
keydown?: (ev: KeyboardEvent) => void;
}
interface LuciWidget {
render(): Node | Promise<Node>;
getValue(): any;
setValue(v: any): void;
isValid(): boolean;
triggerValidation(): void;
setChangeEvents?(node: Node, ...events: string[]): void;
node?: HTMLElement;
}
interface WidgetOptions {
id?: string;
name?: string;
optional?: boolean;
datatype?: string;
placeholder?: string;
validate?: (value: string) => true | string;
disabled?: boolean;
readonly?: boolean;
widget?: 'select' | 'radio' | 'checkbox';
sort?: boolean | string[];
create?: boolean;
multiple?: boolean;
size?: number;
rows?: number;
cols?: number;
monospace?: boolean;
password?: boolean;
value_enabled?: string;
value_disabled?: string;
hiddenname?: string;
}
interface LuciUI {
/** The menu is cached for the session; flush it after Dawnline's pages change. */
menu?: { flushCache(): void };
showModal(title: string | null, children: Child, ...classes: string[]): HTMLElement;
hideModal(): void;
addNotification(title: string | null, children: Child, ...classes: string[]): HTMLElement;
addTimeLimitedNotification(title: string | null, children: Child, timeout?: number, ...classes: string[]): HTMLElement;
changes: any;
itemlist(node: Node, items: unknown[], separators?: unknown): HTMLElement;
createHandlerFn(ctx: unknown, fn: string | ((...args: any[]) => unknown), ...args: unknown[]): (ev: Event) => void;
Textfield: new (value: string | null, options?: WidgetOptions) => LuciWidget;
Textarea: new (value: string | null, options?: WidgetOptions) => LuciWidget;
Select: new (value: string | string[] | null, choices: Record<string, string | Node>, options?: WidgetOptions) => LuciWidget;
Checkbox: new (value: string | null, options?: WidgetOptions) => LuciWidget;
DynamicList: new (values: string[] | null, choices?: Record<string, string>, options?: WidgetOptions) => LuciWidget;
Dropdown: new (value: string | string[] | null, choices: Record<string, string | Node>, options?: WidgetOptions) => LuciWidget;
}
interface LuciRpc {
declare<T = any>(spec: {
object: string;
method: string;
params?: string[];
expect?: Record<string, unknown>;
filter?: (data: any, args: unknown[], ...extra: unknown[]) => any;
reject?: boolean;
}): (...args: any[]) => Promise<T>;
}
interface LuciPoll {
add(fn: () => unknown, interval?: number): boolean;
remove(fn: () => unknown): boolean;
start(): void;
stop(): void;
active(): boolean;
}
interface LuciDom {
content(node: Node, children: Child): Node;
findClassInstance(node: Node): any;
append(node: Node, children: Child): Node;
isEmpty(node: Node): boolean;
}
interface LuciEnv {
sessionid?: string;
rpctimeout?: number;
[key: string]: unknown;
}
interface LuciL {
env: LuciEnv;
url(...parts: string[]): string;
resolveDefault<T>(p: Promise<T>, def: T): Promise<T>;
resource(...parts: string[]): string;
itemlist(node: Node, items: unknown[], separators?: unknown): HTMLElement;
bind<F extends (...args: any[]) => any>(fn: F, self: unknown, ...args: unknown[]): F;
raise(type: string, fmt: string, ...args: unknown[]): never;
}
declare global {
interface String {
format(...args: unknown[]): string;
}
const E: (tag: string, attrs?: ElementAttrs | Child, children?: Child) => HTMLElement;
const _: (msg: string, ctx?: string) => string;
const N_: (n: number, singular: string, plural: string, ctx?: string) => string;
const L: LuciL;
const ui: LuciUI;
const rpc: LuciRpc;
const poll: LuciPoll;
const dom: LuciDom;
const baseclass: { extend<T>(props: T): T };
}
export type { Child, LuciWidget, WidgetOptions };