@riebeckite/honox 0.1.0 → 0.3.0
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 +128 -62
- package/dist/server.js +36 -40
- package/dist/src/client_module.d.ts +7 -1
- package/dist/src/content_route.d.ts +37 -3
- package/dist/src/vite_plugin.d.ts +1 -1
- package/package.json +14 -13
- package/dist/src/client_module_part1.d.ts +0 -5
- package/dist/src/client_module_part2.d.ts +0 -2
- package/dist/src/content_route_part1.d.ts +0 -37
- package/dist/src/content_route_part2.d.ts +0 -8
package/dist/index.js
CHANGED
|
@@ -509,7 +509,7 @@ function isRendererModule(filePath, rendererPath) {
|
|
|
509
509
|
import { createHash as createHash2 } from "node:crypto";
|
|
510
510
|
import { readdir, readFile } from "node:fs/promises";
|
|
511
511
|
import { dirname, join, relative as relative2 } from "node:path";
|
|
512
|
-
import { performance } from "node:perf_hooks";
|
|
512
|
+
import { performance as performance2 } from "node:perf_hooks";
|
|
513
513
|
|
|
514
514
|
// src/ssg/file_system.ts
|
|
515
515
|
import { relative, resolve } from "node:path";
|
|
@@ -640,11 +640,11 @@ async function fingerprintOutputDirectory(directory, relativeDirectory = "", met
|
|
|
640
640
|
inventory[relativePath] = knownChecksum;
|
|
641
641
|
continue;
|
|
642
642
|
}
|
|
643
|
-
const hashedAt =
|
|
643
|
+
const hashedAt = performance2.now();
|
|
644
644
|
const content = await readFile(file);
|
|
645
645
|
inventory[relativePath] = fingerprintOutputContent(content);
|
|
646
646
|
if (metrics) {
|
|
647
|
-
metrics.outputHashValidationDurationMs +=
|
|
647
|
+
metrics.outputHashValidationDurationMs += performance2.now() - hashedAt;
|
|
648
648
|
metrics.outputFilesHashed += 1;
|
|
649
649
|
metrics.outputBytesHashed += content.length;
|
|
650
650
|
}
|
|
@@ -1066,7 +1066,7 @@ import { resolve as resolve3 } from "node:path";
|
|
|
1066
1066
|
|
|
1067
1067
|
// src/ssg/output_cache_decision.ts
|
|
1068
1068
|
import { join as join4 } from "node:path";
|
|
1069
|
-
import { performance as
|
|
1069
|
+
import { performance as performance4 } from "node:perf_hooks";
|
|
1070
1070
|
|
|
1071
1071
|
// src/ssg/output_cache_fastpath.ts
|
|
1072
1072
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
@@ -1159,23 +1159,23 @@ import { join as join3 } from "node:path";
|
|
|
1159
1159
|
|
|
1160
1160
|
// src/ssg/runtime_metrics.ts
|
|
1161
1161
|
import { writeFile } from "node:fs/promises";
|
|
1162
|
-
import { performance as
|
|
1162
|
+
import { performance as performance3 } from "node:perf_hooks";
|
|
1163
1163
|
async function measure(timingsMs, name, fn) {
|
|
1164
1164
|
if (!timingsMs) return await fn();
|
|
1165
|
-
const start =
|
|
1165
|
+
const start = performance3.now();
|
|
1166
1166
|
try {
|
|
1167
1167
|
return await fn();
|
|
1168
1168
|
} finally {
|
|
1169
|
-
timingsMs[name] = (timingsMs[name] ?? 0) +
|
|
1169
|
+
timingsMs[name] = (timingsMs[name] ?? 0) + performance3.now() - start;
|
|
1170
1170
|
}
|
|
1171
1171
|
}
|
|
1172
1172
|
function measureSync(timingsMs, name, fn) {
|
|
1173
1173
|
if (!timingsMs) return fn();
|
|
1174
|
-
const start =
|
|
1174
|
+
const start = performance3.now();
|
|
1175
1175
|
try {
|
|
1176
1176
|
return fn();
|
|
1177
1177
|
} finally {
|
|
1178
|
-
timingsMs[name] = (timingsMs[name] ?? 0) +
|
|
1178
|
+
timingsMs[name] = (timingsMs[name] ?? 0) + performance3.now() - start;
|
|
1179
1179
|
}
|
|
1180
1180
|
}
|
|
1181
1181
|
async function writeSsgOutputMetrics(metrics) {
|
|
@@ -1463,7 +1463,7 @@ async function verifyNoChangeFastPath(input) {
|
|
|
1463
1463
|
cache.finalOutputInventory,
|
|
1464
1464
|
cache.finalOutputStats
|
|
1465
1465
|
);
|
|
1466
|
-
const inventoryStartedAt =
|
|
1466
|
+
const inventoryStartedAt = performance4.now();
|
|
1467
1467
|
const currentInventory = await fingerprintOutputDirectory(
|
|
1468
1468
|
input.outputDirectory,
|
|
1469
1469
|
"",
|
|
@@ -1471,7 +1471,7 @@ async function verifyNoChangeFastPath(input) {
|
|
|
1471
1471
|
knownChecksums
|
|
1472
1472
|
);
|
|
1473
1473
|
if (input.metrics)
|
|
1474
|
-
input.metrics.outputInventoryValidationDurationMs +=
|
|
1474
|
+
input.metrics.outputInventoryValidationDurationMs += performance4.now() - inventoryStartedAt;
|
|
1475
1475
|
if (!inventoriesEqual(cache.finalOutputInventory, currentInventory)) {
|
|
1476
1476
|
return { used: false, blockReason: "output-inventory-mismatch" };
|
|
1477
1477
|
}
|
|
@@ -3077,13 +3077,16 @@ function createRiebeckiteSsg(options = {}) {
|
|
|
3077
3077
|
|
|
3078
3078
|
// src/vite_plugin.ts
|
|
3079
3079
|
import path13 from "node:path";
|
|
3080
|
+
import { createMutationPathPolicy, resolveAiIntegration } from "@riebeckite/ai";
|
|
3080
3081
|
import {
|
|
3081
3082
|
invalidateDevelopmentInspector,
|
|
3082
3083
|
invalidateRiebeckiteBridge,
|
|
3083
3084
|
riebeckiteBridge,
|
|
3084
3085
|
riebeckiteDevelopmentInspector
|
|
3085
3086
|
} from "@riebeckite/dev-inspector";
|
|
3086
|
-
import {
|
|
3087
|
+
import {
|
|
3088
|
+
mergeConfig
|
|
3089
|
+
} from "vite";
|
|
3087
3090
|
|
|
3088
3091
|
// src/asset_entries.ts
|
|
3089
3092
|
import fs6 from "node:fs";
|
|
@@ -3159,7 +3162,28 @@ function isNotFoundError3(error) {
|
|
|
3159
3162
|
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
3160
3163
|
}
|
|
3161
3164
|
|
|
3162
|
-
// src/
|
|
3165
|
+
// src/client_module.ts
|
|
3166
|
+
var clientModuleId = "virtual:riebeckite/client";
|
|
3167
|
+
var resolvedClientModuleId = `\0${clientModuleId}`;
|
|
3168
|
+
function riebeckiteClientModule(getConfig, ensure = async () => {
|
|
3169
|
+
}) {
|
|
3170
|
+
let development = false;
|
|
3171
|
+
return {
|
|
3172
|
+
name: "riebeckite-client-module",
|
|
3173
|
+
config(_config, environment) {
|
|
3174
|
+
development = environment.command === "serve";
|
|
3175
|
+
},
|
|
3176
|
+
resolveId(id) {
|
|
3177
|
+
if (id === clientModuleId) return resolvedClientModuleId;
|
|
3178
|
+
return null;
|
|
3179
|
+
},
|
|
3180
|
+
async load(id) {
|
|
3181
|
+
await ensure();
|
|
3182
|
+
if (id !== resolvedClientModuleId) return null;
|
|
3183
|
+
return await createClientModule(getConfig(), development);
|
|
3184
|
+
}
|
|
3185
|
+
};
|
|
3186
|
+
}
|
|
3163
3187
|
async function createClientModule(config, development) {
|
|
3164
3188
|
const { serializePublicClientConfig } = await import("@riebeckite/core");
|
|
3165
3189
|
const imports = [];
|
|
@@ -3189,6 +3213,10 @@ async function createClientModule(config, development) {
|
|
|
3189
3213
|
}
|
|
3190
3214
|
}
|
|
3191
3215
|
const hasRuntimes = runtimeEntries.size > 0;
|
|
3216
|
+
const uiConfig = {
|
|
3217
|
+
...config.ui?.locale === void 0 ? {} : { locale: config.ui.locale },
|
|
3218
|
+
...config.ui?.labels === void 0 ? {} : { labels: config.ui.labels }
|
|
3219
|
+
};
|
|
3192
3220
|
imports.push('import { ClientLifecycle } from "@riebeckite/core/client";');
|
|
3193
3221
|
if (interactiveMarkdownComponents.length > 0) {
|
|
3194
3222
|
imports.push('import { hydrateRoot } from "hono/jsx/dom/client";');
|
|
@@ -3283,6 +3311,7 @@ function createPluginRuntimeHost(root, ids) {
|
|
|
3283
3311
|
` : "";
|
|
3284
3312
|
return `${imports.join("\n")}
|
|
3285
3313
|
|
|
3314
|
+
globalThis.__riebeckiteUi = ${serializePublicClientConfig(uiConfig)};
|
|
3286
3315
|
const lifecycle = new ClientLifecycle();
|
|
3287
3316
|
${runtimeSupport}const clientModuleDevelopment = ${development ? "true" : "false"};
|
|
3288
3317
|
const conditionalInitializerLoads = new Map();
|
|
@@ -3396,29 +3425,6 @@ export async function disposeRiebeckiteClient() {
|
|
|
3396
3425
|
`;
|
|
3397
3426
|
}
|
|
3398
3427
|
|
|
3399
|
-
// src/client_module_part1.ts
|
|
3400
|
-
var clientModuleId = "virtual:riebeckite/client";
|
|
3401
|
-
var resolvedClientModuleId = `\0${clientModuleId}`;
|
|
3402
|
-
function riebeckiteClientModule(getConfig, ensure = async () => {
|
|
3403
|
-
}) {
|
|
3404
|
-
let development = false;
|
|
3405
|
-
return {
|
|
3406
|
-
name: "riebeckite-client-module",
|
|
3407
|
-
config(_config, environment) {
|
|
3408
|
-
development = environment.command === "serve";
|
|
3409
|
-
},
|
|
3410
|
-
resolveId(id) {
|
|
3411
|
-
if (id === clientModuleId) return resolvedClientModuleId;
|
|
3412
|
-
return null;
|
|
3413
|
-
},
|
|
3414
|
-
async load(id) {
|
|
3415
|
-
await ensure();
|
|
3416
|
-
if (id !== resolvedClientModuleId) return null;
|
|
3417
|
-
return await createClientModule(getConfig(), development);
|
|
3418
|
-
}
|
|
3419
|
-
};
|
|
3420
|
-
}
|
|
3421
|
-
|
|
3422
3428
|
// src/content_watch.ts
|
|
3423
3429
|
import path9 from "node:path";
|
|
3424
3430
|
|
|
@@ -3591,9 +3597,11 @@ function riebeckiteContentWatch(options) {
|
|
|
3591
3597
|
if (timer) clearTimeout(timer);
|
|
3592
3598
|
timer = setTimeout(() => {
|
|
3593
3599
|
timer = void 0;
|
|
3594
|
-
void invalidateApplicationRuntime(server, appRoot)
|
|
3595
|
-
|
|
3596
|
-
|
|
3600
|
+
void invalidateApplicationRuntime(server, appRoot).catch(() => {
|
|
3601
|
+
}).then(() => {
|
|
3602
|
+
options.onInvalidate?.(server);
|
|
3603
|
+
server.hot.send({ type: "full-reload" });
|
|
3604
|
+
});
|
|
3597
3605
|
}, CONTENT_RELOAD_DEBOUNCE_MS);
|
|
3598
3606
|
};
|
|
3599
3607
|
server.httpServer?.once("close", () => {
|
|
@@ -3988,7 +3996,7 @@ async function hasViteConfig(directory) {
|
|
|
3988
3996
|
}
|
|
3989
3997
|
|
|
3990
3998
|
// src/vite_plugin.ts
|
|
3991
|
-
function riebeckite(options = {}
|
|
3999
|
+
function riebeckite(options = {}) {
|
|
3992
4000
|
let resolvedConfig;
|
|
3993
4001
|
let application;
|
|
3994
4002
|
let contentVitePlugins = [];
|
|
@@ -4018,7 +4026,6 @@ function riebeckite(options = {}, onApplicationResolved) {
|
|
|
4018
4026
|
}) ?? []
|
|
4019
4027
|
);
|
|
4020
4028
|
application = resolvedApplication;
|
|
4021
|
-
onApplicationResolved?.(resolvedApplication);
|
|
4022
4029
|
await writeRiebeckiteAssetEntries(resolvedConfig, {
|
|
4023
4030
|
frameworkStyles: path13.join(
|
|
4024
4031
|
applicationAppRoot,
|
|
@@ -4088,7 +4095,7 @@ function riebeckite(options = {}, onApplicationResolved) {
|
|
|
4088
4095
|
() => requireApplication(application),
|
|
4089
4096
|
ensureApplication
|
|
4090
4097
|
),
|
|
4091
|
-
riebeckiteContentWarmup(options.warmContent ??
|
|
4098
|
+
riebeckiteContentWarmup(options.warmContent ?? true, ensureApplication),
|
|
4092
4099
|
riebeckiteContentAssets({
|
|
4093
4100
|
appRoot: async () => (await ensureApplication()).appRoot,
|
|
4094
4101
|
contentRoot: async () => (await ensureApplication()).contentRoot
|
|
@@ -4123,6 +4130,14 @@ function riebeckite(options = {}, onApplicationResolved) {
|
|
|
4123
4130
|
return contentFormatRegistryFactory(getConfig().plugins);
|
|
4124
4131
|
},
|
|
4125
4132
|
publicOrigin: () => getConfig().site.baseUrl || void 0,
|
|
4133
|
+
isMutationPathAllowed: () => createMutationPathPolicy(
|
|
4134
|
+
resolveAiIntegration(getConfig().integrations?.ai).mutationPolicy
|
|
4135
|
+
),
|
|
4136
|
+
project: () => ({
|
|
4137
|
+
contentDirectory: getConfig().content.directory,
|
|
4138
|
+
locale: getConfig().site.locale,
|
|
4139
|
+
mutationPolicy: resolveAiIntegration(getConfig().integrations?.ai).mutationPolicy
|
|
4140
|
+
}),
|
|
4126
4141
|
async getSnapshot(server) {
|
|
4127
4142
|
const { appRoot } = requireApplication(application);
|
|
4128
4143
|
if (!isContentModuleLoaded(server, appRoot)) return void 0;
|
|
@@ -4140,20 +4155,74 @@ function riebeckiteContentWarmup(enabled, getApplication) {
|
|
|
4140
4155
|
configureServer(server) {
|
|
4141
4156
|
if (!enabled || !server.httpServer) return;
|
|
4142
4157
|
server.httpServer.once("listening", () => {
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
async (module) => await module.content?.getManifest?.()
|
|
4147
|
-
);
|
|
4148
|
-
})().catch((error) => {
|
|
4149
|
-
server.config.logger.error("Riebeckite content warmup failed.", {
|
|
4150
|
-
error: error instanceof Error ? error : new Error(String(error))
|
|
4151
|
-
});
|
|
4152
|
-
});
|
|
4158
|
+
const origin = server.resolvedUrls?.local?.[0];
|
|
4159
|
+
if (origin) warmFirstPage(server, origin);
|
|
4160
|
+
else warmContentManifest(server, getApplication);
|
|
4153
4161
|
});
|
|
4154
4162
|
}
|
|
4155
4163
|
};
|
|
4156
4164
|
}
|
|
4165
|
+
function warmContentManifest(server, getApplication) {
|
|
4166
|
+
void (async () => {
|
|
4167
|
+
const { appRoot } = await getApplication();
|
|
4168
|
+
const module = await loadContentModule(server, appRoot);
|
|
4169
|
+
await module.content?.getManifest?.();
|
|
4170
|
+
})().catch((error) => {
|
|
4171
|
+
server.config.logger.error("Riebeckite content warmup failed.", {
|
|
4172
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
4173
|
+
});
|
|
4174
|
+
});
|
|
4175
|
+
}
|
|
4176
|
+
function warmFirstPage(server, origin) {
|
|
4177
|
+
const logger = server.config.logger;
|
|
4178
|
+
const originalInfo = logger.info.bind(logger);
|
|
4179
|
+
let banner;
|
|
4180
|
+
logger.info = (message, options) => {
|
|
4181
|
+
const plain = message.split(`${String.fromCharCode(27)}[`).map((part) => part.replace(/^[0-9;]*m/, "")).join("");
|
|
4182
|
+
if (plain.includes("VITE v") && plain.includes("ready in")) {
|
|
4183
|
+
banner = () => originalInfo(message, options);
|
|
4184
|
+
return;
|
|
4185
|
+
}
|
|
4186
|
+
originalInfo(message, options);
|
|
4187
|
+
};
|
|
4188
|
+
const printUrls = server.printUrls.bind(server);
|
|
4189
|
+
server.printUrls = () => {
|
|
4190
|
+
};
|
|
4191
|
+
const quiet = process.env.RIEBECKITE_DEV_INDICATOR === "1" || process.env.RIEBECKITE_MANAGED_DEV_CONTROL_FD !== void 0;
|
|
4192
|
+
const startedAt = performance.now();
|
|
4193
|
+
const elapsed = () => `${((performance.now() - startedAt) / 1e3).toFixed(1)}s`;
|
|
4194
|
+
const progress = (message) => logger.info(message, { clear: true });
|
|
4195
|
+
if (!quiet) progress(`riebeckite: preparing the first page (${elapsed()})`);
|
|
4196
|
+
const ticker = quiet ? void 0 : setInterval(() => {
|
|
4197
|
+
progress(`riebeckite: preparing the first page (${elapsed()})`);
|
|
4198
|
+
}, 5e3);
|
|
4199
|
+
ticker?.unref();
|
|
4200
|
+
void waitForDevWarmup(origin).then((status) => {
|
|
4201
|
+
if (ticker) clearInterval(ticker);
|
|
4202
|
+
banner?.();
|
|
4203
|
+
printUrls();
|
|
4204
|
+
if (status === void 0) {
|
|
4205
|
+
logger.error(`riebeckite: dev server did not respond (${elapsed()})`);
|
|
4206
|
+
return;
|
|
4207
|
+
}
|
|
4208
|
+
const suffix = status >= 400 ? ` (HTTP ${status})` : "";
|
|
4209
|
+
if (!quiet)
|
|
4210
|
+
progress(`riebeckite: ready at ${origin}${suffix} (${elapsed()})`);
|
|
4211
|
+
});
|
|
4212
|
+
}
|
|
4213
|
+
async function waitForDevWarmup(origin, timeoutMs = 3e5) {
|
|
4214
|
+
const deadline = performance.now() + timeoutMs;
|
|
4215
|
+
while (performance.now() < deadline) {
|
|
4216
|
+
try {
|
|
4217
|
+
return (await fetch(origin, { redirect: "manual" })).status;
|
|
4218
|
+
} catch {
|
|
4219
|
+
}
|
|
4220
|
+
await new Promise((resolve7) => {
|
|
4221
|
+
setTimeout(resolve7, 100).unref();
|
|
4222
|
+
});
|
|
4223
|
+
}
|
|
4224
|
+
return void 0;
|
|
4225
|
+
}
|
|
4157
4226
|
function contentBareImportResolver(getApplication, ensure) {
|
|
4158
4227
|
return {
|
|
4159
4228
|
name: "riebeckite-content-bare-imports",
|
|
@@ -4251,18 +4320,14 @@ function requireApplication(application) {
|
|
|
4251
4320
|
}
|
|
4252
4321
|
function riebeckiteVite(options = {}) {
|
|
4253
4322
|
const { ssg, ssrExternals, ...integration } = options;
|
|
4254
|
-
const fallbackSiteRoot = integration.configRoot ?? integration.appRoot;
|
|
4255
|
-
let resolvedSiteRoot;
|
|
4256
4323
|
return [
|
|
4257
|
-
...riebeckite(integration,
|
|
4258
|
-
resolvedSiteRoot = application.configRoot;
|
|
4259
|
-
}),
|
|
4324
|
+
...riebeckite(integration),
|
|
4260
4325
|
riebeckiteSsrExternals(
|
|
4261
4326
|
[...defaultSsrExternals, ...ssrExternals ?? []],
|
|
4262
|
-
() => {
|
|
4327
|
+
(viteRoot) => {
|
|
4263
4328
|
if (integration.workspaceRoot) return [];
|
|
4264
|
-
const siteRoot =
|
|
4265
|
-
return
|
|
4329
|
+
const siteRoot = integration.configRoot ?? integration.appRoot ?? viteRoot;
|
|
4330
|
+
return siteRiebeckiteExternals(siteRoot);
|
|
4266
4331
|
}
|
|
4267
4332
|
),
|
|
4268
4333
|
createRiebeckiteSsg(ssg)
|
|
@@ -4271,12 +4336,13 @@ function riebeckiteVite(options = {}) {
|
|
|
4271
4336
|
function riebeckiteSsrExternals(externals, siteExternals = () => []) {
|
|
4272
4337
|
return {
|
|
4273
4338
|
name: "riebeckite-ssr-externals",
|
|
4274
|
-
config() {
|
|
4339
|
+
config(userConfig) {
|
|
4340
|
+
const viteRoot = userConfig.root ? path13.resolve(userConfig.root) : process.cwd();
|
|
4275
4341
|
return {
|
|
4276
4342
|
environments: {
|
|
4277
4343
|
ssr: {
|
|
4278
4344
|
resolve: {
|
|
4279
|
-
external: [...externals, ...siteExternals()]
|
|
4345
|
+
external: [...externals, ...siteExternals(viteRoot)]
|
|
4280
4346
|
}
|
|
4281
4347
|
}
|
|
4282
4348
|
}
|
package/dist/server.js
CHANGED
|
@@ -1,45 +1,8 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/content_route.ts
|
|
2
2
|
import {
|
|
3
|
-
getEntryLanguage
|
|
3
|
+
getEntryLanguage,
|
|
4
|
+
htmlOutputPath
|
|
4
5
|
} from "@riebeckite/core";
|
|
5
|
-
|
|
6
|
-
// src/content_route_part2.ts
|
|
7
|
-
import { htmlOutputPath } from "@riebeckite/core";
|
|
8
|
-
function ssgEnumerableHandler(handler) {
|
|
9
|
-
const enumerable = (...args) => Reflect.apply(handler, void 0, args);
|
|
10
|
-
return enumerable;
|
|
11
|
-
}
|
|
12
|
-
function isDynamicRoute(path) {
|
|
13
|
-
return path.split("/").some((segment) => segment.startsWith(":") || segment.includes("*"));
|
|
14
|
-
}
|
|
15
|
-
function normalizeRequestPath(pathname) {
|
|
16
|
-
const trailingSlash = pathname.length > 1 && pathname.endsWith("/");
|
|
17
|
-
const segments = pathname.split("/").filter(Boolean).map(encodeSegment);
|
|
18
|
-
const path = `/${segments.join("/")}`;
|
|
19
|
-
return trailingSlash ? `${path}/` : path;
|
|
20
|
-
}
|
|
21
|
-
function redirectSsgPaths(manifest) {
|
|
22
|
-
const paths = [];
|
|
23
|
-
for (const [path, redirect] of manifest.publicRedirects) {
|
|
24
|
-
const permalink = manifest.bySlug.get(redirect.slug)?.permalink;
|
|
25
|
-
if (permalink && htmlOutputPath(permalink) === routeOutputPath(path))
|
|
26
|
-
continue;
|
|
27
|
-
paths.push(path);
|
|
28
|
-
}
|
|
29
|
-
return paths;
|
|
30
|
-
}
|
|
31
|
-
function routeOutputPath(pathname) {
|
|
32
|
-
return htmlOutputPath(pathname);
|
|
33
|
-
}
|
|
34
|
-
function encodeSegment(segment) {
|
|
35
|
-
try {
|
|
36
|
-
return encodeURIComponent(decodeURIComponent(segment));
|
|
37
|
-
} catch {
|
|
38
|
-
return encodeURIComponent(segment);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// src/content_route_part1.ts
|
|
43
6
|
async function resolveRiebeckiteRoute(content, pathname) {
|
|
44
7
|
const page = await content.resolvePage(pathname);
|
|
45
8
|
if (page) return { kind: "page", page };
|
|
@@ -145,6 +108,39 @@ function contentRouteSsgParams(routePath, params) {
|
|
|
145
108
|
return c.notFound();
|
|
146
109
|
};
|
|
147
110
|
}
|
|
111
|
+
function ssgEnumerableHandler(handler) {
|
|
112
|
+
const enumerable = (...args) => Reflect.apply(handler, void 0, args);
|
|
113
|
+
return enumerable;
|
|
114
|
+
}
|
|
115
|
+
function isDynamicRoute(path) {
|
|
116
|
+
return path.split("/").some((segment) => segment.startsWith(":") || segment.includes("*"));
|
|
117
|
+
}
|
|
118
|
+
function normalizeRequestPath(pathname) {
|
|
119
|
+
const trailingSlash = pathname.length > 1 && pathname.endsWith("/");
|
|
120
|
+
const segments = pathname.split("/").filter(Boolean).map(encodeSegment);
|
|
121
|
+
const path = `/${segments.join("/")}`;
|
|
122
|
+
return trailingSlash ? `${path}/` : path;
|
|
123
|
+
}
|
|
124
|
+
function redirectSsgPaths(manifest) {
|
|
125
|
+
const paths = [];
|
|
126
|
+
for (const [path, redirect] of manifest.publicRedirects) {
|
|
127
|
+
const permalink = manifest.bySlug.get(redirect.slug)?.permalink;
|
|
128
|
+
if (permalink && htmlOutputPath(permalink) === routeOutputPath(path))
|
|
129
|
+
continue;
|
|
130
|
+
paths.push(path);
|
|
131
|
+
}
|
|
132
|
+
return paths;
|
|
133
|
+
}
|
|
134
|
+
function routeOutputPath(pathname) {
|
|
135
|
+
return htmlOutputPath(pathname);
|
|
136
|
+
}
|
|
137
|
+
function encodeSegment(segment) {
|
|
138
|
+
try {
|
|
139
|
+
return encodeURIComponent(decodeURIComponent(segment));
|
|
140
|
+
} catch {
|
|
141
|
+
return encodeURIComponent(segment);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
148
144
|
|
|
149
145
|
// src/endpoints.ts
|
|
150
146
|
function mountRiebeckiteEndpoints(app, options) {
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ResolvedRiebeckiteConfig } from "@riebeckite/core";
|
|
2
|
+
import type { Plugin } from "vite";
|
|
3
|
+
type ClientModuleConfig = Pick<ResolvedRiebeckiteConfig, "plugins" | "spa"> & {
|
|
4
|
+
ui?: ResolvedRiebeckiteConfig["ui"];
|
|
5
|
+
};
|
|
6
|
+
export declare function riebeckiteClientModule(getConfig: () => ClientModuleConfig, ensure?: () => Promise<unknown>): Plugin;
|
|
7
|
+
export {};
|
|
@@ -1,3 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
1
|
+
import { type ContentManager, type ContentManifest, type ContentManifestEntry, type PostContent, type ResolvedPluginPage } from "@riebeckite/core";
|
|
2
|
+
import type { Context, Handler, MiddlewareHandler } from "hono";
|
|
3
|
+
export type ResolvedContentRoute = {
|
|
4
|
+
kind: "content";
|
|
5
|
+
entry: ContentManifestEntry;
|
|
6
|
+
} | {
|
|
7
|
+
kind: "redirect";
|
|
8
|
+
location: string;
|
|
9
|
+
status: 301 | 302 | 307 | 308;
|
|
10
|
+
} | null;
|
|
11
|
+
export type ResolvedRiebeckiteRoute = Exclude<ResolvedContentRoute, null> | {
|
|
12
|
+
kind: "page";
|
|
13
|
+
page: ResolvedPluginPage;
|
|
14
|
+
} | null;
|
|
15
|
+
export declare function resolveRiebeckiteRoute(content: Pick<ContentManager, "resolvePage" | "getRequestManifest">, pathname: string): Promise<ResolvedRiebeckiteRoute>;
|
|
16
|
+
export type ResolvedContentRequest = {
|
|
17
|
+
kind: "content";
|
|
18
|
+
entry: ContentManifestEntry;
|
|
19
|
+
post: PostContent;
|
|
20
|
+
} | {
|
|
21
|
+
kind: "page";
|
|
22
|
+
page: ResolvedPluginPage;
|
|
23
|
+
} | {
|
|
24
|
+
kind: "response";
|
|
25
|
+
response: Response | Promise<Response>;
|
|
26
|
+
};
|
|
27
|
+
export declare function applyRiebeckiteRouteContext(c: Context, route: Exclude<ResolvedRiebeckiteRoute, null>): void;
|
|
28
|
+
type RouteContent = Pick<ContentManager, "resolvePage" | "getRequestManifest" | "getProcessedContent">;
|
|
29
|
+
export declare function resolveRiebeckiteContentRequest(c: Context, content: RouteContent, parameter?: string): Promise<ResolvedContentRequest>;
|
|
30
|
+
export declare function resolveRiebeckiteHomeRequest(c: Context, content: RouteContent): Promise<ResolvedContentRequest>;
|
|
31
|
+
export declare function pluginPageSsgParams(content: Pick<ContentManager, "getPagePaths">, parameter?: string): Promise<Record<string, string>[]>;
|
|
32
|
+
export declare function riebeckiteSsgParams(content: Pick<ContentManager, "getManifest" | "getOutputChangeSet" | "getPagePaths">, parameter?: string): Promise<Record<string, string>[]>;
|
|
33
|
+
export declare function resolveContentRoute(manifest: ContentManifest, pathname: string): ResolvedContentRoute;
|
|
34
|
+
type SsgParams = Record<string, string>[];
|
|
35
|
+
export declare function contentRouteSsgParams(routePath: string, params: SsgParams | ((c: Context) => SsgParams | Promise<SsgParams>)): MiddlewareHandler;
|
|
36
|
+
export declare function ssgEnumerableHandler<H extends Handler<any, any, any>>(handler: H): H;
|
|
37
|
+
export {};
|
|
@@ -14,7 +14,7 @@ export type RiebeckiteViteOptions = RiebeckiteIntegrationOptions & {
|
|
|
14
14
|
/** SSG overrides. A normal site does not need them. */
|
|
15
15
|
ssg?: RiebeckiteSsgOptions;
|
|
16
16
|
};
|
|
17
|
-
export declare function riebeckite(options?: RiebeckiteViteOptions
|
|
17
|
+
export declare function riebeckite(options?: RiebeckiteViteOptions): Plugin[];
|
|
18
18
|
export declare function riebeckiteContentWarmup(enabled: boolean, getApplication: () => Promise<ResolvedHonoxApplication>): Plugin;
|
|
19
19
|
/**
|
|
20
20
|
* Higher-level helper that registers the complete Riebeckite Vite integration
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riebeckite/honox",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -44,16 +44,17 @@
|
|
|
44
44
|
"hono": "^4.13.18",
|
|
45
45
|
"honox": "0.1.62",
|
|
46
46
|
"vite": "^8.3.7",
|
|
47
|
-
"@riebeckite/
|
|
48
|
-
"@riebeckite/
|
|
49
|
-
"@riebeckite/
|
|
50
|
-
"@riebeckite/
|
|
51
|
-
"@riebeckite/
|
|
52
|
-
"@riebeckite/
|
|
53
|
-
"@riebeckite/ui": "0.
|
|
47
|
+
"@riebeckite/ai": "0.3.0",
|
|
48
|
+
"@riebeckite/dev-inspector": "0.3.0",
|
|
49
|
+
"@riebeckite/og-image": "0.3.0",
|
|
50
|
+
"@riebeckite/plugin-color-mode": "0.3.0",
|
|
51
|
+
"@riebeckite/node": "0.3.0",
|
|
52
|
+
"@riebeckite/runtime": "0.3.0",
|
|
53
|
+
"@riebeckite/ui": "0.3.0",
|
|
54
|
+
"@riebeckite/spa": "0.3.0"
|
|
54
55
|
},
|
|
55
56
|
"peerDependencies": {
|
|
56
|
-
"@riebeckite/core": "^0.
|
|
57
|
+
"@riebeckite/core": "^0.3.0"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
59
60
|
"@d2lang/d2": "^0.1.34",
|
|
@@ -61,9 +62,9 @@
|
|
|
61
62
|
"@hono/vite-build": "^1.11.1",
|
|
62
63
|
"@marp-team/marp-core": "^4.4.0",
|
|
63
64
|
"tsx": "^4.22.4",
|
|
64
|
-
"@riebeckite/test": "0.
|
|
65
|
-
"@riebeckite/
|
|
66
|
-
"@riebeckite/
|
|
65
|
+
"@riebeckite/test": "0.3.0",
|
|
66
|
+
"@riebeckite/core": "0.3.0",
|
|
67
|
+
"@riebeckite/plugin-bases": "0.3.0"
|
|
67
68
|
},
|
|
68
69
|
"publishConfig": {
|
|
69
70
|
"access": "public"
|
|
@@ -92,7 +93,7 @@
|
|
|
92
93
|
"static-site-generator"
|
|
93
94
|
],
|
|
94
95
|
"engines": {
|
|
95
|
-
"node": "^
|
|
96
|
+
"node": "^22.13.0 || ^24.0.0 || ^26.0.0"
|
|
96
97
|
},
|
|
97
98
|
"sideEffects": [
|
|
98
99
|
"./style.css"
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { ResolvedRiebeckiteConfig } from "@riebeckite/core";
|
|
2
|
-
import type { Plugin } from "vite";
|
|
3
|
-
export declare const clientModuleId = "virtual:riebeckite/client";
|
|
4
|
-
export declare const resolvedClientModuleId = "\0virtual:riebeckite/client";
|
|
5
|
-
export declare function riebeckiteClientModule(getConfig: () => Pick<ResolvedRiebeckiteConfig, "plugins" | "spa">, ensure?: () => Promise<unknown>): Plugin;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { type ContentManager, type ContentManifest, type ContentManifestEntry, type PostContent, type ResolvedPluginPage } from "@riebeckite/core";
|
|
2
|
-
import type { Context, MiddlewareHandler } from "hono";
|
|
3
|
-
export type ResolvedContentRoute = {
|
|
4
|
-
kind: "content";
|
|
5
|
-
entry: ContentManifestEntry;
|
|
6
|
-
} | {
|
|
7
|
-
kind: "redirect";
|
|
8
|
-
location: string;
|
|
9
|
-
status: 301 | 302 | 307 | 308;
|
|
10
|
-
} | null;
|
|
11
|
-
export type ResolvedRiebeckiteRoute = Exclude<ResolvedContentRoute, null> | {
|
|
12
|
-
kind: "page";
|
|
13
|
-
page: ResolvedPluginPage;
|
|
14
|
-
} | null;
|
|
15
|
-
export declare function resolveRiebeckiteRoute(content: Pick<ContentManager, "resolvePage" | "getRequestManifest">, pathname: string): Promise<ResolvedRiebeckiteRoute>;
|
|
16
|
-
export type ResolvedContentRequest = {
|
|
17
|
-
kind: "content";
|
|
18
|
-
entry: ContentManifestEntry;
|
|
19
|
-
post: PostContent;
|
|
20
|
-
} | {
|
|
21
|
-
kind: "page";
|
|
22
|
-
page: ResolvedPluginPage;
|
|
23
|
-
} | {
|
|
24
|
-
kind: "response";
|
|
25
|
-
response: Response | Promise<Response>;
|
|
26
|
-
};
|
|
27
|
-
export declare function applyRiebeckiteRouteContext(c: Context, route: Exclude<ResolvedRiebeckiteRoute, null>): void;
|
|
28
|
-
export declare const contentExtensionPattern: RegExp;
|
|
29
|
-
export type RouteContent = Pick<ContentManager, "resolvePage" | "getRequestManifest" | "getProcessedContent">;
|
|
30
|
-
export declare function resolveRouteRequest(c: Context, content: RouteContent): Promise<ResolvedContentRequest>;
|
|
31
|
-
export declare function resolveRiebeckiteContentRequest(c: Context, content: RouteContent, parameter?: string): Promise<ResolvedContentRequest>;
|
|
32
|
-
export declare function resolveRiebeckiteHomeRequest(c: Context, content: RouteContent): Promise<ResolvedContentRequest>;
|
|
33
|
-
export declare function pluginPageSsgParams(content: Pick<ContentManager, "getPagePaths">, parameter?: string): Promise<Record<string, string>[]>;
|
|
34
|
-
export declare function riebeckiteSsgParams(content: Pick<ContentManager, "getManifest" | "getOutputChangeSet" | "getPagePaths">, parameter?: string): Promise<Record<string, string>[]>;
|
|
35
|
-
export declare function resolveContentRoute(manifest: ContentManifest, pathname: string): ResolvedContentRoute;
|
|
36
|
-
export type SsgParams = Record<string, string>[];
|
|
37
|
-
export declare function contentRouteSsgParams(routePath: string, params: SsgParams | ((c: Context) => SsgParams | Promise<SsgParams>)): MiddlewareHandler;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type ContentManifest } from "@riebeckite/core";
|
|
2
|
-
import type { Handler } from "hono";
|
|
3
|
-
export declare function ssgEnumerableHandler<H extends Handler<any, any, any>>(handler: H): H;
|
|
4
|
-
export declare function isDynamicRoute(path: string): boolean;
|
|
5
|
-
export declare function normalizeRequestPath(pathname: string): string;
|
|
6
|
-
export declare function redirectSsgPaths(manifest: ContentManifest): string[];
|
|
7
|
-
export declare function routeOutputPath(pathname: string): string;
|
|
8
|
-
export declare function encodeSegment(segment: string): string;
|