sigment 1.3.5 → 1.3.7
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 +5 -5
- package/package.json +1 -1
- package/types/index.d.ts +40 -4
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var
|
|
2
|
-
Available components: ${
|
|
1
|
+
var he=Object.defineProperty;var c=(e,t)=>he(e,"name",{value:t,configurable:!0});var _={cleanHtml:we,cleanhtml:!0,setMaxCacheSize:Ee,maxCacheSize:10,setloadAtRunTime:Ae,loadAtRunTime:null,setRoute:_e,route:null,setStopPropagation:Ce,stopPropagation:!1},C={funcname:[],dataMap:new Map},D=null,O={},z=new Map,S=new Map,V=new Map,M=new Map,ye=null,N=null,B=new Map,ge=null,F="",T=typeof window>"u",I=0;T||(F=window.location.href.replace(/^https?:\/\//,"").replace(/\/$/,""));globalThis.__CURRENT_COMPONENT__=null;var $=0,le=new Map;T&&(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","svg","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","wbr","frame"]};Object.values(b).flat().forEach(e=>{globalThis[e]||(globalThis[e]=(...t)=>W(e,...t),Object.defineProperty(globalThis,e,{writable:!1,configurable:!1}))});var J=new Set(b.valueElements),ee=new Set(b.srcElements),te=new Set(b.hrefElements),G=new Set(b.voidElements);function De(e,t){O[e]||(O[e]=fe(t))}c(De,"createGlobalSignal");function Ie(e){return O[e]}c(Ie,"getGlobalSignal");function ne(e,t){C.dataMap.has(e)&&C.dataMap.delete(e),C.dataMap.set(e,t)}c(ne,"addEntry");function H(e){P(H.name);let t=C.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}c(H,"gve");function qe(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)}c(qe,"setCookie");function We(e){let n=`; ${document.cookie}`.split(`; ${e}=`);if(n.length===2){let o=n.pop().split(";").shift();try{let i=JSON.parse(o);return typeof i=="object"&&i!==null&&"nodeType"in i&&i.nodeType===1,i}catch{return o}}return null}c(We,"getCookie");function ze(e,t){let n;t instanceof HTMLElement?n=t.outerHTML:typeof t=="object"?n=JSON.stringify(t):n=t.toString(),localStorage.setItem(e,n)}c(ze,"setStorage");function Ue(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}}c(Ue,"getStorage");function K(e,t=void 0){P(K.name),C.createInstance=K.name;let n="";t===void 0?n=e():n=e(t)}c(K,"createInstance");function oe(e,t){P(oe.name),C.rpc=oe.name;let n={};for(let[o,i]of Object.entries(t))e[o]?n[o]=e[o].apply(null,i):(console.error(`Function ${o} not found!`),n[o]=null);return n}c(oe,"rpc");function re(e,t=!1,n){P(re.name),C.gvec=re.name;let o=Object.keys(e),i=o[0],s=o[1],u=o[2];var r=e[i];r=r.name;var d=e[s];let a=e[s];var f=H(s)===null;if(f||t===!1){var y=""+s;C.dataMap.delete(y),K(d,e[u])}d=H(s);var p=H(i);if(p===null)throw new Error(` source id '${i} is not found in source component `);if(d===null)throw new Error(` target id '${s} is not found in target component `);if(p.replaceWith(d),n!==void 0)for(let l in a){let m=l.toString();if(typeof n=="object"){for(var g in n)if(m===g){var h=n[g];typeof h=="object"?a[l].apply(null,h):a[l].apply(null,[])}}else if(n.indexOf(",">-1)){let w=n.split(",");for(let L=0;L<w.length;L++)m===w[L]&&a[l].apply(null,[])}else m===n&&a[l].apply(null,[])}}c(re,"gvec");async function Ve(e,t={}){let{passRestriction:n=[]}=t,o=window.location.pathname.replace(/^\/|\/$/g,"").toLowerCase(),i=e.replace(/^\/|\/$/g,"").toLowerCase();if(!new RegExp("^"+i.replace(/:[^\/]+/g,"[^/]+")+"$").test(o))return!1;let u=Array.isArray(n)?n:[n];for(let r of u)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}c(Ve,"Route");function Be(e){return e==null||e===""}c(Be,"IsEmpty");function be(e){let t=e.startsWith("/")?e:"/"+e;window.history.pushState({},"",t)}c(be,"Navigate");function Ee(e){_.maxCacheSize=e}c(Ee,"setMaxCacheSize");function we(e){_.cleanhtml=e}c(we,"cleanHtml");function _e(e){_.route=e}c(_e,"setRoute");function Ae(e){_.loadAtRunTime=e}c(Ae,"setloadAtRunTime");function Ce(e){_.stopPropagation=e}c(Ce,"setStopPropagation");async function Je(e,t){let n;t==="/"?n=t:n=t.replace(/\//g,"").toLowerCase();let o=Object.keys(e).find(i=>i.toLowerCase()===n.toLowerCase());if(!o){let i=Object.keys(e).join(", ");throw new Error(`Unknown component: "${t}".
|
|
2
|
+
Available components: ${i}
|
|
3
3
|
|
|
4
4
|
To add this component:
|
|
5
5
|
|
|
6
6
|
const loadAsyncComponents = {
|
|
7
7
|
...existingComponents,
|
|
8
8
|
"${t}": () => import('./${t}.js')
|
|
9
|
-
};`)}if(
|
|
10
|
-
`);for(let
|
|
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={"&":"&","<":"<",">":">",'"':""","'":"'"};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};
|
|
9
|
+
};`)}if(S.has(o))return S.get(o);try{let s=(await e[o]()).default;return S.set(o,s),s}catch(i){throw new Error(`Failed to load component "${o}": ${i.message}`)}}c(Je,"loadFunc");function Se(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 i=o.closest("[data-part]");if(t=i==null?void 0:i.getAttribute("data-part"),i){let s=o.getAttribute("data-component");s&&i.querySelectorAll(`[data-component="${s}"]`).forEach((r,d)=>{r===o&&(n=d)})}}return{partName:t,index:n}}c(Se,"getTargetPartAndIndex");async function Ge(e,t,n,o,i=null){if(T)return;let s=null,{partName:u,index:r}=Se(i);u&&(s=u);let d=window.location.host+"/"+e;if(s===null){if(F===d)return;F=d}let a;typeof t=="boolean"||typeof t=="string"?(n=t,t=_.route):t===void 0&&(t=_.route,n=!1),be(e);let{componentKey:f,params:y}=ae(t);(f===void 0||f==="")&&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")f=n,a=!!o;else if(typeof n=="boolean"){if(p.length===1)f=p[0];else if(p.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.`);a=n}else{if(p.length===1)f=p[0];else if(p.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.`);a=!1}let g=await xe(t,f,y,null,!1);s&&(e=e+s+r);let h=B.get(e);if((!h||!a)&&(typeof g=="function"?($=le.get(g.name),I=0,Array.isArray(y)?h=g(...y):typeof y=="object"&&y!==null?h=g(y):h=g(),B.set(e,h)):h=g),N&&N.isConnected){var l=N.contains(h);l||N.replaceWith(h)}else{typeof rvs_map_sigment<"u"&&rvs_map_sigment!==null&&(f=q(rvs_map_sigment,f));let m=document.querySelectorAll('[data-part="'+s+'"] [data-component="'+f+'"]');h.setAttribute("data-component",f),m&&m.length===1?m[0].replaceWith(h):m&&m.length>1?m[r].replaceWith(h):document.body.replaceChildren(h)}s===null&&(N=h,ye=e),F=d}c(Ge,"NavigateTo");function Ke(e=ge,t){let n=typeof e=="string"?document.getElementById(e):e;n.contains(t)||n.replaceChildren(t)}c(Ke,"updateNodeIfNeeded");function Ye(e){if(e){let t=e.toLowerCase(),n=!1;for(let o of S.keys())o.toLowerCase()===t&&(S.delete(o),n=!0);return n}else return S.clear(),!0}c(Ye,"clearComponentCache");function ae(e){if(T)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={},i=null,s=null,u=0;function r(a){return a.length>1&&a.endsWith("/")&&(a=a.slice(0,-1)),a.replace(/^\//,"").split("/").map(f=>{let y=f.startsWith(":"),p=y&&f.endsWith("?"),g=y?f.slice(1).replace("?",""):f;return g===""&&(g="/"),{isParam:y,isOptional:p,name:g}})}c(r,"parseRouteSegments");for(let[a,f]of Object.entries(e)){let y=f.path||`/${a}`,p=r(y),g=!0;for(let h=0;h<p.length;h++){let l=p[h],m=n[h];if(l.isParam){if(!m&&!l.isOptional){g=!1;break}}else if(l.name!==m){g=!1;break}}if(n.length<p.length){for(let h=n.length;h<p.length;h++)if(!p[h].isOptional){g=!1;break}}if(g){i=a,s=f,u=p.length,p.forEach((h,l)=>{if(h.isParam){let m=n[l];m!==void 0&&m!==""&&(o[h.name]=m)}});break}}return i||(i="",s=e[i]),s!=null&&s.urlParam&&s.urlParam.split("/").map(f=>f.replace(/[{}]/g,"")).forEach((f,y)=>{let p=n[u+y];p!==void 0&&p!==""&&(o[f]=p)}),new URL(window.location.href).searchParams.forEach((a,f)=>{o[f]=a}),{componentKey:i,componentName:i,params:o}}c(ae,"parsePath");function j(e){return new DOMParser().parseFromString(e,"text/html").body.firstChild}c(j,"parseHTML");async function xe(e,t,n=null,o=null,i=!0){if(T)return;let s=e[t.toLowerCase()];if(s||(typeof e.fallback=="string"?s=e[e.fallback]:s=e.fallback),!s)return j("<h1>404 - Component not found</h1>");let{loader:u,guard:r,cacheExpiration:d=null,...a}=s;if(o===null&&typeof s.logic=="function"&&(o=s.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 f in a){let y=a[f];if(typeof y=="function")try{await y()}catch(p){console.error(p)}}try{let f=Date.now(),y=S.get(t);y&&d!==null&&f-y.cachedAt>d&&(S.delete(t),y=null);let p;if(y)p=y.component,S.set(t,{component:p,cachedAt:f});else{if(p=(await u()).default,S.size>=_.maxCacheSize){let m=S.keys().next().value;S.delete(m)}S.set(t,{component:p,cachedAt:f})}if(typeof p!="function")return j("<h1>Invalid component</h1>");if(!i)return p;let g;Array.isArray(n)?g=p(...n):typeof n=="object"&&n!==null?g=p(n):g=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 B.set(h,g),N=g,g}catch(f){return console.error(f),j("<h1>Error loading component</h1>")}}c(xe,"loadRunFunc");function Y(e=""){var i,s;if(T)return"";P(Y.name),C.buildRoadMap=Y.name;var t="";let n=(i=new Error().stack)==null?void 0:i.toString();navigator.userAgent.toLowerCase().indexOf("firefox")>0?n=n.split("@"):n=n.split(`
|
|
10
|
+
`);for(let u=0;u<n.length;u++){var o="";if(navigator.userAgent.indexOf("Firefox")>0){let r=n[u].lastIndexOf(`
|
|
11
|
+
`);if(r===-1)continue;o=n[u].slice(r+1),o===""?(r=n[u].lastIndexOf("/")+1,r>-1&&(o=n[u].substr(r),o=o.substr(0,o.indexOf(".")))):o.indexOf("/")>-1&&(o=o.substr(0,o.indexOf("/")))}else o=(s=n[u])==null?void 0:s.trim().split(" ")[1];if(!C.funcname.includes(o)&&!(o===void 0||o==="")&&!(o.indexOf("http://")>-1||o.indexOf("https://")>-1)){if(C.gvec!==void 0&&o.indexOf(C.gvec)>-1)break;t.indexOf("|"+o)>-1||(t+="|"+o.replace(".","|"))}}return e+t}c(Y,"buildRoadMap");function P(e){!C.funcname.includes(e)&&C.funcname.push(e)}c(P,"setFuncName");function ce(e){let t=typeof e=="object"&&e!==null&&!Array.isArray(e),n=!(typeof process<"u");if(t&&n)throw new Error("[Sigment] createSignal() no longer supports objects. Use signal().");t&&!n&&console.warn("[Sigment] createSignal() is deprecated for objects. Use signal().");let o=e,i=new Set;function s(){return D&&i.add(D),o}c(s,"get"),s.__isSignal=!0,s.__isPrimitiveSignal=!0;function u(d,a=!1){(a||o!==d)&&(o=d,i.forEach(f=>f()))}return c(u,"set"),[new Proxy(s,{get(d,a){if(a==="valueOf")return()=>o;if(a==="toString")return()=>String(o);if(a in d)return d[a]}}),u]}c(ce,"createSignal");function Te(e){return typeof e=="object"&&e!==null}c(Te,"isObject");function Ze(e){return fe(e)[0]}c(Ze,"store");function ue(e){let t=e,n=new Map,o=c(r=>Te(r)?ue(r)[0]:r,"wrap"),i=c(r=>{if(!n.has(r)){let[d,a]=ce(o(t[r])),f=new Proxy(d,{get(y,p){return p==="valueOf"?()=>d():p==="toString"?()=>String(d()):y[p]}});n.set(r,[f,a])}return n.get(r)},"getSignal"),s=new Proxy(t,{get(r,d){if(typeof d=="symbol")return t[d];let[a]=i(d);return a()},set(r,d,a){t[d]=a;let[,f]=i(d);return f(o(a)),!0}});function u(r){let d=typeof r=="function"?r(s):r;for(let a in d)s[a]=d[a]}return c(u,"setState"),[s,u]}c(ue,"signalObject");function fe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?ue(e):ce(e)}c(fe,"signal");function Z(e){function t(){D=t,e(),D=null}c(t,"wrapped"),t()}c(Z,"createEffect");function ke(e){e=e.toLowerCase(),b.innerHTMLElements.includes(e)||(b.innerHTMLElements.push(e),globalThis[e]=(...t)=>W(e,...t))}c(ke,"createTypeElement");function de(e){return e.replace(/-+/g,"-").replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}c(de,"dashToCamel");function Xe(e,t=null){pe(e,t)}c(Xe,"createSigment");function Qe(e,t=null){pe(e,t)}c(Qe,"addSigment");function et(e,...t){if(ke(e),t.length!==0)return globalThis[e](...t)}c(et,"createElement");function ve(e){let t=document.createTextNode("");return Z(()=>{if(typeof O!="object"||O===null){t.nodeValue=e;return}let n=e.replace(/{{(.*?)}}/g,(o,i)=>{let s=i.trim();if(O.hasOwnProperty(s)){let u=O[s];if(u&&typeof u[0]=="function")return u[0]()??""}return""});t.nodeValue=n}),t}c(ve,"interpolateReactiveText");function tt(e,t=5e3,n={}){let o=JSON.stringify([e,n,t]);if(!z.has(o)){let i=Oe(async()=>{let s=await fetch(e,n);if(!s.ok)throw new Error(`Fetch failed: ${s.status}`);return s.json()},t);z.set(o,i)}return z.get(o)()}c(tt,"fetchCache");function X(e){if(Array.isArray(e))return e.map(X);if(e&&typeof e=="object"){let t={};return Object.keys(e).sort().forEach(n=>{t[n]=X(e[n])}),t}return e}c(X,"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}c(Le,"sortObjectShallow");function Oe(e,t=null,n={}){let o=new Map,i=c((...s)=>{let{deepSort:u}=n,r;u===!0?r=s.map(g=>g&&typeof g=="object"?X(g):g):u===!1?r=s.map(g=>g&&typeof g=="object"?Le(g):g):r=s;let d=JSON.stringify(r),a=Date.now();d.length===2&&(d=e.name);let y=o.get(d);if(y&&(t===null||a-y.timestamp<t))return y.value;let p=e(...s);return o.set(d,{value:p,timestamp:a}),p instanceof Promise&&p.catch(()=>o.delete(d)),p},"wrapped");return i.clear=()=>o.clear(),i}c(Oe,"memoizeFunc");function U(e){let t={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,n=>t[n])}c(U,"escapeHtml");function Ne(e){let t="";function n(o,i=0){let s=" ".repeat(i);if(o==null||o===!1||o===!0)return;if(Array.isArray(o)){o.forEach(r=>n(r,i+1));return}let u=o;typeof u=="function"&&(u=u()),typeof u=="function"&&u.__isSignal&&(u=u()),!(u==null||u===!1||u===!0)&&(t+=String(u))}return c(n,"process"),e.forEach(o=>n(o)),t}c(Ne,"renderChildren");function Me(e){let t=[];for(let n=0;n<e.length;n++){let o=e[n],i=e[n+1];typeof o=="string"&&typeof i=="function"?(t.push(()=>o+i()),n++):t.push(o)}return t}c(Me,"normalizeChildren");function W(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||!(t[0]instanceof Node))?(n=t[0],o=t.slice(1)):o=t,T&&typeof document>"u"){let l=globalThis.__CURRENT_COMPONENT__;globalThis.__HANDLER_REGISTRY__||(globalThis.__HANDLER_REGISTRY__={}),(h=globalThis.__HANDLER_REGISTRY__)[l]||(h[l]=[]);let m=[];for(let[v,k]of Object.entries(n))if(v==="style"&&typeof k=="object"){let R=Object.entries(k).map(([A,me])=>`${A.replace(/([A-Z])/g,"-$1").toLowerCase()}:${me}`).join(";");m.push(` style="${U(R)}"`)}else v!=="className"&&v!=="class"&&!v.startsWith("on")&&m.push(` ${v}="${U(String(k))}"`);(n.className||n.class)&&m.push(` class="${U(n.className||n.class)}"`);let w=Ne(o);if(["input","img","br","hr","meta","link"].includes(e))return`<${e}${m.join("")} />`;if(e==="fragment")return w;var i;let E=V.get(e);E&&(i=E.tagName,E.nativeTag!==null&&(i=E.nativeTag)),i!==void 0&&(e=i);let x=`<${e}${m.join("")}>${w}</${e}>`;return console.log("=== FINAL HTML ===",x),x}P(W.name);var s="";s=Y();var u=s.split("|");if(u.includes(C.rpc))return;let r=null,d=e.toLowerCase()==="fragment";if(d)r=document.createDocumentFragment();else{var i;let m=V.get(e);m&&(i=m.tagName,m.nativeTag!==null&&(i=m.nativeTag)),i!==void 0&&(e=i),r=document.createElement(e)}if(globalThis.__CURRENT_COMPONENT__){I++;let l=I;r.dataIndex=l,r.realtedComponent=globalThis.__CURRENT_COMPONENT__,r.cmpNbr=$}let a=[];for(let[l,m]of Object.entries(n))if(l.startsWith("on")&&typeof m=="function"){let w=l.slice(2).toLowerCase();a.push({type:w,val:m})}a.length&&(r._handlers=a);let f=G.has(e),y=J.has(de(e)),p=e==="input"||e==="option",g=e==="option";if(!d)for(let l in n){let m=n[l];if(l.startsWith("on")&&typeof m=="function"){let w=l.slice(2).toLowerCase();r.addEventListener(w,L=>{_.stopPropagation&&L.stopPropagation(),m(L)})}else typeof m=="function"&&l!=="children"?Z(()=>{let w=m();w==null||w===!1?(r.removeAttribute(l),l==="value"&&y&&(r.value="",_.cleanhtml||r.removeAttribute("value")),l==="checked"&&p&&(r.checked=!1,_.cleanhtml||r.removeAttribute("checked")),l==="selected"&&g&&(r.selected=!1,_.cleanhtml||r.removeAttribute("selected")),l==="id"&&(r.iid="",_.cleanhtml||r.removeAttribute("id"))):l==="id"?(r.iid=w,_.cleanhtml?r.removeAttribute("id"):r.setAttribute("id",w),ne(w,{name:w,caller:w+s,value:r})):l==="value"&&y?(r.value=w,_.cleanhtml?r.removeAttribute("value"):r.setAttribute("value",w)):l==="checked"&&p?(r.checked=w,_.cleanhtml?r.removeAttribute("checked"):w?r.setAttribute("checked",""):r.removeAttribute("checked")):l==="selected"&&g?(r.selected=w,_.cleanhtml?r.removeAttribute("selected"):w?r.setAttribute("selected",""):r.removeAttribute("selected")):r.setAttribute(l,w)}):m!=null&&m!==!1&&(l==="id"?(r.iid=m,_.cleanhtml?r.removeAttribute("id"):r.setAttribute("id",m),ne(m,{name:m,caller:m+s,value:r})):l==="value"&&y?(r.value=m,_.cleanhtml?r.removeAttribute("value"):r.setAttribute("value",m)):l==="checked"&&p?(r.checked=m,_.cleanhtml?r.removeAttribute("checked"):r.setAttribute("checked","")):l==="selected"&&g?(r.selected=m,_.cleanhtml?r.removeAttribute("selected"):r.setAttribute("selected","")):r.setAttribute(l,m))}return f?o.length===1&&(typeof o[0]=="string"||typeof o[0]=="number")?y&&(r.value=o[0],_.cleanhtml?r.removeAttribute("value"):r.setAttribute("value",o[0])):o.length>0&&console.warn(`Void element <${e}> should not have children.`):(o=Me(o),o.flat().forEach((l,m)=>{if(l&&l.__isSignal&&l.__isPrimitiveSignal&&!l.__isWrapped){let w=l;w.__isWrapped=!0,l=c(()=>w(),"child")}if(typeof l=="function"){let w=l(),E=w===!1||w===null||w===!0?document.createComment(""):document.createTextNode("");r.appendChild(E),Z(()=>{let x=l();if(Array.isArray(x)){let k=E.parentNode;if(!k)return;E._insertedNodes&&(E._insertedNodes.forEach(A=>A.remove()),E._insertedNodes=null);let R=x.flat().filter(Boolean).map(A=>A instanceof Node?A:typeof A=="string"||typeof A=="number"?document.createTextNode(String(A)):typeof A=="object"?A.__isNode?A:div(A.name??JSON.stringify(A)):null).filter(Boolean);R.forEach(A=>k.insertBefore(A,E)),E._insertedNodes=R,E.nodeValue="";return}if(x 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(x,E),E._insertedNode=x;return}let v=x==null||x===!1||x===!0?"":String(x);if(E._insertedNode&&(E._insertedNode._boundNode&&E._insertedNode._boundNode.remove(),E._insertedNode.remove(),E._insertedNode=null),E.nodeValue!==v){if(!E.parentNode)return;E!=null&&E._boundNode?E._boundNode.nodeValue=v:E.nodeValue=v}})}else if(typeof l=="string"&&l.includes("{{")&&!l.includes("function"))r.appendChild(ve(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}c(W,"h");function Pe(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/-+/g,"-").toLowerCase()}c(Pe,"camelToDash");function pe(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)?Pe(e):e.toLowerCase();o.includes("-")||(o="s-"+o),e.includes("-")&&(o=e,e=de(e)),V.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),J.add(e)):!b.valueElements.includes(e)&&t!==null&&(b.valueElements.includes(t)||(b.valueElements.push(e),J.add(e))),!b.srcElements.includes(e)&&t===null?(b.srcElements.push(e),ee.add(e)):!b.srcElements.includes(e)&&t!==null&&(b.srcElements.includes(t)||(b.srcElements.push(e),ee.add(e))),!b.hrefElements.includes(e)&&t===null?(b.hrefElements.push(e),te.add(e)):!b.hrefElements.includes(e)&&t!==null&&(b.hrefElements.includes(t)||(b.hrefElements.push(e),te.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]=(...i)=>W(e,...i)}c(pe,"defineElement");function $e(e){T||requestAnimationFrame(()=>{requestAnimationFrame(e)})}c($e,"onPaint");function nt(e){if(T)return;let t=!1;$e(()=>{t||(t=!0,e())})}c(nt,"paintFinish");function ie(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}c(ie,"getPropsFromDataAttributes");async function Re(){let e=document.querySelector("layout[data-layout]");if(!e)return!1;let t=e.getAttribute("data-layout");if(!t)return!1;try{T||(t="/"+t);let n=await fetch(t);if(!n.ok)throw new Error("Failed to load layout");let o=await n.text(),s=new DOMParser().parseFromString(o,"text/html"),u=document.querySelector("description[data-description]");if(u){let a=s.querySelector('meta[name="description"]');a||(a=s.createElement("meta"),a.name="description",s.head.appendChild(a)),a.content=u.getAttribute("data-description")}let r=document.querySelector("keywords[data-keywords]");if(r){let a=s.querySelector('meta[name="keywords"]');a||(a=s.createElement("meta"),a.name="keywords",s.head.appendChild(a)),a.content=r.getAttribute("data-keywords")}return document.querySelectorAll("[data-part]").forEach(a=>{let f=a.getAttribute("data-part"),y=s.querySelector(`[data-part="${f}"]`);y&&(y.innerHTML="",[...a.childNodes].forEach(p=>{y.appendChild(p.cloneNode(!0))}))}),document.documentElement.innerHTML=s.documentElement.innerHTML,!0}catch(n){return console.error("Failed to inject layout:",n),!1}}c(Re,"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 i=n.toUpperCase();if(e[i])return e[i];let s=n.toLowerCase(),u=Object.entries(e).find(([r,d])=>r.toLowerCase()===s);if(u)return u[1]}c(q,"lookupComponent");async function se(e){var d;let t=e||_.route;await Re();let{componentKey:n,componentName:o,params:i}=ae(t),s=new Set,u=o,r=document.querySelectorAll("[data-component]");for(let a of r){let f=a.getAttribute("data-component"),y=f==null?void 0:f.toLowerCase();if(typeof rvs_map_sigment<"u"&&rvs_map_sigment!==null?u=q(rvs_map_sigment,f):u=y,!u||s.has(u))continue;let p=q(t,u);try{a.hasChildNodes()&&(globalThis.__CURRENT_COMPONENT__=f);let g=p?await je(p):await Fe(_.loadAtRunTime,u),h=p?{...i,...ie(a)}:ie(a),l=g.default(h);l.funcName=o.toLowerCase();let m=(d=a.closest("[data-part]"))==null?void 0:d.getAttribute("data-part");l.datapart=m,l.setAttribute("data-component",f),l.hydrate=!0,a.cmpNbr=$,Q(a,l),le.set(u,$),$++,I=0}catch(g){console.warn(`Component "${y}" failed to load`,g)}}}c(se,"hydrateComponent");async function je(e){if(!M.has(e)){let t=await e.loader();M.set(e,t)}return M.get(e)}c(je,"loadModule");async function Fe(e,t){let n=q(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)}}}c(Fe,"loadModuleFromFile");function ot(e,t){if(e===void 0){se();return}if(typeof e=="object"&&t===void 0){se(e);return}let n=typeof e=="string"?document.getElementById(e):e;if(!n)throw new Error("Mount target not found: "+e);n.hasChildNodes()?Q(n,t):n.replaceChildren(t)}c(ot,"mount");function Q(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 i of Array.from(t.attributes))e.setAttribute(i.name,i.value);for(let i of Array.from(e.attributes))t.hasAttribute(i.name)||e.removeAttribute(i.name);t._handlers&&t._handlers.forEach(({type:i,val:s})=>{e.addEventListener(i,u=>{_.stopPropagation&&u.stopPropagation(),s(u)})})}let n=Array.from(t.childNodes),o=Array.from(e.childNodes);for(let i=0;i<Math.max(n.length,o.length);i++){let s=o[i],u=n[i];s&&u?Q(s,u):u?e.appendChild(u):s&&e.removeChild(s)}}catch(n){console.error("Hydration failed:",n)}})()}c(Q,"hydrate");export{Be as IsEmpty,_ as MyApp,be as Navigate,Ge as NavigateTo,Ve as Route,Qe as addSigment,Ye as clearComponentCache,Z as createEffect,et as createElement,De as createGlobalSignal,Xe as createSigment,ce as createSignal,tt as fetchCache,We as getCookie,Ie as getGlobalSignal,Ue as getStorage,H as getVirtualElementById,De as globalSignal,H as gve,re as gvec,W as h,se as hydrateComponent,Je as loadFunc,xe as loadRunFunc,Oe as memoizeFunc,ot as mount,$e as onPaint,nt as paintFinish,ae as parsePath,oe as rpc,qe as setCookie,ze as setStorage,fe as sig,fe as signal,Ze as store,Ke as updateNodeIfNeeded,Ie as useGlobalSignal};
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -168,8 +168,11 @@ export { getGlobalSignal as useGlobalSignal };
|
|
|
168
168
|
|
|
169
169
|
|
|
170
170
|
/**
|
|
171
|
-
* Creates a
|
|
172
|
-
*
|
|
171
|
+
* Creates a primitive or array signal (reactive value) with getter and setter.
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* const [count, setCount] = createSignal(0);
|
|
175
|
+
* setCount(count() + 1); // reactive update
|
|
173
176
|
*/
|
|
174
177
|
export declare function createSignal<T = undefined>(
|
|
175
178
|
initialValue?: T
|
|
@@ -177,10 +180,43 @@ export declare function createSignal<T = undefined>(
|
|
|
177
180
|
|
|
178
181
|
|
|
179
182
|
/**
|
|
180
|
-
*
|
|
183
|
+
* Creates a reactive object signal (tuple style) or primitive signal (tuple style).
|
|
184
|
+
*
|
|
185
|
+
* @example Object signal (tuple)
|
|
186
|
+
* const [state, setState] = signal({ counter: 0, open: false });
|
|
187
|
+
* setState({ counter: state.counter + 1 });
|
|
188
|
+
* setState({ open: !state.open }); // toggle boolean
|
|
189
|
+
*
|
|
190
|
+
* @example Primitive signal
|
|
191
|
+
* const [count, setCount] = signal(0);
|
|
192
|
+
* setCount(count() + 1);
|
|
193
|
+
*/
|
|
194
|
+
export declare function signal<T extends object>(
|
|
195
|
+
value: T
|
|
196
|
+
): [
|
|
197
|
+
T,
|
|
198
|
+
(update: Partial<T> | ((state: T) => Partial<T>)) => void
|
|
199
|
+
];
|
|
200
|
+
|
|
201
|
+
export declare function signal<T>(
|
|
202
|
+
value: T
|
|
203
|
+
): [() => T, (newValue: T, force?: boolean) => void];
|
|
204
|
+
|
|
205
|
+
/** Alias for `signal` */
|
|
206
|
+
export { signal as sig };
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Creates a reactive object store.
|
|
211
|
+
* Returns the reactive object directly (no tuple), supporting direct mutation.
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* const state = store({ mobileMenuOpen: false, counter: 0 });
|
|
215
|
+
* state.mobileMenuOpen = !state.mobileMenuOpen; // toggle boolean
|
|
216
|
+
* state.counter += 1;
|
|
181
217
|
*/
|
|
218
|
+
export declare function store<T extends object>(value: T): T;
|
|
182
219
|
|
|
183
|
-
export { createSignal as signal };
|
|
184
220
|
|
|
185
221
|
|
|
186
222
|
/**
|