@typeonce/effect-machine-devtools 0.23.0

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.
Files changed (91) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +3 -0
  3. package/README.md +81 -0
  4. package/dist/DevServer.d.ts +42 -0
  5. package/dist/DevServer.d.ts.map +1 -0
  6. package/dist/DevServer.js +28 -0
  7. package/dist/DevServer.js.map +1 -0
  8. package/dist/DevToolsProtocol.d.ts +954 -0
  9. package/dist/DevToolsProtocol.d.ts.map +1 -0
  10. package/dist/DevToolsProtocol.js +96 -0
  11. package/dist/DevToolsProtocol.js.map +1 -0
  12. package/dist/MachineDocument.d.ts +396 -0
  13. package/dist/MachineDocument.d.ts.map +1 -0
  14. package/dist/MachineDocument.js +172 -0
  15. package/dist/MachineDocument.js.map +1 -0
  16. package/dist/MachineRegistry.d.ts +349 -0
  17. package/dist/MachineRegistry.d.ts.map +1 -0
  18. package/dist/MachineRegistry.js +46 -0
  19. package/dist/MachineRegistry.js.map +1 -0
  20. package/dist/MachineSimulator.d.ts +169 -0
  21. package/dist/MachineSimulator.d.ts.map +1 -0
  22. package/dist/MachineSimulator.js +98 -0
  23. package/dist/MachineSimulator.js.map +1 -0
  24. package/dist/ProjectInspector.d.ts +116 -0
  25. package/dist/ProjectInspector.d.ts.map +1 -0
  26. package/dist/ProjectInspector.js +82 -0
  27. package/dist/ProjectInspector.js.map +1 -0
  28. package/dist/bin.d.ts +3 -0
  29. package/dist/bin.d.ts.map +1 -0
  30. package/dist/bin.js +23 -0
  31. package/dist/bin.js.map +1 -0
  32. package/dist/client/assets/index-BGOhE3Ng.css +1 -0
  33. package/dist/client/assets/index-DiqGhsGR.js +14 -0
  34. package/dist/client/index.html +14 -0
  35. package/dist/index.d.ts +18 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +18 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/internal/devServer.d.ts +9 -0
  40. package/dist/internal/devServer.d.ts.map +1 -0
  41. package/dist/internal/devServer.js +119 -0
  42. package/dist/internal/devServer.js.map +1 -0
  43. package/dist/internal/evaluationWorker.d.ts +3 -0
  44. package/dist/internal/evaluationWorker.d.ts.map +1 -0
  45. package/dist/internal/evaluationWorker.js +69 -0
  46. package/dist/internal/evaluationWorker.js.map +1 -0
  47. package/dist/internal/evaluationWorkerBootstrap.d.ts +2 -0
  48. package/dist/internal/evaluationWorkerBootstrap.d.ts.map +1 -0
  49. package/dist/internal/evaluationWorkerBootstrap.js +21 -0
  50. package/dist/internal/evaluationWorkerBootstrap.js.map +1 -0
  51. package/dist/internal/machineDocument.d.ts +4 -0
  52. package/dist/internal/machineDocument.d.ts.map +1 -0
  53. package/dist/internal/machineDocument.js +122 -0
  54. package/dist/internal/machineDocument.js.map +1 -0
  55. package/dist/internal/machineRegistry.d.ts +12 -0
  56. package/dist/internal/machineRegistry.d.ts.map +1 -0
  57. package/dist/internal/machineRegistry.js +97 -0
  58. package/dist/internal/machineRegistry.js.map +1 -0
  59. package/dist/internal/machineSimulator.d.ts +5 -0
  60. package/dist/internal/machineSimulator.d.ts.map +1 -0
  61. package/dist/internal/machineSimulator.js +156 -0
  62. package/dist/internal/machineSimulator.js.map +1 -0
  63. package/dist/internal/projectInspector.d.ts +11 -0
  64. package/dist/internal/projectInspector.d.ts.map +1 -0
  65. package/dist/internal/projectInspector.js +150 -0
  66. package/dist/internal/projectInspector.js.map +1 -0
  67. package/index.html +13 -0
  68. package/package.json +69 -0
  69. package/src/DevServer.ts +45 -0
  70. package/src/DevToolsProtocol.ts +146 -0
  71. package/src/MachineDocument.ts +264 -0
  72. package/src/MachineRegistry.ts +69 -0
  73. package/src/MachineSimulator.ts +154 -0
  74. package/src/ProjectInspector.ts +140 -0
  75. package/src/bin.ts +56 -0
  76. package/src/index.ts +20 -0
  77. package/src/internal/browser/example-machine.ts +134 -0
  78. package/src/internal/browser/machine-index.ts +81 -0
  79. package/src/internal/browser/main.ts +42 -0
  80. package/src/internal/browser/styles.css +817 -0
  81. package/src/internal/browser/text-tree.ts +214 -0
  82. package/src/internal/browser/visualizer-app.ts +659 -0
  83. package/src/internal/browser/visualizer-model.ts +173 -0
  84. package/src/internal/browser/visualizer.ts +31 -0
  85. package/src/internal/devServer.ts +171 -0
  86. package/src/internal/evaluationWorker.ts +138 -0
  87. package/src/internal/evaluationWorkerBootstrap.js +21 -0
  88. package/src/internal/machineDocument.ts +138 -0
  89. package/src/internal/machineRegistry.ts +128 -0
  90. package/src/internal/machineSimulator.ts +199 -0
  91. package/src/internal/projectInspector.ts +226 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sandro Maglione
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/NOTICE ADDED
@@ -0,0 +1,3 @@
1
+ Portions are adapted from the Effect project, which is distributed under the
2
+ MIT License. See https://github.com/Effect-TS/effect and the source history for
3
+ authorship and provenance.
package/README.md ADDED
@@ -0,0 +1,81 @@
1
+ # Effect Machine devtools
2
+
3
+ `@typeonce/effect-machine-devtools` scans a local project for exported Effect Machine `.handle(...)` results and serves a live text-tree visualizer.
4
+
5
+ The package is experimental and pre-1.0. Minor releases may change its command options, document schemas, and programmatic modules.
6
+
7
+ ## Compatibility
8
+
9
+ Core and devtools always release at the same version. Install matching versions:
10
+
11
+ ```sh
12
+ pnpm add @typeonce/effect-machine@latest effect@4.0.0-rc.111
13
+ pnpm add --save-dev @typeonce/effect-machine-devtools@latest
14
+ ```
15
+
16
+ When pinning a release instead of using `latest`, use the same explicit version for both packages.
17
+
18
+ The current release requires Node.js 22.19 or newer and Effect `4.0.0-rc.111`.
19
+
20
+ ## Run the visualizer
21
+
22
+ Start it from the project that contains the machines:
23
+
24
+ ```sh
25
+ pnpm exec effect-machine
26
+ ```
27
+
28
+ The command scans `**/src/**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}` and serves the visualizer at `http://127.0.0.1:5173`.
29
+
30
+ ```sh
31
+ pnpm exec effect-machine \
32
+ --root ./packages/app \
33
+ --include "src/**/*.ts" \
34
+ --port 4173 \
35
+ --open
36
+ ```
37
+
38
+ | Option | Default | Purpose |
39
+ | ----------------- | --------------------------------------------- | ---------------------------------------------------------- |
40
+ | `--root` | current directory | Project directory to inspect |
41
+ | `--include` | `**/src/**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}` | Machine source glob relative to the project root |
42
+ | `--host` | `127.0.0.1` | Local server host |
43
+ | `--port` | `5173` | Local server port |
44
+ | `--open` | `false` | Open the visualizer in the default browser |
45
+ | `--watch-polling` | `false` | Use polling when native file-system events are unavailable |
46
+
47
+ Native file-system events are the default. Polling scans more frequently and may use more CPU in large repositories, so enable it only when the platform watcher misses changes.
48
+
49
+ ## Live results
50
+
51
+ The browser reports one of these statuses for every candidate:
52
+
53
+ - `Ready` contains the latest complete machine document.
54
+ - `Partial` keeps the last valid document visible and adds diagnostics from the incomplete source.
55
+ - `Failed` contains diagnostics when no valid document is available.
56
+
57
+ An incomplete edit can remove `.handle(...)` or change an export temporarily without discarding the last valid topology. A syntactically valid removal removes the machine from the index on the next scan.
58
+
59
+ ## Trusted projects only
60
+
61
+ Discovery parses source files without executing them. Evaluation then loads candidate modules in a fresh worker. Module initialization code executes during that load, although transition resolvers and activity sources do not.
62
+
63
+ Run the devtools only against code you trust. The server has no authentication and binds to the loopback interface by default. Do not expose it on a public or untrusted network.
64
+
65
+ ## Inspection and simulation
66
+
67
+ The visualizer shows topology, active initial paths, state annotations, events, transitions, branches, state updates, activities, source metadata, and diagnostics. The tree supports pointer and keyboard navigation, subtree expansion, related-state highlighting, and structured detail inspection.
68
+
69
+ Simulation works from the serialized machine document and never runs project code. It advances only when an event has one required direct transition whose target is statically known.
70
+
71
+ Declinable transitions, conditional branches, parallel transitions, history, and choices return an indeterminate result. Deterministic steps report skipped state updates, runtime effects, raised events, reentry lifecycles, and automatic stabilization instead of pretending to execute them.
72
+
73
+ ## Programmatic modules
74
+
75
+ The first release publishes three programmatic modules:
76
+
77
+ - `DevToolsProtocol` defines the versioned worker and browser messages.
78
+ - `MachineDocument` defines and constructs the serializable inspection document.
79
+ - `MachineSimulator` provides the side-effect-free document simulator.
80
+
81
+ The project inspector, registry, worker, and local server remain implementation modules. Their interfaces can change without becoming package-level compatibility commitments.
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Local HTTP server for the Effect Machine visualizer.
3
+ *
4
+ * @since 0.23.0
5
+ */
6
+ import * as Effect from "effect/Effect";
7
+ import * as Schema from "effect/Schema";
8
+ import type * as MachineRegistry from "./MachineRegistry.js";
9
+ /**
10
+ * @category models
11
+ * @since 0.23.0
12
+ */
13
+ export interface Options {
14
+ readonly root: string;
15
+ readonly host: string;
16
+ readonly port: number;
17
+ readonly open?: boolean | undefined;
18
+ readonly debounce?: number | undefined;
19
+ readonly watchPolling?: boolean | undefined;
20
+ }
21
+ declare const DevServerError_base: Schema.Class<DevServerError, Schema.Struct<{
22
+ readonly _tag: Schema.tag<"DevServerError">;
23
+ readonly message: Schema.String;
24
+ readonly cause: Schema.optional<Schema.Defect>;
25
+ }>, import("effect/Cause").YieldableError>;
26
+ /**
27
+ * Failure while starting or serving the local visualizer.
28
+ *
29
+ * @category errors
30
+ * @since 0.23.0
31
+ */
32
+ export declare class DevServerError extends DevServerError_base {
33
+ }
34
+ /**
35
+ * Starts the local visualizer and runs until interrupted.
36
+ *
37
+ * @category constructors
38
+ * @since 0.23.0
39
+ */
40
+ export declare const run: (options: Options) => Effect.Effect<never, DevServerError, MachineRegistry.MachineRegistry>;
41
+ export {};
42
+ //# sourceMappingURL=DevServer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DevServer.d.ts","sourceRoot":"","sources":["../src/DevServer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,KAAK,eAAe,MAAM,sBAAsB,CAAA;AAE5D;;;GAGG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IACnC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACtC,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAC5C;;;;;;AAED;;;;;GAKG;AACH,qBAAa,cAAe,SAAQ,mBAMlC;CAAG;AAEL;;;;;GAKG;AACH,eAAO,MAAM,GAAG,GAAI,SAAS,OAAO,KAAG,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,cAAc,EAAE,eAAe,CAAC,eAAe,CACpE,CAAA"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Local HTTP server for the Effect Machine visualizer.
3
+ *
4
+ * @since 0.23.0
5
+ */
6
+ import * as Effect from "effect/Effect";
7
+ import * as Schema from "effect/Schema";
8
+ import * as internal from "./internal/devServer.js";
9
+ /**
10
+ * Failure while starting or serving the local visualizer.
11
+ *
12
+ * @category errors
13
+ * @since 0.23.0
14
+ */
15
+ export class DevServerError extends Schema.Error("@typeonce/effect-machine-devtools/DevServer/DevServerError")({
16
+ _tag: Schema.tag("DevServerError"),
17
+ message: Schema.String,
18
+ cause: Schema.optional(Schema.Defect())
19
+ }) {
20
+ }
21
+ /**
22
+ * Starts the local visualizer and runs until interrupted.
23
+ *
24
+ * @category constructors
25
+ * @since 0.23.0
26
+ */
27
+ export const run = (options) => internal.run(DevServerError, options);
28
+ //# sourceMappingURL=DevServer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DevServer.js","sourceRoot":"","sources":["../src/DevServer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAA;AAgBnD;;;;;GAKG;AACH,MAAM,OAAO,cAAe,SAAQ,MAAM,CAAC,KAAK,CAC9C,4DAA4D,CAC7D,CAAC;IACA,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC;IAClC,OAAO,EAAE,MAAM,CAAC,MAAM;IACtB,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;CACxC,CAAC;CAAG;AAEL;;;;;GAKG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,OAAgB,EAAyE,EAAE,CAC7G,QAAQ,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC,CAAA"}