@interop/was-react 0.19.0 → 0.20.1
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/README.md +4 -3
- package/dist/auth/verifyResponse.d.ts.map +1 -1
- package/dist/auth/verifyResponse.js +10 -5
- package/dist/auth/verifyResponse.js.map +1 -1
- package/dist/identity/agents.d.ts +5 -0
- package/dist/identity/agents.d.ts.map +1 -1
- package/dist/identity/agents.js +10 -3
- package/dist/identity/agents.js.map +1 -1
- package/dist/identity/seedCredential.d.ts +5 -1
- package/dist/identity/seedCredential.d.ts.map +1 -1
- package/dist/identity/seedCredential.js +15 -28
- package/dist/identity/seedCredential.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -6
- package/dist/index.js.map +1 -1
- package/dist/react/hooks.d.ts +3 -2
- package/dist/react/hooks.d.ts.map +1 -1
- package/dist/react/hooks.js +8 -4
- package/dist/react/hooks.js.map +1 -1
- package/dist/session/authStore.d.ts +9 -0
- package/dist/session/authStore.d.ts.map +1 -1
- package/dist/session/authStore.js +113 -47
- package/dist/session/authStore.js.map +1 -1
- package/dist/session/localWipe.d.ts +1 -1
- package/dist/session/localWipe.js +2 -2
- package/dist/session/localWipe.js.map +1 -1
- package/dist/storage/adopt.d.ts +4 -1
- package/dist/storage/adopt.d.ts.map +1 -1
- package/dist/storage/adopt.js +4 -3
- package/dist/storage/adopt.js.map +1 -1
- package/dist/storage/descriptorManager.d.ts +1 -0
- package/dist/storage/descriptorManager.d.ts.map +1 -1
- package/dist/storage/descriptorManager.js +39 -21
- package/dist/storage/descriptorManager.js.map +1 -1
- package/dist/storage/entityStore.d.ts.map +1 -1
- package/dist/storage/entityStore.js +3 -0
- package/dist/storage/entityStore.js.map +1 -1
- package/dist/storage/publicUrl.js +3 -3
- package/dist/storage/storageContext.d.ts +178 -0
- package/dist/storage/storageContext.d.ts.map +1 -0
- package/dist/storage/storageContext.js +331 -0
- package/dist/storage/storageContext.js.map +1 -0
- package/dist/storage/storageManager.d.ts +61 -76
- package/dist/storage/storageManager.d.ts.map +1 -1
- package/dist/storage/storageManager.js +59 -150
- package/dist/storage/storageManager.js.map +1 -1
- package/dist/storage/syncController.d.ts +10 -1
- package/dist/storage/syncController.d.ts.map +1 -1
- package/dist/storage/syncController.js +12 -4
- package/dist/storage/syncController.js.map +1 -1
- package/dist/storage/syncStatusStore.d.ts +23 -2
- package/dist/storage/syncStatusStore.d.ts.map +1 -1
- package/dist/storage/syncStatusStore.js +22 -13
- package/dist/storage/syncStatusStore.js.map +1 -1
- package/dist/storage/wasRemoteStore.d.ts +24 -10
- package/dist/storage/wasRemoteStore.d.ts.map +1 -1
- package/dist/storage/wasRemoteStore.js +91 -36
- package/dist/storage/wasRemoteStore.js.map +1 -1
- package/dist/storage/wasSync.d.ts +24 -9
- package/dist/storage/wasSync.d.ts.map +1 -1
- package/dist/storage/wasSync.js +52 -21
- package/dist/storage/wasSync.js.map +1 -1
- package/dist/storage/writerId.d.ts +36 -0
- package/dist/storage/writerId.d.ts.map +1 -0
- package/dist/storage/writerId.js +76 -0
- package/dist/storage/writerId.js.map +1 -0
- package/package.json +9 -9
- package/dist/storage/rehydrate.d.ts +0 -64
- package/dist/storage/rehydrate.d.ts.map +0 -1
- package/dist/storage/rehydrate.js +0 -132
- package/dist/storage/rehydrate.js.map +0 -1
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* The hydration MECHANISM: the per-collection re-hydrate hooks (decrypt the
|
|
6
|
-
* localStore rows into the app's stores) plus the debounced remote-change
|
|
7
|
-
* scheduler used by every sync entry point. Generic over an injected
|
|
8
|
-
* {@link StoreRegistry} -- the app supplies the concrete per-collection
|
|
9
|
-
* handlers; nothing here knows the domain entities.
|
|
10
|
-
*/
|
|
11
|
-
import type { Json } from '../sync/index.js';
|
|
12
|
-
import type { StoreRegistry } from '../config.js';
|
|
13
|
-
/**
|
|
14
|
-
* Hydrates every registered store from the (already opened) localStore.
|
|
15
|
-
*
|
|
16
|
-
* @param registry {StoreRegistry}
|
|
17
|
-
* @returns {Promise<void>}
|
|
18
|
-
*/
|
|
19
|
-
export declare function hydrateAll(registry: StoreRegistry): Promise<void>;
|
|
20
|
-
/**
|
|
21
|
-
* Empties every registered store (logout).
|
|
22
|
-
*
|
|
23
|
-
* @param registry {StoreRegistry}
|
|
24
|
-
* @returns {void}
|
|
25
|
-
*/
|
|
26
|
-
export declare function clearAllEntityStores(registry: StoreRegistry): void;
|
|
27
|
-
/**
|
|
28
|
-
* Patches ONE store from a single RxDB change event (per-doc, no whole-collection
|
|
29
|
-
* re-hydrate): decrypt the changed envelope, then upsert the payload (INSERT /
|
|
30
|
-
* UPDATE, including conflict-resolved rows) or drop it (DELETE / tombstone). The
|
|
31
|
-
* `uuid -> envelopeId` index is kept in step so a later local edit of a
|
|
32
|
-
* remotely-created doc still finds its envelope. Falls back to a debounced
|
|
33
|
-
* whole-collection re-hydrate if the envelope is missing or fails to decrypt.
|
|
34
|
-
*
|
|
35
|
-
* @param registry {StoreRegistry}
|
|
36
|
-
* @param collectionKey {string}
|
|
37
|
-
* @param event {object} an RxDB change event (operation + documentData)
|
|
38
|
-
* @returns {Promise<void>}
|
|
39
|
-
*/
|
|
40
|
-
export declare function patchFromChange(registry: StoreRegistry, collectionKey: string, event: {
|
|
41
|
-
operation: string;
|
|
42
|
-
documentData?: {
|
|
43
|
-
id: string;
|
|
44
|
-
data?: Json;
|
|
45
|
-
_deleted?: boolean;
|
|
46
|
-
};
|
|
47
|
-
}): Promise<void>;
|
|
48
|
-
/**
|
|
49
|
-
* Schedules a debounced re-hydrate of one collection's store after a pull.
|
|
50
|
-
*
|
|
51
|
-
* @param registry {StoreRegistry}
|
|
52
|
-
* @param collectionKey {string}
|
|
53
|
-
* @returns {void}
|
|
54
|
-
*/
|
|
55
|
-
export declare function scheduleRehydrate(registry: StoreRegistry, collectionKey: string): void;
|
|
56
|
-
/**
|
|
57
|
-
* Cancels every pending debounced re-hydrate. Called on logout so a timer that
|
|
58
|
-
* fires after the LocalStore is torn down does not reach a `requireStore()` that
|
|
59
|
-
* throws (an unhandled rejection).
|
|
60
|
-
*
|
|
61
|
-
* @returns {void}
|
|
62
|
-
*/
|
|
63
|
-
export declare function cancelScheduledRehydrates(): void;
|
|
64
|
-
//# sourceMappingURL=rehydrate.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rehydrate.d.ts","sourceRoot":"","sources":["../../src/storage/rehydrate.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAGjD;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAEvE;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI,CAIlE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,aAAa,EACvB,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE;IACL,SAAS,EAAE,MAAM,CAAA;IACjB,YAAY,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,IAAI,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,CAAA;CAC/D,GACA,OAAO,CAAC,IAAI,CAAC,CAsDf;AAOD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,aAAa,EACvB,aAAa,EAAE,MAAM,GACpB,IAAI,CAqBN;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,IAAI,IAAI,CAKhD"}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { hasStore, requireStore } from './storageManager.js';
|
|
2
|
-
/**
|
|
3
|
-
* Hydrates every registered store from the (already opened) localStore.
|
|
4
|
-
*
|
|
5
|
-
* @param registry {StoreRegistry}
|
|
6
|
-
* @returns {Promise<void>}
|
|
7
|
-
*/
|
|
8
|
-
export async function hydrateAll(registry) {
|
|
9
|
-
await Promise.all(Object.values(registry).map(entry => entry.hydrate()));
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Empties every registered store (logout).
|
|
13
|
-
*
|
|
14
|
-
* @param registry {StoreRegistry}
|
|
15
|
-
* @returns {void}
|
|
16
|
-
*/
|
|
17
|
-
export function clearAllEntityStores(registry) {
|
|
18
|
-
for (const entry of Object.values(registry)) {
|
|
19
|
-
entry.clear();
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Patches ONE store from a single RxDB change event (per-doc, no whole-collection
|
|
24
|
-
* re-hydrate): decrypt the changed envelope, then upsert the payload (INSERT /
|
|
25
|
-
* UPDATE, including conflict-resolved rows) or drop it (DELETE / tombstone). The
|
|
26
|
-
* `uuid -> envelopeId` index is kept in step so a later local edit of a
|
|
27
|
-
* remotely-created doc still finds its envelope. Falls back to a debounced
|
|
28
|
-
* whole-collection re-hydrate if the envelope is missing or fails to decrypt.
|
|
29
|
-
*
|
|
30
|
-
* @param registry {StoreRegistry}
|
|
31
|
-
* @param collectionKey {string}
|
|
32
|
-
* @param event {object} an RxDB change event (operation + documentData)
|
|
33
|
-
* @returns {Promise<void>}
|
|
34
|
-
*/
|
|
35
|
-
export async function patchFromChange(registry, collectionKey, event) {
|
|
36
|
-
const entry = registry[collectionKey];
|
|
37
|
-
if (!entry) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
const row = event.documentData;
|
|
41
|
-
const envelope = row?.data;
|
|
42
|
-
const deleted = event.operation === 'DELETE' || row?._deleted === true;
|
|
43
|
-
if (!row || envelope === undefined) {
|
|
44
|
-
scheduleRehydrate(registry, collectionKey);
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
// Capture the store BEFORE the decrypt await. This patch is fired floating
|
|
48
|
-
// off the RxDB change stream, so a logout/login teardown can clear or SWAP
|
|
49
|
-
// the process-wide holder while the decrypt is in flight; re-resolving the
|
|
50
|
-
// holder after the await would either throw (an unhandled rejection) or --
|
|
51
|
-
// worse -- write the previous session's payload and envelope id into the
|
|
52
|
-
// NEW session's replica. The captured store plus the identity re-check
|
|
53
|
-
// below makes a patch that outlives its store a silent no-op.
|
|
54
|
-
if (!hasStore()) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const store = requireStore();
|
|
58
|
-
let payload;
|
|
59
|
-
try {
|
|
60
|
-
payload = await store.decryptEnvelope(collectionKey, envelope);
|
|
61
|
-
}
|
|
62
|
-
catch {
|
|
63
|
-
scheduleRehydrate(registry, collectionKey);
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
// Bail if the holder changed or closed across the await: this event belongs
|
|
67
|
-
// to the torn-down session, not the one now live.
|
|
68
|
-
if (!hasStore() || requireStore() !== store) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
if (deleted) {
|
|
72
|
-
// Only honor a tombstone for the envelope the entity currently lives in.
|
|
73
|
-
// A delete of a DIFFERENT envelope that decrypts to the same logical id is
|
|
74
|
-
// a stale duplicate being cleaned up (a reconciled singleton loser, or the
|
|
75
|
-
// pre-resurrection row of a locally re-created doc) -- dropping the live
|
|
76
|
-
// doc for it would undo the reconciliation/resurrection.
|
|
77
|
-
const mapped = store.envelopeIdFor(collectionKey, payload.id);
|
|
78
|
-
if (mapped !== undefined && mapped !== row.id) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
store.forgetEnvelope(collectionKey, payload.id);
|
|
82
|
-
entry.drop(payload.id);
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
store.rememberEnvelope(collectionKey, payload.id, row.id);
|
|
86
|
-
entry.upsert(payload);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Per-collection debounce timers coalescing a pull burst into one hydrate.
|
|
91
|
-
*/
|
|
92
|
-
const rehydrateTimers = new Map();
|
|
93
|
-
/**
|
|
94
|
-
* Schedules a debounced re-hydrate of one collection's store after a pull.
|
|
95
|
-
*
|
|
96
|
-
* @param registry {StoreRegistry}
|
|
97
|
-
* @param collectionKey {string}
|
|
98
|
-
* @returns {void}
|
|
99
|
-
*/
|
|
100
|
-
export function scheduleRehydrate(registry, collectionKey) {
|
|
101
|
-
const entry = registry[collectionKey];
|
|
102
|
-
if (!entry) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
const existing = rehydrateTimers.get(collectionKey);
|
|
106
|
-
if (existing) {
|
|
107
|
-
clearTimeout(existing);
|
|
108
|
-
}
|
|
109
|
-
rehydrateTimers.set(collectionKey, setTimeout(() => {
|
|
110
|
-
rehydrateTimers.delete(collectionKey);
|
|
111
|
-
// A timer that outlived logout must not touch a torn-down store: hydrate
|
|
112
|
-
// reaches for `requireStore()`, which throws once the store is cleared.
|
|
113
|
-
if (!hasStore()) {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
void entry.hydrate();
|
|
117
|
-
}, 50));
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Cancels every pending debounced re-hydrate. Called on logout so a timer that
|
|
121
|
-
* fires after the LocalStore is torn down does not reach a `requireStore()` that
|
|
122
|
-
* throws (an unhandled rejection).
|
|
123
|
-
*
|
|
124
|
-
* @returns {void}
|
|
125
|
-
*/
|
|
126
|
-
export function cancelScheduledRehydrates() {
|
|
127
|
-
for (const timer of rehydrateTimers.values()) {
|
|
128
|
-
clearTimeout(timer);
|
|
129
|
-
}
|
|
130
|
-
rehydrateTimers.clear();
|
|
131
|
-
}
|
|
132
|
-
//# sourceMappingURL=rehydrate.js.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