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