@dxos/echo-pipeline 0.4.8-main.2d8e727 → 0.4.8-main.512e4c8
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-M7BOB47J.mjs → chunk-XR2636AC.mjs} +21 -22
- package/dist/lib/browser/{chunk-M7BOB47J.mjs.map → chunk-XR2636AC.mjs.map} +3 -3
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +1 -1
- package/dist/lib/node/{chunk-B5LDK2PA.cjs → chunk-LD4R726W.cjs} +23 -24
- package/dist/lib/node/{chunk-B5LDK2PA.cjs.map → chunk-LD4R726W.cjs.map} +3 -3
- package/dist/lib/node/index.cjs +30 -30
- package/dist/lib/node/index.cjs.map +1 -1
- 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 -2
- package/dist/types/src/automerge/automerge-host.d.ts.map +1 -1
- package/package.json +33 -33
- package/src/automerge/automerge-host.ts +16 -26
|
@@ -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 = {
|
|
@@ -104,7 +104,7 @@ export class AutomergeHost {
|
|
|
104
104
|
return false;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
const authorizedDevices = this._authorizedDevices.get(spaceKey);
|
|
107
|
+
const authorizedDevices = this._authorizedDevices.get(PublicKey.from(spaceKey));
|
|
108
108
|
|
|
109
109
|
// TODO(mykola): Hack, stop abusing `peerMetadata` field.
|
|
110
110
|
const deviceKeyHex = (this.repo.peerMetadataByPeerId[peerId] as any)?.dxos_deviceKey;
|
|
@@ -162,8 +162,8 @@ export class AutomergeHost {
|
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
private _onUpdate(event: DocHandleChangePayload<any>) {
|
|
165
|
-
const spaceKey = event.doc
|
|
166
|
-
if (!spaceKey) {
|
|
165
|
+
const spaceKey = getSpaceKeyFromDoc(event.doc);
|
|
166
|
+
if (!spaceKey || this._metadata == null) {
|
|
167
167
|
return;
|
|
168
168
|
}
|
|
169
169
|
|
|
@@ -178,28 +178,18 @@ export class AutomergeHost {
|
|
|
178
178
|
return;
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
await cancelWithContext(
|
|
188
|
-
this._ctx,
|
|
189
|
-
this._metadata!.markDirty(
|
|
190
|
-
idCodec.encode({ documentId: event.handle.documentId, objectId, spaceKey }),
|
|
191
|
-
lastAvailableHash,
|
|
192
|
-
),
|
|
193
|
-
);
|
|
194
|
-
}),
|
|
195
|
-
)
|
|
181
|
+
const encodedIds = objectIds.map((objectId) =>
|
|
182
|
+
idCodec.encode({ documentId: event.handle.documentId, objectId, spaceKey }),
|
|
183
|
+
);
|
|
184
|
+
const idToLastHash = new Map(encodedIds.map((id) => [id, lastAvailableHash]));
|
|
185
|
+
const markingDirtyPromise = this._metadata
|
|
186
|
+
.markDirty(idToLastHash)
|
|
196
187
|
.then(() => {
|
|
197
188
|
this._updatingMetadata.delete(event.handle.documentId);
|
|
198
189
|
})
|
|
199
190
|
.catch((err: Error) => {
|
|
200
|
-
|
|
191
|
+
this._ctx.disposed && log.catch(err);
|
|
201
192
|
});
|
|
202
|
-
|
|
203
193
|
this._updatingMetadata.set(event.handle.documentId, markingDirtyPromise);
|
|
204
194
|
}
|
|
205
195
|
|
|
@@ -288,12 +278,12 @@ const getInlineChanges = (event: DocHandleChangePayload<any>) => {
|
|
|
288
278
|
return [...inlineChangedObjectIds];
|
|
289
279
|
};
|
|
290
280
|
|
|
291
|
-
export const getSpaceKeyFromDoc = (doc: any) => {
|
|
281
|
+
export const getSpaceKeyFromDoc = (doc: any): string | null => {
|
|
292
282
|
// experimental_spaceKey is set on old documents, new ones are created with doc.access.spaceKey
|
|
293
283
|
const rawSpaceKey = doc.access?.spaceKey ?? doc.experimental_spaceKey;
|
|
294
|
-
if (
|
|
295
|
-
return;
|
|
284
|
+
if (rawSpaceKey == null) {
|
|
285
|
+
return null;
|
|
296
286
|
}
|
|
297
287
|
|
|
298
|
-
return rawSpaceKey;
|
|
288
|
+
return String(rawSpaceKey);
|
|
299
289
|
};
|