@livequery/rpc 2.0.91 → 2.0.96

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,2245 +1,9 @@
1
- // node_modules/tslib/tslib.es6.mjs
2
- var extendStatics = function(d, b) {
3
- extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
4
- d2.__proto__ = b2;
5
- } || function(d2, b2) {
6
- for (var p in b2)
7
- if (Object.prototype.hasOwnProperty.call(b2, p))
8
- d2[p] = b2[p];
9
- };
10
- return extendStatics(d, b);
11
- };
12
- function __extends(d, b) {
13
- if (typeof b !== "function" && b !== null)
14
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
15
- extendStatics(d, b);
16
- function __() {
17
- this.constructor = d;
18
- }
19
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __);
20
- }
21
- function __awaiter(thisArg, _arguments, P, generator) {
22
- function adopt(value) {
23
- return value instanceof P ? value : new P(function(resolve) {
24
- resolve(value);
25
- });
26
- }
27
- return new (P || (P = Promise))(function(resolve, reject) {
28
- function fulfilled(value) {
29
- try {
30
- step(generator.next(value));
31
- } catch (e) {
32
- reject(e);
33
- }
34
- }
35
- function rejected(value) {
36
- try {
37
- step(generator["throw"](value));
38
- } catch (e) {
39
- reject(e);
40
- }
41
- }
42
- function step(result) {
43
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
44
- }
45
- step((generator = generator.apply(thisArg, _arguments || [])).next());
46
- });
47
- }
48
- function __generator(thisArg, body) {
49
- var _ = { label: 0, sent: function() {
50
- if (t[0] & 1)
51
- throw t[1];
52
- return t[1];
53
- }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
54
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
55
- return this;
56
- }), g;
57
- function verb(n) {
58
- return function(v) {
59
- return step([n, v]);
60
- };
61
- }
62
- function step(op) {
63
- if (f)
64
- throw new TypeError("Generator is already executing.");
65
- while (g && (g = 0, op[0] && (_ = 0)), _)
66
- try {
67
- 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)
68
- return t;
69
- if (y = 0, t)
70
- op = [op[0] & 2, t.value];
71
- switch (op[0]) {
72
- case 0:
73
- case 1:
74
- t = op;
75
- break;
76
- case 4:
77
- _.label++;
78
- return { value: op[1], done: false };
79
- case 5:
80
- _.label++;
81
- y = op[1];
82
- op = [0];
83
- continue;
84
- case 7:
85
- op = _.ops.pop();
86
- _.trys.pop();
87
- continue;
88
- default:
89
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
90
- _ = 0;
91
- continue;
92
- }
93
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
94
- _.label = op[1];
95
- break;
96
- }
97
- if (op[0] === 6 && _.label < t[1]) {
98
- _.label = t[1];
99
- t = op;
100
- break;
101
- }
102
- if (t && _.label < t[2]) {
103
- _.label = t[2];
104
- _.ops.push(op);
105
- break;
106
- }
107
- if (t[2])
108
- _.ops.pop();
109
- _.trys.pop();
110
- continue;
111
- }
112
- op = body.call(thisArg, _);
113
- } catch (e) {
114
- op = [6, e];
115
- y = 0;
116
- } finally {
117
- f = t = 0;
118
- }
119
- if (op[0] & 5)
120
- throw op[1];
121
- return { value: op[0] ? op[1] : undefined, done: true };
122
- }
123
- }
124
- function __values(o) {
125
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
126
- if (m)
127
- return m.call(o);
128
- if (o && typeof o.length === "number")
129
- return {
130
- next: function() {
131
- if (o && i >= o.length)
132
- o = undefined;
133
- return { value: o && o[i++], done: !o };
134
- }
135
- };
136
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
137
- }
138
- function __read(o, n) {
139
- var m = typeof Symbol === "function" && o[Symbol.iterator];
140
- if (!m)
141
- return o;
142
- var i = m.call(o), r, ar = [], e;
143
- try {
144
- while ((n === undefined || n-- > 0) && !(r = i.next()).done)
145
- ar.push(r.value);
146
- } catch (error) {
147
- e = { error };
148
- } finally {
149
- try {
150
- if (r && !r.done && (m = i["return"]))
151
- m.call(i);
152
- } finally {
153
- if (e)
154
- throw e.error;
155
- }
156
- }
157
- return ar;
158
- }
159
- function __spreadArray(to, from, pack) {
160
- if (pack || arguments.length === 2)
161
- for (var i = 0, l = from.length, ar;i < l; i++) {
162
- if (ar || !(i in from)) {
163
- if (!ar)
164
- ar = Array.prototype.slice.call(from, 0, i);
165
- ar[i] = from[i];
166
- }
167
- }
168
- return to.concat(ar || Array.prototype.slice.call(from));
169
- }
170
- function __await(v) {
171
- return this instanceof __await ? (this.v = v, this) : new __await(v);
172
- }
173
- function __asyncGenerator(thisArg, _arguments, generator) {
174
- if (!Symbol.asyncIterator)
175
- throw new TypeError("Symbol.asyncIterator is not defined.");
176
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
177
- return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function() {
178
- return this;
179
- }, i;
180
- function awaitReturn(f) {
181
- return function(v) {
182
- return Promise.resolve(v).then(f, reject);
183
- };
184
- }
185
- function verb(n, f) {
186
- if (g[n]) {
187
- i[n] = function(v) {
188
- return new Promise(function(a, b) {
189
- q.push([n, v, a, b]) > 1 || resume(n, v);
190
- });
191
- };
192
- if (f)
193
- i[n] = f(i[n]);
194
- }
195
- }
196
- function resume(n, v) {
197
- try {
198
- step(g[n](v));
199
- } catch (e) {
200
- settle(q[0][3], e);
201
- }
202
- }
203
- function step(r) {
204
- r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
205
- }
206
- function fulfill(value) {
207
- resume("next", value);
208
- }
209
- function reject(value) {
210
- resume("throw", value);
211
- }
212
- function settle(f, v) {
213
- if (f(v), q.shift(), q.length)
214
- resume(q[0][0], q[0][1]);
215
- }
216
- }
217
- function __asyncValues(o) {
218
- if (!Symbol.asyncIterator)
219
- throw new TypeError("Symbol.asyncIterator is not defined.");
220
- var m = o[Symbol.asyncIterator], i;
221
- 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() {
222
- return this;
223
- }, i);
224
- function verb(n) {
225
- i[n] = o[n] && function(v) {
226
- return new Promise(function(resolve, reject) {
227
- v = o[n](v), settle(resolve, reject, v.done, v.value);
228
- });
229
- };
230
- }
231
- function settle(resolve, reject, d, v) {
232
- Promise.resolve(v).then(function(v2) {
233
- resolve({ value: v2, done: d });
234
- }, reject);
235
- }
236
- }
237
-
238
- // node_modules/rxjs/dist/esm5/internal/util/isFunction.js
239
- function isFunction(value) {
240
- return typeof value === "function";
241
- }
242
-
243
- // node_modules/rxjs/dist/esm5/internal/util/createErrorClass.js
244
- function createErrorClass(createImpl) {
245
- var _super = function(instance) {
246
- Error.call(instance);
247
- instance.stack = new Error().stack;
248
- };
249
- var ctorFunc = createImpl(_super);
250
- ctorFunc.prototype = Object.create(Error.prototype);
251
- ctorFunc.prototype.constructor = ctorFunc;
252
- return ctorFunc;
253
- }
254
-
255
- // node_modules/rxjs/dist/esm5/internal/util/UnsubscriptionError.js
256
- var UnsubscriptionError = createErrorClass(function(_super) {
257
- return function UnsubscriptionErrorImpl(errors) {
258
- _super(this);
259
- this.message = errors ? errors.length + ` errors occurred during unsubscription:
260
- ` + errors.map(function(err, i) {
261
- return i + 1 + ") " + err.toString();
262
- }).join(`
263
- `) : "";
264
- this.name = "UnsubscriptionError";
265
- this.errors = errors;
266
- };
267
- });
268
-
269
- // node_modules/rxjs/dist/esm5/internal/util/arrRemove.js
270
- function arrRemove(arr, item) {
271
- if (arr) {
272
- var index = arr.indexOf(item);
273
- 0 <= index && arr.splice(index, 1);
274
- }
275
- }
276
-
277
- // node_modules/rxjs/dist/esm5/internal/Subscription.js
278
- var Subscription = function() {
279
- function Subscription2(initialTeardown) {
280
- this.initialTeardown = initialTeardown;
281
- this.closed = false;
282
- this._parentage = null;
283
- this._finalizers = null;
284
- }
285
- Subscription2.prototype.unsubscribe = function() {
286
- var e_1, _a, e_2, _b;
287
- var errors;
288
- if (!this.closed) {
289
- this.closed = true;
290
- var _parentage = this._parentage;
291
- if (_parentage) {
292
- this._parentage = null;
293
- if (Array.isArray(_parentage)) {
294
- try {
295
- for (var _parentage_1 = __values(_parentage), _parentage_1_1 = _parentage_1.next();!_parentage_1_1.done; _parentage_1_1 = _parentage_1.next()) {
296
- var parent_1 = _parentage_1_1.value;
297
- parent_1.remove(this);
298
- }
299
- } catch (e_1_1) {
300
- e_1 = { error: e_1_1 };
301
- } finally {
302
- try {
303
- if (_parentage_1_1 && !_parentage_1_1.done && (_a = _parentage_1.return))
304
- _a.call(_parentage_1);
305
- } finally {
306
- if (e_1)
307
- throw e_1.error;
308
- }
309
- }
310
- } else {
311
- _parentage.remove(this);
312
- }
313
- }
314
- var initialFinalizer = this.initialTeardown;
315
- if (isFunction(initialFinalizer)) {
316
- try {
317
- initialFinalizer();
318
- } catch (e) {
319
- errors = e instanceof UnsubscriptionError ? e.errors : [e];
320
- }
321
- }
322
- var _finalizers = this._finalizers;
323
- if (_finalizers) {
324
- this._finalizers = null;
325
- try {
326
- for (var _finalizers_1 = __values(_finalizers), _finalizers_1_1 = _finalizers_1.next();!_finalizers_1_1.done; _finalizers_1_1 = _finalizers_1.next()) {
327
- var finalizer = _finalizers_1_1.value;
328
- try {
329
- execFinalizer(finalizer);
330
- } catch (err) {
331
- errors = errors !== null && errors !== undefined ? errors : [];
332
- if (err instanceof UnsubscriptionError) {
333
- errors = __spreadArray(__spreadArray([], __read(errors)), __read(err.errors));
334
- } else {
335
- errors.push(err);
336
- }
337
- }
338
- }
339
- } catch (e_2_1) {
340
- e_2 = { error: e_2_1 };
341
- } finally {
342
- try {
343
- if (_finalizers_1_1 && !_finalizers_1_1.done && (_b = _finalizers_1.return))
344
- _b.call(_finalizers_1);
345
- } finally {
346
- if (e_2)
347
- throw e_2.error;
348
- }
349
- }
350
- }
351
- if (errors) {
352
- throw new UnsubscriptionError(errors);
353
- }
354
- }
355
- };
356
- Subscription2.prototype.add = function(teardown) {
357
- var _a;
358
- if (teardown && teardown !== this) {
359
- if (this.closed) {
360
- execFinalizer(teardown);
361
- } else {
362
- if (teardown instanceof Subscription2) {
363
- if (teardown.closed || teardown._hasParent(this)) {
364
- return;
365
- }
366
- teardown._addParent(this);
367
- }
368
- (this._finalizers = (_a = this._finalizers) !== null && _a !== undefined ? _a : []).push(teardown);
369
- }
370
- }
371
- };
372
- Subscription2.prototype._hasParent = function(parent) {
373
- var _parentage = this._parentage;
374
- return _parentage === parent || Array.isArray(_parentage) && _parentage.includes(parent);
375
- };
376
- Subscription2.prototype._addParent = function(parent) {
377
- var _parentage = this._parentage;
378
- this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent;
379
- };
380
- Subscription2.prototype._removeParent = function(parent) {
381
- var _parentage = this._parentage;
382
- if (_parentage === parent) {
383
- this._parentage = null;
384
- } else if (Array.isArray(_parentage)) {
385
- arrRemove(_parentage, parent);
386
- }
387
- };
388
- Subscription2.prototype.remove = function(teardown) {
389
- var _finalizers = this._finalizers;
390
- _finalizers && arrRemove(_finalizers, teardown);
391
- if (teardown instanceof Subscription2) {
392
- teardown._removeParent(this);
393
- }
394
- };
395
- Subscription2.EMPTY = function() {
396
- var empty = new Subscription2;
397
- empty.closed = true;
398
- return empty;
399
- }();
400
- return Subscription2;
401
- }();
402
- var EMPTY_SUBSCRIPTION = Subscription.EMPTY;
403
- function isSubscription(value) {
404
- return value instanceof Subscription || value && "closed" in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe);
405
- }
406
- function execFinalizer(finalizer) {
407
- if (isFunction(finalizer)) {
408
- finalizer();
409
- } else {
410
- finalizer.unsubscribe();
411
- }
412
- }
413
-
414
- // node_modules/rxjs/dist/esm5/internal/config.js
415
- var config = {
416
- onUnhandledError: null,
417
- onStoppedNotification: null,
418
- Promise: undefined,
419
- useDeprecatedSynchronousErrorHandling: false,
420
- useDeprecatedNextContext: false
421
- };
422
-
423
- // node_modules/rxjs/dist/esm5/internal/scheduler/timeoutProvider.js
424
- var timeoutProvider = {
425
- setTimeout: function(handler, timeout) {
426
- var args = [];
427
- for (var _i = 2;_i < arguments.length; _i++) {
428
- args[_i - 2] = arguments[_i];
429
- }
430
- var delegate = timeoutProvider.delegate;
431
- if (delegate === null || delegate === undefined ? undefined : delegate.setTimeout) {
432
- return delegate.setTimeout.apply(delegate, __spreadArray([handler, timeout], __read(args)));
433
- }
434
- return setTimeout.apply(undefined, __spreadArray([handler, timeout], __read(args)));
435
- },
436
- clearTimeout: function(handle) {
437
- var delegate = timeoutProvider.delegate;
438
- return ((delegate === null || delegate === undefined ? undefined : delegate.clearTimeout) || clearTimeout)(handle);
439
- },
440
- delegate: undefined
441
- };
442
-
443
- // node_modules/rxjs/dist/esm5/internal/util/reportUnhandledError.js
444
- function reportUnhandledError(err) {
445
- timeoutProvider.setTimeout(function() {
446
- var onUnhandledError = config.onUnhandledError;
447
- if (onUnhandledError) {
448
- onUnhandledError(err);
449
- } else {
450
- throw err;
451
- }
452
- });
453
- }
454
-
455
- // node_modules/rxjs/dist/esm5/internal/util/noop.js
456
- function noop() {}
457
-
458
- // node_modules/rxjs/dist/esm5/internal/NotificationFactories.js
459
- var COMPLETE_NOTIFICATION = function() {
460
- return createNotification("C", undefined, undefined);
461
- }();
462
- function errorNotification(error) {
463
- return createNotification("E", undefined, error);
464
- }
465
- function nextNotification(value) {
466
- return createNotification("N", value, undefined);
467
- }
468
- function createNotification(kind, value, error) {
469
- return {
470
- kind,
471
- value,
472
- error
473
- };
474
- }
475
-
476
- // node_modules/rxjs/dist/esm5/internal/util/errorContext.js
477
- var context = null;
478
- function errorContext(cb) {
479
- if (config.useDeprecatedSynchronousErrorHandling) {
480
- var isRoot = !context;
481
- if (isRoot) {
482
- context = { errorThrown: false, error: null };
483
- }
484
- cb();
485
- if (isRoot) {
486
- var _a = context, errorThrown = _a.errorThrown, error = _a.error;
487
- context = null;
488
- if (errorThrown) {
489
- throw error;
490
- }
491
- }
492
- } else {
493
- cb();
494
- }
495
- }
496
- function captureError(err) {
497
- if (config.useDeprecatedSynchronousErrorHandling && context) {
498
- context.errorThrown = true;
499
- context.error = err;
500
- }
501
- }
502
-
503
- // node_modules/rxjs/dist/esm5/internal/Subscriber.js
504
- var Subscriber = function(_super) {
505
- __extends(Subscriber2, _super);
506
- function Subscriber2(destination) {
507
- var _this = _super.call(this) || this;
508
- _this.isStopped = false;
509
- if (destination) {
510
- _this.destination = destination;
511
- if (isSubscription(destination)) {
512
- destination.add(_this);
513
- }
514
- } else {
515
- _this.destination = EMPTY_OBSERVER;
516
- }
517
- return _this;
518
- }
519
- Subscriber2.create = function(next, error, complete) {
520
- return new SafeSubscriber(next, error, complete);
521
- };
522
- Subscriber2.prototype.next = function(value) {
523
- if (this.isStopped) {
524
- handleStoppedNotification(nextNotification(value), this);
525
- } else {
526
- this._next(value);
527
- }
528
- };
529
- Subscriber2.prototype.error = function(err) {
530
- if (this.isStopped) {
531
- handleStoppedNotification(errorNotification(err), this);
532
- } else {
533
- this.isStopped = true;
534
- this._error(err);
535
- }
536
- };
537
- Subscriber2.prototype.complete = function() {
538
- if (this.isStopped) {
539
- handleStoppedNotification(COMPLETE_NOTIFICATION, this);
540
- } else {
541
- this.isStopped = true;
542
- this._complete();
543
- }
544
- };
545
- Subscriber2.prototype.unsubscribe = function() {
546
- if (!this.closed) {
547
- this.isStopped = true;
548
- _super.prototype.unsubscribe.call(this);
549
- this.destination = null;
550
- }
551
- };
552
- Subscriber2.prototype._next = function(value) {
553
- this.destination.next(value);
554
- };
555
- Subscriber2.prototype._error = function(err) {
556
- try {
557
- this.destination.error(err);
558
- } finally {
559
- this.unsubscribe();
560
- }
561
- };
562
- Subscriber2.prototype._complete = function() {
563
- try {
564
- this.destination.complete();
565
- } finally {
566
- this.unsubscribe();
567
- }
568
- };
569
- return Subscriber2;
570
- }(Subscription);
571
- var _bind = Function.prototype.bind;
572
- function bind(fn, thisArg) {
573
- return _bind.call(fn, thisArg);
574
- }
575
- var ConsumerObserver = function() {
576
- function ConsumerObserver2(partialObserver) {
577
- this.partialObserver = partialObserver;
578
- }
579
- ConsumerObserver2.prototype.next = function(value) {
580
- var partialObserver = this.partialObserver;
581
- if (partialObserver.next) {
582
- try {
583
- partialObserver.next(value);
584
- } catch (error) {
585
- handleUnhandledError(error);
586
- }
587
- }
588
- };
589
- ConsumerObserver2.prototype.error = function(err) {
590
- var partialObserver = this.partialObserver;
591
- if (partialObserver.error) {
592
- try {
593
- partialObserver.error(err);
594
- } catch (error) {
595
- handleUnhandledError(error);
596
- }
597
- } else {
598
- handleUnhandledError(err);
599
- }
600
- };
601
- ConsumerObserver2.prototype.complete = function() {
602
- var partialObserver = this.partialObserver;
603
- if (partialObserver.complete) {
604
- try {
605
- partialObserver.complete();
606
- } catch (error) {
607
- handleUnhandledError(error);
608
- }
609
- }
610
- };
611
- return ConsumerObserver2;
612
- }();
613
- var SafeSubscriber = function(_super) {
614
- __extends(SafeSubscriber2, _super);
615
- function SafeSubscriber2(observerOrNext, error, complete) {
616
- var _this = _super.call(this) || this;
617
- var partialObserver;
618
- if (isFunction(observerOrNext) || !observerOrNext) {
619
- partialObserver = {
620
- next: observerOrNext !== null && observerOrNext !== undefined ? observerOrNext : undefined,
621
- error: error !== null && error !== undefined ? error : undefined,
622
- complete: complete !== null && complete !== undefined ? complete : undefined
623
- };
624
- } else {
625
- var context_1;
626
- if (_this && config.useDeprecatedNextContext) {
627
- context_1 = Object.create(observerOrNext);
628
- context_1.unsubscribe = function() {
629
- return _this.unsubscribe();
630
- };
631
- partialObserver = {
632
- next: observerOrNext.next && bind(observerOrNext.next, context_1),
633
- error: observerOrNext.error && bind(observerOrNext.error, context_1),
634
- complete: observerOrNext.complete && bind(observerOrNext.complete, context_1)
635
- };
636
- } else {
637
- partialObserver = observerOrNext;
638
- }
639
- }
640
- _this.destination = new ConsumerObserver(partialObserver);
641
- return _this;
642
- }
643
- return SafeSubscriber2;
644
- }(Subscriber);
645
- function handleUnhandledError(error) {
646
- if (config.useDeprecatedSynchronousErrorHandling) {
647
- captureError(error);
648
- } else {
649
- reportUnhandledError(error);
650
- }
651
- }
652
- function defaultErrorHandler(err) {
653
- throw err;
654
- }
655
- function handleStoppedNotification(notification, subscriber) {
656
- var onStoppedNotification = config.onStoppedNotification;
657
- onStoppedNotification && timeoutProvider.setTimeout(function() {
658
- return onStoppedNotification(notification, subscriber);
659
- });
660
- }
661
- var EMPTY_OBSERVER = {
662
- closed: true,
663
- next: noop,
664
- error: defaultErrorHandler,
665
- complete: noop
666
- };
667
-
668
- // node_modules/rxjs/dist/esm5/internal/symbol/observable.js
669
- var observable = function() {
670
- return typeof Symbol === "function" && Symbol.observable || "@@observable";
671
- }();
672
-
673
- // node_modules/rxjs/dist/esm5/internal/util/identity.js
674
- function identity(x) {
675
- return x;
676
- }
677
-
678
- // node_modules/rxjs/dist/esm5/internal/util/pipe.js
679
- function pipeFromArray(fns) {
680
- if (fns.length === 0) {
681
- return identity;
682
- }
683
- if (fns.length === 1) {
684
- return fns[0];
685
- }
686
- return function piped(input) {
687
- return fns.reduce(function(prev, fn) {
688
- return fn(prev);
689
- }, input);
690
- };
691
- }
692
-
693
- // node_modules/rxjs/dist/esm5/internal/Observable.js
694
- var Observable = function() {
695
- function Observable2(subscribe) {
696
- if (subscribe) {
697
- this._subscribe = subscribe;
698
- }
699
- }
700
- Observable2.prototype.lift = function(operator) {
701
- var observable2 = new Observable2;
702
- observable2.source = this;
703
- observable2.operator = operator;
704
- return observable2;
705
- };
706
- Observable2.prototype.subscribe = function(observerOrNext, error, complete) {
707
- var _this = this;
708
- var subscriber = isSubscriber(observerOrNext) ? observerOrNext : new SafeSubscriber(observerOrNext, error, complete);
709
- errorContext(function() {
710
- var _a = _this, operator = _a.operator, source = _a.source;
711
- subscriber.add(operator ? operator.call(subscriber, source) : source ? _this._subscribe(subscriber) : _this._trySubscribe(subscriber));
712
- });
713
- return subscriber;
714
- };
715
- Observable2.prototype._trySubscribe = function(sink) {
716
- try {
717
- return this._subscribe(sink);
718
- } catch (err) {
719
- sink.error(err);
720
- }
721
- };
722
- Observable2.prototype.forEach = function(next, promiseCtor) {
723
- var _this = this;
724
- promiseCtor = getPromiseCtor(promiseCtor);
725
- return new promiseCtor(function(resolve, reject) {
726
- var subscriber = new SafeSubscriber({
727
- next: function(value) {
728
- try {
729
- next(value);
730
- } catch (err) {
731
- reject(err);
732
- subscriber.unsubscribe();
733
- }
734
- },
735
- error: reject,
736
- complete: resolve
737
- });
738
- _this.subscribe(subscriber);
739
- });
740
- };
741
- Observable2.prototype._subscribe = function(subscriber) {
742
- var _a;
743
- return (_a = this.source) === null || _a === undefined ? undefined : _a.subscribe(subscriber);
744
- };
745
- Observable2.prototype[observable] = function() {
746
- return this;
747
- };
748
- Observable2.prototype.pipe = function() {
749
- var operations = [];
750
- for (var _i = 0;_i < arguments.length; _i++) {
751
- operations[_i] = arguments[_i];
752
- }
753
- return pipeFromArray(operations)(this);
754
- };
755
- Observable2.prototype.toPromise = function(promiseCtor) {
756
- var _this = this;
757
- promiseCtor = getPromiseCtor(promiseCtor);
758
- return new promiseCtor(function(resolve, reject) {
759
- var value;
760
- _this.subscribe(function(x) {
761
- return value = x;
762
- }, function(err) {
763
- return reject(err);
764
- }, function() {
765
- return resolve(value);
766
- });
767
- });
768
- };
769
- Observable2.create = function(subscribe) {
770
- return new Observable2(subscribe);
771
- };
772
- return Observable2;
773
- }();
774
- function getPromiseCtor(promiseCtor) {
775
- var _a;
776
- return (_a = promiseCtor !== null && promiseCtor !== undefined ? promiseCtor : config.Promise) !== null && _a !== undefined ? _a : Promise;
777
- }
778
- function isObserver(value) {
779
- return value && isFunction(value.next) && isFunction(value.error) && isFunction(value.complete);
780
- }
781
- function isSubscriber(value) {
782
- return value && value instanceof Subscriber || isObserver(value) && isSubscription(value);
783
- }
784
- // node_modules/rxjs/dist/esm5/internal/util/ObjectUnsubscribedError.js
785
- var ObjectUnsubscribedError = createErrorClass(function(_super) {
786
- return function ObjectUnsubscribedErrorImpl() {
787
- _super(this);
788
- this.name = "ObjectUnsubscribedError";
789
- this.message = "object unsubscribed";
790
- };
791
- });
792
-
793
- // node_modules/rxjs/dist/esm5/internal/Subject.js
794
- var Subject = function(_super) {
795
- __extends(Subject2, _super);
796
- function Subject2() {
797
- var _this = _super.call(this) || this;
798
- _this.closed = false;
799
- _this.currentObservers = null;
800
- _this.observers = [];
801
- _this.isStopped = false;
802
- _this.hasError = false;
803
- _this.thrownError = null;
804
- return _this;
805
- }
806
- Subject2.prototype.lift = function(operator) {
807
- var subject = new AnonymousSubject(this, this);
808
- subject.operator = operator;
809
- return subject;
810
- };
811
- Subject2.prototype._throwIfClosed = function() {
812
- if (this.closed) {
813
- throw new ObjectUnsubscribedError;
814
- }
815
- };
816
- Subject2.prototype.next = function(value) {
817
- var _this = this;
818
- errorContext(function() {
819
- var e_1, _a;
820
- _this._throwIfClosed();
821
- if (!_this.isStopped) {
822
- if (!_this.currentObservers) {
823
- _this.currentObservers = Array.from(_this.observers);
824
- }
825
- try {
826
- for (var _b = __values(_this.currentObservers), _c = _b.next();!_c.done; _c = _b.next()) {
827
- var observer = _c.value;
828
- observer.next(value);
829
- }
830
- } catch (e_1_1) {
831
- e_1 = { error: e_1_1 };
832
- } finally {
833
- try {
834
- if (_c && !_c.done && (_a = _b.return))
835
- _a.call(_b);
836
- } finally {
837
- if (e_1)
838
- throw e_1.error;
839
- }
840
- }
841
- }
842
- });
843
- };
844
- Subject2.prototype.error = function(err) {
845
- var _this = this;
846
- errorContext(function() {
847
- _this._throwIfClosed();
848
- if (!_this.isStopped) {
849
- _this.hasError = _this.isStopped = true;
850
- _this.thrownError = err;
851
- var observers = _this.observers;
852
- while (observers.length) {
853
- observers.shift().error(err);
854
- }
855
- }
856
- });
857
- };
858
- Subject2.prototype.complete = function() {
859
- var _this = this;
860
- errorContext(function() {
861
- _this._throwIfClosed();
862
- if (!_this.isStopped) {
863
- _this.isStopped = true;
864
- var observers = _this.observers;
865
- while (observers.length) {
866
- observers.shift().complete();
867
- }
868
- }
869
- });
870
- };
871
- Subject2.prototype.unsubscribe = function() {
872
- this.isStopped = this.closed = true;
873
- this.observers = this.currentObservers = null;
874
- };
875
- Object.defineProperty(Subject2.prototype, "observed", {
876
- get: function() {
877
- var _a;
878
- return ((_a = this.observers) === null || _a === undefined ? undefined : _a.length) > 0;
879
- },
880
- enumerable: false,
881
- configurable: true
882
- });
883
- Subject2.prototype._trySubscribe = function(subscriber) {
884
- this._throwIfClosed();
885
- return _super.prototype._trySubscribe.call(this, subscriber);
886
- };
887
- Subject2.prototype._subscribe = function(subscriber) {
888
- this._throwIfClosed();
889
- this._checkFinalizedStatuses(subscriber);
890
- return this._innerSubscribe(subscriber);
891
- };
892
- Subject2.prototype._innerSubscribe = function(subscriber) {
893
- var _this = this;
894
- var _a = this, hasError = _a.hasError, isStopped = _a.isStopped, observers = _a.observers;
895
- if (hasError || isStopped) {
896
- return EMPTY_SUBSCRIPTION;
897
- }
898
- this.currentObservers = null;
899
- observers.push(subscriber);
900
- return new Subscription(function() {
901
- _this.currentObservers = null;
902
- arrRemove(observers, subscriber);
903
- });
904
- };
905
- Subject2.prototype._checkFinalizedStatuses = function(subscriber) {
906
- var _a = this, hasError = _a.hasError, thrownError = _a.thrownError, isStopped = _a.isStopped;
907
- if (hasError) {
908
- subscriber.error(thrownError);
909
- } else if (isStopped) {
910
- subscriber.complete();
911
- }
912
- };
913
- Subject2.prototype.asObservable = function() {
914
- var observable2 = new Observable;
915
- observable2.source = this;
916
- return observable2;
917
- };
918
- Subject2.create = function(destination, source) {
919
- return new AnonymousSubject(destination, source);
920
- };
921
- return Subject2;
922
- }(Observable);
923
- var AnonymousSubject = function(_super) {
924
- __extends(AnonymousSubject2, _super);
925
- function AnonymousSubject2(destination, source) {
926
- var _this = _super.call(this) || this;
927
- _this.destination = destination;
928
- _this.source = source;
929
- return _this;
930
- }
931
- AnonymousSubject2.prototype.next = function(value) {
932
- var _a, _b;
933
- (_b = (_a = this.destination) === null || _a === undefined ? undefined : _a.next) === null || _b === undefined || _b.call(_a, value);
934
- };
935
- AnonymousSubject2.prototype.error = function(err) {
936
- var _a, _b;
937
- (_b = (_a = this.destination) === null || _a === undefined ? undefined : _a.error) === null || _b === undefined || _b.call(_a, err);
938
- };
939
- AnonymousSubject2.prototype.complete = function() {
940
- var _a, _b;
941
- (_b = (_a = this.destination) === null || _a === undefined ? undefined : _a.complete) === null || _b === undefined || _b.call(_a);
942
- };
943
- AnonymousSubject2.prototype._subscribe = function(subscriber) {
944
- var _a, _b;
945
- return (_b = (_a = this.source) === null || _a === undefined ? undefined : _a.subscribe(subscriber)) !== null && _b !== undefined ? _b : EMPTY_SUBSCRIPTION;
946
- };
947
- return AnonymousSubject2;
948
- }(Subject);
949
- // node_modules/rxjs/dist/esm5/internal/BehaviorSubject.js
950
- var BehaviorSubject = function(_super) {
951
- __extends(BehaviorSubject2, _super);
952
- function BehaviorSubject2(_value) {
953
- var _this = _super.call(this) || this;
954
- _this._value = _value;
955
- return _this;
956
- }
957
- Object.defineProperty(BehaviorSubject2.prototype, "value", {
958
- get: function() {
959
- return this.getValue();
960
- },
961
- enumerable: false,
962
- configurable: true
963
- });
964
- BehaviorSubject2.prototype._subscribe = function(subscriber) {
965
- var subscription = _super.prototype._subscribe.call(this, subscriber);
966
- !subscription.closed && subscriber.next(this._value);
967
- return subscription;
968
- };
969
- BehaviorSubject2.prototype.getValue = function() {
970
- var _a = this, hasError = _a.hasError, thrownError = _a.thrownError, _value = _a._value;
971
- if (hasError) {
972
- throw thrownError;
973
- }
974
- this._throwIfClosed();
975
- return _value;
976
- };
977
- BehaviorSubject2.prototype.next = function(value) {
978
- _super.prototype.next.call(this, this._value = value);
979
- };
980
- return BehaviorSubject2;
981
- }(Subject);
982
- // node_modules/rxjs/dist/esm5/internal/util/EmptyError.js
983
- var EmptyError = createErrorClass(function(_super) {
984
- return function EmptyErrorImpl() {
985
- _super(this);
986
- this.name = "EmptyError";
987
- this.message = "no elements in sequence";
988
- };
989
- });
990
-
991
- // node_modules/rxjs/dist/esm5/internal/lastValueFrom.js
992
- function lastValueFrom(source, config2) {
993
- var hasConfig = typeof config2 === "object";
994
- return new Promise(function(resolve, reject) {
995
- var _hasValue = false;
996
- var _value;
997
- source.subscribe({
998
- next: function(value) {
999
- _value = value;
1000
- _hasValue = true;
1001
- },
1002
- error: reject,
1003
- complete: function() {
1004
- if (_hasValue) {
1005
- resolve(_value);
1006
- } else if (hasConfig) {
1007
- resolve(config2.defaultValue);
1008
- } else {
1009
- reject(new EmptyError);
1010
- }
1011
- }
1012
- });
1013
- });
1014
- }
1015
- // node_modules/rxjs/dist/esm5/internal/firstValueFrom.js
1016
- function firstValueFrom(source, config2) {
1017
- var hasConfig = typeof config2 === "object";
1018
- return new Promise(function(resolve, reject) {
1019
- var subscriber = new SafeSubscriber({
1020
- next: function(value) {
1021
- resolve(value);
1022
- subscriber.unsubscribe();
1023
- },
1024
- error: reject,
1025
- complete: function() {
1026
- if (hasConfig) {
1027
- resolve(config2.defaultValue);
1028
- } else {
1029
- reject(new EmptyError);
1030
- }
1031
- }
1032
- });
1033
- source.subscribe(subscriber);
1034
- });
1035
- }
1036
- // node_modules/rxjs/dist/esm5/internal/util/argsArgArrayOrObject.js
1037
- var isArray = Array.isArray;
1038
- var getPrototypeOf = Object.getPrototypeOf;
1039
- var objectProto = Object.prototype;
1040
- var getKeys = Object.keys;
1041
- function argsArgArrayOrObject(args) {
1042
- if (args.length === 1) {
1043
- var first_1 = args[0];
1044
- if (isArray(first_1)) {
1045
- return { args: first_1, keys: null };
1046
- }
1047
- if (isPOJO(first_1)) {
1048
- var keys = getKeys(first_1);
1049
- return {
1050
- args: keys.map(function(key) {
1051
- return first_1[key];
1052
- }),
1053
- keys
1054
- };
1055
- }
1056
- }
1057
- return { args, keys: null };
1058
- }
1059
- function isPOJO(obj) {
1060
- return obj && typeof obj === "object" && getPrototypeOf(obj) === objectProto;
1061
- }
1062
-
1063
- // node_modules/rxjs/dist/esm5/internal/util/isArrayLike.js
1064
- var isArrayLike = function(x) {
1065
- return x && typeof x.length === "number" && typeof x !== "function";
1066
- };
1067
-
1068
- // node_modules/rxjs/dist/esm5/internal/util/isPromise.js
1069
- function isPromise(value) {
1070
- return isFunction(value === null || value === undefined ? undefined : value.then);
1071
- }
1072
-
1073
- // node_modules/rxjs/dist/esm5/internal/util/isInteropObservable.js
1074
- function isInteropObservable(input) {
1075
- return isFunction(input[observable]);
1076
- }
1077
-
1078
- // node_modules/rxjs/dist/esm5/internal/util/isAsyncIterable.js
1079
- function isAsyncIterable(obj) {
1080
- return Symbol.asyncIterator && isFunction(obj === null || obj === undefined ? undefined : obj[Symbol.asyncIterator]);
1081
- }
1082
-
1083
- // node_modules/rxjs/dist/esm5/internal/util/throwUnobservableError.js
1084
- function createInvalidObservableTypeError(input) {
1085
- 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.");
1086
- }
1087
-
1088
- // node_modules/rxjs/dist/esm5/internal/symbol/iterator.js
1089
- function getSymbolIterator() {
1090
- if (typeof Symbol !== "function" || !Symbol.iterator) {
1091
- return "@@iterator";
1092
- }
1093
- return Symbol.iterator;
1094
- }
1095
- var iterator = getSymbolIterator();
1096
-
1097
- // node_modules/rxjs/dist/esm5/internal/util/isIterable.js
1098
- function isIterable(input) {
1099
- return isFunction(input === null || input === undefined ? undefined : input[iterator]);
1100
- }
1101
-
1102
- // node_modules/rxjs/dist/esm5/internal/util/isReadableStreamLike.js
1103
- function readableStreamLikeToAsyncGenerator(readableStream) {
1104
- return __asyncGenerator(this, arguments, function readableStreamLikeToAsyncGenerator_1() {
1105
- var reader, _a, value, done;
1106
- return __generator(this, function(_b) {
1107
- switch (_b.label) {
1108
- case 0:
1109
- reader = readableStream.getReader();
1110
- _b.label = 1;
1111
- case 1:
1112
- _b.trys.push([1, , 9, 10]);
1113
- _b.label = 2;
1114
- case 2:
1115
- if (false)
1116
- ;
1117
- return [4, __await(reader.read())];
1118
- case 3:
1119
- _a = _b.sent(), value = _a.value, done = _a.done;
1120
- if (!done)
1121
- return [3, 5];
1122
- return [4, __await(undefined)];
1123
- case 4:
1124
- return [2, _b.sent()];
1125
- case 5:
1126
- return [4, __await(value)];
1127
- case 6:
1128
- return [4, _b.sent()];
1129
- case 7:
1130
- _b.sent();
1131
- return [3, 2];
1132
- case 8:
1133
- return [3, 10];
1134
- case 9:
1135
- reader.releaseLock();
1136
- return [7];
1137
- case 10:
1138
- return [2];
1139
- }
1140
- });
1141
- });
1142
- }
1143
- function isReadableStreamLike(obj) {
1144
- return isFunction(obj === null || obj === undefined ? undefined : obj.getReader);
1145
- }
1146
-
1147
- // node_modules/rxjs/dist/esm5/internal/observable/innerFrom.js
1148
- function innerFrom(input) {
1149
- if (input instanceof Observable) {
1150
- return input;
1151
- }
1152
- if (input != null) {
1153
- if (isInteropObservable(input)) {
1154
- return fromInteropObservable(input);
1155
- }
1156
- if (isArrayLike(input)) {
1157
- return fromArrayLike(input);
1158
- }
1159
- if (isPromise(input)) {
1160
- return fromPromise(input);
1161
- }
1162
- if (isAsyncIterable(input)) {
1163
- return fromAsyncIterable(input);
1164
- }
1165
- if (isIterable(input)) {
1166
- return fromIterable(input);
1167
- }
1168
- if (isReadableStreamLike(input)) {
1169
- return fromReadableStreamLike(input);
1170
- }
1171
- }
1172
- throw createInvalidObservableTypeError(input);
1173
- }
1174
- function fromInteropObservable(obj) {
1175
- return new Observable(function(subscriber) {
1176
- var obs = obj[observable]();
1177
- if (isFunction(obs.subscribe)) {
1178
- return obs.subscribe(subscriber);
1179
- }
1180
- throw new TypeError("Provided object does not correctly implement Symbol.observable");
1181
- });
1182
- }
1183
- function fromArrayLike(array) {
1184
- return new Observable(function(subscriber) {
1185
- for (var i = 0;i < array.length && !subscriber.closed; i++) {
1186
- subscriber.next(array[i]);
1187
- }
1188
- subscriber.complete();
1189
- });
1190
- }
1191
- function fromPromise(promise) {
1192
- return new Observable(function(subscriber) {
1193
- promise.then(function(value) {
1194
- if (!subscriber.closed) {
1195
- subscriber.next(value);
1196
- subscriber.complete();
1197
- }
1198
- }, function(err) {
1199
- return subscriber.error(err);
1200
- }).then(null, reportUnhandledError);
1201
- });
1202
- }
1203
- function fromIterable(iterable) {
1204
- return new Observable(function(subscriber) {
1205
- var e_1, _a;
1206
- try {
1207
- for (var iterable_1 = __values(iterable), iterable_1_1 = iterable_1.next();!iterable_1_1.done; iterable_1_1 = iterable_1.next()) {
1208
- var value = iterable_1_1.value;
1209
- subscriber.next(value);
1210
- if (subscriber.closed) {
1211
- return;
1212
- }
1213
- }
1214
- } catch (e_1_1) {
1215
- e_1 = { error: e_1_1 };
1216
- } finally {
1217
- try {
1218
- if (iterable_1_1 && !iterable_1_1.done && (_a = iterable_1.return))
1219
- _a.call(iterable_1);
1220
- } finally {
1221
- if (e_1)
1222
- throw e_1.error;
1223
- }
1224
- }
1225
- subscriber.complete();
1226
- });
1227
- }
1228
- function fromAsyncIterable(asyncIterable) {
1229
- return new Observable(function(subscriber) {
1230
- process(asyncIterable, subscriber).catch(function(err) {
1231
- return subscriber.error(err);
1232
- });
1233
- });
1234
- }
1235
- function fromReadableStreamLike(readableStream) {
1236
- return fromAsyncIterable(readableStreamLikeToAsyncGenerator(readableStream));
1237
- }
1238
- function process(asyncIterable, subscriber) {
1239
- var asyncIterable_1, asyncIterable_1_1;
1240
- var e_2, _a;
1241
- return __awaiter(this, undefined, undefined, function() {
1242
- var value, e_2_1;
1243
- return __generator(this, function(_b) {
1244
- switch (_b.label) {
1245
- case 0:
1246
- _b.trys.push([0, 5, 6, 11]);
1247
- asyncIterable_1 = __asyncValues(asyncIterable);
1248
- _b.label = 1;
1249
- case 1:
1250
- return [4, asyncIterable_1.next()];
1251
- case 2:
1252
- if (!(asyncIterable_1_1 = _b.sent(), !asyncIterable_1_1.done))
1253
- return [3, 4];
1254
- value = asyncIterable_1_1.value;
1255
- subscriber.next(value);
1256
- if (subscriber.closed) {
1257
- return [2];
1258
- }
1259
- _b.label = 3;
1260
- case 3:
1261
- return [3, 1];
1262
- case 4:
1263
- return [3, 11];
1264
- case 5:
1265
- e_2_1 = _b.sent();
1266
- e_2 = { error: e_2_1 };
1267
- return [3, 11];
1268
- case 6:
1269
- _b.trys.push([6, , 9, 10]);
1270
- if (!(asyncIterable_1_1 && !asyncIterable_1_1.done && (_a = asyncIterable_1.return)))
1271
- return [3, 8];
1272
- return [4, _a.call(asyncIterable_1)];
1273
- case 7:
1274
- _b.sent();
1275
- _b.label = 8;
1276
- case 8:
1277
- return [3, 10];
1278
- case 9:
1279
- if (e_2)
1280
- throw e_2.error;
1281
- return [7];
1282
- case 10:
1283
- return [7];
1284
- case 11:
1285
- subscriber.complete();
1286
- return [2];
1287
- }
1288
- });
1289
- });
1290
- }
1291
-
1292
- // node_modules/rxjs/dist/esm5/internal/util/executeSchedule.js
1293
- function executeSchedule(parentSubscription, scheduler, work, delay, repeat) {
1294
- if (delay === undefined) {
1295
- delay = 0;
1296
- }
1297
- if (repeat === undefined) {
1298
- repeat = false;
1299
- }
1300
- var scheduleSubscription = scheduler.schedule(function() {
1301
- work();
1302
- if (repeat) {
1303
- parentSubscription.add(this.schedule(null, delay));
1304
- } else {
1305
- this.unsubscribe();
1306
- }
1307
- }, delay);
1308
- parentSubscription.add(scheduleSubscription);
1309
- if (!repeat) {
1310
- return scheduleSubscription;
1311
- }
1312
- }
1313
-
1314
- // node_modules/rxjs/dist/esm5/internal/util/lift.js
1315
- function hasLift(source) {
1316
- return isFunction(source === null || source === undefined ? undefined : source.lift);
1317
- }
1318
- function operate(init) {
1319
- return function(source) {
1320
- if (hasLift(source)) {
1321
- return source.lift(function(liftedSource) {
1322
- try {
1323
- return init(liftedSource, this);
1324
- } catch (err) {
1325
- this.error(err);
1326
- }
1327
- });
1328
- }
1329
- throw new TypeError("Unable to lift unknown Observable type");
1330
- };
1331
- }
1332
-
1333
- // node_modules/rxjs/dist/esm5/internal/operators/OperatorSubscriber.js
1334
- function createOperatorSubscriber(destination, onNext, onComplete, onError, onFinalize) {
1335
- return new OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize);
1336
- }
1337
- var OperatorSubscriber = function(_super) {
1338
- __extends(OperatorSubscriber2, _super);
1339
- function OperatorSubscriber2(destination, onNext, onComplete, onError, onFinalize, shouldUnsubscribe) {
1340
- var _this = _super.call(this, destination) || this;
1341
- _this.onFinalize = onFinalize;
1342
- _this.shouldUnsubscribe = shouldUnsubscribe;
1343
- _this._next = onNext ? function(value) {
1344
- try {
1345
- onNext(value);
1346
- } catch (err) {
1347
- destination.error(err);
1348
- }
1349
- } : _super.prototype._next;
1350
- _this._error = onError ? function(err) {
1351
- try {
1352
- onError(err);
1353
- } catch (err2) {
1354
- destination.error(err2);
1355
- } finally {
1356
- this.unsubscribe();
1357
- }
1358
- } : _super.prototype._error;
1359
- _this._complete = onComplete ? function() {
1360
- try {
1361
- onComplete();
1362
- } catch (err) {
1363
- destination.error(err);
1364
- } finally {
1365
- this.unsubscribe();
1366
- }
1367
- } : _super.prototype._complete;
1368
- return _this;
1369
- }
1370
- OperatorSubscriber2.prototype.unsubscribe = function() {
1371
- var _a;
1372
- if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {
1373
- var closed_1 = this.closed;
1374
- _super.prototype.unsubscribe.call(this);
1375
- !closed_1 && ((_a = this.onFinalize) === null || _a === undefined || _a.call(this));
1376
- }
1377
- };
1378
- return OperatorSubscriber2;
1379
- }(Subscriber);
1380
-
1381
- // node_modules/rxjs/dist/esm5/internal/operators/observeOn.js
1382
- function observeOn(scheduler, delay) {
1383
- if (delay === undefined) {
1384
- delay = 0;
1385
- }
1386
- return operate(function(source, subscriber) {
1387
- source.subscribe(createOperatorSubscriber(subscriber, function(value) {
1388
- return executeSchedule(subscriber, scheduler, function() {
1389
- return subscriber.next(value);
1390
- }, delay);
1391
- }, function() {
1392
- return executeSchedule(subscriber, scheduler, function() {
1393
- return subscriber.complete();
1394
- }, delay);
1395
- }, function(err) {
1396
- return executeSchedule(subscriber, scheduler, function() {
1397
- return subscriber.error(err);
1398
- }, delay);
1399
- }));
1400
- });
1401
- }
1402
-
1403
- // node_modules/rxjs/dist/esm5/internal/operators/subscribeOn.js
1404
- function subscribeOn(scheduler, delay) {
1405
- if (delay === undefined) {
1406
- delay = 0;
1407
- }
1408
- return operate(function(source, subscriber) {
1409
- subscriber.add(scheduler.schedule(function() {
1410
- return source.subscribe(subscriber);
1411
- }, delay));
1412
- });
1413
- }
1414
-
1415
- // node_modules/rxjs/dist/esm5/internal/scheduled/scheduleObservable.js
1416
- function scheduleObservable(input, scheduler) {
1417
- return innerFrom(input).pipe(subscribeOn(scheduler), observeOn(scheduler));
1418
- }
1419
-
1420
- // node_modules/rxjs/dist/esm5/internal/scheduled/schedulePromise.js
1421
- function schedulePromise(input, scheduler) {
1422
- return innerFrom(input).pipe(subscribeOn(scheduler), observeOn(scheduler));
1423
- }
1424
-
1425
- // node_modules/rxjs/dist/esm5/internal/scheduled/scheduleArray.js
1426
- function scheduleArray(input, scheduler) {
1427
- return new Observable(function(subscriber) {
1428
- var i = 0;
1429
- return scheduler.schedule(function() {
1430
- if (i === input.length) {
1431
- subscriber.complete();
1432
- } else {
1433
- subscriber.next(input[i++]);
1434
- if (!subscriber.closed) {
1435
- this.schedule();
1436
- }
1437
- }
1438
- });
1439
- });
1440
- }
1441
-
1442
- // node_modules/rxjs/dist/esm5/internal/scheduled/scheduleIterable.js
1443
- function scheduleIterable(input, scheduler) {
1444
- return new Observable(function(subscriber) {
1445
- var iterator2;
1446
- executeSchedule(subscriber, scheduler, function() {
1447
- iterator2 = input[iterator]();
1448
- executeSchedule(subscriber, scheduler, function() {
1449
- var _a;
1450
- var value;
1451
- var done;
1452
- try {
1453
- _a = iterator2.next(), value = _a.value, done = _a.done;
1454
- } catch (err) {
1455
- subscriber.error(err);
1456
- return;
1457
- }
1458
- if (done) {
1459
- subscriber.complete();
1460
- } else {
1461
- subscriber.next(value);
1462
- }
1463
- }, 0, true);
1464
- });
1465
- return function() {
1466
- return isFunction(iterator2 === null || iterator2 === undefined ? undefined : iterator2.return) && iterator2.return();
1467
- };
1468
- });
1469
- }
1470
-
1471
- // node_modules/rxjs/dist/esm5/internal/scheduled/scheduleAsyncIterable.js
1472
- function scheduleAsyncIterable(input, scheduler) {
1473
- if (!input) {
1474
- throw new Error("Iterable cannot be null");
1475
- }
1476
- return new Observable(function(subscriber) {
1477
- executeSchedule(subscriber, scheduler, function() {
1478
- var iterator2 = input[Symbol.asyncIterator]();
1479
- executeSchedule(subscriber, scheduler, function() {
1480
- iterator2.next().then(function(result) {
1481
- if (result.done) {
1482
- subscriber.complete();
1483
- } else {
1484
- subscriber.next(result.value);
1485
- }
1486
- });
1487
- }, 0, true);
1488
- });
1489
- });
1490
- }
1491
-
1492
- // node_modules/rxjs/dist/esm5/internal/scheduled/scheduleReadableStreamLike.js
1493
- function scheduleReadableStreamLike(input, scheduler) {
1494
- return scheduleAsyncIterable(readableStreamLikeToAsyncGenerator(input), scheduler);
1495
- }
1496
-
1497
- // node_modules/rxjs/dist/esm5/internal/scheduled/scheduled.js
1498
- function scheduled(input, scheduler) {
1499
- if (input != null) {
1500
- if (isInteropObservable(input)) {
1501
- return scheduleObservable(input, scheduler);
1502
- }
1503
- if (isArrayLike(input)) {
1504
- return scheduleArray(input, scheduler);
1505
- }
1506
- if (isPromise(input)) {
1507
- return schedulePromise(input, scheduler);
1508
- }
1509
- if (isAsyncIterable(input)) {
1510
- return scheduleAsyncIterable(input, scheduler);
1511
- }
1512
- if (isIterable(input)) {
1513
- return scheduleIterable(input, scheduler);
1514
- }
1515
- if (isReadableStreamLike(input)) {
1516
- return scheduleReadableStreamLike(input, scheduler);
1517
- }
1518
- }
1519
- throw createInvalidObservableTypeError(input);
1520
- }
1521
-
1522
- // node_modules/rxjs/dist/esm5/internal/observable/from.js
1523
- function from(input, scheduler) {
1524
- return scheduler ? scheduled(input, scheduler) : innerFrom(input);
1525
- }
1526
-
1527
- // node_modules/rxjs/dist/esm5/internal/operators/map.js
1528
- function map(project, thisArg) {
1529
- return operate(function(source, subscriber) {
1530
- var index = 0;
1531
- source.subscribe(createOperatorSubscriber(subscriber, function(value) {
1532
- subscriber.next(project.call(thisArg, value, index++));
1533
- }));
1534
- });
1535
- }
1536
-
1537
- // node_modules/rxjs/dist/esm5/internal/util/mapOneOrManyArgs.js
1538
- var isArray2 = Array.isArray;
1539
- function callOrApply(fn, args) {
1540
- return isArray2(args) ? fn.apply(undefined, __spreadArray([], __read(args))) : fn(args);
1541
- }
1542
- function mapOneOrManyArgs(fn) {
1543
- return map(function(args) {
1544
- return callOrApply(fn, args);
1545
- });
1546
- }
1547
-
1548
- // node_modules/rxjs/dist/esm5/internal/util/isScheduler.js
1549
- function isScheduler(value) {
1550
- return value && isFunction(value.schedule);
1551
- }
1552
-
1553
- // node_modules/rxjs/dist/esm5/internal/util/args.js
1554
- function last(arr) {
1555
- return arr[arr.length - 1];
1556
- }
1557
- function popResultSelector(args) {
1558
- return isFunction(last(args)) ? args.pop() : undefined;
1559
- }
1560
- function popScheduler(args) {
1561
- return isScheduler(last(args)) ? args.pop() : undefined;
1562
- }
1563
- function popNumber(args, defaultValue) {
1564
- return typeof last(args) === "number" ? args.pop() : defaultValue;
1565
- }
1566
-
1567
- // node_modules/rxjs/dist/esm5/internal/util/createObject.js
1568
- function createObject(keys, values) {
1569
- return keys.reduce(function(result, key, i) {
1570
- return result[key] = values[i], result;
1571
- }, {});
1572
- }
1573
-
1574
- // node_modules/rxjs/dist/esm5/internal/observable/combineLatest.js
1575
- function combineLatest() {
1576
- var args = [];
1577
- for (var _i = 0;_i < arguments.length; _i++) {
1578
- args[_i] = arguments[_i];
1579
- }
1580
- var scheduler = popScheduler(args);
1581
- var resultSelector = popResultSelector(args);
1582
- var _a = argsArgArrayOrObject(args), observables = _a.args, keys = _a.keys;
1583
- if (observables.length === 0) {
1584
- return from([], scheduler);
1585
- }
1586
- var result = new Observable(combineLatestInit(observables, scheduler, keys ? function(values) {
1587
- return createObject(keys, values);
1588
- } : identity));
1589
- return resultSelector ? result.pipe(mapOneOrManyArgs(resultSelector)) : result;
1590
- }
1591
- function combineLatestInit(observables, scheduler, valueTransform) {
1592
- if (valueTransform === undefined) {
1593
- valueTransform = identity;
1594
- }
1595
- return function(subscriber) {
1596
- maybeSchedule(scheduler, function() {
1597
- var length = observables.length;
1598
- var values = new Array(length);
1599
- var active = length;
1600
- var remainingFirstValues = length;
1601
- var _loop_1 = function(i2) {
1602
- maybeSchedule(scheduler, function() {
1603
- var source = from(observables[i2], scheduler);
1604
- var hasFirstValue = false;
1605
- source.subscribe(createOperatorSubscriber(subscriber, function(value) {
1606
- values[i2] = value;
1607
- if (!hasFirstValue) {
1608
- hasFirstValue = true;
1609
- remainingFirstValues--;
1610
- }
1611
- if (!remainingFirstValues) {
1612
- subscriber.next(valueTransform(values.slice()));
1613
- }
1614
- }, function() {
1615
- if (!--active) {
1616
- subscriber.complete();
1617
- }
1618
- }));
1619
- }, subscriber);
1620
- };
1621
- for (var i = 0;i < length; i++) {
1622
- _loop_1(i);
1623
- }
1624
- }, subscriber);
1625
- };
1626
- }
1627
- function maybeSchedule(scheduler, execute, subscription) {
1628
- if (scheduler) {
1629
- executeSchedule(subscription, scheduler, execute);
1630
- } else {
1631
- execute();
1632
- }
1633
- }
1634
- // node_modules/rxjs/dist/esm5/internal/operators/mergeInternals.js
1635
- function mergeInternals(source, subscriber, project, concurrent, onBeforeNext, expand, innerSubScheduler, additionalFinalizer) {
1636
- var buffer = [];
1637
- var active = 0;
1638
- var index = 0;
1639
- var isComplete = false;
1640
- var checkComplete = function() {
1641
- if (isComplete && !buffer.length && !active) {
1642
- subscriber.complete();
1643
- }
1644
- };
1645
- var outerNext = function(value) {
1646
- return active < concurrent ? doInnerSub(value) : buffer.push(value);
1647
- };
1648
- var doInnerSub = function(value) {
1649
- expand && subscriber.next(value);
1650
- active++;
1651
- var innerComplete = false;
1652
- innerFrom(project(value, index++)).subscribe(createOperatorSubscriber(subscriber, function(innerValue) {
1653
- onBeforeNext === null || onBeforeNext === undefined || onBeforeNext(innerValue);
1654
- if (expand) {
1655
- outerNext(innerValue);
1656
- } else {
1657
- subscriber.next(innerValue);
1658
- }
1659
- }, function() {
1660
- innerComplete = true;
1661
- }, undefined, function() {
1662
- if (innerComplete) {
1663
- try {
1664
- active--;
1665
- var _loop_1 = function() {
1666
- var bufferedValue = buffer.shift();
1667
- if (innerSubScheduler) {
1668
- executeSchedule(subscriber, innerSubScheduler, function() {
1669
- return doInnerSub(bufferedValue);
1670
- });
1671
- } else {
1672
- doInnerSub(bufferedValue);
1673
- }
1674
- };
1675
- while (buffer.length && active < concurrent) {
1676
- _loop_1();
1677
- }
1678
- checkComplete();
1679
- } catch (err) {
1680
- subscriber.error(err);
1681
- }
1682
- }
1683
- }));
1684
- };
1685
- source.subscribe(createOperatorSubscriber(subscriber, outerNext, function() {
1686
- isComplete = true;
1687
- checkComplete();
1688
- }));
1689
- return function() {
1690
- additionalFinalizer === null || additionalFinalizer === undefined || additionalFinalizer();
1691
- };
1692
- }
1693
-
1694
- // node_modules/rxjs/dist/esm5/internal/operators/mergeMap.js
1695
- function mergeMap(project, resultSelector, concurrent) {
1696
- if (concurrent === undefined) {
1697
- concurrent = Infinity;
1698
- }
1699
- if (isFunction(resultSelector)) {
1700
- return mergeMap(function(a, i) {
1701
- return map(function(b, ii) {
1702
- return resultSelector(a, b, i, ii);
1703
- })(innerFrom(project(a, i)));
1704
- }, concurrent);
1705
- } else if (typeof resultSelector === "number") {
1706
- concurrent = resultSelector;
1707
- }
1708
- return operate(function(source, subscriber) {
1709
- return mergeInternals(source, subscriber, project, concurrent);
1710
- });
1711
- }
1712
-
1713
- // node_modules/rxjs/dist/esm5/internal/observable/fromEvent.js
1714
- var nodeEventEmitterMethods = ["addListener", "removeListener"];
1715
- var eventTargetMethods = ["addEventListener", "removeEventListener"];
1716
- var jqueryMethods = ["on", "off"];
1717
- function fromEvent(target, eventName, options, resultSelector) {
1718
- if (isFunction(options)) {
1719
- resultSelector = options;
1720
- options = undefined;
1721
- }
1722
- if (resultSelector) {
1723
- return fromEvent(target, eventName, options).pipe(mapOneOrManyArgs(resultSelector));
1724
- }
1725
- var _a = __read(isEventTarget(target) ? eventTargetMethods.map(function(methodName) {
1726
- return function(handler) {
1727
- return target[methodName](eventName, handler, options);
1728
- };
1729
- }) : isNodeStyleEventEmitter(target) ? nodeEventEmitterMethods.map(toCommonHandlerRegistry(target, eventName)) : isJQueryStyleEventEmitter(target) ? jqueryMethods.map(toCommonHandlerRegistry(target, eventName)) : [], 2), add = _a[0], remove = _a[1];
1730
- if (!add) {
1731
- if (isArrayLike(target)) {
1732
- return mergeMap(function(subTarget) {
1733
- return fromEvent(subTarget, eventName, options);
1734
- })(innerFrom(target));
1735
- }
1736
- }
1737
- if (!add) {
1738
- throw new TypeError("Invalid event target");
1739
- }
1740
- return new Observable(function(subscriber) {
1741
- var handler = function() {
1742
- var args = [];
1743
- for (var _i = 0;_i < arguments.length; _i++) {
1744
- args[_i] = arguments[_i];
1745
- }
1746
- return subscriber.next(1 < args.length ? args : args[0]);
1747
- };
1748
- add(handler);
1749
- return function() {
1750
- return remove(handler);
1751
- };
1752
- });
1753
- }
1754
- function toCommonHandlerRegistry(target, eventName) {
1755
- return function(methodName) {
1756
- return function(handler) {
1757
- return target[methodName](eventName, handler);
1758
- };
1759
- };
1760
- }
1761
- function isNodeStyleEventEmitter(target) {
1762
- return isFunction(target.addListener) && isFunction(target.removeListener);
1763
- }
1764
- function isJQueryStyleEventEmitter(target) {
1765
- return isFunction(target.on) && isFunction(target.off);
1766
- }
1767
- function isEventTarget(target) {
1768
- return isFunction(target.addEventListener) && isFunction(target.removeEventListener);
1769
- }
1770
- // node_modules/rxjs/dist/esm5/internal/operators/mergeAll.js
1771
- function mergeAll(concurrent) {
1772
- if (concurrent === undefined) {
1773
- concurrent = Infinity;
1774
- }
1775
- return mergeMap(identity, concurrent);
1776
- }
1777
-
1778
- // node_modules/rxjs/dist/esm5/internal/observable/empty.js
1779
- var EMPTY = new Observable(function(subscriber) {
1780
- return subscriber.complete();
1781
- });
1782
-
1783
- // node_modules/rxjs/dist/esm5/internal/observable/merge.js
1784
- function merge() {
1785
- var args = [];
1786
- for (var _i = 0;_i < arguments.length; _i++) {
1787
- args[_i] = arguments[_i];
1788
- }
1789
- var scheduler = popScheduler(args);
1790
- var concurrent = popNumber(args, Infinity);
1791
- var sources = args;
1792
- return !sources.length ? EMPTY : sources.length === 1 ? innerFrom(sources[0]) : mergeAll(concurrent)(from(sources, scheduler));
1793
- }
1794
- // node_modules/rxjs/dist/esm5/internal/observable/of.js
1795
- function of() {
1796
- var args = [];
1797
- for (var _i = 0;_i < arguments.length; _i++) {
1798
- args[_i] = arguments[_i];
1799
- }
1800
- var scheduler = popScheduler(args);
1801
- return from(args, scheduler);
1802
- }
1803
- // node_modules/rxjs/dist/esm5/internal/operators/catchError.js
1804
- function catchError(selector) {
1805
- return operate(function(source, subscriber) {
1806
- var innerSub = null;
1807
- var syncUnsub = false;
1808
- var handledResult;
1809
- innerSub = source.subscribe(createOperatorSubscriber(subscriber, undefined, undefined, function(err) {
1810
- handledResult = innerFrom(selector(err, catchError(selector)(source)));
1811
- if (innerSub) {
1812
- innerSub.unsubscribe();
1813
- innerSub = null;
1814
- handledResult.subscribe(subscriber);
1815
- } else {
1816
- syncUnsub = true;
1817
- }
1818
- }));
1819
- if (syncUnsub) {
1820
- innerSub.unsubscribe();
1821
- innerSub = null;
1822
- handledResult.subscribe(subscriber);
1823
- }
1824
- });
1825
- }
1826
- // node_modules/rxjs/dist/esm5/internal/operators/filter.js
1827
- function filter(predicate, thisArg) {
1828
- return operate(function(source, subscriber) {
1829
- var index = 0;
1830
- source.subscribe(createOperatorSubscriber(subscriber, function(value) {
1831
- return predicate.call(thisArg, value, index++) && subscriber.next(value);
1832
- }));
1833
- });
1834
- }
1835
- // node_modules/rxjs/dist/esm5/internal/operators/finalize.js
1836
- function finalize(callback) {
1837
- return operate(function(source, subscriber) {
1838
- try {
1839
- source.subscribe(subscriber);
1840
- } finally {
1841
- subscriber.add(callback);
1842
- }
1843
- });
1844
- }
1845
- // node_modules/rxjs/dist/esm5/internal/operators/switchMap.js
1846
- function switchMap(project, resultSelector) {
1847
- return operate(function(source, subscriber) {
1848
- var innerSubscriber = null;
1849
- var index = 0;
1850
- var isComplete = false;
1851
- var checkComplete = function() {
1852
- return isComplete && !innerSubscriber && subscriber.complete();
1853
- };
1854
- source.subscribe(createOperatorSubscriber(subscriber, function(value) {
1855
- innerSubscriber === null || innerSubscriber === undefined || innerSubscriber.unsubscribe();
1856
- var innerIndex = 0;
1857
- var outerIndex = index++;
1858
- innerFrom(project(value, outerIndex)).subscribe(innerSubscriber = createOperatorSubscriber(subscriber, function(innerValue) {
1859
- return subscriber.next(resultSelector ? resultSelector(value, innerValue, outerIndex, innerIndex++) : innerValue);
1860
- }, function() {
1861
- innerSubscriber = null;
1862
- checkComplete();
1863
- }));
1864
- }, function() {
1865
- isComplete = true;
1866
- checkComplete();
1867
- }));
1868
- });
1869
- }
1870
- // node_modules/rxjs/dist/esm5/internal/operators/takeUntil.js
1871
- function takeUntil(notifier) {
1872
- return operate(function(source, subscriber) {
1873
- innerFrom(notifier).subscribe(createOperatorSubscriber(subscriber, function() {
1874
- return subscriber.complete();
1875
- }, noop));
1876
- !subscriber.closed && source.subscribe(subscriber);
1877
- });
1878
- }
1879
- // node_modules/rxjs/dist/esm5/internal/operators/tap.js
1880
- function tap(observerOrNext, error, complete) {
1881
- var tapObserver = isFunction(observerOrNext) || error || complete ? { next: observerOrNext, error, complete } : observerOrNext;
1882
- return tapObserver ? operate(function(source, subscriber) {
1883
- var _a;
1884
- (_a = tapObserver.subscribe) === null || _a === undefined || _a.call(tapObserver);
1885
- var isUnsub = true;
1886
- source.subscribe(createOperatorSubscriber(subscriber, function(value) {
1887
- var _a2;
1888
- (_a2 = tapObserver.next) === null || _a2 === undefined || _a2.call(tapObserver, value);
1889
- subscriber.next(value);
1890
- }, function() {
1891
- var _a2;
1892
- isUnsub = false;
1893
- (_a2 = tapObserver.complete) === null || _a2 === undefined || _a2.call(tapObserver);
1894
- subscriber.complete();
1895
- }, function(err) {
1896
- var _a2;
1897
- isUnsub = false;
1898
- (_a2 = tapObserver.error) === null || _a2 === undefined || _a2.call(tapObserver, err);
1899
- subscriber.error(err);
1900
- }, function() {
1901
- var _a2, _b;
1902
- if (isUnsub) {
1903
- (_a2 = tapObserver.unsubscribe) === null || _a2 === undefined || _a2.call(tapObserver);
1904
- }
1905
- (_b = tapObserver.finalize) === null || _b === undefined || _b.call(tapObserver);
1906
- }));
1907
- }) : identity;
1908
- }
1909
- // src/RpcChannel.ts
1910
- class RpcChannel extends Subject {
1911
- }
1912
- // src/SharedWorkerChannel.ts
1913
- class SharedWorkerChannel extends RpcChannel {
1914
- worker;
1915
- constructor(worker) {
1916
- super();
1917
- this.worker = worker;
1918
- if (typeof window == "undefined") {
1919
- this.#initBackground();
1920
- } else {
1921
- if (worker) {
1922
- this.#initForegound(worker);
1923
- }
1924
- }
1925
- }
1926
- #initBackground() {
1927
- const me = globalThis;
1928
- fromEvent(me, "connect").pipe(mergeMap((e) => {
1929
- const port = e.ports[0];
1930
- if (!port)
1931
- return EMPTY;
1932
- port.start();
1933
- return fromEvent(port, "message").pipe(takeUntil(fromEvent(port, "messageerror")), tap((msg) => {
1934
- const respond = (response) => {
1935
- port.postMessage({
1936
- id: msg.data.id,
1937
- response
1938
- });
1939
- };
1940
- this.next({ ...msg.data, respond });
1941
- }), finalize(() => {
1942
- port.close();
1943
- }));
1944
- })).subscribe();
1945
- }
1946
- #initForegound(worker) {
1947
- worker.port.start();
1948
- fromEvent(worker.port, "message").pipe(takeUntil(fromEvent(worker.port, "messageerror")), tap((e) => {
1949
- const respond = (response) => {
1950
- const msg = {
1951
- id: e.data.id,
1952
- response
1953
- };
1954
- worker.port.postMessage(msg);
1955
- };
1956
- this.next({ ...e.data, respond });
1957
- }), finalize(() => worker.port.close()), catchError((e) => {
1958
- return EMPTY;
1959
- })).subscribe();
1960
- }
1961
- send(message) {
1962
- if (!this.worker)
1963
- return;
1964
- this.worker.port.postMessage(message);
1965
- }
1966
- }
1967
- // src/ServiceLinker.ts
1968
- class ServiceLinker {
1969
- channel;
1970
- #request_id = 1;
1971
- #services = new Map;
1972
- #requests = new Map;
1973
- constructor(channel) {
1974
- this.channel = channel;
1975
- lastValueFrom(merge(this.channel.pipe(tap((e) => {
1976
- if (!e.response)
1977
- return;
1978
- const request = this.#requests.get(e.id);
1979
- if (!request)
1980
- return;
1981
- const { completed, data, error } = e.response;
1982
- if (completed || error)
1983
- request.completed = true;
1984
- data && request.o.next(data);
1985
- completed && request.o.complete();
1986
- error && request.o.error(new Error(error));
1987
- }))));
1988
- }
1989
- linkService(name) {
1990
- const cache = this.#services.get(name);
1991
- if (cache)
1992
- return cache;
1993
- const behaviot_subject_values = new Map;
1994
- const behavior_subjects = new Map;
1995
- const ready$ = new BehaviorSubject(false);
1996
- const rpc = (paths, args) => {
1997
- if (paths.length == 0 || paths[0] == "#")
1998
- throw new Error(`Invalid method path: ${paths.join(".")}`);
1999
- const id = this.#request_id++;
2000
- const o = new Subject;
2001
- this.#requests.set(id, { o, completed: false });
2002
- const observable3 = o.pipe(finalize(() => {
2003
- const request = this.#requests.get(id);
2004
- this.#requests.delete(id);
2005
- if (!request || request.completed)
2006
- return;
2007
- setTimeout(() => {
2008
- this.channel.send({ id: 0, cancel: { id } });
2009
- });
2010
- }));
2011
- setTimeout(() => {
2012
- this.channel.send({
2013
- id,
2014
- request: {
2015
- service: name,
2016
- method: paths,
2017
- args
2018
- }
2019
- });
2020
- });
2021
- return Object.assign(observable3, {
2022
- then(onFulfilled, onRejected) {
2023
- return firstValueFrom(observable3, { defaultValue: { data: null } }).then(onFulfilled, onRejected);
2024
- }
2025
- });
2026
- };
2027
- const build = (paths = []) => {
2028
- const fn = (...args) => rpc(paths, args);
2029
- return new Proxy(fn, {
2030
- get: (_, prop) => {
2031
- if (prop == "then" || typeof prop != "string")
2032
- return null;
2033
- if (prop == "###READY###")
2034
- return ready$;
2035
- if (behavior_subjects.has(prop))
2036
- return behavior_subjects.get(prop);
2037
- if (prop == "pipe" || prop == "subscribe" || prop == "getValue") {
2038
- const key = paths.join(".");
2039
- const cache2 = behavior_subjects.get(key) || new BehaviorSubject(behaviot_subject_values.get(key) ?? null);
2040
- if (!behavior_subjects.has(key)) {
2041
- behavior_subjects.set(key, cache2);
2042
- rpc(paths, []).subscribe((v) => cache2.next(v));
2043
- }
2044
- return (...args) => cache2[prop](...args);
2045
- }
2046
- return build([...paths, prop]);
2047
- },
2048
- has(target, prop) {
2049
- if (prop == "pipe" || prop == "subscribe" || prop == "getValue") {
2050
- return true;
2051
- }
2052
- return prop in target;
2053
- }
2054
- });
2055
- };
2056
- const service = build();
2057
- rpc(["____initialize____"], []).then((states) => {
2058
- for (const [key, value] of Object.entries(states)) {
2059
- behaviot_subject_values.set(key, value);
2060
- }
2061
- ready$.next(true);
2062
- });
2063
- this.#services.set(name, service);
2064
- return service;
2065
- }
2066
- static ready$(services) {
2067
- return combineLatest(Object.values(services).map((s) => s["###READY###"])).pipe(map((status) => status.every(Boolean)));
2068
- }
2069
- }
2070
- // src/WorkerManager.ts
2071
- function isObservableLike(value) {
2072
- return !!value && typeof value === "object" && typeof value.pipe === "function";
2073
- }
2074
-
2075
- class WorkerManager {
2076
- channel;
2077
- #services = new BehaviorSubject(new Map);
2078
- async#call(target, paths, args) {
2079
- const [first2, ...rest] = paths;
2080
- if (!first2 || first2 == "#")
2081
- throw new Error(`Invalid method path: ${paths.join(".")}`);
2082
- if (rest.length == 0) {
2083
- const prop = target[first2];
2084
- if (typeof prop == "function") {
2085
- return await prop.apply(target, args);
2086
- } else {
2087
- return prop;
2088
- }
2089
- }
2090
- return this.#call(target[first2], rest, args);
2091
- }
2092
- constructor(channel) {
2093
- this.channel = channel;
2094
- const responses = new Map;
2095
- this.channel.pipe(map(({ id, cancel, request, respond }) => {
2096
- if (cancel) {
2097
- const subscription = responses.get(cancel.id);
2098
- if (subscription) {
2099
- subscription.unsubscribe();
2100
- responses.delete(cancel.id);
2101
- }
2102
- return;
2103
- }
2104
- if (!request)
2105
- return;
2106
- const service = this.#services.getValue().get(request.service);
2107
- if (!service)
2108
- return respond({ error: `Service ${request.service} not found` });
2109
- if (request.method.length == 0 || request.method[0] == "#") {
2110
- respond({ error: `Can not call [${request.service}.${request.method.join(".")}]` });
2111
- return;
2112
- }
2113
- return { request, id, respond, service };
2114
- }), filter(Boolean), map((a) => a), mergeMap(async ({ id, request, respond, service }) => {
2115
- try {
2116
- const result = await this.#call(service, request.method, request.args);
2117
- if (isObservableLike(result)) {
2118
- const subscription = result.pipe(finalize(() => {
2119
- responses.delete(id);
2120
- })).subscribe((data) => respond({ data }), (err) => respond({ error: err?.message ?? String(err), completed: true }), () => respond({ completed: true }));
2121
- responses.set(id, subscription);
2122
- } else {
2123
- const data = await result;
2124
- respond({ data, completed: true });
2125
- }
2126
- } catch (err) {
2127
- respond({
2128
- error: err?.message ?? String(err),
2129
- completed: true
2130
- });
2131
- }
2132
- })).subscribe();
2133
- }
2134
- exposeService(name, service) {
2135
- const services = this.#services.getValue();
2136
- services.set(name, Object.assign(service, {
2137
- ____initialize____: () => {
2138
- const states = Object.getOwnPropertyNames(service).reduce((p, k) => {
2139
- if (service[k] && typeof service[k].getValue === "function") {
2140
- try {
2141
- return {
2142
- ...p,
2143
- [k]: service[k].getValue()
2144
- };
2145
- } catch {}
2146
- }
2147
- return p;
2148
- }, {});
2149
- return states;
2150
- }
2151
- }));
2152
- this.#services.next(services);
2153
- }
2154
- }
2155
- // src/LimitConcurrency.ts
2156
- var LimitConcurrency = (limit = 1) => (target, propertyKey, descriptor) => {
2157
- const originalMethod = descriptor.value;
2158
- const sj = new Subject;
2159
- sj.pipe(mergeMap(async ({ args, o }) => {
2160
- try {
2161
- const result = await originalMethod.apply(target, args);
2162
- const observable3 = result instanceof Promise ? from(result) : result instanceof Observable ? result : of(result);
2163
- await lastValueFrom(observable3.pipe(tap((data) => o.next(data)), catchError((e) => {
2164
- o.error(e);
2165
- return EMPTY;
2166
- }), finalize(() => o.complete())), { defaultValue: null });
2167
- } catch (e) {
2168
- o.error(e);
2169
- }
2170
- }, limit)).subscribe();
2171
- const ovf = (...args) => {
2172
- const o = new Observable((o2) => {
2173
- sj.next({ args, o: o2 });
2174
- });
2175
- return Object.assign(o, {
2176
- async then(resolve, reject) {
2177
- try {
2178
- const r = await lastValueFrom(o, { defaultValue: null });
2179
- resolve(r);
2180
- } catch (e) {
2181
- reject(e);
2182
- }
2183
- }
2184
- });
2185
- };
2186
- return ovf;
2187
- };
2188
- // src/StorageBehaviorSubject.ts
2189
- class StorageBehaviorSubject extends BehaviorSubject {
2190
- storage;
2191
- key;
2192
- constructor(storage, key, defaultValue) {
2193
- const value = storage.getItem(key);
2194
- super(value instanceof Promise ? defaultValue : value || defaultValue);
2195
- this.storage = storage;
2196
- this.key = key;
2197
- if (value instanceof Promise) {
2198
- value.then((v) => this.next(v ?? defaultValue));
2199
- }
2200
- }
2201
- next(value) {
2202
- super.next(value);
2203
- this.storage.setItem(this.key, value);
2204
- }
2205
- }
2206
- // src/RxjsQueue.ts
2207
- class RxjsQueue {
2208
- #limit$ = new Subject;
2209
- #task = new Subject;
2210
- constructor(limit) {
2211
- this.#limit$.pipe(switchMap((limit2) => this.#task.pipe(mergeMap(async ({ fn, s, r }) => {
2212
- try {
2213
- const data = await fn();
2214
- s(data);
2215
- } catch (e) {
2216
- r(e);
2217
- }
2218
- }, limit2)))).subscribe();
2219
- limit && limit >= 1 && this.#limit$.next(limit);
2220
- }
2221
- updateLimit(limit) {
2222
- this.#limit$.next(limit);
2223
- }
2224
- run(fn) {
2225
- return new Promise((s, r) => {
2226
- this.#task.next({
2227
- fn,
2228
- s,
2229
- r
2230
- });
2231
- });
2232
- }
2233
- }
2234
- export {
2235
- WorkerManager,
2236
- StorageBehaviorSubject,
2237
- SharedWorkerChannel,
2238
- ServiceLinker,
2239
- RxjsQueue,
2240
- RpcChannel,
2241
- LimitConcurrency
2242
- };
2243
-
2244
- //# debugId=4DEAD1008E8D001064756E2164756E21
2245
- //# sourceMappingURL=index.js.map
1
+ export * from "./RpcChannel.js";
2
+ export * from "./SharedWorkerChannel.js";
3
+ export * from "./ServiceLinker.js";
4
+ export * from "./WorkerService.js";
5
+ export * from "./WorkerManager.js";
6
+ export * from "./LimitConcurrency.js";
7
+ export * from "./StorageBehaviorSubject.js";
8
+ export * from "./RxjsQueue.js";
9
+ //# sourceMappingURL=index.js.map