sigment 1.0.2 → 1.0.3

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 +3 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var D=Object.defineProperty;var c=(e,t)=>D(e,"name",{value:t,configurable:!0});var y={cleanHtml:K,cleanhtml:!0,setMaxCacheSize:G,maxCacheSize:10},g={funcname:[],dataMap:new Map},C=null,w={},M=new Map,v=new Map,x={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(x).flat().forEach(e=>{globalThis[e]=(...t)=>S(e,...t)});var P=new Set(x.valueElements),Q=new Set(x.srcElements),X=new Set(x.hrefElements),I=new Set(x.voidElements);function Z(e,t){w[e]||(w[e]=V(t))}c(Z,"createGlobalSignal");function J(e){return w[e]}c(J,"getGlobalSignal");var ee=J;function te(e){k(e)}c(te,"getVirtualElementById");function R(e,t){g.dataMap.has(e)&&g.dataMap.delete(e),g.dataMap.set(e,t)}c(R,"addEntry");function k(e){A(k.name);let t=g.dataMap.get(e);return t?t.value:null}c(k,"gve");function ne(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(ne,"setCookie");function oe(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(oe,"getCookie");function re(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(re,"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}}c(ie,"getStorage");function L(e,t=void 0){A(L.name),g.createInstance=L.name;let n="";t===void 0?n=e():n=e(t)}c(L,"createInstance");function z(e,t){A(z.name),g.rpc=z.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(z,"rpc");function H(e,t=!1,n){A(H.name),g.gvec=H.name;let o=Object.keys(e),i=o[0],l=o[1],r=o[2];var a=e[i];a=a.name;var p=e[l];let f=e[l];debugger;var h=k(l)===null;if(h||t===!1){var m=""+l;g.dataMap.delete(m),L(p,e[r])}p=k(l);var s=k(i);if(s===null)throw new Error(` source id '${i} is not found in source component `);if(p===null)throw new Error(` target id '${l} is not found in target component `);if(s.replaceWith(p),n!==void 0)for(let b in f){let O=b.toString();if(typeof n=="object"){for(var u in n)if(O===u){var d=n[u];typeof d=="object"?f[b].apply(null,d):f[b].apply(null,[])}}else if(n.indexOf(",">-1)){let j=n.split(",");for(let T=0;T<j.length;T++)O===j[T]&&f[b].apply(null,[])}else O===n&&f[b].apply(null,[])}}c(H,"gvec");async function se(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 r=Array.isArray(n)?n:[n];for(let a of r)try{let p=typeof a=="function"?a():a;if(p instanceof Promise){if(!await p)return!1}else if(!p)return!1}catch(p){return console.error("Route check failed:",p),!1}return!0}c(se,"Route");function ce(e){return e==null||e===""}c(ce,"IsEmpty");function le(e){window.history.pushState(e,e,e)}c(le,"Navigate");function G(e){y.maxCacheSize=e}c(G,"setMaxCacheSize");function K(e){y.cleanhtml=e}c(K,"cleanHtml");async function ae(e,t){let n=t.replace(/\//g,"").toLowerCase(),o=Object.keys(e).find(i=>i.toLowerCase()===n);if(!o){let i=Object.keys(e).join(", ");throw new Error(`Unknown component: "${t}".
1
+ var D=Object.defineProperty;var c=(e,t)=>D(e,"name",{value:t,configurable:!0});var y={cleanHtml:K,cleanhtml:!0,setMaxCacheSize:G,maxCacheSize:10},b={funcname:[],dataMap:new Map},C=null,w={},M=new Map,v=new Map,x={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(x).flat().forEach(e=>{globalThis[e]=(...t)=>S(e,...t)});var P=new Set(x.valueElements),Q=new Set(x.srcElements),X=new Set(x.hrefElements),I=new Set(x.voidElements);function Z(e,t){w[e]||(w[e]=V(t))}c(Z,"createGlobalSignal");function J(e){return w[e]}c(J,"getGlobalSignal");var ee=J;function te(e){k(e)}c(te,"getVirtualElementById");function R(e,t){b.dataMap.has(e)&&b.dataMap.delete(e),b.dataMap.set(e,t)}c(R,"addEntry");function k(e){A(k.name);let t=b.dataMap.get(e);return t?t.value:null}c(k,"gve");function ne(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(ne,"setCookie");function oe(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(oe,"getCookie");function re(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(re,"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}}c(ie,"getStorage");function L(e,t=void 0){A(L.name),b.createInstance=L.name;let n="";t===void 0?n=e():n=e(t)}c(L,"createInstance");function z(e,t){A(z.name),b.rpc=z.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(z,"rpc");function H(e,t=!1,n){A(H.name),b.gvec=H.name;let o=Object.keys(e),i=o[0],l=o[1],r=o[2];var a=e[i];a=a.name;var p=e[l];let f=e[l];var h=k(l)===null;if(h||t===!1){var m=""+l;b.dataMap.delete(m),L(p,e[r])}p=k(l);var s=k(i);if(s===null)throw new Error(` source id '${i} is not found in source component `);if(p===null)throw new Error(` target id '${l} is not found in target component `);if(s.replaceWith(p),n!==void 0)for(let g in f){let O=g.toString();if(typeof n=="object"){for(var u in n)if(O===u){var d=n[u];typeof d=="object"?f[g].apply(null,d):f[g].apply(null,[])}}else if(n.indexOf(",">-1)){let j=n.split(",");for(let T=0;T<j.length;T++)O===j[T]&&f[g].apply(null,[])}else O===n&&f[g].apply(null,[])}}c(H,"gvec");async function se(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 r=Array.isArray(n)?n:[n];for(let a of r)try{let p=typeof a=="function"?a():a;if(p instanceof Promise){if(!await p)return!1}else if(!p)return!1}catch(p){return console.error("Route check failed:",p),!1}return!0}c(se,"Route");function ce(e){return e==null||e===""}c(ce,"IsEmpty");function le(e){window.history.pushState(e,e,e)}c(le,"Navigate");function G(e){y.maxCacheSize=e}c(G,"setMaxCacheSize");function K(e){y.cleanhtml=e}c(K,"cleanHtml");async function ae(e,t){let n=t.replace(/\//g,"").toLowerCase(),o=Object.keys(e).find(i=>i.toLowerCase()===n);if(!o){let i=Object.keys(e).join(", ");throw new Error(`Unknown component: "${t}".
2
2
  Available components: ${i}
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(v.has(o))return v.get(o);try{let l=(await e[o]()).default;return v.set(o,l),l}catch(i){throw new Error(`Failed to load component "${o}": ${i.message}`)}}c(ae,"loadFunc");function ue(e){if(e){let t=e.toLowerCase(),n=!1;for(let o of v.keys())o.toLowerCase()===t&&(v.delete(o),n=!0);return n}else return v.clear(),!0}c(ue,"clearComponentCache");function fe(e){var a,p;let n=window.location.pathname.split("/").filter(Boolean),o=n[0]||"home",i=n.slice(1),l=(p=(a=e[o])==null?void 0:a.urlParam)==null?void 0:p.split(":"),r={};return l&&l.length&&l[0].includes("{")?(l.forEach((f,h)=>{f=f.replace(/[{}]/g,""),r[f]=i[h]}),{componentName:o,params:r}):{componentName:o,params:i}}c(fe,"parsePath");function E(e){return new DOMParser().parseFromString(e,"text/html").body.firstChild}c(E,"parseHTML");async function de(e,t,n=null,o=null){let i=e[t];if(i||(typeof e.fallback=="string"?i=e[e.fallback]:i=e.fallback),!i)return E("<h1>404 - Component not found</h1>");let{loader:l,guard:r,cacheExpiration:a=null,...p}=i;if(o===null&&typeof i.logic=="function"&&(o=i.logic),typeof r=="function"&&!await r(n))return E("<h1>403 - Forbidden</h1><p>You do not have access to this page.</p>");for(let f in p){let h=p[f];if(typeof h=="function")try{await h()}catch(m){console.error(m)}}try{let f=Date.now(),h=v.get(t);h&&a!==null&&f-h.cachedAt>a&&(v.delete(t),h=null);let m;if(h)m=h.component,v.set(t,{component:m,cachedAt:f});else{if(m=(await l()).default,v.size>=y.maxCacheSize){let u=v.keys().next().value;v.delete(u)}v.set(t,{component:m,cachedAt:f})}return typeof m!="function"?E("<h1>Invalid component</h1>"):typeof n=="object"&&!Array.isArray(n)?m(n):n?m(...n):m()}catch(f){return console.error(f),E("<h1>Error loading component</h1>")}}c(de,"loadRunFunc");function F(e=""){var i,l;A(F.name),g.buildRoadMap=F.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(`
9
+ };`)}if(v.has(o))return v.get(o);try{let l=(await e[o]()).default;return v.set(o,l),l}catch(i){throw new Error(`Failed to load component "${o}": ${i.message}`)}}c(ae,"loadFunc");function ue(e){if(e){let t=e.toLowerCase(),n=!1;for(let o of v.keys())o.toLowerCase()===t&&(v.delete(o),n=!0);return n}else return v.clear(),!0}c(ue,"clearComponentCache");function fe(e){var a,p;let n=window.location.pathname.split("/").filter(Boolean),o=n[0]||"home",i=n.slice(1),l=(p=(a=e[o])==null?void 0:a.urlParam)==null?void 0:p.split(":"),r={};return l&&l.length&&l[0].includes("{")?(l.forEach((f,h)=>{f=f.replace(/[{}]/g,""),r[f]=i[h]}),{componentName:o,params:r}):{componentName:o,params:i}}c(fe,"parsePath");function E(e){return new DOMParser().parseFromString(e,"text/html").body.firstChild}c(E,"parseHTML");async function de(e,t,n=null,o=null){let i=e[t];if(i||(typeof e.fallback=="string"?i=e[e.fallback]:i=e.fallback),!i)return E("<h1>404 - Component not found</h1>");let{loader:l,guard:r,cacheExpiration:a=null,...p}=i;if(o===null&&typeof i.logic=="function"&&(o=i.logic),typeof r=="function"&&!await r(n))return E("<h1>403 - Forbidden</h1><p>You do not have access to this page.</p>");for(let f in p){let h=p[f];if(typeof h=="function")try{await h()}catch(m){console.error(m)}}try{let f=Date.now(),h=v.get(t);h&&a!==null&&f-h.cachedAt>a&&(v.delete(t),h=null);let m;if(h)m=h.component,v.set(t,{component:m,cachedAt:f});else{if(m=(await l()).default,v.size>=y.maxCacheSize){let u=v.keys().next().value;v.delete(u)}v.set(t,{component:m,cachedAt:f})}return typeof m!="function"?E("<h1>Invalid component</h1>"):typeof n=="object"&&!Array.isArray(n)?m(n):n?m(...n):m()}catch(f){return console.error(f),E("<h1>Error loading component</h1>")}}c(de,"loadRunFunc");function F(e=""){var i,l;A(F.name),b.buildRoadMap=F.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
10
  `);for(let r=0;r<n.length;r++){var o="";if(navigator.userAgent.indexOf("Firefox")>0){let a=n[r].lastIndexOf(`
11
- `);if(a===-1)continue;o=n[r].slice(a+1),o===""?(a=n[r].lastIndexOf("/")+1,a>-1&&(o=n[r].substr(a),o=o.substr(0,o.indexOf(".")))):o.indexOf("/")>-1&&(o=o.substr(0,o.indexOf("/")))}else o=(l=n[r])==null?void 0:l.trim().split(" ")[1];if(!g.funcname.includes(o)&&!(o===void 0||o==="")&&!(o.indexOf("http://")>-1||o.indexOf("https://")>-1)){if(g.gvec!==void 0&&o.indexOf(g.gvec)>-1)break;t.indexOf("|"+o)>-1||(t+="|"+o.replace(".","|"))}}return e+t}c(F,"buildRoadMap");function A(e){!g.funcname.includes(e)&&g.funcname.push(e)}c(A,"setFuncName");function V(e){let t=e,n=new Set;function o(){return C&&n.add(C),t}c(o,"get");function i(l,r=!1){(r||t!==l)&&(t=l,n.forEach(a=>a()))}return c(i,"set"),[o,i]}c(V,"createSignal");function $(e){function t(){C=t,e(),C=null}c(t,"wrapped"),t()}c($,"createEffect");function B(e){e=e.toLowerCase(),x.innerHTMLElements.includes(e)||(x.innerHTMLElements.push(e),globalThis[e]=(...t)=>S(e,...t))}c(B,"createTypeElement");function U(e){e=e.toLowerCase(),x.innerHTMLElements.includes(e)||(x.innerHTMLElements.push(e),globalThis[e]=(...t)=>S(e,...t))}c(U,"createSigment");function pe(e){U(e)}c(pe,"addSigment");function me(e,...t){if(B(e),t.length!==0)return globalThis[e](...t)}c(me,"createElement");function _(e){let t=document.createTextNode("");return $(()=>{if(typeof w!="object"||w===null){t.textContent=e;return}let n=e.replace(/{{(.*?)}}/g,(o,i)=>{let l=i.trim();if(w.hasOwnProperty(l)){let r=w[l];if(r&&typeof r[0]=="function")return r[0]()??""}return""});t.textContent=n}),t}c(_,"interpolateReactiveText");function he(e,t=5e3,n={}){let o=JSON.stringify([e,n,t]);if(!M.has(o)){let i=W(async()=>{let l=await fetch(e,n);if(!l.ok)throw new Error(`Fetch failed: ${l.status}`);return l.json()},t);M.set(o,i)}return M.get(o)()}c(he,"fetchCache");function N(e){if(Array.isArray(e))return e.map(N);if(e&&typeof e=="object"){let t={};return Object.keys(e).sort().forEach(n=>{t[n]=N(e[n])}),t}return e}c(N,"sortObjectDeep");function q(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(q,"sortObjectShallow");function W(e,t=5e3,n={}){let o=new Map,i=c((...l)=>{let{deepSort:r}=n,a;r===!0?a=l.map(s=>s&&typeof s=="object"?N(s):s):r===!1?a=l.map(s=>s&&typeof s=="object"?q(s):s):a=l;let p=JSON.stringify(a),f=Date.now(),h=o.get(p);if(h&&f-h.timestamp<t)return h.value;let m=e(...l);return o.set(p,{value:m,timestamp:f}),m instanceof Promise&&m.catch(()=>o.delete(p)),m},"wrapped");return i.clear=()=>o.clear(),i}c(W,"memoizeFunc");function S(e,...t){let n={},o=[];A(S.name);var i="";i=F();var l=i.split("|");if(l.includes(g.rpc))return;t[0]&&typeof t[0]=="object"&&!Array.isArray(t[0])&&!(t[0]instanceof Node)?(n=t[0],o=t.slice(1)):o=t;let r=null,a=e.toLowerCase()==="fragment";if(a){debugger;r=document.createDocumentFragment()}else r=document.createElement(e);let p=I.has(e),f=P.has(e),h=e==="input"||e==="option",m=e==="option";if(!a)for(let s in n){let u=n[s];s.startsWith("on")&&typeof u=="function"?r.addEventListener(s.slice(2).toLowerCase(),u):typeof u=="function"&&s!=="children"?$(()=>{let d=u();d==null||d===!1?(r.removeAttribute(s),s==="value"&&f&&(r.value="",y.cleanhtml||r.removeAttribute("value")),s==="checked"&&h&&(r.checked=!1,y.cleanhtml||r.removeAttribute("checked")),s==="selected"&&m&&(r.selected=!1,y.cleanhtml||r.removeAttribute("selected")),s==="id"&&(r.iid="",y.cleanhtml||r.removeAttribute("id"))):s==="id"?(r.iid=d,y.cleanhtml?r.setAttribute("id",d):r.removeAttribute("id"),R(d,{name:d,caller:d+i,value:r})):s==="value"&&f?(r.value=d,y.cleanhtml?r.setAttribute("value",d):r.removeAttribute("value")):s==="checked"&&h?(r.checked=d,y.cleanhtml&&d?r.setAttribute("checked",""):r.removeAttribute("checked")):s==="selected"&&m?(r.selected=d,y.cleanhtml&&d?r.setAttribute("selected",""):r.removeAttribute("selected")):r.setAttribute(s,d)}):u!=null&&u!==!1&&(s==="id"?(r.iid=u,y.cleanhtml?r.setAttribute("id",u):r.removeAttribute("id"),R(u,{name:u,caller:u+i,value:r})):s==="value"&&f?(r.value=u,y.cleanhtml?r.setAttribute("value",u):r.removeAttribute("value")):s==="checked"&&h?(r.checked=u,y.cleanhtml?r.setAttribute("checked",""):r.removeAttribute("checked")):s==="selected"&&m?(r.selected=u,y.cleanhtml?r.setAttribute("selected",""):r.removeAttribute("selected")):r.setAttribute(s,u))}return p?o.length===1&&(typeof o[0]=="string"||typeof o[0]=="number")?f&&(r.value=o[0],y.cleanhtml?r.setAttribute("value",o[0]):r.removeAttribute("value")):o.length>0&&console.warn(`Void element <${e}> should not have children.`):o.flat().forEach(s=>{if(typeof s=="function"){let u=document.createTextNode("");r.appendChild(u),$(()=>{let d=s();if(d instanceof Node){let b=u.parentNode;if(!b)return;b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.replaceChildren(d):b.replaceChild(d,u),u=d}else{let b=d==null?"":String(d);u.textContent!==b&&(u.textContent=b)}})}else if(typeof s=="string"&&s.includes("{{")&&!s.includes("function")){debugger;r.appendChild(_(s))}else if(typeof s=="string"||typeof s=="number"){if(s.includes("function get(")||s.includes("function (")||s.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(s))}else(s instanceof DocumentFragment||s instanceof Node)&&r.appendChild(s)}),r}c(S,"h");export{ce as IsEmpty,y as MyApp,le as Navigate,se as Route,pe as addSigment,ue as clearComponentCache,$ as createEffect,me as createElement,Z as createGlobalSignal,U as createSigment,V as createSignal,he as fetchCache,oe as getCookie,J as getGlobalSignal,ie as getStorage,te as getVirtualElementById,k as gve,H as gvec,S as h,ae as loadFunc,de as loadRunFunc,W as memoizeFunc,fe as parsePath,z as rpc,ne as setCookie,re as setStorage,ee as useGlobalSignal};
11
+ `);if(a===-1)continue;o=n[r].slice(a+1),o===""?(a=n[r].lastIndexOf("/")+1,a>-1&&(o=n[r].substr(a),o=o.substr(0,o.indexOf(".")))):o.indexOf("/")>-1&&(o=o.substr(0,o.indexOf("/")))}else o=(l=n[r])==null?void 0:l.trim().split(" ")[1];if(!b.funcname.includes(o)&&!(o===void 0||o==="")&&!(o.indexOf("http://")>-1||o.indexOf("https://")>-1)){if(b.gvec!==void 0&&o.indexOf(b.gvec)>-1)break;t.indexOf("|"+o)>-1||(t+="|"+o.replace(".","|"))}}return e+t}c(F,"buildRoadMap");function A(e){!b.funcname.includes(e)&&b.funcname.push(e)}c(A,"setFuncName");function V(e){let t=e,n=new Set;function o(){return C&&n.add(C),t}c(o,"get");function i(l,r=!1){(r||t!==l)&&(t=l,n.forEach(a=>a()))}return c(i,"set"),[o,i]}c(V,"createSignal");function $(e){function t(){C=t,e(),C=null}c(t,"wrapped"),t()}c($,"createEffect");function B(e){e=e.toLowerCase(),x.innerHTMLElements.includes(e)||(x.innerHTMLElements.push(e),globalThis[e]=(...t)=>S(e,...t))}c(B,"createTypeElement");function U(e){e=e.toLowerCase(),x.innerHTMLElements.includes(e)||(x.innerHTMLElements.push(e),globalThis[e]=(...t)=>S(e,...t))}c(U,"createSigment");function pe(e){U(e)}c(pe,"addSigment");function me(e,...t){if(B(e),t.length!==0)return globalThis[e](...t)}c(me,"createElement");function _(e){let t=document.createTextNode("");return $(()=>{if(typeof w!="object"||w===null){t.textContent=e;return}let n=e.replace(/{{(.*?)}}/g,(o,i)=>{let l=i.trim();if(w.hasOwnProperty(l)){let r=w[l];if(r&&typeof r[0]=="function")return r[0]()??""}return""});t.textContent=n}),t}c(_,"interpolateReactiveText");function he(e,t=5e3,n={}){let o=JSON.stringify([e,n,t]);if(!M.has(o)){let i=W(async()=>{let l=await fetch(e,n);if(!l.ok)throw new Error(`Fetch failed: ${l.status}`);return l.json()},t);M.set(o,i)}return M.get(o)()}c(he,"fetchCache");function N(e){if(Array.isArray(e))return e.map(N);if(e&&typeof e=="object"){let t={};return Object.keys(e).sort().forEach(n=>{t[n]=N(e[n])}),t}return e}c(N,"sortObjectDeep");function q(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(q,"sortObjectShallow");function W(e,t=5e3,n={}){let o=new Map,i=c((...l)=>{let{deepSort:r}=n,a;r===!0?a=l.map(s=>s&&typeof s=="object"?N(s):s):r===!1?a=l.map(s=>s&&typeof s=="object"?q(s):s):a=l;let p=JSON.stringify(a),f=Date.now(),h=o.get(p);if(h&&f-h.timestamp<t)return h.value;let m=e(...l);return o.set(p,{value:m,timestamp:f}),m instanceof Promise&&m.catch(()=>o.delete(p)),m},"wrapped");return i.clear=()=>o.clear(),i}c(W,"memoizeFunc");function S(e,...t){let n={},o=[];A(S.name);var i="";i=F();var l=i.split("|");if(l.includes(b.rpc))return;t[0]&&typeof t[0]=="object"&&!Array.isArray(t[0])&&!(t[0]instanceof Node)?(n=t[0],o=t.slice(1)):o=t;let r=null,a=e.toLowerCase()==="fragment";a?r=document.createDocumentFragment():r=document.createElement(e);let p=I.has(e),f=P.has(e),h=e==="input"||e==="option",m=e==="option";if(!a)for(let s in n){let u=n[s];s.startsWith("on")&&typeof u=="function"?r.addEventListener(s.slice(2).toLowerCase(),u):typeof u=="function"&&s!=="children"?$(()=>{let d=u();d==null||d===!1?(r.removeAttribute(s),s==="value"&&f&&(r.value="",y.cleanhtml||r.removeAttribute("value")),s==="checked"&&h&&(r.checked=!1,y.cleanhtml||r.removeAttribute("checked")),s==="selected"&&m&&(r.selected=!1,y.cleanhtml||r.removeAttribute("selected")),s==="id"&&(r.iid="",y.cleanhtml||r.removeAttribute("id"))):s==="id"?(r.iid=d,y.cleanhtml?r.setAttribute("id",d):r.removeAttribute("id"),R(d,{name:d,caller:d+i,value:r})):s==="value"&&f?(r.value=d,y.cleanhtml?r.setAttribute("value",d):r.removeAttribute("value")):s==="checked"&&h?(r.checked=d,y.cleanhtml&&d?r.setAttribute("checked",""):r.removeAttribute("checked")):s==="selected"&&m?(r.selected=d,y.cleanhtml&&d?r.setAttribute("selected",""):r.removeAttribute("selected")):r.setAttribute(s,d)}):u!=null&&u!==!1&&(s==="id"?(r.iid=u,y.cleanhtml?r.setAttribute("id",u):r.removeAttribute("id"),R(u,{name:u,caller:u+i,value:r})):s==="value"&&f?(r.value=u,y.cleanhtml?r.setAttribute("value",u):r.removeAttribute("value")):s==="checked"&&h?(r.checked=u,y.cleanhtml?r.setAttribute("checked",""):r.removeAttribute("checked")):s==="selected"&&m?(r.selected=u,y.cleanhtml?r.setAttribute("selected",""):r.removeAttribute("selected")):r.setAttribute(s,u))}return p?o.length===1&&(typeof o[0]=="string"||typeof o[0]=="number")?f&&(r.value=o[0],y.cleanhtml?r.setAttribute("value",o[0]):r.removeAttribute("value")):o.length>0&&console.warn(`Void element <${e}> should not have children.`):o.flat().forEach(s=>{if(typeof s=="function"){let u=document.createTextNode("");r.appendChild(u),$(()=>{let d=s();if(d instanceof Node){let g=u.parentNode;if(!g)return;g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.replaceChildren(d):g.replaceChild(d,u),u=d}else{let g=d==null?"":String(d);u.textContent!==g&&(u.textContent=g)}})}else if(typeof s=="string"&&s.includes("{{")&&!s.includes("function"))r.appendChild(_(s));else if(typeof s=="string"||typeof s=="number"){if(s.includes("function get(")||s.includes("function (")||s.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(s))}else(s instanceof DocumentFragment||s instanceof Node)&&r.appendChild(s)}),r}c(S,"h");export{ce as IsEmpty,y as MyApp,le as Navigate,se as Route,pe as addSigment,ue as clearComponentCache,$ as createEffect,me as createElement,Z as createGlobalSignal,U as createSigment,V as createSignal,he as fetchCache,oe as getCookie,J as getGlobalSignal,ie as getStorage,te as getVirtualElementById,k as gve,H as gvec,S as h,ae as loadFunc,de as loadRunFunc,W as memoizeFunc,fe as parsePath,z as rpc,ne as setCookie,re as setStorage,ee as useGlobalSignal};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sigment",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "JavaScript Vanilla library",
5
5
  "main": "./dist/index.js",
6
6
  "repository": {