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