@typeonce/effect-machine 0.15.0 → 0.16.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 +31 -3
- package/dist/Machine.d.ts +258 -88
- package/dist/Machine.d.ts.map +1 -1
- package/dist/Machine.js +33 -33
- package/dist/Machine.js.map +1 -1
- package/dist/internal/machine/activities.d.ts +2 -0
- package/dist/internal/machine/activities.d.ts.map +1 -1
- package/dist/internal/machine/activities.js +4 -0
- package/dist/internal/machine/activities.js.map +1 -1
- package/dist/internal/machine/executionPlan.d.ts.map +1 -1
- package/dist/internal/machine/executionPlan.js +6 -1
- package/dist/internal/machine/executionPlan.js.map +1 -1
- package/dist/internal/machine/invocation.d.ts +1 -1
- package/dist/internal/machine/invocation.d.ts.map +1 -1
- package/dist/internal/machine/invocation.js +25 -3
- package/dist/internal/machine/invocation.js.map +1 -1
- package/dist/internal/machine/invocationEvent.d.ts +8 -0
- package/dist/internal/machine/invocationEvent.d.ts.map +1 -1
- package/dist/internal/machine/invocationEvent.js +8 -0
- package/dist/internal/machine/invocationEvent.js.map +1 -1
- package/dist/internal/machine/machine.d.ts.map +1 -1
- package/dist/internal/machine/machine.js +119 -48
- package/dist/internal/machine/machine.js.map +1 -1
- package/dist/internal/machine/planner.d.ts +7 -0
- package/dist/internal/machine/planner.d.ts.map +1 -1
- package/dist/internal/machine/planner.js +20 -11
- package/dist/internal/machine/planner.js.map +1 -1
- package/dist/internal/machine/runtime.d.ts +1 -0
- package/dist/internal/machine/runtime.d.ts.map +1 -1
- package/dist/internal/machine/runtime.js +25 -16
- package/dist/internal/machine/runtime.js.map +1 -1
- package/dist/internal/machine/topology.d.ts +11 -0
- package/dist/internal/machine/topology.d.ts.map +1 -1
- package/dist/internal/machine/topology.js +17 -6
- package/dist/internal/machine/topology.js.map +1 -1
- package/dist/internal/testing/machine/transitionCoverage.d.ts.map +1 -1
- package/dist/internal/testing/machine/transitionCoverage.js +6 -2
- package/dist/internal/testing/machine/transitionCoverage.js.map +1 -1
- package/dist/internal/testing/machine/verification.d.ts.map +1 -1
- package/dist/internal/testing/machine/verification.js +6 -0
- package/dist/internal/testing/machine/verification.js.map +1 -1
- package/dist/testing/MachineTest.d.ts +2 -1
- package/dist/testing/MachineTest.d.ts.map +1 -1
- package/dist/testing/MachineTest.js.map +1 -1
- package/docs/agent-guide.md +63 -37
- package/package.json +1 -1
- package/src/Machine.ts +592 -159
- package/src/internal/machine/activities.ts +7 -0
- package/src/internal/machine/executionPlan.ts +6 -1
- package/src/internal/machine/invocation.ts +39 -4
- package/src/internal/machine/invocationEvent.ts +16 -0
- package/src/internal/machine/machine.ts +160 -47
- package/src/internal/machine/planner.ts +17 -3
- package/src/internal/machine/runtime.ts +61 -25
- package/src/internal/machine/topology.ts +31 -2
- package/src/internal/testing/machine/transitionCoverage.ts +6 -2
- package/src/internal/testing/machine/verification.ts +11 -0
- package/src/testing/MachineTest.ts +2 -0
package/src/Machine.ts
CHANGED
|
@@ -53,7 +53,6 @@ declare const MachineTypeId: unique symbol
|
|
|
53
53
|
declare const EventConstructionTypeId: unique symbol
|
|
54
54
|
declare const EmittedEventConstructionTypeId: unique symbol
|
|
55
55
|
declare const EventProtocolTypeId: unique symbol
|
|
56
|
-
declare const TransitionCaseTypeId: unique symbol
|
|
57
56
|
|
|
58
57
|
const ChildMachineLogicTypeId: typeof internal.ChildMachineLogicTypeId = internal.ChildMachineLogicTypeId
|
|
59
58
|
|
|
@@ -1953,10 +1952,10 @@ export declare namespace Inspection {
|
|
|
1953
1952
|
readonly sessionId: string
|
|
1954
1953
|
readonly owner: Subject
|
|
1955
1954
|
readonly ownerPath: string
|
|
1956
|
-
readonly kind: "Effect" | "Timer"
|
|
1955
|
+
readonly kind: "Effect" | "Stream" | "Timer"
|
|
1957
1956
|
}
|
|
1958
1957
|
|
|
1959
|
-
/** Announces an Effect or timer invocation starting. */
|
|
1958
|
+
/** Announces an Effect, Stream, or timer invocation starting. */
|
|
1960
1959
|
export interface ActivityStarted extends Base {
|
|
1961
1960
|
readonly _tag: "ActivityStarted"
|
|
1962
1961
|
readonly activity: Activity
|
|
@@ -3252,7 +3251,7 @@ export declare namespace Machine {
|
|
|
3252
3251
|
| {
|
|
3253
3252
|
readonly type: "invoke"
|
|
3254
3253
|
readonly id: string
|
|
3255
|
-
readonly outcome: "done" | "failure" | "snapshot"
|
|
3254
|
+
readonly outcome: "element" | "done" | "failure" | "snapshot"
|
|
3256
3255
|
}
|
|
3257
3256
|
|
|
3258
3257
|
/** Static topology selected by a transition branch. */
|
|
@@ -3274,16 +3273,12 @@ export declare namespace Machine {
|
|
|
3274
3273
|
readonly selection: TransitionTargetSelection<Path | undefined>
|
|
3275
3274
|
}
|
|
3276
3275
|
| {
|
|
3277
|
-
readonly type: "
|
|
3276
|
+
readonly type: "branch"
|
|
3277
|
+
readonly key: string
|
|
3278
3278
|
readonly title: string
|
|
3279
3279
|
readonly target: Path | undefined
|
|
3280
3280
|
readonly selection: TransitionTargetSelection<Path | undefined>
|
|
3281
3281
|
}
|
|
3282
|
-
| {
|
|
3283
|
-
readonly type: "otherwise"
|
|
3284
|
-
readonly target: Path | undefined
|
|
3285
|
-
readonly selection: TransitionTargetSelection<Path | undefined>
|
|
3286
|
-
}
|
|
3287
3282
|
|
|
3288
3283
|
/** The statically selected root entry for machine startup. */
|
|
3289
3284
|
export interface InitialDefinition<Path extends string = string> {
|
|
@@ -3296,8 +3291,8 @@ export declare namespace Machine {
|
|
|
3296
3291
|
*
|
|
3297
3292
|
* **Details**
|
|
3298
3293
|
*
|
|
3299
|
-
* Every branch exposes its selected target without executing its
|
|
3300
|
-
*
|
|
3294
|
+
* Every branch exposes its selected target without executing its resolver.
|
|
3295
|
+
* A compound local or branch target covers its descendants;
|
|
3301
3296
|
* `undefined` identifies an explicitly targetless branch.
|
|
3302
3297
|
*
|
|
3303
3298
|
* @category models
|
|
@@ -3343,6 +3338,8 @@ export declare namespace Machine {
|
|
|
3343
3338
|
readonly reenter: boolean
|
|
3344
3339
|
/** Zero-based index of the selected static branch. */
|
|
3345
3340
|
readonly branchIndex: number
|
|
3341
|
+
/** Stable key of a named branch, or `undefined` for a direct transition. */
|
|
3342
|
+
readonly branchKey: string | undefined
|
|
3346
3343
|
/** Path returned by the handler, including a choice or history pseudo-state. */
|
|
3347
3344
|
readonly target: TargetPath | undefined
|
|
3348
3345
|
/**
|
|
@@ -4651,6 +4648,25 @@ export declare namespace Machine {
|
|
|
4651
4648
|
readonly output: Output
|
|
4652
4649
|
}
|
|
4653
4650
|
|
|
4651
|
+
/** Context passed to a Stream invocation's element transition. */
|
|
4652
|
+
export interface InvokeElementContext<
|
|
4653
|
+
States extends StateSchemas,
|
|
4654
|
+
Events extends ReadonlyArray<TaggedSchema>,
|
|
4655
|
+
Emits extends ReadonlyArray<TaggedSchema>,
|
|
4656
|
+
StateId extends StateIdentifier<States>,
|
|
4657
|
+
Element,
|
|
4658
|
+
InputEvents extends ReadonlyArray<TaggedSchema> = Events,
|
|
4659
|
+
ParentEvents extends ReadonlyArray<TaggedSchema> = readonly []
|
|
4660
|
+
> extends MachineReferences<InputEvents, ParentEvents> {
|
|
4661
|
+
readonly id: string
|
|
4662
|
+
readonly state: StateByIdentifier<States, StateId>
|
|
4663
|
+
readonly containingState: ParentStateValue<States, StateId>
|
|
4664
|
+
readonly ancestors: ParentStateValues<States, StateId>
|
|
4665
|
+
readonly snapshot: Snapshot<States>
|
|
4666
|
+
readonly target: TargetBuilder<States, StateId>
|
|
4667
|
+
readonly element: Element
|
|
4668
|
+
}
|
|
4669
|
+
|
|
4654
4670
|
/** Context passed to an invocation typed-failure transition. */
|
|
4655
4671
|
export interface InvokeFailureContext<
|
|
4656
4672
|
States extends StateSchemas,
|
|
@@ -4931,14 +4947,9 @@ export declare namespace Machine {
|
|
|
4931
4947
|
* @category utility types
|
|
4932
4948
|
* @since 0.4.0
|
|
4933
4949
|
*/
|
|
4934
|
-
export type EventTransitionReturn<Transition> =
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
: never)
|
|
4938
|
-
| (Transition extends { readonly cases: infer Cases extends ReadonlyArray<unknown> } ?
|
|
4939
|
-
EventTransitionReturn<Cases[number]>
|
|
4940
|
-
: never)
|
|
4941
|
-
| (Transition extends { readonly otherwise: infer Otherwise } ? EventTransitionReturn<Otherwise> : never)
|
|
4950
|
+
export type EventTransitionReturn<Transition> = Transition extends { readonly resolve?: infer Resolve } ?
|
|
4951
|
+
NonNullable<Resolve> extends (...args: any) => infer Ret ? Ret : never
|
|
4952
|
+
: never
|
|
4942
4953
|
/**
|
|
4943
4954
|
* Extracts the return value from a state's event handlers.
|
|
4944
4955
|
*
|
|
@@ -5003,6 +5014,15 @@ export declare namespace Machine {
|
|
|
5003
5014
|
Effect.Success<Fx>
|
|
5004
5015
|
>
|
|
5005
5016
|
: never
|
|
5017
|
+
: Invoke extends { readonly stream: infer Source } ?
|
|
5018
|
+
InvokeFactoryResult<Source> extends infer SourceStream extends Stream.Stream<any, any, any> ? Logic<
|
|
5019
|
+
void,
|
|
5020
|
+
never,
|
|
5021
|
+
Stream.Error<SourceStream>,
|
|
5022
|
+
Stream.Services<SourceStream>,
|
|
5023
|
+
void
|
|
5024
|
+
>
|
|
5025
|
+
: never
|
|
5006
5026
|
: Invoke extends { readonly after: unknown } ? Logic<void, never, never, never, void>
|
|
5007
5027
|
: Invoke extends { readonly logic: infer Source } ? InvokeResolvedSource<Source>
|
|
5008
5028
|
: Invoke extends { readonly child: infer Child } ? ChildMachineLogic<Child>
|
|
@@ -5074,6 +5094,7 @@ export declare namespace Machine {
|
|
|
5074
5094
|
export type InvokeOutcomeReturn<Invoke> = Invoke extends unknown ?
|
|
5075
5095
|
| (Invoke extends { readonly onDone?: infer Handler } ? EventTransitionReturn<NonNullable<Handler>> : never)
|
|
5076
5096
|
| (Invoke extends { readonly onFailure?: infer Handler } ? EventTransitionReturn<NonNullable<Handler>> : never)
|
|
5097
|
+
| (Invoke extends { readonly onElement?: infer Handler } ? EventTransitionReturn<NonNullable<Handler>> : never)
|
|
5077
5098
|
| (Invoke extends { readonly onSnapshot?: infer Handler } ? EventTransitionReturn<NonNullable<Handler>> : never)
|
|
5078
5099
|
: never
|
|
5079
5100
|
/**
|
|
@@ -5144,8 +5165,6 @@ export declare namespace Machine {
|
|
|
5144
5165
|
| Effect.Services<ChoiceReturn<Config>>
|
|
5145
5166
|
| InvokeRequirements<Config>
|
|
5146
5167
|
|
|
5147
|
-
type TransitionWhenContext<Context> = Omit<Context, "target">
|
|
5148
|
-
|
|
5149
5168
|
/** Type evidence retained by {@link transition} without affecting runtime data. */
|
|
5150
5169
|
export interface TransitionTyped<
|
|
5151
5170
|
States extends StateSchemas,
|
|
@@ -5176,11 +5195,40 @@ export declare namespace Machine {
|
|
|
5176
5195
|
Context,
|
|
5177
5196
|
Reenter extends boolean = false
|
|
5178
5197
|
> =
|
|
5179
|
-
& (
|
|
5198
|
+
& (
|
|
5199
|
+
| TransitionTyped<States, Events, Emits, StateId, Context, Reenter>
|
|
5200
|
+
| TargetlessTransitionTyped
|
|
5201
|
+
| TargetlessTransitionInput<Events, Emits, Context>
|
|
5202
|
+
)
|
|
5180
5203
|
& {
|
|
5181
5204
|
readonly reenter?: [Reenter] extends [true] ? boolean : never
|
|
5182
5205
|
}
|
|
5183
5206
|
|
|
5207
|
+
/** Direct shorthand for a non-reentering targetless transition. */
|
|
5208
|
+
// Keep the context generic so omitting `target` is deferred until a resolver
|
|
5209
|
+
// is actually authored instead of expanding every TransitionConfig eagerly.
|
|
5210
|
+
interface TargetlessTransitionResolver<
|
|
5211
|
+
Events extends ReadonlyArray<TaggedSchema>,
|
|
5212
|
+
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5213
|
+
Context
|
|
5214
|
+
> {
|
|
5215
|
+
<ResolvedContext extends Omit<Context, "target">>(
|
|
5216
|
+
context: ResolvedContext,
|
|
5217
|
+
enqueue: Enqueue<EventOf<Events>, EmitOf<Emits>>
|
|
5218
|
+
): undefined
|
|
5219
|
+
}
|
|
5220
|
+
|
|
5221
|
+
export type TargetlessTransitionInput<
|
|
5222
|
+
Events extends ReadonlyArray<TaggedSchema>,
|
|
5223
|
+
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5224
|
+
Context
|
|
5225
|
+
> = {
|
|
5226
|
+
readonly target: TargetlessSelector
|
|
5227
|
+
readonly resolve?: TargetlessTransitionResolver<Events, Emits, Context>
|
|
5228
|
+
readonly branches?: never
|
|
5229
|
+
readonly reenter?: never
|
|
5230
|
+
}
|
|
5231
|
+
|
|
5184
5232
|
export type SelectionBuilder<Selection> = Selection extends TargetSelection<infer Builder, any, any> ? Builder : never
|
|
5185
5233
|
export type SelectionKind<Selection> = Selection extends TargetSelection<any, any, infer Kind> ? Kind : never
|
|
5186
5234
|
export type SelectionPath<Selection> = Selection extends TargetSelection<any, infer Path, any> ? Path : never
|
|
@@ -5193,21 +5241,18 @@ export declare namespace Machine {
|
|
|
5193
5241
|
|
|
5194
5242
|
export type TransitionResolveContext<
|
|
5195
5243
|
Context,
|
|
5196
|
-
Selection
|
|
5197
|
-
Match = never
|
|
5244
|
+
Selection
|
|
5198
5245
|
> =
|
|
5199
5246
|
& Omit<Context, "target">
|
|
5200
|
-
& ([Match] extends [never] ? {} : { readonly match: Match })
|
|
5201
5247
|
& (SelectionKind<Selection> extends "none" ? {} : { readonly target: SelectionBuilder<Selection> })
|
|
5202
5248
|
|
|
5203
5249
|
export type TransitionResolver<
|
|
5204
5250
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
5205
5251
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5206
5252
|
Context,
|
|
5207
|
-
Selection
|
|
5208
|
-
Match = never
|
|
5253
|
+
Selection
|
|
5209
5254
|
> = (
|
|
5210
|
-
context: TransitionResolveContext<Context, Selection
|
|
5255
|
+
context: TransitionResolveContext<Context, Selection>,
|
|
5211
5256
|
enqueue: Enqueue<EventOf<Events>, EmitOf<Emits>>
|
|
5212
5257
|
) => SelectionKind<Selection> extends "none" ? undefined : SelectedTargetResult<Selection> | undefined
|
|
5213
5258
|
|
|
@@ -5222,51 +5267,95 @@ export declare namespace Machine {
|
|
|
5222
5267
|
> = {
|
|
5223
5268
|
readonly target: (to: TargetSelector<States, StateId>) => Selection
|
|
5224
5269
|
readonly resolve?: TransitionResolver<Events, Emits, Context, Selection>
|
|
5225
|
-
readonly
|
|
5226
|
-
readonly otherwise?: never
|
|
5270
|
+
readonly branches?: never
|
|
5227
5271
|
readonly reenter?: Reenter
|
|
5228
5272
|
}
|
|
5229
5273
|
|
|
5230
|
-
|
|
5231
|
-
|
|
5274
|
+
/** One named destination declared by a branching transition. */
|
|
5275
|
+
export interface TransitionBranchInput<
|
|
5276
|
+
Selection extends TargetSelection<any, any, any> = TargetSelection<any, any, any>
|
|
5277
|
+
> {
|
|
5278
|
+
readonly target: Selection
|
|
5279
|
+
readonly title?: string
|
|
5280
|
+
}
|
|
5281
|
+
|
|
5282
|
+
/** Opaque evidence that a branching resolver selected one declared branch. */
|
|
5283
|
+
export interface SelectedBranch<out Key extends string, out Result> {
|
|
5284
|
+
readonly [Topology.SelectedBranchTypeId]: {
|
|
5285
|
+
readonly key: Types.Covariant<Key>
|
|
5286
|
+
readonly result: Types.Covariant<Result>
|
|
5287
|
+
}
|
|
5288
|
+
}
|
|
5289
|
+
|
|
5290
|
+
type SelectedBranchCallable<Callable, Key extends string> = Callable extends {
|
|
5291
|
+
(...args: infer Arguments1): infer Result1
|
|
5292
|
+
(...args: infer Arguments2): infer Result2
|
|
5293
|
+
} ? {
|
|
5294
|
+
(...args: Arguments1): SelectedBranch<Key, Result1>
|
|
5295
|
+
(...args: Arguments2): SelectedBranch<Key, Result2>
|
|
5296
|
+
}
|
|
5297
|
+
: Callable extends (...args: infer Arguments) => infer Result ? (...args: Arguments) => SelectedBranch<Key, Result>
|
|
5298
|
+
: {}
|
|
5299
|
+
|
|
5300
|
+
type SelectedBranchBuilderProperties<Builder, Key extends string> = {
|
|
5301
|
+
readonly [Property in keyof Builder]: Builder[Property] extends (...args: any) => any ?
|
|
5302
|
+
SelectedBranchCallable<Builder[Property], Key>
|
|
5303
|
+
: Builder[Property]
|
|
5304
|
+
}
|
|
5305
|
+
|
|
5306
|
+
/** Target-specific builder that brands every construction with its branch key. */
|
|
5307
|
+
export type SelectedBranchBuilder<Builder, Key extends string> =
|
|
5308
|
+
& SelectedBranchCallable<Builder, Key>
|
|
5309
|
+
& SelectedBranchBuilderProperties<Builder, Key>
|
|
5310
|
+
|
|
5311
|
+
export type BranchSelectors<Branches extends Readonly<Record<string, TransitionBranchInput>>> = {
|
|
5312
|
+
readonly [Key in Extract<keyof Branches, string>]: SelectedBranchBuilder<
|
|
5313
|
+
SelectionBuilder<Branches[Key]["target"]>,
|
|
5314
|
+
Key
|
|
5315
|
+
>
|
|
5316
|
+
}
|
|
5317
|
+
|
|
5318
|
+
export type BranchSelectionResult<Branches extends Readonly<Record<string, TransitionBranchInput>>> = {
|
|
5319
|
+
readonly [Key in Extract<keyof Branches, string>]: SelectedBranch<
|
|
5320
|
+
Key,
|
|
5321
|
+
SelectedTargetResult<Branches[Key]["target"]>
|
|
5322
|
+
>
|
|
5323
|
+
}[Extract<keyof Branches, string>]
|
|
5324
|
+
|
|
5325
|
+
export type TransitionBranchesResolveContext<
|
|
5326
|
+
Context,
|
|
5327
|
+
Branches extends Readonly<Record<string, TransitionBranchInput>>
|
|
5328
|
+
> = Omit<Context, "target"> & { readonly select: BranchSelectors<Branches> }
|
|
5329
|
+
|
|
5330
|
+
export type TransitionBranchesResolver<
|
|
5232
5331
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
5233
5332
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5234
|
-
StateId extends StateNodeIdentifier<States>,
|
|
5235
5333
|
Context,
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
readonly target: (to: TargetSelector<States, StateId>) => Selection
|
|
5242
|
-
readonly resolve?: TransitionResolver<Events, Emits, Context, Selection, NoInfer<Match>>
|
|
5243
|
-
readonly cases?: never
|
|
5244
|
-
readonly otherwise?: never
|
|
5245
|
-
readonly reenter?: never
|
|
5246
|
-
}
|
|
5334
|
+
Branches extends Readonly<Record<string, TransitionBranchInput>>
|
|
5335
|
+
> = (
|
|
5336
|
+
context: TransitionBranchesResolveContext<Context, Branches>,
|
|
5337
|
+
enqueue: Enqueue<EventOf<Events>, EmitOf<Emits>>
|
|
5338
|
+
) => BranchSelectionResult<Branches>
|
|
5247
5339
|
|
|
5248
|
-
export type
|
|
5340
|
+
export type TransitionBranchesInput<
|
|
5249
5341
|
States extends StateSchemas,
|
|
5250
5342
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
5251
5343
|
Emits extends ReadonlyArray<TaggedSchema>,
|
|
5252
5344
|
StateId extends StateNodeIdentifier<States>,
|
|
5253
5345
|
Context,
|
|
5254
5346
|
Reenter extends boolean,
|
|
5255
|
-
|
|
5256
|
-
OtherwiseSelection extends TargetSelection<any, any, any>
|
|
5347
|
+
Branches extends Readonly<Record<string, TransitionBranchInput>>
|
|
5257
5348
|
> = {
|
|
5258
5349
|
readonly target?: never
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
|
|
5268
|
-
OtherwiseSelection
|
|
5269
|
-
>
|
|
5350
|
+
/**
|
|
5351
|
+
* Declares every possible destination under a stable semantic key.
|
|
5352
|
+
*
|
|
5353
|
+
* Branches are captured once in ECMAScript property order. Array-index
|
|
5354
|
+
* keys are rejected so reordering ordinary named properties affects only
|
|
5355
|
+
* presentation order; the key remains the testing and inspection identity.
|
|
5356
|
+
*/
|
|
5357
|
+
readonly branches: (to: TargetSelector<States, StateId>) => Branches
|
|
5358
|
+
readonly resolve: TransitionBranchesResolver<Events, Emits, Context, Branches>
|
|
5270
5359
|
readonly reenter?: Reenter
|
|
5271
5360
|
}
|
|
5272
5361
|
|
|
@@ -5317,12 +5406,29 @@ export declare namespace Machine {
|
|
|
5317
5406
|
readonly effect: (
|
|
5318
5407
|
context: InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
5319
5408
|
) => Effect.Effect<any, any, any>
|
|
5409
|
+
readonly stream?: never
|
|
5320
5410
|
readonly after?: never
|
|
5321
5411
|
readonly logic?: never
|
|
5322
5412
|
readonly child?: never
|
|
5323
5413
|
readonly address?: never
|
|
5324
5414
|
readonly onDone?: unknown
|
|
5325
5415
|
readonly onFailure?: unknown
|
|
5416
|
+
readonly onElement?: never
|
|
5417
|
+
readonly onSnapshot?: never
|
|
5418
|
+
}
|
|
5419
|
+
| {
|
|
5420
|
+
readonly id: string
|
|
5421
|
+
readonly stream: (
|
|
5422
|
+
context: InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
5423
|
+
) => Stream.Stream<any, any, any>
|
|
5424
|
+
readonly effect?: never
|
|
5425
|
+
readonly after?: never
|
|
5426
|
+
readonly logic?: never
|
|
5427
|
+
readonly child?: never
|
|
5428
|
+
readonly address?: never
|
|
5429
|
+
readonly onElement?: unknown
|
|
5430
|
+
readonly onDone: unknown
|
|
5431
|
+
readonly onFailure?: unknown
|
|
5326
5432
|
readonly onSnapshot?: never
|
|
5327
5433
|
}
|
|
5328
5434
|
| {
|
|
@@ -5332,11 +5438,13 @@ export declare namespace Machine {
|
|
|
5332
5438
|
InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
5333
5439
|
>
|
|
5334
5440
|
readonly effect?: never
|
|
5441
|
+
readonly stream?: never
|
|
5335
5442
|
readonly logic?: never
|
|
5336
5443
|
readonly child?: never
|
|
5337
5444
|
readonly address?: never
|
|
5338
5445
|
readonly onDone: unknown
|
|
5339
5446
|
readonly onFailure?: never
|
|
5447
|
+
readonly onElement?: never
|
|
5340
5448
|
readonly onSnapshot?: never
|
|
5341
5449
|
}
|
|
5342
5450
|
| {
|
|
@@ -5347,10 +5455,12 @@ export declare namespace Machine {
|
|
|
5347
5455
|
InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
5348
5456
|
>
|
|
5349
5457
|
readonly effect?: never
|
|
5458
|
+
readonly stream?: never
|
|
5350
5459
|
readonly after?: never
|
|
5351
5460
|
readonly child?: never
|
|
5352
5461
|
readonly onDone?: unknown
|
|
5353
5462
|
readonly onFailure?: unknown
|
|
5463
|
+
readonly onElement?: never
|
|
5354
5464
|
readonly onSnapshot?: unknown
|
|
5355
5465
|
}
|
|
5356
5466
|
| {
|
|
@@ -5362,10 +5472,12 @@ export declare namespace Machine {
|
|
|
5362
5472
|
readonly id?: never
|
|
5363
5473
|
readonly address?: never
|
|
5364
5474
|
readonly effect?: never
|
|
5475
|
+
readonly stream?: never
|
|
5365
5476
|
readonly after?: never
|
|
5366
5477
|
readonly logic?: never
|
|
5367
5478
|
readonly onDone?: unknown
|
|
5368
5479
|
readonly onFailure?: unknown
|
|
5480
|
+
readonly onElement?: never
|
|
5369
5481
|
readonly onSnapshot?: unknown
|
|
5370
5482
|
}
|
|
5371
5483
|
)
|
|
@@ -5400,6 +5512,11 @@ export declare namespace Machine {
|
|
|
5400
5512
|
: { readonly onFailure?: never }
|
|
5401
5513
|
: never
|
|
5402
5514
|
|
|
5515
|
+
export type InvokeElementRequirement<Value, Handler> = InvokeHandlerRequirement<Value, Handler> extends
|
|
5516
|
+
infer Requirement ? Requirement extends { readonly handler: infer Required } ? { readonly onElement: Required }
|
|
5517
|
+
: { readonly onElement?: never }
|
|
5518
|
+
: never
|
|
5519
|
+
|
|
5403
5520
|
export type TimerInvokeArgs<
|
|
5404
5521
|
States extends StateSchemas,
|
|
5405
5522
|
Events extends ReadonlyArray<TaggedSchema>,
|
|
@@ -5414,10 +5531,12 @@ export declare namespace Machine {
|
|
|
5414
5531
|
InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
5415
5532
|
>
|
|
5416
5533
|
readonly effect?: never
|
|
5534
|
+
readonly stream?: never
|
|
5417
5535
|
readonly logic?: never
|
|
5418
5536
|
readonly child?: never
|
|
5419
5537
|
readonly address?: never
|
|
5420
5538
|
readonly onFailure?: never
|
|
5539
|
+
readonly onElement?: never
|
|
5421
5540
|
readonly onSnapshot?: never
|
|
5422
5541
|
readonly onDone: InvokeTransition<
|
|
5423
5542
|
States,
|
|
@@ -5449,8 +5568,10 @@ export declare namespace Machine {
|
|
|
5449
5568
|
readonly address: Address & ChildAddress.Compatibility<Address, ChildEvent>
|
|
5450
5569
|
readonly logic: Source
|
|
5451
5570
|
readonly effect?: never
|
|
5571
|
+
readonly stream?: never
|
|
5452
5572
|
readonly after?: never
|
|
5453
5573
|
readonly child?: never
|
|
5574
|
+
readonly onElement?: never
|
|
5454
5575
|
readonly onSnapshot?: InvokeTransition<
|
|
5455
5576
|
States,
|
|
5456
5577
|
Events,
|
|
@@ -5512,8 +5633,10 @@ export declare namespace Machine {
|
|
|
5512
5633
|
readonly id?: never
|
|
5513
5634
|
readonly address?: never
|
|
5514
5635
|
readonly effect?: never
|
|
5636
|
+
readonly stream?: never
|
|
5515
5637
|
readonly after?: never
|
|
5516
5638
|
readonly logic?: never
|
|
5639
|
+
readonly onElement?: never
|
|
5517
5640
|
readonly onSnapshot?: InvokeTransition<
|
|
5518
5641
|
States,
|
|
5519
5642
|
Events,
|
|
@@ -5627,6 +5750,55 @@ export declare namespace Machine {
|
|
|
5627
5750
|
>
|
|
5628
5751
|
& { readonly onSnapshot?: never }
|
|
5629
5752
|
: never
|
|
5753
|
+
: Raw extends { readonly stream: infer Source } ?
|
|
5754
|
+
InvokeFactoryResult<Source> extends infer SourceStream extends Stream.Stream<any, any, any> ?
|
|
5755
|
+
& InvokeElementRequirement<
|
|
5756
|
+
Stream.Success<SourceStream>,
|
|
5757
|
+
InvokeTransition<
|
|
5758
|
+
States,
|
|
5759
|
+
Events,
|
|
5760
|
+
Emits,
|
|
5761
|
+
StateId,
|
|
5762
|
+
InvokeElementContext<
|
|
5763
|
+
States,
|
|
5764
|
+
Events,
|
|
5765
|
+
Emits,
|
|
5766
|
+
StateId,
|
|
5767
|
+
Stream.Success<SourceStream>,
|
|
5768
|
+
InputEvents,
|
|
5769
|
+
ParentEvents
|
|
5770
|
+
>
|
|
5771
|
+
>
|
|
5772
|
+
>
|
|
5773
|
+
& {
|
|
5774
|
+
readonly onDone: InvokeTransition<
|
|
5775
|
+
States,
|
|
5776
|
+
Events,
|
|
5777
|
+
Emits,
|
|
5778
|
+
StateId,
|
|
5779
|
+
InvokeDoneContext<States, Events, Emits, StateId, void, InputEvents, ParentEvents>
|
|
5780
|
+
>
|
|
5781
|
+
}
|
|
5782
|
+
& InvokeFailureRequirement<
|
|
5783
|
+
Stream.Error<SourceStream>,
|
|
5784
|
+
InvokeTransition<
|
|
5785
|
+
States,
|
|
5786
|
+
Events,
|
|
5787
|
+
Emits,
|
|
5788
|
+
StateId,
|
|
5789
|
+
InvokeFailureContext<
|
|
5790
|
+
States,
|
|
5791
|
+
Events,
|
|
5792
|
+
Emits,
|
|
5793
|
+
StateId,
|
|
5794
|
+
Stream.Error<SourceStream>,
|
|
5795
|
+
InputEvents,
|
|
5796
|
+
ParentEvents
|
|
5797
|
+
>
|
|
5798
|
+
>
|
|
5799
|
+
>
|
|
5800
|
+
& { readonly onSnapshot?: never }
|
|
5801
|
+
: never
|
|
5630
5802
|
: Raw extends { readonly after: unknown } ? {
|
|
5631
5803
|
readonly onDone: InvokeTransition<
|
|
5632
5804
|
States,
|
|
@@ -6374,6 +6546,7 @@ export declare namespace Machine {
|
|
|
6374
6546
|
|
|
6375
6547
|
type TransitionResultInitialTargetPath<Result> = IsAny<Result> extends true ? never
|
|
6376
6548
|
: Result extends Effect.Effect<infer Success, any, any> ? TransitionResultInitialTargetPath<Success>
|
|
6549
|
+
: Result extends SelectedBranch<any, infer Selected> ? TransitionResultInitialTargetPath<Selected>
|
|
6377
6550
|
: Result extends StateConstruction<infer Constructed> ? TransitionResultInitialTargetPath<Constructed>
|
|
6378
6551
|
: Result extends {
|
|
6379
6552
|
readonly [Topology.InitialTargetTypeId]: typeof Topology.InitialTargetTypeId
|
|
@@ -7516,10 +7689,12 @@ type EffectInvokeSource<
|
|
|
7516
7689
|
> = {
|
|
7517
7690
|
readonly id: InvokeLifecycleId
|
|
7518
7691
|
readonly effect: Source
|
|
7692
|
+
readonly stream?: never
|
|
7519
7693
|
readonly after?: never
|
|
7520
7694
|
readonly logic?: never
|
|
7521
7695
|
readonly child?: never
|
|
7522
7696
|
readonly address?: never
|
|
7697
|
+
readonly onElement?: never
|
|
7523
7698
|
readonly onSnapshot?: never
|
|
7524
7699
|
}
|
|
7525
7700
|
|
|
@@ -7588,6 +7763,110 @@ type EffectInvokeResult<
|
|
|
7588
7763
|
never
|
|
7589
7764
|
>
|
|
7590
7765
|
|
|
7766
|
+
type StreamInvokeSource<
|
|
7767
|
+
States extends Machine.StateSchemas,
|
|
7768
|
+
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7769
|
+
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7770
|
+
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7771
|
+
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7772
|
+
StateId extends Machine.StateIdentifier<States>,
|
|
7773
|
+
Source extends (...args: ReadonlyArray<any>) => unknown
|
|
7774
|
+
> = {
|
|
7775
|
+
readonly id: InvokeLifecycleId
|
|
7776
|
+
readonly stream:
|
|
7777
|
+
& Source
|
|
7778
|
+
& ((context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>) => unknown)
|
|
7779
|
+
readonly effect?: never
|
|
7780
|
+
readonly after?: never
|
|
7781
|
+
readonly logic?: never
|
|
7782
|
+
readonly child?: never
|
|
7783
|
+
readonly address?: never
|
|
7784
|
+
readonly onSnapshot?: never
|
|
7785
|
+
}
|
|
7786
|
+
|
|
7787
|
+
type StreamSourceResult<Source extends (...args: ReadonlyArray<any>) => unknown> = ReturnType<Source> extends
|
|
7788
|
+
infer Result extends Stream.Stream<any, any, any> ? Result : never
|
|
7789
|
+
|
|
7790
|
+
type StreamElementHandler<
|
|
7791
|
+
States extends Machine.StateSchemas,
|
|
7792
|
+
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7793
|
+
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7794
|
+
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7795
|
+
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7796
|
+
StateId extends Machine.StateIdentifier<States>,
|
|
7797
|
+
Source extends (...args: ReadonlyArray<any>) => unknown
|
|
7798
|
+
> = Machine.InvokeTransition<
|
|
7799
|
+
States,
|
|
7800
|
+
Events,
|
|
7801
|
+
Emits,
|
|
7802
|
+
StateId,
|
|
7803
|
+
Machine.InvokeElementContext<
|
|
7804
|
+
States,
|
|
7805
|
+
Events,
|
|
7806
|
+
Emits,
|
|
7807
|
+
StateId,
|
|
7808
|
+
Stream.Success<StreamSourceResult<NoInfer<Source>>>,
|
|
7809
|
+
InputEvents,
|
|
7810
|
+
ParentEvents
|
|
7811
|
+
>
|
|
7812
|
+
>
|
|
7813
|
+
|
|
7814
|
+
type StreamDoneHandler<
|
|
7815
|
+
States extends Machine.StateSchemas,
|
|
7816
|
+
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7817
|
+
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7818
|
+
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7819
|
+
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7820
|
+
StateId extends Machine.StateIdentifier<States>
|
|
7821
|
+
> = Machine.InvokeTransition<
|
|
7822
|
+
States,
|
|
7823
|
+
Events,
|
|
7824
|
+
Emits,
|
|
7825
|
+
StateId,
|
|
7826
|
+
Machine.InvokeDoneContext<States, Events, Emits, StateId, void, InputEvents, ParentEvents>
|
|
7827
|
+
>
|
|
7828
|
+
|
|
7829
|
+
type StreamFailureHandler<
|
|
7830
|
+
States extends Machine.StateSchemas,
|
|
7831
|
+
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7832
|
+
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7833
|
+
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7834
|
+
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7835
|
+
StateId extends Machine.StateIdentifier<States>,
|
|
7836
|
+
Source extends (...args: ReadonlyArray<any>) => unknown
|
|
7837
|
+
> = Machine.InvokeTransition<
|
|
7838
|
+
States,
|
|
7839
|
+
Events,
|
|
7840
|
+
Emits,
|
|
7841
|
+
StateId,
|
|
7842
|
+
Machine.InvokeFailureContext<
|
|
7843
|
+
States,
|
|
7844
|
+
Events,
|
|
7845
|
+
Emits,
|
|
7846
|
+
StateId,
|
|
7847
|
+
Stream.Error<StreamSourceResult<NoInfer<Source>>>,
|
|
7848
|
+
InputEvents,
|
|
7849
|
+
ParentEvents
|
|
7850
|
+
>
|
|
7851
|
+
>
|
|
7852
|
+
|
|
7853
|
+
type StreamInvokeResult<
|
|
7854
|
+
States extends Machine.StateSchemas,
|
|
7855
|
+
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7856
|
+
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7857
|
+
InputEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7858
|
+
ParentEvents extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7859
|
+
StateId extends Machine.StateIdentifier<States>,
|
|
7860
|
+
Source extends (...args: ReadonlyArray<any>) => unknown
|
|
7861
|
+
> =
|
|
7862
|
+
& Machine.InvokeConfig<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
7863
|
+
& Machine.InvokeTyped<
|
|
7864
|
+
void,
|
|
7865
|
+
Stream.Error<StreamSourceResult<Source>>,
|
|
7866
|
+
Stream.Services<StreamSourceResult<Source>>,
|
|
7867
|
+
never
|
|
7868
|
+
>
|
|
7869
|
+
|
|
7591
7870
|
type InvokeChannelIsNever<Value> = IsAny<Value> extends true ? false : [Value] extends [never] ? true : false
|
|
7592
7871
|
|
|
7593
7872
|
type BoundEffectInvokeSource<
|
|
@@ -7603,10 +7882,12 @@ type BoundEffectInvokeSource<
|
|
|
7603
7882
|
> = {
|
|
7604
7883
|
readonly id: InvokeLifecycleId
|
|
7605
7884
|
readonly effect: Source
|
|
7885
|
+
readonly stream?: never
|
|
7606
7886
|
readonly after?: never
|
|
7607
7887
|
readonly logic?: never
|
|
7608
7888
|
readonly child?: never
|
|
7609
7889
|
readonly address?: never
|
|
7890
|
+
readonly onElement?: never
|
|
7610
7891
|
readonly onSnapshot?: never
|
|
7611
7892
|
}
|
|
7612
7893
|
|
|
@@ -7675,66 +7956,36 @@ type BoundEffectInvokeResult<
|
|
|
7675
7956
|
never
|
|
7676
7957
|
>
|
|
7677
7958
|
|
|
7678
|
-
/**
|
|
7679
|
-
|
|
7680
|
-
readonly [TransitionCaseTypeId]: true
|
|
7681
|
-
}
|
|
7682
|
-
|
|
7683
|
-
/** Locally bound constructor that preserves each conditional transition case independently. */
|
|
7684
|
-
interface TransitionCaseConstructor<
|
|
7685
|
-
States extends Machine.StateSchemas,
|
|
7686
|
-
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7687
|
-
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7688
|
-
StateId extends Machine.StateNodeIdentifier<States>,
|
|
7689
|
-
Context
|
|
7690
|
-
> {
|
|
7691
|
-
<
|
|
7692
|
-
const Selection extends Machine.TargetSelection<any, any, any>,
|
|
7693
|
-
const Match
|
|
7694
|
-
>(
|
|
7695
|
-
config: Machine.TransitionCaseInput<States, Events, Emits, StateId, Context, Selection, Match>
|
|
7696
|
-
):
|
|
7697
|
-
& Machine.TransitionCaseInput<States, Events, Emits, StateId, Context, Selection, Match>
|
|
7698
|
-
& TransitionCaseTyped
|
|
7699
|
-
}
|
|
7700
|
-
|
|
7701
|
-
/**
|
|
7702
|
-
* Captures one exact transition topology while preserving handler inference.
|
|
7703
|
-
*
|
|
7704
|
-
* @category constructors
|
|
7705
|
-
* @since 0.14.0
|
|
7706
|
-
*/
|
|
7707
|
-
type ConditionalTransitionResult<
|
|
7959
|
+
/** Captures one exact named-branch topology while preserving handler inference. */
|
|
7960
|
+
type BranchingTransitionResult<
|
|
7708
7961
|
States extends Machine.StateSchemas,
|
|
7709
7962
|
Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7710
7963
|
Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7711
7964
|
StateId extends Machine.StateNodeIdentifier<States>,
|
|
7712
7965
|
Context,
|
|
7713
7966
|
Reenter extends boolean,
|
|
7714
|
-
|
|
7715
|
-
TransitionCaseTyped,
|
|
7716
|
-
...ReadonlyArray<TransitionCaseTyped>
|
|
7717
|
-
],
|
|
7718
|
-
OtherwiseSelection extends Machine.TargetSelection<any, any, any>
|
|
7967
|
+
Branches extends Readonly<Record<string, Machine.TransitionBranchInput>>
|
|
7719
7968
|
> =
|
|
7720
|
-
&
|
|
7721
|
-
Machine.TransitionConditionalInput<
|
|
7722
|
-
States,
|
|
7723
|
-
Events,
|
|
7724
|
-
Emits,
|
|
7725
|
-
StateId,
|
|
7726
|
-
Context,
|
|
7727
|
-
Reenter,
|
|
7728
|
-
Cases,
|
|
7729
|
-
OtherwiseSelection
|
|
7730
|
-
>,
|
|
7731
|
-
"cases"
|
|
7732
|
-
>
|
|
7733
|
-
& { readonly cases: Cases }
|
|
7969
|
+
& Machine.TransitionBranchesInput<States, Events, Emits, StateId, Context, Reenter, Branches>
|
|
7734
7970
|
& Machine.TransitionTyped<States, Events, Emits, StateId, Context, Reenter>
|
|
7735
7971
|
|
|
7972
|
+
type TransitionBranchRecordError<Message extends string, Key extends PropertyKey = never> = {
|
|
7973
|
+
readonly "~effect/Machine/TransitionBranchRecordError": Message
|
|
7974
|
+
readonly key: Key
|
|
7975
|
+
}
|
|
7976
|
+
|
|
7977
|
+
type InvalidStaticTransitionBranchKey<Branches> = Extract<keyof Branches, "" | number | symbol>
|
|
7978
|
+
|
|
7979
|
+
type ValidateTransitionBranchRecord<Branches> = [keyof Branches] extends [never] ?
|
|
7980
|
+
TransitionBranchRecordError<"Branch records must contain at least one branch">
|
|
7981
|
+
: [InvalidStaticTransitionBranchKey<Branches>] extends [never] ? unknown
|
|
7982
|
+
: TransitionBranchRecordError<
|
|
7983
|
+
"Branch keys must be non-empty, non-index strings",
|
|
7984
|
+
InvalidStaticTransitionBranchKey<Branches>
|
|
7985
|
+
>
|
|
7986
|
+
|
|
7736
7987
|
/**
|
|
7737
|
-
* Contextually types direct and
|
|
7988
|
+
* Contextually types direct and branching transition definitions.
|
|
7738
7989
|
*
|
|
7739
7990
|
* @category constructors
|
|
7740
7991
|
* @since 0.14.0
|
|
@@ -7760,32 +8011,28 @@ export interface TransitionConstructor {
|
|
|
7760
8011
|
const Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
7761
8012
|
StateId extends Machine.StateNodeIdentifier<States>,
|
|
7762
8013
|
Context,
|
|
7763
|
-
const
|
|
7764
|
-
TransitionCaseTyped,
|
|
7765
|
-
...ReadonlyArray<TransitionCaseTyped>
|
|
7766
|
-
],
|
|
7767
|
-
const OtherwiseSelection extends Machine.TargetSelection<any, any, any>,
|
|
8014
|
+
const Branches extends Readonly<Record<string, Machine.TransitionBranchInput>>,
|
|
7768
8015
|
Reenter extends boolean = never
|
|
7769
8016
|
>(
|
|
7770
|
-
config:
|
|
7771
|
-
|
|
7772
|
-
|
|
7773
|
-
|
|
7774
|
-
|
|
7775
|
-
|
|
7776
|
-
|
|
7777
|
-
|
|
7778
|
-
|
|
7779
|
-
|
|
7780
|
-
|
|
8017
|
+
config:
|
|
8018
|
+
& Machine.TransitionBranchesInput<
|
|
8019
|
+
States,
|
|
8020
|
+
Events,
|
|
8021
|
+
Emits,
|
|
8022
|
+
StateId,
|
|
8023
|
+
Context,
|
|
8024
|
+
Reenter,
|
|
8025
|
+
Branches
|
|
8026
|
+
>
|
|
8027
|
+
& ValidateTransitionBranchRecord<NoInfer<Branches>>
|
|
8028
|
+
): BranchingTransitionResult<
|
|
7781
8029
|
States,
|
|
7782
8030
|
Events,
|
|
7783
8031
|
Emits,
|
|
7784
8032
|
StateId,
|
|
7785
8033
|
Context,
|
|
7786
8034
|
Reenter,
|
|
7787
|
-
|
|
7788
|
-
OtherwiseSelection
|
|
8035
|
+
Branches
|
|
7789
8036
|
>
|
|
7790
8037
|
}
|
|
7791
8038
|
|
|
@@ -7794,9 +8041,9 @@ export interface TransitionConstructor {
|
|
|
7794
8041
|
*
|
|
7795
8042
|
* It is required for every event, lifecycle, choice, and invocation transition
|
|
7796
8043
|
* so the destination selected by `target` can contextually type the
|
|
7797
|
-
* corresponding resolver.
|
|
7798
|
-
*
|
|
7799
|
-
*
|
|
8044
|
+
* corresponding resolver. Branching transitions declare every possible
|
|
8045
|
+
* destination up front, then select one through ordinary TypeScript control
|
|
8046
|
+
* flow in `resolve`.
|
|
7800
8047
|
*
|
|
7801
8048
|
* ```ts
|
|
7802
8049
|
* Machine.transition({
|
|
@@ -7805,31 +8052,61 @@ export interface TransitionConstructor {
|
|
|
7805
8052
|
* })
|
|
7806
8053
|
*
|
|
7807
8054
|
* Machine.transition({
|
|
7808
|
-
*
|
|
7809
|
-
*
|
|
7810
|
-
*
|
|
7811
|
-
*
|
|
7812
|
-
*
|
|
7813
|
-
*
|
|
7814
|
-
*
|
|
7815
|
-
* ],
|
|
7816
|
-
* otherwise: {
|
|
7817
|
-
* target: (to) => to.full.Loading(),
|
|
7818
|
-
* resolve: ({ target }) => target.from()
|
|
7819
|
-
* }
|
|
8055
|
+
* branches: (to) => ({
|
|
8056
|
+
* cached: { target: to.full.Ready() },
|
|
8057
|
+
* loading: { target: to.full.Loading() }
|
|
8058
|
+
* }),
|
|
8059
|
+
* resolve: ({ event, select }) => event.cached
|
|
8060
|
+
* ? select.cached.from({ data: event.cached })
|
|
8061
|
+
* : select.loading.from()
|
|
7820
8062
|
* })
|
|
7821
8063
|
* ```
|
|
7822
8064
|
*
|
|
7823
8065
|
* @category constructors
|
|
7824
8066
|
* @since 0.14.0
|
|
7825
8067
|
*/
|
|
7826
|
-
export const transition: TransitionConstructor = ((config: unknown) =>
|
|
7827
|
-
|
|
7828
|
-
|
|
7829
|
-
|
|
7830
|
-
|
|
7831
|
-
|
|
7832
|
-
|
|
8068
|
+
export const transition: TransitionConstructor = ((config: unknown) => config) as TransitionConstructor
|
|
8069
|
+
|
|
8070
|
+
/**
|
|
8071
|
+
* Sentinel used by direct targetless transition shorthands.
|
|
8072
|
+
*
|
|
8073
|
+
* This is the concise form of `target: (to) => to.none()`.
|
|
8074
|
+
*
|
|
8075
|
+
* ```ts
|
|
8076
|
+
* onElement: {
|
|
8077
|
+
* target: Machine.targetless,
|
|
8078
|
+
* resolve: ({ element }, enqueue) => {
|
|
8079
|
+
* enqueue.raise(new MeasurementReceived({ value: element }))
|
|
8080
|
+
* }
|
|
8081
|
+
* }
|
|
8082
|
+
*
|
|
8083
|
+
* onDone: { target: Machine.targetless }
|
|
8084
|
+
* ```
|
|
8085
|
+
*
|
|
8086
|
+
* @category constructors
|
|
8087
|
+
* @since 0.16.0
|
|
8088
|
+
*/
|
|
8089
|
+
export interface TargetlessSelector {
|
|
8090
|
+
readonly "~effect/Machine/TargetlessSelector": true
|
|
8091
|
+
<
|
|
8092
|
+
const States extends Machine.StateSchemas,
|
|
8093
|
+
StateId extends Machine.StateNodeIdentifier<States>
|
|
8094
|
+
>(to: Machine.TargetSelector<States, StateId>): ReturnType<Machine.TargetSelector<States, StateId>["none"]>
|
|
8095
|
+
}
|
|
8096
|
+
|
|
8097
|
+
/**
|
|
8098
|
+
* Selects no transition target while keeping enqueue operations explicit.
|
|
8099
|
+
*
|
|
8100
|
+
* Use as the `target` of a direct handler object when the handler should keep
|
|
8101
|
+
* the current state configuration and only raise, emit, or send events.
|
|
8102
|
+
*
|
|
8103
|
+
* @category constructors
|
|
8104
|
+
* @since 0.16.0
|
|
8105
|
+
*/
|
|
8106
|
+
export const targetless: TargetlessSelector = Object.assign(
|
|
8107
|
+
(to: Machine.TargetSelector<any, any>) => to.none(),
|
|
8108
|
+
{ "~effect/Machine/TargetlessSelector": true as const }
|
|
8109
|
+
)
|
|
7833
8110
|
|
|
7834
8111
|
/**
|
|
7835
8112
|
* Machine-bound invocation constructor that preserves the owning machine's
|
|
@@ -7944,6 +8221,73 @@ export interface Invoker<
|
|
|
7944
8221
|
readonly onFailure?: never
|
|
7945
8222
|
}
|
|
7946
8223
|
): BoundEffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8224
|
+
<
|
|
8225
|
+
StateId extends Machine.StateIdentifier<States>,
|
|
8226
|
+
const Source extends (
|
|
8227
|
+
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8228
|
+
) => Stream.Stream<unknown, unknown, any>
|
|
8229
|
+
>(
|
|
8230
|
+
config:
|
|
8231
|
+
& StreamInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8232
|
+
& {
|
|
8233
|
+
readonly onElement: StreamElementHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8234
|
+
readonly onDone: StreamDoneHandler<States, Events, Emits, InputEvents, ParentEvents, StateId>
|
|
8235
|
+
readonly onFailure: StreamFailureHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8236
|
+
},
|
|
8237
|
+
..._validation: InvokeChannelIsNever<Stream.Success<ReturnType<Source>>> extends true ? [
|
|
8238
|
+
"onElement must be omitted when the Stream element is never"
|
|
8239
|
+
]
|
|
8240
|
+
: InvokeChannelIsNever<Stream.Error<ReturnType<Source>>> extends true ? [
|
|
8241
|
+
"onFailure must be omitted when the Stream error is never"
|
|
8242
|
+
]
|
|
8243
|
+
: []
|
|
8244
|
+
): StreamInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8245
|
+
<
|
|
8246
|
+
StateId extends Machine.StateIdentifier<States>,
|
|
8247
|
+
const Source extends (
|
|
8248
|
+
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8249
|
+
) => Stream.Stream<never, unknown, any>
|
|
8250
|
+
>(
|
|
8251
|
+
config:
|
|
8252
|
+
& StreamInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8253
|
+
& {
|
|
8254
|
+
readonly onElement?: never
|
|
8255
|
+
readonly onDone: StreamDoneHandler<States, Events, Emits, InputEvents, ParentEvents, StateId>
|
|
8256
|
+
readonly onFailure: StreamFailureHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8257
|
+
},
|
|
8258
|
+
..._validation: InvokeChannelIsNever<Stream.Error<ReturnType<Source>>> extends true ? [
|
|
8259
|
+
"onFailure must be omitted when the Stream error is never"
|
|
8260
|
+
]
|
|
8261
|
+
: []
|
|
8262
|
+
): StreamInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8263
|
+
<
|
|
8264
|
+
StateId extends Machine.StateIdentifier<States>,
|
|
8265
|
+
const Source extends (
|
|
8266
|
+
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8267
|
+
) => Stream.Stream<never, never, any>
|
|
8268
|
+
>(
|
|
8269
|
+
config:
|
|
8270
|
+
& StreamInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8271
|
+
& {
|
|
8272
|
+
readonly onElement?: never
|
|
8273
|
+
readonly onDone: StreamDoneHandler<States, Events, Emits, InputEvents, ParentEvents, StateId>
|
|
8274
|
+
readonly onFailure?: never
|
|
8275
|
+
}
|
|
8276
|
+
): StreamInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8277
|
+
<
|
|
8278
|
+
StateId extends Machine.StateIdentifier<States>,
|
|
8279
|
+
const Source extends (
|
|
8280
|
+
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8281
|
+
) => Stream.Stream<unknown, never, any>
|
|
8282
|
+
>(
|
|
8283
|
+
config:
|
|
8284
|
+
& StreamInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8285
|
+
& {
|
|
8286
|
+
readonly onElement: StreamElementHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8287
|
+
readonly onDone: StreamDoneHandler<States, Events, Emits, InputEvents, ParentEvents, StateId>
|
|
8288
|
+
readonly onFailure?: never
|
|
8289
|
+
}
|
|
8290
|
+
): StreamInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
7947
8291
|
<StateId extends Machine.StateIdentifier<States>, const Config extends object>(
|
|
7948
8292
|
config: Config & Machine.TimerInvokeArgs<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
7949
8293
|
): Config & Machine.InvokeOwned<States, Events, Emits, StateId> & Machine.InvokeTyped<void, never, never, never>
|
|
@@ -8050,15 +8394,18 @@ export interface Invoker<
|
|
|
8050
8394
|
/**
|
|
8051
8395
|
* Preserves inference for a state-owned invocation configuration.
|
|
8052
8396
|
*
|
|
8053
|
-
* Use `effect` for one-shot work, `
|
|
8054
|
-
* reusable process logic, or `child` for a
|
|
8055
|
-
*
|
|
8056
|
-
*
|
|
8397
|
+
* Use `effect` for one-shot work, `stream` for repeated values, `after` for a
|
|
8398
|
+
* cancellable timer, `logic` for reusable process logic, or `child` for a
|
|
8399
|
+
* complete child machine. Stream elements are handled by `onElement` before
|
|
8400
|
+
* the next element is pulled. `onDone` is required whenever the source can
|
|
8401
|
+
* complete, while `onFailure` is required only when the source has a typed
|
|
8402
|
+
* failure channel.
|
|
8057
8403
|
*
|
|
8058
8404
|
* This constructor is an identity at runtime, but preserves lifecycle callback
|
|
8059
|
-
* inference through published declarations. Effect factories run
|
|
8060
|
-
* owning state is entered and infer the owner context,
|
|
8061
|
-
* service channels together without a return annotation.
|
|
8405
|
+
* inference through published declarations. Effect and Stream factories run
|
|
8406
|
+
* when their owning state is entered and infer the owner context, value,
|
|
8407
|
+
* output, error, and service channels together without a return annotation.
|
|
8408
|
+
* Durations may be
|
|
8062
8409
|
* supplied directly or derived from the owning state's entry context. Logic
|
|
8063
8410
|
* invocations require both a lifecycle `id` and a typed communication
|
|
8064
8411
|
* `address`. Child descriptors already own their identity, so `id` and
|
|
@@ -8179,6 +8526,93 @@ export const invoke: {
|
|
|
8179
8526
|
readonly onFailure?: never
|
|
8180
8527
|
}
|
|
8181
8528
|
): EffectInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8529
|
+
<
|
|
8530
|
+
const States extends Machine.StateSchemas,
|
|
8531
|
+
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8532
|
+
const Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8533
|
+
StateId extends Machine.StateIdentifier<States>,
|
|
8534
|
+
const Source extends (
|
|
8535
|
+
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8536
|
+
) => Stream.Stream<unknown, unknown, any>,
|
|
8537
|
+
const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
8538
|
+
const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []
|
|
8539
|
+
>(
|
|
8540
|
+
config:
|
|
8541
|
+
& StreamInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8542
|
+
& {
|
|
8543
|
+
readonly onElement: StreamElementHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8544
|
+
readonly onDone: StreamDoneHandler<States, Events, Emits, InputEvents, ParentEvents, StateId>
|
|
8545
|
+
readonly onFailure: StreamFailureHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8546
|
+
},
|
|
8547
|
+
..._validation: InvokeChannelIsNever<Stream.Success<ReturnType<Source>>> extends true ? [
|
|
8548
|
+
"onElement must be omitted when the Stream element is never"
|
|
8549
|
+
]
|
|
8550
|
+
: InvokeChannelIsNever<Stream.Error<ReturnType<Source>>> extends true ? [
|
|
8551
|
+
"onFailure must be omitted when the Stream error is never"
|
|
8552
|
+
]
|
|
8553
|
+
: []
|
|
8554
|
+
): StreamInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8555
|
+
<
|
|
8556
|
+
const States extends Machine.StateSchemas,
|
|
8557
|
+
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8558
|
+
const Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8559
|
+
StateId extends Machine.StateIdentifier<States>,
|
|
8560
|
+
const Source extends (
|
|
8561
|
+
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8562
|
+
) => Stream.Stream<never, unknown, any>,
|
|
8563
|
+
const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
8564
|
+
const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []
|
|
8565
|
+
>(
|
|
8566
|
+
config:
|
|
8567
|
+
& StreamInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8568
|
+
& {
|
|
8569
|
+
readonly onElement?: never
|
|
8570
|
+
readonly onDone: StreamDoneHandler<States, Events, Emits, InputEvents, ParentEvents, StateId>
|
|
8571
|
+
readonly onFailure: StreamFailureHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8572
|
+
},
|
|
8573
|
+
..._validation: InvokeChannelIsNever<Stream.Error<ReturnType<Source>>> extends true ? [
|
|
8574
|
+
"onFailure must be omitted when the Stream error is never"
|
|
8575
|
+
]
|
|
8576
|
+
: []
|
|
8577
|
+
): StreamInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8578
|
+
<
|
|
8579
|
+
const States extends Machine.StateSchemas,
|
|
8580
|
+
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8581
|
+
const Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8582
|
+
StateId extends Machine.StateIdentifier<States>,
|
|
8583
|
+
const Source extends (
|
|
8584
|
+
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8585
|
+
) => Stream.Stream<never, never, any>,
|
|
8586
|
+
const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
8587
|
+
const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []
|
|
8588
|
+
>(
|
|
8589
|
+
config:
|
|
8590
|
+
& StreamInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8591
|
+
& {
|
|
8592
|
+
readonly onElement?: never
|
|
8593
|
+
readonly onDone: StreamDoneHandler<States, Events, Emits, InputEvents, ParentEvents, StateId>
|
|
8594
|
+
readonly onFailure?: never
|
|
8595
|
+
}
|
|
8596
|
+
): StreamInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8597
|
+
<
|
|
8598
|
+
const States extends Machine.StateSchemas,
|
|
8599
|
+
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8600
|
+
const Emits extends ReadonlyArray<Machine.TaggedSchema>,
|
|
8601
|
+
StateId extends Machine.StateIdentifier<States>,
|
|
8602
|
+
const Source extends (
|
|
8603
|
+
context: Machine.InvokeContext<States, Events, Emits, StateId, InputEvents, ParentEvents>
|
|
8604
|
+
) => Stream.Stream<unknown, never, any>,
|
|
8605
|
+
const InputEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly [],
|
|
8606
|
+
const ParentEvents extends ReadonlyArray<Machine.TaggedSchema> = readonly []
|
|
8607
|
+
>(
|
|
8608
|
+
config:
|
|
8609
|
+
& StreamInvokeSource<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8610
|
+
& {
|
|
8611
|
+
readonly onElement: StreamElementHandler<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8612
|
+
readonly onDone: StreamDoneHandler<States, Events, Emits, InputEvents, ParentEvents, StateId>
|
|
8613
|
+
readonly onFailure?: never
|
|
8614
|
+
}
|
|
8615
|
+
): StreamInvokeResult<States, Events, Emits, InputEvents, ParentEvents, StateId, Source>
|
|
8182
8616
|
<
|
|
8183
8617
|
const States extends Machine.StateSchemas,
|
|
8184
8618
|
const Events extends ReadonlyArray<Machine.TaggedSchema>,
|
|
@@ -8464,9 +8898,8 @@ export const initialDefinition: <M extends Machine.Any>(machine: M) => Machine.I
|
|
|
8464
8898
|
*
|
|
8465
8899
|
* Event handlers retain their handler-key order within each source state and
|
|
8466
8900
|
* are followed by eventless and completion handlers. This function does not
|
|
8467
|
-
* execute
|
|
8468
|
-
*
|
|
8469
|
-
* `target` declaration.
|
|
8901
|
+
* execute resolvers. Every direct, named, and targetless branch exposes the
|
|
8902
|
+
* destination selected by its required static `target` declaration.
|
|
8470
8903
|
*
|
|
8471
8904
|
* @category getters
|
|
8472
8905
|
* @since 0.4.0
|