xstate 5.0.0-alpha.6 → 5.0.0-beta.8
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/actions/dist/xstate-actions.cjs.dev.js +2 -1
- package/actions/dist/xstate-actions.cjs.prod.js +2 -1
- package/actions/dist/xstate-actions.esm.js +1 -1
- package/actions/dist/xstate-actions.umd.min.js +1 -1
- package/actions/dist/xstate-actions.umd.min.js.map +1 -1
- package/actors/dist/xstate-actors.cjs.dev.js +2 -1
- package/actors/dist/xstate-actors.cjs.prod.js +2 -1
- package/actors/dist/xstate-actors.esm.js +1 -1
- package/actors/dist/xstate-actors.umd.min.js +1 -1
- package/actors/dist/xstate-actors.umd.min.js.map +1 -1
- package/dist/{actions-c46e4911.cjs.prod.js → actions-900f9761.cjs.prod.js} +100 -55
- package/dist/{actions-41b74cdc.esm.js → actions-c8d7df32.esm.js} +99 -54
- package/dist/{actions-bf7bb1c5.cjs.dev.js → actions-d06ca158.cjs.dev.js} +100 -55
- package/dist/declarations/src/StateMachine.d.ts +2 -2
- package/dist/declarations/src/actions.d.ts +1 -0
- package/dist/declarations/src/actors/index.d.ts +2 -1
- package/dist/declarations/src/actors/observable.d.ts +1 -2
- package/dist/declarations/src/actors/promise.d.ts +1 -2
- package/dist/declarations/src/index.d.ts +12 -28
- package/dist/declarations/src/types.d.ts +5 -5
- package/dist/declarations/src/waitFor.d.ts +33 -0
- package/dist/xstate.cjs.dev.js +87 -52
- package/dist/xstate.cjs.prod.js +84 -52
- package/dist/xstate.esm.js +73 -50
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +1 -1
- package/guards/dist/xstate-guards.cjs.dev.js +1 -1
- package/guards/dist/xstate-guards.cjs.prod.js +1 -1
- package/guards/dist/xstate-guards.esm.js +1 -1
- package/guards/dist/xstate-guards.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/dist/declarations/src/schema.d.ts +0 -2
|
@@ -535,6 +535,9 @@ function send$1(eventOrExpr, options) {
|
|
|
535
535
|
var delaysMap = state.machine.options.delays;
|
|
536
536
|
|
|
537
537
|
// TODO: helper function for resolving Expr
|
|
538
|
+
if (typeof eventOrExpr === 'string') {
|
|
539
|
+
throw new Error("Only event objects may be used with sendTo; use sendTo({ type: \"".concat(eventOrExpr, "\" }) instead"));
|
|
540
|
+
}
|
|
538
541
|
var resolvedEvent = toSCXMLEvent(isFunction(eventOrExpr) ? eventOrExpr(args) : eventOrExpr);
|
|
539
542
|
var resolvedDelay;
|
|
540
543
|
if (isString(params.delay)) {
|
|
@@ -832,25 +835,28 @@ promiseCreator) {
|
|
|
832
835
|
var behavior = {
|
|
833
836
|
transition: function transition(state, event) {
|
|
834
837
|
var _event = toSCXMLEvent(event);
|
|
835
|
-
if (state.
|
|
838
|
+
if (state.status !== 'active') {
|
|
836
839
|
return state;
|
|
837
840
|
}
|
|
838
841
|
var eventObject = _event.data;
|
|
839
842
|
switch (_event.name) {
|
|
840
843
|
case resolveEventType:
|
|
841
|
-
state
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
844
|
+
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
845
|
+
status: 'done',
|
|
846
|
+
data: eventObject.data,
|
|
847
|
+
input: undefined
|
|
848
|
+
});
|
|
845
849
|
case rejectEventType:
|
|
846
|
-
state
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
+
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
851
|
+
status: 'error',
|
|
852
|
+
data: eventObject.data,
|
|
853
|
+
input: undefined
|
|
854
|
+
});
|
|
850
855
|
case stopSignalType:
|
|
851
|
-
state
|
|
852
|
-
|
|
853
|
-
|
|
856
|
+
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
857
|
+
status: 'canceled',
|
|
858
|
+
input: undefined
|
|
859
|
+
});
|
|
854
860
|
default:
|
|
855
861
|
return state;
|
|
856
862
|
}
|
|
@@ -879,7 +885,6 @@ promiseCreator) {
|
|
|
879
885
|
},
|
|
880
886
|
getInitialState: function getInitialState(_, input) {
|
|
881
887
|
return {
|
|
882
|
-
canceled: false,
|
|
883
888
|
status: 'active',
|
|
884
889
|
data: undefined,
|
|
885
890
|
input: input
|
|
@@ -914,12 +919,11 @@ function fromObservable(observableCreator) {
|
|
|
914
919
|
id = _ref.id,
|
|
915
920
|
defer = _ref.defer;
|
|
916
921
|
var _event = toSCXMLEvent(event);
|
|
917
|
-
if (state.
|
|
922
|
+
if (state.status !== 'active') {
|
|
918
923
|
return state;
|
|
919
924
|
}
|
|
920
925
|
switch (_event.name) {
|
|
921
926
|
case nextEventType:
|
|
922
|
-
state.data = event.data.data;
|
|
923
927
|
// match the exact timing of events sent by machines
|
|
924
928
|
// send actions are not executed immediately
|
|
925
929
|
defer(function () {
|
|
@@ -931,21 +935,29 @@ function fromObservable(observableCreator) {
|
|
|
931
935
|
origin: self
|
|
932
936
|
}));
|
|
933
937
|
});
|
|
934
|
-
return state
|
|
938
|
+
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
939
|
+
data: event.data.data
|
|
940
|
+
});
|
|
935
941
|
case errorEventType:
|
|
936
|
-
state
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
942
|
+
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
943
|
+
status: 'error',
|
|
944
|
+
input: undefined,
|
|
945
|
+
data: _event.data.data,
|
|
946
|
+
subscription: undefined
|
|
947
|
+
});
|
|
940
948
|
case completeEventType:
|
|
941
|
-
state
|
|
942
|
-
|
|
943
|
-
|
|
949
|
+
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
950
|
+
status: 'done',
|
|
951
|
+
input: undefined,
|
|
952
|
+
subscription: undefined
|
|
953
|
+
});
|
|
944
954
|
case stopSignalType:
|
|
945
|
-
state.canceled = true;
|
|
946
|
-
delete state.input;
|
|
947
955
|
state.subscription.unsubscribe();
|
|
948
|
-
return state
|
|
956
|
+
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
957
|
+
status: 'canceled',
|
|
958
|
+
input: undefined,
|
|
959
|
+
subscription: undefined
|
|
960
|
+
});
|
|
949
961
|
default:
|
|
950
962
|
return state;
|
|
951
963
|
}
|
|
@@ -953,7 +965,6 @@ function fromObservable(observableCreator) {
|
|
|
953
965
|
getInitialState: function getInitialState(_, input) {
|
|
954
966
|
return {
|
|
955
967
|
subscription: undefined,
|
|
956
|
-
canceled: false,
|
|
957
968
|
status: 'active',
|
|
958
969
|
data: undefined,
|
|
959
970
|
input: input
|
|
@@ -991,12 +1002,10 @@ function fromObservable(observableCreator) {
|
|
|
991
1002
|
return state.data;
|
|
992
1003
|
},
|
|
993
1004
|
getPersistedState: function getPersistedState(_ref3) {
|
|
994
|
-
var
|
|
995
|
-
status = _ref3.status,
|
|
1005
|
+
var status = _ref3.status,
|
|
996
1006
|
data = _ref3.data,
|
|
997
1007
|
input = _ref3.input;
|
|
998
1008
|
return {
|
|
999
|
-
canceled: canceled,
|
|
1000
1009
|
status: status,
|
|
1001
1010
|
data: data,
|
|
1002
1011
|
input: input
|
|
@@ -1031,24 +1040,30 @@ function fromEventObservable(lazyObservable) {
|
|
|
1031
1040
|
var behavior = {
|
|
1032
1041
|
transition: function transition(state, event) {
|
|
1033
1042
|
var _event = toSCXMLEvent(event);
|
|
1034
|
-
if (state.
|
|
1043
|
+
if (state.status !== 'active') {
|
|
1035
1044
|
return state;
|
|
1036
1045
|
}
|
|
1037
1046
|
switch (_event.name) {
|
|
1038
1047
|
case errorEventType:
|
|
1039
|
-
state
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1048
|
+
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
1049
|
+
status: 'error',
|
|
1050
|
+
input: undefined,
|
|
1051
|
+
data: _event.data.data,
|
|
1052
|
+
subscription: undefined
|
|
1053
|
+
});
|
|
1043
1054
|
case completeEventType:
|
|
1044
|
-
state
|
|
1045
|
-
|
|
1046
|
-
|
|
1055
|
+
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
1056
|
+
status: 'done',
|
|
1057
|
+
input: undefined,
|
|
1058
|
+
subscription: undefined
|
|
1059
|
+
});
|
|
1047
1060
|
case stopSignalType:
|
|
1048
|
-
state.canceled = true;
|
|
1049
|
-
delete state.input;
|
|
1050
1061
|
state.subscription.unsubscribe();
|
|
1051
|
-
return state
|
|
1062
|
+
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
1063
|
+
status: 'canceled',
|
|
1064
|
+
input: undefined,
|
|
1065
|
+
subscription: undefined
|
|
1066
|
+
});
|
|
1052
1067
|
default:
|
|
1053
1068
|
return state;
|
|
1054
1069
|
}
|
|
@@ -1056,7 +1071,6 @@ function fromEventObservable(lazyObservable) {
|
|
|
1056
1071
|
getInitialState: function getInitialState() {
|
|
1057
1072
|
return {
|
|
1058
1073
|
subscription: undefined,
|
|
1059
|
-
canceled: false,
|
|
1060
1074
|
status: 'active',
|
|
1061
1075
|
data: undefined
|
|
1062
1076
|
};
|
|
@@ -1093,12 +1107,10 @@ function fromEventObservable(lazyObservable) {
|
|
|
1093
1107
|
return undefined;
|
|
1094
1108
|
},
|
|
1095
1109
|
getPersistedState: function getPersistedState(_ref5) {
|
|
1096
|
-
var
|
|
1097
|
-
status = _ref5.status,
|
|
1110
|
+
var status = _ref5.status,
|
|
1098
1111
|
data = _ref5.data,
|
|
1099
1112
|
input = _ref5.input;
|
|
1100
1113
|
return {
|
|
1101
|
-
canceled: canceled,
|
|
1102
1114
|
status: status,
|
|
1103
1115
|
data: data,
|
|
1104
1116
|
input: input
|
|
@@ -1132,7 +1144,7 @@ function fromCallback(invokeCallback) {
|
|
|
1132
1144
|
var sender = function sender(eventForParent) {
|
|
1133
1145
|
var _self$_parent;
|
|
1134
1146
|
if (state.canceled) {
|
|
1135
|
-
return
|
|
1147
|
+
return;
|
|
1136
1148
|
}
|
|
1137
1149
|
(_self$_parent = self._parent) === null || _self$_parent === void 0 ? void 0 : _self$_parent.send(toSCXMLEvent(eventForParent, {
|
|
1138
1150
|
origin: self
|
|
@@ -1247,6 +1259,12 @@ function toActorRef(actorRefLike) {
|
|
|
1247
1259
|
return void 0;
|
|
1248
1260
|
}), _objectSpread2$1), actorRefLike);
|
|
1249
1261
|
}
|
|
1262
|
+
var emptyBehavior = fromTransition(function (_) {
|
|
1263
|
+
return undefined;
|
|
1264
|
+
}, undefined);
|
|
1265
|
+
function createEmptyActor() {
|
|
1266
|
+
return interpret(emptyBehavior);
|
|
1267
|
+
}
|
|
1250
1268
|
|
|
1251
1269
|
function createSystem() {
|
|
1252
1270
|
var sessionIdCounter = 0;
|
|
@@ -1650,6 +1668,9 @@ var Interpreter = /*#__PURE__*/function () {
|
|
|
1650
1668
|
}, {
|
|
1651
1669
|
key: "send",
|
|
1652
1670
|
value: function send(event) {
|
|
1671
|
+
if (typeof event === 'string') {
|
|
1672
|
+
throw new Error("Only event objects may be sent to actors; use .send({ type: \"".concat(event, "\" }) instead"));
|
|
1673
|
+
}
|
|
1653
1674
|
var _event = toSCXMLEvent(event);
|
|
1654
1675
|
if (this.status === exports.ActorStatus.Stopped) {
|
|
1655
1676
|
// do nothing
|
|
@@ -2256,7 +2277,7 @@ function getDelayedTransitions(stateNode) {
|
|
|
2256
2277
|
var mutateEntryExit = function mutateEntryExit(delay, i) {
|
|
2257
2278
|
var delayRef = isFunction(delay) ? "".concat(stateNode.id, ":delay[").concat(i, "]") : delay;
|
|
2258
2279
|
var eventType = after$1(delayRef, stateNode.id);
|
|
2259
|
-
stateNode.entry.push(
|
|
2280
|
+
stateNode.entry.push(raise$1({
|
|
2260
2281
|
type: eventType
|
|
2261
2282
|
}, {
|
|
2262
2283
|
delay: delay
|
|
@@ -2291,9 +2312,9 @@ function getDelayedTransitions(stateNode) {
|
|
|
2291
2312
|
});
|
|
2292
2313
|
}
|
|
2293
2314
|
function formatTransition(stateNode, transitionConfig) {
|
|
2294
|
-
var _transitionConfig$
|
|
2315
|
+
var _transitionConfig$ree;
|
|
2295
2316
|
var normalizedTarget = normalizeTarget(transitionConfig.target);
|
|
2296
|
-
var
|
|
2317
|
+
var reenter = (_transitionConfig$ree = transitionConfig.reenter) !== null && _transitionConfig$ree !== void 0 ? _transitionConfig$ree : false;
|
|
2297
2318
|
var guards = stateNode.machine.options.guards;
|
|
2298
2319
|
var target = resolveTarget(stateNode, normalizedTarget);
|
|
2299
2320
|
|
|
@@ -2308,7 +2329,7 @@ function formatTransition(stateNode, transitionConfig) {
|
|
|
2308
2329
|
}) : undefined,
|
|
2309
2330
|
target: target,
|
|
2310
2331
|
source: stateNode,
|
|
2311
|
-
|
|
2332
|
+
reenter: reenter,
|
|
2312
2333
|
eventType: transitionConfig.event,
|
|
2313
2334
|
toJSON: function toJSON() {
|
|
2314
2335
|
return _objectSpread2(_objectSpread2({}, transition), {}, {
|
|
@@ -2395,7 +2416,7 @@ function formatInitialTransition(stateNode, _target) {
|
|
|
2395
2416
|
source: stateNode,
|
|
2396
2417
|
actions: [],
|
|
2397
2418
|
eventType: null,
|
|
2398
|
-
|
|
2419
|
+
reenter: false,
|
|
2399
2420
|
target: resolvedTarget,
|
|
2400
2421
|
toJSON: function toJSON() {
|
|
2401
2422
|
return _objectSpread2(_objectSpread2({}, transition), {}, {
|
|
@@ -2818,7 +2839,7 @@ function getTransitionDomain(transition, historyValue) {
|
|
|
2818
2839
|
if (!targetStates) {
|
|
2819
2840
|
return null;
|
|
2820
2841
|
}
|
|
2821
|
-
if (!transition.
|
|
2842
|
+
if (!transition.reenter && transition.source.type !== 'parallel' && targetStates.every(function (targetStateNode) {
|
|
2822
2843
|
return isDescendant(targetStateNode, transition.source);
|
|
2823
2844
|
})) {
|
|
2824
2845
|
return transition.source;
|
|
@@ -2888,7 +2909,7 @@ function microstep(transitions, currentState, actorCtx, scxmlEvent) {
|
|
|
2888
2909
|
var microstate = microstepProcedure(currentState._initial ? [{
|
|
2889
2910
|
target: _toConsumableArray(currentState.configuration).filter(isAtomicStateNode),
|
|
2890
2911
|
source: machine.root,
|
|
2891
|
-
|
|
2912
|
+
reenter: true,
|
|
2892
2913
|
actions: [],
|
|
2893
2914
|
eventType: null,
|
|
2894
2915
|
toJSON: null // TODO: fix
|
|
@@ -4048,6 +4069,9 @@ function raise$1(eventOrExpr, options) {
|
|
|
4048
4069
|
var delaysMap = state.machine.options.delays;
|
|
4049
4070
|
|
|
4050
4071
|
// TODO: helper function for resolving Expr
|
|
4072
|
+
if (typeof eventOrExpr === 'string') {
|
|
4073
|
+
throw new Error("Only event objects may be used with raise; use raise({ type: \"".concat(eventOrExpr, "\" }) instead"));
|
|
4074
|
+
}
|
|
4051
4075
|
var resolvedEvent = toSCXMLEvent(typeof eventOrExpr === 'function' ? eventOrExpr(args) : eventOrExpr);
|
|
4052
4076
|
var resolvedDelay;
|
|
4053
4077
|
if (typeof params.delay === 'string') {
|
|
@@ -4098,6 +4122,27 @@ function choose$1(guards) {
|
|
|
4098
4122
|
});
|
|
4099
4123
|
}
|
|
4100
4124
|
|
|
4125
|
+
function pure$1(getActions) {
|
|
4126
|
+
return createDynamicAction({
|
|
4127
|
+
type: pure,
|
|
4128
|
+
params: {
|
|
4129
|
+
get: getActions
|
|
4130
|
+
}
|
|
4131
|
+
}, function (_event, _ref) {
|
|
4132
|
+
var _toArray;
|
|
4133
|
+
var state = _ref.state;
|
|
4134
|
+
return [state, {
|
|
4135
|
+
type: pure,
|
|
4136
|
+
params: {
|
|
4137
|
+
actions: (_toArray = toArray(toActionObjects(getActions({
|
|
4138
|
+
context: state.context,
|
|
4139
|
+
event: _event.data
|
|
4140
|
+
})))) !== null && _toArray !== void 0 ? _toArray : []
|
|
4141
|
+
}
|
|
4142
|
+
}];
|
|
4143
|
+
});
|
|
4144
|
+
}
|
|
4145
|
+
|
|
4101
4146
|
var initEvent = toSCXMLEvent({
|
|
4102
4147
|
type: init
|
|
4103
4148
|
});
|
|
@@ -4270,7 +4315,7 @@ exports.and = and;
|
|
|
4270
4315
|
exports.assign = assign$1;
|
|
4271
4316
|
exports.cancel = cancel$1;
|
|
4272
4317
|
exports.choose = choose$1;
|
|
4273
|
-
exports.
|
|
4318
|
+
exports.createEmptyActor = createEmptyActor;
|
|
4274
4319
|
exports.createInitEvent = createInitEvent;
|
|
4275
4320
|
exports.createInvokeId = createInvokeId;
|
|
4276
4321
|
exports.createSpawner = createSpawner;
|
|
@@ -4314,7 +4359,7 @@ exports.microstep = microstep;
|
|
|
4314
4359
|
exports.not = not;
|
|
4315
4360
|
exports.or = or;
|
|
4316
4361
|
exports.pathToStateValue = pathToStateValue;
|
|
4317
|
-
exports.pure = pure;
|
|
4362
|
+
exports.pure = pure$1;
|
|
4318
4363
|
exports.raise = raise$1;
|
|
4319
4364
|
exports.resolveActionObject = resolveActionObject;
|
|
4320
4365
|
exports.resolveActionsAndContext = resolveActionsAndContext;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { State } from './State.ts';
|
|
2
2
|
import { StateNode } from './StateNode.ts';
|
|
3
3
|
import type { AreAllImplementationsAssumedToBeProvided, MarkAllImplementationsAsProvided, ResolveTypegenMeta, TypegenDisabled } from './typegenTypes.ts';
|
|
4
|
-
import type { ActorContext, ActorMap, ActorBehavior, EventObject, InternalMachineImplementations, MachineConfig, MachineContext, MachineImplementationsSimplified,
|
|
4
|
+
import type { ActorContext, ActorMap, ActorBehavior, EventObject, InternalMachineImplementations, MachineConfig, MachineContext, MachineImplementationsSimplified, MachineTypes, NoInfer, SCXML, StateConfig, StateMachineDefinition, StateValue, TransitionDefinition, PersistedMachineState, ParameterizedObject, AnyActorContext } from './types.ts';
|
|
5
5
|
export declare const NULL_EVENT = "";
|
|
6
6
|
export declare const STATE_IDENTIFIER = "#";
|
|
7
7
|
export declare const WILDCARD = "*";
|
|
@@ -21,7 +21,7 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
|
|
|
21
21
|
*/
|
|
22
22
|
delimiter: string;
|
|
23
23
|
options: MachineImplementationsSimplified<TContext, TEvent>;
|
|
24
|
-
|
|
24
|
+
types: MachineTypes<TContext, TEvent>;
|
|
25
25
|
__xstatenode: true;
|
|
26
26
|
idMap: Map<string, StateNode<TContext, TEvent>>;
|
|
27
27
|
root: StateNode<TContext, TEvent>;
|
|
@@ -7,6 +7,7 @@ export { cancel } from './actions/cancel.ts';
|
|
|
7
7
|
export { assign } from './actions/assign.ts';
|
|
8
8
|
export { raise } from './actions/raise.ts';
|
|
9
9
|
export { choose } from './actions/choose.ts';
|
|
10
|
+
export { pure } from './actions/pure.ts';
|
|
10
11
|
export { actionTypes };
|
|
11
12
|
export declare const initEvent: SCXML.Event<{
|
|
12
13
|
type: ActionTypes;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EventObject, ActorRef, BaseActorRef } from '../types.ts';
|
|
1
|
+
import type { EventObject, ActorRef, BaseActorRef, AnyEventObject } from '../types.ts';
|
|
2
2
|
export { fromTransition } from './transition.ts';
|
|
3
3
|
export { fromPromise } from './promise.ts';
|
|
4
4
|
export { fromObservable, fromEventObservable } from './observable.ts';
|
|
@@ -25,3 +25,4 @@ export type LifecycleSignalType = typeof startSignalType | typeof stopSignalType
|
|
|
25
25
|
export declare function isSignal(eventType: string): eventType is LifecycleSignalType;
|
|
26
26
|
export declare function isActorRef(item: any): item is ActorRef<any>;
|
|
27
27
|
export declare function toActorRef<TEvent extends EventObject, TSnapshot = any, TActorRefLike extends BaseActorRef<TEvent> = BaseActorRef<TEvent>>(actorRefLike: TActorRefLike): ActorRef<TEvent, TSnapshot> & Omit<TActorRefLike, keyof ActorRef<any, any>>;
|
|
28
|
+
export declare function createEmptyActor(): ActorRef<AnyEventObject, undefined>;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Subscribable, ActorBehavior, EventObject, Subscription } from '../types';
|
|
2
2
|
export interface ObservableInternalState<T> {
|
|
3
3
|
subscription: Subscription | undefined;
|
|
4
|
-
|
|
5
|
-
status: 'active' | 'done' | 'error';
|
|
4
|
+
status: 'active' | 'done' | 'error' | 'canceled';
|
|
6
5
|
data: T | undefined;
|
|
7
6
|
input?: any;
|
|
8
7
|
}
|
|
@@ -1,42 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import { stop } from './actions/stop.ts';
|
|
1
|
+
import { doneInvoke, forwardTo, sendParent, sendTo } from './actions.ts';
|
|
2
|
+
export { assign } from './actions/assign.ts';
|
|
3
|
+
export { cancel } from './actions/cancel.ts';
|
|
4
|
+
export { choose } from './actions/choose.ts';
|
|
5
|
+
export { log } from './actions/log.ts';
|
|
6
|
+
export { pure } from './actions/pure.ts';
|
|
7
|
+
export { raise } from './actions/raise.ts';
|
|
8
|
+
export { stop } from './actions/stop.ts';
|
|
10
9
|
import { interpret, Interpreter, ActorStatus } from './interpreter.ts';
|
|
11
10
|
import { createMachine } from './Machine.ts';
|
|
12
11
|
import { mapState } from './mapState.ts';
|
|
13
12
|
import { State } from './State.ts';
|
|
14
13
|
import { StateNode } from './StateNode.ts';
|
|
15
|
-
export { createSchema, t } from './schema.ts';
|
|
16
14
|
export { SimulatedClock } from './SimulatedClock.ts';
|
|
17
15
|
export { StateMachine } from './StateMachine.ts';
|
|
18
16
|
export { getStateNodes } from './stateUtils.ts';
|
|
17
|
+
export { waitFor } from './waitFor.ts';
|
|
19
18
|
export * from './typegenTypes.ts';
|
|
20
19
|
export * from './types.ts';
|
|
21
20
|
export { matchesState, pathToStateValue, toObserver, toSCXMLEvent } from './utils.ts';
|
|
22
|
-
export { StateNode, State, mapState,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
send: typeof send;
|
|
26
|
-
sendParent: typeof sendParent;
|
|
27
|
-
sendTo: typeof sendTo;
|
|
28
|
-
log: typeof log;
|
|
29
|
-
cancel: typeof cancel;
|
|
30
|
-
stop: typeof stop;
|
|
31
|
-
assign: typeof assign;
|
|
32
|
-
after: typeof after;
|
|
33
|
-
done: typeof done;
|
|
34
|
-
respond: typeof respond;
|
|
35
|
-
forwardTo: typeof forwardTo;
|
|
36
|
-
escalate: typeof escalate;
|
|
37
|
-
choose: typeof choose;
|
|
38
|
-
pure: typeof pure;
|
|
39
|
-
};
|
|
21
|
+
export { StateNode, State, mapState, sendTo, sendParent, forwardTo, interpret, Interpreter, ActorStatus as InterpreterStatus, doneInvoke, createMachine };
|
|
22
|
+
export { fromPromise, fromObservable, fromCallback, fromEventObservable, fromTransition } from './actors/index.ts';
|
|
23
|
+
export { stateIn, not, and, or } from './guards.ts';
|
|
40
24
|
declare global {
|
|
41
25
|
interface SymbolConstructor {
|
|
42
26
|
readonly observable: symbol;
|
|
@@ -161,7 +161,7 @@ export type TransitionTarget = SingleOrArray<string>;
|
|
|
161
161
|
export interface TransitionConfig<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject = TExpressionEvent, TAction extends ParameterizedObject = ParameterizedObject> {
|
|
162
162
|
guard?: GuardConfig<TContext, TExpressionEvent>;
|
|
163
163
|
actions?: BaseActions<TContext, TExpressionEvent, TEvent, TAction>;
|
|
164
|
-
|
|
164
|
+
reenter?: boolean;
|
|
165
165
|
target?: TransitionTarget | undefined;
|
|
166
166
|
meta?: Record<string, any>;
|
|
167
167
|
description?: string;
|
|
@@ -490,13 +490,12 @@ export interface MachineConfig<TContext extends MachineContext, TEvent extends E
|
|
|
490
490
|
* If `true`, will use SCXML semantics, such as event token matching.
|
|
491
491
|
*/
|
|
492
492
|
scxml?: boolean;
|
|
493
|
-
|
|
494
|
-
tsTypes?: TTypesMeta;
|
|
493
|
+
types?: MachineTypes<TContext, TEvent, TActorMap, TTypesMeta>;
|
|
495
494
|
}
|
|
496
495
|
export type ActorMap = Record<string, {
|
|
497
496
|
output: any;
|
|
498
497
|
}>;
|
|
499
|
-
export interface
|
|
498
|
+
export interface MachineTypes<TContext extends MachineContext, TEvent extends EventObject, TActorMap extends ActorMap = ActorMap, TTypesMeta = TypegenDisabled> {
|
|
500
499
|
context?: TContext;
|
|
501
500
|
actions?: {
|
|
502
501
|
type: string;
|
|
@@ -508,6 +507,7 @@ export interface MachineSchema<TContext extends MachineContext, TEvent extends E
|
|
|
508
507
|
type: string;
|
|
509
508
|
[key: string]: any;
|
|
510
509
|
};
|
|
510
|
+
typegen?: TTypesMeta;
|
|
511
511
|
}
|
|
512
512
|
export interface HistoryStateNode<TContext extends MachineContext> extends StateNode<TContext> {
|
|
513
513
|
history: 'shallow' | 'deep';
|
|
@@ -731,7 +731,7 @@ export interface TransitionDefinition<TContext extends MachineContext, TEvent ex
|
|
|
731
731
|
target: Array<StateNode<TContext, TEvent>> | undefined;
|
|
732
732
|
source: StateNode<TContext, TEvent>;
|
|
733
733
|
actions: BaseActionObject[];
|
|
734
|
-
|
|
734
|
+
reenter: boolean;
|
|
735
735
|
guard?: GuardDefinition<TContext, TEvent>;
|
|
736
736
|
eventType: TEvent['type'] | '*';
|
|
737
737
|
toJSON: () => {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ActorRef, SnapshotFrom } from '.';
|
|
2
|
+
interface WaitForOptions {
|
|
3
|
+
/**
|
|
4
|
+
* How long to wait before rejecting, if no emitted
|
|
5
|
+
* state satisfies the predicate.
|
|
6
|
+
*
|
|
7
|
+
* @default 10_000 (10 seconds)
|
|
8
|
+
*/
|
|
9
|
+
timeout: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Subscribes to an actor ref and waits for its emitted value to satisfy
|
|
13
|
+
* a predicate, and then resolves with that value.
|
|
14
|
+
* Will throw if the desired state is not reached after a timeout
|
|
15
|
+
* (defaults to 10 seconds).
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```js
|
|
19
|
+
* const state = await waitFor(someService, state => {
|
|
20
|
+
* return state.hasTag('loaded');
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* state.hasTag('loaded'); // true
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @param actorRef The actor ref to subscribe to
|
|
27
|
+
* @param predicate Determines if a value matches the condition to wait for
|
|
28
|
+
* @param options
|
|
29
|
+
* @returns A promise that eventually resolves to the emitted value
|
|
30
|
+
* that matches the condition
|
|
31
|
+
*/
|
|
32
|
+
export declare function waitFor<TActorRef extends ActorRef<any, any>>(actorRef: TActorRef, predicate: (emitted: SnapshotFrom<TActorRef>) => boolean, options?: Partial<WaitForOptions>): Promise<SnapshotFrom<TActorRef>>;
|
|
33
|
+
export {};
|