dexie-cloud-addon 4.0.1-beta.47 → 4.0.1-beta.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{types → modern}/TSON.d.ts +1 -1
- package/dist/modern/dexie-cloud-addon.d.ts +3 -0
- package/dist/modern/dexie-cloud-addon.js +21 -58
- package/dist/modern/dexie-cloud-addon.js.map +1 -1
- package/dist/modern/dexie-cloud-addon.min.js +2 -2
- package/dist/modern/dexie-cloud-addon.min.js.map +1 -1
- package/dist/modern/dexie-cloud-client.d.ts +22 -0
- package/dist/modern/service-worker.js +1568 -19
- package/dist/modern/service-worker.js.map +1 -1
- package/dist/modern/service-worker.min.js +2 -2
- package/dist/modern/service-worker.min.js.map +1 -1
- package/dist/umd/DISABLE_SERVICEWORKER_STRATEGY.d.ts +1 -0
- package/dist/umd/DXCWebSocketStatus.d.ts +1 -0
- package/dist/umd/DexieCloudAPI.d.ts +72 -0
- package/dist/umd/DexieCloudOptions.d.ts +22 -0
- package/dist/umd/DexieCloudSyncOptions.d.ts +4 -0
- package/dist/umd/DexieCloudTable.d.ts +18 -0
- package/dist/umd/InvalidLicenseError.d.ts +5 -0
- package/dist/umd/Invite.d.ts +8 -0
- package/dist/umd/PermissionChecker.d.ts +15 -0
- package/dist/umd/TSON.d.ts +17 -0
- package/dist/umd/WSObservable.d.ts +68 -0
- package/dist/umd/associate.d.ts +1 -0
- package/dist/umd/authentication/AuthPersistedContext.d.ts +9 -0
- package/dist/umd/authentication/TokenErrorResponseError.d.ts +10 -0
- package/dist/umd/authentication/TokenExpiredError.d.ts +3 -0
- package/dist/umd/authentication/UNAUTHORIZED_USER.d.ts +2 -0
- package/dist/umd/authentication/authenticate.d.ts +20 -0
- package/dist/umd/authentication/currentUserObservable.d.ts +1 -0
- package/dist/umd/authentication/interactWithUser.d.ts +21 -0
- package/dist/umd/authentication/login.d.ts +6 -0
- package/dist/umd/authentication/logout.d.ts +5 -0
- package/dist/umd/authentication/otpFetchTokenCallback.d.ts +3 -0
- package/dist/umd/authentication/setCurrentUser.d.ts +14 -0
- package/dist/umd/authentication/waitUntil.d.ts +3 -0
- package/dist/umd/computeSyncState.d.ts +4 -0
- package/dist/umd/createSharedValueObservable.d.ts +3 -0
- package/dist/umd/currentUserEmitter.d.ts +3 -0
- package/dist/umd/db/DexieCloudDB.d.ts +59 -0
- package/dist/umd/db/entities/BaseRevisionMapEntry.d.ts +5 -0
- package/dist/umd/db/entities/EntityCommon.d.ts +5 -0
- package/dist/umd/db/entities/GuardedJob.d.ts +5 -0
- package/dist/umd/db/entities/Member.d.ts +19 -0
- package/dist/umd/db/entities/PersistedSyncState.d.ts +14 -0
- package/dist/umd/db/entities/Realm.d.ts +16 -0
- package/dist/umd/db/entities/Role.d.ts +11 -0
- package/dist/umd/db/entities/UserLogin.d.ts +22 -0
- package/dist/umd/default-ui/Dialog.d.ts +5 -0
- package/dist/umd/default-ui/LoginDialog.d.ts +3 -0
- package/dist/umd/default-ui/Styles.d.ts +3 -0
- package/dist/umd/default-ui/index.d.ts +24 -0
- package/dist/umd/dexie-cloud-addon.d.ts +3 -0
- package/dist/umd/dexie-cloud-addon.js +41 -81
- package/dist/umd/dexie-cloud-addon.js.map +1 -1
- package/dist/umd/dexie-cloud-client.d.ts +22 -0
- package/dist/umd/errors/HttpError.d.ts +5 -0
- package/dist/umd/extend-dexie-interface.d.ts +23 -0
- package/dist/umd/getGlobalRolesObservable.d.ts +5 -0
- package/dist/umd/getInternalAccessControlObservable.d.ts +12 -0
- package/dist/umd/getInvitesObservable.d.ts +23 -0
- package/dist/umd/getPermissionsLookupObservable.d.ts +16 -0
- package/dist/umd/getTiedRealmId.d.ts +2 -0
- package/dist/umd/helpers/BroadcastedAndLocalEvent.d.ts +8 -0
- package/dist/umd/helpers/CancelToken.d.ts +4 -0
- package/dist/umd/helpers/IS_SERVICE_WORKER.d.ts +1 -0
- package/dist/umd/helpers/SWBroadcastChannel.d.ts +12 -0
- package/dist/umd/helpers/allSettled.d.ts +1 -0
- package/dist/umd/helpers/bulkUpdate.d.ts +4 -0
- package/dist/umd/helpers/computeRealmSetHash.d.ts +2 -0
- package/dist/umd/helpers/date-constants.d.ts +5 -0
- package/dist/umd/helpers/dbOnClosed.d.ts +2 -0
- package/dist/umd/helpers/flatten.d.ts +1 -0
- package/dist/umd/helpers/getMutationTable.d.ts +1 -0
- package/dist/umd/helpers/getSyncableTables.d.ts +4 -0
- package/dist/umd/helpers/getTableFromMutationTable.d.ts +1 -0
- package/dist/umd/helpers/makeArray.d.ts +1 -0
- package/dist/umd/helpers/randomString.d.ts +1 -0
- package/dist/umd/helpers/resolveText.d.ts +16 -0
- package/dist/umd/helpers/throwVersionIncrementNeeded.d.ts +1 -0
- package/dist/umd/helpers/visibilityState.d.ts +1 -0
- package/dist/umd/isEagerSyncDisabled.d.ts +2 -0
- package/dist/umd/isFirefox.d.ts +1 -0
- package/dist/umd/isSafari.d.ts +2 -0
- package/dist/umd/mapValueObservable.d.ts +5 -0
- package/dist/umd/mergePermissions.d.ts +2 -0
- package/dist/umd/middleware-helpers/guardedTable.d.ts +11 -0
- package/dist/umd/middleware-helpers/idGenerationHelpers.d.ts +18 -0
- package/dist/umd/middlewares/createIdGenerationMiddleware.d.ts +3 -0
- package/dist/umd/middlewares/createImplicitPropSetterMiddleware.d.ts +3 -0
- package/dist/umd/middlewares/createMutationTrackingMiddleware.d.ts +17 -0
- package/dist/umd/middlewares/outstandingTransaction.d.ts +4 -0
- package/dist/umd/overrideParseStoresSpec.d.ts +4 -0
- package/dist/umd/performInitialSync.d.ts +4 -0
- package/dist/umd/permissions.d.ts +9 -0
- package/dist/umd/prodLog.d.ts +9 -0
- package/dist/umd/service-worker.d.ts +1 -0
- package/dist/umd/service-worker.js +1624 -78
- package/dist/umd/service-worker.js.map +1 -1
- package/dist/umd/sync/LocalSyncWorker.d.ts +7 -0
- package/dist/umd/sync/SyncRequiredError.d.ts +3 -0
- package/dist/umd/sync/applyServerChanges.d.ts +3 -0
- package/dist/umd/sync/connectWebSocket.d.ts +2 -0
- package/dist/umd/sync/encodeIdsForServer.d.ts +4 -0
- package/dist/umd/sync/extractRealm.d.ts +2 -0
- package/dist/umd/sync/getLatestRevisionsPerTable.d.ts +6 -0
- package/dist/umd/sync/getTablesToSyncify.d.ts +3 -0
- package/dist/umd/sync/isOnline.d.ts +1 -0
- package/dist/umd/sync/isSyncNeeded.d.ts +2 -0
- package/dist/umd/sync/listClientChanges.d.ts +9 -0
- package/dist/umd/sync/listSyncifiedChanges.d.ts +5 -0
- package/dist/umd/sync/messageConsumerIsReady.d.ts +2 -0
- package/dist/umd/sync/messagesFromServerQueue.d.ts +8 -0
- package/dist/umd/sync/modifyLocalObjectsWithNewUserId.d.ts +4 -0
- package/dist/umd/sync/myId.d.ts +1 -0
- package/dist/umd/sync/numUnsyncedMutations.d.ts +2 -0
- package/dist/umd/sync/old_startSyncingClientChanges.d.ts +39 -0
- package/dist/umd/sync/performGuardedJob.d.ts +2 -0
- package/dist/umd/sync/ratelimit.d.ts +3 -0
- package/dist/umd/sync/registerSyncEvent.d.ts +3 -0
- package/dist/umd/sync/sync.d.ts +15 -0
- package/dist/umd/sync/syncIfPossible.d.ts +5 -0
- package/dist/umd/sync/syncWithServer.d.ts +6 -0
- package/dist/umd/sync/triggerSync.d.ts +2 -0
- package/dist/umd/sync/updateBaseRevs.d.ts +5 -0
- package/dist/umd/types/DXCAlert.d.ts +25 -0
- package/dist/umd/types/DXCInputField.d.ts +11 -0
- package/dist/umd/types/DXCUserInteraction.d.ts +93 -0
- package/dist/umd/types/NewIdOptions.d.ts +3 -0
- package/dist/umd/types/SWMessageEvent.d.ts +3 -0
- package/dist/umd/types/SWSyncEvent.d.ts +4 -0
- package/dist/umd/types/SyncState.d.ts +9 -0
- package/dist/umd/types/TXExpandos.d.ts +11 -0
- package/dist/umd/updateSchemaFromOptions.d.ts +3 -0
- package/dist/umd/userIsActive.d.ts +7 -0
- package/dist/umd/verifyConfig.d.ts +2 -0
- package/dist/umd/verifySchema.d.ts +2 -0
- package/package.json +12 -47
- package/copydts.sh +0 -5
- package/dist/types/dexie-cloud-client.d.ts +0 -13
- package/dist/umd/dexie-cloud-addon.min.js +0 -2
- package/dist/umd/dexie-cloud-addon.min.js.map +0 -1
- package/dist/umd/service-worker.min.js +0 -2
- package/dist/umd/service-worker.min.js.map +0 -1
- /package/dist/{types → modern}/DISABLE_SERVICEWORKER_STRATEGY.d.ts +0 -0
- /package/dist/{types → modern}/DXCWebSocketStatus.d.ts +0 -0
- /package/dist/{types → modern}/DexieCloudAPI.d.ts +0 -0
- /package/dist/{types → modern}/DexieCloudOptions.d.ts +0 -0
- /package/dist/{types → modern}/DexieCloudSyncOptions.d.ts +0 -0
- /package/dist/{types → modern}/DexieCloudTable.d.ts +0 -0
- /package/dist/{types → modern}/InvalidLicenseError.d.ts +0 -0
- /package/dist/{types → modern}/Invite.d.ts +0 -0
- /package/dist/{types → modern}/PermissionChecker.d.ts +0 -0
- /package/dist/{types → modern}/WSObservable.d.ts +0 -0
- /package/dist/{types → modern}/associate.d.ts +0 -0
- /package/dist/{types → modern}/authentication/AuthPersistedContext.d.ts +0 -0
- /package/dist/{types → modern}/authentication/TokenErrorResponseError.d.ts +0 -0
- /package/dist/{types → modern}/authentication/TokenExpiredError.d.ts +0 -0
- /package/dist/{types → modern}/authentication/UNAUTHORIZED_USER.d.ts +0 -0
- /package/dist/{types → modern}/authentication/authenticate.d.ts +0 -0
- /package/dist/{types → modern}/authentication/currentUserObservable.d.ts +0 -0
- /package/dist/{types → modern}/authentication/interactWithUser.d.ts +0 -0
- /package/dist/{types → modern}/authentication/login.d.ts +0 -0
- /package/dist/{types → modern}/authentication/logout.d.ts +0 -0
- /package/dist/{types → modern}/authentication/otpFetchTokenCallback.d.ts +0 -0
- /package/dist/{types → modern}/authentication/setCurrentUser.d.ts +0 -0
- /package/dist/{types → modern}/authentication/waitUntil.d.ts +0 -0
- /package/dist/{types → modern}/computeSyncState.d.ts +0 -0
- /package/dist/{types → modern}/createSharedValueObservable.d.ts +0 -0
- /package/dist/{types → modern}/currentUserEmitter.d.ts +0 -0
- /package/dist/{types → modern}/db/DexieCloudDB.d.ts +0 -0
- /package/dist/{types → modern}/db/entities/BaseRevisionMapEntry.d.ts +0 -0
- /package/dist/{types → modern}/db/entities/EntityCommon.d.ts +0 -0
- /package/dist/{types → modern}/db/entities/GuardedJob.d.ts +0 -0
- /package/dist/{types → modern}/db/entities/Member.d.ts +0 -0
- /package/dist/{types → modern}/db/entities/PersistedSyncState.d.ts +0 -0
- /package/dist/{types → modern}/db/entities/Realm.d.ts +0 -0
- /package/dist/{types → modern}/db/entities/Role.d.ts +0 -0
- /package/dist/{types → modern}/db/entities/UserLogin.d.ts +0 -0
- /package/dist/{types → modern}/default-ui/Dialog.d.ts +0 -0
- /package/dist/{types → modern}/default-ui/LoginDialog.d.ts +0 -0
- /package/dist/{types → modern}/default-ui/Styles.d.ts +0 -0
- /package/dist/{types → modern}/default-ui/index.d.ts +0 -0
- /package/dist/{types → modern}/errors/HttpError.d.ts +0 -0
- /package/dist/{types → modern}/extend-dexie-interface.d.ts +0 -0
- /package/dist/{types → modern}/getGlobalRolesObservable.d.ts +0 -0
- /package/dist/{types → modern}/getInternalAccessControlObservable.d.ts +0 -0
- /package/dist/{types → modern}/getInvitesObservable.d.ts +0 -0
- /package/dist/{types → modern}/getPermissionsLookupObservable.d.ts +0 -0
- /package/dist/{types → modern}/getTiedRealmId.d.ts +0 -0
- /package/dist/{types → modern}/helpers/BroadcastedAndLocalEvent.d.ts +0 -0
- /package/dist/{types → modern}/helpers/CancelToken.d.ts +0 -0
- /package/dist/{types → modern}/helpers/IS_SERVICE_WORKER.d.ts +0 -0
- /package/dist/{types → modern}/helpers/SWBroadcastChannel.d.ts +0 -0
- /package/dist/{types → modern}/helpers/allSettled.d.ts +0 -0
- /package/dist/{types → modern}/helpers/bulkUpdate.d.ts +0 -0
- /package/dist/{types → modern}/helpers/computeRealmSetHash.d.ts +0 -0
- /package/dist/{types → modern}/helpers/date-constants.d.ts +0 -0
- /package/dist/{types → modern}/helpers/dbOnClosed.d.ts +0 -0
- /package/dist/{types → modern}/helpers/flatten.d.ts +0 -0
- /package/dist/{types → modern}/helpers/getMutationTable.d.ts +0 -0
- /package/dist/{types → modern}/helpers/getSyncableTables.d.ts +0 -0
- /package/dist/{types → modern}/helpers/getTableFromMutationTable.d.ts +0 -0
- /package/dist/{types → modern}/helpers/makeArray.d.ts +0 -0
- /package/dist/{types → modern}/helpers/randomString.d.ts +0 -0
- /package/dist/{types → modern}/helpers/resolveText.d.ts +0 -0
- /package/dist/{types → modern}/helpers/throwVersionIncrementNeeded.d.ts +0 -0
- /package/dist/{types → modern}/helpers/visibilityState.d.ts +0 -0
- /package/dist/{types → modern}/isEagerSyncDisabled.d.ts +0 -0
- /package/dist/{types → modern}/isFirefox.d.ts +0 -0
- /package/dist/{types → modern}/isSafari.d.ts +0 -0
- /package/dist/{types → modern}/mapValueObservable.d.ts +0 -0
- /package/dist/{types → modern}/mergePermissions.d.ts +0 -0
- /package/dist/{types → modern}/middleware-helpers/guardedTable.d.ts +0 -0
- /package/dist/{types → modern}/middleware-helpers/idGenerationHelpers.d.ts +0 -0
- /package/dist/{types → modern}/middlewares/createIdGenerationMiddleware.d.ts +0 -0
- /package/dist/{types → modern}/middlewares/createImplicitPropSetterMiddleware.d.ts +0 -0
- /package/dist/{types → modern}/middlewares/createMutationTrackingMiddleware.d.ts +0 -0
- /package/dist/{types → modern}/middlewares/outstandingTransaction.d.ts +0 -0
- /package/dist/{types → modern}/overrideParseStoresSpec.d.ts +0 -0
- /package/dist/{types → modern}/performInitialSync.d.ts +0 -0
- /package/dist/{types → modern}/permissions.d.ts +0 -0
- /package/dist/{types → modern}/prodLog.d.ts +0 -0
- /package/dist/{types → modern}/service-worker.d.ts +0 -0
- /package/dist/{types → modern}/sync/LocalSyncWorker.d.ts +0 -0
- /package/dist/{types → modern}/sync/SyncRequiredError.d.ts +0 -0
- /package/dist/{types → modern}/sync/applyServerChanges.d.ts +0 -0
- /package/dist/{types → modern}/sync/connectWebSocket.d.ts +0 -0
- /package/dist/{types → modern}/sync/encodeIdsForServer.d.ts +0 -0
- /package/dist/{types → modern}/sync/extractRealm.d.ts +0 -0
- /package/dist/{types → modern}/sync/getLatestRevisionsPerTable.d.ts +0 -0
- /package/dist/{types → modern}/sync/getTablesToSyncify.d.ts +0 -0
- /package/dist/{types → modern}/sync/isOnline.d.ts +0 -0
- /package/dist/{types → modern}/sync/isSyncNeeded.d.ts +0 -0
- /package/dist/{types → modern}/sync/listClientChanges.d.ts +0 -0
- /package/dist/{types → modern}/sync/listSyncifiedChanges.d.ts +0 -0
- /package/dist/{types → modern}/sync/messageConsumerIsReady.d.ts +0 -0
- /package/dist/{types → modern}/sync/messagesFromServerQueue.d.ts +0 -0
- /package/dist/{types → modern}/sync/modifyLocalObjectsWithNewUserId.d.ts +0 -0
- /package/dist/{types → modern}/sync/myId.d.ts +0 -0
- /package/dist/{types → modern}/sync/numUnsyncedMutations.d.ts +0 -0
- /package/dist/{types → modern}/sync/old_startSyncingClientChanges.d.ts +0 -0
- /package/dist/{types → modern}/sync/performGuardedJob.d.ts +0 -0
- /package/dist/{types → modern}/sync/ratelimit.d.ts +0 -0
- /package/dist/{types → modern}/sync/registerSyncEvent.d.ts +0 -0
- /package/dist/{types → modern}/sync/sync.d.ts +0 -0
- /package/dist/{types → modern}/sync/syncIfPossible.d.ts +0 -0
- /package/dist/{types → modern}/sync/syncWithServer.d.ts +0 -0
- /package/dist/{types → modern}/sync/triggerSync.d.ts +0 -0
- /package/dist/{types → modern}/sync/updateBaseRevs.d.ts +0 -0
- /package/dist/{types → modern}/types/DXCAlert.d.ts +0 -0
- /package/dist/{types → modern}/types/DXCInputField.d.ts +0 -0
- /package/dist/{types → modern}/types/DXCUserInteraction.d.ts +0 -0
- /package/dist/{types → modern}/types/NewIdOptions.d.ts +0 -0
- /package/dist/{types → modern}/types/SWMessageEvent.d.ts +0 -0
- /package/dist/{types → modern}/types/SWSyncEvent.d.ts +0 -0
- /package/dist/{types → modern}/types/SyncState.d.ts +0 -0
- /package/dist/{types → modern}/types/TXExpandos.d.ts +0 -0
- /package/dist/{types → modern}/updateSchemaFromOptions.d.ts +0 -0
- /package/dist/{types → modern}/userIsActive.d.ts +0 -0
- /package/dist/{types → modern}/verifyConfig.d.ts +0 -0
- /package/dist/{types → modern}/verifySchema.d.ts +0 -0
|
@@ -1,12 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
/* ==========================================================================
|
|
2
|
+
* dexie-cloud-addom.js
|
|
3
|
+
* ==========================================================================
|
|
4
|
+
*
|
|
5
|
+
* Dexie addon that syncs IndexedDB with Dexie Cloud.
|
|
6
|
+
*
|
|
7
|
+
* By David Fahlander, david@dexie.org
|
|
8
|
+
*
|
|
9
|
+
* ==========================================================================
|
|
10
|
+
*
|
|
11
|
+
* Version 4.0.1-beta.49, Sat Oct 28 2023
|
|
12
|
+
*
|
|
13
|
+
* https://dexie.org
|
|
14
|
+
*
|
|
15
|
+
* Apache License Version 2.0, January 2004, http://www.apache.org/licenses/
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
8
18
|
|
|
9
|
-
|
|
19
|
+
(function (global, factory) {
|
|
20
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('dexie'), require('rxjs')) :
|
|
21
|
+
typeof define === 'function' && define.amd ? define(['dexie', 'rxjs'], factory) :
|
|
22
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Dexie, global.rxjs));
|
|
23
|
+
})(this, (function (Dexie, rxjs) { 'use strict';
|
|
10
24
|
|
|
11
25
|
/******************************************************************************
|
|
12
26
|
Copyright (c) Microsoft Corporation.
|
|
@@ -22,6 +36,22 @@
|
|
|
22
36
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
23
37
|
PERFORMANCE OF THIS SOFTWARE.
|
|
24
38
|
***************************************************************************** */
|
|
39
|
+
/* global Reflect, Promise */
|
|
40
|
+
|
|
41
|
+
var extendStatics = function(d, b) {
|
|
42
|
+
extendStatics = Object.setPrototypeOf ||
|
|
43
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
44
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
45
|
+
return extendStatics(d, b);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
function __extends(d, b) {
|
|
49
|
+
if (typeof b !== "function" && b !== null)
|
|
50
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
51
|
+
extendStatics(d, b);
|
|
52
|
+
function __() { this.constructor = d; }
|
|
53
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
54
|
+
}
|
|
25
55
|
|
|
26
56
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
27
57
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
@@ -31,6 +61,97 @@
|
|
|
31
61
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
32
62
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
33
63
|
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function __generator(thisArg, body) {
|
|
67
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
68
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
69
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
70
|
+
function step(op) {
|
|
71
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
72
|
+
while (_) try {
|
|
73
|
+
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;
|
|
74
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
75
|
+
switch (op[0]) {
|
|
76
|
+
case 0: case 1: t = op; break;
|
|
77
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
78
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
79
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
80
|
+
default:
|
|
81
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
82
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
83
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
84
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
85
|
+
if (t[2]) _.ops.pop();
|
|
86
|
+
_.trys.pop(); continue;
|
|
87
|
+
}
|
|
88
|
+
op = body.call(thisArg, _);
|
|
89
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
90
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function __values(o) {
|
|
95
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
96
|
+
if (m) return m.call(o);
|
|
97
|
+
if (o && typeof o.length === "number") return {
|
|
98
|
+
next: function () {
|
|
99
|
+
if (o && i >= o.length) o = void 0;
|
|
100
|
+
return { value: o && o[i++], done: !o };
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function __read(o, n) {
|
|
107
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
108
|
+
if (!m) return o;
|
|
109
|
+
var i = m.call(o), r, ar = [], e;
|
|
110
|
+
try {
|
|
111
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
112
|
+
}
|
|
113
|
+
catch (error) { e = { error: error }; }
|
|
114
|
+
finally {
|
|
115
|
+
try {
|
|
116
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
117
|
+
}
|
|
118
|
+
finally { if (e) throw e.error; }
|
|
119
|
+
}
|
|
120
|
+
return ar;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function __spreadArray(to, from, pack) {
|
|
124
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
125
|
+
if (ar || !(i in from)) {
|
|
126
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
127
|
+
ar[i] = from[i];
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function __await(v) {
|
|
134
|
+
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
138
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
139
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
140
|
+
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
141
|
+
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); }); }; }
|
|
142
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
143
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
144
|
+
function fulfill(value) { resume("next", value); }
|
|
145
|
+
function reject(value) { resume("throw", value); }
|
|
146
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function __asyncValues(o) {
|
|
150
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
151
|
+
var m = o[Symbol.asyncIterator], i;
|
|
152
|
+
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);
|
|
153
|
+
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); }); }; }
|
|
154
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
34
155
|
}
|
|
35
156
|
|
|
36
157
|
const UNAUTHORIZED_USER = {
|
|
@@ -184,6 +305,1424 @@
|
|
|
184
305
|
}
|
|
185
306
|
}
|
|
186
307
|
|
|
308
|
+
function isFunction(value) {
|
|
309
|
+
return typeof value === 'function';
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
function hasLift(source) {
|
|
313
|
+
return isFunction(source === null || source === void 0 ? void 0 : source.lift);
|
|
314
|
+
}
|
|
315
|
+
function operate(init) {
|
|
316
|
+
return function (source) {
|
|
317
|
+
if (hasLift(source)) {
|
|
318
|
+
return source.lift(function (liftedSource) {
|
|
319
|
+
try {
|
|
320
|
+
return init(liftedSource, this);
|
|
321
|
+
}
|
|
322
|
+
catch (err) {
|
|
323
|
+
this.error(err);
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
throw new TypeError('Unable to lift unknown Observable type');
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
var isArrayLike = (function (x) { return x && typeof x.length === 'number' && typeof x !== 'function'; });
|
|
332
|
+
|
|
333
|
+
function isPromise(value) {
|
|
334
|
+
return isFunction(value === null || value === void 0 ? void 0 : value.then);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
function createErrorClass(createImpl) {
|
|
338
|
+
var _super = function (instance) {
|
|
339
|
+
Error.call(instance);
|
|
340
|
+
instance.stack = new Error().stack;
|
|
341
|
+
};
|
|
342
|
+
var ctorFunc = createImpl(_super);
|
|
343
|
+
ctorFunc.prototype = Object.create(Error.prototype);
|
|
344
|
+
ctorFunc.prototype.constructor = ctorFunc;
|
|
345
|
+
return ctorFunc;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
var UnsubscriptionError = createErrorClass(function (_super) {
|
|
349
|
+
return function UnsubscriptionErrorImpl(errors) {
|
|
350
|
+
_super(this);
|
|
351
|
+
this.message = errors
|
|
352
|
+
? errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n ')
|
|
353
|
+
: '';
|
|
354
|
+
this.name = 'UnsubscriptionError';
|
|
355
|
+
this.errors = errors;
|
|
356
|
+
};
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
function arrRemove(arr, item) {
|
|
360
|
+
if (arr) {
|
|
361
|
+
var index = arr.indexOf(item);
|
|
362
|
+
0 <= index && arr.splice(index, 1);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
var Subscription = (function () {
|
|
367
|
+
function Subscription(initialTeardown) {
|
|
368
|
+
this.initialTeardown = initialTeardown;
|
|
369
|
+
this.closed = false;
|
|
370
|
+
this._parentage = null;
|
|
371
|
+
this._finalizers = null;
|
|
372
|
+
}
|
|
373
|
+
Subscription.prototype.unsubscribe = function () {
|
|
374
|
+
var e_1, _a, e_2, _b;
|
|
375
|
+
var errors;
|
|
376
|
+
if (!this.closed) {
|
|
377
|
+
this.closed = true;
|
|
378
|
+
var _parentage = this._parentage;
|
|
379
|
+
if (_parentage) {
|
|
380
|
+
this._parentage = null;
|
|
381
|
+
if (Array.isArray(_parentage)) {
|
|
382
|
+
try {
|
|
383
|
+
for (var _parentage_1 = __values(_parentage), _parentage_1_1 = _parentage_1.next(); !_parentage_1_1.done; _parentage_1_1 = _parentage_1.next()) {
|
|
384
|
+
var parent_1 = _parentage_1_1.value;
|
|
385
|
+
parent_1.remove(this);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
389
|
+
finally {
|
|
390
|
+
try {
|
|
391
|
+
if (_parentage_1_1 && !_parentage_1_1.done && (_a = _parentage_1.return)) _a.call(_parentage_1);
|
|
392
|
+
}
|
|
393
|
+
finally { if (e_1) throw e_1.error; }
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
397
|
+
_parentage.remove(this);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
var initialFinalizer = this.initialTeardown;
|
|
401
|
+
if (isFunction(initialFinalizer)) {
|
|
402
|
+
try {
|
|
403
|
+
initialFinalizer();
|
|
404
|
+
}
|
|
405
|
+
catch (e) {
|
|
406
|
+
errors = e instanceof UnsubscriptionError ? e.errors : [e];
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
var _finalizers = this._finalizers;
|
|
410
|
+
if (_finalizers) {
|
|
411
|
+
this._finalizers = null;
|
|
412
|
+
try {
|
|
413
|
+
for (var _finalizers_1 = __values(_finalizers), _finalizers_1_1 = _finalizers_1.next(); !_finalizers_1_1.done; _finalizers_1_1 = _finalizers_1.next()) {
|
|
414
|
+
var finalizer = _finalizers_1_1.value;
|
|
415
|
+
try {
|
|
416
|
+
execFinalizer(finalizer);
|
|
417
|
+
}
|
|
418
|
+
catch (err) {
|
|
419
|
+
errors = errors !== null && errors !== void 0 ? errors : [];
|
|
420
|
+
if (err instanceof UnsubscriptionError) {
|
|
421
|
+
errors = __spreadArray(__spreadArray([], __read(errors)), __read(err.errors));
|
|
422
|
+
}
|
|
423
|
+
else {
|
|
424
|
+
errors.push(err);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
430
|
+
finally {
|
|
431
|
+
try {
|
|
432
|
+
if (_finalizers_1_1 && !_finalizers_1_1.done && (_b = _finalizers_1.return)) _b.call(_finalizers_1);
|
|
433
|
+
}
|
|
434
|
+
finally { if (e_2) throw e_2.error; }
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
if (errors) {
|
|
438
|
+
throw new UnsubscriptionError(errors);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
Subscription.prototype.add = function (teardown) {
|
|
443
|
+
var _a;
|
|
444
|
+
if (teardown && teardown !== this) {
|
|
445
|
+
if (this.closed) {
|
|
446
|
+
execFinalizer(teardown);
|
|
447
|
+
}
|
|
448
|
+
else {
|
|
449
|
+
if (teardown instanceof Subscription) {
|
|
450
|
+
if (teardown.closed || teardown._hasParent(this)) {
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
teardown._addParent(this);
|
|
454
|
+
}
|
|
455
|
+
(this._finalizers = (_a = this._finalizers) !== null && _a !== void 0 ? _a : []).push(teardown);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
};
|
|
459
|
+
Subscription.prototype._hasParent = function (parent) {
|
|
460
|
+
var _parentage = this._parentage;
|
|
461
|
+
return _parentage === parent || (Array.isArray(_parentage) && _parentage.includes(parent));
|
|
462
|
+
};
|
|
463
|
+
Subscription.prototype._addParent = function (parent) {
|
|
464
|
+
var _parentage = this._parentage;
|
|
465
|
+
this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent;
|
|
466
|
+
};
|
|
467
|
+
Subscription.prototype._removeParent = function (parent) {
|
|
468
|
+
var _parentage = this._parentage;
|
|
469
|
+
if (_parentage === parent) {
|
|
470
|
+
this._parentage = null;
|
|
471
|
+
}
|
|
472
|
+
else if (Array.isArray(_parentage)) {
|
|
473
|
+
arrRemove(_parentage, parent);
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
Subscription.prototype.remove = function (teardown) {
|
|
477
|
+
var _finalizers = this._finalizers;
|
|
478
|
+
_finalizers && arrRemove(_finalizers, teardown);
|
|
479
|
+
if (teardown instanceof Subscription) {
|
|
480
|
+
teardown._removeParent(this);
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
Subscription.EMPTY = (function () {
|
|
484
|
+
var empty = new Subscription();
|
|
485
|
+
empty.closed = true;
|
|
486
|
+
return empty;
|
|
487
|
+
})();
|
|
488
|
+
return Subscription;
|
|
489
|
+
}());
|
|
490
|
+
Subscription.EMPTY;
|
|
491
|
+
function isSubscription(value) {
|
|
492
|
+
return (value instanceof Subscription ||
|
|
493
|
+
(value && 'closed' in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe)));
|
|
494
|
+
}
|
|
495
|
+
function execFinalizer(finalizer) {
|
|
496
|
+
if (isFunction(finalizer)) {
|
|
497
|
+
finalizer();
|
|
498
|
+
}
|
|
499
|
+
else {
|
|
500
|
+
finalizer.unsubscribe();
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
var config = {
|
|
505
|
+
onUnhandledError: null,
|
|
506
|
+
onStoppedNotification: null,
|
|
507
|
+
Promise: undefined,
|
|
508
|
+
useDeprecatedSynchronousErrorHandling: false,
|
|
509
|
+
useDeprecatedNextContext: false,
|
|
510
|
+
};
|
|
511
|
+
|
|
512
|
+
var timeoutProvider = {
|
|
513
|
+
setTimeout: function (handler, timeout) {
|
|
514
|
+
var args = [];
|
|
515
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
516
|
+
args[_i - 2] = arguments[_i];
|
|
517
|
+
}
|
|
518
|
+
var delegate = timeoutProvider.delegate;
|
|
519
|
+
if (delegate === null || delegate === void 0 ? void 0 : delegate.setTimeout) {
|
|
520
|
+
return delegate.setTimeout.apply(delegate, __spreadArray([handler, timeout], __read(args)));
|
|
521
|
+
}
|
|
522
|
+
return setTimeout.apply(void 0, __spreadArray([handler, timeout], __read(args)));
|
|
523
|
+
},
|
|
524
|
+
clearTimeout: function (handle) {
|
|
525
|
+
var delegate = timeoutProvider.delegate;
|
|
526
|
+
return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearTimeout) || clearTimeout)(handle);
|
|
527
|
+
},
|
|
528
|
+
delegate: undefined,
|
|
529
|
+
};
|
|
530
|
+
|
|
531
|
+
function reportUnhandledError(err) {
|
|
532
|
+
timeoutProvider.setTimeout(function () {
|
|
533
|
+
{
|
|
534
|
+
throw err;
|
|
535
|
+
}
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
function noop() { }
|
|
540
|
+
|
|
541
|
+
function errorContext(cb) {
|
|
542
|
+
{
|
|
543
|
+
cb();
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
var Subscriber = (function (_super) {
|
|
548
|
+
__extends(Subscriber, _super);
|
|
549
|
+
function Subscriber(destination) {
|
|
550
|
+
var _this = _super.call(this) || this;
|
|
551
|
+
_this.isStopped = false;
|
|
552
|
+
if (destination) {
|
|
553
|
+
_this.destination = destination;
|
|
554
|
+
if (isSubscription(destination)) {
|
|
555
|
+
destination.add(_this);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
else {
|
|
559
|
+
_this.destination = EMPTY_OBSERVER;
|
|
560
|
+
}
|
|
561
|
+
return _this;
|
|
562
|
+
}
|
|
563
|
+
Subscriber.create = function (next, error, complete) {
|
|
564
|
+
return new SafeSubscriber(next, error, complete);
|
|
565
|
+
};
|
|
566
|
+
Subscriber.prototype.next = function (value) {
|
|
567
|
+
if (this.isStopped) ;
|
|
568
|
+
else {
|
|
569
|
+
this._next(value);
|
|
570
|
+
}
|
|
571
|
+
};
|
|
572
|
+
Subscriber.prototype.error = function (err) {
|
|
573
|
+
if (this.isStopped) ;
|
|
574
|
+
else {
|
|
575
|
+
this.isStopped = true;
|
|
576
|
+
this._error(err);
|
|
577
|
+
}
|
|
578
|
+
};
|
|
579
|
+
Subscriber.prototype.complete = function () {
|
|
580
|
+
if (this.isStopped) ;
|
|
581
|
+
else {
|
|
582
|
+
this.isStopped = true;
|
|
583
|
+
this._complete();
|
|
584
|
+
}
|
|
585
|
+
};
|
|
586
|
+
Subscriber.prototype.unsubscribe = function () {
|
|
587
|
+
if (!this.closed) {
|
|
588
|
+
this.isStopped = true;
|
|
589
|
+
_super.prototype.unsubscribe.call(this);
|
|
590
|
+
this.destination = null;
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
Subscriber.prototype._next = function (value) {
|
|
594
|
+
this.destination.next(value);
|
|
595
|
+
};
|
|
596
|
+
Subscriber.prototype._error = function (err) {
|
|
597
|
+
try {
|
|
598
|
+
this.destination.error(err);
|
|
599
|
+
}
|
|
600
|
+
finally {
|
|
601
|
+
this.unsubscribe();
|
|
602
|
+
}
|
|
603
|
+
};
|
|
604
|
+
Subscriber.prototype._complete = function () {
|
|
605
|
+
try {
|
|
606
|
+
this.destination.complete();
|
|
607
|
+
}
|
|
608
|
+
finally {
|
|
609
|
+
this.unsubscribe();
|
|
610
|
+
}
|
|
611
|
+
};
|
|
612
|
+
return Subscriber;
|
|
613
|
+
}(Subscription));
|
|
614
|
+
var _bind = Function.prototype.bind;
|
|
615
|
+
function bind(fn, thisArg) {
|
|
616
|
+
return _bind.call(fn, thisArg);
|
|
617
|
+
}
|
|
618
|
+
var ConsumerObserver = (function () {
|
|
619
|
+
function ConsumerObserver(partialObserver) {
|
|
620
|
+
this.partialObserver = partialObserver;
|
|
621
|
+
}
|
|
622
|
+
ConsumerObserver.prototype.next = function (value) {
|
|
623
|
+
var partialObserver = this.partialObserver;
|
|
624
|
+
if (partialObserver.next) {
|
|
625
|
+
try {
|
|
626
|
+
partialObserver.next(value);
|
|
627
|
+
}
|
|
628
|
+
catch (error) {
|
|
629
|
+
handleUnhandledError(error);
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
};
|
|
633
|
+
ConsumerObserver.prototype.error = function (err) {
|
|
634
|
+
var partialObserver = this.partialObserver;
|
|
635
|
+
if (partialObserver.error) {
|
|
636
|
+
try {
|
|
637
|
+
partialObserver.error(err);
|
|
638
|
+
}
|
|
639
|
+
catch (error) {
|
|
640
|
+
handleUnhandledError(error);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
else {
|
|
644
|
+
handleUnhandledError(err);
|
|
645
|
+
}
|
|
646
|
+
};
|
|
647
|
+
ConsumerObserver.prototype.complete = function () {
|
|
648
|
+
var partialObserver = this.partialObserver;
|
|
649
|
+
if (partialObserver.complete) {
|
|
650
|
+
try {
|
|
651
|
+
partialObserver.complete();
|
|
652
|
+
}
|
|
653
|
+
catch (error) {
|
|
654
|
+
handleUnhandledError(error);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
};
|
|
658
|
+
return ConsumerObserver;
|
|
659
|
+
}());
|
|
660
|
+
var SafeSubscriber = (function (_super) {
|
|
661
|
+
__extends(SafeSubscriber, _super);
|
|
662
|
+
function SafeSubscriber(observerOrNext, error, complete) {
|
|
663
|
+
var _this = _super.call(this) || this;
|
|
664
|
+
var partialObserver;
|
|
665
|
+
if (isFunction(observerOrNext) || !observerOrNext) {
|
|
666
|
+
partialObserver = {
|
|
667
|
+
next: (observerOrNext !== null && observerOrNext !== void 0 ? observerOrNext : undefined),
|
|
668
|
+
error: error !== null && error !== void 0 ? error : undefined,
|
|
669
|
+
complete: complete !== null && complete !== void 0 ? complete : undefined,
|
|
670
|
+
};
|
|
671
|
+
}
|
|
672
|
+
else {
|
|
673
|
+
var context_1;
|
|
674
|
+
if (_this && config.useDeprecatedNextContext) {
|
|
675
|
+
context_1 = Object.create(observerOrNext);
|
|
676
|
+
context_1.unsubscribe = function () { return _this.unsubscribe(); };
|
|
677
|
+
partialObserver = {
|
|
678
|
+
next: observerOrNext.next && bind(observerOrNext.next, context_1),
|
|
679
|
+
error: observerOrNext.error && bind(observerOrNext.error, context_1),
|
|
680
|
+
complete: observerOrNext.complete && bind(observerOrNext.complete, context_1),
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
else {
|
|
684
|
+
partialObserver = observerOrNext;
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
_this.destination = new ConsumerObserver(partialObserver);
|
|
688
|
+
return _this;
|
|
689
|
+
}
|
|
690
|
+
return SafeSubscriber;
|
|
691
|
+
}(Subscriber));
|
|
692
|
+
function handleUnhandledError(error) {
|
|
693
|
+
{
|
|
694
|
+
reportUnhandledError(error);
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
function defaultErrorHandler(err) {
|
|
698
|
+
throw err;
|
|
699
|
+
}
|
|
700
|
+
var EMPTY_OBSERVER = {
|
|
701
|
+
closed: true,
|
|
702
|
+
next: noop,
|
|
703
|
+
error: defaultErrorHandler,
|
|
704
|
+
complete: noop,
|
|
705
|
+
};
|
|
706
|
+
|
|
707
|
+
var observable = (function () { return (typeof Symbol === 'function' && Symbol.observable) || '@@observable'; })();
|
|
708
|
+
|
|
709
|
+
function identity(x) {
|
|
710
|
+
return x;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
function pipeFromArray(fns) {
|
|
714
|
+
if (fns.length === 0) {
|
|
715
|
+
return identity;
|
|
716
|
+
}
|
|
717
|
+
if (fns.length === 1) {
|
|
718
|
+
return fns[0];
|
|
719
|
+
}
|
|
720
|
+
return function piped(input) {
|
|
721
|
+
return fns.reduce(function (prev, fn) { return fn(prev); }, input);
|
|
722
|
+
};
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
var Observable = (function () {
|
|
726
|
+
function Observable(subscribe) {
|
|
727
|
+
if (subscribe) {
|
|
728
|
+
this._subscribe = subscribe;
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
Observable.prototype.lift = function (operator) {
|
|
732
|
+
var observable = new Observable();
|
|
733
|
+
observable.source = this;
|
|
734
|
+
observable.operator = operator;
|
|
735
|
+
return observable;
|
|
736
|
+
};
|
|
737
|
+
Observable.prototype.subscribe = function (observerOrNext, error, complete) {
|
|
738
|
+
var _this = this;
|
|
739
|
+
var subscriber = isSubscriber(observerOrNext) ? observerOrNext : new SafeSubscriber(observerOrNext, error, complete);
|
|
740
|
+
errorContext(function () {
|
|
741
|
+
var _a = _this, operator = _a.operator, source = _a.source;
|
|
742
|
+
subscriber.add(operator
|
|
743
|
+
?
|
|
744
|
+
operator.call(subscriber, source)
|
|
745
|
+
: source
|
|
746
|
+
?
|
|
747
|
+
_this._subscribe(subscriber)
|
|
748
|
+
:
|
|
749
|
+
_this._trySubscribe(subscriber));
|
|
750
|
+
});
|
|
751
|
+
return subscriber;
|
|
752
|
+
};
|
|
753
|
+
Observable.prototype._trySubscribe = function (sink) {
|
|
754
|
+
try {
|
|
755
|
+
return this._subscribe(sink);
|
|
756
|
+
}
|
|
757
|
+
catch (err) {
|
|
758
|
+
sink.error(err);
|
|
759
|
+
}
|
|
760
|
+
};
|
|
761
|
+
Observable.prototype.forEach = function (next, promiseCtor) {
|
|
762
|
+
var _this = this;
|
|
763
|
+
promiseCtor = getPromiseCtor(promiseCtor);
|
|
764
|
+
return new promiseCtor(function (resolve, reject) {
|
|
765
|
+
var subscriber = new SafeSubscriber({
|
|
766
|
+
next: function (value) {
|
|
767
|
+
try {
|
|
768
|
+
next(value);
|
|
769
|
+
}
|
|
770
|
+
catch (err) {
|
|
771
|
+
reject(err);
|
|
772
|
+
subscriber.unsubscribe();
|
|
773
|
+
}
|
|
774
|
+
},
|
|
775
|
+
error: reject,
|
|
776
|
+
complete: resolve,
|
|
777
|
+
});
|
|
778
|
+
_this.subscribe(subscriber);
|
|
779
|
+
});
|
|
780
|
+
};
|
|
781
|
+
Observable.prototype._subscribe = function (subscriber) {
|
|
782
|
+
var _a;
|
|
783
|
+
return (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber);
|
|
784
|
+
};
|
|
785
|
+
Observable.prototype[observable] = function () {
|
|
786
|
+
return this;
|
|
787
|
+
};
|
|
788
|
+
Observable.prototype.pipe = function () {
|
|
789
|
+
var operations = [];
|
|
790
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
791
|
+
operations[_i] = arguments[_i];
|
|
792
|
+
}
|
|
793
|
+
return pipeFromArray(operations)(this);
|
|
794
|
+
};
|
|
795
|
+
Observable.prototype.toPromise = function (promiseCtor) {
|
|
796
|
+
var _this = this;
|
|
797
|
+
promiseCtor = getPromiseCtor(promiseCtor);
|
|
798
|
+
return new promiseCtor(function (resolve, reject) {
|
|
799
|
+
var value;
|
|
800
|
+
_this.subscribe(function (x) { return (value = x); }, function (err) { return reject(err); }, function () { return resolve(value); });
|
|
801
|
+
});
|
|
802
|
+
};
|
|
803
|
+
Observable.create = function (subscribe) {
|
|
804
|
+
return new Observable(subscribe);
|
|
805
|
+
};
|
|
806
|
+
return Observable;
|
|
807
|
+
}());
|
|
808
|
+
function getPromiseCtor(promiseCtor) {
|
|
809
|
+
var _a;
|
|
810
|
+
return (_a = promiseCtor !== null && promiseCtor !== void 0 ? promiseCtor : config.Promise) !== null && _a !== void 0 ? _a : Promise;
|
|
811
|
+
}
|
|
812
|
+
function isObserver(value) {
|
|
813
|
+
return value && isFunction(value.next) && isFunction(value.error) && isFunction(value.complete);
|
|
814
|
+
}
|
|
815
|
+
function isSubscriber(value) {
|
|
816
|
+
return (value && value instanceof Subscriber) || (isObserver(value) && isSubscription(value));
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
function isInteropObservable(input) {
|
|
820
|
+
return isFunction(input[observable]);
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
function isAsyncIterable(obj) {
|
|
824
|
+
return Symbol.asyncIterator && isFunction(obj === null || obj === void 0 ? void 0 : obj[Symbol.asyncIterator]);
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
function createInvalidObservableTypeError(input) {
|
|
828
|
+
return new TypeError("You provided " + (input !== null && typeof input === 'object' ? 'an invalid object' : "'" + input + "'") + " where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.");
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
function getSymbolIterator() {
|
|
832
|
+
if (typeof Symbol !== 'function' || !Symbol.iterator) {
|
|
833
|
+
return '@@iterator';
|
|
834
|
+
}
|
|
835
|
+
return Symbol.iterator;
|
|
836
|
+
}
|
|
837
|
+
var iterator = getSymbolIterator();
|
|
838
|
+
|
|
839
|
+
function isIterable(input) {
|
|
840
|
+
return isFunction(input === null || input === void 0 ? void 0 : input[iterator]);
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
function readableStreamLikeToAsyncGenerator(readableStream) {
|
|
844
|
+
return __asyncGenerator(this, arguments, function readableStreamLikeToAsyncGenerator_1() {
|
|
845
|
+
var reader, _a, value, done;
|
|
846
|
+
return __generator(this, function (_b) {
|
|
847
|
+
switch (_b.label) {
|
|
848
|
+
case 0:
|
|
849
|
+
reader = readableStream.getReader();
|
|
850
|
+
_b.label = 1;
|
|
851
|
+
case 1:
|
|
852
|
+
_b.trys.push([1, , 9, 10]);
|
|
853
|
+
_b.label = 2;
|
|
854
|
+
case 2:
|
|
855
|
+
return [4, __await(reader.read())];
|
|
856
|
+
case 3:
|
|
857
|
+
_a = _b.sent(), value = _a.value, done = _a.done;
|
|
858
|
+
if (!done) return [3, 5];
|
|
859
|
+
return [4, __await(void 0)];
|
|
860
|
+
case 4: return [2, _b.sent()];
|
|
861
|
+
case 5: return [4, __await(value)];
|
|
862
|
+
case 6: return [4, _b.sent()];
|
|
863
|
+
case 7:
|
|
864
|
+
_b.sent();
|
|
865
|
+
return [3, 2];
|
|
866
|
+
case 8: return [3, 10];
|
|
867
|
+
case 9:
|
|
868
|
+
reader.releaseLock();
|
|
869
|
+
return [7];
|
|
870
|
+
case 10: return [2];
|
|
871
|
+
}
|
|
872
|
+
});
|
|
873
|
+
});
|
|
874
|
+
}
|
|
875
|
+
function isReadableStreamLike(obj) {
|
|
876
|
+
return isFunction(obj === null || obj === void 0 ? void 0 : obj.getReader);
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
function innerFrom(input) {
|
|
880
|
+
if (input instanceof Observable) {
|
|
881
|
+
return input;
|
|
882
|
+
}
|
|
883
|
+
if (input != null) {
|
|
884
|
+
if (isInteropObservable(input)) {
|
|
885
|
+
return fromInteropObservable(input);
|
|
886
|
+
}
|
|
887
|
+
if (isArrayLike(input)) {
|
|
888
|
+
return fromArrayLike(input);
|
|
889
|
+
}
|
|
890
|
+
if (isPromise(input)) {
|
|
891
|
+
return fromPromise(input);
|
|
892
|
+
}
|
|
893
|
+
if (isAsyncIterable(input)) {
|
|
894
|
+
return fromAsyncIterable(input);
|
|
895
|
+
}
|
|
896
|
+
if (isIterable(input)) {
|
|
897
|
+
return fromIterable(input);
|
|
898
|
+
}
|
|
899
|
+
if (isReadableStreamLike(input)) {
|
|
900
|
+
return fromReadableStreamLike(input);
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
throw createInvalidObservableTypeError(input);
|
|
904
|
+
}
|
|
905
|
+
function fromInteropObservable(obj) {
|
|
906
|
+
return new Observable(function (subscriber) {
|
|
907
|
+
var obs = obj[observable]();
|
|
908
|
+
if (isFunction(obs.subscribe)) {
|
|
909
|
+
return obs.subscribe(subscriber);
|
|
910
|
+
}
|
|
911
|
+
throw new TypeError('Provided object does not correctly implement Symbol.observable');
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
function fromArrayLike(array) {
|
|
915
|
+
return new Observable(function (subscriber) {
|
|
916
|
+
for (var i = 0; i < array.length && !subscriber.closed; i++) {
|
|
917
|
+
subscriber.next(array[i]);
|
|
918
|
+
}
|
|
919
|
+
subscriber.complete();
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
function fromPromise(promise) {
|
|
923
|
+
return new Observable(function (subscriber) {
|
|
924
|
+
promise
|
|
925
|
+
.then(function (value) {
|
|
926
|
+
if (!subscriber.closed) {
|
|
927
|
+
subscriber.next(value);
|
|
928
|
+
subscriber.complete();
|
|
929
|
+
}
|
|
930
|
+
}, function (err) { return subscriber.error(err); })
|
|
931
|
+
.then(null, reportUnhandledError);
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
function fromIterable(iterable) {
|
|
935
|
+
return new Observable(function (subscriber) {
|
|
936
|
+
var e_1, _a;
|
|
937
|
+
try {
|
|
938
|
+
for (var iterable_1 = __values(iterable), iterable_1_1 = iterable_1.next(); !iterable_1_1.done; iterable_1_1 = iterable_1.next()) {
|
|
939
|
+
var value = iterable_1_1.value;
|
|
940
|
+
subscriber.next(value);
|
|
941
|
+
if (subscriber.closed) {
|
|
942
|
+
return;
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
947
|
+
finally {
|
|
948
|
+
try {
|
|
949
|
+
if (iterable_1_1 && !iterable_1_1.done && (_a = iterable_1.return)) _a.call(iterable_1);
|
|
950
|
+
}
|
|
951
|
+
finally { if (e_1) throw e_1.error; }
|
|
952
|
+
}
|
|
953
|
+
subscriber.complete();
|
|
954
|
+
});
|
|
955
|
+
}
|
|
956
|
+
function fromAsyncIterable(asyncIterable) {
|
|
957
|
+
return new Observable(function (subscriber) {
|
|
958
|
+
process(asyncIterable, subscriber).catch(function (err) { return subscriber.error(err); });
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
function fromReadableStreamLike(readableStream) {
|
|
962
|
+
return fromAsyncIterable(readableStreamLikeToAsyncGenerator(readableStream));
|
|
963
|
+
}
|
|
964
|
+
function process(asyncIterable, subscriber) {
|
|
965
|
+
var asyncIterable_1, asyncIterable_1_1;
|
|
966
|
+
var e_2, _a;
|
|
967
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
968
|
+
var value, e_2_1;
|
|
969
|
+
return __generator(this, function (_b) {
|
|
970
|
+
switch (_b.label) {
|
|
971
|
+
case 0:
|
|
972
|
+
_b.trys.push([0, 5, 6, 11]);
|
|
973
|
+
asyncIterable_1 = __asyncValues(asyncIterable);
|
|
974
|
+
_b.label = 1;
|
|
975
|
+
case 1: return [4, asyncIterable_1.next()];
|
|
976
|
+
case 2:
|
|
977
|
+
if (!(asyncIterable_1_1 = _b.sent(), !asyncIterable_1_1.done)) return [3, 4];
|
|
978
|
+
value = asyncIterable_1_1.value;
|
|
979
|
+
subscriber.next(value);
|
|
980
|
+
if (subscriber.closed) {
|
|
981
|
+
return [2];
|
|
982
|
+
}
|
|
983
|
+
_b.label = 3;
|
|
984
|
+
case 3: return [3, 1];
|
|
985
|
+
case 4: return [3, 11];
|
|
986
|
+
case 5:
|
|
987
|
+
e_2_1 = _b.sent();
|
|
988
|
+
e_2 = { error: e_2_1 };
|
|
989
|
+
return [3, 11];
|
|
990
|
+
case 6:
|
|
991
|
+
_b.trys.push([6, , 9, 10]);
|
|
992
|
+
if (!(asyncIterable_1_1 && !asyncIterable_1_1.done && (_a = asyncIterable_1.return))) return [3, 8];
|
|
993
|
+
return [4, _a.call(asyncIterable_1)];
|
|
994
|
+
case 7:
|
|
995
|
+
_b.sent();
|
|
996
|
+
_b.label = 8;
|
|
997
|
+
case 8: return [3, 10];
|
|
998
|
+
case 9:
|
|
999
|
+
if (e_2) throw e_2.error;
|
|
1000
|
+
return [7];
|
|
1001
|
+
case 10: return [7];
|
|
1002
|
+
case 11:
|
|
1003
|
+
subscriber.complete();
|
|
1004
|
+
return [2];
|
|
1005
|
+
}
|
|
1006
|
+
});
|
|
1007
|
+
});
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
function createOperatorSubscriber(destination, onNext, onComplete, onError, onFinalize) {
|
|
1011
|
+
return new OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize);
|
|
1012
|
+
}
|
|
1013
|
+
var OperatorSubscriber = (function (_super) {
|
|
1014
|
+
__extends(OperatorSubscriber, _super);
|
|
1015
|
+
function OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize, shouldUnsubscribe) {
|
|
1016
|
+
var _this = _super.call(this, destination) || this;
|
|
1017
|
+
_this.onFinalize = onFinalize;
|
|
1018
|
+
_this.shouldUnsubscribe = shouldUnsubscribe;
|
|
1019
|
+
_this._next = onNext
|
|
1020
|
+
? function (value) {
|
|
1021
|
+
try {
|
|
1022
|
+
onNext(value);
|
|
1023
|
+
}
|
|
1024
|
+
catch (err) {
|
|
1025
|
+
destination.error(err);
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
: _super.prototype._next;
|
|
1029
|
+
_this._error = onError
|
|
1030
|
+
? function (err) {
|
|
1031
|
+
try {
|
|
1032
|
+
onError(err);
|
|
1033
|
+
}
|
|
1034
|
+
catch (err) {
|
|
1035
|
+
destination.error(err);
|
|
1036
|
+
}
|
|
1037
|
+
finally {
|
|
1038
|
+
this.unsubscribe();
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
: _super.prototype._error;
|
|
1042
|
+
_this._complete = onComplete
|
|
1043
|
+
? function () {
|
|
1044
|
+
try {
|
|
1045
|
+
onComplete();
|
|
1046
|
+
}
|
|
1047
|
+
catch (err) {
|
|
1048
|
+
destination.error(err);
|
|
1049
|
+
}
|
|
1050
|
+
finally {
|
|
1051
|
+
this.unsubscribe();
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
: _super.prototype._complete;
|
|
1055
|
+
return _this;
|
|
1056
|
+
}
|
|
1057
|
+
OperatorSubscriber.prototype.unsubscribe = function () {
|
|
1058
|
+
var _a;
|
|
1059
|
+
if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {
|
|
1060
|
+
var closed_1 = this.closed;
|
|
1061
|
+
_super.prototype.unsubscribe.call(this);
|
|
1062
|
+
!closed_1 && ((_a = this.onFinalize) === null || _a === void 0 ? void 0 : _a.call(this));
|
|
1063
|
+
}
|
|
1064
|
+
};
|
|
1065
|
+
return OperatorSubscriber;
|
|
1066
|
+
}(Subscriber));
|
|
1067
|
+
|
|
1068
|
+
var Action = (function (_super) {
|
|
1069
|
+
__extends(Action, _super);
|
|
1070
|
+
function Action(scheduler, work) {
|
|
1071
|
+
return _super.call(this) || this;
|
|
1072
|
+
}
|
|
1073
|
+
Action.prototype.schedule = function (state, delay) {
|
|
1074
|
+
return this;
|
|
1075
|
+
};
|
|
1076
|
+
return Action;
|
|
1077
|
+
}(Subscription));
|
|
1078
|
+
|
|
1079
|
+
var intervalProvider = {
|
|
1080
|
+
setInterval: function (handler, timeout) {
|
|
1081
|
+
var args = [];
|
|
1082
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1083
|
+
args[_i - 2] = arguments[_i];
|
|
1084
|
+
}
|
|
1085
|
+
var delegate = intervalProvider.delegate;
|
|
1086
|
+
if (delegate === null || delegate === void 0 ? void 0 : delegate.setInterval) {
|
|
1087
|
+
return delegate.setInterval.apply(delegate, __spreadArray([handler, timeout], __read(args)));
|
|
1088
|
+
}
|
|
1089
|
+
return setInterval.apply(void 0, __spreadArray([handler, timeout], __read(args)));
|
|
1090
|
+
},
|
|
1091
|
+
clearInterval: function (handle) {
|
|
1092
|
+
var delegate = intervalProvider.delegate;
|
|
1093
|
+
return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearInterval) || clearInterval)(handle);
|
|
1094
|
+
},
|
|
1095
|
+
delegate: undefined,
|
|
1096
|
+
};
|
|
1097
|
+
|
|
1098
|
+
var AsyncAction = (function (_super) {
|
|
1099
|
+
__extends(AsyncAction, _super);
|
|
1100
|
+
function AsyncAction(scheduler, work) {
|
|
1101
|
+
var _this = _super.call(this, scheduler, work) || this;
|
|
1102
|
+
_this.scheduler = scheduler;
|
|
1103
|
+
_this.work = work;
|
|
1104
|
+
_this.pending = false;
|
|
1105
|
+
return _this;
|
|
1106
|
+
}
|
|
1107
|
+
AsyncAction.prototype.schedule = function (state, delay) {
|
|
1108
|
+
if (delay === void 0) { delay = 0; }
|
|
1109
|
+
if (this.closed) {
|
|
1110
|
+
return this;
|
|
1111
|
+
}
|
|
1112
|
+
this.state = state;
|
|
1113
|
+
var id = this.id;
|
|
1114
|
+
var scheduler = this.scheduler;
|
|
1115
|
+
if (id != null) {
|
|
1116
|
+
this.id = this.recycleAsyncId(scheduler, id, delay);
|
|
1117
|
+
}
|
|
1118
|
+
this.pending = true;
|
|
1119
|
+
this.delay = delay;
|
|
1120
|
+
this.id = this.id || this.requestAsyncId(scheduler, this.id, delay);
|
|
1121
|
+
return this;
|
|
1122
|
+
};
|
|
1123
|
+
AsyncAction.prototype.requestAsyncId = function (scheduler, _id, delay) {
|
|
1124
|
+
if (delay === void 0) { delay = 0; }
|
|
1125
|
+
return intervalProvider.setInterval(scheduler.flush.bind(scheduler, this), delay);
|
|
1126
|
+
};
|
|
1127
|
+
AsyncAction.prototype.recycleAsyncId = function (_scheduler, id, delay) {
|
|
1128
|
+
if (delay === void 0) { delay = 0; }
|
|
1129
|
+
if (delay != null && this.delay === delay && this.pending === false) {
|
|
1130
|
+
return id;
|
|
1131
|
+
}
|
|
1132
|
+
intervalProvider.clearInterval(id);
|
|
1133
|
+
return undefined;
|
|
1134
|
+
};
|
|
1135
|
+
AsyncAction.prototype.execute = function (state, delay) {
|
|
1136
|
+
if (this.closed) {
|
|
1137
|
+
return new Error('executing a cancelled action');
|
|
1138
|
+
}
|
|
1139
|
+
this.pending = false;
|
|
1140
|
+
var error = this._execute(state, delay);
|
|
1141
|
+
if (error) {
|
|
1142
|
+
return error;
|
|
1143
|
+
}
|
|
1144
|
+
else if (this.pending === false && this.id != null) {
|
|
1145
|
+
this.id = this.recycleAsyncId(this.scheduler, this.id, null);
|
|
1146
|
+
}
|
|
1147
|
+
};
|
|
1148
|
+
AsyncAction.prototype._execute = function (state, _delay) {
|
|
1149
|
+
var errored = false;
|
|
1150
|
+
var errorValue;
|
|
1151
|
+
try {
|
|
1152
|
+
this.work(state);
|
|
1153
|
+
}
|
|
1154
|
+
catch (e) {
|
|
1155
|
+
errored = true;
|
|
1156
|
+
errorValue = e ? e : new Error('Scheduled action threw falsy error');
|
|
1157
|
+
}
|
|
1158
|
+
if (errored) {
|
|
1159
|
+
this.unsubscribe();
|
|
1160
|
+
return errorValue;
|
|
1161
|
+
}
|
|
1162
|
+
};
|
|
1163
|
+
AsyncAction.prototype.unsubscribe = function () {
|
|
1164
|
+
if (!this.closed) {
|
|
1165
|
+
var _a = this, id = _a.id, scheduler = _a.scheduler;
|
|
1166
|
+
var actions = scheduler.actions;
|
|
1167
|
+
this.work = this.state = this.scheduler = null;
|
|
1168
|
+
this.pending = false;
|
|
1169
|
+
arrRemove(actions, this);
|
|
1170
|
+
if (id != null) {
|
|
1171
|
+
this.id = this.recycleAsyncId(scheduler, id, null);
|
|
1172
|
+
}
|
|
1173
|
+
this.delay = null;
|
|
1174
|
+
_super.prototype.unsubscribe.call(this);
|
|
1175
|
+
}
|
|
1176
|
+
};
|
|
1177
|
+
return AsyncAction;
|
|
1178
|
+
}(Action));
|
|
1179
|
+
|
|
1180
|
+
var dateTimestampProvider = {
|
|
1181
|
+
now: function () {
|
|
1182
|
+
return (dateTimestampProvider.delegate || Date).now();
|
|
1183
|
+
},
|
|
1184
|
+
delegate: undefined,
|
|
1185
|
+
};
|
|
1186
|
+
|
|
1187
|
+
var Scheduler = (function () {
|
|
1188
|
+
function Scheduler(schedulerActionCtor, now) {
|
|
1189
|
+
if (now === void 0) { now = Scheduler.now; }
|
|
1190
|
+
this.schedulerActionCtor = schedulerActionCtor;
|
|
1191
|
+
this.now = now;
|
|
1192
|
+
}
|
|
1193
|
+
Scheduler.prototype.schedule = function (work, delay, state) {
|
|
1194
|
+
if (delay === void 0) { delay = 0; }
|
|
1195
|
+
return new this.schedulerActionCtor(this, work).schedule(state, delay);
|
|
1196
|
+
};
|
|
1197
|
+
Scheduler.now = dateTimestampProvider.now;
|
|
1198
|
+
return Scheduler;
|
|
1199
|
+
}());
|
|
1200
|
+
|
|
1201
|
+
var AsyncScheduler = (function (_super) {
|
|
1202
|
+
__extends(AsyncScheduler, _super);
|
|
1203
|
+
function AsyncScheduler(SchedulerAction, now) {
|
|
1204
|
+
if (now === void 0) { now = Scheduler.now; }
|
|
1205
|
+
var _this = _super.call(this, SchedulerAction, now) || this;
|
|
1206
|
+
_this.actions = [];
|
|
1207
|
+
_this._active = false;
|
|
1208
|
+
_this._scheduled = undefined;
|
|
1209
|
+
return _this;
|
|
1210
|
+
}
|
|
1211
|
+
AsyncScheduler.prototype.flush = function (action) {
|
|
1212
|
+
var actions = this.actions;
|
|
1213
|
+
if (this._active) {
|
|
1214
|
+
actions.push(action);
|
|
1215
|
+
return;
|
|
1216
|
+
}
|
|
1217
|
+
var error;
|
|
1218
|
+
this._active = true;
|
|
1219
|
+
do {
|
|
1220
|
+
if ((error = action.execute(action.state, action.delay))) {
|
|
1221
|
+
break;
|
|
1222
|
+
}
|
|
1223
|
+
} while ((action = actions.shift()));
|
|
1224
|
+
this._active = false;
|
|
1225
|
+
if (error) {
|
|
1226
|
+
while ((action = actions.shift())) {
|
|
1227
|
+
action.unsubscribe();
|
|
1228
|
+
}
|
|
1229
|
+
throw error;
|
|
1230
|
+
}
|
|
1231
|
+
};
|
|
1232
|
+
return AsyncScheduler;
|
|
1233
|
+
}(Scheduler));
|
|
1234
|
+
|
|
1235
|
+
var asyncScheduler = new AsyncScheduler(AsyncAction);
|
|
1236
|
+
var async = asyncScheduler;
|
|
1237
|
+
|
|
1238
|
+
function isScheduler(value) {
|
|
1239
|
+
return value && isFunction(value.schedule);
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
function isValidDate(value) {
|
|
1243
|
+
return value instanceof Date && !isNaN(value);
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
function timer(dueTime, intervalOrScheduler, scheduler) {
|
|
1247
|
+
if (dueTime === void 0) { dueTime = 0; }
|
|
1248
|
+
if (scheduler === void 0) { scheduler = async; }
|
|
1249
|
+
var intervalDuration = -1;
|
|
1250
|
+
if (intervalOrScheduler != null) {
|
|
1251
|
+
if (isScheduler(intervalOrScheduler)) {
|
|
1252
|
+
scheduler = intervalOrScheduler;
|
|
1253
|
+
}
|
|
1254
|
+
else {
|
|
1255
|
+
intervalDuration = intervalOrScheduler;
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
return new Observable(function (subscriber) {
|
|
1259
|
+
var due = isValidDate(dueTime) ? +dueTime - scheduler.now() : dueTime;
|
|
1260
|
+
if (due < 0) {
|
|
1261
|
+
due = 0;
|
|
1262
|
+
}
|
|
1263
|
+
var n = 0;
|
|
1264
|
+
return scheduler.schedule(function () {
|
|
1265
|
+
if (!subscriber.closed) {
|
|
1266
|
+
subscriber.next(n++);
|
|
1267
|
+
if (0 <= intervalDuration) {
|
|
1268
|
+
this.schedule(undefined, intervalDuration);
|
|
1269
|
+
}
|
|
1270
|
+
else {
|
|
1271
|
+
subscriber.complete();
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
}, due);
|
|
1275
|
+
});
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
function last(arr) {
|
|
1279
|
+
return arr[arr.length - 1];
|
|
1280
|
+
}
|
|
1281
|
+
function popScheduler(args) {
|
|
1282
|
+
return isScheduler(last(args)) ? args.pop() : undefined;
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
function executeSchedule(parentSubscription, scheduler, work, delay, repeat) {
|
|
1286
|
+
if (delay === void 0) { delay = 0; }
|
|
1287
|
+
if (repeat === void 0) { repeat = false; }
|
|
1288
|
+
var scheduleSubscription = scheduler.schedule(function () {
|
|
1289
|
+
work();
|
|
1290
|
+
if (repeat) {
|
|
1291
|
+
parentSubscription.add(this.schedule(null, delay));
|
|
1292
|
+
}
|
|
1293
|
+
else {
|
|
1294
|
+
this.unsubscribe();
|
|
1295
|
+
}
|
|
1296
|
+
}, delay);
|
|
1297
|
+
parentSubscription.add(scheduleSubscription);
|
|
1298
|
+
if (!repeat) {
|
|
1299
|
+
return scheduleSubscription;
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
function catchError(selector) {
|
|
1304
|
+
return operate(function (source, subscriber) {
|
|
1305
|
+
var innerSub = null;
|
|
1306
|
+
var syncUnsub = false;
|
|
1307
|
+
var handledResult;
|
|
1308
|
+
innerSub = source.subscribe(createOperatorSubscriber(subscriber, undefined, undefined, function (err) {
|
|
1309
|
+
handledResult = innerFrom(selector(err, catchError(selector)(source)));
|
|
1310
|
+
if (innerSub) {
|
|
1311
|
+
innerSub.unsubscribe();
|
|
1312
|
+
innerSub = null;
|
|
1313
|
+
handledResult.subscribe(subscriber);
|
|
1314
|
+
}
|
|
1315
|
+
else {
|
|
1316
|
+
syncUnsub = true;
|
|
1317
|
+
}
|
|
1318
|
+
}));
|
|
1319
|
+
if (syncUnsub) {
|
|
1320
|
+
innerSub.unsubscribe();
|
|
1321
|
+
innerSub = null;
|
|
1322
|
+
handledResult.subscribe(subscriber);
|
|
1323
|
+
}
|
|
1324
|
+
});
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
function observeOn(scheduler, delay) {
|
|
1328
|
+
if (delay === void 0) { delay = 0; }
|
|
1329
|
+
return operate(function (source, subscriber) {
|
|
1330
|
+
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); }));
|
|
1331
|
+
});
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
function subscribeOn(scheduler, delay) {
|
|
1335
|
+
if (delay === void 0) { delay = 0; }
|
|
1336
|
+
return operate(function (source, subscriber) {
|
|
1337
|
+
subscriber.add(scheduler.schedule(function () { return source.subscribe(subscriber); }, delay));
|
|
1338
|
+
});
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
function scheduleObservable(input, scheduler) {
|
|
1342
|
+
return innerFrom(input).pipe(subscribeOn(scheduler), observeOn(scheduler));
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
function schedulePromise(input, scheduler) {
|
|
1346
|
+
return innerFrom(input).pipe(subscribeOn(scheduler), observeOn(scheduler));
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
function scheduleArray(input, scheduler) {
|
|
1350
|
+
return new Observable(function (subscriber) {
|
|
1351
|
+
var i = 0;
|
|
1352
|
+
return scheduler.schedule(function () {
|
|
1353
|
+
if (i === input.length) {
|
|
1354
|
+
subscriber.complete();
|
|
1355
|
+
}
|
|
1356
|
+
else {
|
|
1357
|
+
subscriber.next(input[i++]);
|
|
1358
|
+
if (!subscriber.closed) {
|
|
1359
|
+
this.schedule();
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
});
|
|
1363
|
+
});
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
function scheduleIterable(input, scheduler) {
|
|
1367
|
+
return new Observable(function (subscriber) {
|
|
1368
|
+
var iterator$1;
|
|
1369
|
+
executeSchedule(subscriber, scheduler, function () {
|
|
1370
|
+
iterator$1 = input[iterator]();
|
|
1371
|
+
executeSchedule(subscriber, scheduler, function () {
|
|
1372
|
+
var _a;
|
|
1373
|
+
var value;
|
|
1374
|
+
var done;
|
|
1375
|
+
try {
|
|
1376
|
+
(_a = iterator$1.next(), value = _a.value, done = _a.done);
|
|
1377
|
+
}
|
|
1378
|
+
catch (err) {
|
|
1379
|
+
subscriber.error(err);
|
|
1380
|
+
return;
|
|
1381
|
+
}
|
|
1382
|
+
if (done) {
|
|
1383
|
+
subscriber.complete();
|
|
1384
|
+
}
|
|
1385
|
+
else {
|
|
1386
|
+
subscriber.next(value);
|
|
1387
|
+
}
|
|
1388
|
+
}, 0, true);
|
|
1389
|
+
});
|
|
1390
|
+
return function () { return isFunction(iterator$1 === null || iterator$1 === void 0 ? void 0 : iterator$1.return) && iterator$1.return(); };
|
|
1391
|
+
});
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
function scheduleAsyncIterable(input, scheduler) {
|
|
1395
|
+
if (!input) {
|
|
1396
|
+
throw new Error('Iterable cannot be null');
|
|
1397
|
+
}
|
|
1398
|
+
return new Observable(function (subscriber) {
|
|
1399
|
+
executeSchedule(subscriber, scheduler, function () {
|
|
1400
|
+
var iterator = input[Symbol.asyncIterator]();
|
|
1401
|
+
executeSchedule(subscriber, scheduler, function () {
|
|
1402
|
+
iterator.next().then(function (result) {
|
|
1403
|
+
if (result.done) {
|
|
1404
|
+
subscriber.complete();
|
|
1405
|
+
}
|
|
1406
|
+
else {
|
|
1407
|
+
subscriber.next(result.value);
|
|
1408
|
+
}
|
|
1409
|
+
});
|
|
1410
|
+
}, 0, true);
|
|
1411
|
+
});
|
|
1412
|
+
});
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
function scheduleReadableStreamLike(input, scheduler) {
|
|
1416
|
+
return scheduleAsyncIterable(readableStreamLikeToAsyncGenerator(input), scheduler);
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
function scheduled(input, scheduler) {
|
|
1420
|
+
if (input != null) {
|
|
1421
|
+
if (isInteropObservable(input)) {
|
|
1422
|
+
return scheduleObservable(input, scheduler);
|
|
1423
|
+
}
|
|
1424
|
+
if (isArrayLike(input)) {
|
|
1425
|
+
return scheduleArray(input, scheduler);
|
|
1426
|
+
}
|
|
1427
|
+
if (isPromise(input)) {
|
|
1428
|
+
return schedulePromise(input, scheduler);
|
|
1429
|
+
}
|
|
1430
|
+
if (isAsyncIterable(input)) {
|
|
1431
|
+
return scheduleAsyncIterable(input, scheduler);
|
|
1432
|
+
}
|
|
1433
|
+
if (isIterable(input)) {
|
|
1434
|
+
return scheduleIterable(input, scheduler);
|
|
1435
|
+
}
|
|
1436
|
+
if (isReadableStreamLike(input)) {
|
|
1437
|
+
return scheduleReadableStreamLike(input, scheduler);
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
throw createInvalidObservableTypeError(input);
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
function from(input, scheduler) {
|
|
1444
|
+
return scheduler ? scheduled(input, scheduler) : innerFrom(input);
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
function map(project, thisArg) {
|
|
1448
|
+
return operate(function (source, subscriber) {
|
|
1449
|
+
var index = 0;
|
|
1450
|
+
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1451
|
+
subscriber.next(project.call(thisArg, value, index++));
|
|
1452
|
+
}));
|
|
1453
|
+
});
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
function mergeInternals(source, subscriber, project, concurrent, onBeforeNext, expand, innerSubScheduler, additionalFinalizer) {
|
|
1457
|
+
var buffer = [];
|
|
1458
|
+
var active = 0;
|
|
1459
|
+
var index = 0;
|
|
1460
|
+
var isComplete = false;
|
|
1461
|
+
var checkComplete = function () {
|
|
1462
|
+
if (isComplete && !buffer.length && !active) {
|
|
1463
|
+
subscriber.complete();
|
|
1464
|
+
}
|
|
1465
|
+
};
|
|
1466
|
+
var outerNext = function (value) { return (active < concurrent ? doInnerSub(value) : buffer.push(value)); };
|
|
1467
|
+
var doInnerSub = function (value) {
|
|
1468
|
+
expand && subscriber.next(value);
|
|
1469
|
+
active++;
|
|
1470
|
+
var innerComplete = false;
|
|
1471
|
+
innerFrom(project(value, index++)).subscribe(createOperatorSubscriber(subscriber, function (innerValue) {
|
|
1472
|
+
onBeforeNext === null || onBeforeNext === void 0 ? void 0 : onBeforeNext(innerValue);
|
|
1473
|
+
if (expand) {
|
|
1474
|
+
outerNext(innerValue);
|
|
1475
|
+
}
|
|
1476
|
+
else {
|
|
1477
|
+
subscriber.next(innerValue);
|
|
1478
|
+
}
|
|
1479
|
+
}, function () {
|
|
1480
|
+
innerComplete = true;
|
|
1481
|
+
}, undefined, function () {
|
|
1482
|
+
if (innerComplete) {
|
|
1483
|
+
try {
|
|
1484
|
+
active--;
|
|
1485
|
+
var _loop_1 = function () {
|
|
1486
|
+
var bufferedValue = buffer.shift();
|
|
1487
|
+
if (innerSubScheduler) {
|
|
1488
|
+
executeSchedule(subscriber, innerSubScheduler, function () { return doInnerSub(bufferedValue); });
|
|
1489
|
+
}
|
|
1490
|
+
else {
|
|
1491
|
+
doInnerSub(bufferedValue);
|
|
1492
|
+
}
|
|
1493
|
+
};
|
|
1494
|
+
while (buffer.length && active < concurrent) {
|
|
1495
|
+
_loop_1();
|
|
1496
|
+
}
|
|
1497
|
+
checkComplete();
|
|
1498
|
+
}
|
|
1499
|
+
catch (err) {
|
|
1500
|
+
subscriber.error(err);
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
}));
|
|
1504
|
+
};
|
|
1505
|
+
source.subscribe(createOperatorSubscriber(subscriber, outerNext, function () {
|
|
1506
|
+
isComplete = true;
|
|
1507
|
+
checkComplete();
|
|
1508
|
+
}));
|
|
1509
|
+
return function () {
|
|
1510
|
+
additionalFinalizer === null || additionalFinalizer === void 0 ? void 0 : additionalFinalizer();
|
|
1511
|
+
};
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
function mergeMap(project, resultSelector, concurrent) {
|
|
1515
|
+
if (concurrent === void 0) { concurrent = Infinity; }
|
|
1516
|
+
if (isFunction(resultSelector)) {
|
|
1517
|
+
return mergeMap(function (a, i) { return map(function (b, ii) { return resultSelector(a, b, i, ii); })(innerFrom(project(a, i))); }, concurrent);
|
|
1518
|
+
}
|
|
1519
|
+
else if (typeof resultSelector === 'number') {
|
|
1520
|
+
concurrent = resultSelector;
|
|
1521
|
+
}
|
|
1522
|
+
return operate(function (source, subscriber) { return mergeInternals(source, subscriber, project, concurrent); });
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
function mergeAll(concurrent) {
|
|
1526
|
+
if (concurrent === void 0) { concurrent = Infinity; }
|
|
1527
|
+
return mergeMap(identity, concurrent);
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1530
|
+
function concatAll() {
|
|
1531
|
+
return mergeAll(1);
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
function debounceTime(dueTime, scheduler) {
|
|
1535
|
+
if (scheduler === void 0) { scheduler = asyncScheduler; }
|
|
1536
|
+
return operate(function (source, subscriber) {
|
|
1537
|
+
var activeTask = null;
|
|
1538
|
+
var lastValue = null;
|
|
1539
|
+
var lastTime = null;
|
|
1540
|
+
var emit = function () {
|
|
1541
|
+
if (activeTask) {
|
|
1542
|
+
activeTask.unsubscribe();
|
|
1543
|
+
activeTask = null;
|
|
1544
|
+
var value = lastValue;
|
|
1545
|
+
lastValue = null;
|
|
1546
|
+
subscriber.next(value);
|
|
1547
|
+
}
|
|
1548
|
+
};
|
|
1549
|
+
function emitWhenIdle() {
|
|
1550
|
+
var targetTime = lastTime + dueTime;
|
|
1551
|
+
var now = scheduler.now();
|
|
1552
|
+
if (now < targetTime) {
|
|
1553
|
+
activeTask = this.schedule(undefined, targetTime - now);
|
|
1554
|
+
subscriber.add(activeTask);
|
|
1555
|
+
return;
|
|
1556
|
+
}
|
|
1557
|
+
emit();
|
|
1558
|
+
}
|
|
1559
|
+
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1560
|
+
lastValue = value;
|
|
1561
|
+
lastTime = scheduler.now();
|
|
1562
|
+
if (!activeTask) {
|
|
1563
|
+
activeTask = scheduler.schedule(emitWhenIdle, dueTime);
|
|
1564
|
+
subscriber.add(activeTask);
|
|
1565
|
+
}
|
|
1566
|
+
}, function () {
|
|
1567
|
+
emit();
|
|
1568
|
+
subscriber.complete();
|
|
1569
|
+
}, undefined, function () {
|
|
1570
|
+
lastValue = activeTask = null;
|
|
1571
|
+
}));
|
|
1572
|
+
});
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1575
|
+
function concat$1() {
|
|
1576
|
+
var args = [];
|
|
1577
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1578
|
+
args[_i] = arguments[_i];
|
|
1579
|
+
}
|
|
1580
|
+
return concatAll()(from(args, popScheduler(args)));
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
var EMPTY = new Observable(function (subscriber) { return subscriber.complete(); });
|
|
1584
|
+
|
|
1585
|
+
function take(count) {
|
|
1586
|
+
return count <= 0
|
|
1587
|
+
?
|
|
1588
|
+
function () { return EMPTY; }
|
|
1589
|
+
: operate(function (source, subscriber) {
|
|
1590
|
+
var seen = 0;
|
|
1591
|
+
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1592
|
+
if (++seen <= count) {
|
|
1593
|
+
subscriber.next(value);
|
|
1594
|
+
if (count <= seen) {
|
|
1595
|
+
subscriber.complete();
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
}));
|
|
1599
|
+
});
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1602
|
+
function ignoreElements() {
|
|
1603
|
+
return operate(function (source, subscriber) {
|
|
1604
|
+
source.subscribe(createOperatorSubscriber(subscriber, noop));
|
|
1605
|
+
});
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
function mapTo(value) {
|
|
1609
|
+
return map(function () { return value; });
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
function delayWhen(delayDurationSelector, subscriptionDelay) {
|
|
1613
|
+
if (subscriptionDelay) {
|
|
1614
|
+
return function (source) {
|
|
1615
|
+
return concat$1(subscriptionDelay.pipe(take(1), ignoreElements()), source.pipe(delayWhen(delayDurationSelector)));
|
|
1616
|
+
};
|
|
1617
|
+
}
|
|
1618
|
+
return mergeMap(function (value, index) { return delayDurationSelector(value, index).pipe(take(1), mapTo(value)); });
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
function delay(due, scheduler) {
|
|
1622
|
+
if (scheduler === void 0) { scheduler = asyncScheduler; }
|
|
1623
|
+
var duration = timer(due, scheduler);
|
|
1624
|
+
return delayWhen(function () { return duration; });
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
function distinctUntilChanged(comparator, keySelector) {
|
|
1628
|
+
if (keySelector === void 0) { keySelector = identity; }
|
|
1629
|
+
comparator = comparator !== null && comparator !== void 0 ? comparator : defaultCompare;
|
|
1630
|
+
return operate(function (source, subscriber) {
|
|
1631
|
+
var previousKey;
|
|
1632
|
+
var first = true;
|
|
1633
|
+
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1634
|
+
var currentKey = keySelector(value);
|
|
1635
|
+
if (first || !comparator(previousKey, currentKey)) {
|
|
1636
|
+
first = false;
|
|
1637
|
+
previousKey = currentKey;
|
|
1638
|
+
subscriber.next(value);
|
|
1639
|
+
}
|
|
1640
|
+
}));
|
|
1641
|
+
});
|
|
1642
|
+
}
|
|
1643
|
+
function defaultCompare(a, b) {
|
|
1644
|
+
return a === b;
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
function filter(predicate, thisArg) {
|
|
1648
|
+
return operate(function (source, subscriber) {
|
|
1649
|
+
var index = 0;
|
|
1650
|
+
source.subscribe(createOperatorSubscriber(subscriber, function (value) { return predicate.call(thisArg, value, index++) && subscriber.next(value); }));
|
|
1651
|
+
});
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1654
|
+
function skip(count) {
|
|
1655
|
+
return filter(function (_, index) { return count <= index; });
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
function startWith() {
|
|
1659
|
+
var values = [];
|
|
1660
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1661
|
+
values[_i] = arguments[_i];
|
|
1662
|
+
}
|
|
1663
|
+
var scheduler = popScheduler(values);
|
|
1664
|
+
return operate(function (source, subscriber) {
|
|
1665
|
+
(scheduler ? concat$1(values, source, scheduler) : concat$1(values, source)).subscribe(subscriber);
|
|
1666
|
+
});
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1669
|
+
function switchMap(project, resultSelector) {
|
|
1670
|
+
return operate(function (source, subscriber) {
|
|
1671
|
+
var innerSubscriber = null;
|
|
1672
|
+
var index = 0;
|
|
1673
|
+
var isComplete = false;
|
|
1674
|
+
var checkComplete = function () { return isComplete && !innerSubscriber && subscriber.complete(); };
|
|
1675
|
+
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1676
|
+
innerSubscriber === null || innerSubscriber === void 0 ? void 0 : innerSubscriber.unsubscribe();
|
|
1677
|
+
var innerIndex = 0;
|
|
1678
|
+
var outerIndex = index++;
|
|
1679
|
+
innerFrom(project(value, outerIndex)).subscribe((innerSubscriber = createOperatorSubscriber(subscriber, function (innerValue) { return subscriber.next(resultSelector ? resultSelector(value, innerValue, outerIndex, innerIndex++) : innerValue); }, function () {
|
|
1680
|
+
innerSubscriber = null;
|
|
1681
|
+
checkComplete();
|
|
1682
|
+
})));
|
|
1683
|
+
}, function () {
|
|
1684
|
+
isComplete = true;
|
|
1685
|
+
checkComplete();
|
|
1686
|
+
}));
|
|
1687
|
+
});
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1690
|
+
function tap(observerOrNext, error, complete) {
|
|
1691
|
+
var tapObserver = isFunction(observerOrNext) || error || complete
|
|
1692
|
+
?
|
|
1693
|
+
{ next: observerOrNext, error: error, complete: complete }
|
|
1694
|
+
: observerOrNext;
|
|
1695
|
+
return tapObserver
|
|
1696
|
+
? operate(function (source, subscriber) {
|
|
1697
|
+
var _a;
|
|
1698
|
+
(_a = tapObserver.subscribe) === null || _a === void 0 ? void 0 : _a.call(tapObserver);
|
|
1699
|
+
var isUnsub = true;
|
|
1700
|
+
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
1701
|
+
var _a;
|
|
1702
|
+
(_a = tapObserver.next) === null || _a === void 0 ? void 0 : _a.call(tapObserver, value);
|
|
1703
|
+
subscriber.next(value);
|
|
1704
|
+
}, function () {
|
|
1705
|
+
var _a;
|
|
1706
|
+
isUnsub = false;
|
|
1707
|
+
(_a = tapObserver.complete) === null || _a === void 0 ? void 0 : _a.call(tapObserver);
|
|
1708
|
+
subscriber.complete();
|
|
1709
|
+
}, function (err) {
|
|
1710
|
+
var _a;
|
|
1711
|
+
isUnsub = false;
|
|
1712
|
+
(_a = tapObserver.error) === null || _a === void 0 ? void 0 : _a.call(tapObserver, err);
|
|
1713
|
+
subscriber.error(err);
|
|
1714
|
+
}, function () {
|
|
1715
|
+
var _a, _b;
|
|
1716
|
+
if (isUnsub) {
|
|
1717
|
+
(_a = tapObserver.unsubscribe) === null || _a === void 0 ? void 0 : _a.call(tapObserver);
|
|
1718
|
+
}
|
|
1719
|
+
(_b = tapObserver.finalize) === null || _b === void 0 ? void 0 : _b.call(tapObserver);
|
|
1720
|
+
}));
|
|
1721
|
+
})
|
|
1722
|
+
:
|
|
1723
|
+
identity;
|
|
1724
|
+
}
|
|
1725
|
+
|
|
187
1726
|
//const hasSW = 'serviceWorker' in navigator;
|
|
188
1727
|
let hasComplainedAboutSyncEvent = false;
|
|
189
1728
|
function registerSyncEvent(db, purpose) {
|
|
@@ -273,7 +1812,14 @@
|
|
|
273
1812
|
}
|
|
274
1813
|
}
|
|
275
1814
|
: (b) => {
|
|
276
|
-
|
|
1815
|
+
const u8a = ArrayBuffer.isView(b) ? b : new Uint8Array(b);
|
|
1816
|
+
const CHUNK_SIZE = 0x1000;
|
|
1817
|
+
const strs = [];
|
|
1818
|
+
for (let i = 0, l = u8a.length; i < l; i += CHUNK_SIZE) {
|
|
1819
|
+
const chunk = u8a.subarray(i, i + CHUNK_SIZE);
|
|
1820
|
+
strs.push(String.fromCharCode.apply(null, chunk));
|
|
1821
|
+
}
|
|
1822
|
+
return btoa(strs.join(""));
|
|
277
1823
|
};
|
|
278
1824
|
|
|
279
1825
|
function computeRealmSetHash({ realms, inviteRealms, }) {
|
|
@@ -763,7 +2309,7 @@
|
|
|
763
2309
|
resolve(res);
|
|
764
2310
|
}, onCancel: () => {
|
|
765
2311
|
userInteraction.next(undefined);
|
|
766
|
-
reject(new
|
|
2312
|
+
reject(new Dexie.AbortError('User cancelled'));
|
|
767
2313
|
} });
|
|
768
2314
|
userInteraction.next(interactionProps);
|
|
769
2315
|
// Start subscribing for external updates to db.cloud.userInteraction, and if so, cancel this request.
|
|
@@ -1048,7 +2594,7 @@
|
|
|
1048
2594
|
if (isOffline) {
|
|
1049
2595
|
message = `You seem to be offline. Please connect to the internet and try again.`;
|
|
1050
2596
|
}
|
|
1051
|
-
else if (
|
|
2597
|
+
else if (Dexie.debug || (typeof location !== 'undefined' && (location.hostname === 'localhost' || location.hostname === '127.0.0.1'))) {
|
|
1052
2598
|
// The audience is most likely the developer. Suggest to whitelist the localhost origin:
|
|
1053
2599
|
message = `Could not connect to server. Please verify that your origin '${location.origin}' is whitelisted using \`npx dexie-cloud whitelist\``;
|
|
1054
2600
|
}
|
|
@@ -1283,13 +2829,13 @@
|
|
|
1283
2829
|
},
|
|
1284
2830
|
};
|
|
1285
2831
|
|
|
1286
|
-
const _global = typeof globalThis !== "undefined"
|
|
2832
|
+
const _global = typeof globalThis !== "undefined" // All modern environments (node, bun, deno, browser, workers, webview etc)
|
|
1287
2833
|
? globalThis
|
|
1288
|
-
: typeof self !== "undefined"
|
|
2834
|
+
: typeof self !== "undefined" // Older browsers, workers, webview, window etc
|
|
1289
2835
|
? self
|
|
1290
|
-
: typeof global
|
|
2836
|
+
: typeof global !== "undefined" // Older versions of node
|
|
1291
2837
|
? global
|
|
1292
|
-
: undefined;
|
|
2838
|
+
: undefined; // Unsupported environment. No idea to return 'this' since we are in a module or a function scope anyway.
|
|
1293
2839
|
|
|
1294
2840
|
var TypedArraysDefs = [
|
|
1295
2841
|
"Int8Array",
|
|
@@ -1665,7 +3211,7 @@
|
|
|
1665
3211
|
const rewrittenKey = `${key}:${currentUser.userId}`;
|
|
1666
3212
|
mutClone.keys[keyIndex] = rewrittenKey;
|
|
1667
3213
|
if (rewriteValues) {
|
|
1668
|
-
|
|
3214
|
+
Dexie.setByKeyPath(mutClone.values[keyIndex], primaryKey.keyPath, rewrittenKey);
|
|
1669
3215
|
}
|
|
1670
3216
|
}
|
|
1671
3217
|
});
|
|
@@ -1829,7 +3375,7 @@
|
|
|
1829
3375
|
|
|
1830
3376
|
function throwIfCancelled(cancelToken) {
|
|
1831
3377
|
if (cancelToken === null || cancelToken === void 0 ? void 0 : cancelToken.cancelled)
|
|
1832
|
-
throw new
|
|
3378
|
+
throw new Dexie.AbortError(`Operation was cancelled`);
|
|
1833
3379
|
}
|
|
1834
3380
|
|
|
1835
3381
|
/* Need this because navigator.onLine seems to say "false" when it is actually online.
|
|
@@ -1881,7 +3427,7 @@
|
|
|
1881
3427
|
}
|
|
1882
3428
|
}
|
|
1883
3429
|
else {
|
|
1884
|
-
|
|
3430
|
+
Dexie.setByKeyPath(obj, keyPath, value);
|
|
1885
3431
|
}
|
|
1886
3432
|
}
|
|
1887
3433
|
resultKeys.push(key);
|
|
@@ -1896,7 +3442,7 @@
|
|
|
1896
3442
|
|
|
1897
3443
|
function applyServerChanges(changes, db) {
|
|
1898
3444
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1899
|
-
console.debug('Applying server changes', changes,
|
|
3445
|
+
console.debug('Applying server changes', changes, Dexie.currentTransaction);
|
|
1900
3446
|
for (const { table: tableName, muts } of changes) {
|
|
1901
3447
|
const table = db.table(tableName);
|
|
1902
3448
|
if (!table)
|
|
@@ -1933,7 +3479,7 @@
|
|
|
1933
3479
|
else {
|
|
1934
3480
|
keys.forEach((key, i) => {
|
|
1935
3481
|
// Make sure inbound keys are consistent
|
|
1936
|
-
|
|
3482
|
+
Dexie.setByKeyPath(mut.values[i], primaryKey.keyPath, key);
|
|
1937
3483
|
});
|
|
1938
3484
|
yield table.bulkAdd(mut.values);
|
|
1939
3485
|
}
|
|
@@ -1945,7 +3491,7 @@
|
|
|
1945
3491
|
else {
|
|
1946
3492
|
keys.forEach((key, i) => {
|
|
1947
3493
|
// Make sure inbound keys are consistent
|
|
1948
|
-
|
|
3494
|
+
Dexie.setByKeyPath(mut.values[i], primaryKey.keyPath, key);
|
|
1949
3495
|
});
|
|
1950
3496
|
yield table.bulkPut(mut.values);
|
|
1951
3497
|
}
|
|
@@ -2315,7 +3861,7 @@
|
|
|
2315
3861
|
// It's no need to have two channels at the same time - even though it wouldnt
|
|
2316
3862
|
// be a problem - this is an optimization.
|
|
2317
3863
|
yield db.cloud.syncState
|
|
2318
|
-
.pipe(
|
|
3864
|
+
.pipe(filter(({ phase }) => phase === 'in-sync' || phase === 'error'), take(1))
|
|
2319
3865
|
.toPromise();
|
|
2320
3866
|
console.debug('processing msg', msg);
|
|
2321
3867
|
const persistedSyncState = db.cloud.persistedSyncState.value;
|
|
@@ -2410,7 +3956,7 @@
|
|
|
2410
3956
|
return; // Ignore message
|
|
2411
3957
|
}
|
|
2412
3958
|
// Verify also that the message is based on the exact same set of realms
|
|
2413
|
-
const ourRealmSetHash = yield
|
|
3959
|
+
const ourRealmSetHash = yield Dexie.waitFor(
|
|
2414
3960
|
// Keep TX in non-IDB work
|
|
2415
3961
|
computeRealmSetHash(syncState));
|
|
2416
3962
|
console.debug('ourRealmSetHash', ourRealmSetHash);
|
|
@@ -2896,7 +4442,7 @@
|
|
|
2896
4442
|
const IS_SERVICE_WORKER = typeof self !== "undefined" && "clients" in self && !self.document;
|
|
2897
4443
|
|
|
2898
4444
|
function throwVersionIncrementNeeded() {
|
|
2899
|
-
throw new
|
|
4445
|
+
throw new Dexie.SchemaError(`Version increment needed to allow dexie-cloud change tracking`);
|
|
2900
4446
|
}
|
|
2901
4447
|
|
|
2902
4448
|
const { toString } = {};
|
|
@@ -3012,14 +4558,14 @@
|
|
|
3012
4558
|
if (!table.schema.primaryKey.outbound) {
|
|
3013
4559
|
if (!valueClones)
|
|
3014
4560
|
valueClones = req.values.slice();
|
|
3015
|
-
valueClones[idx] =
|
|
3016
|
-
|
|
4561
|
+
valueClones[idx] = Dexie.deepClone(valueClones[idx]);
|
|
4562
|
+
Dexie.setByKeyPath(valueClones[idx], table.schema.primaryKey.keyPath, keys[idx]);
|
|
3017
4563
|
}
|
|
3018
4564
|
}
|
|
3019
4565
|
else if (typeof key !== 'string' ||
|
|
3020
4566
|
(!key.startsWith(idPrefix) && !key.startsWith('#' + idPrefix))) {
|
|
3021
4567
|
// Key was specified by caller. Verify it complies with id prefix.
|
|
3022
|
-
throw new
|
|
4568
|
+
throw new Dexie.ConstraintError(`The ID "${key}" is not valid for table "${tableName}". ` +
|
|
3023
4569
|
`Primary '@' keys requires the key to be prefixed with "${idPrefix}" (or "#${idPrefix}).\n` +
|
|
3024
4570
|
`If you want to generate IDs programmatically, remove '@' from the schema to get rid of this constraint. Dexie Cloud supports custom IDs as long as they are random and globally unique.`);
|
|
3025
4571
|
}
|
|
@@ -3044,7 +4590,7 @@
|
|
|
3044
4590
|
const type = Array.isArray(key)
|
|
3045
4591
|
? key.map(toStringTag).join(',')
|
|
3046
4592
|
: toStringTag(key);
|
|
3047
|
-
throw new
|
|
4593
|
+
throw new Dexie.ConstraintError(`Invalid primary key type ${type} for table ${tableName}. Tables marked for sync has primary keys of type string or Array of string (and optional numbers)`);
|
|
3048
4594
|
}
|
|
3049
4595
|
});
|
|
3050
4596
|
}
|
|
@@ -3491,13 +5037,13 @@
|
|
|
3491
5037
|
// for just a short time.
|
|
3492
5038
|
const userIsReallyActive = new rxjs.BehaviorSubject(true);
|
|
3493
5039
|
userIsActive
|
|
3494
|
-
.pipe(
|
|
5040
|
+
.pipe(switchMap((isActive) => {
|
|
3495
5041
|
//console.debug('SyncStatus: DUBB: isActive changed to', isActive);
|
|
3496
5042
|
return isActive
|
|
3497
5043
|
? rxjs.of(true)
|
|
3498
|
-
: rxjs.of(false).pipe(
|
|
5044
|
+
: rxjs.of(false).pipe(delay(INACTIVE_WAIT_TIME))
|
|
3499
5045
|
;
|
|
3500
|
-
}),
|
|
5046
|
+
}), distinctUntilChanged())
|
|
3501
5047
|
.subscribe(userIsReallyActive);
|
|
3502
5048
|
//
|
|
3503
5049
|
// First create some corner-stone observables to build the flow on
|
|
@@ -3507,9 +5053,9 @@
|
|
|
3507
5053
|
? rxjs.fromEvent(document, 'visibilitychange')
|
|
3508
5054
|
: rxjs.of({});
|
|
3509
5055
|
// document.onvisibilitychange makes document hidden:
|
|
3510
|
-
const documentBecomesHidden = visibilityStateIsChanged.pipe(
|
|
5056
|
+
const documentBecomesHidden = visibilityStateIsChanged.pipe(filter(() => document.visibilityState === 'hidden'));
|
|
3511
5057
|
// document.onvisibilitychange makes document visible
|
|
3512
|
-
const documentBecomesVisible = visibilityStateIsChanged.pipe(
|
|
5058
|
+
const documentBecomesVisible = visibilityStateIsChanged.pipe(filter(() => document.visibilityState === 'visible'));
|
|
3513
5059
|
// Any of various user-activity-related events happen:
|
|
3514
5060
|
const userDoesSomething = typeof window !== 'undefined'
|
|
3515
5061
|
? rxjs.merge(documentBecomesVisible, rxjs.fromEvent(window, 'mousedown'), rxjs.fromEvent(window, 'mousemove'), rxjs.fromEvent(window, 'keydown'), rxjs.fromEvent(window, 'wheel'), rxjs.fromEvent(window, 'touchmove'))
|
|
@@ -3527,9 +5073,9 @@
|
|
|
3527
5073
|
userDoesSomething)
|
|
3528
5074
|
.pipe(
|
|
3529
5075
|
// No matter event source, compute whether user is visible using visibilityState:
|
|
3530
|
-
|
|
5076
|
+
map(() => document.visibilityState === 'visible'),
|
|
3531
5077
|
// Make sure to emit it
|
|
3532
|
-
|
|
5078
|
+
tap((isActive) => {
|
|
3533
5079
|
if (userIsActive.value !== isActive) {
|
|
3534
5080
|
// Emit new value unless it already has that value
|
|
3535
5081
|
userIsActive.next(isActive);
|
|
@@ -3537,8 +5083,8 @@
|
|
|
3537
5083
|
}),
|
|
3538
5084
|
// Now, if true was emitted, make sure to set a timeout to emit false
|
|
3539
5085
|
// unless new user activity things happen (in that case, the timeout will be cancelled!)
|
|
3540
|
-
|
|
3541
|
-
? rxjs.of(0).pipe(
|
|
5086
|
+
switchMap((isActive) => isActive
|
|
5087
|
+
? rxjs.of(0).pipe(delay(USER_INACTIVITY_TIMEOUT - INACTIVE_WAIT_TIME), tap(() => userIsActive.next(false)))
|
|
3542
5088
|
: rxjs.of(0)))
|
|
3543
5089
|
.subscribe(() => { }); // Unless we subscribe nothing will be propagated to userIsActive observable
|
|
3544
5090
|
}
|
|
@@ -3782,7 +5328,7 @@
|
|
|
3782
5328
|
yield sleep$1(3000);
|
|
3783
5329
|
// Wait til user does something (move mouse, tap, scroll, click etc)
|
|
3784
5330
|
console.debug('waiting for someone to do something');
|
|
3785
|
-
yield userDoesSomething.pipe(
|
|
5331
|
+
yield userDoesSomething.pipe(take(1)).toPromise();
|
|
3786
5332
|
console.debug('someone did something!');
|
|
3787
5333
|
});
|
|
3788
5334
|
}
|
|
@@ -3791,10 +5337,10 @@
|
|
|
3791
5337
|
if (!((_a = db.cloud.options) === null || _a === void 0 ? void 0 : _a.databaseUrl)) {
|
|
3792
5338
|
throw new Error(`No database URL to connect WebSocket to`);
|
|
3793
5339
|
}
|
|
3794
|
-
const messageProducer = db.messageConsumer.readyToServe.pipe(
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
5340
|
+
const messageProducer = db.messageConsumer.readyToServe.pipe(filter((isReady) => isReady), // When consumer is ready for new messages, produce such a message to inform server about it
|
|
5341
|
+
switchMap(() => db.getPersistedSyncState()), // We need the info on which server revision we are at:
|
|
5342
|
+
filter((syncState) => syncState && syncState.serverRevision), // We wont send anything to server before inital sync has taken place
|
|
5343
|
+
switchMap((syncState) => __awaiter(this, void 0, void 0, function* () {
|
|
3798
5344
|
return ({
|
|
3799
5345
|
// Produce the message to trigger server to send us new messages to consume:
|
|
3800
5346
|
type: 'ready',
|
|
@@ -3803,22 +5349,22 @@
|
|
|
3803
5349
|
});
|
|
3804
5350
|
})));
|
|
3805
5351
|
function createObservable() {
|
|
3806
|
-
return db.cloud.persistedSyncState.pipe(
|
|
3807
|
-
|
|
3808
|
-
|
|
5352
|
+
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.
|
|
5353
|
+
take(1), // Don't continue waking up whenever syncState change
|
|
5354
|
+
switchMap((syncState) => db.cloud.currentUser.pipe(map((userLogin) => [userLogin, syncState]))), switchMap(([userLogin, syncState]) => {
|
|
3809
5355
|
/*if (userLogin.license?.status && userLogin.license.status !== 'ok') {
|
|
3810
5356
|
throw new InvalidLicenseError();
|
|
3811
5357
|
}*/
|
|
3812
|
-
return userIsReallyActive.pipe(
|
|
3813
|
-
}),
|
|
5358
|
+
return userIsReallyActive.pipe(map((isActive) => [isActive ? userLogin : null, syncState]));
|
|
5359
|
+
}), switchMap(([userLogin, syncState]) => {
|
|
3814
5360
|
if ((userLogin === null || userLogin === void 0 ? void 0 : userLogin.isLoggedIn) && !(syncState === null || syncState === void 0 ? void 0 : syncState.realms.includes(userLogin.userId))) {
|
|
3815
5361
|
// We're in an in-between state when user is logged in but the user's realms are not yet synced.
|
|
3816
5362
|
// Don't make this change reconnect the websocket just yet. Wait till syncState is updated
|
|
3817
5363
|
// to iclude the user's realm.
|
|
3818
|
-
return db.cloud.persistedSyncState.pipe(
|
|
5364
|
+
return db.cloud.persistedSyncState.pipe(filter((syncState) => (syncState === null || syncState === void 0 ? void 0 : syncState.realms.includes(userLogin.userId)) || false), take(1), map((syncState) => [userLogin, syncState]));
|
|
3819
5365
|
}
|
|
3820
5366
|
return new rxjs.BehaviorSubject([userLogin, syncState]);
|
|
3821
|
-
}),
|
|
5367
|
+
}), switchMap(([userLogin, syncState]) => __awaiter(this, void 0, void 0, function* () { return [userLogin, yield computeRealmSetHash(syncState)]; })), distinctUntilChanged(([prevUser, prevHash], [currUser, currHash]) => prevUser === currUser && prevHash === currHash), switchMap(([userLogin, realmSetHash]) => {
|
|
3822
5368
|
// Let server end query changes from last entry of same client-ID and forward.
|
|
3823
5369
|
// If no new entries, server won't bother the client. If new entries, server sends only those
|
|
3824
5370
|
// and the baseRev of the last from same client-ID.
|
|
@@ -3828,10 +5374,10 @@
|
|
|
3828
5374
|
else {
|
|
3829
5375
|
return rxjs.from([]);
|
|
3830
5376
|
}
|
|
3831
|
-
}),
|
|
5377
|
+
}), catchError((error) => {
|
|
3832
5378
|
if ((error === null || error === void 0 ? void 0 : error.name) === 'TokenExpiredError') {
|
|
3833
5379
|
console.debug('WebSocket observable: Token expired. Refreshing token...');
|
|
3834
|
-
return rxjs.of(true).pipe(
|
|
5380
|
+
return rxjs.of(true).pipe(switchMap(() => __awaiter(this, void 0, void 0, function* () {
|
|
3835
5381
|
// Refresh access token
|
|
3836
5382
|
const user = yield db.getCurrentUser();
|
|
3837
5383
|
const refreshedLogin = yield refreshAccessToken(db.cloud.options.databaseUrl, user);
|
|
@@ -3842,18 +5388,18 @@
|
|
|
3842
5388
|
claims: refreshedLogin.claims,
|
|
3843
5389
|
license: refreshedLogin.license,
|
|
3844
5390
|
});
|
|
3845
|
-
})),
|
|
5391
|
+
})), switchMap(() => createObservable()));
|
|
3846
5392
|
}
|
|
3847
5393
|
else {
|
|
3848
5394
|
return rxjs.throwError(() => error);
|
|
3849
5395
|
}
|
|
3850
|
-
}),
|
|
5396
|
+
}), catchError((error) => {
|
|
3851
5397
|
db.cloud.webSocketStatus.next("error");
|
|
3852
5398
|
if (error instanceof InvalidLicenseError) {
|
|
3853
5399
|
// Don't retry. Just throw and don't try connect again.
|
|
3854
5400
|
return rxjs.throwError(() => error);
|
|
3855
5401
|
}
|
|
3856
|
-
return rxjs.from(waitAndReconnectWhenUserDoesSomething(error)).pipe(
|
|
5402
|
+
return rxjs.from(waitAndReconnectWhenUserDoesSomething(error)).pipe(switchMap(() => createObservable()));
|
|
3857
5403
|
}));
|
|
3858
5404
|
}
|
|
3859
5405
|
return createObservable().subscribe({
|
|
@@ -4058,11 +5604,11 @@
|
|
|
4058
5604
|
for (const table of db.tables) {
|
|
4059
5605
|
if ((_b = (_a = db.cloud.schema) === null || _a === void 0 ? void 0 : _a[table.name]) === null || _b === void 0 ? void 0 : _b.markedForSync) {
|
|
4060
5606
|
if (table.schema.primKey.auto) {
|
|
4061
|
-
throw new
|
|
5607
|
+
throw new Dexie.SchemaError(`Table ${table.name} is both autoIncremented and synced. ` +
|
|
4062
5608
|
`Use db.cloud.configure({unsyncedTables: [${JSON.stringify(table.name)}]}) to blacklist it from sync`);
|
|
4063
5609
|
}
|
|
4064
5610
|
if (!table.schema.primKey.keyPath) {
|
|
4065
|
-
throw new
|
|
5611
|
+
throw new Dexie.SchemaError(`Table ${table.name} cannot be both synced and outbound. ` +
|
|
4066
5612
|
`Use db.cloud.configure({unsyncedTables: [${JSON.stringify(table.name)}]}) to blacklist it from sync`);
|
|
4067
5613
|
}
|
|
4068
5614
|
}
|
|
@@ -4270,7 +5816,7 @@
|
|
|
4270
5816
|
|
|
4271
5817
|
function computeSyncState(db) {
|
|
4272
5818
|
let _prevStatus = db.cloud.webSocketStatus.value;
|
|
4273
|
-
const lazyWebSocketStatus = db.cloud.webSocketStatus.pipe(
|
|
5819
|
+
const lazyWebSocketStatus = db.cloud.webSocketStatus.pipe(switchMap((status) => {
|
|
4274
5820
|
const prevStatus = _prevStatus;
|
|
4275
5821
|
_prevStatus = status;
|
|
4276
5822
|
const rv = rxjs.of(status);
|
|
@@ -4280,23 +5826,23 @@
|
|
|
4280
5826
|
// Only show disconnected if disconnected more than 500ms, or if we can
|
|
4281
5827
|
// see that the user is indeed not active.
|
|
4282
5828
|
case 'disconnected':
|
|
4283
|
-
return userIsActive.value ? rv.pipe(
|
|
5829
|
+
return userIsActive.value ? rv.pipe(debounceTime(500)) : rv;
|
|
4284
5830
|
// Only show connecting if previous state was 'not-started' or 'error', or if
|
|
4285
5831
|
// the time it takes to connect goes beyond 4 seconds.
|
|
4286
5832
|
case 'connecting':
|
|
4287
5833
|
return prevStatus === 'not-started' || prevStatus === 'error'
|
|
4288
5834
|
? rv
|
|
4289
|
-
: rv.pipe(
|
|
5835
|
+
: rv.pipe(debounceTime(4000));
|
|
4290
5836
|
default:
|
|
4291
5837
|
return rv;
|
|
4292
5838
|
}
|
|
4293
5839
|
}));
|
|
4294
5840
|
return rxjs.combineLatest([
|
|
4295
5841
|
lazyWebSocketStatus,
|
|
4296
|
-
db.syncStateChangedEvent.pipe(
|
|
5842
|
+
db.syncStateChangedEvent.pipe(startWith({ phase: 'initial' })),
|
|
4297
5843
|
getCurrentUserEmitter(db.dx._novip),
|
|
4298
5844
|
userIsReallyActive
|
|
4299
|
-
]).pipe(
|
|
5845
|
+
]).pipe(map(([status, syncState, user, userIsActive]) => {
|
|
4300
5846
|
var _a;
|
|
4301
5847
|
if (((_a = user.license) === null || _a === void 0 ? void 0 : _a.status) && user.license.status !== 'ok') {
|
|
4302
5848
|
return {
|
|
@@ -4385,7 +5931,7 @@
|
|
|
4385
5931
|
});
|
|
4386
5932
|
|
|
4387
5933
|
const getInternalAccessControlObservable = associate((db) => {
|
|
4388
|
-
return createSharedValueObservable(getCurrentUserEmitter(db._novip).pipe(
|
|
5934
|
+
return createSharedValueObservable(getCurrentUserEmitter(db._novip).pipe(switchMap((currentUser) => Dexie.liveQuery(() => db.transaction('r', 'realms', 'members', () => Promise.all([
|
|
4389
5935
|
db.members.where({ userId: currentUser.userId }).toArray(),
|
|
4390
5936
|
db.realms.toArray(),
|
|
4391
5937
|
currentUser.userId,
|
|
@@ -4486,7 +6032,7 @@
|
|
|
4486
6032
|
const o = createSharedValueObservable(rxjs.combineLatest([
|
|
4487
6033
|
getInternalAccessControlObservable(db._novip),
|
|
4488
6034
|
getGlobalRolesObservable(db._novip),
|
|
4489
|
-
]).pipe(
|
|
6035
|
+
]).pipe(map(([{ selfMembers, realms, userId }, globalRoles]) => ({
|
|
4490
6036
|
selfMembers,
|
|
4491
6037
|
realms,
|
|
4492
6038
|
userId,
|
|
@@ -4600,16 +6146,16 @@
|
|
|
4600
6146
|
return new PermissionChecker({}, tableName, !owner || owner === dexie.cloud.currentUserId);
|
|
4601
6147
|
return new PermissionChecker(realm.permissions, tableName, realmId === dexie.cloud.currentUserId || owner === dexie.cloud.currentUserId);
|
|
4602
6148
|
};
|
|
4603
|
-
const o = source.pipe(
|
|
6149
|
+
const o = source.pipe(map(mapper));
|
|
4604
6150
|
o.getValue = () => mapper(source.getValue());
|
|
4605
6151
|
return o;
|
|
4606
6152
|
}
|
|
4607
6153
|
|
|
4608
6154
|
const getInvitesObservable = associate((db) => {
|
|
4609
|
-
const membersByEmail = getCurrentUserEmitter(db._novip).pipe(
|
|
6155
|
+
const membersByEmail = getCurrentUserEmitter(db._novip).pipe(switchMap((currentUser) => Dexie.liveQuery(() => db.members.where({ email: currentUser.email || '' }).toArray())));
|
|
4610
6156
|
const permissions = getPermissionsLookupObservable(db._novip);
|
|
4611
6157
|
const accessControl = getInternalAccessControlObservable(db._novip);
|
|
4612
|
-
return createSharedValueObservable(rxjs.combineLatest([membersByEmail, accessControl, permissions]).pipe(
|
|
6158
|
+
return createSharedValueObservable(rxjs.combineLatest([membersByEmail, accessControl, permissions]).pipe(map(([membersByEmail, accessControl, realmLookup]) => {
|
|
4613
6159
|
const reducer = (result, m) => (Object.assign(Object.assign({}, result), { [m.id]: Object.assign(Object.assign({}, m), { realm: realmLookup[m.realmId] }) }));
|
|
4614
6160
|
const emailMembersById = membersByEmail.reduce(reducer, {});
|
|
4615
6161
|
const membersById = accessControl.selfMembers.reduce(reducer, emailMembersById);
|
|
@@ -4655,7 +6201,7 @@
|
|
|
4655
6201
|
let closed = false;
|
|
4656
6202
|
function throwIfClosed() {
|
|
4657
6203
|
if (closed)
|
|
4658
|
-
throw new
|
|
6204
|
+
throw new Dexie.DatabaseClosedError();
|
|
4659
6205
|
}
|
|
4660
6206
|
dbOnClosed(dexie, () => {
|
|
4661
6207
|
subscriptions.forEach((subscription) => subscription.unsubscribe());
|
|
@@ -4666,7 +6212,7 @@
|
|
|
4666
6212
|
});
|
|
4667
6213
|
const syncComplete = new rxjs.Subject();
|
|
4668
6214
|
dexie.cloud = {
|
|
4669
|
-
version: '
|
|
6215
|
+
version: '{version}',
|
|
4670
6216
|
options: Object.assign({}, DEFAULT_OPTIONS),
|
|
4671
6217
|
schema: null,
|
|
4672
6218
|
get currentUserId() {
|
|
@@ -4725,8 +6271,8 @@
|
|
|
4725
6271
|
triggerSync(db, purpose);
|
|
4726
6272
|
if (wait) {
|
|
4727
6273
|
const newSyncState = yield db.cloud.persistedSyncState
|
|
4728
|
-
.pipe(
|
|
4729
|
-
(!syncState || newSyncState.timestamp > syncState.timestamp)),
|
|
6274
|
+
.pipe(filter((newSyncState) => (newSyncState === null || newSyncState === void 0 ? void 0 : newSyncState.timestamp) != null &&
|
|
6275
|
+
(!syncState || newSyncState.timestamp > syncState.timestamp)), take(1))
|
|
4730
6276
|
.toPromise();
|
|
4731
6277
|
if (newSyncState === null || newSyncState === void 0 ? void 0 : newSyncState.error) {
|
|
4732
6278
|
throw new Error(`Sync error: ` + newSyncState.error);
|
|
@@ -4746,7 +6292,7 @@
|
|
|
4746
6292
|
throw new Error(`Sync error: ` + newSyncState.error);
|
|
4747
6293
|
return syncNeeded;
|
|
4748
6294
|
})))
|
|
4749
|
-
.pipe(
|
|
6295
|
+
.pipe(filter((isNeeded) => !isNeeded), take(1))
|
|
4750
6296
|
.toPromise();
|
|
4751
6297
|
console.debug('Done waiting for sync completion because we have nothing to push anymore');
|
|
4752
6298
|
}
|
|
@@ -4757,7 +6303,7 @@
|
|
|
4757
6303
|
return permissions(dexie._novip, obj, tableName);
|
|
4758
6304
|
},
|
|
4759
6305
|
};
|
|
4760
|
-
dexie.Version.prototype['_parseStoresSpec'] =
|
|
6306
|
+
dexie.Version.prototype['_parseStoresSpec'] = Dexie.override(dexie.Version.prototype['_parseStoresSpec'], (origFunc) => overrideParseStoresSpec(origFunc, dexie));
|
|
4761
6307
|
dexie.Table.prototype.newId = function ({ colocateWith } = {}) {
|
|
4762
6308
|
const shardKey = colocateWith && colocateWith.substr(colocateWith.length - 3);
|
|
4763
6309
|
return generateKey(dexie.cloud.schema[this.name].idPrefix || '', shardKey);
|
|
@@ -4890,8 +6436,8 @@
|
|
|
4890
6436
|
// This is so that when db.open() completes, user should be safe
|
|
4891
6437
|
// to subscribe to these observables and get actual data.
|
|
4892
6438
|
yield rxjs.combineLatest([
|
|
4893
|
-
currentUserEmitter.pipe(
|
|
4894
|
-
db.cloud.persistedSyncState.pipe(
|
|
6439
|
+
currentUserEmitter.pipe(skip(1), take(1)),
|
|
6440
|
+
db.cloud.persistedSyncState.pipe(skip(1), take(1)),
|
|
4895
6441
|
]).toPromise();
|
|
4896
6442
|
}
|
|
4897
6443
|
// HERE: If requireAuth, do athentication now.
|
|
@@ -4942,8 +6488,8 @@
|
|
|
4942
6488
|
});
|
|
4943
6489
|
}
|
|
4944
6490
|
}
|
|
4945
|
-
dexieCloud.version = '
|
|
4946
|
-
|
|
6491
|
+
dexieCloud.version = '{version}';
|
|
6492
|
+
Dexie.Cloud = dexieCloud;
|
|
4947
6493
|
|
|
4948
6494
|
// In case the SW lives for a while, let it reuse already opened connections:
|
|
4949
6495
|
const managedDBs = new Map();
|
|
@@ -4977,7 +6523,7 @@
|
|
|
4977
6523
|
let db = managedDBs.get(dbName);
|
|
4978
6524
|
if (!db) {
|
|
4979
6525
|
console.debug('Dexie Cloud SW: Creating new Dexie instance for', dbName);
|
|
4980
|
-
const dexie = new
|
|
6526
|
+
const dexie = new Dexie(dbName, { addons: [dexieCloud] });
|
|
4981
6527
|
db = DexieCloudDB(dexie);
|
|
4982
6528
|
db.cloud.isServiceWorkerDB = true;
|
|
4983
6529
|
dexie.on('versionchange', stopManagingDB);
|
|
@@ -5020,7 +6566,7 @@
|
|
|
5020
6566
|
// Error occured. Stop managing this DB until we wake up again by a sync event,
|
|
5021
6567
|
// which will open a new Dexie and start trying to sync it.
|
|
5022
6568
|
stopManagingDB();
|
|
5023
|
-
if (e.name !==
|
|
6569
|
+
if (e.name !== Dexie.errnames.NoSuchDatabase) {
|
|
5024
6570
|
// Unless the error was that DB doesn't exist, rethrow to trigger sync retry.
|
|
5025
6571
|
throw e; // Throw e to make syncEvent.waitUntil() receive a rejected promis, so it will retry.
|
|
5026
6572
|
}
|