yvee 0.0.9 → 0.1.0

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,371 +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[]): 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 sleep: (ms?: number) => Promise<unknown>;
292
- static get screen(): "xs" | "sm" | "smd" | "md" | "lg" | "xl" | "xxl" | undefined;
293
- bytes(bytes: number): string;
294
- static format(val: any): Formatteer;
295
- }
296
- declare class returner {
297
- static arr<T = string>(val?: any): T[];
298
- static num(val: any, iferr?: any): number;
299
- static str(val: any): string;
300
- static arr2obj(val: any[], switched?: boolean): any;
301
- }
302
- declare class Formatteer {
303
- val: any;
304
- constructor(val: any);
305
- get px(): string;
306
- get rem(): string;
307
- 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;
308
183
  }
309
184
 
310
185
  type hookFN<T extends any[]> = (...args: statefulValue<T>) => maybePromise<void>;
311
- interface stateCFG {
186
+ interface StateHookOptions {
312
187
  id?: string;
313
188
  init?: boolean;
189
+ signal?: AbortSignal;
190
+ scope?: DisposalScope;
314
191
  }
315
192
  declare function StateHook<T extends any[]>(callback: hookFN<T>, statefuls: [...{
316
- [K in keyof T]: Stateful<T[K]>;
317
- }], { 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
+ }
318
219
 
319
220
  type statefulValue<T extends any[]> = {
320
- [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];
321
222
  };
223
+ interface StateUpdate {
224
+ readonly signal: AbortSignal;
225
+ isCurrent(): boolean;
226
+ }
322
227
  declare class Stateful<T> extends EventTarget {
323
228
  private options;
324
- private deep;
325
- private verify;
326
229
  private hooks;
230
+ private loads;
327
231
  private states;
328
- private _value;
232
+ protected _value: T;
329
233
  private listening;
234
+ private controller;
235
+ private readonly pending;
236
+ private readonly failures;
237
+ private readonly emit;
330
238
  private end?;
331
- constructor(value: T, options?: AddEventListenerOptions, deep?: boolean, verify?: boolean);
239
+ constructor(value: T, options?: StateOptions<T>);
332
240
  get value(): T;
241
+ get clone(): T;
333
242
  set value(newValue: T);
334
- get listen(): () => void;
335
- call<Q>(callback: (this: Elements, arg: T) => Q, entry: string): (id: string) => () => void;
336
- 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>;
337
326
  }
338
- declare function State<T>(value: T, options?: AddEventListenerOptions): Stateful<T>;
339
327
  /**
340
- * 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
341
329
  */
342
- 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
+ };
343
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>>;
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];
344
473
  type CSSStyle = {
345
- [P in keyof CSSStyleDeclaration]?: DVal;
474
+ [P in CSSStyleProperty]?: DVal;
346
475
  } & {
347
- [key: string]: DVal;
476
+ [key: `--${string}`]: DVal;
348
477
  };
349
478
 
350
479
  interface c_events<T extends Elements = HTMLElement> {
351
- state?: (this: T, e: T) => [(...args: any[]) => void, Stateful<any>[], boolean?];
352
- 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)>;
353
493
  resize?: (this: T, e: UIEvent) => void;
354
494
  beforeunload?: (this: T, e: BeforeUnloadEvent) => void;
355
495
  popstate?: (this: T, e: PopStateEvent) => void;
496
+ DOMContentLoaded?: (this: T, e: Event) => void;
356
497
  winscroll?: (this: T, e: Event) => void;
357
498
  winload?: (this: T, e: Event) => void;
358
499
  winfocus?: (this: T, e: Event) => void;
359
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;
360
504
  }
505
+ type DOMEvents<T extends Elements = HTMLElement> = {
506
+ [P in keyof GlobalEventHandlersEventMap]?: (this: T, event: GlobalEventHandlersEventMap[P]) => void;
507
+ } & c_events<T>;
361
508
 
