@riebeckite/honox 0.0.41 → 0.0.43

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
@@ -1456,11 +1456,14 @@ async function saveOutputCacheEntries(directory, outputDirectory, outputs, final
1456
1456
  if (existing.cachePath !== outputCacheEntryName(outputPath) || !isChecksum(existing.checksum)) {
1457
1457
  throw new Error(`Invalid SSG output cache entry: ${outputPath}`);
1458
1458
  }
1459
- entries[outputPath] = await withOutputCacheEntryStat(
1459
+ const cached = await existingOutputCacheEntry(
1460
1460
  existing,
1461
1461
  join4(directory, existing.cachePath)
1462
1462
  );
1463
- continue;
1463
+ if (cached) {
1464
+ entries[outputPath] = cached;
1465
+ continue;
1466
+ }
1464
1467
  }
1465
1468
  const source = resolveOutputCacheFile(outputDirectory, outputPath);
1466
1469
  const cachePath = outputCacheEntryName(outputPath);
@@ -1490,6 +1493,11 @@ async function withOutputCacheEntryStat(entry, path12) {
1490
1493
  if (!info?.isFile() || info.isSymbolicLink()) return entry;
1491
1494
  return { ...entry, size: info.size, modifiedAtMs: info.mtimeMs };
1492
1495
  }
1496
+ async function existingOutputCacheEntry(entry, path12) {
1497
+ const info = await lstat2(path12).catch(() => void 0);
1498
+ if (!info?.isFile() || info.isSymbolicLink()) return void 0;
1499
+ return { ...entry, size: info.size, modifiedAtMs: info.mtimeMs };
1500
+ }
1493
1501
  async function validateOutputCacheEntries(outputCachePath, entries, timingsMs) {
1494
1502
  try {
1495
1503
  const directory = outputCacheEntriesPath(outputCachePath);
@@ -1819,13 +1827,29 @@ async function runSsg(options) {
1819
1827
  },
1820
1828
  {
1821
1829
  dir: options.outDir,
1822
- plugins: [redirectPlugin(), ...options.plugins ?? []],
1830
+ plugins: [
1831
+ redirectPlugin(),
1832
+ failOnServerError(),
1833
+ ...options.plugins ?? []
1834
+ ],
1823
1835
  extensionMap: options.extensionMap ?? defaultExtensionMap,
1824
1836
  ...options.concurrency === void 0 ? {} : { concurrency: options.concurrency }
1825
1837
  }
1826
1838
  )
1827
1839
  );
1828
1840
  }
