@akashjs/runtime 0.2.1 → 0.2.6
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/{chunk-NVZLEJXB.cjs → chunk-2Q6SYE5O.cjs} +2 -2
- package/dist/{chunk-NVZLEJXB.cjs.map → chunk-2Q6SYE5O.cjs.map} +1 -1
- package/dist/chunk-2U643GJZ.cjs +2 -0
- package/dist/chunk-2U643GJZ.cjs.map +1 -0
- package/dist/chunk-35DJOBEO.cjs +2 -0
- package/dist/chunk-35DJOBEO.cjs.map +1 -0
- package/dist/{chunk-POLTPHUA.js → chunk-3GRR4VW2.js} +3 -3
- package/dist/{chunk-3AL2DVPZ.cjs.map → chunk-3GRR4VW2.js.map} +1 -1
- package/dist/{chunk-Z5LQV5ND.js → chunk-5A7KDBDU.js} +2 -2
- package/dist/{chunk-Z5LQV5ND.js.map → chunk-5A7KDBDU.js.map} +1 -1
- package/dist/{chunk-D6QQYZIC.js → chunk-5NHDEY2C.js} +2 -2
- package/dist/chunk-5NHDEY2C.js.map +1 -0
- package/dist/{chunk-NQVWTQ2I.cjs → chunk-6GGYM5SF.cjs} +3 -3
- package/dist/{chunk-NQVWTQ2I.cjs.map → chunk-6GGYM5SF.cjs.map} +1 -1
- package/dist/chunk-AVVJKYT3.cjs +2 -0
- package/dist/chunk-AVVJKYT3.cjs.map +1 -0
- package/dist/{chunk-3AL2DVPZ.cjs → chunk-EEILP4OL.cjs} +3 -3
- package/dist/chunk-EEILP4OL.cjs.map +1 -0
- package/dist/{chunk-BT6HNBE7.js → chunk-FTTNKDZQ.js} +3 -3
- package/dist/{chunk-BT6HNBE7.js.map → chunk-FTTNKDZQ.js.map} +1 -1
- package/dist/chunk-H2HNKYN2.js +2 -0
- package/dist/chunk-H2HNKYN2.js.map +1 -0
- package/dist/chunk-TKFJGLUO.js +2 -0
- package/dist/chunk-TKFJGLUO.js.map +1 -0
- package/dist/chunk-U53YRJNV.js +36 -0
- package/dist/chunk-U53YRJNV.js.map +1 -0
- package/dist/chunk-ZYVQQ5VR.cjs +36 -0
- package/dist/chunk-ZYVQQ5VR.cjs.map +1 -0
- package/dist/{context-2uQ6fuxu.d.ts → context-CB1mCq2h.d.cts} +1 -1
- package/dist/{context-2uQ6fuxu.d.cts → context-CB1mCq2h.d.ts} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.d.cts +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +1 -1
- package/dist/devtools-overlay-CJWKBTP4.js +57 -0
- package/dist/devtools-overlay-CJWKBTP4.js.map +1 -0
- package/dist/devtools-overlay-EQ3G755P.cjs +57 -0
- package/dist/devtools-overlay-EQ3G755P.cjs.map +1 -0
- package/dist/index.cjs +18 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -7
- package/dist/index.d.ts +11 -7
- package/dist/index.js +18 -18
- package/dist/index.js.map +1 -1
- package/dist/machine.cjs +1 -1
- package/dist/machine.js +1 -1
- package/dist/offline.cjs +1 -1
- package/dist/offline.d.cts +2 -0
- package/dist/offline.d.ts +2 -0
- package/dist/offline.js +1 -1
- package/dist/pwa.cjs +1 -1
- package/dist/pwa.d.cts +5 -1
- package/dist/pwa.d.ts +5 -1
- package/dist/pwa.js +1 -1
- package/dist/ssr.cjs +1 -1
- package/dist/ssr.js +1 -1
- package/dist/store.cjs +1 -1
- package/dist/store.d.cts +35 -36
- package/dist/store.d.ts +35 -36
- package/dist/store.js +1 -1
- package/dist/sync.cjs +1 -1
- package/dist/sync.d.cts +59 -4
- package/dist/sync.d.ts +59 -4
- package/dist/sync.js +1 -1
- package/dist/test.cjs +4 -4
- package/dist/test.cjs.map +1 -1
- package/dist/test.d.cts +71 -3
- package/dist/test.d.ts +71 -3
- package/dist/test.js +4 -4
- package/dist/test.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-6NX6JRSV.cjs +0 -32
- package/dist/chunk-6NX6JRSV.cjs.map +0 -1
- package/dist/chunk-772SU4MG.js +0 -2
- package/dist/chunk-772SU4MG.js.map +0 -1
- package/dist/chunk-7LQZF3XA.cjs +0 -2
- package/dist/chunk-7LQZF3XA.cjs.map +0 -1
- package/dist/chunk-D6QQYZIC.js.map +0 -1
- package/dist/chunk-H4SAK7A5.cjs +0 -2
- package/dist/chunk-H4SAK7A5.cjs.map +0 -1
- package/dist/chunk-IM2VW4TK.js +0 -32
- package/dist/chunk-IM2VW4TK.js.map +0 -1
- package/dist/chunk-ODDXU5DO.js +0 -2
- package/dist/chunk-ODDXU5DO.js.map +0 -1
- package/dist/chunk-POLTPHUA.js.map +0 -1
- package/dist/chunk-YIB4EKVI.cjs +0 -2
- package/dist/chunk-YIB4EKVI.cjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkEEILP4OL_cjs=require('./chunk-EEILP4OL.cjs');var w={AK0010:{code:"AK0010",message:"provide() called outside of component setup.",hint:"provide() must be called inside defineComponent()."},AK0012:{code:"AK0012",message:"inject() called outside of component setup.",hint:"inject() must be called inside defineComponent()."},AK0013:{code:"AK0013",message:"No provider found for injected context.",hint:"Make sure an ancestor component calls provide() with this key."},AK0020:{code:"AK0020",message:"onMount() called outside of component setup.",hint:"onMount() must be called inside defineComponent()."},AK0021:{code:"AK0021",message:"onUnmount() called outside of component setup.",hint:"onUnmount() must be called inside defineComponent()."},AK0022:{code:"AK0022",message:"onError() called outside of component setup.",hint:"onError() must be called inside defineComponent()."},AK0030:{code:"AK0030",message:"Circular dependency detected in computed signal.",hint:"A computed signal is reading itself, directly or via other computeds."},AK0031:{code:"AK0031",message:"Signal set() called during computation.",hint:"Do not set signals inside computed() or during effect execution. Use batch() or set signals in event handlers."},AK0040:{code:"AK0040",message:"Component setup must return a render function.",hint:"The function passed to defineComponent() must return () => AkashNode."},AK0041:{code:"AK0041",message:"Required prop is missing.",hint:"Check that the parent component is passing all required props."},AK0050:{code:"AK0050",message:"useRoute() called outside of router context.",hint:"Make sure your component is rendered inside a router provider."},AK0051:{code:"AK0051",message:"No route matched the current URL.",hint:"Add a catch-all route ([...rest]) to handle unmatched paths."},AK0052:{code:"AK0052",message:"Route guard threw an error.",hint:"Check the guard function for unhandled exceptions."},AK0060:{code:"AK0060",message:"Form submitted while invalid.",hint:"The submit handler was not called because validation failed. Check form.errors()."},AK0061:{code:"AK0061",message:"Async validator timed out.",hint:"The async validator did not resolve within the expected time. Check your async validation logic."},AK0070:{code:"AK0070",message:"HTTP request failed.",hint:"Check the server response status and network connectivity."},AK0071:{code:"AK0071",message:"createResource() fetcher threw an error.",hint:"Check the fetcher function passed to createResource()."}},P="https://akashjs.dev/errors";function R(e,n){let o=w[e];if(!o)return `[AkashJS ${e}] Unknown error code.`;let s=`[AkashJS ${e}] ${o.message}`;return n&&(s+=`
|
|
2
2
|
${n}`),s+=`
|
|
3
3
|
${o.hint}`,s+=`
|
|
4
|
-
See: ${P}/${e}`,s}function T(e,n){return new Error(R(e,n))}function F(e){return w[e]}function _(){return Object.keys(w)}var D=Symbol("akash.context"),m=null;function S(e=m){let n={values:new Map,parent:e};return m=n,n}function K(e){m=e.parent;}function C(){return m}function v(e,n){let o=m;m=e;try{return n()}finally{m=o;}}function O(e){return {[D]:true,_type:void 0,defaultValue:e,id:Symbol("context")}}function $(e,n){if(!m)throw T("AK0010");m.values.set(e.id,n);}function U(e,n){if(!m)throw T("AK0012");let o=m;for(;o;){if(o.values.has(e.id))return o.values.get(e.id);o=o.parent;}if(n!==void 0)return n;if(e.defaultValue!==void 0)return e.defaultValue;throw T("AK0013")}function W(e,n){let o=document.createElement(e);if(n)for(let[s,a]of Object.entries(n))b(o,s,a);return o}function X(e){return document.createTextNode(e)}function G(e){let n=document.createElement("template");return n.innerHTML=e,n.content.cloneNode(true)}function b(e,n,o){if(n==="class"||n==="className")e.className=o;else if(n==="style"&&typeof o=="object"&&o!==null)Object.assign(e.style,o);else if(n==="innerHTML")e.innerHTML=o;else if(n!=="ref")if(n.startsWith("on")){let s=n.slice(2).toLowerCase();e.addEventListener(s,o);}else n in e?e[n]=o:o===false||o==null?e.removeAttribute(n):e.setAttribute(n,o===true?"":String(o));}function Y(e,n){return
|
|
5
|
-
//# sourceMappingURL=chunk-
|
|
4
|
+
See: ${P}/${e}`,s}function T(e,n){return new Error(R(e,n))}function F(e){return w[e]}function _(){return Object.keys(w)}var D=Symbol("akash.context"),m=null;function S(e=m){let n={values:new Map,parent:e};return m=n,n}function K(e){m=e.parent;}function C(){return m}function v(e,n){let o=m;m=e;try{return n()}finally{m=o;}}function O(e){return {[D]:true,_type:void 0,defaultValue:e,id:Symbol("context")}}function $(e,n){if(!m)throw T("AK0010");m.values.set(e.id,n);}function U(e,n){if(!m)throw T("AK0012");let o=m;for(;o;){if(o.values.has(e.id))return o.values.get(e.id);o=o.parent;}if(n!==void 0)return n;if(e.defaultValue!==void 0)return e.defaultValue;throw T("AK0013")}function W(e,n){let o=document.createElement(e);if(n)for(let[s,a]of Object.entries(n))b(o,s,a);return o}function X(e){return document.createTextNode(e)}function G(e){let n=document.createElement("template");return n.innerHTML=e,n.content.cloneNode(true)}function b(e,n,o){if(n==="class"||n==="className")e.className=o;else if(n==="style"&&typeof o=="object"&&o!==null)Object.assign(e.style,o);else if(n==="innerHTML")e.innerHTML=o;else if(n!=="ref")if(n.startsWith("on")){let s=n.slice(2).toLowerCase();e.addEventListener(s,o);}else n in e?e[n]=o:o===false||o==null?e.removeAttribute(n):e.setAttribute(n,o===true?"":String(o));}function Y(e,n){return chunkEEILP4OL_cjs.n(()=>{e.textContent=String(n());},{render:true})}function z(e,n,o){return chunkEEILP4OL_cjs.n(()=>{b(e,n,o());},{render:true})}function Q(e,n){return chunkEEILP4OL_cjs.n(()=>{e.style.display=n()?"":"none";},{render:true})}function L(e=""){return document.createComment(e)}function j(e,n,o,s,a){let i=null,g=C(),y=chunkEEILP4OL_cjs.n(()=>{let c=o();if(i){for(let f of i.nodes)try{f.parentNode?.removeChild(f);}catch{}i.dispose?.(),i=null;}let d=c?s:a,p=n.parentNode;if(!p&&i?.nodes[0]?.parentNode&&(p=i.nodes[0].parentNode),d&&p){let f=g?v(g,d):d(),t=f instanceof DocumentFragment?Array.from(f.childNodes):[f];for(let r of t)p.insertBefore(r,n);i={nodes:t,dispose:null};}},{render:true});return ()=>{if(y(),i){for(let c of i.nodes)try{c.parentNode?.removeChild(c);}catch{}i.dispose?.();}}}function H(e,n,o,s,a){let i=[],g=C(),y=chunkEEILP4OL_cjs.n(()=>{let c=o(),d=[],p=new Map;for(let t of i)p.set(t.key,t);for(let t=0;t<c.length;t++){let r=c[t],u=s(r,t),l=p.get(u);if(l){p.delete(u);let A=l.nodes[0];if(A&&!A.parentNode){let k=g?v(g,()=>a(r,t)):a(r,t),M=k instanceof DocumentFragment?Array.from(k.childNodes):[k];d.push({key:u,value:r,nodes:M,dispose:null});}else l.value=r,d.push(l);}else {let A=g?v(g,()=>a(r,t)):a(r,t),k=A instanceof DocumentFragment?Array.from(A.childNodes):[A];d.push({key:u,value:r,nodes:k,dispose:null});}}for(let t of p.values()){for(let r of t.nodes)r.parentNode&&r.parentNode.removeChild(r);t.dispose?.();}let f=n.parentNode;if(f)for(let t of d)for(let r of t.nodes)f.insertBefore(r,n);else {let t=null;for(let r of i)if(r.nodes[0]?.parentNode){t=r.nodes[0].parentNode;break}if(t)for(let r of d)for(let u of r.nodes)t.appendChild(u);}i=d;},{render:true});return ()=>{y();for(let c of i){for(let d of c.nodes)d.parentNode&&d.parentNode.removeChild(d);c.dispose?.();}i=[];}}function Z(e){let n=L("show"),o=document.createDocumentFragment();o.appendChild(n);let s=typeof e.when=="function"?e.when:()=>e.when,a;return j(o,n,()=>(a=s(),!!a),()=>x(e.children(a)),e.fallback?()=>x(e.fallback()):void 0),o}function ee(e){let n=L("for"),o=document.createDocumentFragment();o.appendChild(n);let s=typeof e.each=="function"?e.each:()=>e.each;return H(o,n,s,e.key,(a,i)=>x(e.children(a,i))),o}function x(e){if(e==null||typeof e=="boolean")return document.createTextNode("");if(typeof e=="string"||typeof e=="number")return document.createTextNode(String(e));if(e instanceof Node)return e;if(Array.isArray(e)){let n=document.createDocumentFragment();for(let o of e)n.appendChild(x(o));return n}return document.createTextNode(String(e))}function ne(e,n,o){let s=x(n);o?e.insertBefore(s,o):e.appendChild(s);}function de(e){return e.__reactive=true,e}var h=null;function ae(e){if(!h)throw T("AK0020");h.mount.push(e);}function ue(e){if(!h)throw T("AK0021");h.unmount.push(e);}function le(e){if(!h)throw T("AK0022");h.error.push(e);}function fe(e){return {current:e}}function pe(e){let n=o=>{let{children:s,...a}=o??{},y={props:a,children:typeof s=="function"?s:()=>s??null},c={mount:[],unmount:[],error:[]},d=h;h=c;let p=C(),f=S(p),t,r;try{r=chunkEEILP4OL_cjs.o(()=>{if(t=e(y),typeof t!="function")throw T("AK0040");let u=t();return x(u)});}catch(u){if(K(f),h=d,c.error.length>0){for(let l of c.error)l(u instanceof Error?u:new Error(String(u)));return document.createComment("error")}throw u}return K(f),h=d,c.mount.length>0&&queueMicrotask(()=>{for(let u of c.mount)try{let l=u();typeof l=="function"&&c.unmount.push(l);}catch(l){for(let A of c.error)A(l instanceof Error?l:new Error(String(l)));}}),r};return n._akash=true,n}exports.A=fe;exports.B=pe;exports.a=R;exports.b=T;exports.c=F;exports.d=_;exports.e=C;exports.f=v;exports.g=O;exports.h=$;exports.i=U;exports.j=W;exports.k=X;exports.l=G;exports.m=b;exports.n=Y;exports.o=z;exports.p=Q;exports.q=j;exports.r=H;exports.s=Z;exports.t=ee;exports.u=x;exports.v=ne;exports.w=de;exports.x=ae;exports.y=ue;exports.z=le;//# sourceMappingURL=chunk-6GGYM5SF.cjs.map
|
|
5
|
+
//# sourceMappingURL=chunk-6GGYM5SF.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.ts","../src/context.ts","../src/dom.ts","../src/component.ts"],"names":["errors","DOC_BASE","formatError","code","context","def","msg","akashError","getErrorDef","getAllErrorCodes","CONTEXT_BRAND","currentScope","pushScope","parent","scope","popScope","getCurrentScope","runInScope","fn","prev","createContext","defaultValue","provide","key","value","inject","fallback","createElement","tag","attrs","el","setProperty","createText","cloneTemplate","html","template","event","bindText","node","effect","bindProperty","bindVisible","createAnchor","label","renderConditional","anchor","condition","trueBranch","falseBranch","current","dispose","branch","liveParent","fragment","nodes","renderList","items","keyFn","renderItem","currentItems","newData","newItems","oldMap","item","i","data","existing","firstNode","realParent","Show","props","container","getWhen","whenValue","nodeToDOM","For","getEach","index","child","insert","domNode","__getter","currentHooks","onMount","onUnmount","onError","ref","initialValue","defineComponent","setup","component","rawProps","childrenProp","restProps","ctx","hooks","prevHooks","parentScope","renderFn","untrack","rendered","err","handler","mountFn","cleanup"],"mappings":"mEAqBA,IAAMA,EAAmC,CAEvC,MAAA,CAAQ,CACN,IAAA,CAAM,QAAA,CACN,QAAS,8CAAA,CACT,IAAA,CAAM,oDACR,CAAA,CACA,MAAA,CAAQ,CACN,IAAA,CAAM,QAAA,CACN,QAAS,6CAAA,CACT,IAAA,CAAM,mDACR,CAAA,CACA,MAAA,CAAQ,CACN,IAAA,CAAM,QAAA,CACN,QAAS,yCAAA,CACT,IAAA,CAAM,gEACR,CAAA,CAGA,MAAA,CAAQ,CACN,IAAA,CAAM,QAAA,CACN,QAAS,8CAAA,CACT,IAAA,CAAM,oDACR,CAAA,CACA,MAAA,CAAQ,CACN,IAAA,CAAM,QAAA,CACN,QAAS,gDAAA,CACT,IAAA,CAAM,sDACR,CAAA,CACA,OAAQ,CACN,IAAA,CAAM,SACN,OAAA,CAAS,8CAAA,CACT,KAAM,oDACR,CAAA,CAGA,OAAQ,CACN,IAAA,CAAM,SACN,OAAA,CAAS,kDAAA,CACT,KAAM,uEACR,CAAA,CACA,OAAQ,CACN,IAAA,CAAM,SACN,OAAA,CAAS,yCAAA,CACT,KAAM,gHACR,CAAA,CAGA,OAAQ,CACN,IAAA,CAAM,SACN,OAAA,CAAS,gDAAA,CACT,KAAM,uEACR,CAAA,CACA,O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chunk-NQVWTQ2I.cjs","sourcesContent":["/**\n * Error message catalog.\n *\n * Every AkashJS runtime error has a unique code (AK0001, AK0002, etc.),\n * a one-line description, and a link to detailed documentation.\n *\n * Usage:\n * throw akashError('AK0010', 'provide()');\n */\n\n// --- Error registry ---\n\nexport interface ErrorDef {\n /** Error code */\n code: string;\n /** Short description */\n message: string;\n /** Extended explanation and fix suggestion */\n hint: string;\n}\n\nconst errors: Record<string, ErrorDef> = {\n // --- Context errors (AK001x) ---\n AK0010: {\n code: 'AK0010',\n message: 'provide() called outside of component setup.',\n hint: 'provide() must be called inside defineComponent().',\n },\n AK0012: {\n code: 'AK0012',\n message: 'inject() called outside of component setup.',\n hint: 'inject() must be called inside defineComponent().',\n },\n AK0013: {\n code: 'AK0013',\n message: 'No provider found for injected context.',\n hint: 'Make sure an ancestor component calls provide() with this key.',\n },\n\n // --- Lifecycle errors (AK002x) ---\n AK0020: {\n code: 'AK0020',\n message: 'onMount() called outside of component setup.',\n hint: 'onMount() must be called inside defineComponent().',\n },\n AK0021: {\n code: 'AK0021',\n message: 'onUnmount() called outside of component setup.',\n hint: 'onUnmount() must be called inside defineComponent().',\n },\n AK0022: {\n code: 'AK0022',\n message: 'onError() called outside of component setup.',\n hint: 'onError() must be called inside defineComponent().',\n },\n\n // --- Signal errors (AK003x) ---\n AK0030: {\n code: 'AK0030',\n message: 'Circular dependency detected in computed signal.',\n hint: 'A computed signal is reading itself, directly or via other computeds.',\n },\n AK0031: {\n code: 'AK0031',\n message: 'Signal set() called during computation.',\n hint: 'Do not set signals inside computed() or during effect execution. Use batch() or set signals in event handlers.',\n },\n\n // --- Component errors (AK004x) ---\n AK0040: {\n code: 'AK0040',\n message: 'Component setup must return a render function.',\n hint: 'The function passed to defineComponent() must return () => AkashNode.',\n },\n AK0041: {\n code: 'AK0041',\n message: 'Required prop is missing.',\n hint: 'Check that the parent component is passing all required props.',\n },\n\n // --- Router errors (AK005x) ---\n AK0050: {\n code: 'AK0050',\n message: 'useRoute() called outside of router context.',\n hint: 'Make sure your component is rendered inside a router provider.',\n },\n AK0051: {\n code: 'AK0051',\n message: 'No route matched the current URL.',\n hint: 'Add a catch-all route ([...rest]) to handle unmatched paths.',\n },\n AK0052: {\n code: 'AK0052',\n message: 'Route guard threw an error.',\n hint: 'Check the guard function for unhandled exceptions.',\n },\n\n // --- Form errors (AK006x) ---\n AK0060: {\n code: 'AK0060',\n message: 'Form submitted while invalid.',\n hint: 'The submit handler was not called because validation failed. Check form.errors().',\n },\n AK0061: {\n code: 'AK0061',\n message: 'Async validator timed out.',\n hint: 'The async validator did not resolve within the expected time. Check your async validation logic.',\n },\n\n // --- HTTP errors (AK007x) ---\n AK0070: {\n code: 'AK0070',\n message: 'HTTP request failed.',\n hint: 'Check the server response status and network connectivity.',\n },\n AK0071: {\n code: 'AK0071',\n message: 'createResource() fetcher threw an error.',\n hint: 'Check the fetcher function passed to createResource().',\n },\n};\n\n// --- Public API ---\n\nconst DOC_BASE = 'https://akashjs.dev/errors';\n\n/**\n * Format an AkashJS error with code, message, hint, and doc link.\n */\nexport function formatError(code: string, context?: string): string {\n const def = errors[code];\n if (!def) {\n return `[AkashJS ${code}] Unknown error code.`;\n }\n\n let msg = `[AkashJS ${code}] ${def.message}`;\n if (context) {\n msg += `\\n ${context}`;\n }\n msg += `\\n ${def.hint}`;\n msg += `\\n See: ${DOC_BASE}/${code}`;\n return msg;\n}\n\n/**\n * Create and throw an AkashJS error.\n */\nexport function akashError(code: string, context?: string): Error {\n return new Error(formatError(code, context));\n}\n\n/**\n * Get the error definition for a code.\n */\nexport function getErrorDef(code: string): ErrorDef | undefined {\n return errors[code];\n}\n\n/**\n * Get all registered error codes.\n */\nexport function getAllErrorCodes(): string[] {\n return Object.keys(errors);\n}\n","/**\n * Lightweight dependency injection via provide/inject.\n *\n * Context is scoped to the component tree — no injector hierarchy,\n * no decorators, no classes. Just createContext(), provide(), inject().\n */\n\n// --- Types ---\n\nimport { akashError } from './errors.js';\n\nconst CONTEXT_BRAND = Symbol('akash.context');\n\nexport interface InjectionKey<T> {\n readonly [CONTEXT_BRAND]: true;\n readonly _type: T; // phantom type — never used at runtime\n readonly defaultValue: T | undefined;\n readonly id: symbol;\n}\n\n// --- Context stack (managed by component system) ---\n\ninterface ContextScope {\n values: Map<symbol, unknown>;\n parent: ContextScope | null;\n}\n\nlet currentScope: ContextScope | null = null;\n\n/** @internal — called by defineComponent to push/pop context scopes */\nexport function pushScope(parent: ContextScope | null = currentScope): ContextScope {\n const scope: ContextScope = { values: new Map(), parent };\n currentScope = scope;\n return scope;\n}\n\n/** @internal */\nexport function popScope(scope: ContextScope): void {\n currentScope = scope.parent;\n}\n\n/** @internal */\nexport function getCurrentScope(): ContextScope | null {\n return currentScope;\n}\n\n/**\n * Run a function within a given scope so that provide/inject\n * work correctly for components created asynchronously\n * (e.g., lazy-loaded route components).\n */\nexport function runInScope<T>(scope: ContextScope, fn: () => T): T {\n const prev = currentScope;\n currentScope = scope;\n try {\n return fn();\n } finally {\n currentScope = prev;\n }\n}\n\n// --- Public API ---\n\n/**\n * Create a typed context key with an optional default value.\n *\n * ```ts\n * const ThemeContext = createContext<'light' | 'dark'>('light');\n * ```\n */\nexport function createContext<T>(defaultValue?: T): InjectionKey<T> {\n return {\n [CONTEXT_BRAND]: true,\n _type: undefined as T,\n defaultValue,\n id: Symbol('context'),\n };\n}\n\n/**\n * Provide a value for a context key in the current component scope.\n * All descendant components can inject() this value.\n *\n * Must be called inside defineComponent() setup.\n */\nexport function provide<T>(key: InjectionKey<T>, value: T): void {\n if (!currentScope) {\n throw akashError('AK0010');\n }\n currentScope.values.set(key.id, value);\n}\n\n/**\n * Inject a value from the nearest ancestor that provided it.\n *\n * Must be called inside defineComponent() setup.\n */\nexport function inject<T>(key: InjectionKey<T>): T;\nexport function inject<T>(key: InjectionKey<T>, fallback: T): T;\nexport function inject<T>(key: InjectionKey<T>, fallback?: T): T {\n if (!currentScope) {\n throw akashError('AK0012');\n }\n\n // Walk up the scope chain\n let scope: ContextScope | null = currentScope;\n while (scope) {\n if (scope.values.has(key.id)) {\n return scope.values.get(key.id) as T;\n }\n scope = scope.parent;\n }\n\n // Check fallback, then default\n if (fallback !== undefined) return fallback;\n if (key.defaultValue !== undefined) return key.defaultValue;\n\n throw akashError('AK0013');\n}\n","/**\n * Direct DOM rendering runtime.\n *\n * No virtual DOM. The compiler generates calls to these helpers.\n * Signal reads inside templates become fine-grained effects that\n * update only the specific DOM node that changed.\n */\n\nimport { effect } from './signals.js';\nimport { getCurrentScope, runInScope } from './context.js';\nimport type { AkashNode } from './types.js';\n\n// --- DOM creation helpers (used by compiler output) ---\n\n/** Create an element and optionally set static attributes */\nexport function createElement(\n tag: string,\n attrs?: Record<string, unknown>,\n): HTMLElement {\n const el = document.createElement(tag);\n if (attrs) {\n for (const [key, value] of Object.entries(attrs)) {\n setProperty(el, key, value);\n }\n }\n return el;\n}\n\n/** Create a text node */\nexport function createText(value: string): Text {\n return document.createTextNode(value);\n}\n\n/** Clone a template element for static structure */\nexport function cloneTemplate(html: string): DocumentFragment {\n const template = document.createElement('template');\n template.innerHTML = html;\n return template.content.cloneNode(true) as DocumentFragment;\n}\n\n// --- Property/attribute setting ---\n\nexport function setProperty(el: HTMLElement, key: string, value: unknown): void {\n if (key === 'class' || key === 'className') {\n el.className = value as string;\n } else if (key === 'style' && typeof value === 'object' && value !== null) {\n Object.assign(el.style, value);\n } else if (key === 'innerHTML') {\n el.innerHTML = value as string;\n } else if (key === 'ref') {\n // Handled separately by component system\n } else if (key.startsWith('on')) {\n const event = key.slice(2).toLowerCase();\n el.addEventListener(event, value as EventListener);\n } else if (key in el) {\n (el as unknown as Record<string, unknown>)[key] = value;\n } else if (value === false || value == null) {\n el.removeAttribute(key);\n } else {\n el.setAttribute(key, value === true ? '' : String(value));\n }\n}\n\n// --- Reactive binding (used by compiler for dynamic expressions) ---\n\n/** Bind a reactive expression to a text node's content */\nexport function bindText(node: Text, fn: () => unknown): () => void {\n return effect(\n () => {\n node.textContent = String(fn());\n },\n { render: true },\n );\n}\n\n/** Bind a reactive expression to an element's attribute/property */\nexport function bindProperty(\n el: HTMLElement,\n key: string,\n fn: () => unknown,\n): () => void {\n return effect(\n () => {\n setProperty(el, key, fn());\n },\n { render: true },\n );\n}\n\n/** Bind a reactive expression to an element's visibility (display) */\nexport function bindVisible(el: HTMLElement, fn: () => boolean): () => void {\n return effect(\n () => {\n el.style.display = fn() ? '' : 'none';\n },\n { render: true },\n );\n}\n\n// --- Conditional rendering ---\n\n/** Anchor node — comment for normal DOM, hidden element for table contexts */\ntype Anchor = Comment | HTMLElement;\n\n/** Table elements where comment nodes get relocated by the browser */\nconst TABLE_TAGS = new Set(['TABLE', 'THEAD', 'TBODY', 'TFOOT', 'TR']);\n\nfunction createAnchor(label = ''): Anchor {\n return document.createComment(label);\n}\n\n/**\n * Create a table-safe anchor. Browsers relocate comment nodes inside\n * table elements, breaking anchor-based insertion. Use a hidden element instead.\n */\nfunction createTableSafeAnchor(parent: Node): Anchor {\n if (parent instanceof HTMLElement && TABLE_TAGS.has(parent.tagName)) {\n const tag = parent.tagName === 'TR' ? 'td' : 'tr';\n const el = document.createElement(tag);\n el.style.display = 'none';\n return el;\n }\n return document.createComment('');\n}\n\ninterface ConditionalBlock {\n nodes: Node[];\n dispose: (() => void) | null;\n}\n\n/**\n * Render a conditional block. Swaps DOM fragments based on a reactive\n * condition. Used by the compiler for :if directives and <Show>.\n */\nexport function renderConditional(\n parent: Node,\n anchor: Node,\n condition: () => boolean,\n trueBranch: () => Node,\n falseBranch?: () => Node,\n): () => void {\n let current: ConditionalBlock | null = null;\n\n // Capture scope so children created in branches inherit provide/inject context\n const scope = getCurrentScope();\n\n const dispose = effect(\n () => {\n const value = condition();\n\n // Remove old nodes\n if (current) {\n for (const node of current.nodes) {\n try { node.parentNode?.removeChild(node); } catch {}\n }\n current.dispose?.();\n current = null;\n }\n\n // Insert new nodes — use anchor.parentNode since the anchor may have\n // moved from the initial DocumentFragment into the real DOM.\n // In table contexts, the browser may relocate comment anchors.\n const branch = value ? trueBranch : falseBranch;\n let liveParent: Node | null = anchor.parentNode;\n if (!liveParent && (current as ConditionalBlock | null)?.nodes[0]?.parentNode) {\n liveParent = (current as ConditionalBlock | null)!.nodes[0].parentNode;\n }\n if (branch && liveParent) {\n const fragment = scope ? runInScope(scope, branch) : branch();\n const nodes = fragment instanceof DocumentFragment\n ? Array.from(fragment.childNodes)\n : [fragment];\n for (const node of nodes) {\n liveParent.insertBefore(node, anchor);\n }\n current = { nodes, dispose: null };\n }\n },\n { render: true },\n );\n\n return () => {\n dispose();\n if (current) {\n for (const node of current.nodes) {\n try { node.parentNode?.removeChild(node); } catch {}\n }\n current.dispose?.();\n }\n };\n}\n\n// --- List rendering ---\n\ninterface ListItem<T> {\n key: unknown;\n value: T;\n nodes: Node[];\n dispose: (() => void) | null;\n}\n\n/**\n * Render a reactive list with keyed reconciliation.\n * Used by the compiler for :for directives and <For>.\n */\nexport function renderList<T>(\n parent: Node,\n anchor: Node,\n items: () => T[],\n keyFn: (item: T, index: number) => unknown,\n renderItem: (item: T, index: number) => Node,\n): () => void {\n let currentItems: ListItem<T>[] = [];\n\n // Capture scope so children created in renderItem inherit provide/inject context\n const scope = getCurrentScope();\n\n const dispose = effect(\n () => {\n const newData = items();\n const newItems: ListItem<T>[] = [];\n const oldMap = new Map<unknown, ListItem<T>>();\n\n for (const item of currentItems) {\n oldMap.set(item.key, item);\n }\n\n // Build new list, reuse existing DOM nodes when keys match\n for (let i = 0; i < newData.length; i++) {\n const data = newData[i];\n const key = keyFn(data, i);\n const existing = oldMap.get(key);\n\n if (existing) {\n oldMap.delete(key);\n // If the reused item's nodes were detached (e.g., parent removed them),\n // treat as new to avoid stale DOM references\n const firstNode = existing.nodes[0];\n if (firstNode && !firstNode.parentNode) {\n // Nodes were detached — create fresh\n const fragment = scope ? runInScope(scope, () => renderItem(data, i)) : renderItem(data, i);\n const nodes = fragment instanceof DocumentFragment\n ? Array.from(fragment.childNodes)\n : [fragment];\n newItems.push({ key, value: data, nodes, dispose: null });\n } else {\n existing.value = data;\n newItems.push(existing);\n }\n } else {\n const fragment = scope ? runInScope(scope, () => renderItem(data, i)) : renderItem(data, i);\n const nodes = fragment instanceof DocumentFragment\n ? Array.from(fragment.childNodes)\n : [fragment];\n newItems.push({ key, value: data, nodes, dispose: null });\n }\n }\n\n // Remove items that are no longer in the list\n for (const item of oldMap.values()) {\n for (const node of item.nodes) {\n if (node.parentNode) node.parentNode.removeChild(node);\n }\n item.dispose?.();\n }\n\n // Reconcile DOM order — insertBefore moves existing nodes, inserts new ones\n const liveParent = anchor.parentNode;\n if (liveParent) {\n // Normal path — anchor is in the DOM, insert before it\n for (const item of newItems) {\n for (const node of item.nodes) {\n liveParent.insertBefore(node, anchor);\n }\n }\n } else {\n // Table fallback — browser relocated the comment anchor.\n // Find the real parent from any node still in the DOM.\n let realParent: Node | null = null;\n for (const item of currentItems) {\n if (item.nodes[0]?.parentNode) { realParent = item.nodes[0].parentNode; break; }\n }\n if (realParent) {\n // Remove old nodes first (oldMap items already removed above)\n // Then append all new items\n for (const item of newItems) {\n for (const node of item.nodes) {\n realParent.appendChild(node);\n }\n }\n }\n }\n\n currentItems = newItems;\n },\n { render: true },\n );\n\n return () => {\n dispose();\n for (const item of currentItems) {\n for (const node of item.nodes) {\n if (node.parentNode) node.parentNode.removeChild(node);\n }\n item.dispose?.();\n }\n currentItems = [];\n };\n}\n\n// --- Built-in control flow components ---\n\n/** Props for the <Show> component */\nexport interface ShowProps<T> {\n when: (() => T | null | undefined | false) | T | null | undefined | false;\n fallback?: () => AkashNode;\n children: (value: T) => AkashNode;\n}\n\n/**\n * <Show> component — conditionally renders children with type narrowing.\n * The children callback receives the non-null/undefined value.\n * `when` can be a reactive getter or a static value.\n */\nexport function Show<T>(props: ShowProps<T>): Node {\n const anchor = createAnchor('show');\n const container = document.createDocumentFragment();\n container.appendChild(anchor);\n\n // Resolve when — if it's a function, always call it (supports both\n // compiler-generated __reactive getters and plain programmatic functions)\n const getWhen = typeof props.when === 'function'\n ? props.when as () => T | null | undefined | false\n : () => props.when as T | null | undefined | false;\n\n // Capture the when value once per evaluation so the condition check\n // and the children callback receive the same value (fixes nested For contexts)\n let whenValue: T | null | undefined | false;\n renderConditional(\n container,\n anchor,\n () => { whenValue = getWhen(); return !!whenValue; },\n () => nodeToDOM(props.children(whenValue as T)),\n props.fallback ? () => nodeToDOM(props.fallback!()) : undefined,\n );\n\n return container;\n}\n\n/** Props for the <For> component */\nexport interface ForProps<T> {\n each: (() => T[]) | T[];\n key: (item: T) => unknown;\n children: (item: T, index: number) => AkashNode;\n}\n\n/**\n * <For> component — renders a list with keyed reconciliation.\n * `each` can be a reactive getter or a static array.\n */\nexport function For<T>(props: ForProps<T>): Node {\n const anchor = createAnchor('for');\n const container = document.createDocumentFragment();\n container.appendChild(anchor);\n\n // Resolve each — if it's a function, always call it (supports both\n // compiler-generated __reactive getters and plain programmatic functions)\n const getEach = typeof props.each === 'function'\n ? props.each as () => T[]\n : () => props.each as T[];\n\n renderList(\n container,\n anchor,\n getEach,\n props.key,\n (item, index) => nodeToDOM(props.children(item, index)),\n );\n\n return container;\n}\n\n// --- Helpers ---\n\n/** Convert an AkashNode to a DOM Node */\nexport function nodeToDOM(node: AkashNode): Node {\n if (node == null || typeof node === 'boolean') {\n return document.createTextNode('');\n }\n if (typeof node === 'string' || typeof node === 'number') {\n return document.createTextNode(String(node));\n }\n if (node instanceof Node) {\n return node;\n }\n if (Array.isArray(node)) {\n const fragment = document.createDocumentFragment();\n for (const child of node) {\n fragment.appendChild(nodeToDOM(child));\n }\n return fragment;\n }\n return document.createTextNode(String(node));\n}\n\n/** Insert a node into a parent before an anchor */\nexport function insert(parent: Node, node: AkashNode, anchor?: Node): void {\n const domNode = nodeToDOM(node);\n if (anchor) {\n parent.insertBefore(domNode, anchor);\n } else {\n parent.appendChild(domNode);\n }\n}\n","/**\n * Component system.\n *\n * Components are functions. defineComponent() wraps a setup function\n * that runs once, establishes signals and effects, and returns a\n * render function that produces DOM nodes.\n */\n\nimport { effect, untrack } from './signals.js';\nimport { pushScope, popScope, getCurrentScope } from './context.js';\nimport { nodeToDOM } from './dom.js';\nimport { akashError } from './errors.js';\nimport type { AkashNode } from './types.js';\n\n// --- Reactive getter marker (used by compiler) ---\n\n/** Mark a function as a compiler-generated reactive getter */\nexport function __getter<T>(fn: () => T): (() => T) & { __reactive: true } {\n (fn as any).__reactive = true;\n return fn as any;\n}\n\n// --- Types ---\n\nexport interface Ref<T = HTMLElement> {\n current: T | undefined;\n}\n\nexport interface ComponentContext<P extends Record<string, unknown> = Record<string, unknown>> {\n props: Readonly<P>;\n children: () => AkashNode;\n}\n\nexport type Component<P extends Record<string, unknown> = Record<string, unknown>> = {\n (props: P & { children?: AkashNode | (() => AkashNode) }): Node;\n _akash: true;\n};\n\n// --- Lifecycle hook storage ---\n\ninterface LifecycleHooks {\n mount: Array<() => void | (() => void)>;\n unmount: Array<() => void>;\n error: Array<(error: Error) => void>;\n}\n\nlet currentHooks: LifecycleHooks | null = null;\n\n// --- Public lifecycle hooks ---\n\n/**\n * Register a callback to run after the component is mounted to the DOM.\n * If the callback returns a function, it will be called on unmount (cleanup).\n */\nexport function onMount(fn: () => void | (() => void)): void {\n if (!currentHooks) {\n throw akashError('AK0020');\n }\n currentHooks.mount.push(fn);\n}\n\n/**\n * Register a callback to run before the component is unmounted.\n */\nexport function onUnmount(fn: () => void): void {\n if (!currentHooks) {\n throw akashError('AK0021');\n }\n currentHooks.unmount.push(fn);\n}\n\n/**\n * Register an error handler for this component and its descendants.\n */\nexport function onError(fn: (error: Error) => void): void {\n if (!currentHooks) {\n throw akashError('AK0022');\n }\n currentHooks.error.push(fn);\n}\n\n/**\n * Create a ref for accessing a DOM element or storing a mutable value.\n */\nexport function ref<T = HTMLElement>(initialValue?: T): Ref<T> {\n return { current: initialValue as T | undefined };\n}\n\n// --- defineComponent ---\n\n/**\n * Define a component. The setup function runs once per instance.\n * It receives a context with typed props and must return a render function.\n *\n * ```ts\n * const Counter = defineComponent<{ initial: number }>((ctx) => {\n * const count = signal(ctx.props.initial);\n * return () => <div>{count()}</div>;\n * });\n * ```\n */\nexport function defineComponent<P extends Record<string, any> = Record<string, any>>(\n setup: (ctx: ComponentContext<P>) => () => AkashNode,\n): Component<P> {\n const component = (rawProps: P & { children?: AkashNode | (() => AkashNode) }): Node => {\n // Separate children from props, unwrap getter functions for reactivity\n const { children: childrenProp, ...restProps } = rawProps ?? {};\n // Props are passed through as-is — no auto-unwrapping.\n // Components use readProp() to unwrap reactive getters/signals inside\n // effects, which preserves dependency tracking. Auto-unwrapping in the\n // Proxy broke reactivity because it called the getter once and returned\n // the plain value, so effects never subscribed to the underlying signal.\n const props = restProps as unknown as P;\n\n const childrenFn: () => AkashNode =\n typeof childrenProp === 'function'\n ? childrenProp\n : () => childrenProp ?? null;\n\n const ctx: ComponentContext<P> = {\n props,\n children: childrenFn,\n };\n\n // Set up lifecycle hooks collector\n const hooks: LifecycleHooks = { mount: [], unmount: [], error: [] };\n const prevHooks = currentHooks;\n currentHooks = hooks;\n\n // Push context scope for provide/inject\n const parentScope = getCurrentScope();\n const scope = pushScope(parentScope);\n\n let renderFn: () => AkashNode;\n let domNode: Node;\n\n try {\n // Untrack component creation so that signals created inside the component\n // don't register with a parent render effect. This prevents parent effects\n // from re-running (and re-creating the entire component) when internal\n // component state changes. The component's own effects still track their\n // dependencies because effect() sets its own subscriber during execution.\n domNode = untrack(() => {\n renderFn = setup(ctx);\n if (typeof renderFn !== 'function') { throw akashError('AK0040'); }\n const rendered = renderFn();\n return nodeToDOM(rendered);\n });\n } catch (err) {\n popScope(scope);\n currentHooks = prevHooks;\n if (hooks.error.length > 0) {\n for (const handler of hooks.error) {\n handler(err instanceof Error ? err : new Error(String(err)));\n }\n return document.createComment('error');\n }\n throw err;\n }\n\n // Restore parent state\n popScope(scope);\n currentHooks = prevHooks;\n\n // Run mount callbacks (microtask to ensure DOM is attached)\n if (hooks.mount.length > 0) {\n queueMicrotask(() => {\n for (const mountFn of hooks.mount) {\n try {\n const cleanup = mountFn();\n if (typeof cleanup === 'function') {\n hooks.unmount.push(cleanup);\n }\n } catch (err) {\n for (const handler of hooks.error) {\n handler(err instanceof Error ? err : new Error(String(err)));\n }\n }\n }\n });\n }\n\n return domNode;\n };\n\n component._akash = true as const;\n return component as Component<P>;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/context.ts","../src/dom.ts","../src/component.ts"],"names":["errors","DOC_BASE","formatError","code","context","def","msg","akashError","getErrorDef","getAllErrorCodes","CONTEXT_BRAND","currentScope","pushScope","parent","scope","popScope","getCurrentScope","runInScope","fn","prev","createContext","defaultValue","provide","key","value","inject","fallback","createElement","tag","attrs","el","setProperty","createText","cloneTemplate","html","template","event","bindText","node","effect","bindProperty","bindVisible","createAnchor","label","renderConditional","anchor","condition","trueBranch","falseBranch","current","dispose","branch","liveParent","fragment","nodes","renderList","items","keyFn","renderItem","currentItems","newData","newItems","oldMap","item","i","data","existing","firstNode","realParent","Show","props","container","getWhen","whenValue","nodeToDOM","For","getEach","index","child","insert","domNode","__getter","currentHooks","onMount","onUnmount","onError","ref","initialValue","defineComponent","setup","component","rawProps","childrenProp","restProps","ctx","hooks","prevHooks","parentScope","renderFn","untrack","rendered","err","handler","mountFn","cleanup"],"mappings":"mEAqBA,IAAMA,EAAmC,CAEvC,MAAA,CAAQ,CACN,IAAA,CAAM,QAAA,CACN,QAAS,8CAAA,CACT,IAAA,CAAM,oDACR,CAAA,CACA,MAAA,CAAQ,CACN,IAAA,CAAM,QAAA,CACN,QAAS,6CAAA,CACT,IAAA,CAAM,mDACR,CAAA,CACA,MAAA,CAAQ,CACN,IAAA,CAAM,QAAA,CACN,QAAS,yCAAA,CACT,IAAA,CAAM,gEACR,CAAA,CAGA,MAAA,CAAQ,CACN,IAAA,CAAM,QAAA,CACN,QAAS,8CAAA,CACT,IAAA,CAAM,oDACR,CAAA,CACA,MAAA,CAAQ,CACN,IAAA,CAAM,Q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,CAAUD,GAAQ,CACpB,OAAOC,CAAAA,EAAY,UAAA,EACrBT,EAAM,OAAA,CAAQ,IAAA,CAAKS,CAAO,EAE9B,OAASH,CAAAA,CAAK,CACZ,IAAA,IAAWC,CAAAA,IAAWP,EAAM,KAAA,CAC1BO,CAAAA,CAAQD,CAAAA,YAAe,KAAA,CAAQA,EAAM,IAAI,KAAA,CAAM,MAAA,CAAOA,CAAG,CAAC,CAAC,EAE/D,CAEJ,CAAC,EAGIrB,CACT,CAAA,CAEA,OAAAU,CAAAA,CAAU,MAAA,CAAS,KACZA,CACT","file":"chunk-6GGYM5SF.cjs","sourcesContent":["/**\n * Error message catalog.\n *\n * Every AkashJS runtime error has a unique code (AK0001, AK0002, etc.),\n * a one-line description, and a link to detailed documentation.\n *\n * Usage:\n * throw akashError('AK0010', 'provide()');\n */\n\n// --- Error registry ---\n\nexport interface ErrorDef {\n /** Error code */\n code: string;\n /** Short description */\n message: string;\n /** Extended explanation and fix suggestion */\n hint: string;\n}\n\nconst errors: Record<string, ErrorDef> = {\n // --- Context errors (AK001x) ---\n AK0010: {\n code: 'AK0010',\n message: 'provide() called outside of component setup.',\n hint: 'provide() must be called inside defineComponent().',\n },\n AK0012: {\n code: 'AK0012',\n message: 'inject() called outside of component setup.',\n hint: 'inject() must be called inside defineComponent().',\n },\n AK0013: {\n code: 'AK0013',\n message: 'No provider found for injected context.',\n hint: 'Make sure an ancestor component calls provide() with this key.',\n },\n\n // --- Lifecycle errors (AK002x) ---\n AK0020: {\n code: 'AK0020',\n message: 'onMount() called outside of component setup.',\n hint: 'onMount() must be called inside defineComponent().',\n },\n AK0021: {\n code: 'AK0021',\n message: 'onUnmount() called outside of component setup.',\n hint: 'onUnmount() must be called inside defineComponent().',\n },\n AK0022: {\n code: 'AK0022',\n message: 'onError() called outside of component setup.',\n hint: 'onError() must be called inside defineComponent().',\n },\n\n // --- Signal errors (AK003x) ---\n AK0030: {\n code: 'AK0030',\n message: 'Circular dependency detected in computed signal.',\n hint: 'A computed signal is reading itself, directly or via other computeds.',\n },\n AK0031: {\n code: 'AK0031',\n message: 'Signal set() called during computation.',\n hint: 'Do not set signals inside computed() or during effect execution. Use batch() or set signals in event handlers.',\n },\n\n // --- Component errors (AK004x) ---\n AK0040: {\n code: 'AK0040',\n message: 'Component setup must return a render function.',\n hint: 'The function passed to defineComponent() must return () => AkashNode.',\n },\n AK0041: {\n code: 'AK0041',\n message: 'Required prop is missing.',\n hint: 'Check that the parent component is passing all required props.',\n },\n\n // --- Router errors (AK005x) ---\n AK0050: {\n code: 'AK0050',\n message: 'useRoute() called outside of router context.',\n hint: 'Make sure your component is rendered inside a router provider.',\n },\n AK0051: {\n code: 'AK0051',\n message: 'No route matched the current URL.',\n hint: 'Add a catch-all route ([...rest]) to handle unmatched paths.',\n },\n AK0052: {\n code: 'AK0052',\n message: 'Route guard threw an error.',\n hint: 'Check the guard function for unhandled exceptions.',\n },\n\n // --- Form errors (AK006x) ---\n AK0060: {\n code: 'AK0060',\n message: 'Form submitted while invalid.',\n hint: 'The submit handler was not called because validation failed. Check form.errors().',\n },\n AK0061: {\n code: 'AK0061',\n message: 'Async validator timed out.',\n hint: 'The async validator did not resolve within the expected time. Check your async validation logic.',\n },\n\n // --- HTTP errors (AK007x) ---\n AK0070: {\n code: 'AK0070',\n message: 'HTTP request failed.',\n hint: 'Check the server response status and network connectivity.',\n },\n AK0071: {\n code: 'AK0071',\n message: 'createResource() fetcher threw an error.',\n hint: 'Check the fetcher function passed to createResource().',\n },\n};\n\n// --- Public API ---\n\nconst DOC_BASE = 'https://akashjs.dev/errors';\n\n/**\n * Format an AkashJS error with code, message, hint, and doc link.\n */\nexport function formatError(code: string, context?: string): string {\n const def = errors[code];\n if (!def) {\n return `[AkashJS ${code}] Unknown error code.`;\n }\n\n let msg = `[AkashJS ${code}] ${def.message}`;\n if (context) {\n msg += `\\n ${context}`;\n }\n msg += `\\n ${def.hint}`;\n msg += `\\n See: ${DOC_BASE}/${code}`;\n return msg;\n}\n\n/**\n * Create and throw an AkashJS error.\n */\nexport function akashError(code: string, context?: string): Error {\n return new Error(formatError(code, context));\n}\n\n/**\n * Get the error definition for a code.\n */\nexport function getErrorDef(code: string): ErrorDef | undefined {\n return errors[code];\n}\n\n/**\n * Get all registered error codes.\n */\nexport function getAllErrorCodes(): string[] {\n return Object.keys(errors);\n}\n","/**\n * Lightweight dependency injection via provide/inject.\n *\n * Context is scoped to the component tree — no injector hierarchy,\n * no decorators, no classes. Just createContext(), provide(), inject().\n */\n\n// --- Types ---\n\nimport { akashError } from './errors.js';\n\nconst CONTEXT_BRAND = Symbol('akash.context');\n\nexport interface InjectionKey<T> {\n readonly [CONTEXT_BRAND]: true;\n readonly _type: T; // phantom type — never used at runtime\n readonly defaultValue: T | undefined;\n readonly id: symbol;\n}\n\n// --- Context stack (managed by component system) ---\n\ninterface ContextScope {\n values: Map<symbol, unknown>;\n parent: ContextScope | null;\n}\n\nlet currentScope: ContextScope | null = null;\n\n/** @internal — called by defineComponent to push/pop context scopes */\nexport function pushScope(parent: ContextScope | null = currentScope): ContextScope {\n const scope: ContextScope = { values: new Map(), parent };\n currentScope = scope;\n return scope;\n}\n\n/** @internal */\nexport function popScope(scope: ContextScope): void {\n currentScope = scope.parent;\n}\n\n/** @internal */\nexport function getCurrentScope(): ContextScope | null {\n return currentScope;\n}\n\n/**\n * Run a function within a given scope so that provide/inject\n * work correctly for components created asynchronously\n * (e.g., lazy-loaded route components).\n */\nexport function runInScope<T>(scope: ContextScope, fn: () => T): T {\n const prev = currentScope;\n currentScope = scope;\n try {\n return fn();\n } finally {\n currentScope = prev;\n }\n}\n\n// --- Public API ---\n\n/**\n * Create a typed context key with an optional default value.\n *\n * ```ts\n * const ThemeContext = createContext<'light' | 'dark'>('light');\n * ```\n */\nexport function createContext<T>(defaultValue?: T): InjectionKey<T> {\n return {\n [CONTEXT_BRAND]: true,\n _type: undefined as T,\n defaultValue,\n id: Symbol('context'),\n };\n}\n\n/**\n * Provide a value for a context key in the current component scope.\n * All descendant components can inject() this value.\n *\n * Must be called inside defineComponent() setup.\n */\nexport function provide<T>(key: InjectionKey<T>, value: T): void {\n if (!currentScope) {\n throw akashError('AK0010');\n }\n currentScope.values.set(key.id, value);\n}\n\n/**\n * Inject a value from the nearest ancestor that provided it.\n *\n * Must be called inside defineComponent() setup.\n */\nexport function inject<T>(key: InjectionKey<T>): T;\nexport function inject<T>(key: InjectionKey<T>, fallback: T): T;\nexport function inject<T>(key: InjectionKey<T>, fallback?: T): T {\n if (!currentScope) {\n throw akashError('AK0012');\n }\n\n // Walk up the scope chain\n let scope: ContextScope | null = currentScope;\n while (scope) {\n if (scope.values.has(key.id)) {\n return scope.values.get(key.id) as T;\n }\n scope = scope.parent;\n }\n\n // Check fallback, then default\n if (fallback !== undefined) return fallback;\n if (key.defaultValue !== undefined) return key.defaultValue;\n\n throw akashError('AK0013');\n}\n","/**\n * Direct DOM rendering runtime.\n *\n * No virtual DOM. The compiler generates calls to these helpers.\n * Signal reads inside templates become fine-grained effects that\n * update only the specific DOM node that changed.\n */\n\nimport { effect } from './signals.js';\nimport { getCurrentScope, runInScope } from './context.js';\nimport type { AkashNode } from './types.js';\n\n// --- DOM creation helpers (used by compiler output) ---\n\n/** Create an element and optionally set static attributes */\nexport function createElement(\n tag: string,\n attrs?: Record<string, unknown>,\n): HTMLElement {\n const el = document.createElement(tag);\n if (attrs) {\n for (const [key, value] of Object.entries(attrs)) {\n setProperty(el, key, value);\n }\n }\n return el;\n}\n\n/** Create a text node */\nexport function createText(value: string): Text {\n return document.createTextNode(value);\n}\n\n/** Clone a template element for static structure */\nexport function cloneTemplate(html: string): DocumentFragment {\n const template = document.createElement('template');\n template.innerHTML = html;\n return template.content.cloneNode(true) as DocumentFragment;\n}\n\n// --- Property/attribute setting ---\n\nexport function setProperty(el: HTMLElement, key: string, value: unknown): void {\n if (key === 'class' || key === 'className') {\n el.className = value as string;\n } else if (key === 'style' && typeof value === 'object' && value !== null) {\n Object.assign(el.style, value);\n } else if (key === 'innerHTML') {\n el.innerHTML = value as string;\n } else if (key === 'ref') {\n // Handled separately by component system\n } else if (key.startsWith('on')) {\n const event = key.slice(2).toLowerCase();\n el.addEventListener(event, value as EventListener);\n } else if (key in el) {\n (el as unknown as Record<string, unknown>)[key] = value;\n } else if (value === false || value == null) {\n el.removeAttribute(key);\n } else {\n el.setAttribute(key, value === true ? '' : String(value));\n }\n}\n\n// --- Reactive binding (used by compiler for dynamic expressions) ---\n\n/** Bind a reactive expression to a text node's content */\nexport function bindText(node: Text, fn: () => unknown): () => void {\n return effect(\n () => {\n node.textContent = String(fn());\n },\n { render: true },\n );\n}\n\n/** Bind a reactive expression to an element's attribute/property */\nexport function bindProperty(\n el: HTMLElement,\n key: string,\n fn: () => unknown,\n): () => void {\n return effect(\n () => {\n setProperty(el, key, fn());\n },\n { render: true },\n );\n}\n\n/** Bind a reactive expression to an element's visibility (display) */\nexport function bindVisible(el: HTMLElement, fn: () => boolean): () => void {\n return effect(\n () => {\n el.style.display = fn() ? '' : 'none';\n },\n { render: true },\n );\n}\n\n// --- Conditional rendering ---\n\n/** Anchor node — comment for normal DOM, hidden element for table contexts */\ntype Anchor = Comment | HTMLElement;\n\n/** Table elements where comment nodes get relocated by the browser */\nconst TABLE_TAGS = new Set(['TABLE', 'THEAD', 'TBODY', 'TFOOT', 'TR']);\n\nfunction createAnchor(label = ''): Anchor {\n return document.createComment(label);\n}\n\n/**\n * Create a table-safe anchor. Browsers relocate comment nodes inside\n * table elements, breaking anchor-based insertion. Use a hidden element instead.\n */\nfunction createTableSafeAnchor(parent: Node): Anchor {\n if (parent instanceof HTMLElement && TABLE_TAGS.has(parent.tagName)) {\n const tag = parent.tagName === 'TR' ? 'td' : 'tr';\n const el = document.createElement(tag);\n el.style.display = 'none';\n return el;\n }\n return document.createComment('');\n}\n\ninterface ConditionalBlock {\n nodes: Node[];\n dispose: (() => void) | null;\n}\n\n/**\n * Render a conditional block. Swaps DOM fragments based on a reactive\n * condition. Used by the compiler for :if directives and <Show>.\n */\nexport function renderConditional(\n parent: Node,\n anchor: Node,\n condition: () => boolean,\n trueBranch: () => Node,\n falseBranch?: () => Node,\n): () => void {\n let current: ConditionalBlock | null = null;\n\n // Capture scope so children created in branches inherit provide/inject context\n const scope = getCurrentScope();\n\n const dispose = effect(\n () => {\n const value = condition();\n\n // Remove old nodes\n if (current) {\n for (const node of current.nodes) {\n try { node.parentNode?.removeChild(node); } catch {}\n }\n current.dispose?.();\n current = null;\n }\n\n // Insert new nodes — use anchor.parentNode since the anchor may have\n // moved from the initial DocumentFragment into the real DOM.\n // In table contexts, the browser may relocate comment anchors.\n const branch = value ? trueBranch : falseBranch;\n let liveParent: Node | null = anchor.parentNode;\n if (!liveParent && (current as ConditionalBlock | null)?.nodes[0]?.parentNode) {\n liveParent = (current as ConditionalBlock | null)!.nodes[0].parentNode;\n }\n if (branch && liveParent) {\n const fragment = scope ? runInScope(scope, branch) : branch();\n const nodes = fragment instanceof DocumentFragment\n ? Array.from(fragment.childNodes)\n : [fragment];\n for (const node of nodes) {\n liveParent.insertBefore(node, anchor);\n }\n current = { nodes, dispose: null };\n }\n },\n { render: true },\n );\n\n return () => {\n dispose();\n if (current) {\n for (const node of current.nodes) {\n try { node.parentNode?.removeChild(node); } catch {}\n }\n current.dispose?.();\n }\n };\n}\n\n// --- List rendering ---\n\ninterface ListItem<T> {\n key: unknown;\n value: T;\n nodes: Node[];\n dispose: (() => void) | null;\n}\n\n/**\n * Render a reactive list with keyed reconciliation.\n * Used by the compiler for :for directives and <For>.\n */\nexport function renderList<T>(\n parent: Node,\n anchor: Node,\n items: () => T[],\n keyFn: (item: T, index: number) => unknown,\n renderItem: (item: T, index: number) => Node,\n): () => void {\n let currentItems: ListItem<T>[] = [];\n\n // Capture scope so children created in renderItem inherit provide/inject context\n const scope = getCurrentScope();\n\n const dispose = effect(\n () => {\n const newData = items();\n const newItems: ListItem<T>[] = [];\n const oldMap = new Map<unknown, ListItem<T>>();\n\n for (const item of currentItems) {\n oldMap.set(item.key, item);\n }\n\n // Build new list, reuse existing DOM nodes when keys match\n for (let i = 0; i < newData.length; i++) {\n const data = newData[i];\n const key = keyFn(data, i);\n const existing = oldMap.get(key);\n\n if (existing) {\n oldMap.delete(key);\n // If the reused item's nodes were detached (e.g., parent removed them),\n // treat as new to avoid stale DOM references\n const firstNode = existing.nodes[0];\n if (firstNode && !firstNode.parentNode) {\n // Nodes were detached — create fresh\n const fragment = scope ? runInScope(scope, () => renderItem(data, i)) : renderItem(data, i);\n const nodes = fragment instanceof DocumentFragment\n ? Array.from(fragment.childNodes)\n : [fragment];\n newItems.push({ key, value: data, nodes, dispose: null });\n } else {\n existing.value = data;\n newItems.push(existing);\n }\n } else {\n const fragment = scope ? runInScope(scope, () => renderItem(data, i)) : renderItem(data, i);\n const nodes = fragment instanceof DocumentFragment\n ? Array.from(fragment.childNodes)\n : [fragment];\n newItems.push({ key, value: data, nodes, dispose: null });\n }\n }\n\n // Remove items that are no longer in the list\n for (const item of oldMap.values()) {\n for (const node of item.nodes) {\n if (node.parentNode) node.parentNode.removeChild(node);\n }\n item.dispose?.();\n }\n\n // Reconcile DOM order — insertBefore moves existing nodes, inserts new ones\n const liveParent = anchor.parentNode;\n if (liveParent) {\n // Normal path — anchor is in the DOM, insert before it\n for (const item of newItems) {\n for (const node of item.nodes) {\n liveParent.insertBefore(node, anchor);\n }\n }\n } else {\n // Table fallback — browser relocated the comment anchor.\n // Find the real parent from any node still in the DOM.\n let realParent: Node | null = null;\n for (const item of currentItems) {\n if (item.nodes[0]?.parentNode) { realParent = item.nodes[0].parentNode; break; }\n }\n if (realParent) {\n // Remove old nodes first (oldMap items already removed above)\n // Then append all new items\n for (const item of newItems) {\n for (const node of item.nodes) {\n realParent.appendChild(node);\n }\n }\n }\n }\n\n currentItems = newItems;\n },\n { render: true },\n );\n\n return () => {\n dispose();\n for (const item of currentItems) {\n for (const node of item.nodes) {\n if (node.parentNode) node.parentNode.removeChild(node);\n }\n item.dispose?.();\n }\n currentItems = [];\n };\n}\n\n// --- Built-in control flow components ---\n\n/** Props for the <Show> component */\nexport interface ShowProps<T> {\n when: (() => T | null | undefined | false) | T | null | undefined | false;\n fallback?: () => AkashNode;\n children: (value: T) => AkashNode;\n}\n\n/**\n * <Show> component — conditionally renders children with type narrowing.\n * The children callback receives the non-null/undefined value.\n * `when` can be a reactive getter or a static value.\n */\nexport function Show<T>(props: ShowProps<T>): Node {\n const anchor = createAnchor('show');\n const container = document.createDocumentFragment();\n container.appendChild(anchor);\n\n // Resolve when — if it's a function, always call it (supports both\n // compiler-generated __reactive getters and plain programmatic functions)\n const getWhen = typeof props.when === 'function'\n ? props.when as () => T | null | undefined | false\n : () => props.when as T | null | undefined | false;\n\n // Capture the when value once per evaluation so the condition check\n // and the children callback receive the same value (fixes nested For contexts)\n let whenValue: T | null | undefined | false;\n renderConditional(\n container,\n anchor,\n () => { whenValue = getWhen(); return !!whenValue; },\n () => nodeToDOM(props.children(whenValue as T)),\n props.fallback ? () => nodeToDOM(props.fallback!()) : undefined,\n );\n\n return container;\n}\n\n/** Props for the <For> component */\nexport interface ForProps<T> {\n each: (() => T[]) | T[];\n key: (item: T) => unknown;\n children: (item: T, index: number) => AkashNode;\n}\n\n/**\n * <For> component — renders a list with keyed reconciliation.\n * `each` can be a reactive getter or a static array.\n */\nexport function For<T>(props: ForProps<T>): Node {\n const anchor = createAnchor('for');\n const container = document.createDocumentFragment();\n container.appendChild(anchor);\n\n // Resolve each — if it's a function, always call it (supports both\n // compiler-generated __reactive getters and plain programmatic functions)\n const getEach = typeof props.each === 'function'\n ? props.each as () => T[]\n : () => props.each as T[];\n\n renderList(\n container,\n anchor,\n getEach,\n props.key,\n (item, index) => nodeToDOM(props.children(item, index)),\n );\n\n return container;\n}\n\n// --- Helpers ---\n\n/** Convert an AkashNode to a DOM Node */\nexport function nodeToDOM(node: AkashNode): Node {\n if (node == null || typeof node === 'boolean') {\n return document.createTextNode('');\n }\n if (typeof node === 'string' || typeof node === 'number') {\n return document.createTextNode(String(node));\n }\n if (node instanceof Node) {\n return node;\n }\n if (Array.isArray(node)) {\n const fragment = document.createDocumentFragment();\n for (const child of node) {\n fragment.appendChild(nodeToDOM(child));\n }\n return fragment;\n }\n return document.createTextNode(String(node));\n}\n\n/** Insert a node into a parent before an anchor */\nexport function insert(parent: Node, node: AkashNode, anchor?: Node): void {\n const domNode = nodeToDOM(node);\n if (anchor) {\n parent.insertBefore(domNode, anchor);\n } else {\n parent.appendChild(domNode);\n }\n}\n","/**\n * Component system.\n *\n * Components are functions. defineComponent() wraps a setup function\n * that runs once, establishes signals and effects, and returns a\n * render function that produces DOM nodes.\n */\n\nimport { effect, untrack } from './signals.js';\nimport { pushScope, popScope, getCurrentScope } from './context.js';\nimport { nodeToDOM } from './dom.js';\nimport { akashError } from './errors.js';\nimport type { AkashNode } from './types.js';\n\n// --- Reactive getter marker (used by compiler) ---\n\n/** Mark a function as a compiler-generated reactive getter */\nexport function __getter<T>(fn: () => T): (() => T) & { __reactive: true } {\n (fn as any).__reactive = true;\n return fn as any;\n}\n\n// --- Types ---\n\nexport interface Ref<T = HTMLElement> {\n current: T | undefined;\n}\n\nexport interface ComponentContext<P extends Record<string, unknown> = Record<string, unknown>> {\n props: Readonly<P>;\n children: () => AkashNode;\n}\n\nexport type Component<P extends Record<string, unknown> = Record<string, unknown>> = {\n (props: P & { children?: AkashNode | (() => AkashNode) }): Node;\n _akash: true;\n};\n\n// --- Lifecycle hook storage ---\n\ninterface LifecycleHooks {\n mount: Array<() => void | (() => void)>;\n unmount: Array<() => void>;\n error: Array<(error: Error) => void>;\n}\n\nlet currentHooks: LifecycleHooks | null = null;\n\n// --- Public lifecycle hooks ---\n\n/**\n * Register a callback to run after the component is mounted to the DOM.\n * If the callback returns a function, it will be called on unmount (cleanup).\n */\nexport function onMount(fn: () => void | (() => void)): void {\n if (!currentHooks) {\n throw akashError('AK0020');\n }\n currentHooks.mount.push(fn);\n}\n\n/**\n * Register a callback to run before the component is unmounted.\n */\nexport function onUnmount(fn: () => void): void {\n if (!currentHooks) {\n throw akashError('AK0021');\n }\n currentHooks.unmount.push(fn);\n}\n\n/**\n * Register an error handler for this component and its descendants.\n */\nexport function onError(fn: (error: Error) => void): void {\n if (!currentHooks) {\n throw akashError('AK0022');\n }\n currentHooks.error.push(fn);\n}\n\n/**\n * Create a ref for accessing a DOM element or storing a mutable value.\n */\nexport function ref<T = HTMLElement>(initialValue?: T): Ref<T> {\n return { current: initialValue as T | undefined };\n}\n\n// --- defineComponent ---\n\n/**\n * Define a component. The setup function runs once per instance.\n * It receives a context with typed props and must return a render function.\n *\n * ```ts\n * const Counter = defineComponent<{ initial: number }>((ctx) => {\n * const count = signal(ctx.props.initial);\n * return () => <div>{count()}</div>;\n * });\n * ```\n */\nexport function defineComponent<P extends Record<string, any> = Record<string, any>>(\n setup: (ctx: ComponentContext<P>) => () => AkashNode,\n): Component<P> {\n const component = (rawProps: P & { children?: AkashNode | (() => AkashNode) }): Node => {\n // Separate children from props, unwrap getter functions for reactivity\n const { children: childrenProp, ...restProps } = rawProps ?? {};\n // Props are passed through as-is — no auto-unwrapping.\n // Components use readProp() to unwrap reactive getters/signals inside\n // effects, which preserves dependency tracking. Auto-unwrapping in the\n // Proxy broke reactivity because it called the getter once and returned\n // the plain value, so effects never subscribed to the underlying signal.\n const props = restProps as unknown as P;\n\n const childrenFn: () => AkashNode =\n typeof childrenProp === 'function'\n ? childrenProp\n : () => childrenProp ?? null;\n\n const ctx: ComponentContext<P> = {\n props,\n children: childrenFn,\n };\n\n // Set up lifecycle hooks collector\n const hooks: LifecycleHooks = { mount: [], unmount: [], error: [] };\n const prevHooks = currentHooks;\n currentHooks = hooks;\n\n // Push context scope for provide/inject\n const parentScope = getCurrentScope();\n const scope = pushScope(parentScope);\n\n let renderFn: () => AkashNode;\n let domNode: Node;\n\n try {\n // Untrack component creation so that signals created inside the component\n // don't register with a parent render effect. This prevents parent effects\n // from re-running (and re-creating the entire component) when internal\n // component state changes. The component's own effects still track their\n // dependencies because effect() sets its own subscriber during execution.\n domNode = untrack(() => {\n renderFn = setup(ctx);\n if (typeof renderFn !== 'function') { throw akashError('AK0040'); }\n const rendered = renderFn();\n return nodeToDOM(rendered);\n });\n } catch (err) {\n popScope(scope);\n currentHooks = prevHooks;\n if (hooks.error.length > 0) {\n for (const handler of hooks.error) {\n handler(err instanceof Error ? err : new Error(String(err)));\n }\n return document.createComment('error');\n }\n throw err;\n }\n\n // Restore parent state\n popScope(scope);\n currentHooks = prevHooks;\n\n // Run mount callbacks (microtask to ensure DOM is attached)\n if (hooks.mount.length > 0) {\n queueMicrotask(() => {\n for (const mountFn of hooks.mount) {\n try {\n const cleanup = mountFn();\n if (typeof cleanup === 'function') {\n hooks.unmount.push(cleanup);\n }\n } catch (err) {\n for (const handler of hooks.error) {\n handler(err instanceof Error ? err : new Error(String(err)));\n }\n }\n }\n });\n }\n\n return domNode;\n };\n\n component._akash = true as const;\n return component as Component<P>;\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunk35DJOBEO_cjs=require('./chunk-35DJOBEO.cjs'),chunkEEILP4OL_cjs=require('./chunk-EEILP4OL.cjs');var K=[];function F(c){K.push(...c.plugins);}var k=new Map;function D(c,f){return ()=>{if(k.has(c))return k.get(c);let o=f.state(),n=$(c,o,f);return k.set(c,n),n}}function $(c,f,o){let n={},p=Object.keys(f);for(let e of p)n[e]=chunkEEILP4OL_cjs.l(f[e]);let i={$id:c};for(let e of p)i[e]=n[e];let h=[],m=[];if(i.$__meta={stateKeys:p,getterKeys:h,actionKeys:m},o.getters)for(let[e,t]of Object.entries(o.getters))h.push(e),i[e]=chunkEEILP4OL_cjs.m(()=>t.call(i,n));let R=[...K,...o.plugins??[]];if(o.actions)for(let[e,t]of Object.entries(o.actions))m.push(e),i[e]=(...S)=>{for(let s of R)s.onAction?.(i,e,S);return t.apply(i,S)};i.$reset=()=>{let e=o.state();for(let t of p)n[t].set(e[t]);},i.$patch=e=>{chunkEEILP4OL_cjs.a(()=>{if(typeof e=="function")e(n);else for(let[t,S]of Object.entries(e))t in n&&n[t].set(S);});},i.$snapshot=()=>{let e={};for(let t of p)e[t]=n[t]();return e};let w=new Set,d=null;if(i.$subscribe=e=>{if(w.add(e),!d){let t=true;d=chunkEEILP4OL_cjs.n(()=>{for(let s of p)n[s]();if(t){t=false;return}let S=i.$snapshot();for(let s of w)s(S);});}return ()=>{w.delete(e),w.size===0&&d&&(d(),d=null);}},o.persist&&typeof window<"u"){let e=O(c,o.persist);for(let t of e){let S=t.storage==="sessionStorage"?sessionStorage:localStorage,s=t.serialize??JSON.stringify,y=t.deserialize??JSON.parse,g=t.pick??p;try{let r=S.getItem(t.key);if(r){let a=y(r);for(let l of g)l in a&&l in n&&n[l].set(a[l]);}}catch{}let u=false,b=true;chunkEEILP4OL_cjs.n(()=>{for(let r of g)r in n&&n[r]();if(b){b=false;return}u||(u=true,queueMicrotask(()=>{u=false;let r={};for(let a of g)a in n&&(r[a]=n[a].peek());try{S.setItem(t.key,s(r));}catch{}}));}),t.storage!=="sessionStorage"&&window.addEventListener("storage",r=>{if(!(r.key!==t.key||!r.newValue))try{let a=y(r.newValue);for(let l of g)l in a&&l in n&&n[l].set(a[l]);}catch{}});}}if(o.sync&&o.sync.enabled!==false){let e=o.sync,t=e.pick??p,S={};for(let y of t)S[y]=n[y]?.peek?.()??f[y];let s=chunk35DJOBEO_cjs.d(S,{transport:e.transport,peerId:e.peerId});for(let y of t){if(!(y in n)||!(y in s.state))continue;let g=n[y],u=s.state[y],b=g.set,r=false;g.set=a=>{b.call(g,a),r||u.set(a);},chunkEEILP4OL_cjs.n(()=>{let a=u();r=true,g.set(a),r=false;});}i.$sync={peers:s.peers,presence:s.presence,peerPresence:s.peerPresence,peerId:s.peerId,connected:s.connected,connect:s.connect.bind(s),disconnect:s.disconnect.bind(s)};}for(let e of R)e.init?.(i);return i}function O(c,f){return f===true?[{key:`akash-store:${c}`}]:f===false?[]:Array.isArray(f)?f.map((o,n)=>({...o,key:o.key??`akash-store:${c}:${n}`})):[{...f,key:f.key??`akash-store:${c}`}]}function _(){k.clear();}function E(){return Object.fromEntries(k)}exports.a=F;exports.b=D;exports.c=_;exports.d=E;//# sourceMappingURL=chunk-AVVJKYT3.cjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-AVVJKYT3.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/store.ts"],"names":["globalPlugins","configureStores","options","storeInstances","defineStore","id","definition","initialState","store","createStoreInstance","stateSignals","stateKeys","key","signal","getterKeys","actionKeys","getterFn","computed","plugins","actionFn","args","plugin","fresh","partialOrFn","batch","value","snapshot","subscribers","subscribeEffect","callback","isInitial","effect","cb","configs","normalizePersistConfigs","cfg","storage","serialize","deserialize","persistKeys","raw","saved","persistScheduled","isInitialPersist","e","updated","syncOpts","syncKeys","syncState","doc","createSync","localSignal","syncSignal","originalSet","fromSync","remoteVal","persist","p","i","clearStores","__getStoreInstances"],"mappings":"qHA2HA,IAAMA,EAA+B,EAAC,CAG/B,SAASC,CAAAA,CAAgBC,CAAAA,CAA2C,CACzEF,CAAAA,CAAc,IAAA,CAAK,GAAGE,CAAAA,CAAQ,OAAO,EACvC,CAIA,IAAMC,EAAiB,IAAI,GAAA,CAQpB,SAASC,CAAAA,CAKdC,CAAAA,CACAC,CAAAA,CACsB,CACtB,OAAO,IAAM,CAEX,GAAIH,CAAAA,CAAe,GAAA,CAAIE,CAAE,CAAA,CACvB,OAAOF,EAAe,GAAA,CAAIE,CAAE,EAG9B,IAAME,CAAAA,CAAeD,EAAW,KAAA,EAAM,CAChCE,EAAQC,CAAAA,CAAoBJ,CAAAA,CAAIE,CAAAA,CAAcD,CAAU,EAC9D,OAAAH,CAAAA,CAAe,IAAIE,CAAAA,CAAIG,CAAK,EACrBA,CACT,CACF,CAEA,SAASC,CAAAA,CAKPJ,EACAE,CAAAA,CACAD,CAAAA,CACgB,CAEhB,IAAMI,CAAAA,CAAgD,EAAC,CACjDC,CAAA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BA,CAAAA,CAAQ,GAAA,CAAI,CAACC,CAAAA,CAAGC,CAAAA,IAAO,CAAE,GAAGD,CAAAA,CAAG,IAAKA,CAAAA,CAAE,GAAA,EAAO,eAAepD,CAAE,CAAA,CAAA,EAAIqD,CAAC,CAAA,CAAG,CAAA,CAAE,EAE1E,CAAC,CAAE,GAAGF,CAAAA,CAAS,GAAA,CAAKA,EAAQ,GAAA,EAAO,CAAA,YAAA,EAAenD,CAAE,CAAA,CAAG,CAAC,CACjE,CAKO,SAASsD,GAAoB,CAClCxD,CAAAA,CAAe,QACjB,CAGO,SAASyD,CAAAA,EAA4D,CAC1E,OAAO,MAAA,CAAO,WAAA,CAAYzD,CAAc,CAC1C","file":"chunk-AVVJKYT3.cjs","sourcesContent":["/**\n * Global state management via defineStore().\n *\n * Stores are singleton signal containers that persist across\n * components. They provide shared state, computed getters,\n * and actions — no external library needed.\n *\n * ```ts\n * const useCounterStore = defineStore('counter', {\n * state: () => ({ count: 0, name: 'Counter' }),\n * getters: {\n * doubled: (state) => state.count() * 2,\n * },\n * actions: {\n * increment() { this.count.update(c => c + 1); },\n * reset() { this.count.set(0); },\n * },\n * });\n *\n * // In any component:\n * const store = useCounterStore();\n * store.count(); // 0\n * store.doubled(); // 0\n * store.increment();\n * store.count(); // 1\n * ```\n */\n\nimport { signal, computed, effect } from './signals.js';\nimport { batch } from './scheduler.js';\nimport { createSync } from './sync.js';\nimport type { SyncDoc } from './sync.js';\nimport type { Signal, ReadonlySignal } from './signals.js';\n\n// --- Types ---\n\ntype StateFactory<S> = () => S;\n\ntype Getters<S, G> = {\n [K in keyof G]: (state: SignalifiedState<S>) => G[K];\n};\n\ntype Actions<A> = {\n [K in keyof A]: A[K] extends (...args: infer P) => infer R\n ? (...args: P) => R\n : never;\n};\n\n/** Maps plain state values to signals */\ntype SignalifiedState<S> = {\n [K in keyof S]: Signal<S[K]>;\n};\n\n/** The store instance returned to consumers */\nexport type Store<S, G, A> = SignalifiedState<S> & {\n [K in keyof G]: ReadonlySignal<G[K]>;\n} & {\n [K in keyof A]: A[K] extends (...args: infer P) => infer R\n ? (...args: P) => R\n : never;\n} & {\n /** Reset all state to initial values */\n $reset(): void;\n /** Merge partial state into the store, or apply changes via callback */\n $patch(partialOrFn: Partial<S> | ((state: SignalifiedState<S>) => void)): void;\n /** Subscribe to all state changes */\n $subscribe(callback: (state: S) => void): () => void;\n /** Get a plain snapshot of current state */\n $snapshot(): S;\n /** Store ID */\n $id: string;\n};\n\nexport interface PersistOptions<S> {\n /** Only persist these state keys (default: all) */\n pick?: (keyof S)[];\n /** Storage backend (default: 'localStorage') */\n storage?: 'localStorage' | 'sessionStorage';\n /** Custom storage key (default: 'akash-store:{storeId}') */\n key?: string;\n /** Custom serializer (default: JSON.stringify) */\n serialize?: (value: unknown) => string;\n /** Custom deserializer (default: JSON.parse) */\n deserialize?: (value: string) => unknown;\n}\n\nexport interface StoreSyncOptions {\n /** Sync transport (WebSocket, local, etc.) */\n transport?: import('./sync.js').SyncTransport;\n /** Enable sync — uses provided or default transport */\n enabled?: boolean;\n /** Sync room/channel name (default: store ID) */\n room?: string;\n /** Unique peer ID */\n peerId?: string;\n /** Enable presence tracking */\n presence?: boolean;\n /** Only sync these state keys (default: all) */\n pick?: string[];\n}\n\nexport interface StoreDefinition<S, G, A> {\n state: StateFactory<S>;\n getters?: Getters<S, G>;\n actions?: A & ThisType<\n SignalifiedState<S> &\n { [K in keyof G]: ReadonlySignal<G[K]> } &\n A\n >;\n plugins?: StorePlugin[];\n /** Auto-persist state to storage. true = persist all to localStorage. */\n persist?: boolean | PersistOptions<S> | PersistOptions<S>[];\n /** Sync state across peers via CRDT. Adds real-time collaboration to any store. */\n sync?: StoreSyncOptions;\n}\n\n// --- Plugin system ---\n\nexport interface StorePlugin {\n init?(store: Store<any, any, any>): void;\n onAction?(store: Store<any, any, any>, actionName: string, args: unknown[]): void;\n}\n\nconst globalPlugins: StorePlugin[] = [];\n\n/** Register global plugins that apply to all stores */\nexport function configureStores(options: { plugins: StorePlugin[] }): void {\n globalPlugins.push(...options.plugins);\n}\n\n// --- Store registry (singleton) ---\n\nconst storeInstances = new Map<string, Store<any, any, any>>();\n\n// --- defineStore ---\n\n/**\n * Define a global store. Returns a composable function that\n * always returns the same store instance (singleton).\n */\nexport function defineStore<\n S extends Record<string, unknown>,\n G extends Record<string, unknown> = {},\n A extends Record<string, (...args: any[]) => any> = {},\n>(\n id: string,\n definition: StoreDefinition<S, G, A>,\n): () => Store<S, G, A> {\n return () => {\n // Return existing instance if already created\n if (storeInstances.has(id)) {\n return storeInstances.get(id) as Store<S, G, A>;\n }\n\n const initialState = definition.state();\n const store = createStoreInstance(id, initialState, definition);\n storeInstances.set(id, store);\n return store;\n };\n}\n\nfunction createStoreInstance<\n S extends Record<string, unknown>,\n G extends Record<string, unknown>,\n A extends Record<string, (...args: any[]) => any>,\n>(\n id: string,\n initialState: S,\n definition: StoreDefinition<S, G, A>,\n): Store<S, G, A> {\n // Create signals for each state property\n const stateSignals: Record<string, Signal<unknown>> = {};\n const stateKeys = Object.keys(initialState);\n\n for (const key of stateKeys) {\n stateSignals[key] = signal(initialState[key]);\n }\n\n // Build the store object first so getters can reference other getters via `this`\n const store: any = { $id: id };\n\n // Add state signals\n for (const key of stateKeys) {\n store[key] = stateSignals[key];\n }\n\n // Metadata for devtools — avoids calling functions to classify them\n const getterKeys: string[] = [];\n const actionKeys: string[] = [];\n store.$__meta = { stateKeys, getterKeys, actionKeys };\n\n // Create computed getters — bound to store so `this.otherGetter()` works\n if (definition.getters) {\n for (const [key, getterFn] of Object.entries(definition.getters)) {\n getterKeys.push(key);\n store[key] = computed(() =>\n (getterFn as Function).call(store, stateSignals),\n );\n }\n }\n\n // Collect all plugins (global + per-store)\n const plugins = [...globalPlugins, ...(definition.plugins ?? [])];\n\n // Bind actions with `this` pointing to the full store (state + getters + actions)\n if (definition.actions) {\n for (const [key, actionFn] of Object.entries(definition.actions)) {\n actionKeys.push(key);\n store[key] = (...args: unknown[]) => {\n for (const plugin of plugins) plugin.onAction?.(store, key, args);\n return (actionFn as Function).apply(store, args);\n };\n }\n }\n\n // $reset\n store.$reset = () => {\n const fresh = definition.state();\n for (const key of stateKeys) {\n stateSignals[key].set(fresh[key as keyof S]);\n }\n };\n\n // $patch — merge partial state or apply via callback (batched)\n store.$patch = (partialOrFn: Partial<S> | ((state: any) => void)) => {\n batch(() => {\n if (typeof partialOrFn === 'function') {\n partialOrFn(stateSignals);\n } else {\n for (const [key, value] of Object.entries(partialOrFn)) {\n if (key in stateSignals) {\n stateSignals[key].set(value);\n }\n }\n }\n });\n };\n\n // $snapshot\n store.$snapshot = (): S => {\n const snapshot: Record<string, unknown> = {};\n for (const key of stateKeys) {\n snapshot[key] = stateSignals[key]();\n }\n return snapshot as S;\n };\n\n // $subscribe — watch all state signals and notify on change\n const subscribers = new Set<(state: S) => void>();\n let subscribeEffect: (() => void) | null = null;\n store.$subscribe = (callback: (state: S) => void): (() => void) => {\n subscribers.add(callback);\n // Start watching if this is the first subscriber\n if (!subscribeEffect) {\n let isInitial = true;\n subscribeEffect = effect(() => {\n // Read all state signals to track them\n for (const key of stateKeys) {\n stateSignals[key]();\n }\n // Skip initial run — only notify on actual changes\n if (isInitial) {\n isInitial = false;\n return;\n }\n const snapshot = store.$snapshot();\n for (const cb of subscribers) {\n cb(snapshot);\n }\n });\n }\n return () => {\n subscribers.delete(callback);\n // Dispose effect when no subscribers remain\n if (subscribers.size === 0 && subscribeEffect) {\n subscribeEffect();\n subscribeEffect = null;\n }\n };\n };\n\n // --- Persistence ---\n if (definition.persist && typeof window !== 'undefined') {\n const configs = normalizePersistConfigs(id, definition.persist);\n for (const cfg of configs) {\n const storage = cfg.storage === 'sessionStorage' ? sessionStorage : localStorage;\n const serialize = cfg.serialize ?? JSON.stringify;\n const deserialize = cfg.deserialize ?? JSON.parse;\n const persistKeys = cfg.pick ?? stateKeys;\n\n // Hydrate: read from storage and merge into state\n try {\n const raw = storage.getItem(cfg.key);\n if (raw) {\n const saved = deserialize(raw) as Record<string, unknown>;\n for (const key of persistKeys as string[]) {\n if (key in saved && key in stateSignals) {\n stateSignals[key].set(saved[key]);\n }\n }\n }\n } catch { /* corrupt storage — ignore */ }\n\n // Write: subscribe to state changes and persist (debounced via microtask)\n // The effect tracks signals to detect changes; the microtask reads\n // fresh values so sequential updates in the same tick are all captured.\n let persistScheduled = false;\n let isInitialPersist = true;\n effect(() => {\n // Track the persisted signals (read them so the effect re-runs on change)\n for (const key of persistKeys as string[]) {\n if (key in stateSignals) stateSignals[key]();\n }\n // Skip the initial run (hydration just happened, don't write stale defaults)\n if (isInitialPersist) { isInitialPersist = false; return; }\n // Schedule a microtask to capture the LATEST values after all sync updates\n if (!persistScheduled) {\n persistScheduled = true;\n queueMicrotask(() => {\n persistScheduled = false;\n // Read fresh values NOW, not when the effect ran\n const snapshot: Record<string, unknown> = {};\n for (const key of persistKeys as string[]) {\n if (key in stateSignals) snapshot[key] = stateSignals[key].peek();\n }\n try { storage.setItem(cfg.key, serialize(snapshot)); } catch { /* quota exceeded */ }\n });\n }\n });\n\n // Cross-tab sync: listen for storage events from other tabs\n if (cfg.storage !== 'sessionStorage') {\n window.addEventListener('storage', (e) => {\n if (e.key !== cfg.key || !e.newValue) return;\n try {\n const updated = deserialize(e.newValue) as Record<string, unknown>;\n for (const key of persistKeys as string[]) {\n if (key in updated && key in stateSignals) {\n stateSignals[key].set(updated[key]);\n }\n }\n } catch { /* ignore parse errors */ }\n });\n }\n }\n }\n\n // --- Sync ---\n if (definition.sync && (definition.sync.enabled !== false)) {\n const syncOpts = definition.sync;\n const syncKeys = syncOpts.pick ?? stateKeys;\n\n const syncState: Record<string, unknown> = {};\n for (const key of syncKeys) {\n syncState[key] = stateSignals[key]?.peek?.() ?? initialState[key as keyof S];\n }\n\n const doc = createSync(syncState as Record<string, unknown>, {\n transport: syncOpts.transport,\n peerId: syncOpts.peerId,\n });\n\n // Wire: local signal changes → sync broadcast\n for (const key of syncKeys) {\n if (!(key in stateSignals) || !(key in doc.state)) continue;\n const localSignal = stateSignals[key];\n const syncSignal = (doc.state as Record<string, any>)[key];\n\n const originalSet = localSignal.set;\n let fromSync = false;\n localSignal.set = (value: unknown) => {\n originalSet.call(localSignal, value);\n if (!fromSync) syncSignal.set(value);\n };\n\n // Listen for remote changes\n effect(() => {\n const remoteVal = syncSignal();\n fromSync = true;\n localSignal.set(remoteVal);\n fromSync = false;\n });\n }\n\n // Expose sync metadata on the store\n (store as any).$sync = {\n peers: doc.peers,\n presence: doc.presence,\n peerPresence: doc.peerPresence,\n peerId: doc.peerId,\n connected: doc.connected,\n connect: doc.connect.bind(doc),\n disconnect: doc.disconnect.bind(doc),\n };\n }\n\n // Initialize plugins\n for (const plugin of plugins) plugin.init?.(store);\n\n return store as Store<S, G, A>;\n}\n\nfunction normalizePersistConfigs<S>(id: string, persist: boolean | PersistOptions<S> | PersistOptions<S>[]): Array<PersistOptions<S> & { key: string }> {\n if (persist === true) {\n return [{ key: `akash-store:${id}` }];\n }\n if (persist === false) return [];\n if (Array.isArray(persist)) {\n return persist.map((p, i) => ({ ...p, key: p.key ?? `akash-store:${id}:${i}` }));\n }\n return [{ ...persist, key: persist.key ?? `akash-store:${id}` }];\n}\n\n/**\n * Clear all store instances (useful for testing).\n */\nexport function clearStores(): void {\n storeInstances.clear();\n}\n\n/** @internal — exposes store registry for devtools */\nexport function __getStoreInstances(): Record<string, Store<any, any, any>> {\n return Object.fromEntries(storeInstances);\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var f=new Set,l=new Set,b=false,d=0,g=false,x=3,P=100;function v(){if(b)return;b=true;let e=new Map,n=false,t=0;for(;(f.size>0||l.size>0)&&t<P;){if(t++,f.size>0){let s=[...f].sort(C);f.clear();for(let r of s){let o=(e.get(r)??0)+1;if(e.set(r,o),o>x){n=true;continue}r.run();}}if(l.size>0){let s=[...l].sort(C);l.clear();for(let r of s){let o=(e.get(r)??0)+1;if(e.set(r,o),o>x){n=true;continue}r.run();}}if(n&&f.size===0&&l.size===0)break}(n||t>=P)&&(f.clear(),l.clear(),console.error("[AkashJS] Circular dependency detected between effects. Two or more effects are writing to each other's dependencies. The cycle has been broken after "+t+" iterations.")),b=false,g&&(g=false,(f.size>0||l.size>0)&&v());}function N(e){e.isRender?f.add(e):l.add(e),d===0&&!b?v():b&&(g=true);}function _(e){d++;try{e()
|
|
1
|
+
'use strict';var f=new Set,l=new Set,b=false,d=0,g=false,x=3,P=100;function v(){if(b)return;b=true;let e=new Map,n=false,t=0;for(;(f.size>0||l.size>0)&&t<P;){if(t++,f.size>0){let s=[...f].sort(C);f.clear();for(let r of s){let o=(e.get(r)??0)+1;if(e.set(r,o),o>x){n=true;continue}r.run();}}if(l.size>0){let s=[...l].sort(C);l.clear();for(let r of s){let o=(e.get(r)??0)+1;if(e.set(r,o),o>x){n=true;continue}r.run();}}if(n&&f.size===0&&l.size===0)break}(n||t>=P)&&(f.clear(),l.clear(),console.error("[AkashJS] Circular dependency detected between effects. Two or more effects are writing to each other's dependencies. The cycle has been broken after "+t+" iterations.")),b=false,g&&(g=false,(f.size>0||l.size>0)&&v());}function N(e){e.isRender?f.add(e):l.add(e),d===0&&!b?v():b&&(g=true);}function _(e){d++;try{return e()}finally{d--,d===0&&v();}}function R(){d++;}function k(){d--,d===0&&v();}function C(e,n){return (e.depth??0)-(n.depth??0)}function M(){v();}var T=false,h=[],S=0;function B(){T=true,h=[],S=performance.now();}function K(){T=false;let e=performance.now();return {entries:[...h],totalDuration:e-S,startTime:S,endTime:e}}function y(){return T}function p(e,n,t){T&&h.push({type:e,name:n,duration:t,timestamp:performance.now()});}function z(e){let n=e.entries.filter(i=>i.type==="render"),t=e.entries.filter(i=>i.type==="effect"),s=e.entries.filter(i=>i.type==="signal-update"),r=e.entries.filter(i=>i.type==="computed"),o=i=>i.length>0?i.reduce((u,m)=>u+m.duration,0)/i.length:0,c=i=>i.length>0?i.reduce((u,m)=>m.duration>u.duration?m:u):null;return {totalRenders:n.length,totalEffects:t.length,totalSignalUpdates:s.length,totalComputedEvals:r.length,avgRenderTime:o(n),avgEffectTime:o(t),slowestRender:c(n),slowestEffect:c(t)}}function O(e,n){let t=performance.now(),s=n(),r=performance.now()-t;return p("render",e,r),{result:s,duration:r}}async function j(e,n){let t=performance.now(),s=await n(),r=performance.now()-t;return p("render",e,r),{result:s,duration:r}}function I(e){let n=0,t=0;return {start(){n=performance.now();},stop(){t=performance.now()-n,p("render",e,t);},get duration(){return t}}}function X(e){let n=z(e),t=`
|
|
2
2
|
Performance Profile
|
|
3
3
|
`;return t+=" "+"\u2500".repeat(50)+`
|
|
4
4
|
`,t+=` Duration: ${e.totalDuration.toFixed(1)} ms
|
|
@@ -9,5 +9,5 @@
|
|
|
9
9
|
`,n.slowestRender&&(t+=` Slowest render: ${n.slowestRender.name} (${n.slowestRender.duration.toFixed(2)} ms)
|
|
10
10
|
`),n.slowestEffect&&(t+=` Slowest effect: ${n.slowestEffect.name} (${n.slowestEffect.duration.toFixed(2)} ms)
|
|
11
11
|
`),t+=" "+"\u2500".repeat(50)+`
|
|
12
|
-
`,t}var F=typeof process>"u"||process.env?.NODE_ENV!=="production";var a=null;function G(e,n){let t={value:e,subscribers:new Set,equals:n?.equals??Object.is},s=()=>(J(t),t.value);return s.set=r=>{F&&a&&a._tag==="computed"&&console.warn("[AkashJS] Writing to a signal inside computed() is not allowed. The write will be lost on the next evaluation."),!t.equals(t.value,r)&&(t.value=r,
|
|
13
|
-
//# sourceMappingURL=chunk-
|
|
12
|
+
`,t}var F=typeof process>"u"||process.env?.NODE_ENV!=="production";var a=null;function G(e,n){let t={value:e,subscribers:new Set,equals:n?.equals??Object.is},s=()=>(J(t),t.value);return s.set=r=>{F&&a&&a._tag==="computed"&&console.warn("[AkashJS] Writing to a signal inside computed() is not allowed. The write will be lost on the next evaluation."),!t.equals(t.value,r)&&(t.value=r,y()&&p("signal-update","signal.set",0),_(()=>{E(t);}));},s.update=r=>{s.set(r(t.value));},s.peek=()=>t.value,s}function Q(e,n){let t={_tag:"computed",fn:e,value:void 0,state:1,subscribers:new Set,sources:new Set,equals:n?.equals??Object.is};return ()=>(a&&(t.subscribers.add(a),"sources"in a&&a.sources.add(t)),t.state!==0&&q(t),t.value)}var w=new Set;function q(e,n=false){if(w.has(e))throw new Error("[AkashJS] Circular dependency detected between computed values.");w.add(e),R();for(let r of e.sources)r.subscribers.delete(e);e.sources.clear();let t=a;a=e;let s=y()?performance.now():0;try{let r=e.fn(),o=e.value===void 0,c=o||!e.equals(e.value,r);if(e.value=r,e.state=0,c&&!o)if(n){for(let i of [...e.subscribers])if(i._tag==="computed"){i.state=1;for(let u of [...i.subscribers])u._tag==="computed"&&(u.state=1);}}else E(e);}finally{s&&p("computed","computed",performance.now()-s),w.delete(e),a=t,k();}}function Y(e,n){let t={_tag:"effect",fn:e,cleanup:null,sources:new Set,disposed:false,isRender:n?.render??false,run(){D(t);}};return D(t),()=>{t.disposed=true,A(t);for(let s of t.sources)s.subscribers.delete(t);t.sources.clear();}}function D(e){if(e.disposed)return;if(e.sources.size>0){let r=false;for(let o of e.sources)if("_tag"in o&&o._tag==="computed"){o.state===1&&q(o,true);let c=e._lastSeen;if(c?.has(o)){let i=c.get(o);o.equals(i,o.value)||(r=true);}else r=true;}else r=true;if(!r)return}A(e);let n=new Set(e.sources);for(let r of e.sources)r.subscribers.delete(e);e.sources.clear();let t=a;a=e;let s=y()?performance.now():0;try{let r=e.fn();typeof r=="function"&&(e.cleanup=r);}catch(r){for(let o of n)o.subscribers.add(e),e.sources.add(o);console.error("[AkashJS] Error in effect (will retry on next signal change):",r);}finally{s&&p("effect","effect",performance.now()-s),a=t;let r=new Map;for(let o of e.sources)"_tag"in o&&o._tag==="computed"&&r.set(o,o.value);r.size>0&&(e._lastSeen=r);}}function A(e){if(e.cleanup){try{e.cleanup();}catch(n){console.error("[AkashJS] Error in effect cleanup (ignored):",n);}e.cleanup=null;}}function U(e){let n=a;a=null;try{return e()}finally{a=n;}}function Z(e,n,t){let s=Array.isArray(e),r=s?e:[e],o,c=true;return ()=>{let i=r.map(m=>m());if(c&&(c=false,o=i.slice(),t?.defer!==false))return;let u=o;return o=i.slice(),U(()=>n(s?i:i[0],u?s?u:u[0]:void 0))}}function J(e){a&&(e.subscribers.add(a),"sources"in a&&a.sources.add(e));}function E(e){let n=[...e.subscribers];for(let t of n)t._tag==="computed"?(t.state=1,E(t)):t._tag==="effect"&&N(t);}exports.a=_;exports.b=M;exports.c=B;exports.d=K;exports.e=y;exports.f=p;exports.g=z;exports.h=O;exports.i=j;exports.j=I;exports.k=X;exports.l=G;exports.m=Q;exports.n=Y;exports.o=U;exports.p=Z;//# sourceMappingURL=chunk-EEILP4OL.cjs.map
|
|
13
|
+
//# sourceMappingURL=chunk-EEILP4OL.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/scheduler.ts","../src/perf.ts","../src/signals.ts"],"names":["pendingRender","pendingUser","flushing","batchDepth","reflushNeeded","MAX_EFFECT_RUNS","MAX_FLUSH_ITERATIONS","flush","runCounts","circularDetected","iterations","queue","byDepth","fx","count","scheduleEffect","batch","fn","enterBatch","exitBatch","a","b","flushSync","profiling","entries","profileStart","startProfiling","stopProfiling","endTime","isProfiling","recordPerfEntry","type","name","duration","getProfileSummary","profile","renders","e","effects","signalUpdates","computeds","avg","arr","s","slowest","measureSync","start","result","measureAsync","createTimer","startTime","dur","formatProfile","summary","out","__DEV__","currentSubscriber","signal","initialValue","options","node","read","trackSubscriber","value","notifySubscribers","computed","recompute","computingSet","skipEffectNotify","source","prevSubscriber","_t0","newValue","isFirst","changed","sub","sub2","effect","runEffect","cleanupEffect","anyChanged","cachedValues","lastSeen","prevSources","err","untrack","prev","on","deps","isArray","depArray","prevValues","values","d","subs"],"mappings":"aAcA,IAAMA,CAAAA,CAAgB,IAAI,GAAA,CACpBC,CAAAA,CAAc,IAAI,GAAA,CACpBC,CAAAA,CAAW,KAAA,CACXC,CAAAA,CAAa,CAAA,CAEbC,EAA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AAAA,CAAI,IAAA,GAAS,YAEfA,CAAAA,CAAI,KAAA,CAAQ,CAAA,CAIZX,CAAAA,CAAkBW,CAAG,CAAA,EACZA,CAAAA,CAAI,OAAS,QAAA,EACtB5D,CAAAA,CAAe4D,CAAG,EAGxB","file":"chunk-EEILP4OL.cjs","sourcesContent":["/**\n * Microtask-based effect scheduler with priority levels and deduplication.\n *\n * Render effects (DOM bindings) run before user effects to ensure\n * DOM is consistent before user-side effects execute.\n */\n\nexport interface ScheduledEffect {\n run(): void;\n isRender: boolean;\n /** Depth in the dependency graph (0 = root). Lower depth runs first. */\n depth?: number;\n}\n\nconst pendingRender = new Set<ScheduledEffect>();\nconst pendingUser = new Set<ScheduledEffect>();\nlet flushing = false;\nlet batchDepth = 0;\nlet flushScheduled = false;\nlet reflushNeeded = false;\n\nconst MAX_EFFECT_RUNS = 3;\nconst MAX_FLUSH_ITERATIONS = 100;\n\nfunction flush(): void {\n if (flushing) return;\n flushing = true;\n flushScheduled = false;\n\n // Fresh per-effect run counter for THIS flush — reset every time\n const runCounts = new Map<ScheduledEffect, number>();\n let circularDetected = false;\n\n // Process render effects first, then user effects.\n // Effects may enqueue more effects during flush, so loop until empty.\n let iterations = 0;\n while ((pendingRender.size > 0 || pendingUser.size > 0) && iterations < MAX_FLUSH_ITERATIONS) {\n iterations++;\n\n // Drain render effects (sorted by depth — parents before children)\n if (pendingRender.size > 0) {\n const queue = [...pendingRender].sort(byDepth);\n pendingRender.clear();\n for (const fx of queue) {\n const count = (runCounts.get(fx) ?? 0) + 1;\n runCounts.set(fx, count);\n if (count > MAX_EFFECT_RUNS) {\n circularDetected = true;\n continue; // skip this effect — it's in a cycle\n }\n fx.run();\n }\n }\n\n // Drain user effects (sorted by depth)\n if (pendingUser.size > 0) {\n const queue = [...pendingUser].sort(byDepth);\n pendingUser.clear();\n for (const fx of queue) {\n const count = (runCounts.get(fx) ?? 0) + 1;\n runCounts.set(fx, count);\n if (count > MAX_EFFECT_RUNS) {\n circularDetected = true;\n continue; // skip this effect — it's in a cycle\n }\n fx.run();\n }\n }\n\n // If all remaining effects were skipped due to cycle detection, break\n if (circularDetected && pendingRender.size === 0 && pendingUser.size === 0) {\n break;\n }\n }\n\n if (circularDetected || iterations >= MAX_FLUSH_ITERATIONS) {\n pendingRender.clear();\n pendingUser.clear();\n console.error(\n '[AkashJS] Circular dependency detected between effects. ' +\n 'Two or more effects are writing to each other\\'s dependencies. ' +\n 'The cycle has been broken after ' + iterations + ' iterations.'\n );\n }\n\n flushing = false;\n\n // If effects were scheduled during the tail end of this flush (after the\n // while loop's condition was last checked), re-flush them now.\n if (reflushNeeded) {\n reflushNeeded = false;\n if (pendingRender.size > 0 || pendingUser.size > 0) {\n flush();\n }\n }\n}\n\nexport function scheduleEffect(fx: ScheduledEffect): void {\n if (fx.isRender) {\n pendingRender.add(fx);\n } else {\n pendingUser.add(fx);\n }\n\n if (batchDepth === 0 && !flushing) {\n flush();\n } else if (flushing) {\n // Effects were added during a flush. The while loop may still pick them\n // up, but if it has already checked the queues and found them empty,\n // we need a re-flush after the current one completes.\n reflushNeeded = true;\n }\n}\n\n/**\n * Batch multiple signal writes — subscribers are notified only once\n * at the end of the batch.\n */\nexport function batch<T>(fn: () => T): T {\n batchDepth++;\n try {\n return fn();\n } finally {\n batchDepth--;\n if (batchDepth === 0) {\n flush();\n }\n }\n}\n\n/** Enter/exit batch depth — used by computed recompute to prevent mid-evaluation flush */\nexport function enterBatch(): void { batchDepth++; }\nexport function exitBatch(): void {\n batchDepth--;\n if (batchDepth === 0) flush();\n}\n\n/** Sort effects by depth (lower depth first = parents before children) */\nfunction byDepth(a: ScheduledEffect, b: ScheduledEffect): number {\n return (a.depth ?? 0) - (b.depth ?? 0);\n}\n\n/** Synchronously flush all pending effects. Useful for testing. */\nexport function flushSync(): void {\n flush();\n}\n","/**\n * Performance profiling utilities.\n *\n * Measure component render times, signal propagation, and\n * effect execution for performance debugging.\n *\n * ```ts\n * import { startProfiling, stopProfiling, getProfile } from '@akashjs/runtime';\n *\n * startProfiling();\n * // ... do stuff ...\n * stopProfiling();\n * console.table(getProfile().entries);\n * ```\n */\n\n// --- Types ---\n\nexport interface PerfEntry {\n type: 'render' | 'effect' | 'signal-update' | 'computed';\n name: string;\n duration: number;\n timestamp: number;\n}\n\nexport interface PerfProfile {\n entries: PerfEntry[];\n totalDuration: number;\n startTime: number;\n endTime: number;\n}\n\nexport interface PerfSummary {\n totalRenders: number;\n totalEffects: number;\n totalSignalUpdates: number;\n totalComputedEvals: number;\n avgRenderTime: number;\n avgEffectTime: number;\n slowestRender: PerfEntry | null;\n slowestEffect: PerfEntry | null;\n}\n\n// --- Profiling state ---\n\nlet profiling = false;\nlet entries: PerfEntry[] = [];\nlet profileStart = 0;\n\n// --- Public API ---\n\n/**\n * Start profiling. Clears previous data.\n */\nexport function startProfiling(): void {\n profiling = true;\n entries = [];\n profileStart = performance.now();\n}\n\n/**\n * Stop profiling.\n */\nexport function stopProfiling(): PerfProfile {\n profiling = false;\n const endTime = performance.now();\n\n return {\n entries: [...entries],\n totalDuration: endTime - profileStart,\n startTime: profileStart,\n endTime,\n };\n}\n\n/**\n * Check if profiling is active.\n */\nexport function isProfiling(): boolean {\n return profiling;\n}\n\n/**\n * Record a performance entry (called internally by the framework).\n */\nexport function recordPerfEntry(\n type: PerfEntry['type'],\n name: string,\n duration: number,\n): void {\n if (!profiling) return;\n entries.push({\n type,\n name,\n duration,\n timestamp: performance.now(),\n });\n}\n\n/**\n * Get a summary of the profiling data.\n */\nexport function getProfileSummary(profile: PerfProfile): PerfSummary {\n const renders = profile.entries.filter((e) => e.type === 'render');\n const effects = profile.entries.filter((e) => e.type === 'effect');\n const signalUpdates = profile.entries.filter((e) => e.type === 'signal-update');\n const computeds = profile.entries.filter((e) => e.type === 'computed');\n\n const avg = (arr: PerfEntry[]) =>\n arr.length > 0 ? arr.reduce((s, e) => s + e.duration, 0) / arr.length : 0;\n\n const slowest = (arr: PerfEntry[]) =>\n arr.length > 0 ? arr.reduce((s, e) => (e.duration > s.duration ? e : s)) : null;\n\n return {\n totalRenders: renders.length,\n totalEffects: effects.length,\n totalSignalUpdates: signalUpdates.length,\n totalComputedEvals: computeds.length,\n avgRenderTime: avg(renders),\n avgEffectTime: avg(effects),\n slowestRender: slowest(renders),\n slowestEffect: slowest(effects),\n };\n}\n\n// --- Measurement helpers ---\n\n/**\n * Measure the time to execute a function.\n *\n * ```ts\n * const { result, duration } = measureSync('my-operation', () => expensiveWork());\n * ```\n */\nexport function measureSync<T>(name: string, fn: () => T): { result: T; duration: number } {\n const start = performance.now();\n const result = fn();\n const duration = performance.now() - start;\n recordPerfEntry('render', name, duration);\n return { result, duration };\n}\n\n/**\n * Measure the time to execute an async function.\n */\nexport async function measureAsync<T>(\n name: string,\n fn: () => Promise<T>,\n): Promise<{ result: T; duration: number }> {\n const start = performance.now();\n const result = await fn();\n const duration = performance.now() - start;\n recordPerfEntry('render', name, duration);\n return { result, duration };\n}\n\n/**\n * Create a named timer for manual start/stop measurement.\n *\n * ```ts\n * const timer = createTimer('data-fetch');\n * timer.start();\n * await fetch(...);\n * timer.stop(); // records the entry\n * timer.duration; // ms\n * ```\n */\nexport function createTimer(name: string) {\n let startTime = 0;\n let dur = 0;\n\n return {\n start() { startTime = performance.now(); },\n stop() {\n dur = performance.now() - startTime;\n recordPerfEntry('render', name, dur);\n },\n get duration() { return dur; },\n };\n}\n\n/**\n * Format a profile for console output.\n */\nexport function formatProfile(profile: PerfProfile): string {\n const summary = getProfileSummary(profile);\n let out = '\\n Performance Profile\\n';\n out += ' ' + '─'.repeat(50) + '\\n';\n out += ` Duration: ${profile.totalDuration.toFixed(1)} ms\\n`;\n out += ` Renders: ${summary.totalRenders} (avg ${summary.avgRenderTime.toFixed(2)} ms)\\n`;\n out += ` Effects: ${summary.totalEffects} (avg ${summary.avgEffectTime.toFixed(2)} ms)\\n`;\n out += ` Signal updates: ${summary.totalSignalUpdates}\\n`;\n out += ` Computed evals: ${summary.totalComputedEvals}\\n`;\n\n if (summary.slowestRender) {\n out += ` Slowest render: ${summary.slowestRender.name} (${summary.slowestRender.duration.toFixed(2)} ms)\\n`;\n }\n if (summary.slowestEffect) {\n out += ` Slowest effect: ${summary.slowestEffect.name} (${summary.slowestEffect.duration.toFixed(2)} ms)\\n`;\n }\n\n out += ' ' + '─'.repeat(50) + '\\n';\n return out;\n}\n","/**\n * Fine-grained reactivity system.\n *\n * Inspired by SolidJS/Preact Signals. Provides signal(), computed(),\n * effect(), and untrack() primitives with automatic dependency tracking\n * and glitch-free diamond dependency resolution.\n */\n\nimport { scheduleEffect, batch, enterBatch, exitBatch, type ScheduledEffect } from './scheduler.js';\nimport { recordPerfEntry, isProfiling } from './perf.js';\n\nconst __DEV__ = typeof process === 'undefined' || process.env?.NODE_ENV !== 'production';\n\n/** Depth counter to defer effect scheduling until all notifications complete (glitch-free) */\nlet notifyDepth = 0;\n\n// --- Tracking scope ---\n\ntype Subscriber = EffectNode | ComputedNode<any>;\n\nlet currentSubscriber: Subscriber | null = null;\n\n// --- Signal ---\n\nexport interface Signal<T> {\n /** Read the current value (tracks dependency if inside a reactive scope) */\n (): T;\n /** Set a new value */\n set(value: T): void;\n /** Update the value using the previous value */\n update(fn: (prev: T) => T): void;\n /** Read without tracking (no dependency registered) */\n peek(): T;\n}\n\nexport type ReadonlySignal<T> = () => T;\n\ninterface SignalNode<T> {\n value: T;\n subscribers: Set<Subscriber>;\n equals: (a: T, b: T) => boolean;\n}\n\nexport function signal<T>(\n initialValue: T,\n options?: { equals?: (a: T, b: T) => boolean },\n): Signal<T> {\n const node: SignalNode<T> = {\n value: initialValue,\n subscribers: new Set(),\n equals: options?.equals ?? Object.is,\n };\n\n const read = (): T => {\n trackSubscriber(node);\n return node.value;\n };\n\n read.set = (value: T): void => {\n if (__DEV__ && currentSubscriber && currentSubscriber._tag === 'computed') {\n console.warn('[AkashJS] Writing to a signal inside computed() is not allowed. The write will be lost on the next evaluation.');\n }\n if (node.equals(node.value, value)) return;\n node.value = value;\n if (isProfiling()) recordPerfEntry('signal-update', 'signal.set', 0);\n batch(() => { notifySubscribers(node); });\n };\n\n read.update = (fn: (prev: T) => T): void => {\n read.set(fn(node.value));\n };\n\n read.peek = (): T => node.value;\n\n return read;\n}\n\n// --- Computed ---\n\nconst enum ComputedState {\n Clean = 0,\n Dirty = 1,\n}\n\ninterface ComputedNode<T> {\n _tag: 'computed';\n fn: () => T;\n value: T | undefined;\n state: ComputedState;\n subscribers: Set<Subscriber>;\n sources: Set<SignalNode<any> | ComputedNode<any>>;\n equals: (a: T, b: T) => boolean;\n}\n\nexport function computed<T>(\n fn: () => T,\n options?: { equals?: (a: T, b: T) => boolean },\n): ReadonlySignal<T> {\n const node: ComputedNode<T> = {\n _tag: 'computed',\n fn,\n value: undefined,\n state: ComputedState.Dirty,\n subscribers: new Set(),\n sources: new Set(),\n equals: options?.equals ?? Object.is,\n };\n\n const read = (): T => {\n // Track this computed as a dependency of the current subscriber\n if (currentSubscriber) {\n node.subscribers.add(currentSubscriber);\n if ('sources' in currentSubscriber) {\n currentSubscriber.sources.add(node);\n }\n }\n\n if (node.state !== ComputedState.Clean) {\n recompute(node);\n }\n\n return node.value as T;\n };\n\n return read;\n}\n\nconst computingSet = new Set<ComputedNode<unknown>>();\n\n/**\n * @param skipEffectNotify - When true, don't schedule effects in notifySubscribers.\n * Used when recompute is called from runEffect's dirty check — the effect is\n * already being processed, re-scheduling it would trigger the circular run limit.\n */\nfunction recompute<T>(node: ComputedNode<T>, skipEffectNotify = false): void {\n // Detect circular computed dependencies — only if THIS node is already being computed\n if (computingSet.has(node as ComputedNode<unknown>)) {\n throw new Error('[AkashJS] Circular dependency detected between computed values.');\n }\n computingSet.add(node as ComputedNode<unknown>);\n\n // Prevent effects from flushing while computed is evaluating.\n // Without this, a computed that reads other dirty computeds can trigger\n // notifySubscribers → scheduleEffect → flush → re-enter recompute on\n // a node still in computingSet (false circular detection).\n enterBatch();\n\n // Clean up old source subscriptions\n for (const source of node.sources) {\n source.subscribers.delete(node);\n }\n node.sources.clear();\n\n const prevSubscriber = currentSubscriber;\n currentSubscriber = node;\n\n const _t0 = isProfiling() ? performance.now() : 0;\n try {\n const newValue = node.fn();\n const isFirst = node.value === undefined;\n const changed = isFirst || !node.equals(node.value as T, newValue);\n node.value = newValue;\n node.state = ComputedState.Clean;\n\n // Only propagate if value actually changed (skip first computation —\n // the effect that triggered the read is already running).\n if (changed && !isFirst) {\n if (skipEffectNotify) {\n // Only mark downstream computeds as dirty — don't schedule effects.\n // Effects are already handled by the runEffect that triggered this recompute.\n for (const sub of [...node.subscribers]) {\n if (sub._tag === 'computed') {\n sub.state = ComputedState.Dirty;\n // Recursively propagate to further computeds\n for (const sub2 of [...sub.subscribers]) {\n if (sub2._tag === 'computed') sub2.state = ComputedState.Dirty;\n }\n }\n }\n } else {\n notifySubscribers(node);\n }\n }\n } finally {\n if (_t0) recordPerfEntry('computed', 'computed', performance.now() - _t0);\n computingSet.delete(node as ComputedNode<unknown>);\n currentSubscriber = prevSubscriber;\n exitBatch();\n }\n}\n\n// --- Effect ---\n\ninterface EffectNode extends ScheduledEffect {\n _tag: 'effect';\n fn: () => void | (() => void);\n cleanup: (() => void) | null;\n sources: Set<SignalNode<any> | ComputedNode<any>>;\n disposed: boolean;\n isRender: boolean;\n}\n\nexport function effect(\n fn: () => void | (() => void),\n options?: { render?: boolean },\n): () => void {\n const node: EffectNode = {\n _tag: 'effect',\n fn,\n cleanup: null,\n sources: new Set(),\n disposed: false,\n isRender: options?.render ?? false,\n run() {\n runEffect(node);\n },\n };\n\n // Run immediately to establish dependencies\n runEffect(node);\n\n // Return dispose function\n return () => {\n node.disposed = true;\n cleanupEffect(node);\n for (const source of node.sources) {\n source.subscribers.delete(node);\n }\n node.sources.clear();\n };\n}\n\nfunction runEffect(node: EffectNode): void {\n if (node.disposed) return;\n\n // Before re-running, check if any dirty computed source actually changed.\n // Compare against per-effect cached values (not the shared source.value which\n // may have been updated by another effect's recompute already).\n if (node.sources.size > 0) {\n let anyChanged = false;\n for (const source of node.sources) {\n if ('_tag' in source && source._tag === 'computed') {\n if (source.state === ComputedState.Dirty) {\n recompute(source, true);\n }\n // Compare against this effect's last-seen value (not the shared source.value\n // which another effect's recompute may have already updated)\n const cachedValues = (node as any)._lastSeen as Map<unknown, unknown> | undefined;\n if (cachedValues?.has(source)) {\n const lastSeen = cachedValues.get(source);\n if (!source.equals(lastSeen as never, source.value as never)) {\n anyChanged = true;\n }\n } else {\n // No cached value — first dirty check after creation. Always run.\n anyChanged = true;\n }\n } else {\n // Plain signal source — if we got scheduled, something changed\n anyChanged = true;\n }\n }\n if (!anyChanged) return;\n }\n\n // Clean up previous run\n cleanupEffect(node);\n\n // Save old sources in case the effect throws — we need to re-subscribe\n const prevSources = new Set(node.sources);\n\n // Clean up old source subscriptions\n for (const source of node.sources) {\n source.subscribers.delete(node);\n }\n node.sources.clear();\n\n const prevSubscriber = currentSubscriber;\n currentSubscriber = node;\n const _t0 = isProfiling() ? performance.now() : 0;\n\n try {\n const result = node.fn();\n if (typeof result === 'function') {\n node.cleanup = result;\n }\n } catch (err) {\n // Re-subscribe to previous sources so the effect can recover on next change\n for (const source of prevSources) {\n source.subscribers.add(node);\n node.sources.add(source);\n }\n console.error('[AkashJS] Error in effect (will retry on next signal change):', err);\n } finally {\n if (_t0) recordPerfEntry('effect', 'effect', performance.now() - _t0);\n currentSubscriber = prevSubscriber;\n\n // Cache computed values so the next dirty check compares against THIS effect's\n // last-seen values, not the shared source.value (which another effect may update)\n const lastSeen = new Map();\n for (const source of node.sources) {\n if ('_tag' in source && source._tag === 'computed') {\n lastSeen.set(source, source.value);\n }\n }\n if (lastSeen.size > 0) (node as any)._lastSeen = lastSeen;\n }\n}\n\nfunction cleanupEffect(node: EffectNode): void {\n if (node.cleanup) {\n try {\n node.cleanup();\n } catch (err) {\n console.error('[AkashJS] Error in effect cleanup (ignored):', err);\n }\n node.cleanup = null;\n }\n}\n\n// --- Untrack ---\n\n/** Execute a function without tracking any signal reads */\nexport function untrack<T>(fn: () => T): T {\n const prev = currentSubscriber;\n currentSubscriber = null;\n try {\n return fn();\n } finally {\n currentSubscriber = prev;\n }\n}\n\n// --- on() helper ---\n\n/**\n * Create an effect callback that only tracks specific signals.\n * All other signal reads inside the callback are untracked.\n *\n * ```ts\n * effect(on(url, (currentUrl, prevUrl) => {\n * fetch(currentUrl, options()); // options() not tracked\n * }));\n *\n * effect(on([url, page], ([u, p], prev) => {\n * fetch(`${u}?page=${p}`);\n * }));\n * ```\n */\nexport function on<T>(\n dep: () => T,\n fn: (value: T, prev: T | undefined) => void | (() => void),\n options?: { defer?: boolean },\n): () => void | (() => void);\nexport function on<T extends readonly (() => unknown)[]>(\n deps: [...T],\n fn: (values: { [K in keyof T]: ReturnType<T[K]> }, prev: { [K in keyof T]: ReturnType<T[K]> } | undefined) => void | (() => void),\n options?: { defer?: boolean },\n): () => void | (() => void);\nexport function on(\n deps: (() => any) | (() => any)[],\n fn: (values: any, prev: any) => void | (() => void),\n options?: { defer?: boolean },\n): () => void | (() => void) {\n const isArray = Array.isArray(deps);\n const depArray = isArray ? deps : [deps];\n let prevValues: unknown[] | undefined;\n let isFirst = true;\n\n return () => {\n // Track only the specified deps\n const values = depArray.map(d => d());\n\n // Skip the initial effect run — only fire on actual changes\n // (pass { defer: false } to opt out and run immediately)\n if (isFirst) {\n isFirst = false;\n prevValues = values.slice();\n if (options?.defer !== false) return;\n }\n\n const prev = prevValues;\n prevValues = values.slice();\n\n // Run fn without tracking so reads inside don't create subscriptions\n return untrack(() => fn(\n isArray ? values : values[0],\n prev ? (isArray ? prev : prev[0]) : undefined,\n ));\n };\n}\n\n// --- Internal helpers ---\n\nfunction trackSubscriber(\n node: SignalNode<any> | ComputedNode<any>,\n): void {\n if (currentSubscriber) {\n node.subscribers.add(currentSubscriber);\n\n if ('sources' in currentSubscriber) {\n currentSubscriber.sources.add(node);\n }\n }\n}\n\nfunction notifySubscribers(\n node: SignalNode<any> | ComputedNode<any>,\n): void {\n // Snapshot subscribers before iterating. Effects that run synchronously\n // during flush() will delete and re-add themselves to the Set, and JS\n // Set iterators visit newly added entries — causing an infinite loop\n // without the snapshot.\n const subs = [...node.subscribers];\n for (const sub of subs) {\n if (sub._tag === 'computed') {\n // Mark dirty. The computed will re-evaluate lazily when read.\n sub.state = ComputedState.Dirty;\n // Propagate through the computed chain to reach effects.\n // The effects will re-read the computed, triggering recompute,\n // and only update DOM if the value actually changed.\n notifySubscribers(sub);\n } else if (sub._tag === 'effect') {\n scheduleEffect(sub);\n }\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {n,o}from'./chunk-
|
|
1
|
+
import {n,o}from'./chunk-3GRR4VW2.js';var w={AK0010:{code:"AK0010",message:"provide() called outside of component setup.",hint:"provide() must be called inside defineComponent()."},AK0012:{code:"AK0012",message:"inject() called outside of component setup.",hint:"inject() must be called inside defineComponent()."},AK0013:{code:"AK0013",message:"No provider found for injected context.",hint:"Make sure an ancestor component calls provide() with this key."},AK0020:{code:"AK0020",message:"onMount() called outside of component setup.",hint:"onMount() must be called inside defineComponent()."},AK0021:{code:"AK0021",message:"onUnmount() called outside of component setup.",hint:"onUnmount() must be called inside defineComponent()."},AK0022:{code:"AK0022",message:"onError() called outside of component setup.",hint:"onError() must be called inside defineComponent()."},AK0030:{code:"AK0030",message:"Circular dependency detected in computed signal.",hint:"A computed signal is reading itself, directly or via other computeds."},AK0031:{code:"AK0031",message:"Signal set() called during computation.",hint:"Do not set signals inside computed() or during effect execution. Use batch() or set signals in event handlers."},AK0040:{code:"AK0040",message:"Component setup must return a render function.",hint:"The function passed to defineComponent() must return () => AkashNode."},AK0041:{code:"AK0041",message:"Required prop is missing.",hint:"Check that the parent component is passing all required props."},AK0050:{code:"AK0050",message:"useRoute() called outside of router context.",hint:"Make sure your component is rendered inside a router provider."},AK0051:{code:"AK0051",message:"No route matched the current URL.",hint:"Add a catch-all route ([...rest]) to handle unmatched paths."},AK0052:{code:"AK0052",message:"Route guard threw an error.",hint:"Check the guard function for unhandled exceptions."},AK0060:{code:"AK0060",message:"Form submitted while invalid.",hint:"The submit handler was not called because validation failed. Check form.errors()."},AK0061:{code:"AK0061",message:"Async validator timed out.",hint:"The async validator did not resolve within the expected time. Check your async validation logic."},AK0070:{code:"AK0070",message:"HTTP request failed.",hint:"Check the server response status and network connectivity."},AK0071:{code:"AK0071",message:"createResource() fetcher threw an error.",hint:"Check the fetcher function passed to createResource()."}},P="https://akashjs.dev/errors";function R(e,n){let o=w[e];if(!o)return `[AkashJS ${e}] Unknown error code.`;let s=`[AkashJS ${e}] ${o.message}`;return n&&(s+=`
|
|
2
2
|
${n}`),s+=`
|
|
3
3
|
${o.hint}`,s+=`
|
|
4
|
-
See: ${P}/${e}`,s}function T(e,n){return new Error(R(e,n))}function F(e){return w[e]}function _(){return Object.keys(w)}var D=Symbol("akash.context"),m=null;function S(e=m){let n={values:new Map,parent:e};return m=n,n}function K(e){m=e.parent;}function C(){return m}function v(e,n){let o=m;m=e;try{return n()}finally{m=o;}}function O(e){return {[D]:true,_type:void 0,defaultValue:e,id:Symbol("context")}}function $(e,n){if(!m)throw T("AK0010");m.values.set(e.id,n);}function U(e,n){if(!m)throw T("AK0012");let o=m;for(;o;){if(o.values.has(e.id))return o.values.get(e.id);o=o.parent;}if(n!==void 0)return n;if(e.defaultValue!==void 0)return e.defaultValue;throw T("AK0013")}function W(e,n){let o=document.createElement(e);if(n)for(let[s,a]of Object.entries(n))b(o,s,a);return o}function X(e){return document.createTextNode(e)}function G(e){let n=document.createElement("template");return n.innerHTML=e,n.content.cloneNode(true)}function b(e,n,o){if(n==="class"||n==="className")e.className=o;else if(n==="style"&&typeof o=="object"&&o!==null)Object.assign(e.style,o);else if(n==="innerHTML")e.innerHTML=o;else if(n!=="ref")if(n.startsWith("on")){let s=n.slice(2).toLowerCase();e.addEventListener(s,o);}else n in e?e[n]=o:o===false||o==null?e.removeAttribute(n):e.setAttribute(n,o===true?"":String(o));}function Y(e,n$1){return n(()=>{e.textContent=String(n$1());},{render:true})}function z(e,n$1,o){return n(()=>{b(e,n$1,o());},{render:true})}function Q(e,n$1){return n(()=>{e.style.display=n$1()?"":"none";},{render:true})}function L(e=""){return document.createComment(e)}function j(e,n$1,o,s,a){let i=null,g=C(),y=n(()=>{let c=o();if(i){for(let f of i.nodes)try{f.parentNode?.removeChild(f);}catch{}i.dispose?.(),i=null;}let d=c?s:a,p=n$1.parentNode;if(!p&&i?.nodes[0]?.parentNode&&(p=i.nodes[0].parentNode),d&&p){let f=g?v(g,d):d(),t=f instanceof DocumentFragment?Array.from(f.childNodes):[f];for(let r of t)p.insertBefore(r,n$1);i={nodes:t,dispose:null};}},{render:true});return ()=>{if(y(),i){for(let c of i.nodes)try{c.parentNode?.removeChild(c);}catch{}i.dispose?.();}}}function H(e,n$1,o,s,a){let i=[],g=C(),y=n(()=>{let c=o(),d=[],p=new Map;for(let t of i)p.set(t.key,t);for(let t=0;t<c.length;t++){let r=c[t],u=s(r,t),l=p.get(u);if(l){p.delete(u);let A=l.nodes[0];if(A&&!A.parentNode){let k=g?v(g,()=>a(r,t)):a(r,t),M=k instanceof DocumentFragment?Array.from(k.childNodes):[k];d.push({key:u,value:r,nodes:M,dispose:null});}else l.value=r,d.push(l);}else {let A=g?v(g,()=>a(r,t)):a(r,t),k=A instanceof DocumentFragment?Array.from(A.childNodes):[A];d.push({key:u,value:r,nodes:k,dispose:null});}}for(let t of p.values()){for(let r of t.nodes)r.parentNode&&r.parentNode.removeChild(r);t.dispose?.();}let f=n$1.parentNode;if(f)for(let t of d)for(let r of t.nodes)f.insertBefore(r,n$1);else {let t=null;for(let r of i)if(r.nodes[0]?.parentNode){t=r.nodes[0].parentNode;break}if(t)for(let r of d)for(let u of r.nodes)t.appendChild(u);}i=d;},{render:true});return ()=>{y();for(let c of i){for(let d of c.nodes)d.parentNode&&d.parentNode.removeChild(d);c.dispose?.();}i=[];}}function Z(e){let n=L("show"),o=document.createDocumentFragment();o.appendChild(n);let s=typeof e.when=="function"?e.when:()=>e.when,a;return j(o,n,()=>(a=s(),!!a),()=>x(e.children(a)),e.fallback?()=>x(e.fallback()):void 0),o}function ee(e){let n=L("for"),o=document.createDocumentFragment();o.appendChild(n);let s=typeof e.each=="function"?e.each:()=>e.each;return H(o,n,s,e.key,(a,i)=>x(e.children(a,i))),o}function x(e){if(e==null||typeof e=="boolean")return document.createTextNode("");if(typeof e=="string"||typeof e=="number")return document.createTextNode(String(e));if(e instanceof Node)return e;if(Array.isArray(e)){let n=document.createDocumentFragment();for(let o of e)n.appendChild(x(o));return n}return document.createTextNode(String(e))}function ne(e,n,o){let s=x(n);o?e.insertBefore(s,o):e.appendChild(s);}function de(e){return e.__reactive=true,e}var h=null;function ae(e){if(!h)throw T("AK0020");h.mount.push(e);}function ue(e){if(!h)throw T("AK0021");h.unmount.push(e);}function le(e){if(!h)throw T("AK0022");h.error.push(e);}function fe(e){return {current:e}}function pe(e){let n=o$1=>{let{children:s,...a}=o$1??{},y={props:a,children:typeof s=="function"?s:()=>s??null},c={mount:[],unmount:[],error:[]},d=h;h=c;let p=C(),f=S(p),t,r;try{r=o(()=>{if(t=e(y),typeof t!="function")throw T("AK0040");let u=t();return x(u)});}catch(u){if(K(f),h=d,c.error.length>0){for(let l of c.error)l(u instanceof Error?u:new Error(String(u)));return document.createComment("error")}throw u}return K(f),h=d,c.mount.length>0&&queueMicrotask(()=>{for(let u of c.mount)try{let l=u();typeof l=="function"&&c.unmount.push(l);}catch(l){for(let A of c.error)A(l instanceof Error?l:new Error(String(l)));}}),r};return n._akash=true,n}export{fe as A,pe as B,R as a,T as b,F as c,_ as d,C as e,v as f,O as g,$ as h,U as i,W as j,X as k,G as l,b as m,Y as n,z as o,Q as p,j as q,H as r,Z as s,ee as t,x as u,ne as v,de as w,ae as x,ue as y,le as z};//# sourceMappingURL=chunk-
|
|
5
|
-
//# sourceMappingURL=chunk-
|
|
4
|
+
See: ${P}/${e}`,s}function T(e,n){return new Error(R(e,n))}function F(e){return w[e]}function _(){return Object.keys(w)}var D=Symbol("akash.context"),m=null;function S(e=m){let n={values:new Map,parent:e};return m=n,n}function K(e){m=e.parent;}function C(){return m}function v(e,n){let o=m;m=e;try{return n()}finally{m=o;}}function O(e){return {[D]:true,_type:void 0,defaultValue:e,id:Symbol("context")}}function $(e,n){if(!m)throw T("AK0010");m.values.set(e.id,n);}function U(e,n){if(!m)throw T("AK0012");let o=m;for(;o;){if(o.values.has(e.id))return o.values.get(e.id);o=o.parent;}if(n!==void 0)return n;if(e.defaultValue!==void 0)return e.defaultValue;throw T("AK0013")}function W(e,n){let o=document.createElement(e);if(n)for(let[s,a]of Object.entries(n))b(o,s,a);return o}function X(e){return document.createTextNode(e)}function G(e){let n=document.createElement("template");return n.innerHTML=e,n.content.cloneNode(true)}function b(e,n,o){if(n==="class"||n==="className")e.className=o;else if(n==="style"&&typeof o=="object"&&o!==null)Object.assign(e.style,o);else if(n==="innerHTML")e.innerHTML=o;else if(n!=="ref")if(n.startsWith("on")){let s=n.slice(2).toLowerCase();e.addEventListener(s,o);}else n in e?e[n]=o:o===false||o==null?e.removeAttribute(n):e.setAttribute(n,o===true?"":String(o));}function Y(e,n$1){return n(()=>{e.textContent=String(n$1());},{render:true})}function z(e,n$1,o){return n(()=>{b(e,n$1,o());},{render:true})}function Q(e,n$1){return n(()=>{e.style.display=n$1()?"":"none";},{render:true})}function L(e=""){return document.createComment(e)}function j(e,n$1,o,s,a){let i=null,g=C(),y=n(()=>{let c=o();if(i){for(let f of i.nodes)try{f.parentNode?.removeChild(f);}catch{}i.dispose?.(),i=null;}let d=c?s:a,p=n$1.parentNode;if(!p&&i?.nodes[0]?.parentNode&&(p=i.nodes[0].parentNode),d&&p){let f=g?v(g,d):d(),t=f instanceof DocumentFragment?Array.from(f.childNodes):[f];for(let r of t)p.insertBefore(r,n$1);i={nodes:t,dispose:null};}},{render:true});return ()=>{if(y(),i){for(let c of i.nodes)try{c.parentNode?.removeChild(c);}catch{}i.dispose?.();}}}function H(e,n$1,o,s,a){let i=[],g=C(),y=n(()=>{let c=o(),d=[],p=new Map;for(let t of i)p.set(t.key,t);for(let t=0;t<c.length;t++){let r=c[t],u=s(r,t),l=p.get(u);if(l){p.delete(u);let A=l.nodes[0];if(A&&!A.parentNode){let k=g?v(g,()=>a(r,t)):a(r,t),M=k instanceof DocumentFragment?Array.from(k.childNodes):[k];d.push({key:u,value:r,nodes:M,dispose:null});}else l.value=r,d.push(l);}else {let A=g?v(g,()=>a(r,t)):a(r,t),k=A instanceof DocumentFragment?Array.from(A.childNodes):[A];d.push({key:u,value:r,nodes:k,dispose:null});}}for(let t of p.values()){for(let r of t.nodes)r.parentNode&&r.parentNode.removeChild(r);t.dispose?.();}let f=n$1.parentNode;if(f)for(let t of d)for(let r of t.nodes)f.insertBefore(r,n$1);else {let t=null;for(let r of i)if(r.nodes[0]?.parentNode){t=r.nodes[0].parentNode;break}if(t)for(let r of d)for(let u of r.nodes)t.appendChild(u);}i=d;},{render:true});return ()=>{y();for(let c of i){for(let d of c.nodes)d.parentNode&&d.parentNode.removeChild(d);c.dispose?.();}i=[];}}function Z(e){let n=L("show"),o=document.createDocumentFragment();o.appendChild(n);let s=typeof e.when=="function"?e.when:()=>e.when,a;return j(o,n,()=>(a=s(),!!a),()=>x(e.children(a)),e.fallback?()=>x(e.fallback()):void 0),o}function ee(e){let n=L("for"),o=document.createDocumentFragment();o.appendChild(n);let s=typeof e.each=="function"?e.each:()=>e.each;return H(o,n,s,e.key,(a,i)=>x(e.children(a,i))),o}function x(e){if(e==null||typeof e=="boolean")return document.createTextNode("");if(typeof e=="string"||typeof e=="number")return document.createTextNode(String(e));if(e instanceof Node)return e;if(Array.isArray(e)){let n=document.createDocumentFragment();for(let o of e)n.appendChild(x(o));return n}return document.createTextNode(String(e))}function ne(e,n,o){let s=x(n);o?e.insertBefore(s,o):e.appendChild(s);}function de(e){return e.__reactive=true,e}var h=null;function ae(e){if(!h)throw T("AK0020");h.mount.push(e);}function ue(e){if(!h)throw T("AK0021");h.unmount.push(e);}function le(e){if(!h)throw T("AK0022");h.error.push(e);}function fe(e){return {current:e}}function pe(e){let n=o$1=>{let{children:s,...a}=o$1??{},y={props:a,children:typeof s=="function"?s:()=>s??null},c={mount:[],unmount:[],error:[]},d=h;h=c;let p=C(),f=S(p),t,r;try{r=o(()=>{if(t=e(y),typeof t!="function")throw T("AK0040");let u=t();return x(u)});}catch(u){if(K(f),h=d,c.error.length>0){for(let l of c.error)l(u instanceof Error?u:new Error(String(u)));return document.createComment("error")}throw u}return K(f),h=d,c.mount.length>0&&queueMicrotask(()=>{for(let u of c.mount)try{let l=u();typeof l=="function"&&c.unmount.push(l);}catch(l){for(let A of c.error)A(l instanceof Error?l:new Error(String(l)));}}),r};return n._akash=true,n}export{fe as A,pe as B,R as a,T as b,F as c,_ as d,C as e,v as f,O as g,$ as h,U as i,W as j,X as k,G as l,b as m,Y as n,z as o,Q as p,j as q,H as r,Z as s,ee as t,x as u,ne as v,de as w,ae as x,ue as y,le as z};//# sourceMappingURL=chunk-FTTNKDZQ.js.map
|
|
5
|
+
//# sourceMappingURL=chunk-FTTNKDZQ.js.map
|