@typeonce/effect-machine-devtools 0.31.2 → 0.33.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 (33) hide show
  1. package/dist/MachineRegistry.d.ts +4 -3
  2. package/dist/MachineRegistry.d.ts.map +1 -1
  3. package/dist/MachineRegistry.js +4 -3
  4. package/dist/MachineRegistry.js.map +1 -1
  5. package/dist/client/assets/index-2uvShdlX.js +37 -0
  6. package/dist/client/index.html +1 -1
  7. package/dist/internal/devServer.d.ts +3 -1
  8. package/dist/internal/devServer.d.ts.map +1 -1
  9. package/dist/internal/devServer.js +8 -6
  10. package/dist/internal/devServer.js.map +1 -1
  11. package/dist/internal/machineRegistry.js +9 -6
  12. package/dist/internal/machineRegistry.js.map +1 -1
  13. package/package.json +2 -2
  14. package/src/MachineRegistry.ts +4 -3
  15. package/src/internal/browser/chart-layout-policy.ts +2 -2
  16. package/src/internal/browser/chart-layout.ts +236 -51
  17. package/src/internal/browser/chart-model.ts +3 -0
  18. package/src/internal/browser/chart-renderer.ts +5 -4
  19. package/src/internal/browser/example-machine.ts +94 -85
  20. package/src/internal/browser/hierarchy-routing-example.ts +67 -58
  21. package/src/internal/browser/invoke-outcomes-example.ts +153 -143
  22. package/src/internal/browser/layout-resilience-example.ts +115 -104
  23. package/src/internal/browser/parallel-completion-example.ts +117 -107
  24. package/src/internal/browser/parallel-owner-routing-example.ts +104 -0
  25. package/src/internal/browser/planner-example.ts +44 -38
  26. package/src/internal/browser/protocol-events-example.ts +123 -102
  27. package/src/internal/browser/shared-terminal-routing-example.ts +125 -120
  28. package/src/internal/browser/text-tree.ts +2 -2
  29. package/src/internal/browser/transition-semantics-example.ts +143 -131
  30. package/src/internal/browser/visualizer-model.ts +7 -7
  31. package/src/internal/devServer.ts +15 -12
  32. package/src/internal/machineRegistry.ts +17 -17
  33. package/dist/client/assets/index-CSgOYHLh.js +0 -37
@@ -24,116 +24,125 @@ class Finish extends Schema.TaggedClass<Finish>("Finish")("Finish", {}) {}
24
24
  class Disconnect extends Schema.TaggedClass<Disconnect>("Disconnect")("Disconnect", {}) {}
25
25
  class Refresh extends Schema.TaggedClass<Refresh>("Refresh")("Refresh", {}) {}
26
26
 
