@automerge/automerge-repo 1.0.0-alpha.0 → 1.0.0-alpha.3
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 +2 -1
- package/dist/DocCollection.d.ts.map +1 -1
- package/dist/DocCollection.js +17 -8
- package/dist/DocHandle.d.ts +27 -7
- package/dist/DocHandle.d.ts.map +1 -1
- package/dist/DocHandle.js +47 -23
- package/dist/DocUrl.d.ts +3 -3
- 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 +18 -36
- package/dist/helpers/headsAreSame.d.ts +2 -2
- package/dist/helpers/headsAreSame.d.ts.map +1 -1
- package/dist/helpers/headsAreSame.js +1 -4
- 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 +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/network/NetworkAdapter.d.ts +4 -13
- package/dist/network/NetworkAdapter.d.ts.map +1 -1
- package/dist/network/NetworkSubsystem.d.ts +5 -4
- package/dist/network/NetworkSubsystem.d.ts.map +1 -1
- package/dist/network/NetworkSubsystem.js +39 -25
- 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 +2 -2
- package/dist/storage/StorageSubsystem.d.ts.map +1 -1
- package/dist/storage/StorageSubsystem.js +36 -6
- 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 +145 -29
- package/dist/synchronizer/Synchronizer.d.ts +3 -4
- package/dist/synchronizer/Synchronizer.d.ts.map +1 -1
- package/dist/types.d.ts +1 -3
- package/dist/types.d.ts.map +1 -1
- package/fuzz/fuzz.ts +4 -4
- package/package.json +3 -3
- package/src/DocCollection.ts +19 -9
- package/src/DocHandle.ts +82 -37
- package/src/DocUrl.ts +9 -9
- package/src/EphemeralData.ts +6 -36
- package/src/Repo.ts +20 -52
- package/src/helpers/headsAreSame.ts +3 -5
- package/src/helpers/tests/network-adapter-tests.ts +18 -14
- package/src/index.ts +12 -2
- package/src/network/NetworkAdapter.ts +4 -20
- package/src/network/NetworkSubsystem.ts +61 -38
- package/src/network/messages.ts +123 -0
- package/src/storage/StorageSubsystem.ts +42 -6
- package/src/synchronizer/CollectionSynchronizer.ts +38 -19
- package/src/synchronizer/DocSynchronizer.ts +196 -38
- package/src/synchronizer/Synchronizer.ts +3 -8
- package/src/types.ts +4 -1
- package/test/CollectionSynchronizer.test.ts +6 -7
- package/test/DocHandle.test.ts +36 -22
- package/test/DocSynchronizer.test.ts +85 -9
- package/test/Repo.test.ts +279 -59
- package/test/StorageSubsystem.test.ts +9 -9
- package/test/helpers/DummyNetworkAdapter.ts +1 -1
- package/tsconfig.json +2 -1
- 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
|
-
})
|