@dlightjs/dlight
Advanced tools
Comparing version 1.0.0-next.7 to 1.0.0-next.8
@@ -1,2 +0,2 @@ | ||
import{Store as b}from"@dlightjs/store";"global"in b||(typeof window<"u"?b.global=window:typeof global<"u"?b.global=global:b.global={});"document"in b||typeof document<"u"&&(b.document=document);var r={...b,delegatedEvents:new Set};function z(i){r.global=i}function q(i){r.document=i}function g(i,t){return!t||i.length!==t.length?!1:i.every((e,n)=>!(e instanceof Object)&&t[n]===e)}var f={Comp:0,For:1,Cond:2,Env:3,Exp:4,Snippet:5,Try:6},l=class{_$dlNodeType;constructor(t){this._$dlNodeType=t}get _$el(){return l.toEls(this._$nodes)}static toEls(t){let e=[];return this.loopShallowEls(t,n=>{e.push(n)}),e}static loopShallowEls(t,e){let n=[...t].reverse();for(;n.length>0;){let s=n.pop();"_$dlNodeType"in s?s._$nodes&&n.push(...[...s._$nodes].reverse()):e(s)}}static addParentEl(t,e){t.forEach(n=>{"_$dlNodeType"in n&&(n._$parentEl=e,n._$nodes&&l.addParentEl(n._$nodes,e))})}static getFlowIndexFromNodes(t,e){let n=0,s=[...t].reverse();for(;s.length>0;){let o=s.pop();if(o===e)break;"_$dlNodeType"in o?o._$nodes&&s.push(...[...o._$nodes].reverse()):n++}return n}static appendNodesWithSibling(t,e,n){return n?this.insertNodesBefore(t,e,n):this.appendNodes(t,e)}static appendNodesWithIndex(t,e,n,s){return s=s??e.childNodes.length,s!==n?this.insertNodesBefore(t,e,e.childNodes[n]):this.appendNodes(t,e)}static insertNodesBefore(t,e,n){let s=0;return this.loopShallowEls(t,o=>{e.insertBefore(o,n),s++}),s}static appendNodes(t,e){let n=0;return this.loopShallowEls(t,s=>{e.appendChild(s),n++}),n}static addWillUnmount(t,e){let n=r.global.WillUnmountStore,s=n[n.length-1];s&&s.push(e.bind(null,t))}static addDidUnmount(t,e){let n=r.global.DidUnmountStore,s=n[n.length-1];s&&s.push(e.bind(null,t))}static addDidMount(t,e){r.global.DidMountStore||(r.global.DidMountStore=[]),r.global.DidMountStore.push(e.bind(null,t))}static runDidMount(){let t=r.global.DidMountStore;if(!(!t||t.length===0)){for(let e=t.length-1;e>=0;e--)t[e]();r.global.DidMountStore=[]}}};function y(i,t,e){if(e.length===0)return!1;let n=`$${t}`;return g(e,i[n])?!0:(i[n]=e,!1)}function C(i,t){Object.entries(t).forEach(([e,n])=>{e.startsWith("--")?i.style.setProperty(e,n):i.style[e]=n})}function K(i,t){Object.assign(i.dataset,t)}function T(i,t,e,n){y(i,t,n)||(i[t]=e())}function G(i,t){Object.entries(t).forEach(([e,n])=>{if(e==="style")return C(i,n);if(e==="dataset")return K(i,n);T(i,e,()=>n,[])})}function O(i,t,e,n){y(i,t,n)||i.setAttribute(t,e())}function Y(i,t){Object.entries(t).forEach(([e,n])=>{O(i,e,()=>n,[])})}function J(i,t,e){let n=i[`$on${t}`];n&&i.removeEventListener(t,n),i.addEventListener(t,e),i[`$on${t}`]=e}function Q(i){let t=`$$${i.type}`;for(let e of i.composedPath())if(e[t]&&e[t](i),i.cancelBubble)return}function it(i,t,e){i[`$$${t}`]!==e&&(i[`$$${t}`]=e,r.delegatedEvents.has(t)||(r.delegatedEvents.add(t),r.document.addEventListener(t,Q)))}function ot(i){return r.document.createElement(i)}function I(i,t,e){i._$nodes||(i._$nodes=Array.from(i.childNodes)),i._$nodes.splice(e,0,t);let n=l.getFlowIndexFromNodes(i._$nodes,t);l.appendNodesWithIndex([t],i,n),l.addParentEl([t],i)}function j(i,t,e,n){if(t==="style")return C(i,e());if(t==="dataset")return K(i,e());if(t!=="element"){if(t==="prop")return G(i,e());if(t==="attr")return Y(i,e());if(t==="innerHTML")return T(i,"innerHTML",e,n);if(t==="textContent")return T(i,"textContent",e,n);if(t!=="forwardProp"){if(t.startsWith("on"))return J(i,t.slice(2).toLowerCase(),e());O(i,t,e,n)}}}var v=class extends l{constructor(){super(f.Comp)}_$init(t,e,n,s){this._$notInitd=!0,s&&s._$addForwardProps(this),e&&this._$setContent(()=>e[0],e[1]),t&&t.forEach(([o,h,d])=>{if(o==="props")return this._$setProps(()=>h,d);this._$setProp(o,()=>h,d)}),n&&(this._$children=n),r.global.DLEnvStore&&Object.entries(r.global.DLEnvStore.envs).forEach(([o,[h,d]])=>{if(o==="_$catchable"){this._$catchable=h;return}`$e$${o}`in this&&(d.addNode(this),this._$initEnv(o,h,d))}),this._$callUpdatesBeforeInit(),this.didMount&&l.addDidMount(this,this.didMount.bind(this)),this.willUnmount&&l.addWillUnmount(this,this.willUnmount.bind(this)),l.addDidUnmount(this,this._$setUnmounted.bind(this)),this.didUnmount&&l.addDidUnmount(this,this.didUnmount.bind(this)),this.willMount?.(),this._$nodes=this.Body?.()??[],this._$catchable&&(this._$update&&(this._$update=this._$catchable(this._$update.bind(this))),this._$updateDerived=this._$catchable(this._$updateDerived.bind(this)),delete this._$catchable)}_$setUnmounted(){this._$unmounted=!0}_$callUpdatesBeforeInit(){let t=Object.getOwnPropertyNames(Object.getPrototypeOf(this)),e=Object.getOwnPropertyNames(this);[...t,...e].forEach(s=>{if(s.startsWith("$w$"))return this[s.slice(3)]();if(s.startsWith("$md$")){let o=s.slice(4);this[o]=this[o]();return}if(s.startsWith("$f$")){let o=s.slice(3);this[o]=this[s],this._$updateDerived(o)}}),delete this._$notInitd}_$setPropToForward(t,e,n){this._$forwardPropsSet.forEach(s=>{let o=t==="_$content";if(s._$dlNodeType===f.Comp){o?s._$setContent(()=>e,n):s._$setProp(t,()=>e,n);return}s instanceof HTMLElement&&(o&&(t="textContent"),j(s,t,()=>e,n))})}_$setForwardProp(t,e,n){let s="_$notInitd"in this;if(!s&&this._$cache(t,n))return;let o=e();t==="_$content"&&this._$contentKey&&(this[this._$contentKey]=o,this._$updateDerived(this._$contentKey)),this[t]=o,this._$updateDerived(t),s?this._$forwardPropsId.push(t):this._$setPropToForward(t,o,n)}_$addForwardProps(t){this._$forwardPropsSet.add(t),this._$forwardPropsId.forEach(e=>{this._$setPropToForward(e,this[e],[])}),l.addWillUnmount(t,this._$forwardPropsSet.delete.bind(this._$forwardPropsSet,t))}_$cache(t,e){if(!e||!e.length)return!1;let n=`$cc$${t}`;return g(e,this[n])?!0:(this[n]=e,!1)}_$setContent(t,e){if("_$forwardProps"in this)return this._$setForwardProp("_$content",t,e);let n=this._$contentKey;n&&(this._$cache(n,e)||(this[n]=t(),this._$updateDerived(n)))}_$setProp(t,e,n){if("_$forwardProps"in this)return this._$setForwardProp(t,e,n);if(!(`$p$${t}`in this)){console.warn(`[${t}] is not a prop in ${this.constructor.name}`);return}this._$cache(t,n)||(this[t]=e(),this._$updateDerived(t))}_$setProps(t,e){if(this._$cache("props",e))return;let n=t();n&&Object.entries(n).forEach(([s,o])=>{this._$setProp(s,()=>o,[])})}_$initEnv(t,e,n){this[t]=e,this[`$en$${t}`]=n}_$updateEnv(t,e,n){`$e$${t}`in this&&n===this[`$en$${t}`]&&(this[t]=e,this._$updateDerived(t))}_$ud(t,e){return this._$updateDerived(e),t}_$updateDerived(t){"_$notInitd"in this||(this[`$s$${t}`]?.forEach(e=>{`$w$${e}`in this?this[e](t):`$md$${e}`in this?this[e]._$update():this[e]=this[`$f$${e}`]}),this._$updateView(t))}_$updateView(t){if(this._$modelCallee)return this._$updateModelCallee();if(!("_$update"in this))return;let e=this[`$$${t}`];e&&("_$depNumsToUpdate"in this?this._$depNumsToUpdate.push(e):(this._$depNumsToUpdate=[e],Promise.resolve().then(()=>{if(this._$unmounted)return;let n=this._$depNumsToUpdate;if(n.length>0){let s=n.reduce((o,h)=>o|h,0);this._$update(s)}delete this._$depNumsToUpdate})))}_$updateModelCallee(){"_$depNumsToUpdate"in this||(this._$depNumsToUpdate=!0,Promise.resolve().then(()=>{this._$unmounted||(this._$modelCallee._$updateDerived(this._$modelKey),delete this._$depNumsToUpdate)}))}static _$updateModel(t,e,n){let s=e()??{},o=s.s??[];s.m?.forEach(([d,$])=>{Object.entries(d).forEach(([c,w])=>{o.push([c,w,$])})}),o.forEach(([d,$,c])=>{t._$setProp(d,()=>$,c)});let h=n();h&&t._$setContent(()=>h[0],h[1])}static _$releaseModel(){delete this._$modelCallee}_$injectModel(t,e,n,s){let o=e()??{},h=o.s??[];o.m?.forEach(([$,c])=>{Object.entries($).forEach(([w,u])=>{h.push([w,u,c])})});let d=new t;return d._$init(h,n(),null,null),d._$modelCallee=this,d._$modelKey=s,d._$update=v._$updateModel.bind(null,d,e,n),d}},lt=v,at=v;function pt(i,t){i._$updateDerived(t)}var W=class{constructor(){this.envs={},this.currentEnvNodes=[]}addEnvNode(t){this.currentEnvNodes.push(t),this.mergeEnvs()}replaceEnvNodes(t){this.currentEnvNodes=t,this.mergeEnvs()}removeEnvNode(){this.currentEnvNodes.pop(),this.mergeEnvs()}mergeEnvs(){this.envs={},this.currentEnvNodes.forEach(t=>{Object.entries(t.envs).forEach(([e,n])=>{this.envs[e]=[n,t]})})}},F=class extends l{constructor(t,e){super(f.Env),"DLEnvStore"in r.global||(r.global.DLEnvStore=new W),this.envs=t,this.depsArr=e,this.updateNodes=new Set,r.global.DLEnvStore.addEnvNode(this)}cached(t,e){return!t||!t.length?!1:g(t,this.depsArr[e])?!0:(this.depsArr[e]=t,!1)}updateEnv(t,e,n){if(this.cached(n,t))return;let s=e();this.envs[t]=s,r.global.DLEnvStore.currentEnvNodes.includes(this)&&r.global.DLEnvStore.mergeEnvs(),this.updateNodes.forEach(o=>{o._$updateEnv(t,s,this)})}addNode(t){this.updateNodes.add(t),l.addWillUnmount(t,this.updateNodes.delete.bind(this.updateNodes,t))}initNodes(t){this._$nodes=t,r.global.DLEnvStore.removeEnvNode()}};function Nt(i,t){let e=r.document.createTextNode(i);return e.$$deps=t,e}function Ut(i,t,e){if(g(e,i.$$deps))return;let n=t();i.textContent=n,i.$$deps=e}var A=class{propViewFunc;dlUpdateFunc=new Set;constructor(t){this.propViewFunc=t}build(){let t,e=s=>{t=s,this.dlUpdateFunc.add(s)},n=this.propViewFunc(e);return n.length===0?[]:(t&&l.addWillUnmount(n[0],this.dlUpdateFunc.delete.bind(this.dlUpdateFunc,t)),n)}update(...t){this.dlUpdateFunc.forEach(e=>{e(...t)})}};function Et(i,t){I(i,{_$nodes:t.build(),_$dlNodeType:7},0)}var H=class extends l{constructor(t){super(f.Snippet),this.depsArr=t}cached(t,e){if(!t||!t.length)return!1;let n=Math.log2(e),s=this.depsArr[n];return g(t,s)?!0:(this.depsArr[n]=t,!1)}};var D=class extends l{constructor(t){super(t),r.global.DLEnvStore&&r.global.DLEnvStore.currentEnvNodes.length>0&&(this.savedEnvNodes=[...r.global.DLEnvStore.currentEnvNodes])}initNewNodes(t){l.addParentEl(t,this._$parentEl)}geneNewNodesInEnv(t){if(!this.savedEnvNodes){let s=t();return this.initNewNodes(s),s}let e=r.global.DLEnvStore.currentEnvNodes;r.global.DLEnvStore.replaceEnvNodes(this.savedEnvNodes);let n=t();return r.global.DLEnvStore.replaceEnvNodes(e),this.initNewNodes(n),n}initUnmountStore(){r.global.WillUnmountStore.push([]),r.global.DidUnmountStore.push([])}removeNodes(t){l.loopShallowEls(t,e=>{this._$parentEl.removeChild(e)})}};var p=class extends D{array;nodeFunc;depNum;nodesMap=new Map;updateArr=[];get _$nodes(){let t=[];for(let e=0;e<this.array.length;e++)t.push(...this.nodesMap.get(this.keys?.[e]??e));return t}constructor(t,e,n,s){super(f.For),this.array=[...t],this.keys=n,this.depNum=e,this.addNodeFunc(s)}addNodeFunc(t){this.nodeFunc=t,this.array.forEach((e,n)=>{this.initUnmountStore();let s=this.keys?.[n]??n,o=t(e,this.updateArr,n);this.nodesMap.set(s,o),this.setUnmountMap(s)}),p.addWillUnmount(this,this.runAllWillUnmount.bind(this)),p.addDidUnmount(this,this.runAllDidUnmount.bind(this))}updateItem(t,e,n){this.updateArr[t]?.(n??this.depNum,e[t])}updateItems(t){for(let e=0;e<this.array.length;e++)this.updateItem(e,this.array,t)}update(t){~this.depNum&t&&this.updateItems(t)}updateArray(t,e){if(e){this.updateWithKey(t,e);return}this.updateWithOutKey(t)}getNewNodes(t,e,n,s){this.initUnmountStore();let o=this.geneNewNodesInEnv(()=>this.nodeFunc(n[t],s??this.updateArr,t));return this.setUnmountMap(e),this.nodesMap.set(e,o),o}setUnmountMap(t){let e=r.global.WillUnmountStore.pop();e&&e.length>0&&(this.willUnmountMap||(this.willUnmountMap=new Map),this.willUnmountMap.set(t,e));let n=r.global.DidUnmountStore.pop();n&&n.length>0&&(this.didUnmountMap||(this.didUnmountMap=new Map),this.didUnmountMap.set(t,n))}runAllWillUnmount(){!this.willUnmountMap||this.willUnmountMap.size===0||(this.willUnmountMap.forEach(t=>{for(let e=0;e<t.length;e++)t[e]?.()}),this.willUnmountMap.clear())}runAllDidUnmount(){!this.didUnmountMap||this.didUnmountMap.size===0||(this.didUnmountMap.forEach(t=>{for(let e=t.length-1;e>=0;e--)t[e]?.()}),this.didUnmountMap.clear())}runWillUnmount(t){if(!this.willUnmountMap||this.willUnmountMap.size===0)return;let e=this.willUnmountMap.get(t);if(e){for(let n=0;n<e.length;n++)e[n]?.();this.willUnmountMap.delete(t)}}runDidUnmount(t){if(!this.didUnmountMap||this.didUnmountMap.size===0)return;let e=this.didUnmountMap.get(t);if(e){for(let n=e.length-1;n>=0;n--)e[n]?.();this.didUnmountMap.delete(t)}}removeNodes(t,e){this.runWillUnmount(e),super.removeNodes(t),this.runDidUnmount(e),this.nodesMap.delete(e)}updateWithOutKey(t){let e=this.array.length,n=t.length;if(e===n){for(let o=0;o<this.array.length;o++)this.updateItem(o,t);this.array=[...t];return}let s=this._$parentEl;if(e<n){let o=p.getFlowIndexFromNodes(s._$nodes,this),h=s.childNodes.length;for(let d=0;d<n;d++){if(d<e){o+=p.getFlowIndexFromNodes(this.nodesMap.get(d)),this.updateItem(d,t);continue}let $=this.getNewNodes(d,d,t);p.appendNodesWithIndex($,s,o,h)}p.runDidMount(),this.array=[...t];return}for(let o=0;o<n;o++)this.updateItem(o,t);for(let o=n;o<e;o++){let h=this.nodesMap.get(o);this.removeNodes(h,o)}this.updateArr.splice(n,e-n),this.array=[...t]}updateWithKey(t,e){if(e.length!==new Set(e).size)throw new Error("DLight: Duplicate keys in for loop are not allowed");let n=this.keys;if(this.keys=e,p.arrayEqual(n,this.keys)){for(let u=0;u<t.length;u++)this.updateItem(u,t);this.array=[...t];return}let s=this._$parentEl;if(this.keys.length===0){let u=s._$nodes??[];if(u.length===1&&u[0]===this)this.runAllWillUnmount(),s.innerHTML="",this.runAllDidUnmount();else for(let a=0;a<n.length;a++){let m=n[a];this.removeNodes(this.nodesMap.get(m),m)}this.nodesMap.clear(),this.updateArr=[],this.array=[];return}let o=p.getFlowIndexFromNodes(s._$nodes,this);if(n.length===0){let u=s.childNodes[o];for(let a=0;a<this.keys.length;a++){let m=this.getNewNodes(a,this.keys[a],t);p.appendNodesWithSibling(m,s,u)}p.runDidMount(),this.array=[...t];return}let h=[],d=[];for(let u=0;u<n.length;u++){let a=n[u];if(this.keys.includes(a)){h.push(a),d.push(this.updateArr[u]);continue}this.removeNodes(this.nodesMap.get(a),a)}let $=s.childNodes.length,c=o;for(let u=0;u<this.keys.length;u++){let a=this.keys[u],m=h.indexOf(a);if(m!==-1){c+=p.getFlowIndexFromNodes(this.nodesMap.get(a)),d[m]?.(this.depNum,t[u]);continue}d.splice(u,0,null);let E=this.getNewNodes(u,a,t,d);h.splice(u,0,a);let L=p.appendNodesWithIndex(E,s,c,$);c+=L,$+=L}if(p.runDidMount(),p.arrayEqual(this.keys,h)){this.array=[...t],this.updateArr=d;return}c=o;let w=new Map;for(let u=0;u<this.keys.length;u++){let a=this.keys[u],m=h.indexOf(a),E=w.get(a);if(E){let M=p.getFlowIndexFromNodes(E),S=p.toEls(E).pop(),x=s.childNodes[c+M];S!==x&&S.nextSibling!==x&&p.insertNodesBefore(E,s,x),c+=M,delete w[u]}else if(m===u){c+=p.getFlowIndexFromNodes(this.nodesMap.get(a));continue}else{let M=h[u];w.set(M,this.nodesMap.get(M));let S=this.nodesMap.get(a),x=p.toEls(S).pop(),P=s.childNodes[c];x!==P&&x.nextSibling!==P&&(c+=p.insertNodesBefore(S,s,P))}let L=h[u];h[u]=h[m],h[m]=L;let V=d[u];d[u]=d[m],d[m]=V}this.array=[...t],this.updateArr=d}static arrayEqual(t,e){return t.length!==e.length?!1:t.every((n,s)=>n===e[s])}};var N=class extends D{willUnmountFuncs=[];didUnmountFuncs=[];setUnmountFuncs(){this.willUnmountFuncs=r.global.WillUnmountStore.pop(),this.didUnmountFuncs=r.global.DidUnmountStore.pop()}runWillUnmount(){for(let t=0;t<this.willUnmountFuncs.length;t++)this.willUnmountFuncs[t]()}runDidUnmount(){for(let t=this.didUnmountFuncs.length-1;t>=0;t--)this.didUnmountFuncs[t]()}removeNodes(t){this.runWillUnmount(),super.removeNodes(t),this.runDidUnmount()}geneNewNodesInEnv(t){this.initUnmountStore();let e=super.geneNewNodesInEnv(t);return this.setUnmountFuncs(),e}};var U=class extends N{constructor(t,e){super(f.Exp),this.initUnmountStore(),this._$nodes=U.formatNodes(t),this.setUnmountFuncs(),this.deps=this.parseDeps(e),U.addWillUnmount(this,this.runWillUnmount.bind(this)),U.addDidUnmount(this,this.runDidUnmount.bind(this))}parseDeps(t){return t.map(e=>e?.prototype?._$init?e.toString():e)}cache(t){return!t||!t.length?!1:(t=this.parseDeps(t),g(t,this.deps)?!0:(this.deps=t,!1))}update(t,e){if(this.cache(e))return;this.removeNodes(this._$nodes);let n=this.geneNewNodesInEnv(()=>U.formatNodes(t()));if(n.length===0){this._$nodes=[];return}let s=this._$parentEl,o=U.getFlowIndexFromNodes(s._$nodes,this),h=s.childNodes[o];U.appendNodesWithSibling(n,s,h),U.runDidMount(),this._$nodes=n}static formatNodes(t){return Array.isArray(t)||(t=[t]),t.flat(1).filter(e=>e!=null&&typeof e!="boolean").map(e=>typeof e=="string"||typeof e=="number"||typeof e=="bigint"?r.document.createTextNode(`${e}`):"propViewFunc"in e?e.build():e).flat(1)}};var _=class extends N{constructor(t,e){super(f.Cond),this.depNum=t,this.cond=-1,this.condFunc=e,this.initUnmountStore(),this._$nodes=this.condFunc(this),this.setUnmountFuncs(),_.addWillUnmount(this,this.runWillUnmount.bind(this)),_.addDidUnmount(this,this.runDidUnmount.bind(this))}updateCond(t){let e=[this.willUnmountFuncs,this.didUnmountFuncs],n=this.geneNewNodesInEnv(()=>this.condFunc(this));if(this.didntChange){[this.willUnmountFuncs,this.didUnmountFuncs]=e,this.didntChange=!1,this.updateFunc?.(this.depNum,t);return}let s=[this.willUnmountFuncs,this.didUnmountFuncs];if([this.willUnmountFuncs,this.didUnmountFuncs]=e,this._$nodes&&this._$nodes.length>0&&this.removeNodes(this._$nodes),[this.willUnmountFuncs,this.didUnmountFuncs]=s,n.length===0){this._$nodes=[];return}let o=this._$parentEl,h=_.getFlowIndexFromNodes(o._$nodes,this),d=o.childNodes[h];_.appendNodesWithSibling(n,o,d),_.runDidMount(),this._$nodes=n}update(t){~this.depNum&t&&this.updateFunc?.(t)}};var B=class extends N{constructor(t,e){super(f.Try),this.tryFunc=t;let n=this.getCatchable(e);this.envNode=new F({_$catchable:n});let s=t(this.setUpdateFunc.bind(this),n)??[];this.envNode.initNodes(s),this._$nodes=s}update(t){this.updateFunc?.(t)}setUpdateFunc(t){this.updateFunc=t}getCatchable(t){return e=>(...n)=>{try{return e(...n)}catch(s){let o=this.geneNewNodesInEnv(()=>t(this.setUpdateFunc.bind(this),s));this._$nodes&&this.removeNodes(this._$nodes);let h=this._$parentEl,d=N.getFlowIndexFromNodes(h._$nodes,this),$=h.childNodes[d];N.appendNodesWithSibling(o,h,$),N.runDidMount(),this._$nodes=o}}}};function R(){r.global.WillUnmountStore=[],r.global.DidUnmountStore=[]}function Zt(i,t){let e=i;if(typeof i=="string"){let s=r.document.getElementById(i);if(s)e=s;else throw new Error(`DLight: Element with id ${i} not found`)}R(),e.innerHTML="";let n=new t;n._$init(),I(e,n,0),l.runDidMount()}function kt(i,t){return i()}function X(i){return i}var te=X,ee=null;function ne(){console.error("DLight: use() is not supported be called directly. You can only assign `use(model)` to a dlight class property. Any other expressions are not allowed.")}export{te as $,v as CompNode,_ as CondNode,F as EnvNode,W as EnvStoreClass,U as ExpNode,p as ForNode,at as Model,A as PropView,H as SnippetNode,B as TryNode,lt as View,ot as createElement,Nt as createTextNode,it as delegateEvent,X as escape,j as forwardHTMLProp,Et as insertChildren,I as insertNode,kt as manual,Zt as render,ee as required,K as setDataset,q as setDocument,J as setEvent,z as setGlobal,O as setHTMLAttr,Y as setHTMLAttrs,T as setHTMLProp,G as setHTMLProps,C as setStyle,pt as update,Ut as updateText,ne as use}; | ||
import{Store as b}from"@dlightjs/store";"global"in b||(typeof window<"u"?b.global=window:typeof global<"u"?b.global=global:b.global={});"document"in b||typeof document<"u"&&(b.document=document);var r={...b,delegatedEvents:new Set};function z(i){r.global=i}function q(i){r.document=i}function g(i,t){return!t||i.length!==t.length?!1:i.every((e,n)=>!(e instanceof Object)&&t[n]===e)}var f={Comp:0,For:1,Cond:2,Env:3,Exp:4,Snippet:5,Try:6},l=class{_$dlNodeType;constructor(t){this._$dlNodeType=t}get _$el(){return l.toEls(this._$nodes)}static toEls(t){let e=[];return this.loopShallowEls(t,n=>{e.push(n)}),e}static loopShallowEls(t,e){let n=[...t].reverse();for(;n.length>0;){let s=n.pop();"_$dlNodeType"in s?s._$nodes&&n.push(...[...s._$nodes].reverse()):e(s)}}static addParentEl(t,e){t.forEach(n=>{"_$dlNodeType"in n&&(n._$parentEl=e,n._$nodes&&l.addParentEl(n._$nodes,e))})}static getFlowIndexFromNodes(t,e){let n=0,s=[...t].reverse();for(;s.length>0;){let o=s.pop();if(o===e)break;"_$dlNodeType"in o?o._$nodes&&s.push(...[...o._$nodes].reverse()):n++}return n}static appendNodesWithSibling(t,e,n){return n?this.insertNodesBefore(t,e,n):this.appendNodes(t,e)}static appendNodesWithIndex(t,e,n,s){return s=s??e.childNodes.length,s!==n?this.insertNodesBefore(t,e,e.childNodes[n]):this.appendNodes(t,e)}static insertNodesBefore(t,e,n){let s=0;return this.loopShallowEls(t,o=>{e.insertBefore(o,n),s++}),s}static appendNodes(t,e){let n=0;return this.loopShallowEls(t,s=>{e.appendChild(s),n++}),n}static addWillUnmount(t,e){let n=r.global.WillUnmountStore,s=n[n.length-1];s&&s.push(e.bind(null,t))}static addDidUnmount(t,e){let n=r.global.DidUnmountStore,s=n[n.length-1];s&&s.push(e.bind(null,t))}static addDidMount(t,e){r.global.DidMountStore||(r.global.DidMountStore=[]),r.global.DidMountStore.push(e.bind(null,t))}static runDidMount(){let t=r.global.DidMountStore;if(!(!t||t.length===0)){for(let e=t.length-1;e>=0;e--)t[e]();r.global.DidMountStore=[]}}};function y(i,t,e){if(e.length===0)return!1;let n=`$${t}`;return g(e,i[n])?!0:(i[n]=e,!1)}function C(i,t){Object.entries(t).forEach(([e,n])=>{e.startsWith("--")?i.style.setProperty(e,n):i.style[e]=n})}function K(i,t){Object.assign(i.dataset,t)}function T(i,t,e,n){y(i,t,n)||(i[t]=e())}function G(i,t){Object.entries(t).forEach(([e,n])=>{if(e==="style")return C(i,n);if(e==="dataset")return K(i,n);T(i,e,()=>n,[])})}function O(i,t,e,n){y(i,t,n)||i.setAttribute(t,e())}function Y(i,t){Object.entries(t).forEach(([e,n])=>{O(i,e,()=>n,[])})}function J(i,t,e){let n=i[`$on${t}`];n&&i.removeEventListener(t,n),i.addEventListener(t,e),i[`$on${t}`]=e}function Q(i){let t=`$$${i.type}`;for(let e of i.composedPath())if(e[t]&&e[t](i),i.cancelBubble)return}function it(i,t,e){i[`$$${t}`]!==e&&(i[`$$${t}`]=e,r.delegatedEvents.has(t)||(r.delegatedEvents.add(t),r.document.addEventListener(t,Q)))}function ot(i){return r.document.createElement(i)}function F(i,t,e){i._$nodes||(i._$nodes=Array.from(i.childNodes)),i._$nodes.splice(e,0,t);let n=l.getFlowIndexFromNodes(i._$nodes,t);l.appendNodesWithIndex([t],i,n),l.addParentEl([t],i)}function j(i,t,e,n){if(t==="style")return C(i,e());if(t==="dataset")return K(i,e());if(t!=="element"){if(t==="prop")return G(i,e());if(t==="attr")return Y(i,e());if(t==="innerHTML")return T(i,"innerHTML",e,n);if(t==="textContent")return T(i,"textContent",e,n);if(t!=="forwardProp"){if(t.startsWith("on"))return J(i,t.slice(2).toLowerCase(),e());O(i,t,e,n)}}}var v=class extends l{constructor(){super(f.Comp)}_$init(t,e,n,s){this._$notInitd=!0,s&&s._$addForwardProps(this),e&&this._$setContent(()=>e[0],e[1]),t&&t.forEach(([o,h,d])=>{if(o==="props")return this._$setProps(()=>h,d);this._$setProp(o,()=>h,d)}),n&&(this._$children=n),r.global.DLEnvStore&&Object.entries(r.global.DLEnvStore.envs).forEach(([o,[h,d]])=>{if(o==="_$catchable"){this._$catchable=h;return}`$e$${o}`in this&&(d.addNode(this),this._$initEnv(o,h,d))}),this._$callUpdatesBeforeInit(),this.didMount&&l.addDidMount(this,this.didMount.bind(this)),this.willUnmount&&l.addWillUnmount(this,this.willUnmount.bind(this)),l.addDidUnmount(this,this._$setUnmounted.bind(this)),this.didUnmount&&l.addDidUnmount(this,this.didUnmount.bind(this)),this.willMount?.(),this._$nodes=this.Body?.()??[],this._$catchable&&(this._$update&&(this._$update=this._$catchable(this._$update.bind(this))),this._$updateDerived=this._$catchable(this._$updateDerived.bind(this)),delete this._$catchable)}_$setUnmounted(){this._$unmounted=!0}_$callUpdatesBeforeInit(){let t=Object.getOwnPropertyNames(Object.getPrototypeOf(this)),e=Object.getOwnPropertyNames(this);[...t,...e].forEach(s=>{if(s.startsWith("$w$"))return this[s.slice(3)]();if(s.startsWith("$md$")){let o=s.slice(4);this[o]=this[o]();return}if(s.startsWith("$f$")){let o=s.slice(3);this[o]=this[s],this._$updateDerived(o)}}),delete this._$notInitd}_$setPropToForward(t,e,n){this._$forwardPropsSet.forEach(s=>{let o=t==="_$content";if(s._$dlNodeType===f.Comp){o?s._$setContent(()=>e,n):s._$setProp(t,()=>e,n);return}s instanceof HTMLElement&&(o&&(t="textContent"),j(s,t,()=>e,n))})}_$setForwardProp(t,e,n){let s="_$notInitd"in this;if(!s&&this._$cache(t,n))return;let o=e();t==="_$content"&&this._$contentKey&&(this[this._$contentKey]=o,this._$updateDerived(this._$contentKey)),this[t]=o,this._$updateDerived(t),s?this._$forwardPropsId.push(t):this._$setPropToForward(t,o,n)}_$addForwardProps(t){this._$forwardPropsSet.add(t),this._$forwardPropsId.forEach(e=>{this._$setPropToForward(e,this[e],[])}),l.addWillUnmount(t,this._$forwardPropsSet.delete.bind(this._$forwardPropsSet,t))}_$cache(t,e){if(!e||!e.length)return!1;let n=`$cc$${t}`;return g(e,this[n])?!0:(this[n]=e,!1)}_$setContent(t,e){if("_$forwardProps"in this)return this._$setForwardProp("_$content",t,e);let n=this._$contentKey;n&&(this._$cache(n,e)||(this[n]=t(),this._$updateDerived(n)))}_$setProp(t,e,n){if("_$forwardProps"in this)return this._$setForwardProp(t,e,n);if(!(`$p$${t}`in this)){console.warn(`[${t}] is not a prop in ${this.constructor.name}`);return}this._$cache(t,n)||(this[t]=e(),this._$updateDerived(t))}_$setProps(t,e){if(this._$cache("props",e))return;let n=t();n&&Object.entries(n).forEach(([s,o])=>{this._$setProp(s,()=>o,[])})}_$initEnv(t,e,n){this[t]=e,this[`$en$${t}`]=n}_$updateEnv(t,e,n){`$e$${t}`in this&&n===this[`$en$${t}`]&&(this[t]=e,this._$updateDerived(t))}_$ud(t,e){return this._$updateDerived(e),t}_$updateDerived(t){"_$notInitd"in this||(this[`$s$${t}`]?.forEach(e=>{`$w$${e}`in this?this[e](t):`$md$${e}`in this?this[e]._$update():this[e]=this[`$f$${e}`]}),this._$updateView(t))}_$updateView(t){if(this._$modelCallee)return this._$updateModelCallee();if(!("_$update"in this))return;let e=this[`$$${t}`];e&&("_$depNumsToUpdate"in this?this._$depNumsToUpdate.push(e):(this._$depNumsToUpdate=[e],Promise.resolve().then(()=>{if(this._$unmounted)return;let n=this._$depNumsToUpdate;if(n.length>0){let s=n.reduce((o,h)=>o|h,0);this._$update(s)}delete this._$depNumsToUpdate})))}_$updateModelCallee(){"_$depNumsToUpdate"in this||(this._$depNumsToUpdate=!0,Promise.resolve().then(()=>{this._$unmounted||(this._$modelCallee._$updateDerived(this._$modelKey),delete this._$depNumsToUpdate)}))}static _$updateModel(t,e,n){let s=e()??{},o=s.s??[];s.m?.forEach(([d,$])=>{Object.entries(d).forEach(([c,w])=>{o.push([c,w,$])})}),o.forEach(([d,$,c])=>{t._$setProp(d,()=>$,c)});let h=n();h&&t._$setContent(()=>h[0],h[1])}static _$releaseModel(){delete this._$modelCallee}_$injectModel(t,e,n,s){let o=e()??{},h=o.s??[];o.m?.forEach(([$,c])=>{Object.entries($).forEach(([w,u])=>{h.push([w,u,c])})});let d=new t;return d._$init(h,n(),null,null),d._$modelCallee=this,d._$modelKey=s,d._$update=v._$updateModel.bind(null,d,e,n),d}},lt=v,at=v;function pt(i,t){i._$updateDerived(t)}var W=class{constructor(){this.envs={},this.currentEnvNodes=[]}addEnvNode(t){this.currentEnvNodes.push(t),this.mergeEnvs()}replaceEnvNodes(t){this.currentEnvNodes=t,this.mergeEnvs()}removeEnvNode(){this.currentEnvNodes.pop(),this.mergeEnvs()}mergeEnvs(){this.envs={},this.currentEnvNodes.forEach(t=>{Object.entries(t.envs).forEach(([e,n])=>{this.envs[e]=[n,t]})})}},I=class extends l{constructor(t,e){super(f.Env),"DLEnvStore"in r.global||(r.global.DLEnvStore=new W),this.envs=t,this.depsArr=e,this.updateNodes=new Set,r.global.DLEnvStore.addEnvNode(this)}cached(t,e){return!t||!t.length?!1:g(t,this.depsArr[e])?!0:(this.depsArr[e]=t,!1)}updateEnv(t,e,n){if(this.cached(n,t))return;let s=e();this.envs[t]=s,r.global.DLEnvStore.currentEnvNodes.includes(this)&&r.global.DLEnvStore.mergeEnvs(),this.updateNodes.forEach(o=>{o._$updateEnv(t,s,this)})}addNode(t){this.updateNodes.add(t),l.addWillUnmount(t,this.updateNodes.delete.bind(this.updateNodes,t))}initNodes(t){this._$nodes=t,r.global.DLEnvStore.removeEnvNode()}};function Nt(i,t){let e=r.document.createTextNode(i);return e.$$deps=t,e}function Ut(i,t,e){if(g(e,i.$$deps))return;let n=t();i.textContent=n,i.$$deps=e}var A=class{propViewFunc;dlUpdateFunc=new Set;constructor(t){this.propViewFunc=t}build(){let t,e=s=>{t=s,this.dlUpdateFunc.add(s)},n=this.propViewFunc(e);return n.length===0?[]:(t&&l.addWillUnmount(n[0],this.dlUpdateFunc.delete.bind(this.dlUpdateFunc,t)),n)}update(...t){this.dlUpdateFunc.forEach(e=>{e(...t)})}};function Et(i,t){F(i,{_$nodes:t.build(),_$dlNodeType:7},0)}var H=class extends l{constructor(t){super(f.Snippet),this.depsArr=t}cached(t,e){if(!t||!t.length)return!1;let n=Math.log2(e),s=this.depsArr[n];return g(t,s)?!0:(this.depsArr[n]=t,!1)}};var D=class extends l{constructor(t){super(t),r.global.DLEnvStore&&r.global.DLEnvStore.currentEnvNodes.length>0&&(this.savedEnvNodes=[...r.global.DLEnvStore.currentEnvNodes])}initNewNodes(t){l.addParentEl(t,this._$parentEl)}geneNewNodesInEnv(t){if(!this.savedEnvNodes){let s=t();return this.initNewNodes(s),s}let e=r.global.DLEnvStore.currentEnvNodes;r.global.DLEnvStore.replaceEnvNodes(this.savedEnvNodes);let n=t();return r.global.DLEnvStore.replaceEnvNodes(e),this.initNewNodes(n),n}initUnmountStore(){r.global.WillUnmountStore.push([]),r.global.DidUnmountStore.push([])}removeNodes(t){l.loopShallowEls(t,e=>{this._$parentEl.removeChild(e)})}};var p=class extends D{array;nodeFunc;depNum;nodesMap=new Map;updateArr=[];get _$nodes(){let t=[];for(let e=0;e<this.array.length;e++)t.push(...this.nodesMap.get(this.keys?.[e]??e));return t}constructor(t,e,n,s){super(f.For),this.array=[...t],this.keys=n,this.depNum=e,this.addNodeFunc(s)}addNodeFunc(t){this.nodeFunc=t,this.array.forEach((e,n)=>{this.initUnmountStore();let s=this.keys?.[n]??n,o=t(e,this.updateArr,n);this.nodesMap.set(s,o),this.setUnmountMap(s)}),p.addWillUnmount(this,this.runAllWillUnmount.bind(this)),p.addDidUnmount(this,this.runAllDidUnmount.bind(this))}updateItem(t,e,n){this.updateArr[t]?.(n??this.depNum,e[t])}updateItems(t){for(let e=0;e<this.array.length;e++)this.updateItem(e,this.array,t)}update(t){~this.depNum&t&&this.updateItems(t)}updateArray(t,e){if(e){this.updateWithKey(t,e);return}this.updateWithOutKey(t)}getNewNodes(t,e,n,s){this.initUnmountStore();let o=this.geneNewNodesInEnv(()=>this.nodeFunc(n[t],s??this.updateArr,t));return this.setUnmountMap(e),this.nodesMap.set(e,o),o}setUnmountMap(t){let e=r.global.WillUnmountStore.pop();e&&e.length>0&&(this.willUnmountMap||(this.willUnmountMap=new Map),this.willUnmountMap.set(t,e));let n=r.global.DidUnmountStore.pop();n&&n.length>0&&(this.didUnmountMap||(this.didUnmountMap=new Map),this.didUnmountMap.set(t,n))}runAllWillUnmount(){!this.willUnmountMap||this.willUnmountMap.size===0||(this.willUnmountMap.forEach(t=>{for(let e=0;e<t.length;e++)t[e]?.()}),this.willUnmountMap.clear())}runAllDidUnmount(){!this.didUnmountMap||this.didUnmountMap.size===0||(this.didUnmountMap.forEach(t=>{for(let e=t.length-1;e>=0;e--)t[e]?.()}),this.didUnmountMap.clear())}runWillUnmount(t){if(!this.willUnmountMap||this.willUnmountMap.size===0)return;let e=this.willUnmountMap.get(t);if(e){for(let n=0;n<e.length;n++)e[n]?.();this.willUnmountMap.delete(t)}}runDidUnmount(t){if(!this.didUnmountMap||this.didUnmountMap.size===0)return;let e=this.didUnmountMap.get(t);if(e){for(let n=e.length-1;n>=0;n--)e[n]?.();this.didUnmountMap.delete(t)}}removeNodes(t,e){this.runWillUnmount(e),super.removeNodes(t),this.runDidUnmount(e),this.nodesMap.delete(e)}updateWithOutKey(t){let e=this.array.length,n=t.length;if(e===n){for(let o=0;o<this.array.length;o++)this.updateItem(o,t);this.array=[...t];return}let s=this._$parentEl;if(e<n){let o=p.getFlowIndexFromNodes(s._$nodes,this),h=s.childNodes.length;for(let d=0;d<n;d++){if(d<e){o+=p.getFlowIndexFromNodes(this.nodesMap.get(d)),this.updateItem(d,t);continue}let $=this.getNewNodes(d,d,t);p.appendNodesWithIndex($,s,o,h)}p.runDidMount(),this.array=[...t];return}for(let o=0;o<n;o++)this.updateItem(o,t);for(let o=n;o<e;o++){let h=this.nodesMap.get(o);this.removeNodes(h,o)}this.updateArr.splice(n,e-n),this.array=[...t]}updateWithKey(t,e){if(e.length!==new Set(e).size)throw new Error("DLight: Duplicate keys in for loop are not allowed");let n=this.keys;if(this.keys=e,p.arrayEqual(n,this.keys)){for(let u=0;u<t.length;u++)this.updateItem(u,t);this.array=[...t];return}let s=this._$parentEl;if(this.keys.length===0){let u=s._$nodes??[];if(u.length===1&&u[0]===this)this.runAllWillUnmount(),s.innerHTML="",this.runAllDidUnmount();else for(let a=0;a<n.length;a++){let m=n[a];this.removeNodes(this.nodesMap.get(m),m)}this.nodesMap.clear(),this.updateArr=[],this.array=[];return}let o=p.getFlowIndexFromNodes(s._$nodes,this);if(n.length===0){let u=s.childNodes[o];for(let a=0;a<this.keys.length;a++){let m=this.getNewNodes(a,this.keys[a],t);p.appendNodesWithSibling(m,s,u)}p.runDidMount(),this.array=[...t];return}let h=[],d=[];for(let u=0;u<n.length;u++){let a=n[u];if(this.keys.includes(a)){h.push(a),d.push(this.updateArr[u]);continue}this.removeNodes(this.nodesMap.get(a),a)}let $=s.childNodes.length,c=o;for(let u=0;u<this.keys.length;u++){let a=this.keys[u],m=h.indexOf(a);if(m!==-1){c+=p.getFlowIndexFromNodes(this.nodesMap.get(a)),d[m]?.(this.depNum,t[u]);continue}d.splice(u,0,null);let E=this.getNewNodes(u,a,t,d);h.splice(u,0,a);let L=p.appendNodesWithIndex(E,s,c,$);c+=L,$+=L}if(p.runDidMount(),p.arrayEqual(this.keys,h)){this.array=[...t],this.updateArr=d;return}c=o;let w=new Map;for(let u=0;u<this.keys.length;u++){let a=this.keys[u],m=h.indexOf(a),E=w.get(a);if(E){let M=p.getFlowIndexFromNodes(E),S=p.toEls(E).pop(),x=s.childNodes[c+M];S!==x&&S.nextSibling!==x&&p.insertNodesBefore(E,s,x),c+=M,delete w[u]}else if(m===u){c+=p.getFlowIndexFromNodes(this.nodesMap.get(a));continue}else{let M=h[u];w.set(M,this.nodesMap.get(M));let S=this.nodesMap.get(a),x=p.toEls(S).pop(),P=s.childNodes[c];x!==P&&x.nextSibling!==P&&(c+=p.insertNodesBefore(S,s,P))}let L=h[u];h[u]=h[m],h[m]=L;let V=d[u];d[u]=d[m],d[m]=V}this.array=[...t],this.updateArr=d}static arrayEqual(t,e){return t.length!==e.length?!1:t.every((n,s)=>n===e[s])}};var N=class extends D{willUnmountFuncs=[];didUnmountFuncs=[];setUnmountFuncs(){this.willUnmountFuncs=r.global.WillUnmountStore.pop(),this.didUnmountFuncs=r.global.DidUnmountStore.pop()}runWillUnmount(){for(let t=0;t<this.willUnmountFuncs.length;t++)this.willUnmountFuncs[t]()}runDidUnmount(){for(let t=this.didUnmountFuncs.length-1;t>=0;t--)this.didUnmountFuncs[t]()}removeNodes(t){this.runWillUnmount(),super.removeNodes(t),this.runDidUnmount()}geneNewNodesInEnv(t){this.initUnmountStore();let e=super.geneNewNodesInEnv(t);return this.setUnmountFuncs(),e}};var U=class extends N{constructor(t,e){super(f.Exp),this.initUnmountStore(),this._$nodes=U.formatNodes(t),this.setUnmountFuncs(),this.deps=this.parseDeps(e),U.addWillUnmount(this,this.runWillUnmount.bind(this)),U.addDidUnmount(this,this.runDidUnmount.bind(this))}parseDeps(t){return t.map(e=>e?.prototype?._$init?e.toString():e?.propViewFunc?e.propViewFunc.toString():e)}cache(t){return!t||!t.length?!1:(t=this.parseDeps(t),g(t,this.deps)?!0:(this.deps=t,!1))}update(t,e){if(this.cache(e))return;this.removeNodes(this._$nodes);let n=this.geneNewNodesInEnv(()=>U.formatNodes(t()));if(n.length===0){this._$nodes=[];return}let s=this._$parentEl,o=U.getFlowIndexFromNodes(s._$nodes,this),h=s.childNodes[o];U.appendNodesWithSibling(n,s,h),U.runDidMount(),this._$nodes=n}static formatNodes(t){return Array.isArray(t)||(t=[t]),t.flat(1).filter(e=>e!=null&&typeof e!="boolean").map(e=>typeof e=="string"||typeof e=="number"||typeof e=="bigint"?r.document.createTextNode(`${e}`):"propViewFunc"in e?e.build():e).flat(1)}};var _=class extends N{constructor(t,e){super(f.Cond),this.depNum=t,this.cond=-1,this.condFunc=e,this.initUnmountStore(),this._$nodes=this.condFunc(this),this.setUnmountFuncs(),_.addWillUnmount(this,this.runWillUnmount.bind(this)),_.addDidUnmount(this,this.runDidUnmount.bind(this))}updateCond(t){let e=[this.willUnmountFuncs,this.didUnmountFuncs],n=this.geneNewNodesInEnv(()=>this.condFunc(this));if(this.didntChange){[this.willUnmountFuncs,this.didUnmountFuncs]=e,this.didntChange=!1,this.updateFunc?.(this.depNum,t);return}let s=[this.willUnmountFuncs,this.didUnmountFuncs];if([this.willUnmountFuncs,this.didUnmountFuncs]=e,this._$nodes&&this._$nodes.length>0&&this.removeNodes(this._$nodes),[this.willUnmountFuncs,this.didUnmountFuncs]=s,n.length===0){this._$nodes=[];return}let o=this._$parentEl,h=_.getFlowIndexFromNodes(o._$nodes,this),d=o.childNodes[h];_.appendNodesWithSibling(n,o,d),_.runDidMount(),this._$nodes=n}update(t){~this.depNum&t&&this.updateFunc?.(t)}};var B=class extends N{constructor(t,e){super(f.Try),this.tryFunc=t;let n=this.getCatchable(e);this.envNode=new I({_$catchable:n});let s=t(this.setUpdateFunc.bind(this),n)??[];this.envNode.initNodes(s),this._$nodes=s}update(t){this.updateFunc?.(t)}setUpdateFunc(t){this.updateFunc=t}getCatchable(t){return e=>(...n)=>{try{return e(...n)}catch(s){let o=this.geneNewNodesInEnv(()=>t(this.setUpdateFunc.bind(this),s));this._$nodes&&this.removeNodes(this._$nodes);let h=this._$parentEl,d=N.getFlowIndexFromNodes(h._$nodes,this),$=h.childNodes[d];N.appendNodesWithSibling(o,h,$),N.runDidMount(),this._$nodes=o}}}};function R(){r.global.WillUnmountStore=[],r.global.DidUnmountStore=[]}function Zt(i,t){let e=i;if(typeof i=="string"){let s=r.document.getElementById(i);if(s)e=s;else throw new Error(`DLight: Element with id ${i} not found`)}R(),e.innerHTML="";let n=new t;n._$init(),F(e,n,0),l.runDidMount()}function kt(i,t){return i()}function X(i){return i}var te=X,ee=null;function ne(){console.error("DLight: use() is not supported be called directly. You can only assign `use(model)` to a dlight class property. Any other expressions are not allowed.")}export{te as $,v as CompNode,_ as CondNode,I as EnvNode,W as EnvStoreClass,U as ExpNode,p as ForNode,at as Model,A as PropView,H as SnippetNode,B as TryNode,lt as View,ot as createElement,Nt as createTextNode,it as delegateEvent,X as escape,j as forwardHTMLProp,Et as insertChildren,F as insertNode,kt as manual,Zt as render,ee as required,K as setDataset,q as setDocument,J as setEvent,z as setGlobal,O as setHTMLAttr,Y as setHTMLAttrs,T as setHTMLProp,G as setHTMLProps,C as setStyle,pt as update,Ut as updateText,ne as use}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@dlightjs/dlight", | ||
"version": "1.0.0-next.7", | ||
"version": "1.0.0-next.8", | ||
"description": "DX-first UI rendering library", | ||
@@ -5,0 +5,0 @@ "author": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
243616