@typeonce/effect-machine-devtools 0.38.1 → 0.40.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.
@@ -128,19 +128,18 @@ const defaultWorkspaceSnapshot = () => ({
128
128
  }
129
129
  }
130
130
  })
131
- const targets1 = Machine.targets(TransitionStates)
132
131
  export const transitionSemanticsMachine = Machine.make({
133
132
  branches: {
134
133
  transition4: {
135
- draft: { target: targets1.root.Workspace.Draft, title: "Preferred route is draft" },
136
- review: { target: targets1.root.Workspace.Review, title: "Preferred route is review" }
134
+ draft: { target: "Workspace.Draft", title: "Preferred route is draft" },
135
+ review: { target: "Workspace.Review", title: "Preferred route is review" }
137
136
  },
138
137
  transition7: {
139
- review: { target: targets1.root.Workspace.Review, title: "Enter the review flow" },
140
- publish: { target: targets1.root.Workspace.Finished, title: "Publish without review" }
138
+ review: { target: "Workspace.Review", title: "Enter the review flow" },
139
+ publish: { target: "Workspace.Finished", title: "Publish without review" }
141
140
  },
142
- transition14: { destination: { history: targets1.root.Workspace.recent } },
143
- transition15: { destination: { history: targets1.root.Workspace.exact } }
141
+ transition14: { destination: { history: "Workspace.recent" } },
142
+ transition15: { destination: { history: "Workspace.exact" } }
144
143
  },
145
144
  id: "transition-semantics",
146
145
  root: TransitionStates,
@@ -164,14 +163,14 @@ export const transitionSemanticsMachine = Machine.make({
164
163
  )
165
164
  }).handle({
166
165
  initial: {
167
- target: Machine.targets(TransitionStates).root.Paused,
166
+ target: "Paused",
168
167
  decoded: true,
169
168
  data: new Paused({ reason: "not started" })
170
169
  },
171
170
  states: {
172
171
  Workspace: {
173
172
  initial: {
174
- target: Machine.targets(TransitionStates).root.Workspace.Routing
173
+ target: "Workspace.Routing"
175
174
  },
176
175
  history: {
177
176
  recent: { default: defaultWorkspaceSnapshot },
@@ -179,12 +178,12 @@ export const transitionSemanticsMachine = Machine.make({
179
178
  },
180
179
  on: {
181
180
  Pause: {
182
- target: targets1.root.Paused,
181
+ target: "Paused",
183
182
  decoded: true,
184
183
  data: ({ event }) => (new Paused({ reason: event.reason }))
185
184
  },
186
185
  BumpWorkspace: {
187
- update: targets1.root.Workspace,
186
+ update: "Workspace",
188
187
  decoded: true,
189
188
  data: ({ state: current }) => (new Workspace({
190
189
  revision: current.revision + 1,
@@ -193,7 +192,7 @@ export const transitionSemanticsMachine = Machine.make({
193
192
  }
194
193
  },
195
194
  onDone: {
196
- target: targets1.root.Published,
195
+ target: "Published",
197
196
  decoded: true,
198
197
  data: () => (new Published({ result: "workspace published" }))
199
198
  },
@@ -210,11 +209,11 @@ export const transitionSemanticsMachine = Machine.make({
210
209
  Draft: {
211
210
  on: {
212
211
  Edit: {
213
- target: targets1.root.Workspace.Draft,
212
+ target: "Workspace.Draft",
214
213
  decoded: true,
215
214
  data: ({ event, state }) => (new Draft({ text: event.text, autosaves: state.autosaves }))
216
215
  },
217
- Save: { target: targets1.root.Workspace.AutoSaving, decoded: true, data: () => (new AutoSaving({})) },
216
+ Save: { target: "Workspace.AutoSaving", decoded: true, data: () => (new AutoSaving({})) },
218
217
  Submit: {
219
218
  branches: "transition7",
220
219
  resolve: ({ event, select }) =>
@@ -233,19 +232,19 @@ export const transitionSemanticsMachine = Machine.make({
233
232
  },
234
233
  AutoSaving: {
235
234
  always: {
236
- target: targets1.root.Workspace.Draft,
235
+ target: "Workspace.Draft",
237
236
  decoded: true,
238
237
  data: () => (new Draft({ text: "Autosaved draft", autosaves: 1 }))
239
238
  }
240
239
  },
241
240
  Review: {
242
241
  initial: {
243
- target: Machine.targets(TransitionStates).root.Workspace.Review.Checking,
242
+ target: "Workspace.Review.Checking",
244
243
  decoded: true,
245
244
  data: ({}) => new Checking({ checks: ["types", "tests"] })
246
245
  },
247
246
  onDone: {
248
- target: targets1.root.Workspace.Finished,
247
+ target: "Workspace.Finished",
249
248
  decoded: true,
250
249
  data: () => (new WorkspaceFinished({ result: "approved review" }))
251
250
  },
@@ -253,12 +252,12 @@ export const transitionSemanticsMachine = Machine.make({
253
252
  Checking: {
254
253
  on: {
255
254
  Approve: {
256
- target: targets1.root.Workspace.Review.Approved,
255
+ target: "Workspace.Review.Approved",
257
256
  decoded: true,
258
257
  data: ({ event }) => (new Approved({ reviewer: event.reviewer }))
259
258
  },
260
259
  Reject: {
261
- target: targets1.root.Workspace.Review.ChangesRequested,
260
+ target: "Workspace.Review.ChangesRequested",
262
261
  decoded: true,
263
262
  data: ({ event }) => (new ChangesRequested({ reason: event.reason }))
264
263
  }
@@ -267,7 +266,7 @@ export const transitionSemanticsMachine = Machine.make({
267
266
  ChangesRequested: {
268
267
  on: {
269
268
  Revise: {
270
- target: targets1.root.Workspace.Draft,
269
+ target: "Workspace.Draft",
271
270
  decoded: true,
272
271
  data: () => (new Draft({ text: "Revised draft", autosaves: 0 }))
273
272
  }
@@ -282,14 +281,14 @@ export const transitionSemanticsMachine = Machine.make({
282
281
  Paused: {
283
282
  on: {
284
283
  Create: {
285
- target: targets1.root.Workspace,
284
+ target: "Workspace",
286
285
  decoded: true,
287
286
  data: ({ event }) => (new Workspace({ revision: 0, preferredRoute: event.route }))
288
287
  },
289
288
  ResumeShallow: { branches: "transition14", resolve: ({ select: { destination: target } }) => target() },
290
289
  ResumeDeep: { branches: "transition15", resolve: ({ select: { destination: target } }) => target() },
291
290
  Restart: {
292
- target: targets1.root.Workspace,
291
+ target: "Workspace",
293
292
  decoded: true,
294
293
  data: () => (new Workspace({ revision: 0, preferredRoute: "draft" }))
295
294
  }
@@ -72,9 +72,7 @@ export const triggerLabel = (transition: VisualizationTransition): string => {
72
72
  }
73
73
  }
74
74
 
75
- const propertyAccess = (key: string): string => /^[$A-Z_a-z][$\w]*$/.test(key) ? `.${key}` : `[${JSON.stringify(key)}]`
76
-
77
- const pathAccess = (path: string): string => path === "" ? "" : path.split(".").map(propertyAccess).join("")
75
+ const pathName = (path: string): string => JSON.stringify(path === "" ? "root" : path)
78
76
 
79
77
  /** Public declaration represented by a retained transition branch. */
80
78
  export const branchTargetApi = (branch: VisualizationBranch): string | undefined => {
@@ -84,9 +82,10 @@ export const branchTargetApi = (branch: VisualizationBranch): string | undefined
84
82
  if (path === null) return undefined
85
83
  if (selection.scope === "initial") return "initialConfiguration"
86
84
  const operation = selection.kind === "state" || selection.kind === "choice" ? "target" : selection.kind
87
- const fields = [`${operation}: targets.root${pathAccess(path)}`]
85
+ if (operation === "target" && path === "") return "{ initialize: … }"
86
+ const fields = [`${operation}: ${pathName(path)}`]
88
87
  if (operation !== "update") {
89
- for (const owner of branch.updates) fields.push(`update: targets.root${pathAccess(owner)}`)
88
+ for (const owner of branch.updates) fields.push(`update: ${pathName(owner)}`)
90
89
  }
91
90
  return `{ ${fields.join(", ")} }`
92
91
  }
@@ -2,7 +2,7 @@ import * as NodeWorkerRunner from "@effect/platform-node/NodeWorkerRunner"
2
2
  import { Machine } from "@typeonce/effect-machine"
3
3
  import * as Effect from "effect/Effect"
4
4
  import * as Schema from "effect/Schema"
5
- import * as WorkerRunner from "effect/unstable/workers/WorkerRunner"
5
+ import * as WorkerRunner from "effect/workers/WorkerRunner"
6
6
  import { resolve } from "node:path"
7
7
  import { pathToFileURL } from "node:url"
8
8
  import type { ViteDevServer } from "vite"
@@ -8,7 +8,7 @@ import * as FileSystem from "effect/FileSystem"
8
8
  import * as Layer from "effect/Layer"
9
9
  import * as Path from "effect/Path"
10
10
  import * as Schema from "effect/Schema"
11
- import * as Worker from "effect/unstable/workers/Worker"
11
+ import * as Worker from "effect/workers/Worker"
12
12
  import { Worker as NodeWorkerThread } from "node:worker_threads"
13
13
  import ts from "typescript"
14
14
  import * as DevToolsProtocol from "../DevToolsProtocol.js"