@riebeckite/honox 0.0.52 → 0.2.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 +505 -227
- package/dist/runtime.js +2 -5
- package/dist/server.js +36 -40
- package/dist/src/asset_entries.d.ts +2 -2
- package/dist/src/client_module.d.ts +3 -1
- package/dist/src/content_assets.d.ts +6 -6
- package/dist/src/content_route.d.ts +37 -3
- package/dist/src/content_watch.d.ts +4 -4
- package/dist/src/honox_islands.d.ts +1 -1
- package/dist/src/runtime_modules.d.ts +1 -1
- package/dist/src/spa_diagnostics.d.ts +1 -1
- package/dist/src/vite_plugin.d.ts +1 -1
- package/dist/src/workspace_packages.d.ts +5 -4
- package/package.json +13 -12
- 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
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// src/config_loader.ts
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
2
3
|
import fs3 from "node:fs/promises";
|
|
4
|
+
import { createRequire } from "node:module";
|
|
5
|
+
import { tmpdir } from "node:os";
|
|
3
6
|
import path4 from "node:path";
|
|
4
|
-
import { build as buildWithEsbuild } from "esbuild";
|
|
5
7
|
|
|
6
8
|
// src/site_externals.ts
|
|
7
9
|
import fs from "node:fs";
|
|
@@ -30,8 +32,8 @@ function siteRiebeckiteExternals(siteRoot) {
|
|
|
30
32
|
// src/workspace_packages.ts
|
|
31
33
|
import fs2 from "node:fs";
|
|
32
34
|
import path2 from "node:path";
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
async function createWorkspacePackageAliases(workspaceRoot) {
|
|
36
|
+
const { escapeRegExp } = await import("@riebeckite/core");
|
|
35
37
|
const packagesRoot = path2.join(workspaceRoot, "packages");
|
|
36
38
|
if (!fs2.existsSync(packagesRoot)) return [];
|
|
37
39
|
return findWorkspacePackageDirectories(packagesRoot).flatMap(
|
|
@@ -42,13 +44,21 @@ function createWorkspacePackageAliases(workspaceRoot) {
|
|
|
42
44
|
return createPackageAliases(
|
|
43
45
|
packageJson.name,
|
|
44
46
|
packageDirectory,
|
|
45
|
-
packageJson
|
|
47
|
+
packageJson,
|
|
48
|
+
escapeRegExp
|
|
46
49
|
);
|
|
47
50
|
}
|
|
48
51
|
);
|
|
49
52
|
}
|
|
50
|
-
function
|
|
51
|
-
const
|
|
53
|
+
function workspacePackageJsonPaths(workspaceRoot) {
|
|
54
|
+
const packagesRoot = path2.join(workspaceRoot, "packages");
|
|
55
|
+
if (!fs2.existsSync(packagesRoot)) return [];
|
|
56
|
+
return findWorkspacePackageDirectories(packagesRoot).map(
|
|
57
|
+
(packageDirectory) => path2.join(packageDirectory, "package.json")
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
async function workspacePackageResolver(workspaceRoot) {
|
|
61
|
+
const aliases = await createWorkspacePackageAliases(workspaceRoot);
|
|
52
62
|
return {
|
|
53
63
|
name: "workspace-package-resolver",
|
|
54
64
|
setup(buildApi) {
|
|
@@ -68,7 +78,7 @@ function findWorkspacePackageDirectories(rootDirectory) {
|
|
|
68
78
|
(entry) => findWorkspacePackageDirectories(path2.join(rootDirectory, entry.name))
|
|
69
79
|
);
|
|
70
80
|
}
|
|
71
|
-
function createPackageAliases(packageName, packageDirectory, packageJson) {
|
|
81
|
+
function createPackageAliases(packageName, packageDirectory, packageJson, escapeRegExp) {
|
|
72
82
|
const aliases = [];
|
|
73
83
|
const mainEntry = resolveExportsEntry(packageJson.exports) ?? packageJson.main;
|
|
74
84
|
if (mainEntry) {
|
|
@@ -133,9 +143,6 @@ function resolveExportTarget(target) {
|
|
|
133
143
|
import path3 from "node:path";
|
|
134
144
|
|
|
135
145
|
// src/spa_diagnostics.ts
|
|
136
|
-
import {
|
|
137
|
-
definePlugin
|
|
138
|
-
} from "@riebeckite/core";
|
|
139
146
|
var SPA_DIAGNOSTICS_PLUGIN_NAME = "riebeckite:spa-diagnostics";
|
|
140
147
|
var MAIN_CONTENT_PATTERN = /<main\b[^>]*\bid=["']main-content["']/iu;
|
|
141
148
|
var REDIRECT_PATTERN = /<meta\b[^>]*\bhttp-equiv=["']refresh["'][^>]*\bcontent=["'][^"']*\burl=/iu;
|
|
@@ -153,10 +160,10 @@ function inspectSpaPage(page) {
|
|
|
153
160
|
];
|
|
154
161
|
}
|
|
155
162
|
function spaDiagnostics() {
|
|
156
|
-
return
|
|
163
|
+
return {
|
|
157
164
|
name: SPA_DIAGNOSTICS_PLUGIN_NAME,
|
|
158
165
|
inspectGeneratedHtml: inspectSpaPage
|
|
159
|
-
}
|
|
166
|
+
};
|
|
160
167
|
}
|
|
161
168
|
|
|
162
169
|
// src/resolved_config.ts
|
|
@@ -175,39 +182,190 @@ function resolveHonoxConfig(config, appRoot) {
|
|
|
175
182
|
|
|
176
183
|
// src/config_loader.ts
|
|
177
184
|
var riebeckiteConfigTemporaryDirectory = ".riebeckite-config-";
|
|
185
|
+
var cacheFormatVersion = 2;
|
|
186
|
+
var cacheDirectoryName = path4.join(".riebeckite", "config-bundle");
|
|
187
|
+
var outputNamePattern = /^config-[0-9a-f]{16}\.mjs$/;
|
|
188
|
+
var failedCacheImports = /* @__PURE__ */ new Set();
|
|
178
189
|
async function loadRiebeckiteConfig(options) {
|
|
179
|
-
const
|
|
180
|
-
const
|
|
181
|
-
|
|
190
|
+
const mode = options.workspaceRoot ? "workspace" : "site";
|
|
191
|
+
const cacheDirectory = path4.join(options.configRoot, cacheDirectoryName);
|
|
192
|
+
const configFilePath = path4.resolve(
|
|
193
|
+
options.configRoot,
|
|
194
|
+
options.configFile ?? "riebeckite.config.ts"
|
|
182
195
|
);
|
|
183
|
-
const
|
|
196
|
+
const packageJsonListDigest = digestPackageJsonList(
|
|
197
|
+
options.workspaceRoot ? workspacePackageJsonPaths(options.workspaceRoot) : [path4.join(options.configRoot, "package.json")]
|
|
198
|
+
);
|
|
199
|
+
const cached = await loadCachedConfig({
|
|
200
|
+
cacheDirectory,
|
|
201
|
+
mode,
|
|
202
|
+
workspaceRoot: options.workspaceRoot ?? null,
|
|
203
|
+
configFile: configFilePath,
|
|
204
|
+
packageJsonListDigest
|
|
205
|
+
});
|
|
206
|
+
if (cached) return cached;
|
|
207
|
+
const esbuild = await import("esbuild");
|
|
208
|
+
const resolverPackageJsonPaths = options.workspaceRoot ? workspacePackageJsonPaths(options.workspaceRoot) : [path4.join(options.configRoot, "package.json")];
|
|
209
|
+
const result = await esbuild.build({
|
|
210
|
+
stdin: {
|
|
211
|
+
contents: `
|
|
212
|
+
import rawConfig from ${JSON.stringify(
|
|
213
|
+
path4.resolve(
|
|
214
|
+
options.configRoot,
|
|
215
|
+
options.configFile ?? "riebeckite.config.ts"
|
|
216
|
+
)
|
|
217
|
+
)};
|
|
218
|
+
import { resolveConfigModule } from "@riebeckite/core";
|
|
219
|
+
export default resolveConfigModule(rawConfig);
|
|
220
|
+
`,
|
|
221
|
+
resolveDir: options.configRoot,
|
|
222
|
+
loader: "ts"
|
|
223
|
+
},
|
|
224
|
+
bundle: true,
|
|
225
|
+
write: false,
|
|
226
|
+
metafile: true,
|
|
227
|
+
platform: "node",
|
|
228
|
+
format: "esm",
|
|
229
|
+
external: options.workspaceRoot ? ["@riebeckite/og-image"] : ["@riebeckite/core", ...siteRiebeckiteExternals(options.configRoot)],
|
|
230
|
+
banner: {
|
|
231
|
+
js: 'import { createRequire as __riebeckiteCreateRequire } from "node:module"; const require = __riebeckiteCreateRequire(import.meta.url);'
|
|
232
|
+
},
|
|
233
|
+
plugins: options.workspaceRoot ? [await workspacePackageResolver(options.workspaceRoot)] : []
|
|
234
|
+
});
|
|
235
|
+
const metafile = result.metafile;
|
|
236
|
+
if (!metafile) throw new Error("esbuild returned no config bundle metadata.");
|
|
237
|
+
const inputMap = /* @__PURE__ */ new Map();
|
|
238
|
+
for (const input of Object.keys(metafile.inputs)) {
|
|
239
|
+
if (input === "<stdin>") continue;
|
|
240
|
+
const inputPath = path4.isAbsolute(input) ? input : path4.resolve(process.cwd(), input);
|
|
241
|
+
if (!inputMap.has(inputPath)) {
|
|
242
|
+
inputMap.set(inputPath, await digestFile(inputPath));
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
for (const packageJsonPath of resolverPackageJsonPaths) {
|
|
246
|
+
if (!inputMap.has(packageJsonPath)) {
|
|
247
|
+
inputMap.set(packageJsonPath, await digestFile(packageJsonPath));
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
const inputs = [...inputMap.entries()].map(([inputPath, digest]) => ({ path: inputPath, digest })).sort(
|
|
251
|
+
(left, right) => left.path < right.path ? -1 : left.path > right.path ? 1 : 0
|
|
252
|
+
);
|
|
253
|
+
const fingerprint = createHash("sha256").update(
|
|
254
|
+
JSON.stringify({
|
|
255
|
+
version: cacheFormatVersion,
|
|
256
|
+
esbuildVersion: esbuild.version,
|
|
257
|
+
mode,
|
|
258
|
+
configFile: configFilePath,
|
|
259
|
+
packageJsonListDigest,
|
|
260
|
+
inputs
|
|
261
|
+
})
|
|
262
|
+
).digest("hex").slice(0, 16);
|
|
263
|
+
const bundle = result.outputFiles?.[0]?.contents;
|
|
264
|
+
if (!bundle) throw new Error("esbuild returned no config bundle output.");
|
|
265
|
+
const output = `config-${fingerprint}.mjs`;
|
|
266
|
+
const outputPath = path4.join(cacheDirectory, output);
|
|
267
|
+
let outputUrl = pathToFileUrl(outputPath);
|
|
268
|
+
if (failedCacheImports.has(outputUrl)) outputUrl += `?retry=${Date.now()}`;
|
|
269
|
+
let wroteToCache = true;
|
|
184
270
|
try {
|
|
185
|
-
await
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
271
|
+
await fs3.mkdir(cacheDirectory, { recursive: true });
|
|
272
|
+
await fs3.writeFile(outputPath, bundle);
|
|
273
|
+
} catch {
|
|
274
|
+
wroteToCache = false;
|
|
275
|
+
outputUrl = await writeFallbackBundle(bundle, output);
|
|
276
|
+
}
|
|
277
|
+
const module = await import(outputUrl);
|
|
278
|
+
if (wroteToCache) {
|
|
279
|
+
await fs3.writeFile(
|
|
280
|
+
path4.join(cacheDirectory, "manifest.json"),
|
|
281
|
+
`${JSON.stringify({
|
|
282
|
+
version: cacheFormatVersion,
|
|
283
|
+
esbuildVersion: esbuild.version,
|
|
284
|
+
mode,
|
|
285
|
+
workspaceRoot: options.workspaceRoot ?? null,
|
|
286
|
+
configFile: configFilePath,
|
|
287
|
+
packageJsonListDigest,
|
|
288
|
+
output,
|
|
289
|
+
inputs
|
|
290
|
+
})}
|
|
291
|
+
`,
|
|
292
|
+
"utf8"
|
|
293
|
+
).catch(() => {
|
|
204
294
|
});
|
|
205
|
-
|
|
295
|
+
}
|
|
296
|
+
failedCacheImports.delete(pathToFileUrl(outputPath));
|
|
297
|
+
return module.default;
|
|
298
|
+
}
|
|
299
|
+
async function writeFallbackBundle(bundle, name) {
|
|
300
|
+
const fallbackDirectory = await fs3.mkdtemp(
|
|
301
|
+
path4.join(tmpdir(), "riebeckite-config-")
|
|
302
|
+
);
|
|
303
|
+
const fallbackPath = path4.join(fallbackDirectory, name);
|
|
304
|
+
await fs3.writeFile(fallbackPath, bundle);
|
|
305
|
+
return pathToFileUrl(fallbackPath);
|
|
306
|
+
}
|
|
307
|
+
async function loadCachedConfig(cache) {
|
|
308
|
+
let manifest;
|
|
309
|
+
try {
|
|
310
|
+
manifest = JSON.parse(
|
|
311
|
+
await fs3.readFile(
|
|
312
|
+
path4.join(cache.cacheDirectory, "manifest.json"),
|
|
313
|
+
"utf8"
|
|
314
|
+
)
|
|
315
|
+
);
|
|
316
|
+
} catch {
|
|
317
|
+
return null;
|
|
318
|
+
}
|
|
319
|
+
if (typeof manifest !== "object" || manifest === null || typeof manifest.output !== "string" || !outputNamePattern.test(manifest.output) || !Array.isArray(manifest.inputs) || !manifest.inputs.every(
|
|
320
|
+
(input) => typeof input?.path === "string" && typeof input?.digest !== "undefined"
|
|
321
|
+
)) {
|
|
322
|
+
return null;
|
|
323
|
+
}
|
|
324
|
+
if (manifest.version !== cacheFormatVersion || manifest.mode !== cache.mode || manifest.workspaceRoot !== cache.workspaceRoot || manifest.configFile !== cache.configFile || manifest.packageJsonListDigest !== cache.packageJsonListDigest || manifest.esbuildVersion !== await readEsbuildVersion()) {
|
|
325
|
+
return null;
|
|
326
|
+
}
|
|
327
|
+
const currentDigests = await Promise.all(
|
|
328
|
+
manifest.inputs.map((input) => digestFile(input.path))
|
|
329
|
+
);
|
|
330
|
+
if (manifest.inputs.some(
|
|
331
|
+
(input, index) => input.digest !== currentDigests[index]
|
|
332
|
+
)) {
|
|
333
|
+
return null;
|
|
334
|
+
}
|
|
335
|
+
const outputUrl = pathToFileUrl(
|
|
336
|
+
path4.join(cache.cacheDirectory, manifest.output)
|
|
337
|
+
);
|
|
338
|
+
try {
|
|
339
|
+
const module = await import(outputUrl);
|
|
206
340
|
return module.default;
|
|
207
|
-
}
|
|
208
|
-
|
|
341
|
+
} catch {
|
|
342
|
+
failedCacheImports.add(outputUrl);
|
|
343
|
+
return null;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
async function readEsbuildVersion() {
|
|
347
|
+
try {
|
|
348
|
+
const require2 = createRequire(import.meta.url);
|
|
349
|
+
const packageJsonPath = require2.resolve("esbuild/package.json");
|
|
350
|
+
const packageJson = JSON.parse(
|
|
351
|
+
await fs3.readFile(packageJsonPath, "utf8")
|
|
352
|
+
);
|
|
353
|
+
return packageJson.version ?? null;
|
|
354
|
+
} catch {
|
|
355
|
+
return null;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
async function digestFile(filePath) {
|
|
359
|
+
try {
|
|
360
|
+
return createHash("sha256").update(await fs3.readFile(filePath)).digest("hex");
|
|
361
|
+
} catch {
|
|
362
|
+
return null;
|
|
209
363
|
}
|
|
210
364
|
}
|
|
365
|
+
function digestPackageJsonList(paths) {
|
|
366
|
+
const sorted = [...paths].sort();
|
|
367
|
+
return createHash("sha256").update(JSON.stringify(sorted)).digest("hex");
|
|
368
|
+
}
|
|
211
369
|
function pathToFileUrl(filePath) {
|
|
212
370
|
return `file:///${filePath.replace(/\\/g, "/").replace(/^([A-Za-z]):/, "$1:")}`;
|
|
213
371
|
}
|
|
@@ -215,7 +373,6 @@ function pathToFileUrl(filePath) {
|
|
|
215
373
|
// src/honox_islands.ts
|
|
216
374
|
import fs4 from "node:fs/promises";
|
|
217
375
|
import path5 from "node:path";
|
|
218
|
-
import { parse } from "@babel/parser";
|
|
219
376
|
var honoxIslandDependencyPluginName = "inject-importing-islands";
|
|
220
377
|
var importingIslandsExport = "__importing_islands";
|
|
221
378
|
function replaceHonoxIslandDependencyPlugin(plugins) {
|
|
@@ -224,7 +381,8 @@ function replaceHonoxIslandDependencyPlugin(plugins) {
|
|
|
224
381
|
scopedIslandDependencyPlugin()
|
|
225
382
|
];
|
|
226
383
|
}
|
|
227
|
-
function injectRiebeckiteClientBundle(getConfig) {
|
|
384
|
+
function injectRiebeckiteClientBundle(getConfig, ensure = async () => {
|
|
385
|
+
}) {
|
|
228
386
|
let rendererPath = "";
|
|
229
387
|
return {
|
|
230
388
|
name: "riebeckite-inject-client-bundle",
|
|
@@ -232,7 +390,8 @@ function injectRiebeckiteClientBundle(getConfig) {
|
|
|
232
390
|
configResolved(config) {
|
|
233
391
|
rendererPath = path5.join(config.root, "app", "routes", "_renderer");
|
|
234
392
|
},
|
|
235
|
-
transform(sourceCode, id) {
|
|
393
|
+
async transform(sourceCode, id) {
|
|
394
|
+
await ensure();
|
|
236
395
|
if (!requiresClientBundle(getConfig()) || !isRendererModule(toFilePath(id), rendererPath) || sourceCode.includes(`export const ${importingIslandsExport}`)) {
|
|
237
396
|
return;
|
|
238
397
|
}
|
|
@@ -292,7 +451,7 @@ export const ${importingIslandsExport} = true;
|
|
|
292
451
|
if (visited.has(currentModulePath)) return false;
|
|
293
452
|
visited.add(currentModulePath);
|
|
294
453
|
if (isInDirectory(currentModulePath, islandDirectory)) return true;
|
|
295
|
-
const importSources = getStaticImportSources(currentSourceCode);
|
|
454
|
+
const importSources = await getStaticImportSources(currentSourceCode);
|
|
296
455
|
for (const importSource of importSources) {
|
|
297
456
|
const resolved = await pluginContext.resolve(
|
|
298
457
|
importSource,
|
|
@@ -317,7 +476,8 @@ export const ${importingIslandsExport} = true;
|
|
|
317
476
|
return visit(modulePath, sourceCode);
|
|
318
477
|
}
|
|
319
478
|
}
|
|
320
|
-
function getStaticImportSources(sourceCode) {
|
|
479
|
+
async function getStaticImportSources(sourceCode) {
|
|
480
|
+
const { parse } = await import("@babel/parser");
|
|
321
481
|
const ast = parse(sourceCode, {
|
|
322
482
|
sourceType: "module",
|
|
323
483
|
plugins: ["typescript", "jsx"]
|
|
@@ -346,10 +506,10 @@ function isRendererModule(filePath, rendererPath) {
|
|
|
346
506
|
}
|
|
347
507
|
|
|
348
508
|
// src/ssg/inventory.ts
|
|
349
|
-
import { createHash } from "node:crypto";
|
|
509
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
350
510
|
import { readdir, readFile } from "node:fs/promises";
|
|
351
511
|
import { dirname, join, relative as relative2 } from "node:path";
|
|
352
|
-
import { performance } from "node:perf_hooks";
|
|
512
|
+
import { performance as performance2 } from "node:perf_hooks";
|
|
353
513
|
|
|
354
514
|
// src/ssg/file_system.ts
|
|
355
515
|
import { relative, resolve } from "node:path";
|
|
@@ -396,7 +556,7 @@ async function computeAppFingerprint(root, configFile) {
|
|
|
396
556
|
files.push(join(root, name));
|
|
397
557
|
}
|
|
398
558
|
files.sort();
|
|
399
|
-
const hash =
|
|
559
|
+
const hash = createHash2("sha256");
|
|
400
560
|
for (const file of files) {
|
|
401
561
|
let content;
|
|
402
562
|
try {
|
|
@@ -412,7 +572,7 @@ async function computeAppFingerprint(root, configFile) {
|
|
|
412
572
|
return hash.digest("hex");
|
|
413
573
|
}
|
|
414
574
|
async function computeBundleFingerprint(root, configFile) {
|
|
415
|
-
const hash =
|
|
575
|
+
const hash = createHash2("sha256");
|
|
416
576
|
hash.update(await computeAppFingerprint(root, configFile));
|
|
417
577
|
const files = [
|
|
418
578
|
...await findBundleInputFiles(root),
|
|
@@ -436,7 +596,7 @@ async function fingerprintDirectory(directory) {
|
|
|
436
596
|
);
|
|
437
597
|
}
|
|
438
598
|
function fingerprintOutputInventory(inventory) {
|
|
439
|
-
const hash =
|
|
599
|
+
const hash = createHash2("sha256");
|
|
440
600
|
for (const [path14, checksum] of Object.entries(inventory).sort(
|
|
441
601
|
([left], [right]) => left.localeCompare(right)
|
|
442
602
|
)) {
|
|
@@ -445,7 +605,7 @@ function fingerprintOutputInventory(inventory) {
|
|
|
445
605
|
return hash.digest("hex");
|
|
446
606
|
}
|
|
447
607
|
function fingerprintOutputContent(content) {
|
|
448
|
-
return
|
|
608
|
+
return createHash2("sha256").update(content).digest("hex");
|
|
449
609
|
}
|
|
450
610
|
async function fingerprintOutputDirectory(directory, relativeDirectory = "", metrics, knownChecksums) {
|
|
451
611
|
const entries = await readdir(directory, { withFileTypes: true }).catch(
|
|
@@ -480,11 +640,11 @@ async function fingerprintOutputDirectory(directory, relativeDirectory = "", met
|
|
|
480
640
|
inventory[relativePath] = knownChecksum;
|
|
481
641
|
continue;
|
|
482
642
|
}
|
|
483
|
-
const hashedAt =
|
|
643
|
+
const hashedAt = performance2.now();
|
|
484
644
|
const content = await readFile(file);
|
|
485
645
|
inventory[relativePath] = fingerprintOutputContent(content);
|
|
486
646
|
if (metrics) {
|
|
487
|
-
metrics.outputHashValidationDurationMs +=
|
|
647
|
+
metrics.outputHashValidationDurationMs += performance2.now() - hashedAt;
|
|
488
648
|
metrics.outputFilesHashed += 1;
|
|
489
649
|
metrics.outputBytesHashed += content.length;
|
|
490
650
|
}
|
|
@@ -618,12 +778,12 @@ async function collectPackageFiles(directory, files) {
|
|
|
618
778
|
|
|
619
779
|
// src/ssg/standalone.ts
|
|
620
780
|
import { mkdir } from "node:fs/promises";
|
|
621
|
-
import { createRequire } from "node:module";
|
|
781
|
+
import { createRequire as createRequire2 } from "node:module";
|
|
622
782
|
import { relative as relative3, resolve as resolve2 } from "node:path";
|
|
623
783
|
import { pathToFileURL } from "node:url";
|
|
624
784
|
import { build } from "vite";
|
|
625
785
|
var standaloneSsgMode = "riebeckite-ssr";
|
|
626
|
-
var frameworkRequire =
|
|
786
|
+
var frameworkRequire = createRequire2(import.meta.url);
|
|
627
787
|
async function loadStandaloneSsgBundle(input) {
|
|
628
788
|
const root = resolve2(input.root);
|
|
629
789
|
const outputDirectory = resolve2(input.outputDirectory);
|
|
@@ -711,7 +871,7 @@ function createClientManifestPlugin(root, clientOutputDirectory) {
|
|
|
711
871
|
import { rm as rm2 } from "node:fs/promises";
|
|
712
872
|
|
|
713
873
|
// src/ssg/build_output.ts
|
|
714
|
-
import { createHash as
|
|
874
|
+
import { createHash as createHash3, randomUUID } from "node:crypto";
|
|
715
875
|
import { mkdir as mkdir2, readdir as readdir2, readFile as readFile2, rename, rm, stat } from "node:fs/promises";
|
|
716
876
|
import { dirname as dirname2, join as join2 } from "node:path";
|
|
717
877
|
var CLOUDFLARE_WORKER_ASSET_LIMIT = 25 * 1024 * 1024;
|
|
@@ -780,7 +940,7 @@ async function preserveClientBuildArtifacts(outDir) {
|
|
|
780
940
|
return {
|
|
781
941
|
stagingDirectory,
|
|
782
942
|
paths,
|
|
783
|
-
manifestFingerprint:
|
|
943
|
+
manifestFingerprint: createHash3("sha256").update(manifestSource).digest("hex")
|
|
784
944
|
};
|
|
785
945
|
}
|
|
786
946
|
async function restoreClientBuildArtifacts(outDir, artifacts) {
|
|
@@ -842,7 +1002,7 @@ async function verifyClientBuildArtifacts(input) {
|
|
|
842
1002
|
const expectedChecksum = input.expectedInventory[relativePath];
|
|
843
1003
|
if (!expectedChecksum) return false;
|
|
844
1004
|
try {
|
|
845
|
-
const actualChecksum =
|
|
1005
|
+
const actualChecksum = createHash3("sha256").update(
|
|
846
1006
|
await readFile2(resolveBuildArtifactPath(input.outDir, relativePath))
|
|
847
1007
|
).digest("hex");
|
|
848
1008
|
if (actualChecksum !== expectedChecksum) return false;
|
|
@@ -903,11 +1063,10 @@ async function cleanupSsgGeneration(ctx, state) {
|
|
|
903
1063
|
|
|
904
1064
|
// src/ssg_plugin_close.ts
|
|
905
1065
|
import { resolve as resolve3 } from "node:path";
|
|
906
|
-
import { buildOutputPlan, compareOutputPlan } from "@riebeckite/core";
|
|
907
1066
|
|
|
908
1067
|
// src/ssg/output_cache_decision.ts
|
|
909
1068
|
import { join as join4 } from "node:path";
|
|
910
|
-
import { performance as
|
|
1069
|
+
import { performance as performance4 } from "node:perf_hooks";
|
|
911
1070
|
|
|
912
1071
|
// src/ssg/output_cache_fastpath.ts
|
|
913
1072
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
@@ -915,7 +1074,7 @@ import { lstat as lstat3, mkdir as mkdir4, readFile as readFile4, rm as rm4, wri
|
|
|
915
1074
|
import { dirname as dirname3 } from "node:path";
|
|
916
1075
|
|
|
917
1076
|
// src/ssg/output_cache_paths.ts
|
|
918
|
-
import { createHash as
|
|
1077
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
919
1078
|
import { lstat, mkdir as mkdir3, readFile as readFile3 } from "node:fs/promises";
|
|
920
1079
|
function outputCacheEntriesPath(outputCachePath) {
|
|
921
1080
|
return outputCachePath.replace(/\.json$/, ".entries");
|
|
@@ -950,7 +1109,7 @@ function assertSafeLogicalOutputPath(path14) {
|
|
|
950
1109
|
}
|
|
951
1110
|
}
|
|
952
1111
|
function outputCacheEntryName(outputPath) {
|
|
953
|
-
return
|
|
1112
|
+
return createHash4("sha256").update(outputPath).digest("hex");
|
|
954
1113
|
}
|
|
955
1114
|
async function ensureOutputCacheEntriesDirectory(directory) {
|
|
956
1115
|
await mkdir3(directory, { recursive: true });
|
|
@@ -986,7 +1145,7 @@ async function isRegularFile(path14) {
|
|
|
986
1145
|
}
|
|
987
1146
|
|
|
988
1147
|
// src/ssg/output_cache_replace.ts
|
|
989
|
-
import { createHash as
|
|
1148
|
+
import { createHash as createHash5, randomUUID as randomUUID2 } from "node:crypto";
|
|
990
1149
|
import { createReadStream } from "node:fs";
|
|
991
1150
|
import {
|
|
992
1151
|
copyFile,
|
|
@@ -1000,23 +1159,23 @@ import { join as join3 } from "node:path";
|
|
|
1000
1159
|
|
|
1001
1160
|
// src/ssg/runtime_metrics.ts
|
|
1002
1161
|
import { writeFile } from "node:fs/promises";
|
|
1003
|
-
import { performance as
|
|
1162
|
+
import { performance as performance3 } from "node:perf_hooks";
|
|
1004
1163
|
async function measure(timingsMs, name, fn) {
|
|
1005
1164
|
if (!timingsMs) return await fn();
|
|
1006
|
-
const start =
|
|
1165
|
+
const start = performance3.now();
|
|
1007
1166
|
try {
|
|
1008
1167
|
return await fn();
|
|
1009
1168
|
} finally {
|
|
1010
|
-
timingsMs[name] = (timingsMs[name] ?? 0) +
|
|
1169
|
+
timingsMs[name] = (timingsMs[name] ?? 0) + performance3.now() - start;
|
|
1011
1170
|
}
|
|
1012
1171
|
}
|
|
1013
1172
|
function measureSync(timingsMs, name, fn) {
|
|
1014
1173
|
if (!timingsMs) return fn();
|
|
1015
|
-
const start =
|
|
1174
|
+
const start = performance3.now();
|
|
1016
1175
|
try {
|
|
1017
1176
|
return fn();
|
|
1018
1177
|
} finally {
|
|
1019
|
-
timingsMs[name] = (timingsMs[name] ?? 0) +
|
|
1178
|
+
timingsMs[name] = (timingsMs[name] ?? 0) + performance3.now() - start;
|
|
1020
1179
|
}
|
|
1021
1180
|
}
|
|
1022
1181
|
async function writeSsgOutputMetrics(metrics) {
|
|
@@ -1028,7 +1187,7 @@ async function writeSsgOutputMetrics(metrics) {
|
|
|
1028
1187
|
|
|
1029
1188
|
// src/ssg/output_cache_replace.ts
|
|
1030
1189
|
async function checksumFile(path14) {
|
|
1031
|
-
const hash =
|
|
1190
|
+
const hash = createHash5("sha256");
|
|
1032
1191
|
try {
|
|
1033
1192
|
for await (const chunk of createReadStream(path14)) hash.update(chunk);
|
|
1034
1193
|
return hash.digest("hex");
|
|
@@ -1304,7 +1463,7 @@ async function verifyNoChangeFastPath(input) {
|
|
|
1304
1463
|
cache.finalOutputInventory,
|
|
1305
1464
|
cache.finalOutputStats
|
|
1306
1465
|
);
|
|
1307
|
-
const inventoryStartedAt =
|
|
1466
|
+
const inventoryStartedAt = performance4.now();
|
|
1308
1467
|
const currentInventory = await fingerprintOutputDirectory(
|
|
1309
1468
|
input.outputDirectory,
|
|
1310
1469
|
"",
|
|
@@ -1312,7 +1471,7 @@ async function verifyNoChangeFastPath(input) {
|
|
|
1312
1471
|
knownChecksums
|
|
1313
1472
|
);
|
|
1314
1473
|
if (input.metrics)
|
|
1315
|
-
input.metrics.outputInventoryValidationDurationMs +=
|
|
1474
|
+
input.metrics.outputInventoryValidationDurationMs += performance4.now() - inventoryStartedAt;
|
|
1316
1475
|
if (!inventoriesEqual(cache.finalOutputInventory, currentInventory)) {
|
|
1317
1476
|
return { used: false, blockReason: "output-inventory-mismatch" };
|
|
1318
1477
|
}
|
|
@@ -1499,7 +1658,7 @@ async function validateOutputCache(cache, path14, timingsMs, log = () => {
|
|
|
1499
1658
|
}
|
|
1500
1659
|
|
|
1501
1660
|
// src/ssg/output_cache_save.ts
|
|
1502
|
-
import { createHash as
|
|
1661
|
+
import { createHash as createHash6, randomUUID as randomUUID4 } from "node:crypto";
|
|
1503
1662
|
import { mkdir as mkdir5, rm as rm5, writeFile as writeFile4 } from "node:fs/promises";
|
|
1504
1663
|
import { dirname as dirname5 } from "node:path";
|
|
1505
1664
|
async function saveOutputCache(path14, state, outputDirectory, timingsMs) {
|
|
@@ -1541,7 +1700,7 @@ async function saveOutputCache(path14, state, outputDirectory, timingsMs) {
|
|
|
1541
1700
|
"outputCacheRename",
|
|
1542
1701
|
() => replaceFile(temporaryPath, path14)
|
|
1543
1702
|
);
|
|
1544
|
-
const checksum =
|
|
1703
|
+
const checksum = createHash6("sha256").update(serialized).digest("hex");
|
|
1545
1704
|
if (state.finalOutputInventory && state.configFile) {
|
|
1546
1705
|
await saveFastPathCache(
|
|
1547
1706
|
fastPathCachePath(path14),
|
|
@@ -1564,12 +1723,6 @@ async function saveOutputCache(path14, state, outputDirectory, timingsMs) {
|
|
|
1564
1723
|
// src/ssg_plugin_helpers.ts
|
|
1565
1724
|
import { lstat as lstat5, mkdir as mkdir6, writeFile as writeFile5 } from "node:fs/promises";
|
|
1566
1725
|
import { dirname as dirname6, join as join6 } from "node:path";
|
|
1567
|
-
import {
|
|
1568
|
-
BUILD_OUTPUT_MARKER_FILE,
|
|
1569
|
-
createBuildOutputMarker,
|
|
1570
|
-
isDeferredGeneratedOutput,
|
|
1571
|
-
serializeBuildOutputMarker
|
|
1572
|
-
} from "@riebeckite/core";
|
|
1573
1726
|
async function isDirectory(path14) {
|
|
1574
1727
|
try {
|
|
1575
1728
|
return (await lstat5(path14)).isDirectory();
|
|
@@ -1601,6 +1754,7 @@ async function emitGeneratedOutputs(module, emit, affectedPaths, shadowedPaths,
|
|
|
1601
1754
|
const content = module.content;
|
|
1602
1755
|
if (!content) return 0;
|
|
1603
1756
|
if (affectedPaths?.size === 0) return 0;
|
|
1757
|
+
const { isDeferredGeneratedOutput } = await import("@riebeckite/core");
|
|
1604
1758
|
const manifest = await content.getManifest();
|
|
1605
1759
|
let count = 0;
|
|
1606
1760
|
for (const output of manifest.generatedOutputs ?? []) {
|
|
@@ -1627,6 +1781,11 @@ function removeVirtualEntryChunk(bundle, virtualEntryId) {
|
|
|
1627
1781
|
}
|
|
1628
1782
|
}
|
|
1629
1783
|
async function writePublicationMarker(input) {
|
|
1784
|
+
const {
|
|
1785
|
+
BUILD_OUTPUT_MARKER_FILE,
|
|
1786
|
+
createBuildOutputMarker,
|
|
1787
|
+
serializeBuildOutputMarker
|
|
1788
|
+
} = await import("@riebeckite/core");
|
|
1630
1789
|
const path14 = join6(input.root, ".riebeckite", BUILD_OUTPUT_MARKER_FILE);
|
|
1631
1790
|
try {
|
|
1632
1791
|
await mkdir6(dirname6(path14), { recursive: true });
|
|
@@ -1653,6 +1812,7 @@ async function writePublicationMarker(input) {
|
|
|
1653
1812
|
async function closeSsgBundle(plugin, state) {
|
|
1654
1813
|
if (!state.resolvedConfig) return;
|
|
1655
1814
|
if (state.resolvedConfig.mode === "client") return;
|
|
1815
|
+
const { buildOutputPlan, compareOutputPlan } = await import("@riebeckite/core");
|
|
1656
1816
|
const outputDirectory = state.publicationOutputDirectory;
|
|
1657
1817
|
if (!outputDirectory) {
|
|
1658
1818
|
throw new Error(
|
|
@@ -1769,14 +1929,6 @@ async function closeSsgBundle(plugin, state) {
|
|
|
1769
1929
|
}
|
|
1770
1930
|
}
|
|
1771
1931
|
|
|
1772
|
-
// src/ssg_plugin_generate_finalize.ts
|
|
1773
|
-
import {
|
|
1774
|
-
publicationFingerprint as fingerprintPublication,
|
|
1775
|
-
publicationEntriesFromManifest,
|
|
1776
|
-
publicationOutputsFromManifest,
|
|
1777
|
-
publicationRedirectsFromManifest
|
|
1778
|
-
} from "@riebeckite/core";
|
|
1779
|
-
|
|
1780
1932
|
// src/ssg/diagnostics.ts
|
|
1781
1933
|
function formatSsrNoExternal() {
|
|
1782
1934
|
return "/^honox(?:\\/.*)?$/";
|
|
@@ -1835,6 +1987,12 @@ function inspectGeneratedHtmlPages(module, pages, log) {
|
|
|
1835
1987
|
|
|
1836
1988
|
// src/ssg_plugin_generate_finalize.ts
|
|
1837
1989
|
async function finalizeSsgGeneration(plugin, ctx, state) {
|
|
1990
|
+
const {
|
|
1991
|
+
publicationFingerprint: fingerprintPublication,
|
|
1992
|
+
publicationEntriesFromManifest,
|
|
1993
|
+
publicationRedirectsFromManifest,
|
|
1994
|
+
publicationOutputsFromManifest
|
|
1995
|
+
} = await import("@riebeckite/core");
|
|
1838
1996
|
ctx.metrics.shadowedOutputCount = ctx.shadowedOutputs.size;
|
|
1839
1997
|
if (ctx.shadowedOutputs.size > 0) {
|
|
1840
1998
|
plugin.warn(
|
|
@@ -1902,8 +2060,6 @@ import { join as join7, resolve as resolve4 } from "node:path";
|
|
|
1902
2060
|
// src/content_assets.ts
|
|
1903
2061
|
import fs5 from "node:fs/promises";
|
|
1904
2062
|
import path7 from "node:path";
|
|
1905
|
-
import { isImagePath, normalizeContentPath } from "@riebeckite/core";
|
|
1906
|
-
import { isIgnoredContentPath, isPathInsideDirectory } from "@riebeckite/node";
|
|
1907
2063
|
|
|
1908
2064
|
// src/content_module.ts
|
|
1909
2065
|
import path6 from "node:path";
|
|
@@ -1942,7 +2098,6 @@ function riebeckiteContentAssets(options) {
|
|
|
1942
2098
|
apply: "serve",
|
|
1943
2099
|
enforce: "pre",
|
|
1944
2100
|
configureServer(server) {
|
|
1945
|
-
const contentRoot = options.contentRoot();
|
|
1946
2101
|
const base = server.config.base;
|
|
1947
2102
|
const publicDir = server.config.publicDir;
|
|
1948
2103
|
let cachedManifest;
|
|
@@ -1953,7 +2108,7 @@ function riebeckiteContentAssets(options) {
|
|
|
1953
2108
|
};
|
|
1954
2109
|
const deferredContents = /* @__PURE__ */ new Map();
|
|
1955
2110
|
const resolvePublicAssets = async () => {
|
|
1956
|
-
const module = await loadContentModule(server, options.appRoot());
|
|
2111
|
+
const module = await loadContentModule(server, await options.appRoot());
|
|
1957
2112
|
const manifest = await module.content?.getManifest?.();
|
|
1958
2113
|
if (!manifest) {
|
|
1959
2114
|
return {
|
|
@@ -1966,9 +2121,9 @@ function riebeckiteContentAssets(options) {
|
|
|
1966
2121
|
cachedManifest = manifest;
|
|
1967
2122
|
deferredContents.clear();
|
|
1968
2123
|
cachedAssets = {
|
|
1969
|
-
paths: collectPublicImagePaths(manifest),
|
|
1970
|
-
generated: collectGeneratedImageContents(manifest),
|
|
1971
|
-
deferred: collectDeferredGeneratedImages(manifest)
|
|
2124
|
+
paths: await collectPublicImagePaths(manifest),
|
|
2125
|
+
generated: await collectGeneratedImageContents(manifest),
|
|
2126
|
+
deferred: await collectDeferredGeneratedImages(manifest)
|
|
1972
2127
|
};
|
|
1973
2128
|
}
|
|
1974
2129
|
return cachedAssets;
|
|
@@ -1979,7 +2134,8 @@ function riebeckiteContentAssets(options) {
|
|
|
1979
2134
|
next();
|
|
1980
2135
|
return;
|
|
1981
2136
|
}
|
|
1982
|
-
const
|
|
2137
|
+
const { isIgnoredContentPath, isPathInsideDirectory } = await import("@riebeckite/node");
|
|
2138
|
+
const logicalPath = await toContentPath(request.url, base);
|
|
1983
2139
|
if (!logicalPath) {
|
|
1984
2140
|
next();
|
|
1985
2141
|
return;
|
|
@@ -2017,6 +2173,7 @@ function riebeckiteContentAssets(options) {
|
|
|
2017
2173
|
sendImage(request, response, contentType, content2);
|
|
2018
2174
|
return;
|
|
2019
2175
|
}
|
|
2176
|
+
const contentRoot = await options.contentRoot();
|
|
2020
2177
|
const file = path7.join(contentRoot, logicalPath);
|
|
2021
2178
|
if (!isPathInsideDirectory(contentRoot, file)) {
|
|
2022
2179
|
next();
|
|
@@ -2035,7 +2192,8 @@ function riebeckiteContentAssets(options) {
|
|
|
2035
2192
|
}
|
|
2036
2193
|
};
|
|
2037
2194
|
}
|
|
2038
|
-
function collectPublicImagePaths(manifest) {
|
|
2195
|
+
async function collectPublicImagePaths(manifest) {
|
|
2196
|
+
const { isImagePath, normalizeContentPath } = await import("@riebeckite/core");
|
|
2039
2197
|
const paths = /* @__PURE__ */ new Set();
|
|
2040
2198
|
for (const entry of manifest.publicEntries ?? []) {
|
|
2041
2199
|
for (const asset of entry.assets ?? []) {
|
|
@@ -2045,7 +2203,8 @@ function collectPublicImagePaths(manifest) {
|
|
|
2045
2203
|
}
|
|
2046
2204
|
return paths;
|
|
2047
2205
|
}
|
|
2048
|
-
function collectGeneratedImageContents(manifest) {
|
|
2206
|
+
async function collectGeneratedImageContents(manifest) {
|
|
2207
|
+
const { normalizeContentPath } = await import("@riebeckite/core");
|
|
2049
2208
|
const contents = /* @__PURE__ */ new Map();
|
|
2050
2209
|
for (const output of manifest.generatedOutputs ?? []) {
|
|
2051
2210
|
if (output.content === void 0) continue;
|
|
@@ -2055,7 +2214,8 @@ function collectGeneratedImageContents(manifest) {
|
|
|
2055
2214
|
}
|
|
2056
2215
|
return contents;
|
|
2057
2216
|
}
|
|
2058
|
-
function collectDeferredGeneratedImages(manifest) {
|
|
2217
|
+
async function collectDeferredGeneratedImages(manifest) {
|
|
2218
|
+
const { normalizeContentPath } = await import("@riebeckite/core");
|
|
2059
2219
|
const outputs = /* @__PURE__ */ new Map();
|
|
2060
2220
|
for (const output of manifest.generatedOutputs ?? []) {
|
|
2061
2221
|
if (!output.generate) continue;
|
|
@@ -2096,8 +2256,9 @@ async function collectSiteOwnedOutputPaths(publicDir) {
|
|
|
2096
2256
|
await walk(root);
|
|
2097
2257
|
return paths;
|
|
2098
2258
|
}
|
|
2099
|
-
function toContentPath(url, base) {
|
|
2259
|
+
async function toContentPath(url, base) {
|
|
2100
2260
|
if (!url) return void 0;
|
|
2261
|
+
const { normalizeContentPath } = await import("@riebeckite/core");
|
|
2101
2262
|
const withoutQuery = url.split("?")[0]?.split("#")[0];
|
|
2102
2263
|
if (!withoutQuery) return void 0;
|
|
2103
2264
|
let decoded = withoutQuery;
|
|
@@ -2916,41 +3077,53 @@ function createRiebeckiteSsg(options = {}) {
|
|
|
2916
3077
|
|
|
2917
3078
|
// src/vite_plugin.ts
|
|
2918
3079
|
import path13 from "node:path";
|
|
2919
|
-
import {
|
|
2920
|
-
createContentFormatRegistry
|
|
2921
|
-
} from "@riebeckite/core";
|
|
3080
|
+
import { createMutationPathPolicy, resolveAiIntegration } from "@riebeckite/ai";
|
|
2922
3081
|
import {
|
|
2923
3082
|
invalidateDevelopmentInspector,
|
|
2924
3083
|
invalidateRiebeckiteBridge,
|
|
2925
3084
|
riebeckiteBridge,
|
|
2926
3085
|
riebeckiteDevelopmentInspector
|
|
2927
3086
|
} from "@riebeckite/dev-inspector";
|
|
2928
|
-
import {
|
|
3087
|
+
import {
|
|
3088
|
+
mergeConfig
|
|
3089
|
+
} from "vite";
|
|
2929
3090
|
|
|
2930
3091
|
// src/asset_entries.ts
|
|
2931
3092
|
import fs6 from "node:fs";
|
|
2932
3093
|
import path8 from "node:path";
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
writeGeneratedFile(
|
|
2936
|
-
|
|
2937
|
-
|
|
3094
|
+
async function writeRiebeckiteAssetEntries(config, paths) {
|
|
3095
|
+
const { uniqueStrings } = await import("@riebeckite/core");
|
|
3096
|
+
writeGeneratedFile(
|
|
3097
|
+
paths.frameworkStyles,
|
|
3098
|
+
createFrameworkStylesEntry(uniqueStrings)
|
|
3099
|
+
);
|
|
3100
|
+
writeGeneratedFile(
|
|
3101
|
+
paths.pluginStyles,
|
|
3102
|
+
createPluginStylesEntry(config, uniqueStrings)
|
|
3103
|
+
);
|
|
3104
|
+
writeGeneratedFile(
|
|
3105
|
+
paths.themeStyles,
|
|
3106
|
+
createThemeStylesEntry(config, uniqueStrings)
|
|
3107
|
+
);
|
|
2938
3108
|
}
|
|
2939
|
-
function createFrameworkStylesEntry() {
|
|
3109
|
+
function createFrameworkStylesEntry(uniqueStrings) {
|
|
2940
3110
|
return createStylesheetEntry(
|
|
3111
|
+
uniqueStrings,
|
|
2941
3112
|
["@riebeckite/honox/style.css"],
|
|
2942
3113
|
"Framework structural styles. Generated by @riebeckite/honox; do not edit. Import this before the plugin and theme stylesheets."
|
|
2943
3114
|
);
|
|
2944
3115
|
}
|
|
2945
|
-
function createPluginStylesEntry(config) {
|
|
3116
|
+
function createPluginStylesEntry(config, uniqueStrings) {
|
|
2946
3117
|
return createStylesheetEntry(
|
|
3118
|
+
uniqueStrings,
|
|
2947
3119
|
collectPluginStyleSpecifiers(config),
|
|
2948
3120
|
"Plugin default styles in the rb-plugins cascade layer, in resolved plugin order. Generated by @riebeckite/honox; do not edit.",
|
|
2949
3121
|
"rb-plugins"
|
|
2950
3122
|
);
|
|
2951
3123
|
}
|
|
2952
|
-
function createThemeStylesEntry(config) {
|
|
3124
|
+
function createThemeStylesEntry(config, uniqueStrings) {
|
|
2953
3125
|
return createStylesheetEntry(
|
|
3126
|
+
uniqueStrings,
|
|
2954
3127
|
config.theme.styles.map((style) => style.moduleSpecifier),
|
|
2955
3128
|
"Theme styles in the rb-theme cascade layer. Generated by @riebeckite/honox; do not edit.",
|
|
2956
3129
|
"rb-theme"
|
|
@@ -2961,7 +3134,7 @@ function collectPluginStyleSpecifiers(config) {
|
|
|
2961
3134
|
(plugin) => (plugin.assets ?? []).filter((asset) => asset.kind === "style").map((asset) => asset.moduleSpecifier)
|
|
2962
3135
|
);
|
|
2963
3136
|
}
|
|
2964
|
-
function createStylesheetEntry(moduleSpecifiers, banner, layer) {
|
|
3137
|
+
function createStylesheetEntry(uniqueStrings, moduleSpecifiers, banner, layer) {
|
|
2965
3138
|
const imports = uniqueStrings(moduleSpecifiers).map(
|
|
2966
3139
|
(specifier) => `@import ${JSON.stringify(specifier)}${layer ? ` layer(${layer})` : ""};`
|
|
2967
3140
|
).join("\n");
|
|
@@ -2989,11 +3162,30 @@ function isNotFoundError3(error) {
|
|
|
2989
3162
|
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
2990
3163
|
}
|
|
2991
3164
|
|
|
2992
|
-
// src/
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
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
|
+
}
|
|
3187
|
+
async function createClientModule(config, development) {
|
|
3188
|
+
const { serializePublicClientConfig } = await import("@riebeckite/core");
|
|
2997
3189
|
const imports = [];
|
|
2998
3190
|
const appInitializers = [];
|
|
2999
3191
|
const appConditionalInitializers = [];
|
|
@@ -3228,35 +3420,8 @@ export async function disposeRiebeckiteClient() {
|
|
|
3228
3420
|
`;
|
|
3229
3421
|
}
|
|
3230
3422
|
|
|
3231
|
-
// src/client_module_part1.ts
|
|
3232
|
-
var clientModuleId = "virtual:riebeckite/client";
|
|
3233
|
-
var resolvedClientModuleId = `\0${clientModuleId}`;
|
|
3234
|
-
function riebeckiteClientModule(getConfig) {
|
|
3235
|
-
let development = false;
|
|
3236
|
-
return {
|
|
3237
|
-
name: "riebeckite-client-module",
|
|
3238
|
-
config(_config, environment) {
|
|
3239
|
-
development = environment.command === "serve";
|
|
3240
|
-
},
|
|
3241
|
-
resolveId(id) {
|
|
3242
|
-
if (id === clientModuleId) return resolvedClientModuleId;
|
|
3243
|
-
return null;
|
|
3244
|
-
},
|
|
3245
|
-
load(id) {
|
|
3246
|
-
if (id !== resolvedClientModuleId) return null;
|
|
3247
|
-
return createClientModule(getConfig(), development);
|
|
3248
|
-
}
|
|
3249
|
-
};
|
|
3250
|
-
}
|
|
3251
|
-
|
|
3252
3423
|
// src/content_watch.ts
|
|
3253
3424
|
import path9 from "node:path";
|
|
3254
|
-
import { isAttachmentPath, isImagePath as isImagePath2 } from "@riebeckite/core";
|
|
3255
|
-
import {
|
|
3256
|
-
isIgnoredContentPath as isIgnoredContentPath2,
|
|
3257
|
-
isPathInsideDirectory as isPathInsideDirectory2,
|
|
3258
|
-
toLogicalPath
|
|
3259
|
-
} from "@riebeckite/node";
|
|
3260
3425
|
|
|
3261
3426
|
// src/runtime_modules.ts
|
|
3262
3427
|
var riebeckiteConfigModuleId = "virtual:riebeckite/config";
|
|
@@ -3270,7 +3435,8 @@ var runtimeModuleIds = [
|
|
|
3270
3435
|
var resolvedConfigModuleId = `\0${riebeckiteConfigModuleId}`;
|
|
3271
3436
|
var resolvedContentModuleId = `\0${riebeckiteContentModuleId}`;
|
|
3272
3437
|
var resolvedContentRenderersModuleId = `\0${riebeckiteContentRenderersModuleId}`;
|
|
3273
|
-
function riebeckiteRuntimeModules(getApplication) {
|
|
3438
|
+
function riebeckiteRuntimeModules(getApplication, ensure = async () => {
|
|
3439
|
+
}) {
|
|
3274
3440
|
let development = false;
|
|
3275
3441
|
return {
|
|
3276
3442
|
name: "riebeckite-runtime-modules",
|
|
@@ -3284,7 +3450,8 @@ function riebeckiteRuntimeModules(getApplication) {
|
|
|
3284
3450
|
return resolvedContentRenderersModuleId;
|
|
3285
3451
|
return null;
|
|
3286
3452
|
},
|
|
3287
|
-
load(id) {
|
|
3453
|
+
async load(id) {
|
|
3454
|
+
await ensure();
|
|
3288
3455
|
if (id === resolvedConfigModuleId) {
|
|
3289
3456
|
const { appRoot, configFile } = getApplication();
|
|
3290
3457
|
return createConfigModule(appRoot, configFile);
|
|
@@ -3408,45 +3575,51 @@ function riebeckiteContentWatch(options) {
|
|
|
3408
3575
|
configureServer(server) {
|
|
3409
3576
|
if (configuredWatchers.has(server.watcher)) return;
|
|
3410
3577
|
configuredWatchers.add(server.watcher);
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3578
|
+
void Promise.all([
|
|
3579
|
+
options.appRoot(),
|
|
3580
|
+
options.contentRoot(),
|
|
3581
|
+
import("@riebeckite/core"),
|
|
3582
|
+
import("@riebeckite/node")
|
|
3583
|
+
]).then(([appRoot, contentRoot, core, nodeUtils]) => {
|
|
3584
|
+
const { isAttachmentPath, isImagePath } = core;
|
|
3585
|
+
const { isIgnoredContentPath, isPathInsideDirectory, toLogicalPath } = nodeUtils;
|
|
3586
|
+
const exclude = options.exclude();
|
|
3587
|
+
const isContentFile = (file) => isPathInsideDirectory(contentRoot, file);
|
|
3588
|
+
server.watcher.add(contentRoot);
|
|
3589
|
+
suppressRestartOnContentEvents(server, isContentFile);
|
|
3590
|
+
let timer;
|
|
3591
|
+
const invalidate = () => {
|
|
3592
|
+
if (timer) clearTimeout(timer);
|
|
3593
|
+
timer = setTimeout(() => {
|
|
3594
|
+
timer = void 0;
|
|
3595
|
+
void invalidateApplicationRuntime(server, appRoot);
|
|
3596
|
+
options.onInvalidate?.(server);
|
|
3597
|
+
server.hot.send({ type: "full-reload" });
|
|
3598
|
+
}, CONTENT_RELOAD_DEBOUNCE_MS);
|
|
3599
|
+
};
|
|
3600
|
+
server.httpServer?.once("close", () => {
|
|
3601
|
+
if (timer) clearTimeout(timer);
|
|
3602
|
+
});
|
|
3603
|
+
const handle = (event) => (file) => {
|
|
3604
|
+
if (!isContentFile(file)) return;
|
|
3605
|
+
const logicalPath = toLogicalPath(contentRoot, file);
|
|
3606
|
+
if (isIgnoredContentPath(logicalPath, exclude)) return;
|
|
3607
|
+
if (event === "change" && (isImagePath(logicalPath) || isAttachmentPath(logicalPath))) {
|
|
3608
|
+
server.hot.send({ type: "full-reload" });
|
|
3609
|
+
return;
|
|
3610
|
+
}
|
|
3611
|
+
invalidate();
|
|
3612
|
+
};
|
|
3613
|
+
server.watcher.on("add", handle("add"));
|
|
3614
|
+
server.watcher.on("change", handle("change"));
|
|
3615
|
+
server.watcher.on("unlink", handle("unlink"));
|
|
3616
|
+
}).catch(() => {
|
|
3429
3617
|
});
|
|
3430
|
-
const handle = (event) => (file) => {
|
|
3431
|
-
if (!isContentFile(file)) return;
|
|
3432
|
-
const logicalPath = toLogicalPath(contentRoot, file);
|
|
3433
|
-
if (isIgnoredContentPath2(logicalPath, exclude)) return;
|
|
3434
|
-
if (event === "change" && isSiteAssetPath(logicalPath)) {
|
|
3435
|
-
server.hot.send({ type: "full-reload" });
|
|
3436
|
-
return;
|
|
3437
|
-
}
|
|
3438
|
-
invalidate();
|
|
3439
|
-
};
|
|
3440
|
-
server.watcher.on("add", handle("add"));
|
|
3441
|
-
server.watcher.on("change", handle("change"));
|
|
3442
|
-
server.watcher.on("unlink", handle("unlink"));
|
|
3443
3618
|
}
|
|
3444
3619
|
};
|
|
3445
3620
|
}
|
|
3446
|
-
function
|
|
3447
|
-
|
|
3448
|
-
}
|
|
3449
|
-
function invalidateApplicationRuntime(server, appRoot) {
|
|
3621
|
+
async function invalidateApplicationRuntime(server, appRoot) {
|
|
3622
|
+
const { isPathInsideDirectory } = await import("@riebeckite/node");
|
|
3450
3623
|
const moduleGraph = server.environments?.ssr?.moduleGraph;
|
|
3451
3624
|
if (!moduleGraph) return 0;
|
|
3452
3625
|
const appDirectory = path9.join(appRoot, "app") + path9.sep;
|
|
@@ -3454,14 +3627,15 @@ function invalidateApplicationRuntime(server, appRoot) {
|
|
|
3454
3627
|
const timestamp = Date.now();
|
|
3455
3628
|
let invalidated = 0;
|
|
3456
3629
|
for (const mod of moduleGraph.idToModuleMap.values()) {
|
|
3457
|
-
if (!isApplicationRuntimeModule(mod, appDirectory))
|
|
3630
|
+
if (!isApplicationRuntimeModule(mod, appDirectory, isPathInsideDirectory))
|
|
3631
|
+
continue;
|
|
3458
3632
|
moduleGraph.invalidateModule(mod, seen, timestamp);
|
|
3459
3633
|
invalidated += 1;
|
|
3460
3634
|
}
|
|
3461
3635
|
return invalidated;
|
|
3462
3636
|
}
|
|
3463
|
-
function isApplicationRuntimeModule(mod, appDirectory) {
|
|
3464
|
-
if (mod.file &&
|
|
3637
|
+
function isApplicationRuntimeModule(mod, appDirectory, isPathInsideDirectory) {
|
|
3638
|
+
if (mod.file && isPathInsideDirectory(appDirectory, mod.file)) return true;
|
|
3465
3639
|
return isRiebeckiteRuntimeModuleId(mod.id);
|
|
3466
3640
|
}
|
|
3467
3641
|
function suppressRestartOnContentEvents(server, isContentFile) {
|
|
@@ -3825,38 +3999,57 @@ function riebeckite(options = {}, onApplicationResolved) {
|
|
|
3825
3999
|
}
|
|
3826
4000
|
return resolvedConfig;
|
|
3827
4001
|
};
|
|
4002
|
+
let applicationPromise;
|
|
4003
|
+
let applicationAppRoot = "";
|
|
4004
|
+
let contentFormatRegistryFactory;
|
|
4005
|
+
const ensureApplication = () => applicationPromise ??= (async () => {
|
|
4006
|
+
const core = await import("@riebeckite/core");
|
|
4007
|
+
contentFormatRegistryFactory = core.createContentFormatRegistry;
|
|
4008
|
+
const resolvedApplication = await resolveHonoxApplication({
|
|
4009
|
+
configRoot: options.configRoot ?? applicationAppRoot,
|
|
4010
|
+
configFile: options.configFile,
|
|
4011
|
+
appRoot: applicationAppRoot,
|
|
4012
|
+
workspaceRoot: options.workspaceRoot
|
|
4013
|
+
});
|
|
4014
|
+
resolvedConfig = resolvedApplication.config;
|
|
4015
|
+
const resolved = resolvedConfig;
|
|
4016
|
+
contentVitePlugins = resolved.plugins.flatMap(
|
|
4017
|
+
(plugin) => plugin.vitePlugins?.({
|
|
4018
|
+
contentDirectory: resolved.content.directory
|
|
4019
|
+
}) ?? []
|
|
4020
|
+
);
|
|
4021
|
+
application = resolvedApplication;
|
|
4022
|
+
onApplicationResolved?.(resolvedApplication);
|
|
4023
|
+
await writeRiebeckiteAssetEntries(resolvedConfig, {
|
|
4024
|
+
frameworkStyles: path13.join(
|
|
4025
|
+
applicationAppRoot,
|
|
4026
|
+
"app/.riebeckite/framework-styles.css"
|
|
4027
|
+
),
|
|
4028
|
+
pluginStyles: path13.join(
|
|
4029
|
+
applicationAppRoot,
|
|
4030
|
+
"app/.riebeckite/plugin-styles.css"
|
|
4031
|
+
),
|
|
4032
|
+
themeStyles: path13.join(
|
|
4033
|
+
applicationAppRoot,
|
|
4034
|
+
"app/.riebeckite/theme-styles.css"
|
|
4035
|
+
)
|
|
4036
|
+
});
|
|
4037
|
+
return resolvedApplication;
|
|
4038
|
+
})();
|
|
3828
4039
|
return [
|
|
3829
4040
|
{
|
|
3830
4041
|
name: "riebeckite-host-integration",
|
|
3831
|
-
async config(userConfig) {
|
|
4042
|
+
async config(userConfig, environment) {
|
|
3832
4043
|
const root = userConfig.root ? path13.resolve(userConfig.root) : process.cwd();
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
configRoot: options.configRoot ?? appRoot,
|
|
3836
|
-
configFile: options.configFile,
|
|
3837
|
-
appRoot,
|
|
3838
|
-
workspaceRoot: options.workspaceRoot
|
|
3839
|
-
});
|
|
3840
|
-
resolvedConfig = resolvedApplication.config;
|
|
3841
|
-
const resolved = resolvedConfig;
|
|
3842
|
-
contentVitePlugins = resolved.plugins.flatMap(
|
|
3843
|
-
(plugin) => plugin.vitePlugins?.({
|
|
3844
|
-
contentDirectory: resolved.content.directory
|
|
3845
|
-
}) ?? []
|
|
3846
|
-
);
|
|
3847
|
-
application = resolvedApplication;
|
|
3848
|
-
onApplicationResolved?.(resolvedApplication);
|
|
3849
|
-
writeRiebeckiteAssetEntries(resolvedConfig, {
|
|
3850
|
-
frameworkStyles: path13.join(
|
|
3851
|
-
appRoot,
|
|
3852
|
-
"app/.riebeckite/framework-styles.css"
|
|
3853
|
-
),
|
|
3854
|
-
pluginStyles: path13.join(appRoot, "app/.riebeckite/plugin-styles.css"),
|
|
3855
|
-
themeStyles: path13.join(appRoot, "app/.riebeckite/theme-styles.css")
|
|
4044
|
+
applicationAppRoot = options.appRoot ?? root;
|
|
4045
|
+
void ensureApplication().catch(() => {
|
|
3856
4046
|
});
|
|
4047
|
+
if (environment.command === "build") {
|
|
4048
|
+
await ensureApplication();
|
|
4049
|
+
}
|
|
3857
4050
|
return {
|
|
3858
4051
|
define: {
|
|
3859
|
-
"process.env.RIEBECKITE_APP_ROOT": JSON.stringify(
|
|
4052
|
+
"process.env.RIEBECKITE_APP_ROOT": JSON.stringify(applicationAppRoot)
|
|
3860
4053
|
},
|
|
3861
4054
|
oxc: {
|
|
3862
4055
|
jsx: { runtime: "automatic", importSource: "hono/jsx" }
|
|
@@ -3870,27 +4063,40 @@ function riebeckite(options = {}, onApplicationResolved) {
|
|
|
3870
4063
|
}
|
|
3871
4064
|
},
|
|
3872
4065
|
resolve: {
|
|
3873
|
-
alias: options.workspaceRoot ? createWorkspacePackageAliases(options.workspaceRoot) : []
|
|
4066
|
+
alias: options.workspaceRoot ? await createWorkspacePackageAliases(options.workspaceRoot) : []
|
|
3874
4067
|
}
|
|
3875
4068
|
};
|
|
4069
|
+
},
|
|
4070
|
+
configureServer(server) {
|
|
4071
|
+
applicationPromise?.catch((error) => {
|
|
4072
|
+
server.config.logger.error(
|
|
4073
|
+
"Failed to resolve Riebeckite application.",
|
|
4074
|
+
{
|
|
4075
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
4076
|
+
}
|
|
4077
|
+
);
|
|
4078
|
+
});
|
|
3876
4079
|
}
|
|
3877
4080
|
},
|
|
3878
4081
|
contentVitePluginBridge(() => contentVitePlugins),
|
|
3879
|
-
contentBareImportResolver(
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
4082
|
+
contentBareImportResolver(
|
|
4083
|
+
() => requireApplication(application),
|
|
4084
|
+
ensureApplication
|
|
4085
|
+
),
|
|
4086
|
+
injectRiebeckiteClientBundle(getConfig, ensureApplication),
|
|
4087
|
+
riebeckiteClientModule(getConfig, ensureApplication),
|
|
4088
|
+
riebeckiteRuntimeModules(
|
|
4089
|
+
() => requireApplication(application),
|
|
4090
|
+
ensureApplication
|
|
3886
4091
|
),
|
|
4092
|
+
riebeckiteContentWarmup(options.warmContent ?? true, ensureApplication),
|
|
3887
4093
|
riebeckiteContentAssets({
|
|
3888
|
-
appRoot: () =>
|
|
3889
|
-
contentRoot: () =>
|
|
4094
|
+
appRoot: async () => (await ensureApplication()).appRoot,
|
|
4095
|
+
contentRoot: async () => (await ensureApplication()).contentRoot
|
|
3890
4096
|
}),
|
|
3891
4097
|
riebeckiteContentWatch({
|
|
3892
|
-
appRoot: () =>
|
|
3893
|
-
contentRoot: () =>
|
|
4098
|
+
appRoot: async () => (await ensureApplication()).appRoot,
|
|
4099
|
+
contentRoot: async () => (await ensureApplication()).contentRoot,
|
|
3894
4100
|
exclude: () => getConfig().content.exclude ?? [],
|
|
3895
4101
|
onInvalidate(server) {
|
|
3896
4102
|
invalidateDevelopmentInspector(server);
|
|
@@ -3911,8 +4117,21 @@ function riebeckite(options = {}, onApplicationResolved) {
|
|
|
3911
4117
|
mutationToken: process.env.RIEBECKITE_BRIDGE_MUTATION_TOKEN,
|
|
3912
4118
|
mutationApprovalToken: process.env.RIEBECKITE_BRIDGE_MUTATION_APPROVAL_TOKEN,
|
|
3913
4119
|
contentRoot: () => requireApplication(application).contentRoot,
|
|
3914
|
-
contentFormats: () =>
|
|
4120
|
+
contentFormats: () => {
|
|
4121
|
+
if (!contentFormatRegistryFactory) {
|
|
4122
|
+
throw new Error("Riebeckite config has not been loaded yet.");
|
|
4123
|
+
}
|
|
4124
|
+
return contentFormatRegistryFactory(getConfig().plugins);
|
|
4125
|
+
},
|
|
3915
4126
|
publicOrigin: () => getConfig().site.baseUrl || void 0,
|
|
4127
|
+
isMutationPathAllowed: () => createMutationPathPolicy(
|
|
4128
|
+
resolveAiIntegration(getConfig().integrations?.ai).mutationPolicy
|
|
4129
|
+
),
|
|
4130
|
+
project: () => ({
|
|
4131
|
+
contentDirectory: getConfig().content.directory,
|
|
4132
|
+
locale: getConfig().site.locale,
|
|
4133
|
+
mutationPolicy: resolveAiIntegration(getConfig().integrations?.ai).mutationPolicy
|
|
4134
|
+
}),
|
|
3916
4135
|
async getSnapshot(server) {
|
|
3917
4136
|
const { appRoot } = requireApplication(application);
|
|
3918
4137
|
if (!isContentModuleLoaded(server, appRoot)) return void 0;
|
|
@@ -3930,21 +4149,80 @@ function riebeckiteContentWarmup(enabled, getApplication) {
|
|
|
3930
4149
|
configureServer(server) {
|
|
3931
4150
|
if (!enabled || !server.httpServer) return;
|
|
3932
4151
|
server.httpServer.once("listening", () => {
|
|
3933
|
-
const
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
error: error instanceof Error ? error : new Error(String(error))
|
|
3937
|
-
});
|
|
3938
|
-
});
|
|
4152
|
+
const origin = server.resolvedUrls?.local?.[0];
|
|
4153
|
+
if (origin) warmFirstPage(server, origin);
|
|
4154
|
+
else warmContentManifest(server, getApplication);
|
|
3939
4155
|
});
|
|
3940
4156
|
}
|
|
3941
4157
|
};
|
|
3942
4158
|
}
|
|
3943
|
-
function
|
|
4159
|
+
function warmContentManifest(server, getApplication) {
|
|
4160
|
+
void (async () => {
|
|
4161
|
+
const { appRoot } = await getApplication();
|
|
4162
|
+
const module = await loadContentModule(server, appRoot);
|
|
4163
|
+
await module.content?.getManifest?.();
|
|
4164
|
+
})().catch((error) => {
|
|
4165
|
+
server.config.logger.error("Riebeckite content warmup failed.", {
|
|
4166
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
4167
|
+
});
|
|
4168
|
+
});
|
|
4169
|
+
}
|
|
4170
|
+
function warmFirstPage(server, origin) {
|
|
4171
|
+
const logger = server.config.logger;
|
|
4172
|
+
const originalInfo = logger.info.bind(logger);
|
|
4173
|
+
let banner;
|
|
4174
|
+
logger.info = (message, options) => {
|
|
4175
|
+
const plain = message.split(`${String.fromCharCode(27)}[`).map((part) => part.replace(/^[0-9;]*m/, "")).join("");
|
|
4176
|
+
if (plain.includes("VITE v") && plain.includes("ready in")) {
|
|
4177
|
+
banner = () => originalInfo(message, options);
|
|
4178
|
+
return;
|
|
4179
|
+
}
|
|
4180
|
+
originalInfo(message, options);
|
|
4181
|
+
};
|
|
4182
|
+
const printUrls = server.printUrls.bind(server);
|
|
4183
|
+
server.printUrls = () => {
|
|
4184
|
+
};
|
|
4185
|
+
const quiet = process.env.RIEBECKITE_DEV_INDICATOR === "1" || process.env.RIEBECKITE_MANAGED_DEV_CONTROL_FD !== void 0;
|
|
4186
|
+
const startedAt = performance.now();
|
|
4187
|
+
const elapsed = () => `${((performance.now() - startedAt) / 1e3).toFixed(1)}s`;
|
|
4188
|
+
const progress = (message) => logger.info(message, { clear: true });
|
|
4189
|
+
if (!quiet) progress(`riebeckite: preparing the first page (${elapsed()})`);
|
|
4190
|
+
const ticker = quiet ? void 0 : setInterval(() => {
|
|
4191
|
+
progress(`riebeckite: preparing the first page (${elapsed()})`);
|
|
4192
|
+
}, 5e3);
|
|
4193
|
+
ticker?.unref();
|
|
4194
|
+
void waitForDevWarmup(origin).then((status) => {
|
|
4195
|
+
if (ticker) clearInterval(ticker);
|
|
4196
|
+
banner?.();
|
|
4197
|
+
printUrls();
|
|
4198
|
+
if (status === void 0) {
|
|
4199
|
+
logger.error(`riebeckite: dev server did not respond (${elapsed()})`);
|
|
4200
|
+
return;
|
|
4201
|
+
}
|
|
4202
|
+
const suffix = status >= 400 ? ` (HTTP ${status})` : "";
|
|
4203
|
+
if (!quiet)
|
|
4204
|
+
progress(`riebeckite: ready at ${origin}${suffix} (${elapsed()})`);
|
|
4205
|
+
});
|
|
4206
|
+
}
|
|
4207
|
+
async function waitForDevWarmup(origin, timeoutMs = 3e5) {
|
|
4208
|
+
const deadline = performance.now() + timeoutMs;
|
|
4209
|
+
while (performance.now() < deadline) {
|
|
4210
|
+
try {
|
|
4211
|
+
return (await fetch(origin, { redirect: "manual" })).status;
|
|
4212
|
+
} catch {
|
|
4213
|
+
}
|
|
4214
|
+
await new Promise((resolve7) => {
|
|
4215
|
+
setTimeout(resolve7, 100).unref();
|
|
4216
|
+
});
|
|
4217
|
+
}
|
|
4218
|
+
return void 0;
|
|
4219
|
+
}
|
|
4220
|
+
function contentBareImportResolver(getApplication, ensure) {
|
|
3944
4221
|
return {
|
|
3945
4222
|
name: "riebeckite-content-bare-imports",
|
|
3946
4223
|
async resolveId(source, importer) {
|
|
3947
4224
|
if (!importer || !isBareImport(source)) return null;
|
|
4225
|
+
await ensure();
|
|
3948
4226
|
const { appRoot, contentRoot } = getApplication();
|
|
3949
4227
|
if (!isInDirectory2(importer, contentRoot)) return null;
|
|
3950
4228
|
return await this.resolve(source, path13.join(appRoot, "package.json"), {
|