@storyblok/vue 6.2.0 → 6.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -0
- package/dist/StoryblokComponent.vue.d.ts +1 -1
- package/dist/storyblok-vue.js +4 -4
- package/dist/storyblok-vue.mjs +422 -563
- package/package.json +6 -6
package/dist/storyblok-vue.mjs
CHANGED
|
@@ -1,86 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
import { defineComponent, openBlock, createBlock, resolveDynamicComponent, normalizeProps, guardReactiveProps, ref, onMounted } from "vue";
|
|
18
|
-
import e from "axios";
|
|
19
|
-
var __defProp2 = Object.defineProperty;
|
|
20
|
-
var __defProps = Object.defineProperties;
|
|
21
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
22
|
-
var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
|
|
23
|
-
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
24
|
-
var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
|
|
25
|
-
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
26
|
-
var __spreadValues2 = (a2, b) => {
|
|
27
|
-
for (var prop in b || (b = {}))
|
|
28
|
-
if (__hasOwnProp2.call(b, prop))
|
|
29
|
-
__defNormalProp2(a2, prop, b[prop]);
|
|
30
|
-
if (__getOwnPropSymbols2)
|
|
31
|
-
for (var prop of __getOwnPropSymbols2(b)) {
|
|
32
|
-
if (__propIsEnum2.call(b, prop))
|
|
33
|
-
__defNormalProp2(a2, prop, b[prop]);
|
|
34
|
-
}
|
|
35
|
-
return a2;
|
|
36
|
-
};
|
|
37
|
-
var __spreadProps = (a2, b) => __defProps(a2, __getOwnPropDescs(b));
|
|
38
|
-
let loaded = false;
|
|
39
|
-
const callbacks = [];
|
|
40
|
-
const loadBridge = (src) => {
|
|
41
|
-
return new Promise((resolve, reject) => {
|
|
42
|
-
if (typeof window === "undefined")
|
|
43
|
-
return;
|
|
44
|
-
window.storyblokRegisterEvent = (cb) => {
|
|
45
|
-
if (window.location === window.parent.location) {
|
|
46
|
-
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
if (!loaded)
|
|
50
|
-
callbacks.push(cb);
|
|
51
|
-
else
|
|
52
|
-
cb();
|
|
53
|
-
};
|
|
54
|
-
if (document.getElementById("storyblok-javascript-bridge"))
|
|
1
|
+
import { defineComponent as E, openBlock as O, createBlock as S, resolveDynamicComponent as P, normalizeProps as j, guardReactiveProps as A, ref as C, onMounted as M } from "vue";
|
|
2
|
+
import x from "axios";
|
|
3
|
+
var N = Object.defineProperty, I = Object.defineProperties, q = Object.getOwnPropertyDescriptors, k = Object.getOwnPropertySymbols, L = Object.prototype.hasOwnProperty, B = Object.prototype.propertyIsEnumerable, b = (n, t, e) => t in n ? N(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, h = (n, t) => {
|
|
4
|
+
for (var e in t || (t = {}))
|
|
5
|
+
L.call(t, e) && b(n, e, t[e]);
|
|
6
|
+
if (k)
|
|
7
|
+
for (var e of k(t))
|
|
8
|
+
B.call(t, e) && b(n, e, t[e]);
|
|
9
|
+
return n;
|
|
10
|
+
}, y = (n, t) => I(n, q(t));
|
|
11
|
+
let v = !1;
|
|
12
|
+
const _ = [], z = (n) => new Promise((t, e) => {
|
|
13
|
+
if (typeof window > "u" || (window.storyblokRegisterEvent = (s) => {
|
|
14
|
+
if (window.location === window.parent.location) {
|
|
15
|
+
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
55
16
|
return;
|
|
56
|
-
const script = document.createElement("script");
|
|
57
|
-
script.async = true;
|
|
58
|
-
script.src = src;
|
|
59
|
-
script.id = "storyblok-javascript-bridge";
|
|
60
|
-
script.onerror = (error) => reject(error);
|
|
61
|
-
script.onload = (ev) => {
|
|
62
|
-
callbacks.forEach((cb) => cb());
|
|
63
|
-
loaded = true;
|
|
64
|
-
resolve(ev);
|
|
65
|
-
};
|
|
66
|
-
document.getElementsByTagName("head")[0].appendChild(script);
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
const pick = function(attrs, allowed) {
|
|
70
|
-
if (!attrs) {
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
|
-
let h2 = {};
|
|
74
|
-
for (let key in attrs) {
|
|
75
|
-
let value = attrs[key];
|
|
76
|
-
if (allowed.indexOf(key) > -1 && value !== null) {
|
|
77
|
-
h2[key] = value;
|
|
78
17
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
|
|
18
|
+
v ? s() : _.push(s);
|
|
19
|
+
}, document.getElementById("storyblok-javascript-bridge")))
|
|
20
|
+
return;
|
|
21
|
+
const r = document.createElement("script");
|
|
22
|
+
r.async = !0, r.src = n, r.id = "storyblok-javascript-bridge", r.onerror = (s) => e(s), r.onload = (s) => {
|
|
23
|
+
_.forEach((o) => o()), v = !0, t(s);
|
|
24
|
+
}, document.getElementsByTagName("head")[0].appendChild(r);
|
|
25
|
+
}), D = function(n, t) {
|
|
26
|
+
if (!n)
|
|
27
|
+
return null;
|
|
28
|
+
let e = {};
|
|
29
|
+
for (let r in n) {
|
|
30
|
+
let s = n[r];
|
|
31
|
+
t.indexOf(r) > -1 && s !== null && (e[r] = s);
|
|
32
|
+
}
|
|
33
|
+
return e;
|
|
34
|
+
}, U = (n) => n === "email";
|
|
35
|
+
var V = {
|
|
84
36
|
nodes: {
|
|
85
37
|
horizontal_rule() {
|
|
86
38
|
return {
|
|
@@ -97,13 +49,13 @@ var defaultHtmlSerializer = {
|
|
|
97
49
|
tag: "ul"
|
|
98
50
|
};
|
|
99
51
|
},
|
|
100
|
-
code_block(
|
|
52
|
+
code_block(n) {
|
|
101
53
|
return {
|
|
102
54
|
tag: [
|
|
103
55
|
"pre",
|
|
104
56
|
{
|
|
105
57
|
tag: "code",
|
|
106
|
-
attrs:
|
|
58
|
+
attrs: n.attrs
|
|
107
59
|
}
|
|
108
60
|
]
|
|
109
61
|
};
|
|
@@ -113,17 +65,17 @@ var defaultHtmlSerializer = {
|
|
|
113
65
|
singleTag: "br"
|
|
114
66
|
};
|
|
115
67
|
},
|
|
116
|
-
heading(
|
|
68
|
+
heading(n) {
|
|
117
69
|
return {
|
|
118
|
-
tag: `h${
|
|
70
|
+
tag: `h${n.attrs.level}`
|
|
119
71
|
};
|
|
120
72
|
},
|
|
121
|
-
image(
|
|
73
|
+
image(n) {
|
|
122
74
|
return {
|
|
123
75
|
singleTag: [
|
|
124
76
|
{
|
|
125
77
|
tag: "img",
|
|
126
|
-
attrs:
|
|
78
|
+
attrs: D(n.attrs, ["src", "alt", "title"])
|
|
127
79
|
}
|
|
128
80
|
]
|
|
129
81
|
};
|
|
@@ -175,161 +127,100 @@ var defaultHtmlSerializer = {
|
|
|
175
127
|
tag: "i"
|
|
176
128
|
};
|
|
177
129
|
},
|
|
178
|
-
link(
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
if (isEmailLinkType(linktype)) {
|
|
182
|
-
attrs.href = `mailto:${attrs.href}`;
|
|
183
|
-
}
|
|
184
|
-
if (attrs.anchor) {
|
|
185
|
-
attrs.href = `${attrs.href}#${attrs.anchor}`;
|
|
186
|
-
delete attrs.anchor;
|
|
187
|
-
}
|
|
188
|
-
return {
|
|
130
|
+
link(n) {
|
|
131
|
+
const t = h({}, n.attrs), { linktype: e = "url" } = n.attrs;
|
|
132
|
+
return U(e) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), {
|
|
189
133
|
tag: [
|
|
190
134
|
{
|
|
191
135
|
tag: "a",
|
|
192
|
-
attrs
|
|
136
|
+
attrs: t
|
|
193
137
|
}
|
|
194
138
|
]
|
|
195
139
|
};
|
|
196
140
|
},
|
|
197
|
-
styled(
|
|
141
|
+
styled(n) {
|
|
198
142
|
return {
|
|
199
143
|
tag: [
|
|
200
144
|
{
|
|
201
145
|
tag: "span",
|
|
202
|
-
attrs:
|
|
146
|
+
attrs: n.attrs
|
|
203
147
|
}
|
|
204
148
|
]
|
|
205
149
|
};
|
|
206
150
|
}
|
|
207
151
|
}
|
|
208
152
|
};
|
|
209
|
-
const
|
|
210
|
-
const
|
|
153
|
+
const H = function(n) {
|
|
154
|
+
const t = {
|
|
211
155
|
"&": "&",
|
|
212
156
|
"<": "<",
|
|
213
157
|
">": ">",
|
|
214
158
|
'"': """,
|
|
215
159
|
"'": "'"
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
const reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
|
|
219
|
-
return string && reHasUnescapedHtml.test(string) ? string.replace(reUnescapedHtml, (chr) => htmlEscapes[chr]) : string;
|
|
160
|
+
}, e = /[&<>"']/g, r = RegExp(e.source);
|
|
161
|
+
return n && r.test(n) ? n.replace(e, (s) => t[s]) : n;
|
|
220
162
|
};
|
|
221
|
-
class
|
|
222
|
-
constructor(
|
|
223
|
-
|
|
224
|
-
|
|
163
|
+
class J {
|
|
164
|
+
constructor(t) {
|
|
165
|
+
t || (t = V), this.marks = t.marks || [], this.nodes = t.nodes || [];
|
|
166
|
+
}
|
|
167
|
+
addNode(t, e) {
|
|
168
|
+
this.nodes[t] = e;
|
|
169
|
+
}
|
|
170
|
+
addMark(t, e) {
|
|
171
|
+
this.marks[t] = e;
|
|
172
|
+
}
|
|
173
|
+
render(t = {}) {
|
|
174
|
+
if (t.content && Array.isArray(t.content)) {
|
|
175
|
+
let e = "";
|
|
176
|
+
return t.content.forEach((r) => {
|
|
177
|
+
e += this.renderNode(r);
|
|
178
|
+
}), e;
|
|
225
179
|
}
|
|
226
|
-
|
|
227
|
-
this.nodes = schema.nodes || [];
|
|
228
|
-
}
|
|
229
|
-
addNode(key, schema) {
|
|
230
|
-
this.nodes[key] = schema;
|
|
231
|
-
}
|
|
232
|
-
addMark(key, schema) {
|
|
233
|
-
this.marks[key] = schema;
|
|
234
|
-
}
|
|
235
|
-
render(data = {}) {
|
|
236
|
-
if (data.content && Array.isArray(data.content)) {
|
|
237
|
-
let html = "";
|
|
238
|
-
data.content.forEach((node) => {
|
|
239
|
-
html += this.renderNode(node);
|
|
240
|
-
});
|
|
241
|
-
return html;
|
|
242
|
-
}
|
|
243
|
-
console.warn("The render method must receive an object with a content field, which is an array");
|
|
244
|
-
return "";
|
|
245
|
-
}
|
|
246
|
-
renderNode(item) {
|
|
247
|
-
let html = [];
|
|
248
|
-
if (item.marks) {
|
|
249
|
-
item.marks.forEach((m) => {
|
|
250
|
-
const mark = this.getMatchingMark(m);
|
|
251
|
-
if (mark) {
|
|
252
|
-
html.push(this.renderOpeningTag(mark.tag));
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
const node = this.getMatchingNode(item);
|
|
257
|
-
if (node && node.tag) {
|
|
258
|
-
html.push(this.renderOpeningTag(node.tag));
|
|
259
|
-
}
|
|
260
|
-
if (item.content) {
|
|
261
|
-
item.content.forEach((content) => {
|
|
262
|
-
html.push(this.renderNode(content));
|
|
263
|
-
});
|
|
264
|
-
} else if (item.text) {
|
|
265
|
-
html.push(escapeHTML(item.text));
|
|
266
|
-
} else if (node && node.singleTag) {
|
|
267
|
-
html.push(this.renderTag(node.singleTag, " /"));
|
|
268
|
-
} else if (node && node.html) {
|
|
269
|
-
html.push(node.html);
|
|
270
|
-
}
|
|
271
|
-
if (node && node.tag) {
|
|
272
|
-
html.push(this.renderClosingTag(node.tag));
|
|
273
|
-
}
|
|
274
|
-
if (item.marks) {
|
|
275
|
-
item.marks.slice(0).reverse().forEach((m) => {
|
|
276
|
-
const mark = this.getMatchingMark(m);
|
|
277
|
-
if (mark) {
|
|
278
|
-
html.push(this.renderClosingTag(mark.tag));
|
|
279
|
-
}
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
return html.join("");
|
|
180
|
+
return console.warn("The render method must receive an object with a content field, which is an array"), "";
|
|
283
181
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
182
|
+
renderNode(t) {
|
|
183
|
+
let e = [];
|
|
184
|
+
t.marks && t.marks.forEach((s) => {
|
|
185
|
+
const o = this.getMatchingMark(s);
|
|
186
|
+
o && e.push(this.renderOpeningTag(o.tag));
|
|
187
|
+
});
|
|
188
|
+
const r = this.getMatchingNode(t);
|
|
189
|
+
return r && r.tag && e.push(this.renderOpeningTag(r.tag)), t.content ? t.content.forEach((s) => {
|
|
190
|
+
e.push(this.renderNode(s));
|
|
191
|
+
}) : t.text ? e.push(H(t.text)) : r && r.singleTag ? e.push(this.renderTag(r.singleTag, " /")) : r && r.html && e.push(r.html), r && r.tag && e.push(this.renderClosingTag(r.tag)), t.marks && t.marks.slice(0).reverse().forEach((s) => {
|
|
192
|
+
const o = this.getMatchingMark(s);
|
|
193
|
+
o && e.push(this.renderClosingTag(o.tag));
|
|
194
|
+
}), e.join("");
|
|
195
|
+
}
|
|
196
|
+
renderTag(t, e) {
|
|
197
|
+
return t.constructor === String ? `<${t}${e}>` : t.map((s) => {
|
|
198
|
+
if (s.constructor === String)
|
|
199
|
+
return `<${s}${e}>`;
|
|
200
|
+
{
|
|
201
|
+
let o = `<${s.tag}`;
|
|
202
|
+
if (s.attrs)
|
|
203
|
+
for (let i in s.attrs) {
|
|
204
|
+
let a = s.attrs[i];
|
|
205
|
+
a !== null && (o += ` ${i}="${a}"`);
|
|
299
206
|
}
|
|
300
|
-
}
|
|
301
|
-
return `${h2}${ending}>`;
|
|
207
|
+
return `${o}${e}>`;
|
|
302
208
|
}
|
|
303
|
-
});
|
|
304
|
-
return all.join("");
|
|
209
|
+
}).join("");
|
|
305
210
|
}
|
|
306
|
-
renderOpeningTag(
|
|
307
|
-
return this.renderTag(
|
|
211
|
+
renderOpeningTag(t) {
|
|
212
|
+
return this.renderTag(t, "");
|
|
308
213
|
}
|
|
309
|
-
renderClosingTag(
|
|
310
|
-
|
|
311
|
-
return `</${tags}>`;
|
|
312
|
-
}
|
|
313
|
-
const all = tags.slice(0).reverse().map((tag) => {
|
|
314
|
-
if (tag.constructor === String) {
|
|
315
|
-
return `</${tag}>`;
|
|
316
|
-
} else {
|
|
317
|
-
return `</${tag.tag}>`;
|
|
318
|
-
}
|
|
319
|
-
});
|
|
320
|
-
return all.join("");
|
|
214
|
+
renderClosingTag(t) {
|
|
215
|
+
return t.constructor === String ? `</${t}>` : t.slice(0).reverse().map((r) => r.constructor === String ? `</${r}>` : `</${r.tag}>`).join("");
|
|
321
216
|
}
|
|
322
|
-
getMatchingNode(
|
|
323
|
-
if (typeof this.nodes[
|
|
324
|
-
return;
|
|
325
|
-
}
|
|
326
|
-
return this.nodes[item.type](item);
|
|
217
|
+
getMatchingNode(t) {
|
|
218
|
+
if (typeof this.nodes[t.type] == "function")
|
|
219
|
+
return this.nodes[t.type](t);
|
|
327
220
|
}
|
|
328
|
-
getMatchingMark(
|
|
329
|
-
if (typeof this.marks[
|
|
330
|
-
return;
|
|
331
|
-
}
|
|
332
|
-
return this.marks[item.type](item);
|
|
221
|
+
getMatchingMark(t) {
|
|
222
|
+
if (typeof this.marks[t.type] == "function")
|
|
223
|
+
return this.marks[t.type](t);
|
|
333
224
|
}
|
|
334
225
|
}
|
|
335
226
|
/*!
|
|
@@ -337,340 +228,334 @@ class RichTextResolver {
|
|
|
337
228
|
* Universal JavaScript SDK for Storyblok's API
|
|
338
229
|
* (c) 2020-2022 Stobylok Team
|
|
339
230
|
*/
|
|
340
|
-
function
|
|
341
|
-
return typeof
|
|
231
|
+
function T(n) {
|
|
232
|
+
return typeof n == "number" && n == n && n !== 1 / 0 && n !== -1 / 0;
|
|
342
233
|
}
|
|
343
|
-
function
|
|
344
|
-
if (!t
|
|
234
|
+
function w(n, t, e) {
|
|
235
|
+
if (!T(t))
|
|
345
236
|
throw new TypeError("Expected `limit` to be a finite number");
|
|
346
|
-
if (!
|
|
237
|
+
if (!T(e))
|
|
347
238
|
throw new TypeError("Expected `interval` to be a finite number");
|
|
348
|
-
var
|
|
349
|
-
|
|
350
|
-
var
|
|
351
|
-
|
|
352
|
-
return
|
|
239
|
+
var r = [], s = [], o = 0, i = function() {
|
|
240
|
+
o++;
|
|
241
|
+
var c = setTimeout(function() {
|
|
242
|
+
o--, r.length > 0 && i(), s = s.filter(function(u) {
|
|
243
|
+
return u !== c;
|
|
353
244
|
});
|
|
354
|
-
},
|
|
355
|
-
|
|
356
|
-
var
|
|
357
|
-
|
|
358
|
-
},
|
|
359
|
-
var
|
|
360
|
-
return new Promise(function(
|
|
361
|
-
|
|
245
|
+
}, e);
|
|
246
|
+
s.indexOf(c) < 0 && s.push(c);
|
|
247
|
+
var l = r.shift();
|
|
248
|
+
l.resolve(n.apply(l.self, l.args));
|
|
249
|
+
}, a = function() {
|
|
250
|
+
var c = arguments, l = this;
|
|
251
|
+
return new Promise(function(u, p) {
|
|
252
|
+
r.push({ resolve: u, reject: p, args: c, self: l }), o < t && i();
|
|
362
253
|
});
|
|
363
254
|
};
|
|
364
|
-
return
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
}),
|
|
368
|
-
},
|
|
255
|
+
return a.abort = function() {
|
|
256
|
+
s.forEach(clearTimeout), s = [], r.forEach(function(c) {
|
|
257
|
+
c.reject(new throttle.AbortError());
|
|
258
|
+
}), r.length = 0;
|
|
259
|
+
}, a;
|
|
369
260
|
}
|
|
370
|
-
|
|
261
|
+
w.AbortError = function() {
|
|
371
262
|
Error.call(this, "Throttled function aborted"), this.name = "AbortError";
|
|
372
263
|
};
|
|
373
|
-
const
|
|
374
|
-
if (!
|
|
264
|
+
const Y = function(n, t) {
|
|
265
|
+
if (!n)
|
|
375
266
|
return null;
|
|
376
|
-
let
|
|
377
|
-
for (let
|
|
378
|
-
let
|
|
379
|
-
|
|
267
|
+
let e = {};
|
|
268
|
+
for (let r in n) {
|
|
269
|
+
let s = n[r];
|
|
270
|
+
t.indexOf(r) > -1 && s !== null && (e[r] = s);
|
|
380
271
|
}
|
|
381
|
-
return
|
|
272
|
+
return e;
|
|
382
273
|
};
|
|
383
|
-
var
|
|
384
|
-
const
|
|
385
|
-
return
|
|
386
|
-
}, styled: (
|
|
387
|
-
class
|
|
388
|
-
constructor(
|
|
389
|
-
|
|
390
|
-
}
|
|
391
|
-
addNode(
|
|
392
|
-
this.nodes[
|
|
393
|
-
}
|
|
394
|
-
addMark(
|
|
395
|
-
this.marks[
|
|
396
|
-
}
|
|
397
|
-
render(
|
|
398
|
-
if (
|
|
399
|
-
let
|
|
400
|
-
return
|
|
401
|
-
|
|
402
|
-
}),
|
|
274
|
+
var F = { nodes: { horizontal_rule: () => ({ singleTag: "hr" }), blockquote: () => ({ tag: "blockquote" }), bullet_list: () => ({ tag: "ul" }), code_block: (n) => ({ tag: ["pre", { tag: "code", attrs: n.attrs }] }), hard_break: () => ({ singleTag: "br" }), heading: (n) => ({ tag: `h${n.attrs.level}` }), image: (n) => ({ singleTag: [{ tag: "img", attrs: Y(n.attrs, ["src", "alt", "title"]) }] }), list_item: () => ({ tag: "li" }), ordered_list: () => ({ tag: "ol" }), paragraph: () => ({ tag: "p" }) }, marks: { bold: () => ({ tag: "b" }), strike: () => ({ tag: "strike" }), underline: () => ({ tag: "u" }), strong: () => ({ tag: "strong" }), code: () => ({ tag: "code" }), italic: () => ({ tag: "i" }), link(n) {
|
|
275
|
+
const t = h({}, n.attrs), { linktype: e = "url" } = n.attrs;
|
|
276
|
+
return e === "email" && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), { tag: [{ tag: "a", attrs: t }] };
|
|
277
|
+
}, styled: (n) => ({ tag: [{ tag: "span", attrs: n.attrs }] }) } };
|
|
278
|
+
class G {
|
|
279
|
+
constructor(t) {
|
|
280
|
+
t || (t = F), this.marks = t.marks || [], this.nodes = t.nodes || [];
|
|
281
|
+
}
|
|
282
|
+
addNode(t, e) {
|
|
283
|
+
this.nodes[t] = e;
|
|
284
|
+
}
|
|
285
|
+
addMark(t, e) {
|
|
286
|
+
this.marks[t] = e;
|
|
287
|
+
}
|
|
288
|
+
render(t = {}) {
|
|
289
|
+
if (t.content && Array.isArray(t.content)) {
|
|
290
|
+
let e = "";
|
|
291
|
+
return t.content.forEach((r) => {
|
|
292
|
+
e += this.renderNode(r);
|
|
293
|
+
}), e;
|
|
403
294
|
}
|
|
404
295
|
return console.warn("The render method must receive an object with a content field, which is an array"), "";
|
|
405
296
|
}
|
|
406
|
-
renderNode(
|
|
407
|
-
let
|
|
408
|
-
|
|
409
|
-
const
|
|
410
|
-
|
|
297
|
+
renderNode(t) {
|
|
298
|
+
let e = [];
|
|
299
|
+
t.marks && t.marks.forEach((s) => {
|
|
300
|
+
const o = this.getMatchingMark(s);
|
|
301
|
+
o && e.push(this.renderOpeningTag(o.tag));
|
|
411
302
|
});
|
|
412
|
-
const
|
|
413
|
-
return
|
|
414
|
-
|
|
415
|
-
}) :
|
|
416
|
-
const
|
|
417
|
-
return
|
|
418
|
-
}(
|
|
419
|
-
const
|
|
420
|
-
|
|
421
|
-
}),
|
|
422
|
-
}
|
|
423
|
-
renderTag(
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
if (e3.constructor === String)
|
|
428
|
-
return `<${e3}${t2}>`;
|
|
303
|
+
const r = this.getMatchingNode(t);
|
|
304
|
+
return r && r.tag && e.push(this.renderOpeningTag(r.tag)), t.content ? t.content.forEach((s) => {
|
|
305
|
+
e.push(this.renderNode(s));
|
|
306
|
+
}) : t.text ? e.push(function(s) {
|
|
307
|
+
const o = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }, i = /[&<>"']/g, a = RegExp(i.source);
|
|
308
|
+
return s && a.test(s) ? s.replace(i, (c) => o[c]) : s;
|
|
309
|
+
}(t.text)) : r && r.singleTag ? e.push(this.renderTag(r.singleTag, " /")) : r && r.html && e.push(r.html), r && r.tag && e.push(this.renderClosingTag(r.tag)), t.marks && t.marks.slice(0).reverse().forEach((s) => {
|
|
310
|
+
const o = this.getMatchingMark(s);
|
|
311
|
+
o && e.push(this.renderClosingTag(o.tag));
|
|
312
|
+
}), e.join("");
|
|
313
|
+
}
|
|
314
|
+
renderTag(t, e) {
|
|
315
|
+
return t.constructor === String ? `<${t}${e}>` : t.map((r) => {
|
|
316
|
+
if (r.constructor === String)
|
|
317
|
+
return `<${r}${e}>`;
|
|
429
318
|
{
|
|
430
|
-
let
|
|
431
|
-
if (
|
|
432
|
-
for (let
|
|
433
|
-
let
|
|
434
|
-
|
|
319
|
+
let s = `<${r.tag}`;
|
|
320
|
+
if (r.attrs)
|
|
321
|
+
for (let o in r.attrs) {
|
|
322
|
+
let i = r.attrs[o];
|
|
323
|
+
i !== null && (s += ` ${o}="${i}"`);
|
|
435
324
|
}
|
|
436
|
-
return `${
|
|
325
|
+
return `${s}${e}>`;
|
|
437
326
|
}
|
|
438
327
|
}).join("");
|
|
439
328
|
}
|
|
440
|
-
renderOpeningTag(
|
|
441
|
-
return this.renderTag(
|
|
329
|
+
renderOpeningTag(t) {
|
|
330
|
+
return this.renderTag(t, "");
|
|
442
331
|
}
|
|
443
|
-
renderClosingTag(
|
|
444
|
-
|
|
445
|
-
return `</${e2}>`;
|
|
446
|
-
return e2.slice(0).reverse().map((e3) => e3.constructor === String ? `</${e3}>` : `</${e3.tag}>`).join("");
|
|
332
|
+
renderClosingTag(t) {
|
|
333
|
+
return t.constructor === String ? `</${t}>` : t.slice(0).reverse().map((e) => e.constructor === String ? `</${e}>` : `</${e.tag}>`).join("");
|
|
447
334
|
}
|
|
448
|
-
getMatchingNode(
|
|
449
|
-
if (typeof this.nodes[
|
|
450
|
-
return this.nodes[
|
|
335
|
+
getMatchingNode(t) {
|
|
336
|
+
if (typeof this.nodes[t.type] == "function")
|
|
337
|
+
return this.nodes[t.type](t);
|
|
451
338
|
}
|
|
452
|
-
getMatchingMark(
|
|
453
|
-
if (typeof this.marks[
|
|
454
|
-
return this.marks[
|
|
339
|
+
getMatchingMark(t) {
|
|
340
|
+
if (typeof this.marks[t.type] == "function")
|
|
341
|
+
return this.marks[t.type](t);
|
|
455
342
|
}
|
|
456
343
|
}
|
|
457
|
-
const
|
|
458
|
-
const
|
|
459
|
-
return ((
|
|
460
|
-
},
|
|
461
|
-
const
|
|
462
|
-
for (const
|
|
463
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
344
|
+
const K = (n = 0, t = n) => {
|
|
345
|
+
const e = Math.abs(t - n) || 0, r = n < t ? 1 : -1;
|
|
346
|
+
return ((s = 0, o) => [...Array(s)].map(o))(e, (s, o) => o * r + n);
|
|
347
|
+
}, m = (n, t, e) => {
|
|
348
|
+
const r = [];
|
|
349
|
+
for (const s in n) {
|
|
350
|
+
if (!Object.prototype.hasOwnProperty.call(n, s))
|
|
464
351
|
continue;
|
|
465
|
-
const
|
|
466
|
-
let
|
|
467
|
-
|
|
352
|
+
const o = n[s], i = e ? "" : encodeURIComponent(s);
|
|
353
|
+
let a;
|
|
354
|
+
a = typeof o == "object" ? m(o, t ? t + encodeURIComponent("[" + i + "]") : i, Array.isArray(o)) : (t ? t + encodeURIComponent("[" + i + "]") : i) + "=" + encodeURIComponent(o), r.push(a);
|
|
468
355
|
}
|
|
469
|
-
return
|
|
356
|
+
return r.join("&");
|
|
470
357
|
};
|
|
471
|
-
let
|
|
472
|
-
class
|
|
473
|
-
constructor(
|
|
474
|
-
if (!
|
|
475
|
-
let
|
|
476
|
-
|
|
358
|
+
let f = {}, d = {};
|
|
359
|
+
class Q {
|
|
360
|
+
constructor(t, e) {
|
|
361
|
+
if (!e) {
|
|
362
|
+
let o = t.region ? `-${t.region}` : "", i = t.https === !1 ? "http" : "https";
|
|
363
|
+
e = t.oauthToken === void 0 ? `${i}://api${o}.storyblok.com/v2` : `${i}://api${o}.storyblok.com/v1`;
|
|
477
364
|
}
|
|
478
|
-
let
|
|
479
|
-
|
|
480
|
-
}
|
|
481
|
-
setComponentResolver(
|
|
482
|
-
this.richTextResolver.addNode("blok", (
|
|
483
|
-
let
|
|
484
|
-
return
|
|
485
|
-
|
|
486
|
-
}), { html:
|
|
365
|
+
let r = Object.assign({}, t.headers), s = 5;
|
|
366
|
+
t.oauthToken !== void 0 && (r.Authorization = t.oauthToken, s = 3), t.rateLimit !== void 0 && (s = t.rateLimit), this.richTextResolver = new G(t.richTextSchema), typeof t.componentResolver == "function" && this.setComponentResolver(t.componentResolver), this.maxRetries = t.maxRetries || 5, this.throttle = w(this.throttledRequest, s, 1e3), this.accessToken = t.accessToken, this.relations = {}, this.links = {}, this.cache = t.cache || { clear: "manual" }, this.client = x.create({ baseURL: e, timeout: t.timeout || 0, headers: r, proxy: t.proxy || !1 }), t.responseInterceptor && this.client.interceptors.response.use((o) => t.responseInterceptor(o)), this.resolveNestedRelations = t.resolveNestedRelations || !0;
|
|
367
|
+
}
|
|
368
|
+
setComponentResolver(t) {
|
|
369
|
+
this.richTextResolver.addNode("blok", (e) => {
|
|
370
|
+
let r = "";
|
|
371
|
+
return e.attrs.body.forEach((s) => {
|
|
372
|
+
r += t(s.component, s);
|
|
373
|
+
}), { html: r };
|
|
487
374
|
});
|
|
488
375
|
}
|
|
489
|
-
parseParams(
|
|
490
|
-
return
|
|
376
|
+
parseParams(t = {}) {
|
|
377
|
+
return t.version || (t.version = "published"), t.token || (t.token = this.getToken()), t.cv || (t.cv = d[t.token]), Array.isArray(t.resolve_relations) && (t.resolve_relations = t.resolve_relations.join(",")), t;
|
|
491
378
|
}
|
|
492
|
-
factoryParamOptions(
|
|
493
|
-
return ((
|
|
379
|
+
factoryParamOptions(t, e = {}) {
|
|
380
|
+
return ((r = "") => r.indexOf("/cdn/") > -1)(t) ? this.parseParams(e) : e;
|
|
494
381
|
}
|
|
495
|
-
makeRequest(
|
|
496
|
-
const
|
|
497
|
-
return this.cacheResponse(
|
|
382
|
+
makeRequest(t, e, r, s) {
|
|
383
|
+
const o = this.factoryParamOptions(t, ((i = {}, a = 25, c = 1) => y(h({}, i), { per_page: a, page: c }))(e, r, s));
|
|
384
|
+
return this.cacheResponse(t, o);
|
|
498
385
|
}
|
|
499
|
-
get(
|
|
500
|
-
let
|
|
501
|
-
const
|
|
502
|
-
return this.cacheResponse(
|
|
386
|
+
get(t, e) {
|
|
387
|
+
let r = `/${t}`;
|
|
388
|
+
const s = this.factoryParamOptions(r, e);
|
|
389
|
+
return this.cacheResponse(r, s);
|
|
503
390
|
}
|
|
504
|
-
async getAll(
|
|
505
|
-
const
|
|
506
|
-
|
|
507
|
-
const
|
|
508
|
-
return ((
|
|
391
|
+
async getAll(t, e = {}, r) {
|
|
392
|
+
const s = e.per_page || 25, o = `/${t}`, i = o.split("/");
|
|
393
|
+
r = r || i[i.length - 1];
|
|
394
|
+
const a = await this.makeRequest(o, e, s, 1), c = Math.ceil(a.total / s);
|
|
395
|
+
return ((l = [], u) => l.map(u).reduce((p, $) => [...p, ...$], []))([a, ...await (async (l = [], u) => Promise.all(l.map(u)))(K(1, c), async (l) => this.makeRequest(o, e, s, l + 1))], (l) => Object.values(l.data[r]));
|
|
509
396
|
}
|
|
510
|
-
post(
|
|
511
|
-
let
|
|
512
|
-
return this.throttle("post",
|
|
397
|
+
post(t, e) {
|
|
398
|
+
let r = `/${t}`;
|
|
399
|
+
return this.throttle("post", r, e);
|
|
513
400
|
}
|
|
514
|
-
put(
|
|
515
|
-
let
|
|
516
|
-
return this.throttle("put",
|
|
401
|
+
put(t, e) {
|
|
402
|
+
let r = `/${t}`;
|
|
403
|
+
return this.throttle("put", r, e);
|
|
517
404
|
}
|
|
518
|
-
delete(
|
|
519
|
-
let
|
|
520
|
-
return this.throttle("delete",
|
|
405
|
+
delete(t, e) {
|
|
406
|
+
let r = `/${t}`;
|
|
407
|
+
return this.throttle("delete", r, e);
|
|
521
408
|
}
|
|
522
|
-
getStories(
|
|
523
|
-
return this.get("cdn/stories",
|
|
409
|
+
getStories(t) {
|
|
410
|
+
return this.get("cdn/stories", t);
|
|
524
411
|
}
|
|
525
|
-
getStory(
|
|
526
|
-
return this.get(`cdn/stories/${
|
|
412
|
+
getStory(t, e) {
|
|
413
|
+
return this.get(`cdn/stories/${t}`, e);
|
|
527
414
|
}
|
|
528
|
-
setToken(
|
|
529
|
-
this.accessToken =
|
|
415
|
+
setToken(t) {
|
|
416
|
+
this.accessToken = t;
|
|
530
417
|
}
|
|
531
418
|
getToken() {
|
|
532
419
|
return this.accessToken;
|
|
533
420
|
}
|
|
534
|
-
_cleanCopy(
|
|
535
|
-
return JSON.parse(JSON.stringify(
|
|
536
|
-
}
|
|
537
|
-
_insertLinks(
|
|
538
|
-
const
|
|
539
|
-
|
|
540
|
-
}
|
|
541
|
-
_insertRelations(
|
|
542
|
-
if (
|
|
543
|
-
if (typeof
|
|
544
|
-
this.relations[
|
|
545
|
-
else if (
|
|
546
|
-
let
|
|
547
|
-
|
|
548
|
-
this.relations[
|
|
549
|
-
}),
|
|
421
|
+
_cleanCopy(t) {
|
|
422
|
+
return JSON.parse(JSON.stringify(t));
|
|
423
|
+
}
|
|
424
|
+
_insertLinks(t, e) {
|
|
425
|
+
const r = t[e];
|
|
426
|
+
r && r.fieldtype == "multilink" && r.linktype == "story" && typeof r.id == "string" && this.links[r.id] ? r.story = this._cleanCopy(this.links[r.id]) : r && r.linktype === "story" && typeof r.uuid == "string" && this.links[r.uuid] && (r.story = this._cleanCopy(this.links[r.uuid]));
|
|
427
|
+
}
|
|
428
|
+
_insertRelations(t, e, r) {
|
|
429
|
+
if (r.indexOf(t.component + "." + e) > -1) {
|
|
430
|
+
if (typeof t[e] == "string")
|
|
431
|
+
this.relations[t[e]] && (t[e] = this._cleanCopy(this.relations[t[e]]));
|
|
432
|
+
else if (t[e].constructor === Array) {
|
|
433
|
+
let s = [];
|
|
434
|
+
t[e].forEach((o) => {
|
|
435
|
+
this.relations[o] && s.push(this._cleanCopy(this.relations[o]));
|
|
436
|
+
}), t[e] = s;
|
|
550
437
|
}
|
|
551
438
|
}
|
|
552
439
|
}
|
|
553
|
-
_insertAssetsRelations(
|
|
554
|
-
|
|
555
|
-
|
|
440
|
+
_insertAssetsRelations(t, e) {
|
|
441
|
+
e.forEach((r) => {
|
|
442
|
+
t.id === r.id && (t.original = r, t.original.filename = t.filename, t.original.filename = t.original.filename.includes("https://s3.amazonaws.com/") ? t.original.filename : t.original.filename.replace("https://", "https://s3.amazonaws.com/"), delete t.original.s3_filename);
|
|
556
443
|
});
|
|
557
444
|
}
|
|
558
|
-
iterateTree(
|
|
559
|
-
let
|
|
560
|
-
if (
|
|
561
|
-
if (
|
|
562
|
-
for (let
|
|
563
|
-
|
|
564
|
-
else if (
|
|
565
|
-
if (
|
|
445
|
+
iterateTree(t, e) {
|
|
446
|
+
let r = (s) => {
|
|
447
|
+
if (s != null) {
|
|
448
|
+
if (s.constructor === Array)
|
|
449
|
+
for (let o = 0; o < s.length; o++)
|
|
450
|
+
r(s[o]);
|
|
451
|
+
else if (s.constructor === Object) {
|
|
452
|
+
if (s._stopResolving)
|
|
566
453
|
return;
|
|
567
|
-
for (let
|
|
568
|
-
|
|
454
|
+
for (let o in s)
|
|
455
|
+
s.component && s._uid || s.type === "link" ? (this._insertRelations(s, o, e), this._insertLinks(s, o)) : "id" in s && s.fieldtype === "asset" && this._insertAssetsRelations(s, e), r(s[o]);
|
|
569
456
|
}
|
|
570
457
|
}
|
|
571
458
|
};
|
|
572
|
-
|
|
573
|
-
}
|
|
574
|
-
async resolveLinks(
|
|
575
|
-
let
|
|
576
|
-
if (
|
|
577
|
-
const
|
|
578
|
-
let
|
|
579
|
-
const
|
|
580
|
-
for (let
|
|
581
|
-
const
|
|
582
|
-
|
|
459
|
+
r(t.content);
|
|
460
|
+
}
|
|
461
|
+
async resolveLinks(t, e) {
|
|
462
|
+
let r = [];
|
|
463
|
+
if (t.link_uuids) {
|
|
464
|
+
const s = t.link_uuids.length;
|
|
465
|
+
let o = [];
|
|
466
|
+
const i = 50;
|
|
467
|
+
for (let a = 0; a < s; a += i) {
|
|
468
|
+
const c = Math.min(s, a + i);
|
|
469
|
+
o.push(t.link_uuids.slice(a, c));
|
|
583
470
|
}
|
|
584
|
-
for (let
|
|
585
|
-
(await this.getStories({ per_page:
|
|
586
|
-
|
|
471
|
+
for (let a = 0; a < o.length; a++)
|
|
472
|
+
(await this.getStories({ per_page: i, language: e.language, version: e.version, by_uuids: o[a].join(",") })).data.stories.forEach((c) => {
|
|
473
|
+
r.push(c);
|
|
587
474
|
});
|
|
588
|
-
}
|
|
589
475
|
} else
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
this.links[
|
|
476
|
+
r = t.links;
|
|
477
|
+
r.forEach((s) => {
|
|
478
|
+
this.links[s.uuid] = y(h({}, s), { _stopResolving: !0 });
|
|
593
479
|
});
|
|
594
480
|
}
|
|
595
|
-
async resolveRelations(
|
|
596
|
-
let
|
|
597
|
-
if (
|
|
598
|
-
const
|
|
599
|
-
let
|
|
600
|
-
const
|
|
601
|
-
for (let
|
|
602
|
-
const
|
|
603
|
-
|
|
481
|
+
async resolveRelations(t, e) {
|
|
482
|
+
let r = [];
|
|
483
|
+
if (t.rel_uuids) {
|
|
484
|
+
const s = t.rel_uuids.length;
|
|
485
|
+
let o = [];
|
|
486
|
+
const i = 50;
|
|
487
|
+
for (let a = 0; a < s; a += i) {
|
|
488
|
+
const c = Math.min(s, a + i);
|
|
489
|
+
o.push(t.rel_uuids.slice(a, c));
|
|
604
490
|
}
|
|
605
|
-
for (let
|
|
606
|
-
(await this.getStories({ per_page:
|
|
607
|
-
|
|
491
|
+
for (let a = 0; a < o.length; a++)
|
|
492
|
+
(await this.getStories({ per_page: i, language: e.language, version: e.version, by_uuids: o[a].join(",") })).data.stories.forEach((c) => {
|
|
493
|
+
r.push(c);
|
|
608
494
|
});
|
|
609
|
-
}
|
|
610
495
|
} else
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
this.relations[
|
|
496
|
+
r = t.rels;
|
|
497
|
+
r.forEach((s) => {
|
|
498
|
+
this.relations[s.uuid] = y(h({}, s), { _stopResolving: !0 });
|
|
614
499
|
});
|
|
615
500
|
}
|
|
616
|
-
async resolveStories(
|
|
617
|
-
let
|
|
618
|
-
if (
|
|
619
|
-
for (const
|
|
620
|
-
this.iterateTree(this.relations[
|
|
621
|
-
|
|
622
|
-
this.iterateTree(
|
|
501
|
+
async resolveStories(t, e) {
|
|
502
|
+
let r = [];
|
|
503
|
+
if (e.resolve_relations !== void 0 && e.resolve_relations.length > 0 && (t.rels || t.rel_uuids) && (r = e.resolve_relations.split(","), await this.resolveRelations(t, e)), ["1", "story", "url"].indexOf(e.resolve_links) > -1 && (t.links || t.link_uuids) && await this.resolveLinks(t, e), this.resolveNestedRelations)
|
|
504
|
+
for (const s in this.relations)
|
|
505
|
+
this.iterateTree(this.relations[s], r);
|
|
506
|
+
t.story ? this.iterateTree(t.story, r) : t.stories.forEach((s) => {
|
|
507
|
+
this.iterateTree(s, r);
|
|
623
508
|
});
|
|
624
509
|
}
|
|
625
|
-
resolveAssetsRelations(
|
|
626
|
-
const { assets:
|
|
627
|
-
if (
|
|
628
|
-
for (const
|
|
629
|
-
this.iterateTree(
|
|
510
|
+
resolveAssetsRelations(t) {
|
|
511
|
+
const { assets: e, stories: r, story: s } = t;
|
|
512
|
+
if (r)
|
|
513
|
+
for (const o of r)
|
|
514
|
+
this.iterateTree(o, e);
|
|
630
515
|
else {
|
|
631
|
-
if (!
|
|
632
|
-
return
|
|
633
|
-
this.iterateTree(
|
|
516
|
+
if (!s)
|
|
517
|
+
return t;
|
|
518
|
+
this.iterateTree(s, e);
|
|
634
519
|
}
|
|
635
520
|
}
|
|
636
|
-
cacheResponse(
|
|
637
|
-
return
|
|
638
|
-
let
|
|
639
|
-
if (this.cache.clear === "auto" &&
|
|
640
|
-
const
|
|
641
|
-
if (
|
|
642
|
-
return
|
|
521
|
+
cacheResponse(t, e, r) {
|
|
522
|
+
return r === void 0 && (r = 0), new Promise(async (s, o) => {
|
|
523
|
+
let i = m({ url: t, params: e }), a = this.cacheProvider();
|
|
524
|
+
if (this.cache.clear === "auto" && e.version === "draft" && await this.flushCache(), e.version === "published" && t != "/cdn/spaces/me") {
|
|
525
|
+
const l = await a.get(i);
|
|
526
|
+
if (l)
|
|
527
|
+
return s(l);
|
|
643
528
|
}
|
|
644
529
|
try {
|
|
645
|
-
let
|
|
646
|
-
if (
|
|
647
|
-
return
|
|
648
|
-
(
|
|
649
|
-
} catch (
|
|
650
|
-
if (
|
|
651
|
-
return console.log(`Hit rate limit. Retrying in ${
|
|
652
|
-
|
|
530
|
+
let l = await this.throttle("get", t, { params: e, paramsSerializer: (p) => m(p) }), u = { data: l.data, headers: l.headers };
|
|
531
|
+
if (u.data.assets && u.data.assets.length && this.resolveAssetsRelations(u.data), l.headers["per-page"] && (u = Object.assign({}, u, { perPage: parseInt(l.headers["per-page"]), total: parseInt(l.headers.total) })), l.status != 200)
|
|
532
|
+
return o(l);
|
|
533
|
+
(u.data.story || u.data.stories) && await this.resolveStories(u.data, e), e.version === "published" && t != "/cdn/spaces/me" && a.set(i, u), u.data.cv && (e.version == "draft" && d[e.token] != u.data.cv && this.flushCache(), d[e.token] = u.data.cv), s(u);
|
|
534
|
+
} catch (l) {
|
|
535
|
+
if (l.response && l.response.status === 429 && (r += 1) < this.maxRetries)
|
|
536
|
+
return console.log(`Hit rate limit. Retrying in ${r} seconds.`), await (c = 1e3 * r, new Promise((u) => setTimeout(u, c))), this.cacheResponse(t, e, r).then(s).catch(o);
|
|
537
|
+
o(l);
|
|
653
538
|
}
|
|
654
|
-
var
|
|
539
|
+
var c;
|
|
655
540
|
});
|
|
656
541
|
}
|
|
657
|
-
throttledRequest(
|
|
658
|
-
return this.client[
|
|
542
|
+
throttledRequest(t, e, r) {
|
|
543
|
+
return this.client[t](e, r);
|
|
659
544
|
}
|
|
660
545
|
cacheVersions() {
|
|
661
|
-
return
|
|
546
|
+
return d;
|
|
662
547
|
}
|
|
663
548
|
cacheVersion() {
|
|
664
|
-
return
|
|
549
|
+
return d[this.accessToken];
|
|
665
550
|
}
|
|
666
|
-
setCacheVersion(
|
|
667
|
-
this.accessToken && (
|
|
551
|
+
setCacheVersion(t) {
|
|
552
|
+
this.accessToken && (d[this.accessToken] = t);
|
|
668
553
|
}
|
|
669
554
|
cacheProvider() {
|
|
670
|
-
return this.cache.type === "memory" ? { get: (
|
|
671
|
-
|
|
555
|
+
return this.cache.type === "memory" ? { get: (t) => f[t], getAll: () => f, set(t, e) {
|
|
556
|
+
f[t] = e;
|
|
672
557
|
}, flush() {
|
|
673
|
-
|
|
558
|
+
f = {};
|
|
674
559
|
} } : { get() {
|
|
675
560
|
}, getAll() {
|
|
676
561
|
}, set() {
|
|
@@ -681,125 +566,99 @@ class h {
|
|
|
681
566
|
return await this.cacheProvider().flush(), this;
|
|
682
567
|
}
|
|
683
568
|
}
|
|
684
|
-
const
|
|
685
|
-
const { apiOptions } =
|
|
686
|
-
if (!
|
|
569
|
+
const it = (n = {}) => {
|
|
570
|
+
const { apiOptions: t } = n;
|
|
571
|
+
if (!t.accessToken) {
|
|
687
572
|
console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");
|
|
688
573
|
return;
|
|
689
574
|
}
|
|
690
|
-
|
|
691
|
-
return { storyblokApi };
|
|
575
|
+
return { storyblokApi: new Q(t) };
|
|
692
576
|
};
|
|
693
|
-
var
|
|
694
|
-
if (typeof
|
|
577
|
+
var W = (n) => {
|
|
578
|
+
if (typeof n != "object" || typeof n._editable > "u")
|
|
695
579
|
return {};
|
|
696
|
-
|
|
697
|
-
const options = JSON.parse(blok._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, ""));
|
|
580
|
+
const t = JSON.parse(n._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, ""));
|
|
698
581
|
return {
|
|
699
|
-
"data-blok-c": JSON.stringify(
|
|
700
|
-
"data-blok-uid":
|
|
582
|
+
"data-blok-c": JSON.stringify(t),
|
|
583
|
+
"data-blok-uid": t.id + "-" + t.uid
|
|
701
584
|
};
|
|
702
585
|
};
|
|
703
|
-
const
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
window.storyblokRegisterEvent(() => {
|
|
718
|
-
const sbBridge = new window.StoryblokBridge(options);
|
|
719
|
-
sbBridge.on(["input", "published", "change"], (event) => {
|
|
720
|
-
if (event.action == "input" && event.story.id === id) {
|
|
721
|
-
cb(event.story);
|
|
722
|
-
} else {
|
|
723
|
-
window.location.reload();
|
|
724
|
-
}
|
|
586
|
+
const X = new J(), Z = "https://app.storyblok.com/f/storyblok-v2-latest.js", tt = (n, t, e = {}) => {
|
|
587
|
+
if (!(typeof window > "u")) {
|
|
588
|
+
if (typeof window.storyblokRegisterEvent > "u") {
|
|
589
|
+
console.error("Storyblok Bridge is disabled. Please enable it to use it. Read https://github.com/storyblok/storyblok-js");
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
if (!n) {
|
|
593
|
+
console.warn("Story ID is not defined. Please provide a valid ID.");
|
|
594
|
+
return;
|
|
595
|
+
}
|
|
596
|
+
window.storyblokRegisterEvent(() => {
|
|
597
|
+
new window.StoryblokBridge(e).on(["input", "published", "change"], (s) => {
|
|
598
|
+
s.story.id === n && (s.action === "input" ? t(s.story) : window.location.reload());
|
|
599
|
+
});
|
|
725
600
|
});
|
|
726
|
-
});
|
|
727
|
-
};
|
|
728
|
-
const storyblokInit = (pluginOptions = {}) => {
|
|
729
|
-
const { bridge, accessToken, use = [], apiOptions = {} } = pluginOptions;
|
|
730
|
-
apiOptions.accessToken = apiOptions.accessToken || accessToken;
|
|
731
|
-
const options = { bridge, apiOptions };
|
|
732
|
-
let result = {};
|
|
733
|
-
use.forEach((pluginFactory) => {
|
|
734
|
-
result = __spreadValues2(__spreadValues2({}, result), pluginFactory(options));
|
|
735
|
-
});
|
|
736
|
-
if (bridge !== false) {
|
|
737
|
-
loadBridge(bridgeLatest);
|
|
738
|
-
}
|
|
739
|
-
return result;
|
|
740
|
-
};
|
|
741
|
-
const renderRichText = (text) => {
|
|
742
|
-
if (text === "") {
|
|
743
|
-
return "";
|
|
744
|
-
} else if (!text) {
|
|
745
|
-
console.warn(`${text} is not a valid Richtext object. This might be because the value of the richtext field is empty.
|
|
746
|
-
|
|
747
|
-
For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`);
|
|
748
|
-
return "";
|
|
749
601
|
}
|
|
750
|
-
|
|
751
|
-
};
|
|
752
|
-
|
|
602
|
+
}, et = (n = {}) => {
|
|
603
|
+
const { bridge: t, accessToken: e, use: r = [], apiOptions: s = {} } = n;
|
|
604
|
+
s.accessToken = s.accessToken || e;
|
|
605
|
+
const o = { bridge: t, apiOptions: s };
|
|
606
|
+
let i = {};
|
|
607
|
+
return r.forEach((a) => {
|
|
608
|
+
i = h(h({}, i), a(o));
|
|
609
|
+
}), t !== !1 && z(Z), i;
|
|
610
|
+
}, at = (n) => n === "" ? "" : n ? X.render(n) : (console.warn(`${n} is not a valid Richtext object. This might be because the value of the richtext field is empty.
|
|
611
|
+
|
|
612
|
+
For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`), ""), rt = /* @__PURE__ */ E({
|
|
753
613
|
__name: "StoryblokComponent",
|
|
754
614
|
props: {
|
|
755
615
|
blok: null
|
|
756
616
|
},
|
|
757
|
-
setup(
|
|
758
|
-
return (
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
const
|
|
764
|
-
|
|
765
|
-
if (binding.value) {
|
|
766
|
-
const options = editable(binding.value);
|
|
767
|
-
el.setAttribute("data-blok-c", options["data-blok-c"]);
|
|
768
|
-
el.setAttribute("data-blok-uid", options["data-blok-uid"]);
|
|
769
|
-
el.classList.add("storyblok__outline");
|
|
617
|
+
setup(n) {
|
|
618
|
+
return (t, e) => (O(), S(P(n.blok.component), j(A({ ...t.$props, ...t.$attrs })), null, 16));
|
|
619
|
+
}
|
|
620
|
+
}), st = {
|
|
621
|
+
beforeMount(n, t) {
|
|
622
|
+
if (t.value) {
|
|
623
|
+
const e = W(t.value);
|
|
624
|
+
n.setAttribute("data-blok-c", e["data-blok-c"]), n.setAttribute("data-blok-uid", e["data-blok-uid"]), n.classList.add("storyblok__outline");
|
|
770
625
|
}
|
|
771
626
|
}
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
console.error(`You can't use ${fnName} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
|
|
627
|
+
}, R = (n) => {
|
|
628
|
+
console.error(`You can't use ${n} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
|
|
775
629
|
`);
|
|
776
630
|
};
|
|
777
|
-
let
|
|
778
|
-
const useStoryblokApi = () => {
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
story.value = data.story;
|
|
631
|
+
let g = null;
|
|
632
|
+
const lt = () => (g || R("useStoryblokApi"), g), ct = async (n, t = {}, e = {}) => {
|
|
633
|
+
const r = C(null);
|
|
634
|
+
if (M(() => {
|
|
635
|
+
r.value && r.value.id && tt(
|
|
636
|
+
r.value.id,
|
|
637
|
+
(s) => r.value = s,
|
|
638
|
+
e
|
|
639
|
+
);
|
|
640
|
+
}), g) {
|
|
641
|
+
const { data: s } = await g.get(
|
|
642
|
+
`cdn/stories/${n}`,
|
|
643
|
+
t
|
|
644
|
+
);
|
|
645
|
+
r.value = s.story;
|
|
793
646
|
} else
|
|
794
|
-
|
|
795
|
-
return
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
const { storyblokApi } = storyblokInit(pluginOptions);
|
|
802
|
-
storyblokApiInstance = storyblokApi;
|
|
647
|
+
R("useStoryblok");
|
|
648
|
+
return r;
|
|
649
|
+
}, ut = {
|
|
650
|
+
install(n, t = {}) {
|
|
651
|
+
n.directive("editable", st), n.component("StoryblokComponent", rt);
|
|
652
|
+
const { storyblokApi: e } = et(t);
|
|
653
|
+
g = e;
|
|
803
654
|
}
|
|
804
655
|
};
|
|
805
|
-
export {
|
|
656
|
+
export {
|
|
657
|
+
rt as StoryblokComponent,
|
|
658
|
+
ut as StoryblokVue,
|
|
659
|
+
it as apiPlugin,
|
|
660
|
+
at as renderRichText,
|
|
661
|
+
ct as useStoryblok,
|
|
662
|
+
lt as useStoryblokApi,
|
|
663
|
+
tt as useStoryblokBridge
|
|
664
|
+
};
|