@use-everywhere/core
Classes
| Class | Description |
|---|---|
| BroadcastChannelTransport | Same-origin transport over a real BroadcastChannel. |
| HandshakeTimeoutError | The ready/ready-ack handshake never completed. |
| MemoryHub | In-memory hub for tests: N transports attached to one hub, each post is delivered to every other transport on a microtask (mirrors BroadcastChannel's async, no-self-echo delivery). |
| MemoryTransport | One simulated client on a MemoryHub. Create via hub.connect(). |
| NoopTransport | Silent local transport: nothing leaves this context, nothing arrives. Used for SSR and for state scoped to a single tab. |
| WindowClosedError | The opened window closed before delivering a result. |
Interfaces
| Interface | Description |
|---|---|
| BusEvent | One wire crossing the bus, in either direction. |
| Channel | - |
| CommonOptions | - |
| ConnectToOpenerOptions | - |
| DebugOptions | - |
| Leader | - |
| LeaderOptions | Deliberately extends CommonOptions, not BusOptions: heartbeatMs here means the leader's re-announce interval, which is a different thing from the bus's presence ping. See the note in leader.ts about forwarding to getBus. |
| LeaderSnapshot | - |
| MessageEventLike | - |
| MessageMeta | - |
| OpenedWindow | - |
| OpenerConnection | - |
| OpenWindowOptions | - |
| Peer | - |
| PersistAdapter | - |
| Persisted | What goes to disk. The version clocks travel with the values — that is the whole point: a reopened tab re-enters the last-writer-wins race with its real term instead of a fresh zero, so a restored value can legitimately beat, or legitimately lose to, whatever the live tabs are holding. |
| PersistOptions | - |
| Presence | - |
| PresenceOptions | - |
| SharedStore | - |
| SharedStoreOptions | - |
| Transport | Minimal message bus. Implementations: BroadcastChannelTransport (same-origin), NoopTransport (SSR / local-only), MemoryTransport (tests). A transport never echoes a client's own posts back to it. |
| WindowEventTarget | The subset of Window we listen on (our side). |
| WindowLike | The subset of Window we post to (the other side). |
Type Aliases
| Type Alias | Description |
|---|---|
| BusObserver | - |
| BusWire | Everything on the same-origin bus, multiplexed by scope over one BroadcastChannel per name. |
| MessageMap | - |
| PeerKind | - |
| StorageLike | - |
| Version | Per-key logical clock: [counter, clientId]. Ties break by clientId. |
Variables
| Variable | Description |
|---|---|
| CID_PARAM | - |
| DEFAULT_NAME | The bus name used when a caller does not pick one. A BroadcastChannel is global to the origin, so identity is the name string — everything that omits a name lands on this one bus. |
Functions
| Function | Description |
|---|---|
| connectToOpener | Call from the opened (child) window to connect back to its opener. Throws synchronously when there is no opener or no ue-cid parameter — i.e. the page was not opened via openWindow(). |
| createChannel | Typed pub/sub over the same-origin bus. |
| createLeader | Elects exactly one client on the bus to hold a seat: the tab that owns the WebSocket, polls, or refreshes the token, while the others stand by. |
| createPresence | Tracks the other tabs/windows/workers on this bus. Any message from a peer counts as a liveness signal (state patches, events, and presence pings all piggyback); explicit 'bye' or silence past pruneAfterMs removes them. |
| createSharedStore | State synced across every same-origin tab/window/worker: per-key last-writer-wins version clocks and a hello/snapshot late-joiner handshake. Create at most one store per name per tab (the React package memoizes). |
| defaultTransport | Default factory: real BroadcastChannel when available, otherwise a local no-op. |
| enableDebug | Log every wire on a bus to the console. Returns a function to stop. |
| getBusNames | Names of the buses currently alive on this page. Buses built with a custom transport (tests) bypass the registry, so they are not listed. |
| isBroadcastChannelAvailable | - |
| localStorageAdapter | Survives closing every tab. |
| newer | Is a newer than b? Last-writer-wins; equal counters break ties by clientId. |
| observeBus | Watch every wire crossing the named bus, in both directions. Outbound wires are the interesting half: a post goes straight to the transport, so without this seam nothing this client says is visible to it. |
| openWindow | Open a window (possibly on another origin) and get a typed 1:1 channel to it. The child must call connectToOpener(). Every received message is validated: event.origin, envelope brand, per-connection nonce, and event.source. |
| sessionStorageAdapter | Survives reloads, but dies with the tab. |
| webStorageAdapter | Persist to any Storage-shaped thing. |