@typeonce/effect-machine-devtools 0.33.0 → 0.35.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 +95 -49
- package/src/internal/browser/hierarchy-routing-example.ts +40 -46
- package/src/internal/browser/invoke-outcomes-example.ts +187 -137
- package/src/internal/browser/layout-resilience-example.ts +103 -82
- package/src/internal/browser/parallel-completion-example.ts +141 -98
- package/src/internal/browser/parallel-owner-routing-example.ts +89 -50
- package/src/internal/browser/planner-example.ts +80 -30
- package/src/internal/browser/protocol-events-example.ts +155 -103
- package/src/internal/browser/shared-terminal-routing-example.ts +98 -73
- package/src/internal/browser/transition-semantics-example.ts +165 -119
- 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
|
@@ -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> => {
|