xstate 5.0.0-alpha.2 → 5.0.0-alpha.3
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 +1 -1
- package/actions/dist/xstate-actions.cjs.prod.js +1 -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 +1 -1
- package/actors/dist/xstate-actors.cjs.prod.js +1 -1
- package/actors/dist/xstate-actors.esm.js +1 -1
- package/actors/dist/xstate-actors.umd.min.js.map +1 -1
- package/dist/{actions-acb29ffe.cjs.prod.js → actions-3910d35f.cjs.prod.js} +94 -46
- package/dist/{actions-1e9778c2.cjs.dev.js → actions-3f0ba11b.cjs.dev.js} +94 -46
- package/dist/{actions-9778f6fb.esm.js → actions-4fe4ada8.esm.js} +94 -46
- package/dist/declarations/src/actions/pure.d.ts +4 -1
- package/dist/declarations/src/types.d.ts +38 -12
- package/dist/xstate.cjs.dev.js +5 -2
- package/dist/xstate.cjs.prod.js +5 -2
- package/dist/xstate.esm.js +6 -3
- 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 +1 -1
- package/guards/dist/xstate-guards.umd.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -377,14 +377,21 @@ function toArray(value) {
|
|
|
377
377
|
}
|
|
378
378
|
function mapContext(mapper, context, _event) {
|
|
379
379
|
if (isFunction(mapper)) {
|
|
380
|
-
return mapper(
|
|
380
|
+
return mapper({
|
|
381
|
+
context: context,
|
|
382
|
+
event: _event.data
|
|
383
|
+
});
|
|
381
384
|
}
|
|
382
385
|
var result = {};
|
|
386
|
+
var args = {
|
|
387
|
+
context: context,
|
|
388
|
+
event: _event.data
|
|
389
|
+
};
|
|
383
390
|
for (var _i4 = 0, _Object$keys2 = Object.keys(mapper); _i4 < _Object$keys2.length; _i4++) {
|
|
384
391
|
var _key3 = _Object$keys2[_i4];
|
|
385
392
|
var subMapper = mapper[_key3];
|
|
386
393
|
if (isFunction(subMapper)) {
|
|
387
|
-
result[_key3] = subMapper(
|
|
394
|
+
result[_key3] = subMapper(args);
|
|
388
395
|
} else {
|
|
389
396
|
result[_key3] = subMapper;
|
|
390
397
|
}
|
|
@@ -549,7 +556,9 @@ function send$1(eventOrExpr, options) {
|
|
|
549
556
|
// there is too big chance of the ID collision
|
|
550
557
|
id: options && options.id !== undefined ? options.id : isFunction(eventOrExpr) ? eventOrExpr.name : eventOrExpr.type
|
|
551
558
|
};
|
|
552
|
-
var
|
|
559
|
+
var args = {
|
|
560
|
+
context: state.context,
|
|
561
|
+
event: _event.data,
|
|
553
562
|
_event: _event,
|
|
554
563
|
state: state,
|
|
555
564
|
self: (_actorContext$self = actorContext === null || actorContext === void 0 ? void 0 : actorContext.self) !== null && _actorContext$self !== void 0 ? _actorContext$self : null,
|
|
@@ -558,15 +567,15 @@ function send$1(eventOrExpr, options) {
|
|
|
558
567
|
var delaysMap = state.machine.options.delays;
|
|
559
568
|
|
|
560
569
|
// TODO: helper function for resolving Expr
|
|
561
|
-
var resolvedEvent = toSCXMLEvent(isFunction(eventOrExpr) ? eventOrExpr(
|
|
570
|
+
var resolvedEvent = toSCXMLEvent(isFunction(eventOrExpr) ? eventOrExpr(args) : eventOrExpr);
|
|
562
571
|
var resolvedDelay;
|
|
563
572
|
if (isString(params.delay)) {
|
|
564
573
|
var configDelay = delaysMap && delaysMap[params.delay];
|
|
565
|
-
resolvedDelay = isFunction(configDelay) ? configDelay(
|
|
574
|
+
resolvedDelay = isFunction(configDelay) ? configDelay(args) : configDelay;
|
|
566
575
|
} else {
|
|
567
|
-
resolvedDelay = isFunction(params.delay) ? params.delay(
|
|
576
|
+
resolvedDelay = isFunction(params.delay) ? params.delay(args) : params.delay;
|
|
568
577
|
}
|
|
569
|
-
var resolvedTarget = isFunction(params.to) ? params.to(
|
|
578
|
+
var resolvedTarget = isFunction(params.to) ? params.to(args) : params.to;
|
|
570
579
|
var targetActorRef;
|
|
571
580
|
if (typeof resolvedTarget === 'string') {
|
|
572
581
|
if (resolvedTarget === SpecialTargets.Parent) {
|
|
@@ -638,7 +647,7 @@ function sendParent(event, options) {
|
|
|
638
647
|
*/
|
|
639
648
|
function respond(event, options) {
|
|
640
649
|
return send$1(event, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
641
|
-
to: function to(
|
|
650
|
+
to: function to(_ref2) {
|
|
642
651
|
var _event = _ref2._event;
|
|
643
652
|
return _event.origin; // TODO: handle when _event.origin is undefined
|
|
644
653
|
}
|
|
@@ -662,7 +671,8 @@ function forwardTo(target, options) {
|
|
|
662
671
|
return resolvedTarget;
|
|
663
672
|
};
|
|
664
673
|
}
|
|
665
|
-
return send$1(function (
|
|
674
|
+
return send$1(function (_ref3) {
|
|
675
|
+
var event = _ref3.event;
|
|
666
676
|
return event;
|
|
667
677
|
}, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
668
678
|
to: target
|
|
@@ -677,10 +687,10 @@ function forwardTo(target, options) {
|
|
|
677
687
|
* @param options Options to pass into the send action creator.
|
|
678
688
|
*/
|
|
679
689
|
function escalate(errorData, options) {
|
|
680
|
-
return sendParent(function (
|
|
690
|
+
return sendParent(function (arg) {
|
|
681
691
|
return {
|
|
682
692
|
type: error,
|
|
683
|
-
data: isFunction(errorData) ? errorData(
|
|
693
|
+
data: isFunction(errorData) ? errorData(arg) : errorData
|
|
684
694
|
};
|
|
685
695
|
}, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
686
696
|
to: SpecialTargets.Parent
|
|
@@ -1774,7 +1784,10 @@ function stop$1(actorRef) {
|
|
|
1774
1784
|
}
|
|
1775
1785
|
}, function (_event, _ref) {
|
|
1776
1786
|
var state = _ref.state;
|
|
1777
|
-
var actorRefOrString = isFunction(actor) ? actor(
|
|
1787
|
+
var actorRefOrString = isFunction(actor) ? actor({
|
|
1788
|
+
context: state.context,
|
|
1789
|
+
event: _event.data
|
|
1790
|
+
}) : actor;
|
|
1778
1791
|
var actorRef = typeof actorRefOrString === 'string' ? state.children[actorRefOrString] : actorRefOrString;
|
|
1779
1792
|
return [state, {
|
|
1780
1793
|
type: 'xstate.stop',
|
|
@@ -1797,7 +1810,9 @@ function stop$1(actorRef) {
|
|
|
1797
1810
|
});
|
|
1798
1811
|
}
|
|
1799
1812
|
|
|
1800
|
-
var defaultLogExpr = function defaultLogExpr(
|
|
1813
|
+
var defaultLogExpr = function defaultLogExpr(_ref) {
|
|
1814
|
+
var context = _ref.context,
|
|
1815
|
+
event = _ref.event;
|
|
1801
1816
|
return {
|
|
1802
1817
|
context: context,
|
|
1803
1818
|
event: event
|
|
@@ -1822,11 +1837,13 @@ function log$1() {
|
|
|
1822
1837
|
label: label,
|
|
1823
1838
|
expr: expr
|
|
1824
1839
|
}
|
|
1825
|
-
}, function (_event,
|
|
1840
|
+
}, function (_event, _ref2) {
|
|
1826
1841
|
var _actorContext$self;
|
|
1827
|
-
var state =
|
|
1828
|
-
actorContext =
|
|
1829
|
-
var resolvedValue = typeof expr === 'function' ? expr(
|
|
1842
|
+
var state = _ref2.state,
|
|
1843
|
+
actorContext = _ref2.actorContext;
|
|
1844
|
+
var resolvedValue = typeof expr === 'function' ? expr({
|
|
1845
|
+
context: state.context,
|
|
1846
|
+
event: _event.data,
|
|
1830
1847
|
_event: _event,
|
|
1831
1848
|
state: state,
|
|
1832
1849
|
self: (_actorContext$self = actorContext === null || actorContext === void 0 ? void 0 : actorContext.self) !== null && _actorContext$self !== void 0 ? _actorContext$self : {},
|
|
@@ -1869,7 +1886,9 @@ function cancel$1(sendId) {
|
|
|
1869
1886
|
var _actorContext$self;
|
|
1870
1887
|
var state = _ref.state,
|
|
1871
1888
|
actorContext = _ref.actorContext;
|
|
1872
|
-
var resolvedSendId = isFunction(sendId) ? sendId(
|
|
1889
|
+
var resolvedSendId = isFunction(sendId) ? sendId({
|
|
1890
|
+
context: state.context,
|
|
1891
|
+
event: _event.data,
|
|
1873
1892
|
_event: _event,
|
|
1874
1893
|
state: state,
|
|
1875
1894
|
// TODO: fix types,
|
|
@@ -1936,7 +1955,7 @@ function stateIn(stateValue) {
|
|
|
1936
1955
|
params: {
|
|
1937
1956
|
stateValue: stateValue
|
|
1938
1957
|
},
|
|
1939
|
-
predicate: function predicate(
|
|
1958
|
+
predicate: function predicate(_ref) {
|
|
1940
1959
|
var state = _ref.state;
|
|
1941
1960
|
if (isString(stateValue) && isStateId(stateValue)) {
|
|
1942
1961
|
return state.configuration.some(function (sn) {
|
|
@@ -1954,8 +1973,13 @@ function not(guard) {
|
|
|
1954
1973
|
op: 'not'
|
|
1955
1974
|
},
|
|
1956
1975
|
children: [toGuardDefinition(guard)],
|
|
1957
|
-
predicate: function predicate(
|
|
1958
|
-
|
|
1976
|
+
predicate: function predicate(_ref2) {
|
|
1977
|
+
var evaluate = _ref2.evaluate,
|
|
1978
|
+
guard = _ref2.guard,
|
|
1979
|
+
context = _ref2.context,
|
|
1980
|
+
_event = _ref2._event,
|
|
1981
|
+
state = _ref2.state;
|
|
1982
|
+
return !evaluate(guard.children[0], context, _event, state);
|
|
1959
1983
|
}
|
|
1960
1984
|
};
|
|
1961
1985
|
}
|
|
@@ -1968,9 +1992,14 @@ function and(guards) {
|
|
|
1968
1992
|
children: guards.map(function (guard) {
|
|
1969
1993
|
return toGuardDefinition(guard);
|
|
1970
1994
|
}),
|
|
1971
|
-
predicate: function predicate(
|
|
1972
|
-
|
|
1973
|
-
|
|
1995
|
+
predicate: function predicate(_ref3) {
|
|
1996
|
+
var evaluate = _ref3.evaluate,
|
|
1997
|
+
guard = _ref3.guard,
|
|
1998
|
+
context = _ref3.context,
|
|
1999
|
+
_event = _ref3._event,
|
|
2000
|
+
state = _ref3.state;
|
|
2001
|
+
return guard.children.every(function (childGuard) {
|
|
2002
|
+
return evaluate(childGuard, context, _event, state);
|
|
1974
2003
|
});
|
|
1975
2004
|
}
|
|
1976
2005
|
};
|
|
@@ -1984,9 +2013,14 @@ function or(guards) {
|
|
|
1984
2013
|
children: guards.map(function (guard) {
|
|
1985
2014
|
return toGuardDefinition(guard);
|
|
1986
2015
|
}),
|
|
1987
|
-
predicate: function predicate(
|
|
1988
|
-
|
|
1989
|
-
|
|
2016
|
+
predicate: function predicate(_ref4) {
|
|
2017
|
+
var evaluate = _ref4.evaluate,
|
|
2018
|
+
guard = _ref4.guard,
|
|
2019
|
+
context = _ref4.context,
|
|
2020
|
+
_event = _ref4._event,
|
|
2021
|
+
state = _ref4.state;
|
|
2022
|
+
return guard.children.some(function (childGuard) {
|
|
2023
|
+
return evaluate(childGuard, context, _event, state);
|
|
1990
2024
|
});
|
|
1991
2025
|
}
|
|
1992
2026
|
};
|
|
@@ -1994,17 +2028,18 @@ function or(guards) {
|
|
|
1994
2028
|
function evaluateGuard(guard, context, _event, state) {
|
|
1995
2029
|
var _machine$options$guar, _machine$options, _machine$options$guar2;
|
|
1996
2030
|
var machine = state.machine;
|
|
1997
|
-
var guardMeta = {
|
|
1998
|
-
state: state,
|
|
1999
|
-
guard: guard,
|
|
2000
|
-
_event: _event,
|
|
2001
|
-
evaluate: evaluateGuard
|
|
2002
|
-
};
|
|
2003
2031
|
var predicate = (_machine$options$guar = machine === null || machine === void 0 ? void 0 : (_machine$options = machine.options) === null || _machine$options === void 0 ? void 0 : (_machine$options$guar2 = _machine$options.guards) === null || _machine$options$guar2 === void 0 ? void 0 : _machine$options$guar2[guard.type]) !== null && _machine$options$guar !== void 0 ? _machine$options$guar : guard.predicate;
|
|
2004
2032
|
if (!predicate) {
|
|
2005
2033
|
throw new Error("Guard '".concat(guard.type, "' is not implemented.'."));
|
|
2006
2034
|
}
|
|
2007
|
-
return predicate(
|
|
2035
|
+
return predicate({
|
|
2036
|
+
context: context,
|
|
2037
|
+
event: _event.data,
|
|
2038
|
+
state: state,
|
|
2039
|
+
guard: guard,
|
|
2040
|
+
_event: _event,
|
|
2041
|
+
evaluate: evaluateGuard
|
|
2042
|
+
});
|
|
2008
2043
|
}
|
|
2009
2044
|
function toGuardDefinition(guardConfig, getPredicate) {
|
|
2010
2045
|
var _guardConfig$children;
|
|
@@ -3861,8 +3896,10 @@ function invoke$1(invokeDef) {
|
|
|
3861
3896
|
src: src,
|
|
3862
3897
|
parent: actorContext === null || actorContext === void 0 ? void 0 : actorContext.self,
|
|
3863
3898
|
systemId: invokeDef.systemId,
|
|
3864
|
-
input: typeof input === 'function' ? input(
|
|
3865
|
-
|
|
3899
|
+
input: typeof input === 'function' ? input({
|
|
3900
|
+
context: state.context,
|
|
3901
|
+
event: _event.data,
|
|
3902
|
+
self: actorContext === null || actorContext === void 0 ? void 0 : actorContext.self
|
|
3866
3903
|
}) : input
|
|
3867
3904
|
});
|
|
3868
3905
|
resolvedInvokeAction = {
|
|
@@ -3919,7 +3956,9 @@ function createSpawner(self, machine, context, _event, mutCapturedActions) {
|
|
|
3919
3956
|
var actorRef = interpret(referenced.src, {
|
|
3920
3957
|
id: resolvedName,
|
|
3921
3958
|
parent: self,
|
|
3922
|
-
input: typeof input === 'function' ? input(
|
|
3959
|
+
input: typeof input === 'function' ? input({
|
|
3960
|
+
context: context,
|
|
3961
|
+
event: _event.data,
|
|
3923
3962
|
self: self
|
|
3924
3963
|
}) : input
|
|
3925
3964
|
});
|
|
@@ -3977,7 +4016,9 @@ function assign$1(assignment) {
|
|
|
3977
4016
|
if (!state.context) {
|
|
3978
4017
|
throw new Error('Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.');
|
|
3979
4018
|
}
|
|
3980
|
-
var
|
|
4019
|
+
var args = {
|
|
4020
|
+
context: state.context,
|
|
4021
|
+
event: _event.data,
|
|
3981
4022
|
state: state,
|
|
3982
4023
|
action: action,
|
|
3983
4024
|
_event: _event,
|
|
@@ -3987,12 +4028,12 @@ function assign$1(assignment) {
|
|
|
3987
4028
|
};
|
|
3988
4029
|
var partialUpdate = {};
|
|
3989
4030
|
if (isFunction(assignment)) {
|
|
3990
|
-
partialUpdate = assignment(
|
|
4031
|
+
partialUpdate = assignment(args);
|
|
3991
4032
|
} else {
|
|
3992
4033
|
for (var _i = 0, _Object$keys = Object.keys(assignment); _i < _Object$keys.length; _i++) {
|
|
3993
4034
|
var key = _Object$keys[_i];
|
|
3994
4035
|
var propAssignment = assignment[key];
|
|
3995
|
-
partialUpdate[key] = isFunction(propAssignment) ? propAssignment(
|
|
4036
|
+
partialUpdate[key] = isFunction(propAssignment) ? propAssignment(args) : propAssignment;
|
|
3996
4037
|
}
|
|
3997
4038
|
}
|
|
3998
4039
|
var updatedContext = Object.assign({}, state.context, partialUpdate);
|
|
@@ -4032,22 +4073,25 @@ function raise$1(eventOrExpr, options) {
|
|
|
4032
4073
|
event: eventOrExpr,
|
|
4033
4074
|
id: options && options.id !== undefined ? options.id : typeof eventOrExpr === 'function' ? eventOrExpr.name : eventOrExpr.type
|
|
4034
4075
|
};
|
|
4035
|
-
var
|
|
4076
|
+
var args = {
|
|
4077
|
+
context: state.context,
|
|
4078
|
+
event: _event.data,
|
|
4036
4079
|
_event: _event,
|
|
4037
4080
|
state: state,
|
|
4081
|
+
// TODO: fix
|
|
4038
4082
|
self: (_actorContext$self = actorContext === null || actorContext === void 0 ? void 0 : actorContext.self) !== null && _actorContext$self !== void 0 ? _actorContext$self : {},
|
|
4039
4083
|
system: actorContext === null || actorContext === void 0 ? void 0 : actorContext.system
|
|
4040
4084
|
};
|
|
4041
4085
|
var delaysMap = state.machine.options.delays;
|
|
4042
4086
|
|
|
4043
4087
|
// TODO: helper function for resolving Expr
|
|
4044
|
-
var resolvedEvent = toSCXMLEvent(typeof eventOrExpr === 'function' ? eventOrExpr(
|
|
4088
|
+
var resolvedEvent = toSCXMLEvent(typeof eventOrExpr === 'function' ? eventOrExpr(args) : eventOrExpr);
|
|
4045
4089
|
var resolvedDelay;
|
|
4046
4090
|
if (typeof params.delay === 'string') {
|
|
4047
4091
|
var configDelay = delaysMap && delaysMap[params.delay];
|
|
4048
|
-
resolvedDelay = typeof configDelay === 'function' ? configDelay(
|
|
4092
|
+
resolvedDelay = typeof configDelay === 'function' ? configDelay(args) : configDelay;
|
|
4049
4093
|
} else {
|
|
4050
|
-
resolvedDelay = typeof params.delay === 'function' ? params.delay(
|
|
4094
|
+
resolvedDelay = typeof params.delay === 'function' ? params.delay(args) : params.delay;
|
|
4051
4095
|
}
|
|
4052
4096
|
var resolvedAction = {
|
|
4053
4097
|
type: raise,
|
|
@@ -4110,7 +4154,9 @@ function resolveActionObject(actionObject, actionFunctionMap) {
|
|
|
4110
4154
|
type: actionObject.type,
|
|
4111
4155
|
params: actionObject.params,
|
|
4112
4156
|
execute: function execute(actorCtx) {
|
|
4113
|
-
return dereferencedAction(
|
|
4157
|
+
return dereferencedAction({
|
|
4158
|
+
context: state.context,
|
|
4159
|
+
event: state.event,
|
|
4114
4160
|
action: a,
|
|
4115
4161
|
_event: state._event,
|
|
4116
4162
|
state: state,
|
|
@@ -4150,7 +4196,9 @@ function toActionObject(action) {
|
|
|
4150
4196
|
"function": action
|
|
4151
4197
|
},
|
|
4152
4198
|
execute: function execute(actorCtx) {
|
|
4153
|
-
return action(
|
|
4199
|
+
return action({
|
|
4200
|
+
context: state.context,
|
|
4201
|
+
event: _event.data,
|
|
4154
4202
|
action: actionObject,
|
|
4155
4203
|
_event: _event,
|
|
4156
4204
|
state: state,
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { EventObject, SingleOrArray, MachineContext } from '../types.js';
|
|
2
2
|
import { BaseActionObject, BaseDynamicActionObject, DynamicPureActionObject, PureActionObject } from '..';
|
|
3
|
-
export declare function pure<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject = TExpressionEvent>(getActions: (context
|
|
3
|
+
export declare function pure<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject = TExpressionEvent>(getActions: ({ context, event }: {
|
|
4
|
+
context: TContext;
|
|
5
|
+
event: TExpressionEvent;
|
|
6
|
+
}) => SingleOrArray<BaseActionObject | string> | undefined): BaseDynamicActionObject<TContext, TExpressionEvent, TEvent, PureActionObject, DynamicPureActionObject<TContext, TExpressionEvent>['params']>;
|
|
@@ -51,6 +51,10 @@ export interface BuiltInActionObject extends ParameterizedObject {
|
|
|
51
51
|
type: `xstate.${string}`;
|
|
52
52
|
params: Record<string, any>;
|
|
53
53
|
}
|
|
54
|
+
export interface UnifiedArg<TContext extends MachineContext, TEvent extends EventObject> {
|
|
55
|
+
context: TContext;
|
|
56
|
+
event: TEvent;
|
|
57
|
+
}
|
|
54
58
|
export interface BaseDynamicActionObject<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject, TResolvedAction extends BaseActionObject, TDynamicParams extends Record<string, any>> {
|
|
55
59
|
type: `xstate.${string}`;
|
|
56
60
|
params: TDynamicParams;
|
|
@@ -63,7 +67,10 @@ export interface BaseDynamicActionObject<TContext extends MachineContext, TExpre
|
|
|
63
67
|
actorContext: AnyActorContext | undefined;
|
|
64
68
|
}) => [AnyState, TResolvedAction];
|
|
65
69
|
/** @deprecated an internal signature that doesn't exist at runtime. Its existence helps TS to choose a better code path in the inference algorithm */
|
|
66
|
-
(
|
|
70
|
+
(args: {
|
|
71
|
+
context: TContext;
|
|
72
|
+
event: TExpressionEvent;
|
|
73
|
+
} & ActionMeta<TContext, TEvent, ParameterizedObject>): void;
|
|
67
74
|
}
|
|
68
75
|
export type MachineContext = Record<string, any>;
|
|
69
76
|
export interface ActionMeta<TContext extends MachineContext, TEvent extends EventObject, TAction extends ParameterizedObject = ParameterizedObject> extends StateMeta<TContext, TEvent> {
|
|
@@ -80,9 +87,10 @@ export interface AssignMeta<TContext extends MachineContext, TExpressionEvent ex
|
|
|
80
87
|
_event: SCXML.Event<TExpressionEvent>;
|
|
81
88
|
spawn: Spawner;
|
|
82
89
|
}
|
|
83
|
-
export type ActionFunction<TContext extends MachineContext, TExpressionEvent extends EventObject, TAction extends ParameterizedObject = ParameterizedObject, TEvent extends EventObject = TExpressionEvent> = {
|
|
84
|
-
|
|
85
|
-
|
|
90
|
+
export type ActionFunction<TContext extends MachineContext, TExpressionEvent extends EventObject, TAction extends ParameterizedObject = ParameterizedObject, TEvent extends EventObject = TExpressionEvent> = (args: {
|
|
91
|
+
context: TContext;
|
|
92
|
+
event: TExpressionEvent;
|
|
93
|
+
} & ActionMeta<TContext, TEvent, TAction>) => void;
|
|
86
94
|
export interface ChooseCondition<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject = TExpressionEvent> {
|
|
87
95
|
guard?: GuardConfig<TContext, TEvent>;
|
|
88
96
|
actions: Actions<TContext, TExpressionEvent, TEvent>;
|
|
@@ -107,7 +115,10 @@ export interface StateValueMap {
|
|
|
107
115
|
* - For complex state nodes, this is an object, e.g., `{ success: "someChildState" }`.
|
|
108
116
|
*/
|
|
109
117
|
export type StateValue = string | StateValueMap;
|
|
110
|
-
export type GuardPredicate<TContext extends MachineContext, TEvent extends EventObject> = (
|
|
118
|
+
export type GuardPredicate<TContext extends MachineContext, TEvent extends EventObject> = (args: {
|
|
119
|
+
context: TContext;
|
|
120
|
+
event: TEvent;
|
|
121
|
+
} & GuardMeta<TContext, TEvent>) => boolean;
|
|
111
122
|
export interface DefaultGuardObject<TContext extends MachineContext, TEvent extends EventObject> extends ParameterizedObject {
|
|
112
123
|
/**
|
|
113
124
|
* Nested guards
|
|
@@ -623,8 +634,8 @@ export interface SendActionObject<TSentEvent extends EventObject = AnyEventObjec
|
|
|
623
634
|
internal: boolean;
|
|
624
635
|
};
|
|
625
636
|
}
|
|
626
|
-
export type Expr<TContext extends MachineContext, TEvent extends EventObject, T> = (
|
|
627
|
-
export type ExprWithMeta<TContext extends MachineContext, TEvent extends EventObject, T> = (
|
|
637
|
+
export type Expr<TContext extends MachineContext, TEvent extends EventObject, T> = (arg: UnifiedArg<TContext, TEvent>) => T;
|
|
638
|
+
export type ExprWithMeta<TContext extends MachineContext, TEvent extends EventObject, T> = (args: UnifiedArg<TContext, TEvent> & StateMeta<TContext, TEvent>) => T;
|
|
628
639
|
export type SendExpr<TContext extends MachineContext, TEvent extends EventObject, TSentEvent extends EventObject = AnyEventObject> = ExprWithMeta<TContext, TEvent, TSentEvent>;
|
|
629
640
|
export declare enum SpecialTargets {
|
|
630
641
|
Parent = "#_parent",
|
|
@@ -655,14 +666,26 @@ export interface CancelActionObject extends BaseActionObject {
|
|
|
655
666
|
sendId: string;
|
|
656
667
|
};
|
|
657
668
|
}
|
|
658
|
-
export type Assigner<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject = TExpressionEvent> = (
|
|
659
|
-
|
|
669
|
+
export type Assigner<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject = TExpressionEvent> = (args: {
|
|
670
|
+
context: TContext;
|
|
671
|
+
event: TExpressionEvent;
|
|
672
|
+
} & AssignMeta<TContext, TExpressionEvent, TEvent>) => Partial<TContext>;
|
|
673
|
+
export type PartialAssigner<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject, TKey extends keyof TContext> = (args: {
|
|
674
|
+
context: TContext;
|
|
675
|
+
event: TExpressionEvent;
|
|
676
|
+
} & AssignMeta<TContext, TExpressionEvent, TEvent>) => TContext[TKey];
|
|
660
677
|
export type PropertyAssigner<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject = TExpressionEvent> = {
|
|
661
678
|
[K in keyof TContext]?: PartialAssigner<TContext, TExpressionEvent, TEvent, K> | TContext[K];
|
|
662
679
|
};
|
|
663
|
-
export type Mapper<TContext extends MachineContext, TEvent extends EventObject, TParams extends {}> = (
|
|
680
|
+
export type Mapper<TContext extends MachineContext, TEvent extends EventObject, TParams extends {}> = (args: {
|
|
681
|
+
context: TContext;
|
|
682
|
+
event: TEvent;
|
|
683
|
+
}) => TParams;
|
|
664
684
|
export type PropertyMapper<TContext extends MachineContext, TEvent extends EventObject, TParams extends {}> = {
|
|
665
|
-
[K in keyof TParams]?: ((
|
|
685
|
+
[K in keyof TParams]?: ((args: {
|
|
686
|
+
context: TContext;
|
|
687
|
+
event: TEvent;
|
|
688
|
+
}) => TParams[K]) | TParams[K];
|
|
666
689
|
};
|
|
667
690
|
export interface AnyAssignAction extends BaseActionObject {
|
|
668
691
|
type: ActionTypes.Assign;
|
|
@@ -681,7 +704,10 @@ export interface AssignActionObject<TContext extends MachineContext> extends Bas
|
|
|
681
704
|
export interface DynamicPureActionObject<TContext extends MachineContext, TEvent extends EventObject> {
|
|
682
705
|
type: ActionTypes.Pure;
|
|
683
706
|
params: {
|
|
684
|
-
get: (
|
|
707
|
+
get: (args: {
|
|
708
|
+
context: TContext;
|
|
709
|
+
event: TEvent;
|
|
710
|
+
}) => SingleOrArray<BaseActionObject | BaseActionObject['type']> | undefined;
|
|
685
711
|
};
|
|
686
712
|
}
|
|
687
713
|
export interface PureActionObject extends BaseActionObject {
|
package/dist/xstate.cjs.dev.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var actors_dist_xstateActors = require('./actions-
|
|
5
|
+
var actors_dist_xstateActors = require('./actions-3f0ba11b.cjs.dev.js');
|
|
6
6
|
require('./index-ebaab3c9.cjs.dev.js');
|
|
7
7
|
|
|
8
8
|
function pure(getActions) {
|
|
@@ -17,7 +17,10 @@ function pure(getActions) {
|
|
|
17
17
|
return [state, {
|
|
18
18
|
type: actors_dist_xstateActors.pure,
|
|
19
19
|
params: {
|
|
20
|
-
actions: (_toArray = actors_dist_xstateActors.toArray(actors_dist_xstateActors.toActionObjects(getActions(
|
|
20
|
+
actions: (_toArray = actors_dist_xstateActors.toArray(actors_dist_xstateActors.toActionObjects(getActions({
|
|
21
|
+
context: state.context,
|
|
22
|
+
event: _event.data
|
|
23
|
+
})))) !== null && _toArray !== void 0 ? _toArray : []
|
|
21
24
|
}
|
|
22
25
|
}];
|
|
23
26
|
});
|
package/dist/xstate.cjs.prod.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var actors_dist_xstateActors = require('./actions-
|
|
5
|
+
var actors_dist_xstateActors = require('./actions-3910d35f.cjs.prod.js');
|
|
6
6
|
require('../dev/dist/xstate-dev.cjs.prod.js');
|
|
7
7
|
|
|
8
8
|
function pure(getActions) {
|
|
@@ -17,7 +17,10 @@ function pure(getActions) {
|
|
|
17
17
|
return [state, {
|
|
18
18
|
type: actors_dist_xstateActors.pure,
|
|
19
19
|
params: {
|
|
20
|
-
actions: (_toArray = actors_dist_xstateActors.toArray(actors_dist_xstateActors.toActionObjects(getActions(
|
|
20
|
+
actions: (_toArray = actors_dist_xstateActors.toArray(actors_dist_xstateActors.toActionObjects(getActions({
|
|
21
|
+
context: state.context,
|
|
22
|
+
event: _event.data
|
|
23
|
+
})))) !== null && _toArray !== void 0 ? _toArray : []
|
|
21
24
|
}
|
|
22
25
|
}];
|
|
23
26
|
});
|
package/dist/xstate.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as createDynamicAction, p as pure$1, t as toArray, a as toActionObjects, _ as _createClass, f as formatTransitions, b as toTransitionConfigArray, N as NULL_EVENT, d as formatTransition, m as mapValues, e as memo, g as _createForOfIteratorHelper, h as evaluateGuard, i as _toConsumableArray, j as flatten, k as _classCallCheck, l as _defineProperty, n as createInvokeId, o as toInvokeConfig, q as _objectSpread2, r as invoke, s as _objectWithoutProperties, u as getDelayedTransitions, v as formatInitialTransition, w as getCandidates, x as isString, y as createSpawner, z as createInitEvent, A as getConfiguration, B as getStateNodes, C as resolveStateValue, D as isInFinalState, S as State, E as toSCXMLEvent, F as isSCXMLErrorEvent, G as macrostep, H as transitionNode, I as _slicedToArray, J as getInitialConfiguration, K as resolveActionsAndContext, L as microstep, M as error, O as isStateId, P as getPersistedState, Q as resolveReferencedActor, R as interpret, T as STATE_DELIMITER, U as initEvent, V as matchesState, W as raise, X as send, Y as sendParent, Z as sendTo, $ as log, a0 as cancel, a1 as stop, a2 as assign, a3 as after, a4 as done, a5 as respond, a6 as forwardTo, a7 as escalate, a8 as choose } from './actions-
|
|
2
|
-
export { ae as ActionTypes, a9 as Interpreter, aa as InterpreterStatus, af as SpecialTargets, S as State, a2 as assign, ab as doneInvoke, a6 as forwardTo, B as getStateNodes, R as interpret, V as matchesState, ac as pathToStateValue, X as send, Y as sendParent, Z as sendTo, ad as toObserver, E as toSCXMLEvent } from './actions-
|
|
1
|
+
import { c as createDynamicAction, p as pure$1, t as toArray, a as toActionObjects, _ as _createClass, f as formatTransitions, b as toTransitionConfigArray, N as NULL_EVENT, d as formatTransition, m as mapValues, e as memo, g as _createForOfIteratorHelper, h as evaluateGuard, i as _toConsumableArray, j as flatten, k as _classCallCheck, l as _defineProperty, n as createInvokeId, o as toInvokeConfig, q as _objectSpread2, r as invoke, s as _objectWithoutProperties, u as getDelayedTransitions, v as formatInitialTransition, w as getCandidates, x as isString, y as createSpawner, z as createInitEvent, A as getConfiguration, B as getStateNodes, C as resolveStateValue, D as isInFinalState, S as State, E as toSCXMLEvent, F as isSCXMLErrorEvent, G as macrostep, H as transitionNode, I as _slicedToArray, J as getInitialConfiguration, K as resolveActionsAndContext, L as microstep, M as error, O as isStateId, P as getPersistedState, Q as resolveReferencedActor, R as interpret, T as STATE_DELIMITER, U as initEvent, V as matchesState, W as raise, X as send, Y as sendParent, Z as sendTo, $ as log, a0 as cancel, a1 as stop, a2 as assign, a3 as after, a4 as done, a5 as respond, a6 as forwardTo, a7 as escalate, a8 as choose } from './actions-4fe4ada8.esm.js';
|
|
2
|
+
export { ae as ActionTypes, a9 as Interpreter, aa as InterpreterStatus, af as SpecialTargets, S as State, a2 as assign, ab as doneInvoke, a6 as forwardTo, B as getStateNodes, R as interpret, V as matchesState, ac as pathToStateValue, X as send, Y as sendParent, Z as sendTo, ad as toObserver, E as toSCXMLEvent } from './actions-4fe4ada8.esm.js';
|
|
3
3
|
import './index-50bd0aff.esm.js';
|
|
4
4
|
|
|
5
5
|
function pure(getActions) {
|
|
@@ -14,7 +14,10 @@ function pure(getActions) {
|
|
|
14
14
|
return [state, {
|
|
15
15
|
type: pure$1,
|
|
16
16
|
params: {
|
|
17
|
-
actions: (_toArray = toArray(toActionObjects(getActions(
|
|
17
|
+
actions: (_toArray = toArray(toActionObjects(getActions({
|
|
18
|
+
context: state.context,
|
|
19
|
+
event: _event.data
|
|
20
|
+
})))) !== null && _toArray !== void 0 ? _toArray : []
|
|
18
21
|
}
|
|
19
22
|
}];
|
|
20
23
|
});
|