@akashjs/runtime 0.2.0 → 0.2.2

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.
Files changed (84) hide show
  1. package/dist/animate.d.cts +145 -0
  2. package/dist/animate.d.ts +145 -0
  3. package/dist/{chunk-V7VG23IO.cjs → chunk-3AL2DVPZ.cjs} +3 -3
  4. package/dist/{chunk-V7VG23IO.cjs.map → chunk-3AL2DVPZ.cjs.map} +1 -1
  5. package/dist/{chunk-CHF5LH56.cjs → chunk-6NX6JRSV.cjs} +3 -3
  6. package/dist/{chunk-CHF5LH56.cjs.map → chunk-6NX6JRSV.cjs.map} +1 -1
  7. package/dist/{chunk-DYJUCZXA.js → chunk-BT6HNBE7.js} +4 -4
  8. package/dist/chunk-BT6HNBE7.js.map +1 -0
  9. package/dist/{chunk-CGKMCVEZ.js → chunk-D6QQYZIC.js} +2 -2
  10. package/dist/{chunk-CGKMCVEZ.js.map → chunk-D6QQYZIC.js.map} +1 -1
  11. package/dist/{chunk-R3W5W647.cjs → chunk-H4SAK7A5.cjs} +2 -2
  12. package/dist/{chunk-R3W5W647.cjs.map → chunk-H4SAK7A5.cjs.map} +1 -1
  13. package/dist/chunk-IKZMC3T6.js +2 -0
  14. package/dist/chunk-IKZMC3T6.js.map +1 -0
  15. package/dist/{chunk-VFOAULHK.js → chunk-IM2VW4TK.js} +3 -3
  16. package/dist/{chunk-VFOAULHK.js.map → chunk-IM2VW4TK.js.map} +1 -1
  17. package/dist/chunk-NQVWTQ2I.cjs +5 -0
  18. package/dist/chunk-NQVWTQ2I.cjs.map +1 -0
  19. package/dist/{chunk-5EFX654I.cjs → chunk-NVZLEJXB.cjs} +2 -2
  20. package/dist/{chunk-5EFX654I.cjs.map → chunk-NVZLEJXB.cjs.map} +1 -1
  21. package/dist/{chunk-DPJ6RJ7A.js → chunk-ODDXU5DO.js} +2 -2
  22. package/dist/chunk-ODDXU5DO.js.map +1 -0
  23. package/dist/{chunk-EUKRTV4W.js → chunk-POLTPHUA.js} +3 -3
  24. package/dist/{chunk-EUKRTV4W.js.map → chunk-POLTPHUA.js.map} +1 -1
  25. package/dist/{chunk-4HAE7H7W.cjs → chunk-YIB4EKVI.cjs} +2 -2
  26. package/dist/chunk-YIB4EKVI.cjs.map +1 -0
  27. package/dist/chunk-YJQLXUTN.cjs +2 -0
  28. package/dist/chunk-YJQLXUTN.cjs.map +1 -0
  29. package/dist/{chunk-SRPWGLOQ.js → chunk-Z5LQV5ND.js} +2 -2
  30. package/dist/{chunk-SRPWGLOQ.js.map → chunk-Z5LQV5ND.js.map} +1 -1
  31. package/dist/component-C1WnFcRp.d.cts +59 -0
  32. package/dist/component-C1WnFcRp.d.ts +59 -0
  33. package/dist/context-2uQ6fuxu.d.cts +57 -0
  34. package/dist/context-2uQ6fuxu.d.ts +57 -0
  35. package/dist/core.cjs +1 -1
  36. package/dist/core.d.cts +65 -0
  37. package/dist/core.d.ts +65 -0
  38. package/dist/core.js +1 -1
  39. package/dist/index.cjs +8 -8
  40. package/dist/index.cjs.map +1 -1
  41. package/dist/index.d.cts +3218 -0
  42. package/dist/index.d.ts +3218 -0
  43. package/dist/index.js +8 -8
  44. package/dist/index.js.map +1 -1
  45. package/dist/machine.cjs +1 -1
  46. package/dist/machine.d.cts +87 -0
  47. package/dist/machine.d.ts +87 -0
  48. package/dist/machine.js +1 -1
  49. package/dist/offline.cjs +1 -1
  50. package/dist/offline.d.cts +73 -0
  51. package/dist/offline.d.ts +73 -0
  52. package/dist/offline.js +1 -1
  53. package/dist/pwa.cjs +1 -1
  54. package/dist/pwa.d.cts +80 -0
  55. package/dist/pwa.d.ts +80 -0
  56. package/dist/pwa.js +1 -1
  57. package/dist/signals-C7XfOHHR.d.cts +55 -0
  58. package/dist/signals-C7XfOHHR.d.ts +55 -0
  59. package/dist/ssr.cjs +1 -1
  60. package/dist/ssr.d.cts +78 -0
  61. package/dist/ssr.d.ts +78 -0
  62. package/dist/ssr.js +1 -1
  63. package/dist/store.cjs +1 -1
  64. package/dist/store.d.cts +84 -0
  65. package/dist/store.d.ts +84 -0
  66. package/dist/store.js +1 -1
  67. package/dist/sync.cjs +1 -1
  68. package/dist/sync.d.cts +128 -0
  69. package/dist/sync.d.ts +128 -0
  70. package/dist/sync.js +1 -1
  71. package/dist/test.cjs +2 -2
  72. package/dist/test.d.cts +109 -0
  73. package/dist/test.d.ts +109 -0
  74. package/dist/test.js +1 -1
  75. package/package.json +1 -1
  76. package/dist/chunk-4HAE7H7W.cjs.map +0 -1
  77. package/dist/chunk-DPJ6RJ7A.js.map +0 -1
  78. package/dist/chunk-DYJUCZXA.js.map +0 -1
  79. package/dist/chunk-P5GADKQS.cjs +0 -2
  80. package/dist/chunk-P5GADKQS.cjs.map +0 -1
  81. package/dist/chunk-Q5BER4ZB.js +0 -2
  82. package/dist/chunk-Q5BER4ZB.js.map +0 -1
  83. package/dist/chunk-QDCIW4YE.cjs +0 -5
  84. package/dist/chunk-QDCIW4YE.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/machine.ts"],"names":["createMachine","config","currentState","signal","contextData","stateHistory","done","computed","nextEvents","stateCfg","initialStateCfg","send","event","payload","state","transition","target","guard","action","t","ctx","h","targetCfg","can"],"mappings":"sCAkGO,SAASA,CAAAA,CAIdC,CAAAA,CAAoF,CACpF,IAAMC,EAAeC,CAAAA,CAAeF,CAAAA,CAAO,OAAO,CAAA,CAC5CG,EAAcD,CAAAA,CAAkBF,CAAAA,CAAO,OAAA,EAAW,EAAe,CAAA,CACjEI,CAAAA,CAAeF,CAAAA,CAAiB,CAACF,CAAAA,CAAO,OAAO,CAAC,CAAA,CAEhDK,EAAOC,CAAAA,CAAS,IACHN,CAAAA,CAAO,MAAA,CAAOC,GAAc,CAAA,EAC5B,IAAA,GAAS,OAC3B,EAEKM,CAAAA,CAAaD,CAAAA,CAAS,IAAgB,CAC1C,IAAME,CAAAA,CAAWR,CAAAA,CAAO,MAAA,CAAOC,GAAc,CAAA,CAC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,CACF,CACF","file":"chunk-SRPWGLOQ.js","sourcesContent":["/**\n * State machines for complex UI flows.\n *\n * Finite state machines with typed states, events, guards,\n * actions, and reactive current state signal.\n *\n * ```ts\n * const checkout = createMachine({\n * initial: 'cart',\n * states: {\n * cart: { on: { CHECKOUT: 'shipping' } },\n * shipping: { on: { NEXT: 'payment', BACK: 'cart' } },\n * payment: { on: { PAY: 'processing', BACK: 'shipping' } },\n * processing: { on: { SUCCESS: 'complete', FAIL: 'payment' } },\n * complete: { type: 'final' },\n * },\n * });\n *\n * checkout.state(); // 'cart'\n * checkout.send('CHECKOUT');\n * checkout.state(); // 'shipping'\n * checkout.matches('shipping'); // true\n * ```\n */\n\nimport { signal, computed } from './signals.js';\nimport type { ReadonlySignal } from './signals.js';\n\n// =========================================================================\n// Types\n// =========================================================================\n\nexport interface MachineConfig<TState extends string, TEvent extends string, TContext = unknown> {\n /** Initial state */\n initial: TState;\n /** Initial context data */\n context?: TContext;\n /** State definitions */\n states: Record<TState, StateConfig<TState, TEvent, TContext>>;\n}\n\nexport interface StateConfig<TState extends string, TEvent extends string, TContext = unknown> {\n /** Transitions: event → target state */\n on?: Partial<Record<TEvent, TState | TransitionConfig<TState, TEvent, TContext>>>;\n /** Entry action — runs when entering this state */\n entry?: (ctx: MachineContext<TContext>) => void;\n /** Exit action — runs when leaving this state */\n exit?: (ctx: MachineContext<TContext>) => void;\n /** Final state — machine stops accepting events */\n type?: 'final';\n}\n\nexport interface TransitionConfig<TState extends string, TEvent extends string, TContext = unknown> {\n /** Target state */\n target: TState;\n /** Guard — transition only if this returns true */\n guard?: (ctx: MachineContext<TContext>) => boolean;\n /** Action — runs during the transition */\n action?: (ctx: MachineContext<TContext>) => void;\n}\n\nexport interface MachineContext<TContext> {\n /** The context data (mutable) */\n data: TContext;\n /** The current event that triggered the transition */\n event: string;\n /** Optional payload passed with the event via send(event, payload) */\n payload?: unknown;\n}\n\nexport interface Machine<TState extends string, TEvent extends string, TContext = unknown> {\n /** Current state (reactive signal) */\n state: ReadonlySignal<TState>;\n /** Context data (reactive signal) */\n context: ReadonlySignal<TContext>;\n /** Send an event to the machine */\n send(event: TEvent, payload?: Record<string, unknown>): void;\n /** Check if currently in a specific state */\n matches(state: TState): boolean;\n /** Whether the machine is in a final state */\n done: ReadonlySignal<boolean>;\n /** Reset to initial state */\n reset(): void;\n /** State history */\n history: ReadonlySignal<TState[]>;\n /** Can a specific event be sent in the current state? */\n can(event: TEvent): boolean;\n /** Get all possible events from current state */\n nextEvents: ReadonlySignal<TEvent[]>;\n}\n\n// =========================================================================\n// createMachine\n// =========================================================================\n\n/**\n * Create a finite state machine.\n */\nexport function createMachine<\n TState extends string,\n TEvent extends string,\n TContext = unknown,\n>(config: MachineConfig<TState, TEvent, TContext>): Machine<TState, TEvent, TContext> {\n const currentState = signal<TState>(config.initial);\n const contextData = signal<TContext>((config.context ?? {}) as TContext);\n const stateHistory = signal<TState[]>([config.initial]);\n\n const done = computed(() => {\n const stateCfg = config.states[currentState()];\n return stateCfg?.type === 'final';\n });\n\n const nextEvents = computed((): TEvent[] => {\n const stateCfg = config.states[currentState()];\n if (!stateCfg?.on) return [];\n return Object.keys(stateCfg.on) as TEvent[];\n });\n\n // Run entry action for initial state\n const initialStateCfg = config.states[config.initial];\n if (initialStateCfg?.entry) {\n initialStateCfg.entry({ data: contextData() as TContext, event: '' });\n }\n\n function send(event: TEvent, payload?: unknown): void {\n if (done()) return; // Final state — no more transitions\n\n const state = currentState();\n const stateCfg = config.states[state];\n if (!stateCfg?.on) return;\n\n const transition = stateCfg.on[event];\n if (!transition) return;\n\n let target: TState;\n let guard: ((ctx: MachineContext<TContext>) => boolean) | undefined;\n let action: ((ctx: MachineContext<TContext>) => void) | undefined;\n\n if (typeof transition === 'string') {\n target = transition;\n } else {\n const t = transition as TransitionConfig<TState, TEvent, TContext>;\n target = t.target;\n guard = t.guard;\n action = t.action;\n }\n\n const ctx: MachineContext<TContext> = {\n data: contextData() as TContext,\n event,\n payload,\n };\n\n // Check guard\n if (guard && !guard(ctx)) return;\n\n // Exit action\n if (stateCfg.exit) {\n stateCfg.exit(ctx);\n }\n\n // Transition action — pass payload as second argument for convenience\n if (action) {\n (action as Function)(ctx, payload);\n }\n\n // Update context if modified\n contextData.set(ctx.data);\n\n // Enter new state\n currentState.set(target);\n stateHistory.update((h) => [...h, target]);\n\n // Entry action for new state\n const targetCfg = config.states[target];\n if (targetCfg?.entry) {\n targetCfg.entry({ data: contextData() as TContext, event });\n }\n }\n\n function can(event: TEvent): boolean {\n const stateCfg = config.states[currentState()];\n if (!stateCfg?.on) return false;\n const transition = stateCfg.on[event];\n if (!transition) return false;\n\n if (typeof transition !== 'string') {\n const t = transition as TransitionConfig<TState, TEvent, TContext>;\n if (t.guard) {\n return t.guard({ data: contextData() as TContext, event });\n }\n }\n return true;\n }\n\n return {\n state: () => currentState(),\n context: () => contextData(),\n send,\n matches: (state: TState) => currentState() === state,\n done,\n reset() {\n currentState.set(config.initial);\n contextData.set((config.context ?? {}) as TContext);\n stateHistory.set([config.initial]);\n },\n history: () => stateHistory(),\n can,\n nextEvents,\n };\n}\n"]}
