@storyblok/svelte 2.3.3 → 2.3.5
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 +4 -4
- package/dist/storyblok-svelte.mjs +626 -896
- package/package.json +4 -4
|
@@ -1,69 +1,37 @@
|
|
|
1
|
-
import
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (__propIsEnum.call(b, prop))
|
|
16
|
-
__defNormalProp(a2, prop, b[prop]);
|
|
17
|
-
}
|
|
18
|
-
return a2;
|
|
19
|
-
};
|
|
20
|
-
var __spreadProps = (a2, b) => __defProps(a2, __getOwnPropDescs(b));
|
|
21
|
-
let loaded = false;
|
|
22
|
-
const callbacks = [];
|
|
23
|
-
const loadBridge = (src) => {
|
|
24
|
-
return new Promise((resolve, reject) => {
|
|
25
|
-
if (typeof window === "undefined")
|
|
26
|
-
return;
|
|
27
|
-
window.storyblokRegisterEvent = (cb) => {
|
|
28
|
-
if (window.location === window.parent.location) {
|
|
29
|
-
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
if (!loaded)
|
|
33
|
-
callbacks.push(cb);
|
|
34
|
-
else
|
|
35
|
-
cb();
|
|
36
|
-
};
|
|
37
|
-
if (document.getElementById("storyblok-javascript-bridge"))
|
|
1
|
+
import rt from "axios";
|
|
2
|
+
var nt = Object.defineProperty, st = Object.defineProperties, ot = Object.getOwnPropertyDescriptors, q = Object.getOwnPropertySymbols, it = Object.prototype.hasOwnProperty, at = Object.prototype.propertyIsEnumerable, L = (r, t, e) => t in r ? nt(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, d = (r, t) => {
|
|
3
|
+
for (var e in t || (t = {}))
|
|
4
|
+
it.call(t, e) && L(r, e, t[e]);
|
|
5
|
+
if (q)
|
|
6
|
+
for (var e of q(t))
|
|
7
|
+
at.call(t, e) && L(r, e, t[e]);
|
|
8
|
+
return r;
|
|
9
|
+
}, $ = (r, t) => st(r, ot(t));
|
|
10
|
+
let B = !1;
|
|
11
|
+
const z = [], lt = (r) => new Promise((t, e) => {
|
|
12
|
+
if (typeof window > "u" || (window.storyblokRegisterEvent = (s) => {
|
|
13
|
+
if (window.location === window.parent.location) {
|
|
14
|
+
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
38
15
|
return;
|
|
39
|
-
const script = document.createElement("script");
|
|
40
|
-
script.async = true;
|
|
41
|
-
script.src = src;
|
|
42
|
-
script.id = "storyblok-javascript-bridge";
|
|
43
|
-
script.onerror = (error) => reject(error);
|
|
44
|
-
script.onload = (ev) => {
|
|
45
|
-
callbacks.forEach((cb) => cb());
|
|
46
|
-
loaded = true;
|
|
47
|
-
resolve(ev);
|
|
48
|
-
};
|
|
49
|
-
document.getElementsByTagName("head")[0].appendChild(script);
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
const pick = function(attrs, allowed) {
|
|
53
|
-
if (!attrs) {
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
let h2 = {};
|
|
57
|
-
for (let key in attrs) {
|
|
58
|
-
let value = attrs[key];
|
|
59
|
-
if (allowed.indexOf(key) > -1 && value !== null) {
|
|
60
|
-
h2[key] = value;
|
|
61
16
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
17
|
+
B ? s() : z.push(s);
|
|
18
|
+
}, document.getElementById("storyblok-javascript-bridge")))
|
|
19
|
+
return;
|
|
20
|
+
const n = document.createElement("script");
|
|
21
|
+
n.async = !0, n.src = r, n.id = "storyblok-javascript-bridge", n.onerror = (s) => e(s), n.onload = (s) => {
|
|
22
|
+
z.forEach((o) => o()), B = !0, t(s);
|
|
23
|
+
}, document.getElementsByTagName("head")[0].appendChild(n);
|
|
24
|
+
}), ct = function(r, t) {
|
|
25
|
+
if (!r)
|
|
26
|
+
return null;
|
|
27
|
+
let e = {};
|
|
28
|
+
for (let n in r) {
|
|
29
|
+
let s = r[n];
|
|
30
|
+
t.indexOf(n) > -1 && s !== null && (e[n] = s);
|
|
31
|
+
}
|
|
32
|
+
return e;
|
|
33
|
+
}, ut = (r) => r === "email";
|
|
34
|
+
var ht = {
|
|
67
35
|
nodes: {
|
|
68
36
|
horizontal_rule() {
|
|
69
37
|
return {
|
|
@@ -80,13 +48,13 @@ var defaultHtmlSerializer = {
|
|
|
80
48
|
tag: "ul"
|
|
81
49
|
};
|
|
82
50
|
},
|
|
83
|
-
code_block(
|
|
51
|
+
code_block(r) {
|
|
84
52
|
return {
|
|
85
53
|
tag: [
|
|
86
54
|
"pre",
|
|
87
55
|
{
|
|
88
56
|
tag: "code",
|
|
89
|
-
attrs:
|
|
57
|
+
attrs: r.attrs
|
|
90
58
|
}
|
|
91
59
|
]
|
|
92
60
|
};
|
|
@@ -96,17 +64,17 @@ var defaultHtmlSerializer = {
|
|
|
96
64
|
singleTag: "br"
|
|
97
65
|
};
|
|
98
66
|
},
|
|
99
|
-
heading(
|
|
67
|
+
heading(r) {
|
|
100
68
|
return {
|
|
101
|
-
tag: `h${
|
|
69
|
+
tag: `h${r.attrs.level}`
|
|
102
70
|
};
|
|
103
71
|
},
|
|
104
|
-
image(
|
|
72
|
+
image(r) {
|
|
105
73
|
return {
|
|
106
74
|
singleTag: [
|
|
107
75
|
{
|
|
108
76
|
tag: "img",
|
|
109
|
-
attrs:
|
|
77
|
+
attrs: ct(r.attrs, ["src", "alt", "title"])
|
|
110
78
|
}
|
|
111
79
|
]
|
|
112
80
|
};
|
|
@@ -158,161 +126,100 @@ var defaultHtmlSerializer = {
|
|
|
158
126
|
tag: "i"
|
|
159
127
|
};
|
|
160
128
|
},
|
|
161
|
-
link(
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
if (isEmailLinkType(linktype)) {
|
|
165
|
-
attrs.href = `mailto:${attrs.href}`;
|
|
166
|
-
}
|
|
167
|
-
if (attrs.anchor) {
|
|
168
|
-
attrs.href = `${attrs.href}#${attrs.anchor}`;
|
|
169
|
-
delete attrs.anchor;
|
|
170
|
-
}
|
|
171
|
-
return {
|
|
129
|
+
link(r) {
|
|
130
|
+
const t = d({}, r.attrs), { linktype: e = "url" } = r.attrs;
|
|
131
|
+
return ut(e) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), {
|
|
172
132
|
tag: [
|
|
173
133
|
{
|
|
174
134
|
tag: "a",
|
|
175
|
-
attrs
|
|
135
|
+
attrs: t
|
|
176
136
|
}
|
|
177
137
|
]
|
|
178
138
|
};
|
|
179
139
|
},
|
|
180
|
-
styled(
|
|
140
|
+
styled(r) {
|
|
181
141
|
return {
|
|
182
142
|
tag: [
|
|
183
143
|
{
|
|
184
144
|
tag: "span",
|
|
185
|
-
attrs:
|
|
145
|
+
attrs: r.attrs
|
|
186
146
|
}
|
|
187
147
|
]
|
|
188
148
|
};
|
|
189
149
|
}
|
|
190
150
|
}
|
|
191
151
|
};
|
|
192
|
-
const
|
|
193
|
-
const
|
|
152
|
+
const ft = function(r) {
|
|
153
|
+
const t = {
|
|
194
154
|
"&": "&",
|
|
195
155
|
"<": "<",
|
|
196
156
|
">": ">",
|
|
197
157
|
'"': """,
|
|
198
158
|
"'": "'"
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
const reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
|
|
202
|
-
return string && reHasUnescapedHtml.test(string) ? string.replace(reUnescapedHtml, (chr) => htmlEscapes[chr]) : string;
|
|
159
|
+
}, e = /[&<>"']/g, n = RegExp(e.source);
|
|
160
|
+
return r && n.test(r) ? r.replace(e, (s) => t[s]) : r;
|
|
203
161
|
};
|
|
204
|
-
class
|
|
205
|
-
constructor(
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
this.
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
let html = "";
|
|
221
|
-
data.content.forEach((node) => {
|
|
222
|
-
html += this.renderNode(node);
|
|
223
|
-
});
|
|
224
|
-
return html;
|
|
225
|
-
}
|
|
226
|
-
console.warn("The render method must receive an object with a content field, which is an array");
|
|
227
|
-
return "";
|
|
228
|
-
}
|
|
229
|
-
renderNode(item) {
|
|
230
|
-
let html = [];
|
|
231
|
-
if (item.marks) {
|
|
232
|
-
item.marks.forEach((m) => {
|
|
233
|
-
const mark = this.getMatchingMark(m);
|
|
234
|
-
if (mark) {
|
|
235
|
-
html.push(this.renderOpeningTag(mark.tag));
|
|
236
|
-
}
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
const node = this.getMatchingNode(item);
|
|
240
|
-
if (node && node.tag) {
|
|
241
|
-
html.push(this.renderOpeningTag(node.tag));
|
|
242
|
-
}
|
|
243
|
-
if (item.content) {
|
|
244
|
-
item.content.forEach((content) => {
|
|
245
|
-
html.push(this.renderNode(content));
|
|
246
|
-
});
|
|
247
|
-
} else if (item.text) {
|
|
248
|
-
html.push(escapeHTML(item.text));
|
|
249
|
-
} else if (node && node.singleTag) {
|
|
250
|
-
html.push(this.renderTag(node.singleTag, " /"));
|
|
251
|
-
} else if (node && node.html) {
|
|
252
|
-
html.push(node.html);
|
|
162
|
+
class K {
|
|
163
|
+
constructor(t) {
|
|
164
|
+
t || (t = ht), this.marks = t.marks || [], this.nodes = t.nodes || [];
|
|
165
|
+
}
|
|
166
|
+
addNode(t, e) {
|
|
167
|
+
this.nodes[t] = e;
|
|
168
|
+
}
|
|
169
|
+
addMark(t, e) {
|
|
170
|
+
this.marks[t] = e;
|
|
171
|
+
}
|
|
172
|
+
render(t = {}) {
|
|
173
|
+
if (t.content && Array.isArray(t.content)) {
|
|
174
|
+
let e = "";
|
|
175
|
+
return t.content.forEach((n) => {
|
|
176
|
+
e += this.renderNode(n);
|
|
177
|
+
}), e;
|
|
253
178
|
}
|
|
254
|
-
|
|
255
|
-
html.push(this.renderClosingTag(node.tag));
|
|
256
|
-
}
|
|
257
|
-
if (item.marks) {
|
|
258
|
-
item.marks.slice(0).reverse().forEach((m) => {
|
|
259
|
-
const mark = this.getMatchingMark(m);
|
|
260
|
-
if (mark) {
|
|
261
|
-
html.push(this.renderClosingTag(mark.tag));
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
return html.join("");
|
|
179
|
+
return console.warn("The render method must receive an object with a content field, which is an array"), "";
|
|
266
180
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
181
|
+
renderNode(t) {
|
|
182
|
+
let e = [];
|
|
183
|
+
t.marks && t.marks.forEach((s) => {
|
|
184
|
+
const o = this.getMatchingMark(s);
|
|
185
|
+
o && e.push(this.renderOpeningTag(o.tag));
|
|
186
|
+
});
|
|
187
|
+
const n = this.getMatchingNode(t);
|
|
188
|
+
return n && n.tag && e.push(this.renderOpeningTag(n.tag)), t.content ? t.content.forEach((s) => {
|
|
189
|
+
e.push(this.renderNode(s));
|
|
190
|
+
}) : t.text ? e.push(ft(t.text)) : n && n.singleTag ? e.push(this.renderTag(n.singleTag, " /")) : n && n.html && e.push(n.html), n && n.tag && e.push(this.renderClosingTag(n.tag)), t.marks && t.marks.slice(0).reverse().forEach((s) => {
|
|
191
|
+
const o = this.getMatchingMark(s);
|
|
192
|
+
o && e.push(this.renderClosingTag(o.tag));
|
|
193
|
+
}), e.join("");
|
|
194
|
+
}
|
|
195
|
+
renderTag(t, e) {
|
|
196
|
+
return t.constructor === String ? `<${t}${e}>` : t.map((s) => {
|
|
197
|
+
if (s.constructor === String)
|
|
198
|
+
return `<${s}${e}>`;
|
|
199
|
+
{
|
|
200
|
+
let o = `<${s.tag}`;
|
|
201
|
+
if (s.attrs)
|
|
202
|
+
for (let a in s.attrs) {
|
|
203
|
+
let i = s.attrs[a];
|
|
204
|
+
i !== null && (o += ` ${a}="${i}"`);
|
|
282
205
|
}
|
|
283
|
-
}
|
|
284
|
-
return `${h2}${ending}>`;
|
|
206
|
+
return `${o}${e}>`;
|
|
285
207
|
}
|
|
286
|
-
});
|
|
287
|
-
return all.join("");
|
|
208
|
+
}).join("");
|
|
288
209
|
}
|
|
289
|
-
renderOpeningTag(
|
|
290
|
-
return this.renderTag(
|
|
210
|
+
renderOpeningTag(t) {
|
|
211
|
+
return this.renderTag(t, "");
|
|
291
212
|
}
|
|
292
|
-
renderClosingTag(
|
|
293
|
-
|
|
294
|
-
return `</${tags}>`;
|
|
295
|
-
}
|
|
296
|
-
const all = tags.slice(0).reverse().map((tag) => {
|
|
297
|
-
if (tag.constructor === String) {
|
|
298
|
-
return `</${tag}>`;
|
|
299
|
-
} else {
|
|
300
|
-
return `</${tag.tag}>`;
|
|
301
|
-
}
|
|
302
|
-
});
|
|
303
|
-
return all.join("");
|
|
213
|
+
renderClosingTag(t) {
|
|
214
|
+
return t.constructor === String ? `</${t}>` : t.slice(0).reverse().map((n) => n.constructor === String ? `</${n}>` : `</${n.tag}>`).join("");
|
|
304
215
|
}
|
|
305
|
-
getMatchingNode(
|
|
306
|
-
if (typeof this.nodes[
|
|
307
|
-
return;
|
|
308
|
-
}
|
|
309
|
-
return this.nodes[item.type](item);
|
|
216
|
+
getMatchingNode(t) {
|
|
217
|
+
if (typeof this.nodes[t.type] == "function")
|
|
218
|
+
return this.nodes[t.type](t);
|
|
310
219
|
}
|
|
311
|
-
getMatchingMark(
|
|
312
|
-
if (typeof this.marks[
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
return this.marks[item.type](item);
|
|
220
|
+
getMatchingMark(t) {
|
|
221
|
+
if (typeof this.marks[t.type] == "function")
|
|
222
|
+
return this.marks[t.type](t);
|
|
316
223
|
}
|
|
317
224
|
}
|
|
318
225
|
/*!
|
|
@@ -320,340 +227,334 @@ class RichTextResolver {
|
|
|
320
227
|
* Universal JavaScript SDK for Storyblok's API
|
|
321
228
|
* (c) 2020-2022 Stobylok Team
|
|
322
229
|
*/
|
|
323
|
-
function
|
|
324
|
-
return typeof
|
|
230
|
+
function D(r) {
|
|
231
|
+
return typeof r == "number" && r == r && r !== 1 / 0 && r !== -1 / 0;
|
|
325
232
|
}
|
|
326
|
-
function
|
|
327
|
-
if (!t
|
|
233
|
+
function G(r, t, e) {
|
|
234
|
+
if (!D(t))
|
|
328
235
|
throw new TypeError("Expected `limit` to be a finite number");
|
|
329
|
-
if (!
|
|
236
|
+
if (!D(e))
|
|
330
237
|
throw new TypeError("Expected `interval` to be a finite number");
|
|
331
|
-
var
|
|
332
|
-
|
|
333
|
-
var
|
|
334
|
-
|
|
335
|
-
return
|
|
238
|
+
var n = [], s = [], o = 0, a = function() {
|
|
239
|
+
o++;
|
|
240
|
+
var l = setTimeout(function() {
|
|
241
|
+
o--, n.length > 0 && a(), s = s.filter(function(u) {
|
|
242
|
+
return u !== l;
|
|
336
243
|
});
|
|
337
|
-
},
|
|
338
|
-
|
|
339
|
-
var
|
|
340
|
-
|
|
341
|
-
},
|
|
342
|
-
var
|
|
343
|
-
return new Promise(function(
|
|
344
|
-
|
|
244
|
+
}, e);
|
|
245
|
+
s.indexOf(l) < 0 && s.push(l);
|
|
246
|
+
var c = n.shift();
|
|
247
|
+
c.resolve(r.apply(c.self, c.args));
|
|
248
|
+
}, i = function() {
|
|
249
|
+
var l = arguments, c = this;
|
|
250
|
+
return new Promise(function(u, h) {
|
|
251
|
+
n.push({ resolve: u, reject: h, args: l, self: c }), o < t && a();
|
|
345
252
|
});
|
|
346
253
|
};
|
|
347
|
-
return
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
}),
|
|
351
|
-
},
|
|
254
|
+
return i.abort = function() {
|
|
255
|
+
s.forEach(clearTimeout), s = [], n.forEach(function(l) {
|
|
256
|
+
l.reject(new throttle.AbortError());
|
|
257
|
+
}), n.length = 0;
|
|
258
|
+
}, i;
|
|
352
259
|
}
|
|
353
|
-
|
|
260
|
+
G.AbortError = function() {
|
|
354
261
|
Error.call(this, "Throttled function aborted"), this.name = "AbortError";
|
|
355
262
|
};
|
|
356
|
-
const
|
|
357
|
-
if (!
|
|
263
|
+
const dt = function(r, t) {
|
|
264
|
+
if (!r)
|
|
358
265
|
return null;
|
|
359
|
-
let
|
|
360
|
-
for (let
|
|
361
|
-
let
|
|
362
|
-
|
|
266
|
+
let e = {};
|
|
267
|
+
for (let n in r) {
|
|
268
|
+
let s = r[n];
|
|
269
|
+
t.indexOf(n) > -1 && s !== null && (e[n] = s);
|
|
363
270
|
}
|
|
364
|
-
return
|
|
271
|
+
return e;
|
|
365
272
|
};
|
|
366
|
-
var
|
|
367
|
-
const
|
|
368
|
-
return
|
|
369
|
-
}, styled: (
|
|
370
|
-
class
|
|
371
|
-
constructor(
|
|
372
|
-
|
|
373
|
-
}
|
|
374
|
-
addNode(
|
|
375
|
-
this.nodes[
|
|
376
|
-
}
|
|
377
|
-
addMark(
|
|
378
|
-
this.marks[
|
|
379
|
-
}
|
|
380
|
-
render(
|
|
381
|
-
if (
|
|
382
|
-
let
|
|
383
|
-
return
|
|
384
|
-
|
|
385
|
-
}),
|
|
273
|
+
var pt = { nodes: { horizontal_rule: () => ({ singleTag: "hr" }), blockquote: () => ({ tag: "blockquote" }), bullet_list: () => ({ tag: "ul" }), code_block: (r) => ({ tag: ["pre", { tag: "code", attrs: r.attrs }] }), hard_break: () => ({ singleTag: "br" }), heading: (r) => ({ tag: `h${r.attrs.level}` }), image: (r) => ({ singleTag: [{ tag: "img", attrs: dt(r.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(r) {
|
|
274
|
+
const t = d({}, r.attrs), { linktype: e = "url" } = r.attrs;
|
|
275
|
+
return e === "email" && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), { tag: [{ tag: "a", attrs: t }] };
|
|
276
|
+
}, styled: (r) => ({ tag: [{ tag: "span", attrs: r.attrs }] }) } };
|
|
277
|
+
class gt {
|
|
278
|
+
constructor(t) {
|
|
279
|
+
t || (t = pt), this.marks = t.marks || [], this.nodes = t.nodes || [];
|
|
280
|
+
}
|
|
281
|
+
addNode(t, e) {
|
|
282
|
+
this.nodes[t] = e;
|
|
283
|
+
}
|
|
284
|
+
addMark(t, e) {
|
|
285
|
+
this.marks[t] = e;
|
|
286
|
+
}
|
|
287
|
+
render(t = {}) {
|
|
288
|
+
if (t.content && Array.isArray(t.content)) {
|
|
289
|
+
let e = "";
|
|
290
|
+
return t.content.forEach((n) => {
|
|
291
|
+
e += this.renderNode(n);
|
|
292
|
+
}), e;
|
|
386
293
|
}
|
|
387
294
|
return console.warn("The render method must receive an object with a content field, which is an array"), "";
|
|
388
295
|
}
|
|
389
|
-
renderNode(
|
|
390
|
-
let
|
|
391
|
-
|
|
392
|
-
const
|
|
393
|
-
|
|
296
|
+
renderNode(t) {
|
|
297
|
+
let e = [];
|
|
298
|
+
t.marks && t.marks.forEach((s) => {
|
|
299
|
+
const o = this.getMatchingMark(s);
|
|
300
|
+
o && e.push(this.renderOpeningTag(o.tag));
|
|
394
301
|
});
|
|
395
|
-
const
|
|
396
|
-
return
|
|
397
|
-
|
|
398
|
-
}) :
|
|
399
|
-
const
|
|
400
|
-
return
|
|
401
|
-
}(
|
|
402
|
-
const
|
|
403
|
-
|
|
404
|
-
}),
|
|
405
|
-
}
|
|
406
|
-
renderTag(
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
if (e3.constructor === String)
|
|
411
|
-
return `<${e3}${t2}>`;
|
|
302
|
+
const n = this.getMatchingNode(t);
|
|
303
|
+
return n && n.tag && e.push(this.renderOpeningTag(n.tag)), t.content ? t.content.forEach((s) => {
|
|
304
|
+
e.push(this.renderNode(s));
|
|
305
|
+
}) : t.text ? e.push(function(s) {
|
|
306
|
+
const o = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }, a = /[&<>"']/g, i = RegExp(a.source);
|
|
307
|
+
return s && i.test(s) ? s.replace(a, (l) => o[l]) : s;
|
|
308
|
+
}(t.text)) : n && n.singleTag ? e.push(this.renderTag(n.singleTag, " /")) : n && n.html && e.push(n.html), n && n.tag && e.push(this.renderClosingTag(n.tag)), t.marks && t.marks.slice(0).reverse().forEach((s) => {
|
|
309
|
+
const o = this.getMatchingMark(s);
|
|
310
|
+
o && e.push(this.renderClosingTag(o.tag));
|
|
311
|
+
}), e.join("");
|
|
312
|
+
}
|
|
313
|
+
renderTag(t, e) {
|
|
314
|
+
return t.constructor === String ? `<${t}${e}>` : t.map((n) => {
|
|
315
|
+
if (n.constructor === String)
|
|
316
|
+
return `<${n}${e}>`;
|
|
412
317
|
{
|
|
413
|
-
let
|
|
414
|
-
if (
|
|
415
|
-
for (let
|
|
416
|
-
let
|
|
417
|
-
|
|
318
|
+
let s = `<${n.tag}`;
|
|
319
|
+
if (n.attrs)
|
|
320
|
+
for (let o in n.attrs) {
|
|
321
|
+
let a = n.attrs[o];
|
|
322
|
+
a !== null && (s += ` ${o}="${a}"`);
|
|
418
323
|
}
|
|
419
|
-
return `${
|
|
324
|
+
return `${s}${e}>`;
|
|
420
325
|
}
|
|
421
326
|
}).join("");
|
|
422
327
|
}
|
|
423
|
-
renderOpeningTag(
|
|
424
|
-
return this.renderTag(
|
|
328
|
+
renderOpeningTag(t) {
|
|
329
|
+
return this.renderTag(t, "");
|
|
425
330
|
}
|
|
426
|
-
renderClosingTag(
|
|
427
|
-
|
|
428
|
-
return `</${e2}>`;
|
|
429
|
-
return e2.slice(0).reverse().map((e3) => e3.constructor === String ? `</${e3}>` : `</${e3.tag}>`).join("");
|
|
331
|
+
renderClosingTag(t) {
|
|
332
|
+
return t.constructor === String ? `</${t}>` : t.slice(0).reverse().map((e) => e.constructor === String ? `</${e}>` : `</${e.tag}>`).join("");
|
|
430
333
|
}
|
|
431
|
-
getMatchingNode(
|
|
432
|
-
if (typeof this.nodes[
|
|
433
|
-
return this.nodes[
|
|
334
|
+
getMatchingNode(t) {
|
|
335
|
+
if (typeof this.nodes[t.type] == "function")
|
|
336
|
+
return this.nodes[t.type](t);
|
|
434
337
|
}
|
|
435
|
-
getMatchingMark(
|
|
436
|
-
if (typeof this.marks[
|
|
437
|
-
return this.marks[
|
|
338
|
+
getMatchingMark(t) {
|
|
339
|
+
if (typeof this.marks[t.type] == "function")
|
|
340
|
+
return this.marks[t.type](t);
|
|
438
341
|
}
|
|
439
342
|
}
|
|
440
|
-
const
|
|
441
|
-
const
|
|
442
|
-
return ((
|
|
443
|
-
},
|
|
444
|
-
const
|
|
445
|
-
for (const
|
|
446
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
343
|
+
const mt = (r = 0, t = r) => {
|
|
344
|
+
const e = Math.abs(t - r) || 0, n = r < t ? 1 : -1;
|
|
345
|
+
return ((s = 0, o) => [...Array(s)].map(o))(e, (s, o) => o * n + r);
|
|
346
|
+
}, R = (r, t, e) => {
|
|
347
|
+
const n = [];
|
|
348
|
+
for (const s in r) {
|
|
349
|
+
if (!Object.prototype.hasOwnProperty.call(r, s))
|
|
447
350
|
continue;
|
|
448
|
-
const
|
|
449
|
-
let
|
|
450
|
-
|
|
351
|
+
const o = r[s], a = e ? "" : encodeURIComponent(s);
|
|
352
|
+
let i;
|
|
353
|
+
i = typeof o == "object" ? R(o, t ? t + encodeURIComponent("[" + a + "]") : a, Array.isArray(o)) : (t ? t + encodeURIComponent("[" + a + "]") : a) + "=" + encodeURIComponent(o), n.push(i);
|
|
451
354
|
}
|
|
452
|
-
return
|
|
355
|
+
return n.join("&");
|
|
453
356
|
};
|
|
454
|
-
let
|
|
455
|
-
class
|
|
456
|
-
constructor(
|
|
457
|
-
if (!
|
|
458
|
-
let
|
|
459
|
-
|
|
357
|
+
let _ = {}, p = {};
|
|
358
|
+
class yt {
|
|
359
|
+
constructor(t, e) {
|
|
360
|
+
if (!e) {
|
|
361
|
+
let o = t.region ? `-${t.region}` : "", a = t.https === !1 ? "http" : "https";
|
|
362
|
+
e = t.oauthToken === void 0 ? `${a}://api${o}.storyblok.com/v2` : `${a}://api${o}.storyblok.com/v1`;
|
|
460
363
|
}
|
|
461
|
-
let
|
|
462
|
-
|
|
463
|
-
}
|
|
464
|
-
setComponentResolver(
|
|
465
|
-
this.richTextResolver.addNode("blok", (
|
|
466
|
-
let
|
|
467
|
-
return
|
|
468
|
-
|
|
469
|
-
}), { html:
|
|
364
|
+
let n = Object.assign({}, t.headers), s = 5;
|
|
365
|
+
t.oauthToken !== void 0 && (n.Authorization = t.oauthToken, s = 3), t.rateLimit !== void 0 && (s = t.rateLimit), this.richTextResolver = new gt(t.richTextSchema), typeof t.componentResolver == "function" && this.setComponentResolver(t.componentResolver), this.maxRetries = t.maxRetries || 5, this.throttle = G(this.throttledRequest, s, 1e3), this.accessToken = t.accessToken, this.relations = {}, this.links = {}, this.cache = t.cache || { clear: "manual" }, this.client = rt.create({ baseURL: e, timeout: t.timeout || 0, headers: n, proxy: t.proxy || !1 }), t.responseInterceptor && this.client.interceptors.response.use((o) => t.responseInterceptor(o)), this.resolveNestedRelations = t.resolveNestedRelations || !0;
|
|
366
|
+
}
|
|
367
|
+
setComponentResolver(t) {
|
|
368
|
+
this.richTextResolver.addNode("blok", (e) => {
|
|
369
|
+
let n = "";
|
|
370
|
+
return e.attrs.body.forEach((s) => {
|
|
371
|
+
n += t(s.component, s);
|
|
372
|
+
}), { html: n };
|
|
470
373
|
});
|
|
471
374
|
}
|
|
472
|
-
parseParams(
|
|
473
|
-
return
|
|
375
|
+
parseParams(t = {}) {
|
|
376
|
+
return t.version || (t.version = "published"), t.token || (t.token = this.getToken()), t.cv || (t.cv = p[t.token]), Array.isArray(t.resolve_relations) && (t.resolve_relations = t.resolve_relations.join(",")), t;
|
|
474
377
|
}
|
|
475
|
-
factoryParamOptions(
|
|
476
|
-
return ((
|
|
378
|
+
factoryParamOptions(t, e = {}) {
|
|
379
|
+
return ((n = "") => n.indexOf("/cdn/") > -1)(t) ? this.parseParams(e) : e;
|
|
477
380
|
}
|
|
478
|
-
makeRequest(
|
|
479
|
-
const
|
|
480
|
-
return this.cacheResponse(
|
|
381
|
+
makeRequest(t, e, n, s) {
|
|
382
|
+
const o = this.factoryParamOptions(t, ((a = {}, i = 25, l = 1) => $(d({}, a), { per_page: i, page: l }))(e, n, s));
|
|
383
|
+
return this.cacheResponse(t, o);
|
|
481
384
|
}
|
|
482
|
-
get(
|
|
483
|
-
let
|
|
484
|
-
const
|
|
485
|
-
return this.cacheResponse(
|
|
385
|
+
get(t, e) {
|
|
386
|
+
let n = `/${t}`;
|
|
387
|
+
const s = this.factoryParamOptions(n, e);
|
|
388
|
+
return this.cacheResponse(n, s);
|
|
486
389
|
}
|
|
487
|
-
async getAll(
|
|
488
|
-
const
|
|
489
|
-
|
|
490
|
-
const
|
|
491
|
-
return ((
|
|
390
|
+
async getAll(t, e = {}, n) {
|
|
391
|
+
const s = e.per_page || 25, o = `/${t}`, a = o.split("/");
|
|
392
|
+
n = n || a[a.length - 1];
|
|
393
|
+
const i = await this.makeRequest(o, e, s, 1), l = i.total ? Math.ceil(i.total / s) : 1;
|
|
394
|
+
return ((c = [], u) => c.map(u).reduce((h, k) => [...h, ...k], []))([i, ...await (async (c = [], u) => Promise.all(c.map(u)))(mt(1, l), async (c) => this.makeRequest(o, e, s, c + 1))], (c) => Object.values(c.data[n]));
|
|
492
395
|
}
|
|
493
|
-
post(
|
|
494
|
-
let
|
|
495
|
-
return this.throttle("post",
|
|
396
|
+
post(t, e) {
|
|
397
|
+
let n = `/${t}`;
|
|
398
|
+
return this.throttle("post", n, e);
|
|
496
399
|
}
|
|
497
|
-
put(
|
|
498
|
-
let
|
|
499
|
-
return this.throttle("put",
|
|
400
|
+
put(t, e) {
|
|
401
|
+
let n = `/${t}`;
|
|
402
|
+
return this.throttle("put", n, e);
|
|
500
403
|
}
|
|
501
|
-
delete(
|
|
502
|
-
let
|
|
503
|
-
return this.throttle("delete",
|
|
404
|
+
delete(t, e) {
|
|
405
|
+
let n = `/${t}`;
|
|
406
|
+
return this.throttle("delete", n, e);
|
|
504
407
|
}
|
|
505
|
-
getStories(
|
|
506
|
-
return this.get("cdn/stories",
|
|
408
|
+
getStories(t) {
|
|
409
|
+
return this.get("cdn/stories", t);
|
|
507
410
|
}
|
|
508
|
-
getStory(
|
|
509
|
-
return this.get(`cdn/stories/${
|
|
411
|
+
getStory(t, e) {
|
|
412
|
+
return this.get(`cdn/stories/${t}`, e);
|
|
510
413
|
}
|
|
511
|
-
setToken(
|
|
512
|
-
this.accessToken =
|
|
414
|
+
setToken(t) {
|
|
415
|
+
this.accessToken = t;
|
|
513
416
|
}
|
|
514
417
|
getToken() {
|
|
515
418
|
return this.accessToken;
|
|
516
419
|
}
|
|
517
|
-
_cleanCopy(
|
|
518
|
-
return JSON.parse(JSON.stringify(
|
|
519
|
-
}
|
|
520
|
-
_insertLinks(
|
|
521
|
-
const
|
|
522
|
-
|
|
523
|
-
}
|
|
524
|
-
_insertRelations(
|
|
525
|
-
if (
|
|
526
|
-
if (typeof
|
|
527
|
-
this.relations[
|
|
528
|
-
else if (
|
|
529
|
-
let
|
|
530
|
-
|
|
531
|
-
this.relations[
|
|
532
|
-
}),
|
|
420
|
+
_cleanCopy(t) {
|
|
421
|
+
return JSON.parse(JSON.stringify(t));
|
|
422
|
+
}
|
|
423
|
+
_insertLinks(t, e) {
|
|
424
|
+
const n = t[e];
|
|
425
|
+
n && n.fieldtype == "multilink" && n.linktype == "story" && typeof n.id == "string" && this.links[n.id] ? n.story = this._cleanCopy(this.links[n.id]) : n && n.linktype === "story" && typeof n.uuid == "string" && this.links[n.uuid] && (n.story = this._cleanCopy(this.links[n.uuid]));
|
|
426
|
+
}
|
|
427
|
+
_insertRelations(t, e, n) {
|
|
428
|
+
if (n.indexOf(t.component + "." + e) > -1) {
|
|
429
|
+
if (typeof t[e] == "string")
|
|
430
|
+
this.relations[t[e]] && (t[e] = this._cleanCopy(this.relations[t[e]]));
|
|
431
|
+
else if (t[e].constructor === Array) {
|
|
432
|
+
let s = [];
|
|
433
|
+
t[e].forEach((o) => {
|
|
434
|
+
this.relations[o] && s.push(this._cleanCopy(this.relations[o]));
|
|
435
|
+
}), t[e] = s;
|
|
533
436
|
}
|
|
534
437
|
}
|
|
535
438
|
}
|
|
536
|
-
_insertAssetsRelations(
|
|
537
|
-
|
|
538
|
-
|
|
439
|
+
_insertAssetsRelations(t, e) {
|
|
440
|
+
e.forEach((n) => {
|
|
441
|
+
t.id === n.id && (t.original = n, t.original.filename = t.filename, t.original.filename = t.original.filename.includes("https://s3.amazonaws.com/") ? t.original.filename : t.original.filename.replace("https://", "https://s3.amazonaws.com/"), delete t.original.s3_filename);
|
|
539
442
|
});
|
|
540
443
|
}
|
|
541
|
-
iterateTree(
|
|
542
|
-
let
|
|
543
|
-
if (
|
|
544
|
-
if (
|
|
545
|
-
for (let
|
|
546
|
-
|
|
547
|
-
else if (
|
|
548
|
-
if (
|
|
444
|
+
iterateTree(t, e) {
|
|
445
|
+
let n = (s) => {
|
|
446
|
+
if (s != null) {
|
|
447
|
+
if (s.constructor === Array)
|
|
448
|
+
for (let o = 0; o < s.length; o++)
|
|
449
|
+
n(s[o]);
|
|
450
|
+
else if (s.constructor === Object) {
|
|
451
|
+
if (s._stopResolving)
|
|
549
452
|
return;
|
|
550
|
-
for (let
|
|
551
|
-
|
|
453
|
+
for (let o in s)
|
|
454
|
+
s.component && s._uid || s.type === "link" ? (this._insertRelations(s, o, e), this._insertLinks(s, o)) : "id" in s && s.fieldtype === "asset" && this._insertAssetsRelations(s, e), n(s[o]);
|
|
552
455
|
}
|
|
553
456
|
}
|
|
554
457
|
};
|
|
555
|
-
|
|
556
|
-
}
|
|
557
|
-
async resolveLinks(
|
|
558
|
-
let
|
|
559
|
-
if (
|
|
560
|
-
const
|
|
561
|
-
let
|
|
562
|
-
const
|
|
563
|
-
for (let
|
|
564
|
-
const
|
|
565
|
-
|
|
458
|
+
n(t.content);
|
|
459
|
+
}
|
|
460
|
+
async resolveLinks(t, e) {
|
|
461
|
+
let n = [];
|
|
462
|
+
if (t.link_uuids) {
|
|
463
|
+
const s = t.link_uuids.length;
|
|
464
|
+
let o = [];
|
|
465
|
+
const a = 50;
|
|
466
|
+
for (let i = 0; i < s; i += a) {
|
|
467
|
+
const l = Math.min(s, i + a);
|
|
468
|
+
o.push(t.link_uuids.slice(i, l));
|
|
566
469
|
}
|
|
567
|
-
for (let
|
|
568
|
-
(await this.getStories({ per_page:
|
|
569
|
-
|
|
470
|
+
for (let i = 0; i < o.length; i++)
|
|
471
|
+
(await this.getStories({ per_page: a, language: e.language, version: e.version, by_uuids: o[i].join(",") })).data.stories.forEach((l) => {
|
|
472
|
+
n.push(l);
|
|
570
473
|
});
|
|
571
|
-
}
|
|
572
474
|
} else
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
this.links[
|
|
475
|
+
n = t.links;
|
|
476
|
+
n.forEach((s) => {
|
|
477
|
+
this.links[s.uuid] = $(d({}, s), { _stopResolving: !0 });
|
|
576
478
|
});
|
|
577
479
|
}
|
|
578
|
-
async resolveRelations(
|
|
579
|
-
let
|
|
580
|
-
if (
|
|
581
|
-
const
|
|
582
|
-
let
|
|
583
|
-
const
|
|
584
|
-
for (let
|
|
585
|
-
const
|
|
586
|
-
|
|
480
|
+
async resolveRelations(t, e) {
|
|
481
|
+
let n = [];
|
|
482
|
+
if (t.rel_uuids) {
|
|
483
|
+
const s = t.rel_uuids.length;
|
|
484
|
+
let o = [];
|
|
485
|
+
const a = 50;
|
|
486
|
+
for (let i = 0; i < s; i += a) {
|
|
487
|
+
const l = Math.min(s, i + a);
|
|
488
|
+
o.push(t.rel_uuids.slice(i, l));
|
|
587
489
|
}
|
|
588
|
-
for (let
|
|
589
|
-
(await this.getStories({ per_page:
|
|
590
|
-
|
|
490
|
+
for (let i = 0; i < o.length; i++)
|
|
491
|
+
(await this.getStories({ per_page: a, language: e.language, version: e.version, by_uuids: o[i].join(",") })).data.stories.forEach((l) => {
|
|
492
|
+
n.push(l);
|
|
591
493
|
});
|
|
592
|
-
}
|
|
593
494
|
} else
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
this.relations[
|
|
495
|
+
n = t.rels;
|
|
496
|
+
n.forEach((s) => {
|
|
497
|
+
this.relations[s.uuid] = $(d({}, s), { _stopResolving: !0 });
|
|
597
498
|
});
|
|
598
499
|
}
|
|
599
|
-
async resolveStories(
|
|
600
|
-
let
|
|
601
|
-
if (
|
|
602
|
-
for (const
|
|
603
|
-
this.iterateTree(this.relations[
|
|
604
|
-
|
|
605
|
-
this.iterateTree(
|
|
500
|
+
async resolveStories(t, e) {
|
|
501
|
+
let n = [];
|
|
502
|
+
if (e.resolve_relations !== void 0 && e.resolve_relations.length > 0 && (t.rels || t.rel_uuids) && (n = e.resolve_relations.split(","), await this.resolveRelations(t, e)), ["1", "story", "url"].indexOf(e.resolve_links) > -1 && (t.links || t.link_uuids) && await this.resolveLinks(t, e), this.resolveNestedRelations)
|
|
503
|
+
for (const s in this.relations)
|
|
504
|
+
this.iterateTree(this.relations[s], n);
|
|
505
|
+
t.story ? this.iterateTree(t.story, n) : t.stories.forEach((s) => {
|
|
506
|
+
this.iterateTree(s, n);
|
|
606
507
|
});
|
|
607
508
|
}
|
|
608
|
-
resolveAssetsRelations(
|
|
609
|
-
const { assets:
|
|
610
|
-
if (
|
|
611
|
-
for (const
|
|
612
|
-
this.iterateTree(
|
|
509
|
+
resolveAssetsRelations(t) {
|
|
510
|
+
const { assets: e, stories: n, story: s } = t;
|
|
511
|
+
if (n)
|
|
512
|
+
for (const o of n)
|
|
513
|
+
this.iterateTree(o, e);
|
|
613
514
|
else {
|
|
614
|
-
if (!
|
|
615
|
-
return
|
|
616
|
-
this.iterateTree(
|
|
515
|
+
if (!s)
|
|
516
|
+
return t;
|
|
517
|
+
this.iterateTree(s, e);
|
|
617
518
|
}
|
|
618
519
|
}
|
|
619
|
-
cacheResponse(
|
|
620
|
-
return
|
|
621
|
-
let
|
|
622
|
-
if (this.cache.clear === "auto" &&
|
|
623
|
-
const
|
|
624
|
-
if (
|
|
625
|
-
return
|
|
520
|
+
cacheResponse(t, e, n) {
|
|
521
|
+
return n === void 0 && (n = 0), new Promise(async (s, o) => {
|
|
522
|
+
let a = R({ url: t, params: e }), i = this.cacheProvider();
|
|
523
|
+
if (this.cache.clear === "auto" && e.version === "draft" && await this.flushCache(), e.version === "published" && t != "/cdn/spaces/me") {
|
|
524
|
+
const c = await i.get(a);
|
|
525
|
+
if (c)
|
|
526
|
+
return s(c);
|
|
626
527
|
}
|
|
627
528
|
try {
|
|
628
|
-
let
|
|
629
|
-
if (
|
|
630
|
-
return
|
|
631
|
-
(
|
|
632
|
-
} catch (
|
|
633
|
-
if (
|
|
634
|
-
return console.log(`Hit rate limit. Retrying in ${
|
|
635
|
-
|
|
529
|
+
let c = await this.throttle("get", t, { params: e, paramsSerializer: (h) => R(h) }), u = { data: c.data, headers: c.headers };
|
|
530
|
+
if (u.data.assets && u.data.assets.length && this.resolveAssetsRelations(u.data), u = Object.assign({}, u, { perPage: c.headers["per-page"] ? parseInt(c.headers["per-page"]) : 0, total: c.headers["per-page"] ? parseInt(c.headers.total) : 0 }), c.status != 200)
|
|
531
|
+
return o(c);
|
|
532
|
+
(u.data.story || u.data.stories) && await this.resolveStories(u.data, e), e.version === "published" && t != "/cdn/spaces/me" && i.set(a, u), u.data.cv && (e.version == "draft" && p[e.token] != u.data.cv && this.flushCache(), p[e.token] = u.data.cv), s(u);
|
|
533
|
+
} catch (c) {
|
|
534
|
+
if (c.response && c.response.status === 429 && (n += 1) < this.maxRetries)
|
|
535
|
+
return console.log(`Hit rate limit. Retrying in ${n} seconds.`), await (l = 1e3 * n, new Promise((u) => setTimeout(u, l))), this.cacheResponse(t, e, n).then(s).catch(o);
|
|
536
|
+
o(c);
|
|
636
537
|
}
|
|
637
|
-
var
|
|
538
|
+
var l;
|
|
638
539
|
});
|
|
639
540
|
}
|
|
640
|
-
throttledRequest(
|
|
641
|
-
return this.client[
|
|
541
|
+
throttledRequest(t, e, n) {
|
|
542
|
+
return this.client[t](e, n);
|
|
642
543
|
}
|
|
643
544
|
cacheVersions() {
|
|
644
|
-
return
|
|
545
|
+
return p;
|
|
645
546
|
}
|
|
646
547
|
cacheVersion() {
|
|
647
|
-
return
|
|
548
|
+
return p[this.accessToken];
|
|
648
549
|
}
|
|
649
|
-
setCacheVersion(
|
|
650
|
-
this.accessToken && (
|
|
550
|
+
setCacheVersion(t) {
|
|
551
|
+
this.accessToken && (p[this.accessToken] = t);
|
|
651
552
|
}
|
|
652
553
|
cacheProvider() {
|
|
653
|
-
return this.cache.type === "memory" ? { get: (
|
|
654
|
-
|
|
554
|
+
return this.cache.type === "memory" ? { get: (t) => _[t], getAll: () => _, set(t, e) {
|
|
555
|
+
_[t] = e;
|
|
655
556
|
}, flush() {
|
|
656
|
-
|
|
557
|
+
_ = {};
|
|
657
558
|
} } : { get() {
|
|
658
559
|
}, getAll() {
|
|
659
560
|
}, set() {
|
|
@@ -664,548 +565,377 @@ class h {
|
|
|
664
565
|
return await this.cacheProvider().flush(), this;
|
|
665
566
|
}
|
|
666
567
|
}
|
|
667
|
-
const
|
|
668
|
-
const { apiOptions } =
|
|
669
|
-
if (!
|
|
568
|
+
const Ht = (r = {}) => {
|
|
569
|
+
const { apiOptions: t } = r;
|
|
570
|
+
if (!t.accessToken) {
|
|
670
571
|
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");
|
|
671
572
|
return;
|
|
672
573
|
}
|
|
673
|
-
|
|
674
|
-
return { storyblokApi };
|
|
574
|
+
return { storyblokApi: new yt(t) };
|
|
675
575
|
};
|
|
676
|
-
var
|
|
677
|
-
if (typeof
|
|
576
|
+
var kt = (r) => {
|
|
577
|
+
if (typeof r != "object" || typeof r._editable > "u")
|
|
678
578
|
return {};
|
|
679
|
-
|
|
680
|
-
const options = JSON.parse(blok._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, ""));
|
|
579
|
+
const t = JSON.parse(r._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, ""));
|
|
681
580
|
return {
|
|
682
|
-
"data-blok-c": JSON.stringify(
|
|
683
|
-
"data-blok-uid":
|
|
581
|
+
"data-blok-c": JSON.stringify(t),
|
|
582
|
+
"data-blok-uid": t.id + "-" + t.uid
|
|
684
583
|
};
|
|
685
584
|
};
|
|
686
|
-
let
|
|
687
|
-
const
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
const sbBridge = new window.StoryblokBridge(options);
|
|
702
|
-
sbBridge.on(["input", "published", "change"], (event) => {
|
|
703
|
-
if (event.action === "input" && event.story.id === id) {
|
|
704
|
-
cb(event.story);
|
|
705
|
-
} else if ((event.action === "change" || event.action === "published") && event.storyId === id) {
|
|
706
|
-
window.location.reload();
|
|
707
|
-
}
|
|
585
|
+
let x;
|
|
586
|
+
const _t = "https://app.storyblok.com/f/storyblok-v2-latest.js", Vt = (r, t, e = {}) => {
|
|
587
|
+
if (!(typeof window > "u")) {
|
|
588
|
+
if (typeof window.storyblokRegisterEvent > "u") {
|
|
589
|
+
console.error("Storyblok Bridge is disabled. Please enable it to use it. Read https://github.com/storyblok/storyblok-js");
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
if (!r) {
|
|
593
|
+
console.warn("Story ID is not defined. Please provide a valid ID.");
|
|
594
|
+
return;
|
|
595
|
+
}
|
|
596
|
+
window.storyblokRegisterEvent(() => {
|
|
597
|
+
new window.StoryblokBridge(e).on(["input", "published", "change"], (s) => {
|
|
598
|
+
s.action === "input" && s.story.id === r ? t(s.story) : (s.action === "change" || s.action === "published") && s.storyId === r && window.location.reload();
|
|
599
|
+
});
|
|
708
600
|
});
|
|
709
|
-
});
|
|
710
|
-
};
|
|
711
|
-
const storyblokInit$1 = (pluginOptions = {}) => {
|
|
712
|
-
const {
|
|
713
|
-
bridge,
|
|
714
|
-
accessToken,
|
|
715
|
-
use = [],
|
|
716
|
-
apiOptions = {},
|
|
717
|
-
richText = {}
|
|
718
|
-
} = pluginOptions;
|
|
719
|
-
apiOptions.accessToken = apiOptions.accessToken || accessToken;
|
|
720
|
-
const options = { bridge, apiOptions };
|
|
721
|
-
let result = {};
|
|
722
|
-
use.forEach((pluginFactory) => {
|
|
723
|
-
result = __spreadValues(__spreadValues({}, result), pluginFactory(options));
|
|
724
|
-
});
|
|
725
|
-
if (bridge !== false) {
|
|
726
|
-
loadBridge(bridgeLatest);
|
|
727
|
-
}
|
|
728
|
-
richTextResolver = new RichTextResolver(richText.schema);
|
|
729
|
-
if (richText.resolver) {
|
|
730
|
-
setComponentResolver(richTextResolver, richText.resolver);
|
|
731
601
|
}
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
602
|
+
}, bt = (r = {}) => {
|
|
603
|
+
const {
|
|
604
|
+
bridge: t,
|
|
605
|
+
accessToken: e,
|
|
606
|
+
use: n = [],
|
|
607
|
+
apiOptions: s = {},
|
|
608
|
+
richText: o = {}
|
|
609
|
+
} = r;
|
|
610
|
+
s.accessToken = s.accessToken || e;
|
|
611
|
+
const a = { bridge: t, apiOptions: s };
|
|
612
|
+
let i = {};
|
|
613
|
+
return n.forEach((l) => {
|
|
614
|
+
i = d(d({}, i), l(a));
|
|
615
|
+
}), t !== !1 && lt(_t), x = new K(o.schema), o.resolver && Q(x, o.resolver), i;
|
|
616
|
+
}, Q = (r, t) => {
|
|
617
|
+
r.addNode("blok", (e) => {
|
|
618
|
+
let n = "";
|
|
619
|
+
return e.attrs.body.forEach((s) => {
|
|
620
|
+
n += t(s.component, s);
|
|
621
|
+
}), {
|
|
622
|
+
html: n
|
|
742
623
|
};
|
|
743
624
|
});
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
if (!
|
|
625
|
+
}, Jt = (r, t, e) => {
|
|
626
|
+
let n = e || x;
|
|
627
|
+
if (!n) {
|
|
747
628
|
console.error("Please initialize the Storyblok SDK before calling the renderRichText function");
|
|
748
629
|
return;
|
|
749
630
|
}
|
|
750
|
-
|
|
751
|
-
return "";
|
|
752
|
-
} else if (!data) {
|
|
753
|
-
console.warn(`${data} is not a valid Richtext object. This might be because the value of the richtext field is empty.
|
|
631
|
+
return r === "" ? "" : r ? (t && (n = new K(t.schema), t.resolver && Q(n, t.resolver)), n.render(r)) : (console.warn(`${r} is not a valid Richtext object. This might be because the value of the richtext field is empty.
|
|
754
632
|
|
|
755
|
-
For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`);
|
|
756
|
-
return "";
|
|
757
|
-
}
|
|
758
|
-
let localResolver = richTextResolver;
|
|
759
|
-
if (options) {
|
|
760
|
-
localResolver = new RichTextResolver(options.schema);
|
|
761
|
-
if (options.resolver) {
|
|
762
|
-
setComponentResolver(localResolver, options.resolver);
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
return localResolver.render(data);
|
|
633
|
+
For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`), "");
|
|
766
634
|
};
|
|
767
|
-
function
|
|
635
|
+
function W() {
|
|
768
636
|
}
|
|
769
|
-
function
|
|
770
|
-
for (const
|
|
771
|
-
|
|
772
|
-
return
|
|
637
|
+
function E(r, t) {
|
|
638
|
+
for (const e in t)
|
|
639
|
+
r[e] = t[e];
|
|
640
|
+
return r;
|
|
773
641
|
}
|
|
774
|
-
function
|
|
775
|
-
return
|
|
642
|
+
function X(r) {
|
|
643
|
+
return r();
|
|
776
644
|
}
|
|
777
|
-
function
|
|
645
|
+
function U() {
|
|
778
646
|
return /* @__PURE__ */ Object.create(null);
|
|
779
647
|
}
|
|
780
|
-
function
|
|
781
|
-
|
|
648
|
+
function y(r) {
|
|
649
|
+
r.forEach(X);
|
|
782
650
|
}
|
|
783
|
-
function
|
|
784
|
-
return typeof
|
|
651
|
+
function vt(r) {
|
|
652
|
+
return typeof r == "function";
|
|
785
653
|
}
|
|
786
|
-
function
|
|
787
|
-
return
|
|
654
|
+
function wt(r, t) {
|
|
655
|
+
return r != r ? t == t : r !== t || r && typeof r == "object" || typeof r == "function";
|
|
788
656
|
}
|
|
789
|
-
function
|
|
790
|
-
return Object.keys(
|
|
657
|
+
function $t(r) {
|
|
658
|
+
return Object.keys(r).length === 0;
|
|
791
659
|
}
|
|
792
|
-
function
|
|
793
|
-
const
|
|
794
|
-
for (const
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
return result;
|
|
660
|
+
function Tt(r) {
|
|
661
|
+
const t = {};
|
|
662
|
+
for (const e in r)
|
|
663
|
+
e[0] !== "$" && (t[e] = r[e]);
|
|
664
|
+
return t;
|
|
798
665
|
}
|
|
799
|
-
function
|
|
800
|
-
const
|
|
801
|
-
|
|
802
|
-
for (const
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
return rest;
|
|
666
|
+
function H(r, t) {
|
|
667
|
+
const e = {};
|
|
668
|
+
t = new Set(t);
|
|
669
|
+
for (const n in r)
|
|
670
|
+
!t.has(n) && n[0] !== "$" && (e[n] = r[n]);
|
|
671
|
+
return e;
|
|
806
672
|
}
|
|
807
|
-
function
|
|
808
|
-
|
|
673
|
+
function Rt(r, t, e) {
|
|
674
|
+
r.insertBefore(t, e || null);
|
|
809
675
|
}
|
|
810
|
-
function
|
|
811
|
-
|
|
676
|
+
function Z(r) {
|
|
677
|
+
r.parentNode.removeChild(r);
|
|
812
678
|
}
|
|
813
|
-
function
|
|
814
|
-
return document.createTextNode(
|
|
679
|
+
function xt(r) {
|
|
680
|
+
return document.createTextNode(r);
|
|
815
681
|
}
|
|
816
|
-
function
|
|
817
|
-
return
|
|
682
|
+
function Et() {
|
|
683
|
+
return xt("");
|
|
818
684
|
}
|
|
819
|
-
function
|
|
820
|
-
return Array.from(
|
|
685
|
+
function Ot(r) {
|
|
686
|
+
return Array.from(r.childNodes);
|
|
821
687
|
}
|
|
822
|
-
let
|
|
823
|
-
function
|
|
824
|
-
|
|
688
|
+
let M;
|
|
689
|
+
function m(r) {
|
|
690
|
+
M = r;
|
|
825
691
|
}
|
|
826
|
-
const
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
const resolved_promise = Promise.resolve();
|
|
831
|
-
let update_scheduled = false;
|
|
832
|
-
function schedule_update() {
|
|
833
|
-
if (!update_scheduled) {
|
|
834
|
-
update_scheduled = true;
|
|
835
|
-
resolved_promise.then(flush);
|
|
836
|
-
}
|
|
692
|
+
const g = [], V = [], v = [], J = [], St = Promise.resolve();
|
|
693
|
+
let O = !1;
|
|
694
|
+
function jt() {
|
|
695
|
+
O || (O = !0, St.then(tt));
|
|
837
696
|
}
|
|
838
|
-
function
|
|
839
|
-
|
|
697
|
+
function S(r) {
|
|
698
|
+
v.push(r);
|
|
840
699
|
}
|
|
841
|
-
const
|
|
842
|
-
let
|
|
843
|
-
function
|
|
844
|
-
const
|
|
700
|
+
const T = /* @__PURE__ */ new Set();
|
|
701
|
+
let b = 0;
|
|
702
|
+
function tt() {
|
|
703
|
+
const r = M;
|
|
845
704
|
do {
|
|
846
|
-
|
|
847
|
-
const
|
|
848
|
-
|
|
849
|
-
set_current_component(component);
|
|
850
|
-
update(component.$$);
|
|
705
|
+
for (; b < g.length; ) {
|
|
706
|
+
const t = g[b];
|
|
707
|
+
b++, m(t), Pt(t.$$);
|
|
851
708
|
}
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
for (let i2 = 0; i2 < render_callbacks.length; i2 += 1) {
|
|
858
|
-
const callback = render_callbacks[i2];
|
|
859
|
-
if (!seen_callbacks.has(callback)) {
|
|
860
|
-
seen_callbacks.add(callback);
|
|
861
|
-
callback();
|
|
862
|
-
}
|
|
709
|
+
for (m(null), g.length = 0, b = 0; V.length; )
|
|
710
|
+
V.pop()();
|
|
711
|
+
for (let t = 0; t < v.length; t += 1) {
|
|
712
|
+
const e = v[t];
|
|
713
|
+
T.has(e) || (T.add(e), e());
|
|
863
714
|
}
|
|
864
|
-
|
|
865
|
-
} while (
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
}
|
|
882
|
-
}
|
|
883
|
-
const outroing = /* @__PURE__ */ new Set();
|
|
884
|
-
let outros;
|
|
885
|
-
function group_outros() {
|
|
886
|
-
outros = {
|
|
715
|
+
v.length = 0;
|
|
716
|
+
} while (g.length);
|
|
717
|
+
for (; J.length; )
|
|
718
|
+
J.pop()();
|
|
719
|
+
O = !1, T.clear(), m(r);
|
|
720
|
+
}
|
|
721
|
+
function Pt(r) {
|
|
722
|
+
if (r.fragment !== null) {
|
|
723
|
+
r.update(), y(r.before_update);
|
|
724
|
+
const t = r.dirty;
|
|
725
|
+
r.dirty = [-1], r.fragment && r.fragment.p(r.ctx, t), r.after_update.forEach(S);
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
const w = /* @__PURE__ */ new Set();
|
|
729
|
+
let f;
|
|
730
|
+
function At() {
|
|
731
|
+
f = {
|
|
887
732
|
r: 0,
|
|
888
733
|
c: [],
|
|
889
|
-
p:
|
|
734
|
+
p: f
|
|
890
735
|
};
|
|
891
736
|
}
|
|
892
|
-
function
|
|
893
|
-
|
|
894
|
-
run_all(outros.c);
|
|
895
|
-
}
|
|
896
|
-
outros = outros.p;
|
|
737
|
+
function Ct() {
|
|
738
|
+
f.r || y(f.c), f = f.p;
|
|
897
739
|
}
|
|
898
|
-
function
|
|
899
|
-
|
|
900
|
-
outroing.delete(block);
|
|
901
|
-
block.i(local);
|
|
902
|
-
}
|
|
740
|
+
function j(r, t) {
|
|
741
|
+
r && r.i && (w.delete(r), r.i(t));
|
|
903
742
|
}
|
|
904
|
-
function
|
|
905
|
-
if (
|
|
906
|
-
if (
|
|
743
|
+
function Y(r, t, e, n) {
|
|
744
|
+
if (r && r.o) {
|
|
745
|
+
if (w.has(r))
|
|
907
746
|
return;
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
const o2 = levels[i2];
|
|
929
|
-
const n2 = updates[i2];
|
|
930
|
-
if (n2) {
|
|
931
|
-
for (const key in o2) {
|
|
932
|
-
if (!(key in n2))
|
|
933
|
-
to_null_out[key] = 1;
|
|
934
|
-
}
|
|
935
|
-
for (const key in n2) {
|
|
936
|
-
if (!accounted_for[key]) {
|
|
937
|
-
update2[key] = n2[key];
|
|
938
|
-
accounted_for[key] = 1;
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
levels[i2] = n2;
|
|
942
|
-
} else {
|
|
943
|
-
for (const key in o2) {
|
|
944
|
-
accounted_for[key] = 1;
|
|
945
|
-
}
|
|
946
|
-
}
|
|
947
|
-
}
|
|
948
|
-
for (const key in to_null_out) {
|
|
949
|
-
if (!(key in update2))
|
|
950
|
-
update2[key] = void 0;
|
|
747
|
+
w.add(r), f.c.push(() => {
|
|
748
|
+
w.delete(r), n && (e && r.d(1), n());
|
|
749
|
+
}), r.o(t);
|
|
750
|
+
} else
|
|
751
|
+
n && n();
|
|
752
|
+
}
|
|
753
|
+
function Mt(r, t) {
|
|
754
|
+
const e = {}, n = {}, s = { $$scope: 1 };
|
|
755
|
+
let o = r.length;
|
|
756
|
+
for (; o--; ) {
|
|
757
|
+
const a = r[o], i = t[o];
|
|
758
|
+
if (i) {
|
|
759
|
+
for (const l in a)
|
|
760
|
+
l in i || (n[l] = 1);
|
|
761
|
+
for (const l in i)
|
|
762
|
+
s[l] || (e[l] = i[l], s[l] = 1);
|
|
763
|
+
r[o] = i;
|
|
764
|
+
} else
|
|
765
|
+
for (const l in a)
|
|
766
|
+
s[l] = 1;
|
|
951
767
|
}
|
|
952
|
-
|
|
768
|
+
for (const a in n)
|
|
769
|
+
a in e || (e[a] = void 0);
|
|
770
|
+
return e;
|
|
953
771
|
}
|
|
954
|
-
function
|
|
955
|
-
return typeof
|
|
772
|
+
function Nt(r) {
|
|
773
|
+
return typeof r == "object" && r !== null ? r : {};
|
|
956
774
|
}
|
|
957
|
-
function
|
|
958
|
-
|
|
775
|
+
function F(r) {
|
|
776
|
+
r && r.c();
|
|
959
777
|
}
|
|
960
|
-
function
|
|
961
|
-
const { fragment, on_mount, on_destroy, after_update } =
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
if (on_destroy) {
|
|
967
|
-
on_destroy.push(...new_on_destroy);
|
|
968
|
-
} else {
|
|
969
|
-
run_all(new_on_destroy);
|
|
970
|
-
}
|
|
971
|
-
component.$$.on_mount = [];
|
|
972
|
-
});
|
|
973
|
-
}
|
|
974
|
-
after_update.forEach(add_render_callback);
|
|
778
|
+
function P(r, t, e, n) {
|
|
779
|
+
const { fragment: s, on_mount: o, on_destroy: a, after_update: i } = r.$$;
|
|
780
|
+
s && s.m(t, e), n || S(() => {
|
|
781
|
+
const l = o.map(X).filter(vt);
|
|
782
|
+
a ? a.push(...l) : y(l), r.$$.on_mount = [];
|
|
783
|
+
}), i.forEach(S);
|
|
975
784
|
}
|
|
976
|
-
function
|
|
977
|
-
const
|
|
978
|
-
|
|
979
|
-
run_all($$.on_destroy);
|
|
980
|
-
$$.fragment && $$.fragment.d(detaching);
|
|
981
|
-
$$.on_destroy = $$.fragment = null;
|
|
982
|
-
$$.ctx = [];
|
|
983
|
-
}
|
|
785
|
+
function A(r, t) {
|
|
786
|
+
const e = r.$$;
|
|
787
|
+
e.fragment !== null && (y(e.on_destroy), e.fragment && e.fragment.d(t), e.on_destroy = e.fragment = null, e.ctx = []);
|
|
984
788
|
}
|
|
985
|
-
function
|
|
986
|
-
|
|
987
|
-
dirty_components.push(component);
|
|
988
|
-
schedule_update();
|
|
989
|
-
component.$$.dirty.fill(0);
|
|
990
|
-
}
|
|
991
|
-
component.$$.dirty[i2 / 31 | 0] |= 1 << i2 % 31;
|
|
789
|
+
function It(r, t) {
|
|
790
|
+
r.$$.dirty[0] === -1 && (g.push(r), jt(), r.$$.dirty.fill(0)), r.$$.dirty[t / 31 | 0] |= 1 << t % 31;
|
|
992
791
|
}
|
|
993
|
-
function
|
|
994
|
-
const
|
|
995
|
-
|
|
996
|
-
const
|
|
792
|
+
function qt(r, t, e, n, s, o, a, i = [-1]) {
|
|
793
|
+
const l = M;
|
|
794
|
+
m(r);
|
|
795
|
+
const c = r.$$ = {
|
|
997
796
|
fragment: null,
|
|
998
797
|
ctx: null,
|
|
999
|
-
props,
|
|
1000
|
-
update:
|
|
1001
|
-
not_equal,
|
|
1002
|
-
bound:
|
|
798
|
+
props: o,
|
|
799
|
+
update: W,
|
|
800
|
+
not_equal: s,
|
|
801
|
+
bound: U(),
|
|
1003
802
|
on_mount: [],
|
|
1004
803
|
on_destroy: [],
|
|
1005
804
|
on_disconnect: [],
|
|
1006
805
|
before_update: [],
|
|
1007
806
|
after_update: [],
|
|
1008
|
-
context: new Map(
|
|
1009
|
-
callbacks:
|
|
1010
|
-
dirty,
|
|
1011
|
-
skip_bound:
|
|
1012
|
-
root:
|
|
807
|
+
context: new Map(t.context || (l ? l.$$.context : [])),
|
|
808
|
+
callbacks: U(),
|
|
809
|
+
dirty: i,
|
|
810
|
+
skip_bound: !1,
|
|
811
|
+
root: t.target || l.$$.root
|
|
1013
812
|
};
|
|
1014
|
-
|
|
1015
|
-
let
|
|
1016
|
-
|
|
1017
|
-
const
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
}
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
$$.update();
|
|
1027
|
-
ready = true;
|
|
1028
|
-
run_all($$.before_update);
|
|
1029
|
-
$$.fragment = create_fragment2 ? create_fragment2($$.ctx) : false;
|
|
1030
|
-
if (options.target) {
|
|
1031
|
-
if (options.hydrate) {
|
|
1032
|
-
const nodes = children(options.target);
|
|
1033
|
-
$$.fragment && $$.fragment.l(nodes);
|
|
1034
|
-
nodes.forEach(detach);
|
|
1035
|
-
} else {
|
|
1036
|
-
$$.fragment && $$.fragment.c();
|
|
1037
|
-
}
|
|
1038
|
-
if (options.intro)
|
|
1039
|
-
transition_in(component.$$.fragment);
|
|
1040
|
-
mount_component(component, options.target, options.anchor, options.customElement);
|
|
1041
|
-
flush();
|
|
813
|
+
a && a(c.root);
|
|
814
|
+
let u = !1;
|
|
815
|
+
if (c.ctx = e ? e(r, t.props || {}, (h, k, ...N) => {
|
|
816
|
+
const I = N.length ? N[0] : k;
|
|
817
|
+
return c.ctx && s(c.ctx[h], c.ctx[h] = I) && (!c.skip_bound && c.bound[h] && c.bound[h](I), u && It(r, h)), k;
|
|
818
|
+
}) : [], c.update(), u = !0, y(c.before_update), c.fragment = n ? n(c.ctx) : !1, t.target) {
|
|
819
|
+
if (t.hydrate) {
|
|
820
|
+
const h = Ot(t.target);
|
|
821
|
+
c.fragment && c.fragment.l(h), h.forEach(Z);
|
|
822
|
+
} else
|
|
823
|
+
c.fragment && c.fragment.c();
|
|
824
|
+
t.intro && j(r.$$.fragment), P(r, t.target, t.anchor, t.customElement), tt();
|
|
1042
825
|
}
|
|
1043
|
-
|
|
826
|
+
m(l);
|
|
1044
827
|
}
|
|
1045
|
-
class
|
|
828
|
+
class Lt {
|
|
1046
829
|
$destroy() {
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
const index = callbacks2.indexOf(callback);
|
|
1055
|
-
if (index !== -1)
|
|
1056
|
-
callbacks2.splice(index, 1);
|
|
830
|
+
A(this, 1), this.$destroy = W;
|
|
831
|
+
}
|
|
832
|
+
$on(t, e) {
|
|
833
|
+
const n = this.$$.callbacks[t] || (this.$$.callbacks[t] = []);
|
|
834
|
+
return n.push(e), () => {
|
|
835
|
+
const s = n.indexOf(e);
|
|
836
|
+
s !== -1 && n.splice(s, 1);
|
|
1057
837
|
};
|
|
1058
838
|
}
|
|
1059
|
-
$set(
|
|
1060
|
-
|
|
1061
|
-
this.$$.skip_bound = true;
|
|
1062
|
-
this.$$set($$props);
|
|
1063
|
-
this.$$.skip_bound = false;
|
|
1064
|
-
}
|
|
839
|
+
$set(t) {
|
|
840
|
+
this.$$set && !$t(t) && (this.$$.skip_bound = !0, this.$$set(t), this.$$.skip_bound = !1);
|
|
1065
841
|
}
|
|
1066
842
|
}
|
|
1067
|
-
function
|
|
1068
|
-
let
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
switch_instance_props = assign(switch_instance_props, switch_instance_spread_levels[i2]);
|
|
1077
|
-
}
|
|
1078
|
-
return { props: switch_instance_props };
|
|
843
|
+
function Bt(r) {
|
|
844
|
+
let t, e, n;
|
|
845
|
+
const s = [{ blok: r[0] }, r[2]];
|
|
846
|
+
var o = r[1];
|
|
847
|
+
function a(i) {
|
|
848
|
+
let l = {};
|
|
849
|
+
for (let c = 0; c < s.length; c += 1)
|
|
850
|
+
l = E(l, s[c]);
|
|
851
|
+
return { props: l };
|
|
1079
852
|
}
|
|
1080
|
-
|
|
1081
|
-
switch_instance = new switch_value(switch_props());
|
|
1082
|
-
}
|
|
1083
|
-
return {
|
|
853
|
+
return o && (t = new o(a())), {
|
|
1084
854
|
c() {
|
|
1085
|
-
|
|
1086
|
-
create_component(switch_instance.$$.fragment);
|
|
1087
|
-
switch_instance_anchor = empty();
|
|
855
|
+
t && F(t.$$.fragment), e = Et();
|
|
1088
856
|
},
|
|
1089
|
-
m(
|
|
1090
|
-
|
|
1091
|
-
mount_component(switch_instance, target, anchor);
|
|
1092
|
-
}
|
|
1093
|
-
insert(target, switch_instance_anchor, anchor);
|
|
1094
|
-
current = true;
|
|
857
|
+
m(i, l) {
|
|
858
|
+
t && P(t, i, l), Rt(i, e, l), n = !0;
|
|
1095
859
|
},
|
|
1096
|
-
p(
|
|
1097
|
-
const
|
|
1098
|
-
|
|
1099
|
-
|
|
860
|
+
p(i, [l]) {
|
|
861
|
+
const c = l & 5 ? Mt(s, [
|
|
862
|
+
l & 1 && { blok: i[0] },
|
|
863
|
+
l & 4 && Nt(i[2])
|
|
1100
864
|
]) : {};
|
|
1101
|
-
if (
|
|
1102
|
-
if (
|
|
1103
|
-
|
|
1104
|
-
const
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
});
|
|
1108
|
-
check_outros();
|
|
1109
|
-
}
|
|
1110
|
-
if (switch_value) {
|
|
1111
|
-
switch_instance = new switch_value(switch_props());
|
|
1112
|
-
create_component(switch_instance.$$.fragment);
|
|
1113
|
-
transition_in(switch_instance.$$.fragment, 1);
|
|
1114
|
-
mount_component(switch_instance, switch_instance_anchor.parentNode, switch_instance_anchor);
|
|
1115
|
-
} else {
|
|
1116
|
-
switch_instance = null;
|
|
865
|
+
if (o !== (o = i[1])) {
|
|
866
|
+
if (t) {
|
|
867
|
+
At();
|
|
868
|
+
const u = t;
|
|
869
|
+
Y(u.$$.fragment, 1, 0, () => {
|
|
870
|
+
A(u, 1);
|
|
871
|
+
}), Ct();
|
|
1117
872
|
}
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
873
|
+
o ? (t = new o(a()), F(t.$$.fragment), j(t.$$.fragment, 1), P(t, e.parentNode, e)) : t = null;
|
|
874
|
+
} else
|
|
875
|
+
o && t.$set(c);
|
|
1121
876
|
},
|
|
1122
|
-
i(
|
|
1123
|
-
|
|
1124
|
-
return;
|
|
1125
|
-
if (switch_instance)
|
|
1126
|
-
transition_in(switch_instance.$$.fragment, local);
|
|
1127
|
-
current = true;
|
|
877
|
+
i(i) {
|
|
878
|
+
n || (t && j(t.$$.fragment, i), n = !0);
|
|
1128
879
|
},
|
|
1129
|
-
o(
|
|
1130
|
-
|
|
1131
|
-
transition_out(switch_instance.$$.fragment, local);
|
|
1132
|
-
current = false;
|
|
880
|
+
o(i) {
|
|
881
|
+
t && Y(t.$$.fragment, i), n = !1;
|
|
1133
882
|
},
|
|
1134
|
-
d(
|
|
1135
|
-
|
|
1136
|
-
detach(switch_instance_anchor);
|
|
1137
|
-
if (switch_instance)
|
|
1138
|
-
destroy_component(switch_instance, detaching);
|
|
883
|
+
d(i) {
|
|
884
|
+
i && Z(e), t && A(t, i);
|
|
1139
885
|
}
|
|
1140
886
|
};
|
|
1141
887
|
}
|
|
1142
|
-
function
|
|
1143
|
-
const
|
|
1144
|
-
let
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
component = getComponent(blok.component);
|
|
1149
|
-
} else {
|
|
1150
|
-
console.error("Please provide a 'blok' property to the StoryblokComponent");
|
|
1151
|
-
}
|
|
1152
|
-
$$self.$$set = ($$new_props) => {
|
|
1153
|
-
$$props = assign(assign({}, $$props), exclude_internal_props($$new_props));
|
|
1154
|
-
$$invalidate(2, $$restProps = compute_rest_props($$props, omit_props_names));
|
|
1155
|
-
if ("blok" in $$new_props)
|
|
1156
|
-
$$invalidate(0, blok = $$new_props.blok);
|
|
1157
|
-
};
|
|
1158
|
-
return [blok, component, $$restProps];
|
|
888
|
+
function zt(r, t, e) {
|
|
889
|
+
const n = ["blok"];
|
|
890
|
+
let s = H(t, n), o, { blok: a } = t;
|
|
891
|
+
return a ? o = Dt(a.component) : console.error("Please provide a 'blok' property to the StoryblokComponent"), r.$$set = (i) => {
|
|
892
|
+
t = E(E({}, t), Tt(i)), e(2, s = H(t, n)), "blok" in i && e(0, a = i.blok);
|
|
893
|
+
}, [a, o, s];
|
|
1159
894
|
}
|
|
1160
|
-
class
|
|
1161
|
-
constructor(
|
|
1162
|
-
super();
|
|
1163
|
-
init(this, options, instance, create_fragment, safe_not_equal, { blok: 0 });
|
|
895
|
+
class Yt extends Lt {
|
|
896
|
+
constructor(t) {
|
|
897
|
+
super(), qt(this, t, zt, Bt, wt, { blok: 0 });
|
|
1164
898
|
}
|
|
1165
899
|
}
|
|
1166
|
-
const
|
|
1167
|
-
const
|
|
1168
|
-
const
|
|
1169
|
-
|
|
1170
|
-
node.setAttribute("data-blok-c", options["data-blok-c"]);
|
|
1171
|
-
node.setAttribute("data-blok-uid", options["data-blok-uid"]);
|
|
1172
|
-
node.classList.add("storyblok__outline");
|
|
1173
|
-
}
|
|
900
|
+
const Ft = (r, t) => {
|
|
901
|
+
const e = (n) => {
|
|
902
|
+
const s = kt(n);
|
|
903
|
+
s["data-blok-c"] && (r.setAttribute("data-blok-c", s["data-blok-c"]), r.setAttribute("data-blok-uid", s["data-blok-uid"]), r.classList.add("storyblok__outline"));
|
|
1174
904
|
};
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
updateDom(newValue);
|
|
905
|
+
return e(t), {
|
|
906
|
+
update(n) {
|
|
907
|
+
e(n);
|
|
1179
908
|
}
|
|
1180
909
|
};
|
|
1181
910
|
};
|
|
1182
|
-
let
|
|
1183
|
-
const
|
|
1184
|
-
if
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
}
|
|
1189
|
-
|
|
1190
|
-
}
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
const { storyblokApi } = storyblokInit$1(options);
|
|
1194
|
-
storyblokApiInstance = storyblokApi;
|
|
1195
|
-
componentsMap = options.components || {};
|
|
1196
|
-
};
|
|
1197
|
-
const getComponent = (componentName) => {
|
|
1198
|
-
const component = componentsMap[componentName];
|
|
1199
|
-
if (!component) {
|
|
1200
|
-
console.error(`You didn't load the ${componentName} component. Please load it in storyblokInit. For example:
|
|
911
|
+
let C = null;
|
|
912
|
+
const Kt = () => (C || console.log(
|
|
913
|
+
"You can't use getStoryblokApi if you're not loading apiPlugin."
|
|
914
|
+
), C);
|
|
915
|
+
let et = null;
|
|
916
|
+
const Gt = (r) => {
|
|
917
|
+
const { storyblokApi: t } = bt(r);
|
|
918
|
+
C = t, et = r.components || {};
|
|
919
|
+
}, Dt = (r) => {
|
|
920
|
+
const t = et[r];
|
|
921
|
+
return t || console.error(`You didn't load the ${r} component. Please load it in storyblokInit. For example:
|
|
1201
922
|
storyblokInit({
|
|
1202
923
|
accessToken: "<your-token>",
|
|
1203
924
|
components: {
|
|
1204
925
|
"teaser": Teaser
|
|
1205
926
|
}
|
|
1206
927
|
})
|
|
1207
|
-
`);
|
|
1208
|
-
|
|
1209
|
-
|
|
928
|
+
`), t;
|
|
929
|
+
};
|
|
930
|
+
export {
|
|
931
|
+
ht as RichTextSchema,
|
|
932
|
+
Yt as StoryblokComponent,
|
|
933
|
+
Ht as apiPlugin,
|
|
934
|
+
Dt as getComponent,
|
|
935
|
+
Kt as getStoryblokApi,
|
|
936
|
+
Jt as renderRichText,
|
|
937
|
+
Ft as storyblokEditable,
|
|
938
|
+
Gt as storyblokInit,
|
|
939
|
+
Kt as useStoryblokApi,
|
|
940
|
+
Vt as useStoryblokBridge
|
|
1210
941
|
};
|
|
1211
|
-
export { defaultHtmlSerializer as RichTextSchema, StoryblokComponent, apiFactory as apiPlugin, getComponent, useStoryblokApi as getStoryblokApi, renderRichText, storyblokEditable, storyblokInit, useStoryblokApi, useStoryblokBridge };
|