dexie-cloud-addon 4.0.1-beta.37 → 4.0.1-beta.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modern/dexie-cloud-addon.js +35 -3
- package/dist/modern/dexie-cloud-addon.js.map +1 -1
- package/dist/modern/dexie-cloud-addon.min.js +1 -1
- package/dist/modern/dexie-cloud-addon.min.js.map +1 -1
- package/dist/modern/service-worker.js +172 -1760
- package/dist/modern/service-worker.js.map +1 -1
- package/dist/modern/service-worker.min.js +1 -1
- package/dist/modern/service-worker.min.js.map +1 -1
- package/dist/types/DexieCloudAPI.d.ts +11 -11
- package/dist/umd/dexie-cloud-addon.js +2765 -3812
- package/dist/umd/dexie-cloud-addon.js.map +1 -1
- package/dist/umd/dexie-cloud-addon.min.js +2 -1
- package/dist/umd/dexie-cloud-addon.min.js.map +1 -1
- package/dist/umd/service-worker.js +205 -1794
- package/dist/umd/service-worker.js.map +1 -1
- package/dist/umd/service-worker.min.js +1 -1
- package/dist/umd/service-worker.min.js.map +1 -1
- package/package.json +14 -26
- package/dist/module-es5/dexie-cloud-addon.js +0 -7388
- package/dist/module-es5/dexie-cloud-addon.js.map +0 -1
- package/dist/module-es5/dexie-cloud-addon.min.js +0 -2
- package/dist/module-es5/dexie-cloud-addon.min.js.map +0 -1
- package/dist/types/DexieCloudEntity.d.ts +0 -8
- package/dist/types/DexieCloudServerState.d.ts +0 -5
- package/dist/types/WebSocketStatus.d.ts +0 -1
- package/dist/types/createMyMembersObservable.d.ts +0 -14
- package/dist/types/currentUserObservable.d.ts +0 -3
- package/dist/types/helpers/BroadcastedLocalEvent.d.ts +0 -8
- package/dist/types/helpers/visibleState.d.ts +0 -1
- package/dist/types/permissionsLookup.d.ts +0 -9
- package/dist/types/permissionsLookupObservable.d.ts +0 -14
- package/dist/types/sync/globalizePrivateIds.d.ts +0 -4
- package/dist/types/sync/syncServerToClientOnly.d.ts +0 -3
- package/dist/types/types/CloudConnectionStatus.d.ts +0 -0
- package/dist/types/types/ConnectionStatus.d.ts +0 -0
- package/dist/types/types/LoginState.d.ts +0 -41
- package/dist/types/types/SyncConnectionStatus.d.ts +0 -1
- package/dist/types/types/SyncFlowStatus.d.ts +0 -6
- package/dist/types/types/SyncStatus.d.ts +0 -6
- package/dist/umd-modern/dexie-cloud-addon.js +0 -6323
- package/dist/umd-modern/dexie-cloud-addon.js.map +0 -1
- package/dist/umd-modern/dexie-cloud-addon.min.js +0 -2
- package/dist/umd-modern/dexie-cloud-addon.min.js.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Dexie, { cmp, liveQuery } from 'dexie';
|
|
2
|
-
import { Observable
|
|
2
|
+
import { Observable, BehaviorSubject, Subject, of, fromEvent, merge, Subscription, from, throwError, combineLatest, map as map$1, share, timer } from 'rxjs';
|
|
3
|
+
import { filter, take, switchMap, delay, distinctUntilChanged, map, tap, catchError, timeout, debounceTime, startWith, skip } from 'rxjs/operators';
|
|
3
4
|
|
|
4
5
|
/******************************************************************************
|
|
5
6
|
Copyright (c) Microsoft Corporation.
|
|
@@ -15,22 +16,6 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
15
16
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
16
17
|
PERFORMANCE OF THIS SOFTWARE.
|
|
17
18
|
***************************************************************************** */
|
|
18
|
-
/* global Reflect, Promise */
|
|
19
|
-
|
|
20
|
-
var extendStatics = function(d, b) {
|
|
21
|
-
extendStatics = Object.setPrototypeOf ||
|
|
22
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
23
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
24
|
-
return extendStatics(d, b);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
function __extends(d, b) {
|
|
28
|
-
if (typeof b !== "function" && b !== null)
|
|
29
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
30
|
-
extendStatics(d, b);
|
|
31
|
-
function __() { this.constructor = d; }
|
|
32
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
33
|
-
}
|
|
34
19
|
|
|
35
20
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
36
21
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
@@ -38,1764 +23,159 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
38
23
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
24
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
25
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function __generator(thisArg, body) {
|
|
46
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
47
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
48
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
|
-
function step(op) {
|
|
50
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
51
|
-
while (_) try {
|
|
52
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
53
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
54
|
-
switch (op[0]) {
|
|
55
|
-
case 0: case 1: t = op; break;
|
|
56
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
57
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
58
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
59
|
-
default:
|
|
60
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
61
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
62
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
63
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
64
|
-
if (t[2]) _.ops.pop();
|
|
65
|
-
_.trys.pop(); continue;
|
|
66
|
-
}
|
|
67
|
-
op = body.call(thisArg, _);
|
|
68
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
69
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function __values(o) {
|
|
74
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
75
|
-
if (m) return m.call(o);
|
|
76
|
-
if (o && typeof o.length === "number") return {
|
|
77
|
-
next: function () {
|
|
78
|
-
if (o && i >= o.length) o = void 0;
|
|
79
|
-
return { value: o && o[i++], done: !o };
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function __read(o, n) {
|
|
86
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
87
|
-
if (!m) return o;
|
|
88
|
-
var i = m.call(o), r, ar = [], e;
|
|
89
|
-
try {
|
|
90
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
91
|
-
}
|
|
92
|
-
catch (error) { e = { error: error }; }
|
|
93
|
-
finally {
|
|
94
|
-
try {
|
|
95
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
96
|
-
}
|
|
97
|
-
finally { if (e) throw e.error; }
|
|
98
|
-
}
|
|
99
|
-
return ar;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function __spreadArray(to, from, pack) {
|
|
103
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
104
|
-
if (ar || !(i in from)) {
|
|
105
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
106
|
-
ar[i] = from[i];
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function __await(v) {
|
|
113
|
-
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
117
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
118
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
119
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
120
|
-
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
121
|
-
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
122
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
123
|
-
function fulfill(value) { resume("next", value); }
|
|
124
|
-
function reject(value) { resume("throw", value); }
|
|
125
|
-
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function __asyncValues(o) {
|
|
129
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
130
|
-
var m = o[Symbol.asyncIterator], i;
|
|
131
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
132
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
133
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const UNAUTHORIZED_USER = {
|
|
137
|
-
userId: "unauthorized",
|
|
138
|
-
name: "Unauthorized",
|
|
139
|
-
claims: {
|
|
140
|
-
sub: "unauthorized",
|
|
141
|
-
},
|
|
142
|
-
lastLogin: new Date(0)
|
|
143
|
-
};
|
|
144
|
-
try {
|
|
145
|
-
Object.freeze(UNAUTHORIZED_USER);
|
|
146
|
-
Object.freeze(UNAUTHORIZED_USER.claims);
|
|
147
|
-
}
|
|
148
|
-
catch (_a) { }
|
|
149
|
-
|
|
150
|
-
const swHolder = {};
|
|
151
|
-
const swContainer = typeof self !== 'undefined' && self.document && // self.document is to verify we're not the SW ourself
|
|
152
|
-
typeof navigator !== 'undefined' && navigator.serviceWorker;
|
|
153
|
-
if (swContainer)
|
|
154
|
-
swContainer.ready.then((registration) => (swHolder.registration = registration));
|
|
155
|
-
if (typeof self !== 'undefined' && 'clients' in self && !self.document) {
|
|
156
|
-
// We are the service worker. Propagate messages to all our clients.
|
|
157
|
-
addEventListener('message', (ev) => {
|
|
158
|
-
var _a, _b;
|
|
159
|
-
if ((_b = (_a = ev.data) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.startsWith('sw-broadcast-')) {
|
|
160
|
-
[...self['clients'].matchAll({ includeUncontrolled: true })].forEach((client) => { var _a; return client.id !== ((_a = ev.source) === null || _a === void 0 ? void 0 : _a.id) && client.postMessage(ev.data); });
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
/** This class is a fallback for browsers that lacks BroadcastChannel but have
|
|
165
|
-
* service workers (which is Safari versions 11.1 through 15.3).
|
|
166
|
-
* Safari 15.4 with BroadcastChannel was released on 2022-03-14.
|
|
167
|
-
* We might be able to remove this class in a near future as Safari < 15.4 is
|
|
168
|
-
* already very low in market share as of 2023-03-10.
|
|
169
|
-
*/
|
|
170
|
-
class SWBroadcastChannel {
|
|
171
|
-
constructor(name) {
|
|
172
|
-
this.name = name;
|
|
173
|
-
}
|
|
174
|
-
subscribe(listener) {
|
|
175
|
-
if (!swContainer)
|
|
176
|
-
return () => { };
|
|
177
|
-
const forwarder = (ev) => {
|
|
178
|
-
var _a;
|
|
179
|
-
if (((_a = ev.data) === null || _a === void 0 ? void 0 : _a.type) === `sw-broadcast-${this.name}`) {
|
|
180
|
-
listener(ev.data.message);
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
swContainer.addEventListener('message', forwarder);
|
|
184
|
-
return () => swContainer.removeEventListener('message', forwarder);
|
|
185
|
-
}
|
|
186
|
-
postMessage(message) {
|
|
187
|
-
var _a;
|
|
188
|
-
if (typeof self['clients'] === 'object') {
|
|
189
|
-
// We're a service worker. Propagate to our browser clients.
|
|
190
|
-
[...self['clients'].matchAll({ includeUncontrolled: true })].forEach((client) => client.postMessage({
|
|
191
|
-
type: `sw-broadcast-${this.name}`,
|
|
192
|
-
message,
|
|
193
|
-
}));
|
|
194
|
-
}
|
|
195
|
-
else if (swHolder.registration) {
|
|
196
|
-
// We're a client (browser window or other worker)
|
|
197
|
-
// Post to SW so it can repost to all its clients and to itself
|
|
198
|
-
(_a = swHolder.registration.active) === null || _a === void 0 ? void 0 : _a.postMessage({
|
|
199
|
-
type: `sw-broadcast-${this.name}`,
|
|
200
|
-
message,
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
const events = globalThis['lbc-events'] || (globalThis['lbc-events'] = new Map());
|
|
207
|
-
function addListener(name, listener) {
|
|
208
|
-
if (events.has(name)) {
|
|
209
|
-
events.get(name).push(listener);
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
events.set(name, [listener]);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
function removeListener(name, listener) {
|
|
216
|
-
const listeners = events.get(name);
|
|
217
|
-
if (listeners) {
|
|
218
|
-
const idx = listeners.indexOf(listener);
|
|
219
|
-
if (idx !== -1) {
|
|
220
|
-
listeners.splice(idx, 1);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
function dispatch(ev) {
|
|
225
|
-
const listeners = events.get(ev.type);
|
|
226
|
-
if (listeners) {
|
|
227
|
-
listeners.forEach(listener => {
|
|
228
|
-
try {
|
|
229
|
-
listener(ev);
|
|
230
|
-
}
|
|
231
|
-
catch (_a) {
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
class BroadcastedAndLocalEvent extends Observable$1 {
|
|
237
|
-
constructor(name) {
|
|
238
|
-
const bc = typeof BroadcastChannel === "undefined"
|
|
239
|
-
? new SWBroadcastChannel(name) : new BroadcastChannel(name);
|
|
240
|
-
super(subscriber => {
|
|
241
|
-
function onCustomEvent(ev) {
|
|
242
|
-
subscriber.next(ev.detail);
|
|
243
|
-
}
|
|
244
|
-
function onMessageEvent(ev) {
|
|
245
|
-
console.debug("BroadcastedAndLocalEvent: onMessageEvent", ev);
|
|
246
|
-
subscriber.next(ev.data);
|
|
247
|
-
}
|
|
248
|
-
let unsubscribe;
|
|
249
|
-
//self.addEventListener(`lbc-${name}`, onCustomEvent); // Fails in service workers
|
|
250
|
-
addListener(`lbc-${name}`, onCustomEvent); // Works better in service worker
|
|
251
|
-
try {
|
|
252
|
-
if (bc instanceof SWBroadcastChannel) {
|
|
253
|
-
unsubscribe = bc.subscribe(message => subscriber.next(message));
|
|
254
|
-
}
|
|
255
|
-
else {
|
|
256
|
-
console.debug("BroadcastedAndLocalEvent: bc.addEventListener()", name, "bc is a", bc);
|
|
257
|
-
bc.addEventListener("message", onMessageEvent);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
catch (err) {
|
|
261
|
-
// Service workers might fail to subscribe outside its initial script.
|
|
262
|
-
console.warn('Failed to subscribe to broadcast channel', err);
|
|
263
|
-
}
|
|
264
|
-
return () => {
|
|
265
|
-
//self.removeEventListener(`lbc-${name}`, onCustomEvent);
|
|
266
|
-
removeListener(`lbc-${name}`, onCustomEvent);
|
|
267
|
-
if (bc instanceof SWBroadcastChannel) {
|
|
268
|
-
unsubscribe();
|
|
269
|
-
}
|
|
270
|
-
else {
|
|
271
|
-
bc.removeEventListener("message", onMessageEvent);
|
|
272
|
-
}
|
|
273
|
-
};
|
|
274
|
-
});
|
|
275
|
-
this.name = name;
|
|
276
|
-
this.bc = bc;
|
|
277
|
-
}
|
|
278
|
-
next(message) {
|
|
279
|
-
console.debug("BroadcastedAndLocalEvent: bc.postMessage()", Object.assign({}, message), "bc is a", this.bc);
|
|
280
|
-
this.bc.postMessage(message);
|
|
281
|
-
const ev = new CustomEvent(`lbc-${this.name}`, { detail: message });
|
|
282
|
-
//self.dispatchEvent(ev);
|
|
283
|
-
dispatch(ev);
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
function isFunction(value) {
|
|
288
|
-
return typeof value === 'function';
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
function hasLift(source) {
|
|
292
|
-
return isFunction(source === null || source === void 0 ? void 0 : source.lift);
|
|
293
|
-
}
|
|
294
|
-
function operate(init) {
|
|
295
|
-
return function (source) {
|
|
296
|
-
if (hasLift(source)) {
|
|
297
|
-
return source.lift(function (liftedSource) {
|
|
298
|
-
try {
|
|
299
|
-
return init(liftedSource, this);
|
|
300
|
-
}
|
|
301
|
-
catch (err) {
|
|
302
|
-
this.error(err);
|
|
303
|
-
}
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
throw new TypeError('Unable to lift unknown Observable type');
|
|
307
|
-
};
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
var isArrayLike = (function (x) { return x && typeof x.length === 'number' && typeof x !== 'function'; });
|
|
311
|
-
|
|
312
|
-
function isPromise(value) {
|
|
313
|
-
return isFunction(value === null || value === void 0 ? void 0 : value.then);
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
function createErrorClass(createImpl) {
|
|
317
|
-
var _super = function (instance) {
|
|
318
|
-
Error.call(instance);
|
|
319
|
-
instance.stack = new Error().stack;
|
|
320
|
-
};
|
|
321
|
-
var ctorFunc = createImpl(_super);
|
|
322
|
-
ctorFunc.prototype = Object.create(Error.prototype);
|
|
323
|
-
ctorFunc.prototype.constructor = ctorFunc;
|
|
324
|
-
return ctorFunc;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
var UnsubscriptionError = createErrorClass(function (_super) {
|
|
328
|
-
return function UnsubscriptionErrorImpl(errors) {
|
|
329
|
-
_super(this);
|
|
330
|
-
this.message = errors
|
|
331
|
-
? errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n ')
|
|
332
|
-
: '';
|
|
333
|
-
this.name = 'UnsubscriptionError';
|
|
334
|
-
this.errors = errors;
|
|
335
|
-
};
|
|
336
|
-
});
|
|
337
|
-
|
|
338
|
-
function arrRemove(arr, item) {
|
|
339
|
-
if (arr) {
|
|
340
|
-
var index = arr.indexOf(item);
|
|
341
|
-
0 <= index && arr.splice(index, 1);
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
var Subscription = (function () {
|
|
346
|
-
function Subscription(initialTeardown) {
|
|
347
|
-
this.initialTeardown = initialTeardown;
|
|
348
|
-
this.closed = false;
|
|
349
|
-
this._parentage = null;
|
|
350
|
-
this._finalizers = null;
|
|
351
|
-
}
|
|
352
|
-
Subscription.prototype.unsubscribe = function () {
|
|
353
|
-
var e_1, _a, e_2, _b;
|
|
354
|
-
var errors;
|
|
355
|
-
if (!this.closed) {
|
|
356
|
-
this.closed = true;
|
|
357
|
-
var _parentage = this._parentage;
|
|
358
|
-
if (_parentage) {
|
|
359
|
-
this._parentage = null;
|
|
360
|
-
if (Array.isArray(_parentage)) {
|
|
361
|
-
try {
|
|
362
|
-
for (var _parentage_1 = __values(_parentage), _parentage_1_1 = _parentage_1.next(); !_parentage_1_1.done; _parentage_1_1 = _parentage_1.next()) {
|
|
363
|
-
var parent_1 = _parentage_1_1.value;
|
|
364
|
-
parent_1.remove(this);
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
368
|
-
finally {
|
|
369
|
-
try {
|
|
370
|
-
if (_parentage_1_1 && !_parentage_1_1.done && (_a = _parentage_1.return)) _a.call(_parentage_1);
|
|
371
|
-
}
|
|
372
|
-
finally { if (e_1) throw e_1.error; }
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
else {
|
|
376
|
-
_parentage.remove(this);
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
var initialFinalizer = this.initialTeardown;
|
|
380
|
-
if (isFunction(initialFinalizer)) {
|
|
381
|
-
try {
|
|
382
|
-
initialFinalizer();
|
|
383
|
-
}
|
|
384
|
-
catch (e) {
|
|
385
|
-
errors = e instanceof UnsubscriptionError ? e.errors : [e];
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
var _finalizers = this._finalizers;
|
|
389
|
-
if (_finalizers) {
|
|
390
|
-
this._finalizers = null;
|
|
391
|
-
try {
|
|
392
|
-
for (var _finalizers_1 = __values(_finalizers), _finalizers_1_1 = _finalizers_1.next(); !_finalizers_1_1.done; _finalizers_1_1 = _finalizers_1.next()) {
|
|
393
|
-
var finalizer = _finalizers_1_1.value;
|
|
394
|
-
try {
|
|
395
|
-
execFinalizer(finalizer);
|
|
396
|
-
}
|
|
397
|
-
catch (err) {
|
|
398
|
-
errors = errors !== null && errors !== void 0 ? errors : [];
|
|
399
|
-
if (err instanceof UnsubscriptionError) {
|
|
400
|
-
errors = __spreadArray(__spreadArray([], __read(errors)), __read(err.errors));
|
|
401
|
-
}
|
|
402
|
-
else {
|
|
403
|
-
errors.push(err);
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
409
|
-
finally {
|
|
410
|
-
try {
|
|
411
|
-
if (_finalizers_1_1 && !_finalizers_1_1.done && (_b = _finalizers_1.return)) _b.call(_finalizers_1);
|
|
412
|
-
}
|
|
413
|
-
finally { if (e_2) throw e_2.error; }
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
if (errors) {
|
|
417
|
-
throw new UnsubscriptionError(errors);
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
};
|
|
421
|
-
Subscription.prototype.add = function (teardown) {
|
|
422
|
-
var _a;
|
|
423
|
-
if (teardown && teardown !== this) {
|
|
424
|
-
if (this.closed) {
|
|
425
|
-
execFinalizer(teardown);
|
|
426
|
-
}
|
|
427
|
-
else {
|
|
428
|
-
if (teardown instanceof Subscription) {
|
|
429
|
-
if (teardown.closed || teardown._hasParent(this)) {
|
|
430
|
-
return;
|
|
431
|
-
}
|
|
432
|
-
teardown._addParent(this);
|
|
433
|
-
}
|
|
434
|
-
(this._finalizers = (_a = this._finalizers) !== null && _a !== void 0 ? _a : []).push(teardown);
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
};
|
|
438
|
-
Subscription.prototype._hasParent = function (parent) {
|
|
439
|
-
var _parentage = this._parentage;
|
|
440
|
-
return _parentage === parent || (Array.isArray(_parentage) && _parentage.includes(parent));
|
|
441
|
-
};
|
|
442
|
-
Subscription.prototype._addParent = function (parent) {
|
|
443
|
-
var _parentage = this._parentage;
|
|
444
|
-
this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent;
|
|
445
|
-
};
|
|
446
|
-
Subscription.prototype._removeParent = function (parent) {
|
|
447
|
-
var _parentage = this._parentage;
|
|
448
|
-
if (_parentage === parent) {
|
|
449
|
-
this._parentage = null;
|
|
450
|
-
}
|
|
451
|
-
else if (Array.isArray(_parentage)) {
|
|
452
|
-
arrRemove(_parentage, parent);
|
|
453
|
-
}
|
|
454
|
-
};
|
|
455
|
-
Subscription.prototype.remove = function (teardown) {
|
|
456
|
-
var _finalizers = this._finalizers;
|
|
457
|
-
_finalizers && arrRemove(_finalizers, teardown);
|
|
458
|
-
if (teardown instanceof Subscription) {
|
|
459
|
-
teardown._removeParent(this);
|
|
460
|
-
}
|
|
461
|
-
};
|
|
462
|
-
Subscription.EMPTY = (function () {
|
|
463
|
-
var empty = new Subscription();
|
|
464
|
-
empty.closed = true;
|
|
465
|
-
return empty;
|
|
466
|
-
})();
|
|
467
|
-
return Subscription;
|
|
468
|
-
}());
|
|
469
|
-
Subscription.EMPTY;
|
|
470
|
-
function isSubscription(value) {
|
|
471
|
-
return (value instanceof Subscription ||
|
|
472
|
-
(value && 'closed' in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe)));
|
|
473
|
-
}
|
|
474
|
-
function execFinalizer(finalizer) {
|
|
475
|
-
if (isFunction(finalizer)) {
|
|
476
|
-
finalizer();
|
|
477
|
-
}
|
|
478
|
-
else {
|
|
479
|
-
finalizer.unsubscribe();
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
var config = {
|
|
484
|
-
onUnhandledError: null,
|
|
485
|
-
onStoppedNotification: null,
|
|
486
|
-
Promise: undefined,
|
|
487
|
-
useDeprecatedSynchronousErrorHandling: false,
|
|
488
|
-
useDeprecatedNextContext: false,
|
|
489
|
-
};
|
|
490
|
-
|
|
491
|
-
var timeoutProvider = {
|
|
492
|
-
setTimeout: function (handler, timeout) {
|
|
493
|
-
var args = [];
|
|
494
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
495
|
-
args[_i - 2] = arguments[_i];
|
|
496
|
-
}
|
|
497
|
-
var delegate = timeoutProvider.delegate;
|
|
498
|
-
if (delegate === null || delegate === void 0 ? void 0 : delegate.setTimeout) {
|
|
499
|
-
return delegate.setTimeout.apply(delegate, __spreadArray([handler, timeout], __read(args)));
|
|
500
|
-
}
|
|
501
|
-
return setTimeout.apply(void 0, __spreadArray([handler, timeout], __read(args)));
|
|
502
|
-
},
|
|
503
|
-
clearTimeout: function (handle) {
|
|
504
|
-
var delegate = timeoutProvider.delegate;
|
|
505
|
-
return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearTimeout) || clearTimeout)(handle);
|
|
506
|
-
},
|
|
507
|
-
delegate: undefined,
|
|
508
|
-
};
|
|
509
|
-
|
|
510
|
-
function reportUnhandledError(err) {
|
|
511
|
-
timeoutProvider.setTimeout(function () {
|
|
512
|
-
var onUnhandledError = config.onUnhandledError;
|
|
513
|
-
if (onUnhandledError) {
|
|
514
|
-
onUnhandledError(err);
|
|
515
|
-
}
|
|
516
|
-
else {
|
|
517
|
-
throw err;
|
|
518
|
-
}
|
|
519
|
-
});
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
function noop() { }
|
|
523
|
-
|
|
524
|
-
var COMPLETE_NOTIFICATION = (function () { return createNotification('C', undefined, undefined); })();
|
|
525
|
-
function errorNotification(error) {
|
|
526
|
-
return createNotification('E', undefined, error);
|
|
527
|
-
}
|
|
528
|
-
function nextNotification(value) {
|
|
529
|
-
return createNotification('N', value, undefined);
|
|
530
|
-
}
|
|
531
|
-
function createNotification(kind, value, error) {
|
|
532
|
-
return {
|
|
533
|
-
kind: kind,
|
|
534
|
-
value: value,
|
|
535
|
-
error: error,
|
|
536
|
-
};
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
var context = null;
|
|
540
|
-
function errorContext(cb) {
|
|
541
|
-
if (config.useDeprecatedSynchronousErrorHandling) {
|
|
542
|
-
var isRoot = !context;
|
|
543
|
-
if (isRoot) {
|
|
544
|
-
context = { errorThrown: false, error: null };
|
|
545
|
-
}
|
|
546
|
-
cb();
|
|
547
|
-
if (isRoot) {
|
|
548
|
-
var _a = context, errorThrown = _a.errorThrown, error = _a.error;
|
|
549
|
-
context = null;
|
|
550
|
-
if (errorThrown) {
|
|
551
|
-
throw error;
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
else {
|
|
556
|
-
cb();
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
var Subscriber = (function (_super) {
|
|
561
|
-
__extends(Subscriber, _super);
|
|
562
|
-
function Subscriber(destination) {
|
|
563
|
-
var _this = _super.call(this) || this;
|
|
564
|
-
_this.isStopped = false;
|
|
565
|
-
if (destination) {
|
|
566
|
-
_this.destination = destination;
|
|
567
|
-
if (isSubscription(destination)) {
|
|
568
|
-
destination.add(_this);
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
else {
|
|
572
|
-
_this.destination = EMPTY_OBSERVER;
|
|
573
|
-
}
|
|
574
|
-
return _this;
|
|
575
|
-
}
|
|
576
|
-
Subscriber.create = function (next, error, complete) {
|
|
577
|
-
return new SafeSubscriber(next, error, complete);
|
|
578
|
-
};
|
|
579
|
-
Subscriber.prototype.next = function (value) {
|
|
580
|
-
if (this.isStopped) {
|
|
581
|
-
handleStoppedNotification(nextNotification(value), this);
|
|
582
|
-
}
|
|
583
|
-
else {
|
|
584
|
-
this._next(value);
|
|
585
|
-
}
|
|
586
|
-
};
|
|
587
|
-
Subscriber.prototype.error = function (err) {
|
|
588
|
-
if (this.isStopped) {
|
|
589
|
-
handleStoppedNotification(errorNotification(err), this);
|
|
590
|
-
}
|
|
591
|
-
else {
|
|
592
|
-
this.isStopped = true;
|
|
593
|
-
this._error(err);
|
|
594
|
-
}
|
|
595
|
-
};
|
|
596
|
-
Subscriber.prototype.complete = function () {
|
|
597
|
-
if (this.isStopped) {
|
|
598
|
-
handleStoppedNotification(COMPLETE_NOTIFICATION, this);
|
|
599
|
-
}
|
|
600
|
-
else {
|
|
601
|
-
this.isStopped = true;
|
|
602
|
-
this._complete();
|
|
603
|
-
}
|
|
604
|
-
};
|
|
605
|
-
Subscriber.prototype.unsubscribe = function () {
|
|
606
|
-
if (!this.closed) {
|
|
607
|
-
this.isStopped = true;
|
|
608
|
-
_super.prototype.unsubscribe.call(this);
|
|
609
|
-
this.destination = null;
|
|
610
|
-
}
|
|
611
|
-
};
|
|
612
|
-
Subscriber.prototype._next = function (value) {
|
|
613
|
-
this.destination.next(value);
|
|
614
|
-
};
|
|
615
|
-
Subscriber.prototype._error = function (err) {
|
|
616
|
-
try {
|
|
617
|
-
this.destination.error(err);
|
|
618
|
-
}
|
|
619
|
-
finally {
|
|
620
|
-
this.unsubscribe();
|
|
621
|
-
}
|
|
622
|
-
};
|
|
623
|
-
Subscriber.prototype._complete = function () {
|
|
624
|
-
try {
|
|
625
|
-
this.destination.complete();
|
|
626
|
-
}
|
|
627
|
-
finally {
|
|
628
|
-
this.unsubscribe();
|
|
629
|
-
}
|
|
630
|
-
};
|
|
631
|
-
return Subscriber;
|
|
632
|
-
}(Subscription));
|
|
633
|
-
var _bind = Function.prototype.bind;
|
|
634
|
-
function bind(fn, thisArg) {
|
|
635
|
-
return _bind.call(fn, thisArg);
|
|
636
|
-
}
|
|
637
|
-
var ConsumerObserver = (function () {
|
|
638
|
-
function ConsumerObserver(partialObserver) {
|
|
639
|
-
this.partialObserver = partialObserver;
|
|
640
|
-
}
|
|
641
|
-
ConsumerObserver.prototype.next = function (value) {
|
|
642
|
-
var partialObserver = this.partialObserver;
|
|
643
|
-
if (partialObserver.next) {
|
|
644
|
-
try {
|
|
645
|
-
partialObserver.next(value);
|
|
646
|
-
}
|
|
647
|
-
catch (error) {
|
|
648
|
-
handleUnhandledError(error);
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
};
|
|
652
|
-
ConsumerObserver.prototype.error = function (err) {
|
|
653
|
-
var partialObserver = this.partialObserver;
|
|
654
|
-
if (partialObserver.error) {
|
|
655
|
-
try {
|
|
656
|
-
partialObserver.error(err);
|
|
657
|
-
}
|
|
658
|
-
catch (error) {
|
|
659
|
-
handleUnhandledError(error);
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
else {
|
|
663
|
-
handleUnhandledError(err);
|
|
664
|
-
}
|
|
665
|
-
};
|
|
666
|
-
ConsumerObserver.prototype.complete = function () {
|
|
667
|
-
var partialObserver = this.partialObserver;
|
|
668
|
-
if (partialObserver.complete) {
|
|
669
|
-
try {
|
|
670
|
-
partialObserver.complete();
|
|
671
|
-
}
|
|
672
|
-
catch (error) {
|
|
673
|
-
handleUnhandledError(error);
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
};
|
|
677
|
-
return ConsumerObserver;
|
|
678
|
-
}());
|
|
679
|
-
var SafeSubscriber = (function (_super) {
|
|
680
|
-
__extends(SafeSubscriber, _super);
|
|
681
|
-
function SafeSubscriber(observerOrNext, error, complete) {
|
|
682
|
-
var _this = _super.call(this) || this;
|
|
683
|
-
var partialObserver;
|
|
684
|
-
if (isFunction(observerOrNext) || !observerOrNext) {
|
|
685
|
-
partialObserver = {
|
|
686
|
-
next: (observerOrNext !== null && observerOrNext !== void 0 ? observerOrNext : undefined),
|
|
687
|
-
error: error !== null && error !== void 0 ? error : undefined,
|
|
688
|
-
complete: complete !== null && complete !== void 0 ? complete : undefined,
|
|
689
|
-
};
|
|
690
|
-
}
|
|
691
|
-
else {
|
|
692
|
-
var context_1;
|
|
693
|
-
if (_this && config.useDeprecatedNextContext) {
|
|
694
|
-
context_1 = Object.create(observerOrNext);
|
|
695
|
-
context_1.unsubscribe = function () { return _this.unsubscribe(); };
|
|
696
|
-
partialObserver = {
|
|
697
|
-
next: observerOrNext.next && bind(observerOrNext.next, context_1),
|
|
698
|
-
error: observerOrNext.error && bind(observerOrNext.error, context_1),
|
|
699
|
-
complete: observerOrNext.complete && bind(observerOrNext.complete, context_1),
|
|
700
|
-
};
|
|
701
|
-
}
|
|
702
|
-
else {
|
|
703
|
-
partialObserver = observerOrNext;
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
_this.destination = new ConsumerObserver(partialObserver);
|
|
707
|
-
return _this;
|
|
708
|
-
}
|
|
709
|
-
return SafeSubscriber;
|
|
710
|
-
}(Subscriber));
|
|
711
|
-
function handleUnhandledError(error) {
|
|
712
|
-
{
|
|
713
|
-
reportUnhandledError(error);
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
function defaultErrorHandler(err) {
|
|
717
|
-
throw err;
|
|
718
|
-
}
|
|
719
|
-
function handleStoppedNotification(notification, subscriber) {
|
|
720
|
-
var onStoppedNotification = config.onStoppedNotification;
|
|
721
|
-
onStoppedNotification && timeoutProvider.setTimeout(function () { return onStoppedNotification(notification, subscriber); });
|
|
722
|
-
}
|
|
723
|
-
var EMPTY_OBSERVER = {
|
|
724
|
-
closed: true,
|
|
725
|
-
next: noop,
|
|
726
|
-
error: defaultErrorHandler,
|
|
727
|
-
complete: noop,
|
|
728
|
-
};
|
|
729
|
-
|
|
730
|
-
var observable = (function () { return (typeof Symbol === 'function' && Symbol.observable) || '@@observable'; })();
|
|
731
|
-
|
|
732
|
-
function identity(x) {
|
|
733
|
-
return x;
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
function pipeFromArray(fns) {
|
|
737
|
-
if (fns.length === 0) {
|
|
738
|
-
return identity;
|
|
739
|
-
}
|
|
740
|
-
if (fns.length === 1) {
|
|
741
|
-
return fns[0];
|
|
742
|
-
}
|
|
743
|
-
return function piped(input) {
|
|
744
|
-
return fns.reduce(function (prev, fn) { return fn(prev); }, input);
|
|
745
|
-
};
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
var Observable = (function () {
|
|
749
|
-
function Observable(subscribe) {
|
|
750
|
-
if (subscribe) {
|
|
751
|
-
this._subscribe = subscribe;
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
Observable.prototype.lift = function (operator) {
|
|
755
|
-
var observable = new Observable();
|
|
756
|
-
observable.source = this;
|
|
757
|
-
observable.operator = operator;
|
|
758
|
-
return observable;
|
|
759
|
-
};
|
|
760
|
-
Observable.prototype.subscribe = function (observerOrNext, error, complete) {
|
|
761
|
-
var _this = this;
|
|
762
|
-
var subscriber = isSubscriber(observerOrNext) ? observerOrNext : new SafeSubscriber(observerOrNext, error, complete);
|
|
763
|
-
errorContext(function () {
|
|
764
|
-
var _a = _this, operator = _a.operator, source = _a.source;
|
|
765
|
-
subscriber.add(operator
|
|
766
|
-
?
|
|
767
|
-
operator.call(subscriber, source)
|
|
768
|
-
: source
|
|
769
|
-
?
|
|
770
|
-
_this._subscribe(subscriber)
|
|
771
|
-
:
|
|
772
|
-
_this._trySubscribe(subscriber));
|
|
773
|
-
});
|
|
774
|
-
return subscriber;
|
|
775
|
-
};
|
|
776
|
-
Observable.prototype._trySubscribe = function (sink) {
|
|
777
|
-
try {
|
|
778
|
-
return this._subscribe(sink);
|
|
779
|
-
}
|
|
780
|
-
catch (err) {
|
|
781
|
-
sink.error(err);
|
|
782
|
-
}
|
|
783
|
-
};
|
|
784
|
-
Observable.prototype.forEach = function (next, promiseCtor) {
|
|
785
|
-
var _this = this;
|
|
786
|
-
promiseCtor = getPromiseCtor(promiseCtor);
|
|
787
|
-
return new promiseCtor(function (resolve, reject) {
|
|
788
|
-
var subscriber = new SafeSubscriber({
|
|
789
|
-
next: function (value) {
|
|
790
|
-
try {
|
|
791
|
-
next(value);
|
|
792
|
-
}
|
|
793
|
-
catch (err) {
|
|
794
|
-
reject(err);
|
|
795
|
-
subscriber.unsubscribe();
|
|
796
|
-
}
|
|
797
|
-
},
|
|
798
|
-
error: reject,
|
|
799
|
-
complete: resolve,
|
|
800
|
-
});
|
|
801
|
-
_this.subscribe(subscriber);
|
|
802
|
-
});
|
|
803
|
-
};
|
|
804
|
-
Observable.prototype._subscribe = function (subscriber) {
|
|
805
|
-
var _a;
|
|
806
|
-
return (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber);
|
|
807
|
-
};
|
|
808
|
-
Observable.prototype[observable] = function () {
|
|
809
|
-
return this;
|
|
810
|
-
};
|
|
811
|
-
Observable.prototype.pipe = function () {
|
|
812
|
-
var operations = [];
|
|
813
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
814
|
-
operations[_i] = arguments[_i];
|
|
815
|
-
}
|
|
816
|
-
return pipeFromArray(operations)(this);
|
|
817
|
-
};
|
|
818
|
-
Observable.prototype.toPromise = function (promiseCtor) {
|
|
819
|
-
var _this = this;
|
|
820
|
-
promiseCtor = getPromiseCtor(promiseCtor);
|
|
821
|
-
return new promiseCtor(function (resolve, reject) {
|
|
822
|
-
var value;
|
|
823
|
-
_this.subscribe(function (x) { return (value = x); }, function (err) { return reject(err); }, function () { return resolve(value); });
|
|
824
|
-
});
|
|
825
|
-
};
|
|
826
|
-
Observable.create = function (subscribe) {
|
|
827
|
-
return new Observable(subscribe);
|
|
828
|
-
};
|
|
829
|
-
return Observable;
|
|
830
|
-
}());
|
|
831
|
-
function getPromiseCtor(promiseCtor) {
|
|
832
|
-
var _a;
|
|
833
|
-
return (_a = promiseCtor !== null && promiseCtor !== void 0 ? promiseCtor : config.Promise) !== null && _a !== void 0 ? _a : Promise;
|
|
834
|
-
}
|
|
835
|
-
function isObserver(value) {
|
|
836
|
-
return value && isFunction(value.next) && isFunction(value.error) && isFunction(value.complete);
|
|
837
|
-
}
|
|
838
|
-
function isSubscriber(value) {
|
|
839
|
-
return (value && value instanceof Subscriber) || (isObserver(value) && isSubscription(value));
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
function isInteropObservable(input) {
|
|
843
|
-
return isFunction(input[observable]);
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
function isAsyncIterable(obj) {
|
|
847
|
-
return Symbol.asyncIterator && isFunction(obj === null || obj === void 0 ? void 0 : obj[Symbol.asyncIterator]);
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
function createInvalidObservableTypeError(input) {
|
|
851
|
-
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.");
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
function getSymbolIterator() {
|
|
855
|
-
if (typeof Symbol !== 'function' || !Symbol.iterator) {
|
|
856
|
-
return '@@iterator';
|
|
857
|
-
}
|
|
858
|
-
return Symbol.iterator;
|
|
859
|
-
}
|
|
860
|
-
var iterator = getSymbolIterator();
|
|
861
|
-
|
|
862
|
-
function isIterable(input) {
|
|
863
|
-
return isFunction(input === null || input === void 0 ? void 0 : input[iterator]);
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
function readableStreamLikeToAsyncGenerator(readableStream) {
|
|
867
|
-
return __asyncGenerator(this, arguments, function readableStreamLikeToAsyncGenerator_1() {
|
|
868
|
-
var reader, _a, value, done;
|
|
869
|
-
return __generator(this, function (_b) {
|
|
870
|
-
switch (_b.label) {
|
|
871
|
-
case 0:
|
|
872
|
-
reader = readableStream.getReader();
|
|
873
|
-
_b.label = 1;
|
|
874
|
-
case 1:
|
|
875
|
-
_b.trys.push([1, , 9, 10]);
|
|
876
|
-
_b.label = 2;
|
|
877
|
-
case 2:
|
|
878
|
-
return [4, __await(reader.read())];
|
|
879
|
-
case 3:
|
|
880
|
-
_a = _b.sent(), value = _a.value, done = _a.done;
|
|
881
|
-
if (!done) return [3, 5];
|
|
882
|
-
return [4, __await(void 0)];
|
|
883
|
-
case 4: return [2, _b.sent()];
|
|
884
|
-
case 5: return [4, __await(value)];
|
|
885
|
-
case 6: return [4, _b.sent()];
|
|
886
|
-
case 7:
|
|
887
|
-
_b.sent();
|
|
888
|
-
return [3, 2];
|
|
889
|
-
case 8: return [3, 10];
|
|
890
|
-
case 9:
|
|
891
|
-
reader.releaseLock();
|
|
892
|
-
return [7];
|
|
893
|
-
case 10: return [2];
|
|
894
|
-
}
|
|
895
|
-
});
|
|
896
|
-
});
|
|
897
|
-
}
|
|
898
|
-
function isReadableStreamLike(obj) {
|
|
899
|
-
return isFunction(obj === null || obj === void 0 ? void 0 : obj.getReader);
|
|
900
|
-
}
|
|
901
|
-
|
|
902
|
-
function innerFrom(input) {
|
|
903
|
-
if (input instanceof Observable) {
|
|
904
|
-
return input;
|
|
905
|
-
}
|
|
906
|
-
if (input != null) {
|
|
907
|
-
if (isInteropObservable(input)) {
|
|
908
|
-
return fromInteropObservable(input);
|
|
909
|
-
}
|
|
910
|
-
if (isArrayLike(input)) {
|
|
911
|
-
return fromArrayLike(input);
|
|
912
|
-
}
|
|
913
|
-
if (isPromise(input)) {
|
|
914
|
-
return fromPromise(input);
|
|
915
|
-
}
|
|
916
|
-
if (isAsyncIterable(input)) {
|
|
917
|
-
return fromAsyncIterable(input);
|
|
918
|
-
}
|
|
919
|
-
if (isIterable(input)) {
|
|
920
|
-
return fromIterable(input);
|
|
921
|
-
}
|
|
922
|
-
if (isReadableStreamLike(input)) {
|
|
923
|
-
return fromReadableStreamLike(input);
|
|
924
|
-
}
|
|
925
|
-
}
|
|
926
|
-
throw createInvalidObservableTypeError(input);
|
|
927
|
-
}
|
|
928
|
-
function fromInteropObservable(obj) {
|
|
929
|
-
return new Observable(function (subscriber) {
|
|
930
|
-
var obs = obj[observable]();
|
|
931
|
-
if (isFunction(obs.subscribe)) {
|
|
932
|
-
return obs.subscribe(subscriber);
|
|
933
|
-
}
|
|
934
|
-
throw new TypeError('Provided object does not correctly implement Symbol.observable');
|
|
935
|
-
});
|
|
936
|
-
}
|
|
937
|
-
function fromArrayLike(array) {
|
|
938
|
-
return new Observable(function (subscriber) {
|
|
939
|
-
for (var i = 0; i < array.length && !subscriber.closed; i++) {
|
|
940
|
-
subscriber.next(array[i]);
|
|
941
|
-
}
|
|
942
|
-
subscriber.complete();
|
|
943
|
-
});
|
|
944
|
-
}
|
|
945
|
-
function fromPromise(promise) {
|
|
946
|
-
return new Observable(function (subscriber) {
|
|
947
|
-
promise
|
|
948
|
-
.then(function (value) {
|
|
949
|
-
if (!subscriber.closed) {
|
|
950
|
-
subscriber.next(value);
|
|
951
|
-
subscriber.complete();
|
|
952
|
-
}
|
|
953
|
-
}, function (err) { return subscriber.error(err); })
|
|
954
|
-
.then(null, reportUnhandledError);
|
|
955
|
-
});
|
|
956
|
-
}
|
|
957
|
-
function fromIterable(iterable) {
|
|
958
|
-
return new Observable(function (subscriber) {
|
|
959
|
-
var e_1, _a;
|
|
960
|
-
try {
|
|
961
|
-
for (var iterable_1 = __values(iterable), iterable_1_1 = iterable_1.next(); !iterable_1_1.done; iterable_1_1 = iterable_1.next()) {
|
|
962
|
-
var value = iterable_1_1.value;
|
|
963
|
-
subscriber.next(value);
|
|
964
|
-
if (subscriber.closed) {
|
|
965
|
-
return;
|
|
966
|
-
}
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
970
|
-
finally {
|
|
971
|
-
try {
|
|
972
|
-
if (iterable_1_1 && !iterable_1_1.done && (_a = iterable_1.return)) _a.call(iterable_1);
|
|
973
|
-
}
|
|
974
|
-
finally { if (e_1) throw e_1.error; }
|
|
975
|
-
}
|
|
976
|
-
subscriber.complete();
|
|
977
|
-
});
|
|
978
|
-
}
|
|
979
|
-
function fromAsyncIterable(asyncIterable) {
|
|
980
|
-
return new Observable(function (subscriber) {
|
|
981
|
-
process(asyncIterable, subscriber).catch(function (err) { return subscriber.error(err); });
|
|
982
|
-
});
|
|
983
|
-
}
|
|
984
|
-
function fromReadableStreamLike(readableStream) {
|
|
985
|
-
return fromAsyncIterable(readableStreamLikeToAsyncGenerator(readableStream));
|
|
986
|
-
}
|
|
987
|
-
function process(asyncIterable, subscriber) {
|
|
988
|
-
var asyncIterable_1, asyncIterable_1_1;
|
|
989
|
-
var e_2, _a;
|
|
990
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
991
|
-
var value, e_2_1;
|
|
992
|
-
return __generator(this, function (_b) {
|
|
993
|
-
switch (_b.label) {
|
|
994
|
-
case 0:
|
|
995
|
-
_b.trys.push([0, 5, 6, 11]);
|
|
996
|
-
asyncIterable_1 = __asyncValues(asyncIterable);
|
|
997
|
-
_b.label = 1;
|
|
998
|
-
case 1: return [4, asyncIterable_1.next()];
|
|
999
|
-
case 2:
|
|
1000
|
-
if (!(asyncIterable_1_1 = _b.sent(), !asyncIterable_1_1.done)) return [3, 4];
|
|
1001
|
-
value = asyncIterable_1_1.value;
|
|
1002
|
-
subscriber.next(value);
|
|
1003
|
-
if (subscriber.closed) {
|
|
1004
|
-
return [2];
|
|
1005
|
-
}
|
|
1006
|
-
_b.label = 3;
|
|
1007
|
-
case 3: return [3, 1];
|
|
1008
|
-
case 4: return [3, 11];
|
|
1009
|
-
case 5:
|
|
1010
|
-
e_2_1 = _b.sent();
|
|
1011
|
-
e_2 = { error: e_2_1 };
|
|
1012
|
-
return [3, 11];
|
|
1013
|
-
case 6:
|
|
1014
|
-
_b.trys.push([6, , 9, 10]);
|
|
1015
|
-
if (!(asyncIterable_1_1 && !asyncIterable_1_1.done && (_a = asyncIterable_1.return))) return [3, 8];
|
|
1016
|
-
return [4, _a.call(asyncIterable_1)];
|
|
1017
|
-
case 7:
|
|
1018
|
-
_b.sent();
|
|
1019
|
-
_b.label = 8;
|
|
1020
|
-
case 8: return [3, 10];
|
|
1021
|
-
case 9:
|
|
1022
|
-
if (e_2) throw e_2.error;
|
|
1023
|
-
return [7];
|
|
1024
|
-
case 10: return [7];
|
|
1025
|
-
case 11:
|
|
1026
|
-
subscriber.complete();
|
|
1027
|
-
return [2];
|
|
1028
|
-
}
|
|
1029
|
-
});
|
|
1030
|
-
});
|
|
1031
|
-
}
|
|
1032
|
-
|
|
1033
|
-
function createOperatorSubscriber(destination, onNext, onComplete, onError, onFinalize) {
|
|
1034
|
-
return new OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize);
|
|
1035
|
-
}
|
|
1036
|
-
var OperatorSubscriber = (function (_super) {
|
|
1037
|
-
__extends(OperatorSubscriber, _super);
|
|
1038
|
-
function OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize, shouldUnsubscribe) {
|
|
1039
|
-
var _this = _super.call(this, destination) || this;
|
|
1040
|
-
_this.onFinalize = onFinalize;
|
|
1041
|
-
_this.shouldUnsubscribe = shouldUnsubscribe;
|
|
1042
|
-
_this._next = onNext
|
|
1043
|
-
? function (value) {
|
|
1044
|
-
try {
|
|
1045
|
-
onNext(value);
|
|
1046
|
-
}
|
|
1047
|
-
catch (err) {
|
|
1048
|
-
destination.error(err);
|
|
1049
|
-
}
|
|
1050
|
-
}
|
|
1051
|
-
: _super.prototype._next;
|
|
1052
|
-
_this._error = onError
|
|
1053
|
-
? function (err) {
|
|
1054
|
-
try {
|
|
1055
|
-
onError(err);
|
|
1056
|
-
}
|
|
1057
|
-
catch (err) {
|
|
1058
|
-
destination.error(err);
|
|
1059
|
-
}
|
|
1060
|
-
finally {
|
|
1061
|
-
this.unsubscribe();
|
|
1062
|
-
}
|
|
1063
|
-
}
|
|
1064
|
-
: _super.prototype._error;
|
|
1065
|
-
_this._complete = onComplete
|
|
1066
|
-
? function () {
|
|
1067
|
-
try {
|
|
1068
|
-
onComplete();
|
|
1069
|
-
}
|
|
1070
|
-
catch (err) {
|
|
1071
|
-
destination.error(err);
|
|
1072
|
-
}
|
|
1073
|
-
finally {
|
|
1074
|
-
this.unsubscribe();
|
|
1075
|
-
}
|
|
1076
|
-
}
|
|
1077
|
-
: _super.prototype._complete;
|
|
1078
|
-
return _this;
|
|
1079
|
-
}
|
|
1080
|
-
OperatorSubscriber.prototype.unsubscribe = function () {
|
|
1081
|
-
var _a;
|
|
1082
|
-
if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {
|
|
1083
|
-
var closed_1 = this.closed;
|
|
1084
|
-
_super.prototype.unsubscribe.call(this);
|
|
1085
|
-
!closed_1 && ((_a = this.onFinalize) === null || _a === void 0 ? void 0 : _a.call(this));
|
|
1086
|
-
}
|
|
1087
|
-
};
|
|
1088
|
-
return OperatorSubscriber;
|
|
1089
|
-
}(Subscriber));
|
|
1090
|
-
|
|
1091
|
-
var Action = (function (_super) {
|
|
1092
|
-
__extends(Action, _super);
|
|
1093
|
-
function Action(scheduler, work) {
|
|
1094
|
-
return _super.call(this) || this;
|
|
1095
|
-
}
|
|
1096
|
-
Action.prototype.schedule = function (state, delay) {
|
|
1097
|
-
return this;
|
|
1098
|
-
};
|
|
1099
|
-
return Action;
|
|
1100
|
-
}(Subscription));
|
|
1101
|
-
|
|
1102
|
-
var intervalProvider = {
|
|
1103
|
-
setInterval: function (handler, timeout) {
|
|
1104
|
-
var args = [];
|
|
1105
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1106
|
-
args[_i - 2] = arguments[_i];
|
|
1107
|
-
}
|
|
1108
|
-
var delegate = intervalProvider.delegate;
|
|
1109
|
-
if (delegate === null || delegate === void 0 ? void 0 : delegate.setInterval) {
|
|
1110
|
-
return delegate.setInterval.apply(delegate, __spreadArray([handler, timeout], __read(args)));
|
|
1111
|
-
}
|
|
1112
|
-
return setInterval.apply(void 0, __spreadArray([handler, timeout], __read(args)));
|
|
1113
|
-
},
|
|
1114
|
-
clearInterval: function (handle) {
|
|
1115
|
-
var delegate = intervalProvider.delegate;
|
|
1116
|
-
return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearInterval) || clearInterval)(handle);
|
|
1117
|
-
},
|
|
1118
|
-
delegate: undefined,
|
|
1119
|
-
};
|
|
1120
|
-
|
|
1121
|
-
var AsyncAction = (function (_super) {
|
|
1122
|
-
__extends(AsyncAction, _super);
|
|
1123
|
-
function AsyncAction(scheduler, work) {
|
|
1124
|
-
var _this = _super.call(this, scheduler, work) || this;
|
|
1125
|
-
_this.scheduler = scheduler;
|
|
1126
|
-
_this.work = work;
|
|
1127
|
-
_this.pending = false;
|
|
1128
|
-
return _this;
|
|
1129
|
-
}
|
|
1130
|
-
AsyncAction.prototype.schedule = function (state, delay) {
|
|
1131
|
-
if (delay === void 0) { delay = 0; }
|
|
1132
|
-
if (this.closed) {
|
|
1133
|
-
return this;
|
|
1134
|
-
}
|
|
1135
|
-
this.state = state;
|
|
1136
|
-
var id = this.id;
|
|
1137
|
-
var scheduler = this.scheduler;
|
|
1138
|
-
if (id != null) {
|
|
1139
|
-
this.id = this.recycleAsyncId(scheduler, id, delay);
|
|
1140
|
-
}
|
|
1141
|
-
this.pending = true;
|
|
1142
|
-
this.delay = delay;
|
|
1143
|
-
this.id = this.id || this.requestAsyncId(scheduler, this.id, delay);
|
|
1144
|
-
return this;
|
|
1145
|
-
};
|
|
1146
|
-
AsyncAction.prototype.requestAsyncId = function (scheduler, _id, delay) {
|
|
1147
|
-
if (delay === void 0) { delay = 0; }
|
|
1148
|
-
return intervalProvider.setInterval(scheduler.flush.bind(scheduler, this), delay);
|
|
1149
|
-
};
|
|
1150
|
-
AsyncAction.prototype.recycleAsyncId = function (_scheduler, id, delay) {
|
|
1151
|
-
if (delay === void 0) { delay = 0; }
|
|
1152
|
-
if (delay != null && this.delay === delay && this.pending === false) {
|
|
1153
|
-
return id;
|
|
1154
|
-
}
|
|
1155
|
-
intervalProvider.clearInterval(id);
|
|
1156
|
-
return undefined;
|
|
1157
|
-
};
|
|
1158
|
-
AsyncAction.prototype.execute = function (state, delay) {
|
|
1159
|
-
if (this.closed) {
|
|
1160
|
-
return new Error('executing a cancelled action');
|
|
1161
|
-
}
|
|
1162
|
-
this.pending = false;
|
|
1163
|
-
var error = this._execute(state, delay);
|
|
1164
|
-
if (error) {
|
|
1165
|
-
return error;
|
|
1166
|
-
}
|
|
1167
|
-
else if (this.pending === false && this.id != null) {
|
|
1168
|
-
this.id = this.recycleAsyncId(this.scheduler, this.id, null);
|
|
1169
|
-
}
|
|
1170
|
-
};
|
|
1171
|
-
AsyncAction.prototype._execute = function (state, _delay) {
|
|
1172
|
-
var errored = false;
|
|
1173
|
-
var errorValue;
|
|
1174
|
-
try {
|
|
1175
|
-
this.work(state);
|
|
1176
|
-
}
|
|
1177
|
-
catch (e) {
|
|
1178
|
-
errored = true;
|
|
1179
|
-
errorValue = e ? e : new Error('Scheduled action threw falsy error');
|
|
1180
|
-
}
|
|
1181
|
-
if (errored) {
|
|
1182
|
-
this.unsubscribe();
|
|
1183
|
-
return errorValue;
|
|
1184
|
-
}
|
|
1185
|
-
};
|
|
1186
|
-
AsyncAction.prototype.unsubscribe = function () {
|
|
1187
|
-
if (!this.closed) {
|
|
1188
|
-
var _a = this, id = _a.id, scheduler = _a.scheduler;
|
|
1189
|
-
var actions = scheduler.actions;
|
|
1190
|
-
this.work = this.state = this.scheduler = null;
|
|
1191
|
-
this.pending = false;
|
|
1192
|
-
arrRemove(actions, this);
|
|
1193
|
-
if (id != null) {
|
|
1194
|
-
this.id = this.recycleAsyncId(scheduler, id, null);
|
|
1195
|
-
}
|
|
1196
|
-
this.delay = null;
|
|
1197
|
-
_super.prototype.unsubscribe.call(this);
|
|
1198
|
-
}
|
|
1199
|
-
};
|
|
1200
|
-
return AsyncAction;
|
|
1201
|
-
}(Action));
|
|
1202
|
-
|
|
1203
|
-
var dateTimestampProvider = {
|
|
1204
|
-
now: function () {
|
|
1205
|
-
return (dateTimestampProvider.delegate || Date).now();
|
|
1206
|
-
},
|
|
1207
|
-
delegate: undefined,
|
|
1208
|
-
};
|
|
1209
|
-
|
|
1210
|
-
var Scheduler = (function () {
|
|
1211
|
-
function Scheduler(schedulerActionCtor, now) {
|
|
1212
|
-
if (now === void 0) { now = Scheduler.now; }
|
|
1213
|
-
this.schedulerActionCtor = schedulerActionCtor;
|
|
1214
|
-
this.now = now;
|
|
1215
|
-
}
|
|
1216
|
-
Scheduler.prototype.schedule = function (work, delay, state) {
|
|
1217
|
-
if (delay === void 0) { delay = 0; }
|
|
1218
|
-
return new this.schedulerActionCtor(this, work).schedule(state, delay);
|
|
1219
|
-
};
|
|
1220
|
-
Scheduler.now = dateTimestampProvider.now;
|
|
1221
|
-
return Scheduler;
|
|
1222
|
-
}());
|
|
1223
|
-
|
|
1224
|
-
var AsyncScheduler = (function (_super) {
|
|
1225
|
-
__extends(AsyncScheduler, _super);
|
|
1226
|
-
function AsyncScheduler(SchedulerAction, now) {
|
|
1227
|
-
if (now === void 0) { now = Scheduler.now; }
|
|
1228
|
-
var _this = _super.call(this, SchedulerAction, now) || this;
|
|
1229
|
-
_this.actions = [];
|
|
1230
|
-
_this._active = false;
|
|
1231
|
-
_this._scheduled = undefined;
|
|
1232
|
-
return _this;
|
|
1233
|
-
}
|
|
1234
|
-
AsyncScheduler.prototype.flush = function (action) {
|
|
1235
|
-
var actions = this.actions;
|
|
1236
|
-
if (this._active) {
|
|
1237
|
-
actions.push(action);
|
|
1238
|
-
return;
|
|
1239
|
-
}
|
|
1240
|
-
var error;
|
|
1241
|
-
this._active = true;
|
|
1242
|
-
do {
|
|
1243
|
-
if ((error = action.execute(action.state, action.delay))) {
|
|
1244
|
-
break;
|
|
1245
|
-
}
|
|
1246
|
-
} while ((action = actions.shift()));
|
|
1247
|
-
this._active = false;
|
|
1248
|
-
if (error) {
|
|
1249
|
-
while ((action = actions.shift())) {
|
|
1250
|
-
action.unsubscribe();
|
|
1251
|
-
}
|
|
1252
|
-
throw error;
|
|
1253
|
-
}
|
|
1254
|
-
};
|
|
1255
|
-
return AsyncScheduler;
|
|
1256
|
-
}(Scheduler));
|
|
1257
|
-
|
|
1258
|
-
var asyncScheduler = new AsyncScheduler(AsyncAction);
|
|
1259
|
-
var async = asyncScheduler;
|
|
1260
|
-
|
|
1261
|
-
function isScheduler(value) {
|
|
1262
|
-
return value && isFunction(value.schedule);
|
|
1263
|
-
}
|
|
1264
|
-
|
|
1265
|
-
function isValidDate(value) {
|
|
1266
|
-
return value instanceof Date && !isNaN(value);
|
|
1267
|
-
}
|
|
1268
|
-
|
|
1269
|
-
function timer(dueTime, intervalOrScheduler, scheduler) {
|
|
1270
|
-
if (dueTime === void 0) { dueTime = 0; }
|
|
1271
|
-
if (scheduler === void 0) { scheduler = async; }
|
|
1272
|
-
var intervalDuration = -1;
|
|
1273
|
-
if (intervalOrScheduler != null) {
|
|
1274
|
-
if (isScheduler(intervalOrScheduler)) {
|
|
1275
|
-
scheduler = intervalOrScheduler;
|
|
1276
|
-
}
|
|
1277
|
-
else {
|
|
1278
|
-
intervalDuration = intervalOrScheduler;
|
|
1279
|
-
}
|
|
1280
|
-
}
|
|
1281
|
-
return new Observable(function (subscriber) {
|
|
1282
|
-
var due = isValidDate(dueTime) ? +dueTime - scheduler.now() : dueTime;
|
|
1283
|
-
if (due < 0) {
|
|
1284
|
-
due = 0;
|
|
1285
|
-
}
|
|
1286
|
-
var n = 0;
|
|
1287
|
-
return scheduler.schedule(function () {
|
|
1288
|
-
if (!subscriber.closed) {
|
|
1289
|
-
subscriber.next(n++);
|
|
1290
|
-
if (0 <= intervalDuration) {
|
|
1291
|
-
this.schedule(undefined, intervalDuration);
|
|
1292
|
-
}
|
|
1293
|
-
else {
|
|
1294
|
-
subscriber.complete();
|
|
1295
|
-
}
|
|
1296
|
-
}
|
|
1297
|
-
}, due);
|
|
1298
|
-
});
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1301
|
-
function last(arr) {
|
|
1302
|
-
return arr[arr.length - 1];
|
|
1303
|
-
}
|
|
1304
|
-
function popScheduler(args) {
|
|
1305
|
-
return isScheduler(last(args)) ? args.pop() : undefined;
|
|
1306
|
-
}
|
|
1307
|
-
|
|
1308
|
-
function executeSchedule(parentSubscription, scheduler, work, delay, repeat) {
|
|
1309
|
-
if (delay === void 0) { delay = 0; }
|
|
1310
|
-
if (repeat === void 0) { repeat = false; }
|
|
1311
|
-
var scheduleSubscription = scheduler.schedule(function () {
|
|
1312
|
-
work();
|
|
1313
|
-
if (repeat) {
|
|
1314
|
-
parentSubscription.add(this.schedule(null, delay));
|
|
1315
|
-
}
|
|
1316
|
-
else {
|
|
1317
|
-
this.unsubscribe();
|
|
1318
|
-
}
|
|
1319
|
-
}, delay);
|
|
1320
|
-
parentSubscription.add(scheduleSubscription);
|
|
1321
|
-
if (!repeat) {
|
|
1322
|
-
return scheduleSubscription;
|
|
1323
|
-
}
|
|
1324
|
-
}
|
|
1325
|
-
|
|
1326
|
-
function catchError(selector) {
|
|
1327
|
-
return operate(function (source, subscriber) {
|
|
1328
|
-
var innerSub = null;
|
|
1329
|
-
var syncUnsub = false;
|
|
1330
|
-
var handledResult;
|
|
1331
|
-
innerSub = source.subscribe(createOperatorSubscriber(subscriber, undefined, undefined, function (err) {
|
|
1332
|
-
handledResult = innerFrom(selector(err, catchError(selector)(source)));
|
|
1333
|
-
if (innerSub) {
|
|
1334
|
-
innerSub.unsubscribe();
|
|
1335
|
-
innerSub = null;
|
|
1336
|
-
handledResult.subscribe(subscriber);
|
|
1337
|
-
}
|
|
1338
|
-
else {
|
|
1339
|
-
syncUnsub = true;
|
|
1340
|
-
}
|
|
1341
|
-
}));
|
|
1342
|
-
if (syncUnsub) {
|
|
1343
|
-
innerSub.unsubscribe();
|
|
1344
|
-
innerSub = null;
|
|
1345
|
-
handledResult.subscribe(subscriber);
|
|
1346
|
-
}
|
|
1347
|
-
});
|
|
26
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
27
|
+
});
|
|
1348
28
|
}
|
|
1349
29
|
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
30
|
+
const UNAUTHORIZED_USER = {
|
|
31
|
+
userId: "unauthorized",
|
|
32
|
+
name: "Unauthorized",
|
|
33
|
+
claims: {
|
|
34
|
+
sub: "unauthorized",
|
|
35
|
+
},
|
|
36
|
+
lastLogin: new Date(0)
|
|
37
|
+
};
|
|
38
|
+
try {
|
|
39
|
+
Object.freeze(UNAUTHORIZED_USER);
|
|
40
|
+
Object.freeze(UNAUTHORIZED_USER.claims);
|
|
1355
41
|
}
|
|
42
|
+
catch (_a) { }
|
|
1356
43
|
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
44
|
+
const swHolder = {};
|
|
45
|
+
const swContainer = typeof self !== 'undefined' && self.document && // self.document is to verify we're not the SW ourself
|
|
46
|
+
typeof navigator !== 'undefined' && navigator.serviceWorker;
|
|
47
|
+
if (swContainer)
|
|
48
|
+
swContainer.ready.then((registration) => (swHolder.registration = registration));
|
|
49
|
+
if (typeof self !== 'undefined' && 'clients' in self && !self.document) {
|
|
50
|
+
// We are the service worker. Propagate messages to all our clients.
|
|
51
|
+
addEventListener('message', (ev) => {
|
|
52
|
+
var _a, _b;
|
|
53
|
+
if ((_b = (_a = ev.data) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.startsWith('sw-broadcast-')) {
|
|
54
|
+
[...self['clients'].matchAll({ includeUncontrolled: true })].forEach((client) => { var _a; return client.id !== ((_a = ev.source) === null || _a === void 0 ? void 0 : _a.id) && client.postMessage(ev.data); });
|
|
55
|
+
}
|
|
1361
56
|
});
|
|
1362
57
|
}
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
}
|
|
1379
|
-
|
|
1380
|
-
subscriber.next(input[i++]);
|
|
1381
|
-
if (!subscriber.closed) {
|
|
1382
|
-
this.schedule();
|
|
1383
|
-
}
|
|
58
|
+
/** This class is a fallback for browsers that lacks BroadcastChannel but have
|
|
59
|
+
* service workers (which is Safari versions 11.1 through 15.3).
|
|
60
|
+
* Safari 15.4 with BroadcastChannel was released on 2022-03-14.
|
|
61
|
+
* We might be able to remove this class in a near future as Safari < 15.4 is
|
|
62
|
+
* already very low in market share as of 2023-03-10.
|
|
63
|
+
*/
|
|
64
|
+
class SWBroadcastChannel {
|
|
65
|
+
constructor(name) {
|
|
66
|
+
this.name = name;
|
|
67
|
+
}
|
|
68
|
+
subscribe(listener) {
|
|
69
|
+
if (!swContainer)
|
|
70
|
+
return () => { };
|
|
71
|
+
const forwarder = (ev) => {
|
|
72
|
+
var _a;
|
|
73
|
+
if (((_a = ev.data) === null || _a === void 0 ? void 0 : _a.type) === `sw-broadcast-${this.name}`) {
|
|
74
|
+
listener(ev.data.message);
|
|
1384
75
|
}
|
|
1385
|
-
}
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
function scheduleIterable(input, scheduler) {
|
|
1390
|
-
return new Observable(function (subscriber) {
|
|
1391
|
-
var iterator$1;
|
|
1392
|
-
executeSchedule(subscriber, scheduler, function () {
|
|
1393
|
-
iterator$1 = input[iterator]();
|
|
1394
|
-
executeSchedule(subscriber, scheduler, function () {
|
|
1395
|
-
var _a;
|
|
1396
|
-
var value;
|
|
1397
|
-
var done;
|
|
1398
|
-
try {
|
|
1399
|
-
(_a = iterator$1.next(), value = _a.value, done = _a.done);
|
|
1400
|
-
}
|
|
1401
|
-
catch (err) {
|
|
1402
|
-
subscriber.error(err);
|
|
1403
|
-
return;
|
|
1404
|
-
}
|
|
1405
|
-
if (done) {
|
|
1406
|
-
subscriber.complete();
|
|
1407
|
-
}
|
|
1408
|
-
else {
|
|
1409
|
-
subscriber.next(value);
|
|
1410
|
-
}
|
|
1411
|
-
}, 0, true);
|
|
1412
|
-
});
|
|
1413
|
-
return function () { return isFunction(iterator$1 === null || iterator$1 === void 0 ? void 0 : iterator$1.return) && iterator$1.return(); };
|
|
1414
|
-
});
|
|
1415
|
-
}
|
|
1416
|
-
|
|
1417
|
-
function scheduleAsyncIterable(input, scheduler) {
|
|
1418
|
-
if (!input) {
|
|
1419
|
-
throw new Error('Iterable cannot be null');
|
|
76
|
+
};
|
|
77
|
+
swContainer.addEventListener('message', forwarder);
|
|
78
|
+
return () => swContainer.removeEventListener('message', forwarder);
|
|
1420
79
|
}
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
else {
|
|
1430
|
-
subscriber.next(result.value);
|
|
1431
|
-
}
|
|
1432
|
-
});
|
|
1433
|
-
}, 0, true);
|
|
1434
|
-
});
|
|
1435
|
-
});
|
|
1436
|
-
}
|
|
1437
|
-
|
|
1438
|
-
function scheduleReadableStreamLike(input, scheduler) {
|
|
1439
|
-
return scheduleAsyncIterable(readableStreamLikeToAsyncGenerator(input), scheduler);
|
|
1440
|
-
}
|
|
1441
|
-
|
|
1442
|
-
function scheduled(input, scheduler) {
|
|
1443
|
-
if (input != null) {
|
|
1444
|
-
if (isInteropObservable(input)) {
|
|
1445
|
-
return scheduleObservable(input, scheduler);
|
|
1446
|
-
}
|
|
1447
|
-
if (isArrayLike(input)) {
|
|
1448
|
-
return scheduleArray(input, scheduler);
|
|
1449
|
-
}
|
|
1450
|
-
if (isPromise(input)) {
|
|
1451
|
-
return schedulePromise(input, scheduler);
|
|
1452
|
-
}
|
|
1453
|
-
if (isAsyncIterable(input)) {
|
|
1454
|
-
return scheduleAsyncIterable(input, scheduler);
|
|
1455
|
-
}
|
|
1456
|
-
if (isIterable(input)) {
|
|
1457
|
-
return scheduleIterable(input, scheduler);
|
|
80
|
+
postMessage(message) {
|
|
81
|
+
var _a;
|
|
82
|
+
if (typeof self['clients'] === 'object') {
|
|
83
|
+
// We're a service worker. Propagate to our browser clients.
|
|
84
|
+
[...self['clients'].matchAll({ includeUncontrolled: true })].forEach((client) => client.postMessage({
|
|
85
|
+
type: `sw-broadcast-${this.name}`,
|
|
86
|
+
message,
|
|
87
|
+
}));
|
|
1458
88
|
}
|
|
1459
|
-
if (
|
|
1460
|
-
|
|
89
|
+
else if (swHolder.registration) {
|
|
90
|
+
// We're a client (browser window or other worker)
|
|
91
|
+
// Post to SW so it can repost to all its clients and to itself
|
|
92
|
+
(_a = swHolder.registration.active) === null || _a === void 0 ? void 0 : _a.postMessage({
|
|
93
|
+
type: `sw-broadcast-${this.name}`,
|
|
94
|
+
message,
|
|
95
|
+
});
|
|
1461
96
|
}
|
|
1462
97
|
}
|
|
1463
|
-
throw createInvalidObservableTypeError(input);
|
|
1464
|
-
}
|
|
1465
|
-
|
|
1466
|
-
function from(input, scheduler) {
|
|
1467
|
-
return scheduler ? scheduled(input, scheduler) : innerFrom(input);
|
|
1468
|
-
}
|
|
1469
|
-
|
|
1470
|
-
function map(project, thisArg) {
|
|
1471
|
-
return operate(function (source, subscriber) {
|
|
1472
|
-
var index = 0;
|
|
1473
|
-
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1474
|
-
subscriber.next(project.call(thisArg, value, index++));
|
|
1475
|
-
}));
|
|
1476
|
-
});
|
|
1477
|
-
}
|
|
1478
|
-
|
|
1479
|
-
function mergeInternals(source, subscriber, project, concurrent, onBeforeNext, expand, innerSubScheduler, additionalFinalizer) {
|
|
1480
|
-
var buffer = [];
|
|
1481
|
-
var active = 0;
|
|
1482
|
-
var index = 0;
|
|
1483
|
-
var isComplete = false;
|
|
1484
|
-
var checkComplete = function () {
|
|
1485
|
-
if (isComplete && !buffer.length && !active) {
|
|
1486
|
-
subscriber.complete();
|
|
1487
|
-
}
|
|
1488
|
-
};
|
|
1489
|
-
var outerNext = function (value) { return (active < concurrent ? doInnerSub(value) : buffer.push(value)); };
|
|
1490
|
-
var doInnerSub = function (value) {
|
|
1491
|
-
expand && subscriber.next(value);
|
|
1492
|
-
active++;
|
|
1493
|
-
var innerComplete = false;
|
|
1494
|
-
innerFrom(project(value, index++)).subscribe(createOperatorSubscriber(subscriber, function (innerValue) {
|
|
1495
|
-
onBeforeNext === null || onBeforeNext === void 0 ? void 0 : onBeforeNext(innerValue);
|
|
1496
|
-
if (expand) {
|
|
1497
|
-
outerNext(innerValue);
|
|
1498
|
-
}
|
|
1499
|
-
else {
|
|
1500
|
-
subscriber.next(innerValue);
|
|
1501
|
-
}
|
|
1502
|
-
}, function () {
|
|
1503
|
-
innerComplete = true;
|
|
1504
|
-
}, undefined, function () {
|
|
1505
|
-
if (innerComplete) {
|
|
1506
|
-
try {
|
|
1507
|
-
active--;
|
|
1508
|
-
var _loop_1 = function () {
|
|
1509
|
-
var bufferedValue = buffer.shift();
|
|
1510
|
-
if (innerSubScheduler) {
|
|
1511
|
-
executeSchedule(subscriber, innerSubScheduler, function () { return doInnerSub(bufferedValue); });
|
|
1512
|
-
}
|
|
1513
|
-
else {
|
|
1514
|
-
doInnerSub(bufferedValue);
|
|
1515
|
-
}
|
|
1516
|
-
};
|
|
1517
|
-
while (buffer.length && active < concurrent) {
|
|
1518
|
-
_loop_1();
|
|
1519
|
-
}
|
|
1520
|
-
checkComplete();
|
|
1521
|
-
}
|
|
1522
|
-
catch (err) {
|
|
1523
|
-
subscriber.error(err);
|
|
1524
|
-
}
|
|
1525
|
-
}
|
|
1526
|
-
}));
|
|
1527
|
-
};
|
|
1528
|
-
source.subscribe(createOperatorSubscriber(subscriber, outerNext, function () {
|
|
1529
|
-
isComplete = true;
|
|
1530
|
-
checkComplete();
|
|
1531
|
-
}));
|
|
1532
|
-
return function () {
|
|
1533
|
-
additionalFinalizer === null || additionalFinalizer === void 0 ? void 0 : additionalFinalizer();
|
|
1534
|
-
};
|
|
1535
98
|
}
|
|
1536
99
|
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
if (
|
|
1540
|
-
|
|
100
|
+
const events = globalThis['lbc-events'] || (globalThis['lbc-events'] = new Map());
|
|
101
|
+
function addListener(name, listener) {
|
|
102
|
+
if (events.has(name)) {
|
|
103
|
+
events.get(name).push(listener);
|
|
1541
104
|
}
|
|
1542
|
-
else
|
|
1543
|
-
|
|
105
|
+
else {
|
|
106
|
+
events.set(name, [listener]);
|
|
1544
107
|
}
|
|
1545
|
-
return operate(function (source, subscriber) { return mergeInternals(source, subscriber, project, concurrent); });
|
|
1546
|
-
}
|
|
1547
|
-
|
|
1548
|
-
function mergeAll(concurrent) {
|
|
1549
|
-
if (concurrent === void 0) { concurrent = Infinity; }
|
|
1550
|
-
return mergeMap(identity, concurrent);
|
|
1551
|
-
}
|
|
1552
|
-
|
|
1553
|
-
function concatAll() {
|
|
1554
|
-
return mergeAll(1);
|
|
1555
108
|
}
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
if (
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
var lastTime = null;
|
|
1563
|
-
var emit = function () {
|
|
1564
|
-
if (activeTask) {
|
|
1565
|
-
activeTask.unsubscribe();
|
|
1566
|
-
activeTask = null;
|
|
1567
|
-
var value = lastValue;
|
|
1568
|
-
lastValue = null;
|
|
1569
|
-
subscriber.next(value);
|
|
1570
|
-
}
|
|
1571
|
-
};
|
|
1572
|
-
function emitWhenIdle() {
|
|
1573
|
-
var targetTime = lastTime + dueTime;
|
|
1574
|
-
var now = scheduler.now();
|
|
1575
|
-
if (now < targetTime) {
|
|
1576
|
-
activeTask = this.schedule(undefined, targetTime - now);
|
|
1577
|
-
subscriber.add(activeTask);
|
|
1578
|
-
return;
|
|
1579
|
-
}
|
|
1580
|
-
emit();
|
|
109
|
+
function removeListener(name, listener) {
|
|
110
|
+
const listeners = events.get(name);
|
|
111
|
+
if (listeners) {
|
|
112
|
+
const idx = listeners.indexOf(listener);
|
|
113
|
+
if (idx !== -1) {
|
|
114
|
+
listeners.splice(idx, 1);
|
|
1581
115
|
}
|
|
1582
|
-
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1583
|
-
lastValue = value;
|
|
1584
|
-
lastTime = scheduler.now();
|
|
1585
|
-
if (!activeTask) {
|
|
1586
|
-
activeTask = scheduler.schedule(emitWhenIdle, dueTime);
|
|
1587
|
-
subscriber.add(activeTask);
|
|
1588
|
-
}
|
|
1589
|
-
}, function () {
|
|
1590
|
-
emit();
|
|
1591
|
-
subscriber.complete();
|
|
1592
|
-
}, undefined, function () {
|
|
1593
|
-
lastValue = activeTask = null;
|
|
1594
|
-
}));
|
|
1595
|
-
});
|
|
1596
|
-
}
|
|
1597
|
-
|
|
1598
|
-
function concat$1() {
|
|
1599
|
-
var args = [];
|
|
1600
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1601
|
-
args[_i] = arguments[_i];
|
|
1602
116
|
}
|
|
1603
|
-
return concatAll()(from(args, popScheduler(args)));
|
|
1604
117
|
}
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1615
|
-
if (++seen <= count) {
|
|
1616
|
-
subscriber.next(value);
|
|
1617
|
-
if (count <= seen) {
|
|
1618
|
-
subscriber.complete();
|
|
1619
|
-
}
|
|
1620
|
-
}
|
|
1621
|
-
}));
|
|
118
|
+
function dispatch(ev) {
|
|
119
|
+
const listeners = events.get(ev.type);
|
|
120
|
+
if (listeners) {
|
|
121
|
+
listeners.forEach(listener => {
|
|
122
|
+
try {
|
|
123
|
+
listener(ev);
|
|
124
|
+
}
|
|
125
|
+
catch (_a) {
|
|
126
|
+
}
|
|
1622
127
|
});
|
|
1623
|
-
}
|
|
1624
|
-
|
|
1625
|
-
function ignoreElements() {
|
|
1626
|
-
return operate(function (source, subscriber) {
|
|
1627
|
-
source.subscribe(createOperatorSubscriber(subscriber, noop));
|
|
1628
|
-
});
|
|
1629
|
-
}
|
|
1630
|
-
|
|
1631
|
-
function mapTo(value) {
|
|
1632
|
-
return map(function () { return value; });
|
|
1633
|
-
}
|
|
1634
|
-
|
|
1635
|
-
function delayWhen(delayDurationSelector, subscriptionDelay) {
|
|
1636
|
-
if (subscriptionDelay) {
|
|
1637
|
-
return function (source) {
|
|
1638
|
-
return concat$1(subscriptionDelay.pipe(take(1), ignoreElements()), source.pipe(delayWhen(delayDurationSelector)));
|
|
1639
|
-
};
|
|
1640
128
|
}
|
|
1641
|
-
return mergeMap(function (value, index) { return delayDurationSelector(value, index).pipe(take(1), mapTo(value)); });
|
|
1642
|
-
}
|
|
1643
|
-
|
|
1644
|
-
function delay(due, scheduler) {
|
|
1645
|
-
if (scheduler === void 0) { scheduler = asyncScheduler; }
|
|
1646
|
-
var duration = timer(due, scheduler);
|
|
1647
|
-
return delayWhen(function () { return duration; });
|
|
1648
129
|
}
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1657
|
-
var currentKey = keySelector(value);
|
|
1658
|
-
if (first || !comparator(previousKey, currentKey)) {
|
|
1659
|
-
first = false;
|
|
1660
|
-
previousKey = currentKey;
|
|
1661
|
-
subscriber.next(value);
|
|
130
|
+
class BroadcastedAndLocalEvent extends Observable {
|
|
131
|
+
constructor(name) {
|
|
132
|
+
const bc = typeof BroadcastChannel === "undefined"
|
|
133
|
+
? new SWBroadcastChannel(name) : new BroadcastChannel(name);
|
|
134
|
+
super(subscriber => {
|
|
135
|
+
function onCustomEvent(ev) {
|
|
136
|
+
subscriber.next(ev.detail);
|
|
1662
137
|
}
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
}
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
source.subscribe(createOperatorSubscriber(subscriber, function (value) { return predicate.call(thisArg, value, index++) && subscriber.next(value); }));
|
|
1674
|
-
});
|
|
1675
|
-
}
|
|
1676
|
-
|
|
1677
|
-
function skip(count) {
|
|
1678
|
-
return filter(function (_, index) { return count <= index; });
|
|
1679
|
-
}
|
|
1680
|
-
|
|
1681
|
-
function startWith() {
|
|
1682
|
-
var values = [];
|
|
1683
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1684
|
-
values[_i] = arguments[_i];
|
|
1685
|
-
}
|
|
1686
|
-
var scheduler = popScheduler(values);
|
|
1687
|
-
return operate(function (source, subscriber) {
|
|
1688
|
-
(scheduler ? concat$1(values, source, scheduler) : concat$1(values, source)).subscribe(subscriber);
|
|
1689
|
-
});
|
|
1690
|
-
}
|
|
1691
|
-
|
|
1692
|
-
function switchMap(project, resultSelector) {
|
|
1693
|
-
return operate(function (source, subscriber) {
|
|
1694
|
-
var innerSubscriber = null;
|
|
1695
|
-
var index = 0;
|
|
1696
|
-
var isComplete = false;
|
|
1697
|
-
var checkComplete = function () { return isComplete && !innerSubscriber && subscriber.complete(); };
|
|
1698
|
-
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1699
|
-
innerSubscriber === null || innerSubscriber === void 0 ? void 0 : innerSubscriber.unsubscribe();
|
|
1700
|
-
var innerIndex = 0;
|
|
1701
|
-
var outerIndex = index++;
|
|
1702
|
-
innerFrom(project(value, outerIndex)).subscribe((innerSubscriber = createOperatorSubscriber(subscriber, function (innerValue) { return subscriber.next(resultSelector ? resultSelector(value, innerValue, outerIndex, innerIndex++) : innerValue); }, function () {
|
|
1703
|
-
innerSubscriber = null;
|
|
1704
|
-
checkComplete();
|
|
1705
|
-
})));
|
|
1706
|
-
}, function () {
|
|
1707
|
-
isComplete = true;
|
|
1708
|
-
checkComplete();
|
|
1709
|
-
}));
|
|
1710
|
-
});
|
|
1711
|
-
}
|
|
1712
|
-
|
|
1713
|
-
function tap(observerOrNext, error, complete) {
|
|
1714
|
-
var tapObserver = isFunction(observerOrNext) || error || complete
|
|
1715
|
-
?
|
|
1716
|
-
{ next: observerOrNext, error: error, complete: complete }
|
|
1717
|
-
: observerOrNext;
|
|
1718
|
-
return tapObserver
|
|
1719
|
-
? operate(function (source, subscriber) {
|
|
1720
|
-
var _a;
|
|
1721
|
-
(_a = tapObserver.subscribe) === null || _a === void 0 ? void 0 : _a.call(tapObserver);
|
|
1722
|
-
var isUnsub = true;
|
|
1723
|
-
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1724
|
-
var _a;
|
|
1725
|
-
(_a = tapObserver.next) === null || _a === void 0 ? void 0 : _a.call(tapObserver, value);
|
|
1726
|
-
subscriber.next(value);
|
|
1727
|
-
}, function () {
|
|
1728
|
-
var _a;
|
|
1729
|
-
isUnsub = false;
|
|
1730
|
-
(_a = tapObserver.complete) === null || _a === void 0 ? void 0 : _a.call(tapObserver);
|
|
1731
|
-
subscriber.complete();
|
|
1732
|
-
}, function (err) {
|
|
1733
|
-
var _a;
|
|
1734
|
-
isUnsub = false;
|
|
1735
|
-
(_a = tapObserver.error) === null || _a === void 0 ? void 0 : _a.call(tapObserver, err);
|
|
1736
|
-
subscriber.error(err);
|
|
1737
|
-
}, function () {
|
|
1738
|
-
var _a, _b;
|
|
1739
|
-
if (isUnsub) {
|
|
1740
|
-
(_a = tapObserver.unsubscribe) === null || _a === void 0 ? void 0 : _a.call(tapObserver);
|
|
1741
|
-
}
|
|
1742
|
-
(_b = tapObserver.finalize) === null || _b === void 0 ? void 0 : _b.call(tapObserver);
|
|
1743
|
-
}));
|
|
1744
|
-
})
|
|
1745
|
-
:
|
|
1746
|
-
identity;
|
|
1747
|
-
}
|
|
1748
|
-
|
|
1749
|
-
var TimeoutError = createErrorClass(function (_super) {
|
|
1750
|
-
return function TimeoutErrorImpl(info) {
|
|
1751
|
-
if (info === void 0) { info = null; }
|
|
1752
|
-
_super(this);
|
|
1753
|
-
this.message = 'Timeout has occurred';
|
|
1754
|
-
this.name = 'TimeoutError';
|
|
1755
|
-
this.info = info;
|
|
1756
|
-
};
|
|
1757
|
-
});
|
|
1758
|
-
function timeout(config, schedulerArg) {
|
|
1759
|
-
var _a = (isValidDate(config) ? { first: config } : typeof config === 'number' ? { each: config } : config), first = _a.first, each = _a.each, _b = _a.with, _with = _b === void 0 ? timeoutErrorFactory : _b, _c = _a.scheduler, scheduler = _c === void 0 ? schedulerArg !== null && schedulerArg !== void 0 ? schedulerArg : asyncScheduler : _c, _d = _a.meta, meta = _d === void 0 ? null : _d;
|
|
1760
|
-
if (first == null && each == null) {
|
|
1761
|
-
throw new TypeError('No timeout provided.');
|
|
1762
|
-
}
|
|
1763
|
-
return operate(function (source, subscriber) {
|
|
1764
|
-
var originalSourceSubscription;
|
|
1765
|
-
var timerSubscription;
|
|
1766
|
-
var lastValue = null;
|
|
1767
|
-
var seen = 0;
|
|
1768
|
-
var startTimer = function (delay) {
|
|
1769
|
-
timerSubscription = executeSchedule(subscriber, scheduler, function () {
|
|
1770
|
-
try {
|
|
1771
|
-
originalSourceSubscription.unsubscribe();
|
|
1772
|
-
innerFrom(_with({
|
|
1773
|
-
meta: meta,
|
|
1774
|
-
lastValue: lastValue,
|
|
1775
|
-
seen: seen,
|
|
1776
|
-
})).subscribe(subscriber);
|
|
138
|
+
function onMessageEvent(ev) {
|
|
139
|
+
console.debug("BroadcastedAndLocalEvent: onMessageEvent", ev);
|
|
140
|
+
subscriber.next(ev.data);
|
|
141
|
+
}
|
|
142
|
+
let unsubscribe;
|
|
143
|
+
//self.addEventListener(`lbc-${name}`, onCustomEvent); // Fails in service workers
|
|
144
|
+
addListener(`lbc-${name}`, onCustomEvent); // Works better in service worker
|
|
145
|
+
try {
|
|
146
|
+
if (bc instanceof SWBroadcastChannel) {
|
|
147
|
+
unsubscribe = bc.subscribe(message => subscriber.next(message));
|
|
1777
148
|
}
|
|
1778
|
-
|
|
1779
|
-
|
|
149
|
+
else {
|
|
150
|
+
console.debug("BroadcastedAndLocalEvent: bc.addEventListener()", name, "bc is a", bc);
|
|
151
|
+
bc.addEventListener("message", onMessageEvent);
|
|
1780
152
|
}
|
|
1781
|
-
}, delay);
|
|
1782
|
-
};
|
|
1783
|
-
originalSourceSubscription = source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1784
|
-
timerSubscription === null || timerSubscription === void 0 ? void 0 : timerSubscription.unsubscribe();
|
|
1785
|
-
seen++;
|
|
1786
|
-
subscriber.next((lastValue = value));
|
|
1787
|
-
each > 0 && startTimer(each);
|
|
1788
|
-
}, undefined, undefined, function () {
|
|
1789
|
-
if (!(timerSubscription === null || timerSubscription === void 0 ? void 0 : timerSubscription.closed)) {
|
|
1790
|
-
timerSubscription === null || timerSubscription === void 0 ? void 0 : timerSubscription.unsubscribe();
|
|
1791
153
|
}
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
154
|
+
catch (err) {
|
|
155
|
+
// Service workers might fail to subscribe outside its initial script.
|
|
156
|
+
console.warn('Failed to subscribe to broadcast channel', err);
|
|
157
|
+
}
|
|
158
|
+
return () => {
|
|
159
|
+
//self.removeEventListener(`lbc-${name}`, onCustomEvent);
|
|
160
|
+
removeListener(`lbc-${name}`, onCustomEvent);
|
|
161
|
+
if (bc instanceof SWBroadcastChannel) {
|
|
162
|
+
unsubscribe();
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
bc.removeEventListener("message", onMessageEvent);
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
});
|
|
169
|
+
this.name = name;
|
|
170
|
+
this.bc = bc;
|
|
171
|
+
}
|
|
172
|
+
next(message) {
|
|
173
|
+
console.debug("BroadcastedAndLocalEvent: bc.postMessage()", Object.assign({}, message), "bc is a", this.bc);
|
|
174
|
+
this.bc.postMessage(message);
|
|
175
|
+
const ev = new CustomEvent(`lbc-${this.name}`, { detail: message });
|
|
176
|
+
//self.dispatchEvent(ev);
|
|
177
|
+
dispatch(ev);
|
|
178
|
+
}
|
|
1799
179
|
}
|
|
1800
180
|
|
|
1801
181
|
//const hasSW = 'serviceWorker' in navigator;
|
|
@@ -4794,6 +3174,38 @@ function createMutationTrackingMiddleware({ currentUserObservable, db }) {
|
|
|
4794
3174
|
function overrideParseStoresSpec(origFunc, dexie) {
|
|
4795
3175
|
return function (stores, dbSchema) {
|
|
4796
3176
|
const storesClone = Object.assign(Object.assign({}, DEXIE_CLOUD_SCHEMA), stores);
|
|
3177
|
+
// Merge indexes of DEXIE_CLOUD_SCHEMA with stores
|
|
3178
|
+
Object.keys(DEXIE_CLOUD_SCHEMA).forEach((tableName) => {
|
|
3179
|
+
const schemaSrc = storesClone[tableName];
|
|
3180
|
+
// Verify that they don't try to delete a table that is needed for access control of Dexie Cloud
|
|
3181
|
+
if (schemaSrc == null) {
|
|
3182
|
+
// They try to delete one of the built-in schema tables.
|
|
3183
|
+
throw new Error(`Cannot delete table ${tableName} as it is needed for access control of Dexie Cloud`);
|
|
3184
|
+
}
|
|
3185
|
+
// If not trying to override a built-in table, then we can skip this and continue to next table.
|
|
3186
|
+
if (!stores[tableName]) {
|
|
3187
|
+
// They haven't tried to declare this table. No need to merge indexes.
|
|
3188
|
+
return; // Continue
|
|
3189
|
+
}
|
|
3190
|
+
// They have declared this table. Merge indexes in case they didn't declare all indexes we need.
|
|
3191
|
+
const requestedIndexes = schemaSrc.split(',').map(spec => spec.trim());
|
|
3192
|
+
const builtInIndexes = DEXIE_CLOUD_SCHEMA[tableName].split(',').map(spec => spec.trim());
|
|
3193
|
+
const requestedIndexSet = new Set(requestedIndexes.map(index => index.replace(/([&*]|\+\+)/g, "")));
|
|
3194
|
+
// Verify that primary key is unchanged
|
|
3195
|
+
if (requestedIndexes[0] !== builtInIndexes[0]) {
|
|
3196
|
+
// Primary key must match exactly
|
|
3197
|
+
throw new Error(`Cannot override primary key of table ${tableName}. Please declare it as {${tableName}: ${JSON.stringify(DEXIE_CLOUD_SCHEMA[tableName])}`);
|
|
3198
|
+
}
|
|
3199
|
+
// Merge indexes
|
|
3200
|
+
for (let i = 1; i < builtInIndexes.length; ++i) {
|
|
3201
|
+
const builtInIndex = builtInIndexes[i];
|
|
3202
|
+
if (!requestedIndexSet.has(builtInIndex.replace(/([&*]|\+\+)/g, ""))) {
|
|
3203
|
+
// Add built-in index if not already requested
|
|
3204
|
+
storesClone[tableName] += `,${builtInIndex}`;
|
|
3205
|
+
}
|
|
3206
|
+
}
|
|
3207
|
+
});
|
|
3208
|
+
// Populate dexie.cloud.schema
|
|
4797
3209
|
const cloudSchema = dexie.cloud.schema || (dexie.cloud.schema = {});
|
|
4798
3210
|
const allPrefixes = new Set();
|
|
4799
3211
|
Object.keys(storesClone).forEach(tableName => {
|
|
@@ -4909,13 +3321,13 @@ class TokenExpiredError extends Error {
|
|
|
4909
3321
|
const SERVER_PING_TIMEOUT = 20000;
|
|
4910
3322
|
const CLIENT_PING_INTERVAL = 30000;
|
|
4911
3323
|
const FAIL_RETRY_WAIT_TIME = 60000;
|
|
4912
|
-
class WSObservable extends Observable
|
|
3324
|
+
class WSObservable extends Observable {
|
|
4913
3325
|
constructor(databaseUrl, rev, realmSetHash, clientIdentity, messageProducer, webSocketStatus, token, tokenExpiration) {
|
|
4914
3326
|
super((subscriber) => new WSConnection(databaseUrl, rev, realmSetHash, clientIdentity, token, tokenExpiration, subscriber, messageProducer, webSocketStatus));
|
|
4915
3327
|
}
|
|
4916
3328
|
}
|
|
4917
3329
|
let counter = 0;
|
|
4918
|
-
class WSConnection extends Subscription
|
|
3330
|
+
class WSConnection extends Subscription {
|
|
4919
3331
|
constructor(databaseUrl, rev, realmSetHash, clientIdentity, token, tokenExpiration, subscriber, messageProducer, webSocketStatus) {
|
|
4920
3332
|
super(() => this.teardown());
|
|
4921
3333
|
this.id = ++counter;
|
|
@@ -5158,7 +3570,7 @@ function connectWebSocket(db) {
|
|
|
5158
3570
|
// and the baseRev of the last from same client-ID.
|
|
5159
3571
|
userLogin
|
|
5160
3572
|
? new WSObservable(db.cloud.options.databaseUrl, db.cloud.persistedSyncState.value.serverRevision, realmSetHash, db.cloud.persistedSyncState.value.clientIdentity, messageProducer, db.cloud.webSocketStatus, userLogin.accessToken, userLogin.accessTokenExpiration)
|
|
5161
|
-
: from
|
|
3573
|
+
: from([])), catchError((error) => {
|
|
5162
3574
|
if ((error === null || error === void 0 ? void 0 : error.name) === 'TokenExpiredError') {
|
|
5163
3575
|
console.debug('WebSocket observable: Token expired. Refreshing token...');
|
|
5164
3576
|
return of(true).pipe(switchMap(() => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -5177,7 +3589,7 @@ function connectWebSocket(db) {
|
|
|
5177
3589
|
}
|
|
5178
3590
|
}), catchError((error) => {
|
|
5179
3591
|
db.cloud.webSocketStatus.next("error");
|
|
5180
|
-
return from
|
|
3592
|
+
return from(waitAndReconnectWhenUserDoesSomething(error)).pipe(switchMap(() => createObservable()));
|
|
5181
3593
|
}));
|
|
5182
3594
|
}
|
|
5183
3595
|
return createObservable().subscribe((msg) => {
|
|
@@ -5246,7 +3658,7 @@ function performGuardedJob(db, jobName, jobsTableName, job, { awaitRemoteJob } =
|
|
|
5246
3658
|
// Someone else took the job.
|
|
5247
3659
|
if (awaitRemoteJob) {
|
|
5248
3660
|
try {
|
|
5249
|
-
const jobDoneObservable = from
|
|
3661
|
+
const jobDoneObservable = from(liveQuery(() => jobsTable.get(jobName))).pipe(timeout(GUARDED_JOB_TIMEOUT), filter((job) => !job)); // Wait til job is not there anymore.
|
|
5250
3662
|
yield jobDoneObservable.toPromise();
|
|
5251
3663
|
return false;
|
|
5252
3664
|
}
|
|
@@ -5565,7 +3977,7 @@ class LoginGui extends d$1 {
|
|
|
5565
3977
|
this.state = { userInteraction: undefined };
|
|
5566
3978
|
}
|
|
5567
3979
|
componentDidMount() {
|
|
5568
|
-
this.subscription = from
|
|
3980
|
+
this.subscription = from(this.props.db.cloud.userInteraction).subscribe(this.observer);
|
|
5569
3981
|
}
|
|
5570
3982
|
componentWillUnmount() {
|
|
5571
3983
|
if (this.subscription) {
|
|
@@ -5693,8 +4105,8 @@ function associate(factory) {
|
|
|
5693
4105
|
|
|
5694
4106
|
function createSharedValueObservable(o, defaultValue) {
|
|
5695
4107
|
let currentValue = defaultValue;
|
|
5696
|
-
let shared = from
|
|
5697
|
-
const rv = new Observable
|
|
4108
|
+
let shared = from(o).pipe(map$1((x) => (currentValue = x)), share({ resetOnRefCountZero: () => timer(1000) }));
|
|
4109
|
+
const rv = new Observable((observer) => {
|
|
5698
4110
|
let didEmit = false;
|
|
5699
4111
|
const subscription = shared.subscribe({
|
|
5700
4112
|
next(value) {
|
|
@@ -6016,7 +4428,7 @@ function dexieCloud(dexie) {
|
|
|
6016
4428
|
});
|
|
6017
4429
|
const syncComplete = new Subject();
|
|
6018
4430
|
dexie.cloud = {
|
|
6019
|
-
version: '4.0.1-beta.
|
|
4431
|
+
version: '4.0.1-beta.39',
|
|
6020
4432
|
options: Object.assign({}, DEFAULT_OPTIONS),
|
|
6021
4433
|
schema: null,
|
|
6022
4434
|
get currentUserId() {
|
|
@@ -6075,7 +4487,7 @@ function dexieCloud(dexie) {
|
|
|
6075
4487
|
triggerSync(db, purpose);
|
|
6076
4488
|
if (wait) {
|
|
6077
4489
|
console.debug('db.cloud.login() is waiting for sync completion...');
|
|
6078
|
-
yield from
|
|
4490
|
+
yield from(liveQuery(() => __awaiter(this, void 0, void 0, function* () {
|
|
6079
4491
|
const syncNeeded = yield isSyncNeeded(db);
|
|
6080
4492
|
const newSyncState = yield db.getPersistedSyncState();
|
|
6081
4493
|
if ((newSyncState === null || newSyncState === void 0 ? void 0 : newSyncState.timestamp) !== (syncState === null || syncState === void 0 ? void 0 : syncState.timestamp) &&
|
|
@@ -6277,7 +4689,7 @@ function dexieCloud(dexie) {
|
|
|
6277
4689
|
});
|
|
6278
4690
|
}
|
|
6279
4691
|
}
|
|
6280
|
-
dexieCloud.version = '4.0.1-beta.
|
|
4692
|
+
dexieCloud.version = '4.0.1-beta.39';
|
|
6281
4693
|
Dexie.Cloud = dexieCloud;
|
|
6282
4694
|
|
|
6283
4695
|
// In case the SW lives for a while, let it reuse already opened connections:
|