olova 1.0.4 → 1.0.6
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/README.md +0 -2
- package/dist/olova.js +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
</div>
|
|
12
12
|
|
|
13
13
|
<script type="module">
|
|
14
|
-
let rander = document.querySelector("template").innerHTML;
|
|
15
14
|
import { createApp } from "//unpkg.com/olova";
|
|
16
15
|
|
|
17
16
|
const app = createApp({
|
|
@@ -23,7 +22,6 @@
|
|
|
23
22
|
this.count++;
|
|
24
23
|
},
|
|
25
24
|
},
|
|
26
|
-
template: rander,
|
|
27
25
|
});
|
|
28
26
|
app.mount("#app");
|
|
29
27
|
</script>
|
package/dist/olova.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
let createApp=({data:e,computed:t,methods:r,watch:l,mounted:a,beforeMount:n,beforeUpdate:o,template:i,plugins:c=[],components:s={}})=>{let u,f={},d={},h={},p={},m={},E=new Map,y=new Map,b=(e,t)=>{y.set(e,t)},g=(e,t)=>{m[e]=t},v=e=>{Array.from(e.attributes).forEach(t=>{let r=t.name.startsWith("$")?t.name.slice(1):null;if(r&&m[r]){let l=t.value;m[r](e,l,M),e.removeAttribute(t.name)}})},w=e=>new Proxy(e,{get:(e,t)=>"object"==typeof e[t]&&null!==e[t]?w(e[t]):e[t],set:(e,t,r)=>(e[t]!==r&&(e[t]=r,k(t)),!0)});class A extends Error{constructor(e){super(e),this.name="TemplateError"}}class N extends Error{constructor(e){super(e),this.name="StateError"}}let C=(e,t,r=Error)=>function(...l){try{return e.apply(this,l)}catch(a){throw new r(`${t}: ${a.message}`)}};n&&C(n,"Error in beforeMount hook",N).call(M);let x=new Set,T=e=>{f[e]&&(x.add(e),requestAnimationFrame(()=>{x.forEach(e=>{f[e].forEach(C(t=>{t.node?t.node.textContent=t.originalText.replace(/\{(.*?)\}/g,(e,t)=>Function("state",`with(state) { return ${t} }`)(M)):t.element&&t.attrName?(t.element.setAttribute(t.attrName,M[e]),t.element.removeAttribute(`:${t.attrName}`)):t.update&&t.update()},"Error updating bindings"))}),x.clear()}))},S=e=>{if("function"==typeof e){let t=C(e,"Error in onUpdated callback");h.__updated__||(h.__updated__=[]),h.__updated__.push({callback:t})}},k=e=>{o&&C(o,"Error in beforeUpdate hook").call(M,e),T(e),L(),q(e),h.__updated__&&h.__updated__.forEach(e=>e.callback.call(M))},L=()=>{Object.keys(d).forEach(e=>delete d[e])},q=e=>{h[e]&&h[e].forEach(t=>{t.debounce?(clearTimeout(t.timeout),t.timeout=setTimeout(()=>t.callback.call(M,M[e]),t.debounce)):t.throttle?(!t.lastCalled||Date.now()-t.lastCalled>t.throttle)&&(t.callback.call(M,M[e]),t.lastCalled=Date.now()):t.callback.call(M,M[e])})};l&&Object.keys(l).forEach(e=>{"function"==typeof l[e]?h[e]=[{callback:l[e]}]:"object"==typeof l[e]?h[e]=[{...l[e]}]:h[e]=Array.isArray(l[e])?l[e].map(e=>({callback:e})):[{callback:l[e]}]});let M=w({...e,$refs:new Proxy(p,{get:(e,t)=>e[t],set(){throw Error("$refs is read-only")}})}),O={},$={};t&&Object.keys(t).forEach(e=>{let r=t[e];O[e]=[],Object.defineProperty(M,e,{get:()=>"function"==typeof r&&"AsyncFunction"===r.constructor.name?($[e]||(d[e]=new Proxy(M,{get:(t,r)=>(O[e].includes(r)||O[e].push(r),t[r])}),$[e]=r.call(M).then(t=>(d[e]=t,delete $[e],T(e),t)).catch(t=>{console.error(`Error in async computed property "${e}":`,t)})),$[e]):(d.hasOwnProperty(e)||(d[e]=new Proxy(M,{get:(t,r)=>(O[e].includes(r)||O[e].push(r),t[r])}),d[e]=r.call(M)),d[e]),enumerable:!0})});let D=e=>{Object.keys(O).forEach(t=>{O[t].includes(e)&&(delete d[t],T(t))})},B=()=>{u.querySelectorAll("[\\$style]").forEach(e=>{if(!(e instanceof HTMLElement))return;let t=e.getAttribute("$style");if(!t)return;let r=()=>{try{let r=Function("state",`with(state) { return ${t} }`)(M);"object"==typeof r&&null!==r?Object.entries(r).forEach(([t,r])=>{e.style[t]=r}):"string"==typeof r&&e.setAttribute("style",r)}catch(l){console.error("Error applying style directive:",l)}};r(),T(t)})},_=()=>{u.querySelectorAll("[\\$if]").forEach(e=>{if(!(e instanceof HTMLElement))return;let t=e.getAttribute("$if");if(!t)return;let r=e.parentNode,l=document.createComment("$if placeholder");r?.insertBefore(l,e);let a=e.nextElementSibling;for(;a&&!a.hasAttribute("$else");)a=a.nextElementSibling;let n=()=>{try{Function("state",`with(state) { return ${t} }`)(M)?(e.style.display="",e.parentNode!==r&&r?.insertBefore(e,l.nextSibling),a&&(a.style.display="none")):(e.style.display="none",a&&(a.style.display=""))}catch(n){console.error("Error evaluating :if directive:",n)}};n(),T(t)})},j=e=>{if(!(e instanceof HTMLElement))return;let t=e.getAttribute("$show");if(!t)return;let r=()=>{try{let r=Function("state",`with(state) { return ${t} }`)(M);e.style.display=r?"":"none"}catch(l){console.error("Error evaluating $show directive:",l)}};r(),f[t]||(f[t]=[]),f[t].push({element:e,update:r})},H=()=>{u.querySelectorAll("[\\$for]").forEach(e=>{if(!(e instanceof HTMLElement))return;let t=e.getAttribute("$for");if(!t)return;let r=t.match(/^\s*(\w+)\s+(?:of|in)\s+(\w+)\s*$/);if(!r){console.error("Invalid :for expression:",t);return}let[,l,a]=r,n=e.parentNode,o=document.createComment("$for placeholder");n?.insertBefore(o,e),e.removeAttribute("$for");let i=e.cloneNode(!0);n?.removeChild(e);let c=()=>{let e=document.createDocumentFragment(),t=M[a];for(Array.isArray(t)&&t.forEach((t,r)=>{let a=i.cloneNode(!0),n={[l]:t,index:r},o=new Proxy(n,{get:(e,t)=>(t in e)?e[t]:M[t]}),c=e=>{if(e.nodeType===Node.TEXT_NODE){let t=e.textContent;t.includes("{")&&t.includes("}")&&(e.textContent=t.replace(/\{(.*?)\}/g,(e,t)=>Function("state",`with(state) { return ${t} }`)(o)))}else e.nodeType===Node.ELEMENT_NODE&&Array.from(e.childNodes).forEach(c)};c(a),a.querySelectorAll("*").forEach(e=>{Array.from(e.attributes).forEach(t=>{if(t.value.includes("{")&&t.value.includes("}")){let r=t.value.replace(/\{(.*?)\}/g,(e,t)=>Function("state",`with(state) { return ${t} }`)(o));e.setAttribute(t.name,r)}})}),e.appendChild(a)});o.nextSibling;)n?.removeChild(o.nextSibling);n?.insertBefore(e,o.nextSibling)};c(),f[a]||(f[a]=[]),f[a].push({updateFor:c})})},U=()=>{u.querySelectorAll("[\\$ref]").forEach(e=>{if(!(e instanceof HTMLElement))return;let t=e.getAttribute("$ref");t&&(p[t]=e,e.removeAttribute("$ref"))})},W=()=>{u.querySelectorAll("[\\$model]").forEach(e=>{if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement))return;let t=e.getAttribute("$model");t&&(e.value=M[t]||"",e.addEventListener("input",e=>{M[t]=e.target.value}),f[t]||(f[t]=[]),f[t].push({element:e,updateModel(){e.value=M[t]||""}}),e.removeAttribute("$model"))})},F=e=>{if(e.nodeType===Node.ELEMENT_NODE){let t=e.tagName.toLowerCase();if(y.has(t)){let r=y.get(t),l=Array.from(e.attributes).reduce((e,t)=>(e[t.name]=t.value,e),{}),a=r(l),n=document.createElement("div");n.innerHTML=a;let o=n.firstElementChild;return e.parentNode.replaceChild(o,e),o}}return e},P=()=>{let e=document.createElement("div");e.innerHTML=i.trim();let t=e.getElementsByTagName("template");if(t.length>0){let r=t[0].content;u.innerHTML="",u.appendChild(r.cloneNode(!0))}else u.innerHTML="",u.appendChild(e);let l=e=>{e.nodeType===Node.ELEMENT_NODE&&Array.from((e=F(e)).childNodes).forEach(l)};Array.from(u.childNodes).forEach(l),u.querySelectorAll("*").forEach(e=>{if(e instanceof HTMLElement){v(e);let t=[...e.childNodes].filter(e=>e.nodeType===Node.TEXT_NODE&&/\{.*?\}/.test(e.textContent||""));t.forEach(e=>{let t=e.textContent||"",r=t.match(/\{(.*?)\}/g);r&&r.forEach(r=>{let l=r.replace(/\{|\}/g,"").trim();f[l]||(f[l]=[]),f[l].push({node:e,originalText:t})})}),Array.from(e.attributes).forEach(t=>{if(t.name.startsWith("$")){let r=t.value.trim(),l=t.name.slice(1);f[r]||(f[r]=[]),f[r].push({element:e,attrName:l})}})}})};Object.entries(s).forEach(([e,t])=>{b(e,t)});let X=()=>{c.forEach(e=>{"function"==typeof e&&e({createPlugin:g,state:M,bindings:f})})},G=()=>{u.querySelectorAll("*").forEach(e=>{Array.from(e.attributes).forEach(t=>{if(t.name.startsWith("@")){let l=t.name.slice(1),a=t.value.trim();e.addEventListener(l,e=>{if(r&&r[a])r[a].call(M,e);else try{Function("state","event",`with(state) { ${a} }`).call(M,M,e),k()}catch(t){console.error(`Error executing inline event expression: ${a}`,t)}})}})})},I=()=>{u.querySelectorAll("[\\$class]").forEach(e=>{if(!(e instanceof HTMLElement))return;let t=e.getAttribute("$class");if(!t)return;let r=()=>{try{let r=Function("state",`with(state) { return ${t} }`)(M);"object"==typeof r&&null!==r?Object.entries(r).forEach(([t,r])=>{r?e.classList.add(t):e.classList.remove(t)}):"string"==typeof r&&(e.className=r)}catch(l){console.error("Error applying class directive:",l)}e.removeAttribute("$class")};r(),f[t]||(f[t]=[]),f[t].push({updateClass:r})})},z=(e,t)=>{E.has(e)||E.set(e,[]),E.get(e).forEach(e=>e(t))},J=(e,t)=>(E.has(e)||E.set(e,[]),E.get(e).push(t),()=>{let r=E.get(e),l=r.indexOf(t);-1!==l&&r.splice(l,1)}),K={beforeCreate:[],created:[],beforeMount:[],mounted:[],beforeUpdate:[],updated:[],beforeUnmount:[],unmounted:[]},Q=(e,t)=>{K[e]&&K[e].push(t)},R=e=>{K[e]&&K[e].forEach(e=>e.call(M))},V=e=>{e.data&&Object.assign(M,e.data()),e.methods&&Object.assign(r,e.methods),e.computed&&Object.assign(t,e.computed),e.watch&&Object.keys(e.watch).forEach(t=>{l[t]||(l[t]=[]),l[t].push(e.watch[t])}),e.mounted&&Q("mounted",e.mounted)},Y=e=>{console.error("Global error:",e)};return window.addEventListener("error",Y),{mount:C(function(e){if(!(u=document.querySelector(e)))throw Error(`Element with selector "${e}" not found.`);R("beforeCreate"),R("created"),n&&n.call(M),R("beforeMount"),X(),P(),G(),B(),_(),H(),U(),W(),I(),D(),u.querySelectorAll("[\\$show]").forEach(e=>{e instanceof HTMLElement&&j(e)}),a&&a.call(M),R("mounted"),Object.keys(M).forEach(e=>T(e))},"Error mounting application"),onUpdated:S,createPlugin:g,emit:z,on:J,addLifecycleHook:Q,applyMixin:V,component:b}};export{createApp};
|
|
1
|
+
let createApp=({data:e,computed:t,methods:r,watch:n,mounted:o,beforeMount:a,beforeUpdate:l,template:i,plugins:c=[],components:s={},mixins:u=[],directives:d={}})=>{let f,m={},p={},h={},y={},E={...d},b=new Map,g=new Map,A=(e,t)=>{g.set(e,t)},v=(e,t)=>{E[e]=t},w=e=>{Array.from(e.attributes).forEach((t=>{let r=t.name.startsWith("i-")?t.name.slice(1):null;r&&E[r]&&(E[r](e,t.value,$),e.removeAttribute(t.name))}))},T=e=>new Proxy(e,{get:(e,t)=>"object"==typeof e[t]&&null!==e[t]?T(e[t]):e[t],set:(e,t,r)=>(e[t]!==r&&(e[t]=r,x(t)),!0)});Error;class L extends Error{constructor(e){super(e),this.name="StateError"}}let M=(e,t,r=Error)=>function(...n){try{return e.apply(this,n)}catch(e){throw new r(`${t}: ${e.message}`)}};a&&M(a,"Error in beforeMount hook",L).call($);let C=new Set,N=e=>{m[e]&&(C.add(e),requestAnimationFrame((()=>{C.forEach((e=>{m[e].forEach(M((t=>{t.node?t.node.textContent=t.originalText.replace(/\{(.*?)\}/g,((e,t)=>Function("state",`with(state) { return ${t} }`)($))):t.element&&t.attrName?(t.element.setAttribute(t.attrName,$[e]),t.element.removeAttribute(`:${t.attrName}`)):t.update&&t.update()}),"Error updating bindings"))})),C.clear()})))},x=e=>{l&&M(l,"Error in beforeUpdate hook").call($,e),N(e),H(),S(e),h.__updated__?.forEach((e=>e.callback.call($)))},H=()=>{Object.keys(p).forEach((e=>delete p[e]))},S=e=>{h[e]&&h[e].forEach((t=>{t.debounce?(clearTimeout(t.timeout),t.timeout=setTimeout((()=>t.callback.call($,$[e])),t.debounce)):t.throttle?(!t.lastCalled||Date.now()-t.lastCalled>t.throttle)&&(t.callback.call($,$[e]),t.lastCalled=Date.now()):t.callback.call($,$[e])}))};n&&Object.entries(n).forEach((([e,t])=>{h[e]=Array.isArray(t)?t.map((e=>({callback:e}))):["function"==typeof t?{callback:t}:{...t}]}));let $=T({...e,$refs:new Proxy(y,{get:(e,t)=>e[t],set(){throw Error("$refs is read-only")}})}),O={},_={};t&&Object.entries(t).forEach((([e,t])=>{O[e]=[],Object.defineProperty($,e,{get:()=>"function"==typeof t&&"AsyncFunction"===t.constructor.name?(_[e]||(p[e]=new Proxy($,{get:(t,r)=>(O[e].includes(r)||O[e].push(r),t[r])}),_[e]=t.call($).then((t=>(p[e]=t,delete _[e],N(e),t))).catch((t=>{console.error(`Error in async computed property "${e}":`,t)}))),_[e]):(p.hasOwnProperty(e)||(p[e]=new Proxy($,{get:(t,r)=>(O[e].includes(r)||O[e].push(r),t[r])}),p[e]=t.call($)),p[e]),enumerable:!0})}));let j=()=>{let e="string"==typeof i?i.trim():i instanceof HTMLElement?i.innerHTML:f.innerHTML.trim();if(!e)throw Error("No template provided and container is empty");let t=document.createElement("template");t.innerHTML=e,f.innerHTML="",f.appendChild(t.content.cloneNode(!0));let r=e=>{e.nodeType===Node.ELEMENT_NODE&&((e=(e=>{if(e.nodeType===Node.ELEMENT_NODE){let t=e.tagName.toLowerCase();if(g.has(t)){let r=g.get(t),n=Array.from(e.attributes).reduce(((e,t)=>({...e,[t.name]:t.value})),{}),o=r(n),a=document.createElement("div");a.innerHTML=o;let l=a.firstElementChild;if(l)return e.parentNode?.replaceChild(l,e),l}}return e})(e))instanceof HTMLElement&&(e.hasAttribute("i-if")&&(e=>{if(!(e instanceof HTMLElement))return;let t=e.getAttribute("i-if");if(!t)return;let r=e.nextElementSibling?.hasAttribute("i-else")?e.nextElementSibling:null,n=e.parentNode,o=document.createComment("i-if placeholder");n?.insertBefore(o,e);let a=()=>{try{Function("state",`with(state) { return ${t} }`)($)?(e.isConnected||n?.insertBefore(e,o.nextSibling),r?.isConnected&&n?.removeChild(r)):(e.isConnected&&n?.removeChild(e),r&&!r.isConnected&&n?.insertBefore(r,o.nextSibling))}catch(e){console.error("Error evaluating i-if directive:",e)}};a(),(m[t]??=[]).push({element:e,update:a}),e.removeAttribute("i-if"),r?.removeAttribute("i-else")})(e),e.hasAttribute("i-show")&&U(e),w(e)),Array.from(e.childNodes).forEach(r))};Array.from(f.childNodes).forEach(r),f.querySelectorAll("*").forEach((e=>{if(e instanceof HTMLElement){w(e),[...e.childNodes].filter((e=>e.nodeType===Node.TEXT_NODE&&/\{.*?\}/.test(e.textContent||""))).forEach((e=>{let t=e.textContent||"",r=t.match(/\{(.*?)\}/g);r&&r.forEach((r=>{let n=r.replace(/\{|\}/g,"").trim();(m[n]??=[]).push({node:e,originalText:t})}))})),Array.from(e.attributes).forEach((t=>{if(t.name.startsWith("$")){let r=t.value.trim(),n=t.name.slice(1);(m[r]??=[]).push({element:e,attrName:n})}}))}}))};Object.entries(s).forEach((([e,t])=>{A(e,t)}));let F={beforeCreate:[],created:[],beforeMount:[],mounted:[],beforeUpdate:[],updated:[],beforeUnmount:[],unmounted:[]},q=(e,t)=>{F[e]&&F[e].push(t)},k=e=>{F[e]?.forEach((e=>e.call($)))},D=e=>{e.data&&Object.assign($,e.data()),e.methods&&Object.assign(r,e.methods),e.computed&&Object.assign(t,e.computed),e.watch&&Object.entries(e.watch).forEach((([e,t])=>{(n[e]??=[]).push(t)})),e.mounted&&q("mounted",e.mounted)};u.forEach(D);window.addEventListener("error",(e=>{console.error("Global error:",e)}));let P={beforeEnter(e){e.style.opacity="0",e.style.transform="translateY(-20px)",e.style.display=""},enter(e,t){let r=1e3*parseFloat(getComputedStyle(e).transitionDuration);requestAnimationFrame((()=>{e.style.opacity="1",e.style.transform="translateY(0)",setTimeout(t,r)}))},afterEnter(e){e.style.opacity="",e.style.transform=""},enterCancelled(e){e.style.opacity="",e.style.transform=""},beforeLeave(e){e.style.opacity="1",e.style.transform="translateY(0)"},leave(e,t){let r=1e3*parseFloat(getComputedStyle(e).transitionDuration);requestAnimationFrame((()=>{e.style.opacity="0",e.style.transform="translateY(-20px)",setTimeout(t,r)}))},afterLeave(e){e.style.display="none",e.style.opacity="",e.style.transform=""},leaveCancelled(e){e.style.opacity="",e.style.transform=""}},U=e=>{if(!(e instanceof HTMLElement))return;let t=e.getAttribute("i-show");if(!t)return;let r=null,n=async()=>{try{let n=Function("state",`with(state) { return ${t} }`)($);e._transitionShow&&e._transitionHide?(r&&(await r,r=null),await(r=n?e._transitionShow():e._transitionHide())):e.style.display=n?"":"none"}catch(e){console.error("Error evaluating i-show directive:",e)}};n(),(m[t]??=[]).push({element:e,update:n}),e.removeAttribute("i-show")};return{mount:M((function(e){if(!(f=document.querySelector(e)))throw Error(`Element with selector "${e}" not found.`);k("beforeCreate"),k("created"),a&&a.call($),k("beforeMount"),c.forEach((e=>{"function"==typeof e&&e({createPlugin:v,state:$,bindings:m})}));let t=f.querySelector("template");t&&(f.innerHTML=t.innerHTML),j(),f.querySelectorAll("*").forEach((e=>{Array.from(e.attributes).forEach((t=>{if(t.name.startsWith("@")){let[n,...o]=t.name.slice(1).split("."),a=t.value.trim(),l={once:o.includes("once"),capture:o.includes("capture")};e.addEventListener(n,(e=>{try{o.includes("prevent")&&e.preventDefault(),o.includes("stop")&&e.stopPropagation(),r&&r[a]?r[a].call($,e):Function("state","event",`with(state) { ${a} }`).call($,$,e),x()}catch(e){console.error(`Error executing event handler: ${a}`,e)}}),l),e.removeAttribute(t.name)}}))})),f.querySelectorAll("[\\i-for]").forEach((e=>{if(!(e instanceof HTMLElement))return;let t=e.getAttribute("i-for");if(!t)return;let r=t.match(/^\s*(\w+)(?:\s*,\s*(\w+))?\s+(?:of|in)\s+(\w+)\s*$/);if(!r)return void console.error("Invalid i-for expression:",t);let[,n,o,a]=r,l=e.parentNode,i=document.createComment("i-for placeholder");l?.insertBefore(i,e),e.removeAttribute("i-for");let c=e.cloneNode(!0);l?.removeChild(e);let s=()=>{let e=document.createDocumentFragment(),t=$[a];for((Array.isArray(t)&&t.forEach(((t,r)=>{let a=c.cloneNode(!0),l={[n]:t,...o&&{[o]:r}},i=new Proxy(l,{get:(e,t)=>t in e?e[t]:$[t]}),s=e=>{if(e.nodeType===Node.TEXT_NODE){let t=e.textContent;t.includes("{")&&t.includes("}")&&(e.textContent=t.replace(/\{(.*?)\}/g,((e,t)=>Function("state",`with(state) { return ${t} }`)(i))))}else e.nodeType===Node.ELEMENT_NODE&&Array.from(e.childNodes).forEach(s)};s(a),a.querySelectorAll("*").forEach((e=>{Array.from(e.attributes).forEach((t=>{if(t.value.includes("{")&&t.value.includes("}")){let r=t.value.replace(/\{(.*?)\}/g,((e,t)=>Function("state",`with(state) { return ${t} }`)(i)));e.setAttribute(t.name,r)}}))})),e.appendChild(a)})));i.nextSibling;)l?.removeChild(i.nextSibling);l?.insertBefore(e,i.nextSibling)};s(),(m[a]??=[]).push({updateFor:s})})),f.querySelectorAll("[\\i-ref]").forEach((e=>{if(!(e instanceof HTMLElement))return;let t=e.getAttribute("i-ref");t&&(y[t]=e,e.removeAttribute("i-ref"))})),f.querySelectorAll("[\\i-model]").forEach((e=>{if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement))return;let t=e.getAttribute("i-model");t&&(e.value=$[t]||"",e.addEventListener("input",(e=>{$[t]=e.target.value})),(m[t]??=[]).push({element:e,updateModel(){e.value=$[t]||""}}),e.removeAttribute("i-model"))})),f.querySelectorAll("[\\i-html]").forEach((e=>{if(!(e instanceof HTMLElement))return;let t=e.getAttribute("i-html");if(!t)return;let r=()=>{try{let r=Function("state",`with(state) { return ${t} }`)($);e.innerHTML=r}catch(e){console.error("Error applying i-html directive:",e)}};r(),(m[t]??=[]).push({updateHtml:r}),e.removeAttribute("i-html")})),f.querySelectorAll("[i-transition]").forEach((e=>{if(!(e instanceof HTMLElement))return;let t=e.getAttribute("i-transition");if(!t)return;let[r,n,o]=t.split(",").map((e=>e.trim())),a=n?`${n}ms`:"300ms",l=o||"ease";e.style.transition=`opacity ${a} ${l}, transform ${a} ${l}`;let i=(t,r)=>new Promise((n=>{let o=!1;return t.before(e),t.during(e,(()=>{o||(t.after(e),r&&r(),n())})),()=>{o=!0,t.cancelled(e),n()}}));e._transitionShow=async t=>{e.style.display="",await i({before:P.beforeEnter,during:P.enter,after:P.afterEnter,cancelled:P.enterCancelled},t)},e._transitionHide=async e=>{await i({before:P.beforeLeave,during:P.leave,after:P.afterLeave,cancelled:P.leaveCancelled},e)},e.style.display="none",e.removeAttribute("i-transition")})),f.querySelectorAll("*").forEach((e=>{e instanceof HTMLElement&&Array.from(e.attributes).forEach((t=>{let r=t.name.match(/^(?:i-bind:|:)(.+)$/);if(!r)return;let[,n]=r,o=t.value,a=()=>{try{let t=Function("state",`with(state) { return ${o} }`)($);"class"===n?"object"==typeof t&&null!==t?Object.entries(t).forEach((([t,r])=>{e.classList.toggle(t,!!r)})):e.className=t:"style"===n?"object"==typeof t&&null!==t?Object.entries(t).forEach((([t,r])=>{e.style[t]=r})):e.setAttribute("style",t):!1===t?e.removeAttribute(n):e.setAttribute(n,!0===t?"":t)}catch(e){console.error(`Error applying bind directive for ${n}:`,e)}};a(),(m[o]??=[]).push({update:a}),e.removeAttribute(t.name)}))})),(e=>{Object.entries(O).forEach((([t,r])=>{r.includes(e)&&(delete p[t],N(t))}))})(),f.querySelectorAll("[\\i-show]").forEach((e=>{e instanceof HTMLElement&&U(e)})),o&&o.call($),k("mounted"),Object.keys($).forEach((e=>N(e)))}),"Error mounting application"),onUpdated:e=>{if("function"==typeof e){let t=M(e,"Error in onUpdated callback");(h.__updated__??=[]).push({callback:t})}},createPlugin:v,emit:(e,t)=>{(b.get(e)??[]).forEach((e=>e(t)))},on:(e,t)=>(b.has(e)||b.set(e,[]),b.get(e).push(t),()=>{let r=b.get(e),n=r.indexOf(t);-1!==n&&r.splice(n,1)}),addLifecycleHook:q,applyMixin:D,component:A,render:e=>{let t=document.createElement("template");return t.innerHTML=e.trim(),t.content}}};export{createApp};
|