@abraca/dabra 2.17.1 → 2.18.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/dist/index.d.ts
CHANGED
|
@@ -3281,6 +3281,24 @@ declare class BackgroundSyncManager extends EventEmitter {
|
|
|
3281
3281
|
*/
|
|
3282
3282
|
init(): Promise<void>;
|
|
3283
3283
|
private _loadPersistedStates;
|
|
3284
|
+
/**
|
|
3285
|
+
* Re-read persisted sync states from IndexedDB, merging in any docs not
|
|
3286
|
+
* already tracked in memory. Unlike `init()` this is **not** cached behind
|
|
3287
|
+
* `_initPromise` — every call hits IDB afresh.
|
|
3288
|
+
*
|
|
3289
|
+
* Why this exists: `init()` only ever loads IDB once. If a manager was
|
|
3290
|
+
* created while IDB was empty/mid-population (or a UI singleton was left
|
|
3291
|
+
* pointing at a manager whose in-memory map is stale after a connection
|
|
3292
|
+
* swap), the only thing that recovered the real counts was a full page
|
|
3293
|
+
* reload (which spins up a brand-new manager → fresh `_loadPersistedStates`).
|
|
3294
|
+
* Calling this re-hydrates from the same source a reload reads, so the
|
|
3295
|
+
* offline-sync panel can self-heal from a spurious "0/0" without a reload.
|
|
3296
|
+
*
|
|
3297
|
+
* Merge-only by design: an in-memory entry (possibly a fresher in-flight
|
|
3298
|
+
* `syncing`/`synced`) is never clobbered by the persisted copy; we only add
|
|
3299
|
+
* docs IDB knows about that memory doesn't.
|
|
3300
|
+
*/
|
|
3301
|
+
reloadPersistedStates(): Promise<void>;
|
|
3284
3302
|
/** Sync all documents in the root tree. */
|
|
3285
3303
|
syncAll(): Promise<void>;
|
|
3286
3304
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abraca/dabra",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.18.0",
|
|
4
4
|
"description": "abracadabra provider",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"abracadabra",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"yjs": "^13.6.8"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@abraca/schema": "2.
|
|
44
|
+
"@abraca/schema": "2.18.0"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"test": "node --no-warnings --conditions=source --experimental-transform-types --test 'tests/*.test.ts'"
|
|
@@ -199,6 +199,36 @@ export class BackgroundSyncManager extends EventEmitter {
|
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
+
/**
|
|
203
|
+
* Re-read persisted sync states from IndexedDB, merging in any docs not
|
|
204
|
+
* already tracked in memory. Unlike `init()` this is **not** cached behind
|
|
205
|
+
* `_initPromise` — every call hits IDB afresh.
|
|
206
|
+
*
|
|
207
|
+
* Why this exists: `init()` only ever loads IDB once. If a manager was
|
|
208
|
+
* created while IDB was empty/mid-population (or a UI singleton was left
|
|
209
|
+
* pointing at a manager whose in-memory map is stale after a connection
|
|
210
|
+
* swap), the only thing that recovered the real counts was a full page
|
|
211
|
+
* reload (which spins up a brand-new manager → fresh `_loadPersistedStates`).
|
|
212
|
+
* Calling this re-hydrates from the same source a reload reads, so the
|
|
213
|
+
* offline-sync panel can self-heal from a spurious "0/0" without a reload.
|
|
214
|
+
*
|
|
215
|
+
* Merge-only by design: an in-memory entry (possibly a fresher in-flight
|
|
216
|
+
* `syncing`/`synced`) is never clobbered by the persisted copy; we only add
|
|
217
|
+
* docs IDB knows about that memory doesn't.
|
|
218
|
+
*/
|
|
219
|
+
async reloadPersistedStates(): Promise<void> {
|
|
220
|
+
try {
|
|
221
|
+
const states = await this.persistence.getAllStates();
|
|
222
|
+
for (const state of states) {
|
|
223
|
+
if (!this.syncStates.has(state.docId)) {
|
|
224
|
+
this.syncStates.set(state.docId, state);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
} catch {
|
|
228
|
+
// IDB unavailable — keep whatever is already in memory.
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
202
232
|
/** Sync all documents in the root tree. */
|
|
203
233
|
async syncAll(): Promise<void> {
|
|
204
234
|
if (this._destroyed) return;
|