-
Notifications
You must be signed in to change notification settings - Fork 22
feat: add runtime in-page channel events #358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0ed9101
feat: add runtime in-page channel events
posva c5337a8
fix: preserve required in-page function declarations
posva 3eb32b9
docs: clarify in-page event direction
posva 5c026a0
refactor: split in-page function option types
posva a3bea6c
fix: restrict in-page listeners to events
posva 993c3f3
docs: reword
posva 6be6f9c
fix: reject unknown in-page listeners
posva 0b53ab2
fix: restrict in-page emits to events
posva 372e06c
test: simplify unknown listener assertion
posva fe623c6
docs: reword
posva 0331943
chore: simpler
posva 022938d
test: word
posva c449f95
style: lint
posva 723c19f
chore: reword
posva f37858e
test: simplify unknown listener cleanup
posva File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
| title: 'Browser-Side API' | ||
| navigation: | ||
| icon: i-lucide-globe | ||
| description: 'Lookup tables for the browser side: connectDevframe options, RPC client events, connection statuses, and in-page channel error codes.' | ||
| description: 'Lookup tables for the browser side: connectDevframe options, RPC client events, connection statuses, and in-page channels.' | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so many useless edits on this one... I'm reverting them |
||
| --- | ||
|
|
||
| Lookup tables for a devframe's browser side. Each section links the guide page that teaches the concept. | ||
|
|
@@ -45,6 +45,18 @@ The values of `rpc.status`: [Handling connection and auth errors](/guide/client# | |
| | `disconnected` | Socket closed (dropped mid-session or never opened). | | ||
| | `error` | Fatal: the socket errored or connection meta couldn't load. | | ||
|
|
||
| ## In-page channel endpoints | ||
|
|
||
| The browser-only endpoint methods of the [in-page channel](/guide/in-page-channel). | ||
|
|
||
| | Method or property | Page script | Panel | | ||
| |--------------------|-------------|-------| | ||
| | `emit(name, ...args)` | Fans an event out to every connected panel. | Sends an event to the page script, buffering while connecting. | | ||
| | `on(name, listener)` | Subscribes to events emitted by a panel. | Subscribes to events emitted by the page script. Returns an unsubscribe function. | | ||
| | `call(name, ...args)` | Available through a specific `PanelPeer`. | Calls a page-script function and awaits its result. | | ||
|
posva marked this conversation as resolved.
|
||
| | `events` | Local `panel:connected` / `panel:disconnected` lifecycle events. | Local `status:updated` lifecycle event. | | ||
| | `sharedState` | Owns the authoritative state. | Mirrors the page-script state. | | ||
|
|
||
| ## In-page channel error codes | ||
|
|
||
| The `error.code` values of `InPageChannelError`: [Errors and fallbacks](/guide/in-page-channel#errors-and-fallbacks). | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,7 +33,7 @@ export type { | |
| export function defineChannelFunction< | ||
| NAME extends string, | ||
| TYPE extends InPageFunctionType, | ||
| ARGS extends any[], | ||
| ARGS extends any[] = [], | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. needed because handler is optional if type is event |
||
| RETURN = void, | ||
| const AS extends RpcArgsSchema | undefined = undefined, | ||
| const RS extends RpcReturnSchema | undefined = undefined, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.