@sanity/client 4.0.0-alpha.esm.2 → 4.0.0-alpha.esm.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/browser/sanityClient.js +1297 -10
- package/dist/node/sanityClient.js +6123 -17
- package/package.json +2 -2
|
@@ -1,3 +1,1273 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
19
|
+
|
|
20
|
+
// node_modules/nano-pubsub/index.js
|
|
21
|
+
var require_nano_pubsub = __commonJS({
|
|
22
|
+
"node_modules/nano-pubsub/index.js"(exports, module) {
|
|
23
|
+
module.exports = function Pubsub() {
|
|
24
|
+
var subscribers = [];
|
|
25
|
+
return {
|
|
26
|
+
subscribe,
|
|
27
|
+
publish
|
|
28
|
+
};
|
|
29
|
+
function subscribe(subscriber) {
|
|
30
|
+
subscribers.push(subscriber);
|
|
31
|
+
return function unsubscribe() {
|
|
32
|
+
var idx = subscribers.indexOf(subscriber);
|
|
33
|
+
if (idx > -1) {
|
|
34
|
+
subscribers.splice(idx, 1);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function publish() {
|
|
39
|
+
for (var i = 0; i < subscribers.length; i++) {
|
|
40
|
+
subscribers[i].apply(null, arguments);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// node_modules/get-it/lib/util/middlewareReducer.js
|
|
48
|
+
var require_middlewareReducer = __commonJS({
|
|
49
|
+
"node_modules/get-it/lib/util/middlewareReducer.js"(exports, module) {
|
|
50
|
+
"use strict";
|
|
51
|
+
module.exports = function(middleware3) {
|
|
52
|
+
var applyMiddleware = function applyMiddleware2(hook, defaultValue) {
|
|
53
|
+
var bailEarly = hook === "onError";
|
|
54
|
+
var value = defaultValue;
|
|
55
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
56
|
+
args[_key - 2] = arguments[_key];
|
|
57
|
+
}
|
|
58
|
+
for (var i = 0; i < middleware3[hook].length; i++) {
|
|
59
|
+
var handler = middleware3[hook][i];
|
|
60
|
+
value = handler.apply(void 0, [value].concat(args));
|
|
61
|
+
if (bailEarly && !value) {
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return value;
|
|
66
|
+
};
|
|
67
|
+
return applyMiddleware;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// node_modules/object-assign/index.js
|
|
73
|
+
var require_object_assign = __commonJS({
|
|
74
|
+
"node_modules/object-assign/index.js"(exports, module) {
|
|
75
|
+
"use strict";
|
|
76
|
+
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
77
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
78
|
+
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
|
79
|
+
function toObject(val) {
|
|
80
|
+
if (val === null || val === void 0) {
|
|
81
|
+
throw new TypeError("Object.assign cannot be called with null or undefined");
|
|
82
|
+
}
|
|
83
|
+
return Object(val);
|
|
84
|
+
}
|
|
85
|
+
function shouldUseNative() {
|
|
86
|
+
try {
|
|
87
|
+
if (!Object.assign) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
var test1 = new String("abc");
|
|
91
|
+
test1[5] = "de";
|
|
92
|
+
if (Object.getOwnPropertyNames(test1)[0] === "5") {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
var test2 = {};
|
|
96
|
+
for (var i = 0; i < 10; i++) {
|
|
97
|
+
test2["_" + String.fromCharCode(i)] = i;
|
|
98
|
+
}
|
|
99
|
+
var order2 = Object.getOwnPropertyNames(test2).map(function(n) {
|
|
100
|
+
return test2[n];
|
|
101
|
+
});
|
|
102
|
+
if (order2.join("") !== "0123456789") {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
var test3 = {};
|
|
106
|
+
"abcdefghijklmnopqrst".split("").forEach(function(letter) {
|
|
107
|
+
test3[letter] = letter;
|
|
108
|
+
});
|
|
109
|
+
if (Object.keys(Object.assign({}, test3)).join("") !== "abcdefghijklmnopqrst") {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
return true;
|
|
113
|
+
} catch (err) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
module.exports = shouldUseNative() ? Object.assign : function(target, source) {
|
|
118
|
+
var from;
|
|
119
|
+
var to = toObject(target);
|
|
120
|
+
var symbols;
|
|
121
|
+
for (var s = 1; s < arguments.length; s++) {
|
|
122
|
+
from = Object(arguments[s]);
|
|
123
|
+
for (var key in from) {
|
|
124
|
+
if (hasOwnProperty.call(from, key)) {
|
|
125
|
+
to[key] = from[key];
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (getOwnPropertySymbols) {
|
|
129
|
+
symbols = getOwnPropertySymbols(from);
|
|
130
|
+
for (var i = 0; i < symbols.length; i++) {
|
|
131
|
+
if (propIsEnumerable.call(from, symbols[i])) {
|
|
132
|
+
to[symbols[i]] = from[symbols[i]];
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return to;
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// node_modules/requires-port/index.js
|
|
143
|
+
var require_requires_port = __commonJS({
|
|
144
|
+
"node_modules/requires-port/index.js"(exports, module) {
|
|
145
|
+
"use strict";
|
|
146
|
+
module.exports = function required(port, protocol) {
|
|
147
|
+
protocol = protocol.split(":")[0];
|
|
148
|
+
port = +port;
|
|
149
|
+
if (!port)
|
|
150
|
+
return false;
|
|
151
|
+
switch (protocol) {
|
|
152
|
+
case "http":
|
|
153
|
+
case "ws":
|
|
154
|
+
return port !== 80;
|
|
155
|
+
case "https":
|
|
156
|
+
case "wss":
|
|
157
|
+
return port !== 443;
|
|
158
|
+
case "ftp":
|
|
159
|
+
return port !== 21;
|
|
160
|
+
case "gopher":
|
|
161
|
+
return port !== 70;
|
|
162
|
+
case "file":
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
return port !== 0;
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
// node_modules/querystringify/index.js
|
|
171
|
+
var require_querystringify = __commonJS({
|
|
172
|
+
"node_modules/querystringify/index.js"(exports) {
|
|
173
|
+
"use strict";
|
|
174
|
+
var has = Object.prototype.hasOwnProperty;
|
|
175
|
+
var undef;
|
|
176
|
+
function decode(input) {
|
|
177
|
+
try {
|
|
178
|
+
return decodeURIComponent(input.replace(/\+/g, " "));
|
|
179
|
+
} catch (e) {
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function encode(input) {
|
|
184
|
+
try {
|
|
185
|
+
return encodeURIComponent(input);
|
|
186
|
+
} catch (e) {
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
function querystring(query) {
|
|
191
|
+
var parser = /([^=?#&]+)=?([^&]*)/g, result = {}, part;
|
|
192
|
+
while (part = parser.exec(query)) {
|
|
193
|
+
var key = decode(part[1]), value = decode(part[2]);
|
|
194
|
+
if (key === null || value === null || key in result)
|
|
195
|
+
continue;
|
|
196
|
+
result[key] = value;
|
|
197
|
+
}
|
|
198
|
+
return result;
|
|
199
|
+
}
|
|
200
|
+
function querystringify(obj, prefix) {
|
|
201
|
+
prefix = prefix || "";
|
|
202
|
+
var pairs = [], value, key;
|
|
203
|
+
if (typeof prefix !== "string")
|
|
204
|
+
prefix = "?";
|
|
205
|
+
for (key in obj) {
|
|
206
|
+
if (has.call(obj, key)) {
|
|
207
|
+
value = obj[key];
|
|
208
|
+
if (!value && (value === null || value === undef || isNaN(value))) {
|
|
209
|
+
value = "";
|
|
210
|
+
}
|
|
211
|
+
key = encode(key);
|
|
212
|
+
value = encode(value);
|
|
213
|
+
if (key === null || value === null)
|
|
214
|
+
continue;
|
|
215
|
+
pairs.push(key + "=" + value);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return pairs.length ? prefix + pairs.join("&") : "";
|
|
219
|
+
}
|
|
220
|
+
exports.stringify = querystringify;
|
|
221
|
+
exports.parse = querystring;
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
// node_modules/url-parse/index.js
|
|
226
|
+
var require_url_parse = __commonJS({
|
|
227
|
+
"node_modules/url-parse/index.js"(exports, module) {
|
|
228
|
+
"use strict";
|
|
229
|
+
var required = require_requires_port();
|
|
230
|
+
var qs = require_querystringify();
|
|
231
|
+
var controlOrWhitespace = /^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/;
|
|
232
|
+
var CRHTLF = /[\n\r\t]/g;
|
|
233
|
+
var slashes = /^[A-Za-z][A-Za-z0-9+-.]*:\/\//;
|
|
234
|
+
var port = /:\d+$/;
|
|
235
|
+
var protocolre = /^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i;
|
|
236
|
+
var windowsDriveLetter = /^[a-zA-Z]:/;
|
|
237
|
+
function trimLeft(str) {
|
|
238
|
+
return (str ? str : "").toString().replace(controlOrWhitespace, "");
|
|
239
|
+
}
|
|
240
|
+
var rules = [
|
|
241
|
+
["#", "hash"],
|
|
242
|
+
["?", "query"],
|
|
243
|
+
function sanitize(address, url) {
|
|
244
|
+
return isSpecial(url.protocol) ? address.replace(/\\/g, "/") : address;
|
|
245
|
+
},
|
|
246
|
+
["/", "pathname"],
|
|
247
|
+
["@", "auth", 1],
|
|
248
|
+
[NaN, "host", void 0, 1, 1],
|
|
249
|
+
[/:(\d*)$/, "port", void 0, 1],
|
|
250
|
+
[NaN, "hostname", void 0, 1, 1]
|
|
251
|
+
];
|
|
252
|
+
var ignore = { hash: 1, query: 1 };
|
|
253
|
+
function lolcation(loc) {
|
|
254
|
+
var globalVar;
|
|
255
|
+
if (typeof window !== "undefined")
|
|
256
|
+
globalVar = window;
|
|
257
|
+
else if (typeof global !== "undefined")
|
|
258
|
+
globalVar = global;
|
|
259
|
+
else if (typeof self !== "undefined")
|
|
260
|
+
globalVar = self;
|
|
261
|
+
else
|
|
262
|
+
globalVar = {};
|
|
263
|
+
var location = globalVar.location || {};
|
|
264
|
+
loc = loc || location;
|
|
265
|
+
var finaldestination = {}, type = typeof loc, key;
|
|
266
|
+
if (loc.protocol === "blob:") {
|
|
267
|
+
finaldestination = new Url(unescape(loc.pathname), {});
|
|
268
|
+
} else if (type === "string") {
|
|
269
|
+
finaldestination = new Url(loc, {});
|
|
270
|
+
for (key in ignore)
|
|
271
|
+
delete finaldestination[key];
|
|
272
|
+
} else if (type === "object") {
|
|
273
|
+
for (key in loc) {
|
|
274
|
+
if (key in ignore)
|
|
275
|
+
continue;
|
|
276
|
+
finaldestination[key] = loc[key];
|
|
277
|
+
}
|
|
278
|
+
if (finaldestination.slashes === void 0) {
|
|
279
|
+
finaldestination.slashes = slashes.test(loc.href);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return finaldestination;
|
|
283
|
+
}
|
|
284
|
+
function isSpecial(scheme) {
|
|
285
|
+
return scheme === "file:" || scheme === "ftp:" || scheme === "http:" || scheme === "https:" || scheme === "ws:" || scheme === "wss:";
|
|
286
|
+
}
|
|
287
|
+
function extractProtocol(address, location) {
|
|
288
|
+
address = trimLeft(address);
|
|
289
|
+
address = address.replace(CRHTLF, "");
|
|
290
|
+
location = location || {};
|
|
291
|
+
var match = protocolre.exec(address);
|
|
292
|
+
var protocol = match[1] ? match[1].toLowerCase() : "";
|
|
293
|
+
var forwardSlashes = !!match[2];
|
|
294
|
+
var otherSlashes = !!match[3];
|
|
295
|
+
var slashesCount = 0;
|
|
296
|
+
var rest;
|
|
297
|
+
if (forwardSlashes) {
|
|
298
|
+
if (otherSlashes) {
|
|
299
|
+
rest = match[2] + match[3] + match[4];
|
|
300
|
+
slashesCount = match[2].length + match[3].length;
|
|
301
|
+
} else {
|
|
302
|
+
rest = match[2] + match[4];
|
|
303
|
+
slashesCount = match[2].length;
|
|
304
|
+
}
|
|
305
|
+
} else {
|
|
306
|
+
if (otherSlashes) {
|
|
307
|
+
rest = match[3] + match[4];
|
|
308
|
+
slashesCount = match[3].length;
|
|
309
|
+
} else {
|
|
310
|
+
rest = match[4];
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
if (protocol === "file:") {
|
|
314
|
+
if (slashesCount >= 2) {
|
|
315
|
+
rest = rest.slice(2);
|
|
316
|
+
}
|
|
317
|
+
} else if (isSpecial(protocol)) {
|
|
318
|
+
rest = match[4];
|
|
319
|
+
} else if (protocol) {
|
|
320
|
+
if (forwardSlashes) {
|
|
321
|
+
rest = rest.slice(2);
|
|
322
|
+
}
|
|
323
|
+
} else if (slashesCount >= 2 && isSpecial(location.protocol)) {
|
|
324
|
+
rest = match[4];
|
|
325
|
+
}
|
|
326
|
+
return {
|
|
327
|
+
protocol,
|
|
328
|
+
slashes: forwardSlashes || isSpecial(protocol),
|
|
329
|
+
slashesCount,
|
|
330
|
+
rest
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
function resolve(relative, base) {
|
|
334
|
+
if (relative === "")
|
|
335
|
+
return base;
|
|
336
|
+
var path = (base || "/").split("/").slice(0, -1).concat(relative.split("/")), i = path.length, last = path[i - 1], unshift = false, up = 0;
|
|
337
|
+
while (i--) {
|
|
338
|
+
if (path[i] === ".") {
|
|
339
|
+
path.splice(i, 1);
|
|
340
|
+
} else if (path[i] === "..") {
|
|
341
|
+
path.splice(i, 1);
|
|
342
|
+
up++;
|
|
343
|
+
} else if (up) {
|
|
344
|
+
if (i === 0)
|
|
345
|
+
unshift = true;
|
|
346
|
+
path.splice(i, 1);
|
|
347
|
+
up--;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
if (unshift)
|
|
351
|
+
path.unshift("");
|
|
352
|
+
if (last === "." || last === "..")
|
|
353
|
+
path.push("");
|
|
354
|
+
return path.join("/");
|
|
355
|
+
}
|
|
356
|
+
function Url(address, location, parser) {
|
|
357
|
+
address = trimLeft(address);
|
|
358
|
+
address = address.replace(CRHTLF, "");
|
|
359
|
+
if (!(this instanceof Url)) {
|
|
360
|
+
return new Url(address, location, parser);
|
|
361
|
+
}
|
|
362
|
+
var relative, extracted, parse, instruction, index, key, instructions = rules.slice(), type = typeof location, url = this, i = 0;
|
|
363
|
+
if (type !== "object" && type !== "string") {
|
|
364
|
+
parser = location;
|
|
365
|
+
location = null;
|
|
366
|
+
}
|
|
367
|
+
if (parser && typeof parser !== "function")
|
|
368
|
+
parser = qs.parse;
|
|
369
|
+
location = lolcation(location);
|
|
370
|
+
extracted = extractProtocol(address || "", location);
|
|
371
|
+
relative = !extracted.protocol && !extracted.slashes;
|
|
372
|
+
url.slashes = extracted.slashes || relative && location.slashes;
|
|
373
|
+
url.protocol = extracted.protocol || location.protocol || "";
|
|
374
|
+
address = extracted.rest;
|
|
375
|
+
if (extracted.protocol === "file:" && (extracted.slashesCount !== 2 || windowsDriveLetter.test(address)) || !extracted.slashes && (extracted.protocol || extracted.slashesCount < 2 || !isSpecial(url.protocol))) {
|
|
376
|
+
instructions[3] = [/(.*)/, "pathname"];
|
|
377
|
+
}
|
|
378
|
+
for (; i < instructions.length; i++) {
|
|
379
|
+
instruction = instructions[i];
|
|
380
|
+
if (typeof instruction === "function") {
|
|
381
|
+
address = instruction(address, url);
|
|
382
|
+
continue;
|
|
383
|
+
}
|
|
384
|
+
parse = instruction[0];
|
|
385
|
+
key = instruction[1];
|
|
386
|
+
if (parse !== parse) {
|
|
387
|
+
url[key] = address;
|
|
388
|
+
} else if (typeof parse === "string") {
|
|
389
|
+
index = parse === "@" ? address.lastIndexOf(parse) : address.indexOf(parse);
|
|
390
|
+
if (~index) {
|
|
391
|
+
if (typeof instruction[2] === "number") {
|
|
392
|
+
url[key] = address.slice(0, index);
|
|
393
|
+
address = address.slice(index + instruction[2]);
|
|
394
|
+
} else {
|
|
395
|
+
url[key] = address.slice(index);
|
|
396
|
+
address = address.slice(0, index);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
} else if (index = parse.exec(address)) {
|
|
400
|
+
url[key] = index[1];
|
|
401
|
+
address = address.slice(0, index.index);
|
|
402
|
+
}
|
|
403
|
+
url[key] = url[key] || (relative && instruction[3] ? location[key] || "" : "");
|
|
404
|
+
if (instruction[4])
|
|
405
|
+
url[key] = url[key].toLowerCase();
|
|
406
|
+
}
|
|
407
|
+
if (parser)
|
|
408
|
+
url.query = parser(url.query);
|
|
409
|
+
if (relative && location.slashes && url.pathname.charAt(0) !== "/" && (url.pathname !== "" || location.pathname !== "")) {
|
|
410
|
+
url.pathname = resolve(url.pathname, location.pathname);
|
|
411
|
+
}
|
|
412
|
+
if (url.pathname.charAt(0) !== "/" && isSpecial(url.protocol)) {
|
|
413
|
+
url.pathname = "/" + url.pathname;
|
|
414
|
+
}
|
|
415
|
+
if (!required(url.port, url.protocol)) {
|
|
416
|
+
url.host = url.hostname;
|
|
417
|
+
url.port = "";
|
|
418
|
+
}
|
|
419
|
+
url.username = url.password = "";
|
|
420
|
+
if (url.auth) {
|
|
421
|
+
index = url.auth.indexOf(":");
|
|
422
|
+
if (~index) {
|
|
423
|
+
url.username = url.auth.slice(0, index);
|
|
424
|
+
url.username = encodeURIComponent(decodeURIComponent(url.username));
|
|
425
|
+
url.password = url.auth.slice(index + 1);
|
|
426
|
+
url.password = encodeURIComponent(decodeURIComponent(url.password));
|
|
427
|
+
} else {
|
|
428
|
+
url.username = encodeURIComponent(decodeURIComponent(url.auth));
|
|
429
|
+
}
|
|
430
|
+
url.auth = url.password ? url.username + ":" + url.password : url.username;
|
|
431
|
+
}
|
|
432
|
+
url.origin = url.protocol !== "file:" && isSpecial(url.protocol) && url.host ? url.protocol + "//" + url.host : "null";
|
|
433
|
+
url.href = url.toString();
|
|
434
|
+
}
|
|
435
|
+
function set(part, value, fn) {
|
|
436
|
+
var url = this;
|
|
437
|
+
switch (part) {
|
|
438
|
+
case "query":
|
|
439
|
+
if (typeof value === "string" && value.length) {
|
|
440
|
+
value = (fn || qs.parse)(value);
|
|
441
|
+
}
|
|
442
|
+
url[part] = value;
|
|
443
|
+
break;
|
|
444
|
+
case "port":
|
|
445
|
+
url[part] = value;
|
|
446
|
+
if (!required(value, url.protocol)) {
|
|
447
|
+
url.host = url.hostname;
|
|
448
|
+
url[part] = "";
|
|
449
|
+
} else if (value) {
|
|
450
|
+
url.host = url.hostname + ":" + value;
|
|
451
|
+
}
|
|
452
|
+
break;
|
|
453
|
+
case "hostname":
|
|
454
|
+
url[part] = value;
|
|
455
|
+
if (url.port)
|
|
456
|
+
value += ":" + url.port;
|
|
457
|
+
url.host = value;
|
|
458
|
+
break;
|
|
459
|
+
case "host":
|
|
460
|
+
url[part] = value;
|
|
461
|
+
if (port.test(value)) {
|
|
462
|
+
value = value.split(":");
|
|
463
|
+
url.port = value.pop();
|
|
464
|
+
url.hostname = value.join(":");
|
|
465
|
+
} else {
|
|
466
|
+
url.hostname = value;
|
|
467
|
+
url.port = "";
|
|
468
|
+
}
|
|
469
|
+
break;
|
|
470
|
+
case "protocol":
|
|
471
|
+
url.protocol = value.toLowerCase();
|
|
472
|
+
url.slashes = !fn;
|
|
473
|
+
break;
|
|
474
|
+
case "pathname":
|
|
475
|
+
case "hash":
|
|
476
|
+
if (value) {
|
|
477
|
+
var char = part === "pathname" ? "/" : "#";
|
|
478
|
+
url[part] = value.charAt(0) !== char ? char + value : value;
|
|
479
|
+
} else {
|
|
480
|
+
url[part] = value;
|
|
481
|
+
}
|
|
482
|
+
break;
|
|
483
|
+
case "username":
|
|
484
|
+
case "password":
|
|
485
|
+
url[part] = encodeURIComponent(value);
|
|
486
|
+
break;
|
|
487
|
+
case "auth":
|
|
488
|
+
var index = value.indexOf(":");
|
|
489
|
+
if (~index) {
|
|
490
|
+
url.username = value.slice(0, index);
|
|
491
|
+
url.username = encodeURIComponent(decodeURIComponent(url.username));
|
|
492
|
+
url.password = value.slice(index + 1);
|
|
493
|
+
url.password = encodeURIComponent(decodeURIComponent(url.password));
|
|
494
|
+
} else {
|
|
495
|
+
url.username = encodeURIComponent(decodeURIComponent(value));
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
for (var i = 0; i < rules.length; i++) {
|
|
499
|
+
var ins = rules[i];
|
|
500
|
+
if (ins[4])
|
|
501
|
+
url[ins[1]] = url[ins[1]].toLowerCase();
|
|
502
|
+
}
|
|
503
|
+
url.auth = url.password ? url.username + ":" + url.password : url.username;
|
|
504
|
+
url.origin = url.protocol !== "file:" && isSpecial(url.protocol) && url.host ? url.protocol + "//" + url.host : "null";
|
|
505
|
+
url.href = url.toString();
|
|
506
|
+
return url;
|
|
507
|
+
}
|
|
508
|
+
function toString(stringify) {
|
|
509
|
+
if (!stringify || typeof stringify !== "function")
|
|
510
|
+
stringify = qs.stringify;
|
|
511
|
+
var query, url = this, host = url.host, protocol = url.protocol;
|
|
512
|
+
if (protocol && protocol.charAt(protocol.length - 1) !== ":")
|
|
513
|
+
protocol += ":";
|
|
514
|
+
var result = protocol + (url.protocol && url.slashes || isSpecial(url.protocol) ? "//" : "");
|
|
515
|
+
if (url.username) {
|
|
516
|
+
result += url.username;
|
|
517
|
+
if (url.password)
|
|
518
|
+
result += ":" + url.password;
|
|
519
|
+
result += "@";
|
|
520
|
+
} else if (url.password) {
|
|
521
|
+
result += ":" + url.password;
|
|
522
|
+
result += "@";
|
|
523
|
+
} else if (url.protocol !== "file:" && isSpecial(url.protocol) && !host && url.pathname !== "/") {
|
|
524
|
+
result += "@";
|
|
525
|
+
}
|
|
526
|
+
if (host[host.length - 1] === ":" || port.test(url.hostname) && !url.port) {
|
|
527
|
+
host += ":";
|
|
528
|
+
}
|
|
529
|
+
result += host + url.pathname;
|
|
530
|
+
query = typeof url.query === "object" ? stringify(url.query) : url.query;
|
|
531
|
+
if (query)
|
|
532
|
+
result += query.charAt(0) !== "?" ? "?" + query : query;
|
|
533
|
+
if (url.hash)
|
|
534
|
+
result += url.hash;
|
|
535
|
+
return result;
|
|
536
|
+
}
|
|
537
|
+
Url.prototype = { set, toString };
|
|
538
|
+
Url.extractProtocol = extractProtocol;
|
|
539
|
+
Url.location = lolcation;
|
|
540
|
+
Url.trimLeft = trimLeft;
|
|
541
|
+
Url.qs = qs;
|
|
542
|
+
module.exports = Url;
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
|
|
546
|
+
// node_modules/get-it/lib/middleware/defaultOptionsProcessor.js
|
|
547
|
+
var require_defaultOptionsProcessor = __commonJS({
|
|
548
|
+
"node_modules/get-it/lib/middleware/defaultOptionsProcessor.js"(exports, module) {
|
|
549
|
+
"use strict";
|
|
550
|
+
var objectAssign = require_object_assign();
|
|
551
|
+
var urlParse = require_url_parse();
|
|
552
|
+
var isReactNative = typeof navigator === "undefined" ? false : navigator.product === "ReactNative";
|
|
553
|
+
var has = Object.prototype.hasOwnProperty;
|
|
554
|
+
var defaultOptions2 = {
|
|
555
|
+
timeout: isReactNative ? 6e4 : 12e4
|
|
556
|
+
};
|
|
557
|
+
module.exports = function(opts) {
|
|
558
|
+
var options = typeof opts === "string" ? objectAssign({
|
|
559
|
+
url: opts
|
|
560
|
+
}, defaultOptions2) : objectAssign({}, defaultOptions2, opts);
|
|
561
|
+
var url = urlParse(options.url, {}, true);
|
|
562
|
+
options.timeout = normalizeTimeout(options.timeout);
|
|
563
|
+
if (options.query) {
|
|
564
|
+
url.query = objectAssign({}, url.query, removeUndefined(options.query));
|
|
565
|
+
}
|
|
566
|
+
options.method = options.body && !options.method ? "POST" : (options.method || "GET").toUpperCase();
|
|
567
|
+
options.url = url.toString(stringifyQueryString);
|
|
568
|
+
return options;
|
|
569
|
+
};
|
|
570
|
+
function stringifyQueryString(obj) {
|
|
571
|
+
var pairs = [];
|
|
572
|
+
for (var key in obj) {
|
|
573
|
+
if (has.call(obj, key)) {
|
|
574
|
+
push(key, obj[key]);
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
return pairs.length ? pairs.join("&") : "";
|
|
578
|
+
function push(key2, val) {
|
|
579
|
+
if (Array.isArray(val)) {
|
|
580
|
+
val.forEach(function(item) {
|
|
581
|
+
return push(key2, item);
|
|
582
|
+
});
|
|
583
|
+
} else {
|
|
584
|
+
pairs.push([key2, val].map(encodeURIComponent).join("="));
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
function normalizeTimeout(time) {
|
|
589
|
+
if (time === false || time === 0) {
|
|
590
|
+
return false;
|
|
591
|
+
}
|
|
592
|
+
if (time.connect || time.socket) {
|
|
593
|
+
return time;
|
|
594
|
+
}
|
|
595
|
+
var delay = Number(time);
|
|
596
|
+
if (isNaN(delay)) {
|
|
597
|
+
return normalizeTimeout(defaultOptions2.timeout);
|
|
598
|
+
}
|
|
599
|
+
return {
|
|
600
|
+
connect: delay,
|
|
601
|
+
socket: delay
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
function removeUndefined(obj) {
|
|
605
|
+
var target = {};
|
|
606
|
+
for (var key in obj) {
|
|
607
|
+
if (obj[key] !== void 0) {
|
|
608
|
+
target[key] = obj[key];
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
return target;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
});
|
|
615
|
+
|
|
616
|
+
// node_modules/get-it/lib/middleware/defaultOptionsValidator.js
|
|
617
|
+
var require_defaultOptionsValidator = __commonJS({
|
|
618
|
+
"node_modules/get-it/lib/middleware/defaultOptionsValidator.js"(exports, module) {
|
|
619
|
+
"use strict";
|
|
620
|
+
var validUrl = /^https?:\/\//i;
|
|
621
|
+
module.exports = function(options) {
|
|
622
|
+
if (!validUrl.test(options.url)) {
|
|
623
|
+
throw new Error('"'.concat(options.url, '" is not a valid URL'));
|
|
624
|
+
}
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
});
|
|
628
|
+
|
|
629
|
+
// node_modules/same-origin/url-parser.js
|
|
630
|
+
var require_url_parser = __commonJS({
|
|
631
|
+
"node_modules/same-origin/url-parser.js"(exports, module) {
|
|
632
|
+
"use strict";
|
|
633
|
+
var regex = /^(?:(?:(?:([^:\/#\?]+:)?(?:(?:\/\/)((?:((?:[^:@\/#\?]+)(?:\:(?:[^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([0-9]+))?))?)?)?((?:\/?(?:[^\/\?#]+\/+)*)(?:[^\?#]*)))?(\?[^#]+)?)(#.*)?/;
|
|
634
|
+
module.exports = {
|
|
635
|
+
regex,
|
|
636
|
+
parse: function(url) {
|
|
637
|
+
var match = regex.exec(url);
|
|
638
|
+
if (!match) {
|
|
639
|
+
return {};
|
|
640
|
+
}
|
|
641
|
+
return {
|
|
642
|
+
protocol: (match[1] || "").toLowerCase() || void 0,
|
|
643
|
+
hostname: (match[5] || "").toLowerCase() || void 0,
|
|
644
|
+
port: match[6] || void 0
|
|
645
|
+
};
|
|
646
|
+
}
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
});
|
|
650
|
+
|
|
651
|
+
// node_modules/same-origin/index.js
|
|
652
|
+
var require_same_origin = __commonJS({
|
|
653
|
+
"node_modules/same-origin/index.js"(exports, module) {
|
|
654
|
+
"use strict";
|
|
655
|
+
var url = require_url_parser();
|
|
656
|
+
module.exports = function(uri1, uri2, ieMode) {
|
|
657
|
+
if (uri1 === uri2) {
|
|
658
|
+
return true;
|
|
659
|
+
}
|
|
660
|
+
var url1 = url.parse(uri1, false, true);
|
|
661
|
+
var url2 = url.parse(uri2, false, true);
|
|
662
|
+
var url1Port = url1.port | 0 || (url1.protocol === "https" ? 443 : 80);
|
|
663
|
+
var url2Port = url2.port | 0 || (url2.protocol === "https" ? 443 : 80);
|
|
664
|
+
var match = {
|
|
665
|
+
proto: url1.protocol === url2.protocol,
|
|
666
|
+
hostname: url1.hostname === url2.hostname,
|
|
667
|
+
port: url1Port === url2Port
|
|
668
|
+
};
|
|
669
|
+
return match.proto && match.hostname && (match.port || ieMode);
|
|
670
|
+
};
|
|
671
|
+
}
|
|
672
|
+
});
|
|
673
|
+
|
|
674
|
+
// node_modules/parse-headers/parse-headers.js
|
|
675
|
+
var require_parse_headers = __commonJS({
|
|
676
|
+
"node_modules/parse-headers/parse-headers.js"(exports, module) {
|
|
677
|
+
var trim = function(string) {
|
|
678
|
+
return string.replace(/^\s+|\s+$/g, "");
|
|
679
|
+
};
|
|
680
|
+
var isArray = function(arg) {
|
|
681
|
+
return Object.prototype.toString.call(arg) === "[object Array]";
|
|
682
|
+
};
|
|
683
|
+
module.exports = function(headers) {
|
|
684
|
+
if (!headers)
|
|
685
|
+
return {};
|
|
686
|
+
var result = {};
|
|
687
|
+
var headersArr = trim(headers).split("\n");
|
|
688
|
+
for (var i = 0; i < headersArr.length; i++) {
|
|
689
|
+
var row = headersArr[i];
|
|
690
|
+
var index = row.indexOf(":"), key = trim(row.slice(0, index)).toLowerCase(), value = trim(row.slice(index + 1));
|
|
691
|
+
if (typeof result[key] === "undefined") {
|
|
692
|
+
result[key] = value;
|
|
693
|
+
} else if (isArray(result[key])) {
|
|
694
|
+
result[key].push(value);
|
|
695
|
+
} else {
|
|
696
|
+
result[key] = [result[key], value];
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
return result;
|
|
700
|
+
};
|
|
701
|
+
}
|
|
702
|
+
});
|
|
703
|
+
|
|
704
|
+
// node_modules/get-it/lib/request/browser/fetchXhr.js
|
|
705
|
+
var require_fetchXhr = __commonJS({
|
|
706
|
+
"node_modules/get-it/lib/request/browser/fetchXhr.js"(exports, module) {
|
|
707
|
+
"use strict";
|
|
708
|
+
function FetchXhr() {
|
|
709
|
+
this.readyState = 0;
|
|
710
|
+
}
|
|
711
|
+
FetchXhr.prototype.open = function(method, url) {
|
|
712
|
+
this._method = method;
|
|
713
|
+
this._url = url;
|
|
714
|
+
this._resHeaders = "";
|
|
715
|
+
this.readyState = 1;
|
|
716
|
+
this.onreadystatechange();
|
|
717
|
+
};
|
|
718
|
+
FetchXhr.prototype.abort = function() {
|
|
719
|
+
if (this._controller) {
|
|
720
|
+
this._controller.abort();
|
|
721
|
+
}
|
|
722
|
+
};
|
|
723
|
+
FetchXhr.prototype.getAllResponseHeaders = function() {
|
|
724
|
+
return this._resHeaders;
|
|
725
|
+
};
|
|
726
|
+
FetchXhr.prototype.setRequestHeader = function(key, value) {
|
|
727
|
+
this._headers = this._headers || {};
|
|
728
|
+
this._headers[key] = value;
|
|
729
|
+
};
|
|
730
|
+
FetchXhr.prototype.send = function(body) {
|
|
731
|
+
var _this = this;
|
|
732
|
+
var ctrl = this._controller = typeof AbortController === "function" && new AbortController();
|
|
733
|
+
var textBody = this.responseType !== "arraybuffer";
|
|
734
|
+
var options = {
|
|
735
|
+
method: this._method,
|
|
736
|
+
headers: this._headers,
|
|
737
|
+
signal: ctrl && ctrl.signal,
|
|
738
|
+
body
|
|
739
|
+
};
|
|
740
|
+
if (typeof window !== "undefined") {
|
|
741
|
+
options.credentials = this.withCredentials ? "include" : "omit";
|
|
742
|
+
}
|
|
743
|
+
fetch(this._url, options).then(function(res) {
|
|
744
|
+
res.headers.forEach(function(value, key) {
|
|
745
|
+
_this._resHeaders += "".concat(key, ": ").concat(value, "\r\n");
|
|
746
|
+
});
|
|
747
|
+
_this.status = res.status;
|
|
748
|
+
_this.statusText = res.statusText;
|
|
749
|
+
_this.readyState = 3;
|
|
750
|
+
return textBody ? res.text() : res.arrayBuffer();
|
|
751
|
+
}).then(function(resBody) {
|
|
752
|
+
if (textBody) {
|
|
753
|
+
_this.responseText = resBody;
|
|
754
|
+
} else {
|
|
755
|
+
_this.response = resBody;
|
|
756
|
+
}
|
|
757
|
+
_this.readyState = 4;
|
|
758
|
+
_this.onreadystatechange();
|
|
759
|
+
}).catch(function(err) {
|
|
760
|
+
if (err.name === "AbortError") {
|
|
761
|
+
_this.onabort();
|
|
762
|
+
return;
|
|
763
|
+
}
|
|
764
|
+
_this.onerror(err);
|
|
765
|
+
});
|
|
766
|
+
};
|
|
767
|
+
module.exports = FetchXhr;
|
|
768
|
+
}
|
|
769
|
+
});
|
|
770
|
+
|
|
771
|
+
// node_modules/get-it/lib/request/browser-request.js
|
|
772
|
+
var require_browser_request = __commonJS({
|
|
773
|
+
"node_modules/get-it/lib/request/browser-request.js"(exports, module) {
|
|
774
|
+
"use strict";
|
|
775
|
+
var sameOrigin = require_same_origin();
|
|
776
|
+
var parseHeaders = require_parse_headers();
|
|
777
|
+
var FetchXhr = require_fetchXhr();
|
|
778
|
+
var noop = function noop2() {
|
|
779
|
+
};
|
|
780
|
+
var win = typeof window === "undefined" ? void 0 : window;
|
|
781
|
+
var adapter = win ? "xhr" : "fetch";
|
|
782
|
+
var XmlHttpRequest = typeof XMLHttpRequest === "function" ? XMLHttpRequest : noop;
|
|
783
|
+
var hasXhr2 = "withCredentials" in new XmlHttpRequest();
|
|
784
|
+
var XDR = typeof XDomainRequest === "undefined" ? void 0 : XDomainRequest;
|
|
785
|
+
var CrossDomainRequest = hasXhr2 ? XmlHttpRequest : XDR;
|
|
786
|
+
if (!win) {
|
|
787
|
+
XmlHttpRequest = FetchXhr;
|
|
788
|
+
CrossDomainRequest = FetchXhr;
|
|
789
|
+
}
|
|
790
|
+
module.exports = function(context, callback) {
|
|
791
|
+
var opts = context.options;
|
|
792
|
+
var options = context.applyMiddleware("finalizeOptions", opts);
|
|
793
|
+
var timers = {};
|
|
794
|
+
var cors = win && win.location && !sameOrigin(win.location.href, options.url);
|
|
795
|
+
var injectedResponse = context.applyMiddleware("interceptRequest", void 0, {
|
|
796
|
+
adapter,
|
|
797
|
+
context
|
|
798
|
+
});
|
|
799
|
+
if (injectedResponse) {
|
|
800
|
+
var cbTimer = setTimeout(callback, 0, null, injectedResponse);
|
|
801
|
+
var cancel = function cancel2() {
|
|
802
|
+
return clearTimeout(cbTimer);
|
|
803
|
+
};
|
|
804
|
+
return {
|
|
805
|
+
abort: cancel
|
|
806
|
+
};
|
|
807
|
+
}
|
|
808
|
+
var xhr = cors ? new CrossDomainRequest() : new XmlHttpRequest();
|
|
809
|
+
var isXdr = win && win.XDomainRequest && xhr instanceof win.XDomainRequest;
|
|
810
|
+
var headers = options.headers;
|
|
811
|
+
var delays = options.timeout;
|
|
812
|
+
var aborted = false;
|
|
813
|
+
var loaded = false;
|
|
814
|
+
var timedOut = false;
|
|
815
|
+
xhr.onerror = onError;
|
|
816
|
+
xhr.ontimeout = onError;
|
|
817
|
+
xhr.onabort = function() {
|
|
818
|
+
stopTimers(true);
|
|
819
|
+
aborted = true;
|
|
820
|
+
};
|
|
821
|
+
xhr.onprogress = function() {
|
|
822
|
+
};
|
|
823
|
+
var loadEvent = isXdr ? "onload" : "onreadystatechange";
|
|
824
|
+
xhr[loadEvent] = function() {
|
|
825
|
+
resetTimers();
|
|
826
|
+
if (aborted || xhr.readyState !== 4 && !isXdr) {
|
|
827
|
+
return;
|
|
828
|
+
}
|
|
829
|
+
if (xhr.status === 0) {
|
|
830
|
+
return;
|
|
831
|
+
}
|
|
832
|
+
onLoad();
|
|
833
|
+
};
|
|
834
|
+
xhr.open(options.method, options.url, true);
|
|
835
|
+
xhr.withCredentials = !!options.withCredentials;
|
|
836
|
+
if (headers && xhr.setRequestHeader) {
|
|
837
|
+
for (var key in headers) {
|
|
838
|
+
if (headers.hasOwnProperty(key)) {
|
|
839
|
+
xhr.setRequestHeader(key, headers[key]);
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
} else if (headers && isXdr) {
|
|
843
|
+
throw new Error("Headers cannot be set on an XDomainRequest object");
|
|
844
|
+
}
|
|
845
|
+
if (options.rawBody) {
|
|
846
|
+
xhr.responseType = "arraybuffer";
|
|
847
|
+
}
|
|
848
|
+
context.applyMiddleware("onRequest", {
|
|
849
|
+
options,
|
|
850
|
+
adapter,
|
|
851
|
+
request: xhr,
|
|
852
|
+
context
|
|
853
|
+
});
|
|
854
|
+
xhr.send(options.body || null);
|
|
855
|
+
if (delays) {
|
|
856
|
+
timers.connect = setTimeout(function() {
|
|
857
|
+
return timeoutRequest("ETIMEDOUT");
|
|
858
|
+
}, delays.connect);
|
|
859
|
+
}
|
|
860
|
+
return {
|
|
861
|
+
abort
|
|
862
|
+
};
|
|
863
|
+
function abort() {
|
|
864
|
+
aborted = true;
|
|
865
|
+
if (xhr) {
|
|
866
|
+
xhr.abort();
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
function timeoutRequest(code) {
|
|
870
|
+
timedOut = true;
|
|
871
|
+
xhr.abort();
|
|
872
|
+
var error = new Error(code === "ESOCKETTIMEDOUT" ? "Socket timed out on request to ".concat(options.url) : "Connection timed out on request to ".concat(options.url));
|
|
873
|
+
error.code = code;
|
|
874
|
+
context.channels.error.publish(error);
|
|
875
|
+
}
|
|
876
|
+
function resetTimers() {
|
|
877
|
+
if (!delays) {
|
|
878
|
+
return;
|
|
879
|
+
}
|
|
880
|
+
stopTimers();
|
|
881
|
+
timers.socket = setTimeout(function() {
|
|
882
|
+
return timeoutRequest("ESOCKETTIMEDOUT");
|
|
883
|
+
}, delays.socket);
|
|
884
|
+
}
|
|
885
|
+
function stopTimers(force) {
|
|
886
|
+
if (force || aborted || xhr.readyState >= 2 && timers.connect) {
|
|
887
|
+
clearTimeout(timers.connect);
|
|
888
|
+
}
|
|
889
|
+
if (timers.socket) {
|
|
890
|
+
clearTimeout(timers.socket);
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
function onError(error) {
|
|
894
|
+
if (loaded) {
|
|
895
|
+
return;
|
|
896
|
+
}
|
|
897
|
+
stopTimers(true);
|
|
898
|
+
loaded = true;
|
|
899
|
+
xhr = null;
|
|
900
|
+
var err = error || new Error("Network error while attempting to reach ".concat(options.url));
|
|
901
|
+
err.isNetworkError = true;
|
|
902
|
+
err.request = options;
|
|
903
|
+
callback(err);
|
|
904
|
+
}
|
|
905
|
+
function reduceResponse() {
|
|
906
|
+
var statusCode = xhr.status;
|
|
907
|
+
var statusMessage = xhr.statusText;
|
|
908
|
+
if (isXdr && statusCode === void 0) {
|
|
909
|
+
statusCode = 200;
|
|
910
|
+
} else if (statusCode > 12e3 && statusCode < 12156) {
|
|
911
|
+
return onError();
|
|
912
|
+
} else {
|
|
913
|
+
statusCode = xhr.status === 1223 ? 204 : xhr.status;
|
|
914
|
+
statusMessage = xhr.status === 1223 ? "No Content" : statusMessage;
|
|
915
|
+
}
|
|
916
|
+
return {
|
|
917
|
+
body: xhr.response || xhr.responseText,
|
|
918
|
+
url: options.url,
|
|
919
|
+
method: options.method,
|
|
920
|
+
headers: isXdr ? {} : parseHeaders(xhr.getAllResponseHeaders()),
|
|
921
|
+
statusCode,
|
|
922
|
+
statusMessage
|
|
923
|
+
};
|
|
924
|
+
}
|
|
925
|
+
function onLoad() {
|
|
926
|
+
if (aborted || loaded || timedOut) {
|
|
927
|
+
return;
|
|
928
|
+
}
|
|
929
|
+
if (xhr.status === 0) {
|
|
930
|
+
onError(new Error("Unknown XHR error"));
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
933
|
+
stopTimers();
|
|
934
|
+
loaded = true;
|
|
935
|
+
callback(null, reduceResponse());
|
|
936
|
+
}
|
|
937
|
+
};
|
|
938
|
+
}
|
|
939
|
+
});
|
|
940
|
+
|
|
941
|
+
// node_modules/get-it/lib/request/index.js
|
|
942
|
+
var require_request = __commonJS({
|
|
943
|
+
"node_modules/get-it/lib/request/index.js"(exports, module) {
|
|
944
|
+
"use strict";
|
|
945
|
+
module.exports = require_browser_request();
|
|
946
|
+
}
|
|
947
|
+
});
|
|
948
|
+
|
|
949
|
+
// node_modules/get-it/lib/index.js
|
|
950
|
+
var require_lib = __commonJS({
|
|
951
|
+
"node_modules/get-it/lib/index.js"(exports, module) {
|
|
952
|
+
"use strict";
|
|
953
|
+
var pubsub = require_nano_pubsub();
|
|
954
|
+
var middlewareReducer = require_middlewareReducer();
|
|
955
|
+
var processOptions = require_defaultOptionsProcessor();
|
|
956
|
+
var validateOptions = require_defaultOptionsValidator();
|
|
957
|
+
var httpRequester = require_request();
|
|
958
|
+
var channelNames = ["request", "response", "progress", "error", "abort"];
|
|
959
|
+
var middlehooks = ["processOptions", "validateOptions", "interceptRequest", "finalizeOptions", "onRequest", "onResponse", "onError", "onReturn", "onHeaders"];
|
|
960
|
+
module.exports = function createRequester() {
|
|
961
|
+
var initMiddleware = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
|
|
962
|
+
var httpRequest2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : httpRequester;
|
|
963
|
+
var loadedMiddleware = [];
|
|
964
|
+
var middleware3 = middlehooks.reduce(function(ware, name) {
|
|
965
|
+
ware[name] = ware[name] || [];
|
|
966
|
+
return ware;
|
|
967
|
+
}, {
|
|
968
|
+
processOptions: [processOptions],
|
|
969
|
+
validateOptions: [validateOptions]
|
|
970
|
+
});
|
|
971
|
+
function request2(opts) {
|
|
972
|
+
var channels = channelNames.reduce(function(target, name) {
|
|
973
|
+
target[name] = pubsub();
|
|
974
|
+
return target;
|
|
975
|
+
}, {});
|
|
976
|
+
var applyMiddleware = middlewareReducer(middleware3);
|
|
977
|
+
var options = applyMiddleware("processOptions", opts);
|
|
978
|
+
applyMiddleware("validateOptions", options);
|
|
979
|
+
var context = {
|
|
980
|
+
options,
|
|
981
|
+
channels,
|
|
982
|
+
applyMiddleware
|
|
983
|
+
};
|
|
984
|
+
var ongoingRequest = null;
|
|
985
|
+
var unsubscribe = channels.request.subscribe(function(ctx) {
|
|
986
|
+
ongoingRequest = httpRequest2(ctx, function(err, res) {
|
|
987
|
+
return onResponse(err, res, ctx);
|
|
988
|
+
});
|
|
989
|
+
});
|
|
990
|
+
channels.abort.subscribe(function() {
|
|
991
|
+
unsubscribe();
|
|
992
|
+
if (ongoingRequest) {
|
|
993
|
+
ongoingRequest.abort();
|
|
994
|
+
}
|
|
995
|
+
});
|
|
996
|
+
var returnValue = applyMiddleware("onReturn", channels, context);
|
|
997
|
+
if (returnValue === channels) {
|
|
998
|
+
channels.request.publish(context);
|
|
999
|
+
}
|
|
1000
|
+
return returnValue;
|
|
1001
|
+
function onResponse(reqErr, res, ctx) {
|
|
1002
|
+
var error = reqErr;
|
|
1003
|
+
var response = res;
|
|
1004
|
+
if (!error) {
|
|
1005
|
+
try {
|
|
1006
|
+
response = applyMiddleware("onResponse", res, ctx);
|
|
1007
|
+
} catch (err) {
|
|
1008
|
+
response = null;
|
|
1009
|
+
error = err;
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
error = error && applyMiddleware("onError", error, ctx);
|
|
1013
|
+
if (error) {
|
|
1014
|
+
channels.error.publish(error);
|
|
1015
|
+
} else if (response) {
|
|
1016
|
+
channels.response.publish(response);
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
request2.use = function use(newMiddleware) {
|
|
1021
|
+
if (!newMiddleware) {
|
|
1022
|
+
throw new Error("Tried to add middleware that resolved to falsey value");
|
|
1023
|
+
}
|
|
1024
|
+
if (typeof newMiddleware === "function") {
|
|
1025
|
+
throw new Error("Tried to add middleware that was a function. It probably expects you to pass options to it.");
|
|
1026
|
+
}
|
|
1027
|
+
if (newMiddleware.onReturn && middleware3.onReturn.length > 0) {
|
|
1028
|
+
throw new Error("Tried to add new middleware with `onReturn` handler, but another handler has already been registered for this event");
|
|
1029
|
+
}
|
|
1030
|
+
middlehooks.forEach(function(key) {
|
|
1031
|
+
if (newMiddleware[key]) {
|
|
1032
|
+
middleware3[key].push(newMiddleware[key]);
|
|
1033
|
+
}
|
|
1034
|
+
});
|
|
1035
|
+
loadedMiddleware.push(newMiddleware);
|
|
1036
|
+
return request2;
|
|
1037
|
+
};
|
|
1038
|
+
request2.clone = function clone() {
|
|
1039
|
+
return createRequester(loadedMiddleware);
|
|
1040
|
+
};
|
|
1041
|
+
initMiddleware.forEach(request2.use);
|
|
1042
|
+
return request2;
|
|
1043
|
+
};
|
|
1044
|
+
}
|
|
1045
|
+
});
|
|
1046
|
+
|
|
1047
|
+
// node_modules/get-it/index.js
|
|
1048
|
+
var require_get_it = __commonJS({
|
|
1049
|
+
"node_modules/get-it/index.js"(exports, module) {
|
|
1050
|
+
module.exports = require_lib();
|
|
1051
|
+
}
|
|
1052
|
+
});
|
|
1053
|
+
|
|
1054
|
+
// node_modules/get-it/lib/util/global.js
|
|
1055
|
+
var require_global = __commonJS({
|
|
1056
|
+
"node_modules/get-it/lib/util/global.js"(exports, module) {
|
|
1057
|
+
"use strict";
|
|
1058
|
+
if (typeof globalThis !== "undefined") {
|
|
1059
|
+
module.exports = globalThis;
|
|
1060
|
+
} else if (typeof window !== "undefined") {
|
|
1061
|
+
module.exports = window;
|
|
1062
|
+
} else if (typeof global !== "undefined") {
|
|
1063
|
+
module.exports = global;
|
|
1064
|
+
} else if (typeof self !== "undefined") {
|
|
1065
|
+
module.exports = self;
|
|
1066
|
+
} else {
|
|
1067
|
+
module.exports = {};
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
});
|
|
1071
|
+
|
|
1072
|
+
// node_modules/get-it/lib/middleware/observable.js
|
|
1073
|
+
var require_observable = __commonJS({
|
|
1074
|
+
"node_modules/get-it/lib/middleware/observable.js"(exports, module) {
|
|
1075
|
+
"use strict";
|
|
1076
|
+
var global2 = require_global();
|
|
1077
|
+
var objectAssign = require_object_assign();
|
|
1078
|
+
module.exports = function() {
|
|
1079
|
+
var opts = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
1080
|
+
var Observable2 = opts.implementation || global2.Observable;
|
|
1081
|
+
if (!Observable2) {
|
|
1082
|
+
throw new Error("`Observable` is not available in global scope, and no implementation was passed");
|
|
1083
|
+
}
|
|
1084
|
+
return {
|
|
1085
|
+
onReturn: function onReturn(channels, context) {
|
|
1086
|
+
return new Observable2(function(observer) {
|
|
1087
|
+
channels.error.subscribe(function(err) {
|
|
1088
|
+
return observer.error(err);
|
|
1089
|
+
});
|
|
1090
|
+
channels.progress.subscribe(function(event) {
|
|
1091
|
+
return observer.next(objectAssign({
|
|
1092
|
+
type: "progress"
|
|
1093
|
+
}, event));
|
|
1094
|
+
});
|
|
1095
|
+
channels.response.subscribe(function(response) {
|
|
1096
|
+
observer.next(objectAssign({
|
|
1097
|
+
type: "response"
|
|
1098
|
+
}, response));
|
|
1099
|
+
observer.complete();
|
|
1100
|
+
});
|
|
1101
|
+
channels.request.publish(context);
|
|
1102
|
+
return function() {
|
|
1103
|
+
return channels.abort.publish();
|
|
1104
|
+
};
|
|
1105
|
+
});
|
|
1106
|
+
}
|
|
1107
|
+
};
|
|
1108
|
+
};
|
|
1109
|
+
}
|
|
1110
|
+
});
|
|
1111
|
+
|
|
1112
|
+
// node_modules/isobject/index.js
|
|
1113
|
+
var require_isobject = __commonJS({
|
|
1114
|
+
"node_modules/isobject/index.js"(exports, module) {
|
|
1115
|
+
"use strict";
|
|
1116
|
+
module.exports = function isObject(val) {
|
|
1117
|
+
return val != null && typeof val === "object" && Array.isArray(val) === false;
|
|
1118
|
+
};
|
|
1119
|
+
}
|
|
1120
|
+
});
|
|
1121
|
+
|
|
1122
|
+
// node_modules/is-plain-object/index.js
|
|
1123
|
+
var require_is_plain_object = __commonJS({
|
|
1124
|
+
"node_modules/is-plain-object/index.js"(exports, module) {
|
|
1125
|
+
"use strict";
|
|
1126
|
+
var isObject = require_isobject();
|
|
1127
|
+
function isObjectObject(o) {
|
|
1128
|
+
return isObject(o) === true && Object.prototype.toString.call(o) === "[object Object]";
|
|
1129
|
+
}
|
|
1130
|
+
module.exports = function isPlainObject(o) {
|
|
1131
|
+
var ctor, prot;
|
|
1132
|
+
if (isObjectObject(o) === false)
|
|
1133
|
+
return false;
|
|
1134
|
+
ctor = o.constructor;
|
|
1135
|
+
if (typeof ctor !== "function")
|
|
1136
|
+
return false;
|
|
1137
|
+
prot = ctor.prototype;
|
|
1138
|
+
if (isObjectObject(prot) === false)
|
|
1139
|
+
return false;
|
|
1140
|
+
if (prot.hasOwnProperty("isPrototypeOf") === false) {
|
|
1141
|
+
return false;
|
|
1142
|
+
}
|
|
1143
|
+
return true;
|
|
1144
|
+
};
|
|
1145
|
+
}
|
|
1146
|
+
});
|
|
1147
|
+
|
|
1148
|
+
// node_modules/get-it/lib/middleware/jsonRequest.js
|
|
1149
|
+
var require_jsonRequest = __commonJS({
|
|
1150
|
+
"node_modules/get-it/lib/middleware/jsonRequest.js"(exports, module) {
|
|
1151
|
+
"use strict";
|
|
1152
|
+
function _typeof(obj) {
|
|
1153
|
+
"@babel/helpers - typeof";
|
|
1154
|
+
return _typeof = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(obj2) {
|
|
1155
|
+
return typeof obj2;
|
|
1156
|
+
} : function(obj2) {
|
|
1157
|
+
return obj2 && typeof Symbol == "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
1158
|
+
}, _typeof(obj);
|
|
1159
|
+
}
|
|
1160
|
+
var objectAssign = require_object_assign();
|
|
1161
|
+
var isPlainObject = require_is_plain_object();
|
|
1162
|
+
var serializeTypes = ["boolean", "string", "number"];
|
|
1163
|
+
var isBuffer = function isBuffer2(obj) {
|
|
1164
|
+
return !!obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
|
|
1165
|
+
};
|
|
1166
|
+
module.exports = function() {
|
|
1167
|
+
return {
|
|
1168
|
+
processOptions: function processOptions(options) {
|
|
1169
|
+
var body = options.body;
|
|
1170
|
+
if (!body) {
|
|
1171
|
+
return options;
|
|
1172
|
+
}
|
|
1173
|
+
var isStream = typeof body.pipe === "function";
|
|
1174
|
+
var shouldSerialize = !isStream && !isBuffer(body) && (serializeTypes.indexOf(_typeof(body)) !== -1 || Array.isArray(body) || isPlainObject(body));
|
|
1175
|
+
if (!shouldSerialize) {
|
|
1176
|
+
return options;
|
|
1177
|
+
}
|
|
1178
|
+
return objectAssign({}, options, {
|
|
1179
|
+
body: JSON.stringify(options.body),
|
|
1180
|
+
headers: objectAssign({}, options.headers, {
|
|
1181
|
+
"Content-Type": "application/json"
|
|
1182
|
+
})
|
|
1183
|
+
});
|
|
1184
|
+
}
|
|
1185
|
+
};
|
|
1186
|
+
};
|
|
1187
|
+
}
|
|
1188
|
+
});
|
|
1189
|
+
|
|
1190
|
+
// node_modules/get-it/lib/middleware/jsonResponse.js
|
|
1191
|
+
var require_jsonResponse = __commonJS({
|
|
1192
|
+
"node_modules/get-it/lib/middleware/jsonResponse.js"(exports, module) {
|
|
1193
|
+
"use strict";
|
|
1194
|
+
var objectAssign = require_object_assign();
|
|
1195
|
+
module.exports = function(opts) {
|
|
1196
|
+
return {
|
|
1197
|
+
onResponse: function onResponse(response) {
|
|
1198
|
+
var contentType = response.headers["content-type"] || "";
|
|
1199
|
+
var shouldDecode = opts && opts.force || contentType.indexOf("application/json") !== -1;
|
|
1200
|
+
if (!response.body || !contentType || !shouldDecode) {
|
|
1201
|
+
return response;
|
|
1202
|
+
}
|
|
1203
|
+
return objectAssign({}, response, {
|
|
1204
|
+
body: tryParse(response.body)
|
|
1205
|
+
});
|
|
1206
|
+
},
|
|
1207
|
+
processOptions: function processOptions(options) {
|
|
1208
|
+
return objectAssign({}, options, {
|
|
1209
|
+
headers: objectAssign({
|
|
1210
|
+
Accept: "application/json"
|
|
1211
|
+
}, options.headers)
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1214
|
+
};
|
|
1215
|
+
};
|
|
1216
|
+
function tryParse(body) {
|
|
1217
|
+
try {
|
|
1218
|
+
return JSON.parse(body);
|
|
1219
|
+
} catch (err) {
|
|
1220
|
+
err.message = "Failed to parsed response body as JSON: ".concat(err.message);
|
|
1221
|
+
throw err;
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
});
|
|
1226
|
+
|
|
1227
|
+
// node_modules/get-it/lib/middleware/progress/browser-progress.js
|
|
1228
|
+
var require_browser_progress = __commonJS({
|
|
1229
|
+
"node_modules/get-it/lib/middleware/progress/browser-progress.js"(exports, module) {
|
|
1230
|
+
"use strict";
|
|
1231
|
+
module.exports = function() {
|
|
1232
|
+
return {
|
|
1233
|
+
onRequest: function onRequest(evt) {
|
|
1234
|
+
if (evt.adapter !== "xhr") {
|
|
1235
|
+
return;
|
|
1236
|
+
}
|
|
1237
|
+
var xhr = evt.request;
|
|
1238
|
+
var context = evt.context;
|
|
1239
|
+
if ("upload" in xhr && "onprogress" in xhr.upload) {
|
|
1240
|
+
xhr.upload.onprogress = handleProgress("upload");
|
|
1241
|
+
}
|
|
1242
|
+
if ("onprogress" in xhr) {
|
|
1243
|
+
xhr.onprogress = handleProgress("download");
|
|
1244
|
+
}
|
|
1245
|
+
function handleProgress(stage) {
|
|
1246
|
+
return function(event) {
|
|
1247
|
+
var percent = event.lengthComputable ? event.loaded / event.total * 100 : -1;
|
|
1248
|
+
context.channels.progress.publish({
|
|
1249
|
+
stage,
|
|
1250
|
+
percent,
|
|
1251
|
+
total: event.total,
|
|
1252
|
+
loaded: event.loaded,
|
|
1253
|
+
lengthComputable: event.lengthComputable
|
|
1254
|
+
});
|
|
1255
|
+
};
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
};
|
|
1259
|
+
};
|
|
1260
|
+
}
|
|
1261
|
+
});
|
|
1262
|
+
|
|
1263
|
+
// node_modules/get-it/lib/middleware/progress/index.js
|
|
1264
|
+
var require_progress = __commonJS({
|
|
1265
|
+
"node_modules/get-it/lib/middleware/progress/index.js"(exports, module) {
|
|
1266
|
+
"use strict";
|
|
1267
|
+
module.exports = require_browser_progress();
|
|
1268
|
+
}
|
|
1269
|
+
});
|
|
1270
|
+
|
|
1
1271
|
// src/util/observable.js
|
|
2
1272
|
import { Observable } from "rxjs/internal/Observable";
|
|
3
1273
|
import { filter } from "rxjs/internal/operators/filter";
|
|
@@ -665,11 +1935,11 @@ var AuthClient = class {
|
|
|
665
1935
|
};
|
|
666
1936
|
|
|
667
1937
|
// src/http/request.js
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
1938
|
+
var import_get_it = __toESM(require_get_it());
|
|
1939
|
+
var import_observable4 = __toESM(require_observable());
|
|
1940
|
+
var import_jsonRequest = __toESM(require_jsonRequest());
|
|
1941
|
+
var import_jsonResponse = __toESM(require_jsonResponse());
|
|
1942
|
+
var import_progress = __toESM(require_progress());
|
|
673
1943
|
|
|
674
1944
|
// src/http/errors.js
|
|
675
1945
|
import makeError from "make-error";
|
|
@@ -738,13 +2008,13 @@ var printWarnings = {
|
|
|
738
2008
|
};
|
|
739
2009
|
var middleware2 = middleware.concat([
|
|
740
2010
|
printWarnings,
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
2011
|
+
(0, import_jsonRequest.default)(),
|
|
2012
|
+
(0, import_jsonResponse.default)(),
|
|
2013
|
+
(0, import_progress.default)(),
|
|
744
2014
|
httpError,
|
|
745
|
-
|
|
2015
|
+
(0, import_observable4.default)({ implementation: Observable })
|
|
746
2016
|
]);
|
|
747
|
-
var request =
|
|
2017
|
+
var request = (0, import_get_it.default)(middleware2);
|
|
748
2018
|
function httpRequest(options, requester = request) {
|
|
749
2019
|
return requester(Object.assign({ maxRedirects: 0 }, options));
|
|
750
2020
|
}
|
|
@@ -954,3 +2224,20 @@ export {
|
|
|
954
2224
|
SanityClient,
|
|
955
2225
|
createClient
|
|
956
2226
|
};
|
|
2227
|
+
/*
|
|
2228
|
+
object-assign
|
|
2229
|
+
(c) Sindre Sorhus
|
|
2230
|
+
@license MIT
|
|
2231
|
+
*/
|
|
2232
|
+
/*!
|
|
2233
|
+
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
|
2234
|
+
*
|
|
2235
|
+
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
2236
|
+
* Released under the MIT License.
|
|
2237
|
+
*/
|
|
2238
|
+
/*!
|
|
2239
|
+
* isobject <https://github.com/jonschlinkert/isobject>
|
|
2240
|
+
*
|
|
2241
|
+
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
2242
|
+
* Released under the MIT License.
|
|
2243
|
+
*/
|