@akashjs/runtime 0.1.8 → 0.1.9

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/test.cjs CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';var chunkNFMF4N7P_cjs=require('./chunk-NFMF4N7P.cjs');require('./chunk-3Q7GK4DL.cjs');function M(e,n){let t=document.createElement("div");t.setAttribute("data-akash-test-root","");let l=n?.props??{},o=n?.provide,a;return o&&o.size>0?a=chunkNFMF4N7P_cjs.A(()=>{for(let[i,d]of o)chunkNFMF4N7P_cjs.h(i,d);return ()=>e(l)})({}):a=e(l),t.appendChild(a),document.body.appendChild(t),{container:t,unmount(){t.remove();},getByText(r){let i=m(t,r);if(!i)throw new Error(`[AkashJS Test] Could not find element with text: "${r}"
1
+ 'use strict';var chunkRVHMMGJG_cjs=require('./chunk-RVHMMGJG.cjs');require('./chunk-3Q7GK4DL.cjs');function M(e,n){let t=document.createElement("div");t.setAttribute("data-akash-test-root","");let l=n?.props??{},o=n?.provide,a;return o&&o.size>0?a=chunkRVHMMGJG_cjs.B(()=>{for(let[i,d]of o)chunkRVHMMGJG_cjs.h(i,d);return ()=>e(l)})({}):a=e(l),t.appendChild(a),document.body.appendChild(t),{container:t,unmount(){t.remove();},getByText(r){let i=m(t,r);if(!i)throw new Error(`[AkashJS Test] Could not find element with text: "${r}"
2
2
  Container HTML: ${t.innerHTML.slice(0,200)}`);return i},getByRole(r){let i=t.querySelector(`[role="${r}"]`)??p(t,r);if(!i)throw new Error(`[AkashJS Test] Could not find element with role: "${r}"
3
3
  Container HTML: ${t.innerHTML.slice(0,200)}`);return i},getByTestId(r){let i=t.querySelector(`[data-testid="${r}"]`);if(!i)throw new Error(`[AkashJS Test] Could not find element with data-testid: "${r}"
4
4
  Container HTML: ${t.innerHTML.slice(0,200)}`);return i},queryAll(r){return Array.from(t.querySelectorAll(r))},query(r){return t.querySelector(r)}}}var y={async click(e){e.dispatchEvent(new MouseEvent("click",{bubbles:true,cancelable:true})),await s();},async input(e,n){let t=Object.getOwnPropertyDescriptor(e instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,"value")?.set;t?t.call(e,n):e.value=n,e.dispatchEvent(new Event("input",{bubbles:true})),e.dispatchEvent(new Event("change",{bubbles:true})),await s();},async submit(e){e.dispatchEvent(new Event("submit",{bubbles:true,cancelable:true})),await s();},async focus(e){e.focus(),e.dispatchEvent(new FocusEvent("focus",{bubbles:true})),await s();},async blur(e){e.blur(),e.dispatchEvent(new FocusEvent("blur",{bubbles:true})),await s();},async keyDown(e,n,t){e.dispatchEvent(new KeyboardEvent("keydown",{key:n,bubbles:true,...t})),await s();},async keyUp(e,n,t){e.dispatchEvent(new KeyboardEvent("keyup",{key:n,bubbles:true,...t})),await s();}};function s(){return new Promise(e=>queueMicrotask(e))}function m(e,n){let t=null,l=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT),o=l.nextNode();for(;o;)o instanceof HTMLElement&&o.textContent?.includes(n)&&(t=o),o=l.nextNode();return !t&&e.textContent?.includes(n)&&(t=e),t}var E={button:["button"],a:["link"],input:["textbox","checkbox","radio","spinbutton","slider"],select:["combobox","listbox"],textarea:["textbox"],img:["img"],form:["form"],nav:["navigation"],main:["main"],header:["banner"],footer:["contentinfo"],aside:["complementary"],section:["region"],article:["article"],ul:["list"],ol:["list"],li:["listitem"],table:["table"],th:["columnheader"],td:["cell"],h1:["heading"],h2:["heading"],h3:["heading"],h4:["heading"],h5:["heading"],h6:["heading"]};function p(e,n){let t=[];for(let[o,a]of Object.entries(E))a.includes(n)&&t.push(o);if(t.length===0)return null;let l=t.join(", ");return e.querySelector(l)}exports.fireEvent=y;exports.mount=M;//# sourceMappingURL=test.cjs.map
