@storyblok/js 4.2.1 → 4.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/storyblok-js.js +1 -1
- package/dist/storyblok-js.mjs +905 -661
- package/package.json +5 -4
package/dist/storyblok-js.mjs
CHANGED
@@ -4,39 +4,339 @@
|
|
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
|
-
|
7
|
+
var lt = Object.defineProperty;
|
8
|
+
var ht = (t, e, s) => e in t ? lt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
|
9
|
+
var E = (t, e, s) => ht(t, typeof e != "symbol" ? e + "" : e, s);
|
10
|
+
const Dt = /[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDEAD\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/, dt = /[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C0\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC2\uFD40-\uFD4F\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF76\uDF7B-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDE53\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC5\uDECE-\uDEDB\uDEE0-\uDEE8\uDEF0-\uDEF8\uDF00-\uDF92\uDF94-\uDFCA]/;
|
11
|
+
function O(t) {
|
12
|
+
switch (t) {
|
13
|
+
case 9:
|
14
|
+
case 32:
|
15
|
+
return !0;
|
16
|
+
}
|
17
|
+
return !1;
|
18
|
+
}
|
19
|
+
function G(t) {
|
20
|
+
if (t >= 8192 && t <= 8202)
|
21
|
+
return !0;
|
22
|
+
switch (t) {
|
23
|
+
case 9:
|
24
|
+
// \t
|
25
|
+
case 10:
|
26
|
+
// \n
|
27
|
+
case 11:
|
28
|
+
// \v
|
29
|
+
case 12:
|
30
|
+
// \f
|
31
|
+
case 13:
|
32
|
+
// \r
|
33
|
+
case 32:
|
34
|
+
case 160:
|
35
|
+
case 5760:
|
36
|
+
case 8239:
|
37
|
+
case 8287:
|
38
|
+
case 12288:
|
39
|
+
return !0;
|
40
|
+
}
|
41
|
+
return !1;
|
42
|
+
}
|
43
|
+
function q(t) {
|
44
|
+
return Dt.test(t) || dt.test(t);
|
45
|
+
}
|
46
|
+
function J(t) {
|
47
|
+
switch (t) {
|
48
|
+
case 33:
|
49
|
+
case 34:
|
50
|
+
case 35:
|
51
|
+
case 36:
|
52
|
+
case 37:
|
53
|
+
case 38:
|
54
|
+
case 39:
|
55
|
+
case 40:
|
56
|
+
case 41:
|
57
|
+
case 42:
|
58
|
+
case 43:
|
59
|
+
case 44:
|
60
|
+
case 45:
|
61
|
+
case 46:
|
62
|
+
case 47:
|
63
|
+
case 58:
|
64
|
+
case 59:
|
65
|
+
case 60:
|
66
|
+
case 61:
|
67
|
+
case 62:
|
68
|
+
case 63:
|
69
|
+
case 64:
|
70
|
+
case 91:
|
71
|
+
case 92:
|
72
|
+
case 93:
|
73
|
+
case 94:
|
74
|
+
case 95:
|
75
|
+
case 96:
|
76
|
+
case 123:
|
77
|
+
case 124:
|
78
|
+
case 125:
|
79
|
+
case 126:
|
80
|
+
return !0;
|
81
|
+
default:
|
82
|
+
return !1;
|
83
|
+
}
|
84
|
+
}
|
85
|
+
function x(t, e, s) {
|
86
|
+
this.type = t, this.tag = e, this.attrs = null, this.map = null, this.nesting = s, this.level = 0, this.children = null, this.content = "", this.markup = "", this.info = "", this.meta = null, this.block = !1, this.hidden = !1;
|
87
|
+
}
|
88
|
+
x.prototype.attrIndex = function(e) {
|
89
|
+
if (!this.attrs)
|
90
|
+
return -1;
|
91
|
+
const s = this.attrs;
|
92
|
+
for (let r = 0, u = s.length; r < u; r++)
|
93
|
+
if (s[r][0] === e)
|
94
|
+
return r;
|
95
|
+
return -1;
|
96
|
+
};
|
97
|
+
x.prototype.attrPush = function(e) {
|
98
|
+
this.attrs ? this.attrs.push(e) : this.attrs = [e];
|
99
|
+
};
|
100
|
+
x.prototype.attrSet = function(e, s) {
|
101
|
+
const r = this.attrIndex(e), u = [e, s];
|
102
|
+
r < 0 ? this.attrPush(u) : this.attrs[r] = u;
|
103
|
+
};
|
104
|
+
x.prototype.attrGet = function(e) {
|
105
|
+
const s = this.attrIndex(e);
|
106
|
+
let r = null;
|
107
|
+
return s >= 0 && (r = this.attrs[s][1]), r;
|
108
|
+
};
|
109
|
+
x.prototype.attrJoin = function(e, s) {
|
110
|
+
const r = this.attrIndex(e);
|
111
|
+
r < 0 ? this.attrPush([e, s]) : this.attrs[r][1] = this.attrs[r][1] + " " + s;
|
112
|
+
};
|
113
|
+
function ft(t, e, s) {
|
114
|
+
this.src = t, this.env = s, this.tokens = [], this.inlineMode = !1, this.md = e;
|
115
|
+
}
|
116
|
+
ft.prototype.Token = x;
|
117
|
+
function _(t, e, s, r) {
|
118
|
+
this.src = t, this.md = e, this.env = s, 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;
|
119
|
+
const u = this.src;
|
120
|
+
for (let i = 0, o = 0, n = 0, a = 0, c = u.length, h = !1; o < c; o++) {
|
121
|
+
const D = u.charCodeAt(o);
|
122
|
+
if (!h)
|
123
|
+
if (O(D)) {
|
124
|
+
n++, D === 9 ? a += 4 - a % 4 : a++;
|
125
|
+
continue;
|
126
|
+
} else
|
127
|
+
h = !0;
|
128
|
+
(D === 10 || o === c - 1) && (D !== 10 && o++, this.bMarks.push(i), this.eMarks.push(o), this.tShift.push(n), this.sCount.push(a), this.bsCount.push(0), h = !1, n = 0, a = 0, i = o + 1);
|
129
|
+
}
|
130
|
+
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;
|
131
|
+
}
|
132
|
+
_.prototype.push = function(t, e, s) {
|
133
|
+
const r = new x(t, e, s);
|
134
|
+
return r.block = !0, s < 0 && this.level--, r.level = this.level, s > 0 && this.level++, this.tokens.push(r), r;
|
135
|
+
};
|
136
|
+
_.prototype.isEmpty = function(e) {
|
137
|
+
return this.bMarks[e] + this.tShift[e] >= this.eMarks[e];
|
138
|
+
};
|
139
|
+
_.prototype.skipEmptyLines = function(e) {
|
140
|
+
for (let s = this.lineMax; e < s && !(this.bMarks[e] + this.tShift[e] < this.eMarks[e]); e++)
|
141
|
+
;
|
142
|
+
return e;
|
143
|
+
};
|
144
|
+
_.prototype.skipSpaces = function(e) {
|
145
|
+
for (let s = this.src.length; e < s; e++) {
|
146
|
+
const r = this.src.charCodeAt(e);
|
147
|
+
if (!O(r))
|
148
|
+
break;
|
149
|
+
}
|
150
|
+
return e;
|
151
|
+
};
|
152
|
+
_.prototype.skipSpacesBack = function(e, s) {
|
153
|
+
if (e <= s)
|
154
|
+
return e;
|
155
|
+
for (; e > s; )
|
156
|
+
if (!O(this.src.charCodeAt(--e)))
|
157
|
+
return e + 1;
|
158
|
+
return e;
|
159
|
+
};
|
160
|
+
_.prototype.skipChars = function(e, s) {
|
161
|
+
for (let r = this.src.length; e < r && this.src.charCodeAt(e) === s; e++)
|
162
|
+
;
|
163
|
+
return e;
|
164
|
+
};
|
165
|
+
_.prototype.skipCharsBack = function(e, s, r) {
|
166
|
+
if (e <= r)
|
167
|
+
return e;
|
168
|
+
for (; e > r; )
|
169
|
+
if (s !== this.src.charCodeAt(--e))
|
170
|
+
return e + 1;
|
171
|
+
return e;
|
172
|
+
};
|
173
|
+
_.prototype.getLines = function(e, s, r, u) {
|
174
|
+
if (e >= s)
|
175
|
+
return "";
|
176
|
+
const i = new Array(s - e);
|
177
|
+
for (let o = 0, n = e; n < s; n++, o++) {
|
178
|
+
let a = 0;
|
179
|
+
const c = this.bMarks[n];
|
180
|
+
let h = c, D;
|
181
|
+
for (n + 1 < s || u ? D = this.eMarks[n] + 1 : D = this.eMarks[n]; h < D && a < r; ) {
|
182
|
+
const g = this.src.charCodeAt(h);
|
183
|
+
if (O(g))
|
184
|
+
g === 9 ? a += 4 - (a + this.bsCount[n]) % 4 : a++;
|
185
|
+
else if (h - c < this.tShift[n])
|
186
|
+
a++;
|
187
|
+
else
|
188
|
+
break;
|
189
|
+
h++;
|
190
|
+
}
|
191
|
+
a > r ? i[o] = new Array(a - r + 1).join(" ") + this.src.slice(h, D) : i[o] = this.src.slice(h, D);
|
192
|
+
}
|
193
|
+
return i.join("");
|
194
|
+
};
|
195
|
+
_.prototype.Token = x;
|
196
|
+
const Ft = [
|
197
|
+
"address",
|
198
|
+
"article",
|
199
|
+
"aside",
|
200
|
+
"base",
|
201
|
+
"basefont",
|
202
|
+
"blockquote",
|
203
|
+
"body",
|
204
|
+
"caption",
|
205
|
+
"center",
|
206
|
+
"col",
|
207
|
+
"colgroup",
|
208
|
+
"dd",
|
209
|
+
"details",
|
210
|
+
"dialog",
|
211
|
+
"dir",
|
212
|
+
"div",
|
213
|
+
"dl",
|
214
|
+
"dt",
|
215
|
+
"fieldset",
|
216
|
+
"figcaption",
|
217
|
+
"figure",
|
218
|
+
"footer",
|
219
|
+
"form",
|
220
|
+
"frame",
|
221
|
+
"frameset",
|
222
|
+
"h1",
|
223
|
+
"h2",
|
224
|
+
"h3",
|
225
|
+
"h4",
|
226
|
+
"h5",
|
227
|
+
"h6",
|
228
|
+
"head",
|
229
|
+
"header",
|
230
|
+
"hr",
|
231
|
+
"html",
|
232
|
+
"iframe",
|
233
|
+
"legend",
|
234
|
+
"li",
|
235
|
+
"link",
|
236
|
+
"main",
|
237
|
+
"menu",
|
238
|
+
"menuitem",
|
239
|
+
"nav",
|
240
|
+
"noframes",
|
241
|
+
"ol",
|
242
|
+
"optgroup",
|
243
|
+
"option",
|
244
|
+
"p",
|
245
|
+
"param",
|
246
|
+
"search",
|
247
|
+
"section",
|
248
|
+
"summary",
|
249
|
+
"table",
|
250
|
+
"tbody",
|
251
|
+
"td",
|
252
|
+
"tfoot",
|
253
|
+
"th",
|
254
|
+
"thead",
|
255
|
+
"title",
|
256
|
+
"tr",
|
257
|
+
"track",
|
258
|
+
"ul"
|
259
|
+
], Et = "[a-zA-Z_:][a-zA-Z0-9:._-]*", pt = "[^\"'=<>`\\x00-\\x20]+", Ct = "'[^']*'", At = '"[^"]*"', gt = "(?:" + pt + "|" + Ct + "|" + At + ")", yt = "(?:\\s+" + Et + "(?:\\s*=\\s*" + gt + ")?)", bt = "<[A-Za-z][A-Za-z0-9\\-]*" + yt + "*\\s*\\/?>", kt = "<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>", mt = new RegExp("^(?:" + bt + "|" + kt + ")");
|
260
|
+
new RegExp("^</?(" + Ft.join("|") + ")(?=(\\s|/?>|$))", "i"), new RegExp(mt.source + "\\s*$");
|
261
|
+
function I(t, e, s, r) {
|
262
|
+
this.src = t, this.env = s, this.md = e, 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;
|
263
|
+
}
|
264
|
+
I.prototype.pushPending = function() {
|
265
|
+
const t = new x("text", "", 0);
|
266
|
+
return t.content = this.pending, t.level = this.pendingLevel, this.tokens.push(t), this.pending = "", t;
|
267
|
+
};
|
268
|
+
I.prototype.push = function(t, e, s) {
|
269
|
+
this.pending && this.pushPending();
|
270
|
+
const r = new x(t, e, s);
|
271
|
+
let u = null;
|
272
|
+
return s < 0 && (this.level--, this.delimiters = this._prev_delimiters.pop()), r.level = this.level, s > 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;
|
273
|
+
};
|
274
|
+
I.prototype.scanDelims = function(t, e) {
|
275
|
+
const s = this.posMax, r = this.src.charCodeAt(t), u = t > 0 ? this.src.charCodeAt(t - 1) : 32;
|
276
|
+
let i = t;
|
277
|
+
for (; i < s && this.src.charCodeAt(i) === r; )
|
278
|
+
i++;
|
279
|
+
const o = i - t, n = i < s ? this.src.charCodeAt(i) : 32, a = J(u) || q(String.fromCharCode(u)), c = J(n) || q(String.fromCharCode(n)), h = G(u), D = G(n), g = !D && (!c || h || a), k = !h && (!a || D || c);
|
280
|
+
return { can_open: g && (e || !k || a), can_close: k && (e || !g || c), length: o };
|
281
|
+
};
|
282
|
+
I.prototype.Token = x;
|
283
|
+
const Q = [];
|
284
|
+
for (let t = 0; t < 256; t++)
|
285
|
+
Q.push(0);
|
286
|
+
"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(t) {
|
287
|
+
Q[t.charCodeAt(0)] = 1;
|
288
|
+
});
|
289
|
+
let b = /* @__PURE__ */ function(t) {
|
290
|
+
return t.DOCUMENT = "doc", t.HEADING = "heading", t.PARAGRAPH = "paragraph", t.QUOTE = "blockquote", t.OL_LIST = "ordered_list", t.UL_LIST = "bullet_list", t.LIST_ITEM = "list_item", t.CODE_BLOCK = "code_block", t.HR = "horizontal_rule", t.BR = "hard_break", t.IMAGE = "image", t.EMOJI = "emoji", t.COMPONENT = "blok", t.TABLE = "table", t.TABLE_ROW = "tableRow", t.TABLE_CELL = "tableCell", t.TABLE_HEADER = "tableHeader", t;
|
291
|
+
}({}), v = /* @__PURE__ */ function(t) {
|
292
|
+
return t.BOLD = "bold", t.STRONG = "strong", t.STRIKE = "strike", t.UNDERLINE = "underline", t.ITALIC = "italic", t.CODE = "code", t.LINK = "link", t.ANCHOR = "anchor", t.STYLED = "styled", t.SUPERSCRIPT = "superscript", t.SUBSCRIPT = "subscript", t.TEXT_STYLE = "textStyle", t.HIGHLIGHT = "highlight", t;
|
293
|
+
}({}), vt = /* @__PURE__ */ function(t) {
|
294
|
+
return t.TEXT = "text", t;
|
295
|
+
}({}), L = /* @__PURE__ */ function(t) {
|
296
|
+
return t.URL = "url", t.STORY = "story", t.ASSET = "asset", t.EMAIL = "email", t;
|
297
|
+
}({});
|
298
|
+
function xt(t, e) {
|
299
|
+
if (!e) return {
|
300
|
+
src: t,
|
301
|
+
attrs: {}
|
302
|
+
};
|
303
|
+
let s = 0, r = 0;
|
304
|
+
const u = {}, i = [];
|
305
|
+
function o(a, c, h, D, g) {
|
306
|
+
typeof a != "number" || a <= c || a >= h ? console.warn(`[StoryblokRichText] - ${D.charAt(0).toUpperCase() + D.slice(1)} value must be a number between ${c} and ${h} (inclusive)`) : g.push(`${D}(${a})`);
|
14
307
|
}
|
15
308
|
if (typeof e == "object") {
|
16
|
-
if (typeof e.width == "number" && e.width > 0 ? (
|
17
|
-
const { filters: a } = e || {}, { blur:
|
18
|
-
|
309
|
+
if (typeof e.width == "number" && e.width > 0 ? (u.width = e.width, s = e.width) : console.warn("[StoryblokRichText] - Width value must be a number greater than 0"), e.height && typeof e.height == "number" && e.height > 0 ? (u.height = e.height, r = e.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than 0"), e.loading && ["lazy", "eager"].includes(e.loading) && (u.loading = e.loading), e.class && (u.class = e.class), e.filters) {
|
310
|
+
const { filters: a } = e || {}, { blur: c, brightness: h, fill: D, format: g, grayscale: k, quality: w, rotate: R } = a || {};
|
311
|
+
c && o(c, 0, 100, "blur", i), w && o(w, 0, 100, "quality", i), h && o(h, 0, 100, "brightness", i), D && i.push(`fill(${D})`), k && i.push("grayscale()"), R && [
|
312
|
+
0,
|
313
|
+
90,
|
314
|
+
180,
|
315
|
+
270
|
316
|
+
].includes(e.filters.rotate || 0) && i.push(`rotate(${R})`), g && [
|
317
|
+
"webp",
|
318
|
+
"png",
|
319
|
+
"jpeg"
|
320
|
+
].includes(g) && i.push(`format(${g})`);
|
19
321
|
}
|
20
|
-
e.srcset && (
|
21
|
-
if (typeof a == "number")
|
22
|
-
return `${r}/m/${a}x0/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${a}w`;
|
322
|
+
e.srcset && (u.srcset = e.srcset.map((a) => {
|
323
|
+
if (typeof a == "number") return `${t}/m/${a}x0/${i.length > 0 ? `filters:${i.join(":")}` : ""} ${a}w`;
|
23
324
|
if (Array.isArray(a) && a.length === 2) {
|
24
|
-
const [
|
25
|
-
return `${
|
325
|
+
const [c, h] = a;
|
326
|
+
return `${t}/m/${c}x${h}/${i.length > 0 ? `filters:${i.join(":")}` : ""} ${c}w`;
|
26
327
|
} else {
|
27
328
|
console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
|
28
329
|
return;
|
29
330
|
}
|
30
|
-
}).join(", ")), e.sizes && (
|
331
|
+
}).join(", ")), e.sizes && (u.sizes = e.sizes.join(", "));
|
31
332
|
}
|
32
|
-
let
|
33
|
-
return
|
34
|
-
src:
|
35
|
-
attrs:
|
333
|
+
let n = `${t}/m/`;
|
334
|
+
return s > 0 && r > 0 && (n = `${n}${s}x${r}/`), i.length > 0 && (n = `${n}filters:${i.join(":")}`), {
|
335
|
+
src: n,
|
336
|
+
attrs: u
|
36
337
|
};
|
37
338
|
}
|
38
|
-
|
39
|
-
const oe = [
|
339
|
+
const _t = [
|
40
340
|
"area",
|
41
341
|
"base",
|
42
342
|
"br",
|
@@ -51,291 +351,257 @@ const oe = [
|
|
51
351
|
"source",
|
52
352
|
"track",
|
53
353
|
"wbr"
|
54
|
-
],
|
55
|
-
function
|
56
|
-
return
|
354
|
+
], Bt = (t = {}) => Object.keys(t).map((e) => `${e}="${t[e]}"`).join(" "), wt = (t = {}) => Object.keys(t).map((e) => `${e}: ${t[e]}`).join("; ");
|
355
|
+
function Rt(t) {
|
356
|
+
return t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
57
357
|
}
|
58
|
-
const
|
59
|
-
function
|
60
|
-
const
|
61
|
-
if (
|
62
|
-
if (
|
63
|
-
|
64
|
-
|
65
|
-
return `<${s}>${n}</${r}>`;
|
358
|
+
const T = (t) => Object.fromEntries(Object.entries(t).filter(([e, s]) => s !== void 0));
|
359
|
+
function V(t, e = {}, s) {
|
360
|
+
const r = Bt(e), u = r ? `${t} ${r}` : t, i = Array.isArray(s) ? s.join("") : s || "";
|
361
|
+
if (t) {
|
362
|
+
if (_t.includes(t)) return `<${u}>`;
|
363
|
+
} else return i;
|
364
|
+
return `<${u}>${i}</${t}>`;
|
66
365
|
}
|
67
|
-
function
|
68
|
-
const e = /* @__PURE__ */ new Map(), {
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
}, h = (i, u) => {
|
78
|
-
const { src: p, alt: f, title: m, srcset: w, sizes: b } = i.attrs || {};
|
79
|
-
let k = p, $ = {};
|
80
|
-
if (n) {
|
81
|
-
const { src: te, attrs: se } = re(p, n);
|
82
|
-
k = te, $ = se;
|
366
|
+
function St(t = {}) {
|
367
|
+
const e = /* @__PURE__ */ new Map(), { renderFn: s = V, textFn: r = Rt, resolvers: u = {}, optimizeImages: i = !1, keyedResolvers: o = !1 } = t, n = s !== V, a = (l) => (f, d) => {
|
368
|
+
const F = f.attrs || {};
|
369
|
+
return d.render(l, F, f.children || null);
|
370
|
+
}, c = (l, f) => {
|
371
|
+
const { src: d, alt: F, title: p, srcset: C, sizes: A } = l.attrs || {};
|
372
|
+
let y = d, m = {};
|
373
|
+
if (i) {
|
374
|
+
const { src: at, attrs: ct } = xt(d, i);
|
375
|
+
y = at, m = ct;
|
83
376
|
}
|
84
|
-
const
|
85
|
-
src:
|
86
|
-
alt:
|
87
|
-
title:
|
88
|
-
srcset:
|
89
|
-
sizes:
|
90
|
-
|
377
|
+
const ot = {
|
378
|
+
src: y,
|
379
|
+
alt: F,
|
380
|
+
title: p,
|
381
|
+
srcset: C,
|
382
|
+
sizes: A,
|
383
|
+
...m
|
91
384
|
};
|
92
|
-
return
|
93
|
-
},
|
94
|
-
const { level:
|
95
|
-
return
|
96
|
-
},
|
97
|
-
var
|
98
|
-
const
|
99
|
-
src: (
|
100
|
-
alt: (
|
385
|
+
return f.render("img", T(ot));
|
386
|
+
}, h = (l, f) => {
|
387
|
+
const { level: d, ...F } = l.attrs || {};
|
388
|
+
return f.render(`h${d}`, F, l.children);
|
389
|
+
}, D = (l, f) => {
|
390
|
+
var F, p, C, A;
|
391
|
+
const d = f.render("img", {
|
392
|
+
src: (F = l.attrs) == null ? void 0 : F.fallbackImage,
|
393
|
+
alt: (p = l.attrs) == null ? void 0 : p.alt,
|
101
394
|
style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
|
102
395
|
draggable: "false",
|
103
396
|
loading: "lazy"
|
104
397
|
});
|
105
|
-
return
|
398
|
+
return f.render("span", {
|
106
399
|
"data-type": "emoji",
|
107
|
-
"data-name": (
|
108
|
-
"data-emoji": (
|
109
|
-
},
|
110
|
-
},
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
const m = e.get("txt") || 0;
|
132
|
-
e.set("txt", m + 1), f.key = `txt-${m}`;
|
400
|
+
"data-name": (C = l.attrs) == null ? void 0 : C.name,
|
401
|
+
"data-emoji": (A = l.attrs) == null ? void 0 : A.emoji
|
402
|
+
}, d);
|
403
|
+
}, g = (l, f) => f.render("pre", l.attrs || {}, f.render("code", {}, l.children || "")), k = (l, f = !1) => ({ text: d, attrs: F }, p) => {
|
404
|
+
const { class: C, id: A, ...y } = F || {}, m = f ? {
|
405
|
+
class: C,
|
406
|
+
id: A,
|
407
|
+
style: wt(y) || void 0
|
408
|
+
} : F || {};
|
409
|
+
return p.render(l, T(m), d);
|
410
|
+
}, w = (l) => N(l), R = (l) => {
|
411
|
+
const { marks: f, ...d } = l;
|
412
|
+
if ("text" in l) {
|
413
|
+
if (f) return f.reduce((p, C) => w({
|
414
|
+
...C,
|
415
|
+
text: p
|
416
|
+
}), w({
|
417
|
+
...d,
|
418
|
+
children: d.children
|
419
|
+
}));
|
420
|
+
const F = l.attrs || {};
|
421
|
+
if (o) {
|
422
|
+
const p = e.get("txt") || 0;
|
423
|
+
e.set("txt", p + 1), F.key = `txt-${p}`;
|
133
424
|
}
|
134
|
-
return
|
425
|
+
return r(d.text, F);
|
135
426
|
}
|
136
427
|
return "";
|
137
|
-
},
|
138
|
-
const { linktype:
|
139
|
-
let
|
140
|
-
switch (
|
141
|
-
case
|
142
|
-
case
|
143
|
-
|
428
|
+
}, U = (l, f) => {
|
429
|
+
const { linktype: d, href: F, anchor: p, ...C } = l.attrs || {};
|
430
|
+
let A = "";
|
431
|
+
switch (d) {
|
432
|
+
case L.ASSET:
|
433
|
+
case L.URL:
|
434
|
+
A = F;
|
144
435
|
break;
|
145
|
-
case
|
146
|
-
|
436
|
+
case L.EMAIL:
|
437
|
+
A = `mailto:${F}`;
|
147
438
|
break;
|
148
|
-
case
|
149
|
-
|
439
|
+
case L.STORY:
|
440
|
+
A = F, p && (A = `${A}#${p}`);
|
150
441
|
break;
|
151
442
|
default:
|
152
|
-
|
443
|
+
A = F;
|
153
444
|
break;
|
154
445
|
}
|
155
|
-
const
|
156
|
-
return
|
157
|
-
},
|
158
|
-
var
|
159
|
-
return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),
|
160
|
-
blok: (
|
161
|
-
id: (
|
446
|
+
const y = { ...C };
|
447
|
+
return A && (y.href = A), f.render("a", y, l.text);
|
448
|
+
}, et = (l, f) => {
|
449
|
+
var d, F;
|
450
|
+
return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), f.render("span", {
|
451
|
+
blok: (d = l == null ? void 0 : l.attrs) == null ? void 0 : d.body[0],
|
452
|
+
id: (F = l.attrs) == null ? void 0 : F.id,
|
162
453
|
style: "display: none"
|
163
454
|
});
|
164
|
-
},
|
165
|
-
const
|
166
|
-
return
|
167
|
-
},
|
168
|
-
const
|
169
|
-
return
|
170
|
-
},
|
171
|
-
const { colspan:
|
172
|
-
|
173
|
-
|
174
|
-
p
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
const
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
[
|
186
|
-
[
|
187
|
-
[
|
188
|
-
[
|
189
|
-
[
|
190
|
-
[
|
191
|
-
[
|
192
|
-
[
|
193
|
-
[
|
194
|
-
[
|
195
|
-
[v.
|
196
|
-
[v.
|
197
|
-
[v.
|
198
|
-
[
|
199
|
-
[
|
200
|
-
[
|
201
|
-
[
|
202
|
-
[
|
203
|
-
[
|
204
|
-
[
|
205
|
-
[
|
206
|
-
[
|
207
|
-
[
|
208
|
-
[
|
209
|
-
[
|
210
|
-
[
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
...B,
|
217
|
-
...Object.entries(s).map(([i, u]) => [i, u])
|
218
|
-
]), Z = () => ({
|
219
|
-
render: (i, u = {}, p) => {
|
220
|
-
if (l && i) {
|
221
|
-
const f = e.get(i) || 0;
|
222
|
-
e.set(i, f + 1), u.key = `${i}-${f}`;
|
455
|
+
}, st = (l, f) => {
|
456
|
+
const d = {}, F = f.render("tbody", {}, l.children);
|
457
|
+
return f.render("table", d, F);
|
458
|
+
}, rt = (l, f) => {
|
459
|
+
const d = {};
|
460
|
+
return f.render("tr", d, l.children);
|
461
|
+
}, ut = (l, f) => {
|
462
|
+
const { colspan: d, rowspan: F, colwidth: p, backgroundColor: C, ...A } = l.attrs || {}, y = { ...A };
|
463
|
+
d > 1 && (y.colspan = d), F > 1 && (y.rowspan = F);
|
464
|
+
const m = [];
|
465
|
+
return p && m.push(`width: ${p}px;`), C && m.push(`background-color: ${C};`), m.length > 0 && (y.style = m.join(" ")), f.render("td", T(y), l.children);
|
466
|
+
}, it = (l, f) => {
|
467
|
+
const { colspan: d, rowspan: F, colwidth: p, backgroundColor: C, ...A } = l.attrs || {}, y = { ...A };
|
468
|
+
d > 1 && (y.colspan = d), F > 1 && (y.rowspan = F);
|
469
|
+
const m = [];
|
470
|
+
return p && m.push(`width: ${p}px;`), C && m.push(`background-color: ${C};`), m.length > 0 && (y.style = m.join(" ")), f.render("th", T(y), l.children);
|
471
|
+
}, M = /* @__PURE__ */ new Map([
|
472
|
+
[b.DOCUMENT, a("")],
|
473
|
+
[b.HEADING, h],
|
474
|
+
[b.PARAGRAPH, a("p")],
|
475
|
+
[b.UL_LIST, a("ul")],
|
476
|
+
[b.OL_LIST, a("ol")],
|
477
|
+
[b.LIST_ITEM, a("li")],
|
478
|
+
[b.IMAGE, c],
|
479
|
+
[b.EMOJI, D],
|
480
|
+
[b.CODE_BLOCK, g],
|
481
|
+
[b.HR, a("hr")],
|
482
|
+
[b.BR, a("br")],
|
483
|
+
[b.QUOTE, a("blockquote")],
|
484
|
+
[b.COMPONENT, et],
|
485
|
+
[vt.TEXT, R],
|
486
|
+
[v.LINK, U],
|
487
|
+
[v.ANCHOR, U],
|
488
|
+
[v.STYLED, k("span", !0)],
|
489
|
+
[v.BOLD, k("strong")],
|
490
|
+
[v.TEXT_STYLE, k("span", !0)],
|
491
|
+
[v.ITALIC, k("em")],
|
492
|
+
[v.UNDERLINE, k("u")],
|
493
|
+
[v.STRIKE, k("s")],
|
494
|
+
[v.CODE, k("code")],
|
495
|
+
[v.SUPERSCRIPT, k("sup")],
|
496
|
+
[v.SUBSCRIPT, k("sub")],
|
497
|
+
[v.HIGHLIGHT, k("mark")],
|
498
|
+
[b.TABLE, st],
|
499
|
+
[b.TABLE_ROW, rt],
|
500
|
+
[b.TABLE_CELL, ut],
|
501
|
+
[b.TABLE_HEADER, it]
|
502
|
+
]), z = new Map([...M, ...Object.entries(u).map(([l, f]) => [l, f])]), nt = () => ({
|
503
|
+
render: (d, F = {}, p) => {
|
504
|
+
if (o && d) {
|
505
|
+
const C = e.get(d) || 0;
|
506
|
+
e.set(d, C + 1), F.key = `${d}-${C}`;
|
223
507
|
}
|
224
|
-
return
|
508
|
+
return s(d, F, p);
|
225
509
|
},
|
226
|
-
originalResolvers:
|
227
|
-
mergedResolvers:
|
510
|
+
originalResolvers: M,
|
511
|
+
mergedResolvers: z
|
228
512
|
});
|
229
|
-
function
|
230
|
-
const
|
231
|
-
if (!
|
232
|
-
return console.error("<Storyblok>", `No resolver found for node type ${
|
233
|
-
const
|
234
|
-
if (
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
}
|
245
|
-
return {
|
246
|
-
render: C
|
247
|
-
};
|
513
|
+
function S(l) {
|
514
|
+
const f = z.get(l.type);
|
515
|
+
if (!f)
|
516
|
+
return console.error("<Storyblok>", `No resolver found for node type ${l.type}`), "";
|
517
|
+
const d = nt();
|
518
|
+
if (l.type === "text") return f(l, d);
|
519
|
+
const F = l.content ? l.content.map(N) : void 0;
|
520
|
+
return f({
|
521
|
+
...l,
|
522
|
+
children: F
|
523
|
+
}, d);
|
524
|
+
}
|
525
|
+
function N(l) {
|
526
|
+
return l.type === "doc" ? n ? l.content.map(S) : l.content.map(S).join("") : Array.isArray(l) ? l.map(S) : S(l);
|
527
|
+
}
|
528
|
+
return { render: N };
|
248
529
|
}
|
249
|
-
let
|
250
|
-
const
|
530
|
+
let K = !1;
|
531
|
+
const Y = [], tt = (t) => new Promise((e, s) => {
|
251
532
|
if (typeof window > "u") {
|
252
|
-
|
533
|
+
s(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));
|
253
534
|
return;
|
254
535
|
}
|
255
|
-
if (window.storyblokRegisterEvent = (
|
536
|
+
if (window.storyblokRegisterEvent = (u) => {
|
256
537
|
if (!window.location.search.includes("_storyblok")) {
|
257
538
|
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
258
539
|
return;
|
259
540
|
}
|
260
|
-
|
541
|
+
K ? u() : Y.push(u);
|
261
542
|
}, document.getElementById("storyblok-javascript-bridge")) {
|
262
543
|
e(void 0);
|
263
544
|
return;
|
264
545
|
}
|
265
|
-
const
|
266
|
-
|
267
|
-
|
268
|
-
}, document.getElementsByTagName("head")[0].appendChild(
|
546
|
+
const r = document.createElement("script");
|
547
|
+
r.async = !0, r.src = t, r.id = "storyblok-javascript-bridge", r.onerror = (u) => s(u), r.onload = (u) => {
|
548
|
+
Y.forEach((i) => i()), K = !0, e(u);
|
549
|
+
}, document.getElementsByTagName("head")[0].appendChild(r);
|
269
550
|
});
|
270
|
-
var
|
271
|
-
|
272
|
-
|
273
|
-
super(e), this.name = "AbortError";
|
551
|
+
var Lt = class extends Error {
|
552
|
+
constructor(t) {
|
553
|
+
super(t), this.name = "AbortError";
|
274
554
|
}
|
275
|
-
}
|
276
|
-
function
|
277
|
-
if (!Number.isFinite(e))
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
const
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
)
|
301
|
-
) : new Promise((d, y) => {
|
302
|
-
o.push({
|
303
|
-
resolve: d,
|
304
|
-
reject: y,
|
305
|
-
args: h
|
306
|
-
}), n < e && c();
|
555
|
+
};
|
556
|
+
function Tt(t, e, s) {
|
557
|
+
if (!Number.isFinite(e)) throw new TypeError("Expected `limit` to be a finite number");
|
558
|
+
if (!Number.isFinite(s)) throw new TypeError("Expected `interval` to be a finite number");
|
559
|
+
const r = [];
|
560
|
+
let u = [], i = 0, o = !1;
|
561
|
+
const n = async () => {
|
562
|
+
i++;
|
563
|
+
const c = r.shift();
|
564
|
+
if (c) try {
|
565
|
+
const D = await t(...c.args);
|
566
|
+
c.resolve(D);
|
567
|
+
} catch (D) {
|
568
|
+
c.reject(D);
|
569
|
+
}
|
570
|
+
const h = setTimeout(() => {
|
571
|
+
i--, r.length > 0 && n(), u = u.filter((D) => D !== h);
|
572
|
+
}, s);
|
573
|
+
u.includes(h) || u.push(h);
|
574
|
+
}, a = (...c) => o ? Promise.reject(/* @__PURE__ */ new Error("Throttled function is already aborted and not accepting new promises")) : new Promise((h, D) => {
|
575
|
+
r.push({
|
576
|
+
resolve: h,
|
577
|
+
reject: D,
|
578
|
+
args: c
|
579
|
+
}), i < e && n();
|
307
580
|
});
|
308
581
|
return a.abort = () => {
|
309
|
-
|
310
|
-
(h) => h.reject(() => new ue("Throttle function aborted"))
|
311
|
-
), o.length = 0;
|
582
|
+
o = !0, u.forEach(clearTimeout), u = [], r.forEach((c) => c.reject(() => new Lt("Throttle function aborted"))), r.length = 0;
|
312
583
|
}, a;
|
313
584
|
}
|
314
|
-
|
315
|
-
|
585
|
+
var Pt = Tt;
|
586
|
+
const W = (t = "") => t.includes("/cdn/"), Ot = (t, e = 25, s = 1) => ({
|
587
|
+
...t,
|
316
588
|
per_page: e,
|
317
|
-
page:
|
318
|
-
}),
|
319
|
-
const
|
320
|
-
return
|
321
|
-
},
|
322
|
-
const
|
323
|
-
for (const
|
324
|
-
if (!Object.prototype.hasOwnProperty.call(
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
e ? e + encodeURIComponent(`[${l}]`) : l,
|
334
|
-
Array.isArray(n)
|
335
|
-
) : c = `${e ? e + encodeURIComponent(`[${l}]`) : l}=${encodeURIComponent(n)}`, o.push(c);
|
336
|
-
}
|
337
|
-
return o.join("&");
|
338
|
-
}, V = (r) => {
|
589
|
+
page: s
|
590
|
+
}), It = (t) => new Promise((e) => setTimeout(e, t)), Nt = (t = 0, e) => Array.from({ length: t }, e), $t = (t = 0, e = t) => {
|
591
|
+
const s = Math.abs(e - t) || 0, r = t < e ? 1 : -1;
|
592
|
+
return Nt(s, (u, i) => i * r + t);
|
593
|
+
}, jt = async (t, e) => Promise.all(t.map(e)), Ht = (t = [], e) => t.map(e).reduce((s, r) => [...s, ...r], []), H = (t, e, s) => {
|
594
|
+
const r = [];
|
595
|
+
for (const u in t) {
|
596
|
+
if (!Object.prototype.hasOwnProperty.call(t, u)) continue;
|
597
|
+
const i = t[u];
|
598
|
+
if (i == null) continue;
|
599
|
+
const o = s ? "" : encodeURIComponent(u);
|
600
|
+
let n;
|
601
|
+
typeof i == "object" ? n = H(i, e ? e + encodeURIComponent(`[${o}]`) : o, Array.isArray(i)) : n = `${e ? e + encodeURIComponent(`[${o}]`) : o}=${encodeURIComponent(i)}`, r.push(n);
|
602
|
+
}
|
603
|
+
return r.join("&");
|
604
|
+
}, Z = (t) => {
|
339
605
|
const e = {
|
340
606
|
eu: "api.storyblok.com",
|
341
607
|
us: "api-us.storyblok.com",
|
@@ -343,206 +609,202 @@ const G = (r = "") => r.includes("/cdn/"), pe = (r, e = 25, t = 1) => ({
|
|
343
609
|
ap: "api-ap.storyblok.com",
|
344
610
|
ca: "api-ca.storyblok.com"
|
345
611
|
};
|
346
|
-
return e[
|
612
|
+
return e[t] ?? e.eu;
|
347
613
|
};
|
348
|
-
class
|
349
|
-
constructor(
|
350
|
-
|
614
|
+
var Ut = class {
|
615
|
+
constructor(t) {
|
616
|
+
E(this, "baseURL");
|
617
|
+
E(this, "timeout");
|
618
|
+
E(this, "headers");
|
619
|
+
E(this, "responseInterceptor");
|
620
|
+
E(this, "fetch");
|
621
|
+
E(this, "ejectInterceptor");
|
622
|
+
E(this, "url");
|
623
|
+
E(this, "parameters");
|
624
|
+
E(this, "fetchOptions");
|
625
|
+
this.baseURL = t.baseURL, this.headers = t.headers || new Headers(), this.timeout = t != null && t.timeout ? t.timeout * 1e3 : 0, this.responseInterceptor = t.responseInterceptor, this.fetch = (...e) => t.fetch ? t.fetch(...e) : fetch(...e), this.ejectInterceptor = !1, this.url = "", this.parameters = {}, this.fetchOptions = {};
|
351
626
|
}
|
352
627
|
/**
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
get(
|
359
|
-
return this.url =
|
628
|
+
*
|
629
|
+
* @param url string
|
630
|
+
* @param params ISbStoriesParams
|
631
|
+
* @returns Promise<ISbResponse | Error>
|
632
|
+
*/
|
633
|
+
get(t, e) {
|
634
|
+
return this.url = t, this.parameters = e, this._methodHandler("get");
|
360
635
|
}
|
361
|
-
post(
|
362
|
-
return this.url =
|
636
|
+
post(t, e) {
|
637
|
+
return this.url = t, this.parameters = e, this._methodHandler("post");
|
363
638
|
}
|
364
|
-
put(
|
365
|
-
return this.url =
|
639
|
+
put(t, e) {
|
640
|
+
return this.url = t, this.parameters = e, this._methodHandler("put");
|
366
641
|
}
|
367
|
-
delete(
|
368
|
-
return this.url =
|
642
|
+
delete(t, e) {
|
643
|
+
return this.url = t, this.parameters = e ?? {}, this._methodHandler("delete");
|
369
644
|
}
|
370
|
-
async _responseHandler(
|
371
|
-
const
|
645
|
+
async _responseHandler(t) {
|
646
|
+
const e = [], s = {
|
372
647
|
data: {},
|
373
648
|
headers: {},
|
374
649
|
status: 0,
|
375
650
|
statusText: ""
|
376
651
|
};
|
377
|
-
|
378
|
-
|
652
|
+
t.status !== 204 && await t.json().then((r) => {
|
653
|
+
s.data = r;
|
379
654
|
});
|
380
|
-
for (const
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
this.timeout && (c = setTimeout(() => n.abort(), this.timeout));
|
655
|
+
for (const r of t.headers.entries()) e[r[0]] = r[1];
|
656
|
+
return s.headers = { ...e }, s.status = t.status, s.statusText = t.statusText, s;
|
657
|
+
}
|
658
|
+
async _methodHandler(t) {
|
659
|
+
let e = `${this.baseURL}${this.url}`, s = null;
|
660
|
+
t === "get" ? e = `${this.baseURL}${this.url}?${H(this.parameters)}` : s = JSON.stringify(this.parameters);
|
661
|
+
const r = new URL(e), u = new AbortController(), { signal: i } = u;
|
662
|
+
let o;
|
663
|
+
this.timeout && (o = setTimeout(() => u.abort(), this.timeout));
|
390
664
|
try {
|
391
|
-
const
|
392
|
-
method:
|
665
|
+
const n = await this.fetch(`${r}`, {
|
666
|
+
method: t,
|
393
667
|
headers: this.headers,
|
394
|
-
body:
|
395
|
-
signal:
|
668
|
+
body: s,
|
669
|
+
signal: i,
|
396
670
|
...this.fetchOptions
|
397
671
|
});
|
398
|
-
this.timeout && clearTimeout(
|
399
|
-
const
|
400
|
-
|
401
|
-
|
402
|
-
return
|
403
|
-
} catch (a) {
|
404
|
-
return {
|
405
|
-
message: a
|
406
|
-
};
|
672
|
+
this.timeout && clearTimeout(o);
|
673
|
+
const a = await this._responseHandler(n);
|
674
|
+
return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(a)) : this._statusHandler(a);
|
675
|
+
} catch (n) {
|
676
|
+
return { message: n };
|
407
677
|
}
|
408
678
|
}
|
409
|
-
setFetchOptions(
|
410
|
-
Object.keys(
|
679
|
+
setFetchOptions(t = {}) {
|
680
|
+
Object.keys(t).length > 0 && "method" in t && delete t.method, this.fetchOptions = { ...t };
|
411
681
|
}
|
412
682
|
eject() {
|
413
683
|
this.ejectInterceptor = !0;
|
414
684
|
}
|
415
685
|
/**
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
_normalizeErrorMessage(
|
421
|
-
if (Array.isArray(
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
return e
|
426
|
-
|
427
|
-
if (Array.isArray(e[t]))
|
428
|
-
return `${t}: ${e[t][0]}`;
|
429
|
-
if (typeof e[t] == "string")
|
430
|
-
return `${t}: ${e[t]}`;
|
686
|
+
* Normalizes error messages from different response structures
|
687
|
+
* @param data The response data that might contain error information
|
688
|
+
* @returns A normalized error message string
|
689
|
+
*/
|
690
|
+
_normalizeErrorMessage(t) {
|
691
|
+
if (Array.isArray(t)) return t[0] || "Unknown error";
|
692
|
+
if (t && typeof t == "object") {
|
693
|
+
if (t.error) return t.error;
|
694
|
+
for (const e in t) {
|
695
|
+
if (Array.isArray(t[e])) return `${e}: ${t[e][0]}`;
|
696
|
+
if (typeof t[e] == "string") return `${e}: ${t[e]}`;
|
431
697
|
}
|
432
|
-
if (
|
433
|
-
return e.slug;
|
698
|
+
if (t.slug) return t.slug;
|
434
699
|
}
|
435
700
|
return "Unknown error";
|
436
701
|
}
|
437
|
-
_statusHandler(
|
438
|
-
const
|
439
|
-
return new Promise((
|
440
|
-
if (
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
response: e
|
702
|
+
_statusHandler(t) {
|
703
|
+
const e = /20[0-6]/g;
|
704
|
+
return new Promise((s, r) => {
|
705
|
+
if (e.test(`${t.status}`)) return s(t);
|
706
|
+
const u = {
|
707
|
+
message: this._normalizeErrorMessage(t.data),
|
708
|
+
status: t.status,
|
709
|
+
response: t
|
446
710
|
};
|
447
|
-
|
711
|
+
r(u);
|
448
712
|
});
|
449
713
|
}
|
450
|
-
}
|
451
|
-
const
|
714
|
+
}, Mt = Ut;
|
715
|
+
const X = "SB-Agent", $ = {
|
452
716
|
defaultAgentName: "SB-JS-CLIENT",
|
453
717
|
defaultAgentVersion: "SB-Agent-Version",
|
454
718
|
packageVersion: "7.0.0"
|
455
|
-
},
|
719
|
+
}, zt = {
|
456
720
|
PUBLISHED: "published"
|
457
721
|
};
|
458
|
-
let
|
459
|
-
const
|
460
|
-
class
|
722
|
+
let P = {};
|
723
|
+
const B = {};
|
724
|
+
var Gt = class {
|
461
725
|
/**
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
constructor(
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
726
|
+
*
|
727
|
+
* @param config ISbConfig interface
|
728
|
+
* @param pEndpoint string, optional
|
729
|
+
*/
|
730
|
+
constructor(t, e) {
|
731
|
+
E(this, "client");
|
732
|
+
E(this, "maxRetries");
|
733
|
+
E(this, "retriesDelay");
|
734
|
+
E(this, "throttle");
|
735
|
+
E(this, "accessToken");
|
736
|
+
E(this, "cache");
|
737
|
+
E(this, "resolveCounter");
|
738
|
+
E(this, "relations");
|
739
|
+
E(this, "links");
|
740
|
+
E(this, "version");
|
741
|
+
/**
|
742
|
+
* @deprecated This property is deprecated. Use the standalone `richTextResolver` from `@storyblok/richtext` instead.
|
743
|
+
* @see https://github.com/storyblok/richtext
|
744
|
+
*/
|
745
|
+
E(this, "richTextResolver");
|
746
|
+
E(this, "resolveNestedRelations");
|
747
|
+
E(this, "stringifiedStoriesCache");
|
748
|
+
E(this, "inlineAssets");
|
749
|
+
let s = t.endpoint || e;
|
750
|
+
if (!s) {
|
751
|
+
const i = t.https === !1 ? "http" : "https";
|
752
|
+
t.oauthToken ? s = `${i}://${Z(t.region)}/v1` : s = `${i}://${Z(t.region)}/v2`;
|
472
753
|
}
|
473
|
-
const
|
474
|
-
|
475
|
-
|
476
|
-
}),
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
1e3
|
485
|
-
), 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 ve({
|
486
|
-
baseURL: o,
|
487
|
-
timeout: e.timeout || 0,
|
488
|
-
headers: s,
|
489
|
-
responseInterceptor: e.responseInterceptor,
|
490
|
-
fetch: e.fetch
|
754
|
+
const r = new Headers();
|
755
|
+
r.set("Content-Type", "application/json"), r.set("Accept", "application/json"), t.headers && (t.headers.constructor.name === "Headers" ? t.headers.entries().toArray() : Object.entries(t.headers)).forEach(([o, n]) => {
|
756
|
+
r.set(o, n);
|
757
|
+
}), r.has(X) || (r.set(X, $.defaultAgentName), r.set($.defaultAgentVersion, $.packageVersion));
|
758
|
+
let u = 5;
|
759
|
+
t.oauthToken && (r.set("Authorization", t.oauthToken), u = 3), t.rateLimit && (u = t.rateLimit), this.maxRetries = t.maxRetries || 10, this.retriesDelay = 300, this.throttle = Pt(this.throttledRequest.bind(this), u, 1e3), this.accessToken = t.accessToken || "", this.relations = {}, this.links = {}, this.cache = t.cache || { clear: "manual" }, this.resolveCounter = 0, this.resolveNestedRelations = t.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.version = t.version || zt.PUBLISHED, this.inlineAssets = t.inlineAssets || !1, this.client = new Mt({
|
760
|
+
baseURL: s,
|
761
|
+
timeout: t.timeout || 0,
|
762
|
+
headers: r,
|
763
|
+
responseInterceptor: t.responseInterceptor,
|
764
|
+
fetch: t.fetch
|
491
765
|
});
|
492
766
|
}
|
493
|
-
parseParams(
|
494
|
-
return
|
767
|
+
parseParams(t) {
|
768
|
+
return t.token || (t.token = this.getToken()), t.cv || (t.cv = B[t.token]), Array.isArray(t.resolve_relations) && (t.resolve_relations = t.resolve_relations.join(",")), typeof t.resolve_relations < "u" && (t.resolve_level = 2), t;
|
495
769
|
}
|
496
|
-
factoryParamOptions(
|
497
|
-
return
|
770
|
+
factoryParamOptions(t, e) {
|
771
|
+
return W(t) ? this.parseParams(e) : e;
|
498
772
|
}
|
499
|
-
makeRequest(
|
500
|
-
const
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
t.version = t.version || this.version;
|
516
|
-
const a = 1, h = await this.makeRequest(
|
517
|
-
l,
|
518
|
-
t,
|
519
|
-
n,
|
520
|
-
a,
|
521
|
-
s
|
522
|
-
), d = h.total ? Math.ceil(h.total / n) : 1, y = await me(
|
523
|
-
ge(a, d),
|
524
|
-
(T) => this.makeRequest(l, t, n, T + 1, s)
|
525
|
-
);
|
526
|
-
return be([h, ...y], (T) => Object.values(T.data[c]));
|
773
|
+
makeRequest(t, e, s, r, u) {
|
774
|
+
const i = this.factoryParamOptions(t, Ot(e, s, r));
|
775
|
+
return this.cacheResponse(t, i, void 0, u);
|
776
|
+
}
|
777
|
+
get(t, e = {}, s) {
|
778
|
+
e || (e = {});
|
779
|
+
const r = `/${t}`;
|
780
|
+
W(r) && (e.version = e.version || this.version);
|
781
|
+
const u = this.factoryParamOptions(r, e);
|
782
|
+
return this.cacheResponse(r, u, void 0, s);
|
783
|
+
}
|
784
|
+
async getAll(t, e = {}, s, r) {
|
785
|
+
const u = (e == null ? void 0 : e.per_page) || 25, i = `/${t}`.replace(/\/$/, ""), o = s ?? i.substring(i.lastIndexOf("/") + 1);
|
786
|
+
e.version = e.version || this.version;
|
787
|
+
const n = 1, a = await this.makeRequest(i, e, u, n, r), c = a.total ? Math.ceil(a.total / (a.perPage || u)) : 1, h = await jt($t(n, c), (D) => this.makeRequest(i, e, u, D + 1, r));
|
788
|
+
return Ht([a, ...h], (D) => Object.values(D.data[o]));
|
527
789
|
}
|
528
|
-
post(
|
529
|
-
const
|
530
|
-
return this.throttle("post",
|
790
|
+
post(t, e = {}, s) {
|
791
|
+
const r = `/${t}`;
|
792
|
+
return this.throttle("post", r, e, s);
|
531
793
|
}
|
532
|
-
put(
|
533
|
-
const
|
534
|
-
return this.throttle("put",
|
794
|
+
put(t, e = {}, s) {
|
795
|
+
const r = `/${t}`;
|
796
|
+
return this.throttle("put", r, e, s);
|
535
797
|
}
|
536
|
-
delete(
|
537
|
-
|
538
|
-
const
|
539
|
-
return this.throttle("delete",
|
798
|
+
delete(t, e = {}, s) {
|
799
|
+
e || (e = {});
|
800
|
+
const r = `/${t}`;
|
801
|
+
return this.throttle("delete", r, e, s);
|
540
802
|
}
|
541
|
-
getStories(
|
542
|
-
return this._addResolveLevel(
|
803
|
+
getStories(t = {}, e) {
|
804
|
+
return this._addResolveLevel(t), this.get("cdn/stories", t, e);
|
543
805
|
}
|
544
|
-
getStory(
|
545
|
-
return this._addResolveLevel(
|
806
|
+
getStory(t, e = {}, s) {
|
807
|
+
return this._addResolveLevel(e), this.get(`cdn/stories/${t}`, e, s);
|
546
808
|
}
|
547
809
|
getToken() {
|
548
810
|
return this.accessToken;
|
@@ -550,241 +812,227 @@ class we {
|
|
550
812
|
ejectInterceptor() {
|
551
813
|
this.client.eject();
|
552
814
|
}
|
553
|
-
_addResolveLevel(
|
554
|
-
typeof
|
815
|
+
_addResolveLevel(t) {
|
816
|
+
typeof t.resolve_relations < "u" && (t.resolve_level = 2);
|
555
817
|
}
|
556
|
-
_cleanCopy(
|
557
|
-
return JSON.parse(JSON.stringify(
|
818
|
+
_cleanCopy(t) {
|
819
|
+
return JSON.parse(JSON.stringify(t));
|
558
820
|
}
|
559
|
-
_insertLinks(
|
560
|
-
const
|
561
|
-
|
821
|
+
_insertLinks(t, e, s) {
|
822
|
+
const r = t[e];
|
823
|
+
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]));
|
562
824
|
}
|
563
825
|
/**
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
getStoryReference(
|
570
|
-
return this.relations[
|
826
|
+
*
|
827
|
+
* @param resolveId A counter number as a string
|
828
|
+
* @param uuid The uuid of the story
|
829
|
+
* @returns string | object
|
830
|
+
*/
|
831
|
+
getStoryReference(t, e) {
|
832
|
+
return this.relations[t][e] ? JSON.parse(this.stringifiedStoriesCache[e] || JSON.stringify(this.relations[t][e])) : e;
|
571
833
|
}
|
572
834
|
/**
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
_resolveField(
|
583
|
-
const
|
584
|
-
typeof
|
585
|
-
(n) => this.getStoryReference(o, n)
|
586
|
-
).filter(Boolean));
|
835
|
+
* Resolves a field's value by replacing UUIDs with their corresponding story references
|
836
|
+
* @param jtree - The JSON tree object containing the field to resolve
|
837
|
+
* @param treeItem - The key of the field to resolve
|
838
|
+
* @param resolveId - The unique identifier for the current resolution context
|
839
|
+
*
|
840
|
+
* This method handles both single string UUIDs and arrays of UUIDs:
|
841
|
+
* - For single strings: directly replaces the UUID with the story reference
|
842
|
+
* - For arrays: maps through each UUID and replaces with corresponding story references
|
843
|
+
*/
|
844
|
+
_resolveField(t, e, s) {
|
845
|
+
const r = t[e];
|
846
|
+
typeof r == "string" ? t[e] = this.getStoryReference(s, r) : Array.isArray(r) && (t[e] = r.map((u) => this.getStoryReference(s, u)).filter(Boolean));
|
587
847
|
}
|
588
848
|
/**
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
_insertRelations(
|
606
|
-
if (Array.isArray(
|
607
|
-
this._resolveField(
|
849
|
+
* Inserts relations into the JSON tree by resolving references
|
850
|
+
* @param jtree - The JSON tree object to process
|
851
|
+
* @param treeItem - The current field being processed
|
852
|
+
* @param fields - The relation patterns to resolve (string or array of strings)
|
853
|
+
* @param resolveId - The unique identifier for the current resolution context
|
854
|
+
*
|
855
|
+
* This method handles two types of relation patterns:
|
856
|
+
* 1. Nested relations: matches fields that end with the current field name
|
857
|
+
* Example: If treeItem is "event_type", it matches patterns like "*.event_type"
|
858
|
+
*
|
859
|
+
* 2. Direct component relations: matches exact component.field patterns
|
860
|
+
* Example: "event.event_type" for component "event" and field "event_type"
|
861
|
+
*
|
862
|
+
* The method supports both string and array formats for the fields parameter,
|
863
|
+
* allowing flexible specification of relation patterns.
|
864
|
+
*/
|
865
|
+
_insertRelations(t, e, s, r) {
|
866
|
+
if (Array.isArray(s) ? s.find((o) => o.endsWith(`.${e}`)) : s.endsWith(`.${e}`)) {
|
867
|
+
this._resolveField(t, e, r);
|
608
868
|
return;
|
609
869
|
}
|
610
|
-
const
|
611
|
-
(Array.isArray(
|
870
|
+
const i = t.component ? `${t.component}.${e}` : e;
|
871
|
+
(Array.isArray(s) ? s.includes(i) : s === i) && this._resolveField(t, e, r);
|
612
872
|
}
|
613
873
|
/**
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
iterateTree(
|
620
|
-
const
|
621
|
-
if (!(!
|
622
|
-
if (Array.isArray(n))
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
(n.component && n._uid || n.type === "link") && (this._insertRelations(n, c, t, o), this._insertLinks(n, c, o)), s(n[c], a);
|
628
|
-
}
|
874
|
+
* Recursively traverses and resolves relations in the story content tree
|
875
|
+
* @param story - The story object containing the content to process
|
876
|
+
* @param fields - The relation patterns to resolve
|
877
|
+
* @param resolveId - The unique identifier for the current resolution context
|
878
|
+
*/
|
879
|
+
iterateTree(t, e, s) {
|
880
|
+
const r = (u, i = "") => {
|
881
|
+
if (!(!u || u._stopResolving)) {
|
882
|
+
if (Array.isArray(u)) u.forEach((o, n) => r(o, `${i}[${n}]`));
|
883
|
+
else if (typeof u == "object") for (const o in u) {
|
884
|
+
const n = i ? `${i}.${o}` : o;
|
885
|
+
(u.component && u._uid || u.type === "link") && (this._insertRelations(u, o, e, s), this._insertLinks(u, o, s)), r(u[o], n);
|
886
|
+
}
|
629
887
|
}
|
630
888
|
};
|
631
|
-
|
632
|
-
}
|
633
|
-
async resolveLinks(
|
634
|
-
let
|
635
|
-
if (
|
636
|
-
const
|
637
|
-
for (let
|
638
|
-
const
|
639
|
-
|
889
|
+
r(t.content);
|
890
|
+
}
|
891
|
+
async resolveLinks(t, e, s) {
|
892
|
+
let r = [];
|
893
|
+
if (t.link_uuids) {
|
894
|
+
const u = t.link_uuids.length, i = [], o = 50;
|
895
|
+
for (let n = 0; n < u; n += o) {
|
896
|
+
const a = Math.min(u, n + o);
|
897
|
+
i.push(t.link_uuids.slice(n, a));
|
640
898
|
}
|
641
|
-
for (let
|
899
|
+
for (let n = 0; n < i.length; n++)
|
642
900
|
(await this.getStories({
|
643
|
-
per_page:
|
644
|
-
language:
|
645
|
-
version:
|
646
|
-
starts_with:
|
647
|
-
by_uuids:
|
648
|
-
})).data.stories.forEach(
|
649
|
-
(
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
s.forEach((n) => {
|
656
|
-
this.links[o][n.uuid] = {
|
657
|
-
...n,
|
901
|
+
per_page: o,
|
902
|
+
language: e.language,
|
903
|
+
version: e.version,
|
904
|
+
starts_with: e.starts_with,
|
905
|
+
by_uuids: i[n].join(",")
|
906
|
+
})).data.stories.forEach((c) => {
|
907
|
+
r.push(c);
|
908
|
+
});
|
909
|
+
} else r = t.links;
|
910
|
+
r.forEach((u) => {
|
911
|
+
this.links[s][u.uuid] = {
|
912
|
+
...u,
|
658
913
|
_stopResolving: !0
|
659
914
|
};
|
660
915
|
});
|
661
916
|
}
|
662
|
-
async resolveRelations(
|
663
|
-
let
|
664
|
-
if (
|
665
|
-
const
|
666
|
-
for (let
|
667
|
-
const
|
668
|
-
|
917
|
+
async resolveRelations(t, e, s) {
|
918
|
+
let r = [];
|
919
|
+
if (t.rel_uuids) {
|
920
|
+
const u = t.rel_uuids.length, i = [], o = 50;
|
921
|
+
for (let n = 0; n < u; n += o) {
|
922
|
+
const a = Math.min(u, n + o);
|
923
|
+
i.push(t.rel_uuids.slice(n, a));
|
669
924
|
}
|
670
|
-
for (let
|
925
|
+
for (let n = 0; n < i.length; n++)
|
671
926
|
(await this.getStories({
|
672
|
-
per_page:
|
673
|
-
language:
|
674
|
-
version:
|
675
|
-
starts_with:
|
676
|
-
by_uuids:
|
677
|
-
excluding_fields:
|
678
|
-
})).data.stories.forEach((
|
679
|
-
|
927
|
+
per_page: o,
|
928
|
+
language: e.language,
|
929
|
+
version: e.version,
|
930
|
+
starts_with: e.starts_with,
|
931
|
+
by_uuids: i[n].join(","),
|
932
|
+
excluding_fields: e.excluding_fields
|
933
|
+
})).data.stories.forEach((c) => {
|
934
|
+
r.push(c);
|
680
935
|
});
|
681
|
-
|
682
|
-
} else
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
...n,
|
936
|
+
r.length > 0 && (t.rels = r, delete t.rel_uuids);
|
937
|
+
} else r = t.rels;
|
938
|
+
r && r.length > 0 && r.forEach((u) => {
|
939
|
+
this.relations[s][u.uuid] = {
|
940
|
+
...u,
|
687
941
|
_stopResolving: !0
|
688
942
|
};
|
689
943
|
});
|
690
944
|
}
|
691
945
|
/**
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
async resolveStories(
|
701
|
-
var
|
702
|
-
let
|
703
|
-
if (this.links[
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
946
|
+
*
|
947
|
+
* @param responseData
|
948
|
+
* @param params
|
949
|
+
* @param resolveId
|
950
|
+
* @description Resolves the relations and links of the stories
|
951
|
+
* @returns Promise<void>
|
952
|
+
*
|
953
|
+
*/
|
954
|
+
async resolveStories(t, e, s) {
|
955
|
+
var u, i;
|
956
|
+
let r = [];
|
957
|
+
if (this.links[s] = {}, this.relations[s] = {}, typeof e.resolve_relations < "u" && e.resolve_relations.length > 0 && (typeof e.resolve_relations == "string" && (r = e.resolve_relations.split(",")), await this.resolveRelations(t, e, s)), e.resolve_links && [
|
958
|
+
"1",
|
959
|
+
"story",
|
960
|
+
"url",
|
961
|
+
"link"
|
962
|
+
].includes(e.resolve_links) && ((u = t.links) != null && u.length || (i = t.link_uuids) != null && i.length) && await this.resolveLinks(t, e, s), this.resolveNestedRelations) for (const o in this.relations[s]) this.iterateTree(this.relations[s][o], r, s);
|
963
|
+
t.story ? this.iterateTree(t.story, r, s) : t.stories.forEach((o) => {
|
964
|
+
this.iterateTree(o, r, s);
|
965
|
+
}), this.stringifiedStoriesCache = {}, delete this.links[s], delete this.relations[s];
|
966
|
+
}
|
967
|
+
async cacheResponse(t, e, s, r) {
|
968
|
+
const u = H({
|
969
|
+
url: t,
|
970
|
+
params: e
|
971
|
+
}), i = this.cacheProvider();
|
972
|
+
if (e.version === "published" && t !== "/cdn/spaces/me") {
|
973
|
+
const o = await i.get(u);
|
974
|
+
if (o) return Promise.resolve(o);
|
720
975
|
}
|
721
|
-
return new Promise(async (
|
722
|
-
var
|
976
|
+
return new Promise(async (o, n) => {
|
977
|
+
var a;
|
723
978
|
try {
|
724
|
-
const
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
if (
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
})), y.data.story || y.data.stories) {
|
737
|
-
const _ = this.resolveCounter = ++this.resolveCounter % 1e3;
|
738
|
-
await this.resolveStories(y.data, t, `${_}`), y = await this.processInlineAssets(y);
|
979
|
+
const c = await this.throttle("get", t, e, r);
|
980
|
+
if (c.status !== 200) return n(c);
|
981
|
+
let h = {
|
982
|
+
data: c.data,
|
983
|
+
headers: c.headers
|
984
|
+
};
|
985
|
+
if ((a = c.headers) != null && a["per-page"] && (h = Object.assign({}, h, {
|
986
|
+
perPage: c.headers["per-page"] ? Number.parseInt(c.headers["per-page"]) : 0,
|
987
|
+
total: c.headers["per-page"] ? Number.parseInt(c.headers.total) : 0
|
988
|
+
})), h.data.story || h.data.stories) {
|
989
|
+
const g = this.resolveCounter = ++this.resolveCounter % 1e3;
|
990
|
+
await this.resolveStories(h.data, e, `${g}`), h = await this.processInlineAssets(h);
|
739
991
|
}
|
740
|
-
|
741
|
-
const
|
742
|
-
return
|
743
|
-
} catch (
|
744
|
-
if (
|
745
|
-
return console.log(
|
746
|
-
|
747
|
-
), await fe(this.retriesDelay), this.cacheResponse(e, t, o).then(c).catch(a);
|
748
|
-
a(d);
|
992
|
+
e.version === "published" && t !== "/cdn/spaces/me" && await i.set(u, h);
|
993
|
+
const D = this.cache.clear === "onpreview" && e.version === "draft" || this.cache.clear === "auto";
|
994
|
+
return e.token && h.data.cv && (D && B[e.token] && B[e.token] !== h.data.cv && await this.flushCache(), B[e.token] = h.data.cv), o(h);
|
995
|
+
} catch (c) {
|
996
|
+
if (c.response && c.status === 429 && (s = typeof s > "u" ? 0 : s + 1, s < this.maxRetries))
|
997
|
+
return console.log(`Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`), await It(this.retriesDelay), this.cacheResponse(t, e, s).then(o).catch(n);
|
998
|
+
n(c);
|
749
999
|
}
|
750
1000
|
});
|
751
1001
|
}
|
752
|
-
throttledRequest(
|
753
|
-
return this.client.setFetchOptions(
|
1002
|
+
throttledRequest(t, e, s, r) {
|
1003
|
+
return this.client.setFetchOptions(r), this.client[t](e, s);
|
754
1004
|
}
|
755
1005
|
cacheVersions() {
|
756
|
-
return
|
1006
|
+
return B;
|
757
1007
|
}
|
758
1008
|
cacheVersion() {
|
759
|
-
return
|
1009
|
+
return B[this.accessToken];
|
760
1010
|
}
|
761
|
-
setCacheVersion(
|
762
|
-
this.accessToken && (
|
1011
|
+
setCacheVersion(t) {
|
1012
|
+
this.accessToken && (B[this.accessToken] = t);
|
763
1013
|
}
|
764
1014
|
clearCacheVersion() {
|
765
|
-
this.accessToken && (
|
1015
|
+
this.accessToken && (B[this.accessToken] = 0);
|
766
1016
|
}
|
767
1017
|
cacheProvider() {
|
768
1018
|
switch (this.cache.type) {
|
769
1019
|
case "memory":
|
770
1020
|
return {
|
771
|
-
get(
|
772
|
-
return Promise.resolve(
|
1021
|
+
get(t) {
|
1022
|
+
return Promise.resolve(P[t]);
|
773
1023
|
},
|
774
1024
|
getAll() {
|
775
|
-
return Promise.resolve(
|
1025
|
+
return Promise.resolve(P);
|
776
1026
|
},
|
777
|
-
set(
|
778
|
-
return
|
1027
|
+
set(t, e) {
|
1028
|
+
return P[t] = e, Promise.resolve(void 0);
|
779
1029
|
},
|
780
1030
|
flush() {
|
781
|
-
return
|
1031
|
+
return P = {}, Promise.resolve(void 0);
|
782
1032
|
}
|
783
1033
|
};
|
784
1034
|
case "custom":
|
785
|
-
if (this.cache.custom)
|
786
|
-
return this.cache.custom;
|
787
|
-
// eslint-disable-next-line no-fallthrough
|
1035
|
+
if (this.cache.custom) return this.cache.custom;
|
788
1036
|
default:
|
789
1037
|
return {
|
790
1038
|
get() {
|
@@ -805,41 +1053,37 @@ class we {
|
|
805
1053
|
async flushCache() {
|
806
1054
|
return await this.cacheProvider().flush(), this.clearCacheVersion(), this;
|
807
1055
|
}
|
808
|
-
async processInlineAssets(
|
809
|
-
if (!this.inlineAssets)
|
810
|
-
|
811
|
-
|
812
|
-
if (
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
s.fieldtype === "asset" && Array.isArray(e.data.assets) && (s = {
|
818
|
-
...s,
|
819
|
-
...e.data.assets.find((n) => n.id === s.id)
|
1056
|
+
async processInlineAssets(t) {
|
1057
|
+
if (!this.inlineAssets) return t;
|
1058
|
+
const e = (s) => {
|
1059
|
+
if (!s || typeof s != "object") return s;
|
1060
|
+
if (Array.isArray(s)) return s.map((u) => e(u));
|
1061
|
+
let r = { ...s };
|
1062
|
+
r.fieldtype === "asset" && Array.isArray(t.data.assets) && (r = {
|
1063
|
+
...r,
|
1064
|
+
...t.data.assets.find((u) => u.id === r.id)
|
820
1065
|
});
|
821
|
-
for (const
|
822
|
-
|
823
|
-
return s;
|
1066
|
+
for (const u in r) typeof r[u] == "object" && (r[u] = e(r[u]));
|
1067
|
+
return r;
|
824
1068
|
};
|
825
|
-
return
|
1069
|
+
return t.data.story && (t.data.story.content = e(t.data.story.content)), t.data.stories && (t.data.stories = t.data.stories.map((s) => (s.content = e(s.content), s))), t;
|
826
1070
|
}
|
827
|
-
}
|
828
|
-
const
|
829
|
-
const { apiOptions: e } =
|
1071
|
+
}, qt = Gt;
|
1072
|
+
const Vt = (t = {}) => {
|
1073
|
+
const { apiOptions: e } = t;
|
830
1074
|
if (!e || !e.accessToken) {
|
831
1075
|
console.error(
|
832
1076
|
"You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication"
|
833
1077
|
);
|
834
1078
|
return;
|
835
1079
|
}
|
836
|
-
return { storyblokApi: new
|
837
|
-
},
|
838
|
-
if (typeof
|
1080
|
+
return { storyblokApi: new qt(e) };
|
1081
|
+
}, Kt = (t) => {
|
1082
|
+
if (typeof t != "object" || typeof t._editable > "u")
|
839
1083
|
return {};
|
840
1084
|
try {
|
841
1085
|
const e = JSON.parse(
|
842
|
-
|
1086
|
+
t._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
|
843
1087
|
);
|
844
1088
|
return e ? {
|
845
1089
|
"data-blok-c": JSON.stringify(e),
|
@@ -849,56 +1093,56 @@ const Te = (r = {}) => {
|
|
849
1093
|
return {};
|
850
1094
|
}
|
851
1095
|
};
|
852
|
-
let
|
853
|
-
const
|
854
|
-
var
|
855
|
-
const
|
1096
|
+
let j = "https://app.storyblok.com/f/storyblok-v2-latest.js";
|
1097
|
+
const Yt = (t, e, s = {}) => {
|
1098
|
+
var n;
|
1099
|
+
const u = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", i = new URL((n = window.location) == null ? void 0 : n.href).searchParams.get(
|
856
1100
|
"_storyblok"
|
857
|
-
),
|
858
|
-
if (!(!
|
859
|
-
if (!
|
1101
|
+
), o = i !== null && +i === t;
|
1102
|
+
if (!(!u || !o)) {
|
1103
|
+
if (!t) {
|
860
1104
|
console.warn("Story ID is not defined. Please provide a valid ID.");
|
861
1105
|
return;
|
862
1106
|
}
|
863
1107
|
window.storyblokRegisterEvent(() => {
|
864
|
-
new window.StoryblokBridge(
|
865
|
-
var
|
866
|
-
|
1108
|
+
new window.StoryblokBridge(s).on(["input", "published", "change"], (c) => {
|
1109
|
+
var h;
|
1110
|
+
c && (c.action === "input" && ((h = c.story) == null ? void 0 : h.id) === t ? e(c.story) : (c.action === "change" || c.action === "published") && c.storyId === t && window.location.reload());
|
867
1111
|
});
|
868
1112
|
});
|
869
1113
|
}
|
870
|
-
},
|
871
|
-
var
|
1114
|
+
}, Wt = (t = {}) => {
|
1115
|
+
var h, D;
|
872
1116
|
const {
|
873
1117
|
bridge: e,
|
874
|
-
accessToken:
|
875
|
-
use:
|
876
|
-
apiOptions:
|
877
|
-
bridgeUrl:
|
878
|
-
} =
|
879
|
-
|
880
|
-
const
|
881
|
-
let
|
882
|
-
|
883
|
-
|
884
|
-
}),
|
885
|
-
const
|
886
|
-
return e !== !1 &&
|
1118
|
+
accessToken: s,
|
1119
|
+
use: r = [],
|
1120
|
+
apiOptions: u = {},
|
1121
|
+
bridgeUrl: i
|
1122
|
+
} = t;
|
1123
|
+
u.accessToken = u.accessToken || s;
|
1124
|
+
const o = { bridge: e, apiOptions: u };
|
1125
|
+
let n = {};
|
1126
|
+
r.forEach((g) => {
|
1127
|
+
n = { ...n, ...g(o) };
|
1128
|
+
}), i && (j = i);
|
1129
|
+
const c = !(typeof window > "u") && ((D = (h = window.location) == null ? void 0 : h.search) == null ? void 0 : D.includes("_storyblok_tk"));
|
1130
|
+
return e !== !1 && c && tt(j), n;
|
887
1131
|
};
|
888
|
-
function
|
889
|
-
return
|
1132
|
+
function Zt(t, e) {
|
1133
|
+
return St(e).render(t);
|
890
1134
|
}
|
891
|
-
const
|
1135
|
+
const Xt = () => tt(j);
|
892
1136
|
export {
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
1137
|
+
b as BlockTypes,
|
1138
|
+
v as MarkTypes,
|
1139
|
+
vt as TextTypes,
|
1140
|
+
Vt as apiPlugin,
|
1141
|
+
Xt as loadStoryblokBridge,
|
1142
|
+
Yt as registerStoryblokBridge,
|
1143
|
+
Zt as renderRichText,
|
1144
|
+
St as richTextResolver,
|
1145
|
+
Kt as storyblokEditable,
|
1146
|
+
Wt as storyblokInit,
|
1147
|
+
Yt as useStoryblokBridge
|
904
1148
|
};
|