dexie-cloud-addon 4.0.0-beta.22 → 4.0.0-beta.23
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 +364 -323
- 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 +365 -324
- 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 +540 -506
- 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 +539 -505
- 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 +365 -324
- 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 +361 -320
- package/dist/umd-modern/dexie-cloud-addon.js.map +1 -1
- package/package.json +11 -10
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
var Dexie__default = /*#__PURE__*/_interopDefaultLegacy(Dexie);
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/******************************************************************************
|
|
12
12
|
Copyright (c) Microsoft Corporation.
|
|
13
13
|
|
|
14
14
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -22,8 +22,24 @@
|
|
|
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
|
+
};
|
|
25
33
|
|
|
26
|
-
function
|
|
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
|
+
|
|
42
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
27
43
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
28
44
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
29
45
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
@@ -31,6 +47,97 @@
|
|
|
31
47
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
32
48
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
33
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); }
|
|
34
141
|
}
|
|
35
142
|
|
|
36
143
|
const UNAUTHORIZED_USER = {
|
|
@@ -161,134 +268,6 @@
|
|
|
161
268
|
};
|
|
162
269
|
}
|
|
163
270
|
|
|
164
|
-
/*! *****************************************************************************
|
|
165
|
-
Copyright (c) Microsoft Corporation.
|
|
166
|
-
|
|
167
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
168
|
-
purpose with or without fee is hereby granted.
|
|
169
|
-
|
|
170
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
171
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
172
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
173
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
174
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
175
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
176
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
177
|
-
***************************************************************************** */
|
|
178
|
-
/* global Reflect, Promise */
|
|
179
|
-
|
|
180
|
-
var extendStatics = function(d, b) {
|
|
181
|
-
extendStatics = Object.setPrototypeOf ||
|
|
182
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
183
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
184
|
-
return extendStatics(d, b);
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
function __extends(d, b) {
|
|
188
|
-
if (typeof b !== "function" && b !== null)
|
|
189
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
190
|
-
extendStatics(d, b);
|
|
191
|
-
function __() { this.constructor = d; }
|
|
192
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
196
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
197
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
198
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
199
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
200
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
201
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
function __generator(thisArg, body) {
|
|
206
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
207
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
208
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
209
|
-
function step(op) {
|
|
210
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
211
|
-
while (_) try {
|
|
212
|
-
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;
|
|
213
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
214
|
-
switch (op[0]) {
|
|
215
|
-
case 0: case 1: t = op; break;
|
|
216
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
217
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
218
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
219
|
-
default:
|
|
220
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
221
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
222
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
223
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
224
|
-
if (t[2]) _.ops.pop();
|
|
225
|
-
_.trys.pop(); continue;
|
|
226
|
-
}
|
|
227
|
-
op = body.call(thisArg, _);
|
|
228
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
229
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
function __values(o) {
|
|
234
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
235
|
-
if (m) return m.call(o);
|
|
236
|
-
if (o && typeof o.length === "number") return {
|
|
237
|
-
next: function () {
|
|
238
|
-
if (o && i >= o.length) o = void 0;
|
|
239
|
-
return { value: o && o[i++], done: !o };
|
|
240
|
-
}
|
|
241
|
-
};
|
|
242
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
function __read(o, n) {
|
|
246
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
247
|
-
if (!m) return o;
|
|
248
|
-
var i = m.call(o), r, ar = [], e;
|
|
249
|
-
try {
|
|
250
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
251
|
-
}
|
|
252
|
-
catch (error) { e = { error: error }; }
|
|
253
|
-
finally {
|
|
254
|
-
try {
|
|
255
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
256
|
-
}
|
|
257
|
-
finally { if (e) throw e.error; }
|
|
258
|
-
}
|
|
259
|
-
return ar;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
function __spreadArray(to, from) {
|
|
263
|
-
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
264
|
-
to[j] = from[i];
|
|
265
|
-
return to;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
function __await(v) {
|
|
269
|
-
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
273
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
274
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
275
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
276
|
-
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); }); }; }
|
|
277
|
-
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
278
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
279
|
-
function fulfill(value) { resume("next", value); }
|
|
280
|
-
function reject(value) { resume("throw", value); }
|
|
281
|
-
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
function __asyncValues(o) {
|
|
285
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
286
|
-
var m = o[Symbol.asyncIterator], i;
|
|
287
|
-
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);
|
|
288
|
-
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); }); }; }
|
|
289
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
290
|
-
}
|
|
291
|
-
|
|
292
271
|
var isArrayLike = (function (x) { return x && typeof x.length === 'number' && typeof x !== 'function'; });
|
|
293
272
|
|
|
294
273
|
function isPromise(value) {
|
|
@@ -329,7 +308,7 @@
|
|
|
329
308
|
this.initialTeardown = initialTeardown;
|
|
330
309
|
this.closed = false;
|
|
331
310
|
this._parentage = null;
|
|
332
|
-
this.
|
|
311
|
+
this._finalizers = null;
|
|
333
312
|
}
|
|
334
313
|
Subscription.prototype.unsubscribe = function () {
|
|
335
314
|
var e_1, _a, e_2, _b;
|
|
@@ -358,23 +337,23 @@
|
|
|
358
337
|
_parentage.remove(this);
|
|
359
338
|
}
|
|
360
339
|
}
|
|
361
|
-
var
|
|
362
|
-
if (isFunction(
|
|
340
|
+
var initialFinalizer = this.initialTeardown;
|
|
341
|
+
if (isFunction(initialFinalizer)) {
|
|
363
342
|
try {
|
|
364
|
-
|
|
343
|
+
initialFinalizer();
|
|
365
344
|
}
|
|
366
345
|
catch (e) {
|
|
367
346
|
errors = e instanceof UnsubscriptionError ? e.errors : [e];
|
|
368
347
|
}
|
|
369
348
|
}
|
|
370
|
-
var
|
|
371
|
-
if (
|
|
372
|
-
this.
|
|
349
|
+
var _finalizers = this._finalizers;
|
|
350
|
+
if (_finalizers) {
|
|
351
|
+
this._finalizers = null;
|
|
373
352
|
try {
|
|
374
|
-
for (var
|
|
375
|
-
var
|
|
353
|
+
for (var _finalizers_1 = __values(_finalizers), _finalizers_1_1 = _finalizers_1.next(); !_finalizers_1_1.done; _finalizers_1_1 = _finalizers_1.next()) {
|
|
354
|
+
var finalizer = _finalizers_1_1.value;
|
|
376
355
|
try {
|
|
377
|
-
|
|
356
|
+
execFinalizer(finalizer);
|
|
378
357
|
}
|
|
379
358
|
catch (err) {
|
|
380
359
|
errors = errors !== null && errors !== void 0 ? errors : [];
|
|
@@ -390,7 +369,7 @@
|
|
|
390
369
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
391
370
|
finally {
|
|
392
371
|
try {
|
|
393
|
-
if (
|
|
372
|
+
if (_finalizers_1_1 && !_finalizers_1_1.done && (_b = _finalizers_1.return)) _b.call(_finalizers_1);
|
|
394
373
|
}
|
|
395
374
|
finally { if (e_2) throw e_2.error; }
|
|
396
375
|
}
|
|
@@ -404,7 +383,7 @@
|
|
|
404
383
|
var _a;
|
|
405
384
|
if (teardown && teardown !== this) {
|
|
406
385
|
if (this.closed) {
|
|
407
|
-
|
|
386
|
+
execFinalizer(teardown);
|
|
408
387
|
}
|
|
409
388
|
else {
|
|
410
389
|
if (teardown instanceof Subscription) {
|
|
@@ -413,7 +392,7 @@
|
|
|
413
392
|
}
|
|
414
393
|
teardown._addParent(this);
|
|
415
394
|
}
|
|
416
|
-
(this.
|
|
395
|
+
(this._finalizers = (_a = this._finalizers) !== null && _a !== void 0 ? _a : []).push(teardown);
|
|
417
396
|
}
|
|
418
397
|
}
|
|
419
398
|
};
|
|
@@ -435,8 +414,8 @@
|
|
|
435
414
|
}
|
|
436
415
|
};
|
|
437
416
|
Subscription.prototype.remove = function (teardown) {
|
|
438
|
-
var
|
|
439
|
-
|
|
417
|
+
var _finalizers = this._finalizers;
|
|
418
|
+
_finalizers && arrRemove(_finalizers, teardown);
|
|
440
419
|
if (teardown instanceof Subscription) {
|
|
441
420
|
teardown._removeParent(this);
|
|
442
421
|
}
|
|
@@ -448,16 +427,17 @@
|
|
|
448
427
|
})();
|
|
449
428
|
return Subscription;
|
|
450
429
|
}());
|
|
430
|
+
Subscription.EMPTY;
|
|
451
431
|
function isSubscription(value) {
|
|
452
432
|
return (value instanceof Subscription ||
|
|
453
433
|
(value && 'closed' in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe)));
|
|
454
434
|
}
|
|
455
|
-
function
|
|
456
|
-
if (isFunction(
|
|
457
|
-
|
|
435
|
+
function execFinalizer(finalizer) {
|
|
436
|
+
if (isFunction(finalizer)) {
|
|
437
|
+
finalizer();
|
|
458
438
|
}
|
|
459
439
|
else {
|
|
460
|
-
|
|
440
|
+
finalizer.unsubscribe();
|
|
461
441
|
}
|
|
462
442
|
}
|
|
463
443
|
|
|
@@ -470,13 +450,16 @@
|
|
|
470
450
|
};
|
|
471
451
|
|
|
472
452
|
var timeoutProvider = {
|
|
473
|
-
setTimeout: function () {
|
|
453
|
+
setTimeout: function (handler, timeout) {
|
|
474
454
|
var args = [];
|
|
475
|
-
for (var _i =
|
|
476
|
-
args[_i] = arguments[_i];
|
|
455
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
456
|
+
args[_i - 2] = arguments[_i];
|
|
477
457
|
}
|
|
478
458
|
var delegate = timeoutProvider.delegate;
|
|
479
|
-
|
|
459
|
+
if (delegate === null || delegate === void 0 ? void 0 : delegate.setTimeout) {
|
|
460
|
+
return delegate.setTimeout.apply(delegate, __spreadArray([handler, timeout], __read(args)));
|
|
461
|
+
}
|
|
462
|
+
return setTimeout.apply(void 0, __spreadArray([handler, timeout], __read(args)));
|
|
480
463
|
},
|
|
481
464
|
clearTimeout: function (handle) {
|
|
482
465
|
var delegate = timeoutProvider.delegate;
|
|
@@ -487,7 +470,11 @@
|
|
|
487
470
|
|
|
488
471
|
function reportUnhandledError(err) {
|
|
489
472
|
timeoutProvider.setTimeout(function () {
|
|
490
|
-
|
|
473
|
+
var onUnhandledError = config.onUnhandledError;
|
|
474
|
+
if (onUnhandledError) {
|
|
475
|
+
onUnhandledError(err);
|
|
476
|
+
}
|
|
477
|
+
else {
|
|
491
478
|
throw err;
|
|
492
479
|
}
|
|
493
480
|
});
|
|
@@ -512,14 +499,22 @@
|
|
|
512
499
|
|
|
513
500
|
var context = null;
|
|
514
501
|
function errorContext(cb) {
|
|
515
|
-
{
|
|
502
|
+
if (config.useDeprecatedSynchronousErrorHandling) {
|
|
503
|
+
var isRoot = !context;
|
|
504
|
+
if (isRoot) {
|
|
505
|
+
context = { errorThrown: false, error: null };
|
|
506
|
+
}
|
|
516
507
|
cb();
|
|
508
|
+
if (isRoot) {
|
|
509
|
+
var _a = context, errorThrown = _a.errorThrown, error = _a.error;
|
|
510
|
+
context = null;
|
|
511
|
+
if (errorThrown) {
|
|
512
|
+
throw error;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
517
515
|
}
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
if (config.useDeprecatedSynchronousErrorHandling && context) {
|
|
521
|
-
context.errorThrown = true;
|
|
522
|
-
context.error = err;
|
|
516
|
+
else {
|
|
517
|
+
cb();
|
|
523
518
|
}
|
|
524
519
|
}
|
|
525
520
|
|
|
@@ -596,55 +591,88 @@
|
|
|
596
591
|
};
|
|
597
592
|
return Subscriber;
|
|
598
593
|
}(Subscription));
|
|
594
|
+
var _bind = Function.prototype.bind;
|
|
595
|
+
function bind(fn, thisArg) {
|
|
596
|
+
return _bind.call(fn, thisArg);
|
|
597
|
+
}
|
|
598
|
+
var ConsumerObserver = (function () {
|
|
599
|
+
function ConsumerObserver(partialObserver) {
|
|
600
|
+
this.partialObserver = partialObserver;
|
|
601
|
+
}
|
|
602
|
+
ConsumerObserver.prototype.next = function (value) {
|
|
603
|
+
var partialObserver = this.partialObserver;
|
|
604
|
+
if (partialObserver.next) {
|
|
605
|
+
try {
|
|
606
|
+
partialObserver.next(value);
|
|
607
|
+
}
|
|
608
|
+
catch (error) {
|
|
609
|
+
handleUnhandledError(error);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
};
|
|
613
|
+
ConsumerObserver.prototype.error = function (err) {
|
|
614
|
+
var partialObserver = this.partialObserver;
|
|
615
|
+
if (partialObserver.error) {
|
|
616
|
+
try {
|
|
617
|
+
partialObserver.error(err);
|
|
618
|
+
}
|
|
619
|
+
catch (error) {
|
|
620
|
+
handleUnhandledError(error);
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
else {
|
|
624
|
+
handleUnhandledError(err);
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
ConsumerObserver.prototype.complete = function () {
|
|
628
|
+
var partialObserver = this.partialObserver;
|
|
629
|
+
if (partialObserver.complete) {
|
|
630
|
+
try {
|
|
631
|
+
partialObserver.complete();
|
|
632
|
+
}
|
|
633
|
+
catch (error) {
|
|
634
|
+
handleUnhandledError(error);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
return ConsumerObserver;
|
|
639
|
+
}());
|
|
599
640
|
var SafeSubscriber = (function (_super) {
|
|
600
641
|
__extends(SafeSubscriber, _super);
|
|
601
642
|
function SafeSubscriber(observerOrNext, error, complete) {
|
|
602
643
|
var _this = _super.call(this) || this;
|
|
603
|
-
var
|
|
604
|
-
if (isFunction(observerOrNext)) {
|
|
605
|
-
|
|
644
|
+
var partialObserver;
|
|
645
|
+
if (isFunction(observerOrNext) || !observerOrNext) {
|
|
646
|
+
partialObserver = {
|
|
647
|
+
next: (observerOrNext !== null && observerOrNext !== void 0 ? observerOrNext : undefined),
|
|
648
|
+
error: error !== null && error !== void 0 ? error : undefined,
|
|
649
|
+
complete: complete !== null && complete !== void 0 ? complete : undefined,
|
|
650
|
+
};
|
|
606
651
|
}
|
|
607
|
-
else
|
|
608
|
-
(next = observerOrNext.next, error = observerOrNext.error, complete = observerOrNext.complete);
|
|
652
|
+
else {
|
|
609
653
|
var context_1;
|
|
610
654
|
if (_this && config.useDeprecatedNextContext) {
|
|
611
655
|
context_1 = Object.create(observerOrNext);
|
|
612
656
|
context_1.unsubscribe = function () { return _this.unsubscribe(); };
|
|
657
|
+
partialObserver = {
|
|
658
|
+
next: observerOrNext.next && bind(observerOrNext.next, context_1),
|
|
659
|
+
error: observerOrNext.error && bind(observerOrNext.error, context_1),
|
|
660
|
+
complete: observerOrNext.complete && bind(observerOrNext.complete, context_1),
|
|
661
|
+
};
|
|
613
662
|
}
|
|
614
663
|
else {
|
|
615
|
-
|
|
664
|
+
partialObserver = observerOrNext;
|
|
616
665
|
}
|
|
617
|
-
next = next === null || next === void 0 ? void 0 : next.bind(context_1);
|
|
618
|
-
error = error === null || error === void 0 ? void 0 : error.bind(context_1);
|
|
619
|
-
complete = complete === null || complete === void 0 ? void 0 : complete.bind(context_1);
|
|
620
666
|
}
|
|
621
|
-
_this.destination =
|
|
622
|
-
next: next ? wrapForErrorHandling(next) : noop,
|
|
623
|
-
error: wrapForErrorHandling(error !== null && error !== void 0 ? error : defaultErrorHandler),
|
|
624
|
-
complete: complete ? wrapForErrorHandling(complete) : noop,
|
|
625
|
-
};
|
|
667
|
+
_this.destination = new ConsumerObserver(partialObserver);
|
|
626
668
|
return _this;
|
|
627
669
|
}
|
|
628
670
|
return SafeSubscriber;
|
|
629
671
|
}(Subscriber));
|
|
630
|
-
function
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
args[_i] = arguments[_i];
|
|
635
|
-
}
|
|
636
|
-
try {
|
|
637
|
-
handler.apply(void 0, __spreadArray([], __read(args)));
|
|
638
|
-
}
|
|
639
|
-
catch (err) {
|
|
640
|
-
if (config.useDeprecatedSynchronousErrorHandling) {
|
|
641
|
-
captureError(err);
|
|
642
|
-
}
|
|
643
|
-
else {
|
|
644
|
-
reportUnhandledError(err);
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
};
|
|
672
|
+
function handleUnhandledError(error) {
|
|
673
|
+
{
|
|
674
|
+
reportUnhandledError(error);
|
|
675
|
+
}
|
|
648
676
|
}
|
|
649
677
|
function defaultErrorHandler(err) {
|
|
650
678
|
throw err;
|
|
@@ -718,16 +746,20 @@
|
|
|
718
746
|
var _this = this;
|
|
719
747
|
promiseCtor = getPromiseCtor(promiseCtor);
|
|
720
748
|
return new promiseCtor(function (resolve, reject) {
|
|
721
|
-
var
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
749
|
+
var subscriber = new SafeSubscriber({
|
|
750
|
+
next: function (value) {
|
|
751
|
+
try {
|
|
752
|
+
next(value);
|
|
753
|
+
}
|
|
754
|
+
catch (err) {
|
|
755
|
+
reject(err);
|
|
756
|
+
subscriber.unsubscribe();
|
|
757
|
+
}
|
|
758
|
+
},
|
|
759
|
+
error: reject,
|
|
760
|
+
complete: resolve,
|
|
761
|
+
});
|
|
762
|
+
_this.subscribe(subscriber);
|
|
731
763
|
});
|
|
732
764
|
};
|
|
733
765
|
Observable.prototype._subscribe = function (subscriber) {
|
|
@@ -959,11 +991,15 @@
|
|
|
959
991
|
});
|
|
960
992
|
}
|
|
961
993
|
|
|
994
|
+
function createOperatorSubscriber(destination, onNext, onComplete, onError, onFinalize) {
|
|
995
|
+
return new OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize);
|
|
996
|
+
}
|
|
962
997
|
var OperatorSubscriber = (function (_super) {
|
|
963
998
|
__extends(OperatorSubscriber, _super);
|
|
964
|
-
function OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize) {
|
|
999
|
+
function OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize, shouldUnsubscribe) {
|
|
965
1000
|
var _this = _super.call(this, destination) || this;
|
|
966
1001
|
_this.onFinalize = onFinalize;
|
|
1002
|
+
_this.shouldUnsubscribe = shouldUnsubscribe;
|
|
967
1003
|
_this._next = onNext
|
|
968
1004
|
? function (value) {
|
|
969
1005
|
try {
|
|
@@ -1004,9 +1040,11 @@
|
|
|
1004
1040
|
}
|
|
1005
1041
|
OperatorSubscriber.prototype.unsubscribe = function () {
|
|
1006
1042
|
var _a;
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1043
|
+
if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {
|
|
1044
|
+
var closed_1 = this.closed;
|
|
1045
|
+
_super.prototype.unsubscribe.call(this);
|
|
1046
|
+
!closed_1 && ((_a = this.onFinalize) === null || _a === void 0 ? void 0 : _a.call(this));
|
|
1047
|
+
}
|
|
1010
1048
|
};
|
|
1011
1049
|
return OperatorSubscriber;
|
|
1012
1050
|
}(Subscriber));
|
|
@@ -1023,13 +1061,16 @@
|
|
|
1023
1061
|
}(Subscription));
|
|
1024
1062
|
|
|
1025
1063
|
var intervalProvider = {
|
|
1026
|
-
setInterval: function () {
|
|
1064
|
+
setInterval: function (handler, timeout) {
|
|
1027
1065
|
var args = [];
|
|
1028
|
-
for (var _i =
|
|
1029
|
-
args[_i] = arguments[_i];
|
|
1066
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1067
|
+
args[_i - 2] = arguments[_i];
|
|
1030
1068
|
}
|
|
1031
1069
|
var delegate = intervalProvider.delegate;
|
|
1032
|
-
|
|
1070
|
+
if (delegate === null || delegate === void 0 ? void 0 : delegate.setInterval) {
|
|
1071
|
+
return delegate.setInterval.apply(delegate, __spreadArray([handler, timeout], __read(args)));
|
|
1072
|
+
}
|
|
1073
|
+
return setInterval.apply(void 0, __spreadArray([handler, timeout], __read(args)));
|
|
1033
1074
|
},
|
|
1034
1075
|
clearInterval: function (handle) {
|
|
1035
1076
|
var delegate = intervalProvider.delegate;
|
|
@@ -1248,7 +1289,7 @@
|
|
|
1248
1289
|
var innerSub = null;
|
|
1249
1290
|
var syncUnsub = false;
|
|
1250
1291
|
var handledResult;
|
|
1251
|
-
innerSub = source.subscribe(
|
|
1292
|
+
innerSub = source.subscribe(createOperatorSubscriber(subscriber, undefined, undefined, function (err) {
|
|
1252
1293
|
handledResult = innerFrom(selector(err, catchError(selector)(source)));
|
|
1253
1294
|
if (innerSub) {
|
|
1254
1295
|
innerSub.unsubscribe();
|
|
@@ -1270,7 +1311,7 @@
|
|
|
1270
1311
|
function observeOn(scheduler, delay) {
|
|
1271
1312
|
if (delay === void 0) { delay = 0; }
|
|
1272
1313
|
return operate(function (source, subscriber) {
|
|
1273
|
-
source.subscribe(
|
|
1314
|
+
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); }));
|
|
1274
1315
|
});
|
|
1275
1316
|
}
|
|
1276
1317
|
|
|
@@ -1390,13 +1431,13 @@
|
|
|
1390
1431
|
function map(project, thisArg) {
|
|
1391
1432
|
return operate(function (source, subscriber) {
|
|
1392
1433
|
var index = 0;
|
|
1393
|
-
source.subscribe(
|
|
1434
|
+
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1394
1435
|
subscriber.next(project.call(thisArg, value, index++));
|
|
1395
1436
|
}));
|
|
1396
1437
|
});
|
|
1397
1438
|
}
|
|
1398
1439
|
|
|
1399
|
-
function mergeInternals(source, subscriber, project, concurrent, onBeforeNext, expand, innerSubScheduler,
|
|
1440
|
+
function mergeInternals(source, subscriber, project, concurrent, onBeforeNext, expand, innerSubScheduler, additionalFinalizer) {
|
|
1400
1441
|
var buffer = [];
|
|
1401
1442
|
var active = 0;
|
|
1402
1443
|
var index = 0;
|
|
@@ -1411,7 +1452,7 @@
|
|
|
1411
1452
|
expand && subscriber.next(value);
|
|
1412
1453
|
active++;
|
|
1413
1454
|
var innerComplete = false;
|
|
1414
|
-
innerFrom(project(value, index++)).subscribe(
|
|
1455
|
+
innerFrom(project(value, index++)).subscribe(createOperatorSubscriber(subscriber, function (innerValue) {
|
|
1415
1456
|
onBeforeNext === null || onBeforeNext === void 0 ? void 0 : onBeforeNext(innerValue);
|
|
1416
1457
|
if (expand) {
|
|
1417
1458
|
outerNext(innerValue);
|
|
@@ -1445,12 +1486,12 @@
|
|
|
1445
1486
|
}
|
|
1446
1487
|
}));
|
|
1447
1488
|
};
|
|
1448
|
-
source.subscribe(
|
|
1489
|
+
source.subscribe(createOperatorSubscriber(subscriber, outerNext, function () {
|
|
1449
1490
|
isComplete = true;
|
|
1450
1491
|
checkComplete();
|
|
1451
1492
|
}));
|
|
1452
1493
|
return function () {
|
|
1453
|
-
|
|
1494
|
+
additionalFinalizer === null || additionalFinalizer === void 0 ? void 0 : additionalFinalizer();
|
|
1454
1495
|
};
|
|
1455
1496
|
}
|
|
1456
1497
|
|
|
@@ -1499,7 +1540,7 @@
|
|
|
1499
1540
|
}
|
|
1500
1541
|
emit();
|
|
1501
1542
|
}
|
|
1502
|
-
source.subscribe(
|
|
1543
|
+
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1503
1544
|
lastValue = value;
|
|
1504
1545
|
lastTime = scheduler.now();
|
|
1505
1546
|
if (!activeTask) {
|
|
@@ -1531,7 +1572,7 @@
|
|
|
1531
1572
|
function () { return EMPTY; }
|
|
1532
1573
|
: operate(function (source, subscriber) {
|
|
1533
1574
|
var seen = 0;
|
|
1534
|
-
source.subscribe(
|
|
1575
|
+
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1535
1576
|
if (++seen <= count) {
|
|
1536
1577
|
subscriber.next(value);
|
|
1537
1578
|
if (count <= seen) {
|
|
@@ -1544,7 +1585,7 @@
|
|
|
1544
1585
|
|
|
1545
1586
|
function ignoreElements() {
|
|
1546
1587
|
return operate(function (source, subscriber) {
|
|
1547
|
-
source.subscribe(
|
|
1588
|
+
source.subscribe(createOperatorSubscriber(subscriber, noop));
|
|
1548
1589
|
});
|
|
1549
1590
|
}
|
|
1550
1591
|
|
|
@@ -1573,7 +1614,7 @@
|
|
|
1573
1614
|
return operate(function (source, subscriber) {
|
|
1574
1615
|
var previousKey;
|
|
1575
1616
|
var first = true;
|
|
1576
|
-
source.subscribe(
|
|
1617
|
+
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1577
1618
|
var currentKey = keySelector(value);
|
|
1578
1619
|
if (first || !comparator(previousKey, currentKey)) {
|
|
1579
1620
|
first = false;
|
|
@@ -1590,7 +1631,7 @@
|
|
|
1590
1631
|
function filter(predicate, thisArg) {
|
|
1591
1632
|
return operate(function (source, subscriber) {
|
|
1592
1633
|
var index = 0;
|
|
1593
|
-
source.subscribe(
|
|
1634
|
+
source.subscribe(createOperatorSubscriber(subscriber, function (value) { return predicate.call(thisArg, value, index++) && subscriber.next(value); }));
|
|
1594
1635
|
});
|
|
1595
1636
|
}
|
|
1596
1637
|
|
|
@@ -1615,11 +1656,11 @@
|
|
|
1615
1656
|
var index = 0;
|
|
1616
1657
|
var isComplete = false;
|
|
1617
1658
|
var checkComplete = function () { return isComplete && !innerSubscriber && subscriber.complete(); };
|
|
1618
|
-
source.subscribe(
|
|
1659
|
+
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1619
1660
|
innerSubscriber === null || innerSubscriber === void 0 ? void 0 : innerSubscriber.unsubscribe();
|
|
1620
1661
|
var innerIndex = 0;
|
|
1621
1662
|
var outerIndex = index++;
|
|
1622
|
-
innerFrom(project(value, outerIndex)).subscribe((innerSubscriber =
|
|
1663
|
+
innerFrom(project(value, outerIndex)).subscribe((innerSubscriber = createOperatorSubscriber(subscriber, function (innerValue) { return subscriber.next(resultSelector ? resultSelector(value, innerValue, outerIndex, innerIndex++) : innerValue); }, function () {
|
|
1623
1664
|
innerSubscriber = null;
|
|
1624
1665
|
checkComplete();
|
|
1625
1666
|
})));
|
|
@@ -1640,7 +1681,7 @@
|
|
|
1640
1681
|
var _a;
|
|
1641
1682
|
(_a = tapObserver.subscribe) === null || _a === void 0 ? void 0 : _a.call(tapObserver);
|
|
1642
1683
|
var isUnsub = true;
|
|
1643
|
-
source.subscribe(
|
|
1684
|
+
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1644
1685
|
var _a;
|
|
1645
1686
|
(_a = tapObserver.next) === null || _a === void 0 ? void 0 : _a.call(tapObserver, value);
|
|
1646
1687
|
subscriber.next(value);
|
|
@@ -1676,11 +1717,7 @@
|
|
|
1676
1717
|
};
|
|
1677
1718
|
});
|
|
1678
1719
|
function timeout(config, schedulerArg) {
|
|
1679
|
-
var _a = (isValidDate(config)
|
|
1680
|
-
? { first: config }
|
|
1681
|
-
: typeof config === 'number'
|
|
1682
|
-
? { each: config }
|
|
1683
|
-
: 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;
|
|
1720
|
+
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;
|
|
1684
1721
|
if (first == null && each == null) {
|
|
1685
1722
|
throw new TypeError('No timeout provided.');
|
|
1686
1723
|
}
|
|
@@ -1704,7 +1741,7 @@
|
|
|
1704
1741
|
}
|
|
1705
1742
|
}, delay);
|
|
1706
1743
|
};
|
|
1707
|
-
originalSourceSubscription = source.subscribe(
|
|
1744
|
+
originalSourceSubscription = source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1708
1745
|
timerSubscription === null || timerSubscription === void 0 ? void 0 : timerSubscription.unsubscribe();
|
|
1709
1746
|
seen++;
|
|
1710
1747
|
subscriber.next((lastValue = value));
|
|
@@ -1715,7 +1752,7 @@
|
|
|
1715
1752
|
}
|
|
1716
1753
|
lastValue = null;
|
|
1717
1754
|
}));
|
|
1718
|
-
startTimer(first != null ? (typeof first === 'number' ? first : +first - scheduler.now()) : each);
|
|
1755
|
+
!seen && startTimer(first != null ? (typeof first === 'number' ? first : +first - scheduler.now()) : each);
|
|
1719
1756
|
});
|
|
1720
1757
|
}
|
|
1721
1758
|
function timeoutErrorFactory(info) {
|
|
@@ -1725,7 +1762,7 @@
|
|
|
1725
1762
|
//const hasSW = 'serviceWorker' in navigator;
|
|
1726
1763
|
let hasComplainedAboutSyncEvent = false;
|
|
1727
1764
|
function registerSyncEvent(db, purpose) {
|
|
1728
|
-
return __awaiter
|
|
1765
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1729
1766
|
try {
|
|
1730
1767
|
// Send sync event to SW:
|
|
1731
1768
|
const sw = yield navigator.serviceWorker.ready;
|
|
@@ -1756,7 +1793,7 @@
|
|
|
1756
1793
|
}
|
|
1757
1794
|
function registerPeriodicSyncEvent(db) {
|
|
1758
1795
|
var _a;
|
|
1759
|
-
return __awaiter
|
|
1796
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1760
1797
|
try {
|
|
1761
1798
|
// Register periodicSync event to SW:
|
|
1762
1799
|
// @ts-ignore
|
|
@@ -1814,7 +1851,7 @@
|
|
|
1814
1851
|
};
|
|
1815
1852
|
|
|
1816
1853
|
function computeRealmSetHash({ realms, inviteRealms, }) {
|
|
1817
|
-
return __awaiter
|
|
1854
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1818
1855
|
const data = JSON.stringify([
|
|
1819
1856
|
...realms.map((realmId) => ({ realmId, accepted: true })),
|
|
1820
1857
|
...inviteRealms.map((realmId) => ({ realmId, accepted: false })),
|
|
@@ -1851,8 +1888,8 @@
|
|
|
1851
1888
|
}
|
|
1852
1889
|
|
|
1853
1890
|
function listClientChanges(mutationTables, db, { since = {}, limit = Infinity } = {}) {
|
|
1854
|
-
return __awaiter
|
|
1855
|
-
const allMutsOnTables = yield Promise.all(mutationTables.map((mutationTable) => __awaiter
|
|
1891
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1892
|
+
const allMutsOnTables = yield Promise.all(mutationTables.map((mutationTable) => __awaiter(this, void 0, void 0, function* () {
|
|
1856
1893
|
const tableName = getTableFromMutationTable(mutationTable.name);
|
|
1857
1894
|
const lastRevision = since[tableName];
|
|
1858
1895
|
let query = lastRevision
|
|
@@ -1910,6 +1947,10 @@
|
|
|
1910
1947
|
if (!b)
|
|
1911
1948
|
throw new Error('Assertion Failed');
|
|
1912
1949
|
}
|
|
1950
|
+
const _hasOwn = {}.hasOwnProperty;
|
|
1951
|
+
function hasOwn(obj, prop) {
|
|
1952
|
+
return _hasOwn.call(obj, prop);
|
|
1953
|
+
}
|
|
1913
1954
|
function setByKeyPath(obj, keyPath, value) {
|
|
1914
1955
|
if (!obj || keyPath === undefined)
|
|
1915
1956
|
return;
|
|
@@ -1942,8 +1983,8 @@
|
|
|
1942
1983
|
//@ts-ignore: even if currentKeyPath would be numeric string and obj would be array - it works.
|
|
1943
1984
|
var innerObj = obj[currentKeyPath];
|
|
1944
1985
|
//@ts-ignore: even if currentKeyPath would be numeric string and obj would be array - it works.
|
|
1945
|
-
if (!innerObj)
|
|
1946
|
-
innerObj = obj[currentKeyPath] = {};
|
|
1986
|
+
if (!innerObj || !hasOwn(obj, currentKeyPath))
|
|
1987
|
+
innerObj = (obj[currentKeyPath] = {});
|
|
1947
1988
|
setByKeyPath(innerObj, remainingKeyPath, value);
|
|
1948
1989
|
}
|
|
1949
1990
|
}
|
|
@@ -1962,7 +2003,7 @@
|
|
|
1962
2003
|
}
|
|
1963
2004
|
}
|
|
1964
2005
|
}
|
|
1965
|
-
const randomString = typeof
|
|
2006
|
+
const randomString = typeof Buffer !== 'undefined' ? (bytes) => {
|
|
1966
2007
|
// Node
|
|
1967
2008
|
const buf = Buffer.alloc(bytes);
|
|
1968
2009
|
randomFillSync(buf);
|
|
@@ -2201,28 +2242,28 @@
|
|
|
2201
2242
|
}
|
|
2202
2243
|
|
|
2203
2244
|
function listSyncifiedChanges(tablesToSyncify, currentUser, schema, alreadySyncedRealms) {
|
|
2204
|
-
return __awaiter
|
|
2245
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2205
2246
|
const txid = `upload-${randomString$1(8)}`;
|
|
2206
2247
|
if (currentUser.isLoggedIn) {
|
|
2207
2248
|
if (tablesToSyncify.length > 0) {
|
|
2208
2249
|
const ignoredRealms = new Set(alreadySyncedRealms || []);
|
|
2209
|
-
const upserts = yield Promise.all(tablesToSyncify.map((table) => __awaiter
|
|
2250
|
+
const upserts = yield Promise.all(tablesToSyncify.map((table) => __awaiter(this, void 0, void 0, function* () {
|
|
2210
2251
|
const { extractKey } = table.core.schema.primaryKey;
|
|
2211
2252
|
if (!extractKey)
|
|
2212
2253
|
return { table: table.name, muts: [] }; // Outbound tables are not synced.
|
|
2213
2254
|
const dexieCloudTableSchema = schema[table.name];
|
|
2214
2255
|
const query = (dexieCloudTableSchema === null || dexieCloudTableSchema === void 0 ? void 0 : dexieCloudTableSchema.generatedGlobalId)
|
|
2215
2256
|
? table.filter((item) => {
|
|
2216
|
-
|
|
2257
|
+
extractKey(item);
|
|
2217
2258
|
return (!ignoredRealms.has(item.realmId || '') &&
|
|
2218
2259
|
//(id[0] !== '#' || !!item.$ts) && // Private obj need no sync if not changed
|
|
2219
|
-
|
|
2260
|
+
isValidAtID(extractKey(item), dexieCloudTableSchema === null || dexieCloudTableSchema === void 0 ? void 0 : dexieCloudTableSchema.idPrefix));
|
|
2220
2261
|
})
|
|
2221
2262
|
: table.filter((item) => {
|
|
2222
|
-
extractKey(item);
|
|
2263
|
+
const id = extractKey(item);
|
|
2223
2264
|
return (!ignoredRealms.has(item.realmId || '') &&
|
|
2224
2265
|
//(id[0] !== '#' || !!item.$ts) && // Private obj need no sync if not changed
|
|
2225
|
-
|
|
2266
|
+
isValidSyncableID(id));
|
|
2226
2267
|
});
|
|
2227
2268
|
const unsyncedObjects = yield query.toArray();
|
|
2228
2269
|
if (unsyncedObjects.length > 0) {
|
|
@@ -2260,15 +2301,12 @@
|
|
|
2260
2301
|
}
|
|
2261
2302
|
|
|
2262
2303
|
function interactWithUser(userInteraction, req) {
|
|
2263
|
-
let done = false;
|
|
2264
2304
|
return new Promise((resolve, reject) => {
|
|
2265
2305
|
const interactionProps = Object.assign(Object.assign({}, req), { onSubmit: (res) => {
|
|
2266
2306
|
userInteraction.next(undefined);
|
|
2267
|
-
done = true;
|
|
2268
2307
|
resolve(res);
|
|
2269
2308
|
}, onCancel: () => {
|
|
2270
2309
|
userInteraction.next(undefined);
|
|
2271
|
-
done = true;
|
|
2272
2310
|
reject(new Dexie__default["default"].AbortError("User cancelled"));
|
|
2273
2311
|
} });
|
|
2274
2312
|
userInteraction.next(interactionProps);
|
|
@@ -2292,7 +2330,7 @@
|
|
|
2292
2330
|
});
|
|
2293
2331
|
}
|
|
2294
2332
|
function promptForEmail(userInteraction, title, emailHint) {
|
|
2295
|
-
return __awaiter
|
|
2333
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2296
2334
|
let email = emailHint || '';
|
|
2297
2335
|
while (!email || !/^[\w-\.]+@([\w-]+\.)+[\w-]{2,10}$/.test(email)) {
|
|
2298
2336
|
email = (yield interactWithUser(userInteraction, {
|
|
@@ -2320,7 +2358,7 @@
|
|
|
2320
2358
|
});
|
|
2321
2359
|
}
|
|
2322
2360
|
function promptForOTP(userInteraction, email, alert) {
|
|
2323
|
-
return __awaiter
|
|
2361
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2324
2362
|
const alerts = [
|
|
2325
2363
|
{
|
|
2326
2364
|
type: 'info',
|
|
@@ -2350,7 +2388,7 @@
|
|
|
2350
2388
|
|
|
2351
2389
|
function loadAccessToken(db) {
|
|
2352
2390
|
var _a, _b;
|
|
2353
|
-
return __awaiter
|
|
2391
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2354
2392
|
const currentUser = yield db.getCurrentUser();
|
|
2355
2393
|
const { accessToken, accessTokenExpiration, refreshToken, refreshTokenExpiration, claims, } = currentUser;
|
|
2356
2394
|
if (!accessToken)
|
|
@@ -2375,7 +2413,7 @@
|
|
|
2375
2413
|
});
|
|
2376
2414
|
}
|
|
2377
2415
|
function authenticate(url, context, fetchToken, userInteraction, hints) {
|
|
2378
|
-
return __awaiter
|
|
2416
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2379
2417
|
if (context.accessToken &&
|
|
2380
2418
|
context.accessTokenExpiration.getTime() > Date.now()) {
|
|
2381
2419
|
return context;
|
|
@@ -2391,7 +2429,7 @@
|
|
|
2391
2429
|
});
|
|
2392
2430
|
}
|
|
2393
2431
|
function refreshAccessToken(url, login) {
|
|
2394
|
-
return __awaiter
|
|
2432
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2395
2433
|
if (!login.refreshToken)
|
|
2396
2434
|
throw new Error(`Cannot refresh token - refresh token is missing.`);
|
|
2397
2435
|
if (!login.nonExportablePrivateKey)
|
|
@@ -2427,7 +2465,7 @@
|
|
|
2427
2465
|
});
|
|
2428
2466
|
}
|
|
2429
2467
|
function userAuthenticate(context, fetchToken, userInteraction, hints) {
|
|
2430
|
-
return __awaiter
|
|
2468
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2431
2469
|
const { privateKey, publicKey } = yield crypto.subtle.generateKey({
|
|
2432
2470
|
name: 'RSASSA-PKCS1-v1_5',
|
|
2433
2471
|
modulusLength: 2048,
|
|
@@ -3086,7 +3124,7 @@
|
|
|
3086
3124
|
|
|
3087
3125
|
//import {BisonWebStreamReader} from "dreambase-library/dist/typeson-simplified/BisonWebStreamReader";
|
|
3088
3126
|
function syncWithServer(changes, syncState, baseRevs, db, databaseUrl, schema, clientIdentity, currentUser) {
|
|
3089
|
-
return __awaiter
|
|
3127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3090
3128
|
//
|
|
3091
3129
|
// Push changes to server using fetch
|
|
3092
3130
|
//
|
|
@@ -3142,7 +3180,7 @@
|
|
|
3142
3180
|
}
|
|
3143
3181
|
|
|
3144
3182
|
function modifyLocalObjectsWithNewUserId(syncifiedTables, currentUser, alreadySyncedRealms) {
|
|
3145
|
-
return __awaiter
|
|
3183
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3146
3184
|
const ignoredRealms = new Set(alreadySyncedRealms || []);
|
|
3147
3185
|
for (const table of syncifiedTables) {
|
|
3148
3186
|
if (table.name === "members") {
|
|
@@ -3192,7 +3230,7 @@
|
|
|
3192
3230
|
self.addEventListener('offline', () => isOnline = false);
|
|
3193
3231
|
|
|
3194
3232
|
function updateBaseRevs(db, schema, latestRevisions, serverRev) {
|
|
3195
|
-
return __awaiter
|
|
3233
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3196
3234
|
yield db.$baseRevs.bulkPut(Object.keys(schema)
|
|
3197
3235
|
.filter((table) => schema[table].markedForSync)
|
|
3198
3236
|
.map((tableName) => {
|
|
@@ -3215,7 +3253,7 @@
|
|
|
3215
3253
|
}
|
|
3216
3254
|
|
|
3217
3255
|
function bulkUpdate(table, keys, changeSpecs) {
|
|
3218
|
-
return __awaiter
|
|
3256
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3219
3257
|
const objs = yield table.bulkGet(keys);
|
|
3220
3258
|
const resultKeys = [];
|
|
3221
3259
|
const resultObjs = [];
|
|
@@ -3243,7 +3281,7 @@
|
|
|
3243
3281
|
}
|
|
3244
3282
|
|
|
3245
3283
|
function applyServerChanges(changes, db) {
|
|
3246
|
-
return __awaiter
|
|
3284
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3247
3285
|
console.debug('Applying server changes', changes, Dexie__default["default"].currentTransaction);
|
|
3248
3286
|
for (const { table: tableName, muts } of changes) {
|
|
3249
3287
|
const table = db.table(tableName);
|
|
@@ -3329,7 +3367,7 @@
|
|
|
3329
3367
|
});
|
|
3330
3368
|
}
|
|
3331
3369
|
})
|
|
3332
|
-
.catch((error) => __awaiter
|
|
3370
|
+
.catch((error) => __awaiter(this, void 0, void 0, function* () {
|
|
3333
3371
|
if (syncOptions === null || syncOptions === void 0 ? void 0 : syncOptions.justCheckIfNeeded)
|
|
3334
3372
|
return Promise.reject(error); // Just rethrow.
|
|
3335
3373
|
console.debug('Error from _sync', {
|
|
@@ -3366,7 +3404,7 @@
|
|
|
3366
3404
|
isInitialSync: false,
|
|
3367
3405
|
}) {
|
|
3368
3406
|
var _a;
|
|
3369
|
-
return __awaiter
|
|
3407
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3370
3408
|
if (!justCheckIfNeeded) {
|
|
3371
3409
|
console.debug('SYNC STARTED', { isInitialSync, purpose });
|
|
3372
3410
|
}
|
|
@@ -3383,7 +3421,8 @@
|
|
|
3383
3421
|
// Prepare for syncification by modifying locally unauthorized objects:
|
|
3384
3422
|
//
|
|
3385
3423
|
const persistedSyncState = yield db.getPersistedSyncState();
|
|
3386
|
-
const
|
|
3424
|
+
const readyForSyncification = !isInitialSync && currentUser.isLoggedIn;
|
|
3425
|
+
const tablesToSyncify = readyForSyncification
|
|
3387
3426
|
? getTablesToSyncify(db, persistedSyncState)
|
|
3388
3427
|
: [];
|
|
3389
3428
|
throwIfCancelled(cancelToken);
|
|
@@ -3392,7 +3431,7 @@
|
|
|
3392
3431
|
if (justCheckIfNeeded)
|
|
3393
3432
|
return true;
|
|
3394
3433
|
//console.debug('sync doSyncify is true');
|
|
3395
|
-
yield db.transaction('rw', tablesToSyncify, (tx) => __awaiter
|
|
3434
|
+
yield db.transaction('rw', tablesToSyncify, (tx) => __awaiter(this, void 0, void 0, function* () {
|
|
3396
3435
|
// @ts-ignore
|
|
3397
3436
|
tx.idbtrans.disableChangeTracking = true;
|
|
3398
3437
|
// @ts-ignore
|
|
@@ -3404,7 +3443,7 @@
|
|
|
3404
3443
|
//
|
|
3405
3444
|
// List changes to sync
|
|
3406
3445
|
//
|
|
3407
|
-
const [clientChangeSet, syncState, baseRevs] = yield db.transaction('r', db.tables, () => __awaiter
|
|
3446
|
+
const [clientChangeSet, syncState, baseRevs] = yield db.transaction('r', db.tables, () => __awaiter(this, void 0, void 0, function* () {
|
|
3408
3447
|
const syncState = yield db.getPersistedSyncState();
|
|
3409
3448
|
const baseRevs = yield db.$baseRevs.toArray();
|
|
3410
3449
|
let clientChanges = yield listClientChanges(mutationTables);
|
|
@@ -3441,7 +3480,7 @@
|
|
|
3441
3480
|
//
|
|
3442
3481
|
// Apply changes locally and clear old change entries:
|
|
3443
3482
|
//
|
|
3444
|
-
const done = yield db.transaction('rw', db.tables, (tx) => __awaiter
|
|
3483
|
+
const done = yield db.transaction('rw', db.tables, (tx) => __awaiter(this, void 0, void 0, function* () {
|
|
3445
3484
|
// @ts-ignore
|
|
3446
3485
|
tx.idbtrans.disableChangeTracking = true;
|
|
3447
3486
|
// @ts-ignore
|
|
@@ -3515,9 +3554,11 @@
|
|
|
3515
3554
|
inviteRealms: [],
|
|
3516
3555
|
clientIdentity,
|
|
3517
3556
|
};
|
|
3518
|
-
|
|
3519
|
-
.
|
|
3520
|
-
|
|
3557
|
+
if (readyForSyncification) {
|
|
3558
|
+
newSyncState.syncedTables = tablesToSync
|
|
3559
|
+
.map((tbl) => tbl.name)
|
|
3560
|
+
.concat(tablesToSyncify.map((tbl) => tbl.name));
|
|
3561
|
+
}
|
|
3521
3562
|
newSyncState.latestRevisions = latestRevisions;
|
|
3522
3563
|
newSyncState.remoteDbId = res.dbId;
|
|
3523
3564
|
newSyncState.initiallySynced = true;
|
|
@@ -3546,7 +3587,7 @@
|
|
|
3546
3587
|
});
|
|
3547
3588
|
}
|
|
3548
3589
|
function deleteObjectsFromRemovedRealms(db, res, prevState) {
|
|
3549
|
-
return __awaiter
|
|
3590
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3550
3591
|
const deletedRealms = new Set();
|
|
3551
3592
|
const rejectedRealms = new Set();
|
|
3552
3593
|
const previousRealmSet = prevState ? prevState.realms : [];
|
|
@@ -3610,7 +3651,7 @@
|
|
|
3610
3651
|
let isWorking = false;
|
|
3611
3652
|
let loopWarning = 0;
|
|
3612
3653
|
let loopDetection = [0, 0, 0, 0, 0, 0, 0, 0, 0, Date.now()];
|
|
3613
|
-
event.subscribe(() => __awaiter
|
|
3654
|
+
event.subscribe(() => __awaiter(this, void 0, void 0, function* () {
|
|
3614
3655
|
if (isWorking)
|
|
3615
3656
|
return;
|
|
3616
3657
|
if (queue.length > 0) {
|
|
@@ -3649,7 +3690,7 @@
|
|
|
3649
3690
|
}
|
|
3650
3691
|
function consumeQueue() {
|
|
3651
3692
|
var _a, _b, _c;
|
|
3652
|
-
return __awaiter
|
|
3693
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3653
3694
|
while (queue.length > 0) {
|
|
3654
3695
|
const msg = queue.shift();
|
|
3655
3696
|
try {
|
|
@@ -3706,7 +3747,7 @@
|
|
|
3706
3747
|
triggerSync(db, 'pull');
|
|
3707
3748
|
break;
|
|
3708
3749
|
}
|
|
3709
|
-
yield db.transaction('rw', db.dx.tables, (tx) => __awaiter
|
|
3750
|
+
yield db.transaction('rw', db.dx.tables, (tx) => __awaiter(this, void 0, void 0, function* () {
|
|
3710
3751
|
// @ts-ignore
|
|
3711
3752
|
tx.idbtrans.disableChangeTracking = true;
|
|
3712
3753
|
// @ts-ignore
|
|
@@ -3915,7 +3956,7 @@
|
|
|
3915
3956
|
}));
|
|
3916
3957
|
}
|
|
3917
3958
|
save() {
|
|
3918
|
-
return __awaiter
|
|
3959
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3919
3960
|
const db = wm.get(this);
|
|
3920
3961
|
db.table("$logins").put(this);
|
|
3921
3962
|
});
|
|
@@ -3926,7 +3967,7 @@
|
|
|
3926
3967
|
const { userInteraction } = db.cloud;
|
|
3927
3968
|
return function otpAuthenticate({ public_key, hints }) {
|
|
3928
3969
|
var _a;
|
|
3929
|
-
return __awaiter
|
|
3970
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3930
3971
|
let tokenRequest;
|
|
3931
3972
|
const url = (_a = db.cloud.options) === null || _a === void 0 ? void 0 : _a.databaseUrl;
|
|
3932
3973
|
if (!url)
|
|
@@ -4028,11 +4069,11 @@
|
|
|
4028
4069
|
* @param newUser
|
|
4029
4070
|
*/
|
|
4030
4071
|
function setCurrentUser(db, user) {
|
|
4031
|
-
return __awaiter
|
|
4072
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4032
4073
|
if (user.userId === db.cloud.currentUserId)
|
|
4033
4074
|
return; // Already this user.
|
|
4034
4075
|
const $logins = db.table('$logins');
|
|
4035
|
-
yield db.transaction('rw', $logins, (tx) => __awaiter
|
|
4076
|
+
yield db.transaction('rw', $logins, (tx) => __awaiter(this, void 0, void 0, function* () {
|
|
4036
4077
|
const existingLogins = yield $logins.toArray();
|
|
4037
4078
|
yield Promise.all(existingLogins
|
|
4038
4079
|
.filter((login) => login.userId !== user.userId && login.isLoggedIn)
|
|
@@ -4083,7 +4124,7 @@
|
|
|
4083
4124
|
}
|
|
4084
4125
|
|
|
4085
4126
|
function login(db, hints) {
|
|
4086
|
-
return __awaiter
|
|
4127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4087
4128
|
const currentUser = yield db.getCurrentUser();
|
|
4088
4129
|
if (currentUser.isLoggedIn) {
|
|
4089
4130
|
if (hints) {
|
|
@@ -4682,7 +4723,7 @@
|
|
|
4682
4723
|
}
|
|
4683
4724
|
|
|
4684
4725
|
function performInitialSync(db, cloudOptions, cloudSchema) {
|
|
4685
|
-
return __awaiter
|
|
4726
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4686
4727
|
console.debug('Performing initial sync');
|
|
4687
4728
|
yield sync(db, cloudOptions, cloudSchema, { isInitialSync: true });
|
|
4688
4729
|
console.debug('Done initial sync');
|
|
@@ -4825,7 +4866,7 @@
|
|
|
4825
4866
|
.then(() => (this.reconnecting = false)); // finally()
|
|
4826
4867
|
}
|
|
4827
4868
|
connect() {
|
|
4828
|
-
return __awaiter
|
|
4869
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4829
4870
|
this.lastServerActivity = new Date();
|
|
4830
4871
|
if (this.pauseUntil && this.pauseUntil > new Date()) {
|
|
4831
4872
|
console.debug('WS not reconnecting just yet', {
|
|
@@ -4848,7 +4889,7 @@
|
|
|
4848
4889
|
return;
|
|
4849
4890
|
}
|
|
4850
4891
|
this.webSocketStatus.next('connecting');
|
|
4851
|
-
this.pinger = setInterval(() => __awaiter
|
|
4892
|
+
this.pinger = setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
|
4852
4893
|
if (this.closed) {
|
|
4853
4894
|
console.debug('pinger check', this.id, 'CLOSED.');
|
|
4854
4895
|
this.teardown();
|
|
@@ -4974,7 +5015,7 @@
|
|
|
4974
5015
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
4975
5016
|
}
|
|
4976
5017
|
function waitAndReconnectWhenUserDoesSomething(error) {
|
|
4977
|
-
return __awaiter
|
|
5018
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4978
5019
|
console.error(`WebSocket observable: error but revive when user does some active thing...`, error);
|
|
4979
5020
|
// Sleep some seconds...
|
|
4980
5021
|
yield sleep$1(3000);
|
|
@@ -5000,7 +5041,7 @@
|
|
|
5000
5041
|
function createObservable() {
|
|
5001
5042
|
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.
|
|
5002
5043
|
take(1), // Don't continue waking up whenever syncState change
|
|
5003
|
-
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
|
|
5044
|
+
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]) =>
|
|
5004
5045
|
// Let server end query changes from last entry of same client-ID and forward.
|
|
5005
5046
|
// If no new entries, server won't bother the client. If new entries, server sends only those
|
|
5006
5047
|
// and the baseRev of the last from same client-ID.
|
|
@@ -5009,7 +5050,7 @@
|
|
|
5009
5050
|
: rxjs.from([])), catchError((error) => {
|
|
5010
5051
|
if ((error === null || error === void 0 ? void 0 : error.name) === 'TokenExpiredError') {
|
|
5011
5052
|
console.debug('WebSocket observable: Token expired. Refreshing token...');
|
|
5012
|
-
return rxjs.of(true).pipe(switchMap(() => __awaiter
|
|
5053
|
+
return rxjs.of(true).pipe(switchMap(() => __awaiter(this, void 0, void 0, function* () {
|
|
5013
5054
|
// Refresh access token
|
|
5014
5055
|
const user = yield db.getCurrentUser();
|
|
5015
5056
|
const refreshedLogin = yield refreshAccessToken(db.cloud.options.databaseUrl, user);
|
|
@@ -5042,7 +5083,7 @@
|
|
|
5042
5083
|
|
|
5043
5084
|
function isSyncNeeded(db) {
|
|
5044
5085
|
var _a;
|
|
5045
|
-
return __awaiter
|
|
5086
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5046
5087
|
return ((_a = db.cloud.options) === null || _a === void 0 ? void 0 : _a.databaseUrl) && db.cloud.schema
|
|
5047
5088
|
? yield sync(db, db.cloud.options, db.cloud.schema, { justCheckIfNeeded: true })
|
|
5048
5089
|
: false;
|
|
@@ -5057,15 +5098,15 @@
|
|
|
5057
5098
|
const GUARDED_JOB_HEARTBEAT = 1 * SECONDS;
|
|
5058
5099
|
const GUARDED_JOB_TIMEOUT = 1 * MINUTES;
|
|
5059
5100
|
function performGuardedJob(db, jobName, jobsTableName, job, { awaitRemoteJob } = {}) {
|
|
5060
|
-
return __awaiter
|
|
5101
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5061
5102
|
// Start working.
|
|
5062
5103
|
//
|
|
5063
5104
|
// Check if someone else is working on this already.
|
|
5064
5105
|
//
|
|
5065
5106
|
const jobsTable = db.table(jobsTableName);
|
|
5066
5107
|
function aquireLock() {
|
|
5067
|
-
return __awaiter
|
|
5068
|
-
const gotTheLock = yield db.transaction('rw!', jobsTableName, () => __awaiter
|
|
5108
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5109
|
+
const gotTheLock = yield db.transaction('rw!', jobsTableName, () => __awaiter(this, void 0, void 0, function* () {
|
|
5069
5110
|
const currentWork = yield jobsTable.get(jobName);
|
|
5070
5111
|
if (!currentWork) {
|
|
5071
5112
|
// No one else is working. Let's record that we are.
|
|
@@ -5131,7 +5172,7 @@
|
|
|
5131
5172
|
// Stop heartbeat
|
|
5132
5173
|
clearInterval(heartbeat);
|
|
5133
5174
|
// Remove the persisted job state:
|
|
5134
|
-
yield db.transaction('rw!', jobsTableName, () => __awaiter
|
|
5175
|
+
yield db.transaction('rw!', jobsTableName, () => __awaiter(this, void 0, void 0, function* () {
|
|
5135
5176
|
const currentWork = yield jobsTable.get(jobName);
|
|
5136
5177
|
if (currentWork && currentWork.nodeId === myId) {
|
|
5137
5178
|
yield jobsTable.delete(jobName);
|
|
@@ -5191,7 +5232,7 @@
|
|
|
5191
5232
|
ongoingSyncs.set(db, { promise, pull: (options === null || options === void 0 ? void 0 : options.purpose) !== 'push' });
|
|
5192
5233
|
return promise;
|
|
5193
5234
|
function _syncIfPossible() {
|
|
5194
|
-
return __awaiter
|
|
5235
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5195
5236
|
try {
|
|
5196
5237
|
if (db.cloud.isServiceWorkerDB) {
|
|
5197
5238
|
// We are the dedicated sync SW:
|
|
@@ -5303,7 +5344,7 @@
|
|
|
5303
5344
|
}
|
|
5304
5345
|
}
|
|
5305
5346
|
|
|
5306
|
-
var n,
|
|
5347
|
+
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;
|
|
5307
5348
|
|
|
5308
5349
|
const Styles = {
|
|
5309
5350
|
Error: {
|
|
@@ -5368,35 +5409,35 @@
|
|
|
5368
5409
|
};
|
|
5369
5410
|
|
|
5370
5411
|
function Dialog({ children, className }) {
|
|
5371
|
-
return (
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
|
|
5412
|
+
return (h("div", { className: className },
|
|
5413
|
+
h("div", { style: Styles.Darken }),
|
|
5414
|
+
h("div", { style: Styles.DialogOuter },
|
|
5415
|
+
h("div", { style: Styles.DialogInner }, children))));
|
|
5375
5416
|
}
|
|
5376
5417
|
|
|
5377
|
-
var t,u,
|
|
5418
|
+
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}
|
|
5378
5419
|
|
|
5379
5420
|
function resolveText({ message, messageCode, messageParams }) {
|
|
5380
5421
|
return message.replace(/\{\w+\}/ig, n => messageParams[n.substr(1, n.length - 2)]);
|
|
5381
5422
|
}
|
|
5382
5423
|
|
|
5383
5424
|
function LoginDialog({ title, alerts, fields, onCancel, onSubmit, }) {
|
|
5384
|
-
const [params, setParams] =
|
|
5385
|
-
const firstFieldRef =
|
|
5386
|
-
|
|
5387
|
-
return (
|
|
5388
|
-
|
|
5389
|
-
|
|
5390
|
-
alerts.map((alert) => (
|
|
5391
|
-
|
|
5425
|
+
const [params, setParams] = p({});
|
|
5426
|
+
const firstFieldRef = _(null);
|
|
5427
|
+
s(() => { var _a; return (_a = firstFieldRef.current) === null || _a === void 0 ? void 0 : _a.focus(); }, []);
|
|
5428
|
+
return (h(Dialog, { className: "dxc-login-dlg" },
|
|
5429
|
+
h(p$1, null,
|
|
5430
|
+
h("h3", { style: Styles.WindowHeader }, title),
|
|
5431
|
+
alerts.map((alert) => (h("p", { style: Styles.Alert[alert.type] }, resolveText(alert)))),
|
|
5432
|
+
h("form", { onSubmit: ev => {
|
|
5392
5433
|
ev.preventDefault();
|
|
5393
5434
|
onSubmit(params);
|
|
5394
|
-
} }, Object.entries(fields).map(([fieldName, { type, label, placeholder }], idx) => (
|
|
5435
|
+
} }, Object.entries(fields).map(([fieldName, { type, label, placeholder }], idx) => (h("label", { style: Styles.Label },
|
|
5395
5436
|
label ? `${label}: ` : '',
|
|
5396
|
-
|
|
5397
|
-
|
|
5398
|
-
|
|
5399
|
-
|
|
5437
|
+
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']) })); } })))))),
|
|
5438
|
+
h("div", { style: Styles.ButtonsDiv },
|
|
5439
|
+
h("button", { type: "submit", style: Styles.Button, onClick: () => onSubmit(params) }, "Submit"),
|
|
5440
|
+
h("button", { style: Styles.Button, onClick: onCancel }, "Cancel"))));
|
|
5400
5441
|
}
|
|
5401
5442
|
function valueTransformer(type, value) {
|
|
5402
5443
|
switch (type) {
|
|
@@ -5406,7 +5447,7 @@
|
|
|
5406
5447
|
}
|
|
5407
5448
|
}
|
|
5408
5449
|
|
|
5409
|
-
class LoginGui extends
|
|
5450
|
+
class LoginGui extends d$1 {
|
|
5410
5451
|
constructor(props) {
|
|
5411
5452
|
super(props);
|
|
5412
5453
|
this.observer = (userInteraction) => this.setState({ userInteraction });
|
|
@@ -5425,13 +5466,13 @@
|
|
|
5425
5466
|
if (!userInteraction)
|
|
5426
5467
|
return null;
|
|
5427
5468
|
//if (props.db.cloud.userInteraction.observers.length > 1) return null; // Someone else subscribes.
|
|
5428
|
-
return
|
|
5469
|
+
return h(LoginDialog, Object.assign({}, userInteraction));
|
|
5429
5470
|
}
|
|
5430
5471
|
}
|
|
5431
5472
|
function setupDefaultGUI(db) {
|
|
5432
5473
|
const el = document.createElement('div');
|
|
5433
5474
|
document.body.appendChild(el);
|
|
5434
|
-
|
|
5475
|
+
P(h(LoginGui, { db: db.vip }), el);
|
|
5435
5476
|
let closed = false;
|
|
5436
5477
|
return {
|
|
5437
5478
|
unsubscribe() {
|
|
@@ -5801,12 +5842,12 @@
|
|
|
5801
5842
|
return Object.values(membersById)
|
|
5802
5843
|
.filter((invite) => !invite.accepted && !invite.rejected)
|
|
5803
5844
|
.map((invite) => (Object.assign(Object.assign({}, invite), { accept() {
|
|
5804
|
-
return __awaiter
|
|
5845
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5805
5846
|
yield db.members.update(invite.id, { accepted: new Date() });
|
|
5806
5847
|
});
|
|
5807
5848
|
},
|
|
5808
5849
|
reject() {
|
|
5809
|
-
return __awaiter
|
|
5850
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5810
5851
|
yield db.members.update(invite.id, { rejected: new Date() });
|
|
5811
5852
|
});
|
|
5812
5853
|
} })));
|
|
@@ -5826,7 +5867,7 @@
|
|
|
5826
5867
|
let configuredProgramatically = false;
|
|
5827
5868
|
// local sync worker - used when there's no service worker.
|
|
5828
5869
|
let localSyncWorker = null;
|
|
5829
|
-
dexie.on('ready', (dexie) => __awaiter
|
|
5870
|
+
dexie.on('ready', (dexie) => __awaiter(this, void 0, void 0, function* () {
|
|
5830
5871
|
try {
|
|
5831
5872
|
yield onDbReady(dexie);
|
|
5832
5873
|
}
|
|
@@ -5850,7 +5891,7 @@
|
|
|
5850
5891
|
currentUserEmitter.next(UNAUTHORIZED_USER);
|
|
5851
5892
|
});
|
|
5852
5893
|
dexie.cloud = {
|
|
5853
|
-
version: '4.0.0-beta.
|
|
5894
|
+
version: '4.0.0-beta.23',
|
|
5854
5895
|
options: Object.assign({}, DEFAULT_OPTIONS),
|
|
5855
5896
|
schema: null,
|
|
5856
5897
|
get currentUserId() {
|
|
@@ -5865,7 +5906,7 @@
|
|
|
5865
5906
|
userInteraction: new rxjs.BehaviorSubject(undefined),
|
|
5866
5907
|
webSocketStatus: new rxjs.BehaviorSubject('not-started'),
|
|
5867
5908
|
login(hint) {
|
|
5868
|
-
return __awaiter
|
|
5909
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5869
5910
|
const db = DexieCloudDB(dexie);
|
|
5870
5911
|
yield db.cloud.sync();
|
|
5871
5912
|
yield login(db, hint);
|
|
@@ -5884,7 +5925,7 @@
|
|
|
5884
5925
|
updateSchemaFromOptions(dexie.cloud.schema, dexie.cloud.options);
|
|
5885
5926
|
},
|
|
5886
5927
|
sync({ wait, purpose } = { wait: true, purpose: 'push' }) {
|
|
5887
|
-
return __awaiter
|
|
5928
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5888
5929
|
if (wait === undefined)
|
|
5889
5930
|
wait = true;
|
|
5890
5931
|
const db = DexieCloudDB(dexie);
|
|
@@ -5906,7 +5947,7 @@
|
|
|
5906
5947
|
triggerSync(db, purpose);
|
|
5907
5948
|
if (wait) {
|
|
5908
5949
|
console.debug('db.cloud.login() is waiting for sync completion...');
|
|
5909
|
-
yield rxjs.from(Dexie.liveQuery(() => __awaiter
|
|
5950
|
+
yield rxjs.from(Dexie.liveQuery(() => __awaiter(this, void 0, void 0, function* () {
|
|
5910
5951
|
const syncNeeded = yield isSyncNeeded(db);
|
|
5911
5952
|
const newSyncState = yield db.getPersistedSyncState();
|
|
5912
5953
|
if ((newSyncState === null || newSyncState === void 0 ? void 0 : newSyncState.timestamp) !== (syncState === null || syncState === void 0 ? void 0 : syncState.timestamp) &&
|
|
@@ -5942,7 +5983,7 @@
|
|
|
5942
5983
|
dexie.use(createIdGenerationMiddleware(DexieCloudDB(dexie)));
|
|
5943
5984
|
function onDbReady(dexie) {
|
|
5944
5985
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
5945
|
-
return __awaiter
|
|
5986
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5946
5987
|
closed = false; // As Dexie calls us, we are not closed anymore. Maybe reopened? Remember db.ready event is registered with sticky flag!
|
|
5947
5988
|
const db = DexieCloudDB(dexie);
|
|
5948
5989
|
// Setup default GUI:
|
|
@@ -5962,7 +6003,7 @@
|
|
|
5962
6003
|
const swRegistrations = 'serviceWorker' in navigator
|
|
5963
6004
|
? yield navigator.serviceWorker.getRegistrations()
|
|
5964
6005
|
: [];
|
|
5965
|
-
const initiallySynced = yield db.transaction('rw', db.$syncState, () => __awaiter
|
|
6006
|
+
const initiallySynced = yield db.transaction('rw', db.$syncState, () => __awaiter(this, void 0, void 0, function* () {
|
|
5966
6007
|
var _h, _j;
|
|
5967
6008
|
const { options, schema } = db.cloud;
|
|
5968
6009
|
const [persistedOptions, persistedSchema, persistedSyncState] = yield Promise.all([
|
|
@@ -6103,7 +6144,7 @@
|
|
|
6103
6144
|
});
|
|
6104
6145
|
}
|
|
6105
6146
|
}
|
|
6106
|
-
dexieCloud.version = '4.0.0-beta.
|
|
6147
|
+
dexieCloud.version = '4.0.0-beta.23';
|
|
6107
6148
|
Dexie__default["default"].Cloud = dexieCloud;
|
|
6108
6149
|
|
|
6109
6150
|
// In case the SW lives for a while, let it reuse already opened connections:
|
|
@@ -6134,7 +6175,7 @@
|
|
|
6134
6175
|
return promise;
|
|
6135
6176
|
function _syncDB(dbName, purpose) {
|
|
6136
6177
|
var _a;
|
|
6137
|
-
return __awaiter
|
|
6178
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6138
6179
|
let db = managedDBs.get(dbName);
|
|
6139
6180
|
if (!db) {
|
|
6140
6181
|
console.debug('Dexie Cloud SW: Creating new Dexie instance for', dbName);
|
|
@@ -6212,7 +6253,7 @@
|
|
|
6212
6253
|
// Mimic background sync behavior - retry in X minutes on failure.
|
|
6213
6254
|
// But lesser timeout and more number of times.
|
|
6214
6255
|
const syncAndRetry = (num = 1) => {
|
|
6215
|
-
return syncDB(dbName, event.data.purpose || "pull").catch((e) => __awaiter
|
|
6256
|
+
return syncDB(dbName, event.data.purpose || "pull").catch((e) => __awaiter(void 0, void 0, void 0, function* () {
|
|
6216
6257
|
if (num === 3)
|
|
6217
6258
|
throw e;
|
|
6218
6259
|
yield sleep(60000); // 1 minute
|