@bagelink/blox 1.12.11 → 1.12.13
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/ssg/client.cjs +30 -0
- package/dist/ssg/client.d.ts +9 -0
- package/dist/ssg/client.d.ts.map +1 -0
- package/dist/ssg/client.mjs +30 -0
- package/dist/ssg/index.cjs +4 -29
- package/dist/ssg/index.mjs +2 -26
- package/package.json +5 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const BLOX_STATE_WINDOW_KEY = "__BLOX_STATE__";
|
|
4
|
+
function installBloxStateCache(globalKey = BLOX_STATE_WINDOW_KEY) {
|
|
5
|
+
if (typeof window === "undefined") return;
|
|
6
|
+
const state = window[globalKey];
|
|
7
|
+
if (!state || typeof state !== "object" || Object.keys(state).length === 0) return;
|
|
8
|
+
const originalFetch = window.fetch.bind(window);
|
|
9
|
+
window.fetch = async function(input, init) {
|
|
10
|
+
const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
11
|
+
if (typeof url === "string" && url.includes("resolve-path")) {
|
|
12
|
+
try {
|
|
13
|
+
const parsed = new URL(url, window.location.origin);
|
|
14
|
+
const path = parsed.searchParams.get("path") ?? window.location.pathname;
|
|
15
|
+
if (path !== "" && state[path] != null) {
|
|
16
|
+
const cached = state[path];
|
|
17
|
+
delete state[path];
|
|
18
|
+
return new Response(JSON.stringify(cached), {
|
|
19
|
+
status: 200,
|
|
20
|
+
headers: { "Content-Type": "application/json" }
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
} catch {
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return originalFetch(input, init);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
exports.BLOX_STATE_WINDOW_KEY = BLOX_STATE_WINDOW_KEY;
|
|
30
|
+
exports.installBloxStateCache = installBloxStateCache;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @bagelink/blox/ssg/client — browser-safe SSG utilities.
|
|
3
|
+
*
|
|
4
|
+
* Use this import in client entry files (main.ts / entry-client.ts).
|
|
5
|
+
* It does NOT pull in Node.js modules (fs, path, url, happy-dom).
|
|
6
|
+
*/
|
|
7
|
+
export { BLOX_STATE_WINDOW_KEY } from './constants';
|
|
8
|
+
export { installBloxStateCache } from './state-cache';
|
|
9
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/ssg/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const BLOX_STATE_WINDOW_KEY = "__BLOX_STATE__";
|
|
2
|
+
function installBloxStateCache(globalKey = BLOX_STATE_WINDOW_KEY) {
|
|
3
|
+
if (typeof window === "undefined") return;
|
|
4
|
+
const state = window[globalKey];
|
|
5
|
+
if (!state || typeof state !== "object" || Object.keys(state).length === 0) return;
|
|
6
|
+
const originalFetch = window.fetch.bind(window);
|
|
7
|
+
window.fetch = async function(input, init) {
|
|
8
|
+
const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
9
|
+
if (typeof url === "string" && url.includes("resolve-path")) {
|
|
10
|
+
try {
|
|
11
|
+
const parsed = new URL(url, window.location.origin);
|
|
12
|
+
const path = parsed.searchParams.get("path") ?? window.location.pathname;
|
|
13
|
+
if (path !== "" && state[path] != null) {
|
|
14
|
+
const cached = state[path];
|
|
15
|
+
delete state[path];
|
|
16
|
+
return new Response(JSON.stringify(cached), {
|
|
17
|
+
status: 200,
|
|
18
|
+
headers: { "Content-Type": "application/json" }
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
} catch {
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return originalFetch(input, init);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
BLOX_STATE_WINDOW_KEY,
|
|
29
|
+
installBloxStateCache
|
|
30
|
+
};
|
package/dist/ssg/index.cjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const prerender = require("../prerender-mMYLIIC8.cjs");
|
|
4
|
-
const
|
|
4
|
+
const ssg_client = require("./client.cjs");
|
|
5
5
|
async function renderBloxSsgPage(options) {
|
|
6
6
|
const {
|
|
7
7
|
url,
|
|
8
8
|
resolvedData,
|
|
9
9
|
renderToString,
|
|
10
10
|
createAppForUrl,
|
|
11
|
-
stateWindowKey = BLOX_STATE_WINDOW_KEY
|
|
11
|
+
stateWindowKey = ssg_client.BLOX_STATE_WINDOW_KEY
|
|
12
12
|
} = options;
|
|
13
13
|
const originalFetch = globalThis.fetch;
|
|
14
14
|
if (resolvedData != null) {
|
|
@@ -39,34 +39,9 @@ async function renderBloxSsgPage(options) {
|
|
|
39
39
|
globalThis.fetch = originalFetch;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
function installBloxStateCache(globalKey = BLOX_STATE_WINDOW_KEY) {
|
|
43
|
-
if (typeof window === "undefined") return;
|
|
44
|
-
const state = window[globalKey];
|
|
45
|
-
if (!state || typeof state !== "object" || Object.keys(state).length === 0) return;
|
|
46
|
-
const originalFetch = window.fetch.bind(window);
|
|
47
|
-
window.fetch = async function(input, init) {
|
|
48
|
-
const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
49
|
-
if (typeof url === "string" && url.includes("resolve-path")) {
|
|
50
|
-
try {
|
|
51
|
-
const parsed = new URL(url, window.location.origin);
|
|
52
|
-
const path = parsed.searchParams.get("path") ?? window.location.pathname;
|
|
53
|
-
if (path !== "" && state[path] != null) {
|
|
54
|
-
const cached = state[path];
|
|
55
|
-
delete state[path];
|
|
56
|
-
return new Response(JSON.stringify(cached), {
|
|
57
|
-
status: 200,
|
|
58
|
-
headers: { "Content-Type": "application/json" }
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
} catch {
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return originalFetch(input, init);
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
42
|
exports.fetchCmsPrerenderPaths = prerender.fetchCmsPrerenderPaths;
|
|
68
43
|
exports.polyfillBloxSsgGlobals = prerender.polyfillBloxSsgGlobals;
|
|
69
44
|
exports.prerender = prerender.prerender;
|
|
70
|
-
exports.BLOX_STATE_WINDOW_KEY = BLOX_STATE_WINDOW_KEY;
|
|
71
|
-
exports.installBloxStateCache = installBloxStateCache;
|
|
45
|
+
exports.BLOX_STATE_WINDOW_KEY = ssg_client.BLOX_STATE_WINDOW_KEY;
|
|
46
|
+
exports.installBloxStateCache = ssg_client.installBloxStateCache;
|
|
72
47
|
exports.renderBloxSsgPage = renderBloxSsgPage;
|
package/dist/ssg/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { f, p, a } from "../prerender-BwmtiKjz.js";
|
|
2
|
-
|
|
2
|
+
import { BLOX_STATE_WINDOW_KEY } from "./client.mjs";
|
|
3
|
+
import { installBloxStateCache } from "./client.mjs";
|
|
3
4
|
async function renderBloxSsgPage(options) {
|
|
4
5
|
const {
|
|
5
6
|
url,
|
|
@@ -37,31 +38,6 @@ async function renderBloxSsgPage(options) {
|
|
|
37
38
|
globalThis.fetch = originalFetch;
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
|
-
function installBloxStateCache(globalKey = BLOX_STATE_WINDOW_KEY) {
|
|
41
|
-
if (typeof window === "undefined") return;
|
|
42
|
-
const state = window[globalKey];
|
|
43
|
-
if (!state || typeof state !== "object" || Object.keys(state).length === 0) return;
|
|
44
|
-
const originalFetch = window.fetch.bind(window);
|
|
45
|
-
window.fetch = async function(input, init) {
|
|
46
|
-
const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
47
|
-
if (typeof url === "string" && url.includes("resolve-path")) {
|
|
48
|
-
try {
|
|
49
|
-
const parsed = new URL(url, window.location.origin);
|
|
50
|
-
const path = parsed.searchParams.get("path") ?? window.location.pathname;
|
|
51
|
-
if (path !== "" && state[path] != null) {
|
|
52
|
-
const cached = state[path];
|
|
53
|
-
delete state[path];
|
|
54
|
-
return new Response(JSON.stringify(cached), {
|
|
55
|
-
status: 200,
|
|
56
|
-
headers: { "Content-Type": "application/json" }
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
} catch {
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return originalFetch(input, init);
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
41
|
export {
|
|
66
42
|
BLOX_STATE_WINDOW_KEY,
|
|
67
43
|
f as fetchCmsPrerenderPaths,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bagelink/blox",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.12.
|
|
4
|
+
"version": "1.12.13",
|
|
5
5
|
"description": "Blox page builder library for drag-and-drop page building and static data management",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Bagel Studio",
|
|
@@ -46,6 +46,10 @@
|
|
|
46
46
|
"types": "./dist/ssg/index.d.ts",
|
|
47
47
|
"import": "./dist/ssg/index.mjs"
|
|
48
48
|
},
|
|
49
|
+
"./ssg/client": {
|
|
50
|
+
"types": "./dist/ssg/client.d.ts",
|
|
51
|
+
"import": "./dist/ssg/client.mjs"
|
|
52
|
+
},
|
|
49
53
|
"./components": {
|
|
50
54
|
"types": "./dist/components/index.d.ts",
|
|
51
55
|
"import": "./dist/components/index.mjs"
|