loro-repo 0.3.0 → 0.5.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 +1101 -1191
- package/dist/index.cjs.map +1 -1
- package/dist/{index-DsCaL9JX.d.cts → index.d.cts} +117 -136
- package/dist/{index-tq65q3qY.d.ts → index.d.ts} +118 -137
- package/dist/index.js +1084 -1178
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
|
@@ -1,10 +1,60 @@
|
|
|
1
1
|
import { Flock } from "@loro-dev/flock";
|
|
2
2
|
import { Frontiers, LoroDoc } from "loro-crdt";
|
|
3
|
-
import {
|
|
3
|
+
import { RoomId } from "loro-protocol";
|
|
4
|
+
import { LoroAdaptorConfig } from "loro-adaptors/loro";
|
|
4
5
|
import { LoroWebsocketClientOptions } from "loro-websocket";
|
|
5
|
-
import { FlockAdaptorConfig } from "loro-adaptors";
|
|
6
6
|
|
|
7
7
|
//#region src/types.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Construction options for creating a `LoroRepo` instance.
|
|
10
|
+
*/
|
|
11
|
+
interface LoroRepoOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Transport adapter responsible for fetching and pushing CRDT bundles.
|
|
14
|
+
* Omit when operating fully offline or within pure tests.
|
|
15
|
+
*/
|
|
16
|
+
readonly transportAdapter?: TransportAdapter;
|
|
17
|
+
/**
|
|
18
|
+
* Storage adapter that hydrates snapshots and persists incremental updates.
|
|
19
|
+
*/
|
|
20
|
+
readonly storageAdapter?: StorageAdapter;
|
|
21
|
+
/**
|
|
22
|
+
* Optional adapter that moves asset payloads while keeping metadata in sync.
|
|
23
|
+
*/
|
|
24
|
+
readonly assetTransportAdapter?: AssetTransportAdapter;
|
|
25
|
+
/**
|
|
26
|
+
* Debounce duration in milliseconds before persisting document frontier metadata
|
|
27
|
+
* after local edits. Defaults to 1000 ms when omitted.
|
|
28
|
+
*/
|
|
29
|
+
readonly docFrontierDebounceMs?: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Persists metadata, documents, and asset payloads on behalf of the repo.
|
|
33
|
+
*/
|
|
34
|
+
interface StorageAdapter {
|
|
35
|
+
init?(): Promise<void>;
|
|
36
|
+
close?(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Writes document snapshots, queued updates, assets, or meta bundles to durable storage.
|
|
39
|
+
*/
|
|
40
|
+
save(payload: StorageSavePayload): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Optionally deletes an asset payload during garbage collection.
|
|
43
|
+
*/
|
|
44
|
+
deleteAsset?(assetId: AssetId): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Loads a stored document by hydrating the persisted snapshot and replaying any queued updates.
|
|
47
|
+
*/
|
|
48
|
+
loadDoc(docId: string): Promise<LoroDoc | undefined>;
|
|
49
|
+
/**
|
|
50
|
+
* Loads the repository-level metadata replica, if present.
|
|
51
|
+
*/
|
|
52
|
+
loadMeta(): Promise<Flock | undefined>;
|
|
53
|
+
/**
|
|
54
|
+
* Loads a cached asset payload, if present.
|
|
55
|
+
*/
|
|
56
|
+
loadAsset(assetId: AssetId): Promise<Uint8Array | undefined>;
|
|
57
|
+
}
|
|
8
58
|
type GlobalBlob = typeof globalThis extends {
|
|
9
59
|
Blob: infer B;
|
|
10
60
|
} ? B : {
|
|
@@ -39,29 +89,6 @@ type JsonObject = {
|
|
|
39
89
|
* Synchronisation lanes available to repo consumers.
|
|
40
90
|
*/
|
|
41
91
|
type SyncScope = "meta" | "doc" | "full";
|
|
42
|
-
/**
|
|
43
|
-
* Construction options for creating a `LoroRepo` instance.
|
|
44
|
-
*/
|
|
45
|
-
interface LoroRepoOptions<_Meta extends JsonObject = JsonObject> {
|
|
46
|
-
/**
|
|
47
|
-
* Transport adapter responsible for fetching and pushing CRDT bundles.
|
|
48
|
-
* Omit when operating fully offline or within pure tests.
|
|
49
|
-
*/
|
|
50
|
-
readonly transportAdapter?: TransportAdapter;
|
|
51
|
-
/**
|
|
52
|
-
* Storage adapter that hydrates snapshots and persists incremental updates.
|
|
53
|
-
*/
|
|
54
|
-
readonly storageAdapter?: StorageAdapter;
|
|
55
|
-
/**
|
|
56
|
-
* Optional adapter that moves asset payloads while keeping metadata in sync.
|
|
57
|
-
*/
|
|
58
|
-
readonly assetTransportAdapter?: AssetTransportAdapter;
|
|
59
|
-
/**
|
|
60
|
-
* Debounce duration in milliseconds before persisting document frontier metadata
|
|
61
|
-
* after local edits. Defaults to 1000 ms when omitted.
|
|
62
|
-
*/
|
|
63
|
-
readonly docFrontierDebounceMs?: number;
|
|
64
|
-
}
|
|
65
92
|
/**
|
|
66
93
|
* Parameters accepted by `LoroRepo.sync`.
|
|
67
94
|
*/
|
|
@@ -147,45 +174,6 @@ interface TransportAdapter {
|
|
|
147
174
|
* Subscribes to live document updates, returning a cleanup handle.
|
|
148
175
|
*/
|
|
149
176
|
joinDocRoom(docId: string, loroDoc: LoroDoc, params?: TransportJoinParams): TransportSubscription;
|
|
150
|
-
/**
|
|
151
|
-
* Optional callback invoked upon successful join responses.
|
|
152
|
-
*/
|
|
153
|
-
handleJoinResponse?(response: JoinResponseOk): void;
|
|
154
|
-
/**
|
|
155
|
-
* Optional callback surfaced when joining a room fails.
|
|
156
|
-
*/
|
|
157
|
-
handleJoinError?(error: JoinError): void;
|
|
158
|
-
/**
|
|
159
|
-
* Optional callback for update-level failures (e.g., decoding errors).
|
|
160
|
-
*/
|
|
161
|
-
handleUpdateError?(error: UpdateError): void;
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Persists metadata, documents, and asset payloads on behalf of the repo.
|
|
165
|
-
*/
|
|
166
|
-
interface StorageAdapter {
|
|
167
|
-
init?(): Promise<void>;
|
|
168
|
-
close?(): void;
|
|
169
|
-
/**
|
|
170
|
-
* Writes document snapshots, queued updates, assets, or meta bundles to durable storage.
|
|
171
|
-
*/
|
|
172
|
-
save(payload: StorageSavePayload): Promise<void>;
|
|
173
|
-
/**
|
|
174
|
-
* Optionally deletes an asset payload during garbage collection.
|
|
175
|
-
*/
|
|
176
|
-
deleteAsset?(assetId: AssetId): Promise<void>;
|
|
177
|
-
/**
|
|
178
|
-
* Loads a stored document by hydrating the persisted snapshot and replaying any queued updates.
|
|
179
|
-
*/
|
|
180
|
-
loadDoc(docId: string): Promise<LoroDoc | undefined>;
|
|
181
|
-
/**
|
|
182
|
-
* Loads the repository-level metadata replica, if present.
|
|
183
|
-
*/
|
|
184
|
-
loadMeta(): Promise<Flock | undefined>;
|
|
185
|
-
/**
|
|
186
|
-
* Loads a cached asset payload, if present.
|
|
187
|
-
*/
|
|
188
|
-
loadAsset(assetId: AssetId): Promise<Uint8Array | undefined>;
|
|
189
177
|
}
|
|
190
178
|
/**
|
|
191
179
|
* Union describing the kinds of payloads persisted via the storage adapter.
|
|
@@ -428,74 +416,6 @@ interface RepoEventFilter<Meta extends JsonObject = JsonObject> {
|
|
|
428
416
|
readonly by?: ReadonlyArray<RepoEventBy>;
|
|
429
417
|
}
|
|
430
418
|
//#endregion
|
|
431
|
-
//#region src/loro-adaptor.d.ts
|
|
432
|
-
type RepoFlockAdaptorConfig = FlockAdaptorConfig;
|
|
433
|
-
//#endregion
|
|
434
|
-
//#region src/transport/websocket.d.ts
|
|
435
|
-
interface WebSocketTransportOptions {
|
|
436
|
-
/**
|
|
437
|
-
* WebSocket endpoint provided to the loro-websocket client.
|
|
438
|
-
*/
|
|
439
|
-
readonly url: string;
|
|
440
|
-
/**
|
|
441
|
-
* Optional loro-websocket client configuration.
|
|
442
|
-
*/
|
|
443
|
-
readonly client?: Omit<LoroWebsocketClientOptions, "url">;
|
|
444
|
-
/**
|
|
445
|
-
* Metadata room identifier. When omitted, metadata synchronisation is disabled.
|
|
446
|
-
*/
|
|
447
|
-
readonly metadataRoomId?: string;
|
|
448
|
-
/**
|
|
449
|
-
* Overrides the CRDT type advertised for the metadata room (defaults to `%FLO`).
|
|
450
|
-
* Only `%FLO` is supported.
|
|
451
|
-
*/
|
|
452
|
-
readonly metadataCrdtType?: string;
|
|
453
|
-
/**
|
|
454
|
-
* Optional adaptor configuration for metadata joins.
|
|
455
|
-
*/
|
|
456
|
-
readonly metadataAdaptorConfig?: RepoFlockAdaptorConfig;
|
|
457
|
-
/**
|
|
458
|
-
* Static auth payload for metadata joins.
|
|
459
|
-
*/
|
|
460
|
-
readonly metadataAuth?: Uint8Array;
|
|
461
|
-
/**
|
|
462
|
-
* Factory that maps document ids to room identifiers. Defaults to the doc id.
|
|
463
|
-
*/
|
|
464
|
-
readonly docRoomId?: (docId: string) => string;
|
|
465
|
-
/**
|
|
466
|
-
* Optional auth provider for document joins.
|
|
467
|
-
*/
|
|
468
|
-
readonly docAuth?: (docId: string) => Uint8Array | undefined;
|
|
469
|
-
}
|
|
470
|
-
/**
|
|
471
|
-
* loro-websocket backed {@link TransportAdapter} implementation for LoroRepo.
|
|
472
|
-
*/
|
|
473
|
-
declare class WebSocketTransportAdapter implements TransportAdapter {
|
|
474
|
-
private readonly options;
|
|
475
|
-
private client?;
|
|
476
|
-
private metadataSession?;
|
|
477
|
-
private readonly docSessions;
|
|
478
|
-
constructor(options: WebSocketTransportOptions);
|
|
479
|
-
connect(_options?: {
|
|
480
|
-
timeout?: number;
|
|
481
|
-
}): Promise<void>;
|
|
482
|
-
close(): Promise<void>;
|
|
483
|
-
isConnected(): boolean;
|
|
484
|
-
syncMeta(flock: Flock, options?: {
|
|
485
|
-
timeout?: number;
|
|
486
|
-
}): Promise<TransportSyncResult>;
|
|
487
|
-
joinMetaRoom(flock: Flock, params?: TransportJoinParams): TransportSubscription;
|
|
488
|
-
syncDoc(docId: string, doc: LoroDoc, options?: {
|
|
489
|
-
timeout?: number;
|
|
490
|
-
}): Promise<TransportSyncResult>;
|
|
491
|
-
joinDocRoom(docId: string, doc: LoroDoc, params?: TransportJoinParams): TransportSubscription;
|
|
492
|
-
private ensureClient;
|
|
493
|
-
private ensureMetadataSession;
|
|
494
|
-
private teardownMetadataSession;
|
|
495
|
-
private ensureDocSession;
|
|
496
|
-
private leaveDocSession;
|
|
497
|
-
}
|
|
498
|
-
//#endregion
|
|
499
419
|
//#region src/transport/broadcast-channel.d.ts
|
|
500
420
|
interface BroadcastChannelTransportOptions {
|
|
501
421
|
/**
|
|
@@ -626,9 +546,70 @@ declare class FileSystemStorageAdaptor implements StorageAdapter {
|
|
|
626
546
|
private assetPath;
|
|
627
547
|
}
|
|
628
548
|
//#endregion
|
|
549
|
+
//#region src/transport/websocket.d.ts
|
|
550
|
+
interface WebSocketTransportOptions {
|
|
551
|
+
/**
|
|
552
|
+
* WebSocket endpoint provided to the loro-websocket client.
|
|
553
|
+
*/
|
|
554
|
+
readonly url: string;
|
|
555
|
+
/**
|
|
556
|
+
* Metadata room identifier. Defaults to "repo:meta".
|
|
557
|
+
*/
|
|
558
|
+
readonly metadataRoomId?: string;
|
|
559
|
+
/**
|
|
560
|
+
* Optional loro-websocket client configuration.
|
|
561
|
+
*/
|
|
562
|
+
readonly client?: Omit<LoroWebsocketClientOptions, "url">;
|
|
563
|
+
/**
|
|
564
|
+
* Optional adaptor configuration for metadata joins.
|
|
565
|
+
*/
|
|
566
|
+
readonly metadataAdaptorConfig?: LoroAdaptorConfig;
|
|
567
|
+
/**
|
|
568
|
+
* Static auth payload for metadata joins.
|
|
569
|
+
*/
|
|
570
|
+
readonly metadataAuth?: Uint8Array | (() => Promise<Uint8Array>);
|
|
571
|
+
/**
|
|
572
|
+
* Factory that maps document ids to room identifiers. Defaults to the doc id.
|
|
573
|
+
*/
|
|
574
|
+
readonly docRoomId?: (docId: string) => string;
|
|
575
|
+
/**
|
|
576
|
+
* Optional auth provider for document joins.
|
|
577
|
+
*/
|
|
578
|
+
readonly docAuth?: (docId: string) => Promise<Uint8Array>;
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* loro-websocket backed {@link TransportAdapter} implementation for LoroRepo.
|
|
582
|
+
* It uses loro-protocol as the underlying protocol for the transport.
|
|
583
|
+
*/
|
|
584
|
+
declare class WebSocketTransportAdapter implements TransportAdapter {
|
|
585
|
+
private readonly options;
|
|
586
|
+
private client?;
|
|
587
|
+
private metadataSession?;
|
|
588
|
+
private readonly docSessions;
|
|
589
|
+
constructor(options: WebSocketTransportOptions);
|
|
590
|
+
connect(_options?: {
|
|
591
|
+
timeout?: number;
|
|
592
|
+
}): Promise<void>;
|
|
593
|
+
close(): Promise<void>;
|
|
594
|
+
isConnected(): boolean;
|
|
595
|
+
syncMeta(flock: Flock, options?: {
|
|
596
|
+
timeout?: number;
|
|
597
|
+
}): Promise<TransportSyncResult>;
|
|
598
|
+
joinMetaRoom(flock: Flock, params?: TransportJoinParams): TransportSubscription;
|
|
599
|
+
syncDoc(docId: string, doc: LoroDoc, options?: {
|
|
600
|
+
timeout?: number;
|
|
601
|
+
}): Promise<TransportSyncResult>;
|
|
602
|
+
joinDocRoom(docId: string, doc: LoroDoc, params?: TransportJoinParams): TransportSubscription;
|
|
603
|
+
private ensureClient;
|
|
604
|
+
private ensureMetadataSession;
|
|
605
|
+
private teardownMetadataSession;
|
|
606
|
+
private ensureDocSession;
|
|
607
|
+
private leaveDocSession;
|
|
608
|
+
}
|
|
609
|
+
//#endregion
|
|
629
610
|
//#region src/index.d.ts
|
|
630
611
|
declare class LoroRepo<Meta extends JsonObject = JsonObject> {
|
|
631
|
-
readonly options: LoroRepoOptions
|
|
612
|
+
readonly options: LoroRepoOptions;
|
|
632
613
|
private _destroyed;
|
|
633
614
|
private readonly transport?;
|
|
634
615
|
private readonly storage?;
|
|
@@ -642,7 +623,7 @@ declare class LoroRepo<Meta extends JsonObject = JsonObject> {
|
|
|
642
623
|
private readonly state;
|
|
643
624
|
private readonly syncRunner;
|
|
644
625
|
private constructor();
|
|
645
|
-
static create<Meta extends JsonObject = JsonObject>(options: LoroRepoOptions
|
|
626
|
+
static create<Meta extends JsonObject = JsonObject>(options: LoroRepoOptions): Promise<LoroRepo<Meta>>;
|
|
646
627
|
/**
|
|
647
628
|
* Load meta from storage.
|
|
648
629
|
*
|
|
@@ -714,5 +695,5 @@ declare class LoroRepo<Meta extends JsonObject = JsonObject> {
|
|
|
714
695
|
destroy(): Promise<void>;
|
|
715
696
|
}
|
|
716
697
|
//#endregion
|
|
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, WebSocketTransportOptions };
|
|
718
|
-
//# sourceMappingURL=index
|
|
698
|
+
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 };
|
|
699
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1,10 +1,60 @@
|
|
|
1
1
|
import { Flock } from "@loro-dev/flock";
|
|
2
|
-
import { FlockAdaptor, FlockAdaptorConfig, LoroAdaptor } from "loro-adaptors";
|
|
3
|
-
import { JoinError, JoinResponseOk, RoomId, UpdateError } from "loro-protocol";
|
|
4
|
-
import { LoroWebsocketClientOptions } from "loro-websocket";
|
|
5
2
|
import { Frontiers, LoroDoc } from "loro-crdt";
|
|
3
|
+
import { LoroAdaptorConfig } from "loro-adaptors/loro";
|
|
4
|
+
import { RoomId } from "loro-protocol";
|
|
5
|
+
import { LoroWebsocketClientOptions } from "loro-websocket";
|
|
6
6
|
|
|
7
7
|
//#region src/types.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Construction options for creating a `LoroRepo` instance.
|
|
10
|
+
*/
|
|
11
|
+
interface LoroRepoOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Transport adapter responsible for fetching and pushing CRDT bundles.
|
|
14
|
+
* Omit when operating fully offline or within pure tests.
|
|
15
|
+
*/
|
|
16
|
+
readonly transportAdapter?: TransportAdapter;
|
|
17
|
+
/**
|
|
18
|
+
* Storage adapter that hydrates snapshots and persists incremental updates.
|
|
19
|
+
*/
|
|
20
|
+
readonly storageAdapter?: StorageAdapter;
|
|
21
|
+
/**
|
|
22
|
+
* Optional adapter that moves asset payloads while keeping metadata in sync.
|
|
23
|
+
*/
|
|
24
|
+
readonly assetTransportAdapter?: AssetTransportAdapter;
|
|
25
|
+
/**
|
|
26
|
+
* Debounce duration in milliseconds before persisting document frontier metadata
|
|
27
|
+
* after local edits. Defaults to 1000 ms when omitted.
|
|
28
|
+
*/
|
|
29
|
+
readonly docFrontierDebounceMs?: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Persists metadata, documents, and asset payloads on behalf of the repo.
|
|
33
|
+
*/
|
|
34
|
+
interface StorageAdapter {
|
|
35
|
+
init?(): Promise<void>;
|
|
36
|
+
close?(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Writes document snapshots, queued updates, assets, or meta bundles to durable storage.
|
|
39
|
+
*/
|
|
40
|
+
save(payload: StorageSavePayload): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Optionally deletes an asset payload during garbage collection.
|
|
43
|
+
*/
|
|
44
|
+
deleteAsset?(assetId: AssetId): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Loads a stored document by hydrating the persisted snapshot and replaying any queued updates.
|
|
47
|
+
*/
|
|
48
|
+
loadDoc(docId: string): Promise<LoroDoc | undefined>;
|
|
49
|
+
/**
|
|
50
|
+
* Loads the repository-level metadata replica, if present.
|
|
51
|
+
*/
|
|
52
|
+
loadMeta(): Promise<Flock | undefined>;
|
|
53
|
+
/**
|
|
54
|
+
* Loads a cached asset payload, if present.
|
|
55
|
+
*/
|
|
56
|
+
loadAsset(assetId: AssetId): Promise<Uint8Array | undefined>;
|
|
57
|
+
}
|
|
8
58
|
type GlobalBlob = typeof globalThis extends {
|
|
9
59
|
Blob: infer B;
|
|
10
60
|
} ? B : {
|
|
@@ -39,29 +89,6 @@ type JsonObject = {
|
|
|
39
89
|
* Synchronisation lanes available to repo consumers.
|
|
40
90
|
*/
|
|
41
91
|
type SyncScope = "meta" | "doc" | "full";
|
|
42
|
-
/**
|
|
43
|
-
* Construction options for creating a `LoroRepo` instance.
|
|
44
|
-
*/
|
|
45
|
-
interface LoroRepoOptions<_Meta extends JsonObject = JsonObject> {
|
|
46
|
-
/**
|
|
47
|
-
* Transport adapter responsible for fetching and pushing CRDT bundles.
|
|
48
|
-
* Omit when operating fully offline or within pure tests.
|
|
49
|
-
*/
|
|
50
|
-
readonly transportAdapter?: TransportAdapter;
|
|
51
|
-
/**
|
|
52
|
-
* Storage adapter that hydrates snapshots and persists incremental updates.
|
|
53
|
-
*/
|
|
54
|
-
readonly storageAdapter?: StorageAdapter;
|
|
55
|
-
/**
|
|
56
|
-
* Optional adapter that moves asset payloads while keeping metadata in sync.
|
|
57
|
-
*/
|
|
58
|
-
readonly assetTransportAdapter?: AssetTransportAdapter;
|
|
59
|
-
/**
|
|
60
|
-
* Debounce duration in milliseconds before persisting document frontier metadata
|
|
61
|
-
* after local edits. Defaults to 1000 ms when omitted.
|
|
62
|
-
*/
|
|
63
|
-
readonly docFrontierDebounceMs?: number;
|
|
64
|
-
}
|
|
65
92
|
/**
|
|
66
93
|
* Parameters accepted by `LoroRepo.sync`.
|
|
67
94
|
*/
|
|
@@ -147,45 +174,6 @@ interface TransportAdapter {
|
|
|
147
174
|
* Subscribes to live document updates, returning a cleanup handle.
|
|
148
175
|
*/
|
|
149
176
|
joinDocRoom(docId: string, loroDoc: LoroDoc, params?: TransportJoinParams): TransportSubscription;
|
|
150
|
-
/**
|
|
151
|
-
* Optional callback invoked upon successful join responses.
|
|
152
|
-
*/
|
|
153
|
-
handleJoinResponse?(response: JoinResponseOk): void;
|
|
154
|
-
/**
|
|
155
|
-
* Optional callback surfaced when joining a room fails.
|
|
156
|
-
*/
|
|
157
|
-
handleJoinError?(error: JoinError): void;
|
|
158
|
-
/**
|
|
159
|
-
* Optional callback for update-level failures (e.g., decoding errors).
|
|
160
|
-
*/
|
|
161
|
-
handleUpdateError?(error: UpdateError): void;
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Persists metadata, documents, and asset payloads on behalf of the repo.
|
|
165
|
-
*/
|
|
166
|
-
interface StorageAdapter {
|
|
167
|
-
init?(): Promise<void>;
|
|
168
|
-
close?(): void;
|
|
169
|
-
/**
|
|
170
|
-
* Writes document snapshots, queued updates, assets, or meta bundles to durable storage.
|
|
171
|
-
*/
|
|
172
|
-
save(payload: StorageSavePayload): Promise<void>;
|
|
173
|
-
/**
|
|
174
|
-
* Optionally deletes an asset payload during garbage collection.
|
|
175
|
-
*/
|
|
176
|
-
deleteAsset?(assetId: AssetId): Promise<void>;
|
|
177
|
-
/**
|
|
178
|
-
* Loads a stored document by hydrating the persisted snapshot and replaying any queued updates.
|
|
179
|
-
*/
|
|
180
|
-
loadDoc(docId: string): Promise<LoroDoc | undefined>;
|
|
181
|
-
/**
|
|
182
|
-
* Loads the repository-level metadata replica, if present.
|
|
183
|
-
*/
|
|
184
|
-
loadMeta(): Promise<Flock | undefined>;
|
|
185
|
-
/**
|
|
186
|
-
* Loads a cached asset payload, if present.
|
|
187
|
-
*/
|
|
188
|
-
loadAsset(assetId: AssetId): Promise<Uint8Array | undefined>;
|
|
189
177
|
}
|
|
190
178
|
/**
|
|
191
179
|
* Union describing the kinds of payloads persisted via the storage adapter.
|
|
@@ -428,74 +416,6 @@ interface RepoEventFilter<Meta extends JsonObject = JsonObject> {
|
|
|
428
416
|
readonly by?: ReadonlyArray<RepoEventBy>;
|
|
429
417
|
}
|
|
430
418
|
//#endregion
|
|
431
|
-
//#region src/loro-adaptor.d.ts
|
|
432
|
-
type RepoFlockAdaptorConfig = FlockAdaptorConfig;
|
|
433
|
-
//#endregion
|
|
434
|
-
//#region src/transport/websocket.d.ts
|
|
435
|
-
interface WebSocketTransportOptions {
|
|
436
|
-
/**
|
|
437
|
-
* WebSocket endpoint provided to the loro-websocket client.
|
|
438
|
-
*/
|
|
439
|
-
readonly url: string;
|
|
440
|
-
/**
|
|
441
|
-
* Optional loro-websocket client configuration.
|
|
442
|
-
*/
|
|
443
|
-
readonly client?: Omit<LoroWebsocketClientOptions, "url">;
|
|
444
|
-
/**
|
|
445
|
-
* Metadata room identifier. When omitted, metadata synchronisation is disabled.
|
|
446
|
-
*/
|
|
447
|
-
readonly metadataRoomId?: string;
|
|
448
|
-
/**
|
|
449
|
-
* Overrides the CRDT type advertised for the metadata room (defaults to `%FLO`).
|
|
450
|
-
* Only `%FLO` is supported.
|
|
451
|
-
*/
|
|
452
|
-
readonly metadataCrdtType?: string;
|
|
453
|
-
/**
|
|
454
|
-
* Optional adaptor configuration for metadata joins.
|
|
455
|
-
*/
|
|
456
|
-
readonly metadataAdaptorConfig?: RepoFlockAdaptorConfig;
|
|
457
|
-
/**
|
|
458
|
-
* Static auth payload for metadata joins.
|
|
459
|
-
*/
|
|
460
|
-
readonly metadataAuth?: Uint8Array;
|
|
461
|
-
/**
|
|
462
|
-
* Factory that maps document ids to room identifiers. Defaults to the doc id.
|
|
463
|
-
*/
|
|
464
|
-
readonly docRoomId?: (docId: string) => string;
|
|
465
|
-
/**
|
|
466
|
-
* Optional auth provider for document joins.
|
|
467
|
-
*/
|
|
468
|
-
readonly docAuth?: (docId: string) => Uint8Array | undefined;
|
|
469
|
-
}
|
|
470
|
-
/**
|
|
471
|
-
* loro-websocket backed {@link TransportAdapter} implementation for LoroRepo.
|
|
472
|
-
*/
|
|
473
|
-
declare class WebSocketTransportAdapter implements TransportAdapter {
|
|
474
|
-
private readonly options;
|
|
475
|
-
private client?;
|
|
476
|
-
private metadataSession?;
|
|
477
|
-
private readonly docSessions;
|
|
478
|
-
constructor(options: WebSocketTransportOptions);
|
|
479
|
-
connect(_options?: {
|
|
480
|
-
timeout?: number;
|
|
481
|
-
}): Promise<void>;
|
|
482
|
-
close(): Promise<void>;
|
|
483
|
-
isConnected(): boolean;
|
|
484
|
-
syncMeta(flock: Flock, options?: {
|
|
485
|
-
timeout?: number;
|
|
486
|
-
}): Promise<TransportSyncResult>;
|
|
487
|
-
joinMetaRoom(flock: Flock, params?: TransportJoinParams): TransportSubscription;
|
|
488
|
-
syncDoc(docId: string, doc: LoroDoc, options?: {
|
|
489
|
-
timeout?: number;
|
|
490
|
-
}): Promise<TransportSyncResult>;
|
|
491
|
-
joinDocRoom(docId: string, doc: LoroDoc, params?: TransportJoinParams): TransportSubscription;
|
|
492
|
-
private ensureClient;
|
|
493
|
-
private ensureMetadataSession;
|
|
494
|
-
private teardownMetadataSession;
|
|
495
|
-
private ensureDocSession;
|
|
496
|
-
private leaveDocSession;
|
|
497
|
-
}
|
|
498
|
-
//#endregion
|
|
499
419
|
//#region src/transport/broadcast-channel.d.ts
|
|
500
420
|
interface BroadcastChannelTransportOptions {
|
|
501
421
|
/**
|
|
@@ -626,9 +546,70 @@ declare class FileSystemStorageAdaptor implements StorageAdapter {
|
|
|
626
546
|
private assetPath;
|
|
627
547
|
}
|
|
628
548
|
//#endregion
|
|
549
|
+
//#region src/transport/websocket.d.ts
|
|
550
|
+
interface WebSocketTransportOptions {
|
|
551
|
+
/**
|
|
552
|
+
* WebSocket endpoint provided to the loro-websocket client.
|
|
553
|
+
*/
|
|
554
|
+
readonly url: string;
|
|
555
|
+
/**
|
|
556
|
+
* Metadata room identifier. Defaults to "repo:meta".
|
|
557
|
+
*/
|
|
558
|
+
readonly metadataRoomId?: string;
|
|
559
|
+
/**
|
|
560
|
+
* Optional loro-websocket client configuration.
|
|
561
|
+
*/
|
|
562
|
+
readonly client?: Omit<LoroWebsocketClientOptions, "url">;
|
|
563
|
+
/**
|
|
564
|
+
* Optional adaptor configuration for metadata joins.
|
|
565
|
+
*/
|
|
566
|
+
readonly metadataAdaptorConfig?: LoroAdaptorConfig;
|
|
567
|
+
/**
|
|
568
|
+
* Static auth payload for metadata joins.
|
|
569
|
+
*/
|
|
570
|
+
readonly metadataAuth?: Uint8Array | (() => Promise<Uint8Array>);
|
|
571
|
+
/**
|
|
572
|
+
* Factory that maps document ids to room identifiers. Defaults to the doc id.
|
|
573
|
+
*/
|
|
574
|
+
readonly docRoomId?: (docId: string) => string;
|
|
575
|
+
/**
|
|
576
|
+
* Optional auth provider for document joins.
|
|
577
|
+
*/
|
|
578
|
+
readonly docAuth?: (docId: string) => Promise<Uint8Array>;
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* loro-websocket backed {@link TransportAdapter} implementation for LoroRepo.
|
|
582
|
+
* It uses loro-protocol as the underlying protocol for the transport.
|
|
583
|
+
*/
|
|
584
|
+
declare class WebSocketTransportAdapter implements TransportAdapter {
|
|
585
|
+
private readonly options;
|
|
586
|
+
private client?;
|
|
587
|
+
private metadataSession?;
|
|
588
|
+
private readonly docSessions;
|
|
589
|
+
constructor(options: WebSocketTransportOptions);
|
|
590
|
+
connect(_options?: {
|
|
591
|
+
timeout?: number;
|
|
592
|
+
}): Promise<void>;
|
|
593
|
+
close(): Promise<void>;
|
|
594
|
+
isConnected(): boolean;
|
|
595
|
+
syncMeta(flock: Flock, options?: {
|
|
596
|
+
timeout?: number;
|
|
597
|
+
}): Promise<TransportSyncResult>;
|
|
598
|
+
joinMetaRoom(flock: Flock, params?: TransportJoinParams): TransportSubscription;
|
|
599
|
+
syncDoc(docId: string, doc: LoroDoc, options?: {
|
|
600
|
+
timeout?: number;
|
|
601
|
+
}): Promise<TransportSyncResult>;
|
|
602
|
+
joinDocRoom(docId: string, doc: LoroDoc, params?: TransportJoinParams): TransportSubscription;
|
|
603
|
+
private ensureClient;
|
|
604
|
+
private ensureMetadataSession;
|
|
605
|
+
private teardownMetadataSession;
|
|
606
|
+
private ensureDocSession;
|
|
607
|
+
private leaveDocSession;
|
|
608
|
+
}
|
|
609
|
+
//#endregion
|
|
629
610
|
//#region src/index.d.ts
|
|
630
611
|
declare class LoroRepo<Meta extends JsonObject = JsonObject> {
|
|
631
|
-
readonly options: LoroRepoOptions
|
|
612
|
+
readonly options: LoroRepoOptions;
|
|
632
613
|
private _destroyed;
|
|
633
614
|
private readonly transport?;
|
|
634
615
|
private readonly storage?;
|
|
@@ -642,7 +623,7 @@ declare class LoroRepo<Meta extends JsonObject = JsonObject> {
|
|
|
642
623
|
private readonly state;
|
|
643
624
|
private readonly syncRunner;
|
|
644
625
|
private constructor();
|
|
645
|
-
static create<Meta extends JsonObject = JsonObject>(options: LoroRepoOptions
|
|
626
|
+
static create<Meta extends JsonObject = JsonObject>(options: LoroRepoOptions): Promise<LoroRepo<Meta>>;
|
|
646
627
|
/**
|
|
647
628
|
* Load meta from storage.
|
|
648
629
|
*
|
|
@@ -714,5 +695,5 @@ declare class LoroRepo<Meta extends JsonObject = JsonObject> {
|
|
|
714
695
|
destroy(): Promise<void>;
|
|
715
696
|
}
|
|
716
697
|
//#endregion
|
|
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, WebSocketTransportOptions };
|
|
718
|
-
//# sourceMappingURL=index
|
|
698
|
+
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 };
|
|
699
|
+
//# sourceMappingURL=index.d.ts.map
|