@bagelink/blox 1.15.533 → 1.15.539
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/{shard-runner-DFZAHrwJ.js → shard-runner-BWwEIABX.js} +20 -31
- package/dist/{shard-runner-DTkniXr1.cjs → shard-runner-D778xfd2.cjs} +20 -31
- package/dist/ssg/build-grant.d.ts +18 -0
- package/dist/ssg/build-grant.d.ts.map +1 -0
- package/dist/ssg/build-request.d.ts +2 -0
- package/dist/ssg/build-request.d.ts.map +1 -1
- package/dist/ssg/cli.cjs +12 -5
- package/dist/ssg/cli.mjs +12 -5
- package/dist/ssg/cms-routes.d.ts.map +1 -1
- package/dist/ssg/createSSREntry.d.ts.map +1 -1
- package/dist/ssg/datastore-snapshot.d.ts +28 -0
- package/dist/ssg/datastore-snapshot.d.ts.map +1 -0
- package/dist/ssg/index.cjs +93 -10
- package/dist/ssg/index.d.ts +6 -2
- package/dist/ssg/index.d.ts.map +1 -1
- package/dist/ssg/index.mjs +107 -24
- package/dist/ssg/manifest-upload.d.ts +2 -1
- package/dist/ssg/manifest-upload.d.ts.map +1 -1
- package/dist/ssg/prerender.d.ts.map +1 -1
- package/dist/ssg/seo.d.ts +17 -0
- package/dist/ssg/seo.d.ts.map +1 -1
- package/dist/ssg/shard-runner.d.ts +3 -19
- package/dist/ssg/shard-runner.d.ts.map +1 -1
- package/dist/{validate-output-C-RpYkvf.js → validate-output-CV4nlrHm.js} +161 -57
- package/dist/{validate-output-C3NhyFsU.cjs → validate-output-DqDUmsyO.cjs} +142 -38
- package/dist/vite-plugin.cjs +3 -0
- package/dist/vite-plugin.d.ts.map +1 -1
- package/dist/vite-plugin.mjs +3 -0
- package/package.json +2 -2
package/dist/ssg/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { j, k,
|
|
1
|
+
import { b as buildPageHead, c as primaryContextEntry, d as buildJsonLd, e as extractPageText, B as BloxBuildResponseError, h as bloxBuildJson } from "../validate-output-CV4nlrHm.js";
|
|
2
|
+
import { i, j, k, f, l, m, n, o, g, q, s, t, w, x, y, z, p, a, r, A, C, u, v } from "../validate-output-CV4nlrHm.js";
|
|
3
3
|
import { BLOX_STATE_WINDOW_KEY, BLOX_WEBSITE_ID_WINDOW_KEY } from "./client.mjs";
|
|
4
4
|
import { BLOX_COLLECTIONS_WINDOW_KEY, BLOX_DATA_WINDOW_KEY, BLOX_PAGE_SEO_WINDOW_KEY, getCollectionCache, getEmbeddedWebsiteId, installBloxStateCache, installCollectionCache } from "./client.mjs";
|
|
5
5
|
import { createPinia } from "pinia";
|
|
@@ -105,12 +105,13 @@ function createBloxSSREntry(options) {
|
|
|
105
105
|
} = options;
|
|
106
106
|
const apiBase = options.apiBase ?? (typeof process !== "undefined" ? (_a = process.env) == null ? void 0 : _a.BAGELINK_API_URL : void 0) ?? "https://api.bagel.to";
|
|
107
107
|
let websiteIdCache = null;
|
|
108
|
+
const publishedBundleCache = /* @__PURE__ */ new Map();
|
|
108
109
|
setApiOrigin(apiBase);
|
|
109
110
|
setCollectionResolver(options.collectionResolver ?? null);
|
|
110
111
|
async function getWebsiteId() {
|
|
111
|
-
var _a2, _b;
|
|
112
|
+
var _a2, _b, _c;
|
|
112
113
|
if (websiteIdCache) return websiteIdCache;
|
|
113
|
-
const configuredWebsiteId = typeof process !== "undefined" ? (
|
|
114
|
+
const configuredWebsiteId = ((_a2 = options.buildRequest) == null ? void 0 : _a2.websiteId) ?? (typeof process !== "undefined" ? (_c = (_b = process.env) == null ? void 0 : _b.BLOX_WEBSITE_ID) == null ? void 0 : _c.trim() : void 0);
|
|
114
115
|
if (configuredWebsiteId) {
|
|
115
116
|
websiteIdCache = configuredWebsiteId;
|
|
116
117
|
return websiteIdCache;
|
|
@@ -134,15 +135,21 @@ function createBloxSSREntry(options) {
|
|
|
134
135
|
return { locale, slug: urlPath || "/" };
|
|
135
136
|
}
|
|
136
137
|
async function fetchResolvedPage(slug, pageLocale) {
|
|
137
|
-
var _a2, _b;
|
|
138
|
+
var _a2, _b, _c;
|
|
138
139
|
const websiteId = await getWebsiteId();
|
|
139
|
-
const configuredWebsiteId = typeof process !== "undefined" ? (
|
|
140
|
+
const configuredWebsiteId = ((_a2 = options.buildRequest) == null ? void 0 : _a2.websiteId) ?? (typeof process !== "undefined" ? (_c = (_b = process.env) == null ? void 0 : _b.BLOX_WEBSITE_ID) == null ? void 0 : _c.trim() : void 0);
|
|
140
141
|
if (configuredWebsiteId) {
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
142
|
+
const cacheKey = pageLocale;
|
|
143
|
+
let pending = publishedBundleCache.get(cacheKey);
|
|
144
|
+
if (!pending) {
|
|
145
|
+
pending = bloxBuildJson(
|
|
146
|
+
`${apiBase}/blox-build/websites/${websiteId}/published?locale=${encodeURIComponent(pageLocale)}`,
|
|
147
|
+
{},
|
|
148
|
+
options.buildRequest
|
|
149
|
+
);
|
|
150
|
+
publishedBundleCache.set(cacheKey, pending);
|
|
151
|
+
}
|
|
152
|
+
const bundle = await pending;
|
|
146
153
|
const page = bundle.pages.find((candidate) => candidate.slug === slug);
|
|
147
154
|
if (!page) return null;
|
|
148
155
|
return { page, contexts: {}, warnings: [] };
|
|
@@ -233,6 +240,76 @@ function createBloxSSREntry(options) {
|
|
|
233
240
|
}
|
|
234
241
|
return { render, prefetchResolve };
|
|
235
242
|
}
|
|
243
|
+
async function fetchDatastoreSnapshot(options) {
|
|
244
|
+
var _a;
|
|
245
|
+
const endpointPrefix = options.endpointPrefix ?? "/datastore";
|
|
246
|
+
const limit = options.limit ?? 2e3;
|
|
247
|
+
const collections = {};
|
|
248
|
+
for (const collection of options.collections) {
|
|
249
|
+
collections[collection] = {};
|
|
250
|
+
const localized = await Promise.all(options.locales.map(async (locale) => {
|
|
251
|
+
const rows = [];
|
|
252
|
+
for (let offset = 0; ; offset += limit) {
|
|
253
|
+
const url = new URL(
|
|
254
|
+
`${endpointPrefix}/${encodeURIComponent(options.store)}/collections/${encodeURIComponent(collection)}`,
|
|
255
|
+
options.apiBase
|
|
256
|
+
);
|
|
257
|
+
url.searchParams.set("locale", locale);
|
|
258
|
+
url.searchParams.set("limit", String(limit));
|
|
259
|
+
url.searchParams.set("offset", String(offset));
|
|
260
|
+
const page = await bloxBuildJson(
|
|
261
|
+
url,
|
|
262
|
+
{},
|
|
263
|
+
options.requestOptions
|
|
264
|
+
);
|
|
265
|
+
if (!Array.isArray(page)) {
|
|
266
|
+
throw new TypeError(`Datastore snapshot response is not an array: ${collection}/${locale}`);
|
|
267
|
+
}
|
|
268
|
+
rows.push(...page);
|
|
269
|
+
if (page.length < limit) break;
|
|
270
|
+
}
|
|
271
|
+
return [locale, rows];
|
|
272
|
+
}));
|
|
273
|
+
for (const [locale, rows] of localized) collections[collection][locale] = rows;
|
|
274
|
+
(_a = options.onCollection) == null ? void 0 : _a.call(
|
|
275
|
+
options,
|
|
276
|
+
collection,
|
|
277
|
+
Object.fromEntries(localized.map(([locale, rows]) => [locale, rows.length]))
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
return {
|
|
281
|
+
version: 1,
|
|
282
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
283
|
+
apiBase: options.apiBase,
|
|
284
|
+
store: options.store,
|
|
285
|
+
collections
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
function snapshotRows(snapshot, collection, locale) {
|
|
289
|
+
var _a;
|
|
290
|
+
const rows = (_a = snapshot.collections[collection]) == null ? void 0 : _a[locale];
|
|
291
|
+
if (!rows) throw new Error(`Datastore snapshot miss: ${collection}/${locale}`);
|
|
292
|
+
return rows;
|
|
293
|
+
}
|
|
294
|
+
function querySnapshotRows(snapshot, options) {
|
|
295
|
+
var _a;
|
|
296
|
+
let rows = snapshotRows(snapshot, options.collection, options.locale);
|
|
297
|
+
if (options.q) {
|
|
298
|
+
const match = options.q.match(/^\s*([A-Za-z0-9_.-]+)\s+eq\s+"((?:\\.|[^"])*)"\s*$/);
|
|
299
|
+
if (!match) throw new Error(`Unsupported snapshot SCIM query: ${options.q}`);
|
|
300
|
+
const [, field, raw] = match;
|
|
301
|
+
const expected = raw.replace(/\\"/g, '"').replace(/\\\\/g, "\\");
|
|
302
|
+
rows = rows.filter((row) => String(row[field]) === expected);
|
|
303
|
+
}
|
|
304
|
+
const offset = options.offset ?? 0;
|
|
305
|
+
rows = rows.slice(offset, offset + (options.limit ?? 100));
|
|
306
|
+
if ((_a = options.select) == null ? void 0 : _a.length) {
|
|
307
|
+
return rows.map((row) => Object.fromEntries(
|
|
308
|
+
options.select.filter((key) => key in row).map((key) => [key, row[key]])
|
|
309
|
+
));
|
|
310
|
+
}
|
|
311
|
+
return rows;
|
|
312
|
+
}
|
|
236
313
|
export {
|
|
237
314
|
BLOX_COLLECTIONS_WINDOW_KEY,
|
|
238
315
|
BLOX_DATA_WINDOW_KEY,
|
|
@@ -241,33 +318,39 @@ export {
|
|
|
241
318
|
BLOX_WEBSITE_ID_WINDOW_KEY,
|
|
242
319
|
BloxBuildResponseError,
|
|
243
320
|
bloxBuildJson,
|
|
244
|
-
|
|
321
|
+
i as bloxBuildRequest,
|
|
245
322
|
buildJsonLd,
|
|
246
323
|
buildPageHead,
|
|
247
|
-
|
|
324
|
+
j as buildSiteHead,
|
|
248
325
|
createBloxSSREntry,
|
|
249
326
|
extractPageText,
|
|
250
|
-
|
|
327
|
+
k as fetchCmsPrerenderPaths,
|
|
251
328
|
f as fetchCmsSiteData,
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
g as
|
|
329
|
+
fetchDatastoreSnapshot,
|
|
330
|
+
l as generateLlmsFullTxt,
|
|
331
|
+
m as generateLlmsTxt,
|
|
332
|
+
n as generateNetlifyRedirects,
|
|
333
|
+
o as generateRobotsTxt,
|
|
334
|
+
g as generateSitemapArtifacts,
|
|
335
|
+
q as generateSitemapIndexXml,
|
|
336
|
+
s as generateSitemapXml,
|
|
258
337
|
t as getBloxBuildRequestOptions,
|
|
259
338
|
getCollectionCache,
|
|
260
339
|
getEmbeddedWebsiteId,
|
|
261
340
|
w as getSiteIconFlags,
|
|
262
341
|
installBloxStateCache,
|
|
263
342
|
installCollectionCache,
|
|
264
|
-
|
|
265
|
-
|
|
343
|
+
x as localeSitemapPath,
|
|
344
|
+
y as mergeLlmParts,
|
|
345
|
+
z as parseBloxBuildGrantBody,
|
|
266
346
|
p as polyfillBloxSsgGlobals,
|
|
267
347
|
a as prerender,
|
|
348
|
+
querySnapshotRows,
|
|
268
349
|
renderBloxSsgPage,
|
|
269
|
-
|
|
270
|
-
|
|
350
|
+
r as resolveBloxBuildGrant,
|
|
351
|
+
A as resolveManifestProvenance,
|
|
352
|
+
snapshotRows,
|
|
353
|
+
C as splitSitemapPathsByLocale,
|
|
271
354
|
u as uploadBloxManifest,
|
|
272
355
|
v as validateSsgOutput
|
|
273
356
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BloxManifest } from '../manifest';
|
|
2
|
+
import { BloxBuildRequestOptions } from './build-request';
|
|
2
3
|
export interface ManifestProvenance {
|
|
3
4
|
repository: string;
|
|
4
5
|
branch: string;
|
|
@@ -9,5 +10,5 @@ export interface ManifestUpload {
|
|
|
9
10
|
provenance: ManifestProvenance;
|
|
10
11
|
}
|
|
11
12
|
export declare function resolveManifestProvenance(): Promise<ManifestProvenance>;
|
|
12
|
-
export declare function uploadBloxManifest(apiBase: string, websiteId: string): Promise<void>;
|
|
13
|
+
export declare function uploadBloxManifest(apiBase: string, websiteId: string, requestOptions?: BloxBuildRequestOptions): Promise<void>;
|
|
13
14
|
//# sourceMappingURL=manifest-upload.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest-upload.d.ts","sourceRoot":"","sources":["../../src/ssg/manifest-upload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"manifest-upload.d.ts","sourceRoot":"","sources":["../../src/ssg/manifest-upload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAK/C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAA;AAG9D,MAAM,WAAW,kBAAkB;IAClC,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,cAAc;IAC9B,QAAQ,EAAE,YAAY,CAAA;IACtB,UAAU,EAAE,kBAAkB,CAAA;CAC9B;AAsBD,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAgB7E;AAED,wBAAsB,kBAAkB,CACvC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,cAAc,GAAE,uBAA4B,GAC1C,OAAO,CAAC,IAAI,CAAC,CAoBf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prerender.d.ts","sourceRoot":"","sources":["../../src/ssg/prerender.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"prerender.d.ts","sourceRoot":"","sources":["../../src/ssg/prerender.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAgBvE,KAAK,WAAW,GAAG,MAAM,G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,CAmTlD;AA4FD,wBAAgB,kBAAkB,CACjC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,SAAS,SAAK,GACZ,MAAM,CA8CR"}
|
package/dist/ssg/seo.d.ts
CHANGED
|
@@ -77,6 +77,23 @@ export declare function splitSitemapPathsByLocale(options: {
|
|
|
77
77
|
supportedLocales: string[];
|
|
78
78
|
}): Map<string, string[]>;
|
|
79
79
|
export declare function localeSitemapPath(locale: string): string;
|
|
80
|
+
export interface SitemapRoute {
|
|
81
|
+
path: string;
|
|
82
|
+
noindex?: boolean;
|
|
83
|
+
lastmod?: string;
|
|
84
|
+
}
|
|
85
|
+
export interface SitemapArtifact {
|
|
86
|
+
path: string;
|
|
87
|
+
content: string;
|
|
88
|
+
}
|
|
89
|
+
export declare function generateSitemapArtifacts(options: {
|
|
90
|
+
routes: SitemapRoute[];
|
|
91
|
+
canonicalBase: string;
|
|
92
|
+
defaultLocale: string;
|
|
93
|
+
supportedLocales: string[];
|
|
94
|
+
splitByLocale?: boolean;
|
|
95
|
+
additionalSitemapPaths?: string[];
|
|
96
|
+
}): SitemapArtifact[];
|
|
80
97
|
export declare function generateRobotsTxt(options: {
|
|
81
98
|
robotsTxt?: string | null;
|
|
82
99
|
canonicalBase?: string;
|
package/dist/ssg/seo.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seo.d.ts","sourceRoot":"","sources":["../../src/ssg/seo.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAOzE,4DAA4D;AAC5D,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,QAAQ,CAAA;IACd,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACnC,QAAQ,CAAC,EAAE,MAAM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BAAgB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,GAAG;IAC9D,UAAU,EAAE,OAAO,CAAA;IACnB,UAAU,EAAE,OAAO,CAAA;CACnB,CAMA;AAMD,UAAU,gBAAgB;IACzB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CACpB;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACpC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,SAAS,GAClE,gBAAgB,CAgBlB;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAClC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,SAAS,GAClE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GAAG,IAAI,CAEtD"}
|
|
@@ -1,22 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Built-in sharded SSG runner (coordinator).
|
|
3
|
-
*
|
|
4
|
-
* Vue SSR (`renderToString`) is CPU-bound and single-threaded, and a single
|
|
5
|
-
* long-lived `blox-ssg` process also accumulates happy-dom/window/timer state
|
|
6
|
-
* under bun — on large sites (thousands of pages) that leak eventually crashes
|
|
7
|
-
* the process silently. Splitting the work across N short-lived child processes
|
|
8
|
-
* (each rendering a disjoint `--shard=i/n` slice into the same `dist`) both
|
|
9
|
-
* parallelizes the CPU-bound render AND keeps each process well under the leak
|
|
10
|
-
* threshold.
|
|
11
|
-
*
|
|
12
|
-
* This module is the coordinator: it enumerates the route list once (optionally
|
|
13
|
-
* via an external `--routes-cmd` for router-driven sites that don't use CMS page
|
|
14
|
-
* discovery), then spawns the shards, divides the resolve-prefetch budget across
|
|
15
|
-
* them, and merges each shard's llms part file into the final llms.txt.
|
|
16
|
-
*
|
|
17
|
-
* Activated by `--shards=<n|auto>` on the CLI. Without it, the CLI runs a single
|
|
18
|
-
* in-process render exactly as before (full backward compat).
|
|
19
|
-
*/
|
|
1
|
+
import { BloxBuildRequestOptions } from './build-request';
|
|
20
2
|
export interface ShardRunnerOptions {
|
|
21
3
|
/** Number of shards, or 'auto' → min(cores, cap). */
|
|
22
4
|
shards: number | 'auto';
|
|
@@ -26,6 +8,8 @@ export interface ShardRunnerOptions {
|
|
|
26
8
|
apiBase: string;
|
|
27
9
|
/** CMS website name (for the post-run llms merge). */
|
|
28
10
|
websiteName: string;
|
|
11
|
+
/** Ephemeral build authority inherited by discovery and child shards. */
|
|
12
|
+
buildRequest?: BloxBuildRequestOptions;
|
|
29
13
|
/** Extra paths already parsed from argv (router-driven sites, static routes). */
|
|
30
14
|
extraPaths: string[];
|
|
31
15
|
/** Other pass-through flags to forward verbatim to each shard (e.g. --exclude=…, --crawl). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shard-runner.d.ts","sourceRoot":"","sources":["../../src/ssg/shard-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;
|
|
1
|
+
{"version":3,"file":"shard-runner.d.ts","sourceRoot":"","sources":["../../src/ssg/shard-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAQH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAA;AAI9D,MAAM,WAAW,kBAAkB;IAClC,qDAAqD;IACrD,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAA;IACZ,uDAAuD;IACvD,OAAO,EAAE,MAAM,CAAA;IACf,sDAAsD;IACtD,WAAW,EAAE,MAAM,CAAA;IACnB,yEAAyE;IACzE,YAAY,CAAC,EAAE,uBAAuB,CAAA;IACtC,iFAAiF;IACjF,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,8FAA8F;IAC9F,eAAe,EAAE,MAAM,EAAE,CAAA;IACzB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CAClB;AA4ED;;GAEG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CAoI1E"}
|
|
@@ -1,9 +1,78 @@
|
|
|
1
|
+
import process$1 from "node:process";
|
|
1
2
|
import { execFile } from "node:child_process";
|
|
2
3
|
import fs, { readFile } from "node:fs/promises";
|
|
3
4
|
import path, { resolve } from "node:path";
|
|
4
|
-
import process$1 from "node:process";
|
|
5
5
|
import { pathToFileURL } from "node:url";
|
|
6
6
|
import { r as resolvePageTitle, p as primaryPageContext, c as contextPageTitle } from "./pageTitle-BOTMH-D8.js";
|
|
7
|
+
const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
8
|
+
const PAYLOAD_FIELDS = /* @__PURE__ */ new Set(["version", "source", "website_id", "grant"]);
|
|
9
|
+
function parseJsonObject(value) {
|
|
10
|
+
let parsed;
|
|
11
|
+
try {
|
|
12
|
+
parsed = JSON.parse(value);
|
|
13
|
+
} catch {
|
|
14
|
+
throw new Error("Invalid Blox build hook payload");
|
|
15
|
+
}
|
|
16
|
+
if (parsed === null || Array.isArray(parsed) || typeof parsed !== "object") {
|
|
17
|
+
throw new Error("Invalid Blox build hook payload");
|
|
18
|
+
}
|
|
19
|
+
return parsed;
|
|
20
|
+
}
|
|
21
|
+
function parseBloxBuildGrantBody(body) {
|
|
22
|
+
const trimmed = body.trim();
|
|
23
|
+
if (!trimmed) throw new Error("Missing Blox build hook payload");
|
|
24
|
+
let payload;
|
|
25
|
+
try {
|
|
26
|
+
payload = parseJsonObject(trimmed);
|
|
27
|
+
} catch {
|
|
28
|
+
let decoded;
|
|
29
|
+
try {
|
|
30
|
+
decoded = decodeURIComponent(trimmed);
|
|
31
|
+
} catch {
|
|
32
|
+
throw new Error("Invalid Blox build hook payload");
|
|
33
|
+
}
|
|
34
|
+
payload = parseJsonObject(decoded);
|
|
35
|
+
}
|
|
36
|
+
if (Object.keys(payload).some((field) => !PAYLOAD_FIELDS.has(field))) {
|
|
37
|
+
throw new Error("Invalid Blox build hook payload fields");
|
|
38
|
+
}
|
|
39
|
+
if (payload.version !== 1 || payload.source !== "blox" || typeof payload.website_id !== "string" || !UUID_PATTERN.test(payload.website_id) || typeof payload.grant !== "string" || payload.grant.trim() === "") {
|
|
40
|
+
throw new Error("Invalid Blox build hook payload");
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
version: 1,
|
|
44
|
+
source: "blox",
|
|
45
|
+
websiteId: payload.website_id,
|
|
46
|
+
grant: payload.grant
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function isLocalOrTest(mode, env2) {
|
|
50
|
+
return mode === "localhost" || mode === "development" || mode === "test" || env2.NODE_ENV === "development" || env2.NODE_ENV === "test";
|
|
51
|
+
}
|
|
52
|
+
function resolveBloxBuildGrant(options = {}) {
|
|
53
|
+
var _a, _b, _c, _d, _e;
|
|
54
|
+
const env2 = options.env ?? process$1.env;
|
|
55
|
+
if (isLocalOrTest(options.mode, env2)) {
|
|
56
|
+
const websiteId = (_a = env2.BLOX_WEBSITE_ID) == null ? void 0 : _a.trim();
|
|
57
|
+
const grant2 = (_b = env2.BLOX_BUILD_TOKEN) == null ? void 0 : _b.trim();
|
|
58
|
+
if (!websiteId && !grant2) return void 0;
|
|
59
|
+
if (!websiteId || !UUID_PATTERN.test(websiteId) || !grant2) {
|
|
60
|
+
throw new Error("Local Blox build overrides require a valid BLOX_WEBSITE_ID and BLOX_BUILD_TOKEN");
|
|
61
|
+
}
|
|
62
|
+
return { version: 1, source: "blox", websiteId, grant: grant2 };
|
|
63
|
+
}
|
|
64
|
+
if (!((_c = env2.INCOMING_HOOK_URL) == null ? void 0 : _c.trim()) || !((_d = env2.INCOMING_HOOK_TITLE) == null ? void 0 : _d.trim())) {
|
|
65
|
+
throw new Error("Blox production builds require Netlify incoming hook metadata");
|
|
66
|
+
}
|
|
67
|
+
const body = env2.INCOMING_HOOK_BODY;
|
|
68
|
+
if (body == null) throw new Error("Blox production builds require a hook payload");
|
|
69
|
+
const grant = parseBloxBuildGrantBody(body);
|
|
70
|
+
const configuredWebsiteId = (_e = env2.BLOX_WEBSITE_ID) == null ? void 0 : _e.trim();
|
|
71
|
+
if (configuredWebsiteId && configuredWebsiteId !== grant.websiteId) {
|
|
72
|
+
throw new Error("Blox build hook website does not match the configured website");
|
|
73
|
+
}
|
|
74
|
+
return grant;
|
|
75
|
+
}
|
|
7
76
|
class BloxBuildResponseError extends Error {
|
|
8
77
|
constructor(status, url, statusText) {
|
|
9
78
|
super(`Build API ${status} ${statusText}: ${url}`);
|
|
@@ -18,6 +87,7 @@ function env(name) {
|
|
|
18
87
|
}
|
|
19
88
|
function getBloxBuildRequestOptions(overrides = {}) {
|
|
20
89
|
return {
|
|
90
|
+
websiteId: overrides.websiteId,
|
|
21
91
|
token: overrides.token ?? env("BLOX_BUILD_TOKEN"),
|
|
22
92
|
tokenHeader: overrides.tokenHeader ?? env("BLOX_BUILD_TOKEN_HEADER") ?? "Authorization",
|
|
23
93
|
tokenScheme: overrides.tokenScheme ?? env("BLOX_BUILD_TOKEN_SCHEME") ?? "Bearer",
|
|
@@ -88,7 +158,7 @@ function expandLocalePaths(paths, defaultLocale, supportedLocales) {
|
|
|
88
158
|
}
|
|
89
159
|
async function fetchCmsSiteData(apiBase, websiteName, requestOptions = {}) {
|
|
90
160
|
var _a, _b, _c;
|
|
91
|
-
const websiteId = typeof process !== "undefined" ? (_b = (_a = process.env) == null ? void 0 : _a.BLOX_WEBSITE_ID) == null ? void 0 : _b.trim() : void 0;
|
|
161
|
+
const websiteId = requestOptions.websiteId ?? (typeof process !== "undefined" ? (_b = (_a = process.env) == null ? void 0 : _a.BLOX_WEBSITE_ID) == null ? void 0 : _b.trim() : void 0);
|
|
92
162
|
if (websiteId) {
|
|
93
163
|
const bundle = await bloxBuildJson(
|
|
94
164
|
`${apiBase}/blox-build/websites/${websiteId}/published`,
|
|
@@ -111,9 +181,11 @@ async function fetchCmsSiteData(apiBase, websiteName, requestOptions = {}) {
|
|
|
111
181
|
collections: extractCollectionRefs(bundle.pages)
|
|
112
182
|
};
|
|
113
183
|
}
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
184
|
+
const site = await bloxBuildJson(
|
|
185
|
+
`${apiBase}/blox/sites/${encodeURIComponent(websiteName)}`,
|
|
186
|
+
{},
|
|
187
|
+
requestOptions
|
|
188
|
+
);
|
|
117
189
|
if ((site == null ? void 0 : site.id) == null || site.id === "") throw new Error(`Website "${websiteName}" not found at ${apiBase}`);
|
|
118
190
|
const website = await bloxBuildJson(
|
|
119
191
|
`${apiBase}/blox/websites/${site.id}`,
|
|
@@ -169,6 +241,7 @@ async function fetchCmsPrerenderPaths(apiBase, websiteName, requestOptions = {})
|
|
|
169
241
|
}
|
|
170
242
|
async function expandRoutes(apiBase, pages, requestOptions, locale) {
|
|
171
243
|
const routes = [];
|
|
244
|
+
const grantedWebsiteId = requestOptions.websiteId;
|
|
172
245
|
for (const page of pages) {
|
|
173
246
|
const slug = page.slug ?? "/";
|
|
174
247
|
if (page.status && page.status !== "published") continue;
|
|
@@ -178,12 +251,13 @@ async function expandRoutes(apiBase, pages, requestOptions, locale) {
|
|
|
178
251
|
if (b.adapter === "datastore" && b.collection != null && b.collection !== "" && b.store != null && b.store !== "" && b.bind_by != null && b.bind_by !== "") {
|
|
179
252
|
const q = b.filter ? `&q=${encodeURIComponent(b.filter)}` : "";
|
|
180
253
|
const localeParam = locale ? `&locale=${encodeURIComponent(locale)}` : "";
|
|
254
|
+
const collectionPath = grantedWebsiteId ? `/blox-build/websites/${grantedWebsiteId}/collections/${b.store}/${b.collection}` : `/datastore/${b.store}/collections/${b.collection}`;
|
|
181
255
|
const itemsData = await bloxBuildJson(
|
|
182
|
-
`${apiBase}
|
|
256
|
+
`${apiBase}${collectionPath}?limit=200${localeParam}${q}`,
|
|
183
257
|
{},
|
|
184
258
|
requestOptions
|
|
185
259
|
);
|
|
186
|
-
const items = Array.isArray(itemsData) ? itemsData : itemsData.data ?? [];
|
|
260
|
+
const items = Array.isArray(itemsData) ? itemsData : itemsData.items ?? itemsData.data ?? [];
|
|
187
261
|
for (const item of items) {
|
|
188
262
|
const bindValue = item[b.bind_by];
|
|
189
263
|
if (typeof bindValue !== "string" || bindValue === "") continue;
|
|
@@ -249,9 +323,9 @@ async function resolveManifestProvenance() {
|
|
|
249
323
|
commit
|
|
250
324
|
};
|
|
251
325
|
}
|
|
252
|
-
async function uploadBloxManifest(apiBase, websiteId) {
|
|
253
|
-
if (!environment("BLOX_BUILD_TOKEN")) {
|
|
254
|
-
throw new Error("
|
|
326
|
+
async function uploadBloxManifest(apiBase, websiteId, requestOptions = {}) {
|
|
327
|
+
if (!requestOptions.token && !environment("BLOX_BUILD_TOKEN")) {
|
|
328
|
+
throw new Error("A Blox build grant is required to upload the Blox manifest");
|
|
255
329
|
}
|
|
256
330
|
const distDirectory = resolve(process$1.cwd(), "dist");
|
|
257
331
|
const resolvedManifestPath = resolve(distDirectory, ".blox-manifest.json");
|
|
@@ -266,7 +340,8 @@ async function uploadBloxManifest(apiBase, websiteId) {
|
|
|
266
340
|
method: "PUT",
|
|
267
341
|
headers: { "Content-Type": "application/json" },
|
|
268
342
|
body: JSON.stringify(payload)
|
|
269
|
-
}
|
|
343
|
+
},
|
|
344
|
+
requestOptions
|
|
270
345
|
);
|
|
271
346
|
}
|
|
272
347
|
async function polyfillBloxSsgGlobals(options) {
|
|
@@ -477,6 +552,45 @@ function localeSitemapPath(locale) {
|
|
|
477
552
|
}
|
|
478
553
|
return `/sitemap-${locale}.xml`;
|
|
479
554
|
}
|
|
555
|
+
function generateSitemapArtifacts(options) {
|
|
556
|
+
const indexableRoutes = options.routes.filter((route) => !route.noindex);
|
|
557
|
+
const renderedPaths = indexableRoutes.map((route) => route.path);
|
|
558
|
+
const lastmod = Object.fromEntries(
|
|
559
|
+
indexableRoutes.flatMap((route) => route.lastmod ? [[route.path, route.lastmod]] : [])
|
|
560
|
+
);
|
|
561
|
+
if (options.splitByLocale === false) {
|
|
562
|
+
return [{
|
|
563
|
+
path: "/sitemap.xml",
|
|
564
|
+
content: generateSitemapXml({ renderedPaths, canonicalBase: options.canonicalBase, lastmod })
|
|
565
|
+
}];
|
|
566
|
+
}
|
|
567
|
+
const pathsByLocale = splitSitemapPathsByLocale({
|
|
568
|
+
renderedPaths,
|
|
569
|
+
defaultLocale: options.defaultLocale,
|
|
570
|
+
supportedLocales: options.supportedLocales
|
|
571
|
+
});
|
|
572
|
+
const localeArtifacts = [...pathsByLocale].map(([locale, paths]) => ({
|
|
573
|
+
path: localeSitemapPath(locale),
|
|
574
|
+
content: generateSitemapXml({
|
|
575
|
+
renderedPaths: paths,
|
|
576
|
+
canonicalBase: options.canonicalBase,
|
|
577
|
+
lastmod
|
|
578
|
+
})
|
|
579
|
+
}));
|
|
580
|
+
return [
|
|
581
|
+
{
|
|
582
|
+
path: "/sitemap.xml",
|
|
583
|
+
content: generateSitemapIndexXml({
|
|
584
|
+
canonicalBase: options.canonicalBase,
|
|
585
|
+
sitemapPaths: [
|
|
586
|
+
...localeArtifacts.map((artifact) => artifact.path),
|
|
587
|
+
...options.additionalSitemapPaths ?? []
|
|
588
|
+
]
|
|
589
|
+
})
|
|
590
|
+
},
|
|
591
|
+
...localeArtifacts
|
|
592
|
+
];
|
|
593
|
+
}
|
|
480
594
|
function generateRobotsTxt(options) {
|
|
481
595
|
const { robotsTxt, canonicalBase, noindex } = options;
|
|
482
596
|
if (noindex) {
|
|
@@ -955,38 +1069,25 @@ async function prerender({
|
|
|
955
1069
|
if (writeSharedAssets) {
|
|
956
1070
|
const sitemapPaths = rendered.filter((p) => !noindexPaths.has(p));
|
|
957
1071
|
if (canonicalBase && sitemapPaths.length > 0) {
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
generateSitemapXml({ renderedPaths: localePaths, canonicalBase, lastmod }),
|
|
970
|
-
"utf8"
|
|
971
|
-
);
|
|
972
|
-
sitemapFiles.push(sitemapPath);
|
|
973
|
-
}
|
|
974
|
-
await fs.writeFile(
|
|
975
|
-
path.join(absClient, "sitemap.xml"),
|
|
976
|
-
generateSitemapIndexXml({ canonicalBase, sitemapPaths: sitemapFiles }),
|
|
977
|
-
"utf8"
|
|
978
|
-
);
|
|
979
|
-
console.log(` Generated sitemap.xml (${sitemapFiles.length} locales, ${sitemapPaths.length} URLs)`);
|
|
980
|
-
} else {
|
|
1072
|
+
const artifacts = generateSitemapArtifacts({
|
|
1073
|
+
routes: sitemapPaths.map((routePath) => ({
|
|
1074
|
+
path: routePath,
|
|
1075
|
+
lastmod: lastmod[routePath]
|
|
1076
|
+
})),
|
|
1077
|
+
canonicalBase,
|
|
1078
|
+
defaultLocale: (website == null ? void 0 : website.default_locale) ?? "en",
|
|
1079
|
+
supportedLocales: (website == null ? void 0 : website.supported_locales) ?? [(website == null ? void 0 : website.default_locale) ?? "en"],
|
|
1080
|
+
splitByLocale: (_b = website == null ? void 0 : website.seo) == null ? void 0 : _b.sitemap_split_by_locale
|
|
1081
|
+
});
|
|
1082
|
+
for (const artifact of artifacts) {
|
|
981
1083
|
await fs.writeFile(
|
|
982
|
-
path.join(absClient,
|
|
983
|
-
|
|
1084
|
+
path.join(absClient, artifact.path.slice(1)),
|
|
1085
|
+
artifact.content,
|
|
984
1086
|
"utf8"
|
|
985
1087
|
);
|
|
986
|
-
console.log(` Generated sitemap.xml (${sitemapPaths.length} URLs)`);
|
|
987
1088
|
}
|
|
988
1089
|
const skipped = noindexPaths.size > 0 ? ` (${noindexPaths.size} noindex excluded)` : "";
|
|
989
|
-
|
|
1090
|
+
console.log(` Generated sitemap.xml (${artifacts.length} files, ${sitemapPaths.length} URLs)${skipped}`);
|
|
990
1091
|
}
|
|
991
1092
|
const robotsTxt = generateRobotsTxt({
|
|
992
1093
|
robotsTxt: website == null ? void 0 : website.robots_txt,
|
|
@@ -1261,31 +1362,34 @@ async function validateSitemap(outDir, content) {
|
|
|
1261
1362
|
return failures;
|
|
1262
1363
|
}
|
|
1263
1364
|
export {
|
|
1365
|
+
resolveManifestProvenance as A,
|
|
1264
1366
|
BloxBuildResponseError as B,
|
|
1367
|
+
splitSitemapPathsByLocale as C,
|
|
1368
|
+
llmArtifacts as D,
|
|
1265
1369
|
prerender as a,
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1370
|
+
buildPageHead as b,
|
|
1371
|
+
primaryContextEntry as c,
|
|
1372
|
+
buildJsonLd as d,
|
|
1373
|
+
extractPageText as e,
|
|
1270
1374
|
fetchCmsSiteData as f,
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1375
|
+
generateSitemapArtifacts as g,
|
|
1376
|
+
bloxBuildJson as h,
|
|
1377
|
+
bloxBuildRequest as i,
|
|
1378
|
+
buildSiteHead as j,
|
|
1379
|
+
fetchCmsPrerenderPaths as k,
|
|
1380
|
+
generateLlmsFullTxt as l,
|
|
1381
|
+
generateLlmsTxt as m,
|
|
1382
|
+
generateNetlifyRedirects as n,
|
|
1383
|
+
generateRobotsTxt as o,
|
|
1280
1384
|
polyfillBloxSsgGlobals as p,
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1385
|
+
generateSitemapIndexXml as q,
|
|
1386
|
+
resolveBloxBuildGrant as r,
|
|
1387
|
+
generateSitemapXml as s,
|
|
1284
1388
|
getBloxBuildRequestOptions as t,
|
|
1285
1389
|
uploadBloxManifest as u,
|
|
1286
1390
|
validateSsgOutput as v,
|
|
1287
1391
|
getSiteIconFlags as w,
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1392
|
+
localeSitemapPath as x,
|
|
1393
|
+
mergeLlmParts as y,
|
|
1394
|
+
parseBloxBuildGrantBody as z
|
|
1291
1395
|
};
|