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