Skip to content

Documentation / @etherfold/browser / HostAccess

Type Alias: HostAccess ​

HostAccess = object

Defined in: packages/browser/src/host/endpoint.ts:43

HOW A PORT IS OBTAINED, which is the whole of what a hosting shape is.

Everything else -- the container, the store, the driving loop, the envelope and every case on it -- is written once against MessageEndpoint and knows nothing about workers. So a reviewer checking "is the host host-agnostic?" checks exactly one thing: that the only code naming Worker is the code that produces one of these.

Properties ​

close? ​

readonly optional close?: (state) => void

Defined in: packages/browser/src/host/endpoint.ts:62

Let the host go, where the holder of this access is what keeps it alive: a tab that constructed a dedicated worker owns that worker. Absent where there is nothing to release (the host's own end of its own scope).

quiesced says whether the host was known to be IDLE when this was called, and a shape that can kill its host must not kill it otherwise. Killing a host mid-write is not the harmless act it was taken for: on WebKit, ending a worker that has a readwrite and a readonly transaction in flight can leave its IndexedDB database permanently unable to run any transaction, which no reload and no new tab recovers (work/notes/findings/webkit-does-not-abort-a-terminated-workers-indexeddb-transaction.md). So the port establishes quiet FIRST where it can, and says so here.

Parameters ​

state ​
quiesced ​

boolean

true only when the host answered the port's letGo by STOPPING, which is a promise that the cycle in flight LANDED and no other will start. false means the host did not answer, or did not stop because other tabs still hold it (a SharedWorker's) -- it is being let go rather than shut down.

Returns ​

void


endpoint ​

readonly endpoint: MessageEndpoint

Defined in: packages/browser/src/host/endpoint.ts:47

The wire.


host ​

readonly host: HostingShape

Defined in: packages/browser/src/host/endpoint.ts:45

WHICH shape this is. Reported to the tab, and never branched on inside the host.


reopen? ​

readonly optional reopen?: () => HostAccess

Defined in: packages/browser/src/host/endpoint.ts:88

OBTAIN A PORT AGAIN, to a NEW host of this same shape, after this one died.

A restart is the shape's business and nothing else's, for the reason the rest of this type exists: obtaining a port is the WHOLE of what a hosting shape is, and starting a host again is obtaining one again. So the port drives the lifetime (watch, reject, restart, resume -- ADR-0082) while knowing no more about workers here than it does anywhere else.

The result is a FULL access, its own close and its own reopen included, so a second death is handled exactly as the first was.

Absent where a shape cannot be re-obtained -- the host's own end of its own scope, or a wire somebody else owns. A port whose access has none REPORTS the death and rejects the calls, and says restarting: false rather than pretending it could have done something.

Returns ​

HostAccess