@riebeckite/honox 0.0.36 → 0.0.38

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.
package/dist/index.js CHANGED
@@ -295,8 +295,8 @@ function isMissingDirectoryError(error) {
295
295
  function isNotFoundError(error) {
296
296
  return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
297
297
  }
298
- function isAbsolutePath(path11) {
299
- return /^([a-z]:)?[\\/]/iu.test(path11);
298
+ function isAbsolutePath(path12) {
299
+ return /^([a-z]:)?[\\/]/iu.test(path12);
300
300
  }
301
301
  function resolveWithinDirectory(directory, relativePath, label) {
302
302
  if (!relativePath || relativePath.includes("\0") || isAbsolutePath(relativePath)) {
@@ -369,10 +369,10 @@ async function computeBundleFingerprint(root, configFile) {
369
369
  async function fingerprintDirectory(directory) {
370
370
  const inventory = await fingerprintOutputDirectory(directory);
371
371
  const hash = createHash("sha256");
372
- for (const [path11, checksum] of Object.entries(inventory).sort(
372
+ for (const [path12, checksum] of Object.entries(inventory).sort(
373
373
  ([left], [right]) => left.localeCompare(right)
374
374
  )) {
375
- hash.update(path11).update("\0").update(checksum).update("\0");
375
+ hash.update(path12).update("\0").update(checksum).update("\0");
376
376
  }
377
377
  return hash.digest("hex");
378
378
  }
@@ -414,7 +414,7 @@ async function fingerprintOutputDirectory(directory, relativeDirectory = "", met
414
414
  function inventoriesEqual(left, right) {
415
415
  const leftPaths = Object.keys(left);
416
416
  const rightPaths = Object.keys(right);
417
- return leftPaths.length === rightPaths.length && leftPaths.every((path11) => left[path11] === right[path11]);
417
+ return leftPaths.length === rightPaths.length && leftPaths.every((path12) => left[path12] === right[path12]);
418
418
  }
419
419
  async function collectAppFiles(directory, files) {
420
420
  const entries = await readdir(directory, { withFileTypes: true }).catch(
@@ -545,6 +545,7 @@ import {
545
545
  compareOutputPlan,
546
546
  createBuildOutputMarker,
547
547
  publicationFingerprint as fingerprintPublication,
548
+ isDeferredGeneratedOutput,
548
549
  publicationEntriesFromManifest,
549
550
  publicationOutputsFromManifest,
550
551
  publicationRedirectsFromManifest,
@@ -553,9 +554,31 @@ import {
553
554
 
554
555
  // src/content_assets.ts
555
556
  import fs5 from "node:fs/promises";
556
- import path6 from "node:path";
557
+ import path7 from "node:path";
557
558
  import { isImagePath, normalizeContentPath } from "@riebeckite/core";
558
559
  import { isIgnoredContentPath, isPathInsideDirectory } from "@riebeckite/node";
560
+
561
+ // src/content_module.ts
562
+ import path6 from "node:path";
563
+ function contentModuleEntry(appRoot) {
564
+ return path6.join(appRoot, "app", "server.ts");
565
+ }
566
+ function isContentModuleLoaded(server, appRoot) {
567
+ const entry = contentModuleEntry(appRoot);
568
+ const moduleGraph = server.environments?.ssr?.moduleGraph;
569
+ return Boolean(
570
+ moduleGraph?.getModuleById(entry) ?? [...moduleGraph?.idToModuleMap?.values() ?? []].find(
571
+ (module) => module.file && path6.resolve(module.file) === path6.resolve(entry)
572
+ )
573
+ );
574
+ }
575
+ async function loadContentModule(server, appRoot) {
576
+ return await server.ssrLoadModule(
577
+ contentModuleEntry(appRoot)
578
+ );
579
+ }
580
+
581
+ // src/content_assets.ts
559
582
  var IMAGE_CONTENT_TYPES = {
560
583
  png: "image/png",
561
584
  jpg: "image/jpeg",
@@ -572,14 +595,13 @@ function riebeckiteContentAssets(options) {
572
595
  enforce: "pre",
573
596
  configureServer(server) {
574
597
  const contentRoot = options.contentRoot();
575
- const entry = path6.join(options.appRoot(), "app", "server.ts");
576
598
  const base = server.config.base;
577
599
  const publicDir = server.config.publicDir;
578
600
  let cachedManifest;
579
601
  let cachedPaths = /* @__PURE__ */ new Set();
580
602
  const resolvePublicImagePaths = async () => {
581
- const module = await server.ssrLoadModule(entry);
582
- const manifest = await module.content?.getManifest();
603
+ const module = await loadContentModule(server, options.appRoot());
604
+ const manifest = await module.content?.getManifest?.();
583
605
  if (!manifest) return /* @__PURE__ */ new Set();
584
606
  if (manifest !== cachedManifest) {
585
607
  cachedManifest = manifest;
@@ -612,7 +634,7 @@ function riebeckiteContentAssets(options) {
612
634
  next();
613
635
  return;
614
636
  }
615
- const file = path6.join(contentRoot, logicalPath);
637
+ const file = path7.join(contentRoot, logicalPath);
616
638
  if (!isPathInsideDirectory(contentRoot, file)) {
617
639
  next();
618
640
  return;
@@ -659,16 +681,16 @@ function collectPublicImagePaths(manifest) {
659
681
  async function collectSiteOwnedOutputPaths(publicDir) {
660
682
  const paths = /* @__PURE__ */ new Set();
661
683
  if (!publicDir) return paths;
662
- const root = path6.resolve(publicDir);
684
+ const root = path7.resolve(publicDir);
663
685
  const walk = async (directory) => {
664
686
  const entries = await fs5.readdir(directory, { withFileTypes: true }).catch(() => void 0);
665
687
  if (!entries) return;
666
688
  for (const entry of entries) {
667
- const full = path6.join(directory, entry.name);
689
+ const full = path7.join(directory, entry.name);
668
690
  if (entry.isDirectory()) {
669
691
  await walk(full);
670
692
  } else {
671
- paths.add(path6.relative(root, full).replaceAll("\\", "/"));
693
+ paths.add(path7.relative(root, full).replaceAll("\\", "/"));
672
694
  }
673
695
  }
674
696
  };
@@ -703,7 +725,7 @@ function imageContentType(logicalPath) {
703
725
  }
704
726
  async function hasSiteOwnedFile(publicDir, logicalPath) {
705
727
  if (!publicDir) return false;
706
- const file = path6.join(publicDir, logicalPath);
728
+ const file = path7.join(publicDir, logicalPath);
707
729
  try {
708
730
  return (await fs5.stat(file)).isFile();
709
731
  } catch {
@@ -713,7 +735,9 @@ async function hasSiteOwnedFile(publicDir, logicalPath) {
713
735
 
714
736
  // src/ssg/artifact_writer.ts
715
737
  import { randomUUID } from "node:crypto";
738
+ import { constants } from "node:fs";
716
739
  import {
740
+ copyFile,
717
741
  cp,
718
742
  lstat,
719
743
  mkdir,
@@ -747,19 +771,26 @@ async function createBuildArtifactWriter(input) {
747
771
  ensureOpen(completed);
748
772
  await cp(source, stagingDirectory, { recursive: true });
749
773
  },
750
- async remove(path11) {
774
+ async remove(path12) {
751
775
  ensureOpen(completed);
752
- await rm(resolveArtifactPath(stagingDirectory, path11), {
776
+ await rm(resolveArtifactPath(stagingDirectory, path12), {
753
777
  force: true,
754
778
  recursive: true
755
779
  });
756
780
  },
757
- async write(path11, data) {
781
+ async write(path12, data) {
758
782
  ensureOpen(completed);
759
- const target = resolveArtifactPath(stagingDirectory, path11);
783
+ const target = resolveArtifactPath(stagingDirectory, path12);
760
784
  await mkdir(dirname2(target), { recursive: true });
761
785
  await writeFile(target, data);
762
786
  },
787
+ async copyFileFrom(source, path12) {
788
+ ensureOpen(completed);
789
+ const target = resolveArtifactPath(stagingDirectory, path12);
790
+ await mkdir(dirname2(target), { recursive: true });
791
+ await rm(target, { force: true });
792
+ await copyFile(source, target, constants.COPYFILE_FICLONE);
793
+ },
763
794
  async publish() {
764
795
  ensureOpen(completed);
765
796
  await publishDirectory(stagingDirectory, outputDirectory);
@@ -775,8 +806,8 @@ async function createBuildArtifactWriter(input) {
775
806
  function ensureOpen(completed) {
776
807
  if (completed) throw new Error("Build artifact writer is already closed.");
777
808
  }
778
- function resolveArtifactPath(directory, path11) {
779
- return resolveWithinDirectory(directory, path11, "Build artifact path");
809
+ function resolveArtifactPath(directory, path12) {
810
+ return resolveWithinDirectory(directory, path12, "Build artifact path");
780
811
  }
781
812
  async function publishDirectory(stagingDirectory, outputDirectory) {
782
813
  const backupDirectory = join2(
@@ -825,22 +856,22 @@ async function publishDirectory(stagingDirectory, outputDirectory) {
825
856
  function publicationJournalPath(outputDirectory) {
826
857
  return join2(dirname2(outputDirectory), ".riebeckite", "build-output.json");
827
858
  }
828
- async function writeJournal(path11, journal) {
829
- await mkdir(dirname2(path11), { recursive: true });
830
- await writeFile(path11, JSON.stringify(journal));
859
+ async function writeJournal(path12, journal) {
860
+ await mkdir(dirname2(path12), { recursive: true });
861
+ await writeFile(path12, JSON.stringify(journal));
831
862
  }
832
863
  async function recoverPendingPublication(outputDirectory) {
833
- const path11 = publicationJournalPath(outputDirectory);
864
+ const path12 = publicationJournalPath(outputDirectory);
834
865
  let journal;
835
866
  try {
836
- journal = JSON.parse(await readFile2(path11, "utf8"));
867
+ journal = JSON.parse(await readFile2(path12, "utf8"));
837
868
  } catch (error) {
838
869
  if (isNotFoundError2(error)) return;
839
- await rm(path11, { force: true });
870
+ await rm(path12, { force: true });
840
871
  return;
841
872
  }
842
873
  if (journal.outputDirectory !== outputDirectory || !isPublicationJournalState(journal.state)) {
843
- await rm(path11, { force: true });
874
+ await rm(path12, { force: true });
844
875
  return;
845
876
  }
846
877
  if (journal.state === "previous-output-moved" && !await isDirectory(outputDirectory) && await isDirectory(journal.backupDirectory)) {
@@ -848,14 +879,14 @@ async function recoverPendingPublication(outputDirectory) {
848
879
  }
849
880
  await rm(journal.backupDirectory, { force: true, recursive: true });
850
881
  await rm(journal.stagingDirectory, { force: true, recursive: true });
851
- await rm(path11, { force: true });
882
+ await rm(path12, { force: true });
852
883
  }
853
884
  function isPublicationJournalState(value) {
854
885
  return value === "staged" || value === "previous-output-moved" || value === "published";
855
886
  }
856
- async function isDirectory(path11) {
887
+ async function isDirectory(path12) {
857
888
  try {
858
- return (await lstat(path11)).isDirectory();
889
+ return (await lstat(path12)).isDirectory();
859
890
  } catch (error) {
860
891
  if (isNotFoundError2(error)) return false;
861
892
  throw error;
@@ -898,16 +929,16 @@ async function findOversizedAssets(directory, relativeDirectory = "") {
898
929
  );
899
930
  const nestedAssets = await Promise.all(
900
931
  entries.map(async (entry) => {
901
- const path11 = join3(directory, entry.name);
932
+ const path12 = join3(directory, entry.name);
902
933
  const relativePath = join3(relativeDirectory, entry.name).replaceAll(
903
934
  "\\",
904
935
  "/"
905
936
  );
906
937
  if (entry.isDirectory()) {
907
- return findOversizedAssets(path11, relativePath);
938
+ return findOversizedAssets(path12, relativePath);
908
939
  }
909
940
  if (!entry.isFile()) return [];
910
- const size = (await stat(path11)).size;
941
+ const size = (await stat(path12)).size;
911
942
  return size > CLOUDFLARE_WORKER_ASSET_LIMIT ? [{ path: relativePath, size }] : [];
912
943
  })
913
944
  );
@@ -1055,7 +1086,7 @@ function addClientAssetPath(paths, value) {
1055
1086
  }
1056
1087
  function addClientAssetPaths(paths, value) {
1057
1088
  if (!Array.isArray(value)) return;
1058
- for (const path11 of value) addClientAssetPath(paths, path11);
1089
+ for (const path12 of value) addClientAssetPath(paths, path12);
1059
1090
  }
1060
1091
  function resolveBuildArtifactPath(directory, relativePath) {
1061
1092
  return resolveWithinDirectory(
@@ -1098,6 +1129,7 @@ function logGeneratedHtmlAssetDiagnostics(logger, pages) {
1098
1129
  }
1099
1130
  }
1100
1131
  function inspectGeneratedHtmlPages(module, pages, log) {
1132
+ const diagnostics = [];
1101
1133
  const plugins = module.config?.plugins ?? [];
1102
1134
  for (const plugin of plugins) {
1103
1135
  const inspector = plugin.inspectGeneratedHtml;
@@ -1107,16 +1139,24 @@ function inspectGeneratedHtmlPages(module, pages, log) {
1107
1139
  const label = `[${plugin.name ?? "plugin"}] ${page.path}: ${diagnostic.message}`;
1108
1140
  if (diagnostic.severity === "info") log.info(label);
1109
1141
  else log.warn(label);
1142
+ diagnostics.push({
1143
+ code: diagnostic.code ?? "generated-html",
1144
+ severity: diagnostic.severity,
1145
+ message: diagnostic.message,
1146
+ pluginName: plugin.name,
1147
+ filePath: diagnostic.filePath ?? page.path
1148
+ });
1110
1149
  }
1111
1150
  }
1112
1151
  }
1152
+ return diagnostics;
1113
1153
  }
1114
1154
 
1115
1155
  // src/ssg/output_cache.ts
1116
1156
  import { createHash as createHash3, randomUUID as randomUUID3 } from "node:crypto";
1117
1157
  import { createReadStream } from "node:fs";
1118
1158
  import {
1119
- copyFile,
1159
+ copyFile as copyFile2,
1120
1160
  lstat as lstat2,
1121
1161
  mkdir as mkdir3,
1122
1162
  readdir as readdir3,
@@ -1216,13 +1256,13 @@ async function verifyNoChangeFastPath(input) {
1216
1256
  }
1217
1257
  return { used: true };
1218
1258
  }
1219
- async function loadOutputCacheMetadata(path11, timingsMs, log = () => {
1259
+ async function loadOutputCacheMetadata(path12, timingsMs, log = () => {
1220
1260
  }) {
1221
- if (!await isSafeOutputCacheDirectory(dirname4(path11))) {
1261
+ if (!await isSafeOutputCacheDirectory(dirname4(path12))) {
1222
1262
  log("SSG output cache directory is unsafe and will be ignored.");
1223
1263
  return void 0;
1224
1264
  }
1225
- if (!await isRegularFile(path11)) {
1265
+ if (!await isRegularFile(path12)) {
1226
1266
  return void 0;
1227
1267
  }
1228
1268
  let raw;
@@ -1230,7 +1270,7 @@ async function loadOutputCacheMetadata(path11, timingsMs, log = () => {
1230
1270
  raw = await measure(
1231
1271
  timingsMs,
1232
1272
  "outputCacheRead",
1233
- () => readFile4(path11, "utf8")
1273
+ () => readFile4(path12, "utf8")
1234
1274
  );
1235
1275
  } catch (error) {
1236
1276
  if (isNotFoundError(error)) return void 0;
@@ -1254,28 +1294,28 @@ async function loadOutputCacheMetadata(path11, timingsMs, log = () => {
1254
1294
  }
1255
1295
  return timingsMs ? { ...parsed, fileSizeBytes: Buffer.byteLength(raw) } : parsed;
1256
1296
  }
1257
- async function validateOutputCache(cache, path11, timingsMs, log = () => {
1297
+ async function validateOutputCache(cache, path12, timingsMs, log = () => {
1258
1298
  }) {
1259
1299
  const entriesAreValid = await measure(
1260
1300
  timingsMs,
1261
1301
  "outputCacheEntriesValidate",
1262
- () => validateOutputCacheEntries(path11, cache.outputs, timingsMs)
1302
+ () => validateOutputCacheEntries(path12, cache.outputs, timingsMs)
1263
1303
  );
1264
1304
  if (entriesAreValid) return true;
1265
1305
  log("SSG output cache entries are corrupted and will be rebuilt.");
1266
1306
  return false;
1267
1307
  }
1268
- async function saveOutputCache(path11, state, outputDirectory, timingsMs) {
1269
- const directory = dirname4(path11);
1308
+ async function saveOutputCache(path12, state, outputDirectory, timingsMs) {
1309
+ const directory = dirname4(path12);
1270
1310
  await mkdir3(directory, { recursive: true });
1271
1311
  if (!await isSafeOutputCacheDirectory(directory)) {
1272
1312
  throw new Error(`Unsafe SSG output cache directory: ${directory}`);
1273
1313
  }
1274
- if (!await isSafeCacheFileTarget(path11)) {
1275
- throw new Error(`Unsafe SSG output cache file: ${path11}`);
1314
+ if (!await isSafeCacheFileTarget(path12)) {
1315
+ throw new Error(`Unsafe SSG output cache file: ${path12}`);
1276
1316
  }
1277
- const entriesPath = outputCacheEntriesPath(path11);
1278
- const temporaryPath = `${path11}.${randomUUID3()}.tmp`;
1317
+ const entriesPath = outputCacheEntriesPath(path12);
1318
+ const temporaryPath = `${path12}.${randomUUID3()}.tmp`;
1279
1319
  try {
1280
1320
  const outputs = await measure(
1281
1321
  timingsMs,
@@ -1302,18 +1342,18 @@ async function saveOutputCache(path11, state, outputDirectory, timingsMs) {
1302
1342
  await measure(
1303
1343
  timingsMs,
1304
1344
  "outputCacheRename",
1305
- () => replaceFile(temporaryPath, path11)
1345
+ () => replaceFile(temporaryPath, path12)
1306
1346
  );
1307
1347
  const checksum = createHash3("sha256").update(serialized).digest("hex");
1308
1348
  if (state.finalOutputInventory && state.configFile) {
1309
1349
  await saveFastPathCache(
1310
- fastPathCachePath(path11),
1350
+ fastPathCachePath(path12),
1311
1351
  createFastPathCacheState(state, checksum),
1312
1352
  timingsMs
1313
1353
  );
1314
1354
  }
1315
1355
  await collectUnreferencedOutputCacheEntries(
1316
- outputCacheEntriesPath(path11),
1356
+ outputCacheEntriesPath(path12),
1317
1357
  outputs,
1318
1358
  timingsMs
1319
1359
  );
@@ -1390,15 +1430,15 @@ async function validateOutputCacheEntries(outputCachePath, entries, timingsMs) {
1390
1430
  valid = false;
1391
1431
  return;
1392
1432
  }
1393
- const path11 = resolveOutputCacheFile(directory, entry.cachePath);
1394
- if (!await isRegularFile(path11)) {
1433
+ const path12 = resolveOutputCacheFile(directory, entry.cachePath);
1434
+ if (!await isRegularFile(path12)) {
1395
1435
  valid = false;
1396
1436
  return;
1397
1437
  }
1398
1438
  if (await measure(
1399
1439
  timingsMs,
1400
1440
  "outputCacheEntryChecksum",
1401
- () => checksumFile(path11)
1441
+ () => checksumFile(path12)
1402
1442
  ) !== entry.checksum)
1403
1443
  valid = false;
1404
1444
  }
@@ -1437,16 +1477,16 @@ function createFastPathCacheState(state, outputCacheChecksum) {
1437
1477
  outputPaths: Object.keys(state.outputs).sort()
1438
1478
  };
1439
1479
  }
1440
- async function saveFastPathCache(path11, state, timingsMs) {
1441
- const directory = dirname4(path11);
1480
+ async function saveFastPathCache(path12, state, timingsMs) {
1481
+ const directory = dirname4(path12);
1442
1482
  await mkdir3(directory, { recursive: true });
1443
1483
  if (!await isSafeOutputCacheDirectory(directory)) {
1444
1484
  throw new Error(`Unsafe SSG fast-path cache directory: ${directory}`);
1445
1485
  }
1446
- if (!await isSafeCacheFileTarget(path11)) {
1447
- throw new Error(`Unsafe SSG fast-path cache file: ${path11}`);
1486
+ if (!await isSafeCacheFileTarget(path12)) {
1487
+ throw new Error(`Unsafe SSG fast-path cache file: ${path12}`);
1448
1488
  }
1449
- const temporaryPath = `${path11}.${randomUUID3()}.tmp`;
1489
+ const temporaryPath = `${path12}.${randomUUID3()}.tmp`;
1450
1490
  try {
1451
1491
  await measure(
1452
1492
  timingsMs,
@@ -1457,18 +1497,18 @@ async function saveFastPathCache(path11, state, timingsMs) {
1457
1497
  await measure(
1458
1498
  timingsMs,
1459
1499
  "sidecarRename",
1460
- () => replaceFile(temporaryPath, path11)
1500
+ () => replaceFile(temporaryPath, path12)
1461
1501
  );
1462
1502
  } catch (error) {
1463
1503
  await rm3(temporaryPath, { force: true }).catch(() => void 0);
1464
1504
  throw error;
1465
1505
  }
1466
1506
  }
1467
- async function loadFastPathCache(path11) {
1507
+ async function loadFastPathCache(path12) {
1468
1508
  try {
1469
- if (!await isSafeOutputCacheDirectory(dirname4(path11))) return void 0;
1470
- if (!await isRegularFile(path11)) return void 0;
1471
- const candidate = JSON.parse(await readFile4(path11, "utf8"));
1509
+ if (!await isSafeOutputCacheDirectory(dirname4(path12))) return void 0;
1510
+ if (!await isRegularFile(path12)) return void 0;
1511
+ const candidate = JSON.parse(await readFile4(path12, "utf8"));
1472
1512
  return isFastPathCacheState(candidate) ? candidate : void 0;
1473
1513
  } catch {
1474
1514
  return void 0;
@@ -1478,13 +1518,13 @@ function isFastPathCacheState(value) {
1478
1518
  if (typeof value !== "object" || value === null) return false;
1479
1519
  const candidate = value;
1480
1520
  return candidate.version === 1 && typeof candidate.outputCacheChecksum === "string" && (candidate.appFingerprint === void 0 || typeof candidate.appFingerprint === "string") && isOutputInventory(candidate.finalOutputInventory) && (candidate.publicDirectory === void 0 || typeof candidate.publicDirectory === "string") && (candidate.publicFingerprint === void 0 || typeof candidate.publicFingerprint === "string") && typeof candidate.configFile === "string" && Array.isArray(candidate.outputPaths) && candidate.outputPaths.every(isSafeLogicalOutputPath) && candidate.outputPaths.every(
1481
- (path11, index, paths) => index === 0 || paths[index - 1] < path11
1521
+ (path12, index, paths) => index === 0 || paths[index - 1] < path12
1482
1522
  );
1483
1523
  }
1484
- async function checksumFile(path11) {
1524
+ async function checksumFile(path12) {
1485
1525
  const hash = createHash3("sha256");
1486
1526
  try {
1487
- for await (const chunk of createReadStream(path11)) hash.update(chunk);
1527
+ for await (const chunk of createReadStream(path12)) hash.update(chunk);
1488
1528
  return hash.digest("hex");
1489
1529
  } catch {
1490
1530
  return void 0;
@@ -1506,17 +1546,11 @@ function isReplacementFailure(error) {
1506
1546
  const code = String(error.code);
1507
1547
  return code === "EPERM" || code === "EEXIST" || code === "EACCES";
1508
1548
  }
1509
- async function decodeOutput(outputCachePath, entry) {
1510
- const file = resolveOutputCacheFile(
1549
+ function resolveOutputCacheEntryPath(outputCachePath, entry) {
1550
+ return resolveOutputCacheFile(
1511
1551
  outputCacheEntriesPath(outputCachePath),
1512
1552
  entry.cachePath
1513
1553
  );
1514
- const content = await readFile4(file);
1515
- const checksum = createHash3("sha256").update(content).digest("hex");
1516
- if (checksum !== entry.checksum) {
1517
- throw new Error("SSG output cache entry checksum mismatch.");
1518
- }
1519
- return content;
1520
1554
  }
1521
1555
  function resolveOutputCacheFile(directory, relativePath) {
1522
1556
  return resolveWithinDirectory(
@@ -1525,20 +1559,20 @@ function resolveOutputCacheFile(directory, relativePath) {
1525
1559
  "SSG output cache path"
1526
1560
  );
1527
1561
  }
1528
- function isSafeLogicalOutputPath(path11) {
1529
- if (typeof path11 !== "string" || !path11 || path11.includes("\\") || path11.includes("\0") || isAbsolutePath(path11)) {
1562
+ function isSafeLogicalOutputPath(path12) {
1563
+ if (typeof path12 !== "string" || !path12 || path12.includes("\\") || path12.includes("\0") || isAbsolutePath(path12)) {
1530
1564
  return false;
1531
1565
  }
1532
1566
  try {
1533
- resolveOutputCacheFile("/riebeckite-output-root", path11);
1567
+ resolveOutputCacheFile("/riebeckite-output-root", path12);
1534
1568
  return true;
1535
1569
  } catch {
1536
1570
  return false;
1537
1571
  }
1538
1572
  }
1539
- function assertSafeLogicalOutputPath(path11) {
1540
- if (!isSafeLogicalOutputPath(path11)) {
1541
- throw new Error(`Invalid SSG output path: ${path11}`);
1573
+ function assertSafeLogicalOutputPath(path12) {
1574
+ if (!isSafeLogicalOutputPath(path12)) {
1575
+ throw new Error(`Invalid SSG output path: ${path12}`);
1542
1576
  }
1543
1577
  }
1544
1578
  function outputCacheEntryName(outputPath) {
@@ -1561,9 +1595,9 @@ async function isSafeOutputCacheDirectory(directory) {
1561
1595
  return false;
1562
1596
  }
1563
1597
  }
1564
- async function isSafeCacheFileTarget(path11) {
1598
+ async function isSafeCacheFileTarget(path12) {
1565
1599
  try {
1566
- return !(await lstat2(path11)).isSymbolicLink();
1600
+ return !(await lstat2(path12)).isSymbolicLink();
1567
1601
  } catch (error) {
1568
1602
  return isNotFoundError(error);
1569
1603
  }
@@ -1571,9 +1605,9 @@ async function isSafeCacheFileTarget(path11) {
1571
1605
  async function isSafeOutputCacheEntriesDirectory(directory) {
1572
1606
  return isSafeOutputCacheDirectory(directory);
1573
1607
  }
1574
- async function isRegularFile(path11) {
1608
+ async function isRegularFile(path12) {
1575
1609
  try {
1576
- const info = await lstat2(path11);
1610
+ const info = await lstat2(path12);
1577
1611
  return info.isFile() && !info.isSymbolicLink();
1578
1612
  } catch {
1579
1613
  return false;
@@ -1593,7 +1627,7 @@ async function replaceOutputCacheEntry(source, destination, timingsMs) {
1593
1627
  await measure(
1594
1628
  timingsMs,
1595
1629
  "outputCacheEntryCopy",
1596
- () => copyFile(source, temporaryPath)
1630
+ () => copyFile2(source, temporaryPath)
1597
1631
  );
1598
1632
  await measure(
1599
1633
  timingsMs,
@@ -1620,12 +1654,12 @@ async function collectUnreferencedOutputCacheEntries(directory, outputs, timings
1620
1654
  if (!/^[a-f0-9]{64}$/u.test(entry.name) || referenced.has(entry.name)) {
1621
1655
  continue;
1622
1656
  }
1623
- const path11 = join4(directory, entry.name);
1624
- if (await isRegularFile(path11)) {
1657
+ const path12 = join4(directory, entry.name);
1658
+ if (await isRegularFile(path12)) {
1625
1659
  await measure(
1626
1660
  timingsMs,
1627
1661
  "outputCacheGcDelete",
1628
- () => rm3(path11, { force: true })
1662
+ () => rm3(path12, { force: true })
1629
1663
  );
1630
1664
  }
1631
1665
  }
@@ -2078,7 +2112,7 @@ function riebeckiteSsg(options = {}) {
2078
2112
  (outputChangeSet?.affected ?? []).filter((output) => output.kind === "generated").map((output) => output.path)
2079
2113
  ) : void 0,
2080
2114
  siteOwnedOutputPaths,
2081
- (path11) => shadowedOutputs.add(path11)
2115
+ (path12) => shadowedOutputs.add(path12)
2082
2116
  )
2083
2117
  );
2084
2118
  if (!outputChangeSet)
@@ -2086,12 +2120,12 @@ function riebeckiteSsg(options = {}) {
2086
2120
  if (canUseIncremental && outputChangeSet && previousOutputCache) {
2087
2121
  await measure(timingsMs, "unchangedOutputReuse", async () => {
2088
2122
  for (const output of outputChangeSet.unchanged) {
2089
- const path11 = output.path;
2090
- if (siteOwnedOutputPaths.has(path11)) {
2091
- shadowedOutputs.add(path11);
2123
+ const path12 = output.path;
2124
+ if (siteOwnedOutputPaths.has(path12)) {
2125
+ shadowedOutputs.add(path12);
2092
2126
  continue;
2093
2127
  }
2094
- const cached = previousOutputCache.outputs[path11];
2128
+ const cached = previousOutputCache.outputs[path12];
2095
2129
  if (!cached) continue;
2096
2130
  if (!artifactWriter) {
2097
2131
  throw new Error(
@@ -2102,11 +2136,14 @@ function riebeckiteSsg(options = {}) {
2102
2136
  await measure(
2103
2137
  timingsMs,
2104
2138
  "outputWrite",
2105
- async () => writer.write(path11, await decodeOutput(outputCachePath, cached))
2139
+ () => writer.copyFileFrom(
2140
+ resolveOutputCacheEntryPath(outputCachePath, cached),
2141
+ path12
2142
+ )
2106
2143
  );
2107
2144
  metrics.emittedOutputCount += 1;
2108
2145
  metrics.reusedOutputCount += 1;
2109
- nextOutputCache.outputs[path11] = cached;
2146
+ nextOutputCache.outputs[path12] = cached;
2110
2147
  }
2111
2148
  });
2112
2149
  }
@@ -2163,17 +2200,22 @@ function riebeckiteSsg(options = {}) {
2163
2200
  content: module.content,
2164
2201
  reusablePaths: new Set(
2165
2202
  [...reusablePaths].filter(
2166
- (path11) => !siteOwnedOutputPaths.has(path11)
2203
+ (path12) => !siteOwnedOutputPaths.has(path12)
2167
2204
  )
2168
2205
  )
2169
2206
  };
2170
2207
  this.info(
2171
2208
  `SSG outputs: ${metrics.renderedOutputCount} rendered · ${metrics.reusedOutputCount} reused · ${metrics.deletedOutputCount} removed`
2172
2209
  );
2173
- inspectGeneratedHtmlPages(module, generatedHtml, {
2174
- warn: (message) => this.warn(message),
2175
- info: (message) => this.info(message)
2176
- });
2210
+ const generatedHtmlDiagnostics = inspectGeneratedHtmlPages(
2211
+ module,
2212
+ generatedHtml,
2213
+ {
2214
+ warn: (message) => this.warn(message),
2215
+ info: (message) => this.info(message)
2216
+ }
2217
+ );
2218
+ module.content?.recordFinalHtmlDiagnostics?.(generatedHtmlDiagnostics);
2177
2219
  logGeneratedHtmlAssetDiagnostics(this, generatedHtml);
2178
2220
  } finally {
2179
2221
  await rm4(bundleDirectory, { recursive: true, force: true });
@@ -2307,9 +2349,9 @@ function riebeckiteSsg(options = {}) {
2307
2349
  }
2308
2350
  };
2309
2351
  }
2310
- async function isDirectory2(path11) {
2352
+ async function isDirectory2(path12) {
2311
2353
  try {
2312
- return (await lstat3(path11)).isDirectory();
2354
+ return (await lstat3(path12)).isDirectory();
2313
2355
  } catch (error) {
2314
2356
  if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
2315
2357
  return false;
@@ -2319,8 +2361,8 @@ async function isDirectory2(path11) {
2319
2361
  }
2320
2362
  function findBuildOutputSiteCollisions(buildOutputPaths, siteOwnedOutputPaths) {
2321
2363
  const collisions = /* @__PURE__ */ new Set();
2322
- for (const path11 of buildOutputPaths) {
2323
- if (siteOwnedOutputPaths.has(path11)) collisions.add(path11);
2364
+ for (const path12 of buildOutputPaths) {
2365
+ if (siteOwnedOutputPaths.has(path12)) collisions.add(path12);
2324
2366
  }
2325
2367
  return [...collisions].sort();
2326
2368
  }
@@ -2336,10 +2378,11 @@ async function emitGeneratedOutputs(module, emit, affectedPaths, shadowedPaths,
2336
2378
  onShadowed?.(output.path);
2337
2379
  continue;
2338
2380
  }
2381
+ const source = isDeferredGeneratedOutput(output) ? await output.generate() : output.content;
2339
2382
  await emit({
2340
2383
  type: "asset",
2341
2384
  fileName: output.path,
2342
- source: output.content
2385
+ source
2343
2386
  });
2344
2387
  count += 1;
2345
2388
  }
@@ -2353,11 +2396,11 @@ function removeVirtualEntryChunk(bundle, virtualEntryId) {
2353
2396
  }
2354
2397
  }
2355
2398
  async function writePublicationMarker(input) {
2356
- const path11 = join5(input.root, ".riebeckite", BUILD_OUTPUT_MARKER_FILE);
2399
+ const path12 = join5(input.root, ".riebeckite", BUILD_OUTPUT_MARKER_FILE);
2357
2400
  try {
2358
- await mkdir5(dirname5(path11), { recursive: true });
2401
+ await mkdir5(dirname5(path12), { recursive: true });
2359
2402
  await writeFile4(
2360
- path11,
2403
+ path12,
2361
2404
  serializeBuildOutputMarker(
2362
2405
  createBuildOutputMarker({
2363
2406
  outputDirectory: input.outputDirectory,
@@ -2399,12 +2442,15 @@ function createRiebeckiteSsg(options = {}) {
2399
2442
  }
2400
2443
 
2401
2444
  // src/vite_plugin.ts
2402
- import path10 from "node:path";
2403
- import { riebeckiteDevelopmentInspector } from "@riebeckite/honox-inspector";
2445
+ import path11 from "node:path";
2446
+ import {
2447
+ invalidateDevelopmentInspector,
2448
+ riebeckiteDevelopmentInspector
2449
+ } from "@riebeckite/dev-inspector";
2404
2450
 
2405
2451
  // src/asset_entries.ts
2406
2452
  import fs6 from "node:fs";
2407
- import path7 from "node:path";
2453
+ import path8 from "node:path";
2408
2454
  import { uniqueStrings } from "@riebeckite/core";
2409
2455
  function writeRiebeckiteAssetEntries(config, paths) {
2410
2456
  writeGeneratedFile(paths.frameworkStyles, createFrameworkStylesEntry());
@@ -2445,7 +2491,7 @@ ${imports}
2445
2491
  }
2446
2492
  function writeGeneratedFile(filePath, contents) {
2447
2493
  if (readGeneratedFile(filePath) === contents) return;
2448
- fs6.mkdirSync(path7.dirname(filePath), { recursive: true });
2494
+ fs6.mkdirSync(path8.dirname(filePath), { recursive: true });
2449
2495
  fs6.writeFileSync(filePath, contents);
2450
2496
  }
2451
2497
  function readGeneratedFile(filePath) {
@@ -2638,7 +2684,7 @@ export async function disposeRiebeckiteClient() {
2638
2684
  }
2639
2685
 
2640
2686
  // src/content_watch.ts
2641
- import path8 from "node:path";
2687
+ import path9 from "node:path";
2642
2688
  import { isAttachmentPath, isImagePath as isImagePath2 } from "@riebeckite/core";
2643
2689
  import {
2644
2690
  isIgnoredContentPath as isIgnoredContentPath2,
@@ -2752,6 +2798,7 @@ function riebeckiteContentWatch(options) {
2752
2798
  timer = setTimeout(() => {
2753
2799
  timer = void 0;
2754
2800
  invalidateApplicationRuntime(server, appRoot);
2801
+ options.onInvalidate?.(server);
2755
2802
  server.hot.send({ type: "full-reload" });
2756
2803
  }, CONTENT_RELOAD_DEBOUNCE_MS);
2757
2804
  };
@@ -2780,7 +2827,7 @@ function isSiteAssetPath(logicalPath) {
2780
2827
  function invalidateApplicationRuntime(server, appRoot) {
2781
2828
  const moduleGraph = server.environments?.ssr?.moduleGraph;
2782
2829
  if (!moduleGraph) return 0;
2783
- const appDirectory = path8.join(appRoot, "app") + path8.sep;
2830
+ const appDirectory = path9.join(appRoot, "app") + path9.sep;
2784
2831
  const seen = /* @__PURE__ */ new Set();
2785
2832
  const timestamp = Date.now();
2786
2833
  let invalidated = 0;
@@ -2811,7 +2858,7 @@ function suppressRestartOnContentEvents(server, isContentFile) {
2811
2858
  // src/vite_runner.ts
2812
2859
  import fs7 from "node:fs/promises";
2813
2860
  import os from "node:os";
2814
- import path9 from "node:path";
2861
+ import path10 from "node:path";
2815
2862
  import { build as build2, createServer } from "vite";
2816
2863
  var viteConfigFileNames = [
2817
2864
  "vite.config.ts",
@@ -2845,10 +2892,10 @@ var HonoxApplicationRootError = class extends Error {
2845
2892
  }
2846
2893
  };
2847
2894
  async function resolveHonoxApplication(options) {
2848
- const configRoot = path9.resolve(options.configRoot);
2849
- const appRoot = options.appRoot ? path9.resolve(options.appRoot) : await resolveHonoxApplicationRoot(configRoot, options.startDirectory);
2895
+ const configRoot = path10.resolve(options.configRoot);
2896
+ const appRoot = options.appRoot ? path10.resolve(options.appRoot) : await resolveHonoxApplicationRoot(configRoot, options.startDirectory);
2850
2897
  const workspaceRoot = options.workspaceRoot ?? await findWorkspaceRoot2(configRoot);
2851
- const configFile = path9.resolve(
2898
+ const configFile = path10.resolve(
2852
2899
  configRoot,
2853
2900
  options.configFile ?? "riebeckite.config.ts"
2854
2901
  );
@@ -2868,23 +2915,23 @@ async function resolveHonoxApplication(options) {
2868
2915
  }
2869
2916
  async function findWorkspaceRoot2(configRoot) {
2870
2917
  try {
2871
- const workspaceConfig = path9.join(configRoot, "pnpm-workspace.yaml");
2918
+ const workspaceConfig = path10.join(configRoot, "pnpm-workspace.yaml");
2872
2919
  return (await fs7.stat(workspaceConfig)).isFile() ? configRoot : void 0;
2873
2920
  } catch {
2874
2921
  return void 0;
2875
2922
  }
2876
2923
  }
2877
2924
  async function startHonoxDevServer(options) {
2878
- const root = path9.resolve(options.root);
2925
+ const root = path10.resolve(options.root);
2879
2926
  await withWorkingDirectory(root, async () => {
2880
2927
  const server = await createServer({ root, server: options.server });
2881
2928
  const restartFiles = new Set(
2882
- options.restartOnChange?.map((file) => path9.resolve(file))
2929
+ options.restartOnChange?.map((file) => path10.resolve(file))
2883
2930
  );
2884
2931
  if (restartFiles.size > 0) {
2885
2932
  server.watcher.add([...restartFiles]);
2886
2933
  server.watcher.on("change", (file) => {
2887
- if (restartFiles.has(path9.resolve(file))) void server.restart();
2934
+ if (restartFiles.has(path10.resolve(file))) void server.restart();
2888
2935
  });
2889
2936
  }
2890
2937
  await server.listen(options.server?.port);
@@ -2909,7 +2956,7 @@ async function startHonoxDevServer(options) {
2909
2956
  });
2910
2957
  }
2911
2958
  async function buildHonoxApplication(options) {
2912
- const root = path9.resolve(options.root);
2959
+ const root = path10.resolve(options.root);
2913
2960
  await withWorkingDirectory(root, async () => {
2914
2961
  if (!options.reuseClientBuild) {
2915
2962
  await runTraced(
@@ -2926,9 +2973,9 @@ async function buildHonoxApplication(options) {
2926
2973
  });
2927
2974
  }
2928
2975
  async function canReuseClientBuild(input) {
2929
- const root = path9.resolve(input.root);
2976
+ const root = path10.resolve(input.root);
2930
2977
  const cache = await loadOutputCacheMetadata(
2931
- path9.join(root, ".riebeckite", "ssg-output-cache.json")
2978
+ path10.join(root, ".riebeckite", "ssg-output-cache.json")
2932
2979
  );
2933
2980
  if (!cache?.bundleFingerprint || !cache.configFile) return false;
2934
2981
  if (cache.bundleFingerprint !== await computeBundleFingerprint(root, cache.configFile)) {
@@ -2945,8 +2992,8 @@ async function buildServerWithMetrics(root, tracer) {
2945
2992
  return;
2946
2993
  }
2947
2994
  const previousMetricsFile = process.env.RIEBECKITE_SSG_METRICS_FILE;
2948
- const metricsDirectory = previousMetricsFile ? void 0 : await fs7.mkdtemp(path9.join(os.tmpdir(), "riebeckite-ssg-metrics-"));
2949
- const metricsFile = previousMetricsFile ?? path9.join(metricsDirectory, "metrics.json");
2995
+ const metricsDirectory = previousMetricsFile ? void 0 : await fs7.mkdtemp(path10.join(os.tmpdir(), "riebeckite-ssg-metrics-"));
2996
+ const metricsFile = previousMetricsFile ?? path10.join(metricsDirectory, "metrics.json");
2950
2997
  if (!previousMetricsFile)
2951
2998
  process.env.RIEBECKITE_SSG_METRICS_FILE = metricsFile;
2952
2999
  try {
@@ -3027,29 +3074,29 @@ async function findViteApplicationRoots(root, startDirectory) {
3027
3074
  if (!entry.isDirectory() || ignoredApplicationRootDirectoryNames.has(entry.name)) {
3028
3075
  continue;
3029
3076
  }
3030
- directories.push(path9.join(directory, entry.name));
3077
+ directories.push(path10.join(directory, entry.name));
3031
3078
  }
3032
3079
  }
3033
3080
  return applicationRoots;
3034
3081
  }
3035
3082
  async function findViteApplicationRootFrom(startDirectory, configRoot) {
3036
- let directory = path9.resolve(startDirectory);
3083
+ let directory = path10.resolve(startDirectory);
3037
3084
  while (isWithin(configRoot, directory)) {
3038
3085
  if (await hasViteConfig(directory)) return directory;
3039
- const parent = path9.dirname(directory);
3086
+ const parent = path10.dirname(directory);
3040
3087
  if (parent === directory) return void 0;
3041
3088
  directory = parent;
3042
3089
  }
3043
3090
  return void 0;
3044
3091
  }
3045
3092
  function isWithin(parent, target) {
3046
- const relative5 = path9.relative(parent, target);
3047
- return relative5 === "" || !relative5.startsWith("..") && !path9.isAbsolute(relative5);
3093
+ const relative5 = path10.relative(parent, target);
3094
+ return relative5 === "" || !relative5.startsWith("..") && !path10.isAbsolute(relative5);
3048
3095
  }
3049
3096
  async function hasViteConfig(directory) {
3050
3097
  for (const fileName of viteConfigFileNames) {
3051
3098
  try {
3052
- if ((await fs7.stat(path9.join(directory, fileName))).isFile()) return true;
3099
+ if ((await fs7.stat(path10.join(directory, fileName))).isFile()) return true;
3053
3100
  } catch {
3054
3101
  }
3055
3102
  }
@@ -3084,7 +3131,7 @@ function riebeckite(options = {}, onApplicationResolved) {
3084
3131
  {
3085
3132
  name: "riebeckite-host-integration",
3086
3133
  async config(userConfig) {
3087
- const root = userConfig.root ? path10.resolve(userConfig.root) : process.cwd();
3134
+ const root = userConfig.root ? path11.resolve(userConfig.root) : process.cwd();
3088
3135
  const appRoot = options.appRoot ?? root;
3089
3136
  const resolvedApplication = await resolveHonoxApplication({
3090
3137
  configRoot: options.configRoot ?? appRoot,
@@ -3096,12 +3143,12 @@ function riebeckite(options = {}, onApplicationResolved) {
3096
3143
  application = resolvedApplication;
3097
3144
  onApplicationResolved?.(resolvedApplication);
3098
3145
  writeRiebeckiteAssetEntries(resolvedConfig, {
3099
- frameworkStyles: path10.join(
3146
+ frameworkStyles: path11.join(
3100
3147
  appRoot,
3101
3148
  "app/.riebeckite/framework-styles.css"
3102
3149
  ),
3103
- pluginStyles: path10.join(appRoot, "app/.riebeckite/plugin-styles.css"),
3104
- themeStyles: path10.join(appRoot, "app/.riebeckite/theme-styles.css")
3150
+ pluginStyles: path11.join(appRoot, "app/.riebeckite/plugin-styles.css"),
3151
+ themeStyles: path11.join(appRoot, "app/.riebeckite/theme-styles.css")
3105
3152
  });
3106
3153
  return {
3107
3154
  define: {
@@ -3130,9 +3177,17 @@ function riebeckite(options = {}, onApplicationResolved) {
3130
3177
  riebeckiteContentWatch({
3131
3178
  appRoot: () => requireApplication(application).appRoot,
3132
3179
  contentRoot: () => requireApplication(application).contentRoot,
3133
- exclude: () => getConfig().content.exclude ?? []
3180
+ exclude: () => getConfig().content.exclude ?? [],
3181
+ onInvalidate: invalidateDevelopmentInspector
3134
3182
  }),
3135
- riebeckiteDevelopmentInspector(() => requireApplication(application))
3183
+ riebeckiteDevelopmentInspector(() => requireApplication(application), {
3184
+ async getSnapshot(server) {
3185
+ const { appRoot } = requireApplication(application);
3186
+ if (!isContentModuleLoaded(server, appRoot)) return void 0;
3187
+ const module = await loadContentModule(server, appRoot);
3188
+ return module.content?.getCompletedBuildSnapshot?.();
3189
+ }
3190
+ })
3136
3191
  ];
3137
3192
  }
3138
3193
  function requireApplication(application) {
package/dist/server.js CHANGED
@@ -135,8 +135,14 @@ function mountRiebeckiteEndpoints(app, options) {
135
135
  for (const endpoint of endpoints) {
136
136
  const method = endpoint.method ?? "GET";
137
137
  const handler = async (context) => {
138
+ const body = await readEndpointBody(context.req);
139
+ if (body === null) {
140
+ return context.text("Payload Too Large", 413, {
141
+ "content-type": "text/plain; charset=utf-8"
142
+ });
143
+ }
144
+ const request = toPluginEndpointRequest(context, method, body);
138
145
  const manifest = endpoint.requiresManifest === false ? void 0 : await options.content.getManifest();
139
- const request = await toPluginEndpointRequest(context, method);
140
146
  const response = await endpoint.handler({
141
147
  config: options.config,
142
148
  manifest,
@@ -195,7 +201,44 @@ function validateEndpointPath(path) {
195
201
  );
196
202
  }
197
203
  }
198
- async function toPluginEndpointRequest(context, method) {
204
+ var MAX_ENDPOINT_BODY_BYTES = 1024 * 1024;
205
+ async function readEndpointBody(request) {
206
+ const declared = request.raw.headers.get?.("content-length");
207
+ if (declared !== null && declared !== void 0) {
208
+ const length = Number(declared);
209
+ if (Number.isFinite(length) && length > MAX_ENDPOINT_BODY_BYTES) {
210
+ return null;
211
+ }
212
+ }
213
+ const body = request.raw.body;
214
+ if (!body) return "";
215
+ const reader = body.getReader();
216
+ const chunks = [];
217
+ let total = 0;
218
+ try {
219
+ for (; ; ) {
220
+ const { done, value } = await reader.read();
221
+ if (done) break;
222
+ if (value === void 0) continue;
223
+ total += value.byteLength;
224
+ if (total > MAX_ENDPOINT_BODY_BYTES) {
225
+ await reader.cancel();
226
+ return null;
227
+ }
228
+ chunks.push(value);
229
+ }
230
+ } finally {
231
+ reader.releaseLock();
232
+ }
233
+ const merged = new Uint8Array(total);
234
+ let offset = 0;
235
+ for (const chunk of chunks) {
236
+ merged.set(chunk, offset);
237
+ offset += chunk.byteLength;
238
+ }
239
+ return new TextDecoder().decode(merged);
240
+ }
241
+ function toPluginEndpointRequest(context, method, body) {
199
242
  const headers = {};
200
243
  context.req.raw.headers.forEach((value, key) => {
201
244
  headers[key.toLowerCase()] = value;
@@ -206,7 +249,7 @@ async function toPluginEndpointRequest(context, method) {
206
249
  path: context.req.path,
207
250
  query: context.req.query(),
208
251
  headers,
209
- body: await context.req.text()
252
+ body
210
253
  };
211
254
  }
212
255
  function toHonoResponse(context, response) {
@@ -0,0 +1,11 @@
1
+ import type { CompletedContentBuildSnapshot } from "@riebeckite/core";
2
+ import type { ViteDevServer } from "vite";
3
+ export type ContentAppModule = {
4
+ readonly content?: {
5
+ getManifest?: () => Promise<unknown>;
6
+ getCompletedBuildSnapshot?: () => CompletedContentBuildSnapshot | undefined;
7
+ };
8
+ };
9
+ export declare function contentModuleEntry(appRoot: string): string;
10
+ export declare function isContentModuleLoaded(server: Pick<ViteDevServer, "environments">, appRoot: string): boolean;
11
+ export declare function loadContentModule(server: Pick<ViteDevServer, "ssrLoadModule">, appRoot: string): Promise<ContentAppModule>;
@@ -3,6 +3,7 @@ type RiebeckiteContentWatchOptions = {
3
3
  appRoot: () => string;
4
4
  contentRoot: () => string;
5
5
  exclude: () => readonly string[];
6
+ onInvalidate?: (server: ViteDevServer) => void;
6
7
  };
7
8
  export declare function riebeckiteContentWatch(options: RiebeckiteContentWatchOptions): Plugin;
8
9
  export declare function isSiteAssetPath(logicalPath: string): boolean;
@@ -9,6 +9,7 @@ type HonoLikeApp = {
9
9
  };
10
10
  type HonoLikeHeaders = {
11
11
  forEach(callback: (value: string, key: string) => void): void;
12
+ get?(name: string): string | null;
12
13
  };
13
14
  type HonoLikeRequest = {
14
15
  method: string;
@@ -16,6 +17,7 @@ type HonoLikeRequest = {
16
17
  path: string;
17
18
  raw: {
18
19
  headers: HonoLikeHeaders;
20
+ body?: ReadableStream<Uint8Array> | null;
19
21
  };
20
22
  query(): Record<string, string>;
21
23
  text(): Promise<string>;
@@ -1,6 +1,7 @@
1
1
  export type BuildArtifactWriter = {
2
2
  readonly directory: string;
3
3
  copyFrom(source: string): Promise<void>;
4
+ copyFileFrom(source: string, path: string): Promise<void>;
4
5
  remove(path: string): Promise<void>;
5
6
  write(path: string, data: string | Uint8Array): Promise<void>;
6
7
  publish(): Promise<void>;
@@ -1,3 +1,4 @@
1
+ import type { Diagnostic } from "@riebeckite/core";
1
2
  import type { SsgModule } from "./types.js";
2
3
  export declare function formatSsrNoExternal(): string;
3
4
  export declare function logSsgDiagnostics(logger: {
@@ -21,4 +22,4 @@ export declare function inspectGeneratedHtmlPages(module: SsgModule, pages: read
21
22
  }[], log: {
22
23
  warn: (message: string) => void;
23
24
  info: (message: string) => void;
24
- }): void;
25
+ }): Diagnostic[];
@@ -31,4 +31,5 @@ export declare function loadOutputCacheMetadata(path: string, timingsMs?: Record
31
31
  export declare function validateOutputCache(cache: OutputCacheState, path: string, timingsMs?: Record<string, number>, log?: (message: string) => void): Promise<boolean>;
32
32
  export declare function saveOutputCache(path: string, state: OutputCacheState, outputDirectory: string, timingsMs?: Record<string, number>): Promise<string>;
33
33
  export declare function decodeOutput(outputCachePath: string, entry: OutputCacheEntry): Promise<Uint8Array>;
34
+ export declare function resolveOutputCacheEntryPath(outputCachePath: string, entry: OutputCacheEntry): string;
34
35
  export {};
@@ -1,4 +1,4 @@
1
- import type { BuildProvenance, ContentManifest, OutputDescriptor } from "@riebeckite/core";
1
+ import type { BuildProvenance, ContentManifest, Diagnostic, OutputDescriptor } from "@riebeckite/core";
2
2
  import type { toSSG } from "hono/ssg";
3
3
  export type GeneratedOutputAsset = {
4
4
  type: "asset";
@@ -22,10 +22,13 @@ export type SsgModule = {
22
22
  default: Parameters<typeof toSSG>[0];
23
23
  content?: {
24
24
  getManifest(): Promise<ContentManifest & {
25
- generatedOutputs?: readonly {
25
+ generatedOutputs?: readonly ({
26
26
  path: string;
27
27
  content: string | Uint8Array;
28
- }[];
28
+ } | {
29
+ path: string;
30
+ generate: () => string | Uint8Array | Promise<string | Uint8Array>;
31
+ })[];
29
32
  }>;
30
33
  getProcessedContentCount(): number;
31
34
  getReusedContentCount(): number;
@@ -55,6 +58,7 @@ export type SsgModule = {
55
58
  unchangedOutputCount: number;
56
59
  }>;
57
60
  getProvenance(): BuildProvenance | undefined;
61
+ recordFinalHtmlDiagnostics?(diagnostics: readonly Diagnostic[]): void;
58
62
  attachFinalOutputArtifacts(buildId: string, fingerprints: Readonly<Record<string, string>>, cacheHits: ReadonlySet<string>): Promise<void>;
59
63
  };
60
64
  config?: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riebeckite/honox",
3
- "version": "0.0.36",
3
+ "version": "0.0.38",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -40,12 +40,12 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "@babel/parser": "^7.29.3",
43
- "@riebeckite/core": "0.0.36",
44
- "@riebeckite/honox-inspector": "0.0.36",
45
- "@riebeckite/node": "0.0.36",
46
- "@riebeckite/plugin-color-mode": "0.0.36",
47
- "@riebeckite/spa": "0.0.36",
48
- "@riebeckite/ui": "0.0.36",
43
+ "@riebeckite/core": "0.0.38",
44
+ "@riebeckite/dev-inspector": "0.0.38",
45
+ "@riebeckite/node": "0.0.38",
46
+ "@riebeckite/plugin-color-mode": "0.0.38",
47
+ "@riebeckite/spa": "0.0.38",
48
+ "@riebeckite/ui": "0.0.38",
49
49
  "esbuild": "^0.28.2",
50
50
  "hono": "^4.12.25",
51
51
  "honox": "0.1.62",
@@ -54,7 +54,7 @@
54
54
  "devDependencies": {
55
55
  "@d2lang/d2": "^0.1.34",
56
56
  "@marp-team/marp-core": "^4.4.0",
57
- "@riebeckite/test": "0.0.36",
57
+ "@riebeckite/test": "0.0.38",
58
58
  "tsx": "^4.22.4"
59
59
  },
60
60
  "publishConfig": {