@automerge/automerge-repo-network-broadcastchannel 0.2.1 → 1.0.0-alpha.0
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/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -8
- package/package.json +6 -3
- package/src/index.ts +7 -10
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export declare class BroadcastChannelNetworkAdapter extends NetworkAdapter {
|
|
|
3
3
|
#private;
|
|
4
4
|
connect(peerId: PeerId): void;
|
|
5
5
|
sendMessage(peerId: PeerId, channelId: ChannelId, uint8message: Uint8Array, broadcast: boolean): void;
|
|
6
|
-
join(
|
|
7
|
-
leave(
|
|
6
|
+
join(): void;
|
|
7
|
+
leave(): void;
|
|
8
8
|
}
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAE7E,qBAAa,8BAA+B,SAAQ,cAAc;;IAGhE,OAAO,CAAC,MAAM,EAAE,MAAM;IA0CtB,WAAW,CACT,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,UAAU,EACxB,SAAS,EAAE,OAAO;IAgBpB,IAAI
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAE7E,qBAAa,8BAA+B,SAAQ,cAAc;;IAGhE,OAAO,CAAC,MAAM,EAAE,MAAM;IA0CtB,WAAW,CACT,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,UAAU,EACxB,SAAS,EAAE,OAAO;IAgBpB,IAAI;IAQJ,KAAK;CAIN"}
|
package/dist/index.js
CHANGED
|
@@ -16,10 +16,10 @@ export class BroadcastChannelNetworkAdapter extends NetworkAdapter {
|
|
|
16
16
|
targetId: senderId,
|
|
17
17
|
type: "welcome",
|
|
18
18
|
});
|
|
19
|
-
this.#announceConnection(
|
|
19
|
+
this.#announceConnection(senderId);
|
|
20
20
|
break;
|
|
21
21
|
case "welcome":
|
|
22
|
-
this.#announceConnection(
|
|
22
|
+
this.#announceConnection(senderId);
|
|
23
23
|
break;
|
|
24
24
|
case "message":
|
|
25
25
|
this.emit("message", {
|
|
@@ -35,8 +35,8 @@ export class BroadcastChannelNetworkAdapter extends NetworkAdapter {
|
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
|
-
#announceConnection(
|
|
39
|
-
this.emit("peer-candidate", { peerId
|
|
38
|
+
#announceConnection(peerId) {
|
|
39
|
+
this.emit("peer-candidate", { peerId });
|
|
40
40
|
}
|
|
41
41
|
sendMessage(peerId, channelId, uint8message, broadcast) {
|
|
42
42
|
const message = uint8message.buffer.slice(uint8message.byteOffset, uint8message.byteOffset + uint8message.byteLength);
|
|
@@ -49,16 +49,15 @@ export class BroadcastChannelNetworkAdapter extends NetworkAdapter {
|
|
|
49
49
|
broadcast,
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
|
-
join(
|
|
52
|
+
join() {
|
|
53
53
|
this.#broadcastChannel.postMessage({
|
|
54
54
|
senderId: this.peerId,
|
|
55
|
-
channelId: joinChannelId,
|
|
56
55
|
type: "arrive",
|
|
57
56
|
broadcast: true,
|
|
58
57
|
});
|
|
59
58
|
}
|
|
60
|
-
leave(
|
|
59
|
+
leave() {
|
|
61
60
|
// TODO
|
|
62
|
-
throw new Error("Unimplemented: leave on BroadcastChannelNetworkAdapter
|
|
61
|
+
throw new Error("Unimplemented: leave on BroadcastChannelNetworkAdapter");
|
|
63
62
|
}
|
|
64
63
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automerge/automerge-repo-network-broadcastchannel",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-alpha.0",
|
|
4
4
|
"description": "BroadcastChannel network adapter for Automerge Repo",
|
|
5
5
|
"repository": "https://github.com/automerge/automerge-repo",
|
|
6
6
|
"author": "Peter van Hardenberg <pvh@pvh.ca>",
|
|
@@ -13,8 +13,11 @@
|
|
|
13
13
|
"watch": "npm-watch",
|
|
14
14
|
"test": "mocha --no-warnings --experimental-specifier-resolution=node --exit"
|
|
15
15
|
},
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"@automerge/automerge": "^2.1.0-alpha.9"
|
|
18
|
+
},
|
|
16
19
|
"dependencies": {
|
|
17
|
-
"@automerge/automerge-repo": "^0.
|
|
20
|
+
"@automerge/automerge-repo": "^1.0.0-alpha.0"
|
|
18
21
|
},
|
|
19
22
|
"watch": {
|
|
20
23
|
"build": {
|
|
@@ -27,5 +30,5 @@
|
|
|
27
30
|
"publishConfig": {
|
|
28
31
|
"access": "public"
|
|
29
32
|
},
|
|
30
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "38c0c32796ddca5f86a2e55ab0f1202a2ce107c8"
|
|
31
34
|
}
|
package/src/index.ts
CHANGED
|
@@ -21,10 +21,10 @@ export class BroadcastChannelNetworkAdapter extends NetworkAdapter {
|
|
|
21
21
|
targetId: senderId,
|
|
22
22
|
type: "welcome",
|
|
23
23
|
})
|
|
24
|
-
this.#announceConnection(
|
|
24
|
+
this.#announceConnection(senderId)
|
|
25
25
|
break
|
|
26
26
|
case "welcome":
|
|
27
|
-
this.#announceConnection(
|
|
27
|
+
this.#announceConnection(senderId)
|
|
28
28
|
break
|
|
29
29
|
case "message":
|
|
30
30
|
this.emit("message", {
|
|
@@ -41,8 +41,8 @@ export class BroadcastChannelNetworkAdapter extends NetworkAdapter {
|
|
|
41
41
|
})
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
#announceConnection(
|
|
45
|
-
this.emit("peer-candidate", { peerId
|
|
44
|
+
#announceConnection(peerId: PeerId) {
|
|
45
|
+
this.emit("peer-candidate", { peerId })
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
sendMessage(
|
|
@@ -65,19 +65,16 @@ export class BroadcastChannelNetworkAdapter extends NetworkAdapter {
|
|
|
65
65
|
})
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
join(
|
|
68
|
+
join() {
|
|
69
69
|
this.#broadcastChannel.postMessage({
|
|
70
70
|
senderId: this.peerId,
|
|
71
|
-
channelId: joinChannelId,
|
|
72
71
|
type: "arrive",
|
|
73
72
|
broadcast: true,
|
|
74
73
|
})
|
|
75
74
|
}
|
|
76
75
|
|
|
77
|
-
leave(
|
|
76
|
+
leave() {
|
|
78
77
|
// TODO
|
|
79
|
-
throw new Error(
|
|
80
|
-
"Unimplemented: leave on BroadcastChannelNetworkAdapter: " + channelId
|
|
81
|
-
)
|
|
78
|
+
throw new Error("Unimplemented: leave on BroadcastChannelNetworkAdapter")
|
|
82
79
|
}
|
|
83
80
|
}
|