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