@storyblok/astro 4.0.4 → 4.0.5-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/storyblok-astro.js +14 -15
- package/dist/storyblok-astro.mjs +818 -355
- package/dist/types/cypress.config.d.ts +1 -1
- package/package.json +3 -3
package/dist/storyblok-astro.mjs
CHANGED
|
@@ -1,147 +1,76 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
name: "vite-plugin-storyblok-init",
|
|
5
|
-
async resolveId(a) {
|
|
6
|
-
if (a === o)
|
|
7
|
-
return s;
|
|
8
|
-
},
|
|
9
|
-
async load(a) {
|
|
10
|
-
if (a === s)
|
|
11
|
-
return `
|
|
12
|
-
import { storyblokInit, apiPlugin } from "@storyblok/js";
|
|
13
|
-
const { storyblokApi } = storyblokInit({
|
|
14
|
-
accessToken: "${r}",
|
|
15
|
-
use: ${t ? "[]" : "[apiPlugin]"},
|
|
16
|
-
apiOptions: ${JSON.stringify(e)},
|
|
17
|
-
});
|
|
18
|
-
export const storyblokApiInstance = storyblokApi;
|
|
19
|
-
`;
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
const T = /[\p{Lu}]/u, x = /[\p{Ll}]/u, k = /^[\p{Lu}](?![\p{Lu}])/gu, C = /([\p{Alpha}\p{N}_]|$)/u, m = /[_.\- ]+/, S = new RegExp("^" + m.source), $ = new RegExp(m.source + C.source, "gu"), v = new RegExp("\\d+" + C.source, "gu"), j = (r, t, e, o) => {
|
|
24
|
-
let s = !1, a = !1, n = !1, c = !1;
|
|
25
|
-
for (let l = 0; l < r.length; l++) {
|
|
26
|
-
const i = r[l];
|
|
27
|
-
c = l > 2 ? r[l - 3] === "-" : !0, s && T.test(i) ? (r = r.slice(0, l) + "-" + r.slice(l), s = !1, n = a, a = !0, l++) : a && n && x.test(i) && (!c || o) ? (r = r.slice(0, l - 1) + "-" + r.slice(l - 1), n = a, a = !1, s = !0) : (s = t(i) === i && e(i) !== i, n = a, a = e(i) === i && t(i) !== i);
|
|
28
|
-
}
|
|
29
|
-
return r;
|
|
30
|
-
}, R = (r, t) => (k.lastIndex = 0, r.replaceAll(k, (e) => t(e))), O = (r, t) => ($.lastIndex = 0, v.lastIndex = 0, r.replaceAll(v, (e, o, s) => ["_", "-"].includes(r.charAt(s + e.length)) ? e : t(e)).replaceAll($, (e, o) => t(o)));
|
|
31
|
-
function I(r, t) {
|
|
32
|
-
if (!(typeof r == "string" || Array.isArray(r)))
|
|
33
|
-
throw new TypeError("Expected the input to be `string | string[]`");
|
|
34
|
-
if (t = {
|
|
35
|
-
pascalCase: !1,
|
|
36
|
-
preserveConsecutiveUppercase: !1,
|
|
37
|
-
...t
|
|
38
|
-
}, Array.isArray(r) ? r = r.map((a) => a.trim()).filter((a) => a.length).join("-") : r = r.trim(), r.length === 0)
|
|
39
|
-
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 ? m.test(r) ? "" : t.pascalCase ? o(r) : e(r) : (r !== e(r) && (r = j(r, e, o, t.preserveConsecutiveUppercase)), r = r.replace(S, ""), r = t.preserveConsecutiveUppercase ? R(r, e) : e(r), t.pascalCase && (r = o(r.charAt(0)) + r.slice(1)), O(r, o));
|
|
42
|
-
}
|
|
43
|
-
function N(r, t, e, o) {
|
|
44
|
-
const s = "virtual:storyblok-components", a = "\0" + s;
|
|
45
|
-
return {
|
|
46
|
-
name: "vite-plugin-storyblok-components",
|
|
47
|
-
async resolveId(n) {
|
|
48
|
-
if (n === s)
|
|
49
|
-
return a;
|
|
50
|
-
},
|
|
51
|
-
async load(n) {
|
|
52
|
-
if (n === a) {
|
|
53
|
-
const c = [], l = [];
|
|
54
|
-
for await (const [g, f] of Object.entries(t)) {
|
|
55
|
-
const d = await this.resolve(
|
|
56
|
-
"/" + r + "/" + f + ".astro"
|
|
57
|
-
);
|
|
58
|
-
if (d)
|
|
59
|
-
c.push(`import ${I(g)} from "${d.id}"`);
|
|
60
|
-
else if (e)
|
|
61
|
-
l.push(g);
|
|
62
|
-
else
|
|
63
|
-
throw new Error(
|
|
64
|
-
`Component could not be found for blok "${g}"! Does "${"/" + r + "/" + f}.astro" exist?`
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
let i = "";
|
|
68
|
-
if (e)
|
|
69
|
-
if (i = ",FallbackComponent", o) {
|
|
70
|
-
const g = await this.resolve(
|
|
71
|
-
"/" + r + "/" + o + ".astro"
|
|
72
|
-
);
|
|
73
|
-
if (!g)
|
|
74
|
-
throw new Error(
|
|
75
|
-
`Custom fallback component could not be found. Does "${"/" + r + "/" + o}.astro" exist?`
|
|
76
|
-
);
|
|
77
|
-
c.push(
|
|
78
|
-
`import FallbackComponent from "${g.id}"`
|
|
79
|
-
);
|
|
80
|
-
} else
|
|
81
|
-
c.push(
|
|
82
|
-
"import FallbackComponent from '@storyblok/astro/FallbackComponent.astro'"
|
|
83
|
-
);
|
|
84
|
-
if (Object.values(t).length)
|
|
85
|
-
return `${c.join(";")};export default {${Object.keys(t).filter((g) => !l.includes(g)).map((g) => I(g)).join(",")}${i}}`;
|
|
86
|
-
if (e)
|
|
87
|
-
return `${c[0]}; export default {${i.replace(",", "")}}`;
|
|
88
|
-
throw new Error(
|
|
89
|
-
`Currently, no Storyblok components are registered in astro.config.mjs.
|
|
90
|
-
Please register your components or enable the fallback component.
|
|
91
|
-
Detailed information can be found here: https://github.com/storyblok/storyblok-astro`
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
function L(r) {
|
|
98
|
-
const t = "virtual:storyblok-options", e = "\0" + t;
|
|
99
|
-
return {
|
|
100
|
-
name: "vite-plugin-storyblok-options",
|
|
101
|
-
async resolveId(o) {
|
|
102
|
-
if (o === t)
|
|
103
|
-
return e;
|
|
104
|
-
},
|
|
105
|
-
async load(o) {
|
|
106
|
-
if (o === e)
|
|
107
|
-
return `export default ${JSON.stringify(r)}`;
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
let w = !1;
|
|
112
|
-
const A = [], M = (r) => new Promise((t, e) => {
|
|
113
|
-
if (typeof window > "u" || (window.storyblokRegisterEvent = (s) => {
|
|
1
|
+
let _ = !1;
|
|
2
|
+
const C = [], P = (o) => new Promise((e, t) => {
|
|
3
|
+
if (typeof window > "u" || (window.storyblokRegisterEvent = (r) => {
|
|
114
4
|
if (window.location === window.parent.location) {
|
|
115
5
|
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
116
6
|
return;
|
|
117
7
|
}
|
|
118
|
-
|
|
8
|
+
_ ? r() : C.push(r);
|
|
119
9
|
}, document.getElementById("storyblok-javascript-bridge")))
|
|
120
10
|
return;
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}, document.getElementsByTagName("head")[0].appendChild(
|
|
11
|
+
const s = document.createElement("script");
|
|
12
|
+
s.async = !0, s.src = o, s.id = "storyblok-javascript-bridge", s.onerror = (r) => t(r), s.onload = (r) => {
|
|
13
|
+
C.forEach((i) => i()), _ = !0, e(r);
|
|
14
|
+
}, document.getElementsByTagName("head")[0].appendChild(s);
|
|
125
15
|
});
|
|
126
|
-
var
|
|
127
|
-
|
|
16
|
+
var M = Object.defineProperty, U = (o, e, t) => e in o ? M(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, u = (o, e, t) => (U(o, typeof e != "symbol" ? e + "" : e, t), t);
|
|
17
|
+
function A(o) {
|
|
18
|
+
return !(o !== o || o === 1 / 0 || o === -1 / 0);
|
|
19
|
+
}
|
|
20
|
+
function z(o, e, t) {
|
|
21
|
+
if (!A(e))
|
|
22
|
+
throw new TypeError("Expected `limit` to be a finite number");
|
|
23
|
+
if (!A(t))
|
|
24
|
+
throw new TypeError("Expected `interval` to be a finite number");
|
|
25
|
+
const s = [];
|
|
26
|
+
let r = [], i = 0;
|
|
27
|
+
const n = function() {
|
|
28
|
+
i++;
|
|
29
|
+
const a = setTimeout(function() {
|
|
30
|
+
i--, s.length > 0 && n(), r = r.filter(function(h) {
|
|
31
|
+
return h !== a;
|
|
32
|
+
});
|
|
33
|
+
}, t);
|
|
34
|
+
r.indexOf(a) < 0 && r.push(a);
|
|
35
|
+
const l = s.shift();
|
|
36
|
+
l.resolve(o.apply(l.self, l.args));
|
|
37
|
+
}, c = function(...a) {
|
|
38
|
+
const l = this;
|
|
39
|
+
return new Promise(function(h, p) {
|
|
40
|
+
s.push({
|
|
41
|
+
resolve: h,
|
|
42
|
+
reject: p,
|
|
43
|
+
args: a,
|
|
44
|
+
self: l
|
|
45
|
+
}), i < e && n();
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
return c.abort = function() {
|
|
49
|
+
r.forEach(clearTimeout), r = [], s.forEach(function(a) {
|
|
50
|
+
a.reject(function() {
|
|
51
|
+
Error.call(this, "Throttled function aborted"), this.name = "AbortError";
|
|
52
|
+
});
|
|
53
|
+
}), s.length = 0;
|
|
54
|
+
}, c;
|
|
55
|
+
}
|
|
56
|
+
class b {
|
|
128
57
|
constructor() {
|
|
129
|
-
|
|
130
|
-
...
|
|
131
|
-
per_page:
|
|
132
|
-
page:
|
|
133
|
-
})),
|
|
134
|
-
const
|
|
135
|
-
return this.arrayFrom(
|
|
136
|
-
}),
|
|
137
|
-
const
|
|
58
|
+
u(this, "isCDNUrl", (e = "") => e.indexOf("/cdn/") > -1), u(this, "getOptionsPage", (e, t = 25, s = 1) => ({
|
|
59
|
+
...e,
|
|
60
|
+
per_page: t,
|
|
61
|
+
page: s
|
|
62
|
+
})), u(this, "delay", (e) => new Promise((t) => setTimeout(t, e))), u(this, "arrayFrom", (e = 0, t) => [...Array(e)].map(t)), u(this, "range", (e = 0, t = e) => {
|
|
63
|
+
const s = Math.abs(t - e) || 0, r = e < t ? 1 : -1;
|
|
64
|
+
return this.arrayFrom(s, (i, n) => n * r + e);
|
|
65
|
+
}), u(this, "asyncMap", async (e, t) => Promise.all(e.map(t))), u(this, "flatMap", (e = [], t) => e.map(t).reduce((s, r) => [...s, ...r], [])), u(this, "escapeHTML", function(e) {
|
|
66
|
+
const t = {
|
|
138
67
|
"&": "&",
|
|
139
68
|
"<": "<",
|
|
140
69
|
">": ">",
|
|
141
70
|
'"': """,
|
|
142
71
|
"'": "'"
|
|
143
|
-
},
|
|
144
|
-
return
|
|
72
|
+
}, s = /[&<>"']/g, r = RegExp(s.source);
|
|
73
|
+
return e && r.test(e) ? e.replace(s, (i) => t[i]) : e;
|
|
145
74
|
});
|
|
146
75
|
}
|
|
147
76
|
/**
|
|
@@ -151,223 +80,223 @@ class z {
|
|
|
151
80
|
* @param {Boolean} isArray
|
|
152
81
|
* @return {String} Stringified object
|
|
153
82
|
*/
|
|
154
|
-
stringify(
|
|
155
|
-
const
|
|
156
|
-
for (const
|
|
157
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
83
|
+
stringify(e, t, s) {
|
|
84
|
+
const r = [];
|
|
85
|
+
for (const i in e) {
|
|
86
|
+
if (!Object.prototype.hasOwnProperty.call(e, i))
|
|
158
87
|
continue;
|
|
159
|
-
const n =
|
|
160
|
-
let
|
|
161
|
-
typeof n == "object" ?
|
|
88
|
+
const n = e[i], c = s ? "" : encodeURIComponent(i);
|
|
89
|
+
let a;
|
|
90
|
+
typeof n == "object" ? a = this.stringify(
|
|
162
91
|
n,
|
|
163
|
-
|
|
92
|
+
t ? t + encodeURIComponent("[" + c + "]") : c,
|
|
164
93
|
Array.isArray(n)
|
|
165
|
-
) :
|
|
94
|
+
) : a = (t ? t + encodeURIComponent("[" + c + "]") : c) + "=" + encodeURIComponent(n), r.push(a);
|
|
166
95
|
}
|
|
167
|
-
return
|
|
96
|
+
return r.join("&");
|
|
168
97
|
}
|
|
169
98
|
/**
|
|
170
99
|
* @method getRegionURL
|
|
171
100
|
* @param {String} regionCode region code, could be eu, us, cn, ap or ca
|
|
172
101
|
* @return {String} The base URL of the region
|
|
173
102
|
*/
|
|
174
|
-
getRegionURL(
|
|
175
|
-
const
|
|
176
|
-
switch (
|
|
103
|
+
getRegionURL(e) {
|
|
104
|
+
const t = "api.storyblok.com", s = "api-us.storyblok.com", r = "app.storyblokchina.cn", i = "api-ap.storyblok.com", n = "api-ca.storyblok.com";
|
|
105
|
+
switch (e) {
|
|
177
106
|
case "us":
|
|
178
|
-
return o;
|
|
179
|
-
case "cn":
|
|
180
107
|
return s;
|
|
108
|
+
case "cn":
|
|
109
|
+
return r;
|
|
181
110
|
case "ap":
|
|
182
|
-
return
|
|
111
|
+
return i;
|
|
183
112
|
case "ca":
|
|
184
113
|
return n;
|
|
185
114
|
default:
|
|
186
|
-
return
|
|
115
|
+
return t;
|
|
187
116
|
}
|
|
188
117
|
}
|
|
189
118
|
}
|
|
190
|
-
const
|
|
191
|
-
const
|
|
192
|
-
for (const
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
return
|
|
197
|
-
},
|
|
119
|
+
const F = function(o, e) {
|
|
120
|
+
const t = {};
|
|
121
|
+
for (const s in o) {
|
|
122
|
+
const r = o[s];
|
|
123
|
+
e.indexOf(s) > -1 && r !== null && (t[s] = r);
|
|
124
|
+
}
|
|
125
|
+
return t;
|
|
126
|
+
}, H = (o) => o === "email", q = () => ({
|
|
198
127
|
singleTag: "hr"
|
|
199
|
-
}),
|
|
128
|
+
}), B = () => ({
|
|
200
129
|
tag: "blockquote"
|
|
201
|
-
}),
|
|
130
|
+
}), D = () => ({
|
|
202
131
|
tag: "ul"
|
|
203
|
-
}),
|
|
132
|
+
}), V = (o) => ({
|
|
204
133
|
tag: [
|
|
205
134
|
"pre",
|
|
206
135
|
{
|
|
207
136
|
tag: "code",
|
|
208
|
-
attrs:
|
|
137
|
+
attrs: o.attrs
|
|
209
138
|
}
|
|
210
139
|
]
|
|
211
|
-
}),
|
|
140
|
+
}), J = () => ({
|
|
212
141
|
singleTag: "br"
|
|
213
|
-
}),
|
|
214
|
-
tag: `h${
|
|
215
|
-
}),
|
|
142
|
+
}), K = (o) => ({
|
|
143
|
+
tag: `h${o.attrs.level}`
|
|
144
|
+
}), G = (o) => ({
|
|
216
145
|
singleTag: [
|
|
217
146
|
{
|
|
218
147
|
tag: "img",
|
|
219
|
-
attrs:
|
|
148
|
+
attrs: F(o.attrs, ["src", "alt", "title"])
|
|
220
149
|
}
|
|
221
150
|
]
|
|
222
|
-
}), G = () => ({
|
|
223
|
-
tag: "li"
|
|
224
151
|
}), W = () => ({
|
|
225
|
-
tag: "
|
|
152
|
+
tag: "li"
|
|
226
153
|
}), Y = () => ({
|
|
154
|
+
tag: "ol"
|
|
155
|
+
}), Q = () => ({
|
|
227
156
|
tag: "p"
|
|
228
|
-
}),
|
|
157
|
+
}), X = (o) => ({
|
|
229
158
|
tag: [
|
|
230
159
|
{
|
|
231
160
|
tag: "span",
|
|
232
161
|
attrs: {
|
|
233
162
|
"data-type": "emoji",
|
|
234
|
-
"data-name":
|
|
235
|
-
emoji:
|
|
163
|
+
"data-name": o.attrs.name,
|
|
164
|
+
emoji: o.attrs.emoji
|
|
236
165
|
}
|
|
237
166
|
}
|
|
238
167
|
]
|
|
239
|
-
}), X = () => ({
|
|
240
|
-
tag: "b"
|
|
241
168
|
}), Z = () => ({
|
|
242
|
-
tag: "
|
|
169
|
+
tag: "b"
|
|
243
170
|
}), ee = () => ({
|
|
244
|
-
tag: "
|
|
171
|
+
tag: "s"
|
|
245
172
|
}), te = () => ({
|
|
173
|
+
tag: "u"
|
|
174
|
+
}), se = () => ({
|
|
246
175
|
tag: "strong"
|
|
247
176
|
}), re = () => ({
|
|
248
177
|
tag: "code"
|
|
249
178
|
}), oe = () => ({
|
|
250
179
|
tag: "i"
|
|
251
|
-
}),
|
|
252
|
-
if (!
|
|
180
|
+
}), ie = (o) => {
|
|
181
|
+
if (!o.attrs)
|
|
253
182
|
return {
|
|
254
183
|
tag: ""
|
|
255
184
|
};
|
|
256
|
-
const
|
|
257
|
-
if (delete
|
|
258
|
-
for (const
|
|
259
|
-
|
|
260
|
-
delete
|
|
185
|
+
const e = new b().escapeHTML, t = { ...o.attrs }, { linktype: s = "url" } = o.attrs;
|
|
186
|
+
if (delete t.linktype, t.href && (t.href = e(o.attrs.href || "")), H(s) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), t.custom) {
|
|
187
|
+
for (const r in t.custom)
|
|
188
|
+
t[r] = t.custom[r];
|
|
189
|
+
delete t.custom;
|
|
261
190
|
}
|
|
262
191
|
return {
|
|
263
192
|
tag: [
|
|
264
193
|
{
|
|
265
194
|
tag: "a",
|
|
266
|
-
attrs:
|
|
195
|
+
attrs: t
|
|
267
196
|
}
|
|
268
197
|
]
|
|
269
198
|
};
|
|
270
|
-
},
|
|
199
|
+
}, ne = (o) => ({
|
|
271
200
|
tag: [
|
|
272
201
|
{
|
|
273
202
|
tag: "span",
|
|
274
|
-
attrs:
|
|
203
|
+
attrs: o.attrs
|
|
275
204
|
}
|
|
276
205
|
]
|
|
277
|
-
}),
|
|
206
|
+
}), ae = () => ({
|
|
278
207
|
tag: "sub"
|
|
279
208
|
}), le = () => ({
|
|
280
209
|
tag: "sup"
|
|
281
|
-
}),
|
|
210
|
+
}), ce = (o) => ({
|
|
282
211
|
tag: [
|
|
283
212
|
{
|
|
284
213
|
tag: "span",
|
|
285
|
-
attrs:
|
|
214
|
+
attrs: o.attrs
|
|
286
215
|
}
|
|
287
216
|
]
|
|
288
|
-
}),
|
|
289
|
-
var
|
|
290
|
-
return (
|
|
217
|
+
}), he = (o) => {
|
|
218
|
+
var e;
|
|
219
|
+
return (e = o.attrs) != null && e.color ? {
|
|
291
220
|
tag: [
|
|
292
221
|
{
|
|
293
222
|
tag: "span",
|
|
294
223
|
attrs: {
|
|
295
|
-
style: `background-color:${
|
|
224
|
+
style: `background-color:${o.attrs.color};`
|
|
296
225
|
}
|
|
297
226
|
}
|
|
298
227
|
]
|
|
299
228
|
} : {
|
|
300
229
|
tag: ""
|
|
301
230
|
};
|
|
302
|
-
},
|
|
303
|
-
var
|
|
304
|
-
return (
|
|
231
|
+
}, ue = (o) => {
|
|
232
|
+
var e;
|
|
233
|
+
return (e = o.attrs) != null && e.color ? {
|
|
305
234
|
tag: [
|
|
306
235
|
{
|
|
307
236
|
tag: "span",
|
|
308
237
|
attrs: {
|
|
309
|
-
style: `color:${
|
|
238
|
+
style: `color:${o.attrs.color}`
|
|
310
239
|
}
|
|
311
240
|
}
|
|
312
241
|
]
|
|
313
242
|
} : {
|
|
314
243
|
tag: ""
|
|
315
244
|
};
|
|
316
|
-
},
|
|
245
|
+
}, pe = {
|
|
317
246
|
nodes: {
|
|
318
|
-
horizontal_rule:
|
|
319
|
-
blockquote:
|
|
320
|
-
bullet_list:
|
|
321
|
-
code_block:
|
|
322
|
-
hard_break:
|
|
323
|
-
heading:
|
|
324
|
-
image:
|
|
325
|
-
list_item:
|
|
326
|
-
ordered_list:
|
|
327
|
-
paragraph:
|
|
328
|
-
emoji:
|
|
247
|
+
horizontal_rule: q,
|
|
248
|
+
blockquote: B,
|
|
249
|
+
bullet_list: D,
|
|
250
|
+
code_block: V,
|
|
251
|
+
hard_break: J,
|
|
252
|
+
heading: K,
|
|
253
|
+
image: G,
|
|
254
|
+
list_item: W,
|
|
255
|
+
ordered_list: Y,
|
|
256
|
+
paragraph: Q,
|
|
257
|
+
emoji: X
|
|
329
258
|
},
|
|
330
259
|
marks: {
|
|
331
|
-
bold:
|
|
332
|
-
strike:
|
|
333
|
-
underline:
|
|
334
|
-
strong:
|
|
260
|
+
bold: Z,
|
|
261
|
+
strike: ee,
|
|
262
|
+
underline: te,
|
|
263
|
+
strong: se,
|
|
335
264
|
code: re,
|
|
336
265
|
italic: oe,
|
|
337
|
-
link:
|
|
338
|
-
styled:
|
|
339
|
-
subscript:
|
|
266
|
+
link: ie,
|
|
267
|
+
styled: ne,
|
|
268
|
+
subscript: ae,
|
|
340
269
|
superscript: le,
|
|
341
|
-
anchor:
|
|
342
|
-
highlight:
|
|
343
|
-
textStyle:
|
|
270
|
+
anchor: ce,
|
|
271
|
+
highlight: he,
|
|
272
|
+
textStyle: ue
|
|
344
273
|
}
|
|
345
|
-
},
|
|
346
|
-
const
|
|
274
|
+
}, de = function(o) {
|
|
275
|
+
const e = {
|
|
347
276
|
"&": "&",
|
|
348
277
|
"<": "<",
|
|
349
278
|
">": ">",
|
|
350
279
|
'"': """,
|
|
351
280
|
"'": "'"
|
|
352
|
-
},
|
|
353
|
-
return
|
|
281
|
+
}, t = /[&<>"']/g, s = RegExp(t.source);
|
|
282
|
+
return o && s.test(o) ? o.replace(t, (r) => e[r]) : o;
|
|
354
283
|
};
|
|
355
|
-
class
|
|
356
|
-
constructor(
|
|
357
|
-
|
|
284
|
+
class k {
|
|
285
|
+
constructor(e) {
|
|
286
|
+
u(this, "marks"), u(this, "nodes"), e || (e = pe), this.marks = e.marks || [], this.nodes = e.nodes || [];
|
|
358
287
|
}
|
|
359
|
-
addNode(
|
|
360
|
-
this.nodes[
|
|
288
|
+
addNode(e, t) {
|
|
289
|
+
this.nodes[e] = t;
|
|
361
290
|
}
|
|
362
|
-
addMark(
|
|
363
|
-
this.marks[
|
|
291
|
+
addMark(e, t) {
|
|
292
|
+
this.marks[e] = t;
|
|
364
293
|
}
|
|
365
|
-
render(
|
|
366
|
-
if (
|
|
367
|
-
let
|
|
368
|
-
return
|
|
369
|
-
|
|
370
|
-
}),
|
|
294
|
+
render(e, t = { optimizeImages: !1 }) {
|
|
295
|
+
if (e && e.content && Array.isArray(e.content)) {
|
|
296
|
+
let s = "";
|
|
297
|
+
return e.content.forEach((r) => {
|
|
298
|
+
s += this.renderNode(r);
|
|
299
|
+
}), t.optimizeImages ? this.optimizeImages(s, t.optimizeImages) : s;
|
|
371
300
|
}
|
|
372
301
|
return console.warn(
|
|
373
302
|
`The render method must receive an Object with a "content" field.
|
|
@@ -396,201 +325,735 @@ class fe {
|
|
|
396
325
|
}`
|
|
397
326
|
), "";
|
|
398
327
|
}
|
|
399
|
-
optimizeImages(
|
|
400
|
-
let
|
|
401
|
-
typeof
|
|
402
|
-
const c =
|
|
403
|
-
return
|
|
328
|
+
optimizeImages(e, t) {
|
|
329
|
+
let s = 0, r = 0, i = "", n = "";
|
|
330
|
+
typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (i += `width="${t.width}" `, s = t.width), typeof t.height == "number" && t.height > 0 && (i += `height="${t.height}" `, r = t.height), (t.loading === "lazy" || t.loading === "eager") && (i += `loading="${t.loading}" `), typeof t.class == "string" && t.class.length > 0 && (i += `class="${t.class}" `), t.filters && (typeof t.filters.blur == "number" && t.filters.blur >= 0 && t.filters.blur <= 100 && (n += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (n += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-Fa-f]{6}/g) || t.filters.fill === "transparent") && (n += `:fill(${t.filters.fill})`), t.filters.format && ["webp", "png", "jpeg"].includes(t.filters.format) && (n += `:format(${t.filters.format})`), typeof t.filters.grayscale == "boolean" && t.filters.grayscale && (n += ":grayscale()"), typeof t.filters.quality == "number" && t.filters.quality >= 0 && t.filters.quality <= 100 && (n += `:quality(${t.filters.quality})`), t.filters.rotate && [90, 180, 270].includes(t.filters.rotate) && (n += `:rotate(${t.filters.rotate})`), n.length > 0 && (n = "/filters" + n))), i.length > 0 && (e = e.replace(/<img/g, `<img ${i.trim()}`));
|
|
331
|
+
const c = s > 0 || r > 0 || n.length > 0 ? `${s}x${r}${n}` : "";
|
|
332
|
+
return e = e.replace(
|
|
404
333
|
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,
|
|
405
334
|
`a.storyblok.com/f/$1/$2.$3/m/${c}`
|
|
406
|
-
), typeof
|
|
407
|
-
var
|
|
408
|
-
const
|
|
335
|
+
), typeof t != "boolean" && (t.sizes || t.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (a) => {
|
|
336
|
+
var l, h;
|
|
337
|
+
const p = a.match(
|
|
409
338
|
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g
|
|
410
339
|
);
|
|
411
|
-
if (
|
|
340
|
+
if (p && p.length > 0) {
|
|
412
341
|
const d = {
|
|
413
|
-
srcset: (
|
|
414
|
-
if (typeof
|
|
415
|
-
return `//${
|
|
416
|
-
if (typeof
|
|
417
|
-
let
|
|
418
|
-
return typeof
|
|
342
|
+
srcset: (l = t.srcset) == null ? void 0 : l.map((g) => {
|
|
343
|
+
if (typeof g == "number")
|
|
344
|
+
return `//${p}/m/${g}x0${n} ${g}w`;
|
|
345
|
+
if (typeof g == "object" && g.length === 2) {
|
|
346
|
+
let v = 0, I = 0;
|
|
347
|
+
return typeof g[0] == "number" && (v = g[0]), typeof g[1] == "number" && (I = g[1]), `//${p}/m/${v}x${I}${n} ${v}w`;
|
|
419
348
|
}
|
|
420
349
|
}).join(", "),
|
|
421
|
-
sizes: (
|
|
350
|
+
sizes: (h = t.sizes) == null ? void 0 : h.map((g) => g).join(", ")
|
|
422
351
|
};
|
|
423
|
-
let
|
|
424
|
-
return d.srcset && (
|
|
352
|
+
let f = "";
|
|
353
|
+
return d.srcset && (f += `srcset="${d.srcset}" `), d.sizes && (f += `sizes="${d.sizes}" `), a.replace(/<img/g, `<img ${f.trim()}`);
|
|
425
354
|
}
|
|
426
|
-
return
|
|
427
|
-
})),
|
|
428
|
-
}
|
|
429
|
-
renderNode(
|
|
430
|
-
const
|
|
431
|
-
|
|
432
|
-
const
|
|
433
|
-
|
|
355
|
+
return a;
|
|
356
|
+
})), e;
|
|
357
|
+
}
|
|
358
|
+
renderNode(e) {
|
|
359
|
+
const t = [];
|
|
360
|
+
e.marks && e.marks.forEach((r) => {
|
|
361
|
+
const i = this.getMatchingMark(r);
|
|
362
|
+
i && i.tag !== "" && t.push(this.renderOpeningTag(i.tag));
|
|
434
363
|
});
|
|
435
|
-
const
|
|
436
|
-
return
|
|
437
|
-
|
|
438
|
-
}) :
|
|
439
|
-
const
|
|
440
|
-
|
|
441
|
-
}),
|
|
442
|
-
}
|
|
443
|
-
renderTag(
|
|
444
|
-
return
|
|
445
|
-
if (
|
|
446
|
-
return `<${
|
|
364
|
+
const s = this.getMatchingNode(e);
|
|
365
|
+
return s && s.tag && t.push(this.renderOpeningTag(s.tag)), e.content ? e.content.forEach((r) => {
|
|
366
|
+
t.push(this.renderNode(r));
|
|
367
|
+
}) : e.text ? t.push(de(e.text)) : s && s.singleTag ? t.push(this.renderTag(s.singleTag, " /")) : s && s.html ? t.push(s.html) : e.type === "emoji" && t.push(this.renderEmoji(e)), s && s.tag && t.push(this.renderClosingTag(s.tag)), e.marks && e.marks.slice(0).reverse().forEach((r) => {
|
|
368
|
+
const i = this.getMatchingMark(r);
|
|
369
|
+
i && i.tag !== "" && t.push(this.renderClosingTag(i.tag));
|
|
370
|
+
}), t.join("");
|
|
371
|
+
}
|
|
372
|
+
renderTag(e, t) {
|
|
373
|
+
return e.constructor === String ? `<${e}${t}>` : e.map((s) => {
|
|
374
|
+
if (s.constructor === String)
|
|
375
|
+
return `<${s}${t}>`;
|
|
447
376
|
{
|
|
448
|
-
let
|
|
449
|
-
if (
|
|
450
|
-
for (const
|
|
451
|
-
const n =
|
|
452
|
-
n !== null && (
|
|
377
|
+
let r = `<${s.tag}`;
|
|
378
|
+
if (s.attrs)
|
|
379
|
+
for (const i in s.attrs) {
|
|
380
|
+
const n = s.attrs[i];
|
|
381
|
+
n !== null && (r += ` ${i}="${n}"`);
|
|
453
382
|
}
|
|
454
|
-
return `${
|
|
383
|
+
return `${r}${t}>`;
|
|
455
384
|
}
|
|
456
385
|
}).join("");
|
|
457
386
|
}
|
|
458
|
-
renderOpeningTag(
|
|
459
|
-
return this.renderTag(
|
|
387
|
+
renderOpeningTag(e) {
|
|
388
|
+
return this.renderTag(e, "");
|
|
460
389
|
}
|
|
461
|
-
renderClosingTag(
|
|
462
|
-
return
|
|
390
|
+
renderClosingTag(e) {
|
|
391
|
+
return e.constructor === String ? `</${e}>` : e.slice(0).reverse().map((t) => t.constructor === String ? `</${t}>` : `</${t.tag}>`).join("");
|
|
463
392
|
}
|
|
464
|
-
getMatchingNode(
|
|
465
|
-
const
|
|
466
|
-
if (typeof
|
|
467
|
-
return e
|
|
393
|
+
getMatchingNode(e) {
|
|
394
|
+
const t = this.nodes[e.type];
|
|
395
|
+
if (typeof t == "function")
|
|
396
|
+
return t(e);
|
|
468
397
|
}
|
|
469
|
-
getMatchingMark(
|
|
470
|
-
const
|
|
471
|
-
if (typeof
|
|
472
|
-
return e
|
|
398
|
+
getMatchingMark(e) {
|
|
399
|
+
const t = this.marks[e.type];
|
|
400
|
+
if (typeof t == "function")
|
|
401
|
+
return t(e);
|
|
473
402
|
}
|
|
474
|
-
renderEmoji(
|
|
475
|
-
if (
|
|
476
|
-
return
|
|
477
|
-
const
|
|
403
|
+
renderEmoji(e) {
|
|
404
|
+
if (e.attrs.emoji)
|
|
405
|
+
return e.attrs.emoji;
|
|
406
|
+
const t = [
|
|
478
407
|
{
|
|
479
408
|
tag: "img",
|
|
480
409
|
attrs: {
|
|
481
|
-
src:
|
|
410
|
+
src: e.attrs.fallbackImage,
|
|
482
411
|
draggable: "false",
|
|
483
412
|
loading: "lazy",
|
|
484
413
|
align: "absmiddle"
|
|
485
414
|
}
|
|
486
415
|
}
|
|
487
416
|
];
|
|
488
|
-
return this.renderTag(
|
|
417
|
+
return this.renderTag(t, " /");
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
class ge {
|
|
421
|
+
constructor(e) {
|
|
422
|
+
u(this, "baseURL"), u(this, "timeout"), u(this, "headers"), u(this, "responseInterceptor"), u(this, "fetch"), u(this, "ejectInterceptor"), u(this, "url"), u(this, "parameters"), u(this, "fetchOptions"), this.baseURL = e.baseURL, this.headers = e.headers || new Headers(), this.timeout = e != null && e.timeout ? e.timeout * 1e3 : 0, this.responseInterceptor = e.responseInterceptor, this.fetch = (...t) => e.fetch ? e.fetch(...t) : fetch(...t), this.ejectInterceptor = !1, this.url = "", this.parameters = {}, this.fetchOptions = {};
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
*
|
|
426
|
+
* @param url string
|
|
427
|
+
* @param params ISbStoriesParams
|
|
428
|
+
* @returns Promise<ISbResponse | Error>
|
|
429
|
+
*/
|
|
430
|
+
get(e, t) {
|
|
431
|
+
return this.url = e, this.parameters = t, this._methodHandler("get");
|
|
432
|
+
}
|
|
433
|
+
post(e, t) {
|
|
434
|
+
return this.url = e, this.parameters = t, this._methodHandler("post");
|
|
435
|
+
}
|
|
436
|
+
put(e, t) {
|
|
437
|
+
return this.url = e, this.parameters = t, this._methodHandler("put");
|
|
438
|
+
}
|
|
439
|
+
delete(e, t) {
|
|
440
|
+
return this.url = e, this.parameters = t, this._methodHandler("delete");
|
|
441
|
+
}
|
|
442
|
+
async _responseHandler(e) {
|
|
443
|
+
const t = [], s = {
|
|
444
|
+
data: {},
|
|
445
|
+
headers: {},
|
|
446
|
+
status: 0,
|
|
447
|
+
statusText: ""
|
|
448
|
+
};
|
|
449
|
+
e.status !== 204 && await e.json().then((r) => {
|
|
450
|
+
s.data = r;
|
|
451
|
+
});
|
|
452
|
+
for (const r of e.headers.entries())
|
|
453
|
+
t[r[0]] = r[1];
|
|
454
|
+
return s.headers = { ...t }, s.status = e.status, s.statusText = e.statusText, s;
|
|
455
|
+
}
|
|
456
|
+
async _methodHandler(e) {
|
|
457
|
+
let t = `${this.baseURL}${this.url}`, s = null;
|
|
458
|
+
if (e === "get") {
|
|
459
|
+
const a = new b();
|
|
460
|
+
t = `${this.baseURL}${this.url}?${a.stringify(
|
|
461
|
+
this.parameters
|
|
462
|
+
)}`;
|
|
463
|
+
} else
|
|
464
|
+
s = JSON.stringify(this.parameters);
|
|
465
|
+
const r = new URL(t), i = new AbortController(), { signal: n } = i;
|
|
466
|
+
let c;
|
|
467
|
+
this.timeout && (c = setTimeout(() => i.abort(), this.timeout));
|
|
468
|
+
try {
|
|
469
|
+
const a = await this.fetch(`${r}`, {
|
|
470
|
+
method: e,
|
|
471
|
+
headers: this.headers,
|
|
472
|
+
body: s,
|
|
473
|
+
signal: n,
|
|
474
|
+
...this.fetchOptions
|
|
475
|
+
});
|
|
476
|
+
this.timeout && clearTimeout(c);
|
|
477
|
+
const l = await this._responseHandler(
|
|
478
|
+
a
|
|
479
|
+
);
|
|
480
|
+
return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(l)) : this._statusHandler(l);
|
|
481
|
+
} catch (a) {
|
|
482
|
+
return {
|
|
483
|
+
message: a
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
setFetchOptions(e = {}) {
|
|
488
|
+
Object.keys(e).length > 0 && "method" in e && delete e.method, this.fetchOptions = { ...e };
|
|
489
|
+
}
|
|
490
|
+
eject() {
|
|
491
|
+
this.ejectInterceptor = !0;
|
|
492
|
+
}
|
|
493
|
+
_statusHandler(e) {
|
|
494
|
+
const t = /20[0-6]/g;
|
|
495
|
+
return new Promise((s, r) => {
|
|
496
|
+
if (t.test(`${e.status}`))
|
|
497
|
+
return s(e);
|
|
498
|
+
const i = {
|
|
499
|
+
message: e.statusText,
|
|
500
|
+
status: e.status,
|
|
501
|
+
response: Array.isArray(e.data) ? e.data[0] : e.data.error || e.data.slug
|
|
502
|
+
};
|
|
503
|
+
r(i);
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
const S = "SB-Agent", w = {
|
|
508
|
+
defaultAgentName: "SB-JS-CLIENT",
|
|
509
|
+
defaultAgentVersion: "SB-Agent-Version",
|
|
510
|
+
packageVersion: "6.0.0"
|
|
511
|
+
};
|
|
512
|
+
let y = {};
|
|
513
|
+
const m = {};
|
|
514
|
+
class fe {
|
|
515
|
+
/**
|
|
516
|
+
*
|
|
517
|
+
* @param config ISbConfig interface
|
|
518
|
+
* @param endpoint string, optional
|
|
519
|
+
*/
|
|
520
|
+
constructor(e, t) {
|
|
521
|
+
u(this, "client"), u(this, "maxRetries"), u(this, "throttle"), u(this, "accessToken"), u(this, "cache"), u(this, "helpers"), u(this, "resolveCounter"), u(this, "relations"), u(this, "links"), u(this, "richTextResolver"), u(this, "resolveNestedRelations"), u(this, "stringifiedStoriesCache");
|
|
522
|
+
let s = e.endpoint || t;
|
|
523
|
+
if (!s) {
|
|
524
|
+
const n = new b().getRegionURL, c = e.https === !1 ? "http" : "https";
|
|
525
|
+
e.oauthToken ? s = `${c}://${n(e.region)}/v1` : s = `${c}://${n(e.region)}/v2`;
|
|
526
|
+
}
|
|
527
|
+
const r = new Headers();
|
|
528
|
+
if (r.set("Content-Type", "application/json"), r.set("Accept", "application/json"), e.headers)
|
|
529
|
+
for (const n in e.headers)
|
|
530
|
+
r.set(n, e.headers[n]);
|
|
531
|
+
r.has(S) || (r.set(S, w.defaultAgentName), r.set(
|
|
532
|
+
w.defaultAgentVersion,
|
|
533
|
+
w.packageVersion
|
|
534
|
+
));
|
|
535
|
+
let i = 5;
|
|
536
|
+
e.oauthToken && (r.set("Authorization", e.oauthToken), i = 3), e.rateLimit && (i = e.rateLimit), e.richTextSchema ? this.richTextResolver = new k(e.richTextSchema) : this.richTextResolver = new k(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 5, this.throttle = z(this.throttledRequest, i, 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new b(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.client = new ge({
|
|
537
|
+
baseURL: s,
|
|
538
|
+
timeout: e.timeout || 0,
|
|
539
|
+
headers: r,
|
|
540
|
+
responseInterceptor: e.responseInterceptor,
|
|
541
|
+
fetch: e.fetch
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
setComponentResolver(e) {
|
|
545
|
+
this.richTextResolver.addNode("blok", (t) => {
|
|
546
|
+
let s = "";
|
|
547
|
+
return t.attrs.body && t.attrs.body.forEach((r) => {
|
|
548
|
+
s += e(r.component, r);
|
|
549
|
+
}), {
|
|
550
|
+
html: s
|
|
551
|
+
};
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
parseParams(e) {
|
|
555
|
+
return e.token || (e.token = this.getToken()), e.cv || (e.cv = m[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), typeof e.resolve_relations < "u" && (e.resolve_level = 2), e;
|
|
556
|
+
}
|
|
557
|
+
factoryParamOptions(e, t) {
|
|
558
|
+
return this.helpers.isCDNUrl(e) ? this.parseParams(t) : t;
|
|
559
|
+
}
|
|
560
|
+
makeRequest(e, t, s, r) {
|
|
561
|
+
const i = this.factoryParamOptions(
|
|
562
|
+
e,
|
|
563
|
+
this.helpers.getOptionsPage(t, s, r)
|
|
564
|
+
);
|
|
565
|
+
return this.cacheResponse(e, i);
|
|
566
|
+
}
|
|
567
|
+
get(e, t, s) {
|
|
568
|
+
t || (t = {});
|
|
569
|
+
const r = `/${e}`, i = this.factoryParamOptions(r, t);
|
|
570
|
+
return this.client.setFetchOptions(s), this.cacheResponse(r, i);
|
|
571
|
+
}
|
|
572
|
+
async getAll(e, t, s, r) {
|
|
573
|
+
const i = (t == null ? void 0 : t.per_page) || 25, n = `/${e}`, c = n.split("/"), a = s || c[c.length - 1], l = 1, h = await this.makeRequest(n, t, i, l), p = h.total ? Math.ceil(h.total / i) : 1;
|
|
574
|
+
this.client.setFetchOptions(r);
|
|
575
|
+
const d = await this.helpers.asyncMap(
|
|
576
|
+
this.helpers.range(l, p),
|
|
577
|
+
(f) => this.makeRequest(n, t, i, f + 1)
|
|
578
|
+
);
|
|
579
|
+
return this.helpers.flatMap(
|
|
580
|
+
[h, ...d],
|
|
581
|
+
(f) => Object.values(f.data[a])
|
|
582
|
+
);
|
|
583
|
+
}
|
|
584
|
+
post(e, t, s) {
|
|
585
|
+
const r = `/${e}`;
|
|
586
|
+
return this.client.setFetchOptions(s), Promise.resolve(this.throttle("post", r, t));
|
|
587
|
+
}
|
|
588
|
+
put(e, t, s) {
|
|
589
|
+
const r = `/${e}`;
|
|
590
|
+
return this.client.setFetchOptions(s), Promise.resolve(this.throttle("put", r, t));
|
|
591
|
+
}
|
|
592
|
+
delete(e, t, s) {
|
|
593
|
+
const r = `/${e}`;
|
|
594
|
+
return this.client.setFetchOptions(s), Promise.resolve(this.throttle("delete", r, t));
|
|
595
|
+
}
|
|
596
|
+
getStories(e, t) {
|
|
597
|
+
return this.client.setFetchOptions(t), this._addResolveLevel(e), this.get("cdn/stories", e);
|
|
598
|
+
}
|
|
599
|
+
getStory(e, t, s) {
|
|
600
|
+
return this.client.setFetchOptions(s), this._addResolveLevel(t), this.get(`cdn/stories/${e}`, t);
|
|
601
|
+
}
|
|
602
|
+
getToken() {
|
|
603
|
+
return this.accessToken;
|
|
604
|
+
}
|
|
605
|
+
ejectInterceptor() {
|
|
606
|
+
this.client.eject();
|
|
607
|
+
}
|
|
608
|
+
_addResolveLevel(e) {
|
|
609
|
+
typeof e.resolve_relations < "u" && (e.resolve_level = 2);
|
|
610
|
+
}
|
|
611
|
+
_cleanCopy(e) {
|
|
612
|
+
return JSON.parse(JSON.stringify(e));
|
|
613
|
+
}
|
|
614
|
+
_insertLinks(e, t, s) {
|
|
615
|
+
const r = e[t];
|
|
616
|
+
r && r.fieldtype == "multilink" && r.linktype == "story" && typeof r.id == "string" && this.links[s][r.id] ? r.story = this._cleanCopy(this.links[s][r.id]) : r && r.linktype === "story" && typeof r.uuid == "string" && this.links[s][r.uuid] && (r.story = this._cleanCopy(this.links[s][r.uuid]));
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
*
|
|
620
|
+
* @param resolveId A counter number as a string
|
|
621
|
+
* @param uuid The uuid of the story
|
|
622
|
+
* @returns string | object
|
|
623
|
+
*/
|
|
624
|
+
getStoryReference(e, t) {
|
|
625
|
+
return this.relations[e][t] ? (this.stringifiedStoriesCache[t] || (this.stringifiedStoriesCache[t] = JSON.stringify(
|
|
626
|
+
this.relations[e][t]
|
|
627
|
+
)), JSON.parse(this.stringifiedStoriesCache[t])) : t;
|
|
628
|
+
}
|
|
629
|
+
_insertRelations(e, t, s, r) {
|
|
630
|
+
s.indexOf(`${e.component}.${t}`) > -1 && (typeof e[t] == "string" ? e[t] = this.getStoryReference(r, e[t]) : Array.isArray(e[t]) && (e[t] = e[t].map((i) => this.getStoryReference(r, i)).filter(Boolean)));
|
|
631
|
+
}
|
|
632
|
+
iterateTree(e, t, s) {
|
|
633
|
+
const r = (i) => {
|
|
634
|
+
if (i != null) {
|
|
635
|
+
if (i.constructor === Array)
|
|
636
|
+
for (let n = 0; n < i.length; n++)
|
|
637
|
+
r(i[n]);
|
|
638
|
+
else if (i.constructor === Object) {
|
|
639
|
+
if (i._stopResolving)
|
|
640
|
+
return;
|
|
641
|
+
for (const n in i)
|
|
642
|
+
(i.component && i._uid || i.type === "link") && (this._insertRelations(
|
|
643
|
+
i,
|
|
644
|
+
n,
|
|
645
|
+
t,
|
|
646
|
+
s
|
|
647
|
+
), this._insertLinks(
|
|
648
|
+
i,
|
|
649
|
+
n,
|
|
650
|
+
s
|
|
651
|
+
)), r(i[n]);
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
};
|
|
655
|
+
r(e.content);
|
|
656
|
+
}
|
|
657
|
+
async resolveLinks(e, t, s) {
|
|
658
|
+
let r = [];
|
|
659
|
+
if (e.link_uuids) {
|
|
660
|
+
const i = e.link_uuids.length, n = [], c = 50;
|
|
661
|
+
for (let a = 0; a < i; a += c) {
|
|
662
|
+
const l = Math.min(i, a + c);
|
|
663
|
+
n.push(e.link_uuids.slice(a, l));
|
|
664
|
+
}
|
|
665
|
+
for (let a = 0; a < n.length; a++)
|
|
666
|
+
(await this.getStories({
|
|
667
|
+
per_page: c,
|
|
668
|
+
language: t.language,
|
|
669
|
+
version: t.version,
|
|
670
|
+
by_uuids: n[a].join(",")
|
|
671
|
+
})).data.stories.forEach(
|
|
672
|
+
(l) => {
|
|
673
|
+
r.push(l);
|
|
674
|
+
}
|
|
675
|
+
);
|
|
676
|
+
} else
|
|
677
|
+
r = e.links;
|
|
678
|
+
r.forEach((i) => {
|
|
679
|
+
this.links[s][i.uuid] = {
|
|
680
|
+
...i,
|
|
681
|
+
_stopResolving: !0
|
|
682
|
+
};
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
async resolveRelations(e, t, s) {
|
|
686
|
+
let r = [];
|
|
687
|
+
if (e.rel_uuids) {
|
|
688
|
+
const i = e.rel_uuids.length, n = [], c = 50;
|
|
689
|
+
for (let a = 0; a < i; a += c) {
|
|
690
|
+
const l = Math.min(i, a + c);
|
|
691
|
+
n.push(e.rel_uuids.slice(a, l));
|
|
692
|
+
}
|
|
693
|
+
for (let a = 0; a < n.length; a++)
|
|
694
|
+
(await this.getStories({
|
|
695
|
+
per_page: c,
|
|
696
|
+
language: t.language,
|
|
697
|
+
version: t.version,
|
|
698
|
+
by_uuids: n[a].join(","),
|
|
699
|
+
excluding_fields: t.excluding_fields
|
|
700
|
+
})).data.stories.forEach((l) => {
|
|
701
|
+
r.push(l);
|
|
702
|
+
});
|
|
703
|
+
} else
|
|
704
|
+
r = e.rels;
|
|
705
|
+
r && r.length > 0 && r.forEach((i) => {
|
|
706
|
+
this.relations[s][i.uuid] = {
|
|
707
|
+
...i,
|
|
708
|
+
_stopResolving: !0
|
|
709
|
+
};
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
/**
|
|
713
|
+
*
|
|
714
|
+
* @param responseData
|
|
715
|
+
* @param params
|
|
716
|
+
* @param resolveId
|
|
717
|
+
* @description Resolves the relations and links of the stories
|
|
718
|
+
* @returns Promise<void>
|
|
719
|
+
*
|
|
720
|
+
*/
|
|
721
|
+
async resolveStories(e, t, s) {
|
|
722
|
+
var r, i;
|
|
723
|
+
let n = [];
|
|
724
|
+
if (this.links[s] = {}, this.relations[s] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (n = t.resolve_relations.split(",")), await this.resolveRelations(e, t, s)), t.resolve_links && ["1", "story", "url", "link"].indexOf(t.resolve_links) > -1 && ((r = e.links) != null && r.length || (i = e.link_uuids) != null && i.length) && await this.resolveLinks(e, t, s), this.resolveNestedRelations)
|
|
725
|
+
for (const c in this.relations[s])
|
|
726
|
+
this.iterateTree(
|
|
727
|
+
this.relations[s][c],
|
|
728
|
+
n,
|
|
729
|
+
s
|
|
730
|
+
);
|
|
731
|
+
e.story ? this.iterateTree(e.story, n, s) : e.stories.forEach((c) => {
|
|
732
|
+
this.iterateTree(c, n, s);
|
|
733
|
+
}), this.stringifiedStoriesCache = {}, delete this.links[s], delete this.relations[s];
|
|
734
|
+
}
|
|
735
|
+
async cacheResponse(e, t, s) {
|
|
736
|
+
(typeof s > "u" || !s) && (s = 0);
|
|
737
|
+
const r = this.helpers.stringify({ url: e, params: t }), i = this.cacheProvider();
|
|
738
|
+
if (this.cache.clear === "auto" && t.version === "draft" && await this.flushCache(), t.version === "published" && e != "/cdn/spaces/me") {
|
|
739
|
+
const n = await i.get(r);
|
|
740
|
+
if (n)
|
|
741
|
+
return Promise.resolve(n);
|
|
742
|
+
}
|
|
743
|
+
return new Promise(async (n, c) => {
|
|
744
|
+
var a;
|
|
745
|
+
try {
|
|
746
|
+
const l = await this.throttle("get", e, t);
|
|
747
|
+
if (l.status !== 200)
|
|
748
|
+
return c(l);
|
|
749
|
+
let h = { data: l.data, headers: l.headers };
|
|
750
|
+
if ((a = l.headers) != null && a["per-page"] && (h = Object.assign({}, h, {
|
|
751
|
+
perPage: l.headers["per-page"] ? parseInt(l.headers["per-page"]) : 0,
|
|
752
|
+
total: l.headers["per-page"] ? parseInt(l.headers.total) : 0
|
|
753
|
+
})), h.data.story || h.data.stories) {
|
|
754
|
+
const p = this.resolveCounter = ++this.resolveCounter % 1e3;
|
|
755
|
+
await this.resolveStories(h.data, t, `${p}`);
|
|
756
|
+
}
|
|
757
|
+
return t.version === "published" && e != "/cdn/spaces/me" && await i.set(r, h), h.data.cv && t.token && (t.version === "draft" && m[t.token] != h.data.cv && await this.flushCache(), m[t.token] = t.cv ? t.cv : h.data.cv), n(h);
|
|
758
|
+
} catch (l) {
|
|
759
|
+
if (l.response && l.status === 429 && (s = s ? s + 1 : 0, s < this.maxRetries))
|
|
760
|
+
return console.log(`Hit rate limit. Retrying in ${s} seconds.`), await this.helpers.delay(1e3 * s), this.cacheResponse(e, t, s).then(n).catch(c);
|
|
761
|
+
c(l);
|
|
762
|
+
}
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
throttledRequest(e, t, s) {
|
|
766
|
+
return this.client[e](t, s);
|
|
767
|
+
}
|
|
768
|
+
cacheVersions() {
|
|
769
|
+
return m;
|
|
770
|
+
}
|
|
771
|
+
cacheVersion() {
|
|
772
|
+
return m[this.accessToken];
|
|
773
|
+
}
|
|
774
|
+
setCacheVersion(e) {
|
|
775
|
+
this.accessToken && (m[this.accessToken] = e);
|
|
776
|
+
}
|
|
777
|
+
cacheProvider() {
|
|
778
|
+
switch (this.cache.type) {
|
|
779
|
+
case "memory":
|
|
780
|
+
return {
|
|
781
|
+
get(e) {
|
|
782
|
+
return Promise.resolve(y[e]);
|
|
783
|
+
},
|
|
784
|
+
getAll() {
|
|
785
|
+
return Promise.resolve(y);
|
|
786
|
+
},
|
|
787
|
+
set(e, t) {
|
|
788
|
+
return y[e] = t, Promise.resolve(void 0);
|
|
789
|
+
},
|
|
790
|
+
flush() {
|
|
791
|
+
return y = {}, Promise.resolve(void 0);
|
|
792
|
+
}
|
|
793
|
+
};
|
|
794
|
+
case "custom":
|
|
795
|
+
if (this.cache.custom)
|
|
796
|
+
return this.cache.custom;
|
|
797
|
+
default:
|
|
798
|
+
return {
|
|
799
|
+
get() {
|
|
800
|
+
return Promise.resolve();
|
|
801
|
+
},
|
|
802
|
+
getAll() {
|
|
803
|
+
return Promise.resolve(void 0);
|
|
804
|
+
},
|
|
805
|
+
set() {
|
|
806
|
+
return Promise.resolve(void 0);
|
|
807
|
+
},
|
|
808
|
+
flush() {
|
|
809
|
+
return Promise.resolve(void 0);
|
|
810
|
+
}
|
|
811
|
+
};
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
async flushCache() {
|
|
815
|
+
return await this.cacheProvider().flush(), this;
|
|
489
816
|
}
|
|
490
817
|
}
|
|
491
|
-
const
|
|
492
|
-
|
|
818
|
+
const me = (o = {}) => {
|
|
819
|
+
const { apiOptions: e } = o;
|
|
820
|
+
if (!e.accessToken) {
|
|
821
|
+
console.error(
|
|
822
|
+
"You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication"
|
|
823
|
+
);
|
|
824
|
+
return;
|
|
825
|
+
}
|
|
826
|
+
return { storyblokApi: new fe(e) };
|
|
827
|
+
}, Se = (o) => {
|
|
828
|
+
if (typeof o != "object" || typeof o._editable > "u")
|
|
493
829
|
return {};
|
|
494
830
|
try {
|
|
495
|
-
const
|
|
496
|
-
|
|
831
|
+
const e = JSON.parse(
|
|
832
|
+
o._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
|
|
497
833
|
);
|
|
498
|
-
return
|
|
499
|
-
"data-blok-c": JSON.stringify(
|
|
500
|
-
"data-blok-uid":
|
|
834
|
+
return e ? {
|
|
835
|
+
"data-blok-c": JSON.stringify(e),
|
|
836
|
+
"data-blok-uid": e.id + "-" + e.uid
|
|
501
837
|
} : {};
|
|
502
838
|
} catch {
|
|
503
839
|
return {};
|
|
504
840
|
}
|
|
505
841
|
};
|
|
506
|
-
let
|
|
507
|
-
const
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
842
|
+
let $, R = "https://app.storyblok.com/f/storyblok-v2-latest.js";
|
|
843
|
+
const ye = (o = {}) => {
|
|
844
|
+
var e, t;
|
|
845
|
+
const {
|
|
846
|
+
bridge: s,
|
|
847
|
+
accessToken: r,
|
|
848
|
+
use: i = [],
|
|
849
|
+
apiOptions: n = {},
|
|
850
|
+
richText: c = {},
|
|
851
|
+
bridgeUrl: a
|
|
852
|
+
} = o;
|
|
853
|
+
n.accessToken = n.accessToken || r;
|
|
854
|
+
const l = { bridge: s, apiOptions: n };
|
|
855
|
+
let h = {};
|
|
856
|
+
i.forEach((d) => {
|
|
857
|
+
h = { ...h, ...d(l) };
|
|
858
|
+
}), a && (R = a);
|
|
859
|
+
const p = !(typeof window > "u") && ((t = (e = window.location) == null ? void 0 : e.search) == null ? void 0 : t.includes("_storyblok_tk"));
|
|
860
|
+
return s !== !1 && p && P(R), $ = new k(c.schema), c.resolver && L($, c.resolver), h;
|
|
861
|
+
}, L = (o, e) => {
|
|
862
|
+
o.addNode("blok", (t) => {
|
|
863
|
+
let s = "";
|
|
864
|
+
return t.attrs.body.forEach((r) => {
|
|
865
|
+
s += e(r.component, r);
|
|
512
866
|
}), {
|
|
513
|
-
html:
|
|
867
|
+
html: s
|
|
514
868
|
};
|
|
515
869
|
});
|
|
516
|
-
},
|
|
517
|
-
let
|
|
518
|
-
if (!
|
|
870
|
+
}, be = (o) => !o || !(o != null && o.content.some((e) => e.content || e.type === "blok" || e.type === "horizontal_rule")), ke = (o, e, t) => {
|
|
871
|
+
let s = t || $;
|
|
872
|
+
if (!s) {
|
|
519
873
|
console.error(
|
|
520
874
|
"Please initialize the Storyblok SDK before calling the renderRichText function"
|
|
521
875
|
);
|
|
522
876
|
return;
|
|
523
877
|
}
|
|
524
|
-
return
|
|
525
|
-
},
|
|
526
|
-
function ve() {
|
|
878
|
+
return be(o) ? "" : (e && (s = new k(e.schema), e.resolver && L(s, e.resolver)), s.render(o));
|
|
879
|
+
}, xe = () => P(R);
|
|
880
|
+
function ve(o, e, t) {
|
|
881
|
+
const s = "virtual:storyblok-init", r = "\0" + s;
|
|
882
|
+
return globalThis.apiPlugin = me, globalThis.storyblokInit = ye, {
|
|
883
|
+
name: "vite-plugin-storyblok-init",
|
|
884
|
+
async resolveId(i) {
|
|
885
|
+
if (i === s)
|
|
886
|
+
return r;
|
|
887
|
+
},
|
|
888
|
+
async load(i) {
|
|
889
|
+
if (i === r)
|
|
890
|
+
return `
|
|
891
|
+
const { storyblokApi } = globalThis.storyblokInit({
|
|
892
|
+
accessToken: "${o}",
|
|
893
|
+
use: ${e ? "[]" : "[globalThis.apiPlugin]"},
|
|
894
|
+
apiOptions: ${JSON.stringify(t)},
|
|
895
|
+
});
|
|
896
|
+
export const storyblokApiInstance = storyblokApi;
|
|
897
|
+
`;
|
|
898
|
+
}
|
|
899
|
+
};
|
|
900
|
+
}
|
|
901
|
+
const we = /[\p{Lu}]/u, $e = /[\p{Ll}]/u, x = /^[\p{Lu}](?![\p{Lu}])/gu, N = /([\p{Alpha}\p{N}_]|$)/u, T = /[_.\- ]+/, Re = new RegExp("^" + T.source), O = new RegExp(T.source + N.source, "gu"), E = new RegExp("\\d+" + N.source, "gu"), Te = (o, e, t, s) => {
|
|
902
|
+
let r = !1, i = !1, n = !1, c = !1;
|
|
903
|
+
for (let a = 0; a < o.length; a++) {
|
|
904
|
+
const l = o[a];
|
|
905
|
+
c = a > 2 ? o[a - 3] === "-" : !0, r && we.test(l) ? (o = o.slice(0, a) + "-" + o.slice(a), r = !1, n = i, i = !0, a++) : i && n && $e.test(l) && (!c || s) ? (o = o.slice(0, a - 1) + "-" + o.slice(a - 1), n = i, i = !1, r = !0) : (r = e(l) === l && t(l) !== l, n = i, i = t(l) === l && e(l) !== l);
|
|
906
|
+
}
|
|
907
|
+
return o;
|
|
908
|
+
}, Ie = (o, e) => (x.lastIndex = 0, o.replaceAll(x, (t) => e(t))), _e = (o, e) => (O.lastIndex = 0, E.lastIndex = 0, o.replaceAll(E, (t, s, r) => ["_", "-"].includes(o.charAt(r + t.length)) ? t : e(t)).replaceAll(O, (t, s) => e(s)));
|
|
909
|
+
function j(o, e) {
|
|
910
|
+
if (!(typeof o == "string" || Array.isArray(o)))
|
|
911
|
+
throw new TypeError("Expected the input to be `string | string[]`");
|
|
912
|
+
if (e = {
|
|
913
|
+
pascalCase: !1,
|
|
914
|
+
preserveConsecutiveUppercase: !1,
|
|
915
|
+
...e
|
|
916
|
+
}, Array.isArray(o) ? o = o.map((i) => i.trim()).filter((i) => i.length).join("-") : o = o.trim(), o.length === 0)
|
|
917
|
+
return "";
|
|
918
|
+
const t = e.locale === !1 ? (i) => i.toLowerCase() : (i) => i.toLocaleLowerCase(e.locale), s = e.locale === !1 ? (i) => i.toUpperCase() : (i) => i.toLocaleUpperCase(e.locale);
|
|
919
|
+
return o.length === 1 ? T.test(o) ? "" : e.pascalCase ? s(o) : t(o) : (o !== t(o) && (o = Te(o, t, s, e.preserveConsecutiveUppercase)), o = o.replace(Re, ""), o = e.preserveConsecutiveUppercase ? Ie(o, t) : t(o), e.pascalCase && (o = s(o.charAt(0)) + o.slice(1)), _e(o, s));
|
|
920
|
+
}
|
|
921
|
+
function Ce(o, e, t, s) {
|
|
922
|
+
const r = "virtual:storyblok-components", i = "\0" + r;
|
|
923
|
+
return {
|
|
924
|
+
name: "vite-plugin-storyblok-components",
|
|
925
|
+
async resolveId(n) {
|
|
926
|
+
if (n === r)
|
|
927
|
+
return i;
|
|
928
|
+
},
|
|
929
|
+
async load(n) {
|
|
930
|
+
if (n === i) {
|
|
931
|
+
const c = [], a = [];
|
|
932
|
+
for await (const [h, p] of Object.entries(e)) {
|
|
933
|
+
const d = await this.resolve(
|
|
934
|
+
"/" + o + "/" + p + ".astro"
|
|
935
|
+
);
|
|
936
|
+
if (d)
|
|
937
|
+
c.push(`import ${j(h)} from "${d.id}"`);
|
|
938
|
+
else if (t)
|
|
939
|
+
a.push(h);
|
|
940
|
+
else
|
|
941
|
+
throw new Error(
|
|
942
|
+
`Component could not be found for blok "${h}"! Does "${"/" + o + "/" + p}.astro" exist?`
|
|
943
|
+
);
|
|
944
|
+
}
|
|
945
|
+
let l = "";
|
|
946
|
+
if (t)
|
|
947
|
+
if (l = ",FallbackComponent", s) {
|
|
948
|
+
const h = await this.resolve(
|
|
949
|
+
"/" + o + "/" + s + ".astro"
|
|
950
|
+
);
|
|
951
|
+
if (!h)
|
|
952
|
+
throw new Error(
|
|
953
|
+
`Custom fallback component could not be found. Does "${"/" + o + "/" + s}.astro" exist?`
|
|
954
|
+
);
|
|
955
|
+
c.push(
|
|
956
|
+
`import FallbackComponent from "${h.id}"`
|
|
957
|
+
);
|
|
958
|
+
} else
|
|
959
|
+
c.push(
|
|
960
|
+
"import FallbackComponent from '@storyblok/astro/FallbackComponent.astro'"
|
|
961
|
+
);
|
|
962
|
+
if (Object.values(e).length)
|
|
963
|
+
return `${c.join(";")};export default {${Object.keys(e).filter((h) => !a.includes(h)).map((h) => j(h)).join(",")}${l}}`;
|
|
964
|
+
if (t)
|
|
965
|
+
return `${c[0]}; export default {${l.replace(",", "")}}`;
|
|
966
|
+
throw new Error(
|
|
967
|
+
`Currently, no Storyblok components are registered in astro.config.mjs.
|
|
968
|
+
Please register your components or enable the fallback component.
|
|
969
|
+
Detailed information can be found here: https://github.com/storyblok/storyblok-astro`
|
|
970
|
+
);
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
};
|
|
974
|
+
}
|
|
975
|
+
function Ae(o) {
|
|
976
|
+
const e = "virtual:storyblok-options", t = "\0" + e;
|
|
977
|
+
return {
|
|
978
|
+
name: "vite-plugin-storyblok-options",
|
|
979
|
+
async resolveId(s) {
|
|
980
|
+
if (s === e)
|
|
981
|
+
return t;
|
|
982
|
+
},
|
|
983
|
+
async load(s) {
|
|
984
|
+
if (s === t)
|
|
985
|
+
return `export default ${JSON.stringify(o)}`;
|
|
986
|
+
}
|
|
987
|
+
};
|
|
988
|
+
}
|
|
989
|
+
function Oe() {
|
|
527
990
|
return globalThis.storyblokApiInstance || console.error("storyblokApiInstance has not been initialized correctly"), globalThis.storyblokApiInstance;
|
|
528
991
|
}
|
|
529
|
-
function
|
|
530
|
-
const
|
|
531
|
-
if (!
|
|
992
|
+
function Ee(o, e) {
|
|
993
|
+
const t = globalThis.storyblokApiInstance.richTextResolver;
|
|
994
|
+
if (!t) {
|
|
532
995
|
console.error(
|
|
533
996
|
"Please initialize the Storyblok SDK before calling the renderRichText function"
|
|
534
997
|
);
|
|
535
998
|
return;
|
|
536
999
|
}
|
|
537
|
-
return
|
|
1000
|
+
return ke(o, e, t);
|
|
538
1001
|
}
|
|
539
|
-
function
|
|
540
|
-
const
|
|
1002
|
+
function je(o) {
|
|
1003
|
+
const e = {
|
|
541
1004
|
useCustomApi: !1,
|
|
542
1005
|
bridge: !0,
|
|
543
1006
|
componentsDir: "src",
|
|
544
1007
|
enableFallbackComponent: !1,
|
|
545
|
-
...
|
|
1008
|
+
...o
|
|
546
1009
|
};
|
|
547
1010
|
return {
|
|
548
1011
|
name: "@storyblok/astro",
|
|
549
1012
|
hooks: {
|
|
550
1013
|
"astro:config:setup": ({
|
|
551
|
-
injectScript:
|
|
552
|
-
updateConfig:
|
|
553
|
-
addDevToolbarApp:
|
|
1014
|
+
injectScript: t,
|
|
1015
|
+
updateConfig: s,
|
|
1016
|
+
addDevToolbarApp: r
|
|
554
1017
|
}) => {
|
|
555
|
-
if (
|
|
1018
|
+
if (s({
|
|
556
1019
|
vite: {
|
|
557
1020
|
plugins: [
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
1021
|
+
ve(
|
|
1022
|
+
e.accessToken,
|
|
1023
|
+
e.useCustomApi,
|
|
1024
|
+
e.apiOptions
|
|
562
1025
|
),
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
1026
|
+
Ce(
|
|
1027
|
+
e.componentsDir,
|
|
1028
|
+
e.components,
|
|
1029
|
+
e.enableFallbackComponent,
|
|
1030
|
+
e.customFallbackComponent
|
|
568
1031
|
),
|
|
569
|
-
|
|
1032
|
+
Ae(e)
|
|
570
1033
|
]
|
|
571
1034
|
}
|
|
572
|
-
}),
|
|
1035
|
+
}), t(
|
|
573
1036
|
"page-ssr",
|
|
574
1037
|
`
|
|
575
1038
|
import { storyblokApiInstance } from "virtual:storyblok-init";
|
|
576
1039
|
globalThis.storyblokApiInstance = storyblokApiInstance;
|
|
577
1040
|
`
|
|
578
|
-
),
|
|
579
|
-
let
|
|
580
|
-
if (typeof
|
|
581
|
-
const n = { ...
|
|
582
|
-
|
|
1041
|
+
), e.bridge) {
|
|
1042
|
+
let i = "";
|
|
1043
|
+
if (typeof e.bridge == "object") {
|
|
1044
|
+
const n = { ...e.bridge };
|
|
1045
|
+
i = `const storyblokInstance = new StoryblokBridge(${JSON.stringify(
|
|
583
1046
|
n
|
|
584
1047
|
)});`;
|
|
585
1048
|
} else
|
|
586
|
-
|
|
587
|
-
|
|
1049
|
+
i = "const storyblokInstance = new StoryblokBridge()";
|
|
1050
|
+
t(
|
|
588
1051
|
"page",
|
|
589
1052
|
`
|
|
590
1053
|
import { loadStoryblokBridge } from "@storyblok/astro";
|
|
591
1054
|
loadStoryblokBridge().then(() => {
|
|
592
1055
|
const { StoryblokBridge, location } = window;
|
|
593
|
-
${
|
|
1056
|
+
${i}
|
|
594
1057
|
|
|
595
1058
|
storyblokInstance.on(["published", "change"], (event) => {
|
|
596
1059
|
if (!event.slugChanged) {
|
|
@@ -601,17 +1064,17 @@ function we(r) {
|
|
|
601
1064
|
`
|
|
602
1065
|
);
|
|
603
1066
|
}
|
|
604
|
-
|
|
1067
|
+
r("@storyblok/astro/toolbar-app-storyblok.ts");
|
|
605
1068
|
}
|
|
606
1069
|
}
|
|
607
1070
|
};
|
|
608
1071
|
}
|
|
609
1072
|
export {
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
1073
|
+
k as RichTextResolver,
|
|
1074
|
+
pe as RichTextSchema,
|
|
1075
|
+
je as default,
|
|
1076
|
+
xe as loadStoryblokBridge,
|
|
1077
|
+
Ee as renderRichText,
|
|
1078
|
+
Se as storyblokEditable,
|
|
1079
|
+
Oe as useStoryblokApi
|
|
617
1080
|
};
|