essor 0.0.14-beta.2 → 0.0.14-beta.3
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 +27 -28
- 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 +5 -9
- package/dist/essor.dev.esm.js +6 -9
- 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,50 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* essor v0.0.14-beta.
|
|
4
|
+
* essor v0.0.14-beta.3
|
|
5
5
|
* (c) 2023-Present jiangxd <jiangxd2016@gmail.com>
|
|
6
6
|
* @license MIT
|
|
7
7
|
**/
|
|
8
|
-
var Ot="0.0.14-beta.2";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 Lt(t){return t.replaceAll(/["&'<>]/g,e=>{switch(e){case"&":return "&";case"<":return "<";case">":return ">";case'"':return """;case"'":return "'";default:return e}})}function L(t,e){return m(e)?e.includes(t):p(e)?e(t):!1}var kt=t=>t.replaceAll(/[A-Z]+/g,(e,r)=>`${r>0?"-":""}${e.toLocaleLowerCase()}`);var It=t=>t.charAt(0).toUpperCase()+t.slice(1);function P(t,...e){console.warn.apply(console,[`[Essor warn]: ${t}`].concat(e));}var ce=Object.defineProperty,ae=Object.defineProperties,le=Object.getOwnPropertyDescriptors,Ht=Object.getOwnPropertySymbols,ue=Object.prototype.hasOwnProperty,fe=Object.prototype.propertyIsEnumerable,Ft=(t,e,r)=>e in t?ce(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,I=(t,e)=>{for(var r in e||(e={}))ue.call(e,r)&&Ft(t,r,e[r]);if(Ht)for(var r of Ht(e))fe.call(e,r)&&Ft(t,r,e[r]);return t},he=(t,e)=>ae(t,le(e)),ut=[],ft=[],Dt=Promise.resolve(),ht=!1;function vt(t){return t?Dt.then(t):Dt}function de(t){ut.includes(t)||(ut.push(t),zt());}function zt(){ht||(ht=!0,vt(ge));}function pe(t){me(t,ft);}function me(t,e){e.includes(t)||(e.push(t),zt());}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"),Kt=Symbol("SignalValueKey"),Gt=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,Kt),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,Kt));}peek(){return this.__value}};function _t(t){return g(t)?t:new bt(t)}function er(t){return new bt(t,!0)}function Xt(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,Gt));}get value(){return h(this,Gt),this.__value}};function Ee(t){return new _e(t)}function Jt(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:_t(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 Et(t,e){return G(t,!1,e)}function nr(t,e){return G(t,!0,e)}var Ne=(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}}),Wt=ye();function ye(){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 Se=(t,e)=>({get(r,n,s){if(n===H)return !0;if(n===F)return r;if(Wt.hasOwnProperty(n))return Reflect.get(Wt,n,s);let i=Reflect.get(r,n,s);return L(n,e)?i:(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}}),Ce={get(t,e){return e===H?!0:e===F?t:((e===Symbol.iterator||e==="size")&&h(t,v),Reflect.get(Z(Ut,e)&&e in t?Ut:t,e,t))}},Te={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,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]()}},qt={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=Se(e,r)):J(t)||Y(t)?(h(t,v),n=Ce):nt(t)||rt(t)?(h(t,x),n=Te):n=Ne(e,r);let s=new Proxy(t,n);return lt.set(t,s),s}function sr(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}we(()=>{m(t)?t.length=0:J(t)||Y(t)?t.clear():C(t)&&Object.keys(t).forEach(e=>{delete t[e];});});}function we(t){try{mt=!0,t();}finally{mt=!1,Me();}}function Me(){Q.size>0&&(Q.forEach(t=>t()),Q.clear());}function ir(t,e,r){return Oe(t,e,r)}var Bt=void 0,V,gt=!1;function Pe(t){V=t,gt||(gt=!0,vt(xe));}function xe(){V==null||V(),V=null,gt=!1;}function Oe(t,e,{deep:r,immediate:n}={}){let s,i=m(t);if(g(t)||Jt(t))s=()=>t.value;else if(K(t))s=()=>I({},t);else if(i)s=()=>t.map(c=>Re(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(Bt):Bt,a=!1,d=()=>{let c=s();w(c,o)&&(n&&e&&(e(c,o),o=c),a&&e&&Pe(()=>{e(c,o),o=c;}),!a&&(o=c));},u=D(d,{flush:"sync"});return a=!0,n&&d(),u}function Re(t){return g(t)||Jt(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 $e(t){let{state:e,getters:r,actions:n}=t,s=I({},e),i=Et(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 or(t){return function(){let e;typeof t=="function"?e=Ae(t):e=t;let r=$e(e);return typeof t=="function"&&Object.keys(e.actions||{}).forEach(n=>{r[n]=e.actions[n].bind(r);}),r}}function Ae(t){let e=new t,r=Object.create(null),n={},s={};return Object.getOwnPropertyNames(e).forEach(i=>{r[i]=e[i];}),Object.getOwnPropertyNames(t.prototype).forEach(i=>{let o=Object.getOwnPropertyDescriptor(t.prototype,i);o&&(typeof o.get=="function"?n[i]=function(){return o.get.call(this)}:typeof o.value=="function"&&i!=="constructor"&&(s[i]=function(...a){return o.value.apply(this,a)}));}),{state:r,getters:n,actions:s}}var Yt="on",Zt="update",U="children",yt="",te="0",je="1",Nt=" __PLACEHOLDER__ ",Le=class{constructor(){this.renderMode=0;}get isSSG(){return this.renderMode===1}get isSSR(){return this.renderMode===2}get isClient(){return this.renderMode===0}setSSR(){this.renderMode=2;}setSSG(){this.renderMode=1;}setClient(){this.renderMode=0;}},N=new Le,ee=new Map;function ke(t,e){ee.set(t,{index:e});}function Ie(t){var e;return (e=ee.get(t))==null?void 0:e.index}var 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,ke(t,O),this.templates=this.processTemplate();}processTemplate(){if(m(this.template)){let t=this.template.join(Nt);return this.processHtmlString(t).split(Nt)}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(Nt,"").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}="${Lt(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(","),He="a,abbr,acronym,address,applet,area,article,aside,audio,b,base,basefont,bdi,bdo,bgsound,big,blink,blockquote,body,br,button,canvas,caption,center,cite,code,col,colgroup,command,content,data,datalist,dd,del,details,dfn,dialog,dir,div,dl,dt,em,embed,fieldset,figcaption,figure,font,footer,form,frame,frameset,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,i,iframe,image,img,input,ins,kbd,keygen,label,legend,li,link,listing,main,map,mark,marquee,menu,menuitem,meta,meter,nav,nobr,noframes,noscript,object,ol,optgroup,option,output,p,param,picture,plaintext,pre,progress,q,rb,rp,rt,rtc,ruby,s,samp,script,section,select,shadow,small,source,spacer,span,strike,strong,style,sub,summary,sup,table,tbody,td,template,textarea,tfoot,th,thead,time,title,tr,track,tt,u,ul,var,video,wbr,xmp".split(",");function Qt(t){if(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=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"?Fe(t,r):e==="style"?De(t,r):Ke(t,e,r);}function Fe(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 De(t,e){typeof e=="string"?t.style.cssText=e:e&&typeof e=="object"&&Object.entries(e).forEach(([n,s])=>{t.style.setProperty(kt(n),String(s));});}function Ke(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 Ge(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 We(t){let e=[],r=[],n=/<\/?([\da-z-]+)([^>]*)>/gi,s=0;for(;;){let i=n.exec(t);if(!i)break;let[o,a]=i,d=o[1]==="/";if(r.push(t.slice(s,i.index)),s=i.index+o.length,d){for(;e.length>0&&e[e.length-1]!==a;){let u=e.pop();u&&r.push(`</${u}>`);}e.length>0&&e.pop();}else re.includes(a)||e.push(a);r.push(o);}for(r.push(t.slice(s));e.length>0;){let i=e.pop();i&&r.push(`</${i}>`);}return r.join("")}function Ue(t){return He.includes(t)}function qe(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?Et(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 Be(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=Je(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=Xe(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(B,c);}return o.forEach(([u,c])=>{ne(t,c,u);}),e.forEach((u,c)=>{u.isConnected&&!s.has(c)&&q(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 Xe(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 Je(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=Ie(this.template));}get firstChild(){var t;return (t=this.nodes[0])!=null?t:null}get isConnected(){return this.mounted}addEventListener(){}removeEventListener(){}mount(t,e){var r;if(this.parent=t,this.isConnected)return this.nodes.forEach(i=>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),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;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));}):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${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}:${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:_t(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&&jt(e)&&(u=Ge(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=Be(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 Pt(t,e,r){if(X(t)){if(Ue(t)){let n=qe(t);return e={[je]:e},new tt(Ct(n),e,r)}else if(t===yt)return e={[te]:e},new tt(Ct(yt),e,r)}return p(t)?new Mt(t,e,r):new tt(t,e,r)}function dr(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=We(t),e}function pr(t){return Pt(yt,{children:m(t.children)?t.children.filter(Boolean):[t.children]})}function mr(t){et("onMounted"),_.ref&&_.ref.addHook("mounted",t);}function gr(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 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 gr(t,e){et("useProvide",t),_.ref&&_.ref.setContext(t,e);}function vr(t,e){var r;return et("useInject",t),(r=_.ref&&_.ref.getContext(t))!=null?r:e}function br(){return zt(null)}function _r(t,e){N.setSSG();let n=new Ct(t,e||{}).mount();return N.setClient(),n}function Er(t,e){let r=typeof e=="string"?document.querySelector(e):e;if(!r)throw new Error(`Could not find container: ${e}`);N.setSSR(),wt(t).mount(r),N.setClient();}function Nr(t,e){return N.isSSG?new Ct(t,e):wt(t,e)}globalThis&&(globalThis.__essor_version__=Pt);/**
|
|
10
|
+
* @estjs/signal v0.0.14-beta.3
|
|
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.3
|
|
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 = dr;
|
|
21
|
+
exports.clearReactive = nr;
|
|
22
|
+
exports.createStore = ir;
|
|
23
|
+
exports.essor_version = Pt;
|
|
24
|
+
exports.h = wt;
|
|
25
|
+
exports.hydrate = Er;
|
|
26
|
+
exports.isComponent = hr;
|
|
27
|
+
exports.isComputed = Xt;
|
|
28
28
|
exports.isJsxElement = S;
|
|
29
29
|
exports.isReactive = K;
|
|
30
30
|
exports.isSignal = g;
|
|
31
|
-
exports.onDestroy =
|
|
32
|
-
exports.onMount =
|
|
33
|
-
exports.renderToString =
|
|
34
|
-
exports.shallowReactive =
|
|
35
|
-
exports.shallowSignal =
|
|
31
|
+
exports.onDestroy = mr;
|
|
32
|
+
exports.onMount = pr;
|
|
33
|
+
exports.renderToString = _r;
|
|
34
|
+
exports.shallowReactive = Jt;
|
|
35
|
+
exports.shallowSignal = zt;
|
|
36
36
|
exports.signalObject = rr;
|
|
37
|
-
exports.ssg =
|
|
38
|
-
exports.template =
|
|
37
|
+
exports.ssg = Nr;
|
|
38
|
+
exports.template = yt;
|
|
39
39
|
exports.toRaw = f;
|
|
40
|
-
exports.useBatch =
|
|
40
|
+
exports.useBatch = Me;
|
|
41
41
|
exports.useComputed = Ee;
|
|
42
42
|
exports.useEffect = D;
|
|
43
|
-
exports.useInject =
|
|
44
|
-
exports.useProvide =
|
|
45
|
-
exports.useReactive =
|
|
46
|
-
exports.useRef =
|
|
47
|
-
exports.
|
|
48
|
-
exports.
|
|
49
|
-
exports.useWatch = ir;
|
|
43
|
+
exports.useInject = vr;
|
|
44
|
+
exports.useProvide = gr;
|
|
45
|
+
exports.useReactive = Ne;
|
|
46
|
+
exports.useRef = br;
|
|
47
|
+
exports.useSignal = bt;
|
|
48
|
+
exports.useWatch = sr;
|
|
50
49
|
//# sourceMappingURL=essor.cjs.js.map
|
|
51
50
|
//# sourceMappingURL=essor.cjs.js.map
|