xstate 4.20.1 → 4.23.1
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/CHANGELOG.md +134 -0
- package/dist/xstate.interpreter.js +1 -1
- package/dist/xstate.js +1 -1
- package/dist/xstate.web.js +2 -2
- package/es/Actor.js +17 -5
- package/es/Machine.d.ts +6 -3
- package/es/Machine.js +3 -6
- package/es/State.js +1 -3
- package/es/StateNode.d.ts +4 -3
- package/es/StateNode.js +34 -20
- package/es/_virtual/_tslib.js +59 -73
- package/es/actionTypes.js +3 -2
- package/es/actions.d.ts +1 -1
- package/es/actions.js +51 -37
- package/es/behaviors.d.ts +37 -0
- package/es/behaviors.js +65 -0
- package/es/constants.js +2 -1
- package/es/devTools.js +1 -1
- package/es/environment.js +2 -1
- package/es/index.js +3 -1
- package/es/interpreter.d.ts +10 -3
- package/es/interpreter.js +44 -22
- package/es/invokeUtils.js +4 -3
- package/es/mapState.js +1 -1
- package/es/match.js +1 -1
- package/es/model.d.ts +2 -36
- package/es/model.types.d.ts +37 -0
- package/es/registry.js +2 -1
- package/es/scheduler.js +2 -1
- package/es/schema.js +1 -1
- package/es/serviceScope.js +1 -3
- package/es/stateUtils.js +1 -9
- package/es/types.d.ts +26 -5
- package/es/types.js +1 -1
- package/es/utils.d.ts +3 -2
- package/es/utils.js +4 -40
- package/lib/Actor.d.ts +25 -25
- package/lib/Actor.js +85 -66
- package/lib/Machine.d.ts +17 -14
- package/lib/Machine.js +14 -14
- package/lib/SimulatedClock.d.ts +16 -16
- package/lib/State.d.ts +108 -108
- package/lib/State.js +246 -236
- package/lib/StateNode.d.ts +279 -278
- package/lib/StateNode.js +1535 -1339
- package/lib/_virtual/_tslib.js +81 -0
- package/lib/actionTypes.d.ts +19 -19
- package/lib/actionTypes.js +43 -23
- package/lib/actions.d.ts +138 -138
- package/lib/actions.js +465 -387
- package/lib/behaviors.d.ts +37 -0
- package/lib/behaviors.js +69 -0
- package/lib/constants.d.ts +5 -5
- package/lib/constants.js +13 -7
- package/lib/devTools.d.ts +15 -15
- package/lib/devTools.js +37 -26
- package/lib/each.d.ts +3 -3
- package/lib/environment.d.ts +1 -1
- package/lib/environment.js +7 -4
- package/lib/index.d.ts +30 -30
- package/lib/index.js +67 -57
- package/lib/interpreter.d.ts +205 -198
- package/lib/interpreter.js +1306 -1054
- package/lib/invoke.d.ts +10 -10
- package/lib/invokeUtils.d.ts +6 -6
- package/lib/invokeUtils.js +40 -37
- package/lib/json.d.ts +30 -30
- package/lib/mapState.d.ts +3 -3
- package/lib/mapState.js +31 -32
- package/lib/match.d.ts +8 -8
- package/lib/match.js +33 -47
- package/lib/model.d.ts +4 -38
- package/lib/model.js +5 -1
- package/lib/model.types.d.ts +37 -0
- package/lib/model.types.js +2 -0
- package/lib/patterns.d.ts +13 -13
- package/lib/registry.d.ts +8 -8
- package/lib/registry.js +21 -18
- package/lib/scheduler.d.ts +16 -16
- package/lib/scheduler.js +79 -70
- package/lib/schema.d.ts +1 -1
- package/lib/schema.js +6 -4
- package/lib/scxml.d.ts +5 -5
- package/lib/serviceScope.d.ts +3 -3
- package/lib/serviceScope.js +16 -12
- package/lib/stateUtils.d.ts +14 -14
- package/lib/stateUtils.js +231 -199
- package/lib/types.d.ts +928 -907
- package/lib/types.js +29 -29
- package/lib/utils.d.ts +68 -67
- package/lib/utils.js +530 -529
- package/package.json +6 -6
package/lib/Actor.js
CHANGED
|
@@ -1,80 +1,99 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.toActorRef = exports.isSpawnedActor = exports.isActor = exports.createDeferredActor = exports.createInvocableActor = exports.createNullActor = void 0;
|
|
15
|
-
var utils_1 = require("./utils");
|
|
16
|
-
var serviceScope = require("./serviceScope");
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _tslib = require('./_virtual/_tslib.js');
|
|
6
|
+
var utils = require('./utils.js');
|
|
7
|
+
var serviceScope = require('./serviceScope.js');
|
|
8
|
+
|
|
17
9
|
function createNullActor(id) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
10
|
+
return {
|
|
11
|
+
id: id,
|
|
12
|
+
send: function () {
|
|
13
|
+
return void 0;
|
|
14
|
+
},
|
|
15
|
+
subscribe: function () {
|
|
16
|
+
return {
|
|
17
|
+
unsubscribe: function () {
|
|
18
|
+
return void 0;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
getSnapshot: function () {
|
|
23
|
+
return undefined;
|
|
24
|
+
},
|
|
25
|
+
toJSON: function () {
|
|
26
|
+
return {
|
|
27
|
+
id: id
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
};
|
|
29
31
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* @param invokeDefinition The meta information needed to invoke the actor.
|
|
32
|
+
/**
|
|
33
|
+
* Creates a deferred actor that is able to be invoked given the provided
|
|
34
|
+
* invocation information in its `.meta` value.
|
|
35
|
+
*
|
|
36
|
+
* @param invokeDefinition The meta information needed to invoke the actor.
|
|
36
37
|
*/
|
|
38
|
+
|
|
37
39
|
function createInvocableActor(invokeDefinition, machine, context, _event) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
// @ts-ignore
|
|
48
|
-
tempActor.meta = invokeDefinition;
|
|
49
|
-
return tempActor;
|
|
40
|
+
var _a;
|
|
41
|
+
|
|
42
|
+
var invokeSrc = utils.toInvokeSource(invokeDefinition.src);
|
|
43
|
+
var serviceCreator = (_a = machine === null || machine === void 0 ? void 0 : machine.options.services) === null || _a === void 0 ? void 0 : _a[invokeSrc.type];
|
|
44
|
+
var resolvedData = invokeDefinition.data ? utils.mapContext(invokeDefinition.data, context, _event) : undefined;
|
|
45
|
+
var tempActor = serviceCreator ? createDeferredActor(serviceCreator, invokeDefinition.id, resolvedData) : createNullActor(invokeDefinition.id); // @ts-ignore
|
|
46
|
+
|
|
47
|
+
tempActor.meta = invokeDefinition;
|
|
48
|
+
return tempActor;
|
|
50
49
|
}
|
|
51
|
-
exports.createInvocableActor = createInvocableActor;
|
|
52
50
|
function createDeferredActor(entity, id, data) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
51
|
+
var tempActor = createNullActor(id); // @ts-ignore
|
|
52
|
+
|
|
53
|
+
tempActor.deferred = true;
|
|
54
|
+
|
|
55
|
+
if (utils.isMachine(entity)) {
|
|
56
|
+
// "mute" the existing service scope so potential spawned actors within the `.initialState` stay deferred here
|
|
57
|
+
var initialState_1 = tempActor.state = serviceScope.provide(undefined, function () {
|
|
58
|
+
return (data ? entity.withContext(data) : entity).initialState;
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
tempActor.getSnapshot = function () {
|
|
62
|
+
return initialState_1;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return tempActor;
|
|
62
67
|
}
|
|
63
|
-
exports.createDeferredActor = createDeferredActor;
|
|
64
68
|
function isActor(item) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
69
|
+
try {
|
|
70
|
+
return typeof item.send === 'function';
|
|
71
|
+
} catch (e) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
71
74
|
}
|
|
72
|
-
exports.isActor = isActor;
|
|
73
75
|
function isSpawnedActor(item) {
|
|
74
|
-
|
|
76
|
+
return isActor(item) && 'id' in item;
|
|
75
77
|
}
|
|
76
|
-
exports.isSpawnedActor = isSpawnedActor;
|
|
77
78
|
function toActorRef(actorRefLike) {
|
|
78
|
-
|
|
79
|
+
return _tslib.__assign({
|
|
80
|
+
subscribe: function () {
|
|
81
|
+
return {
|
|
82
|
+
unsubscribe: function () {
|
|
83
|
+
return void 0;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
},
|
|
87
|
+
id: 'anonymous',
|
|
88
|
+
getSnapshot: function () {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
}, actorRefLike);
|
|
79
92
|
}
|
|
93
|
+
|
|
94
|
+
exports.createDeferredActor = createDeferredActor;
|
|
95
|
+
exports.createInvocableActor = createInvocableActor;
|
|
96
|
+
exports.createNullActor = createNullActor;
|
|
97
|
+
exports.isActor = isActor;
|
|
98
|
+
exports.isSpawnedActor = isSpawnedActor;
|
|
80
99
|
exports.toActorRef = toActorRef;
|
package/lib/Machine.d.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import { StateMachine, MachineOptions, DefaultContext, MachineConfig, StateSchema, EventObject, AnyEventObject, Typestate } from './types';
|
|
2
|
-
import { Model, ModelContextFrom
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { StateMachine, MachineOptions, DefaultContext, MachineConfig, StateSchema, EventObject, AnyEventObject, Typestate, EventFrom } from './types';
|
|
2
|
+
import { Model, ModelContextFrom } from './model.types';
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Use `createMachine(...)` instead.
|
|
5
|
+
*/
|
|
6
|
+
export declare function Machine<TContext = any, TEvent extends EventObject = AnyEventObject>(config: MachineConfig<TContext, any, TEvent>, options?: Partial<MachineOptions<TContext, TEvent>>, initialContext?: TContext): StateMachine<TContext, any, TEvent>;
|
|
7
|
+
export declare function Machine<TContext = DefaultContext, TStateSchema extends StateSchema = any, TEvent extends EventObject = AnyEventObject>(config: MachineConfig<TContext, TStateSchema, TEvent>, options?: Partial<MachineOptions<TContext, TEvent>>, initialContext?: TContext): StateMachine<TContext, TStateSchema, TEvent>;
|
|
8
|
+
export declare function createMachine<TModel extends Model<any, any, any>, TContext = ModelContextFrom<TModel>, TEvent extends EventObject = EventFrom<TModel>, TTypestate extends Typestate<TContext> = {
|
|
9
|
+
value: any;
|
|
10
|
+
context: TContext;
|
|
11
|
+
}>(config: MachineConfig<TContext, any, TEvent> & {
|
|
12
|
+
context: TContext;
|
|
13
|
+
}, options?: Partial<MachineOptions<TContext, TEvent>>): StateMachine<TContext, any, TEvent, TTypestate>;
|
|
14
|
+
export declare function createMachine<TContext, TEvent extends EventObject = AnyEventObject, TTypestate extends Typestate<TContext> = {
|
|
15
|
+
value: any;
|
|
16
|
+
context: TContext;
|
|
17
|
+
}>(config: TContext extends Model<any, any, any> ? never : MachineConfig<TContext, any, TEvent>, options?: Partial<MachineOptions<TContext, TEvent>>): StateMachine<TContext, any, TEvent, TTypestate>;
|
|
15
18
|
//# sourceMappingURL=Machine.d.ts.map
|
package/lib/Machine.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports
|
|
4
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var StateNode = require('./StateNode.js');
|
|
6
|
+
|
|
5
7
|
function Machine(config, options, initialContext) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
if (initialContext === void 0) {
|
|
9
|
+
initialContext = config.context;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return new StateNode.StateNode(config, options, initialContext);
|
|
11
13
|
}
|
|
12
|
-
exports.Machine = Machine;
|
|
13
14
|
function createMachine(config, options) {
|
|
14
|
-
|
|
15
|
-
? config.context()
|
|
16
|
-
: config.context;
|
|
17
|
-
return new StateNode_1.StateNode(config, options, resolvedInitialContext);
|
|
15
|
+
return new StateNode.StateNode(config, options);
|
|
18
16
|
}
|
|
17
|
+
|
|
18
|
+
exports.Machine = Machine;
|
|
19
19
|
exports.createMachine = createMachine;
|
package/lib/SimulatedClock.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Clock } from './interpreter';
|
|
2
|
-
export interface SimulatedClock extends Clock {
|
|
3
|
-
start(speed: number): void;
|
|
4
|
-
increment(ms: number): void;
|
|
5
|
-
set(ms: number): void;
|
|
6
|
-
}
|
|
7
|
-
export declare class SimulatedClock implements SimulatedClock {
|
|
8
|
-
private timeouts;
|
|
9
|
-
private _now;
|
|
10
|
-
private _id;
|
|
11
|
-
now(): number;
|
|
12
|
-
private getId;
|
|
13
|
-
setTimeout(fn: (...args: any[]) => void, timeout: number): number;
|
|
14
|
-
clearTimeout(id: number): void;
|
|
15
|
-
private flushTimeouts;
|
|
16
|
-
}
|
|
1
|
+
import { Clock } from './interpreter';
|
|
2
|
+
export interface SimulatedClock extends Clock {
|
|
3
|
+
start(speed: number): void;
|
|
4
|
+
increment(ms: number): void;
|
|
5
|
+
set(ms: number): void;
|
|
6
|
+
}
|
|
7
|
+
export declare class SimulatedClock implements SimulatedClock {
|
|
8
|
+
private timeouts;
|
|
9
|
+
private _now;
|
|
10
|
+
private _id;
|
|
11
|
+
now(): number;
|
|
12
|
+
private getId;
|
|
13
|
+
setTimeout(fn: (...args: any[]) => void, timeout: number): number;
|
|
14
|
+
clearTimeout(id: number): void;
|
|
15
|
+
private flushTimeouts;
|
|
16
|
+
}
|
|
17
17
|
//# sourceMappingURL=SimulatedClock.d.ts.map
|
package/lib/State.d.ts
CHANGED
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
import { StateValue, ActivityMap, EventObject, HistoryValue, ActionObject, EventType, StateConfig, SCXML, StateSchema, TransitionDefinition, Typestate, ActorRef } from './types';
|
|
2
|
-
import { StateNode } from './StateNode';
|
|
3
|
-
export declare function stateValuesEqual(a: StateValue | undefined, b: StateValue | undefined): boolean;
|
|
4
|
-
export declare function isState<TContext, TEvent extends EventObject, TStateSchema extends StateSchema<TContext> = any, TTypestate extends Typestate<TContext> = {
|
|
5
|
-
value: any;
|
|
6
|
-
context: TContext;
|
|
7
|
-
}>(state: object | string): state is State<TContext, TEvent, TStateSchema, TTypestate>;
|
|
8
|
-
export declare function bindActionToState<TC, TE extends EventObject>(action: ActionObject<TC, TE>, state: State<TC, TE, any, any>): ActionObject<TC, TE>;
|
|
9
|
-
export declare class State<TContext, TEvent extends EventObject = EventObject, TStateSchema extends StateSchema<TContext> = any, TTypestate extends Typestate<TContext> = {
|
|
10
|
-
value: any;
|
|
11
|
-
context: TContext;
|
|
12
|
-
}> {
|
|
13
|
-
value: StateValue;
|
|
14
|
-
context: TContext;
|
|
15
|
-
historyValue?: HistoryValue | undefined;
|
|
16
|
-
history?: State<TContext, TEvent, TStateSchema, TTypestate>;
|
|
17
|
-
actions: Array<ActionObject<TContext, TEvent>>;
|
|
18
|
-
activities: ActivityMap;
|
|
19
|
-
meta: any;
|
|
20
|
-
events: TEvent[];
|
|
21
|
-
event: TEvent;
|
|
22
|
-
_event: SCXML.Event<TEvent>;
|
|
23
|
-
_sessionid: string | null;
|
|
24
|
-
/**
|
|
25
|
-
* Indicates whether the state has changed from the previous state. A state is considered "changed" if:
|
|
26
|
-
*
|
|
27
|
-
* - Its value is not equal to its previous value, or:
|
|
28
|
-
* - It has any new actions (side-effects) to execute.
|
|
29
|
-
*
|
|
30
|
-
* An initial state (with no history) will return `undefined`.
|
|
31
|
-
*/
|
|
32
|
-
changed: boolean | undefined;
|
|
33
|
-
/**
|
|
34
|
-
* Indicates whether the state is a final state.
|
|
35
|
-
*/
|
|
36
|
-
done: boolean | undefined;
|
|
37
|
-
/**
|
|
38
|
-
* The enabled state nodes representative of the state value.
|
|
39
|
-
*/
|
|
40
|
-
configuration: Array<StateNode<TContext, any, TEvent, any>>;
|
|
41
|
-
/**
|
|
42
|
-
* The next events that will cause a transition from the current state.
|
|
43
|
-
*/
|
|
44
|
-
nextEvents: EventType[];
|
|
45
|
-
/**
|
|
46
|
-
* The transition definitions that resulted in this state.
|
|
47
|
-
*/
|
|
48
|
-
transitions: Array<TransitionDefinition<TContext, TEvent>>;
|
|
49
|
-
/**
|
|
50
|
-
* An object mapping actor IDs to spawned actors/invoked services.
|
|
51
|
-
*/
|
|
52
|
-
children: Record<string, ActorRef<any>>;
|
|
53
|
-
tags: Set<string>;
|
|
54
|
-
/**
|
|
55
|
-
* Creates a new State instance for the given `stateValue` and `context`.
|
|
56
|
-
* @param stateValue
|
|
57
|
-
* @param context
|
|
58
|
-
*/
|
|
59
|
-
static from<TC, TE extends EventObject = EventObject>(stateValue: State<TC, TE, any, any> | StateValue, context?: TC | undefined): State<TC, TE, any, any>;
|
|
60
|
-
/**
|
|
61
|
-
* Creates a new State instance for the given `config`.
|
|
62
|
-
* @param config The state config
|
|
63
|
-
*/
|
|
64
|
-
static create<TC, TE extends EventObject = EventObject>(config: StateConfig<TC, TE>): State<TC, TE>;
|
|
65
|
-
/**
|
|
66
|
-
* Creates a new `State` instance for the given `stateValue` and `context` with no actions (side-effects).
|
|
67
|
-
* @param stateValue
|
|
68
|
-
* @param context
|
|
69
|
-
*/
|
|
70
|
-
static inert<TC, TE extends EventObject = EventObject>(stateValue: State<TC, TE> | StateValue, context: TC): State<TC, TE>;
|
|
71
|
-
/**
|
|
72
|
-
* Creates a new State instance.
|
|
73
|
-
* @param value The state value
|
|
74
|
-
* @param context The extended state
|
|
75
|
-
* @param historyValue The tree representing historical values of the state nodes
|
|
76
|
-
* @param history The previous state
|
|
77
|
-
* @param actions An array of action objects to execute as side-effects
|
|
78
|
-
* @param activities A mapping of activities and whether they are started (`true`) or stopped (`false`).
|
|
79
|
-
* @param meta
|
|
80
|
-
* @param events Internal event queue. Should be empty with run-to-completion semantics.
|
|
81
|
-
* @param configuration
|
|
82
|
-
*/
|
|
83
|
-
constructor(config: StateConfig<TContext, TEvent>);
|
|
84
|
-
/**
|
|
85
|
-
* Returns an array of all the string leaf state node paths.
|
|
86
|
-
* @param stateValue
|
|
87
|
-
* @param delimiter The character(s) that separate each subpath in the string state node path.
|
|
88
|
-
*/
|
|
89
|
-
toStrings(stateValue?: StateValue, delimiter?: string): string[];
|
|
90
|
-
toJSON(): Omit<this, "configuration" | "transitions" | "tags"> & {
|
|
91
|
-
tags: string[];
|
|
92
|
-
};
|
|
93
|
-
/**
|
|
94
|
-
* Whether the current state value is a subset of the given parent state value.
|
|
95
|
-
* @param parentStateValue
|
|
96
|
-
*/
|
|
97
|
-
matches<TSV extends TTypestate['value']>(parentStateValue: TSV): this is State<(TTypestate extends any ? {
|
|
98
|
-
value: TSV;
|
|
99
|
-
context: any;
|
|
100
|
-
} extends TTypestate ? TTypestate : never : never)['context'], TEvent, TStateSchema, TTypestate> & {
|
|
101
|
-
value: TSV;
|
|
102
|
-
};
|
|
103
|
-
/**
|
|
104
|
-
* Whether the current state configuration has a state node with the specified `tag`.
|
|
105
|
-
* @param tag
|
|
106
|
-
*/
|
|
107
|
-
hasTag(tag: string): boolean;
|
|
108
|
-
}
|
|
1
|
+
import { StateValue, ActivityMap, EventObject, HistoryValue, ActionObject, EventType, StateConfig, SCXML, StateSchema, TransitionDefinition, Typestate, ActorRef } from './types';
|
|
2
|
+
import { StateNode } from './StateNode';
|
|
3
|
+
export declare function stateValuesEqual(a: StateValue | undefined, b: StateValue | undefined): boolean;
|
|
4
|
+
export declare function isState<TContext, TEvent extends EventObject, TStateSchema extends StateSchema<TContext> = any, TTypestate extends Typestate<TContext> = {
|
|
5
|
+
value: any;
|
|
6
|
+
context: TContext;
|
|
7
|
+
}>(state: object | string): state is State<TContext, TEvent, TStateSchema, TTypestate>;
|
|
8
|
+
export declare function bindActionToState<TC, TE extends EventObject>(action: ActionObject<TC, TE>, state: State<TC, TE, any, any>): ActionObject<TC, TE>;
|
|
9
|
+
export declare class State<TContext, TEvent extends EventObject = EventObject, TStateSchema extends StateSchema<TContext> = any, TTypestate extends Typestate<TContext> = {
|
|
10
|
+
value: any;
|
|
11
|
+
context: TContext;
|
|
12
|
+
}> {
|
|
13
|
+
value: StateValue;
|
|
14
|
+
context: TContext;
|
|
15
|
+
historyValue?: HistoryValue | undefined;
|
|
16
|
+
history?: State<TContext, TEvent, TStateSchema, TTypestate>;
|
|
17
|
+
actions: Array<ActionObject<TContext, TEvent>>;
|
|
18
|
+
activities: ActivityMap;
|
|
19
|
+
meta: any;
|
|
20
|
+
events: TEvent[];
|
|
21
|
+
event: TEvent;
|
|
22
|
+
_event: SCXML.Event<TEvent>;
|
|
23
|
+
_sessionid: string | null;
|
|
24
|
+
/**
|
|
25
|
+
* Indicates whether the state has changed from the previous state. A state is considered "changed" if:
|
|
26
|
+
*
|
|
27
|
+
* - Its value is not equal to its previous value, or:
|
|
28
|
+
* - It has any new actions (side-effects) to execute.
|
|
29
|
+
*
|
|
30
|
+
* An initial state (with no history) will return `undefined`.
|
|
31
|
+
*/
|
|
32
|
+
changed: boolean | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Indicates whether the state is a final state.
|
|
35
|
+
*/
|
|
36
|
+
done: boolean | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* The enabled state nodes representative of the state value.
|
|
39
|
+
*/
|
|
40
|
+
configuration: Array<StateNode<TContext, any, TEvent, any>>;
|
|
41
|
+
/**
|
|
42
|
+
* The next events that will cause a transition from the current state.
|
|
43
|
+
*/
|
|
44
|
+
nextEvents: EventType[];
|
|
45
|
+
/**
|
|
46
|
+
* The transition definitions that resulted in this state.
|
|
47
|
+
*/
|
|
48
|
+
transitions: Array<TransitionDefinition<TContext, TEvent>>;
|
|
49
|
+
/**
|
|
50
|
+
* An object mapping actor IDs to spawned actors/invoked services.
|
|
51
|
+
*/
|
|
52
|
+
children: Record<string, ActorRef<any>>;
|
|
53
|
+
tags: Set<string>;
|
|
54
|
+
/**
|
|
55
|
+
* Creates a new State instance for the given `stateValue` and `context`.
|
|
56
|
+
* @param stateValue
|
|
57
|
+
* @param context
|
|
58
|
+
*/
|
|
59
|
+
static from<TC, TE extends EventObject = EventObject>(stateValue: State<TC, TE, any, any> | StateValue, context?: TC | undefined): State<TC, TE, any, any>;
|
|
60
|
+
/**
|
|
61
|
+
* Creates a new State instance for the given `config`.
|
|
62
|
+
* @param config The state config
|
|
63
|
+
*/
|
|
64
|
+
static create<TC, TE extends EventObject = EventObject>(config: StateConfig<TC, TE>): State<TC, TE>;
|
|
65
|
+
/**
|
|
66
|
+
* Creates a new `State` instance for the given `stateValue` and `context` with no actions (side-effects).
|
|
67
|
+
* @param stateValue
|
|
68
|
+
* @param context
|
|
69
|
+
*/
|
|
70
|
+
static inert<TC, TE extends EventObject = EventObject>(stateValue: State<TC, TE> | StateValue, context: TC): State<TC, TE>;
|
|
71
|
+
/**
|
|
72
|
+
* Creates a new State instance.
|
|
73
|
+
* @param value The state value
|
|
74
|
+
* @param context The extended state
|
|
75
|
+
* @param historyValue The tree representing historical values of the state nodes
|
|
76
|
+
* @param history The previous state
|
|
77
|
+
* @param actions An array of action objects to execute as side-effects
|
|
78
|
+
* @param activities A mapping of activities and whether they are started (`true`) or stopped (`false`).
|
|
79
|
+
* @param meta
|
|
80
|
+
* @param events Internal event queue. Should be empty with run-to-completion semantics.
|
|
81
|
+
* @param configuration
|
|
82
|
+
*/
|
|
83
|
+
constructor(config: StateConfig<TContext, TEvent>);
|
|
84
|
+
/**
|
|
85
|
+
* Returns an array of all the string leaf state node paths.
|
|
86
|
+
* @param stateValue
|
|
87
|
+
* @param delimiter The character(s) that separate each subpath in the string state node path.
|
|
88
|
+
*/
|
|
89
|
+
toStrings(stateValue?: StateValue, delimiter?: string): string[];
|
|
90
|
+
toJSON(): Omit<this, "configuration" | "transitions" | "tags"> & {
|
|
91
|
+
tags: string[];
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Whether the current state value is a subset of the given parent state value.
|
|
95
|
+
* @param parentStateValue
|
|
96
|
+
*/
|
|
97
|
+
matches<TSV extends TTypestate['value']>(parentStateValue: TSV): this is State<(TTypestate extends any ? {
|
|
98
|
+
value: TSV;
|
|
99
|
+
context: any;
|
|
100
|
+
} extends TTypestate ? TTypestate : never : never)['context'], TEvent, TStateSchema, TTypestate> & {
|
|
101
|
+
value: TSV;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Whether the current state configuration has a state node with the specified `tag`.
|
|
105
|
+
* @param tag
|
|
106
|
+
*/
|
|
107
|
+
hasTag(tag: string): boolean;
|
|
108
|
+
}
|
|
109
109
|
//# sourceMappingURL=State.d.ts.map
|