dexie-cloud-addon 4.0.7 → 4.1.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modern/DexieCloudOptions.d.ts +4 -2
- package/dist/modern/WSObservable.d.ts +7 -4
- package/dist/modern/db/DexieCloudDB.d.ts +2 -0
- package/dist/modern/db/entities/PersistedSyncState.d.ts +7 -0
- package/dist/modern/dexie-cloud-addon.js +1709 -72
- package/dist/modern/dexie-cloud-addon.js.map +1 -1
- package/dist/modern/dexie-cloud-addon.min.js +1 -1
- package/dist/modern/dexie-cloud-addon.min.js.map +1 -1
- package/dist/modern/service-worker.js +1709 -72
- package/dist/modern/service-worker.js.map +1 -1
- package/dist/modern/service-worker.min.js +1 -1
- package/dist/modern/service-worker.min.js.map +1 -1
- package/dist/modern/sync/DEXIE_CLOUD_SYNCER_ID.d.ts +1 -0
- package/dist/modern/sync/syncWithServer.d.ts +2 -2
- package/dist/modern/yjs/YDexieCloudSyncState.d.ts +4 -0
- package/dist/modern/yjs/YTable.d.ts +2 -0
- package/dist/modern/yjs/applyYMessages.d.ts +5 -0
- package/dist/modern/yjs/awareness.d.ts +4 -0
- package/dist/modern/yjs/createYClientUpdateObservable.d.ts +4 -0
- package/dist/modern/yjs/createYHandler.d.ts +5 -0
- package/dist/modern/yjs/downloadYDocsFromServer.d.ts +3 -0
- package/dist/modern/yjs/getUpdatesTable.d.ts +3 -0
- package/dist/modern/yjs/listUpdatesSince.d.ts +2 -0
- package/dist/modern/yjs/listYClientMessages.d.ts +3 -0
- package/dist/modern/yjs/listYClientMessagesAndStateVector.d.ts +24 -0
- package/dist/modern/yjs/updateYSyncStates.d.ts +6 -0
- package/dist/modern/yjs/y.d.ts +3 -0
- package/dist/umd/DexieCloudOptions.d.ts +4 -2
- package/dist/umd/WSObservable.d.ts +7 -4
- package/dist/umd/db/DexieCloudDB.d.ts +2 -0
- package/dist/umd/db/entities/PersistedSyncState.d.ts +7 -0
- package/dist/umd/dexie-cloud-addon.js +1707 -70
- package/dist/umd/dexie-cloud-addon.js.map +1 -1
- package/dist/umd/dexie-cloud-addon.min.js +1 -1
- package/dist/umd/dexie-cloud-addon.min.js.map +1 -1
- package/dist/umd/service-worker.js +1707 -70
- package/dist/umd/service-worker.js.map +1 -1
- package/dist/umd/service-worker.min.js +1 -1
- package/dist/umd/service-worker.min.js.map +1 -1
- package/dist/umd/sync/DEXIE_CLOUD_SYNCER_ID.d.ts +1 -0
- package/dist/umd/sync/syncWithServer.d.ts +2 -2
- package/dist/umd/yjs/YDexieCloudSyncState.d.ts +4 -0
- package/dist/umd/yjs/YTable.d.ts +2 -0
- package/dist/umd/yjs/applyYMessages.d.ts +5 -0
- package/dist/umd/yjs/awareness.d.ts +4 -0
- package/dist/umd/yjs/createYClientUpdateObservable.d.ts +4 -0
- package/dist/umd/yjs/createYHandler.d.ts +5 -0
- package/dist/umd/yjs/downloadYDocsFromServer.d.ts +3 -0
- package/dist/umd/yjs/getUpdatesTable.d.ts +3 -0
- package/dist/umd/yjs/listUpdatesSince.d.ts +2 -0
- package/dist/umd/yjs/listYClientMessages.d.ts +3 -0
- package/dist/umd/yjs/listYClientMessagesAndStateVector.d.ts +24 -0
- package/dist/umd/yjs/updateYSyncStates.d.ts +6 -0
- package/dist/umd/yjs/y.d.ts +3 -0
- package/package.json +5 -4
- package/dist/modern/helpers/dbOnClosed.d.ts +0 -2
- package/dist/umd/helpers/dbOnClosed.d.ts +0 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DEXIE_CLOUD_SYNCER_ID = "dexie-cloud-syncer";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DexieCloudDB } from '../db/DexieCloudDB';
|
|
2
2
|
import { PersistedSyncState } from '../db/entities/PersistedSyncState';
|
|
3
3
|
import { BaseRevisionMapEntry } from '../db/entities/BaseRevisionMapEntry';
|
|
4
|
-
import { DBOperationsSet, DexieCloudSchema, SyncResponse } from 'dexie-cloud-common';
|
|
4
|
+
import { DBOperationsSet, DexieCloudSchema, SyncResponse, YClientMessage } from 'dexie-cloud-common';
|
|
5
5
|
import { UserLogin } from '../db/entities/UserLogin';
|
|
6
|
-
export declare function syncWithServer(changes: DBOperationsSet, syncState: PersistedSyncState | undefined, baseRevs: BaseRevisionMapEntry[], db: DexieCloudDB, databaseUrl: string, schema: DexieCloudSchema | null, clientIdentity: string, currentUser: UserLogin): Promise<SyncResponse>;
|
|
6
|
+
export declare function syncWithServer(changes: DBOperationsSet, y: YClientMessage[], syncState: PersistedSyncState | undefined, baseRevs: BaseRevisionMapEntry[], db: DexieCloudDB, databaseUrl: string, schema: DexieCloudSchema | null, clientIdentity: string, currentUser: UserLogin): Promise<SyncResponse>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type DexieCloudDB } from "../db/DexieCloudDB";
|
|
2
|
+
export declare function getAwarenessLibrary(db: DexieCloudDB): typeof import('y-protocols/awareness');
|
|
3
|
+
export declare const awarenessWeakMap: WeakMap<any, import("y-protocols/awareness").Awareness>;
|
|
4
|
+
export declare const getDocAwareness: (doc: any) => import("y-protocols/awareness").Awareness | undefined;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { DexieCloudDB } from '../db/DexieCloudDB';
|
|
2
|
+
import { PersistedSyncState } from '../db/entities/PersistedSyncState';
|
|
3
|
+
export declare function downloadYDocsFromServer(db: DexieCloudDB, databaseUrl: string, { yDownloadedRealms, realms }: PersistedSyncState): Promise<void>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { YClientMessage } from 'dexie-cloud-common';
|
|
2
|
+
import { DexieCloudDB } from '../db/DexieCloudDB';
|
|
3
|
+
/** Queries the local database for YMessages to send to server.
|
|
4
|
+
*
|
|
5
|
+
* There are 2 messages that this function can provide:
|
|
6
|
+
* YUpdateFromClientRequest ( for local updates )
|
|
7
|
+
* YStateVector ( for state vector of foreign updates so that server can reduce the number of udpates to send back )
|
|
8
|
+
*
|
|
9
|
+
* Notice that we do not do a step 1 sync phase here to get a state vector from the server. Reason we can avoid
|
|
10
|
+
* the 2-step sync is that we are client-server and not client-client here and we keep track of the client changes
|
|
11
|
+
* sent to server by letting server acknowledge them. There is always a chance that some client update has already
|
|
12
|
+
* been sent and that the client failed to receive the ack. However, if this happens it does not matter - the change
|
|
13
|
+
* would be sent again and Yjs handles duplicate changes anyway. And it's rare so we earn the cost of roundtrips by
|
|
14
|
+
* avoiding the step1 sync and instead keep track of this in the `unsentFrom` property of the SyncState.
|
|
15
|
+
*
|
|
16
|
+
* @param db
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
export declare function listYClientMessagesAndStateVector(db: DexieCloudDB): Promise<{
|
|
20
|
+
yMessages: YClientMessage[];
|
|
21
|
+
lastUpdateIds: {
|
|
22
|
+
[yTable: string]: number;
|
|
23
|
+
};
|
|
24
|
+
}>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DexieCloudDB } from '../db/DexieCloudDB';
|
|
2
|
+
export declare function updateYSyncStates(lastUpdateIdsBeforeSync: {
|
|
3
|
+
[yTable: string]: number;
|
|
4
|
+
}, receivedUntilsAfterSync: {
|
|
5
|
+
[yTable: string]: number;
|
|
6
|
+
}, db: DexieCloudDB, serverRevision: string): Promise<void>;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { TokenFinalResponse } from 'dexie-cloud-common';
|
|
1
|
+
import type { TokenFinalResponse } from 'dexie-cloud-common';
|
|
2
|
+
import type { LoginHints } from './DexieCloudAPI';
|
|
2
3
|
export interface PeriodicSyncOptions {
|
|
3
4
|
minInterval?: number;
|
|
4
5
|
}
|
|
5
6
|
export interface DexieCloudOptions {
|
|
6
7
|
databaseUrl: string;
|
|
7
|
-
requireAuth?: boolean;
|
|
8
|
+
requireAuth?: boolean | LoginHints;
|
|
8
9
|
tryUseServiceWorker?: boolean;
|
|
9
10
|
periodicSync?: PeriodicSyncOptions;
|
|
10
11
|
customLoginGui?: boolean;
|
|
@@ -19,4 +20,5 @@ export interface DexieCloudOptions {
|
|
|
19
20
|
email?: string;
|
|
20
21
|
};
|
|
21
22
|
}) => Promise<TokenFinalResponse>;
|
|
23
|
+
awarenessProtocol?: typeof import('y-protocols/awareness');
|
|
22
24
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { DBOperationsSet } from 'dexie-cloud-common';
|
|
2
2
|
import { BehaviorSubject, Observable, Subscriber, Subscription } from 'rxjs';
|
|
3
3
|
import { DXCWebSocketStatus } from './DXCWebSocketStatus';
|
|
4
|
-
|
|
4
|
+
import type { YClientMessage } from 'dexie-cloud-common';
|
|
5
|
+
import { DexieCloudDB } from './db/DexieCloudDB';
|
|
6
|
+
export type WSClientToServerMsg = ReadyForChangesMessage | YClientMessage;
|
|
5
7
|
export interface ReadyForChangesMessage {
|
|
6
8
|
type: 'ready';
|
|
7
9
|
realmSetHash: string;
|
|
@@ -39,9 +41,10 @@ export interface TokenExpiredMessage {
|
|
|
39
41
|
type: 'token-expired';
|
|
40
42
|
}
|
|
41
43
|
export declare class WSObservable extends Observable<WSConnectionMsg> {
|
|
42
|
-
constructor(
|
|
44
|
+
constructor(db: DexieCloudDB, rev: string, realmSetHash: string, clientIdentity: string, messageProducer: Observable<WSClientToServerMsg>, webSocketStatus: BehaviorSubject<DXCWebSocketStatus>, token?: string, tokenExpiration?: Date);
|
|
43
45
|
}
|
|
44
46
|
export declare class WSConnection extends Subscription {
|
|
47
|
+
db: DexieCloudDB;
|
|
45
48
|
ws: WebSocket | null;
|
|
46
49
|
lastServerActivity: Date;
|
|
47
50
|
lastUserActivity: Date;
|
|
@@ -58,8 +61,8 @@ export declare class WSConnection extends Subscription {
|
|
|
58
61
|
webSocketStatus: BehaviorSubject<DXCWebSocketStatus>;
|
|
59
62
|
id: number;
|
|
60
63
|
private pinger;
|
|
61
|
-
private
|
|
62
|
-
constructor(
|
|
64
|
+
private subscriptions;
|
|
65
|
+
constructor(db: DexieCloudDB, rev: string, realmSetHash: string, clientIdentity: string, token: string | undefined, tokenExpiration: Date | undefined, subscriber: Subscriber<WSConnectionMsg>, messageProducer: Observable<WSClientToServerMsg>, webSocketStatus: BehaviorSubject<DXCWebSocketStatus>);
|
|
63
66
|
private teardown;
|
|
64
67
|
private disconnect;
|
|
65
68
|
reconnecting: boolean;
|
|
@@ -9,6 +9,7 @@ import { DBRealm, DBRealmMember, DBRealmRole, DexieCloudSchema } from 'dexie-clo
|
|
|
9
9
|
import { BroadcastedAndLocalEvent } from '../helpers/BroadcastedAndLocalEvent';
|
|
10
10
|
import { SyncStatePhase } from '../types/SyncState';
|
|
11
11
|
import { MessagesFromServerConsumer } from '../sync/messagesFromServerQueue';
|
|
12
|
+
import { YClientMessage } from 'dexie-cloud-common';
|
|
12
13
|
export interface SyncStateChangedEventData {
|
|
13
14
|
phase: SyncStatePhase;
|
|
14
15
|
error?: Error;
|
|
@@ -45,6 +46,7 @@ export interface DexieCloudDB extends DexieCloudDBBase {
|
|
|
45
46
|
setInitiallySynced(initiallySynced: boolean): void;
|
|
46
47
|
reconfigure(): void;
|
|
47
48
|
messageConsumer: MessagesFromServerConsumer;
|
|
49
|
+
messageProducer: Subject<YClientMessage>;
|
|
48
50
|
}
|
|
49
51
|
export declare const DEXIE_CLOUD_SCHEMA: {
|
|
50
52
|
members: string;
|