loro-repo 0.0.0 → 0.2.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 +3 -0
- package/dist/index.cjs +1293 -807
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +59 -63
- package/dist/index.d.ts +60 -64
- package/dist/index.js +1272 -811
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -15,6 +15,14 @@ type GlobalBlob = typeof globalThis extends {
|
|
|
15
15
|
* Binary content accepted by asset ingestion helpers.
|
|
16
16
|
*/
|
|
17
17
|
type AssetContent = GlobalBlob | ArrayBufferView | ReadableStream<Uint8Array>;
|
|
18
|
+
interface RepoAssetMetadata {
|
|
19
|
+
readonly assetId: AssetId;
|
|
20
|
+
readonly size: number;
|
|
21
|
+
readonly createdAt: number;
|
|
22
|
+
readonly mime?: string;
|
|
23
|
+
readonly policy?: string;
|
|
24
|
+
readonly tag?: string;
|
|
25
|
+
}
|
|
18
26
|
/**
|
|
19
27
|
* JSON-compatible leaf value used for document metadata.
|
|
20
28
|
*/
|
|
@@ -565,52 +573,66 @@ declare class IndexedDBStorageAdaptor implements StorageAdapter {
|
|
|
565
573
|
private createError;
|
|
566
574
|
}
|
|
567
575
|
//#endregion
|
|
568
|
-
//#region src/
|
|
569
|
-
interface
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
readonly
|
|
575
|
-
|
|
576
|
+
//#region src/storage/filesystem.d.ts
|
|
577
|
+
interface FileSystemStorageAdaptorOptions {
|
|
578
|
+
/**
|
|
579
|
+
* Base directory where metadata, document snapshots, and assets will be stored.
|
|
580
|
+
* Defaults to `.loro-repo` inside the current working directory.
|
|
581
|
+
*/
|
|
582
|
+
readonly baseDir?: string;
|
|
583
|
+
/**
|
|
584
|
+
* Subdirectory dedicated to document persistence. Defaults to `docs`.
|
|
585
|
+
*/
|
|
586
|
+
readonly docsDirName?: string;
|
|
587
|
+
/**
|
|
588
|
+
* Subdirectory dedicated to asset blobs. Defaults to `assets`.
|
|
589
|
+
*/
|
|
590
|
+
readonly assetsDirName?: string;
|
|
591
|
+
/**
|
|
592
|
+
* File name for the metadata snapshot bundle. Defaults to `meta.json`.
|
|
593
|
+
*/
|
|
594
|
+
readonly metaFileName?: string;
|
|
576
595
|
}
|
|
596
|
+
declare class FileSystemStorageAdaptor implements StorageAdapter {
|
|
597
|
+
private readonly baseDir;
|
|
598
|
+
private readonly docsDir;
|
|
599
|
+
private readonly assetsDir;
|
|
600
|
+
private readonly metaPath;
|
|
601
|
+
private readonly initPromise;
|
|
602
|
+
private updateCounter;
|
|
603
|
+
constructor(options?: FileSystemStorageAdaptorOptions);
|
|
604
|
+
save(payload: StorageSavePayload): Promise<void>;
|
|
605
|
+
deleteAsset(assetId: AssetId): Promise<void>;
|
|
606
|
+
loadDoc(docId: string): Promise<LoroDoc | undefined>;
|
|
607
|
+
loadMeta(): Promise<Flock | undefined>;
|
|
608
|
+
loadAsset(assetId: AssetId): Promise<Uint8Array | undefined>;
|
|
609
|
+
private ensureLayout;
|
|
610
|
+
private writeDocSnapshot;
|
|
611
|
+
private enqueueDocUpdate;
|
|
612
|
+
private writeAsset;
|
|
613
|
+
private docDir;
|
|
614
|
+
private docSnapshotPath;
|
|
615
|
+
private docUpdatesDir;
|
|
616
|
+
private assetPath;
|
|
617
|
+
}
|
|
618
|
+
//#endregion
|
|
619
|
+
//#region src/index.d.ts
|
|
577
620
|
declare class LoroRepo<Meta extends JsonObject = JsonObject> {
|
|
578
621
|
readonly options: LoroRepoOptions<Meta>;
|
|
579
622
|
private readonly transport?;
|
|
580
623
|
private readonly storage?;
|
|
581
|
-
private readonly assetTransport?;
|
|
582
624
|
private readonly docFactory;
|
|
583
625
|
private metaFlock;
|
|
584
|
-
private readonly
|
|
585
|
-
private readonly
|
|
586
|
-
private readonly
|
|
587
|
-
private readonly
|
|
588
|
-
private readonly
|
|
589
|
-
private readonly
|
|
590
|
-
private readonly
|
|
591
|
-
private readonly assetToDocRefs;
|
|
592
|
-
private readonly docFrontierKeys;
|
|
593
|
-
private readonly docFrontierUpdates;
|
|
594
|
-
private readonly docPersistedVersions;
|
|
595
|
-
private readonly docFrontierDebounceMs;
|
|
596
|
-
private readonly watchers;
|
|
597
|
-
private readonly eventByStack;
|
|
598
|
-
private metaRoomSubscription?;
|
|
599
|
-
private unsubscribeMetaFlock?;
|
|
600
|
-
private readyPromise?;
|
|
626
|
+
private readonly eventBus;
|
|
627
|
+
private readonly docManager;
|
|
628
|
+
private readonly metadataManager;
|
|
629
|
+
private readonly assetManager;
|
|
630
|
+
private readonly flockHydrator;
|
|
631
|
+
private readonly state;
|
|
632
|
+
private readonly syncRunner;
|
|
601
633
|
constructor(options: LoroRepoOptions<Meta>);
|
|
602
634
|
ready(): Promise<void>;
|
|
603
|
-
private initialize;
|
|
604
635
|
sync(options?: RepoSyncOptions): Promise<void>;
|
|
605
|
-
private refreshDocMetadataEntry;
|
|
606
|
-
private refreshDocAssetsEntry;
|
|
607
|
-
private refreshAssetMetadataEntry;
|
|
608
|
-
private refreshDocFrontierKeys;
|
|
609
|
-
private readDocMetadataFromFlock;
|
|
610
|
-
private readDocAssetsFromFlock;
|
|
611
|
-
private readAssetMetadataFromFlock;
|
|
612
|
-
private handleAssetRemoval;
|
|
613
|
-
private emit;
|
|
614
636
|
joinMetaRoom(params?: TransportJoinParams): Promise<TransportSubscription>;
|
|
615
637
|
joinDocRoom(docId: string, params?: TransportJoinParams): Promise<TransportSubscription>;
|
|
616
638
|
close(): Promise<void>;
|
|
@@ -636,35 +658,9 @@ declare class LoroRepo<Meta extends JsonObject = JsonObject> {
|
|
|
636
658
|
unlinkAsset(docId: string, assetId: AssetId): Promise<void>;
|
|
637
659
|
listAssets(docId: string): Promise<RepoAssetMetadata[]>;
|
|
638
660
|
ensureAsset(assetId: AssetId): Promise<AssetDownload>;
|
|
639
|
-
private createAssetDownload;
|
|
640
|
-
private materializeAsset;
|
|
641
|
-
private updateDocAssetMetadata;
|
|
642
661
|
gcAssets(options?: GarbageCollectionOptions): Promise<number>;
|
|
643
|
-
private onDocHandleClose;
|
|
644
|
-
private ensureDoc;
|
|
645
|
-
private materializeDetachedDoc;
|
|
646
|
-
private exportDocSnapshot;
|
|
647
662
|
private persistMeta;
|
|
648
|
-
private persistDoc;
|
|
649
|
-
private persistDocUpdate;
|
|
650
|
-
private pushEventBy;
|
|
651
|
-
private popEventBy;
|
|
652
|
-
private resolveEventBy;
|
|
653
|
-
private ensureMetaLiveMonitor;
|
|
654
|
-
private applyMetaFlockEvents;
|
|
655
|
-
private registerDoc;
|
|
656
|
-
private ensureDocSubscription;
|
|
657
|
-
private rememberAsset;
|
|
658
|
-
private scheduleDocFrontierUpdate;
|
|
659
|
-
private mergeRepoEventBy;
|
|
660
|
-
private runScheduledDocFrontierUpdate;
|
|
661
|
-
private flushScheduledDocFrontierUpdate;
|
|
662
|
-
private onDocEvent;
|
|
663
|
-
private getAssetMetadata;
|
|
664
|
-
private updateDocFrontiers;
|
|
665
|
-
private hydrateMetadataFromFlock;
|
|
666
|
-
private shouldNotify;
|
|
667
663
|
}
|
|
668
664
|
//#endregion
|
|
669
|
-
export { AssetContent, AssetDownload, AssetId, AssetTransportAdapter, AssetUploadMetadata, BroadcastChannelTransportAdapter, type BroadcastChannelTransportOptions, 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, UpsertDocMetaOptions, WebSocketTransportAdapter, WebSocketTransportOptions };
|
|
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, UpsertDocMetaOptions, WebSocketTransportAdapter, WebSocketTransportOptions };
|
|
670
666
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Flock } from "@loro-dev/flock";
|
|
2
2
|
import { Frontiers, LoroDoc } from "loro-crdt";
|
|
3
|
-
import { FlockAdaptor, FlockAdaptorConfig } from "loro-adaptors";
|
|
3
|
+
import { FlockAdaptor, FlockAdaptorConfig, LoroAdaptor } from "loro-adaptors";
|
|
4
4
|
import { JoinError, JoinResponseOk, RoomId, UpdateError } from "loro-protocol";
|
|
5
5
|
import { LoroWebsocketClientOptions } from "loro-websocket";
|
|
6
6
|
|
|
@@ -15,6 +15,14 @@ type GlobalBlob = typeof globalThis extends {
|
|
|
15
15
|
* Binary content accepted by asset ingestion helpers.
|
|
16
16
|
*/
|
|
17
17
|
type AssetContent = GlobalBlob | ArrayBufferView | ReadableStream<Uint8Array>;
|
|
18
|
+
interface RepoAssetMetadata {
|
|
19
|
+
readonly assetId: AssetId;
|
|
20
|
+
readonly size: number;
|
|
21
|
+
readonly createdAt: number;
|
|
22
|
+
readonly mime?: string;
|
|
23
|
+
readonly policy?: string;
|
|
24
|
+
readonly tag?: string;
|
|
25
|
+
}
|
|
18
26
|
/**
|
|
19
27
|
* JSON-compatible leaf value used for document metadata.
|
|
20
28
|
*/
|
|
@@ -565,52 +573,66 @@ declare class IndexedDBStorageAdaptor implements StorageAdapter {
|
|
|
565
573
|
private createError;
|
|
566
574
|
}
|
|
567
575
|
//#endregion
|
|
568
|
-
//#region src/
|
|
569
|
-
interface
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
readonly
|
|
575
|
-
|
|
576
|
+
//#region src/storage/filesystem.d.ts
|
|
577
|
+
interface FileSystemStorageAdaptorOptions {
|
|
578
|
+
/**
|
|
579
|
+
* Base directory where metadata, document snapshots, and assets will be stored.
|
|
580
|
+
* Defaults to `.loro-repo` inside the current working directory.
|
|
581
|
+
*/
|
|
582
|
+
readonly baseDir?: string;
|
|
583
|
+
/**
|
|
584
|
+
* Subdirectory dedicated to document persistence. Defaults to `docs`.
|
|
585
|
+
*/
|
|
586
|
+
readonly docsDirName?: string;
|
|
587
|
+
/**
|
|
588
|
+
* Subdirectory dedicated to asset blobs. Defaults to `assets`.
|
|
589
|
+
*/
|
|
590
|
+
readonly assetsDirName?: string;
|
|
591
|
+
/**
|
|
592
|
+
* File name for the metadata snapshot bundle. Defaults to `meta.json`.
|
|
593
|
+
*/
|
|
594
|
+
readonly metaFileName?: string;
|
|
576
595
|
}
|
|
596
|
+
declare class FileSystemStorageAdaptor implements StorageAdapter {
|
|
597
|
+
private readonly baseDir;
|
|
598
|
+
private readonly docsDir;
|
|
599
|
+
private readonly assetsDir;
|
|
600
|
+
private readonly metaPath;
|
|
601
|
+
private readonly initPromise;
|
|
602
|
+
private updateCounter;
|
|
603
|
+
constructor(options?: FileSystemStorageAdaptorOptions);
|
|
604
|
+
save(payload: StorageSavePayload): Promise<void>;
|
|
605
|
+
deleteAsset(assetId: AssetId): Promise<void>;
|
|
606
|
+
loadDoc(docId: string): Promise<LoroDoc | undefined>;
|
|
607
|
+
loadMeta(): Promise<Flock | undefined>;
|
|
608
|
+
loadAsset(assetId: AssetId): Promise<Uint8Array | undefined>;
|
|
609
|
+
private ensureLayout;
|
|
610
|
+
private writeDocSnapshot;
|
|
611
|
+
private enqueueDocUpdate;
|
|
612
|
+
private writeAsset;
|
|
613
|
+
private docDir;
|
|
614
|
+
private docSnapshotPath;
|
|
615
|
+
private docUpdatesDir;
|
|
616
|
+
private assetPath;
|
|
617
|
+
}
|
|
618
|
+
//#endregion
|
|
619
|
+
//#region src/index.d.ts
|
|
577
620
|
declare class LoroRepo<Meta extends JsonObject = JsonObject> {
|
|
578
621
|
readonly options: LoroRepoOptions<Meta>;
|
|
579
622
|
private readonly transport?;
|
|
580
623
|
private readonly storage?;
|
|
581
|
-
private readonly assetTransport?;
|
|
582
624
|
private readonly docFactory;
|
|
583
625
|
private metaFlock;
|
|
584
|
-
private readonly
|
|
585
|
-
private readonly
|
|
586
|
-
private readonly
|
|
587
|
-
private readonly
|
|
588
|
-
private readonly
|
|
589
|
-
private readonly
|
|
590
|
-
private readonly
|
|
591
|
-
private readonly assetToDocRefs;
|
|
592
|
-
private readonly docFrontierKeys;
|
|
593
|
-
private readonly docFrontierUpdates;
|
|
594
|
-
private readonly docPersistedVersions;
|
|
595
|
-
private readonly docFrontierDebounceMs;
|
|
596
|
-
private readonly watchers;
|
|
597
|
-
private readonly eventByStack;
|
|
598
|
-
private metaRoomSubscription?;
|
|
599
|
-
private unsubscribeMetaFlock?;
|
|
600
|
-
private readyPromise?;
|
|
626
|
+
private readonly eventBus;
|
|
627
|
+
private readonly docManager;
|
|
628
|
+
private readonly metadataManager;
|
|
629
|
+
private readonly assetManager;
|
|
630
|
+
private readonly flockHydrator;
|
|
631
|
+
private readonly state;
|
|
632
|
+
private readonly syncRunner;
|
|
601
633
|
constructor(options: LoroRepoOptions<Meta>);
|
|
602
634
|
ready(): Promise<void>;
|
|
603
|
-
private initialize;
|
|
604
635
|
sync(options?: RepoSyncOptions): Promise<void>;
|
|
605
|
-
private refreshDocMetadataEntry;
|
|
606
|
-
private refreshDocAssetsEntry;
|
|
607
|
-
private refreshAssetMetadataEntry;
|
|
608
|
-
private refreshDocFrontierKeys;
|
|
609
|
-
private readDocMetadataFromFlock;
|
|
610
|
-
private readDocAssetsFromFlock;
|
|
611
|
-
private readAssetMetadataFromFlock;
|
|
612
|
-
private handleAssetRemoval;
|
|
613
|
-
private emit;
|
|
614
636
|
joinMetaRoom(params?: TransportJoinParams): Promise<TransportSubscription>;
|
|
615
637
|
joinDocRoom(docId: string, params?: TransportJoinParams): Promise<TransportSubscription>;
|
|
616
638
|
close(): Promise<void>;
|
|
@@ -636,35 +658,9 @@ declare class LoroRepo<Meta extends JsonObject = JsonObject> {
|
|
|
636
658
|
unlinkAsset(docId: string, assetId: AssetId): Promise<void>;
|
|
637
659
|
listAssets(docId: string): Promise<RepoAssetMetadata[]>;
|
|
638
660
|
ensureAsset(assetId: AssetId): Promise<AssetDownload>;
|
|
639
|
-
private createAssetDownload;
|
|
640
|
-
private materializeAsset;
|
|
641
|
-
private updateDocAssetMetadata;
|
|
642
661
|
gcAssets(options?: GarbageCollectionOptions): Promise<number>;
|
|
643
|
-
private onDocHandleClose;
|
|
644
|
-
private ensureDoc;
|
|
645
|
-
private materializeDetachedDoc;
|
|
646
|
-
private exportDocSnapshot;
|
|
647
662
|
private persistMeta;
|
|
648
|
-
private persistDoc;
|
|
649
|
-
private persistDocUpdate;
|
|
650
|
-
private pushEventBy;
|
|
651
|
-
private popEventBy;
|
|
652
|
-
private resolveEventBy;
|
|
653
|
-
private ensureMetaLiveMonitor;
|
|
654
|
-
private applyMetaFlockEvents;
|
|
655
|
-
private registerDoc;
|
|
656
|
-
private ensureDocSubscription;
|
|
657
|
-
private rememberAsset;
|
|
658
|
-
private scheduleDocFrontierUpdate;
|
|
659
|
-
private mergeRepoEventBy;
|
|
660
|
-
private runScheduledDocFrontierUpdate;
|
|
661
|
-
private flushScheduledDocFrontierUpdate;
|
|
662
|
-
private onDocEvent;
|
|
663
|
-
private getAssetMetadata;
|
|
664
|
-
private updateDocFrontiers;
|
|
665
|
-
private hydrateMetadataFromFlock;
|
|
666
|
-
private shouldNotify;
|
|
667
663
|
}
|
|
668
664
|
//#endregion
|
|
669
|
-
export { AssetContent, AssetDownload, AssetId, AssetTransportAdapter, AssetUploadMetadata, BroadcastChannelTransportAdapter, type BroadcastChannelTransportOptions, 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, UpsertDocMetaOptions, WebSocketTransportAdapter, WebSocketTransportOptions };
|
|
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, UpsertDocMetaOptions, WebSocketTransportAdapter, WebSocketTransportOptions };
|
|
670
666
|
//# sourceMappingURL=index.d.ts.map
|