@riebeckite/honox 0.0.35 → 0.0.37

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/runtime.d.ts CHANGED
@@ -1 +1,2 @@
1
+ export { createDevelopmentTrace, type DevelopmentTrace, } from "@riebeckite/core";
1
2
  export { resolveHonoxConfig } from "./src/resolved_config.js";
package/dist/runtime.js CHANGED
@@ -1,3 +1,8 @@
1
+ // runtime.ts
2
+ import {
3
+ createDevelopmentTrace
4
+ } from "@riebeckite/core";
5
+
1
6
  // src/resolved_config.ts
2
7
  import path from "node:path";
3
8
  function resolveHonoxConfig(config, appRoot) {
@@ -12,5 +17,6 @@ function resolveHonoxConfig(config, appRoot) {
12
17
  };
13
18
  }
14
19
  export {
20
+ createDevelopmentTrace,
15
21
  resolveHonoxConfig
16
22
  };
package/dist/server.js CHANGED
@@ -3,7 +3,7 @@ import { getEntryLanguage, htmlOutputPath } from "@riebeckite/core";
3
3
  async function resolveRiebeckiteRoute(content, pathname) {
4
4
  const page = await content.resolvePage(pathname);
5
5
  if (page) return { kind: "page", page };
6
- return resolveContentRoute(await content.getManifest(), pathname);
6
+ return resolveContentRoute(await content.getRequestManifest(), pathname);
7
7
  }
