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