362
509
  interface EAttr<T = DVal> {
363
510
  [key: string]: any;
364
511
  [key: `data-${string}`]: T | any;
365
512
  accesskey?: T;
366
513
  autocapitalize?: T;
367
- class?: T;
368
- on?: events<any>;
514
+ class?: T | T[];
515
+ on?: DOMEvents<any>;
516
+ ref?: Ref<any>;
369
517
  contenteditable?: T;
370
518
  dir?: T;
371
519
  draggable?: T;
@@ -381,174 +529,24 @@ interface EAttr<T = DVal> {
381
529
  title?: T;
382
530
  translate?: T;
383
531
  }
384
- interface ElementAttributes {
385
- link: linkAttr;
386
- base: baseAttr;
387
- meta: metaAttr;
388
- p: EAttr;
389
- br: EAttr;
390
- hr: EAttr;
391
- h: EAttr;
392
- cmnt: EAttr;
393
- root: EAttr;
394
- div: EAttr;
395
- span: EAttr;
396
- header: EAttr;
397
- hgroup: EAttr;
398
- footer: EAttr;
399
- main: EAttr;
400
- section: EAttr;
401
- search: EAttr;
402
- article: EAttr;
403
- aside: EAttr;
404
- details: detailsAttr;
405
- dialog: dialogAttr;
406
- summary: EAttr;
407
- data: dataAttr;
408
- noscript: EAttr;
409
- object: objectAttr;
410
- param: paramAttr;
411
- script: scriptAttr;
412
- a: aAttr;
413
- nav: EAttr;
414
- style: styleAttr;
415
- audio: audioAttr;
416
- video: videoAttr;
417
- source: sourceAttr;
418
- track: trackAttr;
419
- img: imgAttr;
420
- map: mapAttr;
421
- area: areaAttr;
422
- canvas: canvasAttr;
423
- figcaption: EAttr;
424
- figure: EAttr;
425
- picture: EAttr;
426
- iframe: iframeAttr;
427
- form: formAttr;
428
- input: inputAttr;
429
- textarea: textareaAttr;
430
- button: buttonAttr;
431
- select: selectAttr;
432
- optgroup: optgroupAttr;
433
- option: optionAttr;
434
- label: labelAttr;
435
- fieldset: fieldsetAttr;
436
- legend: EAttr;
437
- datalist: EAttr;
438
- table: EAttr;
439
- caption: EAttr;
440
- th: thAttr;
441
- tr: EAttr;
442
- td: tdAttr;
443
- thead: EAttr;
444
- tbody: EAttr;
445
- tfoot: EAttr;
446
- col: colAttr;
447
- colgroup: colgroupAttr;
448
- b: EAttr;
449
- i: EAttr;
450
- q: qAttr;
451
- s: EAttr;
452
- u: EAttr;
453
- em: EAttr;
454
- rp: EAttr;
455
- del: delAttr;
456
- dfn: EAttr;
457
- ins: insAttr;
458
- kbd: EAttr;
459
- pre: EAttr;
460
- sub: EAttr;
461
- sup: EAttr;
462
- var: EAttr;
463
- wbr: EAttr;
464
- cite: EAttr;
465
- time: timeAttr;
466
- abbr: EAttr;
467
- code: EAttr;
468
- mark: EAttr;
469
- samp: EAttr;
470
- meter: meterAttr;
471
- small: EAttr;
472
- strong: EAttr;
473
- address: EAttr;
474
- progress: progressAttr;
475
- template: EAttr;
476
- blockquote: blockquoteAttr;
477
- menu: menuAttr;
478
- ul: EAttr;
479
- ol: olAttr;
480
- li: liAttr;
481
- dl: EAttr;
482
- dt: EAttr;
483
- dd: EAttr;
484
- h1: EAttr;
485
- h2: EAttr;
486
- h3: EAttr;
487
- h4: EAttr;
488
- h5: EAttr;
489
- h6: EAttr;
490
- }
491
- interface SVGAttributes {
492
- svg: EAttr;
493
- path: EAttr;
494
- circle: EAttr;
495
- animate: EAttr;
496
- animateMotion: EAttr;
497
- animateTransform: EAttr;
498
- clipPath: EAttr;
499
- defs: EAttr;
500
- desc: EAttr;
501
- ellipse: EAttr;
502
- feBlend: EAttr;
503
- feColorMatrix: EAttr;
504
- feComponentTransfer: EAttr;
505
- feComposite: EAttr;
506
- feConvolveMatrix: EAttr;
507
- feDiffuseLighting: EAttr;
508
- feDisplacementMap: EAttr;
509
- feDistantLight: EAttr;
510
- feDropShadow: EAttr;
511
- feFlood: EAttr;
512
- feFuncA: EAttr;
513
- feFuncB: EAttr;
514
- feFuncG: EAttr;
515
- feFuncR: EAttr;
516
- feGaussianBlur: EAttr;
517
- feImage: EAttr;
518
- feMerge: EAttr;
519
- feMergeNode: EAttr;
520
- feMorphology: EAttr;
521
- feOffset: EAttr;
522
- fePointLight: EAttr;
523
- feSpecularLighting: EAttr;
524
- feSpotLight: EAttr;
525
- feTile: EAttr;
526
- feTurbulence: EAttr;
527
- filter: EAttr;
528
- foreignObject: EAttr;
529
- g: EAttr;
530
- image: EAttr;
531
- line: EAttr;
532
- linearGradient: EAttr;
533
- marker: EAttr;
534
- mask: EAttr;
535
- metadata: EAttr;
536
- mpath: EAttr;
537
- pattern: EAttr;
538
- polygon: EAttr;
539
- polyline: EAttr;
540
- radialGradient: EAttr;
541
- rect: EAttr;
542
- set: EAttr;
543
- stop: EAttr;
544
- symbol: EAttr;
545
- text: EAttr;
546
- textPath: EAttr;
547
- title: EAttr;
548
- tspan: EAttr;
549
- use: EAttr;
550
- 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[]);
551
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
+
552
550
  interface aAttr<T = DVal> extends EAttr {
553
551
  download?: T;
554
552
  href?: T;
@@ -623,6 +621,12 @@ interface detailsAttr<T = DVal> extends EAttr {
623
621
  interface dialogAttr<T = DVal> extends EAttr {
624
622
  open?: T;
625
623
  }
624
+ interface embedAttr<T = DVal> extends EAttr {
625
+ height?: T;
626
+ src?: T;
627
+ type?: T;
628
+ width?: T;
629
+ }
626
630
  interface fieldsetAttr<T = DVal> extends EAttr {
627
631
  disabled?: T;
628
632
  form?: T;
@@ -767,6 +771,11 @@ interface optionAttr<T = DVal> extends EAttr {
767
771
  selected?: T;
768
772
  value?: T;
769
773
  }
774
+ interface outputAttr<T = DVal> extends EAttr {
775
+ for?: T;
776
+ form?: T;
777
+ name?: T;
778
+ }
770
779
  interface paramAttr<T = DVal> extends EAttr {
771
780
  name?: T;
772
781
  value?: T;
@@ -830,7 +839,7 @@ interface textareaAttr<T = DVal> extends EAttr {
830
839
  rows?: T;
831
840
  wrap?: T;
832
841
  }
833
- interface thAttr<T = DVal> extends EAttr {
842
+ interface thAttr<T = DVal> extends EAttr<T> {
834
843
  colspan?: T;
835
844
  headers?: T;
836
845
  rowspan?: T;
@@ -859,310 +868,687 @@ interface videoAttr<T = DVal> extends EAttr {
859
868
  src?: T;
860
869
  width?: T;
861
870
  }
862
-
863
- type kf = KeyframeAnimationOptions;
864
- type KFType = (CSSStyle | obj$1<V>)[] | CSSStyle | obj$1<V>;
865
- declare class anim {
866
- private e;
867
- opt: kf;
868
- constructor(e: Elem);
869
- animate(keyframes: CSSStyle[] | CSSStyle, options?: kf): Elem<HTMLElement>;
870
- get slide(): {
871
- left: (options?: kf) => anim;
872
- right: (options?: kf) => anim;
873
- up: (options?: kf) => anim;
874
- down: (options?: kf) => anim;
875
- };
876
- fade(options?: kf): this;
877
- shake(XorY?: string, opt?: kf): this;
878
- color(c?: string[], opt?: kf): this;
879
- bg(c?: string | string[], opt?: kf): this;
880
- bounce(sVal?: number, opt?: kf): this;
871
+ interface contenteditableAttr<T = DVal> extends EAttr {
872
+ enterkeyhint?: T;
873
+ inputmode?: T;
881
874
  }
882
875
 
883
- declare class Eget<T extends Elements = HTMLElement> {
884
- e: T;
885
- query?: string | undefined;
886
- constructor(e: T, query?: string | undefined);
887
- get a(): anim;
888
- get all(): T[];
889
- get attr(): {
890
- has: (attr: string) => boolean;
891
- get: (attr: string) => string | null;
892
- del: (attr: string) => Eget<T>;
893
- set: (attrs: obj$1<any>) => Eget<T>;
894
- };
895
- get children(): Elem<T>[];
896
- get click(): this;
897
- get delete(): this;
898
- get disabled(): boolean;
899
- get focus(): this;
900
- get href(): string;
901
- get id(): string;
902
- get inner(): string;
903
- get offsetParent(): Elem | undefined;
904
- get parent(): Elem | undefined;
905
- get hash(): string;
906
- get path(): string;
907
- get rect(): DOMRect;
908
- get remove_element(): this;
909
- get style(): {
910
- set: (style: CSSStyle | obj$1<V | null>, delayOrFN?: number | ((e?: any) => void)) => Elem<HTMLElement>;
911
- get: (prop: keyof CSSStyleDeclaration | string) => string;
912
- del: (...props: (keyof CSSStyleDeclaration | string)[]) => void;
913
- };
914
- get submit(): any;
915
- get tag(): string;
916
- get value(): any;
917
- get unload(): () => void;
918
- set append(val: any);
919
- set appendfirst(val: any);
920
- set inner(val: any);
921
- set disabled(vl: boolean);
922
- set id(did: string);
923
- 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;
924
983
  }
925
984
 
926
- type fn<E, T> = (e?: E) => T;
927
- declare class Elem<T extends Elements = HTMLElement> extends Eget<T> {
928
- constructor(e: T, query?: string);
929
- add(...className: string[]): () => void;
930
- remove(...className: string[]): this;
931
- toggle(className: string | fn<any, string>, force?: boolean): boolean;
932
- hasNode(e: Node): boolean;
933
- has(...classes: string[]): boolean;
934
- insert(position: InsertPosition): {
935
- HTML: (...text: string[]) => Elem<T>;
936
- element: (...elem: HTMLElement[]) => Elem<T>;
937
- text: (this: Elem<T>, ...text: string[]) => Elem<T>;
985
+ interface SVGAttributes {
986
+ svg: svgAttr & {
987
+ viewBox?: DVal;
938
988
  };
939
- is(tp: {
940
- dom?: string;
941
- class?: string | string[];
942
- }): boolean;
943
- on(event: keyof events, handler: (e?: any) => void, useCapture?: boolean): this;
944
- remove_on(event: keyof DocumentEventMap, handler: EventListenerOrEventListenerObject, useCapture?: boolean): this;
945
- timed(fn: (ee?: Elem<T>) => void, timeout?: number): this;
946
- animate(keyframes: KFType, options?: kf, onComplete?: fn<any, void>): this;
947
- animate(keyframes: KFType, onComplete?: fn<any, void>): this;
948
- }
949
-
950
- type Elements = HTMLElementTagNameMap[keyof HTMLElementTagNameMap] | SVGElementTagNameMap[keyof SVGElementTagNameMap];
951
- interface CLI {
952
- id?: string;
953
- class?: string;
954
- }
955
- declare function $<T extends Elements = HTMLElement, P extends Elements = HTMLElement>(query: CLI, parent?: P): Elem<T> | undefined;
956
- declare function $<T extends Elements = HTMLElement, P extends Elements = HTMLElement>(query: string, parent?: P): Elem<T> | undefined;
957
- declare function $<T extends Elements = HTMLElement>(element: T): Elem<T>;
958
- type _$<T extends Elements = HTMLElement> = Elem<T> | undefined;
959
- type $E<T extends Elements = HTMLElement> = Elem<T>;
960
- declare class Ref<T extends Elements = HTMLElement> {
961
- state: Stateful<_$<T>>;
962
- constructor();
963
- get element(): T | undefined;
964
- set element(elem: T | undefined);
965
- 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;
966
1094
  }
967
- declare const useRef: <T extends Elements = HTMLElement>() => Ref<T>;
968
1095
 
969
- declare class Dom {
970
- tag: string;
971
- attr: attr;
972
- ctx: ctx[];
973
- constructor(tag: string, attr: attr, ctx: ctx[]);
974
- }
975
- declare function dom(tag: string | ((attr: attr, ...ctx: ctx[]) => Dom), attr?: attr | null, ...ctx: ctx[]): Dom;
976
- declare const frag: (attr: attr, ...ctx: Dom[]) => Dom;
977
1096
  declare global {
978
1097
  type events<T extends Elements = HTMLElement> = {
979
1098
  [P in keyof GlobalEventHandlersEventMap]?: (this: T, e: GlobalEventHandlersEventMap[P]) => void;
980
1099
  } & c_events<T>;
981
- type DVal<T = V | V[]> = T | Stateful<T> | undefined;
982
- type dom = Dom;
983
- type ctx<T = DVal | dom> = T | Stateful<T> | ctx[];
984
- type obj<T> = Record<string, T>;
985
- type DomFN<T = {}> = (a: attr & T, ...D: ctx[]) => dom;
986
- type attr = EAttr;
987
1100
  namespace JSX {
988
- type Element = dom;
1101
+ type Element = maybePromise<DOM>;
989
1102
  interface IntrinsicElements extends ElementAttributes, SVGAttributes {
990
1103
  }
991
1104
  }
992
1105
  }
993
1106
 
994
- interface docObj {
995
- args?: obj<any>;
996
- 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;
997
1119
  }
998
- declare class doc<T extends docObj = obj<obj<any>>> extends head {
999
- path: string;
1000
- data: T["data"];
1001
- args: T["args"];
1002
- importArgs: any[];
1003
- fetch?(): maybePromise<obj<any>>;
1004
- head?(): maybePromise<void>;
1005
- body?(): maybePromise<any>;
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;
1006
1135
  }
1007
1136
 
1008
- type ExtraState = Record<string, unknown>;
1009
- type HistoryData<S extends ExtraState = ExtraState> = (S & {
1010
- path: string;
1011
- }) | null;
1012
- type ChangeHandler<S extends ExtraState> = (path: string, state: HistoryData<S>) => void;
1013
- declare class PathHistory<S extends ExtraState = ExtraState> {
1014
- private onChange?;
1015
- private popListener?;
1016
- constructor(path?: Stateful<string>, onChange?: ChangeHandler<S>);
1017
- /** Current path (pathname + search + hash) */
1018
- path(): string;
1019
- /** Current state object */
1020
- state(): HistoryData<S>;
1021
- /** Navigate to a new path using pushState (no-op if same as current) */
1022
- navigate(path: string, state?: S, title?: string): void;
1023
- /** Replace current entry using replaceState (no-op if same as current) */
1024
- replace(path: string, state?: S, title?: string): void;
1025
- back(): void;
1026
- forward(): void;
1027
- /** Remove listeners */
1028
- destroy(): void;
1029
- private resolve;
1030
- private samePath;
1031
- private assertClient;
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>;
1032
1154
  }
1033
1155
 
1034
- interface contentObj {
1035
- args?: obj<any>;
1036
- 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;
1037
1164
  }
1038
- declare class content<T extends contentObj = obj<obj<string>>> {
1039
- path: string;
1040
- data: T["data"];
1041
- args: T["args"];
1042
- body?(): maybePromise<any>;
1165
+
1166
+ interface RenderedDOM {
1167
+ ctx: string;
1168
+ oz: OZ;
1169
+ id: string | undefined;
1043
1170
  }
1171
+ type renderedDom = RenderedDOM;
1172
+ declare function renderDom(node: maybePromise<DOM>, pid?: Idm | string): Promise<RenderedDOM>;
1044
1173
 
1045
- declare class websocket<T = Record<string, any>> {
1174
+ interface YveeURL {
1046
1175
  path: string;
1047
- protected args: T;
1048
- route: string;
1049
- ws: WebSocket;
1050
- isConnected: Stateful<boolean>;
1051
- data: T;
1052
- constructor(path: string, args?: T);
1053
- protected open(event: Event): Promise<void> | void;
1054
- protected message(event: MessageEvent): Promise<void> | void;
1055
- protected close(event: CloseEvent): Promise<void> | void;
1056
- protected error(event: Event): Promise<void> | void;
1057
- get connect(): this;
1058
- get reconnect(): this;
1059
- get disconnect(): this;
1060
- /**
1061
- * code:
1062
- * * 0 - CONNECTING: The connection is being established.
1063
- * * 1 - OPEN: The connection is open and ready to communicate.
1064
- * * 2 - CLOSING: The connection is in the process of closing.
1065
- * * 3 - CLOSED: The connection has been closed or could not be opened.
1066
- */
1067
- get state(): number;
1068
- set send(message: string | ArrayBufferLike | Blob | ArrayBufferView);
1069
- }
1070
- declare class socket {
1071
- protected yvee: Yvee;
1072
- constructor(yvee: Yvee);
1073
- load(_path: string): Promise<websocket<Record<string, any>> | undefined>;
1074
- unload(_path: string): void;
1176
+ search: string;
1177
+ hash: string;
1178
+ params: URLSearchParams;
1075
1179
  }
1180
+ declare const normalizePath: (input: string) => string;
1181
+ declare const toURL: (input: string | URL) => YveeURL;
1076
1182
 
1077
- declare class BasePath<T> extends MinStorage {
1078
- cls: T;
1079
- constructor(path: string, cls: T);
1080
- }
1081
- declare class ClientPath extends BasePath<typeof doc<{}>> {
1082
- }
1083
- declare class SocketPath extends BasePath<typeof websocket> {
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;
1084
1202
  }
1085
- declare class MainStorage<T extends InstanceType<typeof BasePath>> {
1086
- storage: Storage<T>;
1087
- error: Storage<T>;
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;
1088
1241
  }
1089
- declare class Stormy extends MainStorage<ClientPath> {
1090
- wss: Storage<SocketPath>;
1091
- setRoute(path: string, _doc: typeof doc<{}>): void;
1092
- getRoute(path: string, error?: number): doc<{}>;
1093
- setWss(path: string): void;
1094
- getWss(path: string): [SocketPath | undefined, Record<string, string>];
1095
- setError(code: number, _doc: typeof doc<{}>): void;
1096
- getError(code?: number): [ClientPath | undefined, Record<string, string>];
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>[];
1097
1273
  }
1098
- declare class TabPath extends BasePath<typeof content<{}>> {
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>;
1099
1347
  }
1100
- declare class miniStormy extends MainStorage<TabPath> {
1101
- setRoute(path: string, _doc: typeof content<{}>): void;
1102
- getRoute(path: string, error?: number): content<{}>;
1103
- setWss(path: string): void;
1104
- getWss(path: string): void;
1105
- setError(code: number, _doc: typeof doc<{}>): void;
1106
- getError(code?: number): [TabPath | 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>;
1107
1352
  }
1108
1353
 
1109
- declare class Router extends htmlHead {
1110
- storage: Stormy;
1111
- protected base: string;
1112
- constructor(base?: string, index?: string);
1113
- route<Q extends typeof doc<{}>>(path: string): (f: Q) => Q;
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
+ };
1370
+ }
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;
1114
1390
  }
1115
1391
 
1116
- interface mtab {
1117
- tab: string;
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;
1118
1399
  }
1119
- declare class minElements$1 {
1120
- id: string;
1121
- path: Stateful<string>;
1122
- _root: Stateful<any[]>;
1123
- Main(a: attr): Dom;
1124
- Button(a: attr & mtab, ...ctx: ctx[]): Dom;
1400
+ interface MountOptions<T> {
1401
+ id?: string;
1402
+ data?: T;
1403
+ class?: string | string[];
1404
+ hydrate?: boolean;
1405
+ nonce?: string;
1125
1406
  }
1126
- declare class Tabs extends minElements$1 {
1127
- storage: miniStormy;
1128
- constructor();
1129
- tab<Q extends typeof content<{}>>(path: string): (f: Q) => Q;
1130
- load(tab: string, data?: obj<string>): Promise<void>;
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>;
1413
+
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;
1131
1450
  }
1132
1451
 
1133
- interface renderConfig {
1134
- class?: string | string[];
1135
- id?: string;
1136
- data?: any;
1137
- isDev?: boolean;
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;
1138
1539
  }
1139
- interface _Yvee {
1140
- base?: string;
1141
- index?: string;
1142
- history?: boolean;
1540
+ interface StreamOptions extends EventSourceInit {
1541
+ signal?: AbortSignal;
1143
1542
  }
1144
- declare class minElements extends Router {
1145
- protected pushHistory: boolean;
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: {
1146
1549
  id: string;
1147
- data: obj<any>;
1148
- path: Stateful<string>;
1149
- protected _root: Stateful<any[]>;
1150
- constructor(base?: string, index?: string, pushHistory?: boolean);
1151
- Main(a: attr): Dom;
1152
- A(a: aAttr, ...ctx: ctx[]): Dom;
1153
- }
1154
- interface serverRender {
1155
- path: string;
1156
- error?: number;
1157
- data?: Record<string, any>;
1158
- }
1159
- declare class Yvee extends minElements {
1160
- yvee: Yvee;
1161
- constructor({ base, history, index }?: _Yvee);
1162
- render(x?: renderConfig): Promise<(() => void) | (({ path, data, error }: serverRender) => Promise<string>)>;
1163
- private init;
1164
- }
1165
- declare const Routes: (fn: (route: Yvee["route"]) => void) => (route: Yvee["route"]) => void;
1550
+ nonce?: string;
1551
+ }): string;
1166
1552
 
1167
- export { $, IfClient, Meta, PathHistory, QState, Ref, Routes, State, StateHook, Stateful, Tabs, Time, Yvee, __, addCSS, content, cssLoader, doc, dom, frag, log, socket, useRef, websocket };
1168
- 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 };