yvee 0.0.6 → 0.0.8
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 +316 -196
- package/dist/index.js +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
declare const isFN: (v: any) => v is Function;
|
|
2
2
|
declare const isAsync: (v: any) => v is Function;
|
|
3
|
+
declare const isPromise: (v: any) => v is Function;
|
|
3
4
|
declare const isNumber: (value: any) => boolean;
|
|
4
|
-
declare const
|
|
5
|
+
declare const isObject: (val: any) => val is Record<string, any>;
|
|
5
6
|
declare const isPlainObject: (value: any) => boolean;
|
|
6
7
|
declare const isArraybuff: (val: any) => val is string | ArrayBuffer | Uint8Array<ArrayBufferLike>;
|
|
7
8
|
declare const isClassOrId: (k: string) => boolean;
|
|
@@ -11,7 +12,9 @@ declare const isArr: (v: any) => v is any[];
|
|
|
11
12
|
declare const isObj: (v: any) => v is object;
|
|
12
13
|
declare const isNum: (v: any) => v is number;
|
|
13
14
|
declare const isNull: (v: any) => v is null;
|
|
15
|
+
declare const isNotNull: <T>(v: T) => v is Exclude<T, null>;
|
|
14
16
|
declare const isUndefined: (v: any) => v is undefined;
|
|
17
|
+
declare const isDefined: <T>(v: T) => v is Exclude<T, undefined>;
|
|
15
18
|
declare const isInt: (str: string) => boolean;
|
|
16
19
|
declare const isWindow: boolean;
|
|
17
20
|
declare const isNotWindow: boolean;
|
|
@@ -21,24 +24,48 @@ declare const is_isArraybuff: typeof isArraybuff;
|
|
|
21
24
|
declare const is_isAsync: typeof isAsync;
|
|
22
25
|
declare const is_isBool: typeof isBool;
|
|
23
26
|
declare const is_isClassOrId: typeof isClassOrId;
|
|
24
|
-
declare const
|
|
27
|
+
declare const is_isDefined: typeof isDefined;
|
|
25
28
|
declare const is_isFN: typeof isFN;
|
|
26
29
|
declare const is_isInt: typeof isInt;
|
|
30
|
+
declare const is_isNotNull: typeof isNotNull;
|
|
27
31
|
declare const is_isNotWindow: typeof isNotWindow;
|
|
28
32
|
declare const is_isNull: typeof isNull;
|
|
29
33
|
declare const is_isNum: typeof isNum;
|
|
30
34
|
declare const is_isNumber: typeof isNumber;
|
|
31
35
|
declare const is_isObj: typeof isObj;
|
|
36
|
+
declare const is_isObject: typeof isObject;
|
|
32
37
|
declare const is_isPlainObject: typeof isPlainObject;
|
|
38
|
+
declare const is_isPromise: typeof isPromise;
|
|
33
39
|
declare const is_isStr: typeof isStr;
|
|
34
40
|
declare const is_isUndefined: typeof isUndefined;
|
|
35
41
|
declare const is_isWindow: typeof isWindow;
|
|
36
42
|
declare namespace is {
|
|
37
|
-
export {
|
|
43
|
+
export {
|
|
44
|
+
is_isArr as isArr,
|
|
45
|
+
is_isArraybuff as isArraybuff,
|
|
46
|
+
is_isAsync as isAsync,
|
|
47
|
+
is_isBool as isBool,
|
|
48
|
+
is_isClassOrId as isClassOrId,
|
|
49
|
+
is_isDefined as isDefined,
|
|
50
|
+
is_isFN as isFN,
|
|
51
|
+
is_isInt as isInt,
|
|
52
|
+
is_isNotNull as isNotNull,
|
|
53
|
+
is_isNotWindow as isNotWindow,
|
|
54
|
+
is_isNull as isNull,
|
|
55
|
+
is_isNum as isNum,
|
|
56
|
+
is_isNumber as isNumber,
|
|
57
|
+
is_isObj as isObj,
|
|
58
|
+
is_isObject as isObject,
|
|
59
|
+
is_isPlainObject as isPlainObject,
|
|
60
|
+
is_isPromise as isPromise,
|
|
61
|
+
is_isStr as isStr,
|
|
62
|
+
is_isUndefined as isUndefined,
|
|
63
|
+
is_isWindow as isWindow,
|
|
64
|
+
};
|
|
38
65
|
}
|
|
39
66
|
|
|
40
67
|
type V = string | number | boolean;
|
|
41
|
-
type obj<T> = Record<string, T>;
|
|
68
|
+
type obj$1<T> = Record<string, T>;
|
|
42
69
|
|
|
43
70
|
/**
|
|
44
71
|
* A custom Map implementation that provides additional utility methods for working with objects and maps.
|
|
@@ -54,8 +81,10 @@ declare class Mapper<K, V> extends Map<K, V> {
|
|
|
54
81
|
init(key: K, val: V): V;
|
|
55
82
|
}
|
|
56
83
|
|
|
57
|
-
declare class
|
|
58
|
-
static set
|
|
84
|
+
declare class log {
|
|
85
|
+
static set i(a: any);
|
|
86
|
+
static set e(a: any);
|
|
87
|
+
static set w(a: any);
|
|
59
88
|
}
|
|
60
89
|
declare class idm {
|
|
61
90
|
_c: number;
|
|
@@ -111,7 +140,7 @@ declare class Meta {
|
|
|
111
140
|
themeColor(color: string): this;
|
|
112
141
|
openGraph(og: Omit<OG, "card">): this;
|
|
113
142
|
twitter(og: OG): this;
|
|
114
|
-
|
|
143
|
+
push(metas: meta$1<string>[]): void;
|
|
115
144
|
private set meta(value);
|
|
116
145
|
}
|
|
117
146
|
|
|
@@ -137,9 +166,9 @@ type link<T> = {
|
|
|
137
166
|
crossorigin?: T;
|
|
138
167
|
};
|
|
139
168
|
type impmap = {
|
|
140
|
-
imports?: obj<string>;
|
|
141
|
-
scopes?: obj<string>;
|
|
142
|
-
integrity?: obj<string>;
|
|
169
|
+
imports?: obj$1<string>;
|
|
170
|
+
scopes?: obj$1<string>;
|
|
171
|
+
integrity?: obj$1<string>;
|
|
143
172
|
};
|
|
144
173
|
type script<T> = {
|
|
145
174
|
async?: T;
|
|
@@ -164,6 +193,8 @@ interface headAttr {
|
|
|
164
193
|
meta?: meta<string>[] | Meta;
|
|
165
194
|
link?: link<string>[];
|
|
166
195
|
script?: script<string | boolean>[];
|
|
196
|
+
css?: string[] | string;
|
|
197
|
+
description?: string;
|
|
167
198
|
}
|
|
168
199
|
declare class head implements headAttr {
|
|
169
200
|
title?: string;
|
|
@@ -182,7 +213,7 @@ type CSSinT$1 = {
|
|
|
182
213
|
type headType = Mapper<keyof head, any>;
|
|
183
214
|
declare class htmlHead {
|
|
184
215
|
lang: string;
|
|
185
|
-
|
|
216
|
+
htmlHead: headType;
|
|
186
217
|
head: (heads?: headAttr) => void;
|
|
187
218
|
constructor();
|
|
188
219
|
}
|
|
@@ -202,21 +233,42 @@ declare class MinStorage {
|
|
|
202
233
|
*/
|
|
203
234
|
declare class Storage$1<T extends MinStorage> {
|
|
204
235
|
private _storage;
|
|
236
|
+
private CC;
|
|
237
|
+
constructor();
|
|
205
238
|
set(min: T): void;
|
|
206
239
|
get(path: string): [T | undefined, Record<string, string>];
|
|
207
240
|
}
|
|
208
241
|
|
|
242
|
+
declare class Time {
|
|
243
|
+
date: Date;
|
|
244
|
+
constructor(dateMS?: number);
|
|
245
|
+
delta(date2?: number | null, _Date?: boolean): number | Date;
|
|
246
|
+
timed(time?: {
|
|
247
|
+
year?: number;
|
|
248
|
+
month?: number;
|
|
249
|
+
day?: number;
|
|
250
|
+
hour?: number;
|
|
251
|
+
minute?: number;
|
|
252
|
+
second?: number;
|
|
253
|
+
}): Date;
|
|
254
|
+
static delta(date1: number, date2?: number | null): number;
|
|
255
|
+
static local(date: number): string;
|
|
256
|
+
static get now(): number;
|
|
257
|
+
}
|
|
258
|
+
|
|
209
259
|
declare class __ {
|
|
210
260
|
static rand(min?: number, max?: number): number;
|
|
211
261
|
static fill(count: number, fill?: any): any[];
|
|
212
262
|
static new({ dom, id, inner, }: {
|
|
213
|
-
dom: keyof HTMLElementTagNameMap;
|
|
263
|
+
dom: keyof HTMLElementTagNameMap | keyof SVGElementTagNameMap;
|
|
214
264
|
id?: string;
|
|
215
265
|
inner?: any;
|
|
216
266
|
}): HTMLElement;
|
|
217
267
|
static randFrom(arr: any[] | Object): any;
|
|
268
|
+
static randArray<T>(arr?: T[], length?: number, unique?: boolean): T[];
|
|
269
|
+
static randomAZ: () => string;
|
|
218
270
|
static makeID: (length: number) => string;
|
|
219
|
-
static class(a: obj<any>, classes: string[]): void;
|
|
271
|
+
static class(a: obj$1<any>, ...classes: string[]): void;
|
|
220
272
|
static get O(): {
|
|
221
273
|
vals: {
|
|
222
274
|
<T>(o: {
|
|
@@ -245,9 +297,23 @@ declare class __ {
|
|
|
245
297
|
};
|
|
246
298
|
static get is(): typeof is;
|
|
247
299
|
static get return(): typeof returner;
|
|
300
|
+
static sleep: (ms?: number) => Promise<unknown>;
|
|
301
|
+
static get screen(): "xs" | "sm" | "smd" | "md" | "lg" | "xl" | "xxl" | undefined;
|
|
302
|
+
bytes(bytes: number): string;
|
|
303
|
+
static format(val: any): Formatteer;
|
|
248
304
|
}
|
|
249
305
|
declare class returner {
|
|
250
|
-
static
|
|
306
|
+
static arr<T = string>(val?: any): T[];
|
|
307
|
+
static num(val: any, iferr?: any): number;
|
|
308
|
+
static str(val: any): string;
|
|
309
|
+
static arr2obj(val: any[], switched?: boolean): any;
|
|
310
|
+
}
|
|
311
|
+
declare class Formatteer {
|
|
312
|
+
val: any;
|
|
313
|
+
constructor(val: any);
|
|
314
|
+
get px(): string;
|
|
315
|
+
get rem(): string;
|
|
316
|
+
get pr(): string;
|
|
251
317
|
}
|
|
252
318
|
|
|
253
319
|
declare class CATT {
|
|
@@ -281,11 +347,18 @@ declare class OZ {
|
|
|
281
347
|
RPS(oz?: this): this;
|
|
282
348
|
}
|
|
283
349
|
|
|
350
|
+
declare class ATTR {
|
|
351
|
+
attr: attr;
|
|
352
|
+
constructor(attr?: attr);
|
|
353
|
+
get(catt: CATT, attr?: attr, pre?: string): void;
|
|
354
|
+
unload<T>(x: string): T | undefined;
|
|
355
|
+
}
|
|
356
|
+
|
|
284
357
|
declare class eStream {
|
|
285
358
|
stream: EventSource;
|
|
286
359
|
url: string;
|
|
287
360
|
constructor(eurl: string, withCredentials: boolean);
|
|
288
|
-
on(event: obj<(a: MessageEvent) => void>): this;
|
|
361
|
+
on(event: obj$1<(a: MessageEvent) => void>): this;
|
|
289
362
|
}
|
|
290
363
|
declare function eventStream(url: string, withCredentials?: boolean): eStream;
|
|
291
364
|
|
|
@@ -298,14 +371,14 @@ declare class __I {
|
|
|
298
371
|
get bool(): boolean | null;
|
|
299
372
|
get json(): any | null;
|
|
300
373
|
}
|
|
301
|
-
|
|
374
|
+
type storeValTypes = keyof __I;
|
|
375
|
+
declare class storageInterface<T> {
|
|
302
376
|
key: string;
|
|
303
|
-
|
|
377
|
+
state: Stateful<T> | null;
|
|
304
378
|
storage: Storage;
|
|
305
|
-
constructor(item: obj<
|
|
379
|
+
constructor(item: obj$1<Stateful<T>> | string, _type?: "local" | "session", init?: storeValTypes);
|
|
306
380
|
get as(): __I;
|
|
307
381
|
get value(): string | null;
|
|
308
|
-
get save(): void;
|
|
309
382
|
set set(val: any);
|
|
310
383
|
get remove(): void;
|
|
311
384
|
}
|
|
@@ -314,45 +387,156 @@ declare class storageInterface {
|
|
|
314
387
|
* Local Storage
|
|
315
388
|
*/
|
|
316
389
|
declare const local: {
|
|
317
|
-
get: (item: obj<
|
|
390
|
+
get: <T>(item: obj$1<Stateful<T>> | string) => storageInterface<T>;
|
|
391
|
+
init: <T>(item: obj$1<Stateful<T>>, as: storeValTypes) => storageInterface<T>;
|
|
318
392
|
};
|
|
319
393
|
|
|
320
394
|
/**
|
|
321
395
|
* Session Storage
|
|
322
396
|
*/
|
|
323
397
|
declare const session: {
|
|
324
|
-
get: (item: obj<
|
|
398
|
+
get: <T>(item: obj$1<Stateful<T>> | string) => storageInterface<T>;
|
|
325
399
|
};
|
|
326
400
|
|
|
327
|
-
|
|
401
|
+
type kf = KeyframeAnimationOptions;
|
|
402
|
+
type KFType = (CSSinT | obj$1<V>)[] | CSSinT | obj$1<V>;
|
|
403
|
+
declare class anim {
|
|
404
|
+
private e;
|
|
405
|
+
opt: kf;
|
|
406
|
+
constructor(e: Elem);
|
|
407
|
+
animate(keyframes: CSSinT[] | CSSinT, options?: kf): Elem<HTMLElement>;
|
|
408
|
+
get slide(): {
|
|
409
|
+
left: (options?: kf) => anim;
|
|
410
|
+
right: (options?: kf) => anim;
|
|
411
|
+
up: (options?: kf) => anim;
|
|
412
|
+
down: (options?: kf) => anim;
|
|
413
|
+
};
|
|
414
|
+
fade(options?: kf): this;
|
|
415
|
+
shake(XorY?: string, opt?: kf): this;
|
|
416
|
+
color(c?: string[], opt?: kf): this;
|
|
417
|
+
bg(c?: string | string[], opt?: kf): this;
|
|
418
|
+
bounce(sVal?: number, opt?: kf): this;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
declare class Eget<T extends Elements = HTMLElement> {
|
|
422
|
+
e: T;
|
|
423
|
+
query?: string | undefined;
|
|
424
|
+
constructor(e: T, query?: string | undefined);
|
|
425
|
+
get a(): anim;
|
|
426
|
+
get all(): T[];
|
|
427
|
+
get attr(): {
|
|
428
|
+
has: (attr: string) => boolean;
|
|
429
|
+
get: (attr: string) => string | null;
|
|
430
|
+
del: (attr: string) => Eget<T>;
|
|
431
|
+
set: (attrs: obj$1<any>) => Eget<T>;
|
|
432
|
+
};
|
|
433
|
+
get children(): Elem<T>[];
|
|
434
|
+
get click(): this;
|
|
435
|
+
get delete(): this;
|
|
436
|
+
get disabled(): boolean;
|
|
437
|
+
get focus(): this;
|
|
438
|
+
get href(): string;
|
|
439
|
+
get id(): string;
|
|
440
|
+
get inner(): string;
|
|
441
|
+
get offsetParent(): Elem | undefined;
|
|
442
|
+
get parent(): Elem | undefined;
|
|
443
|
+
get hash(): string;
|
|
444
|
+
get path(): string;
|
|
445
|
+
get rect(): DOMRect;
|
|
446
|
+
get remove_element(): this;
|
|
447
|
+
get style(): {
|
|
448
|
+
set: (style: CSSinT | obj$1<V | null>, delayOrFN?: number | ((e?: any) => void)) => Elem<HTMLElement>;
|
|
449
|
+
get: (prop: keyof CSSStyleDeclaration | string) => string;
|
|
450
|
+
del: (...props: (keyof CSSStyleDeclaration | string)[]) => void;
|
|
451
|
+
};
|
|
452
|
+
get submit(): any;
|
|
453
|
+
get tag(): string;
|
|
454
|
+
get value(): any;
|
|
455
|
+
get unload(): () => void;
|
|
456
|
+
set append(val: any);
|
|
457
|
+
set appendfirst(val: any);
|
|
458
|
+
set inner(val: any);
|
|
459
|
+
set disabled(vl: boolean);
|
|
460
|
+
set id(did: string);
|
|
461
|
+
set value(vl: any);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
type fn<E, T> = (e?: E) => T;
|
|
465
|
+
declare class Elem<T extends Elements = HTMLElement> extends Eget<T> {
|
|
466
|
+
constructor(e: T, query?: string);
|
|
467
|
+
add(...className: string[]): () => void;
|
|
468
|
+
remove(...className: string[]): this;
|
|
469
|
+
toggle(className: string | fn<any, string>, force?: boolean): boolean;
|
|
470
|
+
hasNode(e: Node): boolean;
|
|
471
|
+
has(...classes: string[]): boolean;
|
|
472
|
+
insert(position: InsertPosition): {
|
|
473
|
+
HTML: (...text: string[]) => Elem<T>;
|
|
474
|
+
element: (...elem: HTMLElement[]) => Elem<T>;
|
|
475
|
+
text: (this: Elem<T>, ...text: string[]) => Elem<T>;
|
|
476
|
+
};
|
|
477
|
+
is(tp: {
|
|
478
|
+
dom?: string;
|
|
479
|
+
class?: string | string[];
|
|
480
|
+
}): boolean;
|
|
481
|
+
on(event: keyof events, handler: (e?: any) => void, useCapture?: boolean): this;
|
|
482
|
+
remove_on(event: keyof DocumentEventMap, handler: EventListenerOrEventListenerObject, useCapture?: boolean): this;
|
|
483
|
+
timed(fn: (ee?: Elem<T>) => void, timeout?: number): this;
|
|
484
|
+
animate(keyframes: KFType, options?: kf, onComplete?: fn<any, void>): this;
|
|
485
|
+
animate(keyframes: KFType, onComplete?: fn<any, void>): this;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
interface CLI {
|
|
489
|
+
id?: string;
|
|
490
|
+
class?: string;
|
|
491
|
+
}
|
|
492
|
+
declare function $<T extends Elements = HTMLElement, P extends Elements = HTMLElement>(query: CLI, parent?: P): Elem<T> | undefined;
|
|
493
|
+
declare function $<T extends Elements = HTMLElement, P extends Elements = HTMLElement>(query: string, parent?: P): Elem<T> | undefined;
|
|
494
|
+
declare function $<T extends Elements = HTMLElement>(element: T): Elem<T>;
|
|
495
|
+
type _$<T extends Elements = HTMLElement> = Elem<T> | undefined;
|
|
496
|
+
type $E<T extends Elements = HTMLElement> = Elem<T>;
|
|
497
|
+
declare class Ref<T extends Elements = HTMLElement> {
|
|
498
|
+
state: Stateful<_$<T>>;
|
|
499
|
+
constructor();
|
|
500
|
+
get element(): T | undefined;
|
|
501
|
+
set element(elem: T | undefined);
|
|
502
|
+
get $(): _$<T>;
|
|
503
|
+
}
|
|
504
|
+
declare const useRef: <T extends Elements = HTMLElement>() => Ref<T>;
|
|
505
|
+
|
|
506
|
+
declare class doc<T extends {
|
|
507
|
+
args?: Record<string, any>;
|
|
508
|
+
data?: Record<string, any>;
|
|
509
|
+
} = Record<string, any>> extends head {
|
|
328
510
|
path: string;
|
|
329
|
-
args: T;
|
|
511
|
+
args: T["args"];
|
|
330
512
|
id: string;
|
|
331
513
|
status: number;
|
|
332
514
|
lang?: string;
|
|
333
515
|
import?: any;
|
|
334
|
-
_data: T;
|
|
335
|
-
|
|
336
|
-
|
|
516
|
+
_data: T["data"];
|
|
517
|
+
static route: string;
|
|
518
|
+
constructor(path: string, args: T["args"] | undefined, id: string, status?: number);
|
|
519
|
+
fetch?(): Promise<Record<string, any>>;
|
|
337
520
|
head?(): Promise<void> | void;
|
|
338
521
|
body?(): Promise<Dom> | Dom;
|
|
339
522
|
loader(): Promise<any[]>;
|
|
340
523
|
getHeadAttr(head?: headAttr, ...toMap: headType[]): headType;
|
|
341
|
-
set data(data: obj<any>);
|
|
342
|
-
get data(): T;
|
|
524
|
+
set data(data: obj$1<any>);
|
|
525
|
+
get data(): T["data"];
|
|
343
526
|
}
|
|
344
527
|
|
|
345
|
-
declare class websocket<T = Record<string,
|
|
528
|
+
declare class websocket<T = Record<string, any>> {
|
|
346
529
|
path: string;
|
|
347
|
-
args: T;
|
|
530
|
+
protected args: T;
|
|
348
531
|
ws: WebSocket;
|
|
532
|
+
static route: string;
|
|
349
533
|
isConnected: Stateful<boolean>;
|
|
350
534
|
data: T;
|
|
351
535
|
constructor(path: string, args?: T);
|
|
352
|
-
open(event: Event): Promise<void> | void;
|
|
353
|
-
message(event: MessageEvent): Promise<void> | void;
|
|
354
|
-
close(event: CloseEvent): Promise<void> | void;
|
|
355
|
-
error(event: Event): Promise<void> | void;
|
|
536
|
+
protected open(event: Event): Promise<void> | void;
|
|
537
|
+
protected message(event: MessageEvent): Promise<void> | void;
|
|
538
|
+
protected close(event: CloseEvent): Promise<void> | void;
|
|
539
|
+
protected error(event: Event): Promise<void> | void;
|
|
356
540
|
get connect(): this;
|
|
357
541
|
get reconnect(): this;
|
|
358
542
|
get disconnect(): this;
|
|
@@ -367,59 +551,74 @@ declare class websocket<T = Record<string, string>> {
|
|
|
367
551
|
set send(message: string | ArrayBufferLike | Blob | ArrayBufferView);
|
|
368
552
|
}
|
|
369
553
|
declare class socket {
|
|
370
|
-
|
|
371
|
-
constructor(
|
|
554
|
+
protected yvee: Pager;
|
|
555
|
+
constructor(yvee: Pager);
|
|
372
556
|
load(_path: string): Promise<websocket<{}> | undefined>;
|
|
373
557
|
unload(_path: string): void;
|
|
374
558
|
}
|
|
375
559
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
classes?: string | string[];
|
|
379
|
-
}
|
|
380
|
-
declare class Router extends minClient {
|
|
381
|
-
private isYRA;
|
|
382
|
-
protected unload: boolean;
|
|
560
|
+
declare class Pager extends minClient {
|
|
561
|
+
protected config: routerCfg;
|
|
383
562
|
protected hook?: () => void;
|
|
384
563
|
protected root: Stateful<ctx[]>;
|
|
385
|
-
|
|
564
|
+
socket: socket;
|
|
386
565
|
id: string;
|
|
387
566
|
path: Stateful<string>;
|
|
388
567
|
lastPath: Stateful<string>;
|
|
568
|
+
loading: Stateful<boolean>;
|
|
569
|
+
mainElement?: HTMLElement;
|
|
389
570
|
A: (a: attr & {
|
|
390
571
|
href: string;
|
|
572
|
+
topRef?: Stateful<_$>;
|
|
573
|
+
top?: number | (() => number);
|
|
391
574
|
}, ...D: ctx[]) => Dom;
|
|
392
|
-
Main: (a: attr
|
|
393
|
-
load?: string;
|
|
394
|
-
}) => Dom;
|
|
575
|
+
Main: (a: attr) => Dom;
|
|
395
576
|
load: (path?: string, data?: obj<string>) => Promise<this>;
|
|
396
|
-
|
|
577
|
+
matchPath: (str: string) => boolean;
|
|
578
|
+
protected isYvee: boolean;
|
|
579
|
+
constructor(config?: routerCfg, events?: events);
|
|
397
580
|
protected hooker(): void;
|
|
398
|
-
protected class(this:
|
|
581
|
+
protected class(this: Pager, _path: string, _error: number, isError?: boolean): Promise<doc<{}>>;
|
|
399
582
|
protected fetch(CL?: doc<{}>): Promise<void>;
|
|
400
583
|
protected processHead(CL?: doc<{}>, head?: headAttr): Promise<headType>;
|
|
401
584
|
private processClassHead;
|
|
402
585
|
private processDefaultHead;
|
|
403
|
-
|
|
586
|
+
render(_path: string, _error?: number, data?: obj<string>, head?: headAttr, isClient?: boolean, isError?: boolean): Promise<{
|
|
404
587
|
lang: string;
|
|
405
588
|
heads: headType;
|
|
406
589
|
done: boolean;
|
|
407
590
|
}>;
|
|
408
591
|
}
|
|
409
|
-
|
|
592
|
+
|
|
593
|
+
declare function pushHistory(path?: string, title?: string): void;
|
|
594
|
+
|
|
595
|
+
interface routerCfg {
|
|
596
|
+
classes?: string | string[];
|
|
597
|
+
id?: string;
|
|
598
|
+
base?: string;
|
|
599
|
+
}
|
|
600
|
+
interface yveeCfg extends routerCfg {
|
|
601
|
+
pushState?: boolean;
|
|
602
|
+
}
|
|
603
|
+
declare class Yvee extends Pager {
|
|
604
|
+
protected config: yveeCfg;
|
|
605
|
+
protected isYvee: boolean;
|
|
410
606
|
protected unload: boolean;
|
|
411
|
-
constructor(
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
607
|
+
constructor(config?: yveeCfg, events?: events);
|
|
608
|
+
}
|
|
609
|
+
declare const Routes: (fn: (Yvee: Yvee) => void) => (Yvee: Yvee) => void;
|
|
610
|
+
interface headAttrPlus {
|
|
611
|
+
route?: string;
|
|
612
|
+
base?: string;
|
|
613
|
+
index?: string;
|
|
614
|
+
id?: string;
|
|
615
|
+
bodyattr?: obj$1<V>;
|
|
616
|
+
data?: Record<string, any> | (() => Promise<Record<string, any>> | Record<string, any>);
|
|
617
|
+
}
|
|
618
|
+
type headFN<T = Record<string, any>> = (a: renderConfig & T) => Promise<headAttr> | headAttr;
|
|
619
|
+
type ND<T = Record<string, any>> = (a: renderConfig & T) => Dom | Promise<Dom>;
|
|
620
|
+
declare function Render<T = Record<string, any>>(DOM: ND<T>, head?: headAttr | headFN<T>, cfg?: headAttrPlus): Promise<({ path, data, status }: serverRender) => Promise<string>>;
|
|
621
|
+
declare function Render<T = Record<string, any>>(DOM: ND<T>, App: Yvee): Promise<({ path, data, status }: serverRender) => Promise<string>>;
|
|
423
622
|
|
|
424
623
|
declare class ClientPath extends MinStorage {
|
|
425
624
|
id: string;
|
|
@@ -432,8 +631,6 @@ declare class SocketPath extends MinStorage {
|
|
|
432
631
|
constructor(path: string, id: string, cls: typeof websocket<{}>);
|
|
433
632
|
}
|
|
434
633
|
declare class minClient extends htmlHead {
|
|
435
|
-
protected ImportMeta: ImportMeta;
|
|
436
|
-
protected config: yveeCfg;
|
|
437
634
|
protected storage: Storage$1<ClientPath>;
|
|
438
635
|
protected errorStorage: Storage$1<ClientPath>;
|
|
439
636
|
protected wssStorage: Storage$1<SocketPath>;
|
|
@@ -444,20 +641,22 @@ declare class minClient extends htmlHead {
|
|
|
444
641
|
route: (path: string) => <Q extends typeof doc<{}>>(f: Q) => Q;
|
|
445
642
|
error: (...codes: number[]) => <Q extends typeof doc<{}>>(f: Q) => Q;
|
|
446
643
|
wss: (path: string) => <Q extends typeof websocket<{}>>(f: Q) => Q;
|
|
447
|
-
|
|
644
|
+
base: string;
|
|
645
|
+
constructor(base?: string);
|
|
646
|
+
protected _base(str: string): string;
|
|
448
647
|
protected getPath(path: string): Promise<[ClientPath | undefined, Record<string, string>]>;
|
|
449
648
|
protected loadError(code: number): Promise<[ClientPath | undefined, Record<string, string>]>;
|
|
450
649
|
protected loadWSS(path: string): Promise<[SocketPath | undefined, Record<string, string>]>;
|
|
451
650
|
}
|
|
452
651
|
|
|
453
|
-
type Elements = HTMLElementTagNameMap[keyof HTMLElementTagNameMap];
|
|
652
|
+
type Elements = HTMLElementTagNameMap[keyof HTMLElementTagNameMap] | SVGElementTagNameMap[keyof SVGElementTagNameMap];
|
|
454
653
|
|
|
455
654
|
type hookFN<T extends any[]> = (...args: statefulValue<T>) => void;
|
|
456
655
|
interface stateCFG {
|
|
457
656
|
id?: string;
|
|
458
657
|
init?: boolean;
|
|
459
658
|
}
|
|
460
|
-
declare function
|
|
659
|
+
declare function StateHook<T extends any[]>(callback: hookFN<T>, statefuls: [...{
|
|
461
660
|
[K in keyof T]: Stateful<T[K]>;
|
|
462
661
|
}], { id, init }?: stateCFG): () => void;
|
|
463
662
|
|
|
@@ -465,48 +664,56 @@ type statefulValue<T extends any[]> = {
|
|
|
465
664
|
[K in keyof T]: T[K] extends Stateful<infer U> ? U : T[K];
|
|
466
665
|
};
|
|
467
666
|
declare class Stateful<T> extends EventTarget {
|
|
468
|
-
private options
|
|
667
|
+
private options;
|
|
668
|
+
private deep;
|
|
669
|
+
private verify;
|
|
469
670
|
private hooks;
|
|
470
671
|
private states;
|
|
471
672
|
private _value;
|
|
472
673
|
private listening;
|
|
473
674
|
private end?;
|
|
474
|
-
constructor(value: T, options?: AddEventListenerOptions
|
|
675
|
+
constructor(value: T, options?: AddEventListenerOptions, deep?: boolean, verify?: boolean);
|
|
475
676
|
get value(): T;
|
|
476
677
|
set value(newValue: T);
|
|
477
678
|
get listen(): () => void;
|
|
478
679
|
call<Q>(callback: (this: Elements, arg: T) => Q, entry: string): (id: string) => () => void;
|
|
479
680
|
hook<T extends any[]>(callback: hookFN<T>): (id: string) => () => void;
|
|
480
681
|
}
|
|
481
|
-
declare function State<T>(value: T): Stateful<T>;
|
|
682
|
+
declare function State<T>(value: T, options?: AddEventListenerOptions): Stateful<T>;
|
|
683
|
+
/**
|
|
684
|
+
* Quick State checking - skip checking of Object keys:values as it will only be compared as a===b
|
|
685
|
+
*/
|
|
686
|
+
declare function QState<T>(value: T, verify?: boolean): Stateful<T>;
|
|
482
687
|
|
|
483
688
|
type X2 = V | V[];
|
|
484
|
-
type X3 = X2 | Stateful<X2
|
|
689
|
+
type X3 = X2 | Stateful<X2> | null | undefined;
|
|
485
690
|
type CSSinT = {
|
|
486
691
|
[P in keyof CSSStyleDeclaration]?: X3;
|
|
487
692
|
} & {
|
|
488
693
|
[key: string]: X3;
|
|
489
694
|
};
|
|
490
|
-
interface c_events {
|
|
491
|
-
|
|
492
|
-
ready?: (this:
|
|
493
|
-
resize?: (this:
|
|
494
|
-
beforeunload?: (this:
|
|
495
|
-
popstate?: (this:
|
|
496
|
-
winscroll?: (this:
|
|
497
|
-
winload?: (this:
|
|
498
|
-
winfocus?: (this:
|
|
499
|
-
winblur?: (this:
|
|
500
|
-
}
|
|
695
|
+
interface c_events<T extends Elements = HTMLElement> {
|
|
696
|
+
state?: (this: T, e: T) => [(...args: any[]) => void, Stateful<any>[], boolean?];
|
|
697
|
+
ready?: (this: T, e: T) => void;
|
|
698
|
+
resize?: (this: T, e: UIEvent) => void;
|
|
699
|
+
beforeunload?: (this: T, e: BeforeUnloadEvent) => void;
|
|
700
|
+
popstate?: (this: T, e: PopStateEvent) => void;
|
|
701
|
+
winscroll?: (this: T, e: Event) => void;
|
|
702
|
+
winload?: (this: T, e: Event) => void;
|
|
703
|
+
winfocus?: (this: T, e: Event) => void;
|
|
704
|
+
winblur?: (this: T, e: Event) => void;
|
|
705
|
+
}
|
|
706
|
+
type XU4 = V | undefined | XU4[];
|
|
501
707
|
interface baseAttr {
|
|
502
|
-
style?: CSSinT;
|
|
503
|
-
on?: events
|
|
708
|
+
style?: CSSinT | string;
|
|
709
|
+
on?: events<any>;
|
|
504
710
|
id?: string;
|
|
505
|
-
class?:
|
|
711
|
+
class?: XU4 | Stateful<X2>;
|
|
712
|
+
ref?: Ref<any>;
|
|
506
713
|
}
|
|
507
714
|
declare class Dom {
|
|
508
715
|
tag: string;
|
|
509
|
-
|
|
716
|
+
attr: ATTR;
|
|
510
717
|
private ctx;
|
|
511
718
|
constructor(tag: string, attr?: attr, ...ctx: ctx[]);
|
|
512
719
|
__(pid?: idm): {
|
|
@@ -518,121 +725,22 @@ declare class Dom {
|
|
|
518
725
|
declare function dom(tag: string | ((attr: attr, ...ctx: ctx[]) => Dom), attr?: attr | null, ...ctx: ctx[]): Dom;
|
|
519
726
|
declare const frag: (attr: attr, ...dom: Dom[]) => Dom[];
|
|
520
727
|
|
|
521
|
-
type kf = KeyframeAnimationOptions;
|
|
522
|
-
type KFType = (CSSinT | obj<V>)[] | CSSinT | obj<V>;
|
|
523
|
-
declare class anim {
|
|
524
|
-
private e;
|
|
525
|
-
opt: kf;
|
|
526
|
-
constructor(e: Elem);
|
|
527
|
-
animate(keyframes: CSSinT[] | CSSinT, options?: kf): Elem<HTMLElement>;
|
|
528
|
-
get slide(): {
|
|
529
|
-
left: (options?: kf) => anim;
|
|
530
|
-
right: (options?: kf) => anim;
|
|
531
|
-
up: (options?: kf) => anim;
|
|
532
|
-
down: (options?: kf) => anim;
|
|
533
|
-
};
|
|
534
|
-
fade(options?: kf): this;
|
|
535
|
-
shake(XorY?: string, opt?: kf): this;
|
|
536
|
-
color(c?: string[], opt?: kf): this;
|
|
537
|
-
bg(c?: string | string[], opt?: kf): this;
|
|
538
|
-
bounce(sVal?: number, opt?: kf): this;
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
declare class Eget<T extends TElem = HTMLElement> {
|
|
542
|
-
e: T;
|
|
543
|
-
query?: string | undefined;
|
|
544
|
-
constructor(e: T, query?: string | undefined);
|
|
545
|
-
get a(): anim;
|
|
546
|
-
get all(): T[];
|
|
547
|
-
get attr(): {
|
|
548
|
-
has: (attr: string) => boolean;
|
|
549
|
-
get: (attr: string) => string | null;
|
|
550
|
-
del: (attr: string) => Eget;
|
|
551
|
-
set: (attrs: obj<any>) => Eget;
|
|
552
|
-
};
|
|
553
|
-
get children(): Elem<T>[];
|
|
554
|
-
get click(): this;
|
|
555
|
-
get delete(): this;
|
|
556
|
-
get disabled(): boolean;
|
|
557
|
-
get focus(): this;
|
|
558
|
-
get href(): string;
|
|
559
|
-
get id(): string;
|
|
560
|
-
get inner(): string;
|
|
561
|
-
get offsetParent(): Elem | undefined;
|
|
562
|
-
get parent(): Elem | undefined;
|
|
563
|
-
get path(): string;
|
|
564
|
-
get rect(): DOMRect;
|
|
565
|
-
get remove_element(): this;
|
|
566
|
-
get style(): {
|
|
567
|
-
set: (style: CSSinT | obj<V | null>, delayOrFN?: number | ((e?: any) => void)) => Elem<HTMLElement>;
|
|
568
|
-
get: (prop: keyof CSSStyleDeclaration | string) => string;
|
|
569
|
-
del: (...props: (keyof CSSStyleDeclaration | string)[]) => void;
|
|
570
|
-
};
|
|
571
|
-
get submit(): any;
|
|
572
|
-
get tag(): string;
|
|
573
|
-
get value(): any;
|
|
574
|
-
get unload(): () => void;
|
|
575
|
-
set append(val: any);
|
|
576
|
-
set appendfirst(val: any);
|
|
577
|
-
set inner(val: any);
|
|
578
|
-
set disabled(vl: boolean);
|
|
579
|
-
set id(did: string);
|
|
580
|
-
set value(vl: any);
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
type TElem = HTMLElement & InstanceType<typeof Element>;
|
|
584
|
-
type fn<E, T> = (e?: E) => T;
|
|
585
|
-
declare class Elem<T extends TElem = HTMLElement> extends Eget {
|
|
586
|
-
constructor(e: T, query?: string);
|
|
587
|
-
add(...className: string[]): this;
|
|
588
|
-
remove(...className: string[]): this;
|
|
589
|
-
toggle(className: string | fn<any, string>, force?: boolean): this;
|
|
590
|
-
has(e: any | null): boolean;
|
|
591
|
-
insert(position: InsertPosition): {
|
|
592
|
-
HTML: (...text: string[]) => Elem;
|
|
593
|
-
element: (...elem: HTMLElement[]) => Elem;
|
|
594
|
-
text: (this: Elem, ...text: string[]) => Elem;
|
|
595
|
-
};
|
|
596
|
-
is(tp: {
|
|
597
|
-
dom?: string;
|
|
598
|
-
class?: string | string[];
|
|
599
|
-
}): boolean;
|
|
600
|
-
on(event: keyof events, handler: (e?: any) => void, useCapture?: boolean): this;
|
|
601
|
-
remove_on(event: keyof DocumentEventMap, handler: EventListenerOrEventListenerObject, useCapture?: boolean): this;
|
|
602
|
-
timed(fn: (ee?: Elem) => void, timeout?: number): this;
|
|
603
|
-
animate(keyframes: KFType, options?: kf, onComplete?: fn<any, void>): this;
|
|
604
|
-
animate(keyframes: KFType, onComplete?: fn<any, void>): this;
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
declare function $<T extends TElem = HTMLElement>(query: string): Elem<T> | undefined;
|
|
608
|
-
declare function $<T extends TElem = HTMLElement>(element: T): Elem<T>;
|
|
609
|
-
type _$ = Elem | undefined;
|
|
610
|
-
|
|
611
|
-
declare class ColorScheme {
|
|
612
|
-
state: Stateful<boolean>;
|
|
613
|
-
body?: HTMLElement;
|
|
614
|
-
click: () => void;
|
|
615
|
-
constructor({ toggle, initialState, }?: {
|
|
616
|
-
toggle?: string[];
|
|
617
|
-
initialState?: boolean;
|
|
618
|
-
});
|
|
619
|
-
private loader;
|
|
620
|
-
get isMatchMediaSupported(): boolean;
|
|
621
|
-
get isDark(): boolean;
|
|
622
|
-
toggle(clist: DOMTokenList, isDark: boolean, toggles: string[]): void;
|
|
623
|
-
}
|
|
624
|
-
|
|
625
728
|
declare global {
|
|
626
|
-
type events = {
|
|
627
|
-
[P in keyof GlobalEventHandlersEventMap]?: (this:
|
|
628
|
-
} & c_events
|
|
729
|
+
type events<T extends Elements = HTMLElement> = {
|
|
730
|
+
[P in keyof GlobalEventHandlersEventMap]?: (this: T, e: GlobalEventHandlersEventMap[P]) => void;
|
|
731
|
+
} & c_events<T>;
|
|
629
732
|
type attr = baseAttr | obj<X3>;
|
|
630
733
|
type ctx = V | Dom | Stateful<V | Dom> | ctx[];
|
|
631
734
|
type obj<T> = Record<string, T>;
|
|
632
|
-
type
|
|
735
|
+
type dom = Dom;
|
|
736
|
+
type DomFN<T = {}> = (a: attr & T, ...D: ctx[]) => Dom;
|
|
737
|
+
const BASE_STRING: string;
|
|
633
738
|
namespace JSX {
|
|
634
739
|
type Element = Dom;
|
|
635
740
|
interface IntrinsicElements {
|
|
741
|
+
link: attr;
|
|
742
|
+
base: attr;
|
|
743
|
+
meta: attr;
|
|
636
744
|
p: attr;
|
|
637
745
|
br: attr;
|
|
638
746
|
hr: attr;
|
|
@@ -800,5 +908,17 @@ declare global {
|
|
|
800
908
|
}
|
|
801
909
|
}
|
|
802
910
|
declare const resolvePath: (base: string, relative: string) => string;
|
|
911
|
+
interface renderConfig {
|
|
912
|
+
path: string;
|
|
913
|
+
status: number;
|
|
914
|
+
base: string;
|
|
915
|
+
}
|
|
916
|
+
interface serverRender {
|
|
917
|
+
path: string;
|
|
918
|
+
data?: Record<string, any>;
|
|
919
|
+
status?: number;
|
|
920
|
+
}
|
|
921
|
+
declare const IfClient: <T>(fn: () => T) => T | undefined;
|
|
803
922
|
|
|
804
|
-
export { $,
|
|
923
|
+
export { $, Dom, IfClient, Meta, Pager, QState, Ref, Render, Routes, State, StateHook, Stateful, Time, Yvee, __, addCSS, cssLoader, doc, dom, eventStream, frag, local, log, pushHistory, resolvePath, session, useRef, websocket };
|
|
924
|
+
export type { $E, Elements, _$, headAttr, renderConfig, serverRender };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var dr=Object.defineProperty;var pr=(t,r)=>{for(var n in r)dr(t,n,{get:r[n],enumerable:!0,configurable:!0,set:(i)=>r[n]=()=>i})};var Xt=function(t,r,n,i){var o=arguments.length,e=o<3?r:i===null?i=Object.getOwnPropertyDescriptor(r,n):i,s;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")e=Reflect.decorate(t,r,n,i);else for(var u=t.length-1;u>=0;u--)if(s=t[u])e=(o<3?s(e):o>3?s(r,n,e):s(r,n))||e;return o>3&&e&&Object.defineProperty(r,n,e),e};var Jt=(t,r)=>{if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(t,r)};var pt={};pr(pt,{isWindow:()=>N,isUndefined:()=>ct,isStr:()=>K,isPlainObject:()=>G,isObj:()=>E,isNumber:()=>q,isNum:()=>gt,isNull:()=>X,isNotWindow:()=>y,isInt:()=>dt,isFN:()=>b,isDict:()=>it,isClassOrId:()=>br,isBool:()=>z,isAsync:()=>Tr,isArraybuff:()=>yr,isArr:()=>h});var b=(t)=>typeof t==="function",Tr=(t)=>t.constructor.name==="AsyncFunction",q=(t)=>{return!isNaN(parseFloat(t))&&isFinite(t)},it=(t)=>{return typeof t==="object"&&t!==null&&!Array.isArray(t)},G=(t)=>{return typeof t==="object"&&t!==null&&Object.getPrototypeOf(t)===Object.prototype},yr=(t)=>{return t instanceof Uint8Array||t instanceof ArrayBuffer||typeof t==="string"},br=(t)=>{return t.startsWith(".")||t.startsWith("#")},z=(t)=>typeof t==="boolean",K=(t)=>typeof t==="string",h=(t)=>Array.isArray(t),E=(t)=>typeof t==="object",gt=(t)=>typeof t==="number",X=(t)=>t===null,ct=(t)=>typeof t==="undefined",dt=(t)=>{return Number.isInteger(Number(t))},N=typeof window!=="undefined",y=typeof window==="undefined";function ot(t,r){a(r).forEach(([n,i])=>{Ut(t,n,{value:i,writable:!1,configurable:!1,enumerable:!0})})}class H{static set p(t){if(Array.isArray(t))console.log(...t);else console.log(t)}}class d{_c=0;_id="";constructor(t){if(this._c=0,this._id=t??p(5),t?.includes("-")){let[r,n]=[t.split("-").slice(0,-1).join("-"),t.split("-").slice(-1)[0]];this._id=r,this._c=q(n)?parseInt(n):0}}get id(){return this._id+"-"+this._c}get mid(){return this._id+"-"+ ++this._c}}var sn=new RegExp(/(\d+)(\d*)/,"m"),xr=(t)=>Array.from({length:t},(r,n)=>n),Er="ABCDEFGHIJKLMNOPQRSTUVWXYZ",$r="abcdefghijklmnopqrstuvwxyz",wr=xr(10).join("");var $=(t)=>JSON.stringify(t),Yt=(t)=>{return JSON.parse(t)},S=(t)=>{if(t.startsWith("webkit"))t="-"+t;return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()},p=(t)=>{let r=Er+$r;return Array.from({length:t},(n,i)=>r+(i?wr:"")).reduce((n,i)=>{return n+=i.charAt(Math.floor(Math.random()*i.length))},"")};class f extends Map{obj(t){t&&a(t).forEach(([r,n])=>this.set(r,n))}map(t){t.forEach((r,n)=>{if(r instanceof f)this.set(n,r);else if(h(r)){if(this.lacks(n))this.set(n,[]);this.get(n).push(...r)}else if(E(r))this.ass(n,r);else this.set(n,r)})}ass(t,r){if(!this.has(t))this.set(t,{});T(this.get(t),r)}lacks(t){return!this.has(t)}init(t,r){return this.has(t)?this.get(t):this.set(t,r).get(t)}}var{values:x,keys:J,entries:a}=Object;var{hasOwn:Wt,freeze:Bt,defineProperty:Ut,assign:T}=Object,w=(t)=>{return Object.keys(t).length},et=(t,r)=>{if(!r.has(t))r.set(t,new f);return r.get(t)},V=(t,r)=>{if(!r.has(t))r.set(t,[]);return r.get(t)},Tt=(t,r)=>{let n={added:{},removed:{},modified:{}},i=J(t),o=J(r);for(let e of o){let s=t[e],u=r[e];if(!(e in t))n.added[e]=u;else if(h(s)&&h(u)){if($(s)!==$(u))n.modified[e]={old:s,new:u}}else if(E(s)&&E(u)&&!X(s)&&!X(u)){let m=Tt(s,u);if(w(m.added)||w(m.removed)||w(m.modified))n.modified[e]={old:s,new:u}}else if(s!==u)n.modified[e]={old:s,new:u}}for(let e of i)if(!(e in r))n.removed[e]=t[e];return n};function Pt(t,r){if(t.size!==r.size)return!1;for(let n of t)if(!r.has(n))return!1;return!0}var Ct=(t)=>{return x(t).some((r)=>{return w(r)})};function Gt(t){let r;return class extends t{constructor(...n){if(r)return r;super(...n);Bt(this),r=this}}}var Q=(t,r)=>{return{name:t,content:r}},Hr=(t,r)=>{return{property:t,content:r}},jr=(t,r)=>{return{"http-equiv":t,content:r}};class st{metas=[];constructor(t){t&&this.metas.push(Q("description",t))}author(t){return this.meta=Q("author",t),this}charset(t){return this.meta={charset:t},this}keywords(...t){return this.meta=Q("keywords",t.join(", ")),this}viewport(t){let r=a(t).map(([n,i])=>[S(n),String(i)].join("="));return this.meta=Q("viewport",r.join(", ")),this}httpEquiv(t){return a(t).forEach(([r,n])=>{this.meta=jr(S(r),String(n))}),this}robots(...t){return this.meta=Q("robots",t.join(", ")),this}themeColor(t){return this.meta=Q("theme-color",t),this}openGraph(t){return a(t).forEach(([r,n])=>{this.meta=Hr("og:"+r,String(n))}),this}twitter(t){return a(t).forEach(([r,n])=>{this.meta=Q("twitter:"+r,String(n))}),this}and(t){return this}set meta(t){this.metas.push(t)}}class yt{title;description;base;meta;link;script;css}var Ar=["charset","name","property","http-equiv"],zt=(t,r)=>{r.forEach((n)=>{for(let i of Ar)if(i in n){let o=n[i];t[`${i}_${i==="charset"?"":o}`]=n}})},Dr=(t,r)=>{r.forEach((n)=>{if("href"in n){let i=n.href;t[`${i}`]=n}})};class U{_head;idm;constructor(t){this._head=new f(t)}set head(t){a(t).forEach(([r,n])=>{if(r==="title"||r==="base"){if(n!==void 0)this._head.set(r,n);return}if(n instanceof st)return zt(this._head.init("meta",{}),n.metas);if(!h(n))return;switch(r){case"meta":return zt(this._head.init("meta",{}),n);case"link":return Dr(this._head.init("link",{}),n);case"script":if(n.length){this._head.init(r,[]);let i=n.map((o)=>{if(!o.yid&&this.idm)o.yid="sc"+this.idm.mid;return o});this._head.get(r).push(...i)}return}})}get head(){return this._head}set id(t){this.idm=new d(t)}}var Kt=(t)=>{return a(t).reduce((r,[n,i])=>{return r.push(z(i)&&i?n:`${n}="${i}"`),r},[""]).join(" ")},Nt=(t)=>{if(!t)return"";return[...t].reduce((r,[n,i])=>{if(n==="meta"||n==="link")i=x(i);if(K(i))return r.push(`<${n}>${i}</${n}>`),r;if(!h(i))return r;let o=i.map((e)=>{if(n==="script"){let s={...e};if("yid"in s)return"";let u="";if("importmap"in s)s.type="importmap",u=JSON.stringify(s.importmap),delete s.importmap;else if("body"in s)u=s.body,delete s.body;return`<${n}${Kt(s)}>${u}</${n}>`}return`<${n}${Kt(e)}>`});return r.push(...o),r},[]).join("")};class bt{lang="en";htmlHead=new f;head;constructor(){this.head=(t={})=>{let r=new U(this.htmlHead);r.head=t,this.htmlHead=r.head}}}var xt=(t)=>{if(y)return;return new Promise((r,n)=>{let i=document.createElement("link");if(t.rel!=="stylesheet")t.rel="stylesheet",t.as="style";a(t).forEach(([o,e])=>{i.setAttribute(o,e)}),i.onload=()=>r(i),i.onerror=()=>n(new Error("Failed to load CSS")),document.head.appendChild(i)})},Vt=(t)=>{return new Promise((r,n)=>{let i=document.createElement("script"),o="";if("importmap"in t)t.type="importmap",o=JSON.stringify(t.importmap),delete t.importmap;else if("body"in t)o=t.body,delete t.body;if(o)i.innerHTML=o;a(t).forEach(([e,s])=>{i.setAttribute(e,s)}),i.onload=()=>r(i),i.onerror=()=>n(new Error("Failed to load Script")),document.head.appendChild(i)})},Rr=()=>{let r=document.querySelector("#d-css")?.sheet;if(r)return r;let n=document.createElement("style");return n.id="d-css",document.head.appendChild(n),n.sheet},qr=(t,r)=>{for(let n=0;n<t.cssRules.length;n++)if(t.cssRules[n].selectorText===r)return!0;return!1},Lr=(t)=>Object.entries(t).map(([r,n])=>`${S(r)}: ${n};`).join(" ");function Mr(t,r={}){if(y)return;let n=Rr();if(!n)return;if(!qr(n,t))n.insertRule(`${t} { ${Lr(r)} }`,n.cssRules.length)}var Ot=(t,r=!1)=>{if(q(t))return[+t,dt(t)?"int":"float"];if(r&&/\.\w+$/.test(t))return[t,"file"];if(t==="/")return[t,"-"];if(t.length===36&&t.match(/\-/g)?.length===4)return[t,"uuid"];return[t,"string"]},ut=(t)=>{let r=t.startsWith("/")?t:"/"+t,n=r.match(/(?<=\/)[^/].*?(?=\/|$)/g)??["/"],[i,o]=n.reduce(([e,s],u)=>{if(u.includes("<")){let m=u.match(/(?<=<)[^/].*?(?=>|$)/g);if(m?.length){let[l,c]=m[0].split(":");if(l&&c)e.push(l),s.push(c)}}else e.push(u===">"?"/":u);return[e,s]},[[],[]]);if(r.endsWith("/")&&r.length>1)i.push("/");return{parsed:i,args:o}};class ft{storage=new f;cache(t,r){if(this.storage.lacks(t))this.storage.set(t,r());return this.storage.get(t)}}var Sr=["int","float","file","uuid","string"],Qr=new ft;class Y{_storage=new f;set(t){let{parsed:r,path:n}=t,i=$(r);if(!this._storage.get(i))this._storage.set(i,t);else throw`path: ${n} already used.`}get(t){let{parsed:r}=Qr.cache(t,()=>ut(t)),n={},i=this._storage.get($(r));if(!i&&t!=="/")for(let o of this._storage.keys()){let e=[],s=Yt(o);if(r.length===s.length){let u=s.map((c,A)=>{let D=Ot(r[A],r.length-1===A);if(c===D[0])return D[0];if(Sr.includes(D[1]))return e.push(D[0]),D[1];return c}),m=$(u);if(this._storage.has(m)){i=this._storage.get(m),i?.args.forEach((c,A)=>{n[c]=e[A]});break}}}return[i,n]}}class O{path="";parsed=[];args=[];constructor(t){ot(this,{path:t,...ut(t)})}}class _t{static rand(t=6,r){if(r)return Math.floor(Math.random()*(r-t+1)+t);return Math.floor(Math.random()*t)+1-1}static fill(t,r=null){return Array(t).fill(r)}static new({dom:t,id:r,inner:n}){let i=document.createElement(t);if(r)i.id=r;if(n)i.innerHTML=n;return i}static randFrom(t){if(Array.isArray(t)){let r=t.length,n=this.rand(0,r-1);return t[n]}else if(typeof t=="object"){let r=J(t),n=r.length,i=this.rand(0,n-1);return r[i]}}static makeID=p;static class(t,r){let n=r;if(t?.class)n.push(...h(t.class)?t.class:[t.class]);t.class=r}static get O(){return{vals:x,keys:J,items:a,has:Wt,ass:T,len:(t={})=>J(t).length}}static get is(){return pt}static get return(){return kt}}class kt{static array(t){return h(t)?t:[t]}}var Et={},F={};class vt{stream;url;constructor(t,r){if(this.url=t,t in Et)this.stream=Et[t];else this.stream=new EventSource(t,{withCredentials:r}),Et[t]=this.stream,F[this.url]={}}on(t){let r=this.stream;return a(t).forEach(([n,i])=>{if(n in F[this.url])F[this.url][n].forEach((o)=>{this.stream.removeEventListener(n,o)}),F[this.url][n]=[];if(r.addEventListener(n,i),!(n in F[this.url]))F[this.url][n]=[];F[this.url][n].push(i)}),this}}function tr(t,r=!0){return new vt(t,r)}class rr{value;constructor(t){this.value=t}get str(){return String(this.value).toString()=="null"?null:String(this.value).toString()}get int(){if(q(this.value))return parseInt(this.value);else return null}get float(){if(q(this.value))return parseFloat(this.value);else return null}get bool(){if(this.value==="true")return!0;else if(this.value=="false")return!1;else return null}get json(){if(this.value)return JSON.parse(this.value);return null}}class _{key;func;storage;constructor(t,r="local"){if(typeof t=="object"){let[n,i]=a(t)[0];this.key=n,this.func=i}else this.key=t,this.func=null;this.storage=r=="local"?localStorage:sessionStorage}get as(){return new rr(this.storage.getItem(this.key))}get value(){return this.storage.getItem(this.key)}get save(){if(this.func)this.set=this.func();return}set set(t){if(typeof t=="object")this.storage.setItem(this.key,JSON.stringify(t));else this.storage.setItem(this.key,String(t))}get remove(){this.storage.removeItem(this.key);return}}var k={get:(t)=>new _(t)};var nr={get:(t)=>new _(t,"session")};class mt extends O{id;cls;constructor(t,r,n){super(t);this.id=r;this.cls=n}}class ir extends O{id;cls;constructor(t,r,n){super(t);this.id=r;this.cls=n}}class $t extends bt{ImportMeta;config;storage=new Y;errorStorage=new Y;wssStorage=new Y;route;error;wss;constructor(t,r){super();this.ImportMeta=t;this.config=r;this.route=(n)=>{return(i)=>{return this.storage.set(new mt(n,p(5),i)),i}},this.wss=(n)=>{return(i)=>{return this.wssStorage.set(new ir(n,p(5),i)),i}},this.error=(...n)=>{return(i)=>{if(n.length)n.forEach((o)=>{this.errorStorage.set(new mt(o.toString(),p(5),i))});else this.errorStorage.set(new mt("404",p(5),i));return i}}}async getPath(t){return this.storage.get(t)}async loadError(t){return this.errorStorage.get(t.toString())}async loadWSS(t){return this.wssStorage.get(t)}}var v=new f,tt=(t)=>{if(y)return;let r=v.get(t);if(r?.isConnected)return r;v.delete(t);let n=document.getElementById(t);if(!n)return;return v.set(t,n),n};function or(){let t=[];return v.forEach((r,n)=>{if(!r.isConnected)t.push(n),v.delete(n)}),t}function W(t,r,{id:n="state",init:i}={}){let o=[],e=()=>r.map((u)=>u.value),s=()=>{t(...e())};if(r.forEach((u)=>{o.push(u.hook(s)(n))}),i)s();return()=>{o.forEach((u)=>u())}}var er=(t)=>{t.forEach((r)=>r())};var Fr=(t,r)=>{for(let[n,i]of t){let o=tt(n);if(!o){t.delete(n);continue}i.forEach((e)=>{e.call(o,r)})}};class Z extends EventTarget{options;hooks=new f;states=new f;_value;listening=!1;end;constructor(t,r){super();this.options=r;this._value=t}get value(){return this._value}set value(t){if(X(t)||ct(t))return;if(G(this._value)||h(this._value)){let r=Tt(this._value,t);if(!Ct(r))return}else if(this._value instanceof Set){if(!Pt(this._value,t))return}else if(this._value===t)return;this._value=t,this.dispatchEvent(new CustomEvent("updated",{detail:this._value}))}get listen(){let t=(r)=>{if(er(this.hooks),Fr(this.states,r.detail),!this.states.size&&!this.hooks.size)this.end?.()};if(!this.listening)this.addEventListener("updated",t,this.options),this.listening=!0;return()=>{this.listening&&this.removeEventListener("updated",t,this.options),this.end=void 0,this.listening=!1}}call(t,r){return(n)=>{if(et(n,this.states).set(r,t),!y&&!this.listening)this.end=this.listen;return()=>{if(this.states.has(n))this.states.get(n)?.delete(r)}}}hook(t){return(r)=>{if(this.hooks.set(r,t),!y&&!this.listening)this.end=this.listen;return()=>{if(this.hooks.has(r))this.hooks.delete(r)}}}}function j(t){return new Z(t)}var B=(t)=>{if(h(t))return t.join(" ");else if(E(t)){if(it(t))return $(t)}else if(b(t))return B(t());else if(t!==void 0&&t!==null)return z(t)?t?"":"false":String(t);return""};function Zr(t,r){switch(r??t){case"style":return function(n){this.style.setProperty(t,n)};default:return function(n){this.setAttribute(t,n)}}}class wt{attr;constructor(t={}){this.attr=t}get(t,r=this.attr,n){let i=(o,e)=>{if(h(e))t.attr_push(o,B(e));else if(e instanceof Z){let s=n?`${n}_${o}`:o;t.states.push(e.call(Zr(o,n),s)),i(o,e.value)}else if(E(e)){if(it(e)&&!n)this.get(t,e,o)}else t.attr_push(o,B(e),n)};a(r).forEach(([o,e])=>{if(["on"].includes(o))E(r.on)&&t.events.obj(r.on);else i(o,e)})}}class P{xid;IDM;map=new f;states=[];events=new f;OZ;constructor(t,r=new d,n){this.xid=t;this.IDM=r;this.OZ=n??new ht}attr_push(t,r,n){let i=n??t;if(!this.map.has(i))this.map.set(i,[]);let o=n?`${S(t)}:${r};`:r;this.map.get(i).push(o)}get attr(){let t=[""];return this.map.forEach((r,n)=>{let i=r.join("");t.push(i?`${n}="${i}"`:n)}),t.join(" ")}set id(t){if(!this.map.has("id"))this.map.set("id",[t])}get id(){return this.map.get("id")?.join("")}}var Ir=(t,r,n)=>{return t.addEventListener(r,n),()=>{t.removeEventListener(r,n)}},rt={};class ht{events=new f;states=new f;winStates=new f;windowEvents=new f;resetST=new f;resetEV=new f;constructor(){}get keys(){return[...new Set([...this.states.keys(),...this.events.keys()])]}set(t){let{id:r,events:n,states:i}=t;if(r){if(n.size)this.events.set(r,n);if(i.length)this.states.set(r,i)}return this}push(t){return t.events.forEach((r,n)=>{r.forEach((i,o)=>{et(n,this.events).set(o,i)})}),t.states.forEach((r,n)=>{V(n,this.states).push(...r)}),this}get stage(){return this.events.forEach((t,r)=>{this.events.delete(r);let n=tt(r);if(!n){this.events.delete(r);return}t.forEach((i,o)=>{switch(o){case"ready":i.apply(n,[n]);break;case"resize":case"beforeunload":case"popstate":case"winscroll":case"winload":case"winfocus":case"winblur":let e=o.replace(/^win/,"");this.windowEvents.init(e,new f).set(r,i);break;case"watch":let[s,u,m]=i.apply(n,[n]),l=h(u)?u:[u],c=()=>l.map((D)=>D.value),A=()=>s(...c());if(m)A();l.forEach((D)=>V(r,this.resetST).push(D.call(A,r+"_watch")(r)));break;default:V(r,this.resetEV).push(Ir(n,o,i))}})}),this.processWindowEvents,this.states.forEach((t,r)=>{this.states.delete(r),t.forEach((n)=>{V(r,this.resetST).push(n(r))})}),this}get processWindowEvents(){let t=(r,n)=>{let i=(o)=>{n.forEach((e,s)=>{let u=tt(s);if(u)e.call(u,o);else this.windowEvents.get(r)?.delete(s)})};return window.addEventListener(r,i),()=>{window.removeEventListener(r,i)}};return this.windowEvents.forEach((r,n)=>{if(r.size){if(!rt[n])rt[n]=t(n,r)}else if(rt[n])rt[n](),delete rt[n]}),this}reset(t){return t.forEach((r)=>{this.windowEvents.forEach((n,i)=>{if(n.has(r))n.delete(r)}),this.resetEV.get(r)?.forEach((n)=>{n()}),this.resetST.get(r)?.forEach((n)=>{n()}),this.resetST.delete(r),this.resetEV.delete(r)}),this}RPS(t){if(t){let r=or();this.reset(r);let n=t.keys;if(n.length)this.reset(n).push(t).stage}return this}}var R=new ht;var Xr=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],Jr=(t)=>Xr.includes(t);function Ur(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var at=(t,r)=>{if(h(t))return t.map((n)=>at(n,r)).join("");else if(t instanceof L){let n=t.__(r.IDM),{ctx:i,oz:o}=n;return r.OZ.push(o),i}else if(E(t))return $(t);else if(b(t))return at(t(),r);else if(t!==void 0&&t!==null)return Ur(t);return""},sr=(t,r)=>{let n=new d(t),i=new P(n.id,n);return{ctx:at(r,i),catt:i}};function Yr(t){let r=this.id;if(r){let{ctx:n,catt:i}=sr(r,t);if(this.innerHTML!==n)this.innerHTML=n,R.RPS(i.OZ)}}var Ht=(t,r,n,i=[])=>{if(h(t))t.forEach((o)=>{Ht(o,t.length,n,i)});else if(t instanceof Z)if(r>1)Ht(M("div",{},t),r,n,i);else{let o=t.value,e=o instanceof L?"dom":"ctx",{ctx:s,catt:u}=sr(n.xid+"-0",o);n.xid=u.xid,i.push(s),n.OZ.push(u.OZ),n.states.push(t.call(Yr,e))}else i.push(at(t,n))};class jt{tag;ctx;closing;constructor(t,r){this.tag=t;this.ctx=r;let n=Jr(t);this.closing=n?"":`</${t}>`}process(t,r=this.ctx,n=[]){return r.forEach((i)=>{Ht(i,r.length,t,n)}),n.join("")}get(t){let r=this.process(t);if(t.events.size||t.states.length)t.id=t.xid;return`<${this.tag}${t.attr}>${r}${this.closing}`}}class L{tag;constructor(t,r={},...n){this.tag=t;ot(this,{attr:new wt(r),ctx:new jt(t,n)})}__(t=new d){let r=t.mid,n=new P(r,t);return this.attr.get(n),{ctx:this.ctx.get(n),oz:n.OZ.set(n),id:n.id}}}function M(t,r={},...n){if(b(t))return t(r??{},...n);return new L(t,r??{},n)}var Wr=(t,...r)=>r;class At{e;opt;constructor(t){this.e=t;this.opt={duration:500,easing:"ease-in-out",fill:"forwards"}}animate(t,r={}){return this.e.animate(t,r)}get slide(){let t=({x:r=0,y:n=0},i={})=>{T(this.opt,i);let o=[[r,n],[0,0]].map(([e,s])=>({transform:`translateX(${e}rem) translateY(${s}rem)`}));return this.e.animate(o,this.opt),this};return{left:(r={})=>{return t({x:-2},r)},right:(r={})=>{return t({x:2},r)},up:(r={})=>{return t({y:2},r)},down:(r={})=>{return t({y:-2},r)}}}fade(t={}){T(this.opt,t);let r=[0,1].map((n)=>({opacity:n}));return this.e.animate(r,this.opt),this}shake(t="Y",r={}){T(this.opt,r);let n=[0,5,-5,5,0].map((i)=>({transform:`translate${t}(${i}px)`}));return this.e.animate(n,this.opt),this}color(t=[],r={}){T(this.opt,r);let n=Array.isArray(t)?t.map((i)=>({color:i})):{color:t};return this.e.animate(n,this.opt),this}bg(t=[],r={}){T(this.opt,r);let n=Array.isArray(t)?t.map((i)=>({backgroundColor:i})):{backgroundColor:t};return this.e.animate(n,this.opt),this}bounce(t=1,r={}){T(this.opt,r);let n=[0.5,t,1].map((i)=>({transform:`scale(${i})`}));return this.e.animate(n),this}}class qt{e;query;constructor(t,r){this.e=t;this.query=r}get a(){return new At(this)}get all(){if(this.query){let t=document.querySelectorAll(this.query);if(t.length)return Array.from(t).map((r)=>r)}return[]}get attr(){let t=this.e;return{has:(r)=>{return t.hasAttribute(r)},get:(r)=>{return t.getAttribute(r)},del:(r)=>{return t.removeAttribute(r),this},set:(r)=>{for(let n in r){let i=r[n];if(r[n]!==void 0)t.setAttribute(n,B(i))}return this}}}get children(){return Array.from(this.e.children).map((t)=>g(t))}get click(){return this.e.click(),this}get delete(){return this.e.remove(),this}get disabled(){return this.e.disabled??!1}get focus(){return this.e.focus(),this}get href(){return this.e?.href??""}get id(){return this.e.id}get inner(){return this.e.innerHTML}get offsetParent(){let t=this.e.offsetParent;if(t)return new I(t);return}get parent(){let t=this.e.parentElement;if(t)return new I(t);return}get path(){return this.e?.pathname??""}get rect(){return this.e.getBoundingClientRect()}get remove_element(){return this.e.remove(),this}get style(){let t=this.e.style,r=this;return{set:(n,i=0)=>{let o=t,e=()=>{a(n).forEach(([s,u])=>{if(s in o){if(o[s]!==u)o[s]=u}else if(u!==null)t.setProperty(s,String(u))})};if(b(i))r.on("transitionend",i);if(gt(i))setTimeout(e,i);else e();return r},get:(n)=>{return t.getPropertyValue(n.toString())},del:(...n)=>{n.forEach((i)=>{t.removeProperty(i.toString())})}}}get submit(){let t=this.e;if("submit"in t)return t.submit();return!1}get tag(){return this.e.tagName.toLowerCase()}get value(){return this.e.value??""}get unload(){return()=>{this.e.remove()}}set append(t){let{ctx:r,oz:n}=Dt(t,Rt(this.id));this.e.insertAdjacentHTML("beforeend",r),R.RPS(n)}set appendfirst(t){let{ctx:r,oz:n}=Dt(t,Rt(this.id));this.e.insertAdjacentHTML("afterbegin",r),R.RPS(n)}set inner(t){let{ctx:r,oz:n}=Dt(t,Rt(this.id));this.e.innerHTML=r,R.RPS(n)}set disabled(t){let r=this.e;if("disabled"in r)r.disabled=t}set id(t){this.e.id=t}set value(t){let r=this.e;r.value=t}}var Dt=(t,r)=>{if(t instanceof L)return t.__(new d(r));return{ctx:t,oz:void 0}},Rt=(t)=>t?`${t}-0`:t;class I extends qt{constructor(t,r){super(t,r)}add(...t){return this.e.classList.add(...t.map((r)=>r.replace(/[^\w-]/,""))),this}remove(...t){return this.e.classList.remove(...t.map((r)=>r.replace(/[^\w-]/,""))),this}toggle(t,r){let n=typeof t!="string"?t.apply(this):t,i=this.e.classList;return n.split(" ").forEach((o)=>{i.toggle(o,r)}),this}has(t){return this.e.contains(t)}insert(t){return{HTML:(...r)=>{return r.forEach((n)=>{this.e.insertAdjacentHTML(t,n)}),this},element:(...r)=>{return r.forEach((n)=>{this.e.insertAdjacentElement(t,n)}),this},text:function(...r){return r.forEach((n)=>{this.e.insertAdjacentText(t,n)}),this}}}is(t){let r=this.e.classList.value.split(" "),n=this.e.tagName.toLocaleLowerCase(),i=!0,o=!0;if(t.dom)o=t.dom==n?!0:!1;if(t.class)if(Array.isArray(t.class))t.class.forEach((e)=>{i=i?r.includes(e):!1});else i=i?r.includes(t.class):!1;return i&&o}on(t,r,n=!1){let i=!1;if(t.indexOf("touch")>-1)i=!0;return this.e.addEventListener(t,r,{capture:n,passive:i}),this}remove_on(t,r,n=!1){return this.e.removeEventListener(t,r,n),this}timed(t,r=250){return setTimeout(()=>t(this),r),this}animate(t,r,n){let i={duration:300,easing:"ease",fill:"forwards"};if(b(r))n=r;else T(i,r);let o=this.e.animate(t,i);if(n)o.finished.then(n);return this}}function g(t){if(K(t)){let r=document.querySelector(t);if(r)return new I(r,t);return}else return new I(t)}class lt extends yt{path;args;id;status;lang;import;_data={};constructor(t,r={},n,i=200){super();this.path=t;this.args=r;this.id=n;this.status=i}async loader(){if(this.import)try{let t=await this.import;if(t.default)this.import=await t.default({...this.args,...this.data});else this.import=void 0}catch(t){H.p=t,this.import=void 0}if(this.body){let t=await this.body();return h(t)?t:[t]}if(this.import){let t=this.import;return h(t)?t:[t]}return[]}getHeadAttr(t={},...r){let n=new U;if(w(t))n.head=t;n.id=this.id;let i=n.head;return r.forEach((o)=>{i.map(o)}),Br(n,this),i}set data(t){T(this._data,t)}get data(){return this._data}}class Lt extends lt{head(){this.title=`error ${this.status}`}body(){return M("div",{},this.path+" not found...")}}function Br(t,r){let{link:n,script:i,meta:o,title:e,base:s,description:u,css:m}=r;if(t.head={title:e,base:s,meta:o,link:n,script:i},u)t.head={meta:[{name:"description",content:u}]};if(m){let c=(h(m)?m:[m]).map((A)=>({rel:`${y?"preload ":""}stylesheet`,href:A,as:"style"}));if(t.head.lacks("link"));t.head={link:[...c]}}}function ur(t){let r=[];if(t?.length){let{href:n,target:i}=t[0],o=g("base");if(o)o.attr.set({href:n,target:i});else{let e=g(document.createElement("base"));e.attr.set({href:n,target:i}),document.head.append(e.e)}}else{let n=g("base")?.unload;n&&r.push(n)}return r}var fr=new f;async function mr(t,r={},n=!1){let i=nt.value,o={};if(g("link")?.all.forEach((e)=>{let s=g(e),u=s.attr.get("href");if(u){let m=s.attr.get("rt");if(n){let l=fr.get(i);if(l){if(!l.has(u))o[u]=s.unload}else o[u]=s.unload}else if(m){if(m===t)o[u]=s.unload}}}),r&&w(r))for(let e of x(r)){let s=e.href;if(!(s in o))try{if(!n){e.rt=t;let u=fr.init(i,new Set);if(!u.has(s))u.add(s)}await xt(e)}catch(u){H.p=u}else delete o[s]}return x(o)}var Pr=["charset","name","property","http-equiv"];function hr(t){let r={};if(g("meta")?.all.forEach((n)=>{let i=n.attributes;for(let o of Pr)if(o in i){let e=i[o].value;r[`${o}_${o==="charset"?"":e}`]=n}}),t)a(t).forEach(([n,i])=>{if(n in r)g(r[n]).attr.set(i),delete r[n];else{let o=g(document.createElement("meta"));o.attr.set(i),document.head.append(o.e)}});return x(r).map((n)=>g(n).unload)}var ar=new f;async function lr(t,r,n=!1){let i=nt.value,o={};if(g("script[yid]")?.all.forEach((e)=>{let s=g(e),u=s.attr.get("yid");if(u){let m=s.attr.get("rt");if(n){let l=ar.get(i);if(l){if(!l.has(u))o[u]=s.unload}else o[u]=s.unload}else if(m){if(m===t)o[u]=s.unload}}}),r){for(let e of r)if("yid"in e)if(e.yid in o)delete o[e.yid];else try{if(!n){e.rt=t;let s=e.yid,u=ar.init(i,new Set);if(!u.has(s))u.add(s)}await Vt(e)}catch(s){H.p=s}}return x(o)}async function gr(t,r,n=!1){let i=[];if(y)return[];let o=t.get("title")??"";if(n){let{pushState:e}=this.config,s=this.path.value;if(e)Mt(s,o);document.documentElement.lang=r,document.title=o}if(n)i.push(...ur(t.get("base"))),i.push(...hr(t.get("meta")));return i.push(...await mr(this.id,t.get("link"),n)),i.push(...await lr(this.id,t.get("script"),n)),i}function Mt(t,r){let n=window.location.pathname;if(t&&n!==t)history.pushState({},r??"",t)}class St{lang;head="";constructor(t,r){if(this.lang=t,r)this.head=Nt(r)}body(t,r,n){return[`<!DOCTYPE html><html lang="${this.lang}">`,`<head>${this.head}</head>`,`<body id="${r??p(5)}"${n?" "+n:""}>${t}</body>`,"</html>"].join("")}}class Qt{path;args;isConnected=j(!1);data={};constructor(t,r={}){this.path=t;this.args=r}open(t){}message(t){}close(t){}error(t){}get connect(){if(this.ws&&this.ws.readyState<=1)return this;return this.ws=new WebSocket(this.path),this.ws.onopen=async(t)=>{this.isConnected.value=!0,await this.open.call(this,t)},this.ws.onmessage=async(t)=>{await this.message.call(this,t)},this.ws.onclose=async(t)=>{this.isConnected.value=!1,await this.close.call(this,t)},this.ws.onerror=async(t)=>{this.isConnected.value=this.ws.readyState<=1,await this.error.call(this,t)},this}get reconnect(){if(this.state>=2)this.connect;return this}get disconnect(){if(this.state<=1)this.ws.close();return this}get state(){return this.ws?.readyState??3}set send(t){this.ws.send(t)}}var C=new f;class Ft{yra;constructor(t){this.yra=t}async load(t){if(!C.has(t)){let[n,i]=await this.yra.loadWSS(t);if(!n)return;let{cls:o,path:e,id:s}=n,u=new o(e,i).connect;return C.set(t,u),u}let r=C.get(t);return r.reconnect,r}unload(t){if(C.has(t)){let r=C.get(t);if(!r)return;r.disconnect,C.delete(t)}}}function Cr(t,r,n,i){let o={...t.on??{},click(e){e.preventDefault(),i.value=n.value,n.value=g(this).path}};return delete t.on,M("a",{...t,on:{...o}},...r)}function Gr(t,r,n){let{classes:i}=t.config,{load:o,on:e,...s}=r,u={...r.on??{},...!n&&o&&{ready(m){t.load(o)}},...n&&{popstate(m){let l=m.target;t.path.value=l.location.pathname}}};return M("div",{...s,...i&&{class:i},on:u},t.root)}class Zt extends $t{isYRA;unload=!1;hook;root=j([]);socket;id=p(4);path=j("");lastPath=j("");A;Main;load;constructor(t,r={},n=!1){super(t,r);this.isYRA=n;this.socket=new Ft(this),this.A=(i,...o)=>{return Cr(i,o,this.path,this.lastPath)},this.Main=(i)=>{return Gr(this,i,n)},this.load=async(i,o={})=>{if(this.hook)this.hook();if(i)this.path.value=i,this.lastPath.value=i,this.lang=i,await this.render(i,404,o),this.hooker();return this}}hooker(){let t={},r=this.path.value;if(this.hook)this.hook();this.hook=W(async(n)=>{if(t[r]=window.scrollY,(await this.render(n,404)).done)window.scrollTo({top:t[n]??0,behavior:"instant"}),r=n},[this.path],{id:"router"})}async class(t,r,n=!1){let[i,o]=await this.getPath(t);if(i&&!n){let{cls:e,path:s,id:u}=i;return new e(s,o,u)}else return zr.call(this,t,r)}async fetch(t){if(t)try{if(t.fetch){let r=await t.fetch();if(G(r)&&w(r))t.data=r}}catch(r){H.p=r}}async processHead(t,r={}){return t?await this.processClassHead(t,r):await this.processDefaultHead(r)}async processClassHead(t,r){if(t.head)await t.head();return t.getHeadAttr(r,this.htmlHead)}async processDefaultHead(t){let r=new U;if(w(t))r.head=t;return r.head.map(this.htmlHead),r.head}async render(t,r=404,n={},i={},o=!0,e=!1){let s=await this.class(t,r??Nr(),e);s.data=n,await this.fetch(s);let u=await this.processHead(s,i);if(!s)return{lang:this.lang,heads:u,done:!1};let m=[];if(this.unload)m=await s.loader();let l=[];if(o)l=await gr.call(this,u,s?.lang||this.lang,this.unload);if(!this.unload)l.forEach((c)=>c()),m=await s.loader();if(this.unload)l.forEach((c)=>c());if(m.length)this.root.value=m;else await this.render(t,r,n,i,o,!0);return{heads:u,lang:s.lang??this.lang,done:!0}}}async function zr(t,r){let[n,i]=await this.loadError(r??0);if(n){let{cls:o,id:e}=n;return new o(t,i,e,r)}else{let o=new Lt(t,i,p(5));return o.title=`error ${r}`,o}}var nt=j("");class cr extends Zt{unload=!0;constructor(t,{classes:r,pushState:n=!0}={}){super(t,{classes:r,pushState:n},!0);this.path=nt,this.head({meta:[{charset:"utf-8"},{name:"viewport",content:"width=device-width, initial-scale=1.0"}]}),this.load=async(i,o={})=>{if(N)i=i||location.pathname;if(this.hook)this.hook();if(i)this.path.value=i;if(N&&i)this.render(i,404,o).then(()=>{if(i&&this.config.pushState)Mt(i,document.title);Kr.call(this,this.Main({})),this.hooker()});return this}}async html({path:t,data:r={},status:n=200,attr:i=""}){let o={script:[{type:"module",src:this.ImportMeta.file}]};Vr(o,n),this.path.value=t;let{lang:e,heads:s}=await this.render(t,n,r,o,!1),{ctx:u}=this.Main({}).__(new d(this.id));return new St(e,s).body(u,this.id,i)}}function Kr(t){let r=document.body.id,{oz:n,id:i}=t.__(new d(r));if(this.id=i||this.id,!n)return;R.push(n),requestAnimationFrame(()=>{R.stage})}function Nr(){if(N)return parseInt(g('meta[name="error-code"]')?.attr.get("content")??"404");return 404}var Vr=(t,r)=>{switch(r){case 404:t.meta=[{name:"error-code",content:r.toString()}];return;default:return}},Or=(t)=>{return(r)=>{t(r)}},_r=(t)=>{return(r)=>{t(r)}};class It{state;body;click;constructor({toggle:t=[],initialState:r=!1}={}){this.state=j(r);let n=this.state;this.click=function(){n.value=!n.value},this.loader(t)}loader(t){if(typeof window==="undefined")return;let r=k.get("LOCAL_SCHEME"),n=this.isDark,i=r.as.bool,o=k.get({IS_DARK:()=>this.state.value});if(i!=null&&i!==n)this.state.value=!i,o.save,r.set=n;if(o.as.bool!==null)this.state.value=o.as.bool;let e=this.toggle,s=document.documentElement.classList;if(e(s,this.state.value,t),W(async(u)=>{e(s,u,t),o.save},[this.state],{id:"colorScheme"}),this.isMatchMediaSupported)window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",(u)=>{let l=(u.matches?"dark":"light")==="dark";this.state.value=l,r.set=l})}get isMatchMediaSupported(){return window.matchMedia&&typeof window.matchMedia==="function"}get isDark(){return window.matchMedia("(prefers-color-scheme: dark)").matches}toggle(t,r,n){if(r)t.add(...n);else t.remove(...n)}}It=Xt([Gt,Jt("design:paramtypes",[Object])],It);var es=(t,r)=>{return`${t.replace(/\/+$/,"")}/${r.replace(/^\.\/+/,"")}`};export{Qt as websocket,W as stateHook,nr as session,es as resolvePath,k as local,Wr as frag,tr as eventStream,M as dom,lt as doc,xt as cssLoader,Mr as addCSS,_t as __,cr as Yvee,Z as Stateful,j as State,Or as Routes,Zt as Router,st as Meta,_r as Errors,L as Dom,It as ColorScheme,H as $$,g as $};
|
|
1
|
+
var Pr=Object.defineProperty;var Lr=(t,r)=>{for(var n in r)Pr(t,n,{get:r[n],enumerable:!0,configurable:!0,set:(o)=>r[n]=()=>o})};var At={};Lr(At,{isWindow:()=>q,isUndefined:()=>Ir,isStr:()=>v,isPromise:()=>Zr,isPlainObject:()=>H,isObject:()=>Fr,isObj:()=>E,isNumber:()=>Z,isNum:()=>St,isNull:()=>lt,isNotWindow:()=>p,isNotNull:()=>qr,isInt:()=>Rt,isFN:()=>w,isDefined:()=>Ur,isClassOrId:()=>Xr,isBool:()=>k,isAsync:()=>Cr,isArraybuff:()=>Br,isArr:()=>g});var w=(t)=>typeof t==="function",Cr=(t)=>t.constructor.name==="AsyncFunction",Zr=(t)=>!!t&&typeof t.then==="function",Z=(t)=>{return!isNaN(parseFloat(t))&&isFinite(t)},Fr=(t)=>{return t&&typeof t==="object"&&!Array.isArray(t)},H=(t)=>{return typeof t==="object"&&t!==null&&Object.getPrototypeOf(t)===Object.prototype&&!Array.isArray(t)},Br=(t)=>{return t instanceof Uint8Array||t instanceof ArrayBuffer||typeof t==="string"},Xr=(t)=>{return t.startsWith(".")||t.startsWith("#")},k=(t)=>typeof t==="boolean",v=(t)=>typeof t==="string",g=(t)=>Array.isArray(t),E=(t)=>typeof t==="object",St=(t)=>typeof t==="number",lt=(t)=>t===null,qr=(t)=>t===null,Ir=(t)=>typeof t==="undefined",Ur=(t)=>typeof t!=="undefined",Rt=(t)=>{return Number.isInteger(Number(t))},q=typeof window!=="undefined",p=typeof window==="undefined";function ct(t,r){l(r).forEach(([n,o])=>{Ot(t,n,{value:o,writable:!1,configurable:!1,enumerable:!0})})}var Dt=(t)=>{return g(t)?t:[t]};class ${static set i(t){console.info(...Dt(t))}static set e(t){console.error(...Dt(t))}static set w(t){console.warn(...Dt(t))}}class D{_c=0;_id="";constructor(t){if(this._c=0,this._id=t??x(5),t?.includes("-")){let[r,n]=[t.split("-").slice(0,-1).join("-"),t.split("-").slice(-1)[0]];this._id=r,this._c=Z(n)?parseInt(n):0}}get id(){return this._id+"-"+this._c}get mid(){return this._id+"-"+ ++this._c}}var Jr=(t)=>Array.from({length:t},(r,n)=>n),kt="ABCDEFGHIJKLMNOPQRSTUVWXYZ",vt="abcdefghijklmnopqrstuvwxyz";var S=(t)=>JSON.stringify(t),tr=(t)=>{return JSON.parse(t)};var M=(t)=>{if(t.startsWith("webkit"))t="-"+t;return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()},x=(t)=>{let r=kt+vt,n=Jr(10).join("");return Array.from({length:t},(o,i)=>r+(i?n:"")).reduce((o,i)=>{return o+=i.charAt(Math.floor(Math.random()*i.length))},"")},Wr=(t=6,r)=>{if(!r)return Math.floor(Math.random()*t);return Math.round(Math.random()*(r-t)+t)},rr=()=>{let t=[...kt,...vt],r=Wr(0,t.length);return t[r]};var nr=(t,r)=>{let n=r==="/"?"":r;if(r.startsWith("#"))return t+r;return r.startsWith("/")?t+n:r};class a extends Map{obj(t){t&&l(t).forEach(([r,n])=>this.set(r,n))}map(t){t.forEach((r,n)=>{if(r instanceof a)this.set(n,r);else if(g(r)){if(this.lacks(n))this.set(n,[]);this.get(n).push(...r)}else if(E(r))this.ass(n,r);else this.set(n,r)})}ass(t,r){if(!this.has(t))this.set(t,{});d(this.get(t),r)}lacks(t){return!this.has(t)}init(t,r){return this.has(t)?this.get(t):this.set(t,r).get(t)}}var{values:A,keys:W,entries:l}=Object;var{defineProperty:Ot,assign:d}=Object,or=(t,r)=>Object.hasOwn(t,r),R=(t)=>{return Object.keys(t).length},dt=(t,r)=>{if(!r.has(t))r.set(t,new a);return r.get(t)},tt=(t,r)=>{if(!r.has(t))r.set(t,[]);return r.get(t)},Ht=(t,r)=>{let n={added:{},removed:{},modified:{}},o=W(t),i=W(r);for(let e of i){let f=t[e],s=r[e];if(!(e in t))n.added[e]=s;else if(g(f)&&g(s)){if(S(f)!==S(s))n.modified[e]={old:f,new:s}}else if(E(f)&&E(s)&&!lt(f)&&!lt(s)){let u=Ht(f,s);if(R(u.added)||R(u.removed)||R(u.modified))n.modified[e]={old:f,new:s}}else if(f!==s)n.modified[e]={old:f,new:s}}for(let e of o)if(!(e in r))n.removed[e]=t[e];return n};function ir(t,r){if(t.size!==r.size)return!1;for(let n of t)if(!r.has(n))return!1;return!0}var er=(t)=>{return A(t).some((r)=>{return R(r)})};var I=(t,r)=>{return{name:t,content:r}},Gr=(t,r)=>{return{property:t,content:r}},Qr=(t,r)=>{return{"http-equiv":t,content:r}};class rt{metas=[];constructor(t){t&&this.metas.push(I("description",t))}author(t){return this.meta=I("author",t),this}charset(t){return this.meta={charset:t},this}keywords(...t){return this.meta=I("keywords",t.join(", ")),this}viewport(t){let r=l(t).map(([n,o])=>[M(n),String(o)].join("="));return this.meta=I("viewport",r.join(", ")),this}httpEquiv(t){return l(t).forEach(([r,n])=>{this.meta=Qr(M(r),String(n))}),this}robots(...t){return this.meta=I("robots",t.join(", ")),this}themeColor(t){return this.meta=I("theme-color",t),this}openGraph(t){return l(t).forEach(([r,n])=>{this.meta=Gr("og:"+r,String(n))}),this}twitter(t){return l(t).forEach(([r,n])=>{this.meta=I("twitter:"+r,String(n))}),this}push(t){this.metas.unshift(...t)}set meta(t){this.metas.push(t)}}class Mt{title;description;base;meta;link;script;css}var Kr=["charset","name","property","http-equiv"],sr=(t,r)=>{r.forEach((n)=>{for(let o of Kr)if(o in n){let i=n[o];t[`${o}_${o==="charset"?"":i}`]=n}})},zr=(t,r)=>{r.forEach((n)=>{if("href"in n){let o=n.href;t[`${o}`]=n}})};class G{_head;idm;constructor(t){this._head=new a(t)}set head(t){l(t).forEach(([r,n])=>{if(r==="title"||r==="base"){if(n!==void 0)this._head.set(r,n);return}if(n instanceof rt)return sr(this._head.init("meta",{}),n.metas);if(!g(n))return;switch(r){case"meta":return sr(this._head.init("meta",{}),n);case"link":return zr(this._head.init("link",{}),n);case"script":if(n.length){this._head.init(r,[]);let o=n.map((i)=>{if(!i.yid&&this.idm)i.yid="sc"+this.idm.mid;return i});this._head.get(r).push(...o)}return}})}get head(){return this._head}set id(t){this.idm=new D(t)}}var nt=(t)=>{return l(t??{}).reduce((r,[n,o])=>{return r.push(k(o)&&o?n:`${n}="${o}"`),r},[""]).join(" ")},fr=(t)=>{let r=new Set;if(!t)return"";let n=[...t].reduce((o,[i,e])=>{if(i==="meta"||i==="link")e=A(e);if(v(e)){if(i==="title")r.add(`<${i}>${e}</${i}>`);else o.add(`<${i}>${e}</${i}>`);return o}if(!g(e))return o;if(i==="base"){let s=e.slice(-1);if(s)return r.add(`<${i}${nt(s[0])}>`),o}return e.map((s)=>{if(i==="script"){let u={...s},h="";if("importmap"in u)u.type="importmap",h=JSON.stringify(u.importmap),delete u.importmap;else if("body"in u)h=u.body,delete u.body;return`<${i}${nt(u)}>${h}</${i}>`}return`<${i}${nt(s)}>`}).forEach((s)=>{if(s.includes('type="module"'))r.add(s);else if(s.includes("<meta"))r.add(s);else o.add(s)}),o},new Set);return[...r,...n].join("")};class ot{lang="en";htmlHead;head;constructor(){this.htmlHead=new a,this.head=(t={})=>{let r=new G(this.htmlHead),{css:n,description:o,...i}=t;if(o)r.head={meta:[{name:"description",content:o}]};if(n){let f=(g(n)?n:[n]).map((s)=>({rel:"preload stylesheet",href:s,as:"style"}));r.head={link:[...f]}}r.head=i,this.htmlHead=r.head}}}var jt=(t)=>{if(p)return;return new Promise((r,n)=>{let o=null;if(t.href)o=document.querySelector(`link[href="${t.href}"]`);if(o){r(o);return}let i=document.createElement("link");if(t.rel!=="stylesheet")t.rel="stylesheet",t.as="style";l(t).forEach(([e,f])=>{i.setAttribute(e,f)}),i.onload=()=>r(i),i.onerror=()=>n(new Error("Failed to load CSS")),document.head.appendChild(i)})},ur=(t)=>{if(p)return;return new Promise((r,n)=>{let o=document.createElement("script"),i="";if("importmap"in t)t.type="importmap",i=JSON.stringify(t.importmap),delete t.importmap;else if("body"in t)i=t.body,delete t.body;if(i)o.textContent=i;l(t).forEach(([e,f])=>{o.setAttribute(e,f)}),o.onload=()=>r(o),o.onerror=()=>n(new Error("Failed to load Script")),document.head.appendChild(o),requestAnimationFrame(()=>r("Script executed"))})},Nr=()=>{let r=document.querySelector("#d-css")?.sheet;if(r)return r;let n=document.createElement("style");return n.id="d-css",document.head.appendChild(n),n.sheet},Vr=(t,r)=>{for(let n=0;n<t.cssRules.length;n++)if(t.cssRules[n].selectorText===r)return!0;return!1},_r=(t)=>Object.entries(t).map(([r,n])=>`${M(r)}: ${n};`).join(" ");function Or(t,r={}){if(p)return;let n=Nr();if(!n)return;if(!Vr(n,t))n.insertRule(`${t} { ${_r(r)} }`,n.cssRules.length)}var Yt=(t,r=!1)=>{if(Z(t))return[+t,Rt(t)?"int":"float"];if(r&&/\.\w+$/.test(t))return[t,"file"];if(t==="/")return[t,"-"];if(t.length===36&&t.match(/\-/g)?.length===4)return[t,"uuid"];return[t,"string"]},Q=(t)=>{let r=t.startsWith("/")?t:"/"+t,n=r.match(/(?<=\/)[^/].*?(?=\/|$)/g)??["/"],[o,i]=n.reduce(([e,f],s)=>{if(s.includes("<")){let u=s.match(/(?<=<)[^/].*?(?=>|$)/g);if(u?.length){let[h,m]=u[0].split(":");if(h)e.push(h),f.push(m||"_")}}else e.push(s===">"?"/":s);return[e,f]},[[],[]]);if(r.endsWith("/")&&r.length>1)o.push("/");return{parsed:o,args:i}};class pt{storage;constructor(){this.storage=new a}cache(t,r){if(this.storage.lacks(t))this.storage.set(t,r());return this.storage.get(t)}}var hr=["int","float","file","uuid","string"],Tt=(t,r)=>{let n={},o=[],{parsed:i}=Q(t),{parsed:e,args:f}=Q(r);if(i.length===e.length)e.map((s,u)=>{let h=Yt(i[u],i.length-1===u);if(s===h[0])return h[0];if(hr.includes(h[1]))return o.push(h[0]),h[1];return s}),f.forEach((s,u)=>{n[s]=o[u]});return n};class K{_storage;CC;constructor(){this._storage=new a,this.CC=new pt}set(t){let{parsed:r,path:n}=t,o=S(r);if(!this._storage.get(o))this._storage.set(o,t);else throw`path: ${n} already used.`}get(t){let{parsed:r}=this.CC.cache(t,()=>Q(t)),n={},o=this._storage.get(S(r));if(!o&&t!=="/")for(let i of this._storage.keys()){let e=[],f=tr(i);if(r.length===f.length){let s=f.map((m,b)=>{let T=Yt(r[b],r.length-1===b);if(m===T[0])return T[0];if(hr.includes(T[1]))return e.push(T[0]),T[1];return m}),u=S(s);if(this._storage.has(u)){o=this._storage.get(u),o?.args.forEach((m,b)=>{n[m]=e[b]});break}}}return[o,n]}}class it{path="";parsed=[];args=[];constructor(t){ct(this,{path:t,...Q(t)})}}class Pt{date;constructor(t){this.date=t?new Date(t):new Date}delta(t=null,r=!1){let n=Pt.delta(this.date.getTime(),t);return r?new Date(n):n}timed(t){if(!t)return this.date;return[["year","FullYear"],["month","Month"],["day","Date"],["hour","Hours"],["minute","Minutes"],["second","Seconds"]].reduce((n,[o,i])=>{let e=t[o];return e?new Date(n[`set${i}`](n[`get${i}`]()+e)):n},new Date(this.date))}static delta(t,r=null){return r?r-t:t-Date.now()}static local(t){return new Date(t).toLocaleString()}static get now(){return Date.now()}}class Lt{static rand(t=6,r){if(r)return Math.floor(Math.random()*(r-t+1)+t);return Math.floor(Math.random()*t)+1-1}static fill(t,r=null){return Array(t).fill(r)}static new({dom:t,id:r,inner:n}){let o=document.createElement(t);if(r)o.id=r;if(n)o.innerHTML=n;return o}static randFrom(t){if(Array.isArray(t)){let r=t.length,n=this.rand(0,r-1);return t[n]}else if(typeof t=="object"){let r=W(t),n=r.length,o=this.rand(0,n-1);return r[o]}}static randArray(t=[],r=1,n=!1){let o=[],i=n?new Set:null;while((n?i.size:o.length)<r){let e=t[Lt.rand(0,t.length-1)];n?i.add(e):o.push(e)}return n?[...i]:o}static randomAZ=rr;static makeID=x;static class(t,...r){let n=r;if(t?.class)n.push(...g(t.class)?t.class:[t.class]);t.class=r}static get O(){return{vals:A,keys:W,items:l,has:or,ass:d,len:(t={})=>W(t).length}}static get is(){return At}static get return(){return ar}static sleep=(t=1000)=>new Promise((r)=>setTimeout(r,t));static get screen(){let{innerWidth:t}=window,r={xs:t<=480,sm:t>=480,smd:t>=624,md:t>=768,lg:t>=1024,xl:t>=1280,xxl:t>=1536},n=l(r).reverse();for(let o=0;o<n.length;o++){let[i,e]=n[o];if(e)return i}return}bytes(t){if(t===0)return"0 Bytes";let r=1024,n=["Bytes","KB","MB","GB"],o=Math.floor(Math.log(t)/Math.log(r));return parseFloat((t/Math.pow(r,o)).toFixed(2))+" "+n[o]}static format(t){return new mr(t)}}class ar{static arr(t){return t?g(t)?t:[t]:[]}static num(t,r=0){let n=parseFloat(t);return isNaN(n)?r:n}static str(t){return String(t)}static arr2obj(t,r=!1){return t.reduce((n,o,i)=>{if(r)n[o]=i;else n[i]=o;return n},{})}}class mr{val;constructor(t){this.val=t}get px(){return`${this.val}px`}get rem(){return`${this.val}rem`}get pr(){return`${this.val}%`}}var Ct={},U={};class gr{stream;url;constructor(t,r){if(this.url=t,t in Ct)this.stream=Ct[t];else this.stream=new EventSource(t,{withCredentials:r}),Ct[t]=this.stream,U[this.url]={}}on(t){let r=this.stream;return l(t).forEach(([n,o])=>{if(n in U[this.url])U[this.url][n].forEach((i)=>{this.stream.removeEventListener(n,i)}),U[this.url][n]=[];if(r.addEventListener(n,o),!(n in U[this.url]))U[this.url][n]=[];U[this.url][n].push(o)}),this}}function lr(t,r=!0){return new gr(t,r)}class cr{value;constructor(t){this.value=t}get str(){return String(this.value).toString()=="null"?null:String(this.value).toString()}get int(){if(Z(this.value))return parseInt(this.value);else return null}get float(){if(Z(this.value))return parseFloat(this.value);else return null}get bool(){if(this.value==="true")return!0;else if(this.value=="false")return!1;else return null}get json(){if(this.value)return JSON.parse(this.value);return null}}class z{key;state;storage;constructor(t,r="local",n){if(this.storage=r=="local"?localStorage:sessionStorage,typeof t=="object"){let[o,i]=l(t)[0];if(this.key=o,this.state=i,n){let e=this.as[n];this.state.value=e}N((e)=>{this.set=e},[this.state],{id:this.key})}else this.key=t,this.state=null}get as(){return new cr(this.storage.getItem(this.key))}get value(){return this.storage.getItem(this.key)}set set(t){let r=E(t)?S(t):String(t);this.storage.setItem(this.key,r)}get remove(){this.storage.removeItem(this.key);return}}var dr={get:(t)=>new z(t,"local"),init:(t,r)=>new z(t,"local",r)};var pr={get:(t)=>new z(t,"session")};class bt extends it{id;cls;constructor(t,r,n){super(t);this.id=r;this.cls=n}}class Tr extends it{id;cls;constructor(t,r,n){super(t);this.id=r;this.cls=n}}class Zt extends ot{storage=new K;errorStorage=new K;wssStorage=new K;route;error;wss;base;constructor(t=""){super();this.base=t?t.startsWith("/")?t:`/${t}`:"",this.route=(r)=>{let n=this._base(r);return(o)=>{return o.route=n,this.storage.set(new bt(n,x(5),o)),o}},this.wss=(r)=>{let n=this._base(r);return(o)=>{return o.route=n,this.wssStorage.set(new Tr(n,x(5),o)),o}},this.error=(...r)=>{return(n)=>{if(r.length)r.forEach((o)=>{this.errorStorage.set(new bt(o.toString(),x(5),n))});else this.errorStorage.set(new bt("404",x(5),n));return n}}}_base(t){return nr(this.base,t)}async getPath(t){return this.storage.get(t)}async loadError(t){return this.errorStorage.get(t.toString())}async loadWSS(t){return this.wssStorage.get(t)}}var et=new a,V=(t)=>{if(p)return;let r=et.get(t);if(r?.isConnected)return r;et.delete(t);let n=document.getElementById(t);if(!n)return;return et.set(t,n),n};function br(){let t=[];return et.forEach((r,n)=>{if(!r.isConnected)t.push(n),et.delete(n)}),t}function N(t,r,{id:n="stateHook",init:o}={}){if(p)return()=>{};let i=[],e=()=>r.map((s)=>s.value),f=()=>{t(...e())};if(r.forEach((s)=>{i.push(s.hook(f)(n))}),o)f();return()=>{i.forEach((s)=>s())}}var yr=(t)=>{t.forEach((r)=>r())};var kr=(t,r)=>{for(let[n,o]of t){let i=V(n);if(!i){t.delete(n);continue}o.forEach((e)=>{e.call(i,r)})}};class j extends EventTarget{options;deep;verify;hooks=new a;states=new a;_value;listening=!1;end;constructor(t,r={},n=!0,o=!0){super();this.options=r;this.deep=n;this.verify=o;this._value=t}get value(){return this._value}set value(t){if(!this.verify){this._value=t,this.dispatchEvent(new CustomEvent("updated",{detail:this._value}));return}if(!this.deep){if(this._value===t)return;this._value=t,this.dispatchEvent(new CustomEvent("updated",{detail:this._value}));return}if(H(this._value)||g(this._value)){let r=Ht(this._value,t);if(!er(r))return}else if(this._value instanceof Set){if(!ir(this._value,t))return}else if(this._value===t)return;this._value=t,this.dispatchEvent(new CustomEvent("updated",{detail:this._value}))}get listen(){let t=(r)=>{if(yr(this.hooks),kr(this.states,r.detail),!this.states.size&&!this.hooks.size)this.end?.()};if(!this.listening)this.addEventListener("updated",t,this.options),this.listening=!0;return()=>{this.listening&&this.removeEventListener("updated",t,this.options),this.end=void 0,this.listening=!1}}call(t,r){return(n)=>{if(dt(n,this.states).set(r,t),!p&&!this.listening)this.end=this.listen;return()=>{if(this.states.has(n))this.states.get(n)?.delete(r)}}}hook(t){return(r)=>{if(this.hooks.set(r,t),!p&&!this.listening)this.end=this.listen;return()=>{if(this.hooks.has(r))this.hooks.delete(r)}}}}function Y(t,r={}){return new j(t,r,!0)}function vr(t,r=!1){return new j(t,{},!1,r)}var _=(t)=>{if(g(t))return t.filter((r)=>r!==void 0).join(" ");else if(E(t)){if(H(t))return S(t)}else if(w(t))return _(t());else if(t!==void 0&&t!==null)return k(t)?t?"":"false":String(t);return""};function tn(t,r){switch(r??t){case"style":return function(n){this.style.setProperty(t,n)};default:return function(n){this.setAttribute(t,n)}}}class Ft{attr;constructor(t={}){this.attr=t}get(t,r=this.attr,n){let o=(i,e)=>{if(g(e))t.attr_push(i,_(e));else if(e instanceof j){let f=n?`${n}_${i}`:i;t.states.push(e.call(tn(i,n),f)),o(i,e.value)}else if(E(e)){if(H(e)&&!n)this.get(t,e,i)}else t.attr_push(i,_(e),n)};l(r).forEach(([i,e])=>{if(i==="ref"){if(e instanceof st)t.events.obj({element(){e.element=this}})}else if(["on"].includes(i))E(r.on)&&t.events.obj(r.on);else o(i,e)})}unload(t){let r=void 0;if(t in this.attr)r=this.attr[t],delete this.attr[t];return r}}class F{xid;IDM;map=new a;states=[];events=new a;OZ;constructor(t,r=new D,n){this.xid=t;this.IDM=r;this.OZ=n??new yt}attr_push(t,r,n){let o=n??t;if(!this.map.has(o))this.map.set(o,[]);let i=n?`${M(t)}:${r};`:r;this.map.get(o).push(i)}get attr(){let t=[""];return this.map.forEach((r,n)=>{let o=r.join("");t.push(o?`${n}="${o}"`:n)}),t.join(" ")}set id(t){if(!this.map.has("id"))this.map.set("id",[t])}get id(){return this.map.get("id")?.join("")}}var rn=(t,r,n)=>{return t.addEventListener(r,n),()=>{t.removeEventListener(r,n)}},ft={};class yt{events=new a;states=new a;winStates=new a;windowEvents=new a;resetST=new a;resetEV=new a;constructor(){}get keys(){return[...new Set([...this.states.keys(),...this.events.keys()])]}set(t){let{id:r,events:n,states:o}=t;if(r){if(n.size)this.events.set(r,n);if(o.length)this.states.set(r,o)}return this}push(t){return t.events.forEach((r,n)=>{r.forEach((o,i)=>{dt(n,this.events).set(i,o)})}),t.states.forEach((r,n)=>{tt(n,this.states).push(...r)}),this}get stage(){return this.events.forEach((t,r)=>{this.events.delete(r);let n=V(r);if(!n){this.events.delete(r);return}t.forEach((o,i)=>{switch(i){case"ready":case"element":o.apply(n,[n]);break;case"resize":case"beforeunload":case"popstate":case"winscroll":case"winload":case"winfocus":case"winblur":let e=i.replace(/^win/,"");this.windowEvents.init(e,new a).set(r,o);break;case"state":let[f,s,u]=o.apply(n,[n]),h=g(s)?s:[s];if(!h.length)break;let m=()=>h.map((T)=>T.value),b=()=>f(...m());if(u)b();h.forEach((T)=>tt(r,this.resetST).push(T.call(b,r+"_state")(r)));break;default:tt(r,this.resetEV).push(rn(n,i,o))}})}),this.processWindowEvents,this.states.forEach((t,r)=>{this.states.delete(r),t.forEach((n)=>{tt(r,this.resetST).push(n(r))})}),this}get processWindowEvents(){let t=(r,n)=>{let o=0,i=!1,e=(s)=>{if(o=window.scrollY,!i)window.requestAnimationFrame(()=>{n.forEach((u,h)=>{let m=V(h);if(m)u.call(m,s);else this.windowEvents.get(r)?.delete(h)}),i=!1}),i=!0},f=(s)=>{n.forEach((u,h)=>{let m=V(h);if(m)u.call(m,s);else this.windowEvents.get(r)?.delete(h)})};return window.addEventListener(r,r==="scroll"?e:f),()=>{window.removeEventListener(r,r==="scroll"?e:f)}};return this.windowEvents.forEach((r,n)=>{if(r.size){if(!ft[n])ft[n]=t(n,r)}else if(ft[n])ft[n](),delete ft[n]}),this}reset(t){return t.forEach((r)=>{this.windowEvents.forEach((n,o)=>{if(n.has(r))n.delete(r)}),this.resetEV.get(r)?.forEach((n)=>{n()}),this.resetST.get(r)?.forEach((n)=>{n()}),this.resetST.delete(r),this.resetEV.delete(r)}),this}RPS(t){if(t){let r=br();this.reset(r);let n=t.keys;if(n.length)this.reset(n).push(t).stage}return this}}var P=new yt;var nn=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],on=(t)=>nn.includes(t);function en(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var xt=(t,r)=>{if(g(t))return t.map((n)=>xt(n,r)).join("");else if(t instanceof ht){let n=t.__(r.IDM),{ctx:o,oz:i}=n;return r.OZ.push(i),o}else if(E(t))return S(t);else if(w(t))return xt(t(),r);else if(t!==void 0&&t!==null)return en(t);return""},wt=(t,r)=>{let n=new D(r),o=new F(n.id,n);return{ctx:xt(t,o),catt:o}};function sn(t){let r=this.id;if(r){let{ctx:n,catt:o}=wt(t,r);if(this.innerHTML!==n)this.innerHTML=n,P.RPS(o.OZ)}}var ut=(t,r,n,o=[])=>{if(g(t))t.forEach((i)=>{ut(i,t.length,n,o)});else if(t instanceof j)if(r>1)ut(B("div",{},t),r,n,o);else{let i=t.value,e=i instanceof ht?"dom":"ctx",{ctx:f,catt:s}=wt(i,n.xid+"-0");n.xid=s.xid,o.push(f),n.OZ.push(s.OZ),n.states.push(t.call(sn,e))}else o.push(xt(t,n))};class Bt{tag;ctx;closing;constructor(t,r){this.tag=t;this.ctx=r;let n=on(t);this.closing=n?"":`</${t}>`}process(t,r=this.ctx,n=[]){return r.forEach((o)=>{ut(o,r.length,t,n)}),n.join("")}get(t){let r=this.process(t);if(t.events.size||t.states.length)t.id=t.xid;return`<${this.tag}${t.attr}>${r}${this.closing}`}}class ht{tag;constructor(t,r={},...n){this.tag=t;ct(this,{attr:new Ft(r),ctx:new Bt(t,n)})}__(t=new D){let r=t.mid,n=new F(r,t);return this.attr.get(n),{ctx:this.ctx.get(n),oz:n.OZ.set(n),id:n.id}}}function B(t,r={},...n){if(w(t))return $.i=t,t(r??{},...n);return new ht(t,r??{},n)}var fn=(t,...r)=>r;class Xt{e;opt;constructor(t){this.e=t;this.opt={duration:500,easing:"ease-in-out",fill:"forwards"}}animate(t,r={}){return this.e.animate(t,r)}get slide(){let t=({x:r=0,y:n=0},o={})=>{d(this.opt,o);let i=[[r,n],[0,0]].map(([e,f])=>({transform:`translateX(${e}rem) translateY(${f}rem)`}));return this.e.animate(i,this.opt),this};return{left:(r={})=>{return t({x:-2},r)},right:(r={})=>{return t({x:2},r)},up:(r={})=>{return t({y:2},r)},down:(r={})=>{return t({y:-2},r)}}}fade(t={}){d(this.opt,t);let r=[0,1].map((n)=>({opacity:n}));return this.e.animate(r,this.opt),this}shake(t="Y",r={}){d(this.opt,r);let n=[0,5,-5,5,0].map((o)=>({transform:`translate${t}(${o}px)`}));return this.e.animate(n,this.opt),this}color(t=[],r={}){d(this.opt,r);let n=Array.isArray(t)?t.map((o)=>({color:o})):{color:t};return this.e.animate(n,this.opt),this}bg(t=[],r={}){d(this.opt,r);let n=Array.isArray(t)?t.map((o)=>({backgroundColor:o})):{backgroundColor:t};return this.e.animate(n,this.opt),this}bounce(t=1,r={}){d(this.opt,r);let n=[0.5,t,1].map((o)=>({transform:`scale(${o})`}));return this.e.animate(n),this}}class Ut{e;query;constructor(t,r){this.e=t;this.query=r}get a(){return new Xt(this)}get all(){if(this.query){let t=document.querySelectorAll(this.query);if(t.length)return Array.from(t).map((r)=>r)}return[]}get attr(){let t=this.e;return{has:(r)=>{return t.hasAttribute(r)},get:(r)=>{return t.getAttribute(r)},del:(r)=>{return t.removeAttribute(r),this},set:(r)=>{for(let n in r){let o=r[n];if(r[n]!==void 0)t.setAttribute(n,_(o))}return this}}}get children(){return Array.from(this.e.children).map((t)=>c(t))}get click(){return this.e.click(),this}get delete(){return this.e.remove(),this}get disabled(){return this.e.disabled??!1}get focus(){return this.e.focus(),this}get href(){return this.e?.href??""}get id(){return this.e.id}get inner(){return this.e.innerHTML}get offsetParent(){let t=this.e.offsetParent;if(t)return new L(t);return}get parent(){let t=this.e.parentElement;if(t)return new L(t);return}get hash(){return this.e?.hash??""}get path(){return this.e?.pathname??""}get rect(){return this.e.getBoundingClientRect()}get remove_element(){return this.e.remove(),this}get style(){let t=this.e.style,r=this;return{set:(n,o=0)=>{let i=t,e=()=>{l(n).forEach(([f,s])=>{if(f in i){if(i[f]!==s)i[f]=s}else if(s!==null)t.setProperty(f,String(s))})};if(w(o))r.on("transitionend",o);if(St(o))setTimeout(e,o);else e();return r},get:(n)=>{let o=M(String(n));return t.getPropertyValue(o)},del:(...n)=>{n.forEach((o)=>{let i=M(String(o));t.removeProperty(i)})}}}get submit(){let t=this.e;if("submit"in t)return t.submit();return!1}get tag(){return this.e.tagName.toLowerCase()}get value(){return this.e.value??""}get unload(){return()=>{this.e.remove()}}set append(t){let{ctx:r,oz:n}=qt(t,It(this.id));this.e.insertAdjacentHTML("beforeend",r),P.RPS(n)}set appendfirst(t){let{ctx:r,oz:n}=qt(t,It(this.id));this.e.insertAdjacentHTML("afterbegin",r),P.RPS(n)}set inner(t){let{ctx:r,oz:n}=qt(t,It(this.id));this.e.innerHTML=r,P.RPS(n)}set disabled(t){let r=this.e;if("disabled"in r)r.disabled=t}set id(t){this.e.id=t}set value(t){let r=this.e;r.value=t}}var qt=(t,r)=>{let{ctx:n,catt:o}=wt(t,r);return{ctx:n,oz:o.OZ}},It=(t)=>t?`${t}-0`:t;class L extends Ut{constructor(t,r){super(t,r)}add(...t){return this.e.classList.add(...t.map((r)=>r.replace(/[^\w-]/,""))),()=>{this.e.classList.remove(...t.map((r)=>r.replace(/[^\w-]/,"")))}}remove(...t){return this.e.classList.remove(...t.map((r)=>r.replace(/[^\w-]/,""))),this}toggle(t,r){let n=typeof t!="string"?t.apply(this):t;return this.e.classList.toggle(n,r)}hasNode(t){return this.e.contains(t)}has(...t){let r=this.e.classList;return t.every((n)=>r.contains(n))}insert(t){return{HTML:(...r)=>{return r.forEach((n)=>{this.e.insertAdjacentHTML(t,n)}),this},element:(...r)=>{return r.forEach((n)=>{this.e.insertAdjacentElement(t,n)}),this},text:function(...r){return r.forEach((n)=>{this.e.insertAdjacentText(t,n)}),this}}}is(t){let r=this.e.classList,n=this.e.tagName.toLocaleLowerCase(),o=!0,i=!0;if(t.dom)i=t.dom==n?!0:!1;if(t.class)if(Array.isArray(t.class))t.class.forEach((e)=>{o=o?r.contains(e):!1});else o=o?r.contains(t.class):!1;return o&&i}on(t,r,n=!1){let o=!1;if(t.indexOf("touch")>-1)o=!0;return this.e.addEventListener(t,r,{capture:n,passive:o}),this}remove_on(t,r,n=!1){return this.e.removeEventListener(t,r,n),this}timed(t,r=250){return setTimeout(()=>t(this),r),this}animate(t,r,n){let o={duration:300,easing:"ease",fill:"forwards"};if(w(r))n=r;else d(o,r);let i=this.e.animate(t,o);if(n)i.finished.then(n);return this}}function c(t,r){let n=r?r:document;if(v(t)){let o=n.querySelector(t);if(o)return new L(o,t);return}else if(H(t)){let[[o,i]]=l(t),f=`${o==="id"?"#":"."}${i}`,s=n.querySelector(f);if(s)return new L(s,f);return}else return new L(t)}class st{state=new j(void 0);constructor(){}get element(){return this.state.value?.e}set element(t){if(t)this.state.value=new L(t);else this.state.value=void 0}get $(){return this.state.value}}var un=()=>{return new st};class Jt{lang;head="";constructor(t,r){if(this.lang=t,r)this.head=fr(r)}body(t,r,n){return[`<!DOCTYPE html><html lang="${this.lang}">`,`<head>${this.head}</head>`,`<body id="${r??x(5)}"${n?" "+n:""}>${t}</body>`,"</html>"].join("")}}class $t extends Mt{path;args;id;status;lang;import;_data={};static route="/";constructor(t,r={},n,o=200){super();this.path=t;this.args=r;this.id=n;this.status=o}async loader(){if(this.import)try{let t=await this.import;if(t.default)this.import=await t.default({...this.args,...this.data});else this.import=void 0}catch(t){return $.e=["import",{error:"loader"}],this.import=void 0,[]}if(this.body){let t=await this.body();return g(t)?t:[t]}if(this.import){let t=this.import;return g(t)?t:[t]}return[]}getHeadAttr(t={},...r){let n=new G;if(R(t))n.head=t;n.id=this.id;let o=n.head;return r.forEach((i)=>{o.map(i)}),hn(n,this),o}set data(t){d(this._data,t)}get data(){return this._data}}class Wt extends $t{head(){this.title=`error ${this.status}`}body(){return B("div",{},this.path+" not found...")}}function hn(t,r){let{link:n,script:o,meta:i,title:e,base:f,description:s,css:u}=r;if(t.head={title:e,base:f,meta:i,link:n,script:o},s)t.head={meta:[{name:"description",content:s}]};if(u){let m=(g(u)?u:[u]).map((b)=>({rel:"preload stylesheet",href:b,as:"style"}));t.head={link:[...m]}}}function xr(t){let r=[];if(t?.length){let{href:n,target:o}=t[0],i=c("base");if(i){if(i.attr.get("href")!==n)i.attr.set({href:n,target:o})}else{let e=c(document.createElement("base"));e.attr.set({href:n,target:o}),document.head.append(e.e)}}return r}var wr=new a;async function $r(t,r={},n=!1){let o=at.value,i={};if(c("link")?.all.forEach((e)=>{let f=c(e),s=f.attr.get("href");if(s){let u=f.attr.get("rt");if(n){let h=wr.get(o);if(h){if(!h.has(s))i[s]=f.unload}else i[s]=f.unload}else if(u){if(u===t)i[s]=f.unload}}}),r&&R(r))for(let e of A(r)){let f=e.href;if(!(f in i))try{let s=void 0;if(!n){if(s=c(`link[href='${f}']`),s)s.attr.set({rt:t});e.rt=t;let u=wr.init(o,new Set);if(!u.has(f))u.add(f)}if(!s)await jt(e)}catch(s){$.e=["link error",{error:"yvee @ link"}]}else delete i[f]}return A(i)}var an=["charset","name","property","http-equiv"];function Er(t){let r={};if(c("meta")?.all.forEach((n)=>{let o=n.attributes;for(let i of an)if(i in o){let e=o[i].value;r[`${i}_${i==="charset"?"":e}`]=n}}),t)l(t).forEach(([n,o])=>{if(n in r)c(r[n]).attr.set(o),delete r[n];else{let i=c(document.createElement("meta"));i.attr.set(o),document.head.append(i.e)}});return A(r).map((n)=>c(n).unload)}var Sr=new a;async function Rr(t,r,n=!1){let o=at.value,i={};if(c("script[yid]")?.all.forEach((e)=>{let f=c(e),s=f.attr.get("yid");if(s){let u=f.attr.get("rt");if(n){let h=Sr.get(o);if(h){if(!h.has(s))i[s]=f.unload}else i[s]=f.unload}else if(u){if(u===t)i[s]=f.unload}}}),r){for(let e of r)if("yid"in e)if(e.yid in i)delete i[e.yid];else try{if(!n){e.rt=t;let f=e.yid,s=Sr.init(o,new Set);if(!s.has(f))s.add(f)}await ur(e)}catch(f){$.e=["script error",{error:"yvee @ script"}]}}return A(i)}async function Ar(t,r){let n=[];if(p)return[];let o=t.get("title")??"",{pushState:i}=this.config;if(i){let e=this.path.value,f=this.lastPath.value;if(f!==e)if(!f.startsWith(e))X(e,o);else if(e===this.base)X(e,o);else X(e,o)}if(o&&(document.title=o),this.isYvee)document.documentElement.lang=r,n.push(...xr(t.get("base"))),n.push(...Er(t.get("meta")));return n.push(...await $r(this.id,t.get("link"),this.isYvee)),n.push(...await Rr(this.id,t.get("script"),this.isYvee)),n}function X(t,r){if(p)return;let{pathname:n,hash:o}=window.location,i=n+o;if(t&&i!==t)history.pushState({},r??"",t)}class Gt{path;args;static route="/";isConnected=Y(!1);data={};constructor(t,r={}){this.path=t;this.args=r;this.data=r}open(t){}message(t){}close(t){}error(t){}get connect(){if(this.ws&&this.ws.readyState<=1)return this;return this.ws=new WebSocket(this.path),this.ws.onopen=async(t)=>{this.isConnected.value=!0,await this.open.call(this,t)},this.ws.onmessage=async(t)=>{await this.message.call(this,t)},this.ws.onclose=async(t)=>{this.isConnected.value=!1,await this.close.call(this,t)},this.ws.onerror=async(t)=>{this.isConnected.value=this.ws.readyState<=1,await this.error.call(this,t)},this}get reconnect(){if(this.state>=2)this.connect;return this}get disconnect(){if(this.state<=1)this.ws.close();return this}get state(){return this.ws?.readyState??3}set send(t){if(this.isConnected.value)this.ws.send(t);else throw new Error(`websocket path ${this.path} not connected`)}}var O=new a;class Qt{yvee;constructor(t){this.yvee=t}async load(t){if(p)return;if(!O.has(t)){let[n,o]=await this.yvee.loadWSS(t);if(!n)return;let{cls:i,path:e,id:f}=n,s=new i(e,o).connect;return O.set(t,s),s}let r=O.get(t);return r.reconnect,r}unload(t){if(p)return;if(O.has(t)){let r=O.get(t);if(!r)return;r.disconnect,O.delete(t)}}}var Kt=new a;function mn(t,r,n,o){let{on:i,top:e,topRef:f,...s}=t,u={...i??{},click(h){h.preventDefault();let m=c(this),b=m.path;o.value=n.value,n.value=b;let T=m.hash;if(T){let J=c(T),y=window.scrollY;if(J)y+=J.rect.top;if(f)y-=f?.value?.e.offsetHeight||0;if(e)if(typeof e==="number")y-=e;else y-=e();window.scrollTo({top:y,behavior:"smooth"}),X(b+T)}else if(o.value===n.value)window.scrollTo({top:m.rect.top||0,behavior:"smooth"}),X(window.location.pathname)}};return B("a",{...s,on:{...u}},...r)}function gn(t,r,n){let{classes:o}=t.config,{on:i,...e}=r,f={...r.on??{},...n&&{popstate(s){let h=s.target.location.pathname;t.path.value=h}},...{element(s){t.mainElement=this}}};return B("div",{...e,...o&&{class:o},on:f},t.root)}async function ln(t,r){let[n,o]=await this.loadError(r??0);if(n){let{cls:i,id:e}=n;return new i(t,o,e,r)}else{let i=new Wt(t,o,x(5));return i.title=`error ${r}`,i}}function zt(){if(q)return parseInt(c('meta[name="error"]')?.attr.get("content")??"200");return 200}class mt extends Zt{config;hook;root=Y([]);socket;id=x(4);path=Y("");lastPath=Y("");loading=Y(!1);mainElement;A;Main;load;matchPath;isYvee=!1;constructor(t={},r={}){super(t.base??"");this.config=t;if(this.socket=new Qt(this),t.id)this.id=t.id;this.A=(n,...o)=>{if(this.base){if(!n.href.startsWith(this.base))n.href=this._base(n.href)}return mn(n,o,this.path,this.lastPath)},this.Main=(n)=>{if(R(r))if(!n.on)n.on=r;else d(n.on,r);return gn(this,n,this.isYvee)},this.load=async(n,o={})=>{if(this.hook)this.hook();if(n){this.path.value=n,this.lastPath.value=n;try{await this.render(n,404,o),this.hooker()}catch(i){$.e=["render error",{error:"Pager loader"}]}}return this},this.matchPath=(n)=>{let o=this._base(n),i=this.path.value,e=this.base;if(i===o)return!0;else{let f=i.replace(e,""),s=o.replace(e,"");if(s){if(f.startsWith(s))return!0}else if(!i)return!0}return!1}}hooker(){let t={},r={},n=this.path.value;if(this.hook)this.hook();this.hook=N(async(o)=>{if(r[n]=window.scrollY,t[n]=this.mainElement?.scrollTop??0,(await this.render(o,404)).done){let i=r[o]??0;if(i)window.scrollTo({top:i,behavior:"instant"});let e=t[o]??0;if(e)this.mainElement?.scrollTo({top:e,behavior:"instant"});n=o}},[this.path],{id:"router"})}async class(t,r,n=!1){let[o,i]=await this.getPath(t);if(o&&!n){let{cls:e,id:f}=o;return new e(t,i,f)}else return await ln.call(this,t,404)}async fetch(t){if(t)try{if(t.fetch){let r=await t.fetch();if(H(r)&&R(r))t.data=r}}catch(r){$.e=["class fetch",{error:"fetch"}]}}async processHead(t,r={}){return t?await this.processClassHead(t,r):await this.processDefaultHead(r)}async processClassHead(t,r){if(t.head)await t.head();return t.getHeadAttr(r,this.htmlHead)}async processDefaultHead(t){let r=new G;if(R(t))r.head=t;return r.head.map(this.htmlHead),r.head}async render(t,r=404,n={},o={},i=!0,e=!1){let f=await this.class(t,r??zt(),e);f.data=n,await this.fetch(f);let s=await this.processHead(f,o);if(p)Kt.set(this.id,s);if(!f)return{lang:this.lang,heads:s,done:!1};let u=[];if(this.loading.value=!0,this.isYvee)u=await f.loader();let h=[];if(i)h=await Ar.call(this,s,f?.lang||this.lang);if(!this.isYvee)u=await f.loader(),h.forEach((m)=>m());if(this.isYvee)h.forEach((m)=>m());if(u.length)this.root.value=u;else await this.render(t,r,n,o,i,!0);return this.loading.value=!1,{heads:s,lang:f.lang??this.lang,done:!0}}}var at=Y("");class Et extends mt{config;isYvee=!0;unload=!0;constructor(t={},r={}){super(t,r);this.config=t;this.path=at,this.load=async(n,o={})=>{if(q)n=dn()||this._base(n??"/");if(this.hook)this.hook();if(n){this.path.value=n,this.lastPath.value=n;try{await this.render(n,404,o),this.hooker()}catch(i){$.e=["render error",{error:"Yvee loader"}]}}return this}}}var cn=(t)=>{return(r)=>{t(r)}};function dn(){if(q)return c('meta[name="yvee"]')?.attr.get("content")??"/";return""}var Dr=(t,r,n,o=!1)=>{let i=[];if(i.push({charset:"utf-8"}),i.push({name:"viewport",content:"width=device-width, initial-scale=1.0"}),n)switch(n){case 404:i.push({name:"error",content:n.toString()});break;default:break}if(o)i.push({name:"yvee",content:r});if(t.meta)if(g(t.meta))t.meta.unshift(...i);else t.meta.push(i);else t.meta=i},Hr=async(t,r,n={},o=[])=>{let i=await r(n),e=g(i)?i:[i],f=new F(t,new D(t));return e.forEach((s)=>{ut(s,e.length,f,o)}),f.OZ.set(f),f.OZ};async function pn(t,r,n={}){let{bodyattr:o={},id:i,route:e,base:f="",index:s,data:u}=n;if(q){let h={},m=window.location.pathname,b=document.body.id;if(r)if(r instanceof Et)await r.load();else{if(u)if(w(u))h=await u();else h=u;if(e){if(e.length>1&&e.slice(-1)!=="/")m=m.replace(/^\/|\/$/g,"");d(h,Tt(m,e))}d(h,{path:m,status:zt()})}let T=await Hr(b,t,h);P.push(T),requestAnimationFrame(()=>{P.stage})}return async({path:h,data:m={},status:b=200})=>{let T=x(4),J=new a,y={};if(i)T=i;if(o.id)T=o.id.toString();let Nt="en";if(r instanceof Et){let{base:C,path:gt,id:Mr,lang:jr}=r;if(y.base=[{href:C==="/"?C:`${C}/`,target:"_blank"}],y.script)y.script.push({type:"module",src:"./index.js"});else y.script=[{type:"module",src:"./index.js"}];gt.value=h,Dr(y,h,b,!0);let{heads:_t}=await r.render(h,b,m,y,!1);Kt.values().forEach((Yr)=>{d(_t.init("link",{}),Yr.get("link")??{})}),T=Mr,J=_t,Nt=jr}else{let C=h==="/"?h:`${h}/`;if(s)C=`${s}/`;if(f)C=`${f}${C}`;if(y.base=[{href:C,target:"_self"}],y.script)y.script.push({type:"module",src:"./index.js"});else y.script=[{type:"module",src:"./index.js"}];if(e)d(m,Tt(h,e));d(m,{status:b,path:h,base:f}),d(y,w(r)?await r(m):r),Dr(y,h,b);let gt=new ot;gt.head(y),J=gt.htmlHead}let Vt=[];return await Hr(T,t,m,Vt),new Jt(Nt,J).body(Vt.join(""),T,nt(o))}}var Us=(t,r)=>{return`${t.replace(/\/+$/,"")}/${r.replace(/^\.\/+/,"")}`},Js=(t)=>{if(p)return;return t()};export{Gt as websocket,un as useRef,pr as session,Us as resolvePath,X as pushHistory,$ as log,dr as local,fn as frag,lr as eventStream,B as dom,$t as doc,jt as cssLoader,Or as addCSS,Lt as __,Et as Yvee,Pt as Time,j as Stateful,N as StateHook,Y as State,cn as Routes,pn as Render,st as Ref,vr as QState,mt as Pager,rt as Meta,Js as IfClient,c as $};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yvee",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "Yvee JS framework",
|
|
5
5
|
"author": "Marky <markjotep@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"homepage": "https://github.com/MARKjotep/yvee#readme",
|
|
28
28
|
"dependencies": {},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"rollup": "^4.
|
|
31
|
-
"rollup-plugin-dts": "^6.
|
|
30
|
+
"rollup": "^4.46.2",
|
|
31
|
+
"rollup-plugin-dts": "^6.2.1"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"typescript": "^5.7.3"
|