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