8
8
  function applyRiebeckiteRouteContext(c, route) {
9
9
  if (route.kind === "page") {
@@ -45,7 +45,7 @@ async function resolveRiebeckiteContentRequest(c, content, parameter = "slug") {
45
45
  return resolveRouteRequest(c, content);
46
46
  }
47
47
  async function resolveRiebeckiteHomeRequest(c, content) {
48
- const indexEntry = (await content.getManifest()).bySlug.get("index");
48
+ const indexEntry = (await content.getRequestManifest()).bySlug.get("index");
49
49
  if (indexEntry && indexEntry.permalink !== "/") {
50
50
  return {
51
51
  kind: "response",
@@ -119,7 +119,7 @@ function normalizeRequestPath(pathname) {
119
119
  return trailingSlash ? `${path}/` : path;
120
120
  }
121
121
  function routeOutputPath(pathname) {
122
- return htmlOutputPath(normalizeRequestPath(pathname));
122
+ return htmlOutputPath(pathname);
123
123
  }
124
124
  function decodeSegment(segment) {
125
125
  try {
@@ -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) {
@@ -307,7 +350,7 @@ function createHomeRoute(options) {
307
350
  });
308
351
  }
309
352
  async function renderContent(c, options, entry, post) {
310
- const manifest = await options.content.getManifest();
353
+ const manifest = await options.content.getRequestManifest();
311
354
  const view = createPublicContentView(manifest);
312
355
  const publicEntry = view.findRoutableBySlug(entry.slug);
313
356
  if (!publicEntry) return c.notFound();
@@ -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>;
@@ -17,7 +17,7 @@ export type ResolvedRiebeckiteRoute = Exclude<ResolvedContentRoute, null> | {
17
17
  * single HonoX adapter needed by a catch-all site route; plugins never add
18
18
  * HonoX routes themselves.
19
19
  */
20
- export declare function resolveRiebeckiteRoute(content: Pick<ContentManager, "resolvePage" | "getManifest">, pathname: string): Promise<ResolvedRiebeckiteRoute>;
20
+ export declare function resolveRiebeckiteRoute(content: Pick<ContentManager, "resolvePage" | "getRequestManifest">, pathname: string): Promise<ResolvedRiebeckiteRoute>;
21
21
  /**
22
22
  * The resolved route request a Site consumes from a catch-all content route.
23
23
  *
@@ -42,7 +42,7 @@ export type ResolvedContentRequest = {
42
42
  * so the resolver owns their values instead of each route rebuilding them.
43
43
  */
44
44
  export declare function applyRiebeckiteRouteContext(c: Context, route: Exclude<ResolvedRiebeckiteRoute, null>): void;
45
- type RouteContent = Pick<ContentManager, "resolvePage" | "getManifest" | "getProcessedContent">;
45
+ type RouteContent = Pick<ContentManager, "resolvePage" | "getRequestManifest" | "getProcessedContent">;
46
46
  /**
47
47
  * Resolves a catch-all content request into what a Site should render.
48
48
  *
@@ -3,10 +3,9 @@ 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
- export declare function isPathInsideDirectory(directory: string, file: string): boolean;
10
- export declare function toLogicalPath(directory: string, file: string): string;
11
10
  export declare function invalidateApplicationRuntime(server: Pick<ViteDevServer, "environments">, appRoot: string): number;
12
11
  export {};
@@ -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,6 @@
1
1
  import type { ContentManager, ContentManifestEntry, PostContent, ResolvedRiebeckiteConfig } from "@riebeckite/core";
2
2
  import type { Child } from "hono/jsx";
3
- type RouteContent = Pick<ContentManager, "resolvePage" | "getManifest" | "getProcessedContent" | "getOutputChangeSet" | "getPagePaths">;
3
+ type RouteContent = Pick<ContentManager, "resolvePage" | "getManifest" | "getRequestManifest" | "getProcessedContent" | "getOutputChangeSet" | "getPagePaths">;
4
4
  type RenderContent = (content: {
5
5
  entry: ContentManifestEntry;
6
6
  post: PostContent;
@@ -0,0 +1,14 @@
1
+ export type BuildArtifactWriter = {
2
+ readonly directory: string;
3
+ copyFrom(source: string): Promise<void>;
4
+ copyFileFrom(source: string, path: string): Promise<void>;
5
+ remove(path: string): Promise<void>;
6
+ write(path: string, data: string | Uint8Array): Promise<void>;
7
+ publish(): Promise<void>;
8
+ discard(): Promise<void>;
9
+ };
10
+ export declare function createBuildArtifactWriter(input: {
11
+ readonly outputDirectory: string;
12
+ readonly stagingDirectory?: string;
13
+ readonly clearStagingDirectory?: boolean;
14
+ }): Promise<BuildArtifactWriter>;
@@ -14,3 +14,7 @@ export declare function preserveClientBuildArtifacts(outDir: string): Promise<Cl
14
14
  export declare function restoreClientBuildArtifacts(outDir: string, artifacts: ClientBuildArtifacts | undefined): Promise<void>;
15
15
  export declare function discardClientBuildArtifacts(artifacts: ClientBuildArtifacts | undefined): Promise<void>;
16
16
  export declare function collectBuildOutputPaths(directory: string, relativeDirectory?: string): Promise<string[]>;
17
+ export declare function verifyClientBuildArtifacts(input: {
18
+ readonly outDir: string;
19
+ readonly expectedInventory: Readonly<Record<string, string>>;
20
+ }): Promise<boolean>;
@@ -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[];
@@ -1,5 +1,6 @@
1
1
  import type { NoChangeFastPathOutputMetrics } from "./types.js";
2
2
  export declare function computeAppFingerprint(root: string, configFile: string | undefined): Promise<string>;
3
+ export declare function computeBundleFingerprint(root: string, configFile: string | undefined): Promise<string>;
3
4
  export declare function fingerprintDirectory(directory: string): Promise<string>;
4
5
  export declare function fingerprintOutputDirectory(directory: string, relativeDirectory?: string, metrics?: NoChangeFastPathOutputMetrics): Promise<Record<string, string>>;
5
6
  export declare function inventoriesEqual(left: Record<string, string>, right: Record<string, string>): boolean;
@@ -6,6 +6,7 @@ type OutputCacheEntry = {
6
6
  export type OutputCacheState = {
7
7
  version: 4;
8
8
  appFingerprint?: string;
9
+ bundleFingerprint?: string;
9
10
  clientManifestFingerprint?: string;
10
11
  outputs: Record<string, OutputCacheEntry>;
11
12
  finalOutputInventory?: Record<string, string>;
@@ -24,6 +25,11 @@ export declare function verifyNoChangeFastPath(input: {
24
25
  export declare function loadOutputCache(path: string, timingsMs?: Record<string, number>, log?: (message: string) => void): Promise<(OutputCacheState & {
25
26
  fileSizeBytes?: number;
26
27
  }) | undefined>;
28
+ export declare function loadOutputCacheMetadata(path: string, timingsMs?: Record<string, number>, log?: (message: string) => void): Promise<(OutputCacheState & {
29
+ fileSizeBytes?: number;
30
+ }) | undefined>;
31
+ export declare function validateOutputCache(cache: OutputCacheState, path: string, timingsMs?: Record<string, number>, log?: (message: string) => void): Promise<boolean>;
27
32
  export declare function saveOutputCache(path: string, state: OutputCacheState, outputDirectory: string, timingsMs?: Record<string, number>): Promise<string>;
28
33
  export declare function decodeOutput(outputCachePath: string, entry: OutputCacheEntry): Promise<Uint8Array>;
34
+ export declare function resolveOutputCacheEntryPath(outputCachePath: string, entry: OutputCacheEntry): string;
29
35
  export {};
@@ -0,0 +1,12 @@
1
+ import { toSSG } from "hono/ssg";
2
+ type ToSsgOptions = NonNullable<Parameters<typeof toSSG>[2]>;
3
+ export type SsgRunnerOptions = {
4
+ readonly app: Parameters<typeof toSSG>[0];
5
+ readonly outDir: string;
6
+ readonly write: (path: string, data: string | Uint8Array) => Promise<void>;
7
+ readonly plugins?: ToSsgOptions["plugins"];
8
+ readonly extensionMap?: Record<string, string>;
9
+ readonly incremental: boolean;
10
+ };
11
+ export declare function runSsg(options: SsgRunnerOptions): Promise<import("hono/ssg").ToSSGResult>;
12
+ export {};
@@ -0,0 +1,14 @@
1
+ import { type ResolvedConfig } from "vite";
2
+ import type { SsgModule } from "./types.js";
3
+ export type StandaloneSsgBundle = {
4
+ readonly app: NonNullable<SsgModule["default"]>;
5
+ readonly module: SsgModule;
6
+ };
7
+ export declare function loadStandaloneSsgBundle(input: {
8
+ readonly root: string;
9
+ readonly entry: string;
10
+ readonly outputDirectory: string;
11
+ readonly clientOutputDirectory?: string;
12
+ readonly config?: Pick<ResolvedConfig, "define" | "oxc" | "plugins" | "resolve">;
13
+ }): Promise<StandaloneSsgBundle>;
14
+ export declare function isStandaloneSsgMode(mode: string): boolean;
@@ -1,4 +1,4 @@
1
- import type { 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";
@@ -21,11 +21,14 @@ type SsgHtmlInspectorPlugin = {
21
21
  export type SsgModule = {
22
22
  default: Parameters<typeof toSSG>[0];
23
23
  content?: {
24
- getManifest(): Promise<{
25
- generatedOutputs?: readonly {
24
+ getManifest(): Promise<ContentManifest & {
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;
@@ -54,6 +57,9 @@ export type SsgModule = {
54
57
  removedOutputCount: number;
55
58
  unchangedOutputCount: number;
56
59
  }>;
60
+ getProvenance(): BuildProvenance | undefined;
61
+ recordFinalHtmlDiagnostics?(diagnostics: readonly Diagnostic[]): void;
62
+ attachFinalOutputArtifacts(buildId: string, fingerprints: Readonly<Record<string, string>>, cacheHits: ReadonlySet<string>): Promise<void>;
57
63
  };
58
64
  config?: {
59
65
  plugins?: readonly SsgHtmlInspectorPlugin[];
@@ -1,5 +1,5 @@
1
- import { toSSG } from "hono/ssg";
2
- import { type ConfigEnv, type Plugin } from "vite";
1
+ import type { toSSG } from "hono/ssg";
2
+ import type { ConfigEnv, Plugin } from "vite";
3
3
  export { emptyBuildOutputDirectory } from "./ssg/build_output.js";
4
4
  export { createNoChangeFastPathOutputMetrics, decideOutputCacheRejection, loadOutputCache, saveOutputCache, verifyNoChangeFastPath, } from "./ssg/output_cache.js";
5
5
  export type { NoChangeFastPathOutputMetrics, NoChangeFastPathResult, OutputCacheDecision, OutputCacheRejectionReason, } from "./ssg/types.js";
@@ -10,6 +10,7 @@ type HonoxApplicationOptions = {
10
10
  };
11
11
  onServerReady?: (urls: readonly string[]) => void | Promise<void>;
12
12
  restartOnChange?: readonly string[];
13
+ reuseClientBuild?: boolean;
13
14
  };
14
15
  export type ResolvedHonoxApplication = {
15
16
  config: ResolvedRiebeckiteConfig;
@@ -29,4 +30,8 @@ export declare class HonoxApplicationRootError extends Error {
29
30
  export declare function resolveHonoxApplication(options: ResolveHonoxApplicationOptions): Promise<ResolvedHonoxApplication>;
30
31
  export declare function startHonoxDevServer(options: HonoxApplicationOptions): Promise<void>;
31
32
  export declare function buildHonoxApplication(options: HonoxApplicationOptions): Promise<void>;
33
+ export declare function canReuseClientBuild(input: {
34
+ readonly root: string;
35
+ readonly outputDirectory: string;
36
+ }): Promise<boolean>;
32
37
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riebeckite/honox",
3
- "version": "0.0.35",
3
+ "version": "0.0.37",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -40,19 +40,21 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "@babel/parser": "^7.29.3",
43
- "@riebeckite/core": "0.0.35",
44
- "@riebeckite/diagnostics": "0.0.35",
45
- "@riebeckite/node": "0.0.35",
46
- "@riebeckite/plugin-color-mode": "0.0.35",
47
- "@riebeckite/spa": "0.0.35",
48
- "@riebeckite/ui": "0.0.35",
43
+ "@riebeckite/core": "0.0.37",
44
+ "@riebeckite/dev-inspector": "0.0.37",
45
+ "@riebeckite/node": "0.0.37",
46
+ "@riebeckite/plugin-color-mode": "0.0.37",
47
+ "@riebeckite/spa": "0.0.37",
48
+ "@riebeckite/ui": "0.0.37",
49
49
  "esbuild": "^0.28.2",
50
50
  "hono": "^4.12.25",
51
- "honox": "0.1.56",
51
+ "honox": "0.1.62",
52
52
  "vite": "^8.3.5"
53
53
  },
54
54
  "devDependencies": {
55
- "@riebeckite/test": "0.0.35",
55
+ "@d2lang/d2": "^0.1.34",
56
+ "@marp-team/marp-core": "^4.4.0",
57
+ "@riebeckite/test": "0.0.37",
56
58
  "tsx": "^4.22.4"
57
59
  },
58
60
  "publishConfig": {
@@ -89,6 +91,6 @@
89
91
  ],
90
92
  "scripts": {
91
93
  "build": "node ../../../scripts/build_package.mjs",
92
- "test": "node --import tsx --test \"test/*.test.ts\""
94
+ "test": "node --import tsx --test --test-concurrency=1 \"test/*.test.ts\""
93
95
  }
94
96
  }
package/style.css CHANGED
@@ -7,6 +7,10 @@
7
7
  box-sizing: border-box;
8
8
  }
9
9
 
10
+ html {
11
+ scrollbar-gutter: stable;
12
+ }
13
+
10
14
  body {
11
15
  margin: 0;
12
16
  }
@@ -266,7 +270,7 @@
266
270
 
267
271
  .rb-source-fallback > pre {
268
272
  overflow: auto;
269
- margin: 0 0.75rem 0.75rem;
273
+ margin: 0.25rem 0.75rem 0.75rem;
270
274
  padding: 0.75rem;
271
275
  border: 1px solid var(--rb-color-border);
272
276
  border-radius: 6px;
@@ -1,3 +0,0 @@
1
- import type { Plugin } from "vite";
2
- import type { ResolvedHonoxApplication } from "./vite_runner.js";
3
- export declare function riebeckiteDevelopmentInspector(getApplication: () => ResolvedHonoxApplication): Plugin;