@zenithbuild/bundler 1.3.17 → 1.3.18

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 (48) hide show
  1. package/dist/build-analyzer.d.ts +45 -0
  2. package/dist/build-analyzer.d.ts.map +1 -0
  3. package/dist/build-analyzer.js +88 -0
  4. package/dist/build-analyzer.js.map +1 -0
  5. package/dist/bundle-generator.d.ts +19 -0
  6. package/dist/bundle-generator.d.ts.map +1 -0
  7. package/dist/bundle-generator.js +838 -0
  8. package/dist/bundle-generator.js.map +1 -0
  9. package/dist/bundler.d.ts +32 -0
  10. package/dist/bundler.d.ts.map +1 -0
  11. package/dist/bundler.js +87 -0
  12. package/dist/bundler.js.map +1 -0
  13. package/dist/css.d.ts +60 -0
  14. package/dist/css.d.ts.map +1 -0
  15. package/dist/css.js +229 -0
  16. package/dist/css.js.map +1 -0
  17. package/dist/discovery/componentDiscovery.d.ts +42 -0
  18. package/dist/discovery/componentDiscovery.d.ts.map +1 -0
  19. package/dist/discovery/componentDiscovery.js +67 -0
  20. package/dist/discovery/componentDiscovery.js.map +1 -0
  21. package/dist/discovery/layouts.d.ts +15 -0
  22. package/dist/discovery/layouts.d.ts.map +1 -0
  23. package/dist/discovery/layouts.js +37 -0
  24. package/dist/discovery/layouts.js.map +1 -0
  25. package/dist/generateFinalBundle.d.ts +25 -0
  26. package/dist/generateFinalBundle.d.ts.map +1 -0
  27. package/dist/generateFinalBundle.js +69 -0
  28. package/dist/generateFinalBundle.js.map +1 -0
  29. package/dist/index.d.ts +12 -0
  30. package/dist/index.d.ts.map +1 -0
  31. package/dist/index.js.map +1 -0
  32. package/dist/runtime-generator.d.ts +5 -0
  33. package/dist/runtime-generator.d.ts.map +1 -0
  34. package/dist/runtime-generator.js +21 -0
  35. package/dist/runtime-generator.js.map +1 -0
  36. package/dist/spa-build.d.ts +27 -0
  37. package/dist/spa-build.d.ts.map +1 -0
  38. package/dist/spa-build.js +862 -0
  39. package/dist/spa-build.js.map +1 -0
  40. package/dist/ssg-build.d.ts +32 -0
  41. package/dist/ssg-build.d.ts.map +1 -0
  42. package/dist/ssg-build.js +429 -0
  43. package/dist/ssg-build.js.map +1 -0
  44. package/dist/types.d.ts +6 -0
  45. package/dist/types.d.ts.map +1 -0
  46. package/dist/types.js +2 -0
  47. package/dist/types.js.map +1 -0
  48. package/package.json +2 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle-generator.js","sourceRoot":"","sources":["../src/bundle-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,IAAI,CAAA;AAC7C,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB;;;;;;;;;;;;GAYG;AAEH;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAAgC;IAC7D,oEAAoE;IACpE,8FAA8F;IAC9F,MAAM,cAAc,GAAG,UAAU;QAC7B,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,YAAY,EAAE,YAAY,CAAC;QAChE,CAAC,CAAC,IAAI,CAAC;IAEX,qFAAqF;IACrF,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;IAC7B,IAAI,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,6BAA6B,CAAC,CAAA;IACvE,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;QAC/B,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,qBAAqB,CAAC,CAAA;IAC/D,CAAC;IAED,IAAI,YAAY,GAAG,EAAE,CAAA;IACrB,IAAI,WAAW,GAAG,EAAE,CAAA;IAEpB,IAAI,CAAC;QACD,IAAI,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,qBAAqB,CAAC,CAAA;QACtE,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC;YAAE,cAAc,GAAG,IAAI,CA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwuBvD,CAAC;AACF,CAAC;AAED,UAAU;AACV,SAAS,wBAAwB,CAAC,MAAc;IAC5C,OAAO,MAAM,CAAC,OAAO,CAAC,0CAA0C,EAAE,QAAQ,CAAC,CAAC;AAChF,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @zenithbuild/bundler - Page Script Bundler
