sigment 1.0.4 → 1.0.5
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 +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -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),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(`
|
|
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.toLowerCase()];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
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};
|