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
@@ -56,7 +57,9 @@ Channel names are namespaced with the devframe id, like RPC ids. Function names
56
57
57
58
## The page script endpoint
58
59
59
-
The required `functions` object declares every function on that endpoint's protocol side, preserving a compile-time completeness check. Request/response declarations require a `handler`; an event declaration uses `type: 'event'`, and the receiving endpoint may provide an optional `handler` or subscribe at runtime with `on()`. Functions use the same Standard-Schema `args`/`returns` and `jsonSerializable` metadata as `defineRpcFunction`, narrowed to the browser. Each handler is contextually typed from its key and the corresponding protocol function. `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.
60
+
The required `functions` and `events` options declare every incoming name on the endpoint's protocol side; use `{}` for an empty direction. Functions require a `handler`. Events accept an optional `handler`, and `{}` registers an event for runtime subscriptions through `on()`. Handlers are contextually typed from the shared protocol and support Standard-Schema argument validation and `jsonSerializable` metadata. `defineChannelFunction` retains the named definition shape for lower-level authoring.
61
+
62
+
`call()` accepts names from `functions`, including actions returning `void` or `Promise<void>`: callers can await completion and catch errors or timeouts. `emit()`, its deprecated alias `callEvent()`, and `on()` use the names declared in `events`. Function and event names have separate namespaces.
`emit` on the page-script endpoint is 1:N: it fans out to every connected panel endpoint. Request/response *to* a panel goes through an explicit peer handle: `pageChannel.panels[0].call('flash', '…')`.
94
+
`emit` on the page-script endpoint fans out to every connected panel endpoint. Functions declared under `functions.panel` are called through a specific `pageChannel.panels[0].call()` peer handle.
90
95
91
96
## The panel endpoint
92
97
@@ -98,14 +103,16 @@ import { MY_CHANNEL } from '../shared/protocol'
serialize: value=>toRawDeep(value), // applied to every outgoing argument and result
172
+
functions: {},
173
+
events: { flash: {} },
165
174
})
166
175
```
167
176
@@ -172,7 +181,7 @@ Declaring a function `jsonSerializable: true` additionally enforces strict JSON
172
181
The same app open in two tabs means two page scripts on one origin. Each page script carries a per-tab instance id (persisted in `sessionStorage`), and handshakes are targeted `postMessage`, so a dock panel always pairs with its own tab's page script. A panel can also pin explicitly:
Copy file name to clipboardExpand all lines: docs/content/6.errors/DF0077.md
+8-7Lines changed: 8 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,24 @@
1
1
---
2
-
title: 'DF0077: In-Page Channel Function Not Registered'
3
-
description: 'An in-page channel listener names a function that is not registered on its endpoint.'
2
+
title: 'DF0077: In-Page Channel Event Not Registered'
3
+
description: 'An in-page channel listener names an event that is not registered on its endpoint.'
4
4
---
5
5
6
6
## Message
7
7
8
-
> In-page channel function "{name}" is not registered on this endpoint.
8
+
> In-page channel event "{name}" is not registered on this endpoint.
9
9
10
10
## Cause
11
11
12
-
`channel.on(name, listener)` received a name absent from that endpoint's required `functions` option. A page-script endpoint subscribes to functions declared under `pageScript`; a panel endpoint subscribes to functions declared under `panel`.
12
+
`channel.on(name, listener)` received a name absent from that endpoint's required `events` option. A page-script endpoint subscribes to events declared under `events.pageScript`; a panel endpoint subscribes to events declared under `events.panel`.
Copy file name to clipboardExpand all lines: docs/content/8.references/5.browser-api.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,6 +50,8 @@ The values of `rpc.status`: [Handling connection and auth errors](/guide/client#
50
50
51
51
The browser-only endpoint methods of the [in-page channel](/guide/in-page-channel). `emit()` sends to the opposite endpoint; `on()` handles events arriving from that endpoint.
52
52
53
+
`InPageChannelProtocol` separates `functions` and `events`. Each section has optional `pageScript` and `panel` maps naming the receiving direction. Endpoint options require a complete `functions` map with handlers and a complete `events` map with optional handlers; use `{}` for empty maps. `call()` uses function names regardless of return type, while `emit()`, `callEvent()` (deprecated), and `on()` use event names. A function returning `void` or `Promise<void>` remains an awaitable request/response call.
0 commit comments