Documentation / @etherfold/browser / MessageEndpoint
Type Alias: MessageEndpoint ​
MessageEndpoint =
object
Defined in: packages/browser/src/host/endpoint.ts:16
THE UNTYPED DUPLEX A PORT IS BUILT OVER: two postMessage ends and a listener.
Deliberately structural and deliberately tiny, because this is the ONE thing a hosting shape differs in (CONTEXT.md, indexer host). A Worker, a MessagePort (which is what a SharedWorker hands each tab), a dedicated worker's own global scope and a MessageChannel end in a test all satisfy it already; nothing in this package has to adapt any of them.
It is NOT the port: the port is the TYPED boundary a tab holds (connectToIndexerHost), and this is the wire it speaks over.
Properties ​
start? ​
optionalstart?: () =>void
Defined in: packages/browser/src/host/endpoint.ts:31
MessagePort only, and only where the listener was attached with addEventListener: messages are queued until it is called. A Worker and a worker's own scope do not have it, which is why it is optional and why listen calls it defensively rather than each hosting shape remembering to.
Returns ​
void
Methods ​
addEventListener() ​
addEventListener(
type,listener):void
Defined in: packages/browser/src/host/endpoint.ts:23
Parameters ​
type ​
"message"
listener ​
(event) => void
Returns ​
void
postMessage() ​
postMessage(
message,transfer?):void
Defined in: packages/browser/src/host/endpoint.ts:22
transfer is what a Worker, a MessagePort and a worker scope all take as their second argument. The port uses it for ONE message, the connect that hands a host the provider's MessagePort; nothing else on the wire transfers.
Parameters ​
message ​
unknown
transfer? ​
Transferable[]
Returns ​
void
removeEventListener() ​
removeEventListener(
type,listener):void
Defined in: packages/browser/src/host/endpoint.ts:24
Parameters ​
type ​
"message"
listener ​
(event) => void
Returns ​
void