@xstate-devtools/adapter 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # @xstate-devtools/adapter
2
+
3
+ Inspect [XState v5](https://stately.ai/docs/xstate) actors from a running app and
4
+ stream them to the [XState DevTools](https://github.com/mjbeswick/xstate-devtools)
5
+ panel / VS Code live debugger. Three entry points — pick the one that matches
6
+ where your actors run.
7
+
8
+ ```sh
9
+ npm install @xstate-devtools/adapter
10
+ ```
11
+
12
+ `xstate` is a peer dependency. `ws` is required only for the server adapter;
13
+ `react` + `@xstate/react` only for the React hooks.
14
+
15
+ ## Browser — `@xstate-devtools/adapter`
16
+
17
+ ```ts
18
+ import { createAdapter } from '@xstate-devtools/adapter'
19
+
20
+ export const adapter = createAdapter()
21
+ useMachine(machine, { inspect: adapter.inspect })
22
+ ```
23
+
24
+ In a non-browser environment `createAdapter()` returns a no-op, so the import is
25
+ safe in SSR bundles.
26
+
27
+ ## Node / SSR — `@xstate-devtools/adapter/server`
28
+
29
+ Opens a local WebSocket bridge (default `ws://127.0.0.1:9301`) the debugger
30
+ connects to. Requires `ws`.
31
+
32
+ ```ts
33
+ import { createServerAdapter } from '@xstate-devtools/adapter/server'
34
+
35
+ const adapter = createServerAdapter() // { port?, host?, bufferSize? }
36
+ createActor(machine, { inspect: adapter.inspect }).start()
37
+ ```
38
+
39
+ ## React — `@xstate-devtools/adapter/react`
40
+
41
+ Requires `react` and `@xstate/react`.
42
+
43
+ ```tsx
44
+ import { InspectorProvider, useInspectedMachine } from '@xstate-devtools/adapter/react'
45
+ ```
46
+
47
+ ## License
48
+
49
+ MIT