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