@constela/start 1.2.4 → 1.2.6

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.
@@ -1546,17 +1546,53 @@ async function loadPageData(baseDir, dataSources, context) {
1546
1546
  }
1547
1547
  return result;
1548
1548
  }
1549
- async function generateStaticPathsFromPage(pageConfig, loadedData) {
1549
+ function resolveSourceData(source, loadedData, resolvedImports) {
1550
+ if (typeof source === "string") {
1551
+ return loadedData[source];
1552
+ }
1553
+ if (source && typeof source === "object" && "expr" in source) {
1554
+ const expr = source;
1555
+ if (expr.expr === "import" && "name" in expr) {
1556
+ const importName = expr.name;
1557
+ const importPath = expr.path;
1558
+ const importData = resolvedImports?.[importName];
1559
+ if (importData === void 0) {
1560
+ throw new Error(`Import "${importName}" not found for getStaticPaths source`);
1561
+ }
1562
+ if (importPath) {
1563
+ const pathParts = importPath.split(".");
1564
+ let result = importData;
1565
+ for (const part of pathParts) {
1566
+ if (result && typeof result === "object" && part in result) {
1567
+ result = result[part];
1568
+ } else {
1569
+ throw new Error(`Path "${importPath}" not found in import "${importName}"`);
1570
+ }
1571
+ }
1572
+ return result;
1573
+ }
1574
+ return importData;
1575
+ }
1576
+ if (expr.expr === "var" && "name" in expr) {
1577
+ const varName = expr.name;
1578
+ return loadedData[varName];
1579
+ }
1580
+ }
1581
+ throw new Error(`Invalid getStaticPaths source: ${JSON.stringify(source)}`);
1582
+ }
1583
+ async function generateStaticPathsFromPage(pageConfig, loadedData, resolvedImports) {
1550
1584
  if (!pageConfig.getStaticPaths) {
1551
1585
  return [];
1552
1586
  }
1553
1587
  const { source, params } = pageConfig.getStaticPaths;
1554
- const sourceData = loadedData[source];
1588
+ const sourceData = resolveSourceData(source, loadedData, resolvedImports);
1555
1589
  if (sourceData === void 0) {
1556
- throw new Error(`Data source "${source}" not found for getStaticPaths`);
1590
+ const sourceStr = typeof source === "string" ? source : JSON.stringify(source);
1591
+ throw new Error(`Data source "${sourceStr}" not found for getStaticPaths`);
1557
1592
  }
1558
1593
  if (!Array.isArray(sourceData)) {
1559
- throw new Error(`Data source "${source}" must be an array for getStaticPaths`);
1594
+ const sourceStr = typeof source === "string" ? source : JSON.stringify(source);
1595
+ throw new Error(`Data source "${sourceStr}" must be an array for getStaticPaths`);
1560
1596
  }
1561
1597
  const paths = [];
1562
1598
  for (const item of sourceData) {
@@ -1856,7 +1892,7 @@ var JsonPageLoader = class {
1856
1892
  */
1857
1893
  async getStaticPaths(pagePath) {
1858
1894
  const pageInfo = await this.loadPage(pagePath);
1859
- return generateStaticPathsFromPage(pageInfo.page, pageInfo.loadedData);
1895
+ return generateStaticPathsFromPage(pageInfo.page, pageInfo.loadedData, pageInfo.resolvedImports);
1860
1896
  }
1861
1897
  /**
1862
1898
  * Compile a page to CompiledProgram
@@ -2228,7 +2264,8 @@ async function bundleCSS(options) {
2228
2264
  bundle: true,
2229
2265
  outfile: outFile,
2230
2266
  minify: options.minify ?? true,
2231
- loader: { ".css": "css" }
2267
+ loader: { ".css": "css" },
2268
+ conditions: ["style"]
2232
2269
  });
2233
2270
  } else {
2234
2271
  const virtualEntry = resolvedCssFiles.map((f) => `@import "${f}";`).join("\n");
@@ -2240,7 +2277,8 @@ async function bundleCSS(options) {
2240
2277
  },
2241
2278
  bundle: true,
2242
2279
  outfile: outFile,
2243
- minify: options.minify ?? true
2280
+ minify: options.minify ?? true,
2281
+ conditions: ["style"]
2244
2282
  });
2245
2283
  }
2246
2284
  } catch (error) {
@@ -2537,7 +2575,8 @@ async function build2(options) {
2537
2575
  if (pageInfo.page.getStaticPaths) {
2538
2576
  staticPathsResult = await generateStaticPathsFromPage(
2539
2577
  pageInfo.page,
2540
- pageInfo.loadedData
2578
+ pageInfo.loadedData,
2579
+ pageInfo.resolvedImports
2541
2580
  );
2542
2581
  } else {
2543
2582
  const externalPaths = await loadGetStaticPaths(route.file);
package/dist/cli/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  createDevServer,
4
4
  loadConfig,
5
5
  resolveConfig
6
- } from "../chunk-MP2KUHWS.js";
6
+ } from "../chunk-RA772QBZ.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-MP2KUHWS.js";
26
+ } from "./chunk-RA772QBZ.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.4",
3
+ "version": "1.2.6",
4
4
  "description": "Meta-framework for Constela applications",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -41,10 +41,10 @@
41
41
  "unified": "^11.0.0",
42
42
  "vite": "^6.0.0",
43
43
  "@constela/compiler": "0.7.0",
44
- "@constela/core": "0.7.0",
45
- "@constela/runtime": "0.10.1",
46
44
  "@constela/router": "8.0.0",
47
- "@constela/server": "3.0.0"
45
+ "@constela/core": "0.7.0",
46
+ "@constela/server": "3.0.0",
47
+ "@constela/runtime": "0.10.1"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@types/mdast": "^4.0.4",