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