@abraca/dabra 2.77.0 → 2.78.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/abracadabra-provider.cjs +40 -0
- package/dist/abracadabra-provider.cjs.map +1 -1
- package/dist/abracadabra-provider.esm.js +40 -0
- package/dist/abracadabra-provider.esm.js.map +1 -1
- package/dist/index.d.ts +46 -1
- package/package.json +2 -2
- package/src/AbracadabraClient.ts +31 -0
- package/src/AbracadabraProvider.ts +32 -7
- package/src/BackgroundSyncManager.ts +11 -0
- package/src/types.ts +14 -0
|
@@ -3493,6 +3493,7 @@ var AbracadabraProvider = class AbracadabraProvider extends AbracadabraBaseProvi
|
|
|
3493
3493
|
async flushPendingUpdates() {
|
|
3494
3494
|
const store = this.offlineStore;
|
|
3495
3495
|
if (!store) return;
|
|
3496
|
+
await this.persistSnapshot();
|
|
3496
3497
|
if (this.canWrite) {
|
|
3497
3498
|
const updates = await store.getPendingUpdates();
|
|
3498
3499
|
if (updates.length > 0) {
|
|
@@ -3508,6 +3509,22 @@ var AbracadabraProvider = class AbracadabraProvider extends AbracadabraBaseProvi
|
|
|
3508
3509
|
childDocumentName: childId
|
|
3509
3510
|
});
|
|
3510
3511
|
}
|
|
3512
|
+
}
|
|
3513
|
+
/**
|
|
3514
|
+
* Persist the current merged document state to the offline store.
|
|
3515
|
+
*
|
|
3516
|
+
* This is the ONLY path that persists server-delivered content
|
|
3517
|
+
* (`documentUpdateHandler` skips `origin === this`), so it MUST run for
|
|
3518
|
+
* read-only roles too — otherwise observers/viewers get a permanently
|
|
3519
|
+
* empty offline cache and every cold start waits for a full re-sync.
|
|
3520
|
+
*
|
|
3521
|
+
* Public so short-lived consumers that load a document, read it and
|
|
3522
|
+
* immediately unload it (BackgroundSyncManager) can force the write to
|
|
3523
|
+
* land before teardown instead of racing `destroy()`.
|
|
3524
|
+
*/
|
|
3525
|
+
async persistSnapshot() {
|
|
3526
|
+
const store = this.offlineStore;
|
|
3527
|
+
if (!store) return;
|
|
3511
3528
|
const snapshot = yjs.encodeStateAsUpdate(this.document);
|
|
3512
3529
|
await store.saveDocSnapshot(snapshot).catch(() => null);
|
|
3513
3530
|
}
|
|
@@ -10988,6 +11005,28 @@ var AbracadabraClient = class {
|
|
|
10988
11005
|
return (await this.request("GET", `/docs/search?${params.toString()}`)).results;
|
|
10989
11006
|
}
|
|
10990
11007
|
/**
|
|
11008
|
+
* Documents that link TO `docId`, via `GET /docs/:id/backlinks`.
|
|
11009
|
+
*
|
|
11010
|
+
* Served from the server's `doc_links` index, which is rebuilt from each
|
|
11011
|
+
* document's CRDT state whenever a snapshot is written. Prefer this over
|
|
11012
|
+
* inverting links from a local cache: a client can only invert what it has
|
|
11013
|
+
* downloaded, so on a large space a purely local backlink list is silently
|
|
11014
|
+
* incomplete rather than empty-and-obviously-wrong.
|
|
11015
|
+
*
|
|
11016
|
+
* The caller must be able to read the target document, and each hit is
|
|
11017
|
+
* cascade-filtered, so this never reveals a document the caller couldn't
|
|
11018
|
+
* otherwise see. `limit` is clamped to `[1, 200]` server-side (default 50).
|
|
11019
|
+
*
|
|
11020
|
+
* Throws on servers that predate the endpoint — callers that need to work
|
|
11021
|
+
* against older deployments should catch and fall back to a local index.
|
|
11022
|
+
*/
|
|
11023
|
+
async getBacklinks(docId, opts) {
|
|
11024
|
+
const params = new URLSearchParams();
|
|
11025
|
+
if (opts?.limit != null) params.set("limit", String(opts.limit));
|
|
11026
|
+
const qs = params.toString();
|
|
11027
|
+
return (await this.request("GET", `/docs/${encodeURIComponent(docId)}/backlinks${qs ? `?${qs}` : ""}`)).results;
|
|
11028
|
+
}
|
|
11029
|
+
/**
|
|
10991
11030
|
* Query for documents matching a structural predicate. v1 of the
|
|
10992
11031
|
* indexed-query layer described in
|
|
10993
11032
|
* `ARCHITECTURE/20-kickoff-phase3-queries.md`.
|
|
@@ -17163,6 +17202,7 @@ var BackgroundSyncManager = class extends EventEmitter {
|
|
|
17163
17202
|
try {
|
|
17164
17203
|
await childProvider.ready;
|
|
17165
17204
|
await this._waitForSynced(childProvider);
|
|
17205
|
+
if (typeof childProvider.persistSnapshot === "function") await childProvider.persistSnapshot();
|
|
17166
17206
|
{
|
|
17167
17207
|
const treeEntry = treeMap.get(docId);
|
|
17168
17208
|
this.emit("docSynced", {
|