@zenithbuild/cli 1.3.7 → 1.3.17

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.
package/dist/zen-build.js CHANGED
@@ -1532,7 +1532,7 @@ function showServerPanel(options) {
1532
1532
  `);
1533
1533
  }
1534
1534
 
1535
- // ../zenith-bundler/src/bundle-generator.ts
1535
+ // ../zenith-bundler/dist/bundle-generator.js
1536
1536
  import { readFileSync, existsSync } from "fs";
1537
1537
  import path3 from "path";
1538
1538
  function generateBundleJS(pluginData) {
@@ -2338,7 +2338,7 @@ ${lifecycleJS ? ` // ============================================
2338
2338
  function transformExportsToGlobal(source) {
2339
2339
  return source.replace(/export\s+(const|function|class)\s+(\w+)/g, "var $2");
2340
2340
  }
2341
- // ../zenith-bundler/src/build-analyzer.ts
2341
+ // ../zenith-bundler/dist/build-analyzer.js
2342
2342
  function analyzePageSource(source) {
2343
2343
  const scriptMatch = source.match(/<script[^>]*>([\s\S]*?)<\/script>/i);
2344
2344
  const scriptContent = scriptMatch?.[1] || "";
@@ -8978,7 +8978,7 @@ if (isMainThread) {
8978
8978
  }
8979
8979
  var BindingMagicString = import_binding6.BindingMagicString;
8980
8980
 
8981
- // ../zenith-bundler/src/bundler.ts
8981
+ // ../zenith-bundler/dist/bundler.js
8982
8982
  async function bundlePageScript(plan) {
8983
8983
  const VIRTUAL_ENTRY = "\x00zenith:entry.tsx";
8984
8984
  const virtualModules = new Map;
@@ -9022,7 +9022,7 @@ async function bundlePageScript(plan) {
9022
9022
  }
9023
9023
  return output[0].code;
9024
9024
  }
9025
- // ../zenith-bundler/src/css.ts
9025
+ // ../zenith-bundler/dist/css.js
9026
9026
  import { spawn, spawnSync } from "child_process";
9027
9027
  import path6 from "path";
9028
9028
  import fs2 from "fs";
@@ -9166,7 +9166,7 @@ function resolveGlobalsCss(projectRoot) {
9166
9166
  return globalPath;
9167
9167
  return null;
9168
9168
  }
9169
- // ../zenith-bundler/src/runtime-generator.ts
9169
+ // ../zenith-bundler/dist/runtime-generator.js
9170
9170
  function generateRuntime(manifest, isDev = false) {
9171
9171
  const routes = JSON.stringify(manifest.routes);
9172
9172
  return {
@@ -9187,153 +9187,14 @@ if (window.zenith) {
9187
9187
  `
9188
9188
  };
9189
9189
  }
9190
- // ../zenith-router/src/manifest.ts
9191
- import fs3 from "fs";
9192
- import path7 from "path";
9193
-
9194
- // ../zenith-router/index.js
9195
- import { createRequire as createRequire2 } from "module";
9196
- var require2 = createRequire2(import.meta.url);
9197
- var native = require2("./zenith-router.node");
9198
- var { generateRouteManifestNative, renderRouteNative, resolveRouteNative, generateRuntimeRouterNative, SegmentType, routerBridge } = native;
9199
-
9200
- // ../zenith-router/src/manifest.ts
9201
- var SEGMENT_SCORES = {
9202
- [SegmentType.Static]: 10,
9203
- [SegmentType.Dynamic]: 5,
9204
- [SegmentType.CatchAll]: 1,
9205
- [SegmentType.OptionalCatchAll]: 0
9206
- };
9207
- function discoverPages(pagesDir) {
9208
- const pages = [];
9209
- function walk(dir) {
9210
- if (!fs3.existsSync(dir))
9211
- return;
9212
- const entries = fs3.readdirSync(dir, { withFileTypes: true });
9213
- for (const entry of entries) {
9214
- const fullPath = path7.join(dir, entry.name);
9215
- if (entry.isDirectory()) {
9216
- walk(fullPath);
9217
- } else if (entry.isFile() && entry.name.endsWith(".zen")) {
9218
- pages.push(fullPath);
9219
- }
9220
- }
9221
- }
9222
- walk(pagesDir);
9223
- return pages;
9224
- }
9225
- function filePathToRoutePath(filePath, pagesDir) {
9226
- const relativePath = path7.relative(pagesDir, filePath);
9227
- const withoutExt = relativePath.replace(/\.zen$/, "");
9228
- const segmentsList = withoutExt.split(path7.sep);
9229
- const routeSegments = [];
9230
- for (const segment of segmentsList) {
9231
- if (segment === "index")
9232
- continue;
9233
- const optionalCatchAllMatch = segment.match(/^\[\[\.\.\.(\w+)\]\]$/);
9234
- if (optionalCatchAllMatch) {
9235
- routeSegments.push(`*${optionalCatchAllMatch[1]}?`);
9236
- continue;
9237
- }
9238
- const catchAllMatch = segment.match(/^\[\.\.\.(\w+)\]$/);
9239
- if (catchAllMatch) {
9240
- routeSegments.push(`*${catchAllMatch[1]}`);
9241
- continue;
9242
- }
9243
- const dynamicMatch = segment.match(/^\[(\w+)\]$/);
9244
- if (dynamicMatch) {
9245
- routeSegments.push(`:${dynamicMatch[1]}`);
9246
- continue;
9247
- }
9248
- routeSegments.push(segment);
9249
- }
9250
- const routePath = "/" + routeSegments.join("/");
9251
- return routePath === "/" ? "/" : routePath.replace(/\/$/, "");
9252
- }
9253
- function parseRouteSegments(routePath) {
9254
- if (routePath === "/")
9255
- return [];
9256
- const segmentsList = routePath.slice(1).split("/");
9257
- const parsed = [];
9258
- for (const segment of segmentsList) {
9259
- if (segment.startsWith("*") && segment.endsWith("?")) {
9260
- parsed.push({ segmentType: SegmentType.OptionalCatchAll, paramName: segment.slice(1, -1), raw: segment });
9261
- continue;
9262
- }
9263
- if (segment.startsWith("*")) {
9264
- parsed.push({ segmentType: SegmentType.CatchAll, paramName: segment.slice(1), raw: segment });
9265
- continue;
9266
- }
9267
- if (segment.startsWith(":")) {
9268
- parsed.push({ segmentType: SegmentType.Dynamic, paramName: segment.slice(1), raw: segment });
9269
- continue;
9270
- }
9271
- parsed.push({ segmentType: SegmentType.Static, raw: segment });
9272
- }
9273
- return parsed;
9274
- }
9275
- function calculateRouteScore(segments) {
9276
- if (segments.length === 0)
9277
- return 100;
9278
- let score = 0;
9279
- for (const segment of segments) {
9280
- score += SEGMENT_SCORES[segment.segmentType];
9281
- }
9282
- const staticCount = segments.filter((s2) => s2.segmentType === SegmentType.Static).length;
9283
- score += staticCount * 2;
9284
- return score;
9285
- }
9286
- function extractParamNames(segments) {
9287
- return segments.filter((s2) => s2.paramName !== undefined).map((s2) => s2.paramName);
9288
- }
9289
- function routePathToRegex(routePath) {
9290
- if (routePath === "/")
9291
- return /^\/$/;
9292
- const segmentsList = routePath.slice(1).split("/");
9293
- const regexParts = [];
9294
- for (let i2 = 0;i2 < segmentsList.length; i2++) {
9295
- const segment = segmentsList[i2];
9296
- if (!segment)
9297
- continue;
9298
- if (segment.startsWith("*") && segment.endsWith("?")) {
9299
- regexParts.push("(?:\\/(.*))?");
9300
- continue;
9301
- }
9302
- if (segment.startsWith("*")) {
9303
- regexParts.push("\\/(.+)");
9304
- continue;
9305
- }
9306
- if (segment.startsWith(":")) {
9307
- regexParts.push("\\/([^/]+)");
9308
- continue;
9309
- }
9310
- const escaped = segment.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
9311
- regexParts.push(`\\/${escaped}`);
9312
- }
9313
- return new RegExp(`^${regexParts.join("")}\\/?$`);
9314
- }
9315
- function generateRouteDefinition(filePath, pagesDir) {
9316
- const routePath = filePathToRoutePath(filePath, pagesDir);
9317
- const segments = parseRouteSegments(routePath);
9318
- const paramNames = extractParamNames(segments);
9319
- const score = calculateRouteScore(segments);
9320
- return {
9321
- path: routePath,
9322
- paramNames,
9323
- score,
9324
- filePath,
9325
- regex: routePathToRegex(routePath)
9326
- };
9327
- }
9328
-
9329
9190
  // ../zenith-compiler/dist/parseZenFile.js
9330
9191
  import { readFileSync as readFileSync2 } from "fs";
9331
- var native2;
9192
+ var native;
9332
9193
  try {
9333
- native2 = require_compiler_native();
9194
+ native = require_compiler_native();
9334
9195
  } catch (e3) {
9335
9196
  try {
9336
- native2 = require_compiler_native();
9197
+ native = require_compiler_native();
9337
9198
  } catch {
9338
9199
  console.error(`
9339
9200
  \x1B[31m[Zenith Critical] Native bridge unavailable.\x1B[0m`);
@@ -9347,7 +9208,7 @@ function parseZenFile(filePath, sourceInput, options = {}) {
9347
9208
  const source = sourceInput ?? readFileSync2(filePath, "utf-8");
9348
9209
  const mode = options.mode ?? "full";
9349
9210
  const useCache = options.useCache ?? process.env.ZENITH_CACHE !== "0";
9350
- if (!native2.parseFullZenNative) {
9211
+ if (!native.parseFullZenNative) {
9351
9212
  throw new Error("[Zenith Critical] Broken native bridge: parseFullZenNative symbol missing. Rebuild required.");
9352
9213
  }
9353
9214
  try {
@@ -9358,7 +9219,7 @@ function parseZenFile(filePath, sourceInput, options = {}) {
9358
9219
  layout: options.layout ?? null,
9359
9220
  props: options.props ?? null
9360
9221
  };
9361
- const result = native2.parseFullZenNative(source, filePath, JSON.stringify(nativeOptions));
9222
+ const result = native.parseFullZenNative(source, filePath, JSON.stringify(nativeOptions));
9362
9223
  return result;
9363
9224
  } catch (error4) {
9364
9225
  throw new Error(`[Zenith Native Fatal] ${error4.message}
@@ -9408,122 +9269,18 @@ class InvariantError extends CompilerError {
9408
9269
  }
9409
9270
  }
9410
9271
 
9411
- // ../zenith-compiler/dist/index.js
9412
- async function compile(source, filePath, options) {
9413
- const opts = options || {};
9414
- const components = opts.components || new Map;
9415
- const finalized = parseZenFile(filePath, source, {
9416
- mode: "full",
9417
- components: components ? Object.fromEntries(components) : {},
9418
- layout: opts.layout,
9419
- props: opts.props,
9420
- useCache: true
9421
- });
9422
- if (finalized.code && (finalized.errorType || finalized.error_type)) {
9423
- throw new InvariantError(finalized.code, finalized.message, finalized.guarantee || "Zenith Invariant Violation", filePath, finalized.line || 1, finalized.column || 1, finalized.context, finalized.hints);
9424
- }
9425
- return {
9426
- ir: finalized.ir,
9427
- compiled: {
9428
- html: finalized.html,
9429
- bindings: finalized.bindings || [],
9430
- scripts: finalized.js || null,
9431
- styles: finalized.styles || []
9432
- },
9433
- finalized: {
9434
- ...finalized,
9435
- js: finalized.js,
9436
- npmImports: finalized.npmImports,
9437
- bundlePlan: finalized.bundlePlan
9438
- }
9439
- };
9440
- }
9441
-
9442
- // src/discovery/layouts.ts
9443
- import * as fs4 from "fs";
9444
- import * as path8 from "path";
9445
- function discoverLayouts(layoutsDir) {
9446
- const layouts = new Map;
9447
- if (!fs4.existsSync(layoutsDir))
9448
- return layouts;
9449
- const files = fs4.readdirSync(layoutsDir);
9450
- for (const file of files) {
9451
- if (file.endsWith(".zen")) {
9452
- const fullPath = path8.join(layoutsDir, file);
9453
- const name = path8.basename(file, ".zen");
9454
- try {
9455
- const ir = parseZenFile(fullPath, undefined, { mode: "metadata" });
9456
- layouts.set(name, {
9457
- name,
9458
- filePath: fullPath,
9459
- props: ir.props || [],
9460
- states: new Map,
9461
- html: ir.template.raw,
9462
- scripts: ir.script ? [ir.script.content] : [],
9463
- styles: ir.styles?.map((s2) => s2.raw) || []
9464
- });
9465
- } catch (e3) {
9466
- console.error(`[Zenith Layout Discovery] Failed to parse layout ${file}:`, e3);
9467
- }
9468
- }
9469
- }
9470
- return layouts;
9471
- }
9472
-
9473
- // src/discovery/componentDiscovery.ts
9474
- import * as fs5 from "fs";
9475
- import * as path9 from "path";
9476
- function discoverComponents(baseDir) {
9477
- const components = new Map;
9478
- if (!fs5.existsSync(baseDir))
9479
- return components;
9480
- const walk = (dir) => {
9481
- const files = fs5.readdirSync(dir);
9482
- for (const file of files) {
9483
- const fullPath = path9.join(dir, file);
9484
- if (fs5.statSync(fullPath).isDirectory()) {
9485
- walk(fullPath);
9486
- } else if (file.endsWith(".zen")) {
9487
- const name = path9.basename(file, ".zen");
9488
- try {
9489
- const ir = parseZenFile(fullPath, undefined, { mode: "metadata" });
9490
- components.set(name, {
9491
- name,
9492
- path: fullPath,
9493
- template: ir.template.raw,
9494
- nodes: ir.template.nodes,
9495
- expressions: ir.template.expressions,
9496
- slots: [],
9497
- props: ir.props || [],
9498
- states: ir.script?.states || {},
9499
- styles: ir.styles?.map((s2) => s2.raw) || [],
9500
- script: ir.script?.raw || null,
9501
- scriptAttributes: ir.script?.attributes || null,
9502
- hasScript: !!ir.script,
9503
- hasStyles: ir.styles?.length > 0
9504
- });
9505
- } catch (e3) {
9506
- console.error(`[Zenith Discovery] Failed to parse component ${file}:`, e3);
9507
- }
9508
- }
9509
- }
9510
- };
9511
- walk(baseDir);
9512
- return components;
9513
- }
9514
-
9515
9272
  // ../zenith-compiler/dist/core/config/loader.js
9516
- import fs6 from "fs";
9517
- import path10 from "path";
9273
+ import fs3 from "fs";
9274
+ import path7 from "path";
9518
9275
  async function loadZenithConfig(projectRoot) {
9519
9276
  const configPaths = [
9520
- path10.join(projectRoot, "zenith.config.ts"),
9521
- path10.join(projectRoot, "zenith.config.js"),
9522
- path10.join(projectRoot, "zenith.config.mjs")
9277
+ path7.join(projectRoot, "zenith.config.ts"),
9278
+ path7.join(projectRoot, "zenith.config.js"),
9279
+ path7.join(projectRoot, "zenith.config.mjs")
9523
9280
  ];
9524
9281
  let configPath = null;
9525
9282
  for (const p of configPaths) {
9526
- if (fs6.existsSync(p)) {
9283
+ if (fs3.existsSync(p)) {
9527
9284
  configPath = p;
9528
9285
  break;
9529
9286
  }
@@ -9545,7 +9302,6 @@ async function loadZenithConfig(projectRoot) {
9545
9302
  return { plugins: [] };
9546
9303
  }
9547
9304
  }
9548
-
9549
9305
  // ../zenith-compiler/dist/core/plugins/registry.js
9550
9306
  var pluginDataStore = {};
9551
9307
  function getPluginDataByNamespace(namespace) {
@@ -9595,7 +9351,6 @@ function createPluginContext(projectRoot) {
9595
9351
  options: {}
9596
9352
  };
9597
9353
  }
9598
-
9599
9354
  // ../zenith-compiler/dist/core/plugins/bridge.js
9600
9355
  var hookRegistry = new Map;
9601
9356
  function registerHook(hook, handler) {
@@ -9644,6 +9399,246 @@ function createBridgeAPI() {
9644
9399
  on: registerHook
9645
9400
  };
9646
9401
  }
9402
+ // ../zenith-compiler/dist/index.js
9403
+ async function compile(source, filePath, options) {
9404
+ const opts = options || {};
9405
+ const components = opts.components || new Map;
9406
+ const finalized = parseZenFile(filePath, source, {
9407
+ mode: "full",
9408
+ components: components ? Object.fromEntries(components) : {},
9409
+ layout: opts.layout,
9410
+ props: opts.props,
9411
+ useCache: true
9412
+ });
9413
+ if (finalized.code && (finalized.errorType || finalized.error_type)) {
9414
+ throw new InvariantError(finalized.code, finalized.message, finalized.guarantee || "Zenith Invariant Violation", filePath, finalized.line || 1, finalized.column || 1, finalized.context, finalized.hints);
9415
+ }
9416
+ return {
9417
+ ir: finalized.ir,
9418
+ compiled: {
9419
+ html: finalized.html,
9420
+ bindings: finalized.bindings || [],
9421
+ scripts: finalized.js || null,
9422
+ styles: finalized.styles || []
9423
+ },
9424
+ finalized: {
9425
+ ...finalized,
9426
+ js: finalized.js,
9427
+ npmImports: finalized.npmImports,
9428
+ bundlePlan: finalized.bundlePlan
9429
+ }
9430
+ };
9431
+ }
9432
+
9433
+ // ../zenith-router/dist/manifest.js
9434
+ import fs4 from "fs";
9435
+ import path8 from "path";
9436
+
9437
+ // ../zenith-router/index.js
9438
+ import { createRequire as createRequire2 } from "module";
9439
+ var require2 = createRequire2(import.meta.url);
9440
+ var native2 = require2("./zenith-router.node");
9441
+
9442
+ // ../zenith-router/dist/manifest.js
9443
+ var SEGMENT_SCORES = {
9444
+ [0]: 10,
9445
+ [1]: 5,
9446
+ [2]: 1,
9447
+ [3]: 0
9448
+ };
9449
+ function discoverPages(pagesDir) {
9450
+ const pages = [];
9451
+ function walk(dir) {
9452
+ if (!fs4.existsSync(dir))
9453
+ return;
9454
+ const entries = fs4.readdirSync(dir, { withFileTypes: true });
9455
+ for (const entry of entries) {
9456
+ const fullPath = path8.join(dir, entry.name);
9457
+ if (entry.isDirectory()) {
9458
+ walk(fullPath);
9459
+ } else if (entry.isFile() && entry.name.endsWith(".zen")) {
9460
+ pages.push(fullPath);
9461
+ }
9462
+ }
9463
+ }
9464
+ walk(pagesDir);
9465
+ return pages;
9466
+ }
9467
+ function filePathToRoutePath(filePath, pagesDir) {
9468
+ const relativePath = path8.relative(pagesDir, filePath);
9469
+ const withoutExt = relativePath.replace(/\.zen$/, "");
9470
+ const segmentsList = withoutExt.split(path8.sep);
9471
+ const routeSegments = [];
9472
+ for (const segment of segmentsList) {
9473
+ if (segment === "index")
9474
+ continue;
9475
+ const optionalCatchAllMatch = segment.match(/^\[\[\.\.\.(\w+)\]\]$/);
9476
+ if (optionalCatchAllMatch) {
9477
+ routeSegments.push(`*${optionalCatchAllMatch[1]}?`);
9478
+ continue;
9479
+ }
9480
+ const catchAllMatch = segment.match(/^\[\.\.\.(\w+)\]$/);
9481
+ if (catchAllMatch) {
9482
+ routeSegments.push(`*${catchAllMatch[1]}`);
9483
+ continue;
9484
+ }
9485
+ const dynamicMatch = segment.match(/^\[(\w+)\]$/);
9486
+ if (dynamicMatch) {
9487
+ routeSegments.push(`:${dynamicMatch[1]}`);
9488
+ continue;
9489
+ }
9490
+ routeSegments.push(segment);
9491
+ }
9492
+ const routePath = "/" + routeSegments.join("/");
9493
+ return routePath === "/" ? "/" : routePath.replace(/\/$/, "");
9494
+ }
9495
+ function parseRouteSegments(routePath) {
9496
+ if (routePath === "/")
9497
+ return [];
9498
+ const segmentsList = routePath.slice(1).split("/");
9499
+ const parsed = [];
9500
+ for (const segment of segmentsList) {
9501
+ if (segment.startsWith("*") && segment.endsWith("?")) {
9502
+ parsed.push({ segmentType: 3, paramName: segment.slice(1, -1), raw: segment });
9503
+ continue;
9504
+ }
9505
+ if (segment.startsWith("*")) {
9506
+ parsed.push({ segmentType: 2, paramName: segment.slice(1), raw: segment });
9507
+ continue;
9508
+ }
9509
+ if (segment.startsWith(":")) {
9510
+ parsed.push({ segmentType: 1, paramName: segment.slice(1), raw: segment });
9511
+ continue;
9512
+ }
9513
+ parsed.push({ segmentType: 0, raw: segment });
9514
+ }
9515
+ return parsed;
9516
+ }
9517
+ function calculateRouteScore(segments) {
9518
+ if (segments.length === 0)
9519
+ return 100;
9520
+ let score = 0;
9521
+ for (const segment of segments) {
9522
+ score += SEGMENT_SCORES[segment.segmentType];
9523
+ }
9524
+ const staticCount = segments.filter((s2) => s2.segmentType === 0).length;
9525
+ score += staticCount * 2;
9526
+ return score;
9527
+ }
9528
+ function extractParamNames(segments) {
9529
+ return segments.filter((s2) => s2.paramName !== undefined).map((s2) => s2.paramName);
9530
+ }
9531
+ function routePathToRegex(routePath) {
9532
+ if (routePath === "/")
9533
+ return /^\/$/;
9534
+ const segmentsList = routePath.slice(1).split("/");
9535
+ const regexParts = [];
9536
+ for (let i2 = 0;i2 < segmentsList.length; i2++) {
9537
+ const segment = segmentsList[i2];
9538
+ if (!segment)
9539
+ continue;
9540
+ if (segment.startsWith("*") && segment.endsWith("?")) {
9541
+ regexParts.push("(?:\\/(.*))?");
9542
+ continue;
9543
+ }
9544
+ if (segment.startsWith("*")) {
9545
+ regexParts.push("\\/(.+)");
9546
+ continue;
9547
+ }
9548
+ if (segment.startsWith(":")) {
9549
+ regexParts.push("\\/([^/]+)");
9550
+ continue;
9551
+ }
9552
+ const escaped = segment.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
9553
+ regexParts.push(`\\/${escaped}`);
9554
+ }
9555
+ return new RegExp(`^${regexParts.join("")}\\/?$`);
9556
+ }
9557
+ function generateRouteDefinition(filePath, pagesDir) {
9558
+ const routePath = filePathToRoutePath(filePath, pagesDir);
9559
+ const segments = parseRouteSegments(routePath);
9560
+ const paramNames = extractParamNames(segments);
9561
+ const score = calculateRouteScore(segments);
9562
+ return {
9563
+ path: routePath,
9564
+ paramNames,
9565
+ score,
9566
+ filePath,
9567
+ regex: routePathToRegex(routePath)
9568
+ };
9569
+ }
9570
+ // src/discovery/layouts.ts
9571
+ import * as fs5 from "fs";
9572
+ import * as path9 from "path";
9573
+ function discoverLayouts2(layoutsDir) {
9574
+ const layouts2 = new Map;
9575
+ if (!fs5.existsSync(layoutsDir))
9576
+ return layouts2;
9577
+ const files = fs5.readdirSync(layoutsDir);
9578
+ for (const file of files) {
9579
+ if (file.endsWith(".zen")) {
9580
+ const fullPath = path9.join(layoutsDir, file);
9581
+ const name = path9.basename(file, ".zen");
9582
+ try {
9583
+ const ir = parseZenFile(fullPath, undefined, { mode: "metadata" });
9584
+ layouts2.set(name, {
9585
+ name,
9586
+ filePath: fullPath,
9587
+ props: ir.props || [],
9588
+ states: new Map,
9589
+ html: ir.template.raw,
9590
+ scripts: ir.script ? [ir.script.content] : [],
9591
+ styles: ir.styles?.map((s2) => s2.raw) || []
9592
+ });
9593
+ } catch (e3) {
9594
+ console.error(`[Zenith Layout Discovery] Failed to parse layout ${file}:`, e3);
9595
+ }
9596
+ }
9597
+ }
9598
+ return layouts2;
9599
+ }
9600
+
9601
+ // src/discovery/componentDiscovery.ts
9602
+ import * as fs6 from "fs";
9603
+ import * as path10 from "path";
9604
+ function discoverComponents2(baseDir) {
9605
+ const components = new Map;
9606
+ if (!fs6.existsSync(baseDir))
9607
+ return components;
9608
+ const walk = (dir) => {
9609
+ const files = fs6.readdirSync(dir);
9610
+ for (const file of files) {
9611
+ const fullPath = path10.join(dir, file);
9612
+ if (fs6.statSync(fullPath).isDirectory()) {
9613
+ walk(fullPath);
9614
+ } else if (file.endsWith(".zen")) {
9615
+ const name = path10.basename(file, ".zen");
9616
+ try {
9617
+ const ir = parseZenFile(fullPath, undefined, { mode: "metadata" });
9618
+ components.set(name, {
9619
+ name,
9620
+ path: fullPath,
9621
+ template: ir.template.raw,
9622
+ nodes: ir.template.nodes,
9623
+ expressions: ir.template.expressions,
9624
+ slots: [],
9625
+ props: ir.props || [],
9626
+ states: ir.script?.states || {},
9627
+ styles: ir.styles?.map((s2) => s2.raw) || [],
9628
+ script: ir.script?.raw || null,
9629
+ scriptAttributes: ir.script?.attributes || null,
9630
+ hasScript: !!ir.script,
9631
+ hasStyles: ir.styles?.length > 0
9632
+ });
9633
+ } catch (e3) {
9634
+ console.error(`[Zenith Discovery] Failed to parse component ${file}:`, e3);
9635
+ }
9636
+ }
9637
+ }
9638
+ };
9639
+ walk(baseDir);
9640
+ return components;
9641
+ }
9647
9642
 
9648
9643
  // src/commands/dev.ts
9649
9644
  var pageCache = new Map;
@@ -9709,10 +9704,10 @@ async function dev(options = {}) {
9709
9704
  try {
9710
9705
  const layoutsDir = path11.join(pagesDir, "../layouts");
9711
9706
  const componentsDir = path11.join(pagesDir, "../components");
9712
- const layouts = discoverLayouts(layoutsDir);
9713
- const components = new Map([...layouts]);
9707
+ const layouts2 = discoverLayouts2(layoutsDir);
9708
+ const components = new Map([...layouts2]);
9714
9709
  if (fs7.existsSync(componentsDir)) {
9715
- const discovered = discoverComponents(componentsDir);
9710
+ const discovered = discoverComponents2(componentsDir);
9716
9711
  for (const [k2, v2] of discovered) {
9717
9712
  components.set(k2, v2);
9718
9713
  }
@@ -9968,12 +9963,12 @@ async function compilePage(pagePath, pagesDir, baseDir = process.cwd()) {
9968
9963
  const layoutsDir = path.join(srcDir, "layouts");
9969
9964
  const components = new Map;
9970
9965
  if (fs8.existsSync(componentsDir)) {
9971
- const comps = discoverComponents(componentsDir);
9966
+ const comps = discoverComponents2(componentsDir);
9972
9967
  for (const [k2, v2] of comps)
9973
9968
  components.set(k2, v2);
9974
9969
  }
9975
9970
  if (fs8.existsSync(layoutsDir)) {
9976
- const layoutComps = discoverComponents(layoutsDir);
9971
+ const layoutComps = discoverComponents2(layoutsDir);
9977
9972
  for (const [k2, v2] of layoutComps) {
9978
9973
  if (k2[0] === k2[0]?.toUpperCase()) {
9979
9974
  components.set(k2, v2);