@sanity/client 3.4.0-beta.esm.2 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/sanityClient.browser.mjs +316 -3452
- package/dist/sanityClient.browser.mjs.map +3 -3
- package/lib/config.js +2 -2
- package/lib/generateHelpUrl.js +7 -0
- package/lib/sanityClient.js +5 -1
- package/lib/warnings.js +1 -1
- package/package.json +19 -27
- package/sanityClient.d.ts +252 -97
- package/umd/sanityClient.js +30 -30
- package/umd/sanityClient.min.js +1 -1
- package/dist/sanityClient.node.js +0 -1129
- package/dist/sanityClient.node.js.map +0 -7
|
@@ -1,964 +1,21 @@
|
|
|
1
1
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
-
var
|
|
2
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
4
|
+
}) : x)(function(x) {
|
|
5
|
+
if (typeof require !== "undefined")
|
|
6
|
+
return require.apply(this, arguments);
|
|
7
|
+
throw new Error('Dynamic require of "' + x + '" is not supported');
|
|
8
|
+
});
|
|
9
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
3
10
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
4
11
|
};
|
|
5
12
|
|
|
6
|
-
// node_modules/object-assign/index.js
|
|
7
|
-
var require_object_assign = __commonJS({
|
|
8
|
-
"node_modules/object-assign/index.js"(exports, module) {
|
|
9
|
-
"use strict";
|
|
10
|
-
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
11
|
-
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
12
|
-
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
|
13
|
-
function toObject(val) {
|
|
14
|
-
if (val === null || val === void 0) {
|
|
15
|
-
throw new TypeError("Object.assign cannot be called with null or undefined");
|
|
16
|
-
}
|
|
17
|
-
return Object(val);
|
|
18
|
-
}
|
|
19
|
-
function shouldUseNative() {
|
|
20
|
-
try {
|
|
21
|
-
if (!Object.assign) {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
var test1 = new String("abc");
|
|
25
|
-
test1[5] = "de";
|
|
26
|
-
if (Object.getOwnPropertyNames(test1)[0] === "5") {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
var test2 = {};
|
|
30
|
-
for (var i = 0; i < 10; i++) {
|
|
31
|
-
test2["_" + String.fromCharCode(i)] = i;
|
|
32
|
-
}
|
|
33
|
-
var order2 = Object.getOwnPropertyNames(test2).map(function(n) {
|
|
34
|
-
return test2[n];
|
|
35
|
-
});
|
|
36
|
-
if (order2.join("") !== "0123456789") {
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
var test3 = {};
|
|
40
|
-
"abcdefghijklmnopqrst".split("").forEach(function(letter) {
|
|
41
|
-
test3[letter] = letter;
|
|
42
|
-
});
|
|
43
|
-
if (Object.keys(Object.assign({}, test3)).join("") !== "abcdefghijklmnopqrst") {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
return true;
|
|
47
|
-
} catch (err) {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
module.exports = shouldUseNative() ? Object.assign : function(target, source) {
|
|
52
|
-
var from;
|
|
53
|
-
var to = toObject(target);
|
|
54
|
-
var symbols;
|
|
55
|
-
for (var s = 1; s < arguments.length; s++) {
|
|
56
|
-
from = Object(arguments[s]);
|
|
57
|
-
for (var key in from) {
|
|
58
|
-
if (hasOwnProperty.call(from, key)) {
|
|
59
|
-
to[key] = from[key];
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
if (getOwnPropertySymbols) {
|
|
63
|
-
symbols = getOwnPropertySymbols(from);
|
|
64
|
-
for (var i = 0; i < symbols.length; i++) {
|
|
65
|
-
if (propIsEnumerable.call(from, symbols[i])) {
|
|
66
|
-
to[symbols[i]] = from[symbols[i]];
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return to;
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
// node_modules/rxjs/internal/util/isFunction.js
|
|
77
|
-
var require_isFunction = __commonJS({
|
|
78
|
-
"node_modules/rxjs/internal/util/isFunction.js"(exports) {
|
|
79
|
-
"use strict";
|
|
80
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
81
|
-
function isFunction(x) {
|
|
82
|
-
return typeof x === "function";
|
|
83
|
-
}
|
|
84
|
-
exports.isFunction = isFunction;
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
// node_modules/rxjs/internal/config.js
|
|
89
|
-
var require_config = __commonJS({
|
|
90
|
-
"node_modules/rxjs/internal/config.js"(exports) {
|
|
91
|
-
"use strict";
|
|
92
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
93
|
-
var _enable_super_gross_mode_that_will_cause_bad_things = false;
|
|
94
|
-
exports.config = {
|
|
95
|
-
Promise: void 0,
|
|
96
|
-
set useDeprecatedSynchronousErrorHandling(value) {
|
|
97
|
-
if (value) {
|
|
98
|
-
var error = new Error();
|
|
99
|
-
console.warn("DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n" + error.stack);
|
|
100
|
-
} else if (_enable_super_gross_mode_that_will_cause_bad_things) {
|
|
101
|
-
console.log("RxJS: Back to a better error behavior. Thank you. <3");
|
|
102
|
-
}
|
|
103
|
-
_enable_super_gross_mode_that_will_cause_bad_things = value;
|
|
104
|
-
},
|
|
105
|
-
get useDeprecatedSynchronousErrorHandling() {
|
|
106
|
-
return _enable_super_gross_mode_that_will_cause_bad_things;
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
// node_modules/rxjs/internal/util/hostReportError.js
|
|
113
|
-
var require_hostReportError = __commonJS({
|
|
114
|
-
"node_modules/rxjs/internal/util/hostReportError.js"(exports) {
|
|
115
|
-
"use strict";
|
|
116
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
117
|
-
function hostReportError(err) {
|
|
118
|
-
setTimeout(function() {
|
|
119
|
-
throw err;
|
|
120
|
-
}, 0);
|
|
121
|
-
}
|
|
122
|
-
exports.hostReportError = hostReportError;
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
// node_modules/rxjs/internal/Observer.js
|
|
127
|
-
var require_Observer = __commonJS({
|
|
128
|
-
"node_modules/rxjs/internal/Observer.js"(exports) {
|
|
129
|
-
"use strict";
|
|
130
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
131
|
-
var config_1 = require_config();
|
|
132
|
-
var hostReportError_1 = require_hostReportError();
|
|
133
|
-
exports.empty = {
|
|
134
|
-
closed: true,
|
|
135
|
-
next: function(value) {
|
|
136
|
-
},
|
|
137
|
-
error: function(err) {
|
|
138
|
-
if (config_1.config.useDeprecatedSynchronousErrorHandling) {
|
|
139
|
-
throw err;
|
|
140
|
-
} else {
|
|
141
|
-
hostReportError_1.hostReportError(err);
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
complete: function() {
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
// node_modules/rxjs/internal/util/isArray.js
|
|
151
|
-
var require_isArray = __commonJS({
|
|
152
|
-
"node_modules/rxjs/internal/util/isArray.js"(exports) {
|
|
153
|
-
"use strict";
|
|
154
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
155
|
-
exports.isArray = function() {
|
|
156
|
-
return Array.isArray || function(x) {
|
|
157
|
-
return x && typeof x.length === "number";
|
|
158
|
-
};
|
|
159
|
-
}();
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
// node_modules/rxjs/internal/util/isObject.js
|
|
164
|
-
var require_isObject = __commonJS({
|
|
165
|
-
"node_modules/rxjs/internal/util/isObject.js"(exports) {
|
|
166
|
-
"use strict";
|
|
167
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
168
|
-
function isObject(x) {
|
|
169
|
-
return x !== null && typeof x === "object";
|
|
170
|
-
}
|
|
171
|
-
exports.isObject = isObject;
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
// node_modules/rxjs/internal/util/UnsubscriptionError.js
|
|
176
|
-
var require_UnsubscriptionError = __commonJS({
|
|
177
|
-
"node_modules/rxjs/internal/util/UnsubscriptionError.js"(exports) {
|
|
178
|
-
"use strict";
|
|
179
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
180
|
-
var UnsubscriptionErrorImpl = function() {
|
|
181
|
-
function UnsubscriptionErrorImpl2(errors) {
|
|
182
|
-
Error.call(this);
|
|
183
|
-
this.message = errors ? errors.length + " errors occurred during unsubscription:\n" + errors.map(function(err, i) {
|
|
184
|
-
return i + 1 + ") " + err.toString();
|
|
185
|
-
}).join("\n ") : "";
|
|
186
|
-
this.name = "UnsubscriptionError";
|
|
187
|
-
this.errors = errors;
|
|
188
|
-
return this;
|
|
189
|
-
}
|
|
190
|
-
UnsubscriptionErrorImpl2.prototype = Object.create(Error.prototype);
|
|
191
|
-
return UnsubscriptionErrorImpl2;
|
|
192
|
-
}();
|
|
193
|
-
exports.UnsubscriptionError = UnsubscriptionErrorImpl;
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
// node_modules/rxjs/internal/Subscription.js
|
|
198
|
-
var require_Subscription = __commonJS({
|
|
199
|
-
"node_modules/rxjs/internal/Subscription.js"(exports) {
|
|
200
|
-
"use strict";
|
|
201
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
202
|
-
var isArray_1 = require_isArray();
|
|
203
|
-
var isObject_1 = require_isObject();
|
|
204
|
-
var isFunction_1 = require_isFunction();
|
|
205
|
-
var UnsubscriptionError_1 = require_UnsubscriptionError();
|
|
206
|
-
var Subscription = function() {
|
|
207
|
-
function Subscription2(unsubscribe) {
|
|
208
|
-
this.closed = false;
|
|
209
|
-
this._parentOrParents = null;
|
|
210
|
-
this._subscriptions = null;
|
|
211
|
-
if (unsubscribe) {
|
|
212
|
-
this._ctorUnsubscribe = true;
|
|
213
|
-
this._unsubscribe = unsubscribe;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
Subscription2.prototype.unsubscribe = function() {
|
|
217
|
-
var errors;
|
|
218
|
-
if (this.closed) {
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
var _a = this, _parentOrParents = _a._parentOrParents, _ctorUnsubscribe = _a._ctorUnsubscribe, _unsubscribe = _a._unsubscribe, _subscriptions = _a._subscriptions;
|
|
222
|
-
this.closed = true;
|
|
223
|
-
this._parentOrParents = null;
|
|
224
|
-
this._subscriptions = null;
|
|
225
|
-
if (_parentOrParents instanceof Subscription2) {
|
|
226
|
-
_parentOrParents.remove(this);
|
|
227
|
-
} else if (_parentOrParents !== null) {
|
|
228
|
-
for (var index = 0; index < _parentOrParents.length; ++index) {
|
|
229
|
-
var parent_1 = _parentOrParents[index];
|
|
230
|
-
parent_1.remove(this);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
if (isFunction_1.isFunction(_unsubscribe)) {
|
|
234
|
-
if (_ctorUnsubscribe) {
|
|
235
|
-
this._unsubscribe = void 0;
|
|
236
|
-
}
|
|
237
|
-
try {
|
|
238
|
-
_unsubscribe.call(this);
|
|
239
|
-
} catch (e) {
|
|
240
|
-
errors = e instanceof UnsubscriptionError_1.UnsubscriptionError ? flattenUnsubscriptionErrors(e.errors) : [e];
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
if (isArray_1.isArray(_subscriptions)) {
|
|
244
|
-
var index = -1;
|
|
245
|
-
var len = _subscriptions.length;
|
|
246
|
-
while (++index < len) {
|
|
247
|
-
var sub = _subscriptions[index];
|
|
248
|
-
if (isObject_1.isObject(sub)) {
|
|
249
|
-
try {
|
|
250
|
-
sub.unsubscribe();
|
|
251
|
-
} catch (e) {
|
|
252
|
-
errors = errors || [];
|
|
253
|
-
if (e instanceof UnsubscriptionError_1.UnsubscriptionError) {
|
|
254
|
-
errors = errors.concat(flattenUnsubscriptionErrors(e.errors));
|
|
255
|
-
} else {
|
|
256
|
-
errors.push(e);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
if (errors) {
|
|
263
|
-
throw new UnsubscriptionError_1.UnsubscriptionError(errors);
|
|
264
|
-
}
|
|
265
|
-
};
|
|
266
|
-
Subscription2.prototype.add = function(teardown) {
|
|
267
|
-
var subscription = teardown;
|
|
268
|
-
if (!teardown) {
|
|
269
|
-
return Subscription2.EMPTY;
|
|
270
|
-
}
|
|
271
|
-
switch (typeof teardown) {
|
|
272
|
-
case "function":
|
|
273
|
-
subscription = new Subscription2(teardown);
|
|
274
|
-
case "object":
|
|
275
|
-
if (subscription === this || subscription.closed || typeof subscription.unsubscribe !== "function") {
|
|
276
|
-
return subscription;
|
|
277
|
-
} else if (this.closed) {
|
|
278
|
-
subscription.unsubscribe();
|
|
279
|
-
return subscription;
|
|
280
|
-
} else if (!(subscription instanceof Subscription2)) {
|
|
281
|
-
var tmp = subscription;
|
|
282
|
-
subscription = new Subscription2();
|
|
283
|
-
subscription._subscriptions = [tmp];
|
|
284
|
-
}
|
|
285
|
-
break;
|
|
286
|
-
default: {
|
|
287
|
-
throw new Error("unrecognized teardown " + teardown + " added to Subscription.");
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
var _parentOrParents = subscription._parentOrParents;
|
|
291
|
-
if (_parentOrParents === null) {
|
|
292
|
-
subscription._parentOrParents = this;
|
|
293
|
-
} else if (_parentOrParents instanceof Subscription2) {
|
|
294
|
-
if (_parentOrParents === this) {
|
|
295
|
-
return subscription;
|
|
296
|
-
}
|
|
297
|
-
subscription._parentOrParents = [_parentOrParents, this];
|
|
298
|
-
} else if (_parentOrParents.indexOf(this) === -1) {
|
|
299
|
-
_parentOrParents.push(this);
|
|
300
|
-
} else {
|
|
301
|
-
return subscription;
|
|
302
|
-
}
|
|
303
|
-
var subscriptions = this._subscriptions;
|
|
304
|
-
if (subscriptions === null) {
|
|
305
|
-
this._subscriptions = [subscription];
|
|
306
|
-
} else {
|
|
307
|
-
subscriptions.push(subscription);
|
|
308
|
-
}
|
|
309
|
-
return subscription;
|
|
310
|
-
};
|
|
311
|
-
Subscription2.prototype.remove = function(subscription) {
|
|
312
|
-
var subscriptions = this._subscriptions;
|
|
313
|
-
if (subscriptions) {
|
|
314
|
-
var subscriptionIndex = subscriptions.indexOf(subscription);
|
|
315
|
-
if (subscriptionIndex !== -1) {
|
|
316
|
-
subscriptions.splice(subscriptionIndex, 1);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
};
|
|
320
|
-
Subscription2.EMPTY = function(empty) {
|
|
321
|
-
empty.closed = true;
|
|
322
|
-
return empty;
|
|
323
|
-
}(new Subscription2());
|
|
324
|
-
return Subscription2;
|
|
325
|
-
}();
|
|
326
|
-
exports.Subscription = Subscription;
|
|
327
|
-
function flattenUnsubscriptionErrors(errors) {
|
|
328
|
-
return errors.reduce(function(errs, err) {
|
|
329
|
-
return errs.concat(err instanceof UnsubscriptionError_1.UnsubscriptionError ? err.errors : err);
|
|
330
|
-
}, []);
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
// node_modules/rxjs/internal/symbol/rxSubscriber.js
|
|
336
|
-
var require_rxSubscriber = __commonJS({
|
|
337
|
-
"node_modules/rxjs/internal/symbol/rxSubscriber.js"(exports) {
|
|
338
|
-
"use strict";
|
|
339
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
340
|
-
exports.rxSubscriber = function() {
|
|
341
|
-
return typeof Symbol === "function" ? Symbol("rxSubscriber") : "@@rxSubscriber_" + Math.random();
|
|
342
|
-
}();
|
|
343
|
-
exports.$$rxSubscriber = exports.rxSubscriber;
|
|
344
|
-
}
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
// node_modules/rxjs/internal/Subscriber.js
|
|
348
|
-
var require_Subscriber = __commonJS({
|
|
349
|
-
"node_modules/rxjs/internal/Subscriber.js"(exports) {
|
|
350
|
-
"use strict";
|
|
351
|
-
var __extends = exports && exports.__extends || function() {
|
|
352
|
-
var extendStatics = function(d, b) {
|
|
353
|
-
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
354
|
-
d2.__proto__ = b2;
|
|
355
|
-
} || function(d2, b2) {
|
|
356
|
-
for (var p in b2)
|
|
357
|
-
if (b2.hasOwnProperty(p))
|
|
358
|
-
d2[p] = b2[p];
|
|
359
|
-
};
|
|
360
|
-
return extendStatics(d, b);
|
|
361
|
-
};
|
|
362
|
-
return function(d, b) {
|
|
363
|
-
extendStatics(d, b);
|
|
364
|
-
function __() {
|
|
365
|
-
this.constructor = d;
|
|
366
|
-
}
|
|
367
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
368
|
-
};
|
|
369
|
-
}();
|
|
370
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
371
|
-
var isFunction_1 = require_isFunction();
|
|
372
|
-
var Observer_1 = require_Observer();
|
|
373
|
-
var Subscription_1 = require_Subscription();
|
|
374
|
-
var rxSubscriber_1 = require_rxSubscriber();
|
|
375
|
-
var config_1 = require_config();
|
|
376
|
-
var hostReportError_1 = require_hostReportError();
|
|
377
|
-
var Subscriber = function(_super) {
|
|
378
|
-
__extends(Subscriber2, _super);
|
|
379
|
-
function Subscriber2(destinationOrNext, error, complete) {
|
|
380
|
-
var _this = _super.call(this) || this;
|
|
381
|
-
_this.syncErrorValue = null;
|
|
382
|
-
_this.syncErrorThrown = false;
|
|
383
|
-
_this.syncErrorThrowable = false;
|
|
384
|
-
_this.isStopped = false;
|
|
385
|
-
switch (arguments.length) {
|
|
386
|
-
case 0:
|
|
387
|
-
_this.destination = Observer_1.empty;
|
|
388
|
-
break;
|
|
389
|
-
case 1:
|
|
390
|
-
if (!destinationOrNext) {
|
|
391
|
-
_this.destination = Observer_1.empty;
|
|
392
|
-
break;
|
|
393
|
-
}
|
|
394
|
-
if (typeof destinationOrNext === "object") {
|
|
395
|
-
if (destinationOrNext instanceof Subscriber2) {
|
|
396
|
-
_this.syncErrorThrowable = destinationOrNext.syncErrorThrowable;
|
|
397
|
-
_this.destination = destinationOrNext;
|
|
398
|
-
destinationOrNext.add(_this);
|
|
399
|
-
} else {
|
|
400
|
-
_this.syncErrorThrowable = true;
|
|
401
|
-
_this.destination = new SafeSubscriber(_this, destinationOrNext);
|
|
402
|
-
}
|
|
403
|
-
break;
|
|
404
|
-
}
|
|
405
|
-
default:
|
|
406
|
-
_this.syncErrorThrowable = true;
|
|
407
|
-
_this.destination = new SafeSubscriber(_this, destinationOrNext, error, complete);
|
|
408
|
-
break;
|
|
409
|
-
}
|
|
410
|
-
return _this;
|
|
411
|
-
}
|
|
412
|
-
Subscriber2.prototype[rxSubscriber_1.rxSubscriber] = function() {
|
|
413
|
-
return this;
|
|
414
|
-
};
|
|
415
|
-
Subscriber2.create = function(next, error, complete) {
|
|
416
|
-
var subscriber = new Subscriber2(next, error, complete);
|
|
417
|
-
subscriber.syncErrorThrowable = false;
|
|
418
|
-
return subscriber;
|
|
419
|
-
};
|
|
420
|
-
Subscriber2.prototype.next = function(value) {
|
|
421
|
-
if (!this.isStopped) {
|
|
422
|
-
this._next(value);
|
|
423
|
-
}
|
|
424
|
-
};
|
|
425
|
-
Subscriber2.prototype.error = function(err) {
|
|
426
|
-
if (!this.isStopped) {
|
|
427
|
-
this.isStopped = true;
|
|
428
|
-
this._error(err);
|
|
429
|
-
}
|
|
430
|
-
};
|
|
431
|
-
Subscriber2.prototype.complete = function() {
|
|
432
|
-
if (!this.isStopped) {
|
|
433
|
-
this.isStopped = true;
|
|
434
|
-
this._complete();
|
|
435
|
-
}
|
|
436
|
-
};
|
|
437
|
-
Subscriber2.prototype.unsubscribe = function() {
|
|
438
|
-
if (this.closed) {
|
|
439
|
-
return;
|
|
440
|
-
}
|
|
441
|
-
this.isStopped = true;
|
|
442
|
-
_super.prototype.unsubscribe.call(this);
|
|
443
|
-
};
|
|
444
|
-
Subscriber2.prototype._next = function(value) {
|
|
445
|
-
this.destination.next(value);
|
|
446
|
-
};
|
|
447
|
-
Subscriber2.prototype._error = function(err) {
|
|
448
|
-
this.destination.error(err);
|
|
449
|
-
this.unsubscribe();
|
|
450
|
-
};
|
|
451
|
-
Subscriber2.prototype._complete = function() {
|
|
452
|
-
this.destination.complete();
|
|
453
|
-
this.unsubscribe();
|
|
454
|
-
};
|
|
455
|
-
Subscriber2.prototype._unsubscribeAndRecycle = function() {
|
|
456
|
-
var _parentOrParents = this._parentOrParents;
|
|
457
|
-
this._parentOrParents = null;
|
|
458
|
-
this.unsubscribe();
|
|
459
|
-
this.closed = false;
|
|
460
|
-
this.isStopped = false;
|
|
461
|
-
this._parentOrParents = _parentOrParents;
|
|
462
|
-
return this;
|
|
463
|
-
};
|
|
464
|
-
return Subscriber2;
|
|
465
|
-
}(Subscription_1.Subscription);
|
|
466
|
-
exports.Subscriber = Subscriber;
|
|
467
|
-
var SafeSubscriber = function(_super) {
|
|
468
|
-
__extends(SafeSubscriber2, _super);
|
|
469
|
-
function SafeSubscriber2(_parentSubscriber, observerOrNext, error, complete) {
|
|
470
|
-
var _this = _super.call(this) || this;
|
|
471
|
-
_this._parentSubscriber = _parentSubscriber;
|
|
472
|
-
var next;
|
|
473
|
-
var context = _this;
|
|
474
|
-
if (isFunction_1.isFunction(observerOrNext)) {
|
|
475
|
-
next = observerOrNext;
|
|
476
|
-
} else if (observerOrNext) {
|
|
477
|
-
next = observerOrNext.next;
|
|
478
|
-
error = observerOrNext.error;
|
|
479
|
-
complete = observerOrNext.complete;
|
|
480
|
-
if (observerOrNext !== Observer_1.empty) {
|
|
481
|
-
context = Object.create(observerOrNext);
|
|
482
|
-
if (isFunction_1.isFunction(context.unsubscribe)) {
|
|
483
|
-
_this.add(context.unsubscribe.bind(context));
|
|
484
|
-
}
|
|
485
|
-
context.unsubscribe = _this.unsubscribe.bind(_this);
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
_this._context = context;
|
|
489
|
-
_this._next = next;
|
|
490
|
-
_this._error = error;
|
|
491
|
-
_this._complete = complete;
|
|
492
|
-
return _this;
|
|
493
|
-
}
|
|
494
|
-
SafeSubscriber2.prototype.next = function(value) {
|
|
495
|
-
if (!this.isStopped && this._next) {
|
|
496
|
-
var _parentSubscriber = this._parentSubscriber;
|
|
497
|
-
if (!config_1.config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
|
|
498
|
-
this.__tryOrUnsub(this._next, value);
|
|
499
|
-
} else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
|
|
500
|
-
this.unsubscribe();
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
};
|
|
504
|
-
SafeSubscriber2.prototype.error = function(err) {
|
|
505
|
-
if (!this.isStopped) {
|
|
506
|
-
var _parentSubscriber = this._parentSubscriber;
|
|
507
|
-
var useDeprecatedSynchronousErrorHandling = config_1.config.useDeprecatedSynchronousErrorHandling;
|
|
508
|
-
if (this._error) {
|
|
509
|
-
if (!useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
|
|
510
|
-
this.__tryOrUnsub(this._error, err);
|
|
511
|
-
this.unsubscribe();
|
|
512
|
-
} else {
|
|
513
|
-
this.__tryOrSetError(_parentSubscriber, this._error, err);
|
|
514
|
-
this.unsubscribe();
|
|
515
|
-
}
|
|
516
|
-
} else if (!_parentSubscriber.syncErrorThrowable) {
|
|
517
|
-
this.unsubscribe();
|
|
518
|
-
if (useDeprecatedSynchronousErrorHandling) {
|
|
519
|
-
throw err;
|
|
520
|
-
}
|
|
521
|
-
hostReportError_1.hostReportError(err);
|
|
522
|
-
} else {
|
|
523
|
-
if (useDeprecatedSynchronousErrorHandling) {
|
|
524
|
-
_parentSubscriber.syncErrorValue = err;
|
|
525
|
-
_parentSubscriber.syncErrorThrown = true;
|
|
526
|
-
} else {
|
|
527
|
-
hostReportError_1.hostReportError(err);
|
|
528
|
-
}
|
|
529
|
-
this.unsubscribe();
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
};
|
|
533
|
-
SafeSubscriber2.prototype.complete = function() {
|
|
534
|
-
var _this = this;
|
|
535
|
-
if (!this.isStopped) {
|
|
536
|
-
var _parentSubscriber = this._parentSubscriber;
|
|
537
|
-
if (this._complete) {
|
|
538
|
-
var wrappedComplete = function() {
|
|
539
|
-
return _this._complete.call(_this._context);
|
|
540
|
-
};
|
|
541
|
-
if (!config_1.config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
|
|
542
|
-
this.__tryOrUnsub(wrappedComplete);
|
|
543
|
-
this.unsubscribe();
|
|
544
|
-
} else {
|
|
545
|
-
this.__tryOrSetError(_parentSubscriber, wrappedComplete);
|
|
546
|
-
this.unsubscribe();
|
|
547
|
-
}
|
|
548
|
-
} else {
|
|
549
|
-
this.unsubscribe();
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
};
|
|
553
|
-
SafeSubscriber2.prototype.__tryOrUnsub = function(fn, value) {
|
|
554
|
-
try {
|
|
555
|
-
fn.call(this._context, value);
|
|
556
|
-
} catch (err) {
|
|
557
|
-
this.unsubscribe();
|
|
558
|
-
if (config_1.config.useDeprecatedSynchronousErrorHandling) {
|
|
559
|
-
throw err;
|
|
560
|
-
} else {
|
|
561
|
-
hostReportError_1.hostReportError(err);
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
};
|
|
565
|
-
SafeSubscriber2.prototype.__tryOrSetError = function(parent, fn, value) {
|
|
566
|
-
if (!config_1.config.useDeprecatedSynchronousErrorHandling) {
|
|
567
|
-
throw new Error("bad call");
|
|
568
|
-
}
|
|
569
|
-
try {
|
|
570
|
-
fn.call(this._context, value);
|
|
571
|
-
} catch (err) {
|
|
572
|
-
if (config_1.config.useDeprecatedSynchronousErrorHandling) {
|
|
573
|
-
parent.syncErrorValue = err;
|
|
574
|
-
parent.syncErrorThrown = true;
|
|
575
|
-
return true;
|
|
576
|
-
} else {
|
|
577
|
-
hostReportError_1.hostReportError(err);
|
|
578
|
-
return true;
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
return false;
|
|
582
|
-
};
|
|
583
|
-
SafeSubscriber2.prototype._unsubscribe = function() {
|
|
584
|
-
var _parentSubscriber = this._parentSubscriber;
|
|
585
|
-
this._context = null;
|
|
586
|
-
this._parentSubscriber = null;
|
|
587
|
-
_parentSubscriber.unsubscribe();
|
|
588
|
-
};
|
|
589
|
-
return SafeSubscriber2;
|
|
590
|
-
}(Subscriber);
|
|
591
|
-
exports.SafeSubscriber = SafeSubscriber;
|
|
592
|
-
}
|
|
593
|
-
});
|
|
594
|
-
|
|
595
|
-
// node_modules/rxjs/internal/util/canReportError.js
|
|
596
|
-
var require_canReportError = __commonJS({
|
|
597
|
-
"node_modules/rxjs/internal/util/canReportError.js"(exports) {
|
|
598
|
-
"use strict";
|
|
599
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
600
|
-
var Subscriber_1 = require_Subscriber();
|
|
601
|
-
function canReportError(observer) {
|
|
602
|
-
while (observer) {
|
|
603
|
-
var _a = observer, closed_1 = _a.closed, destination = _a.destination, isStopped = _a.isStopped;
|
|
604
|
-
if (closed_1 || isStopped) {
|
|
605
|
-
return false;
|
|
606
|
-
} else if (destination && destination instanceof Subscriber_1.Subscriber) {
|
|
607
|
-
observer = destination;
|
|
608
|
-
} else {
|
|
609
|
-
observer = null;
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
return true;
|
|
613
|
-
}
|
|
614
|
-
exports.canReportError = canReportError;
|
|
615
|
-
}
|
|
616
|
-
});
|
|
617
|
-
|
|
618
|
-
// node_modules/rxjs/internal/util/toSubscriber.js
|
|
619
|
-
var require_toSubscriber = __commonJS({
|
|
620
|
-
"node_modules/rxjs/internal/util/toSubscriber.js"(exports) {
|
|
621
|
-
"use strict";
|
|
622
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
623
|
-
var Subscriber_1 = require_Subscriber();
|
|
624
|
-
var rxSubscriber_1 = require_rxSubscriber();
|
|
625
|
-
var Observer_1 = require_Observer();
|
|
626
|
-
function toSubscriber(nextOrObserver, error, complete) {
|
|
627
|
-
if (nextOrObserver) {
|
|
628
|
-
if (nextOrObserver instanceof Subscriber_1.Subscriber) {
|
|
629
|
-
return nextOrObserver;
|
|
630
|
-
}
|
|
631
|
-
if (nextOrObserver[rxSubscriber_1.rxSubscriber]) {
|
|
632
|
-
return nextOrObserver[rxSubscriber_1.rxSubscriber]();
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
if (!nextOrObserver && !error && !complete) {
|
|
636
|
-
return new Subscriber_1.Subscriber(Observer_1.empty);
|
|
637
|
-
}
|
|
638
|
-
return new Subscriber_1.Subscriber(nextOrObserver, error, complete);
|
|
639
|
-
}
|
|
640
|
-
exports.toSubscriber = toSubscriber;
|
|
641
|
-
}
|
|
642
|
-
});
|
|
643
|
-
|
|
644
|
-
// node_modules/rxjs/internal/symbol/observable.js
|
|
645
|
-
var require_observable = __commonJS({
|
|
646
|
-
"node_modules/rxjs/internal/symbol/observable.js"(exports) {
|
|
647
|
-
"use strict";
|
|
648
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
649
|
-
exports.observable = function() {
|
|
650
|
-
return typeof Symbol === "function" && Symbol.observable || "@@observable";
|
|
651
|
-
}();
|
|
652
|
-
}
|
|
653
|
-
});
|
|
654
|
-
|
|
655
|
-
// node_modules/rxjs/internal/util/identity.js
|
|
656
|
-
var require_identity = __commonJS({
|
|
657
|
-
"node_modules/rxjs/internal/util/identity.js"(exports) {
|
|
658
|
-
"use strict";
|
|
659
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
660
|
-
function identity(x) {
|
|
661
|
-
return x;
|
|
662
|
-
}
|
|
663
|
-
exports.identity = identity;
|
|
664
|
-
}
|
|
665
|
-
});
|
|
666
|
-
|
|
667
|
-
// node_modules/rxjs/internal/util/pipe.js
|
|
668
|
-
var require_pipe = __commonJS({
|
|
669
|
-
"node_modules/rxjs/internal/util/pipe.js"(exports) {
|
|
670
|
-
"use strict";
|
|
671
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
672
|
-
var identity_1 = require_identity();
|
|
673
|
-
function pipe() {
|
|
674
|
-
var fns = [];
|
|
675
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
676
|
-
fns[_i] = arguments[_i];
|
|
677
|
-
}
|
|
678
|
-
return pipeFromArray(fns);
|
|
679
|
-
}
|
|
680
|
-
exports.pipe = pipe;
|
|
681
|
-
function pipeFromArray(fns) {
|
|
682
|
-
if (fns.length === 0) {
|
|
683
|
-
return identity_1.identity;
|
|
684
|
-
}
|
|
685
|
-
if (fns.length === 1) {
|
|
686
|
-
return fns[0];
|
|
687
|
-
}
|
|
688
|
-
return function piped(input) {
|
|
689
|
-
return fns.reduce(function(prev, fn) {
|
|
690
|
-
return fn(prev);
|
|
691
|
-
}, input);
|
|
692
|
-
};
|
|
693
|
-
}
|
|
694
|
-
exports.pipeFromArray = pipeFromArray;
|
|
695
|
-
}
|
|
696
|
-
});
|
|
697
|
-
|
|
698
|
-
// node_modules/rxjs/internal/Observable.js
|
|
699
|
-
var require_Observable = __commonJS({
|
|
700
|
-
"node_modules/rxjs/internal/Observable.js"(exports) {
|
|
701
|
-
"use strict";
|
|
702
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
703
|
-
var canReportError_1 = require_canReportError();
|
|
704
|
-
var toSubscriber_1 = require_toSubscriber();
|
|
705
|
-
var observable_1 = require_observable();
|
|
706
|
-
var pipe_1 = require_pipe();
|
|
707
|
-
var config_1 = require_config();
|
|
708
|
-
var Observable = function() {
|
|
709
|
-
function Observable2(subscribe) {
|
|
710
|
-
this._isScalar = false;
|
|
711
|
-
if (subscribe) {
|
|
712
|
-
this._subscribe = subscribe;
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
Observable2.prototype.lift = function(operator) {
|
|
716
|
-
var observable = new Observable2();
|
|
717
|
-
observable.source = this;
|
|
718
|
-
observable.operator = operator;
|
|
719
|
-
return observable;
|
|
720
|
-
};
|
|
721
|
-
Observable2.prototype.subscribe = function(observerOrNext, error, complete) {
|
|
722
|
-
var operator = this.operator;
|
|
723
|
-
var sink = toSubscriber_1.toSubscriber(observerOrNext, error, complete);
|
|
724
|
-
if (operator) {
|
|
725
|
-
sink.add(operator.call(sink, this.source));
|
|
726
|
-
} else {
|
|
727
|
-
sink.add(this.source || config_1.config.useDeprecatedSynchronousErrorHandling && !sink.syncErrorThrowable ? this._subscribe(sink) : this._trySubscribe(sink));
|
|
728
|
-
}
|
|
729
|
-
if (config_1.config.useDeprecatedSynchronousErrorHandling) {
|
|
730
|
-
if (sink.syncErrorThrowable) {
|
|
731
|
-
sink.syncErrorThrowable = false;
|
|
732
|
-
if (sink.syncErrorThrown) {
|
|
733
|
-
throw sink.syncErrorValue;
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
return sink;
|
|
738
|
-
};
|
|
739
|
-
Observable2.prototype._trySubscribe = function(sink) {
|
|
740
|
-
try {
|
|
741
|
-
return this._subscribe(sink);
|
|
742
|
-
} catch (err) {
|
|
743
|
-
if (config_1.config.useDeprecatedSynchronousErrorHandling) {
|
|
744
|
-
sink.syncErrorThrown = true;
|
|
745
|
-
sink.syncErrorValue = err;
|
|
746
|
-
}
|
|
747
|
-
if (canReportError_1.canReportError(sink)) {
|
|
748
|
-
sink.error(err);
|
|
749
|
-
} else {
|
|
750
|
-
console.warn(err);
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
};
|
|
754
|
-
Observable2.prototype.forEach = function(next, promiseCtor) {
|
|
755
|
-
var _this = this;
|
|
756
|
-
promiseCtor = getPromiseCtor(promiseCtor);
|
|
757
|
-
return new promiseCtor(function(resolve, reject) {
|
|
758
|
-
var subscription;
|
|
759
|
-
subscription = _this.subscribe(function(value) {
|
|
760
|
-
try {
|
|
761
|
-
next(value);
|
|
762
|
-
} catch (err) {
|
|
763
|
-
reject(err);
|
|
764
|
-
if (subscription) {
|
|
765
|
-
subscription.unsubscribe();
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
}, reject, resolve);
|
|
769
|
-
});
|
|
770
|
-
};
|
|
771
|
-
Observable2.prototype._subscribe = function(subscriber) {
|
|
772
|
-
var source = this.source;
|
|
773
|
-
return source && source.subscribe(subscriber);
|
|
774
|
-
};
|
|
775
|
-
Observable2.prototype[observable_1.observable] = function() {
|
|
776
|
-
return this;
|
|
777
|
-
};
|
|
778
|
-
Observable2.prototype.pipe = function() {
|
|
779
|
-
var operations = [];
|
|
780
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
781
|
-
operations[_i] = arguments[_i];
|
|
782
|
-
}
|
|
783
|
-
if (operations.length === 0) {
|
|
784
|
-
return this;
|
|
785
|
-
}
|
|
786
|
-
return pipe_1.pipeFromArray(operations)(this);
|
|
787
|
-
};
|
|
788
|
-
Observable2.prototype.toPromise = function(promiseCtor) {
|
|
789
|
-
var _this = this;
|
|
790
|
-
promiseCtor = getPromiseCtor(promiseCtor);
|
|
791
|
-
return new promiseCtor(function(resolve, reject) {
|
|
792
|
-
var value;
|
|
793
|
-
_this.subscribe(function(x) {
|
|
794
|
-
return value = x;
|
|
795
|
-
}, function(err) {
|
|
796
|
-
return reject(err);
|
|
797
|
-
}, function() {
|
|
798
|
-
return resolve(value);
|
|
799
|
-
});
|
|
800
|
-
});
|
|
801
|
-
};
|
|
802
|
-
Observable2.create = function(subscribe) {
|
|
803
|
-
return new Observable2(subscribe);
|
|
804
|
-
};
|
|
805
|
-
return Observable2;
|
|
806
|
-
}();
|
|
807
|
-
exports.Observable = Observable;
|
|
808
|
-
function getPromiseCtor(promiseCtor) {
|
|
809
|
-
if (!promiseCtor) {
|
|
810
|
-
promiseCtor = config_1.config.Promise || Promise;
|
|
811
|
-
}
|
|
812
|
-
if (!promiseCtor) {
|
|
813
|
-
throw new Error("no Promise impl found");
|
|
814
|
-
}
|
|
815
|
-
return promiseCtor;
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
});
|
|
819
|
-
|
|
820
|
-
// node_modules/rxjs/internal/operators/filter.js
|
|
821
|
-
var require_filter = __commonJS({
|
|
822
|
-
"node_modules/rxjs/internal/operators/filter.js"(exports) {
|
|
823
|
-
"use strict";
|
|
824
|
-
var __extends = exports && exports.__extends || function() {
|
|
825
|
-
var extendStatics = function(d, b) {
|
|
826
|
-
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
827
|
-
d2.__proto__ = b2;
|
|
828
|
-
} || function(d2, b2) {
|
|
829
|
-
for (var p in b2)
|
|
830
|
-
if (b2.hasOwnProperty(p))
|
|
831
|
-
d2[p] = b2[p];
|
|
832
|
-
};
|
|
833
|
-
return extendStatics(d, b);
|
|
834
|
-
};
|
|
835
|
-
return function(d, b) {
|
|
836
|
-
extendStatics(d, b);
|
|
837
|
-
function __() {
|
|
838
|
-
this.constructor = d;
|
|
839
|
-
}
|
|
840
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
841
|
-
};
|
|
842
|
-
}();
|
|
843
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
844
|
-
var Subscriber_1 = require_Subscriber();
|
|
845
|
-
function filter(predicate, thisArg) {
|
|
846
|
-
return function filterOperatorFunction(source) {
|
|
847
|
-
return source.lift(new FilterOperator(predicate, thisArg));
|
|
848
|
-
};
|
|
849
|
-
}
|
|
850
|
-
exports.filter = filter;
|
|
851
|
-
var FilterOperator = function() {
|
|
852
|
-
function FilterOperator2(predicate, thisArg) {
|
|
853
|
-
this.predicate = predicate;
|
|
854
|
-
this.thisArg = thisArg;
|
|
855
|
-
}
|
|
856
|
-
FilterOperator2.prototype.call = function(subscriber, source) {
|
|
857
|
-
return source.subscribe(new FilterSubscriber(subscriber, this.predicate, this.thisArg));
|
|
858
|
-
};
|
|
859
|
-
return FilterOperator2;
|
|
860
|
-
}();
|
|
861
|
-
var FilterSubscriber = function(_super) {
|
|
862
|
-
__extends(FilterSubscriber2, _super);
|
|
863
|
-
function FilterSubscriber2(destination, predicate, thisArg) {
|
|
864
|
-
var _this = _super.call(this, destination) || this;
|
|
865
|
-
_this.predicate = predicate;
|
|
866
|
-
_this.thisArg = thisArg;
|
|
867
|
-
_this.count = 0;
|
|
868
|
-
return _this;
|
|
869
|
-
}
|
|
870
|
-
FilterSubscriber2.prototype._next = function(value) {
|
|
871
|
-
var result;
|
|
872
|
-
try {
|
|
873
|
-
result = this.predicate.call(this.thisArg, value, this.count++);
|
|
874
|
-
} catch (err) {
|
|
875
|
-
this.destination.error(err);
|
|
876
|
-
return;
|
|
877
|
-
}
|
|
878
|
-
if (result) {
|
|
879
|
-
this.destination.next(value);
|
|
880
|
-
}
|
|
881
|
-
};
|
|
882
|
-
return FilterSubscriber2;
|
|
883
|
-
}(Subscriber_1.Subscriber);
|
|
884
|
-
}
|
|
885
|
-
});
|
|
886
|
-
|
|
887
|
-
// node_modules/rxjs/internal/operators/map.js
|
|
888
|
-
var require_map = __commonJS({
|
|
889
|
-
"node_modules/rxjs/internal/operators/map.js"(exports) {
|
|
890
|
-
"use strict";
|
|
891
|
-
var __extends = exports && exports.__extends || function() {
|
|
892
|
-
var extendStatics = function(d, b) {
|
|
893
|
-
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
894
|
-
d2.__proto__ = b2;
|
|
895
|
-
} || function(d2, b2) {
|
|
896
|
-
for (var p in b2)
|
|
897
|
-
if (b2.hasOwnProperty(p))
|
|
898
|
-
d2[p] = b2[p];
|
|
899
|
-
};
|
|
900
|
-
return extendStatics(d, b);
|
|
901
|
-
};
|
|
902
|
-
return function(d, b) {
|
|
903
|
-
extendStatics(d, b);
|
|
904
|
-
function __() {
|
|
905
|
-
this.constructor = d;
|
|
906
|
-
}
|
|
907
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
908
|
-
};
|
|
909
|
-
}();
|
|
910
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
911
|
-
var Subscriber_1 = require_Subscriber();
|
|
912
|
-
function map(project, thisArg) {
|
|
913
|
-
return function mapOperation(source) {
|
|
914
|
-
if (typeof project !== "function") {
|
|
915
|
-
throw new TypeError("argument is not a function. Are you looking for `mapTo()`?");
|
|
916
|
-
}
|
|
917
|
-
return source.lift(new MapOperator(project, thisArg));
|
|
918
|
-
};
|
|
919
|
-
}
|
|
920
|
-
exports.map = map;
|
|
921
|
-
var MapOperator = function() {
|
|
922
|
-
function MapOperator2(project, thisArg) {
|
|
923
|
-
this.project = project;
|
|
924
|
-
this.thisArg = thisArg;
|
|
925
|
-
}
|
|
926
|
-
MapOperator2.prototype.call = function(subscriber, source) {
|
|
927
|
-
return source.subscribe(new MapSubscriber(subscriber, this.project, this.thisArg));
|
|
928
|
-
};
|
|
929
|
-
return MapOperator2;
|
|
930
|
-
}();
|
|
931
|
-
exports.MapOperator = MapOperator;
|
|
932
|
-
var MapSubscriber = function(_super) {
|
|
933
|
-
__extends(MapSubscriber2, _super);
|
|
934
|
-
function MapSubscriber2(destination, project, thisArg) {
|
|
935
|
-
var _this = _super.call(this, destination) || this;
|
|
936
|
-
_this.project = project;
|
|
937
|
-
_this.count = 0;
|
|
938
|
-
_this.thisArg = thisArg || _this;
|
|
939
|
-
return _this;
|
|
940
|
-
}
|
|
941
|
-
MapSubscriber2.prototype._next = function(value) {
|
|
942
|
-
var result;
|
|
943
|
-
try {
|
|
944
|
-
result = this.project.call(this.thisArg, value, this.count++);
|
|
945
|
-
} catch (err) {
|
|
946
|
-
this.destination.error(err);
|
|
947
|
-
return;
|
|
948
|
-
}
|
|
949
|
-
this.destination.next(result);
|
|
950
|
-
};
|
|
951
|
-
return MapSubscriber2;
|
|
952
|
-
}(Subscriber_1.Subscriber);
|
|
953
|
-
}
|
|
954
|
-
});
|
|
955
|
-
|
|
956
13
|
// src/util/observable.js
|
|
957
|
-
var
|
|
14
|
+
var require_observable = __commonJS({
|
|
958
15
|
"src/util/observable.js"(exports, module) {
|
|
959
|
-
var { Observable } =
|
|
960
|
-
var { filter } =
|
|
961
|
-
var { map } =
|
|
16
|
+
var { Observable } = __require("rxjs/internal/Observable");
|
|
17
|
+
var { filter } = __require("rxjs/internal/operators/filter");
|
|
18
|
+
var { map } = __require("rxjs/internal/operators/map");
|
|
962
19
|
module.exports = {
|
|
963
20
|
Observable,
|
|
964
21
|
filter,
|
|
@@ -996,7 +53,9 @@ var require_validators = __commonJS({
|
|
|
996
53
|
var VALID_INSERT_LOCATIONS = ["before", "after", "replace"];
|
|
997
54
|
exports.dataset = (name) => {
|
|
998
55
|
if (!/^(~[a-z0-9]{1}[-\w]{0,63}|[a-z0-9]{1}[-\w]{0,63})$/.test(name)) {
|
|
999
|
-
throw new Error(
|
|
56
|
+
throw new Error(
|
|
57
|
+
"Datasets can only contain lowercase characters, numbers, underscores and dashes, and start with tilde, and be maximum 64 characters"
|
|
58
|
+
);
|
|
1000
59
|
}
|
|
1001
60
|
};
|
|
1002
61
|
exports.projectId = (id) => {
|
|
@@ -1046,7 +105,9 @@ var require_validators = __commonJS({
|
|
|
1046
105
|
};
|
|
1047
106
|
exports.requestTag = (tag) => {
|
|
1048
107
|
if (typeof tag !== "string" || !/^[a-z0-9._-]{1,75}$/i.test(tag)) {
|
|
1049
|
-
throw new Error(
|
|
108
|
+
throw new Error(
|
|
109
|
+
`Tag can only contain alphanumeric characters, underscores, dashes and dots, and be between one and 75 characters long.`
|
|
110
|
+
);
|
|
1050
111
|
}
|
|
1051
112
|
return tag;
|
|
1052
113
|
};
|
|
@@ -1056,7 +117,7 @@ var require_validators = __commonJS({
|
|
|
1056
117
|
// src/data/patch.js
|
|
1057
118
|
var require_patch = __commonJS({
|
|
1058
119
|
"src/data/patch.js"(exports, module) {
|
|
1059
|
-
var assign =
|
|
120
|
+
var assign = __require("object-assign");
|
|
1060
121
|
var getSelection = require_getSelection();
|
|
1061
122
|
var validate = require_validators();
|
|
1062
123
|
var validateObject = validate.validateObject;
|
|
@@ -1127,7 +188,9 @@ var require_patch = __commonJS({
|
|
|
1127
188
|
},
|
|
1128
189
|
commit(options = {}) {
|
|
1129
190
|
if (!this.client) {
|
|
1130
|
-
throw new Error(
|
|
191
|
+
throw new Error(
|
|
192
|
+
"No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method"
|
|
193
|
+
);
|
|
1131
194
|
}
|
|
1132
195
|
const returnFirst = typeof this.selection === "string";
|
|
1133
196
|
const opts = assign({ returnFirst, returnDocuments: true }, options);
|
|
@@ -1155,7 +218,7 @@ var require_patch = __commonJS({
|
|
|
1155
218
|
// src/data/transaction.js
|
|
1156
219
|
var require_transaction = __commonJS({
|
|
1157
220
|
"src/data/transaction.js"(exports, module) {
|
|
1158
|
-
var assign =
|
|
221
|
+
var assign = __require("object-assign");
|
|
1159
222
|
var validators = require_validators();
|
|
1160
223
|
var Patch = require_patch();
|
|
1161
224
|
var defaultMutateOptions = { returnDocuments: false };
|
|
@@ -1218,9 +281,14 @@ var require_transaction = __commonJS({
|
|
|
1218
281
|
},
|
|
1219
282
|
commit(options) {
|
|
1220
283
|
if (!this.client) {
|
|
1221
|
-
throw new Error(
|
|
1222
|
-
|
|
1223
|
-
|
|
284
|
+
throw new Error(
|
|
285
|
+
"No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method"
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
return this.client.mutate(
|
|
289
|
+
this.serialize(),
|
|
290
|
+
assign({ transactionId: this.trxId }, defaultMutateOptions, options || {})
|
|
291
|
+
);
|
|
1224
292
|
},
|
|
1225
293
|
reset() {
|
|
1226
294
|
this.operations = [];
|
|
@@ -1243,7 +311,10 @@ var require_encodeQueryString = __commonJS({
|
|
|
1243
311
|
const { tag, ...opts } = options;
|
|
1244
312
|
const q = `query=${enc(query)}`;
|
|
1245
313
|
const base = tag ? `?tag=${enc(tag)}&${q}` : `?${q}`;
|
|
1246
|
-
const qString = Object.keys(params).reduce(
|
|
314
|
+
const qString = Object.keys(params).reduce(
|
|
315
|
+
(qs, param) => `${qs}&${enc(`$${param}`)}=${enc(JSON.stringify(params[param]))}`,
|
|
316
|
+
base
|
|
317
|
+
);
|
|
1247
318
|
return Object.keys(opts).reduce((qs, option) => {
|
|
1248
319
|
return options[option] ? `${qs}&${enc(option)}=${enc(options[option])}` : qs;
|
|
1249
320
|
}, qString);
|
|
@@ -1251,932 +322,12 @@ var require_encodeQueryString = __commonJS({
|
|
|
1251
322
|
}
|
|
1252
323
|
});
|
|
1253
324
|
|
|
1254
|
-
//
|
|
1255
|
-
var
|
|
1256
|
-
"
|
|
1257
|
-
(
|
|
1258
|
-
"
|
|
1259
|
-
|
|
1260
|
-
var clearTimeout2 = global2.clearTimeout;
|
|
1261
|
-
var XMLHttpRequest2 = global2.XMLHttpRequest;
|
|
1262
|
-
var XDomainRequest2 = global2.XDomainRequest;
|
|
1263
|
-
var ActiveXObject = global2.ActiveXObject;
|
|
1264
|
-
var NativeEventSource = global2.EventSource;
|
|
1265
|
-
var document = global2.document;
|
|
1266
|
-
var Promise2 = global2.Promise;
|
|
1267
|
-
var fetch2 = global2.fetch;
|
|
1268
|
-
var Response = global2.Response;
|
|
1269
|
-
var TextDecoder = global2.TextDecoder;
|
|
1270
|
-
var TextEncoder = global2.TextEncoder;
|
|
1271
|
-
var AbortController2 = global2.AbortController;
|
|
1272
|
-
if (typeof window !== "undefined" && typeof document !== "undefined" && !("readyState" in document) && document.body == null) {
|
|
1273
|
-
document.readyState = "loading";
|
|
1274
|
-
window.addEventListener("load", function(event) {
|
|
1275
|
-
document.readyState = "complete";
|
|
1276
|
-
}, false);
|
|
1277
|
-
}
|
|
1278
|
-
if (XMLHttpRequest2 == null && ActiveXObject != null) {
|
|
1279
|
-
XMLHttpRequest2 = function() {
|
|
1280
|
-
return new ActiveXObject("Microsoft.XMLHTTP");
|
|
1281
|
-
};
|
|
1282
|
-
}
|
|
1283
|
-
if (Object.create == void 0) {
|
|
1284
|
-
Object.create = function(C) {
|
|
1285
|
-
function F() {
|
|
1286
|
-
}
|
|
1287
|
-
F.prototype = C;
|
|
1288
|
-
return new F();
|
|
1289
|
-
};
|
|
1290
|
-
}
|
|
1291
|
-
if (!Date.now) {
|
|
1292
|
-
Date.now = function now() {
|
|
1293
|
-
return new Date().getTime();
|
|
1294
|
-
};
|
|
1295
|
-
}
|
|
1296
|
-
if (AbortController2 == void 0) {
|
|
1297
|
-
var originalFetch2 = fetch2;
|
|
1298
|
-
fetch2 = function(url, options) {
|
|
1299
|
-
var signal = options.signal;
|
|
1300
|
-
return originalFetch2(url, { headers: options.headers, credentials: options.credentials, cache: options.cache }).then(function(response) {
|
|
1301
|
-
var reader = response.body.getReader();
|
|
1302
|
-
signal._reader = reader;
|
|
1303
|
-
if (signal._aborted) {
|
|
1304
|
-
signal._reader.cancel();
|
|
1305
|
-
}
|
|
1306
|
-
return {
|
|
1307
|
-
status: response.status,
|
|
1308
|
-
statusText: response.statusText,
|
|
1309
|
-
headers: response.headers,
|
|
1310
|
-
body: {
|
|
1311
|
-
getReader: function() {
|
|
1312
|
-
return reader;
|
|
1313
|
-
}
|
|
1314
|
-
}
|
|
1315
|
-
};
|
|
1316
|
-
});
|
|
1317
|
-
};
|
|
1318
|
-
AbortController2 = function() {
|
|
1319
|
-
this.signal = {
|
|
1320
|
-
_reader: null,
|
|
1321
|
-
_aborted: false
|
|
1322
|
-
};
|
|
1323
|
-
this.abort = function() {
|
|
1324
|
-
if (this.signal._reader != null) {
|
|
1325
|
-
this.signal._reader.cancel();
|
|
1326
|
-
}
|
|
1327
|
-
this.signal._aborted = true;
|
|
1328
|
-
};
|
|
1329
|
-
};
|
|
1330
|
-
}
|
|
1331
|
-
function TextDecoderPolyfill() {
|
|
1332
|
-
this.bitsNeeded = 0;
|
|
1333
|
-
this.codePoint = 0;
|
|
1334
|
-
}
|
|
1335
|
-
TextDecoderPolyfill.prototype.decode = function(octets) {
|
|
1336
|
-
function valid(codePoint2, shift, octetsCount2) {
|
|
1337
|
-
if (octetsCount2 === 1) {
|
|
1338
|
-
return codePoint2 >= 128 >> shift && codePoint2 << shift <= 2047;
|
|
1339
|
-
}
|
|
1340
|
-
if (octetsCount2 === 2) {
|
|
1341
|
-
return codePoint2 >= 2048 >> shift && codePoint2 << shift <= 55295 || codePoint2 >= 57344 >> shift && codePoint2 << shift <= 65535;
|
|
1342
|
-
}
|
|
1343
|
-
if (octetsCount2 === 3) {
|
|
1344
|
-
return codePoint2 >= 65536 >> shift && codePoint2 << shift <= 1114111;
|
|
1345
|
-
}
|
|
1346
|
-
throw new Error();
|
|
1347
|
-
}
|
|
1348
|
-
function octetsCount(bitsNeeded2, codePoint2) {
|
|
1349
|
-
if (bitsNeeded2 === 6 * 1) {
|
|
1350
|
-
return codePoint2 >> 6 > 15 ? 3 : codePoint2 > 31 ? 2 : 1;
|
|
1351
|
-
}
|
|
1352
|
-
if (bitsNeeded2 === 6 * 2) {
|
|
1353
|
-
return codePoint2 > 15 ? 3 : 2;
|
|
1354
|
-
}
|
|
1355
|
-
if (bitsNeeded2 === 6 * 3) {
|
|
1356
|
-
return 3;
|
|
1357
|
-
}
|
|
1358
|
-
throw new Error();
|
|
1359
|
-
}
|
|
1360
|
-
var REPLACER = 65533;
|
|
1361
|
-
var string = "";
|
|
1362
|
-
var bitsNeeded = this.bitsNeeded;
|
|
1363
|
-
var codePoint = this.codePoint;
|
|
1364
|
-
for (var i = 0; i < octets.length; i += 1) {
|
|
1365
|
-
var octet = octets[i];
|
|
1366
|
-
if (bitsNeeded !== 0) {
|
|
1367
|
-
if (octet < 128 || octet > 191 || !valid(codePoint << 6 | octet & 63, bitsNeeded - 6, octetsCount(bitsNeeded, codePoint))) {
|
|
1368
|
-
bitsNeeded = 0;
|
|
1369
|
-
codePoint = REPLACER;
|
|
1370
|
-
string += String.fromCharCode(codePoint);
|
|
1371
|
-
}
|
|
1372
|
-
}
|
|
1373
|
-
if (bitsNeeded === 0) {
|
|
1374
|
-
if (octet >= 0 && octet <= 127) {
|
|
1375
|
-
bitsNeeded = 0;
|
|
1376
|
-
codePoint = octet;
|
|
1377
|
-
} else if (octet >= 192 && octet <= 223) {
|
|
1378
|
-
bitsNeeded = 6 * 1;
|
|
1379
|
-
codePoint = octet & 31;
|
|
1380
|
-
} else if (octet >= 224 && octet <= 239) {
|
|
1381
|
-
bitsNeeded = 6 * 2;
|
|
1382
|
-
codePoint = octet & 15;
|
|
1383
|
-
} else if (octet >= 240 && octet <= 247) {
|
|
1384
|
-
bitsNeeded = 6 * 3;
|
|
1385
|
-
codePoint = octet & 7;
|
|
1386
|
-
} else {
|
|
1387
|
-
bitsNeeded = 0;
|
|
1388
|
-
codePoint = REPLACER;
|
|
1389
|
-
}
|
|
1390
|
-
if (bitsNeeded !== 0 && !valid(codePoint, bitsNeeded, octetsCount(bitsNeeded, codePoint))) {
|
|
1391
|
-
bitsNeeded = 0;
|
|
1392
|
-
codePoint = REPLACER;
|
|
1393
|
-
}
|
|
1394
|
-
} else {
|
|
1395
|
-
bitsNeeded -= 6;
|
|
1396
|
-
codePoint = codePoint << 6 | octet & 63;
|
|
1397
|
-
}
|
|
1398
|
-
if (bitsNeeded === 0) {
|
|
1399
|
-
if (codePoint <= 65535) {
|
|
1400
|
-
string += String.fromCharCode(codePoint);
|
|
1401
|
-
} else {
|
|
1402
|
-
string += String.fromCharCode(55296 + (codePoint - 65535 - 1 >> 10));
|
|
1403
|
-
string += String.fromCharCode(56320 + (codePoint - 65535 - 1 & 1023));
|
|
1404
|
-
}
|
|
1405
|
-
}
|
|
1406
|
-
}
|
|
1407
|
-
this.bitsNeeded = bitsNeeded;
|
|
1408
|
-
this.codePoint = codePoint;
|
|
1409
|
-
return string;
|
|
1410
|
-
};
|
|
1411
|
-
var supportsStreamOption = function() {
|
|
1412
|
-
try {
|
|
1413
|
-
return new TextDecoder().decode(new TextEncoder().encode("test"), { stream: true }) === "test";
|
|
1414
|
-
} catch (error) {
|
|
1415
|
-
console.debug("TextDecoder does not support streaming option. Using polyfill instead: " + error);
|
|
1416
|
-
}
|
|
1417
|
-
return false;
|
|
1418
|
-
};
|
|
1419
|
-
if (TextDecoder == void 0 || TextEncoder == void 0 || !supportsStreamOption()) {
|
|
1420
|
-
TextDecoder = TextDecoderPolyfill;
|
|
1421
|
-
}
|
|
1422
|
-
var k = function() {
|
|
1423
|
-
};
|
|
1424
|
-
function XHRWrapper(xhr) {
|
|
1425
|
-
this.withCredentials = false;
|
|
1426
|
-
this.readyState = 0;
|
|
1427
|
-
this.status = 0;
|
|
1428
|
-
this.statusText = "";
|
|
1429
|
-
this.responseText = "";
|
|
1430
|
-
this.onprogress = k;
|
|
1431
|
-
this.onload = k;
|
|
1432
|
-
this.onerror = k;
|
|
1433
|
-
this.onreadystatechange = k;
|
|
1434
|
-
this._contentType = "";
|
|
1435
|
-
this._xhr = xhr;
|
|
1436
|
-
this._sendTimeout = 0;
|
|
1437
|
-
this._abort = k;
|
|
1438
|
-
}
|
|
1439
|
-
XHRWrapper.prototype.open = function(method, url) {
|
|
1440
|
-
this._abort(true);
|
|
1441
|
-
var that = this;
|
|
1442
|
-
var xhr = this._xhr;
|
|
1443
|
-
var state = 1;
|
|
1444
|
-
var timeout = 0;
|
|
1445
|
-
this._abort = function(silent) {
|
|
1446
|
-
if (that._sendTimeout !== 0) {
|
|
1447
|
-
clearTimeout2(that._sendTimeout);
|
|
1448
|
-
that._sendTimeout = 0;
|
|
1449
|
-
}
|
|
1450
|
-
if (state === 1 || state === 2 || state === 3) {
|
|
1451
|
-
state = 4;
|
|
1452
|
-
xhr.onload = k;
|
|
1453
|
-
xhr.onerror = k;
|
|
1454
|
-
xhr.onabort = k;
|
|
1455
|
-
xhr.onprogress = k;
|
|
1456
|
-
xhr.onreadystatechange = k;
|
|
1457
|
-
xhr.abort();
|
|
1458
|
-
if (timeout !== 0) {
|
|
1459
|
-
clearTimeout2(timeout);
|
|
1460
|
-
timeout = 0;
|
|
1461
|
-
}
|
|
1462
|
-
if (!silent) {
|
|
1463
|
-
that.readyState = 4;
|
|
1464
|
-
that.onabort(null);
|
|
1465
|
-
that.onreadystatechange();
|
|
1466
|
-
}
|
|
1467
|
-
}
|
|
1468
|
-
state = 0;
|
|
1469
|
-
};
|
|
1470
|
-
var onStart = function() {
|
|
1471
|
-
if (state === 1) {
|
|
1472
|
-
var status = 0;
|
|
1473
|
-
var statusText = "";
|
|
1474
|
-
var contentType = void 0;
|
|
1475
|
-
if (!("contentType" in xhr)) {
|
|
1476
|
-
try {
|
|
1477
|
-
status = xhr.status;
|
|
1478
|
-
statusText = xhr.statusText;
|
|
1479
|
-
contentType = xhr.getResponseHeader("Content-Type");
|
|
1480
|
-
} catch (error) {
|
|
1481
|
-
status = 0;
|
|
1482
|
-
statusText = "";
|
|
1483
|
-
contentType = void 0;
|
|
1484
|
-
}
|
|
1485
|
-
} else {
|
|
1486
|
-
status = 200;
|
|
1487
|
-
statusText = "OK";
|
|
1488
|
-
contentType = xhr.contentType;
|
|
1489
|
-
}
|
|
1490
|
-
if (status !== 0) {
|
|
1491
|
-
state = 2;
|
|
1492
|
-
that.readyState = 2;
|
|
1493
|
-
that.status = status;
|
|
1494
|
-
that.statusText = statusText;
|
|
1495
|
-
that._contentType = contentType;
|
|
1496
|
-
that.onreadystatechange();
|
|
1497
|
-
}
|
|
1498
|
-
}
|
|
1499
|
-
};
|
|
1500
|
-
var onProgress = function() {
|
|
1501
|
-
onStart();
|
|
1502
|
-
if (state === 2 || state === 3) {
|
|
1503
|
-
state = 3;
|
|
1504
|
-
var responseText = "";
|
|
1505
|
-
try {
|
|
1506
|
-
responseText = xhr.responseText;
|
|
1507
|
-
} catch (error) {
|
|
1508
|
-
}
|
|
1509
|
-
that.readyState = 3;
|
|
1510
|
-
that.responseText = responseText;
|
|
1511
|
-
that.onprogress();
|
|
1512
|
-
}
|
|
1513
|
-
};
|
|
1514
|
-
var onFinish = function(type, event) {
|
|
1515
|
-
if (event == null || event.preventDefault == null) {
|
|
1516
|
-
event = {
|
|
1517
|
-
preventDefault: k
|
|
1518
|
-
};
|
|
1519
|
-
}
|
|
1520
|
-
onProgress();
|
|
1521
|
-
if (state === 1 || state === 2 || state === 3) {
|
|
1522
|
-
state = 4;
|
|
1523
|
-
if (timeout !== 0) {
|
|
1524
|
-
clearTimeout2(timeout);
|
|
1525
|
-
timeout = 0;
|
|
1526
|
-
}
|
|
1527
|
-
that.readyState = 4;
|
|
1528
|
-
if (type === "load") {
|
|
1529
|
-
that.onload(event);
|
|
1530
|
-
} else if (type === "error") {
|
|
1531
|
-
that.onerror(event);
|
|
1532
|
-
} else if (type === "abort") {
|
|
1533
|
-
that.onabort(event);
|
|
1534
|
-
} else {
|
|
1535
|
-
throw new TypeError();
|
|
1536
|
-
}
|
|
1537
|
-
that.onreadystatechange();
|
|
1538
|
-
}
|
|
1539
|
-
};
|
|
1540
|
-
var onReadyStateChange = function(event) {
|
|
1541
|
-
if (xhr != void 0) {
|
|
1542
|
-
if (xhr.readyState === 4) {
|
|
1543
|
-
if (!("onload" in xhr) || !("onerror" in xhr) || !("onabort" in xhr)) {
|
|
1544
|
-
onFinish(xhr.responseText === "" ? "error" : "load", event);
|
|
1545
|
-
}
|
|
1546
|
-
} else if (xhr.readyState === 3) {
|
|
1547
|
-
if (!("onprogress" in xhr)) {
|
|
1548
|
-
onProgress();
|
|
1549
|
-
}
|
|
1550
|
-
} else if (xhr.readyState === 2) {
|
|
1551
|
-
onStart();
|
|
1552
|
-
}
|
|
1553
|
-
}
|
|
1554
|
-
};
|
|
1555
|
-
var onTimeout = function() {
|
|
1556
|
-
timeout = setTimeout2(function() {
|
|
1557
|
-
onTimeout();
|
|
1558
|
-
}, 500);
|
|
1559
|
-
if (xhr.readyState === 3) {
|
|
1560
|
-
onProgress();
|
|
1561
|
-
}
|
|
1562
|
-
};
|
|
1563
|
-
if ("onload" in xhr) {
|
|
1564
|
-
xhr.onload = function(event) {
|
|
1565
|
-
onFinish("load", event);
|
|
1566
|
-
};
|
|
1567
|
-
}
|
|
1568
|
-
if ("onerror" in xhr) {
|
|
1569
|
-
xhr.onerror = function(event) {
|
|
1570
|
-
onFinish("error", event);
|
|
1571
|
-
};
|
|
1572
|
-
}
|
|
1573
|
-
if ("onabort" in xhr) {
|
|
1574
|
-
xhr.onabort = function(event) {
|
|
1575
|
-
onFinish("abort", event);
|
|
1576
|
-
};
|
|
1577
|
-
}
|
|
1578
|
-
if ("onprogress" in xhr) {
|
|
1579
|
-
xhr.onprogress = onProgress;
|
|
1580
|
-
}
|
|
1581
|
-
if ("onreadystatechange" in xhr) {
|
|
1582
|
-
xhr.onreadystatechange = function(event) {
|
|
1583
|
-
onReadyStateChange(event);
|
|
1584
|
-
};
|
|
1585
|
-
}
|
|
1586
|
-
if ("contentType" in xhr || !("ontimeout" in XMLHttpRequest2.prototype)) {
|
|
1587
|
-
url += (url.indexOf("?") === -1 ? "?" : "&") + "padding=true";
|
|
1588
|
-
}
|
|
1589
|
-
xhr.open(method, url, true);
|
|
1590
|
-
if ("readyState" in xhr) {
|
|
1591
|
-
timeout = setTimeout2(function() {
|
|
1592
|
-
onTimeout();
|
|
1593
|
-
}, 0);
|
|
1594
|
-
}
|
|
1595
|
-
};
|
|
1596
|
-
XHRWrapper.prototype.abort = function() {
|
|
1597
|
-
this._abort(false);
|
|
1598
|
-
};
|
|
1599
|
-
XHRWrapper.prototype.getResponseHeader = function(name) {
|
|
1600
|
-
return this._contentType;
|
|
1601
|
-
};
|
|
1602
|
-
XHRWrapper.prototype.setRequestHeader = function(name, value) {
|
|
1603
|
-
var xhr = this._xhr;
|
|
1604
|
-
if ("setRequestHeader" in xhr) {
|
|
1605
|
-
xhr.setRequestHeader(name, value);
|
|
1606
|
-
}
|
|
1607
|
-
};
|
|
1608
|
-
XHRWrapper.prototype.getAllResponseHeaders = function() {
|
|
1609
|
-
return this._xhr.getAllResponseHeaders != void 0 ? this._xhr.getAllResponseHeaders() || "" : "";
|
|
1610
|
-
};
|
|
1611
|
-
XHRWrapper.prototype.send = function() {
|
|
1612
|
-
if ((!("ontimeout" in XMLHttpRequest2.prototype) || !("sendAsBinary" in XMLHttpRequest2.prototype) && !("mozAnon" in XMLHttpRequest2.prototype)) && document != void 0 && document.readyState != void 0 && document.readyState !== "complete") {
|
|
1613
|
-
var that = this;
|
|
1614
|
-
that._sendTimeout = setTimeout2(function() {
|
|
1615
|
-
that._sendTimeout = 0;
|
|
1616
|
-
that.send();
|
|
1617
|
-
}, 4);
|
|
1618
|
-
return;
|
|
1619
|
-
}
|
|
1620
|
-
var xhr = this._xhr;
|
|
1621
|
-
if ("withCredentials" in xhr) {
|
|
1622
|
-
xhr.withCredentials = this.withCredentials;
|
|
1623
|
-
}
|
|
1624
|
-
try {
|
|
1625
|
-
xhr.send(void 0);
|
|
1626
|
-
} catch (error1) {
|
|
1627
|
-
throw error1;
|
|
1628
|
-
}
|
|
1629
|
-
};
|
|
1630
|
-
function toLowerCase(name) {
|
|
1631
|
-
return name.replace(/[A-Z]/g, function(c) {
|
|
1632
|
-
return String.fromCharCode(c.charCodeAt(0) + 32);
|
|
1633
|
-
});
|
|
1634
|
-
}
|
|
1635
|
-
function HeadersPolyfill(all) {
|
|
1636
|
-
var map = /* @__PURE__ */ Object.create(null);
|
|
1637
|
-
var array = all.split("\r\n");
|
|
1638
|
-
for (var i = 0; i < array.length; i += 1) {
|
|
1639
|
-
var line = array[i];
|
|
1640
|
-
var parts = line.split(": ");
|
|
1641
|
-
var name = parts.shift();
|
|
1642
|
-
var value = parts.join(": ");
|
|
1643
|
-
map[toLowerCase(name)] = value;
|
|
1644
|
-
}
|
|
1645
|
-
this._map = map;
|
|
1646
|
-
}
|
|
1647
|
-
HeadersPolyfill.prototype.get = function(name) {
|
|
1648
|
-
return this._map[toLowerCase(name)];
|
|
1649
|
-
};
|
|
1650
|
-
if (XMLHttpRequest2 != null && XMLHttpRequest2.HEADERS_RECEIVED == null) {
|
|
1651
|
-
XMLHttpRequest2.HEADERS_RECEIVED = 2;
|
|
1652
|
-
}
|
|
1653
|
-
function XHRTransport() {
|
|
1654
|
-
}
|
|
1655
|
-
XHRTransport.prototype.open = function(xhr, onStartCallback, onProgressCallback, onFinishCallback, url, withCredentials, headers) {
|
|
1656
|
-
xhr.open("GET", url);
|
|
1657
|
-
var offset = 0;
|
|
1658
|
-
xhr.onprogress = function() {
|
|
1659
|
-
var responseText = xhr.responseText;
|
|
1660
|
-
var chunk = responseText.slice(offset);
|
|
1661
|
-
offset += chunk.length;
|
|
1662
|
-
onProgressCallback(chunk);
|
|
1663
|
-
};
|
|
1664
|
-
xhr.onerror = function(event) {
|
|
1665
|
-
event.preventDefault();
|
|
1666
|
-
onFinishCallback(new Error("NetworkError"));
|
|
1667
|
-
};
|
|
1668
|
-
xhr.onload = function() {
|
|
1669
|
-
onFinishCallback(null);
|
|
1670
|
-
};
|
|
1671
|
-
xhr.onabort = function() {
|
|
1672
|
-
onFinishCallback(null);
|
|
1673
|
-
};
|
|
1674
|
-
xhr.onreadystatechange = function() {
|
|
1675
|
-
if (xhr.readyState === XMLHttpRequest2.HEADERS_RECEIVED) {
|
|
1676
|
-
var status = xhr.status;
|
|
1677
|
-
var statusText = xhr.statusText;
|
|
1678
|
-
var contentType = xhr.getResponseHeader("Content-Type");
|
|
1679
|
-
var headers2 = xhr.getAllResponseHeaders();
|
|
1680
|
-
onStartCallback(status, statusText, contentType, new HeadersPolyfill(headers2));
|
|
1681
|
-
}
|
|
1682
|
-
};
|
|
1683
|
-
xhr.withCredentials = withCredentials;
|
|
1684
|
-
for (var name in headers) {
|
|
1685
|
-
if (Object.prototype.hasOwnProperty.call(headers, name)) {
|
|
1686
|
-
xhr.setRequestHeader(name, headers[name]);
|
|
1687
|
-
}
|
|
1688
|
-
}
|
|
1689
|
-
xhr.send();
|
|
1690
|
-
return xhr;
|
|
1691
|
-
};
|
|
1692
|
-
function HeadersWrapper(headers) {
|
|
1693
|
-
this._headers = headers;
|
|
1694
|
-
}
|
|
1695
|
-
HeadersWrapper.prototype.get = function(name) {
|
|
1696
|
-
return this._headers.get(name);
|
|
1697
|
-
};
|
|
1698
|
-
function FetchTransport() {
|
|
1699
|
-
}
|
|
1700
|
-
FetchTransport.prototype.open = function(xhr, onStartCallback, onProgressCallback, onFinishCallback, url, withCredentials, headers) {
|
|
1701
|
-
var reader = null;
|
|
1702
|
-
var controller = new AbortController2();
|
|
1703
|
-
var signal = controller.signal;
|
|
1704
|
-
var textDecoder = new TextDecoder();
|
|
1705
|
-
fetch2(url, {
|
|
1706
|
-
headers,
|
|
1707
|
-
credentials: withCredentials ? "include" : "same-origin",
|
|
1708
|
-
signal,
|
|
1709
|
-
cache: "no-store"
|
|
1710
|
-
}).then(function(response) {
|
|
1711
|
-
reader = response.body.getReader();
|
|
1712
|
-
onStartCallback(response.status, response.statusText, response.headers.get("Content-Type"), new HeadersWrapper(response.headers));
|
|
1713
|
-
return new Promise2(function(resolve, reject) {
|
|
1714
|
-
var readNextChunk = function() {
|
|
1715
|
-
reader.read().then(function(result) {
|
|
1716
|
-
if (result.done) {
|
|
1717
|
-
resolve(void 0);
|
|
1718
|
-
} else {
|
|
1719
|
-
var chunk = textDecoder.decode(result.value, { stream: true });
|
|
1720
|
-
onProgressCallback(chunk);
|
|
1721
|
-
readNextChunk();
|
|
1722
|
-
}
|
|
1723
|
-
})["catch"](function(error) {
|
|
1724
|
-
reject(error);
|
|
1725
|
-
});
|
|
1726
|
-
};
|
|
1727
|
-
readNextChunk();
|
|
1728
|
-
});
|
|
1729
|
-
})["catch"](function(error) {
|
|
1730
|
-
if (error.name === "AbortError") {
|
|
1731
|
-
return void 0;
|
|
1732
|
-
} else {
|
|
1733
|
-
return error;
|
|
1734
|
-
}
|
|
1735
|
-
}).then(function(error) {
|
|
1736
|
-
onFinishCallback(error);
|
|
1737
|
-
});
|
|
1738
|
-
return {
|
|
1739
|
-
abort: function() {
|
|
1740
|
-
if (reader != null) {
|
|
1741
|
-
reader.cancel();
|
|
1742
|
-
}
|
|
1743
|
-
controller.abort();
|
|
1744
|
-
}
|
|
1745
|
-
};
|
|
1746
|
-
};
|
|
1747
|
-
function EventTarget() {
|
|
1748
|
-
this._listeners = /* @__PURE__ */ Object.create(null);
|
|
1749
|
-
}
|
|
1750
|
-
function throwError(e) {
|
|
1751
|
-
setTimeout2(function() {
|
|
1752
|
-
throw e;
|
|
1753
|
-
}, 0);
|
|
1754
|
-
}
|
|
1755
|
-
EventTarget.prototype.dispatchEvent = function(event) {
|
|
1756
|
-
event.target = this;
|
|
1757
|
-
var typeListeners = this._listeners[event.type];
|
|
1758
|
-
if (typeListeners != void 0) {
|
|
1759
|
-
var length = typeListeners.length;
|
|
1760
|
-
for (var i = 0; i < length; i += 1) {
|
|
1761
|
-
var listener = typeListeners[i];
|
|
1762
|
-
try {
|
|
1763
|
-
if (typeof listener.handleEvent === "function") {
|
|
1764
|
-
listener.handleEvent(event);
|
|
1765
|
-
} else {
|
|
1766
|
-
listener.call(this, event);
|
|
1767
|
-
}
|
|
1768
|
-
} catch (e) {
|
|
1769
|
-
throwError(e);
|
|
1770
|
-
}
|
|
1771
|
-
}
|
|
1772
|
-
}
|
|
1773
|
-
};
|
|
1774
|
-
EventTarget.prototype.addEventListener = function(type, listener) {
|
|
1775
|
-
type = String(type);
|
|
1776
|
-
var listeners = this._listeners;
|
|
1777
|
-
var typeListeners = listeners[type];
|
|
1778
|
-
if (typeListeners == void 0) {
|
|
1779
|
-
typeListeners = [];
|
|
1780
|
-
listeners[type] = typeListeners;
|
|
1781
|
-
}
|
|
1782
|
-
var found = false;
|
|
1783
|
-
for (var i = 0; i < typeListeners.length; i += 1) {
|
|
1784
|
-
if (typeListeners[i] === listener) {
|
|
1785
|
-
found = true;
|
|
1786
|
-
}
|
|
1787
|
-
}
|
|
1788
|
-
if (!found) {
|
|
1789
|
-
typeListeners.push(listener);
|
|
1790
|
-
}
|
|
1791
|
-
};
|
|
1792
|
-
EventTarget.prototype.removeEventListener = function(type, listener) {
|
|
1793
|
-
type = String(type);
|
|
1794
|
-
var listeners = this._listeners;
|
|
1795
|
-
var typeListeners = listeners[type];
|
|
1796
|
-
if (typeListeners != void 0) {
|
|
1797
|
-
var filtered = [];
|
|
1798
|
-
for (var i = 0; i < typeListeners.length; i += 1) {
|
|
1799
|
-
if (typeListeners[i] !== listener) {
|
|
1800
|
-
filtered.push(typeListeners[i]);
|
|
1801
|
-
}
|
|
1802
|
-
}
|
|
1803
|
-
if (filtered.length === 0) {
|
|
1804
|
-
delete listeners[type];
|
|
1805
|
-
} else {
|
|
1806
|
-
listeners[type] = filtered;
|
|
1807
|
-
}
|
|
1808
|
-
}
|
|
1809
|
-
};
|
|
1810
|
-
function Event(type) {
|
|
1811
|
-
this.type = type;
|
|
1812
|
-
this.target = void 0;
|
|
1813
|
-
}
|
|
1814
|
-
function MessageEvent(type, options) {
|
|
1815
|
-
Event.call(this, type);
|
|
1816
|
-
this.data = options.data;
|
|
1817
|
-
this.lastEventId = options.lastEventId;
|
|
1818
|
-
}
|
|
1819
|
-
MessageEvent.prototype = Object.create(Event.prototype);
|
|
1820
|
-
function ConnectionEvent(type, options) {
|
|
1821
|
-
Event.call(this, type);
|
|
1822
|
-
this.status = options.status;
|
|
1823
|
-
this.statusText = options.statusText;
|
|
1824
|
-
this.headers = options.headers;
|
|
1825
|
-
}
|
|
1826
|
-
ConnectionEvent.prototype = Object.create(Event.prototype);
|
|
1827
|
-
function ErrorEvent(type, options) {
|
|
1828
|
-
Event.call(this, type);
|
|
1829
|
-
this.error = options.error;
|
|
1830
|
-
}
|
|
1831
|
-
ErrorEvent.prototype = Object.create(Event.prototype);
|
|
1832
|
-
var WAITING = -1;
|
|
1833
|
-
var CONNECTING = 0;
|
|
1834
|
-
var OPEN = 1;
|
|
1835
|
-
var CLOSED = 2;
|
|
1836
|
-
var AFTER_CR = -1;
|
|
1837
|
-
var FIELD_START = 0;
|
|
1838
|
-
var FIELD = 1;
|
|
1839
|
-
var VALUE_START = 2;
|
|
1840
|
-
var VALUE = 3;
|
|
1841
|
-
var contentTypeRegExp = /^text\/event\-stream(;.*)?$/i;
|
|
1842
|
-
var MINIMUM_DURATION = 1e3;
|
|
1843
|
-
var MAXIMUM_DURATION = 18e6;
|
|
1844
|
-
var parseDuration = function(value, def) {
|
|
1845
|
-
var n = value == null ? def : parseInt(value, 10);
|
|
1846
|
-
if (n !== n) {
|
|
1847
|
-
n = def;
|
|
1848
|
-
}
|
|
1849
|
-
return clampDuration(n);
|
|
1850
|
-
};
|
|
1851
|
-
var clampDuration = function(n) {
|
|
1852
|
-
return Math.min(Math.max(n, MINIMUM_DURATION), MAXIMUM_DURATION);
|
|
1853
|
-
};
|
|
1854
|
-
var fire = function(that, f, event) {
|
|
1855
|
-
try {
|
|
1856
|
-
if (typeof f === "function") {
|
|
1857
|
-
f.call(that, event);
|
|
1858
|
-
}
|
|
1859
|
-
} catch (e) {
|
|
1860
|
-
throwError(e);
|
|
1861
|
-
}
|
|
1862
|
-
};
|
|
1863
|
-
function EventSourcePolyfill(url, options) {
|
|
1864
|
-
EventTarget.call(this);
|
|
1865
|
-
options = options || {};
|
|
1866
|
-
this.onopen = void 0;
|
|
1867
|
-
this.onmessage = void 0;
|
|
1868
|
-
this.onerror = void 0;
|
|
1869
|
-
this.url = void 0;
|
|
1870
|
-
this.readyState = void 0;
|
|
1871
|
-
this.withCredentials = void 0;
|
|
1872
|
-
this.headers = void 0;
|
|
1873
|
-
this._close = void 0;
|
|
1874
|
-
start(this, url, options);
|
|
1875
|
-
}
|
|
1876
|
-
function getBestXHRTransport() {
|
|
1877
|
-
return XMLHttpRequest2 != void 0 && "withCredentials" in XMLHttpRequest2.prototype || XDomainRequest2 == void 0 ? new XMLHttpRequest2() : new XDomainRequest2();
|
|
1878
|
-
}
|
|
1879
|
-
var isFetchSupported = fetch2 != void 0 && Response != void 0 && "body" in Response.prototype;
|
|
1880
|
-
function start(es, url, options) {
|
|
1881
|
-
url = String(url);
|
|
1882
|
-
var withCredentials = Boolean(options.withCredentials);
|
|
1883
|
-
var lastEventIdQueryParameterName = options.lastEventIdQueryParameterName || "lastEventId";
|
|
1884
|
-
var initialRetry = clampDuration(1e3);
|
|
1885
|
-
var heartbeatTimeout = parseDuration(options.heartbeatTimeout, 45e3);
|
|
1886
|
-
var lastEventId = "";
|
|
1887
|
-
var retry = initialRetry;
|
|
1888
|
-
var wasActivity = false;
|
|
1889
|
-
var textLength = 0;
|
|
1890
|
-
var headers = options.headers || {};
|
|
1891
|
-
var TransportOption = options.Transport;
|
|
1892
|
-
var xhr = isFetchSupported && TransportOption == void 0 ? void 0 : new XHRWrapper(TransportOption != void 0 ? new TransportOption() : getBestXHRTransport());
|
|
1893
|
-
var transport = TransportOption != null && typeof TransportOption !== "string" ? new TransportOption() : xhr == void 0 ? new FetchTransport() : new XHRTransport();
|
|
1894
|
-
var abortController = void 0;
|
|
1895
|
-
var timeout = 0;
|
|
1896
|
-
var currentState = WAITING;
|
|
1897
|
-
var dataBuffer = "";
|
|
1898
|
-
var lastEventIdBuffer = "";
|
|
1899
|
-
var eventTypeBuffer = "";
|
|
1900
|
-
var textBuffer = "";
|
|
1901
|
-
var state = FIELD_START;
|
|
1902
|
-
var fieldStart = 0;
|
|
1903
|
-
var valueStart = 0;
|
|
1904
|
-
var onStart = function(status, statusText, contentType, headers2) {
|
|
1905
|
-
if (currentState === CONNECTING) {
|
|
1906
|
-
if (status === 200 && contentType != void 0 && contentTypeRegExp.test(contentType)) {
|
|
1907
|
-
currentState = OPEN;
|
|
1908
|
-
wasActivity = Date.now();
|
|
1909
|
-
retry = initialRetry;
|
|
1910
|
-
es.readyState = OPEN;
|
|
1911
|
-
var event = new ConnectionEvent("open", {
|
|
1912
|
-
status,
|
|
1913
|
-
statusText,
|
|
1914
|
-
headers: headers2
|
|
1915
|
-
});
|
|
1916
|
-
es.dispatchEvent(event);
|
|
1917
|
-
fire(es, es.onopen, event);
|
|
1918
|
-
} else {
|
|
1919
|
-
var message = "";
|
|
1920
|
-
if (status !== 200) {
|
|
1921
|
-
if (statusText) {
|
|
1922
|
-
statusText = statusText.replace(/\s+/g, " ");
|
|
1923
|
-
}
|
|
1924
|
-
message = "EventSource's response has a status " + status + " " + statusText + " that is not 200. Aborting the connection.";
|
|
1925
|
-
} else {
|
|
1926
|
-
message = "EventSource's response has a Content-Type specifying an unsupported type: " + (contentType == void 0 ? "-" : contentType.replace(/\s+/g, " ")) + ". Aborting the connection.";
|
|
1927
|
-
}
|
|
1928
|
-
close();
|
|
1929
|
-
var event = new ConnectionEvent("error", {
|
|
1930
|
-
status,
|
|
1931
|
-
statusText,
|
|
1932
|
-
headers: headers2
|
|
1933
|
-
});
|
|
1934
|
-
es.dispatchEvent(event);
|
|
1935
|
-
fire(es, es.onerror, event);
|
|
1936
|
-
console.error(message);
|
|
1937
|
-
}
|
|
1938
|
-
}
|
|
1939
|
-
};
|
|
1940
|
-
var onProgress = function(textChunk) {
|
|
1941
|
-
if (currentState === OPEN) {
|
|
1942
|
-
var n = -1;
|
|
1943
|
-
for (var i = 0; i < textChunk.length; i += 1) {
|
|
1944
|
-
var c = textChunk.charCodeAt(i);
|
|
1945
|
-
if (c === "\n".charCodeAt(0) || c === "\r".charCodeAt(0)) {
|
|
1946
|
-
n = i;
|
|
1947
|
-
}
|
|
1948
|
-
}
|
|
1949
|
-
var chunk = (n !== -1 ? textBuffer : "") + textChunk.slice(0, n + 1);
|
|
1950
|
-
textBuffer = (n === -1 ? textBuffer : "") + textChunk.slice(n + 1);
|
|
1951
|
-
if (textChunk !== "") {
|
|
1952
|
-
wasActivity = Date.now();
|
|
1953
|
-
textLength += textChunk.length;
|
|
1954
|
-
}
|
|
1955
|
-
for (var position = 0; position < chunk.length; position += 1) {
|
|
1956
|
-
var c = chunk.charCodeAt(position);
|
|
1957
|
-
if (state === AFTER_CR && c === "\n".charCodeAt(0)) {
|
|
1958
|
-
state = FIELD_START;
|
|
1959
|
-
} else {
|
|
1960
|
-
if (state === AFTER_CR) {
|
|
1961
|
-
state = FIELD_START;
|
|
1962
|
-
}
|
|
1963
|
-
if (c === "\r".charCodeAt(0) || c === "\n".charCodeAt(0)) {
|
|
1964
|
-
if (state !== FIELD_START) {
|
|
1965
|
-
if (state === FIELD) {
|
|
1966
|
-
valueStart = position + 1;
|
|
1967
|
-
}
|
|
1968
|
-
var field = chunk.slice(fieldStart, valueStart - 1);
|
|
1969
|
-
var value = chunk.slice(valueStart + (valueStart < position && chunk.charCodeAt(valueStart) === " ".charCodeAt(0) ? 1 : 0), position);
|
|
1970
|
-
if (field === "data") {
|
|
1971
|
-
dataBuffer += "\n";
|
|
1972
|
-
dataBuffer += value;
|
|
1973
|
-
} else if (field === "id") {
|
|
1974
|
-
lastEventIdBuffer = value;
|
|
1975
|
-
} else if (field === "event") {
|
|
1976
|
-
eventTypeBuffer = value;
|
|
1977
|
-
} else if (field === "retry") {
|
|
1978
|
-
initialRetry = parseDuration(value, initialRetry);
|
|
1979
|
-
retry = initialRetry;
|
|
1980
|
-
} else if (field === "heartbeatTimeout") {
|
|
1981
|
-
heartbeatTimeout = parseDuration(value, heartbeatTimeout);
|
|
1982
|
-
if (timeout !== 0) {
|
|
1983
|
-
clearTimeout2(timeout);
|
|
1984
|
-
timeout = setTimeout2(function() {
|
|
1985
|
-
onTimeout();
|
|
1986
|
-
}, heartbeatTimeout);
|
|
1987
|
-
}
|
|
1988
|
-
}
|
|
1989
|
-
}
|
|
1990
|
-
if (state === FIELD_START) {
|
|
1991
|
-
if (dataBuffer !== "") {
|
|
1992
|
-
lastEventId = lastEventIdBuffer;
|
|
1993
|
-
if (eventTypeBuffer === "") {
|
|
1994
|
-
eventTypeBuffer = "message";
|
|
1995
|
-
}
|
|
1996
|
-
var event = new MessageEvent(eventTypeBuffer, {
|
|
1997
|
-
data: dataBuffer.slice(1),
|
|
1998
|
-
lastEventId: lastEventIdBuffer
|
|
1999
|
-
});
|
|
2000
|
-
es.dispatchEvent(event);
|
|
2001
|
-
if (eventTypeBuffer === "open") {
|
|
2002
|
-
fire(es, es.onopen, event);
|
|
2003
|
-
} else if (eventTypeBuffer === "message") {
|
|
2004
|
-
fire(es, es.onmessage, event);
|
|
2005
|
-
} else if (eventTypeBuffer === "error") {
|
|
2006
|
-
fire(es, es.onerror, event);
|
|
2007
|
-
}
|
|
2008
|
-
if (currentState === CLOSED) {
|
|
2009
|
-
return;
|
|
2010
|
-
}
|
|
2011
|
-
}
|
|
2012
|
-
dataBuffer = "";
|
|
2013
|
-
eventTypeBuffer = "";
|
|
2014
|
-
}
|
|
2015
|
-
state = c === "\r".charCodeAt(0) ? AFTER_CR : FIELD_START;
|
|
2016
|
-
} else {
|
|
2017
|
-
if (state === FIELD_START) {
|
|
2018
|
-
fieldStart = position;
|
|
2019
|
-
state = FIELD;
|
|
2020
|
-
}
|
|
2021
|
-
if (state === FIELD) {
|
|
2022
|
-
if (c === ":".charCodeAt(0)) {
|
|
2023
|
-
valueStart = position + 1;
|
|
2024
|
-
state = VALUE_START;
|
|
2025
|
-
}
|
|
2026
|
-
} else if (state === VALUE_START) {
|
|
2027
|
-
state = VALUE;
|
|
2028
|
-
}
|
|
2029
|
-
}
|
|
2030
|
-
}
|
|
2031
|
-
}
|
|
2032
|
-
}
|
|
2033
|
-
};
|
|
2034
|
-
var onFinish = function(error) {
|
|
2035
|
-
if (currentState === OPEN || currentState === CONNECTING) {
|
|
2036
|
-
currentState = WAITING;
|
|
2037
|
-
if (timeout !== 0) {
|
|
2038
|
-
clearTimeout2(timeout);
|
|
2039
|
-
timeout = 0;
|
|
2040
|
-
}
|
|
2041
|
-
timeout = setTimeout2(function() {
|
|
2042
|
-
onTimeout();
|
|
2043
|
-
}, retry);
|
|
2044
|
-
retry = clampDuration(Math.min(initialRetry * 16, retry * 2));
|
|
2045
|
-
es.readyState = CONNECTING;
|
|
2046
|
-
var event = new ErrorEvent("error", { error });
|
|
2047
|
-
es.dispatchEvent(event);
|
|
2048
|
-
fire(es, es.onerror, event);
|
|
2049
|
-
if (error != void 0) {
|
|
2050
|
-
console.error(error);
|
|
2051
|
-
}
|
|
2052
|
-
}
|
|
2053
|
-
};
|
|
2054
|
-
var close = function() {
|
|
2055
|
-
currentState = CLOSED;
|
|
2056
|
-
if (abortController != void 0) {
|
|
2057
|
-
abortController.abort();
|
|
2058
|
-
abortController = void 0;
|
|
2059
|
-
}
|
|
2060
|
-
if (timeout !== 0) {
|
|
2061
|
-
clearTimeout2(timeout);
|
|
2062
|
-
timeout = 0;
|
|
2063
|
-
}
|
|
2064
|
-
es.readyState = CLOSED;
|
|
2065
|
-
};
|
|
2066
|
-
var onTimeout = function() {
|
|
2067
|
-
timeout = 0;
|
|
2068
|
-
if (currentState !== WAITING) {
|
|
2069
|
-
if (!wasActivity && abortController != void 0) {
|
|
2070
|
-
onFinish(new Error("No activity within " + heartbeatTimeout + " milliseconds. " + (currentState === CONNECTING ? "No response received." : textLength + " chars received.") + " Reconnecting."));
|
|
2071
|
-
if (abortController != void 0) {
|
|
2072
|
-
abortController.abort();
|
|
2073
|
-
abortController = void 0;
|
|
2074
|
-
}
|
|
2075
|
-
} else {
|
|
2076
|
-
var nextHeartbeat = Math.max((wasActivity || Date.now()) + heartbeatTimeout - Date.now(), 1);
|
|
2077
|
-
wasActivity = false;
|
|
2078
|
-
timeout = setTimeout2(function() {
|
|
2079
|
-
onTimeout();
|
|
2080
|
-
}, nextHeartbeat);
|
|
2081
|
-
}
|
|
2082
|
-
return;
|
|
2083
|
-
}
|
|
2084
|
-
wasActivity = false;
|
|
2085
|
-
textLength = 0;
|
|
2086
|
-
timeout = setTimeout2(function() {
|
|
2087
|
-
onTimeout();
|
|
2088
|
-
}, heartbeatTimeout);
|
|
2089
|
-
currentState = CONNECTING;
|
|
2090
|
-
dataBuffer = "";
|
|
2091
|
-
eventTypeBuffer = "";
|
|
2092
|
-
lastEventIdBuffer = lastEventId;
|
|
2093
|
-
textBuffer = "";
|
|
2094
|
-
fieldStart = 0;
|
|
2095
|
-
valueStart = 0;
|
|
2096
|
-
state = FIELD_START;
|
|
2097
|
-
var requestURL = url;
|
|
2098
|
-
if (url.slice(0, 5) !== "data:" && url.slice(0, 5) !== "blob:") {
|
|
2099
|
-
if (lastEventId !== "") {
|
|
2100
|
-
var i = url.indexOf("?");
|
|
2101
|
-
requestURL = i === -1 ? url : url.slice(0, i + 1) + url.slice(i + 1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g, function(p, paramName) {
|
|
2102
|
-
return paramName === lastEventIdQueryParameterName ? "" : p;
|
|
2103
|
-
});
|
|
2104
|
-
requestURL += (url.indexOf("?") === -1 ? "?" : "&") + lastEventIdQueryParameterName + "=" + encodeURIComponent(lastEventId);
|
|
2105
|
-
}
|
|
2106
|
-
}
|
|
2107
|
-
var withCredentials2 = es.withCredentials;
|
|
2108
|
-
var requestHeaders = {};
|
|
2109
|
-
requestHeaders["Accept"] = "text/event-stream";
|
|
2110
|
-
var headers2 = es.headers;
|
|
2111
|
-
if (headers2 != void 0) {
|
|
2112
|
-
for (var name in headers2) {
|
|
2113
|
-
if (Object.prototype.hasOwnProperty.call(headers2, name)) {
|
|
2114
|
-
requestHeaders[name] = headers2[name];
|
|
2115
|
-
}
|
|
2116
|
-
}
|
|
2117
|
-
}
|
|
2118
|
-
try {
|
|
2119
|
-
abortController = transport.open(xhr, onStart, onProgress, onFinish, requestURL, withCredentials2, requestHeaders);
|
|
2120
|
-
} catch (error) {
|
|
2121
|
-
close();
|
|
2122
|
-
throw error;
|
|
2123
|
-
}
|
|
2124
|
-
};
|
|
2125
|
-
es.url = url;
|
|
2126
|
-
es.readyState = CONNECTING;
|
|
2127
|
-
es.withCredentials = withCredentials;
|
|
2128
|
-
es.headers = headers;
|
|
2129
|
-
es._close = close;
|
|
2130
|
-
onTimeout();
|
|
2131
|
-
}
|
|
2132
|
-
EventSourcePolyfill.prototype = Object.create(EventTarget.prototype);
|
|
2133
|
-
EventSourcePolyfill.prototype.CONNECTING = CONNECTING;
|
|
2134
|
-
EventSourcePolyfill.prototype.OPEN = OPEN;
|
|
2135
|
-
EventSourcePolyfill.prototype.CLOSED = CLOSED;
|
|
2136
|
-
EventSourcePolyfill.prototype.close = function() {
|
|
2137
|
-
this._close();
|
|
2138
|
-
};
|
|
2139
|
-
EventSourcePolyfill.CONNECTING = CONNECTING;
|
|
2140
|
-
EventSourcePolyfill.OPEN = OPEN;
|
|
2141
|
-
EventSourcePolyfill.CLOSED = CLOSED;
|
|
2142
|
-
EventSourcePolyfill.prototype.withCredentials = void 0;
|
|
2143
|
-
var R = NativeEventSource;
|
|
2144
|
-
if (XMLHttpRequest2 != void 0 && (NativeEventSource == void 0 || !("withCredentials" in NativeEventSource.prototype))) {
|
|
2145
|
-
R = EventSourcePolyfill;
|
|
2146
|
-
}
|
|
2147
|
-
(function(factory) {
|
|
2148
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
2149
|
-
var v = factory(exports);
|
|
2150
|
-
if (v !== void 0)
|
|
2151
|
-
module.exports = v;
|
|
2152
|
-
} else if (typeof define === "function" && define.amd) {
|
|
2153
|
-
define(["exports"], factory);
|
|
2154
|
-
} else {
|
|
2155
|
-
factory(global2);
|
|
2156
|
-
}
|
|
2157
|
-
})(function(exports2) {
|
|
2158
|
-
exports2.EventSourcePolyfill = EventSourcePolyfill;
|
|
2159
|
-
exports2.NativeEventSource = NativeEventSource;
|
|
2160
|
-
exports2.EventSource = R;
|
|
2161
|
-
});
|
|
2162
|
-
})(typeof globalThis === "undefined" ? typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : exports : globalThis);
|
|
2163
|
-
}
|
|
2164
|
-
});
|
|
2165
|
-
|
|
2166
|
-
// node_modules/@sanity/eventsource/browser.js
|
|
2167
|
-
var require_browser = __commonJS({
|
|
2168
|
-
"node_modules/@sanity/eventsource/browser.js"(exports, module) {
|
|
2169
|
-
var evs = require_eventsource();
|
|
2170
|
-
module.exports = evs.EventSourcePolyfill;
|
|
2171
|
-
}
|
|
2172
|
-
});
|
|
2173
|
-
|
|
2174
|
-
// src/util/pick.js
|
|
2175
|
-
var require_pick = __commonJS({
|
|
2176
|
-
"src/util/pick.js"(exports, module) {
|
|
2177
|
-
module.exports = (obj, props) => props.reduce((selection, prop) => {
|
|
2178
|
-
if (typeof obj[prop] === "undefined") {
|
|
2179
|
-
return selection;
|
|
325
|
+
// src/util/pick.js
|
|
326
|
+
var require_pick = __commonJS({
|
|
327
|
+
"src/util/pick.js"(exports, module) {
|
|
328
|
+
module.exports = (obj, props) => props.reduce((selection, prop) => {
|
|
329
|
+
if (typeof obj[prop] === "undefined") {
|
|
330
|
+
return selection;
|
|
2180
331
|
}
|
|
2181
332
|
selection[prop] = obj[prop];
|
|
2182
333
|
return selection;
|
|
@@ -2197,9 +348,9 @@ var require_defaults = __commonJS({
|
|
|
2197
348
|
// src/data/listen.js
|
|
2198
349
|
var require_listen = __commonJS({
|
|
2199
350
|
"src/data/listen.js"(exports, module) {
|
|
2200
|
-
var assign =
|
|
2201
|
-
var { Observable } =
|
|
2202
|
-
var polyfilledEventSource =
|
|
351
|
+
var assign = __require("object-assign");
|
|
352
|
+
var { Observable } = require_observable();
|
|
353
|
+
var polyfilledEventSource = __require("@sanity/eventsource");
|
|
2203
354
|
var pick = require_pick();
|
|
2204
355
|
var defaults = require_defaults();
|
|
2205
356
|
var encodeQueryString = require_encodeQueryString();
|
|
@@ -2326,8 +477,8 @@ var require_listen = __commonJS({
|
|
|
2326
477
|
// src/data/dataMethods.js
|
|
2327
478
|
var require_dataMethods = __commonJS({
|
|
2328
479
|
"src/data/dataMethods.js"(exports, module) {
|
|
2329
|
-
var assign =
|
|
2330
|
-
var { map, filter } =
|
|
480
|
+
var assign = __require("object-assign");
|
|
481
|
+
var { map, filter } = require_observable();
|
|
2331
482
|
var validators = require_validators();
|
|
2332
483
|
var getSelection = require_getSelection();
|
|
2333
484
|
var encodeQueryString = require_encodeQueryString();
|
|
@@ -2372,15 +523,21 @@ var require_dataMethods = __commonJS({
|
|
|
2372
523
|
},
|
|
2373
524
|
getDocument(id, opts = {}) {
|
|
2374
525
|
const options = { uri: this.getDataUrl("doc", id), json: true, tag: opts.tag };
|
|
2375
|
-
const observable = this._requestObservable(options).pipe(
|
|
526
|
+
const observable = this._requestObservable(options).pipe(
|
|
527
|
+
filter(isResponse),
|
|
528
|
+
map((event) => event.body.documents && event.body.documents[0])
|
|
529
|
+
);
|
|
2376
530
|
return this.isPromiseAPI() ? toPromise(observable) : observable;
|
|
2377
531
|
},
|
|
2378
532
|
getDocuments(ids, opts = {}) {
|
|
2379
533
|
const options = { uri: this.getDataUrl("doc", ids.join(",")), json: true, tag: opts.tag };
|
|
2380
|
-
const observable = this._requestObservable(options).pipe(
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
534
|
+
const observable = this._requestObservable(options).pipe(
|
|
535
|
+
filter(isResponse),
|
|
536
|
+
map((event) => {
|
|
537
|
+
const indexed = indexBy(event.body.documents || [], (doc) => doc._id);
|
|
538
|
+
return ids.map((id) => indexed[id] || null);
|
|
539
|
+
})
|
|
540
|
+
);
|
|
2384
541
|
return this.isPromiseAPI() ? toPromise(observable) : observable;
|
|
2385
542
|
},
|
|
2386
543
|
create(doc, options) {
|
|
@@ -2412,1540 +569,256 @@ var require_dataMethods = __commonJS({
|
|
|
2412
569
|
dataRequest(endpoint, body, options = {}) {
|
|
2413
570
|
const request = this._dataRequest(endpoint, body, options);
|
|
2414
571
|
return this.isPromiseAPI() ? toPromise(request) : request;
|
|
2415
|
-
},
|
|
2416
|
-
_dataRequest(endpoint, body, options = {}) {
|
|
2417
|
-
const isMutation = endpoint === "mutate";
|
|
2418
|
-
const isQuery = endpoint === "query";
|
|
2419
|
-
const strQuery = !isMutation && encodeQueryString(body);
|
|
2420
|
-
const useGet = !isMutation && strQuery.length < getQuerySizeLimit;
|
|
2421
|
-
const stringQuery = useGet ? strQuery : "";
|
|
2422
|
-
const returnFirst = options.returnFirst;
|
|
2423
|
-
const { timeout, token, tag, headers } = options;
|
|
2424
|
-
const uri = this.getDataUrl(endpoint, stringQuery);
|
|
2425
|
-
const reqOptions = {
|
|
2426
|
-
method: useGet ? "GET" : "POST",
|
|
2427
|
-
uri,
|
|
2428
|
-
json: true,
|
|
2429
|
-
body: useGet ? void 0 : body,
|
|
2430
|
-
query: isMutation && getMutationQuery(options),
|
|
2431
|
-
timeout,
|
|
2432
|
-
headers,
|
|
2433
|
-
token,
|
|
2434
|
-
tag,
|
|
2435
|
-
canUseCdn: isQuery
|
|
2436
|
-
};
|
|
2437
|
-
return this._requestObservable(reqOptions).pipe(filter(isResponse), map(getBody), map((res) => {
|
|
2438
|
-
if (!isMutation) {
|
|
2439
|
-
return res;
|
|
2440
|
-
}
|
|
2441
|
-
const results = res.results || [];
|
|
2442
|
-
if (options.returnDocuments) {
|
|
2443
|
-
return returnFirst ? results[0] && results[0].document : results.map((mut) => mut.document);
|
|
2444
|
-
}
|
|
2445
|
-
const key = returnFirst ? "documentId" : "documentIds";
|
|
2446
|
-
const ids = returnFirst ? results[0] && results[0].id : results.map((mut) => mut.id);
|
|
2447
|
-
return {
|
|
2448
|
-
transactionId: res.transactionId,
|
|
2449
|
-
results,
|
|
2450
|
-
[key]: ids
|
|
2451
|
-
};
|
|
2452
|
-
}));
|
|
2453
|
-
},
|
|
2454
|
-
_create(doc, op, options = {}) {
|
|
2455
|
-
const mutation = { [op]: doc };
|
|
2456
|
-
const opts = assign({ returnFirst: true, returnDocuments: true }, options);
|
|
2457
|
-
return this.dataRequest("mutate", { mutations: [mutation] }, opts);
|
|
2458
|
-
}
|
|
2459
|
-
};
|
|
2460
|
-
}
|
|
2461
|
-
});
|
|
2462
|
-
|
|
2463
|
-
// src/datasets/datasetsClient.js
|
|
2464
|
-
var require_datasetsClient = __commonJS({
|
|
2465
|
-
"src/datasets/datasetsClient.js"(exports, module) {
|
|
2466
|
-
var assign = require_object_assign();
|
|
2467
|
-
var validate = require_validators();
|
|
2468
|
-
function DatasetsClient(client) {
|
|
2469
|
-
this.request = client.request.bind(client);
|
|
2470
|
-
}
|
|
2471
|
-
assign(DatasetsClient.prototype, {
|
|
2472
|
-
create(name, options) {
|
|
2473
|
-
return this._modify("PUT", name, options);
|
|
2474
|
-
},
|
|
2475
|
-
edit(name, options) {
|
|
2476
|
-
return this._modify("PATCH", name, options);
|
|
2477
|
-
},
|
|
2478
|
-
delete(name) {
|
|
2479
|
-
return this._modify("DELETE", name);
|
|
2480
|
-
},
|
|
2481
|
-
list() {
|
|
2482
|
-
return this.request({ uri: "/datasets" });
|
|
2483
|
-
},
|
|
2484
|
-
_modify(method, name, body) {
|
|
2485
|
-
validate.dataset(name);
|
|
2486
|
-
return this.request({ method, uri: `/datasets/${name}`, body });
|
|
2487
|
-
}
|
|
2488
|
-
});
|
|
2489
|
-
module.exports = DatasetsClient;
|
|
2490
|
-
}
|
|
2491
|
-
});
|
|
2492
|
-
|
|
2493
|
-
// src/projects/projectsClient.js
|
|
2494
|
-
var require_projectsClient = __commonJS({
|
|
2495
|
-
"src/projects/projectsClient.js"(exports, module) {
|
|
2496
|
-
var assign = require_object_assign();
|
|
2497
|
-
function ProjectsClient(client) {
|
|
2498
|
-
this.client = client;
|
|
2499
|
-
}
|
|
2500
|
-
assign(ProjectsClient.prototype, {
|
|
2501
|
-
list() {
|
|
2502
|
-
return this.client.request({ uri: "/projects" });
|
|
2503
|
-
},
|
|
2504
|
-
getById(id) {
|
|
2505
|
-
return this.client.request({ uri: `/projects/${id}` });
|
|
2506
|
-
}
|
|
2507
|
-
});
|
|
2508
|
-
module.exports = ProjectsClient;
|
|
2509
|
-
}
|
|
2510
|
-
});
|
|
2511
|
-
|
|
2512
|
-
// src/http/queryString.js
|
|
2513
|
-
var require_queryString = __commonJS({
|
|
2514
|
-
"src/http/queryString.js"(exports, module) {
|
|
2515
|
-
module.exports = (params) => {
|
|
2516
|
-
const qs = [];
|
|
2517
|
-
for (const key in params) {
|
|
2518
|
-
if (params.hasOwnProperty(key)) {
|
|
2519
|
-
qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`);
|
|
2520
|
-
}
|
|
2521
|
-
}
|
|
2522
|
-
return qs.length > 0 ? `?${qs.join("&")}` : "";
|
|
2523
|
-
};
|
|
2524
|
-
}
|
|
2525
|
-
});
|
|
2526
|
-
|
|
2527
|
-
// src/assets/assetsClient.js
|
|
2528
|
-
var require_assetsClient = __commonJS({
|
|
2529
|
-
"src/assets/assetsClient.js"(exports, module) {
|
|
2530
|
-
var assign = require_object_assign();
|
|
2531
|
-
var { map, filter } = require_observable2();
|
|
2532
|
-
var queryString = require_queryString();
|
|
2533
|
-
var validators = require_validators();
|
|
2534
|
-
function AssetsClient(client) {
|
|
2535
|
-
this.client = client;
|
|
2536
|
-
}
|
|
2537
|
-
function optionsFromFile(opts, file) {
|
|
2538
|
-
if (typeof window === "undefined" || !(file instanceof window.File)) {
|
|
2539
|
-
return opts;
|
|
2540
|
-
}
|
|
2541
|
-
return assign({
|
|
2542
|
-
filename: opts.preserveFilename === false ? void 0 : file.name,
|
|
2543
|
-
contentType: file.type
|
|
2544
|
-
}, opts);
|
|
2545
|
-
}
|
|
2546
|
-
assign(AssetsClient.prototype, {
|
|
2547
|
-
upload(assetType, body, opts = {}) {
|
|
2548
|
-
validators.validateAssetType(assetType);
|
|
2549
|
-
let meta = opts.extract || void 0;
|
|
2550
|
-
if (meta && !meta.length) {
|
|
2551
|
-
meta = ["none"];
|
|
2552
|
-
}
|
|
2553
|
-
const dataset = validators.hasDataset(this.client.clientConfig);
|
|
2554
|
-
const assetEndpoint = assetType === "image" ? "images" : "files";
|
|
2555
|
-
const options = optionsFromFile(opts, body);
|
|
2556
|
-
const { tag, label, title, description, creditLine, filename, source } = options;
|
|
2557
|
-
const query = {
|
|
2558
|
-
label,
|
|
2559
|
-
title,
|
|
2560
|
-
description,
|
|
2561
|
-
filename,
|
|
2562
|
-
meta,
|
|
2563
|
-
creditLine
|
|
2564
|
-
};
|
|
2565
|
-
if (source) {
|
|
2566
|
-
query.sourceId = source.id;
|
|
2567
|
-
query.sourceName = source.name;
|
|
2568
|
-
query.sourceUrl = source.url;
|
|
2569
|
-
}
|
|
2570
|
-
const observable = this.client._requestObservable({
|
|
2571
|
-
tag,
|
|
2572
|
-
method: "POST",
|
|
2573
|
-
timeout: options.timeout || 0,
|
|
2574
|
-
uri: `/assets/${assetEndpoint}/${dataset}`,
|
|
2575
|
-
headers: options.contentType ? { "Content-Type": options.contentType } : {},
|
|
2576
|
-
query,
|
|
2577
|
-
body
|
|
2578
|
-
});
|
|
2579
|
-
return this.client.isPromiseAPI() ? observable.pipe(filter((event) => event.type === "response"), map((event) => event.body.document)).toPromise() : observable;
|
|
2580
|
-
},
|
|
2581
|
-
delete(type, id) {
|
|
2582
|
-
console.warn("client.assets.delete() is deprecated, please use client.delete(<document-id>)");
|
|
2583
|
-
let docId = id || "";
|
|
2584
|
-
if (!/^(image|file)-/.test(docId)) {
|
|
2585
|
-
docId = `${type}-${docId}`;
|
|
2586
|
-
} else if (type._id) {
|
|
2587
|
-
docId = type._id;
|
|
2588
|
-
}
|
|
2589
|
-
validators.hasDataset(this.client.clientConfig);
|
|
2590
|
-
return this.client.delete(docId);
|
|
2591
|
-
},
|
|
2592
|
-
getImageUrl(ref, query) {
|
|
2593
|
-
const id = ref._ref || ref;
|
|
2594
|
-
if (typeof id !== "string") {
|
|
2595
|
-
throw new Error("getImageUrl() needs either an object with a _ref, or a string with an asset document ID");
|
|
2596
|
-
}
|
|
2597
|
-
if (!/^image-[A-Za-z0-9_]+-\d+x\d+-[a-z]{1,5}$/.test(id)) {
|
|
2598
|
-
throw new Error(`Unsupported asset ID "${id}". URL generation only works for auto-generated IDs.`);
|
|
2599
|
-
}
|
|
2600
|
-
const [, assetId, size, format] = id.split("-");
|
|
2601
|
-
validators.hasDataset(this.client.clientConfig);
|
|
2602
|
-
const { projectId, dataset } = this.client.clientConfig;
|
|
2603
|
-
const qs = query ? queryString(query) : "";
|
|
2604
|
-
return `https://cdn.sanity.io/images/${projectId}/${dataset}/${assetId}-${size}.${format}${qs}`;
|
|
2605
|
-
}
|
|
2606
|
-
});
|
|
2607
|
-
module.exports = AssetsClient;
|
|
2608
|
-
}
|
|
2609
|
-
});
|
|
2610
|
-
|
|
2611
|
-
// src/users/usersClient.js
|
|
2612
|
-
var require_usersClient = __commonJS({
|
|
2613
|
-
"src/users/usersClient.js"(exports, module) {
|
|
2614
|
-
var assign = require_object_assign();
|
|
2615
|
-
function UsersClient(client) {
|
|
2616
|
-
this.client = client;
|
|
2617
|
-
}
|
|
2618
|
-
assign(UsersClient.prototype, {
|
|
2619
|
-
getById(id) {
|
|
2620
|
-
return this.client.request({ uri: `/users/${id}` });
|
|
2621
|
-
}
|
|
2622
|
-
});
|
|
2623
|
-
module.exports = UsersClient;
|
|
2624
|
-
}
|
|
2625
|
-
});
|
|
2626
|
-
|
|
2627
|
-
// src/auth/authClient.js
|
|
2628
|
-
var require_authClient = __commonJS({
|
|
2629
|
-
"src/auth/authClient.js"(exports, module) {
|
|
2630
|
-
var assign = require_object_assign();
|
|
2631
|
-
function AuthClient(client) {
|
|
2632
|
-
this.client = client;
|
|
2633
|
-
}
|
|
2634
|
-
assign(AuthClient.prototype, {
|
|
2635
|
-
getLoginProviders() {
|
|
2636
|
-
return this.client.request({ uri: "/auth/providers" });
|
|
2637
|
-
},
|
|
2638
|
-
logout() {
|
|
2639
|
-
return this.client.request({ uri: "/auth/logout", method: "POST" });
|
|
2640
|
-
}
|
|
2641
|
-
});
|
|
2642
|
-
module.exports = AuthClient;
|
|
2643
|
-
}
|
|
2644
|
-
});
|
|
2645
|
-
|
|
2646
|
-
// node_modules/nano-pubsub/index.js
|
|
2647
|
-
var require_nano_pubsub = __commonJS({
|
|
2648
|
-
"node_modules/nano-pubsub/index.js"(exports, module) {
|
|
2649
|
-
module.exports = function Pubsub() {
|
|
2650
|
-
var subscribers = [];
|
|
2651
|
-
return {
|
|
2652
|
-
subscribe,
|
|
2653
|
-
publish
|
|
2654
|
-
};
|
|
2655
|
-
function subscribe(subscriber) {
|
|
2656
|
-
subscribers.push(subscriber);
|
|
2657
|
-
return function unsubscribe() {
|
|
2658
|
-
var idx = subscribers.indexOf(subscriber);
|
|
2659
|
-
if (idx > -1) {
|
|
2660
|
-
subscribers.splice(idx, 1);
|
|
2661
|
-
}
|
|
2662
|
-
};
|
|
2663
|
-
}
|
|
2664
|
-
function publish() {
|
|
2665
|
-
for (var i = 0; i < subscribers.length; i++) {
|
|
2666
|
-
subscribers[i].apply(null, arguments);
|
|
2667
|
-
}
|
|
2668
|
-
}
|
|
2669
|
-
};
|
|
2670
|
-
}
|
|
2671
|
-
});
|
|
2672
|
-
|
|
2673
|
-
// node_modules/get-it/lib/util/middlewareReducer.js
|
|
2674
|
-
var require_middlewareReducer = __commonJS({
|
|
2675
|
-
"node_modules/get-it/lib/util/middlewareReducer.js"(exports, module) {
|
|
2676
|
-
"use strict";
|
|
2677
|
-
module.exports = function(middleware) {
|
|
2678
|
-
var applyMiddleware = function applyMiddleware2(hook, defaultValue) {
|
|
2679
|
-
var bailEarly = hook === "onError";
|
|
2680
|
-
var value = defaultValue;
|
|
2681
|
-
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
2682
|
-
args[_key - 2] = arguments[_key];
|
|
2683
|
-
}
|
|
2684
|
-
for (var i = 0; i < middleware[hook].length; i++) {
|
|
2685
|
-
var handler = middleware[hook][i];
|
|
2686
|
-
value = handler.apply(void 0, [value].concat(args));
|
|
2687
|
-
if (bailEarly && !value) {
|
|
2688
|
-
break;
|
|
2689
|
-
}
|
|
2690
|
-
}
|
|
2691
|
-
return value;
|
|
2692
|
-
};
|
|
2693
|
-
return applyMiddleware;
|
|
2694
|
-
};
|
|
2695
|
-
}
|
|
2696
|
-
});
|
|
2697
|
-
|
|
2698
|
-
// node_modules/requires-port/index.js
|
|
2699
|
-
var require_requires_port = __commonJS({
|
|
2700
|
-
"node_modules/requires-port/index.js"(exports, module) {
|
|
2701
|
-
"use strict";
|
|
2702
|
-
module.exports = function required(port, protocol) {
|
|
2703
|
-
protocol = protocol.split(":")[0];
|
|
2704
|
-
port = +port;
|
|
2705
|
-
if (!port)
|
|
2706
|
-
return false;
|
|
2707
|
-
switch (protocol) {
|
|
2708
|
-
case "http":
|
|
2709
|
-
case "ws":
|
|
2710
|
-
return port !== 80;
|
|
2711
|
-
case "https":
|
|
2712
|
-
case "wss":
|
|
2713
|
-
return port !== 443;
|
|
2714
|
-
case "ftp":
|
|
2715
|
-
return port !== 21;
|
|
2716
|
-
case "gopher":
|
|
2717
|
-
return port !== 70;
|
|
2718
|
-
case "file":
|
|
2719
|
-
return false;
|
|
2720
|
-
}
|
|
2721
|
-
return port !== 0;
|
|
2722
|
-
};
|
|
2723
|
-
}
|
|
2724
|
-
});
|
|
2725
|
-
|
|
2726
|
-
// node_modules/querystringify/index.js
|
|
2727
|
-
var require_querystringify = __commonJS({
|
|
2728
|
-
"node_modules/querystringify/index.js"(exports) {
|
|
2729
|
-
"use strict";
|
|
2730
|
-
var has = Object.prototype.hasOwnProperty;
|
|
2731
|
-
var undef;
|
|
2732
|
-
function decode(input) {
|
|
2733
|
-
try {
|
|
2734
|
-
return decodeURIComponent(input.replace(/\+/g, " "));
|
|
2735
|
-
} catch (e) {
|
|
2736
|
-
return null;
|
|
2737
|
-
}
|
|
2738
|
-
}
|
|
2739
|
-
function encode(input) {
|
|
2740
|
-
try {
|
|
2741
|
-
return encodeURIComponent(input);
|
|
2742
|
-
} catch (e) {
|
|
2743
|
-
return null;
|
|
2744
|
-
}
|
|
2745
|
-
}
|
|
2746
|
-
function querystring(query) {
|
|
2747
|
-
var parser = /([^=?#&]+)=?([^&]*)/g, result = {}, part;
|
|
2748
|
-
while (part = parser.exec(query)) {
|
|
2749
|
-
var key = decode(part[1]), value = decode(part[2]);
|
|
2750
|
-
if (key === null || value === null || key in result)
|
|
2751
|
-
continue;
|
|
2752
|
-
result[key] = value;
|
|
2753
|
-
}
|
|
2754
|
-
return result;
|
|
2755
|
-
}
|
|
2756
|
-
function querystringify(obj, prefix) {
|
|
2757
|
-
prefix = prefix || "";
|
|
2758
|
-
var pairs = [], value, key;
|
|
2759
|
-
if (typeof prefix !== "string")
|
|
2760
|
-
prefix = "?";
|
|
2761
|
-
for (key in obj) {
|
|
2762
|
-
if (has.call(obj, key)) {
|
|
2763
|
-
value = obj[key];
|
|
2764
|
-
if (!value && (value === null || value === undef || isNaN(value))) {
|
|
2765
|
-
value = "";
|
|
2766
|
-
}
|
|
2767
|
-
key = encode(key);
|
|
2768
|
-
value = encode(value);
|
|
2769
|
-
if (key === null || value === null)
|
|
2770
|
-
continue;
|
|
2771
|
-
pairs.push(key + "=" + value);
|
|
2772
|
-
}
|
|
2773
|
-
}
|
|
2774
|
-
return pairs.length ? prefix + pairs.join("&") : "";
|
|
2775
|
-
}
|
|
2776
|
-
exports.stringify = querystringify;
|
|
2777
|
-
exports.parse = querystring;
|
|
2778
|
-
}
|
|
2779
|
-
});
|
|
2780
|
-
|
|
2781
|
-
// node_modules/url-parse/index.js
|
|
2782
|
-
var require_url_parse = __commonJS({
|
|
2783
|
-
"node_modules/url-parse/index.js"(exports, module) {
|
|
2784
|
-
"use strict";
|
|
2785
|
-
var required = require_requires_port();
|
|
2786
|
-
var qs = require_querystringify();
|
|
2787
|
-
var controlOrWhitespace = /^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/;
|
|
2788
|
-
var CRHTLF = /[\n\r\t]/g;
|
|
2789
|
-
var slashes = /^[A-Za-z][A-Za-z0-9+-.]*:\/\//;
|
|
2790
|
-
var port = /:\d+$/;
|
|
2791
|
-
var protocolre = /^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i;
|
|
2792
|
-
var windowsDriveLetter = /^[a-zA-Z]:/;
|
|
2793
|
-
function trimLeft(str) {
|
|
2794
|
-
return (str ? str : "").toString().replace(controlOrWhitespace, "");
|
|
2795
|
-
}
|
|
2796
|
-
var rules = [
|
|
2797
|
-
["#", "hash"],
|
|
2798
|
-
["?", "query"],
|
|
2799
|
-
function sanitize(address, url) {
|
|
2800
|
-
return isSpecial(url.protocol) ? address.replace(/\\/g, "/") : address;
|
|
2801
|
-
},
|
|
2802
|
-
["/", "pathname"],
|
|
2803
|
-
["@", "auth", 1],
|
|
2804
|
-
[NaN, "host", void 0, 1, 1],
|
|
2805
|
-
[/:(\d*)$/, "port", void 0, 1],
|
|
2806
|
-
[NaN, "hostname", void 0, 1, 1]
|
|
2807
|
-
];
|
|
2808
|
-
var ignore = { hash: 1, query: 1 };
|
|
2809
|
-
function lolcation(loc) {
|
|
2810
|
-
var globalVar;
|
|
2811
|
-
if (typeof window !== "undefined")
|
|
2812
|
-
globalVar = window;
|
|
2813
|
-
else if (typeof global !== "undefined")
|
|
2814
|
-
globalVar = global;
|
|
2815
|
-
else if (typeof self !== "undefined")
|
|
2816
|
-
globalVar = self;
|
|
2817
|
-
else
|
|
2818
|
-
globalVar = {};
|
|
2819
|
-
var location = globalVar.location || {};
|
|
2820
|
-
loc = loc || location;
|
|
2821
|
-
var finaldestination = {}, type = typeof loc, key;
|
|
2822
|
-
if (loc.protocol === "blob:") {
|
|
2823
|
-
finaldestination = new Url(unescape(loc.pathname), {});
|
|
2824
|
-
} else if (type === "string") {
|
|
2825
|
-
finaldestination = new Url(loc, {});
|
|
2826
|
-
for (key in ignore)
|
|
2827
|
-
delete finaldestination[key];
|
|
2828
|
-
} else if (type === "object") {
|
|
2829
|
-
for (key in loc) {
|
|
2830
|
-
if (key in ignore)
|
|
2831
|
-
continue;
|
|
2832
|
-
finaldestination[key] = loc[key];
|
|
2833
|
-
}
|
|
2834
|
-
if (finaldestination.slashes === void 0) {
|
|
2835
|
-
finaldestination.slashes = slashes.test(loc.href);
|
|
2836
|
-
}
|
|
2837
|
-
}
|
|
2838
|
-
return finaldestination;
|
|
2839
|
-
}
|
|
2840
|
-
function isSpecial(scheme) {
|
|
2841
|
-
return scheme === "file:" || scheme === "ftp:" || scheme === "http:" || scheme === "https:" || scheme === "ws:" || scheme === "wss:";
|
|
2842
|
-
}
|
|
2843
|
-
function extractProtocol(address, location) {
|
|
2844
|
-
address = trimLeft(address);
|
|
2845
|
-
address = address.replace(CRHTLF, "");
|
|
2846
|
-
location = location || {};
|
|
2847
|
-
var match = protocolre.exec(address);
|
|
2848
|
-
var protocol = match[1] ? match[1].toLowerCase() : "";
|
|
2849
|
-
var forwardSlashes = !!match[2];
|
|
2850
|
-
var otherSlashes = !!match[3];
|
|
2851
|
-
var slashesCount = 0;
|
|
2852
|
-
var rest;
|
|
2853
|
-
if (forwardSlashes) {
|
|
2854
|
-
if (otherSlashes) {
|
|
2855
|
-
rest = match[2] + match[3] + match[4];
|
|
2856
|
-
slashesCount = match[2].length + match[3].length;
|
|
2857
|
-
} else {
|
|
2858
|
-
rest = match[2] + match[4];
|
|
2859
|
-
slashesCount = match[2].length;
|
|
2860
|
-
}
|
|
2861
|
-
} else {
|
|
2862
|
-
if (otherSlashes) {
|
|
2863
|
-
rest = match[3] + match[4];
|
|
2864
|
-
slashesCount = match[3].length;
|
|
2865
|
-
} else {
|
|
2866
|
-
rest = match[4];
|
|
2867
|
-
}
|
|
2868
|
-
}
|
|
2869
|
-
if (protocol === "file:") {
|
|
2870
|
-
if (slashesCount >= 2) {
|
|
2871
|
-
rest = rest.slice(2);
|
|
2872
|
-
}
|
|
2873
|
-
} else if (isSpecial(protocol)) {
|
|
2874
|
-
rest = match[4];
|
|
2875
|
-
} else if (protocol) {
|
|
2876
|
-
if (forwardSlashes) {
|
|
2877
|
-
rest = rest.slice(2);
|
|
2878
|
-
}
|
|
2879
|
-
} else if (slashesCount >= 2 && isSpecial(location.protocol)) {
|
|
2880
|
-
rest = match[4];
|
|
2881
|
-
}
|
|
2882
|
-
return {
|
|
2883
|
-
protocol,
|
|
2884
|
-
slashes: forwardSlashes || isSpecial(protocol),
|
|
2885
|
-
slashesCount,
|
|
2886
|
-
rest
|
|
2887
|
-
};
|
|
2888
|
-
}
|
|
2889
|
-
function resolve(relative, base) {
|
|
2890
|
-
if (relative === "")
|
|
2891
|
-
return base;
|
|
2892
|
-
var path = (base || "/").split("/").slice(0, -1).concat(relative.split("/")), i = path.length, last = path[i - 1], unshift = false, up = 0;
|
|
2893
|
-
while (i--) {
|
|
2894
|
-
if (path[i] === ".") {
|
|
2895
|
-
path.splice(i, 1);
|
|
2896
|
-
} else if (path[i] === "..") {
|
|
2897
|
-
path.splice(i, 1);
|
|
2898
|
-
up++;
|
|
2899
|
-
} else if (up) {
|
|
2900
|
-
if (i === 0)
|
|
2901
|
-
unshift = true;
|
|
2902
|
-
path.splice(i, 1);
|
|
2903
|
-
up--;
|
|
2904
|
-
}
|
|
2905
|
-
}
|
|
2906
|
-
if (unshift)
|
|
2907
|
-
path.unshift("");
|
|
2908
|
-
if (last === "." || last === "..")
|
|
2909
|
-
path.push("");
|
|
2910
|
-
return path.join("/");
|
|
2911
|
-
}
|
|
2912
|
-
function Url(address, location, parser) {
|
|
2913
|
-
address = trimLeft(address);
|
|
2914
|
-
address = address.replace(CRHTLF, "");
|
|
2915
|
-
if (!(this instanceof Url)) {
|
|
2916
|
-
return new Url(address, location, parser);
|
|
2917
|
-
}
|
|
2918
|
-
var relative, extracted, parse, instruction, index, key, instructions = rules.slice(), type = typeof location, url = this, i = 0;
|
|
2919
|
-
if (type !== "object" && type !== "string") {
|
|
2920
|
-
parser = location;
|
|
2921
|
-
location = null;
|
|
2922
|
-
}
|
|
2923
|
-
if (parser && typeof parser !== "function")
|
|
2924
|
-
parser = qs.parse;
|
|
2925
|
-
location = lolcation(location);
|
|
2926
|
-
extracted = extractProtocol(address || "", location);
|
|
2927
|
-
relative = !extracted.protocol && !extracted.slashes;
|
|
2928
|
-
url.slashes = extracted.slashes || relative && location.slashes;
|
|
2929
|
-
url.protocol = extracted.protocol || location.protocol || "";
|
|
2930
|
-
address = extracted.rest;
|
|
2931
|
-
if (extracted.protocol === "file:" && (extracted.slashesCount !== 2 || windowsDriveLetter.test(address)) || !extracted.slashes && (extracted.protocol || extracted.slashesCount < 2 || !isSpecial(url.protocol))) {
|
|
2932
|
-
instructions[3] = [/(.*)/, "pathname"];
|
|
2933
|
-
}
|
|
2934
|
-
for (; i < instructions.length; i++) {
|
|
2935
|
-
instruction = instructions[i];
|
|
2936
|
-
if (typeof instruction === "function") {
|
|
2937
|
-
address = instruction(address, url);
|
|
2938
|
-
continue;
|
|
2939
|
-
}
|
|
2940
|
-
parse = instruction[0];
|
|
2941
|
-
key = instruction[1];
|
|
2942
|
-
if (parse !== parse) {
|
|
2943
|
-
url[key] = address;
|
|
2944
|
-
} else if (typeof parse === "string") {
|
|
2945
|
-
index = parse === "@" ? address.lastIndexOf(parse) : address.indexOf(parse);
|
|
2946
|
-
if (~index) {
|
|
2947
|
-
if (typeof instruction[2] === "number") {
|
|
2948
|
-
url[key] = address.slice(0, index);
|
|
2949
|
-
address = address.slice(index + instruction[2]);
|
|
2950
|
-
} else {
|
|
2951
|
-
url[key] = address.slice(index);
|
|
2952
|
-
address = address.slice(0, index);
|
|
2953
|
-
}
|
|
2954
|
-
}
|
|
2955
|
-
} else if (index = parse.exec(address)) {
|
|
2956
|
-
url[key] = index[1];
|
|
2957
|
-
address = address.slice(0, index.index);
|
|
2958
|
-
}
|
|
2959
|
-
url[key] = url[key] || (relative && instruction[3] ? location[key] || "" : "");
|
|
2960
|
-
if (instruction[4])
|
|
2961
|
-
url[key] = url[key].toLowerCase();
|
|
2962
|
-
}
|
|
2963
|
-
if (parser)
|
|
2964
|
-
url.query = parser(url.query);
|
|
2965
|
-
if (relative && location.slashes && url.pathname.charAt(0) !== "/" && (url.pathname !== "" || location.pathname !== "")) {
|
|
2966
|
-
url.pathname = resolve(url.pathname, location.pathname);
|
|
2967
|
-
}
|
|
2968
|
-
if (url.pathname.charAt(0) !== "/" && isSpecial(url.protocol)) {
|
|
2969
|
-
url.pathname = "/" + url.pathname;
|
|
2970
|
-
}
|
|
2971
|
-
if (!required(url.port, url.protocol)) {
|
|
2972
|
-
url.host = url.hostname;
|
|
2973
|
-
url.port = "";
|
|
2974
|
-
}
|
|
2975
|
-
url.username = url.password = "";
|
|
2976
|
-
if (url.auth) {
|
|
2977
|
-
index = url.auth.indexOf(":");
|
|
2978
|
-
if (~index) {
|
|
2979
|
-
url.username = url.auth.slice(0, index);
|
|
2980
|
-
url.username = encodeURIComponent(decodeURIComponent(url.username));
|
|
2981
|
-
url.password = url.auth.slice(index + 1);
|
|
2982
|
-
url.password = encodeURIComponent(decodeURIComponent(url.password));
|
|
2983
|
-
} else {
|
|
2984
|
-
url.username = encodeURIComponent(decodeURIComponent(url.auth));
|
|
2985
|
-
}
|
|
2986
|
-
url.auth = url.password ? url.username + ":" + url.password : url.username;
|
|
2987
|
-
}
|
|
2988
|
-
url.origin = url.protocol !== "file:" && isSpecial(url.protocol) && url.host ? url.protocol + "//" + url.host : "null";
|
|
2989
|
-
url.href = url.toString();
|
|
2990
|
-
}
|
|
2991
|
-
function set(part, value, fn) {
|
|
2992
|
-
var url = this;
|
|
2993
|
-
switch (part) {
|
|
2994
|
-
case "query":
|
|
2995
|
-
if (typeof value === "string" && value.length) {
|
|
2996
|
-
value = (fn || qs.parse)(value);
|
|
2997
|
-
}
|
|
2998
|
-
url[part] = value;
|
|
2999
|
-
break;
|
|
3000
|
-
case "port":
|
|
3001
|
-
url[part] = value;
|
|
3002
|
-
if (!required(value, url.protocol)) {
|
|
3003
|
-
url.host = url.hostname;
|
|
3004
|
-
url[part] = "";
|
|
3005
|
-
} else if (value) {
|
|
3006
|
-
url.host = url.hostname + ":" + value;
|
|
3007
|
-
}
|
|
3008
|
-
break;
|
|
3009
|
-
case "hostname":
|
|
3010
|
-
url[part] = value;
|
|
3011
|
-
if (url.port)
|
|
3012
|
-
value += ":" + url.port;
|
|
3013
|
-
url.host = value;
|
|
3014
|
-
break;
|
|
3015
|
-
case "host":
|
|
3016
|
-
url[part] = value;
|
|
3017
|
-
if (port.test(value)) {
|
|
3018
|
-
value = value.split(":");
|
|
3019
|
-
url.port = value.pop();
|
|
3020
|
-
url.hostname = value.join(":");
|
|
3021
|
-
} else {
|
|
3022
|
-
url.hostname = value;
|
|
3023
|
-
url.port = "";
|
|
3024
|
-
}
|
|
3025
|
-
break;
|
|
3026
|
-
case "protocol":
|
|
3027
|
-
url.protocol = value.toLowerCase();
|
|
3028
|
-
url.slashes = !fn;
|
|
3029
|
-
break;
|
|
3030
|
-
case "pathname":
|
|
3031
|
-
case "hash":
|
|
3032
|
-
if (value) {
|
|
3033
|
-
var char = part === "pathname" ? "/" : "#";
|
|
3034
|
-
url[part] = value.charAt(0) !== char ? char + value : value;
|
|
3035
|
-
} else {
|
|
3036
|
-
url[part] = value;
|
|
3037
|
-
}
|
|
3038
|
-
break;
|
|
3039
|
-
case "username":
|
|
3040
|
-
case "password":
|
|
3041
|
-
url[part] = encodeURIComponent(value);
|
|
3042
|
-
break;
|
|
3043
|
-
case "auth":
|
|
3044
|
-
var index = value.indexOf(":");
|
|
3045
|
-
if (~index) {
|
|
3046
|
-
url.username = value.slice(0, index);
|
|
3047
|
-
url.username = encodeURIComponent(decodeURIComponent(url.username));
|
|
3048
|
-
url.password = value.slice(index + 1);
|
|
3049
|
-
url.password = encodeURIComponent(decodeURIComponent(url.password));
|
|
3050
|
-
} else {
|
|
3051
|
-
url.username = encodeURIComponent(decodeURIComponent(value));
|
|
3052
|
-
}
|
|
3053
|
-
}
|
|
3054
|
-
for (var i = 0; i < rules.length; i++) {
|
|
3055
|
-
var ins = rules[i];
|
|
3056
|
-
if (ins[4])
|
|
3057
|
-
url[ins[1]] = url[ins[1]].toLowerCase();
|
|
3058
|
-
}
|
|
3059
|
-
url.auth = url.password ? url.username + ":" + url.password : url.username;
|
|
3060
|
-
url.origin = url.protocol !== "file:" && isSpecial(url.protocol) && url.host ? url.protocol + "//" + url.host : "null";
|
|
3061
|
-
url.href = url.toString();
|
|
3062
|
-
return url;
|
|
3063
|
-
}
|
|
3064
|
-
function toString(stringify) {
|
|
3065
|
-
if (!stringify || typeof stringify !== "function")
|
|
3066
|
-
stringify = qs.stringify;
|
|
3067
|
-
var query, url = this, host = url.host, protocol = url.protocol;
|
|
3068
|
-
if (protocol && protocol.charAt(protocol.length - 1) !== ":")
|
|
3069
|
-
protocol += ":";
|
|
3070
|
-
var result = protocol + (url.protocol && url.slashes || isSpecial(url.protocol) ? "//" : "");
|
|
3071
|
-
if (url.username) {
|
|
3072
|
-
result += url.username;
|
|
3073
|
-
if (url.password)
|
|
3074
|
-
result += ":" + url.password;
|
|
3075
|
-
result += "@";
|
|
3076
|
-
} else if (url.password) {
|
|
3077
|
-
result += ":" + url.password;
|
|
3078
|
-
result += "@";
|
|
3079
|
-
} else if (url.protocol !== "file:" && isSpecial(url.protocol) && !host && url.pathname !== "/") {
|
|
3080
|
-
result += "@";
|
|
3081
|
-
}
|
|
3082
|
-
if (host[host.length - 1] === ":" || port.test(url.hostname) && !url.port) {
|
|
3083
|
-
host += ":";
|
|
3084
|
-
}
|
|
3085
|
-
result += host + url.pathname;
|
|
3086
|
-
query = typeof url.query === "object" ? stringify(url.query) : url.query;
|
|
3087
|
-
if (query)
|
|
3088
|
-
result += query.charAt(0) !== "?" ? "?" + query : query;
|
|
3089
|
-
if (url.hash)
|
|
3090
|
-
result += url.hash;
|
|
3091
|
-
return result;
|
|
3092
|
-
}
|
|
3093
|
-
Url.prototype = { set, toString };
|
|
3094
|
-
Url.extractProtocol = extractProtocol;
|
|
3095
|
-
Url.location = lolcation;
|
|
3096
|
-
Url.trimLeft = trimLeft;
|
|
3097
|
-
Url.qs = qs;
|
|
3098
|
-
module.exports = Url;
|
|
3099
|
-
}
|
|
3100
|
-
});
|
|
3101
|
-
|
|
3102
|
-
// node_modules/get-it/lib/middleware/defaultOptionsProcessor.js
|
|
3103
|
-
var require_defaultOptionsProcessor = __commonJS({
|
|
3104
|
-
"node_modules/get-it/lib/middleware/defaultOptionsProcessor.js"(exports, module) {
|
|
3105
|
-
"use strict";
|
|
3106
|
-
var objectAssign = require_object_assign();
|
|
3107
|
-
var urlParse = require_url_parse();
|
|
3108
|
-
var isReactNative = typeof navigator === "undefined" ? false : navigator.product === "ReactNative";
|
|
3109
|
-
var has = Object.prototype.hasOwnProperty;
|
|
3110
|
-
var defaultOptions = {
|
|
3111
|
-
timeout: isReactNative ? 6e4 : 12e4
|
|
3112
|
-
};
|
|
3113
|
-
module.exports = function(opts) {
|
|
3114
|
-
var options = typeof opts === "string" ? objectAssign({
|
|
3115
|
-
url: opts
|
|
3116
|
-
}, defaultOptions) : objectAssign({}, defaultOptions, opts);
|
|
3117
|
-
var url = urlParse(options.url, {}, true);
|
|
3118
|
-
options.timeout = normalizeTimeout(options.timeout);
|
|
3119
|
-
if (options.query) {
|
|
3120
|
-
url.query = objectAssign({}, url.query, removeUndefined(options.query));
|
|
3121
|
-
}
|
|
3122
|
-
options.method = options.body && !options.method ? "POST" : (options.method || "GET").toUpperCase();
|
|
3123
|
-
options.url = url.toString(stringifyQueryString);
|
|
3124
|
-
return options;
|
|
3125
|
-
};
|
|
3126
|
-
function stringifyQueryString(obj) {
|
|
3127
|
-
var pairs = [];
|
|
3128
|
-
for (var key in obj) {
|
|
3129
|
-
if (has.call(obj, key)) {
|
|
3130
|
-
push(key, obj[key]);
|
|
3131
|
-
}
|
|
3132
|
-
}
|
|
3133
|
-
return pairs.length ? pairs.join("&") : "";
|
|
3134
|
-
function push(key2, val) {
|
|
3135
|
-
if (Array.isArray(val)) {
|
|
3136
|
-
val.forEach(function(item) {
|
|
3137
|
-
return push(key2, item);
|
|
3138
|
-
});
|
|
3139
|
-
} else {
|
|
3140
|
-
pairs.push([key2, val].map(encodeURIComponent).join("="));
|
|
3141
|
-
}
|
|
3142
|
-
}
|
|
3143
|
-
}
|
|
3144
|
-
function normalizeTimeout(time) {
|
|
3145
|
-
if (time === false || time === 0) {
|
|
3146
|
-
return false;
|
|
3147
|
-
}
|
|
3148
|
-
if (time.connect || time.socket) {
|
|
3149
|
-
return time;
|
|
3150
|
-
}
|
|
3151
|
-
var delay = Number(time);
|
|
3152
|
-
if (isNaN(delay)) {
|
|
3153
|
-
return normalizeTimeout(defaultOptions.timeout);
|
|
3154
|
-
}
|
|
3155
|
-
return {
|
|
3156
|
-
connect: delay,
|
|
3157
|
-
socket: delay
|
|
3158
|
-
};
|
|
3159
|
-
}
|
|
3160
|
-
function removeUndefined(obj) {
|
|
3161
|
-
var target = {};
|
|
3162
|
-
for (var key in obj) {
|
|
3163
|
-
if (obj[key] !== void 0) {
|
|
3164
|
-
target[key] = obj[key];
|
|
3165
|
-
}
|
|
3166
|
-
}
|
|
3167
|
-
return target;
|
|
3168
|
-
}
|
|
3169
|
-
}
|
|
3170
|
-
});
|
|
3171
|
-
|
|
3172
|
-
// node_modules/get-it/lib/middleware/defaultOptionsValidator.js
|
|
3173
|
-
var require_defaultOptionsValidator = __commonJS({
|
|
3174
|
-
"node_modules/get-it/lib/middleware/defaultOptionsValidator.js"(exports, module) {
|
|
3175
|
-
"use strict";
|
|
3176
|
-
var validUrl = /^https?:\/\//i;
|
|
3177
|
-
module.exports = function(options) {
|
|
3178
|
-
if (!validUrl.test(options.url)) {
|
|
3179
|
-
throw new Error('"'.concat(options.url, '" is not a valid URL'));
|
|
3180
|
-
}
|
|
3181
|
-
};
|
|
3182
|
-
}
|
|
3183
|
-
});
|
|
3184
|
-
|
|
3185
|
-
// node_modules/same-origin/url-parser.js
|
|
3186
|
-
var require_url_parser = __commonJS({
|
|
3187
|
-
"node_modules/same-origin/url-parser.js"(exports, module) {
|
|
3188
|
-
"use strict";
|
|
3189
|
-
var regex = /^(?:(?:(?:([^:\/#\?]+:)?(?:(?:\/\/)((?:((?:[^:@\/#\?]+)(?:\:(?:[^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([0-9]+))?))?)?)?((?:\/?(?:[^\/\?#]+\/+)*)(?:[^\?#]*)))?(\?[^#]+)?)(#.*)?/;
|
|
3190
|
-
module.exports = {
|
|
3191
|
-
regex,
|
|
3192
|
-
parse: function(url) {
|
|
3193
|
-
var match = regex.exec(url);
|
|
3194
|
-
if (!match) {
|
|
3195
|
-
return {};
|
|
3196
|
-
}
|
|
3197
|
-
return {
|
|
3198
|
-
protocol: (match[1] || "").toLowerCase() || void 0,
|
|
3199
|
-
hostname: (match[5] || "").toLowerCase() || void 0,
|
|
3200
|
-
port: match[6] || void 0
|
|
3201
|
-
};
|
|
3202
|
-
}
|
|
3203
|
-
};
|
|
3204
|
-
}
|
|
3205
|
-
});
|
|
3206
|
-
|
|
3207
|
-
// node_modules/same-origin/index.js
|
|
3208
|
-
var require_same_origin = __commonJS({
|
|
3209
|
-
"node_modules/same-origin/index.js"(exports, module) {
|
|
3210
|
-
"use strict";
|
|
3211
|
-
var url = require_url_parser();
|
|
3212
|
-
module.exports = function(uri1, uri2, ieMode) {
|
|
3213
|
-
if (uri1 === uri2) {
|
|
3214
|
-
return true;
|
|
3215
|
-
}
|
|
3216
|
-
var url1 = url.parse(uri1, false, true);
|
|
3217
|
-
var url2 = url.parse(uri2, false, true);
|
|
3218
|
-
var url1Port = url1.port | 0 || (url1.protocol === "https" ? 443 : 80);
|
|
3219
|
-
var url2Port = url2.port | 0 || (url2.protocol === "https" ? 443 : 80);
|
|
3220
|
-
var match = {
|
|
3221
|
-
proto: url1.protocol === url2.protocol,
|
|
3222
|
-
hostname: url1.hostname === url2.hostname,
|
|
3223
|
-
port: url1Port === url2Port
|
|
3224
|
-
};
|
|
3225
|
-
return match.proto && match.hostname && (match.port || ieMode);
|
|
3226
|
-
};
|
|
3227
|
-
}
|
|
3228
|
-
});
|
|
3229
|
-
|
|
3230
|
-
// node_modules/parse-headers/parse-headers.js
|
|
3231
|
-
var require_parse_headers = __commonJS({
|
|
3232
|
-
"node_modules/parse-headers/parse-headers.js"(exports, module) {
|
|
3233
|
-
var trim = function(string) {
|
|
3234
|
-
return string.replace(/^\s+|\s+$/g, "");
|
|
3235
|
-
};
|
|
3236
|
-
var isArray = function(arg) {
|
|
3237
|
-
return Object.prototype.toString.call(arg) === "[object Array]";
|
|
3238
|
-
};
|
|
3239
|
-
module.exports = function(headers) {
|
|
3240
|
-
if (!headers)
|
|
3241
|
-
return {};
|
|
3242
|
-
var result = {};
|
|
3243
|
-
var headersArr = trim(headers).split("\n");
|
|
3244
|
-
for (var i = 0; i < headersArr.length; i++) {
|
|
3245
|
-
var row = headersArr[i];
|
|
3246
|
-
var index = row.indexOf(":"), key = trim(row.slice(0, index)).toLowerCase(), value = trim(row.slice(index + 1));
|
|
3247
|
-
if (typeof result[key] === "undefined") {
|
|
3248
|
-
result[key] = value;
|
|
3249
|
-
} else if (isArray(result[key])) {
|
|
3250
|
-
result[key].push(value);
|
|
3251
|
-
} else {
|
|
3252
|
-
result[key] = [result[key], value];
|
|
3253
|
-
}
|
|
3254
|
-
}
|
|
3255
|
-
return result;
|
|
3256
|
-
};
|
|
3257
|
-
}
|
|
3258
|
-
});
|
|
3259
|
-
|
|
3260
|
-
// node_modules/get-it/lib/request/browser/fetchXhr.js
|
|
3261
|
-
var require_fetchXhr = __commonJS({
|
|
3262
|
-
"node_modules/get-it/lib/request/browser/fetchXhr.js"(exports, module) {
|
|
3263
|
-
"use strict";
|
|
3264
|
-
function FetchXhr() {
|
|
3265
|
-
this.readyState = 0;
|
|
3266
|
-
}
|
|
3267
|
-
FetchXhr.prototype.open = function(method, url) {
|
|
3268
|
-
this._method = method;
|
|
3269
|
-
this._url = url;
|
|
3270
|
-
this._resHeaders = "";
|
|
3271
|
-
this.readyState = 1;
|
|
3272
|
-
this.onreadystatechange();
|
|
3273
|
-
};
|
|
3274
|
-
FetchXhr.prototype.abort = function() {
|
|
3275
|
-
if (this._controller) {
|
|
3276
|
-
this._controller.abort();
|
|
3277
|
-
}
|
|
3278
|
-
};
|
|
3279
|
-
FetchXhr.prototype.getAllResponseHeaders = function() {
|
|
3280
|
-
return this._resHeaders;
|
|
3281
|
-
};
|
|
3282
|
-
FetchXhr.prototype.setRequestHeader = function(key, value) {
|
|
3283
|
-
this._headers = this._headers || {};
|
|
3284
|
-
this._headers[key] = value;
|
|
3285
|
-
};
|
|
3286
|
-
FetchXhr.prototype.send = function(body) {
|
|
3287
|
-
var _this = this;
|
|
3288
|
-
var ctrl = this._controller = typeof AbortController === "function" && new AbortController();
|
|
3289
|
-
var textBody = this.responseType !== "arraybuffer";
|
|
3290
|
-
var options = {
|
|
3291
|
-
method: this._method,
|
|
3292
|
-
headers: this._headers,
|
|
3293
|
-
signal: ctrl && ctrl.signal,
|
|
3294
|
-
body
|
|
3295
|
-
};
|
|
3296
|
-
if (typeof window !== "undefined") {
|
|
3297
|
-
options.credentials = this.withCredentials ? "include" : "omit";
|
|
3298
|
-
}
|
|
3299
|
-
fetch(this._url, options).then(function(res) {
|
|
3300
|
-
res.headers.forEach(function(value, key) {
|
|
3301
|
-
_this._resHeaders += "".concat(key, ": ").concat(value, "\r\n");
|
|
3302
|
-
});
|
|
3303
|
-
_this.status = res.status;
|
|
3304
|
-
_this.statusText = res.statusText;
|
|
3305
|
-
_this.readyState = 3;
|
|
3306
|
-
return textBody ? res.text() : res.arrayBuffer();
|
|
3307
|
-
}).then(function(resBody) {
|
|
3308
|
-
if (textBody) {
|
|
3309
|
-
_this.responseText = resBody;
|
|
3310
|
-
} else {
|
|
3311
|
-
_this.response = resBody;
|
|
3312
|
-
}
|
|
3313
|
-
_this.readyState = 4;
|
|
3314
|
-
_this.onreadystatechange();
|
|
3315
|
-
}).catch(function(err) {
|
|
3316
|
-
if (err.name === "AbortError") {
|
|
3317
|
-
_this.onabort();
|
|
3318
|
-
return;
|
|
3319
|
-
}
|
|
3320
|
-
_this.onerror(err);
|
|
3321
|
-
});
|
|
3322
|
-
};
|
|
3323
|
-
module.exports = FetchXhr;
|
|
3324
|
-
}
|
|
3325
|
-
});
|
|
3326
|
-
|
|
3327
|
-
// node_modules/get-it/lib/request/browser-request.js
|
|
3328
|
-
var require_browser_request = __commonJS({
|
|
3329
|
-
"node_modules/get-it/lib/request/browser-request.js"(exports, module) {
|
|
3330
|
-
"use strict";
|
|
3331
|
-
var sameOrigin = require_same_origin();
|
|
3332
|
-
var parseHeaders = require_parse_headers();
|
|
3333
|
-
var FetchXhr = require_fetchXhr();
|
|
3334
|
-
var noop = function noop2() {
|
|
3335
|
-
};
|
|
3336
|
-
var win = typeof window === "undefined" ? void 0 : window;
|
|
3337
|
-
var adapter = win ? "xhr" : "fetch";
|
|
3338
|
-
var XmlHttpRequest = typeof XMLHttpRequest === "function" ? XMLHttpRequest : noop;
|
|
3339
|
-
var hasXhr2 = "withCredentials" in new XmlHttpRequest();
|
|
3340
|
-
var XDR = typeof XDomainRequest === "undefined" ? void 0 : XDomainRequest;
|
|
3341
|
-
var CrossDomainRequest = hasXhr2 ? XmlHttpRequest : XDR;
|
|
3342
|
-
if (!win) {
|
|
3343
|
-
XmlHttpRequest = FetchXhr;
|
|
3344
|
-
CrossDomainRequest = FetchXhr;
|
|
3345
|
-
}
|
|
3346
|
-
module.exports = function(context, callback) {
|
|
3347
|
-
var opts = context.options;
|
|
3348
|
-
var options = context.applyMiddleware("finalizeOptions", opts);
|
|
3349
|
-
var timers = {};
|
|
3350
|
-
var cors = win && win.location && !sameOrigin(win.location.href, options.url);
|
|
3351
|
-
var injectedResponse = context.applyMiddleware("interceptRequest", void 0, {
|
|
3352
|
-
adapter,
|
|
3353
|
-
context
|
|
3354
|
-
});
|
|
3355
|
-
if (injectedResponse) {
|
|
3356
|
-
var cbTimer = setTimeout(callback, 0, null, injectedResponse);
|
|
3357
|
-
var cancel = function cancel2() {
|
|
3358
|
-
return clearTimeout(cbTimer);
|
|
3359
|
-
};
|
|
3360
|
-
return {
|
|
3361
|
-
abort: cancel
|
|
3362
|
-
};
|
|
3363
|
-
}
|
|
3364
|
-
var xhr = cors ? new CrossDomainRequest() : new XmlHttpRequest();
|
|
3365
|
-
var isXdr = win && win.XDomainRequest && xhr instanceof win.XDomainRequest;
|
|
3366
|
-
var headers = options.headers;
|
|
3367
|
-
var delays = options.timeout;
|
|
3368
|
-
var aborted = false;
|
|
3369
|
-
var loaded = false;
|
|
3370
|
-
var timedOut = false;
|
|
3371
|
-
xhr.onerror = onError;
|
|
3372
|
-
xhr.ontimeout = onError;
|
|
3373
|
-
xhr.onabort = function() {
|
|
3374
|
-
stopTimers(true);
|
|
3375
|
-
aborted = true;
|
|
3376
|
-
};
|
|
3377
|
-
xhr.onprogress = function() {
|
|
3378
|
-
};
|
|
3379
|
-
var loadEvent = isXdr ? "onload" : "onreadystatechange";
|
|
3380
|
-
xhr[loadEvent] = function() {
|
|
3381
|
-
resetTimers();
|
|
3382
|
-
if (aborted || xhr.readyState !== 4 && !isXdr) {
|
|
3383
|
-
return;
|
|
3384
|
-
}
|
|
3385
|
-
if (xhr.status === 0) {
|
|
3386
|
-
return;
|
|
3387
|
-
}
|
|
3388
|
-
onLoad();
|
|
3389
|
-
};
|
|
3390
|
-
xhr.open(options.method, options.url, true);
|
|
3391
|
-
xhr.withCredentials = !!options.withCredentials;
|
|
3392
|
-
if (headers && xhr.setRequestHeader) {
|
|
3393
|
-
for (var key in headers) {
|
|
3394
|
-
if (headers.hasOwnProperty(key)) {
|
|
3395
|
-
xhr.setRequestHeader(key, headers[key]);
|
|
3396
|
-
}
|
|
3397
|
-
}
|
|
3398
|
-
} else if (headers && isXdr) {
|
|
3399
|
-
throw new Error("Headers cannot be set on an XDomainRequest object");
|
|
3400
|
-
}
|
|
3401
|
-
if (options.rawBody) {
|
|
3402
|
-
xhr.responseType = "arraybuffer";
|
|
3403
|
-
}
|
|
3404
|
-
context.applyMiddleware("onRequest", {
|
|
3405
|
-
options,
|
|
3406
|
-
adapter,
|
|
3407
|
-
request: xhr,
|
|
3408
|
-
context
|
|
3409
|
-
});
|
|
3410
|
-
xhr.send(options.body || null);
|
|
3411
|
-
if (delays) {
|
|
3412
|
-
timers.connect = setTimeout(function() {
|
|
3413
|
-
return timeoutRequest("ETIMEDOUT");
|
|
3414
|
-
}, delays.connect);
|
|
3415
|
-
}
|
|
3416
|
-
return {
|
|
3417
|
-
abort
|
|
3418
|
-
};
|
|
3419
|
-
function abort() {
|
|
3420
|
-
aborted = true;
|
|
3421
|
-
if (xhr) {
|
|
3422
|
-
xhr.abort();
|
|
3423
|
-
}
|
|
3424
|
-
}
|
|
3425
|
-
function timeoutRequest(code) {
|
|
3426
|
-
timedOut = true;
|
|
3427
|
-
xhr.abort();
|
|
3428
|
-
var error = new Error(code === "ESOCKETTIMEDOUT" ? "Socket timed out on request to ".concat(options.url) : "Connection timed out on request to ".concat(options.url));
|
|
3429
|
-
error.code = code;
|
|
3430
|
-
context.channels.error.publish(error);
|
|
3431
|
-
}
|
|
3432
|
-
function resetTimers() {
|
|
3433
|
-
if (!delays) {
|
|
3434
|
-
return;
|
|
3435
|
-
}
|
|
3436
|
-
stopTimers();
|
|
3437
|
-
timers.socket = setTimeout(function() {
|
|
3438
|
-
return timeoutRequest("ESOCKETTIMEDOUT");
|
|
3439
|
-
}, delays.socket);
|
|
3440
|
-
}
|
|
3441
|
-
function stopTimers(force) {
|
|
3442
|
-
if (force || aborted || xhr.readyState >= 2 && timers.connect) {
|
|
3443
|
-
clearTimeout(timers.connect);
|
|
3444
|
-
}
|
|
3445
|
-
if (timers.socket) {
|
|
3446
|
-
clearTimeout(timers.socket);
|
|
3447
|
-
}
|
|
3448
|
-
}
|
|
3449
|
-
function onError(error) {
|
|
3450
|
-
if (loaded) {
|
|
3451
|
-
return;
|
|
3452
|
-
}
|
|
3453
|
-
stopTimers(true);
|
|
3454
|
-
loaded = true;
|
|
3455
|
-
xhr = null;
|
|
3456
|
-
var err = error || new Error("Network error while attempting to reach ".concat(options.url));
|
|
3457
|
-
err.isNetworkError = true;
|
|
3458
|
-
err.request = options;
|
|
3459
|
-
callback(err);
|
|
3460
|
-
}
|
|
3461
|
-
function reduceResponse() {
|
|
3462
|
-
var statusCode = xhr.status;
|
|
3463
|
-
var statusMessage = xhr.statusText;
|
|
3464
|
-
if (isXdr && statusCode === void 0) {
|
|
3465
|
-
statusCode = 200;
|
|
3466
|
-
} else if (statusCode > 12e3 && statusCode < 12156) {
|
|
3467
|
-
return onError();
|
|
3468
|
-
} else {
|
|
3469
|
-
statusCode = xhr.status === 1223 ? 204 : xhr.status;
|
|
3470
|
-
statusMessage = xhr.status === 1223 ? "No Content" : statusMessage;
|
|
3471
|
-
}
|
|
3472
|
-
return {
|
|
3473
|
-
body: xhr.response || xhr.responseText,
|
|
3474
|
-
url: options.url,
|
|
3475
|
-
method: options.method,
|
|
3476
|
-
headers: isXdr ? {} : parseHeaders(xhr.getAllResponseHeaders()),
|
|
3477
|
-
statusCode,
|
|
3478
|
-
statusMessage
|
|
3479
|
-
};
|
|
3480
|
-
}
|
|
3481
|
-
function onLoad() {
|
|
3482
|
-
if (aborted || loaded || timedOut) {
|
|
3483
|
-
return;
|
|
3484
|
-
}
|
|
3485
|
-
if (xhr.status === 0) {
|
|
3486
|
-
onError(new Error("Unknown XHR error"));
|
|
3487
|
-
return;
|
|
3488
|
-
}
|
|
3489
|
-
stopTimers();
|
|
3490
|
-
loaded = true;
|
|
3491
|
-
callback(null, reduceResponse());
|
|
3492
|
-
}
|
|
3493
|
-
};
|
|
3494
|
-
}
|
|
3495
|
-
});
|
|
3496
|
-
|
|
3497
|
-
// node_modules/get-it/lib/request/index.js
|
|
3498
|
-
var require_request = __commonJS({
|
|
3499
|
-
"node_modules/get-it/lib/request/index.js"(exports, module) {
|
|
3500
|
-
"use strict";
|
|
3501
|
-
module.exports = require_browser_request();
|
|
3502
|
-
}
|
|
3503
|
-
});
|
|
3504
|
-
|
|
3505
|
-
// node_modules/get-it/lib/index.js
|
|
3506
|
-
var require_lib = __commonJS({
|
|
3507
|
-
"node_modules/get-it/lib/index.js"(exports, module) {
|
|
3508
|
-
"use strict";
|
|
3509
|
-
var pubsub = require_nano_pubsub();
|
|
3510
|
-
var middlewareReducer = require_middlewareReducer();
|
|
3511
|
-
var processOptions = require_defaultOptionsProcessor();
|
|
3512
|
-
var validateOptions = require_defaultOptionsValidator();
|
|
3513
|
-
var httpRequester = require_request();
|
|
3514
|
-
var channelNames = ["request", "response", "progress", "error", "abort"];
|
|
3515
|
-
var middlehooks = ["processOptions", "validateOptions", "interceptRequest", "finalizeOptions", "onRequest", "onResponse", "onError", "onReturn", "onHeaders"];
|
|
3516
|
-
module.exports = function createRequester() {
|
|
3517
|
-
var initMiddleware = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
|
|
3518
|
-
var httpRequest = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : httpRequester;
|
|
3519
|
-
var loadedMiddleware = [];
|
|
3520
|
-
var middleware = middlehooks.reduce(function(ware, name) {
|
|
3521
|
-
ware[name] = ware[name] || [];
|
|
3522
|
-
return ware;
|
|
3523
|
-
}, {
|
|
3524
|
-
processOptions: [processOptions],
|
|
3525
|
-
validateOptions: [validateOptions]
|
|
3526
|
-
});
|
|
3527
|
-
function request(opts) {
|
|
3528
|
-
var channels = channelNames.reduce(function(target, name) {
|
|
3529
|
-
target[name] = pubsub();
|
|
3530
|
-
return target;
|
|
3531
|
-
}, {});
|
|
3532
|
-
var applyMiddleware = middlewareReducer(middleware);
|
|
3533
|
-
var options = applyMiddleware("processOptions", opts);
|
|
3534
|
-
applyMiddleware("validateOptions", options);
|
|
3535
|
-
var context = {
|
|
3536
|
-
options,
|
|
3537
|
-
channels,
|
|
3538
|
-
applyMiddleware
|
|
572
|
+
},
|
|
573
|
+
_dataRequest(endpoint, body, options = {}) {
|
|
574
|
+
const isMutation = endpoint === "mutate";
|
|
575
|
+
const isQuery = endpoint === "query";
|
|
576
|
+
const strQuery = !isMutation && encodeQueryString(body);
|
|
577
|
+
const useGet = !isMutation && strQuery.length < getQuerySizeLimit;
|
|
578
|
+
const stringQuery = useGet ? strQuery : "";
|
|
579
|
+
const returnFirst = options.returnFirst;
|
|
580
|
+
const { timeout, token, tag, headers } = options;
|
|
581
|
+
const uri = this.getDataUrl(endpoint, stringQuery);
|
|
582
|
+
const reqOptions = {
|
|
583
|
+
method: useGet ? "GET" : "POST",
|
|
584
|
+
uri,
|
|
585
|
+
json: true,
|
|
586
|
+
body: useGet ? void 0 : body,
|
|
587
|
+
query: isMutation && getMutationQuery(options),
|
|
588
|
+
timeout,
|
|
589
|
+
headers,
|
|
590
|
+
token,
|
|
591
|
+
tag,
|
|
592
|
+
canUseCdn: isQuery
|
|
3539
593
|
};
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
channels.abort.subscribe(function() {
|
|
3547
|
-
unsubscribe();
|
|
3548
|
-
if (ongoingRequest) {
|
|
3549
|
-
ongoingRequest.abort();
|
|
3550
|
-
}
|
|
3551
|
-
});
|
|
3552
|
-
var returnValue = applyMiddleware("onReturn", channels, context);
|
|
3553
|
-
if (returnValue === channels) {
|
|
3554
|
-
channels.request.publish(context);
|
|
3555
|
-
}
|
|
3556
|
-
return returnValue;
|
|
3557
|
-
function onResponse(reqErr, res, ctx) {
|
|
3558
|
-
var error = reqErr;
|
|
3559
|
-
var response = res;
|
|
3560
|
-
if (!error) {
|
|
3561
|
-
try {
|
|
3562
|
-
response = applyMiddleware("onResponse", res, ctx);
|
|
3563
|
-
} catch (err) {
|
|
3564
|
-
response = null;
|
|
3565
|
-
error = err;
|
|
594
|
+
return this._requestObservable(reqOptions).pipe(
|
|
595
|
+
filter(isResponse),
|
|
596
|
+
map(getBody),
|
|
597
|
+
map((res) => {
|
|
598
|
+
if (!isMutation) {
|
|
599
|
+
return res;
|
|
3566
600
|
}
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
601
|
+
const results = res.results || [];
|
|
602
|
+
if (options.returnDocuments) {
|
|
603
|
+
return returnFirst ? results[0] && results[0].document : results.map((mut) => mut.document);
|
|
604
|
+
}
|
|
605
|
+
const key = returnFirst ? "documentId" : "documentIds";
|
|
606
|
+
const ids = returnFirst ? results[0] && results[0].id : results.map((mut) => mut.id);
|
|
607
|
+
return {
|
|
608
|
+
transactionId: res.transactionId,
|
|
609
|
+
results,
|
|
610
|
+
[key]: ids
|
|
611
|
+
};
|
|
612
|
+
})
|
|
613
|
+
);
|
|
614
|
+
},
|
|
615
|
+
_create(doc, op, options = {}) {
|
|
616
|
+
const mutation = { [op]: doc };
|
|
617
|
+
const opts = assign({ returnFirst: true, returnDocuments: true }, options);
|
|
618
|
+
return this.dataRequest("mutate", { mutations: [mutation] }, opts);
|
|
3575
619
|
}
|
|
3576
|
-
request.use = function use(newMiddleware) {
|
|
3577
|
-
if (!newMiddleware) {
|
|
3578
|
-
throw new Error("Tried to add middleware that resolved to falsey value");
|
|
3579
|
-
}
|
|
3580
|
-
if (typeof newMiddleware === "function") {
|
|
3581
|
-
throw new Error("Tried to add middleware that was a function. It probably expects you to pass options to it.");
|
|
3582
|
-
}
|
|
3583
|
-
if (newMiddleware.onReturn && middleware.onReturn.length > 0) {
|
|
3584
|
-
throw new Error("Tried to add new middleware with `onReturn` handler, but another handler has already been registered for this event");
|
|
3585
|
-
}
|
|
3586
|
-
middlehooks.forEach(function(key) {
|
|
3587
|
-
if (newMiddleware[key]) {
|
|
3588
|
-
middleware[key].push(newMiddleware[key]);
|
|
3589
|
-
}
|
|
3590
|
-
});
|
|
3591
|
-
loadedMiddleware.push(newMiddleware);
|
|
3592
|
-
return request;
|
|
3593
|
-
};
|
|
3594
|
-
request.clone = function clone() {
|
|
3595
|
-
return createRequester(loadedMiddleware);
|
|
3596
|
-
};
|
|
3597
|
-
initMiddleware.forEach(request.use);
|
|
3598
|
-
return request;
|
|
3599
620
|
};
|
|
3600
621
|
}
|
|
3601
622
|
});
|
|
3602
623
|
|
|
3603
|
-
//
|
|
3604
|
-
var
|
|
3605
|
-
"
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
// node_modules/get-it/lib/util/global.js
|
|
3611
|
-
var require_global = __commonJS({
|
|
3612
|
-
"node_modules/get-it/lib/util/global.js"(exports, module) {
|
|
3613
|
-
"use strict";
|
|
3614
|
-
if (typeof globalThis !== "undefined") {
|
|
3615
|
-
module.exports = globalThis;
|
|
3616
|
-
} else if (typeof window !== "undefined") {
|
|
3617
|
-
module.exports = window;
|
|
3618
|
-
} else if (typeof global !== "undefined") {
|
|
3619
|
-
module.exports = global;
|
|
3620
|
-
} else if (typeof self !== "undefined") {
|
|
3621
|
-
module.exports = self;
|
|
3622
|
-
} else {
|
|
3623
|
-
module.exports = {};
|
|
624
|
+
// src/datasets/datasetsClient.js
|
|
625
|
+
var require_datasetsClient = __commonJS({
|
|
626
|
+
"src/datasets/datasetsClient.js"(exports, module) {
|
|
627
|
+
var assign = __require("object-assign");
|
|
628
|
+
var validate = require_validators();
|
|
629
|
+
function DatasetsClient(client) {
|
|
630
|
+
this.request = client.request.bind(client);
|
|
3624
631
|
}
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
632
|
+
assign(DatasetsClient.prototype, {
|
|
633
|
+
create(name, options) {
|
|
634
|
+
return this._modify("PUT", name, options);
|
|
635
|
+
},
|
|
636
|
+
edit(name, options) {
|
|
637
|
+
return this._modify("PATCH", name, options);
|
|
638
|
+
},
|
|
639
|
+
delete(name) {
|
|
640
|
+
return this._modify("DELETE", name);
|
|
641
|
+
},
|
|
642
|
+
list() {
|
|
643
|
+
return this.request({ uri: "/datasets" });
|
|
644
|
+
},
|
|
645
|
+
_modify(method, name, body) {
|
|
646
|
+
validate.dataset(name);
|
|
647
|
+
return this.request({ method, uri: `/datasets/${name}`, body });
|
|
3639
648
|
}
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
return new Observable(function(observer) {
|
|
3643
|
-
channels.error.subscribe(function(err) {
|
|
3644
|
-
return observer.error(err);
|
|
3645
|
-
});
|
|
3646
|
-
channels.progress.subscribe(function(event) {
|
|
3647
|
-
return observer.next(objectAssign({
|
|
3648
|
-
type: "progress"
|
|
3649
|
-
}, event));
|
|
3650
|
-
});
|
|
3651
|
-
channels.response.subscribe(function(response) {
|
|
3652
|
-
observer.next(objectAssign({
|
|
3653
|
-
type: "response"
|
|
3654
|
-
}, response));
|
|
3655
|
-
observer.complete();
|
|
3656
|
-
});
|
|
3657
|
-
channels.request.publish(context);
|
|
3658
|
-
return function() {
|
|
3659
|
-
return channels.abort.publish();
|
|
3660
|
-
};
|
|
3661
|
-
});
|
|
3662
|
-
}
|
|
3663
|
-
};
|
|
3664
|
-
};
|
|
3665
|
-
}
|
|
3666
|
-
});
|
|
3667
|
-
|
|
3668
|
-
// node_modules/isobject/index.js
|
|
3669
|
-
var require_isobject = __commonJS({
|
|
3670
|
-
"node_modules/isobject/index.js"(exports, module) {
|
|
3671
|
-
"use strict";
|
|
3672
|
-
module.exports = function isObject(val) {
|
|
3673
|
-
return val != null && typeof val === "object" && Array.isArray(val) === false;
|
|
3674
|
-
};
|
|
649
|
+
});
|
|
650
|
+
module.exports = DatasetsClient;
|
|
3675
651
|
}
|
|
3676
652
|
});
|
|
3677
653
|
|
|
3678
|
-
//
|
|
3679
|
-
var
|
|
3680
|
-
"
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
return isObject(o) === true && Object.prototype.toString.call(o) === "[object Object]";
|
|
654
|
+
// src/projects/projectsClient.js
|
|
655
|
+
var require_projectsClient = __commonJS({
|
|
656
|
+
"src/projects/projectsClient.js"(exports, module) {
|
|
657
|
+
var assign = __require("object-assign");
|
|
658
|
+
function ProjectsClient(client) {
|
|
659
|
+
this.client = client;
|
|
3685
660
|
}
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
return false;
|
|
3693
|
-
prot = ctor.prototype;
|
|
3694
|
-
if (isObjectObject(prot) === false)
|
|
3695
|
-
return false;
|
|
3696
|
-
if (prot.hasOwnProperty("isPrototypeOf") === false) {
|
|
3697
|
-
return false;
|
|
661
|
+
assign(ProjectsClient.prototype, {
|
|
662
|
+
list() {
|
|
663
|
+
return this.client.request({ uri: "/projects" });
|
|
664
|
+
},
|
|
665
|
+
getById(id) {
|
|
666
|
+
return this.client.request({ uri: `/projects/${id}` });
|
|
3698
667
|
}
|
|
3699
|
-
|
|
3700
|
-
|
|
668
|
+
});
|
|
669
|
+
module.exports = ProjectsClient;
|
|
3701
670
|
}
|
|
3702
671
|
});
|
|
3703
672
|
|
|
3704
|
-
//
|
|
3705
|
-
var
|
|
3706
|
-
"
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
} : function(obj2) {
|
|
3713
|
-
return obj2 && typeof Symbol == "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
3714
|
-
}, _typeof(obj);
|
|
3715
|
-
}
|
|
3716
|
-
var objectAssign = require_object_assign();
|
|
3717
|
-
var isPlainObject = require_is_plain_object();
|
|
3718
|
-
var serializeTypes = ["boolean", "string", "number"];
|
|
3719
|
-
var isBuffer = function isBuffer2(obj) {
|
|
3720
|
-
return !!obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
|
|
3721
|
-
};
|
|
3722
|
-
module.exports = function() {
|
|
3723
|
-
return {
|
|
3724
|
-
processOptions: function processOptions(options) {
|
|
3725
|
-
var body = options.body;
|
|
3726
|
-
if (!body) {
|
|
3727
|
-
return options;
|
|
3728
|
-
}
|
|
3729
|
-
var isStream = typeof body.pipe === "function";
|
|
3730
|
-
var shouldSerialize = !isStream && !isBuffer(body) && (serializeTypes.indexOf(_typeof(body)) !== -1 || Array.isArray(body) || isPlainObject(body));
|
|
3731
|
-
if (!shouldSerialize) {
|
|
3732
|
-
return options;
|
|
3733
|
-
}
|
|
3734
|
-
return objectAssign({}, options, {
|
|
3735
|
-
body: JSON.stringify(options.body),
|
|
3736
|
-
headers: objectAssign({}, options.headers, {
|
|
3737
|
-
"Content-Type": "application/json"
|
|
3738
|
-
})
|
|
3739
|
-
});
|
|
673
|
+
// src/http/queryString.js
|
|
674
|
+
var require_queryString = __commonJS({
|
|
675
|
+
"src/http/queryString.js"(exports, module) {
|
|
676
|
+
module.exports = (params) => {
|
|
677
|
+
const qs = [];
|
|
678
|
+
for (const key in params) {
|
|
679
|
+
if (params.hasOwnProperty(key)) {
|
|
680
|
+
qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`);
|
|
3740
681
|
}
|
|
3741
|
-
}
|
|
682
|
+
}
|
|
683
|
+
return qs.length > 0 ? `?${qs.join("&")}` : "";
|
|
3742
684
|
};
|
|
3743
685
|
}
|
|
3744
686
|
});
|
|
3745
687
|
|
|
3746
|
-
//
|
|
3747
|
-
var
|
|
3748
|
-
"
|
|
3749
|
-
|
|
3750
|
-
var
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
return objectAssign({}, response, {
|
|
3760
|
-
body: tryParse(response.body)
|
|
3761
|
-
});
|
|
3762
|
-
},
|
|
3763
|
-
processOptions: function processOptions(options) {
|
|
3764
|
-
return objectAssign({}, options, {
|
|
3765
|
-
headers: objectAssign({
|
|
3766
|
-
Accept: "application/json"
|
|
3767
|
-
}, options.headers)
|
|
3768
|
-
});
|
|
3769
|
-
}
|
|
3770
|
-
};
|
|
3771
|
-
};
|
|
3772
|
-
function tryParse(body) {
|
|
3773
|
-
try {
|
|
3774
|
-
return JSON.parse(body);
|
|
3775
|
-
} catch (err) {
|
|
3776
|
-
err.message = "Failed to parsed response body as JSON: ".concat(err.message);
|
|
3777
|
-
throw err;
|
|
688
|
+
// src/assets/assetsClient.js
|
|
689
|
+
var require_assetsClient = __commonJS({
|
|
690
|
+
"src/assets/assetsClient.js"(exports, module) {
|
|
691
|
+
var assign = __require("object-assign");
|
|
692
|
+
var { map, filter } = require_observable();
|
|
693
|
+
var queryString = require_queryString();
|
|
694
|
+
var validators = require_validators();
|
|
695
|
+
function AssetsClient(client) {
|
|
696
|
+
this.client = client;
|
|
697
|
+
}
|
|
698
|
+
function optionsFromFile(opts, file) {
|
|
699
|
+
if (typeof window === "undefined" || !(file instanceof window.File)) {
|
|
700
|
+
return opts;
|
|
3778
701
|
}
|
|
702
|
+
return assign(
|
|
703
|
+
{
|
|
704
|
+
filename: opts.preserveFilename === false ? void 0 : file.name,
|
|
705
|
+
contentType: file.type
|
|
706
|
+
},
|
|
707
|
+
opts
|
|
708
|
+
);
|
|
3779
709
|
}
|
|
3780
|
-
|
|
3781
|
-
})
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
"use strict";
|
|
3787
|
-
module.exports = function() {
|
|
3788
|
-
return {
|
|
3789
|
-
onRequest: function onRequest(evt) {
|
|
3790
|
-
if (evt.adapter !== "xhr") {
|
|
3791
|
-
return;
|
|
3792
|
-
}
|
|
3793
|
-
var xhr = evt.request;
|
|
3794
|
-
var context = evt.context;
|
|
3795
|
-
if ("upload" in xhr && "onprogress" in xhr.upload) {
|
|
3796
|
-
xhr.upload.onprogress = handleProgress("upload");
|
|
3797
|
-
}
|
|
3798
|
-
if ("onprogress" in xhr) {
|
|
3799
|
-
xhr.onprogress = handleProgress("download");
|
|
3800
|
-
}
|
|
3801
|
-
function handleProgress(stage) {
|
|
3802
|
-
return function(event) {
|
|
3803
|
-
var percent = event.lengthComputable ? event.loaded / event.total * 100 : -1;
|
|
3804
|
-
context.channels.progress.publish({
|
|
3805
|
-
stage,
|
|
3806
|
-
percent,
|
|
3807
|
-
total: event.total,
|
|
3808
|
-
loaded: event.loaded,
|
|
3809
|
-
lengthComputable: event.lengthComputable
|
|
3810
|
-
});
|
|
3811
|
-
};
|
|
3812
|
-
}
|
|
710
|
+
assign(AssetsClient.prototype, {
|
|
711
|
+
upload(assetType, body, opts = {}) {
|
|
712
|
+
validators.validateAssetType(assetType);
|
|
713
|
+
let meta = opts.extract || void 0;
|
|
714
|
+
if (meta && !meta.length) {
|
|
715
|
+
meta = ["none"];
|
|
3813
716
|
}
|
|
3814
|
-
|
|
3815
|
-
|
|
717
|
+
const dataset = validators.hasDataset(this.client.clientConfig);
|
|
718
|
+
const assetEndpoint = assetType === "image" ? "images" : "files";
|
|
719
|
+
const options = optionsFromFile(opts, body);
|
|
720
|
+
const { tag, label, title, description, creditLine, filename, source } = options;
|
|
721
|
+
const query = {
|
|
722
|
+
label,
|
|
723
|
+
title,
|
|
724
|
+
description,
|
|
725
|
+
filename,
|
|
726
|
+
meta,
|
|
727
|
+
creditLine
|
|
728
|
+
};
|
|
729
|
+
if (source) {
|
|
730
|
+
query.sourceId = source.id;
|
|
731
|
+
query.sourceName = source.name;
|
|
732
|
+
query.sourceUrl = source.url;
|
|
733
|
+
}
|
|
734
|
+
const observable = this.client._requestObservable({
|
|
735
|
+
tag,
|
|
736
|
+
method: "POST",
|
|
737
|
+
timeout: options.timeout || 0,
|
|
738
|
+
uri: `/assets/${assetEndpoint}/${dataset}`,
|
|
739
|
+
headers: options.contentType ? { "Content-Type": options.contentType } : {},
|
|
740
|
+
query,
|
|
741
|
+
body
|
|
742
|
+
});
|
|
743
|
+
return this.client.isPromiseAPI() ? observable.pipe(
|
|
744
|
+
filter((event) => event.type === "response"),
|
|
745
|
+
map((event) => event.body.document)
|
|
746
|
+
).toPromise() : observable;
|
|
747
|
+
},
|
|
748
|
+
delete(type, id) {
|
|
749
|
+
console.warn("client.assets.delete() is deprecated, please use client.delete(<document-id>)");
|
|
750
|
+
let docId = id || "";
|
|
751
|
+
if (!/^(image|file)-/.test(docId)) {
|
|
752
|
+
docId = `${type}-${docId}`;
|
|
753
|
+
} else if (type._id) {
|
|
754
|
+
docId = type._id;
|
|
755
|
+
}
|
|
756
|
+
validators.hasDataset(this.client.clientConfig);
|
|
757
|
+
return this.client.delete(docId);
|
|
758
|
+
},
|
|
759
|
+
getImageUrl(ref, query) {
|
|
760
|
+
const id = ref._ref || ref;
|
|
761
|
+
if (typeof id !== "string") {
|
|
762
|
+
throw new Error(
|
|
763
|
+
"getImageUrl() needs either an object with a _ref, or a string with an asset document ID"
|
|
764
|
+
);
|
|
765
|
+
}
|
|
766
|
+
if (!/^image-[A-Za-z0-9_]+-\d+x\d+-[a-z]{1,5}$/.test(id)) {
|
|
767
|
+
throw new Error(
|
|
768
|
+
`Unsupported asset ID "${id}". URL generation only works for auto-generated IDs.`
|
|
769
|
+
);
|
|
770
|
+
}
|
|
771
|
+
const [, assetId, size, format] = id.split("-");
|
|
772
|
+
validators.hasDataset(this.client.clientConfig);
|
|
773
|
+
const { projectId, dataset } = this.client.clientConfig;
|
|
774
|
+
const qs = query ? queryString(query) : "";
|
|
775
|
+
return `https://cdn.sanity.io/images/${projectId}/${dataset}/${assetId}-${size}.${format}${qs}`;
|
|
776
|
+
}
|
|
777
|
+
});
|
|
778
|
+
module.exports = AssetsClient;
|
|
3816
779
|
}
|
|
3817
780
|
});
|
|
3818
781
|
|
|
3819
|
-
//
|
|
3820
|
-
var
|
|
3821
|
-
"
|
|
3822
|
-
|
|
3823
|
-
|
|
782
|
+
// src/users/usersClient.js
|
|
783
|
+
var require_usersClient = __commonJS({
|
|
784
|
+
"src/users/usersClient.js"(exports, module) {
|
|
785
|
+
var assign = __require("object-assign");
|
|
786
|
+
function UsersClient(client) {
|
|
787
|
+
this.client = client;
|
|
788
|
+
}
|
|
789
|
+
assign(UsersClient.prototype, {
|
|
790
|
+
getById(id) {
|
|
791
|
+
return this.client.request({ uri: `/users/${id}` });
|
|
792
|
+
}
|
|
793
|
+
});
|
|
794
|
+
module.exports = UsersClient;
|
|
3824
795
|
}
|
|
3825
796
|
});
|
|
3826
797
|
|
|
3827
|
-
//
|
|
3828
|
-
var
|
|
3829
|
-
"
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
var captureStackTrace = Error.captureStackTrace;
|
|
3834
|
-
if (captureStackTrace === void 0) {
|
|
3835
|
-
captureStackTrace = function captureStackTrace2(error) {
|
|
3836
|
-
var container = new Error();
|
|
3837
|
-
defineProperty(error, "stack", {
|
|
3838
|
-
configurable: true,
|
|
3839
|
-
get: function getStack() {
|
|
3840
|
-
var stack = container.stack;
|
|
3841
|
-
defineProperty(this, "stack", {
|
|
3842
|
-
configurable: true,
|
|
3843
|
-
value: stack,
|
|
3844
|
-
writable: true
|
|
3845
|
-
});
|
|
3846
|
-
return stack;
|
|
3847
|
-
},
|
|
3848
|
-
set: function setStack(stack) {
|
|
3849
|
-
defineProperty(error, "stack", {
|
|
3850
|
-
configurable: true,
|
|
3851
|
-
value: stack,
|
|
3852
|
-
writable: true
|
|
3853
|
-
});
|
|
3854
|
-
}
|
|
3855
|
-
});
|
|
3856
|
-
};
|
|
3857
|
-
}
|
|
3858
|
-
function BaseError(message) {
|
|
3859
|
-
if (message !== void 0) {
|
|
3860
|
-
defineProperty(this, "message", {
|
|
3861
|
-
configurable: true,
|
|
3862
|
-
value: message,
|
|
3863
|
-
writable: true
|
|
3864
|
-
});
|
|
3865
|
-
}
|
|
3866
|
-
var cname = this.constructor.name;
|
|
3867
|
-
if (cname !== void 0 && cname !== this.name) {
|
|
3868
|
-
defineProperty(this, "name", {
|
|
3869
|
-
configurable: true,
|
|
3870
|
-
value: cname,
|
|
3871
|
-
writable: true
|
|
3872
|
-
});
|
|
3873
|
-
}
|
|
3874
|
-
captureStackTrace(this, this.constructor);
|
|
798
|
+
// src/auth/authClient.js
|
|
799
|
+
var require_authClient = __commonJS({
|
|
800
|
+
"src/auth/authClient.js"(exports, module) {
|
|
801
|
+
var assign = __require("object-assign");
|
|
802
|
+
function AuthClient(client) {
|
|
803
|
+
this.client = client;
|
|
3875
804
|
}
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
805
|
+
assign(AuthClient.prototype, {
|
|
806
|
+
getLoginProviders() {
|
|
807
|
+
return this.client.request({ uri: "/auth/providers" });
|
|
808
|
+
},
|
|
809
|
+
logout() {
|
|
810
|
+
return this.client.request({ uri: "/auth/logout", method: "POST" });
|
|
3881
811
|
}
|
|
3882
812
|
});
|
|
3883
|
-
|
|
3884
|
-
function setFunctionName2(fn, name) {
|
|
3885
|
-
return defineProperty(fn, "name", {
|
|
3886
|
-
configurable: true,
|
|
3887
|
-
value: name
|
|
3888
|
-
});
|
|
3889
|
-
}
|
|
3890
|
-
try {
|
|
3891
|
-
var f = function() {
|
|
3892
|
-
};
|
|
3893
|
-
setFunctionName2(f, "foo");
|
|
3894
|
-
if (f.name === "foo") {
|
|
3895
|
-
return setFunctionName2;
|
|
3896
|
-
}
|
|
3897
|
-
} catch (_) {
|
|
3898
|
-
}
|
|
3899
|
-
}();
|
|
3900
|
-
function makeError(constructor, super_) {
|
|
3901
|
-
if (super_ == null || super_ === Error) {
|
|
3902
|
-
super_ = BaseError;
|
|
3903
|
-
} else if (typeof super_ !== "function") {
|
|
3904
|
-
throw new TypeError("super_ should be a function");
|
|
3905
|
-
}
|
|
3906
|
-
var name;
|
|
3907
|
-
if (typeof constructor === "string") {
|
|
3908
|
-
name = constructor;
|
|
3909
|
-
constructor = construct !== void 0 ? function() {
|
|
3910
|
-
return construct(super_, arguments, this.constructor);
|
|
3911
|
-
} : function() {
|
|
3912
|
-
super_.apply(this, arguments);
|
|
3913
|
-
};
|
|
3914
|
-
if (setFunctionName !== void 0) {
|
|
3915
|
-
setFunctionName(constructor, name);
|
|
3916
|
-
name = void 0;
|
|
3917
|
-
}
|
|
3918
|
-
} else if (typeof constructor !== "function") {
|
|
3919
|
-
throw new TypeError("constructor should be either a string or a function");
|
|
3920
|
-
}
|
|
3921
|
-
constructor.super_ = constructor["super"] = super_;
|
|
3922
|
-
var properties = {
|
|
3923
|
-
constructor: {
|
|
3924
|
-
configurable: true,
|
|
3925
|
-
value: constructor,
|
|
3926
|
-
writable: true
|
|
3927
|
-
}
|
|
3928
|
-
};
|
|
3929
|
-
if (name !== void 0) {
|
|
3930
|
-
properties.name = {
|
|
3931
|
-
configurable: true,
|
|
3932
|
-
value: name,
|
|
3933
|
-
writable: true
|
|
3934
|
-
};
|
|
3935
|
-
}
|
|
3936
|
-
constructor.prototype = Object.create(super_.prototype, properties);
|
|
3937
|
-
return constructor;
|
|
3938
|
-
}
|
|
3939
|
-
exports = module.exports = makeError;
|
|
3940
|
-
exports.BaseError = BaseError;
|
|
813
|
+
module.exports = AuthClient;
|
|
3941
814
|
}
|
|
3942
815
|
});
|
|
3943
816
|
|
|
3944
817
|
// src/http/errors.js
|
|
3945
818
|
var require_errors = __commonJS({
|
|
3946
819
|
"src/http/errors.js"(exports) {
|
|
3947
|
-
var makeError =
|
|
3948
|
-
var assign =
|
|
820
|
+
var makeError = __require("make-error");
|
|
821
|
+
var assign = __require("object-assign");
|
|
3949
822
|
function ClientError(res) {
|
|
3950
823
|
const props = extractErrorProps(res);
|
|
3951
824
|
ClientError.super.call(this, props.message);
|
|
@@ -3999,15 +872,15 @@ var require_browserMiddleware = __commonJS({
|
|
|
3999
872
|
});
|
|
4000
873
|
|
|
4001
874
|
// src/http/request.js
|
|
4002
|
-
var
|
|
875
|
+
var require_request = __commonJS({
|
|
4003
876
|
"src/http/request.js"(exports, module) {
|
|
4004
|
-
var getIt =
|
|
4005
|
-
var assign =
|
|
4006
|
-
var observable =
|
|
4007
|
-
var jsonRequest =
|
|
4008
|
-
var jsonResponse =
|
|
4009
|
-
var progress =
|
|
4010
|
-
var { Observable } =
|
|
877
|
+
var getIt = __require("get-it");
|
|
878
|
+
var assign = __require("object-assign");
|
|
879
|
+
var observable = __require("get-it/lib/middleware/observable");
|
|
880
|
+
var jsonRequest = __require("get-it/lib/middleware/jsonRequest");
|
|
881
|
+
var jsonResponse = __require("get-it/lib/middleware/jsonResponse");
|
|
882
|
+
var progress = __require("get-it/lib/middleware/progress");
|
|
883
|
+
var { Observable } = require_observable();
|
|
4011
884
|
var { ClientError, ServerError } = require_errors();
|
|
4012
885
|
var httpError = {
|
|
4013
886
|
onResponse: (res) => {
|
|
@@ -4050,7 +923,7 @@ var require_request2 = __commonJS({
|
|
|
4050
923
|
// src/http/requestOptions.js
|
|
4051
924
|
var require_requestOptions = __commonJS({
|
|
4052
925
|
"src/http/requestOptions.js"(exports, module) {
|
|
4053
|
-
var assign =
|
|
926
|
+
var assign = __require("object-assign");
|
|
4054
927
|
var projectHeader = "X-Sanity-Project-ID";
|
|
4055
928
|
module.exports = (config, overrides = {}) => {
|
|
4056
929
|
const headers = {};
|
|
@@ -4061,7 +934,9 @@ var require_requestOptions = __commonJS({
|
|
|
4061
934
|
if (!overrides.useGlobalApi && !config.useProjectHostname && config.projectId) {
|
|
4062
935
|
headers[projectHeader] = config.projectId;
|
|
4063
936
|
}
|
|
4064
|
-
const withCredentials = Boolean(
|
|
937
|
+
const withCredentials = Boolean(
|
|
938
|
+
typeof overrides.withCredentials === "undefined" ? config.token || config.withCredentials : overrides.withCredentials
|
|
939
|
+
);
|
|
4065
940
|
const timeout = typeof overrides.timeout === "undefined" ? config.timeout : overrides.timeout;
|
|
4066
941
|
return assign({}, overrides, {
|
|
4067
942
|
headers: assign({}, headers, overrides.headers || {}),
|
|
@@ -4074,17 +949,13 @@ var require_requestOptions = __commonJS({
|
|
|
4074
949
|
}
|
|
4075
950
|
});
|
|
4076
951
|
|
|
4077
|
-
//
|
|
4078
|
-
var
|
|
4079
|
-
"
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
function r(e) {
|
|
4085
|
-
return t + e;
|
|
4086
|
-
}
|
|
4087
|
-
exports.generateHelpUrl = r;
|
|
952
|
+
// src/generateHelpUrl.js
|
|
953
|
+
var require_generateHelpUrl = __commonJS({
|
|
954
|
+
"src/generateHelpUrl.js"(exports, module) {
|
|
955
|
+
var BASE_URL = "https://docs.sanity.io/help/";
|
|
956
|
+
module.exports = function generateHelpUrl(slug) {
|
|
957
|
+
return BASE_URL + slug;
|
|
958
|
+
};
|
|
4088
959
|
}
|
|
4089
960
|
});
|
|
4090
961
|
|
|
@@ -4109,7 +980,7 @@ var require_once = __commonJS({
|
|
|
4109
980
|
// src/warnings.js
|
|
4110
981
|
var require_warnings = __commonJS({
|
|
4111
982
|
"src/warnings.js"(exports) {
|
|
4112
|
-
var generateHelpUrl =
|
|
983
|
+
var generateHelpUrl = require_generateHelpUrl();
|
|
4113
984
|
var once = require_once();
|
|
4114
985
|
var createWarningPrinter = (message) => once((...args) => console.warn(message.join(" "), ...args));
|
|
4115
986
|
exports.printCdnWarning = createWarningPrinter([
|
|
@@ -4120,7 +991,9 @@ var require_warnings = __commonJS({
|
|
|
4120
991
|
]);
|
|
4121
992
|
exports.printBrowserTokenWarning = createWarningPrinter([
|
|
4122
993
|
"You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.",
|
|
4123
|
-
`See ${generateHelpUrl(
|
|
994
|
+
`See ${generateHelpUrl(
|
|
995
|
+
"js-client-browser-token"
|
|
996
|
+
)} for more information and how to hide this warning.`
|
|
4124
997
|
]);
|
|
4125
998
|
exports.printNoApiVersionSpecifiedWarning = createWarningPrinter([
|
|
4126
999
|
"Using the Sanity client without specifying an API version is deprecated.",
|
|
@@ -4130,10 +1003,10 @@ var require_warnings = __commonJS({
|
|
|
4130
1003
|
});
|
|
4131
1004
|
|
|
4132
1005
|
// src/config.js
|
|
4133
|
-
var
|
|
1006
|
+
var require_config = __commonJS({
|
|
4134
1007
|
"src/config.js"(exports) {
|
|
4135
|
-
var
|
|
4136
|
-
var
|
|
1008
|
+
var assign = __require("object-assign");
|
|
1009
|
+
var generateHelpUrl = require_generateHelpUrl();
|
|
4137
1010
|
var validate = require_validators();
|
|
4138
1011
|
var warnings = require_warnings();
|
|
4139
1012
|
var defaultCdnHost = "apicdn.sanity.io";
|
|
@@ -4209,8 +1082,8 @@ var require_config2 = __commonJS({
|
|
|
4209
1082
|
// src/sanityClient.js
|
|
4210
1083
|
var require_sanityClient = __commonJS({
|
|
4211
1084
|
"src/sanityClient.js"(exports, module) {
|
|
4212
|
-
var assign =
|
|
4213
|
-
var { Observable, map, filter } =
|
|
1085
|
+
var assign = __require("object-assign");
|
|
1086
|
+
var { Observable, map, filter } = require_observable();
|
|
4214
1087
|
var Patch = require_patch();
|
|
4215
1088
|
var Transaction = require_transaction();
|
|
4216
1089
|
var dataMethods = require_dataMethods();
|
|
@@ -4219,9 +1092,9 @@ var require_sanityClient = __commonJS({
|
|
|
4219
1092
|
var AssetsClient = require_assetsClient();
|
|
4220
1093
|
var UsersClient = require_usersClient();
|
|
4221
1094
|
var AuthClient = require_authClient();
|
|
4222
|
-
var httpRequest =
|
|
1095
|
+
var httpRequest = require_request();
|
|
4223
1096
|
var getRequestOptions = require_requestOptions();
|
|
4224
|
-
var { defaultConfig, initConfig } =
|
|
1097
|
+
var { defaultConfig, initConfig } = require_config();
|
|
4225
1098
|
var validate = require_validators();
|
|
4226
1099
|
var toPromise = (observable) => observable.toPromise();
|
|
4227
1100
|
function SanityClient(config = defaultConfig) {
|
|
@@ -4248,6 +1121,11 @@ var require_sanityClient = __commonJS({
|
|
|
4248
1121
|
if (typeof newConfig === "undefined") {
|
|
4249
1122
|
return assign({}, this.clientConfig);
|
|
4250
1123
|
}
|
|
1124
|
+
if (this.clientConfig && this.clientConfig.allowReconfigure === false) {
|
|
1125
|
+
throw new Error(
|
|
1126
|
+
"Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client"
|
|
1127
|
+
);
|
|
1128
|
+
}
|
|
4251
1129
|
if (this.observable) {
|
|
4252
1130
|
const observableConfig = assign({}, newConfig, { isPromiseAPI: false });
|
|
4253
1131
|
this.observable.config(observableConfig);
|
|
@@ -4256,7 +1134,7 @@ var require_sanityClient = __commonJS({
|
|
|
4256
1134
|
return this;
|
|
4257
1135
|
},
|
|
4258
1136
|
withConfig(newConfig) {
|
|
4259
|
-
return this.
|
|
1137
|
+
return new SanityClient({ ...this.config(), ...newConfig });
|
|
4260
1138
|
},
|
|
4261
1139
|
getUrl(uri, useCdn = false) {
|
|
4262
1140
|
const base = useCdn ? this.clientConfig.cdnUrl : this.clientConfig.url;
|
|
@@ -4273,13 +1151,21 @@ var require_sanityClient = __commonJS({
|
|
|
4273
1151
|
if (tag) {
|
|
4274
1152
|
options.query = { tag: validate.requestTag(tag), ...options.query };
|
|
4275
1153
|
}
|
|
4276
|
-
const reqOptions = getRequestOptions(
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
1154
|
+
const reqOptions = getRequestOptions(
|
|
1155
|
+
this.clientConfig,
|
|
1156
|
+
assign({}, options, {
|
|
1157
|
+
url: this.getUrl(uri, useCdn)
|
|
1158
|
+
})
|
|
1159
|
+
);
|
|
1160
|
+
return new Observable(
|
|
1161
|
+
(subscriber) => httpRequest(reqOptions, this.clientConfig.requester).subscribe(subscriber)
|
|
1162
|
+
);
|
|
4280
1163
|
},
|
|
4281
1164
|
request(options) {
|
|
4282
|
-
const observable = this._requestObservable(options).pipe(
|
|
1165
|
+
const observable = this._requestObservable(options).pipe(
|
|
1166
|
+
filter((event) => event.type === "response"),
|
|
1167
|
+
map((event) => event.body)
|
|
1168
|
+
);
|
|
4283
1169
|
return this.isPromiseAPI() ? toPromise(observable) : observable;
|
|
4284
1170
|
}
|
|
4285
1171
|
});
|
|
@@ -4292,26 +1178,4 @@ var require_sanityClient = __commonJS({
|
|
|
4292
1178
|
}
|
|
4293
1179
|
});
|
|
4294
1180
|
export default require_sanityClient();
|
|
4295
|
-
/*
|
|
4296
|
-
object-assign
|
|
4297
|
-
(c) Sindre Sorhus
|
|
4298
|
-
@license MIT
|
|
4299
|
-
*/
|
|
4300
|
-
/*!
|
|
4301
|
-
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
|
4302
|
-
*
|
|
4303
|
-
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
4304
|
-
* Released under the MIT License.
|
|
4305
|
-
*/
|
|
4306
|
-
/*!
|
|
4307
|
-
* isobject <https://github.com/jonschlinkert/isobject>
|
|
4308
|
-
*
|
|
4309
|
-
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
4310
|
-
* Released under the MIT License.
|
|
4311
|
-
*/
|
|
4312
|
-
/** @license
|
|
4313
|
-
* eventsource.js
|
|
4314
|
-
* Available under MIT License (MIT)
|
|
4315
|
-
* https://github.com/Yaffle/EventSource/
|
|
4316
|
-
*/
|
|
4317
1181
|
//# sourceMappingURL=sanityClient.browser.mjs.map
|