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