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