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