1
+ {"version":3,"sources":["../src/machine.ts"],"names":["createMachine","config","currentState","signal","contextData","stateHistory","done","computed","nextEvents","stateCfg","initialStateCfg","send","event","payload","state","transition","target","guard","action","t","ctx","h","targetCfg","can"],"mappings":"sCAkGO,SAASA,CAAAA,CAIdC,CAAAA,CAAoF,CACpF,IAAMC,EAAeC,CAAAA,CAAeF,CAAAA,CAAO,OAAO,CAAA,CAC5CG,EAAcD,CAAAA,CAAkBF,CAAAA,CAAO,OAAA,EAAW,EAAe,CAAA,CACjEI,CAAAA,CAAeF,CAAAA,CAAiB,CAACF,CAAAA,CAAO,OAAO,CAAC,CAAA,CAEhDK,EAAOC,CAAAA,CAAS,IACHN,CAAAA,CAAO,MAAA,CAAOC,GAAc,CAAA,EAC5B,IAAA,GAAS,OAC3B,EAEKM,CAAAA,CAAaD,CAAAA,CAAS,IAAgB,CAC1C,IA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,IAAMI,GAAa,CAC5B,GAAA,CAAAkB,CAAAA,CACA,UAAA,CAAAf,CACF,CACF","file":"chunk-Z5LQV5ND.js","sourcesContent":["/**\n * State machines for complex UI flows.\n *\n * Finite state machines with typed states, events, guards,\n * actions, and reactive current state signal.\n *\n * ```ts\n * const checkout = createMachine({\n * initial: 'cart',\n * states: {\n * cart: { on: { CHECKOUT: 'shipping' } },\n * shipping: { on: { NEXT: 'payment', BACK: 'cart' } },\n * payment: { on: { PAY: 'processing', BACK: 'shipping' } },\n * processing: { on: { SUCCESS: 'complete', FAIL: 'payment' } },\n * complete: { type: 'final' },\n * },\n * });\n *\n * checkout.state(); // 'cart'\n * checkout.send('CHECKOUT');\n * checkout.state(); // 'shipping'\n * checkout.matches('shipping'); // true\n * ```\n */\n\nimport { signal, computed } from './signals.js';\nimport type { ReadonlySignal } from './signals.js';\n\n// =========================================================================\n// Types\n// =========================================================================\n\nexport interface MachineConfig<TState extends string, TEvent extends string, TContext = unknown> {\n /** Initial state */\n initial: TState;\n /** Initial context data */\n context?: TContext;\n /** State definitions */\n states: Record<TState, StateConfig<TState, TEvent, TContext>>;\n}\n\nexport interface StateConfig<TState extends string, TEvent extends string, TContext = unknown> {\n /** Transitions: event → target state */\n on?: Partial<Record<TEvent, TState | TransitionConfig<TState, TEvent, TContext>>>;\n /** Entry action — runs when entering this state */\n entry?: (ctx: MachineContext<TContext>) => void;\n /** Exit action — runs when leaving this state */\n exit?: (ctx: MachineContext<TContext>) => void;\n /** Final state — machine stops accepting events */\n type?: 'final';\n}\n\nexport interface TransitionConfig<TState extends string, TEvent extends string, TContext = unknown> {\n /** Target state */\n target: TState;\n /** Guard — transition only if this returns true */\n guard?: (ctx: MachineContext<TContext>) => boolean;\n /** Action — runs during the transition */\n action?: (ctx: MachineContext<TContext>) => void;\n}\n\nexport interface MachineContext<TContext> {\n /** The context data (mutable) */\n data: TContext;\n /** The current event that triggered the transition */\n event: string;\n /** Optional payload passed with the event via send(event, payload) */\n payload?: unknown;\n}\n\nexport interface Machine<TState extends string, TEvent extends string, TContext = unknown> {\n /** Current state (reactive signal) */\n state: ReadonlySignal<TState>;\n /** Context data (reactive signal) */\n context: ReadonlySignal<TContext>;\n /** Send an event to the machine */\n send(event: TEvent, payload?: Record<string, unknown>): void;\n /** Check if currently in a specific state */\n matches(state: TState): boolean;\n /** Whether the machine is in a final state */\n done: ReadonlySignal<boolean>;\n /** Reset to initial state */\n reset(): void;\n /** State history */\n history: ReadonlySignal<TState[]>;\n /** Can a specific event be sent in the current state? */\n can(event: TEvent): boolean;\n /** Get all possible events from current state */\n nextEvents: ReadonlySignal<TEvent[]>;\n}\n\n// =========================================================================\n// createMachine\n// =========================================================================\n\n/**\n * Create a finite state machine.\n */\nexport function createMachine<\n TState extends string,\n TEvent extends string,\n TContext = unknown,\n>(config: MachineConfig<TState, TEvent, TContext>): Machine<TState, TEvent, TContext> {\n const currentState = signal<TState>(config.initial);\n const contextData = signal<TContext>((config.context ?? {}) as TContext);\n const stateHistory = signal<TState[]>([config.initial]);\n\n const done = computed(() => {\n const stateCfg = config.states[currentState()];\n return stateCfg?.type === 'final';\n });\n\n const nextEvents = computed((): TEvent[] => {\n const stateCfg = config.states[currentState()];\n if (!stateCfg?.on) return [];\n return Object.keys(stateCfg.on) as TEvent[];\n });\n\n // Run entry action for initial state\n const initialStateCfg = config.states[config.initial];\n if (initialStateCfg?.entry) {\n initialStateCfg.entry({ data: contextData() as TContext, event: '' });\n }\n\n function send(event: TEvent, payload?: unknown): void {\n if (done()) return; // Final state — no more transitions\n\n const state = currentState();\n const stateCfg = config.states[state];\n if (!stateCfg?.on) return;\n\n const transition = stateCfg.on[event];\n if (!transition) return;\n\n let target: TState;\n let guard: ((ctx: MachineContext<TContext>) => boolean) | undefined;\n let action: ((ctx: MachineContext<TContext>) => void) | undefined;\n\n if (typeof transition === 'string') {\n target = transition as TState;\n } else {\n const t = transition as TransitionConfig<TState, TEvent, TContext>;\n target = t.target;\n guard = t.guard;\n action = t.action;\n }\n\n const ctx: MachineContext<TContext> = {\n data: contextData() as TContext,\n event,\n payload,\n };\n\n // Check guard\n if (guard && !guard(ctx)) return;\n\n // Exit action\n if (stateCfg.exit) {\n stateCfg.exit(ctx);\n }\n\n // Transition action — pass payload as second argument for convenience\n if (action) {\n (action as Function)(ctx, payload);\n }\n\n // Update context if modified\n contextData.set(ctx.data);\n\n // Enter new state\n currentState.set(target);\n stateHistory.update((h) => [...h, target]);\n\n // Entry action for new state\n const targetCfg = config.states[target];\n if (targetCfg?.entry) {\n targetCfg.entry({ data: contextData() as TContext, event });\n }\n }\n\n function can(event: TEvent): boolean {\n const stateCfg = config.states[currentState()];\n if (!stateCfg?.on) return false;\n const transition = stateCfg.on[event];\n if (!transition) return false;\n\n if (typeof transition !== 'string') {\n const t = transition as TransitionConfig<TState, TEvent, TContext>;\n if (t.guard) {\n return t.guard({ data: contextData() as TContext, event });\n }\n }\n return true;\n }\n\n return {\n state: () => currentState(),\n context: () => contextData(),\n send,\n matches: (state: TState) => currentState() === state,\n done,\n reset() {\n currentState.set(config.initial);\n contextData.set((config.context ?? {}) as TContext);\n stateHistory.set([config.initial]);\n },\n history: () => stateHistory(),\n can,\n nextEvents,\n };\n}\n"]}
@@ -0,0 +1,59 @@
1
+ /** Represents any renderable node in AkashJS */
2
+ type AkashNode = Node | string | number | boolean | null | undefined | AkashNode[];
3
+
4
+ /**
5
+ * Component system.
6
+ *
7
+ * Components are functions. defineComponent() wraps a setup function
8
+ * that runs once, establishes signals and effects, and returns a
9
+ * render function that produces DOM nodes.
10
+ */
11
+
12
+ /** Mark a function as a compiler-generated reactive getter */
13
+ declare function __getter<T>(fn: () => T): (() => T) & {
14
+ __reactive: true;
15
+ };
16
+ interface Ref<T = HTMLElement> {
17
+ current: T | undefined;
18
+ }
19
+ interface ComponentContext<P extends Record<string, unknown> = Record<string, unknown>> {
20
+ props: Readonly<P>;
21
+ children: () => AkashNode;
22
+ }
23
+ type Component<P extends Record<string, unknown> = Record<string, unknown>> = {
24
+ (props: P & {
25
+ children?: AkashNode | (() => AkashNode);
26
+ }): Node;
27
+ _akash: true;
28
+ };
29
+ /**
30
+ * Register a callback to run after the component is mounted to the DOM.
31
+ * If the callback returns a function, it will be called on unmount (cleanup).
32
+ */
33
+ declare function onMount(fn: () => void | (() => void)): void;
34
+ /**
35
+ * Register a callback to run before the component is unmounted.
36
+ */
37
+ declare function onUnmount(fn: () => void): void;
38
+ /**
39
+ * Register an error handler for this component and its descendants.
40
+ */
41
+ declare function onError(fn: (error: Error) => void): void;
42
+ /**
43
+ * Create a ref for accessing a DOM element or storing a mutable value.
44
+ */
45
+ declare function ref<T = HTMLElement>(initialValue?: T): Ref<T>;
46
+ /**
47
+ * Define a component. The setup function runs once per instance.
48
+ * It receives a context with typed props and must return a render function.
49
+ *
50
+ * ```ts
51
+ * const Counter = defineComponent<{ initial: number }>((ctx) => {
52
+ * const count = signal(ctx.props.initial);
53
+ * return () => <div>{count()}</div>;
54
+ * });
55
+ * ```
56
+ */
57
+ declare function defineComponent<P extends Record<string, any> = Record<string, any>>(setup: (ctx: ComponentContext<P>) => () => AkashNode): Component<P>;
58
+
59
+ export { type AkashNode as A, type Component as C, type Ref as R, __getter as _, type ComponentContext as a, onMount as b, onUnmount as c, defineComponent as d, onError as o, ref as r };
@@ -0,0 +1,59 @@
1
+ /** Represents any renderable node in AkashJS */
2
+ type AkashNode = Node | string | number | boolean | null | undefined | AkashNode[];
3
+
4
+ /**
5
+ * Component system.
6
+ *
7
+ * Components are functions. defineComponent() wraps a setup function
8
+ * that runs once, establishes signals and effects, and returns a
9
+ * render function that produces DOM nodes.
10
+ */
11
+
12
+ /** Mark a function as a compiler-generated reactive getter */
13
+ declare function __getter<T>(fn: () => T): (() => T) & {
14
+ __reactive: true;
15
+ };
16
+ interface Ref<T = HTMLElement> {
17
+ current: T | undefined;
18
+ }
19
+ interface ComponentContext<P extends Record<string, unknown> = Record<string, unknown>> {
20
+ props: Readonly<P>;
21
+ children: () => AkashNode;
22
+ }
23
+ type Component<P extends Record<string, unknown> = Record<string, unknown>> = {
24
+ (props: P & {
25
+ children?: AkashNode | (() => AkashNode);
26
+ }): Node;
27
+ _akash: true;
28
+ };
29
+ /**
30
+ * Register a callback to run after the component is mounted to the DOM.
31
+ * If the callback returns a function, it will be called on unmount (cleanup).
32
+ */
33
+ declare function onMount(fn: () => void | (() => void)): void;
34
+ /**
35
+ * Register a callback to run before the component is unmounted.
36
+ */
37
+ declare function onUnmount(fn: () => void): void;
38
+ /**
39
+ * Register an error handler for this component and its descendants.
40
+ */
41
+ declare function onError(fn: (error: Error) => void): void;
42
+ /**
43
+ * Create a ref for accessing a DOM element or storing a mutable value.
44
+ */
45
+ declare function ref<T = HTMLElement>(initialValue?: T): Ref<T>;
46
+ /**
47
+ * Define a component. The setup function runs once per instance.
48
+ * It receives a context with typed props and must return a render function.
49
+ *
50
+ * ```ts
51
+ * const Counter = defineComponent<{ initial: number }>((ctx) => {
52
+ * const count = signal(ctx.props.initial);
53
+ * return () => <div>{count()}</div>;
54
+ * });
55
+ * ```
56
+ */
57
+ declare function defineComponent<P extends Record<string, any> = Record<string, any>>(setup: (ctx: ComponentContext<P>) => () => AkashNode): Component<P>;
58
+
59
+ export { type AkashNode as A, type Component as C, type Ref as R, __getter as _, type ComponentContext as a, onMount as b, onUnmount as c, defineComponent as d, onError as o, ref as r };
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Batch multiple signal writes — subscribers are notified only once
3
+ * at the end of the batch.
4
+ */
5
+ declare function batch(fn: () => void): void;
6
+ /** Synchronously flush all pending effects. Useful for testing. */
7
+ declare function flushSync(): void;
8
+
9
+ /**
10
+ * Lightweight dependency injection via provide/inject.
11
+ *
12
+ * Context is scoped to the component tree — no injector hierarchy,
13
+ * no decorators, no classes. Just createContext(), provide(), inject().
14
+ */
15
+ declare const CONTEXT_BRAND: unique symbol;
16
+ interface InjectionKey<T> {
17
+ readonly [CONTEXT_BRAND]: true;
18
+ readonly _type: T;
19
+ readonly defaultValue: T | undefined;
20
+ readonly id: symbol;
21
+ }
22
+ interface ContextScope {
23
+ values: Map<symbol, unknown>;
24
+ parent: ContextScope | null;
25
+ }
26
+ /** @internal */
27
+ declare function getCurrentScope(): ContextScope | null;
28
+ /**
29
+ * Run a function within a given scope so that provide/inject
30
+ * work correctly for components created asynchronously
31
+ * (e.g., lazy-loaded route components).
32
+ */
33
+ declare function runInScope<T>(scope: ContextScope, fn: () => T): T;
34
+ /**
35
+ * Create a typed context key with an optional default value.
36
+ *
37
+ * ```ts
38
+ * const ThemeContext = createContext<'light' | 'dark'>('light');
39
+ * ```
40
+ */
41
+ declare function createContext<T>(defaultValue?: T): InjectionKey<T>;
42
+ /**
43
+ * Provide a value for a context key in the current component scope.
44
+ * All descendant components can inject() this value.
45
+ *
46
+ * Must be called inside defineComponent() setup.
47
+ */
48
+ declare function provide<T>(key: InjectionKey<T>, value: T): void;
49
+ /**
50
+ * Inject a value from the nearest ancestor that provided it.
51
+ *
52
+ * Must be called inside defineComponent() setup.
53
+ */
54
+ declare function inject<T>(key: InjectionKey<T>): T;
55
+ declare function inject<T>(key: InjectionKey<T>, fallback: T): T;
56
+
57
+ export { type InjectionKey as I, batch as b, createContext as c, flushSync as f, getCurrentScope as g, inject as i, provide as p, runInScope as r };
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Batch multiple signal writes — subscribers are notified only once
3
+ * at the end of the batch.
4
+ */
5
+ declare function batch(fn: () => void): void;
6
+ /** Synchronously flush all pending effects. Useful for testing. */
7
+ declare function flushSync(): void;
8
+
9
+ /**
10
+ * Lightweight dependency injection via provide/inject.
11
+ *
12
+ * Context is scoped to the component tree — no injector hierarchy,
13
+ * no decorators, no classes. Just createContext(), provide(), inject().
14
+ */
15
+ declare const CONTEXT_BRAND: unique symbol;
16
+ interface InjectionKey<T> {
17
+ readonly [CONTEXT_BRAND]: true;
18
+ readonly _type: T;
19
+ readonly defaultValue: T | undefined;
20
+ readonly id: symbol;
21
+ }
22
+ interface ContextScope {
23
+ values: Map<symbol, unknown>;
24
+ parent: ContextScope | null;
25
+ }
26
+ /** @internal */
27
+ declare function getCurrentScope(): ContextScope | null;
28
+ /**
29
+ * Run a function within a given scope so that provide/inject
30
+ * work correctly for components created asynchronously
31
+ * (e.g., lazy-loaded route components).
32
+ */
33
+ declare function runInScope<T>(scope: ContextScope, fn: () => T): T;
34
+ /**
35
+ * Create a typed context key with an optional default value.
36
+ *
37
+ * ```ts
38
+ * const ThemeContext = createContext<'light' | 'dark'>('light');
39
+ * ```
40
+ */
41
+ declare function createContext<T>(defaultValue?: T): InjectionKey<T>;
42
+ /**
43
+ * Provide a value for a context key in the current component scope.
44
+ * All descendant components can inject() this value.
45
+ *
46
+ * Must be called inside defineComponent() setup.
47
+ */
48
+ declare function provide<T>(key: InjectionKey<T>, value: T): void;
49
+ /**
50
+ * Inject a value from the nearest ancestor that provided it.
51
+ *
52
+ * Must be called inside defineComponent() setup.
53
+ */
54
+ declare function inject<T>(key: InjectionKey<T>): T;
55
+ declare function inject<T>(key: InjectionKey<T>, fallback: T): T;
56
+
57
+ export { type InjectionKey as I, batch as b, createContext as c, flushSync as f, getCurrentScope as g, inject as i, provide as p, runInScope as r };
package/dist/core.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkQDCIW4YE_cjs=require('./chunk-QDCIW4YE.cjs'),chunkV7VG23IO_cjs=require('./chunk-V7VG23IO.cjs');Object.defineProperty(exports,"For",{enumerable:true,get:function(){return chunkQDCIW4YE_cjs.t}});Object.defineProperty(exports,"Show",{enumerable:true,get:function(){return chunkQDCIW4YE_cjs.s}});Object.defineProperty(exports,"bindProperty",{enumerable:true,get:function(){return chunkQDCIW4YE_cjs.o}});Object.defineProperty(exports,"bindText",{enumerable:true,get:function(){return chunkQDCIW4YE_cjs.n}});Object.defineProperty(exports,"bindVisible",{enumerable:true,get:function(){return chunkQDCIW4YE_cjs.p}});Object.defineProperty(exports,"cloneTemplate",{enumerable:true,get:function(){return chunkQDCIW4YE_cjs.l}});Object.defineProperty(exports,"createContext",{enumerable:true,get:function(){return chunkQDCIW4YE_cjs.g}});Object.defineProperty(exports,"createElement",{enumerable:true,get:function(){return chunkQDCIW4YE_cjs.j}});Object.defineProperty(exports,"createText",{enumerable:true,get:function(){return chunkQDCIW4YE_cjs.k}});Object.defineProperty(exports,"defineComponent",{enumerable:true,get:function(){return chunkQDCIW4YE_cjs.B}});Object.defineProperty(exports,"inject",{enumerable:true,get:function(){return chunkQDCIW4YE_cjs.i}});Object.defineProperty(exports,"insert",{enumerable:true,get:function(){return chunkQDCIW4YE_cjs.v}});Object.defineProperty(exports,"nodeToDOM",{enumerable:true,get:function(){return chunkQDCIW4YE_cjs.u}});Object.defineProperty(exports,"onError",{enumerable:true,get:function(){return chunkQDCIW4YE_cjs.z}});Object.defineProperty(exports,"onMount",{enumerable:true,get:function(){return chunkQDCIW4YE_cjs.x}});Object.defineProperty(exports,"onUnmount",{enumerable:true,get:function(){return chunkQDCIW4YE_cjs.y}});Object.defineProperty(exports,"provide",{enumerable:true,get:function(){return chunkQDCIW4YE_cjs.h}});Object.defineProperty(exports,"ref",{enumerable:true,get:function(){return chunkQDCIW4YE_cjs.A}});Object.defineProperty(exports,"renderConditional",{enumerable:true,get:function(){return chunkQDCIW4YE_cjs.q}});Object.defineProperty(exports,"renderList",{enumerable:true,get:function(){return chunkQDCIW4YE_cjs.r}});Object.defineProperty(exports,"setProperty",{enumerable:true,get:function(){return chunkQDCIW4YE_cjs.m}});Object.defineProperty(exports,"batch",{enumerable:true,get:function(){return chunkV7VG23IO_cjs.a}});Object.defineProperty(exports,"computed",{enumerable:true,get:function(){return chunkV7VG23IO_cjs.m}});Object.defineProperty(exports,"effect",{enumerable:true,get:function(){return chunkV7VG23IO_cjs.n}});Object.defineProperty(exports,"flushSync",{enumerable:true,get:function(){return chunkV7VG23IO_cjs.b}});Object.defineProperty(exports,"signal",{enumerable:true,get:function(){return chunkV7VG23IO_cjs.l}});Object.defineProperty(exports,"untrack",{enumerable:true,get:function(){return chunkV7VG23IO_cjs.o}});//# sourceMappingURL=core.cjs.map
1
+ 'use strict';var chunkNQVWTQ2I_cjs=require('./chunk-NQVWTQ2I.cjs'),chunk3AL2DVPZ_cjs=require('./chunk-3AL2DVPZ.cjs');Object.defineProperty(exports,"For",{enumerable:true,get:function(){return chunkNQVWTQ2I_cjs.t}});Object.defineProperty(exports,"Show",{enumerable:true,get:function(){return chunkNQVWTQ2I_cjs.s}});Object.defineProperty(exports,"bindProperty",{enumerable:true,get:function(){return chunkNQVWTQ2I_cjs.o}});Object.defineProperty(exports,"bindText",{enumerable:true,get:function(){return chunkNQVWTQ2I_cjs.n}});Object.defineProperty(exports,"bindVisible",{enumerable:true,get:function(){return chunkNQVWTQ2I_cjs.p}});Object.defineProperty(exports,"cloneTemplate",{enumerable:true,get:function(){return chunkNQVWTQ2I_cjs.l}});Object.defineProperty(exports,"createContext",{enumerable:true,get:function(){return chunkNQVWTQ2I_cjs.g}});Object.defineProperty(exports,"createElement",{enumerable:true,get:function(){return chunkNQVWTQ2I_cjs.j}});Object.defineProperty(exports,"createText",{enumerable:true,get:function(){return chunkNQVWTQ2I_cjs.k}});Object.defineProperty(exports,"defineComponent",{enumerable:true,get:function(){return chunkNQVWTQ2I_cjs.B}});Object.defineProperty(exports,"inject",{enumerable:true,get:function(){return chunkNQVWTQ2I_cjs.i}});Object.defineProperty(exports,"insert",{enumerable:true,get:function(){return chunkNQVWTQ2I_cjs.v}});Object.defineProperty(exports,"nodeToDOM",{enumerable:true,get:function(){return chunkNQVWTQ2I_cjs.u}});Object.defineProperty(exports,"onError",{enumerable:true,get:function(){return chunkNQVWTQ2I_cjs.z}});Object.defineProperty(exports,"onMount",{enumerable:true,get:function(){return chunkNQVWTQ2I_cjs.x}});Object.defineProperty(exports,"onUnmount",{enumerable:true,get:function(){return chunkNQVWTQ2I_cjs.y}});Object.defineProperty(exports,"provide",{enumerable:true,get:function(){return chunkNQVWTQ2I_cjs.h}});Object.defineProperty(exports,"ref",{enumerable:true,get:function(){return chunkNQVWTQ2I_cjs.A}});Object.defineProperty(exports,"renderConditional",{enumerable:true,get:function(){return chunkNQVWTQ2I_cjs.q}});Object.defineProperty(exports,"renderList",{enumerable:true,get:function(){return chunkNQVWTQ2I_cjs.r}});Object.defineProperty(exports,"setProperty",{enumerable:true,get:function(){return chunkNQVWTQ2I_cjs.m}});Object.defineProperty(exports,"batch",{enumerable:true,get:function(){return chunk3AL2DVPZ_cjs.a}});Object.defineProperty(exports,"computed",{enumerable:true,get:function(){return chunk3AL2DVPZ_cjs.m}});Object.defineProperty(exports,"effect",{enumerable:true,get:function(){return chunk3AL2DVPZ_cjs.n}});Object.defineProperty(exports,"flushSync",{enumerable:true,get:function(){return chunk3AL2DVPZ_cjs.b}});Object.defineProperty(exports,"signal",{enumerable:true,get:function(){return chunk3AL2DVPZ_cjs.l}});Object.defineProperty(exports,"untrack",{enumerable:true,get:function(){return chunk3AL2DVPZ_cjs.o}});//# sourceMappingURL=core.cjs.map
2
2
  //# sourceMappingURL=core.cjs.map
