@typeonce/effect-machine-devtools 0.33.0 → 0.34.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/client/assets/index-s8iI2tep.js +37 -0
- package/dist/client/index.html +1 -1
- package/package.json +2 -2
- package/src/internal/browser/example-machine.ts +24 -15
- package/src/internal/browser/hierarchy-routing-example.ts +27 -24
- package/src/internal/browser/invoke-outcomes-example.ts +107 -83
- package/src/internal/browser/layout-resilience-example.ts +66 -52
- package/src/internal/browser/parallel-completion-example.ts +58 -51
- package/src/internal/browser/parallel-owner-routing-example.ts +32 -11
- package/src/internal/browser/planner-example.ts +20 -13
- package/src/internal/browser/protocol-events-example.ts +80 -50
- package/src/internal/browser/shared-terminal-routing-example.ts +90 -59
- package/src/internal/browser/transition-semantics-example.ts +73 -66
- package/src/internal/browser/visualizer-app.ts +8 -18
- package/src/internal/browser/visualizer-model.ts +10 -95
- package/dist/client/assets/index-2uvShdlX.js +0 -37
|
@@ -28,9 +28,22 @@ const ReplicationEvents = Machine.eventsFromSchemas(
|
|
|
28
28
|
})
|
|
29
29
|
)
|
|
30
30
|
|
|
31
|
-
const operation
|
|
31
|
+
const operation: Effect.Effect<void, string> = Effect.succeed(undefined)
|
|
32
32
|
|
|
33
|
+
const targets1 = Machine.targets(ReplicationStates)
|
|
33
34
|
export const sharedTerminalRoutingMachine = Machine.make({
|
|
35
|
+
effects: {
|
|
36
|
+
source1: operation,
|
|
37
|
+
source2: operation,
|
|
38
|
+
source3: operation,
|
|
39
|
+
source4: operation,
|
|
40
|
+
source5: operation,
|
|
41
|
+
source6: operation,
|
|
42
|
+
source7: operation,
|
|
43
|
+
source8: operation,
|
|
44
|
+
source9: operation
|
|
45
|
+
},
|
|
46
|
+
|
|
34
47
|
id: "shared-terminal-routing",
|
|
35
48
|
root: ReplicationStates,
|
|
36
49
|
events: ReplicationEvents,
|
|
@@ -38,108 +51,126 @@ export const sharedTerminalRoutingMachine = Machine.make({
|
|
|
38
51
|
}).handle({
|
|
39
52
|
states: {
|
|
40
53
|
Connecting: {
|
|
41
|
-
invoke:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
54
|
+
invoke: {
|
|
55
|
+
src: "source1",
|
|
56
|
+
id: "connect",
|
|
57
|
+
onDone: { target: targets1.root.IdentifyingSource },
|
|
58
|
+
onFailure: { target: targets1.root.Failed }
|
|
59
|
+
},
|
|
45
60
|
on: {
|
|
46
|
-
SessionUnavailable:
|
|
47
|
-
StopRequested:
|
|
61
|
+
SessionUnavailable: { target: targets1.root.SessionUnavailable },
|
|
62
|
+
StopRequested: { target: targets1.root.Stopping }
|
|
48
63
|
}
|
|
49
64
|
},
|
|
50
65
|
IdentifyingSource: {
|
|
51
|
-
invoke:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
66
|
+
invoke: {
|
|
67
|
+
src: "source2",
|
|
68
|
+
id: "identify-source",
|
|
69
|
+
onDone: { target: targets1.root.ReadingServerInfo },
|
|
70
|
+
onFailure: { target: targets1.root.Failed }
|
|
71
|
+
},
|
|
55
72
|
on: {
|
|
56
|
-
SessionUnavailable:
|
|
57
|
-
StopRequested:
|
|
73
|
+
SessionUnavailable: { target: targets1.root.SessionUnavailable },
|
|
74
|
+
StopRequested: { target: targets1.root.Stopping }
|
|
58
75
|
}
|
|
59
76
|
},
|
|
60
77
|
ReadingServerInfo: {
|
|
61
|
-
invoke:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
78
|
+
invoke: {
|
|
79
|
+
src: "source3",
|
|
80
|
+
id: "read-server-info",
|
|
81
|
+
onDone: { target: targets1.root.ReadingSlot },
|
|
82
|
+
onFailure: { target: targets1.root.Failed }
|
|
83
|
+
},
|
|
65
84
|
on: {
|
|
66
|
-
SessionUnavailable:
|
|
67
|
-
StopRequested:
|
|
85
|
+
SessionUnavailable: { target: targets1.root.SessionUnavailable },
|
|
86
|
+
StopRequested: { target: targets1.root.Stopping }
|
|
68
87
|
}
|
|
69
88
|
},
|
|
70
89
|
ReadingSlot: {
|
|
71
|
-
invoke:
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
90
|
+
invoke: {
|
|
91
|
+
src: "source4",
|
|
92
|
+
id: "read-slot",
|
|
93
|
+
onDone: { target: targets1.root.CreatingSlot },
|
|
94
|
+
onFailure: { target: targets1.root.Failed }
|
|
95
|
+
},
|
|
75
96
|
on: {
|
|
76
|
-
SessionUnavailable:
|
|
77
|
-
StopRequested:
|
|
97
|
+
SessionUnavailable: { target: targets1.root.SessionUnavailable },
|
|
98
|
+
StopRequested: { target: targets1.root.Stopping }
|
|
78
99
|
}
|
|
79
100
|
},
|
|
80
101
|
CreatingSlot: {
|
|
81
|
-
invoke:
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
102
|
+
invoke: {
|
|
103
|
+
src: "source5",
|
|
104
|
+
id: "create-slot",
|
|
105
|
+
onDone: { target: targets1.root.CopyingSnapshot },
|
|
106
|
+
onFailure: { target: targets1.root.Failed }
|
|
107
|
+
},
|
|
85
108
|
on: {
|
|
86
|
-
SessionUnavailable:
|
|
87
|
-
StopRequested:
|
|
109
|
+
SessionUnavailable: { target: targets1.root.SessionUnavailable },
|
|
110
|
+
StopRequested: { target: targets1.root.Stopping }
|
|
88
111
|
}
|
|
89
112
|
},
|
|
90
113
|
CopyingSnapshot: {
|
|
91
|
-
invoke:
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
114
|
+
invoke: {
|
|
115
|
+
src: "source6",
|
|
116
|
+
id: "copy-snapshot",
|
|
117
|
+
onDone: { target: targets1.root.CatchingUp },
|
|
118
|
+
onFailure: { target: targets1.root.Failed }
|
|
119
|
+
},
|
|
95
120
|
on: {
|
|
96
|
-
SessionUnavailable:
|
|
97
|
-
StopRequested:
|
|
121
|
+
SessionUnavailable: { target: targets1.root.SessionUnavailable },
|
|
122
|
+
StopRequested: { target: targets1.root.Stopping }
|
|
98
123
|
}
|
|
99
124
|
},
|
|
100
125
|
CatchingUp: {
|
|
101
|
-
invoke:
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
126
|
+
invoke: {
|
|
127
|
+
src: "source7",
|
|
128
|
+
id: "catch-up",
|
|
129
|
+
onDone: { target: targets1.root.ApplyingChanges },
|
|
130
|
+
onFailure: { target: targets1.root.Failed }
|
|
131
|
+
},
|
|
105
132
|
on: {
|
|
106
|
-
SessionUnavailable:
|
|
107
|
-
StopRequested:
|
|
133
|
+
SessionUnavailable: { target: targets1.root.SessionUnavailable },
|
|
134
|
+
StopRequested: { target: targets1.root.Stopping }
|
|
108
135
|
}
|
|
109
136
|
},
|
|
110
137
|
ApplyingChanges: {
|
|
111
|
-
invoke:
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
138
|
+
invoke: {
|
|
139
|
+
src: "source8",
|
|
140
|
+
id: "apply-changes",
|
|
141
|
+
onDone: { target: targets1.root.Ready },
|
|
142
|
+
onFailure: { target: targets1.root.Failed }
|
|
143
|
+
},
|
|
115
144
|
on: {
|
|
116
|
-
SessionUnavailable:
|
|
117
|
-
StopRequested:
|
|
145
|
+
SessionUnavailable: { target: targets1.root.SessionUnavailable },
|
|
146
|
+
StopRequested: { target: targets1.root.Stopping }
|
|
118
147
|
}
|
|
119
148
|
},
|
|
120
149
|
Ready: {
|
|
121
150
|
on: {
|
|
122
|
-
SessionUnavailable:
|
|
123
|
-
StopRequested:
|
|
151
|
+
SessionUnavailable: { target: targets1.root.SessionUnavailable },
|
|
152
|
+
StopRequested: { target: targets1.root.Stopping }
|
|
124
153
|
}
|
|
125
154
|
},
|
|
126
155
|
SessionUnavailable: {
|
|
127
156
|
on: {
|
|
128
|
-
Retry:
|
|
129
|
-
StopRequested:
|
|
157
|
+
Retry: { target: targets1.root.Connecting },
|
|
158
|
+
StopRequested: { target: targets1.root.Stopping }
|
|
130
159
|
}
|
|
131
160
|
},
|
|
132
161
|
Stopping: {
|
|
133
|
-
invoke:
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
162
|
+
invoke: {
|
|
163
|
+
src: "source9",
|
|
164
|
+
id: "stop-session",
|
|
165
|
+
onDone: { target: targets1.root.Stopped },
|
|
166
|
+
onFailure: { target: targets1.root.Failed }
|
|
167
|
+
}
|
|
137
168
|
},
|
|
138
169
|
Stopped: {},
|
|
139
170
|
Failed: {
|
|
140
171
|
on: {
|
|
141
|
-
Retry:
|
|
142
|
-
StopRequested:
|
|
172
|
+
Retry: { target: targets1.root.Connecting },
|
|
173
|
+
StopRequested: { target: targets1.root.Stopping }
|
|
143
174
|
}
|
|
144
175
|
}
|
|
145
176
|
}
|
|
@@ -117,7 +117,21 @@ const defaultWorkspaceSnapshot = () => ({
|
|
|
117
117
|
}
|
|
118
118
|
})
|
|
119
119
|
|
|
120
|
+
const targets1 = Machine.targets(TransitionStates)
|
|
120
121
|
export const transitionSemanticsMachine = Machine.make({
|
|
122
|
+
branches: {
|
|
123
|
+
transition4: {
|
|
124
|
+
draft: { target: targets1.root.Workspace.Draft, title: "Preferred route is draft" },
|
|
125
|
+
review: { initial: targets1.root.Workspace.Review, title: "Preferred route is review" }
|
|
126
|
+
},
|
|
127
|
+
transition7: {
|
|
128
|
+
review: { initial: targets1.root.Workspace.Review, title: "Enter the review flow" },
|
|
129
|
+
publish: { target: targets1.root.Workspace.Finished, title: "Publish without review" }
|
|
130
|
+
},
|
|
131
|
+
transition14: { destination: { history: targets1.root.Workspace.recent } },
|
|
132
|
+
transition15: { destination: { history: targets1.root.Workspace.exact } }
|
|
133
|
+
},
|
|
134
|
+
|
|
121
135
|
id: "transition-semantics",
|
|
122
136
|
root: TransitionStates,
|
|
123
137
|
events: Machine.eventsFromSchemas(
|
|
@@ -148,87 +162,80 @@ export const transitionSemanticsMachine = Machine.make({
|
|
|
148
162
|
exact: { default: defaultWorkspaceSnapshot }
|
|
149
163
|
},
|
|
150
164
|
on: {
|
|
151
|
-
Pause: (
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
})
|
|
160
|
-
)
|
|
161
|
-
)
|
|
165
|
+
Pause: { target: targets1.root.Paused, decoded: ({ event }) => (new Paused({ reason: event.reason })) },
|
|
166
|
+
BumpWorkspace: {
|
|
167
|
+
update: targets1.root.Workspace,
|
|
168
|
+
decoded: ({ state: current }) => (new Workspace({
|
|
169
|
+
revision: current.revision + 1,
|
|
170
|
+
preferredRoute: current.preferredRoute
|
|
171
|
+
}))
|
|
172
|
+
}
|
|
162
173
|
},
|
|
163
|
-
onDone: (
|
|
164
|
-
to.branch.Published().resolve(({ target }) => target.decoded(new Published({ result: "workspace published" }))),
|
|
174
|
+
onDone: { target: targets1.root.Published, decoded: () => (new Published({ result: "workspace published" })) },
|
|
165
175
|
states: {
|
|
166
176
|
Routing: {
|
|
167
|
-
choice:
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
review: { title: "Preferred route is review", target: to.local.Review.initial }
|
|
171
|
-
}).resolve(({ containingState, select }) =>
|
|
177
|
+
choice: {
|
|
178
|
+
branches: "transition4",
|
|
179
|
+
resolve: ({ containingState, select }) =>
|
|
172
180
|
containingState.preferredRoute === "review"
|
|
173
181
|
? select.review.decoded(new Review({ requestedBy: "initial route" }))
|
|
174
182
|
: select.draft.decoded(new Draft({ text: "", autosaves: 0 }))
|
|
175
|
-
|
|
183
|
+
}
|
|
176
184
|
},
|
|
177
185
|
Draft: {
|
|
178
186
|
on: {
|
|
179
|
-
Edit:
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
Save:
|
|
184
|
-
Submit:
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
publish: { title: "Publish without review", target: to.local.Finished() }
|
|
188
|
-
}).resolve(({ event, select }) =>
|
|
187
|
+
Edit: {
|
|
188
|
+
target: targets1.root.Workspace.Draft,
|
|
189
|
+
decoded: ({ event, state }) => (new Draft({ text: event.text, autosaves: state.autosaves }))
|
|
190
|
+
},
|
|
191
|
+
Save: { target: targets1.root.Workspace.AutoSaving, decoded: () => (new AutoSaving({})) },
|
|
192
|
+
Submit: {
|
|
193
|
+
branches: "transition7",
|
|
194
|
+
resolve: ({ event, select }) =>
|
|
189
195
|
event.mode === "publish"
|
|
190
196
|
? select.publish.decoded(new WorkspaceFinished({ result: "published directly" }))
|
|
191
197
|
: select.review.decoded(new Review({ requestedBy: event.requestedBy }))
|
|
192
|
-
|
|
193
|
-
Refresh:
|
|
194
|
-
Ignore:
|
|
195
|
-
MaybeHandle:
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
198
|
+
},
|
|
199
|
+
Refresh: { none: true, reenter: true },
|
|
200
|
+
Ignore: { none: true },
|
|
201
|
+
MaybeHandle: {
|
|
202
|
+
none: true,
|
|
203
|
+
resolve: ({ decline, event }) => event.accept ? undefined : decline(),
|
|
204
|
+
declinable: true
|
|
205
|
+
}
|
|
199
206
|
}
|
|
200
207
|
},
|
|
201
208
|
AutoSaving: {
|
|
202
|
-
always:
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
209
|
+
always: {
|
|
210
|
+
target: targets1.root.Workspace.Draft,
|
|
211
|
+
decoded: () => (new Draft({ text: "Autosaved draft", autosaves: 1 }))
|
|
212
|
+
}
|
|
206
213
|
},
|
|
207
214
|
Review: {
|
|
208
215
|
initialize: ({ builder }) => builder.decoded(new Checking({ checks: ["types", "tests"] })),
|
|
209
|
-
onDone:
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
216
|
+
onDone: {
|
|
217
|
+
target: targets1.root.Workspace.Finished,
|
|
218
|
+
decoded: () => (new WorkspaceFinished({ result: "approved review" }))
|
|
219
|
+
},
|
|
213
220
|
states: {
|
|
214
221
|
Checking: {
|
|
215
222
|
on: {
|
|
216
|
-
Approve:
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
Reject:
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
223
|
+
Approve: {
|
|
224
|
+
target: targets1.root.Workspace.Review.Approved,
|
|
225
|
+
decoded: ({ event }) => (new Approved({ reviewer: event.reviewer }))
|
|
226
|
+
},
|
|
227
|
+
Reject: {
|
|
228
|
+
target: targets1.root.Workspace.Review.ChangesRequested,
|
|
229
|
+
decoded: ({ event }) => (new ChangesRequested({ reason: event.reason }))
|
|
230
|
+
}
|
|
224
231
|
}
|
|
225
232
|
},
|
|
226
233
|
ChangesRequested: {
|
|
227
234
|
on: {
|
|
228
|
-
Revise:
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
235
|
+
Revise: {
|
|
236
|
+
target: targets1.root.Workspace.Draft,
|
|
237
|
+
decoded: () => (new Draft({ text: "Revised draft", autosaves: 0 }))
|
|
238
|
+
}
|
|
232
239
|
}
|
|
233
240
|
}
|
|
234
241
|
}
|
|
@@ -237,16 +244,16 @@ export const transitionSemanticsMachine = Machine.make({
|
|
|
237
244
|
},
|
|
238
245
|
Paused: {
|
|
239
246
|
on: {
|
|
240
|
-
Create:
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
ResumeShallow:
|
|
245
|
-
ResumeDeep:
|
|
246
|
-
Restart:
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
247
|
+
Create: {
|
|
248
|
+
initial: targets1.root.Workspace,
|
|
249
|
+
decoded: ({ event }) => (new Workspace({ revision: 0, preferredRoute: event.route }))
|
|
250
|
+
},
|
|
251
|
+
ResumeShallow: { branches: "transition14", resolve: ({ select: { destination: target } }) => target() },
|
|
252
|
+
ResumeDeep: { branches: "transition15", resolve: ({ select: { destination: target } }) => target() },
|
|
253
|
+
Restart: {
|
|
254
|
+
initial: targets1.root.Workspace,
|
|
255
|
+
decoded: () => (new Workspace({ revision: 0, preferredRoute: "draft" }))
|
|
256
|
+
}
|
|
250
257
|
}
|
|
251
258
|
},
|
|
252
259
|
Disabled: {},
|
|
@@ -76,8 +76,6 @@ const stateLink = (path: string, label: string, navigate: StateNavigator): HTMLB
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
const renderBranch = (
|
|
79
|
-
document: VisualizationDocument,
|
|
80
|
-
source: string,
|
|
81
79
|
branch: VisualizationBranch,
|
|
82
80
|
navigate: StateNavigator
|
|
83
81
|
): HTMLElement => {
|
|
@@ -88,7 +86,7 @@ const renderBranch = (
|
|
|
88
86
|
main.append(createElement("span", "branch-arrow", "→"), stateLink(branch.target, branch.target, navigate))
|
|
89
87
|
} else if (branch.selection.kind === "update") {
|
|
90
88
|
main.append(
|
|
91
|
-
badge(
|
|
89
|
+
badge("value update", "update"),
|
|
92
90
|
createElement("span", "branch-target", "Updates the owner value")
|
|
93
91
|
)
|
|
94
92
|
} else {
|
|
@@ -96,7 +94,7 @@ const renderBranch = (
|
|
|
96
94
|
}
|
|
97
95
|
row.append(main)
|
|
98
96
|
|
|
99
|
-
const api = branchTargetApi(
|
|
97
|
+
const api = branchTargetApi(branch)
|
|
100
98
|
const details: Array<readonly [string, MetadataValue]> = api === undefined
|
|
101
99
|
? [["Selection", branch.selection.kind], ["Scope", branch.selection.scope]]
|
|
102
100
|
: [["API", api]]
|
|
@@ -111,7 +109,6 @@ const renderBranch = (
|
|
|
111
109
|
}
|
|
112
110
|
|
|
113
111
|
const renderTransition = (
|
|
114
|
-
document: VisualizationDocument,
|
|
115
112
|
transition: VisualizationTransition,
|
|
116
113
|
navigate: StateNavigator,
|
|
117
114
|
showSource = false
|
|
@@ -134,16 +131,13 @@ const renderTransition = (
|
|
|
134
131
|
|
|
135
132
|
if (transition.branches.length > 0) {
|
|
136
133
|
const branches = createElement("div", "branch-list")
|
|
137
|
-
transition.branches.forEach((branch) =>
|
|
138
|
-
branches.append(renderBranch(document, transition.source, branch, navigate))
|
|
139
|
-
)
|
|
134
|
+
transition.branches.forEach((branch) => branches.append(renderBranch(branch, navigate)))
|
|
140
135
|
card.append(branches)
|
|
141
136
|
}
|
|
142
137
|
return card
|
|
143
138
|
}
|
|
144
139
|
|
|
145
140
|
const renderIncomingTransition = (
|
|
146
|
-
document: VisualizationDocument,
|
|
147
141
|
incoming: IncomingTransition,
|
|
148
142
|
navigate: StateNavigator
|
|
149
143
|
): HTMLElement => {
|
|
@@ -156,7 +150,7 @@ const renderIncomingTransition = (
|
|
|
156
150
|
header.append(title, flags)
|
|
157
151
|
card.append(header)
|
|
158
152
|
|
|
159
|
-
const api = branchTargetApi(
|
|
153
|
+
const api = branchTargetApi(incoming.branch)
|
|
160
154
|
const details: Array<readonly [string, MetadataValue]> = [
|
|
161
155
|
["Source", stateLink(incoming.transition.source, incoming.transition.source, navigate)],
|
|
162
156
|
["API", api]
|
|
@@ -576,16 +570,14 @@ export const renderVisualizer = (
|
|
|
576
570
|
if (inspection.outgoing.length > 0) {
|
|
577
571
|
const transitions = createElement("section", "inspector-section")
|
|
578
572
|
transitions.append(inspectionSection("Transitions", inspection.outgoing.length))
|
|
579
|
-
inspection.outgoing.forEach((transition) =>
|
|
580
|
-
transitions.append(renderTransition(visualization, transition, navigateToState))
|
|
581
|
-
)
|
|
573
|
+
inspection.outgoing.forEach((transition) => transitions.append(renderTransition(transition, navigateToState)))
|
|
582
574
|
inspectorContent.append(transitions)
|
|
583
575
|
}
|
|
584
576
|
if (inspection.incoming.length > 0) {
|
|
585
577
|
const incoming = createElement("section", "inspector-section")
|
|
586
578
|
incoming.append(inspectionSection("Entered by", inspection.incoming.length))
|
|
587
579
|
inspection.incoming.forEach((transition) =>
|
|
588
|
-
incoming.append(renderIncomingTransition(
|
|
580
|
+
incoming.append(renderIncomingTransition(transition, navigateToState))
|
|
589
581
|
)
|
|
590
582
|
inspectorContent.append(incoming)
|
|
591
583
|
}
|
|
@@ -623,9 +615,7 @@ export const renderVisualizer = (
|
|
|
623
615
|
const details = createElement("section", "inspector-section")
|
|
624
616
|
details.append(inspectionSection("Branches", transition.branches.length))
|
|
625
617
|
const branches = createElement("div", "inspection-card branch-list")
|
|
626
|
-
transition.branches.forEach((branch) =>
|
|
627
|
-
branches.append(renderBranch(visualization, transition.source, branch, navigateToState))
|
|
628
|
-
)
|
|
618
|
+
transition.branches.forEach((branch) => branches.append(renderBranch(branch, navigateToState)))
|
|
629
619
|
details.append(branches)
|
|
630
620
|
inspectorContent.append(details)
|
|
631
621
|
}
|
|
@@ -758,7 +748,7 @@ export const renderVisualizer = (
|
|
|
758
748
|
const choice = frame.choice
|
|
759
749
|
const transition = transitionsById.get(choice.transitionId)
|
|
760
750
|
const branch = transition?.branches.find(({ id }) => id === choice.branchId)
|
|
761
|
-
const api = branch === undefined ? undefined : branchTargetApi(
|
|
751
|
+
const api = branch === undefined ? undefined : branchTargetApi(branch)
|
|
762
752
|
const selection = createElement("section", "inspector-section")
|
|
763
753
|
selection.append(inspectionSection("Selected branch"))
|
|
764
754
|
const card = createElement("article", "inspection-card trace-card")
|
|
@@ -76,104 +76,19 @@ const propertyAccess = (key: string): string => /^[$A-Z_a-z][$\w]*$/.test(key) ?
|
|
|
76
76
|
|
|
77
77
|
const pathAccess = (path: string): string => path === "" ? "" : path.split(".").map(propertyAccess).join("")
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
source: string
|
|
82
|
-
): string | undefined => {
|
|
83
|
-
const states = new Map(document.states.map((state) => [state.path, state]))
|
|
84
|
-
let current = states.get(source)
|
|
85
|
-
while (current !== undefined) {
|
|
86
|
-
if (current.type === "compound") return current.path
|
|
87
|
-
current = current.parent === null ? undefined : states.get(current.parent)
|
|
88
|
-
}
|
|
89
|
-
return undefined
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const localPathAccess = (
|
|
93
|
-
document: VisualizationDocument,
|
|
94
|
-
source: string,
|
|
95
|
-
path: string
|
|
96
|
-
): string | undefined => {
|
|
97
|
-
const scope = nearestCompoundScope(document, source)
|
|
98
|
-
if (scope === undefined) return undefined
|
|
99
|
-
if (path === scope) return ""
|
|
100
|
-
const prefix = scope === "" ? "" : `${scope}.`
|
|
101
|
-
return path.startsWith(prefix) ? pathAccess(path.slice(prefix.length)) : undefined
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/** Canonical Effect Machine selector represented by one retained transition branch. */
|
|
105
|
-
export const branchTargetApi = (
|
|
106
|
-
document: VisualizationDocument,
|
|
107
|
-
source: string,
|
|
108
|
-
branch: VisualizationBranch
|
|
109
|
-
): string | undefined => {
|
|
79
|
+
/** Public declaration represented by a retained transition branch. */
|
|
80
|
+
export const branchTargetApi = (branch: VisualizationBranch): string | undefined => {
|
|
110
81
|
const { selection } = branch
|
|
111
|
-
if (selection.kind === "none") return "
|
|
82
|
+
if (selection.kind === "none") return "{ none: true }"
|
|
112
83
|
const path = selection.path
|
|
113
|
-
if (path === null
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const local = localPathAccess(document, source, path)
|
|
120
|
-
if (local === undefined) return undefined
|
|
121
|
-
switch (selection.kind) {
|
|
122
|
-
case "state":
|
|
123
|
-
api = local === "" ? "to.local.with" : `to.local${local}()`
|
|
124
|
-
break
|
|
125
|
-
case "choice":
|
|
126
|
-
api = local === "" ? undefined : `to.local${local}()`
|
|
127
|
-
break
|
|
128
|
-
case "initial":
|
|
129
|
-
api = local === "" ? undefined : `to.local${local}.initial`
|
|
130
|
-
break
|
|
131
|
-
case "update":
|
|
132
|
-
api = local === "" ? "to.local.update" : undefined
|
|
133
|
-
break
|
|
134
|
-
case "history":
|
|
135
|
-
break
|
|
136
|
-
}
|
|
137
|
-
} else if (selection.scope === "branch") {
|
|
138
|
-
switch (selection.kind) {
|
|
139
|
-
case "state":
|
|
140
|
-
case "choice":
|
|
141
|
-
api = path === "" ? "to.root()" : `to.branch${pathAccess(path)}()`
|
|
142
|
-
break
|
|
143
|
-
case "initial":
|
|
144
|
-
api = path === "" ? "to.root.initial" : `to.branch${pathAccess(path)}.initial`
|
|
145
|
-
break
|
|
146
|
-
case "update":
|
|
147
|
-
api = path === "" ? "to.root.update" : `to.branch${pathAccess(path)}.update`
|
|
148
|
-
break
|
|
149
|
-
case "history":
|
|
150
|
-
break
|
|
151
|
-
}
|
|
152
|
-
} else if (selection.scope === "full") {
|
|
153
|
-
switch (selection.kind) {
|
|
154
|
-
case "state":
|
|
155
|
-
case "choice":
|
|
156
|
-
api = `to.full${pathAccess(path)}()`
|
|
157
|
-
break
|
|
158
|
-
case "initial":
|
|
159
|
-
api = `to.full${pathAccess(path)}.initial`
|
|
160
|
-
break
|
|
161
|
-
case "history":
|
|
162
|
-
api = `to.history${pathAccess(path)}`
|
|
163
|
-
break
|
|
164
|
-
case "update":
|
|
165
|
-
break
|
|
166
|
-
}
|
|
167
|
-
} else if (selection.scope === "initial") {
|
|
168
|
-
if (selection.kind === "state") api = path === "" ? "to" : `to${pathAccess(path)}()`
|
|
169
|
-
if (selection.kind === "initial") api = `to${pathAccess(path)}.initial`
|
|
84
|
+
if (path === null) return undefined
|
|
85
|
+
if (selection.scope === "initial") return "initialConfiguration"
|
|
86
|
+
const operation = selection.kind === "state" || selection.kind === "choice" ? "target" : selection.kind
|
|
87
|
+
const fields = [`${operation}: targets.root${pathAccess(path)}`]
|
|
88
|
+
if (operation !== "update") {
|
|
89
|
+
for (const owner of branch.updates) fields.push(`update: targets.root${pathAccess(owner)}`)
|
|
170
90
|
}
|
|
171
|
-
|
|
172
|
-
if (api === undefined || selection.kind === "update") return api
|
|
173
|
-
return branch.updates.reduce(
|
|
174
|
-
(expression, owner) => `${expression}.updating(to.branch${pathAccess(owner)})`,
|
|
175
|
-
api
|
|
176
|
-
)
|
|
91
|
+
return `{ ${fields.join(", ")} }`
|
|
177
92
|
}
|
|
178
93
|
|
|
179
94
|
const buildInitialPaths = (document: VisualizationDocument): ReadonlySet<string> => {
|