@bagelink/blox 1.13.4 → 1.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/CmsPageView.vue.d.ts.map +1 -1
  2. package/dist/PreviewApp-BrthGx2F.js +4 -0
  3. package/dist/PreviewApp-CV_Uh9-d.cjs +4 -0
  4. package/dist/PreviewApp.vue.d.ts.map +1 -1
  5. package/dist/PreviewApp.vue_vue_type_style_index_0_lang-BkGWMbsE.js +185 -0
  6. package/dist/PreviewApp.vue_vue_type_style_index_0_lang-CFS05Itn.cjs +184 -0
  7. package/dist/PreviewRenderer.d.ts.map +1 -1
  8. package/dist/bridge.d.ts +1 -0
  9. package/dist/bridge.d.ts.map +1 -1
  10. package/dist/core-CPXNfJ-Z.js +460 -0
  11. package/dist/core-D1FiZJtz.cjs +459 -0
  12. package/dist/core.d.ts.map +1 -1
  13. package/dist/createBloxApp.d.ts +107 -0
  14. package/dist/createBloxApp.d.ts.map +1 -0
  15. package/dist/defineBlock.d.ts +19 -4
  16. package/dist/defineBlock.d.ts.map +1 -1
  17. package/dist/index.cjs +87 -604
  18. package/dist/index.d.ts +2 -0
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.mjs +86 -602
  21. package/dist/{prerender-CjJwDXkC.cjs → prerender-Bi7YtzSp.cjs} +48 -46
  22. package/dist/{prerender-oMLxrKGs.js → prerender-D3Q4jKXm.js} +51 -49
  23. package/dist/schema.d.ts +2 -0
  24. package/dist/schema.d.ts.map +1 -1
  25. package/dist/ssg/cli.cjs +17 -5
  26. package/dist/ssg/cli.mjs +17 -5
  27. package/dist/ssg/client.cjs +9 -7
  28. package/dist/ssg/client.d.ts +1 -1
  29. package/dist/ssg/client.d.ts.map +1 -1
  30. package/dist/ssg/client.mjs +3 -1
  31. package/dist/ssg/createSSREntry.d.ts +73 -0
  32. package/dist/ssg/createSSREntry.d.ts.map +1 -0
  33. package/dist/ssg/index.cjs +116 -8
  34. package/dist/ssg/index.d.ts +2 -0
  35. package/dist/ssg/index.d.ts.map +1 -1
  36. package/dist/ssg/index.mjs +93 -6
  37. package/dist/ssg/prerender.d.ts.map +1 -1
  38. package/dist/style.css +5 -46
  39. package/dist/vite-plugin.cjs +142 -3
  40. package/dist/vite-plugin.d.ts +22 -21
  41. package/dist/vite-plugin.d.ts.map +1 -1
  42. package/dist/vite-plugin.mjs +142 -3
  43. package/package.json +4 -1
  44. package/dist/PreviewApp-BZNzZkit.js +0 -4
  45. package/dist/PreviewApp-C1WvJWI4.cjs +0 -4
  46. package/dist/constants-BjitNk-W.js +0 -8
  47. package/dist/constants-CFB_pMvT.cjs +0 -7
@@ -112,50 +112,6 @@ function extractCollectionRefs(pages) {
112
112
  }
113
113
  return refs;
114
114
  }
