@bagelink/blox 1.15.311 → 1.15.323
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/{prerender-BCRyYSNg.js → prerender-BpLkRIA8.js} +107 -72
- package/dist/{prerender-DQ7D6auC.cjs → prerender-CYES_qNu.cjs} +92 -57
- package/dist/{shard-runner-BJd76pCJ.js → shard-runner-26opEo2v.js} +2 -2
- package/dist/{shard-runner-DKz93Boo.cjs → shard-runner-D_67ZcHW.cjs} +2 -2
- package/dist/ssg/build-request.d.ts +22 -0
- package/dist/ssg/build-request.d.ts.map +1 -0
- package/dist/ssg/cli.cjs +7 -4
- package/dist/ssg/cli.mjs +7 -4
- package/dist/ssg/cms-routes.d.ts +3 -2
- package/dist/ssg/cms-routes.d.ts.map +1 -1
- package/dist/ssg/createSSREntry.d.ts +3 -0
- package/dist/ssg/createSSREntry.d.ts.map +1 -1
- package/dist/ssg/index.cjs +25 -21
- package/dist/ssg/index.d.ts +2 -0
- package/dist/ssg/index.d.ts.map +1 -1
- package/dist/ssg/index.mjs +45 -41
- package/dist/ssg/prerender.d.ts.map +1 -1
- package/dist/ssg/render-resolved-page.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,48 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import process from "node:process";
|
|
3
|
+
import process$1 from "node:process";
|
|
4
4
|
import { pathToFileURL } from "node:url";
|
|
5
|
+
class BloxBuildResponseError extends Error {
|
|
6
|
+
constructor(status, url, statusText) {
|
|
7
|
+
super(`Build API ${status} ${statusText}: ${url}`);
|
|
8
|
+
this.status = status;
|
|
9
|
+
this.url = url;
|
|
10
|
+
this.name = "BloxBuildResponseError";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function env(name) {
|
|
14
|
+
var _a, _b;
|
|
15
|
+
return typeof process !== "undefined" ? ((_b = (_a = process.env) == null ? void 0 : _a[name]) == null ? void 0 : _b.trim()) || void 0 : void 0;
|
|
16
|
+
}
|
|
17
|
+
function getBloxBuildRequestOptions(overrides = {}) {
|
|
18
|
+
return {
|
|
19
|
+
token: overrides.token ?? env("BLOX_BUILD_TOKEN"),
|
|
20
|
+
tokenHeader: overrides.tokenHeader ?? env("BLOX_BUILD_TOKEN_HEADER") ?? "Authorization",
|
|
21
|
+
tokenScheme: overrides.tokenScheme ?? env("BLOX_BUILD_TOKEN_SCHEME") ?? "Bearer",
|
|
22
|
+
headers: overrides.headers
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
async function bloxBuildRequest(input, init = {}, options = {}) {
|
|
26
|
+
const config = getBloxBuildRequestOptions(options);
|
|
27
|
+
const headers = new Headers(config.headers);
|
|
28
|
+
new Headers(init.headers).forEach((value, key) => headers.set(key, value));
|
|
29
|
+
if (config.token && config.tokenHeader && !headers.has(config.tokenHeader)) {
|
|
30
|
+
headers.set(
|
|
31
|
+
config.tokenHeader,
|
|
32
|
+
config.tokenScheme ? `${config.tokenScheme} ${config.token}` : config.token
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
return fetch(input, { ...init, headers });
|
|
36
|
+
}
|
|
37
|
+
async function bloxBuildJson(input, init = {}, options = {}) {
|
|
38
|
+
const response = await bloxBuildRequest(input, init, options);
|
|
39
|
+
if (!response.ok) {
|
|
40
|
+
const url = typeof input === "string" ? input : input.toString();
|
|
41
|
+
throw new BloxBuildResponseError(response.status, url, response.statusText);
|
|
42
|
+
}
|
|
43
|
+
if (response.status === 204) return null;
|
|
44
|
+
return response.json();
|
|
45
|
+
}
|
|
5
46
|
function localizePath(slug, locale, defaultLocale) {
|
|
6
47
|
if (locale === defaultLocale) return slug === "" ? "/" : slug;
|
|
7
48
|
const s = slug === "" || slug === "/" ? "" : slug;
|
|
@@ -17,43 +58,41 @@ function expandLocalePaths(paths, defaultLocale, supportedLocales) {
|
|
|
17
58
|
}
|
|
18
59
|
return [...new Set(out)];
|
|
19
60
|
}
|
|
20
|
-
async function fetchCmsSiteData(apiBase, websiteName) {
|
|
21
|
-
const
|
|
22
|
-
const sitesData = await sitesRes.json();
|
|
61
|
+
async function fetchCmsSiteData(apiBase, websiteName, requestOptions = {}) {
|
|
62
|
+
const sitesData = await bloxBuildJson(`${apiBase}/blox/websites`, {}, requestOptions);
|
|
23
63
|
const sites = Array.isArray(sitesData) ? sitesData : sitesData.data ?? [];
|
|
24
64
|
const site = sites.find((s) => s.name === websiteName);
|
|
25
65
|
if ((site == null ? void 0 : site.id) == null || site.id === "") throw new Error(`Website "${websiteName}" not found at ${apiBase}`);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
66
|
+
const website = await bloxBuildJson(
|
|
67
|
+
`${apiBase}/blox/websites/${site.id}`,
|
|
68
|
+
{},
|
|
69
|
+
requestOptions
|
|
70
|
+
);
|
|
71
|
+
const pagesData = await bloxBuildJson(
|
|
72
|
+
`${apiBase}/blox/websites/${site.id}/pages?locale=${website.default_locale || "en"}`,
|
|
73
|
+
{},
|
|
74
|
+
requestOptions
|
|
75
|
+
);
|
|
34
76
|
const pages = Array.isArray(pagesData) ? pagesData : pagesData.data ?? [];
|
|
35
|
-
const basePaths = await expandRoutes(apiBase, pages);
|
|
77
|
+
const basePaths = await expandRoutes(apiBase, pages, requestOptions);
|
|
36
78
|
const defaultLocale = website.default_locale || "en";
|
|
37
79
|
const supportedLocales = Array.isArray(website.supported_locales) && website.supported_locales.length > 0 ? website.supported_locales : [defaultLocale];
|
|
38
80
|
const paths = expandLocalePaths(basePaths, defaultLocale, supportedLocales);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
} catch {
|
|
48
|
-
}
|
|
81
|
+
const rData = await bloxBuildJson(
|
|
82
|
+
`${apiBase}/blox/websites/${site.id}/redirects`,
|
|
83
|
+
{},
|
|
84
|
+
requestOptions
|
|
85
|
+
);
|
|
86
|
+
const redirectItems = Array.isArray(rData) ? rData : rData.data ?? [];
|
|
87
|
+
const redirects = redirectItems.filter((r) => r.from_path && r.to_path);
|
|
49
88
|
const collections = extractCollectionRefs(pages);
|
|
50
89
|
return { websiteId: site.id, website, paths, redirects, collections };
|
|
51
90
|
}
|
|
52
|
-
async function fetchCmsPrerenderPaths(apiBase, websiteName) {
|
|
53
|
-
const { paths } = await fetchCmsSiteData(apiBase, websiteName);
|
|
91
|
+
async function fetchCmsPrerenderPaths(apiBase, websiteName, requestOptions = {}) {
|
|
92
|
+
const { paths } = await fetchCmsSiteData(apiBase, websiteName, requestOptions);
|
|
54
93
|
return paths;
|
|
55
94
|
}
|
|
56
|
-
async function expandRoutes(apiBase, pages) {
|
|
95
|
+
async function expandRoutes(apiBase, pages, requestOptions) {
|
|
57
96
|
const routes = [];
|
|
58
97
|
for (const page of pages) {
|
|
59
98
|
const slug = page.slug ?? "/";
|
|
@@ -62,28 +101,25 @@ async function expandRoutes(apiBase, pages) {
|
|
|
62
101
|
for (const [, binding] of Object.entries(page.data_bindings)) {
|
|
63
102
|
const b = binding;
|
|
64
103
|
if (b.adapter === "datastore" && b.collection != null && b.collection !== "" && b.store != null && b.store !== "" && b.bind_by != null && b.bind_by !== "") {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
104
|
+
const q = b.filter ? `&q=${encodeURIComponent(b.filter)}` : "";
|
|
105
|
+
const itemsData = await bloxBuildJson(
|
|
106
|
+
`${apiBase}/datastore/${b.store}/collections/${b.collection}?limit=200${q}`,
|
|
107
|
+
{},
|
|
108
|
+
requestOptions
|
|
109
|
+
);
|
|
110
|
+
const items = Array.isArray(itemsData) ? itemsData : itemsData.data ?? [];
|
|
111
|
+
for (const item of items) {
|
|
112
|
+
const bindValue = item[b.bind_by];
|
|
113
|
+
if (typeof bindValue !== "string" || bindValue === "") continue;
|
|
114
|
+
const concrete = slug.replace(
|
|
115
|
+
/:([a-z_]+)/g,
|
|
116
|
+
(_m, p) => {
|
|
117
|
+
const v = p === b.bind_by ? bindValue : item[p];
|
|
118
|
+
return typeof v === "string" ? v : "";
|
|
119
|
+
}
|
|
69
120
|
);
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
for (const item of items) {
|
|
73
|
-
const bindValue = item[b.bind_by];
|
|
74
|
-
if (typeof bindValue !== "string" || bindValue === "") continue;
|
|
75
|
-
const concrete = slug.replace(
|
|
76
|
-
/:([a-z_]+)/g,
|
|
77
|
-
(_m, p) => {
|
|
78
|
-
const v = p === b.bind_by ? bindValue : item[p];
|
|
79
|
-
return typeof v === "string" ? v : "";
|
|
80
|
-
}
|
|
81
|
-
);
|
|
82
|
-
if (concrete.includes("//") || concrete.endsWith("/")) continue;
|
|
83
|
-
routes.push(concrete);
|
|
84
|
-
}
|
|
85
|
-
} catch (e) {
|
|
86
|
-
console.warn(` [blox-ssg] Could not expand ${slug}: ${e.message}`);
|
|
121
|
+
if (concrete.includes("//") || concrete.endsWith("/")) continue;
|
|
122
|
+
routes.push(concrete);
|
|
87
123
|
}
|
|
88
124
|
}
|
|
89
125
|
}
|
|
@@ -118,8 +154,8 @@ const cmsRoutes = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePro
|
|
|
118
154
|
fetchCmsSiteData
|
|
119
155
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
120
156
|
async function polyfillBloxSsgGlobals(options) {
|
|
121
|
-
const { env } = await import("node:process");
|
|
122
|
-
const pageUrl = (options == null ? void 0 : options.pageUrl) ??
|
|
157
|
+
const { env: env2 } = await import("node:process");
|
|
158
|
+
const pageUrl = (options == null ? void 0 : options.pageUrl) ?? env2.BAGELINK_API_URL ?? "https://example.com/";
|
|
123
159
|
const { Window: HappyWindow } = await import("happy-dom");
|
|
124
160
|
const _win = new HappyWindow({ url: pageUrl });
|
|
125
161
|
const g = globalThis;
|
|
@@ -563,7 +599,7 @@ const llmArtifacts = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.define
|
|
|
563
599
|
mergeLlmParts
|
|
564
600
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
565
601
|
async function prerender({
|
|
566
|
-
root = process.cwd(),
|
|
602
|
+
root = process$1.cwd(),
|
|
567
603
|
clientOutDir = "dist/client",
|
|
568
604
|
serverEntry = "dist/server/main.server.js",
|
|
569
605
|
paths = [],
|
|
@@ -637,11 +673,7 @@ async function prerender({
|
|
|
637
673
|
while (idx < targets.length) {
|
|
638
674
|
const url = targets[idx++];
|
|
639
675
|
if (resolveCache.has(url)) continue;
|
|
640
|
-
|
|
641
|
-
resolveCache.set(url, await prefetch(url));
|
|
642
|
-
} catch {
|
|
643
|
-
resolveCache.set(url, null);
|
|
644
|
-
}
|
|
676
|
+
resolveCache.set(url, await prefetch(url));
|
|
645
677
|
}
|
|
646
678
|
}
|
|
647
679
|
await Promise.all(
|
|
@@ -700,8 +732,7 @@ async function prerender({
|
|
|
700
732
|
}
|
|
701
733
|
}
|
|
702
734
|
}
|
|
703
|
-
await runResolvePrefetch()
|
|
704
|
-
});
|
|
735
|
+
await runResolvePrefetch();
|
|
705
736
|
while (queue.length && !stopped && rendered.length < maxPages) {
|
|
706
737
|
const workers = Array.from(
|
|
707
738
|
{ length: Math.min(concurrency, queue.length) },
|
|
@@ -887,22 +918,26 @@ function discoverInternalLinks(html) {
|
|
|
887
918
|
return [...out];
|
|
888
919
|
}
|
|
889
920
|
export {
|
|
921
|
+
BloxBuildResponseError as B,
|
|
890
922
|
prerender as a,
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
923
|
+
bloxBuildJson as b,
|
|
924
|
+
buildPageHead as c,
|
|
925
|
+
primaryContextEntry as d,
|
|
926
|
+
buildJsonLd as e,
|
|
895
927
|
fetchCmsSiteData as f,
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
928
|
+
extractPageText as g,
|
|
929
|
+
bloxBuildRequest as h,
|
|
930
|
+
buildSiteHead as i,
|
|
931
|
+
fetchCmsPrerenderPaths as j,
|
|
932
|
+
generateLlmsFullTxt as k,
|
|
933
|
+
generateLlmsTxt as l,
|
|
934
|
+
generateNetlifyRedirects as m,
|
|
935
|
+
generateRobotsTxt as n,
|
|
936
|
+
generateSitemapXml as o,
|
|
905
937
|
polyfillBloxSsgGlobals as p,
|
|
906
|
-
|
|
907
|
-
|
|
938
|
+
getBloxBuildRequestOptions as q,
|
|
939
|
+
getSiteIconFlags as r,
|
|
940
|
+
mergeLlmParts as s,
|
|
941
|
+
cmsRoutes as t,
|
|
942
|
+
llmArtifacts as u
|
|
908
943
|
};
|
|
@@ -23,8 +23,49 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
));
|
|
24
24
|
const fs = require("node:fs/promises");
|
|
25
25
|
const path = require("node:path");
|
|
26
|
-
const process = require("node:process");
|
|
26
|
+
const process$1 = require("node:process");
|
|
27
27
|
const node_url = require("node:url");
|
|
28
|
+
class BloxBuildResponseError extends Error {
|
|
29
|
+
constructor(status, url, statusText) {
|
|
30
|
+
super(`Build API ${status} ${statusText}: ${url}`);
|
|
31
|
+
this.status = status;
|
|
32
|
+
this.url = url;
|
|
33
|
+
this.name = "BloxBuildResponseError";
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function env(name) {
|
|
37
|
+
var _a, _b;
|
|
38
|
+
return typeof process !== "undefined" ? ((_b = (_a = process.env) == null ? void 0 : _a[name]) == null ? void 0 : _b.trim()) || void 0 : void 0;
|
|
39
|
+
}
|
|
40
|
+
function getBloxBuildRequestOptions(overrides = {}) {
|
|
41
|
+
return {
|
|
42
|
+
token: overrides.token ?? env("BLOX_BUILD_TOKEN"),
|
|
43
|
+
tokenHeader: overrides.tokenHeader ?? env("BLOX_BUILD_TOKEN_HEADER") ?? "Authorization",
|
|
44
|
+
tokenScheme: overrides.tokenScheme ?? env("BLOX_BUILD_TOKEN_SCHEME") ?? "Bearer",
|
|
45
|
+
headers: overrides.headers
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
async function bloxBuildRequest(input, init = {}, options = {}) {
|
|
49
|
+
const config = getBloxBuildRequestOptions(options);
|
|
50
|
+
const headers = new Headers(config.headers);
|
|
51
|
+
new Headers(init.headers).forEach((value, key) => headers.set(key, value));
|
|
52
|
+
if (config.token && config.tokenHeader && !headers.has(config.tokenHeader)) {
|
|
53
|
+
headers.set(
|
|
54
|
+
config.tokenHeader,
|
|
55
|
+
config.tokenScheme ? `${config.tokenScheme} ${config.token}` : config.token
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
return fetch(input, { ...init, headers });
|
|
59
|
+
}
|
|
60
|
+
async function bloxBuildJson(input, init = {}, options = {}) {
|
|
61
|
+
const response = await bloxBuildRequest(input, init, options);
|
|
62
|
+
if (!response.ok) {
|
|
63
|
+
const url = typeof input === "string" ? input : input.toString();
|
|
64
|
+
throw new BloxBuildResponseError(response.status, url, response.statusText);
|
|
65
|
+
}
|
|
66
|
+
if (response.status === 204) return null;
|
|
67
|
+
return response.json();
|
|
68
|
+
}
|
|
28
69
|
function localizePath(slug, locale, defaultLocale) {
|
|
29
70
|
if (locale === defaultLocale) return slug === "" ? "/" : slug;
|
|
30
71
|
const s = slug === "" || slug === "/" ? "" : slug;
|
|
@@ -40,43 +81,41 @@ function expandLocalePaths(paths, defaultLocale, supportedLocales) {
|
|
|
40
81
|
}
|
|
41
82
|
return [...new Set(out)];
|
|
42
83
|
}
|
|
43
|
-
async function fetchCmsSiteData(apiBase, websiteName) {
|
|
44
|
-
const
|
|
45
|
-
const sitesData = await sitesRes.json();
|
|
84
|
+
async function fetchCmsSiteData(apiBase, websiteName, requestOptions = {}) {
|
|
85
|
+
const sitesData = await bloxBuildJson(`${apiBase}/blox/websites`, {}, requestOptions);
|
|
46
86
|
const sites = Array.isArray(sitesData) ? sitesData : sitesData.data ?? [];
|
|
47
87
|
const site = sites.find((s) => s.name === websiteName);
|
|
48
88
|
if ((site == null ? void 0 : site.id) == null || site.id === "") throw new Error(`Website "${websiteName}" not found at ${apiBase}`);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
89
|
+
const website = await bloxBuildJson(
|
|
90
|
+
`${apiBase}/blox/websites/${site.id}`,
|
|
91
|
+
{},
|
|
92
|
+
requestOptions
|
|
93
|
+
);
|
|
94
|
+
const pagesData = await bloxBuildJson(
|
|
95
|
+
`${apiBase}/blox/websites/${site.id}/pages?locale=${website.default_locale || "en"}`,
|
|
96
|
+
{},
|
|
97
|
+
requestOptions
|
|
98
|
+
);
|
|
57
99
|
const pages = Array.isArray(pagesData) ? pagesData : pagesData.data ?? [];
|
|
58
|
-
const basePaths = await expandRoutes(apiBase, pages);
|
|
100
|
+
const basePaths = await expandRoutes(apiBase, pages, requestOptions);
|
|
59
101
|
const defaultLocale = website.default_locale || "en";
|
|
60
102
|
const supportedLocales = Array.isArray(website.supported_locales) && website.supported_locales.length > 0 ? website.supported_locales : [defaultLocale];
|
|
61
103
|
const paths = expandLocalePaths(basePaths, defaultLocale, supportedLocales);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
} catch {
|
|
71
|
-
}
|
|
104
|
+
const rData = await bloxBuildJson(
|
|
105
|
+
`${apiBase}/blox/websites/${site.id}/redirects`,
|
|
106
|
+
{},
|
|
107
|
+
requestOptions
|
|
108
|
+
);
|
|
109
|
+
const redirectItems = Array.isArray(rData) ? rData : rData.data ?? [];
|
|
110
|
+
const redirects = redirectItems.filter((r) => r.from_path && r.to_path);
|
|
72
111
|
const collections = extractCollectionRefs(pages);
|
|
73
112
|
return { websiteId: site.id, website, paths, redirects, collections };
|
|
74
113
|
}
|
|
75
|
-
async function fetchCmsPrerenderPaths(apiBase, websiteName) {
|
|
76
|
-
const { paths } = await fetchCmsSiteData(apiBase, websiteName);
|
|
114
|
+
async function fetchCmsPrerenderPaths(apiBase, websiteName, requestOptions = {}) {
|
|
115
|
+
const { paths } = await fetchCmsSiteData(apiBase, websiteName, requestOptions);
|
|
77
116
|
return paths;
|
|
78
117
|
}
|
|
79
|
-
async function expandRoutes(apiBase, pages) {
|
|
118
|
+
async function expandRoutes(apiBase, pages, requestOptions) {
|
|
80
119
|
const routes = [];
|
|
81
120
|
for (const page of pages) {
|
|
82
121
|
const slug = page.slug ?? "/";
|
|
@@ -85,28 +124,25 @@ async function expandRoutes(apiBase, pages) {
|
|
|
85
124
|
for (const [, binding] of Object.entries(page.data_bindings)) {
|
|
86
125
|
const b = binding;
|
|
87
126
|
if (b.adapter === "datastore" && b.collection != null && b.collection !== "" && b.store != null && b.store !== "" && b.bind_by != null && b.bind_by !== "") {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
127
|
+
const q = b.filter ? `&q=${encodeURIComponent(b.filter)}` : "";
|
|
128
|
+
const itemsData = await bloxBuildJson(
|
|
129
|
+
`${apiBase}/datastore/${b.store}/collections/${b.collection}?limit=200${q}`,
|
|
130
|
+
{},
|
|
131
|
+
requestOptions
|
|
132
|
+
);
|
|
133
|
+
const items = Array.isArray(itemsData) ? itemsData : itemsData.data ?? [];
|
|
134
|
+
for (const item of items) {
|
|
135
|
+
const bindValue = item[b.bind_by];
|
|
136
|
+
if (typeof bindValue !== "string" || bindValue === "") continue;
|
|
137
|
+
const concrete = slug.replace(
|
|
138
|
+
/:([a-z_]+)/g,
|
|
139
|
+
(_m, p) => {
|
|
140
|
+
const v = p === b.bind_by ? bindValue : item[p];
|
|
141
|
+
return typeof v === "string" ? v : "";
|
|
142
|
+
}
|
|
92
143
|
);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
for (const item of items) {
|
|
96
|
-
const bindValue = item[b.bind_by];
|
|
97
|
-
if (typeof bindValue !== "string" || bindValue === "") continue;
|
|
98
|
-
const concrete = slug.replace(
|
|
99
|
-
/:([a-z_]+)/g,
|
|
100
|
-
(_m, p) => {
|
|
101
|
-
const v = p === b.bind_by ? bindValue : item[p];
|
|
102
|
-
return typeof v === "string" ? v : "";
|
|
103
|
-
}
|
|
104
|
-
);
|
|
105
|
-
if (concrete.includes("//") || concrete.endsWith("/")) continue;
|
|
106
|
-
routes.push(concrete);
|
|
107
|
-
}
|
|
108
|
-
} catch (e) {
|
|
109
|
-
console.warn(` [blox-ssg] Could not expand ${slug}: ${e.message}`);
|
|
144
|
+
if (concrete.includes("//") || concrete.endsWith("/")) continue;
|
|
145
|
+
routes.push(concrete);
|
|
110
146
|
}
|
|
111
147
|
}
|
|
112
148
|
}
|
|
@@ -141,8 +177,8 @@ const cmsRoutes = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePro
|
|
|
141
177
|
fetchCmsSiteData
|
|
142
178
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
143
179
|
async function polyfillBloxSsgGlobals(options) {
|
|
144
|
-
const { env } = await import("node:process");
|
|
145
|
-
const pageUrl = (options == null ? void 0 : options.pageUrl) ??
|
|
180
|
+
const { env: env2 } = await import("node:process");
|
|
181
|
+
const pageUrl = (options == null ? void 0 : options.pageUrl) ?? env2.BAGELINK_API_URL ?? "https://example.com/";
|
|
146
182
|
const { Window: HappyWindow } = await import("happy-dom");
|
|
147
183
|
const _win = new HappyWindow({ url: pageUrl });
|
|
148
184
|
const g = globalThis;
|
|
@@ -586,7 +622,7 @@ const llmArtifacts = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.define
|
|
|
586
622
|
mergeLlmParts
|
|
587
623
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
588
624
|
async function prerender({
|
|
589
|
-
root = process.cwd(),
|
|
625
|
+
root = process$1.cwd(),
|
|
590
626
|
clientOutDir = "dist/client",
|
|
591
627
|
serverEntry = "dist/server/main.server.js",
|
|
592
628
|
paths = [],
|
|
@@ -660,11 +696,7 @@ async function prerender({
|
|
|
660
696
|
while (idx < targets.length) {
|
|
661
697
|
const url = targets[idx++];
|
|
662
698
|
if (resolveCache.has(url)) continue;
|
|
663
|
-
|
|
664
|
-
resolveCache.set(url, await prefetch(url));
|
|
665
|
-
} catch {
|
|
666
|
-
resolveCache.set(url, null);
|
|
667
|
-
}
|
|
699
|
+
resolveCache.set(url, await prefetch(url));
|
|
668
700
|
}
|
|
669
701
|
}
|
|
670
702
|
await Promise.all(
|
|
@@ -723,8 +755,7 @@ async function prerender({
|
|
|
723
755
|
}
|
|
724
756
|
}
|
|
725
757
|
}
|
|
726
|
-
await runResolvePrefetch()
|
|
727
|
-
});
|
|
758
|
+
await runResolvePrefetch();
|
|
728
759
|
while (queue.length && !stopped && rendered.length < maxPages) {
|
|
729
760
|
const workers = Array.from(
|
|
730
761
|
{ length: Math.min(concurrency, queue.length) },
|
|
@@ -909,6 +940,9 @@ function discoverInternalLinks(html) {
|
|
|
909
940
|
}
|
|
910
941
|
return [...out];
|
|
911
942
|
}
|
|
943
|
+
exports.BloxBuildResponseError = BloxBuildResponseError;
|
|
944
|
+
exports.bloxBuildJson = bloxBuildJson;
|
|
945
|
+
exports.bloxBuildRequest = bloxBuildRequest;
|
|
912
946
|
exports.buildJsonLd = buildJsonLd;
|
|
913
947
|
exports.buildPageHead = buildPageHead;
|
|
914
948
|
exports.buildSiteHead = buildSiteHead;
|
|
@@ -921,6 +955,7 @@ exports.generateLlmsTxt = generateLlmsTxt;
|
|
|
921
955
|
exports.generateNetlifyRedirects = generateNetlifyRedirects;
|
|
922
956
|
exports.generateRobotsTxt = generateRobotsTxt;
|
|
923
957
|
exports.generateSitemapXml = generateSitemapXml;
|
|
958
|
+
exports.getBloxBuildRequestOptions = getBloxBuildRequestOptions;
|
|
924
959
|
exports.getSiteIconFlags = getSiteIconFlags;
|
|
925
960
|
exports.llmArtifacts = llmArtifacts;
|
|
926
961
|
exports.mergeLlmParts = mergeLlmParts;
|
|
@@ -74,8 +74,8 @@ async function runSharded(opts) {
|
|
|
74
74
|
if (process.env.BLOX_SSG_LLM !== "0") {
|
|
75
75
|
try {
|
|
76
76
|
const [{ mergeLlmParts }, { fetchCmsSiteData }] = await Promise.all([
|
|
77
|
-
import("./prerender-
|
|
78
|
-
import("./prerender-
|
|
77
|
+
import("./prerender-BpLkRIA8.js").then((n) => n.u),
|
|
78
|
+
import("./prerender-BpLkRIA8.js").then((n) => n.t)
|
|
79
79
|
]);
|
|
80
80
|
let website = null;
|
|
81
81
|
try {
|
|
@@ -98,8 +98,8 @@ async function runSharded(opts) {
|
|
|
98
98
|
if (process.env.BLOX_SSG_LLM !== "0") {
|
|
99
99
|
try {
|
|
100
100
|
const [{ mergeLlmParts }, { fetchCmsSiteData }] = await Promise.all([
|
|
101
|
-
Promise.resolve().then(() => require("./prerender-
|
|
102
|
-
Promise.resolve().then(() => require("./prerender-
|
|
101
|
+
Promise.resolve().then(() => require("./prerender-CYES_qNu.cjs")).then((n) => n.llmArtifacts),
|
|
102
|
+
Promise.resolve().then(() => require("./prerender-CYES_qNu.cjs")).then((n) => n.cmsRoutes)
|
|
103
103
|
]);
|
|
104
104
|
let website = null;
|
|
105
105
|
try {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface BloxBuildRequestOptions {
|
|
2
|
+
/** Server-only build token. Never use a VITE_-prefixed environment variable. */
|
|
3
|
+
token?: string;
|
|
4
|
+
/** Header accepted by the build API/gateway. @default "Authorization" */
|
|
5
|
+
tokenHeader?: string;
|
|
6
|
+
/** Prefix applied to the token. @default "Bearer" */
|
|
7
|
+
tokenScheme?: string;
|
|
8
|
+
/** Additional build-only headers. */
|
|
9
|
+
headers?: HeadersInit;
|
|
10
|
+
}
|
|
11
|
+
export declare class BloxBuildResponseError extends Error {
|
|
12
|
+
readonly status: number;
|
|
13
|
+
readonly url: string;
|
|
14
|
+
constructor(status: number, url: string, statusText: string);
|
|
15
|
+
}
|
|
16
|
+
/** Resolve server-only build authentication without exposing it to browser bundles. */
|
|
17
|
+
export declare function getBloxBuildRequestOptions(overrides?: BloxBuildRequestOptions): BloxBuildRequestOptions;
|
|
18
|
+
/** Central fetch helper for every CMS/datastore request made during a build. */
|
|
19
|
+
export declare function bloxBuildRequest(input: RequestInfo | URL, init?: RequestInit, options?: BloxBuildRequestOptions): Promise<Response>;
|
|
20
|
+
/** Fetch JSON and consistently reject non-2xx build API responses. */
|
|
21
|
+
export declare function bloxBuildJson<T>(input: RequestInfo | URL, init?: RequestInit, options?: BloxBuildRequestOptions): Promise<T>;
|
|
22
|
+
//# sourceMappingURL=build-request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-request.d.ts","sourceRoot":"","sources":["../../src/ssg/build-request.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,uBAAuB;IACvC,gFAAgF;IAChF,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,yEAAyE;IACzE,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,qDAAqD;IACrD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,qCAAqC;IACrC,OAAO,CAAC,EAAE,WAAW,CAAA;CACrB;AAED,qBAAa,sBAAuB,SAAQ,KAAK;aAE/B,MAAM,EAAE,MAAM;aACd,GAAG,EAAE,MAAM;gBADX,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EAC3B,UAAU,EAAE,MAAM;CAKnB;AAMD,uFAAuF;AACvF,wBAAgB,0BAA0B,CACzC,SAAS,GAAE,uBAA4B,GACrC,uBAAuB,CAOzB;AAED,gFAAgF;AAChF,wBAAsB,gBAAgB,CACrC,KAAK,EAAE,WAAW,GAAG,GAAG,EACxB,IAAI,GAAE,WAAgB,EACtB,OAAO,GAAE,uBAA4B,GACnC,OAAO,CAAC,QAAQ,CAAC,CAWnB;AAED,sEAAsE;AACtE,wBAAsB,aAAa,CAAC,CAAC,EACpC,KAAK,EAAE,WAAW,GAAG,GAAG,EACxB,IAAI,GAAE,WAAgB,EACtB,OAAO,GAAE,uBAA4B,GACnC,OAAO,CAAC,CAAC,CAAC,CAQZ"}
|
package/dist/ssg/cli.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
"use strict";
|
|
3
3
|
const process = require("node:process");
|
|
4
|
-
const cmsRoutes = require("../prerender-
|
|
4
|
+
const cmsRoutes = require("../prerender-CYES_qNu.cjs");
|
|
5
5
|
function installFetchTimeout() {
|
|
6
6
|
const ms = Number(process.env.BLOX_SSG_FETCH_TIMEOUT_MS) || 2e4;
|
|
7
7
|
const original = globalThis.fetch;
|
|
@@ -110,7 +110,7 @@ Environment:
|
|
|
110
110
|
if (shardsOpt !== null || routesCmd) {
|
|
111
111
|
const { apiBase: apiBase2, websiteName: configWebsiteName2 } = await resolveApiBase(mode);
|
|
112
112
|
const websiteName2 = process.env.WEBSITE_NAME ?? configWebsiteName2 ?? "default";
|
|
113
|
-
const { runSharded } = await Promise.resolve().then(() => require("../shard-runner-
|
|
113
|
+
const { runSharded } = await Promise.resolve().then(() => require("../shard-runner-D_67ZcHW.cjs"));
|
|
114
114
|
const code = await runSharded({
|
|
115
115
|
shards: shardsOpt ?? "auto",
|
|
116
116
|
mode,
|
|
@@ -132,6 +132,7 @@ Environment:
|
|
|
132
132
|
let websiteId = "";
|
|
133
133
|
let redirects = [];
|
|
134
134
|
const collections = {};
|
|
135
|
+
const productionBuild = process.env.NODE_ENV === "production" || mode === "production";
|
|
135
136
|
try {
|
|
136
137
|
const siteData = await cmsRoutes.fetchCmsSiteData(apiBase, websiteName);
|
|
137
138
|
paths = siteData.paths;
|
|
@@ -156,19 +157,20 @@ Environment:
|
|
|
156
157
|
for (const ref of allCollectionRefs) {
|
|
157
158
|
try {
|
|
158
159
|
const url = `${apiBase}/datastore/${ref.store}/collections/${ref.collection}?limit=500`;
|
|
159
|
-
const
|
|
160
|
-
const data = await res.json();
|
|
160
|
+
const data = await cmsRoutes.bloxBuildJson(url);
|
|
161
161
|
const items = Array.isArray(data) ? data : data.data ?? [];
|
|
162
162
|
const key = `${ref.store}/${ref.collection}`;
|
|
163
163
|
collections[key] = items;
|
|
164
164
|
console.log(` ${key}: ${items.length} items`);
|
|
165
165
|
} catch (e) {
|
|
166
|
+
if (productionBuild) throw e;
|
|
166
167
|
console.warn(` Failed to fetch ${ref.store}/${ref.collection}: ${e.message}`);
|
|
167
168
|
}
|
|
168
169
|
}
|
|
169
170
|
}
|
|
170
171
|
} catch (err) {
|
|
171
172
|
console.error(" Failed to fetch CMS data:", err.message);
|
|
173
|
+
if (productionBuild) throw err;
|
|
172
174
|
paths = ["/"];
|
|
173
175
|
}
|
|
174
176
|
for (const p of extraPaths) {
|
|
@@ -190,6 +192,7 @@ Environment:
|
|
|
190
192
|
crawl,
|
|
191
193
|
excludePaths,
|
|
192
194
|
maxPages: 5e3,
|
|
195
|
+
failFast: productionBuild,
|
|
193
196
|
// Bounded concurrency — configurable so we don't overwhelm a small
|
|
194
197
|
// staging box. Defaults conservative; bump for beefy prod builds.
|
|
195
198
|
concurrency: Number(process.env.BLOX_SSG_CONCURRENCY) || 4,
|
package/dist/ssg/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
import process from "node:process";
|
|
3
|
-
import { p as polyfillBloxSsgGlobals, f as fetchCmsSiteData, a as prerender } from "../prerender-
|
|
3
|
+
import { p as polyfillBloxSsgGlobals, f as fetchCmsSiteData, b as bloxBuildJson, a as prerender } from "../prerender-BpLkRIA8.js";
|
|
4
4
|
function installFetchTimeout() {
|
|
5
5
|
const ms = Number(process.env.BLOX_SSG_FETCH_TIMEOUT_MS) || 2e4;
|
|
6
6
|
const original = globalThis.fetch;
|
|
@@ -109,7 +109,7 @@ Environment:
|
|
|
109
109
|
if (shardsOpt !== null || routesCmd) {
|
|
110
110
|
const { apiBase: apiBase2, websiteName: configWebsiteName2 } = await resolveApiBase(mode);
|
|
111
111
|
const websiteName2 = process.env.WEBSITE_NAME ?? configWebsiteName2 ?? "default";
|
|
112
|
-
const { runSharded } = await import("../shard-runner-
|
|
112
|
+
const { runSharded } = await import("../shard-runner-26opEo2v.js");
|
|
113
113
|
const code = await runSharded({
|
|
114
114
|
shards: shardsOpt ?? "auto",
|
|
115
115
|
mode,
|
|
@@ -131,6 +131,7 @@ Environment:
|
|
|
131
131
|
let websiteId = "";
|
|
132
132
|
let redirects = [];
|
|
133
133
|
const collections = {};
|
|
134
|
+
const productionBuild = process.env.NODE_ENV === "production" || mode === "production";
|
|
134
135
|
try {
|
|
135
136
|
const siteData = await fetchCmsSiteData(apiBase, websiteName);
|
|
136
137
|
paths = siteData.paths;
|
|
@@ -155,19 +156,20 @@ Environment:
|
|
|
155
156
|
for (const ref of allCollectionRefs) {
|
|
156
157
|
try {
|
|
157
158
|
const url = `${apiBase}/datastore/${ref.store}/collections/${ref.collection}?limit=500`;
|
|
158
|
-
const
|
|
159
|
-
const data = await res.json();
|
|
159
|
+
const data = await bloxBuildJson(url);
|
|
160
160
|
const items = Array.isArray(data) ? data : data.data ?? [];
|
|
161
161
|
const key = `${ref.store}/${ref.collection}`;
|
|
162
162
|
collections[key] = items;
|
|
163
163
|
console.log(` ${key}: ${items.length} items`);
|
|
164
164
|
} catch (e) {
|
|
165
|
+
if (productionBuild) throw e;
|
|
165
166
|
console.warn(` Failed to fetch ${ref.store}/${ref.collection}: ${e.message}`);
|
|
166
167
|
}
|
|
167
168
|
}
|
|
168
169
|
}
|
|
169
170
|
} catch (err) {
|
|
170
171
|
console.error(" Failed to fetch CMS data:", err.message);
|
|
172
|
+
if (productionBuild) throw err;
|
|
171
173
|
paths = ["/"];
|
|
172
174
|
}
|
|
173
175
|
for (const p of extraPaths) {
|
|
@@ -189,6 +191,7 @@ Environment:
|
|
|
189
191
|
crawl,
|
|
190
192
|
excludePaths,
|
|
191
193
|
maxPages: 5e3,
|
|
194
|
+
failFast: productionBuild,
|
|
192
195
|
// Bounded concurrency — configurable so we don't overwhelm a small
|
|
193
196
|
// staging box. Defaults conservative; bump for beefy prod builds.
|
|
194
197
|
concurrency: Number(process.env.BLOX_SSG_CONCURRENCY) || 4,
|
package/dist/ssg/cms-routes.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { WebsiteRead } from '../api/types';
|
|
2
2
|
import { RedirectEntry } from './seo';
|
|
3
|
+
import { BloxBuildRequestOptions } from './build-request';
|
|
3
4
|
/** A datastore collection reference discovered from page data_bindings. */
|
|
4
5
|
export interface CollectionRef {
|
|
5
6
|
store: string;
|
|
@@ -22,9 +23,9 @@ export declare function expandLocalePaths(paths: string[], defaultLocale: string
|
|
|
22
23
|
* Fetch everything the SSG needs from the CMS in one go:
|
|
23
24
|
* website settings, page routes, and redirects.
|
|
24
25
|
*/
|
|
25
|
-
export declare function fetchCmsSiteData(apiBase: string, websiteName: string): Promise<CmsSiteData>;
|
|
26
|
+
export declare function fetchCmsSiteData(apiBase: string, websiteName: string, requestOptions?: BloxBuildRequestOptions): Promise<CmsSiteData>;
|
|
26
27
|
/**
|
|
27
28
|
* Legacy compat: fetch only prerender paths (no website/redirect data).
|
|
28
29
|
*/
|
|
29
|
-
export declare function fetchCmsPrerenderPaths(apiBase: string, websiteName: string): Promise<string[]>;
|
|
30
|
+
export declare function fetchCmsPrerenderPaths(apiBase: string, websiteName: string, requestOptions?: BloxBuildRequestOptions): Promise<string[]>;
|
|
30
31
|
//# sourceMappingURL=cms-routes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cms-routes.d.ts","sourceRoot":"","sources":["../../src/ssg/cms-routes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"cms-routes.d.ts","sourceRoot":"","sources":["../../src/ssg/cms-routes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAA;AAa9D,2EAA2E;AAC3E,MAAM,WAAW,aAAa;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,WAAW;IAC3B,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,WAAW,CAAA;IACpB,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,SAAS,EAAE,aAAa,EAAE,CAAA;IAC1B,oEAAoE;IACpE,WAAW,EAAE,aAAa,EAAE,CAAA;CAC5B;AAYD;;;GAGG;AACH,wBAAgB,iBAAiB,CAChC,KAAK,EAAE,MAAM,EAAE,EACf,aAAa,EAAE,MAAM,EACrB,gBAAgB,EAAE,MAAM,EAAE,GACxB,MAAM,EAAE,CASV;AAMD;;;GAGG;AACH,wBAAsB,gBAAgB,CACrC,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,cAAc,GAAE,uBAA4B,GAC1C,OAAO,CAAC,WAAW,CAAC,CA8CtB;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAC3C,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,cAAc,GAAE,uBAA4B,GAC1C,OAAO,CAAC,MAAM,EAAE,CAAC,CAGnB"}
|
|
@@ -2,6 +2,7 @@ import { App, Component } from 'vue';
|
|
|
2
2
|
import { Router } from 'vue-router';
|
|
3
3
|
import { BlockModule } from '../defineBlock';
|
|
4
4
|
import { RenderContext, RenderResult } from './prerender';
|
|
5
|
+
import { BloxBuildRequestOptions } from './build-request';
|
|
5
6
|
export interface CreateBloxSSREntryOptions {
|
|
6
7
|
/** Root Vue component (App.vue). */
|
|
7
8
|
rootComponent: Component;
|
|
@@ -22,6 +23,8 @@ export interface CreateBloxSSREntryOptions {
|
|
|
22
23
|
store: string;
|
|
23
24
|
/** API base URL for SSR fetches. @default process.env.BAGELINK_API_URL ?? 'https://api.bagel.to' */
|
|
24
25
|
apiBase?: string;
|
|
26
|
+
/** Build-only authentication/headers. Defaults to BLOX_BUILD_TOKEN env. */
|
|
27
|
+
buildRequest?: BloxBuildRequestOptions;
|
|
25
28
|
/** Default locale. @default 'en' */
|
|
26
29
|
locale?: string;
|
|
27
30
|
/** Supported locales. @default [locale] */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSSREntry.d.ts","sourceRoot":"","sources":["../../src/ssg/createSSREntry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AACzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"createSSREntry.d.ts","sourceRoot":"","sources":["../../src/ssg/createSSREntry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AACzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG9D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAA;AAW9D,MAAM,WAAW,yBAAyB;IACzC,oCAAoC;IACpC,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ANGED
|
@@ -22,7 +22,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
22
|
mod
|
|
23
23
|
));
|
|
24
24
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
25
|
-
const cmsRoutes = require("../prerender-
|
|
25
|
+
const cmsRoutes = require("../prerender-CYES_qNu.cjs");
|
|
26
26
|
const ssg_client = require("./client.cjs");
|
|
27
27
|
const pinia = require("pinia");
|
|
28
28
|
const vue = require("vue");
|
|
@@ -44,6 +44,9 @@ async function renderBloxSsgPage(options) {
|
|
|
44
44
|
collections,
|
|
45
45
|
llm
|
|
46
46
|
} = options;
|
|
47
|
+
if (resolvedData != null && !websiteId) {
|
|
48
|
+
throw new Error(`CMS page "${url}" requires a websiteId for hydration`);
|
|
49
|
+
}
|
|
47
50
|
const g = globalThis;
|
|
48
51
|
const prevState = g[stateWindowKey];
|
|
49
52
|
if (resolvedData != null) {
|
|
@@ -55,7 +58,7 @@ async function renderBloxSsgPage(options) {
|
|
|
55
58
|
await router.isReady();
|
|
56
59
|
const html = await renderToString(app);
|
|
57
60
|
const stateScript = resolvedData != null ? `<script>window[${JSON.stringify(stateWindowKey)}]=${JSON.stringify({ [stateKey]: resolvedData })};${"<"}/script>` : "";
|
|
58
|
-
const collectionsScript =
|
|
61
|
+
const collectionsScript = "";
|
|
59
62
|
const websiteIdScript = websiteId ? `<script>window[${JSON.stringify(ssg_client.BLOX_WEBSITE_ID_WINDOW_KEY)}]=${JSON.stringify(websiteId)};${"<"}/script>` : "";
|
|
60
63
|
const seoHead = dataRegistry && collectSeo ? collectSeo(dataRegistry) : void 0;
|
|
61
64
|
const seoOverride = seoHead && Object.keys(seoHead).length > 0 ? seoHead : void 0;
|
|
@@ -109,7 +112,6 @@ ${jsonLd}`;
|
|
|
109
112
|
function safeJson(value) {
|
|
110
113
|
return JSON.stringify(value).replace(/</g, "\\u003c");
|
|
111
114
|
}
|
|
112
|
-
let _websiteId = null;
|
|
113
115
|
function createBloxSSREntry(options) {
|
|
114
116
|
var _a;
|
|
115
117
|
const {
|
|
@@ -125,16 +127,16 @@ function createBloxSSREntry(options) {
|
|
|
125
127
|
setup: userSetup
|
|
126
128
|
} = options;
|
|
127
129
|
const apiBase = options.apiBase ?? (typeof process !== "undefined" ? (_a = process.env) == null ? void 0 : _a.BAGELINK_API_URL : void 0) ?? "https://api.bagel.to";
|
|
130
|
+
let websiteIdCache = null;
|
|
128
131
|
routes.setApiOrigin(apiBase);
|
|
129
132
|
async function getWebsiteId() {
|
|
130
|
-
if (
|
|
131
|
-
const
|
|
132
|
-
const data = await res.json();
|
|
133
|
+
if (websiteIdCache) return websiteIdCache;
|
|
134
|
+
const data = await cmsRoutes.bloxBuildJson(`${apiBase}/blox/websites`, {}, options.buildRequest);
|
|
133
135
|
const sites = Array.isArray(data) ? data : (data == null ? void 0 : data.data) ?? [];
|
|
134
136
|
const site = sites.find((s) => s.name === websiteName);
|
|
135
137
|
if (!(site == null ? void 0 : site.id)) throw new Error(`Website "${websiteName}" not found`);
|
|
136
|
-
|
|
137
|
-
return
|
|
138
|
+
websiteIdCache = site.id;
|
|
139
|
+
return websiteIdCache;
|
|
138
140
|
}
|
|
139
141
|
function detectLocale(urlPath) {
|
|
140
142
|
const segments = urlPath.replace(/^\//, "").split("/");
|
|
@@ -148,9 +150,15 @@ function createBloxSSREntry(options) {
|
|
|
148
150
|
async function fetchResolvedPage(slug, pageLocale) {
|
|
149
151
|
const websiteId = await getWebsiteId();
|
|
150
152
|
const url = `${apiBase}/blox/websites/${websiteId}/resolve-path?path=${encodeURIComponent(slug)}&locale=${pageLocale}`;
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
153
|
+
return cmsRoutes.bloxBuildJson(url, {}, options.buildRequest);
|
|
154
|
+
}
|
|
155
|
+
async function resolveForBuild(slug, pageLocale) {
|
|
156
|
+
try {
|
|
157
|
+
return await fetchResolvedPage(slug, pageLocale);
|
|
158
|
+
} catch (error) {
|
|
159
|
+
if (error instanceof cmsRoutes.BloxBuildResponseError && error.status === 404) return null;
|
|
160
|
+
throw error;
|
|
161
|
+
}
|
|
154
162
|
}
|
|
155
163
|
function buildApp(url) {
|
|
156
164
|
const router = createRouter("memory", url);
|
|
@@ -200,11 +208,7 @@ function createBloxSSREntry(options) {
|
|
|
200
208
|
if ((_a2 = ctx.resolveCache) == null ? void 0 : _a2.has(url)) {
|
|
201
209
|
resolvedData = ctx.resolveCache.get(url) ?? null;
|
|
202
210
|
} else {
|
|
203
|
-
|
|
204
|
-
resolvedData = await fetchResolvedPage(slug, pageLocale);
|
|
205
|
-
} catch (e) {
|
|
206
|
-
console.warn(`[prerender] Could not resolve: ${url} — ${e.message}`);
|
|
207
|
-
}
|
|
211
|
+
resolvedData = await resolveForBuild(slug, pageLocale);
|
|
208
212
|
}
|
|
209
213
|
const { renderToString } = await import("vue/server-renderer");
|
|
210
214
|
return renderBloxSsgPage({
|
|
@@ -226,14 +230,13 @@ function createBloxSSREntry(options) {
|
|
|
226
230
|
}
|
|
227
231
|
async function prefetchResolve(url) {
|
|
228
232
|
const { locale: pageLocale, slug } = detectLocale(url);
|
|
229
|
-
|
|
230
|
-
return await fetchResolvedPage(slug, pageLocale);
|
|
231
|
-
} catch {
|
|
232
|
-
return null;
|
|
233
|
-
}
|
|
233
|
+
return resolveForBuild(slug, pageLocale);
|
|
234
234
|
}
|
|
235
235
|
return { render, prefetchResolve };
|
|
236
236
|
}
|
|
237
|
+
exports.BloxBuildResponseError = cmsRoutes.BloxBuildResponseError;
|
|
238
|
+
exports.bloxBuildJson = cmsRoutes.bloxBuildJson;
|
|
239
|
+
exports.bloxBuildRequest = cmsRoutes.bloxBuildRequest;
|
|
237
240
|
exports.buildJsonLd = cmsRoutes.buildJsonLd;
|
|
238
241
|
exports.buildPageHead = cmsRoutes.buildPageHead;
|
|
239
242
|
exports.buildSiteHead = cmsRoutes.buildSiteHead;
|
|
@@ -245,6 +248,7 @@ exports.generateLlmsTxt = cmsRoutes.generateLlmsTxt;
|
|
|
245
248
|
exports.generateNetlifyRedirects = cmsRoutes.generateNetlifyRedirects;
|
|
246
249
|
exports.generateRobotsTxt = cmsRoutes.generateRobotsTxt;
|
|
247
250
|
exports.generateSitemapXml = cmsRoutes.generateSitemapXml;
|
|
251
|
+
exports.getBloxBuildRequestOptions = cmsRoutes.getBloxBuildRequestOptions;
|
|
248
252
|
exports.getSiteIconFlags = cmsRoutes.getSiteIconFlags;
|
|
249
253
|
exports.mergeLlmParts = cmsRoutes.mergeLlmParts;
|
|
250
254
|
exports.polyfillBloxSsgGlobals = cmsRoutes.polyfillBloxSsgGlobals;
|
package/dist/ssg/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { fetchCmsPrerenderPaths, fetchCmsSiteData } from './cms-routes';
|
|
2
2
|
export type { CmsSiteData, CollectionRef } from './cms-routes';
|
|
3
|
+
export { BloxBuildResponseError, bloxBuildJson, bloxBuildRequest, getBloxBuildRequestOptions } from './build-request';
|
|
4
|
+
export type { BloxBuildRequestOptions } from './build-request';
|
|
3
5
|
export { getCollectionCache, getEmbeddedWebsiteId, installCollectionCache } from './collection-cache';
|
|
4
6
|
/**
|
|
5
7
|
* @bagelink/blox/ssg — Static Site Generation helpers for Blox CMS sites.
|
package/dist/ssg/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ssg/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AACvE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC9D,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AACrG;;;;;;;;;;GAUG;AACH,OAAO,EAAE,2BAA2B,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,0BA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oB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AACrG;;;;;;;;;;GAUG;AACH,OAAO,EAAE,2BAA2B,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAA;AAC5J,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACrD,YAAY,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAA;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AACjG,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,YAAY,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAA;AACvI,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AACvD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,mBAAmB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AACnH,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA"}
|
package/dist/ssg/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { BLOX_STATE_WINDOW_KEY,
|
|
4
|
-
import { BLOX_DATA_WINDOW_KEY, BLOX_PAGE_SEO_WINDOW_KEY, getCollectionCache, getEmbeddedWebsiteId, installBloxStateCache, installCollectionCache } from "./client.mjs";
|
|
1
|
+
import { c as buildPageHead, d as primaryContextEntry, e as buildJsonLd, g as extractPageText, B as BloxBuildResponseError, b as bloxBuildJson } from "../prerender-BpLkRIA8.js";
|
|
2
|
+
import { h, i, j, f, k, l, m, n, o, q, r, s, p, a } from "../prerender-BpLkRIA8.js";
|
|
3
|
+
import { BLOX_STATE_WINDOW_KEY, BLOX_WEBSITE_ID_WINDOW_KEY } from "./client.mjs";
|
|
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";
|
|
6
6
|
import { createSSRApp, h as h2, Suspense, markRaw } from "vue";
|
|
7
7
|
import { B as BLOX_DATA_WINDOW_KEY2, s as setApiOrigin, a as setActiveLocale, c as collectBloxData, b as collectBloxSeo, p as provideBloxData, d as createBlox, g as generateContentRoutes, i as installLocaleAwareResolve } from "../routes-CjlJQqgW.js";
|
|
@@ -22,10 +22,13 @@ async function renderBloxSsgPage(options) {
|
|
|
22
22
|
collections,
|
|
23
23
|
llm
|
|
24
24
|
} = options;
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
if (resolvedData != null && !websiteId) {
|
|
26
|
+
throw new Error(`CMS page "${url}" requires a websiteId for hydration`);
|
|
27
|
+
}
|
|
28
|
+
const g = globalThis;
|
|
29
|
+
const prevState = g[stateWindowKey];
|
|
27
30
|
if (resolvedData != null) {
|
|
28
|
-
|
|
31
|
+
g[stateWindowKey] = { [stateKey]: resolvedData };
|
|
29
32
|
}
|
|
30
33
|
try {
|
|
31
34
|
const { app, router, dataRegistry } = createAppForUrl(url);
|
|
@@ -33,7 +36,7 @@ async function renderBloxSsgPage(options) {
|
|
|
33
36
|
await router.isReady();
|
|
34
37
|
const html = await renderToString(app);
|
|
35
38
|
const stateScript = resolvedData != null ? `<script>window[${JSON.stringify(stateWindowKey)}]=${JSON.stringify({ [stateKey]: resolvedData })};${"<"}/script>` : "";
|
|
36
|
-
const collectionsScript =
|
|
39
|
+
const collectionsScript = "";
|
|
37
40
|
const websiteIdScript = websiteId ? `<script>window[${JSON.stringify(BLOX_WEBSITE_ID_WINDOW_KEY)}]=${JSON.stringify(websiteId)};${"<"}/script>` : "";
|
|
38
41
|
const seoHead = dataRegistry && collectSeo ? collectSeo(dataRegistry) : void 0;
|
|
39
42
|
const seoOverride = seoHead && Object.keys(seoHead).length > 0 ? seoHead : void 0;
|
|
@@ -78,16 +81,15 @@ ${jsonLd}`;
|
|
|
78
81
|
return { html, head, htmlAttrs, llm: llmEntry };
|
|
79
82
|
} finally {
|
|
80
83
|
if (prevState !== void 0) {
|
|
81
|
-
|
|
84
|
+
g[stateWindowKey] = prevState;
|
|
82
85
|
} else {
|
|
83
|
-
delete
|
|
86
|
+
delete g[stateWindowKey];
|
|
84
87
|
}
|
|
85
88
|
}
|
|
86
89
|
}
|
|
87
90
|
function safeJson(value) {
|
|
88
91
|
return JSON.stringify(value).replace(/</g, "\\u003c");
|
|
89
92
|
}
|
|
90
|
-
let _websiteId = null;
|
|
91
93
|
function createBloxSSREntry(options) {
|
|
92
94
|
var _a;
|
|
93
95
|
const {
|
|
@@ -103,16 +105,16 @@ function createBloxSSREntry(options) {
|
|
|
103
105
|
setup: userSetup
|
|
104
106
|
} = options;
|
|
105
107
|
const apiBase = options.apiBase ?? (typeof process !== "undefined" ? (_a = process.env) == null ? void 0 : _a.BAGELINK_API_URL : void 0) ?? "https://api.bagel.to";
|
|
108
|
+
let websiteIdCache = null;
|
|
106
109
|
setApiOrigin(apiBase);
|
|
107
110
|
async function getWebsiteId() {
|
|
108
|
-
if (
|
|
109
|
-
const
|
|
110
|
-
const data = await res.json();
|
|
111
|
+
if (websiteIdCache) return websiteIdCache;
|
|
112
|
+
const data = await bloxBuildJson(`${apiBase}/blox/websites`, {}, options.buildRequest);
|
|
111
113
|
const sites = Array.isArray(data) ? data : (data == null ? void 0 : data.data) ?? [];
|
|
112
|
-
const site = sites.find((
|
|
114
|
+
const site = sites.find((s2) => s2.name === websiteName);
|
|
113
115
|
if (!(site == null ? void 0 : site.id)) throw new Error(`Website "${websiteName}" not found`);
|
|
114
|
-
|
|
115
|
-
return
|
|
116
|
+
websiteIdCache = site.id;
|
|
117
|
+
return websiteIdCache;
|
|
116
118
|
}
|
|
117
119
|
function detectLocale(urlPath) {
|
|
118
120
|
const segments = urlPath.replace(/^\//, "").split("/");
|
|
@@ -126,9 +128,15 @@ function createBloxSSREntry(options) {
|
|
|
126
128
|
async function fetchResolvedPage(slug, pageLocale) {
|
|
127
129
|
const websiteId = await getWebsiteId();
|
|
128
130
|
const url = `${apiBase}/blox/websites/${websiteId}/resolve-path?path=${encodeURIComponent(slug)}&locale=${pageLocale}`;
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
131
|
+
return bloxBuildJson(url, {}, options.buildRequest);
|
|
132
|
+
}
|
|
133
|
+
async function resolveForBuild(slug, pageLocale) {
|
|
134
|
+
try {
|
|
135
|
+
return await fetchResolvedPage(slug, pageLocale);
|
|
136
|
+
} catch (error) {
|
|
137
|
+
if (error instanceof BloxBuildResponseError && error.status === 404) return null;
|
|
138
|
+
throw error;
|
|
139
|
+
}
|
|
132
140
|
}
|
|
133
141
|
function buildApp(url) {
|
|
134
142
|
const router = createRouter("memory", url);
|
|
@@ -138,8 +146,8 @@ function createBloxSSREntry(options) {
|
|
|
138
146
|
});
|
|
139
147
|
const dataRegistry = provideBloxData(app, { server: true });
|
|
140
148
|
const pinia = createPinia();
|
|
141
|
-
pinia.use(({ store:
|
|
142
|
-
|
|
149
|
+
pinia.use(({ store: s2 }) => {
|
|
150
|
+
s2.router = markRaw(router);
|
|
143
151
|
});
|
|
144
152
|
const blox = createBlox({
|
|
145
153
|
modules,
|
|
@@ -178,11 +186,7 @@ function createBloxSSREntry(options) {
|
|
|
178
186
|
if ((_a2 = ctx.resolveCache) == null ? void 0 : _a2.has(url)) {
|
|
179
187
|
resolvedData = ctx.resolveCache.get(url) ?? null;
|
|
180
188
|
} else {
|
|
181
|
-
|
|
182
|
-
resolvedData = await fetchResolvedPage(slug, pageLocale);
|
|
183
|
-
} catch (e) {
|
|
184
|
-
console.warn(`[prerender] Could not resolve: ${url} — ${e.message}`);
|
|
185
|
-
}
|
|
189
|
+
resolvedData = await resolveForBuild(slug, pageLocale);
|
|
186
190
|
}
|
|
187
191
|
const { renderToString } = await import("vue/server-renderer");
|
|
188
192
|
return renderBloxSsgPage({
|
|
@@ -204,11 +208,7 @@ function createBloxSSREntry(options) {
|
|
|
204
208
|
}
|
|
205
209
|
async function prefetchResolve(url) {
|
|
206
210
|
const { locale: pageLocale, slug } = detectLocale(url);
|
|
207
|
-
|
|
208
|
-
return await fetchResolvedPage(slug, pageLocale);
|
|
209
|
-
} catch {
|
|
210
|
-
return null;
|
|
211
|
-
}
|
|
211
|
+
return resolveForBuild(slug, pageLocale);
|
|
212
212
|
}
|
|
213
213
|
return { render, prefetchResolve };
|
|
214
214
|
}
|
|
@@ -218,24 +218,28 @@ export {
|
|
|
218
218
|
BLOX_PAGE_SEO_WINDOW_KEY,
|
|
219
219
|
BLOX_STATE_WINDOW_KEY,
|
|
220
220
|
BLOX_WEBSITE_ID_WINDOW_KEY,
|
|
221
|
+
BloxBuildResponseError,
|
|
222
|
+
bloxBuildJson,
|
|
223
|
+
h as bloxBuildRequest,
|
|
221
224
|
buildJsonLd,
|
|
222
225
|
buildPageHead,
|
|
223
|
-
|
|
226
|
+
i as buildSiteHead,
|
|
224
227
|
createBloxSSREntry,
|
|
225
228
|
extractPageText,
|
|
226
|
-
|
|
229
|
+
j as fetchCmsPrerenderPaths,
|
|
227
230
|
f as fetchCmsSiteData,
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
231
|
+
k as generateLlmsFullTxt,
|
|
232
|
+
l as generateLlmsTxt,
|
|
233
|
+
m as generateNetlifyRedirects,
|
|
234
|
+
n as generateRobotsTxt,
|
|
235
|
+
o as generateSitemapXml,
|
|
236
|
+
q as getBloxBuildRequestOptions,
|
|
233
237
|
getCollectionCache,
|
|
234
238
|
getEmbeddedWebsiteId,
|
|
235
|
-
|
|
239
|
+
r as getSiteIconFlags,
|
|
236
240
|
installBloxStateCache,
|
|
237
241
|
installCollectionCache,
|
|
238
|
-
|
|
242
|
+
s as mergeLlmParts,
|
|
239
243
|
p as polyfillBloxSsgGlobals,
|
|
240
244
|
a as prerender,
|
|
241
245
|
renderBloxSsgPage
|
|
@@ -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;AAgBvE,KAAK,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAA;AAEhE,MAAM,WAAW,gBAAgB;IAChC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,YAAY,CAAC,EAAE,WAAW,GAAG,WAAW,EAAE,CAAA;IAC1C,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,yDAAyD;IACzD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,6FAA6F;IAC7F,0BAA0B,CAAC,EAAE,MAAM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