@dxos/echo-pipeline 0.4.8-main.c1d1c78 → 0.4.8-main.c2effdb
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-LED7X4WK.mjs → chunk-3FVT6KX6.mjs} +32 -25
- package/dist/lib/browser/{chunk-LED7X4WK.mjs.map → chunk-3FVT6KX6.mjs.map} +3 -3
- package/dist/lib/browser/index.mjs +3 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +1 -1
- package/dist/lib/node/{chunk-UKREXVZX.cjs → chunk-WZ4WTAN6.cjs} +44 -36
- package/dist/lib/node/{chunk-UKREXVZX.cjs.map → chunk-WZ4WTAN6.cjs.map} +3 -3
- package/dist/lib/node/index.cjs +31 -29
- package/dist/lib/node/index.cjs.map +2 -2
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +16 -16
- package/dist/types/src/automerge/automerge-host.d.ts +2 -1
- package/dist/types/src/automerge/automerge-host.d.ts.map +1 -1
- package/dist/types/src/automerge/automerge-storage-adapter.d.ts +2 -2
- package/dist/types/src/automerge/automerge-storage-adapter.d.ts.map +1 -1
- package/package.json +33 -33
- package/src/automerge/automerge-host.ts +21 -22
- package/src/automerge/automerge-storage-adapter.ts +8 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/echo-pipeline",
|
|
3
|
-
"version": "0.4.8-main.
|
|
3
|
+
"version": "0.4.8-main.c2effdb",
|
|
4
4
|
"description": "ECHO database.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -36,38 +36,38 @@
|
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"crc-32": "^1.2.2",
|
|
39
|
-
"@dxos/async": "0.4.8-main.
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/context": "0.4.8-main.
|
|
43
|
-
"@dxos/credentials": "0.4.8-main.
|
|
44
|
-
"@dxos/crypto": "0.4.8-main.
|
|
45
|
-
"@dxos/debug": "0.4.8-main.
|
|
46
|
-
"@dxos/document-model": "0.4.8-main.
|
|
47
|
-
"@dxos/echo-db": "0.4.8-main.
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/
|
|
52
|
-
"@dxos/keys": "0.4.8-main.
|
|
53
|
-
"@dxos/log": "0.4.8-main.
|
|
54
|
-
"@dxos/messaging": "0.4.8-main.
|
|
55
|
-
"@dxos/model-factory": "0.4.8-main.
|
|
56
|
-
"@dxos/network-manager": "0.4.8-main.
|
|
57
|
-
"@dxos/
|
|
58
|
-
"@dxos/
|
|
59
|
-
"@dxos/random-access-storage": "0.4.8-main.
|
|
60
|
-
"@dxos/
|
|
61
|
-
"@dxos/
|
|
62
|
-
"@dxos/teleport
|
|
63
|
-
"@dxos/teleport-extension-
|
|
64
|
-
"@dxos/teleport-extension-
|
|
65
|
-
"@dxos/teleport-extension-
|
|
66
|
-
"@dxos/
|
|
67
|
-
"@dxos/
|
|
68
|
-
"@dxos/
|
|
69
|
-
"@dxos/
|
|
70
|
-
"@dxos/
|
|
39
|
+
"@dxos/async": "0.4.8-main.c2effdb",
|
|
40
|
+
"@dxos/codec-protobuf": "0.4.8-main.c2effdb",
|
|
41
|
+
"@dxos/automerge": "0.4.8-main.c2effdb",
|
|
42
|
+
"@dxos/context": "0.4.8-main.c2effdb",
|
|
43
|
+
"@dxos/credentials": "0.4.8-main.c2effdb",
|
|
44
|
+
"@dxos/crypto": "0.4.8-main.c2effdb",
|
|
45
|
+
"@dxos/debug": "0.4.8-main.c2effdb",
|
|
46
|
+
"@dxos/document-model": "0.4.8-main.c2effdb",
|
|
47
|
+
"@dxos/echo-db": "0.4.8-main.c2effdb",
|
|
48
|
+
"@dxos/hypercore": "0.4.8-main.c2effdb",
|
|
49
|
+
"@dxos/invariant": "0.4.8-main.c2effdb",
|
|
50
|
+
"@dxos/feed-store": "0.4.8-main.c2effdb",
|
|
51
|
+
"@dxos/keyring": "0.4.8-main.c2effdb",
|
|
52
|
+
"@dxos/keys": "0.4.8-main.c2effdb",
|
|
53
|
+
"@dxos/log": "0.4.8-main.c2effdb",
|
|
54
|
+
"@dxos/messaging": "0.4.8-main.c2effdb",
|
|
55
|
+
"@dxos/model-factory": "0.4.8-main.c2effdb",
|
|
56
|
+
"@dxos/network-manager": "0.4.8-main.c2effdb",
|
|
57
|
+
"@dxos/node-std": "0.4.8-main.c2effdb",
|
|
58
|
+
"@dxos/protocols": "0.4.8-main.c2effdb",
|
|
59
|
+
"@dxos/random-access-storage": "0.4.8-main.c2effdb",
|
|
60
|
+
"@dxos/rpc": "0.4.8-main.c2effdb",
|
|
61
|
+
"@dxos/teleport-extension-automerge-replicator": "0.4.8-main.c2effdb",
|
|
62
|
+
"@dxos/teleport": "0.4.8-main.c2effdb",
|
|
63
|
+
"@dxos/teleport-extension-gossip": "0.4.8-main.c2effdb",
|
|
64
|
+
"@dxos/teleport-extension-object-sync": "0.4.8-main.c2effdb",
|
|
65
|
+
"@dxos/teleport-extension-replicator": "0.4.8-main.c2effdb",
|
|
66
|
+
"@dxos/text-model": "0.4.8-main.c2effdb",
|
|
67
|
+
"@dxos/timeframe": "0.4.8-main.c2effdb",
|
|
68
|
+
"@dxos/tracing": "0.4.8-main.c2effdb",
|
|
69
|
+
"@dxos/typings": "0.4.8-main.c2effdb",
|
|
70
|
+
"@dxos/util": "0.4.8-main.c2effdb"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"fast-check": "^3.15.1",
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from '@dxos/automerge/automerge-repo';
|
|
14
14
|
import { IndexedDBStorageAdapter } from '@dxos/automerge/automerge-repo-storage-indexeddb';
|
|
15
15
|
import { type Stream } from '@dxos/codec-protobuf';
|
|
16
|
-
import { Context
|
|
16
|
+
import { Context } from '@dxos/context';
|
|
17
17
|
import { PublicKey } from '@dxos/keys';
|
|
18
18
|
import { log } from '@dxos/log';
|
|
19
19
|
import { idCodec } from '@dxos/protocols';
|
|
@@ -31,7 +31,7 @@ import { MeshNetworkAdapter } from './mesh-network-adapter';
|
|
|
31
31
|
export type { DocumentId };
|
|
32
32
|
|
|
33
33
|
export interface MetadataMethods {
|
|
34
|
-
markDirty(
|
|
34
|
+
markDirty(idToLastHash: Map<string, string>): Promise<void>;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
export type AutomergeHostParams = {
|
|
@@ -98,15 +98,13 @@ export class AutomergeHost {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
try {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (!rawSpaceKey) {
|
|
101
|
+
const spaceKey = getSpaceKeyFromDoc(doc);
|
|
102
|
+
if (!spaceKey) {
|
|
104
103
|
log('space key not found for share policy check', { peerId, documentId });
|
|
105
104
|
return false;
|
|
106
105
|
}
|
|
107
106
|
|
|
108
|
-
const
|
|
109
|
-
const authorizedDevices = this._authorizedDevices.get(spaceKey);
|
|
107
|
+
const authorizedDevices = this._authorizedDevices.get(PublicKey.from(spaceKey));
|
|
110
108
|
|
|
111
109
|
// TODO(mykola): Hack, stop abusing `peerMetadata` field.
|
|
112
110
|
const deviceKeyHex = (this.repo.peerMetadataByPeerId[peerId] as any)?.dxos_deviceKey;
|
|
@@ -164,8 +162,7 @@ export class AutomergeHost {
|
|
|
164
162
|
}
|
|
165
163
|
|
|
166
164
|
private _onUpdate(event: DocHandleChangePayload<any>) {
|
|
167
|
-
|
|
168
|
-
if (!spaceKey) {
|
|
165
|
+
if (this._metadata == null) {
|
|
169
166
|
return;
|
|
170
167
|
}
|
|
171
168
|
|
|
@@ -180,24 +177,16 @@ export class AutomergeHost {
|
|
|
180
177
|
return;
|
|
181
178
|
}
|
|
182
179
|
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
this._metadata!.markDirty(
|
|
188
|
-
idCodec.encode({ documentId: event.handle.documentId, objectId }),
|
|
189
|
-
lastAvailableHash,
|
|
190
|
-
),
|
|
191
|
-
);
|
|
192
|
-
}),
|
|
193
|
-
)
|
|
180
|
+
const encodedIds = objectIds.map((objectId) => idCodec.encode({ documentId: event.handle.documentId, objectId }));
|
|
181
|
+
const idToLastHash = new Map(encodedIds.map((id) => [id, lastAvailableHash]));
|
|
182
|
+
const markingDirtyPromise = this._metadata
|
|
183
|
+
.markDirty(idToLastHash)
|
|
194
184
|
.then(() => {
|
|
195
185
|
this._updatingMetadata.delete(event.handle.documentId);
|
|
196
186
|
})
|
|
197
187
|
.catch((err: Error) => {
|
|
198
|
-
|
|
188
|
+
this._ctx.disposed && log.catch(err);
|
|
199
189
|
});
|
|
200
|
-
|
|
201
190
|
this._updatingMetadata.set(event.handle.documentId, markingDirtyPromise);
|
|
202
191
|
}
|
|
203
192
|
|
|
@@ -285,3 +274,13 @@ const getInlineChanges = (event: DocHandleChangePayload<any>) => {
|
|
|
285
274
|
}
|
|
286
275
|
return [...inlineChangedObjectIds];
|
|
287
276
|
};
|
|
277
|
+
|
|
278
|
+
export const getSpaceKeyFromDoc = (doc: any): string | null => {
|
|
279
|
+
// experimental_spaceKey is set on old documents, new ones are created with doc.access.spaceKey
|
|
280
|
+
const rawSpaceKey = doc.access?.spaceKey ?? doc.experimental_spaceKey;
|
|
281
|
+
if (rawSpaceKey == null) {
|
|
282
|
+
return null;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
return String(rawSpaceKey);
|
|
286
|
+
};
|
|
@@ -5,20 +5,18 @@
|
|
|
5
5
|
// Copyright 2023 DXOS.org
|
|
6
6
|
//
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { type Chunk, type StorageKey, type StorageAdapterInterface } from '@dxos/automerge/automerge-repo';
|
|
9
9
|
import { type Directory } from '@dxos/random-access-storage';
|
|
10
10
|
import { arrayToBuffer, bufferToArray } from '@dxos/util';
|
|
11
11
|
|
|
12
|
-
export class AutomergeStorageAdapter
|
|
12
|
+
export class AutomergeStorageAdapter implements StorageAdapterInterface {
|
|
13
13
|
// TODO(mykola): Hack for restricting automerge Repo to access storage if Host is `closed`.
|
|
14
14
|
// Automerge Repo do not have any lifetime management.
|
|
15
15
|
private _state: 'opened' | 'closed' = 'opened';
|
|
16
16
|
|
|
17
|
-
constructor(private readonly _directory: Directory) {
|
|
18
|
-
super();
|
|
19
|
-
}
|
|
17
|
+
constructor(private readonly _directory: Directory) {}
|
|
20
18
|
|
|
21
|
-
|
|
19
|
+
async load(key: StorageKey): Promise<Uint8Array | undefined> {
|
|
22
20
|
if (this._state !== 'opened') {
|
|
23
21
|
return undefined;
|
|
24
22
|
}
|
|
@@ -32,7 +30,7 @@ export class AutomergeStorageAdapter extends StorageAdapter {
|
|
|
32
30
|
return bufferToArray(buffer);
|
|
33
31
|
}
|
|
34
32
|
|
|
35
|
-
|
|
33
|
+
async save(key: StorageKey, data: Uint8Array): Promise<void> {
|
|
36
34
|
if (this._state !== 'opened') {
|
|
37
35
|
return undefined;
|
|
38
36
|
}
|
|
@@ -44,7 +42,7 @@ export class AutomergeStorageAdapter extends StorageAdapter {
|
|
|
44
42
|
await file.flush?.();
|
|
45
43
|
}
|
|
46
44
|
|
|
47
|
-
|
|
45
|
+
async remove(key: StorageKey): Promise<void> {
|
|
48
46
|
if (this._state !== 'opened') {
|
|
49
47
|
return undefined;
|
|
50
48
|
}
|
|
@@ -54,7 +52,7 @@ export class AutomergeStorageAdapter extends StorageAdapter {
|
|
|
54
52
|
await file.destroy();
|
|
55
53
|
}
|
|
56
54
|
|
|
57
|
-
|
|
55
|
+
async loadRange(keyPrefix: StorageKey): Promise<Chunk[]> {
|
|
58
56
|
if (this._state !== 'opened') {
|
|
59
57
|
return [];
|
|
60
58
|
}
|
|
@@ -75,7 +73,7 @@ export class AutomergeStorageAdapter extends StorageAdapter {
|
|
|
75
73
|
);
|
|
76
74
|
}
|
|
77
75
|
|
|
78
|
-
|
|
76
|
+
async removeRange(keyPrefix: StorageKey): Promise<void> {
|
|
79
77
|
if (this._state !== 'opened') {
|
|
80
78
|
return undefined;
|
|
81
79
|
}
|