115
- async function polyfillBloxSsgGlobals(options) {
116
- const { env } = await import("node:process");
117
- const pageUrl = (options == null ? void 0 : options.pageUrl) ?? env.BAGELINK_API_URL ?? "https://example.com/";
118
- const { Window: HappyWindow } = await import("happy-dom");
119
- const _win = new HappyWindow({ url: pageUrl });
120
- const g = globalThis;
121
- if (g.window == null) g.window = g;
122
- for (const key of Object.getOwnPropertyNames(_win)) {
123
- if (key === "window" || key === "global" || key === "globalThis") continue;
124
- try {
125
- if (!(key in g)) g[key] = _win[key];
126
- } catch {
127
- }
128
- }
129
- for (const key of [
130
- "document",
131
- "location",
132
- "localStorage",
133
- "sessionStorage",
134
- "navigator",
135
- "Element",
136
- "Document",
137
- "HTMLElement",
138
- "Event",
139
- "CustomEvent",
140
- "MouseEvent",
141
- "KeyboardEvent",
142
- "MutationObserver",
143
- "IntersectionObserver",
144
- "ResizeObserver",
145
- "getComputedStyle",
146
- "matchMedia",
147
- "requestAnimationFrame",
148
- "cancelAnimationFrame"
149
- ]) {
150
- try {
151
- g[key] = _win[key];
152
- } catch {
153
- }
154
- }
155
- g.window = g;
156
- g.window.location = _win.location;
157
- g.window.document = _win.document;
158
- }
159
115
  function buildPageHead(options) {
160
116
  const { url, resolvedData, website, stateScript } = options;
161
117
  const parts = [];
@@ -267,7 +223,8 @@ Sitemap: ${base}/sitemap.xml
267
223
  ` : "";
268
224
  if (robotsTxt) {
269
225
  if (sitemapLine && !robotsTxt.toLowerCase().includes("sitemap:")) {
270
- return robotsTxt.trimEnd() + "\n" + sitemapLine;
226
+ return `${robotsTxt.trimEnd()}
227
+ ${sitemapLine}`;
271
228
  }
272
229
  return robotsTxt;
273
230
  }
@@ -277,7 +234,8 @@ ${sitemapLine}`;
277
234
  }
278
235
  function generateNetlifyRedirects(redirects) {
279
236
  if (redirects.length === 0) return "";
280
- return redirects.map((r) => `${r.from_path} ${r.to_path} ${r.status_code}`).join("\n") + "\n";
237
+ return `${redirects.map((r) => `${r.from_path} ${r.to_path} ${r.status_code}`).join("\n")}
238
+ `;
281
239
  }
