@riebeckite/honox 0.0.38 → 0.0.39

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/README.md CHANGED
@@ -105,10 +105,10 @@ longer need `app/config.ts`, `app/content.ts`, or `app/constants/paths.ts`.
105
105
  ### `@riebeckite/honox/ui`
106
106
 
107
107
  Structural composition primitives only: `Article`, `ArticleLayout`,
108
- `ArticleHeader`, `ArticleContent`, `ArticleMeta`, `ArticleFooter`, `Sidebar`,
109
- and their public `*Props` types. They provide semantic HTML, stable `rb-*`
110
- styling hooks, and `class`/`className` composition; the site owns content,
111
- layout, islands, and CSS.
108
+ `ArticleHeader`, `ArticleContent`, `ArticleMeta`, `ArticleFooter`, `Sidebar`.
109
+ They provide semantic HTML, stable `rb-*` styling hooks, and
110
+ `class`/`className` composition; the site owns content, layout, islands, and
111
+ CSS. The `*Props` types are internal.
112
112
 
113
113
  ## See also
114
114
 
package/README_ja.md CHANGED
@@ -86,7 +86,7 @@ Plugin は generated Site が import する bootstrap module も提供します
86
86
 
87
87
  ### `@riebeckite/honox/ui`
88
88
 
89
- 構造を組み立てるための primitive のみを公開します。`Article`、`ArticleLayout`、`ArticleHeader`、`ArticleContent`、`ArticleMeta`、`ArticleFooter`、`Sidebar` と、対応する公開 `*Props` 型です。semantic な HTML、安定した `rb-*` のスタイルフック、`class` / `className` の合成だけを提供し、コンテンツ、レイアウト、island、CSS はサイトが所有します。
89
+ 構造を組み立てるための primitive のみを公開します。`Article`、`ArticleLayout`、`ArticleHeader`、`ArticleContent`、`ArticleMeta`、`ArticleFooter`、`Sidebar` です。semantic な HTML、安定した `rb-*` のスタイルフック、`class` / `className` の合成だけを提供し、コンテンツ、レイアウト、island、CSS はサイトが所有します。`*Props` 型は内部向けです。
90
90
 
91
91
  ## 関連資料
92
92
 
package/dist/index.js CHANGED
@@ -144,10 +144,11 @@ function resolveHonoxConfig(config, appRoot) {
144
144
  }
145
145
 
146
146
  // src/config_loader.ts
