@bagelink/blox 1.15.535 → 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-Aw77Pe6C.js → shard-runner-BWwEIABX.js} +7 -3
- package/dist/{shard-runner-C-OeWaVM.cjs → shard-runner-D778xfd2.cjs} +7 -3
- 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/index.cjs +19 -10
- package/dist/ssg/index.d.ts +2 -0
- package/dist/ssg/index.d.ts.map +1 -1
- package/dist/ssg/index.mjs +27 -18
- package/dist/ssg/manifest-upload.d.ts +2 -1
- package/dist/ssg/manifest-upload.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-CfHo6w9k.js → validate-output-CV4nlrHm.js} +96 -19
- package/dist/{validate-output-2iH8f9ql.cjs → validate-output-DqDUmsyO.cjs} +88 -11
- 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 +1 -1
|
@@ -2,7 +2,7 @@ import { spawn } from "node:child_process";
|
|
|
2
2
|
import os from "node:os";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import process from "node:process";
|
|
5
|
-
import { f as fetchCmsSiteData, g as generateSitemapArtifacts } from "./validate-output-
|
|
5
|
+
import { f as fetchCmsSiteData, g as generateSitemapArtifacts } from "./validate-output-CV4nlrHm.js";
|
|
6
6
|
const AUTO_SHARD_CAP = Number(process.env.BLOX_SSG_SHARD_CAP) || 6;
|
|
7
7
|
const PREFETCH_BUDGET = Number(process.env.BLOX_SSG_PREFETCH_BUDGET) || 24;
|
|
8
8
|
function resolveShardCount(shards) {
|
|
@@ -71,7 +71,11 @@ async function runSharded(opts) {
|
|
|
71
71
|
}
|
|
72
72
|
console.log(`[blox-ssg] routes-cmd enumerated ${enumerated.length} route(s)`);
|
|
73
73
|
}
|
|
74
|
-
const siteData = await fetchCmsSiteData(
|
|
74
|
+
const siteData = await fetchCmsSiteData(
|
|
75
|
+
opts.apiBase,
|
|
76
|
+
opts.websiteName,
|
|
77
|
+
opts.buildRequest
|
|
78
|
+
);
|
|
75
79
|
for (const p of siteData.paths) if (!paths.includes(p)) paths.push(p);
|
|
76
80
|
const cmsPathSet = new Set(siteData.paths);
|
|
77
81
|
const routerPaths = appPaths.filter((path2) => !cmsPathSet.has(path2));
|
|
@@ -109,7 +113,7 @@ async function runSharded(opts) {
|
|
|
109
113
|
}
|
|
110
114
|
if (process.env.BLOX_SSG_LLM !== "0") {
|
|
111
115
|
try {
|
|
112
|
-
const { mergeLlmParts } = await import("./validate-output-
|
|
116
|
+
const { mergeLlmParts } = await import("./validate-output-CV4nlrHm.js").then((n) => n.D);
|
|
113
117
|
const mergeWebsite = website;
|
|
114
118
|
const partFiles = Array.from({ length: total }, (_, i) => path.join(llmPartsDir, `part.${i}.json`));
|
|
115
119
|
const { pages } = await mergeLlmParts({
|
|
@@ -26,7 +26,7 @@ const node_child_process = require("node:child_process");
|
|
|
26
26
|
const os = require("node:os");
|
|
27
27
|
const path = require("node:path");
|
|
28
28
|
const process = require("node:process");
|
|
29
|
-
const llmArtifacts = require("./validate-output-
|
|
29
|
+
const llmArtifacts = require("./validate-output-DqDUmsyO.cjs");
|
|
30
30
|
const AUTO_SHARD_CAP = Number(process.env.BLOX_SSG_SHARD_CAP) || 6;
|
|
31
31
|
const PREFETCH_BUDGET = Number(process.env.BLOX_SSG_PREFETCH_BUDGET) || 24;
|
|
32
32
|
function resolveShardCount(shards) {
|
|
@@ -95,7 +95,11 @@ async function runSharded(opts) {
|
|
|
95
95
|
}
|
|
96
96
|
console.log(`[blox-ssg] routes-cmd enumerated ${enumerated.length} route(s)`);
|
|
97
97
|
}
|
|
98
|
-
const siteData = await llmArtifacts.fetchCmsSiteData(
|
|
98
|
+
const siteData = await llmArtifacts.fetchCmsSiteData(
|
|
99
|
+
opts.apiBase,
|
|
100
|
+
opts.websiteName,
|
|
101
|
+
opts.buildRequest
|
|
102
|
+
);
|
|
99
103
|
for (const p of siteData.paths) if (!paths.includes(p)) paths.push(p);
|
|
100
104
|
const cmsPathSet = new Set(siteData.paths);
|
|
101
105
|
const routerPaths = appPaths.filter((path2) => !cmsPathSet.has(path2));
|
|
@@ -133,7 +137,7 @@ async function runSharded(opts) {
|
|
|
133
137
|
}
|
|
134
138
|
if (process.env.BLOX_SSG_LLM !== "0") {
|
|
135
139
|
try {
|
|
136
|
-
const { mergeLlmParts } = await Promise.resolve().then(() => require("./validate-output-
|
|
140
|
+
const { mergeLlmParts } = await Promise.resolve().then(() => require("./validate-output-DqDUmsyO.cjs")).then((n) => n.llmArtifacts);
|
|
137
141
|
const mergeWebsite = website;
|
|
138
142
|
const partFiles = Array.from({ length: total }, (_, i) => path.join(llmPartsDir, `part.${i}.json`));
|
|
139
143
|
const { pages } = await mergeLlmParts({
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface BloxBuildGrant {
|
|
2
|
+
version: 1;
|
|
3
|
+
source: 'blox';
|
|
4
|
+
websiteId: string;
|
|
5
|
+
grant: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ResolveBloxBuildGrantOptions {
|
|
8
|
+
mode?: string;
|
|
9
|
+
env?: NodeJS.ProcessEnv;
|
|
10
|
+
}
|
|
11
|
+
/** Parse a Netlify hook body as direct JSON or exactly one URL-decoded JSON value. */
|
|
12
|
+
export declare function parseBloxBuildGrantBody(body: string): BloxBuildGrant;
|
|
13
|
+
/**
|
|
14
|
+
* Resolve ephemeral build authority. Non-local builds only trust Netlify hook
|
|
15
|
+
* metadata and never fall back to long-lived environment credentials.
|
|
16
|
+
*/
|
|
17
|
+
export declare function resolveBloxBuildGrant(options?: ResolveBloxBuildGrantOptions): BloxBuildGrant | undefined;
|
|
18
|
+
//# sourceMappingURL=build-grant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-grant.d.ts","sourceRoot":"","sources":["../../src/ssg/build-grant.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,cAAc;IAC9B,OAAO,EAAE,CAAC,CAAA;IACV,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,4BAA4B;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAA;CACvB;AAkBD,sFAAsF;AACtF,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAqCpE;AAUD;;;GAGG;AACH,wBAAgB,qBAAqB,CACpC,OAAO,GAAE,4BAAiC,GACxC,cAAc,GAAG,SAAS,CAuB5B"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export interface BloxBuildRequestOptions {
|
|
2
|
+
/** Website authorized by the ephemeral build grant. */
|
|
3
|
+
websiteId?: string;
|
|
2
4
|
/** Server-only build token. Never use a VITE_-prefixed environment variable. */
|
|
3
5
|
token?: string;
|
|
4
6
|
/** Header accepted by the build API/gateway. @default "Authorization" */
|
|
@@ -1 +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;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E,uBAA4B,GACnC,OAAO,CAAC,QAAQ,CAAC,CAiCnB;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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
const process = require("node:process");
|
|
4
4
|
const fs = require("node:fs/promises");
|
|
5
|
-
const llmArtifacts = require("../validate-output-
|
|
5
|
+
const llmArtifacts = require("../validate-output-DqDUmsyO.cjs");
|
|
6
6
|
function installFetchTimeout() {
|
|
7
7
|
const ms = Number(process.env.BLOX_SSG_FETCH_TIMEOUT_MS) || 2e4;
|
|
8
8
|
const original = globalThis.fetch;
|
|
@@ -131,15 +131,22 @@ Environment:
|
|
|
131
131
|
console.log(`[blox-ssg] validated output in ${validateOutDir}`);
|
|
132
132
|
return;
|
|
133
133
|
}
|
|
134
|
+
const buildGrant = llmArtifacts.resolveBloxBuildGrant({ mode });
|
|
135
|
+
if (buildGrant) {
|
|
136
|
+
process.env.BLOX_WEBSITE_ID = buildGrant.websiteId;
|
|
137
|
+
process.env.BLOX_BUILD_TOKEN = buildGrant.grant;
|
|
138
|
+
}
|
|
139
|
+
const buildRequest = buildGrant ? { websiteId: buildGrant.websiteId, token: buildGrant.grant } : {};
|
|
134
140
|
if (shardsOpt !== null || routesCmd) {
|
|
135
141
|
const { apiBase: apiBase2, websiteName: configWebsiteName2 } = await resolveApiBase(mode);
|
|
136
142
|
const websiteName2 = process.env.WEBSITE_NAME ?? configWebsiteName2 ?? "default";
|
|
137
|
-
const { runSharded } = await Promise.resolve().then(() => require("../shard-runner-
|
|
143
|
+
const { runSharded } = await Promise.resolve().then(() => require("../shard-runner-D778xfd2.cjs"));
|
|
138
144
|
const code = await runSharded({
|
|
139
145
|
shards: shardsOpt ?? "auto",
|
|
140
146
|
mode,
|
|
141
147
|
apiBase: apiBase2,
|
|
142
148
|
websiteName: websiteName2,
|
|
149
|
+
buildRequest,
|
|
143
150
|
extraPaths,
|
|
144
151
|
passthroughArgs,
|
|
145
152
|
routesCmd: routesCmd || void 0
|
|
@@ -147,7 +154,7 @@ Environment:
|
|
|
147
154
|
if (code === 0 && (process.env.NODE_ENV === "production" || mode === "production")) {
|
|
148
155
|
const uploadWebsiteId = (_a = process.env.BLOX_WEBSITE_ID) == null ? void 0 : _a.trim();
|
|
149
156
|
if (uploadWebsiteId) {
|
|
150
|
-
await llmArtifacts.uploadBloxManifest(apiBase2, uploadWebsiteId);
|
|
157
|
+
await llmArtifacts.uploadBloxManifest(apiBase2, uploadWebsiteId, buildRequest);
|
|
151
158
|
console.log("Uploaded .blox-manifest.json with Git provenance");
|
|
152
159
|
} else {
|
|
153
160
|
console.log("Skipped Blox manifest upload (BLOX_WEBSITE_ID is not configured)");
|
|
@@ -169,7 +176,7 @@ Environment:
|
|
|
169
176
|
let cachedAppPaths = [];
|
|
170
177
|
const productionBuild = process.env.NODE_ENV === "production" || mode === "production";
|
|
171
178
|
try {
|
|
172
|
-
const siteData = siteDataFile ? JSON.parse(await fs.readFile(siteDataFile, "utf8")) : await llmArtifacts.fetchCmsSiteData(apiBase, websiteName);
|
|
179
|
+
const siteData = siteDataFile ? JSON.parse(await fs.readFile(siteDataFile, "utf8")) : await llmArtifacts.fetchCmsSiteData(apiBase, websiteName, buildRequest);
|
|
173
180
|
paths = siteData.paths;
|
|
174
181
|
cachedAppPaths = "appPaths" in siteData && Array.isArray(siteData.appPaths) ? siteData.appPaths : [];
|
|
175
182
|
cmsPathSet = new Set(siteData.paths.filter((path) => !cachedAppPaths.includes(path)));
|
|
@@ -270,7 +277,7 @@ ${"=".repeat(60)}`);
|
|
|
270
277
|
if (productionBuild && shardTotal === 1) {
|
|
271
278
|
const uploadWebsiteId = ((_b = process.env.BLOX_WEBSITE_ID) == null ? void 0 : _b.trim()) || websiteId;
|
|
272
279
|
if (!uploadWebsiteId) throw new Error("BLOX_WEBSITE_ID is required to upload the Blox manifest");
|
|
273
|
-
await llmArtifacts.uploadBloxManifest(apiBase, uploadWebsiteId);
|
|
280
|
+
await llmArtifacts.uploadBloxManifest(apiBase, uploadWebsiteId, buildRequest);
|
|
274
281
|
console.log("Uploaded .blox-manifest.json with Git provenance");
|
|
275
282
|
}
|
|
276
283
|
} catch (err) {
|
package/dist/ssg/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
import process from "node:process";
|
|
3
3
|
import fs from "node:fs/promises";
|
|
4
|
-
import { v as validateSsgOutput, u as uploadBloxManifest, p as polyfillBloxSsgGlobals, f as fetchCmsSiteData, a as prerender } from "../validate-output-
|
|
4
|
+
import { v as validateSsgOutput, r as resolveBloxBuildGrant, u as uploadBloxManifest, p as polyfillBloxSsgGlobals, f as fetchCmsSiteData, a as prerender } from "../validate-output-CV4nlrHm.js";
|
|
5
5
|
function installFetchTimeout() {
|
|
6
6
|
const ms = Number(process.env.BLOX_SSG_FETCH_TIMEOUT_MS) || 2e4;
|
|
7
7
|
const original = globalThis.fetch;
|
|
@@ -130,15 +130,22 @@ Environment:
|
|
|
130
130
|
console.log(`[blox-ssg] validated output in ${validateOutDir}`);
|
|
131
131
|
return;
|
|
132
132
|
}
|
|
133
|
+
const buildGrant = resolveBloxBuildGrant({ mode });
|
|
134
|
+
if (buildGrant) {
|
|
135
|
+
process.env.BLOX_WEBSITE_ID = buildGrant.websiteId;
|
|
136
|
+
process.env.BLOX_BUILD_TOKEN = buildGrant.grant;
|
|
137
|
+
}
|
|
138
|
+
const buildRequest = buildGrant ? { websiteId: buildGrant.websiteId, token: buildGrant.grant } : {};
|
|
133
139
|
if (shardsOpt !== null || routesCmd) {
|
|
134
140
|
const { apiBase: apiBase2, websiteName: configWebsiteName2 } = await resolveApiBase(mode);
|
|
135
141
|
const websiteName2 = process.env.WEBSITE_NAME ?? configWebsiteName2 ?? "default";
|
|
136
|
-
const { runSharded } = await import("../shard-runner-
|
|
142
|
+
const { runSharded } = await import("../shard-runner-BWwEIABX.js");
|
|
137
143
|
const code = await runSharded({
|
|
138
144
|
shards: shardsOpt ?? "auto",
|
|
139
145
|
mode,
|
|
140
146
|
apiBase: apiBase2,
|
|
141
147
|
websiteName: websiteName2,
|
|
148
|
+
buildRequest,
|
|
142
149
|
extraPaths,
|
|
143
150
|
passthroughArgs,
|
|
144
151
|
routesCmd: routesCmd || void 0
|
|
@@ -146,7 +153,7 @@ Environment:
|
|
|
146
153
|
if (code === 0 && (process.env.NODE_ENV === "production" || mode === "production")) {
|
|
147
154
|
const uploadWebsiteId = (_a = process.env.BLOX_WEBSITE_ID) == null ? void 0 : _a.trim();
|
|
148
155
|
if (uploadWebsiteId) {
|
|
149
|
-
await uploadBloxManifest(apiBase2, uploadWebsiteId);
|
|
156
|
+
await uploadBloxManifest(apiBase2, uploadWebsiteId, buildRequest);
|
|
150
157
|
console.log("Uploaded .blox-manifest.json with Git provenance");
|
|
151
158
|
} else {
|
|
152
159
|
console.log("Skipped Blox manifest upload (BLOX_WEBSITE_ID is not configured)");
|
|
@@ -168,7 +175,7 @@ Environment:
|
|
|
168
175
|
let cachedAppPaths = [];
|
|
169
176
|
const productionBuild = process.env.NODE_ENV === "production" || mode === "production";
|
|
170
177
|
try {
|
|
171
|
-
const siteData = siteDataFile ? JSON.parse(await fs.readFile(siteDataFile, "utf8")) : await fetchCmsSiteData(apiBase, websiteName);
|
|
178
|
+
const siteData = siteDataFile ? JSON.parse(await fs.readFile(siteDataFile, "utf8")) : await fetchCmsSiteData(apiBase, websiteName, buildRequest);
|
|
172
179
|
paths = siteData.paths;
|
|
173
180
|
cachedAppPaths = "appPaths" in siteData && Array.isArray(siteData.appPaths) ? siteData.appPaths : [];
|
|
174
181
|
cmsPathSet = new Set(siteData.paths.filter((path) => !cachedAppPaths.includes(path)));
|
|
@@ -269,7 +276,7 @@ ${"=".repeat(60)}`);
|
|
|
269
276
|
if (productionBuild && shardTotal === 1) {
|
|
270
277
|
const uploadWebsiteId = ((_b = process.env.BLOX_WEBSITE_ID) == null ? void 0 : _b.trim()) || websiteId;
|
|
271
278
|
if (!uploadWebsiteId) throw new Error("BLOX_WEBSITE_ID is required to upload the Blox manifest");
|
|
272
|
-
await uploadBloxManifest(apiBase, uploadWebsiteId);
|
|
279
|
+
await uploadBloxManifest(apiBase, uploadWebsiteId, buildRequest);
|
|
273
280
|
console.log("Uploaded .blox-manifest.json with Git provenance");
|
|
274
281
|
}
|
|
275
282
|
} catch (err) {
|
|
@@ -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;AAC1C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAA;AAoB9D,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,
|
|
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;AAoB9D,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,CA4GtB;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAC3C,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,cAAc,GAAE,uBAA4B,GAC1C,OAAO,CAAC,MAAM,EAAE,CAAC,CAGnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSSREntry.d.ts","sourceRoot":"","sources":["../../src/ssg/createSSREntry.ts"],"names":[],"mappings":"AAAA,OAA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@@ -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 llmArtifacts = require("../validate-output-
|
|
25
|
+
const llmArtifacts = require("../validate-output-DqDUmsyO.cjs");
|
|
26
26
|
const ssg_client = require("./client.cjs");
|
|
27
27
|
const pinia = require("pinia");
|
|
28
28
|
const vue = require("vue");
|
|
@@ -127,12 +127,13 @@ function createBloxSSREntry(options) {
|
|
|
127
127
|
} = options;
|
|
128
128
|
const apiBase = options.apiBase ?? (typeof process !== "undefined" ? (_a = process.env) == null ? void 0 : _a.BAGELINK_API_URL : void 0) ?? "https://api.bagel.to";
|
|
129
129
|
let websiteIdCache = null;
|
|
130
|
+
const publishedBundleCache = /* @__PURE__ */ new Map();
|
|
130
131
|
routes.setApiOrigin(apiBase);
|
|
131
132
|
routes.setCollectionResolver(options.collectionResolver ?? null);
|
|
132
133
|
async function getWebsiteId() {
|
|
133
|
-
var _a2, _b;
|
|
134
|
+
var _a2, _b, _c;
|
|
134
135
|
if (websiteIdCache) return websiteIdCache;
|
|
135
|
-
const configuredWebsiteId = typeof process !== "undefined" ? (
|
|
136
|
+
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);
|
|
136
137
|
if (configuredWebsiteId) {
|
|
137
138
|
websiteIdCache = configuredWebsiteId;
|
|
138
139
|
return websiteIdCache;
|
|
@@ -156,15 +157,21 @@ function createBloxSSREntry(options) {
|
|
|
156
157
|
return { locale, slug: urlPath || "/" };
|
|
157
158
|
}
|
|
158
159
|
async function fetchResolvedPage(slug, pageLocale) {
|
|
159
|
-
var _a2, _b;
|
|
160
|
+
var _a2, _b, _c;
|
|
160
161
|
const websiteId = await getWebsiteId();
|
|
161
|
-
const configuredWebsiteId = typeof process !== "undefined" ? (
|
|
162
|
+
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);
|
|
162
163
|
if (configuredWebsiteId) {
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
164
|
+
const cacheKey = pageLocale;
|
|
165
|
+
let pending = publishedBundleCache.get(cacheKey);
|
|
166
|
+
if (!pending) {
|
|
167
|
+
pending = llmArtifacts.bloxBuildJson(
|
|
168
|
+
`${apiBase}/blox-build/websites/${websiteId}/published?locale=${encodeURIComponent(pageLocale)}`,
|
|
169
|
+
{},
|
|
170
|
+
options.buildRequest
|
|
171
|
+
);
|
|
172
|
+
publishedBundleCache.set(cacheKey, pending);
|
|
173
|
+
}
|
|
174
|
+
const bundle = await pending;
|
|
168
175
|
const page = bundle.pages.find((candidate) => candidate.slug === slug);
|
|
169
176
|
if (!page) return null;
|
|
170
177
|
return { page, contexts: {}, warnings: [] };
|
|
@@ -345,8 +352,10 @@ exports.getBloxBuildRequestOptions = llmArtifacts.getBloxBuildRequestOptions;
|
|
|
345
352
|
exports.getSiteIconFlags = llmArtifacts.getSiteIconFlags;
|
|
346
353
|
exports.localeSitemapPath = llmArtifacts.localeSitemapPath;
|
|
347
354
|
exports.mergeLlmParts = llmArtifacts.mergeLlmParts;
|
|
355
|
+
exports.parseBloxBuildGrantBody = llmArtifacts.parseBloxBuildGrantBody;
|
|
348
356
|
exports.polyfillBloxSsgGlobals = llmArtifacts.polyfillBloxSsgGlobals;
|
|
349
357
|
exports.prerender = llmArtifacts.prerender;
|
|
358
|
+
exports.resolveBloxBuildGrant = llmArtifacts.resolveBloxBuildGrant;
|
|
350
359
|
exports.resolveManifestProvenance = llmArtifacts.resolveManifestProvenance;
|
|
351
360
|
exports.splitSitemapPathsByLocale = llmArtifacts.splitSitemapPathsByLocale;
|
|
352
361
|
exports.uploadBloxManifest = llmArtifacts.uploadBloxManifest;
|
package/dist/ssg/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { fetchCmsPrerenderPaths, fetchCmsSiteData } from './cms-routes';
|
|
2
2
|
export type { CmsSiteData, CollectionRef } from './cms-routes';
|
|
3
3
|
export { BloxBuildResponseError, bloxBuildJson, bloxBuildRequest, getBloxBuildRequestOptions } from './build-request';
|
|
4
|
+
export { parseBloxBuildGrantBody, resolveBloxBuildGrant } from './build-grant';
|
|
5
|
+
export type { BloxBuildGrant, ResolveBloxBuildGrantOptions } from './build-grant';
|
|
4
6
|
export type { BloxBuildRequestOptions } from './build-request';
|
|
5
7
|
export { getCollectionCache, getEmbeddedWebsiteId, installCollectionCache } from './collection-cache';
|
|
6
8
|
/**
|
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,sBAAsB,EAAE,aAAa,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAA;AACrH,YAAY,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,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,0BAA0B,EAAE,MAAM,aAAa,CAAA;AAC5J,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACr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AO,EAAE,aAAa,EAAE,aAAa,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,OAAO,CAAA;AACxO,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AACtF,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;AACrD,OAAO,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AACjF,YAAY,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AACrD,YAAY,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAA"}
|
package/dist/ssg/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as buildPageHead, c as primaryContextEntry, d as buildJsonLd, e as extractPageText, B as BloxBuildResponseError, h as bloxBuildJson } from "../validate-output-
|
|
2
|
-
import { i, j, k, f, l, m, n, o, g, q,
|
|
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: [] };
|
|
@@ -326,22 +333,24 @@ export {
|
|
|
326
333
|
o as generateRobotsTxt,
|
|
327
334
|
g as generateSitemapArtifacts,
|
|
328
335
|
q as generateSitemapIndexXml,
|
|
329
|
-
|
|
330
|
-
|
|
336
|
+
s as generateSitemapXml,
|
|
337
|
+
t as getBloxBuildRequestOptions,
|
|
331
338
|
getCollectionCache,
|
|
332
339
|
getEmbeddedWebsiteId,
|
|
333
|
-
|
|
340
|
+
w as getSiteIconFlags,
|
|
334
341
|
installBloxStateCache,
|
|
335
342
|
installCollectionCache,
|
|
336
|
-
|
|
337
|
-
|
|
343
|
+
x as localeSitemapPath,
|
|
344
|
+
y as mergeLlmParts,
|
|
345
|
+
z as parseBloxBuildGrantBody,
|
|
338
346
|
p as polyfillBloxSsgGlobals,
|
|
339
347
|
a as prerender,
|
|
340
348
|
querySnapshotRows,
|
|
341
349
|
renderBloxSsgPage,
|
|
342
|
-
|
|
350
|
+
r as resolveBloxBuildGrant,
|
|
351
|
+
A as resolveManifestProvenance,
|
|
343
352
|
snapshotRows,
|
|
344
|
-
|
|
353
|
+
C as splitSitemapPathsByLocale,
|
|
345
354
|
u as uploadBloxManifest,
|
|
346
355
|
v as validateSsgOutput
|
|
347
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,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) {
|
|
@@ -1287,8 +1362,10 @@ async function validateSitemap(outDir, content) {
|
|
|
1287
1362
|
return failures;
|
|
1288
1363
|
}
|
|
1289
1364
|
export {
|
|
1290
|
-
|
|
1365
|
+
resolveManifestProvenance as A,
|
|
1291
1366
|
BloxBuildResponseError as B,
|
|
1367
|
+
splitSitemapPathsByLocale as C,
|
|
1368
|
+
llmArtifacts as D,
|
|
1292
1369
|
prerender as a,
|
|
1293
1370
|
buildPageHead as b,
|
|
1294
1371
|
primaryContextEntry as c,
|
|
@@ -1306,13 +1383,13 @@ export {
|
|
|
1306
1383
|
generateRobotsTxt as o,
|
|
1307
1384
|
polyfillBloxSsgGlobals as p,
|
|
1308
1385
|
generateSitemapIndexXml as q,
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1386
|
+
resolveBloxBuildGrant as r,
|
|
1387
|
+
generateSitemapXml as s,
|
|
1388
|
+
getBloxBuildRequestOptions as t,
|
|
1312
1389
|
uploadBloxManifest as u,
|
|
1313
1390
|
validateSsgOutput as v,
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1391
|
+
getSiteIconFlags as w,
|
|
1392
|
+
localeSitemapPath as x,
|
|
1393
|
+
mergeLlmParts as y,
|
|
1394
|
+
parseBloxBuildGrantBody as z
|
|
1318
1395
|
};
|
|
@@ -21,12 +21,81 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
22
|
mod
|
|
23
23
|
));
|
|
24
|
+
const process$1 = require("node:process");
|
|
24
25
|
const node_child_process = require("node:child_process");
|
|
25
26
|
const fs = require("node:fs/promises");
|
|
26
27
|
const path = require("node:path");
|
|
27
|
-
const process$1 = require("node:process");
|
|
28
28
|
const node_url = require("node:url");
|
|
29
29
|
const pageTitle = require("./pageTitle-nIl1cDfD.cjs");
|
|
30
|
+
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;
|
|
31
|
+
const PAYLOAD_FIELDS = /* @__PURE__ */ new Set(["version", "source", "website_id", "grant"]);
|
|
32
|
+
function parseJsonObject(value) {
|
|
33
|
+
let parsed;
|
|
34
|
+
try {
|
|
35
|
+
parsed = JSON.parse(value);
|
|
36
|
+
} catch {
|
|
37
|
+
throw new Error("Invalid Blox build hook payload");
|
|
38
|
+
}
|
|
39
|
+
if (parsed === null || Array.isArray(parsed) || typeof parsed !== "object") {
|
|
40
|
+
throw new Error("Invalid Blox build hook payload");
|
|
41
|
+
}
|
|
42
|
+
return parsed;
|
|
43
|
+
}
|
|
44
|
+
function parseBloxBuildGrantBody(body) {
|
|
45
|
+
const trimmed = body.trim();
|
|
46
|
+
if (!trimmed) throw new Error("Missing Blox build hook payload");
|
|
47
|
+
let payload;
|
|
48
|
+
try {
|
|
49
|
+
payload = parseJsonObject(trimmed);
|
|
50
|
+
} catch {
|
|
51
|
+
let decoded;
|
|
52
|
+
try {
|
|
53
|
+
decoded = decodeURIComponent(trimmed);
|
|
54
|
+
} catch {
|
|
55
|
+
throw new Error("Invalid Blox build hook payload");
|
|
56
|
+
}
|
|
57
|
+
payload = parseJsonObject(decoded);
|
|
58
|
+
}
|
|
59
|
+
if (Object.keys(payload).some((field) => !PAYLOAD_FIELDS.has(field))) {
|
|
60
|
+
throw new Error("Invalid Blox build hook payload fields");
|
|
61
|
+
}
|
|
62
|
+
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() === "") {
|
|
63
|
+
throw new Error("Invalid Blox build hook payload");
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
version: 1,
|
|
67
|
+
source: "blox",
|
|
68
|
+
websiteId: payload.website_id,
|
|
69
|
+
grant: payload.grant
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function isLocalOrTest(mode, env2) {
|
|
73
|
+
return mode === "localhost" || mode === "development" || mode === "test" || env2.NODE_ENV === "development" || env2.NODE_ENV === "test";
|
|
74
|
+
}
|
|
75
|
+
function resolveBloxBuildGrant(options = {}) {
|
|
76
|
+
var _a, _b, _c, _d, _e;
|
|
77
|
+
const env2 = options.env ?? process$1.env;
|
|
78
|
+
if (isLocalOrTest(options.mode, env2)) {
|
|
79
|
+
const websiteId = (_a = env2.BLOX_WEBSITE_ID) == null ? void 0 : _a.trim();
|
|
80
|
+
const grant2 = (_b = env2.BLOX_BUILD_TOKEN) == null ? void 0 : _b.trim();
|
|
81
|
+
if (!websiteId && !grant2) return void 0;
|
|
82
|
+
if (!websiteId || !UUID_PATTERN.test(websiteId) || !grant2) {
|
|
83
|
+
throw new Error("Local Blox build overrides require a valid BLOX_WEBSITE_ID and BLOX_BUILD_TOKEN");
|
|
84
|
+
}
|
|
85
|
+
return { version: 1, source: "blox", websiteId, grant: grant2 };
|
|
86
|
+
}
|
|
87
|
+
if (!((_c = env2.INCOMING_HOOK_URL) == null ? void 0 : _c.trim()) || !((_d = env2.INCOMING_HOOK_TITLE) == null ? void 0 : _d.trim())) {
|
|
88
|
+
throw new Error("Blox production builds require Netlify incoming hook metadata");
|
|
89
|
+
}
|
|
90
|
+
const body = env2.INCOMING_HOOK_BODY;
|
|
91
|
+
if (body == null) throw new Error("Blox production builds require a hook payload");
|
|
92
|
+
const grant = parseBloxBuildGrantBody(body);
|
|
93
|
+
const configuredWebsiteId = (_e = env2.BLOX_WEBSITE_ID) == null ? void 0 : _e.trim();
|
|
94
|
+
if (configuredWebsiteId && configuredWebsiteId !== grant.websiteId) {
|
|
95
|
+
throw new Error("Blox build hook website does not match the configured website");
|
|
96
|
+
}
|
|
97
|
+
return grant;
|
|
98
|
+
}
|
|
30
99
|
class BloxBuildResponseError extends Error {
|
|
31
100
|
constructor(status, url, statusText) {
|
|
32
101
|
super(`Build API ${status} ${statusText}: ${url}`);
|
|
@@ -41,6 +110,7 @@ function env(name) {
|
|
|
41
110
|
}
|
|
42
111
|
function getBloxBuildRequestOptions(overrides = {}) {
|
|
43
112
|
return {
|
|
113
|
+
websiteId: overrides.websiteId,
|
|
44
114
|
token: overrides.token ?? env("BLOX_BUILD_TOKEN"),
|
|
45
115
|
tokenHeader: overrides.tokenHeader ?? env("BLOX_BUILD_TOKEN_HEADER") ?? "Authorization",
|
|
46
116
|
tokenScheme: overrides.tokenScheme ?? env("BLOX_BUILD_TOKEN_SCHEME") ?? "Bearer",
|
|
@@ -111,7 +181,7 @@ function expandLocalePaths(paths, defaultLocale, supportedLocales) {
|
|
|
111
181
|
}
|
|
112
182
|
async function fetchCmsSiteData(apiBase, websiteName, requestOptions = {}) {
|
|
113
183
|
var _a, _b, _c;
|
|
114
|
-
const websiteId = typeof process !== "undefined" ? (_b = (_a = process.env) == null ? void 0 : _a.BLOX_WEBSITE_ID) == null ? void 0 : _b.trim() : void 0;
|
|
184
|
+
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);
|
|
115
185
|
if (websiteId) {
|
|
116
186
|
const bundle = await bloxBuildJson(
|
|
117
187
|
`${apiBase}/blox-build/websites/${websiteId}/published`,
|
|
@@ -134,9 +204,11 @@ async function fetchCmsSiteData(apiBase, websiteName, requestOptions = {}) {
|
|
|
134
204
|
collections: extractCollectionRefs(bundle.pages)
|
|
135
205
|
};
|
|
136
206
|
}
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
207
|
+
const site = await bloxBuildJson(
|
|
208
|
+
`${apiBase}/blox/sites/${encodeURIComponent(websiteName)}`,
|
|
209
|
+
{},
|
|
210
|
+
requestOptions
|
|
211
|
+
);
|
|
140
212
|
if ((site == null ? void 0 : site.id) == null || site.id === "") throw new Error(`Website "${websiteName}" not found at ${apiBase}`);
|
|
141
213
|
const website = await bloxBuildJson(
|
|
142
214
|
`${apiBase}/blox/websites/${site.id}`,
|
|
@@ -192,6 +264,7 @@ async function fetchCmsPrerenderPaths(apiBase, websiteName, requestOptions = {})
|
|
|
192
264
|
}
|
|
193
265
|
async function expandRoutes(apiBase, pages, requestOptions, locale) {
|
|
194
266
|
const routes = [];
|
|
267
|
+
const grantedWebsiteId = requestOptions.websiteId;
|
|
195
268
|
for (const page of pages) {
|
|
196
269
|
const slug = page.slug ?? "/";
|
|
197
270
|
if (page.status && page.status !== "published") continue;
|
|
@@ -201,12 +274,13 @@ async function expandRoutes(apiBase, pages, requestOptions, locale) {
|
|
|
201
274
|
if (b.adapter === "datastore" && b.collection != null && b.collection !== "" && b.store != null && b.store !== "" && b.bind_by != null && b.bind_by !== "") {
|
|
202
275
|
const q = b.filter ? `&q=${encodeURIComponent(b.filter)}` : "";
|
|
203
276
|
const localeParam = locale ? `&locale=${encodeURIComponent(locale)}` : "";
|
|
277
|
+
const collectionPath = grantedWebsiteId ? `/blox-build/websites/${grantedWebsiteId}/collections/${b.store}/${b.collection}` : `/datastore/${b.store}/collections/${b.collection}`;
|
|
204
278
|
const itemsData = await bloxBuildJson(
|
|
205
|
-
`${apiBase}
|
|
279
|
+
`${apiBase}${collectionPath}?limit=200${localeParam}${q}`,
|
|
206
280
|
{},
|
|
207
281
|
requestOptions
|
|
208
282
|
);
|
|
209
|
-
const items = Array.isArray(itemsData) ? itemsData : itemsData.data ?? [];
|
|
283
|
+
const items = Array.isArray(itemsData) ? itemsData : itemsData.items ?? itemsData.data ?? [];
|
|
210
284
|
for (const item of items) {
|
|
211
285
|
const bindValue = item[b.bind_by];
|
|
212
286
|
if (typeof bindValue !== "string" || bindValue === "") continue;
|
|
@@ -272,9 +346,9 @@ async function resolveManifestProvenance() {
|
|
|
272
346
|
commit
|
|
273
347
|
};
|
|
274
348
|
}
|
|
275
|
-
async function uploadBloxManifest(apiBase, websiteId) {
|
|
276
|
-
if (!environment("BLOX_BUILD_TOKEN")) {
|
|
277
|
-
throw new Error("
|
|
349
|
+
async function uploadBloxManifest(apiBase, websiteId, requestOptions = {}) {
|
|
350
|
+
if (!requestOptions.token && !environment("BLOX_BUILD_TOKEN")) {
|
|
351
|
+
throw new Error("A Blox build grant is required to upload the Blox manifest");
|
|
278
352
|
}
|
|
279
353
|
const distDirectory = path.resolve(process$1.cwd(), "dist");
|
|
280
354
|
const resolvedManifestPath = path.resolve(distDirectory, ".blox-manifest.json");
|
|
@@ -289,7 +363,8 @@ async function uploadBloxManifest(apiBase, websiteId) {
|
|
|
289
363
|
method: "PUT",
|
|
290
364
|
headers: { "Content-Type": "application/json" },
|
|
291
365
|
body: JSON.stringify(payload)
|
|
292
|
-
}
|
|
366
|
+
},
|
|
367
|
+
requestOptions
|
|
293
368
|
);
|
|
294
369
|
}
|
|
295
370
|
async function polyfillBloxSsgGlobals(options) {
|
|
@@ -1330,9 +1405,11 @@ exports.getSiteIconFlags = getSiteIconFlags;
|
|
|
1330
1405
|
exports.llmArtifacts = llmArtifacts;
|
|
1331
1406
|
exports.localeSitemapPath = localeSitemapPath;
|
|
1332
1407
|
exports.mergeLlmParts = mergeLlmParts;
|
|
1408
|
+
exports.parseBloxBuildGrantBody = parseBloxBuildGrantBody;
|
|
1333
1409
|
exports.polyfillBloxSsgGlobals = polyfillBloxSsgGlobals;
|
|
1334
1410
|
exports.prerender = prerender;
|
|
1335
1411
|
exports.primaryContextEntry = primaryContextEntry;
|
|
1412
|
+
exports.resolveBloxBuildGrant = resolveBloxBuildGrant;
|
|
1336
1413
|
exports.resolveManifestProvenance = resolveManifestProvenance;
|
|
1337
1414
|
exports.splitSitemapPathsByLocale = splitSitemapPathsByLocale;
|
|
1338
1415
|
exports.uploadBloxManifest = uploadBloxManifest;
|
package/dist/vite-plugin.cjs
CHANGED
|
@@ -176,6 +176,7 @@ function bloxPlugin(options = {}) {
|
|
|
176
176
|
let outDir = "dist";
|
|
177
177
|
let isSsrBuild = false;
|
|
178
178
|
let vuePlugin;
|
|
179
|
+
let resolvedAliases;
|
|
179
180
|
plugins.push({
|
|
180
181
|
name: "vite-plugin-blox-manifest",
|
|
181
182
|
apply: "build",
|
|
@@ -184,6 +185,7 @@ function bloxPlugin(options = {}) {
|
|
|
184
185
|
outDir = resolved.build.outDir;
|
|
185
186
|
isSsrBuild = !!resolved.build.ssr;
|
|
186
187
|
vuePlugin = resolved.plugins.find((plugin) => plugin.name === "vite:vue");
|
|
188
|
+
resolvedAliases = resolved.resolve.alias;
|
|
187
189
|
},
|
|
188
190
|
resolveId(id) {
|
|
189
191
|
if (id === VIRTUAL_ENTRY) return RESOLVED_ENTRY;
|
|
@@ -212,6 +214,7 @@ function bloxPlugin(options = {}) {
|
|
|
212
214
|
configFile: false,
|
|
213
215
|
logLevel: "silent",
|
|
214
216
|
server: { middlewareMode: true, hmr: false },
|
|
217
|
+
resolve: { alias: resolvedAliases },
|
|
215
218
|
plugins: [
|
|
216
219
|
{
|
|
217
220
|
name: "vite-plugin-blox-manifest-entry",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAc,MAAM,MAAM,CAAA;AAM9C,MAAM,WAAW,iBAAiB;IACjC;;;;;OAKG;IACH,GAAG,CAAC,EAAE,OAAO,CAAA;IACb;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;;;;;;;;;;;;OAaG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;CACzB;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAc,MAAM,MAAM,CAAA;AAM9C,MAAM,WAAW,iBAAiB;IACjC;;;;;OAKG;IACH,GAAG,CAAC,EAAE,OAAO,CAAA;IACb;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;;;;;;;;;;;;OAaG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;CACzB;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,MAAM,EAAE,CAugBpE"}
|
package/dist/vite-plugin.mjs
CHANGED
|
@@ -152,6 +152,7 @@ function bloxPlugin(options = {}) {
|
|
|
152
152
|
let outDir = "dist";
|
|
153
153
|
let isSsrBuild = false;
|
|
154
154
|
let vuePlugin;
|
|
155
|
+
let resolvedAliases;
|
|
155
156
|
plugins.push({
|
|
156
157
|
name: "vite-plugin-blox-manifest",
|
|
157
158
|
apply: "build",
|
|
@@ -160,6 +161,7 @@ function bloxPlugin(options = {}) {
|
|
|
160
161
|
outDir = resolved.build.outDir;
|
|
161
162
|
isSsrBuild = !!resolved.build.ssr;
|
|
162
163
|
vuePlugin = resolved.plugins.find((plugin) => plugin.name === "vite:vue");
|
|
164
|
+
resolvedAliases = resolved.resolve.alias;
|
|
163
165
|
},
|
|
164
166
|
resolveId(id) {
|
|
165
167
|
if (id === VIRTUAL_ENTRY) return RESOLVED_ENTRY;
|
|
@@ -188,6 +190,7 @@ function bloxPlugin(options = {}) {
|
|
|
188
190
|
configFile: false,
|
|
189
191
|
logLevel: "silent",
|
|
190
192
|
server: { middlewareMode: true, hmr: false },
|
|
193
|
+
resolve: { alias: resolvedAliases },
|
|
191
194
|
plugins: [
|
|
192
195
|
{
|
|
193
196
|
name: "vite-plugin-blox-manifest-entry",
|
package/package.json
CHANGED