@storyblok/astro 7.2.8 → 7.3.1
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/FallbackComponent.astro +1 -1
- package/dist/components/FallbackComponent.d.ts +3 -3
- package/dist/components/StoryblokComponent.astro +13 -12
- package/dist/dev-toolbar/toolbarApp.d.ts +1 -1
- package/dist/dev-toolbar/toolbarApp.ts +20 -30
- package/dist/index.d.ts +3 -0
- package/dist/lib/client.d.ts +2 -0
- package/dist/lib/client.ts +3 -0
- package/dist/lib/helpers.d.ts +35 -3
- package/dist/lib/richTextToHTML.d.ts +27 -0
- package/dist/lib/richTextToHTML.ts +103 -0
- package/dist/public.d.ts +71 -0
- package/dist/storyblok-astro.es.js +942 -344
- package/dist/storyblok-astro.umd.js +50 -20
- package/dist/utils/normalizeAstroExtension.d.ts +5 -0
- package/dist/utils/normalizePath.d.ts +16 -0
- package/dist/vite-plugins/vite-plugin-import-storyblok-components.d.ts +8 -0
- package/dist/vite-plugins/vite-plugin-storyblok-init.d.ts +1 -1
- package/dist/vite-plugins/vite-plugin-storyblok-options.d.ts +2 -1
- package/package.json +4 -7
- package/dist/components/StoryblokComponent.d.ts +0 -6
- package/dist/vite-plugins/vite-plugin-storyblok-components.d.ts +0 -2
|
@@ -1,138 +1,200 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
</g>
|
|
10
|
-
</svg>`, te = /[\p{Lu}]/u, re = /[\p{Ll}]/u, M = /^[\p{Lu}](?![\p{Lu}])/gu, z = /([\p{Alpha}\p{N}_]|$)/u, O = /[_.\- ]+/, oe = new RegExp("^" + O.source), P = new RegExp(O.source + z.source, "gu"), j = new RegExp("\\d+" + z.source, "gu"), se = (e, t, s, n) => {
|
|
11
|
-
let a = !1, o = !1, f = !1, y = !1;
|
|
12
|
-
for (let d = 0; d < e.length; d++) {
|
|
13
|
-
const u = e[d];
|
|
14
|
-
y = d > 2 ? e[d - 3] === "-" : !0, a && te.test(u) ? (e = e.slice(0, d) + "-" + e.slice(d), a = !1, f = o, o = !0, d++) : o && f && re.test(u) && (!y || n) ? (e = e.slice(0, d - 1) + "-" + e.slice(d - 1), f = o, o = !1, a = !0) : (a = t(u) === u && s(u) !== u, f = o, o = s(u) === u && t(u) !== u);
|
|
15
|
-
}
|
|
16
|
-
return e;
|
|
17
|
-
}, ne = (e, t) => (M.lastIndex = 0, e.replaceAll(M, (s) => t(s))), le = (e, t) => (P.lastIndex = 0, j.lastIndex = 0, e.replaceAll(j, (s, n, a) => ["_", "-"].includes(e.charAt(a + s.length)) ? s : t(s)).replaceAll(P, (s, n) => t(n)));
|
|
18
|
-
function ae(e, t) {
|
|
19
|
-
if (!(typeof e == "string" || Array.isArray(e)))
|
|
20
|
-
throw new TypeError("Expected the input to be `string | string[]`");
|
|
21
|
-
if (t = {
|
|
22
|
-
pascalCase: !1,
|
|
23
|
-
preserveConsecutiveUppercase: !1,
|
|
24
|
-
...t
|
|
25
|
-
}, Array.isArray(e) ? e = e.map((o) => o.trim()).filter((o) => o.length).join("-") : e = e.trim(), e.length === 0)
|
|
26
|
-
return "";
|
|
27
|
-
const s = t.locale === !1 ? (o) => o.toLowerCase() : (o) => o.toLocaleLowerCase(t.locale), n = t.locale === !1 ? (o) => o.toUpperCase() : (o) => o.toLocaleUpperCase(t.locale);
|
|
28
|
-
return e.length === 1 ? O.test(e) ? "" : t.pascalCase ? n(e) : s(e) : (e !== s(e) && (e = se(e, s, n, t.preserveConsecutiveUppercase)), e = e.replace(oe, ""), e = t.preserveConsecutiveUppercase ? ne(e, s) : s(e), t.pascalCase && (e = n(e.charAt(0)) + e.slice(1)), le(e, n));
|
|
29
|
-
}
|
|
30
|
-
function D(e) {
|
|
31
|
-
return ae(e);
|
|
32
|
-
}
|
|
33
|
-
function ie(e, t = {}, s, n) {
|
|
34
|
-
const a = "virtual:storyblok-components", o = `\0${a}`;
|
|
35
|
-
return {
|
|
36
|
-
name: "vite-plugin-storyblok-components",
|
|
37
|
-
async resolveId(f) {
|
|
38
|
-
if (f === a)
|
|
39
|
-
return o;
|
|
40
|
-
},
|
|
41
|
-
async load(f) {
|
|
42
|
-
if (f === o) {
|
|
43
|
-
const y = [], d = [];
|
|
44
|
-
for await (const [h, C] of Object.entries(t)) {
|
|
45
|
-
const L = await this.resolve(
|
|
46
|
-
`/${e}/${C}.astro`
|
|
47
|
-
);
|
|
48
|
-
if (L)
|
|
49
|
-
y.push(`import ${D(h)} from "${L.id}"`);
|
|
50
|
-
else if (s)
|
|
51
|
-
d.push(h);
|
|
52
|
-
else
|
|
53
|
-
throw new Error(
|
|
54
|
-
`Component could not be found for blok "${h}"! Does "${`/${e}/${C}`}.astro" exist?`
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
let u = "";
|
|
58
|
-
if (s)
|
|
59
|
-
if (u = ",FallbackComponent", n) {
|
|
60
|
-
const h = await this.resolve(
|
|
61
|
-
`/${e}/${n}.astro`
|
|
62
|
-
);
|
|
63
|
-
if (!h)
|
|
64
|
-
throw new Error(
|
|
65
|
-
`Custom fallback component could not be found. Does "${`/${e}/${n}`}.astro" exist?`
|
|
66
|
-
);
|
|
67
|
-
y.push(
|
|
68
|
-
`import FallbackComponent from "${h.id}"`
|
|
69
|
-
);
|
|
70
|
-
} else
|
|
71
|
-
y.push(
|
|
72
|
-
"import FallbackComponent from '@storyblok/astro/FallbackComponent.astro'"
|
|
73
|
-
);
|
|
74
|
-
if (Object.values(t).length)
|
|
75
|
-
return `${y.join(";")};export default {${Object.keys(t).filter((h) => !d.includes(h)).map((h) => D(h)).join(",")}${u}}`;
|
|
76
|
-
if (s)
|
|
77
|
-
return `${y[0]}; export default {${u.replace(",", "")}}`;
|
|
78
|
-
throw new Error(
|
|
79
|
-
`Currently, no Storyblok components are registered in astro.config.mjs.
|
|
80
|
-
Please register your components or enable the fallback component.
|
|
81
|
-
Detailed information can be found here: https://github.com/storyblok/storyblok-astro`
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
function ce(e, t, s) {
|
|
88
|
-
const n = "virtual:storyblok-init", a = `\0${n}`;
|
|
1
|
+
const de = `
|
|
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
|
+
<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
|
+
<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
|
+
</svg>
|
|
6
|
+
`;
|
|
7
|
+
function pe(e, t, r) {
|
|
8
|
+
const s = "virtual:storyblok-init", o = `\0${s}`;
|
|
89
9
|
return {
|
|
90
10
|
name: "vite-plugin-storyblok-init",
|
|
91
|
-
async resolveId(
|
|
92
|
-
if (
|
|
93
|
-
return
|
|
11
|
+
async resolveId(n) {
|
|
12
|
+
if (n === s)
|
|
13
|
+
return o;
|
|
94
14
|
},
|
|
95
|
-
async load(
|
|
96
|
-
if (
|
|
15
|
+
async load(n) {
|
|
16
|
+
if (n === o)
|
|
97
17
|
return `
|
|
98
|
-
import { storyblokInit, apiPlugin } from "@storyblok/
|
|
18
|
+
import { storyblokInit, apiPlugin } from "@storyblok/astro";
|
|
99
19
|
const { storyblokApi } = storyblokInit({
|
|
100
20
|
accessToken: "${e}",
|
|
101
21
|
use: ${t ? "[]" : "[apiPlugin]"},
|
|
102
|
-
apiOptions: ${JSON.stringify(
|
|
22
|
+
apiOptions: ${JSON.stringify(r)},
|
|
103
23
|
});
|
|
104
24
|
export const storyblokApiInstance = storyblokApi;
|
|
105
25
|
`;
|
|
106
26
|
}
|
|
107
27
|
};
|
|
108
28
|
}
|
|
109
|
-
function
|
|
110
|
-
const t = "virtual:storyblok-options",
|
|
29
|
+
function fe(e) {
|
|
30
|
+
const t = "virtual:storyblok-options", r = `\0${t}`;
|
|
111
31
|
return {
|
|
112
32
|
name: "vite-plugin-storyblok-options",
|
|
113
|
-
async resolveId(
|
|
114
|
-
if (
|
|
115
|
-
return
|
|
33
|
+
async resolveId(s) {
|
|
34
|
+
if (s === t)
|
|
35
|
+
return r;
|
|
116
36
|
},
|
|
117
|
-
async load(
|
|
118
|
-
if (
|
|
37
|
+
async load(s) {
|
|
38
|
+
if (s === r)
|
|
119
39
|
return `export default ${JSON.stringify(e)}`;
|
|
120
40
|
}
|
|
121
41
|
};
|
|
122
42
|
}
|
|
123
|
-
function
|
|
43
|
+
function et() {
|
|
124
44
|
if (!(globalThis != null && globalThis.storyblokApiInstance))
|
|
125
45
|
throw new Error("storyblokApiInstance has not been initialized correctly");
|
|
126
46
|
return globalThis.storyblokApiInstance;
|
|
127
47
|
}
|
|
128
|
-
async function
|
|
48
|
+
async function tt(e) {
|
|
129
49
|
let t = null;
|
|
130
50
|
return e && e.locals._storyblok_preview_data && (t = e.locals._storyblok_preview_data), t;
|
|
131
51
|
}
|
|
132
|
-
function
|
|
52
|
+
function me(e) {
|
|
133
53
|
return typeof e == "object" ? `const storyblokInstance = new StoryblokBridge(${JSON.stringify(e)});` : "const storyblokInstance = new StoryblokBridge();";
|
|
134
54
|
}
|
|
135
|
-
function
|
|
55
|
+
function ye(e) {
|
|
56
|
+
return e.endsWith(".astro") ? e : `${e}.astro`;
|
|
57
|
+
}
|
|
58
|
+
function N(e) {
|
|
59
|
+
return `/${e.trim().replace(/^\/+/, "").replace(/\/+$/, "").replace(/\/{2,}/g, "/")}`;
|
|
60
|
+
}
|
|
61
|
+
const be = /[\p{Lu}]/u, ge = /[\p{Ll}]/u, z = /^[\p{Lu}](?![\p{Lu}])/gu, te = /([\p{Alpha}\p{N}_]|$)/u, D = /[_.\- ]+/, Ce = new RegExp("^" + D.source), Z = new RegExp(D.source + te.source, "gu"), G = new RegExp("\\d+" + te.source, "gu"), ke = (e, t, r, s) => {
|
|
62
|
+
let o = !1, n = !1, i = !1, l = !1;
|
|
63
|
+
for (let c = 0; c < e.length; c++) {
|
|
64
|
+
const u = e[c];
|
|
65
|
+
l = c > 2 ? e[c - 3] === "-" : !0, o && be.test(u) ? (e = e.slice(0, c) + "-" + e.slice(c), o = !1, i = n, n = !0, c++) : n && i && ge.test(u) && (!l || s) ? (e = e.slice(0, c - 1) + "-" + e.slice(c - 1), i = n, n = !1, o = !0) : (o = t(u) === u && r(u) !== u, i = n, n = r(u) === u && t(u) !== u);
|
|
66
|
+
}
|
|
67
|
+
return e;
|
|
68
|
+
}, ve = (e, t) => (z.lastIndex = 0, e.replaceAll(z, (r) => t(r))), we = (e, t) => (Z.lastIndex = 0, G.lastIndex = 0, e.replaceAll(G, (r, s, o) => ["_", "-"].includes(e.charAt(o + r.length)) ? r : t(r)).replaceAll(Z, (r, s) => t(s)));
|
|
69
|
+
function Ae(e, t) {
|
|
70
|
+
if (!(typeof e == "string" || Array.isArray(e)))
|
|
71
|
+
throw new TypeError("Expected the input to be `string | string[]`");
|
|
72
|
+
if (t = {
|
|
73
|
+
pascalCase: !1,
|
|
74
|
+
preserveConsecutiveUppercase: !1,
|
|
75
|
+
...t
|
|
76
|
+
}, Array.isArray(e) ? e = e.map((n) => n.trim()).filter((n) => n.length).join("-") : e = e.trim(), e.length === 0)
|
|
77
|
+
return "";
|
|
78
|
+
const r = t.locale === !1 ? (n) => n.toLowerCase() : (n) => n.toLocaleLowerCase(t.locale), s = t.locale === !1 ? (n) => n.toUpperCase() : (n) => n.toLocaleUpperCase(t.locale);
|
|
79
|
+
return e.length === 1 ? D.test(e) ? "" : t.pascalCase ? s(e) : r(e) : (e !== r(e) && (e = ke(e, r, s, t.preserveConsecutiveUppercase)), e = e.replace(Ce, ""), e = t.preserveConsecutiveUppercase ? ve(e, r) : r(e), t.pascalCase && (e = s(e.charAt(0)) + e.slice(1)), we(e, s));
|
|
80
|
+
}
|
|
81
|
+
function $e(e) {
|
|
82
|
+
return Ae(e);
|
|
83
|
+
}
|
|
84
|
+
function Ee(e, t, r, s) {
|
|
85
|
+
const o = "virtual:import-storyblok-components", n = `\0${o}`;
|
|
86
|
+
return {
|
|
87
|
+
name: "vite-plugin-import-storyblok-components",
|
|
88
|
+
/**
|
|
89
|
+
* Resolves virtual module imports
|
|
90
|
+
*/
|
|
91
|
+
async resolveId(i) {
|
|
92
|
+
if (i === o)
|
|
93
|
+
return n;
|
|
94
|
+
},
|
|
95
|
+
/**
|
|
96
|
+
* Generates the virtual module content with dynamic imports
|
|
97
|
+
*/
|
|
98
|
+
async load(i) {
|
|
99
|
+
if (i !== n)
|
|
100
|
+
return;
|
|
101
|
+
const l = await Le(
|
|
102
|
+
this,
|
|
103
|
+
t,
|
|
104
|
+
r,
|
|
105
|
+
s
|
|
106
|
+
), c = await _e(
|
|
107
|
+
this,
|
|
108
|
+
e,
|
|
109
|
+
t,
|
|
110
|
+
r
|
|
111
|
+
);
|
|
112
|
+
return Te(
|
|
113
|
+
t,
|
|
114
|
+
l,
|
|
115
|
+
c
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function Te(e, t, r) {
|
|
121
|
+
const o = `${N(e)}/storyblok/**/*.astro`;
|
|
122
|
+
return `
|
|
123
|
+
// Import utilities and fallback component
|
|
124
|
+
import { toCamelCase } from '@storyblok/astro';
|
|
125
|
+
${t}
|
|
126
|
+
${r.join(`
|
|
127
|
+
`)}
|
|
128
|
+
|
|
129
|
+
// Dynamically import all Storyblok components using Vite's glob import
|
|
130
|
+
const modules = import.meta.glob('${o}', { eager: true });
|
|
131
|
+
// Process imported modules into a components object
|
|
132
|
+
const storyblokComponents = {};
|
|
133
|
+
|
|
134
|
+
for (const filePath in modules) {
|
|
135
|
+
// Extract component name from file path (remove extension)
|
|
136
|
+
const fileName = filePath.split('/').pop();
|
|
137
|
+
const componentName = fileName?.replace(/\\.[^/.]+$/, '');
|
|
138
|
+
|
|
139
|
+
if (componentName) {
|
|
140
|
+
// Get the component (handle both default and named exports)
|
|
141
|
+
const component = modules[filePath].default || modules[filePath];
|
|
142
|
+
|
|
143
|
+
// Convert filename to camelCase for Storyblok component naming
|
|
144
|
+
const camelCaseName = toCamelCase(componentName);
|
|
145
|
+
storyblokComponents[camelCaseName] = component;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Manual imports (overwrite auto if same key exists)
|
|
150
|
+
${r.map((n) => {
|
|
151
|
+
var l;
|
|
152
|
+
const i = (l = n.match(/import\s+(\w+)\s+from/)) == null ? void 0 : l[1];
|
|
153
|
+
return `storyblokComponents['${i}'] = ${i};`;
|
|
154
|
+
}).join(`
|
|
155
|
+
`)}
|
|
156
|
+
|
|
157
|
+
// Add fallback component if enabled
|
|
158
|
+
${t ? "storyblokComponents['FallbackComponent'] = FallbackComponent;" : ""}
|
|
159
|
+
|
|
160
|
+
// Export the components object for use in Storyblok initialization
|
|
161
|
+
export { storyblokComponents };
|
|
162
|
+
`.trim();
|
|
163
|
+
}
|
|
164
|
+
async function Le(e, t, r, s) {
|
|
165
|
+
if (!r)
|
|
166
|
+
return "";
|
|
167
|
+
if (s) {
|
|
168
|
+
const o = re(
|
|
169
|
+
t,
|
|
170
|
+
s
|
|
171
|
+
);
|
|
172
|
+
if (!await e.resolve(o))
|
|
173
|
+
throw new Error(
|
|
174
|
+
`Custom fallback component could not be found. Does "${o}" exist?`
|
|
175
|
+
);
|
|
176
|
+
return `import FallbackComponent from '${o}';`;
|
|
177
|
+
}
|
|
178
|
+
return "import FallbackComponent from '@storyblok/astro/FallbackComponent.astro';";
|
|
179
|
+
}
|
|
180
|
+
async function _e(e, t, r, s) {
|
|
181
|
+
const o = [];
|
|
182
|
+
for await (const [n, i] of Object.entries(t)) {
|
|
183
|
+
const l = re(r, i), c = await e.resolve(l);
|
|
184
|
+
if (c)
|
|
185
|
+
o.push(`import ${$e(n)} from "${c.id}"`);
|
|
186
|
+
else if (!s)
|
|
187
|
+
throw new Error(
|
|
188
|
+
`Component could not be found for blok "${n}"! Does "${l}" exist?`
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
return o;
|
|
192
|
+
}
|
|
193
|
+
function re(e, t) {
|
|
194
|
+
const s = `${N(e)}${N(t)}`;
|
|
195
|
+
return ye(s);
|
|
196
|
+
}
|
|
197
|
+
function rt(e) {
|
|
136
198
|
const t = {
|
|
137
199
|
useCustomApi: !1,
|
|
138
200
|
bridge: !0,
|
|
@@ -140,50 +202,56 @@ function Ae(e) {
|
|
|
140
202
|
enableFallbackComponent: !1,
|
|
141
203
|
livePreview: !1,
|
|
142
204
|
...e
|
|
143
|
-
},
|
|
205
|
+
}, {
|
|
206
|
+
accessToken: r,
|
|
207
|
+
useCustomApi: s,
|
|
208
|
+
apiOptions: o,
|
|
209
|
+
componentsDir: n,
|
|
210
|
+
customFallbackComponent: i,
|
|
211
|
+
enableFallbackComponent: l,
|
|
212
|
+
components: c,
|
|
213
|
+
bridge: u,
|
|
214
|
+
livePreview: f
|
|
215
|
+
} = t, m = me(t.bridge);
|
|
144
216
|
return {
|
|
145
217
|
name: "@storyblok/astro",
|
|
146
218
|
hooks: {
|
|
147
219
|
"astro:config:setup": ({
|
|
148
|
-
injectScript:
|
|
149
|
-
updateConfig:
|
|
150
|
-
addDevToolbarApp:
|
|
151
|
-
addMiddleware:
|
|
152
|
-
config:
|
|
220
|
+
injectScript: A,
|
|
221
|
+
updateConfig: _,
|
|
222
|
+
addDevToolbarApp: w,
|
|
223
|
+
addMiddleware: L,
|
|
224
|
+
config: S
|
|
153
225
|
}) => {
|
|
154
|
-
if (
|
|
226
|
+
if (_({
|
|
155
227
|
vite: {
|
|
156
228
|
plugins: [
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
t.componentsDir,
|
|
164
|
-
t.components,
|
|
165
|
-
t.enableFallbackComponent,
|
|
166
|
-
t.customFallbackComponent
|
|
229
|
+
pe(r, s, o),
|
|
230
|
+
Ee(
|
|
231
|
+
c || {},
|
|
232
|
+
n,
|
|
233
|
+
l,
|
|
234
|
+
i
|
|
167
235
|
),
|
|
168
|
-
|
|
236
|
+
fe(t)
|
|
169
237
|
]
|
|
170
238
|
}
|
|
171
|
-
}),
|
|
239
|
+
}), f && (S == null ? void 0 : S.output) !== "server")
|
|
172
240
|
throw new Error(
|
|
173
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."
|
|
174
242
|
);
|
|
175
|
-
|
|
243
|
+
A(
|
|
176
244
|
"page-ssr",
|
|
177
245
|
`
|
|
178
246
|
import { storyblokApiInstance } from "virtual:storyblok-init";
|
|
179
247
|
globalThis.storyblokApiInstance = storyblokApiInstance;
|
|
180
248
|
`
|
|
181
|
-
),
|
|
249
|
+
), u && !f && A(
|
|
182
250
|
"page",
|
|
183
251
|
`import { loadStoryblokBridge } from "@storyblok/astro";
|
|
184
252
|
loadStoryblokBridge().then(() => {
|
|
185
253
|
const { StoryblokBridge, location } = window;
|
|
186
|
-
${
|
|
254
|
+
${m}
|
|
187
255
|
storyblokInstance.on(["published", "change"], (event) => {
|
|
188
256
|
if (!event.slugChanged) {
|
|
189
257
|
location.reload(true);
|
|
@@ -191,54 +259,55 @@ function Ae(e) {
|
|
|
191
259
|
});
|
|
192
260
|
});
|
|
193
261
|
`
|
|
194
|
-
),
|
|
262
|
+
), f && (A(
|
|
195
263
|
"page",
|
|
196
264
|
`import { loadStoryblokBridge, handleStoryblokMessage } from "@storyblok/astro";
|
|
197
265
|
loadStoryblokBridge().then(() => {
|
|
198
266
|
const { StoryblokBridge, location } = window;
|
|
199
|
-
${
|
|
267
|
+
${m}
|
|
200
268
|
storyblokInstance.on(["published", "change", "input"], handleStoryblokMessage);
|
|
201
269
|
});
|
|
202
270
|
`
|
|
203
|
-
),
|
|
271
|
+
), L({
|
|
204
272
|
entrypoint: "@storyblok/astro/middleware.ts",
|
|
205
273
|
order: "pre"
|
|
206
|
-
})),
|
|
274
|
+
})), w({
|
|
207
275
|
id: "storyblok",
|
|
208
276
|
name: "Storyblok",
|
|
209
|
-
icon:
|
|
277
|
+
icon: de,
|
|
210
278
|
entrypoint: "@storyblok/astro/toolbarApp.ts"
|
|
211
279
|
});
|
|
212
280
|
}
|
|
213
281
|
}
|
|
214
282
|
};
|
|
215
283
|
}
|
|
216
|
-
let
|
|
217
|
-
async function
|
|
218
|
-
const { action: t, story:
|
|
219
|
-
if (t === "input" &&
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
|
|
284
|
+
let J;
|
|
285
|
+
async function st(e) {
|
|
286
|
+
const { action: t, story: r } = e || {};
|
|
287
|
+
if (t === "input" && r) {
|
|
288
|
+
const s = async () => {
|
|
289
|
+
q("storyblok-live-preview-updating", { story: r });
|
|
290
|
+
const n = await Ie(r), i = document.body;
|
|
291
|
+
if (n.outerHTML === i.outerHTML)
|
|
223
292
|
return;
|
|
224
|
-
const
|
|
225
|
-
|
|
293
|
+
const l = document.querySelector('[data-blok-focused="true"]');
|
|
294
|
+
Se(i, n, l), q("storyblok-live-preview-updated", { story: r });
|
|
226
295
|
};
|
|
227
|
-
clearTimeout(
|
|
296
|
+
clearTimeout(J), J = setTimeout(s, 500);
|
|
228
297
|
}
|
|
229
298
|
["published", "change"].includes(e == null ? void 0 : e.action) && location.reload();
|
|
230
299
|
}
|
|
231
|
-
function
|
|
232
|
-
if (
|
|
233
|
-
const
|
|
234
|
-
`[data-blok-uid="${
|
|
300
|
+
function Se(e, t, r) {
|
|
301
|
+
if (r) {
|
|
302
|
+
const s = r.getAttribute("data-blok-uid"), o = t.querySelector(
|
|
303
|
+
`[data-blok-uid="${s}"]`
|
|
235
304
|
);
|
|
236
|
-
|
|
305
|
+
o && (o.setAttribute("data-blok-focused", "true"), r.replaceWith(o));
|
|
237
306
|
} else
|
|
238
307
|
e.replaceWith(t);
|
|
239
308
|
}
|
|
240
|
-
async function
|
|
241
|
-
const
|
|
309
|
+
async function Ie(e) {
|
|
310
|
+
const r = await (await fetch(location.href, {
|
|
242
311
|
method: "POST",
|
|
243
312
|
body: JSON.stringify({
|
|
244
313
|
...e,
|
|
@@ -248,18 +317,22 @@ async function be(e) {
|
|
|
248
317
|
"Content-Type": "application/json"
|
|
249
318
|
}
|
|
250
319
|
})).text();
|
|
251
|
-
return new DOMParser().parseFromString(
|
|
320
|
+
return new DOMParser().parseFromString(r, "text/html").body;
|
|
252
321
|
}
|
|
322
|
+
function q(e, t) {
|
|
323
|
+
document.dispatchEvent(new CustomEvent(e, { detail: t }));
|
|
324
|
+
}
|
|
325
|
+
var Re = Object.defineProperty, Oe = (e, t, r) => t in e ? Re(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, g = (e, t, r) => Oe(e, typeof t != "symbol" ? t + "" : t, r);
|
|
253
326
|
let k = /* @__PURE__ */ function(e) {
|
|
254
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;
|
|
255
|
-
}({}),
|
|
328
|
+
}({}), $ = /* @__PURE__ */ function(e) {
|
|
256
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;
|
|
257
|
-
}({}),
|
|
330
|
+
}({}), Pe = /* @__PURE__ */ function(e) {
|
|
258
331
|
return e.TEXT = "text", e;
|
|
259
|
-
}({}),
|
|
332
|
+
}({}), P = /* @__PURE__ */ function(e) {
|
|
260
333
|
return e.URL = "url", e.STORY = "story", e.ASSET = "asset", e.EMAIL = "email", e;
|
|
261
334
|
}({});
|
|
262
|
-
const
|
|
335
|
+
const xe = [
|
|
263
336
|
"area",
|
|
264
337
|
"base",
|
|
265
338
|
"br",
|
|
@@ -274,262 +347,767 @@ const fe = [
|
|
|
274
347
|
"source",
|
|
275
348
|
"track",
|
|
276
349
|
"wbr"
|
|
277
|
-
],
|
|
278
|
-
function
|
|
350
|
+
], He = (e = {}) => Object.keys(e).map((t) => `${t}="${e[t]}"`).join(" "), je = (e = {}) => Object.keys(e).map((t) => `${t}: ${e[t]}`).join("; ");
|
|
351
|
+
function Ne(e) {
|
|
279
352
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
280
353
|
}
|
|
281
|
-
const
|
|
282
|
-
function
|
|
354
|
+
const R = (e) => Object.fromEntries(Object.entries(e).filter(([t, r]) => r !== void 0));
|
|
355
|
+
function Me(e, t) {
|
|
283
356
|
if (!t) return {
|
|
284
357
|
src: e,
|
|
285
358
|
attrs: {}
|
|
286
359
|
};
|
|
287
|
-
let
|
|
288
|
-
const
|
|
289
|
-
function
|
|
290
|
-
typeof
|
|
360
|
+
let r = 0, s = 0;
|
|
361
|
+
const o = {}, n = [];
|
|
362
|
+
function i(c, u, f, m, A) {
|
|
363
|
+
typeof c != "number" || c <= u || c >= f ? console.warn(`[StoryblokRichText] - ${m.charAt(0).toUpperCase() + m.slice(1)} value must be a number between ${u} and ${f} (inclusive)`) : A.push(`${m}(${c})`);
|
|
291
364
|
}
|
|
292
365
|
if (typeof t == "object") {
|
|
293
|
-
if (typeof t.width == "number" && t.width > 0 ? (
|
|
294
|
-
const { filters:
|
|
295
|
-
u &&
|
|
366
|
+
if (typeof t.width == "number" && t.width > 0 ? (o.width = t.width, r = t.width) : console.warn("[StoryblokRichText] - Width value must be a number greater than 0"), t.height && typeof t.height == "number" && t.height > 0 ? (o.height = t.height, s = t.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than 0"), t.loading && ["lazy", "eager"].includes(t.loading) && (o.loading = t.loading), t.class && (o.class = t.class), t.filters) {
|
|
367
|
+
const { filters: c } = t || {}, { blur: u, brightness: f, fill: m, format: A, grayscale: _, quality: w, rotate: L } = c || {};
|
|
368
|
+
u && i(u, 0, 100, "blur", n), w && i(w, 0, 100, "quality", n), f && i(f, 0, 100, "brightness", n), m && n.push(`fill(${m})`), _ && n.push("grayscale()"), L && [
|
|
296
369
|
0,
|
|
297
370
|
90,
|
|
298
371
|
180,
|
|
299
372
|
270
|
|
300
|
-
].includes(t.filters.rotate || 0) &&
|
|
373
|
+
].includes(t.filters.rotate || 0) && n.push(`rotate(${L})`), A && [
|
|
301
374
|
"webp",
|
|
302
375
|
"png",
|
|
303
376
|
"jpeg"
|
|
304
|
-
].includes(
|
|
377
|
+
].includes(A) && n.push(`format(${A})`);
|
|
305
378
|
}
|
|
306
|
-
t.srcset && (
|
|
307
|
-
if (typeof
|
|
308
|
-
if (Array.isArray(
|
|
309
|
-
const [u,
|
|
310
|
-
return `${e}/m/${u}x${
|
|
379
|
+
t.srcset && (o.srcset = t.srcset.map((c) => {
|
|
380
|
+
if (typeof c == "number") return `${e}/m/${c}x0/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${c}w`;
|
|
381
|
+
if (Array.isArray(c) && c.length === 2) {
|
|
382
|
+
const [u, f] = c;
|
|
383
|
+
return `${e}/m/${u}x${f}/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${u}w`;
|
|
311
384
|
} else {
|
|
312
385
|
console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
|
|
313
386
|
return;
|
|
314
387
|
}
|
|
315
|
-
}).join(", ")), t.sizes && (
|
|
388
|
+
}).join(", ")), t.sizes && (o.sizes = t.sizes.join(", "));
|
|
316
389
|
}
|
|
317
|
-
let
|
|
318
|
-
return
|
|
319
|
-
src:
|
|
320
|
-
attrs:
|
|
390
|
+
let l = `${e}/m/`;
|
|
391
|
+
return r > 0 && s > 0 && (l = `${l}${r}x${s}/`), n.length > 0 && (l = `${l}filters:${n.join(":")}`), {
|
|
392
|
+
src: l,
|
|
393
|
+
attrs: o
|
|
321
394
|
};
|
|
322
395
|
}
|
|
323
|
-
function
|
|
324
|
-
const
|
|
396
|
+
function W(e, t = {}, r) {
|
|
397
|
+
const s = He(t), o = s ? `${e} ${s}` : e, n = Array.isArray(r) ? r.join("") : r || "";
|
|
325
398
|
if (e) {
|
|
326
|
-
if (
|
|
327
|
-
} else return
|
|
328
|
-
return `<${
|
|
399
|
+
if (xe.includes(e)) return `<${o}>`;
|
|
400
|
+
} else return n;
|
|
401
|
+
return `<${o}>${n}</${e}>`;
|
|
329
402
|
}
|
|
330
|
-
function
|
|
331
|
-
const t = /* @__PURE__ */ new Map(), { renderFn:
|
|
332
|
-
const { textAlign:
|
|
333
|
-
return
|
|
334
|
-
...
|
|
335
|
-
class:
|
|
336
|
-
id:
|
|
403
|
+
function De(e = {}) {
|
|
404
|
+
const t = /* @__PURE__ */ new Map(), { renderFn: r = W, textFn: s = Ne, resolvers: o = {}, optimizeImages: n = !1, keyedResolvers: i = !1 } = e, l = r !== W, c = (a = {}) => {
|
|
405
|
+
const { textAlign: h, class: d, id: p, style: y, ...C } = a, b = [];
|
|
406
|
+
return y && b.push(y.endsWith(";") ? y : `${y};`), h && b.push(`text-align: ${h};`), R({
|
|
407
|
+
...C,
|
|
408
|
+
class: d,
|
|
409
|
+
id: p,
|
|
337
410
|
...b.length > 0 ? { style: b.join(" ") } : {}
|
|
338
411
|
});
|
|
339
|
-
}, u = (
|
|
340
|
-
const
|
|
341
|
-
return
|
|
342
|
-
},
|
|
343
|
-
const { src:
|
|
344
|
-
let E =
|
|
345
|
-
if (
|
|
346
|
-
const { src:
|
|
347
|
-
E =
|
|
412
|
+
}, u = (a) => (h, d) => {
|
|
413
|
+
const p = c(h.attrs);
|
|
414
|
+
return d.render(a, p, h.children || null);
|
|
415
|
+
}, f = (a, h) => {
|
|
416
|
+
const { src: d, alt: p, title: y, srcset: C, sizes: b } = a.attrs || {};
|
|
417
|
+
let E = d, v = {};
|
|
418
|
+
if (n) {
|
|
419
|
+
const { src: ue, attrs: he } = Me(d, n);
|
|
420
|
+
E = ue, v = he;
|
|
348
421
|
}
|
|
349
|
-
const
|
|
422
|
+
const I = {
|
|
350
423
|
src: E,
|
|
351
|
-
alt:
|
|
352
|
-
title:
|
|
353
|
-
srcset:
|
|
424
|
+
alt: p,
|
|
425
|
+
title: y,
|
|
426
|
+
srcset: C,
|
|
354
427
|
sizes: b,
|
|
355
|
-
...
|
|
428
|
+
...v
|
|
356
429
|
};
|
|
357
|
-
return
|
|
358
|
-
},
|
|
359
|
-
const { level:
|
|
360
|
-
return
|
|
361
|
-
},
|
|
362
|
-
var
|
|
363
|
-
const b =
|
|
364
|
-
src: (
|
|
365
|
-
alt: (
|
|
430
|
+
return h.render("img", R(I));
|
|
431
|
+
}, m = (a, h) => {
|
|
432
|
+
const { level: d, ...p } = a.attrs || {}, y = c(p);
|
|
433
|
+
return h.render(`h${d}`, y, a.children);
|
|
434
|
+
}, A = (a, h) => {
|
|
435
|
+
var d, p, y, C;
|
|
436
|
+
const b = h.render("img", {
|
|
437
|
+
src: (d = a.attrs) == null ? void 0 : d.fallbackImage,
|
|
438
|
+
alt: (p = a.attrs) == null ? void 0 : p.alt,
|
|
366
439
|
style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
|
|
367
440
|
draggable: "false",
|
|
368
441
|
loading: "lazy"
|
|
369
442
|
});
|
|
370
|
-
return
|
|
443
|
+
return h.render("span", {
|
|
371
444
|
"data-type": "emoji",
|
|
372
|
-
"data-name": (
|
|
373
|
-
"data-emoji": (
|
|
445
|
+
"data-name": (y = a.attrs) == null ? void 0 : y.name,
|
|
446
|
+
"data-emoji": (C = a.attrs) == null ? void 0 : C.emoji
|
|
374
447
|
}, b);
|
|
375
|
-
},
|
|
376
|
-
const { class:
|
|
377
|
-
class:
|
|
448
|
+
}, _ = (a, h) => h.render("pre", a.attrs || {}, h.render("code", {}, a.children || "")), w = (a, h = !1) => ({ text: d, attrs: p }, y) => {
|
|
449
|
+
const { class: C, id: b, ...E } = p || {}, v = h ? {
|
|
450
|
+
class: C,
|
|
378
451
|
id: b,
|
|
379
|
-
style:
|
|
380
|
-
} :
|
|
381
|
-
return
|
|
382
|
-
},
|
|
383
|
-
const { marks:
|
|
384
|
-
if ("text" in
|
|
385
|
-
if (
|
|
386
|
-
...
|
|
387
|
-
text:
|
|
388
|
-
}),
|
|
389
|
-
...
|
|
390
|
-
children:
|
|
452
|
+
style: je(E) || void 0
|
|
453
|
+
} : p || {};
|
|
454
|
+
return y.render(a, R(v), d);
|
|
455
|
+
}, L = (a) => H(a), S = (a) => {
|
|
456
|
+
const { marks: h, ...d } = a;
|
|
457
|
+
if ("text" in a) {
|
|
458
|
+
if (h) return h.reduce((y, C) => L({
|
|
459
|
+
...C,
|
|
460
|
+
text: y
|
|
461
|
+
}), L({
|
|
462
|
+
...d,
|
|
463
|
+
children: d.children
|
|
391
464
|
}));
|
|
392
|
-
const
|
|
393
|
-
if (
|
|
394
|
-
const
|
|
395
|
-
t.set("txt",
|
|
465
|
+
const p = a.attrs || {};
|
|
466
|
+
if (i) {
|
|
467
|
+
const y = t.get("txt") || 0;
|
|
468
|
+
t.set("txt", y + 1), p.key = `txt-${y}`;
|
|
396
469
|
}
|
|
397
|
-
return
|
|
470
|
+
return s(d.text, p);
|
|
398
471
|
}
|
|
399
472
|
return "";
|
|
400
|
-
},
|
|
401
|
-
const { linktype:
|
|
473
|
+
}, V = (a, h) => {
|
|
474
|
+
const { linktype: d, href: p, anchor: y, ...C } = a.attrs || {};
|
|
402
475
|
let b = "";
|
|
403
|
-
switch (
|
|
404
|
-
case
|
|
405
|
-
case
|
|
406
|
-
b =
|
|
476
|
+
switch (d) {
|
|
477
|
+
case P.ASSET:
|
|
478
|
+
case P.URL:
|
|
479
|
+
b = p;
|
|
407
480
|
break;
|
|
408
|
-
case
|
|
409
|
-
b = `mailto:${
|
|
481
|
+
case P.EMAIL:
|
|
482
|
+
b = `mailto:${p}`;
|
|
410
483
|
break;
|
|
411
|
-
case
|
|
412
|
-
b =
|
|
484
|
+
case P.STORY:
|
|
485
|
+
b = p, y && (b = `${b}#${y}`);
|
|
413
486
|
break;
|
|
414
487
|
default:
|
|
415
|
-
b =
|
|
488
|
+
b = p;
|
|
416
489
|
break;
|
|
417
490
|
}
|
|
418
|
-
const E = { ...
|
|
419
|
-
return b && (E.href = b),
|
|
420
|
-
},
|
|
421
|
-
var
|
|
422
|
-
return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),
|
|
423
|
-
blok: (
|
|
424
|
-
id: (
|
|
491
|
+
const E = { ...C };
|
|
492
|
+
return b && (E.href = b), h.render("a", E, a.text);
|
|
493
|
+
}, oe = (a, h) => {
|
|
494
|
+
var d, p;
|
|
495
|
+
return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), h.render("span", {
|
|
496
|
+
blok: (d = a == null ? void 0 : a.attrs) == null ? void 0 : d.body[0],
|
|
497
|
+
id: (p = a.attrs) == null ? void 0 : p.id,
|
|
425
498
|
style: "display: none"
|
|
426
499
|
});
|
|
427
|
-
},
|
|
428
|
-
const
|
|
429
|
-
return
|
|
430
|
-
},
|
|
431
|
-
const
|
|
432
|
-
return
|
|
433
|
-
},
|
|
434
|
-
const { colspan:
|
|
435
|
-
|
|
436
|
-
const
|
|
500
|
+
}, ne = (a, h) => {
|
|
501
|
+
const d = c(a.attrs), p = a.children || null;
|
|
502
|
+
return h.render("table", d, h.render("tbody", {}, p));
|
|
503
|
+
}, ie = (a, h) => {
|
|
504
|
+
const d = c(a.attrs);
|
|
505
|
+
return h.render("tr", d, a.children);
|
|
506
|
+
}, ae = (a, h) => {
|
|
507
|
+
const { colspan: d, rowspan: p, colwidth: y, backgroundColor: C, textAlign: b, ...E } = a.attrs || {}, v = [];
|
|
508
|
+
y && v.push(`width: ${y}px;`), C && v.push(`background-color: ${C};`), b && v.push(`text-align: ${b};`);
|
|
509
|
+
const I = {
|
|
437
510
|
...E,
|
|
438
|
-
...
|
|
439
|
-
...
|
|
440
|
-
...
|
|
511
|
+
...d > 1 ? { colspan: d } : {},
|
|
512
|
+
...p > 1 ? { rowspan: p } : {},
|
|
513
|
+
...v.length > 0 ? { style: v.join(" ") } : {}
|
|
441
514
|
};
|
|
442
|
-
return
|
|
443
|
-
},
|
|
444
|
-
const { colspan:
|
|
445
|
-
|
|
446
|
-
const
|
|
515
|
+
return h.render("td", R(I), a.children);
|
|
516
|
+
}, le = (a, h) => {
|
|
517
|
+
const { colspan: d, rowspan: p, colwidth: y, backgroundColor: C, textAlign: b, ...E } = a.attrs || {}, v = [];
|
|
518
|
+
y && v.push(`width: ${y}px;`), C && v.push(`background-color: ${C};`), b && v.push(`text-align: ${b};`);
|
|
519
|
+
const I = {
|
|
447
520
|
...E,
|
|
448
|
-
...
|
|
449
|
-
...
|
|
450
|
-
...
|
|
521
|
+
...d > 1 ? { colspan: d } : {},
|
|
522
|
+
...p > 1 ? { rowspan: p } : {},
|
|
523
|
+
...v.length > 0 ? { style: v.join(" ") } : {}
|
|
451
524
|
};
|
|
452
|
-
return
|
|
525
|
+
return h.render("th", R(I), a.children);
|
|
453
526
|
}, B = /* @__PURE__ */ new Map([
|
|
454
527
|
[k.DOCUMENT, u("")],
|
|
455
|
-
[k.HEADING,
|
|
528
|
+
[k.HEADING, m],
|
|
456
529
|
[k.PARAGRAPH, u("p")],
|
|
457
530
|
[k.UL_LIST, u("ul")],
|
|
458
531
|
[k.OL_LIST, u("ol")],
|
|
459
532
|
[k.LIST_ITEM, u("li")],
|
|
460
|
-
[k.IMAGE,
|
|
461
|
-
[k.EMOJI,
|
|
462
|
-
[k.CODE_BLOCK,
|
|
533
|
+
[k.IMAGE, f],
|
|
534
|
+
[k.EMOJI, A],
|
|
535
|
+
[k.CODE_BLOCK, _],
|
|
463
536
|
[k.HR, u("hr")],
|
|
464
537
|
[k.BR, u("br")],
|
|
465
538
|
[k.QUOTE, u("blockquote")],
|
|
466
|
-
[k.COMPONENT,
|
|
467
|
-
[
|
|
468
|
-
[
|
|
469
|
-
[
|
|
470
|
-
[
|
|
471
|
-
[
|
|
472
|
-
[
|
|
473
|
-
[
|
|
474
|
-
[
|
|
475
|
-
[
|
|
476
|
-
[
|
|
477
|
-
[
|
|
478
|
-
[
|
|
479
|
-
[
|
|
480
|
-
[k.TABLE,
|
|
481
|
-
[k.TABLE_ROW,
|
|
482
|
-
[k.TABLE_CELL,
|
|
483
|
-
[k.TABLE_HEADER,
|
|
484
|
-
]),
|
|
485
|
-
render: (
|
|
486
|
-
if (
|
|
487
|
-
const
|
|
488
|
-
t.set(
|
|
539
|
+
[k.COMPONENT, oe],
|
|
540
|
+
[Pe.TEXT, S],
|
|
541
|
+
[$.LINK, V],
|
|
542
|
+
[$.ANCHOR, V],
|
|
543
|
+
[$.STYLED, w("span", !0)],
|
|
544
|
+
[$.BOLD, w("strong")],
|
|
545
|
+
[$.TEXT_STYLE, w("span", !0)],
|
|
546
|
+
[$.ITALIC, w("em")],
|
|
547
|
+
[$.UNDERLINE, w("u")],
|
|
548
|
+
[$.STRIKE, w("s")],
|
|
549
|
+
[$.CODE, w("code")],
|
|
550
|
+
[$.SUPERSCRIPT, w("sup")],
|
|
551
|
+
[$.SUBSCRIPT, w("sub")],
|
|
552
|
+
[$.HIGHLIGHT, w("mark")],
|
|
553
|
+
[k.TABLE, ne],
|
|
554
|
+
[k.TABLE_ROW, ie],
|
|
555
|
+
[k.TABLE_CELL, ae],
|
|
556
|
+
[k.TABLE_HEADER, le]
|
|
557
|
+
]), F = new Map([...B, ...Object.entries(o).map(([a, h]) => [a, h])]), ce = () => ({
|
|
558
|
+
render: (a, h = {}, d) => {
|
|
559
|
+
if (i && a) {
|
|
560
|
+
const p = t.get(a) || 0;
|
|
561
|
+
t.set(a, p + 1), h.key = `${a}-${p}`;
|
|
489
562
|
}
|
|
490
|
-
return
|
|
563
|
+
return r(a, h, d);
|
|
491
564
|
},
|
|
492
565
|
originalResolvers: B,
|
|
493
|
-
mergedResolvers:
|
|
566
|
+
mergedResolvers: F
|
|
494
567
|
});
|
|
495
|
-
function
|
|
496
|
-
const
|
|
497
|
-
if (!
|
|
498
|
-
return console.error("<Storyblok>", `No resolver found for node type ${
|
|
499
|
-
const
|
|
500
|
-
if (
|
|
501
|
-
const
|
|
502
|
-
return
|
|
503
|
-
...
|
|
504
|
-
children:
|
|
505
|
-
},
|
|
506
|
-
}
|
|
507
|
-
function
|
|
508
|
-
return
|
|
509
|
-
}
|
|
510
|
-
return { render:
|
|
568
|
+
function O(a) {
|
|
569
|
+
const h = F.get(a.type);
|
|
570
|
+
if (!h)
|
|
571
|
+
return console.error("<Storyblok>", `No resolver found for node type ${a.type}`), "";
|
|
572
|
+
const d = ce();
|
|
573
|
+
if (a.type === "text") return h(a, d);
|
|
574
|
+
const p = a.content ? a.content.map(H) : void 0;
|
|
575
|
+
return h({
|
|
576
|
+
...a,
|
|
577
|
+
children: p
|
|
578
|
+
}, d);
|
|
579
|
+
}
|
|
580
|
+
function H(a) {
|
|
581
|
+
return a.type === "doc" ? l ? a.content.map(O) : a.content.map(O).join("") : Array.isArray(a) ? a.map(O) : O(a);
|
|
582
|
+
}
|
|
583
|
+
return { render: H };
|
|
511
584
|
}
|
|
512
|
-
let
|
|
513
|
-
const
|
|
585
|
+
let Y = !1;
|
|
586
|
+
const K = [], se = (e) => new Promise((t, r) => {
|
|
514
587
|
if (typeof window > "u") {
|
|
515
|
-
|
|
588
|
+
r(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));
|
|
516
589
|
return;
|
|
517
590
|
}
|
|
518
|
-
if (window.storyblokRegisterEvent = (
|
|
591
|
+
if (window.storyblokRegisterEvent = (o) => {
|
|
519
592
|
if (!window.location.search.includes("_storyblok")) {
|
|
520
593
|
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
521
594
|
return;
|
|
522
595
|
}
|
|
523
|
-
|
|
596
|
+
Y ? o() : K.push(o);
|
|
524
597
|
}, document.getElementById("storyblok-javascript-bridge")) {
|
|
525
598
|
t(void 0);
|
|
526
599
|
return;
|
|
527
600
|
}
|
|
528
|
-
const
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
}, document.getElementsByTagName("head")[0].appendChild(
|
|
532
|
-
})
|
|
601
|
+
const s = document.createElement("script");
|
|
602
|
+
s.async = !0, s.src = e, s.id = "storyblok-javascript-bridge", s.onerror = (o) => r(o), s.onload = (o) => {
|
|
603
|
+
K.forEach((n) => n()), Y = !0, t(o);
|
|
604
|
+
}, document.getElementsByTagName("head")[0].appendChild(s);
|
|
605
|
+
});
|
|
606
|
+
var Ue = class extends Error {
|
|
607
|
+
constructor(e) {
|
|
608
|
+
super(e), this.name = "AbortError";
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
function Ve(e, t, r) {
|
|
612
|
+
if (!Number.isFinite(t)) throw new TypeError("Expected `limit` to be a finite number");
|
|
613
|
+
if (!Number.isFinite(r)) throw new TypeError("Expected `interval` to be a finite number");
|
|
614
|
+
const s = [];
|
|
615
|
+
let o = [], n = 0, i = !1;
|
|
616
|
+
const l = async () => {
|
|
617
|
+
n++;
|
|
618
|
+
const u = s.shift();
|
|
619
|
+
if (u) try {
|
|
620
|
+
const m = await e(...u.args);
|
|
621
|
+
u.resolve(m);
|
|
622
|
+
} catch (m) {
|
|
623
|
+
u.reject(m);
|
|
624
|
+
}
|
|
625
|
+
const f = setTimeout(() => {
|
|
626
|
+
n--, s.length > 0 && l(), o = o.filter((m) => m !== f);
|
|
627
|
+
}, r);
|
|
628
|
+
o.includes(f) || o.push(f);
|
|
629
|
+
}, c = (...u) => i ? Promise.reject(/* @__PURE__ */ new Error("Throttled function is already aborted and not accepting new promises")) : new Promise((f, m) => {
|
|
630
|
+
s.push({
|
|
631
|
+
resolve: f,
|
|
632
|
+
reject: m,
|
|
633
|
+
args: u
|
|
634
|
+
}), n < t && l();
|
|
635
|
+
});
|
|
636
|
+
return c.abort = () => {
|
|
637
|
+
i = !0, o.forEach(clearTimeout), o = [], s.forEach((u) => u.reject(() => new Ue("Throttle function aborted"))), s.length = 0;
|
|
638
|
+
}, c;
|
|
639
|
+
}
|
|
640
|
+
var Be = Ve;
|
|
641
|
+
const X = (e = "") => e.includes("/cdn/"), Fe = (e, t = 25, r = 1) => ({
|
|
642
|
+
...e,
|
|
643
|
+
per_page: t,
|
|
644
|
+
page: r
|
|
645
|
+
}), ze = (e) => new Promise((t) => setTimeout(t, e)), Ze = (e = 0, t) => Array.from({ length: e }, t), Ge = (e = 0, t = e) => {
|
|
646
|
+
const r = Math.abs(t - e) || 0, s = e < t ? 1 : -1;
|
|
647
|
+
return Ze(r, (o, n) => n * s + e);
|
|
648
|
+
}, Je = async (e, t) => Promise.all(e.map(t)), qe = (e = [], t) => e.map(t).reduce((r, s) => [...r, ...s], []), U = (e, t, r) => {
|
|
649
|
+
const s = [];
|
|
650
|
+
for (const o in e) {
|
|
651
|
+
if (!Object.prototype.hasOwnProperty.call(e, o)) continue;
|
|
652
|
+
const n = e[o];
|
|
653
|
+
if (n == null) continue;
|
|
654
|
+
const i = r ? "" : encodeURIComponent(o);
|
|
655
|
+
let l;
|
|
656
|
+
typeof n == "object" ? l = U(n, t ? t + encodeURIComponent(`[${i}]`) : i, Array.isArray(n)) : l = `${t ? t + encodeURIComponent(`[${i}]`) : i}=${encodeURIComponent(n)}`, s.push(l);
|
|
657
|
+
}
|
|
658
|
+
return s.join("&");
|
|
659
|
+
}, Q = (e) => {
|
|
660
|
+
const t = {
|
|
661
|
+
eu: "api.storyblok.com",
|
|
662
|
+
us: "api-us.storyblok.com",
|
|
663
|
+
cn: "app.storyblokchina.cn",
|
|
664
|
+
ap: "api-ap.storyblok.com",
|
|
665
|
+
ca: "api-ca.storyblok.com"
|
|
666
|
+
};
|
|
667
|
+
return t[e] ?? t.eu;
|
|
668
|
+
};
|
|
669
|
+
var We = class {
|
|
670
|
+
constructor(e) {
|
|
671
|
+
g(this, "baseURL"), g(this, "timeout"), g(this, "headers"), g(this, "responseInterceptor"), g(this, "fetch"), g(this, "ejectInterceptor"), g(this, "url"), g(this, "parameters"), g(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 = {};
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
*
|
|
675
|
+
* @param url string
|
|
676
|
+
* @param params ISbStoriesParams
|
|
677
|
+
* @returns Promise<ISbResponse | Error>
|
|
678
|
+
*/
|
|
679
|
+
get(e, t) {
|
|
680
|
+
return this.url = e, this.parameters = t, this._methodHandler("get");
|
|
681
|
+
}
|
|
682
|
+
post(e, t) {
|
|
683
|
+
return this.url = e, this.parameters = t, this._methodHandler("post");
|
|
684
|
+
}
|
|
685
|
+
put(e, t) {
|
|
686
|
+
return this.url = e, this.parameters = t, this._methodHandler("put");
|
|
687
|
+
}
|
|
688
|
+
delete(e, t) {
|
|
689
|
+
return this.url = e, this.parameters = t ?? {}, this._methodHandler("delete");
|
|
690
|
+
}
|
|
691
|
+
async _responseHandler(e) {
|
|
692
|
+
const t = [], r = {
|
|
693
|
+
data: {},
|
|
694
|
+
headers: {},
|
|
695
|
+
status: 0,
|
|
696
|
+
statusText: ""
|
|
697
|
+
};
|
|
698
|
+
e.status !== 204 && await e.json().then((s) => {
|
|
699
|
+
r.data = s;
|
|
700
|
+
});
|
|
701
|
+
for (const s of e.headers.entries()) t[s[0]] = s[1];
|
|
702
|
+
return r.headers = { ...t }, r.status = e.status, r.statusText = e.statusText, r;
|
|
703
|
+
}
|
|
704
|
+
async _methodHandler(e) {
|
|
705
|
+
let t = `${this.baseURL}${this.url}`, r = null;
|
|
706
|
+
e === "get" ? t = `${this.baseURL}${this.url}?${U(this.parameters)}` : r = JSON.stringify(this.parameters);
|
|
707
|
+
const s = new URL(t), o = new AbortController(), { signal: n } = o;
|
|
708
|
+
let i;
|
|
709
|
+
this.timeout && (i = setTimeout(() => o.abort(), this.timeout));
|
|
710
|
+
try {
|
|
711
|
+
const l = await this.fetch(`${s}`, {
|
|
712
|
+
method: e,
|
|
713
|
+
headers: this.headers,
|
|
714
|
+
body: r,
|
|
715
|
+
signal: n,
|
|
716
|
+
...this.fetchOptions
|
|
717
|
+
});
|
|
718
|
+
this.timeout && clearTimeout(i);
|
|
719
|
+
const c = await this._responseHandler(l);
|
|
720
|
+
return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(c)) : this._statusHandler(c);
|
|
721
|
+
} catch (l) {
|
|
722
|
+
return { message: l };
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
setFetchOptions(e = {}) {
|
|
726
|
+
Object.keys(e).length > 0 && "method" in e && delete e.method, this.fetchOptions = { ...e };
|
|
727
|
+
}
|
|
728
|
+
eject() {
|
|
729
|
+
this.ejectInterceptor = !0;
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
* Normalizes error messages from different response structures
|
|
733
|
+
* @param data The response data that might contain error information
|
|
734
|
+
* @returns A normalized error message string
|
|
735
|
+
*/
|
|
736
|
+
_normalizeErrorMessage(e) {
|
|
737
|
+
if (Array.isArray(e)) return e[0] || "Unknown error";
|
|
738
|
+
if (e && typeof e == "object") {
|
|
739
|
+
if (e.error) return e.error;
|
|
740
|
+
for (const t in e) {
|
|
741
|
+
if (Array.isArray(e[t])) return `${t}: ${e[t][0]}`;
|
|
742
|
+
if (typeof e[t] == "string") return `${t}: ${e[t]}`;
|
|
743
|
+
}
|
|
744
|
+
if (e.slug) return e.slug;
|
|
745
|
+
}
|
|
746
|
+
return "Unknown error";
|
|
747
|
+
}
|
|
748
|
+
_statusHandler(e) {
|
|
749
|
+
const t = /20[0-6]/g;
|
|
750
|
+
return new Promise((r, s) => {
|
|
751
|
+
if (t.test(`${e.status}`)) return r(e);
|
|
752
|
+
const o = {
|
|
753
|
+
message: this._normalizeErrorMessage(e.data),
|
|
754
|
+
status: e.status,
|
|
755
|
+
response: e
|
|
756
|
+
};
|
|
757
|
+
s(o);
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
}, Ye = We;
|
|
761
|
+
const ee = "SB-Agent", j = {
|
|
762
|
+
defaultAgentName: "SB-JS-CLIENT",
|
|
763
|
+
defaultAgentVersion: "SB-Agent-Version",
|
|
764
|
+
packageVersion: "7.0.0"
|
|
765
|
+
}, Ke = {
|
|
766
|
+
PUBLISHED: "published"
|
|
767
|
+
};
|
|
768
|
+
let x = {};
|
|
769
|
+
const T = {};
|
|
770
|
+
var Xe = class {
|
|
771
|
+
/**
|
|
772
|
+
*
|
|
773
|
+
* @param config ISbConfig interface
|
|
774
|
+
* @param pEndpoint string, optional
|
|
775
|
+
*/
|
|
776
|
+
constructor(e, t) {
|
|
777
|
+
g(this, "client"), g(this, "maxRetries"), g(this, "retriesDelay"), g(this, "throttle"), g(this, "accessToken"), g(this, "cache"), g(this, "resolveCounter"), g(this, "relations"), g(this, "links"), g(this, "version"), g(this, "richTextResolver"), g(this, "resolveNestedRelations"), g(this, "stringifiedStoriesCache"), g(this, "inlineAssets");
|
|
778
|
+
let r = e.endpoint || t;
|
|
779
|
+
if (!r) {
|
|
780
|
+
const n = e.https === !1 ? "http" : "https";
|
|
781
|
+
e.oauthToken ? r = `${n}://${Q(e.region)}/v1` : r = `${n}://${Q(e.region)}/v2`;
|
|
782
|
+
}
|
|
783
|
+
const s = new Headers();
|
|
784
|
+
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]) => {
|
|
785
|
+
s.set(n, i);
|
|
786
|
+
}), s.has(ee) || (s.set(ee, j.defaultAgentName), s.set(j.defaultAgentVersion, j.packageVersion));
|
|
787
|
+
let o = 5;
|
|
788
|
+
e.oauthToken && (s.set("Authorization", e.oauthToken), o = 3), e.rateLimit && (o = e.rateLimit), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = Be(this.throttledRequest.bind(this), o, 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 || Ke.PUBLISHED, this.inlineAssets = e.inlineAssets || !1, this.client = new Ye({
|
|
789
|
+
baseURL: r,
|
|
790
|
+
timeout: e.timeout || 0,
|
|
791
|
+
headers: s,
|
|
792
|
+
responseInterceptor: e.responseInterceptor,
|
|
793
|
+
fetch: e.fetch
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
parseParams(e) {
|
|
797
|
+
return e.token || (e.token = this.getToken()), e.cv || (e.cv = T[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), typeof e.resolve_relations < "u" && (e.resolve_level = 2), e;
|
|
798
|
+
}
|
|
799
|
+
factoryParamOptions(e, t) {
|
|
800
|
+
return X(e) ? this.parseParams(t) : t;
|
|
801
|
+
}
|
|
802
|
+
makeRequest(e, t, r, s, o) {
|
|
803
|
+
const n = this.factoryParamOptions(e, Fe(t, r, s));
|
|
804
|
+
return this.cacheResponse(e, n, void 0, o);
|
|
805
|
+
}
|
|
806
|
+
get(e, t = {}, r) {
|
|
807
|
+
t || (t = {});
|
|
808
|
+
const s = `/${e}`;
|
|
809
|
+
X(s) && (t.version = t.version || this.version);
|
|
810
|
+
const o = this.factoryParamOptions(s, t);
|
|
811
|
+
return this.cacheResponse(s, o, void 0, r);
|
|
812
|
+
}
|
|
813
|
+
async getAll(e, t = {}, r, s) {
|
|
814
|
+
const o = (t == null ? void 0 : t.per_page) || 25, n = `/${e}`.replace(/\/$/, ""), i = r ?? n.substring(n.lastIndexOf("/") + 1);
|
|
815
|
+
t.version = t.version || this.version;
|
|
816
|
+
const l = 1, c = await this.makeRequest(n, t, o, l, s), u = c.total ? Math.ceil(c.total / (c.perPage || o)) : 1, f = await Je(Ge(l, u), (m) => this.makeRequest(n, t, o, m + 1, s));
|
|
817
|
+
return qe([c, ...f], (m) => Object.values(m.data[i]));
|
|
818
|
+
}
|
|
819
|
+
post(e, t = {}, r) {
|
|
820
|
+
const s = `/${e}`;
|
|
821
|
+
return this.throttle("post", s, t, r);
|
|
822
|
+
}
|
|
823
|
+
put(e, t = {}, r) {
|
|
824
|
+
const s = `/${e}`;
|
|
825
|
+
return this.throttle("put", s, t, r);
|
|
826
|
+
}
|
|
827
|
+
delete(e, t = {}, r) {
|
|
828
|
+
t || (t = {});
|
|
829
|
+
const s = `/${e}`;
|
|
830
|
+
return this.throttle("delete", s, t, r);
|
|
831
|
+
}
|
|
832
|
+
getStories(e = {}, t) {
|
|
833
|
+
return this._addResolveLevel(e), this.get("cdn/stories", e, t);
|
|
834
|
+
}
|
|
835
|
+
getStory(e, t = {}, r) {
|
|
836
|
+
return this._addResolveLevel(t), this.get(`cdn/stories/${e}`, t, r);
|
|
837
|
+
}
|
|
838
|
+
getToken() {
|
|
839
|
+
return this.accessToken;
|
|
840
|
+
}
|
|
841
|
+
ejectInterceptor() {
|
|
842
|
+
this.client.eject();
|
|
843
|
+
}
|
|
844
|
+
_addResolveLevel(e) {
|
|
845
|
+
typeof e.resolve_relations < "u" && (e.resolve_level = 2);
|
|
846
|
+
}
|
|
847
|
+
_cleanCopy(e) {
|
|
848
|
+
return JSON.parse(JSON.stringify(e));
|
|
849
|
+
}
|
|
850
|
+
_insertLinks(e, t, r) {
|
|
851
|
+
const s = e[t];
|
|
852
|
+
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]));
|
|
853
|
+
}
|
|
854
|
+
/**
|
|
855
|
+
*
|
|
856
|
+
* @param resolveId A counter number as a string
|
|
857
|
+
* @param uuid The uuid of the story
|
|
858
|
+
* @returns string | object
|
|
859
|
+
*/
|
|
860
|
+
getStoryReference(e, t) {
|
|
861
|
+
return this.relations[e][t] ? JSON.parse(this.stringifiedStoriesCache[t] || JSON.stringify(this.relations[e][t])) : t;
|
|
862
|
+
}
|
|
863
|
+
/**
|
|
864
|
+
* Resolves a field's value by replacing UUIDs with their corresponding story references
|
|
865
|
+
* @param jtree - The JSON tree object containing the field to resolve
|
|
866
|
+
* @param treeItem - The key of the field to resolve
|
|
867
|
+
* @param resolveId - The unique identifier for the current resolution context
|
|
868
|
+
*
|
|
869
|
+
* This method handles both single string UUIDs and arrays of UUIDs:
|
|
870
|
+
* - For single strings: directly replaces the UUID with the story reference
|
|
871
|
+
* - For arrays: maps through each UUID and replaces with corresponding story references
|
|
872
|
+
*/
|
|
873
|
+
_resolveField(e, t, r) {
|
|
874
|
+
const s = e[t];
|
|
875
|
+
typeof s == "string" ? e[t] = this.getStoryReference(r, s) : Array.isArray(s) && (e[t] = s.map((o) => this.getStoryReference(r, o)).filter(Boolean));
|
|
876
|
+
}
|
|
877
|
+
/**
|
|
878
|
+
* Inserts relations into the JSON tree by resolving references
|
|
879
|
+
* @param jtree - The JSON tree object to process
|
|
880
|
+
* @param treeItem - The current field being processed
|
|
881
|
+
* @param fields - The relation patterns to resolve (string or array of strings)
|
|
882
|
+
* @param resolveId - The unique identifier for the current resolution context
|
|
883
|
+
*
|
|
884
|
+
* This method handles two types of relation patterns:
|
|
885
|
+
* 1. Nested relations: matches fields that end with the current field name
|
|
886
|
+
* Example: If treeItem is "event_type", it matches patterns like "*.event_type"
|
|
887
|
+
*
|
|
888
|
+
* 2. Direct component relations: matches exact component.field patterns
|
|
889
|
+
* Example: "event.event_type" for component "event" and field "event_type"
|
|
890
|
+
*
|
|
891
|
+
* The method supports both string and array formats for the fields parameter,
|
|
892
|
+
* allowing flexible specification of relation patterns.
|
|
893
|
+
*/
|
|
894
|
+
_insertRelations(e, t, r, s) {
|
|
895
|
+
if (Array.isArray(r) ? r.find((n) => n.endsWith(`.${t}`)) : r.endsWith(`.${t}`)) {
|
|
896
|
+
this._resolveField(e, t, s);
|
|
897
|
+
return;
|
|
898
|
+
}
|
|
899
|
+
const o = e.component ? `${e.component}.${t}` : t;
|
|
900
|
+
(Array.isArray(r) ? r.includes(o) : r === o) && this._resolveField(e, t, s);
|
|
901
|
+
}
|
|
902
|
+
/**
|
|
903
|
+
* Recursively traverses and resolves relations in the story content tree
|
|
904
|
+
* @param story - The story object containing the content to process
|
|
905
|
+
* @param fields - The relation patterns to resolve
|
|
906
|
+
* @param resolveId - The unique identifier for the current resolution context
|
|
907
|
+
*/
|
|
908
|
+
iterateTree(e, t, r) {
|
|
909
|
+
const s = (o, n = "") => {
|
|
910
|
+
if (!(!o || o._stopResolving)) {
|
|
911
|
+
if (Array.isArray(o)) o.forEach((i, l) => s(i, `${n}[${l}]`));
|
|
912
|
+
else if (typeof o == "object") for (const i in o) {
|
|
913
|
+
const l = n ? `${n}.${i}` : i;
|
|
914
|
+
(o.component && o._uid || o.type === "link") && (this._insertRelations(o, i, t, r), this._insertLinks(o, i, r)), s(o[i], l);
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
};
|
|
918
|
+
s(e.content);
|
|
919
|
+
}
|
|
920
|
+
async resolveLinks(e, t, r) {
|
|
921
|
+
let s = [];
|
|
922
|
+
if (e.link_uuids) {
|
|
923
|
+
const o = e.link_uuids.length, n = [], i = 50;
|
|
924
|
+
for (let l = 0; l < o; l += i) {
|
|
925
|
+
const c = Math.min(o, l + i);
|
|
926
|
+
n.push(e.link_uuids.slice(l, c));
|
|
927
|
+
}
|
|
928
|
+
for (let l = 0; l < n.length; l++)
|
|
929
|
+
(await this.getStories({
|
|
930
|
+
per_page: i,
|
|
931
|
+
language: t.language,
|
|
932
|
+
version: t.version,
|
|
933
|
+
starts_with: t.starts_with,
|
|
934
|
+
by_uuids: n[l].join(",")
|
|
935
|
+
})).data.stories.forEach((c) => {
|
|
936
|
+
s.push(c);
|
|
937
|
+
});
|
|
938
|
+
} else s = e.links;
|
|
939
|
+
s.forEach((o) => {
|
|
940
|
+
this.links[r][o.uuid] = {
|
|
941
|
+
...o,
|
|
942
|
+
_stopResolving: !0
|
|
943
|
+
};
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
async resolveRelations(e, t, r) {
|
|
947
|
+
let s = [];
|
|
948
|
+
if (e.rel_uuids) {
|
|
949
|
+
const o = e.rel_uuids.length, n = [], i = 50;
|
|
950
|
+
for (let l = 0; l < o; l += i) {
|
|
951
|
+
const c = Math.min(o, l + i);
|
|
952
|
+
n.push(e.rel_uuids.slice(l, c));
|
|
953
|
+
}
|
|
954
|
+
for (let l = 0; l < n.length; l++)
|
|
955
|
+
(await this.getStories({
|
|
956
|
+
per_page: i,
|
|
957
|
+
language: t.language,
|
|
958
|
+
version: t.version,
|
|
959
|
+
starts_with: t.starts_with,
|
|
960
|
+
by_uuids: n[l].join(","),
|
|
961
|
+
excluding_fields: t.excluding_fields
|
|
962
|
+
})).data.stories.forEach((c) => {
|
|
963
|
+
s.push(c);
|
|
964
|
+
});
|
|
965
|
+
s.length > 0 && (e.rels = s, delete e.rel_uuids);
|
|
966
|
+
} else s = e.rels;
|
|
967
|
+
s && s.length > 0 && s.forEach((o) => {
|
|
968
|
+
this.relations[r][o.uuid] = {
|
|
969
|
+
...o,
|
|
970
|
+
_stopResolving: !0
|
|
971
|
+
};
|
|
972
|
+
});
|
|
973
|
+
}
|
|
974
|
+
/**
|
|
975
|
+
*
|
|
976
|
+
* @param responseData
|
|
977
|
+
* @param params
|
|
978
|
+
* @param resolveId
|
|
979
|
+
* @description Resolves the relations and links of the stories
|
|
980
|
+
* @returns Promise<void>
|
|
981
|
+
*
|
|
982
|
+
*/
|
|
983
|
+
async resolveStories(e, t, r) {
|
|
984
|
+
var s, o;
|
|
985
|
+
let n = [];
|
|
986
|
+
if (this.links[r] = {}, this.relations[r] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (n = t.resolve_relations.split(",")), await this.resolveRelations(e, t, r)), t.resolve_links && [
|
|
987
|
+
"1",
|
|
988
|
+
"story",
|
|
989
|
+
"url",
|
|
990
|
+
"link"
|
|
991
|
+
].includes(t.resolve_links) && ((s = e.links) != null && s.length || (o = e.link_uuids) != null && o.length) && await this.resolveLinks(e, t, r), this.resolveNestedRelations) for (const i in this.relations[r]) this.iterateTree(this.relations[r][i], n, r);
|
|
992
|
+
e.story ? this.iterateTree(e.story, n, r) : e.stories.forEach((i) => {
|
|
993
|
+
this.iterateTree(i, n, r);
|
|
994
|
+
}), this.stringifiedStoriesCache = {}, delete this.links[r], delete this.relations[r];
|
|
995
|
+
}
|
|
996
|
+
async cacheResponse(e, t, r, s) {
|
|
997
|
+
const o = U({
|
|
998
|
+
url: e,
|
|
999
|
+
params: t
|
|
1000
|
+
}), n = this.cacheProvider();
|
|
1001
|
+
if (t.version === "published" && e !== "/cdn/spaces/me") {
|
|
1002
|
+
const i = await n.get(o);
|
|
1003
|
+
if (i) return Promise.resolve(i);
|
|
1004
|
+
}
|
|
1005
|
+
return new Promise(async (i, l) => {
|
|
1006
|
+
var c;
|
|
1007
|
+
try {
|
|
1008
|
+
const u = await this.throttle("get", e, t, s);
|
|
1009
|
+
if (u.status !== 200) return l(u);
|
|
1010
|
+
let f = {
|
|
1011
|
+
data: u.data,
|
|
1012
|
+
headers: u.headers
|
|
1013
|
+
};
|
|
1014
|
+
if ((c = u.headers) != null && c["per-page"] && (f = Object.assign({}, f, {
|
|
1015
|
+
perPage: u.headers["per-page"] ? Number.parseInt(u.headers["per-page"]) : 0,
|
|
1016
|
+
total: u.headers["per-page"] ? Number.parseInt(u.headers.total) : 0
|
|
1017
|
+
})), f.data.story || f.data.stories) {
|
|
1018
|
+
const A = this.resolveCounter = ++this.resolveCounter % 1e3;
|
|
1019
|
+
await this.resolveStories(f.data, t, `${A}`), f = await this.processInlineAssets(f);
|
|
1020
|
+
}
|
|
1021
|
+
t.version === "published" && e !== "/cdn/spaces/me" && await n.set(o, f);
|
|
1022
|
+
const m = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
|
|
1023
|
+
return t.token && f.data.cv && (m && T[t.token] && T[t.token] !== f.data.cv && await this.flushCache(), T[t.token] = f.data.cv), i(f);
|
|
1024
|
+
} catch (u) {
|
|
1025
|
+
if (u.response && u.status === 429 && (r = typeof r > "u" ? 0 : r + 1, r < this.maxRetries))
|
|
1026
|
+
return console.log(`Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`), await ze(this.retriesDelay), this.cacheResponse(e, t, r).then(i).catch(l);
|
|
1027
|
+
l(u);
|
|
1028
|
+
}
|
|
1029
|
+
});
|
|
1030
|
+
}
|
|
1031
|
+
throttledRequest(e, t, r, s) {
|
|
1032
|
+
return this.client.setFetchOptions(s), this.client[e](t, r);
|
|
1033
|
+
}
|
|
1034
|
+
cacheVersions() {
|
|
1035
|
+
return T;
|
|
1036
|
+
}
|
|
1037
|
+
cacheVersion() {
|
|
1038
|
+
return T[this.accessToken];
|
|
1039
|
+
}
|
|
1040
|
+
setCacheVersion(e) {
|
|
1041
|
+
this.accessToken && (T[this.accessToken] = e);
|
|
1042
|
+
}
|
|
1043
|
+
clearCacheVersion() {
|
|
1044
|
+
this.accessToken && (T[this.accessToken] = 0);
|
|
1045
|
+
}
|
|
1046
|
+
cacheProvider() {
|
|
1047
|
+
switch (this.cache.type) {
|
|
1048
|
+
case "memory":
|
|
1049
|
+
return {
|
|
1050
|
+
get(e) {
|
|
1051
|
+
return Promise.resolve(x[e]);
|
|
1052
|
+
},
|
|
1053
|
+
getAll() {
|
|
1054
|
+
return Promise.resolve(x);
|
|
1055
|
+
},
|
|
1056
|
+
set(e, t) {
|
|
1057
|
+
return x[e] = t, Promise.resolve(void 0);
|
|
1058
|
+
},
|
|
1059
|
+
flush() {
|
|
1060
|
+
return x = {}, Promise.resolve(void 0);
|
|
1061
|
+
}
|
|
1062
|
+
};
|
|
1063
|
+
case "custom":
|
|
1064
|
+
if (this.cache.custom) return this.cache.custom;
|
|
1065
|
+
default:
|
|
1066
|
+
return {
|
|
1067
|
+
get() {
|
|
1068
|
+
return Promise.resolve();
|
|
1069
|
+
},
|
|
1070
|
+
getAll() {
|
|
1071
|
+
return Promise.resolve(void 0);
|
|
1072
|
+
},
|
|
1073
|
+
set() {
|
|
1074
|
+
return Promise.resolve(void 0);
|
|
1075
|
+
},
|
|
1076
|
+
flush() {
|
|
1077
|
+
return Promise.resolve(void 0);
|
|
1078
|
+
}
|
|
1079
|
+
};
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
async flushCache() {
|
|
1083
|
+
return await this.cacheProvider().flush(), this.clearCacheVersion(), this;
|
|
1084
|
+
}
|
|
1085
|
+
async processInlineAssets(e) {
|
|
1086
|
+
if (!this.inlineAssets) return e;
|
|
1087
|
+
const t = (r) => {
|
|
1088
|
+
if (!r || typeof r != "object") return r;
|
|
1089
|
+
if (Array.isArray(r)) return r.map((o) => t(o));
|
|
1090
|
+
let s = { ...r };
|
|
1091
|
+
s.fieldtype === "asset" && Array.isArray(e.data.assets) && (s = {
|
|
1092
|
+
...s,
|
|
1093
|
+
...e.data.assets.find((o) => o.id === s.id)
|
|
1094
|
+
});
|
|
1095
|
+
for (const o in s) typeof s[o] == "object" && (s[o] = t(s[o]));
|
|
1096
|
+
return s;
|
|
1097
|
+
};
|
|
1098
|
+
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;
|
|
1099
|
+
}
|
|
1100
|
+
}, Qe = Xe;
|
|
1101
|
+
const ot = (e = {}) => {
|
|
1102
|
+
const { apiOptions: t } = e;
|
|
1103
|
+
if (!t || !t.accessToken) {
|
|
1104
|
+
console.error(
|
|
1105
|
+
"You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication"
|
|
1106
|
+
);
|
|
1107
|
+
return;
|
|
1108
|
+
}
|
|
1109
|
+
return { storyblokApi: new Qe(t) };
|
|
1110
|
+
}, nt = (e) => {
|
|
533
1111
|
if (typeof e != "object" || typeof e._editable > "u")
|
|
534
1112
|
return {};
|
|
535
1113
|
try {
|
|
@@ -544,19 +1122,39 @@ const G = [], we = (e) => new Promise((t, s) => {
|
|
|
544
1122
|
return {};
|
|
545
1123
|
}
|
|
546
1124
|
};
|
|
547
|
-
let
|
|
548
|
-
|
|
549
|
-
|
|
1125
|
+
let M = "https://app.storyblok.com/f/storyblok-v2-latest.js";
|
|
1126
|
+
const it = (e = {}) => {
|
|
1127
|
+
var t, r;
|
|
1128
|
+
const {
|
|
1129
|
+
bridge: s,
|
|
1130
|
+
accessToken: o,
|
|
1131
|
+
use: n = [],
|
|
1132
|
+
apiOptions: i = {},
|
|
1133
|
+
bridgeUrl: l
|
|
1134
|
+
} = e;
|
|
1135
|
+
i.accessToken = i.accessToken || o;
|
|
1136
|
+
const c = { bridge: s, apiOptions: i };
|
|
1137
|
+
let u = {};
|
|
1138
|
+
n.forEach((m) => {
|
|
1139
|
+
u = { ...u, ...m(c) };
|
|
1140
|
+
}), l && (M = l);
|
|
1141
|
+
const f = !(typeof window > "u") && ((r = (t = window.location) == null ? void 0 : t.search) == null ? void 0 : r.includes("_storyblok_tk"));
|
|
1142
|
+
return s !== !1 && f && se(M), u;
|
|
1143
|
+
};
|
|
1144
|
+
function at(e, t) {
|
|
1145
|
+
return De(t).render(e);
|
|
550
1146
|
}
|
|
551
|
-
const
|
|
1147
|
+
const lt = () => se(M);
|
|
552
1148
|
export {
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
1149
|
+
ot as apiPlugin,
|
|
1150
|
+
tt as getLiveStory,
|
|
1151
|
+
st as handleStoryblokMessage,
|
|
1152
|
+
lt as loadStoryblokBridge,
|
|
1153
|
+
at as renderRichText,
|
|
1154
|
+
De as richTextResolver,
|
|
1155
|
+
rt as storyblok,
|
|
1156
|
+
nt as storyblokEditable,
|
|
1157
|
+
it as storyblokInit,
|
|
1158
|
+
$e as toCamelCase,
|
|
1159
|
+
et as useStoryblokApi
|
|
562
1160
|
};
|