@automerge/automerge-repo-network-websocket 1.0.2 → 1.0.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/index.d.ts CHANGED
@@ -1,3 +1,19 @@
1
+ /**
2
+ * A `NetworkAdapter` which connects to a remote host via WebSockets
3
+ *
4
+ * The websocket protocol requires a server to be listening and a client to
5
+ * connect to the server. To that end the {@link NodeWSServerAdapter} does not
6
+ * make outbound connections and instead listens on the provided socket for
7
+ * new connections whilst the {@link BrowserWebSocketClientAdapter} makes an
8
+ * outbound connection to the provided socket.
9
+ *
10
+ * Note that the "browser" and "node" naming is a bit misleading, both
11
+ * implementations work in both the browser and on node via `isomorphic-ws`.
12
+ *
13
+ * @module
14
+ * */
1
15
  export { BrowserWebSocketClientAdapter } from "./BrowserWebSocketClientAdapter.js";
2
16
  export { NodeWSServerAdapter } from "./NodeWSServerAdapter.js";
17
+ export type { FromClientMessage, FromServerMessage, JoinMessage, LeaveMessage, ErrorMessage, PeerMessage } from "./messages.js";
18
+ export type { ProtocolVersion, ProtocolV1 } from "./protocolVersion.js";
3
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAA;AAClF,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;KAaK;AACL,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAA;AAClF,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC/H,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA"}
package/dist/index.js CHANGED
@@ -1,2 +1,16 @@
1
+ /**
2
+ * A `NetworkAdapter` which connects to a remote host via WebSockets
3
+ *
4
+ * The websocket protocol requires a server to be listening and a client to
5
+ * connect to the server. To that end the {@link NodeWSServerAdapter} does not
6
+ * make outbound connections and instead listens on the provided socket for
7
+ * new connections whilst the {@link BrowserWebSocketClientAdapter} makes an
8
+ * outbound connection to the provided socket.
9
+ *
10
+ * Note that the "browser" and "node" naming is a bit misleading, both
11
+ * implementations work in both the browser and on node via `isomorphic-ws`.
12
+ *
13
+ * @module
14
+ * */
1
15
  export { BrowserWebSocketClientAdapter } from "./BrowserWebSocketClientAdapter.js";
2
16
  export { NodeWSServerAdapter } from "./NodeWSServerAdapter.js";
@@ -1,26 +1,40 @@
1
1
  import { type Message, type PeerId } from "@automerge/automerge-repo";
2
2
  import { ProtocolVersion } from "./protocolVersion.js";
3
+ /** The sender is disconnecting */
3
4
  export type LeaveMessage = {
4
5
  type: "leave";
5
6
  senderId: PeerId;
6
7
  };
8
+ /** Sent by the client to the server to tell the server the clients PeerID */
7
9
  export type JoinMessage = {
8
10
  type: "join";
11
+ /** The PeerID of the client */
9
12
  senderId: PeerId;
13
+ /** The protocol version the client supports */
10
14
  supportedProtocolVersions: ProtocolVersion[];
11
15
  };
16
+ /** Sent by the server in response to a "join" message to advertise the servers PeerID */
12
17
  export type PeerMessage = {
13
18
  type: "peer";
19
+ /** The PeerID of the server */
14
20
  senderId: PeerId;
21
+ /** The protocol version the server selected for this connection */
15
22
  selectedProtocolVersion: ProtocolVersion;
23
+ /** The PeerID of the client */
16
24
  targetId: PeerId;
17
25
  };
26
+ /** An error occurred. The other end will terminate the connection after sending this message */
18
27
  export type ErrorMessage = {
19
28
  type: "error";
29
+ /** The peer sending the message */
20
30
  senderId: PeerId;
31
+ /** A description of the error*/
21
32
  message: string;
33
+ /** The PeerID of the client */
22
34
  targetId: PeerId;
23
35
  };
36
+ /** A message from the client to the server */
24
37
  export type FromClientMessage = JoinMessage | LeaveMessage | Message;
38
+ /** A message from the server to the client */
25
39
  export type FromServerMessage = PeerMessage | ErrorMessage | Message;
26
40
  //# sourceMappingURL=messages.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,2BAA2B,CAAA;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEtD,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,OAAO,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,yBAAyB,EAAE,eAAe,EAAE,CAAA;CAC7C,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,uBAAuB,EAAE,eAAe,CAAA;IACxC,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,OAAO,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAGD,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG,YAAY,GAAG,OAAO,CAAA;AACpE,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG,YAAY,GAAG,OAAO,CAAA"}
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,2BAA2B,CAAA;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEtD,kCAAkC;AAClC,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,OAAO,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,6EAA6E;AAC7E,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAA;IAChB,+CAA+C;IAC/C,yBAAyB,EAAE,eAAe,EAAE,CAAA;CAC7C,CAAA;AAED,yFAAyF;AACzF,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAA;IAChB,mEAAmE;IACnE,uBAAuB,EAAE,eAAe,CAAA;IACxC,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,gGAAgG;AAChG,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,OAAO,CAAA;IACb,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAA;IAChB,gCAAgC;IAChC,OAAO,EAAE,MAAM,CAAA;IACf,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAGD,8CAA8C;AAC9C,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG,YAAY,GAAG,OAAO,CAAA;AACpE,8CAA8C;AAC9C,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG,YAAY,GAAG,OAAO,CAAA"}
@@ -1,3 +1,4 @@
1
1
  export declare const ProtocolV1 = "1";
2
+ /** The versions of the websocket protocol */
2
3
  export type ProtocolVersion = typeof ProtocolV1;
3
4
  //# sourceMappingURL=protocolVersion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"protocolVersion.d.ts","sourceRoot":"","sources":["../src/protocolVersion.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,MAAM,CAAA;AAC7B,MAAM,MAAM,eAAe,GAAG,OAAO,UAAU,CAAA"}
