xstate 6.0.0-alpha.51 → 6.0.0-alpha.52
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/{createActor-a0610101.cjs.js → createActor-20277025.cjs.js} +5 -0
- package/dist/{createActor-67a1cda3.development.esm.js → createActor-41e3bbc3.development.esm.js} +5 -0
- package/dist/{createActor-ae612b26.development.cjs.js → createActor-4d94dd53.development.cjs.js} +5 -0
- package/dist/{createActor-5d4780c4.esm.js → createActor-6fa87eea.esm.js} +5 -0
- package/dist/declarations/src/graph/graph.d.ts +1 -0
- package/dist/declarations/src/schema.types.d.ts +3 -1
- package/dist/{effectDescriptor-143d3c39.development.cjs.js → effectDescriptor-6991ab90.development.cjs.js} +1 -1
- package/dist/{effectDescriptor-727e5012.esm.js → effectDescriptor-c56bd9d5.esm.js} +1 -1
- package/dist/{effectDescriptor-0399a5cc.development.esm.js → effectDescriptor-e64efd18.development.esm.js} +1 -1
- package/dist/{effectDescriptor-f5237352.cjs.js → effectDescriptor-fa21710c.cjs.js} +1 -1
- package/dist/{schema.types-6c3a61af.development.esm.js → schema.types-1b4319f7.development.esm.js} +3 -1
- package/dist/{schema.types-7a48b14e.cjs.js → schema.types-20693e6b.cjs.js} +3 -1
- package/dist/{schema.types-9a23aaa8.esm.js → schema.types-7439a117.esm.js} +3 -1
- package/dist/{schema.types-e396f88c.development.cjs.js → schema.types-a2b10853.development.cjs.js} +3 -1
- package/dist/{StateMachine-c3c54551.cjs.js → types-5d934c5c.cjs.js} +191 -1
- package/dist/{StateMachine-df7199a8.development.esm.js → types-63cc2400.development.esm.js} +189 -2
- package/dist/{StateMachine-559e0140.development.cjs.js → types-84a9c6a1.development.cjs.js} +191 -1
- package/dist/{StateMachine-c6e2cb9e.esm.js → types-ab7eb7a3.esm.js} +189 -2
- package/dist/xstate-actors.cjs.js +1 -1
- package/dist/xstate-actors.development.cjs.js +1 -1
- package/dist/xstate-actors.development.esm.js +2 -2
- package/dist/xstate-actors.esm.js +2 -2
- package/dist/xstate-actors.umd.min.js.map +1 -1
- package/dist/xstate-durable.cjs.js +2 -2
- package/dist/xstate-durable.development.cjs.js +2 -2
- package/dist/xstate-durable.development.esm.js +2 -2
- package/dist/xstate-durable.esm.js +2 -2
- package/dist/xstate-durable.umd.min.js.map +1 -1
- package/dist/xstate-fsm.cjs.js +1 -1
- package/dist/xstate-fsm.development.cjs.js +1 -1
- package/dist/xstate-fsm.development.esm.js +1 -1
- package/dist/xstate-fsm.esm.js +1 -1
- package/dist/xstate-fsm.umd.min.js.map +1 -1
- package/dist/xstate-graph.cjs.js +9 -8
- package/dist/xstate-graph.development.cjs.js +9 -8
- package/dist/xstate-graph.development.esm.js +9 -8
- package/dist/xstate-graph.esm.js +9 -8
- package/dist/xstate-graph.umd.min.js +1 -1
- package/dist/xstate-graph.umd.min.js.map +1 -1
- package/dist/xstate-scxml.cjs.js +2 -3
- package/dist/xstate-scxml.development.cjs.js +2 -3
- package/dist/xstate-scxml.development.esm.js +2 -3
- package/dist/xstate-scxml.esm.js +2 -3
- package/dist/xstate-scxml.umd.min.js +1 -1
- package/dist/xstate-scxml.umd.min.js.map +1 -1
- package/dist/xstate-validation.cjs.js +1 -1
- package/dist/xstate-validation.development.cjs.js +1 -1
- package/dist/xstate-validation.development.esm.js +1 -1
- package/dist/xstate-validation.esm.js +1 -1
- package/dist/xstate.cjs.js +7 -8
- package/dist/xstate.development.cjs.js +7 -8
- package/dist/xstate.development.esm.js +6 -8
- package/dist/xstate.esm.js +6 -8
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/dist/types-47bec2b3.development.cjs.js +0 -194
- package/dist/types-846ceef0.cjs.js +0 -194
- package/dist/types-c59c4824.esm.js +0 -190
- package/dist/types-cfdb878a.development.esm.js +0 -190
|
@@ -983,6 +983,7 @@ function getBuiltInActionFields(action, args) {
|
|
|
983
983
|
{
|
|
984
984
|
const [actor] = args;
|
|
985
985
|
return {
|
|
986
|
+
type: '@xstate.spawn',
|
|
986
987
|
kind: 'builtin',
|
|
987
988
|
exec: execSpawnEffect,
|
|
988
989
|
source: actor._parent,
|
|
@@ -997,6 +998,7 @@ function getBuiltInActionFields(action, args) {
|
|
|
997
998
|
{
|
|
998
999
|
const [, event, options] = args;
|
|
999
1000
|
return {
|
|
1001
|
+
type: '@xstate.raise',
|
|
1000
1002
|
kind: 'builtin',
|
|
1001
1003
|
exec: execRaiseEffect,
|
|
1002
1004
|
source: args[0].self,
|
|
@@ -1009,6 +1011,7 @@ function getBuiltInActionFields(action, args) {
|
|
|
1009
1011
|
{
|
|
1010
1012
|
const [, target, event, options] = args;
|
|
1011
1013
|
return {
|
|
1014
|
+
type: '@xstate.sendTo',
|
|
1012
1015
|
kind: 'builtin',
|
|
1013
1016
|
exec: execSendToEffect,
|
|
1014
1017
|
source: args[0].self,
|
|
@@ -1022,6 +1025,7 @@ function getBuiltInActionFields(action, args) {
|
|
|
1022
1025
|
{
|
|
1023
1026
|
const [, id] = args;
|
|
1024
1027
|
return {
|
|
1028
|
+
type: '@xstate.cancel',
|
|
1025
1029
|
kind: 'builtin',
|
|
1026
1030
|
exec: execCancelEffect,
|
|
1027
1031
|
source: args[0].self,
|
|
@@ -1032,6 +1036,7 @@ function getBuiltInActionFields(action, args) {
|
|
|
1032
1036
|
{
|
|
1033
1037
|
const [, actor] = args;
|
|
1034
1038
|
return {
|
|
1039
|
+
type: '@xstate.stop',
|
|
1035
1040
|
kind: 'builtin',
|
|
1036
1041
|
exec: execStopEffect,
|
|
1037
1042
|
source: args[0].self,
|
package/dist/{createActor-67a1cda3.development.esm.js → createActor-41e3bbc3.development.esm.js}
RENAMED
|
@@ -989,6 +989,7 @@ function getBuiltInActionFields(action, args) {
|
|
|
989
989
|
{
|
|
990
990
|
const [actor] = args;
|
|
991
991
|
return {
|
|
992
|
+
type: '@xstate.spawn',
|
|
992
993
|
kind: 'builtin',
|
|
993
994
|
exec: execSpawnEffect,
|
|
994
995
|
source: actor._parent,
|
|
@@ -1003,6 +1004,7 @@ function getBuiltInActionFields(action, args) {
|
|
|
1003
1004
|
{
|
|
1004
1005
|
const [, event, options] = args;
|
|
1005
1006
|
return {
|
|
1007
|
+
type: '@xstate.raise',
|
|
1006
1008
|
kind: 'builtin',
|
|
1007
1009
|
exec: execRaiseEffect,
|
|
1008
1010
|
source: args[0].self,
|
|
@@ -1015,6 +1017,7 @@ function getBuiltInActionFields(action, args) {
|
|
|
1015
1017
|
{
|
|
1016
1018
|
const [, target, event, options] = args;
|
|
1017
1019
|
return {
|
|
1020
|
+
type: '@xstate.sendTo',
|
|
1018
1021
|
kind: 'builtin',
|
|
1019
1022
|
exec: execSendToEffect,
|
|
1020
1023
|
source: args[0].self,
|
|
@@ -1028,6 +1031,7 @@ function getBuiltInActionFields(action, args) {
|
|
|
1028
1031
|
{
|
|
1029
1032
|
const [, id] = args;
|
|
1030
1033
|
return {
|
|
1034
|
+
type: '@xstate.cancel',
|
|
1031
1035
|
kind: 'builtin',
|
|
1032
1036
|
exec: execCancelEffect,
|
|
1033
1037
|
source: args[0].self,
|
|
@@ -1038,6 +1042,7 @@ function getBuiltInActionFields(action, args) {
|
|
|
1038
1042
|
{
|
|
1039
1043
|
const [, actor] = args;
|
|
1040
1044
|
return {
|
|
1045
|
+
type: '@xstate.stop',
|
|
1041
1046
|
kind: 'builtin',
|
|
1042
1047
|
exec: execStopEffect,
|
|
1043
1048
|
source: args[0].self,
|
package/dist/{createActor-ae612b26.development.cjs.js → createActor-4d94dd53.development.cjs.js}
RENAMED
|
@@ -991,6 +991,7 @@ function getBuiltInActionFields(action, args) {
|
|
|
991
991
|
{
|
|
992
992
|
const [actor] = args;
|
|
993
993
|
return {
|
|
994
|
+
type: '@xstate.spawn',
|
|
994
995
|
kind: 'builtin',
|
|
995
996
|
exec: execSpawnEffect,
|
|
996
997
|
source: actor._parent,
|
|
@@ -1005,6 +1006,7 @@ function getBuiltInActionFields(action, args) {
|
|
|
1005
1006
|
{
|
|
1006
1007
|
const [, event, options] = args;
|
|
1007
1008
|
return {
|
|
1009
|
+
type: '@xstate.raise',
|
|
1008
1010
|
kind: 'builtin',
|
|
1009
1011
|
exec: execRaiseEffect,
|
|
1010
1012
|
source: args[0].self,
|
|
@@ -1017,6 +1019,7 @@ function getBuiltInActionFields(action, args) {
|
|
|
1017
1019
|
{
|
|
1018
1020
|
const [, target, event, options] = args;
|
|
1019
1021
|
return {
|
|
1022
|
+
type: '@xstate.sendTo',
|
|
1020
1023
|
kind: 'builtin',
|
|
1021
1024
|
exec: execSendToEffect,
|
|
1022
1025
|
source: args[0].self,
|
|
@@ -1030,6 +1033,7 @@ function getBuiltInActionFields(action, args) {
|
|
|
1030
1033
|
{
|
|
1031
1034
|
const [, id] = args;
|
|
1032
1035
|
return {
|
|
1036
|
+
type: '@xstate.cancel',
|
|
1033
1037
|
kind: 'builtin',
|
|
1034
1038
|
exec: execCancelEffect,
|
|
1035
1039
|
source: args[0].self,
|
|
@@ -1040,6 +1044,7 @@ function getBuiltInActionFields(action, args) {
|
|
|
1040
1044
|
{
|
|
1041
1045
|
const [, actor] = args;
|
|
1042
1046
|
return {
|
|
1047
|
+
type: '@xstate.stop',
|
|
1043
1048
|
kind: 'builtin',
|
|
1044
1049
|
exec: execStopEffect,
|
|
1045
1050
|
source: args[0].self,
|
|
@@ -981,6 +981,7 @@ function getBuiltInActionFields(action, args) {
|
|
|
981
981
|
{
|
|
982
982
|
const [actor] = args;
|
|
983
983
|
return {
|
|
984
|
+
type: '@xstate.spawn',
|
|
984
985
|
kind: 'builtin',
|
|
985
986
|
exec: execSpawnEffect,
|
|
986
987
|
source: actor._parent,
|
|
@@ -995,6 +996,7 @@ function getBuiltInActionFields(action, args) {
|
|
|
995
996
|
{
|
|
996
997
|
const [, event, options] = args;
|
|
997
998
|
return {
|
|
999
|
+
type: '@xstate.raise',
|
|
998
1000
|
kind: 'builtin',
|
|
999
1001
|
exec: execRaiseEffect,
|
|
1000
1002
|
source: args[0].self,
|
|
@@ -1007,6 +1009,7 @@ function getBuiltInActionFields(action, args) {
|
|
|
1007
1009
|
{
|
|
1008
1010
|
const [, target, event, options] = args;
|
|
1009
1011
|
return {
|
|
1012
|
+
type: '@xstate.sendTo',
|
|
1010
1013
|
kind: 'builtin',
|
|
1011
1014
|
exec: execSendToEffect,
|
|
1012
1015
|
source: args[0].self,
|
|
@@ -1020,6 +1023,7 @@ function getBuiltInActionFields(action, args) {
|
|
|
1020
1023
|
{
|
|
1021
1024
|
const [, id] = args;
|
|
1022
1025
|
return {
|
|
1026
|
+
type: '@xstate.cancel',
|
|
1023
1027
|
kind: 'builtin',
|
|
1024
1028
|
exec: execCancelEffect,
|
|
1025
1029
|
source: args[0].self,
|
|
@@ -1030,6 +1034,7 @@ function getBuiltInActionFields(action, args) {
|
|
|
1030
1034
|
{
|
|
1031
1035
|
const [, actor] = args;
|
|
1032
1036
|
return {
|
|
1037
|
+
type: '@xstate.stop',
|
|
1033
1038
|
kind: 'builtin',
|
|
1034
1039
|
exec: execStopEffect,
|
|
1035
1040
|
source: args[0].self,
|
|
@@ -12,5 +12,6 @@ export declare function serializeSnapshot(snapshot: Snapshot<any>): SerializedSn
|
|
|
12
12
|
export declare function createDefaultMachineOptions<TMachine extends AnyStateMachine>(machine: TMachine, options?: TraversalOptions<SnapshotFrom<TMachine>, EventFromLogic<TMachine>, InputFrom<TMachine>>): TraversalOptions<SnapshotFrom<TMachine>, EventFromLogic<TMachine>, InputFrom<TMachine>>;
|
|
13
13
|
export declare function createDefaultLogicOptions(): TraversalOptions<any, any, any>;
|
|
14
14
|
export declare function toDirectedGraph(stateMachine: AnyStateNode | AnyStateMachine): DirectedGraphNode;
|
|
15
|
+
export declare function isMachineLogic(logic: unknown): logic is AnyStateMachine;
|
|
15
16
|
export declare function resolveTraversalOptions<TLogic extends AnyActorLogic>(logic: TLogic, traversalOptions?: TraversalOptions<SnapshotFrom<TLogic>, EventFromLogic<TLogic>, InputFrom<TLogic>>, defaultOptions?: TraversalOptions<SnapshotFrom<TLogic>, EventFromLogic<TLogic>, InputFrom<TLogic>>): TraversalConfig<SnapshotFrom<TLogic>, EventFromLogic<TLogic>>;
|
|
16
17
|
export declare function joinPaths<TSnapshot extends Snapshot<unknown>, TEvent extends EventObject>(headPath: StatePath<TSnapshot, TEvent>, tailPath: StatePath<TSnapshot, TEvent>): StatePath<TSnapshot, TEvent>;
|
|
@@ -35,13 +35,15 @@ export interface TypeSchema<T> extends StandardSchemaV1<T, T> {
|
|
|
35
35
|
* context: types<{ count: number }>(),
|
|
36
36
|
* events: {
|
|
37
37
|
* inc: types<{ by: number }>(),
|
|
38
|
-
* reset: types<
|
|
38
|
+
* reset: types<void>()
|
|
39
39
|
* }
|
|
40
40
|
* },
|
|
41
41
|
* context: { count: 0 }
|
|
42
42
|
* // ...
|
|
43
43
|
* });
|
|
44
44
|
* ```
|
|
45
|
+
*
|
|
46
|
+
* Use `types<void>()` for events without a payload.
|
|
45
47
|
*/
|
|
46
48
|
export declare function types<T>(): TypeSchema<T>;
|
|
47
49
|
/** Returns true if the value is a type-only schema created by {@link types}. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var createActor = require('./createActor-
|
|
3
|
+
var createActor = require('./createActor-4d94dd53.development.cjs.js');
|
|
4
4
|
|
|
5
5
|
function attachMicrostepActorRefs(microsteps, actorScope, inputSnapshot) {
|
|
6
6
|
if (!microsteps.length) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a3 as createInertActorScope, a4 as setInertActorScopeSnapshot, F as finalizeTransitionResult, a6 as attachSnapshotActorRef, y as createInitEvent, av as hasAmbientInspector, a5 as beginSpawnAllocation, a7 as macrostep, ak as createSpawnEffect, al as initialMicrostep, i as isAtomicStateNode, aw as getProperAncestors, ax as isRemoteActorRef, ay as getActorIdPrefix } from './createActor-
|
|
1
|
+
import { a3 as createInertActorScope, a4 as setInertActorScopeSnapshot, F as finalizeTransitionResult, a6 as attachSnapshotActorRef, y as createInitEvent, av as hasAmbientInspector, a5 as beginSpawnAllocation, a7 as macrostep, ak as createSpawnEffect, al as initialMicrostep, i as isAtomicStateNode, aw as getProperAncestors, ax as isRemoteActorRef, ay as getActorIdPrefix } from './createActor-6fa87eea.esm.js';
|
|
2
2
|
|
|
3
3
|
function attachMicrostepActorRefs(microsteps, actorScope, inputSnapshot) {
|
|
4
4
|
if (!microsteps.length) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a3 as createInertActorScope, a4 as setInertActorScopeSnapshot, F as finalizeTransitionResult, a6 as attachSnapshotActorRef, y as createInitEvent, av as hasAmbientInspector, a5 as beginSpawnAllocation, a7 as macrostep, ak as createSpawnEffect, al as initialMicrostep, i as isAtomicStateNode, aw as getProperAncestors, ax as isRemoteActorRef, ay as getActorIdPrefix } from './createActor-
|
|
1
|
+
import { a3 as createInertActorScope, a4 as setInertActorScopeSnapshot, F as finalizeTransitionResult, a6 as attachSnapshotActorRef, y as createInitEvent, av as hasAmbientInspector, a5 as beginSpawnAllocation, a7 as macrostep, ak as createSpawnEffect, al as initialMicrostep, i as isAtomicStateNode, aw as getProperAncestors, ax as isRemoteActorRef, ay as getActorIdPrefix } from './createActor-41e3bbc3.development.esm.js';
|
|
2
2
|
|
|
3
3
|
function attachMicrostepActorRefs(microsteps, actorScope, inputSnapshot) {
|
|
4
4
|
if (!microsteps.length) {
|
package/dist/{schema.types-6c3a61af.development.esm.js → schema.types-1b4319f7.development.esm.js}
RENAMED
|
@@ -76,13 +76,15 @@ function createFSM(config) {
|
|
|
76
76
|
* context: types<{ count: number }>(),
|
|
77
77
|
* events: {
|
|
78
78
|
* inc: types<{ by: number }>(),
|
|
79
|
-
* reset: types<
|
|
79
|
+
* reset: types<void>()
|
|
80
80
|
* }
|
|
81
81
|
* },
|
|
82
82
|
* context: { count: 0 }
|
|
83
83
|
* // ...
|
|
84
84
|
* });
|
|
85
85
|
* ```
|
|
86
|
+
*
|
|
87
|
+
* Use `types<void>()` for events without a payload.
|
|
86
88
|
*/
|
|
87
89
|
function types() {
|
|
88
90
|
return {
|
|
@@ -78,13 +78,15 @@ function createFSM(config) {
|
|
|
78
78
|
* context: types<{ count: number }>(),
|
|
79
79
|
* events: {
|
|
80
80
|
* inc: types<{ by: number }>(),
|
|
81
|
-
* reset: types<
|
|
81
|
+
* reset: types<void>()
|
|
82
82
|
* }
|
|
83
83
|
* },
|
|
84
84
|
* context: { count: 0 }
|
|
85
85
|
* // ...
|
|
86
86
|
* });
|
|
87
87
|
* ```
|
|
88
|
+
*
|
|
89
|
+
* Use `types<void>()` for events without a payload.
|
|
88
90
|
*/
|
|
89
91
|
function types() {
|
|
90
92
|
return {
|
|
@@ -76,13 +76,15 @@ function createFSM(config) {
|
|
|
76
76
|
* context: types<{ count: number }>(),
|
|
77
77
|
* events: {
|
|
78
78
|
* inc: types<{ by: number }>(),
|
|
79
|
-
* reset: types<
|
|
79
|
+
* reset: types<void>()
|
|
80
80
|
* }
|
|
81
81
|
* },
|
|
82
82
|
* context: { count: 0 }
|
|
83
83
|
* // ...
|
|
84
84
|
* });
|
|
85
85
|
* ```
|
|
86
|
+
*
|
|
87
|
+
* Use `types<void>()` for events without a payload.
|
|
86
88
|
*/
|
|
87
89
|
function types() {
|
|
88
90
|
return {
|
package/dist/{schema.types-e396f88c.development.cjs.js → schema.types-a2b10853.development.cjs.js}
RENAMED
|
@@ -78,13 +78,15 @@ function createFSM(config) {
|
|
|
78
78
|
* context: types<{ count: number }>(),
|
|
79
79
|
* events: {
|
|
80
80
|
* inc: types<{ by: number }>(),
|
|
81
|
-
* reset: types<
|
|
81
|
+
* reset: types<void>()
|
|
82
82
|
* }
|
|
83
83
|
* },
|
|
84
84
|
* context: { count: 0 }
|
|
85
85
|
* // ...
|
|
86
86
|
* });
|
|
87
87
|
* ```
|
|
88
|
+
*
|
|
89
|
+
* Use `types<void>()` for events without a payload.
|
|
88
90
|
*/
|
|
89
91
|
function types() {
|
|
90
92
|
return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var createActor = require('./createActor-
|
|
3
|
+
var createActor = require('./createActor-20277025.cjs.js');
|
|
4
4
|
var validation = require('./validation-4561b43c.cjs.js');
|
|
5
5
|
|
|
6
6
|
function createSpawner(actorScope, actors, spawnedChildren) {
|
|
@@ -1232,5 +1232,195 @@ class StateMachine {
|
|
|
1232
1232
|
}
|
|
1233
1233
|
}
|
|
1234
1234
|
|
|
1235
|
+
/**
|
|
1236
|
+
* Creates a state machine (statechart) with the given configuration.
|
|
1237
|
+
*
|
|
1238
|
+
* The state machine represents the pure logic of a state machine actor.
|
|
1239
|
+
*
|
|
1240
|
+
* @example
|
|
1241
|
+
*
|
|
1242
|
+
* ```ts
|
|
1243
|
+
* import { createMachine } from 'xstate';
|
|
1244
|
+
*
|
|
1245
|
+
* const lightMachine = createMachine({
|
|
1246
|
+
* id: 'light',
|
|
1247
|
+
* initial: 'green',
|
|
1248
|
+
* states: {
|
|
1249
|
+
* green: {
|
|
1250
|
+
* on: {
|
|
1251
|
+
* TIMER: { target: 'yellow' }
|
|
1252
|
+
* }
|
|
1253
|
+
* },
|
|
1254
|
+
* yellow: {
|
|
1255
|
+
* on: {
|
|
1256
|
+
* TIMER: { target: 'red' }
|
|
1257
|
+
* }
|
|
1258
|
+
* },
|
|
1259
|
+
* red: {
|
|
1260
|
+
* on: {
|
|
1261
|
+
* TIMER: { target: 'green' }
|
|
1262
|
+
* }
|
|
1263
|
+
* }
|
|
1264
|
+
* }
|
|
1265
|
+
* });
|
|
1266
|
+
*
|
|
1267
|
+
* const lightActor = createActor(lightMachine);
|
|
1268
|
+
* lightActor.start();
|
|
1269
|
+
*
|
|
1270
|
+
* lightActor.send({ type: 'TIMER' });
|
|
1271
|
+
* ```
|
|
1272
|
+
*
|
|
1273
|
+
* @param config The state machine configuration.
|
|
1274
|
+
* @param options DEPRECATED: use `setup({ ... })` or `machine.provide({ ... })`
|
|
1275
|
+
* to provide machine sources instead.
|
|
1276
|
+
*/
|
|
1277
|
+
// Overload 1: With schemas.context — context type inferred from schema
|
|
1278
|
+
|
|
1279
|
+
// Overload 2: Without schemas.context — context type inferred from config.context
|
|
1280
|
+
|
|
1281
|
+
// Implementation
|
|
1282
|
+
function createMachine(config) {
|
|
1283
|
+
return new StateMachine(config);
|
|
1284
|
+
}
|
|
1285
|
+
function createStateConfig(config) {
|
|
1286
|
+
return config;
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
// this is needed to make JSDoc `@link` work properly
|
|
1290
|
+
// oxlint-disable-next-line no-unused-vars
|
|
1291
|
+
|
|
1292
|
+
/**
|
|
1293
|
+
* @remarks
|
|
1294
|
+
* `T | unknown` reduces to `unknown` and that can be problematic when it comes
|
|
1295
|
+
* to contextual typing. It especially is a problem when the union has a
|
|
1296
|
+
* function member, like here:
|
|
1297
|
+
*
|
|
1298
|
+
* ```ts
|
|
1299
|
+
* declare function test(
|
|
1300
|
+
* cbOrVal: ((arg: number) => unknown) | unknown
|
|
1301
|
+
* ): void;
|
|
1302
|
+
* test((arg) => {}); // oops, implicit any
|
|
1303
|
+
* ```
|
|
1304
|
+
*
|
|
1305
|
+
* This type can be used to avoid this problem. This union represents the same
|
|
1306
|
+
* value space as `unknown`.
|
|
1307
|
+
*/
|
|
1308
|
+
|
|
1309
|
+
// https://github.com/microsoft/TypeScript/issues/23182#issuecomment-379091887
|
|
1310
|
+
|
|
1311
|
+
// @TODO: we can't use native `NoInfer` as we need those:
|
|
1312
|
+
// https://github.com/microsoft/TypeScript/pull/61092
|
|
1313
|
+
// https://github.com/microsoft/TypeScript/pull/61077
|
|
1314
|
+
// but even with those fixes native NoInfer still doesn't work - further issues have to be reproduced and fixed
|
|
1315
|
+
|
|
1316
|
+
/** @deprecated Use the built-in `NoInfer` type instead */
|
|
1317
|
+
|
|
1318
|
+
/** The full definition of an event, with a string `type`. */
|
|
1319
|
+
|
|
1320
|
+
/**
|
|
1321
|
+
* The string or object representing the state value relative to the parent
|
|
1322
|
+
* state node.
|
|
1323
|
+
*
|
|
1324
|
+
* @remarks
|
|
1325
|
+
* - For a child atomic state node, this is a string, e.g., `"pending"`.
|
|
1326
|
+
* - For complex state nodes, this is an object, e.g., `{ success:
|
|
1327
|
+
* "someChildState" }`.
|
|
1328
|
+
*/
|
|
1329
|
+
|
|
1330
|
+
// Accept any StateNode instance regardless of generic parameters
|
|
1331
|
+
// Using a union type to handle variance issues with machine.resolveState
|
|
1332
|
+
|
|
1333
|
+
let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
|
|
1334
|
+
SpecialTargets["Internal"] = "#_internal";
|
|
1335
|
+
return SpecialTargets;
|
|
1336
|
+
}({});
|
|
1337
|
+
|
|
1338
|
+
/** A deterministic delayed-delivery declaration owned by a logic snapshot. */
|
|
1339
|
+
|
|
1340
|
+
/** The logical input delivered to a timer's source when its runtime delay ends. */
|
|
1341
|
+
|
|
1342
|
+
/** A persisted snapshot tied to a versioned actor logic identity. */
|
|
1343
|
+
|
|
1344
|
+
/**
|
|
1345
|
+
* A persisted snapshot restorable into the given actor logic: any snapshot
|
|
1346
|
+
* created by logic with the same machine `id` is accepted, regardless of
|
|
1347
|
+
* version (version mismatches are handled at runtime, e.g. by `migrate`).
|
|
1348
|
+
*/
|
|
1349
|
+
|
|
1350
|
+
/** @deprecated Use `AnyActor` instead. */
|
|
1351
|
+
|
|
1352
|
+
// Based on RxJS types
|
|
1353
|
+
|
|
1354
|
+
/**
|
|
1355
|
+
* A consumer-facing actor handle.
|
|
1356
|
+
*
|
|
1357
|
+
* `ActorRef` describes the contract a consumer needs: which events can be sent
|
|
1358
|
+
* to the actor, which snapshot it publishes for observation, and which emitted
|
|
1359
|
+
* events can be listened to. It intentionally does not expose lifecycle control
|
|
1360
|
+
* or runtime internals. A concrete `Actor` satisfies this interface, so APIs
|
|
1361
|
+
* should accept `ActorRef` whenever they only need to send events, read
|
|
1362
|
+
* snapshots, or listen to emitted events.
|
|
1363
|
+
*/
|
|
1364
|
+
|
|
1365
|
+
/**
|
|
1366
|
+
* Runtime-only actor capabilities.
|
|
1367
|
+
*
|
|
1368
|
+
* These members are needed by the interpreter, scheduler, inspection, and child
|
|
1369
|
+
* management code. Public consumer APIs should prefer `ActorRef` unless they
|
|
1370
|
+
* genuinely need lifecycle control such as starting, stopping, or accessing
|
|
1371
|
+
* system-owned runtime state.
|
|
1372
|
+
*/
|
|
1373
|
+
|
|
1374
|
+
/**
|
|
1375
|
+
* A concrete actor instance type.
|
|
1376
|
+
*
|
|
1377
|
+
* `ActorInstance` combines the consumer `ActorRef` contract with runtime
|
|
1378
|
+
* lifecycle capabilities. Values returned by `createActor(...)` and
|
|
1379
|
+
* `spawn(...)` naturally satisfy narrower `ActorRef` contracts.
|
|
1380
|
+
*/
|
|
1381
|
+
|
|
1382
|
+
/**
|
|
1383
|
+
* The actor's own full self handle.
|
|
1384
|
+
*
|
|
1385
|
+
* Internals and action/guard sources receive this shape because `self` can
|
|
1386
|
+
* participate in runtime-owned behavior while still being usable wherever an
|
|
1387
|
+
* `ActorRef` is expected.
|
|
1388
|
+
*/
|
|
1389
|
+
|
|
1390
|
+
// TODO: in v6, this should only accept AnyActorLogic, like ActorRefFromLogic
|
|
1391
|
+
|
|
1392
|
+
/** The concrete actor instance type produced from actor logic. */
|
|
1393
|
+
|
|
1394
|
+
/**
|
|
1395
|
+
* Represents logic which can be used by an actor.
|
|
1396
|
+
*
|
|
1397
|
+
* @template TSnapshot - The type of the snapshot.
|
|
1398
|
+
* @template TEvent - The type of the event object.
|
|
1399
|
+
* @template TInput - The type of the input.
|
|
1400
|
+
* @template TSystem - The type of the actor system.
|
|
1401
|
+
*/
|
|
1402
|
+
|
|
1403
|
+
// Actors that don't have literal string IDs — these are the only ones
|
|
1404
|
+
// that should appear in the index signature fallback, since actors with
|
|
1405
|
+
// literal IDs are already covered by ToConcreteChildren.
|
|
1406
|
+
|
|
1407
|
+
/** Maps state IDs to their input types based on the StateSchema. */
|
|
1408
|
+
|
|
1409
|
+
/** @deprecated */
|
|
1410
|
+
|
|
1411
|
+
/** The terminal result published when an actor completes or errors. */
|
|
1412
|
+
|
|
1413
|
+
/** An executable effect that publishes an actor's terminal result. */
|
|
1414
|
+
|
|
1415
|
+
/**
|
|
1416
|
+
* An executable effect that reports an event rejected at the delivery boundary
|
|
1417
|
+
* (a dead letter). The snapshot paired with this effect is unchanged.
|
|
1418
|
+
*/
|
|
1419
|
+
|
|
1420
|
+
/** Mappers for subscribeTo - maps lifecycle events to machine events */
|
|
1421
|
+
|
|
1422
|
+
exports.SpecialTargets = SpecialTargets;
|
|
1235
1423
|
exports.StateMachine = StateMachine;
|
|
1236
1424
|
exports.StateNode = StateNode;
|
|
1425
|
+
exports.createMachine = createMachine;
|
|
1426
|
+
exports.createStateConfig = createStateConfig;
|