sigment 1.3.2 → 1.3.4

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.
Files changed (2) hide show
  1. package/dist/index.js +4 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var fe=Object.defineProperty;var a=(e,t)=>fe(e,"name",{value:t,configurable:!0});var A={cleanHtml:ye,cleanhtml:!0,setMaxCacheSize:he,maxCacheSize:10,setloadAtRunTime:be,loadAtRunTime:null,setRoute:ge,route:null,setStopPropagation:Ee,stopPropagation:!1},w={funcname:[],dataMap:new Map},D=null,v={},q=new Map,k=new Map,U=new Map,M=new Map,de=null,O=null,W=new Map,pe=null,F="",_=typeof window>"u",P=0;_||(F=window.location.href.replace(/^https?:\/\//,"").replace(/\/$/,""));globalThis.__CURRENT_COMPONENT__=null;var $=0,le=new Map;_&&(globalThis.__HANDLER_REGISTRY__||(globalThis.__HANDLER_REGISTRY__={}),globalThis.__HANDLER_ELEMENT_MAP__||(globalThis.__HANDLER_ELEMENT_MAP__=new Map));var b={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","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","wbr","frame"]};Object.values(b).flat().forEach(e=>{globalThis[e]=(...t)=>N(e,...t)});var z=new Set(b.valueElements),Z=new Set(b.srcElements),Q=new Set(b.hrefElements),G=new Set(b.voidElements);function Pe(e,t){v[e]||(v[e]=we(t))}a(Pe,"createGlobalSignal");function je(e){return v[e]}a(je,"getGlobalSignal");function ee(e,t){w.dataMap.has(e)&&w.dataMap.delete(e),w.dataMap.set(e,t)}a(ee,"addEntry");function H(e){R(H.name);let t=w.dataMap.get(e);if(t)if(typeof t.value.hydrate<"u"&&t.value.hydrate!==null){if(t.value.hydrate){let n=document.getElementById(e);return n||null}}else return t.value;else return null}a(H,"gve");function Fe(e,t,n){let o;if(t instanceof HTMLElement?o=t.outerHTML:typeof t=="object"?o=JSON.stringify(t):o=t.toString(),o.length>4096){console.error("Cookie size exceeds 4KB limit. Data not stored.");return}document.cookie=e+"="+o+"; max-age="+n+" ; path=/ ;",setTimeout(()=>{document.cookie="testCookie=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/;"},n*1e3)}a(Fe,"setCookie");function He(e){let n=`; ${document.cookie}`.split(`; ${e}=`);if(n.length===2){let o=n.pop().split(";").shift();try{let l=JSON.parse(o);return typeof l=="object"&&l!==null&&"nodeType"in l&&l.nodeType===1,l}catch{return o}}return null}a(He,"getCookie");function De(e,t){let n;t instanceof HTMLElement?n=t.outerHTML:typeof t=="object"?n=JSON.stringify(t):n=t.toString(),localStorage.setItem(e,n)}a(De,"setStorage");function Ie(e){let t=localStorage.getItem(e);if(t!==null)try{let n=JSON.parse(t);return typeof n=="object"&&n!==null&&"nodeType"in n&&n.nodeType===1,n}catch{return t}}a(Ie,"getStorage");function J(e,t=void 0){R(J.name),w.createInstance=J.name;let n="";t===void 0?n=e():n=e(t)}a(J,"createInstance");function te(e,t){R(te.name),w.rpc=te.name;let n={};for(let[o,l]of Object.entries(t))e[o]?n[o]=e[o].apply(null,l):(console.error(`Function ${o} not found!`),n[o]=null);return n}a(te,"rpc");function ne(e,t=!1,n){R(ne.name),w.gvec=ne.name;let o=Object.keys(e),l=o[0],i=o[1],d=o[2];var r=e[l];r=r.name;var g=e[i];let f=e[i];var u=H(i)===null;if(u||t===!1){var m=""+i;w.dataMap.delete(m),J(g,e[d])}g=H(i);var p=H(l);if(p===null)throw new Error(` source id '${l} is not found in source component `);if(g===null)throw new Error(` target id '${i} is not found in target component `);if(p.replaceWith(g),n!==void 0)for(let c in f){let s=c.toString();if(typeof n=="object"){for(var y in n)if(s===y){var h=n[y];typeof h=="object"?f[c].apply(null,h):f[c].apply(null,[])}}else if(n.indexOf(",">-1)){let E=n.split(",");for(let C=0;C<E.length;C++)s===E[C]&&f[c].apply(null,[])}else s===n&&f[c].apply(null,[])}}a(ne,"gvec");async function Ne(e,t={}){let{passRestriction:n=[]}=t,o=window.location.pathname.replace(/^\/|\/$/g,"").toLowerCase(),l=e.replace(/^\/|\/$/g,"").toLowerCase();if(!new RegExp("^"+l.replace(/:[^\/]+/g,"[^/]+")+"$").test(o))return!1;let d=Array.isArray(n)?n:[n];for(let r of d)try{let g=typeof r=="function"?r():r;if(g instanceof Promise){if(!await g)return!1}else if(!g)return!1}catch(g){return console.error("Route check failed:",g),!1}return!0}a(Ne,"Route");function qe(e){return e==null||e===""}a(qe,"IsEmpty");function me(e){let t=e.startsWith("/")?e:"/"+e;window.history.pushState({},"",t)}a(me,"Navigate");function he(e){A.maxCacheSize=e}a(he,"setMaxCacheSize");function ye(e){A.cleanhtml=e}a(ye,"cleanHtml");function ge(e){A.route=e}a(ge,"setRoute");function be(e){A.loadAtRunTime=e}a(be,"setloadAtRunTime");function Ee(e){A.stopPropagation=e}a(Ee,"setStopPropagation");async function Ve(e,t){let n;t==="/"?n=t:n=t.replace(/\//g,"").toLowerCase();let o=Object.keys(e).find(l=>l.toLowerCase()===n.toLowerCase());if(!o){let l=Object.keys(e).join(", ");throw new Error(`Unknown component: "${t}".
1
+ var fe=Object.defineProperty;var u=(e,t)=>fe(e,"name",{value:t,configurable:!0});var A={cleanHtml:ye,cleanhtml:!0,setMaxCacheSize:he,maxCacheSize:10,setloadAtRunTime:ge,loadAtRunTime:null,setRoute:be,route:null,setStopPropagation:Ee,stopPropagation:!1},w={funcname:[],dataMap:new Map},N=null,v={},I=new Map,k=new Map,U=new Map,M=new Map,de=null,O=null,W=new Map,pe=null,j="",_=typeof window>"u",$=0;_||(j=window.location.href.replace(/^https?:\/\//,"").replace(/\/$/,""));globalThis.__CURRENT_COMPONENT__=null;var P=0,le=new Map;_&&(globalThis.__HANDLER_REGISTRY__||(globalThis.__HANDLER_REGISTRY__={}),globalThis.__HANDLER_ELEMENT_MAP__||(globalThis.__HANDLER_ELEMENT_MAP__=new Map));var g={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","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","wbr","frame"]};Object.values(g).flat().forEach(e=>{globalThis[e]||(globalThis[e]=(...t)=>V(e,...t),Object.defineProperty(globalThis,e,{writable:!1,configurable:!1}))});var z=new Set(g.valueElements),Z=new Set(g.srcElements),Q=new Set(g.hrefElements),G=new Set(g.voidElements);function $e(e,t){v[e]||(v[e]=we(t))}u($e,"createGlobalSignal");function He(e){return v[e]}u(He,"getGlobalSignal");function ee(e,t){w.dataMap.has(e)&&w.dataMap.delete(e),w.dataMap.set(e,t)}u(ee,"addEntry");function F(e){R(F.name);let t=w.dataMap.get(e);if(t)if(typeof t.value.hydrate<"u"&&t.value.hydrate!==null){if(t.value.hydrate){let n=document.getElementById(e);return n||null}}else return t.value;else return null}u(F,"gve");function je(e,t,n){let o;if(t instanceof HTMLElement?o=t.outerHTML:typeof t=="object"?o=JSON.stringify(t):o=t.toString(),o.length>4096){console.error("Cookie size exceeds 4KB limit. Data not stored.");return}document.cookie=e+"="+o+"; max-age="+n+" ; path=/ ;",setTimeout(()=>{document.cookie="testCookie=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/;"},n*1e3)}u(je,"setCookie");function Fe(e){let n=`; ${document.cookie}`.split(`; ${e}=`);if(n.length===2){let o=n.pop().split(";").shift();try{let l=JSON.parse(o);return typeof l=="object"&&l!==null&&"nodeType"in l&&l.nodeType===1,l}catch{return o}}return null}u(Fe,"getCookie");function Ne(e,t){let n;t instanceof HTMLElement?n=t.outerHTML:typeof t=="object"?n=JSON.stringify(t):n=t.toString(),localStorage.setItem(e,n)}u(Ne,"setStorage");function De(e){let t=localStorage.getItem(e);if(t!==null)try{let n=JSON.parse(t);return typeof n=="object"&&n!==null&&"nodeType"in n&&n.nodeType===1,n}catch{return t}}u(De,"getStorage");function J(e,t=void 0){R(J.name),w.createInstance=J.name;let n="";t===void 0?n=e():n=e(t)}u(J,"createInstance");function te(e,t){R(te.name),w.rpc=te.name;let n={};for(let[o,l]of Object.entries(t))e[o]?n[o]=e[o].apply(null,l):(console.error(`Function ${o} not found!`),n[o]=null);return n}u(te,"rpc");function ne(e,t=!1,n){R(ne.name),w.gvec=ne.name;let o=Object.keys(e),l=o[0],i=o[1],s=o[2];var r=e[l];r=r.name;var y=e[i];let c=e[i];var d=F(i)===null;if(d||t===!1){var m=""+i;w.dataMap.delete(m),J(y,e[s])}y=F(i);var p=F(l);if(p===null)throw new Error(` source id '${l} is not found in source component `);if(y===null)throw new Error(` target id '${i} is not found in target component `);if(p.replaceWith(y),n!==void 0)for(let a in c){let f=a.toString();if(typeof n=="object"){for(var b in n)if(f===b){var h=n[b];typeof h=="object"?c[a].apply(null,h):c[a].apply(null,[])}}else if(n.indexOf(",">-1)){let E=n.split(",");for(let C=0;C<E.length;C++)f===E[C]&&c[a].apply(null,[])}else f===n&&c[a].apply(null,[])}}u(ne,"gvec");async function Ve(e,t={}){let{passRestriction:n=[]}=t,o=window.location.pathname.replace(/^\/|\/$/g,"").toLowerCase(),l=e.replace(/^\/|\/$/g,"").toLowerCase();if(!new RegExp("^"+l.replace(/:[^\/]+/g,"[^/]+")+"$").test(o))return!1;let s=Array.isArray(n)?n:[n];for(let r of s)try{let y=typeof r=="function"?r():r;if(y instanceof Promise){if(!await y)return!1}else if(!y)return!1}catch(y){return console.error("Route check failed:",y),!1}return!0}u(Ve,"Route");function Ie(e){return e==null||e===""}u(Ie,"IsEmpty");function me(e){let t=e.startsWith("/")?e:"/"+e;window.history.pushState({},"",t)}u(me,"Navigate");function he(e){A.maxCacheSize=e}u(he,"setMaxCacheSize");function ye(e){A.cleanhtml=e}u(ye,"cleanHtml");function be(e){A.route=e}u(be,"setRoute");function ge(e){A.loadAtRunTime=e}u(ge,"setloadAtRunTime");function Ee(e){A.stopPropagation=e}u(Ee,"setStopPropagation");async function qe(e,t){let n;t==="/"?n=t:n=t.replace(/\//g,"").toLowerCase();let o=Object.keys(e).find(l=>l.toLowerCase()===n.toLowerCase());if(!o){let l=Object.keys(e).join(", ");throw new Error(`Unknown component: "${t}".
2
2
  Available components: ${l}
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(k.has(o))return k.get(o);try{let i=(await e[o]()).default;return k.set(o,i),i}catch(l){throw new Error(`Failed to load component "${o}": ${l.message}`)}}a(Ve,"loadFunc");function Ae(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 l=o.closest("[data-part]");if(t=l==null?void 0:l.getAttribute("data-part"),l){let i=o.getAttribute("data-component");i&&l.querySelectorAll(`[data-component="${i}"]`).forEach((r,g)=>{r===o&&(n=g)})}}return{partName:t,index:n}}a(Ae,"getTargetPartAndIndex");async function Ue(e,t,n,o,l=null){if(_)return;let i=null,{partName:d,index:r}=Ae(l);d&&(i=d);let g=window.location.host+"/"+e;if(i===null){if(F===g)return;F=g}let f;typeof t=="boolean"||typeof t=="string"?(n=t,t=A.route):t===void 0&&(t=A.route,n=!1),me(e);let{componentKey:u,params:m}=ie(t);(u===void 0||u==="")&&console.warn(`current path "${e}" not match in route map file , check if param path is match`);let p=Object.keys(t);if(typeof n=="string")u=n,f=!!o;else if(typeof n=="boolean"){if(p.length===1)u=p[0];else if(p.includes(u))u=u;else throw new Error(`Ambiguous component map: multiple components exist and no matching key for path '${e}' found. Provide component key explicitly.`);f=n}else{if(p.length===1)u=p[0];else if(p.includes(u))u=u;else throw new Error(`Ambiguous component map: multiple components exist and no matching key for path '${e}' found. Provide component key explicitly.`);f=!1}let y=await Ce(t,u,m,null,!1);i&&(e=e+i+r);let h=W.get(e);if((!h||!f)&&(typeof y=="function"?($=le.get(y.name),P=0,Array.isArray(m)?h=y(...m):typeof m=="object"&&m!==null?h=y(m):h=y(),W.set(e,h)):h=y),O&&O.isConnected){var c=O.contains(h);c||O.replaceWith(h)}else{typeof rvs_map_sigment<"u"&&rvs_map_sigment!==null&&(u=I(rvs_map_sigment,u));let s=document.querySelectorAll('[data-part="'+i+'"] [data-component="'+u+'"]');h.setAttribute("data-component",u),s&&s.length===1?s[0].replaceWith(h):s&&s.length>1?s[r].replaceWith(h):document.body.replaceChildren(h)}i===null&&(O=h,de=e),F=g}a(Ue,"NavigateTo");function We(e=pe,t){let n=typeof e=="string"?document.getElementById(e):e;n.contains(t)||n.replaceChildren(t)}a(We,"updateNodeIfNeeded");function ze(e){if(e){let t=e.toLowerCase(),n=!1;for(let o of k.keys())o.toLowerCase()===t&&(k.delete(o),n=!0);return n}else return k.clear(),!0}a(ze,"clearComponentCache");function ie(e){if(_)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={},l=null,i=null,d=0;function r(f){return f.length>1&&f.endsWith("/")&&(f=f.slice(0,-1)),f.replace(/^\//,"").split("/").map(u=>{let m=u.startsWith(":"),p=m&&u.endsWith("?"),y=m?u.slice(1).replace("?",""):u;return y===""&&(y="/"),{isParam:m,isOptional:p,name:y}})}a(r,"parseRouteSegments");for(let[f,u]of Object.entries(e)){let m=u.path||`/${f}`,p=r(m),y=!0;for(let h=0;h<p.length;h++){let c=p[h],s=n[h];if(c.isParam){if(!s&&!c.isOptional){y=!1;break}}else if(c.name!==s){y=!1;break}}if(n.length<p.length){for(let h=n.length;h<p.length;h++)if(!p[h].isOptional){y=!1;break}}if(y){l=f,i=u,d=p.length,p.forEach((h,c)=>{if(h.isParam){let s=n[c];s!==void 0&&s!==""&&(o[h.name]=s)}});break}}return l||(l="",i=e[l]),i!=null&&i.urlParam&&i.urlParam.split("/").map(u=>u.replace(/[{}]/g,"")).forEach((u,m)=>{let p=n[d+m];p!==void 0&&p!==""&&(o[u]=p)}),new URL(window.location.href).searchParams.forEach((f,u)=>{o[u]=f}),{componentKey:l,componentName:l,params:o}}a(ie,"parsePath");function j(e){return new DOMParser().parseFromString(e,"text/html").body.firstChild}a(j,"parseHTML");async function Ce(e,t,n=null,o=null,l=!0){if(_)return;let i=e[t.toLowerCase()];if(i||(typeof e.fallback=="string"?i=e[e.fallback]:i=e.fallback),!i)return j("<h1>404 - Component not found</h1>");let{loader:d,guard:r,cacheExpiration:g=null,...f}=i;if(o===null&&typeof i.logic=="function"&&(o=i.logic),typeof r=="function"&&!await r(n))return j("<h1>403 - Forbidden</h1><p>You do not have access to this page.</p>");for(let u in f){let m=f[u];if(typeof m=="function")try{await m()}catch(p){console.error(p)}}try{let u=Date.now(),m=k.get(t);m&&g!==null&&u-m.cachedAt>g&&(k.delete(t),m=null);let p;if(m)p=m.component,k.set(t,{component:p,cachedAt:u});else{if(p=(await d()).default,k.size>=A.maxCacheSize){let s=k.keys().next().value;k.delete(s)}k.set(t,{component:p,cachedAt:u})}if(typeof p!="function")return j("<h1>Invalid component</h1>");if(!l)return p;let y;Array.isArray(n)?y=p(...n):typeof n=="object"&&n!==null?y=p(n):y=p();let h="/";try{h=window.location.pathname.slice(1)+window.location.hash,h=h.endsWith("/")&&h!=="/"?h.slice(0,-1):h,h===""&&(h="/")}catch{h=t}return W.set(h,y),O=y,y}catch(u){return console.error(u),j("<h1>Error loading component</h1>")}}a(Ce,"loadRunFunc");function K(e=""){var l,i;if(_)return"";R(K.name),w.buildRoadMap=K.name;var t="";let n=(l=new Error().stack)==null?void 0:l.toString();navigator.userAgent.toLowerCase().indexOf("firefox")>0?n=n.split("@"):n=n.split(`
10
- `);for(let d=0;d<n.length;d++){var o="";if(navigator.userAgent.indexOf("Firefox")>0){let r=n[d].lastIndexOf(`
11
- `);if(r===-1)continue;o=n[d].slice(r+1),o===""?(r=n[d].lastIndexOf("/")+1,r>-1&&(o=n[d].substr(r),o=o.substr(0,o.indexOf(".")))):o.indexOf("/")>-1&&(o=o.substr(0,o.indexOf("/")))}else o=(i=n[d])==null?void 0:i.trim().split(" ")[1];if(!w.funcname.includes(o)&&!(o===void 0||o==="")&&!(o.indexOf("http://")>-1||o.indexOf("https://")>-1)){if(w.gvec!==void 0&&o.indexOf(w.gvec)>-1)break;t.indexOf("|"+o)>-1||(t+="|"+o.replace(".","|"))}}return e+t}a(K,"buildRoadMap");function R(e){!w.funcname.includes(e)&&w.funcname.push(e)}a(R,"setFuncName");function we(e){let t=e,n=new Set;function o(){return D&&n.add(D),t}a(o,"get");function l(i,d=!1){(d||t!==i)&&(t=i,n.forEach(r=>r()))}return a(l,"set"),[o,l]}a(we,"createSignal");function B(e){function t(){D=t,e(),D=null}a(t,"wrapped"),t()}a(B,"createEffect");function Te(e){e=e.toLowerCase(),b.innerHTMLElements.includes(e)||(b.innerHTMLElements.push(e),globalThis[e]=(...t)=>N(e,...t))}a(Te,"createTypeElement");function se(e){return e.replace(/-+/g,"-").replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}a(se,"dashToCamel");function Ge(e,t=null){ae(e,t)}a(Ge,"createSigment");function Je(e,t=null){ae(e,t)}a(Je,"addSigment");function Ke(e,...t){if(Te(e),t.length!==0)return globalThis[e](...t)}a(Ke,"createElement");function ke(e){let t=document.createTextNode("");return B(()=>{if(typeof v!="object"||v===null){t.nodeValue=e;return}let n=e.replace(/{{(.*?)}}/g,(o,l)=>{let i=l.trim();if(v.hasOwnProperty(i)){let d=v[i];if(d&&typeof d[0]=="function")return d[0]()??""}return""});t.nodeValue=n}),t}a(ke,"interpolateReactiveText");function Be(e,t=5e3,n={}){let o=JSON.stringify([e,n,t]);if(!q.has(o)){let l=Se(async()=>{let i=await fetch(e,n);if(!i.ok)throw new Error(`Fetch failed: ${i.status}`);return i.json()},t);q.set(o,l)}return q.get(o)()}a(Be,"fetchCache");function Y(e){if(Array.isArray(e))return e.map(Y);if(e&&typeof e=="object"){let t={};return Object.keys(e).sort().forEach(n=>{t[n]=Y(e[n])}),t}return e}a(Y,"sortObjectDeep");function _e(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(_e,"sortObjectShallow");function Se(e,t=null,n={}){let o=new Map,l=a((...i)=>{let{deepSort:d}=n,r;d===!0?r=i.map(y=>y&&typeof y=="object"?Y(y):y):d===!1?r=i.map(y=>y&&typeof y=="object"?_e(y):y):r=i;let g=JSON.stringify(r),f=Date.now();g.length===2&&(g=e.name);let m=o.get(g);if(m&&(t===null||f-m.timestamp<t))return m.value;let p=e(...i);return o.set(g,{value:p,timestamp:f}),p instanceof Promise&&p.catch(()=>o.delete(g)),p},"wrapped");return l.clear=()=>o.clear(),l}a(Se,"memoizeFunc");function xe(e,t,n){let l=document.querySelectorAll("[data-component]")[n];return!l||l.getAttribute("data-component")!==e?null:[l,...l.querySelectorAll("*")][t]||null}a(xe,"getSsrElementByIndex");function V(e){let t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};return e.replace(/[&<>"']/g,n=>t[n])}a(V,"escapeHtml");function N(e,...t){var h;let n={},o=[];if(t[0]&&typeof t[0]=="object"&&!Array.isArray(t[0])&&t[0]!==null&&!(t[0]instanceof String)&&(_||!(t[0]instanceof Node))?(n=t[0],o=t.slice(1)):o=t,_&&typeof document>"u"){let c=globalThis.__CURRENT_COMPONENT__;globalThis.__HANDLER_REGISTRY__||(globalThis.__HANDLER_REGISTRY__={}),(h=globalThis.__HANDLER_REGISTRY__)[c]||(h[c]=[]);let s=[];for(let[T,L]of Object.entries(n))if(T==="style"&&typeof L=="object"){let x=Object.entries(L).map(([ce,ue])=>`${ce.replace(/([A-Z])/g,"-$1").toLowerCase()}:${ue}`).join(";");s.push(` style="${V(x)}"`)}else T!=="className"&&T!=="class"&&!T.startsWith("on")&&s.push(` ${T}="${V(String(L))}"`);(n.className||n.class)&&s.push(` class="${V(n.className||n.class)}"`);let E=o.map(T=>typeof T=="function"?T():T??"").join("");if(["input","img","br","hr","meta","link"].includes(e))return`<${e}${s.join("")} />`;if(e==="fragment")return E;var l;let S=U.get(e);return S&&(l=S.tagName,S.nativeTag!==null&&(l=S.nativeTag)),l!==void 0&&(e=l),`<${e}${s.join("")}>${E}</${e}>`}R(N.name);var i="";i=K();var d=i.split("|");if(d.includes(w.rpc))return;let r=null,g=e.toLowerCase()==="fragment";if(g)r=document.createDocumentFragment();else{var l;let s=U.get(e);s&&(l=s.tagName,s.nativeTag!==null&&(l=s.nativeTag)),l!==void 0&&(e=l),r=document.createElement(e)}if(globalThis.__CURRENT_COMPONENT__){P++;let c=P;r.dataIndex=c,r.realtedComponent=globalThis.__CURRENT_COMPONENT__,r.cmpNbr=$}let f=[];for(let[c,s]of Object.entries(n))if(c.startsWith("on")&&typeof s=="function"){let E=c.slice(2).toLowerCase();f.push({type:E,val:s})}f.length&&(r._handlers=f);let u=G.has(e),m=z.has(se(e)),p=e==="input"||e==="option",y=e==="option";if(!g)for(let c in n){let s=n[c];if(c.startsWith("on")&&typeof s=="function"){let E=c.slice(2).toLowerCase();r.addEventListener(E,C=>{A.stopPropagation&&C.stopPropagation(),s(C)})}else typeof s=="function"&&c!=="children"?B(()=>{let E=s();E==null||E===!1?(r.removeAttribute(c),c==="value"&&m&&(r.value="",A.cleanhtml||r.removeAttribute("value")),c==="checked"&&p&&(r.checked=!1,A.cleanhtml||r.removeAttribute("checked")),c==="selected"&&y&&(r.selected=!1,A.cleanhtml||r.removeAttribute("selected")),c==="id"&&(r.iid="",A.cleanhtml||r.removeAttribute("id"))):c==="id"?(r.iid=E,A.cleanhtml?r.removeAttribute("id"):r.setAttribute("id",E),ee(E,{name:E,caller:E+i,value:r})):c==="value"&&m?(r.value=E,A.cleanhtml?r.removeAttribute("value"):r.setAttribute("value",E)):c==="checked"&&p?(r.checked=E,A.cleanhtml?r.removeAttribute("checked"):E?r.setAttribute("checked",""):r.removeAttribute("checked")):c==="selected"&&y?(r.selected=E,A.cleanhtml?r.removeAttribute("selected"):E?r.setAttribute("selected",""):r.removeAttribute("selected")):r.setAttribute(c,E)}):s!=null&&s!==!1&&(c==="id"?(r.iid=s,A.cleanhtml?r.removeAttribute("id"):r.setAttribute("id",s),ee(s,{name:s,caller:s+i,value:r})):c==="value"&&m?(r.value=s,A.cleanhtml?r.removeAttribute("value"):r.setAttribute("value",s)):c==="checked"&&p?(r.checked=s,A.cleanhtml?r.removeAttribute("checked"):r.setAttribute("checked","")):c==="selected"&&y?(r.selected=s,A.cleanhtml?r.removeAttribute("selected"):r.setAttribute("selected","")):r.setAttribute(c,s))}return u?o.length===1&&(typeof o[0]=="string"||typeof o[0]=="number")?m&&(r.value=o[0],A.cleanhtml?r.removeAttribute("value"):r.setAttribute("value",o[0])):o.length>0&&console.warn(`Void element <${e}> should not have children.`):o.flat().forEach(c=>{if(typeof c=="function"){let s=document.createTextNode("");r.appendChild(s),B(()=>{let E=c();if(E instanceof Node){let C=s.parentNode;if(!C)return;C.nodeType===Node.DOCUMENT_FRAGMENT_NODE?C.replaceChildren(E):C.replaceChild(E,s),s=E}else{let C=E==null?"":String(E);if(s.nodeValue!==C){let S=s.parentNode;if(S.realtedComponent){let T=null,L=xe(S.realtedComponent,S.dataset.index,S.cmpNbr);if(L&&(T=L),T!==null){let x=T;x=T.childNodes[0].firstChild,x===null&&(x=T.firstChild),x.nodeType===Node.TEXT_NODE&&(x.nodeValue=C)}}else s.nodeValue=C}}})}else if(typeof c=="string"&&c.includes("{{")&&!c.includes("function"))r.appendChild(ke(c));else if(typeof c=="string"||typeof c=="number"){if(c.includes("function get(")||c.includes("function (")||c.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(c))}else(c instanceof DocumentFragment||c instanceof Node)&&r.appendChild(c)}),r}a(N,"h");function ve(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/-+/g,"-").toLowerCase()}a(ve,"camelToDash");function ae(e,t=null){if(b.innerHTMLElements.includes(e)||b.valueElements.includes(e)||b.srcElements.includes(e)||b.hrefElements.includes(e)||b.voidElements.includes(e))return;let o=/[A-Z]/.test(e)?ve(e):e.toLowerCase();o.includes("-")||(o="s-"+o),e.includes("-")&&(o=e,e=se(e)),U.set(e,{tagName:o,nativeTag:t}),!b.innerHTMLElements.includes(e)&&t===null?b.innerHTMLElements.push(e):!b.innerHTMLElements.includes(e)&&t!==null&&(b.innerHTMLElements.includes(t)||b.innerHTMLElements.push(e)),!b.valueElements.includes(e)&&t===null?(b.valueElements.push(e),z.add(e)):!b.valueElements.includes(e)&&t!==null&&(b.valueElements.includes(t)||(b.valueElements.push(e),z.add(e))),!b.srcElements.includes(e)&&t===null?(b.srcElements.push(e),Z.add(e)):!b.srcElements.includes(e)&&t!==null&&(b.srcElements.includes(t)||(b.srcElements.push(e),Z.add(e))),!b.hrefElements.includes(e)&&t===null?(b.hrefElements.push(e),Q.add(e)):!b.hrefElements.includes(e)&&t!==null&&(b.hrefElements.includes(t)||(b.hrefElements.push(e),Q.add(e))),!b.voidElements.includes(e)&&t===null?(b.voidElements.push(e),G.add(e)):!b.voidElements.includes(e)&&t!==null&&(b.voidElements.includes(t)||(b.voidElements.push(e),G.add(e))),globalThis[e]=(...l)=>N(e,...l)}a(ae,"defineElement");function Le(e){_||requestAnimationFrame(()=>{requestAnimationFrame(e)})}a(Le,"onPaint");function Ye(e){if(_)return;let t=!1;Le(()=>{t||(t=!0,e())})}a(Ye,"paintFinish");function oe(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(oe,"getPropsFromDataAttributes");async function Oe(){let e=document.querySelector("layout[data-layout]");if(!e)return!1;let t=e.getAttribute("data-layout");if(!t)return!1;try{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"),d=document.querySelector("description[data-description]");if(d){let f=i.querySelector('meta[name="description"]');f||(f=i.createElement("meta"),f.name="description",i.head.appendChild(f)),f.content=d.getAttribute("data-description")}let r=document.querySelector("keywords[data-keywords]");if(r){let f=i.querySelector('meta[name="keywords"]');f||(f=i.createElement("meta"),f.name="keywords",i.head.appendChild(f)),f.content=r.getAttribute("data-keywords")}return document.querySelectorAll("[data-part]").forEach(f=>{let u=f.getAttribute("data-part"),m=i.querySelector(`[data-part="${u}"]`);m&&(m.innerHTML="",[...f.childNodes].forEach(p=>{m.appendChild(p.cloneNode(!0))}))}),document.documentElement.innerHTML=i.documentElement.innerHTML,!0}catch(n){return console.error("Failed to inject layout:",n),!1}}a(Oe,"injectLayout");function I(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 l=n.toUpperCase();if(e[l])return e[l];let i=n.toLowerCase(),d=Object.entries(e).find(([r,g])=>r.toLowerCase()===i);if(d)return d[1]}a(I,"lookupComponent");async function re(e){var f;let t=e||A.route,n=await Oe(),{componentKey:o,componentName:l,params:i}=ie(t),d=new Set,r=l,g=document.querySelectorAll("[data-component]");for(let u of g){let m=u.getAttribute("data-component"),p=m==null?void 0:m.toLowerCase();if(typeof rvs_map_sigment<"u"&&rvs_map_sigment!==null?r=I(rvs_map_sigment,m):r=p,!r||d.has(r))continue;let y=I(t,r);try{u.hasChildNodes()&&(globalThis.__CURRENT_COMPONENT__=m);let h=y?await Me(y):await Re(A.loadAtRunTime,r),c=y?{...i,...oe(u)}:oe(u),s=h.default(c);s.funcName=l.toLowerCase();let E=(f=u.closest("[data-part]"))==null?void 0:f.getAttribute("data-part");s.datapart=E,s.setAttribute("data-component",m),s.hydrate=!0,u.cmpNbr=$,X(u,s),le.set(r,$),$++,P=0}catch(h){console.warn(`Component "${p}" failed to load`,h)}}}a(re,"hydrateComponent");async function Me(e){if(!M.has(e)){let t=await e.loader();M.set(e,t)}return M.get(e)}a(Me,"loadModule");async function Re(e,t){let n=I(e,t);if(n){if(M.has(n))return M.get(n);try{let o=await n();return M.set(n,o),o}catch(o){console.error(`Component "${t}" failed to load`,o)}}}a(Re,"loadModuleFromFile");function Xe(e,t){if(e===void 0){re();return}if(typeof e=="object"&&t===void 0){re(e);return}let n=typeof e=="string"?document.getElementById(e):e;if(!n)throw new Error("Mount target not found: "+e);n.hasChildNodes()?X(n,t):n.replaceChildren(t)}a(Xe,"mount");function X(e,t){if(e.hasChildNodes()){let l=[t,...t.querySelectorAll("*")],i=[e,...e.querySelectorAll("*")];l.forEach((d,r)=>{let g=i[r];if(g){d.dataset.index=r;for(let f of d.getAttributeNames()){let u=d.getAttribute(f);if(g.getAttribute(f)!==u){if(f==="data-component"||f==="data-index")continue;g.setAttribute(f,u)}}d.nodeType===Node.TEXT_NODE&&d.nodeValue!==g.nodeValue&&(g.nodeValue=d.nodeValue),d._handlers&&d._handlers.forEach(({type:f,val:u})=>{g.addEventListener(f,m=>{A.stopPropagation&&m.stopPropagation(),u(m)})})}}),globalThis.__CURRENT_COMPONENT__=null,P=0;return}if(!t||e.nodeName!==t.nodeName){e.replaceWith(t);return}if(t.nodeType===Node.TEXT_NODE){e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue);return}if(e.nodeType===Node.ELEMENT_NODE&&t.nodeType===Node.ELEMENT_NODE){for(let l of Array.from(t.attributes))e.setAttribute(l.name,l.value);if(t._handlers)for(let{type:l,val:i}of t._handlers)e.addEventListener(l,d=>{A.stopPropagation&&d.stopPropagation(),i(d)});e instanceof HTMLInputElement?(e.value!==t.value&&(e.value=t.value),["checkbox","radio"].includes(e.type)&&e.checked!==t.checked&&(e.checked=t.checked)):e instanceof HTMLTextAreaElement?e.value!==t.value&&(e.value=t.value):e instanceof HTMLSelectElement&&e.value!==t.value&&(e.value=t.value);for(let l of Array.from(e.attributes))t.hasAttribute(l.name)||e.removeAttribute(l.name)}let n=Array.from(t.childNodes),o=Array.from(e.childNodes);for(let l=0;l<Math.max(n.length,o.length);l++){let i=o[l],d=n[l];i&&d?X(i,d):d?e.appendChild(d):i&&e.removeChild(i)}}a(X,"hydrate");export{qe as IsEmpty,A as MyApp,me as Navigate,Ue as NavigateTo,Ne as Route,Je as addSigment,ze as clearComponentCache,B as createEffect,Ke as createElement,Pe as createGlobalSignal,Ge as createSigment,we as createSignal,Be as fetchCache,He as getCookie,je as getGlobalSignal,Ie as getStorage,H as getVirtualElementById,Pe as globalSignal,H as gve,ne as gvec,N as h,re as hydrateComponent,Ve as loadFunc,Ce as loadRunFunc,Se as memoizeFunc,Xe as mount,Le as onPaint,Ye as paintFinish,ie as parsePath,te as rpc,Fe as setCookie,De as setStorage,we as signal,We as updateNodeIfNeeded,je as useGlobalSignal};
9
+ };`)}if(k.has(o))return k.get(o);try{let i=(await e[o]()).default;return k.set(o,i),i}catch(l){throw new Error(`Failed to load component "${o}": ${l.message}`)}}u(qe,"loadFunc");function Ae(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 l=o.closest("[data-part]");if(t=l==null?void 0:l.getAttribute("data-part"),l){let i=o.getAttribute("data-component");i&&l.querySelectorAll(`[data-component="${i}"]`).forEach((r,y)=>{r===o&&(n=y)})}}return{partName:t,index:n}}u(Ae,"getTargetPartAndIndex");async function Ue(e,t,n,o,l=null){if(_)return;let i=null,{partName:s,index:r}=Ae(l);s&&(i=s);let y=window.location.host+"/"+e;if(i===null){if(j===y)return;j=y}let c;typeof t=="boolean"||typeof t=="string"?(n=t,t=A.route):t===void 0&&(t=A.route,n=!1),me(e);let{componentKey:d,params:m}=ie(t);(d===void 0||d==="")&&console.warn(`current path "${e}" not match in route map file , check if param path is match`);let p=Object.keys(t);if(typeof n=="string")d=n,c=!!o;else if(typeof n=="boolean"){if(p.length===1)d=p[0];else if(p.includes(d))d=d;else throw new Error(`Ambiguous component map: multiple components exist and no matching key for path '${e}' found. Provide component key explicitly.`);c=n}else{if(p.length===1)d=p[0];else if(p.includes(d))d=d;else throw new Error(`Ambiguous component map: multiple components exist and no matching key for path '${e}' found. Provide component key explicitly.`);c=!1}let b=await Ce(t,d,m,null,!1);i&&(e=e+i+r);let h=W.get(e);if((!h||!c)&&(typeof b=="function"?(P=le.get(b.name),$=0,Array.isArray(m)?h=b(...m):typeof m=="object"&&m!==null?h=b(m):h=b(),W.set(e,h)):h=b),O&&O.isConnected){var a=O.contains(h);a||O.replaceWith(h)}else{typeof rvs_map_sigment<"u"&&rvs_map_sigment!==null&&(d=D(rvs_map_sigment,d));let f=document.querySelectorAll('[data-part="'+i+'"] [data-component="'+d+'"]');h.setAttribute("data-component",d),f&&f.length===1?f[0].replaceWith(h):f&&f.length>1?f[r].replaceWith(h):document.body.replaceChildren(h)}i===null&&(O=h,de=e),j=y}u(Ue,"NavigateTo");function We(e=pe,t){let n=typeof e=="string"?document.getElementById(e):e;n.contains(t)||n.replaceChildren(t)}u(We,"updateNodeIfNeeded");function ze(e){if(e){let t=e.toLowerCase(),n=!1;for(let o of k.keys())o.toLowerCase()===t&&(k.delete(o),n=!0);return n}else return k.clear(),!0}u(ze,"clearComponentCache");function ie(e){if(_)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={},l=null,i=null,s=0;function r(c){return c.length>1&&c.endsWith("/")&&(c=c.slice(0,-1)),c.replace(/^\//,"").split("/").map(d=>{let m=d.startsWith(":"),p=m&&d.endsWith("?"),b=m?d.slice(1).replace("?",""):d;return b===""&&(b="/"),{isParam:m,isOptional:p,name:b}})}u(r,"parseRouteSegments");for(let[c,d]of Object.entries(e)){let m=d.path||`/${c}`,p=r(m),b=!0;for(let h=0;h<p.length;h++){let a=p[h],f=n[h];if(a.isParam){if(!f&&!a.isOptional){b=!1;break}}else if(a.name!==f){b=!1;break}}if(n.length<p.length){for(let h=n.length;h<p.length;h++)if(!p[h].isOptional){b=!1;break}}if(b){l=c,i=d,s=p.length,p.forEach((h,a)=>{if(h.isParam){let f=n[a];f!==void 0&&f!==""&&(o[h.name]=f)}});break}}return l||(l="",i=e[l]),i!=null&&i.urlParam&&i.urlParam.split("/").map(d=>d.replace(/[{}]/g,"")).forEach((d,m)=>{let p=n[s+m];p!==void 0&&p!==""&&(o[d]=p)}),new URL(window.location.href).searchParams.forEach((c,d)=>{o[d]=c}),{componentKey:l,componentName:l,params:o}}u(ie,"parsePath");function H(e){return new DOMParser().parseFromString(e,"text/html").body.firstChild}u(H,"parseHTML");async function Ce(e,t,n=null,o=null,l=!0){if(_)return;let i=e[t.toLowerCase()];if(i||(typeof e.fallback=="string"?i=e[e.fallback]:i=e.fallback),!i)return H("<h1>404 - Component not found</h1>");let{loader:s,guard:r,cacheExpiration:y=null,...c}=i;if(o===null&&typeof i.logic=="function"&&(o=i.logic),typeof r=="function"&&!await r(n))return H("<h1>403 - Forbidden</h1><p>You do not have access to this page.</p>");for(let d in c){let m=c[d];if(typeof m=="function")try{await m()}catch(p){console.error(p)}}try{let d=Date.now(),m=k.get(t);m&&y!==null&&d-m.cachedAt>y&&(k.delete(t),m=null);let p;if(m)p=m.component,k.set(t,{component:p,cachedAt:d});else{if(p=(await s()).default,k.size>=A.maxCacheSize){let f=k.keys().next().value;k.delete(f)}k.set(t,{component:p,cachedAt:d})}if(typeof p!="function")return H("<h1>Invalid component</h1>");if(!l)return p;let b;Array.isArray(n)?b=p(...n):typeof n=="object"&&n!==null?b=p(n):b=p();let h="/";try{h=window.location.pathname.slice(1)+window.location.hash,h=h.endsWith("/")&&h!=="/"?h.slice(0,-1):h,h===""&&(h="/")}catch{h=t}return W.set(h,b),O=b,b}catch(d){return console.error(d),H("<h1>Error loading component</h1>")}}u(Ce,"loadRunFunc");function K(e=""){var l,i;if(_)return"";R(K.name),w.buildRoadMap=K.name;var t="";let n=(l=new Error().stack)==null?void 0:l.toString();navigator.userAgent.toLowerCase().indexOf("firefox")>0?n=n.split("@"):n=n.split(`
10
+ `);for(let s=0;s<n.length;s++){var o="";if(navigator.userAgent.indexOf("Firefox")>0){let r=n[s].lastIndexOf(`
11
+ `);if(r===-1)continue;o=n[s].slice(r+1),o===""?(r=n[s].lastIndexOf("/")+1,r>-1&&(o=n[s].substr(r),o=o.substr(0,o.indexOf(".")))):o.indexOf("/")>-1&&(o=o.substr(0,o.indexOf("/")))}else o=(i=n[s])==null?void 0:i.trim().split(" ")[1];if(!w.funcname.includes(o)&&!(o===void 0||o==="")&&!(o.indexOf("http://")>-1||o.indexOf("https://")>-1)){if(w.gvec!==void 0&&o.indexOf(w.gvec)>-1)break;t.indexOf("|"+o)>-1||(t+="|"+o.replace(".","|"))}}return e+t}u(K,"buildRoadMap");function R(e){!w.funcname.includes(e)&&w.funcname.push(e)}u(R,"setFuncName");function we(e){let t=e,n=new Set;function o(){return N&&n.add(N),t}u(o,"get");function l(i,s=!1){(s||t!==i)&&(t=i,n.forEach(r=>r()))}return u(l,"set"),[o,l]}u(we,"createSignal");function B(e){function t(){N=t,e(),N=null}u(t,"wrapped"),t()}u(B,"createEffect");function Te(e){e=e.toLowerCase(),g.innerHTMLElements.includes(e)||(g.innerHTMLElements.push(e),globalThis[e]=(...t)=>V(e,...t))}u(Te,"createTypeElement");function se(e){return e.replace(/-+/g,"-").replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}u(se,"dashToCamel");function Ge(e,t=null){ae(e,t)}u(Ge,"createSigment");function Je(e,t=null){ae(e,t)}u(Je,"addSigment");function Ke(e,...t){if(Te(e),t.length!==0)return globalThis[e](...t)}u(Ke,"createElement");function ke(e){let t=document.createTextNode("");return B(()=>{if(typeof v!="object"||v===null){t.nodeValue=e;return}let n=e.replace(/{{(.*?)}}/g,(o,l)=>{let i=l.trim();if(v.hasOwnProperty(i)){let s=v[i];if(s&&typeof s[0]=="function")return s[0]()??""}return""});t.nodeValue=n}),t}u(ke,"interpolateReactiveText");function Be(e,t=5e3,n={}){let o=JSON.stringify([e,n,t]);if(!I.has(o)){let l=Se(async()=>{let i=await fetch(e,n);if(!i.ok)throw new Error(`Fetch failed: ${i.status}`);return i.json()},t);I.set(o,l)}return I.get(o)()}u(Be,"fetchCache");function Y(e){if(Array.isArray(e))return e.map(Y);if(e&&typeof e=="object"){let t={};return Object.keys(e).sort().forEach(n=>{t[n]=Y(e[n])}),t}return e}u(Y,"sortObjectDeep");function _e(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}u(_e,"sortObjectShallow");function Se(e,t=null,n={}){let o=new Map,l=u((...i)=>{let{deepSort:s}=n,r;s===!0?r=i.map(b=>b&&typeof b=="object"?Y(b):b):s===!1?r=i.map(b=>b&&typeof b=="object"?_e(b):b):r=i;let y=JSON.stringify(r),c=Date.now();y.length===2&&(y=e.name);let m=o.get(y);if(m&&(t===null||c-m.timestamp<t))return m.value;let p=e(...i);return o.set(y,{value:p,timestamp:c}),p instanceof Promise&&p.catch(()=>o.delete(y)),p},"wrapped");return l.clear=()=>o.clear(),l}u(Se,"memoizeFunc");function xe(e,t,n){let l=document.querySelectorAll("[data-component]")[n];return!l||l.getAttribute("data-component")!==e?null:[l,...l.querySelectorAll("*")][t]||null}u(xe,"getSsrElementByIndex");function q(e){let t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};return e.replace(/[&<>"']/g,n=>t[n])}u(q,"escapeHtml");function V(e,...t){var h;let n={},o=[];if(t[0]&&typeof t[0]=="object"&&!Array.isArray(t[0])&&t[0]!==null&&!(t[0]instanceof String)&&(_||!(t[0]instanceof Node))?(n=t[0],o=t.slice(1)):o=t,_&&typeof document>"u"){let a=globalThis.__CURRENT_COMPONENT__;globalThis.__HANDLER_REGISTRY__||(globalThis.__HANDLER_REGISTRY__={}),(h=globalThis.__HANDLER_REGISTRY__)[a]||(h[a]=[]);let f=[];for(let[T,L]of Object.entries(n))if(T==="style"&&typeof L=="object"){let x=Object.entries(L).map(([ce,ue])=>`${ce.replace(/([A-Z])/g,"-$1").toLowerCase()}:${ue}`).join(";");f.push(` style="${q(x)}"`)}else T!=="className"&&T!=="class"&&!T.startsWith("on")&&f.push(` ${T}="${q(String(L))}"`);(n.className||n.class)&&f.push(` class="${q(n.className||n.class)}"`);let E=o.map(T=>typeof T=="function"?T():T??"").join("");if(["input","img","br","hr","meta","link"].includes(e))return`<${e}${f.join("")} />`;if(e==="fragment")return E;var l;let S=U.get(e);return S&&(l=S.tagName,S.nativeTag!==null&&(l=S.nativeTag)),l!==void 0&&(e=l),`<${e}${f.join("")}>${E}</${e}>`}R(V.name);var i="";i=K();var s=i.split("|");if(s.includes(w.rpc))return;let r=null,y=e.toLowerCase()==="fragment";if(y)r=document.createDocumentFragment();else{var l;let f=U.get(e);f&&(l=f.tagName,f.nativeTag!==null&&(l=f.nativeTag)),l!==void 0&&(e=l),r=document.createElement(e)}if(globalThis.__CURRENT_COMPONENT__){$++;let a=$;r.dataIndex=a,r.realtedComponent=globalThis.__CURRENT_COMPONENT__,r.cmpNbr=P}let c=[];for(let[a,f]of Object.entries(n))if(a.startsWith("on")&&typeof f=="function"){let E=a.slice(2).toLowerCase();c.push({type:E,val:f})}c.length&&(r._handlers=c);let d=G.has(e),m=z.has(se(e)),p=e==="input"||e==="option",b=e==="option";if(!y)for(let a in n){let f=n[a];if(a.startsWith("on")&&typeof f=="function"){let E=a.slice(2).toLowerCase();r.addEventListener(E,C=>{A.stopPropagation&&C.stopPropagation(),f(C)})}else typeof f=="function"&&a!=="children"?B(()=>{let E=f();E==null||E===!1?(r.removeAttribute(a),a==="value"&&m&&(r.value="",A.cleanhtml||r.removeAttribute("value")),a==="checked"&&p&&(r.checked=!1,A.cleanhtml||r.removeAttribute("checked")),a==="selected"&&b&&(r.selected=!1,A.cleanhtml||r.removeAttribute("selected")),a==="id"&&(r.iid="",A.cleanhtml||r.removeAttribute("id"))):a==="id"?(r.iid=E,A.cleanhtml?r.removeAttribute("id"):r.setAttribute("id",E),ee(E,{name:E,caller:E+i,value:r})):a==="value"&&m?(r.value=E,A.cleanhtml?r.removeAttribute("value"):r.setAttribute("value",E)):a==="checked"&&p?(r.checked=E,A.cleanhtml?r.removeAttribute("checked"):E?r.setAttribute("checked",""):r.removeAttribute("checked")):a==="selected"&&b?(r.selected=E,A.cleanhtml?r.removeAttribute("selected"):E?r.setAttribute("selected",""):r.removeAttribute("selected")):r.setAttribute(a,E)}):f!=null&&f!==!1&&(a==="id"?(r.iid=f,A.cleanhtml?r.removeAttribute("id"):r.setAttribute("id",f),ee(f,{name:f,caller:f+i,value:r})):a==="value"&&m?(r.value=f,A.cleanhtml?r.removeAttribute("value"):r.setAttribute("value",f)):a==="checked"&&p?(r.checked=f,A.cleanhtml?r.removeAttribute("checked"):r.setAttribute("checked","")):a==="selected"&&b?(r.selected=f,A.cleanhtml?r.removeAttribute("selected"):r.setAttribute("selected","")):r.setAttribute(a,f))}return d?o.length===1&&(typeof o[0]=="string"||typeof o[0]=="number")?m&&(r.value=o[0],A.cleanhtml?r.removeAttribute("value"):r.setAttribute("value",o[0])):o.length>0&&console.warn(`Void element <${e}> should not have children.`):o.flat().forEach(a=>{if(typeof a=="function"){let f=document.createTextNode("");r.appendChild(f),B(()=>{let E=a();if(E instanceof Node){let C=f.parentNode;if(!C)return;C.nodeType===Node.DOCUMENT_FRAGMENT_NODE?C.replaceChildren(E):C.replaceChild(E,f),f=E}else{let C=E==null?"":String(E);if(f.nodeValue!==C){let S=f.parentNode;if(S.realtedComponent){let T=null,L=xe(S.realtedComponent,S.dataset.index,S.cmpNbr);if(L&&(T=L),T!==null){let x=T;x=T.childNodes[0].firstChild,x===null&&(x=T.firstChild),x.nodeType===Node.TEXT_NODE&&(x.nodeValue=C)}else f.nodeValue=C}else f.nodeValue=C}}})}else if(typeof a=="string"&&a.includes("{{")&&!a.includes("function"))r.appendChild(ke(a));else if(typeof a=="string"||typeof a=="number"){if(a.includes("function get(")||a.includes("function (")||a.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(a))}else(a instanceof DocumentFragment||a instanceof Node)&&r.appendChild(a)}),r}u(V,"h");function ve(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/-+/g,"-").toLowerCase()}u(ve,"camelToDash");function ae(e,t=null){if(g.innerHTMLElements.includes(e)||g.valueElements.includes(e)||g.srcElements.includes(e)||g.hrefElements.includes(e)||g.voidElements.includes(e))return;let o=/[A-Z]/.test(e)?ve(e):e.toLowerCase();o.includes("-")||(o="s-"+o),e.includes("-")&&(o=e,e=se(e)),U.set(e,{tagName:o,nativeTag:t}),!g.innerHTMLElements.includes(e)&&t===null?g.innerHTMLElements.push(e):!g.innerHTMLElements.includes(e)&&t!==null&&(g.innerHTMLElements.includes(t)||g.innerHTMLElements.push(e)),!g.valueElements.includes(e)&&t===null?(g.valueElements.push(e),z.add(e)):!g.valueElements.includes(e)&&t!==null&&(g.valueElements.includes(t)||(g.valueElements.push(e),z.add(e))),!g.srcElements.includes(e)&&t===null?(g.srcElements.push(e),Z.add(e)):!g.srcElements.includes(e)&&t!==null&&(g.srcElements.includes(t)||(g.srcElements.push(e),Z.add(e))),!g.hrefElements.includes(e)&&t===null?(g.hrefElements.push(e),Q.add(e)):!g.hrefElements.includes(e)&&t!==null&&(g.hrefElements.includes(t)||(g.hrefElements.push(e),Q.add(e))),!g.voidElements.includes(e)&&t===null?(g.voidElements.push(e),G.add(e)):!g.voidElements.includes(e)&&t!==null&&(g.voidElements.includes(t)||(g.voidElements.push(e),G.add(e))),globalThis[e]=(...l)=>V(e,...l)}u(ae,"defineElement");function Le(e){_||requestAnimationFrame(()=>{requestAnimationFrame(e)})}u(Le,"onPaint");function Ye(e){if(_)return;let t=!1;Le(()=>{t||(t=!0,e())})}u(Ye,"paintFinish");function oe(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}u(oe,"getPropsFromDataAttributes");async function Oe(){let e=document.querySelector("layout[data-layout]");if(!e)return!1;let t=e.getAttribute("data-layout");if(!t)return!1;try{_||(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"),s=document.querySelector("description[data-description]");if(s){let c=i.querySelector('meta[name="description"]');c||(c=i.createElement("meta"),c.name="description",i.head.appendChild(c)),c.content=s.getAttribute("data-description")}let r=document.querySelector("keywords[data-keywords]");if(r){let c=i.querySelector('meta[name="keywords"]');c||(c=i.createElement("meta"),c.name="keywords",i.head.appendChild(c)),c.content=r.getAttribute("data-keywords")}return document.querySelectorAll("[data-part]").forEach(c=>{let d=c.getAttribute("data-part"),m=i.querySelector(`[data-part="${d}"]`);m&&(m.innerHTML="",[...c.childNodes].forEach(p=>{m.appendChild(p.cloneNode(!0))}))}),document.documentElement.innerHTML=i.documentElement.innerHTML,!0}catch(n){return console.error("Failed to inject layout:",n),!1}}u(Oe,"injectLayout");function D(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 l=n.toUpperCase();if(e[l])return e[l];let i=n.toLowerCase(),s=Object.entries(e).find(([r,y])=>r.toLowerCase()===i);if(s)return s[1]}u(D,"lookupComponent");async function re(e){var y;let t=e||A.route;await Oe();let{componentKey:n,componentName:o,params:l}=ie(t),i=new Set,s=o,r=document.querySelectorAll("[data-component]");for(let c of r){let d=c.getAttribute("data-component"),m=d==null?void 0:d.toLowerCase();if(typeof rvs_map_sigment<"u"&&rvs_map_sigment!==null?s=D(rvs_map_sigment,d):s=m,!s||i.has(s))continue;let p=D(t,s);try{c.hasChildNodes()&&(globalThis.__CURRENT_COMPONENT__=d);let b=p?await Me(p):await Re(A.loadAtRunTime,s),h=p?{...l,...oe(c)}:oe(c),a=b.default(h);a.funcName=o.toLowerCase();let f=(y=c.closest("[data-part]"))==null?void 0:y.getAttribute("data-part");a.datapart=f,a.setAttribute("data-component",d),a.hydrate=!0,c.cmpNbr=P,X(c,a),le.set(s,P),P++,$=0}catch(b){console.warn(`Component "${m}" failed to load`,b)}}}u(re,"hydrateComponent");async function Me(e){if(!M.has(e)){let t=await e.loader();M.set(e,t)}return M.get(e)}u(Me,"loadModule");async function Re(e,t){let n=D(e,t);if(n){if(M.has(n))return M.get(n);try{let o=await n();return M.set(n,o),o}catch(o){console.error(`Component "${t}" failed to load`,o)}}}u(Re,"loadModuleFromFile");function Xe(e,t){if(e===void 0){re();return}if(typeof e=="object"&&t===void 0){re(e);return}let n=typeof e=="string"?document.getElementById(e):e;if(!n)throw new Error("Mount target not found: "+e);n.hasChildNodes()?X(n,t):n.replaceChildren(t)}u(Xe,"mount");function X(e,t){(async()=>{try{if(e.hasChildNodes()){let l=[t,...t.querySelectorAll("*")],i=[e,...e.querySelectorAll("*")];l.forEach((s,r)=>{let y=i[r];if(y){s.dataset.index=r;for(let c of s.getAttributeNames()){let d=s.getAttribute(c);if(y.getAttribute(c)!==d){if(c==="data-component"||c==="data-index")continue;y.setAttribute(c,d)}}s.nodeType===Node.TEXT_NODE&&s.nodeValue!==y.nodeValue&&(y.nodeValue=s.nodeValue),s.childNodes[0].nodeType===Node.TEXT_NODE&&s.childNodes[0].nodeValue!==y.nodeValue&&(y.childNodes[0].nodeValue=s.childNodes[0].nodeValue),s._handlers&&s._handlers.forEach(({type:c,val:d})=>{y.addEventListener(c,m=>{A.stopPropagation&&m.stopPropagation(),d(m)})})}}),globalThis.__CURRENT_COMPONENT__=null,$=0;return}if(!t||e.nodeName!==t.nodeName){e.replaceWith(t);return}if(t.nodeType===Node.TEXT_NODE){e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue);return}if(e.nodeType===Node.ELEMENT_NODE&&t.nodeType===Node.ELEMENT_NODE){for(let l of Array.from(t.attributes))e.setAttribute(l.name,l.value);if(t._handlers)for(let{type:l,val:i}of t._handlers)e.addEventListener(l,s=>{A.stopPropagation&&s.stopPropagation(),i(s)});e instanceof HTMLInputElement?(e.value!==t.value&&(e.value=t.value),["checkbox","radio"].includes(e.type)&&e.checked!==t.checked&&(e.checked=t.checked)):e instanceof HTMLTextAreaElement?e.value!==t.value&&(e.value=t.value):e instanceof HTMLSelectElement&&e.value!==t.value&&(e.value=t.value);for(let l of Array.from(e.attributes))t.hasAttribute(l.name)||e.removeAttribute(l.name)}let n=Array.from(t.childNodes),o=Array.from(e.childNodes);for(let l=0;l<Math.max(n.length,o.length);l++){let i=o[l],s=n[l];i&&s?X(i,s):s?e.appendChild(s):i&&e.removeChild(i)}}catch(n){console.error("Hydration failed:",n)}})()}u(X,"hydrate");export{Ie as IsEmpty,A as MyApp,me as Navigate,Ue as NavigateTo,Ve as Route,Je as addSigment,ze as clearComponentCache,B as createEffect,Ke as createElement,$e as createGlobalSignal,Ge as createSigment,we as createSignal,Be as fetchCache,Fe as getCookie,He as getGlobalSignal,De as getStorage,F as getVirtualElementById,$e as globalSignal,F as gve,ne as gvec,V as h,re as hydrateComponent,qe as loadFunc,Ce as loadRunFunc,Se as memoizeFunc,Xe as mount,Le as onPaint,Ye as paintFinish,ie as parsePath,te as rpc,je as setCookie,Ne as setStorage,we as signal,We as updateNodeIfNeeded,He as useGlobalSignal};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sigment",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
4
4
  "description": "A lightweight reactive JavaScript framework built with signals and vanilla JS — no virtual DOM, no JSX, no transpilation.",
5
5
  "main": "./dist/index.js",
6
6
  "repository": {