@blinkk/root 3.0.4 → 3.0.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.
@@ -1,10 +1,9 @@
1
1
  import {
2
2
  RouteTrie,
3
- htmlMinify,
4
- htmlPretty,
5
3
  isValidTagName,
6
- parseTagNames
7
- } from "./chunk-6P3B7ZXL.js";
4
+ parseTagNames,
5
+ transformHtml
6
+ } from "./chunk-7HK6F5RQ.js";
8
7
  import {
9
8
  headersMiddleware,
10
9
  rootProjectMiddleware,
@@ -267,7 +266,7 @@ var BuildAssetMap = class _BuildAssetMap {
267
266
  }
268
267
  return result;
269
268
  }
270
- static fromViteManifest(rootConfig, clientManifest, elementsGraph) {
269
+ static fromViteManifest(rootConfig, clientManifest, elementsGraph, podRoutes = []) {
271
270
  const assetMap = new _BuildAssetMap(rootConfig);
272
271
  const elementFiles = /* @__PURE__ */ new Set();
273
272
  Object.values(elementsGraph.sourceFiles).forEach((elementSource) => {
@@ -294,6 +293,30 @@ var BuildAssetMap = class _BuildAssetMap {
294
293
  };
295
294
  assetMap.add(new BuildAsset(assetMap, assetData));
296
295
  });
296
+ podRoutes.forEach((podRoute) => {
297
+ if (assetMap.srcToAsset.has(podRoute.src)) {
298
+ return;
299
+ }
300
+ const relPath = path2.relative(rootConfig.rootDir, podRoute.filePath).replace(/\\/g, "/");
301
+ const realPath = realPathRelativeTo(rootConfig.rootDir, relPath).replace(
302
+ /\\/g,
303
+ "/"
304
+ );
305
+ const candidateKeys = [relPath, realPath];
306
+ for (const key of candidateKeys) {
307
+ const asset = assetMap.srcToAsset.get(key);
308
+ if (asset) {
309
+ assetMap.add(
310
+ new BuildAsset(assetMap, {
311
+ ...asset.toJson(),
312
+ src: podRoute.src,
313
+ assetUrl: ""
314
+ })
315
+ );
316
+ break;
317
+ }
318
+ }
319
+ });
297
320
  return assetMap;
298
321
  }
299
322
  static fromRootManifest(rootConfig, rootManifest) {
@@ -634,10 +657,17 @@ async function build(rootProjectDir, options) {
634
657
  clientManifest[manifestKey] = asset;
635
658
  }
636
659
  });
660
+ const podRoutes = pods.flatMap(
661
+ (pod) => pod.routeFiles.map((route) => ({
662
+ src: `pod/${pod.name}/${route.relPath}`,
663
+ filePath: route.filePath
664
+ }))
665
+ );
637
666
  const assetMap = BuildAssetMap.fromViteManifest(
638
667
  rootConfig,
639
668
  clientManifest,
640
- elementGraph
669
+ elementGraph,
670
+ podRoutes
641
671
  );
642
672
  const rootManifest = assetMap.toJson();
643
673
  await writeFile(
@@ -753,7 +783,7 @@ async function build(rootProjectDir, options) {
753
783
  const outFilePath2 = urlPath.slice(1);
754
784
  const outPath2 = path3.join(buildDir, outFilePath2);
755
785
  await makeDir(path3.dirname(outPath2));
756
- await writeFile(outPath2, body);
786
+ await writeFile(outPath2, normalizeLineEndings(body));
757
787
  printFileOutput(fileSize(outPath2), "dist/html/", outFilePath2);
758
788
  return;
759
789
  }
@@ -785,13 +815,8 @@ async function build(rootProjectDir, options) {
785
815
  });
786
816
  }
787
817
  }
788
- let html = data.html || "";
789
- if (rootConfig.prettyHtml) {
790
- html = await htmlPretty(html, rootConfig.prettyHtmlOptions);
791
- } else if (rootConfig.minifyHtml) {
792
- html = await htmlMinify(html, rootConfig.minifyHtmlOptions);
793
- }
794
- await writeFile(outPath, html);
818
+ const html = await transformHtml(data.html || "", rootConfig);
819
+ await writeFile(outPath, normalizeLineEndings(html));
795
820
  printFileOutput(fileSize(outPath), "dist/html/", outFilePath);
796
821
  } catch (e) {
797
822
  logBuildError(
@@ -892,6 +917,9 @@ function formatParams(params) {
892
917
  return ` ${key}: ${value}`;
893
918
  }).join("\n");
894
919
  }
920
+ function normalizeLineEndings(str) {
921
+ return str.replace(/\r\n?/g, "\n");
922
+ }
895
923
 
896
924
  // src/cli/codegen.ts
897
925
  import { promises as fs3 } from "node:fs";
@@ -2441,7 +2469,8 @@ function printPushResult(result, rootDir, manifestFilePath) {
2441
2469
  console.log();
2442
2470
  }
2443
2471
  async function ensureRootGitignored(rootDir) {
2444
- const gitignore = path10.join(rootDir, ".gitignore");
2472
+ const gitRoot = await gitToplevel(rootDir) ?? rootDir;
2473
+ const gitignore = path10.join(gitRoot, ".gitignore");
2445
2474
  let content = "";
2446
2475
  try {
2447
2476
  content = await fs8.promises.readFile(gitignore, "utf8");
@@ -2464,6 +2493,27 @@ async function warnIfEnvNotIgnored(rootDir) {
2464
2493
  );
2465
2494
  }
2466
2495
  }
2496
+ function gitToplevel(rootDir) {
2497
+ return new Promise((resolve) => {
2498
+ try {
2499
+ const child = spawn3("git", ["rev-parse", "--show-toplevel"], {
2500
+ cwd: rootDir
2501
+ });
2502
+ let stdout = "";
2503
+ child.stdout.setEncoding("utf8");
2504
+ child.stdout.on("data", (chunk) => {
2505
+ stdout += chunk;
2506
+ });
2507
+ child.on("error", () => resolve(void 0));
2508
+ child.on("close", (code) => {
2509
+ const toplevel = stdout.trim();
2510
+ resolve(code === 0 && toplevel ? toplevel : void 0);
2511
+ });
2512
+ } catch {
2513
+ resolve(void 0);
2514
+ }
2515
+ });
2516
+ }
2467
2517
  function isPathGitIgnored(rootDir, relPath) {
2468
2518
  return new Promise((resolve) => {
2469
2519
  try {
@@ -3529,4 +3579,4 @@ export {
3529
3579
  createProdServer,
3530
3580
  CliRunner
3531
3581
  };
3532
- //# sourceMappingURL=chunk-URG2INLL.js.map
3582
+ //# sourceMappingURL=chunk-3EFECH2D.js.map