@automerge/automerge-repo-network-broadcastchannel 1.0.1 → 1.0.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/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -0
- package/package.json +3 -3
- package/src/index.ts +17 -0
- package/typedoc.json +5 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* A `NetworkAdapter` which uses [BroadcastChannel](https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel)
|
|
4
|
+
* to communicate with other peers in the same browser tab. This is a bit of a
|
|
5
|
+
* hack because `NetworkAdapter`s are supposed to be used as point to
|
|
6
|
+
* point communication channels. To get around this the {@link BroadcastChannelNetworkAdapter}
|
|
7
|
+
* broadcasts messages to all peers and then filters out messages not intended
|
|
8
|
+
* for the current peer. This is quite inefficient as messages get duplicated
|
|
9
|
+
* for every peer in the tab, but as it's all local communication anyway
|
|
10
|
+
* it's not too bad. If efficiency is becoming an issue you can switch to
|
|
11
|
+
* `automerge-repo-network-messagechannel`.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
1
16
|
import { NetworkAdapter, PeerId, Message } from "@automerge/automerge-repo";
|
|
2
17
|
export type BroadcastChannelNetworkAdapterOptions = {
|
|
3
18
|
channelName: string;
|
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,EAEL,cAAc,EACd,MAAM,EACN,OAAO,EACR,MAAM,2BAA2B,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAEL,cAAc,EACd,MAAM,EACN,OAAO,EACR,MAAM,2BAA2B,CAAA;AAGlC,MAAM,MAAM,qCAAqC,GAAG;IAClD,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,qBAAa,8BAA+B,SAAQ,cAAc;;gBAKpD,OAAO,CAAC,EAAE,qCAAqC;IAK3D,OAAO,CAAC,MAAM,EAAE,MAAM;IAoDtB,IAAI,CAAC,OAAO,EAAE,OAAO;IAcrB,UAAU;CAIX"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* A `NetworkAdapter` which uses [BroadcastChannel](https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel)
|
|
4
|
+
* to communicate with other peers in the same browser tab. This is a bit of a
|
|
5
|
+
* hack because `NetworkAdapter`s are supposed to be used as point to
|
|
6
|
+
* point communication channels. To get around this the {@link BroadcastChannelNetworkAdapter}
|
|
7
|
+
* broadcasts messages to all peers and then filters out messages not intended
|
|
8
|
+
* for the current peer. This is quite inefficient as messages get duplicated
|
|
9
|
+
* for every peer in the tab, but as it's all local communication anyway
|
|
10
|
+
* it's not too bad. If efficiency is becoming an issue you can switch to
|
|
11
|
+
* `automerge-repo-network-messagechannel`.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
1
16
|
import { NetworkAdapter, } from "@automerge/automerge-repo";
|
|
2
17
|
export class BroadcastChannelNetworkAdapter extends NetworkAdapter {
|
|
3
18
|
#broadcastChannel;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automerge/automerge-repo-network-broadcastchannel",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
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>",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"@automerge/automerge": "^2.1.0"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@automerge/automerge-repo": "^1.0.
|
|
20
|
+
"@automerge/automerge-repo": "^1.0.3"
|
|
21
21
|
},
|
|
22
22
|
"watch": {
|
|
23
23
|
"build": {
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"publishConfig": {
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "4f3391cd33cd0cabfebde48dbd56749ddb6922da"
|
|
34
34
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* A `NetworkAdapter` which uses [BroadcastChannel](https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel)
|
|
4
|
+
* to communicate with other peers in the same browser tab. This is a bit of a
|
|
5
|
+
* hack because `NetworkAdapter`s are supposed to be used as point to
|
|
6
|
+
* point communication channels. To get around this the {@link BroadcastChannelNetworkAdapter}
|
|
7
|
+
* broadcasts messages to all peers and then filters out messages not intended
|
|
8
|
+
* for the current peer. This is quite inefficient as messages get duplicated
|
|
9
|
+
* for every peer in the tab, but as it's all local communication anyway
|
|
10
|
+
* it's not too bad. If efficiency is becoming an issue you can switch to
|
|
11
|
+
* `automerge-repo-network-messagechannel`.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
|
|
1
17
|
import {
|
|
2
18
|
NetworkAdapterMessage,
|
|
3
19
|
NetworkAdapter,
|
|
@@ -5,6 +21,7 @@ import {
|
|
|
5
21
|
Message,
|
|
6
22
|
} from "@automerge/automerge-repo"
|
|
7
23
|
|
|
24
|
+
|
|
8
25
|
export type BroadcastChannelNetworkAdapterOptions = {
|
|
9
26
|
channelName: string
|
|
10
27
|
}
|