@storyblok/astro 4.0.5 → 4.1.0-alpha.2
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 +50 -0
- package/dist/storyblok-astro.js +21 -10
- package/dist/storyblok-astro.mjs +979 -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 +12 -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 +19 -7
- package/utils/generateFinalBridgeObject.ts +42 -0
- package/utils/parseAstCode.ts +43 -0
package/dist/storyblok-astro.mjs
CHANGED
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
function
|
|
2
|
-
const
|
|
1
|
+
function Or(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 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"), Ut = new RegExp("\\d+" + Gt.source, "gu"), xr = (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 v = o[g];
|
|
27
|
+
f = g > 2 ? o[g - 3] === "-" : !0, s && Cr.test(v) ? (o = o.slice(0, g) + "-" + o.slice(g), s = !1, u = l, l = !0, g++) : l && u && jr.test(v) && (!f || a) ? (o = o.slice(0, g - 1) + "-" + o.slice(g - 1), u = l, l = !1, s = !0) : (s = e(v) === v && r(v) !== v, u = l, l = r(v) === v && e(v) !== v);
|
|
28
28
|
}
|
|
29
|
-
return
|
|
30
|
-
},
|
|
31
|
-
function
|
|
32
|
-
if (!(typeof
|
|
29
|
+
return o;
|
|
30
|
+
}, Er = (o, e) => (zt.lastIndex = 0, o.replaceAll(zt, (r) => e(r))), Rr = (o, e) => (Lt.lastIndex = 0, Ut.lastIndex = 0, o.replaceAll(Ut, (r, a, s) => ["_", "-"].includes(o.charAt(s + r.length)) ? r : e(r)).replaceAll(Lt, (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 = xr(o, r, a, e.preserveConsecutiveUppercase)), o = o.replace($r, ""), o = e.preserveConsecutiveUppercase ? Er(o, r) : r(o), e.pascalCase && (o = a(o.charAt(0)) + o.slice(1)), Rr(o, a));
|
|
42
42
|
}
|
|
43
|
-
function
|
|
44
|
-
const s = "virtual:storyblok-components",
|
|
43
|
+
function Pr(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 [_, T] of Object.entries(e)) {
|
|
55
|
+
const w = await this.resolve(
|
|
56
|
+
"/" + o + "/" + T + ".astro"
|
|
57
57
|
);
|
|
58
|
-
if (
|
|
59
|
-
|
|
60
|
-
else if (
|
|
61
|
-
|
|
58
|
+
if (w)
|
|
59
|
+
f.push(`import ${Dt(_)} from "${w.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 + "/" + T}.astro" exist?`
|
|
65
65
|
);
|
|
66
66
|
}
|
|
67
|
-
let
|
|
68
|
-
if (
|
|
69
|
-
if (
|
|
70
|
-
const
|
|
71
|
-
"/" +
|
|
67
|
+
let v = "";
|
|
68
|
+
if (r)
|
|
69
|
+
if (v = ",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(",")}${v}}`;
|
|
86
|
+
if (r)
|
|
87
|
+
return `${f[0]}; export default {${v.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 Mr(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 = [], Nr = (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 zr = Object.defineProperty, Lr = (o, e, r) => e in o ? zr(o, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[e] = r, O = (o, e, r) => (Lr(o, typeof e != "symbol" ? e + "" : e, r), r);
|
|
127
|
+
class Ur {
|
|
128
128
|
constructor() {
|
|
129
|
-
|
|
130
|
-
...
|
|
131
|
-
per_page:
|
|
132
|
-
page:
|
|
133
|
-
})),
|
|
134
|
-
const
|
|
135
|
-
return this.arrayFrom(
|
|
136
|
-
}),
|
|
137
|
-
const
|
|
129
|
+
O(this, "isCDNUrl", (e = "") => e.indexOf("/cdn/") > -1), O(this, "getOptionsPage", (e, r = 25, a = 1) => ({
|
|
130
|
+
...e,
|
|
131
|
+
per_page: r,
|
|
132
|
+
page: a
|
|
133
|
+
})), 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) => {
|
|
134
|
+
const a = Math.abs(r - e) || 0, s = e < r ? 1 : -1;
|
|
135
|
+
return this.arrayFrom(a, (l, u) => u * s + e);
|
|
136
|
+
}), O(this, "asyncMap", async (e, r) => Promise.all(e.map(r))), O(this, "flatMap", (e = [], r) => e.map(r).reduce((a, s) => [...a, ...s], [])), O(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 Dr = 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
|
+
}, Br = (o) => o === "email", Fr = () => ({
|
|
198
198
|
singleTag: "hr"
|
|
199
|
-
}),
|
|
199
|
+
}), Hr = () => ({
|
|
200
200
|
tag: "blockquote"
|
|
201
|
-
}),
|
|
201
|
+
}), qr = () => ({
|
|
202
202
|
tag: "ul"
|
|
203
|
-
}),
|
|
203
|
+
}), Gr = (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
|
+
}), Jr = () => ({
|
|
212
212
|
singleTag: "br"
|
|
213
|
-
}),
|
|
214
|
-
tag: `h${
|
|
215
|
-
}),
|
|
213
|
+
}), Kr = (o) => ({
|
|
214
|
+
tag: `h${o.attrs.level}`
|
|
215
|
+
}), Wr = (o) => ({
|
|
216
216
|
singleTag: [
|
|
217
217
|
{
|
|
218
218
|
tag: "img",
|
|
219
|
-
attrs:
|
|
219
|
+
attrs: Dr(o.attrs, ["src", "alt", "title"])
|
|
220
220
|
}
|
|
221
221
|
]
|
|
222
|
-
}),
|
|
222
|
+
}), Yr = () => ({
|
|
223
223
|
tag: "li"
|
|
224
|
-
}),
|
|
224
|
+
}), Xr = () => ({
|
|
225
225
|
tag: "ol"
|
|
226
|
-
}),
|
|
226
|
+
}), Zr = () => ({
|
|
227
227
|
tag: "p"
|
|
228
|
-
}),
|
|
228
|
+
}), Qr = (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
|
+
}), Vr = () => ({
|
|
240
240
|
tag: "b"
|
|
241
|
-
}),
|
|
241
|
+
}), tn = () => ({
|
|
242
242
|
tag: "s"
|
|
243
|
-
}),
|
|
243
|
+
}), en = () => ({
|
|
244
244
|
tag: "u"
|
|
245
|
-
}),
|
|
245
|
+
}), rn = () => ({
|
|
246
246
|
tag: "strong"
|
|
247
|
-
}),
|
|
247
|
+
}), nn = () => ({
|
|
248
248
|
tag: "code"
|
|
249
|
-
}),
|
|
249
|
+
}), on = () => ({
|
|
250
250
|
tag: "i"
|
|
251
|
-
}),
|
|
252
|
-
if (!
|
|
251
|
+
}), an = (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 Ur().escapeHTML, r = { ...o.attrs }, { linktype: a = "url" } = o.attrs;
|
|
257
|
+
if (delete r.linktype, r.href && (r.href = e(o.attrs.href || "")), Br(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
|
+
}, sn = (o) => ({
|
|
271
271
|
tag: [
|
|
272
272
|
{
|
|
273
273
|
tag: "span",
|
|
274
|
-
attrs:
|
|
274
|
+
attrs: o.attrs
|
|
275
275
|
}
|
|
276
276
|
]
|
|
277
|
-
}),
|
|
277
|
+
}), ln = () => ({
|
|
278
278
|
tag: "sub"
|
|
279
|
-
}),
|
|
279
|
+
}), cn = () => ({
|
|
280
280
|
tag: "sup"
|
|
281
|
-
}),
|
|
281
|
+
}), un = (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
|
+
}), fn = (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
|
+
}, pn = (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: 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: Xr,
|
|
327
|
+
paragraph: Zr,
|
|
328
|
+
emoji: Qr
|
|
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: Vr,
|
|
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 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 hn {
|
|
356
|
+
constructor(e) {
|
|
357
|
+
O(this, "marks"), O(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,843 @@ 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 v, _;
|
|
408
|
+
const T = 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 (T && T.length > 0) {
|
|
412
|
+
const w = {
|
|
413
|
+
srcset: (v = r.srcset) == null ? void 0 : v.map((k) => {
|
|
414
|
+
if (typeof k == "number")
|
|
415
|
+
return `//${T}/m/${k}x0${u} ${k}w`;
|
|
416
|
+
if (typeof k == "object" && k.length === 2) {
|
|
417
|
+
let M = 0, F = 0;
|
|
418
|
+
return typeof k[0] == "number" && (M = k[0]), typeof k[1] == "number" && (F = k[1]), `//${T}/m/${M}x${F}${u} ${M}w`;
|
|
419
419
|
}
|
|
420
420
|
}).join(", "),
|
|
421
|
-
sizes: (
|
|
421
|
+
sizes: (_ = r.sizes) == null ? void 0 : _.map((k) => k).join(", ")
|
|
422
422
|
};
|
|
423
|
-
let
|
|
424
|
-
return
|
|
423
|
+
let A = "";
|
|
424
|
+
return w.srcset && (A += `srcset="${w.srcset}" `), w.sizes && (A += `sizes="${w.sizes}" `), g.replace(/<img/g, `<img ${A.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(gn(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 bn, yn = "https://app.storyblok.com/f/storyblok-v2-latest.js";
|
|
507
|
+
const mn = (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
|
+
}, vn = (o) => !o || !(o != null && o.content.some((e) => e.content || e.type === "blok" || e.type === "horizontal_rule")), _n = (o, e, r) => {
|
|
517
|
+
let a = r || bn;
|
|
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 vn(o) ? "" : (e && (a = new hn(e.schema), e.resolver && mn(a, e.resolver)), a.render(o));
|
|
525
|
+
}, xn = () => Nr(yn);
|
|
526
|
+
function wn(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 Tn(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]", v = "[object AsyncFunction]", _ = "[object Boolean]", T = "[object Date]", w = "[object Error]", A = "[object Function]", k = "[object GeneratorFunction]", M = "[object Map]", F = "[object Number]", Jt = "[object Null]", pt = "[object Object]", Kt = "[object Proxy]", Wt = "[object RegExp]", Yt = "[object Set]", Xt = "[object String]", Zt = "[object Undefined]", Qt = "[object WeakMap]", Vt = "[object ArrayBuffer]", te = "[object DataView]", ee = "[object Float32Array]", re = "[object Float64Array]", ne = "[object Int8Array]", oe = "[object Int16Array]", ie = "[object Int32Array]", ae = "[object Uint8Array]", se = "[object Uint8ClampedArray]", le = "[object Uint16Array]", ce = "[object Uint32Array]", ue = /[\\^$.*+?()[\]{}|]/g, fe = /^\[object .+?Constructor\]$/, pe = /^(?:0|[1-9]\d*)$/, b = {};
|
|
551
|
+
b[ee] = b[re] = b[ne] = b[oe] = b[ie] = b[ae] = b[se] = b[le] = b[ce] = !0, b[f] = b[g] = b[Vt] = b[_] = b[te] = b[T] = b[w] = b[A] = b[M] = b[F] = b[pt] = b[Wt] = b[Yt] = b[Xt] = b[Qt] = !1;
|
|
552
|
+
var dt = typeof Z == "object" && Z && Z.Object === Object && Z, de = typeof self == "object" && self && self.Object === Object && self, N = dt || de || Function("return this")(), gt = e && !e.nodeType && e, z = gt && !0 && o && !o.nodeType && o, ht = z && z.exports === gt, V = ht && dt.process, bt = function() {
|
|
553
|
+
try {
|
|
554
|
+
var t = z && z.require && z.require("util").types;
|
|
555
|
+
return t || V && V.binding && V.binding("util");
|
|
556
|
+
} catch {
|
|
557
|
+
}
|
|
558
|
+
}(), yt = bt && bt.isTypedArray;
|
|
559
|
+
function ge(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 he(t, n) {
|
|
573
|
+
for (var i = -1, c = Array(t); ++i < t; )
|
|
574
|
+
c[i] = n(i);
|
|
575
|
+
return c;
|
|
576
|
+
}
|
|
577
|
+
function be(t) {
|
|
578
|
+
return function(n) {
|
|
579
|
+
return t(n);
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
function ye(t, n) {
|
|
583
|
+
return t == null ? void 0 : t[n];
|
|
584
|
+
}
|
|
585
|
+
function me(t, n) {
|
|
586
|
+
return function(i) {
|
|
587
|
+
return t(n(i));
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
var ve = Array.prototype, _e = Function.prototype, H = Object.prototype, tt = N["__core-js_shared__"], q = _e.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, we = q.call(Object), Te = RegExp(
|
|
594
|
+
"^" + q.call(C).replace(ue, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
|
|
595
|
+
), 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() {
|
|
596
|
+
try {
|
|
597
|
+
var t = nt(Object, "defineProperty");
|
|
598
|
+
return t({}, "", {}), t;
|
|
599
|
+
} catch {
|
|
600
|
+
}
|
|
601
|
+
}(), Ie = G ? G.isBuffer : void 0, It = Math.max, Se = Date.now, St = nt(N, "Map"), L = nt(Object, "create"), Oe = /* @__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 x(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 Ce() {
|
|
622
|
+
this.__data__ = L ? L(null) : {}, this.size = 0;
|
|
623
|
+
}
|
|
624
|
+
function je(t) {
|
|
625
|
+
var n = this.has(t) && delete this.__data__[t];
|
|
626
|
+
return this.size -= n ? 1 : 0, n;
|
|
627
|
+
}
|
|
628
|
+
function $e(t) {
|
|
629
|
+
var n = this.__data__;
|
|
630
|
+
if (L) {
|
|
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 xe(t) {
|
|
637
|
+
var n = this.__data__;
|
|
638
|
+
return L ? n[t] !== void 0 : C.call(n, t);
|
|
639
|
+
}
|
|
640
|
+
function Ee(t, n) {
|
|
641
|
+
var i = this.__data__;
|
|
642
|
+
return this.size += this.has(t) ? 0 : 1, i[t] = L && n === void 0 ? a : n, this;
|
|
643
|
+
}
|
|
644
|
+
x.prototype.clear = Ce, x.prototype.delete = je, x.prototype.get = $e, x.prototype.has = xe, x.prototype.set = Ee;
|
|
645
|
+
function j(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 Re() {
|
|
653
|
+
this.__data__ = [], this.size = 0;
|
|
654
|
+
}
|
|
655
|
+
function Pe(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() : Ae.call(n, i, 1), --this.size, !0;
|
|
661
|
+
}
|
|
662
|
+
function Me(t) {
|
|
663
|
+
var n = this.__data__, i = K(n, t);
|
|
664
|
+
return i < 0 ? void 0 : n[i][1];
|
|
665
|
+
}
|
|
666
|
+
function Ne(t) {
|
|
667
|
+
return K(this.__data__, t) > -1;
|
|
668
|
+
}
|
|
669
|
+
function ze(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
|
+
j.prototype.clear = Re, j.prototype.delete = Pe, j.prototype.get = Me, j.prototype.has = Ne, j.prototype.set = ze;
|
|
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 Le() {
|
|
682
|
+
this.size = 0, this.__data__ = {
|
|
683
|
+
hash: new x(),
|
|
684
|
+
map: new (St || j)(),
|
|
685
|
+
string: new x()
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
function Ue(t) {
|
|
689
|
+
var n = Y(this, t).delete(t);
|
|
690
|
+
return this.size -= n ? 1 : 0, n;
|
|
691
|
+
}
|
|
692
|
+
function De(t) {
|
|
693
|
+
return Y(this, t).get(t);
|
|
694
|
+
}
|
|
695
|
+
function Be(t) {
|
|
696
|
+
return Y(this, t).has(t);
|
|
697
|
+
}
|
|
698
|
+
function Fe(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 = Le, R.prototype.delete = Ue, R.prototype.get = De, R.prototype.has = Be, R.prototype.set = Fe;
|
|
703
|
+
function P(t) {
|
|
704
|
+
var n = this.__data__ = new j(t);
|
|
705
|
+
this.size = n.size;
|
|
706
|
+
}
|
|
707
|
+
function He() {
|
|
708
|
+
this.__data__ = new j(), this.size = 0;
|
|
709
|
+
}
|
|
710
|
+
function qe(t) {
|
|
711
|
+
var n = this.__data__, i = n.delete(t);
|
|
712
|
+
return this.size = n.size, i;
|
|
713
|
+
}
|
|
714
|
+
function Ge(t) {
|
|
715
|
+
return this.__data__.get(t);
|
|
716
|
+
}
|
|
717
|
+
function Je(t) {
|
|
718
|
+
return this.__data__.has(t);
|
|
719
|
+
}
|
|
720
|
+
function Ke(t, n) {
|
|
721
|
+
var i = this.__data__;
|
|
722
|
+
if (i instanceof j) {
|
|
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 = He, P.prototype.delete = qe, P.prototype.get = Ge, P.prototype.has = Je, P.prototype.set = Ke;
|
|
731
|
+
function We(t, n) {
|
|
732
|
+
var i = at(t), c = !i && it(t), d = !i && !c && xt(t), h = !i && !c && !d && Rt(t), y = i || c || d || h, p = y ? he(t.length, String) : [], m = p.length;
|
|
733
|
+
for (var S in t)
|
|
734
|
+
(n || C.call(t, S)) && !(y && // Safari 9 has enumerable `arguments.length` in strict mode.
|
|
735
|
+
(S == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
|
|
736
|
+
d && (S == "offset" || S == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
|
|
737
|
+
h && (S == "buffer" || S == "byteLength" || S == "byteOffset") || // Skip index properties.
|
|
738
|
+
jt(S, m))) && p.push(S);
|
|
739
|
+
return p;
|
|
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 Ye(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 Xe = cr();
|
|
763
|
+
function W(t) {
|
|
764
|
+
return t == null ? t === void 0 ? Zt : Jt : $ && $ in Object(t) ? ur(t) : br(t);
|
|
765
|
+
}
|
|
766
|
+
function Ot(t) {
|
|
767
|
+
return U(t) && W(t) == f;
|
|
768
|
+
}
|
|
769
|
+
function Ze(t) {
|
|
770
|
+
if (!E(t) || gr(t))
|
|
771
|
+
return !1;
|
|
772
|
+
var n = lt(t) ? Te : fe;
|
|
773
|
+
return n.test(_r(t));
|
|
774
|
+
}
|
|
775
|
+
function Qe(t) {
|
|
776
|
+
return U(t) && Et(t.length) && !!b[W(t)];
|
|
777
|
+
}
|
|
778
|
+
function Ve(t) {
|
|
779
|
+
if (!E(t))
|
|
780
|
+
return hr(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, d) {
|
|
787
|
+
t !== n && Xe(n, function(h, y) {
|
|
788
|
+
if (d || (d = new P()), E(h))
|
|
789
|
+
tr(t, n, y, i, Ct, c, d);
|
|
790
|
+
else {
|
|
791
|
+
var p = c ? c(ot(t, y), h, y + "", t, n, d) : void 0;
|
|
792
|
+
p === void 0 && (p = h), et(t, y, p);
|
|
793
|
+
}
|
|
794
|
+
}, Pt);
|
|
795
|
+
}
|
|
796
|
+
function tr(t, n, i, c, d, h, y) {
|
|
797
|
+
var p = ot(t, i), m = ot(n, i), S = y.get(m);
|
|
798
|
+
if (S) {
|
|
799
|
+
et(t, i, S);
|
|
800
|
+
return;
|
|
801
|
+
}
|
|
802
|
+
var I = h ? h(p, m, i + "", t, n, y) : void 0, D = I === void 0;
|
|
803
|
+
if (D) {
|
|
804
|
+
var ct = at(m), ut = !ct && xt(m), Nt = !ct && !ut && Rt(m);
|
|
805
|
+
I = m, ct || ut || Nt ? at(p) ? I = p : wr(p) ? I = ar(p) : ut ? (D = !1, I = nr(m, !0)) : Nt ? (D = !1, I = ir(m, !0)) : I = [] : Tr(m) || it(m) ? (I = p, it(p) ? I = kr(p) : (!E(p) || lt(p)) && (I = fr(m))) : D = !1;
|
|
806
|
+
}
|
|
807
|
+
D && (y.set(m, I), d(I, m, c, h, y), y.delete(m)), et(t, i, I);
|
|
808
|
+
}
|
|
809
|
+
function er(t, n) {
|
|
810
|
+
return mr(yr(t, n, Mt), t + "");
|
|
811
|
+
}
|
|
812
|
+
var rr = J ? function(t, n) {
|
|
813
|
+
return J(t, "toString", {
|
|
814
|
+
configurable: !0,
|
|
815
|
+
enumerable: !1,
|
|
816
|
+
value: Ir(n),
|
|
817
|
+
writable: !0
|
|
818
|
+
});
|
|
819
|
+
} : Mt;
|
|
820
|
+
function nr(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 or(t) {
|
|
827
|
+
var n = new t.constructor(t.byteLength);
|
|
828
|
+
return new wt(n).set(new wt(t)), n;
|
|
829
|
+
}
|
|
830
|
+
function ir(t, n) {
|
|
831
|
+
var i = n ? or(t.buffer) : t.buffer;
|
|
832
|
+
return new t.constructor(i, t.byteOffset, t.length);
|
|
833
|
+
}
|
|
834
|
+
function ar(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 sr(t, n, i, c) {
|
|
841
|
+
var d = !i;
|
|
842
|
+
i || (i = {});
|
|
843
|
+
for (var h = -1, y = n.length; ++h < y; ) {
|
|
844
|
+
var p = n[h], m = c ? c(i[p], t[p], p, i, t) : void 0;
|
|
845
|
+
m === void 0 && (m = t[p]), d ? rt(i, p, m) : Ye(i, p, m);
|
|
846
|
+
}
|
|
847
|
+
return i;
|
|
848
|
+
}
|
|
849
|
+
function lr(t) {
|
|
850
|
+
return er(function(n, i) {
|
|
851
|
+
var c = -1, d = i.length, h = d > 1 ? i[d - 1] : void 0, y = d > 2 ? i[2] : void 0;
|
|
852
|
+
for (h = t.length > 3 && typeof h == "function" ? (d--, h) : void 0, y && pr(i[0], i[1], y) && (h = d < 3 ? void 0 : h, d = 1), n = Object(n); ++c < d; ) {
|
|
853
|
+
var p = i[c];
|
|
854
|
+
p && t(n, p, c, h);
|
|
855
|
+
}
|
|
856
|
+
return n;
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
function cr(t) {
|
|
860
|
+
return function(n, i, c) {
|
|
861
|
+
for (var d = -1, h = Object(n), y = c(n), p = y.length; p--; ) {
|
|
862
|
+
var m = y[t ? p : ++d];
|
|
863
|
+
if (i(h[m], m, 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 = ye(t, n);
|
|
875
|
+
return Ze(i) ? i : void 0;
|
|
876
|
+
}
|
|
877
|
+
function ur(t) {
|
|
878
|
+
var n = C.call(t, $), i = t[$];
|
|
879
|
+
try {
|
|
880
|
+
t[$] = void 0;
|
|
881
|
+
var c = !0;
|
|
882
|
+
} catch {
|
|
883
|
+
}
|
|
884
|
+
var d = vt.call(t);
|
|
885
|
+
return c && (n ? t[$] = i : delete t[$]), d;
|
|
886
|
+
}
|
|
887
|
+
function fr(t) {
|
|
888
|
+
return typeof t.constructor == "function" && !$t(t) ? Oe(kt(t)) : {};
|
|
889
|
+
}
|
|
890
|
+
function jt(t, n) {
|
|
891
|
+
var i = typeof t;
|
|
892
|
+
return n = n ?? u, !!n && (i == "number" || i != "symbol" && pe.test(t)) && t > -1 && t % 1 == 0 && t < n;
|
|
893
|
+
}
|
|
894
|
+
function pr(t, n, i) {
|
|
895
|
+
if (!E(i))
|
|
896
|
+
return !1;
|
|
897
|
+
var c = typeof n;
|
|
898
|
+
return (c == "number" ? st(i) && jt(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 gr(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 hr(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 br(t) {
|
|
919
|
+
return vt.call(t);
|
|
920
|
+
}
|
|
921
|
+
function yr(t, n, i) {
|
|
922
|
+
return n = It(n === void 0 ? t.length - 1 : n, 0), function() {
|
|
923
|
+
for (var c = arguments, d = -1, h = It(c.length - n, 0), y = Array(h); ++d < h; )
|
|
924
|
+
y[d] = c[n + d];
|
|
925
|
+
d = -1;
|
|
926
|
+
for (var p = Array(n + 1); ++d < n; )
|
|
927
|
+
p[d] = c[d];
|
|
928
|
+
return p[n] = i(y), ge(t, this, p);
|
|
929
|
+
};
|
|
930
|
+
}
|
|
931
|
+
function ot(t, n) {
|
|
932
|
+
if (!(n === "constructor" && typeof t[n] == "function") && n != "__proto__")
|
|
933
|
+
return t[n];
|
|
934
|
+
}
|
|
935
|
+
var mr = vr(rr);
|
|
936
|
+
function vr(t) {
|
|
937
|
+
var n = 0, i = 0;
|
|
938
|
+
return function() {
|
|
939
|
+
var c = Se(), d = l - (c - i);
|
|
940
|
+
if (i = c, d > 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 _r(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") && !ke.call(t, "callee");
|
|
968
|
+
}, at = Array.isArray;
|
|
969
|
+
function st(t) {
|
|
970
|
+
return t != null && Et(t.length) && !lt(t);
|
|
971
|
+
}
|
|
972
|
+
function wr(t) {
|
|
973
|
+
return U(t) && st(t);
|
|
974
|
+
}
|
|
975
|
+
var xt = Ie || Sr;
|
|
976
|
+
function lt(t) {
|
|
977
|
+
if (!E(t))
|
|
978
|
+
return !1;
|
|
979
|
+
var n = W(t);
|
|
980
|
+
return n == A || n == k || n == v || n == Kt;
|
|
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 Tr(t) {
|
|
993
|
+
if (!U(t) || W(t) != pt)
|
|
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) == we;
|
|
1000
|
+
}
|
|
1001
|
+
var Rt = yt ? be(yt) : Qe;
|
|
1002
|
+
function kr(t) {
|
|
1003
|
+
return sr(t, Pt(t));
|
|
1004
|
+
}
|
|
1005
|
+
function Pt(t) {
|
|
1006
|
+
return st(t) ? We(t, !0) : Ve(t);
|
|
1007
|
+
}
|
|
1008
|
+
var Ar = lr(function(t, n, i, c) {
|
|
1009
|
+
Ct(t, n, i, c);
|
|
1010
|
+
});
|
|
1011
|
+
function Ir(t) {
|
|
1012
|
+
return function() {
|
|
1013
|
+
return t;
|
|
1014
|
+
};
|
|
1015
|
+
}
|
|
1016
|
+
function Mt(t) {
|
|
1017
|
+
return t;
|
|
1018
|
+
}
|
|
1019
|
+
function Sr() {
|
|
1020
|
+
return !1;
|
|
1021
|
+
}
|
|
1022
|
+
o.exports = Ar;
|
|
1023
|
+
})(Q, Q.exports);
|
|
1024
|
+
var kn = Q.exports;
|
|
1025
|
+
const An = /* @__PURE__ */ Tn(kn);
|
|
1026
|
+
function In(o) {
|
|
1027
|
+
let e;
|
|
1028
|
+
function r(a, s) {
|
|
1029
|
+
var l, u, f, g, v, _, T;
|
|
1030
|
+
if ((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") {
|
|
1031
|
+
const w = (f = s == null ? void 0 : s.argument) == null ? void 0 : f.arguments;
|
|
1032
|
+
if (((g = w[1]) == null ? void 0 : g.type) === "ObjectExpression") {
|
|
1033
|
+
const A = Ht((v = w[1]) == null ? void 0 : v.properties);
|
|
1034
|
+
e = {
|
|
1035
|
+
...e,
|
|
1036
|
+
apiOptions: A
|
|
1037
|
+
};
|
|
1038
|
+
}
|
|
1039
|
+
if (((_ = w[2]) == null ? void 0 : _.type) === "ObjectExpression") {
|
|
1040
|
+
const A = Ht((T = w[2]) == null ? void 0 : T.properties);
|
|
1041
|
+
e = {
|
|
1042
|
+
...e,
|
|
1043
|
+
bridgeOptions: A
|
|
1044
|
+
};
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
return An({}, o, r), e;
|
|
1049
|
+
}
|
|
1050
|
+
function Ht(o) {
|
|
1051
|
+
return o.reduce((e, { key: r, value: a }) => {
|
|
1052
|
+
const { type: s } = a;
|
|
1053
|
+
return e[r.name] = s === "Literal" ? a.value : s === "ArrayExpression" ? a.elements.map((l) => l.value) : a.value, e;
|
|
1054
|
+
}, {});
|
|
1055
|
+
}
|
|
1056
|
+
let B = [];
|
|
1057
|
+
function Sn(o, e) {
|
|
1058
|
+
const r = "virtual:storyblok-bridge", a = "\0" + r;
|
|
1059
|
+
if (!o || e !== "server")
|
|
1060
|
+
return {
|
|
1061
|
+
name: "vite-plugin-storyblok-bridge",
|
|
1062
|
+
resolveId(f) {
|
|
1063
|
+
if (f === r)
|
|
1064
|
+
return a;
|
|
1065
|
+
},
|
|
1066
|
+
load(f) {
|
|
1067
|
+
if (f === a)
|
|
1068
|
+
return "export const bridgeOptions = null";
|
|
1069
|
+
}
|
|
1070
|
+
};
|
|
1071
|
+
let s = [], l = null, u = null;
|
|
1072
|
+
return {
|
|
1073
|
+
name: "vite-plugin-storyblok-bridge",
|
|
1074
|
+
async resolveId(f) {
|
|
1075
|
+
if (f === r)
|
|
1076
|
+
return a;
|
|
1077
|
+
},
|
|
1078
|
+
async transform(f, g) {
|
|
1079
|
+
var A;
|
|
1080
|
+
if (g.includes("node_modules") && !g.includes("/pages/") || !f.includes("useStoryblok") || !((A = this.getModuleInfo(g).meta) != null && A.astro))
|
|
1081
|
+
return;
|
|
1082
|
+
const [, ..._] = g.split("src/pages/"), T = _.join("/").replace(".astro", ""), w = In(this.parse(f));
|
|
1083
|
+
B.length && (s = B.filter((k) => k.url !== T)), s.push({
|
|
1084
|
+
url: T,
|
|
1085
|
+
options: w
|
|
1086
|
+
}), l && (u && clearTimeout(u), u = setTimeout(() => {
|
|
1087
|
+
On(B, s) || (B.length !== 0 && (l.restart(), console.info("Updating bridge options...")), B = [...s]);
|
|
1088
|
+
}, 1e3));
|
|
1089
|
+
},
|
|
1090
|
+
async load(f) {
|
|
1091
|
+
if (f === a)
|
|
1092
|
+
return `export const bridgeOptions = ${JSON.stringify(wn(s))}`;
|
|
1093
|
+
},
|
|
1094
|
+
configureServer(f) {
|
|
1095
|
+
l = f;
|
|
1096
|
+
}
|
|
1097
|
+
};
|
|
1098
|
+
}
|
|
1099
|
+
function On(o = [], e = []) {
|
|
1100
|
+
return e.every(({ url: r, options: a }) => {
|
|
1101
|
+
const s = o.find((l) => (l == null ? void 0 : l.url) === r);
|
|
1102
|
+
return s && JSON.stringify(a) === JSON.stringify(s.options);
|
|
1103
|
+
});
|
|
1104
|
+
}
|
|
1105
|
+
let qt;
|
|
1106
|
+
async function En(o) {
|
|
1107
|
+
const { action: e, story: r } = o || {};
|
|
1108
|
+
if (e === "input" && r) {
|
|
1109
|
+
const a = async () => {
|
|
1110
|
+
const l = await jn(r), u = document.body;
|
|
1111
|
+
if (l.outerHTML === u.outerHTML)
|
|
1112
|
+
return;
|
|
1113
|
+
const f = document.querySelector('[data-blok-focused="true"]');
|
|
1114
|
+
Cn(u, l, f);
|
|
1115
|
+
};
|
|
1116
|
+
clearTimeout(qt), qt = setTimeout(a, 500);
|
|
1117
|
+
}
|
|
1118
|
+
["published", "change"].includes(o == null ? void 0 : o.action) && location.reload();
|
|
1119
|
+
}
|
|
1120
|
+
function Cn(o, e, r) {
|
|
1121
|
+
if (r) {
|
|
1122
|
+
const a = r.getAttribute("data-blok-uid"), s = e.querySelector(
|
|
1123
|
+
`[data-blok-uid="${a}"]`
|
|
1124
|
+
);
|
|
1125
|
+
s && (s.setAttribute("data-blok-focused", "true"), r.replaceWith(s));
|
|
1126
|
+
} else
|
|
1127
|
+
o.replaceWith(e);
|
|
1128
|
+
}
|
|
1129
|
+
async function jn(o) {
|
|
1130
|
+
const r = await (await fetch(location.href, {
|
|
1131
|
+
method: "POST",
|
|
1132
|
+
body: JSON.stringify({
|
|
1133
|
+
...o,
|
|
1134
|
+
is_storyblok_preview: !0
|
|
1135
|
+
}),
|
|
1136
|
+
headers: {
|
|
1137
|
+
"Content-Type": "application/json"
|
|
1138
|
+
}
|
|
1139
|
+
})).text();
|
|
1140
|
+
return new DOMParser().parseFromString(r, "text/html").body;
|
|
1141
|
+
}
|
|
1142
|
+
function Rn() {
|
|
527
1143
|
return globalThis.storyblokApiInstance || console.error("storyblokApiInstance has not been initialized correctly"), globalThis.storyblokApiInstance;
|
|
528
1144
|
}
|
|
529
|
-
function
|
|
530
|
-
|
|
531
|
-
|
|
1145
|
+
async function Pn(o, e = {}, r = {}, a) {
|
|
1146
|
+
globalThis.storyblokApiInstance || console.error("storyblokApiInstance has not been initialized correctly");
|
|
1147
|
+
let s = null;
|
|
1148
|
+
if (a && a.locals._storyblok_preview_data)
|
|
1149
|
+
s = a.locals._storyblok_preview_data;
|
|
1150
|
+
else {
|
|
1151
|
+
const { data: l } = await globalThis.storyblokApiInstance.get(
|
|
1152
|
+
o,
|
|
1153
|
+
e,
|
|
1154
|
+
r
|
|
1155
|
+
);
|
|
1156
|
+
s = l.story;
|
|
1157
|
+
}
|
|
1158
|
+
return s;
|
|
1159
|
+
}
|
|
1160
|
+
function Mn(o, e) {
|
|
1161
|
+
const r = globalThis.storyblokApiInstance.richTextResolver;
|
|
1162
|
+
if (!r) {
|
|
532
1163
|
console.error(
|
|
533
1164
|
"Please initialize the Storyblok SDK before calling the renderRichText function"
|
|
534
1165
|
);
|
|
535
1166
|
return;
|
|
536
1167
|
}
|
|
537
|
-
return
|
|
1168
|
+
return _n(o, e, r);
|
|
538
1169
|
}
|
|
539
|
-
function
|
|
540
|
-
const
|
|
1170
|
+
function Nn(o) {
|
|
1171
|
+
const e = {
|
|
541
1172
|
useCustomApi: !1,
|
|
542
1173
|
bridge: !0,
|
|
543
1174
|
componentsDir: "src",
|
|
544
1175
|
enableFallbackComponent: !1,
|
|
545
|
-
|
|
1176
|
+
livePreview: !1,
|
|
1177
|
+
...o
|
|
546
1178
|
};
|
|
547
1179
|
return {
|
|
548
1180
|
name: "@storyblok/astro",
|
|
549
1181
|
hooks: {
|
|
550
1182
|
"astro:config:setup": ({
|
|
551
|
-
injectScript:
|
|
552
|
-
updateConfig:
|
|
553
|
-
addDevToolbarApp: s
|
|
1183
|
+
injectScript: r,
|
|
1184
|
+
updateConfig: a,
|
|
1185
|
+
addDevToolbarApp: s,
|
|
1186
|
+
addMiddleware: l,
|
|
1187
|
+
config: u
|
|
554
1188
|
}) => {
|
|
555
|
-
if (
|
|
1189
|
+
if (a({
|
|
556
1190
|
vite: {
|
|
557
1191
|
plugins: [
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
1192
|
+
Or(
|
|
1193
|
+
e.accessToken,
|
|
1194
|
+
e.useCustomApi,
|
|
1195
|
+
e.apiOptions
|
|
562
1196
|
),
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
1197
|
+
Pr(
|
|
1198
|
+
e.componentsDir,
|
|
1199
|
+
e.components,
|
|
1200
|
+
e.enableFallbackComponent,
|
|
1201
|
+
e.customFallbackComponent
|
|
568
1202
|
),
|
|
569
|
-
|
|
1203
|
+
Mr(e),
|
|
1204
|
+
Sn(
|
|
1205
|
+
e.livePreview,
|
|
1206
|
+
u.output
|
|
1207
|
+
)
|
|
570
1208
|
]
|
|
571
1209
|
}
|
|
572
|
-
}), e(
|
|
1210
|
+
}), e.livePreview && (u == null ? void 0 : u.output) !== "server")
|
|
1211
|
+
throw new Error(
|
|
1212
|
+
"To utilize the Astro Storyblok Live feature, Astro must be configured in SSR mode. Please disable this feature or switch Astro to SSR mode."
|
|
1213
|
+
);
|
|
1214
|
+
if (r(
|
|
573
1215
|
"page-ssr",
|
|
574
1216
|
`
|
|
575
1217
|
import { storyblokApiInstance } from "virtual:storyblok-init";
|
|
576
1218
|
globalThis.storyblokApiInstance = storyblokApiInstance;
|
|
577
1219
|
`
|
|
578
|
-
),
|
|
579
|
-
let
|
|
580
|
-
if (typeof
|
|
581
|
-
const
|
|
582
|
-
|
|
583
|
-
|
|
1220
|
+
), e.bridge && !e.livePreview) {
|
|
1221
|
+
let f = "";
|
|
1222
|
+
if (typeof e.bridge == "object") {
|
|
1223
|
+
const g = { ...e.bridge };
|
|
1224
|
+
f = `const storyblokInstance = new StoryblokBridge(${JSON.stringify(
|
|
1225
|
+
g
|
|
584
1226
|
)});`;
|
|
585
1227
|
} else
|
|
586
|
-
|
|
587
|
-
|
|
1228
|
+
f = "const storyblokInstance = new StoryblokBridge()";
|
|
1229
|
+
r(
|
|
588
1230
|
"page",
|
|
589
1231
|
`
|
|
590
1232
|
import { loadStoryblokBridge } from "@storyblok/astro";
|
|
591
1233
|
loadStoryblokBridge().then(() => {
|
|
592
1234
|
const { StoryblokBridge, location } = window;
|
|
593
|
-
${
|
|
1235
|
+
${f}
|
|
594
1236
|
|
|
595
1237
|
storyblokInstance.on(["published", "change"], (event) => {
|
|
596
1238
|
if (!event.slugChanged) {
|
|
@@ -601,17 +1243,36 @@ function we(r) {
|
|
|
601
1243
|
`
|
|
602
1244
|
);
|
|
603
1245
|
}
|
|
604
|
-
|
|
1246
|
+
e.livePreview && (r(
|
|
1247
|
+
"page",
|
|
1248
|
+
`
|
|
1249
|
+
import { loadStoryblokBridge, handleStoryblokMessage } from "@storyblok/astro";
|
|
1250
|
+
import { bridgeOptions } from "virtual:storyblok-bridge";
|
|
1251
|
+
console.info("The Storyblok Astro live preview feature is currently in an experimental phase, and its API is subject to change in the future.")
|
|
1252
|
+
loadStoryblokBridge().then(() => {
|
|
1253
|
+
const { StoryblokBridge, location } = window;
|
|
1254
|
+
if(bridgeOptions){
|
|
1255
|
+
const storyblokInstance = new StoryblokBridge(bridgeOptions);
|
|
1256
|
+
storyblokInstance.on(["published", "change", "input"], handleStoryblokMessage);
|
|
1257
|
+
};
|
|
1258
|
+
});
|
|
1259
|
+
`
|
|
1260
|
+
), l({
|
|
1261
|
+
entrypoint: "@storyblok/astro/middleware.ts",
|
|
1262
|
+
order: "pre"
|
|
1263
|
+
})), s("@storyblok/astro/toolbarApp.ts");
|
|
605
1264
|
}
|
|
606
1265
|
}
|
|
607
1266
|
};
|
|
608
1267
|
}
|
|
609
1268
|
export {
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
1269
|
+
hn as RichTextResolver,
|
|
1270
|
+
dn as RichTextSchema,
|
|
1271
|
+
Nn as default,
|
|
1272
|
+
En as handleStoryblokMessage,
|
|
1273
|
+
xn as loadStoryblokBridge,
|
|
1274
|
+
Mn as renderRichText,
|
|
1275
|
+
$n as storyblokEditable,
|
|
1276
|
+
Pn as useStoryblok,
|
|
1277
|
+
Rn as useStoryblokApi
|
|
617
1278
|
};
|