@blinkk/root 3.0.5 → 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(
@@ -785,12 +815,7 @@ 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
- }
818
+ const html = await transformHtml(data.html || "", rootConfig);
794
819
  await writeFile(outPath, normalizeLineEndings(html));
795
820
  printFileOutput(fileSize(outPath), "dist/html/", outFilePath);
796
821
  } catch (e) {
@@ -2444,7 +2469,8 @@ function printPushResult(result, rootDir, manifestFilePath) {
2444
2469
  console.log();
2445
2470
  }
2446
2471
  async function ensureRootGitignored(rootDir) {
2447
- const gitignore = path10.join(rootDir, ".gitignore");
2472
+ const gitRoot = await gitToplevel(rootDir) ?? rootDir;
2473
+ const gitignore = path10.join(gitRoot, ".gitignore");
2448
2474
  let content = "";
2449
2475
  try {
2450
2476
  content = await fs8.promises.readFile(gitignore, "utf8");
@@ -2467,6 +2493,27 @@ async function warnIfEnvNotIgnored(rootDir) {
2467
2493
  );
2468
2494
  }
2469
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
+ }
2470
2517
  function isPathGitIgnored(rootDir, relPath) {
2471
2518
  return new Promise((resolve) => {
2472
2519
  try {
@@ -3532,4 +3579,4 @@ export {
3532
3579
  createProdServer,
3533
3580
  CliRunner
3534
3581
  };
3535
- //# sourceMappingURL=chunk-VQPDCDKL.js.map
3582
+ //# sourceMappingURL=chunk-3EFECH2D.js.map