@interop/was-react 0.8.2 → 0.9.0
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 +55 -44
- package/dist/auth/chapi.d.ts.map +1 -1
- package/dist/auth/chapi.js +16 -5
- package/dist/auth/chapi.js.map +1 -1
- package/dist/auth/loginFlow.d.ts.map +1 -1
- package/dist/auth/loginFlow.js +55 -49
- package/dist/auth/loginFlow.js.map +1 -1
- package/dist/auth/verifyResponse.d.ts.map +1 -1
- package/dist/auth/verifyResponse.js +27 -10
- package/dist/auth/verifyResponse.js.map +1 -1
- package/dist/auth/walletRequestTypes.d.ts +9 -90
- package/dist/auth/walletRequestTypes.d.ts.map +1 -1
- package/dist/config.d.ts +9 -9
- package/dist/config.js +0 -0
- package/dist/dev/provisionDevGrants.d.ts.map +1 -1
- package/dist/dev/provisionDevGrants.js +18 -19
- package/dist/dev/provisionDevGrants.js.map +1 -1
- package/dist/grants.d.ts +19 -9
- package/dist/grants.d.ts.map +1 -1
- package/dist/grants.js +17 -2
- package/dist/grants.js.map +1 -1
- package/dist/identity/agents.d.ts +1 -1
- package/dist/identity/agents.d.ts.map +1 -1
- package/dist/identity/agents.js +10 -25
- package/dist/identity/agents.js.map +1 -1
- package/dist/identity/appSession.d.ts +27 -0
- package/dist/identity/appSession.d.ts.map +1 -1
- package/dist/identity/appSession.js +51 -13
- package/dist/identity/appSession.js.map +1 -1
- package/dist/identity/seedCredential.d.ts +7 -0
- package/dist/identity/seedCredential.d.ts.map +1 -1
- package/dist/identity/seedCredential.js +11 -14
- package/dist/identity/seedCredential.js.map +1 -1
- package/dist/identity/seedStore.d.ts +19 -0
- package/dist/identity/seedStore.d.ts.map +1 -1
- package/dist/identity/seedStore.js +40 -13
- package/dist/identity/seedStore.js.map +1 -1
- package/dist/index.d.ts +4 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/jsonLd.d.ts +19 -0
- package/dist/jsonLd.d.ts.map +1 -0
- package/dist/jsonLd.js +24 -0
- package/dist/jsonLd.js.map +1 -0
- package/dist/mui/AdoptDialog.d.ts.map +1 -1
- package/dist/mui/AdoptDialog.js +7 -3
- package/dist/mui/AdoptDialog.js.map +1 -1
- package/dist/mui/ClearDataDialog.d.ts.map +1 -1
- package/dist/mui/ClearDataDialog.js +12 -11
- package/dist/mui/ClearDataDialog.js.map +1 -1
- package/dist/mui/ConfirmDialog.d.ts +35 -0
- package/dist/mui/ConfirmDialog.d.ts.map +1 -0
- package/dist/mui/ConfirmDialog.js +18 -0
- package/dist/mui/ConfirmDialog.js.map +1 -0
- package/dist/mui/LogoutDialog.d.ts.map +1 -1
- package/dist/mui/LogoutDialog.js +7 -3
- package/dist/mui/LogoutDialog.js.map +1 -1
- package/dist/react/documentApp.d.ts +29 -0
- package/dist/react/documentApp.d.ts.map +1 -1
- package/dist/react/documentApp.js +9 -38
- package/dist/react/documentApp.js.map +1 -1
- package/dist/react/hooks.d.ts +13 -7
- package/dist/react/hooks.d.ts.map +1 -1
- package/dist/react/hooks.js +17 -11
- package/dist/react/hooks.js.map +1 -1
- package/dist/session/authStore.d.ts +9 -9
- package/dist/session/authStore.d.ts.map +1 -1
- package/dist/session/authStore.js +203 -112
- package/dist/session/authStore.js.map +1 -1
- package/dist/storage/adopt.d.ts +5 -1
- package/dist/storage/adopt.d.ts.map +1 -1
- package/dist/storage/adopt.js +8 -24
- package/dist/storage/adopt.js.map +1 -1
- package/dist/storage/entityStore.d.ts.map +1 -1
- package/dist/storage/entityStore.js +27 -20
- package/dist/storage/entityStore.js.map +1 -1
- package/dist/storage/localStore.d.ts +12 -6
- package/dist/storage/localStore.d.ts.map +1 -1
- package/dist/storage/localStore.js +146 -77
- package/dist/storage/localStore.js.map +1 -1
- package/dist/storage/rehydrate.d.ts.map +1 -1
- package/dist/storage/rehydrate.js +20 -4
- package/dist/storage/rehydrate.js.map +1 -1
- package/dist/storage/sharedCollectionReader.d.ts +1 -1
- package/dist/storage/sharedCollectionReader.d.ts.map +1 -1
- package/dist/storage/sharedCollectionReader.js +79 -64
- package/dist/storage/sharedCollectionReader.js.map +1 -1
- package/dist/storage/storageManager.d.ts +3 -1
- package/dist/storage/storageManager.d.ts.map +1 -1
- package/dist/storage/storageManager.js +20 -6
- package/dist/storage/storageManager.js.map +1 -1
- package/dist/storage/syncController.d.ts +1 -16
- package/dist/storage/syncController.d.ts.map +1 -1
- package/dist/storage/syncController.js +48 -37
- package/dist/storage/syncController.js.map +1 -1
- package/dist/storage/syncStatusStore.d.ts +8 -6
- package/dist/storage/syncStatusStore.d.ts.map +1 -1
- package/dist/storage/syncStatusStore.js +6 -6
- package/dist/storage/syncStatusStore.js.map +1 -1
- package/dist/storage/wasRemoteStore.d.ts +34 -2
- package/dist/storage/wasRemoteStore.d.ts.map +1 -1
- package/dist/storage/wasRemoteStore.js +45 -7
- package/dist/storage/wasRemoteStore.js.map +1 -1
- package/dist/storage/wasSync.d.ts.map +1 -1
- package/dist/storage/wasSync.js +47 -38
- package/dist/storage/wasSync.js.map +1 -1
- package/dist/sync/changesQuery.d.ts.map +1 -1
- package/dist/sync/changesQuery.js +2 -9
- package/dist/sync/changesQuery.js.map +1 -1
- package/dist/sync/docCipher.d.ts +23 -10
- package/dist/sync/docCipher.d.ts.map +1 -1
- package/dist/sync/docCipher.js +17 -11
- package/dist/sync/docCipher.js.map +1 -1
- package/dist/sync/feedMasterPort.d.ts +6 -0
- package/dist/sync/feedMasterPort.d.ts.map +1 -1
- package/dist/sync/feedMasterPort.js +82 -37
- package/dist/sync/feedMasterPort.js.map +1 -1
- package/dist/sync/index.d.ts +6 -5
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +6 -3
- package/dist/sync/index.js.map +1 -1
- package/dist/sync/lww.d.ts +27 -18
- package/dist/sync/lww.d.ts.map +1 -1
- package/dist/sync/lww.js +35 -8
- package/dist/sync/lww.js.map +1 -1
- package/dist/sync/lwwConflictHandler.d.ts +15 -14
- package/dist/sync/lwwConflictHandler.d.ts.map +1 -1
- package/dist/sync/lwwConflictHandler.js +37 -26
- package/dist/sync/lwwConflictHandler.js.map +1 -1
- package/dist/sync/pushWrites.d.ts +9 -9
- package/dist/sync/pushWrites.d.ts.map +1 -1
- package/dist/sync/pushWrites.js +102 -68
- package/dist/sync/pushWrites.js.map +1 -1
- package/dist/sync/syncedDocSchema.d.ts.map +1 -1
- package/dist/sync/syncedDocSchema.js +3 -0
- package/dist/sync/syncedDocSchema.js.map +1 -1
- package/dist/sync/types.d.ts +115 -15
- package/dist/sync/types.d.ts.map +1 -1
- package/dist/sync/types.js +36 -18
- package/dist/sync/types.js.map +1 -1
- package/dist/sync/wasSyncPort.d.ts +0 -11
- package/dist/sync/wasSyncPort.d.ts.map +1 -1
- package/dist/sync/wasSyncPort.js +20 -36
- package/dist/sync/wasSyncPort.js.map +1 -1
- package/package.json +6 -6
- package/dist/identity/initAppSession.d.ts +0 -27
- package/dist/identity/initAppSession.d.ts.map +0 -1
- package/dist/identity/initAppSession.js +0 -30
- package/dist/identity/initAppSession.js.map +0 -1
|
@@ -34,8 +34,9 @@
|
|
|
34
34
|
* expected, not corruption -- they are skipped with a warning.
|
|
35
35
|
*/
|
|
36
36
|
import { NotImplementedError } from '@interop/was-client';
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
37
|
+
import { createRefreshingEdvDocCipher } from '@interop/wallet-core/descriptors';
|
|
38
|
+
import { errorMessage, isEncryptedEnvelope } from '../sync/index.js';
|
|
39
|
+
import { remoteDescriptorSource } from './wasRemoteStore.js';
|
|
39
40
|
/**
|
|
40
41
|
* Default page size for the `changes`-feed walk. The server clamps its own
|
|
41
42
|
* maximum, and a page shorter than what was asked for is the feed's end-of-walk
|
|
@@ -58,23 +59,22 @@ export class SharedCollectionUnavailableError extends Error {
|
|
|
58
59
|
export class SharedCollectionReader {
|
|
59
60
|
collectionId;
|
|
60
61
|
#remoteStore;
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
// Self-refreshing: it acquires the collection's descriptor when it is built
|
|
63
|
+
// and, on a decrypt that meets an unknown key epoch, re-reads the descriptor,
|
|
64
|
+
// swaps itself, and retries that decrypt -- exactly once per reader. An epoch
|
|
65
|
+
// rotation emits no change-feed entry, so a stale descriptor is the expected
|
|
66
|
+
// failure mode; one refresh per reader is enough to recover, and the cap keeps
|
|
67
|
+
// a genuinely undecryptable envelope from looping. The refresh is memoized as
|
|
68
|
+
// a PROMISE upstream, so bodies decrypting concurrently share the single
|
|
69
|
+
// re-read instead of racing it.
|
|
63
70
|
#cipher;
|
|
64
|
-
// Whether an unknown-epoch descriptor refresh has already run for this reader. An
|
|
65
|
-
// epoch rotation emits no change-feed entry, so a stale descriptor is the
|
|
66
|
-
// expected failure mode; one refresh per reader is enough to recover, and the
|
|
67
|
-
// cap keeps a genuinely undecryptable envelope from looping.
|
|
68
|
-
#refreshed = false;
|
|
69
71
|
// Whether the one-time "reading this collection the slow way" warning has
|
|
70
72
|
// already been emitted for this reader.
|
|
71
73
|
#warnedSlowPath = false;
|
|
72
74
|
#pageSize;
|
|
73
|
-
constructor({ collectionId, remoteStore,
|
|
75
|
+
constructor({ collectionId, remoteStore, cipher, pageSize }) {
|
|
74
76
|
this.collectionId = collectionId;
|
|
75
77
|
this.#remoteStore = remoteStore;
|
|
76
|
-
this.#keyAgreementKey = keyAgreementKey;
|
|
77
|
-
this.#keyResolver = keyResolver;
|
|
78
78
|
this.#cipher = cipher;
|
|
79
79
|
this.#pageSize = pageSize;
|
|
80
80
|
}
|
|
@@ -97,18 +97,16 @@ export class SharedCollectionReader {
|
|
|
97
97
|
* @returns {Promise<SharedCollectionReader>}
|
|
98
98
|
*/
|
|
99
99
|
static async open({ remoteStore, keyAgreementKey, keyResolver, collectionId, pageSize = SHARED_CHANGES_PAGE_SIZE }) {
|
|
100
|
-
const encryption = await remoteStore.readCollectionEncryption(collectionId);
|
|
101
100
|
const cipher = await buildSharedCipher({
|
|
102
101
|
collectionId,
|
|
103
102
|
keyAgreementKey,
|
|
104
103
|
keyResolver,
|
|
105
|
-
|
|
104
|
+
source: remoteDescriptorSource({ remoteStore }),
|
|
105
|
+
cache: memoryDescriptorCache()
|
|
106
106
|
});
|
|
107
107
|
return new SharedCollectionReader({
|
|
108
108
|
collectionId,
|
|
109
109
|
remoteStore,
|
|
110
|
-
keyAgreementKey,
|
|
111
|
-
keyResolver,
|
|
112
110
|
cipher,
|
|
113
111
|
pageSize
|
|
114
112
|
});
|
|
@@ -183,14 +181,14 @@ export class SharedCollectionReader {
|
|
|
183
181
|
}
|
|
184
182
|
checkpoint = page.checkpoint;
|
|
185
183
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
return
|
|
184
|
+
// Decrypt the collected bodies concurrently: each is an independent unwrap
|
|
185
|
+
// with no ordering dependency, so serializing the per-body WebCrypto work
|
|
186
|
+
// would only add latency to the read.
|
|
187
|
+
const decrypted = await Promise.all([...bodies].map(async ([id, body]) => {
|
|
188
|
+
const data = await this.#decryptBody({ id, body: body ?? null });
|
|
189
|
+
return data === undefined ? null : { id, data };
|
|
190
|
+
}));
|
|
191
|
+
return decrypted.filter(resource => resource !== null);
|
|
194
192
|
}
|
|
195
193
|
/**
|
|
196
194
|
* The slow path: one listing request for the resource summaries, then one
|
|
@@ -241,9 +239,16 @@ export class SharedCollectionReader {
|
|
|
241
239
|
/**
|
|
242
240
|
* Decrypts one fetched body, tolerating the two expected non-results: a body
|
|
243
241
|
* that is not an EDV envelope at all, and a pre-share single-recipient
|
|
244
|
-
* envelope.
|
|
245
|
-
*
|
|
246
|
-
*
|
|
242
|
+
* envelope.
|
|
243
|
+
*
|
|
244
|
+
* The unknown-epoch recovery lives INSIDE the cipher (it re-reads the
|
|
245
|
+
* descriptor, swaps itself, and retries once per reader), so what reaches
|
|
246
|
+
* this catch is a decrypt that stayed unreadable after the reader spent its
|
|
247
|
+
* one refresh -- or one that raised an unknown epoch when the refresh was
|
|
248
|
+
* already spent. Either way it is a body this app cannot read, and the
|
|
249
|
+
* reader's contract is to warn and skip it, never to fail the listing: a
|
|
250
|
+
* mid-session revoke (the refreshed roster no longer lists this app) degrades
|
|
251
|
+
* to the subset that still decrypts.
|
|
247
252
|
*/
|
|
248
253
|
async #decryptBody({ id, body }) {
|
|
249
254
|
if (body === null || body === undefined) {
|
|
@@ -258,32 +263,9 @@ export class SharedCollectionReader {
|
|
|
258
263
|
return await this.#cipher.decrypt({ envelope: body });
|
|
259
264
|
}
|
|
260
265
|
catch (err) {
|
|
261
|
-
if (err instanceof UnknownEpochError && !this.#refreshed) {
|
|
262
|
-
this.#refreshed = true;
|
|
263
|
-
await this.#rebuildCipher();
|
|
264
|
-
try {
|
|
265
|
-
return await this.#cipher.decrypt({ envelope: body });
|
|
266
|
-
}
|
|
267
|
-
catch (retryErr) {
|
|
268
|
-
return this.#skipUndecryptable({ id, err: retryErr });
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
266
|
return this.#skipUndecryptable({ id, err });
|
|
272
267
|
}
|
|
273
268
|
}
|
|
274
|
-
/**
|
|
275
|
-
* Re-reads the collection's `encryption` descriptor and rebuilds the cipher from
|
|
276
|
-
* it. Used once per reader on an unknown epoch.
|
|
277
|
-
*/
|
|
278
|
-
async #rebuildCipher() {
|
|
279
|
-
const encryption = await this.#remoteStore.readCollectionEncryption(this.collectionId);
|
|
280
|
-
this.#cipher = await buildSharedCipher({
|
|
281
|
-
collectionId: this.collectionId,
|
|
282
|
-
keyAgreementKey: this.#keyAgreementKey,
|
|
283
|
-
keyResolver: this.#keyResolver,
|
|
284
|
-
encryption
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
269
|
/**
|
|
288
270
|
* Warns about, and skips, one envelope this app cannot decrypt. The
|
|
289
271
|
* overwhelmingly likely cause is a resource written BEFORE the collection's
|
|
@@ -300,33 +282,59 @@ export class SharedCollectionReader {
|
|
|
300
282
|
}
|
|
301
283
|
}
|
|
302
284
|
/**
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
*
|
|
285
|
+
* The reader's descriptor cache: a plain in-memory Map, one per reader. Nothing
|
|
286
|
+
* about a WALLET-owned collection belongs in this app's offline descriptor
|
|
287
|
+
* cache (that one is keyed by the app's own collection ids and survives a
|
|
288
|
+
* reload); here the cache exists only so the self-refreshing cipher has the
|
|
289
|
+
* durable seam it is written against, and so the descriptor it acquired at open
|
|
290
|
+
* can be inspected afterwards.
|
|
291
|
+
*
|
|
292
|
+
* @returns {EncryptionDescriptorCache}
|
|
293
|
+
*/
|
|
294
|
+
function memoryDescriptorCache() {
|
|
295
|
+
const descriptors = new Map();
|
|
296
|
+
return {
|
|
297
|
+
async readDescriptor({ collectionId }) {
|
|
298
|
+
return descriptors.get(collectionId);
|
|
299
|
+
},
|
|
300
|
+
async writeDescriptor({ collectionId, descriptor }) {
|
|
301
|
+
descriptors.set(collectionId, descriptor);
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Builds the self-refreshing epoch-aware cipher for a shared collection,
|
|
307
|
+
* turning the two "cannot read this collection" outcomes into one descriptive
|
|
308
|
+
* error: no multi-recipient roster at all, and a roster this app is not in.
|
|
309
|
+
*
|
|
310
|
+
* The build is the reader's ONE descriptor read at open (`acquireDescriptor`
|
|
311
|
+
* fetches through `source` and caches the result), so the roster check below
|
|
312
|
+
* reads the cache rather than fetching a second time. A descriptor with no
|
|
313
|
+
* epochs builds a single-key cipher rather than throwing, which is why the
|
|
314
|
+
* no-roster case is detected after the build and not before it.
|
|
306
315
|
*
|
|
307
316
|
* Only the cipher's `decrypt` is ever exercised here -- the reader has no write
|
|
308
|
-
* path -- so the seam's write-side id model is irrelevant
|
|
317
|
+
* path -- so the seam's write-side id model is irrelevant and left at its
|
|
318
|
+
* default.
|
|
309
319
|
*
|
|
310
320
|
* @param options {object}
|
|
311
321
|
* @param options.collectionId {string}
|
|
312
322
|
* @param options.keyAgreementKey {IKeyAgreementKey}
|
|
313
323
|
* @param options.keyResolver {IKeyResolver}
|
|
314
|
-
* @param
|
|
324
|
+
* @param options.source {EncryptionDescriptorSource}
|
|
325
|
+
* @param options.cache {EncryptionDescriptorCache}
|
|
315
326
|
* @returns {Promise<DocCipher>}
|
|
316
327
|
*/
|
|
317
|
-
async function buildSharedCipher({ collectionId, keyAgreementKey, keyResolver,
|
|
318
|
-
|
|
319
|
-
throw new SharedCollectionUnavailableError(`Shared collection "${collectionId}" carries no key-epoch roster, so it ` +
|
|
320
|
-
`is not multi-recipient and this app cannot be a recipient of it. The ` +
|
|
321
|
-
`wallet has not shared it with this app.`);
|
|
322
|
-
}
|
|
328
|
+
async function buildSharedCipher({ collectionId, keyAgreementKey, keyResolver, source, cache }) {
|
|
329
|
+
let cipher;
|
|
323
330
|
try {
|
|
324
|
-
|
|
331
|
+
cipher = (await createRefreshingEdvDocCipher({
|
|
325
332
|
keyAgreementKey,
|
|
326
333
|
keyResolver,
|
|
327
334
|
collectionId,
|
|
328
|
-
|
|
329
|
-
|
|
335
|
+
source,
|
|
336
|
+
cache
|
|
337
|
+
}));
|
|
330
338
|
}
|
|
331
339
|
catch (err) {
|
|
332
340
|
throw new SharedCollectionUnavailableError(`Cannot read shared collection "${collectionId}": this app is not a ` +
|
|
@@ -334,5 +342,12 @@ async function buildSharedCipher({ collectionId, keyAgreementKey, keyResolver, e
|
|
|
334
342
|
`with this app, or access was removed (removing access rotates the ` +
|
|
335
343
|
`epoch off this app's key).`, { cause: err });
|
|
336
344
|
}
|
|
345
|
+
const encryption = await cache.readDescriptor({ collectionId });
|
|
346
|
+
if (!encryption?.epochs || encryption.epochs.length === 0) {
|
|
347
|
+
throw new SharedCollectionUnavailableError(`Shared collection "${collectionId}" carries no key-epoch roster, so it ` +
|
|
348
|
+
`is not multi-recipient and this app cannot be a recipient of it. The ` +
|
|
349
|
+
`wallet has not shared it with this app.`);
|
|
350
|
+
}
|
|
351
|
+
return cipher;
|
|
337
352
|
}
|
|
338
353
|
//# sourceMappingURL=sharedCollectionReader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedCollectionReader.js","sourceRoot":"","sources":["../../src/storage/sharedCollectionReader.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAMzD,OAAO,
|
|
1
|
+
{"version":3,"file":"sharedCollectionReader.js","sourceRoot":"","sources":["../../src/storage/sharedCollectionReader.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAMzD,OAAO,EACL,4BAA4B,EAG7B,MAAM,kCAAkC,CAAA;AACzC,OAAO,EACL,YAAY,EACZ,mBAAmB,EAGpB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACL,sBAAsB,EAEvB,MAAM,qBAAqB,CAAA;AAE5B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAA;AAmB3C;;;;;GAKG;AACH,MAAM,OAAO,gCAAiC,SAAQ,KAAK;IACzD,YAAY,OAAe,EAAE,OAA6B;QACxD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QACvB,IAAI,CAAC,IAAI,GAAG,kCAAkC,CAAA;IAChD,CAAC;CACF;AAED,MAAM,OAAO,sBAAsB;IACxB,YAAY,CAAQ;IACpB,YAAY,CAAgB;IACrC,4EAA4E;IAC5E,8EAA8E;IAC9E,8EAA8E;IAC9E,6EAA6E;IAC7E,+EAA+E;IAC/E,8EAA8E;IAC9E,yEAAyE;IACzE,gCAAgC;IACvB,OAAO,CAAW;IAC3B,0EAA0E;IAC1E,wCAAwC;IACxC,eAAe,GAAG,KAAK,CAAA;IACd,SAAS,C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vE,yCAAyC,CAC5C,CAAA;IACH,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -54,7 +54,9 @@ export declare function hasRemoteStore(): boolean;
|
|
|
54
54
|
export declare function clearRemoteStore(): void;
|
|
55
55
|
/**
|
|
56
56
|
* A stable per-install client id (the last-write-wins tiebreak stamped into
|
|
57
|
-
* every payload), persisted in localStorage under `<prefix>clientId`.
|
|
57
|
+
* every payload), persisted in localStorage under `<prefix>clientId`. In an
|
|
58
|
+
* environment without `localStorage` it falls back to a process-stable
|
|
59
|
+
* unpersisted id instead of throwing.
|
|
58
60
|
*
|
|
59
61
|
* @param [options] {object}
|
|
60
62
|
* @param [options.storageKeyPrefix] {string} the localStorage key prefix
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storageManager.d.ts","sourceRoot":"","sources":["../../src/storage/storageManager.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAKzD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAErD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,UAAU,CAKzC;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,IAAI,OAAO,CAElC;AAED;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,IAAI,CAEtC;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,CAE1D;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,IAAI,cAAc,CAOnD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAExC;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC;
|
|
1
|
+
{"version":3,"file":"storageManager.d.ts","sourceRoot":"","sources":["../../src/storage/storageManager.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAKzD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAErD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,UAAU,CAKzC;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,IAAI,OAAO,CAElC;AAED;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,IAAI,CAEtC;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,CAE1D;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,IAAI,cAAc,CAOnD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAExC;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC;AASD;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,EAC1B,gBAA6C,EAC9C,GAAE;IAAE,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,MAAM,CAa7C"}
|
|
@@ -87,9 +87,17 @@ export function hasRemoteStore() {
|
|
|
87
87
|
export function clearRemoteStore() {
|
|
88
88
|
remoteStore = null;
|
|
89
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* The unpersisted fallback client id for environments without `localStorage`
|
|
92
|
+
* (tests, SSR): process-stable, so every stamp within one run agrees, minted
|
|
93
|
+
* fresh on the next run.
|
|
94
|
+
*/
|
|
95
|
+
let fallbackClientId = null;
|
|
90
96
|
/**
|
|
91
97
|
* A stable per-install client id (the last-write-wins tiebreak stamped into
|
|
92
|
-
* every payload), persisted in localStorage under `<prefix>clientId`.
|
|
98
|
+
* every payload), persisted in localStorage under `<prefix>clientId`. In an
|
|
99
|
+
* environment without `localStorage` it falls back to a process-stable
|
|
100
|
+
* unpersisted id instead of throwing.
|
|
93
101
|
*
|
|
94
102
|
* @param [options] {object}
|
|
95
103
|
* @param [options.storageKeyPrefix] {string} the localStorage key prefix
|
|
@@ -98,11 +106,17 @@ export function clearRemoteStore() {
|
|
|
98
106
|
*/
|
|
99
107
|
export function getClientId({ storageKeyPrefix = DEFAULT_STORAGE_KEY_PREFIX } = {}) {
|
|
100
108
|
const clientIdKey = `${storageKeyPrefix}clientId`;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
109
|
+
try {
|
|
110
|
+
let id = localStorage.getItem(clientIdKey);
|
|
111
|
+
if (!id) {
|
|
112
|
+
id = uuidv7();
|
|
113
|
+
localStorage.setItem(clientIdKey, id);
|
|
114
|
+
}
|
|
115
|
+
return id;
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
fallbackClientId ??= uuidv7();
|
|
119
|
+
return fallbackClientId;
|
|
105
120
|
}
|
|
106
|
-
return id;
|
|
107
121
|
}
|
|
108
122
|
//# sourceMappingURL=storageManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storageManager.js","sourceRoot":"","sources":["../../src/storage/storageManager.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;GAOG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAA;AAIzD,IAAI,UAAU,GAAsB,IAAI,CAAA;AACxC,IAAI,WAAW,GAA0B,IAAI,CAAA;AAE7C;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,KAAiB;IAC7C,UAAU,GAAG,KAAK,CAAA;AACpB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY;IAC1B,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAA;IAClE,CAAC;IACD,OAAO,UAAU,CAAA;AACnB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,QAAQ;IACtB,OAAO,UAAU,KAAK,IAAI,CAAA;AAC5B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe;IAC7B,UAAU,GAAG,IAAI,CAAA;AACnB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,KAAqB;IAClD,WAAW,GAAG,KAAK,CAAA;AACrB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB;IAChC,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CACb,mEAAmE,CACpE,CAAA;IACH,CAAC;IACD,OAAO,WAAW,CAAA;AACpB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO,WAAW,KAAK,IAAI,CAAA;AAC7B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB;IAC9B,WAAW,GAAG,IAAI,CAAA;AACpB,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"storageManager.js","sourceRoot":"","sources":["../../src/storage/storageManager.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;GAOG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAA;AAIzD,IAAI,UAAU,GAAsB,IAAI,CAAA;AACxC,IAAI,WAAW,GAA0B,IAAI,CAAA;AAE7C;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,KAAiB;IAC7C,UAAU,GAAG,KAAK,CAAA;AACpB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY;IAC1B,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAA;IAClE,CAAC;IACD,OAAO,UAAU,CAAA;AACnB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,QAAQ;IACtB,OAAO,UAAU,KAAK,IAAI,CAAA;AAC5B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe;IAC7B,UAAU,GAAG,IAAI,CAAA;AACnB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,KAAqB;IAClD,WAAW,GAAG,KAAK,CAAA;AACrB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB;IAChC,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CACb,mEAAmE,CACpE,CAAA;IACH,CAAC;IACD,OAAO,WAAW,CAAA;AACpB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO,WAAW,KAAK,IAAI,CAAA;AAC7B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB;IAC9B,WAAW,GAAG,IAAI,CAAA;AACpB,CAAC;AAED;;;;GAIG;AACH,IAAI,gBAAgB,GAAkB,IAAI,CAAA;AAE1C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CAAC,EAC1B,gBAAgB,GAAG,0BAA0B,KACZ,EAAE;IACnC,MAAM,WAAW,GAAG,GAAG,gBAAgB,UAAU,CAAA;IACjD,IAAI,CAAC;QACH,IAAI,EAAE,GAAG,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;QAC1C,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,EAAE,GAAG,MAAM,EAAE,CAAA;YACb,YAAY,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;QACvC,CAAC;QACD,OAAO,EAAE,CAAA;IACX,CAAC;IAAC,MAAM,CAAC;QACP,gBAAgB,KAAK,MAAM,EAAE,CAAA;QAC7B,OAAO,gBAAgB,CAAA;IACzB,CAAC;AACH,CAAC"}
|
|
@@ -20,8 +20,7 @@ import type { WasRemoteStore } from './wasRemoteStore.js';
|
|
|
20
20
|
*/
|
|
21
21
|
export declare function isAuthError(err: unknown): boolean;
|
|
22
22
|
/**
|
|
23
|
-
* A per-session controller around background replication.
|
|
24
|
-
* {@link createSyncController}.
|
|
23
|
+
* A per-session controller around background replication.
|
|
25
24
|
*/
|
|
26
25
|
export declare class SyncController {
|
|
27
26
|
#private;
|
|
@@ -64,18 +63,4 @@ export declare class SyncController {
|
|
|
64
63
|
*/
|
|
65
64
|
stop(): Promise<void>;
|
|
66
65
|
}
|
|
67
|
-
/**
|
|
68
|
-
* Builds a fresh {@link SyncController} bound to the collection registry and
|
|
69
|
-
* sync tuning. Prefer one controller per session (started once, stopped on
|
|
70
|
-
* logout) over a module-level singleton.
|
|
71
|
-
*
|
|
72
|
-
* @param options {object}
|
|
73
|
-
* @param options.collections {WasCollectionConfig[]}
|
|
74
|
-
* @param [options.sync] {WasSyncConfig}
|
|
75
|
-
* @returns {SyncController}
|
|
76
|
-
*/
|
|
77
|
-
export declare function createSyncController({ collections, sync }: {
|
|
78
|
-
collections: WasCollectionConfig[];
|
|
79
|
-
sync?: WasSyncConfig;
|
|
80
|
-
}): SyncController;
|
|
81
66
|
//# sourceMappingURL=syncController.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syncController.d.ts","sourceRoot":"","sources":["../../src/storage/syncController.ts"],"names":[],"mappings":"AA+BA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAML,KAAK,SAAS,EACf,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,aAAa,EACnB,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAQzD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CA+BjD;
|
|
1
|
+
{"version":3,"file":"syncController.d.ts","sourceRoot":"","sources":["../../src/storage/syncController.ts"],"names":[],"mappings":"AA+BA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAML,KAAK,SAAS,EACf,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,aAAa,EACnB,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAQzD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CA+BjD;AAED;;GAEG;AACH,qBAAa,cAAc;;gBAYb,EACV,WAAW,EACX,IAAI,EACL,EAAE;QACD,WAAW,EAAE,mBAAmB,EAAE,CAAA;QAClC,IAAI,CAAC,EAAE,aAAa,CAAA;KACrB;IAKD;;;;;;;;;;;;;OAaG;IACG,KAAK,CAAC,EACV,WAAW,EACX,UAAU,EACV,cAAc,EACd,WAAW,EACZ,EAAE;QACD,WAAW,EAAE,cAAc,CAAA;QAC3B,UAAU,EAAE,UAAU,CAAA;QACtB,cAAc,CAAC,EAAE,CACf,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,aAAa,CAAC,SAAS,CAAC,KAC5B,IAAI,CAAA;QACT,WAAW,CAAC,EAAE,MAAM,IAAI,CAAA;KACzB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgIjB;;;;;OAKG;IACH,MAAM,IAAI,IAAI;IAMd;;;;;OAKG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAQ5B"}
|
|
@@ -43,8 +43,7 @@ export function isAuthError(err) {
|
|
|
43
43
|
return false;
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
|
-
* A per-session controller around background replication.
|
|
47
|
-
* {@link createSyncController}.
|
|
46
|
+
* A per-session controller around background replication.
|
|
48
47
|
*/
|
|
49
48
|
export class SyncController {
|
|
50
49
|
#collections;
|
|
@@ -93,10 +92,10 @@ export class SyncController {
|
|
|
93
92
|
// uncovered collection never masquerades as expired access.
|
|
94
93
|
if (!capability) {
|
|
95
94
|
console.warn(`Skipping sync for "${id}": no delegated capability covers it.`);
|
|
96
|
-
setStatus(
|
|
95
|
+
setStatus(key, 'error');
|
|
97
96
|
continue;
|
|
98
97
|
}
|
|
99
|
-
setStatus(
|
|
98
|
+
setStatus(key, 'idle');
|
|
100
99
|
// Wrap the verbatim port so the 412 conflict re-read resolves `version`
|
|
101
100
|
// from the changes-feed body (CORS hides the `GET` ETag cross-origin).
|
|
102
101
|
const wasPort = withFeedMasterRead(createWasSyncPort({
|
|
@@ -114,11 +113,11 @@ export class SyncController {
|
|
|
114
113
|
});
|
|
115
114
|
const subscriptions = [
|
|
116
115
|
state.active$.subscribe(active => {
|
|
117
|
-
setStatus(
|
|
116
|
+
setStatus(key, active ? 'syncing' : 'synced');
|
|
118
117
|
}),
|
|
119
118
|
state.error$.subscribe(err => {
|
|
120
119
|
console.error(`Sync error for "${id}":`, err);
|
|
121
|
-
setStatus(
|
|
120
|
+
setStatus(key, 'error');
|
|
122
121
|
if (onAuthError && isAuthError(err)) {
|
|
123
122
|
onAuthError();
|
|
124
123
|
}
|
|
@@ -143,30 +142,32 @@ export class SyncController {
|
|
|
143
142
|
}
|
|
144
143
|
catch (err) {
|
|
145
144
|
console.error('Failed to start sync controller:', err);
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
145
|
+
// Unwind the partial bring-up WITHOUT `stop()`: its terminal `#stopped`
|
|
146
|
+
// latch would permanently prevent a later `start()` on this session, and
|
|
147
|
+
// its status reset would leave the rollup reporting "Local only" over a
|
|
148
|
+
// wallet-connected session that failed to start replicating. Instead the
|
|
149
|
+
// per-collection statuses are left at `error` (visible in the rollup)
|
|
150
|
+
// and the error RETHROWS so the caller's bootstrap promise rejects and
|
|
151
|
+
// the session can surface it.
|
|
152
|
+
await this.#teardownReplications();
|
|
153
|
+
this.#started = false;
|
|
154
|
+
for (const { key } of this.#collections) {
|
|
155
|
+
setStatus(key, 'error');
|
|
156
|
+
}
|
|
157
|
+
throw err;
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
/**
|
|
161
|
-
*
|
|
162
|
-
*
|
|
161
|
+
* The shared release path behind the failed-bring-up unwind and {@link stop}:
|
|
162
|
+
* drops the `online` listener, clears the poll timer, unsubscribes every
|
|
163
|
+
* per-collection subscription, and cancels every replication. What each caller
|
|
164
|
+
* does AFTER this differs (the unwind leaves the per-collection statuses at
|
|
165
|
+
* `error` and rethrows; `stop()` resets the status store behind its terminal
|
|
166
|
+
* latch), so the divergence stays at the call sites.
|
|
163
167
|
*
|
|
164
168
|
* @returns {Promise<void>}
|
|
165
169
|
*/
|
|
166
|
-
async
|
|
167
|
-
// Latch first so a concurrent `start()` (a logout racing the session
|
|
168
|
-
// bootstrap) sees the controller as terminally stopped and bails.
|
|
169
|
-
this.#stopped = true;
|
|
170
|
+
async #teardownReplications() {
|
|
170
171
|
if (this.#onlineHandler) {
|
|
171
172
|
window.removeEventListener('online', this.#onlineHandler);
|
|
172
173
|
this.#onlineHandler = undefined;
|
|
@@ -187,21 +188,31 @@ export class SyncController {
|
|
|
187
188
|
}
|
|
188
189
|
}
|
|
189
190
|
this.#replications = [];
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Triggers an immediate replication cycle on every running collection, rather
|
|
194
|
+
* than waiting for RxDB's next scheduled tick. Fire-and-forget.
|
|
195
|
+
*
|
|
196
|
+
* @returns {void}
|
|
197
|
+
*/
|
|
198
|
+
reSync() {
|
|
199
|
+
for (const { state } of this.#replications) {
|
|
200
|
+
state.reSync();
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Stops replication and releases resources (the database is owned by the
|
|
205
|
+
* caller). Idempotent.
|
|
206
|
+
*
|
|
207
|
+
* @returns {Promise<void>}
|
|
208
|
+
*/
|
|
209
|
+
async stop() {
|
|
210
|
+
// Latch first so a concurrent `start()` (a logout racing the session
|
|
211
|
+
// bootstrap) sees the controller as terminally stopped and bails.
|
|
212
|
+
this.#stopped = true;
|
|
213
|
+
await this.#teardownReplications();
|
|
190
214
|
useSyncStatusStore.getState().reset();
|
|
191
215
|
this.#started = false;
|
|
192
216
|
}
|
|
193
217
|
}
|
|
194
|
-
/**
|
|
195
|
-
* Builds a fresh {@link SyncController} bound to the collection registry and
|
|
196
|
-
* sync tuning. Prefer one controller per session (started once, stopped on
|
|
197
|
-
* logout) over a module-level singleton.
|
|
198
|
-
*
|
|
199
|
-
* @param options {object}
|
|
200
|
-
* @param options.collections {WasCollectionConfig[]}
|
|
201
|
-
* @param [options.sync] {WasSyncConfig}
|
|
202
|
-
* @returns {SyncController}
|
|
203
|
-
*/
|
|
204
|
-
export function createSyncController({ collections, sync }) {
|
|
205
|
-
return new SyncController({ collections, ...(sync && { sync }) });
|
|
206
|
-
}
|
|
207
218
|
//# sourceMappingURL=syncController.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syncController.js","sourceRoot":"","sources":["../../src/storage/syncController.ts"],"names":[],"mappings":"AAgCA,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAGjB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACL,oBAAoB,EAGrB,MAAM,cAAc,CAAA;AAGrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAOzD;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,WAAW,CAAC,GAAY;IACtC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAW,CAAA;IAC/B,MAAM,KAAK,GAAc,CAAC,GAAG,CAAC,CAAA;IAC9B,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC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AAI,CAAC,UAAU,CAAC,CAAA;YAC9B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAA;QAC7B,CAAC;QACD,KAAK,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YAC1D,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE,CAAC;gBACzC,YAAY,CAAC,WAAW,EAAE,CAAA;YAC5B,CAAC;YACD,IAAI,CAAC;gBACH,MAAM,KAAK,CAAC,MAAM,EAAE,CAAA;YACtB,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,GAAG,CAAC,CAAA;YACrD,CAAC;QACH,CAAC;QACD,IAAI,CAAC,aAAa,GAAG,EAAE,CAAA;IACzB,CAAC;IAED;;;;;OAKG;IACH,MAAM;QACJ,KAAK,MAAM,EAAE,KAAK,EAAE,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YAC3C,KAAK,CAAC,MAAM,EAAE,CAAA;QAChB,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,IAAI;QACR,qEAAqE;QACrE,kEAAkE;QAClE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAA;QACpB,MAAM,IAAI,CAAC,qBAAqB,EAAE,CAAA;QAClC,kBAAkB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAA;QACrC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAA;IACvB,CAAC;CACF"}
|
|
@@ -6,15 +6,18 @@
|
|
|
6
6
|
* - `error` -- last cycle failed (RxDB is backing off / will retry)
|
|
7
7
|
*/
|
|
8
8
|
export type SyncStatus = 'idle' | 'syncing' | 'synced' | 'error';
|
|
9
|
-
|
|
9
|
+
export declare const useSyncStatusStore: import("zustand").UseBoundStore<import("zustand").StoreApi<{
|
|
10
10
|
/**
|
|
11
|
-
* Keyed by
|
|
11
|
+
* Keyed by the registry's LOGICAL collection key (`WasCollectionConfig.key`,
|
|
12
|
+
* e.g. `actionItems`), not the WAS wire id. Two registry entries may share one
|
|
13
|
+
* WAS id, so the id is not a unique status key; every other layer (the entity
|
|
14
|
+
* stores, the rehydrate mechanism, the local replica's RxDB collections)
|
|
15
|
+
* routes on the logical key too.
|
|
12
16
|
*/
|
|
13
17
|
statuses: Record<string, SyncStatus>;
|
|
14
|
-
setStatus: (
|
|
18
|
+
setStatus: (collectionKey: string, status: SyncStatus) => void;
|
|
15
19
|
reset: () => void;
|
|
16
|
-
}
|
|
17
|
-
export declare const useSyncStatusStore: import("zustand").UseBoundStore<import("zustand").StoreApi<SyncStatusState>>;
|
|
20
|
+
}>>;
|
|
18
21
|
/**
|
|
19
22
|
* The aggregate replication status derived from the per-collection statuses:
|
|
20
23
|
* `offline` when no replication is running (local-only), otherwise rolled up as
|
|
@@ -38,5 +41,4 @@ export declare function deriveSyncRollup(statuses: SyncStatus[]): {
|
|
|
38
41
|
label: string;
|
|
39
42
|
title: string;
|
|
40
43
|
};
|
|
41
|
-
export {};
|
|
42
44
|
//# sourceMappingURL=syncStatusStore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syncStatusStore.d.ts","sourceRoot":"","sources":["../../src/storage/syncStatusStore.ts"],"names":[],"mappings":"AAYA;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAA;AAEhE,
|
|
1
|
+
{"version":3,"file":"syncStatusStore.d.ts","sourceRoot":"","sources":["../../src/storage/syncStatusStore.ts"],"names":[],"mappings":"AAYA;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAA;AAEhE,eAAO,MAAM,kBAAkB;IAC7B;;;;;;OAMG;cACO,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC;eACzB,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,KAAK,IAAI;WACvD,MAAM,IAAI;GAQhB,CAAA;AAEH;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAA;AAEnE;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,UAAU,EAAE,GAAG;IACxD,KAAK,EAAE,UAAU,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd,CA2BA"}
|
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
5
|
* Zustand store holding per-collection replication status, mirroring the WAS
|
|
6
|
-
* per-replica sync-status vocabulary
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* logout.
|
|
6
|
+
* per-replica sync-status vocabulary, keyed by the registry's logical collection
|
|
7
|
+
* key. The sync controller writes to it off the RxDB replication `active$` /
|
|
8
|
+
* `error$` streams; UI (e.g. a header indicator or a settings page) reads from
|
|
9
|
+
* it. In-memory only, like the session -- cleared on logout.
|
|
10
10
|
*/
|
|
11
11
|
import { create } from 'zustand';
|
|
12
12
|
export const useSyncStatusStore = create()(set => ({
|
|
13
13
|
statuses: {},
|
|
14
|
-
setStatus: (
|
|
15
|
-
statuses: { ...state.statuses, [
|
|
14
|
+
setStatus: (collectionKey, status) => set(state => ({
|
|
15
|
+
statuses: { ...state.statuses, [collectionKey]: status }
|
|
16
16
|
})),
|
|
17
17
|
reset: () => set({ statuses: {} })
|
|
18
18
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syncStatusStore.js","sourceRoot":"","sources":["../../src/storage/syncStatusStore.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;GAMG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"syncStatusStore.js","sourceRoot":"","sources":["../../src/storage/syncStatusStore.ts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