1841
+ function failOnServerError() {
1842
+ return {
1843
+ afterResponseHook(response) {
1844
+ if (response.status >= 500) {
1845
+ throw new Error(
1846
+ `SSG route responded with status ${response.status}: ${response.statusText}`
1847
+ );
1848
+ }
1849
+ return response;
1850
+ }
1851
+ };
1852
+ }
1829
1853
  async function withSsgRenderEnvironment(incremental, operation) {
1830
1854
  const previousFullRegeneration = process.env.RIEBECKITE_SSG_FULL_REGENERATION;
1831
1855
  const previousSkipUnchanged = process.env.RIEBECKITE_SSG_SKIP_UNCHANGED;
@@ -1851,10 +1875,12 @@ function restoreEnvironmentVariable(name, value) {
1851
1875
 
1852
1876
  // src/ssg/standalone.ts
1853
1877
  import { mkdir as mkdir4 } from "node:fs/promises";
1878
+ import { createRequire } from "node:module";
1854
1879
  import { relative as relative3, resolve as resolve3 } from "node:path";
1855
1880
  import { pathToFileURL } from "node:url";
1856
1881
  import { build } from "vite";
1857
1882
  var standaloneSsgMode = "riebeckite-ssr";
1883
+ var frameworkRequire = createRequire(import.meta.url);
1858
1884
  async function loadStandaloneSsgBundle(input) {
1859
1885
  const root = resolve3(input.root);
1860
1886
  const outputDirectory = resolve3(input.outputDirectory);
@@ -1870,6 +1896,7 @@ async function loadStandaloneSsgBundle(input) {
1870
1896
  ...input.config.plugins.filter(
1871
1897
  (plugin) => plugin.name !== "riebeckite-ssg" && plugin.name !== "riebeckite-ssr-externals" && !plugin.name.startsWith("@hono/vite-build/")
1872
1898
  ),
1899
+ createFrameworkResolutionPlugin(),
1873
1900
  createRuntimeExternalPlugin(),
1874
1901
  ...input.clientOutputDirectory ? [createClientManifestPlugin(root, input.clientOutputDirectory)] : []
1875
1902
  ],
@@ -1895,6 +1922,18 @@ async function loadStandaloneSsgBundle(input) {
1895
1922
  }
1896
1923
  return { app: module.default, module };
1897
1924
  }
1925
+ function createFrameworkResolutionPlugin() {
1926
+ return {
1927
+ name: "riebeckite-ssg-framework-resolution",
1928
+ enforce: "pre",
1929
+ resolveId(source) {
1930
+ if (!(source === "hono" || source.startsWith("hono/") || source === "honox" || source.startsWith("honox/"))) {
1931
+ return void 0;
1932
+ }
1933
+ return frameworkRequire.resolve(source);
1934
+ }
1935
+ };
1936
+ }
1898
1937
  var runtimeExternalPackages = /* @__PURE__ */ new Set(["@d2lang/d2", "@marp-team/marp-core"]);
1899
1938
  function createRuntimeExternalPlugin() {
1900
1939
  return {
@@ -1949,11 +1988,15 @@ function riebeckiteSsg(options = {}) {
1949
1988
  }
1950
1989
  };
1951
1990
  },
1952
- configResolved(config) {
1991
+ async configResolved(config) {
1953
1992
  resolvedConfig = config;
1954
1993
  if (config.mode === "client") {
1955
1994
  clientOutputDirectory = resolve4(config.root, config.build.outDir);
1995
+ return;
1956
1996
  }
1997
+ await emptyBuildOutputDirectory(
1998
+ resolve4(config.root, config.build.outDir)
1999
+ );
1957
2000
  },
1958
2001
  async buildStart() {
1959
2002
  const config = resolvedConfig;
@@ -1976,9 +2019,6 @@ function riebeckiteSsg(options = {}) {
1976
2019
  );
1977
2020
  }
1978
2021
  if (!clientBuildArtifacts) {
1979
- if (await isDirectory2(publicationOutputDirectory)) {
1980
- await artifactWriter.copyFrom(publicationOutputDirectory);
1981
- }
1982
2022
  return;
1983
2023
  }
1984
2024
  logSsgDiagnostics(
@@ -2033,6 +2073,10 @@ function riebeckiteSsg(options = {}) {
2033
2073
  "outputDependencyResolution",
2034
2074
  async () => module.content?.getOutputChangeSet()
2035
2075
  );
2076
+ const previousOutputDirectory = publicationOutputDirectory;
2077
+ if (!clientBuildArtifacts && artifactWriter && previousOutputDirectory && await isDirectory2(previousOutputDirectory)) {
2078
+ await artifactWriter.copyFrom(previousOutputDirectory);
2079
+ }
2036
2080
  const appFingerprint = await measure(
2037
2081
  timingsMs,
2038
2082
  "appFingerprint",
@@ -2207,12 +2251,14 @@ function riebeckiteSsg(options = {}) {
2207
2251
  "outputWrite",
2208
2252
  () => writer.write(fileName, data)
2209
2253
  );
2210
- outputChecksums.set(fileName, fingerprintOutputContent(data));
2254
+ const checksum = fingerprintOutputContent(data);
2255
+ outputChecksums.set(fileName, checksum);
2211
2256
  metrics.emittedOutputCount += 1;
2212
- nextOutputCache.outputs[fileName] = {
2213
- cachePath: "",
2214
- checksum: ""
2215
- };
2257
+ nextOutputCache.outputs[fileName] = outputCacheEntryFor(
2258
+ previousOutputCache,
2259
+ fileName,
2260
+ checksum
2261
+ );
2216
2262
  }
2217
2263
  })
2218
2264
  );
@@ -2244,15 +2290,14 @@ function riebeckiteSsg(options = {}) {
2244
2290
  "outputWrite",
2245
2291
  () => writer.write(asset.fileName, asset.source)
2246
2292
  );
2247
- outputChecksums.set(
2293
+ const checksum = fingerprintOutputContent(asset.source);
2294
+ outputChecksums.set(asset.fileName, checksum);
2295
+ metrics.emittedOutputCount += 1;
2296
+ nextOutputCache.outputs[asset.fileName] = outputCacheEntryFor(
2297
+ previousOutputCache,
2248
2298
  asset.fileName,
2249
- fingerprintOutputContent(asset.source)
2299
+ checksum
2250
2300
  );
2251
- metrics.emittedOutputCount += 1;
2252
- nextOutputCache.outputs[asset.fileName] = {
2253
- cachePath: "",
2254
- checksum: ""
2255
- };
2256
2301
  },
2257
2302
  canUseIncremental ? new Set(
2258
2303
  (outputChangeSet?.affected ?? []).filter((output) => output.kind === "generated").map((output) => output.path)
@@ -2459,6 +2504,7 @@ function riebeckiteSsg(options = {}) {
2459
2504
  0,
2460
2505
  process.memoryUsage().rss - outputPlanRssBefore
2461
2506
  );
2507
+ assertRequiredOutputsWereGenerated(outputPlanComparison);
2462
2508
  const publicDir = outputCache.publicDir;
2463
2509
  outputCache.state.publicDirectory = publicDir ? resolve4(publicDir) : void 0;
2464
2510
  outputCache.state.publicFingerprint = publicDir ? await measure(
@@ -2520,6 +2566,16 @@ function findBuildOutputSiteCollisions(buildOutputPaths, siteOwnedOutputPaths) {
2520
2566
  }
2521
2567
  return [...collisions].sort();
2522
2568
  }
2569
+ function assertRequiredOutputsWereGenerated(comparison) {
2570
+ if (comparison.missingInDist.length === 0) return;
2571
+ throw new Error(
2572
+ `SSG did not generate required output: ${comparison.missingInDist.join(", ")}`
2573
+ );
2574
+ }
2575
+ function outputCacheEntryFor(previous, path12, checksum) {
2576
+ const cached = previous?.outputs[path12];
2577
+ return cached?.checksum === checksum ? cached : { cachePath: "", checksum: "" };
2578
+ }
2523
2579
  async function emitGeneratedOutputs(module, emit, affectedPaths, shadowedPaths, onShadowed) {
2524
2580
  const content = module.content;
2525
2581
  if (!content) return 0;
package/dist/server.js CHANGED
@@ -114,7 +114,7 @@ function isDynamicRoute(path) {
114
114
  }
115
115
  function normalizeRequestPath(pathname) {
116
116
  const trailingSlash = pathname.length > 1 && pathname.endsWith("/");
117
- const segments = pathname.split("/").filter(Boolean).map(decodeSegment);
117
+ const segments = pathname.split("/").filter(Boolean).map(encodeSegment);
118
118
  const path = `/${segments.join("/")}`;
119
119
  return trailingSlash ? `${path}/` : path;
120
120
  }
@@ -131,11 +131,11 @@ function redirectSsgPaths(manifest) {
131
131
  function routeOutputPath(pathname) {
132
132
  return htmlOutputPath(pathname);
133
133
  }
134
- function decodeSegment(segment) {
134
+ function encodeSegment(segment) {
135
135
  try {
136
- return decodeURIComponent(segment);
136
+ return encodeURIComponent(decodeURIComponent(segment));
137
137
  } catch {
138
- return segment;
138
+ return encodeURIComponent(segment);
139
139
  }
140
140
  }
141
141
 
@@ -11,5 +11,6 @@ export declare function loadStandaloneSsgBundle(input: {
11
11
  readonly clientOutputDirectory?: string;
12
12
  readonly config?: Pick<ResolvedConfig, "define" | "oxc" | "plugins" | "resolve">;
13
13
  }): Promise<StandaloneSsgBundle>;
14
+ export declare function createFrameworkResolutionPlugin(): Plugin;
14
15
  export declare function createClientManifestPlugin(root: string, clientOutputDirectory: string): Plugin;
15
16
  export declare function isStandaloneSsgMode(mode: string): boolean;
@@ -13,3 +13,6 @@ export type RiebeckiteSsgOptions = {
13
13
  export declare function riebeckiteSsg(options?: RiebeckiteSsgOptions): Plugin;
14
14
  export declare function shouldApplyRiebeckiteSsg(_config: unknown, env: ConfigEnv): boolean;
15
15
  export declare function findBuildOutputSiteCollisions(buildOutputPaths: Iterable<string>, siteOwnedOutputPaths: ReadonlySet<string>): readonly string[];
16
+ export declare function assertRequiredOutputsWereGenerated(comparison: {
17
+ readonly missingInDist: readonly string[];
18
+ }): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riebeckite/honox",
3
- "version": "0.0.41",
3
+ "version": "0.0.43",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -40,22 +40,25 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "@babel/parser": "^7.29.3",
43
- "@riebeckite/core": "0.0.41",
44
- "@riebeckite/dev-inspector": "0.0.41",
45
- "@riebeckite/node": "0.0.41",
46
- "@riebeckite/plugin-color-mode": "0.0.41",
47
- "@riebeckite/spa": "0.0.41",
48
- "@riebeckite/ui": "0.0.41",
49
43
  "esbuild": "^0.28.2",
50
44
  "hono": "^4.12.25",
51
45
  "honox": "0.1.62",
52
- "vite": "^8.3.5"
46
+ "vite": "^8.3.5",
47
+ "@riebeckite/core": "0.0.43",
48
+ "@riebeckite/plugin-color-mode": "0.0.43",
49
+ "@riebeckite/node": "0.0.43",
50
+ "@riebeckite/dev-inspector": "0.0.43",
51
+ "@riebeckite/spa": "0.0.43",
52
+ "@riebeckite/ui": "0.0.43"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@d2lang/d2": "^0.1.34",
56
+ "@hono/node-server": "2.1.3",
57
+ "@hono/vite-build": "^1.11.1",
56
58
  "@marp-team/marp-core": "^4.4.0",
57
- "@riebeckite/test": "0.0.41",
58
- "tsx": "^4.22.4"
59
+ "tsx": "^4.22.4",
60
+ "@riebeckite/test": "0.0.43",
61
+ "@riebeckite/plugin-bases": "0.0.43"
59
62
  },
60
63
  "publishConfig": {
61
64
  "access": "public"