@livequery/core 2.0.92 → 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.
Files changed (40) hide show
  1. package/README.md +56 -49
  2. package/dist/LivequeryCollection.d.ts +19 -17
  3. package/dist/LivequeryCollection.d.ts.map +1 -1
  4. package/dist/LivequeryCollection.js +231 -0
  5. package/dist/LivequeryCollection.js.map +1 -0
  6. package/dist/LivequeryCore.d.ts +4 -4
  7. package/dist/LivequeryCore.d.ts.map +1 -1
  8. package/dist/LivequeryCore.js +337 -0
  9. package/dist/LivequeryCore.js.map +1 -0
  10. package/dist/LivequeryDocument.d.ts +2 -2
  11. package/dist/LivequeryDocument.d.ts.map +1 -1
  12. package/dist/LivequeryDocument.js +22 -0
  13. package/dist/LivequeryDocument.js.map +1 -0
  14. package/dist/LivequeryMemoryStorage.d.ts +2 -2
  15. package/dist/LivequeryMemoryStorage.d.ts.map +1 -1
  16. package/dist/LivequeryMemoryStorage.js +89 -0
  17. package/dist/LivequeryMemoryStorage.js.map +1 -0
  18. package/dist/LivequeryStorge.d.ts +1 -1
  19. package/dist/LivequeryStorge.d.ts.map +1 -1
  20. package/dist/LivequeryStorge.js +2 -0
  21. package/dist/LivequeryStorge.js.map +1 -0
  22. package/dist/LivequeryTransporter.d.ts +1 -1
  23. package/dist/LivequeryTransporter.d.ts.map +1 -1
  24. package/dist/LivequeryTransporter.js +2 -0
  25. package/dist/LivequeryTransporter.js.map +1 -0
  26. package/dist/helpers/filterDocs.d.ts +1 -1
  27. package/dist/helpers/filterDocs.d.ts.map +1 -1
  28. package/dist/helpers/filterDocs.js +80 -0
  29. package/dist/helpers/filterDocs.js.map +1 -0
  30. package/dist/helpers/tryCatch.js +10 -0
  31. package/dist/helpers/tryCatch.js.map +1 -0
  32. package/dist/helpers/whenCompleted.js +5 -0
  33. package/dist/helpers/whenCompleted.js.map +1 -0
  34. package/dist/index.d.ts +8 -8
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +9 -3167
  37. package/dist/index.js.map +1 -100
  38. package/dist/types.js +2 -0
  39. package/dist/types.js.map +1 -0
  40. package/package.json +73 -4
