@typeonce/effect-machine-devtools 0.35.0 → 0.37.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-sLHK2z5M.js +37 -0
- package/dist/client/index.html +1 -1
- package/package.json +3 -2
- package/src/internal/browser/chart-layout.ts +57 -52
- package/src/internal/browser/example-machine.ts +6 -2
- package/src/internal/browser/hierarchy-routing-example.ts +2 -2
- package/src/internal/browser/invoke-outcomes-example.ts +3 -3
- package/src/internal/browser/layout-resilience-example.ts +4 -4
- package/src/internal/browser/parallel-completion-example.ts +2 -2
- package/src/internal/browser/planner-example.ts +2 -2
- package/src/internal/browser/protocol-events-example.ts +3 -3
- package/src/internal/browser/transition-semantics-example.ts +8 -8
- package/dist/client/assets/index-s8iI2tep.js +0 -37
package/dist/client/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<meta name="description" content="Interactive statechart visualization for Effect Machine" />
|
|
7
7
|
<title>Effect Machine · Statechart</title>
|
|
8
|
-
<script type="module" crossorigin src="./assets/index-
|
|
8
|
+
<script type="module" crossorigin src="./assets/index-sLHK2z5M.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="./assets/index-DkC3PbTy.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typeonce/effect-machine-devtools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0",
|
|
4
4
|
"description": "Local development tools for Effect Machine",
|
|
5
5
|
"author": "Sandro Maglione",
|
|
6
6
|
"repository": {
|
|
@@ -29,11 +29,12 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@effect/platform-browser": "4.0.0-rc.112",
|
|
31
31
|
"@effect/platform-node": "4.0.0-rc.112",
|
|
32
|
+
"@effect/platform-node-shared": "4.0.0-rc.112",
|
|
32
33
|
"chokidar": "4.0.3",
|
|
33
34
|
"elkjs": "0.12.0",
|
|
34
35
|
"typescript": "6.0.3",
|
|
35
36
|
"vite": "8.1.5",
|
|
36
|
-
"@typeonce/effect-machine": "^0.
|
|
37
|
+
"@typeonce/effect-machine": "^0.37.0"
|
|
37
38
|
},
|
|
38
39
|
"peerDependencies": {
|
|
39
40
|
"effect": "4.0.0-rc.112"
|
|
@@ -896,35 +896,52 @@ const shortenTransitionRoute = (
|
|
|
896
896
|
return candidate
|
|
897
897
|
}
|
|
898
898
|
|
|
899
|
-
|
|
900
|
-
|
|
899
|
+
// Both repairs use a route oriented away from the endpoint being repaired.
|
|
900
|
+
// An attached opposite endpoint is a constraint, including on two-point routes
|
|
901
|
+
// where replacing the connection would otherwise replace both endpoint steps.
|
|
902
|
+
const normalizeEndpointDirection = (
|
|
901
903
|
points: ReadonlyArray<ChartPoint>,
|
|
902
|
-
|
|
903
|
-
|
|
904
|
+
node: LaidOutChartNode,
|
|
905
|
+
opposite: LaidOutChartNode | undefined,
|
|
906
|
+
obstacles: ReadonlyArray<ChartRect>
|
|
904
907
|
): ReadonlyArray<ChartPoint> => {
|
|
905
|
-
|
|
906
|
-
const
|
|
907
|
-
|
|
908
|
-
const
|
|
909
|
-
const
|
|
910
|
-
const
|
|
911
|
-
const
|
|
912
|
-
|
|
913
|
-
const
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
908
|
+
const rawStart = points[0]!
|
|
909
|
+
const side = endpointStepSide(rawStart, points[1]!, node)
|
|
910
|
+
const start = pointOnNodeBoundary(rawStart, node, side)
|
|
911
|
+
const end = points.at(-1)!
|
|
912
|
+
const previous = points.at(-2)!
|
|
913
|
+
const oppositeSide = opposite === undefined ? undefined : endpointStepSide(end, previous, opposite)
|
|
914
|
+
const preserveOpposite = opposite !== undefined && oppositeSide !== undefined &&
|
|
915
|
+
nodeBoundaryDistance(end, opposite) <= 0.5 && isOutwardStep(end, previous, oppositeSide)
|
|
916
|
+
const validEndpoints = (route: ReadonlyArray<ChartPoint>): boolean =>
|
|
917
|
+
isOutwardStep(route[0]!, route[1]!, side) && chartRouteLength(route.slice(0, 2)) >= 9 &&
|
|
918
|
+
(!preserveOpposite ||
|
|
919
|
+
isOutwardStep(route.at(-1)!, route.at(-2)!, oppositeSide!) && chartRouteLength(route.slice(-2)) >= 9)
|
|
920
|
+
|
|
921
|
+
const tail = points.slice(1)
|
|
922
|
+
const attached = compactPoints([start, ...tail])
|
|
923
|
+
if (attached.length >= 2 && validEndpoints(attached)) return attached
|
|
924
|
+
|
|
925
|
+
if (tail.length === 1 && preserveOpposite) {
|
|
926
|
+
tail.unshift(outwardPoint(end, oppositeSide!, 18))
|
|
927
|
+
}
|
|
928
|
+
const stub = outwardPoint(start, side, 18)
|
|
929
|
+
const endpointObstacles = [
|
|
930
|
+
...obstacles,
|
|
931
|
+
routeNodeRect(node),
|
|
932
|
+
...(preserveOpposite ? [routeNodeRect(opposite!)] : [])
|
|
933
|
+
]
|
|
934
|
+
return endpointConnections(stub, tail[0]!, routeNodeRect(node), side)
|
|
935
|
+
.map((connection) => compactPoints([start, ...connection, ...tail.slice(1)]))
|
|
936
|
+
.filter((route) =>
|
|
937
|
+
route.length >= 2 && validEndpoints(route) &&
|
|
938
|
+
!route.slice(1).some((point) => point.x === start.x && point.y === start.y) &&
|
|
939
|
+
routeIsClear(route, endpointObstacles)
|
|
922
940
|
)
|
|
923
|
-
.map((connection) => compactPoints([...prefix, ...connection.slice(1), end]))
|
|
924
941
|
.sort((left, right) => chartRouteLength(left) - chartRouteLength(right))[0] ?? attached
|
|
925
942
|
}
|
|
926
943
|
|
|
927
|
-
const
|
|
944
|
+
const normalizeTransitionEndpoints = (
|
|
928
945
|
edge: ChartEdge,
|
|
929
946
|
points: ReadonlyArray<ChartPoint>,
|
|
930
947
|
nodes: ReadonlyMap<string, LaidOutChartNode>,
|
|
@@ -932,21 +949,14 @@ const normalizeSourceDirection = (
|
|
|
932
949
|
): ReadonlyArray<ChartPoint> => {
|
|
933
950
|
if (isSelfTransition(edge) || points.length < 2) return points
|
|
934
951
|
const source = nodes.get(edge.source)
|
|
935
|
-
|
|
936
|
-
const
|
|
937
|
-
const
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
const sourceStub = outwardPoint(start, side, 18)
|
|
945
|
-
const obstacles = [...routeObstacles(edge, allNodes), routeNodeRect(source)]
|
|
946
|
-
return endpointConnections(sourceStub, next, routeNodeRect(source), side)
|
|
947
|
-
.filter((connection) => routeIsClear([start, ...connection, ...tail.slice(1)], obstacles))
|
|
948
|
-
.map((connection) => compactPoints([start, ...connection, ...tail.slice(1)]))
|
|
949
|
-
.sort((left, right) => chartRouteLength(left) - chartRouteLength(right))[0] ?? attached
|
|
952
|
+
const target = edge.target === null ? undefined : nodes.get(edge.target)
|
|
953
|
+
const obstacles = routeObstacles(edge, allNodes)
|
|
954
|
+
const fromSource = source === undefined || source.node.children.length > 0
|
|
955
|
+
? points
|
|
956
|
+
: normalizeEndpointDirection(points, source, target, obstacles)
|
|
957
|
+
return target === undefined
|
|
958
|
+
? fromSource
|
|
959
|
+
: [...normalizeEndpointDirection([...fromSource].reverse(), target, source, obstacles)].reverse()
|
|
950
960
|
}
|
|
951
961
|
|
|
952
962
|
const headerDetour = (
|
|
@@ -1207,24 +1217,19 @@ const collectLayout = (
|
|
|
1207
1217
|
if (elkPoints === undefined) return []
|
|
1208
1218
|
const chartEdge = chartEdges.get(edge.id)
|
|
1209
1219
|
if (chartEdge === undefined) return []
|
|
1210
|
-
const points =
|
|
1220
|
+
const points = normalizeTransitionEndpoints(
|
|
1211
1221
|
chartEdge,
|
|
1212
|
-
|
|
1222
|
+
avoidCompoundHeaders(
|
|
1213
1223
|
chartEdge,
|
|
1214
|
-
|
|
1224
|
+
(shortenRoutes ? shortenTransitionRoute : (_edge: ChartEdge, route: ReadonlyArray<ChartPoint>) => route)(
|
|
1215
1225
|
chartEdge,
|
|
1216
|
-
(
|
|
1217
|
-
|
|
1218
|
-
normalizeHierarchyRoute(chartEdge, elkPoints, nodesByPath, nodes, hierarchyLanes),
|
|
1219
|
-
nodesByPath,
|
|
1220
|
-
nodes,
|
|
1221
|
-
directLanes
|
|
1222
|
-
),
|
|
1226
|
+
normalizeHierarchyRoute(chartEdge, elkPoints, nodesByPath, nodes, hierarchyLanes),
|
|
1227
|
+
nodesByPath,
|
|
1223
1228
|
nodes,
|
|
1224
|
-
|
|
1229
|
+
directLanes
|
|
1225
1230
|
),
|
|
1226
|
-
|
|
1227
|
-
|
|
1231
|
+
nodes,
|
|
1232
|
+
hierarchyLanes
|
|
1228
1233
|
),
|
|
1229
1234
|
nodesByPath,
|
|
1230
1235
|
nodes
|
|
@@ -1700,7 +1705,7 @@ export const layoutChartWith = (
|
|
|
1700
1705
|
new ChartLayoutError({
|
|
1701
1706
|
cause: { failures, invalid },
|
|
1702
1707
|
message:
|
|
1703
|
-
`
|
|
1708
|
+
`Chart routing did not produce a safe layout for ${model.machineId} after ${layoutProfiles.length} deterministic attempts: ${detail}`
|
|
1704
1709
|
})
|
|
1705
1710
|
)
|
|
1706
1711
|
}
|
|
@@ -141,8 +141,12 @@ export const machine = Machine.make({
|
|
|
141
141
|
Start: {
|
|
142
142
|
branches: "transition1",
|
|
143
143
|
resolve: ({ select: { destination: target } }) =>
|
|
144
|
-
target
|
|
145
|
-
|
|
144
|
+
target({
|
|
145
|
+
data: new Running({}),
|
|
146
|
+
decoded: true,
|
|
147
|
+
states: { editing: { data: new Editing({}), decoded: true } },
|
|
148
|
+
update: { data: new Workflow({ document: "Machine.ts", unsavedChanges: 3 }), decoded: true }
|
|
149
|
+
})
|
|
146
150
|
},
|
|
147
151
|
Refresh: {
|
|
148
152
|
update: targets1.root.application.workflow,
|
|
@@ -60,8 +60,8 @@ export const hierarchyRoutingMachine = Machine.make({
|
|
|
60
60
|
branches: "transition1",
|
|
61
61
|
resolve: ({ event, select }) =>
|
|
62
62
|
event.route === "save"
|
|
63
|
-
? select.save
|
|
64
|
-
: select.invalid
|
|
63
|
+
? select.save({})
|
|
64
|
+
: select.invalid({ data: { message: "Add a title before continuing." } })
|
|
65
65
|
}
|
|
66
66
|
},
|
|
67
67
|
states: {
|
|
@@ -260,7 +260,7 @@ export const invokeOutcomesMachine = Machine.make({
|
|
|
260
260
|
branches: "transition13",
|
|
261
261
|
resolve: ({ select, snapshot }) =>
|
|
262
262
|
snapshot.state === "ready"
|
|
263
|
-
? select.ready
|
|
263
|
+
? select.ready({ data: new Completed({ source: "process", result: "ready" }), decoded: true })
|
|
264
264
|
: select.waiting()
|
|
265
265
|
}
|
|
266
266
|
}
|
|
@@ -279,12 +279,12 @@ export const invokeOutcomesMachine = Machine.make({
|
|
|
279
279
|
},
|
|
280
280
|
Completed: {
|
|
281
281
|
on: {
|
|
282
|
-
Reset: {
|
|
282
|
+
Reset: { target: targets2.root.Gallery, decoded: true, data: () => (new Gallery({ selectedDemo: null })) }
|
|
283
283
|
}
|
|
284
284
|
},
|
|
285
285
|
Failed: {
|
|
286
286
|
on: {
|
|
287
|
-
Reset: {
|
|
287
|
+
Reset: { target: targets2.root.Gallery, decoded: true, data: () => (new Gallery({ selectedDemo: null })) }
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
290
|
}
|
|
@@ -117,12 +117,12 @@ export const layoutResilienceMachine = Machine.make({
|
|
|
117
117
|
branches: "transition4",
|
|
118
118
|
resolve: ({ event, select }) => {
|
|
119
119
|
if (event.route === "login") {
|
|
120
|
-
return select.login
|
|
120
|
+
return select.login({})
|
|
121
121
|
}
|
|
122
122
|
if (event.route === "verification") {
|
|
123
|
-
return select.requestVerification
|
|
123
|
+
return select.requestVerification({})
|
|
124
124
|
}
|
|
125
|
-
return select.invalid
|
|
125
|
+
return select.invalid({ data: { message: "Enter valid authentication details." } })
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
},
|
|
@@ -149,7 +149,7 @@ export const layoutResilienceMachine = Machine.make({
|
|
|
149
149
|
id: "request-verification",
|
|
150
150
|
input: (context) => context,
|
|
151
151
|
onDone: {
|
|
152
|
-
|
|
152
|
+
target: targets1.root.Verification,
|
|
153
153
|
data: ({ containingState }) => ({
|
|
154
154
|
mode: containingState.mode,
|
|
155
155
|
email: containingState.email,
|
|
@@ -130,7 +130,7 @@ export const parallelCompletionMachine = Machine.make({
|
|
|
130
130
|
Cart: {
|
|
131
131
|
on: {
|
|
132
132
|
Checkout: {
|
|
133
|
-
|
|
133
|
+
target: targets1.root.Order,
|
|
134
134
|
decoded: true,
|
|
135
135
|
data: ({ event }) => (new Order({ orderId: event.orderId, total: event.total }))
|
|
136
136
|
}
|
|
@@ -242,7 +242,7 @@ export const parallelCompletionMachine = Machine.make({
|
|
|
242
242
|
Cancelled: {
|
|
243
243
|
on: {
|
|
244
244
|
RetryOrder: {
|
|
245
|
-
|
|
245
|
+
target: targets1.root.Order,
|
|
246
246
|
decoded: true,
|
|
247
247
|
data: () => (new Order({ orderId: "retry", total: 0 }))
|
|
248
248
|
}
|
|
@@ -173,8 +173,8 @@ export const plannerMachine = Machine.make({
|
|
|
173
173
|
}
|
|
174
174
|
const working = new Working({ owner: state.owner, job: event.job })
|
|
175
175
|
return event.priority === "urgent"
|
|
176
|
-
? select.urgent
|
|
177
|
-
: select.normal
|
|
176
|
+
? select.urgent({ data: working, decoded: true })
|
|
177
|
+
: select.normal({ data: working, decoded: true })
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
}
|
|
@@ -89,7 +89,7 @@ export const requiredParentChildMachine = Machine.make({
|
|
|
89
89
|
resolve: ({ event, select: { destination: target } }, enqueue) => {
|
|
90
90
|
enqueue.raise(ChildInternalEvents.Heartbeat({ percent: 25 }))
|
|
91
91
|
enqueue.emit(ChildEmissions.ChildTrace({ message: `started ${event.job}` }))
|
|
92
|
-
return target
|
|
92
|
+
return target({ data: new ChildWorking({ job: event.job, progress: 0 }), decoded: true })
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
}
|
|
@@ -111,7 +111,7 @@ export const requiredParentChildMachine = Machine.make({
|
|
|
111
111
|
branches: "transition3",
|
|
112
112
|
resolve: ({ event, state, select: { destination: target } }, enqueue) => {
|
|
113
113
|
enqueue.raise(ChildInternalEvents.CommitChildWork())
|
|
114
|
-
return target
|
|
114
|
+
return target({ data: new ChildWorking({ job: state.job, progress: event.percent }), decoded: true })
|
|
115
115
|
}
|
|
116
116
|
},
|
|
117
117
|
CommitChildWork: {
|
|
@@ -263,7 +263,7 @@ export const optionalParentMachine = Machine.make({
|
|
|
263
263
|
if (parent !== undefined) {
|
|
264
264
|
enqueue.sendTo(parent, ParentEvents.ChildFinished({ result: event.result }))
|
|
265
265
|
}
|
|
266
|
-
return target
|
|
266
|
+
return target({ data: new Published({ deliveredToParent: parent !== undefined }), decoded: true })
|
|
267
267
|
}
|
|
268
268
|
}
|
|
269
269
|
}
|
|
@@ -133,10 +133,10 @@ export const transitionSemanticsMachine = Machine.make({
|
|
|
133
133
|
branches: {
|
|
134
134
|
transition4: {
|
|
135
135
|
draft: { target: targets1.root.Workspace.Draft, title: "Preferred route is draft" },
|
|
136
|
-
review: {
|
|
136
|
+
review: { target: targets1.root.Workspace.Review, title: "Preferred route is review" }
|
|
137
137
|
},
|
|
138
138
|
transition7: {
|
|
139
|
-
review: {
|
|
139
|
+
review: { target: targets1.root.Workspace.Review, title: "Enter the review flow" },
|
|
140
140
|
publish: { target: targets1.root.Workspace.Finished, title: "Publish without review" }
|
|
141
141
|
},
|
|
142
142
|
transition14: { destination: { history: targets1.root.Workspace.recent } },
|
|
@@ -203,8 +203,8 @@ export const transitionSemanticsMachine = Machine.make({
|
|
|
203
203
|
branches: "transition4",
|
|
204
204
|
resolve: ({ containingState, select }) =>
|
|
205
205
|
containingState.preferredRoute === "review"
|
|
206
|
-
? select.review
|
|
207
|
-
: select.draft
|
|
206
|
+
? select.review({ data: new Review({ requestedBy: "initial route" }), decoded: true })
|
|
207
|
+
: select.draft({ data: new Draft({ text: "", autosaves: 0 }), decoded: true })
|
|
208
208
|
}
|
|
209
209
|
},
|
|
210
210
|
Draft: {
|
|
@@ -219,8 +219,8 @@ export const transitionSemanticsMachine = Machine.make({
|
|
|
219
219
|
branches: "transition7",
|
|
220
220
|
resolve: ({ event, select }) =>
|
|
221
221
|
event.mode === "publish"
|
|
222
|
-
? select.publish
|
|
223
|
-
: select.review
|
|
222
|
+
? select.publish({ data: new WorkspaceFinished({ result: "published directly" }), decoded: true })
|
|
223
|
+
: select.review({ data: new Review({ requestedBy: event.requestedBy }), decoded: true })
|
|
224
224
|
},
|
|
225
225
|
Refresh: { none: true, reenter: true },
|
|
226
226
|
Ignore: { none: true },
|
|
@@ -282,14 +282,14 @@ export const transitionSemanticsMachine = Machine.make({
|
|
|
282
282
|
Paused: {
|
|
283
283
|
on: {
|
|
284
284
|
Create: {
|
|
285
|
-
|
|
285
|
+
target: targets1.root.Workspace,
|
|
286
286
|
decoded: true,
|
|
287
287
|
data: ({ event }) => (new Workspace({ revision: 0, preferredRoute: event.route }))
|
|
288
288
|
},
|
|
289
289
|
ResumeShallow: { branches: "transition14", resolve: ({ select: { destination: target } }) => target() },
|
|
290
290
|
ResumeDeep: { branches: "transition15", resolve: ({ select: { destination: target } }) => target() },
|
|
291
291
|
Restart: {
|
|
292
|
-
|
|
292
|
+
target: targets1.root.Workspace,
|
|
293
293
|
decoded: true,
|
|
294
294
|
data: () => (new Workspace({ revision: 0, preferredRoute: "draft" }))
|
|
295
295
|
}
|