@storyblok/vue 8.1.4 → 8.1.6
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-vue.js +25 -25
- package/dist/storyblok-vue.mjs +626 -560
- package/dist/types.d.ts +1 -1
- package/package.json +13 -13
package/dist/storyblok-vue.mjs
CHANGED
|
@@ -1,189 +1,193 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
let
|
|
3
|
-
const
|
|
1
|
+
import { defineComponent as G, ref as O, resolveDynamicComponent as N, inject as oe, openBlock as K, createBlock as J, mergeProps as ne, h as Y, createTextVNode as ie, watch as ae, onMounted as le, defineAsyncComponent as ce } from "vue";
|
|
2
|
+
let D = !1;
|
|
3
|
+
const z = [], he = (r) => new Promise((e, t) => {
|
|
4
4
|
if (typeof window > "u" || (window.storyblokRegisterEvent = (o) => {
|
|
5
5
|
if (window.location === window.parent.location) {
|
|
6
6
|
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
7
7
|
return;
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
D ? o() : z.push(o);
|
|
10
10
|
}, document.getElementById("storyblok-javascript-bridge"))) return;
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}, document.getElementsByTagName("head")[0].appendChild(
|
|
11
|
+
const s = document.createElement("script");
|
|
12
|
+
s.async = !0, s.src = r, s.id = "storyblok-javascript-bridge", s.onerror = (o) => t(o), s.onload = (o) => {
|
|
13
|
+
z.forEach((n) => n()), D = !0, e(o);
|
|
14
|
+
}, document.getElementsByTagName("head")[0].appendChild(s);
|
|
15
15
|
});
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
var ue = Object.defineProperty, de = (r, e, t) => e in r ? ue(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, p = (r, e, t) => de(r, typeof e != "symbol" ? e + "" : e, t);
|
|
17
|
+
class pe extends Error {
|
|
18
|
+
constructor(e) {
|
|
19
|
+
super(e), this.name = "AbortError";
|
|
20
|
+
}
|
|
19
21
|
}
|
|
20
|
-
function
|
|
21
|
-
if (!
|
|
22
|
+
function ge(r, e, t) {
|
|
23
|
+
if (!Number.isFinite(e))
|
|
22
24
|
throw new TypeError("Expected `limit` to be a finite number");
|
|
23
|
-
if (!
|
|
25
|
+
if (!Number.isFinite(t))
|
|
24
26
|
throw new TypeError("Expected `interval` to be a finite number");
|
|
25
|
-
const
|
|
26
|
-
let o = [], n = 0;
|
|
27
|
-
const
|
|
27
|
+
const s = [];
|
|
28
|
+
let o = [], n = 0, i = !1;
|
|
29
|
+
const a = async () => {
|
|
28
30
|
n++;
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
const h = s.shift();
|
|
32
|
+
if (h)
|
|
33
|
+
try {
|
|
34
|
+
const d = await r(...h.args);
|
|
35
|
+
h.resolve(d);
|
|
36
|
+
} catch (d) {
|
|
37
|
+
h.reject(d);
|
|
38
|
+
}
|
|
39
|
+
const u = setTimeout(() => {
|
|
40
|
+
n--, s.length > 0 && a(), o = o.filter((d) => d !== u);
|
|
33
41
|
}, t);
|
|
34
|
-
o.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
a.reject(function() {
|
|
51
|
-
Error.call(this, "Throttled function aborted"), this.name = "AbortError";
|
|
52
|
-
});
|
|
53
|
-
}), r.length = 0;
|
|
42
|
+
o.includes(u) || o.push(u);
|
|
43
|
+
}, l = (...h) => i ? Promise.reject(
|
|
44
|
+
new Error(
|
|
45
|
+
"Throttled function is already aborted and not accepting new promises"
|
|
46
|
+
)
|
|
47
|
+
) : new Promise((u, d) => {
|
|
48
|
+
s.push({
|
|
49
|
+
resolve: u,
|
|
50
|
+
reject: d,
|
|
51
|
+
args: h
|
|
52
|
+
}), n < e && a();
|
|
53
|
+
});
|
|
54
|
+
return l.abort = () => {
|
|
55
|
+
i = !0, o.forEach(clearTimeout), o = [], s.forEach(
|
|
56
|
+
(h) => h.reject(() => new pe("Throttle function aborted"))
|
|
57
|
+
), s.length = 0;
|
|
54
58
|
}, l;
|
|
55
59
|
}
|
|
56
|
-
class
|
|
60
|
+
let A = class {
|
|
57
61
|
constructor() {
|
|
58
|
-
|
|
59
|
-
...
|
|
60
|
-
per_page:
|
|
61
|
-
page:
|
|
62
|
-
})),
|
|
63
|
-
const
|
|
64
|
-
return this.arrayFrom(
|
|
65
|
-
}),
|
|
66
|
-
const
|
|
62
|
+
p(this, "isCDNUrl", (r = "") => r.includes("/cdn/")), p(this, "getOptionsPage", (r, e = 25, t = 1) => ({
|
|
63
|
+
...r,
|
|
64
|
+
per_page: e,
|
|
65
|
+
page: t
|
|
66
|
+
})), p(this, "delay", (r) => new Promise((e) => setTimeout(e, r))), p(this, "arrayFrom", (r = 0, e) => Array.from({ length: r }, e)), p(this, "range", (r = 0, e = r) => {
|
|
67
|
+
const t = Math.abs(e - r) || 0, s = r < e ? 1 : -1;
|
|
68
|
+
return this.arrayFrom(t, (o, n) => n * s + r);
|
|
69
|
+
}), p(this, "asyncMap", async (r, e) => Promise.all(r.map(e))), p(this, "flatMap", (r = [], e) => r.map(e).reduce((t, s) => [...t, ...s], [])), p(this, "escapeHTML", function(r) {
|
|
70
|
+
const e = {
|
|
67
71
|
"&": "&",
|
|
68
72
|
"<": "<",
|
|
69
73
|
">": ">",
|
|
70
74
|
'"': """,
|
|
71
75
|
"'": "'"
|
|
72
|
-
},
|
|
73
|
-
return
|
|
76
|
+
}, t = /[&<>"']/g, s = new RegExp(t.source);
|
|
77
|
+
return r && s.test(r) ? r.replace(t, (o) => e[o]) : r;
|
|
74
78
|
});
|
|
75
79
|
}
|
|
76
80
|
/**
|
|
77
81
|
* @method stringify
|
|
78
|
-
* @param {
|
|
79
|
-
* @param {
|
|
80
|
-
* @param {
|
|
81
|
-
* @return {
|
|
82
|
+
* @param {object} params
|
|
83
|
+
* @param {string} prefix
|
|
84
|
+
* @param {boolean} isArray
|
|
85
|
+
* @return {string} Stringified object
|
|
82
86
|
*/
|
|
83
|
-
stringify(e, t
|
|
84
|
-
const
|
|
85
|
-
for (const
|
|
86
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
87
|
+
stringify(r, e, t) {
|
|
88
|
+
const s = [];
|
|
89
|
+
for (const o in r) {
|
|
90
|
+
if (!Object.prototype.hasOwnProperty.call(r, o))
|
|
87
91
|
continue;
|
|
88
|
-
const
|
|
92
|
+
const n = r[o], i = t ? "" : encodeURIComponent(o);
|
|
89
93
|
let a;
|
|
90
|
-
typeof
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
Array.isArray(
|
|
94
|
-
) : a =
|
|
94
|
+
typeof n == "object" ? a = this.stringify(
|
|
95
|
+
n,
|
|
96
|
+
e ? e + encodeURIComponent(`[${i}]`) : i,
|
|
97
|
+
Array.isArray(n)
|
|
98
|
+
) : a = `${e ? e + encodeURIComponent(`[${i}]`) : i}=${encodeURIComponent(n)}`, s.push(a);
|
|
95
99
|
}
|
|
96
|
-
return
|
|
100
|
+
return s.join("&");
|
|
97
101
|
}
|
|
98
102
|
/**
|
|
99
103
|
* @method getRegionURL
|
|
100
|
-
* @param {
|
|
101
|
-
* @return {
|
|
104
|
+
* @param {string} regionCode region code, could be eu, us, cn, ap or ca
|
|
105
|
+
* @return {string} The base URL of the region
|
|
102
106
|
*/
|
|
103
|
-
getRegionURL(
|
|
104
|
-
const
|
|
105
|
-
switch (
|
|
107
|
+
getRegionURL(r) {
|
|
108
|
+
const e = "api.storyblok.com", t = "api-us.storyblok.com", s = "app.storyblokchina.cn", o = "api-ap.storyblok.com", n = "api-ca.storyblok.com";
|
|
109
|
+
switch (r) {
|
|
106
110
|
case "us":
|
|
107
|
-
return
|
|
111
|
+
return t;
|
|
108
112
|
case "cn":
|
|
109
|
-
return
|
|
113
|
+
return s;
|
|
110
114
|
case "ap":
|
|
111
|
-
return
|
|
115
|
+
return o;
|
|
112
116
|
case "ca":
|
|
113
|
-
return
|
|
117
|
+
return n;
|
|
114
118
|
default:
|
|
115
|
-
return
|
|
119
|
+
return e;
|
|
116
120
|
}
|
|
117
121
|
}
|
|
118
|
-
}
|
|
119
|
-
const
|
|
122
|
+
};
|
|
123
|
+
const me = function(r, e) {
|
|
120
124
|
const t = {};
|
|
121
|
-
for (const
|
|
122
|
-
const o = s
|
|
123
|
-
e.
|
|
125
|
+
for (const s in r) {
|
|
126
|
+
const o = r[s];
|
|
127
|
+
e.includes(s) && o !== null && (t[s] = o);
|
|
124
128
|
}
|
|
125
129
|
return t;
|
|
126
|
-
},
|
|
130
|
+
}, fe = (r) => r === "email", ye = () => ({
|
|
127
131
|
singleTag: "hr"
|
|
128
|
-
}),
|
|
132
|
+
}), be = () => ({
|
|
129
133
|
tag: "blockquote"
|
|
130
|
-
}),
|
|
134
|
+
}), ke = () => ({
|
|
131
135
|
tag: "ul"
|
|
132
|
-
}),
|
|
136
|
+
}), ve = (r) => ({
|
|
133
137
|
tag: [
|
|
134
138
|
"pre",
|
|
135
139
|
{
|
|
136
140
|
tag: "code",
|
|
137
|
-
attrs:
|
|
141
|
+
attrs: r.attrs
|
|
138
142
|
}
|
|
139
143
|
]
|
|
140
|
-
}),
|
|
144
|
+
}), $e = () => ({
|
|
141
145
|
singleTag: "br"
|
|
142
|
-
}),
|
|
143
|
-
tag: `h${
|
|
144
|
-
}),
|
|
146
|
+
}), Te = (r) => ({
|
|
147
|
+
tag: `h${r.attrs.level}`
|
|
148
|
+
}), we = (r) => ({
|
|
145
149
|
singleTag: [
|
|
146
150
|
{
|
|
147
151
|
tag: "img",
|
|
148
|
-
attrs:
|
|
152
|
+
attrs: me(r.attrs, ["src", "alt", "title"])
|
|
149
153
|
}
|
|
150
154
|
]
|
|
151
|
-
}),
|
|
155
|
+
}), Re = () => ({
|
|
152
156
|
tag: "li"
|
|
153
|
-
}),
|
|
157
|
+
}), Se = () => ({
|
|
154
158
|
tag: "ol"
|
|
155
|
-
}),
|
|
159
|
+
}), _e = () => ({
|
|
156
160
|
tag: "p"
|
|
157
|
-
}),
|
|
161
|
+
}), Ee = (r) => ({
|
|
158
162
|
tag: [
|
|
159
163
|
{
|
|
160
164
|
tag: "span",
|
|
161
165
|
attrs: {
|
|
162
166
|
"data-type": "emoji",
|
|
163
|
-
"data-name":
|
|
164
|
-
emoji:
|
|
167
|
+
"data-name": r.attrs.name,
|
|
168
|
+
emoji: r.attrs.emoji
|
|
165
169
|
}
|
|
166
170
|
}
|
|
167
171
|
]
|
|
168
|
-
}),
|
|
172
|
+
}), je = () => ({
|
|
169
173
|
tag: "b"
|
|
170
|
-
}),
|
|
174
|
+
}), Ie = () => ({
|
|
171
175
|
tag: "s"
|
|
172
|
-
}),
|
|
176
|
+
}), xe = () => ({
|
|
173
177
|
tag: "u"
|
|
174
|
-
}),
|
|
178
|
+
}), Ce = () => ({
|
|
175
179
|
tag: "strong"
|
|
176
|
-
}),
|
|
180
|
+
}), Oe = () => ({
|
|
177
181
|
tag: "code"
|
|
178
|
-
}),
|
|
182
|
+
}), Ae = () => ({
|
|
179
183
|
tag: "i"
|
|
180
|
-
}),
|
|
181
|
-
if (!
|
|
184
|
+
}), Le = (r) => {
|
|
185
|
+
if (!r.attrs)
|
|
182
186
|
return {
|
|
183
187
|
tag: ""
|
|
184
188
|
};
|
|
185
|
-
const e = new
|
|
186
|
-
if (delete t.linktype, t.href && (t.href = e(
|
|
189
|
+
const e = new A().escapeHTML, t = { ...r.attrs }, { linktype: s = "url" } = r.attrs;
|
|
190
|
+
if (delete t.linktype, t.href && (t.href = e(r.attrs.href || "")), fe(s) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), t.custom) {
|
|
187
191
|
for (const o in t.custom)
|
|
188
192
|
t[o] = t.custom[o];
|
|
189
193
|
delete t.custom;
|
|
@@ -196,95 +200,95 @@ const he = function(s, e) {
|
|
|
196
200
|
}
|
|
197
201
|
]
|
|
198
202
|
};
|
|
199
|
-
},
|
|
203
|
+
}, Pe = (r) => ({
|
|
200
204
|
tag: [
|
|
201
205
|
{
|
|
202
206
|
tag: "span",
|
|
203
|
-
attrs:
|
|
207
|
+
attrs: r.attrs
|
|
204
208
|
}
|
|
205
209
|
]
|
|
206
|
-
}),
|
|
210
|
+
}), Ne = () => ({
|
|
207
211
|
tag: "sub"
|
|
208
|
-
}),
|
|
212
|
+
}), Me = () => ({
|
|
209
213
|
tag: "sup"
|
|
210
|
-
}),
|
|
214
|
+
}), He = (r) => ({
|
|
211
215
|
tag: [
|
|
212
216
|
{
|
|
213
217
|
tag: "span",
|
|
214
|
-
attrs:
|
|
218
|
+
attrs: r.attrs
|
|
215
219
|
}
|
|
216
220
|
]
|
|
217
|
-
}),
|
|
221
|
+
}), Ue = (r) => {
|
|
218
222
|
var e;
|
|
219
|
-
return (e =
|
|
223
|
+
return (e = r.attrs) != null && e.color ? {
|
|
220
224
|
tag: [
|
|
221
225
|
{
|
|
222
226
|
tag: "span",
|
|
223
227
|
attrs: {
|
|
224
|
-
style: `background-color:${
|
|
228
|
+
style: `background-color:${r.attrs.color};`
|
|
225
229
|
}
|
|
226
230
|
}
|
|
227
231
|
]
|
|
228
232
|
} : {
|
|
229
233
|
tag: ""
|
|
230
234
|
};
|
|
231
|
-
},
|
|
235
|
+
}, De = (r) => {
|
|
232
236
|
var e;
|
|
233
|
-
return (e =
|
|
237
|
+
return (e = r.attrs) != null && e.color ? {
|
|
234
238
|
tag: [
|
|
235
239
|
{
|
|
236
240
|
tag: "span",
|
|
237
241
|
attrs: {
|
|
238
|
-
style: `color:${
|
|
242
|
+
style: `color:${r.attrs.color}`
|
|
239
243
|
}
|
|
240
244
|
}
|
|
241
245
|
]
|
|
242
246
|
} : {
|
|
243
247
|
tag: ""
|
|
244
248
|
};
|
|
245
|
-
},
|
|
249
|
+
}, ze = {
|
|
246
250
|
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:
|
|
251
|
+
horizontal_rule: ye,
|
|
252
|
+
blockquote: be,
|
|
253
|
+
bullet_list: ke,
|
|
254
|
+
code_block: ve,
|
|
255
|
+
hard_break: $e,
|
|
256
|
+
heading: Te,
|
|
257
|
+
image: we,
|
|
258
|
+
list_item: Re,
|
|
259
|
+
ordered_list: Se,
|
|
260
|
+
paragraph: _e,
|
|
261
|
+
emoji: Ee
|
|
258
262
|
},
|
|
259
263
|
marks: {
|
|
260
|
-
bold:
|
|
261
|
-
strike:
|
|
262
|
-
underline:
|
|
263
|
-
strong:
|
|
264
|
-
code:
|
|
265
|
-
italic:
|
|
266
|
-
link:
|
|
267
|
-
styled:
|
|
268
|
-
subscript:
|
|
269
|
-
superscript:
|
|
270
|
-
anchor:
|
|
271
|
-
highlight:
|
|
272
|
-
textStyle:
|
|
273
|
-
}
|
|
274
|
-
},
|
|
264
|
+
bold: je,
|
|
265
|
+
strike: Ie,
|
|
266
|
+
underline: xe,
|
|
267
|
+
strong: Ce,
|
|
268
|
+
code: Oe,
|
|
269
|
+
italic: Ae,
|
|
270
|
+
link: Le,
|
|
271
|
+
styled: Pe,
|
|
272
|
+
subscript: Ne,
|
|
273
|
+
superscript: Me,
|
|
274
|
+
anchor: He,
|
|
275
|
+
highlight: Ue,
|
|
276
|
+
textStyle: De
|
|
277
|
+
}
|
|
278
|
+
}, Be = function(r) {
|
|
275
279
|
const e = {
|
|
276
280
|
"&": "&",
|
|
277
281
|
"<": "<",
|
|
278
282
|
">": ">",
|
|
279
283
|
'"': """,
|
|
280
284
|
"'": "'"
|
|
281
|
-
}, t = /[&<>"']/g,
|
|
282
|
-
return
|
|
285
|
+
}, t = /[&<>"']/g, s = new RegExp(t.source);
|
|
286
|
+
return r && s.test(r) ? r.replace(t, (o) => e[o]) : r;
|
|
283
287
|
};
|
|
284
|
-
let
|
|
285
|
-
class
|
|
288
|
+
let B = !1;
|
|
289
|
+
class qe {
|
|
286
290
|
constructor(e) {
|
|
287
|
-
|
|
291
|
+
p(this, "marks"), p(this, "nodes"), e || (e = ze), this.marks = e.marks || [], this.nodes = e.nodes || [];
|
|
288
292
|
}
|
|
289
293
|
addNode(e, t) {
|
|
290
294
|
this.nodes[e] = t;
|
|
@@ -292,10 +296,10 @@ class He {
|
|
|
292
296
|
addMark(e, t) {
|
|
293
297
|
this.marks[e] = t;
|
|
294
298
|
}
|
|
295
|
-
render(e, t = { optimizeImages: !1 },
|
|
296
|
-
if (!
|
|
299
|
+
render(e, t = { optimizeImages: !1 }, s = !0) {
|
|
300
|
+
if (!B && s && (console.warn(
|
|
297
301
|
"Warning ⚠️: The RichTextResolver class is deprecated and will be removed in the next major release. Please use the `@storyblok/richtext` package instead. https://github.com/storyblok/richtext/"
|
|
298
|
-
),
|
|
302
|
+
), B = !0), e && e.content && Array.isArray(e.content)) {
|
|
299
303
|
let o = "";
|
|
300
304
|
return e.content.forEach((n) => {
|
|
301
305
|
o += this.renderNode(n);
|
|
@@ -303,59 +307,60 @@ class He {
|
|
|
303
307
|
}
|
|
304
308
|
return console.warn(
|
|
305
309
|
`The render method must receive an Object with a "content" field.
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
310
|
+
The "content" field must be an array of nodes as the type ISbRichtext.
|
|
311
|
+
ISbRichtext:
|
|
312
|
+
content?: ISbRichtext[]
|
|
313
|
+
marks?: ISbRichtext[]
|
|
314
|
+
attrs?: any
|
|
315
|
+
text?: string
|
|
316
|
+
type: string
|
|
317
|
+
|
|
318
|
+
Example:
|
|
319
|
+
{
|
|
320
|
+
content: [
|
|
321
|
+
{
|
|
322
|
+
content: [
|
|
323
|
+
{
|
|
324
|
+
text: 'Hello World',
|
|
325
|
+
type: 'text'
|
|
326
|
+
}
|
|
327
|
+
],
|
|
328
|
+
type: 'paragraph'
|
|
329
|
+
}
|
|
330
|
+
],
|
|
331
|
+
type: 'doc'
|
|
332
|
+
}`
|
|
329
333
|
), "";
|
|
330
334
|
}
|
|
331
335
|
optimizeImages(e, t) {
|
|
332
|
-
let
|
|
333
|
-
typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (n += `width="${t.width}" `,
|
|
334
|
-
const
|
|
336
|
+
let s = 0, o = 0, n = "", i = "";
|
|
337
|
+
typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (n += `width="${t.width}" `, s = t.width), typeof t.height == "number" && t.height > 0 && (n += `height="${t.height}" `, o = t.height), (t.loading === "lazy" || t.loading === "eager") && (n += `loading="${t.loading}" `), typeof t.class == "string" && t.class.length > 0 && (n += `class="${t.class}" `), t.filters && (typeof t.filters.blur == "number" && t.filters.blur >= 0 && t.filters.blur <= 100 && (i += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (i += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-F]{6}/gi) || t.filters.fill === "transparent") && (i += `:fill(${t.filters.fill})`), t.filters.format && ["webp", "png", "jpeg"].includes(t.filters.format) && (i += `:format(${t.filters.format})`), typeof t.filters.grayscale == "boolean" && t.filters.grayscale && (i += ":grayscale()"), typeof t.filters.quality == "number" && t.filters.quality >= 0 && t.filters.quality <= 100 && (i += `:quality(${t.filters.quality})`), t.filters.rotate && [90, 180, 270].includes(t.filters.rotate) && (i += `:rotate(${t.filters.rotate})`), i.length > 0 && (i = `/filters${i}`))), n.length > 0 && (e = e.replace(/<img/g, `<img ${n.trim()}`));
|
|
338
|
+
const a = s > 0 || o > 0 || i.length > 0 ? `${s}x${o}${i}` : "";
|
|
335
339
|
return e = e.replace(
|
|
336
|
-
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|
|
|
337
|
-
`a.storyblok.com/f/$1/$2.$3/m/${
|
|
338
|
-
), typeof t != "boolean" && (t.sizes || t.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (
|
|
339
|
-
var
|
|
340
|
-
const
|
|
341
|
-
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|
|
|
340
|
+
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g,
|
|
341
|
+
`a.storyblok.com/f/$1/$2.$3/m/${a}`
|
|
342
|
+
), typeof t != "boolean" && (t.sizes || t.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (l) => {
|
|
343
|
+
var h, u;
|
|
344
|
+
const d = l.match(
|
|
345
|
+
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g
|
|
342
346
|
);
|
|
343
|
-
if (
|
|
344
|
-
const
|
|
345
|
-
srcset: (
|
|
347
|
+
if (d && d.length > 0) {
|
|
348
|
+
const g = {
|
|
349
|
+
srcset: (h = t.srcset) == null ? void 0 : h.map((y) => {
|
|
346
350
|
if (typeof y == "number")
|
|
347
|
-
return `//${
|
|
351
|
+
return `//${d}/m/${y}x0${i} ${y}w`;
|
|
348
352
|
if (typeof y == "object" && y.length === 2) {
|
|
349
353
|
let w = 0, x = 0;
|
|
350
|
-
return typeof y[0] == "number" && (w = y[0]), typeof y[1] == "number" && (x = y[1]), `//${
|
|
354
|
+
return typeof y[0] == "number" && (w = y[0]), typeof y[1] == "number" && (x = y[1]), `//${d}/m/${w}x${x}${i} ${w}w`;
|
|
351
355
|
}
|
|
356
|
+
return "";
|
|
352
357
|
}).join(", "),
|
|
353
|
-
sizes: (
|
|
358
|
+
sizes: (u = t.sizes) == null ? void 0 : u.map((y) => y).join(", ")
|
|
354
359
|
};
|
|
355
|
-
let
|
|
356
|
-
return
|
|
360
|
+
let R = "";
|
|
361
|
+
return g.srcset && (R += `srcset="${g.srcset}" `), g.sizes && (R += `sizes="${g.sizes}" `), l.replace(/<img/g, `<img ${R.trim()}`);
|
|
357
362
|
}
|
|
358
|
-
return
|
|
363
|
+
return l;
|
|
359
364
|
})), e;
|
|
360
365
|
}
|
|
361
366
|
renderNode(e) {
|
|
@@ -364,24 +369,24 @@ class He {
|
|
|
364
369
|
const n = this.getMatchingMark(o);
|
|
365
370
|
n && n.tag !== "" && t.push(this.renderOpeningTag(n.tag));
|
|
366
371
|
});
|
|
367
|
-
const
|
|
368
|
-
return
|
|
372
|
+
const s = this.getMatchingNode(e);
|
|
373
|
+
return s && s.tag && t.push(this.renderOpeningTag(s.tag)), e.content ? e.content.forEach((o) => {
|
|
369
374
|
t.push(this.renderNode(o));
|
|
370
|
-
}) : e.text ? t.push(
|
|
375
|
+
}) : e.text ? t.push(Be(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((o) => {
|
|
371
376
|
const n = this.getMatchingMark(o);
|
|
372
377
|
n && n.tag !== "" && t.push(this.renderClosingTag(n.tag));
|
|
373
378
|
}), t.join("");
|
|
374
379
|
}
|
|
375
380
|
renderTag(e, t) {
|
|
376
|
-
return e.constructor === String ? `<${e}${t}>` : e.map((
|
|
377
|
-
if (
|
|
378
|
-
return `<${
|
|
381
|
+
return e.constructor === String ? `<${e}${t}>` : e.map((s) => {
|
|
382
|
+
if (s.constructor === String)
|
|
383
|
+
return `<${s}${t}>`;
|
|
379
384
|
{
|
|
380
|
-
let o = `<${
|
|
381
|
-
if (
|
|
382
|
-
for (const n in
|
|
383
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
384
|
-
const i =
|
|
385
|
+
let o = `<${s.tag}`;
|
|
386
|
+
if (s.attrs) {
|
|
387
|
+
for (const n in s.attrs)
|
|
388
|
+
if (Object.prototype.hasOwnProperty.call(s.attrs, n)) {
|
|
389
|
+
const i = s.attrs[n];
|
|
385
390
|
i !== null && (o += ` ${n}="${i}"`);
|
|
386
391
|
}
|
|
387
392
|
}
|
|
@@ -422,10 +427,10 @@ class He {
|
|
|
422
427
|
return this.renderTag(t, " /");
|
|
423
428
|
}
|
|
424
429
|
}
|
|
425
|
-
const
|
|
426
|
-
class
|
|
430
|
+
const L = qe;
|
|
431
|
+
class Fe {
|
|
427
432
|
constructor(e) {
|
|
428
|
-
|
|
433
|
+
p(this, "baseURL"), p(this, "timeout"), p(this, "headers"), p(this, "responseInterceptor"), p(this, "fetch"), p(this, "ejectInterceptor"), p(this, "url"), p(this, "parameters"), p(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 = {};
|
|
429
434
|
}
|
|
430
435
|
/**
|
|
431
436
|
*
|
|
@@ -446,47 +451,47 @@ class Ue {
|
|
|
446
451
|
return this.url = e, this.parameters = t, this._methodHandler("delete");
|
|
447
452
|
}
|
|
448
453
|
async _responseHandler(e) {
|
|
449
|
-
const t = [],
|
|
454
|
+
const t = [], s = {
|
|
450
455
|
data: {},
|
|
451
456
|
headers: {},
|
|
452
457
|
status: 0,
|
|
453
458
|
statusText: ""
|
|
454
459
|
};
|
|
455
460
|
e.status !== 204 && await e.json().then((o) => {
|
|
456
|
-
|
|
461
|
+
s.data = o;
|
|
457
462
|
});
|
|
458
463
|
for (const o of e.headers.entries())
|
|
459
464
|
t[o[0]] = o[1];
|
|
460
|
-
return
|
|
465
|
+
return s.headers = { ...t }, s.status = e.status, s.statusText = e.statusText, s;
|
|
461
466
|
}
|
|
462
467
|
async _methodHandler(e) {
|
|
463
|
-
let t = `${this.baseURL}${this.url}`,
|
|
468
|
+
let t = `${this.baseURL}${this.url}`, s = null;
|
|
464
469
|
if (e === "get") {
|
|
465
|
-
const
|
|
466
|
-
t = `${this.baseURL}${this.url}?${
|
|
470
|
+
const l = new A();
|
|
471
|
+
t = `${this.baseURL}${this.url}?${l.stringify(
|
|
467
472
|
this.parameters
|
|
468
473
|
)}`;
|
|
469
474
|
} else
|
|
470
|
-
|
|
475
|
+
s = JSON.stringify(this.parameters);
|
|
471
476
|
const o = new URL(t), n = new AbortController(), { signal: i } = n;
|
|
472
|
-
let
|
|
473
|
-
this.timeout && (
|
|
477
|
+
let a;
|
|
478
|
+
this.timeout && (a = setTimeout(() => n.abort(), this.timeout));
|
|
474
479
|
try {
|
|
475
|
-
const
|
|
480
|
+
const l = await this.fetch(`${o}`, {
|
|
476
481
|
method: e,
|
|
477
482
|
headers: this.headers,
|
|
478
|
-
body:
|
|
483
|
+
body: s,
|
|
479
484
|
signal: i,
|
|
480
485
|
...this.fetchOptions
|
|
481
486
|
});
|
|
482
|
-
this.timeout && clearTimeout(
|
|
483
|
-
const
|
|
484
|
-
|
|
487
|
+
this.timeout && clearTimeout(a);
|
|
488
|
+
const h = await this._responseHandler(
|
|
489
|
+
l
|
|
485
490
|
);
|
|
486
|
-
return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(
|
|
487
|
-
} catch (
|
|
491
|
+
return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(h)) : this._statusHandler(h);
|
|
492
|
+
} catch (l) {
|
|
488
493
|
return {
|
|
489
|
-
message:
|
|
494
|
+
message: l
|
|
490
495
|
};
|
|
491
496
|
}
|
|
492
497
|
}
|
|
@@ -498,9 +503,9 @@ class Ue {
|
|
|
498
503
|
}
|
|
499
504
|
_statusHandler(e) {
|
|
500
505
|
const t = /20[0-6]/g;
|
|
501
|
-
return new Promise((
|
|
506
|
+
return new Promise((s, o) => {
|
|
502
507
|
if (t.test(`${e.status}`))
|
|
503
|
-
return
|
|
508
|
+
return s(e);
|
|
504
509
|
const n = {
|
|
505
510
|
message: e.statusText,
|
|
506
511
|
status: e.status,
|
|
@@ -510,36 +515,40 @@ class Ue {
|
|
|
510
515
|
});
|
|
511
516
|
}
|
|
512
517
|
}
|
|
513
|
-
const
|
|
518
|
+
const Ve = Fe, q = "SB-Agent", M = {
|
|
514
519
|
defaultAgentName: "SB-JS-CLIENT",
|
|
515
520
|
defaultAgentVersion: "SB-Agent-Version",
|
|
516
521
|
packageVersion: "6.0.0"
|
|
517
522
|
};
|
|
518
|
-
let
|
|
519
|
-
const
|
|
520
|
-
class
|
|
523
|
+
let C = {};
|
|
524
|
+
const E = {};
|
|
525
|
+
class Ge {
|
|
521
526
|
/**
|
|
522
527
|
*
|
|
523
528
|
* @param config ISbConfig interface
|
|
524
|
-
* @param
|
|
529
|
+
* @param pEndpoint string, optional
|
|
525
530
|
*/
|
|
526
531
|
constructor(e, t) {
|
|
527
|
-
|
|
528
|
-
let
|
|
529
|
-
if (!
|
|
530
|
-
const i = new
|
|
531
|
-
e.oauthToken ?
|
|
532
|
+
p(this, "client"), p(this, "maxRetries"), p(this, "retriesDelay"), p(this, "throttle"), p(this, "accessToken"), p(this, "cache"), p(this, "helpers"), p(this, "resolveCounter"), p(this, "relations"), p(this, "links"), p(this, "richTextResolver"), p(this, "resolveNestedRelations"), p(this, "stringifiedStoriesCache");
|
|
533
|
+
let s = e.endpoint || t;
|
|
534
|
+
if (!s) {
|
|
535
|
+
const i = new A().getRegionURL, a = e.https === !1 ? "http" : "https";
|
|
536
|
+
e.oauthToken ? s = `${a}://${i(e.region)}/v1` : s = `${a}://${i(e.region)}/v2`;
|
|
532
537
|
}
|
|
533
538
|
const o = new Headers();
|
|
534
|
-
o.set("Content-Type", "application/json"), o.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([i,
|
|
535
|
-
o.set(i,
|
|
536
|
-
}), o.has(
|
|
537
|
-
|
|
538
|
-
|
|
539
|
+
o.set("Content-Type", "application/json"), o.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([i, a]) => {
|
|
540
|
+
o.set(i, a);
|
|
541
|
+
}), o.has(q) || (o.set(q, M.defaultAgentName), o.set(
|
|
542
|
+
M.defaultAgentVersion,
|
|
543
|
+
M.packageVersion
|
|
539
544
|
));
|
|
540
545
|
let n = 5;
|
|
541
|
-
e.oauthToken && (o.set("Authorization", e.oauthToken), n = 3), e.rateLimit && (n = e.rateLimit), e.richTextSchema ? this.richTextResolver = new
|
|
542
|
-
|
|
546
|
+
e.oauthToken && (o.set("Authorization", e.oauthToken), n = 3), e.rateLimit && (n = e.rateLimit), e.richTextSchema ? this.richTextResolver = new L(e.richTextSchema) : this.richTextResolver = new L(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = ge(
|
|
547
|
+
this.throttledRequest.bind(this),
|
|
548
|
+
n,
|
|
549
|
+
1e3
|
|
550
|
+
), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new A(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.client = new Ve({
|
|
551
|
+
baseURL: s,
|
|
543
552
|
timeout: e.timeout || 0,
|
|
544
553
|
headers: o,
|
|
545
554
|
responseInterceptor: e.responseInterceptor,
|
|
@@ -548,65 +557,68 @@ class ze {
|
|
|
548
557
|
}
|
|
549
558
|
setComponentResolver(e) {
|
|
550
559
|
this.richTextResolver.addNode("blok", (t) => {
|
|
551
|
-
let
|
|
560
|
+
let s = "";
|
|
552
561
|
return t.attrs.body && t.attrs.body.forEach((o) => {
|
|
553
|
-
|
|
562
|
+
s += e(o.component, o);
|
|
554
563
|
}), {
|
|
555
|
-
html:
|
|
564
|
+
html: s
|
|
556
565
|
};
|
|
557
566
|
});
|
|
558
567
|
}
|
|
559
568
|
parseParams(e) {
|
|
560
|
-
return e.token || (e.token = this.getToken()), e.cv || (e.cv =
|
|
569
|
+
return e.token || (e.token = this.getToken()), e.cv || (e.cv = E[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), typeof e.resolve_relations < "u" && (e.resolve_level = 2), e;
|
|
561
570
|
}
|
|
562
571
|
factoryParamOptions(e, t) {
|
|
563
572
|
return this.helpers.isCDNUrl(e) ? this.parseParams(t) : t;
|
|
564
573
|
}
|
|
565
|
-
makeRequest(e, t,
|
|
574
|
+
makeRequest(e, t, s, o, n) {
|
|
566
575
|
const i = this.factoryParamOptions(
|
|
567
576
|
e,
|
|
568
|
-
this.helpers.getOptionsPage(t,
|
|
577
|
+
this.helpers.getOptionsPage(t, s, o)
|
|
569
578
|
);
|
|
570
579
|
return this.cacheResponse(e, i, void 0, n);
|
|
571
580
|
}
|
|
572
|
-
get(e, t,
|
|
581
|
+
get(e, t, s) {
|
|
573
582
|
t || (t = {});
|
|
574
583
|
const o = `/${e}`, n = this.factoryParamOptions(o, t);
|
|
575
|
-
return this.cacheResponse(o, n, void 0,
|
|
584
|
+
return this.cacheResponse(o, n, void 0, s);
|
|
576
585
|
}
|
|
577
|
-
async getAll(e, t,
|
|
578
|
-
const n = (t == null ? void 0 : t.per_page) || 25, i = `/${e}
|
|
586
|
+
async getAll(e, t, s, o) {
|
|
587
|
+
const n = (t == null ? void 0 : t.per_page) || 25, i = `/${e}`.replace(/\/$/, ""), a = s ?? i.substring(i.lastIndexOf("/") + 1), l = 1, h = await this.makeRequest(
|
|
579
588
|
i,
|
|
580
589
|
t,
|
|
581
590
|
n,
|
|
582
|
-
|
|
591
|
+
l,
|
|
583
592
|
o
|
|
584
|
-
),
|
|
585
|
-
this.helpers.range(
|
|
586
|
-
(
|
|
587
|
-
);
|
|
588
|
-
return this.helpers.flatMap(
|
|
589
|
-
[p, ...m],
|
|
590
|
-
($) => Object.values($.data[a])
|
|
593
|
+
), u = h.total ? Math.ceil(h.total / n) : 1, d = await this.helpers.asyncMap(
|
|
594
|
+
this.helpers.range(l, u),
|
|
595
|
+
(g) => this.makeRequest(i, t, n, g + 1, o)
|
|
591
596
|
);
|
|
597
|
+
return this.helpers.flatMap([h, ...d], (g) => Object.values(g.data[a]));
|
|
592
598
|
}
|
|
593
|
-
post(e, t,
|
|
599
|
+
post(e, t, s) {
|
|
594
600
|
const o = `/${e}`;
|
|
595
|
-
return Promise.resolve(
|
|
601
|
+
return Promise.resolve(
|
|
602
|
+
this.throttle("post", o, t, s)
|
|
603
|
+
);
|
|
596
604
|
}
|
|
597
|
-
put(e, t,
|
|
605
|
+
put(e, t, s) {
|
|
598
606
|
const o = `/${e}`;
|
|
599
|
-
return Promise.resolve(
|
|
607
|
+
return Promise.resolve(
|
|
608
|
+
this.throttle("put", o, t, s)
|
|
609
|
+
);
|
|
600
610
|
}
|
|
601
|
-
delete(e, t,
|
|
611
|
+
delete(e, t, s) {
|
|
602
612
|
const o = `/${e}`;
|
|
603
|
-
return Promise.resolve(
|
|
613
|
+
return Promise.resolve(
|
|
614
|
+
this.throttle("delete", o, t, s)
|
|
615
|
+
);
|
|
604
616
|
}
|
|
605
617
|
getStories(e, t) {
|
|
606
618
|
return this._addResolveLevel(e), this.get("cdn/stories", e, t);
|
|
607
619
|
}
|
|
608
|
-
getStory(e, t,
|
|
609
|
-
return this._addResolveLevel(t), this.get(`cdn/stories/${e}`, t,
|
|
620
|
+
getStory(e, t, s) {
|
|
621
|
+
return this._addResolveLevel(t), this.get(`cdn/stories/${e}`, t, s);
|
|
610
622
|
}
|
|
611
623
|
getToken() {
|
|
612
624
|
return this.accessToken;
|
|
@@ -620,9 +632,9 @@ class ze {
|
|
|
620
632
|
_cleanCopy(e) {
|
|
621
633
|
return JSON.parse(JSON.stringify(e));
|
|
622
634
|
}
|
|
623
|
-
_insertLinks(e, t,
|
|
635
|
+
_insertLinks(e, t, s) {
|
|
624
636
|
const o = e[t];
|
|
625
|
-
o && o.fieldtype
|
|
637
|
+
o && o.fieldtype === "multilink" && o.linktype === "story" && typeof o.id == "string" && this.links[s][o.id] ? o.story = this._cleanCopy(this.links[s][o.id]) : o && o.linktype === "story" && typeof o.uuid == "string" && this.links[s][o.uuid] && (o.story = this._cleanCopy(this.links[s][o.uuid]));
|
|
626
638
|
}
|
|
627
639
|
/**
|
|
628
640
|
*
|
|
@@ -635,10 +647,10 @@ class ze {
|
|
|
635
647
|
this.relations[e][t]
|
|
636
648
|
)), JSON.parse(this.stringifiedStoriesCache[t])) : t;
|
|
637
649
|
}
|
|
638
|
-
_insertRelations(e, t,
|
|
639
|
-
|
|
650
|
+
_insertRelations(e, t, s, o) {
|
|
651
|
+
s.includes(`${e.component}.${t}`) && (typeof e[t] == "string" ? e[t] = this.getStoryReference(o, e[t]) : Array.isArray(e[t]) && (e[t] = e[t].map((n) => this.getStoryReference(o, n)).filter(Boolean)));
|
|
640
652
|
}
|
|
641
|
-
iterateTree(e, t,
|
|
653
|
+
iterateTree(e, t, s) {
|
|
642
654
|
const o = (n) => {
|
|
643
655
|
if (n != null) {
|
|
644
656
|
if (n.constructor === Array)
|
|
@@ -652,67 +664,67 @@ class ze {
|
|
|
652
664
|
n,
|
|
653
665
|
i,
|
|
654
666
|
t,
|
|
655
|
-
|
|
667
|
+
s
|
|
656
668
|
), this._insertLinks(
|
|
657
669
|
n,
|
|
658
670
|
i,
|
|
659
|
-
|
|
671
|
+
s
|
|
660
672
|
)), o(n[i]);
|
|
661
673
|
}
|
|
662
674
|
}
|
|
663
675
|
};
|
|
664
676
|
o(e.content);
|
|
665
677
|
}
|
|
666
|
-
async resolveLinks(e, t,
|
|
678
|
+
async resolveLinks(e, t, s) {
|
|
667
679
|
let o = [];
|
|
668
680
|
if (e.link_uuids) {
|
|
669
|
-
const n = e.link_uuids.length, i = [],
|
|
670
|
-
for (let
|
|
671
|
-
const
|
|
672
|
-
i.push(e.link_uuids.slice(
|
|
681
|
+
const n = e.link_uuids.length, i = [], a = 50;
|
|
682
|
+
for (let l = 0; l < n; l += a) {
|
|
683
|
+
const h = Math.min(n, l + a);
|
|
684
|
+
i.push(e.link_uuids.slice(l, h));
|
|
673
685
|
}
|
|
674
|
-
for (let
|
|
686
|
+
for (let l = 0; l < i.length; l++)
|
|
675
687
|
(await this.getStories({
|
|
676
|
-
per_page:
|
|
688
|
+
per_page: a,
|
|
677
689
|
language: t.language,
|
|
678
690
|
version: t.version,
|
|
679
|
-
by_uuids: i[
|
|
691
|
+
by_uuids: i[l].join(",")
|
|
680
692
|
})).data.stories.forEach(
|
|
681
|
-
(
|
|
682
|
-
o.push(
|
|
693
|
+
(h) => {
|
|
694
|
+
o.push(h);
|
|
683
695
|
}
|
|
684
696
|
);
|
|
685
697
|
} else
|
|
686
698
|
o = e.links;
|
|
687
699
|
o.forEach((n) => {
|
|
688
|
-
this.links[
|
|
700
|
+
this.links[s][n.uuid] = {
|
|
689
701
|
...n,
|
|
690
702
|
_stopResolving: !0
|
|
691
703
|
};
|
|
692
704
|
});
|
|
693
705
|
}
|
|
694
|
-
async resolveRelations(e, t,
|
|
706
|
+
async resolveRelations(e, t, s) {
|
|
695
707
|
let o = [];
|
|
696
708
|
if (e.rel_uuids) {
|
|
697
|
-
const n = e.rel_uuids.length, i = [],
|
|
698
|
-
for (let
|
|
699
|
-
const
|
|
700
|
-
i.push(e.rel_uuids.slice(
|
|
709
|
+
const n = e.rel_uuids.length, i = [], a = 50;
|
|
710
|
+
for (let l = 0; l < n; l += a) {
|
|
711
|
+
const h = Math.min(n, l + a);
|
|
712
|
+
i.push(e.rel_uuids.slice(l, h));
|
|
701
713
|
}
|
|
702
|
-
for (let
|
|
714
|
+
for (let l = 0; l < i.length; l++)
|
|
703
715
|
(await this.getStories({
|
|
704
|
-
per_page:
|
|
716
|
+
per_page: a,
|
|
705
717
|
language: t.language,
|
|
706
718
|
version: t.version,
|
|
707
|
-
by_uuids: i[
|
|
719
|
+
by_uuids: i[l].join(","),
|
|
708
720
|
excluding_fields: t.excluding_fields
|
|
709
|
-
})).data.stories.forEach((
|
|
710
|
-
o.push(
|
|
721
|
+
})).data.stories.forEach((h) => {
|
|
722
|
+
o.push(h);
|
|
711
723
|
});
|
|
712
724
|
} else
|
|
713
725
|
o = e.rels;
|
|
714
726
|
o && o.length > 0 && o.forEach((n) => {
|
|
715
|
-
this.relations[
|
|
727
|
+
this.relations[s][n.uuid] = {
|
|
716
728
|
...n,
|
|
717
729
|
_stopResolving: !0
|
|
718
730
|
};
|
|
@@ -727,85 +739,91 @@ class ze {
|
|
|
727
739
|
* @returns Promise<void>
|
|
728
740
|
*
|
|
729
741
|
*/
|
|
730
|
-
async resolveStories(e, t,
|
|
742
|
+
async resolveStories(e, t, s) {
|
|
731
743
|
var o, n;
|
|
732
744
|
let i = [];
|
|
733
|
-
if (this.links[
|
|
734
|
-
for (const
|
|
745
|
+
if (this.links[s] = {}, this.relations[s] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (i = t.resolve_relations.split(",")), await this.resolveRelations(e, t, s)), t.resolve_links && ["1", "story", "url", "link"].includes(t.resolve_links) && ((o = e.links) != null && o.length || (n = e.link_uuids) != null && n.length) && await this.resolveLinks(e, t, s), this.resolveNestedRelations)
|
|
746
|
+
for (const a in this.relations[s])
|
|
735
747
|
this.iterateTree(
|
|
736
|
-
this.relations[
|
|
748
|
+
this.relations[s][a],
|
|
737
749
|
i,
|
|
738
|
-
|
|
750
|
+
s
|
|
739
751
|
);
|
|
740
|
-
e.story ? this.iterateTree(e.story, i,
|
|
741
|
-
this.iterateTree(
|
|
742
|
-
}), this.stringifiedStoriesCache = {}, delete this.links[
|
|
752
|
+
e.story ? this.iterateTree(e.story, i, s) : e.stories.forEach((a) => {
|
|
753
|
+
this.iterateTree(a, i, s);
|
|
754
|
+
}), this.stringifiedStoriesCache = {}, delete this.links[s], delete this.relations[s];
|
|
743
755
|
}
|
|
744
|
-
async cacheResponse(e, t,
|
|
756
|
+
async cacheResponse(e, t, s, o) {
|
|
745
757
|
const n = this.helpers.stringify({ url: e, params: t }), i = this.cacheProvider();
|
|
746
|
-
if (this.cache.clear === "auto" && t.version === "draft" && await this.flushCache(), t.version === "published" && e
|
|
747
|
-
const
|
|
748
|
-
if (
|
|
749
|
-
return Promise.resolve(
|
|
758
|
+
if (this.cache.clear === "auto" && t.version === "draft" && await this.flushCache(), t.version === "published" && e !== "/cdn/spaces/me") {
|
|
759
|
+
const a = await i.get(n);
|
|
760
|
+
if (a)
|
|
761
|
+
return Promise.resolve(a);
|
|
750
762
|
}
|
|
751
|
-
return new Promise(async (
|
|
752
|
-
var
|
|
763
|
+
return new Promise(async (a, l) => {
|
|
764
|
+
var h;
|
|
753
765
|
try {
|
|
754
|
-
const
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
766
|
+
const u = await this.throttle(
|
|
767
|
+
"get",
|
|
768
|
+
e,
|
|
769
|
+
t,
|
|
770
|
+
o
|
|
771
|
+
);
|
|
772
|
+
if (u.status !== 200)
|
|
773
|
+
return l(u);
|
|
774
|
+
let d = { data: u.data, headers: u.headers };
|
|
775
|
+
if ((h = u.headers) != null && h["per-page"] && (d = Object.assign({}, d, {
|
|
776
|
+
perPage: u.headers["per-page"] ? Number.parseInt(u.headers["per-page"]) : 0,
|
|
777
|
+
total: u.headers["per-page"] ? Number.parseInt(u.headers.total) : 0
|
|
778
|
+
})), d.data.story || d.data.stories) {
|
|
779
|
+
const g = this.resolveCounter = ++this.resolveCounter % 1e3;
|
|
780
|
+
await this.resolveStories(d.data, t, `${g}`);
|
|
764
781
|
}
|
|
765
|
-
return t.version === "published" && e
|
|
766
|
-
} catch (
|
|
767
|
-
if (
|
|
782
|
+
return t.version === "published" && e !== "/cdn/spaces/me" && await i.set(n, d), d.data.cv && t.token && E[t.token] !== d.data.cv && (await this.flushCache(), E[t.token] = d.data.cv), a(d);
|
|
783
|
+
} catch (u) {
|
|
784
|
+
if (u.response && u.status === 429 && (s = typeof s > "u" ? 0 : s + 1, s < this.maxRetries))
|
|
768
785
|
return console.log(
|
|
769
786
|
`Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`
|
|
770
|
-
), await this.helpers.delay(this.retriesDelay), this.cacheResponse(e, t,
|
|
771
|
-
|
|
787
|
+
), await this.helpers.delay(this.retriesDelay), this.cacheResponse(e, t, s).then(a).catch(l);
|
|
788
|
+
l(u);
|
|
772
789
|
}
|
|
773
790
|
});
|
|
774
791
|
}
|
|
775
|
-
throttledRequest(e, t,
|
|
776
|
-
return this.client.setFetchOptions(o), this.client[e](t,
|
|
792
|
+
throttledRequest(e, t, s, o) {
|
|
793
|
+
return this.client.setFetchOptions(o), this.client[e](t, s);
|
|
777
794
|
}
|
|
778
795
|
cacheVersions() {
|
|
779
|
-
return
|
|
796
|
+
return E;
|
|
780
797
|
}
|
|
781
798
|
cacheVersion() {
|
|
782
|
-
return
|
|
799
|
+
return E[this.accessToken];
|
|
783
800
|
}
|
|
784
801
|
setCacheVersion(e) {
|
|
785
|
-
this.accessToken && (
|
|
802
|
+
this.accessToken && (E[this.accessToken] = e);
|
|
786
803
|
}
|
|
787
804
|
clearCacheVersion() {
|
|
788
|
-
this.accessToken && (
|
|
805
|
+
this.accessToken && (E[this.accessToken] = 0);
|
|
789
806
|
}
|
|
790
807
|
cacheProvider() {
|
|
791
808
|
switch (this.cache.type) {
|
|
792
809
|
case "memory":
|
|
793
810
|
return {
|
|
794
811
|
get(e) {
|
|
795
|
-
return Promise.resolve(
|
|
812
|
+
return Promise.resolve(C[e]);
|
|
796
813
|
},
|
|
797
814
|
getAll() {
|
|
798
|
-
return Promise.resolve(
|
|
815
|
+
return Promise.resolve(C);
|
|
799
816
|
},
|
|
800
817
|
set(e, t) {
|
|
801
|
-
return
|
|
818
|
+
return C[e] = t, Promise.resolve(void 0);
|
|
802
819
|
},
|
|
803
820
|
flush() {
|
|
804
|
-
return
|
|
821
|
+
return C = {}, Promise.resolve(void 0);
|
|
805
822
|
}
|
|
806
823
|
};
|
|
807
824
|
case "custom":
|
|
808
|
-
if (this.cache.custom)
|
|
825
|
+
if (this.cache.custom)
|
|
826
|
+
return this.cache.custom;
|
|
809
827
|
default:
|
|
810
828
|
return {
|
|
811
829
|
get() {
|
|
@@ -827,21 +845,21 @@ class ze {
|
|
|
827
845
|
return await this.cacheProvider().flush(), this.clearCacheVersion(), this;
|
|
828
846
|
}
|
|
829
847
|
}
|
|
830
|
-
const
|
|
831
|
-
const { apiOptions: e } =
|
|
848
|
+
const ct = (r = {}) => {
|
|
849
|
+
const { apiOptions: e } = r;
|
|
832
850
|
if (!e.accessToken) {
|
|
833
851
|
console.error(
|
|
834
852
|
"You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication"
|
|
835
853
|
);
|
|
836
854
|
return;
|
|
837
855
|
}
|
|
838
|
-
return { storyblokApi: new
|
|
839
|
-
},
|
|
840
|
-
if (typeof
|
|
856
|
+
return { storyblokApi: new Ge(e) };
|
|
857
|
+
}, Ke = (r) => {
|
|
858
|
+
if (typeof r != "object" || typeof r._editable > "u")
|
|
841
859
|
return {};
|
|
842
860
|
try {
|
|
843
861
|
const e = JSON.parse(
|
|
844
|
-
|
|
862
|
+
r._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
|
|
845
863
|
);
|
|
846
864
|
return e ? {
|
|
847
865
|
"data-blok-c": JSON.stringify(e),
|
|
@@ -851,325 +869,373 @@ const st = (s = {}) => {
|
|
|
851
869
|
return {};
|
|
852
870
|
}
|
|
853
871
|
};
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
let t = 0,
|
|
872
|
+
function Je(r, e) {
|
|
873
|
+
if (!e)
|
|
874
|
+
return { src: r, attrs: {} };
|
|
875
|
+
let t = 0, s = 0;
|
|
858
876
|
const o = {}, n = [];
|
|
859
|
-
function i(
|
|
860
|
-
typeof
|
|
877
|
+
function i(l, h, u, d, g) {
|
|
878
|
+
typeof l != "number" || l <= h || l >= u ? console.warn(`[StoryblokRichText] - ${d.charAt(0).toUpperCase() + d.slice(1)} value must be a number between ${h} and ${u} (inclusive)`) : g.push(`${d}(${l})`);
|
|
861
879
|
}
|
|
862
880
|
if (typeof e == "object") {
|
|
863
|
-
if (typeof e.width == "number" && e.width > 0 ? (o.width = e.width, t = e.width) : console.warn("[StoryblokRichText] - Width value must be a number greater than 0"), e.height && typeof e.height == "number" && e.height > 0 ? (o.height = e.height,
|
|
864
|
-
const { filters:
|
|
865
|
-
|
|
881
|
+
if (typeof e.width == "number" && e.width > 0 ? (o.width = e.width, t = e.width) : console.warn("[StoryblokRichText] - Width value must be a number greater than 0"), e.height && typeof e.height == "number" && e.height > 0 ? (o.height = e.height, s = e.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than 0"), e.loading && ["lazy", "eager"].includes(e.loading) && (o.loading = e.loading), e.class && (o.class = e.class), e.filters) {
|
|
882
|
+
const { filters: l } = e || {}, { blur: h, brightness: u, fill: d, format: g, grayscale: R, quality: y, rotate: w } = l || {};
|
|
883
|
+
h && i(h, 0, 100, "blur", n), y && i(y, 0, 100, "quality", n), u && i(u, 0, 100, "brightness", n), d && n.push(`fill(${d})`), R && n.push("grayscale()"), w && [0, 90, 180, 270].includes(e.filters.rotate || 0) && n.push(`rotate(${w})`), g && ["webp", "png", "jpeg"].includes(g) && n.push(`format(${g})`);
|
|
866
884
|
}
|
|
867
|
-
e.srcset && (o.srcset = e.srcset.map((
|
|
868
|
-
if (typeof
|
|
869
|
-
return `${
|
|
870
|
-
if (Array.isArray(
|
|
871
|
-
const [
|
|
872
|
-
return `${
|
|
885
|
+
e.srcset && (o.srcset = e.srcset.map((l) => {
|
|
886
|
+
if (typeof l == "number")
|
|
887
|
+
return `${r}/m/${l}x0/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${l}w`;
|
|
888
|
+
if (Array.isArray(l) && l.length === 2) {
|
|
889
|
+
const [h, u] = l;
|
|
890
|
+
return `${r}/m/${h}x${u}/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${h}w`;
|
|
891
|
+
} else {
|
|
892
|
+
console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
|
|
893
|
+
return;
|
|
873
894
|
}
|
|
874
895
|
}).join(", ")), e.sizes && (o.sizes = e.sizes.join(", "));
|
|
875
896
|
}
|
|
876
|
-
let
|
|
877
|
-
return t > 0 &&
|
|
878
|
-
src:
|
|
897
|
+
let a = `${r}/m/`;
|
|
898
|
+
return t > 0 && s > 0 && (a = `${a}${t}x${s}/`), n.length > 0 && (a = `${a}filters:${n.join(":")}`), {
|
|
899
|
+
src: a,
|
|
879
900
|
attrs: o
|
|
880
901
|
};
|
|
881
902
|
}
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
903
|
+
var k = /* @__PURE__ */ ((r) => (r.DOCUMENT = "doc", r.HEADING = "heading", r.PARAGRAPH = "paragraph", r.QUOTE = "blockquote", r.OL_LIST = "ordered_list", r.UL_LIST = "bullet_list", r.LIST_ITEM = "list_item", r.CODE_BLOCK = "code_block", r.HR = "horizontal_rule", r.BR = "hard_break", r.IMAGE = "image", r.EMOJI = "emoji", r.COMPONENT = "blok", r))(k || {}), v = /* @__PURE__ */ ((r) => (r.BOLD = "bold", r.STRONG = "strong", r.STRIKE = "strike", r.UNDERLINE = "underline", r.ITALIC = "italic", r.CODE = "code", r.LINK = "link", r.ANCHOR = "anchor", r.STYLED = "styled", r.SUPERSCRIPT = "superscript", r.SUBSCRIPT = "subscript", r.TEXT_STYLE = "textStyle", r.HIGHLIGHT = "highlight", r))(v || {}), X = /* @__PURE__ */ ((r) => (r.TEXT = "text", r))(X || {}), j = /* @__PURE__ */ ((r) => (r.URL = "url", r.STORY = "story", r.ASSET = "asset", r.EMAIL = "email", r))(j || {});
|
|
904
|
+
const Ye = [
|
|
905
|
+
"area",
|
|
906
|
+
"base",
|
|
907
|
+
"br",
|
|
908
|
+
"col",
|
|
909
|
+
"embed",
|
|
910
|
+
"hr",
|
|
911
|
+
"img",
|
|
912
|
+
"input",
|
|
913
|
+
"link",
|
|
914
|
+
"meta",
|
|
915
|
+
"param",
|
|
916
|
+
"source",
|
|
917
|
+
"track",
|
|
918
|
+
"wbr"
|
|
919
|
+
], Xe = (r = {}) => Object.keys(r).map((e) => `${e}="${r[e]}"`).join(" "), We = (r = {}) => Object.keys(r).map((e) => `${e}: ${r[e]}`).join("; ");
|
|
920
|
+
function Qe(r) {
|
|
921
|
+
return r.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
885
922
|
}
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
923
|
+
const F = (r) => Object.fromEntries(Object.entries(r).filter(([e, t]) => t !== void 0));
|
|
924
|
+
function Ze(r, e = {}, t) {
|
|
925
|
+
const s = Xe(e), o = s ? `${r} ${s}` : r;
|
|
926
|
+
return Ye.includes(r) ? `<${o}>` : `<${o}>${Array.isArray(t) ? t.join("") : t || ""}</${r}>`;
|
|
889
927
|
}
|
|
890
|
-
function
|
|
928
|
+
function et(r = {}) {
|
|
891
929
|
let e = 0;
|
|
892
930
|
const {
|
|
893
|
-
renderFn: t =
|
|
894
|
-
textFn:
|
|
931
|
+
renderFn: t = Ze,
|
|
932
|
+
textFn: s = Qe,
|
|
895
933
|
resolvers: o = {},
|
|
896
|
-
optimizeImages: n = !1
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
934
|
+
optimizeImages: n = !1,
|
|
935
|
+
keyedResolvers: i = !1
|
|
936
|
+
} = r, a = (c) => (m) => {
|
|
937
|
+
const f = m.attrs || {};
|
|
938
|
+
return i && (f.key = `${c}-${e}`), t(c, f, m.children || null);
|
|
939
|
+
}, l = (c) => {
|
|
940
|
+
const { src: m, alt: f, title: b, srcset: T, sizes: $ } = c.attrs || {};
|
|
941
|
+
let S = m, _ = {};
|
|
900
942
|
if (n) {
|
|
901
|
-
const { src:
|
|
902
|
-
|
|
943
|
+
const { src: re, attrs: se } = Je(m, n);
|
|
944
|
+
S = re, _ = se;
|
|
903
945
|
}
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
946
|
+
i && (_ = {
|
|
947
|
+
..._,
|
|
948
|
+
key: `img-${e}`
|
|
949
|
+
});
|
|
950
|
+
const te = {
|
|
951
|
+
src: S,
|
|
952
|
+
alt: f,
|
|
953
|
+
title: b,
|
|
954
|
+
srcset: T,
|
|
955
|
+
sizes: $,
|
|
956
|
+
..._
|
|
957
|
+
};
|
|
958
|
+
return t("img", F(te));
|
|
959
|
+
}, h = (c) => {
|
|
960
|
+
const { level: m, ...f } = c.attrs || {}, b = {
|
|
961
|
+
...f
|
|
910
962
|
};
|
|
911
|
-
return
|
|
912
|
-
}, a = (c) => {
|
|
913
|
-
const { level: g, ...f } = c.attrs || {};
|
|
914
|
-
return t(`h${g}`, { ...f, key: `h${g}-${e}` }, c.children);
|
|
963
|
+
return i && (b.key = `h${m}-${e}`), t(`h${m}`, b, c.children);
|
|
915
964
|
}, u = (c) => {
|
|
916
|
-
var
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
emoji: (f = c.attrs) == null ? void 0 : f.emoji,
|
|
921
|
-
key: `emoji-${e}`
|
|
922
|
-
}, t("img", {
|
|
923
|
-
src: (v = c.attrs) == null ? void 0 : v.fallbackImage,
|
|
924
|
-
alt: (T = c.attrs) == null ? void 0 : T.alt,
|
|
965
|
+
var m, f, b, T;
|
|
966
|
+
const $ = t("img", {
|
|
967
|
+
src: (m = c.attrs) == null ? void 0 : m.fallbackImage,
|
|
968
|
+
alt: (f = c.attrs) == null ? void 0 : f.alt,
|
|
925
969
|
style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
|
|
926
970
|
draggable: "false",
|
|
927
971
|
loading: "lazy"
|
|
928
|
-
},
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
972
|
+
}), S = {
|
|
973
|
+
"data-type": "emoji",
|
|
974
|
+
"data-name": (b = c.attrs) == null ? void 0 : b.name,
|
|
975
|
+
"data-emoji": (T = c.attrs) == null ? void 0 : T.emoji
|
|
976
|
+
};
|
|
977
|
+
return i && (S.key = `emoji-${e}`), t("span", S, $);
|
|
978
|
+
}, d = (c) => t("pre", {
|
|
979
|
+
...c.attrs,
|
|
980
|
+
key: `code-${e}`
|
|
981
|
+
}, t("code", { key: `code-${e}` }, c.children || "")), g = (c, m = !1) => ({ text: f, attrs: b }) => {
|
|
982
|
+
const { class: T, id: $, ...S } = b || {}, _ = m ? {
|
|
983
|
+
class: T,
|
|
984
|
+
id: $,
|
|
985
|
+
style: We(S) || void 0
|
|
986
|
+
} : b || {};
|
|
987
|
+
return i && (_.key = `${c}-${e}`), t(c, F(_), f);
|
|
988
|
+
}, R = (c) => P(c), y = (c) => {
|
|
989
|
+
const { marks: m, ...f } = c;
|
|
990
|
+
return "text" in c ? m ? m.reduce(
|
|
991
|
+
(b, T) => R({ ...T, text: b }),
|
|
936
992
|
// Fix: Ensure render function returns a string
|
|
937
|
-
|
|
993
|
+
R({ ...f, children: f.children })
|
|
938
994
|
// Fix: Cast children to string
|
|
939
|
-
) :
|
|
940
|
-
},
|
|
941
|
-
const { linktype:
|
|
942
|
-
let
|
|
943
|
-
switch (
|
|
944
|
-
case
|
|
945
|
-
case
|
|
946
|
-
|
|
995
|
+
) : s(f.text) : "";
|
|
996
|
+
}, w = (c) => {
|
|
997
|
+
const { linktype: m, href: f, anchor: b, ...T } = c.attrs || {};
|
|
998
|
+
let $ = "";
|
|
999
|
+
switch (m) {
|
|
1000
|
+
case j.ASSET:
|
|
1001
|
+
case j.URL:
|
|
1002
|
+
$ = f;
|
|
947
1003
|
break;
|
|
948
|
-
case
|
|
949
|
-
|
|
1004
|
+
case j.EMAIL:
|
|
1005
|
+
$ = `mailto:${f}`;
|
|
950
1006
|
break;
|
|
951
|
-
case
|
|
952
|
-
|
|
1007
|
+
case j.STORY:
|
|
1008
|
+
$ = f;
|
|
953
1009
|
break;
|
|
954
1010
|
}
|
|
955
|
-
return
|
|
956
|
-
},
|
|
957
|
-
var
|
|
1011
|
+
return b && ($ = `${$}#${b}`), t("a", { ...T, href: $, key: `a-${e}` }, c.text);
|
|
1012
|
+
}, x = (c) => {
|
|
1013
|
+
var m, f;
|
|
958
1014
|
return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), t("span", {
|
|
959
|
-
blok: (
|
|
1015
|
+
blok: (m = c == null ? void 0 : c.attrs) == null ? void 0 : m.body[0],
|
|
960
1016
|
id: (f = c.attrs) == null ? void 0 : f.id,
|
|
961
1017
|
key: `component-${e}`,
|
|
962
1018
|
style: "display: none"
|
|
963
|
-
}
|
|
964
|
-
},
|
|
965
|
-
[
|
|
966
|
-
[
|
|
967
|
-
[
|
|
968
|
-
[
|
|
969
|
-
[
|
|
970
|
-
[
|
|
971
|
-
[
|
|
972
|
-
[
|
|
973
|
-
[
|
|
974
|
-
[
|
|
975
|
-
[
|
|
976
|
-
[
|
|
977
|
-
[
|
|
978
|
-
[
|
|
979
|
-
[
|
|
980
|
-
[
|
|
981
|
-
[
|
|
982
|
-
[
|
|
983
|
-
[
|
|
984
|
-
[
|
|
985
|
-
[
|
|
986
|
-
[
|
|
987
|
-
[
|
|
988
|
-
[
|
|
989
|
-
[
|
|
990
|
-
[
|
|
991
|
-
...Object.entries(o).map(([c,
|
|
1019
|
+
});
|
|
1020
|
+
}, ee = new Map([
|
|
1021
|
+
[k.DOCUMENT, a("div")],
|
|
1022
|
+
[k.HEADING, h],
|
|
1023
|
+
[k.PARAGRAPH, a("p")],
|
|
1024
|
+
[k.UL_LIST, a("ul")],
|
|
1025
|
+
[k.OL_LIST, a("ol")],
|
|
1026
|
+
[k.LIST_ITEM, a("li")],
|
|
1027
|
+
[k.IMAGE, l],
|
|
1028
|
+
[k.EMOJI, u],
|
|
1029
|
+
[k.CODE_BLOCK, d],
|
|
1030
|
+
[k.HR, a("hr")],
|
|
1031
|
+
[k.BR, a("br")],
|
|
1032
|
+
[k.QUOTE, a("blockquote")],
|
|
1033
|
+
[k.COMPONENT, x],
|
|
1034
|
+
[X.TEXT, y],
|
|
1035
|
+
[v.LINK, w],
|
|
1036
|
+
[v.ANCHOR, w],
|
|
1037
|
+
[v.STYLED, g("span", !0)],
|
|
1038
|
+
[v.BOLD, g("strong")],
|
|
1039
|
+
[v.TEXT_STYLE, g("span", !0)],
|
|
1040
|
+
[v.ITALIC, g("em")],
|
|
1041
|
+
[v.UNDERLINE, g("u")],
|
|
1042
|
+
[v.STRIKE, g("s")],
|
|
1043
|
+
[v.CODE, g("code")],
|
|
1044
|
+
[v.SUPERSCRIPT, g("sup")],
|
|
1045
|
+
[v.SUBSCRIPT, g("sub")],
|
|
1046
|
+
[v.HIGHLIGHT, g("mark")],
|
|
1047
|
+
...Object.entries(o).map(([c, m]) => [c, m])
|
|
992
1048
|
]);
|
|
993
|
-
function
|
|
1049
|
+
function U(c) {
|
|
994
1050
|
e += 1;
|
|
995
|
-
const
|
|
996
|
-
if (!
|
|
1051
|
+
const m = ee.get(c.type);
|
|
1052
|
+
if (!m)
|
|
997
1053
|
return console.error("<Storyblok>", `No resolver found for node type ${c.type}`), "";
|
|
998
1054
|
if (c.type === "text")
|
|
999
|
-
return
|
|
1000
|
-
const f = c.content ? c.content.map(
|
|
1001
|
-
return
|
|
1055
|
+
return m(c);
|
|
1056
|
+
const f = c.content ? c.content.map(P) : void 0;
|
|
1057
|
+
return m({
|
|
1002
1058
|
...c,
|
|
1003
1059
|
children: f
|
|
1004
1060
|
// Fix: Update the type of 'children' to Node[]
|
|
1005
1061
|
});
|
|
1006
1062
|
}
|
|
1007
|
-
function
|
|
1008
|
-
return Array.isArray(c) ? c.map(
|
|
1063
|
+
function P(c) {
|
|
1064
|
+
return Array.isArray(c) ? c.map(U) : U(c);
|
|
1009
1065
|
}
|
|
1010
1066
|
return {
|
|
1011
|
-
render:
|
|
1067
|
+
render: P
|
|
1012
1068
|
};
|
|
1013
1069
|
}
|
|
1014
|
-
let
|
|
1015
|
-
const
|
|
1016
|
-
var
|
|
1017
|
-
const o = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", n = +new URL((
|
|
1070
|
+
let H, V = "https://app.storyblok.com/f/storyblok-v2-latest.js";
|
|
1071
|
+
const tt = (r, e, t = {}) => {
|
|
1072
|
+
var s;
|
|
1073
|
+
const o = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", n = +new URL((s = window.location) == null ? void 0 : s.href).searchParams.get(
|
|
1018
1074
|
"_storyblok"
|
|
1019
|
-
) ===
|
|
1075
|
+
) === r;
|
|
1020
1076
|
if (!(!o || !n)) {
|
|
1021
|
-
if (!
|
|
1077
|
+
if (!r) {
|
|
1022
1078
|
console.warn("Story ID is not defined. Please provide a valid ID.");
|
|
1023
1079
|
return;
|
|
1024
1080
|
}
|
|
1025
1081
|
window.storyblokRegisterEvent(() => {
|
|
1026
1082
|
new window.StoryblokBridge(t).on(["input", "published", "change"], (i) => {
|
|
1027
|
-
i.action === "input" && i.story.id ===
|
|
1083
|
+
i.action === "input" && i.story.id === r ? e(i.story) : (i.action === "change" || i.action === "published") && i.storyId === r && window.location.reload();
|
|
1028
1084
|
});
|
|
1029
1085
|
});
|
|
1030
1086
|
}
|
|
1031
|
-
},
|
|
1087
|
+
}, rt = (r = {}) => {
|
|
1032
1088
|
var e, t;
|
|
1033
1089
|
const {
|
|
1034
|
-
bridge:
|
|
1090
|
+
bridge: s,
|
|
1035
1091
|
accessToken: o,
|
|
1036
1092
|
use: n = [],
|
|
1037
1093
|
apiOptions: i = {},
|
|
1038
|
-
richText:
|
|
1039
|
-
bridgeUrl:
|
|
1040
|
-
} =
|
|
1094
|
+
richText: a = {},
|
|
1095
|
+
bridgeUrl: l
|
|
1096
|
+
} = r;
|
|
1041
1097
|
i.accessToken = i.accessToken || o;
|
|
1042
|
-
const
|
|
1043
|
-
let
|
|
1044
|
-
n.forEach((
|
|
1045
|
-
|
|
1046
|
-
}),
|
|
1047
|
-
const
|
|
1048
|
-
return
|
|
1049
|
-
},
|
|
1050
|
-
|
|
1051
|
-
let
|
|
1098
|
+
const h = { bridge: s, apiOptions: i };
|
|
1099
|
+
let u = {};
|
|
1100
|
+
n.forEach((g) => {
|
|
1101
|
+
u = { ...u, ...g(h) };
|
|
1102
|
+
}), l && (V = l);
|
|
1103
|
+
const d = !(typeof window > "u") && ((t = (e = window.location) == null ? void 0 : e.search) == null ? void 0 : t.includes("_storyblok_tk"));
|
|
1104
|
+
return s !== !1 && d && he(V), H = new L(a.schema), a.resolver && W(H, a.resolver), u;
|
|
1105
|
+
}, W = (r, e) => {
|
|
1106
|
+
r.addNode("blok", (t) => {
|
|
1107
|
+
let s = "";
|
|
1052
1108
|
return t.attrs.body.forEach((o) => {
|
|
1053
|
-
|
|
1109
|
+
s += e(o.component, o);
|
|
1054
1110
|
}), {
|
|
1055
|
-
html:
|
|
1111
|
+
html: s
|
|
1056
1112
|
};
|
|
1057
1113
|
});
|
|
1058
|
-
},
|
|
1059
|
-
let
|
|
1060
|
-
if (!
|
|
1114
|
+
}, st = (r) => !r || !(r != null && r.content.some((e) => e.content || e.type === "blok" || e.type === "horizontal_rule")), ht = (r, e, t) => {
|
|
1115
|
+
let s = t || H;
|
|
1116
|
+
if (!s) {
|
|
1061
1117
|
console.error(
|
|
1062
1118
|
"Please initialize the Storyblok SDK before calling the renderRichText function"
|
|
1063
1119
|
);
|
|
1064
1120
|
return;
|
|
1065
1121
|
}
|
|
1066
|
-
return
|
|
1067
|
-
},
|
|
1122
|
+
return st(r) ? "" : (e && (s = new L(e.schema), e.resolver && W(s, e.resolver)), s.render(r, {}, !1));
|
|
1123
|
+
}, Q = /* @__PURE__ */ G({
|
|
1068
1124
|
__name: "StoryblokComponent",
|
|
1069
1125
|
props: {
|
|
1070
1126
|
blok: {}
|
|
1071
1127
|
},
|
|
1072
|
-
setup(
|
|
1073
|
-
const t =
|
|
1128
|
+
setup(r, { expose: e }) {
|
|
1129
|
+
const t = r, s = O();
|
|
1074
1130
|
e({
|
|
1075
|
-
value:
|
|
1131
|
+
value: s
|
|
1076
1132
|
});
|
|
1077
|
-
const o = typeof
|
|
1078
|
-
return o || (n.enableFallbackComponent ? (i.value = n.customFallbackComponent ?? "FallbackComponent", typeof
|
|
1133
|
+
const o = typeof N(t.blok.component) != "string", n = oe("VueSDKOptions"), i = O(t.blok.component);
|
|
1134
|
+
return o || (n.enableFallbackComponent ? (i.value = n.customFallbackComponent ?? "FallbackComponent", typeof N(i.value) == "string" && console.error(
|
|
1079
1135
|
`Is the Fallback component "${i.value}" registered properly?`
|
|
1080
1136
|
)) : console.error(
|
|
1081
1137
|
`Component could not be found for blok "${t.blok.component}"! Is it defined in main.ts as "app.component("${t.blok.component}", ${t.blok.component});"?`
|
|
1082
|
-
)), (
|
|
1138
|
+
)), (a, l) => (K(), J(N(i.value), ne({
|
|
1083
1139
|
ref_key: "blokRef",
|
|
1084
|
-
ref:
|
|
1085
|
-
}, { ...
|
|
1140
|
+
ref: s
|
|
1141
|
+
}, { ...a.$props, ...a.$attrs }), null, 16));
|
|
1086
1142
|
}
|
|
1087
|
-
}),
|
|
1143
|
+
}), ot = (r) => {
|
|
1088
1144
|
var e, t;
|
|
1089
|
-
return
|
|
1090
|
-
|
|
1145
|
+
return Y(
|
|
1146
|
+
Q,
|
|
1091
1147
|
{
|
|
1092
|
-
blok: (e =
|
|
1093
|
-
id: (t =
|
|
1148
|
+
blok: (e = r == null ? void 0 : r.attrs) == null ? void 0 : e.body[0],
|
|
1149
|
+
id: (t = r.attrs) == null ? void 0 : t.id
|
|
1094
1150
|
},
|
|
1095
|
-
|
|
1151
|
+
r.children
|
|
1096
1152
|
);
|
|
1097
1153
|
};
|
|
1098
|
-
function
|
|
1154
|
+
function nt(r) {
|
|
1099
1155
|
const e = {
|
|
1100
|
-
renderFn:
|
|
1101
|
-
textFn:
|
|
1156
|
+
renderFn: Y,
|
|
1157
|
+
textFn: ie,
|
|
1158
|
+
keyedResolvers: !0,
|
|
1102
1159
|
resolvers: {
|
|
1103
|
-
[
|
|
1104
|
-
...
|
|
1160
|
+
[k.COMPONENT]: ot,
|
|
1161
|
+
...r.resolvers
|
|
1105
1162
|
}
|
|
1106
1163
|
};
|
|
1107
|
-
return
|
|
1164
|
+
return et(e);
|
|
1108
1165
|
}
|
|
1109
|
-
const
|
|
1166
|
+
const it = /* @__PURE__ */ G({
|
|
1110
1167
|
__name: "StoryblokRichText",
|
|
1111
1168
|
props: {
|
|
1112
1169
|
doc: {},
|
|
1113
1170
|
resolvers: {}
|
|
1114
1171
|
},
|
|
1115
|
-
setup(
|
|
1116
|
-
const e =
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1172
|
+
setup(r) {
|
|
1173
|
+
const e = r, t = O(), s = () => t.value;
|
|
1174
|
+
return ae(
|
|
1175
|
+
[e.doc, e.resolvers],
|
|
1176
|
+
([o, n]) => {
|
|
1177
|
+
const { render: i } = nt({
|
|
1178
|
+
resolvers: n ?? {}
|
|
1179
|
+
});
|
|
1180
|
+
t.value = i(o);
|
|
1181
|
+
},
|
|
1182
|
+
{
|
|
1183
|
+
immediate: !0
|
|
1184
|
+
}
|
|
1185
|
+
), (o, n) => (K(), J(s));
|
|
1186
|
+
}
|
|
1187
|
+
}), at = {
|
|
1188
|
+
beforeMount(r, e) {
|
|
1123
1189
|
if (e.value) {
|
|
1124
|
-
const t =
|
|
1125
|
-
Object.keys(t).length > 0 && (
|
|
1190
|
+
const t = Ke(e.value);
|
|
1191
|
+
Object.keys(t).length > 0 && (r.setAttribute("data-blok-c", t["data-blok-c"]), r.setAttribute("data-blok-uid", t["data-blok-uid"]), r.classList.add("storyblok__outline"));
|
|
1126
1192
|
}
|
|
1127
1193
|
}
|
|
1128
|
-
},
|
|
1129
|
-
console.error(`You can't use ${
|
|
1194
|
+
}, Z = (r) => {
|
|
1195
|
+
console.error(`You can't use ${r} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
|
|
1130
1196
|
`);
|
|
1131
1197
|
};
|
|
1132
|
-
let
|
|
1133
|
-
const
|
|
1134
|
-
const
|
|
1135
|
-
if (t.resolveRelations = t.resolveRelations ?? e.resolve_relations, t.resolveLinks = t.resolveLinks ?? e.resolve_links,
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
(o) =>
|
|
1198
|
+
let I = null;
|
|
1199
|
+
const ut = () => (I || Z("useStoryblokApi"), I), dt = async (r, e = {}, t = {}) => {
|
|
1200
|
+
const s = O(null);
|
|
1201
|
+
if (t.resolveRelations = t.resolveRelations ?? e.resolve_relations, t.resolveLinks = t.resolveLinks ?? e.resolve_links, le(() => {
|
|
1202
|
+
s.value && s.value.id && tt(
|
|
1203
|
+
s.value.id,
|
|
1204
|
+
(o) => s.value = o,
|
|
1139
1205
|
t
|
|
1140
1206
|
);
|
|
1141
|
-
}),
|
|
1142
|
-
const { data: o } = await
|
|
1143
|
-
`cdn/stories/${
|
|
1207
|
+
}), I) {
|
|
1208
|
+
const { data: o } = await I.get(
|
|
1209
|
+
`cdn/stories/${r}`,
|
|
1144
1210
|
e
|
|
1145
1211
|
);
|
|
1146
|
-
|
|
1147
|
-
} else
|
|
1148
|
-
return
|
|
1149
|
-
},
|
|
1150
|
-
install(
|
|
1151
|
-
|
|
1212
|
+
s.value = o.story;
|
|
1213
|
+
} else Z("useStoryblok");
|
|
1214
|
+
return s;
|
|
1215
|
+
}, pt = {
|
|
1216
|
+
install(r, e = {}) {
|
|
1217
|
+
r.directive("editable", at), r.component("StoryblokComponent", Q), r.component("StoryblokRichText", it), e.enableFallbackComponent && !e.customFallbackComponent && r.component(
|
|
1152
1218
|
"FallbackComponent",
|
|
1153
|
-
|
|
1219
|
+
ce(() => import("./FallbackComponent-C2j8Ky5h.mjs"))
|
|
1154
1220
|
);
|
|
1155
|
-
const { storyblokApi: t } =
|
|
1156
|
-
|
|
1221
|
+
const { storyblokApi: t } = rt(e);
|
|
1222
|
+
I = t, r.provide("VueSDKOptions", e);
|
|
1157
1223
|
}
|
|
1158
1224
|
};
|
|
1159
1225
|
export {
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1226
|
+
k as BlockTypes,
|
|
1227
|
+
v as MarkTypes,
|
|
1228
|
+
L as RichTextResolver,
|
|
1229
|
+
ze as RichTextSchema,
|
|
1230
|
+
Q as StoryblokComponent,
|
|
1231
|
+
it as StoryblokRichText,
|
|
1232
|
+
pt as StoryblokVue,
|
|
1233
|
+
X as TextTypes,
|
|
1234
|
+
ct as apiPlugin,
|
|
1235
|
+
ht as renderRichText,
|
|
1236
|
+
et as richTextResolver,
|
|
1237
|
+
dt as useStoryblok,
|
|
1238
|
+
ut as useStoryblokApi,
|
|
1239
|
+
tt as useStoryblokBridge,
|
|
1240
|
+
nt as useStoryblokRichText
|
|
1175
1241
|
};
|