@crxjs/vite-plugin 2.0.0-beta.1 → 2.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.cjs +373 -2112
- package/dist/index.mjs +364 -2103
- package/package.json +16 -22
package/dist/index.cjs
CHANGED
|
@@ -7,6 +7,7 @@ var crypto = require('crypto');
|
|
|
7
7
|
var debug$2 = require('debug');
|
|
8
8
|
var v8 = require('v8');
|
|
9
9
|
var path = require('path');
|
|
10
|
+
var rxjs = require('rxjs');
|
|
10
11
|
var fsx = require('fs-extra');
|
|
11
12
|
var perf_hooks = require('perf_hooks');
|
|
12
13
|
var rollup = require('rollup');
|
|
@@ -194,1875 +195,6 @@ function defineClientValues(code, config) {
|
|
|
194
195
|
}
|
|
195
196
|
}
|
|
196
197
|
|
|
197
|
-
/******************************************************************************
|
|
198
|
-
Copyright (c) Microsoft Corporation.
|
|
199
|
-
|
|
200
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
201
|
-
purpose with or without fee is hereby granted.
|
|
202
|
-
|
|
203
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
204
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
205
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
206
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
207
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
208
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
209
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
210
|
-
***************************************************************************** */
|
|
211
|
-
/* global Reflect, Promise */
|
|
212
|
-
|
|
213
|
-
var extendStatics = function(d, b) {
|
|
214
|
-
extendStatics = Object.setPrototypeOf ||
|
|
215
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
216
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
217
|
-
return extendStatics(d, b);
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
function __extends(d, b) {
|
|
221
|
-
if (typeof b !== "function" && b !== null)
|
|
222
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
223
|
-
extendStatics(d, b);
|
|
224
|
-
function __() { this.constructor = d; }
|
|
225
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
229
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
230
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
231
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
232
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
233
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
234
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
function __generator(thisArg, body) {
|
|
239
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
240
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
241
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
242
|
-
function step(op) {
|
|
243
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
244
|
-
while (_) try {
|
|
245
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
246
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
247
|
-
switch (op[0]) {
|
|
248
|
-
case 0: case 1: t = op; break;
|
|
249
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
250
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
251
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
252
|
-
default:
|
|
253
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
254
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
255
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
256
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
257
|
-
if (t[2]) _.ops.pop();
|
|
258
|
-
_.trys.pop(); continue;
|
|
259
|
-
}
|
|
260
|
-
op = body.call(thisArg, _);
|
|
261
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
262
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
function __values(o) {
|
|
267
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
268
|
-
if (m) return m.call(o);
|
|
269
|
-
if (o && typeof o.length === "number") return {
|
|
270
|
-
next: function () {
|
|
271
|
-
if (o && i >= o.length) o = void 0;
|
|
272
|
-
return { value: o && o[i++], done: !o };
|
|
273
|
-
}
|
|
274
|
-
};
|
|
275
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
function __read(o, n) {
|
|
279
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
280
|
-
if (!m) return o;
|
|
281
|
-
var i = m.call(o), r, ar = [], e;
|
|
282
|
-
try {
|
|
283
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
284
|
-
}
|
|
285
|
-
catch (error) { e = { error: error }; }
|
|
286
|
-
finally {
|
|
287
|
-
try {
|
|
288
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
289
|
-
}
|
|
290
|
-
finally { if (e) throw e.error; }
|
|
291
|
-
}
|
|
292
|
-
return ar;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
function __spreadArray(to, from, pack) {
|
|
296
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
297
|
-
if (ar || !(i in from)) {
|
|
298
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
299
|
-
ar[i] = from[i];
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
function __await(v) {
|
|
306
|
-
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
310
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
311
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
312
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
313
|
-
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
314
|
-
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
315
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
316
|
-
function fulfill(value) { resume("next", value); }
|
|
317
|
-
function reject(value) { resume("throw", value); }
|
|
318
|
-
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
function __asyncValues(o) {
|
|
322
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
323
|
-
var m = o[Symbol.asyncIterator], i;
|
|
324
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
325
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
326
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
function isFunction(value) {
|
|
330
|
-
return typeof value === 'function';
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
function createErrorClass(createImpl) {
|
|
334
|
-
var _super = function (instance) {
|
|
335
|
-
Error.call(instance);
|
|
336
|
-
instance.stack = new Error().stack;
|
|
337
|
-
};
|
|
338
|
-
var ctorFunc = createImpl(_super);
|
|
339
|
-
ctorFunc.prototype = Object.create(Error.prototype);
|
|
340
|
-
ctorFunc.prototype.constructor = ctorFunc;
|
|
341
|
-
return ctorFunc;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
var UnsubscriptionError = createErrorClass(function (_super) {
|
|
345
|
-
return function UnsubscriptionErrorImpl(errors) {
|
|
346
|
-
_super(this);
|
|
347
|
-
this.message = errors
|
|
348
|
-
? errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n ')
|
|
349
|
-
: '';
|
|
350
|
-
this.name = 'UnsubscriptionError';
|
|
351
|
-
this.errors = errors;
|
|
352
|
-
};
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
function arrRemove(arr, item) {
|
|
356
|
-
if (arr) {
|
|
357
|
-
var index = arr.indexOf(item);
|
|
358
|
-
0 <= index && arr.splice(index, 1);
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
var Subscription = (function () {
|
|
363
|
-
function Subscription(initialTeardown) {
|
|
364
|
-
this.initialTeardown = initialTeardown;
|
|
365
|
-
this.closed = false;
|
|
366
|
-
this._parentage = null;
|
|
367
|
-
this._finalizers = null;
|
|
368
|
-
}
|
|
369
|
-
Subscription.prototype.unsubscribe = function () {
|
|
370
|
-
var e_1, _a, e_2, _b;
|
|
371
|
-
var errors;
|
|
372
|
-
if (!this.closed) {
|
|
373
|
-
this.closed = true;
|
|
374
|
-
var _parentage = this._parentage;
|
|
375
|
-
if (_parentage) {
|
|
376
|
-
this._parentage = null;
|
|
377
|
-
if (Array.isArray(_parentage)) {
|
|
378
|
-
try {
|
|
379
|
-
for (var _parentage_1 = __values(_parentage), _parentage_1_1 = _parentage_1.next(); !_parentage_1_1.done; _parentage_1_1 = _parentage_1.next()) {
|
|
380
|
-
var parent_1 = _parentage_1_1.value;
|
|
381
|
-
parent_1.remove(this);
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
385
|
-
finally {
|
|
386
|
-
try {
|
|
387
|
-
if (_parentage_1_1 && !_parentage_1_1.done && (_a = _parentage_1.return)) _a.call(_parentage_1);
|
|
388
|
-
}
|
|
389
|
-
finally { if (e_1) throw e_1.error; }
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
else {
|
|
393
|
-
_parentage.remove(this);
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
var initialFinalizer = this.initialTeardown;
|
|
397
|
-
if (isFunction(initialFinalizer)) {
|
|
398
|
-
try {
|
|
399
|
-
initialFinalizer();
|
|
400
|
-
}
|
|
401
|
-
catch (e) {
|
|
402
|
-
errors = e instanceof UnsubscriptionError ? e.errors : [e];
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
var _finalizers = this._finalizers;
|
|
406
|
-
if (_finalizers) {
|
|
407
|
-
this._finalizers = null;
|
|
408
|
-
try {
|
|
409
|
-
for (var _finalizers_1 = __values(_finalizers), _finalizers_1_1 = _finalizers_1.next(); !_finalizers_1_1.done; _finalizers_1_1 = _finalizers_1.next()) {
|
|
410
|
-
var finalizer = _finalizers_1_1.value;
|
|
411
|
-
try {
|
|
412
|
-
execFinalizer(finalizer);
|
|
413
|
-
}
|
|
414
|
-
catch (err) {
|
|
415
|
-
errors = errors !== null && errors !== void 0 ? errors : [];
|
|
416
|
-
if (err instanceof UnsubscriptionError) {
|
|
417
|
-
errors = __spreadArray(__spreadArray([], __read(errors)), __read(err.errors));
|
|
418
|
-
}
|
|
419
|
-
else {
|
|
420
|
-
errors.push(err);
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
426
|
-
finally {
|
|
427
|
-
try {
|
|
428
|
-
if (_finalizers_1_1 && !_finalizers_1_1.done && (_b = _finalizers_1.return)) _b.call(_finalizers_1);
|
|
429
|
-
}
|
|
430
|
-
finally { if (e_2) throw e_2.error; }
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
if (errors) {
|
|
434
|
-
throw new UnsubscriptionError(errors);
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
};
|
|
438
|
-
Subscription.prototype.add = function (teardown) {
|
|
439
|
-
var _a;
|
|
440
|
-
if (teardown && teardown !== this) {
|
|
441
|
-
if (this.closed) {
|
|
442
|
-
execFinalizer(teardown);
|
|
443
|
-
}
|
|
444
|
-
else {
|
|
445
|
-
if (teardown instanceof Subscription) {
|
|
446
|
-
if (teardown.closed || teardown._hasParent(this)) {
|
|
447
|
-
return;
|
|
448
|
-
}
|
|
449
|
-
teardown._addParent(this);
|
|
450
|
-
}
|
|
451
|
-
(this._finalizers = (_a = this._finalizers) !== null && _a !== void 0 ? _a : []).push(teardown);
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
};
|
|
455
|
-
Subscription.prototype._hasParent = function (parent) {
|
|
456
|
-
var _parentage = this._parentage;
|
|
457
|
-
return _parentage === parent || (Array.isArray(_parentage) && _parentage.includes(parent));
|
|
458
|
-
};
|
|
459
|
-
Subscription.prototype._addParent = function (parent) {
|
|
460
|
-
var _parentage = this._parentage;
|
|
461
|
-
this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent;
|
|
462
|
-
};
|
|
463
|
-
Subscription.prototype._removeParent = function (parent) {
|
|
464
|
-
var _parentage = this._parentage;
|
|
465
|
-
if (_parentage === parent) {
|
|
466
|
-
this._parentage = null;
|
|
467
|
-
}
|
|
468
|
-
else if (Array.isArray(_parentage)) {
|
|
469
|
-
arrRemove(_parentage, parent);
|
|
470
|
-
}
|
|
471
|
-
};
|
|
472
|
-
Subscription.prototype.remove = function (teardown) {
|
|
473
|
-
var _finalizers = this._finalizers;
|
|
474
|
-
_finalizers && arrRemove(_finalizers, teardown);
|
|
475
|
-
if (teardown instanceof Subscription) {
|
|
476
|
-
teardown._removeParent(this);
|
|
477
|
-
}
|
|
478
|
-
};
|
|
479
|
-
Subscription.EMPTY = (function () {
|
|
480
|
-
var empty = new Subscription();
|
|
481
|
-
empty.closed = true;
|
|
482
|
-
return empty;
|
|
483
|
-
})();
|
|
484
|
-
return Subscription;
|
|
485
|
-
}());
|
|
486
|
-
var EMPTY_SUBSCRIPTION = Subscription.EMPTY;
|
|
487
|
-
function isSubscription(value) {
|
|
488
|
-
return (value instanceof Subscription ||
|
|
489
|
-
(value && 'closed' in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe)));
|
|
490
|
-
}
|
|
491
|
-
function execFinalizer(finalizer) {
|
|
492
|
-
if (isFunction(finalizer)) {
|
|
493
|
-
finalizer();
|
|
494
|
-
}
|
|
495
|
-
else {
|
|
496
|
-
finalizer.unsubscribe();
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
var config = {
|
|
501
|
-
onUnhandledError: null,
|
|
502
|
-
onStoppedNotification: null,
|
|
503
|
-
Promise: undefined,
|
|
504
|
-
useDeprecatedSynchronousErrorHandling: false,
|
|
505
|
-
useDeprecatedNextContext: false,
|
|
506
|
-
};
|
|
507
|
-
|
|
508
|
-
var timeoutProvider = {
|
|
509
|
-
setTimeout: function (handler, timeout) {
|
|
510
|
-
var args = [];
|
|
511
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
512
|
-
args[_i - 2] = arguments[_i];
|
|
513
|
-
}
|
|
514
|
-
var delegate = timeoutProvider.delegate;
|
|
515
|
-
if (delegate === null || delegate === void 0 ? void 0 : delegate.setTimeout) {
|
|
516
|
-
return delegate.setTimeout.apply(delegate, __spreadArray([handler, timeout], __read(args)));
|
|
517
|
-
}
|
|
518
|
-
return setTimeout.apply(void 0, __spreadArray([handler, timeout], __read(args)));
|
|
519
|
-
},
|
|
520
|
-
clearTimeout: function (handle) {
|
|
521
|
-
var delegate = timeoutProvider.delegate;
|
|
522
|
-
return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearTimeout) || clearTimeout)(handle);
|
|
523
|
-
},
|
|
524
|
-
delegate: undefined,
|
|
525
|
-
};
|
|
526
|
-
|
|
527
|
-
function reportUnhandledError(err) {
|
|
528
|
-
timeoutProvider.setTimeout(function () {
|
|
529
|
-
{
|
|
530
|
-
throw err;
|
|
531
|
-
}
|
|
532
|
-
});
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
function noop() { }
|
|
536
|
-
|
|
537
|
-
var COMPLETE_NOTIFICATION = (function () { return createNotification('C', undefined, undefined); })();
|
|
538
|
-
function errorNotification(error) {
|
|
539
|
-
return createNotification('E', undefined, error);
|
|
540
|
-
}
|
|
541
|
-
function nextNotification(value) {
|
|
542
|
-
return createNotification('N', value, undefined);
|
|
543
|
-
}
|
|
544
|
-
function createNotification(kind, value, error) {
|
|
545
|
-
return {
|
|
546
|
-
kind: kind,
|
|
547
|
-
value: value,
|
|
548
|
-
error: error,
|
|
549
|
-
};
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
var context = null;
|
|
553
|
-
function errorContext(cb) {
|
|
554
|
-
if (config.useDeprecatedSynchronousErrorHandling) {
|
|
555
|
-
var isRoot = !context;
|
|
556
|
-
if (isRoot) {
|
|
557
|
-
context = { errorThrown: false, error: null };
|
|
558
|
-
}
|
|
559
|
-
cb();
|
|
560
|
-
if (isRoot) {
|
|
561
|
-
var _a = context, errorThrown = _a.errorThrown, error = _a.error;
|
|
562
|
-
context = null;
|
|
563
|
-
if (errorThrown) {
|
|
564
|
-
throw error;
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
else {
|
|
569
|
-
cb();
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
var Subscriber = (function (_super) {
|
|
574
|
-
__extends(Subscriber, _super);
|
|
575
|
-
function Subscriber(destination) {
|
|
576
|
-
var _this = _super.call(this) || this;
|
|
577
|
-
_this.isStopped = false;
|
|
578
|
-
if (destination) {
|
|
579
|
-
_this.destination = destination;
|
|
580
|
-
if (isSubscription(destination)) {
|
|
581
|
-
destination.add(_this);
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
else {
|
|
585
|
-
_this.destination = EMPTY_OBSERVER;
|
|
586
|
-
}
|
|
587
|
-
return _this;
|
|
588
|
-
}
|
|
589
|
-
Subscriber.create = function (next, error, complete) {
|
|
590
|
-
return new SafeSubscriber(next, error, complete);
|
|
591
|
-
};
|
|
592
|
-
Subscriber.prototype.next = function (value) {
|
|
593
|
-
if (this.isStopped) {
|
|
594
|
-
handleStoppedNotification(nextNotification(value), this);
|
|
595
|
-
}
|
|
596
|
-
else {
|
|
597
|
-
this._next(value);
|
|
598
|
-
}
|
|
599
|
-
};
|
|
600
|
-
Subscriber.prototype.error = function (err) {
|
|
601
|
-
if (this.isStopped) {
|
|
602
|
-
handleStoppedNotification(errorNotification(err), this);
|
|
603
|
-
}
|
|
604
|
-
else {
|
|
605
|
-
this.isStopped = true;
|
|
606
|
-
this._error(err);
|
|
607
|
-
}
|
|
608
|
-
};
|
|
609
|
-
Subscriber.prototype.complete = function () {
|
|
610
|
-
if (this.isStopped) {
|
|
611
|
-
handleStoppedNotification(COMPLETE_NOTIFICATION, this);
|
|
612
|
-
}
|
|
613
|
-
else {
|
|
614
|
-
this.isStopped = true;
|
|
615
|
-
this._complete();
|
|
616
|
-
}
|
|
617
|
-
};
|
|
618
|
-
Subscriber.prototype.unsubscribe = function () {
|
|
619
|
-
if (!this.closed) {
|
|
620
|
-
this.isStopped = true;
|
|
621
|
-
_super.prototype.unsubscribe.call(this);
|
|
622
|
-
this.destination = null;
|
|
623
|
-
}
|
|
624
|
-
};
|
|
625
|
-
Subscriber.prototype._next = function (value) {
|
|
626
|
-
this.destination.next(value);
|
|
627
|
-
};
|
|
628
|
-
Subscriber.prototype._error = function (err) {
|
|
629
|
-
try {
|
|
630
|
-
this.destination.error(err);
|
|
631
|
-
}
|
|
632
|
-
finally {
|
|
633
|
-
this.unsubscribe();
|
|
634
|
-
}
|
|
635
|
-
};
|
|
636
|
-
Subscriber.prototype._complete = function () {
|
|
637
|
-
try {
|
|
638
|
-
this.destination.complete();
|
|
639
|
-
}
|
|
640
|
-
finally {
|
|
641
|
-
this.unsubscribe();
|
|
642
|
-
}
|
|
643
|
-
};
|
|
644
|
-
return Subscriber;
|
|
645
|
-
}(Subscription));
|
|
646
|
-
var _bind = Function.prototype.bind;
|
|
647
|
-
function bind(fn, thisArg) {
|
|
648
|
-
return _bind.call(fn, thisArg);
|
|
649
|
-
}
|
|
650
|
-
var ConsumerObserver = (function () {
|
|
651
|
-
function ConsumerObserver(partialObserver) {
|
|
652
|
-
this.partialObserver = partialObserver;
|
|
653
|
-
}
|
|
654
|
-
ConsumerObserver.prototype.next = function (value) {
|
|
655
|
-
var partialObserver = this.partialObserver;
|
|
656
|
-
if (partialObserver.next) {
|
|
657
|
-
try {
|
|
658
|
-
partialObserver.next(value);
|
|
659
|
-
}
|
|
660
|
-
catch (error) {
|
|
661
|
-
handleUnhandledError(error);
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
};
|
|
665
|
-
ConsumerObserver.prototype.error = function (err) {
|
|
666
|
-
var partialObserver = this.partialObserver;
|
|
667
|
-
if (partialObserver.error) {
|
|
668
|
-
try {
|
|
669
|
-
partialObserver.error(err);
|
|
670
|
-
}
|
|
671
|
-
catch (error) {
|
|
672
|
-
handleUnhandledError(error);
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
else {
|
|
676
|
-
handleUnhandledError(err);
|
|
677
|
-
}
|
|
678
|
-
};
|
|
679
|
-
ConsumerObserver.prototype.complete = function () {
|
|
680
|
-
var partialObserver = this.partialObserver;
|
|
681
|
-
if (partialObserver.complete) {
|
|
682
|
-
try {
|
|
683
|
-
partialObserver.complete();
|
|
684
|
-
}
|
|
685
|
-
catch (error) {
|
|
686
|
-
handleUnhandledError(error);
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
};
|
|
690
|
-
return ConsumerObserver;
|
|
691
|
-
}());
|
|
692
|
-
var SafeSubscriber = (function (_super) {
|
|
693
|
-
__extends(SafeSubscriber, _super);
|
|
694
|
-
function SafeSubscriber(observerOrNext, error, complete) {
|
|
695
|
-
var _this = _super.call(this) || this;
|
|
696
|
-
var partialObserver;
|
|
697
|
-
if (isFunction(observerOrNext) || !observerOrNext) {
|
|
698
|
-
partialObserver = {
|
|
699
|
-
next: observerOrNext !== null && observerOrNext !== void 0 ? observerOrNext : undefined,
|
|
700
|
-
error: error !== null && error !== void 0 ? error : undefined,
|
|
701
|
-
complete: complete !== null && complete !== void 0 ? complete : undefined,
|
|
702
|
-
};
|
|
703
|
-
}
|
|
704
|
-
else {
|
|
705
|
-
var context_1;
|
|
706
|
-
if (_this && config.useDeprecatedNextContext) {
|
|
707
|
-
context_1 = Object.create(observerOrNext);
|
|
708
|
-
context_1.unsubscribe = function () { return _this.unsubscribe(); };
|
|
709
|
-
partialObserver = {
|
|
710
|
-
next: observerOrNext.next && bind(observerOrNext.next, context_1),
|
|
711
|
-
error: observerOrNext.error && bind(observerOrNext.error, context_1),
|
|
712
|
-
complete: observerOrNext.complete && bind(observerOrNext.complete, context_1),
|
|
713
|
-
};
|
|
714
|
-
}
|
|
715
|
-
else {
|
|
716
|
-
partialObserver = observerOrNext;
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
_this.destination = new ConsumerObserver(partialObserver);
|
|
720
|
-
return _this;
|
|
721
|
-
}
|
|
722
|
-
return SafeSubscriber;
|
|
723
|
-
}(Subscriber));
|
|
724
|
-
function handleUnhandledError(error) {
|
|
725
|
-
{
|
|
726
|
-
reportUnhandledError(error);
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
function defaultErrorHandler(err) {
|
|
730
|
-
throw err;
|
|
731
|
-
}
|
|
732
|
-
function handleStoppedNotification(notification, subscriber) {
|
|
733
|
-
var onStoppedNotification = config.onStoppedNotification;
|
|
734
|
-
onStoppedNotification && timeoutProvider.setTimeout(function () { return onStoppedNotification(notification, subscriber); });
|
|
735
|
-
}
|
|
736
|
-
var EMPTY_OBSERVER = {
|
|
737
|
-
closed: true,
|
|
738
|
-
next: noop,
|
|
739
|
-
error: defaultErrorHandler,
|
|
740
|
-
complete: noop,
|
|
741
|
-
};
|
|
742
|
-
|
|
743
|
-
var observable = (function () { return (typeof Symbol === 'function' && Symbol.observable) || '@@observable'; })();
|
|
744
|
-
|
|
745
|
-
function identity(x) {
|
|
746
|
-
return x;
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
function pipeFromArray(fns) {
|
|
750
|
-
if (fns.length === 0) {
|
|
751
|
-
return identity;
|
|
752
|
-
}
|
|
753
|
-
if (fns.length === 1) {
|
|
754
|
-
return fns[0];
|
|
755
|
-
}
|
|
756
|
-
return function piped(input) {
|
|
757
|
-
return fns.reduce(function (prev, fn) { return fn(prev); }, input);
|
|
758
|
-
};
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
var Observable = (function () {
|
|
762
|
-
function Observable(subscribe) {
|
|
763
|
-
if (subscribe) {
|
|
764
|
-
this._subscribe = subscribe;
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
Observable.prototype.lift = function (operator) {
|
|
768
|
-
var observable = new Observable();
|
|
769
|
-
observable.source = this;
|
|
770
|
-
observable.operator = operator;
|
|
771
|
-
return observable;
|
|
772
|
-
};
|
|
773
|
-
Observable.prototype.subscribe = function (observerOrNext, error, complete) {
|
|
774
|
-
var _this = this;
|
|
775
|
-
var subscriber = isSubscriber(observerOrNext) ? observerOrNext : new SafeSubscriber(observerOrNext, error, complete);
|
|
776
|
-
errorContext(function () {
|
|
777
|
-
var _a = _this, operator = _a.operator, source = _a.source;
|
|
778
|
-
subscriber.add(operator
|
|
779
|
-
?
|
|
780
|
-
operator.call(subscriber, source)
|
|
781
|
-
: source
|
|
782
|
-
?
|
|
783
|
-
_this._subscribe(subscriber)
|
|
784
|
-
:
|
|
785
|
-
_this._trySubscribe(subscriber));
|
|
786
|
-
});
|
|
787
|
-
return subscriber;
|
|
788
|
-
};
|
|
789
|
-
Observable.prototype._trySubscribe = function (sink) {
|
|
790
|
-
try {
|
|
791
|
-
return this._subscribe(sink);
|
|
792
|
-
}
|
|
793
|
-
catch (err) {
|
|
794
|
-
sink.error(err);
|
|
795
|
-
}
|
|
796
|
-
};
|
|
797
|
-
Observable.prototype.forEach = function (next, promiseCtor) {
|
|
798
|
-
var _this = this;
|
|
799
|
-
promiseCtor = getPromiseCtor(promiseCtor);
|
|
800
|
-
return new promiseCtor(function (resolve, reject) {
|
|
801
|
-
var subscriber = new SafeSubscriber({
|
|
802
|
-
next: function (value) {
|
|
803
|
-
try {
|
|
804
|
-
next(value);
|
|
805
|
-
}
|
|
806
|
-
catch (err) {
|
|
807
|
-
reject(err);
|
|
808
|
-
subscriber.unsubscribe();
|
|
809
|
-
}
|
|
810
|
-
},
|
|
811
|
-
error: reject,
|
|
812
|
-
complete: resolve,
|
|
813
|
-
});
|
|
814
|
-
_this.subscribe(subscriber);
|
|
815
|
-
});
|
|
816
|
-
};
|
|
817
|
-
Observable.prototype._subscribe = function (subscriber) {
|
|
818
|
-
var _a;
|
|
819
|
-
return (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber);
|
|
820
|
-
};
|
|
821
|
-
Observable.prototype[observable] = function () {
|
|
822
|
-
return this;
|
|
823
|
-
};
|
|
824
|
-
Observable.prototype.pipe = function () {
|
|
825
|
-
var operations = [];
|
|
826
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
827
|
-
operations[_i] = arguments[_i];
|
|
828
|
-
}
|
|
829
|
-
return pipeFromArray(operations)(this);
|
|
830
|
-
};
|
|
831
|
-
Observable.prototype.toPromise = function (promiseCtor) {
|
|
832
|
-
var _this = this;
|
|
833
|
-
promiseCtor = getPromiseCtor(promiseCtor);
|
|
834
|
-
return new promiseCtor(function (resolve, reject) {
|
|
835
|
-
var value;
|
|
836
|
-
_this.subscribe(function (x) { return (value = x); }, function (err) { return reject(err); }, function () { return resolve(value); });
|
|
837
|
-
});
|
|
838
|
-
};
|
|
839
|
-
Observable.create = function (subscribe) {
|
|
840
|
-
return new Observable(subscribe);
|
|
841
|
-
};
|
|
842
|
-
return Observable;
|
|
843
|
-
}());
|
|
844
|
-
function getPromiseCtor(promiseCtor) {
|
|
845
|
-
var _a;
|
|
846
|
-
return (_a = promiseCtor !== null && promiseCtor !== void 0 ? promiseCtor : config.Promise) !== null && _a !== void 0 ? _a : Promise;
|
|
847
|
-
}
|
|
848
|
-
function isObserver(value) {
|
|
849
|
-
return value && isFunction(value.next) && isFunction(value.error) && isFunction(value.complete);
|
|
850
|
-
}
|
|
851
|
-
function isSubscriber(value) {
|
|
852
|
-
return (value && value instanceof Subscriber) || (isObserver(value) && isSubscription(value));
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
function hasLift(source) {
|
|
856
|
-
return isFunction(source === null || source === void 0 ? void 0 : source.lift);
|
|
857
|
-
}
|
|
858
|
-
function operate(init) {
|
|
859
|
-
return function (source) {
|
|
860
|
-
if (hasLift(source)) {
|
|
861
|
-
return source.lift(function (liftedSource) {
|
|
862
|
-
try {
|
|
863
|
-
return init(liftedSource, this);
|
|
864
|
-
}
|
|
865
|
-
catch (err) {
|
|
866
|
-
this.error(err);
|
|
867
|
-
}
|
|
868
|
-
});
|
|
869
|
-
}
|
|
870
|
-
throw new TypeError('Unable to lift unknown Observable type');
|
|
871
|
-
};
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
function createOperatorSubscriber(destination, onNext, onComplete, onError, onFinalize) {
|
|
875
|
-
return new OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize);
|
|
876
|
-
}
|
|
877
|
-
var OperatorSubscriber = (function (_super) {
|
|
878
|
-
__extends(OperatorSubscriber, _super);
|
|
879
|
-
function OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize, shouldUnsubscribe) {
|
|
880
|
-
var _this = _super.call(this, destination) || this;
|
|
881
|
-
_this.onFinalize = onFinalize;
|
|
882
|
-
_this.shouldUnsubscribe = shouldUnsubscribe;
|
|
883
|
-
_this._next = onNext
|
|
884
|
-
? function (value) {
|
|
885
|
-
try {
|
|
886
|
-
onNext(value);
|
|
887
|
-
}
|
|
888
|
-
catch (err) {
|
|
889
|
-
destination.error(err);
|
|
890
|
-
}
|
|
891
|
-
}
|
|
892
|
-
: _super.prototype._next;
|
|
893
|
-
_this._error = onError
|
|
894
|
-
? function (err) {
|
|
895
|
-
try {
|
|
896
|
-
onError(err);
|
|
897
|
-
}
|
|
898
|
-
catch (err) {
|
|
899
|
-
destination.error(err);
|
|
900
|
-
}
|
|
901
|
-
finally {
|
|
902
|
-
this.unsubscribe();
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
: _super.prototype._error;
|
|
906
|
-
_this._complete = onComplete
|
|
907
|
-
? function () {
|
|
908
|
-
try {
|
|
909
|
-
onComplete();
|
|
910
|
-
}
|
|
911
|
-
catch (err) {
|
|
912
|
-
destination.error(err);
|
|
913
|
-
}
|
|
914
|
-
finally {
|
|
915
|
-
this.unsubscribe();
|
|
916
|
-
}
|
|
917
|
-
}
|
|
918
|
-
: _super.prototype._complete;
|
|
919
|
-
return _this;
|
|
920
|
-
}
|
|
921
|
-
OperatorSubscriber.prototype.unsubscribe = function () {
|
|
922
|
-
var _a;
|
|
923
|
-
if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {
|
|
924
|
-
var closed_1 = this.closed;
|
|
925
|
-
_super.prototype.unsubscribe.call(this);
|
|
926
|
-
!closed_1 && ((_a = this.onFinalize) === null || _a === void 0 ? void 0 : _a.call(this));
|
|
927
|
-
}
|
|
928
|
-
};
|
|
929
|
-
return OperatorSubscriber;
|
|
930
|
-
}(Subscriber));
|
|
931
|
-
|
|
932
|
-
var ObjectUnsubscribedError = createErrorClass(function (_super) {
|
|
933
|
-
return function ObjectUnsubscribedErrorImpl() {
|
|
934
|
-
_super(this);
|
|
935
|
-
this.name = 'ObjectUnsubscribedError';
|
|
936
|
-
this.message = 'object unsubscribed';
|
|
937
|
-
};
|
|
938
|
-
});
|
|
939
|
-
|
|
940
|
-
var Subject = (function (_super) {
|
|
941
|
-
__extends(Subject, _super);
|
|
942
|
-
function Subject() {
|
|
943
|
-
var _this = _super.call(this) || this;
|
|
944
|
-
_this.closed = false;
|
|
945
|
-
_this.currentObservers = null;
|
|
946
|
-
_this.observers = [];
|
|
947
|
-
_this.isStopped = false;
|
|
948
|
-
_this.hasError = false;
|
|
949
|
-
_this.thrownError = null;
|
|
950
|
-
return _this;
|
|
951
|
-
}
|
|
952
|
-
Subject.prototype.lift = function (operator) {
|
|
953
|
-
var subject = new AnonymousSubject(this, this);
|
|
954
|
-
subject.operator = operator;
|
|
955
|
-
return subject;
|
|
956
|
-
};
|
|
957
|
-
Subject.prototype._throwIfClosed = function () {
|
|
958
|
-
if (this.closed) {
|
|
959
|
-
throw new ObjectUnsubscribedError();
|
|
960
|
-
}
|
|
961
|
-
};
|
|
962
|
-
Subject.prototype.next = function (value) {
|
|
963
|
-
var _this = this;
|
|
964
|
-
errorContext(function () {
|
|
965
|
-
var e_1, _a;
|
|
966
|
-
_this._throwIfClosed();
|
|
967
|
-
if (!_this.isStopped) {
|
|
968
|
-
if (!_this.currentObservers) {
|
|
969
|
-
_this.currentObservers = Array.from(_this.observers);
|
|
970
|
-
}
|
|
971
|
-
try {
|
|
972
|
-
for (var _b = __values(_this.currentObservers), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
973
|
-
var observer = _c.value;
|
|
974
|
-
observer.next(value);
|
|
975
|
-
}
|
|
976
|
-
}
|
|
977
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
978
|
-
finally {
|
|
979
|
-
try {
|
|
980
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
981
|
-
}
|
|
982
|
-
finally { if (e_1) throw e_1.error; }
|
|
983
|
-
}
|
|
984
|
-
}
|
|
985
|
-
});
|
|
986
|
-
};
|
|
987
|
-
Subject.prototype.error = function (err) {
|
|
988
|
-
var _this = this;
|
|
989
|
-
errorContext(function () {
|
|
990
|
-
_this._throwIfClosed();
|
|
991
|
-
if (!_this.isStopped) {
|
|
992
|
-
_this.hasError = _this.isStopped = true;
|
|
993
|
-
_this.thrownError = err;
|
|
994
|
-
var observers = _this.observers;
|
|
995
|
-
while (observers.length) {
|
|
996
|
-
observers.shift().error(err);
|
|
997
|
-
}
|
|
998
|
-
}
|
|
999
|
-
});
|
|
1000
|
-
};
|
|
1001
|
-
Subject.prototype.complete = function () {
|
|
1002
|
-
var _this = this;
|
|
1003
|
-
errorContext(function () {
|
|
1004
|
-
_this._throwIfClosed();
|
|
1005
|
-
if (!_this.isStopped) {
|
|
1006
|
-
_this.isStopped = true;
|
|
1007
|
-
var observers = _this.observers;
|
|
1008
|
-
while (observers.length) {
|
|
1009
|
-
observers.shift().complete();
|
|
1010
|
-
}
|
|
1011
|
-
}
|
|
1012
|
-
});
|
|
1013
|
-
};
|
|
1014
|
-
Subject.prototype.unsubscribe = function () {
|
|
1015
|
-
this.isStopped = this.closed = true;
|
|
1016
|
-
this.observers = this.currentObservers = null;
|
|
1017
|
-
};
|
|
1018
|
-
Object.defineProperty(Subject.prototype, "observed", {
|
|
1019
|
-
get: function () {
|
|
1020
|
-
var _a;
|
|
1021
|
-
return ((_a = this.observers) === null || _a === void 0 ? void 0 : _a.length) > 0;
|
|
1022
|
-
},
|
|
1023
|
-
enumerable: false,
|
|
1024
|
-
configurable: true
|
|
1025
|
-
});
|
|
1026
|
-
Subject.prototype._trySubscribe = function (subscriber) {
|
|
1027
|
-
this._throwIfClosed();
|
|
1028
|
-
return _super.prototype._trySubscribe.call(this, subscriber);
|
|
1029
|
-
};
|
|
1030
|
-
Subject.prototype._subscribe = function (subscriber) {
|
|
1031
|
-
this._throwIfClosed();
|
|
1032
|
-
this._checkFinalizedStatuses(subscriber);
|
|
1033
|
-
return this._innerSubscribe(subscriber);
|
|
1034
|
-
};
|
|
1035
|
-
Subject.prototype._innerSubscribe = function (subscriber) {
|
|
1036
|
-
var _this = this;
|
|
1037
|
-
var _a = this, hasError = _a.hasError, isStopped = _a.isStopped, observers = _a.observers;
|
|
1038
|
-
if (hasError || isStopped) {
|
|
1039
|
-
return EMPTY_SUBSCRIPTION;
|
|
1040
|
-
}
|
|
1041
|
-
this.currentObservers = null;
|
|
1042
|
-
observers.push(subscriber);
|
|
1043
|
-
return new Subscription(function () {
|
|
1044
|
-
_this.currentObservers = null;
|
|
1045
|
-
arrRemove(observers, subscriber);
|
|
1046
|
-
});
|
|
1047
|
-
};
|
|
1048
|
-
Subject.prototype._checkFinalizedStatuses = function (subscriber) {
|
|
1049
|
-
var _a = this, hasError = _a.hasError, thrownError = _a.thrownError, isStopped = _a.isStopped;
|
|
1050
|
-
if (hasError) {
|
|
1051
|
-
subscriber.error(thrownError);
|
|
1052
|
-
}
|
|
1053
|
-
else if (isStopped) {
|
|
1054
|
-
subscriber.complete();
|
|
1055
|
-
}
|
|
1056
|
-
};
|
|
1057
|
-
Subject.prototype.asObservable = function () {
|
|
1058
|
-
var observable = new Observable();
|
|
1059
|
-
observable.source = this;
|
|
1060
|
-
return observable;
|
|
1061
|
-
};
|
|
1062
|
-
Subject.create = function (destination, source) {
|
|
1063
|
-
return new AnonymousSubject(destination, source);
|
|
1064
|
-
};
|
|
1065
|
-
return Subject;
|
|
1066
|
-
}(Observable));
|
|
1067
|
-
var AnonymousSubject = (function (_super) {
|
|
1068
|
-
__extends(AnonymousSubject, _super);
|
|
1069
|
-
function AnonymousSubject(destination, source) {
|
|
1070
|
-
var _this = _super.call(this) || this;
|
|
1071
|
-
_this.destination = destination;
|
|
1072
|
-
_this.source = source;
|
|
1073
|
-
return _this;
|
|
1074
|
-
}
|
|
1075
|
-
AnonymousSubject.prototype.next = function (value) {
|
|
1076
|
-
var _a, _b;
|
|
1077
|
-
(_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.next) === null || _b === void 0 ? void 0 : _b.call(_a, value);
|
|
1078
|
-
};
|
|
1079
|
-
AnonymousSubject.prototype.error = function (err) {
|
|
1080
|
-
var _a, _b;
|
|
1081
|
-
(_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.call(_a, err);
|
|
1082
|
-
};
|
|
1083
|
-
AnonymousSubject.prototype.complete = function () {
|
|
1084
|
-
var _a, _b;
|
|
1085
|
-
(_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.complete) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
1086
|
-
};
|
|
1087
|
-
AnonymousSubject.prototype._subscribe = function (subscriber) {
|
|
1088
|
-
var _a, _b;
|
|
1089
|
-
return (_b = (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber)) !== null && _b !== void 0 ? _b : EMPTY_SUBSCRIPTION;
|
|
1090
|
-
};
|
|
1091
|
-
return AnonymousSubject;
|
|
1092
|
-
}(Subject));
|
|
1093
|
-
|
|
1094
|
-
var dateTimestampProvider = {
|
|
1095
|
-
now: function () {
|
|
1096
|
-
return (dateTimestampProvider.delegate || Date).now();
|
|
1097
|
-
},
|
|
1098
|
-
delegate: undefined,
|
|
1099
|
-
};
|
|
1100
|
-
|
|
1101
|
-
var ReplaySubject = (function (_super) {
|
|
1102
|
-
__extends(ReplaySubject, _super);
|
|
1103
|
-
function ReplaySubject(_bufferSize, _windowTime, _timestampProvider) {
|
|
1104
|
-
if (_bufferSize === void 0) { _bufferSize = Infinity; }
|
|
1105
|
-
if (_windowTime === void 0) { _windowTime = Infinity; }
|
|
1106
|
-
if (_timestampProvider === void 0) { _timestampProvider = dateTimestampProvider; }
|
|
1107
|
-
var _this = _super.call(this) || this;
|
|
1108
|
-
_this._bufferSize = _bufferSize;
|
|
1109
|
-
_this._windowTime = _windowTime;
|
|
1110
|
-
_this._timestampProvider = _timestampProvider;
|
|
1111
|
-
_this._buffer = [];
|
|
1112
|
-
_this._infiniteTimeWindow = true;
|
|
1113
|
-
_this._infiniteTimeWindow = _windowTime === Infinity;
|
|
1114
|
-
_this._bufferSize = Math.max(1, _bufferSize);
|
|
1115
|
-
_this._windowTime = Math.max(1, _windowTime);
|
|
1116
|
-
return _this;
|
|
1117
|
-
}
|
|
1118
|
-
ReplaySubject.prototype.next = function (value) {
|
|
1119
|
-
var _a = this, isStopped = _a.isStopped, _buffer = _a._buffer, _infiniteTimeWindow = _a._infiniteTimeWindow, _timestampProvider = _a._timestampProvider, _windowTime = _a._windowTime;
|
|
1120
|
-
if (!isStopped) {
|
|
1121
|
-
_buffer.push(value);
|
|
1122
|
-
!_infiniteTimeWindow && _buffer.push(_timestampProvider.now() + _windowTime);
|
|
1123
|
-
}
|
|
1124
|
-
this._trimBuffer();
|
|
1125
|
-
_super.prototype.next.call(this, value);
|
|
1126
|
-
};
|
|
1127
|
-
ReplaySubject.prototype._subscribe = function (subscriber) {
|
|
1128
|
-
this._throwIfClosed();
|
|
1129
|
-
this._trimBuffer();
|
|
1130
|
-
var subscription = this._innerSubscribe(subscriber);
|
|
1131
|
-
var _a = this, _infiniteTimeWindow = _a._infiniteTimeWindow, _buffer = _a._buffer;
|
|
1132
|
-
var copy = _buffer.slice();
|
|
1133
|
-
for (var i = 0; i < copy.length && !subscriber.closed; i += _infiniteTimeWindow ? 1 : 2) {
|
|
1134
|
-
subscriber.next(copy[i]);
|
|
1135
|
-
}
|
|
1136
|
-
this._checkFinalizedStatuses(subscriber);
|
|
1137
|
-
return subscription;
|
|
1138
|
-
};
|
|
1139
|
-
ReplaySubject.prototype._trimBuffer = function () {
|
|
1140
|
-
var _a = this, _bufferSize = _a._bufferSize, _timestampProvider = _a._timestampProvider, _buffer = _a._buffer, _infiniteTimeWindow = _a._infiniteTimeWindow;
|
|
1141
|
-
var adjustedBufferSize = (_infiniteTimeWindow ? 1 : 2) * _bufferSize;
|
|
1142
|
-
_bufferSize < Infinity && adjustedBufferSize < _buffer.length && _buffer.splice(0, _buffer.length - adjustedBufferSize);
|
|
1143
|
-
if (!_infiniteTimeWindow) {
|
|
1144
|
-
var now = _timestampProvider.now();
|
|
1145
|
-
var last = 0;
|
|
1146
|
-
for (var i = 1; i < _buffer.length && _buffer[i] <= now; i += 2) {
|
|
1147
|
-
last = i;
|
|
1148
|
-
}
|
|
1149
|
-
last && _buffer.splice(0, last + 1);
|
|
1150
|
-
}
|
|
1151
|
-
};
|
|
1152
|
-
return ReplaySubject;
|
|
1153
|
-
}(Subject));
|
|
1154
|
-
|
|
1155
|
-
var Action = (function (_super) {
|
|
1156
|
-
__extends(Action, _super);
|
|
1157
|
-
function Action(scheduler, work) {
|
|
1158
|
-
return _super.call(this) || this;
|
|
1159
|
-
}
|
|
1160
|
-
Action.prototype.schedule = function (state, delay) {
|
|
1161
|
-
return this;
|
|
1162
|
-
};
|
|
1163
|
-
return Action;
|
|
1164
|
-
}(Subscription));
|
|
1165
|
-
|
|
1166
|
-
var intervalProvider = {
|
|
1167
|
-
setInterval: function (handler, timeout) {
|
|
1168
|
-
var args = [];
|
|
1169
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1170
|
-
args[_i - 2] = arguments[_i];
|
|
1171
|
-
}
|
|
1172
|
-
var delegate = intervalProvider.delegate;
|
|
1173
|
-
if (delegate === null || delegate === void 0 ? void 0 : delegate.setInterval) {
|
|
1174
|
-
return delegate.setInterval.apply(delegate, __spreadArray([handler, timeout], __read(args)));
|
|
1175
|
-
}
|
|
1176
|
-
return setInterval.apply(void 0, __spreadArray([handler, timeout], __read(args)));
|
|
1177
|
-
},
|
|
1178
|
-
clearInterval: function (handle) {
|
|
1179
|
-
var delegate = intervalProvider.delegate;
|
|
1180
|
-
return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearInterval) || clearInterval)(handle);
|
|
1181
|
-
},
|
|
1182
|
-
delegate: undefined,
|
|
1183
|
-
};
|
|
1184
|
-
|
|
1185
|
-
var AsyncAction = (function (_super) {
|
|
1186
|
-
__extends(AsyncAction, _super);
|
|
1187
|
-
function AsyncAction(scheduler, work) {
|
|
1188
|
-
var _this = _super.call(this, scheduler, work) || this;
|
|
1189
|
-
_this.scheduler = scheduler;
|
|
1190
|
-
_this.work = work;
|
|
1191
|
-
_this.pending = false;
|
|
1192
|
-
return _this;
|
|
1193
|
-
}
|
|
1194
|
-
AsyncAction.prototype.schedule = function (state, delay) {
|
|
1195
|
-
if (delay === void 0) { delay = 0; }
|
|
1196
|
-
if (this.closed) {
|
|
1197
|
-
return this;
|
|
1198
|
-
}
|
|
1199
|
-
this.state = state;
|
|
1200
|
-
var id = this.id;
|
|
1201
|
-
var scheduler = this.scheduler;
|
|
1202
|
-
if (id != null) {
|
|
1203
|
-
this.id = this.recycleAsyncId(scheduler, id, delay);
|
|
1204
|
-
}
|
|
1205
|
-
this.pending = true;
|
|
1206
|
-
this.delay = delay;
|
|
1207
|
-
this.id = this.id || this.requestAsyncId(scheduler, this.id, delay);
|
|
1208
|
-
return this;
|
|
1209
|
-
};
|
|
1210
|
-
AsyncAction.prototype.requestAsyncId = function (scheduler, _id, delay) {
|
|
1211
|
-
if (delay === void 0) { delay = 0; }
|
|
1212
|
-
return intervalProvider.setInterval(scheduler.flush.bind(scheduler, this), delay);
|
|
1213
|
-
};
|
|
1214
|
-
AsyncAction.prototype.recycleAsyncId = function (_scheduler, id, delay) {
|
|
1215
|
-
if (delay === void 0) { delay = 0; }
|
|
1216
|
-
if (delay != null && this.delay === delay && this.pending === false) {
|
|
1217
|
-
return id;
|
|
1218
|
-
}
|
|
1219
|
-
intervalProvider.clearInterval(id);
|
|
1220
|
-
return undefined;
|
|
1221
|
-
};
|
|
1222
|
-
AsyncAction.prototype.execute = function (state, delay) {
|
|
1223
|
-
if (this.closed) {
|
|
1224
|
-
return new Error('executing a cancelled action');
|
|
1225
|
-
}
|
|
1226
|
-
this.pending = false;
|
|
1227
|
-
var error = this._execute(state, delay);
|
|
1228
|
-
if (error) {
|
|
1229
|
-
return error;
|
|
1230
|
-
}
|
|
1231
|
-
else if (this.pending === false && this.id != null) {
|
|
1232
|
-
this.id = this.recycleAsyncId(this.scheduler, this.id, null);
|
|
1233
|
-
}
|
|
1234
|
-
};
|
|
1235
|
-
AsyncAction.prototype._execute = function (state, _delay) {
|
|
1236
|
-
var errored = false;
|
|
1237
|
-
var errorValue;
|
|
1238
|
-
try {
|
|
1239
|
-
this.work(state);
|
|
1240
|
-
}
|
|
1241
|
-
catch (e) {
|
|
1242
|
-
errored = true;
|
|
1243
|
-
errorValue = e ? e : new Error('Scheduled action threw falsy error');
|
|
1244
|
-
}
|
|
1245
|
-
if (errored) {
|
|
1246
|
-
this.unsubscribe();
|
|
1247
|
-
return errorValue;
|
|
1248
|
-
}
|
|
1249
|
-
};
|
|
1250
|
-
AsyncAction.prototype.unsubscribe = function () {
|
|
1251
|
-
if (!this.closed) {
|
|
1252
|
-
var _a = this, id = _a.id, scheduler = _a.scheduler;
|
|
1253
|
-
var actions = scheduler.actions;
|
|
1254
|
-
this.work = this.state = this.scheduler = null;
|
|
1255
|
-
this.pending = false;
|
|
1256
|
-
arrRemove(actions, this);
|
|
1257
|
-
if (id != null) {
|
|
1258
|
-
this.id = this.recycleAsyncId(scheduler, id, null);
|
|
1259
|
-
}
|
|
1260
|
-
this.delay = null;
|
|
1261
|
-
_super.prototype.unsubscribe.call(this);
|
|
1262
|
-
}
|
|
1263
|
-
};
|
|
1264
|
-
return AsyncAction;
|
|
1265
|
-
}(Action));
|
|
1266
|
-
|
|
1267
|
-
var Scheduler = (function () {
|
|
1268
|
-
function Scheduler(schedulerActionCtor, now) {
|
|
1269
|
-
if (now === void 0) { now = Scheduler.now; }
|
|
1270
|
-
this.schedulerActionCtor = schedulerActionCtor;
|
|
1271
|
-
this.now = now;
|
|
1272
|
-
}
|
|
1273
|
-
Scheduler.prototype.schedule = function (work, delay, state) {
|
|
1274
|
-
if (delay === void 0) { delay = 0; }
|
|
1275
|
-
return new this.schedulerActionCtor(this, work).schedule(state, delay);
|
|
1276
|
-
};
|
|
1277
|
-
Scheduler.now = dateTimestampProvider.now;
|
|
1278
|
-
return Scheduler;
|
|
1279
|
-
}());
|
|
1280
|
-
|
|
1281
|
-
var AsyncScheduler = (function (_super) {
|
|
1282
|
-
__extends(AsyncScheduler, _super);
|
|
1283
|
-
function AsyncScheduler(SchedulerAction, now) {
|
|
1284
|
-
if (now === void 0) { now = Scheduler.now; }
|
|
1285
|
-
var _this = _super.call(this, SchedulerAction, now) || this;
|
|
1286
|
-
_this.actions = [];
|
|
1287
|
-
_this._active = false;
|
|
1288
|
-
_this._scheduled = undefined;
|
|
1289
|
-
return _this;
|
|
1290
|
-
}
|
|
1291
|
-
AsyncScheduler.prototype.flush = function (action) {
|
|
1292
|
-
var actions = this.actions;
|
|
1293
|
-
if (this._active) {
|
|
1294
|
-
actions.push(action);
|
|
1295
|
-
return;
|
|
1296
|
-
}
|
|
1297
|
-
var error;
|
|
1298
|
-
this._active = true;
|
|
1299
|
-
do {
|
|
1300
|
-
if ((error = action.execute(action.state, action.delay))) {
|
|
1301
|
-
break;
|
|
1302
|
-
}
|
|
1303
|
-
} while ((action = actions.shift()));
|
|
1304
|
-
this._active = false;
|
|
1305
|
-
if (error) {
|
|
1306
|
-
while ((action = actions.shift())) {
|
|
1307
|
-
action.unsubscribe();
|
|
1308
|
-
}
|
|
1309
|
-
throw error;
|
|
1310
|
-
}
|
|
1311
|
-
};
|
|
1312
|
-
return AsyncScheduler;
|
|
1313
|
-
}(Scheduler));
|
|
1314
|
-
|
|
1315
|
-
var asyncScheduler = new AsyncScheduler(AsyncAction);
|
|
1316
|
-
var async = asyncScheduler;
|
|
1317
|
-
|
|
1318
|
-
var EMPTY = new Observable(function (subscriber) { return subscriber.complete(); });
|
|
1319
|
-
|
|
1320
|
-
function isScheduler(value) {
|
|
1321
|
-
return value && isFunction(value.schedule);
|
|
1322
|
-
}
|
|
1323
|
-
|
|
1324
|
-
function last(arr) {
|
|
1325
|
-
return arr[arr.length - 1];
|
|
1326
|
-
}
|
|
1327
|
-
function popScheduler(args) {
|
|
1328
|
-
return isScheduler(last(args)) ? args.pop() : undefined;
|
|
1329
|
-
}
|
|
1330
|
-
|
|
1331
|
-
var isArrayLike = (function (x) { return x && typeof x.length === 'number' && typeof x !== 'function'; });
|
|
1332
|
-
|
|
1333
|
-
function isPromise(value) {
|
|
1334
|
-
return isFunction(value === null || value === void 0 ? void 0 : value.then);
|
|
1335
|
-
}
|
|
1336
|
-
|
|
1337
|
-
function isInteropObservable(input) {
|
|
1338
|
-
return isFunction(input[observable]);
|
|
1339
|
-
}
|
|
1340
|
-
|
|
1341
|
-
function isAsyncIterable(obj) {
|
|
1342
|
-
return Symbol.asyncIterator && isFunction(obj === null || obj === void 0 ? void 0 : obj[Symbol.asyncIterator]);
|
|
1343
|
-
}
|
|
1344
|
-
|
|
1345
|
-
function createInvalidObservableTypeError(input) {
|
|
1346
|
-
return new TypeError("You provided " + (input !== null && typeof input === 'object' ? 'an invalid object' : "'" + input + "'") + " where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.");
|
|
1347
|
-
}
|
|
1348
|
-
|
|
1349
|
-
function getSymbolIterator() {
|
|
1350
|
-
if (typeof Symbol !== 'function' || !Symbol.iterator) {
|
|
1351
|
-
return '@@iterator';
|
|
1352
|
-
}
|
|
1353
|
-
return Symbol.iterator;
|
|
1354
|
-
}
|
|
1355
|
-
var iterator = getSymbolIterator();
|
|
1356
|
-
|
|
1357
|
-
function isIterable(input) {
|
|
1358
|
-
return isFunction(input === null || input === void 0 ? void 0 : input[iterator]);
|
|
1359
|
-
}
|
|
1360
|
-
|
|
1361
|
-
function readableStreamLikeToAsyncGenerator(readableStream) {
|
|
1362
|
-
return __asyncGenerator(this, arguments, function readableStreamLikeToAsyncGenerator_1() {
|
|
1363
|
-
var reader, _a, value, done;
|
|
1364
|
-
return __generator(this, function (_b) {
|
|
1365
|
-
switch (_b.label) {
|
|
1366
|
-
case 0:
|
|
1367
|
-
reader = readableStream.getReader();
|
|
1368
|
-
_b.label = 1;
|
|
1369
|
-
case 1:
|
|
1370
|
-
_b.trys.push([1, , 9, 10]);
|
|
1371
|
-
_b.label = 2;
|
|
1372
|
-
case 2:
|
|
1373
|
-
return [4, __await(reader.read())];
|
|
1374
|
-
case 3:
|
|
1375
|
-
_a = _b.sent(), value = _a.value, done = _a.done;
|
|
1376
|
-
if (!done) return [3, 5];
|
|
1377
|
-
return [4, __await(void 0)];
|
|
1378
|
-
case 4: return [2, _b.sent()];
|
|
1379
|
-
case 5: return [4, __await(value)];
|
|
1380
|
-
case 6: return [4, _b.sent()];
|
|
1381
|
-
case 7:
|
|
1382
|
-
_b.sent();
|
|
1383
|
-
return [3, 2];
|
|
1384
|
-
case 8: return [3, 10];
|
|
1385
|
-
case 9:
|
|
1386
|
-
reader.releaseLock();
|
|
1387
|
-
return [7];
|
|
1388
|
-
case 10: return [2];
|
|
1389
|
-
}
|
|
1390
|
-
});
|
|
1391
|
-
});
|
|
1392
|
-
}
|
|
1393
|
-
function isReadableStreamLike(obj) {
|
|
1394
|
-
return isFunction(obj === null || obj === void 0 ? void 0 : obj.getReader);
|
|
1395
|
-
}
|
|
1396
|
-
|
|
1397
|
-
function innerFrom(input) {
|
|
1398
|
-
if (input instanceof Observable) {
|
|
1399
|
-
return input;
|
|
1400
|
-
}
|
|
1401
|
-
if (input != null) {
|
|
1402
|
-
if (isInteropObservable(input)) {
|
|
1403
|
-
return fromInteropObservable(input);
|
|
1404
|
-
}
|
|
1405
|
-
if (isArrayLike(input)) {
|
|
1406
|
-
return fromArrayLike(input);
|
|
1407
|
-
}
|
|
1408
|
-
if (isPromise(input)) {
|
|
1409
|
-
return fromPromise(input);
|
|
1410
|
-
}
|
|
1411
|
-
if (isAsyncIterable(input)) {
|
|
1412
|
-
return fromAsyncIterable(input);
|
|
1413
|
-
}
|
|
1414
|
-
if (isIterable(input)) {
|
|
1415
|
-
return fromIterable(input);
|
|
1416
|
-
}
|
|
1417
|
-
if (isReadableStreamLike(input)) {
|
|
1418
|
-
return fromReadableStreamLike(input);
|
|
1419
|
-
}
|
|
1420
|
-
}
|
|
1421
|
-
throw createInvalidObservableTypeError(input);
|
|
1422
|
-
}
|
|
1423
|
-
function fromInteropObservable(obj) {
|
|
1424
|
-
return new Observable(function (subscriber) {
|
|
1425
|
-
var obs = obj[observable]();
|
|
1426
|
-
if (isFunction(obs.subscribe)) {
|
|
1427
|
-
return obs.subscribe(subscriber);
|
|
1428
|
-
}
|
|
1429
|
-
throw new TypeError('Provided object does not correctly implement Symbol.observable');
|
|
1430
|
-
});
|
|
1431
|
-
}
|
|
1432
|
-
function fromArrayLike(array) {
|
|
1433
|
-
return new Observable(function (subscriber) {
|
|
1434
|
-
for (var i = 0; i < array.length && !subscriber.closed; i++) {
|
|
1435
|
-
subscriber.next(array[i]);
|
|
1436
|
-
}
|
|
1437
|
-
subscriber.complete();
|
|
1438
|
-
});
|
|
1439
|
-
}
|
|
1440
|
-
function fromPromise(promise) {
|
|
1441
|
-
return new Observable(function (subscriber) {
|
|
1442
|
-
promise
|
|
1443
|
-
.then(function (value) {
|
|
1444
|
-
if (!subscriber.closed) {
|
|
1445
|
-
subscriber.next(value);
|
|
1446
|
-
subscriber.complete();
|
|
1447
|
-
}
|
|
1448
|
-
}, function (err) { return subscriber.error(err); })
|
|
1449
|
-
.then(null, reportUnhandledError);
|
|
1450
|
-
});
|
|
1451
|
-
}
|
|
1452
|
-
function fromIterable(iterable) {
|
|
1453
|
-
return new Observable(function (subscriber) {
|
|
1454
|
-
var e_1, _a;
|
|
1455
|
-
try {
|
|
1456
|
-
for (var iterable_1 = __values(iterable), iterable_1_1 = iterable_1.next(); !iterable_1_1.done; iterable_1_1 = iterable_1.next()) {
|
|
1457
|
-
var value = iterable_1_1.value;
|
|
1458
|
-
subscriber.next(value);
|
|
1459
|
-
if (subscriber.closed) {
|
|
1460
|
-
return;
|
|
1461
|
-
}
|
|
1462
|
-
}
|
|
1463
|
-
}
|
|
1464
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1465
|
-
finally {
|
|
1466
|
-
try {
|
|
1467
|
-
if (iterable_1_1 && !iterable_1_1.done && (_a = iterable_1.return)) _a.call(iterable_1);
|
|
1468
|
-
}
|
|
1469
|
-
finally { if (e_1) throw e_1.error; }
|
|
1470
|
-
}
|
|
1471
|
-
subscriber.complete();
|
|
1472
|
-
});
|
|
1473
|
-
}
|
|
1474
|
-
function fromAsyncIterable(asyncIterable) {
|
|
1475
|
-
return new Observable(function (subscriber) {
|
|
1476
|
-
process$1(asyncIterable, subscriber).catch(function (err) { return subscriber.error(err); });
|
|
1477
|
-
});
|
|
1478
|
-
}
|
|
1479
|
-
function fromReadableStreamLike(readableStream) {
|
|
1480
|
-
return fromAsyncIterable(readableStreamLikeToAsyncGenerator(readableStream));
|
|
1481
|
-
}
|
|
1482
|
-
function process$1(asyncIterable, subscriber) {
|
|
1483
|
-
var asyncIterable_1, asyncIterable_1_1;
|
|
1484
|
-
var e_2, _a;
|
|
1485
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1486
|
-
var value, e_2_1;
|
|
1487
|
-
return __generator(this, function (_b) {
|
|
1488
|
-
switch (_b.label) {
|
|
1489
|
-
case 0:
|
|
1490
|
-
_b.trys.push([0, 5, 6, 11]);
|
|
1491
|
-
asyncIterable_1 = __asyncValues(asyncIterable);
|
|
1492
|
-
_b.label = 1;
|
|
1493
|
-
case 1: return [4, asyncIterable_1.next()];
|
|
1494
|
-
case 2:
|
|
1495
|
-
if (!(asyncIterable_1_1 = _b.sent(), !asyncIterable_1_1.done)) return [3, 4];
|
|
1496
|
-
value = asyncIterable_1_1.value;
|
|
1497
|
-
subscriber.next(value);
|
|
1498
|
-
if (subscriber.closed) {
|
|
1499
|
-
return [2];
|
|
1500
|
-
}
|
|
1501
|
-
_b.label = 3;
|
|
1502
|
-
case 3: return [3, 1];
|
|
1503
|
-
case 4: return [3, 11];
|
|
1504
|
-
case 5:
|
|
1505
|
-
e_2_1 = _b.sent();
|
|
1506
|
-
e_2 = { error: e_2_1 };
|
|
1507
|
-
return [3, 11];
|
|
1508
|
-
case 6:
|
|
1509
|
-
_b.trys.push([6, , 9, 10]);
|
|
1510
|
-
if (!(asyncIterable_1_1 && !asyncIterable_1_1.done && (_a = asyncIterable_1.return))) return [3, 8];
|
|
1511
|
-
return [4, _a.call(asyncIterable_1)];
|
|
1512
|
-
case 7:
|
|
1513
|
-
_b.sent();
|
|
1514
|
-
_b.label = 8;
|
|
1515
|
-
case 8: return [3, 10];
|
|
1516
|
-
case 9:
|
|
1517
|
-
if (e_2) throw e_2.error;
|
|
1518
|
-
return [7];
|
|
1519
|
-
case 10: return [7];
|
|
1520
|
-
case 11:
|
|
1521
|
-
subscriber.complete();
|
|
1522
|
-
return [2];
|
|
1523
|
-
}
|
|
1524
|
-
});
|
|
1525
|
-
});
|
|
1526
|
-
}
|
|
1527
|
-
|
|
1528
|
-
function executeSchedule(parentSubscription, scheduler, work, delay, repeat) {
|
|
1529
|
-
if (delay === void 0) { delay = 0; }
|
|
1530
|
-
if (repeat === void 0) { repeat = false; }
|
|
1531
|
-
var scheduleSubscription = scheduler.schedule(function () {
|
|
1532
|
-
work();
|
|
1533
|
-
if (repeat) {
|
|
1534
|
-
parentSubscription.add(this.schedule(null, delay));
|
|
1535
|
-
}
|
|
1536
|
-
else {
|
|
1537
|
-
this.unsubscribe();
|
|
1538
|
-
}
|
|
1539
|
-
}, delay);
|
|
1540
|
-
parentSubscription.add(scheduleSubscription);
|
|
1541
|
-
if (!repeat) {
|
|
1542
|
-
return scheduleSubscription;
|
|
1543
|
-
}
|
|
1544
|
-
}
|
|
1545
|
-
|
|
1546
|
-
function observeOn(scheduler, delay) {
|
|
1547
|
-
if (delay === void 0) { delay = 0; }
|
|
1548
|
-
return operate(function (source, subscriber) {
|
|
1549
|
-
source.subscribe(createOperatorSubscriber(subscriber, function (value) { return executeSchedule(subscriber, scheduler, function () { return subscriber.next(value); }, delay); }, function () { return executeSchedule(subscriber, scheduler, function () { return subscriber.complete(); }, delay); }, function (err) { return executeSchedule(subscriber, scheduler, function () { return subscriber.error(err); }, delay); }));
|
|
1550
|
-
});
|
|
1551
|
-
}
|
|
1552
|
-
|
|
1553
|
-
function subscribeOn(scheduler, delay) {
|
|
1554
|
-
if (delay === void 0) { delay = 0; }
|
|
1555
|
-
return operate(function (source, subscriber) {
|
|
1556
|
-
subscriber.add(scheduler.schedule(function () { return source.subscribe(subscriber); }, delay));
|
|
1557
|
-
});
|
|
1558
|
-
}
|
|
1559
|
-
|
|
1560
|
-
function scheduleObservable(input, scheduler) {
|
|
1561
|
-
return innerFrom(input).pipe(subscribeOn(scheduler), observeOn(scheduler));
|
|
1562
|
-
}
|
|
1563
|
-
|
|
1564
|
-
function schedulePromise(input, scheduler) {
|
|
1565
|
-
return innerFrom(input).pipe(subscribeOn(scheduler), observeOn(scheduler));
|
|
1566
|
-
}
|
|
1567
|
-
|
|
1568
|
-
function scheduleArray(input, scheduler) {
|
|
1569
|
-
return new Observable(function (subscriber) {
|
|
1570
|
-
var i = 0;
|
|
1571
|
-
return scheduler.schedule(function () {
|
|
1572
|
-
if (i === input.length) {
|
|
1573
|
-
subscriber.complete();
|
|
1574
|
-
}
|
|
1575
|
-
else {
|
|
1576
|
-
subscriber.next(input[i++]);
|
|
1577
|
-
if (!subscriber.closed) {
|
|
1578
|
-
this.schedule();
|
|
1579
|
-
}
|
|
1580
|
-
}
|
|
1581
|
-
});
|
|
1582
|
-
});
|
|
1583
|
-
}
|
|
1584
|
-
|
|
1585
|
-
function scheduleIterable(input, scheduler) {
|
|
1586
|
-
return new Observable(function (subscriber) {
|
|
1587
|
-
var iterator$1;
|
|
1588
|
-
executeSchedule(subscriber, scheduler, function () {
|
|
1589
|
-
iterator$1 = input[iterator]();
|
|
1590
|
-
executeSchedule(subscriber, scheduler, function () {
|
|
1591
|
-
var _a;
|
|
1592
|
-
var value;
|
|
1593
|
-
var done;
|
|
1594
|
-
try {
|
|
1595
|
-
(_a = iterator$1.next(), value = _a.value, done = _a.done);
|
|
1596
|
-
}
|
|
1597
|
-
catch (err) {
|
|
1598
|
-
subscriber.error(err);
|
|
1599
|
-
return;
|
|
1600
|
-
}
|
|
1601
|
-
if (done) {
|
|
1602
|
-
subscriber.complete();
|
|
1603
|
-
}
|
|
1604
|
-
else {
|
|
1605
|
-
subscriber.next(value);
|
|
1606
|
-
}
|
|
1607
|
-
}, 0, true);
|
|
1608
|
-
});
|
|
1609
|
-
return function () { return isFunction(iterator$1 === null || iterator$1 === void 0 ? void 0 : iterator$1.return) && iterator$1.return(); };
|
|
1610
|
-
});
|
|
1611
|
-
}
|
|
1612
|
-
|
|
1613
|
-
function scheduleAsyncIterable(input, scheduler) {
|
|
1614
|
-
if (!input) {
|
|
1615
|
-
throw new Error('Iterable cannot be null');
|
|
1616
|
-
}
|
|
1617
|
-
return new Observable(function (subscriber) {
|
|
1618
|
-
executeSchedule(subscriber, scheduler, function () {
|
|
1619
|
-
var iterator = input[Symbol.asyncIterator]();
|
|
1620
|
-
executeSchedule(subscriber, scheduler, function () {
|
|
1621
|
-
iterator.next().then(function (result) {
|
|
1622
|
-
if (result.done) {
|
|
1623
|
-
subscriber.complete();
|
|
1624
|
-
}
|
|
1625
|
-
else {
|
|
1626
|
-
subscriber.next(result.value);
|
|
1627
|
-
}
|
|
1628
|
-
});
|
|
1629
|
-
}, 0, true);
|
|
1630
|
-
});
|
|
1631
|
-
});
|
|
1632
|
-
}
|
|
1633
|
-
|
|
1634
|
-
function scheduleReadableStreamLike(input, scheduler) {
|
|
1635
|
-
return scheduleAsyncIterable(readableStreamLikeToAsyncGenerator(input), scheduler);
|
|
1636
|
-
}
|
|
1637
|
-
|
|
1638
|
-
function scheduled(input, scheduler) {
|
|
1639
|
-
if (input != null) {
|
|
1640
|
-
if (isInteropObservable(input)) {
|
|
1641
|
-
return scheduleObservable(input, scheduler);
|
|
1642
|
-
}
|
|
1643
|
-
if (isArrayLike(input)) {
|
|
1644
|
-
return scheduleArray(input, scheduler);
|
|
1645
|
-
}
|
|
1646
|
-
if (isPromise(input)) {
|
|
1647
|
-
return schedulePromise(input, scheduler);
|
|
1648
|
-
}
|
|
1649
|
-
if (isAsyncIterable(input)) {
|
|
1650
|
-
return scheduleAsyncIterable(input, scheduler);
|
|
1651
|
-
}
|
|
1652
|
-
if (isIterable(input)) {
|
|
1653
|
-
return scheduleIterable(input, scheduler);
|
|
1654
|
-
}
|
|
1655
|
-
if (isReadableStreamLike(input)) {
|
|
1656
|
-
return scheduleReadableStreamLike(input, scheduler);
|
|
1657
|
-
}
|
|
1658
|
-
}
|
|
1659
|
-
throw createInvalidObservableTypeError(input);
|
|
1660
|
-
}
|
|
1661
|
-
|
|
1662
|
-
function from(input, scheduler) {
|
|
1663
|
-
return scheduler ? scheduled(input, scheduler) : innerFrom(input);
|
|
1664
|
-
}
|
|
1665
|
-
|
|
1666
|
-
function of() {
|
|
1667
|
-
var args = [];
|
|
1668
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1669
|
-
args[_i] = arguments[_i];
|
|
1670
|
-
}
|
|
1671
|
-
var scheduler = popScheduler(args);
|
|
1672
|
-
return from(args, scheduler);
|
|
1673
|
-
}
|
|
1674
|
-
|
|
1675
|
-
var EmptyError = createErrorClass(function (_super) { return function EmptyErrorImpl() {
|
|
1676
|
-
_super(this);
|
|
1677
|
-
this.name = 'EmptyError';
|
|
1678
|
-
this.message = 'no elements in sequence';
|
|
1679
|
-
}; });
|
|
1680
|
-
|
|
1681
|
-
function firstValueFrom(source, config) {
|
|
1682
|
-
var hasConfig = typeof config === 'object';
|
|
1683
|
-
return new Promise(function (resolve, reject) {
|
|
1684
|
-
var subscriber = new SafeSubscriber({
|
|
1685
|
-
next: function (value) {
|
|
1686
|
-
resolve(value);
|
|
1687
|
-
subscriber.unsubscribe();
|
|
1688
|
-
},
|
|
1689
|
-
error: reject,
|
|
1690
|
-
complete: function () {
|
|
1691
|
-
if (hasConfig) {
|
|
1692
|
-
resolve(config.defaultValue);
|
|
1693
|
-
}
|
|
1694
|
-
else {
|
|
1695
|
-
reject(new EmptyError());
|
|
1696
|
-
}
|
|
1697
|
-
},
|
|
1698
|
-
});
|
|
1699
|
-
source.subscribe(subscriber);
|
|
1700
|
-
});
|
|
1701
|
-
}
|
|
1702
|
-
|
|
1703
|
-
function isValidDate(value) {
|
|
1704
|
-
return value instanceof Date && !isNaN(value);
|
|
1705
|
-
}
|
|
1706
|
-
|
|
1707
|
-
function map(project, thisArg) {
|
|
1708
|
-
return operate(function (source, subscriber) {
|
|
1709
|
-
var index = 0;
|
|
1710
|
-
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1711
|
-
subscriber.next(project.call(thisArg, value, index++));
|
|
1712
|
-
}));
|
|
1713
|
-
});
|
|
1714
|
-
}
|
|
1715
|
-
|
|
1716
|
-
function mergeInternals(source, subscriber, project, concurrent, onBeforeNext, expand, innerSubScheduler, additionalFinalizer) {
|
|
1717
|
-
var buffer = [];
|
|
1718
|
-
var active = 0;
|
|
1719
|
-
var index = 0;
|
|
1720
|
-
var isComplete = false;
|
|
1721
|
-
var checkComplete = function () {
|
|
1722
|
-
if (isComplete && !buffer.length && !active) {
|
|
1723
|
-
subscriber.complete();
|
|
1724
|
-
}
|
|
1725
|
-
};
|
|
1726
|
-
var outerNext = function (value) { return (active < concurrent ? doInnerSub(value) : buffer.push(value)); };
|
|
1727
|
-
var doInnerSub = function (value) {
|
|
1728
|
-
expand && subscriber.next(value);
|
|
1729
|
-
active++;
|
|
1730
|
-
var innerComplete = false;
|
|
1731
|
-
innerFrom(project(value, index++)).subscribe(createOperatorSubscriber(subscriber, function (innerValue) {
|
|
1732
|
-
onBeforeNext === null || onBeforeNext === void 0 ? void 0 : onBeforeNext(innerValue);
|
|
1733
|
-
if (expand) {
|
|
1734
|
-
outerNext(innerValue);
|
|
1735
|
-
}
|
|
1736
|
-
else {
|
|
1737
|
-
subscriber.next(innerValue);
|
|
1738
|
-
}
|
|
1739
|
-
}, function () {
|
|
1740
|
-
innerComplete = true;
|
|
1741
|
-
}, undefined, function () {
|
|
1742
|
-
if (innerComplete) {
|
|
1743
|
-
try {
|
|
1744
|
-
active--;
|
|
1745
|
-
var _loop_1 = function () {
|
|
1746
|
-
var bufferedValue = buffer.shift();
|
|
1747
|
-
if (innerSubScheduler) {
|
|
1748
|
-
executeSchedule(subscriber, innerSubScheduler, function () { return doInnerSub(bufferedValue); });
|
|
1749
|
-
}
|
|
1750
|
-
else {
|
|
1751
|
-
doInnerSub(bufferedValue);
|
|
1752
|
-
}
|
|
1753
|
-
};
|
|
1754
|
-
while (buffer.length && active < concurrent) {
|
|
1755
|
-
_loop_1();
|
|
1756
|
-
}
|
|
1757
|
-
checkComplete();
|
|
1758
|
-
}
|
|
1759
|
-
catch (err) {
|
|
1760
|
-
subscriber.error(err);
|
|
1761
|
-
}
|
|
1762
|
-
}
|
|
1763
|
-
}));
|
|
1764
|
-
};
|
|
1765
|
-
source.subscribe(createOperatorSubscriber(subscriber, outerNext, function () {
|
|
1766
|
-
isComplete = true;
|
|
1767
|
-
checkComplete();
|
|
1768
|
-
}));
|
|
1769
|
-
return function () {
|
|
1770
|
-
additionalFinalizer === null || additionalFinalizer === void 0 ? void 0 : additionalFinalizer();
|
|
1771
|
-
};
|
|
1772
|
-
}
|
|
1773
|
-
|
|
1774
|
-
function mergeMap(project, resultSelector, concurrent) {
|
|
1775
|
-
if (concurrent === void 0) { concurrent = Infinity; }
|
|
1776
|
-
if (isFunction(resultSelector)) {
|
|
1777
|
-
return mergeMap(function (a, i) { return map(function (b, ii) { return resultSelector(a, b, i, ii); })(innerFrom(project(a, i))); }, concurrent);
|
|
1778
|
-
}
|
|
1779
|
-
else if (typeof resultSelector === 'number') {
|
|
1780
|
-
concurrent = resultSelector;
|
|
1781
|
-
}
|
|
1782
|
-
return operate(function (source, subscriber) { return mergeInternals(source, subscriber, project, concurrent); });
|
|
1783
|
-
}
|
|
1784
|
-
|
|
1785
|
-
function mergeAll(concurrent) {
|
|
1786
|
-
if (concurrent === void 0) { concurrent = Infinity; }
|
|
1787
|
-
return mergeMap(identity, concurrent);
|
|
1788
|
-
}
|
|
1789
|
-
|
|
1790
|
-
function concatAll() {
|
|
1791
|
-
return mergeAll(1);
|
|
1792
|
-
}
|
|
1793
|
-
|
|
1794
|
-
function concat$1() {
|
|
1795
|
-
var args = [];
|
|
1796
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1797
|
-
args[_i] = arguments[_i];
|
|
1798
|
-
}
|
|
1799
|
-
return concatAll()(from(args, popScheduler(args)));
|
|
1800
|
-
}
|
|
1801
|
-
|
|
1802
|
-
function timer(dueTime, intervalOrScheduler, scheduler) {
|
|
1803
|
-
if (dueTime === void 0) { dueTime = 0; }
|
|
1804
|
-
if (scheduler === void 0) { scheduler = async; }
|
|
1805
|
-
var intervalDuration = -1;
|
|
1806
|
-
if (intervalOrScheduler != null) {
|
|
1807
|
-
if (isScheduler(intervalOrScheduler)) {
|
|
1808
|
-
scheduler = intervalOrScheduler;
|
|
1809
|
-
}
|
|
1810
|
-
else {
|
|
1811
|
-
intervalDuration = intervalOrScheduler;
|
|
1812
|
-
}
|
|
1813
|
-
}
|
|
1814
|
-
return new Observable(function (subscriber) {
|
|
1815
|
-
var due = isValidDate(dueTime) ? +dueTime - scheduler.now() : dueTime;
|
|
1816
|
-
if (due < 0) {
|
|
1817
|
-
due = 0;
|
|
1818
|
-
}
|
|
1819
|
-
var n = 0;
|
|
1820
|
-
return scheduler.schedule(function () {
|
|
1821
|
-
if (!subscriber.closed) {
|
|
1822
|
-
subscriber.next(n++);
|
|
1823
|
-
if (0 <= intervalDuration) {
|
|
1824
|
-
this.schedule(undefined, intervalDuration);
|
|
1825
|
-
}
|
|
1826
|
-
else {
|
|
1827
|
-
subscriber.complete();
|
|
1828
|
-
}
|
|
1829
|
-
}
|
|
1830
|
-
}, due);
|
|
1831
|
-
});
|
|
1832
|
-
}
|
|
1833
|
-
|
|
1834
|
-
function filter(predicate, thisArg) {
|
|
1835
|
-
return operate(function (source, subscriber) {
|
|
1836
|
-
var index = 0;
|
|
1837
|
-
source.subscribe(createOperatorSubscriber(subscriber, function (value) { return predicate.call(thisArg, value, index++) && subscriber.next(value); }));
|
|
1838
|
-
});
|
|
1839
|
-
}
|
|
1840
|
-
|
|
1841
|
-
function buffer(closingNotifier) {
|
|
1842
|
-
return operate(function (source, subscriber) {
|
|
1843
|
-
var currentBuffer = [];
|
|
1844
|
-
source.subscribe(createOperatorSubscriber(subscriber, function (value) { return currentBuffer.push(value); }, function () {
|
|
1845
|
-
subscriber.next(currentBuffer);
|
|
1846
|
-
subscriber.complete();
|
|
1847
|
-
}));
|
|
1848
|
-
closingNotifier.subscribe(createOperatorSubscriber(subscriber, function () {
|
|
1849
|
-
var b = currentBuffer;
|
|
1850
|
-
currentBuffer = [];
|
|
1851
|
-
subscriber.next(b);
|
|
1852
|
-
}, noop));
|
|
1853
|
-
return function () {
|
|
1854
|
-
currentBuffer = null;
|
|
1855
|
-
};
|
|
1856
|
-
});
|
|
1857
|
-
}
|
|
1858
|
-
|
|
1859
|
-
function scanInternals(accumulator, seed, hasSeed, emitOnNext, emitBeforeComplete) {
|
|
1860
|
-
return function (source, subscriber) {
|
|
1861
|
-
var hasState = hasSeed;
|
|
1862
|
-
var state = seed;
|
|
1863
|
-
var index = 0;
|
|
1864
|
-
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1865
|
-
var i = index++;
|
|
1866
|
-
state = hasState
|
|
1867
|
-
?
|
|
1868
|
-
accumulator(state, value, i)
|
|
1869
|
-
:
|
|
1870
|
-
((hasState = true), value);
|
|
1871
|
-
emitOnNext && subscriber.next(state);
|
|
1872
|
-
}, emitBeforeComplete &&
|
|
1873
|
-
(function () {
|
|
1874
|
-
hasState && subscriber.next(state);
|
|
1875
|
-
subscriber.complete();
|
|
1876
|
-
})));
|
|
1877
|
-
};
|
|
1878
|
-
}
|
|
1879
|
-
|
|
1880
|
-
function reduce(accumulator, seed) {
|
|
1881
|
-
return operate(scanInternals(accumulator, seed, arguments.length >= 2, false, true));
|
|
1882
|
-
}
|
|
1883
|
-
|
|
1884
|
-
var arrReducer = function (arr, value) { return (arr.push(value), arr); };
|
|
1885
|
-
function toArray() {
|
|
1886
|
-
return operate(function (source, subscriber) {
|
|
1887
|
-
reduce(arrReducer, [])(source).subscribe(subscriber);
|
|
1888
|
-
});
|
|
1889
|
-
}
|
|
1890
|
-
|
|
1891
|
-
function concat() {
|
|
1892
|
-
var args = [];
|
|
1893
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1894
|
-
args[_i] = arguments[_i];
|
|
1895
|
-
}
|
|
1896
|
-
var scheduler = popScheduler(args);
|
|
1897
|
-
return operate(function (source, subscriber) {
|
|
1898
|
-
concatAll()(from(__spreadArray([source], __read(args)), scheduler)).subscribe(subscriber);
|
|
1899
|
-
});
|
|
1900
|
-
}
|
|
1901
|
-
|
|
1902
|
-
function concatWith() {
|
|
1903
|
-
var otherSources = [];
|
|
1904
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1905
|
-
otherSources[_i] = arguments[_i];
|
|
1906
|
-
}
|
|
1907
|
-
return concat.apply(void 0, __spreadArray([], __read(otherSources)));
|
|
1908
|
-
}
|
|
1909
|
-
|
|
1910
|
-
function defaultIfEmpty(defaultValue) {
|
|
1911
|
-
return operate(function (source, subscriber) {
|
|
1912
|
-
var hasValue = false;
|
|
1913
|
-
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1914
|
-
hasValue = true;
|
|
1915
|
-
subscriber.next(value);
|
|
1916
|
-
}, function () {
|
|
1917
|
-
if (!hasValue) {
|
|
1918
|
-
subscriber.next(defaultValue);
|
|
1919
|
-
}
|
|
1920
|
-
subscriber.complete();
|
|
1921
|
-
}));
|
|
1922
|
-
});
|
|
1923
|
-
}
|
|
1924
|
-
|
|
1925
|
-
function take(count) {
|
|
1926
|
-
return count <= 0
|
|
1927
|
-
?
|
|
1928
|
-
function () { return EMPTY; }
|
|
1929
|
-
: operate(function (source, subscriber) {
|
|
1930
|
-
var seen = 0;
|
|
1931
|
-
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1932
|
-
if (++seen <= count) {
|
|
1933
|
-
subscriber.next(value);
|
|
1934
|
-
if (count <= seen) {
|
|
1935
|
-
subscriber.complete();
|
|
1936
|
-
}
|
|
1937
|
-
}
|
|
1938
|
-
}));
|
|
1939
|
-
});
|
|
1940
|
-
}
|
|
1941
|
-
|
|
1942
|
-
function throwIfEmpty(errorFactory) {
|
|
1943
|
-
if (errorFactory === void 0) { errorFactory = defaultErrorFactory; }
|
|
1944
|
-
return operate(function (source, subscriber) {
|
|
1945
|
-
var hasValue = false;
|
|
1946
|
-
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1947
|
-
hasValue = true;
|
|
1948
|
-
subscriber.next(value);
|
|
1949
|
-
}, function () { return (hasValue ? subscriber.complete() : subscriber.error(errorFactory())); }));
|
|
1950
|
-
});
|
|
1951
|
-
}
|
|
1952
|
-
function defaultErrorFactory() {
|
|
1953
|
-
return new EmptyError();
|
|
1954
|
-
}
|
|
1955
|
-
|
|
1956
|
-
function first(predicate, defaultValue) {
|
|
1957
|
-
var hasDefaultValue = arguments.length >= 2;
|
|
1958
|
-
return function (source) {
|
|
1959
|
-
return source.pipe(predicate ? filter(function (v, i) { return predicate(v, i, source); }) : identity, take(1), hasDefaultValue ? defaultIfEmpty(defaultValue) : throwIfEmpty(function () { return new EmptyError(); }));
|
|
1960
|
-
};
|
|
1961
|
-
}
|
|
1962
|
-
|
|
1963
|
-
function retry(configOrCount) {
|
|
1964
|
-
if (configOrCount === void 0) { configOrCount = Infinity; }
|
|
1965
|
-
var config;
|
|
1966
|
-
if (configOrCount && typeof configOrCount === 'object') {
|
|
1967
|
-
config = configOrCount;
|
|
1968
|
-
}
|
|
1969
|
-
else {
|
|
1970
|
-
config = {
|
|
1971
|
-
count: configOrCount,
|
|
1972
|
-
};
|
|
1973
|
-
}
|
|
1974
|
-
var _a = config.count, count = _a === void 0 ? Infinity : _a, delay = config.delay, _b = config.resetOnSuccess, resetOnSuccess = _b === void 0 ? false : _b;
|
|
1975
|
-
return count <= 0
|
|
1976
|
-
? identity
|
|
1977
|
-
: operate(function (source, subscriber) {
|
|
1978
|
-
var soFar = 0;
|
|
1979
|
-
var innerSub;
|
|
1980
|
-
var subscribeForRetry = function () {
|
|
1981
|
-
var syncUnsub = false;
|
|
1982
|
-
innerSub = source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1983
|
-
if (resetOnSuccess) {
|
|
1984
|
-
soFar = 0;
|
|
1985
|
-
}
|
|
1986
|
-
subscriber.next(value);
|
|
1987
|
-
}, undefined, function (err) {
|
|
1988
|
-
if (soFar++ < count) {
|
|
1989
|
-
var resub_1 = function () {
|
|
1990
|
-
if (innerSub) {
|
|
1991
|
-
innerSub.unsubscribe();
|
|
1992
|
-
innerSub = null;
|
|
1993
|
-
subscribeForRetry();
|
|
1994
|
-
}
|
|
1995
|
-
else {
|
|
1996
|
-
syncUnsub = true;
|
|
1997
|
-
}
|
|
1998
|
-
};
|
|
1999
|
-
if (delay != null) {
|
|
2000
|
-
var notifier = typeof delay === 'number' ? timer(delay) : innerFrom(delay(err, soFar));
|
|
2001
|
-
var notifierSubscriber_1 = createOperatorSubscriber(subscriber, function () {
|
|
2002
|
-
notifierSubscriber_1.unsubscribe();
|
|
2003
|
-
resub_1();
|
|
2004
|
-
}, function () {
|
|
2005
|
-
subscriber.complete();
|
|
2006
|
-
});
|
|
2007
|
-
notifier.subscribe(notifierSubscriber_1);
|
|
2008
|
-
}
|
|
2009
|
-
else {
|
|
2010
|
-
resub_1();
|
|
2011
|
-
}
|
|
2012
|
-
}
|
|
2013
|
-
else {
|
|
2014
|
-
subscriber.error(err);
|
|
2015
|
-
}
|
|
2016
|
-
}));
|
|
2017
|
-
if (syncUnsub) {
|
|
2018
|
-
innerSub.unsubscribe();
|
|
2019
|
-
innerSub = null;
|
|
2020
|
-
subscribeForRetry();
|
|
2021
|
-
}
|
|
2022
|
-
};
|
|
2023
|
-
subscribeForRetry();
|
|
2024
|
-
});
|
|
2025
|
-
}
|
|
2026
|
-
|
|
2027
|
-
function startWith() {
|
|
2028
|
-
var values = [];
|
|
2029
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2030
|
-
values[_i] = arguments[_i];
|
|
2031
|
-
}
|
|
2032
|
-
var scheduler = popScheduler(values);
|
|
2033
|
-
return operate(function (source, subscriber) {
|
|
2034
|
-
(scheduler ? concat$1(values, source, scheduler) : concat$1(values, source)).subscribe(subscriber);
|
|
2035
|
-
});
|
|
2036
|
-
}
|
|
2037
|
-
|
|
2038
|
-
function switchMap(project, resultSelector) {
|
|
2039
|
-
return operate(function (source, subscriber) {
|
|
2040
|
-
var innerSubscriber = null;
|
|
2041
|
-
var index = 0;
|
|
2042
|
-
var isComplete = false;
|
|
2043
|
-
var checkComplete = function () { return isComplete && !innerSubscriber && subscriber.complete(); };
|
|
2044
|
-
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
2045
|
-
innerSubscriber === null || innerSubscriber === void 0 ? void 0 : innerSubscriber.unsubscribe();
|
|
2046
|
-
var innerIndex = 0;
|
|
2047
|
-
var outerIndex = index++;
|
|
2048
|
-
innerFrom(project(value, outerIndex)).subscribe((innerSubscriber = createOperatorSubscriber(subscriber, function (innerValue) { return subscriber.next(resultSelector ? resultSelector(value, innerValue, outerIndex, innerIndex++) : innerValue); }, function () {
|
|
2049
|
-
innerSubscriber = null;
|
|
2050
|
-
checkComplete();
|
|
2051
|
-
})));
|
|
2052
|
-
}, function () {
|
|
2053
|
-
isComplete = true;
|
|
2054
|
-
checkComplete();
|
|
2055
|
-
}));
|
|
2056
|
-
});
|
|
2057
|
-
}
|
|
2058
|
-
|
|
2059
|
-
function takeUntil(notifier) {
|
|
2060
|
-
return operate(function (source, subscriber) {
|
|
2061
|
-
innerFrom(notifier).subscribe(createOperatorSubscriber(subscriber, function () { return subscriber.complete(); }, noop));
|
|
2062
|
-
!subscriber.closed && source.subscribe(subscriber);
|
|
2063
|
-
});
|
|
2064
|
-
}
|
|
2065
|
-
|
|
2066
198
|
class RxMap extends Map {
|
|
2067
199
|
static isChangeType = {
|
|
2068
200
|
clear: (x) => x.type === "clear",
|
|
@@ -2072,7 +204,7 @@ class RxMap extends Map {
|
|
|
2072
204
|
change$;
|
|
2073
205
|
constructor(iterable) {
|
|
2074
206
|
super(iterable);
|
|
2075
|
-
const change$ = new Subject();
|
|
207
|
+
const change$ = new rxjs.Subject();
|
|
2076
208
|
this.change$ = change$.asObservable();
|
|
2077
209
|
const changeMethodKeys = ["clear", "set", "delete"];
|
|
2078
210
|
for (const type of changeMethodKeys) {
|
|
@@ -2122,10 +254,12 @@ function getFileName({ type, id }) {
|
|
|
2122
254
|
case "asset":
|
|
2123
255
|
return fileName;
|
|
2124
256
|
default:
|
|
2125
|
-
throw new Error(
|
|
2126
|
-
type
|
|
2127
|
-
|
|
2128
|
-
|
|
257
|
+
throw new Error(
|
|
258
|
+
`Unexpected script type "${type}" for "${JSON.stringify({
|
|
259
|
+
type,
|
|
260
|
+
id
|
|
261
|
+
})}"`
|
|
262
|
+
);
|
|
2129
263
|
}
|
|
2130
264
|
}
|
|
2131
265
|
function getOutputPath(server, fileName) {
|
|
@@ -2181,7 +315,10 @@ const pluginBackground = () => {
|
|
|
2181
315
|
load(id) {
|
|
2182
316
|
if (id === workerClientId) {
|
|
2183
317
|
const base = `http://localhost:${config.server.port}/`;
|
|
2184
|
-
return defineClientValues(
|
|
318
|
+
return defineClientValues(
|
|
319
|
+
workerHmrClient.replace("__BASE__", JSON.stringify(base)),
|
|
320
|
+
config
|
|
321
|
+
);
|
|
2185
322
|
}
|
|
2186
323
|
}
|
|
2187
324
|
},
|
|
@@ -2233,7 +370,7 @@ var contentDevLoader = "(function () {\n 'use strict';\n\n (async () => {\n
|
|
|
2233
370
|
var contentProLoader = "(function () {\n 'use strict';\n\n (async () => {\n await import(\n /* @vite-ignore */\n chrome.runtime.getURL(__SCRIPT__)\n );\n })().catch(console.error);\n\n})();\n";
|
|
2234
371
|
|
|
2235
372
|
const contentScripts = new RxMap();
|
|
2236
|
-
contentScripts.change$.pipe(filter(RxMap.isChangeType.set)).subscribe(({ map, value }) => {
|
|
373
|
+
contentScripts.change$.pipe(rxjs.filter(RxMap.isChangeType.set)).subscribe(({ map, value }) => {
|
|
2237
374
|
const keyNames = [
|
|
2238
375
|
"refId",
|
|
2239
376
|
"id",
|
|
@@ -2265,16 +402,40 @@ function createProLoader({ fileName }) {
|
|
|
2265
402
|
return contentProLoader.replace(/__SCRIPT__/g, JSON.stringify(fileName));
|
|
2266
403
|
}
|
|
2267
404
|
|
|
2268
|
-
const serverEvent$ = new ReplaySubject(1);
|
|
2269
|
-
const close$ = serverEvent$.pipe(
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
405
|
+
const serverEvent$ = new rxjs.ReplaySubject(1);
|
|
406
|
+
const close$ = serverEvent$.pipe(
|
|
407
|
+
rxjs.filter((e) => e.type === "close"),
|
|
408
|
+
rxjs.switchMap((e) => rxjs.of(e))
|
|
409
|
+
);
|
|
410
|
+
const start$ = serverEvent$.pipe(
|
|
411
|
+
rxjs.filter((e) => e.type === "start"),
|
|
412
|
+
rxjs.switchMap((e) => rxjs.of(e))
|
|
413
|
+
);
|
|
414
|
+
const fileWriterEvent$ = new rxjs.ReplaySubject(1);
|
|
415
|
+
const buildEnd$ = fileWriterEvent$.pipe(
|
|
416
|
+
rxjs.filter((e) => e.type === "build_end"),
|
|
417
|
+
rxjs.switchMap((e) => rxjs.of(e))
|
|
418
|
+
);
|
|
419
|
+
fileWriterEvent$.pipe(
|
|
420
|
+
rxjs.filter((e) => e.type === "build_start"),
|
|
421
|
+
rxjs.switchMap((e) => rxjs.of(e))
|
|
422
|
+
);
|
|
423
|
+
const allFilesReady$ = buildEnd$.pipe(
|
|
424
|
+
rxjs.switchMap(() => outputFiles.change$.pipe(rxjs.startWith({ type: "start" }))),
|
|
425
|
+
rxjs.map(() => [...outputFiles.values()]),
|
|
426
|
+
rxjs.switchMap((files) => Promise.allSettled(files.map(({ file }) => file)))
|
|
427
|
+
);
|
|
2275
428
|
const isRejected = (x) => x?.status === "rejected";
|
|
2276
|
-
const fileWriterError$ = allFilesReady$.pipe(
|
|
2277
|
-
|
|
429
|
+
const fileWriterError$ = allFilesReady$.pipe(
|
|
430
|
+
rxjs.mergeMap((results) => results.filter(isRejected)),
|
|
431
|
+
rxjs.map((rejected) => ({ err: rejected.reason, type: "error" }))
|
|
432
|
+
);
|
|
433
|
+
rxjs.firstValueFrom(
|
|
434
|
+
fileWriterError$.pipe(
|
|
435
|
+
rxjs.takeUntil(serverEvent$.pipe(rxjs.first(({ type }) => type === "close"))),
|
|
436
|
+
rxjs.toArray()
|
|
437
|
+
)
|
|
438
|
+
);
|
|
2278
439
|
function prepFileData(fileId) {
|
|
2279
440
|
const fileName = getFileName(fileId);
|
|
2280
441
|
if (fileId.type === "asset") {
|
|
@@ -2284,49 +445,56 @@ function prepFileData(fileId) {
|
|
|
2284
445
|
}
|
|
2285
446
|
}
|
|
2286
447
|
function prepAsset(fileName, { id, source }) {
|
|
2287
|
-
return ($) => $.pipe(
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
448
|
+
return ($) => $.pipe(
|
|
449
|
+
rxjs.mergeMap(async ({ server }) => {
|
|
450
|
+
const target = getOutputPath(server, fileName);
|
|
451
|
+
return {
|
|
452
|
+
target,
|
|
453
|
+
source: source ?? await promises.readFile(join(server.config.root, id)),
|
|
454
|
+
deps: []
|
|
455
|
+
};
|
|
456
|
+
})
|
|
457
|
+
);
|
|
2295
458
|
}
|
|
2296
459
|
function prepScript(fileName, script) {
|
|
2297
|
-
return ($) => $.pipe(
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
const
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
await lexer__namespace.init;
|
|
2316
|
-
const [imports] = lexer__namespace.parse(code, fileName);
|
|
2317
|
-
const depSet = new Set(deps);
|
|
2318
|
-
const magic = new MagicString__default["default"](code);
|
|
2319
|
-
for (const i of imports)
|
|
2320
|
-
if (i.n) {
|
|
2321
|
-
depSet.add(i.n);
|
|
2322
|
-
const fileName2 = getFileName({ type: "module", id: i.n });
|
|
2323
|
-
magic.overwrite(i.s, i.e, `/${fileName2}`);
|
|
460
|
+
return ($) => $.pipe(
|
|
461
|
+
rxjs.mergeMap(async ({ server }) => {
|
|
462
|
+
const target = getOutputPath(server, fileName);
|
|
463
|
+
const viteUrl = getViteUrl(script);
|
|
464
|
+
const transformResult = await server.transformRequest(viteUrl);
|
|
465
|
+
if (!transformResult)
|
|
466
|
+
throw new TypeError(`Unable to load "${script.id}" from server.`);
|
|
467
|
+
const { code, deps = [], dynamicDeps = [] } = transformResult;
|
|
468
|
+
return { target, code, deps: [...deps, ...dynamicDeps].flat(), server };
|
|
469
|
+
}),
|
|
470
|
+
rxjs.retry({ count: 10, delay: 100 }),
|
|
471
|
+
rxjs.mergeMap(async ({ target, server, ...rest }) => {
|
|
472
|
+
const plugins = server.config.plugins;
|
|
473
|
+
let { code, deps } = rest;
|
|
474
|
+
for (const plugin of plugins) {
|
|
475
|
+
const r = await plugin.renderCrxDevScript?.(code, script);
|
|
476
|
+
if (typeof r === "string")
|
|
477
|
+
code = r;
|
|
2324
478
|
}
|
|
2325
|
-
|
|
2326
|
-
|
|
479
|
+
return { target, code, deps };
|
|
480
|
+
}),
|
|
481
|
+
rxjs.mergeMap(async ({ target, code, deps }) => {
|
|
482
|
+
await lexer__namespace.init;
|
|
483
|
+
const [imports] = lexer__namespace.parse(code, fileName);
|
|
484
|
+
const depSet = new Set(deps);
|
|
485
|
+
const magic = new MagicString__default["default"](code);
|
|
486
|
+
for (const i of imports)
|
|
487
|
+
if (i.n) {
|
|
488
|
+
depSet.add(i.n);
|
|
489
|
+
const fileName2 = getFileName({ type: "module", id: i.n });
|
|
490
|
+
magic.overwrite(i.s, i.e, `/${fileName2}`);
|
|
491
|
+
}
|
|
492
|
+
return { target, source: magic.toString(), deps: [...depSet] };
|
|
493
|
+
})
|
|
494
|
+
);
|
|
2327
495
|
}
|
|
2328
496
|
async function allFilesReady() {
|
|
2329
|
-
await firstValueFrom(allFilesReady$);
|
|
497
|
+
await rxjs.firstValueFrom(allFilesReady$);
|
|
2330
498
|
}
|
|
2331
499
|
|
|
2332
500
|
const { outputFile } = fsx__default["default"];
|
|
@@ -2335,7 +503,9 @@ async function start({
|
|
|
2335
503
|
server
|
|
2336
504
|
}) {
|
|
2337
505
|
serverEvent$.next({ type: "start", server });
|
|
2338
|
-
const plugins = server.config.plugins.filter(
|
|
506
|
+
const plugins = server.config.plugins.filter(
|
|
507
|
+
(p) => p.name?.startsWith("crx:")
|
|
508
|
+
);
|
|
2339
509
|
const { rollupOptions, outDir } = server.config.build;
|
|
2340
510
|
const inputOptions = {
|
|
2341
511
|
input: "index.html",
|
|
@@ -2387,21 +557,28 @@ function update(_id) {
|
|
|
2387
557
|
}
|
|
2388
558
|
async function write(fileId) {
|
|
2389
559
|
const start2 = perf_hooks.performance.now();
|
|
2390
|
-
const deps = await firstValueFrom(
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
const
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
560
|
+
const deps = await rxjs.firstValueFrom(
|
|
561
|
+
start$.pipe(
|
|
562
|
+
prepFileData(fileId),
|
|
563
|
+
rxjs.mergeMap(async ({ target, source, deps: deps2 }) => {
|
|
564
|
+
const files = deps2.map((id) => {
|
|
565
|
+
const r = [add({ id, type: "module" })];
|
|
566
|
+
if (id.includes("?import")) {
|
|
567
|
+
const [imported] = id.split("?import");
|
|
568
|
+
r.push(add({ id: imported, type: "asset" }));
|
|
569
|
+
}
|
|
570
|
+
return r;
|
|
571
|
+
}).flat();
|
|
572
|
+
if (source instanceof Uint8Array)
|
|
573
|
+
await outputFile(target, source);
|
|
574
|
+
else
|
|
575
|
+
await outputFile(target, source, { encoding: "utf8" });
|
|
576
|
+
return files;
|
|
577
|
+
}),
|
|
578
|
+
rxjs.takeUntil(close$),
|
|
579
|
+
rxjs.concatWith(rxjs.of([]))
|
|
580
|
+
)
|
|
581
|
+
);
|
|
2405
582
|
const close2 = perf_hooks.performance.now();
|
|
2406
583
|
return { start: start2, close: close2, deps };
|
|
2407
584
|
}
|
|
@@ -2410,7 +587,7 @@ const pluginContentScripts = () => {
|
|
|
2410
587
|
let server;
|
|
2411
588
|
let preambleCode;
|
|
2412
589
|
let hmrTimeout;
|
|
2413
|
-
let sub = new Subscription();
|
|
590
|
+
let sub = new rxjs.Subscription();
|
|
2414
591
|
return [
|
|
2415
592
|
{
|
|
2416
593
|
name: "crx:content-scripts",
|
|
@@ -2422,7 +599,9 @@ const pluginContentScripts = () => {
|
|
|
2422
599
|
},
|
|
2423
600
|
async configureServer(_server) {
|
|
2424
601
|
server = _server;
|
|
2425
|
-
if (typeof preambleCode === "undefined" && server.config.plugins.some(
|
|
602
|
+
if (typeof preambleCode === "undefined" && server.config.plugins.some(
|
|
603
|
+
({ name = "none" }) => name.toLowerCase().includes("react")
|
|
604
|
+
)) {
|
|
2426
605
|
try {
|
|
2427
606
|
const react = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@vitejs/plugin-react')); });
|
|
2428
607
|
preambleCode = react.default.preambleCode;
|
|
@@ -2430,31 +609,33 @@ const pluginContentScripts = () => {
|
|
|
2430
609
|
preambleCode = false;
|
|
2431
610
|
}
|
|
2432
611
|
}
|
|
2433
|
-
sub.add(
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
612
|
+
sub.add(
|
|
613
|
+
contentScripts.change$.pipe(rxjs.filter(RxMap.isChangeType.set)).subscribe(({ value: script }) => {
|
|
614
|
+
const { type, id } = script;
|
|
615
|
+
if (type === "loader") {
|
|
616
|
+
let preamble = { fileName: "" };
|
|
617
|
+
if (preambleCode)
|
|
618
|
+
preamble = add({ type: "module", id: preambleId });
|
|
619
|
+
const client = add({ type: "module", id: viteClientId });
|
|
620
|
+
const file = add({ type: "module", id });
|
|
621
|
+
const loader = add({
|
|
622
|
+
type: "asset",
|
|
623
|
+
id: getFileName({ type: "loader", id }),
|
|
624
|
+
source: createDevLoader({
|
|
625
|
+
preamble: preamble.fileName,
|
|
626
|
+
client: client.fileName,
|
|
627
|
+
fileName: file.fileName
|
|
628
|
+
})
|
|
629
|
+
});
|
|
630
|
+
script.fileName = loader.fileName;
|
|
631
|
+
} else if (type === "iife") {
|
|
632
|
+
throw new Error("IIFE content scripts are not implemented");
|
|
633
|
+
} else {
|
|
634
|
+
const file = add({ type: "module", id });
|
|
635
|
+
script.fileName = file.fileName;
|
|
636
|
+
}
|
|
637
|
+
})
|
|
638
|
+
);
|
|
2458
639
|
},
|
|
2459
640
|
resolveId(source) {
|
|
2460
641
|
if (source === preambleId)
|
|
@@ -2468,13 +649,16 @@ const pluginContentScripts = () => {
|
|
|
2468
649
|
return defined;
|
|
2469
650
|
}
|
|
2470
651
|
if (id === contentHmrPortId) {
|
|
2471
|
-
const defined = contentHmrPort.replace(
|
|
652
|
+
const defined = contentHmrPort.replace(
|
|
653
|
+
"__CRX_HMR_TIMEOUT__",
|
|
654
|
+
JSON.stringify(hmrTimeout)
|
|
655
|
+
);
|
|
2472
656
|
return defined;
|
|
2473
657
|
}
|
|
2474
658
|
},
|
|
2475
659
|
closeBundle() {
|
|
2476
660
|
sub.unsubscribe();
|
|
2477
|
-
sub = new Subscription();
|
|
661
|
+
sub = new rxjs.Subscription();
|
|
2478
662
|
}
|
|
2479
663
|
},
|
|
2480
664
|
{
|
|
@@ -2526,7 +710,9 @@ const pluginContentScriptsCss = () => {
|
|
|
2526
710
|
if (css?.length)
|
|
2527
711
|
script.css = [script.css ?? [], css].flat();
|
|
2528
712
|
} else {
|
|
2529
|
-
throw new Error(
|
|
713
|
+
throw new Error(
|
|
714
|
+
`Content script is undefined by fileName: ${fileName}`
|
|
715
|
+
);
|
|
2530
716
|
}
|
|
2531
717
|
}
|
|
2532
718
|
}
|
|
@@ -2562,7 +748,9 @@ const pluginDynamicContentScripts = () => {
|
|
|
2562
748
|
skipSelf: true
|
|
2563
749
|
});
|
|
2564
750
|
if (!resolved)
|
|
2565
|
-
throw new Error(
|
|
751
|
+
throw new Error(
|
|
752
|
+
`Could not resolve dynamic script: "${_source}" from "${importer}"`
|
|
753
|
+
);
|
|
2566
754
|
const { id } = resolved;
|
|
2567
755
|
let type = "loader";
|
|
2568
756
|
if (url.searchParams.has("module")) {
|
|
@@ -2622,7 +810,9 @@ const pluginDynamicContentScripts = () => {
|
|
|
2622
810
|
await fileReady(script);
|
|
2623
811
|
return `export default ${JSON.stringify(script.fileName)};`;
|
|
2624
812
|
} else {
|
|
2625
|
-
throw new Error(
|
|
813
|
+
throw new Error(
|
|
814
|
+
`Content script fileName is undefined: "${script.id}"`
|
|
815
|
+
);
|
|
2626
816
|
}
|
|
2627
817
|
}
|
|
2628
818
|
}
|
|
@@ -2634,14 +824,23 @@ const pluginDynamicContentScripts = () => {
|
|
|
2634
824
|
for (const chunk of Object.values(bundle))
|
|
2635
825
|
if (chunk.type === "chunk") {
|
|
2636
826
|
if (dynamicScriptRegEx().test(chunk.code)) {
|
|
2637
|
-
const replaced = chunk.code.replace(
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
827
|
+
const replaced = chunk.code.replace(
|
|
828
|
+
dynamicScriptRegEx(),
|
|
829
|
+
(match, p1, scriptKey) => {
|
|
830
|
+
const script = contentScripts.get(scriptKey);
|
|
831
|
+
if (typeof script === "undefined")
|
|
832
|
+
throw new Error(
|
|
833
|
+
`Content script refId is undefined: "${match}"`
|
|
834
|
+
);
|
|
835
|
+
if (typeof script.fileName === "undefined")
|
|
836
|
+
throw new Error(
|
|
837
|
+
`Content script fileName is undefined: "${script.id}"`
|
|
838
|
+
);
|
|
839
|
+
return `${JSON.stringify(
|
|
840
|
+
`/${script.loaderName ?? script.fileName}`
|
|
841
|
+
)};`;
|
|
842
|
+
}
|
|
843
|
+
);
|
|
2645
844
|
chunk.code = replaced;
|
|
2646
845
|
}
|
|
2647
846
|
}
|
|
@@ -2712,24 +911,32 @@ async function manifestFiles(manifest, options = {}) {
|
|
|
2712
911
|
let locales = [];
|
|
2713
912
|
if (manifest.default_locale)
|
|
2714
913
|
locales = await fg__default["default"]("_locales/**/messages.json", options);
|
|
2715
|
-
const rulesets = manifest.declarative_net_request?.rule_resources.flatMap(
|
|
914
|
+
const rulesets = manifest.declarative_net_request?.rule_resources.flatMap(
|
|
915
|
+
({ path }) => path
|
|
916
|
+
) ?? [];
|
|
2716
917
|
const contentScripts = manifest.content_scripts?.flatMap(({ js }) => js) ?? [];
|
|
2717
918
|
const contentStyles = manifest.content_scripts?.flatMap(({ css }) => css);
|
|
2718
919
|
const serviceWorker = manifest.background?.service_worker;
|
|
2719
920
|
const htmlPages = htmlFiles(manifest);
|
|
2720
921
|
const icons = [
|
|
2721
|
-
Object.values(
|
|
2722
|
-
|
|
922
|
+
Object.values(
|
|
923
|
+
isString(manifest.icons) ? [manifest.icons] : manifest.icons ?? {}
|
|
924
|
+
),
|
|
925
|
+
Object.values(
|
|
926
|
+
isString(manifest.action?.default_icon) ? [manifest.action?.default_icon] : manifest.action?.default_icon ?? {}
|
|
927
|
+
)
|
|
2723
928
|
].flat();
|
|
2724
929
|
let webAccessibleResources = [];
|
|
2725
930
|
if (manifest.web_accessible_resources) {
|
|
2726
|
-
const resources = await Promise.all(
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
931
|
+
const resources = await Promise.all(
|
|
932
|
+
manifest.web_accessible_resources.flatMap(({ resources: resources2 }) => resources2).map(async (r) => {
|
|
933
|
+
if (["*", "**/*"].includes(r))
|
|
934
|
+
return void 0;
|
|
935
|
+
if (fg__default["default"].isDynamicPattern(r))
|
|
936
|
+
return fg__default["default"](r, options);
|
|
937
|
+
return r;
|
|
938
|
+
})
|
|
939
|
+
);
|
|
2733
940
|
webAccessibleResources = resources.flat().filter(isString);
|
|
2734
941
|
}
|
|
2735
942
|
return {
|
|
@@ -2781,67 +988,74 @@ const pluginFileWriterPublic = () => {
|
|
|
2781
988
|
|
|
2782
989
|
_debug("file-writer").extend("hmr");
|
|
2783
990
|
const isCrxHMRPayload = (p) => p.type === "custom" && p.event.startsWith("crx:");
|
|
2784
|
-
const hmrPayload$ = new Subject();
|
|
2785
|
-
const crxHMRPayload$ = hmrPayload$.pipe(
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
991
|
+
const hmrPayload$ = new rxjs.Subject();
|
|
992
|
+
const crxHMRPayload$ = hmrPayload$.pipe(
|
|
993
|
+
rxjs.filter((p) => !isCrxHMRPayload(p)),
|
|
994
|
+
rxjs.buffer(allFilesReady$),
|
|
995
|
+
rxjs.mergeMap((pps) => {
|
|
996
|
+
let fullReload;
|
|
997
|
+
const payloads = [];
|
|
998
|
+
for (const p of pps)
|
|
999
|
+
if (p.type === "full-reload") {
|
|
1000
|
+
fullReload = p;
|
|
1001
|
+
} else {
|
|
1002
|
+
payloads.push(p);
|
|
1003
|
+
}
|
|
1004
|
+
if (fullReload)
|
|
1005
|
+
payloads.push(fullReload);
|
|
1006
|
+
return payloads;
|
|
1007
|
+
}),
|
|
1008
|
+
rxjs.map((p) => {
|
|
1009
|
+
switch (p.type) {
|
|
1010
|
+
case "full-reload": {
|
|
1011
|
+
const fullReload = {
|
|
1012
|
+
type: "full-reload",
|
|
1013
|
+
path: p.path && getViteUrl({ id: p.path, type: "module" })
|
|
1014
|
+
};
|
|
1015
|
+
return fullReload;
|
|
1016
|
+
}
|
|
1017
|
+
case "prune": {
|
|
1018
|
+
const prune = {
|
|
1019
|
+
type: "prune",
|
|
1020
|
+
paths: p.paths.map((id) => getViteUrl({ id, type: "module" }))
|
|
1021
|
+
};
|
|
1022
|
+
return prune;
|
|
1023
|
+
}
|
|
1024
|
+
case "update": {
|
|
1025
|
+
const update = {
|
|
1026
|
+
type: "update",
|
|
1027
|
+
updates: p.updates.map(({ acceptedPath: ap, path: p2, ...rest }) => ({
|
|
1028
|
+
...rest,
|
|
1029
|
+
acceptedPath: prefix$1("/", getFileName({ id: ap, type: "module" })),
|
|
1030
|
+
path: prefix$1("/", getFileName({ id: p2, type: "module" }))
|
|
1031
|
+
}))
|
|
1032
|
+
};
|
|
1033
|
+
return update;
|
|
1034
|
+
}
|
|
1035
|
+
default:
|
|
1036
|
+
return p;
|
|
1037
|
+
}
|
|
1038
|
+
}),
|
|
1039
|
+
rxjs.filter((p) => {
|
|
1040
|
+
switch (p.type) {
|
|
1041
|
+
case "full-reload":
|
|
1042
|
+
return typeof p.path === "undefined";
|
|
1043
|
+
case "prune":
|
|
1044
|
+
return p.paths.length > 0;
|
|
1045
|
+
case "update":
|
|
1046
|
+
return p.updates.length > 0;
|
|
1047
|
+
default:
|
|
1048
|
+
return true;
|
|
2823
1049
|
}
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
case "update":
|
|
2834
|
-
return p.updates.length > 0;
|
|
2835
|
-
default:
|
|
2836
|
-
return true;
|
|
2837
|
-
}
|
|
2838
|
-
}), map((data) => {
|
|
2839
|
-
return {
|
|
2840
|
-
type: "custom",
|
|
2841
|
-
event: "crx:content-script-payload",
|
|
2842
|
-
data
|
|
2843
|
-
};
|
|
2844
|
-
}));
|
|
1050
|
+
}),
|
|
1051
|
+
rxjs.map((data) => {
|
|
1052
|
+
return {
|
|
1053
|
+
type: "custom",
|
|
1054
|
+
event: "crx:content-script-payload",
|
|
1055
|
+
data
|
|
1056
|
+
};
|
|
1057
|
+
})
|
|
1058
|
+
);
|
|
2845
1059
|
|
|
2846
1060
|
function isImporter(file) {
|
|
2847
1061
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -2909,11 +1123,13 @@ const pluginHMR = () => {
|
|
|
2909
1123
|
send(payload);
|
|
2910
1124
|
};
|
|
2911
1125
|
server.ws.send = decoratedSend;
|
|
2912
|
-
subs = new Subscription(() => subs = new Subscription());
|
|
1126
|
+
subs = new rxjs.Subscription(() => subs = new rxjs.Subscription());
|
|
2913
1127
|
subs.add(fileWriterError$.subscribe(send));
|
|
2914
|
-
subs.add(
|
|
2915
|
-
|
|
2916
|
-
|
|
1128
|
+
subs.add(
|
|
1129
|
+
crxHMRPayload$.subscribe((payload) => {
|
|
1130
|
+
send(payload);
|
|
1131
|
+
})
|
|
1132
|
+
);
|
|
2917
1133
|
}
|
|
2918
1134
|
},
|
|
2919
1135
|
closeBundle() {
|
|
@@ -2954,7 +1170,9 @@ const pluginHMR = () => {
|
|
|
2954
1170
|
if (type === "module" && _id !== "/@vite/client" && code.includes("createHotContext")) {
|
|
2955
1171
|
const id = _id.replace(/t=\d+&/, "");
|
|
2956
1172
|
const escaped = id.replace(/([?&.])/g, "\\$1");
|
|
2957
|
-
const regexp = new RegExp(
|
|
1173
|
+
const regexp = new RegExp(
|
|
1174
|
+
`(?<=createHotContext\\(")${escaped}(?="\\))`
|
|
1175
|
+
);
|
|
2958
1176
|
const fileUrl = prefix$1("/", getFileName({ id, type }));
|
|
2959
1177
|
const replaced = code.replace(regexp, fileUrl);
|
|
2960
1178
|
return replaced;
|
|
@@ -3039,10 +1257,12 @@ const pluginHtmlInlineScripts = () => {
|
|
|
3039
1257
|
const p = pages.get(key);
|
|
3040
1258
|
if (p?.scripts.some(isInlineTag)) {
|
|
3041
1259
|
const $ = cheerio.load(html);
|
|
3042
|
-
p.scripts.push(
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
1260
|
+
p.scripts.push(
|
|
1261
|
+
...$("script").toArray().map((el) => ({
|
|
1262
|
+
tag: "script",
|
|
1263
|
+
attrs: { src: $(el).attr("src"), type: "module" }
|
|
1264
|
+
}))
|
|
1265
|
+
);
|
|
3046
1266
|
$("script").remove();
|
|
3047
1267
|
const loader2 = {
|
|
3048
1268
|
tag: "script",
|
|
@@ -3115,7 +1335,9 @@ const pluginManifest = () => {
|
|
|
3115
1335
|
const { manifest: _manifest } = await getOptions(config2);
|
|
3116
1336
|
manifest = await (typeof _manifest === "function" ? _manifest(env) : _manifest);
|
|
3117
1337
|
if (manifest.manifest_version !== 3)
|
|
3118
|
-
throw new Error(
|
|
1338
|
+
throw new Error(
|
|
1339
|
+
`CRXJS does not support Manifest v${manifest.manifest_version}, please use Manifest v3`
|
|
1340
|
+
);
|
|
3119
1341
|
if (env.command === "serve") {
|
|
3120
1342
|
const {
|
|
3121
1343
|
contentScripts: js,
|
|
@@ -3220,7 +1442,9 @@ const pluginManifest = () => {
|
|
|
3220
1442
|
configResolved(_config) {
|
|
3221
1443
|
config = _config;
|
|
3222
1444
|
const plugins2 = config.plugins;
|
|
3223
|
-
const crx = plugins2.findIndex(
|
|
1445
|
+
const crx = plugins2.findIndex(
|
|
1446
|
+
({ name }) => name === "crx:manifest-post"
|
|
1447
|
+
);
|
|
3224
1448
|
const [plugin] = plugins2.splice(crx, 1);
|
|
3225
1449
|
plugins2.push(plugin);
|
|
3226
1450
|
},
|
|
@@ -3243,13 +1467,16 @@ const pluginManifest = () => {
|
|
|
3243
1467
|
if (manifest2.content_scripts)
|
|
3244
1468
|
for (const { js = [], matches = [] } of manifest2.content_scripts)
|
|
3245
1469
|
for (const id2 of js) {
|
|
3246
|
-
contentScripts.set(
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
1470
|
+
contentScripts.set(
|
|
1471
|
+
prefix$1("/", id2),
|
|
1472
|
+
formatFileData({
|
|
1473
|
+
type: "loader",
|
|
1474
|
+
id: id2,
|
|
1475
|
+
matches,
|
|
1476
|
+
refId: hashScriptId({ type: "loader", id: id2 }),
|
|
1477
|
+
fileName: getFileName({ type: "loader", id: id2 })
|
|
1478
|
+
})
|
|
1479
|
+
);
|
|
3253
1480
|
}
|
|
3254
1481
|
} else {
|
|
3255
1482
|
if (manifest2.content_scripts)
|
|
@@ -3261,12 +1488,15 @@ const pluginManifest = () => {
|
|
|
3261
1488
|
id: id2,
|
|
3262
1489
|
name: basename(file)
|
|
3263
1490
|
});
|
|
3264
|
-
contentScripts.set(
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
1491
|
+
contentScripts.set(
|
|
1492
|
+
file,
|
|
1493
|
+
formatFileData({
|
|
1494
|
+
type: "loader",
|
|
1495
|
+
id: file,
|
|
1496
|
+
refId: refId2,
|
|
1497
|
+
matches
|
|
1498
|
+
})
|
|
1499
|
+
);
|
|
3270
1500
|
}
|
|
3271
1501
|
if (manifest2.background?.service_worker) {
|
|
3272
1502
|
const file = manifest2.background.service_worker;
|
|
@@ -3297,7 +1527,9 @@ const pluginManifest = () => {
|
|
|
3297
1527
|
if (config.command === "serve") {
|
|
3298
1528
|
if (manifest2.content_scripts)
|
|
3299
1529
|
for (const script of manifest2.content_scripts) {
|
|
3300
|
-
script.js = script.js?.map(
|
|
1530
|
+
script.js = script.js?.map(
|
|
1531
|
+
(id) => getFileName({ id, type: "loader" })
|
|
1532
|
+
);
|
|
3301
1533
|
}
|
|
3302
1534
|
} else {
|
|
3303
1535
|
if (manifest2.background?.service_worker) {
|
|
@@ -3305,18 +1537,22 @@ const pluginManifest = () => {
|
|
|
3305
1537
|
const name = this.getFileName(ref);
|
|
3306
1538
|
manifest2.background.service_worker = name;
|
|
3307
1539
|
}
|
|
3308
|
-
manifest2.content_scripts = manifest2.content_scripts?.map(
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
1540
|
+
manifest2.content_scripts = manifest2.content_scripts?.map(
|
|
1541
|
+
({ js = [], ...rest }) => {
|
|
1542
|
+
return {
|
|
1543
|
+
js: js.map((id) => {
|
|
1544
|
+
const script = contentScripts.get(id);
|
|
1545
|
+
const fileName = script?.loaderName ?? script?.fileName;
|
|
1546
|
+
if (typeof fileName === "undefined")
|
|
1547
|
+
throw new Error(
|
|
1548
|
+
`Content script fileName is undefined: "${id}"`
|
|
1549
|
+
);
|
|
1550
|
+
return fileName;
|
|
1551
|
+
}),
|
|
1552
|
+
...rest
|
|
1553
|
+
};
|
|
1554
|
+
}
|
|
1555
|
+
);
|
|
3320
1556
|
}
|
|
3321
1557
|
for (const plugin of plugins) {
|
|
3322
1558
|
try {
|
|
@@ -3327,7 +1563,9 @@ const pluginManifest = () => {
|
|
|
3327
1563
|
const name = `[${plugin.name}]`;
|
|
3328
1564
|
let message = error;
|
|
3329
1565
|
if (error instanceof Error) {
|
|
3330
|
-
message = colors__default["default"].red(
|
|
1566
|
+
message = colors__default["default"].red(
|
|
1567
|
+
`${name} ${error.stack ? error.stack : error.message}`
|
|
1568
|
+
);
|
|
3331
1569
|
} else if (typeof error === "string") {
|
|
3332
1570
|
message = colors__default["default"].red(`${name} ${error}`);
|
|
3333
1571
|
}
|
|
@@ -3342,23 +1580,27 @@ const pluginManifest = () => {
|
|
|
3342
1580
|
"webAccessibleResources"
|
|
3343
1581
|
];
|
|
3344
1582
|
const files = await manifestFiles(manifest2, { cwd: config.root });
|
|
3345
|
-
await Promise.all(
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
1583
|
+
await Promise.all(
|
|
1584
|
+
assetTypes.map((k) => files[k]).flat().map(async (f) => {
|
|
1585
|
+
if (typeof bundle[f] === "undefined") {
|
|
1586
|
+
let filename = join(config.root, f);
|
|
1587
|
+
if (!fs.existsSync(filename))
|
|
1588
|
+
filename = join(config.publicDir, f);
|
|
1589
|
+
if (!fs.existsSync(filename))
|
|
1590
|
+
throw new Error(
|
|
1591
|
+
`ENOENT: Could not load manifest asset "${f}".
|
|
3352
1592
|
Manifest assets must exist in one of these directories:
|
|
3353
1593
|
Project root: "${config.root}"
|
|
3354
|
-
Public dir: "${config.publicDir}"`
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
1594
|
+
Public dir: "${config.publicDir}"`
|
|
1595
|
+
);
|
|
1596
|
+
this.emitFile({
|
|
1597
|
+
type: "asset",
|
|
1598
|
+
fileName: f,
|
|
1599
|
+
source: await readFile(filename)
|
|
1600
|
+
});
|
|
1601
|
+
}
|
|
1602
|
+
})
|
|
1603
|
+
);
|
|
3362
1604
|
if (config.command === "serve" && files.html.length) {
|
|
3363
1605
|
const refId2 = this.emitFile({
|
|
3364
1606
|
type: "asset",
|
|
@@ -3366,11 +1608,16 @@ Public dir: "${config.publicDir}"`);
|
|
|
3366
1608
|
source: precontrollerJs
|
|
3367
1609
|
});
|
|
3368
1610
|
const precontrollerJsName = this.getFileName(refId2);
|
|
3369
|
-
files.html.map(
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
1611
|
+
files.html.map(
|
|
1612
|
+
(f) => this.emitFile({
|
|
1613
|
+
type: "asset",
|
|
1614
|
+
fileName: f,
|
|
1615
|
+
source: precontrollerHtml.replace(
|
|
1616
|
+
"%SCRIPT%",
|
|
1617
|
+
`/${precontrollerJsName}`
|
|
1618
|
+
)
|
|
1619
|
+
})
|
|
1620
|
+
);
|
|
3374
1621
|
}
|
|
3375
1622
|
const manifestJson = bundle["manifest.json"];
|
|
3376
1623
|
if (typeof manifestJson === "undefined") {
|
|
@@ -3415,7 +1662,11 @@ function compileFileResources(fileName, {
|
|
|
3415
1662
|
throw new Error(`Content script fileName for ${m} is undefined`);
|
|
3416
1663
|
} else {
|
|
3417
1664
|
resources.imports.add(script.fileName);
|
|
3418
|
-
compileFileResources(
|
|
1665
|
+
compileFileResources(
|
|
1666
|
+
script.fileName,
|
|
1667
|
+
{ chunks, files, config },
|
|
1668
|
+
resources
|
|
1669
|
+
);
|
|
3419
1670
|
}
|
|
3420
1671
|
}
|
|
3421
1672
|
}
|
|
@@ -3498,7 +1749,10 @@ const pluginWebAccessibleResources = () => {
|
|
|
3498
1749
|
dynamicScriptMatches.add("https://*/*");
|
|
3499
1750
|
}
|
|
3500
1751
|
if (contentScripts.size > 0) {
|
|
3501
|
-
const viteManifest = parseJsonAsset(
|
|
1752
|
+
const viteManifest = parseJsonAsset(
|
|
1753
|
+
bundle,
|
|
1754
|
+
"manifest.json"
|
|
1755
|
+
);
|
|
3502
1756
|
const viteFiles = /* @__PURE__ */ new Map();
|
|
3503
1757
|
for (const [, file] of Object.entries(viteManifest))
|
|
3504
1758
|
viteFiles.set(file.file, file);
|
|
@@ -3516,9 +1770,14 @@ const pluginWebAccessibleResources = () => {
|
|
|
3516
1770
|
if (key === id) {
|
|
3517
1771
|
if (isDynamicScript || matches.length)
|
|
3518
1772
|
if (typeof fileName === "undefined") {
|
|
3519
|
-
throw new Error(
|
|
1773
|
+
throw new Error(
|
|
1774
|
+
`Content script filename is undefined for "${id}"`
|
|
1775
|
+
);
|
|
3520
1776
|
} else {
|
|
3521
|
-
const { assets, css, imports } = compileFileResources(
|
|
1777
|
+
const { assets, css, imports } = compileFileResources(
|
|
1778
|
+
fileName,
|
|
1779
|
+
{ chunks: bundleChunks, files: viteFiles, config }
|
|
1780
|
+
);
|
|
3522
1781
|
contentScripts.get(key).css = [...css];
|
|
3523
1782
|
if (type === "loader")
|
|
3524
1783
|
imports.add(fileName);
|
|
@@ -3534,7 +1793,9 @@ const pluginWebAccessibleResources = () => {
|
|
|
3534
1793
|
if (type === "module") {
|
|
3535
1794
|
moduleScriptResources.set(fileName, resource);
|
|
3536
1795
|
} else {
|
|
3537
|
-
resource.matches = resource.matches.map(
|
|
1796
|
+
resource.matches = resource.matches.map(
|
|
1797
|
+
getMatchPatternOrigin
|
|
1798
|
+
);
|
|
3538
1799
|
web_accessible_resources.push(resource);
|
|
3539
1800
|
}
|
|
3540
1801
|
}
|