@automerge/automerge-repo 1.0.0-alpha.2 → 1.0.0-alpha.4
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/DocCollection.d.ts +4 -2
- package/dist/DocCollection.d.ts.map +1 -1
- package/dist/DocCollection.js +20 -11
- package/dist/DocHandle.d.ts +34 -6
- package/dist/DocHandle.d.ts.map +1 -1
- package/dist/DocHandle.js +69 -9
- package/dist/DocUrl.d.ts +4 -4
- package/dist/DocUrl.d.ts.map +1 -1
- package/dist/DocUrl.js +9 -9
- package/dist/EphemeralData.d.ts +8 -16
- package/dist/EphemeralData.d.ts.map +1 -1
- package/dist/EphemeralData.js +1 -28
- package/dist/Repo.d.ts +0 -2
- package/dist/Repo.d.ts.map +1 -1
- package/dist/Repo.js +37 -39
- package/dist/helpers/cbor.d.ts +4 -0
- package/dist/helpers/cbor.d.ts.map +1 -0
- package/dist/helpers/cbor.js +8 -0
- package/dist/helpers/eventPromise.d.ts +1 -1
- package/dist/helpers/eventPromise.d.ts.map +1 -1
- package/dist/helpers/headsAreSame.d.ts +0 -1
- package/dist/helpers/headsAreSame.d.ts.map +1 -1
- package/dist/helpers/tests/network-adapter-tests.d.ts.map +1 -1
- package/dist/helpers/tests/network-adapter-tests.js +15 -13
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/network/NetworkAdapter.d.ts +6 -15
- package/dist/network/NetworkAdapter.d.ts.map +1 -1
- package/dist/network/NetworkAdapter.js +1 -1
- package/dist/network/NetworkSubsystem.d.ts +9 -6
- package/dist/network/NetworkSubsystem.d.ts.map +1 -1
- package/dist/network/NetworkSubsystem.js +69 -32
- package/dist/network/messages.d.ts +57 -0
- package/dist/network/messages.d.ts.map +1 -0
- package/dist/network/messages.js +21 -0
- package/dist/storage/StorageSubsystem.d.ts +1 -1
- package/dist/storage/StorageSubsystem.d.ts.map +1 -1
- package/dist/storage/StorageSubsystem.js +2 -2
- package/dist/synchronizer/CollectionSynchronizer.d.ts +3 -2
- package/dist/synchronizer/CollectionSynchronizer.d.ts.map +1 -1
- package/dist/synchronizer/CollectionSynchronizer.js +19 -13
- package/dist/synchronizer/DocSynchronizer.d.ts +9 -3
- package/dist/synchronizer/DocSynchronizer.d.ts.map +1 -1
- package/dist/synchronizer/DocSynchronizer.js +149 -34
- package/dist/synchronizer/Synchronizer.d.ts +4 -5
- package/dist/synchronizer/Synchronizer.d.ts.map +1 -1
- package/dist/synchronizer/Synchronizer.js +1 -1
- package/dist/types.d.ts +1 -3
- package/dist/types.d.ts.map +1 -1
- package/fuzz/fuzz.ts +5 -5
- package/package.json +3 -3
- package/src/DocCollection.ts +23 -12
- package/src/DocHandle.ts +120 -13
- package/src/DocUrl.ts +10 -10
- package/src/EphemeralData.ts +6 -36
- package/src/Repo.ts +37 -55
- package/src/helpers/cbor.ts +10 -0
- package/src/helpers/eventPromise.ts +1 -1
- package/src/helpers/headsAreSame.ts +1 -1
- package/src/helpers/tests/network-adapter-tests.ts +18 -14
- package/src/index.ts +14 -2
- package/src/network/NetworkAdapter.ts +6 -22
- package/src/network/NetworkSubsystem.ts +94 -44
- package/src/network/messages.ts +123 -0
- package/src/storage/StorageSubsystem.ts +2 -2
- package/src/synchronizer/CollectionSynchronizer.ts +38 -19
- package/src/synchronizer/DocSynchronizer.ts +201 -43
- package/src/synchronizer/Synchronizer.ts +4 -9
- package/src/types.ts +4 -1
- package/test/CollectionSynchronizer.test.ts +6 -7
- package/test/DocCollection.test.ts +2 -2
- package/test/DocHandle.test.ts +32 -17
- package/test/DocSynchronizer.test.ts +85 -9
- package/test/Repo.test.ts +267 -63
- package/test/StorageSubsystem.test.ts +4 -5
- package/test/helpers/DummyNetworkAdapter.ts +12 -3
- package/test/helpers/DummyStorageAdapter.ts +1 -1
- package/tsconfig.json +4 -3
- package/test/EphemeralData.test.ts +0 -44
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import assert from "assert"
|
|
2
|
-
import * as CBOR from "cbor-x"
|
|
3
|
-
import { EphemeralData } from "../src/EphemeralData.js"
|
|
4
|
-
import { ChannelId, PeerId } from "../src/types.js"
|
|
5
|
-
|
|
6
|
-
describe("EphemeralData", () => {
|
|
7
|
-
const ephemeral = new EphemeralData()
|
|
8
|
-
const otherPeerId = "other_peer" as PeerId
|
|
9
|
-
const destinationChannelId = "channel_id" as ChannelId
|
|
10
|
-
const messageData = { foo: "bar" }
|
|
11
|
-
|
|
12
|
-
it("should emit a network message on broadcast()", done => {
|
|
13
|
-
ephemeral.on("message", event => {
|
|
14
|
-
try {
|
|
15
|
-
const { targetId, channelId, message, broadcast } = event
|
|
16
|
-
assert.deepStrictEqual(CBOR.decode(message), messageData)
|
|
17
|
-
assert.strictEqual(broadcast, true)
|
|
18
|
-
assert.strictEqual(channelId, channelId)
|
|
19
|
-
done()
|
|
20
|
-
} catch (e) {
|
|
21
|
-
done(e)
|
|
22
|
-
}
|
|
23
|
-
})
|
|
24
|
-
ephemeral.broadcast(destinationChannelId, messageData)
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
it("should emit a data event on receive()", done => {
|
|
28
|
-
ephemeral.on("data", ({ peerId, channelId, data }) => {
|
|
29
|
-
try {
|
|
30
|
-
assert.deepStrictEqual(peerId, otherPeerId)
|
|
31
|
-
assert.deepStrictEqual(channelId, destinationChannelId)
|
|
32
|
-
assert.deepStrictEqual(data, messageData)
|
|
33
|
-
done()
|
|
34
|
-
} catch (e) {
|
|
35
|
-
done(e)
|
|
36
|
-
}
|
|
37
|
-
})
|
|
38
|
-
ephemeral.receive(
|
|
39
|
-
otherPeerId,
|
|
40
|
-
("m/" + destinationChannelId) as ChannelId, // TODO: this is nonsense
|
|
41
|
-
CBOR.encode(messageData)
|
|
42
|
-
)
|
|
43
|
-
})
|
|
44
|
-
})
|