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