essor 0.0.14-beta.4 → 0.0.14-beta.5
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 +29 -29
- 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 +13 -8
- package/dist/essor.dev.esm.js +13 -8
- package/dist/essor.esm.js +6 -6
- package/dist/essor.esm.js.map +1 -1
- package/package.json +4 -4
package/dist/essor.cjs.js
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* essor v0.0.14-beta.
|
|
4
|
+
* essor v0.0.14-beta.5
|
|
5
5
|
* (c) 2023-Present jiangxd <jiangxd2016@gmail.com>
|
|
6
6
|
* @license MIT
|
|
7
7
|
**/
|
|
8
|
-
var Ot="0.0.14-beta.4";var C=t=>t!==null&&typeof t=="object";var m=Array.isArray;function X(t){return typeof t=="string"}function ie(t){return t===null}function Rt(t){return typeof t=="symbol"}function J(t){return j.call(t)==="[object Set]"}function rt(t){return j.call(t)==="[object WeakMap]"}function nt(t){return j.call(t)==="[object WeakSet]"}function Y(t){return j.call(t)==="[object Map]"}function $t(t){return t==null}var p=t=>typeof t=="function";function st(t){return t===!1||t===null||t===void 0}var At=t=>["string","number","boolean","symbol","undefined"].includes(typeof t)||ie(t);function jt(t){return t?t&&typeof t=="object"&&t.nodeType===1&&typeof t.nodeName=="string":!1}var it=t=>j.call(t)==="[object Object]";function ot(t){return X(t)?!Number.isNaN(Number(t)):!1}var j=Object.prototype.toString;var oe=Object.prototype.hasOwnProperty,Z=(t,e)=>oe.call(t,e);function ct(t){return m(t)?t.flat():[t]}var w=(t,e)=>t!==e&&(t===t||e===e),at=Function.prototype;function M(t,e){return X(t)?t.indexOf(e)===0:!1}function kt(t){return t.replaceAll(/["&'<>]/g,e=>{switch(e){case"&":return "&";case"<":return "<";case">":return ">";case'"':return """;case"'":return "'";default:return e}})}function k(t,e){return m(e)?e.includes(t):p(e)?e(t):!1}var lt=t=>{let e=Object.create(null);return r=>e[r]||(e[r]=t(r))},ce=/\B([A-Z])/g,Lt=lt(t=>t.replaceAll(ce,"-$1").toLowerCase()),It=lt(t=>t.charAt(0).toUpperCase()+t.slice(1));function P(t,...e){console.warn.apply(console,[`[Essor warn]: ${t}`].concat(e));}var le=Object.defineProperty,ue=Object.defineProperties,fe=Object.getOwnPropertyDescriptors,Ht=Object.getOwnPropertySymbols,he=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable,Ft=(t,e,r)=>e in t?le(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,I=(t,e)=>{for(var r in e||(e={}))he.call(e,r)&&Ft(t,r,e[r]);if(Ht)for(var r of Ht(e))de.call(e,r)&&Ft(t,r,e[r]);return t},pe=(t,e)=>ue(t,fe(e)),ht=[],dt=[],Dt=Promise.resolve(),pt=!1;function _t(t){return t?Dt.then(t):Dt}function me(t){ht.includes(t)||(ht.push(t),qt());}function qt(){pt||(pt=!0,_t(be));}function ge(t){ve(t,dt);}function ve(t,e){e.includes(t)||(e.push(t),qt());}function be(){pt=!1,_e();let t;for(;t=ht.shift();)t&&t();}function _e(){for(;dt.length>0;){let t=dt.shift();t&&t();}}function ye(t,e){return e==="sync"?()=>t():e==="pre"?()=>ge(t):()=>{_t(()=>me(t));}}var N=null,mt=new WeakMap,ut=new WeakMap,H=Symbol("ReactiveSymbol"),F=Symbol("__raw"),ft=Symbol("SignalValueKey"),Kt=Symbol("ComputedValueKey"),gt=Symbol("ReactiveArrayKey"),b=Symbol("ReactiveCollectionKey"),x=Symbol("ReactiveWeakCollectionKey"),vt=!1,Q=new Set;function h(t,e){if(!N)return;let r=mt.get(t);r||(r=new Map,mt.set(t,r));let n=r.get(e);n||(n=new Set,r.set(e,n)),n.add(N);}function v(t,e){let r=mt.get(t);if(!r)return;let n=r.get(e);n&&n.forEach(s=>{if(Z(s,"active")&&!s.active){n.delete(s);return}vt?Q.add(s):s();});}var zt=class{constructor(t,e=!1){this.__signal=!0,this.__shallow=e,this.__value=t;}get value(){return h(this,ft),C(this.__value)&&!this.__shallow?G(this.__value):this.__value}set value(t){g(t)&&(t=t.peek()),w(t,this.__value)&&(this.__value=t,v(this,ft));}trigger(){v(this,ft);}peek(){return this.__value}};function Ee(t){return g(t)?t:new zt(t)}function yt(t){return new zt(t,!0)}function g(t){return !!(t&&(t!=null&&t.__signal))}var Ne=class{constructor(t){this.fn=t,this.__computed=!0;let e=N;N=this.run.bind(this),this.__value=this.fn(),N=e;}peek(){return this.__value}run(){let t=this.fn();w(t,this.__value)&&(this.__value=t,v(this,Kt));}get value(){return h(this,Kt),this.__value}};function Se(t){return new Ne(t)}function Xt(t){return !!(t&&t.__computed)}function D(t,e={}){let{flush:r="pre",onTrack:n,onTrigger:s}=e;function i(){let a=N;N=i.init?i:i.scheduler,t(),s&&s(),N=a;}let o=ye(i,r);return i.scheduler=o,i.init=!0,i.active=!0,n&&n(),i(),()=>{i.active=!1,N=null;}}function or(t,e){return !t||!C(t)?(P("initialValues must be an object,will return initial value!",t),t):Object.entries(t).reduce((n,[s,i])=>(n[s]=k(s,e)||g(i)?i:Ee(i),n),{})}function f(t){return t&&(K(t)?t[F]:g(t)?t.peek():m(t)?t.map(e=>f(e)):it(t)?Object.fromEntries(Object.entries(t).map(([e,r])=>[e,f(r)])):t)}function K(t){return !!(t&&typeof t=="object"&&t[H])}function Ce(t,e){return G(t,!1,e)}function Jt(t,e){return G(t,!0,e)}var Te=(t,e)=>({get(r,n,s){if(n===H)return !0;if(n===F)return r;let i=Reflect.get(r,n,s),o=g(i)?i.value:i;return k(n,e)?o:(h(r,n),C(o)&&!t?G(o):o)},set(r,n,s,i){if(k(n,e))return Reflect.set(r,n,s,i),!0;let o=Reflect.get(r,n,i);g(o)&&(o=o.value),g(s)&&(s=s.value);let a=Reflect.set(r,n,s,i);return w(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}}),Gt=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,gt),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,gt),n[e].apply(this,r)};}),t}var Me=(t,e)=>({get(r,n,s){if(n===H)return !0;if(n===F)return r;if(Gt.hasOwnProperty(n))return Reflect.get(Gt,n,s);let i=Reflect.get(r,n,s);return k(n,e)?i:(ot(n)&&h(r,n),h(r,"length"),C(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 w(s,o)&&(ot(n)&&v(r,n),(n==="length"||!o)&&v(r,"length")),a}}),Pe={get(t,e){return e===H?!0:e===F?t:((e===Symbol.iterator||e==="size")&&h(t,b),Reflect.get(Z(Wt,e)&&e in t?Wt:t,e,t))}},xe={get(t,e){return e===H?!0:e===F?t:Reflect.get(Z(Bt,e)&&e in t?Bt:t,e,t)}},Wt={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]()}},Bt={get(t){let e=f(this);return h(e,x),e.get(t)},set(t,e){let r=f(this),n=r.set(t,e);return v(r,x),n},add(t){let e=f(this),r=e.add(t);return v(e,x),r},has(t){let e=f(this);return h(e,x),e.has(t)},delete(t){let e=f(this),r=e.delete(t);return v(e,x),r}};function G(t,e=!1,r){if(!C(t)||K(t))return t;if(ut.has(t))return ut.get(t);let n;m(t)?(h(t,gt),n=Me(e,r)):J(t)||Y(t)?(h(t,b),n=Pe):nt(t)||rt(t)?(h(t,x),n=xe):n=Te(e,r);let s=new Proxy(t,n);return ut.set(t,s),s}function cr(t){if(!K(t)){P("clearReactive: argument must be a reactive object");return}if(rt(t)||nt(t)){P("clearReactive: WeakMap and WeakSet are not clearable");return}Oe(()=>{m(t)?t.length=0:J(t)||Y(t)?t.clear():C(t)&&Object.keys(t).forEach(e=>{delete t[e];});});}function Oe(t){try{vt=!0,t();}finally{vt=!1,Re();}}function Re(){Q.size>0&&(Q.forEach(t=>t()),Q.clear());}function ar(t,e,r){return je(t,e,r)}var Ut=void 0,V,bt=!1;function $e(t){V=t,bt||(bt=!0,_t(Ae));}function Ae(){V==null||V(),V=null,bt=!1;}function je(t,e,{deep:r,immediate:n}={}){let s,i=m(t);if(g(t)||Xt(t))s=()=>t.value;else if(K(t))s=()=>I({},t);else if(i)s=()=>t.map(c=>ke(c));else if(p(t))s=t;else return P("Invalid source type",t),at;if(e&&r){let c=s,l=r===!0?1/0:r;s=()=>L(c(),l);}let o=i?Array.from({length:t.length}).fill(Ut):Ut,a=!1,d=()=>{let c=s();w(c,o)&&(n&&e&&(e(c,o),o=c),a&&e&&$e(()=>{e(c,o),o=c;}),!a&&(o=c));},u=D(d,{flush:"sync"});return a=!0,n&&d(),u}function ke(t){return g(t)||Xt(t)?t.value:K(t)?I({},t):p(t)?t():(P("Invalid source",t),at)}function L(t,e=1/0,r){if(e<=0||!C(t)||(r=r||new Set,r.has(t)))return t;if(r.add(t),e--,g(t))L(t.value,e,r);else if(m(t))for(let n of t)L(n,e,r);else if(J(t)||Y(t))t.forEach(n=>{L(n,e,r);});else if(it(t))for(let n in t)L(t[n],e,r);return t}function Le(t){let{state:e,getters:r,actions:n}=t,s=I({},e),i=Ce(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(pe(I({},i),{state:i}),d);if(r)for(let c in r){let l=r[c];l&&Object.defineProperty(u,c,{get(){return Se(()=>l.call(u,i)).value},enumerable:!0,configurable:!0});}if(n)for(let c in n){let l=n[c];l&&(u[c]=function(...$){let q=l.apply(i,$);return a.forEach(A=>A(i)),q});}return u}function lr(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 Yt="on",Zt="update",B="children",Nt="",te="0",He="1",Et=" __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;}},E=new Fe,ee=new Map;function De(t,e){ee.set(t,{index:e});}function Ke(t){var e;return (e=ee.get(t))==null?void 0:e.index}var Tt=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());}};Tt.ref=null;Tt.context={};var _=Tt;function St(t){return t instanceof wt}var O=1,wt=class extends _{constructor(t,e={},r){super(),this.template=t,this.props=e,this.key=r,De(t,O),this.templates=this.processTemplate();}processTemplate(){if(m(this.template)){let t=this.template.join(Et);return this.processHtmlString(t).split(Et)}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}"${o||""}>`):n&&n.replace(Et,"").trim()?`<!--0-${O}-->${n}<!$>`:e)}mount(){this.initRef();let t=this.render();return this.removeRef(),t}render(){if(p(this.template)){let t=this.template(this.props);return St(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"||p(r)?delete t[e]:g(r)&&(t[e]=r.value);});}generateAttributes(t){return Object.entries(t).filter(([e,r])=>e!=="children"&&!p(r)).map(([e,r])=>`${e}="${kt(String(r))}"`).join(" ")}renderChildren(t,e){t.forEach(([r])=>{O++;let n=this.renderChild(r);this.templates[e]+=n;});}renderChild(t){if(p(t))return this.renderChild(t(this.props));if(g(t))return `<!--1-${O}-->${t.value}<!$>`;if(St(t)){let e=t.mount();return p(e)?e(this.props):se(e)}else return `<!--1-${O}-->${t}<!$>`}},re="area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr".split(","),Ge="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(S(t)||t instanceof Node||St(t))return t;let e=st(t)?"":String(t);return document.createTextNode(e)}function T(t,e,r=null){let n=S(r)?r.firstChild:r,s=E.isSSR;S(e)?e.mount(t,n):n&&!s?n.before(e):s||t.append(e);}function U(t){S(t)?t.unmount():t.parentNode&&t.remove();}function ne(t,e,r){T(t,e,r),U(r);}function Vt(t,e,r){e==="class"?We(t,r):e==="style"?Be(t,r):Ue(t,e,r);}function We(t,e){typeof e=="string"?t.className=e:m(e)?t.className=e.join(" "):e&&typeof e=="object"&&(t.className=Object.entries(e).reduce((r,[n,s])=>r+(s?` ${n}`:""),"").trim());}function Be(t,e){typeof e=="string"?t.style.cssText=e:e&&typeof e=="object"&&Object.entries(e).forEach(([n,s])=>{t.style.setProperty(Lt(n),String(s));});}function Ue(t,e,r){st(r)?t.removeAttribute(e):r===!0?t.setAttribute(e,""):t instanceof HTMLInputElement&&e==="value"?t.value=String(r):t.setAttribute(e,String(r));}function qe(t,e){if(t instanceof HTMLInputElement)switch(t.type){case"checkbox":return y(t,"change",()=>{e(!!t.checked);});case"date":return y(t,"change",()=>{e(t.value?t.value:"");});case"file":return y(t,"change",()=>{t.files&&e(t.files);});case"number":return y(t,"input",()=>{let r=Number.parseFloat(t.value);e(Number.isNaN(r)?"":String(r));});case"radio":return y(t,"change",()=>{e(t.checked?t.value:"");});case"text":return y(t,"input",()=>{e(t.value);})}if(t instanceof HTMLSelectElement)return y(t,"change",()=>{e(t.value);});if(t instanceof HTMLTextAreaElement)return y(t,"input",()=>{e(t.value);})}Promise.resolve();function y(t,e,r){return t.addEventListener(e,r),()=>t.removeEventListener(e,r)}function ze(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 Xe(t){return Ge.includes(t)}function Je(t){return re.includes(t)?`<${t}/>`:`<${t}></${t}>`}function se(t){return g(t)?t.value:t}var Mt=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?Jt(t,e=>M(e,Yt)||M(e,Zt)||e===B):{}}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(!p(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))M(r,Yt)&&((e=this.rootNode)!=null&&e.firstChild)?this.patchEventListener(r,n):r==="ref"?this.patchRef(n):M(r,Zt)?this.patchUpdateHandler(r,n):r!==B&&this.patchNormalProp(r,n);this.props=t;}}patchEventListener(t,e){let r=t.slice(2).toLowerCase(),n=y(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=D(()=>{this.proxyProps[t]=p(e)?e():e;});}};function Ye(t,e,r,n){let s=new Map,i=Array.from(e.values());if(i.length&&r.length===0)return Ze(t,i,n),s;let o=[],a=Ve(r),d=0;for(let[u,c]of r.entries()){let l=i[d],$=R(l,u);for(;l&&!a.has($);)U(l),e.delete($),l=i[++d],$=R(l,u);let q=R(c,u),A=e.get(q);if(A&&(c=Qe(t,A,c)),l)if(l===A)d++;else {let xt=document.createComment("");T(t,xt,l),o.push([xt,c]);}else T(t,c,n);s.set(q,c);}return o.forEach(([u,c])=>{ne(t,c,u);}),e.forEach((u,c)=>{u.isConnected&&!s.has(c)&&U(u);}),s}function Ze(t,e,r){if(t.childNodes.length===e.length+(r?1:0))t.innerHTML="",r&&T(t,r);else {let n=document.createRange(),s=e[0],i=S(s)?s.firstChild:s;n.setStartBefore(i),r?n.setEndBefore(r):n.setEndAfter(t),n.deleteContents();}e.forEach(n=>{S(n)&&n.unmount();});}function Qe(t,e,r){return e===r?e:S(e)&&S(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 Ve(t){let e=new Map;for(let[r,n]of t.entries()){let s=R(n,r);e.set(s,n);}return e}function R(t,e){if(S(t)){let r=t.key;if(r!=null)return String(r)}return `_$${e}$`}var tt=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),E.isSSR&&(this.componentIndex=Ke(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=>T(t,i,e)),this.nodes;m(this.template)&&(this.template=Ct(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),E.isSSR?this.mapSSGNodeTree(t):this.mapNodeTree(t,n),T(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=>U(r)),!this.template.innerHTML&&!this.nodes.length){let r=(e=(t=this.props)==null?void 0:t[te])==null?void 0:e.children;r&&(m(r)?r.forEach(n=>{this.deleteFragmentTextNode(n);}):this.deleteFragmentTextNode(r));}this.nodes=[],this.mounted=!1;}deleteFragmentTextNode(t){var e;At(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));}):U(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])=>{if(s===B&&i)this.patchChildren(t,e,i,n);else if(s==="ref")r[s].value=e;else if(M(s,"on"))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 s=`update${It(r)}`;if(s&&t[s]&&p(t[s]))return this.bindValueKeys.push(s),t[s]}patchChildren(t,e,r,n){if(m(r))r.filter(Boolean).forEach((s,i)=>{var o;let[a,d]=m(s)?s:[s,null],u=$t(d)?null:(o=this.treeMap.get(d))!=null?o:null,c=`${t}:${B}:${i}`,l=this.getNodeTrack(c,!0,n);this.patchChild(l,e,a,u);});else {let s=`${t}:${B}: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=y(e,s,n);}patchAttribute(t,e,r,n,s){let i=this.getNodeTrack(`${t}:${r}`),o=p(n)?n():n,a=g(o)?o:yt(o);Vt(e,r,a.value);let d=D(()=>{let c=p(n)?n():n;JSON.stringify(a.value)!==JSON.stringify(c)&&(a.value=g(c)?c.value:c,Vt(e,r,a.value));}),u;s&&jt(e)&&(u=qe(e,c=>{s(c);})),i.cleanup=()=>{d&&d(),u&&u();};}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){p(r)?t.cleanup=D(()=>{let s=ct(r()).map(Qt);E.isSSR?t.lastNodes=this.reconcileChildren(e,s,n):t.lastNodes=Ye(e,t.lastNodes,s,n);}):ct(r).forEach((s,i)=>{let o=Qt(s),a=R(o,i);E.isSSR?t.lastNodes=this.reconcileChildren(e,[o],n):(t.lastNodes.set(a,o),T(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=R(i,o);i.nodeType===Node.TEXT_NODE?s.forEach(d=>{i.textContent===d.textContent&&t.replaceChild(i,d);}):T(t,i,r),n.set(a,i);}),n}};function Pt(t,e,r){if(X(t)){if(Xe(t)){let n=Je(t);return e={[He]:e},new tt(Ct(n),e,r)}else if(t===Nt)return e={[te]:e},new tt(Ct(Nt),e,r)}return p(t)?new Mt(t,e,r):new tt(t,e,r)}function gr(t){return t instanceof Mt}function S(t){return t instanceof Mt||t instanceof tt}function Ct(t){let e=document.createElement("template");return e.innerHTML=ze(t),e}function vr(t){return Pt(Nt,{children:m(t.children)?t.children.filter(Boolean):[t.children]})}function br(t){et("onMounted"),_.ref&&_.ref.addHook("mounted",t);}function _r(t){et("onDestroy"),_.ref&&_.ref.addHook("destroy",t);}function et(t,e){_.ref||console.error(`"${t}"(key: ${Rt(e)?e.toString():e}) can only be called within the component function body
|
|
9
|
-
and cannot be used in asynchronous or deferred calls.`);}function
|
|
10
|
-
* @estjs/signal v0.0.14-beta.
|
|
8
|
+
var $t="0.0.14-beta.5";var C=t=>t!==null&&typeof t=="object";var m=Array.isArray;function X(t){return typeof t=="string"}function ae(t){return t===null}function jt(t){return typeof t=="symbol"}function J(t){return A.call(t)==="[object Set]"}function rt(t){return A.call(t)==="[object WeakMap]"}function nt(t){return A.call(t)==="[object WeakSet]"}function Y(t){return A.call(t)==="[object Map]"}function At(t){return t==null}var p=t=>typeof t=="function";function st(t){return t===!1||t===null||t===void 0}var kt=t=>["string","number","boolean","symbol","undefined"].includes(typeof t)||ae(t);function Lt(t){return t?t&&typeof t=="object"&&t.nodeType===1&&typeof t.nodeName=="string":!1}var it=t=>A.call(t)==="[object Object]";function ot(t){return X(t)?!Number.isNaN(Number(t)):!1}var A=Object.prototype.toString;var le=Object.prototype.hasOwnProperty,Z=(t,e)=>le.call(t,e);function ct(t){return m(t)?t.flat():[t]}var w=(t,e)=>t!==e&&(t===t||e===e),at=Function.prototype;function M(t,e){return X(t)?t.indexOf(e)===0:!1}function It(t){return t.replaceAll(/["&'<>]/g,e=>{switch(e){case"&":return "&";case"<":return "<";case">":return ">";case'"':return """;case"'":return "'";default:return e}})}function k(t,e){return m(e)?e.includes(t):p(e)?e(t):!1}var lt=t=>{let e=Object.create(null);return r=>e[r]||(e[r]=t(r))},ue=/\B([A-Z])/g,Ht=lt(t=>t.replaceAll(ue,"-$1").toLowerCase()),Ft=lt(t=>t.charAt(0).toUpperCase()+t.slice(1));function P(t,...e){console.warn.apply(console,[`[Essor warn]: ${t}`].concat(e));}var he=Object.defineProperty,de=Object.defineProperties,pe=Object.getOwnPropertyDescriptors,Dt=Object.getOwnPropertySymbols,me=Object.prototype.hasOwnProperty,ge=Object.prototype.propertyIsEnumerable,Kt=(t,e,r)=>e in t?he(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,I=(t,e)=>{for(var r in e||(e={}))me.call(e,r)&&Kt(t,r,e[r]);if(Dt)for(var r of Dt(e))ge.call(e,r)&&Kt(t,r,e[r]);return t},ve=(t,e)=>de(t,pe(e)),ht=[],dt=[],Gt=Promise.resolve(),pt=!1;function _t(t){return t?Gt.then(t):Gt}function be(t){ht.includes(t)||(ht.push(t),Xt());}function Xt(){pt||(pt=!0,_t(Ee));}function _e(t){ye(t,dt);}function ye(t,e){e.includes(t)||(e.push(t),Xt());}function Ee(){pt=!1,Ne();let t;for(;t=ht.shift();)t&&t();}function Ne(){for(;dt.length>0;){let t=dt.shift();t&&t();}}function Se(t,e){return e==="sync"?()=>t():e==="pre"?()=>_e(t):()=>{_t(()=>be(t));}}var N=null,mt=new WeakMap,ut=new WeakMap,H=Symbol("ReactiveSymbol"),F=Symbol("__raw"),ft=Symbol("SignalValueKey"),Wt=Symbol("ComputedValueKey"),gt=Symbol("ReactiveArrayKey"),b=Symbol("ReactiveCollectionKey"),O=Symbol("ReactiveWeakCollectionKey"),vt=!1,Q=new Set;function h(t,e){if(!N)return;let r=mt.get(t);r||(r=new Map,mt.set(t,r));let n=r.get(e);n||(n=new Set,r.set(e,n)),n.add(N);}function v(t,e){let r=mt.get(t);if(!r)return;let n=r.get(e);n&&n.forEach(s=>{if(Z(s,"active")&&!s.active){n.delete(s);return}vt?Q.add(s):s();});}var Jt=class{constructor(t,e=!1){this.__signal=!0,this.__shallow=e,this.__value=t;}get value(){return h(this,ft),C(this.__value)&&!this.__shallow?G(this.__value):this.__value}set value(t){g(t)&&(t=t.peek()),w(t,this.__value)&&(this.__value=t,v(this,ft));}trigger(){v(this,ft);}peek(){return this.__value}};function yt(t){return g(t)?t:new Jt(t)}function Et(t){return new Jt(t,!0)}function g(t){return !!(t&&(t!=null&&t.__signal))}var Ce=class{constructor(t){this.fn=t,this.__computed=!0;let e=N;N=this.run.bind(this),this.__value=this.fn(),N=e;}peek(){return this.__value}run(){let t=this.fn();w(t,this.__value)&&(this.__value=t,v(this,Wt));}get value(){return h(this,Wt),this.__value}};function Te(t){return new Ce(t)}function Yt(t){return !!(t&&t.__computed)}function D(t,e={}){let{flush:r="pre",onTrack:n,onTrigger:s}=e;function i(){let a=N;N=i.init?i:i.scheduler,t(),s&&s(),N=a;}let o=Se(i,r);return i.scheduler=o,i.init=!0,i.active=!0,n&&n(),i(),()=>{i.active=!1,N=null;}}function Zt(t,e){return !t||!C(t)?(P("initialValues must be an object,will return initial value!",t),t):Object.entries(t).reduce((n,[s,i])=>(n[s]=k(s,e)||g(i)?i:yt(i),n),{})}function f(t){return t&&(K(t)?t[F]:g(t)?t.peek():m(t)?t.map(e=>f(e)):it(t)?Object.fromEntries(Object.entries(t).map(([e,r])=>[e,f(r)])):t)}function K(t){return !!(t&&typeof t=="object"&&t[H])}function Nt(t,e){return G(t,!1,e)}function ar(t,e){return G(t,!0,e)}var we=(t,e)=>({get(r,n,s){if(n===H)return !0;if(n===F)return r;let i=Reflect.get(r,n,s),o=g(i)?i.value:i;return k(n,e)?o:(h(r,n),C(o)&&!t?G(o):o)},set(r,n,s,i){if(k(n,e))return Reflect.set(r,n,s,i),!0;let o=Reflect.get(r,n,i);g(o)&&(o=o.value),g(s)&&(s=s.value);let a=Reflect.set(r,n,s,i);return w(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}}),Bt=Me();function Me(){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,gt),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,gt),n[e].apply(this,r)};}),t}var Pe=(t,e)=>({get(r,n,s){if(n===H)return !0;if(n===F)return r;if(Bt.hasOwnProperty(n))return Reflect.get(Bt,n,s);let i=Reflect.get(r,n,s);return k(n,e)?i:(ot(n)&&h(r,n),h(r,"length"),C(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 w(s,o)&&(ot(n)&&v(r,n),(n==="length"||!o)&&v(r,"length")),a}}),Oe={get(t,e){return e===H?!0:e===F?t:((e===Symbol.iterator||e==="size")&&h(t,b),Reflect.get(Z(Ut,e)&&e in t?Ut:t,e,t))}},xe={get(t,e){return e===H?!0:e===F?t:Reflect.get(Z(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,O),e.get(t)},set(t,e){let r=f(this),n=r.set(t,e);return v(r,O),n},add(t){let e=f(this),r=e.add(t);return v(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 v(e,O),r}};function G(t,e=!1,r){if(!C(t)||K(t))return t;if(ut.has(t))return ut.get(t);let n;m(t)?(h(t,gt),n=Pe(e,r)):J(t)||Y(t)?(h(t,b),n=Oe):nt(t)||rt(t)?(h(t,O),n=xe):n=we(e,r);let s=new Proxy(t,n);return ut.set(t,s),s}function lr(t){if(!K(t)){P("clearReactive: argument must be a reactive object");return}if(rt(t)||nt(t)){P("clearReactive: WeakMap and WeakSet are not clearable");return}Re(()=>{m(t)?t.length=0:J(t)||Y(t)?t.clear():C(t)&&Object.keys(t).forEach(e=>{delete t[e];});});}function Re(t){try{vt=!0,t();}finally{vt=!1,$e();}}function $e(){Q.size>0&&(Q.forEach(t=>t()),Q.clear());}function ur(t,e,r){return ke(t,e,r)}var zt=void 0,V,bt=!1;function je(t){V=t,bt||(bt=!0,_t(Ae));}function Ae(){V==null||V(),V=null,bt=!1;}function ke(t,e,{deep:r,immediate:n}={}){let s,i=m(t);if(g(t)||Yt(t))s=()=>t.value;else if(K(t))s=()=>I({},t);else if(i)s=()=>t.map(c=>Le(c));else if(p(t))s=t;else return P("Invalid source type",t),at;if(e&&r){let c=s,l=r===!0?1/0:r;s=()=>L(c(),l);}let o=i?Array.from({length:t.length}).fill(zt):zt,a=!1,d=()=>{let c=s();w(c,o)&&(n&&e&&(e(c,o),o=c),a&&e&&je(()=>{e(c,o),o=c;}),!a&&(o=c));},u=D(d,{flush:"sync"});return a=!0,n&&d(),u}function Le(t){return g(t)||Yt(t)?t.value:K(t)?I({},t):p(t)?t():(P("Invalid source",t),at)}function L(t,e=1/0,r){if(e<=0||!C(t)||(r=r||new Set,r.has(t)))return t;if(r.add(t),e--,g(t))L(t.value,e,r);else if(m(t))for(let n of t)L(n,e,r);else if(J(t)||Y(t))t.forEach(n=>{L(n,e,r);});else if(it(t))for(let n in t)L(t[n],e,r);return t}function Ie(t){let{state:e,getters:r,actions:n}=t,s=I({},e),i=Nt(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(ve(I({},i),{state:i}),d);if(r)for(let c in r){let l=r[c];l&&Object.defineProperty(u,c,{get(){return Te(()=>l.call(u,i)).value},enumerable:!0,configurable:!0});}if(n)for(let c in n){let l=n[c];l&&(u[c]=function(...$){let q=l.apply(i,$);return a.forEach(j=>j(i)),q});}return u}function fr(t){return function(){let e;typeof t=="function"?e=He(t):e=t;let r=Ie(e);return typeof t=="function"&&Object.keys(e.actions||{}).forEach(n=>{r[n]=e.actions[n].bind(r);}),r}}function He(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 Qt="on",Vt="update",B="children",Ct="",ne="0",Fe="1",St=" __PLACEHOLDER__ ",De=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;}},E=new De,se=new Map;function Ke(t,e){se.set(t,{index:e});}function Ge(t){var e;return (e=se.get(t))==null?void 0:e.index}var Mt=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());}};Mt.ref=null;Mt.context={};var _=Mt;function Tt(t){return t instanceof Pt}var x=1,Pt=class extends _{constructor(t,e={},r){super(),this.template=t,this.props=e,this.key=r,Ke(t,x),this.templates=this.processTemplate();}processTemplate(){if(m(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="${x}"${o||""}>`):n&&n.replace(St,"").trim()?`<!--0-${x}-->${n}<!$>`:e)}mount(){this.initRef();let t=this.render();return this.removeRef(),t}render(){if(p(this.template)){let t=this.template(this.props);return Tt(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"||p(r)?delete t[e]:g(r)&&(t[e]=r.value);});}generateAttributes(t){return Object.entries(t).filter(([e,r])=>e!=="children"&&!p(r)).map(([e,r])=>`${e}="${It(String(r))}"`).join(" ")}renderChildren(t,e){t.forEach(([r])=>{x++;let n=this.renderChild(r);this.templates[e]+=n;});}renderChild(t){if(p(t))return this.renderChild(t(this.props));if(g(t))return `<!--1-${x}-->${t.value}<!$>`;if(Tt(t)){let e=t.mount();return p(e)?e(this.props):ce(e)}else return `<!--1-${x}-->${t}<!$>`}},ie="area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr".split(","),We="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 te(t){if(S(t)||t instanceof Node||Tt(t))return t;let e=st(t)?"":String(t);return document.createTextNode(e)}function T(t,e,r=null){let n=S(r)?r.firstChild:r,s=E.isSSR;S(e)?e.mount(t,n):n&&!s?n.before(e):s||t.append(e);}function U(t){S(t)?t.unmount():t.parentNode&&t.remove();}function oe(t,e,r){T(t,e,r),U(r);}function ee(t,e,r){e==="class"?Be(t,r):e==="style"?Ue(t,r):qe(t,e,r);}function Be(t,e){typeof e=="string"?t.className=e:m(e)?t.className=e.join(" "):e&&typeof e=="object"&&(t.className=Object.entries(e).reduce((r,[n,s])=>r+(s?` ${n}`:""),"").trim());}function Ue(t,e){typeof e=="string"?t.style.cssText=e:e&&typeof e=="object"&&Object.entries(e).forEach(([n,s])=>{t.style.setProperty(Ht(n),String(s));});}function qe(t,e,r){st(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 y(t,"change",()=>{e(!!t.checked);});case"date":return y(t,"change",()=>{e(t.value?t.value:"");});case"file":return y(t,"change",()=>{t.files&&e(t.files);});case"number":return y(t,"input",()=>{let r=Number.parseFloat(t.value);e(Number.isNaN(r)?"":String(r));});case"radio":return y(t,"change",()=>{e(t.checked?t.value:"");});case"text":return y(t,"input",()=>{e(t.value);})}if(t instanceof HTMLSelectElement)return y(t,"change",()=>{e(t.value);});if(t instanceof HTMLTextAreaElement)return y(t,"input",()=>{e(t.value);})}Promise.resolve();function y(t,e,r){return t.addEventListener(e,r),()=>t.removeEventListener(e,r)}function Xe(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 ie.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 Je(t){return We.includes(t)}function Ye(t){return ie.includes(t)?`<${t}/>`:`<${t}></${t}>`}function ce(t){return g(t)?t.value:t}var Ot=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?Zt(t,e=>M(e,Qt)||M(e,Vt)||e===B):{}}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(!p(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(Nt(this.proxyProps,["children"]));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))M(r,Qt)&&((e=this.rootNode)!=null&&e.firstChild)?this.patchEventListener(r,n):r==="ref"?this.patchRef(n):M(r,Vt)?this.patchUpdateHandler(r,n):r!==B&&this.patchNormalProp(r,n);this.props=t;}}patchEventListener(t,e){let r=t.slice(2).toLowerCase(),n=y(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]=ce(e);}patchNormalProp(t,e){var r,n;let s=(n=(r=this.proxyProps)[t])!=null?n:r[t]=yt(e),i=this.getNodeTrack(t);i.cleanup=D(()=>{s.value=p(e)?e():e;});}},Ze=Object.prototype.toString,re=t=>Ze.call(t)==="[object Object]";function Qe(t,e,r,n){let s=new Map,i=Array.from(e.values());if(i.length&&r.length===0)return Ve(t,i,n),s;let o=[],a=er(r),d=0;for(let[u,c]of r.entries()){let l=i[d],$=R(l,u);for(;l&&!a.has($);)U(l),e.delete($),l=i[++d],$=R(l,u);let q=R(c,u),j=e.get(q);if(j&&(c=tr(t,j,c)),l)if(l===j)d++;else {let Rt=document.createComment("");T(t,Rt,l),o.push([Rt,c]);}else T(t,c,n);s.set(q,c);}return o.forEach(([u,c])=>{oe(t,c,u);}),e.forEach((u,c)=>{u.isConnected&&!s.has(c)&&U(u);}),s}function Ve(t,e,r){if(t.childNodes.length===e.length+(r?1:0))t.innerHTML="",r&&T(t,r);else {let n=document.createRange(),s=e[0],i=S(s)?s.firstChild:s;n.setStartBefore(i),r?n.setEndBefore(r):n.setEndAfter(t),n.deleteContents();}e.forEach(n=>{S(n)&&n.unmount();});}function tr(t,e,r){return e===r?e:S(e)&&S(r)&&e.template===r.template?(r.inheritNode(e),r):e instanceof Text&&r instanceof Text?(e.textContent!==r.textContent&&(e.textContent=r.textContent),e):(oe(t,r,e),r)}function er(t){let e=new Map;for(let[r,n]of t.entries()){let s=R(n,r);e.set(s,n);}return e}function R(t,e){if(S(t)){let r=t.key;if(r!=null)return String(r)}return `_$${e}$`}var tt=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),E.isSSR&&(this.componentIndex=Ge(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=>T(t,i,e)),this.nodes;m(this.template)&&(this.template=wt(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),E.isSSR?this.mapSSGNodeTree(t):this.mapNodeTree(t,n),T(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=>U(r)),!this.template.innerHTML&&!this.nodes.length){let r=(e=(t=this.props)==null?void 0:t[ne])==null?void 0:e.children;r&&(m(r)?r.forEach(n=>{this.deleteFragmentTextNode(n);}):this.deleteFragmentTextNode(r));}this.nodes=[],this.mounted=!1;}deleteFragmentTextNode(t){var e;kt(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));}):U(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])=>{if(s===B&&i)this.patchChildren(t,e,i,n);else if(s==="ref")r[s].value=e;else if(M(s,"on"))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 s=`update${Ft(r)}`;if(s&&t[s]&&p(t[s]))return this.bindValueKeys.push(s),t[s]}patchChildren(t,e,r,n){if(m(r))r.filter(Boolean).forEach((s,i)=>{var o;let[a,d]=m(s)?s:[s,null],u=At(d)?null:(o=this.treeMap.get(d))!=null?o:null,c=`${t}:${B}:${i}`,l=this.getNodeTrack(c,!0,n);this.patchChild(l,e,a,u);});else {let s=`${t}:${B}: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=y(e,s,n);}patchAttribute(t,e,r,n,s){let i=this.getNodeTrack(`${t}:${r}`),o=p(n)?n():n,a=g(o)?o:Et(o);ee(e,r,a.value);let d=D(()=>{let c=p(n)?n():n;re(c)&&re(a.peek())&&JSON.stringify(a.value)===JSON.stringify(c)||(a.value=g(c)?c.value:c,ee(e,r,a.value));}),u;s&&Lt(e)&&(u=ze(e,c=>{s(c);})),i.cleanup=()=>{d&&d(),u&&u();};}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){p(r)?t.cleanup=D(()=>{let s=ct(r()).map(te);E.isSSR?t.lastNodes=this.reconcileChildren(e,s,n):t.lastNodes=Qe(e,t.lastNodes,s,n);}):ct(r).forEach((s,i)=>{let o=te(s),a=R(o,i);E.isSSR?t.lastNodes=this.reconcileChildren(e,[o],n):(t.lastNodes.set(a,o),T(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=R(i,o);i.nodeType===Node.TEXT_NODE?s.forEach(d=>{i.textContent===d.textContent&&t.replaceChild(i,d);}):T(t,i,r),n.set(a,i);}),n}};function xt(t,e,r){if(X(t)){if(Je(t)){let n=Ye(t);return e={[Fe]:e},new tt(wt(n),e,r)}else if(t===Ct)return e={[ne]:e},new tt(wt(Ct),e,r)}return p(t)?new Ot(t,e,r):new tt(t,e,r)}function br(t){return t instanceof Ot}function S(t){return t instanceof Ot||t instanceof tt}function wt(t){let e=document.createElement("template");return e.innerHTML=Xe(t),e}function _r(t){return xt(Ct,{children:m(t.children)?t.children.filter(Boolean):[t.children]})}function yr(t){et("onMounted"),_.ref&&_.ref.addHook("mounted",t);}function Er(t){et("onDestroy"),_.ref&&_.ref.addHook("destroy",t);}function et(t,e){_.ref||console.error(`"${t}"(key: ${jt(e)?e.toString():e}) can only be called within the component function body
|
|
9
|
+
and cannot be used in asynchronous or deferred calls.`);}function Nr(t,e){et("useProvide",t),_.ref&&_.ref.setContext(t,e);}function Sr(t,e){var r;return et("useInject",t),(r=_.ref&&_.ref.getContext(t))!=null?r:e}function Cr(){return Et(null)}function Tr(t,e){E.setSSG();let n=new Pt(t,e||{}).mount();return E.setClient(),n}function wr(t,e){let r=typeof e=="string"?document.querySelector(e):e;if(!r)throw new Error(`Could not find container: ${e}`);E.setSSR(),xt(t).mount(r),E.setClient();}function Mr(t,e){return E.isSSG?new Pt(t,e):xt(t,e)}globalThis&&(globalThis.__essor_version__=$t);/**
|
|
10
|
+
* @estjs/signal v0.0.14-beta.5
|
|
11
11
|
* (c) 2023-Present jiangxd <jiangxd2016@gmail.com>
|
|
12
12
|
* @license MIT
|
|
13
13
|
**/
|
|
14
14
|
/**
|
|
15
|
-
* @estjs/template v0.0.14-beta.
|
|
15
|
+
* @estjs/template v0.0.14-beta.5
|
|
16
16
|
* (c) 2023-Present jiangxd <jiangxd2016@gmail.com>
|
|
17
17
|
* @license MIT
|
|
18
18
|
**/
|
|
19
19
|
|
|
20
|
-
exports.Fragment =
|
|
21
|
-
exports.clearReactive =
|
|
22
|
-
exports.createStore =
|
|
23
|
-
exports.essor_version =
|
|
24
|
-
exports.h =
|
|
25
|
-
exports.hydrate =
|
|
26
|
-
exports.isComponent =
|
|
27
|
-
exports.isComputed =
|
|
20
|
+
exports.Fragment = _r;
|
|
21
|
+
exports.clearReactive = lr;
|
|
22
|
+
exports.createStore = fr;
|
|
23
|
+
exports.essor_version = $t;
|
|
24
|
+
exports.h = xt;
|
|
25
|
+
exports.hydrate = wr;
|
|
26
|
+
exports.isComponent = br;
|
|
27
|
+
exports.isComputed = Yt;
|
|
28
28
|
exports.isJsxElement = S;
|
|
29
29
|
exports.isReactive = K;
|
|
30
30
|
exports.isSignal = g;
|
|
31
31
|
exports.nextTick = _t;
|
|
32
|
-
exports.onDestroy =
|
|
33
|
-
exports.onMount =
|
|
34
|
-
exports.renderToString =
|
|
35
|
-
exports.shallowReactive =
|
|
36
|
-
exports.shallowSignal =
|
|
37
|
-
exports.signalObject =
|
|
38
|
-
exports.ssg =
|
|
39
|
-
exports.template =
|
|
32
|
+
exports.onDestroy = Er;
|
|
33
|
+
exports.onMount = yr;
|
|
34
|
+
exports.renderToString = Tr;
|
|
35
|
+
exports.shallowReactive = ar;
|
|
36
|
+
exports.shallowSignal = Et;
|
|
37
|
+
exports.signalObject = Zt;
|
|
38
|
+
exports.ssg = Mr;
|
|
39
|
+
exports.template = wt;
|
|
40
40
|
exports.toRaw = f;
|
|
41
|
-
exports.useBatch =
|
|
42
|
-
exports.useComputed =
|
|
41
|
+
exports.useBatch = Re;
|
|
42
|
+
exports.useComputed = Te;
|
|
43
43
|
exports.useEffect = D;
|
|
44
|
-
exports.useInject =
|
|
45
|
-
exports.useProvide =
|
|
46
|
-
exports.useReactive =
|
|
47
|
-
exports.useRef =
|
|
48
|
-
exports.useSignal =
|
|
49
|
-
exports.useWatch =
|
|
44
|
+
exports.useInject = Sr;
|
|
45
|
+
exports.useProvide = Nr;
|
|
46
|
+
exports.useReactive = Nt;
|
|
47
|
+
exports.useRef = Cr;
|
|
48
|
+
exports.useSignal = yt;
|
|
49
|
+
exports.useWatch = ur;
|
|
50
50
|
//# sourceMappingURL=essor.cjs.js.map
|
|
51
51
|
//# sourceMappingURL=essor.cjs.js.map
|