package/dist/test.js CHANGED
@@ -1,4 +1,4 @@
1
- import {A,h}from'./chunk-TMEW6WRJ.js';import'./chunk-FX7RHVM5.js';function M(e,n){let t=document.createElement("div");t.setAttribute("data-akash-test-root","");let l=n?.props??{},o=n?.provide,a;return o&&o.size>0?a=A(()=>{for(let[i,d]of o)h(i,d);return ()=>e(l)})({}):a=e(l),t.appendChild(a),document.body.appendChild(t),{container:t,unmount(){t.remove();},getByText(r){let i=m(t,r);if(!i)throw new Error(`[AkashJS Test] Could not find element with text: "${r}"
1
+ import {B,h}from'./chunk-SLMGQKLH.js';import'./chunk-FX7RHVM5.js';function M(e,n){let t=document.createElement("div");t.setAttribute("data-akash-test-root","");let l=n?.props??{},o=n?.provide,a;return o&&o.size>0?a=B(()=>{for(let[i,d]of o)h(i,d);return ()=>e(l)})({}):a=e(l),t.appendChild(a),document.body.appendChild(t),{container:t,unmount(){t.remove();},getByText(r){let i=m(t,r);if(!i)throw new Error(`[AkashJS Test] Could not find element with text: "${r}"
2
2
  Container HTML: ${t.innerHTML.slice(0,200)}`);return i},getByRole(r){let i=t.querySelector(`[role="${r}"]`)??p(t,r);if(!i)throw new Error(`[AkashJS Test] Could not find element with role: "${r}"
3
3
  Container HTML: ${t.innerHTML.slice(0,200)}`);return i},getByTestId(r){let i=t.querySelector(`[data-testid="${r}"]`);if(!i)throw new Error(`[AkashJS Test] Could not find element with data-testid: "${r}"
4
4
  Container HTML: ${t.innerHTML.slice(0,200)}`);return i},queryAll(r){return Array.from(t.querySelectorAll(r))},query(r){return t.querySelector(r)}}}var y={async click(e){e.dispatchEvent(new MouseEvent("click",{bubbles:true,cancelable:true})),await s();},async input(e,n){let t=Object.getOwnPropertyDescriptor(e instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,"value")?.set;t?t.call(e,n):e.value=n,e.dispatchEvent(new Event("input",{bubbles:true})),e.dispatchEvent(new Event("change",{bubbles:true})),await s();},async submit(e){e.dispatchEvent(new Event("submit",{bubbles:true,cancelable:true})),await s();},async focus(e){e.focus(),e.dispatchEvent(new FocusEvent("focus",{bubbles:true})),await s();},async blur(e){e.blur(),e.dispatchEvent(new FocusEvent("blur",{bubbles:true})),await s();},async keyDown(e,n,t){e.dispatchEvent(new KeyboardEvent("keydown",{key:n,bubbles:true,...t})),await s();},async keyUp(e,n,t){e.dispatchEvent(new KeyboardEvent("keyup",{key:n,bubbles:true,...t})),await s();}};function s(){return new Promise(e=>queueMicrotask(e))}function m(e,n){let t=null,l=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT),o=l.nextNode();for(;o;)o instanceof HTMLElement&&o.textContent?.includes(n)&&(t=o),o=l.nextNode();return !t&&e.textContent?.includes(n)&&(t=e),t}var E={button:["button"],a:["link"],input:["textbox","checkbox","radio","spinbutton","slider"],select:["combobox","listbox"],textarea:["textbox"],img:["img"],form:["form"],nav:["navigation"],main:["main"],header:["banner"],footer:["contentinfo"],aside:["complementary"],section:["region"],article:["article"],ul:["list"],ol:["list"],li:["listitem"],table:["table"],th:["columnheader"],td:["cell"],h1:["heading"],h2:["heading"],h3:["heading"],h4:["heading"],h5:["heading"],h6:["heading"]};function p(e,n){let t=[];for(let[o,a]of Object.entries(E))a.includes(n)&&t.push(o);if(t.length===0)return null;let l=t.join(", ");return e.querySelector(l)}export{y as fireEvent,M as mount};//# sourceMappingURL=test.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akashjs/runtime",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "AkashJS core runtime — signals, components, DOM rendering",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -1,5 +0,0 @@
1
- 'use strict';var chunk3Q7GK4DL_cjs=require('./chunk-3Q7GK4DL.cjs');var C={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 L(e,n){let o=C[e];if(!o)return `[AkashJS ${e}] Unknown error code.`;let t=`[AkashJS ${e}] ${o.message}`;return n&&(t+=`
2
- ${n}`),t+=`
3
- ${o.hint}`,t+=`
4
- See: ${P}/${e}`,t}function g(e,n){return new Error(L(e,n))}function D(e){return C[e]}function F(){return Object.keys(C)}var M=Symbol("akash.context"),l=null;function K(e=l){let n={values:new Map,parent:e};return l=n,n}function v(e){l=e.parent;}function N(){return l}function w(e,n){let o=l;l=e;try{return n()}finally{l=o;}}function B(e){return {[M]:true,_type:void 0,defaultValue:e,id:Symbol("context")}}function O(e,n){if(!l)throw g("AK0010");l.values.set(e.id,n);}function _(e,n){if(!l)throw g("AK0012");let o=l;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 g("AK0013")}function V(e,n){let o=document.createElement(e);if(n)for(let[t,p]of Object.entries(n))S(o,t,p);return o}function J(e){return document.createTextNode(e)}function W(e){let n=document.createElement("template");return n.innerHTML=e,n.content.cloneNode(true)}function S(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 t=n.slice(2).toLowerCase();e.addEventListener(t,o);}else n in e?e[n]=o:o===false||o==null?e.removeAttribute(n):e.setAttribute(n,o===true?"":String(o));}function X(e,n){return chunk3Q7GK4DL_cjs.e(()=>{e.textContent=String(n());},{render:true})}function z(e,n,o){return chunk3Q7GK4DL_cjs.e(()=>{S(e,n,o());},{render:true})}function G(e,n){return chunk3Q7GK4DL_cjs.e(()=>{e.style.display=n()?"":"none";},{render:true})}function E(e=""){return document.createComment(e)}function R(e,n,o,t,p){let i=null,A=N(),k=chunk3Q7GK4DL_cjs.e(()=>{let s=o();if(i){for(let a of i.nodes)try{a.parentNode?.removeChild(a);}catch{}i.dispose?.(),i=null;}let d=s?t:p,h=n.parentNode;if(d&&h){let a=A?w(A,d):d(),r=a instanceof DocumentFragment?Array.from(a.childNodes):[a];for(let c of r)h.insertBefore(c,n);i={nodes:r,dispose:null};}},{render:true});return ()=>{if(k(),i){for(let s of i.nodes)try{s.parentNode?.removeChild(s);}catch{}i.dispose?.();}}}function j(e,n,o,t,p){let i=[],A=N(),k=chunk3Q7GK4DL_cjs.e(()=>{let s=o(),d=[],h=new Map;for(let r of i)h.set(r.key,r);for(let r=0;r<s.length;r++){let c=s[r],u=t(c,r),f=h.get(u);if(f)h.delete(u),f.value=c,d.push(f);else {let y=A?w(A,()=>p(c,r)):p(c,r),b=y instanceof DocumentFragment?Array.from(y.childNodes):[y];d.push({key:u,value:c,nodes:b,dispose:null});}}for(let r of h.values()){for(let c of r.nodes)c.parentNode&&c.parentNode.removeChild(c);r.dispose?.();}let a=n.parentNode;if(a)for(let r of d)for(let c of r.nodes)a.insertBefore(c,n);i=d;},{render:true});return ()=>{k();for(let s of i){for(let d of s.nodes)d.parentNode&&d.parentNode.removeChild(d);s.dispose?.();}i=[];}}function Q(e){let n=E("show"),o=document.createDocumentFragment();o.appendChild(n);let t=typeof e.when=="function"?e.when:()=>e.when;return R(o,n,()=>!!t(),()=>T(e.children(t())),e.fallback?()=>T(e.fallback()):void 0),o}function Y(e){let n=E("for"),o=document.createDocumentFragment();o.appendChild(n);let t=typeof e.each=="function"?e.each:()=>e.each;return j(o,n,t,e.key,(p,i)=>T(e.children(p,i))),o}function T(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(T(o));return n}return document.createTextNode(String(e))}function Z(e,n,o){let t=T(n);o?e.insertBefore(t,o):e.appendChild(t);}var m=null;function re(e){if(!m)throw g("AK0020");m.mount.push(e);}function se(e){if(!m)throw g("AK0021");m.unmount.push(e);}function ie(e){if(!m)throw g("AK0022");m.error.push(e);}function ce(){return {current:void 0}}function de(e){let n=o=>{let{children:t,...p}=o??{},k={props:p,children:typeof t=="function"?t:()=>t??null},s={mount:[],unmount:[],error:[]},d=m;m=s;let h=N(),a=K(h),r,c;try{if(r=e(k),typeof r!="function")throw g("AK0040");let u=r();c=T(u);}catch(u){if(v(a),m=d,s.error.length>0){for(let f of s.error)f(u instanceof Error?u:new Error(String(u)));return document.createComment("error")}throw u}return v(a),m=d,s.mount.length>0&&queueMicrotask(()=>{for(let u of s.mount)try{let f=u();typeof f=="function"&&s.unmount.push(f);}catch(f){for(let y of s.error)y(f instanceof Error?f:new Error(String(f)));}}),c};return n._akash=true,n}exports.A=de;exports.a=L;exports.b=g;exports.c=D;exports.d=F;exports.e=N;exports.f=w;exports.g=B;exports.h=O;exports.i=_;exports.j=V;exports.k=J;exports.l=W;exports.m=S;exports.n=X;exports.o=z;exports.p=G;exports.q=R;exports.r=j;exports.s=Q;exports.t=Y;exports.u=T;exports.v=Z;exports.w=re;exports.x=se;exports.y=ie;exports.z=ce;//# sourceMappingURL=chunk-NFMF4N7P.cjs.map
5
- //# sourceMappingURL=chunk-NFMF4N7P.cjs.map
@@ -1 +0,0 @@
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","Show","props","container","getWhen","nodeToDOM","For","getEach","index","child","insert","domNode","currentHooks","onMount","onUnmount","onError","ref","defineComponent","setup","component","rawProps","childrenProp","restProps","ctx","hooks","prevHooks","parentScope","renderFn","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,CA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D,CAAK,CAAA,CACdgE,CAAAA,CAAea,CAAAA,CACXD,CAAAA,CAAM,KAAA,CAAM,MAAA,CAAS,EAAG,CAC1B,IAAA,IAAWM,CAAAA,IAAWN,CAAAA,CAAM,MAC1BM,CAAAA,CAAQD,CAAAA,YAAe,KAAA,CAAQA,CAAAA,CAAM,IAAI,KAAA,CAAM,MAAA,CAAOA,CAAG,CAAC,CAAC,CAAA,CAE7D,OAAO,QAAA,CAAS,cAAc,OAAO,CACvC,CACA,MAAMA,CACR,CAGA,OAAAhF,CAAAA,CAASD,CAAK,CAAA,CACdgE,CAAAA,CAAea,CAAAA,CAGXD,CAAAA,CAAM,KAAA,CAAM,MAAA,CAAS,CAAA,EACvB,cAAA,CAAe,IAAM,CACnB,IAAA,IAAWO,CAAAA,IAAWP,CAAAA,CAAM,KAAA,CAC1B,GAAI,CACF,IAAMQ,EAAUD,CAAAA,EAAQ,CACpB,OAAOC,CAAAA,EAAY,UAAA,EACrBR,CAAAA,CAAM,OAAA,CAAQ,IAAA,CAAKQ,CAAO,EAE9B,CAAA,MAASH,CAAAA,CAAK,CACZ,IAAA,IAAWC,CAAAA,IAAWN,CAAAA,CAAM,KAAA,CAC1BM,EAAQD,CAAAA,YAAe,KAAA,CAAQA,CAAAA,CAAM,IAAI,KAAA,CAAM,MAAA,CAAOA,CAAG,CAAC,CAAC,EAE/D,CAEJ,CAAC,CAAA,CAGIlB,CACT,CAAA,CAEA,OAAAQ,CAAAA,CAAU,MAAA,CAAS,KACZA,CACT","file":"chunk-NFMF4N7P.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 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 type for marking insertion points */\ntype Anchor = Comment;\n\nfunction createAnchor(label = ''): Anchor {\n return document.createComment(label);\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 const branch = value ? trueBranch : falseBranch;\n const liveParent = anchor.parentNode;\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 existing.value = data;\n newItems.push(existing);\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 — use anchor.parentNode since anchor may have\n // moved from the initial DocumentFragment into the real DOM\n const liveParent = anchor.parentNode;\n if (liveParent) {\n for (const item of newItems) {\n for (const node of item.nodes) {\n liveParent.insertBefore(node, anchor);\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 — may be a getter (from compiler) or a static value\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 renderConditional(\n container,\n anchor,\n () => !!getWhen(),\n () => nodeToDOM(props.children(getWhen() 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 — may be a getter (from compiler) or a static array\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 } 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// --- 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.\n */\nexport function ref<T = HTMLElement>(): Ref<T> {\n return { current: 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, unknown> = Record<string, unknown>>(\n setup: (ctx: ComponentContext<P>) => () => AkashNode,\n): Component<P> {\n const component = (rawProps: P & { children?: AkashNode | (() => AkashNode) }): Node => {\n // Separate children from props\n const { children: childrenProp, ...restProps } = rawProps ?? {};\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 renderFn = setup(ctx);\n if (typeof renderFn !== 'function') { throw akashError('AK0040'); }\n const rendered = renderFn();\n domNode = nodeToDOM(rendered);\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,5 +0,0 @@
1
- import {e}from'./chunk-FX7RHVM5.js';var C={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 L(e,n){let o=C[e];if(!o)return `[AkashJS ${e}] Unknown error code.`;let t=`[AkashJS ${e}] ${o.message}`;return n&&(t+=`
2
- ${n}`),t+=`
3
- ${o.hint}`,t+=`
4
- See: ${P}/${e}`,t}function g(e,n){return new Error(L(e,n))}function D(e){return C[e]}function F(){return Object.keys(C)}var M=Symbol("akash.context"),l=null;function K(e=l){let n={values:new Map,parent:e};return l=n,n}function v(e){l=e.parent;}function N(){return l}function w(e,n){let o=l;l=e;try{return n()}finally{l=o;}}function B(e){return {[M]:true,_type:void 0,defaultValue:e,id:Symbol("context")}}function O(e,n){if(!l)throw g("AK0010");l.values.set(e.id,n);}function _(e,n){if(!l)throw g("AK0012");let o=l;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 g("AK0013")}function V(e,n){let o=document.createElement(e);if(n)for(let[t,p]of Object.entries(n))S(o,t,p);return o}function J(e){return document.createTextNode(e)}function W(e){let n=document.createElement("template");return n.innerHTML=e,n.content.cloneNode(true)}function S(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 t=n.slice(2).toLowerCase();e.addEventListener(t,o);}else n in e?e[n]=o:o===false||o==null?e.removeAttribute(n):e.setAttribute(n,o===true?"":String(o));}function X(e$1,n){return e(()=>{e$1.textContent=String(n());},{render:true})}function z(e$1,n,o){return e(()=>{S(e$1,n,o());},{render:true})}function G(e$1,n){return e(()=>{e$1.style.display=n()?"":"none";},{render:true})}function E(e=""){return document.createComment(e)}function R(e$1,n,o,t,p){let i=null,A=N(),k=e(()=>{let s=o();if(i){for(let a of i.nodes)try{a.parentNode?.removeChild(a);}catch{}i.dispose?.(),i=null;}let d=s?t:p,h=n.parentNode;if(d&&h){let a=A?w(A,d):d(),r=a instanceof DocumentFragment?Array.from(a.childNodes):[a];for(let c of r)h.insertBefore(c,n);i={nodes:r,dispose:null};}},{render:true});return ()=>{if(k(),i){for(let s of i.nodes)try{s.parentNode?.removeChild(s);}catch{}i.dispose?.();}}}function j(e$1,n,o,t,p){let i=[],A=N(),k=e(()=>{let s=o(),d=[],h=new Map;for(let r of i)h.set(r.key,r);for(let r=0;r<s.length;r++){let c=s[r],u=t(c,r),f=h.get(u);if(f)h.delete(u),f.value=c,d.push(f);else {let y=A?w(A,()=>p(c,r)):p(c,r),b=y instanceof DocumentFragment?Array.from(y.childNodes):[y];d.push({key:u,value:c,nodes:b,dispose:null});}}for(let r of h.values()){for(let c of r.nodes)c.parentNode&&c.parentNode.removeChild(c);r.dispose?.();}let a=n.parentNode;if(a)for(let r of d)for(let c of r.nodes)a.insertBefore(c,n);i=d;},{render:true});return ()=>{k();for(let s of i){for(let d of s.nodes)d.parentNode&&d.parentNode.removeChild(d);s.dispose?.();}i=[];}}function Q(e){let n=E("show"),o=document.createDocumentFragment();o.appendChild(n);let t=typeof e.when=="function"?e.when:()=>e.when;return R(o,n,()=>!!t(),()=>T(e.children(t())),e.fallback?()=>T(e.fallback()):void 0),o}function Y(e){let n=E("for"),o=document.createDocumentFragment();o.appendChild(n);let t=typeof e.each=="function"?e.each:()=>e.each;return j(o,n,t,e.key,(p,i)=>T(e.children(p,i))),o}function T(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(T(o));return n}return document.createTextNode(String(e))}function Z(e,n,o){let t=T(n);o?e.insertBefore(t,o):e.appendChild(t);}var m=null;function re(e){if(!m)throw g("AK0020");m.mount.push(e);}function se(e){if(!m)throw g("AK0021");m.unmount.push(e);}function ie(e){if(!m)throw g("AK0022");m.error.push(e);}function ce(){return {current:void 0}}function de(e){let n=o=>{let{children:t,...p}=o??{},k={props:p,children:typeof t=="function"?t:()=>t??null},s={mount:[],unmount:[],error:[]},d=m;m=s;let h=N(),a=K(h),r,c;try{if(r=e(k),typeof r!="function")throw g("AK0040");let u=r();c=T(u);}catch(u){if(v(a),m=d,s.error.length>0){for(let f of s.error)f(u instanceof Error?u:new Error(String(u)));return document.createComment("error")}throw u}return v(a),m=d,s.mount.length>0&&queueMicrotask(()=>{for(let u of s.mount)try{let f=u();typeof f=="function"&&s.unmount.push(f);}catch(f){for(let y of s.error)y(f instanceof Error?f:new Error(String(f)));}}),c};return n._akash=true,n}export{de as A,L as a,g as b,D as c,F as d,N as e,w as f,B as g,O as h,_ as i,V as j,J as k,W as l,S as m,X as n,z as o,G as p,R as q,j as r,Q as s,Y as t,T as u,Z as v,re as w,se as x,ie as y,ce as z};//# sourceMappingURL=chunk-TMEW6WRJ.js.map
5
- //# sourceMappingURL=chunk-TMEW6WRJ.js.map
@@ -1 +0,0 @@
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","Show","props","container","getWhen","nodeToDOM","For","getEach","index","child","insert","domNode","currentHooks","onMount","onUnmount","onError","ref","defineComponent","setup","component","rawProps","childrenProp","restProps","ctx","hooks","prevHooks","parentScope","renderFn","rendered","err","handler","mountFn","cleanup"],"mappings":"oCAqBA,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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ACR,CAGA,OAAAhF,CAAAA,CAASD,CAAK,CAAA,CACdgE,CAAAA,CAAea,CAAAA,CAGXD,CAAAA,CAAM,KAAA,CAAM,MAAA,CAAS,CAAA,EACvB,cAAA,CAAe,IAAM,CACnB,IAAA,IAAWO,CAAAA,IAAWP,CAAAA,CAAM,KAAA,CAC1B,GAAI,CACF,IAAMQ,EAAUD,CAAAA,EAAQ,CACpB,OAAOC,CAAAA,EAAY,UAAA,EACrBR,CAAAA,CAAM,OAAA,CAAQ,IAAA,CAAKQ,CAAO,EAE9B,CAAA,MAASH,CAAAA,CAAK,CACZ,IAAA,IAAWC,CAAAA,IAAWN,CAAAA,CAAM,KAAA,CAC1BM,EAAQD,CAAAA,YAAe,KAAA,CAAQA,CAAAA,CAAM,IAAI,KAAA,CAAM,MAAA,CAAOA,CAAG,CAAC,CAAC,EAE/D,CAEJ,CAAC,CAAA,CAGIlB,CACT,CAAA,CAEA,OAAAQ,CAAAA,CAAU,MAAA,CAAS,KACZA,CACT","file":"chunk-TMEW6WRJ.js","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 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 type for marking insertion points */\ntype Anchor = Comment;\n\nfunction createAnchor(label = ''): Anchor {\n return document.createComment(label);\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 const branch = value ? trueBranch : falseBranch;\n const liveParent = anchor.parentNode;\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 existing.value = data;\n newItems.push(existing);\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 — use anchor.parentNode since anchor may have\n // moved from the initial DocumentFragment into the real DOM\n const liveParent = anchor.parentNode;\n if (liveParent) {\n for (const item of newItems) {\n for (const node of item.nodes) {\n liveParent.insertBefore(node, anchor);\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 — may be a getter (from compiler) or a static value\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 renderConditional(\n container,\n anchor,\n () => !!getWhen(),\n () => nodeToDOM(props.children(getWhen() 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 — may be a getter (from compiler) or a static array\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 } 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// --- 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.\n */\nexport function ref<T = HTMLElement>(): Ref<T> {\n return { current: 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, unknown> = Record<string, unknown>>(\n setup: (ctx: ComponentContext<P>) => () => AkashNode,\n): Component<P> {\n const component = (rawProps: P & { children?: AkashNode | (() => AkashNode) }): Node => {\n // Separate children from props\n const { children: childrenProp, ...restProps } = rawProps ?? {};\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 renderFn = setup(ctx);\n if (typeof renderFn !== 'function') { throw akashError('AK0040'); }\n const rendered = renderFn();\n domNode = nodeToDOM(rendered);\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"]}