@dxos/echo-pipeline 0.3.11-main.4feb9c9 → 0.3.11-main.5052d1a
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/lib/browser/{chunk-EM4RCBYQ.mjs → chunk-PB5T4DLC.mjs} +161 -31
- package/dist/lib/browser/{chunk-EM4RCBYQ.mjs.map → chunk-PB5T4DLC.mjs.map} +3 -3
- package/dist/lib/browser/index.mjs +1 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +2 -2
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-CMAJNNUX.cjs → chunk-WGNVVL2H.cjs} +159 -33
- package/dist/lib/node/{chunk-CMAJNNUX.cjs.map → chunk-WGNVVL2H.cjs.map} +3 -3
- package/dist/lib/node/index.cjs +26 -28
- package/dist/lib/node/index.cjs.map +2 -2
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +17 -17
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/types/src/automerge/automerge-host.d.ts +24 -2
- package/dist/types/src/automerge/automerge-host.d.ts.map +1 -1
- package/dist/types/src/automerge/index.d.ts +1 -1
- package/dist/types/src/automerge/index.d.ts.map +1 -1
- package/dist/types/src/space/space-manager.d.ts +2 -2
- package/dist/types/src/space/space-manager.d.ts.map +1 -1
- package/package.json +33 -33
- package/src/automerge/automerge-host.test.ts +291 -34
- package/src/automerge/automerge-host.ts +119 -19
- package/src/automerge/index.ts +1 -1
- package/src/space/space-manager.ts +3 -3
- package/src/testing/test-agent-builder.ts +1 -1
|
@@ -1481,7 +1481,7 @@ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipelin
|
|
|
1481
1481
|
var MESSAGES_PER_SNAPSHOT = 10;
|
|
1482
1482
|
var AUTOMATIC_SNAPSHOT_DEBOUNCE_INTERVAL = 5e3;
|
|
1483
1483
|
var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL = 5e3;
|
|
1484
|
-
var DataPipeline = class
|
|
1484
|
+
var DataPipeline = class {
|
|
1485
1485
|
constructor(_params) {
|
|
1486
1486
|
this._params = _params;
|
|
1487
1487
|
this._ctx = new Context4();
|
|
@@ -1955,7 +1955,7 @@ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeli
|
|
|
1955
1955
|
var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2 = 500;
|
|
1956
1956
|
var CONTROL_PIPELINE_SNAPSHOT_DELAY = 1e4;
|
|
1957
1957
|
var USE_SNAPSHOTS = true;
|
|
1958
|
-
var ControlPipeline = class
|
|
1958
|
+
var ControlPipeline = class {
|
|
1959
1959
|
constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
|
|
1960
1960
|
this._ctx = new Context5();
|
|
1961
1961
|
this._lastTimeframeSaveTime = Date.now();
|
|
@@ -2201,7 +2201,7 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
2201
2201
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2202
2202
|
}
|
|
2203
2203
|
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space.ts";
|
|
2204
|
-
var Space = class
|
|
2204
|
+
var Space = class {
|
|
2205
2205
|
constructor(params) {
|
|
2206
2206
|
this._addFeedLock = new Lock();
|
|
2207
2207
|
this.onCredentialProcessed = new Callback2();
|
|
@@ -2585,7 +2585,7 @@ var SpaceProtocolSession = class {
|
|
|
2585
2585
|
this.replicator = new ReplicatorExtension().setOptions({
|
|
2586
2586
|
upload: true
|
|
2587
2587
|
});
|
|
2588
|
-
this._authStatus =
|
|
2588
|
+
this._authStatus = "INITIAL";
|
|
2589
2589
|
this._wireParams = wireParams;
|
|
2590
2590
|
this._swarmIdentity = swarmIdentity;
|
|
2591
2591
|
this._onSessionAuth = onSessionAuth;
|
|
@@ -2614,11 +2614,11 @@ var SpaceProtocolSession = class {
|
|
|
2614
2614
|
S: this,
|
|
2615
2615
|
C: (f, a) => f(...a)
|
|
2616
2616
|
});
|
|
2617
|
-
this._authStatus =
|
|
2617
|
+
this._authStatus = "SUCCESS";
|
|
2618
2618
|
this._onSessionAuth?.(this._teleport);
|
|
2619
2619
|
},
|
|
2620
2620
|
onAuthFailure: () => {
|
|
2621
|
-
this._authStatus =
|
|
2621
|
+
this._authStatus = "FAILURE";
|
|
2622
2622
|
this._onAuthFailure?.(this._teleport);
|
|
2623
2623
|
}
|
|
2624
2624
|
}));
|
|
@@ -2663,7 +2663,7 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
2663
2663
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2664
2664
|
}
|
|
2665
2665
|
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
|
|
2666
|
-
var SpaceManager = class
|
|
2666
|
+
var SpaceManager = class {
|
|
2667
2667
|
constructor({ feedStore, networkManager, modelFactory, metadataStore, snapshotStore, blobStore }) {
|
|
2668
2668
|
this._spaces = new ComplexMap6(PublicKey7.hash);
|
|
2669
2669
|
this._instanceId = PublicKey7.random().toHex();
|
|
@@ -2685,7 +2685,7 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2685
2685
|
...this._spaces.values()
|
|
2686
2686
|
].map((space) => space.close()));
|
|
2687
2687
|
}
|
|
2688
|
-
async constructSpace({ metadata, swarmIdentity,
|
|
2688
|
+
async constructSpace({ metadata, swarmIdentity, onAuthorizedConnection, onAuthFailure, memberKey }) {
|
|
2689
2689
|
log12.trace("dxos.echo.space-manager.construct-space", trace4.begin({
|
|
2690
2690
|
id: this._instanceId
|
|
2691
2691
|
}), {
|
|
@@ -2708,7 +2708,7 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2708
2708
|
topic: spaceKey,
|
|
2709
2709
|
swarmIdentity,
|
|
2710
2710
|
networkManager: this._networkManager,
|
|
2711
|
-
onSessionAuth:
|
|
2711
|
+
onSessionAuth: onAuthorizedConnection,
|
|
2712
2712
|
onAuthFailure,
|
|
2713
2713
|
blobStore: this._blobStore
|
|
2714
2714
|
});
|
|
@@ -2746,26 +2746,108 @@ SpaceManager = _ts_decorate8([
|
|
|
2746
2746
|
], SpaceManager);
|
|
2747
2747
|
|
|
2748
2748
|
// packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts
|
|
2749
|
+
import { Trigger as Trigger2 } from "@dxos/async";
|
|
2749
2750
|
import { Repo, NetworkAdapter, StorageAdapter, cbor } from "@dxos/automerge/automerge-repo";
|
|
2751
|
+
import { IndexedDBStorageAdapter } from "@dxos/automerge/automerge-repo-storage-indexeddb";
|
|
2750
2752
|
import { Stream as Stream2 } from "@dxos/codec-protobuf";
|
|
2751
2753
|
import { invariant as invariant10 } from "@dxos/invariant";
|
|
2754
|
+
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
2752
2755
|
import { log as log13 } from "@dxos/log";
|
|
2756
|
+
import { StorageType } from "@dxos/random-access-storage";
|
|
2753
2757
|
import { AutomergeReplicator } from "@dxos/teleport-extension-automerge-replicator";
|
|
2754
|
-
import { arrayToBuffer as arrayToBuffer2, bufferToArray } from "@dxos/util";
|
|
2758
|
+
import { ComplexMap as ComplexMap7, ComplexSet, arrayToBuffer as arrayToBuffer2, bufferToArray, defaultMap } from "@dxos/util";
|
|
2755
2759
|
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts";
|
|
2756
2760
|
var AutomergeHost = class {
|
|
2757
2761
|
constructor(storageDirectory) {
|
|
2762
|
+
/**
|
|
2763
|
+
* spaceKey -> deviceKey[]
|
|
2764
|
+
*/
|
|
2765
|
+
this._authorizedDevices = new ComplexMap7(PublicKey8.hash);
|
|
2758
2766
|
this._meshNetwork = new MeshNetworkAdapter();
|
|
2759
2767
|
this._clientNetwork = new LocalHostNetworkAdapter();
|
|
2760
|
-
this._storage = new AutomergeStorageAdapter(storageDirectory);
|
|
2768
|
+
this._storage = storageDirectory.type === StorageType.IDB ? new IndexedDBStorageAdapter(storageDirectory.path, "data") : new AutomergeStorageAdapter(storageDirectory);
|
|
2761
2769
|
this._repo = new Repo({
|
|
2770
|
+
peerId: `host-${PublicKey8.random().toHex()}`,
|
|
2762
2771
|
network: [
|
|
2763
2772
|
this._clientNetwork,
|
|
2764
2773
|
this._meshNetwork
|
|
2765
2774
|
],
|
|
2766
2775
|
storage: this._storage,
|
|
2767
2776
|
// TODO(dmaretskyi): Share based on HALO permissions and space affinity.
|
|
2768
|
-
|
|
2777
|
+
// Hosts, running in the worker, don't share documents unless requested by other peers.
|
|
2778
|
+
sharePolicy: async (peerId, documentId) => {
|
|
2779
|
+
if (peerId.startsWith("client-")) {
|
|
2780
|
+
return true;
|
|
2781
|
+
}
|
|
2782
|
+
if (!documentId) {
|
|
2783
|
+
return false;
|
|
2784
|
+
}
|
|
2785
|
+
const doc = this._repo.handles[documentId]?.docSync();
|
|
2786
|
+
if (!doc) {
|
|
2787
|
+
log13("doc not found for share policy check", {
|
|
2788
|
+
peerId,
|
|
2789
|
+
documentId
|
|
2790
|
+
}, {
|
|
2791
|
+
F: __dxlog_file14,
|
|
2792
|
+
L: 65,
|
|
2793
|
+
S: this,
|
|
2794
|
+
C: (f, a) => f(...a)
|
|
2795
|
+
});
|
|
2796
|
+
return false;
|
|
2797
|
+
}
|
|
2798
|
+
try {
|
|
2799
|
+
if (!doc.experimental_spaceKey) {
|
|
2800
|
+
log13.warn("space key not found for share policy check", {
|
|
2801
|
+
peerId,
|
|
2802
|
+
documentId
|
|
2803
|
+
}, {
|
|
2804
|
+
F: __dxlog_file14,
|
|
2805
|
+
L: 71,
|
|
2806
|
+
S: this,
|
|
2807
|
+
C: (f, a) => f(...a)
|
|
2808
|
+
});
|
|
2809
|
+
return false;
|
|
2810
|
+
}
|
|
2811
|
+
const spaceKey = PublicKey8.from(doc.experimental_spaceKey);
|
|
2812
|
+
const authorizedDevices = this._authorizedDevices.get(spaceKey);
|
|
2813
|
+
const deviceKeyHex = this.repo.peerMetadataByPeerId[peerId]?.dxos_deviceKey;
|
|
2814
|
+
if (!deviceKeyHex) {
|
|
2815
|
+
log13.warn("device key not found for share policy check", {
|
|
2816
|
+
peerId,
|
|
2817
|
+
documentId
|
|
2818
|
+
}, {
|
|
2819
|
+
F: __dxlog_file14,
|
|
2820
|
+
L: 81,
|
|
2821
|
+
S: this,
|
|
2822
|
+
C: (f, a) => f(...a)
|
|
2823
|
+
});
|
|
2824
|
+
return false;
|
|
2825
|
+
}
|
|
2826
|
+
const deviceKey = PublicKey8.from(deviceKeyHex);
|
|
2827
|
+
const isAuthorized = authorizedDevices?.has(deviceKey) ?? false;
|
|
2828
|
+
log13.info("share policy check", {
|
|
2829
|
+
peerId,
|
|
2830
|
+
documentId,
|
|
2831
|
+
deviceKey,
|
|
2832
|
+
spaceKey,
|
|
2833
|
+
isAuthorized
|
|
2834
|
+
}, {
|
|
2835
|
+
F: __dxlog_file14,
|
|
2836
|
+
L: 87,
|
|
2837
|
+
S: this,
|
|
2838
|
+
C: (f, a) => f(...a)
|
|
2839
|
+
});
|
|
2840
|
+
return isAuthorized;
|
|
2841
|
+
} catch (err) {
|
|
2842
|
+
log13.catch(err, void 0, {
|
|
2843
|
+
F: __dxlog_file14,
|
|
2844
|
+
L: 90,
|
|
2845
|
+
S: this,
|
|
2846
|
+
C: (f, a) => f(...a)
|
|
2847
|
+
});
|
|
2848
|
+
return false;
|
|
2849
|
+
}
|
|
2850
|
+
}
|
|
2769
2851
|
});
|
|
2770
2852
|
this._clientNetwork.ready();
|
|
2771
2853
|
this._meshNetwork.ready();
|
|
@@ -2774,6 +2856,7 @@ var AutomergeHost = class {
|
|
|
2774
2856
|
return this._repo;
|
|
2775
2857
|
}
|
|
2776
2858
|
async close() {
|
|
2859
|
+
this._storage instanceof AutomergeStorageAdapter && await this._storage.close();
|
|
2777
2860
|
await this._clientNetwork.close();
|
|
2778
2861
|
}
|
|
2779
2862
|
//
|
|
@@ -2785,7 +2868,7 @@ var AutomergeHost = class {
|
|
|
2785
2868
|
sendSyncMessage(request) {
|
|
2786
2869
|
return this._clientNetwork.sendSyncMessage(request);
|
|
2787
2870
|
}
|
|
2788
|
-
getHostInfo() {
|
|
2871
|
+
async getHostInfo() {
|
|
2789
2872
|
return this._clientNetwork.getHostInfo();
|
|
2790
2873
|
}
|
|
2791
2874
|
//
|
|
@@ -2794,11 +2877,15 @@ var AutomergeHost = class {
|
|
|
2794
2877
|
createExtension() {
|
|
2795
2878
|
return this._meshNetwork.createExtension();
|
|
2796
2879
|
}
|
|
2880
|
+
authorizeDevice(spaceKey, deviceKey) {
|
|
2881
|
+
defaultMap(this._authorizedDevices, spaceKey, () => new ComplexSet(PublicKey8.hash)).add(deviceKey);
|
|
2882
|
+
}
|
|
2797
2883
|
};
|
|
2798
2884
|
var LocalHostNetworkAdapter = class extends NetworkAdapter {
|
|
2799
2885
|
constructor() {
|
|
2800
2886
|
super(...arguments);
|
|
2801
2887
|
this._peers = /* @__PURE__ */ new Map();
|
|
2888
|
+
this._connected = new Trigger2();
|
|
2802
2889
|
}
|
|
2803
2890
|
/**
|
|
2804
2891
|
* Emits `ready` event. That signals to `Repo` that it can start using the adapter.
|
|
@@ -2810,12 +2897,13 @@ var LocalHostNetworkAdapter = class extends NetworkAdapter {
|
|
|
2810
2897
|
}
|
|
2811
2898
|
connect(peerId) {
|
|
2812
2899
|
this.peerId = peerId;
|
|
2900
|
+
this._connected.wake();
|
|
2813
2901
|
}
|
|
2814
2902
|
send(message) {
|
|
2815
2903
|
const peer = this._peers.get(message.targetId);
|
|
2816
2904
|
invariant10(peer, "Peer not found.", {
|
|
2817
2905
|
F: __dxlog_file14,
|
|
2818
|
-
L:
|
|
2906
|
+
L: 170,
|
|
2819
2907
|
S: this,
|
|
2820
2908
|
A: [
|
|
2821
2909
|
"peer",
|
|
@@ -2835,7 +2923,7 @@ var LocalHostNetworkAdapter = class extends NetworkAdapter {
|
|
|
2835
2923
|
return new Stream2(({ next, close }) => {
|
|
2836
2924
|
invariant10(!this._peers.has(peerId), "Peer already connected.", {
|
|
2837
2925
|
F: __dxlog_file14,
|
|
2838
|
-
L:
|
|
2926
|
+
L: 188,
|
|
2839
2927
|
S: this,
|
|
2840
2928
|
A: [
|
|
2841
2929
|
"!this._peers.has(peerId)",
|
|
@@ -2857,19 +2945,35 @@ var LocalHostNetworkAdapter = class extends NetworkAdapter {
|
|
|
2857
2945
|
});
|
|
2858
2946
|
}
|
|
2859
2947
|
});
|
|
2860
|
-
this.
|
|
2861
|
-
|
|
2862
|
-
})
|
|
2948
|
+
this._connected.wait({
|
|
2949
|
+
timeout: 1e3
|
|
2950
|
+
}).then(() => {
|
|
2951
|
+
this.emit("peer-candidate", {
|
|
2952
|
+
peerMetadata: {},
|
|
2953
|
+
peerId
|
|
2954
|
+
});
|
|
2955
|
+
}).catch((err) => log13.catch(err, void 0, {
|
|
2956
|
+
F: __dxlog_file14,
|
|
2957
|
+
L: 213,
|
|
2958
|
+
S: this,
|
|
2959
|
+
C: (f, a) => f(...a)
|
|
2960
|
+
}));
|
|
2863
2961
|
});
|
|
2864
2962
|
}
|
|
2865
2963
|
async sendSyncMessage({ id, syncMessage }) {
|
|
2964
|
+
await this._connected.wait({
|
|
2965
|
+
timeout: 1e3
|
|
2966
|
+
});
|
|
2866
2967
|
const message = cbor.decode(syncMessage);
|
|
2867
2968
|
this.emit("message", message);
|
|
2868
2969
|
}
|
|
2869
|
-
getHostInfo() {
|
|
2970
|
+
async getHostInfo() {
|
|
2971
|
+
await this._connected.wait({
|
|
2972
|
+
timeout: 1e3
|
|
2973
|
+
});
|
|
2870
2974
|
invariant10(this.peerId, "Peer id not set.", {
|
|
2871
2975
|
F: __dxlog_file14,
|
|
2872
|
-
L:
|
|
2976
|
+
L: 225,
|
|
2873
2977
|
S: this,
|
|
2874
2978
|
A: [
|
|
2875
2979
|
"this.peerId",
|
|
@@ -2905,7 +3009,7 @@ var MeshNetworkAdapter = class extends NetworkAdapter {
|
|
|
2905
3009
|
const extension = this._extensions.get(receiverId);
|
|
2906
3010
|
invariant10(extension, "Extension not found.", {
|
|
2907
3011
|
F: __dxlog_file14,
|
|
2908
|
-
L:
|
|
3012
|
+
L: 260,
|
|
2909
3013
|
S: this,
|
|
2910
3014
|
A: [
|
|
2911
3015
|
"extension",
|
|
@@ -2916,7 +3020,7 @@ var MeshNetworkAdapter = class extends NetworkAdapter {
|
|
|
2916
3020
|
payload: cbor.encode(message)
|
|
2917
3021
|
}).catch((err) => log13.catch(err, void 0, {
|
|
2918
3022
|
F: __dxlog_file14,
|
|
2919
|
-
L:
|
|
3023
|
+
L: 261,
|
|
2920
3024
|
S: this,
|
|
2921
3025
|
C: (f, a) => f(...a)
|
|
2922
3026
|
}));
|
|
@@ -2926,7 +3030,7 @@ var MeshNetworkAdapter = class extends NetworkAdapter {
|
|
|
2926
3030
|
createExtension() {
|
|
2927
3031
|
invariant10(this.peerId, "Peer id not set.", {
|
|
2928
3032
|
F: __dxlog_file14,
|
|
2929
|
-
L:
|
|
3033
|
+
L: 269,
|
|
2930
3034
|
S: this,
|
|
2931
3035
|
A: [
|
|
2932
3036
|
"this.peerId",
|
|
@@ -2937,13 +3041,17 @@ var MeshNetworkAdapter = class extends NetworkAdapter {
|
|
|
2937
3041
|
const extension = new AutomergeReplicator({
|
|
2938
3042
|
peerId: this.peerId
|
|
2939
3043
|
}, {
|
|
2940
|
-
onStartReplication: async (info) => {
|
|
3044
|
+
onStartReplication: async (info, remotePeerId) => {
|
|
2941
3045
|
if (this._extensions.has(info.id)) {
|
|
2942
3046
|
return;
|
|
2943
3047
|
}
|
|
2944
3048
|
peerInfo = info;
|
|
2945
3049
|
this._extensions.set(info.id, extension);
|
|
2946
3050
|
this.emit("peer-candidate", {
|
|
3051
|
+
// TODO(mykola): Hack, stop abusing `peerMetadata` field.
|
|
3052
|
+
peerMetadata: {
|
|
3053
|
+
dxos_deviceKey: remotePeerId.toHex()
|
|
3054
|
+
},
|
|
2947
3055
|
peerId: info.id
|
|
2948
3056
|
});
|
|
2949
3057
|
},
|
|
@@ -2952,9 +3060,13 @@ var MeshNetworkAdapter = class extends NetworkAdapter {
|
|
|
2952
3060
|
this.emit("message", message);
|
|
2953
3061
|
},
|
|
2954
3062
|
onClose: async () => {
|
|
2955
|
-
|
|
3063
|
+
if (!peerInfo) {
|
|
3064
|
+
return;
|
|
3065
|
+
}
|
|
3066
|
+
this.emit("peer-disconnected", {
|
|
2956
3067
|
peerId: peerInfo.id
|
|
2957
3068
|
});
|
|
3069
|
+
this._extensions.delete(peerInfo.id);
|
|
2958
3070
|
}
|
|
2959
3071
|
});
|
|
2960
3072
|
return extension;
|
|
@@ -2964,8 +3076,12 @@ var AutomergeStorageAdapter = class extends StorageAdapter {
|
|
|
2964
3076
|
constructor(_directory) {
|
|
2965
3077
|
super();
|
|
2966
3078
|
this._directory = _directory;
|
|
3079
|
+
this._state = "opened";
|
|
2967
3080
|
}
|
|
2968
3081
|
async load(key) {
|
|
3082
|
+
if (this._state !== "opened") {
|
|
3083
|
+
return void 0;
|
|
3084
|
+
}
|
|
2969
3085
|
const filename = this._getFilename(key);
|
|
2970
3086
|
const file = this._directory.getOrCreateFile(filename);
|
|
2971
3087
|
const { size } = await file.stat();
|
|
@@ -2976,6 +3092,9 @@ var AutomergeStorageAdapter = class extends StorageAdapter {
|
|
|
2976
3092
|
return bufferToArray(buffer);
|
|
2977
3093
|
}
|
|
2978
3094
|
async save(key, data) {
|
|
3095
|
+
if (this._state !== "opened") {
|
|
3096
|
+
return void 0;
|
|
3097
|
+
}
|
|
2979
3098
|
const filename = this._getFilename(key);
|
|
2980
3099
|
const file = this._directory.getOrCreateFile(filename);
|
|
2981
3100
|
await file.write(0, arrayToBuffer2(data));
|
|
@@ -2983,11 +3102,17 @@ var AutomergeStorageAdapter = class extends StorageAdapter {
|
|
|
2983
3102
|
await file.flush?.();
|
|
2984
3103
|
}
|
|
2985
3104
|
async remove(key) {
|
|
3105
|
+
if (this._state !== "opened") {
|
|
3106
|
+
return void 0;
|
|
3107
|
+
}
|
|
2986
3108
|
const filename = this._getFilename(key);
|
|
2987
3109
|
const file = this._directory.getOrCreateFile(filename);
|
|
2988
|
-
await file.
|
|
3110
|
+
await file.destroy();
|
|
2989
3111
|
}
|
|
2990
3112
|
async loadRange(keyPrefix) {
|
|
3113
|
+
if (this._state !== "opened") {
|
|
3114
|
+
return [];
|
|
3115
|
+
}
|
|
2991
3116
|
const filename = this._getFilename(keyPrefix);
|
|
2992
3117
|
const entries = await this._directory.list();
|
|
2993
3118
|
return Promise.all(entries.filter((entry) => entry.startsWith(filename)).map(async (entry) => {
|
|
@@ -3001,13 +3126,19 @@ var AutomergeStorageAdapter = class extends StorageAdapter {
|
|
|
3001
3126
|
}));
|
|
3002
3127
|
}
|
|
3003
3128
|
async removeRange(keyPrefix) {
|
|
3129
|
+
if (this._state !== "opened") {
|
|
3130
|
+
return void 0;
|
|
3131
|
+
}
|
|
3004
3132
|
const filename = this._getFilename(keyPrefix);
|
|
3005
3133
|
const entries = await this._directory.list();
|
|
3006
3134
|
await Promise.all(entries.filter((entry) => entry.startsWith(filename)).map(async (entry) => {
|
|
3007
|
-
const file = this._directory.getOrCreateFile(
|
|
3008
|
-
await file.
|
|
3135
|
+
const file = this._directory.getOrCreateFile(entry);
|
|
3136
|
+
await file.destroy();
|
|
3009
3137
|
}));
|
|
3010
3138
|
}
|
|
3139
|
+
async close() {
|
|
3140
|
+
this._state = "closed";
|
|
3141
|
+
}
|
|
3011
3142
|
_getFilename(key) {
|
|
3012
3143
|
return key.map((k) => k.replaceAll("%", "%25").replaceAll("-", "%2D")).join("-");
|
|
3013
3144
|
}
|
|
@@ -3041,7 +3172,6 @@ export {
|
|
|
3041
3172
|
AuthStatus,
|
|
3042
3173
|
SpaceProtocolSession,
|
|
3043
3174
|
SpaceManager,
|
|
3044
|
-
AutomergeHost
|
|
3045
|
-
AutomergeStorageAdapter
|
|
3175
|
+
AutomergeHost
|
|
3046
3176
|
};
|
|
3047
|
-
//# sourceMappingURL=chunk-
|
|
3177
|
+
//# sourceMappingURL=chunk-PB5T4DLC.mjs.map
|