282
240
  function stripTemplateSeoTags(template) {
283
241
  return template.replace(/<title>[^<]*<\/title>/gi, "<!--ssg:title-->").replace(/<meta\s[^>]*name\s*=\s*["']description["'][^>]*>/gi, "").replace(/<meta\s[^>]*property\s*=\s*["']og:[^"']*["'][^>]*>/gi, "").replace(/<meta\s[^>]*(?:property|name)\s*=\s*["']twitter:[^"']*["'][^>]*>/gi, "").replace(/<link\s[^>]*rel\s*=\s*["']apple-touch-icon["'][^>]*>/gi, "").replace(/<link\s[^>]*rel\s*=\s*["']icon["'][^>]*>/gi, "").replace(/\n\s*\n\s*\n/g, "\n\n");
@@ -300,6 +258,50 @@ function extractPrimaryContext(contexts) {
300
258
  function esc(s) {
301
259
  return s.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
302
260
  }
261
+ async function polyfillBloxSsgGlobals(options) {
262
+ const { env } = await import("node:process");
263
+ const pageUrl = (options == null ? void 0 : options.pageUrl) ?? env.BAGELINK_API_URL ?? "https://example.com/";
264
+ const { Window: HappyWindow } = await import("happy-dom");
265
+ const _win = new HappyWindow({ url: pageUrl });
266
+ const g = globalThis;
267
+ if (g.window == null) g.window = g;
268
+ for (const key of Object.getOwnPropertyNames(_win)) {
269
+ if (key === "window" || key === "global" || key === "globalThis") continue;
270
+ try {
271
+ if (!(key in g)) g[key] = _win[key];
272
+ } catch {
273
+ }
274
+ }
275
+ for (const key of [
276
+ "document",
277
+ "location",
278
+ "localStorage",
279
+ "sessionStorage",
280
+ "navigator",
281
+ "Element",
282
+ "Document",
283
+ "HTMLElement",
284
+ "Event",
285
+ "CustomEvent",
286
+ "MouseEvent",
287
+ "KeyboardEvent",
288
+ "MutationObserver",
289
+ "IntersectionObserver",
290
+ "ResizeObserver",
291
+ "getComputedStyle",
292
+ "matchMedia",
293
+ "requestAnimationFrame",
294
+ "cancelAnimationFrame"
295
+ ]) {
296
+ try {
297
+ g[key] = _win[key];
298
+ } catch {
299
+ }
300
+ }
301
+ g.window = g;
302
+ g.window.location = _win.location;
303
+ g.window.document = _win.document;
304
+ }
303
305
  async function prerender({
304
306
  root = process.cwd(),
305
307
  clientOutDir = "dist/client",
@@ -89,50 +89,6 @@ function extractCollectionRefs(pages) {
89
89
  }
90
90
  return refs;
91
91
  }
92
- async function polyfillBloxSsgGlobals(options) {
93
- const { env } = await import("node:process");
94
- const pageUrl = (options == null ? void 0 : options.pageUrl) ?? env.BAGELINK_API_URL ?? "https://example.com/";
95
- const { Window: HappyWindow } = await import("happy-dom");
96
- const _win = new HappyWindow({ url: pageUrl });
97
- const g = globalThis;
98
- if (g.window == null) g.window = g;
99
- for (const key of Object.getOwnPropertyNames(_win)) {
100
- if (key === "window" || key === "global" || key === "globalThis") continue;
101
- try {
102
- if (!(key in g)) g[key] = _win[key];
103
- } catch {
104
- }
105
- }
106
- for (const key of [
107
- "document",
108
- "location",
109
- "localStorage",
110
- "sessionStorage",
111
- "navigator",
112
- "Element",
113
- "Document",
114
- "HTMLElement",
115
- "Event",
116
- "CustomEvent",
117
- "MouseEvent",
118
- "KeyboardEvent",
119
- "MutationObserver",
120
- "IntersectionObserver",
121
- "ResizeObserver",
122
- "getComputedStyle",
123
- "matchMedia",
124
- "requestAnimationFrame",
125
- "cancelAnimationFrame"
126
- ]) {
127
- try {
128
- g[key] = _win[key];
129
- } catch {
130
- }
131
- }
132
- g.window = g;
133
- g.window.location = _win.location;
134
- g.window.document = _win.document;
135
- }
136
92
  function buildPageHead(options) {
137
93
  const { url, resolvedData, website, stateScript } = options;
138
94
  const parts = [];
@@ -244,7 +200,8 @@ Sitemap: ${base}/sitemap.xml
244
200
  ` : "";
245
201
  if (robotsTxt) {
246
202
  if (sitemapLine && !robotsTxt.toLowerCase().includes("sitemap:")) {
247
- return robotsTxt.trimEnd() + "\n" + sitemapLine;
203
+ return `${robotsTxt.trimEnd()}
204
+ ${sitemapLine}`;
248
205
  }
249
206
  return robotsTxt;
250
207
  }
@@ -254,7 +211,8 @@ ${sitemapLine}`;
254
211
  }
255
212
  function generateNetlifyRedirects(redirects) {
256
213
  if (redirects.length === 0) return "";
257
- return redirects.map((r) => `${r.from_path} ${r.to_path} ${r.status_code}`).join("\n") + "\n";
214
+ return `${redirects.map((r) => `${r.from_path} ${r.to_path} ${r.status_code}`).join("\n")}
215
+ `;
258
216
  }
259
217
  function stripTemplateSeoTags(template) {
260
218
  return template.replace(/<title>[^<]*<\/title>/gi, "<!--ssg:title-->").replace(/<meta\s[^>]*name\s*=\s*["']description["'][^>]*>/gi, "").replace(/<meta\s[^>]*property\s*=\s*["']og:[^"']*["'][^>]*>/gi, "").replace(/<meta\s[^>]*(?:property|name)\s*=\s*["']twitter:[^"']*["'][^>]*>/gi, "").replace(/<link\s[^>]*rel\s*=\s*["']apple-touch-icon["'][^>]*>/gi, "").replace(/<link\s[^>]*rel\s*=\s*["']icon["'][^>]*>/gi, "").replace(/\n\s*\n\s*\n/g, "\n\n");
@@ -277,6 +235,50 @@ function extractPrimaryContext(contexts) {
277
235
  function esc(s) {
278
236
  return s.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
279
237
  }
238
+ async function polyfillBloxSsgGlobals(options) {
239
+ const { env } = await import("node:process");
240
+ const pageUrl = (options == null ? void 0 : options.pageUrl) ?? env.BAGELINK_API_URL ?? "https://example.com/";
241
+ const { Window: HappyWindow } = await import("happy-dom");
242
+ const _win = new HappyWindow({ url: pageUrl });
243
+ const g = globalThis;
244
+ if (g.window == null) g.window = g;
245
+ for (const key of Object.getOwnPropertyNames(_win)) {
246
+ if (key === "window" || key === "global" || key === "globalThis") continue;
247
+ try {
248
+ if (!(key in g)) g[key] = _win[key];
249
+ } catch {
250
+ }
251
+ }
252
+ for (const key of [
253
+ "document",
254
+ "location",
255
+ "localStorage",
256
+ "sessionStorage",
257
+ "navigator",
258
+ "Element",
259
+ "Document",
260
+ "HTMLElement",
261
+ "Event",
262
+ "CustomEvent",
263
+ "MouseEvent",
264
+ "KeyboardEvent",
265
+ "MutationObserver",
266
+ "IntersectionObserver",
267
+ "ResizeObserver",
268
+ "getComputedStyle",
269
+ "matchMedia",
270
+ "requestAnimationFrame",
271
+ "cancelAnimationFrame"
272
+ ]) {
273
+ try {
274
+ g[key] = _win[key];
275
+ } catch {
276
+ }
277
+ }
278
+ g.window = g;
279
+ g.window.location = _win.location;
280
+ g.window.document = _win.document;
281
+ }
280
282
  async function prerender({
281
283
  root = process.cwd(),
282
284
  clientOutDir = "dist/client",
@@ -508,12 +510,12 @@ function discoverInternalLinks(html) {
508
510
  return [...out];
509
511
  }
510
512
  export {
511
- fetchCmsSiteData as a,
513
+ prerender as a,
512
514
  buildPageHead as b,
513
- prerender as c,
515
+ fetchCmsPrerenderPaths as c,
514
516
  buildSiteHead as d,
515
517
  generateRobotsTxt as e,
516
- fetchCmsPrerenderPaths as f,
518
+ fetchCmsSiteData as f,
517
519
  generateNetlifyRedirects as g,
518
520
  generateSitemapXml as h,
519
521
  polyfillBloxSsgGlobals as p
package/dist/schema.d.ts CHANGED
@@ -14,6 +14,8 @@ export interface BlockSchema {
14
14
  fields?: SchemaDefinition;
15
15
  /** Default prop values. Merged with block props at render time. */
16
16
  defaults?: Record<string, unknown>;
17
+ /** True when this block fetches its own data from a datastore collection. */
18
+ dataSource?: boolean;
17
19
  }
18
20
  export interface BlockDefinition {
19
21
  component: Component;
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AACpC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C,MAAM,WAAW,WAAW;IAC3B,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,sDAAsD;IACtD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;OAGG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAA;IACzB,mEAAmE;IACnE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAClC;AAED,MAAM,WAAW,eAAe;IAC/B,SAAS,EAAE,SAAS,CAAA;IACpB,MAAM,EAAE,WAAW,CAAA;CACnB;AAED,+EAA+E;AAC/E,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,CAAA"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AACpC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C,MAAM,WAAW,WAAW;IAC3B,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,sDAAsD;IACtD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;OAGG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAA;IACzB,mEAAmE;IACnE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAClC,6EAA6E;IAC7E,UAAU,CAAC,EAAE,OAAO,CAAA;CACpB;AAED,MAAM,WAAW,eAAe;IAC/B,SAAS,EAAE,SAAS,CAAA;IACpB,MAAM,EAAE,WAAW,CAAA;CACnB;AAED,+EAA+E;AAC/E,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,CAAA"}
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 prerender = require("../prerender-CjJwDXkC.cjs");
4
+ const prerender = require("../prerender-Bi7YtzSp.cjs");
5
5
  async function resolveApiBase(mode) {
6
6
  if (process.env.BAGELINK_API_URL != null && process.env.BAGELINK_API_URL !== "") {
7
7
  return { apiBase: process.env.BAGELINK_API_URL };
@@ -30,6 +30,7 @@ async function resolveApiBase(mode) {
30
30
  return { apiBase: "https://localhost:8000" };
31
31
  }
32
32
  async function main() {
33
+ var _a;
33
34
  const argv = process.argv.slice(2);
34
35
  const extraPaths = [];
35
36
  let crawl = false;
@@ -75,7 +76,7 @@ Environment:
75
76
  let website = null;
76
77
  let websiteId = "";
77
78
  let redirects = [];
78
- let collections = {};
79
+ const collections = {};
79
80
  try {
80
81
  const siteData = await prerender.fetchCmsSiteData(apiBase, websiteName);
81
82
  paths = siteData.paths;
@@ -84,9 +85,20 @@ Environment:
84
85
  redirects = siteData.redirects;
85
86
  console.log(` Found ${paths.length} CMS routes`);
86
87
  if (redirects.length > 0) console.log(` Found ${redirects.length} redirects`);
87
- if (siteData.collections.length > 0) {
88
- console.log(` Pre-fetching ${siteData.collections.length} datastore collection(s)…`);
89
- for (const ref of siteData.collections) {
88
+ const allCollectionRefs = [...siteData.collections];
89
+ const extraCollections = (_a = process.env.BLOX_SSG_COLLECTIONS) == null ? void 0 : _a.trim();
90
+ if (extraCollections) {
91
+ for (const entry of extraCollections.split(",")) {
92
+ const parts = entry.trim().split("/");
93
+ if (parts.length === 2 && parts[0] && parts[1]) {
94
+ const already = allCollectionRefs.some((r) => r.store === parts[0] && r.collection === parts[1]);
95
+ if (!already) allCollectionRefs.push({ store: parts[0], collection: parts[1] });
96
+ }
97
+ }
98
+ }
99
+ if (allCollectionRefs.length > 0) {
100
+ console.log(` Pre-fetching ${allCollectionRefs.length} datastore collection(s)…`);
101
+ for (const ref of allCollectionRefs) {
90
102
  try {
91
103
  const url = `${apiBase}/datastore/${ref.store}/collections/${ref.collection}?limit=500`;
92
104
  const res = await fetch(url);
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, a as fetchCmsSiteData, c as prerender } from "../prerender-oMLxrKGs.js";
3
+ import { p as polyfillBloxSsgGlobals, f as fetchCmsSiteData, a as prerender } from "../prerender-D3Q4jKXm.js";
4
4
  async function resolveApiBase(mode) {
5
5
  if (process.env.BAGELINK_API_URL != null && process.env.BAGELINK_API_URL !== "") {
6
6
  return { apiBase: process.env.BAGELINK_API_URL };
@@ -29,6 +29,7 @@ async function resolveApiBase(mode) {
29
29
  return { apiBase: "https://localhost:8000" };
30
30
  }
31
31
  async function main() {
32
+ var _a;
32
33
  const argv = process.argv.slice(2);
33
34
  const extraPaths = [];
34
35
  let crawl = false;
@@ -74,7 +75,7 @@ Environment:
74
75
  let website = null;
75
76
  let websiteId = "";
76
77
  let redirects = [];
77
- let collections = {};
78
+ const collections = {};
78
79
  try {
79
80
  const siteData = await fetchCmsSiteData(apiBase, websiteName);
80
81
  paths = siteData.paths;
@@ -83,9 +84,20 @@ Environment:
83
84
  redirects = siteData.redirects;
84
85
  console.log(` Found ${paths.length} CMS routes`);
85
86
  if (redirects.length > 0) console.log(` Found ${redirects.length} redirects`);
86
- if (siteData.collections.length > 0) {
87
- console.log(` Pre-fetching ${siteData.collections.length} datastore collection(s)…`);
88
- for (const ref of siteData.collections) {
87
+ const allCollectionRefs = [...siteData.collections];
88
+ const extraCollections = (_a = process.env.BLOX_SSG_COLLECTIONS) == null ? void 0 : _a.trim();
89
+ if (extraCollections) {
90
+ for (const entry of extraCollections.split(",")) {
91
+ const parts = entry.trim().split("/");
92
+ if (parts.length === 2 && parts[0] && parts[1]) {
93
+ const already = allCollectionRefs.some((r) => r.store === parts[0] && r.collection === parts[1]);
94
+ if (!already) allCollectionRefs.push({ store: parts[0], collection: parts[1] });
95
+ }
96
+ }
97
+ }
98
+ if (allCollectionRefs.length > 0) {
99
+ console.log(` Pre-fetching ${allCollectionRefs.length} datastore collection(s)…`);
100
+ for (const ref of allCollectionRefs) {
89
101
  try {
90
102
  const url = `${apiBase}/datastore/${ref.store}/collections/${ref.collection}?limit=500`;
91
103
  const res = await fetch(url);
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const constants = require("../constants-CFB_pMvT.cjs");
3
+ const BLOX_STATE_WINDOW_KEY = "__BLOX_STATE__";
4
+ const BLOX_COLLECTIONS_WINDOW_KEY = "__BLOX_COLLECTIONS__";
5
+ const BLOX_WEBSITE_ID_WINDOW_KEY = "__BLOX_WEBSITE_ID__";
4
6
  let _cache = null;
5
7
  function readCache() {
6
8
  if (_cache != null) return _cache;
7
9
  if (typeof window === "undefined") return null;
8
- const raw = window[constants.BLOX_COLLECTIONS_WINDOW_KEY];
10
+ const raw = window[BLOX_COLLECTIONS_WINDOW_KEY];
9
11
  if (raw && typeof raw === "object" && !Array.isArray(raw)) {
10
12
  _cache = raw;
11
13
  return _cache;
@@ -17,7 +19,7 @@ function getCollectionCache() {
17
19
  }
18
20
  function getEmbeddedWebsiteId() {
19
21
  if (typeof window === "undefined") return "";
20
- const id = window[constants.BLOX_WEBSITE_ID_WINDOW_KEY];
22
+ const id = window[BLOX_WEBSITE_ID_WINDOW_KEY];
21
23
  return typeof id === "string" ? id : "";
22
24
  }
23
25
  function installCollectionCache() {
@@ -41,7 +43,7 @@ function installCollectionCache() {
41
43
  return config;
42
44
  };
43
45
  }
44
- function installBloxStateCache(globalKey = constants.BLOX_STATE_WINDOW_KEY) {
46
+ function installBloxStateCache(globalKey = BLOX_STATE_WINDOW_KEY) {
45
47
  if (typeof window === "undefined") return;
46
48
  const state = window[globalKey];
47
49
  if (!state || typeof state !== "object" || Object.keys(state).length === 0) return;
@@ -66,9 +68,9 @@ function installBloxStateCache(globalKey = constants.BLOX_STATE_WINDOW_KEY) {
66
68
  return originalFetch(input, init);
67
69
  };
68
70
  }
69
- exports.BLOX_COLLECTIONS_WINDOW_KEY = constants.BLOX_COLLECTIONS_WINDOW_KEY;
70
- exports.BLOX_STATE_WINDOW_KEY = constants.BLOX_STATE_WINDOW_KEY;
71
- exports.BLOX_WEBSITE_ID_WINDOW_KEY = constants.BLOX_WEBSITE_ID_WINDOW_KEY;
71
+ exports.BLOX_COLLECTIONS_WINDOW_KEY = BLOX_COLLECTIONS_WINDOW_KEY;
72
+ exports.BLOX_STATE_WINDOW_KEY = BLOX_STATE_WINDOW_KEY;
73
+ exports.BLOX_WEBSITE_ID_WINDOW_KEY = BLOX_WEBSITE_ID_WINDOW_KEY;
72
74
  exports.getCollectionCache = getCollectionCache;
73
75
  exports.getEmbeddedWebsiteId = getEmbeddedWebsiteId;
74
76
  exports.installBloxStateCache = installBloxStateCache;
@@ -1,3 +1,4 @@
1
+ export { getCollectionCache, getEmbeddedWebsiteId, installCollectionCache } from './collection-cache';
1
2
  /**
2
3
  * @bagelink/blox/ssg/client — browser-safe SSG utilities.
3
4
  *
@@ -5,6 +6,5 @@
5
6
  * It does NOT pull in Node.js modules (fs, path, url, happy-dom).
6
7
  */
7
8
  export { BLOX_COLLECTIONS_WINDOW_KEY, BLOX_STATE_WINDOW_KEY, BLOX_WEBSITE_ID_WINDOW_KEY } from './constants';
8
- export { getCollectionCache, getEmbeddedWebsiteId, installCollectionCache } from './collection-cache';
9
9
  export { installBloxStateCache } from './state-cache';
10
10
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/ssg/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,2BAA2B,EAAE,qBAAqB,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAA;AAC5G,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AACrG,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/ssg/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AACrG;;;;;GAKG;AACH,OAAO,EAAE,2BAA2B,EAAE,qBAAqB,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAA;AAC5G,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA"}
@@ -1,4 +1,6 @@
1
- import { b as BLOX_WEBSITE_ID_WINDOW_KEY, a as BLOX_COLLECTIONS_WINDOW_KEY, B as BLOX_STATE_WINDOW_KEY } from "../constants-BjitNk-W.js";
1
+ const BLOX_STATE_WINDOW_KEY = "__BLOX_STATE__";
2
+ const BLOX_COLLECTIONS_WINDOW_KEY = "__BLOX_COLLECTIONS__";
3
+ const BLOX_WEBSITE_ID_WINDOW_KEY = "__BLOX_WEBSITE_ID__";
2
4
  let _cache = null;
3
5
  function readCache() {
4
6
  if (_cache != null) return _cache;
@@ -0,0 +1,73 @@
1
+ import { Component } from 'vue';
2
+ import { Router } from 'vue-router';
3
+ import { BlockModule } from '../defineBlock';
4
+ import { RenderContext, RenderResult } from './prerender';
5
+ export interface CreateBloxSSREntryOptions {
6
+ /** Root Vue component (App.vue). */
7
+ rootComponent: Component;
8
+ /**
9
+ * Router factory. Must return a fresh router for each render call.
10
+ * @param mode - 'web' for client, 'memory' for SSR
11
+ * @param url - initial URL (only for 'memory' mode)
12
+ */
13
+ createRouter: (mode: 'web' | 'memory', url?: string) => Router;
14
+ /**
15
+ * Block SFC modules — same format as `createBloxApp`.
16
+ * Use `import.meta.glob('./components/blocks/*.vue', { eager: true })`.
17
+ */
18
+ modules: BlockModule[] | Record<string, BlockModule>;
19
+ /** CMS website name. */
20
+ websiteName: string;
21
+ /** Datastore store identifier. */
22
+ store: string;
23
+ /** API base URL for SSR fetches. @default process.env.BAGELINK_API_URL ?? 'https://api.bagel.to' */
24
+ apiBase?: string;
25
+ /** Default locale. @default 'en' */
26
+ locale?: string;
27
+ /** Supported locales. @default [locale] */
28
+ supportedLocales?: string[];
29
+ /**
30
+ * Extra Vue plugins to install on the SSR app.
31
+ * Typically `[BagelVue]` from `@bagelink/vue`.
32
+ */
33
+ plugins?: Array<import('vue').Plugin | [import('vue').Plugin, ...unknown[]]>;
34
+ /**
35
+ * Global components to register.
36
+ * Typically `{ RouterWrapper }` from `@bagelink/vue`.
37
+ */
38
+ globalComponents?: Record<string, Component>;
39
+ }
40
+ export interface BloxSSREntry {
41
+ render: (url: string, ctx: RenderContext) => Promise<RenderResult>;
42
+ }
43
+ /**
44
+ * Factory that produces the `{ render }` export for `main.server.ts`.
45
+ *
46
+ * Encapsulates all SSR boilerplate:
47
+ * - Website ID resolution
48
+ * - CMS page data fetching
49
+ * - Vue SSR app creation with Blox + Pinia
50
+ * - `renderBloxSsgPage()` call with full context passthrough
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * import { createBloxSSREntry } from '@bagelink/blox/ssg'
55
+ * import { BagelVue, RouterWrapper } from '@bagelink/vue'
56
+ * import App from './App.vue'
57
+ * import { createRouter } from './router'
58
+ *
59
+ * const blocks = import.meta.glob('./components/blocks/*.vue', { eager: true })
60
+ *
61
+ * export const { render } = createBloxSSREntry({
62
+ * rootComponent: App,
63
+ * createRouter,
64
+ * modules: Object.values(blocks),
65
+ * websiteName: 'cylogic',
66
+ * store: 'cylogic',
67
+ * plugins: [BagelVue],
68
+ * globalComponents: { RouterWrapper },
69
+ * })
70
+ * ```
71
+ */
72
+ export declare function createBloxSSREntry(options: CreateBloxSSREntryOptions): BloxSSREntry;
73
+ //# sourceMappingURL=createSSREntry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createSSREntry.d.ts","sourceRoot":"","sources":["../../src/ssg/createSSREntry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAO,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;AAO9D,MAAM,WAAW,yBAAyB;IACzC,oCAAoC;IACpC,aAAa,EAAE,SAAS,CAAA;IACxB;;;;OAIG;IACH,YAAY,EAAE,CAAC,IAAI,EAAE,KAAK,GAAG,QAAQ,EAAE,GAAG,CAAC,EAAE,MAAM,KAAK,MAAM,CAAA;IAC9D;;;OAGG;IACH,OAAO,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;IACpD,wBAAwB;IACxB,WAAW,EAAE,MAAM,CAAA;IACnB,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAA;IACb,oGAAoG;IACpG,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,oCAAoC;IACpC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,2CAA2C;IAC3C,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC3B;;;OAGG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,OAAO,KAAK,EAAE,MAAM,GAAG,CAAC,OAAO,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,CAAA;IAC5E;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;CAC5C;AAED,MAAM,WAAW,YAAY;IAC5B,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa,KAAK,OAAO,CAAC,YAAY,CAAC,CAAA;CAClE;AAKD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,YAAY,CAqGnF"}