yvee 0.0.10 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,388 +1,519 @@
1
- type ModuleLike = {
2
- [Symbol.toStringTag]: "Module";
3
- default?: unknown;
4
- [key: string]: unknown;
5
- };
6
- declare const isFN: (v: any) => v is Function;
7
- declare const isAsync: (v: any) => v is Function;
8
- declare const isPromise: (v: any) => v is Function;
9
- declare const isNumber: (value: any) => boolean;
10
- declare const isObject: (val: any) => val is Record<string, any>;
11
- declare const isPlainObject: (value: any) => boolean;
12
- declare const isModule: (obj: any) => obj is ModuleLike;
13
- declare const isArraybuff: (val: any) => val is string | ArrayBuffer | Uint8Array<ArrayBufferLike>;
14
- declare const isClassOrId: (k: string) => boolean;
15
- declare const isBool: (v: any) => v is boolean;
16
- declare const isStr: (v: any) => v is string;
17
- declare const isArr: (v: any) => v is any[];
18
- declare const isObj: (v: any) => v is object;
19
- declare const isNum: (v: any) => v is number;
20
- declare const isNull: (v: any) => v is null;
21
- declare const isNotNull: <T>(v: T) => v is Exclude<T, null>;
22
- declare const isUndefined: (v: any) => v is undefined;
23
- declare const isDefined: <T>(v: T) => v is Exclude<T, undefined>;
24
- declare const isInt: (str: string) => boolean;
25
- declare const isWindow: boolean;
26
- declare const isNotWindow: boolean;
1
+ /// <reference path="./assets.d.ts" />
2
+ type V$1 = string | number | boolean;
3
+ type CSSStyle$1 = Record<string, V$1 | null | undefined | {
4
+ readonly value: unknown;
5
+ }>;
27
6
 
