@constela/start 1.8.1 → 1.8.2

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