package/dist/index.js CHANGED
@@ -1,3167 +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
-
785
- // node_modules/rxjs/dist/esm5/internal/util/ObjectUnsubscribedError.js
786
- var ObjectUnsubscribedError = createErrorClass(function(_super) {
787
- return function ObjectUnsubscribedErrorImpl() {
788
- _super(this);
789
- this.name = "ObjectUnsubscribedError";
790
- this.message = "object unsubscribed";
791
- };
792
- });
793
-
794
- // node_modules/rxjs/dist/esm5/internal/Subject.js
795
- var Subject = function(_super) {
796
- __extends(Subject2, _super);
797
- function Subject2() {
798
- var _this = _super.call(this) || this;
799
- _this.closed = false;
800
- _this.currentObservers = null;
801
- _this.observers = [];
802
- _this.isStopped = false;
803
- _this.hasError = false;
804
- _this.thrownError = null;
805
- return _this;
806
- }
807
- Subject2.prototype.lift = function(operator) {
808
- var subject = new AnonymousSubject(this, this);
809
- subject.operator = operator;
810
- return subject;
811
- };
812
- Subject2.prototype._throwIfClosed = function() {
813
- if (this.closed) {
814
- throw new ObjectUnsubscribedError;
815
- }
816
- };
817
- Subject2.prototype.next = function(value) {
818
- var _this = this;
819
- errorContext(function() {
820
- var e_1, _a;
821
- _this._throwIfClosed();
822
- if (!_this.isStopped) {
823
- if (!_this.currentObservers) {
824
- _this.currentObservers = Array.from(_this.observers);
825
- }
826
- try {
827
- for (var _b = __values(_this.currentObservers), _c = _b.next();!_c.done; _c = _b.next()) {
828
- var observer = _c.value;
829
- observer.next(value);
830
- }
831
- } catch (e_1_1) {
832
- e_1 = { error: e_1_1 };
833
- } finally {
834
- try {
835
- if (_c && !_c.done && (_a = _b.return))
836
- _a.call(_b);
837
- } finally {
838
- if (e_1)
839
- throw e_1.error;
840
- }
841
- }
842
- }
843
- });
844
- };
845
- Subject2.prototype.error = function(err) {
846
- var _this = this;
847
- errorContext(function() {
848
- _this._throwIfClosed();
849
- if (!_this.isStopped) {
850
- _this.hasError = _this.isStopped = true;
851
- _this.thrownError = err;
852
- var observers = _this.observers;
853
- while (observers.length) {
854
- observers.shift().error(err);
855
- }
856
- }
857
- });
858
- };
859
- Subject2.prototype.complete = function() {
860
- var _this = this;
861
- errorContext(function() {
862
- _this._throwIfClosed();
863
- if (!_this.isStopped) {
864
- _this.isStopped = true;
865
- var observers = _this.observers;
866
- while (observers.length) {
867
- observers.shift().complete();
868
- }
869
- }
870
- });
871
- };
872
- Subject2.prototype.unsubscribe = function() {
873
- this.isStopped = this.closed = true;
874
- this.observers = this.currentObservers = null;
875
- };
876
- Object.defineProperty(Subject2.prototype, "observed", {
877
- get: function() {
878
- var _a;
879
- return ((_a = this.observers) === null || _a === undefined ? undefined : _a.length) > 0;
880
- },
881
- enumerable: false,
882
- configurable: true
883
- });
884
- Subject2.prototype._trySubscribe = function(subscriber) {
885
- this._throwIfClosed();
886
- return _super.prototype._trySubscribe.call(this, subscriber);
887
- };
888
- Subject2.prototype._subscribe = function(subscriber) {
889
- this._throwIfClosed();
890
- this._checkFinalizedStatuses(subscriber);
891
- return this._innerSubscribe(subscriber);
892
- };
893
- Subject2.prototype._innerSubscribe = function(subscriber) {
894
- var _this = this;
895
- var _a = this, hasError = _a.hasError, isStopped = _a.isStopped, observers = _a.observers;
896
- if (hasError || isStopped) {
897
- return EMPTY_SUBSCRIPTION;
898
- }
899
- this.currentObservers = null;
900
- observers.push(subscriber);
901
- return new Subscription(function() {
902
- _this.currentObservers = null;
903
- arrRemove(observers, subscriber);
904
- });
905
- };
906
- Subject2.prototype._checkFinalizedStatuses = function(subscriber) {
907
- var _a = this, hasError = _a.hasError, thrownError = _a.thrownError, isStopped = _a.isStopped;
908
- if (hasError) {
909
- subscriber.error(thrownError);
910
- } else if (isStopped) {
911
- subscriber.complete();
912
- }
913
- };
914
- Subject2.prototype.asObservable = function() {
915
- var observable2 = new Observable;
916
- observable2.source = this;
917
- return observable2;
918
- };
919
- Subject2.create = function(destination, source) {
920
- return new AnonymousSubject(destination, source);
921
- };
922
- return Subject2;
923
- }(Observable);
924
- var AnonymousSubject = function(_super) {
925
- __extends(AnonymousSubject2, _super);
926
- function AnonymousSubject2(destination, source) {
927
- var _this = _super.call(this) || this;
928
- _this.destination = destination;
929
- _this.source = source;
930
- return _this;
931
- }
932
- AnonymousSubject2.prototype.next = function(value) {
933
- var _a, _b;
934
- (_b = (_a = this.destination) === null || _a === undefined ? undefined : _a.next) === null || _b === undefined || _b.call(_a, value);
935
- };
936
- AnonymousSubject2.prototype.error = function(err) {
937
- var _a, _b;
938
- (_b = (_a = this.destination) === null || _a === undefined ? undefined : _a.error) === null || _b === undefined || _b.call(_a, err);
939
- };
940
- AnonymousSubject2.prototype.complete = function() {
941
- var _a, _b;
942
- (_b = (_a = this.destination) === null || _a === undefined ? undefined : _a.complete) === null || _b === undefined || _b.call(_a);
943
- };
944
- AnonymousSubject2.prototype._subscribe = function(subscriber) {
945
- var _a, _b;
946
- return (_b = (_a = this.source) === null || _a === undefined ? undefined : _a.subscribe(subscriber)) !== null && _b !== undefined ? _b : EMPTY_SUBSCRIPTION;
947
- };
948
- return AnonymousSubject2;
949
- }(Subject);
950
- // node_modules/rxjs/dist/esm5/internal/BehaviorSubject.js
951
- var BehaviorSubject = function(_super) {
952
- __extends(BehaviorSubject2, _super);
953
- function BehaviorSubject2(_value) {
954
- var _this = _super.call(this) || this;
955
- _this._value = _value;
956
- return _this;
957
- }
958
- Object.defineProperty(BehaviorSubject2.prototype, "value", {
959
- get: function() {
960
- return this.getValue();
961
- },
962
- enumerable: false,
963
- configurable: true
964
- });
965
- BehaviorSubject2.prototype._subscribe = function(subscriber) {
966
- var subscription = _super.prototype._subscribe.call(this, subscriber);
967
- !subscription.closed && subscriber.next(this._value);
968
- return subscription;
969
- };
970
- BehaviorSubject2.prototype.getValue = function() {
971
- var _a = this, hasError = _a.hasError, thrownError = _a.thrownError, _value = _a._value;
972
- if (hasError) {
973
- throw thrownError;
974
- }
975
- this._throwIfClosed();
976
- return _value;
977
- };
978
- BehaviorSubject2.prototype.next = function(value) {
979
- _super.prototype.next.call(this, this._value = value);
980
- };
981
- return BehaviorSubject2;
982
- }(Subject);
983
- // node_modules/rxjs/dist/esm5/internal/util/EmptyError.js
984
- var EmptyError = createErrorClass(function(_super) {
985
- return function EmptyErrorImpl() {
986
- _super(this);
987
- this.name = "EmptyError";
988
- this.message = "no elements in sequence";
989
- };
990
- });
991
-
992
- // node_modules/rxjs/dist/esm5/internal/lastValueFrom.js
993
- function lastValueFrom(source, config2) {
994
- var hasConfig = typeof config2 === "object";
995
- return new Promise(function(resolve, reject) {
996
- var _hasValue = false;
997
- var _value;
998
- source.subscribe({
999
- next: function(value) {
1000
- _value = value;
1001
- _hasValue = true;
1002
- },
1003
- error: reject,
1004
- complete: function() {
1005
- if (_hasValue) {
1006
- resolve(_value);
1007
- } else if (hasConfig) {
1008
- resolve(config2.defaultValue);
1009
- } else {
1010
- reject(new EmptyError);
1011
- }
1012
- }
1013
- });
1014
- });
1015
- }
1016
- // node_modules/rxjs/dist/esm5/internal/util/isArrayLike.js
1017
- var isArrayLike = function(x) {
1018
- return x && typeof x.length === "number" && typeof x !== "function";
1019
- };
1020
-
1021
- // node_modules/rxjs/dist/esm5/internal/util/isPromise.js
1022
- function isPromise(value) {
1023
- return isFunction(value === null || value === undefined ? undefined : value.then);
1024
- }
1025
-
1026
- // node_modules/rxjs/dist/esm5/internal/util/isInteropObservable.js
1027
- function isInteropObservable(input) {
1028
- return isFunction(input[observable]);
1029
- }
1030
-
1031
- // node_modules/rxjs/dist/esm5/internal/util/isAsyncIterable.js
1032
- function isAsyncIterable(obj) {
1033
- return Symbol.asyncIterator && isFunction(obj === null || obj === undefined ? undefined : obj[Symbol.asyncIterator]);
1034
- }
1035
-
1036
- // node_modules/rxjs/dist/esm5/internal/util/throwUnobservableError.js
1037
- function createInvalidObservableTypeError(input) {
1038
- 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.");
1039
- }
1040
-
1041
- // node_modules/rxjs/dist/esm5/internal/symbol/iterator.js
1042
- function getSymbolIterator() {
1043
- if (typeof Symbol !== "function" || !Symbol.iterator) {
1044
- return "@@iterator";
1045
- }
1046
- return Symbol.iterator;
1047
- }
1048
- var iterator = getSymbolIterator();
1049
-
1050
- // node_modules/rxjs/dist/esm5/internal/util/isIterable.js
1051
- function isIterable(input) {
1052
- return isFunction(input === null || input === undefined ? undefined : input[iterator]);
1053
- }
1054
-
1055
- // node_modules/rxjs/dist/esm5/internal/util/isReadableStreamLike.js
1056
- function readableStreamLikeToAsyncGenerator(readableStream) {
1057
- return __asyncGenerator(this, arguments, function readableStreamLikeToAsyncGenerator_1() {
1058
- var reader, _a, value, done;
1059
- return __generator(this, function(_b) {
1060
- switch (_b.label) {
1061
- case 0:
1062
- reader = readableStream.getReader();
1063
- _b.label = 1;
1064
- case 1:
1065
- _b.trys.push([1, , 9, 10]);
1066
- _b.label = 2;
1067
- case 2:
1068
- if (false)
1069
- ;
1070
- return [4, __await(reader.read())];
1071
- case 3:
1072
- _a = _b.sent(), value = _a.value, done = _a.done;
1073
- if (!done)
1074
- return [3, 5];
1075
- return [4, __await(undefined)];
1076
- case 4:
1077
- return [2, _b.sent()];
1078
- case 5:
1079
- return [4, __await(value)];
1080
- case 6:
1081
- return [4, _b.sent()];
1082
- case 7:
1083
- _b.sent();
1084
- return [3, 2];
1085
- case 8:
1086
- return [3, 10];
1087
- case 9:
1088
- reader.releaseLock();
1089
- return [7];
1090
- case 10:
1091
- return [2];
1092
- }
1093
- });
1094
- });
1095
- }
1096
- function isReadableStreamLike(obj) {
1097
- return isFunction(obj === null || obj === undefined ? undefined : obj.getReader);
1098
- }
1099
-
1100
- // node_modules/rxjs/dist/esm5/internal/observable/innerFrom.js
1101
- function innerFrom(input) {
1102
- if (input instanceof Observable) {
1103
- return input;
1104
- }
1105
- if (input != null) {
1106
- if (isInteropObservable(input)) {
1107
- return fromInteropObservable(input);
1108
- }
1109
- if (isArrayLike(input)) {
1110
- return fromArrayLike(input);
1111
- }
1112
- if (isPromise(input)) {
1113
- return fromPromise(input);
1114
- }
1115
- if (isAsyncIterable(input)) {
1116
- return fromAsyncIterable(input);
1117
- }
1118
- if (isIterable(input)) {
1119
- return fromIterable(input);
1120
- }
1121
- if (isReadableStreamLike(input)) {
1122
- return fromReadableStreamLike(input);
1123
- }
1124
- }
1125
- throw createInvalidObservableTypeError(input);
1126
- }
1127
- function fromInteropObservable(obj) {
1128
- return new Observable(function(subscriber) {
1129
- var obs = obj[observable]();
1130
- if (isFunction(obs.subscribe)) {
1131
- return obs.subscribe(subscriber);
1132
- }
1133
- throw new TypeError("Provided object does not correctly implement Symbol.observable");
1134
- });
1135
- }
1136
- function fromArrayLike(array) {
1137
- return new Observable(function(subscriber) {
1138
- for (var i = 0;i < array.length && !subscriber.closed; i++) {
1139
- subscriber.next(array[i]);
1140
- }
1141
- subscriber.complete();
1142
- });
1143
- }
1144
- function fromPromise(promise) {
1145
- return new Observable(function(subscriber) {
1146
- promise.then(function(value) {
1147
- if (!subscriber.closed) {
1148
- subscriber.next(value);
1149
- subscriber.complete();
1150
- }
1151
- }, function(err) {
1152
- return subscriber.error(err);
1153
- }).then(null, reportUnhandledError);
1154
- });
1155
- }
1156
- function fromIterable(iterable) {
1157
- return new Observable(function(subscriber) {
1158
- var e_1, _a;
1159
- try {
1160
- for (var iterable_1 = __values(iterable), iterable_1_1 = iterable_1.next();!iterable_1_1.done; iterable_1_1 = iterable_1.next()) {
1161
- var value = iterable_1_1.value;
1162
- subscriber.next(value);
1163
- if (subscriber.closed) {
1164
- return;
1165
- }
1166
- }
1167
- } catch (e_1_1) {
1168
- e_1 = { error: e_1_1 };
1169
- } finally {
1170
- try {
1171
- if (iterable_1_1 && !iterable_1_1.done && (_a = iterable_1.return))
1172
- _a.call(iterable_1);
1173
- } finally {
1174
- if (e_1)
1175
- throw e_1.error;
1176
- }
1177
- }
1178
- subscriber.complete();
1179
- });
1180
- }
1181
- function fromAsyncIterable(asyncIterable) {
1182
- return new Observable(function(subscriber) {
1183
- process(asyncIterable, subscriber).catch(function(err) {
1184
- return subscriber.error(err);
1185
- });
1186
- });
1187
- }
1188
- function fromReadableStreamLike(readableStream) {
1189
- return fromAsyncIterable(readableStreamLikeToAsyncGenerator(readableStream));
1190
- }
1191
- function process(asyncIterable, subscriber) {
1192
- var asyncIterable_1, asyncIterable_1_1;
1193
- var e_2, _a;
1194
- return __awaiter(this, undefined, undefined, function() {
1195
- var value, e_2_1;
1196
- return __generator(this, function(_b) {
1197
- switch (_b.label) {
1198
- case 0:
1199
- _b.trys.push([0, 5, 6, 11]);
1200
- asyncIterable_1 = __asyncValues(asyncIterable);
1201
- _b.label = 1;
1202
- case 1:
1203
- return [4, asyncIterable_1.next()];
1204
- case 2:
1205
- if (!(asyncIterable_1_1 = _b.sent(), !asyncIterable_1_1.done))
1206
- return [3, 4];
1207
- value = asyncIterable_1_1.value;
1208
- subscriber.next(value);
1209
- if (subscriber.closed) {
1210
- return [2];
1211
- }
1212
- _b.label = 3;
1213
- case 3:
1214
- return [3, 1];
1215
- case 4:
1216
- return [3, 11];
1217
- case 5:
1218
- e_2_1 = _b.sent();
1219
- e_2 = { error: e_2_1 };
1220
- return [3, 11];
1221
- case 6:
1222
- _b.trys.push([6, , 9, 10]);
1223
- if (!(asyncIterable_1_1 && !asyncIterable_1_1.done && (_a = asyncIterable_1.return)))
1224
- return [3, 8];
1225
- return [4, _a.call(asyncIterable_1)];
1226
- case 7:
1227
- _b.sent();
1228
- _b.label = 8;
1229
- case 8:
1230
- return [3, 10];
1231
- case 9:
1232
- if (e_2)
1233
- throw e_2.error;
1234
- return [7];
1235
- case 10:
1236
- return [7];
1237
- case 11:
1238
- subscriber.complete();
1239
- return [2];
1240
- }
1241
- });
1242
- });
1243
- }
1244
-
1245
- // node_modules/rxjs/dist/esm5/internal/observable/defer.js
1246
- function defer(observableFactory) {
1247
- return new Observable(function(subscriber) {
1248
- innerFrom(observableFactory()).subscribe(subscriber);
1249
- });
1250
- }
1251
- // node_modules/rxjs/dist/esm5/internal/util/argsArgArrayOrObject.js
1252
- var isArray = Array.isArray;
1253
- var getPrototypeOf = Object.getPrototypeOf;
1254
- var objectProto = Object.prototype;
1255
- var getKeys = Object.keys;
1256
- function argsArgArrayOrObject(args) {
1257
- if (args.length === 1) {
1258
- var first_1 = args[0];
1259
- if (isArray(first_1)) {
1260
- return { args: first_1, keys: null };
1261
- }
1262
- if (isPOJO(first_1)) {
1263
- var keys = getKeys(first_1);
1264
- return {
1265
- args: keys.map(function(key) {
1266
- return first_1[key];
1267
- }),
1268
- keys
1269
- };
1270
- }
1271
- }
1272
- return { args, keys: null };
1273
- }
1274
- function isPOJO(obj) {
1275
- return obj && typeof obj === "object" && getPrototypeOf(obj) === objectProto;
1276
- }
1277
-
1278
- // node_modules/rxjs/dist/esm5/internal/util/isScheduler.js
1279
- function isScheduler(value) {
1280
- return value && isFunction(value.schedule);
1281
- }
1282
-
1283
- // node_modules/rxjs/dist/esm5/internal/util/args.js
1284
- function last(arr) {
1285
- return arr[arr.length - 1];
1286
- }
1287
- function popResultSelector(args) {
1288
- return isFunction(last(args)) ? args.pop() : undefined;
1289
- }
1290
- function popScheduler(args) {
1291
- return isScheduler(last(args)) ? args.pop() : undefined;
1292
- }
1293
- function popNumber(args, defaultValue) {
1294
- return typeof last(args) === "number" ? args.pop() : defaultValue;
1295
- }
1296
-
1297
- // node_modules/rxjs/dist/esm5/internal/operators/OperatorSubscriber.js
1298
- function createOperatorSubscriber(destination, onNext, onComplete, onError, onFinalize) {
1299
- return new OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize);
1300
- }
1301
- var OperatorSubscriber = function(_super) {
1302
- __extends(OperatorSubscriber2, _super);
1303
- function OperatorSubscriber2(destination, onNext, onComplete, onError, onFinalize, shouldUnsubscribe) {
1304
- var _this = _super.call(this, destination) || this;
1305
- _this.onFinalize = onFinalize;
1306
- _this.shouldUnsubscribe = shouldUnsubscribe;
1307
- _this._next = onNext ? function(value) {
1308
- try {
1309
- onNext(value);
1310
- } catch (err) {
1311
- destination.error(err);
1312
- }
1313
- } : _super.prototype._next;
1314
- _this._error = onError ? function(err) {
1315
- try {
1316
- onError(err);
1317
- } catch (err2) {
1318
- destination.error(err2);
1319
- } finally {
1320
- this.unsubscribe();
1321
- }
1322
- } : _super.prototype._error;
1323
- _this._complete = onComplete ? function() {
1324
- try {
1325
- onComplete();
1326
- } catch (err) {
1327
- destination.error(err);
1328
- } finally {
1329
- this.unsubscribe();
1330
- }
1331
- } : _super.prototype._complete;
1332
- return _this;
1333
- }
1334
- OperatorSubscriber2.prototype.unsubscribe = function() {
1335
- var _a;
1336
- if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {
1337
- var closed_1 = this.closed;
1338
- _super.prototype.unsubscribe.call(this);
1339
- !closed_1 && ((_a = this.onFinalize) === null || _a === undefined || _a.call(this));
1340
- }
1341
- };
1342
- return OperatorSubscriber2;
1343
- }(Subscriber);
1344
-
1345
- // node_modules/rxjs/dist/esm5/internal/util/lift.js
1346
- function hasLift(source) {
1347
- return isFunction(source === null || source === undefined ? undefined : source.lift);
1348
- }
1349
- function operate(init) {
1350
- return function(source) {
1351
- if (hasLift(source)) {
1352
- return source.lift(function(liftedSource) {
1353
- try {
1354
- return init(liftedSource, this);
1355
- } catch (err) {
1356
- this.error(err);
1357
- }
1358
- });
1359
- }
1360
- throw new TypeError("Unable to lift unknown Observable type");
1361
- };
1362
- }
1363
-
1364
- // node_modules/rxjs/dist/esm5/internal/operators/map.js
1365
- function map(project, thisArg) {
1366
- return operate(function(source, subscriber) {
1367
- var index = 0;
1368
- source.subscribe(createOperatorSubscriber(subscriber, function(value) {
1369
- subscriber.next(project.call(thisArg, value, index++));
1370
- }));
1371
- });
1372
- }
1373
-
1374
- // node_modules/rxjs/dist/esm5/internal/util/mapOneOrManyArgs.js
1375
- var isArray2 = Array.isArray;
1376
- function callOrApply(fn, args) {
1377
- return isArray2(args) ? fn.apply(undefined, __spreadArray([], __read(args))) : fn(args);
1378
- }
1379
- function mapOneOrManyArgs(fn) {
1380
- return map(function(args) {
1381
- return callOrApply(fn, args);
1382
- });
1383
- }
1384
-
1385
- // node_modules/rxjs/dist/esm5/internal/util/createObject.js
1386
- function createObject(keys, values) {
1387
- return keys.reduce(function(result, key, i) {
1388
- return result[key] = values[i], result;
1389
- }, {});
1390
- }
1391
-
1392
- // node_modules/rxjs/dist/esm5/internal/observable/forkJoin.js
1393
- function forkJoin() {
1394
- var args = [];
1395
- for (var _i = 0;_i < arguments.length; _i++) {
1396
- args[_i] = arguments[_i];
1397
- }
1398
- var resultSelector = popResultSelector(args);
1399
- var _a = argsArgArrayOrObject(args), sources = _a.args, keys = _a.keys;
1400
- var result = new Observable(function(subscriber) {
1401
- var length = sources.length;
1402
- if (!length) {
1403
- subscriber.complete();
1404
- return;
1405
- }
1406
- var values = new Array(length);
1407
- var remainingCompletions = length;
1408
- var remainingEmissions = length;
1409
- var _loop_1 = function(sourceIndex2) {
1410
- var hasValue = false;
1411
- innerFrom(sources[sourceIndex2]).subscribe(createOperatorSubscriber(subscriber, function(value) {
1412
- if (!hasValue) {
1413
- hasValue = true;
1414
- remainingEmissions--;
1415
- }
1416
- values[sourceIndex2] = value;
1417
- }, function() {
1418
- return remainingCompletions--;
1419
- }, undefined, function() {
1420
- if (!remainingCompletions || !hasValue) {
1421
- if (!remainingEmissions) {
1422
- subscriber.next(keys ? createObject(keys, values) : values);
1423
- }
1424
- subscriber.complete();
1425
- }
1426
- }));
1427
- };
1428
- for (var sourceIndex = 0;sourceIndex < length; sourceIndex++) {
1429
- _loop_1(sourceIndex);
1430
- }
1431
- });
1432
- return resultSelector ? result.pipe(mapOneOrManyArgs(resultSelector)) : result;
1433
- }
1434
- // node_modules/rxjs/dist/esm5/internal/util/executeSchedule.js
1435
- function executeSchedule(parentSubscription, scheduler, work, delay, repeat) {
1436
- if (delay === undefined) {
1437
- delay = 0;
1438
- }
1439
- if (repeat === undefined) {
1440
- repeat = false;
1441
- }
1442
- var scheduleSubscription = scheduler.schedule(function() {
1443
- work();
1444
- if (repeat) {
1445
- parentSubscription.add(this.schedule(null, delay));
1446
- } else {
1447
- this.unsubscribe();
1448
- }
1449
- }, delay);
1450
- parentSubscription.add(scheduleSubscription);
1451
- if (!repeat) {
1452
- return scheduleSubscription;
1453
- }
1454
- }
1455
-
1456
- // node_modules/rxjs/dist/esm5/internal/operators/observeOn.js
1457
- function observeOn(scheduler, delay) {
1458
- if (delay === undefined) {
1459
- delay = 0;
1460
- }
1461
- return operate(function(source, subscriber) {
1462
- source.subscribe(createOperatorSubscriber(subscriber, function(value) {
1463
- return executeSchedule(subscriber, scheduler, function() {
1464
- return subscriber.next(value);
1465
- }, delay);
1466
- }, function() {
1467
- return executeSchedule(subscriber, scheduler, function() {
1468
- return subscriber.complete();
1469
- }, delay);
1470
- }, function(err) {
1471
- return executeSchedule(subscriber, scheduler, function() {
1472
- return subscriber.error(err);
1473
- }, delay);
1474
- }));
1475
- });
1476
- }
1477
-
1478
- // node_modules/rxjs/dist/esm5/internal/operators/subscribeOn.js
1479
- function subscribeOn(scheduler, delay) {
1480
- if (delay === undefined) {
1481
- delay = 0;
1482
- }
1483
- return operate(function(source, subscriber) {
1484
- subscriber.add(scheduler.schedule(function() {
1485
- return source.subscribe(subscriber);
1486
- }, delay));
1487
- });
1488
- }
1489
-
1490
- // node_modules/rxjs/dist/esm5/internal/scheduled/scheduleObservable.js
1491
- function scheduleObservable(input, scheduler) {
1492
- return innerFrom(input).pipe(subscribeOn(scheduler), observeOn(scheduler));
1493
- }
1494
-
1495
- // node_modules/rxjs/dist/esm5/internal/scheduled/schedulePromise.js
1496
- function schedulePromise(input, scheduler) {
1497
- return innerFrom(input).pipe(subscribeOn(scheduler), observeOn(scheduler));
1498
- }
1499
-
1500
- // node_modules/rxjs/dist/esm5/internal/scheduled/scheduleArray.js
1501
- function scheduleArray(input, scheduler) {
1502
- return new Observable(function(subscriber) {
1503
- var i = 0;
1504
- return scheduler.schedule(function() {
1505
- if (i === input.length) {
1506
- subscriber.complete();
1507
- } else {
1508
- subscriber.next(input[i++]);
1509
- if (!subscriber.closed) {
1510
- this.schedule();
1511
- }
1512
- }
1513
- });
1514
- });
1515
- }
1516
-
1517
- // node_modules/rxjs/dist/esm5/internal/scheduled/scheduleIterable.js
1518
- function scheduleIterable(input, scheduler) {
1519
- return new Observable(function(subscriber) {
1520
- var iterator2;
1521
- executeSchedule(subscriber, scheduler, function() {
1522
- iterator2 = input[iterator]();
1523
- executeSchedule(subscriber, scheduler, function() {
1524
- var _a;
1525
- var value;
1526
- var done;
1527
- try {
1528
- _a = iterator2.next(), value = _a.value, done = _a.done;
1529
- } catch (err) {
1530
- subscriber.error(err);
1531
- return;
1532
- }
1533
- if (done) {
1534
- subscriber.complete();
1535
- } else {
1536
- subscriber.next(value);
1537
- }
1538
- }, 0, true);
1539
- });
1540
- return function() {
1541
- return isFunction(iterator2 === null || iterator2 === undefined ? undefined : iterator2.return) && iterator2.return();
1542
- };
1543
- });
1544
- }
1545
-
1546
- // node_modules/rxjs/dist/esm5/internal/scheduled/scheduleAsyncIterable.js
1547
- function scheduleAsyncIterable(input, scheduler) {
1548
- if (!input) {
1549
- throw new Error("Iterable cannot be null");
1550
- }
1551
- return new Observable(function(subscriber) {
1552
- executeSchedule(subscriber, scheduler, function() {
1553
- var iterator2 = input[Symbol.asyncIterator]();
1554
- executeSchedule(subscriber, scheduler, function() {
1555
- iterator2.next().then(function(result) {
1556
- if (result.done) {
1557
- subscriber.complete();
1558
- } else {
1559
- subscriber.next(result.value);
1560
- }
1561
- });
1562
- }, 0, true);
1563
- });
1564
- });
1565
- }
1566
-
1567
- // node_modules/rxjs/dist/esm5/internal/scheduled/scheduleReadableStreamLike.js
1568
- function scheduleReadableStreamLike(input, scheduler) {
1569
- return scheduleAsyncIterable(readableStreamLikeToAsyncGenerator(input), scheduler);
1570
- }
1571
-
1572
- // node_modules/rxjs/dist/esm5/internal/scheduled/scheduled.js
1573
- function scheduled(input, scheduler) {
1574
- if (input != null) {
1575
- if (isInteropObservable(input)) {
1576
- return scheduleObservable(input, scheduler);
1577
- }
1578
- if (isArrayLike(input)) {
1579
- return scheduleArray(input, scheduler);
1580
- }
1581
- if (isPromise(input)) {
1582
- return schedulePromise(input, scheduler);
1583
- }
1584
- if (isAsyncIterable(input)) {
1585
- return scheduleAsyncIterable(input, scheduler);
1586
- }
1587
- if (isIterable(input)) {
1588
- return scheduleIterable(input, scheduler);
1589
- }
1590
- if (isReadableStreamLike(input)) {
1591
- return scheduleReadableStreamLike(input, scheduler);
1592
- }
1593
- }
1594
- throw createInvalidObservableTypeError(input);
1595
- }
1596
-
1597
- // node_modules/rxjs/dist/esm5/internal/observable/from.js
1598
- function from(input, scheduler) {
1599
- return scheduler ? scheduled(input, scheduler) : innerFrom(input);
1600
- }
1601
- // node_modules/rxjs/dist/esm5/internal/operators/mergeInternals.js
1602
- function mergeInternals(source, subscriber, project, concurrent, onBeforeNext, expand, innerSubScheduler, additionalFinalizer) {
1603
- var buffer = [];
1604
- var active = 0;
1605
- var index = 0;
1606
- var isComplete = false;
1607
- var checkComplete = function() {
1608
- if (isComplete && !buffer.length && !active) {
1609
- subscriber.complete();
1610
- }
1611
- };
1612
- var outerNext = function(value) {
1613
- return active < concurrent ? doInnerSub(value) : buffer.push(value);
1614
- };
1615
- var doInnerSub = function(value) {
1616
- expand && subscriber.next(value);
1617
- active++;
1618
- var innerComplete = false;
1619
- innerFrom(project(value, index++)).subscribe(createOperatorSubscriber(subscriber, function(innerValue) {
1620
- onBeforeNext === null || onBeforeNext === undefined || onBeforeNext(innerValue);
1621
- if (expand) {
1622
- outerNext(innerValue);
1623
- } else {
1624
- subscriber.next(innerValue);
1625
- }
1626
- }, function() {
1627
- innerComplete = true;
1628
- }, undefined, function() {
1629
- if (innerComplete) {
1630
- try {
1631
- active--;
1632
- var _loop_1 = function() {
1633
- var bufferedValue = buffer.shift();
1634
- if (innerSubScheduler) {
1635
- executeSchedule(subscriber, innerSubScheduler, function() {
1636
- return doInnerSub(bufferedValue);
1637
- });
1638
- } else {
1639
- doInnerSub(bufferedValue);
1640
- }
1641
- };
1642
- while (buffer.length && active < concurrent) {
1643
- _loop_1();
1644
- }
1645
- checkComplete();
1646
- } catch (err) {
1647
- subscriber.error(err);
1648
- }
1649
- }
1650
- }));
1651
- };
1652
- source.subscribe(createOperatorSubscriber(subscriber, outerNext, function() {
1653
- isComplete = true;
1654
- checkComplete();
1655
- }));
1656
- return function() {
1657
- additionalFinalizer === null || additionalFinalizer === undefined || additionalFinalizer();
1658
- };
1659
- }
1660
-
1661
- // node_modules/rxjs/dist/esm5/internal/operators/mergeMap.js
1662
- function mergeMap(project, resultSelector, concurrent) {
1663
- if (concurrent === undefined) {
1664
- concurrent = Infinity;
1665
- }
1666
- if (isFunction(resultSelector)) {
1667
- return mergeMap(function(a, i) {
1668
- return map(function(b, ii) {
1669
- return resultSelector(a, b, i, ii);
1670
- })(innerFrom(project(a, i)));
1671
- }, concurrent);
1672
- } else if (typeof resultSelector === "number") {
1673
- concurrent = resultSelector;
1674
- }
1675
- return operate(function(source, subscriber) {
1676
- return mergeInternals(source, subscriber, project, concurrent);
1677
- });
1678
- }
1679
-
1680
- // node_modules/rxjs/dist/esm5/internal/operators/mergeAll.js
1681
- function mergeAll(concurrent) {
1682
- if (concurrent === undefined) {
1683
- concurrent = Infinity;
1684
- }
1685
- return mergeMap(identity, concurrent);
1686
- }
1687
-
1688
- // node_modules/rxjs/dist/esm5/internal/observable/empty.js
1689
- var EMPTY = new Observable(function(subscriber) {
1690
- return subscriber.complete();
1691
- });
1692
-
1693
- // node_modules/rxjs/dist/esm5/internal/observable/merge.js
1694
- function merge() {
1695
- var args = [];
1696
- for (var _i = 0;_i < arguments.length; _i++) {
1697
- args[_i] = arguments[_i];
1698
- }
1699
- var scheduler = popScheduler(args);
1700
- var concurrent = popNumber(args, Infinity);
1701
- var sources = args;
1702
- return !sources.length ? EMPTY : sources.length === 1 ? innerFrom(sources[0]) : mergeAll(concurrent)(from(sources, scheduler));
1703
- }
1704
- // node_modules/rxjs/dist/esm5/internal/observable/of.js
1705
- function of() {
1706
- var args = [];
1707
- for (var _i = 0;_i < arguments.length; _i++) {
1708
- args[_i] = arguments[_i];
1709
- }
1710
- var scheduler = popScheduler(args);
1711
- return from(args, scheduler);
1712
- }
1713
- // node_modules/rxjs/dist/esm5/internal/operators/concatMap.js
1714
- function concatMap(project, resultSelector) {
1715
- return isFunction(resultSelector) ? mergeMap(project, resultSelector, 1) : mergeMap(project, 1);
1716
- }
1717
- // node_modules/rxjs/dist/esm5/internal/scheduler/Action.js
1718
- var Action = function(_super) {
1719
- __extends(Action2, _super);
1720
- function Action2(scheduler, work) {
1721
- return _super.call(this) || this;
1722
- }
1723
- Action2.prototype.schedule = function(state, delay) {
1724
- if (delay === undefined) {
1725
- delay = 0;
1726
- }
1727
- return this;
1728
- };
1729
- return Action2;
1730
- }(Subscription);
1731
-
1732
- // node_modules/rxjs/dist/esm5/internal/scheduler/intervalProvider.js
1733
- var intervalProvider = {
1734
- setInterval: function(handler, timeout) {
1735
- var args = [];
1736
- for (var _i = 2;_i < arguments.length; _i++) {
1737
- args[_i - 2] = arguments[_i];
1738
- }
1739
- var delegate = intervalProvider.delegate;
1740
- if (delegate === null || delegate === undefined ? undefined : delegate.setInterval) {
1741
- return delegate.setInterval.apply(delegate, __spreadArray([handler, timeout], __read(args)));
1742
- }
1743
- return setInterval.apply(undefined, __spreadArray([handler, timeout], __read(args)));
1744
- },
1745
- clearInterval: function(handle) {
1746
- var delegate = intervalProvider.delegate;
1747
- return ((delegate === null || delegate === undefined ? undefined : delegate.clearInterval) || clearInterval)(handle);
1748
- },
1749
- delegate: undefined
1750
- };
1751
-
1752
- // node_modules/rxjs/dist/esm5/internal/scheduler/AsyncAction.js
1753
- var AsyncAction = function(_super) {
1754
- __extends(AsyncAction2, _super);
1755
- function AsyncAction2(scheduler, work) {
1756
- var _this = _super.call(this, scheduler, work) || this;
1757
- _this.scheduler = scheduler;
1758
- _this.work = work;
1759
- _this.pending = false;
1760
- return _this;
1761
- }
1762
- AsyncAction2.prototype.schedule = function(state, delay) {
1763
- var _a;
1764
- if (delay === undefined) {
1765
- delay = 0;
1766
- }
1767
- if (this.closed) {
1768
- return this;
1769
- }
1770
- this.state = state;
1771
- var id = this.id;
1772
- var scheduler = this.scheduler;
1773
- if (id != null) {
1774
- this.id = this.recycleAsyncId(scheduler, id, delay);
1775
- }
1776
- this.pending = true;
1777
- this.delay = delay;
1778
- this.id = (_a = this.id) !== null && _a !== undefined ? _a : this.requestAsyncId(scheduler, this.id, delay);
1779
- return this;
1780
- };
1781
- AsyncAction2.prototype.requestAsyncId = function(scheduler, _id, delay) {
1782
- if (delay === undefined) {
1783
- delay = 0;
1784
- }
1785
- return intervalProvider.setInterval(scheduler.flush.bind(scheduler, this), delay);
1786
- };
1787
- AsyncAction2.prototype.recycleAsyncId = function(_scheduler, id, delay) {
1788
- if (delay === undefined) {
1789
- delay = 0;
1790
- }
1791
- if (delay != null && this.delay === delay && this.pending === false) {
1792
- return id;
1793
- }
1794
- if (id != null) {
1795
- intervalProvider.clearInterval(id);
1796
- }
1797
- return;
1798
- };
1799
- AsyncAction2.prototype.execute = function(state, delay) {
1800
- if (this.closed) {
1801
- return new Error("executing a cancelled action");
1802
- }
1803
- this.pending = false;
1804
- var error = this._execute(state, delay);
1805
- if (error) {
1806
- return error;
1807
- } else if (this.pending === false && this.id != null) {
1808
- this.id = this.recycleAsyncId(this.scheduler, this.id, null);
1809
- }
1810
- };
1811
- AsyncAction2.prototype._execute = function(state, _delay) {
1812
- var errored = false;
1813
- var errorValue;
1814
- try {
1815
- this.work(state);
1816
- } catch (e) {
1817
- errored = true;
1818
- errorValue = e ? e : new Error("Scheduled action threw falsy error");
1819
- }
1820
- if (errored) {
1821
- this.unsubscribe();
1822
- return errorValue;
1823
- }
1824
- };
1825
- AsyncAction2.prototype.unsubscribe = function() {
1826
- if (!this.closed) {
1827
- var _a = this, id = _a.id, scheduler = _a.scheduler;
1828
- var actions = scheduler.actions;
1829
- this.work = this.state = this.scheduler = null;
1830
- this.pending = false;
1831
- arrRemove(actions, this);
1832
- if (id != null) {
1833
- this.id = this.recycleAsyncId(scheduler, id, null);
1834
- }
1835
- this.delay = null;
1836
- _super.prototype.unsubscribe.call(this);
1837
- }
1838
- };
1839
- return AsyncAction2;
1840
- }(Action);
1841
-
1842
- // node_modules/rxjs/dist/esm5/internal/scheduler/dateTimestampProvider.js
1843
- var dateTimestampProvider = {
1844
- now: function() {
1845
- return (dateTimestampProvider.delegate || Date).now();
1846
- },
1847
- delegate: undefined
1848
- };
1849
-
1850
- // node_modules/rxjs/dist/esm5/internal/Scheduler.js
1851
- var Scheduler = function() {
1852
- function Scheduler2(schedulerActionCtor, now) {
1853
- if (now === undefined) {
1854
- now = Scheduler2.now;
1855
- }
1856
- this.schedulerActionCtor = schedulerActionCtor;
1857
- this.now = now;
1858
- }
1859
- Scheduler2.prototype.schedule = function(work, delay, state) {
1860
- if (delay === undefined) {
1861
- delay = 0;
1862
- }
1863
- return new this.schedulerActionCtor(this, work).schedule(state, delay);
1864
- };
1865
- Scheduler2.now = dateTimestampProvider.now;
1866
- return Scheduler2;
1867
- }();
1868
-
1869
- // node_modules/rxjs/dist/esm5/internal/scheduler/AsyncScheduler.js
1870
- var AsyncScheduler = function(_super) {
1871
- __extends(AsyncScheduler2, _super);
1872
- function AsyncScheduler2(SchedulerAction, now) {
1873
- if (now === undefined) {
1874
- now = Scheduler.now;
1875
- }
1876
- var _this = _super.call(this, SchedulerAction, now) || this;
1877
- _this.actions = [];
1878
- _this._active = false;
1879
- return _this;
1880
- }
1881
- AsyncScheduler2.prototype.flush = function(action) {
1882
- var actions = this.actions;
1883
- if (this._active) {
1884
- actions.push(action);
1885
- return;
1886
- }
1887
- var error;
1888
- this._active = true;
1889
- do {
1890
- if (error = action.execute(action.state, action.delay)) {
1891
- break;
1892
- }
1893
- } while (action = actions.shift());
1894
- this._active = false;
1895
- if (error) {
1896
- while (action = actions.shift()) {
1897
- action.unsubscribe();
1898
- }
1899
- throw error;
1900
- }
1901
- };
1902
- return AsyncScheduler2;
1903
- }(Scheduler);
1904
-
1905
- // node_modules/rxjs/dist/esm5/internal/scheduler/async.js
1906
- var asyncScheduler = new AsyncScheduler(AsyncAction);
1907
-
1908
- // node_modules/rxjs/dist/esm5/internal/operators/debounceTime.js
1909
- function debounceTime(dueTime, scheduler) {
1910
- if (scheduler === undefined) {
1911
- scheduler = asyncScheduler;
1912
- }
1913
- return operate(function(source, subscriber) {
1914
- var activeTask = null;
1915
- var lastValue = null;
1916
- var lastTime = null;
1917
- var emit = function() {
1918
- if (activeTask) {
1919
- activeTask.unsubscribe();
1920
- activeTask = null;
1921
- var value = lastValue;
1922
- lastValue = null;
1923
- subscriber.next(value);
1924
- }
1925
- };
1926
- function emitWhenIdle() {
1927
- var targetTime = lastTime + dueTime;
1928
- var now = scheduler.now();
1929
- if (now < targetTime) {
1930
- activeTask = this.schedule(undefined, targetTime - now);
1931
- subscriber.add(activeTask);
1932
- return;
1933
- }
1934
- emit();
1935
- }
1936
- source.subscribe(createOperatorSubscriber(subscriber, function(value) {
1937
- lastValue = value;
1938
- lastTime = scheduler.now();
1939
- if (!activeTask) {
1940
- activeTask = scheduler.schedule(emitWhenIdle, dueTime);
1941
- subscriber.add(activeTask);
1942
- }
1943
- }, function() {
1944
- emit();
1945
- subscriber.complete();
1946
- }, undefined, function() {
1947
- lastValue = activeTask = null;
1948
- }));
1949
- });
1950
- }
1951
- // node_modules/rxjs/dist/esm5/internal/operators/expand.js
1952
- function expand(project, concurrent, scheduler) {
1953
- if (concurrent === undefined) {
1954
- concurrent = Infinity;
1955
- }
1956
- concurrent = (concurrent || 0) < 1 ? Infinity : concurrent;
1957
- return operate(function(source, subscriber) {
1958
- return mergeInternals(source, subscriber, project, concurrent, undefined, true, scheduler);
1959
- });
1960
- }
1961
- // node_modules/rxjs/dist/esm5/internal/operators/filter.js
1962
- function filter(predicate, thisArg) {
1963
- return operate(function(source, subscriber) {
1964
- var index = 0;
1965
- source.subscribe(createOperatorSubscriber(subscriber, function(value) {
1966
- return predicate.call(thisArg, value, index++) && subscriber.next(value);
1967
- }));
1968
- });
1969
- }
1970
- // node_modules/rxjs/dist/esm5/internal/operators/finalize.js
1971
- function finalize(callback) {
1972
- return operate(function(source, subscriber) {
1973
- try {
1974
- source.subscribe(subscriber);
1975
- } finally {
1976
- subscriber.add(callback);
1977
- }
1978
- });
1979
- }
1980
- // node_modules/rxjs/dist/esm5/internal/operators/groupBy.js
1981
- function groupBy(keySelector, elementOrOptions, duration, connector) {
1982
- return operate(function(source, subscriber) {
1983
- var element;
1984
- if (!elementOrOptions || typeof elementOrOptions === "function") {
1985
- element = elementOrOptions;
1986
- } else {
1987
- duration = elementOrOptions.duration, element = elementOrOptions.element, connector = elementOrOptions.connector;
1988
- }
1989
- var groups = new Map;
1990
- var notify = function(cb) {
1991
- groups.forEach(cb);
1992
- cb(subscriber);
1993
- };
1994
- var handleError = function(err) {
1995
- return notify(function(consumer) {
1996
- return consumer.error(err);
1997
- });
1998
- };
1999
- var activeGroups = 0;
2000
- var teardownAttempted = false;
2001
- var groupBySourceSubscriber = new OperatorSubscriber(subscriber, function(value) {
2002
- try {
2003
- var key_1 = keySelector(value);
2004
- var group_1 = groups.get(key_1);
2005
- if (!group_1) {
2006
- groups.set(key_1, group_1 = connector ? connector() : new Subject);
2007
- var grouped = createGroupedObservable(key_1, group_1);
2008
- subscriber.next(grouped);
2009
- if (duration) {
2010
- var durationSubscriber_1 = createOperatorSubscriber(group_1, function() {
2011
- group_1.complete();
2012
- durationSubscriber_1 === null || durationSubscriber_1 === undefined || durationSubscriber_1.unsubscribe();
2013
- }, undefined, undefined, function() {
2014
- return groups.delete(key_1);
2015
- });
2016
- groupBySourceSubscriber.add(innerFrom(duration(grouped)).subscribe(durationSubscriber_1));
2017
- }
2018
- }
2019
- group_1.next(element ? element(value) : value);
2020
- } catch (err) {
2021
- handleError(err);
2022
- }
2023
- }, function() {
2024
- return notify(function(consumer) {
2025
- return consumer.complete();
2026
- });
2027
- }, handleError, function() {
2028
- return groups.clear();
2029
- }, function() {
2030
- teardownAttempted = true;
2031
- return activeGroups === 0;
2032
- });
2033
- source.subscribe(groupBySourceSubscriber);
2034
- function createGroupedObservable(key, groupSubject) {
2035
- var result = new Observable(function(groupSubscriber) {
2036
- activeGroups++;
2037
- var innerSub = groupSubject.subscribe(groupSubscriber);
2038
- return function() {
2039
- innerSub.unsubscribe();
2040
- --activeGroups === 0 && teardownAttempted && groupBySourceSubscriber.unsubscribe();
2041
- };
2042
- });
2043
- result.key = key;
2044
- return result;
2045
- }
2046
- });
2047
- }
2048
- // node_modules/rxjs/dist/esm5/internal/observable/throwError.js
2049
- function throwError(errorOrErrorFactory, scheduler) {
2050
- var errorFactory = isFunction(errorOrErrorFactory) ? errorOrErrorFactory : function() {
2051
- return errorOrErrorFactory;
2052
- };
2053
- var init = function(subscriber) {
2054
- return subscriber.error(errorFactory());
2055
- };
2056
- return new Observable(scheduler ? function(subscriber) {
2057
- return scheduler.schedule(init, 0, subscriber);
2058
- } : init);
2059
- }
2060
-
2061
- // node_modules/rxjs/dist/esm5/internal/Notification.js
2062
- var NotificationKind;
2063
- (function(NotificationKind2) {
2064
- NotificationKind2["NEXT"] = "N";
2065
- NotificationKind2["ERROR"] = "E";
2066
- NotificationKind2["COMPLETE"] = "C";
2067
- })(NotificationKind || (NotificationKind = {}));
2068
- var Notification = function() {
2069
- function Notification2(kind, value, error) {
2070
- this.kind = kind;
2071
- this.value = value;
2072
- this.error = error;
2073
- this.hasValue = kind === "N";
2074
- }
2075
- Notification2.prototype.observe = function(observer) {
2076
- return observeNotification(this, observer);
2077
- };
2078
- Notification2.prototype.do = function(nextHandler, errorHandler, completeHandler) {
2079
- var _a = this, kind = _a.kind, value = _a.value, error = _a.error;
2080
- return kind === "N" ? nextHandler === null || nextHandler === undefined ? undefined : nextHandler(value) : kind === "E" ? errorHandler === null || errorHandler === undefined ? undefined : errorHandler(error) : completeHandler === null || completeHandler === undefined ? undefined : completeHandler();
2081
- };
2082
- Notification2.prototype.accept = function(nextOrObserver, error, complete) {
2083
- var _a;
2084
- return isFunction((_a = nextOrObserver) === null || _a === undefined ? undefined : _a.next) ? this.observe(nextOrObserver) : this.do(nextOrObserver, error, complete);
2085
- };
2086
- Notification2.prototype.toObservable = function() {
2087
- var _a = this, kind = _a.kind, value = _a.value, error = _a.error;
2088
- var result = kind === "N" ? of(value) : kind === "E" ? throwError(function() {
2089
- return error;
2090
- }) : kind === "C" ? EMPTY : 0;
2091
- if (!result) {
2092
- throw new TypeError("Unexpected notification kind " + kind);
2093
- }
2094
- return result;
2095
- };
2096
- Notification2.createNext = function(value) {
2097
- return new Notification2("N", value);
2098
- };
2099
- Notification2.createError = function(err) {
2100
- return new Notification2("E", undefined, err);
2101
- };
2102
- Notification2.createComplete = function() {
2103
- return Notification2.completeNotification;
2104
- };
2105
- Notification2.completeNotification = new Notification2("C");
2106
- return Notification2;
2107
- }();
2108
- function observeNotification(notification, observer) {
2109
- var _a, _b, _c;
2110
- var _d = notification, kind = _d.kind, value = _d.value, error = _d.error;
2111
- if (typeof kind !== "string") {
2112
- throw new TypeError('Invalid notification, missing "kind"');
2113
- }
2114
- kind === "N" ? (_a = observer.next) === null || _a === undefined || _a.call(observer, value) : kind === "E" ? (_b = observer.error) === null || _b === undefined || _b.call(observer, error) : (_c = observer.complete) === null || _c === undefined || _c.call(observer);
2115
- }
2116
-
2117
- // node_modules/rxjs/dist/esm5/internal/operators/materialize.js
2118
- function materialize() {
2119
- return operate(function(source, subscriber) {
2120
- source.subscribe(createOperatorSubscriber(subscriber, function(value) {
2121
- subscriber.next(Notification.createNext(value));
2122
- }, function() {
2123
- subscriber.next(Notification.createComplete());
2124
- subscriber.complete();
2125
- }, function(err) {
2126
- subscriber.next(Notification.createError(err));
2127
- subscriber.complete();
2128
- }));
2129
- });
2130
- }
2131
- // node_modules/rxjs/dist/esm5/internal/operators/pairwise.js
2132
- function pairwise() {
2133
- return operate(function(source, subscriber) {
2134
- var prev;
2135
- var hasPrev = false;
2136
- source.subscribe(createOperatorSubscriber(subscriber, function(value) {
2137
- var p = prev;
2138
- prev = value;
2139
- hasPrev && subscriber.next([p, value]);
2140
- hasPrev = true;
2141
- }));
2142
- });
2143
- }
2144
- // node_modules/rxjs/dist/esm5/internal/operators/scanInternals.js
2145
- function scanInternals(accumulator, seed, hasSeed, emitOnNext, emitBeforeComplete) {
2146
- return function(source, subscriber) {
2147
- var hasState = hasSeed;
2148
- var state = seed;
2149
- var index = 0;
2150
- source.subscribe(createOperatorSubscriber(subscriber, function(value) {
2151
- var i = index++;
2152
- state = hasState ? accumulator(state, value, i) : (hasState = true, value);
2153
- emitOnNext && subscriber.next(state);
2154
- }, emitBeforeComplete && function() {
2155
- hasState && subscriber.next(state);
2156
- subscriber.complete();
2157
- }));
2158
- };
2159
- }
2160
-
2161
- // node_modules/rxjs/dist/esm5/internal/operators/scan.js
2162
- function scan(accumulator, seed) {
2163
- return operate(scanInternals(accumulator, seed, arguments.length >= 2, true));
2164
- }
2165
- // node_modules/rxjs/dist/esm5/internal/ReplaySubject.js
2166
- var ReplaySubject = function(_super) {
2167
- __extends(ReplaySubject2, _super);
2168
- function ReplaySubject2(_bufferSize, _windowTime, _timestampProvider) {
2169
- if (_bufferSize === undefined) {
2170
- _bufferSize = Infinity;
2171
- }
2172
- if (_windowTime === undefined) {
2173
- _windowTime = Infinity;
2174
- }
2175
- if (_timestampProvider === undefined) {
2176
- _timestampProvider = dateTimestampProvider;
2177
- }
2178
- var _this = _super.call(this) || this;
2179
- _this._bufferSize = _bufferSize;
2180
- _this._windowTime = _windowTime;
2181
- _this._timestampProvider = _timestampProvider;
2182
- _this._buffer = [];
2183
- _this._infiniteTimeWindow = true;
2184
- _this._infiniteTimeWindow = _windowTime === Infinity;
2185
- _this._bufferSize = Math.max(1, _bufferSize);
2186
- _this._windowTime = Math.max(1, _windowTime);
2187
- return _this;
2188
- }
2189
- ReplaySubject2.prototype.next = function(value) {
2190
- var _a = this, isStopped = _a.isStopped, _buffer = _a._buffer, _infiniteTimeWindow = _a._infiniteTimeWindow, _timestampProvider = _a._timestampProvider, _windowTime = _a._windowTime;
2191
- if (!isStopped) {
2192
- _buffer.push(value);
2193
- !_infiniteTimeWindow && _buffer.push(_timestampProvider.now() + _windowTime);
2194
- }
2195
- this._trimBuffer();
2196
- _super.prototype.next.call(this, value);
2197
- };
2198
- ReplaySubject2.prototype._subscribe = function(subscriber) {
2199
- this._throwIfClosed();
2200
- this._trimBuffer();
2201
- var subscription = this._innerSubscribe(subscriber);
2202
- var _a = this, _infiniteTimeWindow = _a._infiniteTimeWindow, _buffer = _a._buffer;
2203
- var copy = _buffer.slice();
2204
- for (var i = 0;i < copy.length && !subscriber.closed; i += _infiniteTimeWindow ? 1 : 2) {
2205
- subscriber.next(copy[i]);
2206
- }
2207
- this._checkFinalizedStatuses(subscriber);
2208
- return subscription;
2209
- };
2210
- ReplaySubject2.prototype._trimBuffer = function() {
2211
- var _a = this, _bufferSize = _a._bufferSize, _timestampProvider = _a._timestampProvider, _buffer = _a._buffer, _infiniteTimeWindow = _a._infiniteTimeWindow;
2212
- var adjustedBufferSize = (_infiniteTimeWindow ? 1 : 2) * _bufferSize;
2213
- _bufferSize < Infinity && adjustedBufferSize < _buffer.length && _buffer.splice(0, _buffer.length - adjustedBufferSize);
2214
- if (!_infiniteTimeWindow) {
2215
- var now = _timestampProvider.now();
2216
- var last2 = 0;
2217
- for (var i = 1;i < _buffer.length && _buffer[i] <= now; i += 2) {
2218
- last2 = i;
2219
- }
2220
- last2 && _buffer.splice(0, last2 + 1);
2221
- }
2222
- };
2223
- return ReplaySubject2;
2224
- }(Subject);
2225
-
2226
- // node_modules/rxjs/dist/esm5/internal/operators/share.js
2227
- function share(options) {
2228
- if (options === undefined) {
2229
- options = {};
2230
- }
2231
- var _a = options.connector, connector = _a === undefined ? function() {
2232
- return new Subject;
2233
- } : _a, _b = options.resetOnError, resetOnError = _b === undefined ? true : _b, _c = options.resetOnComplete, resetOnComplete = _c === undefined ? true : _c, _d = options.resetOnRefCountZero, resetOnRefCountZero = _d === undefined ? true : _d;
2234
- return function(wrapperSource) {
2235
- var connection;
2236
- var resetConnection;
2237
- var subject;
2238
- var refCount = 0;
2239
- var hasCompleted = false;
2240
- var hasErrored = false;
2241
- var cancelReset = function() {
2242
- resetConnection === null || resetConnection === undefined || resetConnection.unsubscribe();
2243
- resetConnection = undefined;
2244
- };
2245
- var reset = function() {
2246
- cancelReset();
2247
- connection = subject = undefined;
2248
- hasCompleted = hasErrored = false;
2249
- };
2250
- var resetAndUnsubscribe = function() {
2251
- var conn = connection;
2252
- reset();
2253
- conn === null || conn === undefined || conn.unsubscribe();
2254
- };
2255
- return operate(function(source, subscriber) {
2256
- refCount++;
2257
- if (!hasErrored && !hasCompleted) {
2258
- cancelReset();
2259
- }
2260
- var dest = subject = subject !== null && subject !== undefined ? subject : connector();
2261
- subscriber.add(function() {
2262
- refCount--;
2263
- if (refCount === 0 && !hasErrored && !hasCompleted) {
2264
- resetConnection = handleReset(resetAndUnsubscribe, resetOnRefCountZero);
2265
- }
2266
- });
2267
- dest.subscribe(subscriber);
2268
- if (!connection && refCount > 0) {
2269
- connection = new SafeSubscriber({
2270
- next: function(value) {
2271
- return dest.next(value);
2272
- },
2273
- error: function(err) {
2274
- hasErrored = true;
2275
- cancelReset();
2276
- resetConnection = handleReset(reset, resetOnError, err);
2277
- dest.error(err);
2278
- },
2279
- complete: function() {
2280
- hasCompleted = true;
2281
- cancelReset();
2282
- resetConnection = handleReset(reset, resetOnComplete);
2283
- dest.complete();
2284
- }
2285
- });
2286
- innerFrom(source).subscribe(connection);
2287
- }
2288
- })(wrapperSource);
2289
- };
2290
- }
2291
- function handleReset(reset, on) {
2292
- var args = [];
2293
- for (var _i = 2;_i < arguments.length; _i++) {
2294
- args[_i - 2] = arguments[_i];
2295
- }
2296
- if (on === true) {
2297
- reset();
2298
- return;
2299
- }
2300
- if (on === false) {
2301
- return;
2302
- }
2303
- var onSubscriber = new SafeSubscriber({
2304
- next: function() {
2305
- onSubscriber.unsubscribe();
2306
- reset();
2307
- }
2308
- });
2309
- return innerFrom(on.apply(undefined, __spreadArray([], __read(args)))).subscribe(onSubscriber);
2310
- }
2311
-
2312
- // node_modules/rxjs/dist/esm5/internal/operators/shareReplay.js
2313
- function shareReplay(configOrBufferSize, windowTime, scheduler) {
2314
- var _a, _b, _c;
2315
- var bufferSize;
2316
- var refCount = false;
2317
- if (configOrBufferSize && typeof configOrBufferSize === "object") {
2318
- _a = configOrBufferSize.bufferSize, bufferSize = _a === undefined ? Infinity : _a, _b = configOrBufferSize.windowTime, windowTime = _b === undefined ? Infinity : _b, _c = configOrBufferSize.refCount, refCount = _c === undefined ? false : _c, scheduler = configOrBufferSize.scheduler;
2319
- } else {
2320
- bufferSize = configOrBufferSize !== null && configOrBufferSize !== undefined ? configOrBufferSize : Infinity;
2321
- }
2322
- return share({
2323
- connector: function() {
2324
- return new ReplaySubject(bufferSize, windowTime, scheduler);
2325
- },
2326
- resetOnError: true,
2327
- resetOnComplete: false,
2328
- resetOnRefCountZero: refCount
2329
- });
2330
- }
2331
- // node_modules/rxjs/dist/esm5/internal/operators/switchMap.js
2332
- function switchMap(project, resultSelector) {
2333
- return operate(function(source, subscriber) {
2334
- var innerSubscriber = null;
2335
- var index = 0;
2336
- var isComplete = false;
2337
- var checkComplete = function() {
2338
- return isComplete && !innerSubscriber && subscriber.complete();
2339
- };
2340
- source.subscribe(createOperatorSubscriber(subscriber, function(value) {
2341
- innerSubscriber === null || innerSubscriber === undefined || innerSubscriber.unsubscribe();
2342
- var innerIndex = 0;
2343
- var outerIndex = index++;
2344
- innerFrom(project(value, outerIndex)).subscribe(innerSubscriber = createOperatorSubscriber(subscriber, function(innerValue) {
2345
- return subscriber.next(resultSelector ? resultSelector(value, innerValue, outerIndex, innerIndex++) : innerValue);
2346
- }, function() {
2347
- innerSubscriber = null;
2348
- checkComplete();
2349
- }));
2350
- }, function() {
2351
- isComplete = true;
2352
- checkComplete();
2353
- }));
2354
- });
2355
- }
2356
- // node_modules/rxjs/dist/esm5/internal/operators/takeUntil.js
2357
- function takeUntil(notifier) {
2358
- return operate(function(source, subscriber) {
2359
- innerFrom(notifier).subscribe(createOperatorSubscriber(subscriber, function() {
2360
- return subscriber.complete();
2361
- }, noop));
2362
- !subscriber.closed && source.subscribe(subscriber);
2363
- });
2364
- }
2365
- // node_modules/rxjs/dist/esm5/internal/operators/takeWhile.js
2366
- function takeWhile(predicate, inclusive) {
2367
- if (inclusive === undefined) {
2368
- inclusive = false;
2369
- }
2370
- return operate(function(source, subscriber) {
2371
- var index = 0;
2372
- source.subscribe(createOperatorSubscriber(subscriber, function(value) {
2373
- var result = predicate(value, index++);
2374
- (result || inclusive) && subscriber.next(value);
2375
- !result && subscriber.complete();
2376
- }));
2377
- });
2378
- }
2379
- // node_modules/rxjs/dist/esm5/internal/operators/tap.js
2380
- function tap(observerOrNext, error, complete) {
2381
- var tapObserver = isFunction(observerOrNext) || error || complete ? { next: observerOrNext, error, complete } : observerOrNext;
2382
- return tapObserver ? operate(function(source, subscriber) {
2383
- var _a;
2384
- (_a = tapObserver.subscribe) === null || _a === undefined || _a.call(tapObserver);
2385
- var isUnsub = true;
2386
- source.subscribe(createOperatorSubscriber(subscriber, function(value) {
2387
- var _a2;
2388
- (_a2 = tapObserver.next) === null || _a2 === undefined || _a2.call(tapObserver, value);
2389
- subscriber.next(value);
2390
- }, function() {
2391
- var _a2;
2392
- isUnsub = false;
2393
- (_a2 = tapObserver.complete) === null || _a2 === undefined || _a2.call(tapObserver);
2394
- subscriber.complete();
2395
- }, function(err) {
2396
- var _a2;
2397
- isUnsub = false;
2398
- (_a2 = tapObserver.error) === null || _a2 === undefined || _a2.call(tapObserver, err);
2399
- subscriber.error(err);
2400
- }, function() {
2401
- var _a2, _b;
2402
- if (isUnsub) {
2403
- (_a2 = tapObserver.unsubscribe) === null || _a2 === undefined || _a2.call(tapObserver);
2404
- }
2405
- (_b = tapObserver.finalize) === null || _b === undefined || _b.call(tapObserver);
2406
- }));
2407
- }) : identity;
2408
- }
2409
- // src/LivequeryDocument.ts
2410
- class LivequeryDocument extends BehaviorSubject {
2411
- collection;
2412
- document;
2413
- constructor(collection, document) {
2414
- super(document);
2415
- this.collection = collection;
2416
- this.document = document;
2417
- }
2418
- update(data) {
2419
- const id = this.value.id;
2420
- return this.collection.update(id, data);
2421
- }
2422
- del() {
2423
- const id = this.value.id;
2424
- return this.collection.delete(id);
2425
- }
2426
- trigger(action, payload) {
2427
- return this.collection.trigger(action, payload);
2428
- }
2429
- }
2430
-
2431
- // src/LivequeryCollection.ts
2432
- class LivequeryCollection {
2433
- options;
2434
- id = (Math.random() * 1000000000000000000).toString(36);
2435
- #keys = new Map;
2436
- #indexes;
2437
- #core;
2438
- #filters = new Subject;
2439
- ref;
2440
- collection_ref;
2441
- items;
2442
- summary;
2443
- metadata;
2444
- loading;
2445
- filters;
2446
- paging;
2447
- error;
2448
- constructor(options = {}) {
2449
- this.options = options;
2450
- this.#indexes = new Map;
2451
- this.items = new BehaviorSubject([]);
2452
- this.summary = new BehaviorSubject({});
2453
- this.loading = new BehaviorSubject(null);
2454
- this.filters = new BehaviorSubject(options?.filters || {});
2455
- this.paging = new BehaviorSubject({
2456
- total: 0,
2457
- current: 0
2458
- });
2459
- this.error = new BehaviorSubject(null);
2460
- if (options) {
2461
- this.options = options;
2462
- }
2463
- }
2464
- #commit(items) {
2465
- this.items.next(items);
2466
- this.#indexes = items.reduce((p, c, index) => {
2467
- p.set(c.value.id, index);
2468
- return p;
2469
- }, new Map);
2470
- }
2471
- #subscription = null;
2472
- initialize(core, ref) {
2473
- if (typeof window == "undefined")
2474
- return;
2475
- this.ref = ref;
2476
- const refs = ref.split("/");
2477
- this.collection_ref = refs.length % 2 == 0 ? refs.slice(0, -1).join("/") : ref;
2478
- this.#core = core;
2479
- const timer2 = this.options.lazy !== true && setTimeout(() => !ref.includes("undefined") && this.query(this.filters.value || {}));
2480
- this.#subscription?.unsubscribe();
2481
- this.#subscription = merge(this.options.debounce ? merge(this.#filters.pipe(debounceTime(this.options.debounce), switchMap((filters) => this.query(filters)))) : EMPTY, core.watch(this.ref, this.id, this.options.mode || "server-first").pipe(finalize(() => {
2482
- timer2 && clearTimeout(timer2);
2483
- }), tap((event) => {
2484
- event.loading !== undefined && event.loading !== this.loading.value && this.loading.next(event.loading);
2485
- event.summary && this.summary.next(event.summary);
2486
- event.metadata && this.metadata.next(event.metadata);
2487
- event.paging && this.paging.next(event.paging);
2488
- event.error && this.error.next(event.error);
2489
- if (!event.changes || event.changes.length == 0)
2490
- return;
2491
- const chaos = event.changes && event.changes.some((change) => {
2492
- if (change.type == "added" || change.type == "removed")
2493
- return true;
2494
- if (change.data && change.data.id != change.id)
2495
- return true;
2496
- return Object.keys(change.data || {}).some((k) => this.#keys.has(k));
2497
- });
2498
- const sorter = (a, b) => {
2499
- for (const [key, order] of this.#keys) {
2500
- const va = a.value[key];
2501
- const vb = b.value[key];
2502
- if (typeof va === "number" && typeof vb === "number") {
2503
- if (va < vb)
2504
- return -order;
2505
- if (va > vb)
2506
- return order;
2507
- }
2508
- if (typeof va === "string" && typeof vb === "string") {
2509
- if (va < vb)
2510
- return -order;
2511
- if (va > vb)
2512
- return order;
2513
- }
2514
- }
2515
- return 0;
2516
- };
2517
- const events = event.changes.reduce((p, c) => {
2518
- return {
2519
- ...p,
2520
- [c.type]: [
2521
- ...p[c.type] || [],
2522
- c
2523
- ]
2524
- };
2525
- }, {
2526
- added: [],
2527
- modified: [],
2528
- removed: []
2529
- });
2530
- const updated_items = events.modified.reduce((p, { data, id }) => {
2531
- const index = this.#indexes.get(id);
2532
- const target = index != null && index >= 0 ? p[index] : null;
2533
- target && target.next({ ...target.value, ...data });
2534
- return p;
2535
- }, this.items.value);
2536
- const new_items = events.added.filter((a) => a.data).reduce((p, c) => {
2537
- if (!p.indexes.has(c.id)) {
2538
- const doc = new LivequeryDocument(this, { id: c.id, ...c.data });
2539
- p.list.push(doc);
2540
- p.indexes.add(c.id);
2541
- }
2542
- return p;
2543
- }, {
2544
- list: [],
2545
- indexes: new Set(this.#indexes.keys())
2546
- });
2547
- const remove_indexes = events.removed.map((r) => this.#indexes.get(r.id)).filter((i) => i != null).sort((a, b) => b - a);
2548
- const unsort_items = remove_indexes.reduce((p, index) => {
2549
- return [
2550
- ...p.slice(0, index),
2551
- ...p.slice(index + 1)
2552
- ];
2553
- }, [
2554
- ...updated_items,
2555
- ...new_items.list
2556
- ]);
2557
- const items = chaos ? unsort_items.sort(sorter) : unsort_items;
2558
- chaos && this.#commit(items);
2559
- event.paging && this.paging.next(event.paging);
2560
- }))).subscribe();
2561
- return this.#subscription;
2562
- }
2563
- async#query(filters, flush) {
2564
- if (!this.#core)
2565
- return;
2566
- if (!this.ref)
2567
- return;
2568
- this.error.next(null);
2569
- flush && this.#commit([]);
2570
- this.#keys = Object.entries(filters).reduce((p, [k, v]) => {
2571
- if (k.endsWith(":sort")) {
2572
- const field = k.split(":")[0];
2573
- p.set(field, v === "asc" ? 1 : -1);
2574
- }
2575
- return p;
2576
- }, new Map);
2577
- this.filters.next(filters);
2578
- const cache = await this.#core.query({
2579
- ref: this.ref,
2580
- filters,
2581
- collection_id: this.id
2582
- });
2583
- if (cache && cache.documents && flush) {
2584
- this.#commit(cache.documents.map((i) => new LivequeryDocument(this, i)));
2585
- }
2586
- }
2587
- async query(filters) {
2588
- await this.#query(filters, true);
2589
- }
2590
- async debounceQuery(filters) {
2591
- this.#filters.next(filters);
2592
- }
2593
- async loadMore() {
2594
- const next = this.paging.value.next;
2595
- if (!next)
2596
- return;
2597
- const filters = {
2598
- ...this.filters.value,
2599
- ":after": next.cursor
2600
- };
2601
- await this.#query(filters || {}, false);
2602
- }
2603
- async loadPrev() {
2604
- const prev = this.paging.value.prev;
2605
- if (!prev)
2606
- return;
2607
- const filters = {
2608
- ...this.filters.value,
2609
- ":before": prev.cursor
2610
- };
2611
- await this.#query(filters || {}, false);
2612
- }
2613
- async loadAround(cursor) {
2614
- const filters = {
2615
- ...this.filters.value,
2616
- ":after": cursor,
2617
- ":before": cursor
2618
- };
2619
- await this.#query(filters || {}, false);
2620
- }
2621
- add(payload) {
2622
- if (!this.#core)
2623
- throw new Error("LivequeryCollection is not initialized with a core instance");
2624
- if (!this.collection_ref)
2625
- throw new Error("LivequeryCollection is not initialized with a ref");
2626
- return this.#core.add(this.collection_ref, payload);
2627
- }
2628
- update(id, payload) {
2629
- if (!this.#core)
2630
- throw new Error("LivequeryCollection is not initialized with a core instance");
2631
- if (!this.collection_ref)
2632
- throw new Error("LivequeryCollection is not initialized with a ref");
2633
- return this.#core.update(this.collection_ref, id, payload);
2634
- }
2635
- delete(id) {
2636
- if (!this.#core)
2637
- throw new Error("LivequeryCollection is not initialized with a core instance");
2638
- if (!this.collection_ref)
2639
- throw new Error("LivequeryCollection is not initialized with a ref");
2640
- return this.#core.delete(this.collection_ref, id);
2641
- }
2642
- trigger(action, payload) {
2643
- if (!this.#core)
2644
- throw new Error("LivequeryCollection is not initialized with a core instance");
2645
- if (!this.ref)
2646
- throw new Error("LivequeryCollection is not initialized with a ref");
2647
- return this.#core.trigger({
2648
- action,
2649
- payload,
2650
- ref: this.ref
2651
- });
2652
- }
2653
- resetError() {
2654
- this.error.next(null);
2655
- }
2656
- watch(check) {
2657
- return this.items.pipe(switchMap((items) => merge(...items.map((item) => item.pipe(pairwise(), filter(([p, n]) => {
2658
- return check(p, n);
2659
- }))))));
2660
- }
2661
- }
2662
- // src/helpers/tryCatch.ts
2663
- var tryCatch = async (fn) => {
2664
- try {
2665
- const result = await fn();
2666
- return [undefined, result];
2667
- } catch (error) {
2668
- return [error, undefined];
2669
- }
2670
- };
2671
-
2672
- // src/helpers/whenCompleted.ts
2673
- function whenCompleted(stream) {
2674
- return stream.pipe(materialize(), filter((n) => n.kind === "C" || n.kind === "E"), map(() => {
2675
- return;
2676
- }), shareReplay(1));
2677
- }
2678
-
2679
- // src/helpers/filterDocs.ts
2680
- function filterDocs(documents, filters) {
2681
- if (!filters)
2682
- return documents;
2683
- const normalized = filters;
2684
- return documents.filter((doc) => matchesAllFilters(doc, normalized));
2685
- }
2686
- function matchesAllFilters(doc, filters) {
2687
- for (const [key, expected] of Object.entries(filters)) {
2688
- if (key.startsWith(":") || key.endsWith(":sort"))
2689
- continue;
2690
- const split = key.split(":");
2691
- const fieldPath = split[0];
2692
- if (!fieldPath)
2693
- continue;
2694
- const op = split[1] || "eq";
2695
- const actual = getByPath(doc, fieldPath);
2696
- if (!matchByOperator(actual, op, expected)) {
2697
- return false;
2698
- }
2699
- }
2700
- return true;
2701
- }
2702
- function matchByOperator(actual, op, expected) {
2703
- switch (op) {
2704
- case "gt":
2705
- return asNumber(actual) > asNumber(expected);
2706
- case "gte":
2707
- return asNumber(actual) >= asNumber(expected);
2708
- case "lt":
2709
- return asNumber(actual) < asNumber(expected);
2710
- case "lte":
2711
- return asNumber(actual) <= asNumber(expected);
2712
- case "eq-number":
2713
- return asNumber(actual) === asNumber(expected);
2714
- case "in":
2715
- return Array.isArray(expected) ? expected.includes(actual) : false;
2716
- case "nin":
2717
- return Array.isArray(expected) ? !expected.includes(actual) : true;
2718
- case "include":
2719
- return Array.isArray(actual) ? actual.includes(expected) : false;
2720
- case "boolean":
2721
- return matchBoolean(actual, expected);
2722
- case "like":
2723
- return String(actual || "").toLowerCase().includes(String(expected || "").toLowerCase());
2724
- case "null":
2725
- return expected === "null-only" ? actual === null || typeof actual === "undefined" : actual !== null && typeof actual !== "undefined";
2726
- case "eq":
2727
- default:
2728
- return actual === expected;
2729
- }
2730
- }
2731
- function matchBoolean(actual, expected) {
2732
- switch (expected) {
2733
- case "true":
2734
- return actual === true;
2735
- case "false":
2736
- return actual === false;
2737
- case "not-true":
2738
- return actual !== true;
2739
- case "not-false":
2740
- return actual !== false;
2741
- default:
2742
- return false;
2743
- }
2744
- }
2745
- function getByPath(obj, path) {
2746
- if (!path.includes("."))
2747
- return obj[path];
2748
- return path.split(".").reduce((acc, key) => {
2749
- if (!acc || typeof acc !== "object")
2750
- return;
2751
- return acc[key];
2752
- }, obj);
2753
- }
2754
- function asNumber(value) {
2755
- return Number(value);
2756
- }
2757
-
2758
- // src/LivequeryCore.ts
2759
- class LivequeryCore {
2760
- config;
2761
- #collections = new Map;
2762
- #refs = new Map;
2763
- #queries$ = new Subject;
2764
- #adding = new Map;
2765
- constructor(config3) {
2766
- this.config = config3;
2767
- this.#start();
2768
- }
2769
- #cache = new Map;
2770
- #query(e, deduplicate_key) {
2771
- const clear = () => deduplicate_key && this.#cache.delete(deduplicate_key);
2772
- const cached = deduplicate_key && this.#cache.get(deduplicate_key);
2773
- if (cached)
2774
- return Object.assign(cached, { clear });
2775
- const $ = from(Object.values(this.config.transporters)).pipe(mergeMap((transporter) => transporter.query(e).pipe(tap((result) => {
2776
- for (const change of result.changes || []) {
2777
- change.type == "added" && change.data && this.config.storage.add(change.collection_ref, {
2778
- id: change.data.id,
2779
- ...change.data
2780
- });
2781
- change.type == "modified" && change.data && this.config.storage.update(change.collection_ref, change.id, change.data);
2782
- change.type == "removed" && this.config.storage.delete(change.collection_ref, change.id);
2783
- }
2784
- }), map((result, index) => ({ result, index })), mergeMap(({ result, index }) => {
2785
- if (index == 0)
2786
- return of(result);
2787
- const changes = result.changes || [];
2788
- if (changes.length === 0)
2789
- return EMPTY;
2790
- const lock$ = this.#adding.get(e.collection.collection_ref);
2791
- if (!lock$) {
2792
- this.#broadcast(e.collection.collection_ref, "realtime", changes);
2793
- return EMPTY;
2794
- }
2795
- const ok_changes = changes.filter((c) => c.type != "added");
2796
- const delay_changes = changes.filter((c) => c.type == "added");
2797
- this.#broadcast(e.collection.collection_ref, "realtime", ok_changes);
2798
- return lock$.pipe(tap(() => this.#broadcast(e.collection.collection_ref, "realtime", delay_changes)), switchMap(() => EMPTY));
2799
- }))), finalize(clear), shareReplay());
2800
- deduplicate_key && this.#cache.set(deduplicate_key, $);
2801
- return Object.assign($, { clear });
2802
- }
2803
- #start() {
2804
- lastValueFrom(merge(this.#queries$.pipe(filter((req) => req.collection.mode == "server-first" || req.collection.mode == "cache-first"), mergeMap((e) => {
2805
- const deduplicate_key = `${e.collection.collection_id}:${JSON.stringify(e.filters)}`;
2806
- const before = e.filters?.[":before"];
2807
- const after = e.filters?.[":after"];
2808
- const around = e.filters?.[":around"];
2809
- const loading = !before && !after || before && after || around ? "all" : before ? "prev" : "next";
2810
- e.collection.data$.next({
2811
- from: "query",
2812
- loading: e.collection.document_id ? "all" : loading
2813
- });
2814
- return this.#query(e, deduplicate_key).pipe(takeUntil(whenCompleted(e.collection.data$)), tap((result) => {
2815
- e.collection.data$.next({
2816
- ...result,
2817
- from: "query",
2818
- loading: null
2819
- });
2820
- }));
2821
- })), this.#queries$.pipe(filter((req) => req.collection.mode == "local-first"), groupBy((e) => `${e.collection.collection_ref}/${e.collection.document_id || "::"}`), mergeMap(($) => $.pipe(mergeMap((e, index) => {
2822
- index == 0 && e.collection.data$.next({
2823
- from: "query",
2824
- loading: "all"
2825
- });
2826
- return merge(of(e), index > 0 ? EMPTY : defer(() => {
2827
- return this.#query(e).pipe(expand((res) => {
2828
- const next = res.paging?.next;
2829
- if (!next)
2830
- return EMPTY;
2831
- return this.#query({
2832
- ...e,
2833
- filters: { ":after": next.cursor }
2834
- });
2835
- }), tap((result) => {
2836
- this.#broadcast(e.collection.collection_ref, "query", result.changes || []);
2837
- }));
2838
- }).pipe(switchMap(() => EMPTY)));
2839
- }), scan((p, c) => new Set([...p, c.collection.data$].filter(($2) => !$2.closed)), new Set), map((set) => [...set].map(($2) => whenCompleted($2))), switchMap((list) => forkJoin(list)), takeWhile(() => false))))));
2840
- }
2841
- watch(ref, collection_id, mode) {
2842
- const refs = ref.split("/");
2843
- const document_id = refs.length % 2 == 0 ? refs[refs.length - 1] : undefined;
2844
- const collection_ref = refs.length % 2 == 0 ? refs.slice(0, -1).join("/") : ref;
2845
- const collections = this.#refs.get(collection_ref) || new Set;
2846
- collections.add(collection_id);
2847
- this.#refs.set(collection_ref, collections);
2848
- const data$ = new Subject;
2849
- this.#collections.set(collection_id, {
2850
- data$,
2851
- document_id,
2852
- collection_id,
2853
- collection_ref,
2854
- mode,
2855
- filters: {}
2856
- });
2857
- return data$.pipe(finalize(() => {
2858
- this.#collections.delete(collection_id);
2859
- collections.delete(collection_id);
2860
- if (collections.size === 0) {
2861
- this.#refs.delete(collection_ref);
2862
- }
2863
- }));
2864
- }
2865
- async query(req) {
2866
- const collection = this.#collections.get(req.collection_id);
2867
- if (!collection)
2868
- throw new Error(`Collection with id ${req.collection_id} not found`);
2869
- if (collection.document_id) {
2870
- const ids = this.#refs.get(collection.collection_ref);
2871
- const collections = ids ? [...ids].map((id) => this.#collections.get(id)).filter((c) => c && c.document_id) : [];
2872
- const doc = await this.config.storage.get(collection.collection_ref, collection.document_id);
2873
- if (collections.length > 0 && doc)
2874
- return {
2875
- documents: [doc]
2876
- };
2877
- }
2878
- setTimeout(() => this.#queries$.next({
2879
- ...req,
2880
- filters: collection.mode == "local-first" ? {} : req.filters,
2881
- collection
2882
- }));
2883
- collection.filters = req.filters || {};
2884
- if (collection.mode == "local-first") {
2885
- return await this.config.storage.query(req.ref, req.filters);
2886
- }
2887
- if (collection.mode == "cache-first") {
2888
- const before = req.filters?.[":before"];
2889
- const after = req.filters?.[":after"];
2890
- const is_first_query = !before && !after;
2891
- if (is_first_query) {
2892
- return await this.config.storage.query(req.ref, req.filters);
2893
- }
2894
- }
2895
- }
2896
- #broadcast(collection_ref, from2, events) {
2897
- const collections = this.#refs.get(collection_ref) || new Set;
2898
- for (const collection_id of collections) {
2899
- const collection = this.#collections.get(collection_id);
2900
- if (!collection)
2901
- continue;
2902
- if (collection.document_id) {
2903
- const change = events.find((c) => c.id == collection.document_id);
2904
- change && collection.data$.next({
2905
- changes: [change],
2906
- from: from2,
2907
- loading: null
2908
- });
2909
- continue;
2910
- }
2911
- if (collection.mode == "local-first") {
2912
- const changes = events.filter((e) => {
2913
- if (e.type == "added")
2914
- return e.data && matchesAllFilters(e.data, collection.filters);
2915
- return true;
2916
- });
2917
- collection.data$.next({
2918
- changes,
2919
- from: from2,
2920
- ...from2 == "query" ? { loading: null } : {}
2921
- });
2922
- continue;
2923
- }
2924
- collection.data$.next({
2925
- changes: events,
2926
- from: from2,
2927
- ...from2 == "query" ? { loading: null } : {}
2928
- });
2929
- }
2930
- }
2931
- #push(collection_ref, id, doc) {
2932
- const cleanDoc = Object.entries(doc).reduce((p, [k, v]) => {
2933
- if (k.startsWith("_"))
2934
- return p;
2935
- return { ...p, [k]: v };
2936
- }, {});
2937
- return lastValueFrom(from(Object.entries(this.config.transporters)).pipe(concatMap(async ([_transporterId, transporter]) => {
2938
- if (String(id).startsWith("local:")) {
2939
- const o = new Subject;
2940
- this.#adding.set(collection_ref, o);
2941
- const [e, data] = await tryCatch(() => transporter.add(collection_ref, cleanDoc));
2942
- if (data && data.id) {
2943
- const fnd = {
2944
- ...data,
2945
- _adding: undefined,
2946
- ...e ? { _adding_error: e } : {}
2947
- };
2948
- await this.config.storage.update(collection_ref, id, fnd);
2949
- this.#broadcast(collection_ref, "action", [{
2950
- collection_ref,
2951
- type: "modified",
2952
- id,
2953
- data: fnd
2954
- }]);
2955
- }
2956
- o.next();
2957
- o.complete();
2958
- this.#adding.delete(collection_ref);
2959
- }
2960
- if (doc._deleting) {
2961
- const [e] = await tryCatch(() => transporter.delete(collection_ref, id));
2962
- if (e) {
2963
- const fnd = {
2964
- _deleting: undefined,
2965
- _deleting_error: e
2966
- };
2967
- await this.config.storage.update(collection_ref, id, fnd);
2968
- this.#broadcast(collection_ref, "action", [{
2969
- collection_ref,
2970
- type: "modified",
2971
- id,
2972
- data: fnd
2973
- }]);
2974
- } else {
2975
- await this.config.storage.delete(collection_ref, id);
2976
- this.#broadcast(collection_ref, "action", [{
2977
- collection_ref,
2978
- type: "removed",
2979
- id
2980
- }]);
2981
- }
2982
- }
2983
- if (doc._prev && Object.keys(doc._prev).length > 0) {
2984
- const changedFields = Object.keys(doc._prev).reduce((acc, key) => ({
2985
- ...acc,
2986
- [key]: doc[key]
2987
- }), {});
2988
- const [e] = await tryCatch(() => transporter.update(collection_ref, id, changedFields));
2989
- const fnd = {
2990
- _prev: undefined,
2991
- _updating: undefined,
2992
- _updating_error: e
2993
- };
2994
- await this.config.storage.update(collection_ref, id, fnd);
2995
- this.#broadcast(collection_ref, "action", [{
2996
- collection_ref,
2997
- type: "modified",
2998
- id,
2999
- data: fnd
3000
- }]);
3001
- }
3002
- return EMPTY;
3003
- })), { defaultValue: undefined });
3004
- }
3005
- async add(collection_ref, doc) {
3006
- const data = await this.config.storage.add(collection_ref, { ...doc, _adding: true });
3007
- this.#broadcast(collection_ref, "action", [{
3008
- collection_ref,
3009
- id: data.id,
3010
- type: "added",
3011
- data
3012
- }]);
3013
- await this.#push(collection_ref, data.id, data);
3014
- return data;
3015
- }
3016
- async update(collection_ref, id, data) {
3017
- const old = await this.config.storage.get(collection_ref, id);
3018
- if (!old)
3019
- return;
3020
- const _prev = Object.keys(data).reduce((acc, key) => {
3021
- if (key in (old._prev || {}))
3022
- return acc;
3023
- return {
3024
- ...acc,
3025
- [key]: old[key]
3026
- };
3027
- }, old._prev || {});
3028
- await this.config.storage.update(collection_ref, id, { _prev, _updating: true, ...data });
3029
- const doc = await this.#broadcast(collection_ref, "action", [{
3030
- collection_ref,
3031
- id,
3032
- type: "modified",
3033
- data: {
3034
- _prev,
3035
- _updating: true,
3036
- ...data
3037
- }
3038
- }]);
3039
- await this.#push(collection_ref, id, { ...data, _prev, _updating: true });
3040
- return doc;
3041
- }
3042
- async delete(collection_ref, id) {
3043
- const soft = Object.keys(this.config.transporters).length > 0;
3044
- const is_local_doc = id.startsWith("local:");
3045
- if (!soft || is_local_doc) {
3046
- await this.config.storage.delete(collection_ref, id);
3047
- await this.#broadcast(collection_ref, "action", [{
3048
- collection_ref,
3049
- id,
3050
- type: "removed"
3051
- }]);
3052
- return;
3053
- }
3054
- await this.config.storage.update(collection_ref, id, { _deleting: true });
3055
- const doc = await this.#broadcast(collection_ref, "action", [{
3056
- collection_ref,
3057
- id,
3058
- type: "modified",
3059
- data: {
3060
- _deleting: true
3061
- }
3062
- }]);
3063
- await this.#push(collection_ref, id, { _deleting: true });
3064
- return doc;
3065
- }
3066
- trigger(action) {
3067
- return from(Object.values(this.config.transporters)).pipe(mergeMap((transporter) => transporter.trigger(action)));
3068
- }
3069
- }
3070
- // src/LivequeryMemoryStorage.ts
3071
- class LivequeryMemoryStorage {
3072
- #collections = new Map;
3073
- async query(collection, filters) {
3074
- const sources = Array.from((this.#collections.get(collection) || new Map).values());
3075
- const f = filters || {};
3076
- const sorters = Object.entries(f).filter(([k]) => k.endsWith(":sort"));
3077
- const items = filterDocs(sources, f);
3078
- const sorted = this.#sortItems(items, sorters);
3079
- return {
3080
- documents: sorted,
3081
- paging: {
3082
- total: items.length,
3083
- current: sorted.length
3084
- }
3085
- };
3086
- }
3087
- get(ref, id) {
3088
- const docs = this.#collections.get(ref);
3089
- if (!docs)
3090
- return Promise.resolve(null);
3091
- const doc = docs.get(id) || null;
3092
- return Promise.resolve(doc);
3093
- }
3094
- async add(collection, document) {
3095
- const docs = this.#collections.get(collection) || new Map;
3096
- const doc = {
3097
- ...document,
3098
- id: document.id || `local:${crypto.randomUUID()}`
3099
- };
3100
- docs.set(doc.id, doc);
3101
- this.#collections.set(collection, docs);
3102
- return doc;
3103
- }
3104
- async update(collection, id, document) {
3105
- const docs = this.#collections.get(collection);
3106
- if (!docs)
3107
- return null;
3108
- const existing = docs.get(id);
3109
- if (!existing)
3110
- return null;
3111
- const next = {
3112
- ...existing,
3113
- ...document
3114
- };
3115
- if (document.id && document.id !== id) {
3116
- docs.delete(id);
3117
- docs.set(document.id, next);
3118
- } else {
3119
- docs.set(id, next);
3120
- }
3121
- return next;
3122
- }
3123
- async delete(collection, id) {
3124
- const docs = this.#collections.get(collection);
3125
- if (!docs)
3126
- return null;
3127
- const deleted = docs.get(id) || null;
3128
- docs.delete(id);
3129
- return deleted;
3130
- }
3131
- #sortItems(items, sorters) {
3132
- if (sorters.length === 0)
3133
- return [...items];
3134
- return [...items].sort((a, b) => {
3135
- for (const [sortKey, direction] of sorters) {
3136
- const fieldPath = sortKey.slice(0, -5);
3137
- const va = this.#getByPath(a, fieldPath);
3138
- const vb = this.#getByPath(b, fieldPath);
3139
- if (va === vb)
3140
- continue;
3141
- const order = va < vb ? -1 : 1;
3142
- return direction === "asc" ? order : -order;
3143
- }
3144
- return 0;
3145
- });
3146
- }
3147
- #getByPath(obj, path) {
3148
- if (!path.includes("."))
3149
- return obj[path];
3150
- return path.split(".").reduce((acc, key) => {
3151
- if (!acc || typeof acc !== "object")
3152
- return;
3153
- return acc[key];
3154
- }, obj);
3155
- }
3156
- }
3157
- export {
3158
- matchesAllFilters,
3159
- filterDocs,
3160
- LivequeryMemoryStorage,
3161
- LivequeryDocument,
3162
- LivequeryCore,
3163
- LivequeryCollection
3164
- };
3165
-
3166
- //# debugId=3B6903F16D5160B864756E2164756E21
3167
- //# sourceMappingURL=index.js.map
1
+ export * from "./LivequeryCollection.js";
2
+ export * from "./LivequeryCore.js";
3
+ export * from "./LivequeryMemoryStorage.js";
4
+ export * from "./LivequeryStorge.js";
5
+ export * from "./LivequeryTransporter.js";
6
+ export * from "./types.js";
7
+ export * from "./helpers/filterDocs.js";
8
+ export * from "./LivequeryDocument.js";
9
+ //# sourceMappingURL=index.js.map