28
- type is_ModuleLike = ModuleLike;
29
- declare const is_isArr: typeof isArr;
30
- declare const is_isArraybuff: typeof isArraybuff;
31
- declare const is_isAsync: typeof isAsync;
32
- declare const is_isBool: typeof isBool;
33
- declare const is_isClassOrId: typeof isClassOrId;
34
- declare const is_isDefined: typeof isDefined;
35
- declare const is_isFN: typeof isFN;
36
- declare const is_isInt: typeof isInt;
37
- declare const is_isModule: typeof isModule;
38
- declare const is_isNotNull: typeof isNotNull;
39
- declare const is_isNotWindow: typeof isNotWindow;
40
- declare const is_isNull: typeof isNull;
41
- declare const is_isNum: typeof isNum;
42
- declare const is_isNumber: typeof isNumber;
43
- declare const is_isObj: typeof isObj;
44
- declare const is_isObject: typeof isObject;
45
- declare const is_isPlainObject: typeof isPlainObject;
46
- declare const is_isPromise: typeof isPromise;
47
- declare const is_isStr: typeof isStr;
48
- declare const is_isUndefined: typeof isUndefined;
49
- declare const is_isWindow: typeof isWindow;
50
- declare namespace is {
51
- export { is_isArr as isArr, is_isArraybuff as isArraybuff, is_isAsync as isAsync, is_isBool as isBool, is_isClassOrId as isClassOrId, is_isDefined as isDefined, is_isFN as isFN, is_isInt as isInt, is_isModule as isModule, is_isNotNull as isNotNull, is_isNotWindow as isNotWindow, is_isNull as isNull, is_isNum as isNum, is_isNumber as isNumber, is_isObj as isObj, is_isObject as isObject, is_isPlainObject as isPlainObject, is_isPromise as isPromise, is_isStr as isStr, is_isUndefined as isUndefined, is_isWindow as isWindow };
52
- export type { is_ModuleLike as ModuleLike };
7
+ type kf = KeyframeAnimationOptions;
8
+ type KFType = (CSSStyle$1 | Record<string, V$1>)[] | CSSStyle$1 | Record<string, V$1>;
9
+ declare class anim {
10
+ private e;
11
+ opt: kf;
12
+ constructor(e: Elem);
13
+ animate(keyframes: CSSStyle$1[] | CSSStyle$1, options?: kf): Animation;
14
+ get slide(): {
15
+ left: (options?: kf) => anim;
16
+ right: (options?: kf) => anim;
17
+ up: (options?: kf) => anim;
18
+ down: (options?: kf) => anim;
19
+ };
20
+ fade(options?: kf): this;
21
+ shake(XorY?: "X" | "Y", opt?: kf): this;
22
+ color(c?: string | string[], opt?: kf): this;
23
+ bg(c?: string | string[], opt?: kf): this;
24
+ bounce(sVal?: number, opt?: kf): this;
53
25
  }
54
26
 
55
- declare const IfClient: <T>(fn: () => T) => T | undefined;
56
-
57
- type V = string | number | boolean;
58
- type obj$1<T> = Record<string, T>;
59
- type maybePromise<T> = Promise<T> | T;
60
-
61
- /**
62
- * A custom Map implementation that provides additional utility methods for working with objects and maps.
63
- *
64
- * @template K - The type of the keys in the map.
65
- * @template V - The type of the values in the map.
66
- */
67
- declare class Mapper<K, V> extends Map<K, V> {
68
- obj(obj?: object | null): void;
69
- map(map: Mapper<K, V>): void;
70
- ass<T>(key: K, obj: T): void;
71
- lacks(key: K): boolean;
72
- init(key: K, val: V): V;
27
+ declare class Eget<T extends Elements = HTMLElement> {
28
+ e: T;
29
+ protected _query?: string | undefined;
30
+ constructor(e: T, _query?: string | undefined);
31
+ get a(): anim;
32
+ get all(): T[];
33
+ get attr(): {
34
+ has: (attr: string) => boolean;
35
+ get: (attr: string) => string | null;
36
+ del: (attr: string) => Eget<T>;
37
+ set: (attrs: Record<string, unknown>) => Eget<T>;
38
+ };
39
+ get children(): Elem<T>[];
40
+ get click(): this;
41
+ get delete(): this;
42
+ get disabled(): boolean;
43
+ get focus(): this;
44
+ get href(): string;
45
+ get id(): string;
46
+ get inner(): string;
47
+ get offsetParent(): Elem | undefined;
48
+ get parent(): Elem | undefined;
49
+ get hash(): string;
50
+ get path(): string;
51
+ get rect(): DOMRect;
52
+ get remove_element(): this;
53
+ get style(): {
54
+ set: (style: CSSStyle$1 | Record<string, V$1 | null | undefined>, delayOrFN?: number | ((e?: any) => void)) => Elem<T>;
55
+ get: (prop: keyof CSSStyleDeclaration | string) => string;
56
+ del: (...props: (keyof CSSStyleDeclaration | string)[]) => Elem<T>;
57
+ };
58
+ get submit(): boolean;
59
+ get tag(): string;
60
+ get value(): any;
61
+ get unload(): () => void;
62
+ private updateContent;
63
+ set append(val: any);
64
+ set appendfirst(val: any);
65
+ set inner(val: any);
66
+ set disabled(vl: boolean);
67
+ set id(did: string);
68
+ set value(vl: any);
73
69
  }
74
70
 
75
- declare class log {
76
- static set i(a: any);
77
- static set e(a: any);
78
- static set w(a: any);
71
+ type fn<E, T> = (e?: E) => T;
72
+ type ElementEventName = keyof GlobalEventHandlersEventMap | "state" | "states" | "ready" | "beforeunload" | "popstate" | "DOMContentLoaded" | "winscroll" | "winload" | "winfocus" | "winblur" | "winkeydown" | "winkeypress" | "winkeyup";
73
+ declare class Elem<T extends Elements = HTMLElement> extends Eget<T> {
74
+ add(...className: string[]): () => void;
75
+ remove(...className: string[]): this;
76
+ toggle(className: string | fn<any, string>, force?: boolean): boolean;
77
+ /**
78
+ * Boolean toggle
79
+ * @param className
80
+ * @param force
81
+ * @returns
82
+ */
83
+ toggled(bool: boolean, className: string): this;
84
+ clear(): this;
85
+ hasNode(e: Node): boolean;
86
+ has(...classes: string[]): boolean;
87
+ insert(position: InsertPosition): {
88
+ /** Trusted application-authored HTML only. Use text or rendered content for data. */
89
+ HTML: (...text: string[]) => Elem<T>;
90
+ element: (...elem: Element[]) => Elem<T>;
91
+ text: (...text: string[]) => Elem<T>;
92
+ };
93
+ is(tp: {
94
+ dom?: string;
95
+ class?: string | string[];
96
+ }): boolean;
97
+ on(event: ElementEventName, handler: (e?: any) => void, useCapture?: boolean): this;
98
+ remove_on(event: keyof DocumentEventMap, handler: EventListenerOrEventListenerObject, useCapture?: boolean): this;
99
+ timed(fn: (ee?: Elem<T>) => void, timeout?: number): this;
100
+ animate(keyframes: KFType, options?: kf, onComplete?: fn<any, void>): this;
101
+ animate(keyframes: KFType, onComplete?: fn<any, void>): this;
102
+ query(query: string): T | null;
103
+ queryAll(query: string): T[];
104
+ newChild<P>(element: keyof HTMLElementTagNameMap, props?: Record<string, P>): Elem<HTMLAnchorElement | HTMLAreaElement | HTMLAudioElement | HTMLBRElement | HTMLBaseElement | HTMLBodyElement | HTMLButtonElement | HTMLCanvasElement | HTMLDListElement | HTMLDataElement | HTMLDataListElement | HTMLDetailsElement | HTMLDialogElement | HTMLDivElement | HTMLElement | HTMLEmbedElement | HTMLFieldSetElement | HTMLFormElement | HTMLHRElement | HTMLHeadElement | HTMLHeadingElement | HTMLHtmlElement | HTMLIFrameElement | HTMLImageElement | HTMLInputElement | HTMLLIElement | HTMLLabelElement | HTMLLegendElement | HTMLLinkElement | HTMLMapElement | HTMLMenuElement | HTMLMetaElement | HTMLMeterElement | HTMLModElement | HTMLOListElement | HTMLObjectElement | HTMLOptGroupElement | HTMLOptionElement | HTMLOutputElement | HTMLParagraphElement | HTMLPictureElement | HTMLPreElement | HTMLProgressElement | HTMLQuoteElement | HTMLScriptElement | HTMLSelectElement | HTMLSlotElement | HTMLSourceElement | HTMLSpanElement | HTMLStyleElement | HTMLTableCaptionElement | HTMLTableCellElement | HTMLTableColElement | HTMLTableElement | HTMLTableRowElement | HTMLTableSectionElement | HTMLTemplateElement | HTMLTextAreaElement | HTMLTimeElement | HTMLTitleElement | HTMLTrackElement | HTMLUListElement | HTMLVideoElement>;
105
+ newChildNS<P>(element: keyof SVGElementTagNameMap, props?: Record<string, P>): Elem<SVGAElement | SVGAnimateElement | SVGAnimateMotionElement | SVGAnimateTransformElement | SVGCircleElement | SVGClipPathElement | SVGDefsElement | SVGDescElement | SVGEllipseElement | SVGFEBlendElement | SVGFEColorMatrixElement | SVGFEComponentTransferElement | SVGFECompositeElement | SVGFEConvolveMatrixElement | SVGFEDiffuseLightingElement | SVGFEDisplacementMapElement | SVGFEDistantLightElement | SVGFEDropShadowElement | SVGFEFloodElement | SVGFEFuncAElement | SVGFEFuncBElement | SVGFEFuncGElement | SVGFEFuncRElement | SVGFEGaussianBlurElement | SVGFEImageElement | SVGFEMergeElement | SVGFEMergeNodeElement | SVGFEMorphologyElement | SVGFEOffsetElement | SVGFEPointLightElement | SVGFESpecularLightingElement | SVGFESpotLightElement | SVGFETileElement | SVGFETurbulenceElement | SVGFilterElement | SVGForeignObjectElement | SVGGElement | SVGImageElement | SVGLineElement | SVGLinearGradientElement | SVGMPathElement | SVGMarkerElement | SVGMaskElement | SVGMetadataElement | SVGPathElement | SVGPatternElement | SVGPolygonElement | SVGPolylineElement | SVGRadialGradientElement | SVGRectElement | SVGSVGElement | SVGScriptElement | SVGSetElement | SVGStopElement | SVGStyleElement | SVGSwitchElement | SVGSymbolElement | SVGTSpanElement | SVGTextElement | SVGTextPathElement | SVGTitleElement | SVGUseElement | SVGViewElement>;
106
+ get<K extends keyof T>(property: K): T[K];
107
+ get(property: string): unknown;
79
108
  }
80
109
 
81
- interface metaViewport {
82
- width?: string;
83
- height?: string;
84
- initialScale?: string;
85
- minimumScale?: string;
86
- maximumScale?: string;
87
- userScalable?: string;
88
- interactiveWidget?: string;
89
- }
90
- interface httpeQuiv {
91
- contentSecurityPolicy?: string;
92
- contentType?: string;
93
- defaultStyle?: string;
94
- refresh?: string;
95
- cacheControl?: string;
96
- xUaCompatible?: string;
97
- }
98
- interface OG {
99
- title?: string;
100
- description?: string;
101
- image?: string;
102
- url?: string;
103
- type?: string;
104
- card?: "summary" | "summary_large_image" | "app" | "player";
105
- }
106
- type meta$1<T> = {
107
- charset?: T;
108
- content?: T;
109
- "http-equiv"?: T;
110
- name?: T;
111
- property?: T;
112
- media?: T;
113
- url?: T;
114
- };
115
- declare class Meta {
116
- metas: Record<string, string>[];
117
- constructor(description?: string);
118
- author(name: string): this;
119
- charset(val: string): this;
120
- keywords(...keyword: string[]): this;
121
- viewport(vport: metaViewport): this;
122
- httpEquiv(httpeQuiv: httpeQuiv): this;
123
- robots(...robot: ("index" | "noindex" | "follow" | "nofollow")[]): this;
124
- themeColor(color: string): this;
125
- openGraph(og: Omit<OG, "card">): this;
126
- twitter(og: OG): this;
127
- push(metas: meta$1<string>[]): void;
128
- private set meta(value);
110
+ type Elements = HTMLElementTagNameMap[keyof HTMLElementTagNameMap] | SVGElementTagNameMap[keyof SVGElementTagNameMap];
111
+ type TagNames = keyof HTMLElementTagNameMap | keyof SVGElementTagNameMap;
112
+ declare const getElementById: (key: string) => Elements | undefined;
113
+ declare function IDNotConnected(): string[];
114
+ interface CLI {
115
+ id?: string;
116
+ class?: string;
129
117
  }
118
+ declare function $<T extends Elements = HTMLElement, P extends Elements = HTMLElement>(query: CLI, parent?: P): Elem<T> | undefined;
119
+ declare function $<T extends Elements = HTMLElement, P extends Elements = HTMLElement>(query: string, parent?: P): Elem<T> | undefined;
120
+ declare function $<T extends Elements = HTMLElement>(element: T): Elem<T>;
121
+ type _$<T extends Elements = HTMLElement> = Elem<T> | undefined;
122
+ type $_<T extends Elements = HTMLElement> = Elem<T>;
130
123
 
131
- type meta<T> = {
132
- charset?: T;
133
- content?: T;
134
- "http-equiv"?: T;
135
- name?: T;
136
- property?: T;
137
- media?: T;
138
- url?: T;
139
- };
140
- type link<T> = {
141
- href?: T;
142
- hreflang?: T;
143
- media?: T;
144
- referrerpolicy?: T;
145
- rel?: "stylesheet" | "icon" | "manifest" | T;
146
- sizes?: T;
147
- title?: T;
148
- type?: T;
149
- as?: T;
150
- crossorigin?: T;
151
- };
152
- type impmap = {
153
- imports?: obj$1<string>;
154
- scopes?: obj$1<string>;
155
- integrity?: obj$1<string>;
156
- };
157
- type script<T> = {
158
- async?: T;
159
- crossorigin?: T;
160
- defer?: T;
161
- integrity?: T;
162
- nomodule?: T;
163
- referrerpolicy?: T;
164
- src?: T;
165
- type?: "text/javascript" | T;
166
- id?: T;
167
- importmap?: impmap;
168
- body?: T;
169
- };
170
- type base<T> = {
171
- href?: T;
172
- target?: "_blank" | "_parent" | "_self" | "_top";
173
- };
174
- interface headAttr {
175
- title?: string;
176
- base?: base<string>[];
177
- meta?: meta<string>[] | Meta;
178
- link?: link<string>[];
179
- script?: script<string | boolean>[];
180
- css?: string[] | string;
181
- js?: string[] | string;
182
- description?: string;
183
- }
184
- declare abstract class head implements headAttr {
185
- title?: string;
186
- description?: string;
187
- css?: string[] | string;
188
- js?: string[] | string;
189
- meta?: meta<string>[] | Meta;
190
- link?: link<string>[];
191
- script?: script<string | boolean>[];
192
- }
193
- type CSSinT = {
194
- [P in keyof CSSStyleDeclaration]?: V;
195
- } & {
196
- [key: string]: V;
197
- };
198
- type headType = Mapper<keyof headAttr, any>;
199
- interface hHeadCFG {
200
- initial?: headType;
201
- mark?: boolean;
202
- push?: obj$1<any>;
203
- }
204
- declare class htmlHead {
205
- lang: string;
206
- htmlHead: headType;
207
- head: (heads?: Omit<headAttr, "base">) => void;
208
- constructor({ mark, push }?: hHeadCFG);
209
- }
210
- declare const cssLoader: (vv: link<string>) => Promise<HTMLLinkElement | undefined>;
211
- declare function addCSS(selector: string, rules?: CSSinT): void;
124
+ /** Selects one of two values using a boolean condition. */
125
+ declare function Toggled<T>(bool: boolean, value: T): T | undefined;
126
+ declare function Toggled<T, U>(bool: boolean, value: T, otherwise: U): T | U;
212
127
 
213
- declare class MinStorage {
214
- readonly path: string;
215
- readonly parsed: string[];
216
- readonly args: string[];
217
- constructor(path: string);
128
+ interface RenderedContent {
129
+ html: string;
130
+ commit?: () => void | Promise<void>;
218
131
  }
132
+ type ContentRenderer = (value: unknown, parentId?: string) => RenderedContent | Promise<RenderedContent>;
133
+ declare const setContentRenderer: (next: ContentRenderer) => () => void;
134
+ declare const renderContent: (value: unknown, parentId?: string) => Promise<RenderedContent>;
219
135
 
220
- /** --------------------
221
- * string | int | float | file | uuid
222
- * - /path/\<string:hell>
223
- */
224
- declare class Storage<T extends MinStorage> {
225
- private _storage;
226
- private CC;
227
- constructor();
228
- set(min: T): void;
229
- get(path: string): [T | undefined, Record<string, string>];
230
- keys(): MapIterator<string>;
136
+ /** Holds a mutable value and emits an `updated` event when it changes. */
137
+ declare class RefState<T> extends EventTarget {
138
+ private current;
139
+ constructor(current: T);
140
+ get value(): T;
141
+ get clone(): T;
142
+ set value(value: T);
143
+ }
144
+ declare class Ref<T extends Element = HTMLElement> {
145
+ readonly state: RefState<T | undefined>;
146
+ get element(): T | undefined;
147
+ set element(element: T | undefined);
148
+ get $(): T | undefined;
231
149
  }
150
+ declare const useRef: <T extends Element = HTMLElement>() => Ref<T>;
151
+
152
+ /** Synchronous, nestable batching. Values change immediately; subscribers see the final values. */
153
+ declare function batch<T>(callback: () => T): T;
232
154
 
233
- declare class Time {
234
- date: Date;
235
- constructor(dateMS?: number);
236
- delta(date2?: number | null, _Date?: boolean): number | Date;
237
- timed(time?: {
238
- year?: number;
239
- month?: number;
240
- day?: number;
241
- hour?: number;
242
- minute?: number;
243
- second?: number;
244
- }): Date;
245
- static delta(date1: number, date2?: number | null): number;
246
- static local(date: number): string;
247
- static get now(): number;
155
+ type Equality<T> = (previous: T, next: T) => boolean;
156
+ /** Compares own enumerable keys of records/arrays, using Object.is for values. */
157
+ declare function shallowEqual<T>(previous: T, next: T): boolean;
158
+
159
+ type Cleanup = () => void;
160
+ type Disposable = {
161
+ dispose(): void;
162
+ } | {
163
+ close(): void;
164
+ };
165
+ /** Synchronous resource ownership. Disposal is idempotent and attempts every cleanup. */
166
+ declare class DisposalScope {
167
+ private readonly controller;
168
+ private readonly cleanups;
169
+ get signal(): AbortSignal;
170
+ get disposed(): boolean;
171
+ defer(cleanup: Cleanup): Cleanup;
172
+ own<T extends Disposable>(resource: T): T;
173
+ listen(target: EventTarget, type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): Cleanup;
174
+ timeout(callback: () => void, ms: number): Cleanup;
175
+ dispose(): void;
248
176
  }
249
177
 
250
- declare class __ {
251
- static rand(min?: number, max?: number): number;
252
- static fill(count: number, fill?: any): any[];
253
- static new({ dom, id, inner, }: {
254
- dom: keyof HTMLElementTagNameMap | keyof SVGElementTagNameMap;
255
- id?: string;
256
- inner?: any;
257
- }): HTMLElement;
258
- static randFrom(arr: any[] | Object): any;
259
- static randArray<T>(arr?: T[], length?: number, unique?: boolean): T[];
260
- static randomAZ: () => string;
261
- static makeID: (length: number) => string;
262
- static class(a: obj$1<any>, ...classes: (string | undefined | boolean)[]): void;
263
- static get O(): {
264
- vals: {
265
- <T>(o: {
266
- [s: string]: T;
267
- } | ArrayLike<T>): T[];
268
- (o: {}): any[];
269
- };
270
- keys: {
271
- (o: object): string[];
272
- (o: {}): string[];
273
- };
274
- items: {
275
- <T>(o: {
276
- [s: string]: T;
277
- } | ArrayLike<T>): [string, T][];
278
- (o: {}): [string, any][];
279
- };
280
- has: (o: object, v: PropertyKey) => boolean;
281
- ass: {
282
- <T extends {}, U>(target: T, source: U): T & U;
283
- <T extends {}, U, V>(target: T, source1: U, source2: V): T & U & V;
284
- <T extends {}, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
285
- (target: object, ...sources: any[]): any;
286
- };
287
- len: (obj?: {}) => number;
288
- };
289
- static get is(): typeof is;
290
- static get return(): typeof returner;
291
- static isHREF(pt: string, hpt: string): boolean;
292
- static sleep: (ms?: number) => Promise<unknown>;
293
- static get screen(): "xs" | "sm" | "smd" | "md" | "lg" | "xl" | "xxl" | undefined;
294
- bytes(bytes: number): string;
295
- static format(val: any): Formatteer;
296
- static compareObjects: <T extends object>(oldObj: T, newObj: T | any) => {
297
- added: Record<string, any>;
298
- removed: Record<string, any>;
299
- modified: Record<string, {
300
- old: any;
301
- new: any;
302
- }>;
303
- };
304
- static isObjectUdpated: (changes: {
305
- added: Record<string, any>;
306
- removed: Record<string, any>;
307
- modified: Record<string, {
308
- old: any;
309
- new: any;
310
- }>;
311
- }) => boolean;
312
- }
313
- declare class returner {
314
- static arr<T = string>(val?: any): T[];
315
- static num(val: any, iferr?: any): number;
316
- static str(val: any): string;
317
- static arr2obj(val: any[], switched?: boolean): any;
318
- }
319
- declare class Formatteer {
320
- val: any;
321
- constructor(val: any);
322
- get px(): string;
323
- get rem(): string;
324
- get pr(): string;
178
+ type V = string | number | boolean;
179
+ type maybePromise<T> = T | Promise<T>;
180
+ declare class Mapper<K, V> extends Map<K, V> {
181
+ obj(value?: object | null): this;
182
+ init(key: K, value: V): V;
325
183
  }
326
184
 
327
185
  type hookFN<T extends any[]> = (...args: statefulValue<T>) => maybePromise<void>;
328
- interface stateCFG {
186
+ interface StateHookOptions {
329
187
  id?: string;
330
188
  init?: boolean;
189
+ signal?: AbortSignal;
190
+ scope?: DisposalScope;
331
191
  }
332
192
  declare function StateHook<T extends any[]>(callback: hookFN<T>, statefuls: [...{
333
- [K in keyof T]: Stateful<T[K]>;
334
- }], { id, init }?: stateCFG): Promise<() => void>;
193
+ [K in keyof T]: IStateful<T[K]>;
194
+ }], { id, init, signal, scope }?: StateHookOptions): Promise<() => void>;
195
+ declare function StateLoaded<T extends any[]>(callback: hookFN<T>, statefuls: [...{
196
+ [K in keyof T]: IStateful<T[K]>;
197
+ }], { id, init, signal, scope }?: StateHookOptions): Promise<() => void>;
198
+ declare function hook<T extends any[]>(callback: hookFN<T>, statefuls: [...{
199
+ [K in keyof T]: IStateful<T[K]>;
200
+ }], init?: boolean): [hookFN<T>, [...{
201
+ [K in keyof T]: IStateful<T[K]>;
202
+ }], boolean, boolean];
203
+ declare function loaded<T extends any[]>(callback: hookFN<T>, statefuls: [...{
204
+ [K in keyof T]: IStateful<T[K]>;
205
+ }], init?: boolean): [hookFN<T>, [...{
206
+ [K in keyof T]: IStateful<T[K]>;
207
+ }], boolean, boolean];
208
+ /** Cooperative async effects: a newer update or disposal aborts the previous context. */
209
+ declare function StateEffect<T extends any[]>(callback: (update: StateUpdate, ...values: statefulValue<T>) => maybePromise<void>, states: [...{
210
+ [K in keyof T]: IStateful<T[K]>;
211
+ }], options?: StateHookOptions): Promise<() => void>;
212
+
213
+ interface StateOptions<T> extends AddEventListenerOptions {
214
+ /** false emits on every assignment; otherwise true means unchanged. */
215
+ equals?: Equality<T> | false;
216
+ /** Errors are also retained until flush() observes them. */
217
+ onError?: (error: unknown) => void;
218
+ }
335
219
 
336
220
  type statefulValue<T extends any[]> = {
337
- [K in keyof T]: T[K] extends Stateful<infer U> ? U : T[K];
221
+ [K in keyof T]: T[K] extends IStateful<infer U> ? U : T[K];
338
222
  };
223
+ interface StateUpdate {
224
+ readonly signal: AbortSignal;
225
+ isCurrent(): boolean;
226
+ }
339
227
  declare class Stateful<T> extends EventTarget {
340
228
  private options;
341
- private deep;
342
- private verify;
343
229
  private hooks;
230
+ private loads;
344
231
  private states;
345
- private _value;
232
+ protected _value: T;
346
233
  private listening;
234
+ private controller;
235
+ private readonly pending;
236
+ private readonly failures;
237
+ private readonly emit;
347
238
  private end?;
348
- constructor(value: T, options?: AddEventListenerOptions, deep?: boolean, verify?: boolean);
239
+ constructor(value: T, options?: StateOptions<T>);
349
240
  get value(): T;
241
+ get clone(): T;
350
242
  set value(newValue: T);
351
- get listen(): () => void;
352
- call<Q>(callback: (this: Elements, arg: T) => Q, entry: string): (id: string) => () => void;
353
- hook<T extends any[]>(callback: hookFN<T>): (id: string) => () => void;
243
+ /** Wait for current framework hooks, DOM bindings and loaded hooks; reject observed errors once. */
244
+ flush(): Promise<void>;
245
+ private report;
246
+ private update;
247
+ listen(): () => void;
248
+ private stopListeningWhenUnused;
249
+ call<Q>(callback: (this: Elements, arg: T, update: StateUpdate) => Q, entry: string): (id: string) => Promise<() => void>;
250
+ hook(callback: (update: StateUpdate) => unknown): (id: string) => Promise<() => void>;
251
+ loaded<T extends any[]>(callback: hookFN<T>): (id: string) => () => void;
252
+ protected dispatch(): void;
253
+ }
254
+ declare class SetStateful<T extends unknown> extends Stateful<Set<T>> {
255
+ constructor(vals: T[], options?: AddEventListenerOptions);
256
+ add(val: T): void;
257
+ delete(val: T): void;
258
+ has(val: T): boolean;
259
+ clear(): void;
260
+ }
261
+ declare class RecStateful<T extends {}> extends Stateful<T> {
262
+ constructor(val: T, options?: AddEventListenerOptions);
263
+ set<X extends keyof T>(t: X, value: T[X]): void;
264
+ delete(t: keyof T): void;
265
+ entries(): [string, unknown][];
266
+ }
267
+ type IRecStateful<T extends {}> = IStateful<T> & {
268
+ set: RecStateful<T>["set"];
269
+ delete: RecStateful<T>["delete"];
270
+ entries: RecStateful<T>["entries"];
271
+ };
272
+ type ISetStateful<T extends unknown> = IStateful<Set<T>> & {
273
+ add: SetStateful<T>["add"];
274
+ delete: SetStateful<T>["delete"];
275
+ has: SetStateful<T>["has"];
276
+ clear: SetStateful<T>["clear"];
277
+ };
278
+ type IStateful<T> = {
279
+ value: Stateful<T>["value"];
280
+ clone: Stateful<T>["clone"];
281
+ flush: Stateful<T>["flush"];
282
+ };
283
+ declare function State<T>(value: T, options?: StateOptions<T>): IStateful<T>;
284
+ declare function SetState<T extends unknown>(value: T[], options?: AddEventListenerOptions): ISetStateful<T>;
285
+ declare function RecState<T extends {}>(value: T, options?: AddEventListenerOptions): IRecStateful<T>;
286
+ /**
287
+ * @deprecated Prefer State(value, { equals: false }).
288
+ * Legacy convenience: by default emit on every assignment. Prefer State with equals: false.
289
+ */
290
+ declare function QState<T>(value: T, verify?: boolean): IStateful<T>;
291
+
292
+ type ScopeConfig = Record<string, object>;
293
+
294
+ interface ScopeSet<C extends ScopeConfig> {
295
+ use<Name extends keyof C & string>(name: Name): C[Name];
296
+ }
297
+ /** Shared named objects, exposed through the static register/use interface. */
298
+ declare class _Scope {
299
+ private constructor();
300
+ /** An independent container. It never publishes values to global Scope/Field. */
301
+ static create<C extends ScopeConfig>(config: C): ScopeSet<C>;
302
+ static register<C extends ScopeConfig>(config: C): ScopeSet<C>;
303
+ /** Prefer the typed handle returned by register when it is available. */
304
+ static use<TValue extends object>(name: string): TValue;
305
+ }
306
+ /** Describes the static interface of the Scope class. */
307
+ interface ScopeStatic {
308
+ create<C extends ScopeConfig>(config: C): ScopeSet<C>;
309
+ register<Config extends Record<string, Record<string, any>>>(data: Config): ScopeSet<Config>;
310
+ use<T extends Record<string, any>>(name: string): T;
311
+ }
312
+ type Scope = _Scope;
313
+ declare const Scope: ScopeStatic;
314
+
315
+ type ScopeDecorator<V> = <This>(value: undefined, context: ClassFieldDecoratorContext<This, V>) => (this: This, initialValue: V) => V;
316
+ type ScopeProxy<T extends object> = {
317
+ readonly [K in keyof T]: ScopeDecorator<T[K]>;
318
+ };
319
+ interface FieldScopeSet<C extends ScopeConfig> {
320
+ use<Name extends keyof C & string>(name: Name): ScopeProxy<C[Name]>;
321
+ }
322
+ /** Standard class-field decorators backed by the same registry as Scope. */
323
+ declare class _FieldScope {
324
+ static register<C extends ScopeConfig>(config: C): FieldScopeSet<C>;
325
+ static use<T extends object>(name: string): ScopeProxy<T>;
354
326
  }
355
- declare function State<T>(value: T, options?: AddEventListenerOptions): Stateful<T>;
356
327
  /**
357
- * Quick State checking - skip checking of Object keys:values as it will only be compared as a===b
328
+ * Describes the static interface of the Field class
358
329
  */
359
- declare function QState<T>(value: T, verify?: boolean): Stateful<T>;
330
+ interface FieldScopeStatic {
331
+ register<Config extends Record<string, Record<string, any>>>(data: Config): FieldScopeSet<Config>;
332
+ use<T extends Record<string, any>>(name: string): ScopeProxy<T>;
333
+ }
334
+ type Field = _FieldScope;
335
+ declare const Field: FieldScopeStatic;
336
+
337
+ declare class Stored<T extends Record<PropertyKey, unknown>> {
338
+ private readonly state;
339
+ private readonly dev;
340
+ constructor(initial: T, options?: {
341
+ dev?: boolean;
342
+ });
343
+ get __(): T;
344
+ bind(values: Partial<T>): void;
345
+ set<K extends keyof T, P extends keyof T[K]>(key: K, prop: P, value: T[K][P]): void;
346
+ fn<R>(fn: (state: T) => R): () => R;
347
+ safe<K extends keyof T>(key: K): NonNullable<T[K]>;
348
+ }
349
+
350
+ type successStatus<T extends Record<string, unknown> = {}> = {
351
+ success: boolean;
352
+ data: T;
353
+ message?: string;
354
+ };
355
+ type errorStatus = {
356
+ success: boolean;
357
+ error: {
358
+ message: string;
359
+ code: string;
360
+ } & Record<string, unknown>;
361
+ };
362
+
363
+ type EventHandler = (event: MessageEvent) => void;
364
+ type EventMap = Record<string, EventHandler>;
365
+ declare class EventStream {
366
+ readonly url: string;
367
+ readonly stream: EventSource;
368
+ private readonly handlers;
369
+ private closed;
370
+ constructor(url: string, withCredentials?: boolean);
371
+ on(events: EventMap): this;
372
+ off(eventName?: string, handler?: EventHandler): this;
373
+ close(): void;
374
+ }
375
+ /** @deprecated Prefer dedicated eventStreams(); retain EventStream when sharing a connection intentionally. */
376
+ declare function eventStream(url: string, withCredentials?: boolean): EventStream;
377
+
378
+ type ColumnType = "text" | "integer" | "number" | "boolean" | "date" | "json";
379
+ /** Validation and index metadata; IndexedDB itself is schemaless. */
380
+ declare class Column {
381
+ readonly type: ColumnType;
382
+ primaryKey: boolean;
383
+ required: boolean;
384
+ isUnique: boolean;
385
+ indexed: boolean;
386
+ autoIncrement: boolean;
387
+ hasDefault: boolean;
388
+ private defaultValue;
389
+ constructor(type: ColumnType);
390
+ get primary(): this;
391
+ get notNull(): this;
392
+ get index(): this;
393
+ get unique(): this;
394
+ get defaultNow(): this;
395
+ default(value: unknown | (() => unknown)): this;
396
+ value(): unknown;
397
+ validate(name: string, value: unknown): void;
398
+ }
399
+ declare const t: {
400
+ text: () => Column;
401
+ int: () => Column;
402
+ number: () => Column;
403
+ boolean: () => Column;
404
+ timestamp: () => Column;
405
+ json: () => Column;
406
+ serial: () => Column;
407
+ };
408
+
409
+ declare class Schema<T extends object> {
410
+ readonly table: string;
411
+ private readonly definitions;
412
+ readonly keyPath: string;
413
+ readonly autoIncrement: boolean;
414
+ constructor(table: string, definitions: Record<keyof T, Column>);
415
+ entries(): Array<[string, Column]>;
416
+ prepare(input: Partial<T>): T;
417
+ /** Call only within an IndexedDB versionchange transaction. */
418
+ upgrade(db: IDBDatabase, transaction: IDBTransaction): void;
419
+ }
420
+
421
+ declare class DbRepository<T extends object> {
422
+ private readonly db;
423
+ readonly schema: Schema<T>;
424
+ constructor(db: IDBDatabase, schema: Schema<T>);
425
+ insert(input: Partial<T>): Promise<IDBValidKey>;
426
+ /** Replaces the whole record, or inserts it when its key does not exist. */
427
+ put(input: Partial<T>): Promise<IDBValidKey>;
428
+ find(key: IDBValidKey): Promise<T | undefined>;
429
+ findAll(query?: IDBValidKey | IDBKeyRange, limit?: number): Promise<T[]>;
430
+ findByIndex(name: keyof T & string, query?: IDBValidKey | IDBKeyRange, limit?: number): Promise<T[]>;
431
+ private readAll;
432
+ /** Reads and patches the record in the same atomic transaction. */
433
+ update(key: IDBValidKey, changes: Partial<T>): Promise<T | undefined>;
434
+ count(query?: IDBValidKey | IDBKeyRange): Promise<number>;
435
+ delete(key: IDBValidKey | IDBKeyRange): Promise<void>;
436
+ clear(): Promise<void>;
437
+ }
438
+
439
+ type StoreSchema = Pick<Schema<object>, "table" | "keyPath" | "autoIncrement" | "entries" | "upgrade">;
440
+ interface OpenOptions {
441
+ /** Useful for tests or a worker-specific factory. Defaults to globalThis.indexedDB. */
442
+ factory?: IDBFactory;
443
+ /** Ask other tabs to close their connections. The open request remains pending. */
444
+ onBlocked?: (event: IDBVersionChangeEvent) => void;
445
+ /** Runs after declared stores/indexes are created. Queue IDB requests synchronously. */
446
+ upgrade?: (db: IDBDatabase, transaction: IDBTransaction, oldVersion: number, newVersion: number) => void;
447
+ }
448
+ declare class IndexedDatabase {
449
+ readonly connection: IDBDatabase;
450
+ private readonly schemas;
451
+ private constructor();
452
+ static open(name: string, version: number, schemas: readonly StoreSchema[], options?: OpenOptions): Promise<IndexedDatabase>;
453
+ repository<T extends object>(schema: Schema<T>): DbRepository<T>;
454
+ close(): void;
455
+ }
456
+
457
+ type DerivedValue<T> = Readonly<IStateful<T>> & {
458
+ dispose(): void;
459
+ };
460
+ interface DerivedOptions<T> extends StateOptions<T> {
461
+ scope?: DisposalScope;
462
+ }
463
+ /** Explicit dependencies; await installation before changing inputs. Calculations are synchronous. */
464
+ declare function Derived<T extends unknown[], R>(states: [...{
465
+ [K in keyof T]: IStateful<T[K]>;
466
+ }], compute: (...values: T) => R extends PromiseLike<unknown> ? never : R, options?: DerivedOptions<R>): Promise<DerivedValue<R>>;
360
467
 
468
+ type DVal<T = V | V[]> = T | IStateful<T> | undefined;
469
+
470
+ type CSSStyleProperty = {
471
+ [P in keyof CSSStyleDeclaration]: CSSStyleDeclaration[P] extends (...args: any[]) => any ? never : P;
472
+ }[keyof CSSStyleDeclaration];
361
473
  type CSSStyle = {
362
- [P in keyof CSSStyleDeclaration]?: DVal;
474
+ [P in CSSStyleProperty]?: DVal;
363
475
  } & {
364
- [key: string]: DVal;
476
+ [key: `--${string}`]: DVal;
365
477
  };
366
478
 
367
479
  interface c_events<T extends Elements = HTMLElement> {
368
- state?: (this: T, e: T) => [(...args: any[]) => void, Stateful<any>[], boolean?];
369
- ready?: (this: T, e: T) => void;
480
+ state?: (this: T, e: T) => maybePromise<[
481
+ (...args: any[]) => void,
482
+ IStateful<any>[],
483
+ boolean?,
484
+ boolean?
485
+ ]>;
486
+ states?: (this: T, e: T) => maybePromise<[
487
+ (...args: any[]) => void,
488
+ IStateful<any>[],
489
+ boolean?,
490
+ boolean?
491
+ ]>[];
492
+ ready?: (this: T, e: T) => maybePromise<void | (() => void)>;
370
493
  resize?: (this: T, e: UIEvent) => void;
371
494
  beforeunload?: (this: T, e: BeforeUnloadEvent) => void;
372
495
  popstate?: (this: T, e: PopStateEvent) => void;
496
+ DOMContentLoaded?: (this: T, e: Event) => void;
373
497
  winscroll?: (this: T, e: Event) => void;
374
498
  winload?: (this: T, e: Event) => void;
375
499
  winfocus?: (this: T, e: Event) => void;
376
500
  winblur?: (this: T, e: Event) => void;
501
+ winkeydown?: (this: T, e: KeyboardEvent) => void;
502
+ winkeypress?: (this: T, e: KeyboardEvent) => void;
503
+ winkeyup?: (this: T, e: KeyboardEvent) => void;
377
504
  }
505
+ type DOMEvents<T extends Elements = HTMLElement> = {
506
+ [P in keyof GlobalEventHandlersEventMap]?: (this: T, event: GlobalEventHandlersEventMap[P]) => void;
507
+ } & c_events<T>;
378
508
 
379
509
  interface EAttr<T = DVal> {
380
510
  [key: string]: any;
381
511
  [key: `data-${string}`]: T | any;
382
512
  accesskey?: T;
383
513
  autocapitalize?: T;
384
- class?: T;
385
- on?: events<any>;
514
+ class?: T | T[];
515
+ on?: DOMEvents<any>;
516
+ ref?: Ref<any>;
386
517
  contenteditable?: T;
387
518
  dir?: T;
388
519
  draggable?: T;
@@ -398,174 +529,24 @@ interface EAttr<T = DVal> {
398
529
  title?: T;
399
530
  translate?: T;
400
531
  }
401
- interface ElementAttributes {
402
- link: linkAttr;
403
- base: baseAttr;
404
- meta: metaAttr;
405
- p: EAttr;
406
- br: EAttr;
407
- hr: EAttr;
408
- h: EAttr;
409
- cmnt: EAttr;
410
- root: EAttr;
411
- div: EAttr;
412
- span: EAttr;
413
- header: EAttr;
414
- hgroup: EAttr;
415
- footer: EAttr;
416
- main: EAttr;
417
- section: EAttr;
418
- search: EAttr;
419
- article: EAttr;
420
- aside: EAttr;
421
- details: detailsAttr;
422
- dialog: dialogAttr;
423
- summary: EAttr;
424
- data: dataAttr;
425
- noscript: EAttr;
426
- object: objectAttr;
427
- param: paramAttr;
428
- script: scriptAttr;
429
- a: aAttr;
430
- nav: EAttr;
431
- style: styleAttr;
432
- audio: audioAttr;
433
- video: videoAttr;
434
- source: sourceAttr;
435
- track: trackAttr;
436
- img: imgAttr;
437
- map: mapAttr;
438
- area: areaAttr;
439
- canvas: canvasAttr;
440
- figcaption: EAttr;
441
- figure: EAttr;
442
- picture: EAttr;
443
- iframe: iframeAttr;
444
- form: formAttr;
445
- input: inputAttr;
446
- textarea: textareaAttr;
447
- button: buttonAttr;
448
- select: selectAttr;
449
- optgroup: optgroupAttr;
450
- option: optionAttr;
451
- label: labelAttr;
452
- fieldset: fieldsetAttr;
453
- legend: EAttr;
454
- datalist: EAttr;
455
- table: EAttr;
456
- caption: EAttr;
457
- th: thAttr;
458
- tr: EAttr;
459
- td: tdAttr;
460
- thead: EAttr;
461
- tbody: EAttr;
462
- tfoot: EAttr;
463
- col: colAttr;
464
- colgroup: colgroupAttr;
465
- b: EAttr;
466
- i: EAttr;
467
- q: qAttr;
468
- s: EAttr;
469
- u: EAttr;
470
- em: EAttr;
471
- rp: EAttr;
472
- del: delAttr;
473
- dfn: EAttr;
474
- ins: insAttr;
475
- kbd: EAttr;
476
- pre: EAttr;
477
- sub: EAttr;
478
- sup: EAttr;
479
- var: EAttr;
480
- wbr: EAttr;
481
- cite: EAttr;
482
- time: timeAttr;
483
- abbr: EAttr;
484
- code: EAttr;
485
- mark: EAttr;
486
- samp: EAttr;
487
- meter: meterAttr;
488
- small: EAttr;
489
- strong: EAttr;
490
- address: EAttr;
491
- progress: progressAttr;
492
- template: EAttr;
493
- blockquote: blockquoteAttr;
494
- menu: menuAttr;
495
- ul: EAttr;
496
- ol: olAttr;
497
- li: liAttr;
498
- dl: EAttr;
499
- dt: EAttr;
500
- dd: EAttr;
501
- h1: EAttr;
502
- h2: EAttr;
503
- h3: EAttr;
504
- h4: EAttr;
505
- h5: EAttr;
506
- h6: EAttr;
507
- }
508
- interface SVGAttributes {
509
- svg: EAttr;
510
- path: EAttr;
511
- circle: EAttr;
512
- animate: EAttr;
513
- animateMotion: EAttr;
514
- animateTransform: EAttr;
515
- clipPath: EAttr;
516
- defs: EAttr;
517
- desc: EAttr;
518
- ellipse: EAttr;
519
- feBlend: EAttr;
520
- feColorMatrix: EAttr;
521
- feComponentTransfer: EAttr;
522
- feComposite: EAttr;
523
- feConvolveMatrix: EAttr;
524
- feDiffuseLighting: EAttr;
525
- feDisplacementMap: EAttr;
526
- feDistantLight: EAttr;
527
- feDropShadow: EAttr;
528
- feFlood: EAttr;
529
- feFuncA: EAttr;
530
- feFuncB: EAttr;
531
- feFuncG: EAttr;
532
- feFuncR: EAttr;
533
- feGaussianBlur: EAttr;
534
- feImage: EAttr;
535
- feMerge: EAttr;
536
- feMergeNode: EAttr;
537
- feMorphology: EAttr;
538
- feOffset: EAttr;
539
- fePointLight: EAttr;
540
- feSpecularLighting: EAttr;
541
- feSpotLight: EAttr;
542
- feTile: EAttr;
543
- feTurbulence: EAttr;
544
- filter: EAttr;
545
- foreignObject: EAttr;
546
- g: EAttr;
547
- image: EAttr;
548
- line: EAttr;
549
- linearGradient: EAttr;
550
- marker: EAttr;
551
- mask: EAttr;
552
- metadata: EAttr;
553
- mpath: EAttr;
554
- pattern: EAttr;
555
- polygon: EAttr;
556
- polyline: EAttr;
557
- radialGradient: EAttr;
558
- rect: EAttr;
559
- set: EAttr;
560
- stop: EAttr;
561
- symbol: EAttr;
562
- text: EAttr;
563
- textPath: EAttr;
564
- title: EAttr;
565
- tspan: EAttr;
566
- use: EAttr;
567
- view: EAttr;
532
+
533
+ type DOMAttr = EAttr;
534
+ type DOMValue<T = V | V[]> = DVal<T>;
535
+ type DOMRenderable = string | number | boolean | null | undefined | DOM | DOMRenderable[] | IStateful<unknown> | object | (() => maybePromise<DOMRenderable>);
536
+ type DOMContext = maybePromise<DOMRenderable>;
537
+ type DOMComponentProps<T extends object = {}> = DOMAttr & T;
538
+ type DOMComponent<T extends object = {}> = (attributes: DOMComponentProps<T>, ...children: DOMContext[]) => maybePromise<DOM>;
539
+ type DOMNode = DOM;
540
+
541
+ declare class DOM {
542
+ tag: string;
543
+ attr: DOMAttr;
544
+ ctx: DOMContext[];
545
+ constructor(tag: string, attr: DOMAttr, ctx: DOMContext[]);
568
546
  }
547
+ declare function dom(tag: string | DOMComponent, attr?: DOMAttr | null, ...ctx: DOMContext[]): Promise<DOM>;
548
+ declare const frag: (_attr: DOMAttr, ...ctx: DOMContext[]) => Promise<DOM>;
549
+
569
550
  interface aAttr<T = DVal> extends EAttr {
570
551
  download?: T;
571
552
  href?: T;
@@ -640,6 +621,12 @@ interface detailsAttr<T = DVal> extends EAttr {
640
621
  interface dialogAttr<T = DVal> extends EAttr {
641
622
  open?: T;
642
623
  }
624
+ interface embedAttr<T = DVal> extends EAttr {
625
+ height?: T;
626
+ src?: T;
627
+ type?: T;
628
+ width?: T;
629
+ }
643
630
  interface fieldsetAttr<T = DVal> extends EAttr {
644
631
  disabled?: T;
645
632
  form?: T;
@@ -784,6 +771,11 @@ interface optionAttr<T = DVal> extends EAttr {
784
771
  selected?: T;
785
772
  value?: T;
786
773
  }
774
+ interface outputAttr<T = DVal> extends EAttr {
775
+ for?: T;
776
+ form?: T;
777
+ name?: T;
778
+ }
787
779
  interface paramAttr<T = DVal> extends EAttr {
788
780
  name?: T;
789
781
  value?: T;
@@ -847,7 +839,7 @@ interface textareaAttr<T = DVal> extends EAttr {
847
839
  rows?: T;
848
840
  wrap?: T;
849
841
  }
850
- interface thAttr<T = DVal> extends EAttr {
842
+ interface thAttr<T = DVal> extends EAttr<T> {
851
843
  colspan?: T;
852
844
  headers?: T;
853
845
  rowspan?: T;
@@ -876,336 +868,687 @@ interface videoAttr<T = DVal> extends EAttr {
876
868
  src?: T;
877
869
  width?: T;
878
870
  }
879
-
880
- type kf = KeyframeAnimationOptions;
881
- type KFType = (CSSStyle | obj$1<V>)[] | CSSStyle | obj$1<V>;
882
- declare class anim {
883
- private e;
884
- opt: kf;
885
- constructor(e: Elem);
886
- animate(keyframes: CSSStyle[] | CSSStyle, options?: kf): Elem<HTMLElement>;
887
- get slide(): {
888
- left: (options?: kf) => anim;
889
- right: (options?: kf) => anim;
890
- up: (options?: kf) => anim;
891
- down: (options?: kf) => anim;
892
- };
893
- fade(options?: kf): this;
894
- shake(XorY?: string, opt?: kf): this;
895
- color(c?: string[], opt?: kf): this;
896
- bg(c?: string | string[], opt?: kf): this;
897
- bounce(sVal?: number, opt?: kf): this;
871
+ interface contenteditableAttr<T = DVal> extends EAttr {
872
+ enterkeyhint?: T;
873
+ inputmode?: T;
898
874
  }
899
875
 
900
- declare class Eget<T extends Elements = HTMLElement> {
901
- e: T;
902
- query?: string | undefined;
903
- constructor(e: T, query?: string | undefined);
904
- get a(): anim;
905
- get all(): T[];
906
- get attr(): {
907
- has: (attr: string) => boolean;
908
- get: (attr: string) => string | null;
909
- del: (attr: string) => Eget<T>;
910
- set: (attrs: obj$1<any>) => Eget<T>;
911
- };
912
- get children(): Elem<T>[];
913
- get click(): this;
914
- get delete(): this;
915
- get disabled(): boolean;
916
- get focus(): this;
917
- get href(): string;
918
- get id(): string;
919
- get inner(): string;
920
- get offsetParent(): Elem | undefined;
921
- get parent(): Elem | undefined;
922
- get hash(): string;
923
- get path(): string;
924
- get rect(): DOMRect;
925
- get remove_element(): this;
926
- get style(): {
927
- set: (style: CSSStyle | obj$1<V | null>, delayOrFN?: number | ((e?: any) => void)) => Elem<HTMLElement>;
928
- get: (prop: keyof CSSStyleDeclaration | string) => string;
929
- del: (...props: (keyof CSSStyleDeclaration | string)[]) => void;
930
- };
931
- get submit(): any;
932
- get tag(): string;
933
- get value(): any;
934
- get unload(): () => void;
935
- set append(val: any);
936
- set appendfirst(val: any);
937
- set inner(val: any);
938
- set disabled(vl: boolean);
939
- set id(did: string);
940
- set value(vl: any);
876
+ interface ElementAttributes {
877
+ link: linkAttr;
878
+ base: baseAttr;
879
+ meta: metaAttr;
880
+ p: EAttr;
881
+ br: EAttr;
882
+ hr: EAttr;
883
+ h: EAttr;
884
+ cmnt: EAttr;
885
+ root: EAttr;
886
+ div: EAttr;
887
+ span: EAttr;
888
+ header: EAttr;
889
+ hgroup: EAttr;
890
+ footer: EAttr;
891
+ main: EAttr;
892
+ section: EAttr;
893
+ search: EAttr;
894
+ article: EAttr;
895
+ aside: EAttr;
896
+ details: detailsAttr;
897
+ dialog: dialogAttr;
898
+ summary: EAttr;
899
+ data: dataAttr;
900
+ noscript: EAttr;
901
+ object: objectAttr;
902
+ param: paramAttr;
903
+ script: scriptAttr;
904
+ output: outputAttr;
905
+ a: aAttr;
906
+ nav: EAttr;
907
+ style: styleAttr;
908
+ audio: audioAttr;
909
+ video: videoAttr;
910
+ source: sourceAttr;
911
+ track: trackAttr;
912
+ img: imgAttr;
913
+ map: mapAttr;
914
+ area: areaAttr;
915
+ canvas: canvasAttr;
916
+ figcaption: EAttr;
917
+ figure: EAttr;
918
+ picture: EAttr;
919
+ iframe: iframeAttr;
920
+ form: formAttr;
921
+ input: inputAttr;
922
+ textarea: textareaAttr;
923
+ button: buttonAttr;
924
+ select: selectAttr;
925
+ optgroup: optgroupAttr;
926
+ option: optionAttr;
927
+ label: labelAttr;
928
+ fieldset: fieldsetAttr;
929
+ legend: EAttr;
930
+ datalist: EAttr;
931
+ table: EAttr;
932
+ caption: EAttr;
933
+ th: thAttr;
934
+ tr: EAttr;
935
+ td: tdAttr;
936
+ thead: EAttr;
937
+ tbody: EAttr;
938
+ tfoot: EAttr;
939
+ col: colAttr;
940
+ colgroup: colgroupAttr;
941
+ b: EAttr;
942
+ i: EAttr;
943
+ q: qAttr;
944
+ s: EAttr;
945
+ u: EAttr;
946
+ em: EAttr;
947
+ rp: EAttr;
948
+ del: delAttr;
949
+ dfn: EAttr;
950
+ ins: insAttr;
951
+ kbd: EAttr;
952
+ pre: EAttr;
953
+ sub: EAttr;
954
+ sup: EAttr;
955
+ var: EAttr;
956
+ wbr: EAttr;
957
+ cite: EAttr;
958
+ time: timeAttr;
959
+ abbr: EAttr;
960
+ code: EAttr;
961
+ mark: EAttr;
962
+ samp: EAttr;
963
+ meter: meterAttr;
964
+ small: EAttr;
965
+ strong: EAttr;
966
+ address: EAttr;
967
+ progress: progressAttr;
968
+ template: EAttr;
969
+ blockquote: blockquoteAttr;
970
+ menu: menuAttr;
971
+ ul: EAttr;
972
+ ol: olAttr;
973
+ li: liAttr;
974
+ dl: EAttr;
975
+ dt: EAttr;
976
+ dd: EAttr;
977
+ h1: EAttr;
978
+ h2: EAttr;
979
+ h3: EAttr;
980
+ h4: EAttr;
981
+ h5: EAttr;
982
+ h6: EAttr;
941
983
  }
942
984
 
943
- type fn<E, T> = (e?: E) => T;
944
- declare class Elem<T extends Elements = HTMLElement> extends Eget<T> {
945
- constructor(e: T, query?: string);
946
- add(...className: string[]): () => void;
947
- remove(...className: string[]): this;
948
- toggle(className: string | fn<any, string>, force?: boolean): boolean;
949
- hasNode(e: Node): boolean;
950
- has(...classes: string[]): boolean;
951
- insert(position: InsertPosition): {
952
- HTML: (...text: string[]) => Elem<T>;
953
- element: (...elem: HTMLElement[]) => Elem<T>;
954
- text: (this: Elem<T>, ...text: string[]) => Elem<T>;
985
+ interface SVGAttributes {
986
+ svg: svgAttr & {
987
+ viewBox?: DVal;
955
988
  };
956
- is(tp: {
957
- dom?: string;
958
- class?: string | string[];
959
- }): boolean;
960
- on(event: keyof events, handler: (e?: any) => void, useCapture?: boolean): this;
961
- remove_on(event: keyof DocumentEventMap, handler: EventListenerOrEventListenerObject, useCapture?: boolean): this;
962
- timed(fn: (ee?: Elem<T>) => void, timeout?: number): this;
963
- animate(keyframes: KFType, options?: kf, onComplete?: fn<any, void>): this;
964
- animate(keyframes: KFType, onComplete?: fn<any, void>): this;
965
- }
966
-
967
- type Elements = HTMLElementTagNameMap[keyof HTMLElementTagNameMap] | SVGElementTagNameMap[keyof SVGElementTagNameMap];
968
- interface CLI {
969
- id?: string;
970
- class?: string;
971
- }
972
- declare function $<T extends Elements = HTMLElement, P extends Elements = HTMLElement>(query: CLI, parent?: P): Elem<T> | undefined;
973
- declare function $<T extends Elements = HTMLElement, P extends Elements = HTMLElement>(query: string, parent?: P): Elem<T> | undefined;
974
- declare function $<T extends Elements = HTMLElement>(element: T): Elem<T>;
975
- type _$<T extends Elements = HTMLElement> = Elem<T> | undefined;
976
- type $E<T extends Elements = HTMLElement> = Elem<T>;
977
- declare class Ref<T extends Elements = HTMLElement> {
978
- state: Stateful<_$<T>>;
979
- constructor();
980
- get element(): T | undefined;
981
- set element(elem: T | undefined);
982
- get $(): _$<T>;
989
+ path: svgEAttr;
990
+ circle: svgEAttr;
991
+ animate: svgEAttr;
992
+ animateMotion: svgEAttr;
993
+ animateTransform: svgEAttr;
994
+ clipPath: svgEAttr;
995
+ defs: svgEAttr;
996
+ desc: svgEAttr;
997
+ ellipse: svgEAttr;
998
+ feBlend: svgEAttr;
999
+ feColorMatrix: svgEAttr;
1000
+ feComponentTransfer: svgEAttr;
1001
+ feComposite: svgEAttr;
1002
+ feConvolveMatrix: svgEAttr;
1003
+ feDiffuseLighting: svgEAttr;
1004
+ feDisplacementMap: svgEAttr;
1005
+ feDistantLight: svgEAttr;
1006
+ feDropShadow: svgEAttr;
1007
+ feFlood: svgEAttr;
1008
+ feFuncA: svgEAttr;
1009
+ feFuncB: svgEAttr;
1010
+ feFuncG: svgEAttr;
1011
+ feFuncR: svgEAttr;
1012
+ feGaussianBlur: svgEAttr;
1013
+ feImage: svgEAttr;
1014
+ feMerge: svgEAttr;
1015
+ feMergeNode: svgEAttr;
1016
+ feMorphology: svgEAttr;
1017
+ feOffset: svgEAttr;
1018
+ fePointLight: svgEAttr;
1019
+ feSpecularLighting: svgEAttr;
1020
+ feSpotLight: svgEAttr;
1021
+ feTile: svgEAttr;
1022
+ feTurbulence: svgEAttr;
1023
+ filter: svgEAttr;
1024
+ foreignObject: svgEAttr;
1025
+ g: svgEAttr;
1026
+ image: svgEAttr;
1027
+ line: svgEAttr;
1028
+ linearGradient: svgEAttr;
1029
+ marker: svgEAttr;
1030
+ mask: svgEAttr;
1031
+ metadata: svgEAttr;
1032
+ mpath: svgEAttr;
1033
+ pattern: svgEAttr;
1034
+ polygon: svgEAttr;
1035
+ polyline: svgEAttr;
1036
+ radialGradient: svgEAttr;
1037
+ rect: svgEAttr;
1038
+ set: svgEAttr;
1039
+ stop: svgEAttr;
1040
+ symbol: svgEAttr;
1041
+ text: svgETextAttr;
1042
+ textPath: svgEAttr;
1043
+ title: svgEAttr;
1044
+ tspan: svgEAttr;
1045
+ use: svgEAttr;
1046
+ view: svgEAttr;
1047
+ }
1048
+ interface svgAttr<T = DVal> extends EAttr<T> {
1049
+ height?: T;
1050
+ width?: T;
1051
+ preserveAspectRatio?: T;
1052
+ fill?: T;
1053
+ stroke?: T;
1054
+ strokeWidth?: T;
1055
+ opacity?: T;
1056
+ display?: T;
1057
+ overflow?: T;
1058
+ }
1059
+ interface svgEAttr<T = DVal> extends svgAttr<T> {
1060
+ transform?: T;
1061
+ role?: T;
1062
+ tabindex?: T;
1063
+ visibility?: T;
1064
+ fillOpacity?: T;
1065
+ fillRule?: T;
1066
+ stroke?: T;
1067
+ strokeWidth?: T;
1068
+ strokeOpacity?: T;
1069
+ strokeLinecap?: T;
1070
+ strokeLinejoin?: T;
1071
+ strokeMiterlimit?: T;
1072
+ strokeDasharray?: T;
1073
+ strokeDashoffset?: T;
1074
+ x?: T;
1075
+ y?: T;
1076
+ x1?: T;
1077
+ y1?: T;
1078
+ x2?: T;
1079
+ y2?: T;
1080
+ cx?: T;
1081
+ cy?: T;
1082
+ r?: T;
1083
+ rx?: T;
1084
+ ry?: T;
1085
+ d?: T;
1086
+ points?: T;
1087
+ }
1088
+ interface svgETextAttr<T = DVal> extends svgEAttr<T> {
1089
+ fontSize?: T;
1090
+ fontFamily?: T;
1091
+ fontWeight?: T;
1092
+ textAnchor?: T;
1093
+ dominantBaseline?: T;
983
1094
  }
984
- declare const useRef: <T extends Elements = HTMLElement>() => Ref<T>;
985
1095
 
986
- declare class Dom {
987
- tag: string;
988
- attr: attr;
989
- ctx: ctx[];
990
- constructor(tag: string, attr: attr, ctx: ctx[]);
991
- }
992
- declare function dom$1(tag: string | ((attr: attr, ...ctx: ctx[]) => maybePromise<Dom>), attr?: attr | null, ...ctx: ctx[]): Promise<Dom>;
993
- declare const frag: (attr: attr, ...ctx: Dom[]) => Promise<Dom>;
994
1096
  declare global {
995
1097
  type events<T extends Elements = HTMLElement> = {
996
1098
  [P in keyof GlobalEventHandlersEventMap]?: (this: T, e: GlobalEventHandlersEventMap[P]) => void;
997
1099
  } & c_events<T>;
998
- type DVal<T = V | V[]> = T | Stateful<T> | undefined;
999
- type dom = Dom;
1000
- type ctx<T = DVal | dom> = T | Stateful<T> | ctx[];
1001
- type obj<T> = Record<string, T>;
1002
- type DomFN<T = {}> = (a: attr & T, ...D: ctx[]) => maybePromise<dom>;
1003
- type attr = EAttr;
1004
1100
  namespace JSX {
1005
- type Element = maybePromise<dom>;
1101
+ type Element = maybePromise<DOM>;
1006
1102
  interface IntrinsicElements extends ElementAttributes, SVGAttributes {
1007
1103
  }
1008
1104
  }
1009
1105
  }
1010
1106
 
1011
- interface docObj {
1012
- args?: obj<any>;
1013
- data?: obj<any>;
1107
+ /** Generates a sequence of hierarchical DOM IDs for rendered nodes. */
1108
+ declare class Idm {
1109
+ readonly nonce?: string | undefined;
1110
+ private counter;
1111
+ private readonly baseId;
1112
+ constructor(seed?: string, counter?: number, nonce?: string | undefined);
1113
+ /** Resumes the sequence from an ID previously generated by this class. */
1114
+ static fromId(id: string, nonce?: string): Idm;
1115
+ get id(): string;
1116
+ get nextId(): string;
1117
+ get childId(): Idm;
1118
+ append(prefix?: string): Idm;
1014
1119
  }
1015
- declare class doc<T extends docObj = obj<obj<any>>> extends head {
1016
- path: string;
1017
- data: T["data"];
1018
- args: T["args"];
1019
- importArgs: any[] | (() => any[]);
1020
- fetch?(): maybePromise<obj<any>>;
1021
- head?(): maybePromise<void>;
1022
- body?(): maybePromise<any>;
1023
- static A: (a: aAttr, ...ctx: ctx[]) => Promise<Dom>;
1120
+
1121
+ declare class CATT {
1122
+ xid: string;
1123
+ IDM: Idm;
1124
+ map: Mapper<string, string[]>;
1125
+ states: ((id: string) => Promise<() => void>)[];
1126
+ events: Mapper<string, (...arg: any) => any>;
1127
+ OZ: OZ;
1128
+ private internalId?;
1129
+ constructor(xid: string, IDM?: Idm, _OZ?: OZ);
1130
+ attr_push(key: string, val: any, pre?: string): void;
1131
+ get attr(): string;
1132
+ set id(id: string);
1133
+ get id(): string | undefined;
1134
+ setId(id: string): void;
1024
1135
  }
1025
1136
 
1026
- type ExtraState = Record<string, unknown>;
1027
- type HistoryData<S extends ExtraState = ExtraState> = (S & {
1028
- path: string;
1029
- }) | null;
1030
- type ChangeHandler<S extends ExtraState> = (path: string, state: HistoryData<S>) => void;
1031
- declare class PathHistory<S extends ExtraState = ExtraState> {
1032
- private onChange?;
1033
- private popListener?;
1034
- constructor(path?: Stateful<string>, isDev?: boolean, onChange?: ChangeHandler<S>);
1035
- /** Current path (pathname + search + hash) */
1036
- path(): string;
1037
- /** Current state object */
1038
- state(): HistoryData<S>;
1039
- /** Navigate to a new path using pushState (no-op if same as current) */
1040
- navigate(path: string, state?: S, title?: string): void;
1041
- /** Replace current entry using replaceState (no-op if same as current) */
1042
- replace(path: string, state?: S, title?: string): void;
1043
- back(): void;
1044
- forward(): void;
1045
- /** Remove listeners */
1046
- destroy(): void;
1047
- private resolve;
1048
- private samePath;
1137
+ declare class OZ {
1138
+ private readonly tokens;
1139
+ private events;
1140
+ private states;
1141
+ private windowEvents;
1142
+ private documentEvents;
1143
+ private resetST;
1144
+ private resetEV;
1145
+ get keys(): string[];
1146
+ set(catt: CATT): this;
1147
+ push(_OZ: this): this;
1148
+ stage(isCurrent?: () => boolean): Promise<this>;
1149
+ get processWindowEvents(): this;
1150
+ get processDocumentEvents(): this;
1151
+ reset(id: string[]): this;
1152
+ resetScope(prefix: string): this;
1153
+ RPS(oz?: this, isCurrent?: () => boolean): Promise<this>;
1049
1154
  }
1050
1155
 
1051
- interface contentObj {
1052
- args?: obj<any>;
1053
- data?: obj<any>;
1156
+ /** Converts an attribute value for inclusion in generated HTML. */
1157
+ declare const attr_value: (value: unknown) => string;
1158
+
1159
+ declare class ATTR {
1160
+ attr: EAttr;
1161
+ constructor(attr?: EAttr);
1162
+ get(catt: CATT, attr?: EAttr, pre?: string): void;
1163
+ unload<T>(x: string): T | undefined;
1054
1164
  }
1055
- declare class content<T extends contentObj = obj<obj<string>>> {
1056
- path: string;
1057
- data: T["data"];
1058
- args: T["args"];
1059
- importArgs: any[] | (() => any[]);
1060
- body?(): maybePromise<any>;
1061
- static Button: (a: buttonAttr & {
1062
- tab?: string | string[];
1063
- }, ...ctx: ctx[]) => Promise<Dom>;
1165
+
1166
+ interface RenderedDOM {
1167
+ ctx: string;
1168
+ oz: OZ;
1169
+ id: string | undefined;
1064
1170
  }
1171
+ type renderedDom = RenderedDOM;
1172
+ declare function renderDom(node: maybePromise<DOM>, pid?: Idm | string): Promise<RenderedDOM>;
1065
1173
 
1066
- declare class websocket<T = Record<string, any>> {
1174
+ interface YveeURL {
1067
1175
  path: string;
1068
- protected args: T;
1069
- route: string;
1070
- ws: WebSocket;
1071
- isConnected: Stateful<boolean>;
1072
- data: T;
1073
- constructor(path: string, args?: T);
1074
- protected open(event: Event): Promise<void> | void;
1075
- protected message(event: MessageEvent): Promise<void> | void;
1076
- protected close(event: CloseEvent): Promise<void> | void;
1077
- protected error(event: Event): Promise<void> | void;
1078
- get connect(): this;
1079
- get reconnect(): this;
1080
- get disconnect(): this;
1081
- /**
1082
- * code:
1083
- * * 0 - CONNECTING: The connection is being established.
1084
- * * 1 - OPEN: The connection is open and ready to communicate.
1085
- * * 2 - CLOSING: The connection is in the process of closing.
1086
- * * 3 - CLOSED: The connection has been closed or could not be opened.
1087
- */
1088
- get state(): number;
1089
- set send(message: string | ArrayBufferLike | Blob | ArrayBufferView);
1090
- }
1091
- declare class socket {
1092
- protected yvee: Yvee;
1093
- constructor(yvee: Yvee);
1094
- load(_path: string): Promise<websocket<Record<string, any>> | undefined>;
1095
- unload(_path: string): void;
1176
+ search: string;
1177
+ hash: string;
1178
+ params: URLSearchParams;
1096
1179
  }
1180
+ declare const normalizePath: (input: string) => string;
1181
+ declare const toURL: (input: string | URL) => YveeURL;
1097
1182
 
1098
- declare class BasePath<T> extends MinStorage {
1099
- cls: T;
1100
- constructor(path: string, cls: T);
1183
+ type HeadConfig = {
1184
+ base?: Record<string, string | boolean>[];
1185
+ title?: string;
1186
+ style?: string;
1187
+ description?: string;
1188
+ meta?: Record<string, string | boolean>[];
1189
+ link?: Record<string, string | boolean>[];
1190
+ script?: (Record<string, string | boolean> & {
1191
+ body?: string;
1192
+ })[];
1193
+ css?: string | string[];
1194
+ js?: string | string[];
1195
+ /** DOM-rendered head elements, useful for reactive text and attributes. */
1196
+ elements?: DOM[];
1197
+ };
1198
+ type HeadResult = HeadConfig | DOM | string | void;
1199
+ declare class HeadDefaults {
1200
+ readonly values: HeadConfig;
1201
+ head(value: HeadResult): void;
1101
1202
  }
1102
- declare class ClientPath extends BasePath<typeof doc<{}>> {
1203
+
1204
+ type HeadCleanup = (() => void) & {
1205
+ ready: Promise<void>;
1206
+ activate(): Promise<void>;
1207
+ cancel(): void;
1208
+ };
1209
+ declare function applyHead(config: HeadConfig, owner: string, options?: {
1210
+ keepExisting?: boolean;
1211
+ deferTitle?: boolean;
1212
+ idSeed?: string;
1213
+ nonce?: string;
1214
+ }): HeadCleanup;
1215
+
1216
+ declare class Page<TData extends Record<string, unknown> = Record<string, unknown>> {
1217
+ readonly resources: DisposalScope;
1218
+ url: YveeURL;
1219
+ path: string;
1220
+ params: Record<string, string>;
1221
+ data: TData;
1222
+ error?: unknown;
1223
+ status: number;
1224
+ fetch?(context: PageFetchContext<TData>): Partial<TData> | Promise<Partial<TData>>;
1225
+ head?(): HeadResult | Promise<HeadResult>;
1226
+ body?(): unknown | Promise<unknown>;
1227
+ }
1228
+ interface PageFetchContext<TData extends Record<string, unknown>> {
1229
+ url: YveeURL;
1230
+ params: Readonly<Record<string, string>>;
1231
+ data: TData;
1232
+ signal: AbortSignal;
1233
+ resources: DisposalScope;
1234
+ }
1235
+ declare class MissingPage extends Page {
1236
+ body(): JSX.Element;
1237
+ }
1238
+ declare class FailurePage extends Page {
1239
+ status: number;
1240
+ body(): JSX.Element;
1103
1241
  }
1104
- declare class SocketPath extends BasePath<typeof websocket> {
1242
+
1243
+ type Constructor<T = object> = new (...args: any[]) => T;
1244
+ type Transport = "page" | "socket";
1245
+ interface RouteEntry<T = unknown> {
1246
+ path: string;
1247
+ transport: Transport;
1248
+ expression: RegExp;
1249
+ names: string[];
1250
+ controller: Constructor<T>;
1251
+ }
1252
+ interface RouteMatch<T> {
1253
+ entry: RouteEntry<T>;
1254
+ params: Record<string, string>;
1255
+ }
1256
+ declare function error(status: number): <T extends Constructor<Page>>(controller: T) => T;
1257
+ declare const page: (path?: string) => <T extends Constructor>(controller: T) => T;
1258
+ declare const route: typeof page;
1259
+ declare const socketRoute: (path?: string) => <T extends Constructor>(controller: T) => T;
1260
+ declare class RouteBook<T = unknown> {
1261
+ private readonly base;
1262
+ private readonly entries;
1263
+ constructor(base?: string);
1264
+ add(path: string, controller: Constructor<T>, transport?: Transport): {
1265
+ path: string;
1266
+ expression: RegExp;
1267
+ names: string[];
1268
+ controller: Constructor<T>;
1269
+ transport: Transport;
1270
+ };
1271
+ find(path: string, transport?: Transport): RouteMatch<T> | undefined;
1272
+ all(transport?: Transport): RouteEntry<T>[];
1105
1273
  }
1106
- declare class MainStorage<T extends InstanceType<typeof BasePath>> {
1107
- storage: Storage<T>;
1108
- error: Storage<T>;
1274
+ declare const interpolate: (pattern: string, values: Record<string, unknown> | unknown[]) => string;
1275
+
1276
+ interface GuardApp<TData extends Record<string, unknown>> {
1277
+ data: TData;
1278
+ url: IStateful<YveeURL>;
1279
+ }
1280
+ type GuardResult = void | {
1281
+ kind: "allow";
1282
+ } | {
1283
+ kind: "stop";
1284
+ } | {
1285
+ kind: "redirect";
1286
+ to: string;
1287
+ replace?: boolean;
1288
+ };
1289
+ interface GuardContext<TApp = unknown, TPage = unknown, TData extends Record<string, unknown> = Record<string, unknown>> {
1290
+ app: TApp;
1291
+ page: TPage;
1292
+ url: YveeURL;
1293
+ params: Readonly<Record<string, string>>;
1294
+ data: TData;
1295
+ signal: AbortSignal;
1296
+ }
1297
+ type Guard<TApp = unknown, TPage = unknown, TData extends Record<string, unknown> = Record<string, unknown>> = (context: GuardContext<TApp, TPage, TData>) => GuardResult | Promise<GuardResult>;
1298
+ type GuardFactory<Args extends unknown[] = [], TContext = GuardContext> = (...args: Args) => (context: TContext) => GuardResult | Promise<GuardResult>;
1299
+ declare const createGuard: <Args extends unknown[], TContext = GuardContext>(factory: GuardFactory<Args, TContext>) => GuardFactory<Args, TContext>;
1300
+ declare const use: (...guards: Guard<any, any, any>[]) => <T extends Constructor>(controller: T) => T;
1301
+
1302
+ type ContextGuard<C = GuardContext> = (context: C) => GuardResult | Promise<GuardResult>;
1303
+ type GuardPredicate<C = GuardContext> = (context: C) => boolean | Promise<boolean>;
1304
+ type GuardRejection = Exclude<GuardResult, void | {
1305
+ kind: "allow";
1306
+ }>;
1307
+ type GuardFallback<C = GuardContext> = GuardRejection | ((context: C) => GuardRejection | Promise<GuardRejection>);
1308
+ /** Requires a condition; use a context-derived fallback for redirects. */
1309
+ declare function requireGuard<C = GuardContext>(predicate: GuardPredicate<C>, fallback?: GuardFallback<C>): ContextGuard<C>;
1310
+ /** Evaluates guards in order and returns the first stop/redirect decision. */
1311
+ declare function allGuards<C extends GuardContext<any, any, any> = GuardContext>(...guards: ContextGuard<C>[]): ContextGuard<C>;
1312
+ /** Runs a guard only when its condition holds. */
1313
+ declare function whenGuard<C = GuardContext>(predicate: GuardPredicate<C>, guard: ContextGuard<C>): ContextGuard<C>;
1314
+ /** Validates route parameters before page fetch/render. */
1315
+ declare function paramsGuard<C extends GuardContext<any, any, any> = GuardContext>(validators: Record<string, (value: string, context: C) => boolean | Promise<boolean>>, fallback?: GuardFallback<C>): ContextGuard<C>;
1316
+
1317
+ type Layout = (content: IStateful<unknown[]>) => maybePromise<DOMContext>;
1318
+
1319
+ interface ServerRequest<TData> {
1320
+ /** URL used to select the page for this render. */
1321
+ url: string | URL | YveeURL;
1322
+ /** Request data exposed to the page and its fetch method. */
1323
+ data?: TData;
1324
+ /** Error status to render through the registered error page. */
1325
+ error?: number;
1326
+ /** Unique per response; pass the same value to the client mount. */
1327
+ nonce?: string;
1328
+ /** Abort signal for request-bound page loading and data creation. */
1329
+ signal?: AbortSignal;
1330
+ }
1331
+ /** HTML and the HTTP status produced by a server render. */
1332
+ interface ServerStatusResult {
1333
+ html: string;
1334
+ status: number;
1335
+ }
1336
+ interface ServerDataContext<TData> extends ServerRequest<TData> {
1337
+ signal: AbortSignal;
1338
+ /** Register resources acquired by dataFactory; runs on success, failure or abort. */
1339
+ onDispose(cleanup: () => void | Promise<void>): void;
1340
+ }
1341
+ interface ServerOptions<TData extends Record<string, unknown>> {
1342
+ id?: string;
1343
+ class?: string | string[];
1344
+ data?: TData;
1345
+ /** Return fresh request-owned mutable data/services. Plain data inputs are frozen snapshots. */
1346
+ dataFactory?: (context: ServerDataContext<TData>) => TData | Promise<TData>;
1109
1347
  }
1110
- declare class Stormy extends MainStorage<ClientPath> {
1111
- wss: Storage<SocketPath>;
1112
- setRoute(path: string, _doc: typeof doc<{}>): void;
1113
- getRoute(path: string, error?: number): doc<{}>;
1114
- setWss(path: string, _wss: typeof websocket): void;
1115
- getWss(path: string): [SocketPath | undefined, Record<string, string>];
1116
- setError(code: number, _doc: typeof doc<{}>): void;
1117
- getError(code?: number): [ClientPath | undefined, Record<string, string>];
1348
+ interface ServerRenderer<TData extends Record<string, unknown>> {
1349
+ /** Render a request and return its HTML document. */
1350
+ (request: ServerRequest<TData>): Promise<string>;
1351
+ withStatus(request: ServerRequest<TData>): Promise<ServerStatusResult>;
1118
1352
  }
1119
- declare class TabPath extends BasePath<typeof content<{}>> {
1353
+
1354
+ interface SocketRouteSource {
1355
+ routes: RouteBook;
1356
+ }
1357
+ type MessageFailure = 'parse' | 'validation' | 'handler';
1358
+ interface JsonMessageOptions<T> {
1359
+ validate?: (value: unknown) => value is T;
1360
+ onError?: (error: unknown, phase: MessageFailure, event: MessageEvent) => void;
1361
+ }
1362
+ interface SocketLoadOptions {
1363
+ signal?: AbortSignal;
1364
+ /** No retries by default. Attempts are a total budget per load, including after successful opens. */
1365
+ retry?: {
1366
+ attempts: number;
1367
+ delay?: number;
1368
+ maxDelay?: number;
1369
+ };
1120
1370
  }
1121
- declare class miniStormy extends MainStorage<TabPath> {
1122
- setRoute(path: string, _doc: typeof content<{}>): void;
1123
- getRoute(path: string, error?: number): content<{}>;
1124
- setWss(path: string): void;
1125
- getWss(path: string): void;
1126
- setError(code: number, _doc: typeof content<{}>): void;
1127
- getError(code?: number): [TabPath | undefined, Record<string, string>];
1371
+ declare class SocketController {
1372
+ connection?: WebSocket;
1373
+ path: string;
1374
+ params: Record<string, string>;
1375
+ open(_event: Event): void;
1376
+ message(_event: MessageEvent): void | Promise<void>;
1377
+ close(_event: CloseEvent): void;
1378
+ error(_event: Event): void;
1379
+ messageError(error: unknown, phase: MessageFailure, _event: MessageEvent): void;
1380
+ sendJson(value: unknown): void;
1381
+ onMessage<T = unknown>(handler: (value: T, event: MessageEvent) => void | Promise<void>, options?: JsonMessageOptions<T>): this;
1382
+ }
1383
+ declare class SocketHub {
1384
+ private readonly app;
1385
+ private readonly connections;
1386
+ constructor(app: SocketRouteSource);
1387
+ load(path: string, options?: SocketLoadOptions): SocketController;
1388
+ unload(path: string): void;
1389
+ closeAll(): void;
1128
1390
  }
1129
1391
 
1130
- declare class minElements$1 extends htmlHead {
1131
- id: string;
1132
- data: obj<any>;
1133
- path: Stateful<string>;
1134
- protected _root: Stateful<any[]>;
1135
- constructor();
1136
- A(a: aAttr, ...ctx: ctx[]): Promise<Dom>;
1137
- protected _main?: (root: Stateful<any[]>) => maybePromise<dom>;
1138
- protected getMain(_class?: string | string[]): Promise<Dom>;
1392
+ interface YveeOptions {
1393
+ base?: string;
1394
+ history?: boolean;
1395
+ id?: string;
1396
+ /** Browser entry directory or JavaScript file URL. Defaults to `.`, which resolves to `./index.js` relative to the app's base URL. */
1397
+ client?: string;
1398
+ index?: string;
1139
1399
  }
1140
-
1141
- declare class Router extends minElements$1 {
1142
- protected pushHistory: boolean;
1143
- storage: Stormy;
1144
- protected base: string;
1145
- constructor(base?: string, index?: string, pushHistory?: boolean);
1146
- /** --------------------
1147
- * string | int | float | file | uuid
1148
- * - /url/\<string:hell>
1149
- */
1150
- route<Q extends typeof doc<{}>>(path: string): (f: Q) => Q;
1151
- error<Q extends typeof doc<{}>>(...codes: number[]): (f: Q) => Q;
1152
- /** --------------------
1153
- * string | int | float | file | uuid
1154
- * - /url/\<string:hell>
1155
- */
1156
- wss<Q extends typeof websocket>(path: string): (f: Q) => Q;
1400
+ interface MountOptions<T> {
1401
+ id?: string;
1402
+ data?: T;
1403
+ class?: string | string[];
1404
+ hydrate?: boolean;
1405
+ nonce?: string;
1157
1406
  }
1407
+ /**
1408
+ * The value returned by `render()` can be called on a server to create HTML.
1409
+ * In a browser it also behaves like the mount promise for backwards-compatible
1410
+ * client startup (`app.render().then(...)`).
1411
+ */
1412
+ type RenderResult<T extends Record<string, unknown>> = ServerRenderer<T> & Promise<() => void>;
1158
1413
 
1159
- interface mtab {
1160
- tab?: string | string[];
1161
- }
1162
- declare class minElements {
1163
- id: string;
1164
- path: Stateful<string>;
1165
- protected _root: Stateful<any[]>;
1166
- Button(a: buttonAttr & mtab, ...ctx: ctx[]): Promise<Dom>;
1167
- }
1168
- interface _Tabs {
1169
- path?: Stateful<string>;
1170
- }
1171
- declare class Tabs extends minElements {
1172
- storage: miniStormy;
1173
- private hasLoaded;
1174
- constructor({ path }?: _Tabs);
1175
- tab<Q extends typeof content<{}>>(path: string): (f: Q) => Q;
1176
- Main(a: attr & {
1177
- tab?: string;
1178
- data?: obj<any>;
1179
- }): Promise<Dom>;
1180
- load(tab: string, data?: obj<any>): Promise<void>;
1414
+ declare class Yvee<T extends Record<string, unknown> = Record<string, unknown>> extends HeadDefaults {
1415
+ readonly id: string;
1416
+ readonly routes: RouteBook;
1417
+ readonly url: IStateful<YveeURL>;
1418
+ readonly loading: IStateful<boolean>;
1419
+ readonly socket: SocketHub;
1420
+ readonly history: {
1421
+ navigate: (path: string | YveeURL, state?: Record<string, unknown>) => void;
1422
+ replace: (path: string | YveeURL, state?: Record<string, unknown>) => void;
1423
+ back: () => void;
1424
+ forward: () => void;
1425
+ };
1426
+ data: T;
1427
+ resources: DisposalScope;
1428
+ private readonly root;
1429
+ private readonly pageErrors;
1430
+ private readonly globalGuards;
1431
+ private readonly client;
1432
+ private layout;
1433
+ onError?: (error: unknown, url: YveeURL) => void;
1434
+ constructor(options?: YveeOptions);
1435
+ Main(layout?: Layout): this;
1436
+ use(...guards: Guard<Yvee<T>, Page<T>, T>[]): this;
1437
+ head(value: HeadResult): this;
1438
+ route(path: string): <C extends Constructor<Page>>(controller: C) => C;
1439
+ error(code: number, controller: Constructor<Page>): this;
1440
+ register(...controllers: Constructor[]): this;
1441
+ listRoutes(transport?: Transport): RouteEntry<unknown>[];
1442
+ /** Page paths including the base, with parameter names used as sample values. */
1443
+ listPaths(): string[];
1444
+ /** Render a concrete route URL to a complete HTML document without mounting. */
1445
+ renderHTML(url: ServerRequest<T>["url"], options?: Omit<ServerRequest<T>, "url">): Promise<string>;
1446
+ render(options?: MountOptions<T>): RenderResult<T>;
1447
+ dispose(): void;
1448
+ server(options?: ServerOptions<T>): ServerRenderer<T>;
1449
+ private load;
1181
1450
  }
1182
1451
 
1183
- interface renderConfig {
1184
- class?: string | string[];
1185
- id?: string;
1186
- data?: any;
1452
+ type StoreName = "localStorage" | "sessionStorage";
1453
+
1454
+ interface StorageSchema<T> {
1455
+ version: number;
1456
+ validate: (value: unknown) => value is T;
1457
+ fallback: () => T;
1458
+ /** Destination version -> migration from the preceding version. */
1459
+ migrations?: Readonly<Record<number, (value: unknown) => unknown>>;
1460
+ }
1461
+ interface StorageChange {
1462
+ key: string | null;
1463
+ oldValue: string | null;
1464
+ newValue: string | null;
1465
+ }
1466
+ interface StorageWatchOptions {
1467
+ signal?: AbortSignal;
1468
+ scope?: DisposalScope;
1469
+ }
1470
+ declare class VersionedValue<T> {
1471
+ private readonly store;
1472
+ private readonly base;
1473
+ private readonly schema;
1474
+ readonly key: string;
1475
+ constructor(store: BrowserStore, base: string, schema: StorageSchema<T>);
1476
+ get(): T;
1477
+ set(value: T): this;
1478
+ remove(): this;
1479
+ watch(callback: (change: StorageChange) => void, options?: StorageWatchOptions): Cleanup;
1480
+ private check;
1481
+ }
1482
+ declare class StoredValue<T = unknown> {
1483
+ private readonly storeName;
1484
+ readonly key: string;
1485
+ private current;
1486
+ constructor(storeName: StoreName, key: string, current: T);
1487
+ get value(): T;
1488
+ set value(value: T);
1489
+ set(value: T): this;
1490
+ save(): this;
1491
+ remove(): this;
1492
+ as: {
1493
+ str: () => string;
1494
+ int: () => number;
1495
+ float: () => number;
1496
+ bool: () => boolean;
1497
+ json: <R = unknown>() => R;
1498
+ };
1499
+ private storage;
1500
+ }
1501
+ declare class BrowserStore {
1502
+ private readonly storeName;
1503
+ constructor(storeName: StoreName);
1504
+ versioned<T>(key: string, schema: StorageSchema<T>): VersionedValue<T>;
1505
+ /** Native storage events from other documents; same-document writes do not notify. */
1506
+ watch(key: string, callback: (change: StorageChange) => void, { signal, scope }?: StorageWatchOptions): Cleanup;
1507
+ get<T = unknown>(key: string, fallback?: T): StoredValue<T | undefined>;
1508
+ /** Writes immediately; storage/serialization failures propagate to the caller. */
1509
+ set<T>(key: string, value: T): StoredValue<T>;
1510
+ remove(key: string): this;
1511
+ has(key: string): boolean;
1512
+ private storage;
1513
+ }
1514
+ declare const local: BrowserStore;
1515
+ declare const session: BrowserStore;
1516
+
1517
+ declare class HTTPError extends Error {
1518
+ readonly response: Response;
1519
+ constructor(response: Response);
1520
+ }
1521
+ interface RequestRetry {
1522
+ /** Additional attempts, from 0 to 5. Only GET, HEAD and OPTIONS may retry. */
1523
+ attempts: number;
1524
+ delayMs?: number;
1525
+ }
1526
+ interface JSONRequestOptions<T> extends RequestInit {
1527
+ validate: (value: unknown) => value is T;
1528
+ retry?: RequestRetry;
1529
+ fetch?: typeof globalThis.fetch;
1530
+ }
1531
+ /** HTTP/status failures are distinct from JSON parsing and caller validation failures. */
1532
+ declare function requestJSON<T>(input: RequestInfo | URL, options: JSONRequestOptions<T>): Promise<T>;
1533
+
1534
+ interface StreamHandlers {
1535
+ open?: (event: Event) => void;
1536
+ error?: (event: Event) => void;
1537
+ message?: (event: MessageEvent) => void;
1538
+ [name: string]: ((event: MessageEvent) => void) | ((event: Event) => void) | undefined;
1187
1539
  }
1188
- interface serverRender {
1189
- path: string;
1190
- error?: number;
1191
- data?: Record<string, any>;
1540
+ interface StreamOptions extends EventSourceInit {
1541
+ signal?: AbortSignal;
1192
1542
  }
1193
- interface _Yvee {
1194
- base?: string;
1195
- index?: string;
1196
- history?: boolean;
1197
- isDev?: boolean;
1198
- }
1199
- declare class Yvee extends Router {
1200
- yvee: Yvee;
1201
- private isDev;
1202
- history: PathHistory;
1203
- constructor({ base, history, index, isDev }?: _Yvee);
1204
- Main(main?: (root: Stateful<any[]>) => maybePromise<dom>): void;
1205
- render(x?: renderConfig): Promise<(() => void) | (({ path, data, error }: serverRender) => Promise<string>)>;
1206
- private init;
1207
- }
1208
- declare const Routes: <T>(fn: (route: Yvee["route"]) => T) => (route: Yvee["route"]) => T;
1543
+ /** Dedicated EventSource; native SSE reconnection continues until close/abort. */
1544
+ declare function eventStreams(url: string, handlers?: StreamHandlers, options?: StreamOptions): EventSource;
1545
+
1546
+ /** JSON data only: rejects undefined roots, cycles and unsupported JSON values. */
1547
+ declare function serializePayload(value: unknown): string;
1548
+ declare function renderJSONScript(value: unknown, options: {
1549
+ id: string;
1550
+ nonce?: string;
1551
+ }): string;
1209
1552
 
1210
- export { $, IfClient, Meta, PathHistory, QState, Ref, Routes, State, StateHook, Stateful, Tabs, Time, Yvee, __, addCSS, content, cssLoader, doc, dom$1 as dom, frag, log, socket, useRef, websocket };
1211
- export type { $E, Elements, _$, aAttr, headAttr, maybePromise, serverRender };
1553
+ export { $, ATTR, BrowserStore, Column, DOM, DbRepository, Derived, DisposalScope, Elem, EventStream, FailurePage, Field, HTTPError, HeadDefaults, IDNotConnected, IndexedDatabase, MissingPage, Page, QState, RecState, RecStateful, Ref, RefState, RouteBook, Schema, Scope, SetState, SetStateful, SocketController, SocketHub, State, StateEffect, StateHook, StateLoaded, Stateful, Stored, StoredValue, Toggled, VersionedValue, Yvee, allGuards, applyHead, attr_value, batch, createGuard, dom, error, eventStream, eventStreams, frag, getElementById, hook, interpolate, loaded, local, normalizePath, page, paramsGuard, renderContent, renderDom, renderJSONScript, requestJSON, requireGuard, route, serializePayload, session, setContentRenderer, shallowEqual, socketRoute, t, toURL, use, useRef, whenGuard };
1554
+ export type { $_, CSSStyle, Cleanup, ColumnType, Constructor, ContentRenderer, ContextGuard, DOMAttr, DOMComponent, DOMComponentProps, DOMContext, DOMEvents, DOMNode, DOMRenderable, DOMValue, DVal, DerivedOptions, DerivedValue, Disposable, EAttr, ElementAttributes, Elements, Equality, EventMap, FieldScopeSet, Guard, GuardApp, GuardContext, GuardFactory, GuardFallback, GuardPredicate, GuardRejection, GuardResult, HeadConfig, HeadResult, IRecStateful, ISetStateful, IStateful, JSONRequestOptions, JsonMessageOptions, Layout, MessageFailure, MountOptions, OpenOptions, PageFetchContext, RenderResult, RenderedContent, RenderedDOM, RequestRetry, RouteEntry, SVGAttributes, ScopeDecorator, ScopeProxy, ScopeSet, ServerDataContext, ServerOptions, ServerRenderer, ServerRequest, ServerStatusResult, SocketLoadOptions, StateHookOptions, StateOptions, StateUpdate, StorageChange, StorageSchema, StorageWatchOptions, StreamHandlers, StreamOptions, TagNames, Transport, YveeOptions, YveeURL, _$, aAttr, areaAttr, audioAttr, baseAttr, blockquoteAttr, buttonAttr, c_events, canvasAttr, colAttr, colgroupAttr, contenteditableAttr, dataAttr, delAttr, detailsAttr, dialogAttr, embedAttr, errorStatus, fieldsetAttr, formAttr, iframeAttr, imgAttr, inputAttr, insAttr, labelAttr, liAttr, linkAttr, mapAttr, menuAttr, metaAttr, meterAttr, objectAttr, olAttr, optgroupAttr, optionAttr, outputAttr, paramAttr, progressAttr, qAttr, renderedDom, scriptAttr, selectAttr, sourceAttr, statefulValue, styleAttr, successStatus, svgAttr, svgEAttr, svgETextAttr, tdAttr, textareaAttr, thAttr, timeAttr, trackAttr, videoAttr };