1
+ {"version":3,"file":"protocolVersion.d.ts","sourceRoot":"","sources":["../src/protocolVersion.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,MAAM,CAAA;AAC7B,6CAA6C;AAC7C,MAAM,MAAM,eAAe,GAAG,OAAO,UAAU,CAAA"}
package/package.json CHANGED
@@ -1,14 +1,13 @@
1
1
  {
2
2
  "name": "@automerge/automerge-repo-network-websocket",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "isomorphic node/browser Websocket network adapter for Automerge Repo",
5
5
  "peerDependencies": {
6
6
  "@automerge/automerge": "^2.1.0"
7
7
  },
8
- "repository": "https://github.com/automerge/automerge-repo",
8
+ "repository": "https://github.com/automerge/automerge-repo/tree/master/packages/automerge-repo-network-websocket",
9
9
  "author": "Peter van Hardenberg <pvh@pvh.ca>",
10
10
  "license": "MIT",
11
- "private": false,
12
11
  "type": "module",
13
12
  "main": "dist/index.js",
14
13
  "scripts": {
@@ -17,9 +16,9 @@
17
16
  "test": "mocha --no-warnings --experimental-specifier-resolution=node --exit"
18
17
  },
19
18
  "dependencies": {
20
- "@automerge/automerge-repo": "^1.0.2",
19
+ "@automerge/automerge-repo": "^1.0.4",
21
20
  "cbor-x": "^1.3.0",
22
- "eventemitter3": "^4.0.7",
21
+ "eventemitter3": "^5.0.1",
23
22
  "isomorphic-ws": "^5.0.0",
24
23
  "ws": "^8.7.0"
25
24
  },
@@ -34,5 +33,8 @@
34
33
  "publishConfig": {
35
34
  "access": "public"
36
35
  },
37
- "gitHead": "c72b9ec33c3a1f7f39ad20cb4fa0d766afe42158"
36
+ "devDependencies": {
37
+ "@automerge/automerge": "^2.1.0"
38
+ },
39
+ "gitHead": "17fd5260f9af3e65da636fef084e8c04d6c4bed0"
38
40
  }
package/src/index.ts CHANGED
@@ -1,2 +1,18 @@
1
+ /**
2
+ * A `NetworkAdapter` which connects to a remote host via WebSockets
3
+ *
4
+ * The websocket protocol requires a server to be listening and a client to
5
+ * connect to the server. To that end the {@link NodeWSServerAdapter} does not
6
+ * make outbound connections and instead listens on the provided socket for
7
+ * new connections whilst the {@link BrowserWebSocketClientAdapter} makes an
8
+ * outbound connection to the provided socket.
9
+ *
10
+ * Note that the "browser" and "node" naming is a bit misleading, both
11
+ * implementations work in both the browser and on node via `isomorphic-ws`.
12
+ *
13
+ * @module
14
+ * */
1
15
  export { BrowserWebSocketClientAdapter } from "./BrowserWebSocketClientAdapter.js"
2
16
  export { NodeWSServerAdapter } from "./NodeWSServerAdapter.js"
17
+ export type { FromClientMessage, FromServerMessage, JoinMessage, LeaveMessage, ErrorMessage, PeerMessage } from "./messages.js"
18
+ export type { ProtocolVersion, ProtocolV1 } from "./protocolVersion.js"
package/src/messages.ts CHANGED
@@ -1,31 +1,45 @@
1
1
  import { type Message, type PeerId } from "@automerge/automerge-repo"
2
2
  import { ProtocolVersion } from "./protocolVersion.js"
3
3
 
4
+ /** The sender is disconnecting */
4
5
  export type LeaveMessage = {
5
6
  type: "leave"
6
7
  senderId: PeerId
7
8
  }
8
9
 
10
+ /** Sent by the client to the server to tell the server the clients PeerID */
9
11
  export type JoinMessage = {
10
12
  type: "join"
13
+ /** The PeerID of the client */
11
14
  senderId: PeerId
15
+ /** The protocol version the client supports */
12
16
  supportedProtocolVersions: ProtocolVersion[]
13
17
  }
14
18
 
19
+ /** Sent by the server in response to a "join" message to advertise the servers PeerID */
15
20
  export type PeerMessage = {
16
21
  type: "peer"
22
+ /** The PeerID of the server */
17
23
  senderId: PeerId
24
+ /** The protocol version the server selected for this connection */
18
25
  selectedProtocolVersion: ProtocolVersion
26
+ /** The PeerID of the client */
19
27
  targetId: PeerId
20
28
  }
21
29
 
30
+ /** An error occurred. The other end will terminate the connection after sending this message */
22
31
  export type ErrorMessage = {
23
32
  type: "error"
33
+ /** The peer sending the message */
24
34
  senderId: PeerId
35
+ /** A description of the error*/
25
36
  message: string
37
+ /** The PeerID of the client */
26
38
  targetId: PeerId
27
39
  }
28
40
 
29
41
  // This adapter doesn't use NetworkAdapterMessage, it has its own idea of how to handle join/leave
42
+ /** A message from the client to the server */
30
43
  export type FromClientMessage = JoinMessage | LeaveMessage | Message
44
+ /** A message from the server to the client */
31
45
  export type FromServerMessage = PeerMessage | ErrorMessage | Message
@@ -1,2 +1,3 @@
1
1
  export const ProtocolV1 = "1"
2
+ /** The versions of the websocket protocol */
2
3
  export type ProtocolVersion = typeof ProtocolV1
package/typedoc.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": "../../typedoc.base.json",
3
+ "entryPoints": ["src/index.ts"],
4
+ "readme": "none"
5
+ }