sigment 1.1.9 → 1.2.0
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/types/index.d.ts +10 -7
package/dist/index.js
CHANGED
|
@@ -8,4 +8,4 @@ const loadAsyncComponents = {
|
|
|
8
8
|
"${t}": () => import('./${t}.js')
|
|
9
9
|
};`)}if(x.has(l))return x.get(l);try{let s=(await e[l]()).default;return x.set(l,s),s}catch(o){throw new Error(`Failed to load component "${l}": ${o.message}`)}}c(be,"loadFunc");async function Ee(e,t,n,l){debugger;let o=window.location.host+"/"+e;if(V===o)return;V=o;let s;typeof t=="boolean"||typeof t=="string"?(n=t,t=b.route):t===void 0&&(t=b.route,n=!1),Q(e);let{componentKey:r,params:d}=te(t),a=Object.keys(t);if(typeof n=="string")r=n,s=!!l;else if(typeof n=="boolean"){if(a.length===1)r=a[0];else if(a.includes(e))r=e;else throw new Error(`Ambiguous component map: multiple components exist and no matching key for path '${e}' found. Provide component key explicitly.`);s=n}else{if(a.length===1)r=a[0];else if(a.includes(e))r=e;else throw new Error(`Ambiguous component map: multiple components exist and no matching key for path '${e}' found. Provide component key explicitly.`);s=!1}let m=await ne(t,r,d,null,!1),p=F.get(e);if((!p||!s)&&(typeof m=="function"?(p=m(),F.set(e,p)):p=m),A&&A.isConnected){var g=A.contains(p);g||A.replaceWith(p)}else document.body.appendChild(p);A=p,K=e}c(Ee,"NavigateTo");function we(e=S,t){let n=typeof e=="string"?document.getElementById(e):e;n.contains(t)||n.replaceChildren(t)}c(we,"updateNodeIfNeeded");function xe(e,t){if(S=typeof e=="string"?document.getElementById(e):e,!S)throw new Error("Mount target not found: "+e);S.replaceChildren(t)}c(xe,"mount");function ke(e){if(e){let t=e.toLowerCase(),n=!1;for(let l of x.keys())l.toLowerCase()===t&&(x.delete(l),n=!0);return n}else return x.clear(),!0}c(ke,"clearComponentCache");function te(e){var d,a;let n=window.location.pathname.split("/").filter(Boolean),l=n[0]||"home",o={},s=(a=(d=e[l])==null?void 0:d.urlParam)==null?void 0:a.split("/");return s&&s.length&&s.forEach((m,p)=>{m=m.replace(/[{}]/g,""),n[p+1]&&(o[m]=n[p+1])}),new URL(window.location.href).searchParams.forEach((m,p)=>{o[p]=m}),{componentName:l,params:o}}c(te,"parsePath");function v(e){return new DOMParser().parseFromString(e,"text/html").body.firstChild}c(v,"parseHTML");async function ne(e,t,n=null,l=null,o=!0){let s=e[t.toLowerCase()];if(s||(typeof e.fallback=="string"?s=e[e.fallback]:s=e.fallback),!s)return v("<h1>404 - Component not found</h1>");let{loader:r,guard:d,cacheExpiration:a=null,...m}=s;if(l===null&&typeof s.logic=="function"&&(l=s.logic),typeof d=="function"&&!await d(n))return v("<h1>403 - Forbidden</h1><p>You do not have access to this page.</p>");for(let p in m){let g=m[p];if(typeof g=="function")try{await g()}catch(y){console.error(y)}}try{let p=Date.now(),g=x.get(t);g&&a!==null&&p-g.cachedAt>a&&(x.delete(t),g=null);let y;if(g)y=g.component,x.set(t,{component:y,cachedAt:p});else{if(y=(await r()).default,x.size>=b.maxCacheSize){let w=x.keys().next().value;x.delete(w)}x.set(t,{component:y,cachedAt:p})}if(typeof y!="function")return v("<h1>Invalid component</h1>");if(!o)return y;let i;Array.isArray(n)?i=y(...n):typeof n=="object"&&n!==null?i=y(n):i=y();let u="/";try{u=window.location.pathname.slice(1)+window.location.hash,u=u.endsWith("/")&&u!=="/"?u.slice(0,-1):u,u===""&&(u="/")}catch{u=t}return F.set(u,i),A=i,i}catch(p){return console.error(p),v("<h1>Error loading component</h1>")}}c(ne,"loadRunFunc");function z(e=""){var o,s;C(z.name),E.buildRoadMap=z.name;var t="";let n=(o=new Error().stack)==null?void 0:o.toString();navigator.userAgent.toLowerCase().indexOf("firefox")>0?n=n.split("@"):n=n.split(`
|
|
10
10
|
`);for(let r=0;r<n.length;r++){var l="";if(navigator.userAgent.indexOf("Firefox")>0){let d=n[r].lastIndexOf(`
|
|
11
|
-
`);if(d===-1)continue;l=n[r].slice(d+1),l===""?(d=n[r].lastIndexOf("/")+1,d>-1&&(l=n[r].substr(d),l=l.substr(0,l.indexOf(".")))):l.indexOf("/")>-1&&(l=l.substr(0,l.indexOf("/")))}else l=(s=n[r])==null?void 0:s.trim().split(" ")[1];if(!E.funcname.includes(l)&&!(l===void 0||l==="")&&!(l.indexOf("http://")>-1||l.indexOf("https://")>-1)){if(E.gvec!==void 0&&l.indexOf(E.gvec)>-1)break;t.indexOf("|"+l)>-1||(t+="|"+l.replace(".","|"))}}return e+t}c(z,"buildRoadMap");function C(e){!E.funcname.includes(e)&&E.funcname.push(e)}c(C,"setFuncName");function le(e){let t=e,n=new Set;function l(){return O&&n.add(O),t}c(l,"get");function o(s,r=!1){(r||t!==s)&&(t=s,n.forEach(d=>d()))}return c(o,"set"),[l,o]}c(le,"createSignal");function j(e){function t(){O=t,e(),O=null}c(t,"wrapped"),t()}c(j,"createEffect");function re(e){e=e.toLowerCase(),f.innerHTMLElements.includes(e)||(f.innerHTMLElements.push(e),globalThis[e]=(...t)=>T(e,...t))}c(re,"createTypeElement");function q(e){return e.replace(/-+/g,"-").replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}c(q,"dashToCamel");function Ae(e,t=null){Y(e,t)}c(Ae,"createSigment");function Ce(e,t=null){Y(e,t)}c(Ce,"addSigment");function ve(e,...t){if(re(e),t.length!==0)return globalThis[e](...t)}c(ve,"createElement");function ie(e){let t=document.createTextNode("");return j(()=>{if(typeof k!="object"||k===null){t.nodeValue=e;return}let n=e.replace(/{{(.*?)}}/g,(l,o)=>{let s=o.trim();if(k.hasOwnProperty(s)){let r=k[s];if(r&&typeof r[0]=="function")return r[0]()??""}return""});t.nodeValue=n}),t}c(ie,"interpolateReactiveText");function Se(e,t=5e3,n={}){let l=JSON.stringify([e,n,t]);if(!M.has(l)){let o=se(async()=>{let s=await fetch(e,n);if(!s.ok)throw new Error(`Fetch failed: ${s.status}`);return s.json()},t);M.set(l,o)}return M.get(l)()}c(Se,"fetchCache");function I(e){if(Array.isArray(e))return e.map(I);if(e&&typeof e=="object"){let t={};return Object.keys(e).sort().forEach(n=>{t[n]=I(e[n])}),t}return e}c(I,"sortObjectDeep");function oe(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(oe,"sortObjectShallow");function se(e,t=null,n={}){debugger;let l=new Map,o=c((...s)=>{let{deepSort:r}=n,d;r===!0?d=s.map(i=>i&&typeof i=="object"?I(i):i):r===!1?d=s.map(i=>i&&typeof i=="object"?oe(i):i):d=s;let a=JSON.stringify(d),m=Date.now();a.length===2&&(a=e.name);let g=l.get(a);if(g&&(t===null||m-g.timestamp<t))return g.value;let y=e(...s);return l.set(a,{value:y,timestamp:m}),y instanceof Promise&&y.catch(()=>l.delete(a)),y},"wrapped");return o.clear=()=>l.clear(),o}c(se,"memoizeFunc");function T(e,...t){let n={},l=[];C(T.name);var o="";o=z();var s=o.split("|");if(s.includes(E.rpc))return;t[0]&&typeof t[0]=="object"&&!Array.isArray(t[0])&&!(t[0]instanceof Node)?(n=t[0],l=t.slice(1)):l=t;let r=null,d=e.toLowerCase()==="fragment";if(d)r=document.createDocumentFragment();else{var a;let i=_.get(e);i&&(a=i.tagName,i.nativeTag!==null&&(a=i.nativeTag)),a!==void 0&&(e=a),r=document.createElement(e)}let m=P.has(e),p=H.has(q(e)),g=e==="input"||e==="option",y=e==="option";if(!d)for(let i in n){let u=n[i];i.startsWith("on")&&typeof u=="function"?r.addEventListener(i.slice(2).toLowerCase(),u):typeof u=="function"&&i!=="children"?j(()=>{let h=u();h==null||h===!1?(r.removeAttribute(i),i==="value"&&p&&(r.value="",b.cleanhtml||r.removeAttribute("value")),i==="checked"&&g&&(r.checked=!1,b.cleanhtml||r.removeAttribute("checked")),i==="selected"&&y&&(r.selected=!1,b.cleanhtml||r.removeAttribute("selected")),i==="id"&&(r.iid="",b.cleanhtml||r.removeAttribute("id"))):i==="id"?(r.iid=h,b.cleanhtml?r.
|
|
11
|
+
`);if(d===-1)continue;l=n[r].slice(d+1),l===""?(d=n[r].lastIndexOf("/")+1,d>-1&&(l=n[r].substr(d),l=l.substr(0,l.indexOf(".")))):l.indexOf("/")>-1&&(l=l.substr(0,l.indexOf("/")))}else l=(s=n[r])==null?void 0:s.trim().split(" ")[1];if(!E.funcname.includes(l)&&!(l===void 0||l==="")&&!(l.indexOf("http://")>-1||l.indexOf("https://")>-1)){if(E.gvec!==void 0&&l.indexOf(E.gvec)>-1)break;t.indexOf("|"+l)>-1||(t+="|"+l.replace(".","|"))}}return e+t}c(z,"buildRoadMap");function C(e){!E.funcname.includes(e)&&E.funcname.push(e)}c(C,"setFuncName");function le(e){let t=e,n=new Set;function l(){return O&&n.add(O),t}c(l,"get");function o(s,r=!1){(r||t!==s)&&(t=s,n.forEach(d=>d()))}return c(o,"set"),[l,o]}c(le,"createSignal");function j(e){function t(){O=t,e(),O=null}c(t,"wrapped"),t()}c(j,"createEffect");function re(e){e=e.toLowerCase(),f.innerHTMLElements.includes(e)||(f.innerHTMLElements.push(e),globalThis[e]=(...t)=>T(e,...t))}c(re,"createTypeElement");function q(e){return e.replace(/-+/g,"-").replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}c(q,"dashToCamel");function Ae(e,t=null){Y(e,t)}c(Ae,"createSigment");function Ce(e,t=null){Y(e,t)}c(Ce,"addSigment");function ve(e,...t){if(re(e),t.length!==0)return globalThis[e](...t)}c(ve,"createElement");function ie(e){let t=document.createTextNode("");return j(()=>{if(typeof k!="object"||k===null){t.nodeValue=e;return}let n=e.replace(/{{(.*?)}}/g,(l,o)=>{let s=o.trim();if(k.hasOwnProperty(s)){let r=k[s];if(r&&typeof r[0]=="function")return r[0]()??""}return""});t.nodeValue=n}),t}c(ie,"interpolateReactiveText");function Se(e,t=5e3,n={}){let l=JSON.stringify([e,n,t]);if(!M.has(l)){let o=se(async()=>{let s=await fetch(e,n);if(!s.ok)throw new Error(`Fetch failed: ${s.status}`);return s.json()},t);M.set(l,o)}return M.get(l)()}c(Se,"fetchCache");function I(e){if(Array.isArray(e))return e.map(I);if(e&&typeof e=="object"){let t={};return Object.keys(e).sort().forEach(n=>{t[n]=I(e[n])}),t}return e}c(I,"sortObjectDeep");function oe(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(oe,"sortObjectShallow");function se(e,t=null,n={}){debugger;let l=new Map,o=c((...s)=>{let{deepSort:r}=n,d;r===!0?d=s.map(i=>i&&typeof i=="object"?I(i):i):r===!1?d=s.map(i=>i&&typeof i=="object"?oe(i):i):d=s;let a=JSON.stringify(d),m=Date.now();a.length===2&&(a=e.name);let g=l.get(a);if(g&&(t===null||m-g.timestamp<t))return g.value;let y=e(...s);return l.set(a,{value:y,timestamp:m}),y instanceof Promise&&y.catch(()=>l.delete(a)),y},"wrapped");return o.clear=()=>l.clear(),o}c(se,"memoizeFunc");function T(e,...t){let n={},l=[];C(T.name);var o="";o=z();var s=o.split("|");if(s.includes(E.rpc))return;t[0]&&typeof t[0]=="object"&&!Array.isArray(t[0])&&!(t[0]instanceof Node)?(n=t[0],l=t.slice(1)):l=t;let r=null,d=e.toLowerCase()==="fragment";if(d)r=document.createDocumentFragment();else{var a;let i=_.get(e);i&&(a=i.tagName,i.nativeTag!==null&&(a=i.nativeTag)),a!==void 0&&(e=a),r=document.createElement(e)}let m=P.has(e),p=H.has(q(e)),g=e==="input"||e==="option",y=e==="option";if(!d)for(let i in n){let u=n[i];i.startsWith("on")&&typeof u=="function"?r.addEventListener(i.slice(2).toLowerCase(),u):typeof u=="function"&&i!=="children"?j(()=>{let h=u();h==null||h===!1?(r.removeAttribute(i),i==="value"&&p&&(r.value="",b.cleanhtml||r.removeAttribute("value")),i==="checked"&&g&&(r.checked=!1,b.cleanhtml||r.removeAttribute("checked")),i==="selected"&&y&&(r.selected=!1,b.cleanhtml||r.removeAttribute("selected")),i==="id"&&(r.iid="",b.cleanhtml||r.removeAttribute("id"))):i==="id"?(r.iid=h,b.cleanhtml?r.removeAttribute("id"):r.setAttribute("id",h),B(h,{name:h,caller:h+o,value:r})):i==="value"&&p?(r.value=h,b.cleanhtml?r.removeAttribute("value"):r.setAttribute("value",h)):i==="checked"&&g?(r.checked=h,b.cleanhtml?r.removeAttribute("checked"):h?r.setAttribute("checked",""):r.removeAttribute("checked")):i==="selected"&&y?(r.selected=h,b.cleanhtml?r.removeAttribute("selected"):h?r.setAttribute("selected",""):r.removeAttribute("selected")):r.setAttribute(i,h)}):u!=null&&u!==!1&&(i==="id"?(r.iid=u,b.cleanhtml?r.removeAttribute("id"):r.setAttribute("id",u),B(u,{name:u,caller:u+o,value:r})):i==="value"&&p?(r.value=u,b.cleanhtml?r.removeAttribute("value"):r.setAttribute("value",u)):i==="checked"&&g?(r.checked=u,b.cleanhtml?r.removeAttribute("checked"):r.setAttribute("checked","")):i==="selected"&&y?(r.selected=u,b.cleanhtml?r.removeAttribute("selected"):r.setAttribute("selected","")):r.setAttribute(i,u))}return m?l.length===1&&(typeof l[0]=="string"||typeof l[0]=="number")?p&&(r.value=l[0],b.cleanhtml?r.removeAttribute("value"):r.setAttribute("value",l[0])):l.length>0&&console.warn(`Void element <${e}> should not have children.`):l.flat().forEach(i=>{if(typeof i=="function"){let u=document.createTextNode("");r.appendChild(u),j(()=>{let h=i();if(h instanceof Node){let w=u.parentNode;if(!w)return;w.nodeType===Node.DOCUMENT_FRAGMENT_NODE?w.replaceChildren(h):w.replaceChild(h,u),u=h}else{let w=h==null?"":String(h);u.nodeValue!==w&&(u.nodeValue=w)}})}else if(typeof i=="string"&&i.includes("{{")&&!i.includes("function"))r.appendChild(ie(i));else if(typeof i=="string"||typeof i=="number"){if(i.includes("function get(")||i.includes("function (")||i.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(i))}else(i instanceof DocumentFragment||i instanceof Node)&&r.appendChild(i)}),r}c(T,"h");function ce(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/-+/g,"-").toLowerCase()}c(ce,"camelToDash");function Y(e,t=null){if(f.innerHTMLElements.includes(e)||f.valueElements.includes(e)||f.srcElements.includes(e)||f.hrefElements.includes(e)||f.voidElements.includes(e))return;let l=/[A-Z]/.test(e)?ce(e):e.toLowerCase();l.includes("-")||(l="s-"+l),e.includes("-")&&(l=e,e=q(e)),_.set(e,{tagName:l,nativeTag:t}),!f.innerHTMLElements.includes(e)&&t===null?f.innerHTMLElements.push(e):!f.innerHTMLElements.includes(e)&&t!==null&&(f.innerHTMLElements.includes(t)||f.innerHTMLElements.push(e)),!f.valueElements.includes(e)&&t===null?(f.valueElements.push(e),H.add(e)):!f.valueElements.includes(e)&&t!==null&&(f.valueElements.includes(t)||(f.valueElements.push(e),H.add(e))),!f.srcElements.includes(e)&&t===null?(f.srcElements.push(e),J.add(e)):!f.srcElements.includes(e)&&t!==null&&(f.srcElements.includes(t)||(f.srcElements.push(e),J.add(e))),!f.hrefElements.includes(e)&&t===null?(f.hrefElements.push(e),U.add(e)):!f.hrefElements.includes(e)&&t!==null&&(f.hrefElements.includes(t)||(f.hrefElements.push(e),U.add(e))),!f.voidElements.includes(e)&&t===null?(f.voidElements.push(e),P.add(e)):!f.voidElements.includes(e)&&t!==null&&(f.voidElements.includes(t)||(f.voidElements.push(e),P.add(e))),globalThis[e]=(...o)=>T(e,...o)}c(Y,"defineElement");export{ge as IsEmpty,b as MyApp,Q as Navigate,Ee as NavigateTo,ye as Route,Ce as addSigment,ke as clearComponentCache,j as createEffect,ve as createElement,fe as createGlobalSignal,Ae as createSigment,le as createSignal,Se as fetchCache,pe as getCookie,ae as getGlobalSignal,me as getStorage,L as getVirtualElementById,fe as globalSignal,L as gve,W as gvec,T as h,be as loadFunc,ne as loadRunFunc,se as memoizeFunc,xe as mount,te as parsePath,G as rpc,de as setCookie,he as setStorage,le as signal,we as updateNodeIfNeeded,ae as useGlobalSignal};
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -561,16 +561,19 @@ export function updateNodeIfNeeded(
|
|
|
561
561
|
|
|
562
562
|
|
|
563
563
|
|
|
564
|
-
declare
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
564
|
+
declare global {
|
|
565
|
+
declare module '*.module.css' {
|
|
566
|
+
const classes: { [key: string]: string };
|
|
567
|
+
export default classes;
|
|
568
|
+
}
|
|
568
569
|
|
|
569
|
-
declare module '*.css' {
|
|
570
|
-
|
|
571
|
-
|
|
570
|
+
declare module '*.css' {
|
|
571
|
+
const content: string;
|
|
572
|
+
export default content;
|
|
573
|
+
}
|
|
572
574
|
}
|
|
573
575
|
|
|
576
|
+
export {};
|
|
574
577
|
|
|
575
578
|
export function createElement(tagName: string, ...args: (string | HTMLElement)[]): HTMLElement;
|
|
576
579
|
|