@constela/start 1.2.7 → 1.2.8

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.
@@ -1523,7 +1523,7 @@ async function loadJsonPage(baseDir, pagePath, options) {
1523
1523
  validateVersion(page.version);
1524
1524
  const pageDir = dirname2(filePath);
1525
1525
  const resolvedImports = await resolveImports(pageDir, page.imports, baseDir);
1526
- const patternBaseDir = options?.routesDir ?? pageDir;
1526
+ const patternBaseDir = pageDir;
1527
1527
  const normalizedData = normalizeDataSourcePatterns(baseDir, patternBaseDir, page.data);
1528
1528
  const loadedData = await loadPageData(baseDir, normalizedData, { imports: resolvedImports });
1529
1529
  const widgets = await loadWidgets(pageDir, page.widgets, baseDir);
@@ -2414,6 +2414,76 @@ function normalizeViewNode(node) {
2414
2414
  }
2415
2415
  return nodeObj;
2416
2416
  }
2417
+ function substituteLayoutParamsInExpr(expr, layoutParams) {
2418
+ if (!expr || typeof expr !== "object") {
2419
+ return expr;
2420
+ }
2421
+ const exprObj = expr;
2422
+ if (exprObj["expr"] === "param" && typeof exprObj["name"] === "string") {
2423
+ const paramName = exprObj["name"];
2424
+ const paramValue = layoutParams[paramName];
2425
+ if (paramValue !== void 0) {
2426
+ if (typeof exprObj["path"] === "string") {
2427
+ return {
2428
+ expr: "get",
2429
+ base: paramValue,
2430
+ path: exprObj["path"]
2431
+ };
2432
+ }
2433
+ return paramValue;
2434
+ }
2435
+ }
2436
+ const result = {};
2437
+ for (const [key, value] of Object.entries(exprObj)) {
2438
+ if (key === "expr") {
2439
+ result[key] = value;
2440
+ } else if (value && typeof value === "object") {
2441
+ if (Array.isArray(value)) {
2442
+ result[key] = value.map((item) => substituteLayoutParamsInExpr(item, layoutParams));
2443
+ } else {
2444
+ result[key] = substituteLayoutParamsInExpr(value, layoutParams);
2445
+ }
2446
+ } else {
2447
+ result[key] = value;
2448
+ }
2449
+ }
2450
+ return result;
2451
+ }
2452
+ function substituteLayoutParamsInNode(node, layoutParams) {
2453
+ if (!node || typeof node !== "object") {
2454
+ return node;
2455
+ }
2456
+ const nodeObj = node;
2457
+ const result = {};
2458
+ for (const [key, value] of Object.entries(nodeObj)) {
2459
+ if (key === "children" && Array.isArray(value)) {
2460
+ result[key] = value.map((child) => substituteLayoutParamsInNode(child, layoutParams));
2461
+ } else if (key === "props" && value && typeof value === "object") {
2462
+ const props = {};
2463
+ for (const [propKey, propValue] of Object.entries(value)) {
2464
+ props[propKey] = substituteLayoutParamsInExpr(propValue, layoutParams);
2465
+ }
2466
+ result[key] = props;
2467
+ } else if (key === "value" && value && typeof value === "object") {
2468
+ result[key] = substituteLayoutParamsInExpr(value, layoutParams);
2469
+ } else if (key === "items" && value && typeof value === "object") {
2470
+ result[key] = substituteLayoutParamsInExpr(value, layoutParams);
2471
+ } else if (key === "condition" && value && typeof value === "object") {
2472
+ result[key] = substituteLayoutParamsInExpr(value, layoutParams);
2473
+ } else if (key === "content" && value && typeof value === "object") {
2474
+ result[key] = substituteLayoutParamsInExpr(value, layoutParams);
2475
+ } else if (key === "then" && value && typeof value === "object") {
2476
+ result[key] = substituteLayoutParamsInNode(value, layoutParams);
2477
+ } else if (key === "else" && value && typeof value === "object") {
2478
+ result[key] = substituteLayoutParamsInNode(value, layoutParams);
2479
+ } else if (key === "body" && value && typeof value === "object") {
2480
+ result[key] = substituteLayoutParamsInNode(value, layoutParams);
2481
+ } else {
2482
+ result[key] = value;
2483
+ }
2484
+ }
2485
+ return result;
2486
+ }
2417
2487
  function replaceSlot(node, content) {
2418
2488
  if (!node || typeof node !== "object") {
2419
2489
  return node;
@@ -2437,7 +2507,11 @@ async function processLayouts(pageInfo, layoutsDir) {
2437
2507
  }
2438
2508
  const layout = await loadLayout2(layoutName, layoutsDir);
2439
2509
  const normalizedLayoutView = normalizeViewNode(structuredClone(layout.view));
2440
- const wrappedView = applyLayout(pageInfo.page.view, normalizedLayoutView);
2510
+ let wrappedView = applyLayout(pageInfo.page.view, normalizedLayoutView);
2511
+ const layoutParams = pageInfo.page.route?.layoutParams;
2512
+ if (layoutParams && Object.keys(layoutParams).length > 0) {
2513
+ wrappedView = substituteLayoutParamsInNode(wrappedView, layoutParams);
2514
+ }
2441
2515
  let updatedRoute;
2442
2516
  if (pageInfo.page.route) {
2443
2517
  const { layout: _layout, ...routeWithoutLayout } = pageInfo.page.route;
package/dist/cli/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  createDevServer,
4
4
  loadConfig,
5
5
  resolveConfig
6
- } from "../chunk-RA772QBZ.js";
6
+ } from "../chunk-ZJMQ6IJY.js";
7
7
  import "../chunk-PUTC5BCP.js";
8
8
 
9
9
  // src/cli/index.ts
package/dist/index.js CHANGED
@@ -23,7 +23,7 @@ import {
23
23
  transformCsv,
24
24
  transformMdx,
25
25
  transformYaml
26
- } from "./chunk-RA772QBZ.js";
26
+ } from "./chunk-ZJMQ6IJY.js";
27
27
  import {
28
28
  generateHydrationScript,
29
29
  renderPage,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constela/start",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "description": "Meta-framework for Constela applications",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -42,9 +42,9 @@
42
42
  "vite": "^6.0.0",
43
43
  "@constela/compiler": "0.7.0",
44
44
  "@constela/core": "0.7.0",
45
- "@constela/server": "3.0.1",
45
+ "@constela/router": "8.0.0",
46
46
  "@constela/runtime": "0.10.1",
47
- "@constela/router": "8.0.0"
47
+ "@constela/server": "3.0.1"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@types/mdast": "^4.0.4",