@storyblok/astro 5.0.2 → 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 +367 -974
- 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 +1 -1
- 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 (
|
|
7
|
-
return
|
|
5
|
+
async resolveId(a) {
|
|
6
|
+
if (a === o)
|
|
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
|
|
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
|
|
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
|
|
113
|
-
if (typeof window > "u" || (window.storyblokRegisterEvent = (
|
|
111
|
+
let I = !1;
|
|
112
|
+
const S = [], _ = (r) => new Promise((t, e) => {
|
|
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,226 +150,226 @@ class Dr {
|
|
|
150
150
|
* @param {Boolean} isArray
|
|
151
151
|
* @return {String} Stringified object
|
|
152
152
|
*/
|
|
153
|
-
stringify(
|
|
154
|
-
const
|
|
155
|
-
for (const
|
|
156
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
153
|
+
stringify(t, e, o) {
|
|
154
|
+
const s = [];
|
|
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
|
-
return
|
|
166
|
+
return s.join("&");
|
|
167
167
|
}
|
|
168
168
|
/**
|
|
169
169
|
* @method getRegionURL
|
|
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
|
-
return
|
|
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
|
|
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
|
|
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
|
-
let
|
|
355
|
-
class
|
|
356
|
-
constructor(
|
|
357
|
-
|
|
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
358
|
}
|
|
359
|
-
addNode(
|
|
360
|
-
this.nodes[
|
|
359
|
+
addNode(t, e) {
|
|
360
|
+
this.nodes[t] = e;
|
|
361
361
|
}
|
|
362
|
-
addMark(
|
|
363
|
-
this.marks[
|
|
362
|
+
addMark(t, e) {
|
|
363
|
+
this.marks[t] = e;
|
|
364
364
|
}
|
|
365
|
-
render(
|
|
366
|
-
if (!
|
|
365
|
+
render(t, e = { optimizeImages: !1 }, o = !0) {
|
|
366
|
+
if (!T && o && (console.warn(
|
|
367
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
|
-
),
|
|
369
|
-
let
|
|
370
|
-
return
|
|
371
|
-
|
|
372
|
-
}),
|
|
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;
|
|
373
373
|
}
|
|
374
374
|
return console.warn(
|
|
375
375
|
`The render method must receive an Object with a "content" field.
|
|
@@ -398,853 +398,251 @@ class hn {
|
|
|
398
398
|
}`
|
|
399
399
|
), "";
|
|
400
400
|
}
|
|
401
|
-
optimizeImages(
|
|
402
|
-
let
|
|
403
|
-
typeof
|
|
404
|
-
const
|
|
405
|
-
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(
|
|
406
406
|
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,
|
|
407
|
-
`a.storyblok.com/f/$1/$2.$3/m/${
|
|
408
|
-
), typeof
|
|
409
|
-
var
|
|
410
|
-
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(
|
|
411
411
|
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g
|
|
412
412
|
);
|
|
413
|
-
if (
|
|
414
|
-
const
|
|
415
|
-
srcset: (
|
|
416
|
-
if (typeof
|
|
417
|
-
return `//${
|
|
418
|
-
if (typeof
|
|
419
|
-
let
|
|
420
|
-
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`;
|
|
421
421
|
}
|
|
422
422
|
}).join(", "),
|
|
423
|
-
sizes: (
|
|
423
|
+
sizes: (u = e.sizes) == null ? void 0 : u.map((p) => p).join(", ")
|
|
424
424
|
};
|
|
425
|
-
let
|
|
426
|
-
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()}`);
|
|
427
427
|
}
|
|
428
|
-
return
|
|
429
|
-
})),
|
|
430
|
-
}
|
|
431
|
-
renderNode(
|
|
432
|
-
const
|
|
433
|
-
|
|
434
|
-
const
|
|
435
|
-
|
|
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));
|
|
436
436
|
});
|
|
437
|
-
const
|
|
438
|
-
return
|
|
439
|
-
|
|
440
|
-
}) :
|
|
441
|
-
const
|
|
442
|
-
|
|
443
|
-
}),
|
|
444
|
-
}
|
|
445
|
-
renderTag(
|
|
446
|
-
return
|
|
447
|
-
if (
|
|
448
|
-
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}>`;
|
|
449
449
|
{
|
|
450
|
-
let
|
|
451
|
-
if (
|
|
452
|
-
for (const
|
|
453
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
454
|
-
const
|
|
455
|
-
|
|
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}"`);
|
|
456
456
|
}
|
|
457
457
|
}
|
|
458
|
-
return `${
|
|
458
|
+
return `${s}${e}>`;
|
|
459
459
|
}
|
|
460
460
|
}).join("");
|
|
461
461
|
}
|
|
462
|
-
renderOpeningTag(
|
|
463
|
-
return this.renderTag(
|
|
462
|
+
renderOpeningTag(t) {
|
|
463
|
+
return this.renderTag(t, "");
|
|
464
464
|
}
|
|
465
|
-
renderClosingTag(
|
|
466
|
-
return
|
|
465
|
+
renderClosingTag(t) {
|
|
466
|
+
return t.constructor === String ? `</${t}>` : t.slice(0).reverse().map((e) => e.constructor === String ? `</${e}>` : `</${e.tag}>`).join("");
|
|
467
467
|
}
|
|
468
|
-
getMatchingNode(
|
|
469
|
-
const
|
|
470
|
-
if (typeof
|
|
471
|
-
return t
|
|
468
|
+
getMatchingNode(t) {
|
|
469
|
+
const e = this.nodes[t.type];
|
|
470
|
+
if (typeof e == "function")
|
|
471
|
+
return e(t);
|
|
472
472
|
}
|
|
473
|
-
getMatchingMark(
|
|
474
|
-
const
|
|
475
|
-
if (typeof
|
|
476
|
-
return t
|
|
473
|
+
getMatchingMark(t) {
|
|
474
|
+
const e = this.marks[t.type];
|
|
475
|
+
if (typeof e == "function")
|
|
476
|
+
return e(t);
|
|
477
477
|
}
|
|
478
|
-
renderEmoji(
|
|
479
|
-
if (
|
|
480
|
-
return
|
|
481
|
-
const
|
|
478
|
+
renderEmoji(t) {
|
|
479
|
+
if (t.attrs.emoji)
|
|
480
|
+
return t.attrs.emoji;
|
|
481
|
+
const e = [
|
|
482
482
|
{
|
|
483
483
|
tag: "img",
|
|
484
484
|
attrs: {
|
|
485
|
-
src:
|
|
485
|
+
src: t.attrs.fallbackImage,
|
|
486
486
|
draggable: "false",
|
|
487
487
|
loading: "lazy",
|
|
488
488
|
align: "absmiddle"
|
|
489
489
|
}
|
|
490
490
|
}
|
|
491
491
|
];
|
|
492
|
-
return this.renderTag(
|
|
492
|
+
return this.renderTag(e, " /");
|
|
493
493
|
}
|
|
494
494
|
}
|
|
495
|
-
const
|
|
496
|
-
if (typeof
|
|
495
|
+
const ye = he, Te = (r) => {
|
|
496
|
+
if (typeof r != "object" || typeof r._editable > "u")
|
|
497
497
|
return {};
|
|
498
498
|
try {
|
|
499
|
-
const
|
|
500
|
-
|
|
499
|
+
const t = JSON.parse(
|
|
500
|
+
r._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
|
|
501
501
|
);
|
|
502
|
-
return
|
|
503
|
-
"data-blok-c": JSON.stringify(
|
|
504
|
-
"data-blok-uid":
|
|
502
|
+
return t ? {
|
|
503
|
+
"data-blok-c": JSON.stringify(t),
|
|
504
|
+
"data-blok-uid": t.id + "-" + t.uid
|
|
505
505
|
} : {};
|
|
506
506
|
} catch {
|
|
507
507
|
return {};
|
|
508
508
|
}
|
|
509
509
|
};
|
|
510
|
-
let
|
|
511
|
-
const
|
|
512
|
-
|
|
513
|
-
let
|
|
514
|
-
return
|
|
515
|
-
|
|
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);
|
|
516
516
|
}), {
|
|
517
|
-
html:
|
|
517
|
+
html: o
|
|
518
518
|
};
|
|
519
519
|
});
|
|
520
|
-
},
|
|
521
|
-
let
|
|
522
|
-
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) {
|
|
523
523
|
console.error(
|
|
524
524
|
"Please initialize the Storyblok SDK before calling the renderRichText function"
|
|
525
525
|
);
|
|
526
526
|
return;
|
|
527
527
|
}
|
|
528
|
-
return
|
|
529
|
-
},
|
|
530
|
-
function
|
|
531
|
-
|
|
532
|
-
resolveRelations: []
|
|
533
|
-
};
|
|
534
|
-
function t(s) {
|
|
535
|
-
s && Array.isArray(r.resolveRelations) && r.resolveRelations.push(
|
|
536
|
-
...Array.isArray(s) ? s : [s]
|
|
537
|
-
);
|
|
538
|
-
}
|
|
539
|
-
for (const s of o)
|
|
540
|
-
if (s.options) {
|
|
541
|
-
const { apiOptions: i, bridgeOptions: l } = s.options;
|
|
542
|
-
if (t(i == null ? void 0 : i.resolve_relations), l) {
|
|
543
|
-
const { resolveRelations: u, ...f } = l;
|
|
544
|
-
t(u), Object.assign(r, f);
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
return r.resolveRelations = [...new Set(r.resolveRelations)], r;
|
|
548
|
-
}
|
|
549
|
-
var Z = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
550
|
-
function kn(o) {
|
|
551
|
-
return o && o.__esModule && Object.prototype.hasOwnProperty.call(o, "default") ? o.default : o;
|
|
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();";
|
|
552
532
|
}
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
} catch {
|
|
563
|
-
}
|
|
564
|
-
}(), ye = be && be.isTypedArray;
|
|
565
|
-
function gt(e, n, a) {
|
|
566
|
-
switch (a.length) {
|
|
567
|
-
case 0:
|
|
568
|
-
return e.call(n);
|
|
569
|
-
case 1:
|
|
570
|
-
return e.call(n, a[0]);
|
|
571
|
-
case 2:
|
|
572
|
-
return e.call(n, a[0], a[1]);
|
|
573
|
-
case 3:
|
|
574
|
-
return e.call(n, a[0], a[1], a[2]);
|
|
575
|
-
}
|
|
576
|
-
return e.apply(n, a);
|
|
577
|
-
}
|
|
578
|
-
function ht(e, n) {
|
|
579
|
-
for (var a = -1, c = Array(e); ++a < e; )
|
|
580
|
-
c[a] = n(a);
|
|
581
|
-
return c;
|
|
582
|
-
}
|
|
583
|
-
function bt(e) {
|
|
584
|
-
return function(n) {
|
|
585
|
-
return e(n);
|
|
586
|
-
};
|
|
587
|
-
}
|
|
588
|
-
function yt(e, n) {
|
|
589
|
-
return e == null ? void 0 : e[n];
|
|
590
|
-
}
|
|
591
|
-
function mt(e, n) {
|
|
592
|
-
return function(a) {
|
|
593
|
-
return e(n(a));
|
|
594
|
-
};
|
|
595
|
-
}
|
|
596
|
-
var vt = Array.prototype, _t = Function.prototype, H = Object.prototype, ee = N["__core-js_shared__"], q = _t.toString, j = H.hasOwnProperty, me = function() {
|
|
597
|
-
var e = /[^.]+$/.exec(ee && ee.keys && ee.keys.IE_PROTO || "");
|
|
598
|
-
return e ? "Symbol(src)_1." + e : "";
|
|
599
|
-
}(), ve = H.toString, wt = q.call(Object), Tt = RegExp(
|
|
600
|
-
"^" + q.call(j).replace(ut, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
|
|
601
|
-
), G = he ? N.Buffer : void 0, _e = N.Symbol, we = N.Uint8Array;
|
|
602
|
-
G && G.allocUnsafe;
|
|
603
|
-
var Te = mt(Object.getPrototypeOf, Object), ke = Object.create, kt = H.propertyIsEnumerable, At = vt.splice, x = _e ? _e.toStringTag : void 0, J = function() {
|
|
604
|
-
try {
|
|
605
|
-
var e = ne(Object, "defineProperty");
|
|
606
|
-
return e({}, "", {}), e;
|
|
607
|
-
} catch {
|
|
608
|
-
}
|
|
609
|
-
}(), It = G ? G.isBuffer : void 0, Ae = Math.max, St = Date.now, Ie = ne(N, "Map"), L = ne(Object, "create"), Ot = /* @__PURE__ */ function() {
|
|
610
|
-
function e() {
|
|
611
|
-
}
|
|
612
|
-
return function(n) {
|
|
613
|
-
if (!E(n))
|
|
614
|
-
return {};
|
|
615
|
-
if (ke)
|
|
616
|
-
return ke(n);
|
|
617
|
-
e.prototype = n;
|
|
618
|
-
var a = new e();
|
|
619
|
-
return e.prototype = void 0, a;
|
|
620
|
-
};
|
|
621
|
-
}();
|
|
622
|
-
function $(e) {
|
|
623
|
-
var n = -1, a = e == null ? 0 : e.length;
|
|
624
|
-
for (this.clear(); ++n < a; ) {
|
|
625
|
-
var c = e[n];
|
|
626
|
-
this.set(c[0], c[1]);
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
function Ct() {
|
|
630
|
-
this.__data__ = L ? L(null) : {}, this.size = 0;
|
|
631
|
-
}
|
|
632
|
-
function jt(e) {
|
|
633
|
-
var n = this.has(e) && delete this.__data__[e];
|
|
634
|
-
return this.size -= n ? 1 : 0, n;
|
|
635
|
-
}
|
|
636
|
-
function xt(e) {
|
|
637
|
-
var n = this.__data__;
|
|
638
|
-
if (L) {
|
|
639
|
-
var a = n[e];
|
|
640
|
-
return a === s ? void 0 : a;
|
|
641
|
-
}
|
|
642
|
-
return j.call(n, e) ? n[e] : void 0;
|
|
643
|
-
}
|
|
644
|
-
function $t(e) {
|
|
645
|
-
var n = this.__data__;
|
|
646
|
-
return L ? n[e] !== void 0 : j.call(n, e);
|
|
647
|
-
}
|
|
648
|
-
function Et(e, n) {
|
|
649
|
-
var a = this.__data__;
|
|
650
|
-
return this.size += this.has(e) ? 0 : 1, a[e] = L && n === void 0 ? s : n, this;
|
|
651
|
-
}
|
|
652
|
-
$.prototype.clear = Ct, $.prototype.delete = jt, $.prototype.get = xt, $.prototype.has = $t, $.prototype.set = Et;
|
|
653
|
-
function C(e) {
|
|
654
|
-
var n = -1, a = e == null ? 0 : e.length;
|
|
655
|
-
for (this.clear(); ++n < a; ) {
|
|
656
|
-
var c = e[n];
|
|
657
|
-
this.set(c[0], c[1]);
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
function Rt() {
|
|
661
|
-
this.__data__ = [], this.size = 0;
|
|
662
|
-
}
|
|
663
|
-
function Pt(e) {
|
|
664
|
-
var n = this.__data__, a = K(n, e);
|
|
665
|
-
if (a < 0)
|
|
666
|
-
return !1;
|
|
667
|
-
var c = n.length - 1;
|
|
668
|
-
return a == c ? n.pop() : At.call(n, a, 1), --this.size, !0;
|
|
669
|
-
}
|
|
670
|
-
function Mt(e) {
|
|
671
|
-
var n = this.__data__, a = K(n, e);
|
|
672
|
-
return a < 0 ? void 0 : n[a][1];
|
|
673
|
-
}
|
|
674
|
-
function Nt(e) {
|
|
675
|
-
return K(this.__data__, e) > -1;
|
|
676
|
-
}
|
|
677
|
-
function zt(e, n) {
|
|
678
|
-
var a = this.__data__, c = K(a, e);
|
|
679
|
-
return c < 0 ? (++this.size, a.push([e, n])) : a[c][1] = n, this;
|
|
680
|
-
}
|
|
681
|
-
C.prototype.clear = Rt, C.prototype.delete = Pt, C.prototype.get = Mt, C.prototype.has = Nt, C.prototype.set = zt;
|
|
682
|
-
function R(e) {
|
|
683
|
-
var n = -1, a = e == null ? 0 : e.length;
|
|
684
|
-
for (this.clear(); ++n < a; ) {
|
|
685
|
-
var c = e[n];
|
|
686
|
-
this.set(c[0], c[1]);
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
function Lt() {
|
|
690
|
-
this.size = 0, this.__data__ = {
|
|
691
|
-
hash: new $(),
|
|
692
|
-
map: new (Ie || C)(),
|
|
693
|
-
string: new $()
|
|
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"));
|
|
694
542
|
};
|
|
543
|
+
clearTimeout(A), A = setTimeout(o, 500);
|
|
695
544
|
}
|
|
696
|
-
|
|
697
|
-
var n = X(this, e).delete(e);
|
|
698
|
-
return this.size -= n ? 1 : 0, n;
|
|
699
|
-
}
|
|
700
|
-
function Ut(e) {
|
|
701
|
-
return X(this, e).get(e);
|
|
702
|
-
}
|
|
703
|
-
function Bt(e) {
|
|
704
|
-
return X(this, e).has(e);
|
|
705
|
-
}
|
|
706
|
-
function Ft(e, n) {
|
|
707
|
-
var a = X(this, e), c = a.size;
|
|
708
|
-
return a.set(e, n), this.size += a.size == c ? 0 : 1, this;
|
|
709
|
-
}
|
|
710
|
-
R.prototype.clear = Lt, R.prototype.delete = Dt, R.prototype.get = Ut, R.prototype.has = Bt, R.prototype.set = Ft;
|
|
711
|
-
function P(e) {
|
|
712
|
-
var n = this.__data__ = new C(e);
|
|
713
|
-
this.size = n.size;
|
|
714
|
-
}
|
|
715
|
-
function Ht() {
|
|
716
|
-
this.__data__ = new C(), this.size = 0;
|
|
717
|
-
}
|
|
718
|
-
function qt(e) {
|
|
719
|
-
var n = this.__data__, a = n.delete(e);
|
|
720
|
-
return this.size = n.size, a;
|
|
721
|
-
}
|
|
722
|
-
function Gt(e) {
|
|
723
|
-
return this.__data__.get(e);
|
|
724
|
-
}
|
|
725
|
-
function Jt(e) {
|
|
726
|
-
return this.__data__.has(e);
|
|
727
|
-
}
|
|
728
|
-
function Kt(e, n) {
|
|
729
|
-
var a = this.__data__;
|
|
730
|
-
if (a instanceof C) {
|
|
731
|
-
var c = a.__data__;
|
|
732
|
-
if (!Ie || c.length < t - 1)
|
|
733
|
-
return c.push([e, n]), this.size = ++a.size, this;
|
|
734
|
-
a = this.__data__ = new R(c);
|
|
735
|
-
}
|
|
736
|
-
return a.set(e, n), this.size = a.size, this;
|
|
737
|
-
}
|
|
738
|
-
P.prototype.clear = Ht, P.prototype.delete = qt, P.prototype.get = Gt, P.prototype.has = Jt, P.prototype.set = Kt;
|
|
739
|
-
function Wt(e, n) {
|
|
740
|
-
var a = se(e), c = !a && ae(e), d = !a && !c && xe(e), h = !a && !c && !d && Ee(e), m = a || c || d || h, g = m ? ht(e.length, String) : [], v = g.length;
|
|
741
|
-
for (var I in e)
|
|
742
|
-
m && // Safari 9 has enumerable `arguments.length` in strict mode.
|
|
743
|
-
(I == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
|
|
744
|
-
d && (I == "offset" || I == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
|
|
745
|
-
h && (I == "buffer" || I == "byteLength" || I == "byteOffset") || // Skip index properties.
|
|
746
|
-
Ce(I, v)) || g.push(I);
|
|
747
|
-
return g;
|
|
748
|
-
}
|
|
749
|
-
function te(e, n, a) {
|
|
750
|
-
(a !== void 0 && !Y(e[n], a) || a === void 0 && !(n in e)) && re(e, n, a);
|
|
751
|
-
}
|
|
752
|
-
function Xt(e, n, a) {
|
|
753
|
-
var c = e[n];
|
|
754
|
-
(!(j.call(e, n) && Y(c, a)) || a === void 0 && !(n in e)) && re(e, n, a);
|
|
755
|
-
}
|
|
756
|
-
function K(e, n) {
|
|
757
|
-
for (var a = e.length; a--; )
|
|
758
|
-
if (Y(e[a][0], n))
|
|
759
|
-
return a;
|
|
760
|
-
return -1;
|
|
761
|
-
}
|
|
762
|
-
function re(e, n, a) {
|
|
763
|
-
n == "__proto__" && J ? J(e, n, {
|
|
764
|
-
configurable: !0,
|
|
765
|
-
enumerable: !0,
|
|
766
|
-
value: a,
|
|
767
|
-
writable: !0
|
|
768
|
-
}) : e[n] = a;
|
|
769
|
-
}
|
|
770
|
-
var Yt = cr();
|
|
771
|
-
function W(e) {
|
|
772
|
-
return e == null ? e === void 0 ? Ze : Je : x && x in Object(e) ? ur(e) : br(e);
|
|
773
|
-
}
|
|
774
|
-
function Se(e) {
|
|
775
|
-
return D(e) && W(e) == f;
|
|
776
|
-
}
|
|
777
|
-
function Zt(e) {
|
|
778
|
-
if (!E(e) || gr(e))
|
|
779
|
-
return !1;
|
|
780
|
-
var n = le(e) ? Tt : ft;
|
|
781
|
-
return n.test(_r(e));
|
|
782
|
-
}
|
|
783
|
-
function Qt(e) {
|
|
784
|
-
return D(e) && $e(e.length) && !!b[W(e)];
|
|
785
|
-
}
|
|
786
|
-
function Vt(e) {
|
|
787
|
-
if (!E(e))
|
|
788
|
-
return hr(e);
|
|
789
|
-
var n = je(e), a = [];
|
|
790
|
-
for (var c in e)
|
|
791
|
-
c == "constructor" && (n || !j.call(e, c)) || a.push(c);
|
|
792
|
-
return a;
|
|
793
|
-
}
|
|
794
|
-
function Oe(e, n, a, c, d) {
|
|
795
|
-
e !== n && Yt(n, function(h, m) {
|
|
796
|
-
if (d || (d = new P()), E(h))
|
|
797
|
-
er(e, n, m, a, Oe, c, d);
|
|
798
|
-
else {
|
|
799
|
-
var g = c ? c(oe(e, m), h, m + "", e, n, d) : void 0;
|
|
800
|
-
g === void 0 && (g = h), te(e, m, g);
|
|
801
|
-
}
|
|
802
|
-
}, Re);
|
|
803
|
-
}
|
|
804
|
-
function er(e, n, a, c, d, h, m) {
|
|
805
|
-
var g = oe(e, a), v = oe(n, a), I = m.get(v);
|
|
806
|
-
if (I) {
|
|
807
|
-
te(e, a, I);
|
|
808
|
-
return;
|
|
809
|
-
}
|
|
810
|
-
var T = h ? h(g, v, a + "", e, n, m) : void 0, U = T === void 0;
|
|
811
|
-
if (U) {
|
|
812
|
-
var ce = se(v), ue = !ce && xe(v), Me = !ce && !ue && Ee(v);
|
|
813
|
-
T = v, ce || ue || Me ? se(g) ? T = g : wr(g) ? T = sr(g) : ue ? (U = !1, T = nr(v)) : Me ? (U = !1, T = ar(v)) : T = [] : Tr(v) || ae(v) ? (T = g, ae(g) ? T = kr(g) : (!E(g) || le(g)) && (T = fr(v))) : U = !1;
|
|
814
|
-
}
|
|
815
|
-
U && (m.set(v, T), d(T, v, c, h, m), m.delete(v)), te(e, a, T);
|
|
816
|
-
}
|
|
817
|
-
function tr(e, n) {
|
|
818
|
-
return mr(yr(e, n, Pe), e + "");
|
|
819
|
-
}
|
|
820
|
-
var rr = J ? function(e, n) {
|
|
821
|
-
return J(e, "toString", {
|
|
822
|
-
configurable: !0,
|
|
823
|
-
enumerable: !1,
|
|
824
|
-
value: Ir(n),
|
|
825
|
-
writable: !0
|
|
826
|
-
});
|
|
827
|
-
} : Pe;
|
|
828
|
-
function nr(e, n) {
|
|
829
|
-
return e.slice();
|
|
830
|
-
}
|
|
831
|
-
function or(e) {
|
|
832
|
-
var n = new e.constructor(e.byteLength);
|
|
833
|
-
return new we(n).set(new we(e)), n;
|
|
834
|
-
}
|
|
835
|
-
function ar(e, n) {
|
|
836
|
-
var a = or(e.buffer);
|
|
837
|
-
return new e.constructor(a, e.byteOffset, e.length);
|
|
838
|
-
}
|
|
839
|
-
function sr(e, n) {
|
|
840
|
-
var a = -1, c = e.length;
|
|
841
|
-
for (n || (n = Array(c)); ++a < c; )
|
|
842
|
-
n[a] = e[a];
|
|
843
|
-
return n;
|
|
844
|
-
}
|
|
845
|
-
function ir(e, n, a, c) {
|
|
846
|
-
var d = !a;
|
|
847
|
-
a || (a = {});
|
|
848
|
-
for (var h = -1, m = n.length; ++h < m; ) {
|
|
849
|
-
var g = n[h], v = void 0;
|
|
850
|
-
v === void 0 && (v = e[g]), d ? re(a, g, v) : Xt(a, g, v);
|
|
851
|
-
}
|
|
852
|
-
return a;
|
|
853
|
-
}
|
|
854
|
-
function lr(e) {
|
|
855
|
-
return tr(function(n, a) {
|
|
856
|
-
var c = -1, d = a.length, h = d > 1 ? a[d - 1] : void 0, m = d > 2 ? a[2] : void 0;
|
|
857
|
-
for (h = e.length > 3 && typeof h == "function" ? (d--, h) : void 0, m && dr(a[0], a[1], m) && (h = d < 3 ? void 0 : h, d = 1), n = Object(n); ++c < d; ) {
|
|
858
|
-
var g = a[c];
|
|
859
|
-
g && e(n, g, c, h);
|
|
860
|
-
}
|
|
861
|
-
return n;
|
|
862
|
-
});
|
|
863
|
-
}
|
|
864
|
-
function cr(e) {
|
|
865
|
-
return function(n, a, c) {
|
|
866
|
-
for (var d = -1, h = Object(n), m = c(n), g = m.length; g--; ) {
|
|
867
|
-
var v = m[++d];
|
|
868
|
-
if (a(h[v], v, h) === !1)
|
|
869
|
-
break;
|
|
870
|
-
}
|
|
871
|
-
return n;
|
|
872
|
-
};
|
|
873
|
-
}
|
|
874
|
-
function X(e, n) {
|
|
875
|
-
var a = e.__data__;
|
|
876
|
-
return pr(n) ? a[typeof n == "string" ? "string" : "hash"] : a.map;
|
|
877
|
-
}
|
|
878
|
-
function ne(e, n) {
|
|
879
|
-
var a = yt(e, n);
|
|
880
|
-
return Zt(a) ? a : void 0;
|
|
881
|
-
}
|
|
882
|
-
function ur(e) {
|
|
883
|
-
var n = j.call(e, x), a = e[x];
|
|
884
|
-
try {
|
|
885
|
-
e[x] = void 0;
|
|
886
|
-
var c = !0;
|
|
887
|
-
} catch {
|
|
888
|
-
}
|
|
889
|
-
var d = ve.call(e);
|
|
890
|
-
return c && (n ? e[x] = a : delete e[x]), d;
|
|
891
|
-
}
|
|
892
|
-
function fr(e) {
|
|
893
|
-
return typeof e.constructor == "function" && !je(e) ? Ot(Te(e)) : {};
|
|
894
|
-
}
|
|
895
|
-
function Ce(e, n) {
|
|
896
|
-
var a = typeof e;
|
|
897
|
-
return n = n ?? u, !!n && (a == "number" || a != "symbol" && dt.test(e)) && e > -1 && e % 1 == 0 && e < n;
|
|
898
|
-
}
|
|
899
|
-
function dr(e, n, a) {
|
|
900
|
-
if (!E(a))
|
|
901
|
-
return !1;
|
|
902
|
-
var c = typeof n;
|
|
903
|
-
return (c == "number" ? ie(a) && Ce(n, a.length) : c == "string" && n in a) ? Y(a[n], e) : !1;
|
|
904
|
-
}
|
|
905
|
-
function pr(e) {
|
|
906
|
-
var n = typeof e;
|
|
907
|
-
return n == "string" || n == "number" || n == "symbol" || n == "boolean" ? e !== "__proto__" : e === null;
|
|
908
|
-
}
|
|
909
|
-
function gr(e) {
|
|
910
|
-
return !!me && me in e;
|
|
911
|
-
}
|
|
912
|
-
function je(e) {
|
|
913
|
-
var n = e && e.constructor, a = typeof n == "function" && n.prototype || H;
|
|
914
|
-
return e === a;
|
|
915
|
-
}
|
|
916
|
-
function hr(e) {
|
|
917
|
-
var n = [];
|
|
918
|
-
if (e != null)
|
|
919
|
-
for (var a in Object(e))
|
|
920
|
-
n.push(a);
|
|
921
|
-
return n;
|
|
922
|
-
}
|
|
923
|
-
function br(e) {
|
|
924
|
-
return ve.call(e);
|
|
925
|
-
}
|
|
926
|
-
function yr(e, n, a) {
|
|
927
|
-
return n = Ae(n === void 0 ? e.length - 1 : n, 0), function() {
|
|
928
|
-
for (var c = arguments, d = -1, h = Ae(c.length - n, 0), m = Array(h); ++d < h; )
|
|
929
|
-
m[d] = c[n + d];
|
|
930
|
-
d = -1;
|
|
931
|
-
for (var g = Array(n + 1); ++d < n; )
|
|
932
|
-
g[d] = c[d];
|
|
933
|
-
return g[n] = a(m), gt(e, this, g);
|
|
934
|
-
};
|
|
935
|
-
}
|
|
936
|
-
function oe(e, n) {
|
|
937
|
-
if (!(n === "constructor" && typeof e[n] == "function") && n != "__proto__")
|
|
938
|
-
return e[n];
|
|
939
|
-
}
|
|
940
|
-
var mr = vr(rr);
|
|
941
|
-
function vr(e) {
|
|
942
|
-
var n = 0, a = 0;
|
|
943
|
-
return function() {
|
|
944
|
-
var c = St(), d = l - (c - a);
|
|
945
|
-
if (a = c, d > 0) {
|
|
946
|
-
if (++n >= i)
|
|
947
|
-
return arguments[0];
|
|
948
|
-
} else
|
|
949
|
-
n = 0;
|
|
950
|
-
return e.apply(void 0, arguments);
|
|
951
|
-
};
|
|
952
|
-
}
|
|
953
|
-
function _r(e) {
|
|
954
|
-
if (e != null) {
|
|
955
|
-
try {
|
|
956
|
-
return q.call(e);
|
|
957
|
-
} catch {
|
|
958
|
-
}
|
|
959
|
-
try {
|
|
960
|
-
return e + "";
|
|
961
|
-
} catch {
|
|
962
|
-
}
|
|
963
|
-
}
|
|
964
|
-
return "";
|
|
965
|
-
}
|
|
966
|
-
function Y(e, n) {
|
|
967
|
-
return e === n || e !== e && n !== n;
|
|
968
|
-
}
|
|
969
|
-
var ae = Se(/* @__PURE__ */ function() {
|
|
970
|
-
return arguments;
|
|
971
|
-
}()) ? Se : function(e) {
|
|
972
|
-
return D(e) && j.call(e, "callee") && !kt.call(e, "callee");
|
|
973
|
-
}, se = Array.isArray;
|
|
974
|
-
function ie(e) {
|
|
975
|
-
return e != null && $e(e.length) && !le(e);
|
|
976
|
-
}
|
|
977
|
-
function wr(e) {
|
|
978
|
-
return D(e) && ie(e);
|
|
979
|
-
}
|
|
980
|
-
var xe = It || Sr;
|
|
981
|
-
function le(e) {
|
|
982
|
-
if (!E(e))
|
|
983
|
-
return !1;
|
|
984
|
-
var n = W(e);
|
|
985
|
-
return n == O || n == w || n == y || n == Ke;
|
|
986
|
-
}
|
|
987
|
-
function $e(e) {
|
|
988
|
-
return typeof e == "number" && e > -1 && e % 1 == 0 && e <= u;
|
|
989
|
-
}
|
|
990
|
-
function E(e) {
|
|
991
|
-
var n = typeof e;
|
|
992
|
-
return e != null && (n == "object" || n == "function");
|
|
993
|
-
}
|
|
994
|
-
function D(e) {
|
|
995
|
-
return e != null && typeof e == "object";
|
|
996
|
-
}
|
|
997
|
-
function Tr(e) {
|
|
998
|
-
if (!D(e) || W(e) != de)
|
|
999
|
-
return !1;
|
|
1000
|
-
var n = Te(e);
|
|
1001
|
-
if (n === null)
|
|
1002
|
-
return !0;
|
|
1003
|
-
var a = j.call(n, "constructor") && n.constructor;
|
|
1004
|
-
return typeof a == "function" && a instanceof a && q.call(a) == wt;
|
|
1005
|
-
}
|
|
1006
|
-
var Ee = ye ? bt(ye) : Qt;
|
|
1007
|
-
function kr(e) {
|
|
1008
|
-
return ir(e, Re(e));
|
|
1009
|
-
}
|
|
1010
|
-
function Re(e) {
|
|
1011
|
-
return ie(e) ? Wt(e) : Vt(e);
|
|
1012
|
-
}
|
|
1013
|
-
var Ar = lr(function(e, n, a, c) {
|
|
1014
|
-
Oe(e, n, a, c);
|
|
1015
|
-
});
|
|
1016
|
-
function Ir(e) {
|
|
1017
|
-
return function() {
|
|
1018
|
-
return e;
|
|
1019
|
-
};
|
|
1020
|
-
}
|
|
1021
|
-
function Pe(e) {
|
|
1022
|
-
return e;
|
|
1023
|
-
}
|
|
1024
|
-
function Sr() {
|
|
1025
|
-
return !1;
|
|
1026
|
-
}
|
|
1027
|
-
o.exports = Ar;
|
|
1028
|
-
})(Q, Q.exports);
|
|
1029
|
-
var An = Q.exports;
|
|
1030
|
-
const In = /* @__PURE__ */ kn(An);
|
|
1031
|
-
function Sn(o) {
|
|
1032
|
-
let r = {};
|
|
1033
|
-
function t(s, i) {
|
|
1034
|
-
if ((i == null ? void 0 : i.type) === "AwaitExpression" && i.argument.type === "CallExpression" && i.argument.callee.type === "Identifier" && i.argument.callee.name === "useStoryblok") {
|
|
1035
|
-
const l = i.argument.arguments;
|
|
1036
|
-
if (l && l[1].type === "ObjectExpression") {
|
|
1037
|
-
const u = He(l[1].properties);
|
|
1038
|
-
r = {
|
|
1039
|
-
...r,
|
|
1040
|
-
apiOptions: u
|
|
1041
|
-
};
|
|
1042
|
-
}
|
|
1043
|
-
if (l && l[2].type === "ObjectExpression") {
|
|
1044
|
-
const u = He(l[2].properties);
|
|
1045
|
-
r = {
|
|
1046
|
-
...r,
|
|
1047
|
-
bridgeOptions: u
|
|
1048
|
-
};
|
|
1049
|
-
}
|
|
1050
|
-
}
|
|
1051
|
-
}
|
|
1052
|
-
return In({}, o, t), r;
|
|
1053
|
-
}
|
|
1054
|
-
function He(o) {
|
|
1055
|
-
const r = {};
|
|
1056
|
-
return o.reduce((t, s) => {
|
|
1057
|
-
if (s.type !== "Property") return t;
|
|
1058
|
-
const { key: i, value: l } = s, { type: u } = l;
|
|
1059
|
-
if (i.type !== "Identifier") return t;
|
|
1060
|
-
if (u === "Literal")
|
|
1061
|
-
t[i.name] = l.value;
|
|
1062
|
-
else if (u === "ArrayExpression") {
|
|
1063
|
-
const f = l.elements.reduce((p, y) => y.type === "Literal" && y.value ? [...p, y.value] : p, []);
|
|
1064
|
-
t[i.name] = f;
|
|
1065
|
-
}
|
|
1066
|
-
return t;
|
|
1067
|
-
}, r);
|
|
545
|
+
["published", "change"].includes(r == null ? void 0 : r.action) && location.reload();
|
|
1068
546
|
}
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
return {
|
|
1074
|
-
name: "vite-plugin-storyblok-bridge",
|
|
1075
|
-
resolveId(f) {
|
|
1076
|
-
if (f === t)
|
|
1077
|
-
return s;
|
|
1078
|
-
},
|
|
1079
|
-
load(f) {
|
|
1080
|
-
if (f === s)
|
|
1081
|
-
return "export const bridgeOptions = null";
|
|
1082
|
-
}
|
|
1083
|
-
};
|
|
1084
|
-
let i = [], l = null, u;
|
|
1085
|
-
return {
|
|
1086
|
-
name: "vite-plugin-storyblok-bridge",
|
|
1087
|
-
async resolveId(f) {
|
|
1088
|
-
if (f === t)
|
|
1089
|
-
return s;
|
|
1090
|
-
},
|
|
1091
|
-
async transform(f, p) {
|
|
1092
|
-
var O;
|
|
1093
|
-
if (p.includes("node_modules") && !p.includes("/pages/") || !f.includes("useStoryblok") || !((O = this.getModuleInfo(p).meta) != null && O.astro)) return;
|
|
1094
|
-
const [, ..._] = p.split("src/pages/"), k = _.join("/").replace(".astro", ""), A = Sn(this.parse(f));
|
|
1095
|
-
B.length && (i = B.filter((w) => w.url !== k)), i.push({
|
|
1096
|
-
url: k,
|
|
1097
|
-
options: A
|
|
1098
|
-
}), l && (u && clearTimeout(u), u = setTimeout(() => {
|
|
1099
|
-
Cn(B, i) || (B.length !== 0 && (l.restart(), console.info("Bridge options updated. Restarting...")), B = [...i]);
|
|
1100
|
-
}, 1e3));
|
|
1101
|
-
},
|
|
1102
|
-
async load(f) {
|
|
1103
|
-
if (f === s)
|
|
1104
|
-
return `export const bridgeOptions = ${JSON.stringify(Tn(i))}`;
|
|
1105
|
-
},
|
|
1106
|
-
configureServer(f) {
|
|
1107
|
-
l = f;
|
|
1108
|
-
}
|
|
1109
|
-
};
|
|
1110
|
-
}
|
|
1111
|
-
function Cn(o = [], r = []) {
|
|
1112
|
-
return r.every(({ url: t, options: s }) => {
|
|
1113
|
-
const i = o.find((l) => (l == null ? void 0 : l.url) === t);
|
|
1114
|
-
return i && JSON.stringify(s) === JSON.stringify(i.options);
|
|
1115
|
-
});
|
|
1116
|
-
}
|
|
1117
|
-
let qe;
|
|
1118
|
-
async function Rn(o) {
|
|
1119
|
-
const { action: r, story: t } = o || {};
|
|
1120
|
-
if (r === "input" && t) {
|
|
1121
|
-
const s = async () => {
|
|
1122
|
-
const l = await xn(t), u = document.body;
|
|
1123
|
-
if (l.outerHTML === u.outerHTML) return;
|
|
1124
|
-
const f = document.querySelector('[data-blok-focused="true"]');
|
|
1125
|
-
jn(u, l, f);
|
|
1126
|
-
};
|
|
1127
|
-
clearTimeout(qe), qe = setTimeout(s, 500);
|
|
1128
|
-
}
|
|
1129
|
-
["published", "change"].includes(o == null ? void 0 : o.action) && location.reload();
|
|
1130
|
-
}
|
|
1131
|
-
function jn(o, r, t) {
|
|
1132
|
-
if (t) {
|
|
1133
|
-
const s = t.getAttribute("data-blok-uid"), i = r.querySelector(
|
|
1134
|
-
`[data-blok-uid="${s}"]`
|
|
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}"]`
|
|
1135
551
|
);
|
|
1136
|
-
|
|
552
|
+
s && (s.setAttribute("data-blok-focused", "true"), e.replaceWith(s));
|
|
1137
553
|
} else
|
|
1138
|
-
|
|
554
|
+
r.replaceWith(t);
|
|
1139
555
|
}
|
|
1140
|
-
async function
|
|
1141
|
-
const
|
|
556
|
+
async function Se(r) {
|
|
557
|
+
const e = await (await fetch(location.href, {
|
|
1142
558
|
method: "POST",
|
|
1143
559
|
body: JSON.stringify({
|
|
1144
|
-
...
|
|
560
|
+
...r,
|
|
1145
561
|
is_storyblok_preview: !0
|
|
1146
562
|
}),
|
|
1147
563
|
headers: {
|
|
1148
564
|
"Content-Type": "application/json"
|
|
1149
565
|
}
|
|
1150
566
|
})).text();
|
|
1151
|
-
return new DOMParser().parseFromString(
|
|
567
|
+
return new DOMParser().parseFromString(e, "text/html").body;
|
|
1152
568
|
}
|
|
1153
|
-
function
|
|
569
|
+
function Ee() {
|
|
1154
570
|
return globalThis.storyblokApiInstance || console.error("storyblokApiInstance has not been initialized correctly"), globalThis.storyblokApiInstance;
|
|
1155
571
|
}
|
|
1156
|
-
async function
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
if (s && s.locals._storyblok_preview_data)
|
|
1160
|
-
i = s.locals._storyblok_preview_data;
|
|
1161
|
-
else {
|
|
1162
|
-
const { data: l } = await globalThis.storyblokApiInstance.get(
|
|
1163
|
-
o,
|
|
1164
|
-
r,
|
|
1165
|
-
t
|
|
1166
|
-
);
|
|
1167
|
-
i = l.story;
|
|
1168
|
-
}
|
|
1169
|
-
return i;
|
|
572
|
+
async function Ce(r) {
|
|
573
|
+
let t = null;
|
|
574
|
+
return r && r.locals._storyblok_preview_data && (t = r.locals._storyblok_preview_data), t;
|
|
1170
575
|
}
|
|
1171
|
-
function
|
|
1172
|
-
const
|
|
1173
|
-
if (!
|
|
576
|
+
function je(r, t) {
|
|
577
|
+
const e = globalThis.storyblokApiInstance.richTextResolver;
|
|
578
|
+
if (!e) {
|
|
1174
579
|
console.error(
|
|
1175
580
|
"Please initialize the Storyblok SDK before calling the renderRichText function"
|
|
1176
581
|
);
|
|
1177
582
|
return;
|
|
1178
583
|
}
|
|
1179
|
-
return
|
|
584
|
+
return $e(r, t, e);
|
|
1180
585
|
}
|
|
1181
|
-
function
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
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);
|
|
1190
602
|
return {
|
|
1191
603
|
name: "@storyblok/astro",
|
|
1192
604
|
hooks: {
|
|
1193
605
|
"astro:config:setup": ({
|
|
1194
|
-
injectScript:
|
|
1195
|
-
updateConfig:
|
|
1196
|
-
addDevToolbarApp:
|
|
1197
|
-
addMiddleware:
|
|
1198
|
-
config:
|
|
606
|
+
injectScript: l,
|
|
607
|
+
updateConfig: c,
|
|
608
|
+
addDevToolbarApp: u,
|
|
609
|
+
addMiddleware: f,
|
|
610
|
+
config: d
|
|
1199
611
|
}) => {
|
|
1200
|
-
if (
|
|
612
|
+
if (c({
|
|
1201
613
|
vite: {
|
|
1202
614
|
plugins: [
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
615
|
+
E(
|
|
616
|
+
n.accessToken,
|
|
617
|
+
n.useCustomApi,
|
|
618
|
+
n.apiOptions
|
|
1207
619
|
),
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
620
|
+
N(
|
|
621
|
+
n.componentsDir,
|
|
622
|
+
n.components,
|
|
623
|
+
n.enableFallbackComponent,
|
|
624
|
+
n.customFallbackComponent
|
|
1213
625
|
),
|
|
1214
|
-
|
|
1215
|
-
On(
|
|
1216
|
-
r.livePreview,
|
|
1217
|
-
u.output
|
|
1218
|
-
)
|
|
626
|
+
P(n)
|
|
1219
627
|
]
|
|
1220
628
|
}
|
|
1221
|
-
}),
|
|
629
|
+
}), n.livePreview && (d == null ? void 0 : d.output) !== "server")
|
|
1222
630
|
throw new Error(
|
|
1223
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."
|
|
1224
632
|
);
|
|
1225
|
-
|
|
633
|
+
l(
|
|
1226
634
|
"page-ssr",
|
|
1227
635
|
`
|
|
1228
636
|
import { storyblokApiInstance } from "virtual:storyblok-init";
|
|
1229
637
|
globalThis.storyblokApiInstance = storyblokApiInstance;
|
|
1230
638
|
`
|
|
1231
|
-
),
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
const p = { ...r.bridge };
|
|
1235
|
-
f = `const storyblokInstance = new StoryblokBridge(${JSON.stringify(
|
|
1236
|
-
p
|
|
1237
|
-
)});`;
|
|
1238
|
-
} else
|
|
1239
|
-
f = "const storyblokInstance = new StoryblokBridge()";
|
|
1240
|
-
t(
|
|
1241
|
-
"page",
|
|
1242
|
-
`
|
|
639
|
+
), t && !s && l(
|
|
640
|
+
"page",
|
|
641
|
+
`
|
|
1243
642
|
import { loadStoryblokBridge } from "@storyblok/astro";
|
|
1244
643
|
loadStoryblokBridge().then(() => {
|
|
1245
644
|
const { StoryblokBridge, location } = window;
|
|
1246
|
-
${
|
|
1247
|
-
|
|
645
|
+
${i}
|
|
1248
646
|
storyblokInstance.on(["published", "change"], (event) => {
|
|
1249
647
|
if (!event.slugChanged) {
|
|
1250
648
|
location.reload(true);
|
|
@@ -1252,38 +650,33 @@ function zn(o) {
|
|
|
1252
650
|
});
|
|
1253
651
|
});
|
|
1254
652
|
`
|
|
1255
|
-
|
|
1256
|
-
}
|
|
1257
|
-
r.livePreview && (t(
|
|
653
|
+
), s && (l(
|
|
1258
654
|
"page",
|
|
1259
655
|
`
|
|
1260
656
|
import { loadStoryblokBridge, handleStoryblokMessage } from "@storyblok/astro";
|
|
1261
|
-
import { bridgeOptions } from "virtual:storyblok-bridge";
|
|
1262
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.")
|
|
1263
658
|
loadStoryblokBridge().then(() => {
|
|
1264
659
|
const { StoryblokBridge, location } = window;
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
storyblokInstance.on(["published", "change", "input"], handleStoryblokMessage);
|
|
1268
|
-
};
|
|
660
|
+
${i}
|
|
661
|
+
storyblokInstance.on(["published", "change", "input"], handleStoryblokMessage);
|
|
1269
662
|
});
|
|
1270
663
|
`
|
|
1271
|
-
),
|
|
664
|
+
), f({
|
|
1272
665
|
entrypoint: "@storyblok/astro/middleware.ts",
|
|
1273
666
|
order: "pre"
|
|
1274
|
-
})),
|
|
667
|
+
})), u("@storyblok/astro/toolbarApp.ts");
|
|
1275
668
|
}
|
|
1276
669
|
}
|
|
1277
670
|
};
|
|
1278
671
|
}
|
|
1279
672
|
export {
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
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
|
|
1289
682
|
};
|