@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.
- package/dist/MachineRegistry.d.ts +4 -3
- package/dist/MachineRegistry.d.ts.map +1 -1
- package/dist/MachineRegistry.js +4 -3
- package/dist/MachineRegistry.js.map +1 -1
- package/dist/client/assets/index-2uvShdlX.js +37 -0
- package/dist/client/index.html +1 -1
- package/dist/internal/devServer.d.ts +3 -1
- package/dist/internal/devServer.d.ts.map +1 -1
- package/dist/internal/devServer.js +8 -6
- package/dist/internal/devServer.js.map +1 -1
- package/dist/internal/machineRegistry.js +9 -6
- package/dist/internal/machineRegistry.js.map +1 -1
- package/package.json +2 -2
- package/src/MachineRegistry.ts +4 -3
- package/src/internal/browser/chart-layout-policy.ts +2 -2
- package/src/internal/browser/chart-layout.ts +236 -51
- package/src/internal/browser/chart-model.ts +3 -0
- package/src/internal/browser/chart-renderer.ts +5 -4
- package/src/internal/browser/example-machine.ts +94 -85
- package/src/internal/browser/hierarchy-routing-example.ts +67 -58
- package/src/internal/browser/invoke-outcomes-example.ts +153 -143
- package/src/internal/browser/layout-resilience-example.ts +115 -104
- package/src/internal/browser/parallel-completion-example.ts +117 -107
- package/src/internal/browser/parallel-owner-routing-example.ts +104 -0
- package/src/internal/browser/planner-example.ts +44 -38
- package/src/internal/browser/protocol-events-example.ts +123 -102
- package/src/internal/browser/shared-terminal-routing-example.ts +125 -120
- package/src/internal/browser/text-tree.ts +2 -2
- package/src/internal/browser/transition-semantics-example.ts +143 -131
- package/src/internal/browser/visualizer-model.ts +7 -7
- package/src/internal/devServer.ts +15 -12
- package/src/internal/machineRegistry.ts +17 -17
- 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.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
64
|
+
},
|
|
65
|
+
disabled: Disabled
|
|
66
|
+
}
|
|
64
67
|
})
|
|
65
68
|
|
|
66
69
|
export const snapshot = {
|
|
67
|
-
path: "
|
|
68
|
-
value:
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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.
|
|
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
|
-
|
|
91
|
-
events: Machine.
|
|
92
|
-
|
|
97
|
+
root: States,
|
|
98
|
+
events: Machine.eventsFromSchemas(Start, Finish, Disconnect, Refresh),
|
|
99
|
+
initialConfiguration: (to) => to.resolve(() => snapshot)
|
|
93
100
|
}).handle({
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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.
|
|
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
|
-
|
|
43
|
+
root: ReviewStates,
|
|
41
44
|
events: ReviewEvents,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
target.from((
|
|
45
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
to
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
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
|
})
|