147
+ var riebeckiteConfigTemporaryDirectory = ".riebeckite-config-";
147
148
  async function loadRiebeckiteConfig(options) {
148
149
  const configFile = options.configFile ?? "riebeckite.config.ts";
149
150
  const temporaryDirectory = await fs3.mkdtemp(
150
- path4.join(options.configRoot, ".riebeckite-config-")
151
+ path4.join(options.configRoot, riebeckiteConfigTemporaryDirectory)
151
152
  );
152
153
  const outputFile = path4.join(temporaryDirectory, "config.mjs");
153
154
  try {
@@ -2445,6 +2446,8 @@ function createRiebeckiteSsg(options = {}) {
2445
2446
  import path11 from "node:path";
2446
2447
  import {
2447
2448
  invalidateDevelopmentInspector,
2449
+ invalidateRiebeckiteBridge,
2450
+ riebeckiteBridge,
2448
2451
  riebeckiteDevelopmentInspector
2449
2452
  } from "@riebeckite/dev-inspector";
2450
2453
 
@@ -2924,14 +2927,32 @@ async function findWorkspaceRoot2(configRoot) {
2924
2927
  async function startHonoxDevServer(options) {
2925
2928
  const root = path10.resolve(options.root);
2926
2929
  await withWorkingDirectory(root, async () => {
2927
- const server = await createServer({ root, server: options.server });
2930
+ const previousBridgeToken = process.env.RIEBECKITE_BRIDGE_TOKEN;
2931
+ if (options.bridgeToken) {
2932
+ process.env.RIEBECKITE_BRIDGE_TOKEN = options.bridgeToken;
2933
+ }
2934
+ const server = await (async () => {
2935
+ try {
2936
+ return await createServer({ root, server: options.server });
2937
+ } finally {
2938
+ if (previousBridgeToken === void 0) {
2939
+ delete process.env.RIEBECKITE_BRIDGE_TOKEN;
2940
+ } else {
2941
+ process.env.RIEBECKITE_BRIDGE_TOKEN = previousBridgeToken;
2942
+ }
2943
+ }
2944
+ })();
2928
2945
  const restartFiles = new Set(
2929
2946
  options.restartOnChange?.map((file) => path10.resolve(file))
2930
2947
  );
2931
2948
  if (restartFiles.size > 0) {
2932
2949
  server.watcher.add([...restartFiles]);
2933
2950
  server.watcher.on("change", (file) => {
2934
- if (restartFiles.has(path10.resolve(file))) void server.restart();
2951
+ if (!restartFiles.has(path10.resolve(file))) return;
2952
+ void (async () => {
2953
+ await options.onRestart?.();
2954
+ await server.restart();
2955
+ })();
2935
2956
  });
2936
2957
  }
2937
2958
  await server.listen(options.server?.port);
@@ -2958,6 +2979,11 @@ async function startHonoxDevServer(options) {
2958
2979
  async function buildHonoxApplication(options) {
2959
2980
  const root = path10.resolve(options.root);
2960
2981
  await withWorkingDirectory(root, async () => {
2982
+ const clientOutputDirectory = path10.join(
2983
+ root,
2984
+ ".riebeckite",
2985
+ "build-output-client"
2986
+ );
2961
2987
  if (!options.reuseClientBuild) {
2962
2988
  await runTraced(
2963
2989
  options.tracer,
@@ -2965,10 +2991,35 @@ async function buildHonoxApplication(options) {
2965
2991
  () => build2({ root, mode: "client" })
2966
2992
  );
2967
2993
  }
2994
+ const stableClientDirectory = path10.join(
2995
+ root,
2996
+ ".riebeckite",
2997
+ "client-build"
2998
+ );
2999
+ await fs7.rm(stableClientDirectory, { recursive: true, force: true });
3000
+ const sourceManifest = options.reuseClientBuild ? path10.join(
3001
+ path10.resolve(options.outputDirectory ?? path10.join(root, "dist")),
3002
+ ".vite",
3003
+ "manifest.json"
3004
+ ) : path10.join(clientOutputDirectory, ".vite", "manifest.json");
3005
+ try {
3006
+ await fs7.mkdir(path10.join(stableClientDirectory, ".vite"), {
3007
+ recursive: true
3008
+ });
3009
+ await fs7.copyFile(
3010
+ sourceManifest,
3011
+ path10.join(stableClientDirectory, ".vite", "manifest.json")
3012
+ );
3013
+ } catch (error) {
3014
+ if (error.code !== "ENOENT") throw error;
3015
+ await fs7.rm(stableClientDirectory, { recursive: true, force: true });
3016
+ }
2968
3017
  await runTraced(
2969
3018
  options.tracer,
2970
3019
  "integration.honox.server_build",
2971
- () => buildServerWithMetrics(root, options.tracer)
3020
+ () => buildServerWithMetrics(root, options.tracer, [
3021
+ createClientManifestPlugin(root, stableClientDirectory)
3022
+ ])
2972
3023
  );
2973
3024
  });
2974
3025
  }
@@ -2986,9 +3037,9 @@ async function canReuseClientBuild(input) {
2986
3037
  expectedInventory: cache.finalOutputInventory ?? {}
2987
3038
  });
2988
3039
  }
2989
- async function buildServerWithMetrics(root, tracer) {
3040
+ async function buildServerWithMetrics(root, tracer, plugins = []) {
2990
3041
  if (!tracer) {
2991
- await build2({ root });
3042
+ await build2({ root, plugins });
2992
3043
  return;
2993
3044
  }
2994
3045
  const previousMetricsFile = process.env.RIEBECKITE_SSG_METRICS_FILE;
@@ -2997,7 +3048,7 @@ async function buildServerWithMetrics(root, tracer) {
2997
3048
  if (!previousMetricsFile)
2998
3049
  process.env.RIEBECKITE_SSG_METRICS_FILE = metricsFile;
2999
3050
  try {
3000
- await build2({ root });
3051
+ await build2({ root, plugins });
3001
3052
  await reportSsgTimings(tracer, metricsFile);
3002
3053
  } finally {
3003
3054
  if (previousMetricsFile === void 0) {
@@ -3159,7 +3210,10 @@ function riebeckite(options = {}, onApplicationResolved) {
3159
3210
  },
3160
3211
  server: {
3161
3212
  watch: {
3162
- ignored: ["**/.riebeckite/**"]
3213
+ ignored: [
3214
+ "**/.riebeckite/**",
3215
+ `**/${riebeckiteConfigTemporaryDirectory}*/**`
3216
+ ]
3163
3217
  }
3164
3218
  },
3165
3219
  resolve: {
@@ -3178,7 +3232,10 @@ function riebeckite(options = {}, onApplicationResolved) {
3178
3232
  appRoot: () => requireApplication(application).appRoot,
3179
3233
  contentRoot: () => requireApplication(application).contentRoot,
3180
3234
  exclude: () => getConfig().content.exclude ?? [],
3181
- onInvalidate: invalidateDevelopmentInspector
3235
+ onInvalidate(server) {
3236
+ invalidateDevelopmentInspector(server);
3237
+ invalidateRiebeckiteBridge(server);
3238
+ }
3182
3239
  }),
3183
3240
  riebeckiteDevelopmentInspector(() => requireApplication(application), {
3184
3241
  async getSnapshot(server) {
@@ -3187,6 +3244,19 @@ function riebeckite(options = {}, onApplicationResolved) {
3187
3244
  const module = await loadContentModule(server, appRoot);
3188
3245
  return module.content?.getCompletedBuildSnapshot?.();
3189
3246
  }
3247
+ }),
3248
+ riebeckiteBridge({
3249
+ token: options.bridgeToken ?? process.env.RIEBECKITE_BRIDGE_TOKEN,
3250
+ mutationToken: process.env.RIEBECKITE_BRIDGE_MUTATION_TOKEN,
3251
+ mutationApprovalToken: process.env.RIEBECKITE_BRIDGE_MUTATION_APPROVAL_TOKEN,
3252
+ contentRoot: () => requireApplication(application).contentRoot,
3253
+ publicOrigin: () => getConfig().site.baseUrl || void 0,
3254
+ async getSnapshot(server) {
3255
+ const { appRoot } = requireApplication(application);
3256
+ if (!isContentModuleLoaded(server, appRoot)) return void 0;
3257
+ const module = await loadContentModule(server, appRoot);
3258
+ return module.content?.getCompletedBuildSnapshot?.();
3259
+ }
3190
3260
  })
3191
3261
  ];
3192
3262
  }
package/dist/server.js CHANGED
@@ -67,7 +67,7 @@ async function riebeckiteSsgParams(content, parameter = "slug") {
67
67
  if (changeSet.fullRegenerationRequired || process.env.RIEBECKITE_SSG_FULL_REGENERATION === "1") {
68
68
  return [
69
69
  ...manifest.publicEntries.filter((entry) => entry.permalink !== "/").map((entry) => ({ [parameter]: entry.permalink.replace(/^\/+/, "") })),
70
- ...[...manifest.publicRedirects.keys()].filter((path) => path !== "/").map((path) => ({ [parameter]: path.replace(/^\/+/, "") })),
70
+ ...redirectSsgPaths(manifest).filter((path) => path !== "/").map((path) => ({ [parameter]: path.replace(/^\/+/, "") })),
71
71
  ...await pluginPageSsgParams(content, parameter)
72
72
  ];
73
73
  }
@@ -75,7 +75,7 @@ async function riebeckiteSsgParams(content, parameter = "slug") {
75
75
  changeSet.affected.filter((output) => output.kind !== "generated").map((output) => output.path)
76
76
  );
77
77
  const contentParams = manifest.publicEntries.filter((entry) => affected.has(routeOutputPath(entry.permalink))).filter((entry) => entry.permalink !== "/").map((entry) => ({ [parameter]: entry.permalink.replace(/^\/+/, "") }));
78
- const redirectParams = [...manifest.publicRedirects.keys()].filter((path) => affected.has(routeOutputPath(path))).filter((path) => path !== "/").map((path) => ({ [parameter]: path.replace(/^\/+/, "") }));
78
+ const redirectParams = redirectSsgPaths(manifest).filter((path) => affected.has(routeOutputPath(path))).filter((path) => path !== "/").map((path) => ({ [parameter]: path.replace(/^\/+/, "") }));
79
79
  const pluginPageParams = (await content.getPagePaths()).filter((path) => affected.has(routeOutputPath(path))).filter((path) => path !== "/").map((path) => ({ [parameter]: path.replace(/^\/+/, "") }));
80
80
  return [...contentParams, ...redirectParams, ...pluginPageParams];
81
81
  }
@@ -118,6 +118,16 @@ function normalizeRequestPath(pathname) {
118
118
  const path = `/${segments.join("/")}`;
119
119
  return trailingSlash ? `${path}/` : path;
120
120
  }
121
+ function redirectSsgPaths(manifest) {
122
+ const paths = [];
123
+ for (const [path, redirect] of manifest.publicRedirects) {
124
+ const permalink = manifest.bySlug.get(redirect.slug)?.permalink;
125
+ if (permalink && htmlOutputPath(permalink) === routeOutputPath(path))
126
+ continue;
127
+ paths.push(path);
128
+ }
129
+ return paths;
130
+ }
121
131
  function routeOutputPath(pathname) {
122
132
  return htmlOutputPath(pathname);
123
133
  }
@@ -334,6 +344,7 @@ function createContentRoute(options) {
334
344
  parameter
335
345
  );
336
346
  if (resolved.kind === "response") return resolved.response;
347
+ applySeoContext(c, options.config, resolved);
337
348
  if (resolved.kind === "page")
338
349
  return c.render(/* @__PURE__ */ jsx2(PageBody, { html: resolved.page.body }));
339
350
  return renderContent(c, options, resolved.entry, resolved.post);
@@ -344,11 +355,42 @@ function createHomeRoute(options) {
344
355
  return createRoute(async (c) => {
345
356
  const resolved = await resolveRiebeckiteHomeRequest(c, options.content);
346
357
  if (resolved.kind === "response") return resolved.response;
358
+ applySeoContext(c, options.config, resolved);
347
359
  if (resolved.kind === "page")
348
360
  return c.render(/* @__PURE__ */ jsx2(PageBody, { html: resolved.page.body }));
349
361
  return renderContent(c, options, resolved.entry, resolved.post);
350
362
  });
351
363
  }
364
+ function applySeoContext(c, config, resolved) {
365
+ const provider = config.plugins.find((plugin) => plugin.seo)?.seo;
366
+ if (!provider) return;
367
+ if (resolved.kind === "content") {
368
+ c.set(
369
+ "seo",
370
+ provider.buildArticleSeo(
371
+ config,
372
+ resolved.entry.permalink,
373
+ resolved.post,
374
+ c.get("headTags"),
375
+ c.get("htmlLanguage")
376
+ )
377
+ );
378
+ return;
379
+ }
380
+ c.set(
381
+ "seo",
382
+ provider.buildWebsiteSeo(
383
+ config,
384
+ {
385
+ title: resolved.page.title ?? config.site.title,
386
+ description: resolved.page.description,
387
+ path: resolved.page.pathname
388
+ },
389
+ resolved.page.headTags,
390
+ resolved.page.language
391
+ )
392
+ );
393
+ }
352
394
  async function renderContent(c, options, entry, post) {
353
395
  const manifest = await options.content.getRequestManifest();
354
396
  const view = createPublicContentView(manifest);
@@ -1,4 +1,5 @@
1
1
  import type { ResolvedRiebeckiteConfig } from "@riebeckite/core";
2
+ export declare const riebeckiteConfigTemporaryDirectory = ".riebeckite-config-";
2
3
  export type RiebeckiteConfigLoaderOptions = {
3
4
  configRoot: string;
4
5
  configFile?: string;
@@ -1,4 +1,4 @@
1
- import { type ResolvedConfig } from "vite";
1
+ import { type Plugin, type ResolvedConfig } from "vite";
2
2
  import type { SsgModule } from "./types.js";
3
3
  export type StandaloneSsgBundle = {
4
4
  readonly app: NonNullable<SsgModule["default"]>;
@@ -11,4 +11,5 @@ 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 createClientManifestPlugin(root: string, clientOutputDirectory: string): Plugin;
14
15
  export declare function isStandaloneSsgMode(mode: string): boolean;
@@ -89,6 +89,7 @@ type PluginHeadTagsProps = {
89
89
  export declare function PluginHeadTags(props: PluginHeadTagsProps): import("hono/jsx/jsx-dev-runtime").JSX.Element;
90
90
  type RiebeckiteHeadProps = {
91
91
  title?: string;
92
+ seo?: SeoMetadata;
92
93
  headTags?: readonly PluginHeadTag[];
93
94
  faviconHref?: string | null;
94
95
  colorModeScript?: boolean;
@@ -157,7 +157,16 @@ function RiebeckiteHead(props) {
157
157
  return /* @__PURE__ */ jsxs(Fragment, { children: [
158
158
  /* @__PURE__ */ jsx("meta", { charset: "utf-8" }),
159
159
  /* @__PURE__ */ jsx("meta", { name: "viewport", content: "width=device-width, initial-scale=1.0" }),
160
- /* @__PURE__ */ jsx("title", { children: props.title ?? site?.config.site.title }),
160
+ props.seo ? /* @__PURE__ */ jsx(
161
+ SeoHead,
162
+ {
163
+ seo: props.seo,
164
+ siteTitle: site?.config.site.title ?? "",
165
+ author: site?.config.site.author,
166
+ ogLocale: ogLocale(site?.config.site.locale),
167
+ twitterSite: site?.config.site.twitterSite
168
+ }
169
+ ) : /* @__PURE__ */ jsx("title", { children: props.title ?? site?.config.site.title }),
161
170
  faviconHref ? /* @__PURE__ */ jsx("link", { rel: "icon", href: faviconHref }) : null,
162
171
  colorModeScript ? /* @__PURE__ */ jsx(ColorModeScript, {}) : null,
163
172
  stylesheets.map((href) => /* @__PURE__ */ jsx(Link, { href, rel: "stylesheet", prod: props.prod }, href)),
@@ -168,6 +177,12 @@ function RiebeckiteHead(props) {
168
177
  props.children
169
178
  ] });
170
179
  }
180
+ function ogLocale(locale) {
181
+ if (!locale) return void 0;
182
+ if (/^ja(?:$|[-_])/i.test(locale)) return "ja_JP";
183
+ if (/^en(?:$|[-_])/i.test(locale)) return "en_US";
184
+ return locale.replace("-", "_");
185
+ }
171
186
  function SeoHead(props) {
172
187
  const { seo } = props;
173
188
  const twitterCard = seo.imageUrl ? "summary_large_image" : "summary";
@@ -6,6 +6,7 @@ export type RiebeckiteIntegrationOptions = {
6
6
  workspaceRoot?: string;
7
7
  appRoot?: string;
8
8
  configFile?: string;
9
+ bridgeToken?: string;
9
10
  };
10
11
  /**
11
12
  * SSR externals Riebeckite's own runtime requires the application to leave
@@ -9,8 +9,11 @@ type HonoxApplicationOptions = {
9
9
  port?: number;
10
10
  };
11
11
  onServerReady?: (urls: readonly string[]) => void | Promise<void>;
12
+ onRestart?: () => void | Promise<void>;
12
13
  restartOnChange?: readonly string[];
13
14
  reuseClientBuild?: boolean;
15
+ bridgeToken?: string;
16
+ outputDirectory?: string;
14
17
  };
15
18
  export type ResolvedHonoxApplication = {
16
19
  config: ResolvedRiebeckiteConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riebeckite/honox",
3
- "version": "0.0.38",
3
+ "version": "0.0.39",
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.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",
43
+ "@riebeckite/core": "0.0.39",
44
+ "@riebeckite/dev-inspector": "0.0.39",
45
+ "@riebeckite/node": "0.0.39",
46
+ "@riebeckite/plugin-color-mode": "0.0.39",
47
+ "@riebeckite/spa": "0.0.39",
48
+ "@riebeckite/ui": "0.0.39",
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.38",
57
+ "@riebeckite/test": "0.0.39",
58
58
  "tsx": "^4.22.4"
59
59
  },
60
60
  "publishConfig": {
@@ -91,6 +91,6 @@
91
91
  ],
92
92
  "scripts": {
93
93
  "build": "node ../../../scripts/build_package.mjs",
94
- "test": "node --import tsx --test --test-concurrency=1 \"test/*.test.ts\""
94
+ "test": "node --max-old-space-size=4096 --import tsx --test --test-concurrency=1 \"test/*.test.ts\""
95
95
  }
96
96
  }