essor 0.0.14-beta.3 → 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 +30 -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 +34 -65
- package/dist/essor.dev.esm.js +34 -66
- 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,50 +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 Pt="0.0.14-beta.3";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 xt(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 Ot(t){return t==null}var p=t=>typeof t=="function";function st(t){return t===!1||t===null||t===void 0}var Rt=t=>["string","number","boolean","symbol","undefined"].includes(typeof t)||ie(t);function $t(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 At(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 m(e)?e.includes(t):p(e)?e(t):!1}var jt=t=>t.replaceAll(/[A-Z]+/g,(e,r)=>`${r>0?"-":""}${e.toLocaleLowerCase()}`);var Lt=t=>t.charAt(0).toUpperCase()+t.slice(1);function P(t,...e){console.warn.apply(console,[`[Essor warn]: ${t}`].concat(e));}var ce=Object.defineProperty,ae=Object.defineProperties,le=Object.getOwnPropertyDescriptors,kt=Object.getOwnPropertySymbols,ue=Object.prototype.hasOwnProperty,fe=Object.prototype.propertyIsEnumerable,It=(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)&&It(t,r,e[r]);if(kt)for(var r of kt(e))fe.call(e,r)&&It(t,r,e[r]);return t},he=(t,e)=>ae(t,le(e)),ut=[],ft=[],Ht=Promise.resolve(),ht=!1;function vt(t){return t?Ht.then(t):Ht}function de(t){ut.includes(t)||(ut.push(t),qt());}function qt(){ht||(ht=!0,vt(ge));}function pe(t){me(t,ft);}function me(t,e){e.includes(t)||(e.push(t),qt());}function ge(){ht=!1,ve();let t;for(;t=ut.shift();)t&&t();}function ve(){for(;ft.length>0;){let t=ft.shift();t&&t();}}function be(t,e){return e==="sync"?()=>t():e==="pre"?()=>pe(t):()=>{vt(()=>de(t));}}var y=null,dt=new WeakMap,lt=new WeakMap,H=Symbol("ReactiveSymbol"),F=Symbol("__raw"),Ft=Symbol("SignalValueKey"),Dt=Symbol("ComputedValueKey"),pt=Symbol("ReactiveArrayKey"),v=Symbol("ReactiveCollectionKey"),x=Symbol("ReactiveWeakCollectionKey"),mt=!1,Q=new Set;function h(t,e){if(!y)return;let r=dt.get(t);r||(r=new Map,dt.set(t,r));let n=r.get(e);n||(n=new Set,r.set(e,n)),n.add(y);}function b(t,e){let r=dt.get(t);if(!r)return;let n=r.get(e);n&&n.forEach(s=>{if(Z(s,"active")&&!s.active){n.delete(s);return}mt?Q.add(s):s();});}var Bt=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,b(this,Ft));}peek(){return this.__value}};function bt(t){return g(t)?t:new Bt(t)}function zt(t){return new Bt(t,!0)}function g(t){return !!(t&&(t!=null&&t.__signal))}var _e=class{constructor(t){this.fn=t,this.__computed=!0;let e=y;y=this.run.bind(this),this.__value=this.fn(),y=e;}peek(){return this.__value}run(){let t=this.fn();w(t,this.__value)&&(this.__value=t,b(this,Dt));}get value(){return h(this,Dt),this.__value}};function Ee(t){return new _e(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=y;y=i.init?i:i.scheduler,t(),s&&s(),y=a;}let o=be(i,r);return i.scheduler=o,i.init=!0,i.active=!0,n&&n(),i(),()=>{i.active=!1,y=null;}}function rr(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]=L(s,e)||g(i)?i:bt(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 Ne(t,e){return G(t,!1,e)}function Jt(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=g(i)?i.value:i;return L(n,e)?o:(h(r,n),C(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);g(o)&&(o=o.value),g(s)&&(s=s.value);let a=Reflect.set(r,n,s,i);return w(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}}),Kt=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,pt),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,pt),n[e].apply(this,r)};}),t}var Ce=(t,e)=>({get(r,n,s){if(n===H)return !0;if(n===F)return r;if(Kt.hasOwnProperty(n))return Reflect.get(Kt,n,s);let i=Reflect.get(r,n,s);return L(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)&&b(r,n),(n==="length"||!o)&&b(r,"length")),a}}),Te={get(t,e){return e===H?!0:e===F?t:((e===Symbol.iterator||e==="size")&&h(t,v),Reflect.get(Z(Gt,e)&&e in t?Gt:t,e,t))}},we={get(t,e){return e===H?!0:e===F?t:Reflect.get(Z(Wt,e)&&e in t?Wt:t,e,t)}},Gt={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]()}},Wt={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 b(r,x),n},add(t){let e=f(this),r=e.add(t);return b(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 b(e,x),r}};function G(t,e=!1,r){if(!C(t)||K(t))return t;if(lt.has(t))return lt.get(t);let n;m(t)?(h(t,pt),n=Ce(e,r)):J(t)||Y(t)?(h(t,v),n=Te):nt(t)||rt(t)?(h(t,x),n=we):n=ye(e,r);let s=new Proxy(t,n);return lt.set(t,s),s}function nr(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}Me(()=>{m(t)?t.length=0:J(t)||Y(t)?t.clear():C(t)&&Object.keys(t).forEach(e=>{delete t[e];});});}function Me(t){try{mt=!0,t();}finally{mt=!1,Pe();}}function Pe(){Q.size>0&&(Q.forEach(t=>t()),Q.clear());}function sr(t,e,r){return Re(t,e,r)}var Ut=void 0,V,gt=!1;function xe(t){V=t,gt||(gt=!0,vt(Oe));}function Oe(){V==null||V(),V=null,gt=!1;}function Re(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=>$e(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=()=>k(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&&xe(()=>{e(c,o),o=c;}),!a&&(o=c));},u=D(d,{flush:"sync"});return a=!0,n&&d(),u}function $e(t){return g(t)||Xt(t)?t.value:K(t)?I({},t):p(t)?t():(P("Invalid source",t),at)}function k(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))k(t.value,e,r);else if(m(t))for(let n of t)k(n,e,r);else if(J(t)||Y(t))t.forEach(n=>{k(n,e,r);});else if(it(t))for(let n in t)k(t[n],e,r);return t}function Ae(t){let{state:e,getters:r,actions:n}=t,s=I({},e),i=Ne(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 Ee(()=>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 B=l.apply(i,$);return a.forEach(A=>A(i)),B});}return u}function ir(t){return function(){let e;typeof t=="function"?e=je(t):e=t;let r=Ae(e);return typeof t=="function"&&Object.keys(e.actions||{}).forEach(n=>{r[n]=e.actions[n].bind(r);}),r}}function je(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",U="children",Et="",te="0",Le="1",_t=" __PLACEHOLDER__ ",ke=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 ke,ee=new Map;function Ie(t,e){ee.set(t,{index:e});}function He(t){var e;return (e=ee.get(t))==null?void 0:e.index}var St=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());}};St.ref=null;St.context={};var _=St;function Nt(t){return t instanceof Ct}var O=1,Ct=class extends _{constructor(t,e={},r){super(),this.template=t,this.props=e,this.key=r,Ie(t,O),this.templates=this.processTemplate();}processTemplate(){if(m(this.template)){let t=this.template.join(_t);return this.processHtmlString(t).split(_t)}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(_t,"").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 Nt(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}="${At(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(Nt(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(","),Fe="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||Nt(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=N.isSSR;S(e)?e.mount(t,n):n&&!s?n.before(e):s||t.append(e);}function q(t){S(t)?t.unmount():t.parentNode&&t.remove();}function ne(t,e,r){T(t,e,r),q(r);}function Vt(t,e,r){e==="class"?De(t,r):e==="style"?Ke(t,r):Ge(t,e,r);}function De(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 Ke(t,e){typeof e=="string"?t.style.cssText=e:e&&typeof e=="object"&&Object.entries(e).forEach(([n,s])=>{t.style.setProperty(jt(n),String(s));});}function Ge(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 We(t,e){if(t instanceof HTMLInputElement)switch(t.type){case"checkbox":return E(t,"change",()=>{e(!!t.checked);});case"date":return E(t,"change",()=>{e(t.value?t.value:"");});case"file":return E(t,"change",()=>{t.files&&e(t.files);});case"number":return E(t,"input",()=>{let r=Number.parseFloat(t.value);e(Number.isNaN(r)?"":String(r));});case"radio":return E(t,"change",()=>{e(t.checked?t.value:"");});case"text":return E(t,"input",()=>{e(t.value);})}if(t instanceof HTMLSelectElement)return E(t,"change",()=>{e(t.value);});if(t instanceof HTMLTextAreaElement)return E(t,"input",()=>{e(t.value);})}Promise.resolve();function E(t,e,r){return t.addEventListener(e,r),()=>t.removeEventListener(e,r)}function Ue(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 Fe.includes(t)}function Be(t){return re.includes(t)?`<${t}/>`:`<${t}></${t}>`}function se(t){return g(t)?t.value:t}var Tt=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===U):{}}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!==U&&this.patchNormalProp(r,n);this.props=t;}}patchEventListener(t,e){let r=t.slice(2).toLowerCase(),n=E(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 ze(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=Ye(r),d=0;for(let[u,c]of r.entries()){let l=i[d],$=R(l,u);for(;l&&!a.has($);)q(l),e.delete($),l=i[++d],$=R(l,u);let B=R(c,u),A=e.get(B);if(A&&(c=Je(t,A,c)),l)if(l===A)d++;else {let Mt=document.createComment("");T(t,Mt,l),o.push([Mt,c]);}else T(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)&&q(u);}),s}function Xe(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 Je(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 Ye(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),N.isSSR&&(this.componentIndex=He(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=yt(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),N.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=>q(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;Rt(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));}):q(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===U&&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${Lt(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=Ot(d)?null:(o=this.treeMap.get(d))!=null?o:null,c=`${t}:${U}:${i}`,l=this.getNodeTrack(c,!0,n);this.patchChild(l,e,a,u);});else {let s=`${t}:${U}: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=E(e,s,n);}patchAttribute(t,e,r,n,s){let i=this.getNodeTrack(`${t}:${r}`),o=p(n)?n():n,a=g(o)?o:bt(o);Vt(e,r,a.value);let d=D(()=>{let c=p(n)?n():n;a.value=g(c)?c.value:c,Vt(e,r,a.value);}),u;s&&$t(e)&&(u=We(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);N.isSSR?t.lastNodes=this.reconcileChildren(e,s,n):t.lastNodes=ze(e,t.lastNodes,s,n);}):ct(r).forEach((s,i)=>{let o=Qt(s),a=R(o,i);N.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 wt(t,e,r){if(X(t)){if(qe(t)){let n=Be(t);return e={[Le]:e},new tt(yt(n),e,r)}else if(t===Et)return e={[te]:e},new tt(yt(Et),e,r)}return p(t)?new Tt(t,e,r):new tt(t,e,r)}function hr(t){return t instanceof Tt}function S(t){return t instanceof Tt||t instanceof tt}function yt(t){let e=document.createElement("template");return e.innerHTML=Ue(t),e}function dr(t){return wt(Et,{children:m(t.children)?t.children.filter(Boolean):[t.children]})}function pr(t){et("onMounted"),_.ref&&_.ref.addHook("mounted",t);}function mr(t){et("onDestroy"),_.ref&&_.ref.addHook("destroy",t);}function et(t,e){_.ref||console.error(`"${t}"(key: ${xt(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
|
-
exports.
|
|
32
|
-
exports.
|
|
33
|
-
exports.
|
|
34
|
-
exports.
|
|
35
|
-
exports.
|
|
36
|
-
exports.
|
|
37
|
-
exports.
|
|
38
|
-
exports.
|
|
31
|
+
exports.nextTick = _t;
|
|
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;
|
|
39
40
|
exports.toRaw = f;
|
|
40
|
-
exports.useBatch =
|
|
41
|
-
exports.useComputed =
|
|
41
|
+
exports.useBatch = Re;
|
|
42
|
+
exports.useComputed = Te;
|
|
42
43
|
exports.useEffect = D;
|
|
43
|
-
exports.useInject =
|
|
44
|
-
exports.useProvide =
|
|
45
|
-
exports.useReactive =
|
|
46
|
-
exports.useRef =
|
|
47
|
-
exports.useSignal =
|
|
48
|
-
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;
|
|
49
50
|
//# sourceMappingURL=essor.cjs.js.map
|
|
50
51
|
//# sourceMappingURL=essor.cjs.js.map
|