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,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('dexie'), require('rxjs')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['dexie', 'rxjs'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Dexie, global.rxjs));
|
|
5
|
-
})(this, (function (Dexie, rxjs) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('dexie'), require('rxjs'), require('rxjs/operators')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['dexie', 'rxjs', 'rxjs/operators'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Dexie, global.rxjs, global.rxjs.operators));
|
|
5
|
+
})(this, (function (Dexie, rxjs, operators) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -22,22 +22,6 @@
|
|
|
22
22
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
23
23
|
PERFORMANCE OF THIS SOFTWARE.
|
|
24
24
|
***************************************************************************** */
|
|
25
|
-
/* global Reflect, Promise */
|
|
26
|
-
|
|
27
|
-
var extendStatics = function(d, b) {
|
|
28
|
-
extendStatics = Object.setPrototypeOf ||
|
|
29
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
30
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
31
|
-
return extendStatics(d, b);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
function __extends(d, b) {
|
|
35
|
-
if (typeof b !== "function" && b !== null)
|
|
36
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
37
|
-
extendStatics(d, b);
|
|
38
|
-
function __() { this.constructor = d; }
|
|
39
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
40
|
-
}
|
|
41
25
|
|
|
42
26
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
43
27
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
@@ -46,1763 +30,158 @@
|
|
|
46
30
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
47
31
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
48
32
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function __generator(thisArg, body) {
|
|
53
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
54
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
55
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
56
|
-
function step(op) {
|
|
57
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
58
|
-
while (_) try {
|
|
59
|
-
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;
|
|
60
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
61
|
-
switch (op[0]) {
|
|
62
|
-
case 0: case 1: t = op; break;
|
|
63
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
64
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
65
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
66
|
-
default:
|
|
67
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
68
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
69
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
70
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
71
|
-
if (t[2]) _.ops.pop();
|
|
72
|
-
_.trys.pop(); continue;
|
|
73
|
-
}
|
|
74
|
-
op = body.call(thisArg, _);
|
|
75
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
76
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function __values(o) {
|
|
81
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
82
|
-
if (m) return m.call(o);
|
|
83
|
-
if (o && typeof o.length === "number") return {
|
|
84
|
-
next: function () {
|
|
85
|
-
if (o && i >= o.length) o = void 0;
|
|
86
|
-
return { value: o && o[i++], done: !o };
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function __read(o, n) {
|
|
93
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
94
|
-
if (!m) return o;
|
|
95
|
-
var i = m.call(o), r, ar = [], e;
|
|
96
|
-
try {
|
|
97
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
98
|
-
}
|
|
99
|
-
catch (error) { e = { error: error }; }
|
|
100
|
-
finally {
|
|
101
|
-
try {
|
|
102
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
103
|
-
}
|
|
104
|
-
finally { if (e) throw e.error; }
|
|
105
|
-
}
|
|
106
|
-
return ar;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function __spreadArray(to, from, pack) {
|
|
110
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
111
|
-
if (ar || !(i in from)) {
|
|
112
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
113
|
-
ar[i] = from[i];
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function __await(v) {
|
|
120
|
-
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
124
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
125
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
126
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
127
|
-
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); }); }; }
|
|
128
|
-
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
129
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
130
|
-
function fulfill(value) { resume("next", value); }
|
|
131
|
-
function reject(value) { resume("throw", value); }
|
|
132
|
-
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
function __asyncValues(o) {
|
|
136
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
137
|
-
var m = o[Symbol.asyncIterator], i;
|
|
138
|
-
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);
|
|
139
|
-
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); }); }; }
|
|
140
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
const UNAUTHORIZED_USER = {
|
|
144
|
-
userId: "unauthorized",
|
|
145
|
-
name: "Unauthorized",
|
|
146
|
-
claims: {
|
|
147
|
-
sub: "unauthorized",
|
|
148
|
-
},
|
|
149
|
-
lastLogin: new Date(0)
|
|
150
|
-
};
|
|
151
|
-
try {
|
|
152
|
-
Object.freeze(UNAUTHORIZED_USER);
|
|
153
|
-
Object.freeze(UNAUTHORIZED_USER.claims);
|
|
154
|
-
}
|
|
155
|
-
catch (_a) { }
|
|
156
|
-
|
|
157
|
-
const swHolder = {};
|
|
158
|
-
const swContainer = typeof self !== 'undefined' && self.document && // self.document is to verify we're not the SW ourself
|
|
159
|
-
typeof navigator !== 'undefined' && navigator.serviceWorker;
|
|
160
|
-
if (swContainer)
|
|
161
|
-
swContainer.ready.then((registration) => (swHolder.registration = registration));
|
|
162
|
-
if (typeof self !== 'undefined' && 'clients' in self && !self.document) {
|
|
163
|
-
// We are the service worker. Propagate messages to all our clients.
|
|
164
|
-
addEventListener('message', (ev) => {
|
|
165
|
-
var _a, _b;
|
|
166
|
-
if ((_b = (_a = ev.data) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.startsWith('sw-broadcast-')) {
|
|
167
|
-
[...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); });
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
/** This class is a fallback for browsers that lacks BroadcastChannel but have
|
|
172
|
-
* service workers (which is Safari versions 11.1 through 15.3).
|
|
173
|
-
* Safari 15.4 with BroadcastChannel was released on 2022-03-14.
|
|
174
|
-
* We might be able to remove this class in a near future as Safari < 15.4 is
|
|
175
|
-
* already very low in market share as of 2023-03-10.
|
|
176
|
-
*/
|
|
177
|
-
class SWBroadcastChannel {
|
|
178
|
-
constructor(name) {
|
|
179
|
-
this.name = name;
|
|
180
|
-
}
|
|
181
|
-
subscribe(listener) {
|
|
182
|
-
if (!swContainer)
|
|
183
|
-
return () => { };
|
|
184
|
-
const forwarder = (ev) => {
|
|
185
|
-
var _a;
|
|
186
|
-
if (((_a = ev.data) === null || _a === void 0 ? void 0 : _a.type) === `sw-broadcast-${this.name}`) {
|
|
187
|
-
listener(ev.data.message);
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
swContainer.addEventListener('message', forwarder);
|
|
191
|
-
return () => swContainer.removeEventListener('message', forwarder);
|
|
192
|
-
}
|
|
193
|
-
postMessage(message) {
|
|
194
|
-
var _a;
|
|
195
|
-
if (typeof self['clients'] === 'object') {
|
|
196
|
-
// We're a service worker. Propagate to our browser clients.
|
|
197
|
-
[...self['clients'].matchAll({ includeUncontrolled: true })].forEach((client) => client.postMessage({
|
|
198
|
-
type: `sw-broadcast-${this.name}`,
|
|
199
|
-
message,
|
|
200
|
-
}));
|
|
201
|
-
}
|
|
202
|
-
else if (swHolder.registration) {
|
|
203
|
-
// We're a client (browser window or other worker)
|
|
204
|
-
// Post to SW so it can repost to all its clients and to itself
|
|
205
|
-
(_a = swHolder.registration.active) === null || _a === void 0 ? void 0 : _a.postMessage({
|
|
206
|
-
type: `sw-broadcast-${this.name}`,
|
|
207
|
-
message,
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
const events = globalThis['lbc-events'] || (globalThis['lbc-events'] = new Map());
|
|
214
|
-
function addListener(name, listener) {
|
|
215
|
-
if (events.has(name)) {
|
|
216
|
-
events.get(name).push(listener);
|
|
217
|
-
}
|
|
218
|
-
else {
|
|
219
|
-
events.set(name, [listener]);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
function removeListener(name, listener) {
|
|
223
|
-
const listeners = events.get(name);
|
|
224
|
-
if (listeners) {
|
|
225
|
-
const idx = listeners.indexOf(listener);
|
|
226
|
-
if (idx !== -1) {
|
|
227
|
-
listeners.splice(idx, 1);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
function dispatch(ev) {
|
|
232
|
-
const listeners = events.get(ev.type);
|
|
233
|
-
if (listeners) {
|
|
234
|
-
listeners.forEach(listener => {
|
|
235
|
-
try {
|
|
236
|
-
listener(ev);
|
|
237
|
-
}
|
|
238
|
-
catch (_a) {
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
class BroadcastedAndLocalEvent extends rxjs.Observable {
|
|
244
|
-
constructor(name) {
|
|
245
|
-
const bc = typeof BroadcastChannel === "undefined"
|
|
246
|
-
? new SWBroadcastChannel(name) : new BroadcastChannel(name);
|
|
247
|
-
super(subscriber => {
|
|
248
|
-
function onCustomEvent(ev) {
|
|
249
|
-
subscriber.next(ev.detail);
|
|
250
|
-
}
|
|
251
|
-
function onMessageEvent(ev) {
|
|
252
|
-
console.debug("BroadcastedAndLocalEvent: onMessageEvent", ev);
|
|
253
|
-
subscriber.next(ev.data);
|
|
254
|
-
}
|
|
255
|
-
let unsubscribe;
|
|
256
|
-
//self.addEventListener(`lbc-${name}`, onCustomEvent); // Fails in service workers
|
|
257
|
-
addListener(`lbc-${name}`, onCustomEvent); // Works better in service worker
|
|
258
|
-
try {
|
|
259
|
-
if (bc instanceof SWBroadcastChannel) {
|
|
260
|
-
unsubscribe = bc.subscribe(message => subscriber.next(message));
|
|
261
|
-
}
|
|
262
|
-
else {
|
|
263
|
-
console.debug("BroadcastedAndLocalEvent: bc.addEventListener()", name, "bc is a", bc);
|
|
264
|
-
bc.addEventListener("message", onMessageEvent);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
catch (err) {
|
|
268
|
-
// Service workers might fail to subscribe outside its initial script.
|
|
269
|
-
console.warn('Failed to subscribe to broadcast channel', err);
|
|
270
|
-
}
|
|
271
|
-
return () => {
|
|
272
|
-
//self.removeEventListener(`lbc-${name}`, onCustomEvent);
|
|
273
|
-
removeListener(`lbc-${name}`, onCustomEvent);
|
|
274
|
-
if (bc instanceof SWBroadcastChannel) {
|
|
275
|
-
unsubscribe();
|
|
276
|
-
}
|
|
277
|
-
else {
|
|
278
|
-
bc.removeEventListener("message", onMessageEvent);
|
|
279
|
-
}
|
|
280
|
-
};
|
|
281
|
-
});
|
|
282
|
-
this.name = name;
|
|
283
|
-
this.bc = bc;
|
|
284
|
-
}
|
|
285
|
-
next(message) {
|
|
286
|
-
console.debug("BroadcastedAndLocalEvent: bc.postMessage()", Object.assign({}, message), "bc is a", this.bc);
|
|
287
|
-
this.bc.postMessage(message);
|
|
288
|
-
const ev = new CustomEvent(`lbc-${this.name}`, { detail: message });
|
|
289
|
-
//self.dispatchEvent(ev);
|
|
290
|
-
dispatch(ev);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
function isFunction(value) {
|
|
295
|
-
return typeof value === 'function';
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
function hasLift(source) {
|
|
299
|
-
return isFunction(source === null || source === void 0 ? void 0 : source.lift);
|
|
300
|
-
}
|
|
301
|
-
function operate(init) {
|
|
302
|
-
return function (source) {
|
|
303
|
-
if (hasLift(source)) {
|
|
304
|
-
return source.lift(function (liftedSource) {
|
|
305
|
-
try {
|
|
306
|
-
return init(liftedSource, this);
|
|
307
|
-
}
|
|
308
|
-
catch (err) {
|
|
309
|
-
this.error(err);
|
|
310
|
-
}
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
throw new TypeError('Unable to lift unknown Observable type');
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
var isArrayLike = (function (x) { return x && typeof x.length === 'number' && typeof x !== 'function'; });
|
|
318
|
-
|
|
319
|
-
function isPromise(value) {
|
|
320
|
-
return isFunction(value === null || value === void 0 ? void 0 : value.then);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
function createErrorClass(createImpl) {
|
|
324
|
-
var _super = function (instance) {
|
|
325
|
-
Error.call(instance);
|
|
326
|
-
instance.stack = new Error().stack;
|
|
327
|
-
};
|
|
328
|
-
var ctorFunc = createImpl(_super);
|
|
329
|
-
ctorFunc.prototype = Object.create(Error.prototype);
|
|
330
|
-
ctorFunc.prototype.constructor = ctorFunc;
|
|
331
|
-
return ctorFunc;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
var UnsubscriptionError = createErrorClass(function (_super) {
|
|
335
|
-
return function UnsubscriptionErrorImpl(errors) {
|
|
336
|
-
_super(this);
|
|
337
|
-
this.message = errors
|
|
338
|
-
? errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n ')
|
|
339
|
-
: '';
|
|
340
|
-
this.name = 'UnsubscriptionError';
|
|
341
|
-
this.errors = errors;
|
|
342
|
-
};
|
|
343
|
-
});
|
|
344
|
-
|
|
345
|
-
function arrRemove(arr, item) {
|
|
346
|
-
if (arr) {
|
|
347
|
-
var index = arr.indexOf(item);
|
|
348
|
-
0 <= index && arr.splice(index, 1);
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
var Subscription = (function () {
|
|
353
|
-
function Subscription(initialTeardown) {
|
|
354
|
-
this.initialTeardown = initialTeardown;
|
|
355
|
-
this.closed = false;
|
|
356
|
-
this._parentage = null;
|
|
357
|
-
this._finalizers = null;
|
|
358
|
-
}
|
|
359
|
-
Subscription.prototype.unsubscribe = function () {
|
|
360
|
-
var e_1, _a, e_2, _b;
|
|
361
|
-
var errors;
|
|
362
|
-
if (!this.closed) {
|
|
363
|
-
this.closed = true;
|
|
364
|
-
var _parentage = this._parentage;
|
|
365
|
-
if (_parentage) {
|
|
366
|
-
this._parentage = null;
|
|
367
|
-
if (Array.isArray(_parentage)) {
|
|
368
|
-
try {
|
|
369
|
-
for (var _parentage_1 = __values(_parentage), _parentage_1_1 = _parentage_1.next(); !_parentage_1_1.done; _parentage_1_1 = _parentage_1.next()) {
|
|
370
|
-
var parent_1 = _parentage_1_1.value;
|
|
371
|
-
parent_1.remove(this);
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
375
|
-
finally {
|
|
376
|
-
try {
|
|
377
|
-
if (_parentage_1_1 && !_parentage_1_1.done && (_a = _parentage_1.return)) _a.call(_parentage_1);
|
|
378
|
-
}
|
|
379
|
-
finally { if (e_1) throw e_1.error; }
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
else {
|
|
383
|
-
_parentage.remove(this);
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
var initialFinalizer = this.initialTeardown;
|
|
387
|
-
if (isFunction(initialFinalizer)) {
|
|
388
|
-
try {
|
|
389
|
-
initialFinalizer();
|
|
390
|
-
}
|
|
391
|
-
catch (e) {
|
|
392
|
-
errors = e instanceof UnsubscriptionError ? e.errors : [e];
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
var _finalizers = this._finalizers;
|
|
396
|
-
if (_finalizers) {
|
|
397
|
-
this._finalizers = null;
|
|
398
|
-
try {
|
|
399
|
-
for (var _finalizers_1 = __values(_finalizers), _finalizers_1_1 = _finalizers_1.next(); !_finalizers_1_1.done; _finalizers_1_1 = _finalizers_1.next()) {
|
|
400
|
-
var finalizer = _finalizers_1_1.value;
|
|
401
|
-
try {
|
|
402
|
-
execFinalizer(finalizer);
|
|
403
|
-
}
|
|
404
|
-
catch (err) {
|
|
405
|
-
errors = errors !== null && errors !== void 0 ? errors : [];
|
|
406
|
-
if (err instanceof UnsubscriptionError) {
|
|
407
|
-
errors = __spreadArray(__spreadArray([], __read(errors)), __read(err.errors));
|
|
408
|
-
}
|
|
409
|
-
else {
|
|
410
|
-
errors.push(err);
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
416
|
-
finally {
|
|
417
|
-
try {
|
|
418
|
-
if (_finalizers_1_1 && !_finalizers_1_1.done && (_b = _finalizers_1.return)) _b.call(_finalizers_1);
|
|
419
|
-
}
|
|
420
|
-
finally { if (e_2) throw e_2.error; }
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
if (errors) {
|
|
424
|
-
throw new UnsubscriptionError(errors);
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
};
|
|
428
|
-
Subscription.prototype.add = function (teardown) {
|
|
429
|
-
var _a;
|
|
430
|
-
if (teardown && teardown !== this) {
|
|
431
|
-
if (this.closed) {
|
|
432
|
-
execFinalizer(teardown);
|
|
433
|
-
}
|
|
434
|
-
else {
|
|
435
|
-
if (teardown instanceof Subscription) {
|
|
436
|
-
if (teardown.closed || teardown._hasParent(this)) {
|
|
437
|
-
return;
|
|
438
|
-
}
|
|
439
|
-
teardown._addParent(this);
|
|
440
|
-
}
|
|
441
|
-
(this._finalizers = (_a = this._finalizers) !== null && _a !== void 0 ? _a : []).push(teardown);
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
};
|
|
445
|
-
Subscription.prototype._hasParent = function (parent) {
|
|
446
|
-
var _parentage = this._parentage;
|
|
447
|
-
return _parentage === parent || (Array.isArray(_parentage) && _parentage.includes(parent));
|
|
448
|
-
};
|
|
449
|
-
Subscription.prototype._addParent = function (parent) {
|
|
450
|
-
var _parentage = this._parentage;
|
|
451
|
-
this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent;
|
|
452
|
-
};
|
|
453
|
-
Subscription.prototype._removeParent = function (parent) {
|
|
454
|
-
var _parentage = this._parentage;
|
|
455
|
-
if (_parentage === parent) {
|
|
456
|
-
this._parentage = null;
|
|
457
|
-
}
|
|
458
|
-
else if (Array.isArray(_parentage)) {
|
|
459
|
-
arrRemove(_parentage, parent);
|
|
460
|
-
}
|
|
461
|
-
};
|
|
462
|
-
Subscription.prototype.remove = function (teardown) {
|
|
463
|
-
var _finalizers = this._finalizers;
|
|
464
|
-
_finalizers && arrRemove(_finalizers, teardown);
|
|
465
|
-
if (teardown instanceof Subscription) {
|
|
466
|
-
teardown._removeParent(this);
|
|
467
|
-
}
|
|
468
|
-
};
|
|
469
|
-
Subscription.EMPTY = (function () {
|
|
470
|
-
var empty = new Subscription();
|
|
471
|
-
empty.closed = true;
|
|
472
|
-
return empty;
|
|
473
|
-
})();
|
|
474
|
-
return Subscription;
|
|
475
|
-
}());
|
|
476
|
-
Subscription.EMPTY;
|
|
477
|
-
function isSubscription(value) {
|
|
478
|
-
return (value instanceof Subscription ||
|
|
479
|
-
(value && 'closed' in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe)));
|
|
480
|
-
}
|
|
481
|
-
function execFinalizer(finalizer) {
|
|
482
|
-
if (isFunction(finalizer)) {
|
|
483
|
-
finalizer();
|
|
484
|
-
}
|
|
485
|
-
else {
|
|
486
|
-
finalizer.unsubscribe();
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
var config = {
|
|
491
|
-
onUnhandledError: null,
|
|
492
|
-
onStoppedNotification: null,
|
|
493
|
-
Promise: undefined,
|
|
494
|
-
useDeprecatedSynchronousErrorHandling: false,
|
|
495
|
-
useDeprecatedNextContext: false,
|
|
496
|
-
};
|
|
497
|
-
|
|
498
|
-
var timeoutProvider = {
|
|
499
|
-
setTimeout: function (handler, timeout) {
|
|
500
|
-
var args = [];
|
|
501
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
502
|
-
args[_i - 2] = arguments[_i];
|
|
503
|
-
}
|
|
504
|
-
var delegate = timeoutProvider.delegate;
|
|
505
|
-
if (delegate === null || delegate === void 0 ? void 0 : delegate.setTimeout) {
|
|
506
|
-
return delegate.setTimeout.apply(delegate, __spreadArray([handler, timeout], __read(args)));
|
|
507
|
-
}
|
|
508
|
-
return setTimeout.apply(void 0, __spreadArray([handler, timeout], __read(args)));
|
|
509
|
-
},
|
|
510
|
-
clearTimeout: function (handle) {
|
|
511
|
-
var delegate = timeoutProvider.delegate;
|
|
512
|
-
return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearTimeout) || clearTimeout)(handle);
|
|
513
|
-
},
|
|
514
|
-
delegate: undefined,
|
|
515
|
-
};
|
|
516
|
-
|
|
517
|
-
function reportUnhandledError(err) {
|
|
518
|
-
timeoutProvider.setTimeout(function () {
|
|
519
|
-
var onUnhandledError = config.onUnhandledError;
|
|
520
|
-
if (onUnhandledError) {
|
|
521
|
-
onUnhandledError(err);
|
|
522
|
-
}
|
|
523
|
-
else {
|
|
524
|
-
throw err;
|
|
525
|
-
}
|
|
526
|
-
});
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
function noop() { }
|
|
530
|
-
|
|
531
|
-
var COMPLETE_NOTIFICATION = (function () { return createNotification('C', undefined, undefined); })();
|
|
532
|
-
function errorNotification(error) {
|
|
533
|
-
return createNotification('E', undefined, error);
|
|
534
|
-
}
|
|
535
|
-
function nextNotification(value) {
|
|
536
|
-
return createNotification('N', value, undefined);
|
|
537
|
-
}
|
|
538
|
-
function createNotification(kind, value, error) {
|
|
539
|
-
return {
|
|
540
|
-
kind: kind,
|
|
541
|
-
value: value,
|
|
542
|
-
error: error,
|
|
543
|
-
};
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
var context = null;
|
|
547
|
-
function errorContext(cb) {
|
|
548
|
-
if (config.useDeprecatedSynchronousErrorHandling) {
|
|
549
|
-
var isRoot = !context;
|
|
550
|
-
if (isRoot) {
|
|
551
|
-
context = { errorThrown: false, error: null };
|
|
552
|
-
}
|
|
553
|
-
cb();
|
|
554
|
-
if (isRoot) {
|
|
555
|
-
var _a = context, errorThrown = _a.errorThrown, error = _a.error;
|
|
556
|
-
context = null;
|
|
557
|
-
if (errorThrown) {
|
|
558
|
-
throw error;
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
else {
|
|
563
|
-
cb();
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
var Subscriber = (function (_super) {
|
|
568
|
-
__extends(Subscriber, _super);
|
|
569
|
-
function Subscriber(destination) {
|
|
570
|
-
var _this = _super.call(this) || this;
|
|
571
|
-
_this.isStopped = false;
|
|
572
|
-
if (destination) {
|
|
573
|
-
_this.destination = destination;
|
|
574
|
-
if (isSubscription(destination)) {
|
|
575
|
-
destination.add(_this);
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
else {
|
|
579
|
-
_this.destination = EMPTY_OBSERVER;
|
|
580
|
-
}
|
|
581
|
-
return _this;
|
|
582
|
-
}
|
|
583
|
-
Subscriber.create = function (next, error, complete) {
|
|
584
|
-
return new SafeSubscriber(next, error, complete);
|
|
585
|
-
};
|
|
586
|
-
Subscriber.prototype.next = function (value) {
|
|
587
|
-
if (this.isStopped) {
|
|
588
|
-
handleStoppedNotification(nextNotification(value), this);
|
|
589
|
-
}
|
|
590
|
-
else {
|
|
591
|
-
this._next(value);
|
|
592
|
-
}
|
|
593
|
-
};
|
|
594
|
-
Subscriber.prototype.error = function (err) {
|
|
595
|
-
if (this.isStopped) {
|
|
596
|
-
handleStoppedNotification(errorNotification(err), this);
|
|
597
|
-
}
|
|
598
|
-
else {
|
|
599
|
-
this.isStopped = true;
|
|
600
|
-
this._error(err);
|
|
601
|
-
}
|
|
602
|
-
};
|
|
603
|
-
Subscriber.prototype.complete = function () {
|
|
604
|
-
if (this.isStopped) {
|
|
605
|
-
handleStoppedNotification(COMPLETE_NOTIFICATION, this);
|
|
606
|
-
}
|
|
607
|
-
else {
|
|
608
|
-
this.isStopped = true;
|
|
609
|
-
this._complete();
|
|
610
|
-
}
|
|
611
|
-
};
|
|
612
|
-
Subscriber.prototype.unsubscribe = function () {
|
|
613
|
-
if (!this.closed) {
|
|
614
|
-
this.isStopped = true;
|
|
615
|
-
_super.prototype.unsubscribe.call(this);
|
|
616
|
-
this.destination = null;
|
|
617
|
-
}
|
|
618
|
-
};
|
|
619
|
-
Subscriber.prototype._next = function (value) {
|
|
620
|
-
this.destination.next(value);
|
|
621
|
-
};
|
|
622
|
-
Subscriber.prototype._error = function (err) {
|
|
623
|
-
try {
|
|
624
|
-
this.destination.error(err);
|
|
625
|
-
}
|
|
626
|
-
finally {
|
|
627
|
-
this.unsubscribe();
|
|
628
|
-
}
|
|
629
|
-
};
|
|
630
|
-
Subscriber.prototype._complete = function () {
|
|
631
|
-
try {
|
|
632
|
-
this.destination.complete();
|
|
633
|
-
}
|
|
634
|
-
finally {
|
|
635
|
-
this.unsubscribe();
|
|
636
|
-
}
|
|
637
|
-
};
|
|
638
|
-
return Subscriber;
|
|
639
|
-
}(Subscription));
|
|
640
|
-
var _bind = Function.prototype.bind;
|
|
641
|
-
function bind(fn, thisArg) {
|
|
642
|
-
return _bind.call(fn, thisArg);
|
|
643
|
-
}
|
|
644
|
-
var ConsumerObserver = (function () {
|
|
645
|
-
function ConsumerObserver(partialObserver) {
|
|
646
|
-
this.partialObserver = partialObserver;
|
|
647
|
-
}
|
|
648
|
-
ConsumerObserver.prototype.next = function (value) {
|
|
649
|
-
var partialObserver = this.partialObserver;
|
|
650
|
-
if (partialObserver.next) {
|
|
651
|
-
try {
|
|
652
|
-
partialObserver.next(value);
|
|
653
|
-
}
|
|
654
|
-
catch (error) {
|
|
655
|
-
handleUnhandledError(error);
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
};
|
|
659
|
-
ConsumerObserver.prototype.error = function (err) {
|
|
660
|
-
var partialObserver = this.partialObserver;
|
|
661
|
-
if (partialObserver.error) {
|
|
662
|
-
try {
|
|
663
|
-
partialObserver.error(err);
|
|
664
|
-
}
|
|
665
|
-
catch (error) {
|
|
666
|
-
handleUnhandledError(error);
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
else {
|
|
670
|
-
handleUnhandledError(err);
|
|
671
|
-
}
|
|
672
|
-
};
|
|
673
|
-
ConsumerObserver.prototype.complete = function () {
|
|
674
|
-
var partialObserver = this.partialObserver;
|
|
675
|
-
if (partialObserver.complete) {
|
|
676
|
-
try {
|
|
677
|
-
partialObserver.complete();
|
|
678
|
-
}
|
|
679
|
-
catch (error) {
|
|
680
|
-
handleUnhandledError(error);
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
};
|
|
684
|
-
return ConsumerObserver;
|
|
685
|
-
}());
|
|
686
|
-
var SafeSubscriber = (function (_super) {
|
|
687
|
-
__extends(SafeSubscriber, _super);
|
|
688
|
-
function SafeSubscriber(observerOrNext, error, complete) {
|
|
689
|
-
var _this = _super.call(this) || this;
|
|
690
|
-
var partialObserver;
|
|
691
|
-
if (isFunction(observerOrNext) || !observerOrNext) {
|
|
692
|
-
partialObserver = {
|
|
693
|
-
next: (observerOrNext !== null && observerOrNext !== void 0 ? observerOrNext : undefined),
|
|
694
|
-
error: error !== null && error !== void 0 ? error : undefined,
|
|
695
|
-
complete: complete !== null && complete !== void 0 ? complete : undefined,
|
|
696
|
-
};
|
|
697
|
-
}
|
|
698
|
-
else {
|
|
699
|
-
var context_1;
|
|
700
|
-
if (_this && config.useDeprecatedNextContext) {
|
|
701
|
-
context_1 = Object.create(observerOrNext);
|
|
702
|
-
context_1.unsubscribe = function () { return _this.unsubscribe(); };
|
|
703
|
-
partialObserver = {
|
|
704
|
-
next: observerOrNext.next && bind(observerOrNext.next, context_1),
|
|
705
|
-
error: observerOrNext.error && bind(observerOrNext.error, context_1),
|
|
706
|
-
complete: observerOrNext.complete && bind(observerOrNext.complete, context_1),
|
|
707
|
-
};
|
|
708
|
-
}
|
|
709
|
-
else {
|
|
710
|
-
partialObserver = observerOrNext;
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
_this.destination = new ConsumerObserver(partialObserver);
|
|
714
|
-
return _this;
|
|
715
|
-
}
|
|
716
|
-
return SafeSubscriber;
|
|
717
|
-
}(Subscriber));
|
|
718
|
-
function handleUnhandledError(error) {
|
|
719
|
-
{
|
|
720
|
-
reportUnhandledError(error);
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
function defaultErrorHandler(err) {
|
|
724
|
-
throw err;
|
|
725
|
-
}
|
|
726
|
-
function handleStoppedNotification(notification, subscriber) {
|
|
727
|
-
var onStoppedNotification = config.onStoppedNotification;
|
|
728
|
-
onStoppedNotification && timeoutProvider.setTimeout(function () { return onStoppedNotification(notification, subscriber); });
|
|
729
|
-
}
|
|
730
|
-
var EMPTY_OBSERVER = {
|
|
731
|
-
closed: true,
|
|
732
|
-
next: noop,
|
|
733
|
-
error: defaultErrorHandler,
|
|
734
|
-
complete: noop,
|
|
735
|
-
};
|
|
736
|
-
|
|
737
|
-
var observable = (function () { return (typeof Symbol === 'function' && Symbol.observable) || '@@observable'; })();
|
|
738
|
-
|
|
739
|
-
function identity(x) {
|
|
740
|
-
return x;
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
function pipeFromArray(fns) {
|
|
744
|
-
if (fns.length === 0) {
|
|
745
|
-
return identity;
|
|
746
|
-
}
|
|
747
|
-
if (fns.length === 1) {
|
|
748
|
-
return fns[0];
|
|
749
|
-
}
|
|
750
|
-
return function piped(input) {
|
|
751
|
-
return fns.reduce(function (prev, fn) { return fn(prev); }, input);
|
|
752
|
-
};
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
var Observable = (function () {
|
|
756
|
-
function Observable(subscribe) {
|
|
757
|
-
if (subscribe) {
|
|
758
|
-
this._subscribe = subscribe;
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
Observable.prototype.lift = function (operator) {
|
|
762
|
-
var observable = new Observable();
|
|
763
|
-
observable.source = this;
|
|
764
|
-
observable.operator = operator;
|
|
765
|
-
return observable;
|
|
766
|
-
};
|
|
767
|
-
Observable.prototype.subscribe = function (observerOrNext, error, complete) {
|
|
768
|
-
var _this = this;
|
|
769
|
-
var subscriber = isSubscriber(observerOrNext) ? observerOrNext : new SafeSubscriber(observerOrNext, error, complete);
|
|
770
|
-
errorContext(function () {
|
|
771
|
-
var _a = _this, operator = _a.operator, source = _a.source;
|
|
772
|
-
subscriber.add(operator
|
|
773
|
-
?
|
|
774
|
-
operator.call(subscriber, source)
|
|
775
|
-
: source
|
|
776
|
-
?
|
|
777
|
-
_this._subscribe(subscriber)
|
|
778
|
-
:
|
|
779
|
-
_this._trySubscribe(subscriber));
|
|
780
|
-
});
|
|
781
|
-
return subscriber;
|
|
782
|
-
};
|
|
783
|
-
Observable.prototype._trySubscribe = function (sink) {
|
|
784
|
-
try {
|
|
785
|
-
return this._subscribe(sink);
|
|
786
|
-
}
|
|
787
|
-
catch (err) {
|
|
788
|
-
sink.error(err);
|
|
789
|
-
}
|
|
790
|
-
};
|
|
791
|
-
Observable.prototype.forEach = function (next, promiseCtor) {
|
|
792
|
-
var _this = this;
|
|
793
|
-
promiseCtor = getPromiseCtor(promiseCtor);
|
|
794
|
-
return new promiseCtor(function (resolve, reject) {
|
|
795
|
-
var subscriber = new SafeSubscriber({
|
|
796
|
-
next: function (value) {
|
|
797
|
-
try {
|
|
798
|
-
next(value);
|
|
799
|
-
}
|
|
800
|
-
catch (err) {
|
|
801
|
-
reject(err);
|
|
802
|
-
subscriber.unsubscribe();
|
|
803
|
-
}
|
|
804
|
-
},
|
|
805
|
-
error: reject,
|
|
806
|
-
complete: resolve,
|
|
807
|
-
});
|
|
808
|
-
_this.subscribe(subscriber);
|
|
809
|
-
});
|
|
810
|
-
};
|
|
811
|
-
Observable.prototype._subscribe = function (subscriber) {
|
|
812
|
-
var _a;
|
|
813
|
-
return (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber);
|
|
814
|
-
};
|
|
815
|
-
Observable.prototype[observable] = function () {
|
|
816
|
-
return this;
|
|
817
|
-
};
|
|
818
|
-
Observable.prototype.pipe = function () {
|
|
819
|
-
var operations = [];
|
|
820
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
821
|
-
operations[_i] = arguments[_i];
|
|
822
|
-
}
|
|
823
|
-
return pipeFromArray(operations)(this);
|
|
824
|
-
};
|
|
825
|
-
Observable.prototype.toPromise = function (promiseCtor) {
|
|
826
|
-
var _this = this;
|
|
827
|
-
promiseCtor = getPromiseCtor(promiseCtor);
|
|
828
|
-
return new promiseCtor(function (resolve, reject) {
|
|
829
|
-
var value;
|
|
830
|
-
_this.subscribe(function (x) { return (value = x); }, function (err) { return reject(err); }, function () { return resolve(value); });
|
|
831
|
-
});
|
|
832
|
-
};
|
|
833
|
-
Observable.create = function (subscribe) {
|
|
834
|
-
return new Observable(subscribe);
|
|
835
|
-
};
|
|
836
|
-
return Observable;
|
|
837
|
-
}());
|
|
838
|
-
function getPromiseCtor(promiseCtor) {
|
|
839
|
-
var _a;
|
|
840
|
-
return (_a = promiseCtor !== null && promiseCtor !== void 0 ? promiseCtor : config.Promise) !== null && _a !== void 0 ? _a : Promise;
|
|
841
|
-
}
|
|
842
|
-
function isObserver(value) {
|
|
843
|
-
return value && isFunction(value.next) && isFunction(value.error) && isFunction(value.complete);
|
|
844
|
-
}
|
|
845
|
-
function isSubscriber(value) {
|
|
846
|
-
return (value && value instanceof Subscriber) || (isObserver(value) && isSubscription(value));
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
function isInteropObservable(input) {
|
|
850
|
-
return isFunction(input[observable]);
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
function isAsyncIterable(obj) {
|
|
854
|
-
return Symbol.asyncIterator && isFunction(obj === null || obj === void 0 ? void 0 : obj[Symbol.asyncIterator]);
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
function createInvalidObservableTypeError(input) {
|
|
858
|
-
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.");
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
function getSymbolIterator() {
|
|
862
|
-
if (typeof Symbol !== 'function' || !Symbol.iterator) {
|
|
863
|
-
return '@@iterator';
|
|
864
|
-
}
|
|
865
|
-
return Symbol.iterator;
|
|
866
|
-
}
|
|
867
|
-
var iterator = getSymbolIterator();
|
|
868
|
-
|
|
869
|
-
function isIterable(input) {
|
|
870
|
-
return isFunction(input === null || input === void 0 ? void 0 : input[iterator]);
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
function readableStreamLikeToAsyncGenerator(readableStream) {
|
|
874
|
-
return __asyncGenerator(this, arguments, function readableStreamLikeToAsyncGenerator_1() {
|
|
875
|
-
var reader, _a, value, done;
|
|
876
|
-
return __generator(this, function (_b) {
|
|
877
|
-
switch (_b.label) {
|
|
878
|
-
case 0:
|
|
879
|
-
reader = readableStream.getReader();
|
|
880
|
-
_b.label = 1;
|
|
881
|
-
case 1:
|
|
882
|
-
_b.trys.push([1, , 9, 10]);
|
|
883
|
-
_b.label = 2;
|
|
884
|
-
case 2:
|
|
885
|
-
return [4, __await(reader.read())];
|
|
886
|
-
case 3:
|
|
887
|
-
_a = _b.sent(), value = _a.value, done = _a.done;
|
|
888
|
-
if (!done) return [3, 5];
|
|
889
|
-
return [4, __await(void 0)];
|
|
890
|
-
case 4: return [2, _b.sent()];
|
|
891
|
-
case 5: return [4, __await(value)];
|
|
892
|
-
case 6: return [4, _b.sent()];
|
|
893
|
-
case 7:
|
|
894
|
-
_b.sent();
|
|
895
|
-
return [3, 2];
|
|
896
|
-
case 8: return [3, 10];
|
|
897
|
-
case 9:
|
|
898
|
-
reader.releaseLock();
|
|
899
|
-
return [7];
|
|
900
|
-
case 10: return [2];
|
|
901
|
-
}
|
|
902
|
-
});
|
|
903
|
-
});
|
|
904
|
-
}
|
|
905
|
-
function isReadableStreamLike(obj) {
|
|
906
|
-
return isFunction(obj === null || obj === void 0 ? void 0 : obj.getReader);
|
|
907
|
-
}
|
|
908
|
-
|
|
909
|
-
function innerFrom(input) {
|
|
910
|
-
if (input instanceof Observable) {
|
|
911
|
-
return input;
|
|
912
|
-
}
|
|
913
|
-
if (input != null) {
|
|
914
|
-
if (isInteropObservable(input)) {
|
|
915
|
-
return fromInteropObservable(input);
|
|
916
|
-
}
|
|
917
|
-
if (isArrayLike(input)) {
|
|
918
|
-
return fromArrayLike(input);
|
|
919
|
-
}
|
|
920
|
-
if (isPromise(input)) {
|
|
921
|
-
return fromPromise(input);
|
|
922
|
-
}
|
|
923
|
-
if (isAsyncIterable(input)) {
|
|
924
|
-
return fromAsyncIterable(input);
|
|
925
|
-
}
|
|
926
|
-
if (isIterable(input)) {
|
|
927
|
-
return fromIterable(input);
|
|
928
|
-
}
|
|
929
|
-
if (isReadableStreamLike(input)) {
|
|
930
|
-
return fromReadableStreamLike(input);
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
throw createInvalidObservableTypeError(input);
|
|
934
|
-
}
|
|
935
|
-
function fromInteropObservable(obj) {
|
|
936
|
-
return new Observable(function (subscriber) {
|
|
937
|
-
var obs = obj[observable]();
|
|
938
|
-
if (isFunction(obs.subscribe)) {
|
|
939
|
-
return obs.subscribe(subscriber);
|
|
940
|
-
}
|
|
941
|
-
throw new TypeError('Provided object does not correctly implement Symbol.observable');
|
|
942
|
-
});
|
|
943
|
-
}
|
|
944
|
-
function fromArrayLike(array) {
|
|
945
|
-
return new Observable(function (subscriber) {
|
|
946
|
-
for (var i = 0; i < array.length && !subscriber.closed; i++) {
|
|
947
|
-
subscriber.next(array[i]);
|
|
948
|
-
}
|
|
949
|
-
subscriber.complete();
|
|
950
|
-
});
|
|
951
|
-
}
|
|
952
|
-
function fromPromise(promise) {
|
|
953
|
-
return new Observable(function (subscriber) {
|
|
954
|
-
promise
|
|
955
|
-
.then(function (value) {
|
|
956
|
-
if (!subscriber.closed) {
|
|
957
|
-
subscriber.next(value);
|
|
958
|
-
subscriber.complete();
|
|
959
|
-
}
|
|
960
|
-
}, function (err) { return subscriber.error(err); })
|
|
961
|
-
.then(null, reportUnhandledError);
|
|
962
|
-
});
|
|
963
|
-
}
|
|
964
|
-
function fromIterable(iterable) {
|
|
965
|
-
return new Observable(function (subscriber) {
|
|
966
|
-
var e_1, _a;
|
|
967
|
-
try {
|
|
968
|
-
for (var iterable_1 = __values(iterable), iterable_1_1 = iterable_1.next(); !iterable_1_1.done; iterable_1_1 = iterable_1.next()) {
|
|
969
|
-
var value = iterable_1_1.value;
|
|
970
|
-
subscriber.next(value);
|
|
971
|
-
if (subscriber.closed) {
|
|
972
|
-
return;
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
977
|
-
finally {
|
|
978
|
-
try {
|
|
979
|
-
if (iterable_1_1 && !iterable_1_1.done && (_a = iterable_1.return)) _a.call(iterable_1);
|
|
980
|
-
}
|
|
981
|
-
finally { if (e_1) throw e_1.error; }
|
|
982
|
-
}
|
|
983
|
-
subscriber.complete();
|
|
984
|
-
});
|
|
985
|
-
}
|
|
986
|
-
function fromAsyncIterable(asyncIterable) {
|
|
987
|
-
return new Observable(function (subscriber) {
|
|
988
|
-
process(asyncIterable, subscriber).catch(function (err) { return subscriber.error(err); });
|
|
989
|
-
});
|
|
990
|
-
}
|
|
991
|
-
function fromReadableStreamLike(readableStream) {
|
|
992
|
-
return fromAsyncIterable(readableStreamLikeToAsyncGenerator(readableStream));
|
|
993
|
-
}
|
|
994
|
-
function process(asyncIterable, subscriber) {
|
|
995
|
-
var asyncIterable_1, asyncIterable_1_1;
|
|
996
|
-
var e_2, _a;
|
|
997
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
998
|
-
var value, e_2_1;
|
|
999
|
-
return __generator(this, function (_b) {
|
|
1000
|
-
switch (_b.label) {
|
|
1001
|
-
case 0:
|
|
1002
|
-
_b.trys.push([0, 5, 6, 11]);
|
|
1003
|
-
asyncIterable_1 = __asyncValues(asyncIterable);
|
|
1004
|
-
_b.label = 1;
|
|
1005
|
-
case 1: return [4, asyncIterable_1.next()];
|
|
1006
|
-
case 2:
|
|
1007
|
-
if (!(asyncIterable_1_1 = _b.sent(), !asyncIterable_1_1.done)) return [3, 4];
|
|
1008
|
-
value = asyncIterable_1_1.value;
|
|
1009
|
-
subscriber.next(value);
|
|
1010
|
-
if (subscriber.closed) {
|
|
1011
|
-
return [2];
|
|
1012
|
-
}
|
|
1013
|
-
_b.label = 3;
|
|
1014
|
-
case 3: return [3, 1];
|
|
1015
|
-
case 4: return [3, 11];
|
|
1016
|
-
case 5:
|
|
1017
|
-
e_2_1 = _b.sent();
|
|
1018
|
-
e_2 = { error: e_2_1 };
|
|
1019
|
-
return [3, 11];
|
|
1020
|
-
case 6:
|
|
1021
|
-
_b.trys.push([6, , 9, 10]);
|
|
1022
|
-
if (!(asyncIterable_1_1 && !asyncIterable_1_1.done && (_a = asyncIterable_1.return))) return [3, 8];
|
|
1023
|
-
return [4, _a.call(asyncIterable_1)];
|
|
1024
|
-
case 7:
|
|
1025
|
-
_b.sent();
|
|
1026
|
-
_b.label = 8;
|
|
1027
|
-
case 8: return [3, 10];
|
|
1028
|
-
case 9:
|
|
1029
|
-
if (e_2) throw e_2.error;
|
|
1030
|
-
return [7];
|
|
1031
|
-
case 10: return [7];
|
|
1032
|
-
case 11:
|
|
1033
|
-
subscriber.complete();
|
|
1034
|
-
return [2];
|
|
1035
|
-
}
|
|
1036
|
-
});
|
|
1037
|
-
});
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
|
-
function createOperatorSubscriber(destination, onNext, onComplete, onError, onFinalize) {
|
|
1041
|
-
return new OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize);
|
|
1042
|
-
}
|
|
1043
|
-
var OperatorSubscriber = (function (_super) {
|
|
1044
|
-
__extends(OperatorSubscriber, _super);
|
|
1045
|
-
function OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize, shouldUnsubscribe) {
|
|
1046
|
-
var _this = _super.call(this, destination) || this;
|
|
1047
|
-
_this.onFinalize = onFinalize;
|
|
1048
|
-
_this.shouldUnsubscribe = shouldUnsubscribe;
|
|
1049
|
-
_this._next = onNext
|
|
1050
|
-
? function (value) {
|
|
1051
|
-
try {
|
|
1052
|
-
onNext(value);
|
|
1053
|
-
}
|
|
1054
|
-
catch (err) {
|
|
1055
|
-
destination.error(err);
|
|
1056
|
-
}
|
|
1057
|
-
}
|
|
1058
|
-
: _super.prototype._next;
|
|
1059
|
-
_this._error = onError
|
|
1060
|
-
? function (err) {
|
|
1061
|
-
try {
|
|
1062
|
-
onError(err);
|
|
1063
|
-
}
|
|
1064
|
-
catch (err) {
|
|
1065
|
-
destination.error(err);
|
|
1066
|
-
}
|
|
1067
|
-
finally {
|
|
1068
|
-
this.unsubscribe();
|
|
1069
|
-
}
|
|
1070
|
-
}
|
|
1071
|
-
: _super.prototype._error;
|
|
1072
|
-
_this._complete = onComplete
|
|
1073
|
-
? function () {
|
|
1074
|
-
try {
|
|
1075
|
-
onComplete();
|
|
1076
|
-
}
|
|
1077
|
-
catch (err) {
|
|
1078
|
-
destination.error(err);
|
|
1079
|
-
}
|
|
1080
|
-
finally {
|
|
1081
|
-
this.unsubscribe();
|
|
1082
|
-
}
|
|
1083
|
-
}
|
|
1084
|
-
: _super.prototype._complete;
|
|
1085
|
-
return _this;
|
|
1086
|
-
}
|
|
1087
|
-
OperatorSubscriber.prototype.unsubscribe = function () {
|
|
1088
|
-
var _a;
|
|
1089
|
-
if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {
|
|
1090
|
-
var closed_1 = this.closed;
|
|
1091
|
-
_super.prototype.unsubscribe.call(this);
|
|
1092
|
-
!closed_1 && ((_a = this.onFinalize) === null || _a === void 0 ? void 0 : _a.call(this));
|
|
1093
|
-
}
|
|
1094
|
-
};
|
|
1095
|
-
return OperatorSubscriber;
|
|
1096
|
-
}(Subscriber));
|
|
1097
|
-
|
|
1098
|
-
var Action = (function (_super) {
|
|
1099
|
-
__extends(Action, _super);
|
|
1100
|
-
function Action(scheduler, work) {
|
|
1101
|
-
return _super.call(this) || this;
|
|
1102
|
-
}
|
|
1103
|
-
Action.prototype.schedule = function (state, delay) {
|
|
1104
|
-
return this;
|
|
1105
|
-
};
|
|
1106
|
-
return Action;
|
|
1107
|
-
}(Subscription));
|
|
1108
|
-
|
|
1109
|
-
var intervalProvider = {
|
|
1110
|
-
setInterval: function (handler, timeout) {
|
|
1111
|
-
var args = [];
|
|
1112
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1113
|
-
args[_i - 2] = arguments[_i];
|
|
1114
|
-
}
|
|
1115
|
-
var delegate = intervalProvider.delegate;
|
|
1116
|
-
if (delegate === null || delegate === void 0 ? void 0 : delegate.setInterval) {
|
|
1117
|
-
return delegate.setInterval.apply(delegate, __spreadArray([handler, timeout], __read(args)));
|
|
1118
|
-
}
|
|
1119
|
-
return setInterval.apply(void 0, __spreadArray([handler, timeout], __read(args)));
|
|
1120
|
-
},
|
|
1121
|
-
clearInterval: function (handle) {
|
|
1122
|
-
var delegate = intervalProvider.delegate;
|
|
1123
|
-
return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearInterval) || clearInterval)(handle);
|
|
1124
|
-
},
|
|
1125
|
-
delegate: undefined,
|
|
1126
|
-
};
|
|
1127
|
-
|
|
1128
|
-
var AsyncAction = (function (_super) {
|
|
1129
|
-
__extends(AsyncAction, _super);
|
|
1130
|
-
function AsyncAction(scheduler, work) {
|
|
1131
|
-
var _this = _super.call(this, scheduler, work) || this;
|
|
1132
|
-
_this.scheduler = scheduler;
|
|
1133
|
-
_this.work = work;
|
|
1134
|
-
_this.pending = false;
|
|
1135
|
-
return _this;
|
|
1136
|
-
}
|
|
1137
|
-
AsyncAction.prototype.schedule = function (state, delay) {
|
|
1138
|
-
if (delay === void 0) { delay = 0; }
|
|
1139
|
-
if (this.closed) {
|
|
1140
|
-
return this;
|
|
1141
|
-
}
|
|
1142
|
-
this.state = state;
|
|
1143
|
-
var id = this.id;
|
|
1144
|
-
var scheduler = this.scheduler;
|
|
1145
|
-
if (id != null) {
|
|
1146
|
-
this.id = this.recycleAsyncId(scheduler, id, delay);
|
|
1147
|
-
}
|
|
1148
|
-
this.pending = true;
|
|
1149
|
-
this.delay = delay;
|
|
1150
|
-
this.id = this.id || this.requestAsyncId(scheduler, this.id, delay);
|
|
1151
|
-
return this;
|
|
1152
|
-
};
|
|
1153
|
-
AsyncAction.prototype.requestAsyncId = function (scheduler, _id, delay) {
|
|
1154
|
-
if (delay === void 0) { delay = 0; }
|
|
1155
|
-
return intervalProvider.setInterval(scheduler.flush.bind(scheduler, this), delay);
|
|
1156
|
-
};
|
|
1157
|
-
AsyncAction.prototype.recycleAsyncId = function (_scheduler, id, delay) {
|
|
1158
|
-
if (delay === void 0) { delay = 0; }
|
|
1159
|
-
if (delay != null && this.delay === delay && this.pending === false) {
|
|
1160
|
-
return id;
|
|
1161
|
-
}
|
|
1162
|
-
intervalProvider.clearInterval(id);
|
|
1163
|
-
return undefined;
|
|
1164
|
-
};
|
|
1165
|
-
AsyncAction.prototype.execute = function (state, delay) {
|
|
1166
|
-
if (this.closed) {
|
|
1167
|
-
return new Error('executing a cancelled action');
|
|
1168
|
-
}
|
|
1169
|
-
this.pending = false;
|
|
1170
|
-
var error = this._execute(state, delay);
|
|
1171
|
-
if (error) {
|
|
1172
|
-
return error;
|
|
1173
|
-
}
|
|
1174
|
-
else if (this.pending === false && this.id != null) {
|
|
1175
|
-
this.id = this.recycleAsyncId(this.scheduler, this.id, null);
|
|
1176
|
-
}
|
|
1177
|
-
};
|
|
1178
|
-
AsyncAction.prototype._execute = function (state, _delay) {
|
|
1179
|
-
var errored = false;
|
|
1180
|
-
var errorValue;
|
|
1181
|
-
try {
|
|
1182
|
-
this.work(state);
|
|
1183
|
-
}
|
|
1184
|
-
catch (e) {
|
|
1185
|
-
errored = true;
|
|
1186
|
-
errorValue = e ? e : new Error('Scheduled action threw falsy error');
|
|
1187
|
-
}
|
|
1188
|
-
if (errored) {
|
|
1189
|
-
this.unsubscribe();
|
|
1190
|
-
return errorValue;
|
|
1191
|
-
}
|
|
1192
|
-
};
|
|
1193
|
-
AsyncAction.prototype.unsubscribe = function () {
|
|
1194
|
-
if (!this.closed) {
|
|
1195
|
-
var _a = this, id = _a.id, scheduler = _a.scheduler;
|
|
1196
|
-
var actions = scheduler.actions;
|
|
1197
|
-
this.work = this.state = this.scheduler = null;
|
|
1198
|
-
this.pending = false;
|
|
1199
|
-
arrRemove(actions, this);
|
|
1200
|
-
if (id != null) {
|
|
1201
|
-
this.id = this.recycleAsyncId(scheduler, id, null);
|
|
1202
|
-
}
|
|
1203
|
-
this.delay = null;
|
|
1204
|
-
_super.prototype.unsubscribe.call(this);
|
|
1205
|
-
}
|
|
1206
|
-
};
|
|
1207
|
-
return AsyncAction;
|
|
1208
|
-
}(Action));
|
|
1209
|
-
|
|
1210
|
-
var dateTimestampProvider = {
|
|
1211
|
-
now: function () {
|
|
1212
|
-
return (dateTimestampProvider.delegate || Date).now();
|
|
1213
|
-
},
|
|
1214
|
-
delegate: undefined,
|
|
1215
|
-
};
|
|
1216
|
-
|
|
1217
|
-
var Scheduler = (function () {
|
|
1218
|
-
function Scheduler(schedulerActionCtor, now) {
|
|
1219
|
-
if (now === void 0) { now = Scheduler.now; }
|
|
1220
|
-
this.schedulerActionCtor = schedulerActionCtor;
|
|
1221
|
-
this.now = now;
|
|
1222
|
-
}
|
|
1223
|
-
Scheduler.prototype.schedule = function (work, delay, state) {
|
|
1224
|
-
if (delay === void 0) { delay = 0; }
|
|
1225
|
-
return new this.schedulerActionCtor(this, work).schedule(state, delay);
|
|
1226
|
-
};
|
|
1227
|
-
Scheduler.now = dateTimestampProvider.now;
|
|
1228
|
-
return Scheduler;
|
|
1229
|
-
}());
|
|
1230
|
-
|
|
1231
|
-
var AsyncScheduler = (function (_super) {
|
|
1232
|
-
__extends(AsyncScheduler, _super);
|
|
1233
|
-
function AsyncScheduler(SchedulerAction, now) {
|
|
1234
|
-
if (now === void 0) { now = Scheduler.now; }
|
|
1235
|
-
var _this = _super.call(this, SchedulerAction, now) || this;
|
|
1236
|
-
_this.actions = [];
|
|
1237
|
-
_this._active = false;
|
|
1238
|
-
_this._scheduled = undefined;
|
|
1239
|
-
return _this;
|
|
1240
|
-
}
|
|
1241
|
-
AsyncScheduler.prototype.flush = function (action) {
|
|
1242
|
-
var actions = this.actions;
|
|
1243
|
-
if (this._active) {
|
|
1244
|
-
actions.push(action);
|
|
1245
|
-
return;
|
|
1246
|
-
}
|
|
1247
|
-
var error;
|
|
1248
|
-
this._active = true;
|
|
1249
|
-
do {
|
|
1250
|
-
if ((error = action.execute(action.state, action.delay))) {
|
|
1251
|
-
break;
|
|
1252
|
-
}
|
|
1253
|
-
} while ((action = actions.shift()));
|
|
1254
|
-
this._active = false;
|
|
1255
|
-
if (error) {
|
|
1256
|
-
while ((action = actions.shift())) {
|
|
1257
|
-
action.unsubscribe();
|
|
1258
|
-
}
|
|
1259
|
-
throw error;
|
|
1260
|
-
}
|
|
1261
|
-
};
|
|
1262
|
-
return AsyncScheduler;
|
|
1263
|
-
}(Scheduler));
|
|
1264
|
-
|
|
1265
|
-
var asyncScheduler = new AsyncScheduler(AsyncAction);
|
|
1266
|
-
var async = asyncScheduler;
|
|
1267
|
-
|
|
1268
|
-
function isScheduler(value) {
|
|
1269
|
-
return value && isFunction(value.schedule);
|
|
1270
|
-
}
|
|
1271
|
-
|
|
1272
|
-
function isValidDate(value) {
|
|
1273
|
-
return value instanceof Date && !isNaN(value);
|
|
1274
|
-
}
|
|
1275
|
-
|
|
1276
|
-
function timer(dueTime, intervalOrScheduler, scheduler) {
|
|
1277
|
-
if (dueTime === void 0) { dueTime = 0; }
|
|
1278
|
-
if (scheduler === void 0) { scheduler = async; }
|
|
1279
|
-
var intervalDuration = -1;
|
|
1280
|
-
if (intervalOrScheduler != null) {
|
|
1281
|
-
if (isScheduler(intervalOrScheduler)) {
|
|
1282
|
-
scheduler = intervalOrScheduler;
|
|
1283
|
-
}
|
|
1284
|
-
else {
|
|
1285
|
-
intervalDuration = intervalOrScheduler;
|
|
1286
|
-
}
|
|
1287
|
-
}
|
|
1288
|
-
return new Observable(function (subscriber) {
|
|
1289
|
-
var due = isValidDate(dueTime) ? +dueTime - scheduler.now() : dueTime;
|
|
1290
|
-
if (due < 0) {
|
|
1291
|
-
due = 0;
|
|
1292
|
-
}
|
|
1293
|
-
var n = 0;
|
|
1294
|
-
return scheduler.schedule(function () {
|
|
1295
|
-
if (!subscriber.closed) {
|
|
1296
|
-
subscriber.next(n++);
|
|
1297
|
-
if (0 <= intervalDuration) {
|
|
1298
|
-
this.schedule(undefined, intervalDuration);
|
|
1299
|
-
}
|
|
1300
|
-
else {
|
|
1301
|
-
subscriber.complete();
|
|
1302
|
-
}
|
|
1303
|
-
}
|
|
1304
|
-
}, due);
|
|
1305
|
-
});
|
|
1306
|
-
}
|
|
1307
|
-
|
|
1308
|
-
function last(arr) {
|
|
1309
|
-
return arr[arr.length - 1];
|
|
1310
|
-
}
|
|
1311
|
-
function popScheduler(args) {
|
|
1312
|
-
return isScheduler(last(args)) ? args.pop() : undefined;
|
|
1313
|
-
}
|
|
1314
|
-
|
|
1315
|
-
function executeSchedule(parentSubscription, scheduler, work, delay, repeat) {
|
|
1316
|
-
if (delay === void 0) { delay = 0; }
|
|
1317
|
-
if (repeat === void 0) { repeat = false; }
|
|
1318
|
-
var scheduleSubscription = scheduler.schedule(function () {
|
|
1319
|
-
work();
|
|
1320
|
-
if (repeat) {
|
|
1321
|
-
parentSubscription.add(this.schedule(null, delay));
|
|
1322
|
-
}
|
|
1323
|
-
else {
|
|
1324
|
-
this.unsubscribe();
|
|
1325
|
-
}
|
|
1326
|
-
}, delay);
|
|
1327
|
-
parentSubscription.add(scheduleSubscription);
|
|
1328
|
-
if (!repeat) {
|
|
1329
|
-
return scheduleSubscription;
|
|
1330
|
-
}
|
|
1331
|
-
}
|
|
1332
|
-
|
|
1333
|
-
function catchError(selector) {
|
|
1334
|
-
return operate(function (source, subscriber) {
|
|
1335
|
-
var innerSub = null;
|
|
1336
|
-
var syncUnsub = false;
|
|
1337
|
-
var handledResult;
|
|
1338
|
-
innerSub = source.subscribe(createOperatorSubscriber(subscriber, undefined, undefined, function (err) {
|
|
1339
|
-
handledResult = innerFrom(selector(err, catchError(selector)(source)));
|
|
1340
|
-
if (innerSub) {
|
|
1341
|
-
innerSub.unsubscribe();
|
|
1342
|
-
innerSub = null;
|
|
1343
|
-
handledResult.subscribe(subscriber);
|
|
1344
|
-
}
|
|
1345
|
-
else {
|
|
1346
|
-
syncUnsub = true;
|
|
1347
|
-
}
|
|
1348
|
-
}));
|
|
1349
|
-
if (syncUnsub) {
|
|
1350
|
-
innerSub.unsubscribe();
|
|
1351
|
-
innerSub = null;
|
|
1352
|
-
handledResult.subscribe(subscriber);
|
|
1353
|
-
}
|
|
1354
|
-
});
|
|
33
|
+
});
|
|
1355
34
|
}
|
|
1356
35
|
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
36
|
+
const UNAUTHORIZED_USER = {
|
|
37
|
+
userId: "unauthorized",
|
|
38
|
+
name: "Unauthorized",
|
|
39
|
+
claims: {
|
|
40
|
+
sub: "unauthorized",
|
|
41
|
+
},
|
|
42
|
+
lastLogin: new Date(0)
|
|
43
|
+
};
|
|
44
|
+
try {
|
|
45
|
+
Object.freeze(UNAUTHORIZED_USER);
|
|
46
|
+
Object.freeze(UNAUTHORIZED_USER.claims);
|
|
1362
47
|
}
|
|
48
|
+
catch (_a) { }
|
|
1363
49
|
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
50
|
+
const swHolder = {};
|
|
51
|
+
const swContainer = typeof self !== 'undefined' && self.document && // self.document is to verify we're not the SW ourself
|
|
52
|
+
typeof navigator !== 'undefined' && navigator.serviceWorker;
|
|
53
|
+
if (swContainer)
|
|
54
|
+
swContainer.ready.then((registration) => (swHolder.registration = registration));
|
|
55
|
+
if (typeof self !== 'undefined' && 'clients' in self && !self.document) {
|
|
56
|
+
// We are the service worker. Propagate messages to all our clients.
|
|
57
|
+
addEventListener('message', (ev) => {
|
|
58
|
+
var _a, _b;
|
|
59
|
+
if ((_b = (_a = ev.data) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.startsWith('sw-broadcast-')) {
|
|
60
|
+
[...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); });
|
|
61
|
+
}
|
|
1368
62
|
});
|
|
1369
63
|
}
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
}
|
|
1386
|
-
|
|
1387
|
-
subscriber.next(input[i++]);
|
|
1388
|
-
if (!subscriber.closed) {
|
|
1389
|
-
this.schedule();
|
|
1390
|
-
}
|
|
64
|
+
/** This class is a fallback for browsers that lacks BroadcastChannel but have
|
|
65
|
+
* service workers (which is Safari versions 11.1 through 15.3).
|
|
66
|
+
* Safari 15.4 with BroadcastChannel was released on 2022-03-14.
|
|
67
|
+
* We might be able to remove this class in a near future as Safari < 15.4 is
|
|
68
|
+
* already very low in market share as of 2023-03-10.
|
|
69
|
+
*/
|
|
70
|
+
class SWBroadcastChannel {
|
|
71
|
+
constructor(name) {
|
|
72
|
+
this.name = name;
|
|
73
|
+
}
|
|
74
|
+
subscribe(listener) {
|
|
75
|
+
if (!swContainer)
|
|
76
|
+
return () => { };
|
|
77
|
+
const forwarder = (ev) => {
|
|
78
|
+
var _a;
|
|
79
|
+
if (((_a = ev.data) === null || _a === void 0 ? void 0 : _a.type) === `sw-broadcast-${this.name}`) {
|
|
80
|
+
listener(ev.data.message);
|
|
1391
81
|
}
|
|
1392
|
-
}
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
function scheduleIterable(input, scheduler) {
|
|
1397
|
-
return new Observable(function (subscriber) {
|
|
1398
|
-
var iterator$1;
|
|
1399
|
-
executeSchedule(subscriber, scheduler, function () {
|
|
1400
|
-
iterator$1 = input[iterator]();
|
|
1401
|
-
executeSchedule(subscriber, scheduler, function () {
|
|
1402
|
-
var _a;
|
|
1403
|
-
var value;
|
|
1404
|
-
var done;
|
|
1405
|
-
try {
|
|
1406
|
-
(_a = iterator$1.next(), value = _a.value, done = _a.done);
|
|
1407
|
-
}
|
|
1408
|
-
catch (err) {
|
|
1409
|
-
subscriber.error(err);
|
|
1410
|
-
return;
|
|
1411
|
-
}
|
|
1412
|
-
if (done) {
|
|
1413
|
-
subscriber.complete();
|
|
1414
|
-
}
|
|
1415
|
-
else {
|
|
1416
|
-
subscriber.next(value);
|
|
1417
|
-
}
|
|
1418
|
-
}, 0, true);
|
|
1419
|
-
});
|
|
1420
|
-
return function () { return isFunction(iterator$1 === null || iterator$1 === void 0 ? void 0 : iterator$1.return) && iterator$1.return(); };
|
|
1421
|
-
});
|
|
1422
|
-
}
|
|
1423
|
-
|
|
1424
|
-
function scheduleAsyncIterable(input, scheduler) {
|
|
1425
|
-
if (!input) {
|
|
1426
|
-
throw new Error('Iterable cannot be null');
|
|
82
|
+
};
|
|
83
|
+
swContainer.addEventListener('message', forwarder);
|
|
84
|
+
return () => swContainer.removeEventListener('message', forwarder);
|
|
1427
85
|
}
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
else {
|
|
1437
|
-
subscriber.next(result.value);
|
|
1438
|
-
}
|
|
1439
|
-
});
|
|
1440
|
-
}, 0, true);
|
|
1441
|
-
});
|
|
1442
|
-
});
|
|
1443
|
-
}
|
|
1444
|
-
|
|
1445
|
-
function scheduleReadableStreamLike(input, scheduler) {
|
|
1446
|
-
return scheduleAsyncIterable(readableStreamLikeToAsyncGenerator(input), scheduler);
|
|
1447
|
-
}
|
|
1448
|
-
|
|
1449
|
-
function scheduled(input, scheduler) {
|
|
1450
|
-
if (input != null) {
|
|
1451
|
-
if (isInteropObservable(input)) {
|
|
1452
|
-
return scheduleObservable(input, scheduler);
|
|
1453
|
-
}
|
|
1454
|
-
if (isArrayLike(input)) {
|
|
1455
|
-
return scheduleArray(input, scheduler);
|
|
1456
|
-
}
|
|
1457
|
-
if (isPromise(input)) {
|
|
1458
|
-
return schedulePromise(input, scheduler);
|
|
1459
|
-
}
|
|
1460
|
-
if (isAsyncIterable(input)) {
|
|
1461
|
-
return scheduleAsyncIterable(input, scheduler);
|
|
1462
|
-
}
|
|
1463
|
-
if (isIterable(input)) {
|
|
1464
|
-
return scheduleIterable(input, scheduler);
|
|
86
|
+
postMessage(message) {
|
|
87
|
+
var _a;
|
|
88
|
+
if (typeof self['clients'] === 'object') {
|
|
89
|
+
// We're a service worker. Propagate to our browser clients.
|
|
90
|
+
[...self['clients'].matchAll({ includeUncontrolled: true })].forEach((client) => client.postMessage({
|
|
91
|
+
type: `sw-broadcast-${this.name}`,
|
|
92
|
+
message,
|
|
93
|
+
}));
|
|
1465
94
|
}
|
|
1466
|
-
if (
|
|
1467
|
-
|
|
95
|
+
else if (swHolder.registration) {
|
|
96
|
+
// We're a client (browser window or other worker)
|
|
97
|
+
// Post to SW so it can repost to all its clients and to itself
|
|
98
|
+
(_a = swHolder.registration.active) === null || _a === void 0 ? void 0 : _a.postMessage({
|
|
99
|
+
type: `sw-broadcast-${this.name}`,
|
|
100
|
+
message,
|
|
101
|
+
});
|
|
1468
102
|
}
|
|
1469
103
|
}
|
|
1470
|
-
throw createInvalidObservableTypeError(input);
|
|
1471
|
-
}
|
|
1472
|
-
|
|
1473
|
-
function from(input, scheduler) {
|
|
1474
|
-
return scheduler ? scheduled(input, scheduler) : innerFrom(input);
|
|
1475
|
-
}
|
|
1476
|
-
|
|
1477
|
-
function map(project, thisArg) {
|
|
1478
|
-
return operate(function (source, subscriber) {
|
|
1479
|
-
var index = 0;
|
|
1480
|
-
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1481
|
-
subscriber.next(project.call(thisArg, value, index++));
|
|
1482
|
-
}));
|
|
1483
|
-
});
|
|
1484
|
-
}
|
|
1485
|
-
|
|
1486
|
-
function mergeInternals(source, subscriber, project, concurrent, onBeforeNext, expand, innerSubScheduler, additionalFinalizer) {
|
|
1487
|
-
var buffer = [];
|
|
1488
|
-
var active = 0;
|
|
1489
|
-
var index = 0;
|
|
1490
|
-
var isComplete = false;
|
|
1491
|
-
var checkComplete = function () {
|
|
1492
|
-
if (isComplete && !buffer.length && !active) {
|
|
1493
|
-
subscriber.complete();
|
|
1494
|
-
}
|
|
1495
|
-
};
|
|
1496
|
-
var outerNext = function (value) { return (active < concurrent ? doInnerSub(value) : buffer.push(value)); };
|
|
1497
|
-
var doInnerSub = function (value) {
|
|
1498
|
-
expand && subscriber.next(value);
|
|
1499
|
-
active++;
|
|
1500
|
-
var innerComplete = false;
|
|
1501
|
-
innerFrom(project(value, index++)).subscribe(createOperatorSubscriber(subscriber, function (innerValue) {
|
|
1502
|
-
onBeforeNext === null || onBeforeNext === void 0 ? void 0 : onBeforeNext(innerValue);
|
|
1503
|
-
if (expand) {
|
|
1504
|
-
outerNext(innerValue);
|
|
1505
|
-
}
|
|
1506
|
-
else {
|
|
1507
|
-
subscriber.next(innerValue);
|
|
1508
|
-
}
|
|
1509
|
-
}, function () {
|
|
1510
|
-
innerComplete = true;
|
|
1511
|
-
}, undefined, function () {
|
|
1512
|
-
if (innerComplete) {
|
|
1513
|
-
try {
|
|
1514
|
-
active--;
|
|
1515
|
-
var _loop_1 = function () {
|
|
1516
|
-
var bufferedValue = buffer.shift();
|
|
1517
|
-
if (innerSubScheduler) {
|
|
1518
|
-
executeSchedule(subscriber, innerSubScheduler, function () { return doInnerSub(bufferedValue); });
|
|
1519
|
-
}
|
|
1520
|
-
else {
|
|
1521
|
-
doInnerSub(bufferedValue);
|
|
1522
|
-
}
|
|
1523
|
-
};
|
|
1524
|
-
while (buffer.length && active < concurrent) {
|
|
1525
|
-
_loop_1();
|
|
1526
|
-
}
|
|
1527
|
-
checkComplete();
|
|
1528
|
-
}
|
|
1529
|
-
catch (err) {
|
|
1530
|
-
subscriber.error(err);
|
|
1531
|
-
}
|
|
1532
|
-
}
|
|
1533
|
-
}));
|
|
1534
|
-
};
|
|
1535
|
-
source.subscribe(createOperatorSubscriber(subscriber, outerNext, function () {
|
|
1536
|
-
isComplete = true;
|
|
1537
|
-
checkComplete();
|
|
1538
|
-
}));
|
|
1539
|
-
return function () {
|
|
1540
|
-
additionalFinalizer === null || additionalFinalizer === void 0 ? void 0 : additionalFinalizer();
|
|
1541
|
-
};
|
|
1542
104
|
}
|
|
1543
105
|
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
if (
|
|
1547
|
-
|
|
106
|
+
const events = globalThis['lbc-events'] || (globalThis['lbc-events'] = new Map());
|
|
107
|
+
function addListener(name, listener) {
|
|
108
|
+
if (events.has(name)) {
|
|
109
|
+
events.get(name).push(listener);
|
|
1548
110
|
}
|
|
1549
|
-
else
|
|
1550
|
-
|
|
111
|
+
else {
|
|
112
|
+
events.set(name, [listener]);
|
|
1551
113
|
}
|
|
1552
|
-
return operate(function (source, subscriber) { return mergeInternals(source, subscriber, project, concurrent); });
|
|
1553
|
-
}
|
|
1554
|
-
|
|
1555
|
-
function mergeAll(concurrent) {
|
|
1556
|
-
if (concurrent === void 0) { concurrent = Infinity; }
|
|
1557
|
-
return mergeMap(identity, concurrent);
|
|
1558
114
|
}
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
if (scheduler === void 0) { scheduler = asyncScheduler; }
|
|
1566
|
-
return operate(function (source, subscriber) {
|
|
1567
|
-
var activeTask = null;
|
|
1568
|
-
var lastValue = null;
|
|
1569
|
-
var lastTime = null;
|
|
1570
|
-
var emit = function () {
|
|
1571
|
-
if (activeTask) {
|
|
1572
|
-
activeTask.unsubscribe();
|
|
1573
|
-
activeTask = null;
|
|
1574
|
-
var value = lastValue;
|
|
1575
|
-
lastValue = null;
|
|
1576
|
-
subscriber.next(value);
|
|
1577
|
-
}
|
|
1578
|
-
};
|
|
1579
|
-
function emitWhenIdle() {
|
|
1580
|
-
var targetTime = lastTime + dueTime;
|
|
1581
|
-
var now = scheduler.now();
|
|
1582
|
-
if (now < targetTime) {
|
|
1583
|
-
activeTask = this.schedule(undefined, targetTime - now);
|
|
1584
|
-
subscriber.add(activeTask);
|
|
1585
|
-
return;
|
|
1586
|
-
}
|
|
1587
|
-
emit();
|
|
115
|
+
function removeListener(name, listener) {
|
|
116
|
+
const listeners = events.get(name);
|
|
117
|
+
if (listeners) {
|
|
118
|
+
const idx = listeners.indexOf(listener);
|
|
119
|
+
if (idx !== -1) {
|
|
120
|
+
listeners.splice(idx, 1);
|
|
1588
121
|
}
|
|
1589
|
-
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1590
|
-
lastValue = value;
|
|
1591
|
-
lastTime = scheduler.now();
|
|
1592
|
-
if (!activeTask) {
|
|
1593
|
-
activeTask = scheduler.schedule(emitWhenIdle, dueTime);
|
|
1594
|
-
subscriber.add(activeTask);
|
|
1595
|
-
}
|
|
1596
|
-
}, function () {
|
|
1597
|
-
emit();
|
|
1598
|
-
subscriber.complete();
|
|
1599
|
-
}, undefined, function () {
|
|
1600
|
-
lastValue = activeTask = null;
|
|
1601
|
-
}));
|
|
1602
|
-
});
|
|
1603
|
-
}
|
|
1604
|
-
|
|
1605
|
-
function concat$1() {
|
|
1606
|
-
var args = [];
|
|
1607
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1608
|
-
args[_i] = arguments[_i];
|
|
1609
122
|
}
|
|
1610
|
-
return concatAll()(from(args, popScheduler(args)));
|
|
1611
123
|
}
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1622
|
-
if (++seen <= count) {
|
|
1623
|
-
subscriber.next(value);
|
|
1624
|
-
if (count <= seen) {
|
|
1625
|
-
subscriber.complete();
|
|
1626
|
-
}
|
|
1627
|
-
}
|
|
1628
|
-
}));
|
|
124
|
+
function dispatch(ev) {
|
|
125
|
+
const listeners = events.get(ev.type);
|
|
126
|
+
if (listeners) {
|
|
127
|
+
listeners.forEach(listener => {
|
|
128
|
+
try {
|
|
129
|
+
listener(ev);
|
|
130
|
+
}
|
|
131
|
+
catch (_a) {
|
|
132
|
+
}
|
|
1629
133
|
});
|
|
1630
|
-
}
|
|
1631
|
-
|
|
1632
|
-
function ignoreElements() {
|
|
1633
|
-
return operate(function (source, subscriber) {
|
|
1634
|
-
source.subscribe(createOperatorSubscriber(subscriber, noop));
|
|
1635
|
-
});
|
|
1636
|
-
}
|
|
1637
|
-
|
|
1638
|
-
function mapTo(value) {
|
|
1639
|
-
return map(function () { return value; });
|
|
1640
|
-
}
|
|
1641
|
-
|
|
1642
|
-
function delayWhen(delayDurationSelector, subscriptionDelay) {
|
|
1643
|
-
if (subscriptionDelay) {
|
|
1644
|
-
return function (source) {
|
|
1645
|
-
return concat$1(subscriptionDelay.pipe(take(1), ignoreElements()), source.pipe(delayWhen(delayDurationSelector)));
|
|
1646
|
-
};
|
|
1647
134
|
}
|
|
1648
|
-
return mergeMap(function (value, index) { return delayDurationSelector(value, index).pipe(take(1), mapTo(value)); });
|
|
1649
135
|
}
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
function distinctUntilChanged(comparator, keySelector) {
|
|
1658
|
-
if (keySelector === void 0) { keySelector = identity; }
|
|
1659
|
-
comparator = comparator !== null && comparator !== void 0 ? comparator : defaultCompare;
|
|
1660
|
-
return operate(function (source, subscriber) {
|
|
1661
|
-
var previousKey;
|
|
1662
|
-
var first = true;
|
|
1663
|
-
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1664
|
-
var currentKey = keySelector(value);
|
|
1665
|
-
if (first || !comparator(previousKey, currentKey)) {
|
|
1666
|
-
first = false;
|
|
1667
|
-
previousKey = currentKey;
|
|
1668
|
-
subscriber.next(value);
|
|
136
|
+
class BroadcastedAndLocalEvent extends rxjs.Observable {
|
|
137
|
+
constructor(name) {
|
|
138
|
+
const bc = typeof BroadcastChannel === "undefined"
|
|
139
|
+
? new SWBroadcastChannel(name) : new BroadcastChannel(name);
|
|
140
|
+
super(subscriber => {
|
|
141
|
+
function onCustomEvent(ev) {
|
|
142
|
+
subscriber.next(ev.detail);
|
|
1669
143
|
}
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
source.subscribe(createOperatorSubscriber(subscriber, function (value) { return predicate.call(thisArg, value, index++) && subscriber.next(value); }));
|
|
1681
|
-
});
|
|
1682
|
-
}
|
|
1683
|
-
|
|
1684
|
-
function skip(count) {
|
|
1685
|
-
return filter(function (_, index) { return count <= index; });
|
|
1686
|
-
}
|
|
1687
|
-
|
|
1688
|
-
function startWith() {
|
|
1689
|
-
var values = [];
|
|
1690
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1691
|
-
values[_i] = arguments[_i];
|
|
1692
|
-
}
|
|
1693
|
-
var scheduler = popScheduler(values);
|
|
1694
|
-
return operate(function (source, subscriber) {
|
|
1695
|
-
(scheduler ? concat$1(values, source, scheduler) : concat$1(values, source)).subscribe(subscriber);
|
|
1696
|
-
});
|
|
1697
|
-
}
|
|
1698
|
-
|
|
1699
|
-
function switchMap(project, resultSelector) {
|
|
1700
|
-
return operate(function (source, subscriber) {
|
|
1701
|
-
var innerSubscriber = null;
|
|
1702
|
-
var index = 0;
|
|
1703
|
-
var isComplete = false;
|
|
1704
|
-
var checkComplete = function () { return isComplete && !innerSubscriber && subscriber.complete(); };
|
|
1705
|
-
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1706
|
-
innerSubscriber === null || innerSubscriber === void 0 ? void 0 : innerSubscriber.unsubscribe();
|
|
1707
|
-
var innerIndex = 0;
|
|
1708
|
-
var outerIndex = index++;
|
|
1709
|
-
innerFrom(project(value, outerIndex)).subscribe((innerSubscriber = createOperatorSubscriber(subscriber, function (innerValue) { return subscriber.next(resultSelector ? resultSelector(value, innerValue, outerIndex, innerIndex++) : innerValue); }, function () {
|
|
1710
|
-
innerSubscriber = null;
|
|
1711
|
-
checkComplete();
|
|
1712
|
-
})));
|
|
1713
|
-
}, function () {
|
|
1714
|
-
isComplete = true;
|
|
1715
|
-
checkComplete();
|
|
1716
|
-
}));
|
|
1717
|
-
});
|
|
1718
|
-
}
|
|
1719
|
-
|
|
1720
|
-
function tap(observerOrNext, error, complete) {
|
|
1721
|
-
var tapObserver = isFunction(observerOrNext) || error || complete
|
|
1722
|
-
?
|
|
1723
|
-
{ next: observerOrNext, error: error, complete: complete }
|
|
1724
|
-
: observerOrNext;
|
|
1725
|
-
return tapObserver
|
|
1726
|
-
? operate(function (source, subscriber) {
|
|
1727
|
-
var _a;
|
|
1728
|
-
(_a = tapObserver.subscribe) === null || _a === void 0 ? void 0 : _a.call(tapObserver);
|
|
1729
|
-
var isUnsub = true;
|
|
1730
|
-
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1731
|
-
var _a;
|
|
1732
|
-
(_a = tapObserver.next) === null || _a === void 0 ? void 0 : _a.call(tapObserver, value);
|
|
1733
|
-
subscriber.next(value);
|
|
1734
|
-
}, function () {
|
|
1735
|
-
var _a;
|
|
1736
|
-
isUnsub = false;
|
|
1737
|
-
(_a = tapObserver.complete) === null || _a === void 0 ? void 0 : _a.call(tapObserver);
|
|
1738
|
-
subscriber.complete();
|
|
1739
|
-
}, function (err) {
|
|
1740
|
-
var _a;
|
|
1741
|
-
isUnsub = false;
|
|
1742
|
-
(_a = tapObserver.error) === null || _a === void 0 ? void 0 : _a.call(tapObserver, err);
|
|
1743
|
-
subscriber.error(err);
|
|
1744
|
-
}, function () {
|
|
1745
|
-
var _a, _b;
|
|
1746
|
-
if (isUnsub) {
|
|
1747
|
-
(_a = tapObserver.unsubscribe) === null || _a === void 0 ? void 0 : _a.call(tapObserver);
|
|
1748
|
-
}
|
|
1749
|
-
(_b = tapObserver.finalize) === null || _b === void 0 ? void 0 : _b.call(tapObserver);
|
|
1750
|
-
}));
|
|
1751
|
-
})
|
|
1752
|
-
:
|
|
1753
|
-
identity;
|
|
1754
|
-
}
|
|
1755
|
-
|
|
1756
|
-
var TimeoutError = createErrorClass(function (_super) {
|
|
1757
|
-
return function TimeoutErrorImpl(info) {
|
|
1758
|
-
if (info === void 0) { info = null; }
|
|
1759
|
-
_super(this);
|
|
1760
|
-
this.message = 'Timeout has occurred';
|
|
1761
|
-
this.name = 'TimeoutError';
|
|
1762
|
-
this.info = info;
|
|
1763
|
-
};
|
|
1764
|
-
});
|
|
1765
|
-
function timeout(config, schedulerArg) {
|
|
1766
|
-
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;
|
|
1767
|
-
if (first == null && each == null) {
|
|
1768
|
-
throw new TypeError('No timeout provided.');
|
|
1769
|
-
}
|
|
1770
|
-
return operate(function (source, subscriber) {
|
|
1771
|
-
var originalSourceSubscription;
|
|
1772
|
-
var timerSubscription;
|
|
1773
|
-
var lastValue = null;
|
|
1774
|
-
var seen = 0;
|
|
1775
|
-
var startTimer = function (delay) {
|
|
1776
|
-
timerSubscription = executeSchedule(subscriber, scheduler, function () {
|
|
1777
|
-
try {
|
|
1778
|
-
originalSourceSubscription.unsubscribe();
|
|
1779
|
-
innerFrom(_with({
|
|
1780
|
-
meta: meta,
|
|
1781
|
-
lastValue: lastValue,
|
|
1782
|
-
seen: seen,
|
|
1783
|
-
})).subscribe(subscriber);
|
|
144
|
+
function onMessageEvent(ev) {
|
|
145
|
+
console.debug("BroadcastedAndLocalEvent: onMessageEvent", ev);
|
|
146
|
+
subscriber.next(ev.data);
|
|
147
|
+
}
|
|
148
|
+
let unsubscribe;
|
|
149
|
+
//self.addEventListener(`lbc-${name}`, onCustomEvent); // Fails in service workers
|
|
150
|
+
addListener(`lbc-${name}`, onCustomEvent); // Works better in service worker
|
|
151
|
+
try {
|
|
152
|
+
if (bc instanceof SWBroadcastChannel) {
|
|
153
|
+
unsubscribe = bc.subscribe(message => subscriber.next(message));
|
|
1784
154
|
}
|
|
1785
|
-
|
|
1786
|
-
|
|
155
|
+
else {
|
|
156
|
+
console.debug("BroadcastedAndLocalEvent: bc.addEventListener()", name, "bc is a", bc);
|
|
157
|
+
bc.addEventListener("message", onMessageEvent);
|
|
1787
158
|
}
|
|
1788
|
-
}, delay);
|
|
1789
|
-
};
|
|
1790
|
-
originalSourceSubscription = source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1791
|
-
timerSubscription === null || timerSubscription === void 0 ? void 0 : timerSubscription.unsubscribe();
|
|
1792
|
-
seen++;
|
|
1793
|
-
subscriber.next((lastValue = value));
|
|
1794
|
-
each > 0 && startTimer(each);
|
|
1795
|
-
}, undefined, undefined, function () {
|
|
1796
|
-
if (!(timerSubscription === null || timerSubscription === void 0 ? void 0 : timerSubscription.closed)) {
|
|
1797
|
-
timerSubscription === null || timerSubscription === void 0 ? void 0 : timerSubscription.unsubscribe();
|
|
1798
159
|
}
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
160
|
+
catch (err) {
|
|
161
|
+
// Service workers might fail to subscribe outside its initial script.
|
|
162
|
+
console.warn('Failed to subscribe to broadcast channel', err);
|
|
163
|
+
}
|
|
164
|
+
return () => {
|
|
165
|
+
//self.removeEventListener(`lbc-${name}`, onCustomEvent);
|
|
166
|
+
removeListener(`lbc-${name}`, onCustomEvent);
|
|
167
|
+
if (bc instanceof SWBroadcastChannel) {
|
|
168
|
+
unsubscribe();
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
bc.removeEventListener("message", onMessageEvent);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
});
|
|
175
|
+
this.name = name;
|
|
176
|
+
this.bc = bc;
|
|
177
|
+
}
|
|
178
|
+
next(message) {
|
|
179
|
+
console.debug("BroadcastedAndLocalEvent: bc.postMessage()", Object.assign({}, message), "bc is a", this.bc);
|
|
180
|
+
this.bc.postMessage(message);
|
|
181
|
+
const ev = new CustomEvent(`lbc-${this.name}`, { detail: message });
|
|
182
|
+
//self.dispatchEvent(ev);
|
|
183
|
+
dispatch(ev);
|
|
184
|
+
}
|
|
1806
185
|
}
|
|
1807
186
|
|
|
1808
187
|
//const hasSW = 'serviceWorker' in navigator;
|
|
@@ -3776,7 +2155,7 @@
|
|
|
3776
2155
|
// It's no need to have two channels at the same time - even though it wouldnt
|
|
3777
2156
|
// be a problem - this is an optimization.
|
|
3778
2157
|
yield db.cloud.syncState
|
|
3779
|
-
.pipe(filter(({ phase }) => phase === 'in-sync' || phase === 'error'), take(1))
|
|
2158
|
+
.pipe(operators.filter(({ phase }) => phase === 'in-sync' || phase === 'error'), operators.take(1))
|
|
3780
2159
|
.toPromise();
|
|
3781
2160
|
console.debug('processing msg', msg);
|
|
3782
2161
|
const persistedSyncState = db.cloud.persistedSyncState.value;
|
|
@@ -4801,6 +3180,38 @@
|
|
|
4801
3180
|
function overrideParseStoresSpec(origFunc, dexie) {
|
|
4802
3181
|
return function (stores, dbSchema) {
|
|
4803
3182
|
const storesClone = Object.assign(Object.assign({}, DEXIE_CLOUD_SCHEMA), stores);
|
|
3183
|
+
// Merge indexes of DEXIE_CLOUD_SCHEMA with stores
|
|
3184
|
+
Object.keys(DEXIE_CLOUD_SCHEMA).forEach((tableName) => {
|
|
3185
|
+
const schemaSrc = storesClone[tableName];
|
|
3186
|
+
// Verify that they don't try to delete a table that is needed for access control of Dexie Cloud
|
|
3187
|
+
if (schemaSrc == null) {
|
|
3188
|
+
// They try to delete one of the built-in schema tables.
|
|
3189
|
+
throw new Error(`Cannot delete table ${tableName} as it is needed for access control of Dexie Cloud`);
|
|
3190
|
+
}
|
|
3191
|
+
// If not trying to override a built-in table, then we can skip this and continue to next table.
|
|
3192
|
+
if (!stores[tableName]) {
|
|
3193
|
+
// They haven't tried to declare this table. No need to merge indexes.
|
|
3194
|
+
return; // Continue
|
|
3195
|
+
}
|
|
3196
|
+
// They have declared this table. Merge indexes in case they didn't declare all indexes we need.
|
|
3197
|
+
const requestedIndexes = schemaSrc.split(',').map(spec => spec.trim());
|
|
3198
|
+
const builtInIndexes = DEXIE_CLOUD_SCHEMA[tableName].split(',').map(spec => spec.trim());
|
|
3199
|
+
const requestedIndexSet = new Set(requestedIndexes.map(index => index.replace(/([&*]|\+\+)/g, "")));
|
|
3200
|
+
// Verify that primary key is unchanged
|
|
3201
|
+
if (requestedIndexes[0] !== builtInIndexes[0]) {
|
|
3202
|
+
// Primary key must match exactly
|
|
3203
|
+
throw new Error(`Cannot override primary key of table ${tableName}. Please declare it as {${tableName}: ${JSON.stringify(DEXIE_CLOUD_SCHEMA[tableName])}`);
|
|
3204
|
+
}
|
|
3205
|
+
// Merge indexes
|
|
3206
|
+
for (let i = 1; i < builtInIndexes.length; ++i) {
|
|
3207
|
+
const builtInIndex = builtInIndexes[i];
|
|
3208
|
+
if (!requestedIndexSet.has(builtInIndex.replace(/([&*]|\+\+)/g, ""))) {
|
|
3209
|
+
// Add built-in index if not already requested
|
|
3210
|
+
storesClone[tableName] += `,${builtInIndex}`;
|
|
3211
|
+
}
|
|
3212
|
+
}
|
|
3213
|
+
});
|
|
3214
|
+
// Populate dexie.cloud.schema
|
|
4804
3215
|
const cloudSchema = dexie.cloud.schema || (dexie.cloud.schema = {});
|
|
4805
3216
|
const allPrefixes = new Set();
|
|
4806
3217
|
Object.keys(storesClone).forEach(tableName => {
|
|
@@ -4854,13 +3265,13 @@
|
|
|
4854
3265
|
// for just a short time.
|
|
4855
3266
|
const userIsReallyActive = new rxjs.BehaviorSubject(true);
|
|
4856
3267
|
userIsActive
|
|
4857
|
-
.pipe(switchMap((isActive) => {
|
|
3268
|
+
.pipe(operators.switchMap((isActive) => {
|
|
4858
3269
|
//console.debug('SyncStatus: DUBB: isActive changed to', isActive);
|
|
4859
3270
|
return isActive
|
|
4860
3271
|
? rxjs.of(true)
|
|
4861
|
-
: rxjs.of(false).pipe(delay(INACTIVE_WAIT_TIME))
|
|
3272
|
+
: rxjs.of(false).pipe(operators.delay(INACTIVE_WAIT_TIME))
|
|
4862
3273
|
;
|
|
4863
|
-
}), distinctUntilChanged())
|
|
3274
|
+
}), operators.distinctUntilChanged())
|
|
4864
3275
|
.subscribe(userIsReallyActive);
|
|
4865
3276
|
//
|
|
4866
3277
|
// First create some corner-stone observables to build the flow on
|
|
@@ -4870,9 +3281,9 @@
|
|
|
4870
3281
|
? rxjs.fromEvent(document, 'visibilitychange')
|
|
4871
3282
|
: rxjs.of({});
|
|
4872
3283
|
// document.onvisibilitychange makes document hidden:
|
|
4873
|
-
const documentBecomesHidden = visibilityStateIsChanged.pipe(filter(() => document.visibilityState === 'hidden'));
|
|
3284
|
+
const documentBecomesHidden = visibilityStateIsChanged.pipe(operators.filter(() => document.visibilityState === 'hidden'));
|
|
4874
3285
|
// document.onvisibilitychange makes document visible
|
|
4875
|
-
const documentBecomesVisible = visibilityStateIsChanged.pipe(filter(() => document.visibilityState === 'visible'));
|
|
3286
|
+
const documentBecomesVisible = visibilityStateIsChanged.pipe(operators.filter(() => document.visibilityState === 'visible'));
|
|
4876
3287
|
// Any of various user-activity-related events happen:
|
|
4877
3288
|
const userDoesSomething = typeof window !== 'undefined'
|
|
4878
3289
|
? rxjs.merge(documentBecomesVisible, rxjs.fromEvent(window, 'mousedown'), rxjs.fromEvent(window, 'mousemove'), rxjs.fromEvent(window, 'keydown'), rxjs.fromEvent(window, 'wheel'), rxjs.fromEvent(window, 'touchmove'))
|
|
@@ -4890,9 +3301,9 @@
|
|
|
4890
3301
|
userDoesSomething)
|
|
4891
3302
|
.pipe(
|
|
4892
3303
|
// No matter event source, compute whether user is visible using visibilityState:
|
|
4893
|
-
map(() => document.visibilityState === 'visible'),
|
|
3304
|
+
operators.map(() => document.visibilityState === 'visible'),
|
|
4894
3305
|
// Make sure to emit it
|
|
4895
|
-
tap((isActive) => {
|
|
3306
|
+
operators.tap((isActive) => {
|
|
4896
3307
|
if (userIsActive.value !== isActive) {
|
|
4897
3308
|
// Emit new value unless it already has that value
|
|
4898
3309
|
userIsActive.next(isActive);
|
|
@@ -4900,8 +3311,8 @@
|
|
|
4900
3311
|
}),
|
|
4901
3312
|
// Now, if true was emitted, make sure to set a timeout to emit false
|
|
4902
3313
|
// unless new user activity things happen (in that case, the timeout will be cancelled!)
|
|
4903
|
-
switchMap((isActive) => isActive
|
|
4904
|
-
? rxjs.of(0).pipe(delay(USER_INACTIVITY_TIMEOUT - INACTIVE_WAIT_TIME), tap(() => userIsActive.next(false)))
|
|
3314
|
+
operators.switchMap((isActive) => isActive
|
|
3315
|
+
? rxjs.of(0).pipe(operators.delay(USER_INACTIVITY_TIMEOUT - INACTIVE_WAIT_TIME), operators.tap(() => userIsActive.next(false)))
|
|
4905
3316
|
: rxjs.of(0)))
|
|
4906
3317
|
.subscribe(() => { }); // Unless we subscribe nothing will be propagated to userIsActive observable
|
|
4907
3318
|
}
|
|
@@ -5131,7 +3542,7 @@
|
|
|
5131
3542
|
yield sleep$1(3000);
|
|
5132
3543
|
// Wait til user does something (move mouse, tap, scroll, click etc)
|
|
5133
3544
|
console.debug('waiting for someone to do something');
|
|
5134
|
-
yield userDoesSomething.pipe(take(1)).toPromise();
|
|
3545
|
+
yield userDoesSomething.pipe(operators.take(1)).toPromise();
|
|
5135
3546
|
console.debug('someone did something!');
|
|
5136
3547
|
});
|
|
5137
3548
|
}
|
|
@@ -5140,35 +3551,35 @@
|
|
|
5140
3551
|
if (!((_a = db.cloud.options) === null || _a === void 0 ? void 0 : _a.databaseUrl)) {
|
|
5141
3552
|
throw new Error(`No database URL to connect WebSocket to`);
|
|
5142
3553
|
}
|
|
5143
|
-
const messageProducer = db.messageConsumer.readyToServe.pipe(filter((isReady) => isReady), // When consumer is ready for new messages, produce such a message to inform server about it
|
|
5144
|
-
switchMap(() => db.getPersistedSyncState()), // We need the info on which server revision we are at:
|
|
5145
|
-
filter((syncState) => syncState && syncState.serverRevision), // We wont send anything to server before inital sync has taken place
|
|
5146
|
-
map((syncState) => ({
|
|
3554
|
+
const messageProducer = db.messageConsumer.readyToServe.pipe(operators.filter((isReady) => isReady), // When consumer is ready for new messages, produce such a message to inform server about it
|
|
3555
|
+
operators.switchMap(() => db.getPersistedSyncState()), // We need the info on which server revision we are at:
|
|
3556
|
+
operators.filter((syncState) => syncState && syncState.serverRevision), // We wont send anything to server before inital sync has taken place
|
|
3557
|
+
operators.map((syncState) => ({
|
|
5147
3558
|
// Produce the message to trigger server to send us new messages to consume:
|
|
5148
3559
|
type: 'ready',
|
|
5149
3560
|
rev: syncState.serverRevision,
|
|
5150
3561
|
})));
|
|
5151
3562
|
function createObservable() {
|
|
5152
|
-
return db.cloud.persistedSyncState.pipe(filter((syncState) => syncState === null || syncState === void 0 ? void 0 : syncState.serverRevision), // Don't connect before there's no initial sync performed.
|
|
5153
|
-
take(1), // Don't continue waking up whenever syncState change
|
|
5154
|
-
switchMap((syncState) => db.cloud.currentUser.pipe(map((userLogin) => [userLogin, syncState]))), switchMap(([userLogin, syncState]) => userIsReallyActive.pipe(map((isActive) => [isActive ? userLogin : null, syncState]))), switchMap(([userLogin, syncState]) => {
|
|
3563
|
+
return db.cloud.persistedSyncState.pipe(operators.filter((syncState) => syncState === null || syncState === void 0 ? void 0 : syncState.serverRevision), // Don't connect before there's no initial sync performed.
|
|
3564
|
+
operators.take(1), // Don't continue waking up whenever syncState change
|
|
3565
|
+
operators.switchMap((syncState) => db.cloud.currentUser.pipe(operators.map((userLogin) => [userLogin, syncState]))), operators.switchMap(([userLogin, syncState]) => userIsReallyActive.pipe(operators.map((isActive) => [isActive ? userLogin : null, syncState]))), operators.switchMap(([userLogin, syncState]) => {
|
|
5155
3566
|
if ((userLogin === null || userLogin === void 0 ? void 0 : userLogin.isLoggedIn) && !(syncState === null || syncState === void 0 ? void 0 : syncState.realms.includes(userLogin.userId))) {
|
|
5156
3567
|
// We're in an in-between state when user is logged in but the user's realms are not yet synced.
|
|
5157
3568
|
// Don't make this change reconnect the websocket just yet. Wait till syncState is updated
|
|
5158
3569
|
// to iclude the user's realm.
|
|
5159
|
-
return db.cloud.persistedSyncState.pipe(filter((syncState) => (syncState === null || syncState === void 0 ? void 0 : syncState.realms.includes(userLogin.userId)) || false), take(1), map((syncState) => [userLogin, syncState]));
|
|
3570
|
+
return db.cloud.persistedSyncState.pipe(operators.filter((syncState) => (syncState === null || syncState === void 0 ? void 0 : syncState.realms.includes(userLogin.userId)) || false), operators.take(1), operators.map((syncState) => [userLogin, syncState]));
|
|
5160
3571
|
}
|
|
5161
3572
|
return new rxjs.BehaviorSubject([userLogin, syncState]);
|
|
5162
|
-
}), switchMap(([userLogin, syncState]) => __awaiter(this, void 0, void 0, function* () { return [userLogin, yield computeRealmSetHash(syncState)]; })), switchMap(([userLogin, realmSetHash]) =>
|
|
3573
|
+
}), operators.switchMap(([userLogin, syncState]) => __awaiter(this, void 0, void 0, function* () { return [userLogin, yield computeRealmSetHash(syncState)]; })), operators.switchMap(([userLogin, realmSetHash]) =>
|
|
5163
3574
|
// Let server end query changes from last entry of same client-ID and forward.
|
|
5164
3575
|
// If no new entries, server won't bother the client. If new entries, server sends only those
|
|
5165
3576
|
// and the baseRev of the last from same client-ID.
|
|
5166
3577
|
userLogin
|
|
5167
3578
|
? 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)
|
|
5168
|
-
: rxjs.from([])), catchError((error) => {
|
|
3579
|
+
: rxjs.from([])), operators.catchError((error) => {
|
|
5169
3580
|
if ((error === null || error === void 0 ? void 0 : error.name) === 'TokenExpiredError') {
|
|
5170
3581
|
console.debug('WebSocket observable: Token expired. Refreshing token...');
|
|
5171
|
-
return rxjs.of(true).pipe(switchMap(() => __awaiter(this, void 0, void 0, function* () {
|
|
3582
|
+
return rxjs.of(true).pipe(operators.switchMap(() => __awaiter(this, void 0, void 0, function* () {
|
|
5172
3583
|
// Refresh access token
|
|
5173
3584
|
const user = yield db.getCurrentUser();
|
|
5174
3585
|
const refreshedLogin = yield refreshAccessToken(db.cloud.options.databaseUrl, user);
|
|
@@ -5177,14 +3588,14 @@
|
|
|
5177
3588
|
accessToken: refreshedLogin.accessToken,
|
|
5178
3589
|
accessTokenExpiration: refreshedLogin.accessTokenExpiration,
|
|
5179
3590
|
});
|
|
5180
|
-
})), switchMap(() => createObservable()));
|
|
3591
|
+
})), operators.switchMap(() => createObservable()));
|
|
5181
3592
|
}
|
|
5182
3593
|
else {
|
|
5183
3594
|
return rxjs.throwError(error);
|
|
5184
3595
|
}
|
|
5185
|
-
}), catchError((error) => {
|
|
3596
|
+
}), operators.catchError((error) => {
|
|
5186
3597
|
db.cloud.webSocketStatus.next("error");
|
|
5187
|
-
return rxjs.from(waitAndReconnectWhenUserDoesSomething(error)).pipe(switchMap(() => createObservable()));
|
|
3598
|
+
return rxjs.from(waitAndReconnectWhenUserDoesSomething(error)).pipe(operators.switchMap(() => createObservable()));
|
|
5188
3599
|
}));
|
|
5189
3600
|
}
|
|
5190
3601
|
return createObservable().subscribe((msg) => {
|
|
@@ -5253,7 +3664,7 @@
|
|
|
5253
3664
|
// Someone else took the job.
|
|
5254
3665
|
if (awaitRemoteJob) {
|
|
5255
3666
|
try {
|
|
5256
|
-
const jobDoneObservable = rxjs.from(Dexie.liveQuery(() => jobsTable.get(jobName))).pipe(timeout(GUARDED_JOB_TIMEOUT), filter((job) => !job)); // Wait til job is not there anymore.
|
|
3667
|
+
const jobDoneObservable = rxjs.from(Dexie.liveQuery(() => jobsTable.get(jobName))).pipe(operators.timeout(GUARDED_JOB_TIMEOUT), operators.filter((job) => !job)); // Wait til job is not there anymore.
|
|
5257
3668
|
yield jobDoneObservable.toPromise();
|
|
5258
3669
|
return false;
|
|
5259
3670
|
}
|
|
@@ -5623,7 +4034,7 @@
|
|
|
5623
4034
|
|
|
5624
4035
|
function computeSyncState(db) {
|
|
5625
4036
|
let _prevStatus = db.cloud.webSocketStatus.value;
|
|
5626
|
-
const lazyWebSocketStatus = db.cloud.webSocketStatus.pipe(switchMap((status) => {
|
|
4037
|
+
const lazyWebSocketStatus = db.cloud.webSocketStatus.pipe(operators.switchMap((status) => {
|
|
5627
4038
|
const prevStatus = _prevStatus;
|
|
5628
4039
|
_prevStatus = status;
|
|
5629
4040
|
const rv = rxjs.of(status);
|
|
@@ -5633,22 +4044,22 @@
|
|
|
5633
4044
|
// Only show disconnected if disconnected more than 500ms, or if we can
|
|
5634
4045
|
// see that the user is indeed not active.
|
|
5635
4046
|
case 'disconnected':
|
|
5636
|
-
return userIsActive.value ? rv.pipe(debounceTime(500)) : rv;
|
|
4047
|
+
return userIsActive.value ? rv.pipe(operators.debounceTime(500)) : rv;
|
|
5637
4048
|
// Only show connecting if previous state was 'not-started' or 'error', or if
|
|
5638
4049
|
// the time it takes to connect goes beyond 4 seconds.
|
|
5639
4050
|
case 'connecting':
|
|
5640
4051
|
return prevStatus === 'not-started' || prevStatus === 'error'
|
|
5641
4052
|
? rv
|
|
5642
|
-
: rv.pipe(debounceTime(4000));
|
|
4053
|
+
: rv.pipe(operators.debounceTime(4000));
|
|
5643
4054
|
default:
|
|
5644
4055
|
return rv;
|
|
5645
4056
|
}
|
|
5646
4057
|
}));
|
|
5647
4058
|
return rxjs.combineLatest([
|
|
5648
4059
|
lazyWebSocketStatus,
|
|
5649
|
-
db.syncStateChangedEvent.pipe(startWith({ phase: 'initial' })),
|
|
4060
|
+
db.syncStateChangedEvent.pipe(operators.startWith({ phase: 'initial' })),
|
|
5650
4061
|
userIsReallyActive
|
|
5651
|
-
]).pipe(map(([status, syncState, userIsActive]) => {
|
|
4062
|
+
]).pipe(operators.map(([status, syncState, userIsActive]) => {
|
|
5652
4063
|
let { phase, error, progress } = syncState;
|
|
5653
4064
|
let adjustedStatus = status;
|
|
5654
4065
|
if (phase === 'error') {
|
|
@@ -5742,7 +4153,7 @@
|
|
|
5742
4153
|
const getCurrentUserEmitter = associate((db) => new rxjs.BehaviorSubject(UNAUTHORIZED_USER));
|
|
5743
4154
|
|
|
5744
4155
|
const getInternalAccessControlObservable = associate((db) => {
|
|
5745
|
-
return createSharedValueObservable(getCurrentUserEmitter(db._novip).pipe(switchMap((currentUser) => Dexie.liveQuery(() => db.transaction('r', 'realms', 'members', () => Promise.all([
|
|
4156
|
+
return createSharedValueObservable(getCurrentUserEmitter(db._novip).pipe(operators.switchMap((currentUser) => Dexie.liveQuery(() => db.transaction('r', 'realms', 'members', () => Promise.all([
|
|
5746
4157
|
db.members.where({ userId: currentUser.userId }).toArray(),
|
|
5747
4158
|
db.realms.toArray(),
|
|
5748
4159
|
currentUser.userId,
|
|
@@ -5843,7 +4254,7 @@
|
|
|
5843
4254
|
const o = createSharedValueObservable(rxjs.combineLatest([
|
|
5844
4255
|
getInternalAccessControlObservable(db._novip),
|
|
5845
4256
|
getGlobalRolesObservable(db._novip),
|
|
5846
|
-
]).pipe(map(([{ selfMembers, realms, userId }, globalRoles]) => ({
|
|
4257
|
+
]).pipe(operators.map(([{ selfMembers, realms, userId }, globalRoles]) => ({
|
|
5847
4258
|
selfMembers,
|
|
5848
4259
|
realms,
|
|
5849
4260
|
userId,
|
|
@@ -5957,16 +4368,16 @@
|
|
|
5957
4368
|
return new PermissionChecker({}, tableName, !owner || owner === dexie.cloud.currentUserId);
|
|
5958
4369
|
return new PermissionChecker(realm.permissions, tableName, realmId === dexie.cloud.currentUserId || owner === dexie.cloud.currentUserId);
|
|
5959
4370
|
};
|
|
5960
|
-
const o = source.pipe(map(mapper));
|
|
4371
|
+
const o = source.pipe(operators.map(mapper));
|
|
5961
4372
|
o.getValue = () => mapper(source.getValue());
|
|
5962
4373
|
return o;
|
|
5963
4374
|
}
|
|
5964
4375
|
|
|
5965
4376
|
const getInvitesObservable = associate((db) => {
|
|
5966
|
-
const membersByEmail = getCurrentUserEmitter(db._novip).pipe(switchMap((currentUser) => Dexie.liveQuery(() => db.members.where({ email: currentUser.email || '' }).toArray())));
|
|
4377
|
+
const membersByEmail = getCurrentUserEmitter(db._novip).pipe(operators.switchMap((currentUser) => Dexie.liveQuery(() => db.members.where({ email: currentUser.email || '' }).toArray())));
|
|
5967
4378
|
const permissions = getPermissionsLookupObservable(db._novip);
|
|
5968
4379
|
const accessControl = getInternalAccessControlObservable(db._novip);
|
|
5969
|
-
return createSharedValueObservable(rxjs.combineLatest([membersByEmail, accessControl, permissions]).pipe(map(([membersByEmail, accessControl, realmLookup]) => {
|
|
4380
|
+
return createSharedValueObservable(rxjs.combineLatest([membersByEmail, accessControl, permissions]).pipe(operators.map(([membersByEmail, accessControl, realmLookup]) => {
|
|
5970
4381
|
const reducer = (result, m) => (Object.assign(Object.assign({}, result), { [m.id]: Object.assign(Object.assign({}, m), { realm: realmLookup[m.realmId] }) }));
|
|
5971
4382
|
const emailMembersById = membersByEmail.reduce(reducer, {});
|
|
5972
4383
|
const membersById = accessControl.selfMembers.reduce(reducer, emailMembersById);
|
|
@@ -6023,7 +4434,7 @@
|
|
|
6023
4434
|
});
|
|
6024
4435
|
const syncComplete = new rxjs.Subject();
|
|
6025
4436
|
dexie.cloud = {
|
|
6026
|
-
version: '4.0.1-beta.
|
|
4437
|
+
version: '4.0.1-beta.39',
|
|
6027
4438
|
options: Object.assign({}, DEFAULT_OPTIONS),
|
|
6028
4439
|
schema: null,
|
|
6029
4440
|
get currentUserId() {
|
|
@@ -6069,8 +4480,8 @@
|
|
|
6069
4480
|
triggerSync(db, purpose);
|
|
6070
4481
|
if (wait) {
|
|
6071
4482
|
const newSyncState = yield db.cloud.persistedSyncState
|
|
6072
|
-
.pipe(filter((newSyncState) => (newSyncState === null || newSyncState === void 0 ? void 0 : newSyncState.timestamp) != null &&
|
|
6073
|
-
(!syncState || newSyncState.timestamp > syncState.timestamp)), take(1))
|
|
4483
|
+
.pipe(operators.filter((newSyncState) => (newSyncState === null || newSyncState === void 0 ? void 0 : newSyncState.timestamp) != null &&
|
|
4484
|
+
(!syncState || newSyncState.timestamp > syncState.timestamp)), operators.take(1))
|
|
6074
4485
|
.toPromise();
|
|
6075
4486
|
if (newSyncState === null || newSyncState === void 0 ? void 0 : newSyncState.error) {
|
|
6076
4487
|
throw new Error(`Sync error: ` + newSyncState.error);
|
|
@@ -6090,7 +4501,7 @@
|
|
|
6090
4501
|
throw new Error(`Sync error: ` + newSyncState.error);
|
|
6091
4502
|
return syncNeeded;
|
|
6092
4503
|
})))
|
|
6093
|
-
.pipe(filter((isNeeded) => !isNeeded), take(1))
|
|
4504
|
+
.pipe(operators.filter((isNeeded) => !isNeeded), operators.take(1))
|
|
6094
4505
|
.toPromise();
|
|
6095
4506
|
console.debug('Done waiting for sync completion because we have nothing to push anymore');
|
|
6096
4507
|
}
|
|
@@ -6234,8 +4645,8 @@
|
|
|
6234
4645
|
// This is so that when db.open() completes, user should be safe
|
|
6235
4646
|
// to subscribe to these observables and get actual data.
|
|
6236
4647
|
yield rxjs.combineLatest([
|
|
6237
|
-
currentUserEmitter.pipe(skip(1), take(1)),
|
|
6238
|
-
db.cloud.persistedSyncState.pipe(skip(1), take(1)),
|
|
4648
|
+
currentUserEmitter.pipe(operators.skip(1), operators.take(1)),
|
|
4649
|
+
db.cloud.persistedSyncState.pipe(operators.skip(1), operators.take(1)),
|
|
6239
4650
|
]).toPromise();
|
|
6240
4651
|
}
|
|
6241
4652
|
// HERE: If requireAuth, do athentication now.
|
|
@@ -6284,7 +4695,7 @@
|
|
|
6284
4695
|
});
|
|
6285
4696
|
}
|
|
6286
4697
|
}
|
|
6287
|
-
dexieCloud.version = '4.0.1-beta.
|
|
4698
|
+
dexieCloud.version = '4.0.1-beta.39';
|
|
6288
4699
|
Dexie__default["default"].Cloud = dexieCloud;
|
|
6289
4700
|
|
|
6290
4701
|
// In case the SW lives for a while, let it reuse already opened connections:
|