-
Notifications
You must be signed in to change notification settings - Fork 100
Add support for inspecting via websocket #293
Conversation
🦋 Changeset detectedLatest commit: c4ee436 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@jacksteamdev is attempting to deploy a commit to the Stately Team on Vercel. A member of the Team first needs to authorize it. |
Refactor receiver ref into context
Since this is an important PR, can you add some |
@Andarist Any chance this could get a quick review? |
const [protocol, ...server] = serverUrl.split('://'); | ||
receiver = createWebSocketReceiver({ | ||
protocol: protocol as 'ws' | 'wss', | ||
server: server.join('://'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks somewhat off and could lead to some invalid URL being passed here (or rather to an invalid URL being constructed here). We might slightly refactor this later but no need to block this PR on this nit-picky comment
Based on discussion #191, this PR adds support for inspecting via websocket. Note the new nested states in
inspecting
calledwebsocket
andwindow
.New queries have been added to the query string that reflect the parameters for
createWebSocketReceiver
.server
is required andprotocol
is optional (default is"ws"
).The event handlers inI've moved the inspect receiver into context to avoid duplicating receiver event handlers. Not sure if this is a problem, maybe someone can suggest a better strategy?inspecting
in the invokedproxy
service are duplicated. Not sure how dry you want this, but we could pull them out into the module scope inside a function.This functionality depends on a PR for
@xstate/inspect
: statelyai/xstate#2728 Without that PR, this doesn't work on the server side (in my use case, at least).