3
+ *
4
+ * COMPILER-FIRST ARCHITECTURE
5
+ * ═══════════════════════════════════════════════════════════════════════════════
6
+ *
7
+ * This bundler performs ZERO inference. It executes exactly what the compiler specifies.
8
+ *
9
+ * Rules:
10
+ * - If a BundlePlan is provided, bundling MUST occur
11
+ * - If bundling fails, throw a hard error (no fallback)
12
+ * - The bundler never inspects source code for intent
13
+ * - No temp files, no heuristics, no recovery
14
+ *
15
+ * Bundler failure = compiler bug.
16
+ * ═══════════════════════════════════════════════════════════════════════════════
17
+ */
18
+ import type { BundlePlan } from '@zenithbuild/compiler';
19
+ /**
20
+ * Execute a compiler-emitted BundlePlan
21
+ *
22
+ * This is a PURE PLAN EXECUTOR. It does not:
23
+ * - Inspect source code for imports
24
+ * - Decide whether bundling is needed
25
+ * - Fall back on failure
26
+ * - Use temp files
27
+ *
28
+ * @param plan - Compiler-emitted BundlePlan (must exist; caller must not call if no plan)
29
+ * @throws Error if bundling fails (no fallback, no recovery)
30
+ */
31
+ export declare function bundlePageScript(plan: BundlePlan): Promise<string>;
32
+ //# sourceMappingURL=bundler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundler.d.ts","sourceRoot":"","sources":["../src/bundler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAEvD;;;;;;;;;;;GAWG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAgExE"}
@@ -0,0 +1,87 @@
1
+ /**
2
+ * @zenithbuild/bundler - Page Script Bundler
3
+ *
4
+ * COMPILER-FIRST ARCHITECTURE
5
+ * ═══════════════════════════════════════════════════════════════════════════════
6
+ *
7
+ * This bundler performs ZERO inference. It executes exactly what the compiler specifies.
8
+ *
9
+ * Rules:
10
+ * - If a BundlePlan is provided, bundling MUST occur
11
+ * - If bundling fails, throw a hard error (no fallback)
12
+ * - The bundler never inspects source code for intent
13
+ * - No temp files, no heuristics, no recovery
14
+ *
15
+ * Bundler failure = compiler bug.
16
+ * ═══════════════════════════════════════════════════════════════════════════════
17
+ */
18
+ import { rolldown } from 'rolldown';
19
+ /**
20
+ * Execute a compiler-emitted BundlePlan
21
+ *
22
+ * This is a PURE PLAN EXECUTOR. It does not:
23
+ * - Inspect source code for imports
24
+ * - Decide whether bundling is needed
25
+ * - Fall back on failure
26
+ * - Use temp files
27
+ *
28
+ * @param plan - Compiler-emitted BundlePlan (must exist; caller must not call if no plan)
29
+ * @throws Error if bundling fails (no fallback, no recovery)
30
+ */
31
+ export async function bundlePageScript(plan) {
32
+ // Virtual entry module ID
33
+ const VIRTUAL_ENTRY = '\0zenith:entry.tsx';
34
+ // Build virtual modules map from plan
35
+ const virtualModules = new Map();
36
+ virtualModules.set(VIRTUAL_ENTRY, plan.entry);
37
+ for (const vm of plan.virtualModules) {
38
+ virtualModules.set(vm.id, vm.code);
39
+ }
40
+ // Execute Rolldown with plan-specified configuration
41
+ // No inference, no heuristics, no semantic analysis
42
+ const bundle = await rolldown({
43
+ input: VIRTUAL_ENTRY,
44
+ platform: plan.platform,
45
+ resolve: {
46
+ modules: plan.resolveRoots
47
+ },
48
+ plugins: [{
49
+ name: 'zenith-virtual',
50
+ resolveId(source) {
51
+ // Virtual modules from plan
52
+ if (virtualModules.has(source)) {
53
+ return { id: source, moduleSideEffects: true };
54
+ }
55
+ // Special case: zenith:content namespace
56
+ if (source === 'zenith:content') {
57
+ return { id: '\0zenith:content', moduleSideEffects: true };
58
+ }
59
+ return null;
60
+ },
61
+ load(id) {
62
+ return virtualModules.get(id) ?? null;
63
+ }
64
+ }],
65
+ // DETERMINISTIC OUTPUT: Disable all semantic optimizations
66
+ // Tree-shaking implies semantic analysis - bundler must not infer
67
+ treeshake: false,
68
+ // HARD FAILURE on unresolved imports - no silent external treatment
69
+ onLog(level, log) {
70
+ if (log.code === 'UNRESOLVED_IMPORT') {
71
+ throw new Error(`[Zenith Bundler] Unresolved import: ${log.message}. ` +
72
+ `This is a compiler error - the BundlePlan references a module that cannot be resolved.`);
73
+ }
74
+ }
75
+ });
76
+ // Generate output with plan-specified format
77
+ const { output } = await bundle.generate({
78
+ format: plan.format
79
+ });
80
+ // Hard failure if no output - this is a compiler bug
81
+ if (!output[0]?.code) {
82
+ throw new Error('[Zenith Bundler] Rolldown produced no output. ' +
83
+ 'This is a compiler error - the BundlePlan was invalid or Rolldown failed silently.');
84
+ }
85
+ return output[0].code;
86
+ }
87
+ //# sourceMappingURL=bundler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundler.js","sourceRoot":"","sources":["../src/bundler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAGnC;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,IAAgB;IACnD,0BAA0B;IAC1B,MAAM,aAAa,GAAG,oBAAoB,CAAA;IAE1C,sCAAsC;IACtC,MAAM,cAAc,GAAG,IAAI,GAAG,EAAkB,CAAA;IAChD,cAAc,CAAC,GAAG,CAAC,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;IAC7C,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;QACnC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAA;IACtC,C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C,EAAE,IAAI,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CACX,gDAAgD;YAChD,oFAAoF,CACvF,CAAA;IACL,CAAC;IAED,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AACzB,CAAC"}
package/dist/css.d.ts ADDED
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Zenith CSS Compiler Module
3
+ *
4
+ * Compiler-owned CSS processing that integrates Tailwind CSS v4 JIT
5
+ * at compile time. This module ensures:
6
+ *
7
+ * 1. All CSS is processed at build time (no runtime generation)
8
+ * 2. Tailwind sees all .zen templates for class scanning
9
+ * 3. HMR support for instant CSS updates in dev mode
10
+ * 4. Deterministic, cacheable output for production
11
+ *
12
+ * Per Zenith CSS Directive: The compiler owns styles.
13
+ */
14
+ export interface CSSCompileOptions {
15
+ /** Input CSS file path (e.g., src/styles/globals.css) */
16
+ input: string;
17
+ /** Output CSS file path, or ':memory:' for in-memory result */
18
+ output: string;
19
+ /** Enable minification for production */
20
+ minify?: boolean;
21
+ /** Watch mode for HMR */
22
+ watch?: boolean;
23
+ }
24
+ export interface CSSCompileResult {
25
+ /** Compiled CSS content */
26
+ css: string;
27
+ /** Compilation time in milliseconds */
28
+ duration: number;
29
+ /** Whether compilation succeeded */
30
+ success: boolean;
31
+ /** Error message if failed */
32
+ error?: string;
33
+ }
34
+ /**
35
+ * Compile CSS using Tailwind CSS v4 CLI
36
+ */
37
+ export declare function compileCss(options: CSSCompileOptions): CSSCompileResult;
38
+ /**
39
+ * Compile CSS asynchronously (non-blocking)
40
+ */
41
+ export declare function compileCssAsync(options: CSSCompileOptions): Promise<CSSCompileResult>;
42
+ export interface CSSWatchOptions extends CSSCompileOptions {
43
+ /** Callback when CSS changes */
44
+ onChange: (result: CSSCompileResult) => void;
45
+ /** Debounce delay in ms */
46
+ debounce?: number;
47
+ }
48
+ /**
49
+ * Watch CSS and source files for changes, recompile on change
50
+ */
51
+ export declare function watchCss(options: CSSWatchOptions): () => void;
52
+ /**
53
+ * Resolve the canonical globals.css path for a Zenith project
54
+ */
55
+ export declare function resolveGlobalsCss(projectRoot: string): string | null;
56
+ /**
57
+ * Get the output path for compiled CSS
58
+ */
59
+ export declare function getCompiledCssPath(projectRoot: string, mode: 'dev' | 'build'): string;
60
+ //# sourceMappingURL=css.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css.d.ts","sourceRoot":"","sources":["../src/css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAUH,MAAM,WAAW,iBAAiB;IAC9B,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAA;IACb,+DAA+D;IAC/D,MAAM,EAAE,MAAM,CAAA;IACd,yCAAyC;IACzC,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,yBAAyB;IACzB,KAAK,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC7B,2BAA2B;IAC3B,GAAG,EAAE,MAAM,CAAA;IACX,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAA;IAChB,oCAAoC;IACpC,OAAO,EAAE,OAAO,CAAA;IAChB,8BAA8B;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAA;CACjB;AAMD;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,CAyEvE;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA+E3F;AAED,MAAM,WAAW,eAAgB,SAAQ,iBAAiB;IACtD,gCAAgC;IAChC,QAAQ,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,CAAA;IAC5C,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,IAAI,CA+C7D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAUpE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,GAAG,OAAO,GAAG,MAAM,CAMrF"}
package/dist/css.js ADDED
@@ -0,0 +1,229 @@
1
+ /**
2
+ * Zenith CSS Compiler Module
3
+ *
4
+ * Compiler-owned CSS processing that integrates Tailwind CSS v4 JIT
5
+ * at compile time. This module ensures:
6
+ *
7
+ * 1. All CSS is processed at build time (no runtime generation)
8
+ * 2. Tailwind sees all .zen templates for class scanning
9
+ * 3. HMR support for instant CSS updates in dev mode
10
+ * 4. Deterministic, cacheable output for production
11
+ *
12
+ * Per Zenith CSS Directive: The compiler owns styles.
13
+ */
14
+ import { spawn, spawnSync } from 'child_process';
15
+ import path from 'path';
16
+ import fs from 'fs';
17
+ // ============================================
18
+ // CSS Compilation
19
+ // ============================================
20
+ /**
21
+ * Compile CSS using Tailwind CSS v4 CLI
22
+ */
23
+ export function compileCss(options) {
24
+ const startTime = performance.now();
25
+ const { input, output, minify = false } = options;
26
+ // Validate input exists
27
+ if (!fs.existsSync(input)) {
28
+ return {
29
+ css: '',
30
+ duration: 0,
31
+ success: false,
32
+ error: `CSS input file not found: ${input}`
33
+ };
34
+ }
35
+ try {
36
+ // Build Tailwind CLI arguments
37
+ const args = [
38
+ '@tailwindcss/cli',
39
+ '-i', input
40
+ ];
41
+ // For in-memory compilation, use stdout
42
+ const useStdout = output === ':memory:';
43
+ if (!useStdout) {
44
+ args.push('-o', output);
45
+ }
46
+ if (minify) {
47
+ args.push('--minify');
48
+ }
49
+ // Execute Tailwind CLI synchronously
50
+ const result = spawnSync('bunx', args, {
51
+ cwd: path.dirname(input),
52
+ encoding: 'utf-8',
53
+ stdio: useStdout ? ['pipe', 'pipe', 'pipe'] : ['pipe', 'inherit', 'pipe'],
54
+ env: { ...process.env }
55
+ });
56
+ const duration = Math.round(performance.now() - startTime);
57
+ if (result.status !== 0) {
58
+ const errorMsg = result.stderr?.toString() || 'Unknown compilation error';
59
+ return {
60
+ css: '',
61
+ duration,
62
+ success: false,
63
+ error: `Tailwind compilation failed: ${errorMsg}`
64
+ };
65
+ }
66
+ // Get CSS content
67
+ let css = '';
68
+ if (useStdout) {
69
+ css = result.stdout?.toString() || '';
70
+ }
71
+ else if (fs.existsSync(output)) {
72
+ css = fs.readFileSync(output, 'utf-8');
73
+ }
74
+ return {
75
+ css,
76
+ duration,
77
+ success: true
78
+ };
79
+ }
80
+ catch (error) {
81
+ return {
82
+ css: '',
83
+ duration: Math.round(performance.now() - startTime),
84
+ success: false,
85
+ error: error.message
86
+ };
87
+ }
88
+ }
89
+ /**
90
+ * Compile CSS asynchronously (non-blocking)
91
+ */
92
+ export async function compileCssAsync(options) {
93
+ return new Promise((resolve) => {
94
+ const startTime = performance.now();
95
+ const { input, output, minify = false } = options;
96
+ if (!fs.existsSync(input)) {
97
+ resolve({
98
+ css: '',
99
+ duration: 0,
100
+ success: false,
101
+ error: `CSS input file not found: ${input}`
102
+ });
103
+ return;
104
+ }
105
+ const args = ['@tailwindcss/cli', '-i', input];
106
+ const useStdout = output === ':memory:';
107
+ if (!useStdout) {
108
+ args.push('-o', output);
109
+ }
110
+ if (minify) {
111
+ args.push('--minify');
112
+ }
113
+ const child = spawn('bunx', args, {
114
+ cwd: path.dirname(input),
115
+ stdio: useStdout ? ['pipe', 'pipe', 'pipe'] : ['pipe', 'inherit', 'pipe'],
116
+ env: { ...process.env }
117
+ });
118
+ let stdout = '';
119
+ let stderr = '';
120
+ if (useStdout && child.stdout) {
121
+ child.stdout.on('data', (data) => { stdout += data.toString(); });
122
+ }
123
+ if (child.stderr) {
124
+ child.stderr.on('data', (data) => { stderr += data.toString(); });
125
+ }
126
+ child.on('close', (code) => {
127
+ const duration = Math.round(performance.now() - startTime);
128
+ if (code !== 0) {
129
+ resolve({
130
+ css: '',
131
+ duration,
132
+ success: false,
133
+ error: `Tailwind compilation failed: ${stderr}`
134
+ });
135
+ return;
136
+ }
137
+ let css = '';
138
+ if (useStdout) {
139
+ css = stdout;
140
+ }
141
+ else if (fs.existsSync(output)) {
142
+ css = fs.readFileSync(output, 'utf-8');
143
+ }
144
+ resolve({
145
+ css,
146
+ duration,
147
+ success: true
148
+ });
149
+ });
150
+ child.on('error', (err) => {
151
+ resolve({
152
+ css: '',
153
+ duration: Math.round(performance.now() - startTime),
154
+ success: false,
155
+ error: err.message
156
+ });
157
+ });
158
+ });
159
+ }
160
+ /**
161
+ * Watch CSS and source files for changes, recompile on change
162
+ */
163
+ export function watchCss(options) {
164
+ const { input, output, minify, onChange, debounce = 100 } = options;
165
+ let timeout = null;
166
+ let isCompiling = false;
167
+ const recompile = async () => {
168
+ if (isCompiling)
169
+ return;
170
+ isCompiling = true;
171
+ const result = await compileCssAsync({ input, output, minify });
172
+ onChange(result);
173
+ isCompiling = false;
174
+ };
175
+ const debouncedRecompile = () => {
176
+ if (timeout)
177
+ clearTimeout(timeout);
178
+ timeout = setTimeout(recompile, debounce);
179
+ };
180
+ // Watch the styles directory
181
+ const stylesDir = path.dirname(input);
182
+ const stylesWatcher = fs.watch(stylesDir, { recursive: true }, (event, filename) => {
183
+ if (filename?.endsWith('.css')) {
184
+ debouncedRecompile();
185
+ }
186
+ });
187
+ // Watch source files that Tailwind scans (for class changes)
188
+ const srcDir = path.resolve(stylesDir, '..');
189
+ let srcWatcher = null;
190
+ if (fs.existsSync(srcDir)) {
191
+ srcWatcher = fs.watch(srcDir, { recursive: true }, (event, filename) => {
192
+ if (filename?.endsWith('.zen') || filename?.endsWith('.tsx') || filename?.endsWith('.jsx')) {
193
+ debouncedRecompile();
194
+ }
195
+ });
196
+ }
197
+ // Return cleanup function
198
+ return () => {
199
+ if (timeout)
200
+ clearTimeout(timeout);
201
+ stylesWatcher.close();
202
+ srcWatcher?.close();
203
+ };
204
+ }
205
+ /**
206
+ * Resolve the canonical globals.css path for a Zenith project
207
+ */
208
+ export function resolveGlobalsCss(projectRoot) {
209
+ // Check for globals.css (canonical)
210
+ const globalsPath = path.join(projectRoot, 'src', 'styles', 'globals.css');
211
+ if (fs.existsSync(globalsPath))
212
+ return globalsPath;
213
+ // Check for global.css (legacy)
214
+ const globalPath = path.join(projectRoot, 'src', 'styles', 'global.css');
215
+ if (fs.existsSync(globalPath))
216
+ return globalPath;
217
+ return null;
218
+ }
219
+ /**
220
+ * Get the output path for compiled CSS
221
+ */
222
+ export function getCompiledCssPath(projectRoot, mode) {
223
+ if (mode === 'build') {
224
+ return path.join(projectRoot, 'dist', 'assets', 'styles.css');
225
+ }
226
+ // In dev mode, we use in-memory compilation
227
+ return ':memory:';
228
+ }
229
+ //# sourceMappingURL=css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css.js","sourceRoot":"","sources":["../src/css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,MAAM,IAAI,CAAA;AA4BnB,+CAA+C;AAC/C,kBAAkB;AAClB,+CAA+C;AAE/C;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,OAA0B;IACjD,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,CAAA;IACnC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK,EAAE,GAAG,OAAO,CAAA;IAEjD,wBAAwB;IACxB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO;YACH,GAAG,EAAE,EAAE;YACP,QAAQ,EAAE,CAAC;YACX,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,6BAA6B,KAAK,EAAE;SAC9C,CAAA;IACL,CAAC;IAED,IAAI,CAAC;QACD,+BAA+B;QAC/B,MAAM,IAAI,GAAG;YACT,kBAAkB;YAClB,IAAI,EAAE,KAAK;SACd,CA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WAAmB;IACjD,oCAAoC;IACpC,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAA;IAC1E,IAAI,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC;QAAE,OAAO,WAAW,CAAA;IAElD,gCAAgC;IAChC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAA;IACxE,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;QAAE,OAAO,UAAU,CAAA;IAEhD,OAAO,IAAI,CAAA;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,WAAmB,EAAE,IAAqB;IACzE,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAA;IACjE,CAAC;IACD,4CAA4C;IAC5C,OAAO,UAAU,CAAA;AACrB,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Component Discovery
3
+ *
4
+ * Discovers and catalogs components in a Zenith project using standard
5
+ * file system walking and the unified native "syscall" for metadata.
6
+ */
7
+ import { type TemplateNode, type ExpressionIR } from '@zenithbuild/compiler';
8
+ export interface SlotDefinition {
9
+ name: string | null;
10
+ location: {
11
+ line: number;
12
+ column: number;
13
+ };
14
+ }
15
+ export interface ComponentMetadata {
16
+ name: string;
17
+ path: string;
18
+ template: string;
19
+ nodes: TemplateNode[];
20
+ expressions: ExpressionIR[];
21
+ slots: SlotDefinition[];
22
+ props: string[];
23
+ states: Record<string, string>;
24
+ styles: string[];
25
+ script: string | null;
26
+ scriptAttributes: Record<string, string> | null;
27
+ hasScript: boolean;
28
+ hasStyles: boolean;
29
+ }
30
+ /**
31
+ * Discover all components in a directory recursively
32
+ */
33
+ export declare function discoverComponents(baseDir: string): Map<string, ComponentMetadata>;
34
+ /**
35
+ * Universal Zenith Component Tag Rule: PascalCase
36
+ */
37
+ export declare function isComponentTag(tagName: string): boolean;
38
+ /**
39
+ * Get component metadata by name
40
+ */
41
+ export declare function getComponent(components: Map<string, ComponentMetadata>, name: string): ComponentMetadata | undefined;
42
+ //# sourceMappingURL=componentDiscovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"componentDiscovery.d.ts","sourceRoot":"","sources":["../../src/discovery/componentDiscovery.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAgB,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAE1F,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,QAAQ,EAAE;QACN,IAAI,EAAE,MAAM,CAAA;QACZ,MAAM,EAAE,MAAM,CAAA;KACjB,CAAA;CACJ;AAED,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,YAAY,EAAE,CAAA;IACrB,WAAW,EAAE,YAAY,EAAE,CAAA;IAC3B,KAAK,EAAE,cAAc,EAAE,CAAA;IACvB,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC9B,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAA;IAC/C,SAAS,EAAE,OAAO,CAAA;IAClB,SAAS,EAAE,OAAO,CAAA;CACrB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CA0ClF;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED;;GAEG;AACH,wBAAgB,YAAY,CACxB,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,EAC1C,IAAI,EAAE,MAAM,GACb,iBAAiB,GAAG,SAAS,CAE/B"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Component Discovery
3
+ *
4
+ * Discovers and catalogs components in a Zenith project using standard
5
+ * file system walking and the unified native "syscall" for metadata.
6
+ */
7
+ import * as fs from 'fs';
8
+ import * as path from 'path';
9
+ import { parseZenFile } from '@zenithbuild/compiler';
10
+ /**
11
+ * Discover all components in a directory recursively
12
+ */
13
+ export function discoverComponents(baseDir) {
14
+ const components = new Map();
15
+ if (!fs.existsSync(baseDir))
16
+ return components;
17
+ const walk = (dir) => {
18
+ const files = fs.readdirSync(dir);
19
+ for (const file of files) {
20
+ const fullPath = path.join(dir, file);
21
+ if (fs.statSync(fullPath).isDirectory()) {
22
+ walk(fullPath);
23
+ }
24
+ else if (file.endsWith('.zen')) {
25
+ const name = path.basename(file, '.zen');
26
+ try {
27
+ // Call the "One True Bridge" in metadata mode
28
+ const ir = parseZenFile(fullPath, undefined, { mode: 'metadata' });
29
+ // Map IR to ComponentMetadata format
30
+ components.set(name, {
31
+ name,
32
+ path: fullPath,
33
+ template: ir.template.raw,
34
+ nodes: ir.template.nodes,
35
+ expressions: ir.template.expressions,
36
+ slots: [], // Native bridge needs to return slot info in IR if used
37
+ props: ir.props || [],
38
+ states: ir.script?.states || {},
39
+ styles: ir.styles?.map((s) => s.raw) || [],
40
+ script: ir.script?.raw || null,
41
+ scriptAttributes: ir.script?.attributes || null,
42
+ hasScript: !!ir.script,
43
+ hasStyles: ir.styles?.length > 0
44
+ });
45
+ }
46
+ catch (e) {
47
+ console.error(`[Zenith Discovery] Failed to parse component ${file}:`, e);
48
+ }
49
+ }
50
+ }
51
+ };
52
+ walk(baseDir);
53
+ return components;
54
+ }
55
+ /**
56
+ * Universal Zenith Component Tag Rule: PascalCase
57
+ */
58
+ export function isComponentTag(tagName) {
59
+ return tagName.length > 0 && tagName[0] === tagName[0]?.toUpperCase();
60
+ }
61
+ /**
62
+ * Get component metadata by name
63
+ */
64
+ export function getComponent(components, name) {
65
+ return components.get(name);
66
+ }
67
+ //# sourceMappingURL=componentDiscovery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"componentDiscovery.js","sourceRoot":"","sources":["../../src/discovery/componentDiscovery.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,EAAE,YAAY,EAAwC,MAAM,uBAAuB,CAAA;AA0B1F;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAe;IAC9C,MAAM,UAAU,GAAG,IAAI,GAAG,EAA6B,CAAA;IAEvD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC;QAAE,OAAO,UAAU,CAAC;IAE/C,MAAM,IAAI,GAAG,CAAC,GAAW,EAAE,EAAE;QACzB,MAAM,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAClC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACvB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YACtC,IAAI,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;gBACtC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACnB,CAAC;iBAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC/B,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;gBACzC,IAAI,CAAC;oBACD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AAI,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAA;AACzE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CACxB,UAA0C,EAC1C,IAAY;IAEZ,OAAO,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AAC/B,CAAC"}
@@ -0,0 +1,15 @@
1
+ export interface LayoutMetadata {
2
+ name: string;
3
+ filePath: string;
4
+ props: string[];
5
+ states: Map<string, any>;
6
+ html: string;
7
+ scripts: string[];
8
+ styles: string[];
9
+ }
10
+ /**
11
+ * Discover layouts in a directory using standard file system walking
12
+ * and the unified native bridge for metadata.
13
+ */
14
+ export declare function discoverLayouts(layoutsDir: string): Map<string, LayoutMetadata>;
15
+ //# sourceMappingURL=layouts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layouts.d.ts","sourceRoot":"","sources":["../../src/discovery/layouts.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,MAAM,EAAE,MAAM,EAAE,CAAA;CACnB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CA+B/E"}
@@ -0,0 +1,37 @@
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+ import { parseZenFile } from '@zenithbuild/compiler';
4
+ /**
5
+ * Discover layouts in a directory using standard file system walking
6
+ * and the unified native bridge for metadata.
7
+ */
8
+ export function discoverLayouts(layoutsDir) {
9
+ const layouts = new Map();
10
+ if (!fs.existsSync(layoutsDir))
11
+ return layouts;
12
+ const files = fs.readdirSync(layoutsDir);
13
+ for (const file of files) {
14
+ if (file.endsWith('.zen')) {
15
+ const fullPath = path.join(layoutsDir, file);
16
+ const name = path.basename(file, '.zen');
17
+ try {
18
+ // Call the "One True Bridge" in metadata mode
19
+ const ir = parseZenFile(fullPath, undefined, { mode: 'metadata' });
20
+ layouts.set(name, {
21
+ name,
22
+ filePath: fullPath,
23
+ props: ir.props || [],
24
+ states: new Map(),
25
+ html: ir.template.raw,
26
+ scripts: ir.script ? [ir.script.content] : [],
27
+ styles: ir.styles?.map((s) => s.raw) || []
28
+ });
29
+ }
30
+ catch (e) {
31
+ console.error(`[Zenith Layout Discovery] Failed to parse layout ${file}:`, e);
32
+ }
33
+ }
34
+ }
35
+ return layouts;
36
+ }
37
+ //# sourceMappingURL=layouts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layouts.js","sourceRoot":"","sources":["../../src/discovery/layouts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAYpD;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,UAAkB;IAC9C,MAAM,OAAO,GAAG,IAAI,GAAG,EAA0B,CAAA;IAEjD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;QAAE,OAAO,OAAO,CAAA;IAE9C,MAAM,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,UAAU,CAAC,CAAA;IACxC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YACxB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;YAC5C,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;YAExC,IAAI,CAAC;gBACD,8CAA8C;gBAC9C,MAAM,EAAE,GAAG,YAAY,CAAC,QAAQ,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAA;gBAElE,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE;oBACd,IAAI;oBACJ,QAAQ,EAAE,QAAQ;oBAClB,KAAK,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE;oBACrB,MAAM,EAAE,IAAI,GAAG,EAAE;oBACjB,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG;oBACrB,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE;oBAC7C,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE;iBAClD,CAAC,CAAA;YACN,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACT,OAAO,CAAC,KAAK,CAAC,oDAAoD,IAAI,GAAG,EAAE,CAAC,CAAC,CAAA;YACjF,CAAC;QACL,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAA;AAClB,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Generate Final Bundle
3
+ *
4
+ * Phase 8/9/10: Generate final browser-ready bundle
5
+ *
6
+ * Combines:
7
+ * - Compiled HTML
8
+ * - Runtime JS
9
+ * - Expression functions
10
+ * - Event bindings
11
+ * - Style injection
12
+ */
13
+ import type { FinalizedOutput } from '@zenithbuild/compiler';
14
+ /**
15
+ * Generate final bundle code
16
+ *
17
+ * This is the complete JavaScript bundle that will execute in the browser.
18
+ * All expressions are pre-compiled - no template parsing at runtime.
19
+ */
20
+ export declare function generateFinalBundle(finalized: FinalizedOutput): string;
21
+ /**
22
+ * Generate HTML with inline script
23
+ */
24
+ export declare function generateHTMLWithScript(html: string, jsBundle: string, styles: string[]): string;
25
+ //# sourceMappingURL=generateFinalBundle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateFinalBundle.d.ts","sourceRoot":"","sources":["../src/generateFinalBundle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAE5D;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,eAAe,GAAG,MAAM,CAStE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAClC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EAAE,GACjB,MAAM,CA4BR"}