@typeonce/effect-machine-devtools 0.47.1 → 0.48.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/README.md +2 -2
- package/dist/DevToolsProtocol.d.ts +24 -24
- package/dist/MachineDocument.d.ts +10 -10
- package/dist/MachineDocument.d.ts.map +1 -1
- package/dist/MachineDocument.js +11 -11
- package/dist/MachineDocument.js.map +1 -1
- package/dist/MachineRegistry.d.ts +8 -8
- package/dist/client/assets/index-BKnyFv2V.js +37 -0
- package/dist/client/assets/index-oZzhV9Td.css +1 -0
- package/dist/client/index.html +2 -2
- package/dist/internal/machineDocument.js +14 -14
- package/dist/internal/machineDocument.js.map +1 -1
- package/package.json +3 -3
- package/src/MachineDocument.ts +12 -12
- package/src/internal/browser/chart-layout.ts +10 -10
- package/src/internal/browser/chart-model.ts +22 -22
- package/src/internal/browser/chart-renderer.ts +13 -13
- package/src/internal/browser/styles.css +77 -77
- package/src/internal/browser/text-tree.ts +15 -15
- package/src/internal/browser/visualizer-app.ts +21 -21
- package/src/internal/browser/visualizer-model.ts +9 -9
- package/src/internal/machineDocument.ts +14 -14
- package/dist/client/assets/index-BVMbU47j.js +0 -37
- package/dist/client/assets/index-DkC3PbTy.css +0 -1
|
@@ -509,7 +509,7 @@ button {
|
|
|
509
509
|
|
|
510
510
|
.chart-state-heading,
|
|
511
511
|
.chart-state-identity,
|
|
512
|
-
.chart-
|
|
512
|
+
.chart-invocation-row {
|
|
513
513
|
display: flex;
|
|
514
514
|
min-width: 0;
|
|
515
515
|
align-items: center;
|
|
@@ -539,7 +539,7 @@ button {
|
|
|
539
539
|
}
|
|
540
540
|
|
|
541
541
|
.chart-state-name,
|
|
542
|
-
.chart-
|
|
542
|
+
.chart-invocation-name {
|
|
543
543
|
min-width: 0;
|
|
544
544
|
overflow: hidden;
|
|
545
545
|
text-overflow: ellipsis;
|
|
@@ -550,14 +550,14 @@ button {
|
|
|
550
550
|
font-size: 12px;
|
|
551
551
|
}
|
|
552
552
|
|
|
553
|
-
.chart-
|
|
553
|
+
.chart-invocation-kind,
|
|
554
554
|
.chart-more {
|
|
555
555
|
color: var(--chart-text-muted);
|
|
556
556
|
font-size: 9px;
|
|
557
557
|
line-height: 1.3;
|
|
558
558
|
}
|
|
559
559
|
|
|
560
|
-
.chart-
|
|
560
|
+
.chart-invocation-kind {
|
|
561
561
|
text-transform: uppercase;
|
|
562
562
|
}
|
|
563
563
|
|
|
@@ -568,73 +568,73 @@ button {
|
|
|
568
568
|
border-top: 1px solid #333d48;
|
|
569
569
|
}
|
|
570
570
|
|
|
571
|
-
.chart-
|
|
571
|
+
.chart-invocation-row {
|
|
572
572
|
display: grid;
|
|
573
573
|
min-height: 20px;
|
|
574
574
|
gap: 10px;
|
|
575
575
|
}
|
|
576
576
|
|
|
577
|
-
.chart-
|
|
577
|
+
.chart-invocation-row {
|
|
578
578
|
grid-template-columns: auto minmax(0, 1fr);
|
|
579
579
|
}
|
|
580
580
|
|
|
581
|
-
.chart-
|
|
581
|
+
.chart-invocation-name {
|
|
582
582
|
color: #d1d7df;
|
|
583
583
|
font-size: 10px;
|
|
584
584
|
}
|
|
585
585
|
|
|
586
|
-
.chart-
|
|
586
|
+
.chart-invocation-kind {
|
|
587
587
|
flex: 0 1 auto;
|
|
588
588
|
overflow: hidden;
|
|
589
589
|
text-overflow: ellipsis;
|
|
590
590
|
white-space: nowrap;
|
|
591
591
|
}
|
|
592
592
|
|
|
593
|
-
.chart-
|
|
593
|
+
.chart-invocation-kind {
|
|
594
594
|
min-width: max-content;
|
|
595
|
-
color: var(--chart-
|
|
595
|
+
color: var(--chart-invocation-color, #82a9cb);
|
|
596
596
|
overflow: visible;
|
|
597
597
|
text-overflow: clip;
|
|
598
598
|
}
|
|
599
599
|
|
|
600
|
-
.chart-
|
|
601
|
-
.chart-edge-
|
|
602
|
-
.badge-
|
|
603
|
-
--chart-
|
|
604
|
-
--chart-
|
|
605
|
-
--chart-
|
|
600
|
+
.chart-invocation-process,
|
|
601
|
+
.chart-edge-invocation-process,
|
|
602
|
+
.badge-invocation-process {
|
|
603
|
+
--chart-invocation-color: #c99a82;
|
|
604
|
+
--chart-invocation-border: #624d42;
|
|
605
|
+
--chart-invocation-background: #1d1714;
|
|
606
606
|
}
|
|
607
607
|
|
|
608
|
-
.chart-
|
|
609
|
-
.chart-edge-
|
|
610
|
-
.badge-
|
|
611
|
-
--chart-
|
|
612
|
-
--chart-
|
|
613
|
-
--chart-
|
|
608
|
+
.chart-invocation-effect,
|
|
609
|
+
.chart-edge-invocation-effect,
|
|
610
|
+
.badge-invocation-effect {
|
|
611
|
+
--chart-invocation-color: #82a9cb;
|
|
612
|
+
--chart-invocation-border: #435c71;
|
|
613
|
+
--chart-invocation-background: #121a22;
|
|
614
614
|
}
|
|
615
615
|
|
|
616
|
-
.chart-
|
|
617
|
-
.chart-edge-
|
|
618
|
-
.badge-
|
|
619
|
-
--chart-
|
|
620
|
-
--chart-
|
|
621
|
-
--chart-
|
|
616
|
+
.chart-invocation-timer,
|
|
617
|
+
.chart-edge-invocation-timer,
|
|
618
|
+
.badge-invocation-timer {
|
|
619
|
+
--chart-invocation-color: #c1ad73;
|
|
620
|
+
--chart-invocation-border: #625842;
|
|
621
|
+
--chart-invocation-background: #1c1a13;
|
|
622
622
|
}
|
|
623
623
|
|
|
624
|
-
.chart-
|
|
625
|
-
.chart-edge-
|
|
626
|
-
.badge-
|
|
627
|
-
--chart-
|
|
628
|
-
--chart-
|
|
629
|
-
--chart-
|
|
624
|
+
.chart-invocation-stream,
|
|
625
|
+
.chart-edge-invocation-stream,
|
|
626
|
+
.badge-invocation-stream {
|
|
627
|
+
--chart-invocation-color: #75a9ad;
|
|
628
|
+
--chart-invocation-border: #3f5c5f;
|
|
629
|
+
--chart-invocation-background: #111a1b;
|
|
630
630
|
}
|
|
631
631
|
|
|
632
|
-
.chart-
|
|
633
|
-
.chart-edge-
|
|
634
|
-
.badge-
|
|
635
|
-
--chart-
|
|
636
|
-
--chart-
|
|
637
|
-
--chart-
|
|
632
|
+
.chart-invocation-machine,
|
|
633
|
+
.chart-edge-invocation-machine,
|
|
634
|
+
.badge-invocation-machine {
|
|
635
|
+
--chart-invocation-color: #a99cbd;
|
|
636
|
+
--chart-invocation-border: #574e67;
|
|
637
|
+
--chart-invocation-background: #1a1720;
|
|
638
638
|
}
|
|
639
639
|
|
|
640
640
|
.chart-more {
|
|
@@ -916,32 +916,32 @@ button {
|
|
|
916
916
|
stroke-dasharray: 7 5;
|
|
917
917
|
}
|
|
918
918
|
|
|
919
|
-
.chart-edge-group.chart-edge-
|
|
920
|
-
.chart-edge-group.chart-edge-
|
|
921
|
-
.chart-edge-group.chart-edge-
|
|
922
|
-
.chart-edge-group.chart-edge-
|
|
923
|
-
.chart-edge-group.chart-edge-
|
|
924
|
-
.chart-edge-group.chart-edge-
|
|
925
|
-
.chart-edge-group.chart-edge-
|
|
926
|
-
.chart-edge-group.chart-edge-
|
|
927
|
-
.chart-edge-group.chart-edge-
|
|
928
|
-
.chart-edge-group.chart-edge-
|
|
929
|
-
.chart-edge-group.chart-edge-
|
|
930
|
-
.chart-edge-group.chart-edge-
|
|
931
|
-
.chart-edge-group.chart-edge-
|
|
932
|
-
.chart-edge-group.chart-edge-
|
|
933
|
-
.chart-edge-group.chart-edge-
|
|
934
|
-
stroke: var(--chart-
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
.chart-edge-label.chart-edge-
|
|
938
|
-
.chart-edge-label.chart-edge-
|
|
939
|
-
.chart-edge-label.chart-edge-
|
|
940
|
-
.chart-edge-label.chart-edge-
|
|
941
|
-
.chart-edge-label.chart-edge-
|
|
942
|
-
--chart-edge-label-background: var(--chart-
|
|
943
|
-
--chart-edge-label-border: var(--chart-
|
|
944
|
-
color: var(--chart-
|
|
919
|
+
.chart-edge-group.chart-edge-invocation-process .chart-edge-line,
|
|
920
|
+
.chart-edge-group.chart-edge-invocation-effect .chart-edge-line,
|
|
921
|
+
.chart-edge-group.chart-edge-invocation-timer .chart-edge-line,
|
|
922
|
+
.chart-edge-group.chart-edge-invocation-stream .chart-edge-line,
|
|
923
|
+
.chart-edge-group.chart-edge-invocation-machine .chart-edge-line,
|
|
924
|
+
.chart-edge-group.chart-edge-invocation-process .chart-edge-direction,
|
|
925
|
+
.chart-edge-group.chart-edge-invocation-effect .chart-edge-direction,
|
|
926
|
+
.chart-edge-group.chart-edge-invocation-timer .chart-edge-direction,
|
|
927
|
+
.chart-edge-group.chart-edge-invocation-stream .chart-edge-direction,
|
|
928
|
+
.chart-edge-group.chart-edge-invocation-machine .chart-edge-direction,
|
|
929
|
+
.chart-edge-group.chart-edge-invocation-process .chart-edge-parent-origin,
|
|
930
|
+
.chart-edge-group.chart-edge-invocation-effect .chart-edge-parent-origin,
|
|
931
|
+
.chart-edge-group.chart-edge-invocation-timer .chart-edge-parent-origin,
|
|
932
|
+
.chart-edge-group.chart-edge-invocation-stream .chart-edge-parent-origin,
|
|
933
|
+
.chart-edge-group.chart-edge-invocation-machine .chart-edge-parent-origin {
|
|
934
|
+
stroke: var(--chart-invocation-color);
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
.chart-edge-label.chart-edge-invocation-process,
|
|
938
|
+
.chart-edge-label.chart-edge-invocation-effect,
|
|
939
|
+
.chart-edge-label.chart-edge-invocation-timer,
|
|
940
|
+
.chart-edge-label.chart-edge-invocation-stream,
|
|
941
|
+
.chart-edge-label.chart-edge-invocation-machine {
|
|
942
|
+
--chart-edge-label-background: var(--chart-invocation-background);
|
|
943
|
+
--chart-edge-label-border: var(--chart-invocation-border);
|
|
944
|
+
color: var(--chart-invocation-color);
|
|
945
945
|
}
|
|
946
946
|
|
|
947
947
|
.chart-edge-group.chart-edge-failure .chart-edge-line,
|
|
@@ -1124,18 +1124,18 @@ button {
|
|
|
1124
1124
|
background: rgb(172 104 224 / 15%);
|
|
1125
1125
|
}
|
|
1126
1126
|
|
|
1127
|
-
.badge-
|
|
1127
|
+
.badge-invocation {
|
|
1128
1128
|
color: #acd0e5;
|
|
1129
1129
|
background: rgb(82 145 183 / 16%);
|
|
1130
1130
|
}
|
|
1131
1131
|
|
|
1132
|
-
.badge-
|
|
1133
|
-
.badge-
|
|
1134
|
-
.badge-
|
|
1135
|
-
.badge-
|
|
1136
|
-
.badge-
|
|
1137
|
-
color: var(--chart-
|
|
1138
|
-
background: var(--chart-
|
|
1132
|
+
.badge-invocation-process,
|
|
1133
|
+
.badge-invocation-effect,
|
|
1134
|
+
.badge-invocation-timer,
|
|
1135
|
+
.badge-invocation-stream,
|
|
1136
|
+
.badge-invocation-machine {
|
|
1137
|
+
color: var(--chart-invocation-color);
|
|
1138
|
+
background: var(--chart-invocation-background);
|
|
1139
1139
|
}
|
|
1140
1140
|
|
|
1141
1141
|
.badge-count {
|
|
@@ -1463,7 +1463,7 @@ button {
|
|
|
1463
1463
|
|
|
1464
1464
|
.branch-row .metadata,
|
|
1465
1465
|
.transition-card .card-metadata,
|
|
1466
|
-
.
|
|
1466
|
+
.invocation-card .metadata,
|
|
1467
1467
|
.incoming-card .metadata {
|
|
1468
1468
|
margin-top: 10px;
|
|
1469
1469
|
}
|
|
@@ -1496,11 +1496,11 @@ button {
|
|
|
1496
1496
|
grid-column: 2;
|
|
1497
1497
|
}
|
|
1498
1498
|
|
|
1499
|
-
.
|
|
1499
|
+
.invocation-card {
|
|
1500
1500
|
padding-bottom: 12px;
|
|
1501
1501
|
}
|
|
1502
1502
|
|
|
1503
|
-
.
|
|
1503
|
+
.invocation-card .metadata {
|
|
1504
1504
|
padding: 0 12px;
|
|
1505
1505
|
}
|
|
1506
1506
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
Activity as VisualizationActivity,
|
|
3
2
|
Branch as VisualizationBranch,
|
|
3
|
+
Invocation as VisualizationInvocation,
|
|
4
4
|
MachineDocument as VisualizationDocument,
|
|
5
5
|
State as VisualizationState,
|
|
6
6
|
Transition as VisualizationTransition
|
|
7
7
|
} from "../../MachineDocument.js"
|
|
8
8
|
|
|
9
|
-
export type TreeItemKind = "state" | "transition" | "branch" | "
|
|
9
|
+
export type TreeItemKind = "state" | "transition" | "branch" | "invocation"
|
|
10
10
|
|
|
11
11
|
export interface TreeItemDetail {
|
|
12
12
|
readonly label: string
|
|
@@ -73,10 +73,10 @@ const branchLabel = (branch: VisualizationBranch): string | undefined => {
|
|
|
73
73
|
: `[${branch.key}] → ${target}${updates}`
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
const
|
|
76
|
+
const invocationLabel = (definition: VisualizationInvocation): string => {
|
|
77
77
|
switch (definition.type) {
|
|
78
|
-
case "
|
|
79
|
-
return `◆
|
|
78
|
+
case "logic":
|
|
79
|
+
return `◆ logic: ${definition.lifecycleId}`
|
|
80
80
|
case "effect":
|
|
81
81
|
return `◆ effect: ${definition.lifecycleId} [success: ${definition.outcomes.success}, failure: ${definition.outcomes.failure}]`
|
|
82
82
|
case "timer":
|
|
@@ -90,7 +90,7 @@ const activityLabel = (definition: VisualizationActivity): string => {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
const
|
|
93
|
+
const invocationDetails = (definition: VisualizationInvocation): ReadonlyArray<TreeItemDetail> => {
|
|
94
94
|
const common: Array<TreeItemDetail> = [
|
|
95
95
|
{ label: "Owner", value: definition.source },
|
|
96
96
|
{ label: "Lifecycle id", value: definition.lifecycleId },
|
|
@@ -108,7 +108,7 @@ export const visualizationDocumentToTextTree = (document: VisualizationDocument)
|
|
|
108
108
|
const active = new Set(document.snapshot?.activePaths ?? [])
|
|
109
109
|
const states = new Map(document.states.map((state) => [state.path, state]))
|
|
110
110
|
const transitions = new Map(document.transitions.map((transition) => [transition.id, transition]))
|
|
111
|
-
const
|
|
111
|
+
const invocations = new Map(document.invocations.map((invocation) => [invocation.id, invocation]))
|
|
112
112
|
const children = new Map<string | null, Array<VisualizationState>>()
|
|
113
113
|
|
|
114
114
|
for (const state of document.states) {
|
|
@@ -151,13 +151,13 @@ export const visualizationDocumentToTextTree = (document: VisualizationDocument)
|
|
|
151
151
|
children: branchItems
|
|
152
152
|
}]
|
|
153
153
|
})
|
|
154
|
-
const
|
|
155
|
-
const definition =
|
|
154
|
+
const invocationItems = state.invocationIds.flatMap((invocationId): ReadonlyArray<TreeItem> => {
|
|
155
|
+
const definition = invocations.get(invocationId)
|
|
156
156
|
return definition === undefined ? [] : [{
|
|
157
157
|
id: definition.id,
|
|
158
|
-
kind: "
|
|
159
|
-
label:
|
|
160
|
-
details:
|
|
158
|
+
kind: "invocation",
|
|
159
|
+
label: invocationLabel(definition),
|
|
160
|
+
details: invocationDetails(definition),
|
|
161
161
|
children: []
|
|
162
162
|
}]
|
|
163
163
|
})
|
|
@@ -175,15 +175,15 @@ export const visualizationDocumentToTextTree = (document: VisualizationDocument)
|
|
|
175
175
|
{ label: "Initial", value: state.initial ?? "none" },
|
|
176
176
|
{ label: "Children", value: String(state.children.length) }
|
|
177
177
|
],
|
|
178
|
-
children: [...transitionItems, ...
|
|
178
|
+
children: [...transitionItems, ...invocationItems, ...descendantItems]
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
return {
|
|
183
183
|
machineId: document.machineId,
|
|
184
|
-
legend: document.
|
|
184
|
+
legend: document.invocations.length === 0
|
|
185
185
|
? "● active ○ inactive ◇ transition ┄ branch → target"
|
|
186
|
-
: "● active ○ inactive ◇ transition ┄ branch → target ◆
|
|
186
|
+
: "● active ○ inactive ◇ transition ┄ branch → target ◆ invocation",
|
|
187
187
|
roots: document.roots.flatMap((path): ReadonlyArray<TreeItem> => {
|
|
188
188
|
const state = states.get(path)
|
|
189
189
|
return state === undefined ? [] : [visit(state)]
|
|
@@ -2,9 +2,9 @@ import * as Effect from "effect/Effect"
|
|
|
2
2
|
import * as Result from "effect/Result"
|
|
3
3
|
import type { Diagnostic } from "../../DevToolsProtocol.js"
|
|
4
4
|
import type {
|
|
5
|
-
Activity as VisualizationActivity,
|
|
6
5
|
Branch as VisualizationBranch,
|
|
7
6
|
InputSchema,
|
|
7
|
+
Invocation as VisualizationInvocation,
|
|
8
8
|
MachineDocument as VisualizationDocument,
|
|
9
9
|
Transition as VisualizationTransition,
|
|
10
10
|
Trigger
|
|
@@ -163,37 +163,37 @@ const renderIncomingTransition = (
|
|
|
163
163
|
return card
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
const
|
|
167
|
-
switch (
|
|
168
|
-
case "
|
|
166
|
+
const invocationTitle = (invocation: VisualizationInvocation): string => {
|
|
167
|
+
switch (invocation.type) {
|
|
168
|
+
case "logic":
|
|
169
169
|
case "effect":
|
|
170
170
|
case "timer":
|
|
171
171
|
case "stream":
|
|
172
|
-
return
|
|
172
|
+
return invocation.lifecycleId
|
|
173
173
|
case "machine":
|
|
174
|
-
return `${
|
|
174
|
+
return `${invocation.lifecycleId} → ${invocation.child.machineId ?? invocation.child.id}`
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
const
|
|
179
|
-
const card = createElement("article", "inspection-card
|
|
178
|
+
const renderInvocation = (invocation: VisualizationInvocation, navigate: StateNavigator): HTMLElement => {
|
|
179
|
+
const card = createElement("article", "inspection-card invocation-card")
|
|
180
180
|
const header = createElement("div", "card-header")
|
|
181
181
|
const title = createElement("div", "card-title")
|
|
182
|
-
title.append(createElement("strong", undefined,
|
|
182
|
+
title.append(createElement("strong", undefined, invocationTitle(invocation)))
|
|
183
183
|
const flags = createElement("div", "card-flags")
|
|
184
|
-
flags.append(badge(
|
|
184
|
+
flags.append(badge(invocation.type, `invocation badge-invocation-${invocation.type}`))
|
|
185
185
|
header.append(title, flags)
|
|
186
186
|
card.append(header)
|
|
187
187
|
|
|
188
188
|
const details: Array<readonly [string, MetadataValue]> = [
|
|
189
|
-
["Owner", stateLink(
|
|
189
|
+
["Owner", stateLink(invocation.source, invocation.source, navigate)]
|
|
190
190
|
]
|
|
191
|
-
if (
|
|
192
|
-
if (
|
|
193
|
-
details.push(["Success",
|
|
191
|
+
if (invocation.type === "timer") details.push(["Duration", invocation.duration])
|
|
192
|
+
if (invocation.type === "effect") {
|
|
193
|
+
details.push(["Success", invocation.outcomes.success], ["Failure", invocation.outcomes.failure])
|
|
194
194
|
}
|
|
195
|
-
if (
|
|
196
|
-
details.push(["Child address",
|
|
195
|
+
if (invocation.type === "machine") {
|
|
196
|
+
details.push(["Child address", invocation.child.id], ["Machine", invocation.child.machineId ?? "dynamic"])
|
|
197
197
|
}
|
|
198
198
|
card.append(metadata(details))
|
|
199
199
|
return card
|
|
@@ -581,11 +581,11 @@ export const renderVisualizer = (
|
|
|
581
581
|
)
|
|
582
582
|
inspectorContent.append(incoming)
|
|
583
583
|
}
|
|
584
|
-
if (inspection.
|
|
585
|
-
const
|
|
586
|
-
|
|
587
|
-
inspection.
|
|
588
|
-
inspectorContent.append(
|
|
584
|
+
if (inspection.invocations.length > 0) {
|
|
585
|
+
const invocations = createElement("section", "inspector-section")
|
|
586
|
+
invocations.append(inspectionSection("Invoked", inspection.invocations.length))
|
|
587
|
+
inspection.invocations.forEach((invocation) => invocations.append(renderInvocation(invocation, navigateToState)))
|
|
588
|
+
inspectorContent.append(invocations)
|
|
589
589
|
}
|
|
590
590
|
}
|
|
591
591
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
Activity as VisualizationActivity,
|
|
3
2
|
Branch as VisualizationBranch,
|
|
3
|
+
Invocation as VisualizationInvocation,
|
|
4
4
|
MachineDocument as VisualizationDocument,
|
|
5
5
|
State as VisualizationState,
|
|
6
6
|
Transition as VisualizationTransition
|
|
@@ -13,7 +13,7 @@ export interface TopologyNode {
|
|
|
13
13
|
readonly active: boolean
|
|
14
14
|
readonly initial: boolean
|
|
15
15
|
readonly transitionCount: number
|
|
16
|
-
readonly
|
|
16
|
+
readonly invocationCount: number
|
|
17
17
|
readonly children: ReadonlyArray<TopologyNode>
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -35,7 +35,7 @@ export interface StateInspection {
|
|
|
35
35
|
readonly breadcrumbs: ReadonlyArray<StateBreadcrumb>
|
|
36
36
|
readonly outgoing: ReadonlyArray<VisualizationTransition>
|
|
37
37
|
readonly incoming: ReadonlyArray<IncomingTransition>
|
|
38
|
-
readonly
|
|
38
|
+
readonly invocations: ReadonlyArray<VisualizationInvocation>
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
export interface EventInspection {
|
|
@@ -101,7 +101,7 @@ const buildInitialPaths = (document: VisualizationDocument): ReadonlySet<string>
|
|
|
101
101
|
export const makeVisualizerModel = (document: VisualizationDocument): VisualizerModel => {
|
|
102
102
|
const states = new Map(document.states.map((state) => [state.path, state]))
|
|
103
103
|
const transitions = new Map(document.transitions.map((transition) => [transition.id, transition]))
|
|
104
|
-
const
|
|
104
|
+
const invocations = new Map(document.invocations.map((invocation) => [invocation.id, invocation]))
|
|
105
105
|
const active = new Set(document.snapshot?.activePaths ?? [])
|
|
106
106
|
const initial = buildInitialPaths(document)
|
|
107
107
|
const candidateEvents = document.snapshot?.candidateEvents ?? []
|
|
@@ -112,9 +112,9 @@ export const makeVisualizerModel = (document: VisualizationDocument): Visualizer
|
|
|
112
112
|
return transition === undefined ? [] : [transition]
|
|
113
113
|
})
|
|
114
114
|
|
|
115
|
-
const
|
|
116
|
-
state.
|
|
117
|
-
const definition =
|
|
115
|
+
const ownedInvocations = (state: VisualizationState): ReadonlyArray<VisualizationInvocation> =>
|
|
116
|
+
state.invocationIds.flatMap((id): ReadonlyArray<VisualizationInvocation> => {
|
|
117
|
+
const definition = invocations.get(id)
|
|
118
118
|
return definition === undefined ? [] : [definition]
|
|
119
119
|
})
|
|
120
120
|
|
|
@@ -138,7 +138,7 @@ export const makeVisualizerModel = (document: VisualizationDocument): Visualizer
|
|
|
138
138
|
active: active.has(state.path),
|
|
139
139
|
initial: initial.has(state.path),
|
|
140
140
|
transitionCount: state.transitionIds.length,
|
|
141
|
-
|
|
141
|
+
invocationCount: state.invocationIds.length,
|
|
142
142
|
children: state.children.flatMap((childPath): ReadonlyArray<TopologyNode> => {
|
|
143
143
|
const child = visit(childPath)
|
|
144
144
|
return child === undefined ? [] : [child]
|
|
@@ -177,7 +177,7 @@ export const makeVisualizerModel = (document: VisualizationDocument): Visualizer
|
|
|
177
177
|
breadcrumbs: breadcrumbs(state),
|
|
178
178
|
outgoing: outgoing(state),
|
|
179
179
|
incoming: [...incoming.get(path) ?? []],
|
|
180
|
-
|
|
180
|
+
invocations: ownedInvocations(state)
|
|
181
181
|
}
|
|
182
182
|
},
|
|
183
183
|
inspectEvent: (event) => ({
|
|
@@ -92,11 +92,11 @@ const trigger = (value: Machine.Machine.TransitionTrigger): Public.Trigger => {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
const
|
|
95
|
+
const invocation = (value: Machine.Machine.InvocationDefinition, id: string): Public.Invocation => {
|
|
96
96
|
const common = { id, source: value.source, lifecycleId: value.id }
|
|
97
97
|
switch (value.type) {
|
|
98
|
-
case "
|
|
99
|
-
return { ...common, type: "
|
|
98
|
+
case "logic":
|
|
99
|
+
return { ...common, type: "logic" }
|
|
100
100
|
case "effect":
|
|
101
101
|
return { ...common, type: "effect", outcomes: { ...value.outcomes } }
|
|
102
102
|
case "timer":
|
|
@@ -120,9 +120,9 @@ export const make = <M extends Machine.Machine.Any>(
|
|
|
120
120
|
): Public.MachineDocument => {
|
|
121
121
|
const nodes = Machine.stateNodes(machine)
|
|
122
122
|
const transitionIds = new Map<string, Array<string>>()
|
|
123
|
-
const
|
|
123
|
+
const invocationIds = new Map<string, Array<string>>()
|
|
124
124
|
const transitionOffsets = new Map<string, number>()
|
|
125
|
-
const
|
|
125
|
+
const invocationOffsets = new Map<string, number>()
|
|
126
126
|
const childPaths = new Map<string | null, Array<string>>()
|
|
127
127
|
|
|
128
128
|
for (const node of nodes) {
|
|
@@ -157,17 +157,17 @@ export const make = <M extends Machine.Machine.Any>(
|
|
|
157
157
|
}
|
|
158
158
|
})
|
|
159
159
|
|
|
160
|
-
const
|
|
161
|
-
const offset =
|
|
162
|
-
|
|
163
|
-
const id = `${definition.source}:
|
|
164
|
-
appendReference(
|
|
165
|
-
return
|
|
160
|
+
const invocations = Machine.invocationDefinitions(machine).map((definition): Public.Invocation => {
|
|
161
|
+
const offset = invocationOffsets.get(definition.source) ?? 0
|
|
162
|
+
invocationOffsets.set(definition.source, offset + 1)
|
|
163
|
+
const id = `${definition.source}:invocation:${offset}`
|
|
164
|
+
appendReference(invocationIds, definition.source, id)
|
|
165
|
+
return invocation(definition, id)
|
|
166
166
|
})
|
|
167
167
|
|
|
168
168
|
const initial = Machine.initialDefinition(machine)
|
|
169
169
|
return {
|
|
170
|
-
schemaVersion:
|
|
170
|
+
schemaVersion: 4,
|
|
171
171
|
revision: options.revision ?? 0,
|
|
172
172
|
source: options.source ?? null,
|
|
173
173
|
machineId: machine.id ?? "Machine",
|
|
@@ -191,10 +191,10 @@ export const make = <M extends Machine.Machine.Any>(
|
|
|
191
191
|
valueSchema: node.schema === undefined ? null : inputSchema(node.schema),
|
|
192
192
|
outputSchema: node.output === undefined ? null : inputSchema(node.output),
|
|
193
193
|
transitionIds: [...transitionIds.get(node.path) ?? []],
|
|
194
|
-
|
|
194
|
+
invocationIds: [...invocationIds.get(node.path) ?? []]
|
|
195
195
|
})),
|
|
196
196
|
transitions,
|
|
197
|
-
|
|
197
|
+
invocations,
|
|
198
198
|
inputs: {
|
|
199
199
|
machine: machine.input === undefined ? null : inputSchema(machine.input),
|
|
200
200
|
events: eventInputs(machine)
|