dexie-cloud-addon 4.0.0-beta.22 → 4.0.0-beta.24
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/LICENSE +202 -0
- package/copydts.sh +0 -0
- package/dist/modern/dexie-cloud-addon.js +380 -326
- 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 +381 -327
- 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/module-es5/dexie-cloud-addon.js +556 -509
- package/dist/module-es5/dexie-cloud-addon.js.map +1 -1
- package/dist/module-es5/dexie-cloud-addon.min.js +1 -1
- package/dist/module-es5/dexie-cloud-addon.min.js.map +1 -1
- package/dist/types/helpers/visibilityState.d.ts +1 -1
- package/dist/umd/dexie-cloud-addon.js +555 -508
- package/dist/umd/dexie-cloud-addon.js.map +1 -1
- package/dist/umd/dexie-cloud-addon.min.js +1 -1
- package/dist/umd/dexie-cloud-addon.min.js.map +1 -1
- package/dist/umd/service-worker.js +381 -327
- 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/dist/umd-modern/dexie-cloud-addon.js +377 -323
- package/dist/umd-modern/dexie-cloud-addon.js.map +1 -1
- package/package.json +11 -10
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
|
|
27
27
|
var Dexie__default = /*#__PURE__*/_interopDefaultLegacy(Dexie);
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
/******************************************************************************
|
|
30
30
|
Copyright (c) Microsoft Corporation.
|
|
31
31
|
|
|
32
32
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -40,8 +40,24 @@
|
|
|
40
40
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
41
41
|
PERFORMANCE OF THIS SOFTWARE.
|
|
42
42
|
***************************************************************************** */
|
|
43
|
+
/* global Reflect, Promise */
|
|
44
|
+
|
|
45
|
+
var extendStatics = function(d, b) {
|
|
46
|
+
extendStatics = Object.setPrototypeOf ||
|
|
47
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
48
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
49
|
+
return extendStatics(d, b);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
function __extends(d, b) {
|
|
53
|
+
if (typeof b !== "function" && b !== null)
|
|
54
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
55
|
+
extendStatics(d, b);
|
|
56
|
+
function __() { this.constructor = d; }
|
|
57
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
58
|
+
}
|
|
43
59
|
|
|
44
|
-
function __awaiter
|
|
60
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
45
61
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
46
62
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
47
63
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
@@ -49,6 +65,97 @@
|
|
|
49
65
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
50
66
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
51
67
|
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function __generator(thisArg, body) {
|
|
71
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
72
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
73
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
74
|
+
function step(op) {
|
|
75
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
76
|
+
while (_) try {
|
|
77
|
+
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;
|
|
78
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
79
|
+
switch (op[0]) {
|
|
80
|
+
case 0: case 1: t = op; break;
|
|
81
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
82
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
83
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
84
|
+
default:
|
|
85
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
86
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
87
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
88
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
89
|
+
if (t[2]) _.ops.pop();
|
|
90
|
+
_.trys.pop(); continue;
|
|
91
|
+
}
|
|
92
|
+
op = body.call(thisArg, _);
|
|
93
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
94
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function __values(o) {
|
|
99
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
100
|
+
if (m) return m.call(o);
|
|
101
|
+
if (o && typeof o.length === "number") return {
|
|
102
|
+
next: function () {
|
|
103
|
+
if (o && i >= o.length) o = void 0;
|
|
104
|
+
return { value: o && o[i++], done: !o };
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function __read(o, n) {
|
|
111
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
112
|
+
if (!m) return o;
|
|
113
|
+
var i = m.call(o), r, ar = [], e;
|
|
114
|
+
try {
|
|
115
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
116
|
+
}
|
|
117
|
+
catch (error) { e = { error: error }; }
|
|
118
|
+
finally {
|
|
119
|
+
try {
|
|
120
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
121
|
+
}
|
|
122
|
+
finally { if (e) throw e.error; }
|
|
123
|
+
}
|
|
124
|
+
return ar;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function __spreadArray(to, from, pack) {
|
|
128
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
129
|
+
if (ar || !(i in from)) {
|
|
130
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
131
|
+
ar[i] = from[i];
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function __await(v) {
|
|
138
|
+
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
142
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
143
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
144
|
+
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
145
|
+
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); }); }; }
|
|
146
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
147
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
148
|
+
function fulfill(value) { resume("next", value); }
|
|
149
|
+
function reject(value) { resume("throw", value); }
|
|
150
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function __asyncValues(o) {
|
|
154
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
155
|
+
var m = o[Symbol.asyncIterator], i;
|
|
156
|
+
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);
|
|
157
|
+
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); }); }; }
|
|
158
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
52
159
|
}
|
|
53
160
|
|
|
54
161
|
//@ts-check
|
|
@@ -58,6 +165,10 @@
|
|
|
58
165
|
if (!b)
|
|
59
166
|
throw new Error('Assertion Failed');
|
|
60
167
|
}
|
|
168
|
+
const _hasOwn = {}.hasOwnProperty;
|
|
169
|
+
function hasOwn(obj, prop) {
|
|
170
|
+
return _hasOwn.call(obj, prop);
|
|
171
|
+
}
|
|
61
172
|
function setByKeyPath(obj, keyPath, value) {
|
|
62
173
|
if (!obj || keyPath === undefined)
|
|
63
174
|
return;
|
|
@@ -90,8 +201,8 @@
|
|
|
90
201
|
//@ts-ignore: even if currentKeyPath would be numeric string and obj would be array - it works.
|
|
91
202
|
var innerObj = obj[currentKeyPath];
|
|
92
203
|
//@ts-ignore: even if currentKeyPath would be numeric string and obj would be array - it works.
|
|
93
|
-
if (!innerObj)
|
|
94
|
-
innerObj = obj[currentKeyPath] = {};
|
|
204
|
+
if (!innerObj || !hasOwn(obj, currentKeyPath))
|
|
205
|
+
innerObj = (obj[currentKeyPath] = {});
|
|
95
206
|
setByKeyPath(innerObj, remainingKeyPath, value);
|
|
96
207
|
}
|
|
97
208
|
}
|
|
@@ -110,7 +221,7 @@
|
|
|
110
221
|
}
|
|
111
222
|
}
|
|
112
223
|
}
|
|
113
|
-
const randomString$1 = typeof
|
|
224
|
+
const randomString$1 = typeof Buffer !== 'undefined' ? (bytes) => {
|
|
114
225
|
// Node
|
|
115
226
|
const buf = Buffer.alloc(bytes);
|
|
116
227
|
randomFillSync(buf);
|
|
@@ -371,134 +482,6 @@
|
|
|
371
482
|
};
|
|
372
483
|
}
|
|
373
484
|
|
|
374
|
-
/*! *****************************************************************************
|
|
375
|
-
Copyright (c) Microsoft Corporation.
|
|
376
|
-
|
|
377
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
378
|
-
purpose with or without fee is hereby granted.
|
|
379
|
-
|
|
380
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
381
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
382
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
383
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
384
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
385
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
386
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
387
|
-
***************************************************************************** */
|
|
388
|
-
/* global Reflect, Promise */
|
|
389
|
-
|
|
390
|
-
var extendStatics = function(d, b) {
|
|
391
|
-
extendStatics = Object.setPrototypeOf ||
|
|
392
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
393
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
394
|
-
return extendStatics(d, b);
|
|
395
|
-
};
|
|
396
|
-
|
|
397
|
-
function __extends(d, b) {
|
|
398
|
-
if (typeof b !== "function" && b !== null)
|
|
399
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
400
|
-
extendStatics(d, b);
|
|
401
|
-
function __() { this.constructor = d; }
|
|
402
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
406
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
407
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
408
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
409
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
410
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
411
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
function __generator(thisArg, body) {
|
|
416
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
417
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
418
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
419
|
-
function step(op) {
|
|
420
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
421
|
-
while (_) try {
|
|
422
|
-
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;
|
|
423
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
424
|
-
switch (op[0]) {
|
|
425
|
-
case 0: case 1: t = op; break;
|
|
426
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
427
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
428
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
429
|
-
default:
|
|
430
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
431
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
432
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
433
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
434
|
-
if (t[2]) _.ops.pop();
|
|
435
|
-
_.trys.pop(); continue;
|
|
436
|
-
}
|
|
437
|
-
op = body.call(thisArg, _);
|
|
438
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
439
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
function __values(o) {
|
|
444
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
445
|
-
if (m) return m.call(o);
|
|
446
|
-
if (o && typeof o.length === "number") return {
|
|
447
|
-
next: function () {
|
|
448
|
-
if (o && i >= o.length) o = void 0;
|
|
449
|
-
return { value: o && o[i++], done: !o };
|
|
450
|
-
}
|
|
451
|
-
};
|
|
452
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
function __read(o, n) {
|
|
456
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
457
|
-
if (!m) return o;
|
|
458
|
-
var i = m.call(o), r, ar = [], e;
|
|
459
|
-
try {
|
|
460
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
461
|
-
}
|
|
462
|
-
catch (error) { e = { error: error }; }
|
|
463
|
-
finally {
|
|
464
|
-
try {
|
|
465
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
466
|
-
}
|
|
467
|
-
finally { if (e) throw e.error; }
|
|
468
|
-
}
|
|
469
|
-
return ar;
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
function __spreadArray(to, from) {
|
|
473
|
-
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
474
|
-
to[j] = from[i];
|
|
475
|
-
return to;
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
function __await(v) {
|
|
479
|
-
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
483
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
484
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
485
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
486
|
-
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); }); }; }
|
|
487
|
-
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
488
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
489
|
-
function fulfill(value) { resume("next", value); }
|
|
490
|
-
function reject(value) { resume("throw", value); }
|
|
491
|
-
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
function __asyncValues(o) {
|
|
495
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
496
|
-
var m = o[Symbol.asyncIterator], i;
|
|
497
|
-
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);
|
|
498
|
-
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); }); }; }
|
|
499
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
500
|
-
}
|
|
501
|
-
|
|
502
485
|
var isArrayLike = (function (x) { return x && typeof x.length === 'number' && typeof x !== 'function'; });
|
|
503
486
|
|
|
504
487
|
function isPromise(value) {
|
|
@@ -539,7 +522,7 @@
|
|
|
539
522
|
this.initialTeardown = initialTeardown;
|
|
540
523
|
this.closed = false;
|
|
541
524
|
this._parentage = null;
|
|
542
|
-
this.
|
|
525
|
+
this._finalizers = null;
|
|
543
526
|
}
|
|
544
527
|
Subscription.prototype.unsubscribe = function () {
|
|
545
528
|
var e_1, _a, e_2, _b;
|
|
@@ -568,23 +551,23 @@
|
|
|
568
551
|
_parentage.remove(this);
|
|
569
552
|
}
|
|
570
553
|
}
|
|
571
|
-
var
|
|
572
|
-
if (isFunction(
|
|
554
|
+
var initialFinalizer = this.initialTeardown;
|
|
555
|
+
if (isFunction(initialFinalizer)) {
|
|
573
556
|
try {
|
|
574
|
-
|
|
557
|
+
initialFinalizer();
|
|
575
558
|
}
|
|
576
559
|
catch (e) {
|
|
577
560
|
errors = e instanceof UnsubscriptionError ? e.errors : [e];
|
|
578
561
|
}
|
|
579
562
|
}
|
|
580
|
-
var
|
|
581
|
-
if (
|
|
582
|
-
this.
|
|
563
|
+
var _finalizers = this._finalizers;
|
|
564
|
+
if (_finalizers) {
|
|
565
|
+
this._finalizers = null;
|
|
583
566
|
try {
|
|
584
|
-
for (var
|
|
585
|
-
var
|
|
567
|
+
for (var _finalizers_1 = __values(_finalizers), _finalizers_1_1 = _finalizers_1.next(); !_finalizers_1_1.done; _finalizers_1_1 = _finalizers_1.next()) {
|
|
568
|
+
var finalizer = _finalizers_1_1.value;
|
|
586
569
|
try {
|
|
587
|
-
|
|
570
|
+
execFinalizer(finalizer);
|
|
588
571
|
}
|
|
589
572
|
catch (err) {
|
|
590
573
|
errors = errors !== null && errors !== void 0 ? errors : [];
|
|
@@ -600,7 +583,7 @@
|
|
|
600
583
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
601
584
|
finally {
|
|
602
585
|
try {
|
|
603
|
-
if (
|
|
586
|
+
if (_finalizers_1_1 && !_finalizers_1_1.done && (_b = _finalizers_1.return)) _b.call(_finalizers_1);
|
|
604
587
|
}
|
|
605
588
|
finally { if (e_2) throw e_2.error; }
|
|
606
589
|
}
|
|
@@ -614,7 +597,7 @@
|
|
|
614
597
|
var _a;
|
|
615
598
|
if (teardown && teardown !== this) {
|
|
616
599
|
if (this.closed) {
|
|
617
|
-
|
|
600
|
+
execFinalizer(teardown);
|
|
618
601
|
}
|
|
619
602
|
else {
|
|
620
603
|
if (teardown instanceof Subscription) {
|
|
@@ -623,7 +606,7 @@
|
|
|
623
606
|
}
|
|
624
607
|
teardown._addParent(this);
|
|
625
608
|
}
|
|
626
|
-
(this.
|
|
609
|
+
(this._finalizers = (_a = this._finalizers) !== null && _a !== void 0 ? _a : []).push(teardown);
|
|
627
610
|
}
|
|
628
611
|
}
|
|
629
612
|
};
|
|
@@ -645,8 +628,8 @@
|
|
|
645
628
|
}
|
|
646
629
|
};
|
|
647
630
|
Subscription.prototype.remove = function (teardown) {
|
|
648
|
-
var
|
|
649
|
-
|
|
631
|
+
var _finalizers = this._finalizers;
|
|
632
|
+
_finalizers && arrRemove(_finalizers, teardown);
|
|
650
633
|
if (teardown instanceof Subscription) {
|
|
651
634
|
teardown._removeParent(this);
|
|
652
635
|
}
|
|
@@ -658,16 +641,17 @@
|
|
|
658
641
|
})();
|
|
659
642
|
return Subscription;
|
|
660
643
|
}());
|
|
644
|
+
Subscription.EMPTY;
|
|
661
645
|
function isSubscription(value) {
|
|
662
646
|
return (value instanceof Subscription ||
|
|
663
647
|
(value && 'closed' in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe)));
|
|
664
648
|
}
|
|
665
|
-
function
|
|
666
|
-
if (isFunction(
|
|
667
|
-
|
|
649
|
+
function execFinalizer(finalizer) {
|
|
650
|
+
if (isFunction(finalizer)) {
|
|
651
|
+
finalizer();
|
|
668
652
|
}
|
|
669
653
|
else {
|
|
670
|
-
|
|
654
|
+
finalizer.unsubscribe();
|
|
671
655
|
}
|
|
672
656
|
}
|
|
673
657
|
|
|
@@ -680,13 +664,16 @@
|
|
|
680
664
|
};
|
|
681
665
|
|
|
682
666
|
var timeoutProvider = {
|
|
683
|
-
setTimeout: function () {
|
|
667
|
+
setTimeout: function (handler, timeout) {
|
|
684
668
|
var args = [];
|
|
685
|
-
for (var _i =
|
|
686
|
-
args[_i] = arguments[_i];
|
|
669
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
670
|
+
args[_i - 2] = arguments[_i];
|
|
687
671
|
}
|
|
688
672
|
var delegate = timeoutProvider.delegate;
|
|
689
|
-
|
|
673
|
+
if (delegate === null || delegate === void 0 ? void 0 : delegate.setTimeout) {
|
|
674
|
+
return delegate.setTimeout.apply(delegate, __spreadArray([handler, timeout], __read(args)));
|
|
675
|
+
}
|
|
676
|
+
return setTimeout.apply(void 0, __spreadArray([handler, timeout], __read(args)));
|
|
690
677
|
},
|
|
691
678
|
clearTimeout: function (handle) {
|
|
692
679
|
var delegate = timeoutProvider.delegate;
|
|
@@ -697,7 +684,11 @@
|
|
|
697
684
|
|
|
698
685
|
function reportUnhandledError(err) {
|
|
699
686
|
timeoutProvider.setTimeout(function () {
|
|
700
|
-
|
|
687
|
+
var onUnhandledError = config.onUnhandledError;
|
|
688
|
+
if (onUnhandledError) {
|
|
689
|
+
onUnhandledError(err);
|
|
690
|
+
}
|
|
691
|
+
else {
|
|
701
692
|
throw err;
|
|
702
693
|
}
|
|
703
694
|
});
|
|
@@ -722,14 +713,22 @@
|
|
|
722
713
|
|
|
723
714
|
var context = null;
|
|
724
715
|
function errorContext(cb) {
|
|
725
|
-
{
|
|
716
|
+
if (config.useDeprecatedSynchronousErrorHandling) {
|
|
717
|
+
var isRoot = !context;
|
|
718
|
+
if (isRoot) {
|
|
719
|
+
context = { errorThrown: false, error: null };
|
|
720
|
+
}
|
|
726
721
|
cb();
|
|
722
|
+
if (isRoot) {
|
|
723
|
+
var _a = context, errorThrown = _a.errorThrown, error = _a.error;
|
|
724
|
+
context = null;
|
|
725
|
+
if (errorThrown) {
|
|
726
|
+
throw error;
|
|
727
|
+
}
|
|
728
|
+
}
|
|
727
729
|
}
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
if (config.useDeprecatedSynchronousErrorHandling && context) {
|
|
731
|
-
context.errorThrown = true;
|
|
732
|
-
context.error = err;
|
|
730
|
+
else {
|
|
731
|
+
cb();
|
|
733
732
|
}
|
|
734
733
|
}
|
|
735
734
|
|
|
@@ -806,55 +805,88 @@
|
|
|
806
805
|
};
|
|
807
806
|
return Subscriber;
|
|
808
807
|
}(Subscription));
|
|
808
|
+
var _bind = Function.prototype.bind;
|
|
809
|
+
function bind(fn, thisArg) {
|
|
810
|
+
return _bind.call(fn, thisArg);
|
|
811
|
+
}
|
|
812
|
+
var ConsumerObserver = (function () {
|
|
813
|
+
function ConsumerObserver(partialObserver) {
|
|
814
|
+
this.partialObserver = partialObserver;
|
|
815
|
+
}
|
|
816
|
+
ConsumerObserver.prototype.next = function (value) {
|
|
817
|
+
var partialObserver = this.partialObserver;
|
|
818
|
+
if (partialObserver.next) {
|
|
819
|
+
try {
|
|
820
|
+
partialObserver.next(value);
|
|
821
|
+
}
|
|
822
|
+
catch (error) {
|
|
823
|
+
handleUnhandledError(error);
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
};
|
|
827
|
+
ConsumerObserver.prototype.error = function (err) {
|
|
828
|
+
var partialObserver = this.partialObserver;
|
|
829
|
+
if (partialObserver.error) {
|
|
830
|
+
try {
|
|
831
|
+
partialObserver.error(err);
|
|
832
|
+
}
|
|
833
|
+
catch (error) {
|
|
834
|
+
handleUnhandledError(error);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
else {
|
|
838
|
+
handleUnhandledError(err);
|
|
839
|
+
}
|
|
840
|
+
};
|
|
841
|
+
ConsumerObserver.prototype.complete = function () {
|
|
842
|
+
var partialObserver = this.partialObserver;
|
|
843
|
+
if (partialObserver.complete) {
|
|
844
|
+
try {
|
|
845
|
+
partialObserver.complete();
|
|
846
|
+
}
|
|
847
|
+
catch (error) {
|
|
848
|
+
handleUnhandledError(error);
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
};
|
|
852
|
+
return ConsumerObserver;
|
|
853
|
+
}());
|
|
809
854
|
var SafeSubscriber = (function (_super) {
|
|
810
855
|
__extends(SafeSubscriber, _super);
|
|
811
856
|
function SafeSubscriber(observerOrNext, error, complete) {
|
|
812
857
|
var _this = _super.call(this) || this;
|
|
813
|
-
var
|
|
814
|
-
if (isFunction(observerOrNext)) {
|
|
815
|
-
|
|
858
|
+
var partialObserver;
|
|
859
|
+
if (isFunction(observerOrNext) || !observerOrNext) {
|
|
860
|
+
partialObserver = {
|
|
861
|
+
next: (observerOrNext !== null && observerOrNext !== void 0 ? observerOrNext : undefined),
|
|
862
|
+
error: error !== null && error !== void 0 ? error : undefined,
|
|
863
|
+
complete: complete !== null && complete !== void 0 ? complete : undefined,
|
|
864
|
+
};
|
|
816
865
|
}
|
|
817
|
-
else
|
|
818
|
-
(next = observerOrNext.next, error = observerOrNext.error, complete = observerOrNext.complete);
|
|
866
|
+
else {
|
|
819
867
|
var context_1;
|
|
820
868
|
if (_this && config.useDeprecatedNextContext) {
|
|
821
869
|
context_1 = Object.create(observerOrNext);
|
|
822
870
|
context_1.unsubscribe = function () { return _this.unsubscribe(); };
|
|
871
|
+
partialObserver = {
|
|
872
|
+
next: observerOrNext.next && bind(observerOrNext.next, context_1),
|
|
873
|
+
error: observerOrNext.error && bind(observerOrNext.error, context_1),
|
|
874
|
+
complete: observerOrNext.complete && bind(observerOrNext.complete, context_1),
|
|
875
|
+
};
|
|
823
876
|
}
|
|
824
877
|
else {
|
|
825
|
-
|
|
878
|
+
partialObserver = observerOrNext;
|
|
826
879
|
}
|
|
827
|
-
next = next === null || next === void 0 ? void 0 : next.bind(context_1);
|
|
828
|
-
error = error === null || error === void 0 ? void 0 : error.bind(context_1);
|
|
829
|
-
complete = complete === null || complete === void 0 ? void 0 : complete.bind(context_1);
|
|
830
880
|
}
|
|
831
|
-
_this.destination =
|
|
832
|
-
next: next ? wrapForErrorHandling(next) : noop,
|
|
833
|
-
error: wrapForErrorHandling(error !== null && error !== void 0 ? error : defaultErrorHandler),
|
|
834
|
-
complete: complete ? wrapForErrorHandling(complete) : noop,
|
|
835
|
-
};
|
|
881
|
+
_this.destination = new ConsumerObserver(partialObserver);
|
|
836
882
|
return _this;
|
|
837
883
|
}
|
|
838
884
|
return SafeSubscriber;
|
|
839
885
|
}(Subscriber));
|
|
840
|
-
function
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
args[_i] = arguments[_i];
|
|
845
|
-
}
|
|
846
|
-
try {
|
|
847
|
-
handler.apply(void 0, __spreadArray([], __read(args)));
|
|
848
|
-
}
|
|
849
|
-
catch (err) {
|
|
850
|
-
if (config.useDeprecatedSynchronousErrorHandling) {
|
|
851
|
-
captureError(err);
|
|
852
|
-
}
|
|
853
|
-
else {
|
|
854
|
-
reportUnhandledError(err);
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
};
|
|
886
|
+
function handleUnhandledError(error) {
|
|
887
|
+
{
|
|
888
|
+
reportUnhandledError(error);
|
|
889
|
+
}
|
|
858
890
|
}
|
|
859
891
|
function defaultErrorHandler(err) {
|
|
860
892
|
throw err;
|
|
@@ -928,16 +960,20 @@
|
|
|
928
960
|
var _this = this;
|
|
929
961
|
promiseCtor = getPromiseCtor(promiseCtor);
|
|
930
962
|
return new promiseCtor(function (resolve, reject) {
|
|
931
|
-
var
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
963
|
+
var subscriber = new SafeSubscriber({
|
|
964
|
+
next: function (value) {
|
|
965
|
+
try {
|
|
966
|
+
next(value);
|
|
967
|
+
}
|
|
968
|
+
catch (err) {
|
|
969
|
+
reject(err);
|
|
970
|
+
subscriber.unsubscribe();
|
|
971
|
+
}
|
|
972
|
+
},
|
|
973
|
+
error: reject,
|
|
974
|
+
complete: resolve,
|
|
975
|
+
});
|
|
976
|
+
_this.subscribe(subscriber);
|
|
941
977
|
});
|
|
942
978
|
};
|
|
943
979
|
Observable.prototype._subscribe = function (subscriber) {
|
|
@@ -1169,11 +1205,15 @@
|
|
|
1169
1205
|
});
|
|
1170
1206
|
}
|
|
1171
1207
|
|
|
1208
|
+
function createOperatorSubscriber(destination, onNext, onComplete, onError, onFinalize) {
|
|
1209
|
+
return new OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize);
|
|
1210
|
+
}
|
|
1172
1211
|
var OperatorSubscriber = (function (_super) {
|
|
1173
1212
|
__extends(OperatorSubscriber, _super);
|
|
1174
|
-
function OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize) {
|
|
1213
|
+
function OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize, shouldUnsubscribe) {
|
|
1175
1214
|
var _this = _super.call(this, destination) || this;
|
|
1176
1215
|
_this.onFinalize = onFinalize;
|
|
1216
|
+
_this.shouldUnsubscribe = shouldUnsubscribe;
|
|
1177
1217
|
_this._next = onNext
|
|
1178
1218
|
? function (value) {
|
|
1179
1219
|
try {
|
|
@@ -1214,9 +1254,11 @@
|
|
|
1214
1254
|
}
|
|
1215
1255
|
OperatorSubscriber.prototype.unsubscribe = function () {
|
|
1216
1256
|
var _a;
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1257
|
+
if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {
|
|
1258
|
+
var closed_1 = this.closed;
|
|
1259
|
+
_super.prototype.unsubscribe.call(this);
|
|
1260
|
+
!closed_1 && ((_a = this.onFinalize) === null || _a === void 0 ? void 0 : _a.call(this));
|
|
1261
|
+
}
|
|
1220
1262
|
};
|
|
1221
1263
|
return OperatorSubscriber;
|
|
1222
1264
|
}(Subscriber));
|
|
@@ -1233,13 +1275,16 @@
|
|
|
1233
1275
|
}(Subscription));
|
|
1234
1276
|
|
|
1235
1277
|
var intervalProvider = {
|
|
1236
|
-
setInterval: function () {
|
|
1278
|
+
setInterval: function (handler, timeout) {
|
|
1237
1279
|
var args = [];
|
|
1238
|
-
for (var _i =
|
|
1239
|
-
args[_i] = arguments[_i];
|
|
1280
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1281
|
+
args[_i - 2] = arguments[_i];
|
|
1240
1282
|
}
|
|
1241
1283
|
var delegate = intervalProvider.delegate;
|
|
1242
|
-
|
|
1284
|
+
if (delegate === null || delegate === void 0 ? void 0 : delegate.setInterval) {
|
|
1285
|
+
return delegate.setInterval.apply(delegate, __spreadArray([handler, timeout], __read(args)));
|
|
1286
|
+
}
|
|
1287
|
+
return setInterval.apply(void 0, __spreadArray([handler, timeout], __read(args)));
|
|
1243
1288
|
},
|
|
1244
1289
|
clearInterval: function (handle) {
|
|
1245
1290
|
var delegate = intervalProvider.delegate;
|
|
@@ -1458,7 +1503,7 @@
|
|
|
1458
1503
|
var innerSub = null;
|
|
1459
1504
|
var syncUnsub = false;
|
|
1460
1505
|
var handledResult;
|
|
1461
|
-
innerSub = source.subscribe(
|
|
1506
|
+
innerSub = source.subscribe(createOperatorSubscriber(subscriber, undefined, undefined, function (err) {
|
|
1462
1507
|
handledResult = innerFrom(selector(err, catchError(selector)(source)));
|
|
1463
1508
|
if (innerSub) {
|
|
1464
1509
|
innerSub.unsubscribe();
|
|
@@ -1480,7 +1525,7 @@
|
|
|
1480
1525
|
function observeOn(scheduler, delay) {
|
|
1481
1526
|
if (delay === void 0) { delay = 0; }
|
|
1482
1527
|
return operate(function (source, subscriber) {
|
|
1483
|
-
source.subscribe(
|
|
1528
|
+
source.subscribe(createOperatorSubscriber(subscriber, function (value) { return executeSchedule(subscriber, scheduler, function () { return subscriber.next(value); }, delay); }, function () { return executeSchedule(subscriber, scheduler, function () { return subscriber.complete(); }, delay); }, function (err) { return executeSchedule(subscriber, scheduler, function () { return subscriber.error(err); }, delay); }));
|
|
1484
1529
|
});
|
|
1485
1530
|
}
|
|
1486
1531
|
|
|
@@ -1600,13 +1645,13 @@
|
|
|
1600
1645
|
function map(project, thisArg) {
|
|
1601
1646
|
return operate(function (source, subscriber) {
|
|
1602
1647
|
var index = 0;
|
|
1603
|
-
source.subscribe(
|
|
1648
|
+
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1604
1649
|
subscriber.next(project.call(thisArg, value, index++));
|
|
1605
1650
|
}));
|
|
1606
1651
|
});
|
|
1607
1652
|
}
|
|
1608
1653
|
|
|
1609
|
-
function mergeInternals(source, subscriber, project, concurrent, onBeforeNext, expand, innerSubScheduler,
|
|
1654
|
+
function mergeInternals(source, subscriber, project, concurrent, onBeforeNext, expand, innerSubScheduler, additionalFinalizer) {
|
|
1610
1655
|
var buffer = [];
|
|
1611
1656
|
var active = 0;
|
|
1612
1657
|
var index = 0;
|
|
@@ -1621,7 +1666,7 @@
|
|
|
1621
1666
|
expand && subscriber.next(value);
|
|
1622
1667
|
active++;
|
|
1623
1668
|
var innerComplete = false;
|
|
1624
|
-
innerFrom(project(value, index++)).subscribe(
|
|
1669
|
+
innerFrom(project(value, index++)).subscribe(createOperatorSubscriber(subscriber, function (innerValue) {
|
|
1625
1670
|
onBeforeNext === null || onBeforeNext === void 0 ? void 0 : onBeforeNext(innerValue);
|
|
1626
1671
|
if (expand) {
|
|
1627
1672
|
outerNext(innerValue);
|
|
@@ -1655,12 +1700,12 @@
|
|
|
1655
1700
|
}
|
|
1656
1701
|
}));
|
|
1657
1702
|
};
|
|
1658
|
-
source.subscribe(
|
|
1703
|
+
source.subscribe(createOperatorSubscriber(subscriber, outerNext, function () {
|
|
1659
1704
|
isComplete = true;
|
|
1660
1705
|
checkComplete();
|
|
1661
1706
|
}));
|
|
1662
1707
|
return function () {
|
|
1663
|
-
|
|
1708
|
+
additionalFinalizer === null || additionalFinalizer === void 0 ? void 0 : additionalFinalizer();
|
|
1664
1709
|
};
|
|
1665
1710
|
}
|
|
1666
1711
|
|
|
@@ -1709,7 +1754,7 @@
|
|
|
1709
1754
|
}
|
|
1710
1755
|
emit();
|
|
1711
1756
|
}
|
|
1712
|
-
source.subscribe(
|
|
1757
|
+
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1713
1758
|
lastValue = value;
|
|
1714
1759
|
lastTime = scheduler.now();
|
|
1715
1760
|
if (!activeTask) {
|
|
@@ -1741,7 +1786,7 @@
|
|
|
1741
1786
|
function () { return EMPTY; }
|
|
1742
1787
|
: operate(function (source, subscriber) {
|
|
1743
1788
|
var seen = 0;
|
|
1744
|
-
source.subscribe(
|
|
1789
|
+
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1745
1790
|
if (++seen <= count) {
|
|
1746
1791
|
subscriber.next(value);
|
|
1747
1792
|
if (count <= seen) {
|
|
@@ -1754,7 +1799,7 @@
|
|
|
1754
1799
|
|
|
1755
1800
|
function ignoreElements() {
|
|
1756
1801
|
return operate(function (source, subscriber) {
|
|
1757
|
-
source.subscribe(
|
|
1802
|
+
source.subscribe(createOperatorSubscriber(subscriber, noop));
|
|
1758
1803
|
});
|
|
1759
1804
|
}
|
|
1760
1805
|
|
|
@@ -1783,7 +1828,7 @@
|
|
|
1783
1828
|
return operate(function (source, subscriber) {
|
|
1784
1829
|
var previousKey;
|
|
1785
1830
|
var first = true;
|
|
1786
|
-
source.subscribe(
|
|
1831
|
+
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1787
1832
|
var currentKey = keySelector(value);
|
|
1788
1833
|
if (first || !comparator(previousKey, currentKey)) {
|
|
1789
1834
|
first = false;
|
|
@@ -1800,7 +1845,7 @@
|
|
|
1800
1845
|
function filter(predicate, thisArg) {
|
|
1801
1846
|
return operate(function (source, subscriber) {
|
|
1802
1847
|
var index = 0;
|
|
1803
|
-
source.subscribe(
|
|
1848
|
+
source.subscribe(createOperatorSubscriber(subscriber, function (value) { return predicate.call(thisArg, value, index++) && subscriber.next(value); }));
|
|
1804
1849
|
});
|
|
1805
1850
|
}
|
|
1806
1851
|
|
|
@@ -1825,11 +1870,11 @@
|
|
|
1825
1870
|
var index = 0;
|
|
1826
1871
|
var isComplete = false;
|
|
1827
1872
|
var checkComplete = function () { return isComplete && !innerSubscriber && subscriber.complete(); };
|
|
1828
|
-
source.subscribe(
|
|
1873
|
+
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1829
1874
|
innerSubscriber === null || innerSubscriber === void 0 ? void 0 : innerSubscriber.unsubscribe();
|
|
1830
1875
|
var innerIndex = 0;
|
|
1831
1876
|
var outerIndex = index++;
|
|
1832
|
-
innerFrom(project(value, outerIndex)).subscribe((innerSubscriber =
|
|
1877
|
+
innerFrom(project(value, outerIndex)).subscribe((innerSubscriber = createOperatorSubscriber(subscriber, function (innerValue) { return subscriber.next(resultSelector ? resultSelector(value, innerValue, outerIndex, innerIndex++) : innerValue); }, function () {
|
|
1833
1878
|
innerSubscriber = null;
|
|
1834
1879
|
checkComplete();
|
|
1835
1880
|
})));
|
|
@@ -1850,7 +1895,7 @@
|
|
|
1850
1895
|
var _a;
|
|
1851
1896
|
(_a = tapObserver.subscribe) === null || _a === void 0 ? void 0 : _a.call(tapObserver);
|
|
1852
1897
|
var isUnsub = true;
|
|
1853
|
-
source.subscribe(
|
|
1898
|
+
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1854
1899
|
var _a;
|
|
1855
1900
|
(_a = tapObserver.next) === null || _a === void 0 ? void 0 : _a.call(tapObserver, value);
|
|
1856
1901
|
subscriber.next(value);
|
|
@@ -1886,11 +1931,7 @@
|
|
|
1886
1931
|
};
|
|
1887
1932
|
});
|
|
1888
1933
|
function timeout(config, schedulerArg) {
|
|
1889
|
-
var _a = (isValidDate(config)
|
|
1890
|
-
? { first: config }
|
|
1891
|
-
: typeof config === 'number'
|
|
1892
|
-
? { each: config }
|
|
1893
|
-
: 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;
|
|
1934
|
+
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;
|
|
1894
1935
|
if (first == null && each == null) {
|
|
1895
1936
|
throw new TypeError('No timeout provided.');
|
|
1896
1937
|
}
|
|
@@ -1914,7 +1955,7 @@
|
|
|
1914
1955
|
}
|
|
1915
1956
|
}, delay);
|
|
1916
1957
|
};
|
|
1917
|
-
originalSourceSubscription = source.subscribe(
|
|
1958
|
+
originalSourceSubscription = source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1918
1959
|
timerSubscription === null || timerSubscription === void 0 ? void 0 : timerSubscription.unsubscribe();
|
|
1919
1960
|
seen++;
|
|
1920
1961
|
subscriber.next((lastValue = value));
|
|
@@ -1925,7 +1966,7 @@
|
|
|
1925
1966
|
}
|
|
1926
1967
|
lastValue = null;
|
|
1927
1968
|
}));
|
|
1928
|
-
startTimer(first != null ? (typeof first === 'number' ? first : +first - scheduler.now()) : each);
|
|
1969
|
+
!seen && startTimer(first != null ? (typeof first === 'number' ? first : +first - scheduler.now()) : each);
|
|
1929
1970
|
});
|
|
1930
1971
|
}
|
|
1931
1972
|
function timeoutErrorFactory(info) {
|
|
@@ -1935,7 +1976,7 @@
|
|
|
1935
1976
|
//const hasSW = 'serviceWorker' in navigator;
|
|
1936
1977
|
let hasComplainedAboutSyncEvent = false;
|
|
1937
1978
|
function registerSyncEvent(db, purpose) {
|
|
1938
|
-
return __awaiter
|
|
1979
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1939
1980
|
try {
|
|
1940
1981
|
// Send sync event to SW:
|
|
1941
1982
|
const sw = yield navigator.serviceWorker.ready;
|
|
@@ -1966,7 +2007,7 @@
|
|
|
1966
2007
|
}
|
|
1967
2008
|
function registerPeriodicSyncEvent(db) {
|
|
1968
2009
|
var _a;
|
|
1969
|
-
return __awaiter
|
|
2010
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1970
2011
|
try {
|
|
1971
2012
|
// Register periodicSync event to SW:
|
|
1972
2013
|
// @ts-ignore
|
|
@@ -2024,15 +2065,12 @@
|
|
|
2024
2065
|
};
|
|
2025
2066
|
|
|
2026
2067
|
function interactWithUser(userInteraction, req) {
|
|
2027
|
-
let done = false;
|
|
2028
2068
|
return new Promise((resolve, reject) => {
|
|
2029
2069
|
const interactionProps = Object.assign(Object.assign({}, req), { onSubmit: (res) => {
|
|
2030
2070
|
userInteraction.next(undefined);
|
|
2031
|
-
done = true;
|
|
2032
2071
|
resolve(res);
|
|
2033
2072
|
}, onCancel: () => {
|
|
2034
2073
|
userInteraction.next(undefined);
|
|
2035
|
-
done = true;
|
|
2036
2074
|
reject(new Dexie__default["default"].AbortError("User cancelled"));
|
|
2037
2075
|
} });
|
|
2038
2076
|
userInteraction.next(interactionProps);
|
|
@@ -2056,7 +2094,7 @@
|
|
|
2056
2094
|
});
|
|
2057
2095
|
}
|
|
2058
2096
|
function promptForEmail(userInteraction, title, emailHint) {
|
|
2059
|
-
return __awaiter
|
|
2097
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2060
2098
|
let email = emailHint || '';
|
|
2061
2099
|
while (!email || !/^[\w-\.]+@([\w-]+\.)+[\w-]{2,10}$/.test(email)) {
|
|
2062
2100
|
email = (yield interactWithUser(userInteraction, {
|
|
@@ -2084,7 +2122,7 @@
|
|
|
2084
2122
|
});
|
|
2085
2123
|
}
|
|
2086
2124
|
function promptForOTP(userInteraction, email, alert) {
|
|
2087
|
-
return __awaiter
|
|
2125
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2088
2126
|
const alerts = [
|
|
2089
2127
|
{
|
|
2090
2128
|
type: 'info',
|
|
@@ -2114,7 +2152,7 @@
|
|
|
2114
2152
|
|
|
2115
2153
|
function loadAccessToken(db) {
|
|
2116
2154
|
var _a, _b;
|
|
2117
|
-
return __awaiter
|
|
2155
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2118
2156
|
const currentUser = yield db.getCurrentUser();
|
|
2119
2157
|
const { accessToken, accessTokenExpiration, refreshToken, refreshTokenExpiration, claims, } = currentUser;
|
|
2120
2158
|
if (!accessToken)
|
|
@@ -2139,7 +2177,7 @@
|
|
|
2139
2177
|
});
|
|
2140
2178
|
}
|
|
2141
2179
|
function authenticate(url, context, fetchToken, userInteraction, hints) {
|
|
2142
|
-
return __awaiter
|
|
2180
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2143
2181
|
if (context.accessToken &&
|
|
2144
2182
|
context.accessTokenExpiration.getTime() > Date.now()) {
|
|
2145
2183
|
return context;
|
|
@@ -2155,7 +2193,7 @@
|
|
|
2155
2193
|
});
|
|
2156
2194
|
}
|
|
2157
2195
|
function refreshAccessToken(url, login) {
|
|
2158
|
-
return __awaiter
|
|
2196
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2159
2197
|
if (!login.refreshToken)
|
|
2160
2198
|
throw new Error(`Cannot refresh token - refresh token is missing.`);
|
|
2161
2199
|
if (!login.nonExportablePrivateKey)
|
|
@@ -2191,7 +2229,7 @@
|
|
|
2191
2229
|
});
|
|
2192
2230
|
}
|
|
2193
2231
|
function userAuthenticate(context, fetchToken, userInteraction, hints) {
|
|
2194
|
-
return __awaiter
|
|
2232
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2195
2233
|
const { privateKey, publicKey } = yield crypto.subtle.generateKey({
|
|
2196
2234
|
name: 'RSASSA-PKCS1-v1_5',
|
|
2197
2235
|
modulusLength: 2048,
|
|
@@ -2278,7 +2316,7 @@
|
|
|
2278
2316
|
}));
|
|
2279
2317
|
}
|
|
2280
2318
|
save() {
|
|
2281
|
-
return __awaiter
|
|
2319
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2282
2320
|
const db = wm$1.get(this);
|
|
2283
2321
|
db.table("$logins").put(this);
|
|
2284
2322
|
});
|
|
@@ -2299,7 +2337,7 @@
|
|
|
2299
2337
|
const { userInteraction } = db.cloud;
|
|
2300
2338
|
return function otpAuthenticate({ public_key, hints }) {
|
|
2301
2339
|
var _a;
|
|
2302
|
-
return __awaiter
|
|
2340
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2303
2341
|
let tokenRequest;
|
|
2304
2342
|
const url = (_a = db.cloud.options) === null || _a === void 0 ? void 0 : _a.databaseUrl;
|
|
2305
2343
|
if (!url)
|
|
@@ -2401,11 +2439,11 @@
|
|
|
2401
2439
|
* @param newUser
|
|
2402
2440
|
*/
|
|
2403
2441
|
function setCurrentUser(db, user) {
|
|
2404
|
-
return __awaiter
|
|
2442
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2405
2443
|
if (user.userId === db.cloud.currentUserId)
|
|
2406
2444
|
return; // Already this user.
|
|
2407
2445
|
const $logins = db.table('$logins');
|
|
2408
|
-
yield db.transaction('rw', $logins, (tx) => __awaiter
|
|
2446
|
+
yield db.transaction('rw', $logins, (tx) => __awaiter(this, void 0, void 0, function* () {
|
|
2409
2447
|
const existingLogins = yield $logins.toArray();
|
|
2410
2448
|
yield Promise.all(existingLogins
|
|
2411
2449
|
.filter((login) => login.userId !== user.userId && login.isLoggedIn)
|
|
@@ -2456,7 +2494,7 @@
|
|
|
2456
2494
|
}
|
|
2457
2495
|
|
|
2458
2496
|
function login(db, hints) {
|
|
2459
|
-
return __awaiter
|
|
2497
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2460
2498
|
const currentUser = yield db.getCurrentUser();
|
|
2461
2499
|
if (currentUser.isLoggedIn) {
|
|
2462
2500
|
if (hints) {
|
|
@@ -2589,7 +2627,7 @@
|
|
|
2589
2627
|
}
|
|
2590
2628
|
|
|
2591
2629
|
function computeRealmSetHash({ realms, inviteRealms, }) {
|
|
2592
|
-
return __awaiter
|
|
2630
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2593
2631
|
const data = JSON.stringify([
|
|
2594
2632
|
...realms.map((realmId) => ({ realmId, accepted: true })),
|
|
2595
2633
|
...inviteRealms.map((realmId) => ({ realmId, accepted: false })),
|
|
@@ -2626,8 +2664,8 @@
|
|
|
2626
2664
|
}
|
|
2627
2665
|
|
|
2628
2666
|
function listClientChanges(mutationTables, db, { since = {}, limit = Infinity } = {}) {
|
|
2629
|
-
return __awaiter
|
|
2630
|
-
const allMutsOnTables = yield Promise.all(mutationTables.map((mutationTable) => __awaiter
|
|
2667
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2668
|
+
const allMutsOnTables = yield Promise.all(mutationTables.map((mutationTable) => __awaiter(this, void 0, void 0, function* () {
|
|
2631
2669
|
const tableName = getTableFromMutationTable(mutationTable.name);
|
|
2632
2670
|
const lastRevision = since[tableName];
|
|
2633
2671
|
let query = lastRevision
|
|
@@ -2679,28 +2717,28 @@
|
|
|
2679
2717
|
}
|
|
2680
2718
|
|
|
2681
2719
|
function listSyncifiedChanges(tablesToSyncify, currentUser, schema, alreadySyncedRealms) {
|
|
2682
|
-
return __awaiter
|
|
2720
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2683
2721
|
const txid = `upload-${randomString(8)}`;
|
|
2684
2722
|
if (currentUser.isLoggedIn) {
|
|
2685
2723
|
if (tablesToSyncify.length > 0) {
|
|
2686
2724
|
const ignoredRealms = new Set(alreadySyncedRealms || []);
|
|
2687
|
-
const upserts = yield Promise.all(tablesToSyncify.map((table) => __awaiter
|
|
2725
|
+
const upserts = yield Promise.all(tablesToSyncify.map((table) => __awaiter(this, void 0, void 0, function* () {
|
|
2688
2726
|
const { extractKey } = table.core.schema.primaryKey;
|
|
2689
2727
|
if (!extractKey)
|
|
2690
2728
|
return { table: table.name, muts: [] }; // Outbound tables are not synced.
|
|
2691
2729
|
const dexieCloudTableSchema = schema[table.name];
|
|
2692
2730
|
const query = (dexieCloudTableSchema === null || dexieCloudTableSchema === void 0 ? void 0 : dexieCloudTableSchema.generatedGlobalId)
|
|
2693
2731
|
? table.filter((item) => {
|
|
2694
|
-
|
|
2732
|
+
extractKey(item);
|
|
2695
2733
|
return (!ignoredRealms.has(item.realmId || '') &&
|
|
2696
2734
|
//(id[0] !== '#' || !!item.$ts) && // Private obj need no sync if not changed
|
|
2697
|
-
|
|
2735
|
+
isValidAtID(extractKey(item), dexieCloudTableSchema === null || dexieCloudTableSchema === void 0 ? void 0 : dexieCloudTableSchema.idPrefix));
|
|
2698
2736
|
})
|
|
2699
2737
|
: table.filter((item) => {
|
|
2700
|
-
extractKey(item);
|
|
2738
|
+
const id = extractKey(item);
|
|
2701
2739
|
return (!ignoredRealms.has(item.realmId || '') &&
|
|
2702
2740
|
//(id[0] !== '#' || !!item.$ts) && // Private obj need no sync if not changed
|
|
2703
|
-
|
|
2741
|
+
isValidSyncableID(id));
|
|
2704
2742
|
});
|
|
2705
2743
|
const unsyncedObjects = yield query.toArray();
|
|
2706
2744
|
if (unsyncedObjects.length > 0) {
|
|
@@ -3319,7 +3357,7 @@
|
|
|
3319
3357
|
|
|
3320
3358
|
//import {BisonWebStreamReader} from "dreambase-library/dist/typeson-simplified/BisonWebStreamReader";
|
|
3321
3359
|
function syncWithServer(changes, syncState, baseRevs, db, databaseUrl, schema, clientIdentity, currentUser) {
|
|
3322
|
-
return __awaiter
|
|
3360
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3323
3361
|
//
|
|
3324
3362
|
// Push changes to server using fetch
|
|
3325
3363
|
//
|
|
@@ -3375,7 +3413,7 @@
|
|
|
3375
3413
|
}
|
|
3376
3414
|
|
|
3377
3415
|
function modifyLocalObjectsWithNewUserId(syncifiedTables, currentUser, alreadySyncedRealms) {
|
|
3378
|
-
return __awaiter
|
|
3416
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3379
3417
|
const ignoredRealms = new Set(alreadySyncedRealms || []);
|
|
3380
3418
|
for (const table of syncifiedTables) {
|
|
3381
3419
|
if (table.name === "members") {
|
|
@@ -3425,7 +3463,7 @@
|
|
|
3425
3463
|
self.addEventListener('offline', () => isOnline = false);
|
|
3426
3464
|
|
|
3427
3465
|
function updateBaseRevs(db, schema, latestRevisions, serverRev) {
|
|
3428
|
-
return __awaiter
|
|
3466
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3429
3467
|
yield db.$baseRevs.bulkPut(Object.keys(schema)
|
|
3430
3468
|
.filter((table) => schema[table].markedForSync)
|
|
3431
3469
|
.map((tableName) => {
|
|
@@ -3448,7 +3486,7 @@
|
|
|
3448
3486
|
}
|
|
3449
3487
|
|
|
3450
3488
|
function bulkUpdate(table, keys, changeSpecs) {
|
|
3451
|
-
return __awaiter
|
|
3489
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3452
3490
|
const objs = yield table.bulkGet(keys);
|
|
3453
3491
|
const resultKeys = [];
|
|
3454
3492
|
const resultObjs = [];
|
|
@@ -3476,7 +3514,7 @@
|
|
|
3476
3514
|
}
|
|
3477
3515
|
|
|
3478
3516
|
function applyServerChanges(changes, db) {
|
|
3479
|
-
return __awaiter
|
|
3517
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3480
3518
|
console.debug('Applying server changes', changes, Dexie__default["default"].currentTransaction);
|
|
3481
3519
|
for (const { table: tableName, muts } of changes) {
|
|
3482
3520
|
const table = db.table(tableName);
|
|
@@ -3562,7 +3600,7 @@
|
|
|
3562
3600
|
});
|
|
3563
3601
|
}
|
|
3564
3602
|
})
|
|
3565
|
-
.catch((error) => __awaiter
|
|
3603
|
+
.catch((error) => __awaiter(this, void 0, void 0, function* () {
|
|
3566
3604
|
if (syncOptions === null || syncOptions === void 0 ? void 0 : syncOptions.justCheckIfNeeded)
|
|
3567
3605
|
return Promise.reject(error); // Just rethrow.
|
|
3568
3606
|
console.debug('Error from _sync', {
|
|
@@ -3599,7 +3637,7 @@
|
|
|
3599
3637
|
isInitialSync: false,
|
|
3600
3638
|
}) {
|
|
3601
3639
|
var _a;
|
|
3602
|
-
return __awaiter
|
|
3640
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3603
3641
|
if (!justCheckIfNeeded) {
|
|
3604
3642
|
console.debug('SYNC STARTED', { isInitialSync, purpose });
|
|
3605
3643
|
}
|
|
@@ -3616,7 +3654,8 @@
|
|
|
3616
3654
|
// Prepare for syncification by modifying locally unauthorized objects:
|
|
3617
3655
|
//
|
|
3618
3656
|
const persistedSyncState = yield db.getPersistedSyncState();
|
|
3619
|
-
const
|
|
3657
|
+
const readyForSyncification = !isInitialSync && currentUser.isLoggedIn;
|
|
3658
|
+
const tablesToSyncify = readyForSyncification
|
|
3620
3659
|
? getTablesToSyncify(db, persistedSyncState)
|
|
3621
3660
|
: [];
|
|
3622
3661
|
throwIfCancelled(cancelToken);
|
|
@@ -3625,7 +3664,7 @@
|
|
|
3625
3664
|
if (justCheckIfNeeded)
|
|
3626
3665
|
return true;
|
|
3627
3666
|
//console.debug('sync doSyncify is true');
|
|
3628
|
-
yield db.transaction('rw', tablesToSyncify, (tx) => __awaiter
|
|
3667
|
+
yield db.transaction('rw', tablesToSyncify, (tx) => __awaiter(this, void 0, void 0, function* () {
|
|
3629
3668
|
// @ts-ignore
|
|
3630
3669
|
tx.idbtrans.disableChangeTracking = true;
|
|
3631
3670
|
// @ts-ignore
|
|
@@ -3637,7 +3676,7 @@
|
|
|
3637
3676
|
//
|
|
3638
3677
|
// List changes to sync
|
|
3639
3678
|
//
|
|
3640
|
-
const [clientChangeSet, syncState, baseRevs] = yield db.transaction('r', db.tables, () => __awaiter
|
|
3679
|
+
const [clientChangeSet, syncState, baseRevs] = yield db.transaction('r', db.tables, () => __awaiter(this, void 0, void 0, function* () {
|
|
3641
3680
|
const syncState = yield db.getPersistedSyncState();
|
|
3642
3681
|
const baseRevs = yield db.$baseRevs.toArray();
|
|
3643
3682
|
let clientChanges = yield listClientChanges(mutationTables);
|
|
@@ -3674,7 +3713,7 @@
|
|
|
3674
3713
|
//
|
|
3675
3714
|
// Apply changes locally and clear old change entries:
|
|
3676
3715
|
//
|
|
3677
|
-
const done = yield db.transaction('rw', db.tables, (tx) => __awaiter
|
|
3716
|
+
const done = yield db.transaction('rw', db.tables, (tx) => __awaiter(this, void 0, void 0, function* () {
|
|
3678
3717
|
// @ts-ignore
|
|
3679
3718
|
tx.idbtrans.disableChangeTracking = true;
|
|
3680
3719
|
// @ts-ignore
|
|
@@ -3748,9 +3787,11 @@
|
|
|
3748
3787
|
inviteRealms: [],
|
|
3749
3788
|
clientIdentity,
|
|
3750
3789
|
};
|
|
3751
|
-
|
|
3752
|
-
.
|
|
3753
|
-
|
|
3790
|
+
if (readyForSyncification) {
|
|
3791
|
+
newSyncState.syncedTables = tablesToSync
|
|
3792
|
+
.map((tbl) => tbl.name)
|
|
3793
|
+
.concat(tablesToSyncify.map((tbl) => tbl.name));
|
|
3794
|
+
}
|
|
3754
3795
|
newSyncState.latestRevisions = latestRevisions;
|
|
3755
3796
|
newSyncState.remoteDbId = res.dbId;
|
|
3756
3797
|
newSyncState.initiallySynced = true;
|
|
@@ -3779,7 +3820,7 @@
|
|
|
3779
3820
|
});
|
|
3780
3821
|
}
|
|
3781
3822
|
function deleteObjectsFromRemovedRealms(db, res, prevState) {
|
|
3782
|
-
return __awaiter
|
|
3823
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3783
3824
|
const deletedRealms = new Set();
|
|
3784
3825
|
const rejectedRealms = new Set();
|
|
3785
3826
|
const previousRealmSet = prevState ? prevState.realms : [];
|
|
@@ -3843,7 +3884,7 @@
|
|
|
3843
3884
|
let isWorking = false;
|
|
3844
3885
|
let loopWarning = 0;
|
|
3845
3886
|
let loopDetection = [0, 0, 0, 0, 0, 0, 0, 0, 0, Date.now()];
|
|
3846
|
-
event.subscribe(() => __awaiter
|
|
3887
|
+
event.subscribe(() => __awaiter(this, void 0, void 0, function* () {
|
|
3847
3888
|
if (isWorking)
|
|
3848
3889
|
return;
|
|
3849
3890
|
if (queue.length > 0) {
|
|
@@ -3882,7 +3923,7 @@
|
|
|
3882
3923
|
}
|
|
3883
3924
|
function consumeQueue() {
|
|
3884
3925
|
var _a, _b, _c;
|
|
3885
|
-
return __awaiter
|
|
3926
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3886
3927
|
while (queue.length > 0) {
|
|
3887
3928
|
const msg = queue.shift();
|
|
3888
3929
|
try {
|
|
@@ -3939,7 +3980,7 @@
|
|
|
3939
3980
|
triggerSync(db, 'pull');
|
|
3940
3981
|
break;
|
|
3941
3982
|
}
|
|
3942
|
-
yield db.transaction('rw', db.dx.tables, (tx) => __awaiter
|
|
3983
|
+
yield db.transaction('rw', db.dx.tables, (tx) => __awaiter(this, void 0, void 0, function* () {
|
|
3943
3984
|
// @ts-ignore
|
|
3944
3985
|
tx.idbtrans.disableChangeTracking = true;
|
|
3945
3986
|
// @ts-ignore
|
|
@@ -4700,7 +4741,7 @@
|
|
|
4700
4741
|
}
|
|
4701
4742
|
|
|
4702
4743
|
function performInitialSync(db, cloudOptions, cloudSchema) {
|
|
4703
|
-
return __awaiter
|
|
4744
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4704
4745
|
console.debug('Performing initial sync');
|
|
4705
4746
|
yield sync(db, cloudOptions, cloudSchema, { isInitialSync: true });
|
|
4706
4747
|
console.debug('Done initial sync');
|
|
@@ -4843,7 +4884,7 @@
|
|
|
4843
4884
|
.then(() => (this.reconnecting = false)); // finally()
|
|
4844
4885
|
}
|
|
4845
4886
|
connect() {
|
|
4846
|
-
return __awaiter
|
|
4887
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4847
4888
|
this.lastServerActivity = new Date();
|
|
4848
4889
|
if (this.pauseUntil && this.pauseUntil > new Date()) {
|
|
4849
4890
|
console.debug('WS not reconnecting just yet', {
|
|
@@ -4866,7 +4907,7 @@
|
|
|
4866
4907
|
return;
|
|
4867
4908
|
}
|
|
4868
4909
|
this.webSocketStatus.next('connecting');
|
|
4869
|
-
this.pinger = setInterval(() => __awaiter
|
|
4910
|
+
this.pinger = setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
|
4870
4911
|
if (this.closed) {
|
|
4871
4912
|
console.debug('pinger check', this.id, 'CLOSED.');
|
|
4872
4913
|
this.teardown();
|
|
@@ -4992,7 +5033,7 @@
|
|
|
4992
5033
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
4993
5034
|
}
|
|
4994
5035
|
function waitAndReconnectWhenUserDoesSomething(error) {
|
|
4995
|
-
return __awaiter
|
|
5036
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4996
5037
|
console.error(`WebSocket observable: error but revive when user does some active thing...`, error);
|
|
4997
5038
|
// Sleep some seconds...
|
|
4998
5039
|
yield sleep(3000);
|
|
@@ -5018,7 +5059,7 @@
|
|
|
5018
5059
|
function createObservable() {
|
|
5019
5060
|
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.
|
|
5020
5061
|
take(1), // Don't continue waking up whenever syncState change
|
|
5021
|
-
switchMap((syncState) => db.cloud.currentUser.pipe(map((userLogin) => [userLogin, syncState]))), switchMap(([userLogin, syncState]) => userIsReallyActive.pipe(map((isActive) => [isActive ? userLogin : null, syncState]))), switchMap(([userLogin, syncState]) => __awaiter
|
|
5062
|
+
switchMap((syncState) => db.cloud.currentUser.pipe(map((userLogin) => [userLogin, syncState]))), switchMap(([userLogin, syncState]) => userIsReallyActive.pipe(map((isActive) => [isActive ? userLogin : null, syncState]))), switchMap(([userLogin, syncState]) => __awaiter(this, void 0, void 0, function* () { return [userLogin, yield computeRealmSetHash(syncState)]; })), switchMap(([userLogin, realmSetHash]) =>
|
|
5022
5063
|
// Let server end query changes from last entry of same client-ID and forward.
|
|
5023
5064
|
// If no new entries, server won't bother the client. If new entries, server sends only those
|
|
5024
5065
|
// and the baseRev of the last from same client-ID.
|
|
@@ -5027,7 +5068,7 @@
|
|
|
5027
5068
|
: rxjs.from([])), catchError((error) => {
|
|
5028
5069
|
if ((error === null || error === void 0 ? void 0 : error.name) === 'TokenExpiredError') {
|
|
5029
5070
|
console.debug('WebSocket observable: Token expired. Refreshing token...');
|
|
5030
|
-
return rxjs.of(true).pipe(switchMap(() => __awaiter
|
|
5071
|
+
return rxjs.of(true).pipe(switchMap(() => __awaiter(this, void 0, void 0, function* () {
|
|
5031
5072
|
// Refresh access token
|
|
5032
5073
|
const user = yield db.getCurrentUser();
|
|
5033
5074
|
const refreshedLogin = yield refreshAccessToken(db.cloud.options.databaseUrl, user);
|
|
@@ -5060,7 +5101,7 @@
|
|
|
5060
5101
|
|
|
5061
5102
|
function isSyncNeeded(db) {
|
|
5062
5103
|
var _a;
|
|
5063
|
-
return __awaiter
|
|
5104
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5064
5105
|
return ((_a = db.cloud.options) === null || _a === void 0 ? void 0 : _a.databaseUrl) && db.cloud.schema
|
|
5065
5106
|
? yield sync(db, db.cloud.options, db.cloud.schema, { justCheckIfNeeded: true })
|
|
5066
5107
|
: false;
|
|
@@ -5075,15 +5116,15 @@
|
|
|
5075
5116
|
const GUARDED_JOB_HEARTBEAT = 1 * SECONDS;
|
|
5076
5117
|
const GUARDED_JOB_TIMEOUT = 1 * MINUTES;
|
|
5077
5118
|
function performGuardedJob(db, jobName, jobsTableName, job, { awaitRemoteJob } = {}) {
|
|
5078
|
-
return __awaiter
|
|
5119
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5079
5120
|
// Start working.
|
|
5080
5121
|
//
|
|
5081
5122
|
// Check if someone else is working on this already.
|
|
5082
5123
|
//
|
|
5083
5124
|
const jobsTable = db.table(jobsTableName);
|
|
5084
5125
|
function aquireLock() {
|
|
5085
|
-
return __awaiter
|
|
5086
|
-
const gotTheLock = yield db.transaction('rw!', jobsTableName, () => __awaiter
|
|
5126
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5127
|
+
const gotTheLock = yield db.transaction('rw!', jobsTableName, () => __awaiter(this, void 0, void 0, function* () {
|
|
5087
5128
|
const currentWork = yield jobsTable.get(jobName);
|
|
5088
5129
|
if (!currentWork) {
|
|
5089
5130
|
// No one else is working. Let's record that we are.
|
|
@@ -5149,7 +5190,7 @@
|
|
|
5149
5190
|
// Stop heartbeat
|
|
5150
5191
|
clearInterval(heartbeat);
|
|
5151
5192
|
// Remove the persisted job state:
|
|
5152
|
-
yield db.transaction('rw!', jobsTableName, () => __awaiter
|
|
5193
|
+
yield db.transaction('rw!', jobsTableName, () => __awaiter(this, void 0, void 0, function* () {
|
|
5153
5194
|
const currentWork = yield jobsTable.get(jobName);
|
|
5154
5195
|
if (currentWork && currentWork.nodeId === myId) {
|
|
5155
5196
|
yield jobsTable.delete(jobName);
|
|
@@ -5209,7 +5250,7 @@
|
|
|
5209
5250
|
ongoingSyncs.set(db, { promise, pull: (options === null || options === void 0 ? void 0 : options.purpose) !== 'push' });
|
|
5210
5251
|
return promise;
|
|
5211
5252
|
function _syncIfPossible() {
|
|
5212
|
-
return __awaiter
|
|
5253
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5213
5254
|
try {
|
|
5214
5255
|
if (db.cloud.isServiceWorkerDB) {
|
|
5215
5256
|
// We are the dedicated sync SW:
|
|
@@ -5321,7 +5362,7 @@
|
|
|
5321
5362
|
}
|
|
5322
5363
|
}
|
|
5323
5364
|
|
|
5324
|
-
var n,
|
|
5365
|
+
var n,l$1,u$1,t$1,o$1,f$1={},e$1=[],c$1=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function s$1(n,l){for(var u in l)n[u]=l[u];return n}function a$1(n){var l=n.parentNode;l&&l.removeChild(n);}function h(l,u,i){var t,o,r,f={};for(r in u)"key"==r?t=u[r]:"ref"==r?o=u[r]:f[r]=u[r];if(arguments.length>2&&(f.children=arguments.length>3?n.call(arguments,2):i),"function"==typeof l&&null!=l.defaultProps)for(r in l.defaultProps)void 0===f[r]&&(f[r]=l.defaultProps[r]);return v$1(l,f,t,o,null)}function v$1(n,i,t,o,r){var f={type:n,props:i,key:t,ref:o,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==r?++u$1:r};return null==r&&null!=l$1.vnode&&l$1.vnode(f),f}function p$1(n){return n.children}function d$1(n,l){this.props=n,this.context=l;}function _$1(n,l){if(null==l)return n.__?_$1(n.__,n.__.__k.indexOf(n)+1):null;for(var u;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e)return u.__e;return "function"==typeof n.type?_$1(n):null}function k$1(n){var l,u;if(null!=(n=n.__)&&null!=n.__c){for(n.__e=n.__c.base=null,l=0;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e){n.__e=n.__c.base=u.__e;break}return k$1(n)}}function b$1(n){(!n.__d&&(n.__d=!0)&&t$1.push(n)&&!g$1.__r++||o$1!==l$1.debounceRendering)&&((o$1=l$1.debounceRendering)||setTimeout)(g$1);}function g$1(){for(var n;g$1.__r=t$1.length;)n=t$1.sort(function(n,l){return n.__v.__b-l.__v.__b}),t$1=[],n.some(function(n){var l,u,i,t,o,r;n.__d&&(o=(t=(l=n).__v).__e,(r=l.__P)&&(u=[],(i=s$1({},t)).__v=t.__v+1,j$1(r,t,i,l.__n,void 0!==r.ownerSVGElement,null!=t.__h?[o]:null,u,null==o?_$1(t):o,t.__h),z$1(u,t),t.__e!=o&&k$1(t)));});}function w$1(n,l,u,i,t,o,r,c,s,a){var h,y,d,k,b,g,w,x=i&&i.__k||e$1,C=x.length;for(u.__k=[],h=0;h<l.length;h++)if(null!=(k=u.__k[h]=null==(k=l[h])||"boolean"==typeof k?null:"string"==typeof k||"number"==typeof k||"bigint"==typeof k?v$1(null,k,null,null,k):Array.isArray(k)?v$1(p$1,{children:k},null,null,null):k.__b>0?v$1(k.type,k.props,k.key,null,k.__v):k)){if(k.__=u,k.__b=u.__b+1,null===(d=x[h])||d&&k.key==d.key&&k.type===d.type)x[h]=void 0;else for(y=0;y<C;y++){if((d=x[y])&&k.key==d.key&&k.type===d.type){x[y]=void 0;break}d=null;}j$1(n,k,d=d||f$1,t,o,r,c,s,a),b=k.__e,(y=k.ref)&&d.ref!=y&&(w||(w=[]),d.ref&&w.push(d.ref,null,k),w.push(y,k.__c||b,k)),null!=b?(null==g&&(g=b),"function"==typeof k.type&&k.__k===d.__k?k.__d=s=m$1(k,s,n):s=A(n,k,d,x,b,s),"function"==typeof u.type&&(u.__d=s)):s&&d.__e==s&&s.parentNode!=n&&(s=_$1(d));}for(u.__e=g,h=C;h--;)null!=x[h]&&("function"==typeof u.type&&null!=x[h].__e&&x[h].__e==u.__d&&(u.__d=_$1(i,h+1)),N(x[h],x[h]));if(w)for(h=0;h<w.length;h++)M(w[h],w[++h],w[++h]);}function m$1(n,l,u){for(var i,t=n.__k,o=0;t&&o<t.length;o++)(i=t[o])&&(i.__=n,l="function"==typeof i.type?m$1(i,l,u):A(u,i,i,t,i.__e,l));return l}function A(n,l,u,i,t,o){var r,f,e;if(void 0!==l.__d)r=l.__d,l.__d=void 0;else if(null==u||t!=o||null==t.parentNode)n:if(null==o||o.parentNode!==n)n.appendChild(t),r=null;else {for(f=o,e=0;(f=f.nextSibling)&&e<i.length;e+=2)if(f==t)break n;n.insertBefore(t,o),r=o;}return void 0!==r?r:t.nextSibling}function C(n,l,u,i,t){var o;for(o in u)"children"===o||"key"===o||o in l||H(n,o,null,u[o],i);for(o in l)t&&"function"!=typeof l[o]||"children"===o||"key"===o||"value"===o||"checked"===o||u[o]===l[o]||H(n,o,l[o],u[o],i);}function $(n,l,u){"-"===l[0]?n.setProperty(l,u):n[l]=null==u?"":"number"!=typeof u||c$1.test(l)?u:u+"px";}function H(n,l,u,i,t){var o;n:if("style"===l)if("string"==typeof u)n.style.cssText=u;else {if("string"==typeof i&&(n.style.cssText=i=""),i)for(l in i)u&&l in u||$(n.style,l,"");if(u)for(l in u)i&&u[l]===i[l]||$(n.style,l,u[l]);}else if("o"===l[0]&&"n"===l[1])o=l!==(l=l.replace(/Capture$/,"")),l=l.toLowerCase()in n?l.toLowerCase().slice(2):l.slice(2),n.l||(n.l={}),n.l[l+o]=u,u?i||n.addEventListener(l,o?T:I,o):n.removeEventListener(l,o?T:I,o);else if("dangerouslySetInnerHTML"!==l){if(t)l=l.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("href"!==l&&"list"!==l&&"form"!==l&&"tabIndex"!==l&&"download"!==l&&l in n)try{n[l]=null==u?"":u;break n}catch(n){}"function"==typeof u||(null!=u&&(!1!==u||"a"===l[0]&&"r"===l[1])?n.setAttribute(l,u):n.removeAttribute(l));}}function I(n){this.l[n.type+!1](l$1.event?l$1.event(n):n);}function T(n){this.l[n.type+!0](l$1.event?l$1.event(n):n);}function j$1(n,u,i,t,o,r,f,e,c){var a,h,v,y,_,k,b,g,m,x,A,C,$,H=u.type;if(void 0!==u.constructor)return null;null!=i.__h&&(c=i.__h,e=u.__e=i.__e,u.__h=null,r=[e]),(a=l$1.__b)&&a(u);try{n:if("function"==typeof H){if(g=u.props,m=(a=H.contextType)&&t[a.__c],x=a?m?m.props.value:a.__:t,i.__c?b=(h=u.__c=i.__c).__=h.__E:("prototype"in H&&H.prototype.render?u.__c=h=new H(g,x):(u.__c=h=new d$1(g,x),h.constructor=H,h.render=O),m&&m.sub(h),h.props=g,h.state||(h.state={}),h.context=x,h.__n=t,v=h.__d=!0,h.__h=[]),null==h.__s&&(h.__s=h.state),null!=H.getDerivedStateFromProps&&(h.__s==h.state&&(h.__s=s$1({},h.__s)),s$1(h.__s,H.getDerivedStateFromProps(g,h.__s))),y=h.props,_=h.state,v)null==H.getDerivedStateFromProps&&null!=h.componentWillMount&&h.componentWillMount(),null!=h.componentDidMount&&h.__h.push(h.componentDidMount);else {if(null==H.getDerivedStateFromProps&&g!==y&&null!=h.componentWillReceiveProps&&h.componentWillReceiveProps(g,x),!h.__e&&null!=h.shouldComponentUpdate&&!1===h.shouldComponentUpdate(g,h.__s,x)||u.__v===i.__v){h.props=g,h.state=h.__s,u.__v!==i.__v&&(h.__d=!1),h.__v=u,u.__e=i.__e,u.__k=i.__k,u.__k.forEach(function(n){n&&(n.__=u);}),h.__h.length&&f.push(h);break n}null!=h.componentWillUpdate&&h.componentWillUpdate(g,h.__s,x),null!=h.componentDidUpdate&&h.__h.push(function(){h.componentDidUpdate(y,_,k);});}if(h.context=x,h.props=g,h.__v=u,h.__P=n,A=l$1.__r,C=0,"prototype"in H&&H.prototype.render)h.state=h.__s,h.__d=!1,A&&A(u),a=h.render(h.props,h.state,h.context);else do{h.__d=!1,A&&A(u),a=h.render(h.props,h.state,h.context),h.state=h.__s;}while(h.__d&&++C<25);h.state=h.__s,null!=h.getChildContext&&(t=s$1(s$1({},t),h.getChildContext())),v||null==h.getSnapshotBeforeUpdate||(k=h.getSnapshotBeforeUpdate(y,_)),$=null!=a&&a.type===p$1&&null==a.key?a.props.children:a,w$1(n,Array.isArray($)?$:[$],u,i,t,o,r,f,e,c),h.base=u.__e,u.__h=null,h.__h.length&&f.push(h),b&&(h.__E=h.__=null),h.__e=!1;}else null==r&&u.__v===i.__v?(u.__k=i.__k,u.__e=i.__e):u.__e=L(i.__e,u,i,t,o,r,f,c);(a=l$1.diffed)&&a(u);}catch(n){u.__v=null,(c||null!=r)&&(u.__e=e,u.__h=!!c,r[r.indexOf(e)]=null),l$1.__e(n,u,i);}}function z$1(n,u){l$1.__c&&l$1.__c(u,n),n.some(function(u){try{n=u.__h,u.__h=[],n.some(function(n){n.call(u);});}catch(n){l$1.__e(n,u.__v);}});}function L(l,u,i,t,o,r,e,c){var s,h,v,y=i.props,p=u.props,d=u.type,k=0;if("svg"===d&&(o=!0),null!=r)for(;k<r.length;k++)if((s=r[k])&&"setAttribute"in s==!!d&&(d?s.localName===d:3===s.nodeType)){l=s,r[k]=null;break}if(null==l){if(null===d)return document.createTextNode(p);l=o?document.createElementNS("http://www.w3.org/2000/svg",d):document.createElement(d,p.is&&p),r=null,c=!1;}if(null===d)y===p||c&&l.data===p||(l.data=p);else {if(r=r&&n.call(l.childNodes),h=(y=i.props||f$1).dangerouslySetInnerHTML,v=p.dangerouslySetInnerHTML,!c){if(null!=r)for(y={},k=0;k<l.attributes.length;k++)y[l.attributes[k].name]=l.attributes[k].value;(v||h)&&(v&&(h&&v.__html==h.__html||v.__html===l.innerHTML)||(l.innerHTML=v&&v.__html||""));}if(C(l,p,y,o,c),v)u.__k=[];else if(k=u.props.children,w$1(l,Array.isArray(k)?k:[k],u,i,t,o&&"foreignObject"!==d,r,e,r?r[0]:i.__k&&_$1(i,0),c),null!=r)for(k=r.length;k--;)null!=r[k]&&a$1(r[k]);c||("value"in p&&void 0!==(k=p.value)&&(k!==l.value||"progress"===d&&!k||"option"===d&&k!==y.value)&&H(l,"value",k,y.value,!1),"checked"in p&&void 0!==(k=p.checked)&&k!==l.checked&&H(l,"checked",k,y.checked,!1));}return l}function M(n,u,i){try{"function"==typeof n?n(u):n.current=u;}catch(n){l$1.__e(n,i);}}function N(n,u,i){var t,o;if(l$1.unmount&&l$1.unmount(n),(t=n.ref)&&(t.current&&t.current!==n.__e||M(t,null,u)),null!=(t=n.__c)){if(t.componentWillUnmount)try{t.componentWillUnmount();}catch(n){l$1.__e(n,u);}t.base=t.__P=null;}if(t=n.__k)for(o=0;o<t.length;o++)t[o]&&N(t[o],u,"function"!=typeof n.type);i||null==n.__e||a$1(n.__e),n.__e=n.__d=void 0;}function O(n,l,u){return this.constructor(n,u)}function P(u,i,t){var o,r,e;l$1.__&&l$1.__(u,i),r=(o="function"==typeof t)?null:t&&t.__k||i.__k,e=[],j$1(i,u=(!o&&t||i).__k=h(p$1,null,[u]),r||f$1,f$1,void 0!==i.ownerSVGElement,!o&&t?[t]:r?null:i.firstChild?n.call(i.childNodes):null,e,!o&&t?t:r?r.__e:i.firstChild,o),z$1(e,u);}n=e$1.slice,l$1={__e:function(n,l,u,i){for(var t,o,r;l=l.__;)if((t=l.__c)&&!t.__)try{if((o=t.constructor)&&null!=o.getDerivedStateFromError&&(t.setState(o.getDerivedStateFromError(n)),r=t.__d),null!=t.componentDidCatch&&(t.componentDidCatch(n,i||{}),r=t.__d),r)return t.__E=t}catch(l){n=l;}throw n}},u$1=0,d$1.prototype.setState=function(n,l){var u;u=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=s$1({},this.state),"function"==typeof n&&(n=n(s$1({},u),this.props)),n&&s$1(u,n),null!=n&&this.__v&&(l&&this.__h.push(l),b$1(this));},d$1.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),b$1(this));},d$1.prototype.render=p$1,t$1=[],g$1.__r=0;
|
|
5325
5366
|
|
|
5326
5367
|
const Styles = {
|
|
5327
5368
|
Error: {
|
|
@@ -5386,35 +5427,35 @@
|
|
|
5386
5427
|
};
|
|
5387
5428
|
|
|
5388
5429
|
function Dialog({ children, className }) {
|
|
5389
|
-
return (
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
|
|
5430
|
+
return (h("div", { className: className },
|
|
5431
|
+
h("div", { style: Styles.Darken }),
|
|
5432
|
+
h("div", { style: Styles.DialogOuter },
|
|
5433
|
+
h("div", { style: Styles.DialogInner }, children))));
|
|
5393
5434
|
}
|
|
5394
5435
|
|
|
5395
|
-
var t,u,
|
|
5436
|
+
var t,r,u,i,o=0,c=[],f=[],e=l$1.__b,a=l$1.__r,v=l$1.diffed,l=l$1.__c,m=l$1.unmount;function d(t,u){l$1.__h&&l$1.__h(r,t,o||u),o=0;var i=r.__H||(r.__H={__:[],__h:[]});return t>=i.__.length&&i.__.push({__V:f}),i.__[t]}function p(n){return o=1,y(z,n)}function y(n,u,i){var o=d(t++,2);if(o.t=n,!o.__c&&(o.__=[i?i(u):z(void 0,u),function(n){var t=o.__N?o.__N[0]:o.__[0],r=o.t(t,n);t!==r&&(o.__N=[r,o.__[1]],o.__c.setState({}));}],o.__c=r,!r.u)){r.u=!0;var c=r.shouldComponentUpdate;r.shouldComponentUpdate=function(n,t,r){if(!o.__c.__H)return !0;var u=o.__c.__H.__.filter(function(n){return n.__c});if(u.every(function(n){return !n.__N}))return !c||c.call(this,n,t,r);var i=!1;return u.forEach(function(n){if(n.__N){var t=n.__[0];n.__=n.__N,n.__N=void 0,t!==n.__[0]&&(i=!0);}}),!!i&&(!c||c.call(this,n,t,r))};}return o.__N||o.__}function s(u,i){var o=d(t++,4);!l$1.__s&&w(o.__H,i)&&(o.__=u,o.i=i,r.__h.push(o));}function _(n){return o=5,F(function(){return {current:n}},[])}function F(n,r){var u=d(t++,7);return w(u.__H,r)?(u.__V=n(),u.i=r,u.__h=n,u.__V):u.__}function b(){for(var t;t=c.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(j),t.__H.__h.forEach(k),t.__H.__h=[];}catch(r){t.__H.__h=[],l$1.__e(r,t.__v);}}l$1.__b=function(n){r=null,e&&e(n);},l$1.__r=function(n){a&&a(n),t=0;var i=(r=n.__c).__H;i&&(u===r?(i.__h=[],r.__h=[],i.__.forEach(function(n){n.__N&&(n.__=n.__N),n.__V=f,n.__N=n.i=void 0;})):(i.__h.forEach(j),i.__h.forEach(k),i.__h=[])),u=r;},l$1.diffed=function(t){v&&v(t);var o=t.__c;o&&o.__H&&(o.__H.__h.length&&(1!==c.push(o)&&i===l$1.requestAnimationFrame||((i=l$1.requestAnimationFrame)||function(n){var t,r=function(){clearTimeout(u),g&&cancelAnimationFrame(t),setTimeout(n);},u=setTimeout(r,100);g&&(t=requestAnimationFrame(r));})(b)),o.__H.__.forEach(function(n){n.i&&(n.__H=n.i),n.__V!==f&&(n.__=n.__V),n.i=void 0,n.__V=f;})),u=r=null;},l$1.__c=function(t,r){r.some(function(t){try{t.__h.forEach(j),t.__h=t.__h.filter(function(n){return !n.__||k(n)});}catch(u){r.some(function(n){n.__h&&(n.__h=[]);}),r=[],l$1.__e(u,t.__v);}}),l&&l(t,r);},l$1.unmount=function(t){m&&m(t);var r,u=t.__c;u&&u.__H&&(u.__H.__.forEach(function(n){try{j(n);}catch(n){r=n;}}),r&&l$1.__e(r,u.__v));};var g="function"==typeof requestAnimationFrame;function j(n){var t=r,u=n.__c;"function"==typeof u&&(n.__c=void 0,u()),r=t;}function k(n){var t=r;n.__c=n.__(),r=t;}function w(n,t){return !n||n.length!==t.length||t.some(function(t,r){return t!==n[r]})}function z(n,t){return "function"==typeof t?t(n):t}
|
|
5396
5437
|
|
|
5397
5438
|
function resolveText({ message, messageCode, messageParams }) {
|
|
5398
5439
|
return message.replace(/\{\w+\}/ig, n => messageParams[n.substr(1, n.length - 2)]);
|
|
5399
5440
|
}
|
|
5400
5441
|
|
|
5401
5442
|
function LoginDialog({ title, alerts, fields, onCancel, onSubmit, }) {
|
|
5402
|
-
const [params, setParams] =
|
|
5403
|
-
const firstFieldRef =
|
|
5404
|
-
|
|
5405
|
-
return (
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
alerts.map((alert) => (
|
|
5409
|
-
|
|
5443
|
+
const [params, setParams] = p({});
|
|
5444
|
+
const firstFieldRef = _(null);
|
|
5445
|
+
s(() => { var _a; return (_a = firstFieldRef.current) === null || _a === void 0 ? void 0 : _a.focus(); }, []);
|
|
5446
|
+
return (h(Dialog, { className: "dxc-login-dlg" },
|
|
5447
|
+
h(p$1, null,
|
|
5448
|
+
h("h3", { style: Styles.WindowHeader }, title),
|
|
5449
|
+
alerts.map((alert) => (h("p", { style: Styles.Alert[alert.type] }, resolveText(alert)))),
|
|
5450
|
+
h("form", { onSubmit: ev => {
|
|
5410
5451
|
ev.preventDefault();
|
|
5411
5452
|
onSubmit(params);
|
|
5412
|
-
} }, Object.entries(fields).map(([fieldName, { type, label, placeholder }], idx) => (
|
|
5453
|
+
} }, Object.entries(fields).map(([fieldName, { type, label, placeholder }], idx) => (h("label", { style: Styles.Label },
|
|
5413
5454
|
label ? `${label}: ` : '',
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
|
|
5417
|
-
|
|
5455
|
+
h("input", { ref: idx === 0 ? firstFieldRef : undefined, type: type, name: fieldName, autoComplete: "on", style: Styles.Input, autoFocus: true, placeholder: placeholder, value: params[fieldName] || '', onInput: (ev) => { var _a; return setParams(Object.assign(Object.assign({}, params), { [fieldName]: valueTransformer(type, (_a = ev.target) === null || _a === void 0 ? void 0 : _a['value']) })); } })))))),
|
|
5456
|
+
h("div", { style: Styles.ButtonsDiv },
|
|
5457
|
+
h("button", { type: "submit", style: Styles.Button, onClick: () => onSubmit(params) }, "Submit"),
|
|
5458
|
+
h("button", { style: Styles.Button, onClick: onCancel }, "Cancel"))));
|
|
5418
5459
|
}
|
|
5419
5460
|
function valueTransformer(type, value) {
|
|
5420
5461
|
switch (type) {
|
|
@@ -5424,7 +5465,7 @@
|
|
|
5424
5465
|
}
|
|
5425
5466
|
}
|
|
5426
5467
|
|
|
5427
|
-
class LoginGui extends
|
|
5468
|
+
class LoginGui extends d$1 {
|
|
5428
5469
|
constructor(props) {
|
|
5429
5470
|
super(props);
|
|
5430
5471
|
this.observer = (userInteraction) => this.setState({ userInteraction });
|
|
@@ -5443,17 +5484,30 @@
|
|
|
5443
5484
|
if (!userInteraction)
|
|
5444
5485
|
return null;
|
|
5445
5486
|
//if (props.db.cloud.userInteraction.observers.length > 1) return null; // Someone else subscribes.
|
|
5446
|
-
return
|
|
5487
|
+
return h(LoginDialog, Object.assign({}, userInteraction));
|
|
5447
5488
|
}
|
|
5448
5489
|
}
|
|
5449
5490
|
function setupDefaultGUI(db) {
|
|
5450
|
-
const el = document.createElement('div');
|
|
5451
|
-
document.body.appendChild(el);
|
|
5452
|
-
N(a$1(LoginGui, { db: db.vip }), el);
|
|
5453
5491
|
let closed = false;
|
|
5492
|
+
const el = document.createElement('div');
|
|
5493
|
+
if (document.body) {
|
|
5494
|
+
document.body.appendChild(el);
|
|
5495
|
+
P(h(LoginGui, { db: db.vip }), el);
|
|
5496
|
+
}
|
|
5497
|
+
else {
|
|
5498
|
+
addEventListener('DOMContentLoaded', () => {
|
|
5499
|
+
if (!closed) {
|
|
5500
|
+
document.body.appendChild(el);
|
|
5501
|
+
P(h(LoginGui, { db: db.vip }), el);
|
|
5502
|
+
}
|
|
5503
|
+
});
|
|
5504
|
+
}
|
|
5454
5505
|
return {
|
|
5455
5506
|
unsubscribe() {
|
|
5456
|
-
|
|
5507
|
+
try {
|
|
5508
|
+
el.remove();
|
|
5509
|
+
}
|
|
5510
|
+
catch (_a) { }
|
|
5457
5511
|
closed = true;
|
|
5458
5512
|
},
|
|
5459
5513
|
get closed() {
|
|
@@ -5819,12 +5873,12 @@
|
|
|
5819
5873
|
return Object.values(membersById)
|
|
5820
5874
|
.filter((invite) => !invite.accepted && !invite.rejected)
|
|
5821
5875
|
.map((invite) => (Object.assign(Object.assign({}, invite), { accept() {
|
|
5822
|
-
return __awaiter
|
|
5876
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5823
5877
|
yield db.members.update(invite.id, { accepted: new Date() });
|
|
5824
5878
|
});
|
|
5825
5879
|
},
|
|
5826
5880
|
reject() {
|
|
5827
|
-
return __awaiter
|
|
5881
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5828
5882
|
yield db.members.update(invite.id, { rejected: new Date() });
|
|
5829
5883
|
});
|
|
5830
5884
|
} })));
|
|
@@ -5851,7 +5905,7 @@
|
|
|
5851
5905
|
let configuredProgramatically = false;
|
|
5852
5906
|
// local sync worker - used when there's no service worker.
|
|
5853
5907
|
let localSyncWorker = null;
|
|
5854
|
-
dexie.on('ready', (dexie) => __awaiter
|
|
5908
|
+
dexie.on('ready', (dexie) => __awaiter(this, void 0, void 0, function* () {
|
|
5855
5909
|
try {
|
|
5856
5910
|
yield onDbReady(dexie);
|
|
5857
5911
|
}
|
|
@@ -5890,7 +5944,7 @@
|
|
|
5890
5944
|
userInteraction: new rxjs.BehaviorSubject(undefined),
|
|
5891
5945
|
webSocketStatus: new rxjs.BehaviorSubject('not-started'),
|
|
5892
5946
|
login(hint) {
|
|
5893
|
-
return __awaiter
|
|
5947
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5894
5948
|
const db = DexieCloudDB(dexie);
|
|
5895
5949
|
yield db.cloud.sync();
|
|
5896
5950
|
yield login(db, hint);
|
|
@@ -5909,7 +5963,7 @@
|
|
|
5909
5963
|
updateSchemaFromOptions(dexie.cloud.schema, dexie.cloud.options);
|
|
5910
5964
|
},
|
|
5911
5965
|
sync({ wait, purpose } = { wait: true, purpose: 'push' }) {
|
|
5912
|
-
return __awaiter
|
|
5966
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5913
5967
|
if (wait === undefined)
|
|
5914
5968
|
wait = true;
|
|
5915
5969
|
const db = DexieCloudDB(dexie);
|
|
@@ -5931,7 +5985,7 @@
|
|
|
5931
5985
|
triggerSync(db, purpose);
|
|
5932
5986
|
if (wait) {
|
|
5933
5987
|
console.debug('db.cloud.login() is waiting for sync completion...');
|
|
5934
|
-
yield rxjs.from(Dexie.liveQuery(() => __awaiter
|
|
5988
|
+
yield rxjs.from(Dexie.liveQuery(() => __awaiter(this, void 0, void 0, function* () {
|
|
5935
5989
|
const syncNeeded = yield isSyncNeeded(db);
|
|
5936
5990
|
const newSyncState = yield db.getPersistedSyncState();
|
|
5937
5991
|
if ((newSyncState === null || newSyncState === void 0 ? void 0 : newSyncState.timestamp) !== (syncState === null || syncState === void 0 ? void 0 : syncState.timestamp) &&
|
|
@@ -5967,7 +6021,7 @@
|
|
|
5967
6021
|
dexie.use(createIdGenerationMiddleware(DexieCloudDB(dexie)));
|
|
5968
6022
|
function onDbReady(dexie) {
|
|
5969
6023
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
5970
|
-
return __awaiter
|
|
6024
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5971
6025
|
closed = false; // As Dexie calls us, we are not closed anymore. Maybe reopened? Remember db.ready event is registered with sticky flag!
|
|
5972
6026
|
const db = DexieCloudDB(dexie);
|
|
5973
6027
|
// Setup default GUI:
|
|
@@ -5987,7 +6041,7 @@
|
|
|
5987
6041
|
const swRegistrations = 'serviceWorker' in navigator
|
|
5988
6042
|
? yield navigator.serviceWorker.getRegistrations()
|
|
5989
6043
|
: [];
|
|
5990
|
-
const initiallySynced = yield db.transaction('rw', db.$syncState, () => __awaiter
|
|
6044
|
+
const initiallySynced = yield db.transaction('rw', db.$syncState, () => __awaiter(this, void 0, void 0, function* () {
|
|
5991
6045
|
var _h, _j;
|
|
5992
6046
|
const { options, schema } = db.cloud;
|
|
5993
6047
|
const [persistedOptions, persistedSchema, persistedSyncState] = yield Promise.all([
|