@storyblok/astro 7.3.6 → 7.3.7
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/storyblok-astro.es.js +309 -309
- package/dist/storyblok-astro.umd.js +9 -9
- package/package.json +2 -2
|
@@ -55,17 +55,17 @@ function ke(e) {
|
|
|
55
55
|
function we(e) {
|
|
56
56
|
return e.endsWith(".astro") ? e : `${e}.astro`;
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function F(e) {
|
|
59
59
|
return `/${e.trim().replace(/^\/+/, "").replace(/\/+$/, "").replace(/\/{2,}/g, "/")}`;
|
|
60
60
|
}
|
|
61
|
-
const Le = /[\p{Lu}]/u, Ae = /[\p{Ll}]/u,
|
|
62
|
-
let o = !1, n = !1,
|
|
61
|
+
const Le = /[\p{Lu}]/u, Ae = /[\p{Ll}]/u, Y = /^[\p{Lu}](?![\p{Lu}])/gu, ie = /([\p{Alpha}\p{N}_]|$)/u, G = /[_.\- ]+/, Ee = new RegExp("^" + G.source), K = new RegExp(G.source + ie.source, "gu"), X = new RegExp("\\d+" + ie.source, "gu"), Re = (e, t, s, r) => {
|
|
62
|
+
let o = !1, n = !1, a = !1, l = !1;
|
|
63
63
|
for (let c = 0; c < e.length; c++) {
|
|
64
64
|
const u = e[c];
|
|
65
|
-
|
|
65
|
+
l = c > 2 ? e[c - 3] === "-" : !0, o && Le.test(u) ? (e = e.slice(0, c) + "-" + e.slice(c), o = !1, a = n, n = !0, c++) : n && a && Ae.test(u) && (!l || r) ? (e = e.slice(0, c - 1) + "-" + e.slice(c - 1), a = n, n = !1, o = !0) : (o = t(u) === u && s(u) !== u, a = n, n = s(u) === u && t(u) !== u);
|
|
66
66
|
}
|
|
67
67
|
return e;
|
|
68
|
-
},
|
|
68
|
+
}, Te = (e, t) => (Y.lastIndex = 0, e.replaceAll(Y, (s) => t(s))), _e = (e, t) => (K.lastIndex = 0, X.lastIndex = 0, e.replaceAll(X, (s, r, o) => ["_", "-"].includes(e.charAt(o + s.length)) ? s : t(s)).replaceAll(K, (s, r) => t(r)));
|
|
69
69
|
function $e(e, t) {
|
|
70
70
|
if (!(typeof e == "string" || Array.isArray(e)))
|
|
71
71
|
throw new TypeError("Expected the input to be `string | string[]`");
|
|
@@ -76,29 +76,29 @@ function $e(e, t) {
|
|
|
76
76
|
}, Array.isArray(e) ? e = e.map((n) => n.trim()).filter((n) => n.length).join("-") : e = e.trim(), e.length === 0)
|
|
77
77
|
return "";
|
|
78
78
|
const s = t.locale === !1 ? (n) => n.toLowerCase() : (n) => n.toLocaleLowerCase(t.locale), r = t.locale === !1 ? (n) => n.toUpperCase() : (n) => n.toLocaleUpperCase(t.locale);
|
|
79
|
-
return e.length === 1 ?
|
|
79
|
+
return e.length === 1 ? G.test(e) ? "" : t.pascalCase ? r(e) : s(e) : (e !== s(e) && (e = Re(e, s, r, t.preserveConsecutiveUppercase)), e = e.replace(Ee, ""), e = t.preserveConsecutiveUppercase ? Te(e, s) : s(e), t.pascalCase && (e = r(e.charAt(0)) + e.slice(1)), _e(e, r));
|
|
80
80
|
}
|
|
81
|
-
function
|
|
81
|
+
function Ie(e) {
|
|
82
82
|
return $e(e);
|
|
83
83
|
}
|
|
84
|
-
function
|
|
84
|
+
function Se(e, t, s, r) {
|
|
85
85
|
const o = "virtual:import-storyblok-components", n = `\0${o}`;
|
|
86
86
|
return {
|
|
87
87
|
name: "vite-plugin-import-storyblok-components",
|
|
88
88
|
/**
|
|
89
89
|
* Resolves virtual module imports
|
|
90
90
|
*/
|
|
91
|
-
async resolveId(
|
|
92
|
-
if (
|
|
91
|
+
async resolveId(a) {
|
|
92
|
+
if (a === o)
|
|
93
93
|
return n;
|
|
94
94
|
},
|
|
95
95
|
/**
|
|
96
96
|
* Generates the virtual module content with dynamic imports
|
|
97
97
|
*/
|
|
98
|
-
async load(
|
|
99
|
-
if (
|
|
98
|
+
async load(a) {
|
|
99
|
+
if (a !== n)
|
|
100
100
|
return;
|
|
101
|
-
const
|
|
101
|
+
const l = await xe(
|
|
102
102
|
this,
|
|
103
103
|
t,
|
|
104
104
|
s,
|
|
@@ -111,14 +111,14 @@ function Ie(e, t, s, r) {
|
|
|
111
111
|
);
|
|
112
112
|
return Oe(
|
|
113
113
|
t,
|
|
114
|
-
|
|
114
|
+
l,
|
|
115
115
|
c
|
|
116
116
|
);
|
|
117
117
|
}
|
|
118
118
|
};
|
|
119
119
|
}
|
|
120
120
|
function Oe(e, t, s) {
|
|
121
|
-
const o = `${
|
|
121
|
+
const o = `${F(e)}/storyblok/**/*.astro`;
|
|
122
122
|
return `
|
|
123
123
|
// Import utilities and fallback component
|
|
124
124
|
import { toCamelCase } from '@storyblok/astro';
|
|
@@ -148,9 +148,9 @@ function Oe(e, t, s) {
|
|
|
148
148
|
|
|
149
149
|
// Manual imports (overwrite auto if same key exists)
|
|
150
150
|
${s.map((n) => {
|
|
151
|
-
var
|
|
152
|
-
const
|
|
153
|
-
return `storyblokComponents['${
|
|
151
|
+
var l;
|
|
152
|
+
const a = (l = n.match(/import\s+(\w+)\s+from/)) == null ? void 0 : l[1];
|
|
153
|
+
return `storyblokComponents['${a}'] = ${a};`;
|
|
154
154
|
}).join(`
|
|
155
155
|
`)}
|
|
156
156
|
|
|
@@ -179,19 +179,19 @@ async function xe(e, t, s, r) {
|
|
|
179
179
|
}
|
|
180
180
|
async function Me(e, t, s, r) {
|
|
181
181
|
const o = [];
|
|
182
|
-
for await (const [n,
|
|
183
|
-
const
|
|
182
|
+
for await (const [n, a] of Object.entries(t)) {
|
|
183
|
+
const l = ae(s, a), c = await e.resolve(l);
|
|
184
184
|
if (c)
|
|
185
|
-
o.push(`import ${
|
|
185
|
+
o.push(`import ${Ie(n)} from "${c.id}"`);
|
|
186
186
|
else if (!r)
|
|
187
187
|
throw new Error(
|
|
188
|
-
`Component could not be found for blok "${n}"! Does "${
|
|
188
|
+
`Component could not be found for blok "${n}"! Does "${l}" exist?`
|
|
189
189
|
);
|
|
190
190
|
}
|
|
191
191
|
return o;
|
|
192
192
|
}
|
|
193
193
|
function ae(e, t) {
|
|
194
|
-
const r = `${
|
|
194
|
+
const r = `${F(e)}${F(t)}`;
|
|
195
195
|
return we(r);
|
|
196
196
|
}
|
|
197
197
|
function ft(e) {
|
|
@@ -207,51 +207,51 @@ function ft(e) {
|
|
|
207
207
|
useCustomApi: r,
|
|
208
208
|
apiOptions: o,
|
|
209
209
|
componentsDir: n,
|
|
210
|
-
customFallbackComponent:
|
|
211
|
-
enableFallbackComponent:
|
|
210
|
+
customFallbackComponent: a,
|
|
211
|
+
enableFallbackComponent: l,
|
|
212
212
|
components: c,
|
|
213
213
|
bridge: u,
|
|
214
|
-
livePreview:
|
|
215
|
-
} = t,
|
|
214
|
+
livePreview: g
|
|
215
|
+
} = t, d = ke(t.bridge);
|
|
216
216
|
return {
|
|
217
217
|
name: "@storyblok/astro",
|
|
218
218
|
hooks: {
|
|
219
219
|
"astro:config:setup": ({
|
|
220
|
-
injectScript:
|
|
221
|
-
updateConfig:
|
|
222
|
-
addDevToolbarApp:
|
|
220
|
+
injectScript: C,
|
|
221
|
+
updateConfig: R,
|
|
222
|
+
addDevToolbarApp: k,
|
|
223
223
|
addMiddleware: T,
|
|
224
224
|
config: $
|
|
225
225
|
}) => {
|
|
226
|
-
if (
|
|
226
|
+
if (R({
|
|
227
227
|
vite: {
|
|
228
228
|
plugins: [
|
|
229
229
|
Ce(s, r, o),
|
|
230
|
-
|
|
230
|
+
Se(
|
|
231
231
|
c || {},
|
|
232
232
|
n,
|
|
233
|
-
|
|
234
|
-
|
|
233
|
+
l,
|
|
234
|
+
a
|
|
235
235
|
),
|
|
236
236
|
ve(t)
|
|
237
237
|
]
|
|
238
238
|
}
|
|
239
|
-
}),
|
|
239
|
+
}), g && ($ == null ? void 0 : $.output) !== "server")
|
|
240
240
|
throw new Error(
|
|
241
241
|
"To utilize the Astro Storyblok Live feature, Astro must be configured to run in SSR mode. Please disable this feature or switch Astro to SSR mode."
|
|
242
242
|
);
|
|
243
|
-
|
|
243
|
+
C(
|
|
244
244
|
"page-ssr",
|
|
245
245
|
`
|
|
246
246
|
import { storyblokApiInstance } from "virtual:storyblok-init";
|
|
247
247
|
globalThis.storyblokApiInstance = storyblokApiInstance;
|
|
248
248
|
`
|
|
249
|
-
), u && !
|
|
249
|
+
), u && !g && C(
|
|
250
250
|
"page",
|
|
251
251
|
`import { loadStoryblokBridge } from "@storyblok/astro";
|
|
252
252
|
loadStoryblokBridge().then(() => {
|
|
253
253
|
const { StoryblokBridge, location } = window;
|
|
254
|
-
${
|
|
254
|
+
${d}
|
|
255
255
|
storyblokInstance.on(["published", "change"], (event) => {
|
|
256
256
|
if (!event.slugChanged) {
|
|
257
257
|
location.reload(true);
|
|
@@ -259,19 +259,19 @@ function ft(e) {
|
|
|
259
259
|
});
|
|
260
260
|
});
|
|
261
261
|
`
|
|
262
|
-
),
|
|
262
|
+
), g && (C(
|
|
263
263
|
"page",
|
|
264
264
|
`import { loadStoryblokBridge, handleStoryblokMessage } from "@storyblok/astro";
|
|
265
265
|
loadStoryblokBridge().then(() => {
|
|
266
266
|
const { StoryblokBridge, location } = window;
|
|
267
|
-
${
|
|
267
|
+
${d}
|
|
268
268
|
storyblokInstance.on(["published", "change", "input"], handleStoryblokMessage);
|
|
269
269
|
});
|
|
270
270
|
`
|
|
271
271
|
), T({
|
|
272
272
|
entrypoint: "@storyblok/astro/middleware.ts",
|
|
273
273
|
order: "pre"
|
|
274
|
-
})),
|
|
274
|
+
})), k({
|
|
275
275
|
id: "storyblok",
|
|
276
276
|
name: "Storyblok",
|
|
277
277
|
icon: be,
|
|
@@ -281,19 +281,19 @@ function ft(e) {
|
|
|
281
281
|
}
|
|
282
282
|
};
|
|
283
283
|
}
|
|
284
|
-
let
|
|
284
|
+
let Q;
|
|
285
285
|
async function mt(e) {
|
|
286
286
|
const { action: t, story: s } = e || {};
|
|
287
287
|
if (t === "input" && s) {
|
|
288
288
|
const r = async () => {
|
|
289
|
-
|
|
290
|
-
const n = await He(s),
|
|
291
|
-
if (n.outerHTML ===
|
|
289
|
+
ee("storyblok-live-preview-updating", { story: s });
|
|
290
|
+
const n = await He(s), a = document.body;
|
|
291
|
+
if (n.outerHTML === a.outerHTML)
|
|
292
292
|
return;
|
|
293
|
-
const
|
|
294
|
-
Pe(
|
|
293
|
+
const l = document.querySelector('[data-blok-focused="true"]');
|
|
294
|
+
Pe(a, n, l), ee("storyblok-live-preview-updated", { story: s });
|
|
295
295
|
};
|
|
296
|
-
clearTimeout(
|
|
296
|
+
clearTimeout(Q), Q = setTimeout(r, 500);
|
|
297
297
|
}
|
|
298
298
|
["published", "change"].includes(e == null ? void 0 : e.action) && location.reload();
|
|
299
299
|
}
|
|
@@ -319,11 +319,11 @@ async function He(e) {
|
|
|
319
319
|
})).text();
|
|
320
320
|
return new DOMParser().parseFromString(s, "text/html").body;
|
|
321
321
|
}
|
|
322
|
-
function
|
|
322
|
+
function ee(e, t) {
|
|
323
323
|
document.dispatchEvent(new CustomEvent(e, { detail: t }));
|
|
324
324
|
}
|
|
325
|
-
var Ne = Object.defineProperty, je = (e, t, s) => t in e ? Ne(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s,
|
|
326
|
-
let
|
|
325
|
+
var Ne = Object.defineProperty, je = (e, t, s) => t in e ? Ne(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, y = (e, t, s) => je(e, typeof t != "symbol" ? t + "" : t, s);
|
|
326
|
+
let w = /* @__PURE__ */ function(e) {
|
|
327
327
|
return e.DOCUMENT = "doc", e.HEADING = "heading", e.PARAGRAPH = "paragraph", e.QUOTE = "blockquote", e.OL_LIST = "ordered_list", e.UL_LIST = "bullet_list", e.LIST_ITEM = "list_item", e.CODE_BLOCK = "code_block", e.HR = "horizontal_rule", e.BR = "hard_break", e.IMAGE = "image", e.EMOJI = "emoji", e.COMPONENT = "blok", e.TABLE = "table", e.TABLE_ROW = "tableRow", e.TABLE_CELL = "tableCell", e.TABLE_HEADER = "tableHeader", e;
|
|
328
328
|
}({}), A = /* @__PURE__ */ function(e) {
|
|
329
329
|
return e.BOLD = "bold", e.STRONG = "strong", e.STRIKE = "strike", e.UNDERLINE = "underline", e.ITALIC = "italic", e.CODE = "code", e.LINK = "link", e.ANCHOR = "anchor", e.STYLED = "styled", e.SUPERSCRIPT = "superscript", e.SUBSCRIPT = "subscript", e.TEXT_STYLE = "textStyle", e.HIGHLIGHT = "highlight", e;
|
|
@@ -357,7 +357,7 @@ const Ue = [
|
|
|
357
357
|
function Fe(e) {
|
|
358
358
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
359
359
|
}
|
|
360
|
-
const
|
|
360
|
+
const S = (e) => Object.fromEntries(Object.entries(e).filter(([t, s]) => s !== void 0));
|
|
361
361
|
function qe(e, t) {
|
|
362
362
|
if (!t) return {
|
|
363
363
|
src: e,
|
|
@@ -365,41 +365,41 @@ function qe(e, t) {
|
|
|
365
365
|
};
|
|
366
366
|
let s = 0, r = 0;
|
|
367
367
|
const o = {}, n = [];
|
|
368
|
-
function
|
|
369
|
-
typeof c != "number" || c <= u || c >=
|
|
368
|
+
function a(c, u, g, d, C) {
|
|
369
|
+
typeof c != "number" || c <= u || c >= g ? console.warn(`[StoryblokRichText] - ${d.charAt(0).toUpperCase() + d.slice(1)} value must be a number between ${u} and ${g} (inclusive)`) : C.push(`${d}(${c})`);
|
|
370
370
|
}
|
|
371
371
|
if (typeof t == "object") {
|
|
372
372
|
if (t.width !== void 0 && (typeof t.width == "number" && t.width >= 0 ? (o.width = t.width, s = t.width) : console.warn("[StoryblokRichText] - Width value must be a number greater than or equal to 0")), t.height !== void 0 && (typeof t.height == "number" && t.height >= 0 ? (o.height = t.height, r = t.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than or equal to 0")), t.height === 0 && t.width === 0 && (delete o.width, delete o.height, console.warn("[StoryblokRichText] - Width and height values cannot both be 0")), t.loading && ["lazy", "eager"].includes(t.loading) && (o.loading = t.loading), t.class && (o.class = t.class), t.filters) {
|
|
373
|
-
const { filters: c } = t || {}, { blur: u, brightness:
|
|
374
|
-
u &&
|
|
373
|
+
const { filters: c } = t || {}, { blur: u, brightness: g, fill: d, format: C, grayscale: R, quality: k, rotate: T } = c || {};
|
|
374
|
+
u && a(u, 0, 100, "blur", n), k && a(k, 0, 100, "quality", n), g && a(g, 0, 100, "brightness", n), d && n.push(`fill(${d})`), R && n.push("grayscale()"), T && [
|
|
375
375
|
0,
|
|
376
376
|
90,
|
|
377
377
|
180,
|
|
378
378
|
270
|
|
379
|
-
].includes(t.filters.rotate || 0) && n.push(`rotate(${T})`),
|
|
379
|
+
].includes(t.filters.rotate || 0) && n.push(`rotate(${T})`), C && [
|
|
380
380
|
"webp",
|
|
381
381
|
"png",
|
|
382
382
|
"jpeg"
|
|
383
|
-
].includes(
|
|
383
|
+
].includes(C) && n.push(`format(${C})`);
|
|
384
384
|
}
|
|
385
385
|
t.srcset && (o.srcset = t.srcset.map((c) => {
|
|
386
386
|
if (typeof c == "number") return `${e}/m/${c}x0/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${c}w`;
|
|
387
387
|
if (Array.isArray(c) && c.length === 2) {
|
|
388
|
-
const [u,
|
|
389
|
-
return `${e}/m/${u}x${
|
|
388
|
+
const [u, g] = c;
|
|
389
|
+
return `${e}/m/${u}x${g}/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${u}w`;
|
|
390
390
|
} else {
|
|
391
391
|
console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
|
|
392
392
|
return;
|
|
393
393
|
}
|
|
394
394
|
}).join(", ")), t.sizes && (o.sizes = t.sizes.join(", "));
|
|
395
395
|
}
|
|
396
|
-
let
|
|
397
|
-
return (s > 0 || r > 0) && (
|
|
398
|
-
src:
|
|
396
|
+
let l = `${e}/m/`;
|
|
397
|
+
return (s > 0 || r > 0) && (l = `${l}${s}x${r}/`), n.length > 0 && (l = `${l}filters:${n.join(":")}`), {
|
|
398
|
+
src: l,
|
|
399
399
|
attrs: o
|
|
400
400
|
};
|
|
401
401
|
}
|
|
402
|
-
function
|
|
402
|
+
function te(e, t = {}, s) {
|
|
403
403
|
const r = Ve(t), o = r ? `${e} ${r}` : e, n = Array.isArray(s) ? s.join("") : s || "";
|
|
404
404
|
if (e) {
|
|
405
405
|
if (Ue.includes(e)) return `<${o}>`;
|
|
@@ -407,189 +407,189 @@ function ee(e, t = {}, s) {
|
|
|
407
407
|
return `<${o}>${n}</${e}>`;
|
|
408
408
|
}
|
|
409
409
|
function Ge(e = {}) {
|
|
410
|
-
const t = /* @__PURE__ */ new Map(), { renderFn: s =
|
|
411
|
-
const { textAlign: h, class:
|
|
412
|
-
return
|
|
413
|
-
...
|
|
414
|
-
class:
|
|
415
|
-
id:
|
|
410
|
+
const t = /* @__PURE__ */ new Map(), { renderFn: s = te, textFn: r = Fe, resolvers: o = {}, optimizeImages: n = !1, keyedResolvers: a = !1 } = e, l = s !== te, c = (i = {}) => {
|
|
411
|
+
const { textAlign: h, class: p, id: f, style: m, ...v } = i, b = [];
|
|
412
|
+
return m && b.push(m.endsWith(";") ? m : `${m};`), h && b.push(`text-align: ${h};`), S({
|
|
413
|
+
...v,
|
|
414
|
+
class: p,
|
|
415
|
+
id: f,
|
|
416
416
|
...b.length > 0 ? { style: b.join(" ") } : {}
|
|
417
417
|
});
|
|
418
|
-
}, u = (
|
|
419
|
-
const
|
|
420
|
-
return
|
|
421
|
-
},
|
|
422
|
-
const { src:
|
|
423
|
-
let E =
|
|
418
|
+
}, u = (i) => (h, p) => {
|
|
419
|
+
const f = c(h.attrs);
|
|
420
|
+
return p.render(i, f, h.children || null);
|
|
421
|
+
}, g = (i, h) => {
|
|
422
|
+
const { src: p, alt: f, title: m, srcset: v, sizes: b } = i.attrs || {};
|
|
423
|
+
let E = p, L = {};
|
|
424
424
|
if (n) {
|
|
425
|
-
const { src: ye, attrs: ge } = qe(
|
|
426
|
-
E = ye,
|
|
425
|
+
const { src: ye, attrs: ge } = qe(p, n);
|
|
426
|
+
E = ye, L = ge;
|
|
427
427
|
}
|
|
428
|
-
const
|
|
428
|
+
const I = {
|
|
429
429
|
src: E,
|
|
430
|
-
alt:
|
|
431
|
-
title:
|
|
432
|
-
srcset:
|
|
430
|
+
alt: f,
|
|
431
|
+
title: m,
|
|
432
|
+
srcset: v,
|
|
433
433
|
sizes: b,
|
|
434
|
-
...
|
|
434
|
+
...L
|
|
435
435
|
};
|
|
436
|
-
return h.render("img", I
|
|
437
|
-
},
|
|
438
|
-
const { level:
|
|
439
|
-
return h.render(`h${
|
|
440
|
-
},
|
|
441
|
-
var f, m,
|
|
436
|
+
return h.render("img", S(I));
|
|
437
|
+
}, d = (i, h) => {
|
|
438
|
+
const { level: p, ...f } = i.attrs || {}, m = c(f);
|
|
439
|
+
return h.render(`h${p}`, m, i.children);
|
|
440
|
+
}, C = (i, h) => {
|
|
441
|
+
var p, f, m, v;
|
|
442
442
|
const b = h.render("img", {
|
|
443
|
-
src: (
|
|
444
|
-
alt: (
|
|
443
|
+
src: (p = i.attrs) == null ? void 0 : p.fallbackImage,
|
|
444
|
+
alt: (f = i.attrs) == null ? void 0 : f.alt,
|
|
445
445
|
style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
|
|
446
446
|
draggable: "false",
|
|
447
447
|
loading: "lazy"
|
|
448
448
|
});
|
|
449
449
|
return h.render("span", {
|
|
450
450
|
"data-type": "emoji",
|
|
451
|
-
"data-name": (
|
|
452
|
-
"data-emoji": (
|
|
451
|
+
"data-name": (m = i.attrs) == null ? void 0 : m.name,
|
|
452
|
+
"data-emoji": (v = i.attrs) == null ? void 0 : v.emoji
|
|
453
453
|
}, b);
|
|
454
|
-
},
|
|
455
|
-
const { class:
|
|
456
|
-
class:
|
|
454
|
+
}, R = (i, h) => h.render("pre", i.attrs || {}, h.render("code", {}, i.children || "")), k = (i, h = !1) => ({ text: p, attrs: f }, m) => {
|
|
455
|
+
const { class: v, id: b, ...E } = f || {}, L = h ? {
|
|
456
|
+
class: v,
|
|
457
457
|
id: b,
|
|
458
458
|
style: Be(E) || void 0
|
|
459
|
-
} :
|
|
460
|
-
return
|
|
461
|
-
}, T = (
|
|
462
|
-
const { marks: h, ...
|
|
463
|
-
if ("text" in
|
|
464
|
-
if (h) return h.reduce((
|
|
465
|
-
...
|
|
466
|
-
text:
|
|
459
|
+
} : f || {};
|
|
460
|
+
return m.render(i, S(L), p);
|
|
461
|
+
}, T = (i) => j(i), $ = (i) => {
|
|
462
|
+
const { marks: h, ...p } = i;
|
|
463
|
+
if ("text" in i) {
|
|
464
|
+
if (h) return h.reduce((m, v) => T({
|
|
465
|
+
...v,
|
|
466
|
+
text: m
|
|
467
467
|
}), T({
|
|
468
|
-
...
|
|
469
|
-
children:
|
|
468
|
+
...p,
|
|
469
|
+
children: p.children
|
|
470
470
|
}));
|
|
471
|
-
const
|
|
472
|
-
if (
|
|
473
|
-
const
|
|
474
|
-
t.set("txt",
|
|
471
|
+
const f = i.attrs || {};
|
|
472
|
+
if (a) {
|
|
473
|
+
const m = t.get("txt") || 0;
|
|
474
|
+
t.set("txt", m + 1), f.key = `txt-${m}`;
|
|
475
475
|
}
|
|
476
|
-
return r(
|
|
476
|
+
return r(p.text, f);
|
|
477
477
|
}
|
|
478
478
|
return "";
|
|
479
|
-
},
|
|
480
|
-
const { linktype:
|
|
479
|
+
}, Z = (i, h) => {
|
|
480
|
+
const { linktype: p, href: f, anchor: m, ...v } = i.attrs || {};
|
|
481
481
|
let b = "";
|
|
482
|
-
switch (
|
|
482
|
+
switch (p) {
|
|
483
483
|
case M.ASSET:
|
|
484
484
|
case M.URL:
|
|
485
|
-
b =
|
|
485
|
+
b = f;
|
|
486
486
|
break;
|
|
487
487
|
case M.EMAIL:
|
|
488
|
-
b = `mailto:${
|
|
488
|
+
b = `mailto:${f}`;
|
|
489
489
|
break;
|
|
490
490
|
case M.STORY:
|
|
491
|
-
b =
|
|
491
|
+
b = f, m && (b = `${b}#${m}`);
|
|
492
492
|
break;
|
|
493
493
|
default:
|
|
494
|
-
b =
|
|
494
|
+
b = f;
|
|
495
495
|
break;
|
|
496
496
|
}
|
|
497
|
-
const E = { ...
|
|
498
|
-
return b && (E.href = b), h.render("a", E,
|
|
499
|
-
}, ue = (
|
|
500
|
-
var
|
|
497
|
+
const E = { ...v };
|
|
498
|
+
return b && (E.href = b), h.render("a", E, i.text);
|
|
499
|
+
}, ue = (i, h) => {
|
|
500
|
+
var p, f;
|
|
501
501
|
return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), h.render("span", {
|
|
502
|
-
blok: (
|
|
503
|
-
id: (
|
|
502
|
+
blok: (p = i == null ? void 0 : i.attrs) == null ? void 0 : p.body[0],
|
|
503
|
+
id: (f = i.attrs) == null ? void 0 : f.id,
|
|
504
504
|
style: "display: none"
|
|
505
505
|
});
|
|
506
|
-
}, he = (
|
|
507
|
-
const
|
|
508
|
-
return h.render("table",
|
|
509
|
-
}, de = (
|
|
510
|
-
const
|
|
511
|
-
return h.render("tr",
|
|
512
|
-
}, pe = (
|
|
513
|
-
const { colspan:
|
|
514
|
-
|
|
515
|
-
const
|
|
506
|
+
}, he = (i, h) => {
|
|
507
|
+
const p = c(i.attrs), f = i.children || null;
|
|
508
|
+
return h.render("table", p, h.render("tbody", {}, f));
|
|
509
|
+
}, de = (i, h) => {
|
|
510
|
+
const p = c(i.attrs);
|
|
511
|
+
return h.render("tr", p, i.children);
|
|
512
|
+
}, pe = (i, h) => {
|
|
513
|
+
const { colspan: p, rowspan: f, colwidth: m, backgroundColor: v, textAlign: b, ...E } = i.attrs || {}, L = [];
|
|
514
|
+
m && L.push(`width: ${m}px;`), v && L.push(`background-color: ${v};`), b && L.push(`text-align: ${b};`);
|
|
515
|
+
const I = {
|
|
516
516
|
...E,
|
|
517
|
-
...
|
|
518
|
-
...
|
|
519
|
-
...
|
|
517
|
+
...p > 1 ? { colspan: p } : {},
|
|
518
|
+
...f > 1 ? { rowspan: f } : {},
|
|
519
|
+
...L.length > 0 ? { style: L.join(" ") } : {}
|
|
520
520
|
};
|
|
521
|
-
return h.render("td", I
|
|
522
|
-
}, fe = (
|
|
523
|
-
const { colspan:
|
|
524
|
-
|
|
525
|
-
const
|
|
521
|
+
return h.render("td", S(I), i.children);
|
|
522
|
+
}, fe = (i, h) => {
|
|
523
|
+
const { colspan: p, rowspan: f, colwidth: m, backgroundColor: v, textAlign: b, ...E } = i.attrs || {}, L = [];
|
|
524
|
+
m && L.push(`width: ${m}px;`), v && L.push(`background-color: ${v};`), b && L.push(`text-align: ${b};`);
|
|
525
|
+
const I = {
|
|
526
526
|
...E,
|
|
527
|
-
...
|
|
528
|
-
...
|
|
529
|
-
...
|
|
527
|
+
...p > 1 ? { colspan: p } : {},
|
|
528
|
+
...f > 1 ? { rowspan: f } : {},
|
|
529
|
+
...L.length > 0 ? { style: L.join(" ") } : {}
|
|
530
530
|
};
|
|
531
|
-
return h.render("th", I
|
|
532
|
-
},
|
|
533
|
-
[
|
|
534
|
-
[
|
|
535
|
-
[
|
|
536
|
-
[
|
|
537
|
-
[
|
|
538
|
-
[
|
|
539
|
-
[
|
|
540
|
-
[
|
|
541
|
-
[
|
|
542
|
-
[
|
|
543
|
-
[
|
|
544
|
-
[
|
|
545
|
-
[
|
|
531
|
+
return h.render("th", S(I), i.children);
|
|
532
|
+
}, J = /* @__PURE__ */ new Map([
|
|
533
|
+
[w.DOCUMENT, u("")],
|
|
534
|
+
[w.HEADING, d],
|
|
535
|
+
[w.PARAGRAPH, u("p")],
|
|
536
|
+
[w.UL_LIST, u("ul")],
|
|
537
|
+
[w.OL_LIST, u("ol")],
|
|
538
|
+
[w.LIST_ITEM, u("li")],
|
|
539
|
+
[w.IMAGE, g],
|
|
540
|
+
[w.EMOJI, C],
|
|
541
|
+
[w.CODE_BLOCK, R],
|
|
542
|
+
[w.HR, u("hr")],
|
|
543
|
+
[w.BR, u("br")],
|
|
544
|
+
[w.QUOTE, u("blockquote")],
|
|
545
|
+
[w.COMPONENT, ue],
|
|
546
546
|
[De.TEXT, $],
|
|
547
|
-
[A.LINK,
|
|
548
|
-
[A.ANCHOR,
|
|
549
|
-
[A.STYLED,
|
|
550
|
-
[A.BOLD,
|
|
551
|
-
[A.TEXT_STYLE,
|
|
552
|
-
[A.ITALIC,
|
|
553
|
-
[A.UNDERLINE,
|
|
554
|
-
[A.STRIKE,
|
|
555
|
-
[A.CODE,
|
|
556
|
-
[A.SUPERSCRIPT,
|
|
557
|
-
[A.SUBSCRIPT,
|
|
558
|
-
[A.HIGHLIGHT,
|
|
559
|
-
[
|
|
560
|
-
[
|
|
561
|
-
[
|
|
562
|
-
[
|
|
563
|
-
]),
|
|
564
|
-
render: (
|
|
565
|
-
if (
|
|
566
|
-
const
|
|
567
|
-
t.set(
|
|
547
|
+
[A.LINK, Z],
|
|
548
|
+
[A.ANCHOR, Z],
|
|
549
|
+
[A.STYLED, k("span", !0)],
|
|
550
|
+
[A.BOLD, k("strong")],
|
|
551
|
+
[A.TEXT_STYLE, k("span", !0)],
|
|
552
|
+
[A.ITALIC, k("em")],
|
|
553
|
+
[A.UNDERLINE, k("u")],
|
|
554
|
+
[A.STRIKE, k("s")],
|
|
555
|
+
[A.CODE, k("code")],
|
|
556
|
+
[A.SUPERSCRIPT, k("sup")],
|
|
557
|
+
[A.SUBSCRIPT, k("sub")],
|
|
558
|
+
[A.HIGHLIGHT, k("mark")],
|
|
559
|
+
[w.TABLE, he],
|
|
560
|
+
[w.TABLE_ROW, de],
|
|
561
|
+
[w.TABLE_CELL, pe],
|
|
562
|
+
[w.TABLE_HEADER, fe]
|
|
563
|
+
]), W = new Map([...J, ...Object.entries(o).map(([i, h]) => [i, h])]), me = () => ({
|
|
564
|
+
render: (i, h = {}, p) => {
|
|
565
|
+
if (a && i) {
|
|
566
|
+
const f = t.get(i) || 0;
|
|
567
|
+
t.set(i, f + 1), h.key = `${i}-${f}`;
|
|
568
568
|
}
|
|
569
|
-
return s(
|
|
569
|
+
return s(i, h, p);
|
|
570
570
|
},
|
|
571
|
-
originalResolvers:
|
|
572
|
-
mergedResolvers:
|
|
571
|
+
originalResolvers: J,
|
|
572
|
+
mergedResolvers: W
|
|
573
573
|
});
|
|
574
|
-
function x(
|
|
575
|
-
const h =
|
|
574
|
+
function x(i) {
|
|
575
|
+
const h = W.get(i.type);
|
|
576
576
|
if (!h)
|
|
577
|
-
return console.error("<Storyblok>", `No resolver found for node type ${
|
|
578
|
-
const
|
|
579
|
-
if (
|
|
580
|
-
const
|
|
577
|
+
return console.error("<Storyblok>", `No resolver found for node type ${i.type}`), "";
|
|
578
|
+
const p = me();
|
|
579
|
+
if (i.type === "text") return h(i, p);
|
|
580
|
+
const f = i.content ? i.content.map(j) : void 0;
|
|
581
581
|
return h({
|
|
582
|
-
...
|
|
583
|
-
children:
|
|
584
|
-
},
|
|
582
|
+
...i,
|
|
583
|
+
children: f
|
|
584
|
+
}, p);
|
|
585
585
|
}
|
|
586
|
-
function
|
|
587
|
-
return
|
|
586
|
+
function j(i) {
|
|
587
|
+
return i.type === "doc" ? l ? i.content.map(x) : i.content.map(x).join("") : Array.isArray(i) ? i.map(x) : x(i);
|
|
588
588
|
}
|
|
589
|
-
return { render:
|
|
589
|
+
return { render: j };
|
|
590
590
|
}
|
|
591
|
-
let
|
|
592
|
-
const
|
|
591
|
+
let se = !1;
|
|
592
|
+
const re = [], le = (e) => new Promise((t, s) => {
|
|
593
593
|
if (typeof window > "u") {
|
|
594
594
|
s(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));
|
|
595
595
|
return;
|
|
@@ -599,31 +599,31 @@ const se = [], le = (e) => new Promise((t, s) => {
|
|
|
599
599
|
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
600
600
|
return;
|
|
601
601
|
}
|
|
602
|
-
|
|
602
|
+
se ? o() : re.push(o);
|
|
603
603
|
}, document.getElementById("storyblok-javascript-bridge")) {
|
|
604
604
|
t(void 0);
|
|
605
605
|
return;
|
|
606
606
|
}
|
|
607
607
|
const r = document.createElement("script");
|
|
608
608
|
r.async = !0, r.src = e, r.id = "storyblok-javascript-bridge", r.onerror = (o) => s(o), r.onload = (o) => {
|
|
609
|
-
|
|
609
|
+
re.forEach((n) => n()), se = !0, t(o);
|
|
610
610
|
}, document.getElementsByTagName("head")[0].appendChild(r);
|
|
611
|
-
}),
|
|
611
|
+
}), D = (e = "") => e.includes("/cdn/"), ze = (e, t = 25, s = 1) => ({
|
|
612
612
|
...e,
|
|
613
613
|
per_page: t,
|
|
614
614
|
page: s
|
|
615
615
|
}), Ze = (e) => new Promise((t) => setTimeout(t, e)), Je = (e = 0, t) => Array.from({ length: e }, t), We = (e = 0, t = e) => {
|
|
616
616
|
const s = Math.abs(t - e) || 0, r = e < t ? 1 : -1;
|
|
617
617
|
return Je(s, (o, n) => n * r + e);
|
|
618
|
-
}, Ye = async (e, t) => Promise.all(e.map(t)), Ke = (e = [], t) => e.map(t).reduce((s, r) => [...s, ...r], []),
|
|
618
|
+
}, Ye = async (e, t) => Promise.all(e.map(t)), Ke = (e = [], t) => e.map(t).reduce((s, r) => [...s, ...r], []), z = (e, t, s) => {
|
|
619
619
|
const r = [];
|
|
620
620
|
for (const o in e) {
|
|
621
621
|
if (!Object.prototype.hasOwnProperty.call(e, o)) continue;
|
|
622
622
|
const n = e[o];
|
|
623
623
|
if (n == null) continue;
|
|
624
|
-
const
|
|
625
|
-
let
|
|
626
|
-
typeof n == "object" ?
|
|
624
|
+
const a = s ? "" : encodeURIComponent(o);
|
|
625
|
+
let l;
|
|
626
|
+
typeof n == "object" ? l = z(n, t ? t + encodeURIComponent(`[${a}]`) : a, Array.isArray(n)) : l = `${t ? t + encodeURIComponent(`[${a}]`) : a}=${encodeURIComponent(n)}`, r.push(l);
|
|
627
627
|
}
|
|
628
628
|
return r.join("&");
|
|
629
629
|
}, oe = (e) => {
|
|
@@ -638,7 +638,7 @@ const se = [], le = (e) => new Promise((t, s) => {
|
|
|
638
638
|
};
|
|
639
639
|
var Xe = class {
|
|
640
640
|
constructor(e) {
|
|
641
|
-
|
|
641
|
+
y(this, "baseURL"), y(this, "timeout"), y(this, "headers"), y(this, "responseInterceptor"), y(this, "fetch"), y(this, "ejectInterceptor"), y(this, "url"), y(this, "parameters"), y(this, "fetchOptions"), this.baseURL = e.baseURL, this.headers = e.headers || new Headers(), this.timeout = e != null && e.timeout ? e.timeout * 1e3 : 0, this.responseInterceptor = e.responseInterceptor, this.fetch = (...t) => e.fetch ? e.fetch(...t) : fetch(...t), this.ejectInterceptor = !1, this.url = "", this.parameters = {}, this.fetchOptions = {};
|
|
642
642
|
}
|
|
643
643
|
/**
|
|
644
644
|
*
|
|
@@ -673,23 +673,23 @@ var Xe = class {
|
|
|
673
673
|
}
|
|
674
674
|
async _methodHandler(e) {
|
|
675
675
|
let t = `${this.baseURL}${this.url}`, s = null;
|
|
676
|
-
e === "get" ? t = `${this.baseURL}${this.url}?${
|
|
676
|
+
e === "get" ? t = `${this.baseURL}${this.url}?${z(this.parameters)}` : s = JSON.stringify(this.parameters);
|
|
677
677
|
const r = new URL(t), o = new AbortController(), { signal: n } = o;
|
|
678
|
-
let
|
|
679
|
-
this.timeout && (
|
|
678
|
+
let a = null;
|
|
679
|
+
this.timeout && (a = setTimeout(() => o.abort(), this.timeout));
|
|
680
680
|
try {
|
|
681
|
-
const
|
|
681
|
+
const l = await this.fetch(`${r}`, {
|
|
682
682
|
method: e,
|
|
683
683
|
headers: this.headers,
|
|
684
684
|
body: s,
|
|
685
685
|
signal: n,
|
|
686
686
|
...this.fetchOptions
|
|
687
687
|
});
|
|
688
|
-
this.timeout &&
|
|
689
|
-
const c = await this._responseHandler(
|
|
688
|
+
this.timeout && a && clearTimeout(a);
|
|
689
|
+
const c = await this._responseHandler(l);
|
|
690
690
|
return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(c)) : this._statusHandler(c);
|
|
691
|
-
} catch (
|
|
692
|
-
return { message:
|
|
691
|
+
} catch (l) {
|
|
692
|
+
return { message: l };
|
|
693
693
|
}
|
|
694
694
|
}
|
|
695
695
|
setFetchOptions(e = {}) {
|
|
@@ -728,14 +728,14 @@ var Xe = class {
|
|
|
728
728
|
});
|
|
729
729
|
}
|
|
730
730
|
}, Qe = Xe;
|
|
731
|
-
const ne = "SB-Agent",
|
|
731
|
+
const ne = "SB-Agent", U = {
|
|
732
732
|
defaultAgentName: "SB-JS-CLIENT",
|
|
733
733
|
defaultAgentVersion: "SB-Agent-Version",
|
|
734
734
|
packageVersion: "7.0.0"
|
|
735
735
|
}, ce = {
|
|
736
736
|
DRAFT: "draft",
|
|
737
737
|
PUBLISHED: "published"
|
|
738
|
-
}, et = 25,
|
|
738
|
+
}, et = 25, V = {
|
|
739
739
|
SMALL: 25,
|
|
740
740
|
MEDIUM: 50,
|
|
741
741
|
LARGE: 75
|
|
@@ -744,7 +744,7 @@ const ne = "SB-Agent", j = {
|
|
|
744
744
|
MEDIUM: 15,
|
|
745
745
|
LARGE: 10,
|
|
746
746
|
VERY_LARGE: 6
|
|
747
|
-
},
|
|
747
|
+
}, B = 1e3, P = 3;
|
|
748
748
|
function tt(e) {
|
|
749
749
|
return e.version === ce.DRAFT;
|
|
750
750
|
}
|
|
@@ -753,13 +753,13 @@ function st(e, t) {
|
|
|
753
753
|
return s && r || o;
|
|
754
754
|
}
|
|
755
755
|
function rt(e) {
|
|
756
|
-
return e <=
|
|
756
|
+
return e <= V.SMALL ? O.SINGLE_OR_SMALL : e <= V.MEDIUM ? O.MEDIUM : e <= V.LARGE ? O.LARGE : O.VERY_LARGE;
|
|
757
757
|
}
|
|
758
|
-
function
|
|
759
|
-
if (s.userRateLimit !== void 0) return Math.min(s.userRateLimit,
|
|
760
|
-
if (s.serverHeadersRateLimit !== void 0) return Math.min(s.serverHeadersRateLimit,
|
|
761
|
-
if (t && !tt(t)) return U;
|
|
758
|
+
function H(e, t, s = {}, r) {
|
|
759
|
+
if (s.userRateLimit !== void 0) return Math.min(s.userRateLimit, B);
|
|
760
|
+
if (s.serverHeadersRateLimit !== void 0) return Math.min(s.serverHeadersRateLimit, B);
|
|
762
761
|
if (r !== void 0) return r;
|
|
762
|
+
if (t && !tt(t)) return B;
|
|
763
763
|
if (st(e, t)) return O.SINGLE_OR_SMALL;
|
|
764
764
|
const o = t.per_page || et;
|
|
765
765
|
return rt(o);
|
|
@@ -795,34 +795,34 @@ function at(e, t, s) {
|
|
|
795
795
|
if (!Number.isFinite(t)) throw new TypeError("Expected `limit` to be a finite number");
|
|
796
796
|
if (!Number.isFinite(s)) throw new TypeError("Expected `interval` to be a finite number");
|
|
797
797
|
const r = [];
|
|
798
|
-
let o = [], n = 0,
|
|
799
|
-
const
|
|
798
|
+
let o = [], n = 0, a = !1;
|
|
799
|
+
const l = async () => {
|
|
800
800
|
n++;
|
|
801
801
|
const u = r.shift();
|
|
802
802
|
if (u) try {
|
|
803
|
-
const
|
|
804
|
-
u.resolve(
|
|
805
|
-
} catch (
|
|
806
|
-
u.reject(
|
|
803
|
+
const d = await e(...u.args);
|
|
804
|
+
u.resolve(d);
|
|
805
|
+
} catch (d) {
|
|
806
|
+
u.reject(d);
|
|
807
807
|
}
|
|
808
|
-
const
|
|
809
|
-
n--, r.length > 0 &&
|
|
808
|
+
const g = setTimeout(() => {
|
|
809
|
+
n--, r.length > 0 && l(), o = o.filter((d) => d !== g);
|
|
810
810
|
}, s);
|
|
811
|
-
o.includes(
|
|
812
|
-
}, c = (...u) =>
|
|
811
|
+
o.includes(g) || o.push(g);
|
|
812
|
+
}, c = (...u) => a ? Promise.reject(/* @__PURE__ */ new Error("Throttled function is already aborted and not accepting new promises")) : new Promise((g, d) => {
|
|
813
813
|
r.push({
|
|
814
|
-
resolve:
|
|
815
|
-
reject:
|
|
814
|
+
resolve: g,
|
|
815
|
+
reject: d,
|
|
816
816
|
args: u
|
|
817
|
-
}), n < t &&
|
|
817
|
+
}), n < t && l();
|
|
818
818
|
});
|
|
819
819
|
return c.abort = () => {
|
|
820
|
-
|
|
820
|
+
a = !0, o.forEach(clearTimeout), o = [], r.forEach((u) => u.reject(() => new it("Throttle function aborted"))), r.length = 0;
|
|
821
821
|
}, c;
|
|
822
822
|
}
|
|
823
823
|
var lt = at, ct = class {
|
|
824
824
|
constructor(e, t = 1e3) {
|
|
825
|
-
|
|
825
|
+
y(this, "queues"), y(this, "interval"), y(this, "throttledRequestFn"), this.queues = /* @__PURE__ */ new Map(), this.interval = t, this.throttledRequestFn = e;
|
|
826
826
|
}
|
|
827
827
|
/**
|
|
828
828
|
* Gets or creates a throttle queue for the specified rate limit
|
|
@@ -853,8 +853,8 @@ var lt = at, ct = class {
|
|
|
853
853
|
return this.queues.size;
|
|
854
854
|
}
|
|
855
855
|
};
|
|
856
|
-
let
|
|
857
|
-
const
|
|
856
|
+
let N = {};
|
|
857
|
+
const _ = {};
|
|
858
858
|
var ut = class {
|
|
859
859
|
/**
|
|
860
860
|
*
|
|
@@ -862,7 +862,7 @@ var ut = class {
|
|
|
862
862
|
* @param pEndpoint string, optional
|
|
863
863
|
*/
|
|
864
864
|
constructor(e, t) {
|
|
865
|
-
|
|
865
|
+
y(this, "client"), y(this, "maxRetries"), y(this, "retriesDelay"), y(this, "throttleManager"), y(this, "accessToken"), y(this, "cache"), y(this, "resolveCounter"), y(this, "relations"), y(this, "links"), y(this, "version"), y(this, "rateLimitConfig"), y(this, "richTextResolver"), y(this, "resolveNestedRelations"), y(this, "stringifiedStoriesCache"), y(this, "inlineAssets");
|
|
866
866
|
let s = e.endpoint || t;
|
|
867
867
|
if (!s) {
|
|
868
868
|
const o = e.https === !1 ? "http" : "https";
|
|
@@ -871,7 +871,7 @@ var ut = class {
|
|
|
871
871
|
const r = new Headers();
|
|
872
872
|
r.set("Content-Type", "application/json"), r.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([o, n]) => {
|
|
873
873
|
r.set(o, n);
|
|
874
|
-
}), r.has(ne) || (r.set(ne,
|
|
874
|
+
}), r.has(ne) || (r.set(ne, U.defaultAgentName), r.set(U.defaultAgentVersion, U.packageVersion)), e.oauthToken && r.set("Authorization", e.oauthToken), this.rateLimitConfig = nt(e.rateLimit, !!e.oauthToken), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttleManager = new ct(this.throttledRequest.bind(this), 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.version = e.version || ce.PUBLISHED, this.inlineAssets = e.inlineAssets || !1, this.client = new Qe({
|
|
875
875
|
baseURL: s,
|
|
876
876
|
timeout: e.timeout || 0,
|
|
877
877
|
headers: r,
|
|
@@ -880,10 +880,10 @@ var ut = class {
|
|
|
880
880
|
});
|
|
881
881
|
}
|
|
882
882
|
parseParams(e) {
|
|
883
|
-
return e.token || (e.token = this.getToken()), e.cv || (e.cv =
|
|
883
|
+
return e.token || (e.token = this.getToken()), e.cv || (e.cv = _[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), typeof e.resolve_relations < "u" && (e.resolve_level = 2), e;
|
|
884
884
|
}
|
|
885
885
|
factoryParamOptions(e, t) {
|
|
886
|
-
return
|
|
886
|
+
return D(e) ? this.parseParams(t) : t;
|
|
887
887
|
}
|
|
888
888
|
makeRequest(e, t, s, r, o) {
|
|
889
889
|
const n = this.factoryParamOptions(e, ze(t, s, r));
|
|
@@ -892,27 +892,27 @@ var ut = class {
|
|
|
892
892
|
get(e, t = {}, s) {
|
|
893
893
|
t || (t = {});
|
|
894
894
|
const r = `/${e}`;
|
|
895
|
-
|
|
895
|
+
D(r) && (t.version = t.version || this.version);
|
|
896
896
|
const o = this.factoryParamOptions(r, t);
|
|
897
897
|
return this.cacheResponse(r, o, void 0, s);
|
|
898
898
|
}
|
|
899
899
|
async getAll(e, t = {}, s, r) {
|
|
900
|
-
const o = (t == null ? void 0 : t.per_page) || 25, n = `/${e}`.replace(/\/$/, ""),
|
|
900
|
+
const o = (t == null ? void 0 : t.per_page) || 25, n = `/${e}`.replace(/\/$/, ""), a = s ?? n.substring(n.lastIndexOf("/") + 1);
|
|
901
901
|
t.version = t.version || this.version;
|
|
902
|
-
const
|
|
903
|
-
return Ke([c, ...
|
|
902
|
+
const l = 1, c = await this.makeRequest(n, t, o, l, r), u = c.total ? Math.ceil(c.total / (c.perPage || o)) : 1, g = await Ye(We(l, u), (d) => this.makeRequest(n, t, o, d + 1, r));
|
|
903
|
+
return Ke([c, ...g], (d) => Object.values(d.data[a]));
|
|
904
904
|
}
|
|
905
905
|
post(e, t = {}, s) {
|
|
906
|
-
const r = `/${e}`, o =
|
|
906
|
+
const r = `/${e}`, o = H(void 0, void 0, this.rateLimitConfig, P);
|
|
907
907
|
return this.throttleManager.execute(o, "post", r, t, s);
|
|
908
908
|
}
|
|
909
909
|
put(e, t = {}, s) {
|
|
910
|
-
const r = `/${e}`, o =
|
|
910
|
+
const r = `/${e}`, o = H(void 0, void 0, this.rateLimitConfig, P);
|
|
911
911
|
return this.throttleManager.execute(o, "put", r, t, s);
|
|
912
912
|
}
|
|
913
913
|
delete(e, t = {}, s) {
|
|
914
914
|
t || (t = {});
|
|
915
|
-
const r = `/${e}`, o =
|
|
915
|
+
const r = `/${e}`, o = H(void 0, void 0, this.rateLimitConfig, P);
|
|
916
916
|
return this.throttleManager.execute(o, "delete", r, t, s);
|
|
917
917
|
}
|
|
918
918
|
getStories(e = {}, t) {
|
|
@@ -994,10 +994,10 @@ var ut = class {
|
|
|
994
994
|
iterateTree(e, t, s) {
|
|
995
995
|
const r = (o, n = "") => {
|
|
996
996
|
if (!(!o || o._stopResolving)) {
|
|
997
|
-
if (Array.isArray(o)) o.forEach((
|
|
998
|
-
else if (typeof o == "object") for (const
|
|
999
|
-
const
|
|
1000
|
-
(o.component && o._uid || o.type === "link") && (this._insertRelations(o,
|
|
997
|
+
if (Array.isArray(o)) o.forEach((a, l) => r(a, `${n}[${l}]`));
|
|
998
|
+
else if (typeof o == "object") for (const a in o) {
|
|
999
|
+
const l = n ? `${n}.${a}` : a;
|
|
1000
|
+
(o.component && o._uid || o.type === "link") && (this._insertRelations(o, a, t, s), this._insertLinks(o, a, s)), r(o[a], l);
|
|
1001
1001
|
}
|
|
1002
1002
|
}
|
|
1003
1003
|
};
|
|
@@ -1006,18 +1006,18 @@ var ut = class {
|
|
|
1006
1006
|
async resolveLinks(e, t, s) {
|
|
1007
1007
|
let r = [];
|
|
1008
1008
|
if (e.link_uuids) {
|
|
1009
|
-
const o = e.link_uuids.length, n = [],
|
|
1010
|
-
for (let
|
|
1011
|
-
const c = Math.min(o,
|
|
1012
|
-
n.push(e.link_uuids.slice(
|
|
1009
|
+
const o = e.link_uuids.length, n = [], a = 50;
|
|
1010
|
+
for (let l = 0; l < o; l += a) {
|
|
1011
|
+
const c = Math.min(o, l + a);
|
|
1012
|
+
n.push(e.link_uuids.slice(l, c));
|
|
1013
1013
|
}
|
|
1014
|
-
for (let
|
|
1014
|
+
for (let l = 0; l < n.length; l++)
|
|
1015
1015
|
(await this.getStories({
|
|
1016
|
-
per_page:
|
|
1016
|
+
per_page: a,
|
|
1017
1017
|
language: t.language,
|
|
1018
1018
|
version: t.version,
|
|
1019
1019
|
starts_with: t.starts_with,
|
|
1020
|
-
by_uuids: n[
|
|
1020
|
+
by_uuids: n[l].join(",")
|
|
1021
1021
|
})).data.stories.forEach((c) => {
|
|
1022
1022
|
r.push(c);
|
|
1023
1023
|
});
|
|
@@ -1032,18 +1032,18 @@ var ut = class {
|
|
|
1032
1032
|
async resolveRelations(e, t, s) {
|
|
1033
1033
|
let r = [];
|
|
1034
1034
|
if (e.rel_uuids) {
|
|
1035
|
-
const o = e.rel_uuids.length, n = [],
|
|
1036
|
-
for (let
|
|
1037
|
-
const c = Math.min(o,
|
|
1038
|
-
n.push(e.rel_uuids.slice(
|
|
1035
|
+
const o = e.rel_uuids.length, n = [], a = 50;
|
|
1036
|
+
for (let l = 0; l < o; l += a) {
|
|
1037
|
+
const c = Math.min(o, l + a);
|
|
1038
|
+
n.push(e.rel_uuids.slice(l, c));
|
|
1039
1039
|
}
|
|
1040
|
-
for (let
|
|
1040
|
+
for (let l = 0; l < n.length; l++)
|
|
1041
1041
|
(await this.getStories({
|
|
1042
|
-
per_page:
|
|
1042
|
+
per_page: a,
|
|
1043
1043
|
language: t.language,
|
|
1044
1044
|
version: t.version,
|
|
1045
1045
|
starts_with: t.starts_with,
|
|
1046
|
-
by_uuids: n[
|
|
1046
|
+
by_uuids: n[l].join(","),
|
|
1047
1047
|
excluding_fields: t.excluding_fields
|
|
1048
1048
|
})).data.stories.forEach((c) => {
|
|
1049
1049
|
r.push(c);
|
|
@@ -1074,45 +1074,45 @@ var ut = class {
|
|
|
1074
1074
|
"story",
|
|
1075
1075
|
"url",
|
|
1076
1076
|
"link"
|
|
1077
|
-
].includes(t.resolve_links) && ((r = e.links) != null && r.length || (o = e.link_uuids) != null && o.length) && await this.resolveLinks(e, t, s), this.resolveNestedRelations) for (const
|
|
1078
|
-
e.story ? this.iterateTree(e.story, n, s) : e.stories.forEach((
|
|
1079
|
-
this.iterateTree(
|
|
1077
|
+
].includes(t.resolve_links) && ((r = e.links) != null && r.length || (o = e.link_uuids) != null && o.length) && await this.resolveLinks(e, t, s), this.resolveNestedRelations) for (const a in this.relations[s]) this.iterateTree(this.relations[s][a], n, s);
|
|
1078
|
+
e.story ? this.iterateTree(e.story, n, s) : e.stories.forEach((a) => {
|
|
1079
|
+
this.iterateTree(a, n, s);
|
|
1080
1080
|
}), this.stringifiedStoriesCache = {}, delete this.links[s], delete this.relations[s];
|
|
1081
1081
|
}
|
|
1082
1082
|
async cacheResponse(e, t, s, r) {
|
|
1083
|
-
const o =
|
|
1083
|
+
const o = z({
|
|
1084
1084
|
url: e,
|
|
1085
1085
|
params: t
|
|
1086
1086
|
}), n = this.cacheProvider();
|
|
1087
1087
|
if (t.version === "published" && e !== "/cdn/spaces/me") {
|
|
1088
|
-
const
|
|
1089
|
-
if (
|
|
1088
|
+
const c = await n.get(o);
|
|
1089
|
+
if (c) return Promise.resolve(c);
|
|
1090
1090
|
}
|
|
1091
|
-
const l =
|
|
1092
|
-
return new Promise(async (
|
|
1093
|
-
var
|
|
1091
|
+
const a = !D(e) && this.rateLimitConfig.isManagementApi ? P : void 0, l = H(e, t, this.rateLimitConfig, a);
|
|
1092
|
+
return new Promise(async (c, u) => {
|
|
1093
|
+
var g;
|
|
1094
1094
|
try {
|
|
1095
1095
|
const d = await this.throttleManager.execute(l, "get", e, t, r);
|
|
1096
|
-
if (d.status !== 200) return
|
|
1097
|
-
let
|
|
1096
|
+
if (d.status !== 200) return u(d);
|
|
1097
|
+
let C = {
|
|
1098
1098
|
data: d.data,
|
|
1099
1099
|
headers: d.headers
|
|
1100
1100
|
};
|
|
1101
|
-
const
|
|
1102
|
-
if ((
|
|
1101
|
+
const R = ot(d.headers);
|
|
1102
|
+
if ((R == null ? void 0 : R.max) !== void 0 && (this.rateLimitConfig.serverHeadersRateLimit = R.max), (g = d.headers) != null && g["per-page"] && (C = Object.assign({}, C, {
|
|
1103
1103
|
perPage: d.headers["per-page"] ? Number.parseInt(d.headers["per-page"]) : 0,
|
|
1104
1104
|
total: d.headers["per-page"] ? Number.parseInt(d.headers.total) : 0
|
|
1105
|
-
})),
|
|
1106
|
-
const
|
|
1107
|
-
await this.resolveStories(
|
|
1105
|
+
})), C.data.story || C.data.stories) {
|
|
1106
|
+
const T = this.resolveCounter = ++this.resolveCounter % 1e3;
|
|
1107
|
+
await this.resolveStories(C.data, t, `${T}`), C = await this.processInlineAssets(C);
|
|
1108
1108
|
}
|
|
1109
|
-
t.version === "published" && e !== "/cdn/spaces/me" && await n.set(o,
|
|
1110
|
-
const
|
|
1111
|
-
return t.token &&
|
|
1109
|
+
t.version === "published" && e !== "/cdn/spaces/me" && await n.set(o, C);
|
|
1110
|
+
const k = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
|
|
1111
|
+
return t.token && C.data.cv && (k && _[t.token] && _[t.token] !== C.data.cv && await this.flushCache(), _[t.token] = C.data.cv), c(C);
|
|
1112
1112
|
} catch (d) {
|
|
1113
1113
|
if (d.response && d.status === 429 && (s = typeof s > "u" ? 0 : s + 1, s < this.maxRetries))
|
|
1114
|
-
return console.log(`Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`), await Ze(this.retriesDelay), this.cacheResponse(e, t, s).then(
|
|
1115
|
-
|
|
1114
|
+
return console.log(`Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`), await Ze(this.retriesDelay), this.cacheResponse(e, t, s).then(c).catch(u);
|
|
1115
|
+
u(d);
|
|
1116
1116
|
}
|
|
1117
1117
|
});
|
|
1118
1118
|
}
|
|
@@ -1120,32 +1120,32 @@ var ut = class {
|
|
|
1120
1120
|
return this.client.setFetchOptions(r), this.client[e](t, s);
|
|
1121
1121
|
}
|
|
1122
1122
|
cacheVersions() {
|
|
1123
|
-
return
|
|
1123
|
+
return _;
|
|
1124
1124
|
}
|
|
1125
1125
|
cacheVersion() {
|
|
1126
|
-
return
|
|
1126
|
+
return _[this.accessToken];
|
|
1127
1127
|
}
|
|
1128
1128
|
setCacheVersion(e) {
|
|
1129
|
-
this.accessToken && (
|
|
1129
|
+
this.accessToken && (_[this.accessToken] = e);
|
|
1130
1130
|
}
|
|
1131
1131
|
clearCacheVersion() {
|
|
1132
|
-
this.accessToken && (
|
|
1132
|
+
this.accessToken && (_[this.accessToken] = 0);
|
|
1133
1133
|
}
|
|
1134
1134
|
cacheProvider() {
|
|
1135
1135
|
switch (this.cache.type) {
|
|
1136
1136
|
case "memory":
|
|
1137
1137
|
return {
|
|
1138
1138
|
get(e) {
|
|
1139
|
-
return Promise.resolve(
|
|
1139
|
+
return Promise.resolve(N[e]);
|
|
1140
1140
|
},
|
|
1141
1141
|
getAll() {
|
|
1142
|
-
return Promise.resolve(
|
|
1142
|
+
return Promise.resolve(N);
|
|
1143
1143
|
},
|
|
1144
1144
|
set(e, t) {
|
|
1145
|
-
return
|
|
1145
|
+
return N[e] = t, Promise.resolve(void 0);
|
|
1146
1146
|
},
|
|
1147
1147
|
flush() {
|
|
1148
|
-
return
|
|
1148
|
+
return N = {}, Promise.resolve(void 0);
|
|
1149
1149
|
}
|
|
1150
1150
|
};
|
|
1151
1151
|
case "custom":
|
|
@@ -1210,29 +1210,29 @@ const yt = (e = {}) => {
|
|
|
1210
1210
|
return {};
|
|
1211
1211
|
}
|
|
1212
1212
|
};
|
|
1213
|
-
let
|
|
1213
|
+
let q = "https://app.storyblok.com/f/storyblok-v2-latest.js";
|
|
1214
1214
|
const bt = (e = {}) => {
|
|
1215
1215
|
var t, s;
|
|
1216
1216
|
const {
|
|
1217
1217
|
bridge: r,
|
|
1218
1218
|
accessToken: o,
|
|
1219
1219
|
use: n = [],
|
|
1220
|
-
apiOptions:
|
|
1221
|
-
bridgeUrl:
|
|
1220
|
+
apiOptions: a = {},
|
|
1221
|
+
bridgeUrl: l
|
|
1222
1222
|
} = e;
|
|
1223
|
-
|
|
1224
|
-
const c = { bridge: r, apiOptions:
|
|
1223
|
+
a.accessToken = a.accessToken || o;
|
|
1224
|
+
const c = { bridge: r, apiOptions: a };
|
|
1225
1225
|
let u = {};
|
|
1226
|
-
n.forEach((
|
|
1227
|
-
u = { ...u, ...
|
|
1228
|
-
}),
|
|
1229
|
-
const
|
|
1230
|
-
return r !== !1 &&
|
|
1226
|
+
n.forEach((d) => {
|
|
1227
|
+
u = { ...u, ...d(c) };
|
|
1228
|
+
}), l && (q = l);
|
|
1229
|
+
const g = !(typeof window > "u") && ((s = (t = window.location) == null ? void 0 : t.search) == null ? void 0 : s.includes("_storyblok_tk"));
|
|
1230
|
+
return r !== !1 && g && le(q), u;
|
|
1231
1231
|
};
|
|
1232
1232
|
function Ct(e, t) {
|
|
1233
1233
|
return Ge(t).render(e);
|
|
1234
1234
|
}
|
|
1235
|
-
const vt = () => le(
|
|
1235
|
+
const vt = () => le(q);
|
|
1236
1236
|
export {
|
|
1237
1237
|
yt as apiPlugin,
|
|
1238
1238
|
pt as getLiveStory,
|
|
@@ -1243,6 +1243,6 @@ export {
|
|
|
1243
1243
|
ft as storyblok,
|
|
1244
1244
|
gt as storyblokEditable,
|
|
1245
1245
|
bt as storyblokInit,
|
|
1246
|
-
|
|
1246
|
+
Ie as toCamelCase,
|
|
1247
1247
|
dt as useStoryblokApi
|
|
1248
1248
|
};
|