@automerge/automerge-repo-network-messagechannel
Advanced tools
Comparing version 1.0.0-alpha.3 to 1.0.0-alpha.4
import { type Message, NetworkAdapter, type PeerId } from "@automerge/automerge-repo"; | ||
import { MessagePortRef } from "./MessagePortRef.js"; | ||
export declare class MessageChannelNetworkAdapter extends NetworkAdapter { | ||
#private; | ||
channels: {}; | ||
@@ -5,0 +6,0 @@ messagePortRef: MessagePortRef; |
@@ -9,2 +9,3 @@ import { NetworkAdapter, } from "@automerge/automerge-repo"; | ||
messagePortRef; | ||
#startupComplete = false; | ||
constructor(messagePort, config = {}) { | ||
@@ -56,2 +57,12 @@ super(); | ||
}); | ||
this.join(); | ||
// Mark this messagechannel as ready after 50 ms, at this point there | ||
// must be something weird going on on the other end to cause us to receive | ||
// no response | ||
setTimeout(() => { | ||
if (!this.#startupComplete) { | ||
this.#startupComplete = true; | ||
this.emit("ready", { network: this }); | ||
} | ||
}, 100); | ||
} | ||
@@ -71,2 +82,6 @@ send(message) { | ||
announceConnection(peerId) { | ||
if (!this.#startupComplete) { | ||
this.#startupComplete = true; | ||
this.emit("ready", { network: this }); | ||
} | ||
this.emit("peer-candidate", { peerId }); | ||
@@ -73,0 +88,0 @@ } |
{ | ||
"name": "@automerge/automerge-repo-network-messagechannel", | ||
"version": "1.0.0-alpha.3", | ||
"version": "1.0.0-alpha.4", | ||
"description": "MessageChannel network adapter for Automerge Repo", | ||
@@ -17,6 +17,6 @@ "repository": "https://github.com/automerge/automerge-repo", | ||
"dependencies": { | ||
"@automerge/automerge-repo": "^1.0.0-alpha.3" | ||
"@automerge/automerge-repo": "^1.0.0-alpha.4" | ||
}, | ||
"peerDependencies": { | ||
"@automerge/automerge": "^2.1.0-alpha.10" | ||
"@automerge/automerge": "^2.1.0-alpha.12" | ||
}, | ||
@@ -34,3 +34,3 @@ "watch": { | ||
}, | ||
"gitHead": "0ed108273084319aeea64ceccb49c3d58709f107" | ||
"gitHead": "fbf71f0c3aaa2786a4e279f336f01d665f53ce5b" | ||
} |
@@ -17,2 +17,3 @@ import { | ||
messagePortRef: MessagePortRef | ||
#startupComplete = false | ||
@@ -79,2 +80,13 @@ constructor( | ||
}) | ||
this.join() | ||
// Mark this messagechannel as ready after 50 ms, at this point there | ||
// must be something weird going on on the other end to cause us to receive | ||
// no response | ||
setTimeout(() => { | ||
if (!this.#startupComplete) { | ||
this.#startupComplete = true | ||
this.emit("ready", { network: this }) | ||
} | ||
}, 100) | ||
} | ||
@@ -102,2 +114,6 @@ | ||
announceConnection(peerId: PeerId) { | ||
if (!this.#startupComplete) { | ||
this.#startupComplete = true | ||
this.emit("ready", { network: this }) | ||
} | ||
this.emit("peer-candidate", { peerId }) | ||
@@ -104,0 +120,0 @@ } |
@@ -1,3 +0,3 @@ | ||
import { runAdapterTests } from "../../automerge-repo/src/helpers/tests/network-adapter-tests" | ||
import { MessageChannelNetworkAdapter as Adapter } from "../src" | ||
import { runAdapterTests } from "../../automerge-repo/src/helpers/tests/network-adapter-tests.js" | ||
import { MessageChannelNetworkAdapter as Adapter } from "../src/index.js" | ||
@@ -4,0 +4,0 @@ // bob is the hub, alice and charlie are spokes |
@@ -5,4 +5,4 @@ { | ||
"jsx": "react", | ||
"module": "ESNext", | ||
"moduleResolution": "node", | ||
"module": "NodeNext", | ||
"moduleResolution": "Node16", | ||
"declaration": true, | ||
@@ -9,0 +9,0 @@ "declarationMap": true, |
Sorry, the diff of this file is not supported yet
20233
503