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