@storyblok/astro 7.3.7 → 7.4.0-alpha.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.
- package/dist/components/StoryblokServerData.astro +29 -0
- package/dist/index.d.ts +3 -1
- package/dist/lib/helpers.d.ts +46 -0
- package/dist/lib/sanitizeJSON.d.ts +30 -0
- package/dist/live-preview/middleware.ts +6 -7
- package/dist/public.d.ts +8 -0
- package/dist/storyblok-astro.es.js +935 -608
- package/dist/storyblok-astro.umd.js +13 -13
- package/dist/utils/isEditorRequest.d.ts +41 -0
- package/package.json +5 -3
|
@@ -1,133 +1,139 @@
|
|
|
1
|
-
const
|
|
1
|
+
const Fe = `
|
|
2
2
|
<svg class="logo-storyblok logo-storyblok--dark" role="img" aria-label="Storyblok Official Logo" viewBox="0 0 19 22" xmlns="http://www.w3.org/2000/svg">
|
|
3
3
|
<path d="M29.0287 14.9132C28.2686 14.9132 27.5302 14.8018 26.7918 14.5568C26.0988 14.3265 25.462 13.9468 24.924 13.4432L25.9013 11.7504C26.4443 12.1291 26.9655 12.4186 27.4867 12.6414C27.9862 12.8641 28.4858 12.9532 28.9636 12.9532C29.3111 12.9532 29.5934 12.8864 29.7888 12.7527C29.9843 12.6414 30.0712 12.4409 30.0712 12.1959C30.0712 11.9732 29.9626 11.7504 29.702 11.6168C29.2938 11.4162 28.8636 11.2666 28.4206 11.1714L26.9003 10.6591C26.4877 10.4809 26.1619 10.3027 25.9013 10.1023C25.6407 9.92408 25.4452 9.67908 25.3366 9.43408C25.2184 9.1529 25.1592 8.84935 25.1629 8.54317C25.1502 7.66646 25.5255 6.83107 26.1836 6.27136C26.4877 6.00408 26.8786 5.80363 27.313 5.64772C27.7473 5.49181 28.2251 5.42499 28.7247 5.42499C29.3979 5.42499 30.0277 5.51408 30.6141 5.69226C31.2005 5.89272 31.7652 6.22681 32.3081 6.71681L31.244 8.38726C30.8236 8.07881 30.3722 7.81747 29.8974 7.60772C29.4848 7.42954 29.1156 7.36272 28.7247 7.36272C28.4423 7.36272 28.1817 7.40726 27.9862 7.5409C27.7691 7.65226 27.6822 7.85272 27.6822 8.11999C27.6822 8.38726 27.7908 8.56545 28.008 8.69908C28.2251 8.83272 28.6595 8.96635 29.2459 9.12226C29.7903 9.26289 30.3268 9.4339 30.853 9.63454C31.2874 9.81272 31.6349 10.0132 31.9172 10.2136C32.4511 10.6169 32.7463 11.2726 32.6991 11.9509C32.6991 12.8641 32.3733 13.5768 31.7 14.1114C31.0485 14.6459 30.1798 14.9132 29.0287 14.9132ZM39.7792 14.2673C39.41 14.4232 38.9756 14.5791 38.4978 14.7127C38.02 14.8464 37.5422 14.9354 37.0427 14.9354C36.6952 14.9354 36.3911 14.8909 36.0871 14.8018C35.7915 14.7134 35.5176 14.5616 35.2835 14.3564C35.0663 14.1782 34.8926 13.9109 34.7623 13.6214C34.632 13.3095 34.5451 12.9309 34.5451 12.4854V7.69681H33.4158V5.60317H34.5668V2.68545H37.2599V5.5809H39.0842V7.69681H37.2599V11.5277C37.2599 11.8173 37.325 12.04 37.4771 12.1959C37.6291 12.3073 37.8245 12.3741 38.0417 12.3741C38.2589 12.3741 38.4761 12.3518 38.6715 12.2627C38.8887 12.1959 39.0842 12.1291 39.2362 12.04L39.7575 14.2673H39.7792ZM44.8612 14.9132C44.1701 14.9255 43.4835 14.7968 42.8414 14.5345C41.7112 14.076 40.8261 13.1439 40.409 11.9732C39.9823 10.8102 39.9823 9.52792 40.409 8.36499C40.8261 7.19423 41.7112 6.26214 42.8414 5.80363C43.4278 5.55863 44.1011 5.42499 44.8612 5.42499C46.1833 5.36117 47.4671 5.88947 48.3795 6.87272C48.7922 7.2959 49.0962 7.80817 49.3134 8.36499C49.758 9.5322 49.758 10.8282 49.3134 11.9954C48.8937 13.1518 48.0186 14.0734 46.9027 14.5345C46.2538 14.7998 45.5596 14.9285 44.8612 14.9132ZM42.9066 10.1914C42.9066 10.9041 43.0803 11.4832 43.4495 11.9064C43.8405 12.3518 44.3183 12.5745 44.8829 12.5745C45.4284 12.5853 45.9487 12.3391 46.2946 11.9064C46.4683 11.6836 46.5987 11.4609 46.7072 11.1491C46.8158 10.8595 46.8593 10.5254 46.8593 10.1914C46.8593 9.45636 46.6638 8.87726 46.2946 8.45408C45.9254 8.00863 45.4476 7.78589 44.8829 7.78589C44.3394 7.78464 43.8229 8.02909 43.4712 8.45408C43.2975 8.67681 43.1455 8.89954 43.0369 9.21136C42.939 9.52794 42.8949 9.85944 42.9066 10.1914ZM56.6541 7.98636C56.0026 7.98636 55.3945 8.09772 54.8515 8.32045C54.3736 8.48572 53.9666 8.81646 53.7005 9.2559V14.7573H50.9857V5.60317H53.4833V7.42954C53.7873 6.8059 54.1783 6.3159 54.6778 5.98181C55.1556 5.62545 55.6551 5.44726 56.1981 5.42499H56.4804L56.6541 5.44726V7.96408V7.98636ZM57.8486 16.1159C58.2263 16.2505 58.6217 16.3256 59.0214 16.3386C59.3472 16.3386 59.6078 16.2273 59.8033 16.0045C59.977 15.7818 60.129 15.3364 60.2811 14.7573L56.893 5.60317H59.6947L61.7579 12.3518L63.5605 5.60317H66.1015L62.6918 16.2273C62.1569 18.0318 60.3638 19.1157 58.5653 18.7218C58.3481 18.6773 58.0875 18.6104 57.8486 18.4991V16.1159ZM72.5301 14.9133C71.8568 14.9133 71.2487 14.7795 70.7492 14.4677C70.2417 14.1818 69.8208 13.758 69.533 13.2427V14.7573H67.1657V2.01727H69.9022V7.09545C70.4962 6.02938 71.6157 5.38681 72.8124 5.42499C73.3771 5.42499 73.8983 5.53636 74.3761 5.80363C74.8539 6.02636 75.2448 6.38272 75.614 6.8059C76.6831 8.32739 76.974 10.2831 76.3959 12.0623C76.1787 12.6414 75.8746 13.1536 75.5054 13.5768C74.7429 14.4342 73.6616 14.9198 72.5301 14.9133ZM71.7699 12.5745C72.6515 12.5764 73.4369 12.0037 73.7245 11.1491C74.043 10.2518 73.887 9.24956 73.3119 8.49863C72.9724 8.0401 72.4398 7.7753 71.8785 7.7859C71.4659 7.7859 71.0749 7.94181 70.7057 8.23136C70.3582 8.54317 70.0759 8.92181 69.8805 9.38954V11.305C70.2309 12.0628 70.9738 12.5476 71.7916 12.5523L71.7699 12.5745ZM78.0247 2.01727H80.7395V11.4832C80.7395 12.1959 81.0218 12.53 81.6082 12.53C81.9183 12.5309 82.2239 12.4545 82.4987 12.3073L82.8679 14.3786C82.1072 14.7203 81.2875 14.902 80.4572 14.9132C79.6753 14.9132 79.0672 14.6904 78.6546 14.2895C78.2202 13.8441 78.003 13.265 78.003 12.4632V2.01727H78.0247ZM87.9933 14.9132C87.3023 14.9255 86.6157 14.7968 85.9736 14.5345C84.8367 14.0789 83.9437 13.1469 83.5194 11.9732C82.8914 10.2226 83.2408 8.26037 84.4316 6.85045C84.8659 6.40499 85.3437 6.0709 85.9518 5.80363C86.5382 5.55863 87.2115 5.42499 87.9716 5.42499C89.2937 5.36117 90.5776 5.88947 91.49 6.87272C91.9243 7.2959 92.2066 7.80817 92.4238 8.36499C93.0767 10.1133 92.7249 12.0889 91.5117 13.4877C91.099 13.9332 90.5995 14.2895 89.9914 14.5345C89.3493 14.7968 88.6627 14.9255 87.9716 14.9132H87.9933ZM86.017 10.1914C86.017 10.9041 86.1907 11.4832 86.5599 11.9064C86.9509 12.3518 87.4287 12.5745 87.9933 12.5745C88.5382 12.5821 89.0571 12.3364 89.405 11.9064C89.5788 11.6836 89.7091 11.4609 89.8177 11.1491C89.9262 10.8595 89.9697 10.5254 89.9697 10.1914C89.9697 9.45636 89.7742 8.87726 89.405 8.45408C89.0358 8.00863 88.558 7.78589 87.9933 7.78589C87.4498 7.78464 86.9334 8.02909 86.5817 8.45408C86.4079 8.67681 86.2559 8.89954 86.1473 9.21136C86.0387 9.52317 86.017 9.83499 86.017 10.1914ZM100.112 14.7573L97.7882 11.06L96.8326 12.0845V14.7573H94.1178V2.01727H96.8326V9.38954L99.8514 5.60317H102.74L99.5256 9.54545L103.001 14.7573H100.112Z" fill="currentColor"></path>
|
|
4
4
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 1.71089C0 0.76599 0.76599 0 1.71089 0H17.1089C18.0538 0 18.8198 0.76599 18.8198 1.71089V17.1089C18.8198 18.0538 18.0538 18.8198 17.1089 18.8198H7.13145L4.57616 20.9297C4.24445 21.2036 3.74366 20.9676 3.74366 20.5375V18.8198H1.71089C0.76599 18.8198 0 18.0538 0 17.1089V1.71089ZM3.74233 3.10946H11.9675C13.7438 3.10946 15.1839 4.5495 15.1839 6.32587C15.1839 7.74936 14.2592 8.95687 12.9777 9.38045C14.4761 9.65447 15.6117 10.9667 15.6117 12.5443C15.6117 14.3207 14.1717 15.7607 12.3953 15.7607H3.74247V9.54229H3.74233V3.10946ZM10.583 6.00384H6.73607V7.93369H10.583C11.1159 7.93369 11.5479 7.50168 11.5479 6.96877C11.5479 6.43585 11.1159 6.00384 10.583 6.00384ZM6.73607 10.2925H10.9035C11.4956 10.2925 11.9757 10.7725 11.9757 11.3647C11.9757 11.9568 11.4956 12.4368 10.9035 12.4368H6.73607V10.2925Z" fill="currentColor"></path>
|
|
5
5
|
</svg>
|
|
6
6
|
`;
|
|
7
|
-
function
|
|
8
|
-
const
|
|
7
|
+
function qe(e, t, r) {
|
|
8
|
+
const s = "virtual:storyblok-init", n = `\0${s}`;
|
|
9
9
|
return {
|
|
10
10
|
name: "vite-plugin-storyblok-init",
|
|
11
|
-
async resolveId(
|
|
12
|
-
if (
|
|
13
|
-
return
|
|
11
|
+
async resolveId(i) {
|
|
12
|
+
if (i === s)
|
|
13
|
+
return n;
|
|
14
14
|
},
|
|
15
|
-
async load(
|
|
16
|
-
if (
|
|
15
|
+
async load(i) {
|
|
16
|
+
if (i === n)
|
|
17
17
|
return `
|
|
18
18
|
import { storyblokInit, apiPlugin } from "@storyblok/astro";
|
|
19
19
|
const { storyblokApi } = storyblokInit({
|
|
20
20
|
accessToken: "${e}",
|
|
21
21
|
use: ${t ? "[]" : "[apiPlugin]"},
|
|
22
|
-
apiOptions: ${JSON.stringify(
|
|
22
|
+
apiOptions: ${JSON.stringify(r)},
|
|
23
23
|
});
|
|
24
24
|
export const storyblokApiInstance = storyblokApi;
|
|
25
25
|
`;
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
function
|
|
30
|
-
const t = "virtual:storyblok-options",
|
|
29
|
+
function Ge(e) {
|
|
30
|
+
const t = "virtual:storyblok-options", r = `\0${t}`;
|
|
31
31
|
return {
|
|
32
32
|
name: "vite-plugin-storyblok-options",
|
|
33
|
-
async resolveId(
|
|
34
|
-
if (
|
|
35
|
-
return
|
|
33
|
+
async resolveId(s) {
|
|
34
|
+
if (s === t)
|
|
35
|
+
return r;
|
|
36
36
|
},
|
|
37
|
-
async load(
|
|
38
|
-
if (
|
|
37
|
+
async load(s) {
|
|
38
|
+
if (s === r)
|
|
39
39
|
return `export default ${JSON.stringify(e)}`;
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function lr() {
|
|
44
44
|
if (!(globalThis != null && globalThis.storyblokApiInstance))
|
|
45
45
|
throw new Error("storyblokApiInstance has not been initialized correctly");
|
|
46
46
|
return globalThis.storyblokApiInstance;
|
|
47
47
|
}
|
|
48
|
-
async function
|
|
48
|
+
async function cr(e) {
|
|
49
49
|
let t = null;
|
|
50
|
-
return e && e.locals._storyblok_preview_data && (t = e.locals._storyblok_preview_data), t;
|
|
50
|
+
return e && e.locals._storyblok_preview_data && (t = e.locals._storyblok_preview_data.story || null), t;
|
|
51
|
+
}
|
|
52
|
+
async function ur({
|
|
53
|
+
locals: e
|
|
54
|
+
}) {
|
|
55
|
+
const { story: t, serverData: r } = e._storyblok_preview_data || {};
|
|
56
|
+
return { story: t, serverData: r };
|
|
51
57
|
}
|
|
52
|
-
function
|
|
58
|
+
function ze(e) {
|
|
53
59
|
return typeof e == "object" ? `const storyblokInstance = new StoryblokBridge(${JSON.stringify(e)});` : "const storyblokInstance = new StoryblokBridge();";
|
|
54
60
|
}
|
|
55
|
-
function
|
|
61
|
+
function Je(e) {
|
|
56
62
|
return e.endsWith(".astro") ? e : `${e}.astro`;
|
|
57
63
|
}
|
|
58
|
-
function
|
|
64
|
+
function ge(e) {
|
|
59
65
|
return `/${e.trim().replace(/^\/+/, "").replace(/\/+$/, "").replace(/\/{2,}/g, "/")}`;
|
|
60
66
|
}
|
|
61
|
-
const
|
|
62
|
-
let
|
|
63
|
-
for (let
|
|
64
|
-
const
|
|
65
|
-
l =
|
|
67
|
+
const Ke = /[\p{Lu}]/u, We = /[\p{Ll}]/u, Te = /^[\p{Lu}](?![\p{Lu}])/gu, De = /([\p{Alpha}\p{N}_]|$)/u, Ce = /[_.\- ]+/, Ye = new RegExp("^" + Ce.source), we = new RegExp(Ce.source + De.source, "gu"), Ee = new RegExp("\\d+" + De.source, "gu"), Ze = (e, t, r, s) => {
|
|
68
|
+
let n = !1, i = !1, o = !1, l = !1;
|
|
69
|
+
for (let a = 0; a < e.length; a++) {
|
|
70
|
+
const h = e[a];
|
|
71
|
+
l = a > 2 ? e[a - 3] === "-" : !0, n && Ke.test(h) ? (e = e.slice(0, a) + "-" + e.slice(a), n = !1, o = i, i = !0, a++) : i && o && We.test(h) && (!l || s) ? (e = e.slice(0, a - 1) + "-" + e.slice(a - 1), o = i, i = !1, n = !0) : (n = t(h) === h && r(h) !== h, o = i, i = r(h) === h && t(h) !== h);
|
|
66
72
|
}
|
|
67
73
|
return e;
|
|
68
|
-
},
|
|
69
|
-
function
|
|
74
|
+
}, Xe = (e, t) => (Te.lastIndex = 0, e.replaceAll(Te, (r) => t(r))), Qe = (e, t) => (we.lastIndex = 0, Ee.lastIndex = 0, e.replaceAll(Ee, (r, s, n) => ["_", "-"].includes(e.charAt(n + r.length)) ? r : t(r)).replaceAll(we, (r, s) => t(s)));
|
|
75
|
+
function et(e, t) {
|
|
70
76
|
if (!(typeof e == "string" || Array.isArray(e)))
|
|
71
77
|
throw new TypeError("Expected the input to be `string | string[]`");
|
|
72
78
|
if (t = {
|
|
73
79
|
pascalCase: !1,
|
|
74
80
|
preserveConsecutiveUppercase: !1,
|
|
75
81
|
...t
|
|
76
|
-
}, Array.isArray(e) ? e = e.map((
|
|
82
|
+
}, Array.isArray(e) ? e = e.map((i) => i.trim()).filter((i) => i.length).join("-") : e = e.trim(), e.length === 0)
|
|
77
83
|
return "";
|
|
78
|
-
const
|
|
79
|
-
return e.length === 1 ?
|
|
84
|
+
const r = t.locale === !1 ? (i) => i.toLowerCase() : (i) => i.toLocaleLowerCase(t.locale), s = t.locale === !1 ? (i) => i.toUpperCase() : (i) => i.toLocaleUpperCase(t.locale);
|
|
85
|
+
return e.length === 1 ? Ce.test(e) ? "" : t.pascalCase ? s(e) : r(e) : (e !== r(e) && (e = Ze(e, r, s, t.preserveConsecutiveUppercase)), e = e.replace(Ye, ""), e = t.preserveConsecutiveUppercase ? Xe(e, r) : r(e), t.pascalCase && (e = s(e.charAt(0)) + e.slice(1)), Qe(e, s));
|
|
80
86
|
}
|
|
81
|
-
function
|
|
82
|
-
return
|
|
87
|
+
function tt(e) {
|
|
88
|
+
return et(e);
|
|
83
89
|
}
|
|
84
|
-
function
|
|
85
|
-
const
|
|
90
|
+
function rt(e, t, r, s) {
|
|
91
|
+
const n = "virtual:import-storyblok-components", i = `\0${n}`;
|
|
86
92
|
return {
|
|
87
93
|
name: "vite-plugin-import-storyblok-components",
|
|
88
94
|
/**
|
|
89
95
|
* Resolves virtual module imports
|
|
90
96
|
*/
|
|
91
|
-
async resolveId(
|
|
92
|
-
if (
|
|
93
|
-
return
|
|
97
|
+
async resolveId(o) {
|
|
98
|
+
if (o === n)
|
|
99
|
+
return i;
|
|
94
100
|
},
|
|
95
101
|
/**
|
|
96
102
|
* Generates the virtual module content with dynamic imports
|
|
97
103
|
*/
|
|
98
|
-
async load(
|
|
99
|
-
if (
|
|
104
|
+
async load(o) {
|
|
105
|
+
if (o !== i)
|
|
100
106
|
return;
|
|
101
|
-
const l = await
|
|
107
|
+
const l = await nt(
|
|
102
108
|
this,
|
|
103
109
|
t,
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
),
|
|
110
|
+
r,
|
|
111
|
+
s
|
|
112
|
+
), a = await it(
|
|
107
113
|
this,
|
|
108
114
|
e,
|
|
109
115
|
t,
|
|
110
|
-
|
|
116
|
+
r
|
|
111
117
|
);
|
|
112
|
-
return
|
|
118
|
+
return st(
|
|
113
119
|
t,
|
|
114
120
|
l,
|
|
115
|
-
|
|
121
|
+
a
|
|
116
122
|
);
|
|
117
123
|
}
|
|
118
124
|
};
|
|
119
125
|
}
|
|
120
|
-
function
|
|
121
|
-
const
|
|
126
|
+
function st(e, t, r) {
|
|
127
|
+
const n = `${ge(e)}/storyblok/**/*.astro`;
|
|
122
128
|
return `
|
|
123
129
|
// Import utilities and fallback component
|
|
124
130
|
import { toCamelCase } from '@storyblok/astro';
|
|
125
131
|
${t}
|
|
126
|
-
${
|
|
132
|
+
${r.join(`
|
|
127
133
|
`)}
|
|
128
134
|
|
|
129
135
|
// Dynamically import all Storyblok components using Vite's glob import
|
|
130
|
-
const modules = import.meta.glob('${
|
|
136
|
+
const modules = import.meta.glob('${n}', { eager: true });
|
|
131
137
|
// Process imported modules into a components object
|
|
132
138
|
const storyblokComponents = {};
|
|
133
139
|
|
|
@@ -147,10 +153,10 @@ function Oe(e, t, s) {
|
|
|
147
153
|
}
|
|
148
154
|
|
|
149
155
|
// Manual imports (overwrite auto if same key exists)
|
|
150
|
-
${
|
|
156
|
+
${r.map((i) => {
|
|
151
157
|
var l;
|
|
152
|
-
const
|
|
153
|
-
return `storyblokComponents['${
|
|
158
|
+
const o = (l = i.match(/import\s+(\w+)\s+from/)) == null ? void 0 : l[1];
|
|
159
|
+
return `storyblokComponents['${o}'] = ${o};`;
|
|
154
160
|
}).join(`
|
|
155
161
|
`)}
|
|
156
162
|
|
|
@@ -161,40 +167,40 @@ function Oe(e, t, s) {
|
|
|
161
167
|
export { storyblokComponents };
|
|
162
168
|
`.trim();
|
|
163
169
|
}
|
|
164
|
-
async function
|
|
165
|
-
if (!
|
|
170
|
+
async function nt(e, t, r, s) {
|
|
171
|
+
if (!r)
|
|
166
172
|
return "";
|
|
167
|
-
if (
|
|
168
|
-
const
|
|
173
|
+
if (s) {
|
|
174
|
+
const n = Ue(
|
|
169
175
|
t,
|
|
170
|
-
|
|
176
|
+
s
|
|
171
177
|
);
|
|
172
|
-
if (!await e.resolve(
|
|
178
|
+
if (!await e.resolve(n))
|
|
173
179
|
throw new Error(
|
|
174
|
-
`Custom fallback component could not be found. Does "${
|
|
180
|
+
`Custom fallback component could not be found. Does "${n}" exist?`
|
|
175
181
|
);
|
|
176
|
-
return `import FallbackComponent from '${
|
|
182
|
+
return `import FallbackComponent from '${n}';`;
|
|
177
183
|
}
|
|
178
184
|
return "import FallbackComponent from '@storyblok/astro/FallbackComponent.astro';";
|
|
179
185
|
}
|
|
180
|
-
async function
|
|
181
|
-
const
|
|
182
|
-
for await (const [
|
|
183
|
-
const l =
|
|
184
|
-
if (
|
|
185
|
-
|
|
186
|
-
else if (!
|
|
186
|
+
async function it(e, t, r, s) {
|
|
187
|
+
const n = [];
|
|
188
|
+
for await (const [i, o] of Object.entries(t)) {
|
|
189
|
+
const l = Ue(r, o), a = await e.resolve(l);
|
|
190
|
+
if (a)
|
|
191
|
+
n.push(`import ${tt(i)} from "${a.id}"`);
|
|
192
|
+
else if (!s)
|
|
187
193
|
throw new Error(
|
|
188
|
-
`Component could not be found for blok "${
|
|
194
|
+
`Component could not be found for blok "${i}"! Does "${l}" exist?`
|
|
189
195
|
);
|
|
190
196
|
}
|
|
191
|
-
return
|
|
197
|
+
return n;
|
|
192
198
|
}
|
|
193
|
-
function
|
|
194
|
-
const
|
|
195
|
-
return
|
|
199
|
+
function Ue(e, t) {
|
|
200
|
+
const s = `${ge(e)}${ge(t)}`;
|
|
201
|
+
return Je(s);
|
|
196
202
|
}
|
|
197
|
-
function
|
|
203
|
+
function dr(e) {
|
|
198
204
|
const t = {
|
|
199
205
|
useCustomApi: !1,
|
|
200
206
|
bridge: !0,
|
|
@@ -203,55 +209,55 @@ function ft(e) {
|
|
|
203
209
|
livePreview: !1,
|
|
204
210
|
...e
|
|
205
211
|
}, {
|
|
206
|
-
accessToken:
|
|
207
|
-
useCustomApi:
|
|
208
|
-
apiOptions:
|
|
209
|
-
componentsDir:
|
|
210
|
-
customFallbackComponent:
|
|
212
|
+
accessToken: r,
|
|
213
|
+
useCustomApi: s,
|
|
214
|
+
apiOptions: n,
|
|
215
|
+
componentsDir: i,
|
|
216
|
+
customFallbackComponent: o,
|
|
211
217
|
enableFallbackComponent: l,
|
|
212
|
-
components:
|
|
213
|
-
bridge:
|
|
218
|
+
components: a,
|
|
219
|
+
bridge: h,
|
|
214
220
|
livePreview: g
|
|
215
|
-
} = t,
|
|
221
|
+
} = t, p = ze(t.bridge);
|
|
216
222
|
return {
|
|
217
223
|
name: "@storyblok/astro",
|
|
218
224
|
hooks: {
|
|
219
225
|
"astro:config:setup": ({
|
|
220
|
-
injectScript:
|
|
221
|
-
updateConfig:
|
|
222
|
-
addDevToolbarApp:
|
|
223
|
-
addMiddleware:
|
|
224
|
-
config:
|
|
226
|
+
injectScript: w,
|
|
227
|
+
updateConfig: I,
|
|
228
|
+
addDevToolbarApp: E,
|
|
229
|
+
addMiddleware: $,
|
|
230
|
+
config: U
|
|
225
231
|
}) => {
|
|
226
|
-
if (
|
|
232
|
+
if (I({
|
|
227
233
|
vite: {
|
|
228
234
|
plugins: [
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
235
|
+
qe(r, s, n),
|
|
236
|
+
rt(
|
|
237
|
+
a || {},
|
|
238
|
+
i,
|
|
233
239
|
l,
|
|
234
|
-
|
|
240
|
+
o
|
|
235
241
|
),
|
|
236
|
-
|
|
242
|
+
Ge(t)
|
|
237
243
|
]
|
|
238
244
|
}
|
|
239
|
-
}), g && (
|
|
245
|
+
}), g && (U == null ? void 0 : U.output) !== "server")
|
|
240
246
|
throw new Error(
|
|
241
247
|
"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
248
|
);
|
|
243
|
-
|
|
249
|
+
w(
|
|
244
250
|
"page-ssr",
|
|
245
251
|
`
|
|
246
252
|
import { storyblokApiInstance } from "virtual:storyblok-init";
|
|
247
253
|
globalThis.storyblokApiInstance = storyblokApiInstance;
|
|
248
254
|
`
|
|
249
|
-
),
|
|
255
|
+
), h && !g && w(
|
|
250
256
|
"page",
|
|
251
257
|
`import { loadStoryblokBridge } from "@storyblok/astro";
|
|
252
258
|
loadStoryblokBridge().then(() => {
|
|
253
259
|
const { StoryblokBridge, location } = window;
|
|
254
|
-
${
|
|
260
|
+
${p}
|
|
255
261
|
storyblokInstance.on(["published", "change"], (event) => {
|
|
256
262
|
if (!event.slugChanged) {
|
|
257
263
|
location.reload(true);
|
|
@@ -259,80 +265,398 @@ function ft(e) {
|
|
|
259
265
|
});
|
|
260
266
|
});
|
|
261
267
|
`
|
|
262
|
-
), g && (
|
|
268
|
+
), g && (w(
|
|
263
269
|
"page",
|
|
264
270
|
`import { loadStoryblokBridge, handleStoryblokMessage } from "@storyblok/astro";
|
|
265
271
|
loadStoryblokBridge().then(() => {
|
|
266
272
|
const { StoryblokBridge, location } = window;
|
|
267
|
-
${
|
|
273
|
+
${p}
|
|
268
274
|
storyblokInstance.on(["published", "change", "input"], handleStoryblokMessage);
|
|
269
275
|
});
|
|
270
276
|
`
|
|
271
|
-
),
|
|
277
|
+
), $({
|
|
272
278
|
entrypoint: "@storyblok/astro/middleware.ts",
|
|
273
279
|
order: "pre"
|
|
274
|
-
})),
|
|
280
|
+
})), E({
|
|
275
281
|
id: "storyblok",
|
|
276
282
|
name: "Storyblok",
|
|
277
|
-
icon:
|
|
283
|
+
icon: Fe,
|
|
278
284
|
entrypoint: "@storyblok/astro/toolbarApp.ts"
|
|
279
285
|
});
|
|
280
286
|
}
|
|
281
287
|
}
|
|
282
288
|
};
|
|
283
289
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
290
|
+
function hr(e) {
|
|
291
|
+
const t = JSON.stringify(e);
|
|
292
|
+
return t === void 0 ? "null" : t.replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029").replace(/&/g, "\\u0026");
|
|
293
|
+
}
|
|
294
|
+
var _e = 11;
|
|
295
|
+
function ot(e, t) {
|
|
296
|
+
var r = t.attributes, s, n, i, o, l;
|
|
297
|
+
if (!(t.nodeType === _e || e.nodeType === _e)) {
|
|
298
|
+
for (var a = r.length - 1; a >= 0; a--)
|
|
299
|
+
s = r[a], n = s.name, i = s.namespaceURI, o = s.value, i ? (n = s.localName || n, l = e.getAttributeNS(i, n), l !== o && (s.prefix === "xmlns" && (n = s.name), e.setAttributeNS(i, n, o))) : (l = e.getAttribute(n), l !== o && e.setAttribute(n, o));
|
|
300
|
+
for (var h = e.attributes, g = h.length - 1; g >= 0; g--)
|
|
301
|
+
s = h[g], n = s.name, i = s.namespaceURI, i ? (n = s.localName || n, t.hasAttributeNS(i, n) || e.removeAttributeNS(i, n)) : t.hasAttribute(n) || e.removeAttribute(n);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
var se, at = "http://www.w3.org/1999/xhtml", R = typeof document > "u" ? void 0 : document, lt = !!R && "content" in R.createElement("template"), ct = !!R && R.createRange && "createContextualFragment" in R.createRange();
|
|
305
|
+
function ut(e) {
|
|
306
|
+
var t = R.createElement("template");
|
|
307
|
+
return t.innerHTML = e, t.content.childNodes[0];
|
|
308
|
+
}
|
|
309
|
+
function dt(e) {
|
|
310
|
+
se || (se = R.createRange(), se.selectNode(R.body));
|
|
311
|
+
var t = se.createContextualFragment(e);
|
|
312
|
+
return t.childNodes[0];
|
|
313
|
+
}
|
|
314
|
+
function ht(e) {
|
|
315
|
+
var t = R.createElement("body");
|
|
316
|
+
return t.innerHTML = e, t.childNodes[0];
|
|
317
|
+
}
|
|
318
|
+
function ft(e) {
|
|
319
|
+
return e = e.trim(), lt ? ut(e) : ct ? dt(e) : ht(e);
|
|
320
|
+
}
|
|
321
|
+
function ne(e, t) {
|
|
322
|
+
var r = e.nodeName, s = t.nodeName, n, i;
|
|
323
|
+
return r === s ? !0 : (n = r.charCodeAt(0), i = s.charCodeAt(0), n <= 90 && i >= 97 ? r === s.toUpperCase() : i <= 90 && n >= 97 ? s === r.toUpperCase() : !1);
|
|
324
|
+
}
|
|
325
|
+
function pt(e, t) {
|
|
326
|
+
return !t || t === at ? R.createElement(e) : R.createElementNS(t, e);
|
|
327
|
+
}
|
|
328
|
+
function mt(e, t) {
|
|
329
|
+
for (var r = e.firstChild; r; ) {
|
|
330
|
+
var s = r.nextSibling;
|
|
331
|
+
t.appendChild(r), r = s;
|
|
332
|
+
}
|
|
333
|
+
return t;
|
|
334
|
+
}
|
|
335
|
+
function de(e, t, r) {
|
|
336
|
+
e[r] !== t[r] && (e[r] = t[r], e[r] ? e.setAttribute(r, "") : e.removeAttribute(r));
|
|
337
|
+
}
|
|
338
|
+
var Le = {
|
|
339
|
+
OPTION: function(e, t) {
|
|
340
|
+
var r = e.parentNode;
|
|
341
|
+
if (r) {
|
|
342
|
+
var s = r.nodeName.toUpperCase();
|
|
343
|
+
s === "OPTGROUP" && (r = r.parentNode, s = r && r.nodeName.toUpperCase()), s === "SELECT" && !r.hasAttribute("multiple") && (e.hasAttribute("selected") && !t.selected && (e.setAttribute("selected", "selected"), e.removeAttribute("selected")), r.selectedIndex = -1);
|
|
344
|
+
}
|
|
345
|
+
de(e, t, "selected");
|
|
346
|
+
},
|
|
347
|
+
/**
|
|
348
|
+
* The "value" attribute is special for the <input> element since it sets
|
|
349
|
+
* the initial value. Changing the "value" attribute without changing the
|
|
350
|
+
* "value" property will have no effect since it is only used to the set the
|
|
351
|
+
* initial value. Similar for the "checked" attribute, and "disabled".
|
|
352
|
+
*/
|
|
353
|
+
INPUT: function(e, t) {
|
|
354
|
+
de(e, t, "checked"), de(e, t, "disabled"), e.value !== t.value && (e.value = t.value), t.hasAttribute("value") || e.removeAttribute("value");
|
|
355
|
+
},
|
|
356
|
+
TEXTAREA: function(e, t) {
|
|
357
|
+
var r = t.value;
|
|
358
|
+
e.value !== r && (e.value = r);
|
|
359
|
+
var s = e.firstChild;
|
|
360
|
+
if (s) {
|
|
361
|
+
var n = s.nodeValue;
|
|
362
|
+
if (n == r || !r && n == e.placeholder)
|
|
292
363
|
return;
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
364
|
+
s.nodeValue = r;
|
|
365
|
+
}
|
|
366
|
+
},
|
|
367
|
+
SELECT: function(e, t) {
|
|
368
|
+
if (!t.hasAttribute("multiple")) {
|
|
369
|
+
for (var r = -1, s = 0, n = e.firstChild, i, o; n; )
|
|
370
|
+
if (o = n.nodeName && n.nodeName.toUpperCase(), o === "OPTGROUP")
|
|
371
|
+
i = n, n = i.firstChild, n || (n = i.nextSibling, i = null);
|
|
372
|
+
else {
|
|
373
|
+
if (o === "OPTION") {
|
|
374
|
+
if (n.hasAttribute("selected")) {
|
|
375
|
+
r = s;
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
378
|
+
s++;
|
|
379
|
+
}
|
|
380
|
+
n = n.nextSibling, !n && i && (n = i.nextSibling, i = null);
|
|
381
|
+
}
|
|
382
|
+
e.selectedIndex = r;
|
|
383
|
+
}
|
|
297
384
|
}
|
|
298
|
-
|
|
385
|
+
}, Y = 1, Re = 11, Se = 3, Ie = 8;
|
|
386
|
+
function H() {
|
|
299
387
|
}
|
|
300
|
-
function
|
|
301
|
-
if (
|
|
302
|
-
|
|
303
|
-
|
|
388
|
+
function vt(e) {
|
|
389
|
+
if (e)
|
|
390
|
+
return e.getAttribute && e.getAttribute("id") || e.id;
|
|
391
|
+
}
|
|
392
|
+
function yt(e) {
|
|
393
|
+
return function(r, s, n) {
|
|
394
|
+
if (n || (n = {}), typeof s == "string")
|
|
395
|
+
if (r.nodeName === "#document" || r.nodeName === "HTML") {
|
|
396
|
+
var i = s;
|
|
397
|
+
s = R.createElement("html"), s.innerHTML = i;
|
|
398
|
+
} else if (r.nodeName === "BODY") {
|
|
399
|
+
var o = s;
|
|
400
|
+
s = R.createElement("html"), s.innerHTML = o;
|
|
401
|
+
var l = s.querySelector("body");
|
|
402
|
+
l && (s = l);
|
|
403
|
+
} else
|
|
404
|
+
s = ft(s);
|
|
405
|
+
else s.nodeType === Re && (s = s.firstElementChild);
|
|
406
|
+
var a = n.getNodeKey || vt, h = n.onBeforeNodeAdded || H, g = n.onNodeAdded || H, p = n.onBeforeElUpdated || H, w = n.onElUpdated || H, I = n.onBeforeNodeDiscarded || H, E = n.onNodeDiscarded || H, $ = n.onBeforeElChildrenUpdated || H, U = n.skipFromChildren || H, J = n.addChild || function(f, d) {
|
|
407
|
+
return f.appendChild(d);
|
|
408
|
+
}, K = n.childrenOnly === !0, x = /* @__PURE__ */ Object.create(null), j = [];
|
|
409
|
+
function B(f) {
|
|
410
|
+
j.push(f);
|
|
411
|
+
}
|
|
412
|
+
function ee(f, d) {
|
|
413
|
+
if (f.nodeType === Y)
|
|
414
|
+
for (var A = f.firstChild; A; ) {
|
|
415
|
+
var y = void 0;
|
|
416
|
+
d && (y = a(A)) ? B(y) : (E(A), A.firstChild && ee(A, d)), A = A.nextSibling;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
function V(f, d, A) {
|
|
420
|
+
I(f) !== !1 && (d && d.removeChild(f), E(f), ee(f, A));
|
|
421
|
+
}
|
|
422
|
+
function F(f) {
|
|
423
|
+
if (f.nodeType === Y || f.nodeType === Re)
|
|
424
|
+
for (var d = f.firstChild; d; ) {
|
|
425
|
+
var A = a(d);
|
|
426
|
+
A && (x[A] = d), F(d), d = d.nextSibling;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
F(r);
|
|
430
|
+
function W(f) {
|
|
431
|
+
g(f);
|
|
432
|
+
for (var d = f.firstChild; d; ) {
|
|
433
|
+
var A = d.nextSibling, y = a(d);
|
|
434
|
+
if (y) {
|
|
435
|
+
var C = x[y];
|
|
436
|
+
C && ne(d, C) ? (d.parentNode.replaceChild(C, d), P(C, d)) : W(d);
|
|
437
|
+
} else
|
|
438
|
+
W(d);
|
|
439
|
+
d = A;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
function q(f, d, A) {
|
|
443
|
+
for (; d; ) {
|
|
444
|
+
var y = d.nextSibling;
|
|
445
|
+
(A = a(d)) ? B(A) : V(
|
|
446
|
+
d,
|
|
447
|
+
f,
|
|
448
|
+
!0
|
|
449
|
+
/* skip keyed nodes */
|
|
450
|
+
), d = y;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
function P(f, d, A) {
|
|
454
|
+
var y = a(d);
|
|
455
|
+
if (y && delete x[y], !A) {
|
|
456
|
+
var C = p(f, d);
|
|
457
|
+
if (C === !1 || (C instanceof HTMLElement && (f = C, F(f)), e(f, d), w(f), $(f, d) === !1))
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
f.nodeName !== "TEXTAREA" ? c(f, d) : Le.TEXTAREA(f, d);
|
|
461
|
+
}
|
|
462
|
+
function c(f, d) {
|
|
463
|
+
var A = U(f, d), y = d.firstChild, C = f.firstChild, G, O, z, te, M;
|
|
464
|
+
e: for (; y; ) {
|
|
465
|
+
for (te = y.nextSibling, G = a(y); !A && C; ) {
|
|
466
|
+
if (z = C.nextSibling, y.isSameNode && y.isSameNode(C)) {
|
|
467
|
+
y = te, C = z;
|
|
468
|
+
continue e;
|
|
469
|
+
}
|
|
470
|
+
O = a(C);
|
|
471
|
+
var re = C.nodeType, N = void 0;
|
|
472
|
+
if (re === y.nodeType && (re === Y ? (G ? G !== O && ((M = x[G]) ? z === M ? N = !1 : (f.insertBefore(M, C), O ? B(O) : V(
|
|
473
|
+
C,
|
|
474
|
+
f,
|
|
475
|
+
!0
|
|
476
|
+
/* skip keyed nodes */
|
|
477
|
+
), C = M, O = a(C)) : N = !1) : O && (N = !1), N = N !== !1 && ne(C, y), N && P(C, y)) : (re === Se || re == Ie) && (N = !0, C.nodeValue !== y.nodeValue && (C.nodeValue = y.nodeValue))), N) {
|
|
478
|
+
y = te, C = z;
|
|
479
|
+
continue e;
|
|
480
|
+
}
|
|
481
|
+
O ? B(O) : V(
|
|
482
|
+
C,
|
|
483
|
+
f,
|
|
484
|
+
!0
|
|
485
|
+
/* skip keyed nodes */
|
|
486
|
+
), C = z;
|
|
487
|
+
}
|
|
488
|
+
if (G && (M = x[G]) && ne(M, y))
|
|
489
|
+
A || J(f, M), P(M, y);
|
|
490
|
+
else {
|
|
491
|
+
var ue = h(y);
|
|
492
|
+
ue !== !1 && (ue && (y = ue), y.actualize && (y = y.actualize(f.ownerDocument || R)), J(f, y), W(y));
|
|
493
|
+
}
|
|
494
|
+
y = te, C = z;
|
|
495
|
+
}
|
|
496
|
+
q(f, C, O);
|
|
497
|
+
var Ae = Le[f.nodeName];
|
|
498
|
+
Ae && Ae(f, d);
|
|
499
|
+
}
|
|
500
|
+
var u = r, m = u.nodeType, v = s.nodeType;
|
|
501
|
+
if (!K) {
|
|
502
|
+
if (m === Y)
|
|
503
|
+
v === Y ? ne(r, s) || (E(r), u = mt(r, pt(s.nodeName, s.namespaceURI))) : u = s;
|
|
504
|
+
else if (m === Se || m === Ie) {
|
|
505
|
+
if (v === m)
|
|
506
|
+
return u.nodeValue !== s.nodeValue && (u.nodeValue = s.nodeValue), u;
|
|
507
|
+
u = s;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
if (u === s)
|
|
511
|
+
E(r);
|
|
512
|
+
else {
|
|
513
|
+
if (s.isSameNode && s.isSameNode(u))
|
|
514
|
+
return;
|
|
515
|
+
if (P(u, s, K), j)
|
|
516
|
+
for (var b = 0, _ = j.length; b < _; b++) {
|
|
517
|
+
var k = x[j[b]];
|
|
518
|
+
k && V(k, k.parentNode, !1);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
return !K && u !== r && r.parentNode && (u.actualize && (u = u.actualize(r.ownerDocument || R)), r.parentNode.replaceChild(u, r)), u;
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
var gt = yt(ot);
|
|
525
|
+
let he, ce = null;
|
|
526
|
+
const bt = 500, Ct = "__STORYBLOK_SERVERDATA__", Ve = "data-blok-focused", Q = "data-blok-uid", kt = "data-preserve-state", At = "storyblok-live-preview", Tt = "storyblok-live-preview-updating", $e = "storyblok-live-preview-updated";
|
|
527
|
+
function wt() {
|
|
528
|
+
const e = document.querySelector(
|
|
529
|
+
`meta[name="${At}"]`
|
|
530
|
+
);
|
|
531
|
+
return (e == null ? void 0 : e.content) === "disabled" || (e == null ? void 0 : e.content) === "false";
|
|
532
|
+
}
|
|
533
|
+
async function fr(e) {
|
|
534
|
+
const { action: t, story: r } = e || {};
|
|
535
|
+
if (["published", "change"].includes(t)) {
|
|
536
|
+
location.reload();
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
if (t === "input" && r) {
|
|
540
|
+
if (wt())
|
|
541
|
+
return;
|
|
542
|
+
ce && ce.abort(), he && clearTimeout(he), he = setTimeout(async () => {
|
|
543
|
+
try {
|
|
544
|
+
await Et(r);
|
|
545
|
+
} catch (s) {
|
|
546
|
+
if (s instanceof Error && s.name === "AbortError")
|
|
547
|
+
return;
|
|
548
|
+
console.error("Failed to update live preview:", s);
|
|
549
|
+
}
|
|
550
|
+
}, bt);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
async function Et(e) {
|
|
554
|
+
if (fe(
|
|
555
|
+
Tt,
|
|
556
|
+
{ story: e },
|
|
557
|
+
!0
|
|
558
|
+
).defaultPrevented)
|
|
559
|
+
return;
|
|
560
|
+
const r = document.body, s = $t(r), n = await It(e, s);
|
|
561
|
+
if (n.outerHTML === r.outerHTML) {
|
|
562
|
+
fe($e, { story: e });
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
const i = document.querySelector(`[${Ve}="true"]`);
|
|
566
|
+
Lt(r, n, i), fe($e, { story: e });
|
|
567
|
+
}
|
|
568
|
+
function _t(e, t) {
|
|
569
|
+
var n, i;
|
|
570
|
+
const r = (n = e.attributes.getNamedItem(Q)) == null ? void 0 : n.value, s = (i = t.attributes.getNamedItem(Q)) == null ? void 0 : i.value;
|
|
571
|
+
r === s && Array.from(e.attributes).forEach((o) => {
|
|
572
|
+
if (o.name === Q)
|
|
573
|
+
return;
|
|
574
|
+
const l = o.value, a = t.getAttribute(o.name);
|
|
575
|
+
(!t.hasAttribute(o.name) || a !== l) && t.setAttribute(o.name, l);
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
function Lt(e, t, r) {
|
|
579
|
+
let s = !0;
|
|
580
|
+
if (r) {
|
|
581
|
+
const n = r.getAttribute(Q), i = t.querySelector(
|
|
582
|
+
`[data-blok-uid="${n}"]`
|
|
304
583
|
);
|
|
305
|
-
|
|
306
|
-
}
|
|
307
|
-
|
|
584
|
+
i && (i.setAttribute(Ve, "true"), Oe(r, i), s = !1);
|
|
585
|
+
}
|
|
586
|
+
s && Oe(e, t);
|
|
308
587
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
588
|
+
function Rt(e) {
|
|
589
|
+
if (e.nodeType === 1) {
|
|
590
|
+
const t = e.getAttribute(Q);
|
|
591
|
+
if (t)
|
|
592
|
+
return t;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
function Oe(e, t) {
|
|
596
|
+
gt(e, t, {
|
|
597
|
+
getNodeKey: Rt,
|
|
598
|
+
onBeforeElUpdated: (r, s) => r.hasAttribute(kt) ? !1 : (_t(r, s), !0)
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
const St = (e) => {
|
|
602
|
+
if (e === null || typeof e != "object" || Array.isArray(e))
|
|
603
|
+
return !1;
|
|
604
|
+
const t = Object.getPrototypeOf(e);
|
|
605
|
+
return t === Object.prototype || t === null;
|
|
606
|
+
};
|
|
607
|
+
async function It(e, t) {
|
|
608
|
+
ce = new AbortController();
|
|
609
|
+
const r = {
|
|
610
|
+
story: {
|
|
313
611
|
...e,
|
|
314
612
|
is_storyblok_preview: !0
|
|
315
|
-
}
|
|
613
|
+
},
|
|
614
|
+
...St(t) && { serverData: t }
|
|
615
|
+
}, s = await fetch(location.href, {
|
|
616
|
+
method: "POST",
|
|
617
|
+
body: JSON.stringify(r),
|
|
316
618
|
headers: {
|
|
317
619
|
"Content-Type": "application/json"
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
|
|
620
|
+
},
|
|
621
|
+
signal: ce.signal
|
|
622
|
+
});
|
|
623
|
+
if (!s.ok)
|
|
624
|
+
throw new Error(
|
|
625
|
+
`Failed to fetch updated HTML: ${s.status} ${s.statusText}`
|
|
626
|
+
);
|
|
627
|
+
const n = await s.text();
|
|
628
|
+
return new DOMParser().parseFromString(n, "text/html").body;
|
|
321
629
|
}
|
|
322
|
-
function
|
|
323
|
-
|
|
630
|
+
function fe(e, t, r = !1) {
|
|
631
|
+
const s = new CustomEvent(e, { detail: t, cancelable: r });
|
|
632
|
+
return document.dispatchEvent(s), s;
|
|
324
633
|
}
|
|
325
|
-
|
|
326
|
-
|
|
634
|
+
function $t(e) {
|
|
635
|
+
const t = e.querySelector(`#${Ct}`);
|
|
636
|
+
if (!(t != null && t.textContent))
|
|
637
|
+
return null;
|
|
638
|
+
try {
|
|
639
|
+
return JSON.parse(t.textContent || "{}");
|
|
640
|
+
} catch (r) {
|
|
641
|
+
return console.error("Failed to parse server data:", r), null;
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
const Ot = ["_storyblok", "_storyblok_c", "_storyblok_tk[space_id]"];
|
|
645
|
+
function pr(e, t = {}) {
|
|
646
|
+
const r = e.searchParams;
|
|
647
|
+
return !(!Ot.every((n) => r.has(n)) || t.spaceId && r.get("_storyblok_tk[space_id]") !== t.spaceId);
|
|
648
|
+
}
|
|
649
|
+
var xt = Object.defineProperty, Pt = (e, t, r) => t in e ? xt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, T = (e, t, r) => Pt(e, typeof t != "symbol" ? t + "" : t, r);
|
|
650
|
+
let L = /* @__PURE__ */ function(e) {
|
|
327
651
|
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
|
-
}({}),
|
|
652
|
+
}({}), S = /* @__PURE__ */ function(e) {
|
|
329
653
|
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;
|
|
330
|
-
}({}),
|
|
654
|
+
}({}), Mt = /* @__PURE__ */ function(e) {
|
|
331
655
|
return e.TEXT = "text", e;
|
|
332
|
-
}({}),
|
|
656
|
+
}({}), ie = /* @__PURE__ */ function(e) {
|
|
333
657
|
return e.URL = "url", e.STORY = "story", e.ASSET = "asset", e.EMAIL = "email", e;
|
|
334
658
|
}({});
|
|
335
|
-
const
|
|
659
|
+
const Nt = [
|
|
336
660
|
"area",
|
|
337
661
|
"base",
|
|
338
662
|
"br",
|
|
@@ -347,286 +671,286 @@ const Ue = [
|
|
|
347
671
|
"source",
|
|
348
672
|
"track",
|
|
349
673
|
"wbr"
|
|
350
|
-
],
|
|
351
|
-
const { custom: t, ...
|
|
352
|
-
...
|
|
674
|
+
], Ht = (e = {}) => {
|
|
675
|
+
const { custom: t, ...r } = e, s = {
|
|
676
|
+
...r,
|
|
353
677
|
...t
|
|
354
678
|
};
|
|
355
|
-
return Object.keys(
|
|
356
|
-
},
|
|
357
|
-
function
|
|
679
|
+
return Object.keys(s).map((n) => `${n}="${s[n]}"`).join(" ");
|
|
680
|
+
}, Dt = (e = {}) => Object.keys(e).map((t) => `${t}: ${e[t]}`).join("; ");
|
|
681
|
+
function Ut(e) {
|
|
358
682
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
359
683
|
}
|
|
360
|
-
const
|
|
361
|
-
function
|
|
684
|
+
const Z = (e) => Object.fromEntries(Object.entries(e).filter(([t, r]) => r !== void 0));
|
|
685
|
+
function Vt(e, t) {
|
|
362
686
|
if (!t) return {
|
|
363
687
|
src: e,
|
|
364
688
|
attrs: {}
|
|
365
689
|
};
|
|
366
|
-
let
|
|
367
|
-
const
|
|
368
|
-
function a
|
|
369
|
-
typeof
|
|
690
|
+
let r = 0, s = 0;
|
|
691
|
+
const n = {}, i = [];
|
|
692
|
+
function o(a, h, g, p, w) {
|
|
693
|
+
typeof a != "number" || a <= h || a >= g ? console.warn(`[StoryblokRichText] - ${p.charAt(0).toUpperCase() + p.slice(1)} value must be a number between ${h} and ${g} (inclusive)`) : w.push(`${p}(${a})`);
|
|
370
694
|
}
|
|
371
695
|
if (typeof t == "object") {
|
|
372
|
-
if (t.width !== void 0 && (typeof t.width == "number" && t.width >= 0 ? (
|
|
373
|
-
const { filters:
|
|
374
|
-
|
|
696
|
+
if (t.width !== void 0 && (typeof t.width == "number" && t.width >= 0 ? (n.width = t.width, r = 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 ? (n.height = t.height, s = t.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than or equal to 0")), t.height === 0 && t.width === 0 && (delete n.width, delete n.height, console.warn("[StoryblokRichText] - Width and height values cannot both be 0")), t.loading && ["lazy", "eager"].includes(t.loading) && (n.loading = t.loading), t.class && (n.class = t.class), t.filters) {
|
|
697
|
+
const { filters: a } = t || {}, { blur: h, brightness: g, fill: p, format: w, grayscale: I, quality: E, rotate: $ } = a || {};
|
|
698
|
+
h && o(h, 0, 100, "blur", i), E && o(E, 0, 100, "quality", i), g && o(g, 0, 100, "brightness", i), p && i.push(`fill(${p})`), I && i.push("grayscale()"), $ && [
|
|
375
699
|
0,
|
|
376
700
|
90,
|
|
377
701
|
180,
|
|
378
702
|
270
|
|
379
|
-
].includes(t.filters.rotate || 0) &&
|
|
703
|
+
].includes(t.filters.rotate || 0) && i.push(`rotate(${$})`), w && [
|
|
380
704
|
"webp",
|
|
381
705
|
"png",
|
|
382
706
|
"jpeg"
|
|
383
|
-
].includes(
|
|
707
|
+
].includes(w) && i.push(`format(${w})`);
|
|
384
708
|
}
|
|
385
|
-
t.srcset && (
|
|
386
|
-
if (typeof
|
|
387
|
-
if (Array.isArray(
|
|
388
|
-
const [
|
|
389
|
-
return `${e}/m/${
|
|
709
|
+
t.srcset && (n.srcset = t.srcset.map((a) => {
|
|
710
|
+
if (typeof a == "number") return `${e}/m/${a}x0/${i.length > 0 ? `filters:${i.join(":")}` : ""} ${a}w`;
|
|
711
|
+
if (Array.isArray(a) && a.length === 2) {
|
|
712
|
+
const [h, g] = a;
|
|
713
|
+
return `${e}/m/${h}x${g}/${i.length > 0 ? `filters:${i.join(":")}` : ""} ${h}w`;
|
|
390
714
|
} else {
|
|
391
715
|
console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
|
|
392
716
|
return;
|
|
393
717
|
}
|
|
394
|
-
}).join(", ")), t.sizes && (
|
|
718
|
+
}).join(", ")), t.sizes && (n.sizes = t.sizes.join(", "));
|
|
395
719
|
}
|
|
396
720
|
let l = `${e}/m/`;
|
|
397
|
-
return (
|
|
721
|
+
return (r > 0 || s > 0) && (l = `${l}${r}x${s}/`), i.length > 0 && (l = `${l}filters:${i.join(":")}`), {
|
|
398
722
|
src: l,
|
|
399
|
-
attrs:
|
|
723
|
+
attrs: n
|
|
400
724
|
};
|
|
401
725
|
}
|
|
402
|
-
function
|
|
403
|
-
const
|
|
726
|
+
function xe(e, t = {}, r) {
|
|
727
|
+
const s = Ht(t), n = s ? `${e} ${s}` : e, i = Array.isArray(r) ? r.join("") : r || "";
|
|
404
728
|
if (e) {
|
|
405
|
-
if (
|
|
406
|
-
} else return
|
|
407
|
-
return `<${
|
|
729
|
+
if (Nt.includes(e)) return `<${n}>`;
|
|
730
|
+
} else return i;
|
|
731
|
+
return `<${n}>${i}</${e}>`;
|
|
408
732
|
}
|
|
409
|
-
function
|
|
410
|
-
const t = /* @__PURE__ */ new Map(), { renderFn:
|
|
411
|
-
const { textAlign:
|
|
412
|
-
return
|
|
413
|
-
...
|
|
414
|
-
class:
|
|
415
|
-
id:
|
|
416
|
-
...
|
|
733
|
+
function jt(e = {}) {
|
|
734
|
+
const t = /* @__PURE__ */ new Map(), { renderFn: r = xe, textFn: s = Ut, resolvers: n = {}, optimizeImages: i = !1, keyedResolvers: o = !1 } = e, l = r !== xe, a = (c = {}) => {
|
|
735
|
+
const { textAlign: u, class: m, id: v, style: b, ..._ } = c, k = [];
|
|
736
|
+
return b && k.push(b.endsWith(";") ? b : `${b};`), u && k.push(`text-align: ${u};`), Z({
|
|
737
|
+
..._,
|
|
738
|
+
class: m,
|
|
739
|
+
id: v,
|
|
740
|
+
...k.length > 0 ? { style: k.join(" ") } : {}
|
|
417
741
|
});
|
|
418
|
-
},
|
|
419
|
-
const
|
|
420
|
-
return
|
|
421
|
-
}, g = (
|
|
422
|
-
const { src:
|
|
423
|
-
let
|
|
424
|
-
if (
|
|
425
|
-
const { src:
|
|
426
|
-
|
|
742
|
+
}, h = (c) => (u, m) => {
|
|
743
|
+
const v = a(u.attrs);
|
|
744
|
+
return m.render(c, v, u.children || null);
|
|
745
|
+
}, g = (c, u) => {
|
|
746
|
+
const { src: m, alt: v, title: b, srcset: _, sizes: k } = c.attrs || {};
|
|
747
|
+
let f = m, d = {};
|
|
748
|
+
if (i) {
|
|
749
|
+
const { src: y, attrs: C } = Vt(m, i);
|
|
750
|
+
f = y, d = C;
|
|
427
751
|
}
|
|
428
|
-
const
|
|
429
|
-
src:
|
|
430
|
-
alt:
|
|
431
|
-
title:
|
|
432
|
-
srcset:
|
|
433
|
-
sizes:
|
|
434
|
-
...
|
|
752
|
+
const A = {
|
|
753
|
+
src: f,
|
|
754
|
+
alt: v,
|
|
755
|
+
title: b,
|
|
756
|
+
srcset: _,
|
|
757
|
+
sizes: k,
|
|
758
|
+
...d
|
|
435
759
|
};
|
|
436
|
-
return
|
|
437
|
-
},
|
|
438
|
-
const { level:
|
|
439
|
-
return
|
|
440
|
-
},
|
|
441
|
-
var
|
|
442
|
-
const
|
|
443
|
-
src: (
|
|
444
|
-
alt: (
|
|
760
|
+
return u.render("img", Z(A));
|
|
761
|
+
}, p = (c, u) => {
|
|
762
|
+
const { level: m, ...v } = c.attrs || {}, b = a(v);
|
|
763
|
+
return u.render(`h${m}`, b, c.children);
|
|
764
|
+
}, w = (c, u) => {
|
|
765
|
+
var m, v, b, _;
|
|
766
|
+
const k = u.render("img", {
|
|
767
|
+
src: (m = c.attrs) == null ? void 0 : m.fallbackImage,
|
|
768
|
+
alt: (v = c.attrs) == null ? void 0 : v.alt,
|
|
445
769
|
style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
|
|
446
770
|
draggable: "false",
|
|
447
771
|
loading: "lazy"
|
|
448
772
|
});
|
|
449
|
-
return
|
|
773
|
+
return u.render("span", {
|
|
450
774
|
"data-type": "emoji",
|
|
451
|
-
"data-name": (
|
|
452
|
-
"data-emoji": (
|
|
453
|
-
},
|
|
454
|
-
},
|
|
455
|
-
const { class:
|
|
456
|
-
class:
|
|
457
|
-
id:
|
|
458
|
-
style:
|
|
459
|
-
} :
|
|
460
|
-
return
|
|
461
|
-
},
|
|
462
|
-
const { marks:
|
|
463
|
-
if ("text" in
|
|
464
|
-
if (
|
|
465
|
-
...
|
|
466
|
-
text:
|
|
467
|
-
}),
|
|
468
|
-
...
|
|
469
|
-
children:
|
|
775
|
+
"data-name": (b = c.attrs) == null ? void 0 : b.name,
|
|
776
|
+
"data-emoji": (_ = c.attrs) == null ? void 0 : _.emoji
|
|
777
|
+
}, k);
|
|
778
|
+
}, I = (c, u) => u.render("pre", c.attrs || {}, u.render("code", {}, c.children || "")), E = (c, u = !1) => ({ text: m, attrs: v }, b) => {
|
|
779
|
+
const { class: _, id: k, ...f } = v || {}, d = u ? {
|
|
780
|
+
class: _,
|
|
781
|
+
id: k,
|
|
782
|
+
style: Dt(f) || void 0
|
|
783
|
+
} : v || {};
|
|
784
|
+
return b.render(c, Z(d), m);
|
|
785
|
+
}, $ = (c) => P(c), U = (c) => {
|
|
786
|
+
const { marks: u, ...m } = c;
|
|
787
|
+
if ("text" in c) {
|
|
788
|
+
if (u) return u.reduce((b, _) => $({
|
|
789
|
+
..._,
|
|
790
|
+
text: b
|
|
791
|
+
}), $({
|
|
792
|
+
...m,
|
|
793
|
+
children: m.children
|
|
470
794
|
}));
|
|
471
|
-
const
|
|
472
|
-
if (
|
|
473
|
-
const
|
|
474
|
-
t.set("txt",
|
|
795
|
+
const v = c.attrs || {};
|
|
796
|
+
if (o) {
|
|
797
|
+
const b = t.get("txt") || 0;
|
|
798
|
+
t.set("txt", b + 1), v.key = `txt-${b}`;
|
|
475
799
|
}
|
|
476
|
-
return
|
|
800
|
+
return s(m.text, v);
|
|
477
801
|
}
|
|
478
802
|
return "";
|
|
479
|
-
},
|
|
480
|
-
const { linktype:
|
|
481
|
-
let
|
|
482
|
-
switch (
|
|
483
|
-
case
|
|
484
|
-
case
|
|
485
|
-
|
|
803
|
+
}, J = (c, u) => {
|
|
804
|
+
const { linktype: m, href: v, anchor: b, ..._ } = c.attrs || {};
|
|
805
|
+
let k = "";
|
|
806
|
+
switch (m) {
|
|
807
|
+
case ie.ASSET:
|
|
808
|
+
case ie.URL:
|
|
809
|
+
k = v;
|
|
486
810
|
break;
|
|
487
|
-
case
|
|
488
|
-
|
|
811
|
+
case ie.EMAIL:
|
|
812
|
+
k = `mailto:${v}`;
|
|
489
813
|
break;
|
|
490
|
-
case
|
|
491
|
-
|
|
814
|
+
case ie.STORY:
|
|
815
|
+
k = v, b && (k = `${k}#${b}`);
|
|
492
816
|
break;
|
|
493
817
|
default:
|
|
494
|
-
|
|
818
|
+
k = v;
|
|
495
819
|
break;
|
|
496
820
|
}
|
|
497
|
-
const
|
|
498
|
-
return
|
|
499
|
-
},
|
|
500
|
-
var
|
|
501
|
-
return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),
|
|
502
|
-
blok: (
|
|
503
|
-
id: (
|
|
821
|
+
const f = { ..._ };
|
|
822
|
+
return k && (f.href = k), u.render("a", f, c.text);
|
|
823
|
+
}, K = (c, u) => {
|
|
824
|
+
var m, v;
|
|
825
|
+
return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), u.render("span", {
|
|
826
|
+
blok: (m = c == null ? void 0 : c.attrs) == null ? void 0 : m.body[0],
|
|
827
|
+
id: (v = c.attrs) == null ? void 0 : v.id,
|
|
504
828
|
style: "display: none"
|
|
505
829
|
});
|
|
506
|
-
},
|
|
507
|
-
const
|
|
508
|
-
return
|
|
509
|
-
},
|
|
510
|
-
const
|
|
511
|
-
return
|
|
512
|
-
},
|
|
513
|
-
const { colspan:
|
|
514
|
-
|
|
515
|
-
const
|
|
516
|
-
...
|
|
517
|
-
...
|
|
518
|
-
...
|
|
519
|
-
...
|
|
830
|
+
}, x = (c, u) => {
|
|
831
|
+
const m = a(c.attrs), v = c.children || null;
|
|
832
|
+
return u.render("table", m, u.render("tbody", {}, v));
|
|
833
|
+
}, j = (c, u) => {
|
|
834
|
+
const m = a(c.attrs);
|
|
835
|
+
return u.render("tr", m, c.children);
|
|
836
|
+
}, B = (c, u) => {
|
|
837
|
+
const { colspan: m, rowspan: v, colwidth: b, backgroundColor: _, textAlign: k, ...f } = c.attrs || {}, d = [];
|
|
838
|
+
b && d.push(`width: ${b}px;`), _ && d.push(`background-color: ${_};`), k && d.push(`text-align: ${k};`);
|
|
839
|
+
const A = {
|
|
840
|
+
...f,
|
|
841
|
+
...m > 1 ? { colspan: m } : {},
|
|
842
|
+
...v > 1 ? { rowspan: v } : {},
|
|
843
|
+
...d.length > 0 ? { style: d.join(" ") } : {}
|
|
520
844
|
};
|
|
521
|
-
return
|
|
522
|
-
},
|
|
523
|
-
const { colspan:
|
|
524
|
-
|
|
525
|
-
const
|
|
526
|
-
...
|
|
527
|
-
...
|
|
528
|
-
...
|
|
529
|
-
...
|
|
845
|
+
return u.render("td", Z(A), c.children);
|
|
846
|
+
}, ee = (c, u) => {
|
|
847
|
+
const { colspan: m, rowspan: v, colwidth: b, backgroundColor: _, textAlign: k, ...f } = c.attrs || {}, d = [];
|
|
848
|
+
b && d.push(`width: ${b}px;`), _ && d.push(`background-color: ${_};`), k && d.push(`text-align: ${k};`);
|
|
849
|
+
const A = {
|
|
850
|
+
...f,
|
|
851
|
+
...m > 1 ? { colspan: m } : {},
|
|
852
|
+
...v > 1 ? { rowspan: v } : {},
|
|
853
|
+
...d.length > 0 ? { style: d.join(" ") } : {}
|
|
530
854
|
};
|
|
531
|
-
return
|
|
532
|
-
},
|
|
533
|
-
[
|
|
534
|
-
[
|
|
535
|
-
[
|
|
536
|
-
[
|
|
537
|
-
[
|
|
538
|
-
[
|
|
539
|
-
[
|
|
540
|
-
[
|
|
541
|
-
[
|
|
542
|
-
[
|
|
543
|
-
[
|
|
544
|
-
[
|
|
545
|
-
[
|
|
546
|
-
[
|
|
547
|
-
[
|
|
548
|
-
[
|
|
549
|
-
[
|
|
550
|
-
[
|
|
551
|
-
[
|
|
552
|
-
[
|
|
553
|
-
[
|
|
554
|
-
[
|
|
555
|
-
[
|
|
556
|
-
[
|
|
557
|
-
[
|
|
558
|
-
[
|
|
559
|
-
[
|
|
560
|
-
[
|
|
561
|
-
[
|
|
562
|
-
[
|
|
563
|
-
]),
|
|
564
|
-
render: (
|
|
565
|
-
if (
|
|
566
|
-
const
|
|
567
|
-
t.set(
|
|
855
|
+
return u.render("th", Z(A), c.children);
|
|
856
|
+
}, V = /* @__PURE__ */ new Map([
|
|
857
|
+
[L.DOCUMENT, h("")],
|
|
858
|
+
[L.HEADING, p],
|
|
859
|
+
[L.PARAGRAPH, h("p")],
|
|
860
|
+
[L.UL_LIST, h("ul")],
|
|
861
|
+
[L.OL_LIST, h("ol")],
|
|
862
|
+
[L.LIST_ITEM, h("li")],
|
|
863
|
+
[L.IMAGE, g],
|
|
864
|
+
[L.EMOJI, w],
|
|
865
|
+
[L.CODE_BLOCK, I],
|
|
866
|
+
[L.HR, h("hr")],
|
|
867
|
+
[L.BR, h("br")],
|
|
868
|
+
[L.QUOTE, h("blockquote")],
|
|
869
|
+
[L.COMPONENT, K],
|
|
870
|
+
[Mt.TEXT, U],
|
|
871
|
+
[S.LINK, J],
|
|
872
|
+
[S.ANCHOR, J],
|
|
873
|
+
[S.STYLED, E("span", !0)],
|
|
874
|
+
[S.BOLD, E("strong")],
|
|
875
|
+
[S.TEXT_STYLE, E("span", !0)],
|
|
876
|
+
[S.ITALIC, E("em")],
|
|
877
|
+
[S.UNDERLINE, E("u")],
|
|
878
|
+
[S.STRIKE, E("s")],
|
|
879
|
+
[S.CODE, E("code")],
|
|
880
|
+
[S.SUPERSCRIPT, E("sup")],
|
|
881
|
+
[S.SUBSCRIPT, E("sub")],
|
|
882
|
+
[S.HIGHLIGHT, E("mark")],
|
|
883
|
+
[L.TABLE, x],
|
|
884
|
+
[L.TABLE_ROW, j],
|
|
885
|
+
[L.TABLE_CELL, B],
|
|
886
|
+
[L.TABLE_HEADER, ee]
|
|
887
|
+
]), F = new Map([...V, ...Object.entries(n).map(([c, u]) => [c, u])]), W = () => ({
|
|
888
|
+
render: (c, u = {}, m) => {
|
|
889
|
+
if (o && c) {
|
|
890
|
+
const v = t.get(c) || 0;
|
|
891
|
+
t.set(c, v + 1), u.key = `${c}-${v}`;
|
|
568
892
|
}
|
|
569
|
-
return
|
|
893
|
+
return r(c, u, m);
|
|
570
894
|
},
|
|
571
|
-
originalResolvers:
|
|
572
|
-
mergedResolvers:
|
|
895
|
+
originalResolvers: V,
|
|
896
|
+
mergedResolvers: F
|
|
573
897
|
});
|
|
574
|
-
function
|
|
575
|
-
const
|
|
576
|
-
if (!
|
|
577
|
-
return console.error("<Storyblok>", `No resolver found for node type ${
|
|
578
|
-
const
|
|
579
|
-
if (
|
|
580
|
-
const
|
|
581
|
-
return
|
|
582
|
-
...
|
|
583
|
-
children:
|
|
584
|
-
},
|
|
585
|
-
}
|
|
586
|
-
function
|
|
587
|
-
return
|
|
588
|
-
}
|
|
589
|
-
return { render:
|
|
898
|
+
function q(c) {
|
|
899
|
+
const u = F.get(c.type);
|
|
900
|
+
if (!u)
|
|
901
|
+
return console.error("<Storyblok>", `No resolver found for node type ${c.type}`), "";
|
|
902
|
+
const m = W();
|
|
903
|
+
if (c.type === "text") return u(c, m);
|
|
904
|
+
const v = c.content ? c.content.map(P) : void 0;
|
|
905
|
+
return u({
|
|
906
|
+
...c,
|
|
907
|
+
children: v
|
|
908
|
+
}, m);
|
|
909
|
+
}
|
|
910
|
+
function P(c) {
|
|
911
|
+
return c.type === "doc" ? l ? c.content.map(q) : c.content.map(q).join("") : Array.isArray(c) ? c.map(q) : q(c);
|
|
912
|
+
}
|
|
913
|
+
return { render: P };
|
|
590
914
|
}
|
|
591
|
-
let
|
|
592
|
-
const
|
|
915
|
+
let Pe = !1;
|
|
916
|
+
const Me = [], je = (e) => new Promise((t, r) => {
|
|
593
917
|
if (typeof window > "u") {
|
|
594
|
-
|
|
918
|
+
r(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));
|
|
595
919
|
return;
|
|
596
920
|
}
|
|
597
|
-
if (window.storyblokRegisterEvent = (
|
|
921
|
+
if (window.storyblokRegisterEvent = (n) => {
|
|
598
922
|
if (!window.location.search.includes("_storyblok")) {
|
|
599
923
|
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
600
924
|
return;
|
|
601
925
|
}
|
|
602
|
-
|
|
926
|
+
Pe ? n() : Me.push(n);
|
|
603
927
|
}, document.getElementById("storyblok-javascript-bridge")) {
|
|
604
928
|
t(void 0);
|
|
605
929
|
return;
|
|
606
930
|
}
|
|
607
|
-
const
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
}, document.getElementsByTagName("head")[0].appendChild(
|
|
611
|
-
}),
|
|
931
|
+
const s = document.createElement("script");
|
|
932
|
+
s.async = !0, s.src = e, s.id = "storyblok-javascript-bridge", s.onerror = (n) => r(n), s.onload = (n) => {
|
|
933
|
+
Me.forEach((i) => i()), Pe = !0, t(n);
|
|
934
|
+
}, document.getElementsByTagName("head")[0].appendChild(s);
|
|
935
|
+
}), pe = (e = "") => e.includes("/cdn/"), Bt = (e, t = 25, r = 1) => ({
|
|
612
936
|
...e,
|
|
613
937
|
per_page: t,
|
|
614
|
-
page:
|
|
615
|
-
}),
|
|
616
|
-
const
|
|
617
|
-
return
|
|
618
|
-
},
|
|
619
|
-
const
|
|
620
|
-
for (const
|
|
621
|
-
if (!Object.prototype.hasOwnProperty.call(e,
|
|
622
|
-
const
|
|
623
|
-
if (
|
|
624
|
-
const
|
|
938
|
+
page: r
|
|
939
|
+
}), Ft = (e) => new Promise((t) => setTimeout(t, e)), qt = (e = 0, t) => Array.from({ length: e }, t), Gt = (e = 0, t = e) => {
|
|
940
|
+
const r = Math.abs(t - e) || 0, s = e < t ? 1 : -1;
|
|
941
|
+
return qt(r, (n, i) => i * s + e);
|
|
942
|
+
}, zt = async (e, t) => Promise.all(e.map(t)), Jt = (e = [], t) => e.map(t).reduce((r, s) => [...r, ...s], []), ke = (e, t, r) => {
|
|
943
|
+
const s = [];
|
|
944
|
+
for (const n in e) {
|
|
945
|
+
if (!Object.prototype.hasOwnProperty.call(e, n)) continue;
|
|
946
|
+
const i = e[n];
|
|
947
|
+
if (i == null) continue;
|
|
948
|
+
const o = r ? "" : encodeURIComponent(n);
|
|
625
949
|
let l;
|
|
626
|
-
typeof
|
|
950
|
+
typeof i == "object" ? l = ke(i, t ? t + encodeURIComponent(`[${o}]`) : o, Array.isArray(i)) : l = `${t ? t + encodeURIComponent(`[${o}]`) : o}=${encodeURIComponent(i)}`, s.push(l);
|
|
627
951
|
}
|
|
628
|
-
return
|
|
629
|
-
},
|
|
952
|
+
return s.join("&");
|
|
953
|
+
}, Ne = (e) => {
|
|
630
954
|
const t = {
|
|
631
955
|
eu: "api.storyblok.com",
|
|
632
956
|
us: "api-us.storyblok.com",
|
|
@@ -636,9 +960,9 @@ const re = [], le = (e) => new Promise((t, s) => {
|
|
|
636
960
|
};
|
|
637
961
|
return t[e] ?? t.eu;
|
|
638
962
|
};
|
|
639
|
-
var
|
|
963
|
+
var Kt = class {
|
|
640
964
|
constructor(e) {
|
|
641
|
-
|
|
965
|
+
T(this, "baseURL"), T(this, "timeout"), T(this, "headers"), T(this, "responseInterceptor"), T(this, "fetch"), T(this, "ejectInterceptor"), T(this, "url"), T(this, "parameters"), T(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
966
|
}
|
|
643
967
|
/**
|
|
644
968
|
*
|
|
@@ -659,37 +983,37 @@ var Xe = class {
|
|
|
659
983
|
return this.url = e, this.parameters = t ?? {}, this._methodHandler("delete");
|
|
660
984
|
}
|
|
661
985
|
async _responseHandler(e) {
|
|
662
|
-
const t = [],
|
|
986
|
+
const t = [], r = {
|
|
663
987
|
data: {},
|
|
664
988
|
headers: {},
|
|
665
989
|
status: 0,
|
|
666
990
|
statusText: ""
|
|
667
991
|
};
|
|
668
|
-
e.status !== 204 && await e.json().then((
|
|
669
|
-
|
|
992
|
+
e.status !== 204 && await e.json().then((s) => {
|
|
993
|
+
r.data = s;
|
|
670
994
|
});
|
|
671
|
-
for (const
|
|
672
|
-
return
|
|
995
|
+
for (const s of e.headers.entries()) t[s[0]] = s[1];
|
|
996
|
+
return r.headers = { ...t }, r.status = e.status, r.statusText = e.statusText, r;
|
|
673
997
|
}
|
|
674
998
|
async _methodHandler(e) {
|
|
675
|
-
let t = `${this.baseURL}${this.url}`,
|
|
676
|
-
e === "get" ? t = `${this.baseURL}${this.url}?${
|
|
677
|
-
const
|
|
678
|
-
let
|
|
679
|
-
this.timeout && (
|
|
999
|
+
let t = `${this.baseURL}${this.url}`, r = null;
|
|
1000
|
+
e === "get" ? t = `${this.baseURL}${this.url}?${ke(this.parameters)}` : r = JSON.stringify(this.parameters);
|
|
1001
|
+
const s = new URL(t), n = new AbortController(), { signal: i } = n;
|
|
1002
|
+
let o = null;
|
|
1003
|
+
this.timeout && (o = setTimeout(() => n.abort(), this.timeout));
|
|
680
1004
|
try {
|
|
681
|
-
const l = await this.fetch(`${
|
|
1005
|
+
const l = await this.fetch(`${s}`, {
|
|
682
1006
|
method: e,
|
|
683
1007
|
headers: this.headers,
|
|
684
|
-
body:
|
|
685
|
-
signal:
|
|
1008
|
+
body: r,
|
|
1009
|
+
signal: i,
|
|
686
1010
|
...this.fetchOptions
|
|
687
1011
|
});
|
|
688
|
-
this.timeout &&
|
|
689
|
-
const
|
|
690
|
-
return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(
|
|
1012
|
+
this.timeout && o && clearTimeout(o);
|
|
1013
|
+
const a = await this._responseHandler(l);
|
|
1014
|
+
return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(a)) : this._statusHandler(a);
|
|
691
1015
|
} catch (l) {
|
|
692
|
-
return { message: l };
|
|
1016
|
+
return l.name === "AbortError" ? { message: "Request timeout: The request was aborted due to timeout" } : { message: l.message || l.toString() || "An unknown error occurred" };
|
|
693
1017
|
}
|
|
694
1018
|
}
|
|
695
1019
|
setFetchOptions(e = {}) {
|
|
@@ -717,119 +1041,119 @@ var Xe = class {
|
|
|
717
1041
|
}
|
|
718
1042
|
_statusHandler(e) {
|
|
719
1043
|
const t = /20[0-6]/g;
|
|
720
|
-
return new Promise((
|
|
721
|
-
if (t.test(`${e.status}`)) return
|
|
722
|
-
const
|
|
1044
|
+
return new Promise((r, s) => {
|
|
1045
|
+
if (t.test(`${e.status}`)) return r(e);
|
|
1046
|
+
const n = {
|
|
723
1047
|
message: this._normalizeErrorMessage(e.data),
|
|
724
1048
|
status: e.status,
|
|
725
1049
|
response: e
|
|
726
1050
|
};
|
|
727
|
-
|
|
1051
|
+
s(n);
|
|
728
1052
|
});
|
|
729
1053
|
}
|
|
730
|
-
},
|
|
731
|
-
const
|
|
1054
|
+
}, Wt = Kt;
|
|
1055
|
+
const He = "SB-Agent", me = {
|
|
732
1056
|
defaultAgentName: "SB-JS-CLIENT",
|
|
733
1057
|
defaultAgentVersion: "SB-Agent-Version",
|
|
734
1058
|
packageVersion: "7.0.0"
|
|
735
|
-
},
|
|
1059
|
+
}, Be = {
|
|
736
1060
|
DRAFT: "draft",
|
|
737
1061
|
PUBLISHED: "published"
|
|
738
|
-
},
|
|
1062
|
+
}, Yt = 25, ve = {
|
|
739
1063
|
SMALL: 25,
|
|
740
1064
|
MEDIUM: 50,
|
|
741
1065
|
LARGE: 75
|
|
742
|
-
},
|
|
1066
|
+
}, X = {
|
|
743
1067
|
SINGLE_OR_SMALL: 50,
|
|
744
1068
|
MEDIUM: 15,
|
|
745
1069
|
LARGE: 10,
|
|
746
1070
|
VERY_LARGE: 6
|
|
747
|
-
},
|
|
748
|
-
function
|
|
749
|
-
return e.version ===
|
|
1071
|
+
}, ye = 1e3, oe = 3;
|
|
1072
|
+
function Zt(e) {
|
|
1073
|
+
return e.version === Be.DRAFT;
|
|
750
1074
|
}
|
|
751
|
-
function
|
|
752
|
-
const
|
|
753
|
-
return
|
|
1075
|
+
function Xt(e, t) {
|
|
1076
|
+
const r = e.includes("/cdn/stories/"), s = e.split("/").length > 3 && !e.endsWith("/cdn/stories"), n = "find_by" in t;
|
|
1077
|
+
return r && s || n;
|
|
754
1078
|
}
|
|
755
|
-
function
|
|
756
|
-
return e <=
|
|
1079
|
+
function Qt(e) {
|
|
1080
|
+
return e <= ve.SMALL ? X.SINGLE_OR_SMALL : e <= ve.MEDIUM ? X.MEDIUM : e <= ve.LARGE ? X.LARGE : X.VERY_LARGE;
|
|
757
1081
|
}
|
|
758
|
-
function
|
|
759
|
-
if (
|
|
760
|
-
if (
|
|
761
|
-
if (
|
|
762
|
-
if (t && !
|
|
763
|
-
if (
|
|
764
|
-
const
|
|
765
|
-
return
|
|
1082
|
+
function ae(e, t, r = {}, s) {
|
|
1083
|
+
if (r.userRateLimit !== void 0) return Math.min(r.userRateLimit, ye);
|
|
1084
|
+
if (r.serverHeadersRateLimit !== void 0) return Math.min(r.serverHeadersRateLimit, ye);
|
|
1085
|
+
if (s !== void 0) return s;
|
|
1086
|
+
if (t && !Zt(t)) return ye;
|
|
1087
|
+
if (Xt(e, t)) return X.SINGLE_OR_SMALL;
|
|
1088
|
+
const n = t.per_page || Yt;
|
|
1089
|
+
return Qt(n);
|
|
766
1090
|
}
|
|
767
|
-
function
|
|
1091
|
+
function er(e) {
|
|
768
1092
|
if (!e) return null;
|
|
769
|
-
const t = e["x-ratelimit"] || e["X-RateLimit"],
|
|
770
|
-
if (!t && !
|
|
771
|
-
const
|
|
1093
|
+
const t = e["x-ratelimit"] || e["X-RateLimit"], r = e["x-ratelimit-policy"] || e["X-RateLimit-Policy"];
|
|
1094
|
+
if (!t && !r) return null;
|
|
1095
|
+
const s = {};
|
|
772
1096
|
if (t) {
|
|
773
|
-
const
|
|
774
|
-
|
|
1097
|
+
const n = t.match(/r=(\d+)/);
|
|
1098
|
+
n && (s.remaining = Number.parseInt(n[1], 10));
|
|
775
1099
|
}
|
|
776
|
-
if (
|
|
777
|
-
const
|
|
778
|
-
|
|
1100
|
+
if (r) {
|
|
1101
|
+
const n = r.match(/q=(\d+)/);
|
|
1102
|
+
n && (s.max = Number.parseInt(n[1], 10));
|
|
779
1103
|
}
|
|
780
|
-
return Object.keys(
|
|
1104
|
+
return Object.keys(s).length > 0 ? s : null;
|
|
781
1105
|
}
|
|
782
|
-
function
|
|
1106
|
+
function tr(e, t = !1) {
|
|
783
1107
|
return {
|
|
784
1108
|
userRateLimit: e,
|
|
785
1109
|
serverHeadersRateLimit: void 0,
|
|
786
1110
|
isManagementApi: t
|
|
787
1111
|
};
|
|
788
1112
|
}
|
|
789
|
-
var
|
|
1113
|
+
var rr = class extends Error {
|
|
790
1114
|
constructor(e) {
|
|
791
1115
|
super(e), this.name = "AbortError";
|
|
792
1116
|
}
|
|
793
1117
|
};
|
|
794
|
-
function
|
|
1118
|
+
function sr(e, t, r) {
|
|
795
1119
|
if (!Number.isFinite(t)) throw new TypeError("Expected `limit` to be a finite number");
|
|
796
|
-
if (!Number.isFinite(
|
|
797
|
-
const
|
|
798
|
-
let
|
|
1120
|
+
if (!Number.isFinite(r)) throw new TypeError("Expected `interval` to be a finite number");
|
|
1121
|
+
const s = [];
|
|
1122
|
+
let n = [], i = 0, o = !1;
|
|
799
1123
|
const l = async () => {
|
|
800
|
-
|
|
801
|
-
const
|
|
802
|
-
if (
|
|
803
|
-
const
|
|
804
|
-
|
|
805
|
-
} catch (
|
|
806
|
-
|
|
1124
|
+
i++;
|
|
1125
|
+
const h = s.shift();
|
|
1126
|
+
if (h) try {
|
|
1127
|
+
const p = await e(...h.args);
|
|
1128
|
+
h.resolve(p);
|
|
1129
|
+
} catch (p) {
|
|
1130
|
+
h.reject(p);
|
|
807
1131
|
}
|
|
808
1132
|
const g = setTimeout(() => {
|
|
809
|
-
|
|
810
|
-
},
|
|
811
|
-
|
|
812
|
-
},
|
|
813
|
-
|
|
1133
|
+
i--, s.length > 0 && l(), n = n.filter((p) => p !== g);
|
|
1134
|
+
}, r);
|
|
1135
|
+
n.includes(g) || n.push(g);
|
|
1136
|
+
}, a = (...h) => o ? Promise.reject(/* @__PURE__ */ new Error("Throttled function is already aborted and not accepting new promises")) : new Promise((g, p) => {
|
|
1137
|
+
s.push({
|
|
814
1138
|
resolve: g,
|
|
815
|
-
reject:
|
|
816
|
-
args:
|
|
817
|
-
}),
|
|
1139
|
+
reject: p,
|
|
1140
|
+
args: h
|
|
1141
|
+
}), i < t && l();
|
|
818
1142
|
});
|
|
819
|
-
return
|
|
820
|
-
|
|
821
|
-
},
|
|
1143
|
+
return a.abort = () => {
|
|
1144
|
+
o = !0, n.forEach(clearTimeout), n = [], s.forEach((h) => h.reject(() => new rr("Throttle function aborted"))), s.length = 0;
|
|
1145
|
+
}, a;
|
|
822
1146
|
}
|
|
823
|
-
var
|
|
1147
|
+
var nr = sr, ir = class {
|
|
824
1148
|
constructor(e, t = 1e3) {
|
|
825
|
-
|
|
1149
|
+
T(this, "queues"), T(this, "interval"), T(this, "throttledRequestFn"), this.queues = /* @__PURE__ */ new Map(), this.interval = t, this.throttledRequestFn = e;
|
|
826
1150
|
}
|
|
827
1151
|
/**
|
|
828
1152
|
* Gets or creates a throttle queue for the specified rate limit
|
|
829
1153
|
*/
|
|
830
1154
|
getQueue(e) {
|
|
831
1155
|
let t = this.queues.get(e);
|
|
832
|
-
return t || (t =
|
|
1156
|
+
return t || (t = nr(this.throttledRequestFn, e, this.interval), this.queues.set(e, t)), t;
|
|
833
1157
|
}
|
|
834
1158
|
/**
|
|
835
1159
|
* Executes a request through the appropriate throttle queue based on rate limit
|
|
@@ -853,73 +1177,73 @@ var lt = at, ct = class {
|
|
|
853
1177
|
return this.queues.size;
|
|
854
1178
|
}
|
|
855
1179
|
};
|
|
856
|
-
let
|
|
857
|
-
const
|
|
858
|
-
var
|
|
1180
|
+
let le = {};
|
|
1181
|
+
const D = {};
|
|
1182
|
+
var or = class {
|
|
859
1183
|
/**
|
|
860
1184
|
*
|
|
861
1185
|
* @param config ISbConfig interface
|
|
862
1186
|
* @param pEndpoint string, optional
|
|
863
1187
|
*/
|
|
864
1188
|
constructor(e, t) {
|
|
865
|
-
|
|
866
|
-
let
|
|
867
|
-
if (!
|
|
868
|
-
const
|
|
869
|
-
e.oauthToken ?
|
|
1189
|
+
T(this, "client"), T(this, "maxRetries"), T(this, "retriesDelay"), T(this, "throttleManager"), T(this, "accessToken"), T(this, "cache"), T(this, "resolveCounter"), T(this, "relations"), T(this, "links"), T(this, "version"), T(this, "rateLimitConfig"), T(this, "richTextResolver"), T(this, "resolveNestedRelations"), T(this, "stringifiedStoriesCache"), T(this, "inlineAssets");
|
|
1190
|
+
let r = e.endpoint || t;
|
|
1191
|
+
if (!r) {
|
|
1192
|
+
const n = e.https === !1 ? "http" : "https";
|
|
1193
|
+
e.oauthToken ? r = `${n}://${Ne(e.region)}/v1` : r = `${n}://${Ne(e.region)}/v2`;
|
|
870
1194
|
}
|
|
871
|
-
const
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
}),
|
|
875
|
-
baseURL:
|
|
1195
|
+
const s = new Headers();
|
|
1196
|
+
s.set("Content-Type", "application/json"), s.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([n, i]) => {
|
|
1197
|
+
s.set(n, i);
|
|
1198
|
+
}), s.has(He) || (s.set(He, me.defaultAgentName), s.set(me.defaultAgentVersion, me.packageVersion)), e.oauthToken && s.set("Authorization", e.oauthToken), this.rateLimitConfig = tr(e.rateLimit, !!e.oauthToken), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttleManager = new ir(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 || Be.PUBLISHED, this.inlineAssets = e.inlineAssets || !1, this.client = new Wt({
|
|
1199
|
+
baseURL: r,
|
|
876
1200
|
timeout: e.timeout || 0,
|
|
877
|
-
headers:
|
|
1201
|
+
headers: s,
|
|
878
1202
|
responseInterceptor: e.responseInterceptor,
|
|
879
1203
|
fetch: e.fetch
|
|
880
1204
|
});
|
|
881
1205
|
}
|
|
882
1206
|
parseParams(e) {
|
|
883
|
-
return e.token || (e.token = this.getToken()), e.cv || (e.cv =
|
|
1207
|
+
return e.token || (e.token = this.getToken()), e.cv || (e.cv = D[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
1208
|
}
|
|
885
1209
|
factoryParamOptions(e, t) {
|
|
886
|
-
return
|
|
1210
|
+
return pe(e) ? this.parseParams(t) : t;
|
|
887
1211
|
}
|
|
888
|
-
makeRequest(e, t,
|
|
889
|
-
const
|
|
890
|
-
return this.cacheResponse(e,
|
|
1212
|
+
makeRequest(e, t, r, s, n) {
|
|
1213
|
+
const i = this.factoryParamOptions(e, Bt(t, r, s));
|
|
1214
|
+
return this.cacheResponse(e, i, void 0, n);
|
|
891
1215
|
}
|
|
892
|
-
get(e, t = {},
|
|
1216
|
+
get(e, t = {}, r) {
|
|
893
1217
|
t || (t = {});
|
|
894
|
-
const
|
|
895
|
-
|
|
896
|
-
const
|
|
897
|
-
return this.cacheResponse(
|
|
1218
|
+
const s = `/${e}`;
|
|
1219
|
+
pe(s) && (t.version = t.version || this.version);
|
|
1220
|
+
const n = this.factoryParamOptions(s, t);
|
|
1221
|
+
return this.cacheResponse(s, n, void 0, r);
|
|
898
1222
|
}
|
|
899
|
-
async getAll(e, t = {},
|
|
900
|
-
const
|
|
1223
|
+
async getAll(e, t = {}, r, s) {
|
|
1224
|
+
const n = (t == null ? void 0 : t.per_page) || 25, i = `/${e}`.replace(/\/$/, ""), o = r ?? i.substring(i.lastIndexOf("/") + 1);
|
|
901
1225
|
t.version = t.version || this.version;
|
|
902
|
-
const l = 1,
|
|
903
|
-
return
|
|
1226
|
+
const l = 1, a = await this.makeRequest(i, t, n, l, s), h = a.total ? Math.ceil(a.total / (a.perPage || n)) : 1, g = await zt(Gt(l, h), (p) => this.makeRequest(i, t, n, p + 1, s));
|
|
1227
|
+
return Jt([a, ...g], (p) => Object.values(p.data[o]));
|
|
904
1228
|
}
|
|
905
|
-
post(e, t = {},
|
|
906
|
-
const
|
|
907
|
-
return this.throttleManager.execute(
|
|
1229
|
+
post(e, t = {}, r) {
|
|
1230
|
+
const s = `/${e}`, n = ae(void 0, void 0, this.rateLimitConfig, oe);
|
|
1231
|
+
return this.throttleManager.execute(n, "post", s, t, r);
|
|
908
1232
|
}
|
|
909
|
-
put(e, t = {},
|
|
910
|
-
const
|
|
911
|
-
return this.throttleManager.execute(
|
|
1233
|
+
put(e, t = {}, r) {
|
|
1234
|
+
const s = `/${e}`, n = ae(void 0, void 0, this.rateLimitConfig, oe);
|
|
1235
|
+
return this.throttleManager.execute(n, "put", s, t, r);
|
|
912
1236
|
}
|
|
913
|
-
delete(e, t = {},
|
|
1237
|
+
delete(e, t = {}, r) {
|
|
914
1238
|
t || (t = {});
|
|
915
|
-
const
|
|
916
|
-
return this.throttleManager.execute(
|
|
1239
|
+
const s = `/${e}`, n = ae(void 0, void 0, this.rateLimitConfig, oe);
|
|
1240
|
+
return this.throttleManager.execute(n, "delete", s, t, r);
|
|
917
1241
|
}
|
|
918
1242
|
getStories(e = {}, t) {
|
|
919
1243
|
return this._addResolveLevel(e), this.get("cdn/stories", e, t);
|
|
920
1244
|
}
|
|
921
|
-
getStory(e, t = {},
|
|
922
|
-
return this._addResolveLevel(t), this.get(`cdn/stories/${e}`, t,
|
|
1245
|
+
getStory(e, t = {}, r) {
|
|
1246
|
+
return this._addResolveLevel(t), this.get(`cdn/stories/${e}`, t, r);
|
|
923
1247
|
}
|
|
924
1248
|
getToken() {
|
|
925
1249
|
return this.accessToken;
|
|
@@ -933,9 +1257,9 @@ var ut = class {
|
|
|
933
1257
|
_cleanCopy(e) {
|
|
934
1258
|
return JSON.parse(JSON.stringify(e));
|
|
935
1259
|
}
|
|
936
|
-
_insertLinks(e, t,
|
|
937
|
-
const
|
|
938
|
-
|
|
1260
|
+
_insertLinks(e, t, r) {
|
|
1261
|
+
const s = e[t];
|
|
1262
|
+
s && s.fieldtype === "multilink" && s.linktype === "story" && typeof s.id == "string" && this.links[r][s.id] ? s.story = this._cleanCopy(this.links[r][s.id]) : s && s.linktype === "story" && typeof s.uuid == "string" && this.links[r][s.uuid] && (s.story = this._cleanCopy(this.links[r][s.uuid]));
|
|
939
1263
|
}
|
|
940
1264
|
/**
|
|
941
1265
|
*
|
|
@@ -956,9 +1280,9 @@ var ut = class {
|
|
|
956
1280
|
* - For single strings: directly replaces the UUID with the story reference
|
|
957
1281
|
* - For arrays: maps through each UUID and replaces with corresponding story references
|
|
958
1282
|
*/
|
|
959
|
-
_resolveField(e, t,
|
|
960
|
-
const
|
|
961
|
-
typeof
|
|
1283
|
+
_resolveField(e, t, r) {
|
|
1284
|
+
const s = e[t];
|
|
1285
|
+
typeof s == "string" ? e[t] = this.getStoryReference(r, s) : Array.isArray(s) && (e[t] = s.map((n) => this.getStoryReference(r, n)).filter(Boolean));
|
|
962
1286
|
}
|
|
963
1287
|
/**
|
|
964
1288
|
* Inserts relations into the JSON tree by resolving references
|
|
@@ -977,13 +1301,13 @@ var ut = class {
|
|
|
977
1301
|
* The method supports both string and array formats for the fields parameter,
|
|
978
1302
|
* allowing flexible specification of relation patterns.
|
|
979
1303
|
*/
|
|
980
|
-
_insertRelations(e, t,
|
|
981
|
-
if (Array.isArray(
|
|
982
|
-
this._resolveField(e, t,
|
|
1304
|
+
_insertRelations(e, t, r, s) {
|
|
1305
|
+
if (Array.isArray(r) ? r.find((i) => i.endsWith(`.${t}`)) : r.endsWith(`.${t}`)) {
|
|
1306
|
+
this._resolveField(e, t, s);
|
|
983
1307
|
return;
|
|
984
1308
|
}
|
|
985
|
-
const
|
|
986
|
-
(Array.isArray(
|
|
1309
|
+
const n = e.component ? `${e.component}.${t}` : t;
|
|
1310
|
+
(Array.isArray(r) ? r.includes(n) : r === n) && this._resolveField(e, t, s);
|
|
987
1311
|
}
|
|
988
1312
|
/**
|
|
989
1313
|
* Recursively traverses and resolves relations in the story content tree
|
|
@@ -991,68 +1315,68 @@ var ut = class {
|
|
|
991
1315
|
* @param fields - The relation patterns to resolve
|
|
992
1316
|
* @param resolveId - The unique identifier for the current resolution context
|
|
993
1317
|
*/
|
|
994
|
-
iterateTree(e, t,
|
|
995
|
-
const
|
|
996
|
-
if (!(!
|
|
997
|
-
if (Array.isArray(
|
|
998
|
-
else if (typeof
|
|
999
|
-
const l =
|
|
1000
|
-
(
|
|
1318
|
+
iterateTree(e, t, r) {
|
|
1319
|
+
const s = (n, i = "") => {
|
|
1320
|
+
if (!(!n || n._stopResolving)) {
|
|
1321
|
+
if (Array.isArray(n)) n.forEach((o, l) => s(o, `${i}[${l}]`));
|
|
1322
|
+
else if (typeof n == "object") for (const o in n) {
|
|
1323
|
+
const l = i ? `${i}.${o}` : o;
|
|
1324
|
+
(n.component && n._uid || n.type === "link") && (this._insertRelations(n, o, t, r), this._insertLinks(n, o, r)), s(n[o], l);
|
|
1001
1325
|
}
|
|
1002
1326
|
}
|
|
1003
1327
|
};
|
|
1004
|
-
|
|
1328
|
+
s(e.content);
|
|
1005
1329
|
}
|
|
1006
|
-
async resolveLinks(e, t,
|
|
1007
|
-
let
|
|
1330
|
+
async resolveLinks(e, t, r) {
|
|
1331
|
+
let s = [];
|
|
1008
1332
|
if (e.link_uuids) {
|
|
1009
|
-
const
|
|
1010
|
-
for (let l = 0; l <
|
|
1011
|
-
const
|
|
1012
|
-
|
|
1333
|
+
const n = e.link_uuids.length, i = [], o = 50;
|
|
1334
|
+
for (let l = 0; l < n; l += o) {
|
|
1335
|
+
const a = Math.min(n, l + o);
|
|
1336
|
+
i.push(e.link_uuids.slice(l, a));
|
|
1013
1337
|
}
|
|
1014
|
-
for (let l = 0; l <
|
|
1338
|
+
for (let l = 0; l < i.length; l++)
|
|
1015
1339
|
(await this.getStories({
|
|
1016
|
-
per_page:
|
|
1340
|
+
per_page: o,
|
|
1017
1341
|
language: t.language,
|
|
1018
1342
|
version: t.version,
|
|
1019
1343
|
starts_with: t.starts_with,
|
|
1020
|
-
by_uuids:
|
|
1021
|
-
})).data.stories.forEach((
|
|
1022
|
-
|
|
1344
|
+
by_uuids: i[l].join(",")
|
|
1345
|
+
})).data.stories.forEach((a) => {
|
|
1346
|
+
s.push(a);
|
|
1023
1347
|
});
|
|
1024
|
-
} else
|
|
1025
|
-
|
|
1026
|
-
this.links[
|
|
1027
|
-
...
|
|
1348
|
+
} else s = e.links;
|
|
1349
|
+
s.forEach((n) => {
|
|
1350
|
+
this.links[r][n.uuid] = {
|
|
1351
|
+
...n,
|
|
1028
1352
|
_stopResolving: !0
|
|
1029
1353
|
};
|
|
1030
1354
|
});
|
|
1031
1355
|
}
|
|
1032
|
-
async resolveRelations(e, t,
|
|
1033
|
-
let
|
|
1356
|
+
async resolveRelations(e, t, r) {
|
|
1357
|
+
let s = [];
|
|
1034
1358
|
if (e.rel_uuids) {
|
|
1035
|
-
const
|
|
1036
|
-
for (let l = 0; l <
|
|
1037
|
-
const
|
|
1038
|
-
|
|
1359
|
+
const n = e.rel_uuids.length, i = [], o = 50;
|
|
1360
|
+
for (let l = 0; l < n; l += o) {
|
|
1361
|
+
const a = Math.min(n, l + o);
|
|
1362
|
+
i.push(e.rel_uuids.slice(l, a));
|
|
1039
1363
|
}
|
|
1040
|
-
for (let l = 0; l <
|
|
1364
|
+
for (let l = 0; l < i.length; l++)
|
|
1041
1365
|
(await this.getStories({
|
|
1042
|
-
per_page:
|
|
1366
|
+
per_page: o,
|
|
1043
1367
|
language: t.language,
|
|
1044
1368
|
version: t.version,
|
|
1045
1369
|
starts_with: t.starts_with,
|
|
1046
|
-
by_uuids:
|
|
1370
|
+
by_uuids: i[l].join(","),
|
|
1047
1371
|
excluding_fields: t.excluding_fields
|
|
1048
|
-
})).data.stories.forEach((
|
|
1049
|
-
|
|
1372
|
+
})).data.stories.forEach((a) => {
|
|
1373
|
+
s.push(a);
|
|
1050
1374
|
});
|
|
1051
|
-
|
|
1052
|
-
} else
|
|
1053
|
-
|
|
1054
|
-
this.relations[
|
|
1055
|
-
...
|
|
1375
|
+
s.length > 0 && (e.rels = s, delete e.rel_uuids);
|
|
1376
|
+
} else s = e.rels;
|
|
1377
|
+
s && s.length > 0 && s.forEach((n) => {
|
|
1378
|
+
this.relations[r][n.uuid] = {
|
|
1379
|
+
...n,
|
|
1056
1380
|
_stopResolving: !0
|
|
1057
1381
|
};
|
|
1058
1382
|
});
|
|
@@ -1066,86 +1390,86 @@ var ut = class {
|
|
|
1066
1390
|
* @returns Promise<void>
|
|
1067
1391
|
*
|
|
1068
1392
|
*/
|
|
1069
|
-
async resolveStories(e, t,
|
|
1070
|
-
var
|
|
1071
|
-
let
|
|
1072
|
-
if (this.links[
|
|
1393
|
+
async resolveStories(e, t, r) {
|
|
1394
|
+
var s, n;
|
|
1395
|
+
let i = [];
|
|
1396
|
+
if (this.links[r] = {}, this.relations[r] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (i = t.resolve_relations.split(",")), await this.resolveRelations(e, t, r)), t.resolve_links && [
|
|
1073
1397
|
"1",
|
|
1074
1398
|
"story",
|
|
1075
1399
|
"url",
|
|
1076
1400
|
"link"
|
|
1077
|
-
].includes(t.resolve_links) && ((
|
|
1078
|
-
e.story ? this.iterateTree(e.story,
|
|
1079
|
-
this.iterateTree(
|
|
1080
|
-
}), this.stringifiedStoriesCache = {}, delete this.links[
|
|
1401
|
+
].includes(t.resolve_links) && ((s = e.links) != null && s.length || (n = e.link_uuids) != null && n.length) && await this.resolveLinks(e, t, r), this.resolveNestedRelations) for (const o in this.relations[r]) this.iterateTree(this.relations[r][o], i, r);
|
|
1402
|
+
e.story ? this.iterateTree(e.story, i, r) : e.stories.forEach((o) => {
|
|
1403
|
+
this.iterateTree(o, i, r);
|
|
1404
|
+
}), this.stringifiedStoriesCache = {}, delete this.links[r], delete this.relations[r];
|
|
1081
1405
|
}
|
|
1082
|
-
async cacheResponse(e, t,
|
|
1083
|
-
const
|
|
1406
|
+
async cacheResponse(e, t, r, s) {
|
|
1407
|
+
const n = ke({
|
|
1084
1408
|
url: e,
|
|
1085
1409
|
params: t
|
|
1086
|
-
}),
|
|
1410
|
+
}), i = this.cacheProvider();
|
|
1087
1411
|
if (t.version === "published" && e !== "/cdn/spaces/me") {
|
|
1088
|
-
const
|
|
1089
|
-
if (
|
|
1412
|
+
const a = await i.get(n);
|
|
1413
|
+
if (a) return Promise.resolve(a);
|
|
1090
1414
|
}
|
|
1091
|
-
const
|
|
1092
|
-
return new Promise(async (
|
|
1415
|
+
const o = !pe(e) && this.rateLimitConfig.isManagementApi ? oe : void 0, l = ae(e, t, this.rateLimitConfig, o);
|
|
1416
|
+
return new Promise(async (a, h) => {
|
|
1093
1417
|
var g;
|
|
1094
1418
|
try {
|
|
1095
|
-
const
|
|
1096
|
-
if (
|
|
1097
|
-
let
|
|
1098
|
-
data:
|
|
1099
|
-
headers:
|
|
1419
|
+
const p = await this.throttleManager.execute(l, "get", e, t, s);
|
|
1420
|
+
if (p.status !== 200) return h(p);
|
|
1421
|
+
let w = {
|
|
1422
|
+
data: p.data,
|
|
1423
|
+
headers: p.headers
|
|
1100
1424
|
};
|
|
1101
|
-
const
|
|
1102
|
-
if ((
|
|
1103
|
-
perPage:
|
|
1104
|
-
total:
|
|
1105
|
-
})),
|
|
1106
|
-
const
|
|
1107
|
-
await this.resolveStories(
|
|
1425
|
+
const I = er(p.headers);
|
|
1426
|
+
if ((I == null ? void 0 : I.max) !== void 0 && (this.rateLimitConfig.serverHeadersRateLimit = I.max), (g = p.headers) != null && g["per-page"] && (w = Object.assign({}, w, {
|
|
1427
|
+
perPage: p.headers["per-page"] ? Number.parseInt(p.headers["per-page"]) : 0,
|
|
1428
|
+
total: p.headers["per-page"] ? Number.parseInt(p.headers.total) : 0
|
|
1429
|
+
})), w.data.story || w.data.stories) {
|
|
1430
|
+
const $ = this.resolveCounter = ++this.resolveCounter % 1e3;
|
|
1431
|
+
await this.resolveStories(w.data, t, `${$}`), w = await this.processInlineAssets(w);
|
|
1108
1432
|
}
|
|
1109
|
-
t.version === "published" && e !== "/cdn/spaces/me" && await
|
|
1110
|
-
const
|
|
1111
|
-
return t.token &&
|
|
1112
|
-
} catch (
|
|
1113
|
-
if (
|
|
1114
|
-
return console.log(`Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`), await
|
|
1115
|
-
|
|
1433
|
+
t.version === "published" && e !== "/cdn/spaces/me" && await i.set(n, w);
|
|
1434
|
+
const E = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
|
|
1435
|
+
return t.token && w.data.cv && (E && D[t.token] && D[t.token] !== w.data.cv && await this.flushCache(), D[t.token] = w.data.cv), a(w);
|
|
1436
|
+
} catch (p) {
|
|
1437
|
+
if (p.response && p.status === 429 && (r = typeof r > "u" ? 0 : r + 1, r < this.maxRetries))
|
|
1438
|
+
return console.log(`Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`), await Ft(this.retriesDelay), this.cacheResponse(e, t, r).then(a).catch(h);
|
|
1439
|
+
h(p);
|
|
1116
1440
|
}
|
|
1117
1441
|
});
|
|
1118
1442
|
}
|
|
1119
|
-
throttledRequest(e, t,
|
|
1120
|
-
return this.client.setFetchOptions(
|
|
1443
|
+
throttledRequest(e, t, r, s) {
|
|
1444
|
+
return this.client.setFetchOptions(s), this.client[e](t, r);
|
|
1121
1445
|
}
|
|
1122
1446
|
cacheVersions() {
|
|
1123
|
-
return
|
|
1447
|
+
return D;
|
|
1124
1448
|
}
|
|
1125
1449
|
cacheVersion() {
|
|
1126
|
-
return
|
|
1450
|
+
return D[this.accessToken];
|
|
1127
1451
|
}
|
|
1128
1452
|
setCacheVersion(e) {
|
|
1129
|
-
this.accessToken && (
|
|
1453
|
+
this.accessToken && (D[this.accessToken] = e);
|
|
1130
1454
|
}
|
|
1131
1455
|
clearCacheVersion() {
|
|
1132
|
-
this.accessToken && (
|
|
1456
|
+
this.accessToken && (D[this.accessToken] = 0);
|
|
1133
1457
|
}
|
|
1134
1458
|
cacheProvider() {
|
|
1135
1459
|
switch (this.cache.type) {
|
|
1136
1460
|
case "memory":
|
|
1137
1461
|
return {
|
|
1138
1462
|
get(e) {
|
|
1139
|
-
return Promise.resolve(
|
|
1463
|
+
return Promise.resolve(le[e]);
|
|
1140
1464
|
},
|
|
1141
1465
|
getAll() {
|
|
1142
|
-
return Promise.resolve(
|
|
1466
|
+
return Promise.resolve(le);
|
|
1143
1467
|
},
|
|
1144
1468
|
set(e, t) {
|
|
1145
|
-
return
|
|
1469
|
+
return le[e] = t, Promise.resolve(void 0);
|
|
1146
1470
|
},
|
|
1147
1471
|
flush() {
|
|
1148
|
-
return
|
|
1472
|
+
return le = {}, Promise.resolve(void 0);
|
|
1149
1473
|
}
|
|
1150
1474
|
};
|
|
1151
1475
|
case "custom":
|
|
@@ -1172,21 +1496,21 @@ var ut = class {
|
|
|
1172
1496
|
}
|
|
1173
1497
|
async processInlineAssets(e) {
|
|
1174
1498
|
if (!this.inlineAssets) return e;
|
|
1175
|
-
const t = (
|
|
1176
|
-
if (!
|
|
1177
|
-
if (Array.isArray(
|
|
1178
|
-
let
|
|
1179
|
-
|
|
1180
|
-
...e.data.assets.find((
|
|
1181
|
-
...
|
|
1499
|
+
const t = (r) => {
|
|
1500
|
+
if (!r || typeof r != "object") return r;
|
|
1501
|
+
if (Array.isArray(r)) return r.map((n) => t(n));
|
|
1502
|
+
let s = { ...r };
|
|
1503
|
+
s.fieldtype === "asset" && Array.isArray(e.data.assets) && (s = {
|
|
1504
|
+
...e.data.assets.find((n) => n.id === s.id),
|
|
1505
|
+
...s
|
|
1182
1506
|
});
|
|
1183
|
-
for (const
|
|
1184
|
-
return
|
|
1507
|
+
for (const n in s) typeof s[n] == "object" && (s[n] = t(s[n]));
|
|
1508
|
+
return s;
|
|
1185
1509
|
};
|
|
1186
|
-
return e.data.story && (e.data.story.content = t(e.data.story.content)), e.data.stories && (e.data.stories = e.data.stories.map((
|
|
1510
|
+
return e.data.story && (e.data.story.content = t(e.data.story.content)), e.data.stories && (e.data.stories = e.data.stories.map((r) => (r.content = t(r.content), r))), e;
|
|
1187
1511
|
}
|
|
1188
|
-
},
|
|
1189
|
-
const
|
|
1512
|
+
}, ar = or;
|
|
1513
|
+
const mr = (e = {}) => {
|
|
1190
1514
|
const { apiOptions: t } = e;
|
|
1191
1515
|
if (!t || !t.accessToken) {
|
|
1192
1516
|
console.error(
|
|
@@ -1194,8 +1518,8 @@ const yt = (e = {}) => {
|
|
|
1194
1518
|
);
|
|
1195
1519
|
return;
|
|
1196
1520
|
}
|
|
1197
|
-
return { storyblokApi: new
|
|
1198
|
-
},
|
|
1521
|
+
return { storyblokApi: new ar(t) };
|
|
1522
|
+
}, vr = (e) => {
|
|
1199
1523
|
if (typeof e != "object" || typeof e._editable > "u")
|
|
1200
1524
|
return {};
|
|
1201
1525
|
try {
|
|
@@ -1210,39 +1534,42 @@ const yt = (e = {}) => {
|
|
|
1210
1534
|
return {};
|
|
1211
1535
|
}
|
|
1212
1536
|
};
|
|
1213
|
-
let
|
|
1214
|
-
const
|
|
1215
|
-
var t,
|
|
1537
|
+
let be = "https://app.storyblok.com/f/storyblok-v2-latest.js";
|
|
1538
|
+
const yr = (e = {}) => {
|
|
1539
|
+
var t, r;
|
|
1216
1540
|
const {
|
|
1217
|
-
bridge:
|
|
1218
|
-
accessToken:
|
|
1219
|
-
use:
|
|
1220
|
-
apiOptions:
|
|
1541
|
+
bridge: s,
|
|
1542
|
+
accessToken: n,
|
|
1543
|
+
use: i = [],
|
|
1544
|
+
apiOptions: o = {},
|
|
1221
1545
|
bridgeUrl: l
|
|
1222
1546
|
} = e;
|
|
1223
|
-
|
|
1224
|
-
const
|
|
1225
|
-
let
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
}), l && (
|
|
1229
|
-
const g = !(typeof window > "u") && ((
|
|
1230
|
-
return
|
|
1547
|
+
o.accessToken = o.accessToken || n;
|
|
1548
|
+
const a = { bridge: s, apiOptions: o };
|
|
1549
|
+
let h = {};
|
|
1550
|
+
i.forEach((p) => {
|
|
1551
|
+
h = { ...h, ...p(a) };
|
|
1552
|
+
}), l && (be = l);
|
|
1553
|
+
const g = !(typeof window > "u") && ((r = (t = window.location) == null ? void 0 : t.search) == null ? void 0 : r.includes("_storyblok_tk"));
|
|
1554
|
+
return s !== !1 && g && je(be), h;
|
|
1231
1555
|
};
|
|
1232
|
-
function
|
|
1233
|
-
return
|
|
1556
|
+
function gr(e, t) {
|
|
1557
|
+
return jt(t).render(e);
|
|
1234
1558
|
}
|
|
1235
|
-
const
|
|
1559
|
+
const br = () => je(be);
|
|
1236
1560
|
export {
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1561
|
+
mr as apiPlugin,
|
|
1562
|
+
cr as getLiveStory,
|
|
1563
|
+
ur as getPayload,
|
|
1564
|
+
fr as handleStoryblokMessage,
|
|
1565
|
+
pr as isEditorRequest,
|
|
1566
|
+
br as loadStoryblokBridge,
|
|
1567
|
+
gr as renderRichText,
|
|
1568
|
+
jt as richTextResolver,
|
|
1569
|
+
hr as sanitizeJSON,
|
|
1570
|
+
dr as storyblok,
|
|
1571
|
+
vr as storyblokEditable,
|
|
1572
|
+
yr as storyblokInit,
|
|
1573
|
+
tt as toCamelCase,
|
|
1574
|
+
lr as useStoryblokApi
|
|
1248
1575
|
};
|