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