yvee 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +760 -0
- package/dist/index.js +1 -0
- package/package.json +48 -0
- package/readme.md +3 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,760 @@
|
|
|
1
|
+
type V = string | number | boolean;
|
|
2
|
+
type obj<T> = Record<string, T>;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A custom Map implementation that provides additional utility methods for working with objects and maps.
|
|
6
|
+
*
|
|
7
|
+
* @template K - The type of the keys in the map.
|
|
8
|
+
* @template V - The type of the values in the map.
|
|
9
|
+
*/
|
|
10
|
+
declare class Mapper<K, V> extends Map<K, V> {
|
|
11
|
+
obj(obj?: object | null): void;
|
|
12
|
+
map(map: Mapper<K, V>): void;
|
|
13
|
+
ass<T>(key: K, obj: T): void;
|
|
14
|
+
lacks(key: K): boolean;
|
|
15
|
+
init(key: K, val: V): V;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare class $$ {
|
|
19
|
+
static set p(a: any);
|
|
20
|
+
}
|
|
21
|
+
declare class idm {
|
|
22
|
+
_c: number;
|
|
23
|
+
_id: string;
|
|
24
|
+
constructor(mid?: string);
|
|
25
|
+
get id(): string;
|
|
26
|
+
get mid(): string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface metaViewport {
|
|
30
|
+
width?: string;
|
|
31
|
+
height?: string;
|
|
32
|
+
initialScale?: string;
|
|
33
|
+
minimumScale?: string;
|
|
34
|
+
maximumScale?: string;
|
|
35
|
+
userScalable?: string;
|
|
36
|
+
interactiveWidget?: string;
|
|
37
|
+
}
|
|
38
|
+
interface httpeQuiv {
|
|
39
|
+
contentSecurityPolicy?: string;
|
|
40
|
+
contentType?: string;
|
|
41
|
+
defaultStyle?: string;
|
|
42
|
+
refresh?: string;
|
|
43
|
+
cacheControl?: string;
|
|
44
|
+
xUaCompatible?: string;
|
|
45
|
+
}
|
|
46
|
+
interface OG {
|
|
47
|
+
title?: string;
|
|
48
|
+
description?: string;
|
|
49
|
+
image?: string;
|
|
50
|
+
url?: string;
|
|
51
|
+
type?: string;
|
|
52
|
+
card?: "summary" | "summary_large_image" | "app" | "player";
|
|
53
|
+
}
|
|
54
|
+
type meta$1<T> = {
|
|
55
|
+
charset?: T;
|
|
56
|
+
content?: T;
|
|
57
|
+
"http-equiv"?: T;
|
|
58
|
+
name?: T;
|
|
59
|
+
property?: T;
|
|
60
|
+
media?: T;
|
|
61
|
+
url?: T;
|
|
62
|
+
};
|
|
63
|
+
declare class Meta {
|
|
64
|
+
metas: Record<string, string>[];
|
|
65
|
+
constructor(description?: string);
|
|
66
|
+
author(name: string): this;
|
|
67
|
+
charset(val: string): this;
|
|
68
|
+
keywords(...keyword: string[]): this;
|
|
69
|
+
viewport(vport: metaViewport): this;
|
|
70
|
+
httpEquiv(httpeQuiv: httpeQuiv): this;
|
|
71
|
+
robots(...robot: ("index" | "noindex" | "follow" | "nofollow")[]): this;
|
|
72
|
+
themeColor(color: string): this;
|
|
73
|
+
openGraph(og: Omit<OG, "card">): this;
|
|
74
|
+
twitter(og: OG): this;
|
|
75
|
+
and(metas: meta$1<string>[]): this;
|
|
76
|
+
private set meta(value);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
type meta<T> = {
|
|
80
|
+
charset?: T;
|
|
81
|
+
content?: T;
|
|
82
|
+
"http-equiv"?: T;
|
|
83
|
+
name?: T;
|
|
84
|
+
property?: T;
|
|
85
|
+
media?: T;
|
|
86
|
+
url?: T;
|
|
87
|
+
};
|
|
88
|
+
type link<T> = {
|
|
89
|
+
href?: T;
|
|
90
|
+
hreflang?: T;
|
|
91
|
+
media?: T;
|
|
92
|
+
referrerpolicy?: T;
|
|
93
|
+
rel?: "stylesheet" | "icon" | "manifest" | T;
|
|
94
|
+
sizes?: T;
|
|
95
|
+
title?: T;
|
|
96
|
+
type?: T;
|
|
97
|
+
as?: T;
|
|
98
|
+
crossorigin?: T;
|
|
99
|
+
};
|
|
100
|
+
type impmap = {
|
|
101
|
+
imports?: obj<string>;
|
|
102
|
+
scopes?: obj<string>;
|
|
103
|
+
integrity?: obj<string>;
|
|
104
|
+
};
|
|
105
|
+
type script<T> = {
|
|
106
|
+
async?: T;
|
|
107
|
+
crossorigin?: T;
|
|
108
|
+
defer?: T;
|
|
109
|
+
integrity?: T;
|
|
110
|
+
nomodule?: T;
|
|
111
|
+
referrerpolicy?: T;
|
|
112
|
+
src?: T;
|
|
113
|
+
type?: "text/javascript" | T;
|
|
114
|
+
id?: T;
|
|
115
|
+
importmap?: impmap;
|
|
116
|
+
body?: T;
|
|
117
|
+
};
|
|
118
|
+
type base<T> = {
|
|
119
|
+
href?: T;
|
|
120
|
+
target?: "_blank" | "_parent" | "_self" | "_top";
|
|
121
|
+
};
|
|
122
|
+
interface headAttr {
|
|
123
|
+
title?: string;
|
|
124
|
+
base?: base<string>[];
|
|
125
|
+
meta?: meta<string>[] | Meta;
|
|
126
|
+
link?: link<string>[];
|
|
127
|
+
script?: script<string | boolean>[];
|
|
128
|
+
}
|
|
129
|
+
declare class head implements headAttr {
|
|
130
|
+
title?: string;
|
|
131
|
+
description?: string;
|
|
132
|
+
base?: base<string>[];
|
|
133
|
+
meta?: meta<string>[] | Meta;
|
|
134
|
+
link?: link<string>[];
|
|
135
|
+
script?: script<string | boolean>[];
|
|
136
|
+
css?: string[];
|
|
137
|
+
}
|
|
138
|
+
type CSSinT$1 = {
|
|
139
|
+
[P in keyof CSSStyleDeclaration]?: V;
|
|
140
|
+
} & {
|
|
141
|
+
[key: string]: V;
|
|
142
|
+
};
|
|
143
|
+
type headType = Mapper<keyof head, any>;
|
|
144
|
+
declare class htmlHead {
|
|
145
|
+
lang: string;
|
|
146
|
+
htmlHead: headType;
|
|
147
|
+
head: (heads?: headAttr) => void;
|
|
148
|
+
constructor();
|
|
149
|
+
}
|
|
150
|
+
declare const cssLoader: (vv: link<string>) => Promise<unknown> | undefined;
|
|
151
|
+
declare function addCSS(selector: string, rules?: CSSinT$1): void;
|
|
152
|
+
|
|
153
|
+
declare class MinStorage {
|
|
154
|
+
readonly path: string;
|
|
155
|
+
readonly parsed: string[];
|
|
156
|
+
readonly args: string[];
|
|
157
|
+
constructor(path: string);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** --------------------
|
|
161
|
+
* string | int | float | file | uuid
|
|
162
|
+
* - /path/\<string:hell>
|
|
163
|
+
*/
|
|
164
|
+
declare class Storage$1<T extends MinStorage> {
|
|
165
|
+
private _storage;
|
|
166
|
+
set(min: T): void;
|
|
167
|
+
get(path: string): [T | undefined, Record<string, string>];
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
declare class __ {
|
|
171
|
+
static rand(min?: number, max?: number): number;
|
|
172
|
+
static fill(count: number, fill?: any): any[];
|
|
173
|
+
static new({ dom, id, inner, }: {
|
|
174
|
+
dom: keyof HTMLElementTagNameMap;
|
|
175
|
+
id?: string;
|
|
176
|
+
inner?: any;
|
|
177
|
+
}): HTMLElement;
|
|
178
|
+
static randFrom(arr: any[] | Object): any;
|
|
179
|
+
static makeID: (length: number) => string;
|
|
180
|
+
static reClass: (a: obj<any>, classes: string[]) => any[];
|
|
181
|
+
static get O(): {
|
|
182
|
+
vals: {
|
|
183
|
+
<T>(o: {
|
|
184
|
+
[s: string]: T;
|
|
185
|
+
} | ArrayLike<T>): T[];
|
|
186
|
+
(o: {}): any[];
|
|
187
|
+
};
|
|
188
|
+
keys: {
|
|
189
|
+
(o: object): string[];
|
|
190
|
+
(o: {}): string[];
|
|
191
|
+
};
|
|
192
|
+
items: {
|
|
193
|
+
<T>(o: {
|
|
194
|
+
[s: string]: T;
|
|
195
|
+
} | ArrayLike<T>): [string, T][];
|
|
196
|
+
(o: {}): [string, any][];
|
|
197
|
+
};
|
|
198
|
+
has: (o: object, v: PropertyKey) => boolean;
|
|
199
|
+
ass: {
|
|
200
|
+
<T extends {}, U>(target: T, source: U): T & U;
|
|
201
|
+
<T extends {}, U, V>(target: T, source1: U, source2: V): T & U & V;
|
|
202
|
+
<T extends {}, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
|
|
203
|
+
(target: object, ...sources: any[]): any;
|
|
204
|
+
};
|
|
205
|
+
len: (obj?: {}) => number;
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
declare class CATT {
|
|
210
|
+
xid: string;
|
|
211
|
+
IDM: idm;
|
|
212
|
+
map: Mapper<string, string[]>;
|
|
213
|
+
states: ((id: string) => () => void)[];
|
|
214
|
+
events: Mapper<string, (...arg: any) => any>;
|
|
215
|
+
OZ: OZ;
|
|
216
|
+
constructor(xid: string, IDM?: idm, _OZ?: OZ);
|
|
217
|
+
attr_push(key: string, val: any, pre?: string): void;
|
|
218
|
+
get attr(): string;
|
|
219
|
+
set id(id: string);
|
|
220
|
+
get id(): string | undefined;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
declare class OZ {
|
|
224
|
+
private events;
|
|
225
|
+
private states;
|
|
226
|
+
private winStates;
|
|
227
|
+
private windowEvents;
|
|
228
|
+
private resetST;
|
|
229
|
+
private resetEV;
|
|
230
|
+
constructor();
|
|
231
|
+
get keys(): string[];
|
|
232
|
+
set(catt: CATT): this;
|
|
233
|
+
push(_OZ: this): this;
|
|
234
|
+
get stage(): this;
|
|
235
|
+
get processWindowEvents(): this;
|
|
236
|
+
reset(id: string[]): this;
|
|
237
|
+
RPS(oz?: this): this;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
declare class CTX {
|
|
241
|
+
tag: string;
|
|
242
|
+
ctx: ctx[];
|
|
243
|
+
closing: string;
|
|
244
|
+
constructor(tag: string, ctx: ctx[]);
|
|
245
|
+
private process;
|
|
246
|
+
get(catt: CATT): string;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
declare class eStream {
|
|
250
|
+
stream: EventSource;
|
|
251
|
+
url: string;
|
|
252
|
+
constructor(eurl: string, withCredentials: boolean);
|
|
253
|
+
on(event: obj<(a: MessageEvent) => void>): this;
|
|
254
|
+
}
|
|
255
|
+
declare function eventStream(url: string, withCredentials?: boolean): eStream;
|
|
256
|
+
|
|
257
|
+
declare class __I {
|
|
258
|
+
value: any;
|
|
259
|
+
constructor(value: any);
|
|
260
|
+
get str(): string | null;
|
|
261
|
+
get int(): number | null;
|
|
262
|
+
get float(): number | null;
|
|
263
|
+
get bool(): boolean | null;
|
|
264
|
+
get json(): any | null;
|
|
265
|
+
}
|
|
266
|
+
declare class storageInterface {
|
|
267
|
+
key: string;
|
|
268
|
+
func: (() => any) | null;
|
|
269
|
+
storage: Storage;
|
|
270
|
+
constructor(item: obj<() => any> | string, _type?: "local" | "session");
|
|
271
|
+
get as(): __I;
|
|
272
|
+
get value(): string | null;
|
|
273
|
+
get save(): void;
|
|
274
|
+
set set(val: any);
|
|
275
|
+
get remove(): void;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Local Storage
|
|
280
|
+
*/
|
|
281
|
+
declare const local: {
|
|
282
|
+
get: (item: obj<() => any> | string) => storageInterface;
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Session Storage
|
|
287
|
+
*/
|
|
288
|
+
declare const session: {
|
|
289
|
+
get: (item: obj<() => any> | string) => storageInterface;
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
declare class doc<T = Record<string, string>> extends head {
|
|
293
|
+
path: string;
|
|
294
|
+
args: T;
|
|
295
|
+
id: string;
|
|
296
|
+
status: number;
|
|
297
|
+
lang?: string;
|
|
298
|
+
import?: any;
|
|
299
|
+
_data: T;
|
|
300
|
+
constructor(path: string, args: T | undefined, id: string, status?: number);
|
|
301
|
+
fetch?(): Promise<Record<string, string>>;
|
|
302
|
+
head(): Promise<void> | void;
|
|
303
|
+
body(): Promise<Dom> | Dom;
|
|
304
|
+
loader(): Promise<any[]>;
|
|
305
|
+
getHeadAttr(head?: headAttr, ...toMap: headType[]): headType;
|
|
306
|
+
set data(data: obj<any>);
|
|
307
|
+
get data(): T;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
declare class websocket<T = Record<string, string>> {
|
|
311
|
+
path: string;
|
|
312
|
+
args: T;
|
|
313
|
+
ws: WebSocket;
|
|
314
|
+
isConnected: Stateful<boolean>;
|
|
315
|
+
data: T;
|
|
316
|
+
constructor(path: string, args?: T);
|
|
317
|
+
open(event: Event): Promise<void> | void;
|
|
318
|
+
message(event: MessageEvent): Promise<void> | void;
|
|
319
|
+
close(event: CloseEvent): Promise<void> | void;
|
|
320
|
+
error(event: Event): Promise<void> | void;
|
|
321
|
+
get connect(): this;
|
|
322
|
+
get reconnect(): this;
|
|
323
|
+
get disconnect(): this;
|
|
324
|
+
/**
|
|
325
|
+
* code:
|
|
326
|
+
* * 0 - CONNECTING: The connection is being established.
|
|
327
|
+
* * 1 - OPEN: The connection is open and ready to communicate.
|
|
328
|
+
* * 2 - CLOSING: The connection is in the process of closing.
|
|
329
|
+
* * 3 - CLOSED: The connection has been closed or could not be opened.
|
|
330
|
+
*/
|
|
331
|
+
get state(): number;
|
|
332
|
+
set send(message: string | ArrayBufferLike | Blob | ArrayBufferView);
|
|
333
|
+
}
|
|
334
|
+
declare class socket {
|
|
335
|
+
private yra;
|
|
336
|
+
constructor(yra: Router);
|
|
337
|
+
load(_path: string): Promise<websocket<{}> | undefined>;
|
|
338
|
+
unload(_path: string): void;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
interface yraCfg {
|
|
342
|
+
pushState?: boolean;
|
|
343
|
+
classes?: string | string[];
|
|
344
|
+
}
|
|
345
|
+
declare class Router extends minClient {
|
|
346
|
+
hook?: () => void;
|
|
347
|
+
id: string;
|
|
348
|
+
root: Stateful<ctx[]>;
|
|
349
|
+
path: Stateful<string>;
|
|
350
|
+
socket: socket;
|
|
351
|
+
element: Stateful<HTMLElement | null>;
|
|
352
|
+
A: (a: attr & {
|
|
353
|
+
href: string;
|
|
354
|
+
}, ...D: ctx[]) => Dom;
|
|
355
|
+
Main: (a: attr & {
|
|
356
|
+
render?: string;
|
|
357
|
+
}) => Dom;
|
|
358
|
+
load: (path?: string, data?: obj<string>) => Promise<this>;
|
|
359
|
+
constructor(ImportMeta: ImportMeta, config: yraCfg, isYRA?: boolean);
|
|
360
|
+
hooker(): void;
|
|
361
|
+
class(this: Router, _path: string, _error: number, isError?: boolean): Promise<doc<{}>>;
|
|
362
|
+
render(_path: string, _error?: number, data?: obj<string>): Promise<{
|
|
363
|
+
done: boolean;
|
|
364
|
+
}>;
|
|
365
|
+
fetch(CL?: doc<{}>): Promise<void>;
|
|
366
|
+
}
|
|
367
|
+
declare class Yve extends Router {
|
|
368
|
+
constructor(ImportMeta: ImportMeta, { classes, pushState }: yraCfg);
|
|
369
|
+
processHead(CL?: doc<{}>, head?: headAttr): Promise<headType>;
|
|
370
|
+
private processClassHead;
|
|
371
|
+
private processDefaultHead;
|
|
372
|
+
render(_path?: string, _error?: number, data?: obj<string>, head?: headAttr, isClient?: boolean, isError?: boolean): Promise<{
|
|
373
|
+
lang: string;
|
|
374
|
+
heads: headType;
|
|
375
|
+
done: boolean;
|
|
376
|
+
}>;
|
|
377
|
+
html(path: string, data?: obj<string>, status?: number): Promise<string>;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
declare class ClientPath extends MinStorage {
|
|
381
|
+
id: string;
|
|
382
|
+
cls: typeof doc<{}>;
|
|
383
|
+
constructor(path: string, id: string, cls: typeof doc<{}>);
|
|
384
|
+
}
|
|
385
|
+
declare class SocketPath extends MinStorage {
|
|
386
|
+
id: string;
|
|
387
|
+
cls: typeof websocket<{}>;
|
|
388
|
+
constructor(path: string, id: string, cls: typeof websocket<{}>);
|
|
389
|
+
}
|
|
390
|
+
declare class minClient extends htmlHead {
|
|
391
|
+
ImportMeta: ImportMeta;
|
|
392
|
+
config: yraCfg;
|
|
393
|
+
storage: Storage$1<ClientPath>;
|
|
394
|
+
errorStorage: Storage$1<ClientPath>;
|
|
395
|
+
wssStorage: Storage$1<SocketPath>;
|
|
396
|
+
/** --------------------
|
|
397
|
+
* string | int | float | file | uuid
|
|
398
|
+
* - /url/\<string:hell>
|
|
399
|
+
*/
|
|
400
|
+
route: (path: string) => <Q extends typeof doc<{}>>(f: Q) => Q;
|
|
401
|
+
error: (...codes: number[]) => <Q extends typeof doc<{}>>(f: Q) => Q;
|
|
402
|
+
wss: (path: string) => <Q extends typeof websocket<{}>>(f: Q) => Q;
|
|
403
|
+
constructor(ImportMeta: ImportMeta, config: yraCfg);
|
|
404
|
+
getPath(path: string): Promise<[ClientPath | undefined, Record<string, string>]>;
|
|
405
|
+
loadError(code: number): Promise<[ClientPath | undefined, Record<string, string>]>;
|
|
406
|
+
loadWSS(path: string): Promise<[SocketPath | undefined, Record<string, string>]>;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
type Elements = HTMLElementTagNameMap[keyof HTMLElementTagNameMap];
|
|
410
|
+
|
|
411
|
+
type hookFN<T extends any[]> = (...args: statefulValue<T>) => void;
|
|
412
|
+
interface stateCFG {
|
|
413
|
+
id?: string;
|
|
414
|
+
init?: boolean;
|
|
415
|
+
}
|
|
416
|
+
declare function stateHook<T extends any[]>(callback: hookFN<T>, statefuls: [...{
|
|
417
|
+
[K in keyof T]: Stateful<T[K]>;
|
|
418
|
+
}], { id, init }?: stateCFG): () => void;
|
|
419
|
+
|
|
420
|
+
type statefulValue<T extends any[]> = {
|
|
421
|
+
[K in keyof T]: T[K] extends Stateful<infer U> ? U : T[K];
|
|
422
|
+
};
|
|
423
|
+
declare class Stateful<T> extends EventTarget {
|
|
424
|
+
private options?;
|
|
425
|
+
private hooks;
|
|
426
|
+
private states;
|
|
427
|
+
private _value;
|
|
428
|
+
private listening;
|
|
429
|
+
private end?;
|
|
430
|
+
constructor(value: T, options?: AddEventListenerOptions | undefined);
|
|
431
|
+
get value(): T;
|
|
432
|
+
set value(newValue: T);
|
|
433
|
+
get listen(): () => void;
|
|
434
|
+
call<Q>(callback: (this: Elements, arg: T) => Q, entry: string): (id: string) => () => void;
|
|
435
|
+
hook<T extends any[]>(callback: hookFN<T>): (id: string) => () => void;
|
|
436
|
+
}
|
|
437
|
+
declare function State<T>(value: T): Stateful<T>;
|
|
438
|
+
|
|
439
|
+
type X2 = V | V[];
|
|
440
|
+
type ctx = V | Dom | Stateful<V | Dom> | ctx[];
|
|
441
|
+
type X3 = X2 | Stateful<X2>;
|
|
442
|
+
type CSSinT = {
|
|
443
|
+
[P in keyof CSSStyleDeclaration]?: X3;
|
|
444
|
+
} & {
|
|
445
|
+
[key: string]: X3;
|
|
446
|
+
};
|
|
447
|
+
interface c_events {
|
|
448
|
+
watch?: (this: Elements, e: Elements) => [(...args: any[]) => void, Stateful<any> | Stateful<any>[], boolean?];
|
|
449
|
+
ready?: (this: Elements, e: Elements) => void;
|
|
450
|
+
resize?: (this: Elements, e: UIEvent) => void;
|
|
451
|
+
beforeunload?: (this: Elements, e: BeforeUnloadEvent) => void;
|
|
452
|
+
popstate?: (this: Elements, e: PopStateEvent) => void;
|
|
453
|
+
winscroll?: (this: Elements, e: Event) => void;
|
|
454
|
+
winload?: (this: Elements, e: Event) => void;
|
|
455
|
+
winfocus?: (this: Elements, e: Event) => void;
|
|
456
|
+
winblur?: (this: Elements, e: Event) => void;
|
|
457
|
+
}
|
|
458
|
+
interface baseAttr {
|
|
459
|
+
style?: CSSinT;
|
|
460
|
+
on?: events;
|
|
461
|
+
id?: string;
|
|
462
|
+
class?: X3;
|
|
463
|
+
}
|
|
464
|
+
declare class Dom {
|
|
465
|
+
tag: string;
|
|
466
|
+
private attr;
|
|
467
|
+
ctx: CTX;
|
|
468
|
+
constructor(tag: string, attr?: attr, ...ctx: ctx[]);
|
|
469
|
+
__(pid?: idm): {
|
|
470
|
+
ctx: string;
|
|
471
|
+
oz: OZ;
|
|
472
|
+
id: string | undefined;
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
declare function dom(tag: string | ((attr: attr, ...ctx: ctx[]) => Dom), attr?: attr | null, ...ctx: ctx[]): Dom;
|
|
476
|
+
declare const frag: (attr: attr, ...dom: Dom[]) => Dom[];
|
|
477
|
+
|
|
478
|
+
type kf = KeyframeAnimationOptions;
|
|
479
|
+
type KFType = (CSSinT | obj<V>)[] | CSSinT | obj<V>;
|
|
480
|
+
declare class anim {
|
|
481
|
+
private e;
|
|
482
|
+
opt: kf;
|
|
483
|
+
constructor(e: Elem);
|
|
484
|
+
animate(keyframes: CSSinT[] | CSSinT, options?: kf): Elem<HTMLElement>;
|
|
485
|
+
get slide(): {
|
|
486
|
+
left: (options?: kf) => anim;
|
|
487
|
+
right: (options?: kf) => anim;
|
|
488
|
+
up: (options?: kf) => anim;
|
|
489
|
+
down: (options?: kf) => anim;
|
|
490
|
+
};
|
|
491
|
+
fade(options?: kf): this;
|
|
492
|
+
shake(XorY?: string, opt?: kf): this;
|
|
493
|
+
color(c?: string[], opt?: kf): this;
|
|
494
|
+
bg(c?: string | string[], opt?: kf): this;
|
|
495
|
+
bounce(sVal?: number, opt?: kf): this;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
declare class Eget<T extends TElem = HTMLElement> {
|
|
499
|
+
e: T;
|
|
500
|
+
query?: string | undefined;
|
|
501
|
+
constructor(e: T, query?: string | undefined);
|
|
502
|
+
get a(): anim;
|
|
503
|
+
get all(): T[];
|
|
504
|
+
get attr(): {
|
|
505
|
+
has: (attr: string) => boolean;
|
|
506
|
+
get: (attr: string) => string | null;
|
|
507
|
+
del: (attr: string) => Eget;
|
|
508
|
+
set: (attrs: obj<any>) => Eget;
|
|
509
|
+
};
|
|
510
|
+
get children(): Elem<T>[];
|
|
511
|
+
get click(): this;
|
|
512
|
+
get delete(): this;
|
|
513
|
+
get disabled(): boolean;
|
|
514
|
+
get focus(): this;
|
|
515
|
+
get href(): string;
|
|
516
|
+
get id(): string;
|
|
517
|
+
get inner(): string;
|
|
518
|
+
get offsetParent(): Elem | undefined;
|
|
519
|
+
get parent(): Elem | undefined;
|
|
520
|
+
get path(): string;
|
|
521
|
+
get rect(): DOMRect;
|
|
522
|
+
get remove_element(): this;
|
|
523
|
+
get style(): {
|
|
524
|
+
set: (style: CSSinT | obj<V | null>, delayOrFN?: number | ((e?: any) => void)) => Elem<HTMLElement>;
|
|
525
|
+
get: (prop: keyof CSSStyleDeclaration | string) => string;
|
|
526
|
+
del: (...props: (keyof CSSStyleDeclaration | string)[]) => void;
|
|
527
|
+
};
|
|
528
|
+
get submit(): any;
|
|
529
|
+
get tag(): string;
|
|
530
|
+
get value(): any;
|
|
531
|
+
get unload(): () => void;
|
|
532
|
+
set append(val: any);
|
|
533
|
+
set appendfirst(val: any);
|
|
534
|
+
set inner(val: any);
|
|
535
|
+
set disabled(vl: boolean);
|
|
536
|
+
set id(did: string);
|
|
537
|
+
set value(vl: any);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
type TElem = HTMLElement & InstanceType<typeof Element>;
|
|
541
|
+
type fn<E, T> = (e?: E) => T;
|
|
542
|
+
declare class Elem<T extends TElem = HTMLElement> extends Eget {
|
|
543
|
+
constructor(e: T, query?: string);
|
|
544
|
+
add(...className: string[]): this;
|
|
545
|
+
remove(...className: string[]): this;
|
|
546
|
+
toggle(className: string | fn<any, string>, force?: boolean): this;
|
|
547
|
+
has(e: any | null): boolean;
|
|
548
|
+
insert(position: InsertPosition): {
|
|
549
|
+
HTML: (...text: string[]) => Elem;
|
|
550
|
+
element: (...elem: HTMLElement[]) => Elem;
|
|
551
|
+
text: (this: Elem, ...text: string[]) => Elem;
|
|
552
|
+
};
|
|
553
|
+
is(tp: {
|
|
554
|
+
dom?: string;
|
|
555
|
+
class?: string | string[];
|
|
556
|
+
}): boolean;
|
|
557
|
+
on(event: keyof events, handler: (e?: any) => void, useCapture?: boolean): this;
|
|
558
|
+
remove_on(event: keyof DocumentEventMap, handler: EventListenerOrEventListenerObject, useCapture?: boolean): this;
|
|
559
|
+
timed(fn: (ee?: Elem) => void, timeout?: number): this;
|
|
560
|
+
animate(keyframes: KFType, options?: kf, onComplete?: fn<any, void>): this;
|
|
561
|
+
animate(keyframes: KFType, onComplete?: fn<any, void>): this;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
declare function $<T extends TElem = HTMLElement>(query: string): Elem<T> | undefined;
|
|
565
|
+
declare function $<T extends TElem = HTMLElement>(element: T): Elem<T>;
|
|
566
|
+
type _$ = Elem | undefined;
|
|
567
|
+
|
|
568
|
+
declare class ColorScheme {
|
|
569
|
+
state: Stateful<boolean>;
|
|
570
|
+
body?: HTMLElement;
|
|
571
|
+
click: () => void;
|
|
572
|
+
constructor({ toggle, initialState, }?: {
|
|
573
|
+
toggle?: string[];
|
|
574
|
+
initialState?: boolean;
|
|
575
|
+
});
|
|
576
|
+
private loader;
|
|
577
|
+
get isMatchMediaSupported(): boolean;
|
|
578
|
+
get isDark(): boolean;
|
|
579
|
+
toggle(clist: DOMTokenList, isDark: boolean, toggles: string[]): void;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
declare global {
|
|
583
|
+
type events = {
|
|
584
|
+
[P in keyof GlobalEventHandlersEventMap]?: (this: Elements, e: GlobalEventHandlersEventMap[P]) => void;
|
|
585
|
+
} & c_events;
|
|
586
|
+
type attr = baseAttr | obj<X3>;
|
|
587
|
+
type obj<T> = Record<string, T>;
|
|
588
|
+
type DomFN<T extends {}> = (a: attr & T, ...D: ctx[]) => Dom;
|
|
589
|
+
namespace JSX {
|
|
590
|
+
type Element = Dom;
|
|
591
|
+
interface IntrinsicElements {
|
|
592
|
+
p: attr;
|
|
593
|
+
br: attr;
|
|
594
|
+
hr: attr;
|
|
595
|
+
h: attr;
|
|
596
|
+
cmnt: attr;
|
|
597
|
+
root: attr;
|
|
598
|
+
html: attr;
|
|
599
|
+
body: attr;
|
|
600
|
+
div: attr;
|
|
601
|
+
span: attr;
|
|
602
|
+
header: attr;
|
|
603
|
+
hgroup: attr;
|
|
604
|
+
footer: attr;
|
|
605
|
+
main: attr;
|
|
606
|
+
section: attr;
|
|
607
|
+
search: attr;
|
|
608
|
+
article: attr;
|
|
609
|
+
aside: attr;
|
|
610
|
+
details: attr;
|
|
611
|
+
dialog: attr;
|
|
612
|
+
summary: attr;
|
|
613
|
+
data: attr;
|
|
614
|
+
noscript: attr;
|
|
615
|
+
object: attr;
|
|
616
|
+
param: attr;
|
|
617
|
+
script: attr;
|
|
618
|
+
a: attr;
|
|
619
|
+
nav: attr;
|
|
620
|
+
style: attr;
|
|
621
|
+
audio: attr;
|
|
622
|
+
video: attr;
|
|
623
|
+
source: attr;
|
|
624
|
+
track: attr;
|
|
625
|
+
img: attr;
|
|
626
|
+
map: attr;
|
|
627
|
+
area: attr;
|
|
628
|
+
canvas: attr;
|
|
629
|
+
figcaption: attr;
|
|
630
|
+
figure: attr;
|
|
631
|
+
picture: attr;
|
|
632
|
+
iframe: attr;
|
|
633
|
+
form: attr;
|
|
634
|
+
input: attr;
|
|
635
|
+
textarea: attr;
|
|
636
|
+
button: attr;
|
|
637
|
+
select: attr;
|
|
638
|
+
optgroup: attr;
|
|
639
|
+
option: attr;
|
|
640
|
+
label: attr;
|
|
641
|
+
fieldset: attr;
|
|
642
|
+
legend: attr;
|
|
643
|
+
datalist: attr;
|
|
644
|
+
table: attr;
|
|
645
|
+
caption: attr;
|
|
646
|
+
th: attr;
|
|
647
|
+
tr: attr;
|
|
648
|
+
td: attr;
|
|
649
|
+
thead: attr;
|
|
650
|
+
tbody: attr;
|
|
651
|
+
tfoot: attr;
|
|
652
|
+
col: attr;
|
|
653
|
+
colgroup: attr;
|
|
654
|
+
b: attr;
|
|
655
|
+
i: attr;
|
|
656
|
+
q: attr;
|
|
657
|
+
s: attr;
|
|
658
|
+
u: attr;
|
|
659
|
+
em: attr;
|
|
660
|
+
rp: attr;
|
|
661
|
+
del: attr;
|
|
662
|
+
dfn: attr;
|
|
663
|
+
ins: attr;
|
|
664
|
+
kbd: attr;
|
|
665
|
+
pre: attr;
|
|
666
|
+
sub: attr;
|
|
667
|
+
sup: attr;
|
|
668
|
+
var: attr;
|
|
669
|
+
wbr: attr;
|
|
670
|
+
cite: attr;
|
|
671
|
+
time: attr;
|
|
672
|
+
abbr: attr;
|
|
673
|
+
code: attr;
|
|
674
|
+
mark: attr;
|
|
675
|
+
samp: attr;
|
|
676
|
+
meter: attr;
|
|
677
|
+
small: attr;
|
|
678
|
+
strong: attr;
|
|
679
|
+
address: attr;
|
|
680
|
+
progress: attr;
|
|
681
|
+
template: attr;
|
|
682
|
+
blockquote: attr;
|
|
683
|
+
menu: attr;
|
|
684
|
+
ul: attr;
|
|
685
|
+
ol: attr;
|
|
686
|
+
li: attr;
|
|
687
|
+
dl: attr;
|
|
688
|
+
dt: attr;
|
|
689
|
+
dd: attr;
|
|
690
|
+
h1: attr;
|
|
691
|
+
h2: attr;
|
|
692
|
+
h3: attr;
|
|
693
|
+
h4: attr;
|
|
694
|
+
h5: attr;
|
|
695
|
+
h6: attr;
|
|
696
|
+
svg: attr;
|
|
697
|
+
path: attr;
|
|
698
|
+
circle: attr;
|
|
699
|
+
animate: attr;
|
|
700
|
+
animateMotion: attr;
|
|
701
|
+
animateTransform: attr;
|
|
702
|
+
clipPath: attr;
|
|
703
|
+
defs: attr;
|
|
704
|
+
desc: attr;
|
|
705
|
+
ellipse: attr;
|
|
706
|
+
feBlend: attr;
|
|
707
|
+
feColorMatrix: attr;
|
|
708
|
+
feComponentTransfer: attr;
|
|
709
|
+
feComposite: attr;
|
|
710
|
+
feConvolveMatrix: attr;
|
|
711
|
+
feDiffuseLighting: attr;
|
|
712
|
+
feDisplacementMap: attr;
|
|
713
|
+
feDistantLight: attr;
|
|
714
|
+
feDropShadow: attr;
|
|
715
|
+
feFlood: attr;
|
|
716
|
+
feFuncA: attr;
|
|
717
|
+
feFuncB: attr;
|
|
718
|
+
feFuncG: attr;
|
|
719
|
+
feFuncR: attr;
|
|
720
|
+
feGaussianBlur: attr;
|
|
721
|
+
feImage: attr;
|
|
722
|
+
feMerge: attr;
|
|
723
|
+
feMergeNode: attr;
|
|
724
|
+
feMorphology: attr;
|
|
725
|
+
feOffset: attr;
|
|
726
|
+
fePointLight: attr;
|
|
727
|
+
feSpecularLighting: attr;
|
|
728
|
+
feSpotLight: attr;
|
|
729
|
+
feTile: attr;
|
|
730
|
+
feTurbulence: attr;
|
|
731
|
+
filter: attr;
|
|
732
|
+
foreignObject: attr;
|
|
733
|
+
g: attr;
|
|
734
|
+
image: attr;
|
|
735
|
+
line: attr;
|
|
736
|
+
linearGradient: attr;
|
|
737
|
+
marker: attr;
|
|
738
|
+
mask: attr;
|
|
739
|
+
metadata: attr;
|
|
740
|
+
mpath: attr;
|
|
741
|
+
pattern: attr;
|
|
742
|
+
polygon: attr;
|
|
743
|
+
polyline: attr;
|
|
744
|
+
radialGradient: attr;
|
|
745
|
+
rect: attr;
|
|
746
|
+
set: attr;
|
|
747
|
+
stop: attr;
|
|
748
|
+
symbol: attr;
|
|
749
|
+
text: attr;
|
|
750
|
+
textPath: attr;
|
|
751
|
+
title: attr;
|
|
752
|
+
tspan: attr;
|
|
753
|
+
use: attr;
|
|
754
|
+
view: attr;
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
declare const resolvePath: (base: string, relative: string) => string;
|
|
759
|
+
|
|
760
|
+
export { $, $$, ColorScheme, Dom, Meta, Router, State, Stateful, Yve, type _$, __, addCSS, cssLoader, type ctx, doc, dom, eventStream, frag, local, minClient, resolvePath, session, stateHook, websocket };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var Sn=function(n,t,r,i){var o=arguments.length,s=o<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,r):i,e;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")s=Reflect.decorate(n,t,r,i);else for(var u=n.length-1;u>=0;u--)if(e=n[u])s=(o<3?e(s):o>3?e(t,r,s):e(t,r))||s;return o>3&&s&&Object.defineProperty(t,r,s),s};var An=(n,t)=>{if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(n,t)};var p=(n)=>typeof n==="function";var U=(n)=>{return!isNaN(parseFloat(n))&&isFinite(n)},ln=(n)=>{return typeof n==="object"&&n!==null&&!Array.isArray(n)},k=(n)=>{return typeof n==="object"&&n!==null&&Object.getPrototypeOf(n)===Object.prototype};var v=(n)=>typeof n==="boolean",nn=(n)=>typeof n==="string",g=(n)=>Array.isArray(n),F=(n)=>typeof n==="object",Dn=(n)=>typeof n==="number",P=(n)=>n===null,Gn=(n)=>typeof n==="undefined",Kn=(n)=>{return Number.isInteger(Number(n))},Tn=typeof window!=="undefined",b=typeof window==="undefined";function tn(n,t){m(t).forEach(([r,i])=>{Mn(n,r,{value:i,writable:!1,configurable:!1,enumerable:!0})})}class K{static set p(n){if(Array.isArray(n))console.log(...n);else console.log(n)}}class c{_c=0;_id="";constructor(n){if(this._c=0,this._id=n??y(5),n?.includes("-")){let[t,r]=[n.split("-").slice(0,-1).join("-"),n.split("-").slice(-1)[0]];this._id=t,this._c=U(r)?parseInt(r):0}}get id(){return this._id+"-"+this._c}get mid(){return this._id+"-"+ ++this._c}}var Ot=new RegExp(/(\d+)(\d*)/,"m"),gt=(n)=>Array.from({length:n},(t,r)=>r),lt="ABCDEFGHIJKLMNOPQRSTUVWXYZ",Tt="abcdefghijklmnopqrstuvwxyz",ht=gt(10).join("");var j=(n)=>JSON.stringify(n),In=(n)=>{return JSON.parse(n)},B=(n)=>{if(n.startsWith("webkit"))n="-"+n;return n.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()},y=(n)=>{let t=lt+Tt;return Array.from({length:n},(r,i)=>t+(i?ht:"")).reduce((r,i)=>{return r+=i.charAt(Math.floor(Math.random()*i.length))},"")};class f extends Map{obj(n){n&&m(n).forEach(([t,r])=>this.set(t,r))}map(n){n.forEach((t,r)=>{if(t instanceof f)this.set(r,t);else if(g(t)){if(this.lacks(r))this.set(r,[]);this.get(r).push(...t)}else if(F(t))this.ass(r,t);else this.set(r,t)})}ass(n,t){if(!this.has(n))this.set(n,{});x(this.get(n),t)}lacks(n){return!this.has(n)}init(n,t){return this.has(n)?this.get(n):this.set(n,t).get(n)}}var{values:$,keys:M,entries:m}=Object;var{hasOwn:wn,freeze:Wn,defineProperty:Mn,assign:x}=Object,q=(n)=>{return Object.keys(n).length},rn=(n,t)=>{if(!t.has(n))t.set(n,new f);return t.get(n)},R=(n,t)=>{if(!t.has(n))t.set(n,[]);return t.get(n)},hn=(n,t)=>{let r={added:{},removed:{},modified:{}},i=M(n),o=M(t);for(let s of o){let e=n[s],u=t[s];if(!(s in n))r.added[s]=u;else if(g(e)&&g(u)){if(j(e)!==j(u))r.modified[s]={old:e,new:u}}else if(F(e)&&F(u)&&!P(e)&&!P(u)){let T=hn(e,u);if(q(T.added)||q(T.removed)||q(T.modified))r.modified[s]={old:e,new:u}}else if(e!==u)r.modified[s]={old:e,new:u}}for(let s of i)if(!(s in t))r.removed[s]=n[s];return r};function zn(n,t){if(n.size!==t.size)return!1;for(let r of n)if(!t.has(r))return!1;return!0}var Nn=(n)=>{return $(n).some((t)=>{return q(t)})};function Pn(n){let t;return class extends n{constructor(...r){if(t)return t;super(...r);Wn(this),t=this}}}var S=(n,t)=>{return{name:n,content:t}},bt=(n,t)=>{return{property:n,content:t}},ct=(n,t)=>{return{"http-equiv":n,content:t}};class on{metas=[];constructor(n){n&&this.metas.push(S("description",n))}author(n){return this.meta=S("author",n),this}charset(n){return this.meta={charset:n},this}keywords(...n){return this.meta=S("keywords",n.join(", ")),this}viewport(n){let t=m(n).map(([r,i])=>[B(r),String(i)].join("="));return this.meta=S("viewport",t.join(", ")),this}httpEquiv(n){return m(n).forEach(([t,r])=>{this.meta=ct(B(t),String(r))}),this}robots(...n){return this.meta=S("robots",n.join(", ")),this}themeColor(n){return this.meta=S("theme-color",n),this}openGraph(n){return m(n).forEach(([t,r])=>{this.meta=bt("og:"+t,String(r))}),this}twitter(n){return m(n).forEach(([t,r])=>{this.meta=S("twitter:"+t,String(r))}),this}and(n){return this}set meta(n){this.metas.push(n)}}class bn{title;description;base;meta;link;script;css}var yt=["charset","name","property","http-equiv"],Rn=(n,t)=>{t.forEach((r)=>{for(let i of yt)if(i in r){let o=r[i];n[`${i}_${i==="charset"?"":o}`]=r}})},xt=(n,t)=>{t.forEach((r)=>{if("href"in r){let i=r.href;n[`${i}`]=r}})};class I{_head;idm;constructor(n){this._head=new f(n)}set head(n){m(n).forEach(([t,r])=>{if(t==="title"||t==="base"){if(r!==void 0)this._head.set(t,r);return}if(r instanceof on)return Rn(this._head.init("meta",{}),r.metas);if(!g(r))return;switch(t){case"meta":return Rn(this._head.init("meta",{}),r);case"link":return xt(this._head.init("link",{}),r);case"script":if(r.length){this._head.init(t,[]);let i=r.map((o)=>{if(!o.yid&&this.idm)o.yid="sc"+this.idm.mid;return o});this._head.get(t).push(...i)}return}})}get head(){return this._head}set id(n){this.idm=new c(n)}}var Ln=(n)=>{return m(n).reduce((t,[r,i])=>{return t.push(v(i)&&i?r:`${r}="${i}"`),t},[""]).join(" ")},Vn=(n)=>{if(!n)return"";return[...n].reduce((t,[r,i])=>{if(r==="meta"||r==="link")i=$(i);if(nn(i))return t.push(`<${r}>${i}</${r}>`),t;if(!g(i))return t;let o=i.map((s)=>{if(r==="script"){let e={...s};if("yid"in e)return"";let u="";if("importmap"in e)e.type="importmap",u=JSON.stringify(e.importmap),delete e.importmap;else if("body"in e)u=e.body,delete e.body;return`<${r}${Ln(e)}>${u}</${r}>`}return`<${r}${Ln(s)}>`});return t.push(...o),t},[]).join("")};class cn{lang="en";htmlHead=new f;head;constructor(){this.head=(n={})=>{let t=new I(this.htmlHead);t.head=n,this.htmlHead=t.head}}}var yn=(n)=>{if(b)return;return new Promise((t,r)=>{let i=document.createElement("link");if(n.rel!=="stylesheet")n.rel="stylesheet",n.as="style";m(n).forEach(([o,s])=>{i.setAttribute(o,s)}),i.onload=()=>t(()=>{}),i.onerror=()=>r(new Error("Failed to load CSS")),document.head.appendChild(i)})},Et=()=>{let t=document.querySelector("#d-css")?.sheet;if(t)return t;let r=document.createElement("style");return r.id="d-css",document.head.appendChild(r),r.sheet},$t=(n,t)=>{for(let r=0;r<n.cssRules.length;r++)if(n.cssRules[r].selectorText===t)return!0;return!1},pt=(n)=>Object.entries(n).map(([t,r])=>`${B(t)}: ${r};`).join(" ");function jt(n,t={}){if(b)return;let r=Et();if(!r)return;if(!$t(r,n))r.insertRule(`${n} { ${pt(t)} }`,r.cssRules.length)}var dn=(n,t)=>{let r=t;if(n?.class)r.push(...g(n.class)?n.class:[n.class]);return delete n.class,r.filter((i)=>i)};var On=(n,t=!1)=>{if(U(n))return[+n,Kn(n)?"int":"float"];if(t&&/\.\w+$/.test(n))return[n,"file"];if(n==="/")return[n,"-"];if(n.length===36&&n.match(/\-/g)?.length===4)return[n,"uuid"];return[n,"string"]},sn=(n)=>{let t=n.startsWith("/")?n:"/"+n,r=t.match(/(?<=\/)[^/].*?(?=\/|$)/g)??["/"],[i,o]=r.reduce(([s,e],u)=>{if(u.includes("<")){let T=u.match(/(?<=<)[^/].*?(?=>|$)/g);if(T?.length){let[h,E]=T[0].split(":");if(h&&E)s.push(h),e.push(E)}}else s.push(u===">"?"/":u);return[s,e]},[[],[]]);if(t.endsWith("/")&&t.length>1)i.push("/");return{parsed:i,args:o}};class en{storage=new f;cache(n,t){if(this.storage.lacks(n))this.storage.set(n,t());return this.storage.get(n)}}var qt=["int","float","file","uuid","string"],Ft=new en;class w{_storage=new f;set(n){let{parsed:t,path:r}=n,i=j(t);if(!this._storage.get(i))this._storage.set(i,n);else throw`path: ${r} already used.`}get(n){let{parsed:t}=Ft.cache(n,()=>sn(n)),r={},i=this._storage.get(j(t));if(!i&&n!=="/")for(let o of this._storage.keys()){let s=[],e=In(o);if(t.length===e.length){let u=e.map((E,Y)=>{let Z=On(t[Y],t.length-1===Y);if(E===Z[0])return Z[0];if(qt.includes(Z[1]))return s.push(Z[0]),Z[1];return E}),T=j(u);if(this._storage.has(T)){i=this._storage.get(T),i?.args.forEach((E,Y)=>{r[E]=s[Y]});break}}}return[i,r]}}class L{path="";parsed=[];args=[];constructor(n){tn(this,{path:n,...sn(n)})}}class Cn{static rand(n=6,t){if(t)return Math.floor(Math.random()*(t-n+1)+n);return Math.floor(Math.random()*n)+1-1}static fill(n,t=null){return Array(n).fill(t)}static new({dom:n,id:t,inner:r}){let i=document.createElement(n);if(t)i.id=t;if(r)i.innerHTML=r;return i}static randFrom(n){if(Array.isArray(n)){let t=n.length,r=this.rand(0,t-1);return n[r]}else if(typeof n=="object"){let t=M(n),r=t.length,i=this.rand(0,r-1);return t[i]}}static makeID=y;static reClass=dn;static get O(){return{vals:$,keys:M,items:m,has:wn,ass:x,len:(n={})=>M(n).length}}}var xn={},A={};class _n{stream;url;constructor(n,t){if(this.url=n,n in xn)this.stream=xn[n];else this.stream=new EventSource(n,{withCredentials:t}),xn[n]=this.stream,A[this.url]={}}on(n){let t=this.stream;return m(n).forEach(([r,i])=>{if(r in A[this.url])A[this.url][r].forEach((o)=>{this.stream.removeEventListener(r,o)}),A[this.url][r]=[];if(t.addEventListener(r,i),!(r in A[this.url]))A[this.url][r]=[];A[this.url][r].push(i)}),this}}function an(n,t=!0){return new _n(n,t)}class kn{value;constructor(n){this.value=n}get str(){return String(this.value).toString()=="null"?null:String(this.value).toString()}get int(){if(U(this.value))return parseInt(this.value);else return null}get float(){if(U(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 V{key;func;storage;constructor(n,t="local"){if(typeof n=="object"){let[r,i]=m(n)[0];this.key=r,this.func=i}else this.key=n,this.func=null;this.storage=t=="local"?localStorage:sessionStorage}get as(){return new kn(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(n){if(typeof n=="object")this.storage.setItem(this.key,JSON.stringify(n));else this.storage.setItem(this.key,String(n))}get remove(){this.storage.removeItem(this.key);return}}var d={get:(n)=>new V(n)};var vn={get:(n)=>new V(n,"session")};class un extends L{id;cls;constructor(n,t,r){super(n);this.id=t;this.cls=r}}class nt extends L{id;cls;constructor(n,t,r){super(n);this.id=t;this.cls=r}}class fn extends cn{ImportMeta;config;storage=new w;errorStorage=new w;wssStorage=new w;route;error;wss;constructor(n,t){super();this.ImportMeta=n;this.config=t;this.route=(r)=>{return(i)=>{return this.storage.set(new un(r,y(5),i)),i}},this.wss=(r)=>{return(i)=>{return this.wssStorage.set(new nt(r,y(5),i)),i}},this.error=(...r)=>{return(i)=>{if(r.length)r.forEach((o)=>{this.errorStorage.set(new un(o.toString(),y(5),i))});else this.errorStorage.set(new un("404",y(5),i));return i}}}async getPath(n){return this.storage.get(n)}async loadError(n){return this.errorStorage.get(n.toString())}async loadWSS(n){return this.wssStorage.get(n)}}var O=new f,C=(n)=>{if(b)return;let t=O.get(n);if(t?.isConnected)return t;O.delete(n);let r=document.getElementById(n);if(!r)return;return O.set(n,r),r};function tt(){let n=[];return O.forEach((t,r)=>{if(!t.isConnected)n.push(r),O.delete(r)}),n}function W(n,t,{id:r="state",init:i}={}){let o=[],s=()=>t.map((u)=>u.value),e=()=>{n(...s())};if(t.forEach((u)=>{o.push(u.hook(e)(r))}),i)e();return()=>{o.forEach((u)=>u())}}var rt=(n)=>{n.forEach((t)=>t())};var Zt=(n,t)=>{for(let[r,i]of n){let o=C(r);if(!o){n.delete(r);continue}i.forEach((s)=>{s.call(o,t)})}};class D extends EventTarget{options;hooks=new f;states=new f;_value;listening=!1;end;constructor(n,t){super();this.options=t;this._value=n}get value(){return this._value}set value(n){if(P(n)||Gn(n))return;if(k(this._value)||g(this._value)){let t=hn(this._value,n);if(!Nn(t))return}else if(this._value instanceof Set){if(!zn(this._value,n))return}else if(this._value===n)return;this._value=n,this.dispatchEvent(new CustomEvent("updated",{detail:this._value}))}get listen(){let n=(t)=>{if(rt(this.hooks),Zt(this.states,t.detail),!this.states.size&&!this.hooks.size)this.end?.()};if(!this.listening)this.addEventListener("updated",n,this.options),this.listening=!0;return()=>{this.listening&&this.removeEventListener("updated",n,this.options),this.end=void 0,this.listening=!1}}call(n,t){return(r)=>{if(rn(r,this.states).set(t,n),!b&&!this.listening)this.end=this.listen;return()=>{if(this.states.has(r))this.states.get(r)?.delete(t)}}}hook(n){return(t)=>{if(this.hooks.set(t,n),!b&&!this.listening)this.end=this.listen;return()=>{if(this.hooks.has(t))this.hooks.delete(t)}}}}function H(n){return new D(n)}var En=(n)=>{if(g(n))return n.join(" ");else if(F(n)){if(ln(n))return j(n)}else if(p(n))return En(n());else if(n!==void 0&&n!==null)return v(n)?n?"":"false":String(n);return""};function Ht(n,t){switch(t??n){case"style":return function(r){this.style.setProperty(n,r)};default:return function(r){this.setAttribute(n,r)}}}class $n{attr;constructor(n={}){this.attr=n}get(n,t=this.attr,r){let i=(o,s)=>{if(g(s))n.attr_push(o,En(s));else if(s instanceof D){let e=r?`${r}_${o}`:o;n.states.push(s.call(Ht(o,r),e)),i(o,s.value)}else if(F(s)){if(ln(s)&&!r)this.get(n,s,o)}else n.attr_push(o,En(s),r)};m(t).forEach(([o,s])=>{if(["on"].includes(o))F(t.on)&&n.events.obj(t.on);else i(o,s)})}}class z{xid;IDM;map=new f;states=[];events=new f;OZ;constructor(n,t=new c,r){this.xid=n;this.IDM=t;this.OZ=r??new mn}attr_push(n,t,r){let i=r??n;if(!this.map.has(i))this.map.set(i,[]);let o=r?`${B(n)}:${t};`:t;this.map.get(i).push(o)}get attr(){let n=[""];return this.map.forEach((t,r)=>{let i=t.join("");n.push(i?`${r}="${i}"`:r)}),n.join(" ")}set id(n){if(!this.map.has("id"))this.map.set("id",[n])}get id(){return this.map.get("id")?.join("")}}var Jt=(n,t,r)=>{return n.addEventListener(t,r),()=>{n.removeEventListener(t,r)}},_={};class mn{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(n){let{id:t,events:r,states:i}=n;if(t){if(r.size)this.events.set(t,r);if(i.length)this.states.set(t,i)}return this}push(n){return n.events.forEach((t,r)=>{t.forEach((i,o)=>{rn(r,this.events).set(o,i)})}),n.states.forEach((t,r)=>{R(r,this.states).push(...t)}),this}get stage(){return this.events.forEach((n,t)=>{this.events.delete(t);let r=C(t);if(!r){this.events.delete(t);return}n.forEach((i,o)=>{switch(o){case"ready":i.apply(r,[r]);break;case"resize":case"beforeunload":case"popstate":case"winscroll":case"winload":case"winfocus":case"winblur":let s=o.replace(/^win/,"");this.windowEvents.init(s,new f).set(t,i);break;case"watch":let[e,u,T]=i.apply(r,[r]),h=g(u)?u:[u],E=()=>h.map((Z)=>Z.value),Y=()=>e(...E());if(T)Y();h.forEach((Z)=>R(t,this.resetST).push(Z.call(Y,t+"_watch")(t)));break;default:R(t,this.resetEV).push(Jt(r,o,i))}})}),this.processWindowEvents,this.states.forEach((n,t)=>{this.states.delete(t),n.forEach((r)=>{R(t,this.resetST).push(r(t))})}),this}get processWindowEvents(){let n=(t,r)=>{let i=(o)=>{r.forEach((s,e)=>{let u=C(e);if(u)s.call(u,o);else this.windowEvents.get(t)?.delete(e)})};return window.addEventListener(t,i),()=>{window.removeEventListener(t,i)}};return this.windowEvents.forEach((t,r)=>{if(t.size){if(!_[r])_[r]=n(r,t)}else if(_[r])_[r](),delete _[r]}),this}reset(n){return n.forEach((t)=>{this.windowEvents.forEach((r,i)=>{if(r.has(t))r.delete(t)}),this.resetEV.get(t)?.forEach((r)=>{r()}),this.resetST.get(t)?.forEach((r)=>{r()}),this.resetST.delete(t),this.resetEV.delete(t)}),this}RPS(n){if(n){let t=tt();this.reset(t);let r=n.keys;if(r.length)this.reset(r).push(n).stage}return this}}var J=new mn;var Xt=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],Qt=(n)=>Xt.includes(n),gn=(n,t)=>{if(g(n))return n.map((r)=>gn(r,t)).join("");else if(n instanceof X){let r=n.__(t.IDM),{ctx:i,oz:o}=r;return t.OZ.push(o),i}else if(F(n))return j(n);else if(p(n))return gn(n(),t);else if(n!==void 0&&n!==null)return String(n);return""},it=(n,t)=>{let r=new c(n),i=new z(r.id,r);return{ctx:gn(t,i),catt:i}};function Yt(n){let t=this.id;if(t){let{ctx:r,catt:i}=it(t,n);if(this.innerHTML!==r)this.innerHTML=r,J.RPS(i.OZ)}}var pn=(n,t,r,i=[])=>{if(g(n))n.forEach((o)=>{pn(o,n.length,r,i)});else if(n instanceof D)if(t>1)pn(Q("div",{},n),t,r,i);else{let o=n.value,s=o instanceof X?"dom":"ctx",{ctx:e,catt:u}=it(r.xid+"-0",o);r.xid=u.xid,i.push(e),r.OZ.push(u.OZ),r.states.push(n.call(Yt,s))}else i.push(gn(n,r))};class jn{tag;ctx;closing;constructor(n,t){this.tag=n;this.ctx=t;let r=Qt(n);this.closing=r?"":`</${n}>`}process(n,t=this.ctx,r=[]){return t.forEach((i)=>{pn(i,t.length,n,r)}),r.join("")}get(n){let t=this.process(n);if(n.events.size||n.states.length)n.id=n.xid;return`<${this.tag}${n.attr}>${t}${this.closing}`}}class X{tag;constructor(n,t={},...r){this.tag=n;tn(this,{attr:new $n(t),ctx:new jn(n,r)})}__(n=new c){let t=n.mid,r=new z(t,n);return this.attr.get(r),{ctx:this.ctx.get(r),oz:r.OZ.set(r),id:r.id}}}function Q(n,t={},...r){if(p(n))return n(t??{},...r);return new X(n,t??{},r)}var Ut=(n,...t)=>t;class qn{e;opt;constructor(n){this.e=n;this.opt={duration:500,easing:"ease-in-out",fill:"forwards"}}animate(n,t={}){return this.e.animate(n,t)}get slide(){let n=({x:t=0,y:r=0},i={})=>{x(this.opt,i);let o=[[t,r],[0,0]].map(([s,e])=>({transform:`translateX(${s}rem) translateY(${e}rem)`}));return this.e.animate(o,this.opt),this};return{left:(t={})=>{return n({x:-2},t)},right:(t={})=>{return n({x:2},t)},up:(t={})=>{return n({y:2},t)},down:(t={})=>{return n({y:-2},t)}}}fade(n={}){x(this.opt,n);let t=[0,1].map((r)=>({opacity:r}));return this.e.animate(t,this.opt),this}shake(n="Y",t={}){x(this.opt,t);let r=[0,5,-5,5,0].map((i)=>({transform:`translate${n}(${i}px)`}));return this.e.animate(r,this.opt),this}color(n=[],t={}){x(this.opt,t);let r=Array.isArray(n)?n.map((i)=>({color:i})):{color:n};return this.e.animate(r,this.opt),this}bg(n=[],t={}){x(this.opt,t);let r=Array.isArray(n)?n.map((i)=>({backgroundColor:i})):{backgroundColor:n};return this.e.animate(r,this.opt),this}bounce(n=1,t={}){x(this.opt,t);let r=[0.5,n,1].map((i)=>({transform:`scale(${i})`}));return this.e.animate(r),this}}class Hn{e;query;constructor(n,t){this.e=n;this.query=t}get a(){return new qn(this)}get all(){if(this.query){let n=document.querySelectorAll(this.query);if(n.length)return Array.from(n).map((t)=>t)}return[]}get attr(){let n=this.e;return{has:(t)=>{return n.hasAttribute(t)},get:(t)=>{return n.getAttribute(t)},del:(t)=>{return n.removeAttribute(t),this},set:(t)=>{for(let r in t){let i=t[r];if(t[r]!==void 0)n.setAttribute(r,i?i:"")}return this}}}get children(){return Array.from(this.e.children).map((n)=>l(n))}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 n=this.e.offsetParent;if(n)return new G(n);return}get parent(){let n=this.e.parentElement;if(n)return new G(n);return}get path(){return this.e?.pathname??""}get rect(){return this.e.getBoundingClientRect()}get remove_element(){return this.e.remove(),this}get style(){let n=this.e.style,t=this;return{set:(r,i=0)=>{let o=n,s=()=>{m(r).forEach(([e,u])=>{if(e in o){if(o[e]!==u)o[e]=u}else if(u!==null)n.setProperty(e,String(u))})};if(p(i))t.on("transitionend",i);if(Dn(i))setTimeout(s,i);else s();return t},get:(r)=>{return n.getPropertyValue(r.toString())},del:(...r)=>{r.forEach((i)=>{n.removeProperty(i.toString())})}}}get submit(){let n=this.e;if("submit"in n)return n.submit();return!1}get tag(){return this.e.tagName.toLowerCase()}get value(){return this.e.value??""}get unload(){return()=>{this.e.remove()}}set append(n){let{ctx:t,oz:r}=Fn(n,Zn(this.id));this.e.insertAdjacentHTML("beforeend",t),J.RPS(r)}set appendfirst(n){let{ctx:t,oz:r}=Fn(n,Zn(this.id));this.e.insertAdjacentHTML("afterbegin",t),J.RPS(r)}set inner(n){let{ctx:t,oz:r}=Fn(n,Zn(this.id));this.e.innerHTML=t,J.RPS(r)}set disabled(n){let t=this.e;if("disabled"in t)t.disabled=n}set id(n){this.e.id=n}set value(n){let t=this.e;t.value=n}}var Fn=(n,t)=>{if(n instanceof X)return n.__(new c(t));return{ctx:n,oz:void 0}},Zn=(n)=>n?`${n}-0`:n;class G extends Hn{constructor(n,t){super(n,t)}add(...n){return this.e.classList.add(...n.map((t)=>t.replace(/[^\w-]/,""))),this}remove(...n){return this.e.classList.remove(...n.map((t)=>t.replace(/[^\w-]/,""))),this}toggle(n,t){let r=typeof n!="string"?n.apply(this):n,i=this.e.classList;return r.split(" ").forEach((o)=>{i.toggle(o,t)}),this}has(n){return this.e.contains(n)}insert(n){return{HTML:(...t)=>{return t.forEach((r)=>{this.e.insertAdjacentHTML(n,r)}),this},element:(...t)=>{return t.forEach((r)=>{this.e.insertAdjacentElement(n,r)}),this},text:function(...t){return t.forEach((r)=>{this.e.insertAdjacentText(n,r)}),this}}}is(n){let t=this.e.classList.value.split(" "),r=this.e.tagName.toLocaleLowerCase(),i=!0,o=!0;if(n.dom)o=n.dom==r?!0:!1;if(n.class)if(Array.isArray(n.class))n.class.forEach((s)=>{i=i?t.includes(s):!1});else i=i?t.includes(n.class):!1;return i&&o}on(n,t,r=!1){let i=!1;if(n.indexOf("touch")>-1)i=!0;return this.e.addEventListener(n,t,{capture:r,passive:i}),this}remove_on(n,t,r=!1){return this.e.removeEventListener(n,t,r),this}timed(n,t=250){return setTimeout(()=>n(this),t),this}animate(n,t,r){let i={duration:300,easing:"ease",fill:"forwards"};if(p(t))r=t;else x(i,t);let o=this.e.animate(n,i);if(r)o.finished.then(r);return this}}function l(n){if(nn(n)){let t=document.querySelector(n);if(t)return new G(t,n);return}else return new G(n)}class a extends bn{path;args;id;status;lang;import;_data={};constructor(n,t={},r,i=200){super();this.path=n;this.args=t;this.id=r;this.status=i}head(){this.title="error "+this.status}body(){return Q("div",{},this.path+" not found...")}async loader(){if(this.import)try{let n=await this.import;if(n.default){let t=await n.default({...this.args,...this.data});return g(t)?t:[t]}}catch(n){K.p=n;let t=await this.body();return g(t)?t:[t]}else{let n=await this.body();return g(n)?n:[n]}return[]}getHeadAttr(n={},...t){let r=new I;if(q(n))r.head=n;r.id=this.id;let i=r.head;return t.forEach((o)=>{i.map(o)}),Bt(r,this),i}set data(n){x(this._data,n)}get data(){return this._data}}function Bt(n,t){let{link:r,script:i,meta:o,title:s,base:e,description:u,css:T}=t;if(n.head={title:s,base:e,meta:o,link:r,script:i},u)n.head={meta:[{name:"description",content:u}]};if(T){let h=T.map((E)=>({rel:`${b?"preload ":""}stylesheet`,href:E,as:"style"}));n.head={link:[...h]}}}function ot(n){let t=[];if(n?.length){let{href:r,target:i}=n[0],o=l("base");if(o)o.attr.set({href:r,target:i});else{let s=l(document.createElement("base"));s.attr.set({href:r,target:i}),document.head.append(s.e)}}else{let r=l("base")?.unload;r&&t.push(r)}return t}async function st(n){let t={};if(l("link")?.all.forEach((r)=>{let i=l(r),o=i.attr.get("href");if(o)t[o]=i.unload}),n&&q(n))for(let r of $(n)){let i=r.href;if(!(i in t))await yn(r);else delete t[i]}return $(t)}var St=["charset","name","property","http-equiv"];function et(n){let t={};if(l("meta")?.all.forEach((r)=>{let i=r.attributes;for(let o of St)if(o in i){let s=i[o].value;t[`${o}_${o==="charset"?"":s}`]=r}}),n)m(n).forEach(([r,i])=>{if(r in t)l(t[r]).attr.set(i),delete t[r];else{let o=l(document.createElement("meta"));o.attr.set(i),document.head.append(o.e)}});return $(t).map((r)=>l(r).unload)}async function ut(n){let t={};if(l("script[yid]")?.all.forEach((r)=>{let i=l(r),o=i.attr.get("yid");if(o)t[o]=i.unload}),n){for(let r of n)if("yid"in r)if(r.yid in t)delete t[r.yid];else await At(r)}return $(t)}var At=(n)=>{return new Promise((t,r)=>{let i=l(document.createElement("script")),o="";if("importmap"in n)n.type="importmap",o=JSON.stringify(n.importmap),delete n.importmap;else if("body"in n)o=n.body,delete n.body;if(o)i.inner=o;i.attr.set(n),i.e.onload=()=>t(()=>{}),i.e.onerror=()=>r(new Error("Failed to load CSS")),document.head.appendChild(i.e)})};async function ft(n,t){let r=[];if(b)return[];let i=n.get("title")??"",{pushState:o}=this.config,s=this.path.value;if(o)Jn(s,i);return document.documentElement.lang=t,document.title=i,r.push(...ot(n.get("base"))),r.push(...et(n.get("meta"))),r.push(...await st(n.get("link"))),r.push(...await ut(n.get("script"))),r}function Jn(n,t){let r=window.location.pathname;if(n&&r!==n)history.pushState({},t??"",n)}class Xn{lang;head="";constructor(n,t){if(this.lang=n,t)this.head=Vn(t)}body(n,t){return[`<!DOCTYPE html><html lang="${this.lang}">`,`<head>${this.head}</head>`,`<body id="${t??y(5)}">${n}</body>`,"</html>"].join("")}}class Qn{path;args;isConnected=H(!1);data={};constructor(n,t={}){this.path=n;this.args=t}open(n){}message(n){}close(n){}error(n){}get connect(){if(this.ws&&this.ws.readyState<=1)return this;return this.ws=new WebSocket(this.path),this.ws.onopen=async(n)=>{this.isConnected.value=!0,await this.open.call(this,n)},this.ws.onmessage=async(n)=>{await this.message.call(this,n)},this.ws.onclose=async(n)=>{this.isConnected.value=!1,await this.close.call(this,n)},this.ws.onerror=async(n)=>{this.isConnected.value=this.ws.readyState<=1,await this.error.call(this,n)},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(n){this.ws.send(n)}}var N=new f;class Yn{yra;constructor(n){this.yra=n}async load(n){if(!N.has(n)){let[r,i]=await this.yra.loadWSS(n);if(!r)return;let{cls:o,path:s,id:e}=r,u=new o(s,i).connect;return N.set(n,u),u}let t=N.get(n);return t.reconnect,t}unload(n){if(N.has(n)){let t=N.get(n);if(!t)return;t.disconnect,N.delete(n)}}}function Dt(n,t,r){let i={...n.on??{},click(o){o.preventDefault(),r.value=l(this).path}};return delete n.on,Q("a",{...n,on:{...i}},...t)}function Gt(n,t,r){let{classes:i}=n.config,o={...t.on??{},ready(){n.element.value=this,t.render&&n.render(t.render)},...r&&{popstate(T){let h=T.target;n.path.value=h.location.pathname}}},{render:s,on:e,...u}=t;return Q("div",{...u,...i&&{class:i},on:o},n.root)}class Un extends fn{hook;id=y(4);root=H([]);path=H("");socket;element=H(null);A;Main;load;constructor(n,t,r=!1){super(n,t);this.socket=new Yn(this),this.A=(i,...o)=>{return Dt(i,o,this.path)},this.Main=(i)=>{return Gt(this,i,r)},this.load=async(i,o={})=>{if(i)this.path.value=i,await this.render(i,404,o);return this.hooker(),this}}hooker(){let n={},t=this.path.value;if(this.hook)this.hook();this.hook=W(async(r)=>{if(n[t]=window.scrollY,(await this.render(r,404)).done)window.scrollTo({top:n[r]??0,behavior:"instant"}),t=r},[this.path],{id:"router"})}async class(n,t,r=!1){let[i,o]=await this.getPath(n);if(i&&!r){let{cls:s,path:e,id:u}=i;return new s(e,o,u)}else return Kt.call(this,n,t)}async render(n,t=404,r={}){let i=await this.class(n,t,!1);if(i.data=r,!i)return{done:!1};return await this.fetch(i),this.root.value=await i.loader(),{done:!0}}async fetch(n){if(n)try{if(n.fetch){let t=await n.fetch();if(k(t)&&q(t))n.data=t}}catch(t){K.p=t}}}async function Kt(n,t){let[r,i]=await this.loadError(t??0);if(r){let{cls:o,id:s}=r;return new o(n,i,s,t)}else return new a(n,i,y(5))}class mt extends Un{constructor(n,{classes:t,pushState:r=!0}){super(n,{classes:t,pushState:r},!0);this.head({meta:[{charset:"utf-8"},{name:"viewport",content:"width=device-width, initial-scale=1.0"}]}),this.load=async(i,o={})=>{if(i)this.path.value=i;if(Tn)this.render(i,404,o).then(()=>{if(i&&this.config.pushState)Jn(i,document.title);Mt.call(this,this.Main({})),this.hooker()});return this}}async processHead(n,t={}){return n?await this.processClassHead(n,t):await this.processDefaultHead(t)}async processClassHead(n,t){return await n.head(),n.getHeadAttr(t,this.htmlHead)}async processDefaultHead(n){let t=new I;if(q(n))t.head=n;return t.head.map(this.htmlHead),t.head}async render(n=location.pathname,t,r={},i={},o=!0,s=!1){if(b)this.path.value=n;let e=await this.class(n,t??It(),s);e.data=r,await this.fetch(e);let u=await this.processHead(e,i);if(!e)return{lang:this.lang,heads:u,done:!1};let T=[];if(o)T=await ft.call(this,u,e?.lang||this.lang);let h=await e.loader();if(h.length)this.root.value=h;else await this.render(n,t,r,i,o,!0);if(o)T.forEach((E)=>E());return{heads:u,lang:e.lang??this.lang,done:!0}}async html(n,t={},r){let i={script:[{type:"module",src:this.ImportMeta.file}]};wt(i,r);let{lang:o,heads:s}=await this.render(n,r,t,i,!1),{ctx:e}=this.Main({}).__(new c(this.id));return new Xn(o,s).body(e,this.id)}}function Mt(n){let t=document.body.id,{oz:r,id:i}=n.__(new c(t));if(this.id=i||this.id,!r)return;J.push(r),requestAnimationFrame(()=>{J.stage})}function It(){if(Tn)return parseInt(l('meta[name="error-code"]')?.attr.get("content")??"404");return 404}var wt=(n,t)=>{switch(t){case 404:n.meta=[{name:"error-code",content:t.toString()}];return;default:return}};class Bn{state;body;click;constructor({toggle:n=[],initialState:t=!1}={}){this.state=H(t);let r=this.state;this.click=function(){r.value=!r.value},this.loader(n)}loader(n){if(typeof window==="undefined")return;let t=d.get("LOCAL_SCHEME"),r=this.isDark,i=t.as.bool,o=d.get({IS_DARK:()=>this.state.value});if(i!=null&&i!==r)this.state.value=!i,o.save,t.set=r;if(o.as.bool!==null)this.state.value=o.as.bool;let s=this.toggle,e=document.documentElement.classList;if(s(e,this.state.value,n),W(async(u)=>{s(e,u,n),o.save},[this.state],{id:"colorScheme"}),this.isMatchMediaSupported)window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",(u)=>{let h=(u.matches?"dark":"light")==="dark";this.state.value=h,t.set=h})}get isMatchMediaSupported(){return window.matchMedia&&typeof window.matchMedia==="function"}get isDark(){return window.matchMedia("(prefers-color-scheme: dark)").matches}toggle(n,t,r){if(t)n.add(...r);else n.remove(...r)}}Bn=Sn([Pn,An("design:paramtypes",[Object])],Bn);var Os=(n,t)=>{return`${n.replace(/\/+$/,"")}/${t.replace(/^\.\/+/,"")}`};export{Qn as websocket,W as stateHook,vn as session,Os as resolvePath,fn as minClient,d as local,Ut as frag,an as eventStream,Q as dom,a as doc,yn as cssLoader,jt as addCSS,Cn as __,mt as Yve,D as Stateful,H as State,Un as Router,on as Meta,X as Dom,Bn as ColorScheme,K as $$,l as $};
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "yvee",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Yvee JS framework",
|
|
5
|
+
"author": "Marky <markjotep@gmail.com>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"util": "cp -r ../misc/util ./",
|
|
14
|
+
"dirs": "for dir in ./src ./dist ./test ./util ./types; do mkdir -p $dir; done",
|
|
15
|
+
"@": "ln -sf ../../misc/@/ ./src",
|
|
16
|
+
"ts": "ln -sf ../misc/tsconfig.json ./;",
|
|
17
|
+
"init": "bun run dirs && bun run util && bun run @ && bun run ts;",
|
|
18
|
+
"build": "rm -r ./types ; tsc && bun build ./src/index.ts --outdir ./dist --minify --packages external --target browser && rollup -c ./util/rollup.config.js"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/MARKjotep/yvee.git"
|
|
23
|
+
},
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/MARKjotep/yvee/issues"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://github.com/MARKjotep/yvee#readme",
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"dotenv": "^16.4.7",
|
|
30
|
+
"jsonwebtoken": "^9.0.2",
|
|
31
|
+
"pg": "^8.13.1",
|
|
32
|
+
"authored": "^0.0.2",
|
|
33
|
+
"rollup": "^4.31.0",
|
|
34
|
+
"rollup-plugin-dts": "^6.1.1"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/jsonwebtoken": "^9.0.7",
|
|
38
|
+
"@types/pg": "^8.11.10",
|
|
39
|
+
"@types/bun": "^1.2.2"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"typescript": "^5.7.3"
|
|
43
|
+
},
|
|
44
|
+
"directories": {
|
|
45
|
+
"test": "test"
|
|
46
|
+
},
|
|
47
|
+
"type": "module"
|
|
48
|
+
}
|
package/readme.md
ADDED