@constela/start 1.8.1 → 1.8.3

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.
@@ -768,7 +768,7 @@ async function mdxContentToNode(content, options) {
768
768
 
769
769
  // src/data/loader.ts
770
770
  import { existsSync as existsSync3, readFileSync } from "fs";
771
- import { basename, extname as extname2, join as join3 } from "path";
771
+ import { basename, dirname, extname as extname2, join as join3 } from "path";
772
772
  import fg2 from "fast-glob";
773
773
  var mdxContentToNode2 = mdxContentToNode;
774
774
  function resolveJsonRefs(json) {
@@ -953,7 +953,19 @@ async function transformMdx(content, file, options) {
953
953
  options?.components ? { components: options.components } : void 0
954
954
  );
955
955
  const fmSlug = frontmatter["slug"];
956
- const slug = typeof fmSlug === "string" ? fmSlug : basename(file, extname2(file));
956
+ let slug;
957
+ if (typeof fmSlug === "string") {
958
+ slug = fmSlug;
959
+ } else {
960
+ const filename = basename(file, extname2(file));
961
+ if (filename === "index") {
962
+ const dir = dirname(file);
963
+ slug = dir === "." ? "index" : basename(dir);
964
+ } else {
965
+ const dir = dirname(file);
966
+ slug = dir === "." ? filename : `${dir}/${filename}`;
967
+ }
968
+ }
957
969
  return {
958
970
  file,
959
971
  raw: content,
@@ -1424,7 +1436,7 @@ function createAdapter(options) {
1424
1436
 
1425
1437
  // src/layout/resolver.ts
1426
1438
  import { existsSync as existsSync5, statSync as statSync3, readFileSync as readFileSync3 } from "fs";
1427
- import { join as join5, basename as basename2, dirname } from "path";
1439
+ import { join as join5, basename as basename2, dirname as dirname2 } from "path";
1428
1440
  import fg3 from "fast-glob";
1429
1441
  import { isLayoutProgram } from "@constela/core";
1430
1442
 
@@ -1506,7 +1518,7 @@ async function loadLayout(layoutFile) {
1506
1518
  const parsed = JSON.parse(content);
1507
1519
  const importsValue = parsed["imports"];
1508
1520
  if (importsValue && typeof importsValue === "object" && Object.keys(importsValue).length > 0) {
1509
- const layoutDir = dirname(layoutFile);
1521
+ const layoutDir = dirname2(layoutFile);
1510
1522
  const resolvedImports = await resolveImports(
1511
1523
  layoutDir,
1512
1524
  importsValue
@@ -1622,7 +1634,7 @@ import { isCookieInitialExpr as isCookieInitialExpr2, ConstelaError } from "@con
1622
1634
 
1623
1635
  // src/json-page-loader.ts
1624
1636
  import { existsSync as existsSync6, readFileSync as readFileSync4 } from "fs";
1625
- import { dirname as dirname2, join as join6, relative, resolve as resolve3 } from "path";
1637
+ import { dirname as dirname3, join as join6, relative, resolve as resolve3 } from "path";
1626
1638
  function validateVersion(version) {
1627
1639
  if (version !== "1.0") {
1628
1640
  throw new Error(`Unsupported version: ${version}. Only version "1.0" is supported.`);
@@ -1776,7 +1788,7 @@ async function loadJsonPage(baseDir, pagePath, options) {
1776
1788
  throw new Error(`Missing required field "view" in page: ${filePath}`);
1777
1789
  }
1778
1790
  validateVersion(page.version);
1779
- const pageDir = dirname2(filePath);
1791
+ const pageDir = dirname3(filePath);
1780
1792
  const resolvedImports = await resolveImports(pageDir, page.imports, baseDir);
1781
1793
  const patternBaseDir = pageDir;
1782
1794
  const normalizedData = normalizeDataSourcePatterns(baseDir, patternBaseDir, page.data);
@@ -2851,7 +2863,7 @@ async function resolveConfig(fileConfig, cliOptions) {
2851
2863
  // src/build/index.ts
2852
2864
  import { existsSync as existsSync9, readFileSync as readFileSync6 } from "fs";
2853
2865
  import { mkdir as mkdir2, writeFile, cp, readdir } from "fs/promises";
2854
- import { join as join11, dirname as dirname5, relative as relative5, basename as basename4, isAbsolute as isAbsolute3, resolve as resolve4 } from "path";
2866
+ import { join as join11, dirname as dirname6, relative as relative5, basename as basename4, isAbsolute as isAbsolute3, resolve as resolve4 } from "path";
2855
2867
  import { isCookieInitialExpr as isCookieInitialExpr3 } from "@constela/core";
2856
2868
 
2857
2869
  // src/build/bundler.ts
@@ -2859,15 +2871,15 @@ import * as esbuild from "esbuild";
2859
2871
  import { existsSync as existsSync8 } from "fs";
2860
2872
  import { mkdir, readFile } from "fs/promises";
2861
2873
  import { createRequire } from "module";
2862
- import { join as join10, dirname as dirname4, isAbsolute as isAbsolute2, relative as relative4 } from "path";
2874
+ import { join as join10, dirname as dirname5, isAbsolute as isAbsolute2, relative as relative4 } from "path";
2863
2875
  import { fileURLToPath } from "url";
2864
- var __dirname = dirname4(fileURLToPath(import.meta.url));
2876
+ var __dirname = dirname5(fileURLToPath(import.meta.url));
2865
2877
  async function bundleRuntime(options) {
2866
2878
  const entryContent = `
2867
2879
  export { hydrateApp, createApp } from '@constela/runtime';
2868
2880
  `;
2869
2881
  const outFile = join10(options.outDir, "_constela", "runtime.js");
2870
- await mkdir(dirname4(outFile), { recursive: true });
2882
+ await mkdir(dirname5(outFile), { recursive: true });
2871
2883
  try {
2872
2884
  await esbuild.build({
2873
2885
  stdin: {
@@ -2893,7 +2905,7 @@ async function bundleCSS(options) {
2893
2905
  const cssFiles = Array.isArray(options.css) ? options.css : [options.css];
2894
2906
  const outFile = join10(options.outDir, "_constela", "styles.css");
2895
2907
  const shouldMinify = options.minify ?? true;
2896
- await mkdir(dirname4(outFile), { recursive: true });
2908
+ await mkdir(dirname5(outFile), { recursive: true });
2897
2909
  const resolvedCssFiles = cssFiles.map((f) => isAbsolute2(f) ? f : join10(process.cwd(), f));
2898
2910
  for (const fullPath of resolvedCssFiles) {
2899
2911
  if (!existsSync8(fullPath)) {
@@ -2932,10 +2944,10 @@ async function bundleCSS(options) {
2932
2944
  );
2933
2945
  }
2934
2946
  }
2935
- const sourceDir = dirname4(firstCssFile);
2947
+ const sourceDir = dirname5(firstCssFile);
2936
2948
  const sourceDirectives = options.content.map((contentPath) => {
2937
2949
  const absolutePath = isAbsolute2(contentPath) ? contentPath : join10(process.cwd(), contentPath);
2938
- const srcPath = absolutePath.includes("*") ? dirname4(absolutePath.split("*")[0] ?? absolutePath) : absolutePath;
2950
+ const srcPath = absolutePath.includes("*") ? dirname5(absolutePath.split("*")[0] ?? absolutePath) : absolutePath;
2939
2951
  const relativePath = relative4(sourceDir, srcPath);
2940
2952
  return `@source "${relativePath}";`;
2941
2953
  }).join("\n");
@@ -3033,7 +3045,7 @@ function paramsToOutputPath(basePattern, params, outDir) {
3033
3045
  return join11(outDir, relativePath, "index.html");
3034
3046
  }
3035
3047
  async function loadGetStaticPaths(pageFile) {
3036
- const dir = dirname5(pageFile);
3048
+ const dir = dirname6(pageFile);
3037
3049
  const baseName = basename4(pageFile, ".json");
3038
3050
  const pathsFile = join11(dir, `${baseName}.paths.ts`);
3039
3051
  if (!existsSync9(pathsFile)) {
@@ -3084,7 +3096,7 @@ async function loadLayout2(layoutName, layoutsDir) {
3084
3096
  const content = readFileSync6(layoutPath, "utf-8");
3085
3097
  const parsed = JSON.parse(content);
3086
3098
  if (parsed.imports && Object.keys(parsed.imports).length > 0) {
3087
- const layoutDir = dirname5(layoutPath);
3099
+ const layoutDir = dirname6(layoutPath);
3088
3100
  const resolvedImports = await resolveImports(layoutDir, parsed.imports);
3089
3101
  return { ...parsed, importData: resolvedImports };
3090
3102
  }
@@ -3489,7 +3501,7 @@ async function copyDirRecursive(srcDir, destDir, skipFiles) {
3489
3501
  if (skipFiles.has(destPath)) {
3490
3502
  continue;
3491
3503
  }
3492
- await mkdir2(dirname5(destPath), { recursive: true });
3504
+ await mkdir2(dirname6(destPath), { recursive: true });
3493
3505
  await cp(srcPath, destPath);
3494
3506
  }
3495
3507
  }
@@ -3549,7 +3561,7 @@ async function build2(options) {
3549
3561
  });
3550
3562
  }
3551
3563
  const absoluteRoutesDir = isAbsolute3(routesDir) ? routesDir : resolve4(routesDir);
3552
- const projectRoot = dirname5(dirname5(absoluteRoutesDir));
3564
+ const projectRoot = dirname6(dirname6(absoluteRoutesDir));
3553
3565
  const config = await loadConfig(projectRoot);
3554
3566
  const seoLang = options?.seo?.lang ?? config.seo?.lang;
3555
3567
  for (const route of jsonPages) {
@@ -3604,14 +3616,14 @@ async function build2(options) {
3604
3616
  }
3605
3617
  const program = await convertToCompiledProgram(processedPageInfo);
3606
3618
  const html = await renderPageToHtml(program, params, routePath, runtimePath, cssPath, processedPageInfo.page.externalImports, processedPageInfo.widgets, seoLang);
3607
- await mkdir2(dirname5(outputPath), { recursive: true });
3619
+ await mkdir2(dirname6(outputPath), { recursive: true });
3608
3620
  await writeFile(outputPath, html, "utf-8");
3609
3621
  generatedFiles.push(outputPath);
3610
3622
  const slugValue = params["slug"];
3611
3623
  if (slugValue && (slugValue === "index" || slugValue.endsWith("/index"))) {
3612
- const parentOutputPath = join11(dirname5(dirname5(outputPath)), "index.html");
3624
+ const parentOutputPath = join11(dirname6(dirname6(outputPath)), "index.html");
3613
3625
  if (!generatedFiles.includes(parentOutputPath)) {
3614
- await mkdir2(dirname5(parentOutputPath), { recursive: true });
3626
+ await mkdir2(dirname6(parentOutputPath), { recursive: true });
3615
3627
  await writeFile(parentOutputPath, html, "utf-8");
3616
3628
  generatedFiles.push(parentOutputPath);
3617
3629
  }
@@ -3638,7 +3650,7 @@ async function build2(options) {
3638
3650
  }
3639
3651
  const program = await convertToCompiledProgram(pageInfo);
3640
3652
  const html = await renderPageToHtml(program, {}, routePath, runtimePath, cssPath, pageInfo.page.externalImports, pageInfo.widgets, seoLang);
3641
- await mkdir2(dirname5(outputPath), { recursive: true });
3653
+ await mkdir2(dirname6(outputPath), { recursive: true });
3642
3654
  await writeFile(outputPath, html, "utf-8");
3643
3655
  generatedFiles.push(outputPath);
3644
3656
  }
package/dist/cli/index.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  hyperlink,
5
5
  loadConfig,
6
6
  resolveConfig
7
- } from "../chunk-FQH4I77H.js";
7
+ } from "../chunk-65BRCBTK.js";
8
8
  import "../chunk-3GFRJEKD.js";
9
9
 
10
10
  // src/cli/index.ts
package/dist/index.js CHANGED
@@ -28,7 +28,7 @@ import {
28
28
  transformCsv,
29
29
  transformMdx,
30
30
  transformYaml
31
- } from "./chunk-FQH4I77H.js";
31
+ } from "./chunk-65BRCBTK.js";
32
32
  import {
33
33
  evaluateMetaExpression,
34
34
  generateHydrationScript,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constela/start",
3
- "version": "1.8.1",
3
+ "version": "1.8.3",
4
4
  "description": "Meta-framework for Constela applications",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -46,8 +46,8 @@
46
46
  "ws": "^8.18.0",
47
47
  "@constela/compiler": "0.12.0",
48
48
  "@constela/core": "0.13.0",
49
- "@constela/server": "9.0.0",
50
49
  "@constela/router": "15.0.0",
50
+ "@constela/server": "9.0.0",
51
51
  "@constela/runtime": "0.16.5"
52
52
  },
53
53
  "devDependencies": {