@storyblok/js 4.2.3 → 4.2.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-js.js +1 -1
- package/dist/storyblok-js.mjs +606 -919
- package/package.json +5 -4
package/dist/storyblok-js.mjs
CHANGED
@@ -4,616 +4,325 @@
|
|
4
4
|
* description: SDK to integrate Storyblok into your project using JavaScript.
|
5
5
|
* author: undefined
|
6
6
|
*/
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
function
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
// \t
|
22
|
-
case 10:
|
23
|
-
// \n
|
24
|
-
case 11:
|
25
|
-
// \v
|
26
|
-
case 12:
|
27
|
-
// \f
|
28
|
-
case 13:
|
29
|
-
// \r
|
30
|
-
case 32:
|
31
|
-
case 160:
|
32
|
-
case 5760:
|
33
|
-
case 8239:
|
34
|
-
case 8287:
|
35
|
-
case 12288:
|
36
|
-
return !0;
|
37
|
-
}
|
38
|
-
return !1;
|
39
|
-
}
|
40
|
-
function q(s) {
|
41
|
-
return lt.test(s) || ht.test(s);
|
42
|
-
}
|
43
|
-
function J(s) {
|
44
|
-
switch (s) {
|
45
|
-
case 33:
|
46
|
-
case 34:
|
47
|
-
case 35:
|
48
|
-
case 36:
|
49
|
-
case 37:
|
50
|
-
case 38:
|
51
|
-
case 39:
|
52
|
-
case 40:
|
53
|
-
case 41:
|
54
|
-
case 42:
|
55
|
-
case 43:
|
56
|
-
case 44:
|
57
|
-
case 45:
|
58
|
-
case 46:
|
59
|
-
case 47:
|
60
|
-
case 58:
|
61
|
-
case 59:
|
62
|
-
case 60:
|
63
|
-
case 61:
|
64
|
-
case 62:
|
65
|
-
case 63:
|
66
|
-
case 64:
|
67
|
-
case 91:
|
68
|
-
case 92:
|
69
|
-
case 93:
|
70
|
-
case 94:
|
71
|
-
case 95:
|
72
|
-
case 96:
|
73
|
-
case 123:
|
74
|
-
case 124:
|
75
|
-
case 125:
|
76
|
-
case 126:
|
77
|
-
return !0;
|
78
|
-
default:
|
79
|
-
return !1;
|
80
|
-
}
|
81
|
-
}
|
82
|
-
function x(s, t, e) {
|
83
|
-
this.type = s, this.tag = t, this.attrs = null, this.map = null, this.nesting = e, this.level = 0, this.children = null, this.content = "", this.markup = "", this.info = "", this.meta = null, this.block = !1, this.hidden = !1;
|
84
|
-
}
|
85
|
-
x.prototype.attrIndex = function(t) {
|
86
|
-
if (!this.attrs)
|
87
|
-
return -1;
|
88
|
-
const e = this.attrs;
|
89
|
-
for (let r = 0, u = e.length; r < u; r++)
|
90
|
-
if (e[r][0] === t)
|
91
|
-
return r;
|
92
|
-
return -1;
|
93
|
-
};
|
94
|
-
x.prototype.attrPush = function(t) {
|
95
|
-
this.attrs ? this.attrs.push(t) : this.attrs = [t];
|
96
|
-
};
|
97
|
-
x.prototype.attrSet = function(t, e) {
|
98
|
-
const r = this.attrIndex(t), u = [t, e];
|
99
|
-
r < 0 ? this.attrPush(u) : this.attrs[r] = u;
|
100
|
-
};
|
101
|
-
x.prototype.attrGet = function(t) {
|
102
|
-
const e = this.attrIndex(t);
|
103
|
-
let r = null;
|
104
|
-
return e >= 0 && (r = this.attrs[e][1]), r;
|
105
|
-
};
|
106
|
-
x.prototype.attrJoin = function(t, e) {
|
107
|
-
const r = this.attrIndex(t);
|
108
|
-
r < 0 ? this.attrPush([t, e]) : this.attrs[r][1] = this.attrs[r][1] + " " + e;
|
109
|
-
};
|
110
|
-
function Dt(s, t, e) {
|
111
|
-
this.src = s, this.env = e, this.tokens = [], this.inlineMode = !1, this.md = t;
|
112
|
-
}
|
113
|
-
Dt.prototype.Token = x;
|
114
|
-
function w(s, t, e, r) {
|
115
|
-
this.src = s, this.md = t, this.env = e, this.tokens = r, this.bMarks = [], this.eMarks = [], this.tShift = [], this.sCount = [], this.bsCount = [], this.blkIndent = 0, this.line = 0, this.lineMax = 0, this.tight = !1, this.ddIndent = -1, this.listIndent = -1, this.parentType = "root", this.level = 0;
|
116
|
-
const u = this.src;
|
117
|
-
for (let i = 0, a = 0, o = 0, n = 0, c = u.length, h = !1; a < c; a++) {
|
118
|
-
const D = u.charCodeAt(a);
|
119
|
-
if (!h)
|
120
|
-
if (O(D)) {
|
121
|
-
o++, D === 9 ? n += 4 - n % 4 : n++;
|
122
|
-
continue;
|
123
|
-
} else
|
124
|
-
h = !0;
|
125
|
-
(D === 10 || a === c - 1) && (D !== 10 && a++, this.bMarks.push(i), this.eMarks.push(a), this.tShift.push(o), this.sCount.push(n), this.bsCount.push(0), h = !1, o = 0, n = 0, i = a + 1);
|
126
|
-
}
|
127
|
-
this.bMarks.push(u.length), this.eMarks.push(u.length), this.tShift.push(0), this.sCount.push(0), this.bsCount.push(0), this.lineMax = this.bMarks.length - 1;
|
128
|
-
}
|
129
|
-
w.prototype.push = function(s, t, e) {
|
130
|
-
const r = new x(s, t, e);
|
131
|
-
return r.block = !0, e < 0 && this.level--, r.level = this.level, e > 0 && this.level++, this.tokens.push(r), r;
|
132
|
-
};
|
133
|
-
w.prototype.isEmpty = function(t) {
|
134
|
-
return this.bMarks[t] + this.tShift[t] >= this.eMarks[t];
|
135
|
-
};
|
136
|
-
w.prototype.skipEmptyLines = function(t) {
|
137
|
-
for (let e = this.lineMax; t < e && !(this.bMarks[t] + this.tShift[t] < this.eMarks[t]); t++)
|
138
|
-
;
|
139
|
-
return t;
|
140
|
-
};
|
141
|
-
w.prototype.skipSpaces = function(t) {
|
142
|
-
for (let e = this.src.length; t < e; t++) {
|
143
|
-
const r = this.src.charCodeAt(t);
|
144
|
-
if (!O(r))
|
145
|
-
break;
|
146
|
-
}
|
147
|
-
return t;
|
148
|
-
};
|
149
|
-
w.prototype.skipSpacesBack = function(t, e) {
|
150
|
-
if (t <= e)
|
151
|
-
return t;
|
152
|
-
for (; t > e; )
|
153
|
-
if (!O(this.src.charCodeAt(--t)))
|
154
|
-
return t + 1;
|
155
|
-
return t;
|
156
|
-
};
|
157
|
-
w.prototype.skipChars = function(t, e) {
|
158
|
-
for (let r = this.src.length; t < r && this.src.charCodeAt(t) === e; t++)
|
159
|
-
;
|
160
|
-
return t;
|
161
|
-
};
|
162
|
-
w.prototype.skipCharsBack = function(t, e, r) {
|
163
|
-
if (t <= r)
|
164
|
-
return t;
|
165
|
-
for (; t > r; )
|
166
|
-
if (e !== this.src.charCodeAt(--t))
|
167
|
-
return t + 1;
|
168
|
-
return t;
|
169
|
-
};
|
170
|
-
w.prototype.getLines = function(t, e, r, u) {
|
171
|
-
if (t >= e)
|
172
|
-
return "";
|
173
|
-
const i = new Array(e - t);
|
174
|
-
for (let a = 0, o = t; o < e; o++, a++) {
|
175
|
-
let n = 0;
|
176
|
-
const c = this.bMarks[o];
|
177
|
-
let h = c, D;
|
178
|
-
for (o + 1 < e || u ? D = this.eMarks[o] + 1 : D = this.eMarks[o]; h < D && n < r; ) {
|
179
|
-
const A = this.src.charCodeAt(h);
|
180
|
-
if (O(A))
|
181
|
-
A === 9 ? n += 4 - (n + this.bsCount[o]) % 4 : n++;
|
182
|
-
else if (h - c < this.tShift[o])
|
183
|
-
n++;
|
184
|
-
else
|
185
|
-
break;
|
186
|
-
h++;
|
187
|
-
}
|
188
|
-
n > r ? i[a] = new Array(n - r + 1).join(" ") + this.src.slice(h, D) : i[a] = this.src.slice(h, D);
|
189
|
-
}
|
190
|
-
return i.join("");
|
191
|
-
};
|
192
|
-
w.prototype.Token = x;
|
193
|
-
const dt = [
|
194
|
-
"address",
|
195
|
-
"article",
|
196
|
-
"aside",
|
7
|
+
var re = Object.defineProperty;
|
8
|
+
var se = (e, t, s) => t in e ? re(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
|
9
|
+
var b = (e, t, s) => se(e, typeof t != "symbol" ? t + "" : t, s);
|
10
|
+
let w = /* @__PURE__ */ function(e) {
|
11
|
+
return e.DOCUMENT = "doc", e.HEADING = "heading", e.PARAGRAPH = "paragraph", e.QUOTE = "blockquote", e.OL_LIST = "ordered_list", e.UL_LIST = "bullet_list", e.LIST_ITEM = "list_item", e.CODE_BLOCK = "code_block", e.HR = "horizontal_rule", e.BR = "hard_break", e.IMAGE = "image", e.EMOJI = "emoji", e.COMPONENT = "blok", e.TABLE = "table", e.TABLE_ROW = "tableRow", e.TABLE_CELL = "tableCell", e.TABLE_HEADER = "tableHeader", e;
|
12
|
+
}({}), S = /* @__PURE__ */ function(e) {
|
13
|
+
return e.BOLD = "bold", e.STRONG = "strong", e.STRIKE = "strike", e.UNDERLINE = "underline", e.ITALIC = "italic", e.CODE = "code", e.LINK = "link", e.ANCHOR = "anchor", e.STYLED = "styled", e.SUPERSCRIPT = "superscript", e.SUBSCRIPT = "subscript", e.TEXT_STYLE = "textStyle", e.HIGHLIGHT = "highlight", e;
|
14
|
+
}({}), ie = /* @__PURE__ */ function(e) {
|
15
|
+
return e.TEXT = "text", e;
|
16
|
+
}({}), C = /* @__PURE__ */ function(e) {
|
17
|
+
return e.URL = "url", e.STORY = "story", e.ASSET = "asset", e.EMAIL = "email", e;
|
18
|
+
}({});
|
19
|
+
const ne = [
|
20
|
+
"area",
|
197
21
|
"base",
|
198
|
-
"
|
199
|
-
"blockquote",
|
200
|
-
"body",
|
201
|
-
"caption",
|
202
|
-
"center",
|
22
|
+
"br",
|
203
23
|
"col",
|
204
|
-
"
|
205
|
-
"dd",
|
206
|
-
"details",
|
207
|
-
"dialog",
|
208
|
-
"dir",
|
209
|
-
"div",
|
210
|
-
"dl",
|
211
|
-
"dt",
|
212
|
-
"fieldset",
|
213
|
-
"figcaption",
|
214
|
-
"figure",
|
215
|
-
"footer",
|
216
|
-
"form",
|
217
|
-
"frame",
|
218
|
-
"frameset",
|
219
|
-
"h1",
|
220
|
-
"h2",
|
221
|
-
"h3",
|
222
|
-
"h4",
|
223
|
-
"h5",
|
224
|
-
"h6",
|
225
|
-
"head",
|
226
|
-
"header",
|
24
|
+
"embed",
|
227
25
|
"hr",
|
228
|
-
"
|
229
|
-
"
|
230
|
-
"legend",
|
231
|
-
"li",
|
26
|
+
"img",
|
27
|
+
"input",
|
232
28
|
"link",
|
233
|
-
"
|
234
|
-
"menu",
|
235
|
-
"menuitem",
|
236
|
-
"nav",
|
237
|
-
"noframes",
|
238
|
-
"ol",
|
239
|
-
"optgroup",
|
240
|
-
"option",
|
241
|
-
"p",
|
29
|
+
"meta",
|
242
30
|
"param",
|
243
|
-
"
|
244
|
-
"section",
|
245
|
-
"summary",
|
246
|
-
"table",
|
247
|
-
"tbody",
|
248
|
-
"td",
|
249
|
-
"tfoot",
|
250
|
-
"th",
|
251
|
-
"thead",
|
252
|
-
"title",
|
253
|
-
"tr",
|
31
|
+
"source",
|
254
32
|
"track",
|
255
|
-
"
|
256
|
-
],
|
257
|
-
|
258
|
-
|
259
|
-
this.src = s, this.env = e, this.md = t, this.tokens = r, this.tokens_meta = Array(r.length), this.pos = 0, this.posMax = this.src.length, this.level = 0, this.pending = "", this.pendingLevel = 0, this.cache = {}, this.delimiters = [], this._prev_delimiters = [], this.backticks = {}, this.backticksScanned = !1, this.linkLevel = 0;
|
33
|
+
"wbr"
|
34
|
+
], oe = (e = {}) => Object.keys(e).map((t) => `${t}="${e[t]}"`).join(" "), ae = (e = {}) => Object.keys(e).map((t) => `${t}: ${e[t]}`).join("; ");
|
35
|
+
function le(e) {
|
36
|
+
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
260
37
|
}
|
261
|
-
P
|
262
|
-
|
263
|
-
return s.content = this.pending, s.level = this.pendingLevel, this.tokens.push(s), this.pending = "", s;
|
264
|
-
};
|
265
|
-
P.prototype.push = function(s, t, e) {
|
266
|
-
this.pending && this.pushPending();
|
267
|
-
const r = new x(s, t, e);
|
268
|
-
let u = null;
|
269
|
-
return e < 0 && (this.level--, this.delimiters = this._prev_delimiters.pop()), r.level = this.level, e > 0 && (this.level++, this._prev_delimiters.push(this.delimiters), this.delimiters = [], u = { delimiters: this.delimiters }), this.pendingLevel = this.level, this.tokens.push(r), this.tokens_meta.push(u), r;
|
270
|
-
};
|
271
|
-
P.prototype.scanDelims = function(s, t) {
|
272
|
-
const e = this.posMax, r = this.src.charCodeAt(s), u = s > 0 ? this.src.charCodeAt(s - 1) : 32;
|
273
|
-
let i = s;
|
274
|
-
for (; i < e && this.src.charCodeAt(i) === r; )
|
275
|
-
i++;
|
276
|
-
const a = i - s, o = i < e ? this.src.charCodeAt(i) : 32, n = J(u) || q(String.fromCharCode(u)), c = J(o) || q(String.fromCharCode(o)), h = G(u), D = G(o), A = !D && (!c || h || n), m = !h && (!n || D || c);
|
277
|
-
return { can_open: A && (t || !m || n), can_close: m && (t || !A || c), length: a };
|
278
|
-
};
|
279
|
-
P.prototype.Token = x;
|
280
|
-
const Q = [];
|
281
|
-
for (let s = 0; s < 256; s++)
|
282
|
-
Q.push(0);
|
283
|
-
"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(s) {
|
284
|
-
Q[s.charCodeAt(0)] = 1;
|
285
|
-
});
|
286
|
-
let b = /* @__PURE__ */ function(s) {
|
287
|
-
return s.DOCUMENT = "doc", s.HEADING = "heading", s.PARAGRAPH = "paragraph", s.QUOTE = "blockquote", s.OL_LIST = "ordered_list", s.UL_LIST = "bullet_list", s.LIST_ITEM = "list_item", s.CODE_BLOCK = "code_block", s.HR = "horizontal_rule", s.BR = "hard_break", s.IMAGE = "image", s.EMOJI = "emoji", s.COMPONENT = "blok", s.TABLE = "table", s.TABLE_ROW = "tableRow", s.TABLE_CELL = "tableCell", s.TABLE_HEADER = "tableHeader", s;
|
288
|
-
}({}), k = /* @__PURE__ */ function(s) {
|
289
|
-
return s.BOLD = "bold", s.STRONG = "strong", s.STRIKE = "strike", s.UNDERLINE = "underline", s.ITALIC = "italic", s.CODE = "code", s.LINK = "link", s.ANCHOR = "anchor", s.STYLED = "styled", s.SUPERSCRIPT = "superscript", s.SUBSCRIPT = "subscript", s.TEXT_STYLE = "textStyle", s.HIGHLIGHT = "highlight", s;
|
290
|
-
}({}), bt = /* @__PURE__ */ function(s) {
|
291
|
-
return s.TEXT = "text", s;
|
292
|
-
}({}), I = /* @__PURE__ */ function(s) {
|
293
|
-
return s.URL = "url", s.STORY = "story", s.ASSET = "asset", s.EMAIL = "email", s;
|
294
|
-
}({});
|
295
|
-
function vt(s, t) {
|
38
|
+
const P = (e) => Object.fromEntries(Object.entries(e).filter(([t, s]) => s !== void 0));
|
39
|
+
function ce(e, t) {
|
296
40
|
if (!t) return {
|
297
|
-
src:
|
41
|
+
src: e,
|
298
42
|
attrs: {}
|
299
43
|
};
|
300
|
-
let
|
301
|
-
const
|
302
|
-
function
|
303
|
-
typeof
|
44
|
+
let s = 0, r = 0;
|
45
|
+
const i = {}, n = [];
|
46
|
+
function l(u, c, f, g, E) {
|
47
|
+
typeof u != "number" || u <= c || u >= f ? console.warn(`[StoryblokRichText] - ${g.charAt(0).toUpperCase() + g.slice(1)} value must be a number between ${c} and ${f} (inclusive)`) : E.push(`${g}(${u})`);
|
304
48
|
}
|
305
49
|
if (typeof t == "object") {
|
306
|
-
if (typeof t.width == "number" && t.width > 0 ? (
|
307
|
-
const { filters:
|
308
|
-
c &&
|
50
|
+
if (typeof t.width == "number" && t.width > 0 ? (i.width = t.width, s = t.width) : console.warn("[StoryblokRichText] - Width value must be a number greater than 0"), t.height && typeof t.height == "number" && t.height > 0 ? (i.height = t.height, r = t.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than 0"), t.loading && ["lazy", "eager"].includes(t.loading) && (i.loading = t.loading), t.class && (i.class = t.class), t.filters) {
|
51
|
+
const { filters: u } = t || {}, { blur: c, brightness: f, fill: g, format: E, grayscale: _, quality: T, rotate: L } = u || {};
|
52
|
+
c && l(c, 0, 100, "blur", n), T && l(T, 0, 100, "quality", n), f && l(f, 0, 100, "brightness", n), g && n.push(`fill(${g})`), _ && n.push("grayscale()"), L && [
|
309
53
|
0,
|
310
54
|
90,
|
311
55
|
180,
|
312
56
|
270
|
313
|
-
].includes(t.filters.rotate || 0) &&
|
57
|
+
].includes(t.filters.rotate || 0) && n.push(`rotate(${L})`), E && [
|
314
58
|
"webp",
|
315
59
|
"png",
|
316
60
|
"jpeg"
|
317
|
-
].includes(
|
61
|
+
].includes(E) && n.push(`format(${E})`);
|
318
62
|
}
|
319
|
-
t.srcset && (
|
320
|
-
if (typeof
|
321
|
-
if (Array.isArray(
|
322
|
-
const [c,
|
323
|
-
return `${
|
63
|
+
t.srcset && (i.srcset = t.srcset.map((u) => {
|
64
|
+
if (typeof u == "number") return `${e}/m/${u}x0/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${u}w`;
|
65
|
+
if (Array.isArray(u) && u.length === 2) {
|
66
|
+
const [c, f] = u;
|
67
|
+
return `${e}/m/${c}x${f}/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${c}w`;
|
324
68
|
} else {
|
325
69
|
console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
|
326
70
|
return;
|
327
71
|
}
|
328
|
-
}).join(", ")), t.sizes && (
|
72
|
+
}).join(", ")), t.sizes && (i.sizes = t.sizes.join(", "));
|
329
73
|
}
|
330
|
-
let
|
331
|
-
return
|
332
|
-
src:
|
333
|
-
attrs:
|
74
|
+
let a = `${e}/m/`;
|
75
|
+
return s > 0 && r > 0 && (a = `${a}${s}x${r}/`), n.length > 0 && (a = `${a}filters:${n.join(":")}`), {
|
76
|
+
src: a,
|
77
|
+
attrs: i
|
334
78
|
};
|
335
79
|
}
|
336
|
-
|
337
|
-
"
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
"hr",
|
343
|
-
"img",
|
344
|
-
"input",
|
345
|
-
"link",
|
346
|
-
"meta",
|
347
|
-
"param",
|
348
|
-
"source",
|
349
|
-
"track",
|
350
|
-
"wbr"
|
351
|
-
], xt = (s = {}) => Object.keys(s).map((t) => `${t}="${s[t]}"`).join(" "), wt = (s = {}) => Object.keys(s).map((t) => `${t}: ${s[t]}`).join("; ");
|
352
|
-
function Bt(s) {
|
353
|
-
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
80
|
+
function F(e, t = {}, s) {
|
81
|
+
const r = oe(t), i = r ? `${e} ${r}` : e, n = Array.isArray(s) ? s.join("") : s || "";
|
82
|
+
if (e) {
|
83
|
+
if (ne.includes(e)) return `<${i}>`;
|
84
|
+
} else return n;
|
85
|
+
return `<${i}>${n}</${e}>`;
|
354
86
|
}
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
const f = F.attrs || {};
|
366
|
-
return d.render(l, f, F.children || null);
|
367
|
-
}, c = (l, F) => {
|
368
|
-
const { src: d, alt: f, title: E, srcset: C, sizes: g } = l.attrs || {};
|
369
|
-
let y = d, v = {};
|
370
|
-
if (i) {
|
371
|
-
const { src: at, attrs: ct } = vt(d, i);
|
372
|
-
y = at, v = ct;
|
87
|
+
function ue(e = {}) {
|
88
|
+
const t = /* @__PURE__ */ new Map(), { renderFn: s = F, textFn: r = le, resolvers: i = {}, optimizeImages: n = !1, keyedResolvers: l = !1 } = e, a = s !== F, u = (o) => (d, h) => {
|
89
|
+
const y = d.attrs || {};
|
90
|
+
return h.render(o, y, d.children || null);
|
91
|
+
}, c = (o, d) => {
|
92
|
+
const { src: h, alt: y, title: p, srcset: m, sizes: v } = o.attrs || {};
|
93
|
+
let R = h, k = {};
|
94
|
+
if (n) {
|
95
|
+
const { src: ee, attrs: te } = ce(h, n);
|
96
|
+
R = ee, k = te;
|
373
97
|
}
|
374
|
-
const
|
375
|
-
src:
|
376
|
-
alt:
|
377
|
-
title:
|
378
|
-
srcset:
|
379
|
-
sizes:
|
380
|
-
...
|
98
|
+
const Z = {
|
99
|
+
src: R,
|
100
|
+
alt: y,
|
101
|
+
title: p,
|
102
|
+
srcset: m,
|
103
|
+
sizes: v,
|
104
|
+
...k
|
381
105
|
};
|
382
|
-
return
|
383
|
-
},
|
384
|
-
const { level:
|
385
|
-
return
|
386
|
-
},
|
387
|
-
var
|
388
|
-
const
|
389
|
-
src: (
|
390
|
-
alt: (
|
106
|
+
return d.render("img", P(Z));
|
107
|
+
}, f = (o, d) => {
|
108
|
+
const { level: h, ...y } = o.attrs || {};
|
109
|
+
return d.render(`h${h}`, y, o.children);
|
110
|
+
}, g = (o, d) => {
|
111
|
+
var y, p, m, v;
|
112
|
+
const h = d.render("img", {
|
113
|
+
src: (y = o.attrs) == null ? void 0 : y.fallbackImage,
|
114
|
+
alt: (p = o.attrs) == null ? void 0 : p.alt,
|
391
115
|
style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
|
392
116
|
draggable: "false",
|
393
117
|
loading: "lazy"
|
394
118
|
});
|
395
|
-
return
|
119
|
+
return d.render("span", {
|
396
120
|
"data-type": "emoji",
|
397
|
-
"data-name": (
|
398
|
-
"data-emoji": (
|
399
|
-
},
|
400
|
-
},
|
401
|
-
const { class:
|
402
|
-
class:
|
403
|
-
id:
|
404
|
-
style:
|
405
|
-
} :
|
406
|
-
return
|
407
|
-
},
|
408
|
-
const { marks:
|
409
|
-
if ("text" in
|
410
|
-
if (
|
411
|
-
...
|
412
|
-
text:
|
413
|
-
}),
|
414
|
-
...
|
415
|
-
children:
|
121
|
+
"data-name": (m = o.attrs) == null ? void 0 : m.name,
|
122
|
+
"data-emoji": (v = o.attrs) == null ? void 0 : v.emoji
|
123
|
+
}, h);
|
124
|
+
}, E = (o, d) => d.render("pre", o.attrs || {}, d.render("code", {}, o.children || "")), _ = (o, d = !1) => ({ text: h, attrs: y }, p) => {
|
125
|
+
const { class: m, id: v, ...R } = y || {}, k = d ? {
|
126
|
+
class: m,
|
127
|
+
id: v,
|
128
|
+
style: ae(R) || void 0
|
129
|
+
} : y || {};
|
130
|
+
return p.render(o, P(k), h);
|
131
|
+
}, T = (o) => N(o), L = (o) => {
|
132
|
+
const { marks: d, ...h } = o;
|
133
|
+
if ("text" in o) {
|
134
|
+
if (d) return d.reduce((p, m) => T({
|
135
|
+
...m,
|
136
|
+
text: p
|
137
|
+
}), T({
|
138
|
+
...h,
|
139
|
+
children: h.children
|
416
140
|
}));
|
417
|
-
const
|
418
|
-
if (
|
419
|
-
const
|
420
|
-
t.set("txt",
|
141
|
+
const y = o.attrs || {};
|
142
|
+
if (l) {
|
143
|
+
const p = t.get("txt") || 0;
|
144
|
+
t.set("txt", p + 1), y.key = `txt-${p}`;
|
421
145
|
}
|
422
|
-
return r(
|
146
|
+
return r(h.text, y);
|
423
147
|
}
|
424
148
|
return "";
|
425
|
-
},
|
426
|
-
const { linktype:
|
427
|
-
let
|
428
|
-
switch (
|
429
|
-
case
|
430
|
-
case
|
431
|
-
|
149
|
+
}, j = (o, d) => {
|
150
|
+
const { linktype: h, href: y, anchor: p, ...m } = o.attrs || {};
|
151
|
+
let v = "";
|
152
|
+
switch (h) {
|
153
|
+
case C.ASSET:
|
154
|
+
case C.URL:
|
155
|
+
v = y;
|
432
156
|
break;
|
433
|
-
case
|
434
|
-
|
157
|
+
case C.EMAIL:
|
158
|
+
v = `mailto:${y}`;
|
435
159
|
break;
|
436
|
-
case
|
437
|
-
|
160
|
+
case C.STORY:
|
161
|
+
v = y, p && (v = `${v}#${p}`);
|
438
162
|
break;
|
439
163
|
default:
|
440
|
-
|
164
|
+
v = y;
|
441
165
|
break;
|
442
166
|
}
|
443
|
-
const
|
444
|
-
return
|
445
|
-
},
|
446
|
-
var
|
447
|
-
return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),
|
448
|
-
blok: (
|
449
|
-
id: (
|
167
|
+
const R = { ...m };
|
168
|
+
return v && (R.href = v), d.render("a", R, o.text);
|
169
|
+
}, J = (o, d) => {
|
170
|
+
var h, y;
|
171
|
+
return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), d.render("span", {
|
172
|
+
blok: (h = o == null ? void 0 : o.attrs) == null ? void 0 : h.body[0],
|
173
|
+
id: (y = o.attrs) == null ? void 0 : y.id,
|
450
174
|
style: "display: none"
|
451
175
|
});
|
452
|
-
},
|
453
|
-
const
|
454
|
-
return
|
455
|
-
},
|
456
|
-
const
|
457
|
-
return
|
458
|
-
},
|
459
|
-
const { colspan:
|
460
|
-
|
461
|
-
const
|
462
|
-
return
|
463
|
-
},
|
464
|
-
const { colspan:
|
465
|
-
|
466
|
-
const
|
467
|
-
return
|
176
|
+
}, K = (o, d) => {
|
177
|
+
const h = {}, y = d.render("tbody", {}, o.children);
|
178
|
+
return d.render("table", h, y);
|
179
|
+
}, Y = (o, d) => {
|
180
|
+
const h = {};
|
181
|
+
return d.render("tr", h, o.children);
|
182
|
+
}, W = (o, d) => {
|
183
|
+
const { colspan: h, rowspan: y, colwidth: p, backgroundColor: m, ...v } = o.attrs || {}, R = { ...v };
|
184
|
+
h > 1 && (R.colspan = h), y > 1 && (R.rowspan = y);
|
185
|
+
const k = [];
|
186
|
+
return p && k.push(`width: ${p}px;`), m && k.push(`background-color: ${m};`), k.length > 0 && (R.style = k.join(" ")), d.render("td", P(R), o.children);
|
187
|
+
}, X = (o, d) => {
|
188
|
+
const { colspan: h, rowspan: y, colwidth: p, backgroundColor: m, ...v } = o.attrs || {}, R = { ...v };
|
189
|
+
h > 1 && (R.colspan = h), y > 1 && (R.rowspan = y);
|
190
|
+
const k = [];
|
191
|
+
return p && k.push(`width: ${p}px;`), m && k.push(`background-color: ${m};`), k.length > 0 && (R.style = k.join(" ")), d.render("th", P(R), o.children);
|
468
192
|
}, U = /* @__PURE__ */ new Map([
|
469
|
-
[
|
470
|
-
[
|
471
|
-
[
|
472
|
-
[
|
473
|
-
[
|
474
|
-
[
|
475
|
-
[
|
476
|
-
[
|
477
|
-
[
|
478
|
-
[
|
479
|
-
[
|
480
|
-
[
|
481
|
-
[
|
482
|
-
[
|
483
|
-
[
|
484
|
-
[
|
485
|
-
[
|
486
|
-
[
|
487
|
-
[
|
488
|
-
[
|
489
|
-
[
|
490
|
-
[
|
491
|
-
[
|
492
|
-
[
|
493
|
-
[
|
494
|
-
[
|
495
|
-
[
|
496
|
-
[
|
497
|
-
[
|
498
|
-
[
|
499
|
-
]),
|
500
|
-
render: (
|
501
|
-
if (
|
502
|
-
const
|
503
|
-
t.set(
|
193
|
+
[w.DOCUMENT, u("")],
|
194
|
+
[w.HEADING, f],
|
195
|
+
[w.PARAGRAPH, u("p")],
|
196
|
+
[w.UL_LIST, u("ul")],
|
197
|
+
[w.OL_LIST, u("ol")],
|
198
|
+
[w.LIST_ITEM, u("li")],
|
199
|
+
[w.IMAGE, c],
|
200
|
+
[w.EMOJI, g],
|
201
|
+
[w.CODE_BLOCK, E],
|
202
|
+
[w.HR, u("hr")],
|
203
|
+
[w.BR, u("br")],
|
204
|
+
[w.QUOTE, u("blockquote")],
|
205
|
+
[w.COMPONENT, J],
|
206
|
+
[ie.TEXT, L],
|
207
|
+
[S.LINK, j],
|
208
|
+
[S.ANCHOR, j],
|
209
|
+
[S.STYLED, _("span", !0)],
|
210
|
+
[S.BOLD, _("strong")],
|
211
|
+
[S.TEXT_STYLE, _("span", !0)],
|
212
|
+
[S.ITALIC, _("em")],
|
213
|
+
[S.UNDERLINE, _("u")],
|
214
|
+
[S.STRIKE, _("s")],
|
215
|
+
[S.CODE, _("code")],
|
216
|
+
[S.SUPERSCRIPT, _("sup")],
|
217
|
+
[S.SUBSCRIPT, _("sub")],
|
218
|
+
[S.HIGHLIGHT, _("mark")],
|
219
|
+
[w.TABLE, K],
|
220
|
+
[w.TABLE_ROW, Y],
|
221
|
+
[w.TABLE_CELL, W],
|
222
|
+
[w.TABLE_HEADER, X]
|
223
|
+
]), B = new Map([...U, ...Object.entries(i).map(([o, d]) => [o, d])]), Q = () => ({
|
224
|
+
render: (h, y = {}, p) => {
|
225
|
+
if (l && h) {
|
226
|
+
const m = t.get(h) || 0;
|
227
|
+
t.set(h, m + 1), y.key = `${h}-${m}`;
|
504
228
|
}
|
505
|
-
return
|
229
|
+
return s(h, y, p);
|
506
230
|
},
|
507
231
|
originalResolvers: U,
|
508
|
-
mergedResolvers:
|
232
|
+
mergedResolvers: B
|
509
233
|
});
|
510
|
-
function
|
511
|
-
const
|
512
|
-
if (!
|
513
|
-
return console.error("<Storyblok>", `No resolver found for node type ${
|
514
|
-
const
|
515
|
-
if (
|
516
|
-
const
|
517
|
-
return
|
518
|
-
...
|
519
|
-
children:
|
520
|
-
},
|
521
|
-
}
|
522
|
-
function
|
523
|
-
return
|
524
|
-
}
|
525
|
-
return { render:
|
234
|
+
function O(o) {
|
235
|
+
const d = B.get(o.type);
|
236
|
+
if (!d)
|
237
|
+
return console.error("<Storyblok>", `No resolver found for node type ${o.type}`), "";
|
238
|
+
const h = Q();
|
239
|
+
if (o.type === "text") return d(o, h);
|
240
|
+
const y = o.content ? o.content.map(N) : void 0;
|
241
|
+
return d({
|
242
|
+
...o,
|
243
|
+
children: y
|
244
|
+
}, h);
|
245
|
+
}
|
246
|
+
function N(o) {
|
247
|
+
return o.type === "doc" ? a ? o.content.map(O) : o.content.map(O).join("") : Array.isArray(o) ? o.map(O) : O(o);
|
248
|
+
}
|
249
|
+
return { render: N };
|
526
250
|
}
|
527
|
-
let
|
528
|
-
const
|
251
|
+
let z = !1;
|
252
|
+
const G = [], M = (e) => new Promise((t, s) => {
|
529
253
|
if (typeof window > "u") {
|
530
|
-
|
254
|
+
s(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));
|
531
255
|
return;
|
532
256
|
}
|
533
|
-
if (window.storyblokRegisterEvent = (
|
257
|
+
if (window.storyblokRegisterEvent = (i) => {
|
534
258
|
if (!window.location.search.includes("_storyblok")) {
|
535
259
|
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
536
260
|
return;
|
537
261
|
}
|
538
|
-
|
262
|
+
z ? i() : G.push(i);
|
539
263
|
}, document.getElementById("storyblok-javascript-bridge")) {
|
540
264
|
t(void 0);
|
541
265
|
return;
|
542
266
|
}
|
543
267
|
const r = document.createElement("script");
|
544
|
-
r.async = !0, r.src =
|
545
|
-
|
268
|
+
r.async = !0, r.src = e, r.id = "storyblok-javascript-bridge", r.onerror = (i) => s(i), r.onload = (i) => {
|
269
|
+
G.forEach((n) => n()), z = !0, t(i);
|
546
270
|
}, document.getElementsByTagName("head")[0].appendChild(r);
|
547
271
|
});
|
548
|
-
var
|
549
|
-
|
550
|
-
|
551
|
-
super(t), this.name = "AbortError";
|
272
|
+
var he = class extends Error {
|
273
|
+
constructor(e) {
|
274
|
+
super(e), this.name = "AbortError";
|
552
275
|
}
|
553
|
-
}
|
554
|
-
function
|
555
|
-
if (!Number.isFinite(t))
|
556
|
-
|
557
|
-
if (!Number.isFinite(e))
|
558
|
-
throw new TypeError("Expected `interval` to be a finite number");
|
276
|
+
};
|
277
|
+
function de(e, t, s) {
|
278
|
+
if (!Number.isFinite(t)) throw new TypeError("Expected `limit` to be a finite number");
|
279
|
+
if (!Number.isFinite(s)) throw new TypeError("Expected `interval` to be a finite number");
|
559
280
|
const r = [];
|
560
|
-
let
|
561
|
-
const
|
562
|
-
|
281
|
+
let i = [], n = 0, l = !1;
|
282
|
+
const a = async () => {
|
283
|
+
n++;
|
563
284
|
const c = r.shift();
|
564
|
-
if (c)
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
}, n = (...c) => a ? Promise.reject(
|
576
|
-
new Error(
|
577
|
-
"Throttled function is already aborted and not accepting new promises"
|
578
|
-
)
|
579
|
-
) : new Promise((h, D) => {
|
285
|
+
if (c) try {
|
286
|
+
const g = await e(...c.args);
|
287
|
+
c.resolve(g);
|
288
|
+
} catch (g) {
|
289
|
+
c.reject(g);
|
290
|
+
}
|
291
|
+
const f = setTimeout(() => {
|
292
|
+
n--, r.length > 0 && a(), i = i.filter((g) => g !== f);
|
293
|
+
}, s);
|
294
|
+
i.includes(f) || i.push(f);
|
295
|
+
}, u = (...c) => l ? Promise.reject(/* @__PURE__ */ new Error("Throttled function is already aborted and not accepting new promises")) : new Promise((f, g) => {
|
580
296
|
r.push({
|
581
|
-
resolve:
|
582
|
-
reject:
|
297
|
+
resolve: f,
|
298
|
+
reject: g,
|
583
299
|
args: c
|
584
|
-
}),
|
300
|
+
}), n < t && a();
|
585
301
|
});
|
586
|
-
return
|
587
|
-
|
588
|
-
|
589
|
-
), r.length = 0;
|
590
|
-
}, n;
|
302
|
+
return u.abort = () => {
|
303
|
+
l = !0, i.forEach(clearTimeout), i = [], r.forEach((c) => c.reject(() => new he("Throttle function aborted"))), r.length = 0;
|
304
|
+
}, u;
|
591
305
|
}
|
592
|
-
|
593
|
-
|
306
|
+
var fe = de;
|
307
|
+
const q = (e = "") => e.includes("/cdn/"), ye = (e, t = 25, s = 1) => ({
|
308
|
+
...e,
|
594
309
|
per_page: t,
|
595
|
-
page:
|
596
|
-
}),
|
597
|
-
const
|
598
|
-
return
|
599
|
-
},
|
310
|
+
page: s
|
311
|
+
}), ge = (e) => new Promise((t) => setTimeout(t, e)), be = (e = 0, t) => Array.from({ length: e }, t), pe = (e = 0, t = e) => {
|
312
|
+
const s = Math.abs(t - e) || 0, r = e < t ? 1 : -1;
|
313
|
+
return be(s, (i, n) => n * r + e);
|
314
|
+
}, me = async (e, t) => Promise.all(e.map(t)), ve = (e = [], t) => e.map(t).reduce((s, r) => [...s, ...r], []), H = (e, t, s) => {
|
600
315
|
const r = [];
|
601
|
-
for (const
|
602
|
-
if (!Object.prototype.hasOwnProperty.call(
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
let o;
|
609
|
-
typeof i == "object" ? o = H(
|
610
|
-
i,
|
611
|
-
t ? t + encodeURIComponent(`[${a}]`) : a,
|
612
|
-
Array.isArray(i)
|
613
|
-
) : o = `${t ? t + encodeURIComponent(`[${a}]`) : a}=${encodeURIComponent(i)}`, r.push(o);
|
316
|
+
for (const i in e) {
|
317
|
+
if (!Object.prototype.hasOwnProperty.call(e, i)) continue;
|
318
|
+
const n = e[i];
|
319
|
+
if (n == null) continue;
|
320
|
+
const l = s ? "" : encodeURIComponent(i);
|
321
|
+
let a;
|
322
|
+
typeof n == "object" ? a = H(n, t ? t + encodeURIComponent(`[${l}]`) : l, Array.isArray(n)) : a = `${t ? t + encodeURIComponent(`[${l}]`) : l}=${encodeURIComponent(n)}`, r.push(a);
|
614
323
|
}
|
615
324
|
return r.join("&");
|
616
|
-
},
|
325
|
+
}, V = (e) => {
|
617
326
|
const t = {
|
618
327
|
eu: "api.storyblok.com",
|
619
328
|
us: "api-us.storyblok.com",
|
@@ -621,206 +330,202 @@ const K = (s = "") => s.includes("/cdn/"), Tt = (s, t = 25, e = 1) => ({
|
|
621
330
|
ap: "api-ap.storyblok.com",
|
622
331
|
ca: "api-ca.storyblok.com"
|
623
332
|
};
|
624
|
-
return t[
|
333
|
+
return t[e] ?? t.eu;
|
625
334
|
};
|
626
|
-
class
|
627
|
-
constructor(
|
628
|
-
|
335
|
+
var Re = class {
|
336
|
+
constructor(e) {
|
337
|
+
b(this, "baseURL");
|
338
|
+
b(this, "timeout");
|
339
|
+
b(this, "headers");
|
340
|
+
b(this, "responseInterceptor");
|
341
|
+
b(this, "fetch");
|
342
|
+
b(this, "ejectInterceptor");
|
343
|
+
b(this, "url");
|
344
|
+
b(this, "parameters");
|
345
|
+
b(this, "fetchOptions");
|
346
|
+
this.baseURL = e.baseURL, this.headers = e.headers || new 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 = {}, this.fetchOptions = {};
|
629
347
|
}
|
630
348
|
/**
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
get(
|
637
|
-
return this.url =
|
349
|
+
*
|
350
|
+
* @param url string
|
351
|
+
* @param params ISbStoriesParams
|
352
|
+
* @returns Promise<ISbResponse | Error>
|
353
|
+
*/
|
354
|
+
get(e, t) {
|
355
|
+
return this.url = e, this.parameters = t, this._methodHandler("get");
|
638
356
|
}
|
639
|
-
post(
|
640
|
-
return this.url =
|
357
|
+
post(e, t) {
|
358
|
+
return this.url = e, this.parameters = t, this._methodHandler("post");
|
641
359
|
}
|
642
|
-
put(
|
643
|
-
return this.url =
|
360
|
+
put(e, t) {
|
361
|
+
return this.url = e, this.parameters = t, this._methodHandler("put");
|
644
362
|
}
|
645
|
-
delete(
|
646
|
-
return this.url =
|
363
|
+
delete(e, t) {
|
364
|
+
return this.url = e, this.parameters = t ?? {}, this._methodHandler("delete");
|
647
365
|
}
|
648
|
-
async _responseHandler(
|
649
|
-
const
|
366
|
+
async _responseHandler(e) {
|
367
|
+
const t = [], s = {
|
650
368
|
data: {},
|
651
369
|
headers: {},
|
652
370
|
status: 0,
|
653
371
|
statusText: ""
|
654
372
|
};
|
655
|
-
|
656
|
-
|
373
|
+
e.status !== 204 && await e.json().then((r) => {
|
374
|
+
s.data = r;
|
657
375
|
});
|
658
|
-
for (const
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
this.timeout && (o = setTimeout(() => i.abort(), this.timeout));
|
376
|
+
for (const r of e.headers.entries()) t[r[0]] = r[1];
|
377
|
+
return s.headers = { ...t }, s.status = e.status, s.statusText = e.statusText, s;
|
378
|
+
}
|
379
|
+
async _methodHandler(e) {
|
380
|
+
let t = `${this.baseURL}${this.url}`, s = null;
|
381
|
+
e === "get" ? t = `${this.baseURL}${this.url}?${H(this.parameters)}` : s = JSON.stringify(this.parameters);
|
382
|
+
const r = new URL(t), i = new AbortController(), { signal: n } = i;
|
383
|
+
let l;
|
384
|
+
this.timeout && (l = setTimeout(() => i.abort(), this.timeout));
|
668
385
|
try {
|
669
|
-
const
|
670
|
-
method:
|
386
|
+
const a = await this.fetch(`${r}`, {
|
387
|
+
method: e,
|
671
388
|
headers: this.headers,
|
672
|
-
body:
|
673
|
-
signal:
|
389
|
+
body: s,
|
390
|
+
signal: n,
|
674
391
|
...this.fetchOptions
|
675
392
|
});
|
676
|
-
this.timeout && clearTimeout(
|
677
|
-
const
|
678
|
-
|
679
|
-
|
680
|
-
return
|
681
|
-
} catch (n) {
|
682
|
-
return {
|
683
|
-
message: n
|
684
|
-
};
|
393
|
+
this.timeout && clearTimeout(l);
|
394
|
+
const u = await this._responseHandler(a);
|
395
|
+
return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(u)) : this._statusHandler(u);
|
396
|
+
} catch (a) {
|
397
|
+
return { message: a };
|
685
398
|
}
|
686
399
|
}
|
687
|
-
setFetchOptions(
|
688
|
-
Object.keys(
|
400
|
+
setFetchOptions(e = {}) {
|
401
|
+
Object.keys(e).length > 0 && "method" in e && delete e.method, this.fetchOptions = { ...e };
|
689
402
|
}
|
690
403
|
eject() {
|
691
404
|
this.ejectInterceptor = !0;
|
692
405
|
}
|
693
406
|
/**
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
_normalizeErrorMessage(
|
699
|
-
if (Array.isArray(
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
return t
|
704
|
-
|
705
|
-
if (Array.isArray(t[e]))
|
706
|
-
return `${e}: ${t[e][0]}`;
|
707
|
-
if (typeof t[e] == "string")
|
708
|
-
return `${e}: ${t[e]}`;
|
407
|
+
* Normalizes error messages from different response structures
|
408
|
+
* @param data The response data that might contain error information
|
409
|
+
* @returns A normalized error message string
|
410
|
+
*/
|
411
|
+
_normalizeErrorMessage(e) {
|
412
|
+
if (Array.isArray(e)) return e[0] || "Unknown error";
|
413
|
+
if (e && typeof e == "object") {
|
414
|
+
if (e.error) return e.error;
|
415
|
+
for (const t in e) {
|
416
|
+
if (Array.isArray(e[t])) return `${t}: ${e[t][0]}`;
|
417
|
+
if (typeof e[t] == "string") return `${t}: ${e[t]}`;
|
709
418
|
}
|
710
|
-
if (
|
711
|
-
return t.slug;
|
419
|
+
if (e.slug) return e.slug;
|
712
420
|
}
|
713
421
|
return "Unknown error";
|
714
422
|
}
|
715
|
-
_statusHandler(
|
716
|
-
const
|
717
|
-
return new Promise((
|
718
|
-
if (
|
719
|
-
return r(t);
|
423
|
+
_statusHandler(e) {
|
424
|
+
const t = /20[0-6]/g;
|
425
|
+
return new Promise((s, r) => {
|
426
|
+
if (t.test(`${e.status}`)) return s(e);
|
720
427
|
const i = {
|
721
|
-
message: this._normalizeErrorMessage(
|
722
|
-
status:
|
723
|
-
response:
|
428
|
+
message: this._normalizeErrorMessage(e.data),
|
429
|
+
status: e.status,
|
430
|
+
response: e
|
724
431
|
};
|
725
|
-
|
432
|
+
r(i);
|
726
433
|
});
|
727
434
|
}
|
728
|
-
}
|
729
|
-
const
|
435
|
+
}, we = Re;
|
436
|
+
const D = "SB-Agent", x = {
|
730
437
|
defaultAgentName: "SB-JS-CLIENT",
|
731
438
|
defaultAgentVersion: "SB-Agent-Version",
|
732
439
|
packageVersion: "7.0.0"
|
733
|
-
},
|
440
|
+
}, ke = {
|
734
441
|
PUBLISHED: "published"
|
735
442
|
};
|
736
|
-
let
|
737
|
-
const
|
738
|
-
class
|
443
|
+
let I = {};
|
444
|
+
const A = {};
|
445
|
+
var _e = class {
|
739
446
|
/**
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
constructor(
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
447
|
+
*
|
448
|
+
* @param config ISbConfig interface
|
449
|
+
* @param pEndpoint string, optional
|
450
|
+
*/
|
451
|
+
constructor(e, t) {
|
452
|
+
b(this, "client");
|
453
|
+
b(this, "maxRetries");
|
454
|
+
b(this, "retriesDelay");
|
455
|
+
b(this, "throttle");
|
456
|
+
b(this, "accessToken");
|
457
|
+
b(this, "cache");
|
458
|
+
b(this, "resolveCounter");
|
459
|
+
b(this, "relations");
|
460
|
+
b(this, "links");
|
461
|
+
b(this, "version");
|
462
|
+
/**
|
463
|
+
* @deprecated This property is deprecated. Use the standalone `richTextResolver` from `@storyblok/richtext` instead.
|
464
|
+
* @see https://github.com/storyblok/richtext
|
465
|
+
*/
|
466
|
+
b(this, "richTextResolver");
|
467
|
+
b(this, "resolveNestedRelations");
|
468
|
+
b(this, "stringifiedStoriesCache");
|
469
|
+
b(this, "inlineAssets");
|
470
|
+
let s = e.endpoint || t;
|
471
|
+
if (!s) {
|
472
|
+
const n = e.https === !1 ? "http" : "https";
|
473
|
+
e.oauthToken ? s = `${n}://${V(e.region)}/v1` : s = `${n}://${V(e.region)}/v2`;
|
750
474
|
}
|
751
|
-
const
|
752
|
-
|
753
|
-
|
754
|
-
}),
|
755
|
-
j.defaultAgentVersion,
|
756
|
-
j.packageVersion
|
757
|
-
));
|
475
|
+
const r = new Headers();
|
476
|
+
r.set("Content-Type", "application/json"), r.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([l, a]) => {
|
477
|
+
r.set(l, a);
|
478
|
+
}), r.has(D) || (r.set(D, x.defaultAgentName), r.set(x.defaultAgentVersion, x.packageVersion));
|
758
479
|
let i = 5;
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
timeout: t.timeout || 0,
|
766
|
-
headers: u,
|
767
|
-
responseInterceptor: t.responseInterceptor,
|
768
|
-
fetch: t.fetch
|
480
|
+
e.oauthToken && (r.set("Authorization", e.oauthToken), i = 3), e.rateLimit && (i = e.rateLimit), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = fe(this.throttledRequest.bind(this), i, 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.version = e.version || ke.PUBLISHED, this.inlineAssets = e.inlineAssets || !1, this.client = new we({
|
481
|
+
baseURL: s,
|
482
|
+
timeout: e.timeout || 0,
|
483
|
+
headers: r,
|
484
|
+
responseInterceptor: e.responseInterceptor,
|
485
|
+
fetch: e.fetch
|
769
486
|
});
|
770
487
|
}
|
771
|
-
parseParams(
|
772
|
-
return
|
488
|
+
parseParams(e) {
|
489
|
+
return e.token || (e.token = this.getToken()), e.cv || (e.cv = A[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), typeof e.resolve_relations < "u" && (e.resolve_level = 2), e;
|
773
490
|
}
|
774
|
-
factoryParamOptions(
|
775
|
-
return
|
491
|
+
factoryParamOptions(e, t) {
|
492
|
+
return q(e) ? this.parseParams(t) : t;
|
776
493
|
}
|
777
|
-
makeRequest(t,
|
778
|
-
const
|
779
|
-
|
780
|
-
Tt(e, r, u)
|
781
|
-
);
|
782
|
-
return this.cacheResponse(t, a, void 0, i);
|
494
|
+
makeRequest(e, t, s, r, i) {
|
495
|
+
const n = this.factoryParamOptions(e, ye(t, s, r));
|
496
|
+
return this.cacheResponse(e, n, void 0, i);
|
783
497
|
}
|
784
|
-
get(
|
785
|
-
|
786
|
-
const
|
787
|
-
|
788
|
-
const i = this.factoryParamOptions(
|
789
|
-
return this.cacheResponse(
|
498
|
+
get(e, t = {}, s) {
|
499
|
+
t || (t = {});
|
500
|
+
const r = `/${e}`;
|
501
|
+
q(r) && (t.version = t.version || this.version);
|
502
|
+
const i = this.factoryParamOptions(r, t);
|
503
|
+
return this.cacheResponse(r, i, void 0, s);
|
790
504
|
}
|
791
|
-
async getAll(
|
792
|
-
const i = (
|
793
|
-
|
794
|
-
const
|
795
|
-
|
796
|
-
e,
|
797
|
-
i,
|
798
|
-
n,
|
799
|
-
u
|
800
|
-
), h = c.total ? Math.ceil(c.total / (c.perPage || i)) : 1, D = await jt(
|
801
|
-
$t(n, h),
|
802
|
-
(A) => this.makeRequest(a, e, i, A + 1, u)
|
803
|
-
);
|
804
|
-
return Nt([c, ...D], (A) => Object.values(A.data[o]));
|
505
|
+
async getAll(e, t = {}, s, r) {
|
506
|
+
const i = (t == null ? void 0 : t.per_page) || 25, n = `/${e}`.replace(/\/$/, ""), l = s ?? n.substring(n.lastIndexOf("/") + 1);
|
507
|
+
t.version = t.version || this.version;
|
508
|
+
const a = 1, u = await this.makeRequest(n, t, i, a, r), c = u.total ? Math.ceil(u.total / (u.perPage || i)) : 1, f = await me(pe(a, c), (g) => this.makeRequest(n, t, i, g + 1, r));
|
509
|
+
return ve([u, ...f], (g) => Object.values(g.data[l]));
|
805
510
|
}
|
806
|
-
post(
|
807
|
-
const
|
808
|
-
return this.throttle("post",
|
511
|
+
post(e, t = {}, s) {
|
512
|
+
const r = `/${e}`;
|
513
|
+
return this.throttle("post", r, t, s);
|
809
514
|
}
|
810
|
-
put(
|
811
|
-
const
|
812
|
-
return this.throttle("put",
|
515
|
+
put(e, t = {}, s) {
|
516
|
+
const r = `/${e}`;
|
517
|
+
return this.throttle("put", r, t, s);
|
813
518
|
}
|
814
|
-
delete(
|
815
|
-
|
816
|
-
const
|
817
|
-
return this.throttle("delete",
|
519
|
+
delete(e, t = {}, s) {
|
520
|
+
t || (t = {});
|
521
|
+
const r = `/${e}`;
|
522
|
+
return this.throttle("delete", r, t, s);
|
818
523
|
}
|
819
|
-
getStories(
|
820
|
-
return this._addResolveLevel(
|
524
|
+
getStories(e = {}, t) {
|
525
|
+
return this._addResolveLevel(e), this.get("cdn/stories", e, t);
|
821
526
|
}
|
822
|
-
getStory(
|
823
|
-
return this._addResolveLevel(
|
527
|
+
getStory(e, t = {}, s) {
|
528
|
+
return this._addResolveLevel(t), this.get(`cdn/stories/${e}`, t, s);
|
824
529
|
}
|
825
530
|
getToken() {
|
826
531
|
return this.accessToken;
|
@@ -828,241 +533,227 @@ class Ut {
|
|
828
533
|
ejectInterceptor() {
|
829
534
|
this.client.eject();
|
830
535
|
}
|
831
|
-
_addResolveLevel(
|
832
|
-
typeof
|
536
|
+
_addResolveLevel(e) {
|
537
|
+
typeof e.resolve_relations < "u" && (e.resolve_level = 2);
|
833
538
|
}
|
834
|
-
_cleanCopy(
|
835
|
-
return JSON.parse(JSON.stringify(
|
539
|
+
_cleanCopy(e) {
|
540
|
+
return JSON.parse(JSON.stringify(e));
|
836
541
|
}
|
837
|
-
_insertLinks(
|
838
|
-
const
|
839
|
-
|
542
|
+
_insertLinks(e, t, s) {
|
543
|
+
const r = e[t];
|
544
|
+
r && r.fieldtype === "multilink" && r.linktype === "story" && typeof r.id == "string" && this.links[s][r.id] ? r.story = this._cleanCopy(this.links[s][r.id]) : r && r.linktype === "story" && typeof r.uuid == "string" && this.links[s][r.uuid] && (r.story = this._cleanCopy(this.links[s][r.uuid]));
|
840
545
|
}
|
841
546
|
/**
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
getStoryReference(
|
848
|
-
return this.relations[
|
547
|
+
*
|
548
|
+
* @param resolveId A counter number as a string
|
549
|
+
* @param uuid The uuid of the story
|
550
|
+
* @returns string | object
|
551
|
+
*/
|
552
|
+
getStoryReference(e, t) {
|
553
|
+
return this.relations[e][t] ? JSON.parse(this.stringifiedStoriesCache[t] || JSON.stringify(this.relations[e][t])) : t;
|
849
554
|
}
|
850
555
|
/**
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
_resolveField(
|
861
|
-
const
|
862
|
-
typeof
|
863
|
-
(i) => this.getStoryReference(r, i)
|
864
|
-
).filter(Boolean));
|
556
|
+
* Resolves a field's value by replacing UUIDs with their corresponding story references
|
557
|
+
* @param jtree - The JSON tree object containing the field to resolve
|
558
|
+
* @param treeItem - The key of the field to resolve
|
559
|
+
* @param resolveId - The unique identifier for the current resolution context
|
560
|
+
*
|
561
|
+
* This method handles both single string UUIDs and arrays of UUIDs:
|
562
|
+
* - For single strings: directly replaces the UUID with the story reference
|
563
|
+
* - For arrays: maps through each UUID and replaces with corresponding story references
|
564
|
+
*/
|
565
|
+
_resolveField(e, t, s) {
|
566
|
+
const r = e[t];
|
567
|
+
typeof r == "string" ? e[t] = this.getStoryReference(s, r) : Array.isArray(r) && (e[t] = r.map((i) => this.getStoryReference(s, i)).filter(Boolean));
|
865
568
|
}
|
866
569
|
/**
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
_insertRelations(t,
|
884
|
-
if (Array.isArray(
|
885
|
-
this._resolveField(
|
570
|
+
* Inserts relations into the JSON tree by resolving references
|
571
|
+
* @param jtree - The JSON tree object to process
|
572
|
+
* @param treeItem - The current field being processed
|
573
|
+
* @param fields - The relation patterns to resolve (string or array of strings)
|
574
|
+
* @param resolveId - The unique identifier for the current resolution context
|
575
|
+
*
|
576
|
+
* This method handles two types of relation patterns:
|
577
|
+
* 1. Nested relations: matches fields that end with the current field name
|
578
|
+
* Example: If treeItem is "event_type", it matches patterns like "*.event_type"
|
579
|
+
*
|
580
|
+
* 2. Direct component relations: matches exact component.field patterns
|
581
|
+
* Example: "event.event_type" for component "event" and field "event_type"
|
582
|
+
*
|
583
|
+
* The method supports both string and array formats for the fields parameter,
|
584
|
+
* allowing flexible specification of relation patterns.
|
585
|
+
*/
|
586
|
+
_insertRelations(e, t, s, r) {
|
587
|
+
if (Array.isArray(s) ? s.find((l) => l.endsWith(`.${t}`)) : s.endsWith(`.${t}`)) {
|
588
|
+
this._resolveField(e, t, r);
|
886
589
|
return;
|
887
590
|
}
|
888
|
-
const
|
889
|
-
(Array.isArray(
|
591
|
+
const n = e.component ? `${e.component}.${t}` : t;
|
592
|
+
(Array.isArray(s) ? s.includes(n) : s === n) && this._resolveField(e, t, r);
|
890
593
|
}
|
891
594
|
/**
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
iterateTree(
|
898
|
-
const
|
595
|
+
* Recursively traverses and resolves relations in the story content tree
|
596
|
+
* @param story - The story object containing the content to process
|
597
|
+
* @param fields - The relation patterns to resolve
|
598
|
+
* @param resolveId - The unique identifier for the current resolution context
|
599
|
+
*/
|
600
|
+
iterateTree(e, t, s) {
|
601
|
+
const r = (i, n = "") => {
|
899
602
|
if (!(!i || i._stopResolving)) {
|
900
|
-
if (Array.isArray(i))
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
(i.component && i._uid || i.type === "link") && (this._insertRelations(i, o, e, r), this._insertLinks(i, o, r)), u(i[o], n);
|
906
|
-
}
|
603
|
+
if (Array.isArray(i)) i.forEach((l, a) => r(l, `${n}[${a}]`));
|
604
|
+
else if (typeof i == "object") for (const l in i) {
|
605
|
+
const a = n ? `${n}.${l}` : l;
|
606
|
+
(i.component && i._uid || i.type === "link") && (this._insertRelations(i, l, t, s), this._insertLinks(i, l, s)), r(i[l], a);
|
607
|
+
}
|
907
608
|
}
|
908
609
|
};
|
909
|
-
|
910
|
-
}
|
911
|
-
async resolveLinks(
|
912
|
-
let
|
913
|
-
if (
|
914
|
-
const i =
|
915
|
-
for (let
|
916
|
-
const
|
917
|
-
|
610
|
+
r(e.content);
|
611
|
+
}
|
612
|
+
async resolveLinks(e, t, s) {
|
613
|
+
let r = [];
|
614
|
+
if (e.link_uuids) {
|
615
|
+
const i = e.link_uuids.length, n = [], l = 50;
|
616
|
+
for (let a = 0; a < i; a += l) {
|
617
|
+
const u = Math.min(i, a + l);
|
618
|
+
n.push(e.link_uuids.slice(a, u));
|
918
619
|
}
|
919
|
-
for (let
|
620
|
+
for (let a = 0; a < n.length; a++)
|
920
621
|
(await this.getStories({
|
921
|
-
per_page:
|
922
|
-
language:
|
923
|
-
version:
|
924
|
-
starts_with:
|
925
|
-
by_uuids: a
|
926
|
-
})).data.stories.forEach(
|
927
|
-
(c)
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
u = t.links;
|
933
|
-
u.forEach((i) => {
|
934
|
-
this.links[r][i.uuid] = {
|
622
|
+
per_page: l,
|
623
|
+
language: t.language,
|
624
|
+
version: t.version,
|
625
|
+
starts_with: t.starts_with,
|
626
|
+
by_uuids: n[a].join(",")
|
627
|
+
})).data.stories.forEach((c) => {
|
628
|
+
r.push(c);
|
629
|
+
});
|
630
|
+
} else r = e.links;
|
631
|
+
r.forEach((i) => {
|
632
|
+
this.links[s][i.uuid] = {
|
935
633
|
...i,
|
936
634
|
_stopResolving: !0
|
937
635
|
};
|
938
636
|
});
|
939
637
|
}
|
940
|
-
async resolveRelations(
|
941
|
-
let
|
942
|
-
if (
|
943
|
-
const i =
|
944
|
-
for (let
|
945
|
-
const
|
946
|
-
|
638
|
+
async resolveRelations(e, t, s) {
|
639
|
+
let r = [];
|
640
|
+
if (e.rel_uuids) {
|
641
|
+
const i = e.rel_uuids.length, n = [], l = 50;
|
642
|
+
for (let a = 0; a < i; a += l) {
|
643
|
+
const u = Math.min(i, a + l);
|
644
|
+
n.push(e.rel_uuids.slice(a, u));
|
947
645
|
}
|
948
|
-
for (let
|
646
|
+
for (let a = 0; a < n.length; a++)
|
949
647
|
(await this.getStories({
|
950
|
-
per_page:
|
951
|
-
language:
|
952
|
-
version:
|
953
|
-
starts_with:
|
954
|
-
by_uuids: a
|
955
|
-
excluding_fields:
|
648
|
+
per_page: l,
|
649
|
+
language: t.language,
|
650
|
+
version: t.version,
|
651
|
+
starts_with: t.starts_with,
|
652
|
+
by_uuids: n[a].join(","),
|
653
|
+
excluding_fields: t.excluding_fields
|
956
654
|
})).data.stories.forEach((c) => {
|
957
|
-
|
655
|
+
r.push(c);
|
958
656
|
});
|
959
|
-
|
960
|
-
} else
|
961
|
-
|
962
|
-
|
963
|
-
this.relations[r][i.uuid] = {
|
657
|
+
r.length > 0 && (e.rels = r, delete e.rel_uuids);
|
658
|
+
} else r = e.rels;
|
659
|
+
r && r.length > 0 && r.forEach((i) => {
|
660
|
+
this.relations[s][i.uuid] = {
|
964
661
|
...i,
|
965
662
|
_stopResolving: !0
|
966
663
|
};
|
967
664
|
});
|
968
665
|
}
|
969
666
|
/**
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
async resolveStories(
|
979
|
-
var
|
980
|
-
let
|
981
|
-
if (this.links[
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
667
|
+
*
|
668
|
+
* @param responseData
|
669
|
+
* @param params
|
670
|
+
* @param resolveId
|
671
|
+
* @description Resolves the relations and links of the stories
|
672
|
+
* @returns Promise<void>
|
673
|
+
*
|
674
|
+
*/
|
675
|
+
async resolveStories(e, t, s) {
|
676
|
+
var i, n;
|
677
|
+
let r = [];
|
678
|
+
if (this.links[s] = {}, this.relations[s] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (r = t.resolve_relations.split(",")), await this.resolveRelations(e, t, s)), t.resolve_links && [
|
679
|
+
"1",
|
680
|
+
"story",
|
681
|
+
"url",
|
682
|
+
"link"
|
683
|
+
].includes(t.resolve_links) && ((i = e.links) != null && i.length || (n = e.link_uuids) != null && n.length) && await this.resolveLinks(e, t, s), this.resolveNestedRelations) for (const l in this.relations[s]) this.iterateTree(this.relations[s][l], r, s);
|
684
|
+
e.story ? this.iterateTree(e.story, r, s) : e.stories.forEach((l) => {
|
685
|
+
this.iterateTree(l, r, s);
|
686
|
+
}), this.stringifiedStoriesCache = {}, delete this.links[s], delete this.relations[s];
|
687
|
+
}
|
688
|
+
async cacheResponse(e, t, s, r) {
|
689
|
+
const i = H({
|
690
|
+
url: e,
|
691
|
+
params: t
|
692
|
+
}), n = this.cacheProvider();
|
693
|
+
if (t.version === "published" && e !== "/cdn/spaces/me") {
|
694
|
+
const l = await n.get(i);
|
695
|
+
if (l) return Promise.resolve(l);
|
998
696
|
}
|
999
|
-
return new Promise(async (
|
1000
|
-
var
|
697
|
+
return new Promise(async (l, a) => {
|
698
|
+
var u;
|
1001
699
|
try {
|
1002
|
-
const
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
if (
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
})), D.data.story || D.data.stories) {
|
1015
|
-
const m = this.resolveCounter = ++this.resolveCounter % 1e3;
|
1016
|
-
await this.resolveStories(D.data, e, `${m}`), D = await this.processInlineAssets(D);
|
700
|
+
const c = await this.throttle("get", e, t, r);
|
701
|
+
if (c.status !== 200) return a(c);
|
702
|
+
let f = {
|
703
|
+
data: c.data,
|
704
|
+
headers: c.headers
|
705
|
+
};
|
706
|
+
if ((u = c.headers) != null && u["per-page"] && (f = Object.assign({}, f, {
|
707
|
+
perPage: c.headers["per-page"] ? Number.parseInt(c.headers["per-page"]) : 0,
|
708
|
+
total: c.headers["per-page"] ? Number.parseInt(c.headers.total) : 0
|
709
|
+
})), f.data.story || f.data.stories) {
|
710
|
+
const E = this.resolveCounter = ++this.resolveCounter % 1e3;
|
711
|
+
await this.resolveStories(f.data, t, `${E}`), f = await this.processInlineAssets(f);
|
1017
712
|
}
|
1018
|
-
|
1019
|
-
const
|
1020
|
-
return
|
1021
|
-
} catch (
|
1022
|
-
if (
|
1023
|
-
return console.log(
|
1024
|
-
|
1025
|
-
), await Ot(this.retriesDelay), this.cacheResponse(t, e, r).then(o).catch(n);
|
1026
|
-
n(h);
|
713
|
+
t.version === "published" && e !== "/cdn/spaces/me" && await n.set(i, f);
|
714
|
+
const g = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
|
715
|
+
return t.token && f.data.cv && (g && A[t.token] && A[t.token] !== f.data.cv && await this.flushCache(), A[t.token] = f.data.cv), l(f);
|
716
|
+
} catch (c) {
|
717
|
+
if (c.response && c.status === 429 && (s = typeof s > "u" ? 0 : s + 1, s < this.maxRetries))
|
718
|
+
return console.log(`Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`), await ge(this.retriesDelay), this.cacheResponse(e, t, s).then(l).catch(a);
|
719
|
+
a(c);
|
1027
720
|
}
|
1028
721
|
});
|
1029
722
|
}
|
1030
|
-
throttledRequest(t,
|
1031
|
-
return this.client.setFetchOptions(
|
723
|
+
throttledRequest(e, t, s, r) {
|
724
|
+
return this.client.setFetchOptions(r), this.client[e](t, s);
|
1032
725
|
}
|
1033
726
|
cacheVersions() {
|
1034
|
-
return
|
727
|
+
return A;
|
1035
728
|
}
|
1036
729
|
cacheVersion() {
|
1037
|
-
return
|
730
|
+
return A[this.accessToken];
|
1038
731
|
}
|
1039
|
-
setCacheVersion(
|
1040
|
-
this.accessToken && (
|
732
|
+
setCacheVersion(e) {
|
733
|
+
this.accessToken && (A[this.accessToken] = e);
|
1041
734
|
}
|
1042
735
|
clearCacheVersion() {
|
1043
|
-
this.accessToken && (
|
736
|
+
this.accessToken && (A[this.accessToken] = 0);
|
1044
737
|
}
|
1045
738
|
cacheProvider() {
|
1046
739
|
switch (this.cache.type) {
|
1047
740
|
case "memory":
|
1048
741
|
return {
|
1049
|
-
get(
|
1050
|
-
return Promise.resolve(
|
742
|
+
get(e) {
|
743
|
+
return Promise.resolve(I[e]);
|
1051
744
|
},
|
1052
745
|
getAll() {
|
1053
|
-
return Promise.resolve(
|
746
|
+
return Promise.resolve(I);
|
1054
747
|
},
|
1055
|
-
set(
|
1056
|
-
return
|
748
|
+
set(e, t) {
|
749
|
+
return I[e] = t, Promise.resolve(void 0);
|
1057
750
|
},
|
1058
751
|
flush() {
|
1059
|
-
return
|
752
|
+
return I = {}, Promise.resolve(void 0);
|
1060
753
|
}
|
1061
754
|
};
|
1062
755
|
case "custom":
|
1063
|
-
if (this.cache.custom)
|
1064
|
-
return this.cache.custom;
|
1065
|
-
// eslint-disable-next-line no-fallthrough
|
756
|
+
if (this.cache.custom) return this.cache.custom;
|
1066
757
|
default:
|
1067
758
|
return {
|
1068
759
|
get() {
|
@@ -1083,41 +774,37 @@ class Ut {
|
|
1083
774
|
async flushCache() {
|
1084
775
|
return await this.cacheProvider().flush(), this.clearCacheVersion(), this;
|
1085
776
|
}
|
1086
|
-
async processInlineAssets(
|
1087
|
-
if (!this.inlineAssets)
|
1088
|
-
|
1089
|
-
|
1090
|
-
if (
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
u.fieldtype === "asset" && Array.isArray(t.data.assets) && (u = {
|
1096
|
-
...u,
|
1097
|
-
...t.data.assets.find((i) => i.id === u.id)
|
777
|
+
async processInlineAssets(e) {
|
778
|
+
if (!this.inlineAssets) return e;
|
779
|
+
const t = (s) => {
|
780
|
+
if (!s || typeof s != "object") return s;
|
781
|
+
if (Array.isArray(s)) return s.map((i) => t(i));
|
782
|
+
let r = { ...s };
|
783
|
+
r.fieldtype === "asset" && Array.isArray(e.data.assets) && (r = {
|
784
|
+
...r,
|
785
|
+
...e.data.assets.find((i) => i.id === r.id)
|
1098
786
|
});
|
1099
|
-
for (const i in
|
1100
|
-
|
1101
|
-
return u;
|
787
|
+
for (const i in r) typeof r[i] == "object" && (r[i] = t(r[i]));
|
788
|
+
return r;
|
1102
789
|
};
|
1103
|
-
return
|
790
|
+
return e.data.story && (e.data.story.content = t(e.data.story.content)), e.data.stories && (e.data.stories = e.data.stories.map((s) => (s.content = t(s.content), s))), e;
|
1104
791
|
}
|
1105
|
-
}
|
1106
|
-
const
|
1107
|
-
const { apiOptions: t } =
|
792
|
+
}, Se = _e;
|
793
|
+
const Ae = (e = {}) => {
|
794
|
+
const { apiOptions: t } = e;
|
1108
795
|
if (!t || !t.accessToken) {
|
1109
796
|
console.error(
|
1110
797
|
"You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication"
|
1111
798
|
);
|
1112
799
|
return;
|
1113
800
|
}
|
1114
|
-
return { storyblokApi: new
|
1115
|
-
},
|
1116
|
-
if (typeof
|
801
|
+
return { storyblokApi: new Se(t) };
|
802
|
+
}, Te = (e) => {
|
803
|
+
if (typeof e != "object" || typeof e._editable > "u")
|
1117
804
|
return {};
|
1118
805
|
try {
|
1119
806
|
const t = JSON.parse(
|
1120
|
-
|
807
|
+
e._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
|
1121
808
|
);
|
1122
809
|
return t ? {
|
1123
810
|
"data-blok-c": JSON.stringify(t),
|
@@ -1127,56 +814,56 @@ const zt = (s = {}) => {
|
|
1127
814
|
return {};
|
1128
815
|
}
|
1129
816
|
};
|
1130
|
-
let
|
1131
|
-
const
|
1132
|
-
var
|
1133
|
-
const
|
817
|
+
let $ = "https://app.storyblok.com/f/storyblok-v2-latest.js";
|
818
|
+
const Le = (e, t, s = {}) => {
|
819
|
+
var a;
|
820
|
+
const i = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", n = new URL((a = window.location) == null ? void 0 : a.href).searchParams.get(
|
1134
821
|
"_storyblok"
|
1135
|
-
),
|
1136
|
-
if (!(!
|
1137
|
-
if (!
|
822
|
+
), l = n !== null && +n === e;
|
823
|
+
if (!(!i || !l)) {
|
824
|
+
if (!e) {
|
1138
825
|
console.warn("Story ID is not defined. Please provide a valid ID.");
|
1139
826
|
return;
|
1140
827
|
}
|
1141
828
|
window.storyblokRegisterEvent(() => {
|
1142
|
-
new window.StoryblokBridge(
|
1143
|
-
var
|
1144
|
-
c && (c.action === "input" && ((
|
829
|
+
new window.StoryblokBridge(s).on(["input", "published", "change"], (c) => {
|
830
|
+
var f;
|
831
|
+
c && (c.action === "input" && ((f = c.story) == null ? void 0 : f.id) === e ? t(c.story) : (c.action === "change" || c.action === "published") && c.storyId === e && window.location.reload());
|
1145
832
|
});
|
1146
833
|
});
|
1147
834
|
}
|
1148
|
-
},
|
1149
|
-
var
|
835
|
+
}, Oe = (e = {}) => {
|
836
|
+
var f, g;
|
1150
837
|
const {
|
1151
838
|
bridge: t,
|
1152
|
-
accessToken:
|
839
|
+
accessToken: s,
|
1153
840
|
use: r = [],
|
1154
|
-
apiOptions:
|
1155
|
-
bridgeUrl:
|
1156
|
-
} =
|
1157
|
-
|
1158
|
-
const
|
1159
|
-
let
|
1160
|
-
r.forEach((
|
1161
|
-
|
1162
|
-
}),
|
1163
|
-
const c = !(typeof window > "u") && ((
|
1164
|
-
return t !== !1 && c &&
|
841
|
+
apiOptions: i = {},
|
842
|
+
bridgeUrl: n
|
843
|
+
} = e;
|
844
|
+
i.accessToken = i.accessToken || s;
|
845
|
+
const l = { bridge: t, apiOptions: i };
|
846
|
+
let a = {};
|
847
|
+
r.forEach((E) => {
|
848
|
+
a = { ...a, ...E(l) };
|
849
|
+
}), n && ($ = n);
|
850
|
+
const c = !(typeof window > "u") && ((g = (f = window.location) == null ? void 0 : f.search) == null ? void 0 : g.includes("_storyblok_tk"));
|
851
|
+
return t !== !1 && c && M($), a;
|
1165
852
|
};
|
1166
|
-
function
|
1167
|
-
return
|
853
|
+
function Ce(e, t) {
|
854
|
+
return ue(t).render(e);
|
1168
855
|
}
|
1169
|
-
const
|
856
|
+
const Pe = () => M($);
|
1170
857
|
export {
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
858
|
+
w as BlockTypes,
|
859
|
+
S as MarkTypes,
|
860
|
+
ie as TextTypes,
|
861
|
+
Ae as apiPlugin,
|
862
|
+
Pe as loadStoryblokBridge,
|
863
|
+
Le as registerStoryblokBridge,
|
864
|
+
Ce as renderRichText,
|
865
|
+
ue as richTextResolver,
|
866
|
+
Te as storyblokEditable,
|
867
|
+
Oe as storyblokInit,
|
868
|
+
Le as useStoryblokBridge
|
1182
869
|
};
|