yvee 0.0.5 → 0.0.6
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/LICENSE +1 -1
- package/dist/index.d.ts +51 -6
- package/dist/index.js +1 -1
- package/package.json +4 -12
package/LICENSE
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
1
|
+
declare const isFN: (v: any) => v is Function;
|
|
2
|
+
declare const isAsync: (v: any) => v is Function;
|
|
3
|
+
declare const isNumber: (value: any) => boolean;
|
|
4
|
+
declare const isDict: (val: any) => boolean;
|
|
5
|
+
declare const isPlainObject: (value: any) => boolean;
|
|
6
|
+
declare const isArraybuff: (val: any) => val is string | ArrayBuffer | Uint8Array<ArrayBufferLike>;
|
|
7
|
+
declare const isClassOrId: (k: string) => boolean;
|
|
8
|
+
declare const isBool: (v: any) => v is boolean;
|
|
9
|
+
declare const isStr: (v: any) => v is string;
|
|
10
|
+
declare const isArr: (v: any) => v is any[];
|
|
11
|
+
declare const isObj: (v: any) => v is object;
|
|
12
|
+
declare const isNum: (v: any) => v is number;
|
|
13
|
+
declare const isNull: (v: any) => v is null;
|
|
14
|
+
declare const isUndefined: (v: any) => v is undefined;
|
|
15
|
+
declare const isInt: (str: string) => boolean;
|
|
16
|
+
declare const isWindow: boolean;
|
|
17
|
+
declare const isNotWindow: boolean;
|
|
18
|
+
|
|
19
|
+
declare const is_isArr: typeof isArr;
|
|
20
|
+
declare const is_isArraybuff: typeof isArraybuff;
|
|
21
|
+
declare const is_isAsync: typeof isAsync;
|
|
22
|
+
declare const is_isBool: typeof isBool;
|
|
23
|
+
declare const is_isClassOrId: typeof isClassOrId;
|
|
24
|
+
declare const is_isDict: typeof isDict;
|
|
25
|
+
declare const is_isFN: typeof isFN;
|
|
26
|
+
declare const is_isInt: typeof isInt;
|
|
27
|
+
declare const is_isNotWindow: typeof isNotWindow;
|
|
28
|
+
declare const is_isNull: typeof isNull;
|
|
29
|
+
declare const is_isNum: typeof isNum;
|
|
30
|
+
declare const is_isNumber: typeof isNumber;
|
|
31
|
+
declare const is_isObj: typeof isObj;
|
|
32
|
+
declare const is_isPlainObject: typeof isPlainObject;
|
|
33
|
+
declare const is_isStr: typeof isStr;
|
|
34
|
+
declare const is_isUndefined: typeof isUndefined;
|
|
35
|
+
declare const is_isWindow: typeof isWindow;
|
|
36
|
+
declare namespace is {
|
|
37
|
+
export { is_isArr as isArr, is_isArraybuff as isArraybuff, is_isAsync as isAsync, is_isBool as isBool, is_isClassOrId as isClassOrId, is_isDict as isDict, is_isFN as isFN, is_isInt as isInt, is_isNotWindow as isNotWindow, is_isNull as isNull, is_isNum as isNum, is_isNumber as isNumber, is_isObj as isObj, is_isPlainObject as isPlainObject, is_isStr as isStr, is_isUndefined as isUndefined, is_isWindow as isWindow };
|
|
38
|
+
}
|
|
39
|
+
|
|
1
40
|
type V = string | number | boolean;
|
|
2
41
|
type obj<T> = Record<string, T>;
|
|
3
42
|
|
|
@@ -177,7 +216,7 @@ declare class __ {
|
|
|
177
216
|
}): HTMLElement;
|
|
178
217
|
static randFrom(arr: any[] | Object): any;
|
|
179
218
|
static makeID: (length: number) => string;
|
|
180
|
-
static
|
|
219
|
+
static class(a: obj<any>, classes: string[]): void;
|
|
181
220
|
static get O(): {
|
|
182
221
|
vals: {
|
|
183
222
|
<T>(o: {
|
|
@@ -204,6 +243,11 @@ declare class __ {
|
|
|
204
243
|
};
|
|
205
244
|
len: (obj?: {}) => number;
|
|
206
245
|
};
|
|
246
|
+
static get is(): typeof is;
|
|
247
|
+
static get return(): typeof returner;
|
|
248
|
+
}
|
|
249
|
+
declare class returner {
|
|
250
|
+
static array(val: any): any[];
|
|
207
251
|
}
|
|
208
252
|
|
|
209
253
|
declare class CATT {
|
|
@@ -341,6 +385,7 @@ declare class Router extends minClient {
|
|
|
341
385
|
protected socket: socket;
|
|
342
386
|
id: string;
|
|
343
387
|
path: Stateful<string>;
|
|
388
|
+
lastPath: Stateful<string>;
|
|
344
389
|
A: (a: attr & {
|
|
345
390
|
href: string;
|
|
346
391
|
}, ...D: ctx[]) => Dom;
|
|
@@ -371,6 +416,10 @@ declare class Yvee extends Router {
|
|
|
371
416
|
attr?: string;
|
|
372
417
|
}): Promise<string>;
|
|
373
418
|
}
|
|
419
|
+
type RouteType = (path: string) => <Q extends typeof doc<{}>>(f: Q) => Q;
|
|
420
|
+
declare const Routes: (fn: (route: RouteType) => void) => (route: RouteType) => void;
|
|
421
|
+
type ErrorType = (...codes: number[]) => <Q extends typeof doc<{}>>(f: Q) => Q;
|
|
422
|
+
declare const Errors: (fn: (error: ErrorType) => void) => (error: ErrorType) => void;
|
|
374
423
|
|
|
375
424
|
declare class ClientPath extends MinStorage {
|
|
376
425
|
id: string;
|
|
@@ -751,9 +800,5 @@ declare global {
|
|
|
751
800
|
}
|
|
752
801
|
}
|
|
753
802
|
declare const resolvePath: (base: string, relative: string) => string;
|
|
754
|
-
type RouteType = (path: string) => <Q extends typeof doc<{}>>(f: Q) => Q;
|
|
755
|
-
declare const Routes: (fn: (route: RouteType) => void) => (route: RouteType) => void;
|
|
756
|
-
type ErrorType = (...codes: number[]) => <Q extends typeof doc<{}>>(f: Q) => Q;
|
|
757
|
-
declare const Errors: (fn: (error: ErrorType) => void) => (error: ErrorType) => void;
|
|
758
803
|
|
|
759
|
-
export { $, $$, ColorScheme, Dom, Errors, Meta, Router, Routes, State, Stateful, Yvee, type _$, __, addCSS, cssLoader, doc, dom, eventStream, frag, type headAttr, local,
|
|
804
|
+
export { $, $$, ColorScheme, Dom, Errors, Meta, Router, Routes, State, Stateful, Yvee, type _$, __, addCSS, cssLoader, doc, dom, eventStream, frag, type headAttr, local, resolvePath, session, stateHook, websocket };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Ft=function(t,n,r,i){var o=arguments.length,e=o<3?n:i===null?i=Object.getOwnPropertyDescriptor(n,r):i,s;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")e=Reflect.decorate(t,n,r,i);else for(var u=t.length-1;u>=0;u--)if(s=t[u])e=(o<3?s(e):o>3?s(n,r,e):s(n,r))||e;return o>3&&e&&Object.defineProperty(n,r,e),e};var Zt=(t,n)=>{if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(t,n)};var x=(t)=>typeof t==="function";var R=(t)=>{return!isNaN(parseFloat(t))&&isFinite(t)},at=(t)=>{return typeof t==="object"&&t!==null&&!Array.isArray(t)},k=(t)=>{return typeof t==="object"&&t!==null&&Object.getPrototypeOf(t)===Object.prototype};var v=(t)=>typeof t==="boolean",tt=(t)=>typeof t==="string",a=(t)=>Array.isArray(t),w=(t)=>typeof t==="object",It=(t)=>typeof t==="number",C=(t)=>t===null,Xt=(t)=>typeof t==="undefined",Jt=(t)=>{return Number.isInteger(Number(t))},gt=typeof window!=="undefined",c=typeof window==="undefined";function nt(t,n){h(n).forEach(([r,i])=>{Ut(t,r,{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[n,r]=[t.split("-").slice(0,-1).join("-"),t.split("-").slice(-1)[0]];this._id=n,this._c=R(r)?parseInt(r):0}}get id(){return this._id+"-"+this._c}get mid(){return this._id+"-"+ ++this._c}}var vn=new RegExp(/(\d+)(\d*)/,"m"),dn=(t)=>Array.from({length:t},(n,r)=>r),pn="ABCDEFGHIJKLMNOPQRSTUVWXYZ",Tn="abcdefghijklmnopqrstuvwxyz",bn=dn(10).join("");var E=(t)=>JSON.stringify(t),Qt=(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 n=pn+Tn;return Array.from({length:t},(r,i)=>n+(i?bn:"")).reduce((r,i)=>{return r+=i.charAt(Math.floor(Math.random()*i.length))},"")};class f extends Map{obj(t){t&&h(t).forEach(([n,r])=>this.set(n,r))}map(t){t.forEach((n,r)=>{if(n instanceof f)this.set(r,n);else if(a(n)){if(this.lacks(r))this.set(r,[]);this.get(r).push(...n)}else if(w(n))this.ass(r,n);else this.set(r,n)})}ass(t,n){if(!this.has(t))this.set(t,{});T(this.get(t),n)}lacks(t){return!this.has(t)}init(t,n){return this.has(t)?this.get(t):this.set(t,n).get(t)}}var{values:y,keys:J,entries:h}=Object;var{hasOwn:Yt,freeze:Wt,defineProperty:Ut,assign:T}=Object,$=(t)=>{return Object.keys(t).length},rt=(t,n)=>{if(!n.has(t))n.set(t,new f);return n.get(t)},G=(t,n)=>{if(!n.has(t))n.set(t,[]);return n.get(t)},lt=(t,n)=>{let r={added:{},removed:{},modified:{}},i=J(t),o=J(n);for(let e of o){let s=t[e],u=n[e];if(!(e in t))r.added[e]=u;else if(a(s)&&a(u)){if(E(s)!==E(u))r.modified[e]={old:s,new:u}}else if(w(s)&&w(u)&&!C(s)&&!C(u)){let m=lt(s,u);if($(m.added)||$(m.removed)||$(m.modified))r.modified[e]={old:s,new:u}}else if(s!==u)r.modified[e]={old:s,new:u}}for(let e of i)if(!(e in n))r.removed[e]=t[e];return r};function Bt(t,n){if(t.size!==n.size)return!1;for(let r of t)if(!n.has(r))return!1;return!0}var Ct=(t)=>{return y(t).some((n)=>{return $(n)})};function Gt(t){let n;return class extends t{constructor(...r){if(n)return n;super(...r);Wt(this),n=this}}}var F=(t,n)=>{return{name:t,content:n}},yn=(t,n)=>{return{property:t,content:n}},xn=(t,n)=>{return{"http-equiv":t,content:n}};class it{metas=[];constructor(t){t&&this.metas.push(F("description",t))}author(t){return this.meta=F("author",t),this}charset(t){return this.meta={charset:t},this}keywords(...t){return this.meta=F("keywords",t.join(", ")),this}viewport(t){let n=h(t).map(([r,i])=>[S(r),String(i)].join("="));return this.meta=F("viewport",n.join(", ")),this}httpEquiv(t){return h(t).forEach(([n,r])=>{this.meta=xn(S(n),String(r))}),this}robots(...t){return this.meta=F("robots",t.join(", ")),this}themeColor(t){return this.meta=F("theme-color",t),this}openGraph(t){return h(t).forEach(([n,r])=>{this.meta=yn("og:"+n,String(r))}),this}twitter(t){return h(t).forEach(([n,r])=>{this.meta=F("twitter:"+n,String(r))}),this}and(t){return this}set meta(t){this.metas.push(t)}}class ct{title;description;base;meta;link;script;css}var En=["charset","name","property","http-equiv"],Pt=(t,n)=>{n.forEach((r)=>{for(let i of En)if(i in r){let o=r[i];t[`${i}_${i==="charset"?"":o}`]=r}})},$n=(t,n)=>{n.forEach((r)=>{if("href"in r){let i=r.href;t[`${i}`]=r}})};class U{_head;idm;constructor(t){this._head=new f(t)}set head(t){h(t).forEach(([n,r])=>{if(n==="title"||n==="base"){if(r!==void 0)this._head.set(n,r);return}if(r instanceof it)return Pt(this._head.init("meta",{}),r.metas);if(!a(r))return;switch(n){case"meta":return Pt(this._head.init("meta",{}),r);case"link":return $n(this._head.init("link",{}),r);case"script":if(r.length){this._head.init(n,[]);let i=r.map((o)=>{if(!o.yid&&this.idm)o.yid="sc"+this.idm.mid;return o});this._head.get(n).push(...i)}return}})}get head(){return this._head}set id(t){this.idm=new d(t)}}var zt=(t)=>{return h(t).reduce((n,[r,i])=>{return n.push(v(i)&&i?r:`${r}="${i}"`),n},[""]).join(" ")},Kt=(t)=>{if(!t)return"";return[...t].reduce((n,[r,i])=>{if(r==="meta"||r==="link")i=y(i);if(tt(i))return n.push(`<${r}>${i}</${r}>`),n;if(!a(i))return n;let o=i.map((e)=>{if(r==="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`<${r}${zt(s)}>${u}</${r}>`}return`<${r}${zt(e)}>`});return n.push(...o),n},[]).join("")};class dt{lang="en";htmlHead=new f;head;constructor(){this.head=(t={})=>{let n=new U(this.htmlHead);n.head=t,this.htmlHead=n.head}}}var pt=(t)=>{if(c)return;return new Promise((n,r)=>{let i=document.createElement("link");if(t.rel!=="stylesheet")t.rel="stylesheet",t.as="style";h(t).forEach(([o,e])=>{i.setAttribute(o,e)}),i.onload=()=>n(i),i.onerror=()=>r(new Error("Failed to load CSS")),document.head.appendChild(i)})},Nt=(t)=>{return new Promise((n,r)=>{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;h(t).forEach(([e,s])=>{i.setAttribute(e,s)}),i.onload=()=>n(i),i.onerror=()=>r(new Error("Failed to load Script")),document.head.appendChild(i)})},wn=()=>{let n=document.querySelector("#d-css")?.sheet;if(n)return n;let r=document.createElement("style");return r.id="d-css",document.head.appendChild(r),r.sheet},Hn=(t,n)=>{for(let r=0;r<t.cssRules.length;r++)if(t.cssRules[r].selectorText===n)return!0;return!1},jn=(t)=>Object.entries(t).map(([n,r])=>`${S(n)}: ${r};`).join(" ");function Dn(t,n={}){if(c)return;let r=wn();if(!r)return;if(!Hn(r,t))r.insertRule(`${t} { ${jn(n)} }`,r.cssRules.length)}var Vt=(t,n)=>{let r=n;if(t?.class)r.push(...a(t.class)?t.class:[t.class]);return delete t.class,r.filter((i)=>i)};var Ot=(t,n=!1)=>{if(R(t))return[+t,Jt(t)?"int":"float"];if(n&&/\.\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"]},ot=(t)=>{let n=t.startsWith("/")?t:"/"+t,r=n.match(/(?<=\/)[^/].*?(?=\/|$)/g)??["/"],[i,o]=r.reduce(([e,s],u)=>{if(u.includes("<")){let m=u.match(/(?<=<)[^/].*?(?=>|$)/g);if(m?.length){let[l,b]=m[0].split(":");if(l&&b)e.push(l),s.push(b)}}else e.push(u===">"?"/":u);return[e,s]},[[],[]]);if(n.endsWith("/")&&n.length>1)i.push("/");return{parsed:i,args:o}};class et{storage=new f;cache(t,n){if(this.storage.lacks(t))this.storage.set(t,n());return this.storage.get(t)}}var An=["int","float","file","uuid","string"],qn=new et;class Q{_storage=new f;set(t){let{parsed:n,path:r}=t,i=E(n);if(!this._storage.get(i))this._storage.set(i,t);else throw`path: ${r} already used.`}get(t){let{parsed:n}=qn.cache(t,()=>ot(t)),r={},i=this._storage.get(E(n));if(!i&&t!=="/")for(let o of this._storage.keys()){let e=[],s=Qt(o);if(n.length===s.length){let u=s.map((b,j)=>{let D=Ot(n[j],n.length-1===j);if(b===D[0])return D[0];if(An.includes(D[1]))return e.push(D[0]),D[1];return b}),m=E(u);if(this._storage.has(m)){i=this._storage.get(m),i?.args.forEach((b,j)=>{r[b]=e[j]});break}}}return[i,r]}}class P{path="";parsed=[];args=[];constructor(t){nt(this,{path:t,...ot(t)})}}class _t{static rand(t=6,n){if(n)return Math.floor(Math.random()*(n-t+1)+t);return Math.floor(Math.random()*t)+1-1}static fill(t,n=null){return Array(t).fill(n)}static new({dom:t,id:n,inner:r}){let i=document.createElement(t);if(n)i.id=n;if(r)i.innerHTML=r;return i}static randFrom(t){if(Array.isArray(t)){let n=t.length,r=this.rand(0,n-1);return t[r]}else if(typeof t=="object"){let n=J(t),r=n.length,i=this.rand(0,r-1);return n[i]}}static makeID=p;static reClass=Vt;static get O(){return{vals:y,keys:J,items:h,has:Yt,ass:T,len:(t={})=>J(t).length}}}var Tt={},Z={};class kt{stream;url;constructor(t,n){if(this.url=t,t in Tt)this.stream=Tt[t];else this.stream=new EventSource(t,{withCredentials:n}),Tt[t]=this.stream,Z[this.url]={}}on(t){let n=this.stream;return h(t).forEach(([r,i])=>{if(r in Z[this.url])Z[this.url][r].forEach((o)=>{this.stream.removeEventListener(r,o)}),Z[this.url][r]=[];if(n.addEventListener(r,i),!(r in Z[this.url]))Z[this.url][r]=[];Z[this.url][r].push(i)}),this}}function vt(t,n=!0){return new kt(t,n)}class tn{value;constructor(t){this.value=t}get str(){return String(this.value).toString()=="null"?null:String(this.value).toString()}get int(){if(R(this.value))return parseInt(this.value);else return null}get float(){if(R(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;func;storage;constructor(t,n="local"){if(typeof t=="object"){let[r,i]=h(t)[0];this.key=r,this.func=i}else this.key=t,this.func=null;this.storage=n=="local"?localStorage:sessionStorage}get as(){return new tn(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 z(t)};var nn={get:(t)=>new z(t,"session")};class st extends P{id;cls;constructor(t,n,r){super(t);this.id=n;this.cls=r}}class rn extends P{id;cls;constructor(t,n,r){super(t);this.id=n;this.cls=r}}class ut extends dt{ImportMeta;config;storage=new Q;errorStorage=new Q;wssStorage=new Q;route;error;wss;constructor(t,n){super();this.ImportMeta=t;this.config=n;this.route=(r)=>{return(i)=>{return this.storage.set(new st(r,p(5),i)),i}},this.wss=(r)=>{return(i)=>{return this.wssStorage.set(new rn(r,p(5),i)),i}},this.error=(...r)=>{return(i)=>{if(r.length)r.forEach((o)=>{this.errorStorage.set(new st(o.toString(),p(5),i))});else this.errorStorage.set(new st("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 N=new f,V=(t)=>{if(c)return;let n=N.get(t);if(n?.isConnected)return n;N.delete(t);let r=document.getElementById(t);if(!r)return;return N.set(t,r),r};function on(){let t=[];return N.forEach((n,r)=>{if(!n.isConnected)t.push(r),N.delete(r)}),t}function Y(t,n,{id:r="state",init:i}={}){let o=[],e=()=>n.map((u)=>u.value),s=()=>{t(...e())};if(n.forEach((u)=>{o.push(u.hook(s)(r))}),i)s();return()=>{o.forEach((u)=>u())}}var en=(t)=>{t.forEach((n)=>n())};var Ln=(t,n)=>{for(let[r,i]of t){let o=V(r);if(!o){t.delete(r);continue}i.forEach((e)=>{e.call(o,n)})}};class I extends EventTarget{options;hooks=new f;states=new f;_value;listening=!1;end;constructor(t,n){super();this.options=n;this._value=t}get value(){return this._value}set value(t){if(C(t)||Xt(t))return;if(k(this._value)||a(this._value)){let n=lt(this._value,t);if(!Ct(n))return}else if(this._value instanceof Set){if(!Bt(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=(n)=>{if(en(this.hooks),Ln(this.states,n.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,n){return(r)=>{if(rt(r,this.states).set(n,t),!c&&!this.listening)this.end=this.listen;return()=>{if(this.states.has(r))this.states.get(r)?.delete(n)}}}hook(t){return(n)=>{if(this.hooks.set(n,t),!c&&!this.listening)this.end=this.listen;return()=>{if(this.hooks.has(n))this.hooks.delete(n)}}}}function A(t){return new I(t)}var bt=(t)=>{if(a(t))return t.join(" ");else if(w(t)){if(at(t))return E(t)}else if(x(t))return bt(t());else if(t!==void 0&&t!==null)return v(t)?t?"":"false":String(t);return""};function Mn(t,n){switch(n??t){case"style":return function(r){this.style.setProperty(t,r)};default:return function(r){this.setAttribute(t,r)}}}class yt{attr;constructor(t={}){this.attr=t}get(t,n=this.attr,r){let i=(o,e)=>{if(a(e))t.attr_push(o,bt(e));else if(e instanceof I){let s=r?`${r}_${o}`:o;t.states.push(e.call(Mn(o,r),s)),i(o,e.value)}else if(w(e)){if(at(e)&&!r)this.get(t,e,o)}else t.attr_push(o,bt(e),r)};h(n).forEach(([o,e])=>{if(["on"].includes(o))w(n.on)&&t.events.obj(n.on);else i(o,e)})}}class W{xid;IDM;map=new f;states=[];events=new f;OZ;constructor(t,n=new d,r){this.xid=t;this.IDM=n;this.OZ=r??new ft}attr_push(t,n,r){let i=r??t;if(!this.map.has(i))this.map.set(i,[]);let o=r?`${S(t)}:${n};`:n;this.map.get(i).push(o)}get attr(){let t=[""];return this.map.forEach((n,r)=>{let i=n.join("");t.push(i?`${r}="${i}"`:r)}),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,n,r)=>{return t.addEventListener(n,r),()=>{t.removeEventListener(n,r)}},O={};class ft{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:n,events:r,states:i}=t;if(n){if(r.size)this.events.set(n,r);if(i.length)this.states.set(n,i)}return this}push(t){return t.events.forEach((n,r)=>{n.forEach((i,o)=>{rt(r,this.events).set(o,i)})}),t.states.forEach((n,r)=>{G(r,this.states).push(...n)}),this}get stage(){return this.events.forEach((t,n)=>{this.events.delete(n);let r=V(n);if(!r){this.events.delete(n);return}t.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 e=o.replace(/^win/,"");this.windowEvents.init(e,new f).set(n,i);break;case"watch":let[s,u,m]=i.apply(r,[r]),l=a(u)?u:[u],b=()=>l.map((D)=>D.value),j=()=>s(...b());if(m)j();l.forEach((D)=>G(n,this.resetST).push(D.call(j,n+"_watch")(n)));break;default:G(n,this.resetEV).push(Rn(r,o,i))}})}),this.processWindowEvents,this.states.forEach((t,n)=>{this.states.delete(n),t.forEach((r)=>{G(n,this.resetST).push(r(n))})}),this}get processWindowEvents(){let t=(n,r)=>{let i=(o)=>{r.forEach((e,s)=>{let u=V(s);if(u)e.call(u,o);else this.windowEvents.get(n)?.delete(s)})};return window.addEventListener(n,i),()=>{window.removeEventListener(n,i)}};return this.windowEvents.forEach((n,r)=>{if(n.size){if(!O[r])O[r]=t(r,n)}else if(O[r])O[r](),delete O[r]}),this}reset(t){return t.forEach((n)=>{this.windowEvents.forEach((r,i)=>{if(r.has(n))r.delete(n)}),this.resetEV.get(n)?.forEach((r)=>{r()}),this.resetST.get(n)?.forEach((r)=>{r()}),this.resetST.delete(n),this.resetEV.delete(n)}),this}RPS(t){if(t){let n=on();this.reset(n);let r=t.keys;if(r.length)this.reset(r).push(t).stage}return this}}var q=new ft;var Sn=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],Fn=(t)=>Sn.includes(t);function Zn(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var mt=(t,n)=>{if(a(t))return t.map((r)=>mt(r,n)).join("");else if(t instanceof L){let r=t.__(n.IDM),{ctx:i,oz:o}=r;return n.OZ.push(o),i}else if(w(t))return E(t);else if(x(t))return mt(t(),n);else if(t!==void 0&&t!==null)return Zn(t);return""},sn=(t,n)=>{let r=new d(t),i=new W(r.id,r);return{ctx:mt(n,i),catt:i}};function In(t){let n=this.id;if(n){let{ctx:r,catt:i}=sn(n,t);if(this.innerHTML!==r)this.innerHTML=r,q.RPS(i.OZ)}}var xt=(t,n,r,i=[])=>{if(a(t))t.forEach((o)=>{xt(o,t.length,r,i)});else if(t instanceof I)if(n>1)xt(M("div",{},t),n,r,i);else{let o=t.value,e=o instanceof L?"dom":"ctx",{ctx:s,catt:u}=sn(r.xid+"-0",o);r.xid=u.xid,i.push(s),r.OZ.push(u.OZ),r.states.push(t.call(In,e))}else i.push(mt(t,r))};class Et{tag;ctx;closing;constructor(t,n){this.tag=t;this.ctx=n;let r=Fn(t);this.closing=r?"":`</${t}>`}process(t,n=this.ctx,r=[]){return n.forEach((i)=>{xt(i,n.length,t,r)}),r.join("")}get(t){let n=this.process(t);if(t.events.size||t.states.length)t.id=t.xid;return`<${this.tag}${t.attr}>${n}${this.closing}`}}class L{tag;constructor(t,n={},...r){this.tag=t;nt(this,{attr:new yt(n),ctx:new Et(t,r)})}__(t=new d){let n=t.mid,r=new W(n,t);return this.attr.get(r),{ctx:this.ctx.get(r),oz:r.OZ.set(r),id:r.id}}}function M(t,n={},...r){if(x(t))return t(n??{},...r);return new L(t,n??{},r)}var Xn=(t,...n)=>n;class $t{e;opt;constructor(t){this.e=t;this.opt={duration:500,easing:"ease-in-out",fill:"forwards"}}animate(t,n={}){return this.e.animate(t,n)}get slide(){let t=({x:n=0,y:r=0},i={})=>{T(this.opt,i);let o=[[n,r],[0,0]].map(([e,s])=>({transform:`translateX(${e}rem) translateY(${s}rem)`}));return this.e.animate(o,this.opt),this};return{left:(n={})=>{return t({x:-2},n)},right:(n={})=>{return t({x:2},n)},up:(n={})=>{return t({y:2},n)},down:(n={})=>{return t({y:-2},n)}}}fade(t={}){T(this.opt,t);let n=[0,1].map((r)=>({opacity:r}));return this.e.animate(n,this.opt),this}shake(t="Y",n={}){T(this.opt,n);let r=[0,5,-5,5,0].map((i)=>({transform:`translate${t}(${i}px)`}));return this.e.animate(r,this.opt),this}color(t=[],n={}){T(this.opt,n);let r=Array.isArray(t)?t.map((i)=>({color:i})):{color:t};return this.e.animate(r,this.opt),this}bg(t=[],n={}){T(this.opt,n);let r=Array.isArray(t)?t.map((i)=>({backgroundColor:i})):{backgroundColor:t};return this.e.animate(r,this.opt),this}bounce(t=1,n={}){T(this.opt,n);let r=[0.5,t,1].map((i)=>({transform:`scale(${i})`}));return this.e.animate(r),this}}class jt{e;query;constructor(t,n){this.e=t;this.query=n}get a(){return new $t(this)}get all(){if(this.query){let t=document.querySelectorAll(this.query);if(t.length)return Array.from(t).map((n)=>n)}return[]}get attr(){let t=this.e;return{has:(n)=>{return t.hasAttribute(n)},get:(n)=>{return t.getAttribute(n)},del:(n)=>{return t.removeAttribute(n),this},set:(n)=>{for(let r in n){let i=n[r];if(n[r]!==void 0)t.setAttribute(r,i?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 X(t);return}get parent(){let t=this.e.parentElement;if(t)return new X(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,n=this;return{set:(r,i=0)=>{let o=t,e=()=>{h(r).forEach(([s,u])=>{if(s in o){if(o[s]!==u)o[s]=u}else if(u!==null)t.setProperty(s,String(u))})};if(x(i))n.on("transitionend",i);if(It(i))setTimeout(e,i);else e();return n},get:(r)=>{return t.getPropertyValue(r.toString())},del:(...r)=>{r.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:n,oz:r}=wt(t,Ht(this.id));this.e.insertAdjacentHTML("beforeend",n),q.RPS(r)}set appendfirst(t){let{ctx:n,oz:r}=wt(t,Ht(this.id));this.e.insertAdjacentHTML("afterbegin",n),q.RPS(r)}set inner(t){let{ctx:n,oz:r}=wt(t,Ht(this.id));this.e.innerHTML=n,q.RPS(r)}set disabled(t){let n=this.e;if("disabled"in n)n.disabled=t}set id(t){this.e.id=t}set value(t){let n=this.e;n.value=t}}var wt=(t,n)=>{if(t instanceof L)return t.__(new d(n));return{ctx:t,oz:void 0}},Ht=(t)=>t?`${t}-0`:t;class X extends jt{constructor(t,n){super(t,n)}add(...t){return this.e.classList.add(...t.map((n)=>n.replace(/[^\w-]/,""))),this}remove(...t){return this.e.classList.remove(...t.map((n)=>n.replace(/[^\w-]/,""))),this}toggle(t,n){let r=typeof t!="string"?t.apply(this):t,i=this.e.classList;return r.split(" ").forEach((o)=>{i.toggle(o,n)}),this}has(t){return this.e.contains(t)}insert(t){return{HTML:(...n)=>{return n.forEach((r)=>{this.e.insertAdjacentHTML(t,r)}),this},element:(...n)=>{return n.forEach((r)=>{this.e.insertAdjacentElement(t,r)}),this},text:function(...n){return n.forEach((r)=>{this.e.insertAdjacentText(t,r)}),this}}}is(t){let n=this.e.classList.value.split(" "),r=this.e.tagName.toLocaleLowerCase(),i=!0,o=!0;if(t.dom)o=t.dom==r?!0:!1;if(t.class)if(Array.isArray(t.class))t.class.forEach((e)=>{i=i?n.includes(e):!1});else i=i?n.includes(t.class):!1;return i&&o}on(t,n,r=!1){let i=!1;if(t.indexOf("touch")>-1)i=!0;return this.e.addEventListener(t,n,{capture:r,passive:i}),this}remove_on(t,n,r=!1){return this.e.removeEventListener(t,n,r),this}timed(t,n=250){return setTimeout(()=>t(this),n),this}animate(t,n,r){let i={duration:300,easing:"ease",fill:"forwards"};if(x(n))r=n;else T(i,n);let o=this.e.animate(t,i);if(r)o.finished.then(r);return this}}function g(t){if(tt(t)){let n=document.querySelector(t);if(n)return new X(n,t);return}else return new X(t)}class ht extends ct{path;args;id;status;lang;import;_data={};constructor(t,n={},r,i=200){super();this.path=t;this.args=n;this.id=r;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 a(t)?t:[t]}if(this.import){let t=this.import;return a(t)?t:[t]}return[]}getHeadAttr(t={},...n){let r=new U;if($(t))r.head=t;r.id=this.id;let i=r.head;return n.forEach((o)=>{i.map(o)}),Jn(r,this),i}set data(t){T(this._data,t)}get data(){return this._data}}class Dt extends ht{head(){this.title=`error ${this.status}`}body(){return M("div",{},this.path+" not found...")}}function Jn(t,n){let{link:r,script:i,meta:o,title:e,base:s,description:u,css:m}=n;if(t.head={title:e,base:s,meta:o,link:r,script:i},u)t.head={meta:[{name:"description",content:u}]};if(m){let b=(a(m)?m:[m]).map((j)=>({rel:`${c?"preload ":""}stylesheet`,href:j,as:"style"}));if(t.head.lacks("link"));t.head={link:[...b]}}}function un(t){let n=[];if(t?.length){let{href:r,target:i}=t[0],o=g("base");if(o)o.attr.set({href:r,target:i});else{let e=g(document.createElement("base"));e.attr.set({href:r,target:i}),document.head.append(e.e)}}else{let r=g("base")?.unload;r&&n.push(r)}return n}var fn=new f;async function mn(t,n=!1){let r=_.value,i={};if(g("link")?.all.forEach((o)=>{let e=g(o),s=e.attr.get("href");if(s){let u=e.attr.get("rt");if(n){let m=fn.get(r);if(m){if(!m.has(s))i[s]=e.unload}else i[s]=e.unload}else if(u)i[s]=e.unload}}),t&&$(t))for(let o of y(t)){let e=o.href;if(!(e in i))try{if(!n){o.rt=!0;let s=fn.init(r,new Set);if(!s.has(e))s.add(e)}await pt(o)}catch(s){H.p=s}else delete i[e]}return y(i)}var Un=["charset","name","property","http-equiv"];function hn(t){let n={};if(g("meta")?.all.forEach((r)=>{let i=r.attributes;for(let o of Un)if(o in i){let e=i[o].value;n[`${o}_${o==="charset"?"":e}`]=r}}),t)h(t).forEach(([r,i])=>{if(r in n)g(n[r]).attr.set(i),delete n[r];else{let o=g(document.createElement("meta"));o.attr.set(i),document.head.append(o.e)}});return y(n).map((r)=>g(r).unload)}var an=new f;async function gn(t,n=!1){let r=_.value,i={};if(g("script[yid]")?.all.forEach((o)=>{let e=g(o),s=e.attr.get("yid");if(s){let u=e.attr.get("rt");if(n){let m=an.get(r);if(m){if(!m.has(s))i[s]=e.unload}else i[s]=e.unload}else if(u)i[s]=e.unload}}),t){for(let o of t)if("yid"in o)if(o.yid in i)delete i[o.yid];else try{if(!n){o.rt=!0;let e=o.yid,s=an.init(r,new Set);if(!s.has(e))s.add(e)}await Nt(o)}catch(e){H.p=e}}return y(i)}async function ln(t,n,r=!1){let i=[];if(c)return[];let o=t.get("title")??"";if(r){let{pushState:s}=this.config,u=this.path.value;if(s)At(u,o);document.documentElement.lang=n,document.title=o}let e=this.path.value;if(r)i.push(...un(t.get("base"))),i.push(...hn(t.get("meta")));return i.push(...await mn(t.get("link"),r)),i.push(...await gn(t.get("script"),r)),i}function At(t,n){let r=window.location.pathname;if(t&&r!==t)history.pushState({},n??"",t)}class qt{lang;head="";constructor(t,n){if(this.lang=t,n)this.head=Kt(n)}body(t,n,r){return[`<!DOCTYPE html><html lang="${this.lang}">`,`<head>${this.head}</head>`,`<body id="${n??p(5)}"${r?" "+r:""}>${t}</body>`,"</html>"].join("")}}class Lt{path;args;isConnected=A(!1);data={};constructor(t,n={}){this.path=t;this.args=n}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 B=new f;class Mt{yra;constructor(t){this.yra=t}async load(t){if(!B.has(t)){let[r,i]=await this.yra.loadWSS(t);if(!r)return;let{cls:o,path:e,id:s}=r,u=new o(e,i).connect;return B.set(t,u),u}let n=B.get(t);return n.reconnect,n}unload(t){if(B.has(t)){let n=B.get(t);if(!n)return;n.disconnect,B.delete(t)}}}function Qn(t,n,r){let i={...t.on??{},click(o){o.preventDefault(),r.value=g(this).path}};return delete t.on,M("a",{...t,on:{...i}},...n)}function Yn(t,n,r){let{classes:i}=t.config,{load:o,on:e,...s}=n,u={...n.on??{},...!r&&o&&{ready(m){t.load(o)}},...r&&{popstate(m){let l=m.target;t.path.value=l.location.pathname}}};return M("div",{...s,...i&&{class:i},on:u},t.root)}class Rt extends ut{isYRA;unload=!1;hook;root=A([]);socket;id=p(4);path=A("");A;Main;load;constructor(t,n={},r=!1){super(t,n);this.isYRA=r;this.socket=new Mt(this),this.A=(i,...o)=>{return Qn(i,o,this.path)},this.Main=(i)=>{return Yn(this,i,r)},this.load=async(i,o={})=>{if(this.hook)this.hook();if(i)this.path.value=i,await this.render(i,404,o),this.hooker();return this}}hooker(){let t={},n=this.path.value;if(this.hook)this.hook();this.hook=Y(async(r)=>{if(t[n]=window.scrollY,(await this.render(r,404)).done)window.scrollTo({top:t[r]??0,behavior:"instant"}),n=r},[this.path],{id:"router"})}async class(t,n,r=!1){let[i,o]=await this.getPath(t);if(i&&!r){let{cls:e,path:s,id:u}=i;return new e(s,o,u)}else return Wn.call(this,t,n)}async fetch(t){if(t)try{if(t.fetch){let n=await t.fetch();if(k(n)&&$(n))t.data=n}}catch(n){H.p=n}}async processHead(t,n={}){return t?await this.processClassHead(t,n):await this.processDefaultHead(n)}async processClassHead(t,n){if(t.head)await t.head();return t.getHeadAttr(n,this.htmlHead)}async processDefaultHead(t){let n=new U;if($(t))n.head=t;return n.head.map(this.htmlHead),n.head}async render(t,n=404,r={},i={},o=!0,e=!1){if(c)this.path.value=t;let s=await this.class(t,n??Cn(),e);s.data=r,await this.fetch(s);let u=await this.processHead(s,i);if(!s)return{lang:this.lang,heads:u,done:!1};let m=await s.loader();if(o){let l=await ln.call(this,u,s?.lang||this.lang,this.unload);if(o)l.forEach((b)=>b())}if(m.length)this.root.value=m;else await this.render(t,n,r,i,o,!0);return{heads:u,lang:s.lang??this.lang,done:!0}}}async function Wn(t,n){let[r,i]=await this.loadError(n??0);if(r){let{cls:o,id:e}=r;return new o(t,i,e,n)}else{let o=new Dt(t,i,p(5));return o.title=`error ${n}`,o}}var _=A("");class cn extends Rt{unload=!0;constructor(t,{classes:n,pushState:r=!0}={}){super(t,{classes:n,pushState:r},!0);this.path=_,this.head({meta:[{charset:"utf-8"},{name:"viewport",content:"width=device-width, initial-scale=1.0"}]}),this.load=async(i=location.pathname,o={})=>{if(this.hook)this.hook();if(i)this.path.value=i;if(gt)this.render(i,404,o).then(()=>{if(i&&this.config.pushState)At(i,document.title);Bn.call(this,this.Main({})),this.hooker()});return this}}async html({path:t,data:n={},status:r=200,attr:i=""}){let o={script:[{type:"module",src:this.ImportMeta.file}]};Gn(o,r);let{lang:e,heads:s}=await this.render(t,r,n,o,!1),{ctx:u}=this.Main({}).__(new d(this.id));return new qt(e,s).body(u,this.id,i)}}function Bn(t){let n=document.body.id,{oz:r,id:i}=t.__(new d(n));if(this.id=i||this.id,!r)return;q.push(r),requestAnimationFrame(()=>{q.stage})}function Cn(){if(gt)return parseInt(g('meta[name="error-code"]')?.attr.get("content")??"404");return 404}var Gn=(t,n)=>{switch(n){case 404:t.meta=[{name:"error-code",content:n.toString()}];return;default:return}};class St{state;body;click;constructor({toggle:t=[],initialState:n=!1}={}){this.state=A(n);let r=this.state;this.click=function(){r.value=!r.value},this.loader(t)}loader(t){if(typeof window==="undefined")return;let n=K.get("LOCAL_SCHEME"),r=this.isDark,i=n.as.bool,o=K.get({IS_DARK:()=>this.state.value});if(i!=null&&i!==r)this.state.value=!i,o.save,n.set=r;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),Y(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,n.set=l})}get isMatchMediaSupported(){return window.matchMedia&&typeof window.matchMedia==="function"}get isDark(){return window.matchMedia("(prefers-color-scheme: dark)").matches}toggle(t,n,r){if(n)t.add(...r);else t.remove(...r)}}St=Ft([Gt,Zt("design:paramtypes",[Object])],St);var Ve=(t,n)=>{return`${t.replace(/\/+$/,"")}/${n.replace(/^\.\/+/,"")}`},Oe=(t)=>{return(n)=>{t(n)}},_e=(t)=>{return(n)=>{t(n)}};export{Lt as websocket,Y as stateHook,nn as session,Ve as resolvePath,ut as minClient,K as local,Xn as frag,vt as eventStream,M as dom,ht as doc,pt as cssLoader,Dn as addCSS,_t as __,cn as Yvee,I as Stateful,A as State,Oe as Routes,Rt as Router,it as Meta,_e as Errors,L as Dom,St as ColorScheme,H as $$,g as $};
|
|
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 $};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yvee",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "Yvee JS framework",
|
|
5
5
|
"author": "Marky <markjotep@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,18 +25,10 @@
|
|
|
25
25
|
"url": "https://github.com/MARKjotep/yvee/issues"
|
|
26
26
|
},
|
|
27
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
|
-
},
|
|
28
|
+
"dependencies": {},
|
|
36
29
|
"devDependencies": {
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"@types/bun": "^1.2.2"
|
|
30
|
+
"rollup": "^4.34.8",
|
|
31
|
+
"rollup-plugin-dts": "^6.1.1"
|
|
40
32
|
},
|
|
41
33
|
"peerDependencies": {
|
|
42
34
|
"typescript": "^5.7.3"
|