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