loro-repo 0.2.0 → 0.4.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 +18 -17
- package/dist/index.cjs +501 -233
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +101 -49
- package/dist/index.d.ts +103 -50
- package/dist/index.js +491 -231
- package/dist/index.js.map +1 -1
- package/package.json +10 -7
package/dist/index.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ import { Flock } from "@loro-dev/flock";
|
|
|
2
2
|
import { Frontiers, LoroDoc } from "loro-crdt";
|
|
3
3
|
import { JoinError, JoinResponseOk, RoomId, UpdateError } from "loro-protocol";
|
|
4
4
|
import { LoroWebsocketClientOptions } from "loro-websocket";
|
|
5
|
-
import { FlockAdaptorConfig } from "loro-adaptors";
|
|
5
|
+
import { FlockAdaptorConfig } from "loro-adaptors/flock";
|
|
6
6
|
|
|
7
7
|
//#region src/types.d.ts
|
|
8
8
|
type GlobalBlob = typeof globalThis extends {
|
|
@@ -56,10 +56,6 @@ interface LoroRepoOptions<_Meta extends JsonObject = JsonObject> {
|
|
|
56
56
|
* Optional adapter that moves asset payloads while keeping metadata in sync.
|
|
57
57
|
*/
|
|
58
58
|
readonly assetTransportAdapter?: AssetTransportAdapter;
|
|
59
|
-
/**
|
|
60
|
-
* Factory invoked when a document handle needs to be materialised.
|
|
61
|
-
*/
|
|
62
|
-
readonly docFactory?: (docId: string) => Promise<LoroDoc>;
|
|
63
59
|
/**
|
|
64
60
|
* Debounce duration in milliseconds before persisting document frontier metadata
|
|
65
61
|
* after local edits. Defaults to 1000 ms when omitted.
|
|
@@ -168,6 +164,8 @@ interface TransportAdapter {
|
|
|
168
164
|
* Persists metadata, documents, and asset payloads on behalf of the repo.
|
|
169
165
|
*/
|
|
170
166
|
interface StorageAdapter {
|
|
167
|
+
init?(): Promise<void>;
|
|
168
|
+
close?(): void;
|
|
171
169
|
/**
|
|
172
170
|
* Writes document snapshots, queued updates, assets, or meta bundles to durable storage.
|
|
173
171
|
*/
|
|
@@ -220,6 +218,8 @@ interface AssetUploadMetadata {
|
|
|
220
218
|
* Moves binary assets between peers or infrastructure-specific storage.
|
|
221
219
|
*/
|
|
222
220
|
interface AssetTransportAdapter {
|
|
221
|
+
init?(): Promise<void>;
|
|
222
|
+
close?(): void;
|
|
223
223
|
/**
|
|
224
224
|
* Uploads a raw asset payload using transport-managed metadata.
|
|
225
225
|
*/
|
|
@@ -342,47 +342,57 @@ interface RepoDocHandle {
|
|
|
342
342
|
*/
|
|
343
343
|
readonly doc: LoroDoc;
|
|
344
344
|
/**
|
|
345
|
-
*
|
|
345
|
+
* Sync with the transport adaptor once.
|
|
346
346
|
*/
|
|
347
|
-
readonly
|
|
347
|
+
readonly syncOnce: () => Promise<void>;
|
|
348
348
|
/**
|
|
349
|
-
*
|
|
349
|
+
* Join the realtime collaboration room.
|
|
350
350
|
*/
|
|
351
|
-
|
|
351
|
+
readonly joinRoom: (auth?: Uint8Array) => Promise<TransportSubscription>;
|
|
352
352
|
}
|
|
353
|
-
interface UpsertDocMetaOptions {}
|
|
354
353
|
/**
|
|
355
354
|
* Provenance discriminant attached to every repo event.
|
|
356
355
|
*/
|
|
357
356
|
type RepoEventBy = "local" | "sync" | "live";
|
|
358
357
|
/**
|
|
359
|
-
* Unified event envelope emitted by `watch`.
|
|
358
|
+
* Unified event envelope types emitted by `watch`.
|
|
360
359
|
*/
|
|
361
|
-
type
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
360
|
+
type RepoEventType<Meta extends JsonObject = JsonObject> = {
|
|
361
|
+
"doc-metadata": {
|
|
362
|
+
readonly kind: "doc-metadata";
|
|
363
|
+
readonly docId: string;
|
|
364
|
+
readonly patch: Partial<Meta>;
|
|
365
|
+
readonly by: RepoEventBy;
|
|
366
|
+
};
|
|
367
|
+
"doc-frontiers": {
|
|
368
|
+
readonly kind: "doc-frontiers";
|
|
369
|
+
readonly docId: string;
|
|
370
|
+
readonly frontiers: Frontiers;
|
|
371
|
+
readonly by: RepoEventBy;
|
|
372
|
+
};
|
|
373
|
+
"asset-metadata": {
|
|
374
|
+
readonly kind: "asset-metadata";
|
|
375
|
+
readonly asset: AssetDownload;
|
|
376
|
+
readonly by: RepoEventBy;
|
|
377
|
+
};
|
|
378
|
+
"asset-link": {
|
|
379
|
+
readonly kind: "asset-link";
|
|
380
|
+
readonly docId: string;
|
|
381
|
+
readonly assetId: AssetId;
|
|
382
|
+
readonly by: RepoEventBy;
|
|
383
|
+
};
|
|
384
|
+
"asset-unlink": {
|
|
385
|
+
readonly kind: "asset-unlink";
|
|
386
|
+
readonly docId: string;
|
|
387
|
+
readonly assetId: AssetId;
|
|
388
|
+
readonly by: RepoEventBy;
|
|
389
|
+
};
|
|
385
390
|
};
|
|
391
|
+
/**
|
|
392
|
+
* Discriminant union of all possible repo event types.
|
|
393
|
+
*/
|
|
394
|
+
type RepoEventKind = keyof RepoEventType;
|
|
395
|
+
type RepoEvent<Meta extends JsonObject = JsonObject> = RepoEventType<Meta>[keyof RepoEventType<Meta>];
|
|
386
396
|
/**
|
|
387
397
|
* Listener signature for `watch`.
|
|
388
398
|
*/
|
|
@@ -619,40 +629,80 @@ declare class FileSystemStorageAdaptor implements StorageAdapter {
|
|
|
619
629
|
//#region src/index.d.ts
|
|
620
630
|
declare class LoroRepo<Meta extends JsonObject = JsonObject> {
|
|
621
631
|
readonly options: LoroRepoOptions<Meta>;
|
|
632
|
+
private _destroyed;
|
|
622
633
|
private readonly transport?;
|
|
623
634
|
private readonly storage?;
|
|
624
|
-
private readonly docFactory;
|
|
625
635
|
private metaFlock;
|
|
626
636
|
private readonly eventBus;
|
|
627
637
|
private readonly docManager;
|
|
628
638
|
private readonly metadataManager;
|
|
629
639
|
private readonly assetManager;
|
|
640
|
+
private readonly assetTransport?;
|
|
630
641
|
private readonly flockHydrator;
|
|
631
642
|
private readonly state;
|
|
632
643
|
private readonly syncRunner;
|
|
633
|
-
constructor(
|
|
634
|
-
|
|
644
|
+
private constructor();
|
|
645
|
+
static create<Meta extends JsonObject = JsonObject>(options: LoroRepoOptions<Meta>): Promise<LoroRepo<Meta>>;
|
|
646
|
+
/**
|
|
647
|
+
* Load meta from storage.
|
|
648
|
+
*
|
|
649
|
+
* You need to call this before all other operations to make the app functioning correctly.
|
|
650
|
+
* Though we do that implicitly already
|
|
651
|
+
*/
|
|
652
|
+
private ready;
|
|
653
|
+
/**
|
|
654
|
+
* Sync selected data via the transport adaptor
|
|
655
|
+
* @param options
|
|
656
|
+
*/
|
|
635
657
|
sync(options?: RepoSyncOptions): Promise<void>;
|
|
658
|
+
/**
|
|
659
|
+
* Start syncing the metadata (Flock) room. It will establish a realtime connection to the transport adaptor.
|
|
660
|
+
* All changes on the room will be synced to the Flock, and all changes on the Flock will be synced to the room.
|
|
661
|
+
* @param params
|
|
662
|
+
* @returns
|
|
663
|
+
*/
|
|
636
664
|
joinMetaRoom(params?: TransportJoinParams): Promise<TransportSubscription>;
|
|
665
|
+
/**
|
|
666
|
+
* Start syncing the given doc. It will establish a realtime connection to the transport adaptor.
|
|
667
|
+
* All changes on the doc will be synced to the transport, and all changes on the transport will be synced to the doc.
|
|
668
|
+
*
|
|
669
|
+
* All the changes on the room will be reflected on the same doc you get from `repo.openCollaborativeDoc(docId)`
|
|
670
|
+
* @param docId
|
|
671
|
+
* @param params
|
|
672
|
+
* @returns
|
|
673
|
+
*/
|
|
637
674
|
joinDocRoom(docId: string, params?: TransportJoinParams): Promise<TransportSubscription>;
|
|
638
|
-
|
|
639
|
-
|
|
675
|
+
/**
|
|
676
|
+
* Opens a document that is automatically persisted to the configured storage adapter.
|
|
677
|
+
*
|
|
678
|
+
* - Edits are saved to storage (debounced).
|
|
679
|
+
* - Frontiers are synced to the metadata (Flock).
|
|
680
|
+
* - Realtime collaboration is NOT enabled by default; use `joinDocRoom` to connect.
|
|
681
|
+
*/
|
|
682
|
+
openPersistedDoc(docId: string): Promise<RepoDocHandle>;
|
|
683
|
+
upsertDocMeta(docId: string, patch: Partial<Meta>): Promise<void>;
|
|
640
684
|
getDocMeta(docId: string): Promise<Meta | undefined>;
|
|
641
685
|
listDoc(query?: ListDocQuery): Promise<RepoDocMeta<Meta>[]>;
|
|
642
|
-
|
|
686
|
+
getMeta(): Flock;
|
|
643
687
|
watch(listener: RepoEventListener<Meta>, filter?: RepoEventFilter<Meta>): RepoWatchHandle;
|
|
644
688
|
/**
|
|
645
|
-
* Opens
|
|
646
|
-
*
|
|
689
|
+
* Opens a detached `LoroDoc` snapshot.
|
|
690
|
+
*
|
|
691
|
+
* - **No Persistence**: Edits to this document are NOT saved to storage.
|
|
692
|
+
* - **No Sync**: This document does not participate in realtime updates.
|
|
693
|
+
* - **Use Case**: Ideal for read-only history inspection, temporary drafts, or conflict resolution without affecting the main state.
|
|
647
694
|
*/
|
|
648
|
-
|
|
695
|
+
openDetachedDoc(docId: string): Promise<LoroDoc>;
|
|
649
696
|
/**
|
|
650
|
-
*
|
|
651
|
-
*
|
|
697
|
+
* Explicitly unloads a document from memory.
|
|
698
|
+
*
|
|
699
|
+
* - **Persists Immediately**: Forces a save of the document's current state to storage.
|
|
700
|
+
* - **Frees Memory**: Removes the document from the internal cache.
|
|
701
|
+
* - **Note**: If the document is currently being synced (via `joinDocRoom`), you should also unsubscribe from the room to fully release resources.
|
|
652
702
|
*/
|
|
653
|
-
|
|
703
|
+
unloadDoc(docId: string): Promise<void>;
|
|
704
|
+
flush(): Promise<void>;
|
|
654
705
|
uploadAsset(params: UploadAssetOptions): Promise<AssetId>;
|
|
655
|
-
whenDocInSyncWithRemote(docId: string): Promise<void>;
|
|
656
706
|
linkAsset(docId: string, params: LinkAssetOptions): Promise<AssetId>;
|
|
657
707
|
fetchAsset(assetId: AssetId): Promise<AssetDownload>;
|
|
658
708
|
unlinkAsset(docId: string, assetId: AssetId): Promise<void>;
|
|
@@ -660,7 +710,9 @@ declare class LoroRepo<Meta extends JsonObject = JsonObject> {
|
|
|
660
710
|
ensureAsset(assetId: AssetId): Promise<AssetDownload>;
|
|
661
711
|
gcAssets(options?: GarbageCollectionOptions): Promise<number>;
|
|
662
712
|
private persistMeta;
|
|
713
|
+
get destroyed(): boolean;
|
|
714
|
+
destroy(): Promise<void>;
|
|
663
715
|
}
|
|
664
716
|
//#endregion
|
|
665
|
-
export { AssetContent, AssetDownload, AssetId, AssetTransportAdapter, AssetUploadMetadata, BroadcastChannelTransportAdapter, type BroadcastChannelTransportOptions, FileSystemStorageAdaptor, type FileSystemStorageAdaptorOptions, GarbageCollectionOptions, IndexedDBStorageAdaptor, type IndexedDBStorageAdaptorOptions, JsonObject, JsonValue, LinkAssetOptions, ListDocQuery, LoroRepo, LoroRepoOptions, RepoAssetMetadata, RepoDocHandle, RepoDocMeta, RepoEvent, RepoEventBy, RepoEventFilter, RepoEventListener, type RepoSyncOptions, RepoWatchHandle, StorageAdapter, StorageSavePayload, SyncScope, TransportAdapter, type TransportJoinParams, type TransportSubscription, TransportSyncRequest, type TransportSyncResult, UploadAssetOptions,
|
|
717
|
+
export { AssetContent, AssetDownload, AssetId, AssetTransportAdapter, AssetUploadMetadata, BroadcastChannelTransportAdapter, type BroadcastChannelTransportOptions, FileSystemStorageAdaptor, type FileSystemStorageAdaptorOptions, GarbageCollectionOptions, IndexedDBStorageAdaptor, type IndexedDBStorageAdaptorOptions, JsonObject, JsonValue, LinkAssetOptions, ListDocQuery, LoroRepo, LoroRepoOptions, RepoAssetMetadata, RepoDocHandle, RepoDocMeta, RepoEvent, RepoEventBy, RepoEventFilter, RepoEventKind, RepoEventListener, RepoEventType, type RepoSyncOptions, RepoWatchHandle, StorageAdapter, StorageSavePayload, SyncScope, TransportAdapter, type TransportJoinParams, type TransportSubscription, TransportSyncRequest, type TransportSyncResult, UploadAssetOptions, WebSocketTransportAdapter, type WebSocketTransportOptions };
|
|
666
718
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Flock } from "@loro-dev/flock";
|
|
2
|
-
import {
|
|
3
|
-
import { FlockAdaptor, FlockAdaptorConfig, LoroAdaptor } from "loro-adaptors";
|
|
2
|
+
import { LoroAdaptor } from "loro-adaptors/loro";
|
|
4
3
|
import { JoinError, JoinResponseOk, RoomId, UpdateError } from "loro-protocol";
|
|
5
4
|
import { LoroWebsocketClientOptions } from "loro-websocket";
|
|
5
|
+
import { Frontiers, LoroDoc } from "loro-crdt";
|
|
6
|
+
import { FlockAdaptor, FlockAdaptorConfig } from "loro-adaptors/flock";
|
|
6
7
|
|
|
7
8
|
//#region src/types.d.ts
|
|
8
9
|
type GlobalBlob = typeof globalThis extends {
|
|
@@ -56,10 +57,6 @@ interface LoroRepoOptions<_Meta extends JsonObject = JsonObject> {
|
|
|
56
57
|
* Optional adapter that moves asset payloads while keeping metadata in sync.
|
|
57
58
|
*/
|
|
58
59
|
readonly assetTransportAdapter?: AssetTransportAdapter;
|
|
59
|
-
/**
|
|
60
|
-
* Factory invoked when a document handle needs to be materialised.
|
|
61
|
-
*/
|
|
62
|
-
readonly docFactory?: (docId: string) => Promise<LoroDoc>;
|
|
63
60
|
/**
|
|
64
61
|
* Debounce duration in milliseconds before persisting document frontier metadata
|
|
65
62
|
* after local edits. Defaults to 1000 ms when omitted.
|
|
@@ -168,6 +165,8 @@ interface TransportAdapter {
|
|
|
168
165
|
* Persists metadata, documents, and asset payloads on behalf of the repo.
|
|
169
166
|
*/
|
|
170
167
|
interface StorageAdapter {
|
|
168
|
+
init?(): Promise<void>;
|
|
169
|
+
close?(): void;
|
|
171
170
|
/**
|
|
172
171
|
* Writes document snapshots, queued updates, assets, or meta bundles to durable storage.
|
|
173
172
|
*/
|
|
@@ -220,6 +219,8 @@ interface AssetUploadMetadata {
|
|
|
220
219
|
* Moves binary assets between peers or infrastructure-specific storage.
|
|
221
220
|
*/
|
|
222
221
|
interface AssetTransportAdapter {
|
|
222
|
+
init?(): Promise<void>;
|
|
223
|
+
close?(): void;
|
|
223
224
|
/**
|
|
224
225
|
* Uploads a raw asset payload using transport-managed metadata.
|
|
225
226
|
*/
|
|
@@ -342,47 +343,57 @@ interface RepoDocHandle {
|
|
|
342
343
|
*/
|
|
343
344
|
readonly doc: LoroDoc;
|
|
344
345
|
/**
|
|
345
|
-
*
|
|
346
|
+
* Sync with the transport adaptor once.
|
|
346
347
|
*/
|
|
347
|
-
readonly
|
|
348
|
+
readonly syncOnce: () => Promise<void>;
|
|
348
349
|
/**
|
|
349
|
-
*
|
|
350
|
+
* Join the realtime collaboration room.
|
|
350
351
|
*/
|
|
351
|
-
|
|
352
|
+
readonly joinRoom: (auth?: Uint8Array) => Promise<TransportSubscription>;
|
|
352
353
|
}
|
|
353
|
-
interface UpsertDocMetaOptions {}
|
|
354
354
|
/**
|
|
355
355
|
* Provenance discriminant attached to every repo event.
|
|
356
356
|
*/
|
|
357
357
|
type RepoEventBy = "local" | "sync" | "live";
|
|
358
358
|
/**
|
|
359
|
-
* Unified event envelope emitted by `watch`.
|
|
359
|
+
* Unified event envelope types emitted by `watch`.
|
|
360
360
|
*/
|
|
361
|
-
type
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
361
|
+
type RepoEventType<Meta extends JsonObject = JsonObject> = {
|
|
362
|
+
"doc-metadata": {
|
|
363
|
+
readonly kind: "doc-metadata";
|
|
364
|
+
readonly docId: string;
|
|
365
|
+
readonly patch: Partial<Meta>;
|
|
366
|
+
readonly by: RepoEventBy;
|
|
367
|
+
};
|
|
368
|
+
"doc-frontiers": {
|
|
369
|
+
readonly kind: "doc-frontiers";
|
|
370
|
+
readonly docId: string;
|
|
371
|
+
readonly frontiers: Frontiers;
|
|
372
|
+
readonly by: RepoEventBy;
|
|
373
|
+
};
|
|
374
|
+
"asset-metadata": {
|
|
375
|
+
readonly kind: "asset-metadata";
|
|
376
|
+
readonly asset: AssetDownload;
|
|
377
|
+
readonly by: RepoEventBy;
|
|
378
|
+
};
|
|
379
|
+
"asset-link": {
|
|
380
|
+
readonly kind: "asset-link";
|
|
381
|
+
readonly docId: string;
|
|
382
|
+
readonly assetId: AssetId;
|
|
383
|
+
readonly by: RepoEventBy;
|
|
384
|
+
};
|
|
385
|
+
"asset-unlink": {
|
|
386
|
+
readonly kind: "asset-unlink";
|
|
387
|
+
readonly docId: string;
|
|
388
|
+
readonly assetId: AssetId;
|
|
389
|
+
readonly by: RepoEventBy;
|
|
390
|
+
};
|
|
385
391
|
};
|
|
392
|
+
/**
|
|
393
|
+
* Discriminant union of all possible repo event types.
|
|
394
|
+
*/
|
|
395
|
+
type RepoEventKind = keyof RepoEventType;
|
|
396
|
+
type RepoEvent<Meta extends JsonObject = JsonObject> = RepoEventType<Meta>[keyof RepoEventType<Meta>];
|
|
386
397
|
/**
|
|
387
398
|
* Listener signature for `watch`.
|
|
388
399
|
*/
|
|
@@ -619,40 +630,80 @@ declare class FileSystemStorageAdaptor implements StorageAdapter {
|
|
|
619
630
|
//#region src/index.d.ts
|
|
620
631
|
declare class LoroRepo<Meta extends JsonObject = JsonObject> {
|
|
621
632
|
readonly options: LoroRepoOptions<Meta>;
|
|
633
|
+
private _destroyed;
|
|
622
634
|
private readonly transport?;
|
|
623
635
|
private readonly storage?;
|
|
624
|
-
private readonly docFactory;
|
|
625
636
|
private metaFlock;
|
|
626
637
|
private readonly eventBus;
|
|
627
638
|
private readonly docManager;
|
|
628
639
|
private readonly metadataManager;
|
|
629
640
|
private readonly assetManager;
|
|
641
|
+
private readonly assetTransport?;
|
|
630
642
|
private readonly flockHydrator;
|
|
631
643
|
private readonly state;
|
|
632
644
|
private readonly syncRunner;
|
|
633
|
-
constructor(
|
|
634
|
-
|
|
645
|
+
private constructor();
|
|
646
|
+
static create<Meta extends JsonObject = JsonObject>(options: LoroRepoOptions<Meta>): Promise<LoroRepo<Meta>>;
|
|
647
|
+
/**
|
|
648
|
+
* Load meta from storage.
|
|
649
|
+
*
|
|
650
|
+
* You need to call this before all other operations to make the app functioning correctly.
|
|
651
|
+
* Though we do that implicitly already
|
|
652
|
+
*/
|
|
653
|
+
private ready;
|
|
654
|
+
/**
|
|
655
|
+
* Sync selected data via the transport adaptor
|
|
656
|
+
* @param options
|
|
657
|
+
*/
|
|
635
658
|
sync(options?: RepoSyncOptions): Promise<void>;
|
|
659
|
+
/**
|
|
660
|
+
* Start syncing the metadata (Flock) room. It will establish a realtime connection to the transport adaptor.
|
|
661
|
+
* All changes on the room will be synced to the Flock, and all changes on the Flock will be synced to the room.
|
|
662
|
+
* @param params
|
|
663
|
+
* @returns
|
|
664
|
+
*/
|
|
636
665
|
joinMetaRoom(params?: TransportJoinParams): Promise<TransportSubscription>;
|
|
666
|
+
/**
|
|
667
|
+
* Start syncing the given doc. It will establish a realtime connection to the transport adaptor.
|
|
668
|
+
* All changes on the doc will be synced to the transport, and all changes on the transport will be synced to the doc.
|
|
669
|
+
*
|
|
670
|
+
* All the changes on the room will be reflected on the same doc you get from `repo.openCollaborativeDoc(docId)`
|
|
671
|
+
* @param docId
|
|
672
|
+
* @param params
|
|
673
|
+
* @returns
|
|
674
|
+
*/
|
|
637
675
|
joinDocRoom(docId: string, params?: TransportJoinParams): Promise<TransportSubscription>;
|
|
638
|
-
|
|
639
|
-
|
|
676
|
+
/**
|
|
677
|
+
* Opens a document that is automatically persisted to the configured storage adapter.
|
|
678
|
+
*
|
|
679
|
+
* - Edits are saved to storage (debounced).
|
|
680
|
+
* - Frontiers are synced to the metadata (Flock).
|
|
681
|
+
* - Realtime collaboration is NOT enabled by default; use `joinDocRoom` to connect.
|
|
682
|
+
*/
|
|
683
|
+
openPersistedDoc(docId: string): Promise<RepoDocHandle>;
|
|
684
|
+
upsertDocMeta(docId: string, patch: Partial<Meta>): Promise<void>;
|
|
640
685
|
getDocMeta(docId: string): Promise<Meta | undefined>;
|
|
641
686
|
listDoc(query?: ListDocQuery): Promise<RepoDocMeta<Meta>[]>;
|
|
642
|
-
|
|
687
|
+
getMeta(): Flock;
|
|
643
688
|
watch(listener: RepoEventListener<Meta>, filter?: RepoEventFilter<Meta>): RepoWatchHandle;
|
|
644
689
|
/**
|
|
645
|
-
* Opens
|
|
646
|
-
*
|
|
690
|
+
* Opens a detached `LoroDoc` snapshot.
|
|
691
|
+
*
|
|
692
|
+
* - **No Persistence**: Edits to this document are NOT saved to storage.
|
|
693
|
+
* - **No Sync**: This document does not participate in realtime updates.
|
|
694
|
+
* - **Use Case**: Ideal for read-only history inspection, temporary drafts, or conflict resolution without affecting the main state.
|
|
647
695
|
*/
|
|
648
|
-
|
|
696
|
+
openDetachedDoc(docId: string): Promise<LoroDoc>;
|
|
649
697
|
/**
|
|
650
|
-
*
|
|
651
|
-
*
|
|
698
|
+
* Explicitly unloads a document from memory.
|
|
699
|
+
*
|
|
700
|
+
* - **Persists Immediately**: Forces a save of the document's current state to storage.
|
|
701
|
+
* - **Frees Memory**: Removes the document from the internal cache.
|
|
702
|
+
* - **Note**: If the document is currently being synced (via `joinDocRoom`), you should also unsubscribe from the room to fully release resources.
|
|
652
703
|
*/
|
|
653
|
-
|
|
704
|
+
unloadDoc(docId: string): Promise<void>;
|
|
705
|
+
flush(): Promise<void>;
|
|
654
706
|
uploadAsset(params: UploadAssetOptions): Promise<AssetId>;
|
|
655
|
-
whenDocInSyncWithRemote(docId: string): Promise<void>;
|
|
656
707
|
linkAsset(docId: string, params: LinkAssetOptions): Promise<AssetId>;
|
|
657
708
|
fetchAsset(assetId: AssetId): Promise<AssetDownload>;
|
|
658
709
|
unlinkAsset(docId: string, assetId: AssetId): Promise<void>;
|
|
@@ -660,7 +711,9 @@ declare class LoroRepo<Meta extends JsonObject = JsonObject> {
|
|
|
660
711
|
ensureAsset(assetId: AssetId): Promise<AssetDownload>;
|
|
661
712
|
gcAssets(options?: GarbageCollectionOptions): Promise<number>;
|
|
662
713
|
private persistMeta;
|
|
714
|
+
get destroyed(): boolean;
|
|
715
|
+
destroy(): Promise<void>;
|
|
663
716
|
}
|
|
664
717
|
//#endregion
|
|
665
|
-
export { AssetContent, AssetDownload, AssetId, AssetTransportAdapter, AssetUploadMetadata, BroadcastChannelTransportAdapter, type BroadcastChannelTransportOptions, FileSystemStorageAdaptor, type FileSystemStorageAdaptorOptions, GarbageCollectionOptions, IndexedDBStorageAdaptor, type IndexedDBStorageAdaptorOptions, JsonObject, JsonValue, LinkAssetOptions, ListDocQuery, LoroRepo, LoroRepoOptions, RepoAssetMetadata, RepoDocHandle, RepoDocMeta, RepoEvent, RepoEventBy, RepoEventFilter, RepoEventListener, type RepoSyncOptions, RepoWatchHandle, StorageAdapter, StorageSavePayload, SyncScope, TransportAdapter, type TransportJoinParams, type TransportSubscription, TransportSyncRequest, type TransportSyncResult, UploadAssetOptions,
|
|
718
|
+
export { AssetContent, AssetDownload, AssetId, AssetTransportAdapter, AssetUploadMetadata, BroadcastChannelTransportAdapter, type BroadcastChannelTransportOptions, FileSystemStorageAdaptor, type FileSystemStorageAdaptorOptions, GarbageCollectionOptions, IndexedDBStorageAdaptor, type IndexedDBStorageAdaptorOptions, JsonObject, JsonValue, LinkAssetOptions, ListDocQuery, LoroRepo, LoroRepoOptions, RepoAssetMetadata, RepoDocHandle, RepoDocMeta, RepoEvent, RepoEventBy, RepoEventFilter, RepoEventKind, RepoEventListener, RepoEventType, type RepoSyncOptions, RepoWatchHandle, StorageAdapter, StorageSavePayload, SyncScope, TransportAdapter, type TransportJoinParams, type TransportSubscription, TransportSyncRequest, type TransportSyncResult, UploadAssetOptions, WebSocketTransportAdapter, type WebSocketTransportOptions };
|
|
666
719
|
//# sourceMappingURL=index.d.ts.map
|