@zenithbuild/compiler 1.0.16 → 1.3.1

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 (144) hide show
  1. package/native/compiler-native/compiler-native.node +0 -0
  2. package/native/compiler-native/index.d.ts +46 -7
  3. package/native/compiler-native/index.js +332 -17
  4. package/package.json +2 -2
  5. package/dist/build-analyzer.d.ts +0 -44
  6. package/dist/build-analyzer.js +0 -87
  7. package/dist/bundler.d.ts +0 -31
  8. package/dist/bundler.js +0 -86
  9. package/dist/compiler-native-ep39xj7a.node +0 -0
  10. package/dist/compiler-native-ftk9z446.node +0 -0
  11. package/dist/core/components/index.d.ts +0 -9
  12. package/dist/core/components/index.js +0 -13
  13. package/dist/core/config/index.d.ts +0 -11
  14. package/dist/core/config/index.js +0 -10
  15. package/dist/core/config/loader.d.ts +0 -17
  16. package/dist/core/config/loader.js +0 -60
  17. package/dist/core/config/types.d.ts +0 -98
  18. package/dist/core/config/types.js +0 -32
  19. package/dist/core/index.d.ts +0 -7
  20. package/dist/core/index.js +0 -6
  21. package/dist/core/lifecycle/index.d.ts +0 -16
  22. package/dist/core/lifecycle/index.js +0 -19
  23. package/dist/core/lifecycle/zen-mount.d.ts +0 -66
  24. package/dist/core/lifecycle/zen-mount.js +0 -151
  25. package/dist/core/lifecycle/zen-unmount.d.ts +0 -54
  26. package/dist/core/lifecycle/zen-unmount.js +0 -76
  27. package/dist/core/plugins/bridge.d.ts +0 -116
  28. package/dist/core/plugins/bridge.js +0 -121
  29. package/dist/core/plugins/index.d.ts +0 -6
  30. package/dist/core/plugins/index.js +0 -6
  31. package/dist/core/plugins/registry.d.ts +0 -67
  32. package/dist/core/plugins/registry.js +0 -112
  33. package/dist/core/reactivity/index.d.ts +0 -30
  34. package/dist/core/reactivity/index.js +0 -33
  35. package/dist/core/reactivity/tracking.d.ts +0 -74
  36. package/dist/core/reactivity/tracking.js +0 -136
  37. package/dist/core/reactivity/zen-batch.d.ts +0 -45
  38. package/dist/core/reactivity/zen-batch.js +0 -54
  39. package/dist/core/reactivity/zen-effect.d.ts +0 -48
  40. package/dist/core/reactivity/zen-effect.js +0 -98
  41. package/dist/core/reactivity/zen-memo.d.ts +0 -43
  42. package/dist/core/reactivity/zen-memo.js +0 -100
  43. package/dist/core/reactivity/zen-ref.d.ts +0 -44
  44. package/dist/core/reactivity/zen-ref.js +0 -34
  45. package/dist/core/reactivity/zen-signal.d.ts +0 -48
  46. package/dist/core/reactivity/zen-signal.js +0 -84
  47. package/dist/core/reactivity/zen-state.d.ts +0 -35
  48. package/dist/core/reactivity/zen-state.js +0 -147
  49. package/dist/core/reactivity/zen-untrack.d.ts +0 -38
  50. package/dist/core/reactivity/zen-untrack.js +0 -41
  51. package/dist/css/index.d.ts +0 -73
  52. package/dist/css/index.js +0 -246
  53. package/dist/discovery/componentDiscovery.d.ts +0 -42
  54. package/dist/discovery/componentDiscovery.js +0 -56
  55. package/dist/discovery/layouts.d.ts +0 -13
  56. package/dist/discovery/layouts.js +0 -41
  57. package/dist/errors/compilerError.d.ts +0 -31
  58. package/dist/errors/compilerError.js +0 -51
  59. package/dist/finalize/finalizeOutput.d.ts +0 -32
  60. package/dist/finalize/finalizeOutput.js +0 -62
  61. package/dist/finalize/generateFinalBundle.d.ts +0 -24
  62. package/dist/finalize/generateFinalBundle.js +0 -68
  63. package/dist/index.d.ts +0 -38
  64. package/dist/index.js +0 -57
  65. package/dist/ir/types.d.ts +0 -181
  66. package/dist/ir/types.js +0 -8
  67. package/dist/output/types.d.ts +0 -30
  68. package/dist/output/types.js +0 -6
  69. package/dist/parse/detectMapExpressions.d.ts +0 -45
  70. package/dist/parse/detectMapExpressions.js +0 -77
  71. package/dist/parse/parseScript.d.ts +0 -8
  72. package/dist/parse/parseScript.js +0 -36
  73. package/dist/parse/parseTemplate.d.ts +0 -11
  74. package/dist/parse/parseTemplate.js +0 -487
  75. package/dist/parse/parseZenFile.d.ts +0 -11
  76. package/dist/parse/parseZenFile.js +0 -50
  77. package/dist/parse/scriptAnalysis.d.ts +0 -25
  78. package/dist/parse/scriptAnalysis.js +0 -60
  79. package/dist/parse/trackLoopContext.d.ts +0 -20
  80. package/dist/parse/trackLoopContext.js +0 -62
  81. package/dist/parseZenFile.d.ts +0 -10
  82. package/dist/parseZenFile.js +0 -55
  83. package/dist/runtime/analyzeAndEmit.d.ts +0 -20
  84. package/dist/runtime/analyzeAndEmit.js +0 -70
  85. package/dist/runtime/build.d.ts +0 -6
  86. package/dist/runtime/build.js +0 -13
  87. package/dist/runtime/bundle-generator.d.ts +0 -27
  88. package/dist/runtime/bundle-generator.js +0 -1438
  89. package/dist/runtime/client-runtime.d.ts +0 -41
  90. package/dist/runtime/client-runtime.js +0 -397
  91. package/dist/runtime/dataExposure.d.ts +0 -52
  92. package/dist/runtime/dataExposure.js +0 -227
  93. package/dist/runtime/generateDOM.d.ts +0 -21
  94. package/dist/runtime/generateDOM.js +0 -194
  95. package/dist/runtime/generateHydrationBundle.d.ts +0 -15
  96. package/dist/runtime/generateHydrationBundle.js +0 -399
  97. package/dist/runtime/hydration.d.ts +0 -53
  98. package/dist/runtime/hydration.js +0 -271
  99. package/dist/runtime/navigation.d.ts +0 -58
  100. package/dist/runtime/navigation.js +0 -372
  101. package/dist/runtime/serve.d.ts +0 -13
  102. package/dist/runtime/serve.js +0 -76
  103. package/dist/runtime/thinRuntime.d.ts +0 -23
  104. package/dist/runtime/thinRuntime.js +0 -158
  105. package/dist/runtime/transformIR.d.ts +0 -19
  106. package/dist/runtime/transformIR.js +0 -285
  107. package/dist/runtime/wrapExpression.d.ts +0 -24
  108. package/dist/runtime/wrapExpression.js +0 -76
  109. package/dist/runtime/wrapExpressionWithLoop.d.ts +0 -17
  110. package/dist/runtime/wrapExpressionWithLoop.js +0 -75
  111. package/dist/spa-build.d.ts +0 -26
  112. package/dist/spa-build.js +0 -857
  113. package/dist/ssg-build.d.ts +0 -32
  114. package/dist/ssg-build.js +0 -408
  115. package/dist/test/analyze-emit.test.d.ts +0 -1
  116. package/dist/test/analyze-emit.test.js +0 -88
  117. package/dist/test/bundler-contract.test.d.ts +0 -1
  118. package/dist/test/bundler-contract.test.js +0 -137
  119. package/dist/test/compiler-authority.test.d.ts +0 -1
  120. package/dist/test/compiler-authority.test.js +0 -90
  121. package/dist/test/component-instance-test.d.ts +0 -1
  122. package/dist/test/component-instance-test.js +0 -115
  123. package/dist/test/error-native-bridge.test.d.ts +0 -1
  124. package/dist/test/error-native-bridge.test.js +0 -51
  125. package/dist/test/error-serialization.test.d.ts +0 -1
  126. package/dist/test/error-serialization.test.js +0 -38
  127. package/dist/test/macro-inlining.test.d.ts +0 -1
  128. package/dist/test/macro-inlining.test.js +0 -178
  129. package/dist/test/validate-test.d.ts +0 -6
  130. package/dist/test/validate-test.js +0 -95
  131. package/dist/transform/classifyExpression.d.ts +0 -46
  132. package/dist/transform/classifyExpression.js +0 -359
  133. package/dist/transform/componentResolver.d.ts +0 -15
  134. package/dist/transform/componentResolver.js +0 -24
  135. package/dist/transform/expressionTransformer.d.ts +0 -19
  136. package/dist/transform/expressionTransformer.js +0 -333
  137. package/dist/transform/fragmentLowering.d.ts +0 -25
  138. package/dist/transform/fragmentLowering.js +0 -468
  139. package/dist/transform/layoutProcessor.d.ts +0 -5
  140. package/dist/transform/layoutProcessor.js +0 -34
  141. package/dist/transform/transformTemplate.d.ts +0 -11
  142. package/dist/transform/transformTemplate.js +0 -33
  143. package/dist/validate/invariants.d.ts +0 -23
  144. package/dist/validate/invariants.js +0 -55
