sigment 1.4.0 → 1.4.1
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/index.js +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var ye=Object.defineProperty;var a=(e,t)=>ye(e,"name",{value:t,configurable:!0});var w={cleanHtml:Ce,cleanhtml:!0,setMaxCacheSize:Ae,maxCacheSize:10,setloadAtRunTime:Se,loadAtRunTime:null,setRoute:xe,route:null,setStopPropagation:Te,stopPropagation:!1},A={funcname:[],dataMap:new Map},W=null,O={},z=new Map,v=new Map,I=new Map,L=new Map,ge=null,P=null,G=new Map;var D="",S=typeof window>"u",V=0;S||(D=window.location.href.replace(/^https?:\/\//,"").replace(/\/$/,""));function be(){try{let e=import.meta.glob("/src/components/*.js"),t=Object.fromEntries(Object.entries(e).map(([n,o])=>[n.split("/").pop().replace(".js",""),o]));t.defaultKey="/",w.loadAtRunTime=t}catch{w.loadAtRunTime={}}}a(be,"initLoadAtRunTime");globalThis.__CURRENT_COMPONENT__=null;var M=0,ce=new Map;S&&(globalThis.__HANDLER_REGISTRY__||(globalThis.__HANDLER_REGISTRY__={}),globalThis.__HANDLER_ELEMENT_MAP__||(globalThis.__HANDLER_ELEMENT_MAP__=new Map));var _={innerHTMLElements:["div","p","span","h1","h2","h3","h4","h5","h6","a","ul","ol","li","table","tr","td","th","thead","tbody","tfoot","form","label","button","section","article","header","footer","nav","aside","main","figure","figcaption","blockquote","cite","code","pre","em","strong","i","b","u","s","small","mark","time","abbr","q","dl","dt","dd","fieldset","legend","textarea","output","progress","meter","fragment","details","summary","dialog","menu","slot","svg","defs","linearGradient","text","template"],valueElements:["input","textarea","select","button","option","progress","meter"],srcElements:["img","script","iframe","audio","video","source","track","embed","frame","input"],hrefElements:["a","link","area","base"],voidElements:["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","path","circle","rect","wbr","polygon","ellipse","stop","canvas","frame"]};Object.values(_).flat().forEach(e=>{globalThis[e]||(globalThis[e]=(...t)=>U(e,...t),Object.defineProperty(globalThis,e,{writable:!1,configurable:!1}))});var K=new Set(_.valueElements),te=new Set(_.srcElements),ne=new Set(_.hrefElements),Y=new Set(_.voidElements);function ze(e,t){O[e]||(O[e]=pe(t))}a(ze,"createGlobalSignal");function Be(e){return O[e]}a(Be,"getGlobalSignal");function oe(e,t){A.dataMap.has(e)&&A.dataMap.delete(e),A.dataMap.set(e,t)}a(oe,"addEntry");var j={destroy:a(function(){var n;let e=(n=this.parentNode)==null?void 0:n.iid,t=this._map.get(e);if(t&&t.elements){let o=this._idx;if(o!==void 0&&o!==-1){t.elements.splice(o,1),t.ids.splice(o,1),t.nodes.splice(o,1);for(let s=o;s<t.elements.length;s++)t.elements[s]._idx=s}}this.remove()},"destroy"),swapWith:a(function(e){var f;let t=(f=this.parentNode)==null?void 0:f.iid,n=this._map.get(t);if(!n||!n.elements)return this;let o=this._idx;if(o===void 0||e<0||e>=n.elements.length)return this;let s=n.elements[e],i=n.elements[o];n.elements[o]=n.elements[e],n.elements[e]=i;let c=n.ids[o];n.ids[o]=n.ids[e],n.ids[e]=c,this._idx=e,s._idx=o;let r=this.parentNode,d=s.nextSibling,u=this.nextSibling;return d===this?r.insertBefore(this,s):(r.insertBefore(s,u),r.insertBefore(this,d)),this},"swapWith"),updateVal:a(function(e,t){return this._nodes&&this._nodes[e]&&(this._nodes[e].nodeValue=t),this},"updateVal"),addVal:a(function(e,t){let n=this._nodes[e];return n&&n.appendData(t),this},"addVal"),clear:a(function(){let e=this._map.get(this.iid);e&&(e.elements&&(e.elements.length=0),e.ids&&(e.ids.length=0),e.nodes&&(e.nodes.length=0)),this.textContent=""},"clear")},re=a((e,t,n)=>{if(e.destroy)return e;let o=n||A.dataMap;return e.iid=e.iid||(t==null?void 0:t.id)||e.id,e._map=o,e.destroy=j.destroy,e.swapWith=j.swapWith,e.updateVal=j.updateVal,e.addVal=j.addVal,o.get(e.iid)&&(e.clear=j.clear,e.get=i=>{let c=o.get(e.iid);if(!c||!c.elements)return null;let r=null;if(typeof i=="number")r=c.elements[i];else{let d=c.ids.indexOf(i);d!==-1&&(r=c.elements[d])}return r?H(r):null}),e},"upgradeElement");function H(e){var i;let t=e&&e.nodeType,n=t?e.iid:e,o=A.dataMap.get(n);if(t)return re(e,{id:n},A.dataMap);if(!o)return null;let s=(i=o.value)!=null&&i.hydrate?document.getElementById(n):o.value;return s?re(s,o,A.dataMap):null}a(H,"gve");var Ee=a((e,t)=>{let n=[],o=t;for(;o!==e&&o.parentNode;){let s=o.parentNode,i=Array.prototype.indexOf.call(s.childNodes,o);n.unshift(i),o=s}return n},"getPath"),_e=a(e=>{if(e.length===0)return n=>n;let t=e.map(n=>`childNodes[${n}]`).join(".");return new Function("node",`return node.${t}`)},"compilePath"),Ie=a(e=>{let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),o=n.nextNode(),s=0;for(;o;){if(o.nodeValue.trim()==="?"){let i=Ee(e,o);t.push({dataIndex:s++,fastGet:_e(i)})}o=n.nextNode()}return{blueprint:e,bindings:t}},"createTemplate"),Ge=a((e,t,n,o=1e3,s=!1)=>{let i=A.dataMap.get(n);if(!i)return;s?(i.elements||(i.elements=[]),i.nodes||(i.nodes=[]),i.ids||(i.ids=[])):(i.value.textContent="",i.elements=[],i.nodes=[],i.ids=[]);let{blueprint:c,bindings:r}=t,d=r.length,u=0,f=a(()=>{let p=document.createDocumentFragment(),y=Math.min(u+o,e.length);for(;u<y;u++){let h=e[u];if(!h)continue;let g=h[0],l=c.cloneNode(!0);l.iid=g,l._idx=u;let m=new Array(d);for(let b=0;b<d;b++){let x=r[b],E=x.fastGet(l);E&&(E.nodeValue=h[x.dataIndex],m[b]=E)}l._nodes=m,i.elements[u]=l,i.nodes[u]=m,i.ids[u]=g,p.appendChild(l)}i.value.appendChild(p),u<e.length&&requestAnimationFrame(f)},"renderChunk");f()},"batch");function J(e,t=void 0){R(J.name),A.createInstance=J.name;let n="";t===void 0?n=e():n=e(t)}a(J,"createInstance");function ie(e,t){R(ie.name),A.rpc=ie.name;let n={};for(let[o,s]of Object.entries(t))e[o]?n[o]=e[o].apply(null,s):(console.error(`Function ${o} not found!`),n[o]=null);return n}a(ie,"rpc");function se(e,t=!1,n){R(se.name),A.gvec=se.name;let o=Object.keys(e),s=o[0],i=o[1],c=o[2];var r=e[s];r=r.name;var d=e[i];let u=e[i];var f=H(i)===null;if(f||t===!1){var p=""+i;A.dataMap.delete(p),J(d,e[c])}d=H(i);var y=H(s);if(y===null)throw new Error(` source id '${s} is not found in source component `);if(d===null)throw new Error(` target id '${i} is not found in target component `);if(y.replaceWith(d),n!==void 0)for(let l in u){let m=l.toString();if(typeof n=="object"){for(var h in n)if(m===h){var g=n[h];typeof g=="object"?u[l].apply(null,g):u[l].apply(null,[])}}else if(n.indexOf(",">-1)){let b=n.split(",");for(let x=0;x<b.length;x++)m===b[x]&&u[l].apply(null,[])}else m===n&&u[l].apply(null,[])}}a(se,"gvec");async function Ke(e,t={}){let{passRestriction:n=[]}=t,o=window.location.pathname.replace(/^\/|\/$/g,"").toLowerCase(),s=e.replace(/^\/|\/$/g,"").toLowerCase();if(!new RegExp("^"+s.replace(/:[^\/]+/g,"[^/]+")+"$").test(o))return!1;let c=Array.isArray(n)?n:[n];for(let r of c)try{let d=typeof r=="function"?r():r;if(d instanceof Promise){if(!await d)return!1}else if(!d)return!1}catch(d){return console.error("Route check failed:",d),!1}return!0}a(Ke,"Route");function Ye(e){return e==null||e===""}a(Ye,"IsEmpty");function we(e){let t=e.startsWith("/")?e:"/"+e;window.history.pushState({},"",t)}a(we,"Navigate");function Ae(e){w.maxCacheSize=e}a(Ae,"setMaxCacheSize");function Ce(e){w.cleanhtml=e}a(Ce,"cleanHtml");function xe(e){w.route=e}a(xe,"setRoute");function Se(e){if(e===!0){be();return}if(typeof e=="object"&&e!==null&&!Array.isArray(e)){w.loadAtRunTime=e;return}throw new Error("setloadAtRunTime expects true or an object of dynamic modules")}a(Se,"setloadAtRunTime");function Te(e){w.stopPropagation=e}a(Te,"setStopPropagation");async function Je(e,t){let n;t==="/"?n=t:n=t.replace(/\//g,"").toLowerCase();let o=Object.keys(e).find(s=>s.toLowerCase()===n.toLowerCase());if(!o){let s=Object.keys(e).join(", ");throw new Error(`Unknown component: "${t}".
|
|
2
2
|
Available components: ${s}
|
|
3
3
|
|
|
4
4
|
To add this component:
|
|
@@ -6,6 +6,6 @@ To add this component:
|
|
|
6
6
|
const loadAsyncComponents = {
|
|
7
7
|
...existingComponents,
|
|
8
8
|
"${t}": () => import('./${t}.js')
|
|
9
|
-
};`)}if(
|
|
10
|
-
`);for(let c=0;c<n.length;c++){var
|
|
11
|
-
`);if(o===-1)continue;r=n[c].slice(o+1),r===""?(o=n[c].lastIndexOf("/")+1,o>-1&&(r=n[c].substr(o),r=r.substr(0,r.indexOf(".")))):r.indexOf("/")>-1&&(r=r.substr(0,r.indexOf("/")))}else r=(i=n[c])==null?void 0:i.trim().split(" ")[1];if(!A.funcname.includes(r)&&!(r===void 0||r==="")&&!(r.indexOf("http://")>-1||r.indexOf("https://")>-1)){if(A.gvec!==void 0&&r.indexOf(A.gvec)>-1)break;t.indexOf("|"+r)>-1||(t+="|"+r.replace(".","|"))}}return e+t}a(Q,"buildRoadMap");function $(e){!A.funcname.includes(e)&&A.funcname.push(e)}a($,"setFuncName");function fe(e){let t=typeof e=="object"&&e!==null&&!Array.isArray(e),n=!(typeof process<"u");t&&n&&console.warn("[Sigment] createSignal() is deprecated for objects. Use signal()."),t&&!n&&console.warn("[Sigment] createSignal() is deprecated for objects. Use signal().");let r=e,s=new Set;function i(){return H&&s.add(H),r}a(i,"get"),i.__isSignal=!0,i.__isPrimitiveSignal=!0;function c(u,d=!1){(d||r!==u)&&(r=u,s.forEach(f=>f()))}return a(c,"set"),[new Proxy(i,{get(u,d){if(d==="valueOf")return()=>r;if(d==="toString")return()=>String(r);if(d in u)return u[d]}}),c]}a(fe,"createSignal");function ve(e){return typeof e=="object"&&e!==null}a(ve,"isObject");function Je(e){return pe(e)[0]}a(Je,"store");function de(e){let t=e,n=new Map,r=a(o=>ve(o)?de(o)[0]:o,"wrap"),s=a(o=>{if(!n.has(o)){let[u,d]=fe(r(t[o])),f=new Proxy(u,{get(p,h){return h==="valueOf"?()=>u():h==="toString"?()=>String(u()):p[h]}});n.set(o,[f,d])}return n.get(o)},"getSignal"),i=new Proxy(t,{get(o,u){if(typeof u=="symbol")return t[u];let[d]=s(u);return d()},set(o,u,d){t[u]=d;let[,f]=s(u);return f(r(d)),!0}});function c(o){let u=typeof o=="function"?o(i):o;for(let d in u)i[d]=u[d]}return a(c,"setState"),[i,c]}a(de,"signalObject");function pe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?de(e):fe(e)}a(pe,"signal");function ee(e){function t(){H=t,e(),H=null}a(t,"wrapped"),t()}a(ee,"createEffect");function ke(e){e=e.toLowerCase(),E.innerHTMLElements.includes(e)||(E.innerHTMLElements.push(e),globalThis[e]=(...t)=>I(e,...t))}a(ke,"createTypeElement");function me(e){return e.replace(/-+/g,"-").replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}a(me,"dashToCamel");function Xe(e,t=null){he(e,t)}a(Xe,"createSigment");function Ze(e,t=null){he(e,t)}a(Ze,"addSigment");function Qe(e,...t){if(ke(e),t.length!==0)return globalThis[e](...t)}a(Qe,"createElement");function Ne(e){let t=document.createTextNode("");return ee(()=>{if(typeof M!="object"||M===null){t.nodeValue=e;return}let n=e.replace(/{{(.*?)}}/g,(r,s)=>{let i=s.trim();if(M.hasOwnProperty(i)){let c=M[i];if(c&&typeof c[0]=="function")return c[0]()??""}return""});t.nodeValue=n}),t}a(Ne,"interpolateReactiveText");function et(e,t=5e3,n={}){let r=JSON.stringify([e,n,t]);if(!z.has(r)){let s=Pe(async()=>{let i=await fetch(e,n);if(!i.ok)throw new Error(`Fetch failed: ${i.status}`);return i.json()},t);z.set(r,s)}return z.get(r)()}a(et,"fetchCache");function te(e){if(Array.isArray(e))return e.map(te);if(e&&typeof e=="object"){let t={};return Object.keys(e).sort().forEach(n=>{t[n]=te(e[n])}),t}return e}a(te,"sortObjectDeep");function Me(e){if(e&&typeof e=="object"&&!Array.isArray(e)){let t={};return Object.keys(e).sort().forEach(n=>{t[n]=e[n]}),t}return e}a(Me,"sortObjectShallow");function Pe(e,t=null,n={}){let r=new Map,s=a((...i)=>{let{deepSort:c}=n,o;c===!0?o=i.map(y=>y&&typeof y=="object"?te(y):y):c===!1?o=i.map(y=>y&&typeof y=="object"?Me(y):y):o=i;let u=JSON.stringify(o),d=Date.now();u.length===2&&(u=e.name);let p=r.get(u);if(p&&(t===null||d-p.timestamp<t))return p.value;let h=e(...i);return r.set(u,{value:h,timestamp:d}),h instanceof Promise&&h.catch(()=>r.delete(u)),h},"wrapped");return s.clear=()=>r.clear(),s}a(Pe,"memoizeFunc");function B(e){let t={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,n=>t[n])}a(B,"escapeHtml");function Le(e){let t="";function n(r,s=0){let i=" ".repeat(s);if(r==null||r===!1||r===!0)return;if(Array.isArray(r)){r.forEach(o=>n(o,s+1));return}let c=r;typeof c=="function"&&(c=c()),typeof c=="function"&&c.__isSignal&&(c=c()),!(c==null||c===!1||c===!0)&&(t+=String(c))}return a(n,"process"),e.forEach(r=>n(r)),t}a(Le,"renderChildren");function Re(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n],s=e[n+1];typeof r=="string"&&typeof s=="function"?(t.push(()=>r+s()),n++):t.push(r)}return t}a(Re,"normalizeChildren");function I(e,...t){var g;let n={},r=[];if(t[0]&&typeof t[0]=="object"&&!Array.isArray(t[0])&&t[0]!==null&&!(t[0]instanceof String)&&(v||!(t[0]instanceof Node))?(n=t[0],r=t.slice(1)):r=t,v&&typeof document>"u"){let l=globalThis.__CURRENT_COMPONENT__;globalThis.__HANDLER_REGISTRY__||(globalThis.__HANDLER_REGISTRY__={}),(g=globalThis.__HANDLER_REGISTRY__)[l]||(g[l]=[]);let m=[];for(let[O,T]of Object.entries(n))if(O==="style"&&typeof T=="object"){let N=Object.entries(T).map(([C,ye])=>`${C.replace(/([A-Z])/g,"-$1").toLowerCase()}:${ye}`).join(";");m.push(` style="${B(N)}"`)}else O!=="className"&&O!=="class"&&!O.startsWith("on")&&m.push(` ${O}="${B(String(T))}"`);(n.className||n.class)&&m.push(` class="${B(n.className||n.class)}"`);let b=Le(r);if(["input","img","br","hr","meta","link"].includes(e))return`<${e}${m.join("")} />`;if(e==="fragment")return b;var s;let w=G.get(e);return w&&(s=w.tagName,w.nativeTag!==null&&(s=w.nativeTag)),s!==void 0&&(e=s),`<${e}${m.join("")}>${b}</${e}>`}$(I.name);var i="";i=Q();var c=i.split("|");if(c.includes(A.rpc))return;let o=null,u=e.toLowerCase()==="fragment";if(u)o=document.createDocumentFragment();else{var s;let m=G.get(e);m&&(s=m.tagName,m.nativeTag!==null&&(s=m.nativeTag)),s!==void 0&&(e=s),o=document.createElement(e)}if(globalThis.__CURRENT_COMPONENT__){V++;let l=V;o.dataIndex=l,o.realtedComponent=globalThis.__CURRENT_COMPONENT__,o.cmpNbr=j}let d=[];for(let[l,m]of Object.entries(n))if(l.startsWith("on")&&typeof m=="function"){let b=l.slice(2).toLowerCase();d.push({type:b,val:m})}d.length&&(o._handlers=d);let f=J.has(e),p=Y.has(me(e)),h=e==="input"||e==="option",y=e==="option";if(!u)for(let l in n){let m=n[l];if(l.startsWith("on")&&typeof m=="function"){let b=l.slice(2).toLowerCase();o.addEventListener(b,S=>{_.stopPropagation&&S.stopPropagation(),m(S)})}else typeof m=="function"&&l!=="children"?ee(()=>{let b=m();b==null||b===!1?(o.removeAttribute(l),l==="value"&&p&&(o.value="",_.cleanhtml||o.removeAttribute("value")),l==="checked"&&h&&(o.checked=!1,_.cleanhtml||o.removeAttribute("checked")),l==="selected"&&y&&(o.selected=!1,_.cleanhtml||o.removeAttribute("selected")),l==="id"&&(o.iid="",_.cleanhtml||o.removeAttribute("id"))):l==="id"?(o.iid=b,_.cleanhtml?o.removeAttribute("id"):o.setAttribute("id",b),X(b,{name:b,caller:b+i,value:o})):l==="value"&&p?(o.value=b,_.cleanhtml?o.removeAttribute("value"):o.setAttribute("value",b)):l==="checked"&&h?(o.checked=b,_.cleanhtml?o.removeAttribute("checked"):b?o.setAttribute("checked",""):o.removeAttribute("checked")):l==="selected"&&y?(o.selected=b,_.cleanhtml?o.removeAttribute("selected"):b?o.setAttribute("selected",""):o.removeAttribute("selected")):o.setAttribute(l,b)}):m!=null&&m!==!1&&(l==="id"?(o.iid=m,_.cleanhtml?o.removeAttribute("id"):o.setAttribute("id",m),X(m,{name:m,caller:m+i,value:o})):l==="value"&&p?(o.value=m,_.cleanhtml?o.removeAttribute("value"):o.setAttribute("value",m)):l==="checked"&&h?(o.checked=m,_.cleanhtml?o.removeAttribute("checked"):o.setAttribute("checked","")):l==="selected"&&y?(o.selected=m,_.cleanhtml?o.removeAttribute("selected"):o.setAttribute("selected","")):o.setAttribute(l,m))}return f?r.length===1&&(typeof r[0]=="string"||typeof r[0]=="number")?p&&(o.value=r[0],_.cleanhtml?o.removeAttribute("value"):o.setAttribute("value",r[0])):r.length>0&&console.warn(`Void element <${e}> should not have children.`):(r=Re(r),r.flat().forEach((l,m)=>{if(l&&l.__isSignal&&l.__isPrimitiveSignal&&!l.__isWrapped){let b=l;b.__isWrapped=!0,l=a(()=>b(),"child")}if(typeof l=="function"){let b=l(),w=b===!1||b===null||b===!0?document.createComment(""):document.createTextNode("");o.appendChild(w),ee(()=>{let x=l();if(Array.isArray(x)){let T=w.parentNode;if(!T)return;w._insertedNodes&&(w._insertedNodes.forEach(C=>C.remove()),w._insertedNodes=null);let N=x.flat().filter(Boolean).map(C=>C instanceof Node?C:typeof C=="string"||typeof C=="number"?document.createTextNode(String(C)):typeof C=="object"?C.__isNode?C:div(C.name??JSON.stringify(C)):null).filter(Boolean);N.forEach(C=>T.insertBefore(C,w)),w._insertedNodes=N,w.nodeValue="";return}if(x instanceof Node){let T=w.parentNode;if(!T)return;w._insertedNode&&(w._insertedNode._boundNode&&w._insertedNode._boundNode.remove(),w._insertedNode.remove(),w._insertedNode=null),T.insertBefore(x,w),w._insertedNode=x;return}let O=x==null||x===!1||x===!0?"":String(x);if(w._insertedNode&&(w._insertedNode._boundNode&&w._insertedNode._boundNode.remove(),w._insertedNode.remove(),w._insertedNode=null),w.nodeValue!==O){if(!w.parentNode)return;w!=null&&w._boundNode?w._boundNode.nodeValue=O:w.nodeValue=O}})}else if(typeof l=="string"&&l.includes("{{")&&!l.includes("function"))o.appendChild(Ne(l));else if(typeof l=="string"||typeof l=="number"){if(typeof l=="string"&&(l.includes("function get(")||l.includes("function (")||l.includes("[native code]")))throw new Error("Detected reactive getter function used inside a template string. Use a function instead like: div(() => `Your text is: ${someState()}`)");o.appendChild(document.createTextNode(l))}else(l instanceof DocumentFragment||l instanceof Node)&&o.appendChild(l)})),o}a(I,"h");function je(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/-+/g,"-").toLowerCase()}a(je,"camelToDash");function he(e,t=null){if(E.innerHTMLElements.includes(e)||E.valueElements.includes(e)||E.srcElements.includes(e)||E.hrefElements.includes(e)||E.voidElements.includes(e))return;let r=/[A-Z]/.test(e)?je(e):e.toLowerCase();r.includes("-")||(r="s-"+r),e.includes("-")&&(r=e,e=me(e)),G.set(e,{tagName:r,nativeTag:t}),!E.innerHTMLElements.includes(e)&&t===null?E.innerHTMLElements.push(e):!E.innerHTMLElements.includes(e)&&t!==null&&(E.innerHTMLElements.includes(t)||E.innerHTMLElements.push(e)),!E.valueElements.includes(e)&&t===null?(E.valueElements.push(e),Y.add(e)):!E.valueElements.includes(e)&&t!==null&&(E.valueElements.includes(t)||(E.valueElements.push(e),Y.add(e))),!E.srcElements.includes(e)&&t===null?(E.srcElements.push(e),re.add(e)):!E.srcElements.includes(e)&&t!==null&&(E.srcElements.includes(t)||(E.srcElements.push(e),re.add(e))),!E.hrefElements.includes(e)&&t===null?(E.hrefElements.push(e),oe.add(e)):!E.hrefElements.includes(e)&&t!==null&&(E.hrefElements.includes(t)||(E.hrefElements.push(e),oe.add(e))),!E.voidElements.includes(e)&&t===null?(E.voidElements.push(e),J.add(e)):!E.voidElements.includes(e)&&t!==null&&(E.voidElements.includes(t)||(E.voidElements.push(e),J.add(e))),globalThis[e]=(...s)=>I(e,...s)}a(he,"defineElement");function $e(e){v||requestAnimationFrame(()=>{requestAnimationFrame(e)})}a($e,"onPaint");function tt(e){if(v)return;let t=!1;$e(()=>{t||(t=!0,e())})}a(tt,"paintFinish");function le(e){let t={};for(let n of e.attributes)if(n.name.startsWith("data-")&&n.name!=="data-component"){let r=n.name.slice(5);try{t[r]=JSON.parse(n.value)}catch{t[r]=n.value}}return t}a(le,"getPropsFromDataAttributes");async function Fe(){let e=document.querySelector("layout[data-layout]");if(!e)return!1;let t=e.getAttribute("data-layout");if(!t)return!1;try{v||(t="/"+t);let n=await fetch(t);if(!n.ok)throw new Error("Failed to load layout");let r=await n.text(),i=new DOMParser().parseFromString(r,"text/html"),c=document.querySelector("description[data-description]");if(c){let d=i.querySelector('meta[name="description"]');d||(d=i.createElement("meta"),d.name="description",i.head.appendChild(d)),d.content=c.getAttribute("data-description")}let o=document.querySelector("keywords[data-keywords]");if(o){let d=i.querySelector('meta[name="keywords"]');d||(d=i.createElement("meta"),d.name="keywords",i.head.appendChild(d)),d.content=o.getAttribute("data-keywords")}return document.querySelectorAll("[data-part]").forEach(d=>{let f=d.getAttribute("data-part"),p=i.querySelector(`[data-part="${f}"]`);p&&(p.innerHTML="",[...d.childNodes].forEach(h=>{p.appendChild(h.cloneNode(!0))}))}),document.documentElement.innerHTML=i.documentElement.innerHTML,!0}catch(n){return console.error("Failed to inject layout:",n),!1}}a(Fe,"injectLayout");function U(e,t){if(!t)return;let n=t.trim();if(e[n])return e[n];let r=n[0].toUpperCase()+n.slice(1).toLowerCase();if(e[r])return e[r];let s=n.toUpperCase();if(e[s])return e[s];let i=n.toLowerCase(),c=Object.entries(e).find(([o,u])=>o.toLowerCase()===i);if(c)return c[1]}a(U,"lookupComponent");async function We(e,t){let n=t.trim();for(let[r,s]of Object.entries(e))if(s.loader)try{let i=await s.loader(),c=i.default||Object.values(i)[0];if(typeof c=="function"&&c.name===n)return s._componentName=c.name,s}catch(i){console.warn(`Failed to load route "${r}":`,i);continue}}a(We,"findRouteByComponentName");async function ae(e){var d;let t=e||_.route;await Fe();let{componentKey:n,componentNme:r,params:s}=ue(t),i=new Set,c=await s._componentNamePromise,o=n,u=document.querySelectorAll("[data-component]");for(let f of u){let p=f.getAttribute("data-component"),h=p==null?void 0:p.toLowerCase();if(typeof rvs_map_sigment<"u"&&rvs_map_sigment!==null?o=U(rvs_map_sigment,p):o=h,!o||i.has(o))continue;let y=U(t,o);y===void 0&&(y=await We(t,o));try{f.hasChildNodes()&&(globalThis.__CURRENT_COMPONENT__=p);let g=y?await De(y):await He(_.loadAtRunTime,o),l=y?{...s,...le(f)}:le(f),m=g.default(l);m.funcName=c.toLowerCase();let b=(d=f.closest("[data-part]"))==null?void 0:d.getAttribute("data-part");m.datapart=b,m.setAttribute("data-component",p),m.hydrate=!0,f.cmpNbr=j,ne(f,m),ce.set(o,j),j++,V=0}catch(g){console.warn(`Component "${h}" failed to load`,g)}}}a(ae,"hydrateComponent");async function De(e){if(!L.has(e)){let t=await e.loader();L.set(e,t)}return L.get(e)}a(De,"loadModule");async function He(e,t){let n=U(e,t);if(n){if(L.has(n))return L.get(n);try{let r=await n();return L.set(n,r),r}catch(r){console.error(`Component "${t}" failed to load`,r)}}}a(He,"loadModuleFromFile");function nt(e,t){if(e===void 0){ae();return}if(typeof e=="object"&&t===void 0){ae(e);return}let n=typeof e=="string"?document.getElementById(e):e;if(!n)throw new Error("Mount target not found: "+e);n.hasChildNodes()?ne(n,t):n.replaceChildren(t)}a(nt,"mount");function ne(e,t){(async()=>{try{if(!e||!t)return;if(t._boundNode=e,e.nodeName!==t.nodeName){e.replaceWith(t);return}if(e.nodeType===Node.TEXT_NODE||e.nodeType===Node.COMMENT_NODE){e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue);return}if(e.nodeType===Node.ELEMENT_NODE&&t.nodeType===Node.ELEMENT_NODE){for(let s of Array.from(t.attributes))e.setAttribute(s.name,s.value);for(let s of Array.from(e.attributes))t.hasAttribute(s.name)||e.removeAttribute(s.name);t._handlers&&t._handlers.forEach(({type:s,val:i})=>{e.addEventListener(s,c=>{_.stopPropagation&&c.stopPropagation(),i(c)})})}let n=Array.from(t.childNodes),r=Array.from(e.childNodes);for(let s=0;s<Math.max(n.length,r.length);s++){let i=r[s],c=n[s];i&&c?ne(i,c):c?e.appendChild(c):i&&e.removeChild(i)}}catch(n){console.error("Hydration failed:",n)}})()}a(ne,"hydrate");export{Ge as IsEmpty,_ as MyApp,we as Navigate,Ye as NavigateTo,Be as Route,Ze as addSigment,ze as batch,ee as createEffect,Qe as createElement,qe as createGlobalSignal,Xe as createSigment,fe as createSignal,Ie as createTemplate,et as fetchCache,Ue as getGlobalSignal,D as getVirtualElementById,qe as globalSignal,D as gve,se as gvec,I as h,ae as hydrateComponent,Ke as loadFunc,Oe as loadRunFunc,Pe as memoizeFunc,nt as mount,$e as onPaint,tt as paintFinish,ue as parsePath,ie as rpc,pe as sig,pe as signal,Je as store,Ue as useGlobalSignal};
|
|
9
|
+
};`)}if(v.has(o))return v.get(o);try{let i=(await e[o]()).default;return v.set(o,i),i}catch(s){throw new Error(`Failed to load component "${o}": ${s.message}`)}}a(Je,"loadFunc");function ke(e){let t=null,n=-1;if(typeof e=="string")return{partName:e,index:n};let o=(e==null?void 0:e.target)instanceof Element?e.target.closest("[data-component]"):null;if(o){let s=o.closest("[data-part]");if(t=s==null?void 0:s.getAttribute("data-part"),s){let i=o.getAttribute("data-component");i&&s.querySelectorAll(`[data-component="${i}"]`).forEach((r,d)=>{r===o&&(n=d)})}}return{partName:t,index:n}}a(ke,"getTargetPartAndIndex");async function Ze(e,t,n,o,s=null){if(S)return;let i=null,{partName:c,index:r}=ke(s);c&&(i=c);let d=window.location.host+"/"+e;if(i===null){if(D===d)return;D=d}let u;typeof t=="boolean"||typeof t=="string"?(n=t,t=w.route):t===void 0&&(t=w.route,n=!1),we(e);let{componentKey:f,params:p}=ue(t);(f===void 0||f==="")&&console.warn(`current path "${e}" not match in route map file , check if param path is match`);let y=Object.keys(t);if(typeof n=="string")f=n,u=!!o;else if(typeof n=="boolean"){if(y.length===1)f=y[0];else if(y.includes(f))f=f;else throw new Error(`Ambiguous component map: multiple components exist and no matching key for path '${e}' found. Provide component key explicitly.`);u=n}else{if(y.length===1)f=y[0];else if(y.includes(f))f=f;else throw new Error(`Ambiguous component map: multiple components exist and no matching key for path '${e}' found. Provide component key explicitly.`);u=!1}let h=await ve(t,f,p,null,!1);i&&(e=e+i+r);let g=G.get(e);if((!g||!u)&&(typeof h=="function"?(M=ce.get(h.name),V=0,Array.isArray(p)?g=h(...p):typeof p=="object"&&p!==null?g=h(p):g=h(),G.set(e,g)):g=h),P&&P.isConnected){var l=P.contains(g);l||P.replaceWith(g)}else{typeof rvs_map_sigment<"u"&&rvs_map_sigment!==null&&(f=q(rvs_map_sigment,f));let m=document.querySelectorAll('[data-part="'+i+'"] [data-component="'+f+'"]');g.setAttribute("data-component",f),m&&m.length===1?m[0].replaceWith(g):m&&m.length>1?m[r].replaceWith(g):document.body.replaceChildren(g)}i===null&&(P=g,ge=e),D=d}a(Ze,"NavigateTo");function ue(e){if(S)return;let t=window.location.pathname.replace(/\/{2,}/g,"/");t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1));let n=t.replace(/^\//,"").split("/").filter(Boolean);n[0]===void 0&&(n[0]="/");let o={},s=null,i=null,c=0;function r(f){return f.length>1&&f.endsWith("/")&&(f=f.slice(0,-1)),f.replace(/^\//,"").split("/").map(p=>{let y=p.startsWith(":"),h=y&&p.endsWith("?"),g=y?p.slice(1).replace("?",""):p;return g===""&&(g="/"),{isParam:y,isOptional:h,name:g}})}a(r,"parseRouteSegments");for(let[f,p]of Object.entries(e)){let y=p.path||`/${f}`,h=r(y),g=!0;for(let l=0;l<h.length;l++){let m=h[l],b=n[l];if(m.isParam){if(!b&&!m.isOptional){g=!1;break}}else if(m.name!==b){g=!1;break}}if(n.length<h.length){for(let l=n.length;l<h.length;l++)if(!h[l].isOptional){g=!1;break}}if(g){s=f,i=p,c=h.length,h.forEach((l,m)=>{if(l.isParam){let b=n[m];b!==void 0&&b!==""&&(o[l.name]=b)}});break}}s||(s="",i=e[s]),i!=null&&i.urlParam&&i.urlParam.split("/").map(p=>p.replace(/[{}]/g,"")).forEach((p,y)=>{let h=n[c+y];h!==void 0&&h!==""&&(o[p]=h)}),new URL(window.location.href).searchParams.forEach((f,p)=>{o[p]=f});let u=s;return i!=null&&i.loader&&(Object.defineProperty(o,"_componentNamePromise",{value:i.loader().then(f=>{let p=f.default||Object.values(f)[0];return typeof p=="function"&&p.name?p.name:s})}),Object.defineProperty(o,"componentName",{get(){return u}})),{componentKey:s,componentName:u,params:o}}a(ue,"parsePath");function F(e){return new DOMParser().parseFromString(e,"text/html").body.firstChild}a(F,"parseHTML");async function ve(e,t,n=null,o=null,s=!0){if(S)return;let i=e[t.toLowerCase()];if(i||(typeof e.fallback=="string"?i=e[e.fallback]:i=e.fallback),!i)return F("<h1>404 - Component not found</h1>");let{loader:c,guard:r,cacheExpiration:d=null,...u}=i;if(o===null&&typeof i.logic=="function"&&(o=i.logic),typeof r=="function"&&!await r(n))return F("<h1>403 - Forbidden</h1><p>You do not have access to this page.</p>");for(let f in u){let p=u[f];if(typeof p=="function")try{await p()}catch(y){console.error(y)}}try{let f=Date.now(),p=v.get(t);p&&d!==null&&f-p.cachedAt>d&&(v.delete(t),p=null);let y;if(p)y=p.component,v.set(t,{component:y,cachedAt:f});else{if(y=(await c()).default,v.size>=w.maxCacheSize){let m=v.keys().next().value;v.delete(m)}v.set(t,{component:y,cachedAt:f})}if(typeof y!="function")return F("<h1>Invalid component</h1>");if(!s)return y;let h;Array.isArray(n)?h=y(...n):typeof n=="object"&&n!==null?h=y(n):h=y();let g="/";try{g=window.location.pathname.slice(1)+window.location.hash,g=g.endsWith("/")&&g!=="/"?g.slice(0,-1):g,g===""&&(g="/")}catch{g=t}return G.set(g,h),P=h,h}catch(f){return console.error(f),F("<h1>Error loading component</h1>")}}a(ve,"loadRunFunc");function Z(e=""){var s,i;if(S)return"";R(Z.name),A.buildRoadMap=Z.name;var t="";let n=(s=new Error().stack)==null?void 0:s.toString();navigator.userAgent.toLowerCase().indexOf("firefox")>0?n=n.split("@"):n=n.split(`
|
|
10
|
+
`);for(let c=0;c<n.length;c++){var o="";if(navigator.userAgent.indexOf("Firefox")>0){let r=n[c].lastIndexOf(`
|
|
11
|
+
`);if(r===-1)continue;o=n[c].slice(r+1),o===""?(r=n[c].lastIndexOf("/")+1,r>-1&&(o=n[c].substr(r),o=o.substr(0,o.indexOf(".")))):o.indexOf("/")>-1&&(o=o.substr(0,o.indexOf("/")))}else o=(i=n[c])==null?void 0:i.trim().split(" ")[1];if(!A.funcname.includes(o)&&!(o===void 0||o==="")&&!(o.indexOf("http://")>-1||o.indexOf("https://")>-1)){if(A.gvec!==void 0&&o.indexOf(A.gvec)>-1)break;t.indexOf("|"+o)>-1||(t+="|"+o.replace(".","|"))}}return e+t}a(Z,"buildRoadMap");function R(e){!A.funcname.includes(e)&&A.funcname.push(e)}a(R,"setFuncName");function fe(e){let t=typeof e=="object"&&e!==null&&!Array.isArray(e),n=!(typeof process<"u");t&&n&&console.warn("[Sigment] createSignal() is deprecated for objects. Use signal()."),t&&!n&&console.warn("[Sigment] createSignal() is deprecated for objects. Use signal().");let o=e,s=new Set;function i(){return W&&s.add(W),o}a(i,"get"),i.__isSignal=!0,i.__isPrimitiveSignal=!0;function c(d,u=!1){(u||o!==d)&&(o=d,s.forEach(f=>f()))}return a(c,"set"),[new Proxy(i,{get(d,u){if(u==="valueOf")return()=>o;if(u==="toString")return()=>String(o);if(u in d)return d[u]}}),c]}a(fe,"createSignal");function Ne(e){return typeof e=="object"&&e!==null}a(Ne,"isObject");function Xe(e){return pe(e)[0]}a(Xe,"store");function de(e){let t=e,n=new Map,o=a(r=>Ne(r)?de(r)[0]:r,"wrap"),s=a(r=>{if(!n.has(r)){let[d,u]=fe(o(t[r])),f=new Proxy(d,{get(p,y){return y==="valueOf"?()=>d():y==="toString"?()=>String(d()):p[y]}});n.set(r,[f,u])}return n.get(r)},"getSignal"),i=new Proxy(t,{get(r,d){if(typeof d=="symbol")return t[d];let[u]=s(d);return u()},set(r,d,u){t[d]=u;let[,f]=s(d);return f(o(u)),!0}});function c(r){let d=typeof r=="function"?r(i):r;for(let u in d)i[u]=d[u]}return a(c,"setState"),[i,c]}a(de,"signalObject");function pe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?de(e):fe(e)}a(pe,"signal");function X(e){function t(){W=t,e(),W=null}a(t,"wrapped"),t()}a(X,"createEffect");function Oe(e){e=e.toLowerCase(),_.innerHTMLElements.includes(e)||(_.innerHTMLElements.push(e),globalThis[e]=(...t)=>U(e,...t))}a(Oe,"createTypeElement");function me(e){return e.replace(/-+/g,"-").replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}a(me,"dashToCamel");function Qe(e,t=null){Fe(e,t)}a(Qe,"addSigment");function et(e,...t){if(Oe(e),t.length!==0)return globalThis[e](...t)}a(et,"createElement");function Pe(e){let t=document.createTextNode("");return X(()=>{if(typeof O!="object"||O===null){t.nodeValue=e;return}let n=e.replace(/{{(.*?)}}/g,(o,s)=>{let i=s.trim();if(O.hasOwnProperty(i)){let c=O[i];if(c&&typeof c[0]=="function")return c[0]()??""}return""});t.nodeValue=n}),t}a(Pe,"interpolateReactiveText");function tt(e,t=5e3,n={}){let o=JSON.stringify([e,n,t]);if(!z.has(o)){let s=je(async()=>{let i=await fetch(e,n);if(!i.ok)throw new Error(`Fetch failed: ${i.status}`);return i.json()},t);z.set(o,s)}return z.get(o)()}a(tt,"fetchCache");function Q(e){if(Array.isArray(e))return e.map(Q);if(e&&typeof e=="object"){let t={};return Object.keys(e).sort().forEach(n=>{t[n]=Q(e[n])}),t}return e}a(Q,"sortObjectDeep");function Le(e){if(e&&typeof e=="object"&&!Array.isArray(e)){let t={};return Object.keys(e).sort().forEach(n=>{t[n]=e[n]}),t}return e}a(Le,"sortObjectShallow");function je(e,t=null,n={}){let o=new Map,s=a((...i)=>{let{deepSort:c}=n,r;c===!0?r=i.map(h=>h&&typeof h=="object"?Q(h):h):c===!1?r=i.map(h=>h&&typeof h=="object"?Le(h):h):r=i;let d=JSON.stringify(r),u=Date.now();d.length===2&&(d=e.name);let p=o.get(d);if(p&&(t===null||u-p.timestamp<t))return p.value;let y=e(...i);return o.set(d,{value:y,timestamp:u}),y instanceof Promise&&y.catch(()=>o.delete(d)),y},"wrapped");return s.clear=()=>o.clear(),s}a(je,"memoizeFunc");function B(e){let t={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,n=>t[n])}a(B,"escapeHtml");function Me(e){let t="";function n(o,s=0){let i=" ".repeat(s);if(o==null||o===!1||o===!0)return;if(Array.isArray(o)){o.forEach(r=>n(r,s+1));return}let c=o;typeof c=="function"&&(c=c()),typeof c=="function"&&c.__isSignal&&(c=c()),!(c==null||c===!1||c===!0)&&(t+=String(c))}return a(n,"process"),e.forEach(o=>n(o)),t}a(Me,"renderChildren");function Re(e){let t=[];for(let n=0;n<e.length;n++){let o=e[n],s=e[n+1];typeof o=="string"&&typeof s=="function"?(t.push(()=>o+s()),n++):t.push(o)}return t}a(Re,"normalizeChildren");function U(e,...t){var g;let n={},o=[];if(t[0]&&typeof t[0]=="object"&&!Array.isArray(t[0])&&t[0]!==null&&!(t[0]instanceof String)&&(S||!(t[0]instanceof Node))?(n=t[0],o=t.slice(1)):o=t,S&&typeof document>"u"){let l=globalThis.__CURRENT_COMPONENT__;globalThis.__HANDLER_REGISTRY__||(globalThis.__HANDLER_REGISTRY__={}),(g=globalThis.__HANDLER_REGISTRY__)[l]||(g[l]=[]);let m=[];for(let[N,k]of Object.entries(n))if(N==="style"&&typeof k=="object"){let $=Object.entries(k).map(([C,he])=>`${C.replace(/([A-Z])/g,"-$1").toLowerCase()}:${he}`).join(";");m.push(` style="${B($)}"`)}else N!=="className"&&N!=="class"&&!N.startsWith("on")&&m.push(` ${N}="${B(String(k))}"`);(n.className||n.class)&&m.push(` class="${B(n.className||n.class)}"`);let b=Me(o);if(["input","img","br","hr","meta","link"].includes(e))return`<${e}${m.join("")} />`;if(e==="fragment")return b;var s;let E=I.get(e);return E&&(s=E.tagName,E.nativeTag!==null&&(s=E.nativeTag)),s!==void 0&&(e=s),`<${e}${m.join("")}>${b}</${e}>`}R(U.name);var i="";i=Z();var c=i.split("|");if(c.includes(A.rpc))return;let r=null,d=e.toLowerCase()==="fragment";if(d)r=document.createDocumentFragment();else{var s;let m=I.get(e);m&&(s=m.tagName,m.nativeTag!==null&&(s=m.nativeTag)),s!==void 0&&(e=s),r=document.createElement(e)}if(globalThis.__CURRENT_COMPONENT__){V++;let l=V;r.dataIndex=l,r.realtedComponent=globalThis.__CURRENT_COMPONENT__,r.cmpNbr=M}let u=[];for(let[l,m]of Object.entries(n))if(l.startsWith("on")&&typeof m=="function"){let b=l.slice(2).toLowerCase();u.push({type:b,val:m})}u.length&&(r._handlers=u);let f=Y.has(e),p=K.has(me(e)),y=e==="input"||e==="option",h=e==="option";if(!d)for(let l in n){let m=n[l];if(l.startsWith("on")&&typeof m=="function"){let b=l.slice(2).toLowerCase();r.addEventListener(b,x=>{w.stopPropagation&&x.stopPropagation(),m(x)})}else typeof m=="function"&&l!=="children"?X(()=>{let b=m();b==null||b===!1?(r.removeAttribute(l),l==="value"&&p&&(r.value="",w.cleanhtml||r.removeAttribute("value")),l==="checked"&&y&&(r.checked=!1,w.cleanhtml||r.removeAttribute("checked")),l==="selected"&&h&&(r.selected=!1,w.cleanhtml||r.removeAttribute("selected")),l==="id"&&(r.iid="",w.cleanhtml||r.removeAttribute("id"))):l==="id"?(r.iid=b,w.cleanhtml?r.removeAttribute("id"):r.setAttribute("id",b),oe(b,{name:b,caller:b+i,value:r})):l==="value"&&p?(r.value=b,w.cleanhtml?r.removeAttribute("value"):r.setAttribute("value",b)):l==="checked"&&y?(r.checked=b,w.cleanhtml?r.removeAttribute("checked"):b?r.setAttribute("checked",""):r.removeAttribute("checked")):l==="selected"&&h?(r.selected=b,w.cleanhtml?r.removeAttribute("selected"):b?r.setAttribute("selected",""):r.removeAttribute("selected")):r.setAttribute(l,b)}):m!=null&&m!==!1&&(l==="id"?(r.iid=m,w.cleanhtml?r.removeAttribute("id"):r.setAttribute("id",m),oe(m,{name:m,caller:m+i,value:r})):l==="value"&&p?(r.value=m,w.cleanhtml?r.removeAttribute("value"):r.setAttribute("value",m)):l==="checked"&&y?(r.checked=m,w.cleanhtml?r.removeAttribute("checked"):r.setAttribute("checked","")):l==="selected"&&h?(r.selected=m,w.cleanhtml?r.removeAttribute("selected"):r.setAttribute("selected","")):r.setAttribute(l,m))}return f?o.length===1&&(typeof o[0]=="string"||typeof o[0]=="number")?p&&(r.value=o[0],w.cleanhtml?r.removeAttribute("value"):r.setAttribute("value",o[0])):o.length>0&&console.warn(`Void element <${e}> should not have children.`):(o=Re(o),o.flat().forEach((l,m)=>{if(l&&l.__isSignal&&l.__isPrimitiveSignal&&!l.__isWrapped){let b=l;b.__isWrapped=!0,l=a(()=>b(),"child")}if(typeof l=="function"){let b=l(),E=b===!1||b===null||b===!0?document.createComment(""):document.createTextNode("");r.appendChild(E),X(()=>{let T=l();if(Array.isArray(T)){let k=E.parentNode;if(!k)return;E._insertedNodes&&(E._insertedNodes.forEach(C=>C.remove()),E._insertedNodes=null);let $=T.flat().filter(Boolean).map(C=>C instanceof Node?C:typeof C=="string"||typeof C=="number"?document.createTextNode(String(C)):typeof C=="object"?C.__isNode?C:div(C.name??JSON.stringify(C)):null).filter(Boolean);$.forEach(C=>k.insertBefore(C,E)),E._insertedNodes=$,E.nodeValue="";return}if(T instanceof Node){let k=E.parentNode;if(!k)return;E._insertedNode&&(E._insertedNode._boundNode&&E._insertedNode._boundNode.remove(),E._insertedNode.remove(),E._insertedNode=null),k.insertBefore(T,E),E._insertedNode=T;return}let N=T==null||T===!1||T===!0?"":String(T);if(E._insertedNode&&(E._insertedNode._boundNode&&E._insertedNode._boundNode.remove(),E._insertedNode.remove(),E._insertedNode=null),E.nodeValue!==N){if(!E.parentNode)return;E!=null&&E._boundNode?E._boundNode.nodeValue=N:E.nodeValue=N}})}else if(typeof l=="string"&&l.includes("{{")&&!l.includes("function"))r.appendChild(Pe(l));else if(typeof l=="string"||typeof l=="number"){if(typeof l=="string"&&(l.includes("function get(")||l.includes("function (")||l.includes("[native code]")))throw new Error("Detected reactive getter function used inside a template string. Use a function instead like: div(() => `Your text is: ${someState()}`)");r.appendChild(document.createTextNode(l))}else(l instanceof DocumentFragment||l instanceof Node)&&r.appendChild(l)})),r}a(U,"h");function $e(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/-+/g,"-").toLowerCase()}a($e,"camelToDash");function Fe(e,t=null){if(_.innerHTMLElements.includes(e)||_.valueElements.includes(e)||_.srcElements.includes(e)||_.hrefElements.includes(e)||_.voidElements.includes(e))return;let o=/[A-Z]/.test(e)?$e(e):e.toLowerCase();o.includes("-")||(o="s-"+o),e.includes("-")&&(o=e,e=me(e)),I.set(e,{tagName:o,nativeTag:t}),!_.innerHTMLElements.includes(e)&&t===null?_.innerHTMLElements.push(e):!_.innerHTMLElements.includes(e)&&t!==null&&(_.innerHTMLElements.includes(t)||_.innerHTMLElements.push(e)),!_.valueElements.includes(e)&&t===null?(_.valueElements.push(e),K.add(e)):!_.valueElements.includes(e)&&t!==null&&(_.valueElements.includes(t)||(_.valueElements.push(e),K.add(e))),!_.srcElements.includes(e)&&t===null?(_.srcElements.push(e),te.add(e)):!_.srcElements.includes(e)&&t!==null&&(_.srcElements.includes(t)||(_.srcElements.push(e),te.add(e))),!_.hrefElements.includes(e)&&t===null?(_.hrefElements.push(e),ne.add(e)):!_.hrefElements.includes(e)&&t!==null&&(_.hrefElements.includes(t)||(_.hrefElements.push(e),ne.add(e))),!_.voidElements.includes(e)&&t===null?(_.voidElements.push(e),Y.add(e)):!_.voidElements.includes(e)&&t!==null&&(_.voidElements.includes(t)||(_.voidElements.push(e),Y.add(e))),globalThis[e]=(...s)=>U(e,...s)}a(Fe,"defineElement");function De(e){S||requestAnimationFrame(()=>{requestAnimationFrame(e)})}a(De,"onPaint");function nt(e){if(S)return;let t=!1;De(()=>{t||(t=!0,e())})}a(nt,"paintFinish");function le(e){let t={};for(let n of e.attributes)if(n.name.startsWith("data-")&&n.name!=="data-component"){let o=n.name.slice(5);try{t[o]=JSON.parse(n.value)}catch{t[o]=n.value}}return t}a(le,"getPropsFromDataAttributes");async function He(){let e=document.querySelector("layout[data-layout]");if(!e)return!1;let t=e.getAttribute("data-layout");if(!t)return!1;try{S||(t="/"+t);let n=await fetch(t);if(!n.ok)throw new Error("Failed to load layout");let o=await n.text(),i=new DOMParser().parseFromString(o,"text/html"),c=document.querySelector("description[data-description]");if(c){let u=i.querySelector('meta[name="description"]');u||(u=i.createElement("meta"),u.name="description",i.head.appendChild(u)),u.content=c.getAttribute("data-description")}let r=document.querySelector("keywords[data-keywords]");if(r){let u=i.querySelector('meta[name="keywords"]');u||(u=i.createElement("meta"),u.name="keywords",i.head.appendChild(u)),u.content=r.getAttribute("data-keywords")}return document.querySelectorAll("[data-part]").forEach(u=>{let f=u.getAttribute("data-part"),p=i.querySelector(`[data-part="${f}"]`);p&&(p.innerHTML="",[...u.childNodes].forEach(y=>{p.appendChild(y.cloneNode(!0))}))}),document.documentElement.innerHTML=i.documentElement.innerHTML,!0}catch(n){return console.error("Failed to inject layout:",n),!1}}a(He,"injectLayout");function q(e,t){if(!t)return;let n=t.trim();if(e[n])return e[n];let o=n[0].toUpperCase()+n.slice(1).toLowerCase();if(e[o])return e[o];let s=n.toUpperCase();if(e[s])return e[s];let i=n.toLowerCase(),c=Object.entries(e).find(([r,d])=>r.toLowerCase()===i);if(c)return c[1]}a(q,"lookupComponent");async function We(e,t){let n=t.trim();for(let[o,s]of Object.entries(e))if(s.loader)try{let i=await s.loader(),c=i.default||Object.values(i)[0];if(typeof c=="function"&&c.name===n)return s._componentName=c.name,s}catch(i){console.warn(`Failed to load route "${o}":`,i);continue}}a(We,"findRouteByComponentName");async function ae(e){var u;let t=e||w.route;await He();let{componentKey:n,componentNme:o,params:s}=ue(t),i=new Set,c=await s._componentNamePromise,r=n,d=document.querySelectorAll("[data-component]");for(let f of d){let p=f.getAttribute("data-component"),y=p==null?void 0:p.toLowerCase();if(typeof rvs_map_sigment<"u"&&rvs_map_sigment!==null?r=q(rvs_map_sigment,p):r=y,!r||i.has(r))continue;let h=q(t,r);h===void 0&&(h=await We(t,r));try{f.hasChildNodes()&&(globalThis.__CURRENT_COMPONENT__=p);let g=h?await Ve(h):await qe(w.loadAtRunTime,r),l=h?{...s,...le(f)}:le(f),m=g.default(l);m.funcName=c.toLowerCase();let b=(u=f.closest("[data-part]"))==null?void 0:u.getAttribute("data-part");m.datapart=b,m.setAttribute("data-component",p),m.hydrate=!0,f.cmpNbr=M,ee(f,m),ce.set(r,M),M++,V=0}catch(g){console.warn(`Component "${y}" failed to load`,g)}}}a(ae,"hydrateComponent");async function Ve(e){if(!L.has(e)){let t=await e.loader();L.set(e,t)}return L.get(e)}a(Ve,"loadModule");async function qe(e,t){let n=q(e,t);if(n){if(L.has(n))return L.get(n);try{let o=await n();return L.set(n,o),o}catch(o){console.error(`Component "${t}" failed to load`,o)}}}a(qe,"loadModuleFromFile");function ot(e,t){if(e===void 0){ae();return}if(typeof e=="object"&&t===void 0){ae(e);return}let n=typeof e=="string"?document.getElementById(e):e;if(!n)throw new Error("Mount target not found: "+e);n.hasChildNodes()?ee(n,t):n.replaceChildren(t)}a(ot,"mount");function ee(e,t){(async()=>{try{if(!e||!t)return;if(t._boundNode=e,e.nodeName!==t.nodeName){e.replaceWith(t);return}if(e.nodeType===Node.TEXT_NODE||e.nodeType===Node.COMMENT_NODE){e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue);return}if(e.nodeType===Node.ELEMENT_NODE&&t.nodeType===Node.ELEMENT_NODE){for(let s of Array.from(t.attributes))e.setAttribute(s.name,s.value);for(let s of Array.from(e.attributes))t.hasAttribute(s.name)||e.removeAttribute(s.name);t._handlers&&t._handlers.forEach(({type:s,val:i})=>{e.addEventListener(s,c=>{w.stopPropagation&&c.stopPropagation(),i(c)})})}let n=Array.from(t.childNodes),o=Array.from(e.childNodes);for(let s=0;s<Math.max(n.length,o.length);s++){let i=o[s],c=n[s];i&&c?ee(i,c):c?e.appendChild(c):i&&e.removeChild(i)}}catch(n){console.error("Hydration failed:",n)}})()}a(ee,"hydrate");export{Ye as IsEmpty,w as MyApp,we as Navigate,Ze as NavigateTo,Ke as Route,Qe as addSigment,Ge as batch,X as createEffect,et as createElement,ze as createGlobalSignal,fe as createSignal,Ie as createTemplate,tt as fetchCache,Be as getGlobalSignal,H as getVirtualElementById,ze as globalSignal,H as gve,se as gvec,U as h,ae as hydrateComponent,Je as loadFunc,ve as loadRunFunc,je as memoizeFunc,ot as mount,De as onPaint,nt as paintFinish,ue as parsePath,ie as rpc,pe as sig,pe as signal,Xe as store,Be as useGlobalSignal};
|
package/package.json
CHANGED