@storyblok/astro 4.1.0-next.2 → 4.1.1-next.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/README.md +72 -13
- package/dist/storyblok-astro.js +22 -9
- package/dist/storyblok-astro.mjs +798 -741
- package/dist/types/index.d.ts +6 -2
- package/dist/types/live-preview/handleStoryblokMessage.d.ts +11 -1
- package/dist/types/utils/generateFinalBridgeObject.d.ts +3 -3
- package/dist/types/utils/parseAstCode.d.ts +7 -1
- package/dist/types/vite-plugins/vite-plugin-storyblok-bridge.d.ts +11 -1
- package/live-preview/handleStoryblokMessage.ts +23 -41
- package/live-preview/middleware.ts +16 -3
- package/package.json +11 -8
- package/utils/generateFinalBridgeObject.ts +12 -11
- package/utils/parseAstCode.ts +43 -18
- package/vite-plugins/vite-plugin-storyblok-bridge.ts +0 -69
- package/vite-plugins/vite-plugin-storyblok-components.ts +0 -124
- package/vite-plugins/vite-plugin-storyblok-init.ts +0 -33
- package/vite-plugins/vite-plugin-storyblok-options.ts +0 -20
package/dist/storyblok-astro.mjs
CHANGED
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
function
|
|
2
|
-
const
|
|
1
|
+
function Or(o, r, e) {
|
|
2
|
+
const i = "virtual:storyblok-init", s = "\0" + i;
|
|
3
3
|
return {
|
|
4
4
|
name: "vite-plugin-storyblok-init",
|
|
5
5
|
async resolveId(l) {
|
|
6
|
-
if (l ===
|
|
7
|
-
return
|
|
6
|
+
if (l === i)
|
|
7
|
+
return s;
|
|
8
8
|
},
|
|
9
9
|
async load(l) {
|
|
10
|
-
if (l ===
|
|
10
|
+
if (l === s)
|
|
11
11
|
return `
|
|
12
12
|
import { storyblokInit, apiPlugin } from "@storyblok/js";
|
|
13
13
|
const { storyblokApi } = storyblokInit({
|
|
14
14
|
accessToken: "${o}",
|
|
15
|
-
use: ${
|
|
16
|
-
apiOptions: ${JSON.stringify(
|
|
15
|
+
use: ${r ? "[]" : "[apiPlugin]"},
|
|
16
|
+
apiOptions: ${JSON.stringify(e)},
|
|
17
17
|
});
|
|
18
18
|
export const storyblokApiInstance = storyblokApi;
|
|
19
19
|
`;
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
const Cr = /[\p{Lu}]/u,
|
|
24
|
-
let
|
|
25
|
-
for (let
|
|
26
|
-
const
|
|
27
|
-
|
|
23
|
+
const Cr = /[\p{Lu}]/u, jr = /[\p{Ll}]/u, zt = /^[\p{Lu}](?![\p{Lu}])/gu, Gt = /([\p{Alpha}\p{N}_]|$)/u, ft = /[_.\- ]+/, $r = new RegExp("^" + ft.source), Lt = new RegExp(ft.source + Gt.source, "gu"), Dt = new RegExp("\\d+" + Gt.source, "gu"), xr = (o, r, e, i) => {
|
|
24
|
+
let s = !1, l = !1, u = !1, f = !1;
|
|
25
|
+
for (let g = 0; g < o.length; g++) {
|
|
26
|
+
const b = o[g];
|
|
27
|
+
f = g > 2 ? o[g - 3] === "-" : !0, s && Cr.test(b) ? (o = o.slice(0, g) + "-" + o.slice(g), s = !1, u = l, l = !0, g++) : l && u && jr.test(b) && (!f || i) ? (o = o.slice(0, g - 1) + "-" + o.slice(g - 1), u = l, l = !1, s = !0) : (s = r(b) === b && e(b) !== b, u = l, l = e(b) === b && r(b) !== b);
|
|
28
28
|
}
|
|
29
29
|
return o;
|
|
30
|
-
}, Er = (o,
|
|
31
|
-
function Ut(o,
|
|
30
|
+
}, Er = (o, r) => (zt.lastIndex = 0, o.replaceAll(zt, (e) => r(e))), Rr = (o, r) => (Lt.lastIndex = 0, Dt.lastIndex = 0, o.replaceAll(Dt, (e, i, s) => ["_", "-"].includes(o.charAt(s + e.length)) ? e : r(e)).replaceAll(Lt, (e, i) => r(i)));
|
|
31
|
+
function Ut(o, r) {
|
|
32
32
|
if (!(typeof o == "string" || Array.isArray(o)))
|
|
33
33
|
throw new TypeError("Expected the input to be `string | string[]`");
|
|
34
|
-
if (
|
|
34
|
+
if (r = {
|
|
35
35
|
pascalCase: !1,
|
|
36
36
|
preserveConsecutiveUppercase: !1,
|
|
37
|
-
...
|
|
37
|
+
...r
|
|
38
38
|
}, Array.isArray(o) ? o = o.map((l) => l.trim()).filter((l) => l.length).join("-") : o = o.trim(), o.length === 0)
|
|
39
39
|
return "";
|
|
40
|
-
const
|
|
41
|
-
return o.length === 1 ? ft.test(o) ? "" :
|
|
40
|
+
const e = r.locale === !1 ? (l) => l.toLowerCase() : (l) => l.toLocaleLowerCase(r.locale), i = r.locale === !1 ? (l) => l.toUpperCase() : (l) => l.toLocaleUpperCase(r.locale);
|
|
41
|
+
return o.length === 1 ? ft.test(o) ? "" : r.pascalCase ? i(o) : e(o) : (o !== e(o) && (o = xr(o, e, i, r.preserveConsecutiveUppercase)), o = o.replace($r, ""), o = r.preserveConsecutiveUppercase ? Er(o, e) : e(o), r.pascalCase && (o = i(o.charAt(0)) + o.slice(1)), Rr(o, i));
|
|
42
42
|
}
|
|
43
|
-
function
|
|
44
|
-
const
|
|
43
|
+
function Pr(o, r, e, i) {
|
|
44
|
+
const s = "virtual:storyblok-components", l = "\0" + s;
|
|
45
45
|
return {
|
|
46
46
|
name: "vite-plugin-storyblok-components",
|
|
47
47
|
async resolveId(u) {
|
|
48
|
-
if (u ===
|
|
48
|
+
if (u === s)
|
|
49
49
|
return l;
|
|
50
50
|
},
|
|
51
51
|
async load(u) {
|
|
52
52
|
if (u === l) {
|
|
53
|
-
const
|
|
54
|
-
for await (const [
|
|
55
|
-
const
|
|
56
|
-
"/" + o + "/" +
|
|
53
|
+
const f = [], g = [];
|
|
54
|
+
for await (const [_, k] of Object.entries(r)) {
|
|
55
|
+
const I = await this.resolve(
|
|
56
|
+
"/" + o + "/" + k + ".astro"
|
|
57
57
|
);
|
|
58
|
-
if (
|
|
59
|
-
|
|
60
|
-
else if (
|
|
61
|
-
|
|
58
|
+
if (I)
|
|
59
|
+
f.push(`import ${Ut(_)} from "${I.id}"`);
|
|
60
|
+
else if (e)
|
|
61
|
+
g.push(_);
|
|
62
62
|
else
|
|
63
63
|
throw new Error(
|
|
64
|
-
`Component could not be found for blok "${
|
|
64
|
+
`Component could not be found for blok "${_}"! Does "${"/" + o + "/" + k}.astro" exist?`
|
|
65
65
|
);
|
|
66
66
|
}
|
|
67
|
-
let
|
|
68
|
-
if (
|
|
69
|
-
if (
|
|
70
|
-
const
|
|
71
|
-
"/" + o + "/" +
|
|
67
|
+
let b = "";
|
|
68
|
+
if (e)
|
|
69
|
+
if (b = ",FallbackComponent", i) {
|
|
70
|
+
const _ = await this.resolve(
|
|
71
|
+
"/" + o + "/" + i + ".astro"
|
|
72
72
|
);
|
|
73
|
-
if (!
|
|
73
|
+
if (!_)
|
|
74
74
|
throw new Error(
|
|
75
|
-
`Custom fallback component could not be found. Does "${"/" + o + "/" +
|
|
75
|
+
`Custom fallback component could not be found. Does "${"/" + o + "/" + i}.astro" exist?`
|
|
76
76
|
);
|
|
77
|
-
|
|
78
|
-
`import FallbackComponent from "${
|
|
77
|
+
f.push(
|
|
78
|
+
`import FallbackComponent from "${_.id}"`
|
|
79
79
|
);
|
|
80
80
|
} else
|
|
81
|
-
|
|
81
|
+
f.push(
|
|
82
82
|
"import FallbackComponent from '@storyblok/astro/FallbackComponent.astro'"
|
|
83
83
|
);
|
|
84
|
-
if (Object.values(
|
|
85
|
-
return `${
|
|
86
|
-
if (
|
|
87
|
-
return `${
|
|
84
|
+
if (Object.values(r).length)
|
|
85
|
+
return `${f.join(";")};export default {${Object.keys(r).filter((_) => !g.includes(_)).map((_) => Ut(_)).join(",")}${b}}`;
|
|
86
|
+
if (e)
|
|
87
|
+
return `${f[0]}; export default {${b.replace(",", "")}}`;
|
|
88
88
|
throw new Error(
|
|
89
89
|
`Currently, no Storyblok components are registered in astro.config.mjs.
|
|
90
90
|
Please register your components or enable the fallback component.
|
|
@@ -94,33 +94,467 @@ Detailed information can be found here: https://github.com/storyblok/storyblok-a
|
|
|
94
94
|
}
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
|
-
function
|
|
98
|
-
const
|
|
97
|
+
function Mr(o) {
|
|
98
|
+
const r = "virtual:storyblok-options", e = "\0" + r;
|
|
99
99
|
return {
|
|
100
100
|
name: "vite-plugin-storyblok-options",
|
|
101
|
-
async resolveId(
|
|
102
|
-
if (
|
|
103
|
-
return
|
|
101
|
+
async resolveId(i) {
|
|
102
|
+
if (i === r)
|
|
103
|
+
return e;
|
|
104
104
|
},
|
|
105
|
-
async load(
|
|
106
|
-
if (
|
|
105
|
+
async load(i) {
|
|
106
|
+
if (i === e)
|
|
107
107
|
return `export default ${JSON.stringify(o)}`;
|
|
108
108
|
}
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
let Bt = !1;
|
|
112
|
+
const Ft = [], Nr = (o) => new Promise((r, e) => {
|
|
113
|
+
if (typeof window > "u" || (window.storyblokRegisterEvent = (s) => {
|
|
114
|
+
if (window.location === window.parent.location) {
|
|
115
|
+
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
Bt ? s() : Ft.push(s);
|
|
119
|
+
}, document.getElementById("storyblok-javascript-bridge")))
|
|
120
|
+
return;
|
|
121
|
+
const i = document.createElement("script");
|
|
122
|
+
i.async = !0, i.src = o, i.id = "storyblok-javascript-bridge", i.onerror = (s) => e(s), i.onload = (s) => {
|
|
123
|
+
Ft.forEach((l) => l()), Bt = !0, r(s);
|
|
124
|
+
}, document.getElementsByTagName("head")[0].appendChild(i);
|
|
125
|
+
});
|
|
126
|
+
var zr = Object.defineProperty, Lr = (o, r, e) => r in o ? zr(o, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[r] = e, S = (o, r, e) => (Lr(o, typeof r != "symbol" ? r + "" : r, e), e);
|
|
127
|
+
class Dr {
|
|
128
|
+
constructor() {
|
|
129
|
+
S(this, "isCDNUrl", (r = "") => r.indexOf("/cdn/") > -1), S(this, "getOptionsPage", (r, e = 25, i = 1) => ({
|
|
130
|
+
...r,
|
|
131
|
+
per_page: e,
|
|
132
|
+
page: i
|
|
133
|
+
})), S(this, "delay", (r) => new Promise((e) => setTimeout(e, r))), S(this, "arrayFrom", (r = 0, e) => [...Array(r)].map(e)), S(this, "range", (r = 0, e = r) => {
|
|
134
|
+
const i = Math.abs(e - r) || 0, s = r < e ? 1 : -1;
|
|
135
|
+
return this.arrayFrom(i, (l, u) => u * s + r);
|
|
136
|
+
}), S(this, "asyncMap", async (r, e) => Promise.all(r.map(e))), S(this, "flatMap", (r = [], e) => r.map(e).reduce((i, s) => [...i, ...s], [])), S(this, "escapeHTML", function(r) {
|
|
137
|
+
const e = {
|
|
138
|
+
"&": "&",
|
|
139
|
+
"<": "<",
|
|
140
|
+
">": ">",
|
|
141
|
+
'"': """,
|
|
142
|
+
"'": "'"
|
|
143
|
+
}, i = /[&<>"']/g, s = RegExp(i.source);
|
|
144
|
+
return r && s.test(r) ? r.replace(i, (l) => e[l]) : r;
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* @method stringify
|
|
149
|
+
* @param {Object} params
|
|
150
|
+
* @param {String} prefix
|
|
151
|
+
* @param {Boolean} isArray
|
|
152
|
+
* @return {String} Stringified object
|
|
153
|
+
*/
|
|
154
|
+
stringify(r, e, i) {
|
|
155
|
+
const s = [];
|
|
156
|
+
for (const l in r) {
|
|
157
|
+
if (!Object.prototype.hasOwnProperty.call(r, l))
|
|
158
|
+
continue;
|
|
159
|
+
const u = r[l], f = i ? "" : encodeURIComponent(l);
|
|
160
|
+
let g;
|
|
161
|
+
typeof u == "object" ? g = this.stringify(
|
|
162
|
+
u,
|
|
163
|
+
e ? e + encodeURIComponent("[" + f + "]") : f,
|
|
164
|
+
Array.isArray(u)
|
|
165
|
+
) : g = (e ? e + encodeURIComponent("[" + f + "]") : f) + "=" + encodeURIComponent(u), s.push(g);
|
|
166
|
+
}
|
|
167
|
+
return s.join("&");
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* @method getRegionURL
|
|
171
|
+
* @param {String} regionCode region code, could be eu, us, cn, ap or ca
|
|
172
|
+
* @return {String} The base URL of the region
|
|
173
|
+
*/
|
|
174
|
+
getRegionURL(r) {
|
|
175
|
+
const e = "api.storyblok.com", i = "api-us.storyblok.com", s = "app.storyblokchina.cn", l = "api-ap.storyblok.com", u = "api-ca.storyblok.com";
|
|
176
|
+
switch (r) {
|
|
177
|
+
case "us":
|
|
178
|
+
return i;
|
|
179
|
+
case "cn":
|
|
180
|
+
return s;
|
|
181
|
+
case "ap":
|
|
182
|
+
return l;
|
|
183
|
+
case "ca":
|
|
184
|
+
return u;
|
|
185
|
+
default:
|
|
186
|
+
return e;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
const Ur = function(o, r) {
|
|
191
|
+
const e = {};
|
|
192
|
+
for (const i in o) {
|
|
193
|
+
const s = o[i];
|
|
194
|
+
r.indexOf(i) > -1 && s !== null && (e[i] = s);
|
|
195
|
+
}
|
|
196
|
+
return e;
|
|
197
|
+
}, Br = (o) => o === "email", Fr = () => ({
|
|
198
|
+
singleTag: "hr"
|
|
199
|
+
}), Hr = () => ({
|
|
200
|
+
tag: "blockquote"
|
|
201
|
+
}), qr = () => ({
|
|
202
|
+
tag: "ul"
|
|
203
|
+
}), Gr = (o) => ({
|
|
204
|
+
tag: [
|
|
205
|
+
"pre",
|
|
206
|
+
{
|
|
207
|
+
tag: "code",
|
|
208
|
+
attrs: o.attrs
|
|
209
|
+
}
|
|
210
|
+
]
|
|
211
|
+
}), Jr = () => ({
|
|
212
|
+
singleTag: "br"
|
|
213
|
+
}), Kr = (o) => ({
|
|
214
|
+
tag: `h${o.attrs.level}`
|
|
215
|
+
}), Wr = (o) => ({
|
|
216
|
+
singleTag: [
|
|
217
|
+
{
|
|
218
|
+
tag: "img",
|
|
219
|
+
attrs: Ur(o.attrs, ["src", "alt", "title"])
|
|
220
|
+
}
|
|
221
|
+
]
|
|
222
|
+
}), Yr = () => ({
|
|
223
|
+
tag: "li"
|
|
224
|
+
}), Vr = () => ({
|
|
225
|
+
tag: "ol"
|
|
226
|
+
}), Xr = () => ({
|
|
227
|
+
tag: "p"
|
|
228
|
+
}), Zr = (o) => ({
|
|
229
|
+
tag: [
|
|
230
|
+
{
|
|
231
|
+
tag: "span",
|
|
232
|
+
attrs: {
|
|
233
|
+
"data-type": "emoji",
|
|
234
|
+
"data-name": o.attrs.name,
|
|
235
|
+
emoji: o.attrs.emoji
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
]
|
|
239
|
+
}), Qr = () => ({
|
|
240
|
+
tag: "b"
|
|
241
|
+
}), tn = () => ({
|
|
242
|
+
tag: "s"
|
|
243
|
+
}), en = () => ({
|
|
244
|
+
tag: "u"
|
|
245
|
+
}), rn = () => ({
|
|
246
|
+
tag: "strong"
|
|
247
|
+
}), nn = () => ({
|
|
248
|
+
tag: "code"
|
|
249
|
+
}), on = () => ({
|
|
250
|
+
tag: "i"
|
|
251
|
+
}), an = (o) => {
|
|
252
|
+
if (!o.attrs)
|
|
253
|
+
return {
|
|
254
|
+
tag: ""
|
|
255
|
+
};
|
|
256
|
+
const r = new Dr().escapeHTML, e = { ...o.attrs }, { linktype: i = "url" } = o.attrs;
|
|
257
|
+
if (delete e.linktype, e.href && (e.href = r(o.attrs.href || "")), Br(i) && (e.href = `mailto:${e.href}`), e.anchor && (e.href = `${e.href}#${e.anchor}`, delete e.anchor), e.custom) {
|
|
258
|
+
for (const s in e.custom)
|
|
259
|
+
e[s] = e.custom[s];
|
|
260
|
+
delete e.custom;
|
|
261
|
+
}
|
|
262
|
+
return {
|
|
263
|
+
tag: [
|
|
264
|
+
{
|
|
265
|
+
tag: "a",
|
|
266
|
+
attrs: e
|
|
267
|
+
}
|
|
268
|
+
]
|
|
269
|
+
};
|
|
270
|
+
}, sn = (o) => ({
|
|
271
|
+
tag: [
|
|
272
|
+
{
|
|
273
|
+
tag: "span",
|
|
274
|
+
attrs: o.attrs
|
|
275
|
+
}
|
|
276
|
+
]
|
|
277
|
+
}), ln = () => ({
|
|
278
|
+
tag: "sub"
|
|
279
|
+
}), cn = () => ({
|
|
280
|
+
tag: "sup"
|
|
281
|
+
}), un = (o) => ({
|
|
282
|
+
tag: [
|
|
283
|
+
{
|
|
284
|
+
tag: "span",
|
|
285
|
+
attrs: o.attrs
|
|
286
|
+
}
|
|
287
|
+
]
|
|
288
|
+
}), fn = (o) => {
|
|
289
|
+
var r;
|
|
290
|
+
return (r = o.attrs) != null && r.color ? {
|
|
291
|
+
tag: [
|
|
292
|
+
{
|
|
293
|
+
tag: "span",
|
|
294
|
+
attrs: {
|
|
295
|
+
style: `background-color:${o.attrs.color};`
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
]
|
|
299
|
+
} : {
|
|
300
|
+
tag: ""
|
|
301
|
+
};
|
|
302
|
+
}, pn = (o) => {
|
|
303
|
+
var r;
|
|
304
|
+
return (r = o.attrs) != null && r.color ? {
|
|
305
|
+
tag: [
|
|
306
|
+
{
|
|
307
|
+
tag: "span",
|
|
308
|
+
attrs: {
|
|
309
|
+
style: `color:${o.attrs.color}`
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
]
|
|
313
|
+
} : {
|
|
314
|
+
tag: ""
|
|
315
|
+
};
|
|
316
|
+
}, dn = {
|
|
317
|
+
nodes: {
|
|
318
|
+
horizontal_rule: Fr,
|
|
319
|
+
blockquote: Hr,
|
|
320
|
+
bullet_list: qr,
|
|
321
|
+
code_block: Gr,
|
|
322
|
+
hard_break: Jr,
|
|
323
|
+
heading: Kr,
|
|
324
|
+
image: Wr,
|
|
325
|
+
list_item: Yr,
|
|
326
|
+
ordered_list: Vr,
|
|
327
|
+
paragraph: Xr,
|
|
328
|
+
emoji: Zr
|
|
329
|
+
},
|
|
330
|
+
marks: {
|
|
331
|
+
bold: Qr,
|
|
332
|
+
strike: tn,
|
|
333
|
+
underline: en,
|
|
334
|
+
strong: rn,
|
|
335
|
+
code: nn,
|
|
336
|
+
italic: on,
|
|
337
|
+
link: an,
|
|
338
|
+
styled: sn,
|
|
339
|
+
subscript: ln,
|
|
340
|
+
superscript: cn,
|
|
341
|
+
anchor: un,
|
|
342
|
+
highlight: fn,
|
|
343
|
+
textStyle: pn
|
|
344
|
+
}
|
|
345
|
+
}, gn = function(o) {
|
|
346
|
+
const r = {
|
|
347
|
+
"&": "&",
|
|
348
|
+
"<": "<",
|
|
349
|
+
">": ">",
|
|
350
|
+
'"': """,
|
|
351
|
+
"'": "'"
|
|
352
|
+
}, e = /[&<>"']/g, i = RegExp(e.source);
|
|
353
|
+
return o && i.test(o) ? o.replace(e, (s) => r[s]) : o;
|
|
354
|
+
};
|
|
355
|
+
class hn {
|
|
356
|
+
constructor(r) {
|
|
357
|
+
S(this, "marks"), S(this, "nodes"), r || (r = dn), this.marks = r.marks || [], this.nodes = r.nodes || [];
|
|
358
|
+
}
|
|
359
|
+
addNode(r, e) {
|
|
360
|
+
this.nodes[r] = e;
|
|
361
|
+
}
|
|
362
|
+
addMark(r, e) {
|
|
363
|
+
this.marks[r] = e;
|
|
364
|
+
}
|
|
365
|
+
render(r, e = { optimizeImages: !1 }) {
|
|
366
|
+
if (r && r.content && Array.isArray(r.content)) {
|
|
367
|
+
let i = "";
|
|
368
|
+
return r.content.forEach((s) => {
|
|
369
|
+
i += this.renderNode(s);
|
|
370
|
+
}), e.optimizeImages ? this.optimizeImages(i, e.optimizeImages) : i;
|
|
371
|
+
}
|
|
372
|
+
return console.warn(
|
|
373
|
+
`The render method must receive an Object with a "content" field.
|
|
374
|
+
The "content" field must be an array of nodes as the type ISbRichtext.
|
|
375
|
+
ISbRichtext:
|
|
376
|
+
content?: ISbRichtext[]
|
|
377
|
+
marks?: ISbRichtext[]
|
|
378
|
+
attrs?: any
|
|
379
|
+
text?: string
|
|
380
|
+
type: string
|
|
381
|
+
|
|
382
|
+
Example:
|
|
383
|
+
{
|
|
384
|
+
content: [
|
|
385
|
+
{
|
|
386
|
+
content: [
|
|
387
|
+
{
|
|
388
|
+
text: 'Hello World',
|
|
389
|
+
type: 'text'
|
|
390
|
+
}
|
|
391
|
+
],
|
|
392
|
+
type: 'paragraph'
|
|
393
|
+
}
|
|
394
|
+
],
|
|
395
|
+
type: 'doc'
|
|
396
|
+
}`
|
|
397
|
+
), "";
|
|
398
|
+
}
|
|
399
|
+
optimizeImages(r, e) {
|
|
400
|
+
let i = 0, s = 0, l = "", u = "";
|
|
401
|
+
typeof e != "boolean" && (typeof e.width == "number" && e.width > 0 && (l += `width="${e.width}" `, i = e.width), typeof e.height == "number" && e.height > 0 && (l += `height="${e.height}" `, s = e.height), (e.loading === "lazy" || e.loading === "eager") && (l += `loading="${e.loading}" `), typeof e.class == "string" && e.class.length > 0 && (l += `class="${e.class}" `), e.filters && (typeof e.filters.blur == "number" && e.filters.blur >= 0 && e.filters.blur <= 100 && (u += `:blur(${e.filters.blur})`), typeof e.filters.brightness == "number" && e.filters.brightness >= -100 && e.filters.brightness <= 100 && (u += `:brightness(${e.filters.brightness})`), e.filters.fill && (e.filters.fill.match(/[0-9A-Fa-f]{6}/g) || e.filters.fill === "transparent") && (u += `:fill(${e.filters.fill})`), e.filters.format && ["webp", "png", "jpeg"].includes(e.filters.format) && (u += `:format(${e.filters.format})`), typeof e.filters.grayscale == "boolean" && e.filters.grayscale && (u += ":grayscale()"), typeof e.filters.quality == "number" && e.filters.quality >= 0 && e.filters.quality <= 100 && (u += `:quality(${e.filters.quality})`), e.filters.rotate && [90, 180, 270].includes(e.filters.rotate) && (u += `:rotate(${e.filters.rotate})`), u.length > 0 && (u = "/filters" + u))), l.length > 0 && (r = r.replace(/<img/g, `<img ${l.trim()}`));
|
|
402
|
+
const f = i > 0 || s > 0 || u.length > 0 ? `${i}x${s}${u}` : "";
|
|
403
|
+
return r = r.replace(
|
|
404
|
+
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,
|
|
405
|
+
`a.storyblok.com/f/$1/$2.$3/m/${f}`
|
|
406
|
+
), typeof e != "boolean" && (e.sizes || e.srcset) && (r = r.replace(/<img.*?src=["|'](.*?)["|']/g, (g) => {
|
|
407
|
+
var b, _;
|
|
408
|
+
const k = g.match(
|
|
409
|
+
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g
|
|
410
|
+
);
|
|
411
|
+
if (k && k.length > 0) {
|
|
412
|
+
const I = {
|
|
413
|
+
srcset: (b = e.srcset) == null ? void 0 : b.map((w) => {
|
|
414
|
+
if (typeof w == "number")
|
|
415
|
+
return `//${k}/m/${w}x0${u} ${w}w`;
|
|
416
|
+
if (typeof w == "object" && w.length === 2) {
|
|
417
|
+
let M = 0, F = 0;
|
|
418
|
+
return typeof w[0] == "number" && (M = w[0]), typeof w[1] == "number" && (F = w[1]), `//${k}/m/${M}x${F}${u} ${M}w`;
|
|
419
|
+
}
|
|
420
|
+
}).join(", "),
|
|
421
|
+
sizes: (_ = e.sizes) == null ? void 0 : _.map((w) => w).join(", ")
|
|
422
|
+
};
|
|
423
|
+
let O = "";
|
|
424
|
+
return I.srcset && (O += `srcset="${I.srcset}" `), I.sizes && (O += `sizes="${I.sizes}" `), g.replace(/<img/g, `<img ${O.trim()}`);
|
|
425
|
+
}
|
|
426
|
+
return g;
|
|
427
|
+
})), r;
|
|
428
|
+
}
|
|
429
|
+
renderNode(r) {
|
|
430
|
+
const e = [];
|
|
431
|
+
r.marks && r.marks.forEach((s) => {
|
|
432
|
+
const l = this.getMatchingMark(s);
|
|
433
|
+
l && l.tag !== "" && e.push(this.renderOpeningTag(l.tag));
|
|
434
|
+
});
|
|
435
|
+
const i = this.getMatchingNode(r);
|
|
436
|
+
return i && i.tag && e.push(this.renderOpeningTag(i.tag)), r.content ? r.content.forEach((s) => {
|
|
437
|
+
e.push(this.renderNode(s));
|
|
438
|
+
}) : r.text ? e.push(gn(r.text)) : i && i.singleTag ? e.push(this.renderTag(i.singleTag, " /")) : i && i.html ? e.push(i.html) : r.type === "emoji" && e.push(this.renderEmoji(r)), i && i.tag && e.push(this.renderClosingTag(i.tag)), r.marks && r.marks.slice(0).reverse().forEach((s) => {
|
|
439
|
+
const l = this.getMatchingMark(s);
|
|
440
|
+
l && l.tag !== "" && e.push(this.renderClosingTag(l.tag));
|
|
441
|
+
}), e.join("");
|
|
442
|
+
}
|
|
443
|
+
renderTag(r, e) {
|
|
444
|
+
return r.constructor === String ? `<${r}${e}>` : r.map((i) => {
|
|
445
|
+
if (i.constructor === String)
|
|
446
|
+
return `<${i}${e}>`;
|
|
447
|
+
{
|
|
448
|
+
let s = `<${i.tag}`;
|
|
449
|
+
if (i.attrs)
|
|
450
|
+
for (const l in i.attrs) {
|
|
451
|
+
const u = i.attrs[l];
|
|
452
|
+
u !== null && (s += ` ${l}="${u}"`);
|
|
453
|
+
}
|
|
454
|
+
return `${s}${e}>`;
|
|
455
|
+
}
|
|
456
|
+
}).join("");
|
|
457
|
+
}
|
|
458
|
+
renderOpeningTag(r) {
|
|
459
|
+
return this.renderTag(r, "");
|
|
460
|
+
}
|
|
461
|
+
renderClosingTag(r) {
|
|
462
|
+
return r.constructor === String ? `</${r}>` : r.slice(0).reverse().map((e) => e.constructor === String ? `</${e}>` : `</${e.tag}>`).join("");
|
|
463
|
+
}
|
|
464
|
+
getMatchingNode(r) {
|
|
465
|
+
const e = this.nodes[r.type];
|
|
466
|
+
if (typeof e == "function")
|
|
467
|
+
return e(r);
|
|
468
|
+
}
|
|
469
|
+
getMatchingMark(r) {
|
|
470
|
+
const e = this.marks[r.type];
|
|
471
|
+
if (typeof e == "function")
|
|
472
|
+
return e(r);
|
|
473
|
+
}
|
|
474
|
+
renderEmoji(r) {
|
|
475
|
+
if (r.attrs.emoji)
|
|
476
|
+
return r.attrs.emoji;
|
|
477
|
+
const e = [
|
|
478
|
+
{
|
|
479
|
+
tag: "img",
|
|
480
|
+
attrs: {
|
|
481
|
+
src: r.attrs.fallbackImage,
|
|
482
|
+
draggable: "false",
|
|
483
|
+
loading: "lazy",
|
|
484
|
+
align: "absmiddle"
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
];
|
|
488
|
+
return this.renderTag(e, " /");
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
const $n = (o) => {
|
|
492
|
+
if (typeof o != "object" || typeof o._editable > "u")
|
|
493
|
+
return {};
|
|
494
|
+
try {
|
|
495
|
+
const r = JSON.parse(
|
|
496
|
+
o._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
|
|
497
|
+
);
|
|
498
|
+
return r ? {
|
|
499
|
+
"data-blok-c": JSON.stringify(r),
|
|
500
|
+
"data-blok-uid": r.id + "-" + r.uid
|
|
501
|
+
} : {};
|
|
502
|
+
} catch {
|
|
503
|
+
return {};
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
let yn, bn = "https://app.storyblok.com/f/storyblok-v2-latest.js";
|
|
507
|
+
const mn = (o, r) => {
|
|
508
|
+
o.addNode("blok", (e) => {
|
|
509
|
+
let i = "";
|
|
510
|
+
return e.attrs.body.forEach((s) => {
|
|
511
|
+
i += r(s.component, s);
|
|
512
|
+
}), {
|
|
513
|
+
html: i
|
|
514
|
+
};
|
|
515
|
+
});
|
|
516
|
+
}, vn = (o) => !o || !(o != null && o.content.some((r) => r.content || r.type === "blok" || r.type === "horizontal_rule")), _n = (o, r, e) => {
|
|
517
|
+
let i = e || yn;
|
|
518
|
+
if (!i) {
|
|
519
|
+
console.error(
|
|
520
|
+
"Please initialize the Storyblok SDK before calling the renderRichText function"
|
|
521
|
+
);
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
return vn(o) ? "" : (r && (i = new hn(r.schema), r.resolver && mn(i, r.resolver)), i.render(o));
|
|
525
|
+
}, xn = () => Nr(bn);
|
|
526
|
+
function wn(o) {
|
|
527
|
+
let r = {
|
|
528
|
+
resolveRelations: []
|
|
529
|
+
};
|
|
530
|
+
function e(i) {
|
|
531
|
+
i && Array.isArray(r.resolveRelations) && r.resolveRelations.push(
|
|
532
|
+
...Array.isArray(i) ? i : [i]
|
|
533
|
+
);
|
|
534
|
+
}
|
|
535
|
+
for (const i of o)
|
|
536
|
+
if (i.options) {
|
|
537
|
+
const { apiOptions: s, bridgeOptions: l } = i.options;
|
|
538
|
+
if (e(s == null ? void 0 : s.resolve_relations), l) {
|
|
539
|
+
const { resolveRelations: u, ...f } = l;
|
|
540
|
+
e(u), Object.assign(r, f);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
return r.resolveRelations = [...new Set(r.resolveRelations)], r;
|
|
544
|
+
}
|
|
545
|
+
var X = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
546
|
+
function Tn(o) {
|
|
113
547
|
return o && o.__esModule && Object.prototype.hasOwnProperty.call(o, "default") ? o.default : o;
|
|
114
548
|
}
|
|
115
|
-
var
|
|
116
|
-
|
|
117
|
-
(function(o,
|
|
118
|
-
var
|
|
119
|
-
|
|
120
|
-
var dt = typeof
|
|
549
|
+
var Z = { exports: {} };
|
|
550
|
+
Z.exports;
|
|
551
|
+
(function(o, r) {
|
|
552
|
+
var e = 200, i = "__lodash_hash_undefined__", s = 800, l = 16, u = 9007199254740991, f = "[object Arguments]", g = "[object Array]", b = "[object AsyncFunction]", _ = "[object Boolean]", k = "[object Date]", I = "[object Error]", O = "[object Function]", w = "[object GeneratorFunction]", M = "[object Map]", F = "[object Number]", Jt = "[object Null]", pt = "[object Object]", Kt = "[object Proxy]", Wt = "[object RegExp]", Yt = "[object Set]", Vt = "[object String]", Xt = "[object Undefined]", Zt = "[object WeakMap]", Qt = "[object ArrayBuffer]", te = "[object DataView]", ee = "[object Float32Array]", re = "[object Float64Array]", ne = "[object Int8Array]", oe = "[object Int16Array]", ae = "[object Int32Array]", ie = "[object Uint8Array]", se = "[object Uint8ClampedArray]", le = "[object Uint16Array]", ce = "[object Uint32Array]", ue = /[\\^$.*+?()[\]{}|]/g, fe = /^\[object .+?Constructor\]$/, pe = /^(?:0|[1-9]\d*)$/, y = {};
|
|
553
|
+
y[ee] = y[re] = y[ne] = y[oe] = y[ae] = y[ie] = y[se] = y[le] = y[ce] = !0, y[f] = y[g] = y[Qt] = y[_] = y[te] = y[k] = y[I] = y[O] = y[M] = y[F] = y[pt] = y[Wt] = y[Yt] = y[Vt] = y[Zt] = !1;
|
|
554
|
+
var dt = typeof X == "object" && X && X.Object === Object && X, de = typeof self == "object" && self && self.Object === Object && self, N = dt || de || Function("return this")(), gt = r && !r.nodeType && r, z = gt && !0 && o && !o.nodeType && o, ht = z && z.exports === gt, Q = ht && dt.process, yt = function() {
|
|
121
555
|
try {
|
|
122
556
|
var t = z && z.require && z.require("util").types;
|
|
123
|
-
return t ||
|
|
557
|
+
return t || Q && Q.binding && Q.binding("util");
|
|
124
558
|
} catch {
|
|
125
559
|
}
|
|
126
560
|
}(), bt = yt && yt.isTypedArray;
|
|
@@ -155,31 +589,31 @@ Q.exports;
|
|
|
155
589
|
return t(n(a));
|
|
156
590
|
};
|
|
157
591
|
}
|
|
158
|
-
var
|
|
592
|
+
var ve = Array.prototype, _e = Function.prototype, H = Object.prototype, tt = N["__core-js_shared__"], q = _e.toString, C = H.hasOwnProperty, mt = function() {
|
|
159
593
|
var t = /[^.]+$/.exec(tt && tt.keys && tt.keys.IE_PROTO || "");
|
|
160
594
|
return t ? "Symbol(src)_1." + t : "";
|
|
161
|
-
}(),
|
|
162
|
-
"^" + q.call(
|
|
163
|
-
), G = ht ? N.Buffer : void 0,
|
|
595
|
+
}(), vt = H.toString, we = q.call(Object), Te = RegExp(
|
|
596
|
+
"^" + q.call(C).replace(ue, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
|
|
597
|
+
), G = ht ? N.Buffer : void 0, _t = N.Symbol, wt = N.Uint8Array, Tt = G ? G.allocUnsafe : void 0, kt = me(Object.getPrototypeOf, Object), At = Object.create, ke = H.propertyIsEnumerable, Ae = ve.splice, $ = _t ? _t.toStringTag : void 0, J = function() {
|
|
164
598
|
try {
|
|
165
599
|
var t = nt(Object, "defineProperty");
|
|
166
600
|
return t({}, "", {}), t;
|
|
167
601
|
} catch {
|
|
168
602
|
}
|
|
169
|
-
}(),
|
|
603
|
+
}(), Ie = G ? G.isBuffer : void 0, It = Math.max, Se = Date.now, St = nt(N, "Map"), L = nt(Object, "create"), Oe = /* @__PURE__ */ function() {
|
|
170
604
|
function t() {
|
|
171
605
|
}
|
|
172
606
|
return function(n) {
|
|
173
|
-
if (!
|
|
607
|
+
if (!E(n))
|
|
174
608
|
return {};
|
|
175
|
-
if (
|
|
176
|
-
return
|
|
609
|
+
if (At)
|
|
610
|
+
return At(n);
|
|
177
611
|
t.prototype = n;
|
|
178
612
|
var a = new t();
|
|
179
613
|
return t.prototype = void 0, a;
|
|
180
614
|
};
|
|
181
615
|
}();
|
|
182
|
-
function
|
|
616
|
+
function x(t) {
|
|
183
617
|
var n = -1, a = t == null ? 0 : t.length;
|
|
184
618
|
for (this.clear(); ++n < a; ) {
|
|
185
619
|
var c = t[n];
|
|
@@ -189,28 +623,28 @@ Q.exports;
|
|
|
189
623
|
function Ce() {
|
|
190
624
|
this.__data__ = L ? L(null) : {}, this.size = 0;
|
|
191
625
|
}
|
|
192
|
-
function
|
|
626
|
+
function je(t) {
|
|
193
627
|
var n = this.has(t) && delete this.__data__[t];
|
|
194
628
|
return this.size -= n ? 1 : 0, n;
|
|
195
629
|
}
|
|
196
|
-
function
|
|
630
|
+
function $e(t) {
|
|
197
631
|
var n = this.__data__;
|
|
198
632
|
if (L) {
|
|
199
633
|
var a = n[t];
|
|
200
|
-
return a ===
|
|
634
|
+
return a === i ? void 0 : a;
|
|
201
635
|
}
|
|
202
|
-
return
|
|
636
|
+
return C.call(n, t) ? n[t] : void 0;
|
|
203
637
|
}
|
|
204
638
|
function xe(t) {
|
|
205
639
|
var n = this.__data__;
|
|
206
|
-
return L ? n[t] !== void 0 :
|
|
640
|
+
return L ? n[t] !== void 0 : C.call(n, t);
|
|
207
641
|
}
|
|
208
642
|
function Ee(t, n) {
|
|
209
643
|
var a = this.__data__;
|
|
210
|
-
return this.size += this.has(t) ? 0 : 1, a[t] = L && n === void 0 ?
|
|
644
|
+
return this.size += this.has(t) ? 0 : 1, a[t] = L && n === void 0 ? i : n, this;
|
|
211
645
|
}
|
|
212
|
-
|
|
213
|
-
function
|
|
646
|
+
x.prototype.clear = Ce, x.prototype.delete = je, x.prototype.get = $e, x.prototype.has = xe, x.prototype.set = Ee;
|
|
647
|
+
function j(t) {
|
|
214
648
|
var n = -1, a = t == null ? 0 : t.length;
|
|
215
649
|
for (this.clear(); ++n < a; ) {
|
|
216
650
|
var c = t[n];
|
|
@@ -220,14 +654,14 @@ Q.exports;
|
|
|
220
654
|
function Re() {
|
|
221
655
|
this.__data__ = [], this.size = 0;
|
|
222
656
|
}
|
|
223
|
-
function
|
|
657
|
+
function Pe(t) {
|
|
224
658
|
var n = this.__data__, a = K(n, t);
|
|
225
659
|
if (a < 0)
|
|
226
660
|
return !1;
|
|
227
661
|
var c = n.length - 1;
|
|
228
|
-
return a == c ? n.pop() :
|
|
662
|
+
return a == c ? n.pop() : Ae.call(n, a, 1), --this.size, !0;
|
|
229
663
|
}
|
|
230
|
-
function
|
|
664
|
+
function Me(t) {
|
|
231
665
|
var n = this.__data__, a = K(n, t);
|
|
232
666
|
return a < 0 ? void 0 : n[a][1];
|
|
233
667
|
}
|
|
@@ -238,7 +672,7 @@ Q.exports;
|
|
|
238
672
|
var a = this.__data__, c = K(a, t);
|
|
239
673
|
return c < 0 ? (++this.size, a.push([t, n])) : a[c][1] = n, this;
|
|
240
674
|
}
|
|
241
|
-
|
|
675
|
+
j.prototype.clear = Re, j.prototype.delete = Pe, j.prototype.get = Me, j.prototype.has = Ne, j.prototype.set = ze;
|
|
242
676
|
function R(t) {
|
|
243
677
|
var n = -1, a = t == null ? 0 : t.length;
|
|
244
678
|
for (this.clear(); ++n < a; ) {
|
|
@@ -248,9 +682,9 @@ Q.exports;
|
|
|
248
682
|
}
|
|
249
683
|
function Le() {
|
|
250
684
|
this.size = 0, this.__data__ = {
|
|
251
|
-
hash: new
|
|
252
|
-
map: new (
|
|
253
|
-
string: new
|
|
685
|
+
hash: new x(),
|
|
686
|
+
map: new (St || j)(),
|
|
687
|
+
string: new x()
|
|
254
688
|
};
|
|
255
689
|
}
|
|
256
690
|
function De(t) {
|
|
@@ -260,20 +694,20 @@ Q.exports;
|
|
|
260
694
|
function Ue(t) {
|
|
261
695
|
return Y(this, t).get(t);
|
|
262
696
|
}
|
|
263
|
-
function
|
|
697
|
+
function Be(t) {
|
|
264
698
|
return Y(this, t).has(t);
|
|
265
699
|
}
|
|
266
|
-
function
|
|
700
|
+
function Fe(t, n) {
|
|
267
701
|
var a = Y(this, t), c = a.size;
|
|
268
702
|
return a.set(t, n), this.size += a.size == c ? 0 : 1, this;
|
|
269
703
|
}
|
|
270
|
-
R.prototype.clear = Le, R.prototype.delete = De, R.prototype.get = Ue, R.prototype.has =
|
|
271
|
-
function
|
|
272
|
-
var n = this.__data__ = new
|
|
704
|
+
R.prototype.clear = Le, R.prototype.delete = De, R.prototype.get = Ue, R.prototype.has = Be, R.prototype.set = Fe;
|
|
705
|
+
function P(t) {
|
|
706
|
+
var n = this.__data__ = new j(t);
|
|
273
707
|
this.size = n.size;
|
|
274
708
|
}
|
|
275
709
|
function He() {
|
|
276
|
-
this.__data__ = new
|
|
710
|
+
this.__data__ = new j(), this.size = 0;
|
|
277
711
|
}
|
|
278
712
|
function qe(t) {
|
|
279
713
|
var n = this.__data__, a = n.delete(t);
|
|
@@ -287,35 +721,35 @@ Q.exports;
|
|
|
287
721
|
}
|
|
288
722
|
function Ke(t, n) {
|
|
289
723
|
var a = this.__data__;
|
|
290
|
-
if (a instanceof
|
|
724
|
+
if (a instanceof j) {
|
|
291
725
|
var c = a.__data__;
|
|
292
|
-
if (!
|
|
726
|
+
if (!St || c.length < e - 1)
|
|
293
727
|
return c.push([t, n]), this.size = ++a.size, this;
|
|
294
728
|
a = this.__data__ = new R(c);
|
|
295
729
|
}
|
|
296
730
|
return a.set(t, n), this.size = a.size, this;
|
|
297
731
|
}
|
|
298
|
-
|
|
732
|
+
P.prototype.clear = He, P.prototype.delete = qe, P.prototype.get = Ge, P.prototype.has = Je, P.prototype.set = Ke;
|
|
299
733
|
function We(t, n) {
|
|
300
|
-
var a =
|
|
301
|
-
for (var
|
|
302
|
-
(n ||
|
|
303
|
-
(
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
return
|
|
734
|
+
var a = it(t), c = !a && at(t), d = !a && !c && xt(t), h = !a && !c && !d && Rt(t), m = a || c || d || h, p = m ? he(t.length, String) : [], v = p.length;
|
|
735
|
+
for (var A in t)
|
|
736
|
+
(n || C.call(t, A)) && !(m && // Safari 9 has enumerable `arguments.length` in strict mode.
|
|
737
|
+
(A == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
|
|
738
|
+
d && (A == "offset" || A == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
|
|
739
|
+
h && (A == "buffer" || A == "byteLength" || A == "byteOffset") || // Skip index properties.
|
|
740
|
+
jt(A, v))) && p.push(A);
|
|
741
|
+
return p;
|
|
308
742
|
}
|
|
309
743
|
function et(t, n, a) {
|
|
310
|
-
(a !== void 0 && !
|
|
744
|
+
(a !== void 0 && !V(t[n], a) || a === void 0 && !(n in t)) && rt(t, n, a);
|
|
311
745
|
}
|
|
312
746
|
function Ye(t, n, a) {
|
|
313
747
|
var c = t[n];
|
|
314
|
-
(!(
|
|
748
|
+
(!(C.call(t, n) && V(c, a)) || a === void 0 && !(n in t)) && rt(t, n, a);
|
|
315
749
|
}
|
|
316
750
|
function K(t, n) {
|
|
317
751
|
for (var a = t.length; a--; )
|
|
318
|
-
if (
|
|
752
|
+
if (V(t[a][0], n))
|
|
319
753
|
return a;
|
|
320
754
|
return -1;
|
|
321
755
|
}
|
|
@@ -327,108 +761,108 @@ Q.exports;
|
|
|
327
761
|
writable: !0
|
|
328
762
|
}) : t[n] = a;
|
|
329
763
|
}
|
|
330
|
-
var
|
|
764
|
+
var Ve = cr();
|
|
331
765
|
function W(t) {
|
|
332
|
-
return t == null ? t === void 0 ?
|
|
766
|
+
return t == null ? t === void 0 ? Xt : Jt : $ && $ in Object(t) ? ur(t) : yr(t);
|
|
333
767
|
}
|
|
334
|
-
function
|
|
335
|
-
return D(t) && W(t) ==
|
|
768
|
+
function Ot(t) {
|
|
769
|
+
return D(t) && W(t) == f;
|
|
336
770
|
}
|
|
337
|
-
function
|
|
338
|
-
if (!
|
|
771
|
+
function Xe(t) {
|
|
772
|
+
if (!E(t) || gr(t))
|
|
339
773
|
return !1;
|
|
340
|
-
var n = lt(t) ?
|
|
341
|
-
return n.test(
|
|
774
|
+
var n = lt(t) ? Te : fe;
|
|
775
|
+
return n.test(_r(t));
|
|
342
776
|
}
|
|
343
|
-
function
|
|
344
|
-
return D(t) && Et(t.length) && !!
|
|
777
|
+
function Ze(t) {
|
|
778
|
+
return D(t) && Et(t.length) && !!y[W(t)];
|
|
345
779
|
}
|
|
346
|
-
function
|
|
347
|
-
if (!
|
|
780
|
+
function Qe(t) {
|
|
781
|
+
if (!E(t))
|
|
348
782
|
return hr(t);
|
|
349
|
-
var n =
|
|
783
|
+
var n = $t(t), a = [];
|
|
350
784
|
for (var c in t)
|
|
351
|
-
c == "constructor" && (n || !
|
|
785
|
+
c == "constructor" && (n || !C.call(t, c)) || a.push(c);
|
|
352
786
|
return a;
|
|
353
787
|
}
|
|
354
|
-
function Ct(t, n, a, c,
|
|
355
|
-
t !== n &&
|
|
356
|
-
if (
|
|
357
|
-
tr(t, n, m, a, Ct, c,
|
|
788
|
+
function Ct(t, n, a, c, d) {
|
|
789
|
+
t !== n && Ve(n, function(h, m) {
|
|
790
|
+
if (d || (d = new P()), E(h))
|
|
791
|
+
tr(t, n, m, a, Ct, c, d);
|
|
358
792
|
else {
|
|
359
|
-
var
|
|
360
|
-
|
|
793
|
+
var p = c ? c(ot(t, m), h, m + "", t, n, d) : void 0;
|
|
794
|
+
p === void 0 && (p = h), et(t, m, p);
|
|
361
795
|
}
|
|
362
|
-
},
|
|
796
|
+
}, Pt);
|
|
363
797
|
}
|
|
364
|
-
function tr(t, n, a, c,
|
|
365
|
-
var
|
|
366
|
-
if (
|
|
367
|
-
et(t, a,
|
|
798
|
+
function tr(t, n, a, c, d, h, m) {
|
|
799
|
+
var p = ot(t, a), v = ot(n, a), A = m.get(v);
|
|
800
|
+
if (A) {
|
|
801
|
+
et(t, a, A);
|
|
368
802
|
return;
|
|
369
803
|
}
|
|
370
|
-
var
|
|
804
|
+
var T = h ? h(p, v, a + "", t, n, m) : void 0, U = T === void 0;
|
|
371
805
|
if (U) {
|
|
372
|
-
var ct =
|
|
373
|
-
|
|
806
|
+
var ct = it(v), ut = !ct && xt(v), Nt = !ct && !ut && Rt(v);
|
|
807
|
+
T = v, ct || ut || Nt ? it(p) ? T = p : wr(p) ? T = ir(p) : ut ? (U = !1, T = nr(v, !0)) : Nt ? (U = !1, T = ar(v, !0)) : T = [] : Tr(v) || at(v) ? (T = p, at(p) ? T = kr(p) : (!E(p) || lt(p)) && (T = fr(v))) : U = !1;
|
|
374
808
|
}
|
|
375
|
-
U && (m.set(
|
|
809
|
+
U && (m.set(v, T), d(T, v, c, h, m), m.delete(v)), et(t, a, T);
|
|
376
810
|
}
|
|
377
811
|
function er(t, n) {
|
|
378
|
-
return mr(br(t, n,
|
|
812
|
+
return mr(br(t, n, Mt), t + "");
|
|
379
813
|
}
|
|
380
814
|
var rr = J ? function(t, n) {
|
|
381
815
|
return J(t, "toString", {
|
|
382
816
|
configurable: !0,
|
|
383
817
|
enumerable: !1,
|
|
384
|
-
value:
|
|
818
|
+
value: Ir(n),
|
|
385
819
|
writable: !0
|
|
386
820
|
});
|
|
387
|
-
} :
|
|
821
|
+
} : Mt;
|
|
388
822
|
function nr(t, n) {
|
|
389
823
|
if (n)
|
|
390
824
|
return t.slice();
|
|
391
|
-
var a = t.length, c =
|
|
825
|
+
var a = t.length, c = Tt ? Tt(a) : new t.constructor(a);
|
|
392
826
|
return t.copy(c), c;
|
|
393
827
|
}
|
|
394
828
|
function or(t) {
|
|
395
829
|
var n = new t.constructor(t.byteLength);
|
|
396
|
-
return new
|
|
830
|
+
return new wt(n).set(new wt(t)), n;
|
|
397
831
|
}
|
|
398
832
|
function ar(t, n) {
|
|
399
833
|
var a = n ? or(t.buffer) : t.buffer;
|
|
400
834
|
return new t.constructor(a, t.byteOffset, t.length);
|
|
401
835
|
}
|
|
402
|
-
function
|
|
836
|
+
function ir(t, n) {
|
|
403
837
|
var a = -1, c = t.length;
|
|
404
838
|
for (n || (n = Array(c)); ++a < c; )
|
|
405
839
|
n[a] = t[a];
|
|
406
840
|
return n;
|
|
407
841
|
}
|
|
408
|
-
function
|
|
409
|
-
var
|
|
842
|
+
function sr(t, n, a, c) {
|
|
843
|
+
var d = !a;
|
|
410
844
|
a || (a = {});
|
|
411
|
-
for (var
|
|
412
|
-
var
|
|
413
|
-
|
|
845
|
+
for (var h = -1, m = n.length; ++h < m; ) {
|
|
846
|
+
var p = n[h], v = c ? c(a[p], t[p], p, a, t) : void 0;
|
|
847
|
+
v === void 0 && (v = t[p]), d ? rt(a, p, v) : Ye(a, p, v);
|
|
414
848
|
}
|
|
415
849
|
return a;
|
|
416
850
|
}
|
|
417
851
|
function lr(t) {
|
|
418
852
|
return er(function(n, a) {
|
|
419
|
-
var c = -1,
|
|
420
|
-
for (
|
|
421
|
-
var
|
|
422
|
-
|
|
853
|
+
var c = -1, d = a.length, h = d > 1 ? a[d - 1] : void 0, m = d > 2 ? a[2] : void 0;
|
|
854
|
+
for (h = t.length > 3 && typeof h == "function" ? (d--, h) : void 0, m && pr(a[0], a[1], m) && (h = d < 3 ? void 0 : h, d = 1), n = Object(n); ++c < d; ) {
|
|
855
|
+
var p = a[c];
|
|
856
|
+
p && t(n, p, c, h);
|
|
423
857
|
}
|
|
424
858
|
return n;
|
|
425
859
|
});
|
|
426
860
|
}
|
|
427
861
|
function cr(t) {
|
|
428
862
|
return function(n, a, c) {
|
|
429
|
-
for (var
|
|
430
|
-
var
|
|
431
|
-
if (a(
|
|
863
|
+
for (var d = -1, h = Object(n), m = c(n), p = m.length; p--; ) {
|
|
864
|
+
var v = m[t ? p : ++d];
|
|
865
|
+
if (a(h[v], v, h) === !1)
|
|
432
866
|
break;
|
|
433
867
|
}
|
|
434
868
|
return n;
|
|
@@ -440,30 +874,30 @@ Q.exports;
|
|
|
440
874
|
}
|
|
441
875
|
function nt(t, n) {
|
|
442
876
|
var a = be(t, n);
|
|
443
|
-
return
|
|
877
|
+
return Xe(a) ? a : void 0;
|
|
444
878
|
}
|
|
445
879
|
function ur(t) {
|
|
446
|
-
var n =
|
|
880
|
+
var n = C.call(t, $), a = t[$];
|
|
447
881
|
try {
|
|
448
882
|
t[$] = void 0;
|
|
449
883
|
var c = !0;
|
|
450
884
|
} catch {
|
|
451
885
|
}
|
|
452
|
-
var
|
|
453
|
-
return c && (n ? t[$] = a : delete t[$]),
|
|
886
|
+
var d = vt.call(t);
|
|
887
|
+
return c && (n ? t[$] = a : delete t[$]), d;
|
|
454
888
|
}
|
|
455
889
|
function fr(t) {
|
|
456
|
-
return typeof t.constructor == "function" &&
|
|
890
|
+
return typeof t.constructor == "function" && !$t(t) ? Oe(kt(t)) : {};
|
|
457
891
|
}
|
|
458
|
-
function
|
|
892
|
+
function jt(t, n) {
|
|
459
893
|
var a = typeof t;
|
|
460
894
|
return n = n ?? u, !!n && (a == "number" || a != "symbol" && pe.test(t)) && t > -1 && t % 1 == 0 && t < n;
|
|
461
895
|
}
|
|
462
896
|
function pr(t, n, a) {
|
|
463
|
-
if (!
|
|
897
|
+
if (!E(a))
|
|
464
898
|
return !1;
|
|
465
899
|
var c = typeof n;
|
|
466
|
-
return (c == "number" ?
|
|
900
|
+
return (c == "number" ? st(a) && jt(n, a.length) : c == "string" && n in a) ? V(a[n], t) : !1;
|
|
467
901
|
}
|
|
468
902
|
function dr(t) {
|
|
469
903
|
var n = typeof t;
|
|
@@ -472,7 +906,7 @@ Q.exports;
|
|
|
472
906
|
function gr(t) {
|
|
473
907
|
return !!mt && mt in t;
|
|
474
908
|
}
|
|
475
|
-
function
|
|
909
|
+
function $t(t) {
|
|
476
910
|
var n = t && t.constructor, a = typeof n == "function" && n.prototype || H;
|
|
477
911
|
return t === a;
|
|
478
912
|
}
|
|
@@ -484,36 +918,36 @@ Q.exports;
|
|
|
484
918
|
return n;
|
|
485
919
|
}
|
|
486
920
|
function yr(t) {
|
|
487
|
-
return
|
|
921
|
+
return vt.call(t);
|
|
488
922
|
}
|
|
489
923
|
function br(t, n, a) {
|
|
490
|
-
return n =
|
|
491
|
-
for (var c = arguments,
|
|
492
|
-
m[
|
|
493
|
-
|
|
494
|
-
for (var
|
|
495
|
-
|
|
496
|
-
return
|
|
924
|
+
return n = It(n === void 0 ? t.length - 1 : n, 0), function() {
|
|
925
|
+
for (var c = arguments, d = -1, h = It(c.length - n, 0), m = Array(h); ++d < h; )
|
|
926
|
+
m[d] = c[n + d];
|
|
927
|
+
d = -1;
|
|
928
|
+
for (var p = Array(n + 1); ++d < n; )
|
|
929
|
+
p[d] = c[d];
|
|
930
|
+
return p[n] = a(m), ge(t, this, p);
|
|
497
931
|
};
|
|
498
932
|
}
|
|
499
933
|
function ot(t, n) {
|
|
500
934
|
if (!(n === "constructor" && typeof t[n] == "function") && n != "__proto__")
|
|
501
935
|
return t[n];
|
|
502
936
|
}
|
|
503
|
-
var mr =
|
|
504
|
-
function
|
|
937
|
+
var mr = vr(rr);
|
|
938
|
+
function vr(t) {
|
|
505
939
|
var n = 0, a = 0;
|
|
506
940
|
return function() {
|
|
507
|
-
var c =
|
|
508
|
-
if (a = c,
|
|
509
|
-
if (++n >=
|
|
941
|
+
var c = Se(), d = l - (c - a);
|
|
942
|
+
if (a = c, d > 0) {
|
|
943
|
+
if (++n >= s)
|
|
510
944
|
return arguments[0];
|
|
511
945
|
} else
|
|
512
946
|
n = 0;
|
|
513
947
|
return t.apply(void 0, arguments);
|
|
514
948
|
};
|
|
515
949
|
}
|
|
516
|
-
function
|
|
950
|
+
function _r(t) {
|
|
517
951
|
if (t != null) {
|
|
518
952
|
try {
|
|
519
953
|
return q.call(t);
|
|
@@ -526,595 +960,182 @@ Q.exports;
|
|
|
526
960
|
}
|
|
527
961
|
return "";
|
|
528
962
|
}
|
|
529
|
-
function
|
|
963
|
+
function V(t, n) {
|
|
530
964
|
return t === n || t !== t && n !== n;
|
|
531
965
|
}
|
|
532
|
-
var at =
|
|
966
|
+
var at = Ot(/* @__PURE__ */ function() {
|
|
533
967
|
return arguments;
|
|
534
|
-
}()) ?
|
|
535
|
-
return D(t) &&
|
|
536
|
-
},
|
|
537
|
-
function
|
|
968
|
+
}()) ? Ot : function(t) {
|
|
969
|
+
return D(t) && C.call(t, "callee") && !ke.call(t, "callee");
|
|
970
|
+
}, it = Array.isArray;
|
|
971
|
+
function st(t) {
|
|
538
972
|
return t != null && Et(t.length) && !lt(t);
|
|
539
973
|
}
|
|
540
|
-
function
|
|
541
|
-
return D(t) &&
|
|
974
|
+
function wr(t) {
|
|
975
|
+
return D(t) && st(t);
|
|
542
976
|
}
|
|
543
|
-
var xt =
|
|
977
|
+
var xt = Ie || Sr;
|
|
544
978
|
function lt(t) {
|
|
545
|
-
if (!
|
|
979
|
+
if (!E(t))
|
|
546
980
|
return !1;
|
|
547
981
|
var n = W(t);
|
|
548
|
-
return n ==
|
|
982
|
+
return n == O || n == w || n == b || n == Kt;
|
|
549
983
|
}
|
|
550
984
|
function Et(t) {
|
|
551
985
|
return typeof t == "number" && t > -1 && t % 1 == 0 && t <= u;
|
|
552
986
|
}
|
|
553
|
-
function
|
|
987
|
+
function E(t) {
|
|
554
988
|
var n = typeof t;
|
|
555
989
|
return t != null && (n == "object" || n == "function");
|
|
556
990
|
}
|
|
557
991
|
function D(t) {
|
|
558
992
|
return t != null && typeof t == "object";
|
|
559
993
|
}
|
|
560
|
-
function
|
|
994
|
+
function Tr(t) {
|
|
561
995
|
if (!D(t) || W(t) != pt)
|
|
562
996
|
return !1;
|
|
563
|
-
var n =
|
|
997
|
+
var n = kt(t);
|
|
564
998
|
if (n === null)
|
|
565
999
|
return !0;
|
|
566
|
-
var a =
|
|
567
|
-
return typeof a == "function" && a instanceof a && q.call(a) ==
|
|
1000
|
+
var a = C.call(n, "constructor") && n.constructor;
|
|
1001
|
+
return typeof a == "function" && a instanceof a && q.call(a) == we;
|
|
568
1002
|
}
|
|
569
|
-
var Rt = bt ? ye(bt) :
|
|
570
|
-
function
|
|
571
|
-
return
|
|
1003
|
+
var Rt = bt ? ye(bt) : Ze;
|
|
1004
|
+
function kr(t) {
|
|
1005
|
+
return sr(t, Pt(t));
|
|
572
1006
|
}
|
|
573
|
-
function
|
|
574
|
-
return
|
|
1007
|
+
function Pt(t) {
|
|
1008
|
+
return st(t) ? We(t, !0) : Qe(t);
|
|
575
1009
|
}
|
|
576
|
-
var
|
|
1010
|
+
var Ar = lr(function(t, n, a, c) {
|
|
577
1011
|
Ct(t, n, a, c);
|
|
578
1012
|
});
|
|
579
|
-
function
|
|
1013
|
+
function Ir(t) {
|
|
580
1014
|
return function() {
|
|
581
1015
|
return t;
|
|
582
1016
|
};
|
|
583
1017
|
}
|
|
584
|
-
function
|
|
1018
|
+
function Mt(t) {
|
|
585
1019
|
return t;
|
|
586
1020
|
}
|
|
587
|
-
function
|
|
1021
|
+
function Sr() {
|
|
588
1022
|
return !1;
|
|
589
1023
|
}
|
|
590
|
-
o.exports =
|
|
591
|
-
})(
|
|
592
|
-
var
|
|
593
|
-
const
|
|
594
|
-
function
|
|
595
|
-
let
|
|
596
|
-
function
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
1024
|
+
o.exports = Ar;
|
|
1025
|
+
})(Z, Z.exports);
|
|
1026
|
+
var kn = Z.exports;
|
|
1027
|
+
const An = /* @__PURE__ */ Tn(kn);
|
|
1028
|
+
function In(o) {
|
|
1029
|
+
let r = {};
|
|
1030
|
+
function e(i, s) {
|
|
1031
|
+
if ((s == null ? void 0 : s.type) === "AwaitExpression" && s.argument.type === "CallExpression" && s.argument.callee.type === "Identifier" && s.argument.callee.name === "useStoryblok") {
|
|
1032
|
+
const l = s.argument.arguments;
|
|
1033
|
+
if (l && l[1].type === "ObjectExpression") {
|
|
1034
|
+
const u = Ht(l[1].properties);
|
|
1035
|
+
r = {
|
|
1036
|
+
...r,
|
|
1037
|
+
apiOptions: u
|
|
1038
|
+
};
|
|
1039
|
+
}
|
|
1040
|
+
if (l && l[2].type === "ObjectExpression") {
|
|
1041
|
+
const u = Ht(l[2].properties);
|
|
1042
|
+
r = {
|
|
1043
|
+
...r,
|
|
1044
|
+
bridgeOptions: u
|
|
1045
|
+
};
|
|
1046
|
+
}
|
|
607
1047
|
}
|
|
608
1048
|
}
|
|
609
|
-
return
|
|
1049
|
+
return An({}, o, e), r;
|
|
610
1050
|
}
|
|
611
|
-
function
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
s && (Array.isArray(s) ? e.resolveRelations.push(...s) : e.resolveRelations.push(s));
|
|
623
|
-
}
|
|
624
|
-
for (const s of o)
|
|
625
|
-
if (s.options) {
|
|
626
|
-
const { apiOptions: i, bridgeOptions: l } = s.options;
|
|
627
|
-
if (r(i == null ? void 0 : i.resolve_relations), l) {
|
|
628
|
-
const { resolveRelations: u, ...h } = l;
|
|
629
|
-
r(u), Object.assign(e, h);
|
|
630
|
-
}
|
|
1051
|
+
function Ht(o) {
|
|
1052
|
+
const r = {};
|
|
1053
|
+
return o.reduce((e, i) => {
|
|
1054
|
+
if (i.type !== "Property") return e;
|
|
1055
|
+
const { key: s, value: l } = i, { type: u } = l;
|
|
1056
|
+
if (s.type !== "Identifier") return e;
|
|
1057
|
+
if (u === "Literal")
|
|
1058
|
+
e[s.name] = l.value;
|
|
1059
|
+
else if (u === "ArrayExpression") {
|
|
1060
|
+
const f = l.elements.reduce((g, b) => b.type === "Literal" && b.value ? [...g, b.value] : g, []);
|
|
1061
|
+
e[s.name] = f;
|
|
631
1062
|
}
|
|
632
|
-
|
|
1063
|
+
return e;
|
|
1064
|
+
}, r);
|
|
633
1065
|
}
|
|
634
|
-
let
|
|
635
|
-
function
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
1066
|
+
let B = [];
|
|
1067
|
+
function Sn(o, r) {
|
|
1068
|
+
const e = "virtual:storyblok-bridge", i = "\0" + e;
|
|
1069
|
+
if (!o || r !== "server")
|
|
1070
|
+
return {
|
|
1071
|
+
name: "vite-plugin-storyblok-bridge",
|
|
1072
|
+
resolveId(f) {
|
|
1073
|
+
if (f === e)
|
|
1074
|
+
return i;
|
|
1075
|
+
},
|
|
1076
|
+
load(f) {
|
|
1077
|
+
if (f === i)
|
|
1078
|
+
return "export const bridgeOptions = null";
|
|
1079
|
+
}
|
|
1080
|
+
};
|
|
1081
|
+
let s = [], l = null, u;
|
|
639
1082
|
return {
|
|
640
1083
|
name: "vite-plugin-storyblok-bridge",
|
|
641
|
-
async resolveId(
|
|
642
|
-
if (
|
|
643
|
-
return
|
|
1084
|
+
async resolveId(f) {
|
|
1085
|
+
if (f === e)
|
|
1086
|
+
return i;
|
|
644
1087
|
},
|
|
645
|
-
async transform(
|
|
646
|
-
var
|
|
647
|
-
if (
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
Br(F, o) || (F.length !== 0 && (s.restart(), console.info("Updating bridge options...")), F = [...o]);
|
|
1088
|
+
async transform(f, g) {
|
|
1089
|
+
var O;
|
|
1090
|
+
if (g.includes("node_modules") && !g.includes("/pages/") || !f.includes("useStoryblok") || !((O = this.getModuleInfo(g).meta) != null && O.astro)) return;
|
|
1091
|
+
const [, ..._] = g.split("src/pages/"), k = _.join("/").replace(".astro", ""), I = In(this.parse(f));
|
|
1092
|
+
B.length && (s = B.filter((w) => w.url !== k)), s.push({
|
|
1093
|
+
url: k,
|
|
1094
|
+
options: I
|
|
1095
|
+
}), l && (u && clearTimeout(u), u = setTimeout(() => {
|
|
1096
|
+
On(B, s) || (B.length !== 0 && (l.restart(), console.info("Bridge options updated. Restarting...")), B = [...s]);
|
|
655
1097
|
}, 1e3));
|
|
656
1098
|
},
|
|
657
|
-
async load(
|
|
658
|
-
if (
|
|
659
|
-
return `export const bridgeOptions = ${JSON.stringify(
|
|
1099
|
+
async load(f) {
|
|
1100
|
+
if (f === i)
|
|
1101
|
+
return `export const bridgeOptions = ${JSON.stringify(wn(s))}`;
|
|
660
1102
|
},
|
|
661
|
-
configureServer(
|
|
662
|
-
|
|
1103
|
+
configureServer(f) {
|
|
1104
|
+
l = f;
|
|
663
1105
|
}
|
|
664
1106
|
};
|
|
665
1107
|
}
|
|
666
|
-
function
|
|
667
|
-
return
|
|
668
|
-
const
|
|
669
|
-
return
|
|
1108
|
+
function On(o = [], r = []) {
|
|
1109
|
+
return r.every(({ url: e, options: i }) => {
|
|
1110
|
+
const s = o.find((l) => (l == null ? void 0 : l.url) === e);
|
|
1111
|
+
return s && JSON.stringify(i) === JSON.stringify(s.options);
|
|
670
1112
|
});
|
|
671
1113
|
}
|
|
672
|
-
let Bt = !1;
|
|
673
|
-
const Ht = [], Hr = (o) => new Promise((e, r) => {
|
|
674
|
-
if (typeof window > "u" || (window.storyblokRegisterEvent = (i) => {
|
|
675
|
-
if (window.location === window.parent.location) {
|
|
676
|
-
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
677
|
-
return;
|
|
678
|
-
}
|
|
679
|
-
Bt ? i() : Ht.push(i);
|
|
680
|
-
}, document.getElementById("storyblok-javascript-bridge")))
|
|
681
|
-
return;
|
|
682
|
-
const s = document.createElement("script");
|
|
683
|
-
s.async = !0, s.src = o, s.id = "storyblok-javascript-bridge", s.onerror = (i) => r(i), s.onload = (i) => {
|
|
684
|
-
Ht.forEach((l) => l()), Bt = !0, e(i);
|
|
685
|
-
}, document.getElementsByTagName("head")[0].appendChild(s);
|
|
686
|
-
});
|
|
687
|
-
var qr = Object.defineProperty, Gr = (o, e, r) => e in o ? qr(o, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[e] = r, O = (o, e, r) => (Gr(o, typeof e != "symbol" ? e + "" : e, r), r);
|
|
688
|
-
class Jr {
|
|
689
|
-
constructor() {
|
|
690
|
-
O(this, "isCDNUrl", (e = "") => e.indexOf("/cdn/") > -1), O(this, "getOptionsPage", (e, r = 25, s = 1) => ({
|
|
691
|
-
...e,
|
|
692
|
-
per_page: r,
|
|
693
|
-
page: s
|
|
694
|
-
})), O(this, "delay", (e) => new Promise((r) => setTimeout(r, e))), O(this, "arrayFrom", (e = 0, r) => [...Array(e)].map(r)), O(this, "range", (e = 0, r = e) => {
|
|
695
|
-
const s = Math.abs(r - e) || 0, i = e < r ? 1 : -1;
|
|
696
|
-
return this.arrayFrom(s, (l, u) => u * i + e);
|
|
697
|
-
}), O(this, "asyncMap", async (e, r) => Promise.all(e.map(r))), O(this, "flatMap", (e = [], r) => e.map(r).reduce((s, i) => [...s, ...i], [])), O(this, "escapeHTML", function(e) {
|
|
698
|
-
const r = {
|
|
699
|
-
"&": "&",
|
|
700
|
-
"<": "<",
|
|
701
|
-
">": ">",
|
|
702
|
-
'"': """,
|
|
703
|
-
"'": "'"
|
|
704
|
-
}, s = /[&<>"']/g, i = RegExp(s.source);
|
|
705
|
-
return e && i.test(e) ? e.replace(s, (l) => r[l]) : e;
|
|
706
|
-
});
|
|
707
|
-
}
|
|
708
|
-
/**
|
|
709
|
-
* @method stringify
|
|
710
|
-
* @param {Object} params
|
|
711
|
-
* @param {String} prefix
|
|
712
|
-
* @param {Boolean} isArray
|
|
713
|
-
* @return {String} Stringified object
|
|
714
|
-
*/
|
|
715
|
-
stringify(e, r, s) {
|
|
716
|
-
const i = [];
|
|
717
|
-
for (const l in e) {
|
|
718
|
-
if (!Object.prototype.hasOwnProperty.call(e, l))
|
|
719
|
-
continue;
|
|
720
|
-
const u = e[l], h = s ? "" : encodeURIComponent(l);
|
|
721
|
-
let d;
|
|
722
|
-
typeof u == "object" ? d = this.stringify(
|
|
723
|
-
u,
|
|
724
|
-
r ? r + encodeURIComponent("[" + h + "]") : h,
|
|
725
|
-
Array.isArray(u)
|
|
726
|
-
) : d = (r ? r + encodeURIComponent("[" + h + "]") : h) + "=" + encodeURIComponent(u), i.push(d);
|
|
727
|
-
}
|
|
728
|
-
return i.join("&");
|
|
729
|
-
}
|
|
730
|
-
/**
|
|
731
|
-
* @method getRegionURL
|
|
732
|
-
* @param {String} regionCode region code, could be eu, us, cn, ap or ca
|
|
733
|
-
* @return {String} The base URL of the region
|
|
734
|
-
*/
|
|
735
|
-
getRegionURL(e) {
|
|
736
|
-
const r = "api.storyblok.com", s = "api-us.storyblok.com", i = "app.storyblokchina.cn", l = "api-ap.storyblok.com", u = "api-ca.storyblok.com";
|
|
737
|
-
switch (e) {
|
|
738
|
-
case "us":
|
|
739
|
-
return s;
|
|
740
|
-
case "cn":
|
|
741
|
-
return i;
|
|
742
|
-
case "ap":
|
|
743
|
-
return l;
|
|
744
|
-
case "ca":
|
|
745
|
-
return u;
|
|
746
|
-
default:
|
|
747
|
-
return r;
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
const Kr = function(o, e) {
|
|
752
|
-
const r = {};
|
|
753
|
-
for (const s in o) {
|
|
754
|
-
const i = o[s];
|
|
755
|
-
e.indexOf(s) > -1 && i !== null && (r[s] = i);
|
|
756
|
-
}
|
|
757
|
-
return r;
|
|
758
|
-
}, Wr = (o) => o === "email", Yr = () => ({
|
|
759
|
-
singleTag: "hr"
|
|
760
|
-
}), Xr = () => ({
|
|
761
|
-
tag: "blockquote"
|
|
762
|
-
}), Zr = () => ({
|
|
763
|
-
tag: "ul"
|
|
764
|
-
}), Qr = (o) => ({
|
|
765
|
-
tag: [
|
|
766
|
-
"pre",
|
|
767
|
-
{
|
|
768
|
-
tag: "code",
|
|
769
|
-
attrs: o.attrs
|
|
770
|
-
}
|
|
771
|
-
]
|
|
772
|
-
}), Vr = () => ({
|
|
773
|
-
singleTag: "br"
|
|
774
|
-
}), tn = (o) => ({
|
|
775
|
-
tag: `h${o.attrs.level}`
|
|
776
|
-
}), en = (o) => ({
|
|
777
|
-
singleTag: [
|
|
778
|
-
{
|
|
779
|
-
tag: "img",
|
|
780
|
-
attrs: Kr(o.attrs, ["src", "alt", "title"])
|
|
781
|
-
}
|
|
782
|
-
]
|
|
783
|
-
}), rn = () => ({
|
|
784
|
-
tag: "li"
|
|
785
|
-
}), nn = () => ({
|
|
786
|
-
tag: "ol"
|
|
787
|
-
}), on = () => ({
|
|
788
|
-
tag: "p"
|
|
789
|
-
}), an = (o) => ({
|
|
790
|
-
tag: [
|
|
791
|
-
{
|
|
792
|
-
tag: "span",
|
|
793
|
-
attrs: {
|
|
794
|
-
"data-type": "emoji",
|
|
795
|
-
"data-name": o.attrs.name,
|
|
796
|
-
emoji: o.attrs.emoji
|
|
797
|
-
}
|
|
798
|
-
}
|
|
799
|
-
]
|
|
800
|
-
}), sn = () => ({
|
|
801
|
-
tag: "b"
|
|
802
|
-
}), ln = () => ({
|
|
803
|
-
tag: "s"
|
|
804
|
-
}), cn = () => ({
|
|
805
|
-
tag: "u"
|
|
806
|
-
}), un = () => ({
|
|
807
|
-
tag: "strong"
|
|
808
|
-
}), fn = () => ({
|
|
809
|
-
tag: "code"
|
|
810
|
-
}), pn = () => ({
|
|
811
|
-
tag: "i"
|
|
812
|
-
}), dn = (o) => {
|
|
813
|
-
if (!o.attrs)
|
|
814
|
-
return {
|
|
815
|
-
tag: ""
|
|
816
|
-
};
|
|
817
|
-
const e = new Jr().escapeHTML, r = { ...o.attrs }, { linktype: s = "url" } = o.attrs;
|
|
818
|
-
if (delete r.linktype, r.href && (r.href = e(o.attrs.href || "")), Wr(s) && (r.href = `mailto:${r.href}`), r.anchor && (r.href = `${r.href}#${r.anchor}`, delete r.anchor), r.custom) {
|
|
819
|
-
for (const i in r.custom)
|
|
820
|
-
r[i] = r.custom[i];
|
|
821
|
-
delete r.custom;
|
|
822
|
-
}
|
|
823
|
-
return {
|
|
824
|
-
tag: [
|
|
825
|
-
{
|
|
826
|
-
tag: "a",
|
|
827
|
-
attrs: r
|
|
828
|
-
}
|
|
829
|
-
]
|
|
830
|
-
};
|
|
831
|
-
}, gn = (o) => ({
|
|
832
|
-
tag: [
|
|
833
|
-
{
|
|
834
|
-
tag: "span",
|
|
835
|
-
attrs: o.attrs
|
|
836
|
-
}
|
|
837
|
-
]
|
|
838
|
-
}), hn = () => ({
|
|
839
|
-
tag: "sub"
|
|
840
|
-
}), yn = () => ({
|
|
841
|
-
tag: "sup"
|
|
842
|
-
}), bn = (o) => ({
|
|
843
|
-
tag: [
|
|
844
|
-
{
|
|
845
|
-
tag: "span",
|
|
846
|
-
attrs: o.attrs
|
|
847
|
-
}
|
|
848
|
-
]
|
|
849
|
-
}), mn = (o) => {
|
|
850
|
-
var e;
|
|
851
|
-
return (e = o.attrs) != null && e.color ? {
|
|
852
|
-
tag: [
|
|
853
|
-
{
|
|
854
|
-
tag: "span",
|
|
855
|
-
attrs: {
|
|
856
|
-
style: `background-color:${o.attrs.color};`
|
|
857
|
-
}
|
|
858
|
-
}
|
|
859
|
-
]
|
|
860
|
-
} : {
|
|
861
|
-
tag: ""
|
|
862
|
-
};
|
|
863
|
-
}, _n = (o) => {
|
|
864
|
-
var e;
|
|
865
|
-
return (e = o.attrs) != null && e.color ? {
|
|
866
|
-
tag: [
|
|
867
|
-
{
|
|
868
|
-
tag: "span",
|
|
869
|
-
attrs: {
|
|
870
|
-
style: `color:${o.attrs.color}`
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
]
|
|
874
|
-
} : {
|
|
875
|
-
tag: ""
|
|
876
|
-
};
|
|
877
|
-
}, vn = {
|
|
878
|
-
nodes: {
|
|
879
|
-
horizontal_rule: Yr,
|
|
880
|
-
blockquote: Xr,
|
|
881
|
-
bullet_list: Zr,
|
|
882
|
-
code_block: Qr,
|
|
883
|
-
hard_break: Vr,
|
|
884
|
-
heading: tn,
|
|
885
|
-
image: en,
|
|
886
|
-
list_item: rn,
|
|
887
|
-
ordered_list: nn,
|
|
888
|
-
paragraph: on,
|
|
889
|
-
emoji: an
|
|
890
|
-
},
|
|
891
|
-
marks: {
|
|
892
|
-
bold: sn,
|
|
893
|
-
strike: ln,
|
|
894
|
-
underline: cn,
|
|
895
|
-
strong: un,
|
|
896
|
-
code: fn,
|
|
897
|
-
italic: pn,
|
|
898
|
-
link: dn,
|
|
899
|
-
styled: gn,
|
|
900
|
-
subscript: hn,
|
|
901
|
-
superscript: yn,
|
|
902
|
-
anchor: bn,
|
|
903
|
-
highlight: mn,
|
|
904
|
-
textStyle: _n
|
|
905
|
-
}
|
|
906
|
-
}, Tn = function(o) {
|
|
907
|
-
const e = {
|
|
908
|
-
"&": "&",
|
|
909
|
-
"<": "<",
|
|
910
|
-
">": ">",
|
|
911
|
-
'"': """,
|
|
912
|
-
"'": "'"
|
|
913
|
-
}, r = /[&<>"']/g, s = RegExp(r.source);
|
|
914
|
-
return o && s.test(o) ? o.replace(r, (i) => e[i]) : o;
|
|
915
|
-
};
|
|
916
|
-
class wn {
|
|
917
|
-
constructor(e) {
|
|
918
|
-
O(this, "marks"), O(this, "nodes"), e || (e = vn), this.marks = e.marks || [], this.nodes = e.nodes || [];
|
|
919
|
-
}
|
|
920
|
-
addNode(e, r) {
|
|
921
|
-
this.nodes[e] = r;
|
|
922
|
-
}
|
|
923
|
-
addMark(e, r) {
|
|
924
|
-
this.marks[e] = r;
|
|
925
|
-
}
|
|
926
|
-
render(e, r = { optimizeImages: !1 }) {
|
|
927
|
-
if (e && e.content && Array.isArray(e.content)) {
|
|
928
|
-
let s = "";
|
|
929
|
-
return e.content.forEach((i) => {
|
|
930
|
-
s += this.renderNode(i);
|
|
931
|
-
}), r.optimizeImages ? this.optimizeImages(s, r.optimizeImages) : s;
|
|
932
|
-
}
|
|
933
|
-
return console.warn(
|
|
934
|
-
`The render method must receive an Object with a "content" field.
|
|
935
|
-
The "content" field must be an array of nodes as the type ISbRichtext.
|
|
936
|
-
ISbRichtext:
|
|
937
|
-
content?: ISbRichtext[]
|
|
938
|
-
marks?: ISbRichtext[]
|
|
939
|
-
attrs?: any
|
|
940
|
-
text?: string
|
|
941
|
-
type: string
|
|
942
|
-
|
|
943
|
-
Example:
|
|
944
|
-
{
|
|
945
|
-
content: [
|
|
946
|
-
{
|
|
947
|
-
content: [
|
|
948
|
-
{
|
|
949
|
-
text: 'Hello World',
|
|
950
|
-
type: 'text'
|
|
951
|
-
}
|
|
952
|
-
],
|
|
953
|
-
type: 'paragraph'
|
|
954
|
-
}
|
|
955
|
-
],
|
|
956
|
-
type: 'doc'
|
|
957
|
-
}`
|
|
958
|
-
), "";
|
|
959
|
-
}
|
|
960
|
-
optimizeImages(e, r) {
|
|
961
|
-
let s = 0, i = 0, l = "", u = "";
|
|
962
|
-
typeof r != "boolean" && (typeof r.width == "number" && r.width > 0 && (l += `width="${r.width}" `, s = r.width), typeof r.height == "number" && r.height > 0 && (l += `height="${r.height}" `, i = r.height), (r.loading === "lazy" || r.loading === "eager") && (l += `loading="${r.loading}" `), typeof r.class == "string" && r.class.length > 0 && (l += `class="${r.class}" `), r.filters && (typeof r.filters.blur == "number" && r.filters.blur >= 0 && r.filters.blur <= 100 && (u += `:blur(${r.filters.blur})`), typeof r.filters.brightness == "number" && r.filters.brightness >= -100 && r.filters.brightness <= 100 && (u += `:brightness(${r.filters.brightness})`), r.filters.fill && (r.filters.fill.match(/[0-9A-Fa-f]{6}/g) || r.filters.fill === "transparent") && (u += `:fill(${r.filters.fill})`), r.filters.format && ["webp", "png", "jpeg"].includes(r.filters.format) && (u += `:format(${r.filters.format})`), typeof r.filters.grayscale == "boolean" && r.filters.grayscale && (u += ":grayscale()"), typeof r.filters.quality == "number" && r.filters.quality >= 0 && r.filters.quality <= 100 && (u += `:quality(${r.filters.quality})`), r.filters.rotate && [90, 180, 270].includes(r.filters.rotate) && (u += `:rotate(${r.filters.rotate})`), u.length > 0 && (u = "/filters" + u))), l.length > 0 && (e = e.replace(/<img/g, `<img ${l.trim()}`));
|
|
963
|
-
const h = s > 0 || i > 0 || u.length > 0 ? `${s}x${i}${u}` : "";
|
|
964
|
-
return e = e.replace(
|
|
965
|
-
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,
|
|
966
|
-
`a.storyblok.com/f/$1/$2.$3/m/${h}`
|
|
967
|
-
), typeof r != "boolean" && (r.sizes || r.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (d) => {
|
|
968
|
-
var g, v;
|
|
969
|
-
const T = d.match(
|
|
970
|
-
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g
|
|
971
|
-
);
|
|
972
|
-
if (T && T.length > 0) {
|
|
973
|
-
const w = {
|
|
974
|
-
srcset: (g = r.srcset) == null ? void 0 : g.map((A) => {
|
|
975
|
-
if (typeof A == "number")
|
|
976
|
-
return `//${T}/m/${A}x0${u} ${A}w`;
|
|
977
|
-
if (typeof A == "object" && A.length === 2) {
|
|
978
|
-
let P = 0, B = 0;
|
|
979
|
-
return typeof A[0] == "number" && (P = A[0]), typeof A[1] == "number" && (B = A[1]), `//${T}/m/${P}x${B}${u} ${P}w`;
|
|
980
|
-
}
|
|
981
|
-
}).join(", "),
|
|
982
|
-
sizes: (v = r.sizes) == null ? void 0 : v.map((A) => A).join(", ")
|
|
983
|
-
};
|
|
984
|
-
let E = "";
|
|
985
|
-
return w.srcset && (E += `srcset="${w.srcset}" `), w.sizes && (E += `sizes="${w.sizes}" `), d.replace(/<img/g, `<img ${E.trim()}`);
|
|
986
|
-
}
|
|
987
|
-
return d;
|
|
988
|
-
})), e;
|
|
989
|
-
}
|
|
990
|
-
renderNode(e) {
|
|
991
|
-
const r = [];
|
|
992
|
-
e.marks && e.marks.forEach((i) => {
|
|
993
|
-
const l = this.getMatchingMark(i);
|
|
994
|
-
l && l.tag !== "" && r.push(this.renderOpeningTag(l.tag));
|
|
995
|
-
});
|
|
996
|
-
const s = this.getMatchingNode(e);
|
|
997
|
-
return s && s.tag && r.push(this.renderOpeningTag(s.tag)), e.content ? e.content.forEach((i) => {
|
|
998
|
-
r.push(this.renderNode(i));
|
|
999
|
-
}) : e.text ? r.push(Tn(e.text)) : s && s.singleTag ? r.push(this.renderTag(s.singleTag, " /")) : s && s.html ? r.push(s.html) : e.type === "emoji" && r.push(this.renderEmoji(e)), s && s.tag && r.push(this.renderClosingTag(s.tag)), e.marks && e.marks.slice(0).reverse().forEach((i) => {
|
|
1000
|
-
const l = this.getMatchingMark(i);
|
|
1001
|
-
l && l.tag !== "" && r.push(this.renderClosingTag(l.tag));
|
|
1002
|
-
}), r.join("");
|
|
1003
|
-
}
|
|
1004
|
-
renderTag(e, r) {
|
|
1005
|
-
return e.constructor === String ? `<${e}${r}>` : e.map((s) => {
|
|
1006
|
-
if (s.constructor === String)
|
|
1007
|
-
return `<${s}${r}>`;
|
|
1008
|
-
{
|
|
1009
|
-
let i = `<${s.tag}`;
|
|
1010
|
-
if (s.attrs)
|
|
1011
|
-
for (const l in s.attrs) {
|
|
1012
|
-
const u = s.attrs[l];
|
|
1013
|
-
u !== null && (i += ` ${l}="${u}"`);
|
|
1014
|
-
}
|
|
1015
|
-
return `${i}${r}>`;
|
|
1016
|
-
}
|
|
1017
|
-
}).join("");
|
|
1018
|
-
}
|
|
1019
|
-
renderOpeningTag(e) {
|
|
1020
|
-
return this.renderTag(e, "");
|
|
1021
|
-
}
|
|
1022
|
-
renderClosingTag(e) {
|
|
1023
|
-
return e.constructor === String ? `</${e}>` : e.slice(0).reverse().map((r) => r.constructor === String ? `</${r}>` : `</${r.tag}>`).join("");
|
|
1024
|
-
}
|
|
1025
|
-
getMatchingNode(e) {
|
|
1026
|
-
const r = this.nodes[e.type];
|
|
1027
|
-
if (typeof r == "function")
|
|
1028
|
-
return r(e);
|
|
1029
|
-
}
|
|
1030
|
-
getMatchingMark(e) {
|
|
1031
|
-
const r = this.marks[e.type];
|
|
1032
|
-
if (typeof r == "function")
|
|
1033
|
-
return r(e);
|
|
1034
|
-
}
|
|
1035
|
-
renderEmoji(e) {
|
|
1036
|
-
if (e.attrs.emoji)
|
|
1037
|
-
return e.attrs.emoji;
|
|
1038
|
-
const r = [
|
|
1039
|
-
{
|
|
1040
|
-
tag: "img",
|
|
1041
|
-
attrs: {
|
|
1042
|
-
src: e.attrs.fallbackImage,
|
|
1043
|
-
draggable: "false",
|
|
1044
|
-
loading: "lazy",
|
|
1045
|
-
align: "absmiddle"
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
];
|
|
1049
|
-
return this.renderTag(r, " /");
|
|
1050
|
-
}
|
|
1051
|
-
}
|
|
1052
|
-
const jn = (o) => {
|
|
1053
|
-
if (typeof o != "object" || typeof o._editable > "u")
|
|
1054
|
-
return {};
|
|
1055
|
-
try {
|
|
1056
|
-
const e = JSON.parse(
|
|
1057
|
-
o._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
|
|
1058
|
-
);
|
|
1059
|
-
return e ? {
|
|
1060
|
-
"data-blok-c": JSON.stringify(e),
|
|
1061
|
-
"data-blok-uid": e.id + "-" + e.uid
|
|
1062
|
-
} : {};
|
|
1063
|
-
} catch {
|
|
1064
|
-
return {};
|
|
1065
|
-
}
|
|
1066
|
-
};
|
|
1067
|
-
let An, In = "https://app.storyblok.com/f/storyblok-v2-latest.js";
|
|
1068
|
-
const kn = (o, e) => {
|
|
1069
|
-
o.addNode("blok", (r) => {
|
|
1070
|
-
let s = "";
|
|
1071
|
-
return r.attrs.body.forEach((i) => {
|
|
1072
|
-
s += e(i.component, i);
|
|
1073
|
-
}), {
|
|
1074
|
-
html: s
|
|
1075
|
-
};
|
|
1076
|
-
});
|
|
1077
|
-
}, On = (o) => !o || !(o != null && o.content.some((e) => e.content || e.type === "blok" || e.type === "horizontal_rule")), Sn = (o, e, r) => {
|
|
1078
|
-
let s = r || An;
|
|
1079
|
-
if (!s) {
|
|
1080
|
-
console.error(
|
|
1081
|
-
"Please initialize the Storyblok SDK before calling the renderRichText function"
|
|
1082
|
-
);
|
|
1083
|
-
return;
|
|
1084
|
-
}
|
|
1085
|
-
return On(o) ? "" : (e && (s = new wn(e.schema), e.resolver && kn(s, e.resolver)), s.render(o));
|
|
1086
|
-
}, xn = () => Hr(In);
|
|
1087
1114
|
let qt;
|
|
1088
1115
|
async function En(o) {
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
if (e === "input" && r) {
|
|
1116
|
+
const { action: r, story: e } = o || {};
|
|
1117
|
+
if (r === "input" && e) {
|
|
1092
1118
|
const i = async () => {
|
|
1093
|
-
const
|
|
1094
|
-
|
|
1095
|
-
const
|
|
1096
|
-
|
|
1097
|
-
return;
|
|
1098
|
-
const v = document.querySelector('[data-blok-focused="true"]');
|
|
1099
|
-
Cn(g, h, v);
|
|
1100
|
-
const T = performance.now();
|
|
1101
|
-
console.log(`updateDOMWithNewBody took ${T - d} milliseconds.`), console.log(`total time took ${T - u} milliseconds.`);
|
|
1119
|
+
const l = await jn(e), u = document.body;
|
|
1120
|
+
if (l.outerHTML === u.outerHTML) return;
|
|
1121
|
+
const f = document.querySelector('[data-blok-focused="true"]');
|
|
1122
|
+
Cn(u, l, f);
|
|
1102
1123
|
};
|
|
1103
|
-
clearTimeout(qt), qt = setTimeout(i,
|
|
1124
|
+
clearTimeout(qt), qt = setTimeout(i, 500);
|
|
1104
1125
|
}
|
|
1105
|
-
["published", "change"].includes(
|
|
1126
|
+
["published", "change"].includes(o == null ? void 0 : o.action) && location.reload();
|
|
1106
1127
|
}
|
|
1107
|
-
function Cn(o,
|
|
1108
|
-
if (
|
|
1109
|
-
const
|
|
1110
|
-
`[data-blok-uid="${
|
|
1128
|
+
function Cn(o, r, e) {
|
|
1129
|
+
if (e) {
|
|
1130
|
+
const i = e.getAttribute("data-blok-uid"), s = r.querySelector(
|
|
1131
|
+
`[data-blok-uid="${i}"]`
|
|
1111
1132
|
);
|
|
1112
|
-
|
|
1133
|
+
s && (s.setAttribute("data-blok-focused", "true"), e.replaceWith(s));
|
|
1113
1134
|
} else
|
|
1114
|
-
|
|
1135
|
+
o.replaceWith(r);
|
|
1115
1136
|
}
|
|
1116
|
-
async function
|
|
1117
|
-
const
|
|
1137
|
+
async function jn(o) {
|
|
1138
|
+
const e = await (await fetch(location.href, {
|
|
1118
1139
|
method: "POST",
|
|
1119
1140
|
body: JSON.stringify({
|
|
1120
1141
|
...o,
|
|
@@ -1124,106 +1145,142 @@ async function $n(o) {
|
|
|
1124
1145
|
"Content-Type": "application/json"
|
|
1125
1146
|
}
|
|
1126
1147
|
})).text();
|
|
1127
|
-
return new DOMParser().parseFromString(
|
|
1148
|
+
return new DOMParser().parseFromString(e, "text/html").body;
|
|
1128
1149
|
}
|
|
1129
1150
|
function Rn() {
|
|
1130
1151
|
return globalThis.storyblokApiInstance || console.error("storyblokApiInstance has not been initialized correctly"), globalThis.storyblokApiInstance;
|
|
1131
1152
|
}
|
|
1132
|
-
async function
|
|
1153
|
+
async function Pn(o, r = {}, e = {}, i) {
|
|
1133
1154
|
globalThis.storyblokApiInstance || console.error("storyblokApiInstance has not been initialized correctly");
|
|
1134
|
-
let
|
|
1135
|
-
if (
|
|
1136
|
-
|
|
1155
|
+
let s = null;
|
|
1156
|
+
if (i && i.locals._storyblok_preview_data)
|
|
1157
|
+
s = i.locals._storyblok_preview_data;
|
|
1137
1158
|
else {
|
|
1138
1159
|
const { data: l } = await globalThis.storyblokApiInstance.get(
|
|
1139
1160
|
o,
|
|
1140
|
-
|
|
1141
|
-
|
|
1161
|
+
r,
|
|
1162
|
+
e
|
|
1142
1163
|
);
|
|
1143
|
-
|
|
1164
|
+
s = l.story;
|
|
1144
1165
|
}
|
|
1145
|
-
return
|
|
1166
|
+
return s;
|
|
1146
1167
|
}
|
|
1147
|
-
function
|
|
1148
|
-
const
|
|
1149
|
-
if (!
|
|
1168
|
+
function Mn(o, r) {
|
|
1169
|
+
const e = globalThis.storyblokApiInstance.richTextResolver;
|
|
1170
|
+
if (!e) {
|
|
1150
1171
|
console.error(
|
|
1151
1172
|
"Please initialize the Storyblok SDK before calling the renderRichText function"
|
|
1152
1173
|
);
|
|
1153
1174
|
return;
|
|
1154
1175
|
}
|
|
1155
|
-
return
|
|
1176
|
+
return _n(o, r, e);
|
|
1156
1177
|
}
|
|
1157
1178
|
function Nn(o) {
|
|
1158
|
-
const
|
|
1179
|
+
const r = {
|
|
1159
1180
|
useCustomApi: !1,
|
|
1160
1181
|
bridge: !0,
|
|
1161
1182
|
componentsDir: "src",
|
|
1162
1183
|
enableFallbackComponent: !1,
|
|
1184
|
+
livePreview: !1,
|
|
1163
1185
|
...o
|
|
1164
1186
|
};
|
|
1165
1187
|
return {
|
|
1166
1188
|
name: "@storyblok/astro",
|
|
1167
1189
|
hooks: {
|
|
1168
1190
|
"astro:config:setup": ({
|
|
1169
|
-
injectScript:
|
|
1170
|
-
updateConfig:
|
|
1171
|
-
addDevToolbarApp:
|
|
1172
|
-
addMiddleware: l
|
|
1191
|
+
injectScript: e,
|
|
1192
|
+
updateConfig: i,
|
|
1193
|
+
addDevToolbarApp: s,
|
|
1194
|
+
addMiddleware: l,
|
|
1195
|
+
config: u
|
|
1173
1196
|
}) => {
|
|
1174
|
-
|
|
1197
|
+
if (i({
|
|
1175
1198
|
vite: {
|
|
1176
1199
|
plugins: [
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1200
|
+
Or(
|
|
1201
|
+
r.accessToken,
|
|
1202
|
+
r.useCustomApi,
|
|
1203
|
+
r.apiOptions
|
|
1181
1204
|
),
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1205
|
+
Pr(
|
|
1206
|
+
r.componentsDir,
|
|
1207
|
+
r.components,
|
|
1208
|
+
r.enableFallbackComponent,
|
|
1209
|
+
r.customFallbackComponent
|
|
1187
1210
|
),
|
|
1188
|
-
|
|
1189
|
-
|
|
1211
|
+
Mr(r),
|
|
1212
|
+
Sn(
|
|
1213
|
+
r.livePreview,
|
|
1214
|
+
u.output
|
|
1215
|
+
)
|
|
1190
1216
|
]
|
|
1191
1217
|
}
|
|
1192
|
-
}), r(
|
|
1218
|
+
}), r.livePreview && (u == null ? void 0 : u.output) !== "server")
|
|
1219
|
+
throw new Error(
|
|
1220
|
+
"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."
|
|
1221
|
+
);
|
|
1222
|
+
if (e(
|
|
1193
1223
|
"page-ssr",
|
|
1194
1224
|
`
|
|
1195
1225
|
import { storyblokApiInstance } from "virtual:storyblok-init";
|
|
1196
1226
|
globalThis.storyblokApiInstance = storyblokApiInstance;
|
|
1197
1227
|
`
|
|
1198
|
-
),
|
|
1228
|
+
), r.bridge && !r.livePreview) {
|
|
1229
|
+
let f = "";
|
|
1230
|
+
if (typeof r.bridge == "object") {
|
|
1231
|
+
const g = { ...r.bridge };
|
|
1232
|
+
f = `const storyblokInstance = new StoryblokBridge(${JSON.stringify(
|
|
1233
|
+
g
|
|
1234
|
+
)});`;
|
|
1235
|
+
} else
|
|
1236
|
+
f = "const storyblokInstance = new StoryblokBridge()";
|
|
1237
|
+
e(
|
|
1238
|
+
"page",
|
|
1239
|
+
`
|
|
1240
|
+
import { loadStoryblokBridge } from "@storyblok/astro";
|
|
1241
|
+
loadStoryblokBridge().then(() => {
|
|
1242
|
+
const { StoryblokBridge, location } = window;
|
|
1243
|
+
${f}
|
|
1244
|
+
|
|
1245
|
+
storyblokInstance.on(["published", "change"], (event) => {
|
|
1246
|
+
if (!event.slugChanged) {
|
|
1247
|
+
location.reload(true);
|
|
1248
|
+
}
|
|
1249
|
+
});
|
|
1250
|
+
});
|
|
1251
|
+
`
|
|
1252
|
+
);
|
|
1253
|
+
}
|
|
1254
|
+
r.livePreview && (e(
|
|
1199
1255
|
"page",
|
|
1200
1256
|
`
|
|
1201
1257
|
import { loadStoryblokBridge, handleStoryblokMessage } from "@storyblok/astro";
|
|
1202
1258
|
import { bridgeOptions } from "virtual:storyblok-bridge";
|
|
1259
|
+
console.info("The Storyblok Astro live preview feature is currently in an experimental phase, and its API is subject to change in the future.")
|
|
1203
1260
|
loadStoryblokBridge().then(() => {
|
|
1204
1261
|
const { StoryblokBridge, location } = window;
|
|
1205
1262
|
if(bridgeOptions){
|
|
1206
1263
|
const storyblokInstance = new StoryblokBridge(bridgeOptions);
|
|
1207
|
-
storyblokInstance.on(["published", "change","input"], handleStoryblokMessage);
|
|
1264
|
+
storyblokInstance.on(["published", "change", "input"], handleStoryblokMessage);
|
|
1208
1265
|
};
|
|
1209
1266
|
});
|
|
1210
1267
|
`
|
|
1211
1268
|
), l({
|
|
1212
1269
|
entrypoint: "@storyblok/astro/middleware.ts",
|
|
1213
1270
|
order: "pre"
|
|
1214
|
-
})),
|
|
1271
|
+
})), s("@storyblok/astro/toolbarApp.ts");
|
|
1215
1272
|
}
|
|
1216
1273
|
}
|
|
1217
1274
|
};
|
|
1218
1275
|
}
|
|
1219
1276
|
export {
|
|
1220
|
-
|
|
1221
|
-
|
|
1277
|
+
hn as RichTextResolver,
|
|
1278
|
+
dn as RichTextSchema,
|
|
1222
1279
|
Nn as default,
|
|
1223
1280
|
En as handleStoryblokMessage,
|
|
1224
1281
|
xn as loadStoryblokBridge,
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1282
|
+
Mn as renderRichText,
|
|
1283
|
+
$n as storyblokEditable,
|
|
1284
|
+
Pn as useStoryblok,
|
|
1228
1285
|
Rn as useStoryblokApi
|
|
1229
1286
|
};
|