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