@@ -1,136 +0,0 @@
1
- /**
2
- * Zenith Reactivity Tracking System
3
- *
4
- * This module provides the core dependency tracking mechanism used by
5
- * signals, effects, and memos. It uses a stack-based approach to track
6
- * which reactive values are accessed during effect/memo execution.
7
- *
8
- * Key concepts:
9
- * - Subscriber: A function that should be called when a dependency changes
10
- * - Tracking context: The currently executing effect/memo that should collect dependencies
11
- * - Dependency: A reactive value that an effect/memo depends on
12
- */
13
- /**
14
- * Stack of currently executing tracking contexts
15
- * When an effect runs, it pushes itself onto this stack.
16
- * When a signal is read, it registers the top of the stack as a subscriber.
17
- */
18
- const trackingStack = [];
19
- /**
20
- * Flag to disable tracking (used by zenUntrack)
21
- */
22
- let trackingDisabled = false;
23
- /**
24
- * Batch depth counter - when > 0, effect execution is deferred
25
- */
26
- let batchDepth = 0;
27
- /**
28
- * Queue of effects to run after batch completes
29
- */
30
- const pendingEffects = new Set();
31
- /**
32
- * Get the current tracking context (if any)
33
- */
34
- export function getCurrentContext() {
35
- if (trackingDisabled)
36
- return undefined;
37
- return trackingStack[trackingStack.length - 1];
38
- }
39
- /**
40
- * Push a new tracking context onto the stack
41
- */
42
- export function pushContext(context) {
43
- trackingStack.push(context);
44
- }
45
- /**
46
- * Pop the current tracking context from the stack
47
- */
48
- export function popContext() {
49
- return trackingStack.pop();
50
- }
51
- /**
52
- * Track a dependency - called when a reactive value is read
53
- *
54
- * @param subscribers - The subscriber set of the reactive value being read
55
- */
56
- export function trackDependency(subscribers) {
57
- const context = getCurrentContext();
58
- if (context) {
59
- // Register this effect as a subscriber to the signal
60
- subscribers.add(context.execute);
61
- // Track that this effect depends on this signal
62
- context.dependencies.add(subscribers);
63
- }
64
- }
65
- /**
66
- * Notify subscribers that a reactive value has changed
67
- *
68
- * @param subscribers - The subscriber set to notify
69
- */
70
- export function notifySubscribers(subscribers) {
71
- // Copy subscribers to avoid issues if the set is modified during iteration
72
- const toNotify = [...subscribers];
73
- for (const subscriber of toNotify) {
74
- if (batchDepth > 0) {
75
- // Batching - defer effect execution
76
- pendingEffects.add(subscriber);
77
- }
78
- else {
79
- // Execute immediately
80
- subscriber();
81
- }
82
- }
83
- }
84
- /**
85
- * Clean up a tracking context - remove it from all dependency sets
86
- *
87
- * @param context - The context to clean up
88
- */
89
- export function cleanupContext(context) {
90
- for (const deps of context.dependencies) {
91
- deps.delete(context.execute);
92
- }
93
- context.dependencies.clear();
94
- }
95
- /**
96
- * Run a function without tracking dependencies
97
- *
98
- * @param fn - The function to run
99
- * @returns The return value of the function
100
- */
101
- export function runUntracked(fn) {
102
- const wasDisabled = trackingDisabled;
103
- trackingDisabled = true;
104
- try {
105
- return fn();
106
- }
107
- finally {
108
- trackingDisabled = wasDisabled;
109
- }
110
- }
111
- /**
112
- * Start a batch - defer effect execution until batch ends
113
- */
114
- export function startBatch() {
115
- batchDepth++;
116
- }
117
- /**
118
- * End a batch - run all pending effects
119
- */
120
- export function endBatch() {
121
- batchDepth--;
122
- if (batchDepth === 0 && pendingEffects.size > 0) {
123
- // Run all pending effects
124
- const effects = [...pendingEffects];
125
- pendingEffects.clear();
126
- for (const effect of effects) {
127
- effect();
128
- }
129
- }
130
- }
131
- /**
132
- * Check if currently inside a batch
133
- */
134
- export function isBatching() {
135
- return batchDepth > 0;
136
- }
@@ -1,45 +0,0 @@
1
- /**
2
- * Zenith Batch - Deferred Effect Execution
3
- *
4
- * Batching allows you to make multiple reactive updates without
5
- * triggering effects until all updates are complete. This improves
6
- * performance by preventing redundant effect executions.
7
- *
8
- * Features:
9
- * - Groups multiple mutations
10
- * - Defers effect execution until batch completes
11
- * - Supports nested batches
12
- * - Automatically flushes on completion
13
- *
14
- * @example
15
- * ```ts
16
- * const firstName = zenSignal('John')
17
- * const lastName = zenSignal('Doe')
18
- *
19
- * zenEffect(() => {
20
- * console.log(`${firstName()} ${lastName()}`)
21
- * })
22
- * // Logs: "John Doe"
23
- *
24
- * // Without batch - effect runs twice
25
- * firstName('Jane') // Logs: "Jane Doe"
26
- * lastName('Smith') // Logs: "Jane Smith"
27
- *
28
- * // With batch - effect runs once
29
- * zenBatch(() => {
30
- * firstName('Bob')
31
- * lastName('Brown')
32
- * })
33
- * // Logs: "Bob Brown" (only once)
34
- * ```
35
- */
36
- /**
37
- * Execute a function with batched updates
38
- *
39
- * All reactive updates inside the batch will be collected,
40
- * and effects will only run once after the batch completes.
41
- *
42
- * @param fn - The function to execute
43
- * @returns The return value of the function
44
- */
45
- export declare function zenBatch<T>(fn: () => T): T;
@@ -1,54 +0,0 @@
1
- /**
2
- * Zenith Batch - Deferred Effect Execution
3
- *
4
- * Batching allows you to make multiple reactive updates without
5
- * triggering effects until all updates are complete. This improves
6
- * performance by preventing redundant effect executions.
7
- *
8
- * Features:
9
- * - Groups multiple mutations
10
- * - Defers effect execution until batch completes
11
- * - Supports nested batches
12
- * - Automatically flushes on completion
13
- *
14
- * @example
15
- * ```ts
16
- * const firstName = zenSignal('John')
17
- * const lastName = zenSignal('Doe')
18
- *
19
- * zenEffect(() => {
20
- * console.log(`${firstName()} ${lastName()}`)
21
- * })
22
- * // Logs: "John Doe"
23
- *
24
- * // Without batch - effect runs twice
25
- * firstName('Jane') // Logs: "Jane Doe"
26
- * lastName('Smith') // Logs: "Jane Smith"
27
- *
28
- * // With batch - effect runs once
29
- * zenBatch(() => {
30
- * firstName('Bob')
31
- * lastName('Brown')
32
- * })
33
- * // Logs: "Bob Brown" (only once)
34
- * ```
35
- */
36
- import { startBatch, endBatch } from './tracking';
37
- /**
38
- * Execute a function with batched updates
39
- *
40
- * All reactive updates inside the batch will be collected,
41
- * and effects will only run once after the batch completes.
42
- *
43
- * @param fn - The function to execute
44
- * @returns The return value of the function
45
- */
46
- export function zenBatch(fn) {
47
- startBatch();
48
- try {
49
- return fn();
50
- }
51
- finally {
52
- endBatch();
53
- }
54
- }
@@ -1,48 +0,0 @@
1
- /**
2
- * Zenith Effect - Auto-Tracked Side Effect
3
- *
4
- * Effects are functions that automatically track their reactive dependencies
5
- * and re-run when those dependencies change. They are the bridge between
6
- * reactive state and side effects (DOM updates, logging, API calls, etc.)
7
- *
8
- * Features:
9
- * - Automatic dependency tracking (no dependency arrays)
10
- * - Runs immediately on creation
11
- * - Re-runs when dependencies change
12
- * - Supports cleanup functions
13
- * - Can be manually disposed
14
- *
15
- * @example
16
- * ```ts
17
- * const count = zenSignal(0)
18
- *
19
- * // Effect runs immediately, then re-runs when count changes
20
- * const dispose = zenEffect(() => {
21
- * console.log('Count:', count())
22
- *
23
- * // Optional cleanup - runs before next execution or on dispose
24
- * return () => {
25
- * console.log('Cleanup')
26
- * }
27
- * })
28
- *
29
- * count(1) // Logs: "Cleanup", then "Count: 1"
30
- *
31
- * dispose() // Cleanup and stop watching
32
- * ```
33
- */
34
- /**
35
- * Effect function type - can optionally return a cleanup function
36
- */
37
- export type EffectFn = () => void | (() => void);
38
- /**
39
- * Dispose function - call to stop the effect
40
- */
41
- export type DisposeFn = () => void;
42
- /**
43
- * Create an auto-tracked side effect
44
- *
45
- * @param fn - The effect function to run
46
- * @returns A dispose function to stop the effect
47
- */
48
- export declare function zenEffect(fn: EffectFn): DisposeFn;
@@ -1,98 +0,0 @@
1
- /**
2
- * Zenith Effect - Auto-Tracked Side Effect
3
- *
4
- * Effects are functions that automatically track their reactive dependencies
5
- * and re-run when those dependencies change. They are the bridge between
6
- * reactive state and side effects (DOM updates, logging, API calls, etc.)
7
- *
8
- * Features:
9
- * - Automatic dependency tracking (no dependency arrays)
10
- * - Runs immediately on creation
11
- * - Re-runs when dependencies change
12
- * - Supports cleanup functions
13
- * - Can be manually disposed
14
- *
15
- * @example
16
- * ```ts
17
- * const count = zenSignal(0)
18
- *
19
- * // Effect runs immediately, then re-runs when count changes
20
- * const dispose = zenEffect(() => {
21
- * console.log('Count:', count())
22
- *
23
- * // Optional cleanup - runs before next execution or on dispose
24
- * return () => {
25
- * console.log('Cleanup')
26
- * }
27
- * })
28
- *
29
- * count(1) // Logs: "Cleanup", then "Count: 1"
30
- *
31
- * dispose() // Cleanup and stop watching
32
- * ```
33
- */
34
- import { pushContext, popContext, cleanupContext } from './tracking';
35
- /**
36
- * Create an auto-tracked side effect
37
- *
38
- * @param fn - The effect function to run
39
- * @returns A dispose function to stop the effect
40
- */
41
- export function zenEffect(fn) {
42
- const state = {
43
- fn,
44
- cleanup: null,
45
- context: {
46
- execute: () => runEffect(state),
47
- dependencies: new Set()
48
- },
49
- disposed: false
50
- };
51
- // Run the effect immediately
52
- runEffect(state);
53
- // Return dispose function
54
- return () => disposeEffect(state);
55
- }
56
- /**
57
- * Run an effect, tracking dependencies
58
- */
59
- function runEffect(state) {
60
- if (state.disposed)
61
- return;
62
- // Run cleanup from previous execution
63
- if (state.cleanup) {
64
- state.cleanup();
65
- state.cleanup = null;
66
- }
67
- // Clean up old dependencies
68
- cleanupContext(state.context);
69
- // Push this effect onto the tracking stack
70
- pushContext(state.context);
71
- try {
72
- // Run the effect function
73
- const result = state.fn();
74
- // Store cleanup if returned
75
- if (typeof result === 'function') {
76
- state.cleanup = result;
77
- }
78
- }
79
- finally {
80
- // Pop from tracking stack
81
- popContext();
82
- }
83
- }
84
- /**
85
- * Dispose an effect - run cleanup and stop watching
86
- */
87
- function disposeEffect(state) {
88
- if (state.disposed)
89
- return;
90
- state.disposed = true;
91
- // Run cleanup
92
- if (state.cleanup) {
93
- state.cleanup();
94
- state.cleanup = null;
95
- }
96
- // Remove from all dependency sets
97
- cleanupContext(state.context);
98
- }
@@ -1,43 +0,0 @@
1
- /**
2
- * Zenith Memo - Computed/Derived Value
3
- *
4
- * A memo is a lazily-evaluated, cached computation that automatically
5
- * tracks its dependencies and only recomputes when those dependencies change.
6
- *
7
- * Features:
8
- * - Lazy evaluation (only computes when read)
9
- * - Automatic dependency tracking
10
- * - Cached value until dependencies change
11
- * - Read-only (no setter)
12
- *
13
- * @example
14
- * ```ts
15
- * const firstName = zenSignal('John')
16
- * const lastName = zenSignal('Doe')
17
- *
18
- * // Memo computes full name, tracks firstName and lastName
19
- * const fullName = zenMemo(() => `${firstName()} ${lastName()}`)
20
- *
21
- * console.log(fullName()) // "John Doe"
22
- *
23
- * firstName('Jane')
24
- * console.log(fullName()) // "Jane Doe" (recomputed)
25
- * console.log(fullName()) // "Jane Doe" (cached, no recomputation)
26
- * ```
27
- */
28
- /**
29
- * Memo interface - callable getter
30
- */
31
- export interface Memo<T> {
32
- /** Get the current computed value */
33
- (): T;
34
- /** Peek at cached value without tracking (may be stale) */
35
- peek(): T;
36
- }
37
- /**
38
- * Create a memoized computed value
39
- *
40
- * @param fn - The computation function
41
- * @returns A memo that can be read to get the computed value
42
- */
43
- export declare function zenMemo<T>(fn: () => T): Memo<T>;
@@ -1,100 +0,0 @@
1
- /**
2
- * Zenith Memo - Computed/Derived Value
3
- *
4
- * A memo is a lazily-evaluated, cached computation that automatically
5
- * tracks its dependencies and only recomputes when those dependencies change.
6
- *
7
- * Features:
8
- * - Lazy evaluation (only computes when read)
9
- * - Automatic dependency tracking
10
- * - Cached value until dependencies change
11
- * - Read-only (no setter)
12
- *
13
- * @example
14
- * ```ts
15
- * const firstName = zenSignal('John')
16
- * const lastName = zenSignal('Doe')
17
- *
18
- * // Memo computes full name, tracks firstName and lastName
19
- * const fullName = zenMemo(() => `${firstName()} ${lastName()}`)
20
- *
21
- * console.log(fullName()) // "John Doe"
22
- *
23
- * firstName('Jane')
24
- * console.log(fullName()) // "Jane Doe" (recomputed)
25
- * console.log(fullName()) // "Jane Doe" (cached, no recomputation)
26
- * ```
27
- */
28
- import { pushContext, popContext, cleanupContext, trackDependency } from './tracking';
29
- /**
30
- * Create a memoized computed value
31
- *
32
- * @param fn - The computation function
33
- * @returns A memo that can be read to get the computed value
34
- */
35
- export function zenMemo(fn) {
36
- const state = {
37
- fn,
38
- value: undefined,
39
- dirty: true,
40
- context: {
41
- execute: () => markDirty(state),
42
- dependencies: new Set()
43
- },
44
- subscribers: new Set(),
45
- initialized: false
46
- };
47
- function memo() {
48
- // Track that something is reading this memo
49
- trackDependency(state.subscribers);
50
- // Recompute if dirty
51
- if (state.dirty) {
52
- computeMemo(state);
53
- }
54
- return state.value;
55
- }
56
- // Add peek method
57
- ;
58
- memo.peek = function () {
59
- // Return cached value without tracking or recomputing
60
- if (state.dirty && !state.initialized) {
61
- computeMemo(state);
62
- }
63
- return state.value;
64
- };
65
- return memo;
66
- }
67
- /**
68
- * Compute the memo value, tracking dependencies
69
- */
70
- function computeMemo(state) {
71
- // Clean up old dependencies
72
- cleanupContext(state.context);
73
- // Push this memo onto the tracking stack
74
- pushContext(state.context);
75
- try {
76
- // Compute new value
77
- state.value = state.fn();
78
- state.dirty = false;
79
- state.initialized = true;
80
- }
81
- finally {
82
- // Pop from tracking stack
83
- popContext();
84
- }
85
- }
86
- /**
87
- * Mark the memo as dirty (needs recomputation)
88
- * Called when a dependency changes
89
- */
90
- function markDirty(state) {
91
- if (!state.dirty) {
92
- state.dirty = true;
93
- // Notify any effects/memos that depend on this memo
94
- // Copy to avoid issues during iteration
95
- const subscribers = [...state.subscribers];
96
- for (const subscriber of subscribers) {
97
- subscriber();
98
- }
99
- }
100
- }
@@ -1,44 +0,0 @@
1
- /**
2
- * Zenith Ref - Mutable Reference Container
3
- *
4
- * A ref is a mutable container that does NOT trigger reactivity.
5
- * It's useful for:
6
- * - Storing DOM element references
7
- * - Imperative escape hatches
8
- * - Values that change but shouldn't trigger re-renders
9
- *
10
- * Features:
11
- * - Mutable `.current` property
12
- * - Does NOT track dependencies
13
- * - Does NOT trigger effects
14
- * - Persists across effect re-runs
15
- *
16
- * @example
17
- * ```ts
18
- * // DOM reference
19
- * const inputRef = zenRef<HTMLInputElement>()
20
- *
21
- * // Later, after mount
22
- * inputRef.current = document.querySelector('input')
23
- * inputRef.current?.focus()
24
- *
25
- * // Mutable value that doesn't trigger reactivity
26
- * const previousValue = zenRef(0)
27
- * previousValue.current = count() // No effect triggered
28
- * ```
29
- */
30
- /**
31
- * Ref interface - mutable container with .current
32
- */
33
- export interface Ref<T> {
34
- /** The current value */
35
- current: T;
36
- }
37
- /**
38
- * Create a mutable reference container
39
- *
40
- * @param initialValue - The initial value (optional, defaults to undefined)
41
- * @returns A ref object with a mutable .current property
42
- */
43
- export declare function zenRef<T>(): Ref<T | undefined>;
44
- export declare function zenRef<T>(initialValue: T): Ref<T>;
@@ -1,34 +0,0 @@
1
- /**
2
- * Zenith Ref - Mutable Reference Container
3
- *
4
- * A ref is a mutable container that does NOT trigger reactivity.
5
- * It's useful for:
6
- * - Storing DOM element references
7
- * - Imperative escape hatches
8
- * - Values that change but shouldn't trigger re-renders
9
- *
10
- * Features:
11
- * - Mutable `.current` property
12
- * - Does NOT track dependencies
13
- * - Does NOT trigger effects
14
- * - Persists across effect re-runs
15
- *
16
- * @example
17
- * ```ts
18
- * // DOM reference
19
- * const inputRef = zenRef<HTMLInputElement>()
20
- *
21
- * // Later, after mount
22
- * inputRef.current = document.querySelector('input')
23
- * inputRef.current?.focus()
24
- *
25
- * // Mutable value that doesn't trigger reactivity
26
- * const previousValue = zenRef(0)
27
- * previousValue.current = count() // No effect triggered
28
- * ```
29
- */
30
- export function zenRef(initialValue) {
31
- return {
32
- current: initialValue
33
- };
34
- }
@@ -1,48 +0,0 @@
1
- /**
2
- * Zenith Signal - Atomic Reactive Value
3
- *
4
- * A signal is the most basic reactive primitive. It holds a single value
5
- * and notifies subscribers when the value changes.
6
- *
7
- * Features:
8
- * - Getter/setter model
9
- * - Automatic dependency tracking
10
- * - Fine-grained reactivity (no component re-rendering)
11
- *
12
- * @example
13
- * ```ts
14
- * const count = zenSignal(0)
15
- *
16
- * // Read value
17
- * console.log(count()) // 0
18
- *
19
- * // Write value
20
- * count(1)
21
- *
22
- * // Or use .value
23
- * count.value = 2
24
- * console.log(count.value) // 2
25
- * ```
26
- */
27
- /**
28
- * Signal interface - callable getter/setter with .value accessor
29
- */
30
- export interface Signal<T> {
31
- /** Get the current value (also tracks dependency) */
32
- (): T;
33
- /** Set a new value */
34
- (value: T): void;
35
- /** Get/set value via property */
36
- value: T;
37
- /** Peek at value without tracking */
38
- peek(): T;
39
- /** Subscribe to changes */
40
- subscribe(fn: (value: T) => void): () => void;
41
- }
42
- /**
43
- * Create a reactive signal
44
- *
45
- * @param initialValue - The initial value of the signal
46
- * @returns A signal that can be read and written
47
- */
48
- export declare function zenSignal<T>(initialValue: T): Signal<T>;