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