sigment 1.2.2 → 1.2.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.
- package/dist/index.js +5 -5
- package/dist/ssr.js +8 -0
- package/package.json +7 -2
- package/types/index.d.ts +13 -3
- package/types/ssr.d.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var
|
|
2
|
-
Available components: ${
|
|
1
|
+
var ue=Object.defineProperty;var a=(e,t)=>ue(e,"name",{value:t,configurable:!0});var A={cleanHtml:he,cleanhtml:!0,setMaxCacheSize:me,maxCacheSize:10,setloadAtRunTime:be,loadAtRunTime:null,setRoute:ye,route:null,setStopPropagation:ge,stopPropagation:!1},w={funcname:[],dataMap:new Map},D=null,v={},N=new Map,k=new Map,re=new Map,O=new Map,fe=null,L=null,U=new Map,de=null,F="",_=typeof window>"u",$=0;_||(F=window.location.href.replace(/^https?:\/\//,"").replace(/\/$/,""));globalThis.__CURRENT_COMPONENT__=null;var R=0,le=new Map;_&&(globalThis.__HANDLER_REGISTRY__||(globalThis.__HANDLER_REGISTRY__={}),globalThis.__HANDLER_ELEMENT_MAP__||(globalThis.__HANDLER_ELEMENT_MAP__=new Map));var g={innerHTMLElements:["div","p","span","h1","h2","h3","h4","h5","h6","a","ul","ol","li","table","tr","td","th","thead","tbody","tfoot","form","label","button","section","article","header","footer","nav","aside","main","figure","figcaption","blockquote","cite","code","pre","em","strong","i","b","u","s","small","mark","time","abbr","q","dl","dt","dd","fieldset","legend","textarea","output","progress","meter","fragment","details","summary","dialog","menu","slot","template"],valueElements:["input","textarea","select","button","option","progress","meter"],srcElements:["img","script","iframe","audio","video","source","track","embed","frame","input"],hrefElements:["a","link","area","base"],voidElements:["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr","frame"]};Object.values(g).flat().forEach(e=>{globalThis[e]=(...t)=>q(e,...t)});var W=new Set(g.valueElements),X=new Set(g.srcElements),Z=new Set(g.hrefElements),z=new Set(g.voidElements);function $e(e,t){v[e]||(v[e]=Ce(t))}a($e,"createGlobalSignal");function Pe(e){return v[e]}a(Pe,"getGlobalSignal");function Q(e,t){w.dataMap.has(e)&&w.dataMap.delete(e),w.dataMap.set(e,t)}a(Q,"addEntry");function H(e){M(H.name);let t=w.dataMap.get(e);if(t)if(typeof t.value.hydrate<"u"&&t.value.hydrate!==null){if(t.value.hydrate){let n=document.getElementById(e);return n||null}}else return t.value;else return null}a(H,"gve");function je(e,t,n){let o;if(t instanceof HTMLElement?o=t.outerHTML:typeof t=="object"?o=JSON.stringify(t):o=t.toString(),o.length>4096){console.error("Cookie size exceeds 4KB limit. Data not stored.");return}document.cookie=e+"="+o+"; max-age="+n+" ; path=/ ;",setTimeout(()=>{document.cookie="testCookie=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/;"},n*1e3)}a(je,"setCookie");function Fe(e){let n=`; ${document.cookie}`.split(`; ${e}=`);if(n.length===2){let o=n.pop().split(";").shift();try{let l=JSON.parse(o);return typeof l=="object"&&l!==null&&"nodeType"in l&&l.nodeType===1,l}catch{return o}}return null}a(Fe,"getCookie");function He(e,t){let n;t instanceof HTMLElement?n=t.outerHTML:typeof t=="object"?n=JSON.stringify(t):n=t.toString(),localStorage.setItem(e,n)}a(He,"setStorage");function De(e){let t=localStorage.getItem(e);if(t!==null)try{let n=JSON.parse(t);return typeof n=="object"&&n!==null&&"nodeType"in n&&n.nodeType===1,n}catch{return t}}a(De,"getStorage");function G(e,t=void 0){M(G.name),w.createInstance=G.name;let n="";t===void 0?n=e():n=e(t)}a(G,"createInstance");function ee(e,t){M(ee.name),w.rpc=ee.name;let n={};for(let[o,l]of Object.entries(t))e[o]?n[o]=e[o].apply(null,l):(console.error(`Function ${o} not found!`),n[o]=null);return n}a(ee,"rpc");function te(e,t=!1,n){M(te.name),w.gvec=te.name;let o=Object.keys(e),l=o[0],i=o[1],r=o[2];var p=e[l];p=p.name;var b=e[i];let f=e[i];var c=H(i)===null;if(c||t===!1){var m=""+i;w.dataMap.delete(m),G(b,e[r])}b=H(i);var d=H(l);if(d===null)throw new Error(` source id '${l} is not found in source component `);if(b===null)throw new Error(` target id '${i} is not found in target component `);if(d.replaceWith(b),n!==void 0)for(let s in f){let u=s.toString();if(typeof n=="object"){for(var y in n)if(u===y){var h=n[y];typeof h=="object"?f[s].apply(null,h):f[s].apply(null,[])}}else if(n.indexOf(",">-1)){let E=n.split(",");for(let C=0;C<E.length;C++)u===E[C]&&f[s].apply(null,[])}else u===n&&f[s].apply(null,[])}}a(te,"gvec");async function Ie(e,t={}){let{passRestriction:n=[]}=t,o=window.location.pathname.replace(/^\/|\/$/g,"").toLowerCase(),l=e.replace(/^\/|\/$/g,"").toLowerCase();if(!new RegExp("^"+l.replace(/:[^\/]+/g,"[^/]+")+"$").test(o))return!1;let r=Array.isArray(n)?n:[n];for(let p of r)try{let b=typeof p=="function"?p():p;if(b instanceof Promise){if(!await b)return!1}else if(!b)return!1}catch(b){return console.error("Route check failed:",b),!1}return!0}a(Ie,"Route");function qe(e){return e==null||e===""}a(qe,"IsEmpty");function pe(e){let t=e.startsWith("/")?e:"/"+e;window.history.pushState({},"",t)}a(pe,"Navigate");function me(e){A.maxCacheSize=e}a(me,"setMaxCacheSize");function he(e){A.cleanhtml=e}a(he,"cleanHtml");function ye(e){A.route=e}a(ye,"setRoute");function be(e){A.loadAtRunTime=e}a(be,"setloadAtRunTime");function ge(e){A.stopPropagation=e}a(ge,"setStopPropagation");async function Ne(e,t){let n;t==="/"?n=t:n=t.replace(/\//g,"").toLowerCase();let o=Object.keys(e).find(l=>l.toLowerCase()===n.toLowerCase());if(!o){let l=Object.keys(e).join(", ");throw new Error(`Unknown component: "${t}".
|
|
2
|
+
Available components: ${l}
|
|
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(d===-1)continue;l=n[i].slice(d+1),l===""?(d=n[i].lastIndexOf("/")+1,d>-1&&(l=n[i].substr(d),l=l.substr(0,l.indexOf(".")))):l.indexOf("/")>-1&&(l=l.substr(0,l.indexOf("/")))}else l=(c=n[i])==null?void 0:c.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}s(z,"buildRoadMap");function C(e){!E.funcname.includes(e)&&E.funcname.push(e)}s(C,"setFuncName");function le(e){let t=e,n=new Set;function l(){return O&&n.add(O),t}s(l,"get");function o(c,i=!1){(i||t!==c)&&(t=c,n.forEach(d=>d()))}return s(o,"set"),[l,o]}s(le,"createSignal");function j(e){function t(){O=t,e(),O=null}s(t,"wrapped"),t()}s(j,"createEffect");function ie(e){e=e.toLowerCase(),a.innerHTMLElements.includes(e)||(a.innerHTMLElements.push(e),globalThis[e]=(...t)=>T(e,...t))}s(ie,"createTypeElement");function q(e){return e.replace(/-+/g,"-").replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}s(q,"dashToCamel");function Ce(e,t=null){Y(e,t)}s(Ce,"createSigment");function ve(e,t=null){Y(e,t)}s(ve,"addSigment");function Se(e,...t){if(ie(e),t.length!==0)return globalThis[e](...t)}s(Se,"createElement");function re(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 c=o.trim();if(k.hasOwnProperty(c)){let i=k[c];if(i&&typeof i[0]=="function")return i[0]()??""}return""});t.nodeValue=n}),t}s(re,"interpolateReactiveText");function Le(e,t=5e3,n={}){let l=JSON.stringify([e,n,t]);if(!M.has(l)){let o=se(async()=>{let c=await fetch(e,n);if(!c.ok)throw new Error(`Fetch failed: ${c.status}`);return c.json()},t);M.set(l,o)}return M.get(l)()}s(Le,"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}s(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}s(oe,"sortObjectShallow");function se(e,t=null,n={}){debugger;let l=new Map,o=s((...c)=>{let{deepSort:i}=n,d;i===!0?d=c.map(r=>r&&typeof r=="object"?I(r):r):i===!1?d=c.map(r=>r&&typeof r=="object"?oe(r):r):d=c;let f=JSON.stringify(d),m=Date.now();f.length===2&&(f=e.name);let g=l.get(f);if(g&&(t===null||m-g.timestamp<t))return g.value;let y=e(...c);return l.set(f,{value:y,timestamp:m}),y instanceof Promise&&y.catch(()=>l.delete(f)),y},"wrapped");return o.clear=()=>l.clear(),o}s(se,"memoizeFunc");function T(e,...t){let n={},l=[];C(T.name);var o="";o=z();var c=o.split("|");if(c.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 i=null,d=e.toLowerCase()==="fragment";if(d)i=document.createDocumentFragment();else{var f;let r=_.get(e);r&&(f=r.tagName,r.nativeTag!==null&&(f=r.nativeTag)),f!==void 0&&(e=f),i=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 r in n){let u=n[r];r.startsWith("on")&&typeof u=="function"?i.addEventListener(r.slice(2).toLowerCase(),u):typeof u=="function"&&r!=="children"?j(()=>{let h=u();h==null||h===!1?(i.removeAttribute(r),r==="value"&&p&&(i.value="",b.cleanhtml||i.removeAttribute("value")),r==="checked"&&g&&(i.checked=!1,b.cleanhtml||i.removeAttribute("checked")),r==="selected"&&y&&(i.selected=!1,b.cleanhtml||i.removeAttribute("selected")),r==="id"&&(i.iid="",b.cleanhtml||i.removeAttribute("id"))):r==="id"?(i.iid=h,b.cleanhtml?i.removeAttribute("id"):i.setAttribute("id",h),B(h,{name:h,caller:h+o,value:i})):r==="value"&&p?(i.value=h,b.cleanhtml?i.removeAttribute("value"):i.setAttribute("value",h)):r==="checked"&&g?(i.checked=h,b.cleanhtml?i.removeAttribute("checked"):h?i.setAttribute("checked",""):i.removeAttribute("checked")):r==="selected"&&y?(i.selected=h,b.cleanhtml?i.removeAttribute("selected"):h?i.setAttribute("selected",""):i.removeAttribute("selected")):i.setAttribute(r,h)}):u!=null&&u!==!1&&(r==="id"?(i.iid=u,b.cleanhtml?i.removeAttribute("id"):i.setAttribute("id",u),B(u,{name:u,caller:u+o,value:i})):r==="value"&&p?(i.value=u,b.cleanhtml?i.removeAttribute("value"):i.setAttribute("value",u)):r==="checked"&&g?(i.checked=u,b.cleanhtml?i.removeAttribute("checked"):i.setAttribute("checked","")):r==="selected"&&y?(i.selected=u,b.cleanhtml?i.removeAttribute("selected"):i.setAttribute("selected","")):i.setAttribute(r,u))}return m?l.length===1&&(typeof l[0]=="string"||typeof l[0]=="number")?p&&(i.value=l[0],b.cleanhtml?i.removeAttribute("value"):i.setAttribute("value",l[0])):l.length>0&&console.warn(`Void element <${e}> should not have children.`):l.flat().forEach(r=>{if(typeof r=="function"){let u=document.createTextNode("");i.appendChild(u),j(()=>{let h=r();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 r=="string"&&r.includes("{{")&&!r.includes("function"))i.appendChild(re(r));else if(typeof r=="string"||typeof r=="number"){if(r.includes("function get(")||r.includes("function (")||r.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()}`)");i.appendChild(document.createTextNode(r))}else(r instanceof DocumentFragment||r instanceof Node)&&i.appendChild(r)}),i}s(T,"h");function ce(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/-+/g,"-").toLowerCase()}s(ce,"camelToDash");function Y(e,t=null){if(a.innerHTMLElements.includes(e)||a.valueElements.includes(e)||a.srcElements.includes(e)||a.hrefElements.includes(e)||a.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}),!a.innerHTMLElements.includes(e)&&t===null?a.innerHTMLElements.push(e):!a.innerHTMLElements.includes(e)&&t!==null&&(a.innerHTMLElements.includes(t)||a.innerHTMLElements.push(e)),!a.valueElements.includes(e)&&t===null?(a.valueElements.push(e),H.add(e)):!a.valueElements.includes(e)&&t!==null&&(a.valueElements.includes(t)||(a.valueElements.push(e),H.add(e))),!a.srcElements.includes(e)&&t===null?(a.srcElements.push(e),J.add(e)):!a.srcElements.includes(e)&&t!==null&&(a.srcElements.includes(t)||(a.srcElements.push(e),J.add(e))),!a.hrefElements.includes(e)&&t===null?(a.hrefElements.push(e),U.add(e)):!a.hrefElements.includes(e)&&t!==null&&(a.hrefElements.includes(t)||(a.hrefElements.push(e),U.add(e))),!a.voidElements.includes(e)&&t===null?(a.voidElements.push(e),P.add(e)):!a.voidElements.includes(e)&&t!==null&&(a.voidElements.includes(t)||(a.voidElements.push(e),P.add(e))),globalThis[e]=(...o)=>T(e,...o)}s(Y,"defineElement");function ue(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})}s(ue,"onPaint");function Oe(e){let t=!1;ue(()=>{t||(t=!0,e())})}s(Oe,"paintFinish");export{be as IsEmpty,b as MyApp,Q as Navigate,we as NavigateTo,ge as Route,ve as addSigment,Ae as clearComponentCache,j as createEffect,Se as createElement,fe as createGlobalSignal,Ce as createSigment,le as createSignal,Le as fetchCache,he as getCookie,de as getGlobalSignal,ye as getStorage,L as getVirtualElementById,fe as globalSignal,L as gve,W as gvec,T as h,Ee as loadFunc,ne as loadRunFunc,se as memoizeFunc,ke as mount,ue as onPaint,Oe as paintFinish,te as parsePath,G as rpc,pe as setCookie,me as setStorage,le as signal,xe as updateNodeIfNeeded,de as useGlobalSignal};
|
|
9
|
+
};`)}if(k.has(o))return k.get(o);try{let i=(await e[o]()).default;return k.set(o,i),i}catch(l){throw new Error(`Failed to load component "${o}": ${l.message}`)}}a(Ne,"loadFunc");function Ee(e){let t=null,n=-1;if(typeof e=="string")return{partName:e,index:n};let o=(e==null?void 0:e.target)instanceof Element?e.target.closest("[data-component]"):null;if(o){let l=o.closest("[data-part]");if(t=l==null?void 0:l.getAttribute("data-part"),l){let i=o.getAttribute("data-component");i&&l.querySelectorAll(`[data-component="${i}"]`).forEach((p,b)=>{p===o&&(n=b)})}}return{partName:t,index:n}}a(Ee,"getTargetPartAndIndex");async function Ve(e,t,n,o,l=null){if(_)return;let i=null,{partName:r,index:p}=Ee(l);r&&(i=r);let b=window.location.host+"/"+e;if(i===null){if(F===b)return;F=b}let f;typeof t=="boolean"||typeof t=="string"?(n=t,t=A.route):t===void 0&&(t=A.route,n=!1),pe(e);let{componentKey:c,params:m}=ie(t);(c===void 0||c==="")&&console.warn(`current path "${e}" not match in route map file , check if param path is match`);let d=Object.keys(t);if(typeof n=="string")c=n,f=!!o;else if(typeof n=="boolean"){if(d.length===1)c=d[0];else if(d.includes(c))c=c;else throw new Error(`Ambiguous component map: multiple components exist and no matching key for path '${e}' found. Provide component key explicitly.`);f=n}else{if(d.length===1)c=d[0];else if(d.includes(c))c=c;else throw new Error(`Ambiguous component map: multiple components exist and no matching key for path '${e}' found. Provide component key explicitly.`);f=!1}let y=await Ae(t,c,m,null,!1);i&&(e=e+i+p);let h=U.get(e);if((!h||!f)&&(typeof y=="function"?(R=le.get(y.name),$=0,Array.isArray(m)?h=y(...m):typeof m=="object"&&m!==null?h=y(m):h=y(),U.set(e,h)):h=y),L&&L.isConnected){var s=L.contains(h);s||L.replaceWith(h)}else{typeof rvs_map_sigment<"u"&&rvs_map_sigment!==null&&(c=I(rvs_map_sigment,c));let u=document.querySelectorAll('[data-part="'+i+'"] [data-component="'+c+'"]');h.setAttribute("data-component",c),u&&u.length===1?u[0].replaceWith(h):u&&u.length>1?u[p].replaceWith(h):document.body.replaceChildren(h)}i===null&&(L=h,fe=e),F=b}a(Ve,"NavigateTo");function Ue(e=de,t){let n=typeof e=="string"?document.getElementById(e):e;n.contains(t)||n.replaceChildren(t)}a(Ue,"updateNodeIfNeeded");function We(e){if(e){let t=e.toLowerCase(),n=!1;for(let o of k.keys())o.toLowerCase()===t&&(k.delete(o),n=!0);return n}else return k.clear(),!0}a(We,"clearComponentCache");function ie(e){if(_)return;let t=window.location.pathname.replace(/\/{2,}/g,"/");t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1));let n=t.replace(/^\//,"").split("/").filter(Boolean);n[0]===void 0&&(n[0]="/");let o={},l=null,i=null,r=0;function p(f){return f.length>1&&f.endsWith("/")&&(f=f.slice(0,-1)),f.replace(/^\//,"").split("/").map(c=>{let m=c.startsWith(":"),d=m&&c.endsWith("?"),y=m?c.slice(1).replace("?",""):c;return y===""&&(y="/"),{isParam:m,isOptional:d,name:y}})}a(p,"parseRouteSegments");for(let[f,c]of Object.entries(e)){let m=c.path||`/${f}`,d=p(m),y=!0;for(let h=0;h<d.length;h++){let s=d[h],u=n[h];if(s.isParam){if(!u&&!s.isOptional){y=!1;break}}else if(s.name!==u){y=!1;break}}if(n.length<d.length){for(let h=n.length;h<d.length;h++)if(!d[h].isOptional){y=!1;break}}if(y){l=f,i=c,r=d.length,d.forEach((h,s)=>{if(h.isParam){let u=n[s];u!==void 0&&u!==""&&(o[h.name]=u)}});break}}return l||(l="",i=e[l]),i!=null&&i.urlParam&&i.urlParam.split("/").map(c=>c.replace(/[{}]/g,"")).forEach((c,m)=>{let d=n[r+m];d!==void 0&&d!==""&&(o[c]=d)}),new URL(window.location.href).searchParams.forEach((f,c)=>{o[c]=f}),{componentKey:l,componentName:l,params:o}}a(ie,"parsePath");function j(e){return new DOMParser().parseFromString(e,"text/html").body.firstChild}a(j,"parseHTML");async function Ae(e,t,n=null,o=null,l=!0){if(_)return;let i=e[t.toLowerCase()];if(i||(typeof e.fallback=="string"?i=e[e.fallback]:i=e.fallback),!i)return j("<h1>404 - Component not found</h1>");let{loader:r,guard:p,cacheExpiration:b=null,...f}=i;if(o===null&&typeof i.logic=="function"&&(o=i.logic),typeof p=="function"&&!await p(n))return j("<h1>403 - Forbidden</h1><p>You do not have access to this page.</p>");for(let c in f){let m=f[c];if(typeof m=="function")try{await m()}catch(d){console.error(d)}}try{let c=Date.now(),m=k.get(t);m&&b!==null&&c-m.cachedAt>b&&(k.delete(t),m=null);let d;if(m)d=m.component,k.set(t,{component:d,cachedAt:c});else{if(d=(await r()).default,k.size>=A.maxCacheSize){let u=k.keys().next().value;k.delete(u)}k.set(t,{component:d,cachedAt:c})}if(typeof d!="function")return j("<h1>Invalid component</h1>");if(!l)return d;let y;Array.isArray(n)?y=d(...n):typeof n=="object"&&n!==null?y=d(n):y=d();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 U.set(h,y),L=y,y}catch(c){return console.error(c),j("<h1>Error loading component</h1>")}}a(Ae,"loadRunFunc");function J(e=""){var l,i;if(_)return"";M(J.name),w.buildRoadMap=J.name;var t="";let n=(l=new Error().stack)==null?void 0:l.toString();navigator.userAgent.toLowerCase().indexOf("firefox")>0?n=n.split("@"):n=n.split(`
|
|
10
|
+
`);for(let r=0;r<n.length;r++){var o="";if(navigator.userAgent.indexOf("Firefox")>0){let p=n[r].lastIndexOf(`
|
|
11
|
+
`);if(p===-1)continue;o=n[r].slice(p+1),o===""?(p=n[r].lastIndexOf("/")+1,p>-1&&(o=n[r].substr(p),o=o.substr(0,o.indexOf(".")))):o.indexOf("/")>-1&&(o=o.substr(0,o.indexOf("/")))}else o=(i=n[r])==null?void 0:i.trim().split(" ")[1];if(!w.funcname.includes(o)&&!(o===void 0||o==="")&&!(o.indexOf("http://")>-1||o.indexOf("https://")>-1)){if(w.gvec!==void 0&&o.indexOf(w.gvec)>-1)break;t.indexOf("|"+o)>-1||(t+="|"+o.replace(".","|"))}}return e+t}a(J,"buildRoadMap");function M(e){!w.funcname.includes(e)&&w.funcname.push(e)}a(M,"setFuncName");function Ce(e){let t=e,n=new Set;function o(){return D&&n.add(D),t}a(o,"get");function l(i,r=!1){(r||t!==i)&&(t=i,n.forEach(p=>p()))}return a(l,"set"),[o,l]}a(Ce,"createSignal");function K(e){function t(){D=t,e(),D=null}a(t,"wrapped"),t()}a(K,"createEffect");function we(e){e=e.toLowerCase(),g.innerHTMLElements.includes(e)||(g.innerHTMLElements.push(e),globalThis[e]=(...t)=>q(e,...t))}a(we,"createTypeElement");function se(e){return e.replace(/-+/g,"-").replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}a(se,"dashToCamel");function ze(e,t=null){ae(e,t)}a(ze,"createSigment");function Ge(e,t=null){ae(e,t)}a(Ge,"addSigment");function Je(e,...t){if(we(e),t.length!==0)return globalThis[e](...t)}a(Je,"createElement");function Te(e){let t=document.createTextNode("");return K(()=>{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 r=v[i];if(r&&typeof r[0]=="function")return r[0]()??""}return""});t.nodeValue=n}),t}a(Te,"interpolateReactiveText");function Ke(e,t=5e3,n={}){let o=JSON.stringify([e,n,t]);if(!N.has(o)){let l=_e(async()=>{let i=await fetch(e,n);if(!i.ok)throw new Error(`Fetch failed: ${i.status}`);return i.json()},t);N.set(o,l)}return N.get(o)()}a(Ke,"fetchCache");function B(e){if(Array.isArray(e))return e.map(B);if(e&&typeof e=="object"){let t={};return Object.keys(e).sort().forEach(n=>{t[n]=B(e[n])}),t}return e}a(B,"sortObjectDeep");function ke(e){if(e&&typeof e=="object"&&!Array.isArray(e)){let t={};return Object.keys(e).sort().forEach(n=>{t[n]=e[n]}),t}return e}a(ke,"sortObjectShallow");function _e(e,t=null,n={}){let o=new Map,l=a((...i)=>{let{deepSort:r}=n,p;r===!0?p=i.map(y=>y&&typeof y=="object"?B(y):y):r===!1?p=i.map(y=>y&&typeof y=="object"?ke(y):y):p=i;let b=JSON.stringify(p),f=Date.now();b.length===2&&(b=e.name);let m=o.get(b);if(m&&(t===null||f-m.timestamp<t))return m.value;let d=e(...i);return o.set(b,{value:d,timestamp:f}),d instanceof Promise&&d.catch(()=>o.delete(b)),d},"wrapped");return l.clear=()=>o.clear(),l}a(_e,"memoizeFunc");function Se(e,t,n){let l=document.querySelectorAll("[data-component]")[n];return!l||l.getAttribute("data-component")!==e?null:[l,...l.querySelectorAll("*")][t]||null}a(Se,"getSsrElementByIndex");function V(e){let t={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,n=>t[n])}a(V,"escapeHtml");function q(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 s=globalThis.__CURRENT_COMPONENT__;globalThis.__HANDLER_REGISTRY__||(globalThis.__HANDLER_REGISTRY__={}),(h=globalThis.__HANDLER_REGISTRY__)[s]||(h[s]=[]);let u=[];for(let[T,S]of Object.entries(n))if(T==="style"&&typeof S=="object"){let P=Object.entries(S).map(([x,ce])=>`${x.replace(/([A-Z])/g,"-$1").toLowerCase()}:${ce}`).join(";");u.push(` style="${V(P)}"`)}else T!=="className"&&T!=="class"&&!T.startsWith("on")&&u.push(` ${T}="${V(String(S))}"`);(n.className||n.class)&&u.push(` class="${V(n.className||n.class)}"`);let E=o.map(T=>typeof T=="function"?T():T??"").join("");return["input","img","br","hr","meta","link"].includes(e)?`<${e}${u.join("")} />`:e==="fragment"?E:`<${e}${u.join("")}>${E}</${e}>`}M(q.name);var l="";l=J();var i=l.split("|");if(i.includes(w.rpc))return;let r=null,p=e.toLowerCase()==="fragment";if(p)r=document.createDocumentFragment();else{var b;let s=re.get(e);s&&(b=s.tagName,s.nativeTag!==null&&(b=s.nativeTag)),b!==void 0&&(e=b),r=document.createElement(e)}if(globalThis.__CURRENT_COMPONENT__){$++;let s=$;r.dataIndex=s,r.realtedComponent=globalThis.__CURRENT_COMPONENT__,r.cmpNbr=R}let f=[];for(let[s,u]of Object.entries(n))if(s.startsWith("on")&&typeof u=="function"){let E=s.slice(2).toLowerCase();f.push({type:E,val:u})}f.length&&(r._handlers=f);let c=z.has(e),m=W.has(se(e)),d=e==="input"||e==="option",y=e==="option";if(!p)for(let s in n){let u=n[s];if(s.startsWith("on")&&typeof u=="function"){let E=s.slice(2).toLowerCase();r.addEventListener(E,C=>{A.stopPropagation&&C.stopPropagation(),u(C)})}else typeof u=="function"&&s!=="children"?K(()=>{let E=u();E==null||E===!1?(r.removeAttribute(s),s==="value"&&m&&(r.value="",A.cleanhtml||r.removeAttribute("value")),s==="checked"&&d&&(r.checked=!1,A.cleanhtml||r.removeAttribute("checked")),s==="selected"&&y&&(r.selected=!1,A.cleanhtml||r.removeAttribute("selected")),s==="id"&&(r.iid="",A.cleanhtml||r.removeAttribute("id"))):s==="id"?(r.iid=E,A.cleanhtml?r.removeAttribute("id"):r.setAttribute("id",E),Q(E,{name:E,caller:E+l,value:r})):s==="value"&&m?(r.value=E,A.cleanhtml?r.removeAttribute("value"):r.setAttribute("value",E)):s==="checked"&&d?(r.checked=E,A.cleanhtml?r.removeAttribute("checked"):E?r.setAttribute("checked",""):r.removeAttribute("checked")):s==="selected"&&y?(r.selected=E,A.cleanhtml?r.removeAttribute("selected"):E?r.setAttribute("selected",""):r.removeAttribute("selected")):r.setAttribute(s,E)}):u!=null&&u!==!1&&(s==="id"?(r.iid=u,A.cleanhtml?r.removeAttribute("id"):r.setAttribute("id",u),Q(u,{name:u,caller:u+l,value:r})):s==="value"&&m?(r.value=u,A.cleanhtml?r.removeAttribute("value"):r.setAttribute("value",u)):s==="checked"&&d?(r.checked=u,A.cleanhtml?r.removeAttribute("checked"):r.setAttribute("checked","")):s==="selected"&&y?(r.selected=u,A.cleanhtml?r.removeAttribute("selected"):r.setAttribute("selected","")):r.setAttribute(s,u))}return c?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(s=>{if(typeof s=="function"){let u=document.createTextNode("");r.appendChild(u),K(()=>{let E=s();if(E instanceof Node){let C=u.parentNode;if(!C)return;C.nodeType===Node.DOCUMENT_FRAGMENT_NODE?C.replaceChildren(E):C.replaceChild(E,u),u=E}else{let C=E==null?"":String(E);if(u.nodeValue!==C){let T=u.parentNode;if(T.realtedComponent){let S=null,P=Se(T.realtedComponent,T.dataset.index,T.cmpNbr);if(P&&(S=P),S!==null){let x=S;x=S.childNodes[0].firstChild,x===null&&(x=S.firstChild),x.nodeType===Node.TEXT_NODE&&(x.nodeValue=C)}}else u.nodeValue=C}}})}else if(typeof s=="string"&&s.includes("{{")&&!s.includes("function"))r.appendChild(Te(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}a(q,"h");function xe(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/-+/g,"-").toLowerCase()}a(xe,"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)?xe(e):e.toLowerCase();o.includes("-")||(o="s-"+o),e.includes("-")&&(o=e,e=se(e)),re.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),W.add(e)):!g.valueElements.includes(e)&&t!==null&&(g.valueElements.includes(t)||(g.valueElements.push(e),W.add(e))),!g.srcElements.includes(e)&&t===null?(g.srcElements.push(e),X.add(e)):!g.srcElements.includes(e)&&t!==null&&(g.srcElements.includes(t)||(g.srcElements.push(e),X.add(e))),!g.hrefElements.includes(e)&&t===null?(g.hrefElements.push(e),Z.add(e)):!g.hrefElements.includes(e)&&t!==null&&(g.hrefElements.includes(t)||(g.hrefElements.push(e),Z.add(e))),!g.voidElements.includes(e)&&t===null?(g.voidElements.push(e),z.add(e)):!g.voidElements.includes(e)&&t!==null&&(g.voidElements.includes(t)||(g.voidElements.push(e),z.add(e))),globalThis[e]=(...l)=>q(e,...l)}a(ae,"defineElement");function ve(e){_||requestAnimationFrame(()=>{requestAnimationFrame(e)})}a(ve,"onPaint");function Be(e){if(_)return;let t=!1;ve(()=>{t||(t=!0,e())})}a(Be,"paintFinish");function ne(e){let t={};for(let n of e.attributes)if(n.name.startsWith("data-")&&n.name!=="data-component"){let o=n.name.slice(5);try{t[o]=JSON.parse(n.value)}catch{t[o]=n.value}}return t}a(ne,"getPropsFromDataAttributes");async function Le(){let e=document.querySelector("layout[data-layout]");if(!e)return!1;let t=e.getAttribute("data-layout");if(!t)return!1;try{let n=await fetch(t);if(!n.ok)throw new Error("Failed to load layout");let o=await n.text(),i=new DOMParser().parseFromString(o,"text/html"),r=document.querySelector("description[data-description]");if(r){let f=i.querySelector('meta[name="description"]');f||(f=i.createElement("meta"),f.name="description",i.head.appendChild(f)),f.content=r.getAttribute("data-description")}let p=document.querySelector("keywords[data-keywords]");if(p){let f=i.querySelector('meta[name="keywords"]');f||(f=i.createElement("meta"),f.name="keywords",i.head.appendChild(f)),f.content=p.getAttribute("data-keywords")}return document.querySelectorAll("[data-part]").forEach(f=>{let c=f.getAttribute("data-part"),m=i.querySelector(`[data-part="${c}"]`);m&&(m.innerHTML="",[...f.childNodes].forEach(d=>{m.appendChild(d.cloneNode(!0))}))}),document.documentElement.innerHTML=i.documentElement.innerHTML,!0}catch(n){return console.error("Failed to inject layout:",n),!1}}a(Le,"injectLayout");function I(e,t){if(!t)return;let n=t.trim();if(e[n])return e[n];let o=n[0].toUpperCase()+n.slice(1).toLowerCase();if(e[o])return e[o];let l=n.toUpperCase();if(e[l])return e[l];let i=n.toLowerCase(),r=Object.entries(e).find(([p,b])=>p.toLowerCase()===i);if(r)return r[1]}a(I,"lookupComponent");async function oe(e){var f;let t=e||A.route,n=await Le(),{componentKey:o,componentName:l,params:i}=ie(t),r=new Set,p=l,b=document.querySelectorAll("[data-component]");for(let c of b){let m=c.getAttribute("data-component"),d=m==null?void 0:m.toLowerCase();if(typeof rvs_map_sigment<"u"&&rvs_map_sigment!==null?p=I(rvs_map_sigment,m):p=d,!p||r.has(p))continue;let y=I(t,p);try{c.hasChildNodes()&&(globalThis.__CURRENT_COMPONENT__=m);let h=y?await Oe(y):await Me(A.loadAtRunTime,p),s=y?{...i,...ne(c)}:ne(c),u=h.default(s);u.funcName=l.toLowerCase();let E=(f=c.closest("[data-part]"))==null?void 0:f.getAttribute("data-part");u.datapart=E,u.setAttribute("data-component",m),u.hydrate=!0,c.cmpNbr=R,Y(c,u),le.set(p,R),R++,$=0}catch(h){console.warn(`Component "${d}" failed to load`,h)}}}a(oe,"hydrateComponent");async function Oe(e){if(!O.has(e)){let t=await e.loader();O.set(e,t)}return O.get(e)}a(Oe,"loadModule");async function Me(e,t){let n=I(e,t);if(n){if(O.has(n))return O.get(n);try{let o=await n();return O.set(n,o),o}catch(o){console.error(`Component "${t}" failed to load`,o)}}}a(Me,"loadModuleFromFile");function Ye(e,t){if(e===void 0){oe();return}if(typeof e=="object"&&t===void 0){oe(e);return}let n=typeof e=="string"?document.getElementById(e):e;if(!n)throw new Error("Mount target not found: "+e);n.hasChildNodes()?Y(n,t):n.replaceChildren(t)}a(Ye,"mount");function Y(e,t){if(e.hasChildNodes()){let l=[t,...t.querySelectorAll("*")],i=[e,...e.querySelectorAll("*")];l.forEach((r,p)=>{let b=i[p];if(b){r.dataset.index=p;for(let f of r.getAttributeNames()){let c=r.getAttribute(f);if(b.getAttribute(f)!==c){if(f==="data-component"||f==="data-index")continue;b.setAttribute(f,c)}}r.nodeType===Node.TEXT_NODE&&r.nodeValue!==b.nodeValue&&(b.nodeValue=r.nodeValue),r._handlers&&r._handlers.forEach(({type:f,val:c})=>{b.addEventListener(f,m=>{A.stopPropagation&&m.stopPropagation(),c(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,r=>{A.stopPropagation&&r.stopPropagation(),i(r)});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],r=n[l];i&&r?Y(i,r):r?e.appendChild(r):i&&e.removeChild(i)}}a(Y,"hydrate");export{qe as IsEmpty,A as MyApp,pe as Navigate,Ve as NavigateTo,Ie as Route,Ge as addSigment,We as clearComponentCache,K as createEffect,Je as createElement,$e as createGlobalSignal,ze as createSigment,Ce as createSignal,Ke as fetchCache,Fe as getCookie,Pe as getGlobalSignal,De as getStorage,H as getVirtualElementById,$e as globalSignal,H as gve,te as gvec,q as h,oe as hydrateComponent,Ne as loadFunc,Ae as loadRunFunc,_e as memoizeFunc,Ye as mount,ve as onPaint,Be as paintFinish,ie as parsePath,ee as rpc,je as setCookie,He as setStorage,Ce as signal,Ue as updateNodeIfNeeded,Pe as useGlobalSignal};
|
package/dist/ssr.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import A from"fs";import f from"fs/promises";import i from"path";import{pathToFileURL as R,fileURLToPath as F}from"url";import{execSync as v}from"child_process";import{createRequire as q}from"module";var M=q(import.meta.url),j=F(import.meta.url),rt=i.dirname(j),k={COMPONENTS_PATH:"src/components",HTML_FOLDER_PATH:"src/html",OUT_DIR:"dist"},E=i.resolve(process.cwd(),"ssr.config.js"),C={};try{await A.promises.access(E);let t=await import(R(E).href);C=t.default||t}catch{console.warn("\u26A0\uFE0F No ssr.config.js found, using defaults")}var m={...k,...C};function $(){return parseInt(process.versions.node.split(".")[0],10)<20?"4":"latest"}function P(t,e="latest"){try{M.resolve(t),console.log(`\u2705 ${t} is already installed.`)}catch{console.log(`\u{1F4E6} ${t} not found, installing ${e}...`),v(`npm install ${t}@${e}`,{stdio:"inherit"}),console.log(`\u2705 ${t} installed successfully.`),console.log("\u{1F501} Restarting script to load newly installed modules..."),v(`node "${j}"`,{stdio:"inherit"}),process.exit()}}P("vite",$());P("jsdom");var I=M.resolve("vite"),S=await import(R(I).href),{build:U}=S.build?S:S.default,G=m.COMPONENTS_PATH.split("/")[0]||m.COMPONENTS_PATH,V=m.OUT_DIR.split("/")[0]||m.OUT_DIR,Y=i.resolve("./"+G),T=i.resolve("./"+V);A.mkdirSync(T,{recursive:!0});function x(t){let e="";for(;t>=0;)e=String.fromCharCode(t%26+65)+e,t=Math.floor(t/26)-1;return e}async function B(){await U({build:{minify:!0,rollupOptions:{input:i.join(Y,"Main.js"),output:{dir:T,entryFileNames:"bundle.js",chunkFileNames:"chunks/chunk-[name]-[hash].js",assetFileNames:"assets/[name]-[hash][extname]"}}},plugins:[{name:"component-map-generator",generateBundle(t,e){let s={},n={},o=0;for(let a of Object.values(e))if(a.type==="chunk"){let r=x(o++);s[a.name]=r,n[r]=a.name}let c={...s,...n},l=`
|
|
3
|
+
|
|
4
|
+
// --- bidirectional component map ---
|
|
5
|
+
const rvs_map_sigment = ${JSON.stringify(c,null,2)};
|
|
6
|
+
export { rvs_map_sigment };
|
|
7
|
+
`;A.writeFileSync(i.join(T,"component-map.json"),JSON.stringify(c,null,2));let d=Object.values(e).find(a=>a.type==="chunk"&&a.isEntry);d&&(d.code+=l),console.log("\u2705 forward map saved to component-map.json"),console.log("\u2705 bidirectional rvs_map_sigment embedded into bundle.js")}}]}),console.log("\u2705 Build completed! bundle.js + chunks are ready in dist/")}var{createServer:J}=await import("vite"),{JSDOM:O}=await import("jsdom"),b=m.HTML_FOLDER_PATH,W=m.COMPONENTS_PATH,D=m.OUT_DIR;async function H(t){let e=[];for(let s of await f.readdir(t,{withFileTypes:!0})){let n=i.join(t,s.name);s.isDirectory()?s.name!=="layouts"&&e.push(...await H(n)):s.isFile()&&s.name.endsWith(".html")&&e.push(n)}return e}async function z(t,e,s,n={}){globalThis.__CURRENT_COMPONENT__=e,globalThis.__SSR_SIGNAL_REGISTRY__||={},globalThis.__HANDLER_REGISTRY__||={};let o=await t.ssrLoadModule(`/${W}/${e}.js`),c=typeof o.default=="function"?await o.default.call(s.defaultView,n):`Missing render fn in ${e}`,l=s.createElement("div");l.innerHTML=c.trim();let d=null;for(let r of l.childNodes)if(r.nodeType===1){d=r;break}d&&d.setAttribute("data-component",e);let a=s.createDocumentFragment();for(;l.firstChild;)a.appendChild(l.firstChild);return a}async function K(t,e){globalThis.__SSR_SIGNAL_REGISTRY__={},globalThis.__HANDLER_REGISTRY__={},globalThis.__SSR_EVENT_MAP__={};let n=new O(await f.readFile(e,"utf-8")).window.document,o,c=n.querySelector("layout");if(c){let r=c.getAttribute("data-layout");if(!r)throw new Error(`No data-layout in ${e}`);let h=i.resolve(b,r),u=await f.readFile(h,"utf-8");o=new O(u).window.document,c.remove();let p=n.querySelector("description")?.getAttribute("data-description");p&&o.querySelector('meta[name="description"]')?.setAttribute("content",p);let N=n.querySelector("keywords")?.getAttribute("data-keywords");N&&o.querySelector('meta[name="keywords"]')?.setAttribute("content",N),n.querySelectorAll("[data-part]").forEach(y=>{let g=y.getAttribute("data-part"),w=o.querySelector(`[data-part="${g}"]`);if(w){w.innerHTML="";for(let L of y.childNodes)w.appendChild(o.importNode(L,!0))}}),n.querySelectorAll("script[type='module']").forEach(y=>{let g=y.getAttribute("src");g&&!o.querySelector(`script[src="${g}"]`)&&o.body.appendChild(y.cloneNode(!0))})}else o=n;let l=o.querySelectorAll("[data-component][runAtServer]");for(let r of l){let h=r.getAttribute("data-component"),u={};for(let p of r.attributes)p.name.startsWith("data-prop-")&&(u[p.name.slice(10)]=p.value);let _=await z(t,h,o,u);r.replaceWith(_)}let d=i.join(D,"component-map.json"),a=JSON.parse(await f.readFile(d,"utf-8"));return o.querySelectorAll("[data-component]").forEach(r=>{let h=r.getAttribute("data-component"),u=Object.keys(a).find(_=>_.toLowerCase()===h.toLowerCase());u&&(console.log("componentMap",a[u]),r.setAttribute("data-component",a[u]))}),o.querySelectorAll("layout, description, keywords").forEach(r=>r.remove()),`<!DOCTYPE html>
|
|
8
|
+
`+o.documentElement.outerHTML}async function Q(){let t=await J({server:{middlewareMode:!0},root:process.cwd(),ssr:{noExternal:!0}}),e=await H(b);for(let s of e){let n=i.join(D,i.relative(b,s));await f.mkdir(i.dirname(n),{recursive:!0}),await f.writeFile(n,await K(t,s),"utf-8")}await t.close()}(async()=>{try{await B(),await Q().catch(t=>{console.error(t),process.exit(1)}),console.log("\u{1F389} All components built and HTML rendered successfully!")}catch(t){console.error("\u274C Build failed:",t),process.exit(1)}})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sigment",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "A lightweight reactive JavaScript framework built with signals and vanilla JS — no virtual DOM, no JSX, no transpilation.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -12,7 +12,11 @@
|
|
|
12
12
|
"types": "./types/index.d.ts",
|
|
13
13
|
"import": "./dist/index.js",
|
|
14
14
|
"require": "./throw-on-require.js"
|
|
15
|
-
|
|
15
|
+
},
|
|
16
|
+
"./ssr": {
|
|
17
|
+
"types": "./types/ssr.d.ts",
|
|
18
|
+
"import": "./dist/ssr.js"
|
|
19
|
+
}
|
|
16
20
|
},
|
|
17
21
|
"type": "module",
|
|
18
22
|
"types": "./types/index.d.ts",
|
|
@@ -25,6 +29,7 @@
|
|
|
25
29
|
],
|
|
26
30
|
"scripts": {
|
|
27
31
|
"build": "esbuild index.js --bundle --format=esm --minify --keep-names --target=es2020,chrome90,firefox88,safari15 --outfile=dist/index.js",
|
|
32
|
+
"build:ssr": "esbuild ssr.js --bundle --minify --platform=node --format=esm --target=esnext --outfile=dist/ssr.js --external:vite --external:jsdom",
|
|
28
33
|
"prepare": "npm run build"
|
|
29
34
|
},
|
|
30
35
|
"devDependencies": {
|
package/types/index.d.ts
CHANGED
|
@@ -24,11 +24,20 @@ export type RoutesMap = Record<string, Route | string>;
|
|
|
24
24
|
*/
|
|
25
25
|
export declare const MyApp: {
|
|
26
26
|
cleanHtml: (flag: boolean) => void;
|
|
27
|
-
cleanhtml:
|
|
27
|
+
cleanhtml: boolean;
|
|
28
28
|
setMaxCacheSize: (size: number) => void;
|
|
29
29
|
maxCacheSize: number;
|
|
30
|
-
setRoute: (routes: RoutesMap) => void;
|
|
31
|
-
route: RoutesMap | null;
|
|
30
|
+
setRoute: (routes: RoutesMap) => void;
|
|
31
|
+
route: RoutesMap | null;
|
|
32
|
+
setloadAtRunTime: (loadAtRunTime: LoadAtRunTime) => void;
|
|
33
|
+
loadAtRunTime: LoadAtRunTime | null;
|
|
34
|
+
setStopPropagation: (flag: boolean) => void;
|
|
35
|
+
stopPropagation: boolean;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type LoadAtRunTime = {
|
|
39
|
+
defaultKey: string;
|
|
40
|
+
[key: string]: string | (() => Promise<any>);
|
|
32
41
|
};
|
|
33
42
|
|
|
34
43
|
|
|
@@ -38,6 +47,7 @@ export function NavigateTo(path: string, key: string): Promise<void>;
|
|
|
38
47
|
export function NavigateTo(path: string, key: string, stateful: boolean): Promise<void>;
|
|
39
48
|
export function NavigateTo(path: string, map: ComponentMap, stateful: boolean): Promise<void>;
|
|
40
49
|
export function NavigateTo(path: string, map: ComponentMap, key: string, stateful: boolean): Promise<void>;
|
|
50
|
+
export function NavigateTo(path: string, map: ComponentMap, key: string, stateful: boolean, partOrEvent: any): Promise<void>;
|
|
41
51
|
|
|
42
52
|
|
|
43
53
|
|
package/types/ssr.d.ts
ADDED
|
File without changes
|