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