@typeonce/effect-machine-devtools 0.24.0 → 0.26.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/NOTICE +4 -0
- package/README.md +13 -13
- package/dist/DevToolsProtocol.d.ts +66 -630
- package/dist/DevToolsProtocol.d.ts.map +1 -1
- package/dist/DevToolsProtocol.js +0 -190
- package/dist/DevToolsProtocol.js.map +1 -1
- package/dist/MachineDocument.d.ts +38 -18
- package/dist/MachineDocument.d.ts.map +1 -1
- package/dist/MachineDocument.js +14 -12
- package/dist/MachineDocument.js.map +1 -1
- package/dist/MachineRegistry.d.ts +22 -2
- package/dist/MachineRegistry.d.ts.map +1 -1
- package/dist/MachineWalkthrough.d.ts +171 -0
- package/dist/MachineWalkthrough.d.ts.map +1 -0
- package/dist/MachineWalkthrough.js +98 -0
- package/dist/MachineWalkthrough.js.map +1 -0
- package/dist/ProjectInspector.d.ts +0 -2
- package/dist/ProjectInspector.d.ts.map +1 -1
- package/dist/ProjectInspector.js.map +1 -1
- package/dist/client/assets/index-BsorPSDS.css +1 -0
- package/dist/client/assets/index-eiptehRd.js +37 -0
- package/dist/client/index.html +4 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/internal/devServer.d.ts.map +1 -1
- package/dist/internal/devServer.js +4 -64
- package/dist/internal/devServer.js.map +1 -1
- package/dist/internal/evaluationWorker.d.ts.map +1 -1
- package/dist/internal/evaluationWorker.js +7 -263
- package/dist/internal/evaluationWorker.js.map +1 -1
- package/dist/internal/machineDocument.d.ts.map +1 -1
- package/dist/internal/machineDocument.js +3 -1
- package/dist/internal/machineDocument.js.map +1 -1
- package/dist/internal/machineWalkthrough.d.ts +26 -0
- package/dist/internal/machineWalkthrough.d.ts.map +1 -0
- package/dist/internal/machineWalkthrough.js +256 -0
- package/dist/internal/machineWalkthrough.js.map +1 -0
- package/dist/internal/projectInspector.d.ts.map +1 -1
- package/dist/internal/projectInspector.js +1 -11
- package/dist/internal/projectInspector.js.map +1 -1
- package/index.html +2 -2
- package/package.json +8 -7
- package/src/DevToolsProtocol.ts +0 -285
- package/src/MachineDocument.ts +21 -19
- package/src/MachineWalkthrough.ts +199 -0
- package/src/ProjectInspector.ts +0 -5
- package/src/index.ts +2 -2
- package/src/internal/browser/chart-layout-policy.ts +206 -0
- package/src/internal/browser/chart-layout.ts +686 -0
- package/src/internal/browser/chart-model.ts +244 -0
- package/src/internal/browser/chart-renderer.ts +774 -0
- package/src/internal/browser/example-machine.ts +15 -6
- package/src/internal/browser/input-form.ts +1 -418
- package/src/internal/browser/invoke-outcomes-example.ts +231 -0
- package/src/internal/browser/parallel-completion-example.ts +199 -0
- package/src/internal/browser/planner-example.ts +2 -0
- package/src/internal/browser/protocol-events-example.ts +200 -0
- package/src/internal/browser/styles.css +974 -342
- package/src/internal/browser/transition-semantics-example.ts +245 -0
- package/src/internal/browser/visualizer-analysis.ts +52 -0
- package/src/internal/browser/visualizer-app.ts +874 -706
- package/src/internal/browser/visualizer-model.ts +104 -0
- package/src/internal/devServer.ts +4 -82
- package/src/internal/evaluationWorker.ts +7 -371
- package/src/internal/machineDocument.ts +3 -1
- package/src/internal/machineWalkthrough.ts +355 -0
- package/src/internal/projectInspector.ts +3 -31
- package/dist/MachineSimulator.d.ts +0 -169
- package/dist/MachineSimulator.d.ts.map +0 -1
- package/dist/MachineSimulator.js +0 -98
- package/dist/MachineSimulator.js.map +0 -1
- package/dist/client/assets/index-B49Tjawc.js +0 -14
- package/dist/client/assets/index-BKH0cOG2.css +0 -1
- package/dist/internal/machineSimulator.d.ts +0 -5
- package/dist/internal/machineSimulator.d.ts.map +0 -1
- package/dist/internal/machineSimulator.js +0 -156
- package/dist/internal/machineSimulator.js.map +0 -1
- package/src/MachineSimulator.ts +0 -154
- package/src/internal/browser/simulation-client.ts +0 -20
- package/src/internal/machineSimulator.ts +0 -199
package/src/DevToolsProtocol.ts
CHANGED
|
@@ -144,288 +144,3 @@ export const RegistrySnapshot = Schema.Struct({
|
|
|
144
144
|
* @since 0.23.0
|
|
145
145
|
*/
|
|
146
146
|
export type RegistrySnapshot = Schema.Schema.Type<typeof RegistrySnapshot>
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* JSON-safe representation of a persisted machine snapshot.
|
|
150
|
-
*
|
|
151
|
-
* @category schemas
|
|
152
|
-
* @since 0.24.0
|
|
153
|
-
*/
|
|
154
|
-
export const EncodedSnapshot = Schema.Struct({
|
|
155
|
-
_tag: Schema.Literal("MachineSnapshot"),
|
|
156
|
-
active: Schema.Array(Schema.Struct({
|
|
157
|
-
path: Schema.String,
|
|
158
|
-
value: Schema.optionalKey(Schema.Json)
|
|
159
|
-
})),
|
|
160
|
-
completed: Schema.optionalKey(Schema.Array(Schema.Struct({
|
|
161
|
-
path: Schema.String,
|
|
162
|
-
output: Schema.optionalKey(Schema.Json)
|
|
163
|
-
}))),
|
|
164
|
-
history: Schema.optionalKey(Schema.Record(
|
|
165
|
-
Schema.String,
|
|
166
|
-
Schema.Struct({
|
|
167
|
-
mode: Schema.Literals(["shallow", "deep"]),
|
|
168
|
-
active: Schema.Array(Schema.String),
|
|
169
|
-
values: Schema.Record(Schema.String, Schema.Json)
|
|
170
|
-
})
|
|
171
|
-
))
|
|
172
|
-
})
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* @category models
|
|
176
|
-
* @since 0.24.0
|
|
177
|
-
*/
|
|
178
|
-
export type EncodedSnapshot = Schema.Schema.Type<typeof EncodedSnapshot>
|
|
179
|
-
|
|
180
|
-
const SimulationRequestFields = {
|
|
181
|
-
protocolVersion: Schema.Literal(protocolVersion),
|
|
182
|
-
key: Schema.String,
|
|
183
|
-
revision: Schema.Natural,
|
|
184
|
-
source: MachineDocument.Source
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Starts an isolated planner session. Omitting `input` calls a machine that
|
|
189
|
-
* declares no input; otherwise the JSON value is decoded by its input schema.
|
|
190
|
-
*
|
|
191
|
-
* @category schemas
|
|
192
|
-
* @since 0.24.0
|
|
193
|
-
*/
|
|
194
|
-
export const StartSimulation = Schema.Struct({
|
|
195
|
-
...SimulationRequestFields,
|
|
196
|
-
_tag: Schema.tag("StartSimulation"),
|
|
197
|
-
input: Schema.optionalKey(Schema.Json)
|
|
198
|
-
})
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* @category models
|
|
202
|
-
* @since 0.24.0
|
|
203
|
-
*/
|
|
204
|
-
export type StartSimulation = Schema.Schema.Type<typeof StartSimulation>
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Plans one JSON event from an encoded session snapshot.
|
|
208
|
-
*
|
|
209
|
-
* @category schemas
|
|
210
|
-
* @since 0.24.0
|
|
211
|
-
*/
|
|
212
|
-
export const SendSimulationEvent = Schema.Struct({
|
|
213
|
-
...SimulationRequestFields,
|
|
214
|
-
_tag: Schema.tag("SendSimulationEvent"),
|
|
215
|
-
step: Schema.Natural,
|
|
216
|
-
snapshot: EncodedSnapshot,
|
|
217
|
-
event: Schema.Json
|
|
218
|
-
})
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* @category models
|
|
222
|
-
* @since 0.24.0
|
|
223
|
-
*/
|
|
224
|
-
export type SendSimulationEvent = Schema.Schema.Type<typeof SendSimulationEvent>
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Request accepted by the isolated machine planner.
|
|
228
|
-
*
|
|
229
|
-
* @category schemas
|
|
230
|
-
* @since 0.24.0
|
|
231
|
-
*/
|
|
232
|
-
export const SimulationRequest = Schema.Union([StartSimulation, SendSimulationEvent])
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* @category models
|
|
236
|
-
* @since 0.24.0
|
|
237
|
-
*/
|
|
238
|
-
export type SimulationRequest = Schema.Schema.Type<typeof SimulationRequest>
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* A compact view of one logical machine snapshot.
|
|
242
|
-
*
|
|
243
|
-
* @category schemas
|
|
244
|
-
* @since 0.24.0
|
|
245
|
-
*/
|
|
246
|
-
export const SimulationSnapshot = Schema.Struct({
|
|
247
|
-
activePaths: Schema.Array(Schema.String),
|
|
248
|
-
candidateEvents: Schema.Array(Schema.String)
|
|
249
|
-
})
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* @category models
|
|
253
|
-
* @since 0.24.0
|
|
254
|
-
*/
|
|
255
|
-
export type SimulationSnapshot = Schema.Schema.Type<typeof SimulationSnapshot>
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* Transition selected by the planner after hierarchy and conflict resolution.
|
|
259
|
-
*
|
|
260
|
-
* @category schemas
|
|
261
|
-
* @since 0.24.0
|
|
262
|
-
*/
|
|
263
|
-
export const PlannedTransition = Schema.Struct({
|
|
264
|
-
source: Schema.String,
|
|
265
|
-
trigger: MachineDocument.Trigger,
|
|
266
|
-
reenter: Schema.Boolean,
|
|
267
|
-
branchIndex: Schema.Natural,
|
|
268
|
-
branchKey: Schema.NullOr(Schema.String),
|
|
269
|
-
target: Schema.NullOr(Schema.String),
|
|
270
|
-
resolvedTarget: Schema.NullOr(Schema.String),
|
|
271
|
-
updates: Schema.Array(Schema.String)
|
|
272
|
-
})
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* @category models
|
|
276
|
-
* @since 0.24.0
|
|
277
|
-
*/
|
|
278
|
-
export type PlannedTransition = Schema.Schema.Type<typeof PlannedTransition>
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* Closed command produced by planning. Commands are displayed but never
|
|
282
|
-
* committed by the visualizer.
|
|
283
|
-
*
|
|
284
|
-
* @category schemas
|
|
285
|
-
* @since 0.24.0
|
|
286
|
-
*/
|
|
287
|
-
export const PlannedCommand = Schema.Union([
|
|
288
|
-
Schema.Struct({
|
|
289
|
-
_tag: Schema.tag("SendTo"),
|
|
290
|
-
target: Schema.String,
|
|
291
|
-
event: Schema.Json
|
|
292
|
-
}),
|
|
293
|
-
Schema.Struct({
|
|
294
|
-
_tag: Schema.tag("Stop"),
|
|
295
|
-
target: Schema.String
|
|
296
|
-
})
|
|
297
|
-
])
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* @category models
|
|
301
|
-
* @since 0.24.0
|
|
302
|
-
*/
|
|
303
|
-
export type PlannedCommand = Schema.Schema.Type<typeof PlannedCommand>
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* One statechart microstep retained in a planned macrostep.
|
|
307
|
-
*
|
|
308
|
-
* @category schemas
|
|
309
|
-
* @since 0.24.0
|
|
310
|
-
*/
|
|
311
|
-
export const SimulationMicrostep = Schema.Struct({
|
|
312
|
-
index: Schema.Natural,
|
|
313
|
-
event: Schema.Json,
|
|
314
|
-
transitions: Schema.Array(PlannedTransition),
|
|
315
|
-
raisedEvents: Schema.Array(Schema.Json),
|
|
316
|
-
emittedEvents: Schema.Array(Schema.Json),
|
|
317
|
-
commands: Schema.Array(PlannedCommand),
|
|
318
|
-
exitPaths: Schema.Array(Schema.String),
|
|
319
|
-
entryPaths: Schema.Array(Schema.String),
|
|
320
|
-
activePaths: Schema.Array(Schema.String),
|
|
321
|
-
changed: Schema.Boolean
|
|
322
|
-
})
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* @category models
|
|
326
|
-
* @since 0.24.0
|
|
327
|
-
*/
|
|
328
|
-
export type SimulationMicrostep = Schema.Schema.Type<typeof SimulationMicrostep>
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* Structured trace for an initial plan or one received event.
|
|
332
|
-
*
|
|
333
|
-
* @category schemas
|
|
334
|
-
* @since 0.24.0
|
|
335
|
-
*/
|
|
336
|
-
export const SimulationFrame = Schema.Struct({
|
|
337
|
-
step: Schema.Natural,
|
|
338
|
-
trigger: Schema.Union([
|
|
339
|
-
Schema.Struct({ _tag: Schema.tag("Initial"), input: Schema.optionalKey(Schema.Json) }),
|
|
340
|
-
Schema.Struct({ _tag: Schema.tag("Event"), event: Schema.Json })
|
|
341
|
-
]),
|
|
342
|
-
before: SimulationSnapshot,
|
|
343
|
-
after: SimulationSnapshot,
|
|
344
|
-
microsteps: Schema.Array(SimulationMicrostep),
|
|
345
|
-
commands: Schema.Array(PlannedCommand),
|
|
346
|
-
emittedEvents: Schema.Array(Schema.Json),
|
|
347
|
-
done: Schema.Boolean,
|
|
348
|
-
output: Schema.optionalKey(Schema.Json)
|
|
349
|
-
})
|
|
350
|
-
|
|
351
|
-
/**
|
|
352
|
-
* @category models
|
|
353
|
-
* @since 0.24.0
|
|
354
|
-
*/
|
|
355
|
-
export type SimulationFrame = Schema.Schema.Type<typeof SimulationFrame>
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* Successful planner response containing the next portable session state.
|
|
359
|
-
*
|
|
360
|
-
* @category schemas
|
|
361
|
-
* @since 0.24.0
|
|
362
|
-
*/
|
|
363
|
-
export const SimulationReady = Schema.Struct({
|
|
364
|
-
protocolVersion: Schema.Literal(protocolVersion),
|
|
365
|
-
_tag: Schema.tag("SimulationReady"),
|
|
366
|
-
key: Schema.String,
|
|
367
|
-
revision: Schema.Natural,
|
|
368
|
-
step: Schema.Natural,
|
|
369
|
-
snapshot: EncodedSnapshot,
|
|
370
|
-
current: SimulationSnapshot,
|
|
371
|
-
frame: SimulationFrame
|
|
372
|
-
})
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* @category models
|
|
376
|
-
* @since 0.24.0
|
|
377
|
-
*/
|
|
378
|
-
export type SimulationReady = Schema.Schema.Type<typeof SimulationReady>
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* One authoritative Effect Schema issue associated with a machine or event
|
|
382
|
-
* input path.
|
|
383
|
-
*
|
|
384
|
-
* @category schemas
|
|
385
|
-
* @since 0.24.0
|
|
386
|
-
*/
|
|
387
|
-
export const InputIssue = Schema.Struct({
|
|
388
|
-
path: Schema.Array(Schema.Union([Schema.String, Schema.Number])),
|
|
389
|
-
message: Schema.String
|
|
390
|
-
})
|
|
391
|
-
|
|
392
|
-
/**
|
|
393
|
-
* @category models
|
|
394
|
-
* @since 0.24.0
|
|
395
|
-
*/
|
|
396
|
-
export type InputIssue = Schema.Schema.Type<typeof InputIssue>
|
|
397
|
-
|
|
398
|
-
/**
|
|
399
|
-
* Recoverable failure produced while loading, decoding, or planning a session.
|
|
400
|
-
*
|
|
401
|
-
* @category schemas
|
|
402
|
-
* @since 0.24.0
|
|
403
|
-
*/
|
|
404
|
-
export const SimulationFailed = Schema.Struct({
|
|
405
|
-
protocolVersion: Schema.Literal(protocolVersion),
|
|
406
|
-
_tag: Schema.tag("SimulationFailed"),
|
|
407
|
-
key: Schema.String,
|
|
408
|
-
revision: Schema.Natural,
|
|
409
|
-
diagnostics: Schema.Array(Diagnostic),
|
|
410
|
-
inputIssues: Schema.Array(InputIssue)
|
|
411
|
-
})
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* @category models
|
|
415
|
-
* @since 0.24.0
|
|
416
|
-
*/
|
|
417
|
-
export type SimulationFailed = Schema.Schema.Type<typeof SimulationFailed>
|
|
418
|
-
|
|
419
|
-
/**
|
|
420
|
-
* Result returned by the isolated machine planner.
|
|
421
|
-
*
|
|
422
|
-
* @category schemas
|
|
423
|
-
* @since 0.24.0
|
|
424
|
-
*/
|
|
425
|
-
export const SimulationResult = Schema.Union([SimulationReady, SimulationFailed])
|
|
426
|
-
|
|
427
|
-
/**
|
|
428
|
-
* @category models
|
|
429
|
-
* @since 0.24.0
|
|
430
|
-
*/
|
|
431
|
-
export type SimulationResult = Schema.Schema.Type<typeof SimulationResult>
|
package/src/MachineDocument.ts
CHANGED
|
@@ -13,7 +13,7 @@ import * as internal from "./internal/machineDocument.js"
|
|
|
13
13
|
* @category models
|
|
14
14
|
* @since 0.23.0
|
|
15
15
|
*/
|
|
16
|
-
export const schemaVersion =
|
|
16
|
+
export const schemaVersion = 3 as const
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Source module and export that produced a machine.
|
|
@@ -65,6 +65,24 @@ export const Initial = Schema.Struct({
|
|
|
65
65
|
*/
|
|
66
66
|
export type Initial = Schema.Schema.Type<typeof Initial>
|
|
67
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Canonical JSON Schema retained for machine contracts.
|
|
70
|
+
*
|
|
71
|
+
* @category schemas
|
|
72
|
+
* @since 0.24.0
|
|
73
|
+
*/
|
|
74
|
+
export const InputSchema = Schema.Struct({
|
|
75
|
+
dialect: Schema.Literal("draft-2020-12"),
|
|
76
|
+
schema: Schema.Json,
|
|
77
|
+
definitions: Schema.Record(Schema.String, Schema.Json)
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @category models
|
|
82
|
+
* @since 0.24.0
|
|
83
|
+
*/
|
|
84
|
+
export type InputSchema = Schema.Schema.Type<typeof InputSchema>
|
|
85
|
+
|
|
68
86
|
/**
|
|
69
87
|
* @category schemas
|
|
70
88
|
* @since 0.23.0
|
|
@@ -81,6 +99,8 @@ export const State = Schema.Struct({
|
|
|
81
99
|
parent: Schema.NullOr(Schema.String),
|
|
82
100
|
children: Schema.Array(Schema.String),
|
|
83
101
|
initial: Schema.NullOr(Schema.String),
|
|
102
|
+
valueSchema: Schema.NullOr(InputSchema),
|
|
103
|
+
outputSchema: Schema.NullOr(InputSchema),
|
|
84
104
|
transitionIds: Schema.Array(Schema.String),
|
|
85
105
|
activityIds: Schema.Array(Schema.String)
|
|
86
106
|
})
|
|
@@ -216,24 +236,6 @@ export const Snapshot = Schema.Struct({
|
|
|
216
236
|
*/
|
|
217
237
|
export type Snapshot = Schema.Schema.Type<typeof Snapshot>
|
|
218
238
|
|
|
219
|
-
/**
|
|
220
|
-
* Canonical JSON Schema used to render one machine input form.
|
|
221
|
-
*
|
|
222
|
-
* @category schemas
|
|
223
|
-
* @since 0.24.0
|
|
224
|
-
*/
|
|
225
|
-
export const InputSchema = Schema.Struct({
|
|
226
|
-
dialect: Schema.Literal("draft-2020-12"),
|
|
227
|
-
schema: Schema.Json,
|
|
228
|
-
definitions: Schema.Record(Schema.String, Schema.Json)
|
|
229
|
-
})
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* @category models
|
|
233
|
-
* @since 0.24.0
|
|
234
|
-
*/
|
|
235
|
-
export type InputSchema = Schema.Schema.Type<typeof InputSchema>
|
|
236
|
-
|
|
237
239
|
/**
|
|
238
240
|
* Public event input paired with the schema for its payload.
|
|
239
241
|
*
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Side-effect-free topology walkthroughs over machine documents.
|
|
3
|
+
*
|
|
4
|
+
* @since 0.25.0
|
|
5
|
+
*/
|
|
6
|
+
import { dual } from "effect/Function"
|
|
7
|
+
import * as Result from "effect/Result"
|
|
8
|
+
import * as Schema from "effect/Schema"
|
|
9
|
+
import * as internal from "./internal/machineWalkthrough.js"
|
|
10
|
+
import type * as MachineDocument from "./MachineDocument.js"
|
|
11
|
+
|
|
12
|
+
const TypeId = internal.SessionTypeId
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* An immutable walkthrough session. Its timeline can be inspected and its
|
|
16
|
+
* cursor can move without evaluating machine callbacks.
|
|
17
|
+
*
|
|
18
|
+
* @category models
|
|
19
|
+
* @since 0.25.0
|
|
20
|
+
*/
|
|
21
|
+
export interface Session {
|
|
22
|
+
readonly [TypeId]: typeof TypeId
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Why taking a documented branch requires an explicit human decision.
|
|
27
|
+
*
|
|
28
|
+
* @category models
|
|
29
|
+
* @since 0.25.0
|
|
30
|
+
*/
|
|
31
|
+
export type Decision =
|
|
32
|
+
| "conditional-branch"
|
|
33
|
+
| "declinable-transition"
|
|
34
|
+
| "automatic-trigger"
|
|
35
|
+
| "invoke-outcome"
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Why a documented branch cannot advance topology without runtime data.
|
|
39
|
+
*
|
|
40
|
+
* @category models
|
|
41
|
+
* @since 0.25.0
|
|
42
|
+
*/
|
|
43
|
+
export type UnavailableReason = "history-unavailable" | "runtime-target"
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* One branch that can be explored from the current active configuration.
|
|
47
|
+
*
|
|
48
|
+
* @category models
|
|
49
|
+
* @since 0.25.0
|
|
50
|
+
*/
|
|
51
|
+
export interface Choice {
|
|
52
|
+
readonly id: string
|
|
53
|
+
readonly transitionId: string
|
|
54
|
+
readonly branchId: string
|
|
55
|
+
readonly branchIndex: number
|
|
56
|
+
readonly branchKey: string | null
|
|
57
|
+
readonly title: string | null
|
|
58
|
+
readonly source: string
|
|
59
|
+
readonly trigger: MachineDocument.Trigger
|
|
60
|
+
readonly target: string | null
|
|
61
|
+
readonly selection: MachineDocument.Selection
|
|
62
|
+
readonly updates: ReadonlyArray<string>
|
|
63
|
+
readonly decisions: ReadonlyArray<Decision>
|
|
64
|
+
readonly unavailableReason: UnavailableReason | null
|
|
65
|
+
readonly input: MachineDocument.InputSchema | null
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The active state paths at one point in a walkthrough.
|
|
70
|
+
*
|
|
71
|
+
* @category models
|
|
72
|
+
* @since 0.25.0
|
|
73
|
+
*/
|
|
74
|
+
export interface Snapshot {
|
|
75
|
+
readonly activePaths: ReadonlyArray<string>
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* One initial or manually selected topology step.
|
|
80
|
+
*
|
|
81
|
+
* @category models
|
|
82
|
+
* @since 0.25.0
|
|
83
|
+
*/
|
|
84
|
+
export interface Frame {
|
|
85
|
+
readonly step: number
|
|
86
|
+
readonly choice: Choice | null
|
|
87
|
+
readonly before: Snapshot
|
|
88
|
+
readonly after: Snapshot
|
|
89
|
+
readonly exitPaths: ReadonlyArray<string>
|
|
90
|
+
readonly entryPaths: ReadonlyArray<string>
|
|
91
|
+
readonly changed: boolean
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* A requested choice is not available from the cursor's configuration.
|
|
96
|
+
*
|
|
97
|
+
* @category errors
|
|
98
|
+
* @since 0.25.0
|
|
99
|
+
*/
|
|
100
|
+
export class ChoiceNotFound extends Schema.Error<ChoiceNotFound>(
|
|
101
|
+
"@typeonce/effect-machine-devtools/MachineWalkthrough/ChoiceNotFound"
|
|
102
|
+
)({
|
|
103
|
+
_tag: Schema.tag("ChoiceNotFound"),
|
|
104
|
+
choiceId: Schema.String
|
|
105
|
+
}) {}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* A choice depends on runtime information absent from the machine document.
|
|
109
|
+
*
|
|
110
|
+
* @category errors
|
|
111
|
+
* @since 0.25.0
|
|
112
|
+
*/
|
|
113
|
+
export class ChoiceUnavailable extends Schema.Error<ChoiceUnavailable>(
|
|
114
|
+
"@typeonce/effect-machine-devtools/MachineWalkthrough/ChoiceUnavailable"
|
|
115
|
+
)({
|
|
116
|
+
_tag: Schema.tag("ChoiceUnavailable"),
|
|
117
|
+
choiceId: Schema.String,
|
|
118
|
+
reason: Schema.Literals(["history-unavailable", "runtime-target"])
|
|
119
|
+
}) {}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* A requested timeline step does not exist.
|
|
123
|
+
*
|
|
124
|
+
* @category errors
|
|
125
|
+
* @since 0.25.0
|
|
126
|
+
*/
|
|
127
|
+
export class StepNotFound extends Schema.Error<StepNotFound>(
|
|
128
|
+
"@typeonce/effect-machine-devtools/MachineWalkthrough/StepNotFound"
|
|
129
|
+
)({
|
|
130
|
+
_tag: Schema.tag("StepNotFound"),
|
|
131
|
+
step: Schema.Number
|
|
132
|
+
}) {}
|
|
133
|
+
|
|
134
|
+
const api = { ChoiceNotFound, ChoiceUnavailable, StepNotFound }
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Starts at the document's captured snapshot when present, otherwise at its
|
|
138
|
+
* statically declared initial configuration.
|
|
139
|
+
*
|
|
140
|
+
* @category constructors
|
|
141
|
+
* @since 0.25.0
|
|
142
|
+
*/
|
|
143
|
+
export const start: (document: MachineDocument.MachineDocument) => Session = internal.start
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Returns the frame selected by the session cursor.
|
|
147
|
+
*
|
|
148
|
+
* @category getters
|
|
149
|
+
* @since 0.25.0
|
|
150
|
+
*/
|
|
151
|
+
export const current: (self: Session) => Frame = internal.current
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Returns every retained frame, including frames after the current cursor.
|
|
155
|
+
*
|
|
156
|
+
* @category getters
|
|
157
|
+
* @since 0.25.0
|
|
158
|
+
*/
|
|
159
|
+
export const timeline: (self: Session) => ReadonlyArray<Frame> = internal.timeline
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Returns the current zero-based timeline position.
|
|
163
|
+
*
|
|
164
|
+
* @category getters
|
|
165
|
+
* @since 0.25.0
|
|
166
|
+
*/
|
|
167
|
+
export const cursor: (self: Session) => number = internal.cursor
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Lists documented branches whose sources are active at the current cursor.
|
|
171
|
+
* Runtime-dependent choices remain visible with an unavailable reason.
|
|
172
|
+
*
|
|
173
|
+
* @category getters
|
|
174
|
+
* @since 0.25.0
|
|
175
|
+
*/
|
|
176
|
+
export const choices: (self: Session) => ReadonlyArray<Choice> = internal.choices
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Takes one documented branch. Taking a branch from the past truncates the
|
|
180
|
+
* future timeline before appending the new frame.
|
|
181
|
+
*
|
|
182
|
+
* @category combinators
|
|
183
|
+
* @since 0.25.0
|
|
184
|
+
*/
|
|
185
|
+
export const take: {
|
|
186
|
+
(choiceId: string): (self: Session) => Result.Result<Session, ChoiceNotFound | ChoiceUnavailable>
|
|
187
|
+
(self: Session, choiceId: string): Result.Result<Session, ChoiceNotFound | ChoiceUnavailable>
|
|
188
|
+
} = dual(2, internal.take(api))
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Moves the cursor to an existing frame without changing the timeline.
|
|
192
|
+
*
|
|
193
|
+
* @category combinators
|
|
194
|
+
* @since 0.25.0
|
|
195
|
+
*/
|
|
196
|
+
export const seek: {
|
|
197
|
+
(step: number): (self: Session) => Result.Result<Session, StepNotFound>
|
|
198
|
+
(self: Session, step: number): Result.Result<Session, StepNotFound>
|
|
199
|
+
} = dual(2, internal.seek(api))
|
package/src/ProjectInspector.ts
CHANGED
|
@@ -92,11 +92,6 @@ export class ProjectInspector extends Context.Service<ProjectInspector, {
|
|
|
92
92
|
readonly inspect: (
|
|
93
93
|
options: InspectOptions
|
|
94
94
|
) => Effect.Effect<ReadonlyArray<DevToolsProtocol.MachineResult>, DiscoveryError | EvaluationError>
|
|
95
|
-
/** @internal */
|
|
96
|
-
readonly simulate: (
|
|
97
|
-
request: DevToolsProtocol.SimulationRequest,
|
|
98
|
-
options: Pick<InspectOptions, "root">
|
|
99
|
-
) => Effect.Effect<DevToolsProtocol.SimulationResult, EvaluationError>
|
|
100
95
|
}>()("@typeonce/effect-machine-devtools/ProjectInspector") {}
|
|
101
96
|
|
|
102
97
|
/**
|
package/src/index.ts
CHANGED
|
@@ -15,6 +15,6 @@ export * as DevToolsProtocol from "./DevToolsProtocol.js"
|
|
|
15
15
|
export * as MachineDocument from "./MachineDocument.js"
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* @since 0.
|
|
18
|
+
* @since 0.25.0
|
|
19
19
|
*/
|
|
20
|
-
export * as
|
|
20
|
+
export * as MachineWalkthrough from "./MachineWalkthrough.js"
|