@storyblok/vue 7.1.13 → 7.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/storyblok-vue.js +3 -3
- package/dist/storyblok-vue.mjs +431 -426
- package/package.json +4 -4
package/dist/storyblok-vue.mjs
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import { defineComponent as I, openBlock as A, createBlock as C, resolveDynamicComponent as O, normalizeProps as N, guardReactiveProps as M, ref as
|
|
2
|
-
let
|
|
3
|
-
const j = [],
|
|
1
|
+
import { defineComponent as I, openBlock as A, createBlock as C, resolveDynamicComponent as O, normalizeProps as N, guardReactiveProps as M, ref as L, onMounted as z } from "vue";
|
|
2
|
+
let _ = !1;
|
|
3
|
+
const j = [], H = (o) => new Promise((e, t) => {
|
|
4
4
|
if (typeof window > "u" || (window.storyblokRegisterEvent = (r) => {
|
|
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
|
+
_ ? r() : j.push(r);
|
|
10
10
|
}, document.getElementById("storyblok-javascript-bridge")))
|
|
11
11
|
return;
|
|
12
12
|
const s = document.createElement("script");
|
|
13
|
-
s.async = !0, s.src = o, s.id = "storyblok-javascript-bridge", s.onerror = (r) =>
|
|
14
|
-
j.forEach((
|
|
13
|
+
s.async = !0, s.src = o, s.id = "storyblok-javascript-bridge", s.onerror = (r) => t(r), s.onload = (r) => {
|
|
14
|
+
j.forEach((n) => n()), _ = !0, e(r);
|
|
15
15
|
}, document.getElementsByTagName("head")[0].appendChild(s);
|
|
16
16
|
});
|
|
17
|
-
var
|
|
17
|
+
var U = Object.defineProperty, q = (o, e, t) => e in o ? U(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, h = (o, e, t) => (q(o, typeof e != "symbol" ? e + "" : e, t), t);
|
|
18
18
|
function S(o) {
|
|
19
19
|
return !(o !== o || o === 1 / 0 || o === -1 / 0);
|
|
20
20
|
}
|
|
21
|
-
function V(o,
|
|
22
|
-
if (!S(t))
|
|
23
|
-
throw new TypeError("Expected `limit` to be a finite number");
|
|
21
|
+
function V(o, e, t) {
|
|
24
22
|
if (!S(e))
|
|
23
|
+
throw new TypeError("Expected `limit` to be a finite number");
|
|
24
|
+
if (!S(t))
|
|
25
25
|
throw new TypeError("Expected `interval` to be a finite number");
|
|
26
26
|
const s = [];
|
|
27
|
-
let r = [],
|
|
28
|
-
const
|
|
29
|
-
|
|
27
|
+
let r = [], n = 0;
|
|
28
|
+
const i = function() {
|
|
29
|
+
n++;
|
|
30
30
|
const a = setTimeout(function() {
|
|
31
|
-
|
|
31
|
+
n--, s.length > 0 && i(), r = r.filter(function(u) {
|
|
32
32
|
return u !== a;
|
|
33
33
|
});
|
|
34
|
-
},
|
|
34
|
+
}, t);
|
|
35
35
|
r.indexOf(a) < 0 && r.push(a);
|
|
36
36
|
const l = s.shift();
|
|
37
37
|
l.resolve(o.apply(l.self, l.args));
|
|
38
38
|
}, c = function(...a) {
|
|
39
39
|
const l = this;
|
|
40
|
-
return new Promise(function(u,
|
|
40
|
+
return new Promise(function(u, p) {
|
|
41
41
|
s.push({
|
|
42
42
|
resolve: u,
|
|
43
|
-
reject:
|
|
43
|
+
reject: p,
|
|
44
44
|
args: a,
|
|
45
45
|
self: l
|
|
46
|
-
}),
|
|
46
|
+
}), n < e && i();
|
|
47
47
|
});
|
|
48
48
|
};
|
|
49
49
|
return c.abort = function() {
|
|
@@ -54,13 +54,72 @@ function V(o, t, e) {
|
|
|
54
54
|
}), s.length = 0;
|
|
55
55
|
}, c;
|
|
56
56
|
}
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
class b {
|
|
58
|
+
constructor() {
|
|
59
|
+
h(this, "isCDNUrl", (e = "") => e.indexOf("/cdn/") > -1), h(this, "getOptionsPage", (e, t = 25, s = 1) => ({
|
|
60
|
+
...e,
|
|
61
|
+
per_page: t,
|
|
62
|
+
page: s
|
|
63
|
+
})), h(this, "delay", (e) => new Promise((t) => setTimeout(t, e))), h(this, "arrayFrom", (e = 0, t) => [...Array(e)].map(t)), h(this, "range", (e = 0, t = e) => {
|
|
64
|
+
const s = Math.abs(t - e) || 0, r = e < t ? 1 : -1;
|
|
65
|
+
return this.arrayFrom(s, (n, i) => i * r + e);
|
|
66
|
+
}), h(this, "asyncMap", async (e, t) => Promise.all(e.map(t))), h(this, "flatMap", (e = [], t) => e.map(t).reduce((s, r) => [...s, ...r], [])), h(this, "escapeHTML", function(e) {
|
|
67
|
+
const t = {
|
|
68
|
+
"&": "&",
|
|
69
|
+
"<": "<",
|
|
70
|
+
">": ">",
|
|
71
|
+
'"': """,
|
|
72
|
+
"'": "'"
|
|
73
|
+
}, s = /[&<>"']/g, r = RegExp(s.source);
|
|
74
|
+
return e && r.test(e) ? e.replace(s, (n) => t[n]) : e;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* @method stringify
|
|
79
|
+
* @param {Object} params
|
|
80
|
+
* @param {String} prefix
|
|
81
|
+
* @param {Boolean} isArray
|
|
82
|
+
* @return {String} Stringified object
|
|
83
|
+
*/
|
|
84
|
+
stringify(e, t, s) {
|
|
85
|
+
const r = [];
|
|
86
|
+
for (const n in e) {
|
|
87
|
+
if (!Object.prototype.hasOwnProperty.call(e, n))
|
|
88
|
+
continue;
|
|
89
|
+
const i = e[n], c = s ? "" : encodeURIComponent(n);
|
|
90
|
+
let a;
|
|
91
|
+
typeof i == "object" ? a = this.stringify(
|
|
92
|
+
i,
|
|
93
|
+
t ? t + encodeURIComponent("[" + c + "]") : c,
|
|
94
|
+
Array.isArray(i)
|
|
95
|
+
) : a = (t ? t + encodeURIComponent("[" + c + "]") : c) + "=" + encodeURIComponent(i), r.push(a);
|
|
96
|
+
}
|
|
97
|
+
return r.join("&");
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* @method getRegionURL
|
|
101
|
+
* @param {String} regionCode region code, could be eu, us or cn
|
|
102
|
+
* @return {String} The base URL of the region
|
|
103
|
+
*/
|
|
104
|
+
getRegionURL(e) {
|
|
105
|
+
const t = "api.storyblok.com", s = "api-us.storyblok.com", r = "app.storyblokchina.cn";
|
|
106
|
+
switch (e) {
|
|
107
|
+
case "us":
|
|
108
|
+
return s;
|
|
109
|
+
case "cn":
|
|
110
|
+
return r;
|
|
111
|
+
default:
|
|
112
|
+
return t;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const B = function(o, e) {
|
|
117
|
+
const t = {};
|
|
59
118
|
for (const s in o) {
|
|
60
119
|
const r = o[s];
|
|
61
|
-
|
|
120
|
+
e.indexOf(s) > -1 && r !== null && (t[s] = r);
|
|
62
121
|
}
|
|
63
|
-
return
|
|
122
|
+
return t;
|
|
64
123
|
}, D = (o) => o === "email", J = () => ({
|
|
65
124
|
singleTag: "hr"
|
|
66
125
|
}), F = () => ({
|
|
@@ -90,9 +149,9 @@ const B = function(o, t) {
|
|
|
90
149
|
tag: "li"
|
|
91
150
|
}), Z = () => ({
|
|
92
151
|
tag: "ol"
|
|
93
|
-
}),
|
|
152
|
+
}), ee = () => ({
|
|
94
153
|
tag: "p"
|
|
95
|
-
}),
|
|
154
|
+
}), te = (o) => ({
|
|
96
155
|
tag: [
|
|
97
156
|
{
|
|
98
157
|
tag: "span",
|
|
@@ -103,23 +162,23 @@ const B = function(o, t) {
|
|
|
103
162
|
}
|
|
104
163
|
}
|
|
105
164
|
]
|
|
106
|
-
}),
|
|
165
|
+
}), se = () => ({
|
|
107
166
|
tag: "b"
|
|
108
|
-
}),
|
|
167
|
+
}), re = () => ({
|
|
109
168
|
tag: "strike"
|
|
110
|
-
}),
|
|
169
|
+
}), oe = () => ({
|
|
111
170
|
tag: "u"
|
|
112
|
-
}),
|
|
171
|
+
}), ne = () => ({
|
|
113
172
|
tag: "strong"
|
|
114
|
-
}),
|
|
173
|
+
}), ie = () => ({
|
|
115
174
|
tag: "code"
|
|
116
|
-
}),
|
|
175
|
+
}), ae = () => ({
|
|
117
176
|
tag: "i"
|
|
118
|
-
}),
|
|
119
|
-
const t = { ...o.attrs }, { linktype:
|
|
120
|
-
if (
|
|
121
|
-
for (const
|
|
122
|
-
t[
|
|
177
|
+
}), le = (o) => {
|
|
178
|
+
const e = new b().escapeHTML, t = { ...o.attrs }, { linktype: s = "url" } = o.attrs;
|
|
179
|
+
if (t.href && (t.href = e(o.attrs.href || "")), D(s) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), t.custom) {
|
|
180
|
+
for (const r in t.custom)
|
|
181
|
+
t[r] = t.custom[r];
|
|
123
182
|
delete t.custom;
|
|
124
183
|
}
|
|
125
184
|
return {
|
|
@@ -130,27 +189,27 @@ const B = function(o, t) {
|
|
|
130
189
|
}
|
|
131
190
|
]
|
|
132
191
|
};
|
|
133
|
-
},
|
|
192
|
+
}, ce = (o) => ({
|
|
134
193
|
tag: [
|
|
135
194
|
{
|
|
136
195
|
tag: "span",
|
|
137
196
|
attrs: o.attrs
|
|
138
197
|
}
|
|
139
198
|
]
|
|
140
|
-
}),
|
|
199
|
+
}), he = () => ({
|
|
141
200
|
tag: "sub"
|
|
142
|
-
}),
|
|
201
|
+
}), ue = () => ({
|
|
143
202
|
tag: "sup"
|
|
144
|
-
}),
|
|
203
|
+
}), pe = (o) => ({
|
|
145
204
|
tag: [
|
|
146
205
|
{
|
|
147
206
|
tag: "span",
|
|
148
207
|
attrs: o.attrs
|
|
149
208
|
}
|
|
150
209
|
]
|
|
151
|
-
}),
|
|
152
|
-
var
|
|
153
|
-
return (
|
|
210
|
+
}), de = (o) => {
|
|
211
|
+
var e;
|
|
212
|
+
return (e = o.attrs) != null && e.color ? {
|
|
154
213
|
tag: [
|
|
155
214
|
{
|
|
156
215
|
tag: "span",
|
|
@@ -162,9 +221,9 @@ const B = function(o, t) {
|
|
|
162
221
|
} : {
|
|
163
222
|
tag: ""
|
|
164
223
|
};
|
|
165
|
-
},
|
|
166
|
-
var
|
|
167
|
-
return (
|
|
224
|
+
}, ge = (o) => {
|
|
225
|
+
var e;
|
|
226
|
+
return (e = o.attrs) != null && e.color ? {
|
|
168
227
|
tag: [
|
|
169
228
|
{
|
|
170
229
|
tag: "span",
|
|
@@ -176,7 +235,7 @@ const B = function(o, t) {
|
|
|
176
235
|
} : {
|
|
177
236
|
tag: ""
|
|
178
237
|
};
|
|
179
|
-
},
|
|
238
|
+
}, fe = {
|
|
180
239
|
nodes: {
|
|
181
240
|
horizontal_rule: J,
|
|
182
241
|
blockquote: F,
|
|
@@ -187,50 +246,50 @@ const B = function(o, t) {
|
|
|
187
246
|
image: Q,
|
|
188
247
|
list_item: X,
|
|
189
248
|
ordered_list: Z,
|
|
190
|
-
paragraph:
|
|
191
|
-
emoji:
|
|
249
|
+
paragraph: ee,
|
|
250
|
+
emoji: te
|
|
192
251
|
},
|
|
193
252
|
marks: {
|
|
194
|
-
bold:
|
|
195
|
-
strike:
|
|
196
|
-
underline:
|
|
197
|
-
strong:
|
|
198
|
-
code:
|
|
199
|
-
italic:
|
|
200
|
-
link:
|
|
201
|
-
styled:
|
|
202
|
-
subscript:
|
|
203
|
-
superscript:
|
|
204
|
-
anchor:
|
|
205
|
-
highlight:
|
|
206
|
-
textStyle:
|
|
207
|
-
}
|
|
208
|
-
},
|
|
209
|
-
const
|
|
253
|
+
bold: se,
|
|
254
|
+
strike: re,
|
|
255
|
+
underline: oe,
|
|
256
|
+
strong: ne,
|
|
257
|
+
code: ie,
|
|
258
|
+
italic: ae,
|
|
259
|
+
link: le,
|
|
260
|
+
styled: ce,
|
|
261
|
+
subscript: he,
|
|
262
|
+
superscript: ue,
|
|
263
|
+
anchor: pe,
|
|
264
|
+
highlight: de,
|
|
265
|
+
textStyle: ge
|
|
266
|
+
}
|
|
267
|
+
}, me = function(o) {
|
|
268
|
+
const e = {
|
|
210
269
|
"&": "&",
|
|
211
270
|
"<": "<",
|
|
212
271
|
">": ">",
|
|
213
272
|
'"': """,
|
|
214
273
|
"'": "'"
|
|
215
|
-
},
|
|
216
|
-
return o && s.test(o) ? o.replace(
|
|
274
|
+
}, t = /[&<>"']/g, s = RegExp(t.source);
|
|
275
|
+
return o && s.test(o) ? o.replace(t, (r) => e[r]) : o;
|
|
217
276
|
};
|
|
218
|
-
class
|
|
219
|
-
constructor(
|
|
220
|
-
h(this, "marks"), h(this, "nodes"),
|
|
277
|
+
class k {
|
|
278
|
+
constructor(e) {
|
|
279
|
+
h(this, "marks"), h(this, "nodes"), e || (e = fe), this.marks = e.marks || [], this.nodes = e.nodes || [];
|
|
221
280
|
}
|
|
222
|
-
addNode(
|
|
223
|
-
this.nodes[
|
|
281
|
+
addNode(e, t) {
|
|
282
|
+
this.nodes[e] = t;
|
|
224
283
|
}
|
|
225
|
-
addMark(
|
|
226
|
-
this.marks[
|
|
284
|
+
addMark(e, t) {
|
|
285
|
+
this.marks[e] = t;
|
|
227
286
|
}
|
|
228
|
-
render(
|
|
229
|
-
if (
|
|
287
|
+
render(e, t = { optimizeImages: !1 }) {
|
|
288
|
+
if (e && e.content && Array.isArray(e.content)) {
|
|
230
289
|
let s = "";
|
|
231
|
-
return
|
|
290
|
+
return e.content.forEach((r) => {
|
|
232
291
|
s += this.renderNode(r);
|
|
233
|
-
}),
|
|
292
|
+
}), t.optimizeImages ? this.optimizeImages(s, t.optimizeImages) : s;
|
|
234
293
|
}
|
|
235
294
|
return console.warn(
|
|
236
295
|
`The render method must receive an Object with a "content" field.
|
|
@@ -259,151 +318,101 @@ class b {
|
|
|
259
318
|
}`
|
|
260
319
|
), "";
|
|
261
320
|
}
|
|
262
|
-
optimizeImages(
|
|
263
|
-
let s = 0, r = 0,
|
|
264
|
-
typeof
|
|
265
|
-
const c = s > 0 || r > 0 ||
|
|
266
|
-
return
|
|
321
|
+
optimizeImages(e, t) {
|
|
322
|
+
let s = 0, r = 0, n = "", i = "";
|
|
323
|
+
typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (n += `width="${t.width}" `, s = t.width), typeof t.height == "number" && t.height > 0 && (n += `height="${t.height}" `, r = 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()}`));
|
|
324
|
+
const c = s > 0 || r > 0 || i.length > 0 ? `${s}x${r}${i}` : "";
|
|
325
|
+
return e = e.replace(
|
|
267
326
|
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,
|
|
268
327
|
`a.storyblok.com/f/$1/$2.$3/m/${c}`
|
|
269
|
-
), typeof
|
|
328
|
+
), typeof t != "boolean" && (t.sizes || t.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (a) => {
|
|
270
329
|
var l, u;
|
|
271
|
-
const
|
|
330
|
+
const p = a.match(
|
|
272
331
|
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g
|
|
273
332
|
);
|
|
274
|
-
if (
|
|
333
|
+
if (p && p.length > 0) {
|
|
275
334
|
const g = {
|
|
276
|
-
srcset: (l =
|
|
277
|
-
if (typeof
|
|
278
|
-
return `//${
|
|
279
|
-
if (typeof
|
|
280
|
-
let
|
|
281
|
-
return typeof
|
|
335
|
+
srcset: (l = t.srcset) == null ? void 0 : l.map((d) => {
|
|
336
|
+
if (typeof d == "number")
|
|
337
|
+
return `//${p}/m/${d}x0${i} ${d}w`;
|
|
338
|
+
if (typeof d == "object" && d.length === 2) {
|
|
339
|
+
let w = 0, T = 0;
|
|
340
|
+
return typeof d[0] == "number" && (w = d[0]), typeof d[1] == "number" && (T = d[1]), `//${p}/m/${w}x${T}${i} ${w}w`;
|
|
282
341
|
}
|
|
283
342
|
}).join(", "),
|
|
284
|
-
sizes: (u =
|
|
343
|
+
sizes: (u = t.sizes) == null ? void 0 : u.map((d) => d).join(", ")
|
|
285
344
|
};
|
|
286
345
|
let v = "";
|
|
287
346
|
return g.srcset && (v += `srcset="${g.srcset}" `), g.sizes && (v += `sizes="${g.sizes}" `), a.replace(/<img/g, `<img ${v.trim()}`);
|
|
288
347
|
}
|
|
289
348
|
return a;
|
|
290
|
-
})),
|
|
349
|
+
})), e;
|
|
291
350
|
}
|
|
292
|
-
renderNode(
|
|
293
|
-
const
|
|
294
|
-
|
|
295
|
-
const
|
|
296
|
-
|
|
351
|
+
renderNode(e) {
|
|
352
|
+
const t = [];
|
|
353
|
+
e.marks && e.marks.forEach((r) => {
|
|
354
|
+
const n = this.getMatchingMark(r);
|
|
355
|
+
n && n.tag !== "" && t.push(this.renderOpeningTag(n.tag));
|
|
297
356
|
});
|
|
298
|
-
const s = this.getMatchingNode(
|
|
299
|
-
return s && s.tag &&
|
|
300
|
-
|
|
301
|
-
}) :
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
}),
|
|
305
|
-
}
|
|
306
|
-
renderTag(
|
|
307
|
-
return
|
|
357
|
+
const s = this.getMatchingNode(e);
|
|
358
|
+
return s && s.tag && t.push(this.renderOpeningTag(s.tag)), e.content ? e.content.forEach((r) => {
|
|
359
|
+
t.push(this.renderNode(r));
|
|
360
|
+
}) : e.text ? t.push(me(e.text)) : s && s.singleTag ? t.push(this.renderTag(s.singleTag, " /")) : s && s.html ? t.push(s.html) : e.type === "emoji" && t.push(this.renderEmoji(e)), s && s.tag && t.push(this.renderClosingTag(s.tag)), e.marks && e.marks.slice(0).reverse().forEach((r) => {
|
|
361
|
+
const n = this.getMatchingMark(r);
|
|
362
|
+
n && n.tag !== "" && t.push(this.renderClosingTag(n.tag));
|
|
363
|
+
}), t.join("");
|
|
364
|
+
}
|
|
365
|
+
renderTag(e, t) {
|
|
366
|
+
return e.constructor === String ? `<${e}${t}>` : e.map((s) => {
|
|
308
367
|
if (s.constructor === String)
|
|
309
|
-
return `<${s}${
|
|
368
|
+
return `<${s}${t}>`;
|
|
310
369
|
{
|
|
311
370
|
let r = `<${s.tag}`;
|
|
312
371
|
if (s.attrs)
|
|
313
|
-
for (const
|
|
314
|
-
const
|
|
315
|
-
|
|
372
|
+
for (const n in s.attrs) {
|
|
373
|
+
const i = s.attrs[n];
|
|
374
|
+
i !== null && (r += ` ${n}="${i}"`);
|
|
316
375
|
}
|
|
317
|
-
return `${r}${
|
|
376
|
+
return `${r}${t}>`;
|
|
318
377
|
}
|
|
319
378
|
}).join("");
|
|
320
379
|
}
|
|
321
|
-
renderOpeningTag(
|
|
322
|
-
return this.renderTag(
|
|
380
|
+
renderOpeningTag(e) {
|
|
381
|
+
return this.renderTag(e, "");
|
|
323
382
|
}
|
|
324
|
-
renderClosingTag(
|
|
325
|
-
return
|
|
383
|
+
renderClosingTag(e) {
|
|
384
|
+
return e.constructor === String ? `</${e}>` : e.slice(0).reverse().map((t) => t.constructor === String ? `</${t}>` : `</${t.tag}>`).join("");
|
|
326
385
|
}
|
|
327
|
-
getMatchingNode(
|
|
328
|
-
const
|
|
329
|
-
if (typeof
|
|
330
|
-
return e
|
|
386
|
+
getMatchingNode(e) {
|
|
387
|
+
const t = this.nodes[e.type];
|
|
388
|
+
if (typeof t == "function")
|
|
389
|
+
return t(e);
|
|
331
390
|
}
|
|
332
|
-
getMatchingMark(
|
|
333
|
-
const
|
|
334
|
-
if (typeof
|
|
335
|
-
return e
|
|
391
|
+
getMatchingMark(e) {
|
|
392
|
+
const t = this.marks[e.type];
|
|
393
|
+
if (typeof t == "function")
|
|
394
|
+
return t(e);
|
|
336
395
|
}
|
|
337
|
-
renderEmoji(
|
|
338
|
-
if (
|
|
339
|
-
return
|
|
340
|
-
const
|
|
396
|
+
renderEmoji(e) {
|
|
397
|
+
if (e.attrs.emoji)
|
|
398
|
+
return e.attrs.emoji;
|
|
399
|
+
const t = [
|
|
341
400
|
{
|
|
342
401
|
tag: "img",
|
|
343
402
|
attrs: {
|
|
344
|
-
src:
|
|
403
|
+
src: e.attrs.fallbackImage,
|
|
345
404
|
draggable: "false",
|
|
346
405
|
loading: "lazy",
|
|
347
406
|
align: "absmiddle"
|
|
348
407
|
}
|
|
349
408
|
}
|
|
350
409
|
];
|
|
351
|
-
return this.renderTag(
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
class $ {
|
|
355
|
-
constructor() {
|
|
356
|
-
h(this, "isCDNUrl", (t = "") => t.indexOf("/cdn/") > -1), h(this, "getOptionsPage", (t, e = 25, s = 1) => ({
|
|
357
|
-
...t,
|
|
358
|
-
per_page: e,
|
|
359
|
-
page: s
|
|
360
|
-
})), h(this, "delay", (t) => new Promise((e) => setTimeout(e, t))), h(this, "arrayFrom", (t = 0, e) => [...Array(t)].map(e)), h(this, "range", (t = 0, e = t) => {
|
|
361
|
-
const s = Math.abs(e - t) || 0, r = t < e ? 1 : -1;
|
|
362
|
-
return this.arrayFrom(s, (i, n) => n * r + t);
|
|
363
|
-
}), h(this, "asyncMap", async (t, e) => Promise.all(t.map(e))), h(this, "flatMap", (t = [], e) => t.map(e).reduce((s, r) => [...s, ...r], []));
|
|
364
|
-
}
|
|
365
|
-
/**
|
|
366
|
-
* @method stringify
|
|
367
|
-
* @param {Object} params
|
|
368
|
-
* @param {String} prefix
|
|
369
|
-
* @param {Boolean} isArray
|
|
370
|
-
* @return {String} Stringified object
|
|
371
|
-
*/
|
|
372
|
-
stringify(t, e, s) {
|
|
373
|
-
const r = [];
|
|
374
|
-
for (const i in t) {
|
|
375
|
-
if (!Object.prototype.hasOwnProperty.call(t, i))
|
|
376
|
-
continue;
|
|
377
|
-
const n = t[i], c = s ? "" : encodeURIComponent(i);
|
|
378
|
-
let a;
|
|
379
|
-
typeof n == "object" ? a = this.stringify(
|
|
380
|
-
n,
|
|
381
|
-
e ? e + encodeURIComponent("[" + c + "]") : c,
|
|
382
|
-
Array.isArray(n)
|
|
383
|
-
) : a = (e ? e + encodeURIComponent("[" + c + "]") : c) + "=" + encodeURIComponent(n), r.push(a);
|
|
384
|
-
}
|
|
385
|
-
return r.join("&");
|
|
386
|
-
}
|
|
387
|
-
/**
|
|
388
|
-
* @method getRegionURL
|
|
389
|
-
* @param {String} regionCode region code, could be eu, us or cn
|
|
390
|
-
* @return {String} The base URL of the region
|
|
391
|
-
*/
|
|
392
|
-
getRegionURL(t) {
|
|
393
|
-
const e = "api.storyblok.com", s = "api-us.storyblok.com", r = "app.storyblokchina.cn";
|
|
394
|
-
switch (t) {
|
|
395
|
-
case "us":
|
|
396
|
-
return s;
|
|
397
|
-
case "cn":
|
|
398
|
-
return r;
|
|
399
|
-
default:
|
|
400
|
-
return e;
|
|
401
|
-
}
|
|
410
|
+
return this.renderTag(t, " /");
|
|
402
411
|
}
|
|
403
412
|
}
|
|
404
|
-
class
|
|
405
|
-
constructor(
|
|
406
|
-
h(this, "baseURL"), h(this, "timeout"), h(this, "headers"), h(this, "responseInterceptor"), h(this, "fetch"), h(this, "ejectInterceptor"), h(this, "url"), h(this, "parameters"), this.baseURL =
|
|
413
|
+
class ye {
|
|
414
|
+
constructor(e) {
|
|
415
|
+
h(this, "baseURL"), h(this, "timeout"), h(this, "headers"), h(this, "responseInterceptor"), h(this, "fetch"), h(this, "ejectInterceptor"), h(this, "url"), h(this, "parameters"), 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 = {};
|
|
407
416
|
}
|
|
408
417
|
/**
|
|
409
418
|
*
|
|
@@ -411,50 +420,50 @@ class yt {
|
|
|
411
420
|
* @param params ISbStoriesParams
|
|
412
421
|
* @returns Promise<ISbResponse | Error>
|
|
413
422
|
*/
|
|
414
|
-
get(
|
|
415
|
-
return this.url =
|
|
423
|
+
get(e, t) {
|
|
424
|
+
return this.url = e, this.parameters = t, this._methodHandler("get");
|
|
416
425
|
}
|
|
417
|
-
post(
|
|
418
|
-
return this.url =
|
|
426
|
+
post(e, t) {
|
|
427
|
+
return this.url = e, this.parameters = t, this._methodHandler("post");
|
|
419
428
|
}
|
|
420
|
-
put(
|
|
421
|
-
return this.url =
|
|
429
|
+
put(e, t) {
|
|
430
|
+
return this.url = e, this.parameters = t, this._methodHandler("put");
|
|
422
431
|
}
|
|
423
|
-
delete(
|
|
424
|
-
return this.url =
|
|
432
|
+
delete(e, t) {
|
|
433
|
+
return this.url = e, this.parameters = t, this._methodHandler("delete");
|
|
425
434
|
}
|
|
426
|
-
async _responseHandler(
|
|
427
|
-
const
|
|
435
|
+
async _responseHandler(e) {
|
|
436
|
+
const t = [], s = {
|
|
428
437
|
data: {},
|
|
429
438
|
headers: {},
|
|
430
439
|
status: 0,
|
|
431
440
|
statusText: ""
|
|
432
441
|
};
|
|
433
|
-
|
|
442
|
+
e.status !== 204 && await e.json().then((r) => {
|
|
434
443
|
s.data = r;
|
|
435
444
|
});
|
|
436
|
-
for (const r of
|
|
437
|
-
|
|
438
|
-
return s.headers = { ...
|
|
439
|
-
}
|
|
440
|
-
async _methodHandler(
|
|
441
|
-
let
|
|
442
|
-
if (
|
|
443
|
-
const a = new
|
|
444
|
-
|
|
445
|
+
for (const r of e.headers.entries())
|
|
446
|
+
t[r[0]] = r[1];
|
|
447
|
+
return s.headers = { ...t }, s.status = e.status, s.statusText = e.statusText, s;
|
|
448
|
+
}
|
|
449
|
+
async _methodHandler(e) {
|
|
450
|
+
let t = `${this.baseURL}${this.url}`, s = null;
|
|
451
|
+
if (e === "get") {
|
|
452
|
+
const a = new b();
|
|
453
|
+
t = `${this.baseURL}${this.url}?${a.stringify(
|
|
445
454
|
this.parameters
|
|
446
455
|
)}`;
|
|
447
456
|
} else
|
|
448
457
|
s = JSON.stringify(this.parameters);
|
|
449
|
-
const r = new URL(
|
|
458
|
+
const r = new URL(t), n = new AbortController(), { signal: i } = n;
|
|
450
459
|
let c;
|
|
451
|
-
this.timeout && (c = setTimeout(() =>
|
|
460
|
+
this.timeout && (c = setTimeout(() => n.abort(), this.timeout));
|
|
452
461
|
try {
|
|
453
462
|
const a = await this.fetch(`${r}`, {
|
|
454
|
-
method:
|
|
463
|
+
method: e,
|
|
455
464
|
headers: this.headers,
|
|
456
465
|
body: s,
|
|
457
|
-
signal:
|
|
466
|
+
signal: i
|
|
458
467
|
});
|
|
459
468
|
this.timeout && clearTimeout(c);
|
|
460
469
|
const l = await this._responseHandler(a);
|
|
@@ -468,109 +477,112 @@ class yt {
|
|
|
468
477
|
eject() {
|
|
469
478
|
this.ejectInterceptor = !0;
|
|
470
479
|
}
|
|
471
|
-
_statusHandler(
|
|
472
|
-
const
|
|
480
|
+
_statusHandler(e) {
|
|
481
|
+
const t = /20[0-6]/g;
|
|
473
482
|
return new Promise((s, r) => {
|
|
474
|
-
if (
|
|
475
|
-
return s(
|
|
476
|
-
const
|
|
477
|
-
message: new Error(
|
|
478
|
-
status:
|
|
479
|
-
response: Array.isArray(
|
|
483
|
+
if (t.test(`${e.status}`))
|
|
484
|
+
return s(e);
|
|
485
|
+
const n = {
|
|
486
|
+
message: new Error(e.statusText),
|
|
487
|
+
status: e.status,
|
|
488
|
+
response: Array.isArray(e.data) ? e.data[0] : e.data.error || e.data.slug
|
|
480
489
|
};
|
|
481
|
-
r(
|
|
490
|
+
r(n);
|
|
482
491
|
});
|
|
483
492
|
}
|
|
484
493
|
}
|
|
485
|
-
const
|
|
494
|
+
const x = "SB-Agent", $ = {
|
|
486
495
|
defaultAgentName: "SB-JS-CLIENT",
|
|
487
496
|
defaultAgentVersion: "SB-Agent-Version",
|
|
488
|
-
packageVersion: "
|
|
497
|
+
packageVersion: "5.14.0"
|
|
489
498
|
};
|
|
490
499
|
let y = {};
|
|
491
500
|
const f = {};
|
|
492
|
-
class
|
|
501
|
+
class be {
|
|
493
502
|
/**
|
|
494
503
|
*
|
|
495
504
|
* @param config ISbConfig interface
|
|
496
505
|
* @param endpoint string, optional
|
|
497
506
|
*/
|
|
498
|
-
constructor(
|
|
507
|
+
constructor(e, t) {
|
|
499
508
|
h(this, "client"), h(this, "maxRetries"), h(this, "throttle"), h(this, "accessToken"), h(this, "cache"), h(this, "helpers"), h(this, "resolveCounter"), h(this, "relations"), h(this, "links"), h(this, "richTextResolver"), h(this, "resolveNestedRelations");
|
|
500
|
-
let s =
|
|
509
|
+
let s = e.endpoint || t;
|
|
501
510
|
if (!s) {
|
|
502
|
-
const
|
|
503
|
-
|
|
511
|
+
const i = new b().getRegionURL, c = e.https === !1 ? "http" : "https";
|
|
512
|
+
e.oauthToken ? s = `${c}://${i(e.region)}/v1` : s = `${c}://${i(e.region)}/v2`;
|
|
504
513
|
}
|
|
505
514
|
const r = new Headers();
|
|
506
|
-
if (r.set("Content-Type", "application/json"), r.set("Accept", "application/json"),
|
|
507
|
-
for (const
|
|
508
|
-
r.set(
|
|
509
|
-
r.has(
|
|
510
|
-
|
|
511
|
-
|
|
515
|
+
if (r.set("Content-Type", "application/json"), r.set("Accept", "application/json"), e.headers)
|
|
516
|
+
for (const i in e.headers)
|
|
517
|
+
r.set(i, e.headers[i]);
|
|
518
|
+
r.has(x) || (r.set(x, $.defaultAgentName), r.set(
|
|
519
|
+
$.defaultAgentVersion,
|
|
520
|
+
$.packageVersion
|
|
521
|
+
));
|
|
522
|
+
let n = 5;
|
|
523
|
+
e.oauthToken && (r.set("Authorization", e.oauthToken), n = 3), e.rateLimit && (n = e.rateLimit), e.richTextSchema ? this.richTextResolver = new k(e.richTextSchema) : this.richTextResolver = new k(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 5, this.throttle = V(this.throttledRequest, n, 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new b(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.client = new ye({
|
|
512
524
|
baseURL: s,
|
|
513
|
-
timeout:
|
|
525
|
+
timeout: e.timeout || 0,
|
|
514
526
|
headers: r,
|
|
515
|
-
responseInterceptor:
|
|
516
|
-
fetch:
|
|
527
|
+
responseInterceptor: e.responseInterceptor,
|
|
528
|
+
fetch: e.fetch
|
|
517
529
|
});
|
|
518
530
|
}
|
|
519
|
-
setComponentResolver(
|
|
520
|
-
this.richTextResolver.addNode("blok", (
|
|
531
|
+
setComponentResolver(e) {
|
|
532
|
+
this.richTextResolver.addNode("blok", (t) => {
|
|
521
533
|
let s = "";
|
|
522
|
-
return
|
|
523
|
-
s +=
|
|
534
|
+
return t.attrs.body && t.attrs.body.forEach((r) => {
|
|
535
|
+
s += e(r.component, r);
|
|
524
536
|
}), {
|
|
525
537
|
html: s
|
|
526
538
|
};
|
|
527
539
|
});
|
|
528
540
|
}
|
|
529
|
-
parseParams(
|
|
530
|
-
return
|
|
541
|
+
parseParams(e) {
|
|
542
|
+
return e.version || (e.version = "published"), e.token || (e.token = this.getToken()), e.cv || (e.cv = f[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), e;
|
|
531
543
|
}
|
|
532
|
-
factoryParamOptions(
|
|
533
|
-
return this.helpers.isCDNUrl(
|
|
544
|
+
factoryParamOptions(e, t) {
|
|
545
|
+
return this.helpers.isCDNUrl(e) ? this.parseParams(t) : t;
|
|
534
546
|
}
|
|
535
|
-
makeRequest(
|
|
536
|
-
const
|
|
537
|
-
|
|
538
|
-
this.helpers.getOptionsPage(
|
|
547
|
+
makeRequest(e, t, s, r) {
|
|
548
|
+
const n = this.factoryParamOptions(
|
|
549
|
+
e,
|
|
550
|
+
this.helpers.getOptionsPage(t, s, r)
|
|
539
551
|
);
|
|
540
|
-
return this.cacheResponse(
|
|
552
|
+
return this.cacheResponse(e, n);
|
|
541
553
|
}
|
|
542
|
-
get(
|
|
543
|
-
|
|
544
|
-
const s = `/${
|
|
554
|
+
get(e, t) {
|
|
555
|
+
t || (t = {});
|
|
556
|
+
const s = `/${e}`, r = this.factoryParamOptions(s, t);
|
|
545
557
|
return this.cacheResponse(s, r);
|
|
546
558
|
}
|
|
547
|
-
async getAll(
|
|
548
|
-
const r = (
|
|
559
|
+
async getAll(e, t, s) {
|
|
560
|
+
const r = (t == null ? void 0 : t.per_page) || 25, n = `/${e}`, i = n.split("/"), c = s || i[i.length - 1], a = 1, l = await this.makeRequest(n, t, r, a), u = l.total ? Math.ceil(l.total / r) : 1, p = await this.helpers.asyncMap(
|
|
549
561
|
this.helpers.range(a, u),
|
|
550
|
-
(g) => this.makeRequest(
|
|
562
|
+
(g) => this.makeRequest(n, t, r, g + 1)
|
|
551
563
|
);
|
|
552
564
|
return this.helpers.flatMap(
|
|
553
|
-
[l, ...
|
|
565
|
+
[l, ...p],
|
|
554
566
|
(g) => Object.values(g.data[c])
|
|
555
567
|
);
|
|
556
568
|
}
|
|
557
|
-
post(
|
|
558
|
-
const s = `/${
|
|
559
|
-
return Promise.resolve(this.throttle("post", s,
|
|
569
|
+
post(e, t) {
|
|
570
|
+
const s = `/${e}`;
|
|
571
|
+
return Promise.resolve(this.throttle("post", s, t));
|
|
560
572
|
}
|
|
561
|
-
put(
|
|
562
|
-
const s = `/${
|
|
563
|
-
return Promise.resolve(this.throttle("put", s,
|
|
573
|
+
put(e, t) {
|
|
574
|
+
const s = `/${e}`;
|
|
575
|
+
return Promise.resolve(this.throttle("put", s, t));
|
|
564
576
|
}
|
|
565
|
-
delete(
|
|
566
|
-
const s = `/${
|
|
567
|
-
return Promise.resolve(this.throttle("delete", s,
|
|
577
|
+
delete(e, t) {
|
|
578
|
+
const s = `/${e}`;
|
|
579
|
+
return Promise.resolve(this.throttle("delete", s, t));
|
|
568
580
|
}
|
|
569
|
-
getStories(
|
|
570
|
-
return this.get("cdn/stories",
|
|
581
|
+
getStories(e) {
|
|
582
|
+
return this.get("cdn/stories", e);
|
|
571
583
|
}
|
|
572
|
-
getStory(
|
|
573
|
-
return this.get(`cdn/stories/${
|
|
584
|
+
getStory(e, t) {
|
|
585
|
+
return this.get(`cdn/stories/${e}`, t);
|
|
574
586
|
}
|
|
575
587
|
getToken() {
|
|
576
588
|
return this.accessToken;
|
|
@@ -578,154 +590,150 @@ class bt {
|
|
|
578
590
|
ejectInterceptor() {
|
|
579
591
|
this.client.eject();
|
|
580
592
|
}
|
|
581
|
-
_cleanCopy(
|
|
582
|
-
return JSON.parse(JSON.stringify(
|
|
593
|
+
_cleanCopy(e) {
|
|
594
|
+
return JSON.parse(JSON.stringify(e));
|
|
583
595
|
}
|
|
584
|
-
_insertLinks(
|
|
585
|
-
const r = t
|
|
596
|
+
_insertLinks(e, t, s) {
|
|
597
|
+
const r = e[t];
|
|
586
598
|
r && r.fieldtype == "multilink" && r.linktype == "story" && typeof r.id == "string" && this.links[s][r.id] ? r.story = this._cleanCopy(this.links[s][r.id]) : r && r.linktype === "story" && typeof r.uuid == "string" && this.links[s][r.uuid] && (r.story = this._cleanCopy(this.links[s][r.uuid]));
|
|
587
599
|
}
|
|
588
|
-
_insertRelations(
|
|
589
|
-
if (s.indexOf(`${
|
|
590
|
-
if (typeof t
|
|
591
|
-
this.relations[r][t
|
|
592
|
-
this.relations[r][t
|
|
600
|
+
_insertRelations(e, t, s, r) {
|
|
601
|
+
if (s.indexOf(`${e.component}.${t}`) > -1) {
|
|
602
|
+
if (typeof e[t] == "string")
|
|
603
|
+
this.relations[r][e[t]] && (e[t] = this._cleanCopy(
|
|
604
|
+
this.relations[r][e[t]]
|
|
593
605
|
));
|
|
594
|
-
else if (t
|
|
595
|
-
const
|
|
596
|
-
t
|
|
597
|
-
this.relations[r][
|
|
598
|
-
}), t
|
|
606
|
+
else if (e[t] && e[t].constructor === Array) {
|
|
607
|
+
const n = [];
|
|
608
|
+
e[t].forEach((i) => {
|
|
609
|
+
this.relations[r][i] && n.push(this._cleanCopy(this.relations[r][i]));
|
|
610
|
+
}), e[t] = n;
|
|
599
611
|
}
|
|
600
612
|
}
|
|
601
613
|
}
|
|
602
|
-
iterateTree(
|
|
603
|
-
const r = (
|
|
604
|
-
if (
|
|
605
|
-
if (
|
|
606
|
-
for (let
|
|
607
|
-
r(i
|
|
608
|
-
else if (
|
|
609
|
-
if (
|
|
614
|
+
iterateTree(e, t, s) {
|
|
615
|
+
const r = (n) => {
|
|
616
|
+
if (n != null) {
|
|
617
|
+
if (n.constructor === Array)
|
|
618
|
+
for (let i = 0; i < n.length; i++)
|
|
619
|
+
r(n[i]);
|
|
620
|
+
else if (n.constructor === Object) {
|
|
621
|
+
if (n._stopResolving)
|
|
610
622
|
return;
|
|
611
|
-
for (const
|
|
612
|
-
(
|
|
613
|
-
i,
|
|
623
|
+
for (const i in n)
|
|
624
|
+
(n.component && n._uid || n.type === "link") && (this._insertRelations(
|
|
614
625
|
n,
|
|
615
|
-
|
|
626
|
+
i,
|
|
627
|
+
t,
|
|
616
628
|
s
|
|
617
629
|
), this._insertLinks(
|
|
618
|
-
i,
|
|
619
630
|
n,
|
|
631
|
+
i,
|
|
620
632
|
s
|
|
621
|
-
)), r(i
|
|
633
|
+
)), r(n[i]);
|
|
622
634
|
}
|
|
623
635
|
}
|
|
624
636
|
};
|
|
625
|
-
r(
|
|
637
|
+
r(e.content);
|
|
626
638
|
}
|
|
627
|
-
async resolveLinks(
|
|
639
|
+
async resolveLinks(e, t, s) {
|
|
628
640
|
let r = [];
|
|
629
|
-
if (
|
|
630
|
-
const
|
|
631
|
-
for (let a = 0; a <
|
|
632
|
-
const l = Math.min(
|
|
633
|
-
|
|
641
|
+
if (e.link_uuids) {
|
|
642
|
+
const n = e.link_uuids.length, i = [], c = 50;
|
|
643
|
+
for (let a = 0; a < n; a += c) {
|
|
644
|
+
const l = Math.min(n, a + c);
|
|
645
|
+
i.push(e.link_uuids.slice(a, l));
|
|
634
646
|
}
|
|
635
|
-
for (let a = 0; a <
|
|
647
|
+
for (let a = 0; a < i.length; a++)
|
|
636
648
|
(await this.getStories({
|
|
637
649
|
per_page: c,
|
|
638
|
-
language:
|
|
639
|
-
version:
|
|
640
|
-
by_uuids:
|
|
650
|
+
language: t.language,
|
|
651
|
+
version: t.version,
|
|
652
|
+
by_uuids: i[a].join(",")
|
|
641
653
|
})).data.stories.forEach(
|
|
642
654
|
(l) => {
|
|
643
655
|
r.push(l);
|
|
644
656
|
}
|
|
645
657
|
);
|
|
646
658
|
} else
|
|
647
|
-
r =
|
|
648
|
-
r.forEach((
|
|
649
|
-
this.links[s][
|
|
650
|
-
...
|
|
659
|
+
r = e.links;
|
|
660
|
+
r.forEach((n) => {
|
|
661
|
+
this.links[s][n.uuid] = {
|
|
662
|
+
...n,
|
|
651
663
|
_stopResolving: !0
|
|
652
664
|
};
|
|
653
665
|
});
|
|
654
666
|
}
|
|
655
|
-
async resolveRelations(
|
|
667
|
+
async resolveRelations(e, t, s) {
|
|
656
668
|
let r = [];
|
|
657
|
-
if (
|
|
658
|
-
const
|
|
659
|
-
for (let a = 0; a <
|
|
660
|
-
const l = Math.min(
|
|
661
|
-
|
|
669
|
+
if (e.rel_uuids) {
|
|
670
|
+
const n = e.rel_uuids.length, i = [], c = 50;
|
|
671
|
+
for (let a = 0; a < n; a += c) {
|
|
672
|
+
const l = Math.min(n, a + c);
|
|
673
|
+
i.push(e.rel_uuids.slice(a, l));
|
|
662
674
|
}
|
|
663
|
-
for (let a = 0; a <
|
|
675
|
+
for (let a = 0; a < i.length; a++)
|
|
664
676
|
(await this.getStories({
|
|
665
677
|
per_page: c,
|
|
666
|
-
language:
|
|
667
|
-
version:
|
|
668
|
-
by_uuids:
|
|
678
|
+
language: t.language,
|
|
679
|
+
version: t.version,
|
|
680
|
+
by_uuids: i[a].join(",")
|
|
669
681
|
})).data.stories.forEach((l) => {
|
|
670
682
|
r.push(l);
|
|
671
683
|
});
|
|
672
684
|
} else
|
|
673
|
-
r =
|
|
674
|
-
r && r.length > 0 && r.forEach((
|
|
675
|
-
this.relations[s][
|
|
676
|
-
...
|
|
685
|
+
r = e.rels;
|
|
686
|
+
r && r.length > 0 && r.forEach((n) => {
|
|
687
|
+
this.relations[s][n.uuid] = {
|
|
688
|
+
...n,
|
|
677
689
|
_stopResolving: !0
|
|
678
690
|
};
|
|
679
691
|
});
|
|
680
692
|
}
|
|
681
|
-
async resolveStories(
|
|
682
|
-
var r,
|
|
683
|
-
let
|
|
684
|
-
if (this.links[s] = {}, this.relations[s] = {}, typeof
|
|
693
|
+
async resolveStories(e, t, s) {
|
|
694
|
+
var r, n;
|
|
695
|
+
let i = [];
|
|
696
|
+
if (this.links[s] = {}, this.relations[s] = {}, 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, s)), t.resolve_links && ["1", "story", "url", "link"].indexOf(t.resolve_links) > -1 && ((r = e.links) != null && r.length || (n = e.link_uuids) != null && n.length) && await this.resolveLinks(e, t, s), this.resolveNestedRelations)
|
|
685
697
|
for (const c in this.relations[s])
|
|
686
698
|
this.iterateTree(
|
|
687
699
|
this.relations[s][c],
|
|
688
|
-
|
|
700
|
+
i,
|
|
689
701
|
s
|
|
690
702
|
);
|
|
691
|
-
|
|
692
|
-
this.iterateTree(c,
|
|
703
|
+
e.story ? this.iterateTree(e.story, i, s) : e.stories.forEach((c) => {
|
|
704
|
+
this.iterateTree(c, i, s);
|
|
693
705
|
}), delete this.links[s], delete this.relations[s];
|
|
694
706
|
}
|
|
695
|
-
async cacheResponse(
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
707
|
+
async cacheResponse(e, t, s) {
|
|
708
|
+
(typeof s > "u" || !s) && (s = 0);
|
|
709
|
+
const r = this.helpers.stringify({ url: e, params: t }), n = this.cacheProvider();
|
|
710
|
+
if (this.cache.clear === "auto" && t.version === "draft" && await this.flushCache(), t.version === "published" && e != "/cdn/spaces/me") {
|
|
711
|
+
const i = await n.get(r);
|
|
712
|
+
if (i)
|
|
713
|
+
return Promise.resolve(i);
|
|
701
714
|
}
|
|
702
|
-
return new Promise((
|
|
715
|
+
return new Promise(async (i, c) => {
|
|
716
|
+
var a;
|
|
703
717
|
try {
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
return e.version === "published" && t != "/cdn/spaces/me" && await i.set(r, u), u.data.cv && e.token && (e.version == "draft" && f[e.token] != u.data.cv && await this.flushCache(), f[e.token] = u.data.cv), n(u);
|
|
719
|
-
} catch (l) {
|
|
720
|
-
return c(l);
|
|
721
|
-
}
|
|
722
|
-
})();
|
|
723
|
-
} catch {
|
|
718
|
+
const l = await this.throttle("get", e, t);
|
|
719
|
+
let u = { data: l.data, headers: l.headers };
|
|
720
|
+
if ((a = l.headers) != null && a["per-page"] && (u = Object.assign({}, u, {
|
|
721
|
+
perPage: l.headers["per-page"] ? parseInt(l.headers["per-page"]) : 0,
|
|
722
|
+
total: l.headers["per-page"] ? parseInt(l.headers.total) : 0
|
|
723
|
+
})), u.data.story || u.data.stories) {
|
|
724
|
+
const p = this.resolveCounter = ++this.resolveCounter % 1e3;
|
|
725
|
+
await this.resolveStories(u.data, t, `${p}`);
|
|
726
|
+
}
|
|
727
|
+
return t.version === "published" && e != "/cdn/spaces/me" && await n.set(r, u), u.data.cv && t.token && (t.version == "draft" && f[t.token] != u.data.cv && await this.flushCache(), f[t.token] = u.data.cv), i(u);
|
|
728
|
+
} catch (l) {
|
|
729
|
+
if (l.response && l.response.status === 429 && (s = s ? s + 1 : 0, s < this.maxRetries))
|
|
730
|
+
return console.log(`Hit rate limit. Retrying in ${s} seconds.`), await this.helpers.delay(1e3 * s), this.cacheResponse(e, t, s).then(i).catch(c);
|
|
731
|
+
c(l.message);
|
|
724
732
|
}
|
|
725
733
|
});
|
|
726
734
|
}
|
|
727
|
-
throttledRequest(
|
|
728
|
-
return this.client[
|
|
735
|
+
throttledRequest(e, t, s) {
|
|
736
|
+
return this.client[e](t, s);
|
|
729
737
|
}
|
|
730
738
|
cacheVersions() {
|
|
731
739
|
return f;
|
|
@@ -733,21 +741,21 @@ class bt {
|
|
|
733
741
|
cacheVersion() {
|
|
734
742
|
return f[this.accessToken];
|
|
735
743
|
}
|
|
736
|
-
setCacheVersion(
|
|
737
|
-
this.accessToken && (f[this.accessToken] =
|
|
744
|
+
setCacheVersion(e) {
|
|
745
|
+
this.accessToken && (f[this.accessToken] = e);
|
|
738
746
|
}
|
|
739
747
|
cacheProvider() {
|
|
740
748
|
switch (this.cache.type) {
|
|
741
749
|
case "memory":
|
|
742
750
|
return {
|
|
743
|
-
get(
|
|
744
|
-
return Promise.resolve(y[
|
|
751
|
+
get(e) {
|
|
752
|
+
return Promise.resolve(y[e]);
|
|
745
753
|
},
|
|
746
754
|
getAll() {
|
|
747
755
|
return Promise.resolve(y);
|
|
748
756
|
},
|
|
749
|
-
set(
|
|
750
|
-
return y[
|
|
757
|
+
set(e, t) {
|
|
758
|
+
return y[e] = t, Promise.resolve(void 0);
|
|
751
759
|
},
|
|
752
760
|
flush() {
|
|
753
761
|
return y = {}, Promise.resolve(void 0);
|
|
@@ -777,94 +785,91 @@ class bt {
|
|
|
777
785
|
return await this.cacheProvider().flush(), this;
|
|
778
786
|
}
|
|
779
787
|
}
|
|
780
|
-
const
|
|
781
|
-
const { apiOptions:
|
|
782
|
-
if (!
|
|
788
|
+
const Se = (o = {}) => {
|
|
789
|
+
const { apiOptions: e } = o;
|
|
790
|
+
if (!e.accessToken) {
|
|
783
791
|
console.error(
|
|
784
792
|
"You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication"
|
|
785
793
|
);
|
|
786
794
|
return;
|
|
787
795
|
}
|
|
788
|
-
return { storyblokApi: new
|
|
789
|
-
},
|
|
796
|
+
return { storyblokApi: new be(e) };
|
|
797
|
+
}, ke = (o) => {
|
|
790
798
|
if (typeof o != "object" || typeof o._editable > "u")
|
|
791
799
|
return {};
|
|
792
|
-
const
|
|
800
|
+
const e = JSON.parse(
|
|
793
801
|
o._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
|
|
794
802
|
);
|
|
795
803
|
return {
|
|
796
|
-
"data-blok-c": JSON.stringify(
|
|
797
|
-
"data-blok-uid":
|
|
804
|
+
"data-blok-c": JSON.stringify(e),
|
|
805
|
+
"data-blok-uid": e.id + "-" + e.uid
|
|
798
806
|
};
|
|
799
807
|
};
|
|
800
|
-
let
|
|
801
|
-
const
|
|
808
|
+
let R;
|
|
809
|
+
const ve = "https://app.storyblok.com/f/storyblok-v2-latest.js", we = (o, e, t = {}) => {
|
|
802
810
|
var s;
|
|
803
|
-
const r = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u",
|
|
811
|
+
const r = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", n = +new URL((s = window.location) == null ? void 0 : s.href).searchParams.get(
|
|
804
812
|
"_storyblok"
|
|
805
813
|
) === o;
|
|
806
|
-
if (!(!r || !
|
|
814
|
+
if (!(!r || !n)) {
|
|
807
815
|
if (!o) {
|
|
808
816
|
console.warn("Story ID is not defined. Please provide a valid ID.");
|
|
809
817
|
return;
|
|
810
818
|
}
|
|
811
819
|
window.storyblokRegisterEvent(() => {
|
|
812
|
-
new window.StoryblokBridge(
|
|
813
|
-
|
|
820
|
+
new window.StoryblokBridge(t).on(["input", "published", "change"], (i) => {
|
|
821
|
+
i.action === "input" && i.story.id === o ? e(i.story) : (i.action === "change" || i.action === "published") && i.storyId === o && window.location.reload();
|
|
814
822
|
});
|
|
815
823
|
});
|
|
816
824
|
}
|
|
817
|
-
}, $
|
|
818
|
-
var
|
|
825
|
+
}, $e = (o = {}) => {
|
|
826
|
+
var e, t;
|
|
819
827
|
const {
|
|
820
828
|
bridge: s,
|
|
821
829
|
accessToken: r,
|
|
822
|
-
use:
|
|
823
|
-
apiOptions:
|
|
830
|
+
use: n = [],
|
|
831
|
+
apiOptions: i = {},
|
|
824
832
|
richText: c = {}
|
|
825
833
|
} = o;
|
|
826
|
-
|
|
827
|
-
const a = { bridge: s, apiOptions:
|
|
834
|
+
i.accessToken = i.accessToken || r;
|
|
835
|
+
const a = { bridge: s, apiOptions: i };
|
|
828
836
|
let l = {};
|
|
829
|
-
|
|
830
|
-
l = { ...l, ...
|
|
837
|
+
n.forEach((p) => {
|
|
838
|
+
l = { ...l, ...p(a) };
|
|
831
839
|
});
|
|
832
|
-
const u = !(typeof window > "u") && ((
|
|
833
|
-
return s !== !1 && u &&
|
|
834
|
-
},
|
|
835
|
-
o.addNode("blok", (
|
|
840
|
+
const u = !(typeof window > "u") && ((t = (e = window.location) == null ? void 0 : e.search) == null ? void 0 : t.includes("_storyblok_tk"));
|
|
841
|
+
return s !== !1 && u && H(ve), R = new k(c.schema), c.resolver && P(R, c.resolver), l;
|
|
842
|
+
}, P = (o, e) => {
|
|
843
|
+
o.addNode("blok", (t) => {
|
|
836
844
|
let s = "";
|
|
837
|
-
return
|
|
838
|
-
s +=
|
|
845
|
+
return t.attrs.body.forEach((r) => {
|
|
846
|
+
s += e(r.component, r);
|
|
839
847
|
}), {
|
|
840
848
|
html: s
|
|
841
849
|
};
|
|
842
850
|
});
|
|
843
|
-
},
|
|
844
|
-
|
|
845
|
-
return !o || ((t = o == null ? void 0 : o.content) == null ? void 0 : t[0].type) !== "blok" && !((e = o == null ? void 0 : o.content) != null && e[0].content);
|
|
846
|
-
}, Pt = (o, t, e) => {
|
|
847
|
-
let s = e || _;
|
|
851
|
+
}, Re = (o) => !o || !(o != null && o.content.some((e) => e.content || e.type === "blok" || e.type === "horizontal_rule")), xe = (o, e, t) => {
|
|
852
|
+
let s = t || R;
|
|
848
853
|
if (!s) {
|
|
849
854
|
console.error(
|
|
850
855
|
"Please initialize the Storyblok SDK before calling the renderRichText function"
|
|
851
856
|
);
|
|
852
857
|
return;
|
|
853
858
|
}
|
|
854
|
-
return
|
|
855
|
-
},
|
|
859
|
+
return Re(o) ? "" : (e && (s = new k(e.schema), e.resolver && P(s, e.resolver)), s.render(o));
|
|
860
|
+
}, Te = /* @__PURE__ */ I({
|
|
856
861
|
__name: "StoryblokComponent",
|
|
857
862
|
props: {
|
|
858
863
|
blok: {}
|
|
859
864
|
},
|
|
860
865
|
setup(o) {
|
|
861
|
-
return (
|
|
866
|
+
return (e, t) => (A(), C(O(e.blok.component), N(M({ ...e.$props, ...e.$attrs })), null, 16));
|
|
862
867
|
}
|
|
863
|
-
}),
|
|
864
|
-
beforeMount(o,
|
|
865
|
-
if (
|
|
866
|
-
const
|
|
867
|
-
o.setAttribute("data-blok-c",
|
|
868
|
+
}), _e = {
|
|
869
|
+
beforeMount(o, e) {
|
|
870
|
+
if (e.value) {
|
|
871
|
+
const t = ke(e.value);
|
|
872
|
+
o.setAttribute("data-blok-c", t["data-blok-c"]), o.setAttribute("data-blok-uid", t["data-blok-uid"]), o.classList.add("storyblok__outline");
|
|
868
873
|
}
|
|
869
874
|
}
|
|
870
875
|
}, E = (o) => {
|
|
@@ -872,38 +877,38 @@ const kt = "https://app.storyblok.com/f/storyblok-v2-latest.js", wt = (o, t, e =
|
|
|
872
877
|
`);
|
|
873
878
|
};
|
|
874
879
|
let m = null;
|
|
875
|
-
const
|
|
876
|
-
const s =
|
|
877
|
-
if (
|
|
878
|
-
s.value && s.value.id &&
|
|
880
|
+
const Pe = () => (m || E("useStoryblokApi"), m), Ee = async (o, e = {}, t = {}) => {
|
|
881
|
+
const s = L(null);
|
|
882
|
+
if (z(() => {
|
|
883
|
+
s.value && s.value.id && we(
|
|
879
884
|
s.value.id,
|
|
880
885
|
(r) => s.value = r,
|
|
881
|
-
|
|
886
|
+
t
|
|
882
887
|
);
|
|
883
888
|
}), m) {
|
|
884
889
|
const { data: r } = await m.get(
|
|
885
890
|
`cdn/stories/${o}`,
|
|
886
|
-
|
|
891
|
+
e
|
|
887
892
|
);
|
|
888
893
|
s.value = r.story;
|
|
889
894
|
} else
|
|
890
895
|
E("useStoryblok");
|
|
891
896
|
return s;
|
|
892
|
-
},
|
|
893
|
-
install(o,
|
|
894
|
-
o.directive("editable",
|
|
895
|
-
const { storyblokApi:
|
|
896
|
-
m =
|
|
897
|
+
}, Ie = {
|
|
898
|
+
install(o, e = {}) {
|
|
899
|
+
o.directive("editable", _e), o.component("StoryblokComponent", Te);
|
|
900
|
+
const { storyblokApi: t } = $e(e);
|
|
901
|
+
m = t;
|
|
897
902
|
}
|
|
898
903
|
};
|
|
899
904
|
export {
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
905
|
+
k as RichTextResolver,
|
|
906
|
+
fe as RichTextSchema,
|
|
907
|
+
Te as StoryblokComponent,
|
|
908
|
+
Ie as StoryblokVue,
|
|
909
|
+
Se as apiPlugin,
|
|
910
|
+
xe as renderRichText,
|
|
911
|
+
Ee as useStoryblok,
|
|
912
|
+
Pe as useStoryblokApi,
|
|
913
|
+
we as useStoryblokBridge
|
|
909
914
|
};
|