27
- const States = Machine.states({
28
- application: {
29
- schema: Application,
30
- type: "parallel",
31
- states: {
32
- workflow: {
33
- schema: Workflow,
34
- initial: "idle",
35
- states: {
36
- idle: Idle,
37
- running: {
38
- schema: Running,
39
- initial: "editing",
40
- states: {
41
- editing: Editing,
42
- complete: {
43
- schema: Complete,
44
- type: "final"
27
+ const States = Machine.state({
28
+ initial: "application",
29
+ states: {
30
+ application: {
31
+ schema: Application,
32
+ type: "parallel",
33
+ states: {
34
+ workflow: {
35
+ schema: Workflow,
36
+ initial: "idle",
37
+ states: {
38
+ idle: Idle,
39
+ running: {
40
+ schema: Running,
41
+ initial: "editing",
42
+ states: {
43
+ editing: Editing,
44
+ complete: {
45
+ schema: Complete,
46
+ type: "final"
47
+ }
45
48
  }
49
+ },
50
+ recent: {
51
+ type: "history"
46
52
  }
47
- },
48
- recent: {
49
- type: "history"
50
53
  }
51
- }
52
- },
53
- connection: {
54
- schema: Connection,
55
- initial: "online",
56
- states: {
57
- online: Online,
58
- offline: Offline
54
+ },
55
+ connection: {
56
+ schema: Connection,
57
+ initial: "online",
58
+ states: {
59
+ online: Online,
60
+ offline: Offline
61
+ }
59
62
  }
60
63
  }
61
- }
62
- },
63
- disabled: Disabled
64
+ },
65
+ disabled: Disabled
66
+ }
64
67
  })
65
68
 
66
69
  export const snapshot = {
67
- path: "application" as const,
68
- value: new Application({ workspace: "effect-machine", revision: 7 }),
69
- states: {
70
- workflow: {
71
- path: "application.workflow" as const,
72
- value: new Workflow({ document: "Machine.ts", unsavedChanges: 2 }),
73
- state: { path: "application.workflow.idle" as const, value: new Idle({}) }
74
- },
75
- connection: {
76
- path: "application.connection" as const,
77
- value: new Connection({}),
78
- state: { path: "application.connection.online" as const, value: new Online({}) }
70
+ path: "" as const,
71
+ value: undefined,
72
+ state: {
73
+ path: "application" as const,
74
+ value: new Application({ workspace: "effect-machine", revision: 7 }),
75
+ states: {
76
+ workflow: {
77
+ path: "application.workflow" as const,
78
+ value: new Workflow({ document: "Machine.ts", unsavedChanges: 2 }),
79
+ state: { path: "application.workflow.idle" as const, value: new Idle({}) }
80
+ },
81
+ connection: {
82
+ path: "application.connection" as const,
83
+ value: new Connection({}),
84
+ state: { path: "application.connection.online" as const, value: new Online({}) }
85
+ }
79
86
  }
80
87
  }
81
88
  }
82
89
 
83
90
  const initialWorkflow = (): Machine.Machine.CompleteSnapshotContaining<
84
- typeof States.states,
91
+ { readonly "": typeof States.node },
85
92
  "application.workflow"
86
93
  > => snapshot
87
94
 
88
95
  export const machine = Machine.make({
89
96
  id: "inspection-example",
90
- states: States.states,
91
- events: Machine.events(Start, Finish, Disconnect, Refresh),
92
- initial: (to) => to.application.initial.resolve(() => snapshot)
97
+ root: States,
98
+ events: Machine.eventsFromSchemas(Start, Finish, Disconnect, Refresh),
99
+ initialConfiguration: (to) => to.resolve(() => snapshot)
93
100
  }).handle({
94
- application: {
95
- states: {
96
- workflow: {
97
- history: {
98
- recent: {
99
- default: initialWorkflow
100
- }
101
- },
102
- states: {
103
- idle: {
104
- on: {
105
- Start: (to) =>
106
- to.local.running()
107
- .updating(to.branch.application.workflow)
108
- .resolve(({ owner, target }) =>
109
- target.decoded(
110
- new Running({}),
111
- (running) => running.editing.decoded(new Editing({}))
112
- ).update(owner.decoded(new Workflow({ document: "Machine.ts", unsavedChanges: 3 })))
113
- ),
114
- Refresh: (to) =>
115
- to.local.update(({ owner }) =>
116
- owner.decoded(new Workflow({ document: "Machine.ts", unsavedChanges: 0 }))
117
- )
101
+ states: {
102
+ application: {
103
+ states: {
104
+ workflow: {
105
+ history: {
106
+ recent: {
107
+ default: initialWorkflow
118
108
  }
119
109
  },
120
- running: {
121
- initialize: ({ builder }) => builder.decoded(new Editing({})),
122
- states: {
123
- editing: {
124
- on: {
125
- Finish: (to) => to.local.complete().resolve(({ target }) => target.decoded(new Complete({})))
110
+ states: {
111
+ idle: {
112
+ on: {
113
+ Start: (to) =>
114
+ to.local.running()
115
+ .updating(to.branch.application.workflow)
116
+ .resolve(({ owner, target }) =>
117
+ target.decoded(
118
+ new Running({}),
119
+ (running) => running.editing.decoded(new Editing({}))
120
+ ).update(owner.decoded(new Workflow({ document: "Machine.ts", unsavedChanges: 3 })))
121
+ ),
122
+ Refresh: (to) =>
123
+ to.local.update.resolve(({ owner }) =>
124
+ owner.decoded(new Workflow({ document: "Machine.ts", unsavedChanges: 0 }))
125
+ )
126
+ }
127
+ },
128
+ running: {
129
+ initialize: ({ builder }) => builder.decoded(new Editing({})),
130
+ states: {
131
+ editing: {
132
+ on: {
133
+ Finish: (to) => to.local.complete().resolve(({ target }) => target.decoded(new Complete({})))
134
+ }
126
135
  }
127
136
  }
128
137
  }
129
138
  }
130
- }
131
- },
132
- connection: {
133
- states: {
134
- online: {
135
- on: {
136
- Disconnect: (to) => to.local.offline().resolve(({ target }) => target.decoded(new Offline({})))
139
+ },
140
+ connection: {
141
+ states: {
142
+ online: {
143
+ on: {
144
+ Disconnect: (to) => to.local.offline().resolve(({ target }) => target.decoded(new Offline({})))
145
+ }
137
146
  }
138
147
  }
139
148
  }
@@ -7,26 +7,29 @@ const ReviewState = Schema.TaggedUnion({
7
7
  Complete: { slug: Schema.String }
8
8
  })
9
9
 
10
- const ReviewStates = Machine.states({
11
- Workflow: {
12
- initial: "Review",
13
- states: {
14
- Review: {
15
- schema: ReviewState.cases.Review,
16
- initial: "Form",
17
- states: {
18
- Form: {},
19
- Failed: ReviewState.cases.ReviewFailed
20
- }
21
- },
22
- Saving: {},
23
- Publishing: {},
24
- Complete: ReviewState.cases.Complete
10
+ const ReviewStates = Machine.state({
11
+ initial: "Workflow",
12
+ states: {
13
+ Workflow: {
14
+ initial: "Review",
15
+ states: {
16
+ Review: {
17
+ schema: ReviewState.cases.Review,
18
+ initial: "Form",
19
+ states: {
20
+ Form: {},
21
+ Failed: ReviewState.cases.ReviewFailed
22
+ }
23
+ },
24
+ Saving: {},
25
+ Publishing: {},
26
+ Complete: ReviewState.cases.Complete
27
+ }
25
28
  }
26
29
  }
27
30
  })
28
31
 
29
- const ReviewEvents = Machine.events(
32
+ const ReviewEvents = Machine.eventsFromSchemas(
30
33
  Schema.TaggedUnion({
31
34
  Submit: { route: Schema.Literals(["save", "invalid"]) }
32
35
  })
@@ -37,55 +40,61 @@ const publishReview = Effect.succeed("deterministic-chart")
37
40
 
38
41
  export const hierarchyRoutingMachine = Machine.make({
39
42
  id: "hierarchy-routing",
40
- states: ReviewStates.states,
43
+ root: ReviewStates,
41
44
  events: ReviewEvents,
42
- initial: (to) =>
43
- to.Workflow.initial.resolve(({ target }) =>
44
- target.from((workflow) =>
45
- workflow.Review.from({ title: "A deterministic chart" }, (review) => review.Form.from())
45
+ initialConfiguration: (root) =>
46
+ root.resolve(({ target }) =>
47
+ target.from((to) =>
48
+ to.Workflow.from((workflow) =>
49
+ workflow.Review.from({ title: "A deterministic chart" }, (review) => review.Form.from())
50
+ )
46
51
  )
47
52
  )
48
53
  }).handle({
49
- Workflow: {
50
- states: {
51
- Review: {
52
- on: {
53
- Submit: (to) =>
54
- to.branches({
55
- save: {
56
- title: "Save the review",
57
- target: to.branch.Workflow.Saving()
58
- },
59
- invalid: {
60
- title: "Show validation failure",
61
- target: to.local.Failed()
62
- }
63
- }).resolve(({ event, select }) =>
64
- event.route === "save"
65
- ? select.save.from()
66
- : select.invalid.from({ message: "Add a title before continuing." })
54
+ states: {
55
+ Workflow: {
56
+ states: {
57
+ Review: {
58
+ on: {
59
+ Submit: (to) =>
60
+ to.branches({
61
+ save: {
62
+ title: "Save the review",
63
+ target: to.branch.Workflow.Saving()
64
+ },
65
+ invalid: {
66
+ title: "Show validation failure",
67
+ target: to.local.Failed()
68
+ }
69
+ }).resolve(({ event, select }) =>
70
+ event.route === "save"
71
+ ? select.save.from()
72
+ : select.invalid.from({ message: "Add a title before continuing." })
73
+ )
74
+ },
75
+ states: {
76
+ Form: {},
77
+ Failed: {}
78
+ }
79
+ },
80
+ Saving: {
81
+ invoke: (from) =>
82
+ from.effect("save-review", () => saveReview).onDone((to) => to.branch.Workflow.Publishing()).onFailure((
83
+ to
84
+ ) =>
85
+ to.branch.Workflow.Review.Failed().resolve(({ target }) =>
86
+ target.from({ message: "The review could not be saved." })
87
+ )
67
88
  )
68
89
  },
69
- states: {
70
- Form: {},
71
- Failed: {}
72
- }
73
- },
74
- Saving: {
75
- invoke: (from) =>
76
- from.effect("save-review", () => saveReview).onDone((to) => to.branch.Workflow.Publishing()).onFailure((to) =>
77
- to.branch.Workflow.Review.Failed().resolve(({ target }) =>
78
- target.from({ message: "The review could not be saved." })
90
+ Publishing: {
91
+ invoke: (from) =>
92
+ from.effect("publish-review", () => publishReview).onDone((to) =>
93
+ to.branch.Workflow.Complete().resolve(({ output, target }) => target.from({ slug: output }))
79
94
  )
80
- )
81
- },
82
- Publishing: {
83
- invoke: (from) =>
84
- from.effect("publish-review", () => publishReview).onDone((to) =>
85
- to.branch.Workflow.Complete().resolve(({ output, target }) => target.from({ slug: output }))
86
- )
87
- },
88
- Complete: {}
95
+ },
96
+ Complete: {}
97
+ }
89
98
  }
90
99
  }
91
100
  })