xstate 4.26.0-pr2674-20219515814 → 4.26.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 +37 -10
- package/dist/xstate.interpreter.js +1 -1
- package/dist/xstate.js +1 -1
- package/dist/xstate.web.js +2 -2
- package/es/Actor.d.ts +2 -1
- package/es/Machine.d.ts +4 -5
- package/es/State.d.ts +10 -12
- package/es/State.js +1 -1
- package/es/StateNode.d.ts +14 -15
- package/es/StateNode.js +39 -39
- package/es/_virtual/_tslib.js +8 -4
- package/es/actions.d.ts +5 -4
- package/es/actions.js +7 -7
- package/es/behaviors.d.ts +1 -1
- package/es/devTools.d.ts +2 -3
- package/es/devTools.js +4 -0
- package/es/each.d.ts +1 -1
- package/es/index.d.ts +0 -1
- package/es/interpreter.d.ts +25 -35
- package/es/interpreter.js +19 -17
- package/es/model.d.ts +2 -2
- package/es/model.types.d.ts +9 -8
- package/es/registry.js +1 -1
- package/es/scxml.d.ts +2 -2
- package/es/stateUtils.d.ts +6 -6
- package/es/stateUtils.js +8 -3
- package/es/types.d.ts +46 -60
- package/es/utils.d.ts +1 -1
- package/es/utils.js +10 -10
- package/lib/Actor.d.ts +2 -1
- package/lib/Machine.d.ts +4 -5
- package/lib/SimulatedClock.js +9 -5
- package/lib/State.d.ts +10 -12
- package/lib/State.js +1 -1
- package/lib/StateNode.d.ts +14 -15
- package/lib/StateNode.js +38 -38
- package/lib/_virtual/_tslib.js +8 -4
- package/lib/actions.d.ts +5 -4
- package/lib/actions.js +7 -7
- package/lib/behaviors.d.ts +1 -1
- package/lib/devTools.d.ts +2 -3
- package/lib/devTools.js +4 -0
- package/lib/each.d.ts +1 -1
- package/lib/index.d.ts +0 -1
- package/lib/interpreter.d.ts +25 -35
- package/lib/interpreter.js +19 -17
- package/lib/json.js +7 -7
- package/lib/model.d.ts +2 -2
- package/lib/model.js +14 -10
- package/lib/model.types.d.ts +9 -8
- package/lib/patterns.js +2 -2
- package/lib/registry.js +1 -1
- package/lib/scxml.d.ts +2 -2
- package/lib/scxml.js +29 -25
- package/lib/stateUtils.d.ts +6 -6
- package/lib/stateUtils.js +7 -1
- package/lib/types.d.ts +46 -60
- package/lib/utils.d.ts +1 -1
- package/lib/utils.js +10 -10
- package/package.json +4 -8
- package/dist/xstate.cjs.d.ts +0 -11
- package/dist/xstate.cjs.js +0 -16
- package/es/typegenTypes.d.ts +0 -78
- package/lib/typegenTypes.d.ts +0 -78
- package/lib/typegenTypes.js +0 -2
package/es/interpreter.js
CHANGED
|
@@ -87,14 +87,15 @@ function () {
|
|
|
87
87
|
if (_this.status === InterpreterStatus.Stopped) {
|
|
88
88
|
// do nothing
|
|
89
89
|
if (!IS_PRODUCTION) {
|
|
90
|
-
warn(false, "Event \""
|
|
90
|
+
warn(false, "Event \"".concat(_event.name, "\" was sent to stopped service \"").concat(_this.machine.id, "\". This service has already reached its final state, and will not transition.\nEvent: ").concat(JSON.stringify(_event.data)));
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
return _this.state;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
if (_this.status !== InterpreterStatus.Running && !_this.options.deferEvents) {
|
|
97
|
-
throw new Error("Event \""
|
|
97
|
+
throw new Error("Event \"".concat(_event.name, "\" was sent to uninitialized service \"").concat(_this.machine.id // tslint:disable-next-line:max-line-length
|
|
98
|
+
, "\". Make sure .start() is called for this service, or set { deferEvents: true } in the service options.\nEvent: ").concat(JSON.stringify(_event.data)));
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
_this.scheduler.schedule(function () {
|
|
@@ -116,12 +117,12 @@ function () {
|
|
|
116
117
|
|
|
117
118
|
if (!target) {
|
|
118
119
|
if (!isParent) {
|
|
119
|
-
throw new Error("Unable to send event to child '"
|
|
120
|
+
throw new Error("Unable to send event to child '".concat(to, "' from service '").concat(_this.id, "'."));
|
|
120
121
|
} // tslint:disable-next-line:no-console
|
|
121
122
|
|
|
122
123
|
|
|
123
124
|
if (!IS_PRODUCTION) {
|
|
124
|
-
warn(false, "Service '"
|
|
125
|
+
warn(false, "Service '".concat(_this.id, "' has no parent: unable to send event ").concat(event.type));
|
|
125
126
|
}
|
|
126
127
|
|
|
127
128
|
return;
|
|
@@ -130,7 +131,7 @@ function () {
|
|
|
130
131
|
if ('machine' in target) {
|
|
131
132
|
// Send SCXML events to machines
|
|
132
133
|
target.send(__assign(__assign({}, event), {
|
|
133
|
-
name: event.name === error$1 ? ""
|
|
134
|
+
name: event.name === error$1 ? "".concat(error(_this.id)) : event.name,
|
|
134
135
|
origin: _this.sessionId
|
|
135
136
|
}));
|
|
136
137
|
} else {
|
|
@@ -176,7 +177,7 @@ function () {
|
|
|
176
177
|
Object.defineProperty(Interpreter.prototype, "state", {
|
|
177
178
|
get: function () {
|
|
178
179
|
if (!IS_PRODUCTION) {
|
|
179
|
-
warn(this.status !== InterpreterStatus.NotStarted, "Attempted to read state from uninitialized service '"
|
|
180
|
+
warn(this.status !== InterpreterStatus.NotStarted, "Attempted to read state from uninitialized service '".concat(this.id, "'. Make sure the service is started first."));
|
|
180
181
|
}
|
|
181
182
|
|
|
182
183
|
return this._state;
|
|
@@ -616,11 +617,11 @@ function () {
|
|
|
616
617
|
if (this.status === InterpreterStatus.NotStarted && this.options.deferEvents) {
|
|
617
618
|
// tslint:disable-next-line:no-console
|
|
618
619
|
if (!IS_PRODUCTION) {
|
|
619
|
-
warn(false, events.length
|
|
620
|
+
warn(false, "".concat(events.length, " event(s) were sent to uninitialized service \"").concat(this.machine.id, "\" and are deferred. Make sure .start() is called for this service.\nEvent: ").concat(JSON.stringify(event)));
|
|
620
621
|
}
|
|
621
622
|
} else if (this.status !== InterpreterStatus.Running) {
|
|
622
623
|
throw new Error( // tslint:disable-next-line:max-line-length
|
|
623
|
-
events.length
|
|
624
|
+
"".concat(events.length, " event(s) were sent to uninitialized service \"").concat(this.machine.id, "\". Make sure .start() is called for this service, or set { deferEvents: true } in the service options."));
|
|
624
625
|
}
|
|
625
626
|
|
|
626
627
|
this.scheduler.schedule(function () {
|
|
@@ -640,7 +641,7 @@ function () {
|
|
|
640
641
|
});
|
|
641
642
|
batchedActions.push.apply(batchedActions, __spreadArray([], __read(nextState.actions.map(function (a) {
|
|
642
643
|
return bindActionToState(a, nextState);
|
|
643
|
-
}))));
|
|
644
|
+
})), false));
|
|
644
645
|
batchChanged = batchChanged || !!nextState.changed;
|
|
645
646
|
};
|
|
646
647
|
|
|
@@ -713,7 +714,7 @@ function () {
|
|
|
713
714
|
var child = this.children.get(id);
|
|
714
715
|
|
|
715
716
|
if (!child) {
|
|
716
|
-
throw new Error("Unable to forward event '"
|
|
717
|
+
throw new Error("Unable to forward event '".concat(event, "' from interpreter '").concat(this.id, "' to nonexistant child '").concat(id, "'."));
|
|
717
718
|
}
|
|
718
719
|
|
|
719
720
|
child.send(event);
|
|
@@ -817,7 +818,7 @@ function () {
|
|
|
817
818
|
|
|
818
819
|
if (!IS_PRODUCTION) {
|
|
819
820
|
warn(!('forward' in activity), // tslint:disable-next-line:max-line-length
|
|
820
|
-
"`forward` property is deprecated (found in invocation of '"
|
|
821
|
+
"`forward` property is deprecated (found in invocation of '".concat(activity.src, "' in in machine '").concat(this.machine.id, "'). ") + "Please use `autoForward` instead.");
|
|
821
822
|
}
|
|
822
823
|
|
|
823
824
|
var autoForward = 'autoForward' in activity ? activity.autoForward : !!activity.forward;
|
|
@@ -825,7 +826,7 @@ function () {
|
|
|
825
826
|
if (!serviceCreator) {
|
|
826
827
|
// tslint:disable-next-line:no-console
|
|
827
828
|
if (!IS_PRODUCTION) {
|
|
828
|
-
warn(false, "No service found for invocation '"
|
|
829
|
+
warn(false, "No service found for invocation '".concat(activity.src, "' in machine '").concat(this.machine.id, "'."));
|
|
829
830
|
}
|
|
830
831
|
|
|
831
832
|
return;
|
|
@@ -840,7 +841,8 @@ function () {
|
|
|
840
841
|
|
|
841
842
|
var source = isFunction(serviceCreator) ? serviceCreator(context, _event.data, {
|
|
842
843
|
data: resolvedData,
|
|
843
|
-
src: invokeSource
|
|
844
|
+
src: invokeSource,
|
|
845
|
+
meta: activity.meta
|
|
844
846
|
}) : serviceCreator;
|
|
845
847
|
|
|
846
848
|
if (!source) {
|
|
@@ -885,7 +887,7 @@ function () {
|
|
|
885
887
|
|
|
886
888
|
default:
|
|
887
889
|
if (!IS_PRODUCTION) {
|
|
888
|
-
warn(false, "No implementation found for action type '"
|
|
890
|
+
warn(false, "No implementation found for action type '".concat(action.type, "'"));
|
|
889
891
|
}
|
|
890
892
|
|
|
891
893
|
break;
|
|
@@ -934,7 +936,7 @@ function () {
|
|
|
934
936
|
} else if (isBehavior(entity)) {
|
|
935
937
|
return this.spawnBehavior(entity, name);
|
|
936
938
|
} else {
|
|
937
|
-
throw new Error("Unable to spawn entity \""
|
|
939
|
+
throw new Error("Unable to spawn entity \"".concat(name, "\" of type \"").concat(typeof entity, "\"."));
|
|
938
940
|
}
|
|
939
941
|
};
|
|
940
942
|
|
|
@@ -1210,7 +1212,7 @@ function () {
|
|
|
1210
1212
|
|
|
1211
1213
|
if (!implementation) {
|
|
1212
1214
|
if (!IS_PRODUCTION) {
|
|
1213
|
-
warn(false, "No implementation found for activity '"
|
|
1215
|
+
warn(false, "No implementation found for activity '".concat(activity.type, "'"));
|
|
1214
1216
|
} // tslint:disable-next-line:no-console
|
|
1215
1217
|
|
|
1216
1218
|
|
|
@@ -1342,7 +1344,7 @@ function spawn(entity, nameOrOptions) {
|
|
|
1342
1344
|
return consume(function (service) {
|
|
1343
1345
|
if (!IS_PRODUCTION) {
|
|
1344
1346
|
var isLazyEntity = isMachine(entity) || isFunction(entity);
|
|
1345
|
-
warn(!!service || isLazyEntity, "Attempted to spawn an Actor (ID: \""
|
|
1347
|
+
warn(!!service || isLazyEntity, "Attempted to spawn an Actor (ID: \"".concat(isMachine(entity) ? entity.id : 'undefined', "\") outside of a service. This will have no effect."));
|
|
1346
1348
|
}
|
|
1347
1349
|
|
|
1348
1350
|
if (service) {
|
package/es/model.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { UnionFromCreatorsReturnTypes, FinalModelCreators, Model, ModelCreators } from './model.types';
|
|
1
|
+
import type { EventObject, BaseActionObject } from './types';
|
|
2
|
+
import { Cast, UnionFromCreatorsReturnTypes, FinalModelCreators, Model, ModelCreators, Prop, IsNever } from './model.types';
|
|
3
3
|
export declare function createModel<TContext, TEvent extends EventObject, TAction extends BaseActionObject = BaseActionObject>(initialContext: TContext): Model<TContext, TEvent, TAction, void>;
|
|
4
4
|
export declare function createModel<TContext, TModelCreators extends ModelCreators<TModelCreators>, TFinalModelCreators = FinalModelCreators<TModelCreators>, TComputedEvent = UnionFromCreatorsReturnTypes<Prop<TFinalModelCreators, 'events'>>, TComputedAction = UnionFromCreatorsReturnTypes<Prop<TFinalModelCreators, 'actions'>>>(initialContext: TContext, creators: TModelCreators): Model<TContext, Cast<TComputedEvent, EventObject>, IsNever<TComputedAction> extends true ? BaseActionObject : Cast<TComputedAction, BaseActionObject>, TFinalModelCreators>;
|
|
5
5
|
//# sourceMappingURL=model.d.ts.map
|
package/es/model.types.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { EventObject, Assigner, ExtractEvent, PropertyAssigner, AssignAction, MachineConfig, MachineOptions, StateMachine, BaseActionObject } from './types';
|
|
2
|
+
export declare type AnyFunction = (...args: any[]) => any;
|
|
3
|
+
export declare type IsNever<T> = [T] extends [never] ? true : false;
|
|
4
|
+
export declare type Cast<T extends any, TCastType extends any> = T extends TCastType ? T : TCastType;
|
|
5
|
+
export declare type Compute<A extends any> = {
|
|
6
|
+
[K in keyof A]: A[K];
|
|
7
|
+
} & unknown;
|
|
8
|
+
export declare type Prop<T, K> = K extends keyof T ? T[K] : never;
|
|
3
9
|
export interface Model<TContext, TEvent extends EventObject, TAction extends BaseActionObject = BaseActionObject, TModelCreators = void> {
|
|
4
10
|
initialContext: TContext;
|
|
5
11
|
assign: <TEventType extends TEvent['type'] = TEvent['type']>(assigner: Assigner<TContext, ExtractEvent<TEvent, TEventType>> | PropertyAssigner<TContext, ExtractEvent<TEvent, TEventType>>, eventType?: TEventType) => AssignAction<TContext, ExtractEvent<TEvent, TEventType>>;
|
|
6
12
|
events: Prop<TModelCreators, 'events'>;
|
|
7
13
|
actions: Prop<TModelCreators, 'actions'>;
|
|
8
14
|
reset: () => AssignAction<TContext, any>;
|
|
9
|
-
createMachine:
|
|
10
|
-
<TTypesMeta extends TypegenConstraint = TypegenDisabled>(config: MachineConfig<TContext, any, TEvent, TAction, TTypesMeta>, implementations?: MaybeTypegenMachineOptions<TContext, TEvent, TAction, ResolveTypegenMeta<TTypesMeta, TEvent, TAction>>): StateMachine<TContext, any, TEvent, {
|
|
11
|
-
value: any;
|
|
12
|
-
context: TContext;
|
|
13
|
-
}, TAction, ResolveTypegenMeta<TTypesMeta, TEvent, TAction>>;
|
|
14
|
-
};
|
|
15
|
+
createMachine: (config: MachineConfig<TContext, any, TEvent, TAction>, implementations?: Partial<MachineOptions<TContext, TEvent, TAction>>) => StateMachine<TContext, any, TEvent>;
|
|
15
16
|
}
|
|
16
17
|
export declare type ModelContextFrom<TModel extends Model<any, any, any, any>> = TModel extends Model<infer TContext, any, any, any> ? TContext : never;
|
|
17
18
|
export declare type ModelEventsFrom<TModel extends Model<any, any, any, any> | undefined> = TModel extends Model<any, infer TEvent, any, any> ? TEvent : EventObject;
|
package/es/registry.js
CHANGED
package/es/scxml.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StateNode } from './index';
|
|
2
2
|
export interface ScxmlToMachineOptions {
|
|
3
3
|
delimiter?: string;
|
|
4
4
|
}
|
|
5
|
-
export declare function toMachine(xml: string, options: ScxmlToMachineOptions):
|
|
5
|
+
export declare function toMachine(xml: string, options: ScxmlToMachineOptions): StateNode;
|
|
6
6
|
//# sourceMappingURL=scxml.d.ts.map
|
package/es/stateUtils.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { EventObject, StateValue } from '
|
|
2
|
-
import { StateNode } from './StateNode';
|
|
1
|
+
import { EventObject, StateNode, StateValue } from '.';
|
|
3
2
|
declare type Configuration<TC, TE extends EventObject> = Iterable<StateNode<TC, any, TE>>;
|
|
4
3
|
declare type AdjList<TC, TE extends EventObject> = Map<StateNode<TC, any, TE>, Array<StateNode<TC, any, TE>>>;
|
|
5
|
-
export declare const isLeafNode: (stateNode: StateNode<any, any, any, any
|
|
4
|
+
export declare const isLeafNode: (stateNode: StateNode<any, any, any, any>) => boolean;
|
|
6
5
|
export declare function getChildren<TC, TE extends EventObject>(stateNode: StateNode<TC, any, TE>): Array<StateNode<TC, any, TE>>;
|
|
7
|
-
export declare function getAllStateNodes<TC, TE extends EventObject>(stateNode: StateNode<TC, any, TE, any
|
|
8
|
-
export declare function getConfiguration<TC, TE extends EventObject>(prevStateNodes: Iterable<StateNode<TC, any, TE, any
|
|
6
|
+
export declare function getAllStateNodes<TC, TE extends EventObject>(stateNode: StateNode<TC, any, TE, any>): Array<StateNode<TC, any, TE, any>>;
|
|
7
|
+
export declare function getConfiguration<TC, TE extends EventObject>(prevStateNodes: Iterable<StateNode<TC, any, TE, any>>, stateNodes: Iterable<StateNode<TC, any, TE, any>>): Iterable<StateNode<TC, any, TE, any>>;
|
|
9
8
|
export declare function getAdjList<TC, TE extends EventObject>(configuration: Configuration<TC, TE>): AdjList<TC, TE>;
|
|
10
9
|
export declare function getValue<TC, TE extends EventObject>(rootNode: StateNode<TC, any, TE, any>, configuration: Configuration<TC, TE>): StateValue;
|
|
11
10
|
export declare function has<T>(iterable: Iterable<T>, item: T): boolean;
|
|
12
11
|
export declare function nextEvents<TC, TE extends EventObject>(configuration: Array<StateNode<TC, any, TE>>): Array<TE['type']>;
|
|
13
|
-
export declare function isInFinalState<TC, TE extends EventObject>(configuration: Array<StateNode<TC, any, TE, any
|
|
12
|
+
export declare function isInFinalState<TC, TE extends EventObject>(configuration: Array<StateNode<TC, any, TE, any>>, stateNode: StateNode<TC, any, TE, any>): boolean;
|
|
14
13
|
export declare function getMeta(configuration?: StateNode[]): Record<string, any>;
|
|
14
|
+
export declare function getTagsFromConfiguration(configuration: StateNode<any, any, any, any>[]): Set<string>;
|
|
15
15
|
export {};
|
|
16
16
|
//# sourceMappingURL=stateUtils.d.ts.map
|
package/es/stateUtils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __values, __spreadArray, __read } from './_virtual/_tslib.js';
|
|
2
|
-
import {
|
|
2
|
+
import { flatten, keys } from './utils.js';
|
|
3
3
|
|
|
4
4
|
var isLeafNode = function (stateNode) {
|
|
5
5
|
return stateNode.type === 'atomic' || stateNode.type === 'final';
|
|
@@ -222,7 +222,7 @@ function has(iterable, item) {
|
|
|
222
222
|
function nextEvents(configuration) {
|
|
223
223
|
return __spreadArray([], __read(new Set(flatten(__spreadArray([], __read(configuration.map(function (sn) {
|
|
224
224
|
return sn.ownEvents;
|
|
225
|
-
})))))));
|
|
225
|
+
})), false)))), false);
|
|
226
226
|
}
|
|
227
227
|
function isInFinalState(configuration, stateNode) {
|
|
228
228
|
if (stateNode.type === 'compound') {
|
|
@@ -252,5 +252,10 @@ function getMeta(configuration) {
|
|
|
252
252
|
return acc;
|
|
253
253
|
}, {});
|
|
254
254
|
}
|
|
255
|
+
function getTagsFromConfiguration(configuration) {
|
|
256
|
+
return new Set(flatten(configuration.map(function (sn) {
|
|
257
|
+
return sn.tags;
|
|
258
|
+
})));
|
|
259
|
+
}
|
|
255
260
|
|
|
256
|
-
export { getAdjList, getAllStateNodes, getChildren, getConfiguration, getMeta, getValue, has, isInFinalState, isLeafNode, nextEvents };
|
|
261
|
+
export { getAdjList, getAllStateNodes, getChildren, getConfiguration, getMeta, getTagsFromConfiguration, getValue, has, isInFinalState, isLeafNode, nextEvents };
|
package/es/types.d.ts
CHANGED
|
@@ -1,25 +1,9 @@
|
|
|
1
|
-
import { Clock, Interpreter } from './interpreter';
|
|
2
|
-
import { Model } from './model.types';
|
|
3
|
-
import { State } from './State';
|
|
4
1
|
import { StateNode } from './StateNode';
|
|
5
|
-
import {
|
|
6
|
-
|
|
2
|
+
import { State } from './State';
|
|
3
|
+
import { Interpreter, Clock } from './interpreter';
|
|
4
|
+
import { IsNever, Model, Prop } from './model.types';
|
|
5
|
+
declare type AnyFunction = (...args: any[]) => any;
|
|
7
6
|
declare type ReturnTypeOrValue<T> = T extends AnyFunction ? ReturnType<T> : T;
|
|
8
|
-
export declare type IsNever<T> = [T] extends [never] ? true : false;
|
|
9
|
-
export declare type Cast<T extends any, TCastType extends any> = T extends TCastType ? T : TCastType;
|
|
10
|
-
export declare type Compute<A extends any> = {
|
|
11
|
-
[K in keyof A]: A[K];
|
|
12
|
-
} & unknown;
|
|
13
|
-
export declare type Prop<T, K> = K extends keyof T ? T[K] : never;
|
|
14
|
-
export declare type Values<T> = T[keyof T];
|
|
15
|
-
export declare type Merge<M, N> = Omit<M, keyof N> & N;
|
|
16
|
-
export declare type IndexByType<T extends {
|
|
17
|
-
type: string;
|
|
18
|
-
}> = {
|
|
19
|
-
[K in T['type']]: Extract<T, {
|
|
20
|
-
type: K;
|
|
21
|
-
}>;
|
|
22
|
-
};
|
|
23
7
|
export declare type EventType = string;
|
|
24
8
|
export declare type ActionType = string;
|
|
25
9
|
export declare type MetaObject = Record<string, any>;
|
|
@@ -60,7 +44,7 @@ export declare type EventData = Record<string, any> & {
|
|
|
60
44
|
* The specified string event types or the specified event objects.
|
|
61
45
|
*/
|
|
62
46
|
export declare type Event<TEvent extends EventObject> = TEvent['type'] | TEvent;
|
|
63
|
-
export interface ActionMeta<TContext, TEvent extends EventObject, TAction extends
|
|
47
|
+
export interface ActionMeta<TContext, TEvent extends EventObject, TAction extends ActionObject<TContext, TEvent> = ActionObject<TContext, TEvent>> extends StateMeta<TContext, TEvent> {
|
|
64
48
|
action: TAction;
|
|
65
49
|
_event: SCXML.Event<TEvent>;
|
|
66
50
|
}
|
|
@@ -69,8 +53,8 @@ export interface AssignMeta<TContext, TEvent extends EventObject> {
|
|
|
69
53
|
action: AssignAction<TContext, TEvent>;
|
|
70
54
|
_event: SCXML.Event<TEvent>;
|
|
71
55
|
}
|
|
72
|
-
export declare type ActionFunction<TContext, TEvent extends EventObject, TAction extends
|
|
73
|
-
export interface
|
|
56
|
+
export declare type ActionFunction<TContext, TEvent extends EventObject, TAction extends ActionObject<TContext, TEvent> = ActionObject<TContext, TEvent>> = (context: TContext, event: TEvent, meta: ActionMeta<TContext, TEvent, TAction>) => void;
|
|
57
|
+
export interface ChooseCondition<TContext, TEvent extends EventObject> {
|
|
74
58
|
cond?: Condition<TContext, TEvent>;
|
|
75
59
|
actions: Actions<TContext, TEvent>;
|
|
76
60
|
}
|
|
@@ -97,14 +81,6 @@ export interface StateValueMap {
|
|
|
97
81
|
* - For complex state nodes, this is an object, e.g., `{ success: "someChildState" }`.
|
|
98
82
|
*/
|
|
99
83
|
export declare type StateValue = string | StateValueMap;
|
|
100
|
-
declare type KeysWithStates<TStates extends Record<string, StateSchema> | undefined> = TStates extends object ? {
|
|
101
|
-
[K in keyof TStates]-?: TStates[K] extends {
|
|
102
|
-
states: object;
|
|
103
|
-
} ? K : never;
|
|
104
|
-
}[keyof TStates] : never;
|
|
105
|
-
export declare type ExtractStateValue<TSchema extends Required<Pick<StateSchema<any>, 'states'>>> = keyof TSchema['states'] | (KeysWithStates<TSchema['states']> extends never ? never : {
|
|
106
|
-
[K in KeysWithStates<TSchema['states']>]?: ExtractStateValue<TSchema['states'][K]>;
|
|
107
|
-
});
|
|
108
84
|
export interface HistoryValue {
|
|
109
85
|
states: Record<string, HistoryValue | undefined>;
|
|
110
86
|
current: StateValue | undefined;
|
|
@@ -174,6 +150,7 @@ export declare type InvokeCallback<TEvent extends EventObject = AnyEventObject,
|
|
|
174
150
|
export interface InvokeMeta {
|
|
175
151
|
data: any;
|
|
176
152
|
src: InvokeSourceDefinition;
|
|
153
|
+
meta?: MetaObject;
|
|
177
154
|
}
|
|
178
155
|
/**
|
|
179
156
|
* Returns either a Promises or a callback handler (for streams of events) given the
|
|
@@ -213,6 +190,7 @@ export interface InvokeDefinition<TContext, TEvent extends EventObject> extends
|
|
|
213
190
|
* Data should be mapped to match the child machine's context shape.
|
|
214
191
|
*/
|
|
215
192
|
data?: Mapper<TContext, TEvent, any> | PropertyMapper<TContext, TEvent, any>;
|
|
193
|
+
meta?: MetaObject;
|
|
216
194
|
}
|
|
217
195
|
export interface Delay {
|
|
218
196
|
id: string;
|
|
@@ -295,6 +273,10 @@ export interface InvokeConfig<TContext, TEvent extends EventObject> {
|
|
|
295
273
|
* The transition to take upon the invoked child machine sending an error event.
|
|
296
274
|
*/
|
|
297
275
|
onError?: string | SingleOrArray<TransitionConfig<TContext, DoneInvokeEvent<any>>>;
|
|
276
|
+
/**
|
|
277
|
+
* Meta data related to this invocation
|
|
278
|
+
*/
|
|
279
|
+
meta?: MetaObject;
|
|
298
280
|
}
|
|
299
281
|
export interface StateNodeConfig<TContext, TStateSchema extends StateSchema, TEvent extends EventObject, TAction extends BaseActionObject = BaseActionObject> {
|
|
300
282
|
/**
|
|
@@ -450,6 +432,7 @@ export interface StateNodeDefinition<TContext, TStateSchema extends StateSchema,
|
|
|
450
432
|
data?: FinalStateNodeConfig<TContext, TEvent>['data'];
|
|
451
433
|
invoke: Array<InvokeDefinition<TContext, TEvent>>;
|
|
452
434
|
description?: string;
|
|
435
|
+
tags: string[];
|
|
453
436
|
}
|
|
454
437
|
export declare type AnyStateNodeDefinition = StateNodeDefinition<any, any, any>;
|
|
455
438
|
export interface AtomicStateNodeConfig<TContext, TEvent extends EventObject> extends StateNodeConfig<TContext, StateSchema, TEvent> {
|
|
@@ -471,7 +454,7 @@ export interface FinalStateNodeConfig<TContext, TEvent extends EventObject> exte
|
|
|
471
454
|
data?: Mapper<TContext, TEvent, any> | PropertyMapper<TContext, TEvent, any>;
|
|
472
455
|
}
|
|
473
456
|
export declare type SimpleOrStateNodeConfig<TContext, TStateSchema extends StateSchema, TEvent extends EventObject> = AtomicStateNodeConfig<TContext, TEvent> | StateNodeConfig<TContext, TStateSchema, TEvent>;
|
|
474
|
-
export declare type ActionFunctionMap<TContext, TEvent extends EventObject, TAction extends
|
|
457
|
+
export declare type ActionFunctionMap<TContext, TEvent extends EventObject, TAction extends ActionObject<TContext, TEvent> = ActionObject<TContext, TEvent>> = {
|
|
475
458
|
[K in TAction['type']]?: ActionObject<TContext, TEvent> | ActionFunction<TContext, TEvent, TAction extends {
|
|
476
459
|
type: K;
|
|
477
460
|
} ? TAction : never>;
|
|
@@ -479,25 +462,25 @@ export declare type ActionFunctionMap<TContext, TEvent extends EventObject, TAct
|
|
|
479
462
|
export declare type DelayFunctionMap<TContext, TEvent extends EventObject> = Record<string, DelayConfig<TContext, TEvent>>;
|
|
480
463
|
export declare type ServiceConfig<TContext, TEvent extends EventObject = AnyEventObject> = string | StateMachine<any, any, any> | InvokeCreator<TContext, TEvent>;
|
|
481
464
|
export declare type DelayConfig<TContext, TEvent extends EventObject> = number | DelayExpr<TContext, TEvent>;
|
|
482
|
-
export interface MachineOptions<TContext, TEvent extends EventObject, TAction extends
|
|
483
|
-
guards
|
|
484
|
-
actions
|
|
465
|
+
export interface MachineOptions<TContext, TEvent extends EventObject, TAction extends ActionObject<TContext, TEvent> = ActionObject<TContext, TEvent>> {
|
|
466
|
+
guards: Record<string, ConditionPredicate<TContext, TEvent>>;
|
|
467
|
+
actions: ActionFunctionMap<TContext, TEvent, TAction>;
|
|
485
468
|
/**
|
|
486
469
|
* @deprecated Use `services` instead.
|
|
487
470
|
*/
|
|
488
|
-
activities
|
|
489
|
-
services
|
|
490
|
-
delays
|
|
471
|
+
activities: Record<string, ActivityConfig<TContext, TEvent>>;
|
|
472
|
+
services: Record<string, ServiceConfig<TContext, TEvent>>;
|
|
473
|
+
delays: DelayFunctionMap<TContext, TEvent>;
|
|
491
474
|
/**
|
|
492
475
|
* @private
|
|
493
476
|
*/
|
|
494
|
-
_parent?: StateNode<TContext, any, TEvent, any
|
|
477
|
+
_parent?: StateNode<TContext, any, TEvent, any>;
|
|
495
478
|
/**
|
|
496
479
|
* @private
|
|
497
480
|
*/
|
|
498
481
|
_key?: string;
|
|
499
482
|
}
|
|
500
|
-
export interface MachineConfig<TContext, TStateSchema extends StateSchema, TEvent extends EventObject, TAction extends BaseActionObject =
|
|
483
|
+
export interface MachineConfig<TContext, TStateSchema extends StateSchema, TEvent extends EventObject, TAction extends BaseActionObject = ActionObject<TContext, TEvent>> extends StateNodeConfig<TContext, TStateSchema, TEvent, TAction> {
|
|
501
484
|
/**
|
|
502
485
|
* The initial context (extended state)
|
|
503
486
|
*/
|
|
@@ -507,7 +490,6 @@ export interface MachineConfig<TContext, TStateSchema extends StateSchema, TEven
|
|
|
507
490
|
*/
|
|
508
491
|
version?: string;
|
|
509
492
|
schema?: MachineSchema<TContext, TEvent>;
|
|
510
|
-
tsTypes?: TTypesMeta | true;
|
|
511
493
|
}
|
|
512
494
|
export interface MachineSchema<TContext, TEvent extends EventObject> {
|
|
513
495
|
context?: TContext;
|
|
@@ -542,11 +524,11 @@ export interface HistoryStateNode<TContext> extends StateNode<TContext> {
|
|
|
542
524
|
export interface StateMachine<TContext, TStateSchema extends StateSchema, TEvent extends EventObject, TTypestate extends Typestate<TContext> = {
|
|
543
525
|
value: any;
|
|
544
526
|
context: TContext;
|
|
545
|
-
},
|
|
527
|
+
}, _TAction extends ActionObject<TContext, TEvent> = ActionObject<TContext, TEvent>> extends StateNode<TContext, TStateSchema, TEvent, TTypestate> {
|
|
546
528
|
id: string;
|
|
547
|
-
states: StateNode<TContext, TStateSchema, TEvent
|
|
548
|
-
withConfig(options:
|
|
549
|
-
withContext(context: TContext | (() => TContext)): StateMachine<TContext, TStateSchema, TEvent, TTypestate
|
|
529
|
+
states: StateNode<TContext, TStateSchema, TEvent>['states'];
|
|
530
|
+
withConfig(options: Partial<MachineOptions<TContext, TEvent>>, context?: TContext | (() => TContext)): StateMachine<TContext, TStateSchema, TEvent, TTypestate>;
|
|
531
|
+
withContext(context: TContext | (() => TContext)): StateMachine<TContext, TStateSchema, TEvent, TTypestate>;
|
|
550
532
|
}
|
|
551
533
|
export declare type StateFrom<T extends StateMachine<any, any, any, any> | ((...args: any[]) => StateMachine<any, any, any, any>)> = T extends StateMachine<any, any, any> ? ReturnType<T['transition']> : T extends (...args: any[]) => StateMachine<any, any, any> ? ReturnType<ReturnType<T>['transition']> : never;
|
|
552
534
|
export interface ActionMap<TContext, TEvent extends EventObject> {
|
|
@@ -567,13 +549,13 @@ export interface ActivityMap {
|
|
|
567
549
|
}
|
|
568
550
|
export interface StateTransition<TContext, TEvent extends EventObject> {
|
|
569
551
|
transitions: Array<TransitionDefinition<TContext, TEvent>>;
|
|
570
|
-
configuration: Array<StateNode<TContext, any, TEvent, any
|
|
571
|
-
entrySet: Array<StateNode<TContext, any, TEvent, any
|
|
572
|
-
exitSet: Array<StateNode<TContext, any, TEvent, any
|
|
552
|
+
configuration: Array<StateNode<TContext, any, TEvent, any>>;
|
|
553
|
+
entrySet: Array<StateNode<TContext, any, TEvent, any>>;
|
|
554
|
+
exitSet: Array<StateNode<TContext, any, TEvent, any>>;
|
|
573
555
|
/**
|
|
574
556
|
* The source state that preceded the transition.
|
|
575
557
|
*/
|
|
576
|
-
source: State<TContext, any, any, any
|
|
558
|
+
source: State<TContext, any, any, any> | undefined;
|
|
577
559
|
actions: Array<ActionObject<TContext, TEvent>>;
|
|
578
560
|
}
|
|
579
561
|
export interface TransitionData<TContext, TEvent extends EventObject> {
|
|
@@ -716,7 +698,7 @@ export interface PureAction<TContext, TEvent extends EventObject> extends Action
|
|
|
716
698
|
}
|
|
717
699
|
export interface ChooseAction<TContext, TEvent extends EventObject> extends ActionObject<TContext, TEvent> {
|
|
718
700
|
type: ActionTypes.Choose;
|
|
719
|
-
conds: Array<
|
|
701
|
+
conds: Array<ChooseCondition<TContext, TEvent>>;
|
|
720
702
|
}
|
|
721
703
|
export interface TransitionDefinition<TContext, TEvent extends EventObject> extends TransitionConfig<TContext, TEvent> {
|
|
722
704
|
target: Array<StateNode<TContext, any, TEvent>> | undefined;
|
|
@@ -794,7 +776,7 @@ export interface SCXMLEventMeta<TEvent extends EventObject> {
|
|
|
794
776
|
_event: SCXML.Event<TEvent>;
|
|
795
777
|
}
|
|
796
778
|
export interface StateMeta<TContext, TEvent extends EventObject> {
|
|
797
|
-
state: State<TContext, TEvent, any, any
|
|
779
|
+
state: State<TContext, TEvent, any, any>;
|
|
798
780
|
_event: SCXML.Event<TEvent>;
|
|
799
781
|
}
|
|
800
782
|
export interface Typestate<TContext> {
|
|
@@ -813,7 +795,7 @@ export interface StateConfig<TContext, TEvent extends EventObject> {
|
|
|
813
795
|
_event: SCXML.Event<TEvent>;
|
|
814
796
|
_sessionid: string | null;
|
|
815
797
|
historyValue?: HistoryValue | undefined;
|
|
816
|
-
history?: State<TContext, TEvent
|
|
798
|
+
history?: State<TContext, TEvent>;
|
|
817
799
|
actions?: Array<ActionObject<TContext, TEvent>>;
|
|
818
800
|
/**
|
|
819
801
|
* @deprecated
|
|
@@ -826,7 +808,7 @@ export interface StateConfig<TContext, TEvent extends EventObject> {
|
|
|
826
808
|
children: Record<string, ActorRef<any>>;
|
|
827
809
|
done?: boolean;
|
|
828
810
|
tags?: Set<string>;
|
|
829
|
-
machine?: StateMachine<TContext, any, TEvent, any
|
|
811
|
+
machine?: StateMachine<TContext, any, TEvent, any>;
|
|
830
812
|
}
|
|
831
813
|
export interface StateSchema<TC = any> {
|
|
832
814
|
meta?: any;
|
|
@@ -839,9 +821,9 @@ export interface InterpreterOptions {
|
|
|
839
821
|
/**
|
|
840
822
|
* Whether state actions should be executed immediately upon transition. Defaults to `true`.
|
|
841
823
|
*/
|
|
842
|
-
execute
|
|
843
|
-
clock
|
|
844
|
-
logger
|
|
824
|
+
execute: boolean;
|
|
825
|
+
clock: Clock;
|
|
826
|
+
logger: (...args: any[]) => void;
|
|
845
827
|
parent?: AnyInterpreter;
|
|
846
828
|
/**
|
|
847
829
|
* If `true`, defers processing of sent events until the service
|
|
@@ -850,7 +832,7 @@ export interface InterpreterOptions {
|
|
|
850
832
|
*
|
|
851
833
|
* Default: `true`
|
|
852
834
|
*/
|
|
853
|
-
deferEvents
|
|
835
|
+
deferEvents: boolean;
|
|
854
836
|
/**
|
|
855
837
|
* The custom `id` for referencing this service.
|
|
856
838
|
*/
|
|
@@ -860,7 +842,8 @@ export interface InterpreterOptions {
|
|
|
860
842
|
*
|
|
861
843
|
* Default: `false`
|
|
862
844
|
*/
|
|
863
|
-
devTools
|
|
845
|
+
devTools: boolean | object;
|
|
846
|
+
[option: string]: any;
|
|
864
847
|
}
|
|
865
848
|
export declare namespace SCXML {
|
|
866
849
|
interface Event<TEvent extends EventObject> {
|
|
@@ -961,7 +944,7 @@ export declare type ActorRefWithDeprecatedState<TContext, TEvent extends EventOb
|
|
|
961
944
|
state: State<TContext, TEvent, any, TTypestate>;
|
|
962
945
|
};
|
|
963
946
|
export declare type ActorRefFrom<T> = T extends StateMachine<infer TContext, any, infer TEvent, infer TTypestate> ? ActorRefWithDeprecatedState<TContext, TEvent, TTypestate> : T extends (...args: any[]) => StateMachine<infer TContext, any, infer TEvent, infer TTypestate> ? ActorRefWithDeprecatedState<TContext, TEvent, TTypestate> : T extends Promise<infer U> ? ActorRef<never, U> : T extends Behavior<infer TEvent1, infer TEmitted> ? ActorRef<TEvent1, TEmitted> : T extends (...args: any[]) => Behavior<infer TEvent1, infer TEmitted> ? ActorRef<TEvent1, TEmitted> : never;
|
|
964
|
-
export declare type AnyInterpreter = Interpreter<any, any, any, any
|
|
947
|
+
export declare type AnyInterpreter = Interpreter<any, any, any, any>;
|
|
965
948
|
export declare type InterpreterFrom<T extends StateMachine<any, any, any, any> | ((...args: any[]) => StateMachine<any, any, any, any>)> = T extends StateMachine<infer TContext, infer TStateSchema, infer TEvent, infer TTypestate> ? Interpreter<TContext, TStateSchema, TEvent, TTypestate> : T extends (...args: any[]) => StateMachine<infer TContext, infer TStateSchema, infer TEvent, infer TTypestate> ? Interpreter<TContext, TStateSchema, TEvent, TTypestate> : never;
|
|
966
949
|
export interface ActorContext<TEvent extends EventObject, TEmitted> {
|
|
967
950
|
parent?: ActorRef<any, any>;
|
|
@@ -975,7 +958,10 @@ export interface Behavior<TEvent extends EventObject, TEmitted = any> {
|
|
|
975
958
|
start?: (actorCtx: ActorContext<TEvent, TEmitted>) => TEmitted;
|
|
976
959
|
}
|
|
977
960
|
export declare type EmittedFrom<T> = ReturnTypeOrValue<T> extends infer R ? R extends ActorRef<infer _, infer TEmitted> ? TEmitted : R extends Behavior<infer _, infer TEmitted> ? TEmitted : R extends ActorContext<infer _, infer TEmitted> ? TEmitted : never : never;
|
|
978
|
-
|
|
961
|
+
declare type ResolveEventType<T> = ReturnTypeOrValue<T> extends infer R ? R extends StateMachine<infer _, infer __, infer TEvent, infer ____> ? TEvent : R extends Model<infer _, infer TEvent, infer ___, infer ____> ? TEvent : R extends State<infer _, infer TEvent, infer ___, infer ____> ? TEvent : R extends Interpreter<infer _, infer __, infer TEvent, infer ____> ? TEvent : never : never;
|
|
962
|
+
export declare type EventFrom<T, K extends Prop<TEvent, 'type'> = never, TEvent = ResolveEventType<T>> = IsNever<K> extends true ? TEvent : Extract<TEvent, {
|
|
963
|
+
type: K;
|
|
964
|
+
}>;
|
|
979
965
|
export declare type ContextFrom<T> = ReturnTypeOrValue<T> extends infer R ? R extends StateMachine<infer TContext, infer _, infer __, infer ___> ? TContext : R extends Model<infer TContext, infer _, infer __, infer ___> ? TContext : R extends State<infer TContext, infer _, infer __, infer ___> ? TContext : R extends Interpreter<infer TContext, infer _, infer __, infer ___> ? TContext : never : never;
|
|
980
966
|
export {};
|
|
981
967
|
//# sourceMappingURL=types.d.ts.map
|
package/es/utils.d.ts
CHANGED
|
@@ -63,7 +63,7 @@ export declare function toTransitionConfigArray<TContext, TEvent extends EventOb
|
|
|
63
63
|
}>;
|
|
64
64
|
export declare function normalizeTarget<TContext, TEvent extends EventObject>(target: SingleOrArray<string | StateNode<TContext, any, TEvent>> | undefined): Array<string | StateNode<TContext, any, TEvent>> | undefined;
|
|
65
65
|
export declare function reportUnhandledExceptionOnInvocation(originalError: any, currentError: any, id: string): void;
|
|
66
|
-
export declare function evaluateGuard<TContext, TEvent extends EventObject>(machine: StateNode<TContext, any, TEvent, any
|
|
66
|
+
export declare function evaluateGuard<TContext, TEvent extends EventObject>(machine: StateNode<TContext, any, TEvent, any>, guard: Guard<TContext, TEvent>, context: TContext, _event: SCXML.Event<TEvent>, state: State<TContext, TEvent>): boolean;
|
|
67
67
|
export declare function toInvokeSource(src: string | InvokeSourceDefinition): InvokeSourceDefinition;
|
|
68
68
|
export declare function toObserver<T>(nextHandler: Observer<T> | ((value: T) => void), errorHandler?: (error: any) => void, completionHandler?: () => void): Observer<T>;
|
|
69
69
|
//# sourceMappingURL=utils.d.ts.map
|
package/es/utils.js
CHANGED
|
@@ -36,7 +36,7 @@ function matchesState(parentStateId, childStateId, delimiter) {
|
|
|
36
36
|
}
|
|
37
37
|
function getEventType(event) {
|
|
38
38
|
try {
|
|
39
|
-
return isString(event) || typeof event === 'number' ? ""
|
|
39
|
+
return isString(event) || typeof event === 'number' ? "".concat(event) : event.type;
|
|
40
40
|
} catch (e) {
|
|
41
41
|
throw new Error('Events must be strings or objects with a string event.type property.');
|
|
42
42
|
}
|
|
@@ -49,7 +49,7 @@ function toStatePath(stateId, delimiter) {
|
|
|
49
49
|
|
|
50
50
|
return stateId.toString().split(delimiter);
|
|
51
51
|
} catch (e) {
|
|
52
|
-
throw new Error("'"
|
|
52
|
+
throw new Error("'".concat(stateId, "' is not a valid state path."));
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
function isStateLike(state) {
|
|
@@ -218,7 +218,7 @@ function toStatePaths(stateValue) {
|
|
|
218
218
|
function flatten(array) {
|
|
219
219
|
var _a;
|
|
220
220
|
|
|
221
|
-
return (_a = []).concat.apply(_a, __spreadArray([], __read(array)));
|
|
221
|
+
return (_a = []).concat.apply(_a, __spreadArray([], __read(array), false));
|
|
222
222
|
}
|
|
223
223
|
function toArrayStrict(value) {
|
|
224
224
|
if (isArray(value)) {
|
|
@@ -395,7 +395,7 @@ if (!IS_PRODUCTION) {
|
|
|
395
395
|
}
|
|
396
396
|
|
|
397
397
|
if (console !== undefined) {
|
|
398
|
-
var args = ["Warning: "
|
|
398
|
+
var args = ["Warning: ".concat(message)];
|
|
399
399
|
|
|
400
400
|
if (error) {
|
|
401
401
|
args.push(error);
|
|
@@ -524,15 +524,15 @@ function normalizeTarget(target) {
|
|
|
524
524
|
}
|
|
525
525
|
function reportUnhandledExceptionOnInvocation(originalError, currentError, id) {
|
|
526
526
|
if (!IS_PRODUCTION) {
|
|
527
|
-
var originalStackTrace = originalError.stack ? " Stacktrace was '"
|
|
527
|
+
var originalStackTrace = originalError.stack ? " Stacktrace was '".concat(originalError.stack, "'") : '';
|
|
528
528
|
|
|
529
529
|
if (originalError === currentError) {
|
|
530
530
|
// tslint:disable-next-line:no-console
|
|
531
|
-
console.error("Missing onError handler for invocation '"
|
|
531
|
+
console.error("Missing onError handler for invocation '".concat(id, "', error was '").concat(originalError, "'.").concat(originalStackTrace));
|
|
532
532
|
} else {
|
|
533
|
-
var stackTrace = currentError.stack ? " Stacktrace was '"
|
|
533
|
+
var stackTrace = currentError.stack ? " Stacktrace was '".concat(currentError.stack, "'") : ''; // tslint:disable-next-line:no-console
|
|
534
534
|
|
|
535
|
-
console.error("Missing onError handler and/or unhandled exception/promise rejection for invocation '"
|
|
535
|
+
console.error("Missing onError handler and/or unhandled exception/promise rejection for invocation '".concat(id, "'. ") + "Original error: '".concat(originalError, "'. ").concat(originalStackTrace, " Current error is '").concat(currentError, "'.").concat(stackTrace));
|
|
536
536
|
}
|
|
537
537
|
}
|
|
538
538
|
}
|
|
@@ -548,10 +548,10 @@ function evaluateGuard(machine, guard, context, _event, state) {
|
|
|
548
548
|
return ((guards === null || guards === void 0 ? void 0 : guards[guard.name]) || guard.predicate)(context, _event.data, guardMeta);
|
|
549
549
|
}
|
|
550
550
|
|
|
551
|
-
var condFn = guards
|
|
551
|
+
var condFn = guards[guard.type];
|
|
552
552
|
|
|
553
553
|
if (!condFn) {
|
|
554
|
-
throw new Error("Guard '"
|
|
554
|
+
throw new Error("Guard '".concat(guard.type, "' is not implemented on machine '").concat(machine.id, "'."));
|
|
555
555
|
}
|
|
556
556
|
|
|
557
557
|
return condFn(context, _event.data, guardMeta);
|
package/lib/Actor.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { EventObject, Subscribable, InvokeDefinition, AnyEventObject, StateMachine, Spawnable, SCXML
|
|
1
|
+
import { EventObject, Subscribable, InvokeDefinition, AnyEventObject, StateMachine, Spawnable, SCXML } from './types';
|
|
2
|
+
import { ActorRef, BaseActorRef } from '.';
|
|
2
3
|
export interface Actor<TContext = any, TEvent extends EventObject = AnyEventObject> extends Subscribable<TContext> {
|
|
3
4
|
id: string;
|
|
4
5
|
send: (event: TEvent) => any;
|