@@ -0,0 +1,65 @@
1
+ export { R as ReadonlySignal, S as Signal, c as computed, e as effect, s as signal, u as untrack } from './signals-C7XfOHHR.cjs';
2
+ export { I as InjectionKey, b as batch, c as createContext, f as flushSync, i as inject, p as provide } from './context-2uQ6fuxu.cjs';
3
+ import { A as AkashNode } from './component-C1WnFcRp.cjs';
4
+ export { C as Component, a as ComponentContext, R as Ref, d as defineComponent, o as onError, b as onMount, c as onUnmount, r as ref } from './component-C1WnFcRp.cjs';
5
+
6
+ /**
7
+ * Direct DOM rendering runtime.
8
+ *
9
+ * No virtual DOM. The compiler generates calls to these helpers.
10
+ * Signal reads inside templates become fine-grained effects that
11
+ * update only the specific DOM node that changed.
12
+ */
13
+
14
+ /** Create an element and optionally set static attributes */
15
+ declare function createElement(tag: string, attrs?: Record<string, unknown>): HTMLElement;
16
+ /** Create a text node */
17
+ declare function createText(value: string): Text;
18
+ /** Clone a template element for static structure */
19
+ declare function cloneTemplate(html: string): DocumentFragment;
20
+ declare function setProperty(el: HTMLElement, key: string, value: unknown): void;
21
+ /** Bind a reactive expression to a text node's content */
22
+ declare function bindText(node: Text, fn: () => unknown): () => void;
23
+ /** Bind a reactive expression to an element's attribute/property */
24
+ declare function bindProperty(el: HTMLElement, key: string, fn: () => unknown): () => void;
25
+ /** Bind a reactive expression to an element's visibility (display) */
26
+ declare function bindVisible(el: HTMLElement, fn: () => boolean): () => void;
27
+ /**
28
+ * Render a conditional block. Swaps DOM fragments based on a reactive
29
+ * condition. Used by the compiler for :if directives and <Show>.
30
+ */
31
+ declare function renderConditional(parent: Node, anchor: Node, condition: () => boolean, trueBranch: () => Node, falseBranch?: () => Node): () => void;
32
+ /**
33
+ * Render a reactive list with keyed reconciliation.
34
+ * Used by the compiler for :for directives and <For>.
35
+ */
36
+ declare function renderList<T>(parent: Node, anchor: Node, items: () => T[], keyFn: (item: T, index: number) => unknown, renderItem: (item: T, index: number) => Node): () => void;
37
+ /** Props for the <Show> component */
38
+ interface ShowProps<T> {
39
+ when: (() => T | null | undefined | false) | T | null | undefined | false;
40
+ fallback?: () => AkashNode;
41
+ children: (value: T) => AkashNode;
42
+ }
43
+ /**
44
+ * <Show> component — conditionally renders children with type narrowing.
45
+ * The children callback receives the non-null/undefined value.
46
+ * `when` can be a reactive getter or a static value.
47
+ */
48
+ declare function Show<T>(props: ShowProps<T>): Node;
49
+ /** Props for the <For> component */
50
+ interface ForProps<T> {
51
+ each: (() => T[]) | T[];
52
+ key: (item: T) => unknown;
53
+ children: (item: T, index: number) => AkashNode;
54
+ }
55
+ /**
56
+ * <For> component — renders a list with keyed reconciliation.
57
+ * `each` can be a reactive getter or a static array.
58
+ */
59
+ declare function For<T>(props: ForProps<T>): Node;
60
+ /** Convert an AkashNode to a DOM Node */
61
+ declare function nodeToDOM(node: AkashNode): Node;
62
+ /** Insert a node into a parent before an anchor */
63
+ declare function insert(parent: Node, node: AkashNode, anchor?: Node): void;
64
+
65
+ export { AkashNode, For, Show, bindProperty, bindText, bindVisible, cloneTemplate, createElement, createText, insert, nodeToDOM, renderConditional, renderList, setProperty };
package/dist/core.d.ts ADDED
@@ -0,0 +1,65 @@
1
+ export { R as ReadonlySignal, S as Signal, c as computed, e as effect, s as signal, u as untrack } from './signals-C7XfOHHR.js';
2
+ export { I as InjectionKey, b as batch, c as createContext, f as flushSync, i as inject, p as provide } from './context-2uQ6fuxu.js';
3
+ import { A as AkashNode } from './component-C1WnFcRp.js';
4
+ export { C as Component, a as ComponentContext, R as Ref, d as defineComponent, o as onError, b as onMount, c as onUnmount, r as ref } from './component-C1WnFcRp.js';
5
+
6
+ /**
7
+ * Direct DOM rendering runtime.
8
+ *
9
+ * No virtual DOM. The compiler generates calls to these helpers.
10
+ * Signal reads inside templates become fine-grained effects that
11
+ * update only the specific DOM node that changed.
12
+ */
13
+
14
+ /** Create an element and optionally set static attributes */
15
+ declare function createElement(tag: string, attrs?: Record<string, unknown>): HTMLElement;
16
+ /** Create a text node */
17
+ declare function createText(value: string): Text;
18
+ /** Clone a template element for static structure */
19
+ declare function cloneTemplate(html: string): DocumentFragment;
20
+ declare function setProperty(el: HTMLElement, key: string, value: unknown): void;
21
+ /** Bind a reactive expression to a text node's content */
22
+ declare function bindText(node: Text, fn: () => unknown): () => void;
23
+ /** Bind a reactive expression to an element's attribute/property */
24
+ declare function bindProperty(el: HTMLElement, key: string, fn: () => unknown): () => void;
25
+ /** Bind a reactive expression to an element's visibility (display) */
26
+ declare function bindVisible(el: HTMLElement, fn: () => boolean): () => void;
27
+ /**
28
+ * Render a conditional block. Swaps DOM fragments based on a reactive
29
+ * condition. Used by the compiler for :if directives and <Show>.
30
+ */
31
+ declare function renderConditional(parent: Node, anchor: Node, condition: () => boolean, trueBranch: () => Node, falseBranch?: () => Node): () => void;
32
+ /**
33
+ * Render a reactive list with keyed reconciliation.
34
+ * Used by the compiler for :for directives and <For>.
35
+ */
36
+ declare function renderList<T>(parent: Node, anchor: Node, items: () => T[], keyFn: (item: T, index: number) => unknown, renderItem: (item: T, index: number) => Node): () => void;
37
+ /** Props for the <Show> component */
38
+ interface ShowProps<T> {
39
+ when: (() => T | null | undefined | false) | T | null | undefined | false;
40
+ fallback?: () => AkashNode;
41
+ children: (value: T) => AkashNode;
42
+ }
43
+ /**
44
+ * <Show> component — conditionally renders children with type narrowing.
45
+ * The children callback receives the non-null/undefined value.
46
+ * `when` can be a reactive getter or a static value.
47
+ */
48
+ declare function Show<T>(props: ShowProps<T>): Node;
49
+ /** Props for the <For> component */
50
+ interface ForProps<T> {
51
+ each: (() => T[]) | T[];
52
+ key: (item: T) => unknown;
53
+ children: (item: T, index: number) => AkashNode;
54
+ }
55
+ /**
56
+ * <For> component — renders a list with keyed reconciliation.
57
+ * `each` can be a reactive getter or a static array.
58
+ */
59
+ declare function For<T>(props: ForProps<T>): Node;
60
+ /** Convert an AkashNode to a DOM Node */
61
+ declare function nodeToDOM(node: AkashNode): Node;
62
+ /** Insert a node into a parent before an anchor */
63
+ declare function insert(parent: Node, node: AkashNode, anchor?: Node): void;
64
+
65
+ export { AkashNode, For, Show, bindProperty, bindText, bindVisible, cloneTemplate, createElement, createText, insert, nodeToDOM, renderConditional, renderList, setProperty };
package/dist/core.js CHANGED
@@ -1,2 +1,2 @@
1
- export{t as For,s as Show,o as bindProperty,n as bindText,p as bindVisible,l as cloneTemplate,g as createContext,j as createElement,k as createText,B as defineComponent,i as inject,v as insert,u as nodeToDOM,z as onError,x as onMount,y as onUnmount,h as provide,A as ref,q as renderConditional,r as renderList,m as setProperty}from'./chunk-DYJUCZXA.js';export{a as batch,m as computed,n as effect,b as flushSync,l as signal,o as untrack}from'./chunk-EUKRTV4W.js';//# sourceMappingURL=core.js.map
1
+ export{t as For,s as Show,o as bindProperty,n as bindText,p as bindVisible,l as cloneTemplate,g as createContext,j as createElement,k as createText,B as defineComponent,i as inject,v as insert,u as nodeToDOM,z as onError,x as onMount,y as onUnmount,h as provide,A as ref,q as renderConditional,r as renderList,m as setProperty}from'./chunk-BT6HNBE7.js';export{a as batch,m as computed,n as effect,b as flushSync,l as signal,o as untrack}from'./chunk-POLTPHUA.js';//# sourceMappingURL=core.js.map
2
2
  //# sourceMappingURL=core.js.map