@storyblok/js 1.0.2 → 1.0.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/dist/storyblok-js.js +2 -3
- package/dist/storyblok-js.mjs +162 -1250
- package/package.json +1 -1
package/dist/storyblok-js.mjs
CHANGED
|
@@ -17,6 +17,7 @@ var __spreadValues = (a2, b) => {
|
|
|
17
17
|
return a2;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a2, b) => __defProps(a2, __getOwnPropDescs(b));
|
|
20
|
+
import t from "axios";
|
|
20
21
|
let loaded = false;
|
|
21
22
|
const callbacks = [];
|
|
22
23
|
const loadBridge = (src) => {
|
|
@@ -48,1104 +49,15 @@ const loadBridge = (src) => {
|
|
|
48
49
|
document.getElementsByTagName("head")[0].appendChild(script);
|
|
49
50
|
});
|
|
50
51
|
};
|
|
51
|
-
var axios$2 = { exports: {} };
|
|
52
|
-
var bind$2 = function bind(fn, thisArg) {
|
|
53
|
-
return function wrap() {
|
|
54
|
-
var args = new Array(arguments.length);
|
|
55
|
-
for (var i2 = 0; i2 < args.length; i2++) {
|
|
56
|
-
args[i2] = arguments[i2];
|
|
57
|
-
}
|
|
58
|
-
return fn.apply(thisArg, args);
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
var bind$1 = bind$2;
|
|
62
|
-
var toString = Object.prototype.toString;
|
|
63
|
-
function isArray(val) {
|
|
64
|
-
return toString.call(val) === "[object Array]";
|
|
65
|
-
}
|
|
66
|
-
function isUndefined(val) {
|
|
67
|
-
return typeof val === "undefined";
|
|
68
|
-
}
|
|
69
|
-
function isBuffer(val) {
|
|
70
|
-
return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && typeof val.constructor.isBuffer === "function" && val.constructor.isBuffer(val);
|
|
71
|
-
}
|
|
72
|
-
function isArrayBuffer(val) {
|
|
73
|
-
return toString.call(val) === "[object ArrayBuffer]";
|
|
74
|
-
}
|
|
75
|
-
function isFormData(val) {
|
|
76
|
-
return typeof FormData !== "undefined" && val instanceof FormData;
|
|
77
|
-
}
|
|
78
|
-
function isArrayBufferView(val) {
|
|
79
|
-
var result;
|
|
80
|
-
if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
|
|
81
|
-
result = ArrayBuffer.isView(val);
|
|
82
|
-
} else {
|
|
83
|
-
result = val && val.buffer && val.buffer instanceof ArrayBuffer;
|
|
84
|
-
}
|
|
85
|
-
return result;
|
|
86
|
-
}
|
|
87
|
-
function isString(val) {
|
|
88
|
-
return typeof val === "string";
|
|
89
|
-
}
|
|
90
|
-
function isNumber(val) {
|
|
91
|
-
return typeof val === "number";
|
|
92
|
-
}
|
|
93
|
-
function isObject(val) {
|
|
94
|
-
return val !== null && typeof val === "object";
|
|
95
|
-
}
|
|
96
|
-
function isPlainObject(val) {
|
|
97
|
-
if (toString.call(val) !== "[object Object]") {
|
|
98
|
-
return false;
|
|
99
|
-
}
|
|
100
|
-
var prototype = Object.getPrototypeOf(val);
|
|
101
|
-
return prototype === null || prototype === Object.prototype;
|
|
102
|
-
}
|
|
103
|
-
function isDate(val) {
|
|
104
|
-
return toString.call(val) === "[object Date]";
|
|
105
|
-
}
|
|
106
|
-
function isFile(val) {
|
|
107
|
-
return toString.call(val) === "[object File]";
|
|
108
|
-
}
|
|
109
|
-
function isBlob(val) {
|
|
110
|
-
return toString.call(val) === "[object Blob]";
|
|
111
|
-
}
|
|
112
|
-
function isFunction(val) {
|
|
113
|
-
return toString.call(val) === "[object Function]";
|
|
114
|
-
}
|
|
115
|
-
function isStream(val) {
|
|
116
|
-
return isObject(val) && isFunction(val.pipe);
|
|
117
|
-
}
|
|
118
|
-
function isURLSearchParams(val) {
|
|
119
|
-
return typeof URLSearchParams !== "undefined" && val instanceof URLSearchParams;
|
|
120
|
-
}
|
|
121
|
-
function trim(str) {
|
|
122
|
-
return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, "");
|
|
123
|
-
}
|
|
124
|
-
function isStandardBrowserEnv() {
|
|
125
|
-
if (typeof navigator !== "undefined" && (navigator.product === "ReactNative" || navigator.product === "NativeScript" || navigator.product === "NS")) {
|
|
126
|
-
return false;
|
|
127
|
-
}
|
|
128
|
-
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
129
|
-
}
|
|
130
|
-
function forEach(obj, fn) {
|
|
131
|
-
if (obj === null || typeof obj === "undefined") {
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
if (typeof obj !== "object") {
|
|
135
|
-
obj = [obj];
|
|
136
|
-
}
|
|
137
|
-
if (isArray(obj)) {
|
|
138
|
-
for (var i2 = 0, l2 = obj.length; i2 < l2; i2++) {
|
|
139
|
-
fn.call(null, obj[i2], i2, obj);
|
|
140
|
-
}
|
|
141
|
-
} else {
|
|
142
|
-
for (var key in obj) {
|
|
143
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
144
|
-
fn.call(null, obj[key], key, obj);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
function merge() {
|
|
150
|
-
var result = {};
|
|
151
|
-
function assignValue(val, key) {
|
|
152
|
-
if (isPlainObject(result[key]) && isPlainObject(val)) {
|
|
153
|
-
result[key] = merge(result[key], val);
|
|
154
|
-
} else if (isPlainObject(val)) {
|
|
155
|
-
result[key] = merge({}, val);
|
|
156
|
-
} else if (isArray(val)) {
|
|
157
|
-
result[key] = val.slice();
|
|
158
|
-
} else {
|
|
159
|
-
result[key] = val;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
for (var i2 = 0, l2 = arguments.length; i2 < l2; i2++) {
|
|
163
|
-
forEach(arguments[i2], assignValue);
|
|
164
|
-
}
|
|
165
|
-
return result;
|
|
166
|
-
}
|
|
167
|
-
function extend(a2, b, thisArg) {
|
|
168
|
-
forEach(b, function assignValue(val, key) {
|
|
169
|
-
if (thisArg && typeof val === "function") {
|
|
170
|
-
a2[key] = bind$1(val, thisArg);
|
|
171
|
-
} else {
|
|
172
|
-
a2[key] = val;
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
return a2;
|
|
176
|
-
}
|
|
177
|
-
function stripBOM(content) {
|
|
178
|
-
if (content.charCodeAt(0) === 65279) {
|
|
179
|
-
content = content.slice(1);
|
|
180
|
-
}
|
|
181
|
-
return content;
|
|
182
|
-
}
|
|
183
|
-
var utils$d = {
|
|
184
|
-
isArray,
|
|
185
|
-
isArrayBuffer,
|
|
186
|
-
isBuffer,
|
|
187
|
-
isFormData,
|
|
188
|
-
isArrayBufferView,
|
|
189
|
-
isString,
|
|
190
|
-
isNumber,
|
|
191
|
-
isObject,
|
|
192
|
-
isPlainObject,
|
|
193
|
-
isUndefined,
|
|
194
|
-
isDate,
|
|
195
|
-
isFile,
|
|
196
|
-
isBlob,
|
|
197
|
-
isFunction,
|
|
198
|
-
isStream,
|
|
199
|
-
isURLSearchParams,
|
|
200
|
-
isStandardBrowserEnv,
|
|
201
|
-
forEach,
|
|
202
|
-
merge,
|
|
203
|
-
extend,
|
|
204
|
-
trim,
|
|
205
|
-
stripBOM
|
|
206
|
-
};
|
|
207
|
-
var utils$c = utils$d;
|
|
208
|
-
function encode(val) {
|
|
209
|
-
return encodeURIComponent(val).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]");
|
|
210
|
-
}
|
|
211
|
-
var buildURL$2 = function buildURL(url, params, paramsSerializer) {
|
|
212
|
-
if (!params) {
|
|
213
|
-
return url;
|
|
214
|
-
}
|
|
215
|
-
var serializedParams;
|
|
216
|
-
if (paramsSerializer) {
|
|
217
|
-
serializedParams = paramsSerializer(params);
|
|
218
|
-
} else if (utils$c.isURLSearchParams(params)) {
|
|
219
|
-
serializedParams = params.toString();
|
|
220
|
-
} else {
|
|
221
|
-
var parts = [];
|
|
222
|
-
utils$c.forEach(params, function serialize(val, key) {
|
|
223
|
-
if (val === null || typeof val === "undefined") {
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
if (utils$c.isArray(val)) {
|
|
227
|
-
key = key + "[]";
|
|
228
|
-
} else {
|
|
229
|
-
val = [val];
|
|
230
|
-
}
|
|
231
|
-
utils$c.forEach(val, function parseValue(v) {
|
|
232
|
-
if (utils$c.isDate(v)) {
|
|
233
|
-
v = v.toISOString();
|
|
234
|
-
} else if (utils$c.isObject(v)) {
|
|
235
|
-
v = JSON.stringify(v);
|
|
236
|
-
}
|
|
237
|
-
parts.push(encode(key) + "=" + encode(v));
|
|
238
|
-
});
|
|
239
|
-
});
|
|
240
|
-
serializedParams = parts.join("&");
|
|
241
|
-
}
|
|
242
|
-
if (serializedParams) {
|
|
243
|
-
var hashmarkIndex = url.indexOf("#");
|
|
244
|
-
if (hashmarkIndex !== -1) {
|
|
245
|
-
url = url.slice(0, hashmarkIndex);
|
|
246
|
-
}
|
|
247
|
-
url += (url.indexOf("?") === -1 ? "?" : "&") + serializedParams;
|
|
248
|
-
}
|
|
249
|
-
return url;
|
|
250
|
-
};
|
|
251
|
-
var utils$b = utils$d;
|
|
252
|
-
function InterceptorManager$1() {
|
|
253
|
-
this.handlers = [];
|
|
254
|
-
}
|
|
255
|
-
InterceptorManager$1.prototype.use = function use(fulfilled, rejected, options) {
|
|
256
|
-
this.handlers.push({
|
|
257
|
-
fulfilled,
|
|
258
|
-
rejected,
|
|
259
|
-
synchronous: options ? options.synchronous : false,
|
|
260
|
-
runWhen: options ? options.runWhen : null
|
|
261
|
-
});
|
|
262
|
-
return this.handlers.length - 1;
|
|
263
|
-
};
|
|
264
|
-
InterceptorManager$1.prototype.eject = function eject(id) {
|
|
265
|
-
if (this.handlers[id]) {
|
|
266
|
-
this.handlers[id] = null;
|
|
267
|
-
}
|
|
268
|
-
};
|
|
269
|
-
InterceptorManager$1.prototype.forEach = function forEach2(fn) {
|
|
270
|
-
utils$b.forEach(this.handlers, function forEachHandler(h) {
|
|
271
|
-
if (h !== null) {
|
|
272
|
-
fn(h);
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
};
|
|
276
|
-
var InterceptorManager_1 = InterceptorManager$1;
|
|
277
|
-
var utils$a = utils$d;
|
|
278
|
-
var normalizeHeaderName$1 = function normalizeHeaderName(headers, normalizedName) {
|
|
279
|
-
utils$a.forEach(headers, function processHeader(value, name2) {
|
|
280
|
-
if (name2 !== normalizedName && name2.toUpperCase() === normalizedName.toUpperCase()) {
|
|
281
|
-
headers[normalizedName] = value;
|
|
282
|
-
delete headers[name2];
|
|
283
|
-
}
|
|
284
|
-
});
|
|
285
|
-
};
|
|
286
|
-
var enhanceError$2 = function enhanceError(error, config, code, request2, response) {
|
|
287
|
-
error.config = config;
|
|
288
|
-
if (code) {
|
|
289
|
-
error.code = code;
|
|
290
|
-
}
|
|
291
|
-
error.request = request2;
|
|
292
|
-
error.response = response;
|
|
293
|
-
error.isAxiosError = true;
|
|
294
|
-
error.toJSON = function toJSON() {
|
|
295
|
-
return {
|
|
296
|
-
message: this.message,
|
|
297
|
-
name: this.name,
|
|
298
|
-
description: this.description,
|
|
299
|
-
number: this.number,
|
|
300
|
-
fileName: this.fileName,
|
|
301
|
-
lineNumber: this.lineNumber,
|
|
302
|
-
columnNumber: this.columnNumber,
|
|
303
|
-
stack: this.stack,
|
|
304
|
-
config: this.config,
|
|
305
|
-
code: this.code
|
|
306
|
-
};
|
|
307
|
-
};
|
|
308
|
-
return error;
|
|
309
|
-
};
|
|
310
|
-
var enhanceError$1 = enhanceError$2;
|
|
311
|
-
var createError$2 = function createError(message, config, code, request2, response) {
|
|
312
|
-
var error = new Error(message);
|
|
313
|
-
return enhanceError$1(error, config, code, request2, response);
|
|
314
|
-
};
|
|
315
|
-
var createError$1 = createError$2;
|
|
316
|
-
var settle$1 = function settle(resolve, reject, response) {
|
|
317
|
-
var validateStatus2 = response.config.validateStatus;
|
|
318
|
-
if (!response.status || !validateStatus2 || validateStatus2(response.status)) {
|
|
319
|
-
resolve(response);
|
|
320
|
-
} else {
|
|
321
|
-
reject(createError$1("Request failed with status code " + response.status, response.config, null, response.request, response));
|
|
322
|
-
}
|
|
323
|
-
};
|
|
324
|
-
var utils$9 = utils$d;
|
|
325
|
-
var cookies$1 = utils$9.isStandardBrowserEnv() ? function standardBrowserEnv() {
|
|
326
|
-
return {
|
|
327
|
-
write: function write(name2, value, expires, path, domain, secure) {
|
|
328
|
-
var cookie = [];
|
|
329
|
-
cookie.push(name2 + "=" + encodeURIComponent(value));
|
|
330
|
-
if (utils$9.isNumber(expires)) {
|
|
331
|
-
cookie.push("expires=" + new Date(expires).toGMTString());
|
|
332
|
-
}
|
|
333
|
-
if (utils$9.isString(path)) {
|
|
334
|
-
cookie.push("path=" + path);
|
|
335
|
-
}
|
|
336
|
-
if (utils$9.isString(domain)) {
|
|
337
|
-
cookie.push("domain=" + domain);
|
|
338
|
-
}
|
|
339
|
-
if (secure === true) {
|
|
340
|
-
cookie.push("secure");
|
|
341
|
-
}
|
|
342
|
-
document.cookie = cookie.join("; ");
|
|
343
|
-
},
|
|
344
|
-
read: function read(name2) {
|
|
345
|
-
var match = document.cookie.match(new RegExp("(^|;\\s*)(" + name2 + ")=([^;]*)"));
|
|
346
|
-
return match ? decodeURIComponent(match[3]) : null;
|
|
347
|
-
},
|
|
348
|
-
remove: function remove(name2) {
|
|
349
|
-
this.write(name2, "", Date.now() - 864e5);
|
|
350
|
-
}
|
|
351
|
-
};
|
|
352
|
-
}() : function nonStandardBrowserEnv() {
|
|
353
|
-
return {
|
|
354
|
-
write: function write() {
|
|
355
|
-
},
|
|
356
|
-
read: function read() {
|
|
357
|
-
return null;
|
|
358
|
-
},
|
|
359
|
-
remove: function remove() {
|
|
360
|
-
}
|
|
361
|
-
};
|
|
362
|
-
}();
|
|
363
|
-
var isAbsoluteURL$1 = function isAbsoluteURL(url) {
|
|
364
|
-
return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
|
|
365
|
-
};
|
|
366
|
-
var combineURLs$1 = function combineURLs(baseURL, relativeURL) {
|
|
367
|
-
return relativeURL ? baseURL.replace(/\/+$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
|
|
368
|
-
};
|
|
369
|
-
var isAbsoluteURL2 = isAbsoluteURL$1;
|
|
370
|
-
var combineURLs2 = combineURLs$1;
|
|
371
|
-
var buildFullPath$1 = function buildFullPath(baseURL, requestedURL) {
|
|
372
|
-
if (baseURL && !isAbsoluteURL2(requestedURL)) {
|
|
373
|
-
return combineURLs2(baseURL, requestedURL);
|
|
374
|
-
}
|
|
375
|
-
return requestedURL;
|
|
376
|
-
};
|
|
377
|
-
var utils$8 = utils$d;
|
|
378
|
-
var ignoreDuplicateOf = [
|
|
379
|
-
"age",
|
|
380
|
-
"authorization",
|
|
381
|
-
"content-length",
|
|
382
|
-
"content-type",
|
|
383
|
-
"etag",
|
|
384
|
-
"expires",
|
|
385
|
-
"from",
|
|
386
|
-
"host",
|
|
387
|
-
"if-modified-since",
|
|
388
|
-
"if-unmodified-since",
|
|
389
|
-
"last-modified",
|
|
390
|
-
"location",
|
|
391
|
-
"max-forwards",
|
|
392
|
-
"proxy-authorization",
|
|
393
|
-
"referer",
|
|
394
|
-
"retry-after",
|
|
395
|
-
"user-agent"
|
|
396
|
-
];
|
|
397
|
-
var parseHeaders$1 = function parseHeaders(headers) {
|
|
398
|
-
var parsed = {};
|
|
399
|
-
var key;
|
|
400
|
-
var val;
|
|
401
|
-
var i2;
|
|
402
|
-
if (!headers) {
|
|
403
|
-
return parsed;
|
|
404
|
-
}
|
|
405
|
-
utils$8.forEach(headers.split("\n"), function parser(line) {
|
|
406
|
-
i2 = line.indexOf(":");
|
|
407
|
-
key = utils$8.trim(line.substr(0, i2)).toLowerCase();
|
|
408
|
-
val = utils$8.trim(line.substr(i2 + 1));
|
|
409
|
-
if (key) {
|
|
410
|
-
if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
|
|
411
|
-
return;
|
|
412
|
-
}
|
|
413
|
-
if (key === "set-cookie") {
|
|
414
|
-
parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
|
|
415
|
-
} else {
|
|
416
|
-
parsed[key] = parsed[key] ? parsed[key] + ", " + val : val;
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
});
|
|
420
|
-
return parsed;
|
|
421
|
-
};
|
|
422
|
-
var utils$7 = utils$d;
|
|
423
|
-
var isURLSameOrigin$1 = utils$7.isStandardBrowserEnv() ? function standardBrowserEnv2() {
|
|
424
|
-
var msie = /(msie|trident)/i.test(navigator.userAgent);
|
|
425
|
-
var urlParsingNode = document.createElement("a");
|
|
426
|
-
var originURL;
|
|
427
|
-
function resolveURL(url) {
|
|
428
|
-
var href = url;
|
|
429
|
-
if (msie) {
|
|
430
|
-
urlParsingNode.setAttribute("href", href);
|
|
431
|
-
href = urlParsingNode.href;
|
|
432
|
-
}
|
|
433
|
-
urlParsingNode.setAttribute("href", href);
|
|
434
|
-
return {
|
|
435
|
-
href: urlParsingNode.href,
|
|
436
|
-
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, "") : "",
|
|
437
|
-
host: urlParsingNode.host,
|
|
438
|
-
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, "") : "",
|
|
439
|
-
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, "") : "",
|
|
440
|
-
hostname: urlParsingNode.hostname,
|
|
441
|
-
port: urlParsingNode.port,
|
|
442
|
-
pathname: urlParsingNode.pathname.charAt(0) === "/" ? urlParsingNode.pathname : "/" + urlParsingNode.pathname
|
|
443
|
-
};
|
|
444
|
-
}
|
|
445
|
-
originURL = resolveURL(window.location.href);
|
|
446
|
-
return function isURLSameOrigin2(requestURL) {
|
|
447
|
-
var parsed = utils$7.isString(requestURL) ? resolveURL(requestURL) : requestURL;
|
|
448
|
-
return parsed.protocol === originURL.protocol && parsed.host === originURL.host;
|
|
449
|
-
};
|
|
450
|
-
}() : function nonStandardBrowserEnv2() {
|
|
451
|
-
return function isURLSameOrigin2() {
|
|
452
|
-
return true;
|
|
453
|
-
};
|
|
454
|
-
}();
|
|
455
|
-
var utils$6 = utils$d;
|
|
456
|
-
var settle2 = settle$1;
|
|
457
|
-
var cookies = cookies$1;
|
|
458
|
-
var buildURL$1 = buildURL$2;
|
|
459
|
-
var buildFullPath2 = buildFullPath$1;
|
|
460
|
-
var parseHeaders2 = parseHeaders$1;
|
|
461
|
-
var isURLSameOrigin = isURLSameOrigin$1;
|
|
462
|
-
var createError2 = createError$2;
|
|
463
|
-
var xhr = function xhrAdapter(config) {
|
|
464
|
-
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
|
465
|
-
var requestData = config.data;
|
|
466
|
-
var requestHeaders = config.headers;
|
|
467
|
-
var responseType = config.responseType;
|
|
468
|
-
if (utils$6.isFormData(requestData)) {
|
|
469
|
-
delete requestHeaders["Content-Type"];
|
|
470
|
-
}
|
|
471
|
-
var request2 = new XMLHttpRequest();
|
|
472
|
-
if (config.auth) {
|
|
473
|
-
var username = config.auth.username || "";
|
|
474
|
-
var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : "";
|
|
475
|
-
requestHeaders.Authorization = "Basic " + btoa(username + ":" + password);
|
|
476
|
-
}
|
|
477
|
-
var fullPath = buildFullPath2(config.baseURL, config.url);
|
|
478
|
-
request2.open(config.method.toUpperCase(), buildURL$1(fullPath, config.params, config.paramsSerializer), true);
|
|
479
|
-
request2.timeout = config.timeout;
|
|
480
|
-
function onloadend() {
|
|
481
|
-
if (!request2) {
|
|
482
|
-
return;
|
|
483
|
-
}
|
|
484
|
-
var responseHeaders = "getAllResponseHeaders" in request2 ? parseHeaders2(request2.getAllResponseHeaders()) : null;
|
|
485
|
-
var responseData = !responseType || responseType === "text" || responseType === "json" ? request2.responseText : request2.response;
|
|
486
|
-
var response = {
|
|
487
|
-
data: responseData,
|
|
488
|
-
status: request2.status,
|
|
489
|
-
statusText: request2.statusText,
|
|
490
|
-
headers: responseHeaders,
|
|
491
|
-
config,
|
|
492
|
-
request: request2
|
|
493
|
-
};
|
|
494
|
-
settle2(resolve, reject, response);
|
|
495
|
-
request2 = null;
|
|
496
|
-
}
|
|
497
|
-
if ("onloadend" in request2) {
|
|
498
|
-
request2.onloadend = onloadend;
|
|
499
|
-
} else {
|
|
500
|
-
request2.onreadystatechange = function handleLoad() {
|
|
501
|
-
if (!request2 || request2.readyState !== 4) {
|
|
502
|
-
return;
|
|
503
|
-
}
|
|
504
|
-
if (request2.status === 0 && !(request2.responseURL && request2.responseURL.indexOf("file:") === 0)) {
|
|
505
|
-
return;
|
|
506
|
-
}
|
|
507
|
-
setTimeout(onloadend);
|
|
508
|
-
};
|
|
509
|
-
}
|
|
510
|
-
request2.onabort = function handleAbort() {
|
|
511
|
-
if (!request2) {
|
|
512
|
-
return;
|
|
513
|
-
}
|
|
514
|
-
reject(createError2("Request aborted", config, "ECONNABORTED", request2));
|
|
515
|
-
request2 = null;
|
|
516
|
-
};
|
|
517
|
-
request2.onerror = function handleError() {
|
|
518
|
-
reject(createError2("Network Error", config, null, request2));
|
|
519
|
-
request2 = null;
|
|
520
|
-
};
|
|
521
|
-
request2.ontimeout = function handleTimeout() {
|
|
522
|
-
var timeoutErrorMessage = "timeout of " + config.timeout + "ms exceeded";
|
|
523
|
-
if (config.timeoutErrorMessage) {
|
|
524
|
-
timeoutErrorMessage = config.timeoutErrorMessage;
|
|
525
|
-
}
|
|
526
|
-
reject(createError2(timeoutErrorMessage, config, config.transitional && config.transitional.clarifyTimeoutError ? "ETIMEDOUT" : "ECONNABORTED", request2));
|
|
527
|
-
request2 = null;
|
|
528
|
-
};
|
|
529
|
-
if (utils$6.isStandardBrowserEnv()) {
|
|
530
|
-
var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ? cookies.read(config.xsrfCookieName) : void 0;
|
|
531
|
-
if (xsrfValue) {
|
|
532
|
-
requestHeaders[config.xsrfHeaderName] = xsrfValue;
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
if ("setRequestHeader" in request2) {
|
|
536
|
-
utils$6.forEach(requestHeaders, function setRequestHeader(val, key) {
|
|
537
|
-
if (typeof requestData === "undefined" && key.toLowerCase() === "content-type") {
|
|
538
|
-
delete requestHeaders[key];
|
|
539
|
-
} else {
|
|
540
|
-
request2.setRequestHeader(key, val);
|
|
541
|
-
}
|
|
542
|
-
});
|
|
543
|
-
}
|
|
544
|
-
if (!utils$6.isUndefined(config.withCredentials)) {
|
|
545
|
-
request2.withCredentials = !!config.withCredentials;
|
|
546
|
-
}
|
|
547
|
-
if (responseType && responseType !== "json") {
|
|
548
|
-
request2.responseType = config.responseType;
|
|
549
|
-
}
|
|
550
|
-
if (typeof config.onDownloadProgress === "function") {
|
|
551
|
-
request2.addEventListener("progress", config.onDownloadProgress);
|
|
552
|
-
}
|
|
553
|
-
if (typeof config.onUploadProgress === "function" && request2.upload) {
|
|
554
|
-
request2.upload.addEventListener("progress", config.onUploadProgress);
|
|
555
|
-
}
|
|
556
|
-
if (config.cancelToken) {
|
|
557
|
-
config.cancelToken.promise.then(function onCanceled(cancel) {
|
|
558
|
-
if (!request2) {
|
|
559
|
-
return;
|
|
560
|
-
}
|
|
561
|
-
request2.abort();
|
|
562
|
-
reject(cancel);
|
|
563
|
-
request2 = null;
|
|
564
|
-
});
|
|
565
|
-
}
|
|
566
|
-
if (!requestData) {
|
|
567
|
-
requestData = null;
|
|
568
|
-
}
|
|
569
|
-
request2.send(requestData);
|
|
570
|
-
});
|
|
571
|
-
};
|
|
572
|
-
var utils$5 = utils$d;
|
|
573
|
-
var normalizeHeaderName2 = normalizeHeaderName$1;
|
|
574
|
-
var enhanceError2 = enhanceError$2;
|
|
575
|
-
var DEFAULT_CONTENT_TYPE = {
|
|
576
|
-
"Content-Type": "application/x-www-form-urlencoded"
|
|
577
|
-
};
|
|
578
|
-
function setContentTypeIfUnset(headers, value) {
|
|
579
|
-
if (!utils$5.isUndefined(headers) && utils$5.isUndefined(headers["Content-Type"])) {
|
|
580
|
-
headers["Content-Type"] = value;
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
function getDefaultAdapter() {
|
|
584
|
-
var adapter;
|
|
585
|
-
if (typeof XMLHttpRequest !== "undefined") {
|
|
586
|
-
adapter = xhr;
|
|
587
|
-
} else if (typeof process !== "undefined" && Object.prototype.toString.call(process) === "[object process]") {
|
|
588
|
-
adapter = xhr;
|
|
589
|
-
}
|
|
590
|
-
return adapter;
|
|
591
|
-
}
|
|
592
|
-
function stringifySafely(rawValue, parser, encoder) {
|
|
593
|
-
if (utils$5.isString(rawValue)) {
|
|
594
|
-
try {
|
|
595
|
-
(parser || JSON.parse)(rawValue);
|
|
596
|
-
return utils$5.trim(rawValue);
|
|
597
|
-
} catch (e2) {
|
|
598
|
-
if (e2.name !== "SyntaxError") {
|
|
599
|
-
throw e2;
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
return (encoder || JSON.stringify)(rawValue);
|
|
604
|
-
}
|
|
605
|
-
var defaults$3 = {
|
|
606
|
-
transitional: {
|
|
607
|
-
silentJSONParsing: true,
|
|
608
|
-
forcedJSONParsing: true,
|
|
609
|
-
clarifyTimeoutError: false
|
|
610
|
-
},
|
|
611
|
-
adapter: getDefaultAdapter(),
|
|
612
|
-
transformRequest: [function transformRequest(data, headers) {
|
|
613
|
-
normalizeHeaderName2(headers, "Accept");
|
|
614
|
-
normalizeHeaderName2(headers, "Content-Type");
|
|
615
|
-
if (utils$5.isFormData(data) || utils$5.isArrayBuffer(data) || utils$5.isBuffer(data) || utils$5.isStream(data) || utils$5.isFile(data) || utils$5.isBlob(data)) {
|
|
616
|
-
return data;
|
|
617
|
-
}
|
|
618
|
-
if (utils$5.isArrayBufferView(data)) {
|
|
619
|
-
return data.buffer;
|
|
620
|
-
}
|
|
621
|
-
if (utils$5.isURLSearchParams(data)) {
|
|
622
|
-
setContentTypeIfUnset(headers, "application/x-www-form-urlencoded;charset=utf-8");
|
|
623
|
-
return data.toString();
|
|
624
|
-
}
|
|
625
|
-
if (utils$5.isObject(data) || headers && headers["Content-Type"] === "application/json") {
|
|
626
|
-
setContentTypeIfUnset(headers, "application/json");
|
|
627
|
-
return stringifySafely(data);
|
|
628
|
-
}
|
|
629
|
-
return data;
|
|
630
|
-
}],
|
|
631
|
-
transformResponse: [function transformResponse(data) {
|
|
632
|
-
var transitional2 = this.transitional;
|
|
633
|
-
var silentJSONParsing = transitional2 && transitional2.silentJSONParsing;
|
|
634
|
-
var forcedJSONParsing = transitional2 && transitional2.forcedJSONParsing;
|
|
635
|
-
var strictJSONParsing = !silentJSONParsing && this.responseType === "json";
|
|
636
|
-
if (strictJSONParsing || forcedJSONParsing && utils$5.isString(data) && data.length) {
|
|
637
|
-
try {
|
|
638
|
-
return JSON.parse(data);
|
|
639
|
-
} catch (e2) {
|
|
640
|
-
if (strictJSONParsing) {
|
|
641
|
-
if (e2.name === "SyntaxError") {
|
|
642
|
-
throw enhanceError2(e2, this, "E_JSON_PARSE");
|
|
643
|
-
}
|
|
644
|
-
throw e2;
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
return data;
|
|
649
|
-
}],
|
|
650
|
-
timeout: 0,
|
|
651
|
-
xsrfCookieName: "XSRF-TOKEN",
|
|
652
|
-
xsrfHeaderName: "X-XSRF-TOKEN",
|
|
653
|
-
maxContentLength: -1,
|
|
654
|
-
maxBodyLength: -1,
|
|
655
|
-
validateStatus: function validateStatus(status) {
|
|
656
|
-
return status >= 200 && status < 300;
|
|
657
|
-
}
|
|
658
|
-
};
|
|
659
|
-
defaults$3.headers = {
|
|
660
|
-
common: {
|
|
661
|
-
"Accept": "application/json, text/plain, */*"
|
|
662
|
-
}
|
|
663
|
-
};
|
|
664
|
-
utils$5.forEach(["delete", "get", "head"], function forEachMethodNoData(method) {
|
|
665
|
-
defaults$3.headers[method] = {};
|
|
666
|
-
});
|
|
667
|
-
utils$5.forEach(["post", "put", "patch"], function forEachMethodWithData(method) {
|
|
668
|
-
defaults$3.headers[method] = utils$5.merge(DEFAULT_CONTENT_TYPE);
|
|
669
|
-
});
|
|
670
|
-
var defaults_1 = defaults$3;
|
|
671
|
-
var utils$4 = utils$d;
|
|
672
|
-
var defaults$2 = defaults_1;
|
|
673
|
-
var transformData$1 = function transformData(data, headers, fns) {
|
|
674
|
-
var context = this || defaults$2;
|
|
675
|
-
utils$4.forEach(fns, function transform(fn) {
|
|
676
|
-
data = fn.call(context, data, headers);
|
|
677
|
-
});
|
|
678
|
-
return data;
|
|
679
|
-
};
|
|
680
|
-
var isCancel$1 = function isCancel(value) {
|
|
681
|
-
return !!(value && value.__CANCEL__);
|
|
682
|
-
};
|
|
683
|
-
var utils$3 = utils$d;
|
|
684
|
-
var transformData2 = transformData$1;
|
|
685
|
-
var isCancel2 = isCancel$1;
|
|
686
|
-
var defaults$1 = defaults_1;
|
|
687
|
-
function throwIfCancellationRequested(config) {
|
|
688
|
-
if (config.cancelToken) {
|
|
689
|
-
config.cancelToken.throwIfRequested();
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
var dispatchRequest$1 = function dispatchRequest(config) {
|
|
693
|
-
throwIfCancellationRequested(config);
|
|
694
|
-
config.headers = config.headers || {};
|
|
695
|
-
config.data = transformData2.call(config, config.data, config.headers, config.transformRequest);
|
|
696
|
-
config.headers = utils$3.merge(config.headers.common || {}, config.headers[config.method] || {}, config.headers);
|
|
697
|
-
utils$3.forEach(["delete", "get", "head", "post", "put", "patch", "common"], function cleanHeaderConfig(method) {
|
|
698
|
-
delete config.headers[method];
|
|
699
|
-
});
|
|
700
|
-
var adapter = config.adapter || defaults$1.adapter;
|
|
701
|
-
return adapter(config).then(function onAdapterResolution(response) {
|
|
702
|
-
throwIfCancellationRequested(config);
|
|
703
|
-
response.data = transformData2.call(config, response.data, response.headers, config.transformResponse);
|
|
704
|
-
return response;
|
|
705
|
-
}, function onAdapterRejection(reason) {
|
|
706
|
-
if (!isCancel2(reason)) {
|
|
707
|
-
throwIfCancellationRequested(config);
|
|
708
|
-
if (reason && reason.response) {
|
|
709
|
-
reason.response.data = transformData2.call(config, reason.response.data, reason.response.headers, config.transformResponse);
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
return Promise.reject(reason);
|
|
713
|
-
});
|
|
714
|
-
};
|
|
715
|
-
var utils$2 = utils$d;
|
|
716
|
-
var mergeConfig$2 = function mergeConfig(config1, config2) {
|
|
717
|
-
config2 = config2 || {};
|
|
718
|
-
var config = {};
|
|
719
|
-
var valueFromConfig2Keys = ["url", "method", "data"];
|
|
720
|
-
var mergeDeepPropertiesKeys = ["headers", "auth", "proxy", "params"];
|
|
721
|
-
var defaultToConfig2Keys = [
|
|
722
|
-
"baseURL",
|
|
723
|
-
"transformRequest",
|
|
724
|
-
"transformResponse",
|
|
725
|
-
"paramsSerializer",
|
|
726
|
-
"timeout",
|
|
727
|
-
"timeoutMessage",
|
|
728
|
-
"withCredentials",
|
|
729
|
-
"adapter",
|
|
730
|
-
"responseType",
|
|
731
|
-
"xsrfCookieName",
|
|
732
|
-
"xsrfHeaderName",
|
|
733
|
-
"onUploadProgress",
|
|
734
|
-
"onDownloadProgress",
|
|
735
|
-
"decompress",
|
|
736
|
-
"maxContentLength",
|
|
737
|
-
"maxBodyLength",
|
|
738
|
-
"maxRedirects",
|
|
739
|
-
"transport",
|
|
740
|
-
"httpAgent",
|
|
741
|
-
"httpsAgent",
|
|
742
|
-
"cancelToken",
|
|
743
|
-
"socketPath",
|
|
744
|
-
"responseEncoding"
|
|
745
|
-
];
|
|
746
|
-
var directMergeKeys = ["validateStatus"];
|
|
747
|
-
function getMergedValue(target, source2) {
|
|
748
|
-
if (utils$2.isPlainObject(target) && utils$2.isPlainObject(source2)) {
|
|
749
|
-
return utils$2.merge(target, source2);
|
|
750
|
-
} else if (utils$2.isPlainObject(source2)) {
|
|
751
|
-
return utils$2.merge({}, source2);
|
|
752
|
-
} else if (utils$2.isArray(source2)) {
|
|
753
|
-
return source2.slice();
|
|
754
|
-
}
|
|
755
|
-
return source2;
|
|
756
|
-
}
|
|
757
|
-
function mergeDeepProperties(prop) {
|
|
758
|
-
if (!utils$2.isUndefined(config2[prop])) {
|
|
759
|
-
config[prop] = getMergedValue(config1[prop], config2[prop]);
|
|
760
|
-
} else if (!utils$2.isUndefined(config1[prop])) {
|
|
761
|
-
config[prop] = getMergedValue(void 0, config1[prop]);
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
utils$2.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
|
|
765
|
-
if (!utils$2.isUndefined(config2[prop])) {
|
|
766
|
-
config[prop] = getMergedValue(void 0, config2[prop]);
|
|
767
|
-
}
|
|
768
|
-
});
|
|
769
|
-
utils$2.forEach(mergeDeepPropertiesKeys, mergeDeepProperties);
|
|
770
|
-
utils$2.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
|
|
771
|
-
if (!utils$2.isUndefined(config2[prop])) {
|
|
772
|
-
config[prop] = getMergedValue(void 0, config2[prop]);
|
|
773
|
-
} else if (!utils$2.isUndefined(config1[prop])) {
|
|
774
|
-
config[prop] = getMergedValue(void 0, config1[prop]);
|
|
775
|
-
}
|
|
776
|
-
});
|
|
777
|
-
utils$2.forEach(directMergeKeys, function merge2(prop) {
|
|
778
|
-
if (prop in config2) {
|
|
779
|
-
config[prop] = getMergedValue(config1[prop], config2[prop]);
|
|
780
|
-
} else if (prop in config1) {
|
|
781
|
-
config[prop] = getMergedValue(void 0, config1[prop]);
|
|
782
|
-
}
|
|
783
|
-
});
|
|
784
|
-
var axiosKeys = valueFromConfig2Keys.concat(mergeDeepPropertiesKeys).concat(defaultToConfig2Keys).concat(directMergeKeys);
|
|
785
|
-
var otherKeys = Object.keys(config1).concat(Object.keys(config2)).filter(function filterAxiosKeys(key) {
|
|
786
|
-
return axiosKeys.indexOf(key) === -1;
|
|
787
|
-
});
|
|
788
|
-
utils$2.forEach(otherKeys, mergeDeepProperties);
|
|
789
|
-
return config;
|
|
790
|
-
};
|
|
791
|
-
const name = "axios";
|
|
792
|
-
const version = "0.21.4";
|
|
793
|
-
const description = "Promise based HTTP client for the browser and node.js";
|
|
794
|
-
const main = "index.js";
|
|
795
|
-
const scripts = {
|
|
796
|
-
test: "grunt test",
|
|
797
|
-
start: "node ./sandbox/server.js",
|
|
798
|
-
build: "NODE_ENV=production grunt build",
|
|
799
|
-
preversion: "npm test",
|
|
800
|
-
version: "npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json",
|
|
801
|
-
postversion: "git push && git push --tags",
|
|
802
|
-
examples: "node ./examples/server.js",
|
|
803
|
-
coveralls: "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
|
|
804
|
-
fix: "eslint --fix lib/**/*.js"
|
|
805
|
-
};
|
|
806
|
-
const repository = {
|
|
807
|
-
type: "git",
|
|
808
|
-
url: "https://github.com/axios/axios.git"
|
|
809
|
-
};
|
|
810
|
-
const keywords = [
|
|
811
|
-
"xhr",
|
|
812
|
-
"http",
|
|
813
|
-
"ajax",
|
|
814
|
-
"promise",
|
|
815
|
-
"node"
|
|
816
|
-
];
|
|
817
|
-
const author = "Matt Zabriskie";
|
|
818
|
-
const license = "MIT";
|
|
819
|
-
const bugs = {
|
|
820
|
-
url: "https://github.com/axios/axios/issues"
|
|
821
|
-
};
|
|
822
|
-
const homepage = "https://axios-http.com";
|
|
823
|
-
const devDependencies = {
|
|
824
|
-
coveralls: "^3.0.0",
|
|
825
|
-
"es6-promise": "^4.2.4",
|
|
826
|
-
grunt: "^1.3.0",
|
|
827
|
-
"grunt-banner": "^0.6.0",
|
|
828
|
-
"grunt-cli": "^1.2.0",
|
|
829
|
-
"grunt-contrib-clean": "^1.1.0",
|
|
830
|
-
"grunt-contrib-watch": "^1.0.0",
|
|
831
|
-
"grunt-eslint": "^23.0.0",
|
|
832
|
-
"grunt-karma": "^4.0.0",
|
|
833
|
-
"grunt-mocha-test": "^0.13.3",
|
|
834
|
-
"grunt-ts": "^6.0.0-beta.19",
|
|
835
|
-
"grunt-webpack": "^4.0.2",
|
|
836
|
-
"istanbul-instrumenter-loader": "^1.0.0",
|
|
837
|
-
"jasmine-core": "^2.4.1",
|
|
838
|
-
karma: "^6.3.2",
|
|
839
|
-
"karma-chrome-launcher": "^3.1.0",
|
|
840
|
-
"karma-firefox-launcher": "^2.1.0",
|
|
841
|
-
"karma-jasmine": "^1.1.1",
|
|
842
|
-
"karma-jasmine-ajax": "^0.1.13",
|
|
843
|
-
"karma-safari-launcher": "^1.0.0",
|
|
844
|
-
"karma-sauce-launcher": "^4.3.6",
|
|
845
|
-
"karma-sinon": "^1.0.5",
|
|
846
|
-
"karma-sourcemap-loader": "^0.3.8",
|
|
847
|
-
"karma-webpack": "^4.0.2",
|
|
848
|
-
"load-grunt-tasks": "^3.5.2",
|
|
849
|
-
minimist: "^1.2.0",
|
|
850
|
-
mocha: "^8.2.1",
|
|
851
|
-
sinon: "^4.5.0",
|
|
852
|
-
"terser-webpack-plugin": "^4.2.3",
|
|
853
|
-
typescript: "^4.0.5",
|
|
854
|
-
"url-search-params": "^0.10.0",
|
|
855
|
-
webpack: "^4.44.2",
|
|
856
|
-
"webpack-dev-server": "^3.11.0"
|
|
857
|
-
};
|
|
858
|
-
const browser = {
|
|
859
|
-
"./lib/adapters/http.js": "./lib/adapters/xhr.js"
|
|
860
|
-
};
|
|
861
|
-
const jsdelivr = "dist/axios.min.js";
|
|
862
|
-
const unpkg = "dist/axios.min.js";
|
|
863
|
-
const typings = "./index.d.ts";
|
|
864
|
-
const dependencies = {
|
|
865
|
-
"follow-redirects": "^1.14.0"
|
|
866
|
-
};
|
|
867
|
-
const bundlesize = [
|
|
868
|
-
{
|
|
869
|
-
path: "./dist/axios.min.js",
|
|
870
|
-
threshold: "5kB"
|
|
871
|
-
}
|
|
872
|
-
];
|
|
873
|
-
var require$$0 = {
|
|
874
|
-
name,
|
|
875
|
-
version,
|
|
876
|
-
description,
|
|
877
|
-
main,
|
|
878
|
-
scripts,
|
|
879
|
-
repository,
|
|
880
|
-
keywords,
|
|
881
|
-
author,
|
|
882
|
-
license,
|
|
883
|
-
bugs,
|
|
884
|
-
homepage,
|
|
885
|
-
devDependencies,
|
|
886
|
-
browser,
|
|
887
|
-
jsdelivr,
|
|
888
|
-
unpkg,
|
|
889
|
-
typings,
|
|
890
|
-
dependencies,
|
|
891
|
-
bundlesize
|
|
892
|
-
};
|
|
893
|
-
var pkg = require$$0;
|
|
894
|
-
var validators$1 = {};
|
|
895
|
-
["object", "boolean", "number", "function", "string", "symbol"].forEach(function(type, i2) {
|
|
896
|
-
validators$1[type] = function validator2(thing) {
|
|
897
|
-
return typeof thing === type || "a" + (i2 < 1 ? "n " : " ") + type;
|
|
898
|
-
};
|
|
899
|
-
});
|
|
900
|
-
var deprecatedWarnings = {};
|
|
901
|
-
var currentVerArr = pkg.version.split(".");
|
|
902
|
-
function isOlderVersion(version2, thanVersion) {
|
|
903
|
-
var pkgVersionArr = thanVersion ? thanVersion.split(".") : currentVerArr;
|
|
904
|
-
var destVer = version2.split(".");
|
|
905
|
-
for (var i2 = 0; i2 < 3; i2++) {
|
|
906
|
-
if (pkgVersionArr[i2] > destVer[i2]) {
|
|
907
|
-
return true;
|
|
908
|
-
} else if (pkgVersionArr[i2] < destVer[i2]) {
|
|
909
|
-
return false;
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
return false;
|
|
913
|
-
}
|
|
914
|
-
validators$1.transitional = function transitional(validator2, version2, message) {
|
|
915
|
-
var isDeprecated = version2 && isOlderVersion(version2);
|
|
916
|
-
function formatMessage(opt, desc) {
|
|
917
|
-
return "[Axios v" + pkg.version + "] Transitional option '" + opt + "'" + desc + (message ? ". " + message : "");
|
|
918
|
-
}
|
|
919
|
-
return function(value, opt, opts) {
|
|
920
|
-
if (validator2 === false) {
|
|
921
|
-
throw new Error(formatMessage(opt, " has been removed in " + version2));
|
|
922
|
-
}
|
|
923
|
-
if (isDeprecated && !deprecatedWarnings[opt]) {
|
|
924
|
-
deprecatedWarnings[opt] = true;
|
|
925
|
-
console.warn(formatMessage(opt, " has been deprecated since v" + version2 + " and will be removed in the near future"));
|
|
926
|
-
}
|
|
927
|
-
return validator2 ? validator2(value, opt, opts) : true;
|
|
928
|
-
};
|
|
929
|
-
};
|
|
930
|
-
function assertOptions(options, schema, allowUnknown) {
|
|
931
|
-
if (typeof options !== "object") {
|
|
932
|
-
throw new TypeError("options must be an object");
|
|
933
|
-
}
|
|
934
|
-
var keys = Object.keys(options);
|
|
935
|
-
var i2 = keys.length;
|
|
936
|
-
while (i2-- > 0) {
|
|
937
|
-
var opt = keys[i2];
|
|
938
|
-
var validator2 = schema[opt];
|
|
939
|
-
if (validator2) {
|
|
940
|
-
var value = options[opt];
|
|
941
|
-
var result = value === void 0 || validator2(value, opt, options);
|
|
942
|
-
if (result !== true) {
|
|
943
|
-
throw new TypeError("option " + opt + " must be " + result);
|
|
944
|
-
}
|
|
945
|
-
continue;
|
|
946
|
-
}
|
|
947
|
-
if (allowUnknown !== true) {
|
|
948
|
-
throw Error("Unknown option " + opt);
|
|
949
|
-
}
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
var validator$1 = {
|
|
953
|
-
isOlderVersion,
|
|
954
|
-
assertOptions,
|
|
955
|
-
validators: validators$1
|
|
956
|
-
};
|
|
957
|
-
var utils$1 = utils$d;
|
|
958
|
-
var buildURL2 = buildURL$2;
|
|
959
|
-
var InterceptorManager = InterceptorManager_1;
|
|
960
|
-
var dispatchRequest2 = dispatchRequest$1;
|
|
961
|
-
var mergeConfig$1 = mergeConfig$2;
|
|
962
|
-
var validator = validator$1;
|
|
963
|
-
var validators = validator.validators;
|
|
964
|
-
function Axios$1(instanceConfig) {
|
|
965
|
-
this.defaults = instanceConfig;
|
|
966
|
-
this.interceptors = {
|
|
967
|
-
request: new InterceptorManager(),
|
|
968
|
-
response: new InterceptorManager()
|
|
969
|
-
};
|
|
970
|
-
}
|
|
971
|
-
Axios$1.prototype.request = function request(config) {
|
|
972
|
-
if (typeof config === "string") {
|
|
973
|
-
config = arguments[1] || {};
|
|
974
|
-
config.url = arguments[0];
|
|
975
|
-
} else {
|
|
976
|
-
config = config || {};
|
|
977
|
-
}
|
|
978
|
-
config = mergeConfig$1(this.defaults, config);
|
|
979
|
-
if (config.method) {
|
|
980
|
-
config.method = config.method.toLowerCase();
|
|
981
|
-
} else if (this.defaults.method) {
|
|
982
|
-
config.method = this.defaults.method.toLowerCase();
|
|
983
|
-
} else {
|
|
984
|
-
config.method = "get";
|
|
985
|
-
}
|
|
986
|
-
var transitional2 = config.transitional;
|
|
987
|
-
if (transitional2 !== void 0) {
|
|
988
|
-
validator.assertOptions(transitional2, {
|
|
989
|
-
silentJSONParsing: validators.transitional(validators.boolean, "1.0.0"),
|
|
990
|
-
forcedJSONParsing: validators.transitional(validators.boolean, "1.0.0"),
|
|
991
|
-
clarifyTimeoutError: validators.transitional(validators.boolean, "1.0.0")
|
|
992
|
-
}, false);
|
|
993
|
-
}
|
|
994
|
-
var requestInterceptorChain = [];
|
|
995
|
-
var synchronousRequestInterceptors = true;
|
|
996
|
-
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
|
997
|
-
if (typeof interceptor.runWhen === "function" && interceptor.runWhen(config) === false) {
|
|
998
|
-
return;
|
|
999
|
-
}
|
|
1000
|
-
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
|
1001
|
-
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
|
|
1002
|
-
});
|
|
1003
|
-
var responseInterceptorChain = [];
|
|
1004
|
-
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
|
|
1005
|
-
responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
|
|
1006
|
-
});
|
|
1007
|
-
var promise;
|
|
1008
|
-
if (!synchronousRequestInterceptors) {
|
|
1009
|
-
var chain = [dispatchRequest2, void 0];
|
|
1010
|
-
Array.prototype.unshift.apply(chain, requestInterceptorChain);
|
|
1011
|
-
chain = chain.concat(responseInterceptorChain);
|
|
1012
|
-
promise = Promise.resolve(config);
|
|
1013
|
-
while (chain.length) {
|
|
1014
|
-
promise = promise.then(chain.shift(), chain.shift());
|
|
1015
|
-
}
|
|
1016
|
-
return promise;
|
|
1017
|
-
}
|
|
1018
|
-
var newConfig = config;
|
|
1019
|
-
while (requestInterceptorChain.length) {
|
|
1020
|
-
var onFulfilled = requestInterceptorChain.shift();
|
|
1021
|
-
var onRejected = requestInterceptorChain.shift();
|
|
1022
|
-
try {
|
|
1023
|
-
newConfig = onFulfilled(newConfig);
|
|
1024
|
-
} catch (error) {
|
|
1025
|
-
onRejected(error);
|
|
1026
|
-
break;
|
|
1027
|
-
}
|
|
1028
|
-
}
|
|
1029
|
-
try {
|
|
1030
|
-
promise = dispatchRequest2(newConfig);
|
|
1031
|
-
} catch (error) {
|
|
1032
|
-
return Promise.reject(error);
|
|
1033
|
-
}
|
|
1034
|
-
while (responseInterceptorChain.length) {
|
|
1035
|
-
promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
|
|
1036
|
-
}
|
|
1037
|
-
return promise;
|
|
1038
|
-
};
|
|
1039
|
-
Axios$1.prototype.getUri = function getUri(config) {
|
|
1040
|
-
config = mergeConfig$1(this.defaults, config);
|
|
1041
|
-
return buildURL2(config.url, config.params, config.paramsSerializer).replace(/^\?/, "");
|
|
1042
|
-
};
|
|
1043
|
-
utils$1.forEach(["delete", "get", "head", "options"], function forEachMethodNoData2(method) {
|
|
1044
|
-
Axios$1.prototype[method] = function(url, config) {
|
|
1045
|
-
return this.request(mergeConfig$1(config || {}, {
|
|
1046
|
-
method,
|
|
1047
|
-
url,
|
|
1048
|
-
data: (config || {}).data
|
|
1049
|
-
}));
|
|
1050
|
-
};
|
|
1051
|
-
});
|
|
1052
|
-
utils$1.forEach(["post", "put", "patch"], function forEachMethodWithData2(method) {
|
|
1053
|
-
Axios$1.prototype[method] = function(url, data, config) {
|
|
1054
|
-
return this.request(mergeConfig$1(config || {}, {
|
|
1055
|
-
method,
|
|
1056
|
-
url,
|
|
1057
|
-
data
|
|
1058
|
-
}));
|
|
1059
|
-
};
|
|
1060
|
-
});
|
|
1061
|
-
var Axios_1 = Axios$1;
|
|
1062
|
-
function Cancel$1(message) {
|
|
1063
|
-
this.message = message;
|
|
1064
|
-
}
|
|
1065
|
-
Cancel$1.prototype.toString = function toString2() {
|
|
1066
|
-
return "Cancel" + (this.message ? ": " + this.message : "");
|
|
1067
|
-
};
|
|
1068
|
-
Cancel$1.prototype.__CANCEL__ = true;
|
|
1069
|
-
var Cancel_1 = Cancel$1;
|
|
1070
|
-
var Cancel = Cancel_1;
|
|
1071
|
-
function CancelToken(executor) {
|
|
1072
|
-
if (typeof executor !== "function") {
|
|
1073
|
-
throw new TypeError("executor must be a function.");
|
|
1074
|
-
}
|
|
1075
|
-
var resolvePromise;
|
|
1076
|
-
this.promise = new Promise(function promiseExecutor(resolve) {
|
|
1077
|
-
resolvePromise = resolve;
|
|
1078
|
-
});
|
|
1079
|
-
var token = this;
|
|
1080
|
-
executor(function cancel(message) {
|
|
1081
|
-
if (token.reason) {
|
|
1082
|
-
return;
|
|
1083
|
-
}
|
|
1084
|
-
token.reason = new Cancel(message);
|
|
1085
|
-
resolvePromise(token.reason);
|
|
1086
|
-
});
|
|
1087
|
-
}
|
|
1088
|
-
CancelToken.prototype.throwIfRequested = function throwIfRequested() {
|
|
1089
|
-
if (this.reason) {
|
|
1090
|
-
throw this.reason;
|
|
1091
|
-
}
|
|
1092
|
-
};
|
|
1093
|
-
CancelToken.source = function source() {
|
|
1094
|
-
var cancel;
|
|
1095
|
-
var token = new CancelToken(function executor(c2) {
|
|
1096
|
-
cancel = c2;
|
|
1097
|
-
});
|
|
1098
|
-
return {
|
|
1099
|
-
token,
|
|
1100
|
-
cancel
|
|
1101
|
-
};
|
|
1102
|
-
};
|
|
1103
|
-
var CancelToken_1 = CancelToken;
|
|
1104
|
-
var spread = function spread2(callback) {
|
|
1105
|
-
return function wrap(arr) {
|
|
1106
|
-
return callback.apply(null, arr);
|
|
1107
|
-
};
|
|
1108
|
-
};
|
|
1109
|
-
var isAxiosError = function isAxiosError2(payload) {
|
|
1110
|
-
return typeof payload === "object" && payload.isAxiosError === true;
|
|
1111
|
-
};
|
|
1112
|
-
var utils = utils$d;
|
|
1113
|
-
var bind2 = bind$2;
|
|
1114
|
-
var Axios = Axios_1;
|
|
1115
|
-
var mergeConfig2 = mergeConfig$2;
|
|
1116
|
-
var defaults = defaults_1;
|
|
1117
|
-
function createInstance(defaultConfig) {
|
|
1118
|
-
var context = new Axios(defaultConfig);
|
|
1119
|
-
var instance = bind2(Axios.prototype.request, context);
|
|
1120
|
-
utils.extend(instance, Axios.prototype, context);
|
|
1121
|
-
utils.extend(instance, context);
|
|
1122
|
-
return instance;
|
|
1123
|
-
}
|
|
1124
|
-
var axios$1 = createInstance(defaults);
|
|
1125
|
-
axios$1.Axios = Axios;
|
|
1126
|
-
axios$1.create = function create(instanceConfig) {
|
|
1127
|
-
return createInstance(mergeConfig2(axios$1.defaults, instanceConfig));
|
|
1128
|
-
};
|
|
1129
|
-
axios$1.Cancel = Cancel_1;
|
|
1130
|
-
axios$1.CancelToken = CancelToken_1;
|
|
1131
|
-
axios$1.isCancel = isCancel$1;
|
|
1132
|
-
axios$1.all = function all(promises) {
|
|
1133
|
-
return Promise.all(promises);
|
|
1134
|
-
};
|
|
1135
|
-
axios$1.spread = spread;
|
|
1136
|
-
axios$1.isAxiosError = isAxiosError;
|
|
1137
|
-
axios$2.exports = axios$1;
|
|
1138
|
-
axios$2.exports.default = axios$1;
|
|
1139
|
-
var axios = axios$2.exports;
|
|
1140
52
|
/*!
|
|
1141
53
|
* storyblok-js-client v0.0.0-development
|
|
1142
54
|
* Universal JavaScript SDK for Storyblok's API
|
|
1143
55
|
* (c) 2020-2022 Stobylok Team
|
|
1144
56
|
*/
|
|
1145
|
-
function e(
|
|
1146
|
-
return typeof
|
|
57
|
+
function e(t2) {
|
|
58
|
+
return typeof t2 == "number" && (t2 == t2 && t2 !== 1 / 0 && t2 !== -1 / 0);
|
|
1147
59
|
}
|
|
1148
|
-
function r(
|
|
60
|
+
function r(t2, r2, s2) {
|
|
1149
61
|
if (!e(r2))
|
|
1150
62
|
throw new TypeError("Expected `limit` to be a finite number");
|
|
1151
63
|
if (!e(s2))
|
|
@@ -1153,121 +65,121 @@ function r(t, r2, s2) {
|
|
|
1153
65
|
var n2 = [], i2 = [], o2 = 0, a2 = function() {
|
|
1154
66
|
o2++;
|
|
1155
67
|
var e2 = setTimeout(function() {
|
|
1156
|
-
o2--, n2.length > 0 && a2(), i2 = i2.filter(function(
|
|
1157
|
-
return
|
|
68
|
+
o2--, n2.length > 0 && a2(), i2 = i2.filter(function(t3) {
|
|
69
|
+
return t3 !== e2;
|
|
1158
70
|
});
|
|
1159
71
|
}, s2);
|
|
1160
72
|
i2.indexOf(e2) < 0 && i2.push(e2);
|
|
1161
73
|
var r3 = n2.shift();
|
|
1162
|
-
r3.resolve(
|
|
74
|
+
r3.resolve(t2.apply(r3.self, r3.args));
|
|
1163
75
|
}, l2 = function() {
|
|
1164
|
-
var
|
|
76
|
+
var t3 = arguments, e2 = this;
|
|
1165
77
|
return new Promise(function(s3, i3) {
|
|
1166
|
-
n2.push({ resolve: s3, reject: i3, args:
|
|
78
|
+
n2.push({ resolve: s3, reject: i3, args: t3, self: e2 }), o2 < r2 && a2();
|
|
1167
79
|
});
|
|
1168
80
|
};
|
|
1169
81
|
return l2.abort = function() {
|
|
1170
|
-
i2.forEach(clearTimeout), i2 = [], n2.forEach(function(
|
|
1171
|
-
|
|
82
|
+
i2.forEach(clearTimeout), i2 = [], n2.forEach(function(t3) {
|
|
83
|
+
t3.reject(new throttle.AbortError());
|
|
1172
84
|
}), n2.length = 0;
|
|
1173
85
|
}, l2;
|
|
1174
86
|
}
|
|
1175
87
|
r.AbortError = function() {
|
|
1176
88
|
Error.call(this, "Throttled function aborted"), this.name = "AbortError";
|
|
1177
89
|
};
|
|
1178
|
-
const s = function(
|
|
1179
|
-
if (!
|
|
90
|
+
const s = function(t2, e2) {
|
|
91
|
+
if (!t2)
|
|
1180
92
|
return null;
|
|
1181
93
|
let r2 = {};
|
|
1182
|
-
for (let s2 in
|
|
1183
|
-
let n2 =
|
|
94
|
+
for (let s2 in t2) {
|
|
95
|
+
let n2 = t2[s2];
|
|
1184
96
|
e2.indexOf(s2) > -1 && n2 !== null && (r2[s2] = n2);
|
|
1185
97
|
}
|
|
1186
98
|
return r2;
|
|
1187
99
|
};
|
|
1188
|
-
var n = { nodes: { horizontal_rule: (
|
|
1189
|
-
const e2 = __spreadValues({},
|
|
100
|
+
var n = { nodes: { horizontal_rule: (t2) => ({ singleTag: "hr" }), blockquote: (t2) => ({ tag: "blockquote" }), bullet_list: (t2) => ({ tag: "ul" }), code_block: (t2) => ({ tag: ["pre", { tag: "code", attrs: t2.attrs }] }), hard_break: (t2) => ({ singleTag: "br" }), heading: (t2) => ({ tag: "h" + t2.attrs.level }), image: (t2) => ({ singleTag: [{ tag: "img", attrs: s(t2.attrs, ["src", "alt", "title"]) }] }), list_item: (t2) => ({ tag: "li" }), ordered_list: (t2) => ({ tag: "ol" }), paragraph: (t2) => ({ tag: "p" }) }, marks: { bold: () => ({ tag: "b" }), strike: () => ({ tag: "strike" }), underline: () => ({ tag: "u" }), strong: () => ({ tag: "strong" }), code: () => ({ tag: "code" }), italic: () => ({ tag: "i" }), link(t2) {
|
|
101
|
+
const e2 = __spreadValues({}, t2.attrs), { linktype: r2 = "url" } = t2.attrs;
|
|
1190
102
|
return r2 === "email" && (e2.href = "mailto:" + e2.href), e2.anchor && (e2.href = `${e2.href}#${e2.anchor}`, delete e2.anchor), { tag: [{ tag: "a", attrs: e2 }] };
|
|
1191
|
-
}, styled: (
|
|
103
|
+
}, styled: (t2) => ({ tag: [{ tag: "span", attrs: t2.attrs }] }) } };
|
|
1192
104
|
class i {
|
|
1193
|
-
constructor(
|
|
1194
|
-
|
|
105
|
+
constructor(t2) {
|
|
106
|
+
t2 || (t2 = n), this.marks = t2.marks || [], this.nodes = t2.nodes || [];
|
|
1195
107
|
}
|
|
1196
|
-
addNode(
|
|
1197
|
-
this.nodes[
|
|
108
|
+
addNode(t2, e2) {
|
|
109
|
+
this.nodes[t2] = e2;
|
|
1198
110
|
}
|
|
1199
|
-
addMark(
|
|
1200
|
-
this.marks[
|
|
111
|
+
addMark(t2, e2) {
|
|
112
|
+
this.marks[t2] = e2;
|
|
1201
113
|
}
|
|
1202
|
-
render(
|
|
1203
|
-
if (
|
|
114
|
+
render(t2 = {}) {
|
|
115
|
+
if (t2.content && Array.isArray(t2.content)) {
|
|
1204
116
|
let e2 = "";
|
|
1205
|
-
return
|
|
1206
|
-
e2 += this.renderNode(
|
|
117
|
+
return t2.content.forEach((t3) => {
|
|
118
|
+
e2 += this.renderNode(t3);
|
|
1207
119
|
}), e2;
|
|
1208
120
|
}
|
|
1209
121
|
return console.warn("The render method must receive an object with a content field, which is an array"), "";
|
|
1210
122
|
}
|
|
1211
|
-
renderNode(
|
|
123
|
+
renderNode(t2) {
|
|
1212
124
|
let e2 = [];
|
|
1213
|
-
|
|
1214
|
-
const r3 = this.getMatchingMark(
|
|
125
|
+
t2.marks && t2.marks.forEach((t3) => {
|
|
126
|
+
const r3 = this.getMatchingMark(t3);
|
|
1215
127
|
r3 && e2.push(this.renderOpeningTag(r3.tag));
|
|
1216
128
|
});
|
|
1217
|
-
const r2 = this.getMatchingNode(
|
|
1218
|
-
return r2 && r2.tag && e2.push(this.renderOpeningTag(r2.tag)),
|
|
1219
|
-
e2.push(this.renderNode(
|
|
1220
|
-
}) :
|
|
129
|
+
const r2 = this.getMatchingNode(t2);
|
|
130
|
+
return r2 && r2.tag && e2.push(this.renderOpeningTag(r2.tag)), t2.content ? t2.content.forEach((t3) => {
|
|
131
|
+
e2.push(this.renderNode(t3));
|
|
132
|
+
}) : t2.text ? e2.push(function(t3) {
|
|
1221
133
|
const e3 = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }, r3 = /[&<>"']/g, s2 = RegExp(r3.source);
|
|
1222
|
-
return
|
|
1223
|
-
}(
|
|
1224
|
-
const r3 = this.getMatchingMark(
|
|
134
|
+
return t3 && s2.test(t3) ? t3.replace(r3, (t4) => e3[t4]) : t3;
|
|
135
|
+
}(t2.text)) : r2 && r2.singleTag ? e2.push(this.renderTag(r2.singleTag, " /")) : r2 && r2.html && e2.push(r2.html), r2 && r2.tag && e2.push(this.renderClosingTag(r2.tag)), t2.marks && t2.marks.slice(0).reverse().forEach((t3) => {
|
|
136
|
+
const r3 = this.getMatchingMark(t3);
|
|
1225
137
|
r3 && e2.push(this.renderClosingTag(r3.tag));
|
|
1226
138
|
}), e2.join("");
|
|
1227
139
|
}
|
|
1228
|
-
renderTag(
|
|
1229
|
-
if (
|
|
1230
|
-
return `<${
|
|
1231
|
-
return
|
|
1232
|
-
if (
|
|
1233
|
-
return `<${
|
|
140
|
+
renderTag(t2, e2) {
|
|
141
|
+
if (t2.constructor === String)
|
|
142
|
+
return `<${t2}${e2}>`;
|
|
143
|
+
return t2.map((t3) => {
|
|
144
|
+
if (t3.constructor === String)
|
|
145
|
+
return `<${t3}${e2}>`;
|
|
1234
146
|
{
|
|
1235
|
-
let r2 = "<" +
|
|
1236
|
-
if (
|
|
1237
|
-
for (let e3 in
|
|
1238
|
-
let s2 =
|
|
147
|
+
let r2 = "<" + t3.tag;
|
|
148
|
+
if (t3.attrs)
|
|
149
|
+
for (let e3 in t3.attrs) {
|
|
150
|
+
let s2 = t3.attrs[e3];
|
|
1239
151
|
s2 !== null && (r2 += ` ${e3}="${s2}"`);
|
|
1240
152
|
}
|
|
1241
153
|
return `${r2}${e2}>`;
|
|
1242
154
|
}
|
|
1243
155
|
}).join("");
|
|
1244
156
|
}
|
|
1245
|
-
renderOpeningTag(
|
|
1246
|
-
return this.renderTag(
|
|
157
|
+
renderOpeningTag(t2) {
|
|
158
|
+
return this.renderTag(t2, "");
|
|
1247
159
|
}
|
|
1248
|
-
renderClosingTag(
|
|
1249
|
-
if (
|
|
1250
|
-
return `</${
|
|
1251
|
-
return
|
|
160
|
+
renderClosingTag(t2) {
|
|
161
|
+
if (t2.constructor === String)
|
|
162
|
+
return `</${t2}>`;
|
|
163
|
+
return t2.slice(0).reverse().map((t3) => t3.constructor === String ? `</${t3}>` : `</${t3.tag}>`).join("");
|
|
1252
164
|
}
|
|
1253
|
-
getMatchingNode(
|
|
1254
|
-
if (typeof this.nodes[
|
|
1255
|
-
return this.nodes[
|
|
165
|
+
getMatchingNode(t2) {
|
|
166
|
+
if (typeof this.nodes[t2.type] == "function")
|
|
167
|
+
return this.nodes[t2.type](t2);
|
|
1256
168
|
}
|
|
1257
|
-
getMatchingMark(
|
|
1258
|
-
if (typeof this.marks[
|
|
1259
|
-
return this.marks[
|
|
169
|
+
getMatchingMark(t2) {
|
|
170
|
+
if (typeof this.marks[t2.type] == "function")
|
|
171
|
+
return this.marks[t2.type](t2);
|
|
1260
172
|
}
|
|
1261
173
|
}
|
|
1262
|
-
const o = (
|
|
1263
|
-
const r2 = Math.abs(e2 -
|
|
1264
|
-
return ((
|
|
1265
|
-
}, a = (
|
|
174
|
+
const o = (t2 = 0, e2 = t2) => {
|
|
175
|
+
const r2 = Math.abs(e2 - t2) || 0, s2 = t2 < e2 ? 1 : -1;
|
|
176
|
+
return ((t3 = 0, e3) => [...Array(t3)].map(e3))(r2, (e3, r3) => r3 * s2 + t2);
|
|
177
|
+
}, a = (t2, e2, r2) => {
|
|
1266
178
|
const s2 = [];
|
|
1267
|
-
for (const n2 in
|
|
1268
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
179
|
+
for (const n2 in t2) {
|
|
180
|
+
if (!Object.prototype.hasOwnProperty.call(t2, n2))
|
|
1269
181
|
continue;
|
|
1270
|
-
const i2 =
|
|
182
|
+
const i2 = t2[n2], o2 = r2 ? "" : encodeURIComponent(n2);
|
|
1271
183
|
let l2;
|
|
1272
184
|
l2 = typeof i2 == "object" ? a(i2, e2 ? e2 + encodeURIComponent("[" + o2 + "]") : o2, Array.isArray(i2)) : (e2 ? e2 + encodeURIComponent("[" + o2 + "]") : o2) + "=" + encodeURIComponent(i2), s2.push(l2);
|
|
1273
185
|
}
|
|
@@ -1277,174 +189,174 @@ let l = {}, c = {};
|
|
|
1277
189
|
class StoryblokClient {
|
|
1278
190
|
constructor(e2, s2) {
|
|
1279
191
|
if (!s2) {
|
|
1280
|
-
let
|
|
1281
|
-
s2 = e2.oauthToken === void 0 ? `${r2}://api${
|
|
192
|
+
let t2 = e2.region ? "-" + e2.region : "", r2 = e2.https === false ? "http" : "https";
|
|
193
|
+
s2 = e2.oauthToken === void 0 ? `${r2}://api${t2}.storyblok.com/v2` : `${r2}://api${t2}.storyblok.com/v1`;
|
|
1282
194
|
}
|
|
1283
195
|
let n2 = Object.assign({}, e2.headers), o2 = 5;
|
|
1284
|
-
e2.oauthToken !== void 0 && (n2.Authorization = e2.oauthToken, o2 = 3), e2.rateLimit !== void 0 && (o2 = e2.rateLimit), this.richTextResolver = new i(e2.richTextSchema), typeof e2.componentResolver == "function" && this.setComponentResolver(e2.componentResolver), this.maxRetries = e2.maxRetries || 5, this.throttle = r(this.throttledRequest, o2, 1e3), this.accessToken = e2.accessToken, this.relations = {}, this.links = {}, this.cache = e2.cache || { clear: "manual" }, this.client =
|
|
196
|
+
e2.oauthToken !== void 0 && (n2.Authorization = e2.oauthToken, o2 = 3), e2.rateLimit !== void 0 && (o2 = e2.rateLimit), this.richTextResolver = new i(e2.richTextSchema), typeof e2.componentResolver == "function" && this.setComponentResolver(e2.componentResolver), this.maxRetries = e2.maxRetries || 5, this.throttle = r(this.throttledRequest, o2, 1e3), this.accessToken = e2.accessToken, this.relations = {}, this.links = {}, this.cache = e2.cache || { clear: "manual" }, this.client = t.create({ baseURL: s2, timeout: e2.timeout || 0, headers: n2, proxy: e2.proxy || false }), e2.responseInterceptor && this.client.interceptors.response.use((t2) => e2.responseInterceptor(t2));
|
|
1285
197
|
}
|
|
1286
|
-
setComponentResolver(
|
|
198
|
+
setComponentResolver(t2) {
|
|
1287
199
|
this.richTextResolver.addNode("blok", (e2) => {
|
|
1288
200
|
let r2 = "";
|
|
1289
201
|
return e2.attrs.body.forEach((e3) => {
|
|
1290
|
-
r2 +=
|
|
202
|
+
r2 += t2(e3.component, e3);
|
|
1291
203
|
}), { html: r2 };
|
|
1292
204
|
});
|
|
1293
205
|
}
|
|
1294
|
-
parseParams(
|
|
1295
|
-
return
|
|
206
|
+
parseParams(t2 = {}) {
|
|
207
|
+
return t2.version || (t2.version = "published"), t2.token || (t2.token = this.getToken()), t2.cv || (t2.cv = c[t2.token]), Array.isArray(t2.resolve_relations) && (t2.resolve_relations = t2.resolve_relations.join(",")), t2;
|
|
1296
208
|
}
|
|
1297
|
-
factoryParamOptions(
|
|
1298
|
-
return ((
|
|
209
|
+
factoryParamOptions(t2, e2 = {}) {
|
|
210
|
+
return ((t3 = "") => t3.indexOf("/cdn/") > -1)(t2) ? this.parseParams(e2) : e2;
|
|
1299
211
|
}
|
|
1300
|
-
makeRequest(
|
|
1301
|
-
const n2 = this.factoryParamOptions(
|
|
1302
|
-
return this.cacheResponse(
|
|
212
|
+
makeRequest(t2, e2, r2, s2) {
|
|
213
|
+
const n2 = this.factoryParamOptions(t2, ((t3 = {}, e3 = 25, r3 = 1) => __spreadProps(__spreadValues({}, t3), { per_page: e3, page: r3 }))(e2, r2, s2));
|
|
214
|
+
return this.cacheResponse(t2, n2);
|
|
1303
215
|
}
|
|
1304
|
-
get(
|
|
1305
|
-
let r2 = "/" +
|
|
216
|
+
get(t2, e2) {
|
|
217
|
+
let r2 = "/" + t2;
|
|
1306
218
|
const s2 = this.factoryParamOptions(r2, e2);
|
|
1307
219
|
return this.cacheResponse(r2, s2);
|
|
1308
220
|
}
|
|
1309
|
-
async getAll(
|
|
1310
|
-
const s2 = e2.per_page || 25, n2 = "/" +
|
|
221
|
+
async getAll(t2, e2 = {}, r2) {
|
|
222
|
+
const s2 = e2.per_page || 25, n2 = "/" + t2, i2 = n2.split("/");
|
|
1311
223
|
r2 = r2 || i2[i2.length - 1];
|
|
1312
224
|
const a2 = await this.makeRequest(n2, e2, s2, 1), l2 = Math.ceil(a2.total / s2);
|
|
1313
|
-
return ((
|
|
225
|
+
return ((t3 = [], e3) => t3.map(e3).reduce((t4, e4) => [...t4, ...e4], []))([a2, ...await (async (t3 = [], e3) => Promise.all(t3.map(e3)))(o(1, l2), async (t3) => this.makeRequest(n2, e2, s2, t3 + 1))], (t3) => Object.values(t3.data[r2]));
|
|
1314
226
|
}
|
|
1315
|
-
post(
|
|
1316
|
-
let r2 = "/" +
|
|
227
|
+
post(t2, e2) {
|
|
228
|
+
let r2 = "/" + t2;
|
|
1317
229
|
return this.throttle("post", r2, e2);
|
|
1318
230
|
}
|
|
1319
|
-
put(
|
|
1320
|
-
let r2 = "/" +
|
|
231
|
+
put(t2, e2) {
|
|
232
|
+
let r2 = "/" + t2;
|
|
1321
233
|
return this.throttle("put", r2, e2);
|
|
1322
234
|
}
|
|
1323
|
-
delete(
|
|
1324
|
-
let r2 = "/" +
|
|
235
|
+
delete(t2, e2) {
|
|
236
|
+
let r2 = "/" + t2;
|
|
1325
237
|
return this.throttle("delete", r2, e2);
|
|
1326
238
|
}
|
|
1327
|
-
getStories(
|
|
1328
|
-
return this.get("cdn/stories",
|
|
239
|
+
getStories(t2) {
|
|
240
|
+
return this.get("cdn/stories", t2);
|
|
1329
241
|
}
|
|
1330
|
-
getStory(
|
|
1331
|
-
return this.get("cdn/stories/" +
|
|
242
|
+
getStory(t2, e2) {
|
|
243
|
+
return this.get("cdn/stories/" + t2, e2);
|
|
1332
244
|
}
|
|
1333
|
-
setToken(
|
|
1334
|
-
this.accessToken =
|
|
245
|
+
setToken(t2) {
|
|
246
|
+
this.accessToken = t2;
|
|
1335
247
|
}
|
|
1336
248
|
getToken() {
|
|
1337
249
|
return this.accessToken;
|
|
1338
250
|
}
|
|
1339
|
-
_cleanCopy(
|
|
1340
|
-
return JSON.parse(JSON.stringify(
|
|
251
|
+
_cleanCopy(t2) {
|
|
252
|
+
return JSON.parse(JSON.stringify(t2));
|
|
1341
253
|
}
|
|
1342
|
-
_insertLinks(
|
|
1343
|
-
const r2 =
|
|
254
|
+
_insertLinks(t2, e2) {
|
|
255
|
+
const r2 = t2[e2];
|
|
1344
256
|
r2 && r2.fieldtype == "multilink" && r2.linktype == "story" && typeof r2.id == "string" && this.links[r2.id] ? r2.story = this._cleanCopy(this.links[r2.id]) : r2 && r2.linktype === "story" && typeof r2.uuid == "string" && this.links[r2.uuid] && (r2.story = this._cleanCopy(this.links[r2.uuid]));
|
|
1345
257
|
}
|
|
1346
|
-
_insertRelations(
|
|
1347
|
-
if (r2.indexOf(
|
|
1348
|
-
if (typeof
|
|
1349
|
-
this.relations[
|
|
1350
|
-
else if (
|
|
258
|
+
_insertRelations(t2, e2, r2) {
|
|
259
|
+
if (r2.indexOf(t2.component + "." + e2) > -1) {
|
|
260
|
+
if (typeof t2[e2] == "string")
|
|
261
|
+
this.relations[t2[e2]] && (t2[e2] = this._cleanCopy(this.relations[t2[e2]]));
|
|
262
|
+
else if (t2[e2].constructor === Array) {
|
|
1351
263
|
let r3 = [];
|
|
1352
|
-
|
|
1353
|
-
this.relations[
|
|
1354
|
-
}),
|
|
264
|
+
t2[e2].forEach((t3) => {
|
|
265
|
+
this.relations[t3] && r3.push(this._cleanCopy(this.relations[t3]));
|
|
266
|
+
}), t2[e2] = r3;
|
|
1355
267
|
}
|
|
1356
268
|
}
|
|
1357
269
|
}
|
|
1358
|
-
iterateTree(
|
|
1359
|
-
let r2 = (
|
|
1360
|
-
if (
|
|
1361
|
-
if (
|
|
1362
|
-
for (let e3 = 0; e3 <
|
|
1363
|
-
r2(
|
|
1364
|
-
else if (
|
|
1365
|
-
if (
|
|
270
|
+
iterateTree(t2, e2) {
|
|
271
|
+
let r2 = (t3) => {
|
|
272
|
+
if (t3 != null) {
|
|
273
|
+
if (t3.constructor === Array)
|
|
274
|
+
for (let e3 = 0; e3 < t3.length; e3++)
|
|
275
|
+
r2(t3[e3]);
|
|
276
|
+
else if (t3.constructor === Object) {
|
|
277
|
+
if (t3._stopResolving)
|
|
1366
278
|
return;
|
|
1367
|
-
for (let s2 in
|
|
1368
|
-
(
|
|
279
|
+
for (let s2 in t3)
|
|
280
|
+
(t3.component && t3._uid || t3.type === "link") && (this._insertRelations(t3, s2, e2), this._insertLinks(t3, s2)), r2(t3[s2]);
|
|
1369
281
|
}
|
|
1370
282
|
}
|
|
1371
283
|
};
|
|
1372
|
-
r2(
|
|
284
|
+
r2(t2.content);
|
|
1373
285
|
}
|
|
1374
|
-
async resolveLinks(
|
|
286
|
+
async resolveLinks(t2, e2) {
|
|
1375
287
|
let r2 = [];
|
|
1376
|
-
if (
|
|
1377
|
-
const s2 =
|
|
288
|
+
if (t2.link_uuids) {
|
|
289
|
+
const s2 = t2.link_uuids.length;
|
|
1378
290
|
let n2 = [];
|
|
1379
291
|
const i2 = 50;
|
|
1380
292
|
for (let e3 = 0; e3 < s2; e3 += i2) {
|
|
1381
293
|
const r3 = Math.min(s2, e3 + i2);
|
|
1382
|
-
n2.push(
|
|
294
|
+
n2.push(t2.link_uuids.slice(e3, r3));
|
|
1383
295
|
}
|
|
1384
|
-
for (let
|
|
1385
|
-
(await this.getStories({ per_page: i2, language: e2.language, version: e2.version, by_uuids: n2[
|
|
1386
|
-
r2.push(
|
|
296
|
+
for (let t3 = 0; t3 < n2.length; t3++) {
|
|
297
|
+
(await this.getStories({ per_page: i2, language: e2.language, version: e2.version, by_uuids: n2[t3].join(",") })).data.stories.forEach((t4) => {
|
|
298
|
+
r2.push(t4);
|
|
1387
299
|
});
|
|
1388
300
|
}
|
|
1389
301
|
} else
|
|
1390
|
-
r2 =
|
|
1391
|
-
r2.forEach((
|
|
1392
|
-
this.links[
|
|
302
|
+
r2 = t2.links;
|
|
303
|
+
r2.forEach((t3) => {
|
|
304
|
+
this.links[t3.uuid] = __spreadProps(__spreadValues({}, t3), { _stopResolving: true });
|
|
1393
305
|
});
|
|
1394
306
|
}
|
|
1395
|
-
async resolveRelations(
|
|
307
|
+
async resolveRelations(t2, e2) {
|
|
1396
308
|
let r2 = [];
|
|
1397
|
-
if (
|
|
1398
|
-
const s2 =
|
|
309
|
+
if (t2.rel_uuids) {
|
|
310
|
+
const s2 = t2.rel_uuids.length;
|
|
1399
311
|
let n2 = [];
|
|
1400
312
|
const i2 = 50;
|
|
1401
313
|
for (let e3 = 0; e3 < s2; e3 += i2) {
|
|
1402
314
|
const r3 = Math.min(s2, e3 + i2);
|
|
1403
|
-
n2.push(
|
|
315
|
+
n2.push(t2.rel_uuids.slice(e3, r3));
|
|
1404
316
|
}
|
|
1405
|
-
for (let
|
|
1406
|
-
(await this.getStories({ per_page: i2, language: e2.language, version: e2.version, by_uuids: n2[
|
|
1407
|
-
r2.push(
|
|
317
|
+
for (let t3 = 0; t3 < n2.length; t3++) {
|
|
318
|
+
(await this.getStories({ per_page: i2, language: e2.language, version: e2.version, by_uuids: n2[t3].join(",") })).data.stories.forEach((t4) => {
|
|
319
|
+
r2.push(t4);
|
|
1408
320
|
});
|
|
1409
321
|
}
|
|
1410
322
|
} else
|
|
1411
|
-
r2 =
|
|
1412
|
-
r2.forEach((
|
|
1413
|
-
this.relations[
|
|
323
|
+
r2 = t2.rels;
|
|
324
|
+
r2.forEach((t3) => {
|
|
325
|
+
this.relations[t3.uuid] = __spreadProps(__spreadValues({}, t3), { _stopResolving: true });
|
|
1414
326
|
});
|
|
1415
327
|
}
|
|
1416
|
-
async resolveStories(
|
|
328
|
+
async resolveStories(t2, e2) {
|
|
1417
329
|
let r2 = [];
|
|
1418
|
-
e2.resolve_relations !== void 0 && e2.resolve_relations.length > 0 && (r2 = e2.resolve_relations.split(","), await this.resolveRelations(
|
|
1419
|
-
for (const
|
|
1420
|
-
this.iterateTree(this.relations[
|
|
1421
|
-
|
|
1422
|
-
this.iterateTree(
|
|
330
|
+
e2.resolve_relations !== void 0 && e2.resolve_relations.length > 0 && (r2 = e2.resolve_relations.split(","), await this.resolveRelations(t2, e2)), ["1", "story", "url"].indexOf(e2.resolve_links) > -1 && await this.resolveLinks(t2, e2);
|
|
331
|
+
for (const t3 in this.relations)
|
|
332
|
+
this.iterateTree(this.relations[t3], r2);
|
|
333
|
+
t2.story ? this.iterateTree(t2.story, r2) : t2.stories.forEach((t3) => {
|
|
334
|
+
this.iterateTree(t3, r2);
|
|
1423
335
|
});
|
|
1424
336
|
}
|
|
1425
|
-
cacheResponse(
|
|
337
|
+
cacheResponse(t2, e2, r2) {
|
|
1426
338
|
return r2 === void 0 && (r2 = 0), new Promise(async (s2, n2) => {
|
|
1427
|
-
let i2 = a({ url:
|
|
1428
|
-
if (this.cache.clear === "auto" && e2.version === "draft" && await this.flushCache(), e2.version === "published" &&
|
|
1429
|
-
const
|
|
1430
|
-
if (
|
|
1431
|
-
return s2(
|
|
339
|
+
let i2 = a({ url: t2, params: e2 }), o2 = this.cacheProvider();
|
|
340
|
+
if (this.cache.clear === "auto" && e2.version === "draft" && await this.flushCache(), e2.version === "published" && t2 != "/cdn/spaces/me") {
|
|
341
|
+
const t3 = await o2.get(i2);
|
|
342
|
+
if (t3)
|
|
343
|
+
return s2(t3);
|
|
1432
344
|
}
|
|
1433
345
|
try {
|
|
1434
|
-
let r3 = await this.throttle("get",
|
|
346
|
+
let r3 = await this.throttle("get", t2, { params: e2, paramsSerializer: (t3) => a(t3) }), l3 = { data: r3.data, headers: r3.headers };
|
|
1435
347
|
if (r3.headers["per-page"] && (l3 = Object.assign({}, l3, { perPage: parseInt(r3.headers["per-page"]), total: parseInt(r3.headers.total) })), r3.status != 200)
|
|
1436
348
|
return n2(r3);
|
|
1437
|
-
(l3.data.story || l3.data.stories) && await this.resolveStories(l3.data, e2), e2.version === "published" &&
|
|
349
|
+
(l3.data.story || l3.data.stories) && await this.resolveStories(l3.data, e2), e2.version === "published" && t2 != "/cdn/spaces/me" && o2.set(i2, l3), l3.data.cv && (e2.version == "draft" && c[e2.token] != l3.data.cv && this.flushCache(), c[e2.token] = l3.data.cv), s2(l3);
|
|
1438
350
|
} catch (i3) {
|
|
1439
351
|
if (i3.response && i3.response.status === 429 && (r2 += 1) < this.maxRetries)
|
|
1440
|
-
return console.log(`Hit rate limit. Retrying in ${r2} seconds.`), await (l2 = 1e3 * r2, new Promise((
|
|
352
|
+
return console.log(`Hit rate limit. Retrying in ${r2} seconds.`), await (l2 = 1e3 * r2, new Promise((t3) => setTimeout(t3, l2))), this.cacheResponse(t2, e2, r2).then(s2).catch(n2);
|
|
1441
353
|
n2(i3);
|
|
1442
354
|
}
|
|
1443
355
|
var l2;
|
|
1444
356
|
});
|
|
1445
357
|
}
|
|
1446
|
-
throttledRequest(
|
|
1447
|
-
return this.client[
|
|
358
|
+
throttledRequest(t2, e2, r2) {
|
|
359
|
+
return this.client[t2](e2, r2);
|
|
1448
360
|
}
|
|
1449
361
|
cacheVersions() {
|
|
1450
362
|
return c;
|
|
@@ -1452,14 +364,14 @@ class StoryblokClient {
|
|
|
1452
364
|
cacheVersion() {
|
|
1453
365
|
return c[this.accessToken];
|
|
1454
366
|
}
|
|
1455
|
-
setCacheVersion(
|
|
1456
|
-
this.accessToken && (c[this.accessToken] =
|
|
367
|
+
setCacheVersion(t2) {
|
|
368
|
+
this.accessToken && (c[this.accessToken] = t2);
|
|
1457
369
|
}
|
|
1458
370
|
cacheProvider() {
|
|
1459
371
|
switch (this.cache.type) {
|
|
1460
372
|
case "memory":
|
|
1461
|
-
return { get: (
|
|
1462
|
-
l[
|
|
373
|
+
return { get: (t2) => l[t2], getAll: () => l, set(t2, e2) {
|
|
374
|
+
l[t2] = e2;
|
|
1463
375
|
}, flush() {
|
|
1464
376
|
l = {};
|
|
1465
377
|
} };
|
|
@@ -1514,11 +426,11 @@ const useStoryblokBridge = (id, cb, options = {}) => {
|
|
|
1514
426
|
});
|
|
1515
427
|
};
|
|
1516
428
|
const storyblokInit = (pluginOptions = {}) => {
|
|
1517
|
-
const { bridge, accessToken, use
|
|
429
|
+
const { bridge, accessToken, use = [], apiOptions = {} } = pluginOptions;
|
|
1518
430
|
apiOptions.accessToken = apiOptions.accessToken || accessToken;
|
|
1519
431
|
const options = { bridge, apiOptions };
|
|
1520
432
|
let result = {};
|
|
1521
|
-
|
|
433
|
+
use.forEach((pluginFactory) => {
|
|
1522
434
|
result = __spreadValues(__spreadValues({}, result), pluginFactory(options));
|
|
1523
435
|
});
|
|
1524
436
|
if (bridge !== false) {
|