@zenithbuild/compiler 1.0.16 → 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 +1 -1
  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,181 +0,0 @@
1
- /**
2
- * Zenith Intermediate Representation (IR)
3
- *
4
- * Phase 1: Parse & Extract
5
- * This IR represents the parsed structure of a .zen file
6
- * without any runtime execution or transformation.
7
- */
8
- /**
9
- * Structured ES module import metadata
10
- * Parsed from component scripts, used for deterministic bundling
11
- */
12
- export interface ScriptImport {
13
- source: string;
14
- specifiers: string;
15
- typeOnly: boolean;
16
- sideEffect: boolean;
17
- }
18
- /**
19
- * Component Script IR - represents a component's script block
20
- * Used for collecting and bundling component scripts
21
- */
22
- export type ComponentScriptIR = {
23
- name: string;
24
- script: string;
25
- props: string[];
26
- scriptAttributes: Record<string, string>;
27
- imports: ScriptImport[];
28
- instanceId?: string;
29
- propValues?: Record<string, any>;
30
- expressions?: ExpressionIR[];
31
- };
32
- export type ZenIR = {
33
- filePath: string;
34
- template: TemplateIR;
35
- script: ScriptIR | null;
36
- styles: StyleIR[];
37
- componentScripts?: ComponentScriptIR[];
38
- pageBindings?: string[];
39
- };
40
- export type TemplateIR = {
41
- raw: string;
42
- nodes: TemplateNode[];
43
- expressions: ExpressionIR[];
44
- };
45
- export type TemplateNode = ElementNode | TextNode | ExpressionNode | ComponentNode | ConditionalFragmentNode | OptionalFragmentNode | LoopFragmentNode | DoctypeNode;
46
- export type DoctypeNode = {
47
- type: 'doctype';
48
- name: string;
49
- publicId: string;
50
- systemId: string;
51
- location: SourceLocation;
52
- };
53
- export type ElementNode = {
54
- type: 'element';
55
- tag: string;
56
- attributes: AttributeIR[];
57
- children: TemplateNode[];
58
- location: SourceLocation;
59
- loopContext?: LoopContext;
60
- };
61
- export type ComponentNode = {
62
- type: 'component';
63
- name: string;
64
- attributes: AttributeIR[];
65
- children: TemplateNode[];
66
- location: SourceLocation;
67
- loopContext?: LoopContext;
68
- };
69
- export type TextNode = {
70
- type: 'text';
71
- value: string;
72
- location: SourceLocation;
73
- };
74
- export type ExpressionNode = {
75
- type: 'expression';
76
- expression: string;
77
- location: SourceLocation;
78
- loopContext?: LoopContext;
79
- };
80
- /**
81
- * Conditional Fragment Node
82
- *
83
- * Represents ternary expressions with JSX branches: {cond ? <A /> : <B />}
84
- *
85
- * BOTH branches are compiled at compile time.
86
- * Runtime toggles visibility — never creates DOM.
87
- */
88
- export type ConditionalFragmentNode = {
89
- type: 'conditional-fragment';
90
- condition: string;
91
- consequent: TemplateNode[];
92
- alternate: TemplateNode[];
93
- location: SourceLocation;
94
- loopContext?: LoopContext;
95
- };
96
- /**
97
- * Optional Fragment Node
98
- *
99
- * Represents logical AND expressions with JSX: {cond && <A />}
100
- *
101
- * Fragment is compiled at compile time.
102
- * Runtime toggles mount/unmount based on condition.
103
- */
104
- export type OptionalFragmentNode = {
105
- type: 'optional-fragment';
106
- condition: string;
107
- fragment: TemplateNode[];
108
- location: SourceLocation;
109
- loopContext?: LoopContext;
110
- };
111
- /**
112
- * Loop Fragment Node
113
- *
114
- * Represents .map() expressions with JSX body: {items.map(i => <li>...</li>)}
115
- *
116
- * Desugars to @for loop semantics at compile time.
117
- * Body is compiled once, instantiated per item at runtime.
118
- * Node identity is compiler-owned via stable keys.
119
- */
120
- export type LoopFragmentNode = {
121
- type: 'loop-fragment';
122
- source: string;
123
- itemVar: string;
124
- indexVar?: string;
125
- body: TemplateNode[];
126
- location: SourceLocation;
127
- loopContext: LoopContext;
128
- };
129
- export type AttributeIR = {
130
- name: string;
131
- value: string | ExpressionIR;
132
- location: SourceLocation;
133
- loopContext?: LoopContext;
134
- };
135
- /**
136
- * Loop context for expressions inside map iterations
137
- * Phase 7: Tracks loop variables (e.g., todo, index) for expressions inside .map() calls
138
- */
139
- export type LoopContext = {
140
- variables: string[];
141
- mapSource?: string;
142
- };
143
- export type ExpressionIR = {
144
- id: string;
145
- code: string;
146
- location: SourceLocation;
147
- loopContext?: LoopContext;
148
- };
149
- export type ScriptIR = {
150
- raw: string;
151
- attributes: Record<string, string>;
152
- };
153
- export type StyleIR = {
154
- raw: string;
155
- };
156
- export type SourceLocation = {
157
- line: number;
158
- column: number;
159
- };
160
- /**
161
- * BundlePlan - Compiler-emitted contract for bundler execution
162
- *
163
- * If a plan exists, bundling MUST occur.
164
- * If no plan exists, bundling MUST NOT occur.
165
- * The bundler performs ZERO inference—it executes exactly what the compiler specifies.
166
- */
167
- export interface BundlePlan {
168
- /** Entry point code (not a file path) */
169
- entry: string;
170
- /** Target platform */
171
- platform: 'browser' | 'node';
172
- /** Output format */
173
- format: 'esm' | 'cjs';
174
- /** Directories to resolve modules from */
175
- resolveRoots: string[];
176
- /** Virtual modules provided by the compiler */
177
- virtualModules: Array<{
178
- id: string;
179
- code: string;
180
- }>;
181
- }
package/dist/ir/types.js DELETED
@@ -1,8 +0,0 @@
1
- /**
2
- * Zenith Intermediate Representation (IR)
3
- *
4
- * Phase 1: Parse & Extract
5
- * This IR represents the parsed structure of a .zen file
6
- * without any runtime execution or transformation.
7
- */
8
- export {};
@@ -1,30 +0,0 @@
1
- /**
2
- * Compiled Template Output Types
3
- *
4
- * Phase 2: Transform IR → Static HTML + Runtime Bindings
5
- */
6
- export type CompiledTemplate = {
7
- html: string;
8
- bindings: Binding[];
9
- scripts: string | null;
10
- styles: string[];
11
- };
12
- export type Binding = {
13
- id: string;
14
- type: 'text' | 'attribute' | 'conditional' | 'optional' | 'loop';
15
- target: string;
16
- expression: string;
17
- location?: {
18
- line: number;
19
- column: number;
20
- };
21
- loopContext?: LoopContext;
22
- };
23
- /**
24
- * Loop context for expressions inside map iterations
25
- * Phase 7: Tracks loop variables for runtime setter generation
26
- */
27
- export type LoopContext = {
28
- variables: string[];
29
- mapSource?: string;
30
- };
@@ -1,6 +0,0 @@
1
- /**
2
- * Compiled Template Output Types
3
- *
4
- * Phase 2: Transform IR → Static HTML + Runtime Bindings
5
- */
6
- export {};
@@ -1,45 +0,0 @@
1
- /**
2
- * Map Expression Detection
3
- *
4
- * Phase 7: Detects .map() expressions and extracts loop context information
5
- *
6
- * This module analyzes expression code to detect map expressions like:
7
- * - todoItems.map(todo => ...)
8
- * - notifications.map((n, index) => ...)
9
- *
10
- * It extracts:
11
- * - The array source (todoItems, notifications)
12
- * - Loop variable names (todo, n, index)
13
- * - The map body/template
14
- */
15
- import type { ExpressionIR } from '../ir/types';
16
- /**
17
- * Detected map expression information
18
- */
19
- export interface MapExpressionInfo {
20
- isMap: boolean;
21
- arraySource?: string;
22
- itemVariable?: string;
23
- indexVariable?: string;
24
- mapBody?: string;
25
- fullExpression?: string;
26
- }
27
- /**
28
- * Detect if an expression is a map expression and extract loop context
29
- *
30
- * Patterns detected:
31
- * - arraySource.map(item => body)
32
- * - arraySource.map((item, index) => body)
33
- * - arraySource.map(item => (body))
34
- */
35
- export declare function detectMapExpression(expr: ExpressionIR): MapExpressionInfo;
36
- /**
37
- * Extract loop variables from a map expression
38
- * Returns array of variable names in order: [itemVariable, indexVariable?]
39
- */
40
- export declare function extractLoopVariables(mapInfo: MapExpressionInfo): string[];
41
- /**
42
- * Check if an expression references a loop variable
43
- * Used to determine if an expression needs loop context
44
- */
45
- export declare function referencesLoopVariable(exprCode: string, loopVars: string[]): boolean;
@@ -1,77 +0,0 @@
1
- /**
2
- * Map Expression Detection
3
- *
4
- * Phase 7: Detects .map() expressions and extracts loop context information
5
- *
6
- * This module analyzes expression code to detect map expressions like:
7
- * - todoItems.map(todo => ...)
8
- * - notifications.map((n, index) => ...)
9
- *
10
- * It extracts:
11
- * - The array source (todoItems, notifications)
12
- * - Loop variable names (todo, n, index)
13
- * - The map body/template
14
- */
15
- /**
16
- * Detect if an expression is a map expression and extract loop context
17
- *
18
- * Patterns detected:
19
- * - arraySource.map(item => body)
20
- * - arraySource.map((item, index) => body)
21
- * - arraySource.map(item => (body))
22
- */
23
- export function detectMapExpression(expr) {
24
- const { code } = expr;
25
- // Pattern: arraySource.map(item => body)
26
- // Pattern: arraySource.map((item, index) => body)
27
- // Pattern: arraySource.map(item => (body))
28
- const mapPattern = /^(.+?)\.\s*map\s*\(\s*\(?([^)=,\s]+)(?:\s*,\s*([^)=,\s]+))?\s*\)?\s*=>\s*(.+?)\)?$/s;
29
- const match = code.match(mapPattern);
30
- if (!match) {
31
- return { isMap: false };
32
- }
33
- const arraySource = match[1]?.trim();
34
- const itemVariable = match[2]?.trim();
35
- const indexVariable = match[3]?.trim();
36
- const mapBody = match[4]?.trim();
37
- if (!arraySource || !itemVariable || !mapBody) {
38
- return { isMap: false };
39
- }
40
- return {
41
- isMap: true,
42
- arraySource,
43
- itemVariable,
44
- indexVariable,
45
- mapBody,
46
- fullExpression: code
47
- };
48
- }
49
- /**
50
- * Extract loop variables from a map expression
51
- * Returns array of variable names in order: [itemVariable, indexVariable?]
52
- */
53
- export function extractLoopVariables(mapInfo) {
54
- if (!mapInfo.isMap || !mapInfo.itemVariable) {
55
- return [];
56
- }
57
- const vars = [mapInfo.itemVariable];
58
- if (mapInfo.indexVariable) {
59
- vars.push(mapInfo.indexVariable);
60
- }
61
- return vars;
62
- }
63
- /**
64
- * Check if an expression references a loop variable
65
- * Used to determine if an expression needs loop context
66
- */
67
- export function referencesLoopVariable(exprCode, loopVars) {
68
- for (const loopVar of loopVars) {
69
- // Match variable references: loopVar.property, loopVar, etc.
70
- // Use word boundaries to avoid partial matches
71
- const pattern = new RegExp(`\\b${loopVar}\\b`);
72
- if (pattern.test(exprCode)) {
73
- return true;
74
- }
75
- }
76
- return false;
77
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * Script Parser
3
- *
4
- * Extracts <script> blocks from .zen files
5
- * Phase 1: Only extracts raw content, no evaluation
6
- */
7
- import type { ScriptIR } from '../ir/types';
8
- export declare function parseScript(html: string): ScriptIR | null;
@@ -1,36 +0,0 @@
1
- /**
2
- * Script Parser
3
- *
4
- * Extracts <script> blocks from .zen files
5
- * Phase 1: Only extracts raw content, no evaluation
6
- */
7
- export function parseScript(html) {
8
- const scripts = [];
9
- const attributes = {};
10
- const scriptRegex = /<script\b([^>]*)>([\s\S]*?)<\/script>/gi;
11
- let match;
12
- while ((match = scriptRegex.exec(html)) !== null) {
13
- const attrString = match[1] || '';
14
- const content = match[2] || '';
15
- // Parse attributes
16
- const attrRegex = /([a-z0-9-]+)(?:=(?:"([^"]*)"|'([^']*)'|([^>\s]+)))?/gi;
17
- let attrMatch;
18
- while ((attrMatch = attrRegex.exec(attrString)) !== null) {
19
- const name = attrMatch[1];
20
- if (name) {
21
- const value = attrMatch[2] || attrMatch[3] || attrMatch[4] || 'true';
22
- attributes[name] = value;
23
- }
24
- }
25
- if (content) {
26
- scripts.push(content.trim());
27
- }
28
- }
29
- if (scripts.length === 0) {
30
- return null;
31
- }
32
- return {
33
- raw: scripts.join('\n\n'),
34
- attributes
35
- };
36
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * Template Parser
3
- *
4
- * Parses HTML template and extracts expressions
5
- * Phase 1: Only extracts, does not execute
6
- */
7
- import type { TemplateIR } from '../ir/types';
8
- /**
9
- * Parse template from HTML string
10
- */
11
- export declare function parseTemplate(html: string, filePath: string): TemplateIR;