@zenithbuild/compiler 1.0.15 → 1.3.0

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 +3 -3
  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,76 +0,0 @@
1
- /**
2
- * Zenith OnUnmount - Pre-Unmount Lifecycle Hook
3
- *
4
- * Registers a cleanup callback to run before a component is disposed.
5
- * Useful for cleaning up subscriptions, timers, event listeners, etc.
6
- *
7
- * Features:
8
- * - Runs before component is removed from DOM
9
- * - Can register multiple callbacks
10
- * - Callbacks run in registration order
11
- *
12
- * @example
13
- * ```ts
14
- * zenOnUnmount(() => {
15
- * console.log('Cleaning up...')
16
- * subscription.unsubscribe()
17
- * clearInterval(timerId)
18
- * })
19
- * ```
20
- *
21
- * Note: This hook registers callbacks that will be executed by the
22
- * component lifecycle system when the component is disposed.
23
- */
24
- /**
25
- * Queue of registered unmount callbacks
26
- */
27
- const unmountCallbacks = new Set();
28
- /**
29
- * Register a callback to run before component unmount
30
- *
31
- * @param callback - Function to run before unmount
32
- * @returns Dispose function to cancel the unmount callback
33
- */
34
- export function zenOnUnmount(callback) {
35
- unmountCallbacks.add(callback);
36
- // Return dispose function
37
- return () => {
38
- unmountCallbacks.delete(callback);
39
- };
40
- }
41
- /**
42
- * Execute all unmount callbacks
43
- * Called by the component lifecycle system before disposal
44
- *
45
- * @internal
46
- */
47
- export function executeUnmountCallbacks() {
48
- // Execute in registration order
49
- for (const callback of unmountCallbacks) {
50
- try {
51
- callback();
52
- }
53
- catch (error) {
54
- console.error('[Zenith] Error in onUnmount callback:', error);
55
- }
56
- }
57
- // Clear all callbacks after execution
58
- unmountCallbacks.clear();
59
- }
60
- /**
61
- * Get count of registered unmount callbacks
62
- * Useful for testing
63
- *
64
- * @internal
65
- */
66
- export function getUnmountCallbackCount() {
67
- return unmountCallbacks.size;
68
- }
69
- /**
70
- * Reset unmount state - for testing purposes
71
- *
72
- * @internal
73
- */
74
- export function resetUnmountState() {
75
- unmountCallbacks.clear();
76
- }
@@ -1,116 +0,0 @@
1
- /**
2
- * Zenith CLI Bridge
3
- *
4
- * The ONLY interface between CLI and plugins.
5
- *
6
- * ═══════════════════════════════════════════════════════════════════════════════
7
- * CLI BRIDGE RULES (CANONICAL)
8
- * ═══════════════════════════════════════════════════════════════════════════════
9
- *
10
- * 1. No runtime emitters - plugins return data, CLI serializes blindly
11
- * 2. No plugin typing - all data is unknown
12
- * 3. No semantic helpers - CLI is blind to what data means
13
- *
14
- * The CLI dispatches hooks and collects returns. It never inspects payloads.
15
- * ═══════════════════════════════════════════════════════════════════════════════
16
- */
17
- /**
18
- * CLI Bridge API - passed to plugins during CLI registration
19
- *
20
- * Plugins use this to register namespaced hooks.
21
- * CLI lifecycle hooks: 'cli:*'
22
- * Plugin hooks: '<namespace>:*'
23
- */
24
- export interface CLIBridgeAPI {
25
- /**
26
- * Register a hook handler
27
- *
28
- * @param hook - Namespaced hook name (e.g., 'cli:runtime:collect', 'content:dev:watch')
29
- * @param handler - Handler function that receives context and optionally returns data
30
- */
31
- on(hook: string, handler: (ctx: HookContext) => unknown | void | Promise<unknown | void>): void;
32
- }
33
- /**
34
- * Context passed to hook handlers
35
- *
36
- * CLI provides this but never uses getPluginData itself.
37
- * Only plugins call getPluginData with their own namespace.
38
- */
39
- export interface HookContext {
40
- /** Absolute path to project root */
41
- projectRoot: string;
42
- /**
43
- * Opaque data accessor
44
- *
45
- * CLI passes this function but NEVER calls it.
46
- * Only plugins use it to access their own namespaced data.
47
- */
48
- getPluginData: (namespace: string) => unknown;
49
- /** Additional context data (e.g., filename for file-change hooks) */
50
- [key: string]: unknown;
51
- }
52
- /**
53
- * Runtime payload returned by plugins
54
- *
55
- * CLI collects these and serializes without inspection.
56
- * The envelope structure is: { [namespace]: payload }
57
- */
58
- export interface RuntimePayload {
59
- /** Plugin namespace (e.g., 'content', 'router') */
60
- namespace: string;
61
- /** Opaque payload - CLI never inspects this */
62
- payload: unknown;
63
- }
64
- type HookHandler = (ctx: HookContext) => unknown | void | Promise<unknown | void>;
65
- /**
66
- * Register a hook handler
67
- *
68
- * @internal Called by CLIBridgeAPI.on()
69
- */
70
- export declare function registerHook(hook: string, handler: HookHandler): void;
71
- /**
72
- * Clear all registered hooks
73
- *
74
- * @internal Used for testing and cleanup
75
- */
76
- export declare function clearHooks(): void;
77
- /**
78
- * Run all handlers for a hook (fire-and-forget)
79
- *
80
- * CLI calls this for lifecycle events.
81
- * No return values are collected.
82
- *
83
- * @param hook - Hook name to dispatch
84
- * @param ctx - Hook context
85
- */
86
- export declare function runPluginHooks(hook: string, ctx: HookContext): Promise<void>;
87
- /**
88
- * Collect return values from all handlers for a hook
89
- *
90
- * CLI calls this for 'cli:runtime:collect' to gather plugin payloads.
91
- * Only RuntimePayload-shaped returns are collected.
92
- *
93
- * @param hook - Hook name to dispatch
94
- * @param ctx - Hook context
95
- * @returns Array of runtime payloads from plugins
96
- */
97
- export declare function collectHookReturns(hook: string, ctx: HookContext): Promise<RuntimePayload[]>;
98
- /**
99
- * Build runtime envelope from collected payloads
100
- *
101
- * CLI calls this to serialize plugin data for injection.
102
- * CLI never inspects the envelope contents.
103
- *
104
- * @param payloads - Array of runtime payloads from collectHookReturns
105
- * @returns Envelope object: { [namespace]: payload }
106
- */
107
- export declare function buildRuntimeEnvelope(payloads: RuntimePayload[]): Record<string, unknown>;
108
- /**
109
- * Create a CLI Bridge API for plugin registration
110
- *
111
- * CLI calls this once and passes to each plugin's registerCLI method.
112
- *
113
- * @returns CLIBridgeAPI instance
114
- */
115
- export declare function createBridgeAPI(): CLIBridgeAPI;
116
- export {};
@@ -1,121 +0,0 @@
1
- /**
2
- * Zenith CLI Bridge
3
- *
4
- * The ONLY interface between CLI and plugins.
5
- *
6
- * ═══════════════════════════════════════════════════════════════════════════════
7
- * CLI BRIDGE RULES (CANONICAL)
8
- * ═══════════════════════════════════════════════════════════════════════════════
9
- *
10
- * 1. No runtime emitters - plugins return data, CLI serializes blindly
11
- * 2. No plugin typing - all data is unknown
12
- * 3. No semantic helpers - CLI is blind to what data means
13
- *
14
- * The CLI dispatches hooks and collects returns. It never inspects payloads.
15
- * ═══════════════════════════════════════════════════════════════════════════════
16
- */
17
- const hookRegistry = new Map();
18
- /**
19
- * Register a hook handler
20
- *
21
- * @internal Called by CLIBridgeAPI.on()
22
- */
23
- export function registerHook(hook, handler) {
24
- if (!hookRegistry.has(hook)) {
25
- hookRegistry.set(hook, []);
26
- }
27
- hookRegistry.get(hook).push(handler);
28
- }
29
- /**
30
- * Clear all registered hooks
31
- *
32
- * @internal Used for testing and cleanup
33
- */
34
- export function clearHooks() {
35
- hookRegistry.clear();
36
- }
37
- // ============================================
38
- // Hook Execution (CLI-facing)
39
- // ============================================
40
- /**
41
- * Run all handlers for a hook (fire-and-forget)
42
- *
43
- * CLI calls this for lifecycle events.
44
- * No return values are collected.
45
- *
46
- * @param hook - Hook name to dispatch
47
- * @param ctx - Hook context
48
- */
49
- export async function runPluginHooks(hook, ctx) {
50
- const handlers = hookRegistry.get(hook) || [];
51
- for (const handler of handlers) {
52
- try {
53
- await handler(ctx);
54
- }
55
- catch (error) {
56
- console.error(`[Zenith] Hook "${hook}" error:`, error);
57
- }
58
- }
59
- }
60
- /**
61
- * Collect return values from all handlers for a hook
62
- *
63
- * CLI calls this for 'cli:runtime:collect' to gather plugin payloads.
64
- * Only RuntimePayload-shaped returns are collected.
65
- *
66
- * @param hook - Hook name to dispatch
67
- * @param ctx - Hook context
68
- * @returns Array of runtime payloads from plugins
69
- */
70
- export async function collectHookReturns(hook, ctx) {
71
- const handlers = hookRegistry.get(hook) || [];
72
- const results = [];
73
- for (const handler of handlers) {
74
- try {
75
- const result = await handler(ctx);
76
- // Only collect properly shaped payloads
77
- if (result &&
78
- typeof result === 'object' &&
79
- 'namespace' in result &&
80
- 'payload' in result &&
81
- typeof result.namespace === 'string') {
82
- results.push(result);
83
- }
84
- }
85
- catch (error) {
86
- console.error(`[Zenith] Hook "${hook}" collection error:`, error);
87
- }
88
- }
89
- return results;
90
- }
91
- /**
92
- * Build runtime envelope from collected payloads
93
- *
94
- * CLI calls this to serialize plugin data for injection.
95
- * CLI never inspects the envelope contents.
96
- *
97
- * @param payloads - Array of runtime payloads from collectHookReturns
98
- * @returns Envelope object: { [namespace]: payload }
99
- */
100
- export function buildRuntimeEnvelope(payloads) {
101
- const envelope = {};
102
- for (const { namespace, payload } of payloads) {
103
- envelope[namespace] = payload;
104
- }
105
- return envelope;
106
- }
107
- // ============================================
108
- // Bridge API Factory
109
- // ============================================
110
- /**
111
- * Create a CLI Bridge API for plugin registration
112
- *
113
- * CLI calls this once and passes to each plugin's registerCLI method.
114
- *
115
- * @returns CLIBridgeAPI instance
116
- */
117
- export function createBridgeAPI() {
118
- return {
119
- on: registerHook
120
- };
121
- }
@@ -1,6 +0,0 @@
1
- /**
2
- * Zenith Plugins
3
- *
4
- * Public exports for plugin system
5
- */
6
- export { PluginRegistry, createPluginContext } from './registry';
@@ -1,6 +0,0 @@
1
- /**
2
- * Zenith Plugins
3
- *
4
- * Public exports for plugin system
5
- */
6
- export { PluginRegistry, createPluginContext } from './registry';
@@ -1,67 +0,0 @@
1
- /**
2
- * Zenith Plugin Registry
3
- *
4
- * Manages plugin registration and initialization
5
- *
6
- * ═══════════════════════════════════════════════════════════════════════════════
7
- * HOOK OWNERSHIP RULE (CANONICAL)
8
- * ═══════════════════════════════════════════════════════════════════════════════
9
- *
10
- * The plugin registry is part of core infrastructure.
11
- * It MUST remain plugin-agnostic:
12
- * - No plugin-specific types
13
- * - No plugin-specific logic
14
- * - Generic data handling only
15
- *
16
- * Plugins own their data structures; core provides the storage mechanism.
17
- * ═══════════════════════════════════════════════════════════════════════════════
18
- */
19
- import type { ZenithPlugin, PluginContext } from '../config/types';
20
- /**
21
- * Get all plugin data (for runtime access)
22
- */
23
- export declare function getPluginData(): Record<string, unknown[]>;
24
- /**
25
- * Get plugin data by namespace
26
- */
27
- export declare function getPluginDataByNamespace(namespace: string): unknown[];
28
- /**
29
- * Plugin registry for managing Zenith plugins
30
- */
31
- export declare class PluginRegistry {
32
- private plugins;
33
- /**
34
- * Register a plugin
35
- */
36
- register(plugin: ZenithPlugin): void;
37
- /**
38
- * Get a plugin by name
39
- */
40
- get(name: string): ZenithPlugin | undefined;
41
- /**
42
- * Check if a plugin is registered
43
- */
44
- has(name: string): boolean;
45
- /**
46
- * Get all registered plugins
47
- */
48
- all(): ZenithPlugin[];
49
- /**
50
- * Initialize all plugins with the provided context
51
- */
52
- initAll(ctx: PluginContext): Promise<void>;
53
- /**
54
- * Clear all registered plugins
55
- */
56
- clear(): void;
57
- }
58
- /**
59
- * Create a plugin context for initialization
60
- *
61
- * Uses a generic data setter that stores data by namespace.
62
- * Plugins define their own data structures internally.
63
- *
64
- * @param projectRoot - Absolute path to the project root
65
- * @returns A PluginContext for plugin initialization
66
- */
67
- export declare function createPluginContext(projectRoot: string): PluginContext;
@@ -1,112 +0,0 @@
1
- /**
2
- * Zenith Plugin Registry
3
- *
4
- * Manages plugin registration and initialization
5
- *
6
- * ═══════════════════════════════════════════════════════════════════════════════
7
- * HOOK OWNERSHIP RULE (CANONICAL)
8
- * ═══════════════════════════════════════════════════════════════════════════════
9
- *
10
- * The plugin registry is part of core infrastructure.
11
- * It MUST remain plugin-agnostic:
12
- * - No plugin-specific types
13
- * - No plugin-specific logic
14
- * - Generic data handling only
15
- *
16
- * Plugins own their data structures; core provides the storage mechanism.
17
- * ═══════════════════════════════════════════════════════════════════════════════
18
- */
19
- /**
20
- * Global plugin data store
21
- *
22
- * Plugins store their data here using namespaced keys.
23
- * Core does not interpret this data - it just stores and serves it.
24
- */
25
- const pluginDataStore = {};
26
- /**
27
- * Get all plugin data (for runtime access)
28
- */
29
- export function getPluginData() {
30
- return { ...pluginDataStore };
31
- }
32
- /**
33
- * Get plugin data by namespace
34
- */
35
- export function getPluginDataByNamespace(namespace) {
36
- return pluginDataStore[namespace] || [];
37
- }
38
- /**
39
- * Plugin registry for managing Zenith plugins
40
- */
41
- export class PluginRegistry {
42
- plugins = new Map();
43
- /**
44
- * Register a plugin
45
- */
46
- register(plugin) {
47
- if (this.plugins.has(plugin.name)) {
48
- console.warn(`[Zenith] Plugin "${plugin.name}" is already registered. Overwriting.`);
49
- }
50
- this.plugins.set(plugin.name, plugin);
51
- }
52
- /**
53
- * Get a plugin by name
54
- */
55
- get(name) {
56
- return this.plugins.get(name);
57
- }
58
- /**
59
- * Check if a plugin is registered
60
- */
61
- has(name) {
62
- return this.plugins.has(name);
63
- }
64
- /**
65
- * Get all registered plugins
66
- */
67
- all() {
68
- return Array.from(this.plugins.values());
69
- }
70
- /**
71
- * Initialize all plugins with the provided context
72
- */
73
- async initAll(ctx) {
74
- for (const plugin of this.plugins.values()) {
75
- try {
76
- await plugin.setup(ctx);
77
- }
78
- catch (error) {
79
- const message = error instanceof Error ? error.message : String(error);
80
- console.error(`[Zenith] Failed to initialize plugin "${plugin.name}":`, message);
81
- }
82
- }
83
- }
84
- /**
85
- * Clear all registered plugins
86
- */
87
- clear() {
88
- this.plugins.clear();
89
- // Also clear plugin data
90
- for (const key of Object.keys(pluginDataStore)) {
91
- delete pluginDataStore[key];
92
- }
93
- }
94
- }
95
- /**
96
- * Create a plugin context for initialization
97
- *
98
- * Uses a generic data setter that stores data by namespace.
99
- * Plugins define their own data structures internally.
100
- *
101
- * @param projectRoot - Absolute path to the project root
102
- * @returns A PluginContext for plugin initialization
103
- */
104
- export function createPluginContext(projectRoot) {
105
- return {
106
- projectRoot,
107
- setPluginData: (namespace, data) => {
108
- pluginDataStore[namespace] = data;
109
- },
110
- options: {}
111
- };
112
- }
@@ -1,30 +0,0 @@
1
- /**
2
- * Zenith Reactivity System
3
- *
4
- * This module exports all reactive primitives for the Zenith framework.
5
- *
6
- * Exports both explicit `zen*` names (internal) and clean aliases (public DX).
7
- */
8
- import { zenSignal as _zenSignal, type Signal } from './zen-signal';
9
- import { zenState as _zenState } from './zen-state';
10
- import { zenEffect as _zenEffect, type EffectFn, type DisposeFn } from './zen-effect';
11
- import { zenMemo as _zenMemo, type Memo } from './zen-memo';
12
- import { zenRef as _zenRef, type Ref } from './zen-ref';
13
- import { zenBatch as _zenBatch } from './zen-batch';
14
- import { zenUntrack as _zenUntrack } from './zen-untrack';
15
- export declare const zenSignal: typeof _zenSignal;
16
- export declare const zenState: typeof _zenState;
17
- export declare const zenEffect: typeof _zenEffect;
18
- export declare const zenMemo: typeof _zenMemo;
19
- export declare const zenRef: typeof _zenRef;
20
- export declare const zenBatch: typeof _zenBatch;
21
- export declare const zenUntrack: typeof _zenUntrack;
22
- export type { Signal, Memo, Ref, EffectFn, DisposeFn };
23
- export { type Subscriber, type TrackingContext, trackDependency, notifySubscribers, getCurrentContext, pushContext, popContext, cleanupContext, runUntracked, startBatch, endBatch, isBatching } from './tracking';
24
- export declare const signal: typeof _zenSignal;
25
- export declare const state: typeof _zenState;
26
- export declare const effect: typeof _zenEffect;
27
- export declare const memo: typeof _zenMemo;
28
- export declare const ref: typeof _zenRef;
29
- export declare const batch: typeof _zenBatch;
30
- export declare const untrack: typeof _zenUntrack;
@@ -1,33 +0,0 @@
1
- /**
2
- * Zenith Reactivity System
3
- *
4
- * This module exports all reactive primitives for the Zenith framework.
5
- *
6
- * Exports both explicit `zen*` names (internal) and clean aliases (public DX).
7
- */
8
- // Core primitives - explicit names
9
- import { zenSignal as _zenSignal } from './zen-signal';
10
- import { zenState as _zenState } from './zen-state';
11
- import { zenEffect as _zenEffect } from './zen-effect';
12
- import { zenMemo as _zenMemo } from './zen-memo';
13
- import { zenRef as _zenRef } from './zen-ref';
14
- import { zenBatch as _zenBatch } from './zen-batch';
15
- import { zenUntrack as _zenUntrack } from './zen-untrack';
16
- // Re-export with explicit names
17
- export const zenSignal = _zenSignal;
18
- export const zenState = _zenState;
19
- export const zenEffect = _zenEffect;
20
- export const zenMemo = _zenMemo;
21
- export const zenRef = _zenRef;
22
- export const zenBatch = _zenBatch;
23
- export const zenUntrack = _zenUntrack;
24
- // Internal tracking utilities (for advanced use)
25
- export { trackDependency, notifySubscribers, getCurrentContext, pushContext, popContext, cleanupContext, runUntracked, startBatch, endBatch, isBatching } from './tracking';
26
- // Public DX aliases - clean names
27
- export const signal = _zenSignal;
28
- export const state = _zenState;
29
- export const effect = _zenEffect;
30
- export const memo = _zenMemo;
31
- export const ref = _zenRef;
32
- export const batch = _zenBatch;
33
- export const untrack = _zenUntrack;
@@ -1,74 +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
- * A subscriber is a function that gets called when a reactive value changes
15
- */
16
- export type Subscriber = () => void;
17
- /**
18
- * Tracking context - represents an effect or memo that is collecting dependencies
19
- */
20
- export interface TrackingContext {
21
- /** The function to call when dependencies change */
22
- execute: Subscriber;
23
- /** Set of dependency subscriber sets this context is registered with */
24
- dependencies: Set<Set<Subscriber>>;
25
- }
26
- /**
27
- * Get the current tracking context (if any)
28
- */
29
- export declare function getCurrentContext(): TrackingContext | undefined;
30
- /**
31
- * Push a new tracking context onto the stack
32
- */
33
- export declare function pushContext(context: TrackingContext): void;
34
- /**
35
- * Pop the current tracking context from the stack
36
- */
37
- export declare function popContext(): TrackingContext | undefined;
38
- /**
39
- * Track a dependency - called when a reactive value is read
40
- *
41
- * @param subscribers - The subscriber set of the reactive value being read
42
- */
43
- export declare function trackDependency(subscribers: Set<Subscriber>): void;
44
- /**
45
- * Notify subscribers that a reactive value has changed
46
- *
47
- * @param subscribers - The subscriber set to notify
48
- */
49
- export declare function notifySubscribers(subscribers: Set<Subscriber>): void;
50
- /**
51
- * Clean up a tracking context - remove it from all dependency sets
52
- *
53
- * @param context - The context to clean up
54
- */
55
- export declare function cleanupContext(context: TrackingContext): void;
56
- /**
57
- * Run a function without tracking dependencies
58
- *
59
- * @param fn - The function to run
60
- * @returns The return value of the function
61
- */
62
- export declare function runUntracked<T>(fn: () => T): T;
63
- /**
64
- * Start a batch - defer effect execution until batch ends
65
- */
66
- export declare function startBatch(): void;
67
- /**
68
- * End a batch - run all pending effects
69
- */
70
- export declare function endBatch(): void;
71
- /**
72
- * Check if currently inside a batch
73
- */
74
- export declare function isBatching(): boolean;