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