essor 0.0.13 → 0.0.14-beta.11
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/essor.cjs.js +7 -41
- package/dist/essor.cjs.js.map +1 -1
- package/dist/essor.d.cts +1 -1
- package/dist/essor.d.ts +1 -1
- package/dist/essor.dev.cjs.js +107 -146
- package/dist/essor.dev.esm.js +107 -146
- package/dist/essor.esm.js +6 -9
- package/dist/essor.esm.js.map +1 -1
- package/package.json +4 -4
package/dist/essor.esm.js
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* essor v0.0.
|
|
2
|
+
* essor v0.0.14-beta.11
|
|
3
3
|
* (c) 2023-Present jiangxd <jiangxd2016@gmail.com>
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
6
|
-
var Rt="0.0.13";var T=t=>t!==null&&typeof t=="object";var p=Array.isArray;function J(t){return typeof t=="string"}function ie(t){return t===null}function $t(t){return typeof t=="symbol"}function Y(t){return j.call(t)==="[object Set]"}function nt(t){return j.call(t)==="[object WeakMap]"}function st(t){return j.call(t)==="[object WeakSet]"}function Z(t){return j.call(t)==="[object Map]"}function At(t){return t==null}var g=t=>typeof t=="function";function it(t){return t===!1||t===null||t===void 0}var jt=t=>["string","number","boolean","symbol","undefined"].includes(typeof t)||ie(t);var ot=t=>j.call(t)==="[object Object]";function ct(t){return J(t)?!Number.isNaN(Number(t)):!1}var j=Object.prototype.toString;var oe=Object.prototype.hasOwnProperty,Q=(t,e)=>oe.call(t,e);function at(t){return p(t)?t.flat():[t]}var M=(t,e)=>t!==e&&(t===t||e===e),lt=Function.prototype;function P(t,e){return J(t)?t.indexOf(e)===0:!1}function Lt(t){return t.replaceAll(/["&'<>]/g,e=>{switch(e){case"&":return "&";case"<":return "<";case">":return ">";case'"':return """;case"'":return "'";default:return e}})}function L(t,e){return p(e)?e.includes(t):g(e)?e(t):!1}var kt=t=>t.replaceAll(/[A-Z]+/g,(e,r)=>`${r>0?"-":""}${e.toLocaleLowerCase()}`);var It=t=>t.charAt(0).toUpperCase()+t.slice(1);function x(t,...e){console.warn.apply(console,[`[Essor warn]: ${t}`].concat(e));}var ce=Object.defineProperty,ae=Object.defineProperties,le=Object.getOwnPropertyDescriptors,Ht=Object.getOwnPropertySymbols,ue=Object.prototype.hasOwnProperty,fe=Object.prototype.propertyIsEnumerable,Ft=(t,e,r)=>e in t?ce(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,I=(t,e)=>{for(var r in e||(e={}))ue.call(e,r)&&Ft(t,r,e[r]);if(Ht)for(var r of Ht(e))fe.call(e,r)&&Ft(t,r,e[r]);return t},he=(t,e)=>ae(t,le(e)),ft=[],ht=[],Kt=Promise.resolve(),dt=!1;function bt(t){return t?Kt.then(t):Kt}function de(t){ft.includes(t)||(ft.push(t),Ut());}function Ut(){dt||(dt=!0,bt(ge));}function pe(t){me(t,ht);}function me(t,e){e.includes(t)||(e.push(t),Ut());}function ge(){dt=!1,ve();let t;for(;t=ft.shift();)t&&t();}function ve(){for(;ht.length>0;){let t=ht.shift();t&&t();}}function be(t,e){return e==="sync"?()=>t():e==="pre"?()=>pe(t):()=>{bt(()=>de(t));}}var S=null,pt=new WeakMap,ut=new WeakMap,H=Symbol("ReactiveSymbol"),F=Symbol("__raw"),Dt=Symbol("SignalValueKey"),Gt=Symbol("ComputedValueKey"),mt=Symbol("ReactiveArrayKey"),v=Symbol("ReactiveCollectionKey"),O=Symbol("ReactiveWeakCollectionKey"),gt=!1,V=new Set;function h(t,e){if(!S)return;let r=pt.get(t);r||(r=new Map,pt.set(t,r));let n=r.get(e);n||(n=new Set,r.set(e,n)),n.add(S);}function b(t,e){let r=pt.get(t);if(!r)return;let n=r.get(e);n&&n.forEach(s=>{if(Q(s,"active")&&!s.active){n.delete(s);return}gt?V.add(s):s();});}var _t=class{constructor(t,e=!1){this.__signal=!0,this.__shallow=e,this.__value=t;}get value(){return h(this,Dt),T(this.__value)&&!this.__shallow?G(this.__value):this.__value}set value(t){m(t)&&(t=t.peek()),M(t,this.__value)&&(this.__value=t,b(this,Dt));}peek(){return this.__value}};function Nt(t){return m(t)?t:new _t(t)}function rr(t){return new _t(t,!0)}function Xt(t){return new _t(t,!0)}function m(t){return !!(t&&(t!=null&&t.__signal))}var _e=class{constructor(t){this.fn=t,this.__computed=!0;let e=S;S=this.run.bind(this),this.__value=this.fn(),S=e;}peek(){return this.__value}run(){let t=this.fn();M(t,this.__value)&&(this.__value=t,b(this,Gt));}get value(){return h(this,Gt),this.__value}};function Ne(t){return new _e(t)}function Jt(t){return !!(t&&t.__computed)}function K(t,e={}){let{flush:r="pre",onTrack:n,onTrigger:s}=e;function i(){let a=S;S=i.init?i:i.scheduler,t(),s&&s(),S=a;}let o=be(i,r);return i.scheduler=o,i.init=!0,i.active=!0,n&&n(),i(),()=>{i.active=!1,S=null;}}function nr(t,e){return !t||!T(t)?(x("initialValues must be an object,will return initial value!",t),t):Object.entries(t).reduce((n,[s,i])=>(n[s]=L(s,e)||m(i)?i:Nt(i),n),{})}function f(t){return t&&(D(t)?t[F]:m(t)?t.peek():p(t)?t.map(e=>f(e)):ot(t)?Object.fromEntries(Object.entries(t).map(([e,r])=>[e,f(r)])):t)}function D(t){return !!(t&&typeof t=="object"&&t[H])}function yt(t,e){return G(t,!1,e)}function sr(t,e){return G(t,!0,e)}var ye=(t,e)=>({get(r,n,s){if(n===H)return !0;if(n===F)return r;let i=Reflect.get(r,n,s),o=m(i)?i.value:i;return L(n,e)?o:(h(r,n),T(o)&&!t?G(o):o)},set(r,n,s,i){if(L(n,e))return Reflect.set(r,n,s,i),!0;let o=Reflect.get(r,n,i);m(o)&&(o=o.value),m(s)&&(s=s.value);let a=Reflect.set(r,n,s,i);return M(s,o)&&b(r,n),a},deleteProperty(r,n){let s=Reflect.get(r,n),i=Reflect.deleteProperty(r,n);return s!==void 0&&b(r,n),i}}),Wt=Se();function Se(){let t={};return ["includes","indexOf","lastIndexOf"].forEach(e=>{t[e]=function(...r){let n=f(this);for(let i=0,o=this.length;i<o;i++)h(n,`${i}`);let s=n[e](...r);return s===-1||s===!1?n[e](...r):s};}),["push","pop","shift","unshift","splice","sort","reverse"].forEach(e=>{t[e]=function(...r){let n=f(this),s=n[e].apply(this,r);return b(n,mt),s};}),["forEach","map","filter","reduce","reduceRight","some","every","find","findIndex","findLast","findLastIndex","entries","keys","values"].forEach(e=>{t[e]=function(...r){let n=f(this);return h(n,mt),n[e].apply(this,r)};}),t}var Ee=(t,e)=>({get(r,n,s){if(n===H)return !0;if(n===F)return r;if(Wt.hasOwnProperty(n))return Reflect.get(Wt,n,s);let i=Reflect.get(r,n,s);return L(n,e)?i:(ct(n)&&h(r,n),h(r,"length"),T(i)&&!t?G(i):i)},set(r,n,s,i){let o=Reflect.get(r,n,i),a=Reflect.set(r,n,s,i);return M(s,o)&&(ct(n)&&b(r,n),(n==="length"||!o)&&b(r,"length")),a}}),Ce={get(t,e){return e===H?!0:e===F?t:((e===Symbol.iterator||e==="size")&&h(t,v),Reflect.get(Q(qt,e)&&e in t?qt:t,e,t))}},Te={get(t,e){return e===H?!0:e===F?t:Reflect.get(Q(zt,e)&&e in t?zt:t,e,t)}},qt={get(t){let e=f(this);return h(e,v),e.get(t)},set(t,e){let r=f(this),n=r.set(t,e);return b(r,v),n},add(t){let e=f(this),r=e.add(t);return b(e,v),r},has(t){let e=f(this);return h(e,v),e.has(t)},delete(t){let e=f(this),r=e.has(t),n=e.delete(t);return r&&b(e,v),n},clear(){let t=f(this),e=t.size>0,r=t.clear();return e&&b(t,v),r},forEach(t,e){let r=f(this);h(r,v),r.forEach((n,s)=>{t.call(e,n,s,r);});},get size(){let t=f(this);return h(t,v),t.size},keys(){let t=f(this);return h(t,v),t.keys()},values(){let t=f(this);return h(t,v),t.values()},entries(){let t=f(this);return h(t,v),t.entries()},[Symbol.iterator](){let t=f(this);return h(t,v),t[Symbol.iterator]()}},zt={get(t){let e=f(this);return h(e,O),e.get(t)},set(t,e){let r=f(this),n=r.set(t,e);return b(r,O),n},add(t){let e=f(this),r=e.add(t);return b(e,O),r},has(t){let e=f(this);return h(e,O),e.has(t)},delete(t){let e=f(this),r=e.delete(t);return b(e,O),r}};function G(t,e=!1,r){if(!T(t)||D(t))return t;if(ut.has(t))return ut.get(t);let n;p(t)?(h(t,mt),n=Ee(e,r)):Y(t)||Z(t)?(h(t,v),n=Ce):st(t)||nt(t)?(h(t,O),n=Te):n=ye(e,r);let s=new Proxy(t,n);return ut.set(t,s),s}function ir(t){if(!D(t)){x("clearReactive: argument must be a reactive object");return}if(nt(t)||st(t)){x("clearReactive: WeakMap and WeakSet are not clearable");return}we(()=>{p(t)?t.length=0:Y(t)||Z(t)?t.clear():T(t)&&Object.keys(t).forEach(e=>{delete t[e];});});}function we(t){try{gt=!0,t();}finally{gt=!1,Me();}}function Me(){V.size>0&&(V.forEach(t=>t()),V.clear());}function or(t,e,r){return Oe(t,e,r)}var Bt=void 0,tt,vt=!1;function Pe(t){tt=t,vt||(vt=!0,bt(xe));}function xe(){tt==null||tt(),tt=null,vt=!1;}function Oe(t,e,{deep:r,immediate:n}={}){let s,i=p(t);if(m(t)||Jt(t))s=()=>t.value;else if(D(t))s=()=>I({},t);else if(i)s=()=>t.map(c=>Re(c));else if(g(t))s=t;else return x("Invalid source type",t),lt;if(e&&r){let c=s,l=r===!0?1/0:r;s=()=>k(c(),l);}let o=i?Array.from({length:t.length}).fill(Bt):Bt,a=!1,d=()=>{let c=s();M(c,o)&&(n&&e&&(e(c,o),o=c),a&&e&&Pe(()=>{e(c,o),o=c;}),!a&&(o=c));},u=K(d,{flush:"sync"});return a=!0,n&&d(),u}function Re(t){return m(t)||Jt(t)?t.value:D(t)?I({},t):g(t)?t():(x("Invalid source",t),lt)}function k(t,e=1/0,r){if(e<=0||!T(t)||(r=r||new Set,r.has(t)))return t;if(r.add(t),e--,m(t))k(t.value,e,r);else if(p(t))for(let n of t)k(n,e,r);else if(Y(t)||Z(t))t.forEach(n=>{k(n,e,r);});else if(ot(t))for(let n in t)k(t[n],e,r);return t}function $e(t){let{state:e,getters:r,actions:n}=t,s=I({},e),i=yt(e),o=[],a=[],d={patch$(c){Object.assign(i,c),o.forEach(l=>l(i)),a.forEach(l=>l(i));},subscribe$(c){o.push(c);},unsubscribe$(c){let l=o.indexOf(c);l!==-1&&o.splice(l,1);},onAction$(c){a.push(c);},reset$(){Object.assign(i,s);}},u=I(he(I({},i),{state:i}),d);if(r)for(let c in r){let l=r[c];l&&Object.defineProperty(u,c,{get(){return Ne(()=>l.call(u,i)).value},enumerable:!0,configurable:!0});}if(n)for(let c in n){let l=n[c];l&&(u[c]=function(...C){let B=l.apply(i,C);return a.forEach(A=>A(i)),B});}return u}function cr(t){return function(){let e;typeof t=="function"?e=Ae(t):e=t;let r=$e(e);return typeof t=="function"&&Object.keys(e.actions||{}).forEach(n=>{r[n]=e.actions[n].bind(r);}),r}}function Ae(t){let e=new t,r=Object.create(null),n={},s={};return Object.getOwnPropertyNames(e).forEach(i=>{r[i]=e[i];}),Object.getOwnPropertyNames(t.prototype).forEach(i=>{let o=Object.getOwnPropertyDescriptor(t.prototype,i);o&&(typeof o.get=="function"?n[i]=function(){return o.get.call(this)}:typeof o.value=="function"&&i!=="constructor"&&(s[i]=function(...a){return o.value.apply(this,a)}));}),{state:r,getters:n,actions:s}}var Yt="on",Zt="update",q="children",Et="",te="0",je="1",St=" __PLACEHOLDER__ ",Le=class{constructor(){this.renderMode=0;}get isSSG(){return this.renderMode===1}get isSSR(){return this.renderMode===2}get isClient(){return this.renderMode===0}setSSR(){this.renderMode=2;}setSSG(){this.renderMode=1;}setClient(){this.renderMode=0;}},y=new Le,ee=new Map;function ke(t,e){ee.set(t,{index:e});}function Ie(t){var e;return (e=ee.get(t))==null?void 0:e.index}var wt=class W{constructor(){this.hooks={mounted:new Set,destroy:new Set};}addEventListener(){}removeEventListener(){}addHook(e,r){var n;(n=this.hooks[e])==null||n.add(r);}getContext(e){return W.context[e]}setContext(e,r){W.context[e]=r;}initRef(){W.ref=this;}removeRef(){W.ref=null;}clearHooks(){Object.values(this.hooks).forEach(e=>e.clear());}};wt.ref=null;wt.context={};var _=wt;function Ct(t){return t instanceof Mt}var R=1,Mt=class extends _{constructor(t,e={},r){super(),this.template=t,this.props=e,this.key=r,ke(t,R),this.templates=this.processTemplate();}processTemplate(){if(p(this.template)){let t=this.template.join(St);return this.processHtmlString(t).split(St)}return []}processHtmlString(t){return t.replaceAll(/(<[^>]+>)|([^<]+)/g,(e,r,n)=>r?r.includes("data-ci")?e:r.replace(/<\s*([\da-z]+)(\s[^>]*)?>/i,(s,i,o)=>`<${i} data-ci="${R}"${o||""}>`):n&&n.replace(St,"").trim()?`<!--0-${R}-->${n}<!$>`:e)}mount(){this.initRef();let t=this.render();return this.removeRef(),t}render(){if(g(this.template)){let t=this.template(this.props);return Ct(t)?t.mount():String(t)}return this.renderTemplate()}renderTemplate(){return Object.entries(this.props).forEach(([t,e])=>{let r=e.children;this.normalizeProps(e);let n=this.templates.findIndex(s=>s.includes(`data-hk="${t}"`));r&&this.renderChildren(r,n),this.templates[n]=this.templates[n].replace(`data-hk="${t}"`,`data-hk="${t}" ${this.generateAttributes(e)}`);}),this.templates.join("")}normalizeProps(t){Object.entries(t).forEach(([e,r])=>{e==="children"||g(r)?delete t[e]:m(r)&&(t[e]=r.value);});}generateAttributes(t){return Object.entries(t).filter(([e,r])=>e!=="children"&&!g(r)).map(([e,r])=>`${e}="${Lt(String(r))}"`).join(" ")}renderChildren(t,e){t.forEach(([r])=>{R++;let n=this.renderChild(r);this.templates[e]+=n;});}renderChild(t){if(g(t))return this.renderChild(t(this.props));if(m(t))return `<!--1-${R}-->${t.value}<!$>`;if(Ct(t)){let e=t.mount();return g(e)?e(this.props):se(e)}else return `<!--1-${R}-->${t}<!$>`}},re="area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr".split(","),He="a,abbr,acronym,address,applet,area,article,aside,audio,b,base,basefont,bdi,bdo,bgsound,big,blink,blockquote,body,br,button,canvas,caption,center,cite,code,col,colgroup,command,content,data,datalist,dd,del,details,dfn,dialog,dir,div,dl,dt,em,embed,fieldset,figcaption,figure,font,footer,form,frame,frameset,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,i,iframe,image,img,input,ins,kbd,keygen,label,legend,li,link,listing,main,map,mark,marquee,menu,menuitem,meta,meter,nav,nobr,noframes,noscript,object,ol,optgroup,option,output,p,param,picture,plaintext,pre,progress,q,rb,rp,rt,rtc,ruby,s,samp,script,section,select,shadow,small,source,spacer,span,strike,strong,style,sub,summary,sup,table,tbody,td,template,textarea,tfoot,th,thead,time,title,tr,track,tt,u,ul,var,video,wbr,xmp".split(",");function Qt(t){if(E(t)||t instanceof Node||Ct(t))return t;let e=it(t)?"":String(t);return document.createTextNode(e)}function w(t,e,r=null){let n=E(r)?r.firstChild:r,s=y.isSSR;E(e)?e.mount(t,n):n&&!s?n.before(e):s||t.append(e);}function z(t){E(t)?t.unmount():t.parentNode&&t.remove();}function ne(t,e,r){w(t,e,r),z(r);}function Vt(t,e,r){e==="class"?Fe(t,r):e==="style"?Ke(t,r):De(t,e,r);}function Fe(t,e){typeof e=="string"?t.className=e:p(e)?t.className=e.join(" "):e&&typeof e=="object"&&(t.className=Object.entries(e).reduce((r,[n,s])=>r+(s?` ${n}`:""),"").trim());}function Ke(t,e){typeof e=="string"?t.style.cssText=e:e&&typeof e=="object"&&Object.entries(e).forEach(([n,s])=>{t.style.setProperty(kt(n),String(s));});}function De(t,e,r){it(r)?t.removeAttribute(e):r===!0?t.setAttribute(e,""):t instanceof HTMLInputElement&&e==="value"?t.value=String(r):t.setAttribute(e,String(r));}function Ge(t,e){if(t instanceof HTMLInputElement)switch(t.type){case"checkbox":return N(t,"change",()=>{e(!!t.checked);});case"date":return N(t,"change",()=>{e(t.value?t.value:"");});case"file":return N(t,"change",()=>{t.files&&e(t.files);});case"number":return N(t,"input",()=>{let r=Number.parseFloat(t.value);e(Number.isNaN(r)?"":String(r));});case"radio":return N(t,"change",()=>{e(t.checked?t.value:"");});case"text":return N(t,"input",()=>{e(t.value);})}if(t instanceof HTMLSelectElement)return N(t,"change",()=>{e(t.value);});if(t instanceof HTMLTextAreaElement)return N(t,"input",()=>{e(t.value);})}Promise.resolve();function N(t,e,r){return t.addEventListener(e,r),()=>t.removeEventListener(e,r)}function We(t){let e=[],r=[],n=/<\/?([\da-z-]+)([^>]*)>/gi,s=0;for(;;){let i=n.exec(t);if(!i)break;let[o,a]=i,d=o[1]==="/";if(r.push(t.slice(s,i.index)),s=i.index+o.length,d){for(;e.length>0&&e[e.length-1]!==a;){let u=e.pop();u&&r.push(`</${u}>`);}e.length>0&&e.pop();}else re.includes(a)||e.push(a);r.push(o);}for(r.push(t.slice(s));e.length>0;){let i=e.pop();i&&r.push(`</${i}>`);}return r.join("")}function qe(t){return He.includes(t)}function ze(t){return re.includes(t)?`<${t}/>`:`<${t}></${t}>`}function se(t){return m(t)?t.value:t}var Pt=class extends _{constructor(t,e,r){super(),this.template=t,this.props=e,this.key=r,this.emitter=new Set,this.rootNode=null,this.trackMap=new Map,this.key||(this.key=e==null?void 0:e.key),this.proxyProps=this.createProxyProps(e);}createProxyProps(t){return t?yt(t,e=>P(e,Yt)||P(e,Zt)||e===q):{}}get firstChild(){var t,e;return (e=(t=this.rootNode)==null?void 0:t.firstChild)!=null?e:null}get isConnected(){var t,e;return (e=(t=this.rootNode)==null?void 0:t.isConnected)!=null?e:!1}mount(t,e){var r,n,s,i;if(!g(this.template))throw new Error("Template must be a function");if(this.isConnected)return (n=(r=this.rootNode)==null?void 0:r.mount(t,e))!=null?n:[];this.initRef(),this.rootNode=this.template(this.proxyProps);let o=(i=(s=this.rootNode)==null?void 0:s.mount(t,e))!=null?i:[];return this.callMountHooks(),this.patchProps(this.props),this.removeRef(),o}unmount(){var t;this.callDestroyHooks(),this.clearHooks(),(t=this.rootNode)==null||t.unmount(),this.rootNode=null,this.proxyProps={},this.clearEmitter();}callMountHooks(){this.hooks.mounted.forEach(t=>t());}callDestroyHooks(){this.hooks.destroy.forEach(t=>t());}clearEmitter(){for(let t of this.emitter)t();this.emitter.clear();}inheritNode(t){Object.assign(this.proxyProps,t.proxyProps),this.rootNode=t.rootNode,this.trackMap=t.trackMap,this.hooks=t.hooks;let e=this.props;this.props=t.props,this.patchProps(e);}getNodeTrack(t){let e=this.trackMap.get(t);return e||(e={cleanup:()=>{}},this.trackMap.set(t,e)),e.cleanup(),e}patchProps(t){var e;if(t){for(let[r,n]of Object.entries(t))P(r,Yt)&&((e=this.rootNode)!=null&&e.firstChild)?this.patchEventListener(r,n):r==="ref"?this.patchRef(n):P(r,Zt)?this.patchUpdateHandler(r,n):r!==q&&this.patchNormalProp(r,n);this.props=t;}}patchEventListener(t,e){let r=t.slice(2).toLowerCase(),n=N(this.rootNode.nodes[0],r,e);this.emitter.add(n);}patchRef(t){var e,r;t.value=(r=(e=this.rootNode)==null?void 0:e.firstChild)!=null?r:null;}patchUpdateHandler(t,e){this.props[t]=se(e);}patchNormalProp(t,e){let r=this.getNodeTrack(t);r.cleanup=K(()=>{this.proxyProps[t]=g(e)?e():e;});}};function Be(t,e,r,n){let s=new Map,i=Array.from(e.values());if(i.length&&r.length===0)return Ue(t,i,n),s;let o=[],a=Je(r),d=0;for(let[u,c]of r.entries()){let l=i[d],C=$(l,u);for(;l&&!a.has(C);)z(l),e.delete(C),l=i[++d],C=$(l,u);let B=$(c,u),A=e.get(B);if(A&&(c=Xe(t,A,c)),l)if(l===A)d++;else {let Ot=document.createComment("");w(t,Ot,l),o.push([Ot,c]);}else w(t,c,n);s.set(B,c);}return o.forEach(([u,c])=>{ne(t,c,u);}),e.forEach((u,c)=>{u.isConnected&&!s.has(c)&&z(u);}),s}function Ue(t,e,r){if(t.childNodes.length===e.length+(r?1:0))t.innerHTML="",r&&w(t,r);else {let n=document.createRange(),s=e[0],i=E(s)?s.firstChild:s;n.setStartBefore(i),r?n.setEndBefore(r):n.setEndAfter(t),n.deleteContents();}e.forEach(n=>{E(n)&&n.unmount();});}function Xe(t,e,r){return e===r?e:E(e)&&E(r)&&e.template===r.template?(r.inheritNode(e),r):e instanceof Text&&r instanceof Text?(e.textContent!==r.textContent&&(e.textContent=r.textContent),e):(ne(t,r,e),r)}function Je(t){let e=new Map;for(let[r,n]of t.entries()){let s=$(n,r);e.set(s,n);}return e}function $(t,e){if(E(t)){let r=t.key;if(r!=null)return String(r)}return `_$${e}$`}var et=class{constructor(t,e,r){this.template=t,this.props=e,this.key=r,this.treeMap=new Map,this.mounted=!1,this.nodes=[],this.trackMap=new Map,this.bindValueKeys=[],this.parent=null,this.key||(this.key=e==null?void 0:e.key),y.isSSR&&(this.componentIndex=Ie(this.template));}get firstChild(){var t;return (t=this.nodes[0])!=null?t:null}get isConnected(){return this.mounted}addEventListener(){}removeEventListener(){}mount(t,e){var r;if(this.parent=t,this.isConnected)return this.nodes.forEach(i=>w(t,i,e)),this.nodes;p(this.template)&&(this.template=Tt(this.template.join("")));let n=this.template.content.cloneNode(!0),s=n.firstChild;return (r=s==null?void 0:s.hasAttribute)!=null&&r.call(s,"_svg_")&&(s.remove(),s==null||s.childNodes.forEach(i=>{n.append(i);})),this.nodes=Array.from(n.childNodes),y.isSSR?this.mapSSGNodeTree(t):this.mapNodeTree(t,n),w(t,n,e),this.patchProps(this.props),this.mounted=!0,this.nodes}unmount(){var t,e;if(this.trackMap.forEach(r=>{var n;(n=r.cleanup)==null||n.call(r);}),this.trackMap.clear(),this.treeMap.clear(),this.nodes.forEach(r=>z(r)),!this.template.innerHTML&&!this.nodes.length){let r=(e=(t=this.props)==null?void 0:t[te])==null?void 0:e.children;r&&(p(r)?r.forEach(n=>{this.deleteFragmentTextNode(n);}):this.deleteFragmentTextNode(r));}this.nodes=[],this.mounted=!1;}deleteFragmentTextNode(t){var e;jt(t)?(e=this.parent)==null||e.childNodes.forEach(r=>{var n;r.nodeType===Node.TEXT_NODE&&r.textContent===`${t}`&&((n=this.parent)==null||n.removeChild(r));}):z(t);}inheritNode(t){this.mounted=t.mounted,this.nodes=t.nodes,this.trackMap=t.trackMap,this.treeMap=t.treeMap;let e=this.props;this.props=t.props,this.patchProps(e);}mapSSGNodeTree(t){this.treeMap.set(0,t),this.walkNodeTree(t,this.handleSSGNode.bind(this));}mapNodeTree(t,e){let r=1;this.treeMap.set(0,t);let n=s=>{s.nodeType!==Node.DOCUMENT_FRAGMENT_NODE&&this.treeMap.set(r++,s);};this.walkNodeTree(e,n);}walkNodeTree(t,e){t.nodeType!==Node.DOCUMENT_FRAGMENT_NODE&&e(t);let r=t.firstChild;for(;r;)this.walkNodeTree(r,e),r=r.nextSibling;}handleSSGNode(t){var e;if(t.nodeType===Node.COMMENT_NODE){let[r,n]=((e=t.textContent)==null?void 0:e.split("-"))||[];if(+r==0&&+n===this.componentIndex){let s=t.nextSibling;this.treeMap.set(+n,s);}}else if(t.nodeType!==Node.TEXT_NODE){let{ci:r="-1",hk:n}=(t==null?void 0:t.dataset)||{};n&&+r===this.componentIndex&&this.treeMap.set(+n,t);}}patchProps(t){t&&(Object.entries(t).forEach(([e,r])=>{let n=Number(e),s=this.treeMap.get(n);s&&this.patchProp(e,s,r,n===0);}),this.props=t);}patchProp(t,e,r,n){r&&Object.entries(r).forEach(([s,i])=>{s===q&&i?this.patchChildren(t,e,i,n):s==="ref"?r[s].value=e:P(s,"on")?this.patchEventListener(t,e,s,i):this.patchAttribute(t,e,s,i);});}patchChildren(t,e,r,n){if(p(r))r.filter(Boolean).forEach((s,i)=>{var o;let[a,d]=p(s)?s:[s,null],u=At(d)?null:(o=this.treeMap.get(d))!=null?o:null,c=`${t}:${q}:${i}`,l=this.getNodeTrack(c,!0,n);this.patchChild(l,e,a,u);});else {let s=`${t}:${q}:0`,i=this.getNodeTrack(s,!0,n);this.patchChild(i,e,r,null);}}patchEventListener(t,e,r,n){let s=r.slice(2).toLowerCase(),i=this.getNodeTrack(`${t}:${r}`);i.cleanup=N(e,s,n);}patchAttribute(t,e,r,n){var s,i;let o=`update${It(r)}`;if(this.bindValueKeys.includes(r))return;(s=this.props)!=null&&s[o]&&this.bindValueKeys.push(o);let a=this.getNodeTrack(`${t}:${r}`),d=m(n)?n:Nt(n);Vt(e,r,d.value);let u=K(()=>{d.value=m(n)?n.value:n,Vt(e,r,d.value);}),c;(i=this.props)!=null&&i[o]&&!Ye(r)&&(c=Ge(e,l=>{var C;(C=this.props)==null||C[o](l);})),a.cleanup=()=>{u&&u(),c&&c();};}getNodeTrack(t,e,r){var n;let s=this.trackMap.get(t);return s||(s={cleanup:()=>{}},e&&(s.lastNodes=new Map),r&&(s.isRoot=!0),this.trackMap.set(t,s)),(n=s.cleanup)==null||n.call(s),s}patchChild(t,e,r,n){g(r)?t.cleanup=K(()=>{let s=at(r()).map(Qt);y.isSSR?t.lastNodes=this.reconcileChildren(e,s,n):t.lastNodes=Be(e,t.lastNodes,s,n);}):at(r).forEach((s,i)=>{let o=Qt(s),a=$(o,i);y.isSSR?t.lastNodes=this.reconcileChildren(e,[o],n):(t.lastNodes.set(a,o),w(e,o,n));});}reconcileChildren(t,e,r){let n=new Map,s=Array.from(t.childNodes).filter(i=>{var o,a;return i.nodeType===Node.TEXT_NODE&&((o=i.previousSibling)==null?void 0:o.nodeType)===Node.COMMENT_NODE&&((a=i.nextSibling)==null?void 0:a.nodeType)===Node.COMMENT_NODE});return e.forEach((i,o)=>{let a=$(i,o);i.nodeType===Node.TEXT_NODE?s.forEach(d=>{i.textContent===d.textContent&&t.replaceChild(i,d);}):w(t,i,r),n.set(a,i);}),n}};function xt(t,e,r){if(J(t)){if(qe(t)){let n=ze(t);return e={[je]:e},new et(Tt(n),e,r)}else if(t===Et)return e={[te]:e},new et(Tt(Et),e,r)}return g(t)?new Pt(t,e,r):new et(t,e,r)}function Ye(t){return t instanceof Pt}function E(t){return t instanceof Pt||t instanceof et}function Tt(t){let e=document.createElement("template");return e.innerHTML=We(t),e}function pr(t){return xt(Et,{children:p(t.children)?t.children.filter(Boolean):[t.children]})}function mr(t){rt("onMounted"),_.ref&&_.ref.addHook("mounted",t);}function gr(t){rt("onDestroy"),_.ref&&_.ref.addHook("destroy",t);}function rt(t,e){_.ref||console.error(`"${t}"(key: ${$t(e)?e.toString():e}) can only be called within the component function body
|
|
7
|
-
and cannot be used in asynchronous or deferred calls.`);}function
|
|
8
|
-
* @estjs/signal v0.0.
|
|
6
|
+
var jt="0.0.14-beta.11";var C=t=>t!==null&&typeof t=="object";var g=Array.isArray;function Y(t){return typeof t=="string"}function Lt(t){return typeof t=="symbol"}function Z(t){return k.call(t)==="[object Set]"}function st(t){return k.call(t)==="[object WeakMap]"}function it(t){return k.call(t)==="[object WeakSet]"}function Q(t){return k.call(t)==="[object Map]"}function It(t){return t==null}var d=t=>typeof t=="function";function ot(t){return t===!1||t===null||t===void 0}function kt(t){return t?t&&typeof t=="object"&&t.nodeType===1&&typeof t.nodeName=="string":!1}var T=t=>k.call(t)==="[object Object]";function ct(t){return Y(t)?!Number.isNaN(Number(t)):!1}var k=Object.prototype.toString;var ce=Object.prototype.hasOwnProperty,V=(t,e)=>ce.call(t,e);function at(t){return g(t)?t.flat():[t]}var P=(t,e)=>t!==e&&(t===t||e===e),ut=Function.prototype;function O(t,e){return Y(t)?t.indexOf(e)===0:!1}function Ht(t){return t.replaceAll(/["&'<>]/g,e=>{switch(e){case"&":return "&";case"<":return "<";case">":return ">";case'"':return """;case"'":return "'";default:return e}})}function H(t,e){return g(e)?e.includes(t):d(e)?e(t):!1}var lt=t=>{let e=Object.create(null);return r=>e[r]||(e[r]=t(r))},ae=/\B([A-Z])/g,Ft=lt(t=>t.replaceAll(ae,"-$1").toLowerCase()),Kt=lt(t=>t.charAt(0).toUpperCase()+t.slice(1));function x(t,...e){console.warn.apply(console,[`[Essor warn]: ${t}`].concat(e));}var le=Object.defineProperty,fe=Object.defineProperties,he=Object.getOwnPropertyDescriptors,Wt=Object.getOwnPropertySymbols,pe=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable,Dt=(t,e,r)=>e in t?le(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,K=(t,e)=>{for(var r in e||(e={}))pe.call(e,r)&&Dt(t,r,e[r]);if(Wt)for(var r of Wt(e))de.call(e,r)&&Dt(t,r,e[r]);return t},me=(t,e)=>fe(t,he(e)),pt=[],dt=[],Gt=Promise.resolve(),mt=!1;function St(t){return t?Gt.then(t):Gt}function ge(t){pt.includes(t)||(pt.push(t),Xt());}function Xt(){mt||(mt=!0,St(Ee));}function ve(t){be(t,dt);}function be(t,e){e.includes(t)||(e.push(t),Xt());}function Ee(){mt=!1,Se();let t;for(;t=pt.shift();)t&&t();}function Se(){for(;dt.length>0;){let t=dt.shift();t&&t();}}function Ne(t,e){return e==="sync"?()=>t():e==="pre"?()=>ve(t):()=>{St(()=>ge(t));}}var _=null,gt=new WeakMap,ft=new WeakMap,W=Symbol("ReactiveSymbol"),D=Symbol("__raw"),ht=Symbol("SignalValueKey"),Bt=Symbol("ComputedValueKey"),vt=Symbol("ReactiveArrayKey"),b=Symbol("ReactiveCollectionKey"),R=Symbol("ReactiveWeakCollectionKey"),bt=!1,tt=new Set;function h(t,e){if(!_)return;let r=gt.get(t);r||(r=new Map,gt.set(t,r));let n=r.get(e);n||(n=new Set,r.set(e,n)),n.add(_);}function v(t,e){let r=gt.get(t);if(!r)return;let n=r.get(e);n&&n.forEach(s=>{if(V(s,"active")&&!s.active){n.delete(s);return}bt?tt.add(s):s();});}var Yt=class{constructor(t,e=!1){this.__signal=!0,this.__shallow=e,this.__value=t;}get value(){return h(this,ht),C(this.__value)&&!this.__shallow?z(this.__value):this.__value}set value(t){m(t)&&(t=t.peek()),P(t,this.__value)&&(this.__value=t,v(this,ht));}trigger(){v(this,ht);}peek(){return this.__value}};function Nt(t){return m(t)?t:new Yt(t)}function _t(t){return new Yt(t,!0)}function m(t){return !!(t&&(t!=null&&t.__signal))}var _e=class{constructor(t){this.fn=t,this.__computed=!0;let e=_;_=this.run.bind(this),this.__value=this.fn(),_=e;}peek(){return this.__value}run(){let t=this.fn();P(t,this.__value)&&(this.__value=t,v(this,Bt));}get value(){return h(this,Bt),this.__value}};function ye(t){return new _e(t)}function Zt(t){return !!(t&&t.__computed)}function G(t,e={}){let{flush:r="pre",onTrack:n,onTrigger:s}=e;function i(){let a=_;_=i.init?i:i.scheduler,t(),s&&s(),_=a;}let o=Ne(i,r);return i.scheduler=o,i.init=!0,i.active=!0,n&&n(),i(),()=>{i.active=!1,_=null;}}function Qt(t,e){return !t||!C(t)?(x("initialValues must be an object,will return initial value!",t),t):Object.entries(t).reduce((n,[s,i])=>(n[s]=H(s,e)||m(i)?i:Nt(i),n),{})}function f(t){return t&&(B(t)?t[D]:m(t)?t.peek():g(t)?t.map(e=>f(e)):T(t)?Object.fromEntries(Object.entries(t).map(([e,r])=>[e,f(r)])):t)}function B(t){return !!(t&&typeof t=="object"&&t[W])}function yt(t,e){return z(t,!1,e)}function or(t,e){return z(t,!0,e)}var Ce=(t,e)=>({get(r,n,s){if(n===W)return !0;if(n===D)return r;let i=Reflect.get(r,n,s),o=m(i)?i.value:i;return H(n,e)?o:(h(r,n),C(o)&&!t?z(o):o)},set(r,n,s,i){if(H(n,e))return Reflect.set(r,n,s,i),!0;let o=Reflect.get(r,n,i);m(o)&&(o=o.value),m(s)&&(s=s.value);let a=Reflect.set(r,n,s,i);return P(s,o)&&v(r,n),a},deleteProperty(r,n){let s=Reflect.get(r,n),i=Reflect.deleteProperty(r,n);return s!==void 0&&v(r,n),i}}),zt=we();function we(){let t={};return ["includes","indexOf","lastIndexOf"].forEach(e=>{t[e]=function(...r){let n=f(this);for(let i=0,o=this.length;i<o;i++)h(n,`${i}`);let s=n[e](...r);return s===-1||s===!1?n[e](...r):s};}),["push","pop","shift","unshift","splice","sort","reverse"].forEach(e=>{t[e]=function(...r){let n=f(this),s=n[e].apply(this,r);return v(n,vt),s};}),["forEach","map","filter","reduce","reduceRight","some","every","find","findIndex","findLast","findLastIndex","entries","keys","values"].forEach(e=>{t[e]=function(...r){let n=f(this);return h(n,vt),n[e].apply(this,r)};}),t}var Me=(t,e)=>({get(r,n,s){if(n===W)return !0;if(n===D)return r;if(zt.hasOwnProperty(n))return Reflect.get(zt,n,s);let i=Reflect.get(r,n,s);return H(n,e)?i:(ct(n)&&h(r,n),h(r,"length"),C(i)&&!t?z(i):i)},set(r,n,s,i){let o=Reflect.get(r,n,i),a=Reflect.set(r,n,s,i);return P(s,o)&&(ct(n)&&v(r,n),(n==="length"||!o)&&v(r,"length")),a}}),Te={get(t,e){return e===W?!0:e===D?t:((e===Symbol.iterator||e==="size")&&h(t,b),Reflect.get(V(Ut,e)&&e in t?Ut:t,e,t))}},Pe={get(t,e){return e===W?!0:e===D?t:Reflect.get(V(qt,e)&&e in t?qt:t,e,t)}},Ut={get(t){let e=f(this);return h(e,b),e.get(t)},set(t,e){let r=f(this),n=r.set(t,e);return v(r,b),n},add(t){let e=f(this),r=e.add(t);return v(e,b),r},has(t){let e=f(this);return h(e,b),e.has(t)},delete(t){let e=f(this),r=e.has(t),n=e.delete(t);return r&&v(e,b),n},clear(){let t=f(this),e=t.size>0,r=t.clear();return e&&v(t,b),r},forEach(t,e){let r=f(this);h(r,b),r.forEach((n,s)=>{t.call(e,n,s,r);});},get size(){let t=f(this);return h(t,b),t.size},keys(){let t=f(this);return h(t,b),t.keys()},values(){let t=f(this);return h(t,b),t.values()},entries(){let t=f(this);return h(t,b),t.entries()},[Symbol.iterator](){let t=f(this);return h(t,b),t[Symbol.iterator]()}},qt={get(t){let e=f(this);return h(e,R),e.get(t)},set(t,e){let r=f(this),n=r.set(t,e);return v(r,R),n},add(t){let e=f(this),r=e.add(t);return v(e,R),r},has(t){let e=f(this);return h(e,R),e.has(t)},delete(t){let e=f(this),r=e.delete(t);return v(e,R),r}};function z(t,e=!1,r){if(!C(t)||B(t))return t;if(ft.has(t))return ft.get(t);let n;g(t)?(h(t,vt),n=Me(e,r)):Z(t)||Q(t)?(h(t,b),n=Te):it(t)||st(t)?(h(t,R),n=Pe):n=Ce(e,r);let s=new Proxy(t,n);return ft.set(t,s),s}function cr(t){if(!B(t)){x("clearReactive: argument must be a reactive object");return}if(st(t)||it(t)){x("clearReactive: WeakMap and WeakSet are not clearable");return}Oe(()=>{g(t)?t.length=0:Z(t)||Q(t)?t.clear():C(t)&&Object.keys(t).forEach(e=>{delete t[e];});});}function Oe(t){try{bt=!0,t();}finally{bt=!1,xe();}}function xe(){tt.size>0&&(tt.forEach(t=>t()),tt.clear());}function ar(t,e,r){return Ae(t,e,r)}var Jt=void 0,et,Et=!1;function Re(t){et=t,Et||(Et=!0,St($e));}function $e(){et&&et(),et=null,Et=!1;}function Ae(t,e,{deep:r,immediate:n}={}){let s,i=g(t);if(m(t)||Zt(t))s=()=>t.value;else if(B(t))s=()=>K({},t);else if(i)s=()=>t.map(c=>je(c));else if(d(t))s=t;else return x("Invalid source type",t),ut;if(e&&r){let c=s,u=r===!0?1/0:r;s=()=>F(c(),u);}let o=i?Array.from({length:t.length}).fill(Jt):Jt,a=!1,p=()=>{let c=s();P(c,o)&&(n&&e&&(e(c,o),o=c),a&&e&&Re(()=>{e(c,o),o=c;}),!a&&(o=c));},l=G(p,{flush:"sync"});return a=!0,n&&p(),l}function je(t){return m(t)||Zt(t)?t.value:B(t)?K({},t):d(t)?t():(x("Invalid source",t),ut)}function F(t,e=1/0,r){if(e<=0||!C(t)||(r=r||new Set,r.has(t)))return t;if(r.add(t),e--,m(t))F(t.value,e,r);else if(g(t))for(let n of t)F(n,e,r);else if(Z(t)||Q(t))t.forEach(n=>{F(n,e,r);});else if(T(t))for(let n in t)F(t[n],e,r);return t}function Le(t){let{state:e,getters:r,actions:n}=t,s=K({},e),i=yt(e),o=[],a=[],p={patch$(c){Object.assign(i,c),o.forEach(u=>u(i)),a.forEach(u=>u(i));},subscribe$(c){o.push(c);},unsubscribe$(c){let u=o.indexOf(c);u!==-1&&o.splice(u,1);},onAction$(c){a.push(c);},reset$(){Object.assign(i,s);}},l=K(me(K({},i),{state:i}),p);if(r)for(let c in r){let u=r[c];u&&Object.defineProperty(l,c,{get(){return ye(()=>u.call(l,i)).value},enumerable:!0,configurable:!0});}if(n)for(let c in n){let u=n[c];u&&(l[c]=function(...L){let q=u.apply(i,L);return a.forEach(I=>I(i)),q});}return l}function ur(t){return function(){let e;typeof t=="function"?e=Ie(t):e=t;let r=Le(e);return typeof t=="function"&&Object.keys(e.actions||{}).forEach(n=>{r[n]=e.actions[n].bind(r);}),r}}function Ie(t){let e=new t,r=Object.create(null),n={},s={};return Object.getOwnPropertyNames(e).forEach(i=>{r[i]=e[i];}),Object.getOwnPropertyNames(t.prototype).forEach(i=>{let o=Object.getOwnPropertyDescriptor(t.prototype,i);o&&(typeof o.get=="function"?n[i]=function(){return o.get.call(this)}:typeof o.value=="function"&&i!=="constructor"&&(s[i]=function(...a){return o.value.apply(this,a)}));}),{state:r,getters:n,actions:s}}var wt="on",Mt="update",M="children",Tt="",ke="0",He="1",ee="ref",Ct=" __PLACEHOLDER__ ",Fe=class{constructor(){this.renderMode=0;}get isSSG(){return this.renderMode===1}get isSSR(){return this.renderMode===2}get isClient(){return this.renderMode===0}setSSR(){this.renderMode=2;}setSSG(){this.renderMode=1;}setClient(){this.renderMode=0;}},N=new Fe,re=new Map;function Ke(t,e){re.set(t,{index:e});}function We(t){var e;return (e=re.get(t))==null?void 0:e.index}var Ot=class U{constructor(){this.hooks={mounted:new Set,destroy:new Set};}addEventListener(){}removeEventListener(){}addHook(e,r){var n;(n=this.hooks[e])==null||n.add(r);}getContext(e){return U.context[e]}setContext(e,r){U.context[e]=r;}initRef(){U.ref=this;}removeRef(){U.ref=null;}clearHooks(){Object.values(this.hooks).forEach(e=>e.clear());}};Ot.ref=null;Ot.context={};var E=Ot;function Pt(t){return t instanceof xt}var $=1,xt=class extends E{constructor(t,e={},r){super(),this.template=t,this.props=e,this.key=r,Ke(t,$),this.templates=this.processTemplate();}processTemplate(){if(g(this.template)){let t=this.template.join(Ct);return this.processHtmlString(t).split(Ct)}return []}processHtmlString(t){return t.replaceAll(/(<[^>]+>)|([^<]+)/g,(e,r,n)=>r?r.includes("data-ci")?e:r.replace(/<\s*([\da-z]+)(\s[^>]*)?>/i,(s,i,o)=>`<${i} data-ci="${$}"${o||""}>`):n&&n.replace(Ct,"").trim()?`<!--0-${$}-->${n}<!$>`:e)}mount(){this.initRef();let t=this.render();return this.removeRef(),t}render(){if(d(this.template)){let t=this.template(this.props);return Pt(t)?t.mount():String(t)}return this.renderTemplate()}renderTemplate(){return Object.entries(this.props).forEach(([t,e])=>{let r=e.children;this.normalizeProps(e);let n=this.templates.findIndex(s=>s.includes(`data-hk="${t}"`));r&&this.renderChildren(r,n),this.templates[n]=this.templates[n].replace(`data-hk="${t}"`,`data-hk="${t}" ${this.generateAttributes(e)}`);}),this.templates.join("")}normalizeProps(t){Object.entries(t).forEach(([e,r])=>{e===M||d(r)?delete t[e]:m(r)&&(t[e]=r.value);});}generateAttributes(t){return Object.entries(t).filter(([e,r])=>e!==M&&!d(r)).map(([e,r])=>`${e}="${Ht(String(r))}"`).join(" ")}renderChildren(t,e){t.forEach(([r])=>{$++;let n=this.renderChild(r);this.templates[e]+=n;});}renderChild(t){if(d(t))return this.renderChild(t(this.props));if(m(t))return `<!--1-${$}-->${t.value}<!$>`;if(Pt(t)){let e=t.mount();return d(e)?e(this.props):ie(e)}else return `<!--1-${$}-->${t}<!$>`}},ne="area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr".split(",");function Vt(t){if(y(t)||t instanceof Node||Pt(t))return t;let e=ot(t)?"":String(t);return document.createTextNode(e)}function w(t,e,r=null){let n=y(r)?r.firstChild:r,s=N.isSSR;y(e)?e.mount(t,n):n&&!s?n.before(e):s||t.append(e);}function j(t){y(t)?t.unmount():t.parentNode&&t.remove();}function se(t,e,r){w(t,e,r),j(r);}function te(t,e,r){e==="class"?De(t,r):e==="style"?Ge(t,r):Be(t,e,r);}function De(t,e){typeof e=="string"?t.className=e:g(e)?t.className=e.join(" "):e&&typeof e=="object"&&(t.className=Object.entries(e).reduce((r,[n,s])=>r+(s?` ${n}`:""),"").trim());}function Ge(t,e){typeof e=="string"?t.style.cssText=e:e&&typeof e=="object"&&Object.entries(e).forEach(([n,s])=>{t.style.setProperty(Ft(n),String(s));});}function Be(t,e,r){ot(r)?t.removeAttribute(e):r===!0?t.setAttribute(e,""):t instanceof HTMLInputElement&&e==="value"?t.value=String(r):t.setAttribute(e,String(r));}function ze(t,e){if(t instanceof HTMLInputElement)switch(t.type){case"checkbox":return S(t,"change",()=>{e(!!t.checked);});case"date":return S(t,"change",()=>{e(t.value?t.value:"");});case"file":return S(t,"change",()=>{t.files&&e(t.files);});case"number":return S(t,"input",()=>{let r=Number.parseFloat(t.value);e(Number.isNaN(r)?"":String(r));});case"radio":return S(t,"change",()=>{e(t.checked?t.value:"");});case"text":return S(t,"input",()=>{e(t.value);})}if(t instanceof HTMLSelectElement)return S(t,"change",()=>{e(t.value);});if(t instanceof HTMLTextAreaElement)return S(t,"input",()=>{e(t.value);})}function S(t,e,r){return t.addEventListener(e,r),()=>t.removeEventListener(e,r)}function Ue(t){if(!t)return t;let e=[],r=[],n=/<\/?([\da-z-]+)([^>]*)>/gi,s=0;for(;;){let i=n.exec(t);if(!i)break;let[o,a]=i,p=o[1]==="/";if(r.push(t.slice(s,i.index)),s=i.index+o.length,p){for(;e.length>0&&e[e.length-1]!==a;){let l=e.pop();l&&r.push(`</${l}>`);}e.length>0&&e.pop();}else ne.includes(a)||e.push(a);r.push(o);}for(r.push(t.slice(s));e.length>0;){let i=e.pop();i&&r.push(`</${i}>`);}return r.join("")}function qe(t){return ne.includes(t)?`<${t}/>`:`<${t}></${t}>`}function ie(t){return m(t)?t.value:t}var Rt=class extends E{constructor(t,e,r){super(),this.template=t,this.props=e,this.key=r,this.emitter=new Set,this.rootNode=null,this.trackMap=new Map,this.key||(this.key=e&&e.key),this.proxyProps=this.createProxyProps(e);}createProxyProps(t){return t?Qt(t,e=>O(e,wt)||O(e,Mt)||e===M):{}}get firstChild(){var t,e;return (e=(t=this.rootNode)==null?void 0:t.firstChild)!=null?e:null}get isConnected(){var t,e;return (e=(t=this.rootNode)==null?void 0:t.isConnected)!=null?e:!1}mount(t,e){var r,n,s,i;if(!d(this.template))throw new Error("Template must be a function");if(this.isConnected)return (n=(r=this.rootNode)==null?void 0:r.mount(t,e))!=null?n:[];this.initRef(),this.rootNode=this.template(yt(this.proxyProps,[M]));let o=(i=(s=this.rootNode)==null?void 0:s.mount(t,e))!=null?i:[];return this.callMountHooks(),this.patchProps(this.props),this.removeRef(),o}unmount(){var t;this.callDestroyHooks(),this.clearHooks(),(t=this.rootNode)==null||t.unmount(),this.rootNode=null,this.proxyProps={},this.clearEmitter();}callMountHooks(){this.hooks.mounted.forEach(t=>t());}callDestroyHooks(){this.hooks.destroy.forEach(t=>t());}clearEmitter(){for(let t of this.emitter)t();this.emitter.clear();}inheritNode(t){Object.assign(this.proxyProps,t.proxyProps),this.rootNode=t.rootNode,this.trackMap=t.trackMap,this.hooks=t.hooks;let e=this.props;this.props=t.props,this.patchProps(e);}getNodeTrack(t){let e=this.trackMap.get(t);return e||(e={cleanup:()=>{}},this.trackMap.set(t,e)),e.cleanup(),e}patchProps(t){var e;if(t){for(let[r,n]of Object.entries(t))O(r,wt)&&((e=this.rootNode)!=null&&e.firstChild)?this.patchEventListener(r,n):r===ee?this.patchRef(n):O(r,Mt)?this.patchUpdateHandler(r,n):r!==M&&this.patchNormalProp(r,n);this.props=t;}}patchEventListener(t,e){let r=t.slice(2).toLowerCase(),n=S(this.rootNode.nodes[0],r,e);this.emitter.add(n);}patchRef(t){var e,r;t.value=(r=(e=this.rootNode)==null?void 0:e.firstChild)!=null?r:null;}patchUpdateHandler(t,e){this.props[t]=ie(e);}patchNormalProp(t,e){var r,n;let s=(n=(r=this.proxyProps)[t])!=null?n:r[t]=Nt(e),i=this.getNodeTrack(t);i.cleanup=G(()=>{s.value=d(e)?e():e;});}};function Je(t,e,r,n){let s=new Map,i=Array.from(e.values());if(i.length&&r.length===0)return Xe(t,i,n),s;let o=[],a=Ze(r),p=0;for(let[l,c]of r.entries()){let u=i[p],L=A(u,l);for(;u&&!a.has(L);)j(u),e.delete(L),u=i[++p],L=A(u,l);let q=A(c,l),I=e.get(q);if(I&&(c=Ye(t,I,c)),u)if(u===I)p++;else {let At=document.createComment("");w(t,At,u),o.push([At,c]);}else w(t,c,n);s.set(q,c);}return o.forEach(([l,c])=>{se(t,c,l);}),e.forEach((l,c)=>{l.isConnected&&!s.has(c)&&j(l);}),s}function Xe(t,e,r){if(t.childNodes.length===e.length+(r?1:0))t.innerHTML="",r&&w(t,r);else {let n=document.createRange(),s=e[0],i=y(s)?s.firstChild:s;n.setStartBefore(i),r?n.setEndBefore(r):n.setEndAfter(t),n.deleteContents();}e.forEach(n=>{y(n)&&n.unmount();});}function Ye(t,e,r){return e===r?e:y(e)&&y(r)&&e.template===r.template?(r.inheritNode(e),r):e instanceof Text&&r instanceof Text?(e.textContent!==r.textContent&&(e.textContent=r.textContent),e):(se(t,r,e),r)}function Ze(t){let e=new Map;for(let[r,n]of t.entries()){let s=A(n,r);e.set(s,n);}return e}function A(t,e){if(y(t)){let r=t.key;if(r!=null)return String(r)}return `_$${e}$`}var rt=class{constructor(t,e,r){this.template=t,this.props=e,this.key=r,this.treeMap=new Map,this.mounted=!1,this.nodes=[],this.trackMap=new Map,this.bindValueKeys=[],this.parent=null,N.isSSR&&(this.componentIndex=We(this.template));}get firstChild(){var t;return (t=this.nodes[0])!=null?t:null}get isConnected(){return this.mounted}addEventListener(){}removeEventListener(){}mount(t,e){var r;if(this.parent=t,this.isConnected)return this.nodes.forEach(i=>w(t,i,e)),this.nodes;g(this.template)&&(this.template=$t(this.template.join("")));let n=this.template.content.cloneNode(!0),s=n.firstChild;return (r=s==null?void 0:s.hasAttribute)!=null&&r.call(s,"_svg_")&&(s.remove(),s.childNodes.forEach(i=>{n.append(i);})),this.nodes=Array.from(n.childNodes),N.isSSR?this.mapSSGNodeTree(t):this.mapNodeTree(t,n),w(t,n,e),this.patchProps(this.props),this.mounted=!0,this.nodes}unmount(){this.trackMap.forEach(t=>{t.cleanup&&t.cleanup();}),this.trackMap.clear(),this.treeMap.clear(),this.nodes.forEach(t=>j(t)),this.nodes=[],this.mounted=!1;}inheritNode(t){this.mounted=t.mounted,this.nodes=t.nodes,this.trackMap=t.trackMap,this.treeMap=t.treeMap;let e=this.props;this.props=t.props,this.patchProps(e);}mapSSGNodeTree(t){this.treeMap.set(0,t),this.walkNodeTree(t,this.handleSSGNode.bind(this));}mapNodeTree(t,e){let r=1;this.treeMap.set(0,t);let n=s=>{s.nodeType!==Node.DOCUMENT_FRAGMENT_NODE&&this.treeMap.set(r++,s);};this.walkNodeTree(e,n);}walkNodeTree(t,e){t.nodeType!==Node.DOCUMENT_FRAGMENT_NODE&&e(t);let r=t.firstChild;for(;r;)this.walkNodeTree(r,e),r=r.nextSibling;}handleSSGNode(t){var e;if(t.nodeType===Node.COMMENT_NODE){let[r,n]=((e=t.textContent)==null?void 0:e.split("-"))||[];if(+r==0&&+n===this.componentIndex){let s=t.nextSibling;this.treeMap.set(+n,s);}}else if(t.nodeType!==Node.TEXT_NODE){let{ci:r="-1",hk:n}=(t==null?void 0:t.dataset)||{};n&&+r===this.componentIndex&&this.treeMap.set(+n,t);}}patchProps(t){t&&(Object.entries(t).forEach(([e,r])=>{let n=Number(e),s=this.treeMap.get(n);s&&this.patchProp(e,s,r,n===0);}),this.props=t);}patchProp(t,e,r,n){r&&Object.entries(r).forEach(([s,i])=>{if(s===M&&i)this.patchChildren(t,e,i,n);else if(s===ee)r[s].value=e;else if(O(s,wt))this.patchEventListener(t,e,s,i);else {if(this.bindValueKeys.includes(s))return;let o=this.getBindUpdateValue(r,t,s);this.patchAttribute(t,e,s,i,o);}});}getBindUpdateValue(t,e,r){let n=`${Mt}${Kt(r)}`;if(n&&t[n]&&d(t[n]))return this.bindValueKeys.push(n),t[n]}patchChildren(t,e,r,n){if(g(r))r.filter(Boolean).forEach((s,i)=>{var o;let[a,p]=g(s)?s:[s,null],l=It(p)?null:(o=this.treeMap.get(p))!=null?o:null,c=`${t}:${M}:${i}`,u=this.getNodeTrack(c,!0,n);this.patchChild(u,e,a,l);});else {let s=`${t}:${M}:0`,i=this.getNodeTrack(s,!0,n);this.patchChild(i,e,r,null);}}patchEventListener(t,e,r,n){let s=r.slice(2).toLowerCase(),i=this.getNodeTrack(`${t}:${r}`);i.cleanup=S(e,s,n);}patchAttribute(t,e,r,n,s){let i=this.getNodeTrack(`${t}:${r}`),o=d(n)?n():n,a=m(o)?o:_t(o);te(e,r,a.value);let p=G(()=>{let c=d(n)?n():n;T(c)&&T(a.peek())&&JSON.stringify(a.value)===JSON.stringify(c)||(a.value=m(c)?c.value:c,te(e,r,a.value));}),l;s&&kt(e)&&(l=ze(e,c=>{s(c);})),i.cleanup=()=>{p&&p(),l&&l();};}getNodeTrack(t,e,r){let n=this.trackMap.get(t);return n||(n={cleanup:()=>{}},e&&(n.lastNodes=new Map),r&&(n.isRoot=!0),this.trackMap.set(t,n)),n.cleanup&&n.cleanup(),n}patchChild(t,e,r,n){d(r)?t.cleanup=G(()=>{let s=at(r()).map(Vt);N.isSSR?t.lastNodes=this.reconcileChildren(e,s,n):t.lastNodes=Je(e,t.lastNodes,s,n);}):at(r).forEach((s,i)=>{let o=Vt(s),a=A(o,i);N.isSSR?t.lastNodes=this.reconcileChildren(e,[o],n):(t.lastNodes.set(a,o),w(e,o,n));});}reconcileChildren(t,e,r){let n=new Map,s=Array.from(t.childNodes).filter(i=>{var o,a;return i.nodeType===Node.TEXT_NODE&&((o=i.previousSibling)==null?void 0:o.nodeType)===Node.COMMENT_NODE&&((a=i.nextSibling)==null?void 0:a.nodeType)===Node.COMMENT_NODE});return e.forEach((i,o)=>{let a=A(i,o);i.nodeType===Node.TEXT_NODE?s.forEach(p=>{i.textContent===p.textContent&&t.replaceChild(i,p);}):w(t,i,r),n.set(a,i);}),n}},Qe=class extends rt{unmount(){this.trackMap.forEach(t=>{t.lastNodes&&t.lastNodes.forEach(e=>{j(e);}),t.cleanup&&t.cleanup();}),this.trackMap.clear(),this.treeMap.clear(),this.nodes.forEach(t=>{j(t);}),this.nodes=[],this.mounted=!1;}};function oe(t,e,r){if(t===Tt)return Ve(t,e);if(Y(t)){let n=qe(t);return e={[He]:e},new rt($t(n),e,r)}return d(t)?new Rt(t,e,r):new rt(t,e,r)}function gr(t){return t instanceof Rt}function y(t){return t instanceof Rt||t instanceof rt}function $t(t){let e=document.createElement("template");return e.innerHTML=Ue(t),e}function Ve(t,e){return e.children&&(e={[ke]:{children:g(e.children)?e.children.filter(Boolean):[e.children]}}),t===Tt&&(t=$t(Tt)),new Qe(t,e)}function vr(t){nt("onMounted"),E.ref&&E.ref.addHook("mounted",t);}function br(t){nt("onDestroy"),E.ref&&E.ref.addHook("destroy",t);}function nt(t,e){E.ref||console.error(`"${t}"(key: ${Lt(e)?e.toString():e}) can only be called within the component function body
|
|
7
|
+
and cannot be used in asynchronous or deferred calls.`);}function Er(t,e){nt("useProvide",t),E.ref&&E.ref.setContext(t,e);}function Sr(t,e){var r;return nt("useInject",t),(r=E.ref&&E.ref.getContext(t))!=null?r:e}function Nr(){return _t(null)}function _r(t,e){N.setSSG();let n=new xt(t,e||{}).mount();return N.setClient(),n}function yr(t,e){let r=typeof e=="string"?document.querySelector(e):e;if(!r)throw new Error(`Could not find container: ${e}`);N.setSSR(),oe(t).mount(r),N.setClient();}function Cr(t,e){return N.isSSG?new xt(t,e):oe(t,e)}globalThis&&(globalThis.__essor_version__=jt);/**
|
|
8
|
+
* @estjs/signal v0.0.14-beta.11
|
|
9
9
|
* (c) 2023-Present jiangxd <jiangxd2016@gmail.com>
|
|
10
10
|
* @license MIT
|
|
11
11
|
**/
|
|
12
12
|
/**
|
|
13
|
-
* @estjs/template v0.0.
|
|
13
|
+
* @estjs/template v0.0.14-beta.11
|
|
14
14
|
* (c) 2023-Present jiangxd <jiangxd2016@gmail.com>
|
|
15
15
|
* @license MIT
|
|
16
|
-
**/
|
|
17
|
-
|
|
18
|
-
export { pr as Fragment, ir as clearReactive, cr as createStore, Rt as essor_version, xt as h, yr as hydrate, Ye as isComponent, Jt as isComputed, E as isJsxElement, D as isReactive, m as isSignal, gr as onDestroy, mr as onMount, Nr as renderToString, sr as shallowReactive, Xt as shallowSignal, nr as signalObject, Sr as ssg, Tt as template, f as toRaw, we as useBatch, Ne as useComputed, K as useEffect, br as useInject, vr as useProvide, yt as useReactive, _r as useRef, rr as useShallowSignal, Nt as useSignal, or as useWatch };
|
|
19
|
-
//# sourceMappingURL=essor.esm.js.map
|
|
16
|
+
**/export{Ve as Fragment,cr as clearReactive,ur as createStore,jt as essor_version,oe as h,yr as hydrate,gr as isComponent,Zt as isComputed,y as isJsxElement,B as isReactive,m as isSignal,St as nextTick,br as onDestroy,vr as onMount,_r as renderToString,or as shallowReactive,_t as shallowSignal,Qt as signalObject,Cr as ssg,$t as template,f as toRaw,Oe as useBatch,ye as useComputed,G as useEffect,Sr as useInject,Er as useProvide,yt as useReactive,Nr as useRef,Nt as useSignal,ar as useWatch};//# sourceMappingURL=essor.esm.js.map
|
|
20
17
|
//# sourceMappingURL=essor.esm.js.map
|