You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
panel: { //implemented by panels, called by the page script
44
+
panel: { //functions and events received by panels
45
45
flash: (message:string) =>void
46
46
}
47
47
sharedStates: {
@@ -54,7 +54,7 @@ Channel names are namespaced with the devframe id, like RPC ids. Function names
54
54
55
55
## The page script endpoint
56
56
57
-
Functions use the same authoring metadata as `defineRpcFunction` (`type`, Standard-Schema `args`/`returns`, `jsonSerializable`, `handler`), narrowed to the browser. The required`functions` object's keys are the function names, and it implements every function on that endpoint's protocol side. Each handler is contextually typed from its key and the corresponding function in the protocol. `defineChannelFunction` retains the named definition shape for lower-level authoring. Define each side's functions in that side's source files; the shared protocol file carries only types.
57
+
Request/response functions use the same authoring metadata as `defineRpcFunction` (`type`, Standard-Schema `args`/`returns`, `jsonSerializable`, `handler`), narrowed to the browser. The optional`functions` object registers initial handlers, while `channel.on()` subscribes event listeners at runtime. Each handler is contextually typed from its key and the corresponding function in the protocol. `defineChannelFunction` retains the named definition shape for lower-level authoring. Define each side's functions in that side's source files; the shared protocol file carries only types.
`callEvent` on the page script is 1:N: it fans out to every connected panel, and panels that don't implement the function ignore it. Request/response *to* a panel goes through an explicit peer handle: `channel.panels[0].call('flash', '…')`.
87
+
`emit` on the page script is 1:N: it fans out to every connected panel. Request/response *to* a panel goes through an explicit peer handle: `channel.panels[0].call('flash', '…')`.
88
88
89
89
## The panel endpoint
90
90
@@ -96,15 +96,13 @@ import { MY_CHANNEL } from '../shared/protocol'
channel.emit('highlight', '.hero') // buffered until connected
107
103
const size =awaitchannel.call('measure', '.hero')
104
+
105
+
offFlash() // stop listening
108
106
```
109
107
110
108
## Shared state
@@ -133,7 +131,7 @@ Every failure mode is a coded `InPageChannelError` (`error.code`) with a message
133
131
The panel endpoint's connection lifecycle is explicit, so a panel renders a useful fallback instead of hanging:
134
132
135
133
-`channel.status` is `connecting` → `connected` → (`connecting` on port loss) → `closed`, with `events.on('status:updated', …)` for reactivity.
136
-
- While `connecting`, `call()` is queued (and still subject to its deadline) and `callEvent()` is buffered (up to `eventBufferLimit`, oldest dropped with a warning); both flush on connect.
134
+
- While `connecting`, `call()` is queued (and still subject to its deadline) and `emit()` is buffered (up to `eventBufferLimit`, oldest dropped with a warning); both flush on connect.
137
135
- A page script may legitimately never appear (the panel opened standalone, the user app not instrumented). Race `whenConnected(timeoutMs)` to show a "load the page script" empty state:
0 commit comments