@storyblok/svelte 2.4.6 → 2.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/storyblok-svelte.js +3 -3
- package/dist/storyblok-svelte.mjs +494 -485
- package/package.json +6 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
let U = !1;
|
|
2
|
-
const H = [],
|
|
2
|
+
const H = [], ee = (s) => new Promise((e, t) => {
|
|
3
3
|
if (typeof window > "u" || (window.storyblokRegisterEvent = (n) => {
|
|
4
4
|
if (window.location === window.parent.location) {
|
|
5
5
|
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
@@ -9,64 +9,64 @@ const H = [], tt = (s) => new Promise((t, e) => {
|
|
|
9
9
|
}, document.getElementById("storyblok-javascript-bridge")))
|
|
10
10
|
return;
|
|
11
11
|
const r = document.createElement("script");
|
|
12
|
-
r.async = !0, r.src = s, r.id = "storyblok-javascript-bridge", r.onerror = (n) =>
|
|
13
|
-
H.forEach((o) => o()), U = !0,
|
|
12
|
+
r.async = !0, r.src = s, r.id = "storyblok-javascript-bridge", r.onerror = (n) => t(n), r.onload = (n) => {
|
|
13
|
+
H.forEach((o) => o()), U = !0, e(n);
|
|
14
14
|
}, document.getElementsByTagName("head")[0].appendChild(r);
|
|
15
15
|
});
|
|
16
|
-
var
|
|
16
|
+
var te = Object.defineProperty, se = (s, e, t) => e in s ? te(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t, h = (s, e, t) => (se(s, typeof e != "symbol" ? e + "" : e, t), t);
|
|
17
17
|
function q(s) {
|
|
18
18
|
return !(s !== s || s === 1 / 0 || s === -1 / 0);
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
if (!q(t))
|
|
22
|
-
throw new TypeError("Expected `limit` to be a finite number");
|
|
20
|
+
function re(s, e, t) {
|
|
23
21
|
if (!q(e))
|
|
22
|
+
throw new TypeError("Expected `limit` to be a finite number");
|
|
23
|
+
if (!q(t))
|
|
24
24
|
throw new TypeError("Expected `interval` to be a finite number");
|
|
25
25
|
const r = [];
|
|
26
26
|
let n = [], o = 0;
|
|
27
|
-
const
|
|
27
|
+
const i = function() {
|
|
28
28
|
o++;
|
|
29
|
-
const
|
|
30
|
-
o--, r.length > 0 &&
|
|
31
|
-
return u !==
|
|
29
|
+
const c = setTimeout(function() {
|
|
30
|
+
o--, r.length > 0 && i(), n = n.filter(function(u) {
|
|
31
|
+
return u !== c;
|
|
32
32
|
});
|
|
33
|
-
},
|
|
34
|
-
n.indexOf(
|
|
33
|
+
}, t);
|
|
34
|
+
n.indexOf(c) < 0 && n.push(c);
|
|
35
35
|
const l = r.shift();
|
|
36
36
|
l.resolve(s.apply(l.self, l.args));
|
|
37
|
-
},
|
|
37
|
+
}, a = function(...c) {
|
|
38
38
|
const l = this;
|
|
39
39
|
return new Promise(function(u, d) {
|
|
40
40
|
r.push({
|
|
41
41
|
resolve: u,
|
|
42
42
|
reject: d,
|
|
43
|
-
args:
|
|
43
|
+
args: c,
|
|
44
44
|
self: l
|
|
45
|
-
}), o <
|
|
45
|
+
}), o < e && i();
|
|
46
46
|
});
|
|
47
47
|
};
|
|
48
|
-
return
|
|
49
|
-
n.forEach(clearTimeout), n = [], r.forEach(function(
|
|
50
|
-
|
|
48
|
+
return a.abort = function() {
|
|
49
|
+
n.forEach(clearTimeout), n = [], r.forEach(function(c) {
|
|
50
|
+
c.reject(function() {
|
|
51
51
|
Error.call(this, "Throttled function aborted"), this.name = "AbortError";
|
|
52
52
|
});
|
|
53
53
|
}), r.length = 0;
|
|
54
|
-
},
|
|
54
|
+
}, a;
|
|
55
55
|
}
|
|
56
|
-
const
|
|
57
|
-
const
|
|
56
|
+
const ne = function(s, e) {
|
|
57
|
+
const t = {};
|
|
58
58
|
for (const r in s) {
|
|
59
59
|
const n = s[r];
|
|
60
|
-
|
|
60
|
+
e.indexOf(r) > -1 && n !== null && (t[r] = n);
|
|
61
61
|
}
|
|
62
|
-
return
|
|
63
|
-
},
|
|
62
|
+
return t;
|
|
63
|
+
}, oe = (s) => s === "email", ie = () => ({
|
|
64
64
|
singleTag: "hr"
|
|
65
|
-
}),
|
|
65
|
+
}), ae = () => ({
|
|
66
66
|
tag: "blockquote"
|
|
67
|
-
}),
|
|
67
|
+
}), ce = () => ({
|
|
68
68
|
tag: "ul"
|
|
69
|
-
}),
|
|
69
|
+
}), le = (s) => ({
|
|
70
70
|
tag: [
|
|
71
71
|
"pre",
|
|
72
72
|
{
|
|
@@ -74,246 +74,249 @@ const nt = function(s, t) {
|
|
|
74
74
|
attrs: s.attrs
|
|
75
75
|
}
|
|
76
76
|
]
|
|
77
|
-
}),
|
|
77
|
+
}), he = () => ({
|
|
78
78
|
singleTag: "br"
|
|
79
|
-
}),
|
|
79
|
+
}), ue = (s) => ({
|
|
80
80
|
tag: `h${s.attrs.level}`
|
|
81
|
-
}),
|
|
81
|
+
}), de = (s) => ({
|
|
82
82
|
singleTag: [
|
|
83
83
|
{
|
|
84
84
|
tag: "img",
|
|
85
|
-
attrs:
|
|
85
|
+
attrs: ne(s.attrs, ["src", "alt", "title"])
|
|
86
86
|
}
|
|
87
87
|
]
|
|
88
|
-
}),
|
|
88
|
+
}), fe = () => ({
|
|
89
89
|
tag: "li"
|
|
90
|
-
}),
|
|
90
|
+
}), pe = () => ({
|
|
91
91
|
tag: "ol"
|
|
92
|
-
}),
|
|
92
|
+
}), ge = () => ({
|
|
93
93
|
tag: "p"
|
|
94
|
-
}),
|
|
94
|
+
}), me = () => ({
|
|
95
95
|
tag: "b"
|
|
96
|
-
}),
|
|
96
|
+
}), ye = () => ({
|
|
97
97
|
tag: "strike"
|
|
98
|
-
}),
|
|
98
|
+
}), ke = () => ({
|
|
99
99
|
tag: "u"
|
|
100
|
-
}),
|
|
100
|
+
}), _e = () => ({
|
|
101
101
|
tag: "strong"
|
|
102
|
-
}),
|
|
102
|
+
}), be = () => ({
|
|
103
103
|
tag: "code"
|
|
104
|
-
}),
|
|
104
|
+
}), ve = () => ({
|
|
105
105
|
tag: "i"
|
|
106
|
-
}),
|
|
107
|
-
const
|
|
108
|
-
return
|
|
106
|
+
}), we = (s) => {
|
|
107
|
+
const e = { ...s.attrs }, { linktype: t = "url" } = s.attrs;
|
|
108
|
+
return oe(t) && (e.href = `mailto:${e.href}`), e.anchor && (e.href = `${e.href}#${e.anchor}`, delete e.anchor), {
|
|
109
109
|
tag: [
|
|
110
110
|
{
|
|
111
111
|
tag: "a",
|
|
112
|
-
attrs:
|
|
112
|
+
attrs: e
|
|
113
113
|
}
|
|
114
114
|
]
|
|
115
115
|
};
|
|
116
|
-
}, $
|
|
116
|
+
}, $e = (s) => ({
|
|
117
117
|
tag: [
|
|
118
118
|
{
|
|
119
119
|
tag: "span",
|
|
120
120
|
attrs: s.attrs
|
|
121
121
|
}
|
|
122
122
|
]
|
|
123
|
-
}),
|
|
123
|
+
}), Te = {
|
|
124
124
|
nodes: {
|
|
125
|
-
horizontal_rule:
|
|
126
|
-
blockquote:
|
|
127
|
-
bullet_list:
|
|
128
|
-
code_block:
|
|
129
|
-
hard_break:
|
|
130
|
-
heading:
|
|
131
|
-
image:
|
|
132
|
-
list_item:
|
|
133
|
-
ordered_list:
|
|
134
|
-
paragraph:
|
|
125
|
+
horizontal_rule: ie,
|
|
126
|
+
blockquote: ae,
|
|
127
|
+
bullet_list: ce,
|
|
128
|
+
code_block: le,
|
|
129
|
+
hard_break: he,
|
|
130
|
+
heading: ue,
|
|
131
|
+
image: de,
|
|
132
|
+
list_item: fe,
|
|
133
|
+
ordered_list: pe,
|
|
134
|
+
paragraph: ge
|
|
135
135
|
},
|
|
136
136
|
marks: {
|
|
137
|
-
bold:
|
|
138
|
-
strike:
|
|
139
|
-
underline:
|
|
140
|
-
strong:
|
|
141
|
-
code:
|
|
142
|
-
italic:
|
|
143
|
-
link:
|
|
144
|
-
styled: $
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
const
|
|
137
|
+
bold: me,
|
|
138
|
+
strike: ye,
|
|
139
|
+
underline: ke,
|
|
140
|
+
strong: _e,
|
|
141
|
+
code: be,
|
|
142
|
+
italic: ve,
|
|
143
|
+
link: we,
|
|
144
|
+
styled: $e
|
|
145
|
+
}
|
|
146
|
+
}, Re = function(s) {
|
|
147
|
+
const e = {
|
|
148
148
|
"&": "&",
|
|
149
149
|
"<": "<",
|
|
150
150
|
">": ">",
|
|
151
151
|
'"': """,
|
|
152
152
|
"'": "'"
|
|
153
|
-
},
|
|
154
|
-
return s && r.test(s) ? s.replace(
|
|
153
|
+
}, t = /[&<>"']/g, r = RegExp(t.source);
|
|
154
|
+
return s && r.test(s) ? s.replace(t, (n) => e[n]) : s;
|
|
155
155
|
};
|
|
156
156
|
class T {
|
|
157
|
-
constructor(
|
|
158
|
-
h(this, "marks"), h(this, "nodes"),
|
|
157
|
+
constructor(e) {
|
|
158
|
+
h(this, "marks"), h(this, "nodes"), e || (e = Te), this.marks = e.marks || [], this.nodes = e.nodes || [];
|
|
159
159
|
}
|
|
160
|
-
addNode(
|
|
161
|
-
this.nodes[
|
|
160
|
+
addNode(e, t) {
|
|
161
|
+
this.nodes[e] = t;
|
|
162
162
|
}
|
|
163
|
-
addMark(
|
|
164
|
-
this.marks[
|
|
163
|
+
addMark(e, t) {
|
|
164
|
+
this.marks[e] = t;
|
|
165
165
|
}
|
|
166
|
-
render(
|
|
167
|
-
if (
|
|
168
|
-
let
|
|
169
|
-
return
|
|
170
|
-
|
|
171
|
-
}),
|
|
166
|
+
render(e) {
|
|
167
|
+
if (e && e.content && Array.isArray(e.content)) {
|
|
168
|
+
let t = "";
|
|
169
|
+
return e.content.forEach((r) => {
|
|
170
|
+
t += this.renderNode(r);
|
|
171
|
+
}), t;
|
|
172
172
|
}
|
|
173
173
|
return console.warn(
|
|
174
174
|
"The render method must receive an object with a content field, which is an array"
|
|
175
175
|
), "";
|
|
176
176
|
}
|
|
177
|
-
renderNode(
|
|
178
|
-
const
|
|
179
|
-
|
|
177
|
+
renderNode(e) {
|
|
178
|
+
const t = [];
|
|
179
|
+
e.marks && e.marks.forEach((n) => {
|
|
180
180
|
const o = this.getMatchingMark(n);
|
|
181
|
-
o &&
|
|
181
|
+
o && t.push(this.renderOpeningTag(o.tag));
|
|
182
182
|
});
|
|
183
|
-
const r = this.getMatchingNode(
|
|
184
|
-
return r && r.tag &&
|
|
185
|
-
|
|
186
|
-
}) :
|
|
183
|
+
const r = this.getMatchingNode(e);
|
|
184
|
+
return r && r.tag && t.push(this.renderOpeningTag(r.tag)), e.content ? e.content.forEach((n) => {
|
|
185
|
+
t.push(this.renderNode(n));
|
|
186
|
+
}) : e.text ? t.push(Re(e.text)) : r && r.singleTag ? t.push(this.renderTag(r.singleTag, " /")) : r && r.html && t.push(r.html), r && r.tag && t.push(this.renderClosingTag(r.tag)), e.marks && e.marks.slice(0).reverse().forEach((n) => {
|
|
187
187
|
const o = this.getMatchingMark(n);
|
|
188
|
-
o &&
|
|
189
|
-
}),
|
|
188
|
+
o && t.push(this.renderClosingTag(o.tag));
|
|
189
|
+
}), t.join("");
|
|
190
190
|
}
|
|
191
|
-
renderTag(
|
|
192
|
-
return
|
|
191
|
+
renderTag(e, t) {
|
|
192
|
+
return e.constructor === String ? `<${e}${t}>` : e.map((r) => {
|
|
193
193
|
if (r.constructor === String)
|
|
194
|
-
return `<${r}${
|
|
194
|
+
return `<${r}${t}>`;
|
|
195
195
|
{
|
|
196
196
|
let n = `<${r.tag}`;
|
|
197
197
|
if (r.attrs)
|
|
198
198
|
for (const o in r.attrs) {
|
|
199
|
-
const
|
|
200
|
-
|
|
199
|
+
const i = r.attrs[o];
|
|
200
|
+
i !== null && (n += ` ${o}="${i}"`);
|
|
201
201
|
}
|
|
202
|
-
return `${n}${
|
|
202
|
+
return `${n}${t}>`;
|
|
203
203
|
}
|
|
204
204
|
}).join("");
|
|
205
205
|
}
|
|
206
|
-
renderOpeningTag(
|
|
207
|
-
return this.renderTag(
|
|
206
|
+
renderOpeningTag(e) {
|
|
207
|
+
return this.renderTag(e, "");
|
|
208
208
|
}
|
|
209
|
-
renderClosingTag(
|
|
210
|
-
return
|
|
209
|
+
renderClosingTag(e) {
|
|
210
|
+
return e.constructor === String ? `</${e}>` : e.slice(0).reverse().map((t) => t.constructor === String ? `</${t}>` : `</${t.tag}>`).join("");
|
|
211
211
|
}
|
|
212
|
-
getMatchingNode(
|
|
213
|
-
const
|
|
214
|
-
if (typeof
|
|
215
|
-
return e
|
|
212
|
+
getMatchingNode(e) {
|
|
213
|
+
const t = this.nodes[e.type];
|
|
214
|
+
if (typeof t == "function")
|
|
215
|
+
return t(e);
|
|
216
216
|
}
|
|
217
|
-
getMatchingMark(
|
|
218
|
-
const
|
|
219
|
-
if (typeof
|
|
220
|
-
return e
|
|
217
|
+
getMatchingMark(e) {
|
|
218
|
+
const t = this.marks[e.type];
|
|
219
|
+
if (typeof t == "function")
|
|
220
|
+
return t(e);
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
223
|
class K {
|
|
224
224
|
constructor() {
|
|
225
|
-
h(this, "isCDNUrl", (
|
|
226
|
-
...
|
|
227
|
-
per_page:
|
|
225
|
+
h(this, "isCDNUrl", (e = "") => e.indexOf("/cdn/") > -1), h(this, "getOptionsPage", (e, t = 25, r = 1) => ({
|
|
226
|
+
...e,
|
|
227
|
+
per_page: t,
|
|
228
228
|
page: r
|
|
229
|
-
})), h(this, "delay", (
|
|
230
|
-
const r = Math.abs(
|
|
231
|
-
return this.arrayFrom(r, (o,
|
|
232
|
-
}), h(this, "asyncMap", async (
|
|
229
|
+
})), 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) => {
|
|
230
|
+
const r = Math.abs(t - e) || 0, n = e < t ? 1 : -1;
|
|
231
|
+
return this.arrayFrom(r, (o, i) => i * n + e);
|
|
232
|
+
}), h(this, "asyncMap", async (e, t) => Promise.all(e.map(t))), h(this, "flatMap", (e = [], t) => e.map(t).reduce((r, n) => [...r, ...n], []));
|
|
233
233
|
}
|
|
234
|
-
stringify(
|
|
234
|
+
stringify(e, t, r) {
|
|
235
235
|
const n = [];
|
|
236
|
-
for (const o in
|
|
237
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
236
|
+
for (const o in e) {
|
|
237
|
+
if (!Object.prototype.hasOwnProperty.call(e, o))
|
|
238
238
|
continue;
|
|
239
|
-
const
|
|
240
|
-
let
|
|
241
|
-
typeof
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
Array.isArray(
|
|
245
|
-
) :
|
|
239
|
+
const i = e[o], a = r ? "" : encodeURIComponent(o);
|
|
240
|
+
let c;
|
|
241
|
+
typeof i == "object" ? c = this.stringify(
|
|
242
|
+
i,
|
|
243
|
+
t ? t + encodeURIComponent("[" + a + "]") : a,
|
|
244
|
+
Array.isArray(i)
|
|
245
|
+
) : c = (t ? t + encodeURIComponent("[" + a + "]") : a) + "=" + encodeURIComponent(i), n.push(c);
|
|
246
246
|
}
|
|
247
247
|
return n.join("&");
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
|
-
class
|
|
251
|
-
constructor(
|
|
252
|
-
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 =
|
|
250
|
+
class xe {
|
|
251
|
+
constructor(e) {
|
|
252
|
+
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 = {};
|
|
253
253
|
}
|
|
254
|
-
get(
|
|
255
|
-
return this.url =
|
|
254
|
+
get(e, t) {
|
|
255
|
+
return this.url = e, this.parameters = t, this._methodHandler("get");
|
|
256
256
|
}
|
|
257
|
-
post(
|
|
258
|
-
return this.url =
|
|
257
|
+
post(e, t) {
|
|
258
|
+
return this.url = e, this.parameters = t, this._methodHandler("post");
|
|
259
259
|
}
|
|
260
|
-
put(
|
|
261
|
-
return this.url =
|
|
260
|
+
put(e, t) {
|
|
261
|
+
return this.url = e, this.parameters = t, this._methodHandler("put");
|
|
262
262
|
}
|
|
263
|
-
delete(
|
|
264
|
-
return this.url =
|
|
263
|
+
delete(e, t) {
|
|
264
|
+
return this.url = e, this.parameters = t, this._methodHandler("delete");
|
|
265
265
|
}
|
|
266
|
-
async _responseHandler(
|
|
267
|
-
const
|
|
266
|
+
async _responseHandler(e) {
|
|
267
|
+
const t = [], r = {
|
|
268
268
|
data: {},
|
|
269
269
|
headers: {},
|
|
270
270
|
status: 0,
|
|
271
271
|
statusText: ""
|
|
272
272
|
};
|
|
273
|
-
|
|
273
|
+
e.status !== 204 && await e.json().then((n) => {
|
|
274
274
|
r.data = n;
|
|
275
275
|
});
|
|
276
|
-
for (const n of
|
|
277
|
-
|
|
278
|
-
return r.headers = { ...
|
|
279
|
-
}
|
|
280
|
-
async _methodHandler(
|
|
281
|
-
let
|
|
282
|
-
if (
|
|
283
|
-
const
|
|
284
|
-
|
|
276
|
+
for (const n of e.headers.entries())
|
|
277
|
+
t[n[0]] = n[1];
|
|
278
|
+
return r.headers = { ...t }, r.status = e.status, r.statusText = e.statusText, r;
|
|
279
|
+
}
|
|
280
|
+
async _methodHandler(e) {
|
|
281
|
+
let t = `${this.baseURL}${this.url}`, r = null;
|
|
282
|
+
if (e === "get") {
|
|
283
|
+
const c = new K();
|
|
284
|
+
t = `${this.baseURL}${this.url}?${c.stringify(
|
|
285
285
|
this.parameters
|
|
286
286
|
)}`;
|
|
287
287
|
} else
|
|
288
288
|
r = JSON.stringify(this.parameters);
|
|
289
|
-
const n = new URL(
|
|
290
|
-
let
|
|
291
|
-
this.timeout && (
|
|
289
|
+
const n = new URL(t), o = new AbortController(), { signal: i } = o;
|
|
290
|
+
let a;
|
|
291
|
+
this.timeout && (a = setTimeout(() => o.abort(), this.timeout));
|
|
292
292
|
try {
|
|
293
|
-
const
|
|
294
|
-
method:
|
|
293
|
+
const c = await this.fetch(`${n}`, {
|
|
294
|
+
method: e,
|
|
295
295
|
headers: this.headers,
|
|
296
296
|
body: r,
|
|
297
|
-
signal:
|
|
297
|
+
signal: i
|
|
298
298
|
});
|
|
299
|
-
this.timeout && clearTimeout(
|
|
300
|
-
const l = await this._responseHandler(
|
|
299
|
+
this.timeout && clearTimeout(a);
|
|
300
|
+
const l = await this._responseHandler(c);
|
|
301
301
|
return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(l)) : this._statusHandler(l);
|
|
302
|
-
} catch (
|
|
303
|
-
return
|
|
302
|
+
} catch (c) {
|
|
303
|
+
return {
|
|
304
|
+
message: c
|
|
305
|
+
};
|
|
304
306
|
}
|
|
305
307
|
}
|
|
306
308
|
eject() {
|
|
307
309
|
this.ejectInterceptor = !0;
|
|
308
310
|
}
|
|
309
|
-
_statusHandler(
|
|
310
|
-
const
|
|
311
|
+
_statusHandler(e) {
|
|
312
|
+
const t = /20[0-6]/g;
|
|
311
313
|
return new Promise((r, n) => {
|
|
312
|
-
if (
|
|
313
|
-
return r(
|
|
314
|
+
if (t.test(`${e.status}`))
|
|
315
|
+
return r(e);
|
|
314
316
|
const o = {
|
|
315
|
-
message: new Error(
|
|
316
|
-
|
|
317
|
+
message: new Error(e.statusText),
|
|
318
|
+
status: e.status,
|
|
319
|
+
response: e.data.error || e.data.slug
|
|
317
320
|
};
|
|
318
321
|
n(o);
|
|
319
322
|
});
|
|
@@ -321,80 +324,80 @@ class xt {
|
|
|
321
324
|
}
|
|
322
325
|
let b = {};
|
|
323
326
|
const g = {};
|
|
324
|
-
class
|
|
325
|
-
constructor(
|
|
326
|
-
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"), !
|
|
327
|
-
const o =
|
|
328
|
-
|
|
327
|
+
class Pe {
|
|
328
|
+
constructor(e, t) {
|
|
329
|
+
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) {
|
|
330
|
+
const o = e.region ? `-${e.region}` : "", i = e.https === !1 ? "http" : "https";
|
|
331
|
+
e.oauthToken ? t = `${i}://api${o}.storyblok.com/v1` : t = `${i}://api${o}.storyblok.com/v2`;
|
|
329
332
|
}
|
|
330
333
|
const r = new Headers();
|
|
331
|
-
r.set("Content-Type", "application/json"), r.set("Accept", "application/json"), r.forEach((o,
|
|
332
|
-
|
|
334
|
+
r.set("Content-Type", "application/json"), r.set("Accept", "application/json"), r.forEach((o, i) => {
|
|
335
|
+
e.headers && e.headers[i] && r.set(i, e.headers[i]);
|
|
333
336
|
});
|
|
334
337
|
let n = 5;
|
|
335
|
-
|
|
336
|
-
baseURL:
|
|
337
|
-
timeout:
|
|
338
|
+
e.oauthToken && (r.set("Authorization", e.oauthToken), n = 3), e.rateLimit && (n = e.rateLimit), e.richTextSchema ? this.richTextResolver = new T(e.richTextSchema) : this.richTextResolver = new T(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries, this.throttle = re(this.throttledRequest, n, 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new K(), this.resolveNestedRelations = !1, this.client = new xe({
|
|
339
|
+
baseURL: t,
|
|
340
|
+
timeout: e.timeout || 0,
|
|
338
341
|
headers: r,
|
|
339
|
-
responseInterceptor:
|
|
340
|
-
fetch:
|
|
342
|
+
responseInterceptor: e.responseInterceptor,
|
|
343
|
+
fetch: e.fetch
|
|
341
344
|
});
|
|
342
345
|
}
|
|
343
|
-
setComponentResolver(
|
|
344
|
-
this.richTextResolver.addNode("blok", (
|
|
346
|
+
setComponentResolver(e) {
|
|
347
|
+
this.richTextResolver.addNode("blok", (t) => {
|
|
345
348
|
let r = "";
|
|
346
|
-
return
|
|
347
|
-
r +=
|
|
349
|
+
return t.attrs.body.forEach((n) => {
|
|
350
|
+
r += e(n.component, n);
|
|
348
351
|
}), {
|
|
349
352
|
html: r
|
|
350
353
|
};
|
|
351
354
|
});
|
|
352
355
|
}
|
|
353
|
-
parseParams(
|
|
354
|
-
return
|
|
356
|
+
parseParams(e) {
|
|
357
|
+
return e.version || (e.version = "published"), e.token || (e.token = this.getToken()), e.cv || (e.cv = g[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), e;
|
|
355
358
|
}
|
|
356
|
-
factoryParamOptions(
|
|
357
|
-
return this.helpers.isCDNUrl(
|
|
359
|
+
factoryParamOptions(e, t) {
|
|
360
|
+
return this.helpers.isCDNUrl(e) ? this.parseParams(t) : t;
|
|
358
361
|
}
|
|
359
|
-
makeRequest(
|
|
362
|
+
makeRequest(e, t, r, n) {
|
|
360
363
|
const o = this.factoryParamOptions(
|
|
361
|
-
|
|
362
|
-
this.helpers.getOptionsPage(
|
|
364
|
+
e,
|
|
365
|
+
this.helpers.getOptionsPage(t, r, n)
|
|
363
366
|
);
|
|
364
|
-
return this.cacheResponse(
|
|
367
|
+
return this.cacheResponse(e, o);
|
|
365
368
|
}
|
|
366
|
-
get(
|
|
367
|
-
|
|
368
|
-
const r = `/${
|
|
369
|
+
get(e, t) {
|
|
370
|
+
t || (t = {});
|
|
371
|
+
const r = `/${e}`, n = this.factoryParamOptions(r, t);
|
|
369
372
|
return this.cacheResponse(r, n);
|
|
370
373
|
}
|
|
371
|
-
async getAll(
|
|
372
|
-
const n = (
|
|
373
|
-
this.helpers.range(
|
|
374
|
-
(p) => this.makeRequest(o,
|
|
374
|
+
async getAll(e, t, r) {
|
|
375
|
+
const n = (t == null ? void 0 : t.per_page) || 25, o = `/${e}`, i = o.split("/"), a = r || i[i.length - 1], c = 1, l = await this.makeRequest(o, t, n, c), u = l.total ? Math.ceil(l.total / n) : 1, d = await this.helpers.asyncMap(
|
|
376
|
+
this.helpers.range(c, u),
|
|
377
|
+
(p) => this.makeRequest(o, t, n, p + 1)
|
|
375
378
|
);
|
|
376
379
|
return this.helpers.flatMap(
|
|
377
380
|
[l, ...d],
|
|
378
|
-
(p) => Object.values(p.data[
|
|
381
|
+
(p) => Object.values(p.data[a])
|
|
379
382
|
);
|
|
380
383
|
}
|
|
381
|
-
post(
|
|
382
|
-
const r = `/${
|
|
383
|
-
return Promise.resolve(this.throttle("post", r,
|
|
384
|
+
post(e, t) {
|
|
385
|
+
const r = `/${e}`;
|
|
386
|
+
return Promise.resolve(this.throttle("post", r, t));
|
|
384
387
|
}
|
|
385
|
-
put(
|
|
386
|
-
const r = `/${
|
|
387
|
-
return Promise.resolve(this.throttle("put", r,
|
|
388
|
+
put(e, t) {
|
|
389
|
+
const r = `/${e}`;
|
|
390
|
+
return Promise.resolve(this.throttle("put", r, t));
|
|
388
391
|
}
|
|
389
|
-
delete(
|
|
390
|
-
const r = `/${
|
|
391
|
-
return Promise.resolve(this.throttle("delete", r,
|
|
392
|
+
delete(e, t) {
|
|
393
|
+
const r = `/${e}`;
|
|
394
|
+
return Promise.resolve(this.throttle("delete", r, t));
|
|
392
395
|
}
|
|
393
|
-
getStories(
|
|
394
|
-
return this.get("cdn/stories",
|
|
396
|
+
getStories(e) {
|
|
397
|
+
return this.get("cdn/stories", e);
|
|
395
398
|
}
|
|
396
|
-
getStory(
|
|
397
|
-
return this.get(`cdn/stories/${
|
|
399
|
+
getStory(e, t) {
|
|
400
|
+
return this.get(`cdn/stories/${e}`, t);
|
|
398
401
|
}
|
|
399
402
|
getToken() {
|
|
400
403
|
return this.accessToken;
|
|
@@ -402,26 +405,26 @@ class jt {
|
|
|
402
405
|
ejectInterceptor() {
|
|
403
406
|
this.client.eject();
|
|
404
407
|
}
|
|
405
|
-
_cleanCopy(
|
|
406
|
-
return JSON.parse(JSON.stringify(
|
|
408
|
+
_cleanCopy(e) {
|
|
409
|
+
return JSON.parse(JSON.stringify(e));
|
|
407
410
|
}
|
|
408
|
-
_insertLinks(
|
|
409
|
-
const r = t
|
|
411
|
+
_insertLinks(e, t) {
|
|
412
|
+
const r = e[t];
|
|
410
413
|
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]));
|
|
411
414
|
}
|
|
412
|
-
_insertRelations(
|
|
413
|
-
if (r.indexOf(`${
|
|
414
|
-
if (typeof t
|
|
415
|
-
this.relations[t
|
|
416
|
-
else if (t
|
|
415
|
+
_insertRelations(e, t, r) {
|
|
416
|
+
if (r.indexOf(`${e.component}.${t}`) > -1) {
|
|
417
|
+
if (typeof e[t] == "string")
|
|
418
|
+
this.relations[e[t]] && (e[t] = this._cleanCopy(this.relations[e[t]]));
|
|
419
|
+
else if (e[t] && e[t].constructor === Array) {
|
|
417
420
|
const n = [];
|
|
418
|
-
t
|
|
421
|
+
e[t].forEach((o) => {
|
|
419
422
|
this.relations[o] && n.push(this._cleanCopy(this.relations[o]));
|
|
420
|
-
}), t
|
|
423
|
+
}), e[t] = n;
|
|
421
424
|
}
|
|
422
425
|
}
|
|
423
426
|
}
|
|
424
|
-
iterateTree(
|
|
427
|
+
iterateTree(e, t) {
|
|
425
428
|
const r = (n) => {
|
|
426
429
|
if (n != null) {
|
|
427
430
|
if (n.constructor === Array)
|
|
@@ -434,97 +437,99 @@ class jt {
|
|
|
434
437
|
(n.component && n._uid || n.type === "link") && (this._insertRelations(
|
|
435
438
|
n,
|
|
436
439
|
o,
|
|
437
|
-
|
|
440
|
+
t
|
|
438
441
|
), this._insertLinks(n, o)), r(n[o]);
|
|
439
442
|
}
|
|
440
443
|
}
|
|
441
444
|
};
|
|
442
|
-
r(
|
|
445
|
+
r(e.content);
|
|
443
446
|
}
|
|
444
|
-
async resolveLinks(
|
|
447
|
+
async resolveLinks(e, t) {
|
|
445
448
|
let r = [];
|
|
446
|
-
if (
|
|
447
|
-
const n =
|
|
448
|
-
for (let
|
|
449
|
-
const
|
|
450
|
-
o.push(
|
|
449
|
+
if (e.link_uuids) {
|
|
450
|
+
const n = e.link_uuids.length, o = [], i = 50;
|
|
451
|
+
for (let a = 0; a < n; a += i) {
|
|
452
|
+
const c = Math.min(n, a + i);
|
|
453
|
+
o.push(e.link_uuids.slice(a, c));
|
|
451
454
|
}
|
|
452
|
-
for (let
|
|
455
|
+
for (let a = 0; a < o.length; a++)
|
|
453
456
|
(await this.getStories({
|
|
454
|
-
per_page:
|
|
455
|
-
language:
|
|
456
|
-
version:
|
|
457
|
-
by_uuids: o[
|
|
457
|
+
per_page: i,
|
|
458
|
+
language: t.language,
|
|
459
|
+
version: t.version,
|
|
460
|
+
by_uuids: o[a].join(",")
|
|
458
461
|
})).data.stories.forEach(
|
|
459
|
-
(
|
|
460
|
-
r.push(
|
|
462
|
+
(c) => {
|
|
463
|
+
r.push(c);
|
|
461
464
|
}
|
|
462
465
|
);
|
|
463
466
|
} else
|
|
464
|
-
r =
|
|
467
|
+
r = e.links;
|
|
465
468
|
r.forEach((n) => {
|
|
466
469
|
this.links[n.uuid] = { ...n, _stopResolving: !0 };
|
|
467
470
|
});
|
|
468
471
|
}
|
|
469
|
-
async resolveRelations(
|
|
472
|
+
async resolveRelations(e, t) {
|
|
470
473
|
let r = [];
|
|
471
|
-
if (
|
|
472
|
-
const n =
|
|
473
|
-
for (let
|
|
474
|
-
const
|
|
475
|
-
o.push(
|
|
474
|
+
if (e.rel_uuids) {
|
|
475
|
+
const n = e.rel_uuids.length, o = [], i = 50;
|
|
476
|
+
for (let a = 0; a < n; a += i) {
|
|
477
|
+
const c = Math.min(n, a + i);
|
|
478
|
+
o.push(e.rel_uuids.slice(a, c));
|
|
476
479
|
}
|
|
477
|
-
for (let
|
|
480
|
+
for (let a = 0; a < o.length; a++)
|
|
478
481
|
(await this.getStories({
|
|
479
|
-
per_page:
|
|
480
|
-
language:
|
|
481
|
-
version:
|
|
482
|
-
by_uuids: o[
|
|
483
|
-
})).data.stories.forEach((
|
|
484
|
-
r.push(
|
|
482
|
+
per_page: i,
|
|
483
|
+
language: t.language,
|
|
484
|
+
version: t.version,
|
|
485
|
+
by_uuids: o[a].join(",")
|
|
486
|
+
})).data.stories.forEach((c) => {
|
|
487
|
+
r.push(c);
|
|
485
488
|
});
|
|
486
489
|
} else
|
|
487
|
-
r =
|
|
490
|
+
r = e.rels;
|
|
488
491
|
r && r.length > 0 && r.forEach((n) => {
|
|
489
492
|
this.relations[n.uuid] = { ...n, _stopResolving: !0 };
|
|
490
493
|
});
|
|
491
494
|
}
|
|
492
|
-
async resolveStories(
|
|
495
|
+
async resolveStories(e, t) {
|
|
493
496
|
var r, n;
|
|
494
497
|
let o = [];
|
|
495
|
-
if (typeof
|
|
496
|
-
for (const
|
|
497
|
-
this.iterateTree(this.relations[
|
|
498
|
-
|
|
499
|
-
this.iterateTree(
|
|
498
|
+
if (typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (o = t.resolve_relations.split(",")), await this.resolveRelations(e, t)), t.resolve_links && ["1", "story", "url"].indexOf(t.resolve_links) > -1 && ((r = e.links) != null && r.length || (n = e.link_uuids) != null && n.length) && await this.resolveLinks(e, t), this.resolveNestedRelations)
|
|
499
|
+
for (const i in this.relations)
|
|
500
|
+
this.iterateTree(this.relations[i], o);
|
|
501
|
+
e.story ? this.iterateTree(e.story, o) : e.stories.forEach((i) => {
|
|
502
|
+
this.iterateTree(i, o);
|
|
500
503
|
});
|
|
501
504
|
}
|
|
502
|
-
cacheResponse(
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
505
|
+
async cacheResponse(e, t, r) {
|
|
506
|
+
const n = this.helpers.stringify({ url: e, params: t }), o = this.cacheProvider();
|
|
507
|
+
if (this.cache.clear === "auto" && t.version === "draft" && await this.flushCache(), t.version === "published" && e != "/cdn/spaces/me") {
|
|
508
|
+
const i = await o.get(n);
|
|
509
|
+
if (i)
|
|
510
|
+
return Promise.resolve(i);
|
|
511
|
+
}
|
|
512
|
+
return new Promise((i, a) => {
|
|
510
513
|
try {
|
|
511
514
|
(async () => {
|
|
512
|
-
var
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
515
|
+
var c;
|
|
516
|
+
try {
|
|
517
|
+
const l = await this.throttle("get", e, t);
|
|
518
|
+
let u = { data: l.data, headers: l.headers };
|
|
519
|
+
return (c = l.headers) != null && c["per-page"] && (u = Object.assign({}, u, {
|
|
520
|
+
perPage: l.headers["per-page"] ? parseInt(l.headers["per-page"]) : 0,
|
|
521
|
+
total: l.headers["per-page"] ? parseInt(l.headers.total) : 0
|
|
522
|
+
})), l.status != 200 ? a(l) : ((u.data.story || u.data.stories) && await this.resolveStories(u.data, t), t.version === "published" && e != "/cdn/spaces/me" && await o.set(n, u), u.data.cv && t.token && (t.version == "draft" && g[t.token] != u.data.cv && await this.flushCache(), g[t.token] = u.data.cv), i(u));
|
|
523
|
+
} catch (l) {
|
|
524
|
+
return a(l);
|
|
525
|
+
}
|
|
521
526
|
})();
|
|
522
527
|
} catch {
|
|
523
528
|
}
|
|
524
529
|
});
|
|
525
530
|
}
|
|
526
|
-
throttledRequest(
|
|
527
|
-
return this.client[
|
|
531
|
+
throttledRequest(e, t, r) {
|
|
532
|
+
return this.client[e](t, r);
|
|
528
533
|
}
|
|
529
534
|
cacheVersions() {
|
|
530
535
|
return g;
|
|
@@ -532,122 +537,126 @@ class jt {
|
|
|
532
537
|
cacheVersion() {
|
|
533
538
|
return g[this.accessToken];
|
|
534
539
|
}
|
|
535
|
-
setCacheVersion(
|
|
536
|
-
this.accessToken && (g[this.accessToken] =
|
|
540
|
+
setCacheVersion(e) {
|
|
541
|
+
this.accessToken && (g[this.accessToken] = e);
|
|
537
542
|
}
|
|
538
543
|
cacheProvider() {
|
|
539
544
|
switch (this.cache.type) {
|
|
540
545
|
case "memory":
|
|
541
546
|
return {
|
|
542
|
-
get(
|
|
543
|
-
return b[
|
|
547
|
+
get(e) {
|
|
548
|
+
return Promise.resolve(b[e]);
|
|
544
549
|
},
|
|
545
550
|
getAll() {
|
|
546
|
-
return b;
|
|
551
|
+
return Promise.resolve(b);
|
|
547
552
|
},
|
|
548
|
-
set(
|
|
549
|
-
b[
|
|
553
|
+
set(e, t) {
|
|
554
|
+
return b[e] = t, Promise.resolve(void 0);
|
|
550
555
|
},
|
|
551
556
|
flush() {
|
|
552
|
-
b = {};
|
|
557
|
+
return b = {}, Promise.resolve(void 0);
|
|
553
558
|
}
|
|
554
559
|
};
|
|
560
|
+
case "custom":
|
|
561
|
+
if (this.cache.custom)
|
|
562
|
+
return this.cache.custom;
|
|
555
563
|
default:
|
|
556
564
|
return {
|
|
557
565
|
get() {
|
|
566
|
+
return Promise.resolve(void 0);
|
|
558
567
|
},
|
|
559
568
|
getAll() {
|
|
569
|
+
return Promise.resolve(void 0);
|
|
560
570
|
},
|
|
561
571
|
set() {
|
|
572
|
+
return Promise.resolve(void 0);
|
|
562
573
|
},
|
|
563
574
|
flush() {
|
|
575
|
+
return Promise.resolve(void 0);
|
|
564
576
|
}
|
|
565
577
|
};
|
|
566
578
|
}
|
|
567
579
|
}
|
|
568
|
-
flushCache() {
|
|
569
|
-
return this.cacheProvider().flush(), this;
|
|
580
|
+
async flushCache() {
|
|
581
|
+
return await this.cacheProvider().flush(), this;
|
|
570
582
|
}
|
|
571
583
|
}
|
|
572
|
-
const
|
|
573
|
-
const { apiOptions:
|
|
574
|
-
if (!
|
|
584
|
+
const We = (s = {}) => {
|
|
585
|
+
const { apiOptions: e } = s;
|
|
586
|
+
if (!e.accessToken) {
|
|
575
587
|
console.error(
|
|
576
588
|
"You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication"
|
|
577
589
|
);
|
|
578
590
|
return;
|
|
579
591
|
}
|
|
580
|
-
return { storyblokApi: new
|
|
581
|
-
},
|
|
592
|
+
return { storyblokApi: new Pe(e) };
|
|
593
|
+
}, je = (s) => {
|
|
582
594
|
if (typeof s != "object" || typeof s._editable > "u")
|
|
583
595
|
return {};
|
|
584
|
-
const
|
|
596
|
+
const e = JSON.parse(
|
|
585
597
|
s._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
|
|
586
598
|
);
|
|
587
599
|
return {
|
|
588
|
-
"data-blok-c": JSON.stringify(
|
|
589
|
-
"data-blok-uid":
|
|
600
|
+
"data-blok-c": JSON.stringify(e),
|
|
601
|
+
"data-blok-uid": e.id + "-" + e.uid
|
|
590
602
|
};
|
|
591
603
|
};
|
|
592
604
|
let x;
|
|
593
|
-
const
|
|
594
|
-
if (!(typeof window > "u")) {
|
|
595
|
-
if (typeof window.storyblokRegisterEvent > "u") {
|
|
596
|
-
console.error(
|
|
597
|
-
"Storyblok Bridge is disabled. Please enable it to use it. Read https://github.com/storyblok/storyblok-js"
|
|
598
|
-
);
|
|
599
|
-
return;
|
|
600
|
-
}
|
|
605
|
+
const Ee = "https://app.storyblok.com/f/storyblok-v2-latest.js", Xe = (s, e, t = {}) => {
|
|
606
|
+
if (!(typeof window > "u") && typeof window.storyblokRegisterEvent < "u") {
|
|
601
607
|
if (!s) {
|
|
602
608
|
console.warn("Story ID is not defined. Please provide a valid ID.");
|
|
603
609
|
return;
|
|
604
610
|
}
|
|
605
611
|
window.storyblokRegisterEvent(() => {
|
|
606
|
-
new window.StoryblokBridge(
|
|
607
|
-
r.action === "input" && r.story.id === s ?
|
|
612
|
+
new window.StoryblokBridge(t).on(["input", "published", "change"], (r) => {
|
|
613
|
+
r.action === "input" && r.story.id === s ? e(r.story) : (r.action === "change" || r.action === "published") && r.storyId === s && window.location.reload();
|
|
608
614
|
});
|
|
609
615
|
});
|
|
610
616
|
}
|
|
611
|
-
},
|
|
617
|
+
}, Se = (s = {}) => {
|
|
618
|
+
var e, t;
|
|
612
619
|
const {
|
|
613
|
-
bridge:
|
|
614
|
-
accessToken:
|
|
615
|
-
use:
|
|
616
|
-
apiOptions:
|
|
617
|
-
richText:
|
|
620
|
+
bridge: r,
|
|
621
|
+
accessToken: n,
|
|
622
|
+
use: o = [],
|
|
623
|
+
apiOptions: i = {},
|
|
624
|
+
richText: a = {}
|
|
618
625
|
} = s;
|
|
619
|
-
|
|
620
|
-
const c = { bridge:
|
|
621
|
-
let
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
})
|
|
625
|
-
|
|
626
|
-
|
|
626
|
+
i.accessToken = i.accessToken || n;
|
|
627
|
+
const c = { bridge: r, apiOptions: i };
|
|
628
|
+
let l = {};
|
|
629
|
+
o.forEach((d) => {
|
|
630
|
+
l = { ...l, ...d(c) };
|
|
631
|
+
});
|
|
632
|
+
const u = !(typeof window > "u") && ((t = (e = window.location) == null ? void 0 : e.search) == null ? void 0 : t.includes("_storyblok_tk"));
|
|
633
|
+
return r !== !1 && u && ee(Ee), x = new T(a.schema), a.resolver && G(x, a.resolver), l;
|
|
634
|
+
}, G = (s, e) => {
|
|
635
|
+
s.addNode("blok", (t) => {
|
|
627
636
|
let r = "";
|
|
628
|
-
return
|
|
629
|
-
r +=
|
|
637
|
+
return t.attrs.body.forEach((n) => {
|
|
638
|
+
r += e(n.component, n);
|
|
630
639
|
}), {
|
|
631
640
|
html: r
|
|
632
641
|
};
|
|
633
642
|
});
|
|
634
|
-
},
|
|
635
|
-
let r =
|
|
643
|
+
}, Ze = (s, e, t) => {
|
|
644
|
+
let r = t || x;
|
|
636
645
|
if (!r) {
|
|
637
646
|
console.error(
|
|
638
647
|
"Please initialize the Storyblok SDK before calling the renderRichText function"
|
|
639
648
|
);
|
|
640
649
|
return;
|
|
641
650
|
}
|
|
642
|
-
return s === "" ? "" : s ? (
|
|
651
|
+
return s === "" ? "" : s ? (e && (r = new T(e.schema), e.resolver && G(r, e.resolver)), r.render(s)) : (console.warn(`${s} is not a valid Richtext object. This might be because the value of the richtext field is empty.
|
|
643
652
|
|
|
644
653
|
For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`), "");
|
|
645
654
|
};
|
|
646
|
-
function
|
|
655
|
+
function P() {
|
|
647
656
|
}
|
|
648
|
-
function
|
|
649
|
-
for (const
|
|
650
|
-
s[
|
|
657
|
+
function j(s, e) {
|
|
658
|
+
for (const t in e)
|
|
659
|
+
s[t] = e[t];
|
|
651
660
|
return s;
|
|
652
661
|
}
|
|
653
662
|
function Q(s) {
|
|
@@ -662,53 +671,53 @@ function _(s) {
|
|
|
662
671
|
function W(s) {
|
|
663
672
|
return typeof s == "function";
|
|
664
673
|
}
|
|
665
|
-
function
|
|
666
|
-
return s != s ?
|
|
674
|
+
function Oe(s, e) {
|
|
675
|
+
return s != s ? e == e : s !== e || s && typeof s == "object" || typeof s == "function";
|
|
667
676
|
}
|
|
668
|
-
function
|
|
677
|
+
function Ce(s) {
|
|
669
678
|
return Object.keys(s).length === 0;
|
|
670
679
|
}
|
|
671
|
-
function
|
|
672
|
-
const t = {};
|
|
673
|
-
for (const e in s)
|
|
674
|
-
e[0] !== "$" && (t[e] = s[e]);
|
|
675
|
-
return t;
|
|
676
|
-
}
|
|
677
|
-
function B(s, t) {
|
|
680
|
+
function Ie(s) {
|
|
678
681
|
const e = {};
|
|
679
|
-
t
|
|
680
|
-
|
|
681
|
-
!t.has(r) && r[0] !== "$" && (e[r] = s[r]);
|
|
682
|
+
for (const t in s)
|
|
683
|
+
t[0] !== "$" && (e[t] = s[t]);
|
|
682
684
|
return e;
|
|
683
685
|
}
|
|
684
|
-
function
|
|
685
|
-
|
|
686
|
+
function B(s, e) {
|
|
687
|
+
const t = {};
|
|
688
|
+
e = new Set(e);
|
|
689
|
+
for (const r in s)
|
|
690
|
+
!e.has(r) && r[0] !== "$" && (t[r] = s[r]);
|
|
691
|
+
return t;
|
|
692
|
+
}
|
|
693
|
+
function Ae(s, e, t) {
|
|
694
|
+
s.insertBefore(e, t || null);
|
|
686
695
|
}
|
|
687
696
|
function X(s) {
|
|
688
697
|
s.parentNode && s.parentNode.removeChild(s);
|
|
689
698
|
}
|
|
690
|
-
function
|
|
699
|
+
function Ne(s) {
|
|
691
700
|
return document.createTextNode(s);
|
|
692
701
|
}
|
|
693
|
-
function
|
|
694
|
-
return
|
|
702
|
+
function Me() {
|
|
703
|
+
return Ne("");
|
|
695
704
|
}
|
|
696
|
-
function
|
|
705
|
+
function Le(s) {
|
|
697
706
|
return Array.from(s.childNodes);
|
|
698
707
|
}
|
|
699
|
-
function J(s,
|
|
700
|
-
return new s(
|
|
708
|
+
function J(s, e) {
|
|
709
|
+
return new s(e);
|
|
701
710
|
}
|
|
702
711
|
let N;
|
|
703
712
|
function k(s) {
|
|
704
713
|
N = s;
|
|
705
714
|
}
|
|
706
|
-
const y = [], F = [], v = [], V = [],
|
|
707
|
-
let
|
|
708
|
-
function
|
|
709
|
-
|
|
715
|
+
const y = [], F = [], v = [], V = [], Ue = Promise.resolve();
|
|
716
|
+
let E = !1;
|
|
717
|
+
function He() {
|
|
718
|
+
E || (E = !0, Ue.then(Z));
|
|
710
719
|
}
|
|
711
|
-
function
|
|
720
|
+
function S(s) {
|
|
712
721
|
v.push(s);
|
|
713
722
|
}
|
|
714
723
|
const R = /* @__PURE__ */ new Set();
|
|
@@ -720,34 +729,34 @@ function Z() {
|
|
|
720
729
|
do {
|
|
721
730
|
try {
|
|
722
731
|
for (; m < y.length; ) {
|
|
723
|
-
const
|
|
724
|
-
m++, k(
|
|
732
|
+
const e = y[m];
|
|
733
|
+
m++, k(e), qe(e.$$);
|
|
725
734
|
}
|
|
726
|
-
} catch (
|
|
727
|
-
throw y.length = 0, m = 0,
|
|
735
|
+
} catch (e) {
|
|
736
|
+
throw y.length = 0, m = 0, e;
|
|
728
737
|
}
|
|
729
738
|
for (k(null), y.length = 0, m = 0; F.length; )
|
|
730
739
|
F.pop()();
|
|
731
|
-
for (let
|
|
732
|
-
const
|
|
733
|
-
R.has(
|
|
740
|
+
for (let e = 0; e < v.length; e += 1) {
|
|
741
|
+
const t = v[e];
|
|
742
|
+
R.has(t) || (R.add(t), t());
|
|
734
743
|
}
|
|
735
744
|
v.length = 0;
|
|
736
745
|
} while (y.length);
|
|
737
746
|
for (; V.length; )
|
|
738
747
|
V.pop()();
|
|
739
|
-
|
|
748
|
+
E = !1, R.clear(), k(s);
|
|
740
749
|
}
|
|
741
|
-
function
|
|
750
|
+
function qe(s) {
|
|
742
751
|
if (s.fragment !== null) {
|
|
743
752
|
s.update(), _(s.before_update);
|
|
744
|
-
const
|
|
745
|
-
s.dirty = [-1], s.fragment && s.fragment.p(s.ctx,
|
|
753
|
+
const e = s.dirty;
|
|
754
|
+
s.dirty = [-1], s.fragment && s.fragment.p(s.ctx, e), s.after_update.forEach(S);
|
|
746
755
|
}
|
|
747
756
|
}
|
|
748
757
|
const w = /* @__PURE__ */ new Set();
|
|
749
758
|
let f;
|
|
750
|
-
function
|
|
759
|
+
function De() {
|
|
751
760
|
f = {
|
|
752
761
|
r: 0,
|
|
753
762
|
c: [],
|
|
@@ -755,70 +764,70 @@ function Dt() {
|
|
|
755
764
|
// parent group
|
|
756
765
|
};
|
|
757
766
|
}
|
|
758
|
-
function
|
|
767
|
+
function Be() {
|
|
759
768
|
f.r || _(f.c), f = f.p;
|
|
760
769
|
}
|
|
761
|
-
function O(s,
|
|
762
|
-
s && s.i && (w.delete(s), s.i(
|
|
770
|
+
function O(s, e) {
|
|
771
|
+
s && s.i && (w.delete(s), s.i(e));
|
|
763
772
|
}
|
|
764
|
-
function Y(s,
|
|
773
|
+
function Y(s, e, t, r) {
|
|
765
774
|
if (s && s.o) {
|
|
766
775
|
if (w.has(s))
|
|
767
776
|
return;
|
|
768
777
|
w.add(s), f.c.push(() => {
|
|
769
|
-
w.delete(s), r && (
|
|
770
|
-
}), s.o(
|
|
778
|
+
w.delete(s), r && (t && s.d(1), r());
|
|
779
|
+
}), s.o(e);
|
|
771
780
|
} else
|
|
772
781
|
r && r();
|
|
773
782
|
}
|
|
774
|
-
function
|
|
775
|
-
const
|
|
783
|
+
function Je(s, e) {
|
|
784
|
+
const t = {}, r = {}, n = { $$scope: 1 };
|
|
776
785
|
let o = s.length;
|
|
777
786
|
for (; o--; ) {
|
|
778
|
-
const
|
|
779
|
-
if (
|
|
780
|
-
for (const
|
|
781
|
-
|
|
782
|
-
for (const
|
|
783
|
-
n[
|
|
784
|
-
s[o] =
|
|
787
|
+
const i = s[o], a = e[o];
|
|
788
|
+
if (a) {
|
|
789
|
+
for (const c in i)
|
|
790
|
+
c in a || (r[c] = 1);
|
|
791
|
+
for (const c in a)
|
|
792
|
+
n[c] || (t[c] = a[c], n[c] = 1);
|
|
793
|
+
s[o] = a;
|
|
785
794
|
} else
|
|
786
|
-
for (const
|
|
787
|
-
n[
|
|
795
|
+
for (const c in i)
|
|
796
|
+
n[c] = 1;
|
|
788
797
|
}
|
|
789
|
-
for (const
|
|
790
|
-
|
|
791
|
-
return
|
|
798
|
+
for (const i in r)
|
|
799
|
+
i in t || (t[i] = void 0);
|
|
800
|
+
return t;
|
|
792
801
|
}
|
|
793
|
-
function
|
|
802
|
+
function Fe(s) {
|
|
794
803
|
return typeof s == "object" && s !== null ? s : {};
|
|
795
804
|
}
|
|
796
805
|
function z(s) {
|
|
797
806
|
s && s.c();
|
|
798
807
|
}
|
|
799
|
-
function C(s,
|
|
808
|
+
function C(s, e, t, r) {
|
|
800
809
|
const { fragment: n, after_update: o } = s.$$;
|
|
801
|
-
n && n.m(
|
|
802
|
-
const
|
|
803
|
-
s.$$.on_destroy ? s.$$.on_destroy.push(...
|
|
804
|
-
}), o.forEach(
|
|
810
|
+
n && n.m(e, t), r || S(() => {
|
|
811
|
+
const i = s.$$.on_mount.map(Q).filter(W);
|
|
812
|
+
s.$$.on_destroy ? s.$$.on_destroy.push(...i) : _(i), s.$$.on_mount = [];
|
|
813
|
+
}), o.forEach(S);
|
|
805
814
|
}
|
|
806
|
-
function I(s,
|
|
807
|
-
const
|
|
808
|
-
|
|
815
|
+
function I(s, e) {
|
|
816
|
+
const t = s.$$;
|
|
817
|
+
t.fragment !== null && (_(t.on_destroy), t.fragment && t.fragment.d(e), t.on_destroy = t.fragment = null, t.ctx = []);
|
|
809
818
|
}
|
|
810
|
-
function
|
|
811
|
-
s.$$.dirty[0] === -1 && (y.push(s),
|
|
819
|
+
function Ve(s, e) {
|
|
820
|
+
s.$$.dirty[0] === -1 && (y.push(s), He(), s.$$.dirty.fill(0)), s.$$.dirty[e / 31 | 0] |= 1 << e % 31;
|
|
812
821
|
}
|
|
813
|
-
function
|
|
814
|
-
const
|
|
822
|
+
function Ye(s, e, t, r, n, o, i, a = [-1]) {
|
|
823
|
+
const c = N;
|
|
815
824
|
k(s);
|
|
816
825
|
const l = s.$$ = {
|
|
817
826
|
fragment: null,
|
|
818
827
|
ctx: [],
|
|
819
828
|
// state
|
|
820
829
|
props: o,
|
|
821
|
-
update:
|
|
830
|
+
update: P,
|
|
822
831
|
not_equal: n,
|
|
823
832
|
bound: D(),
|
|
824
833
|
// lifecycle
|
|
@@ -827,47 +836,47 @@ function Yt(s, t, e, r, n, o, c, i = [-1]) {
|
|
|
827
836
|
on_disconnect: [],
|
|
828
837
|
before_update: [],
|
|
829
838
|
after_update: [],
|
|
830
|
-
context: new Map(
|
|
839
|
+
context: new Map(e.context || (c ? c.$$.context : [])),
|
|
831
840
|
// everything else
|
|
832
841
|
callbacks: D(),
|
|
833
|
-
dirty:
|
|
842
|
+
dirty: a,
|
|
834
843
|
skip_bound: !1,
|
|
835
|
-
root:
|
|
844
|
+
root: e.target || c.$$.root
|
|
836
845
|
};
|
|
837
|
-
|
|
846
|
+
i && i(l.root);
|
|
838
847
|
let u = !1;
|
|
839
|
-
if (l.ctx =
|
|
848
|
+
if (l.ctx = t ? t(s, e.props || {}, (d, p, ...M) => {
|
|
840
849
|
const L = M.length ? M[0] : p;
|
|
841
|
-
return l.ctx && n(l.ctx[d], l.ctx[d] = L) && (!l.skip_bound && l.bound[d] && l.bound[d](L), u &&
|
|
842
|
-
}) : [], l.update(), u = !0, _(l.before_update), l.fragment = r ? r(l.ctx) : !1,
|
|
843
|
-
if (
|
|
844
|
-
const d =
|
|
850
|
+
return l.ctx && n(l.ctx[d], l.ctx[d] = L) && (!l.skip_bound && l.bound[d] && l.bound[d](L), u && Ve(s, d)), p;
|
|
851
|
+
}) : [], l.update(), u = !0, _(l.before_update), l.fragment = r ? r(l.ctx) : !1, e.target) {
|
|
852
|
+
if (e.hydrate) {
|
|
853
|
+
const d = Le(e.target);
|
|
845
854
|
l.fragment && l.fragment.l(d), d.forEach(X);
|
|
846
855
|
} else
|
|
847
856
|
l.fragment && l.fragment.c();
|
|
848
|
-
|
|
857
|
+
e.intro && O(s.$$.fragment), C(s, e.target, e.anchor, e.customElement), Z();
|
|
849
858
|
}
|
|
850
|
-
k(
|
|
859
|
+
k(c);
|
|
851
860
|
}
|
|
852
|
-
class
|
|
861
|
+
class ze {
|
|
853
862
|
$destroy() {
|
|
854
|
-
I(this, 1), this.$destroy =
|
|
855
|
-
}
|
|
856
|
-
$on(
|
|
857
|
-
if (!W(
|
|
858
|
-
return
|
|
859
|
-
const r = this.$$.callbacks[
|
|
860
|
-
return r.push(
|
|
861
|
-
const n = r.indexOf(
|
|
863
|
+
I(this, 1), this.$destroy = P;
|
|
864
|
+
}
|
|
865
|
+
$on(e, t) {
|
|
866
|
+
if (!W(t))
|
|
867
|
+
return P;
|
|
868
|
+
const r = this.$$.callbacks[e] || (this.$$.callbacks[e] = []);
|
|
869
|
+
return r.push(t), () => {
|
|
870
|
+
const n = r.indexOf(t);
|
|
862
871
|
n !== -1 && r.splice(n, 1);
|
|
863
872
|
};
|
|
864
873
|
}
|
|
865
|
-
$set(
|
|
866
|
-
this.$$set && !
|
|
874
|
+
$set(e) {
|
|
875
|
+
this.$$set && !Ce(e) && (this.$$.skip_bound = !0, this.$$set(e), this.$$.skip_bound = !1);
|
|
867
876
|
}
|
|
868
877
|
}
|
|
869
|
-
function
|
|
870
|
-
let
|
|
878
|
+
function Ke(s) {
|
|
879
|
+
let e, t, r;
|
|
871
880
|
const n = [
|
|
872
881
|
{ blok: (
|
|
873
882
|
/*blok*/
|
|
@@ -880,108 +889,108 @@ function Kt(s) {
|
|
|
880
889
|
/*component*/
|
|
881
890
|
s[1]
|
|
882
891
|
);
|
|
883
|
-
function
|
|
884
|
-
let
|
|
892
|
+
function i(a) {
|
|
893
|
+
let c = {};
|
|
885
894
|
for (let l = 0; l < n.length; l += 1)
|
|
886
|
-
|
|
887
|
-
return { props:
|
|
895
|
+
c = j(c, n[l]);
|
|
896
|
+
return { props: c };
|
|
888
897
|
}
|
|
889
|
-
return o && (
|
|
898
|
+
return o && (e = J(o, i())), {
|
|
890
899
|
c() {
|
|
891
|
-
|
|
900
|
+
e && z(e.$$.fragment), t = Me();
|
|
892
901
|
},
|
|
893
|
-
m(
|
|
894
|
-
|
|
902
|
+
m(a, c) {
|
|
903
|
+
e && C(e, a, c), Ae(a, t, c), r = !0;
|
|
895
904
|
},
|
|
896
|
-
p(
|
|
897
|
-
const l =
|
|
898
|
-
5 ?
|
|
899
|
-
|
|
905
|
+
p(a, [c]) {
|
|
906
|
+
const l = c & /*blok, $$restProps*/
|
|
907
|
+
5 ? Je(n, [
|
|
908
|
+
c & /*blok*/
|
|
900
909
|
1 && { blok: (
|
|
901
910
|
/*blok*/
|
|
902
|
-
|
|
911
|
+
a[0]
|
|
903
912
|
) },
|
|
904
|
-
|
|
905
|
-
4 &&
|
|
913
|
+
c & /*$$restProps*/
|
|
914
|
+
4 && Fe(
|
|
906
915
|
/*$$restProps*/
|
|
907
|
-
|
|
916
|
+
a[2]
|
|
908
917
|
)
|
|
909
918
|
]) : {};
|
|
910
919
|
if (o !== (o = /*component*/
|
|
911
|
-
|
|
912
|
-
if (
|
|
913
|
-
|
|
914
|
-
const u =
|
|
920
|
+
a[1])) {
|
|
921
|
+
if (e) {
|
|
922
|
+
De();
|
|
923
|
+
const u = e;
|
|
915
924
|
Y(u.$$.fragment, 1, 0, () => {
|
|
916
925
|
I(u, 1);
|
|
917
|
-
}),
|
|
926
|
+
}), Be();
|
|
918
927
|
}
|
|
919
|
-
o ? (
|
|
928
|
+
o ? (e = J(o, i()), z(e.$$.fragment), O(e.$$.fragment, 1), C(e, t.parentNode, t)) : e = null;
|
|
920
929
|
} else
|
|
921
|
-
o &&
|
|
930
|
+
o && e.$set(l);
|
|
922
931
|
},
|
|
923
|
-
i(
|
|
924
|
-
r || (
|
|
932
|
+
i(a) {
|
|
933
|
+
r || (e && O(e.$$.fragment, a), r = !0);
|
|
925
934
|
},
|
|
926
|
-
o(
|
|
927
|
-
|
|
935
|
+
o(a) {
|
|
936
|
+
e && Y(e.$$.fragment, a), r = !1;
|
|
928
937
|
},
|
|
929
|
-
d(
|
|
930
|
-
|
|
938
|
+
d(a) {
|
|
939
|
+
a && X(t), e && I(e, a);
|
|
931
940
|
}
|
|
932
941
|
};
|
|
933
942
|
}
|
|
934
|
-
function
|
|
943
|
+
function Ge(s, e, t) {
|
|
935
944
|
const r = ["blok"];
|
|
936
|
-
let n = B(
|
|
937
|
-
return
|
|
938
|
-
|
|
939
|
-
}, [
|
|
945
|
+
let n = B(e, r), o, { blok: i } = e;
|
|
946
|
+
return i ? o = Qe(i.component) : console.error("Please provide a 'blok' property to the StoryblokComponent"), s.$$set = (a) => {
|
|
947
|
+
e = j(j({}, e), Ie(a)), t(2, n = B(e, r)), "blok" in a && t(0, i = a.blok);
|
|
948
|
+
}, [i, o, n];
|
|
940
949
|
}
|
|
941
|
-
class
|
|
942
|
-
constructor(
|
|
943
|
-
super(),
|
|
950
|
+
class et extends ze {
|
|
951
|
+
constructor(e) {
|
|
952
|
+
super(), Ye(this, e, Ge, Ke, Oe, { blok: 0 });
|
|
944
953
|
}
|
|
945
954
|
}
|
|
946
|
-
const
|
|
947
|
-
const
|
|
948
|
-
const n =
|
|
955
|
+
const tt = (s, e) => {
|
|
956
|
+
const t = (r) => {
|
|
957
|
+
const n = je(r);
|
|
949
958
|
n["data-blok-c"] && (s.setAttribute("data-blok-c", n["data-blok-c"]), s.setAttribute("data-blok-uid", n["data-blok-uid"]), s.classList.add("storyblok__outline"));
|
|
950
959
|
};
|
|
951
|
-
return e
|
|
960
|
+
return t(e), {
|
|
952
961
|
update(r) {
|
|
953
|
-
|
|
962
|
+
t(r);
|
|
954
963
|
}
|
|
955
964
|
};
|
|
956
965
|
};
|
|
957
966
|
let A = null;
|
|
958
|
-
const
|
|
967
|
+
const st = () => (A || console.log(
|
|
959
968
|
"You can't use getStoryblokApi if you're not loading apiPlugin."
|
|
960
969
|
), A);
|
|
961
970
|
let $ = null;
|
|
962
|
-
const
|
|
963
|
-
const { storyblokApi:
|
|
964
|
-
A =
|
|
965
|
-
},
|
|
966
|
-
let
|
|
967
|
-
return
|
|
971
|
+
const rt = (s) => {
|
|
972
|
+
const { storyblokApi: e } = Se(s);
|
|
973
|
+
A = e, $ = s.components || {};
|
|
974
|
+
}, Qe = (s) => {
|
|
975
|
+
let e = null;
|
|
976
|
+
return e = typeof $ == "function" ? $()[s] : $[s], e || console.error(`You didn't load the ${s} component. Please load it in storyblokInit. For example:
|
|
968
977
|
storyblokInit({
|
|
969
978
|
accessToken: "<your-token>",
|
|
970
979
|
components: {
|
|
971
980
|
"teaser": Teaser
|
|
972
981
|
}
|
|
973
982
|
})
|
|
974
|
-
`),
|
|
983
|
+
`), e;
|
|
975
984
|
};
|
|
976
985
|
export {
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
986
|
+
Te as RichTextSchema,
|
|
987
|
+
et as StoryblokComponent,
|
|
988
|
+
We as apiPlugin,
|
|
989
|
+
Qe as getComponent,
|
|
990
|
+
st as getStoryblokApi,
|
|
991
|
+
Ze as renderRichText,
|
|
992
|
+
tt as storyblokEditable,
|
|
993
|
+
rt as storyblokInit,
|
|
994
|
+
st as useStoryblokApi,
|
|
995
|
+
Xe as useStoryblokBridge
|
|
987
996
|
};
|