xstate 5.0.0-beta.37 → 5.0.0-beta.38
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.js +4 -3
- package/actions/dist/xstate-actions.cjs.mjs +1 -0
- package/actions/dist/xstate-actions.development.cjs.js +4 -3
- package/actions/dist/xstate-actions.development.cjs.mjs +1 -0
- package/actions/dist/xstate-actions.development.esm.js +3 -3
- package/actions/dist/xstate-actions.esm.js +3 -3
- 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.js +1 -1
- package/actors/dist/xstate-actors.development.cjs.js +1 -1
- package/actors/dist/xstate-actors.development.esm.js +1 -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/declarations/src/State.d.ts +2 -2
- package/dist/declarations/src/StateMachine.d.ts +4 -4
- package/dist/declarations/src/actions/assign.d.ts +4 -4
- package/dist/declarations/src/actions/cancel.d.ts +4 -4
- package/dist/declarations/src/actions/choose.d.ts +3 -3
- package/dist/declarations/src/actions/log.d.ts +4 -4
- package/dist/declarations/src/actions/pure.d.ts +4 -4
- package/dist/declarations/src/actions/raise.d.ts +3 -3
- package/dist/declarations/src/actions/send.d.ts +7 -7
- package/dist/declarations/src/actions/spawn.d.ts +34 -0
- package/dist/declarations/src/actions/stop.d.ts +4 -4
- package/dist/declarations/src/actions.d.ts +1 -0
- package/dist/declarations/src/actors/callback.d.ts +2 -2
- package/dist/declarations/src/actors/observable.d.ts +2 -3
- package/dist/declarations/src/actors/promise.d.ts +0 -1
- package/dist/declarations/src/actors/transition.d.ts +1 -1
- package/dist/declarations/src/guards.d.ts +9 -10
- package/dist/declarations/src/interpreter.d.ts +2 -2
- package/dist/declarations/src/spawn.d.ts +1 -2
- package/dist/declarations/src/stateUtils.d.ts +0 -5
- package/dist/declarations/src/types.d.ts +46 -57
- package/dist/{interpreter-1c52b23c.development.esm.js → interpreter-4005eb36.development.esm.js} +1 -1
- package/dist/{interpreter-97aff8d2.cjs.js → interpreter-b6f22ee2.cjs.js} +1 -1
- package/dist/{interpreter-8def682e.esm.js → interpreter-c80ce92e.esm.js} +1 -1
- package/dist/{interpreter-e58ca48d.development.cjs.js → interpreter-ed3f81f7.development.cjs.js} +1 -1
- package/dist/{raise-e342a840.development.esm.js → raise-42073973.development.esm.js} +68 -79
- package/dist/{raise-800296d7.cjs.js → raise-7faa9b3b.cjs.js} +69 -79
- package/dist/{raise-1fd59c65.development.cjs.js → raise-b69a3d16.development.cjs.js} +68 -78
- package/dist/{raise-21c417c1.esm.js → raise-c989c7fb.esm.js} +69 -80
- package/dist/{send-4cc29786.cjs.js → send-34160163.cjs.js} +27 -26
- package/dist/{send-92854675.esm.js → send-4b616da9.esm.js} +27 -26
- package/dist/{send-b309ef4e.development.cjs.js → send-58725522.development.cjs.js} +27 -26
- package/dist/{send-83ccc98b.development.esm.js → send-bff8c910.development.esm.js} +27 -26
- package/dist/xstate.cjs.js +9 -6
- package/dist/xstate.cjs.mjs +1 -0
- package/dist/xstate.development.cjs.js +9 -6
- package/dist/xstate.development.cjs.mjs +1 -0
- package/dist/xstate.development.esm.js +11 -9
- package/dist/xstate.esm.js +11 -9
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +1 -1
- package/guards/dist/xstate-guards.cjs.js +2 -2
- package/guards/dist/xstate-guards.development.cjs.js +2 -2
- package/guards/dist/xstate-guards.development.esm.js +2 -2
- package/guards/dist/xstate-guards.esm.js +2 -2
- 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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as resolveReferencedActor, d as createActor, f as ActorStatus, j as createErrorActorEvent, k as toStateValue, l as STATE_IDENTIFIER, n as normalizeTarget, t as toArray, N as NULL_EVENT, a as toTransitionConfigArray, S as STATE_DELIMITER, o as toStatePath, q as createDoneStateEvent, s as resolveOutput, X as XSTATE_STOP, u as XSTATE_INIT, W as WILDCARD, v as createAfterEvent, w as flatten, e as matchesState, $ as $$ACTOR_TYPE } from './interpreter-
|
|
1
|
+
import { r as resolveReferencedActor, d as createActor, f as ActorStatus, j as createErrorActorEvent, k as toStateValue, l as STATE_IDENTIFIER, n as normalizeTarget, t as toArray, N as NULL_EVENT, a as toTransitionConfigArray, S as STATE_DELIMITER, o as toStatePath, q as createDoneStateEvent, s as resolveOutput, X as XSTATE_STOP, u as XSTATE_INIT, W as WILDCARD, v as createAfterEvent, w as flatten, e as matchesState, $ as $$ACTOR_TYPE } from './interpreter-c80ce92e.esm.js';
|
|
2
2
|
|
|
3
3
|
const cache = new WeakMap();
|
|
4
4
|
function memo(object, key, fn) {
|
|
@@ -14,10 +14,10 @@ function memo(object, key, fn) {
|
|
|
14
14
|
return memoizedData[key];
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
function resolveCancel(_, state, actionArgs, {
|
|
17
|
+
function resolveCancel(_, state, actionArgs, actionParams, {
|
|
18
18
|
sendId
|
|
19
19
|
}) {
|
|
20
|
-
const resolvedSendId = typeof sendId === 'function' ? sendId(actionArgs) : sendId;
|
|
20
|
+
const resolvedSendId = typeof sendId === 'function' ? sendId(actionArgs, actionParams) : sendId;
|
|
21
21
|
return [state, resolvedSendId];
|
|
22
22
|
}
|
|
23
23
|
function executeCancel(actorContext, resolvedSendId) {
|
|
@@ -31,7 +31,7 @@ function executeCancel(actorContext, resolvedSendId) {
|
|
|
31
31
|
* @param sendId The `id` of the `send(...)` action to cancel.
|
|
32
32
|
*/
|
|
33
33
|
function cancel(sendId) {
|
|
34
|
-
function cancel(
|
|
34
|
+
function cancel(args, params) {
|
|
35
35
|
}
|
|
36
36
|
cancel.type = 'xstate.cancel';
|
|
37
37
|
cancel.sendId = sendId;
|
|
@@ -40,7 +40,7 @@ function cancel(sendId) {
|
|
|
40
40
|
return cancel;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
function
|
|
43
|
+
function resolveSpawn(actorContext, state, actionArgs, _actionParams, {
|
|
44
44
|
id,
|
|
45
45
|
systemId,
|
|
46
46
|
src,
|
|
@@ -51,12 +51,13 @@ function resolveInvoke(actorContext, state, actionArgs, {
|
|
|
51
51
|
src,
|
|
52
52
|
input: undefined
|
|
53
53
|
};
|
|
54
|
+
const resolvedId = typeof id === 'function' ? id(actionArgs) : id;
|
|
54
55
|
let actorRef;
|
|
55
56
|
if (referenced) {
|
|
56
57
|
// TODO: inline `input: undefined` should win over the referenced one
|
|
57
58
|
const configuredInput = input || referenced.input;
|
|
58
59
|
actorRef = createActor(referenced.src, {
|
|
59
|
-
id,
|
|
60
|
+
id: resolvedId,
|
|
60
61
|
src: typeof src === 'string' ? src : undefined,
|
|
61
62
|
parent: actorContext?.self,
|
|
62
63
|
systemId,
|
|
@@ -76,23 +77,21 @@ function resolveInvoke(actorContext, state, actionArgs, {
|
|
|
76
77
|
});
|
|
77
78
|
}
|
|
78
79
|
},
|
|
79
|
-
error: () => {
|
|
80
|
-
/* TODO */
|
|
81
|
-
}
|
|
80
|
+
error: () => {}
|
|
82
81
|
});
|
|
83
82
|
}
|
|
84
83
|
}
|
|
85
84
|
return [cloneState(state, {
|
|
86
85
|
children: {
|
|
87
86
|
...state.children,
|
|
88
|
-
[
|
|
87
|
+
[resolvedId]: actorRef
|
|
89
88
|
}
|
|
90
89
|
}), {
|
|
91
90
|
id,
|
|
92
91
|
actorRef
|
|
93
92
|
}];
|
|
94
93
|
}
|
|
95
|
-
function
|
|
94
|
+
function executeSpawn(actorContext, {
|
|
96
95
|
id,
|
|
97
96
|
actorRef
|
|
98
97
|
}) {
|
|
@@ -111,33 +110,29 @@ function executeInvoke(actorContext, {
|
|
|
111
110
|
}
|
|
112
111
|
});
|
|
113
112
|
}
|
|
114
|
-
|
|
115
|
-
// we don't export this since it's an internal action that is not meant to be used in the user's code
|
|
116
|
-
|
|
117
|
-
function invoke({
|
|
113
|
+
function spawn(...[src, {
|
|
118
114
|
id,
|
|
119
115
|
systemId,
|
|
120
|
-
src,
|
|
121
116
|
input,
|
|
122
|
-
|
|
123
|
-
}) {
|
|
124
|
-
function
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
return
|
|
117
|
+
syncSnapshot = false
|
|
118
|
+
} = {}]) {
|
|
119
|
+
function spawn(args, params) {
|
|
120
|
+
}
|
|
121
|
+
spawn.type = 'xstate.spawn';
|
|
122
|
+
spawn.id = id;
|
|
123
|
+
spawn.systemId = systemId;
|
|
124
|
+
spawn.src = src;
|
|
125
|
+
spawn.input = input;
|
|
126
|
+
spawn.syncSnapshot = syncSnapshot;
|
|
127
|
+
spawn.resolve = resolveSpawn;
|
|
128
|
+
spawn.execute = executeSpawn;
|
|
129
|
+
return spawn;
|
|
135
130
|
}
|
|
136
131
|
|
|
137
|
-
function resolveStop(_, state, args, {
|
|
132
|
+
function resolveStop(_, state, args, actionParams, {
|
|
138
133
|
actorRef
|
|
139
134
|
}) {
|
|
140
|
-
const actorRefOrString = typeof actorRef === 'function' ? actorRef(args) : actorRef;
|
|
135
|
+
const actorRefOrString = typeof actorRef === 'function' ? actorRef(args, actionParams) : actorRef;
|
|
141
136
|
const resolvedActorRef = typeof actorRefOrString === 'string' ? state.children[actorRefOrString] : actorRefOrString;
|
|
142
137
|
let children = state.children;
|
|
143
138
|
if (resolvedActorRef) {
|
|
@@ -154,6 +149,12 @@ function executeStop(actorContext, actorRef) {
|
|
|
154
149
|
if (!actorRef) {
|
|
155
150
|
return;
|
|
156
151
|
}
|
|
152
|
+
|
|
153
|
+
// we need to eagerly unregister it here so a new actor with the same systemId can be registered immediately
|
|
154
|
+
// since we defer actual stopping of the actor but we don't defer actor creations (and we can't do that)
|
|
155
|
+
// this could throw on `systemId` collision, for example, when dealing with reentering transitions
|
|
156
|
+
actorContext.system._unregister(actorRef);
|
|
157
|
+
|
|
157
158
|
// this allows us to prevent an actor from being started if it gets stopped within the same macrostep
|
|
158
159
|
// this can happen, for example, when the invoking state is being exited immediately by an always transition
|
|
159
160
|
if (actorRef.status !== ActorStatus.Running) {
|
|
@@ -174,7 +175,7 @@ function executeStop(actorContext, actorRef) {
|
|
|
174
175
|
* @param actorRef The actor to stop.
|
|
175
176
|
*/
|
|
176
177
|
function stop(actorRef) {
|
|
177
|
-
function stop(
|
|
178
|
+
function stop(args, params) {
|
|
178
179
|
}
|
|
179
180
|
stop.type = 'xstate.stop';
|
|
180
181
|
stop.actorRef = actorRef;
|
|
@@ -193,7 +194,7 @@ function checkStateIn(state, _, {
|
|
|
193
194
|
return state.matches(stateValue);
|
|
194
195
|
}
|
|
195
196
|
function stateIn(stateValue) {
|
|
196
|
-
function stateIn(
|
|
197
|
+
function stateIn(args, params) {
|
|
197
198
|
return false;
|
|
198
199
|
}
|
|
199
200
|
stateIn.check = checkStateIn;
|
|
@@ -209,7 +210,7 @@ function checkNot(state, {
|
|
|
209
210
|
return !evaluateGuard(guards[0], context, event, state);
|
|
210
211
|
}
|
|
211
212
|
function not(guard) {
|
|
212
|
-
function not(
|
|
213
|
+
function not(args, params) {
|
|
213
214
|
return false;
|
|
214
215
|
}
|
|
215
216
|
not.check = checkNot;
|
|
@@ -225,7 +226,7 @@ function checkAnd(state, {
|
|
|
225
226
|
return guards.every(guard => evaluateGuard(guard, context, event, state));
|
|
226
227
|
}
|
|
227
228
|
function and(guards) {
|
|
228
|
-
function and(
|
|
229
|
+
function and(args, params) {
|
|
229
230
|
return false;
|
|
230
231
|
}
|
|
231
232
|
and.check = checkAnd;
|
|
@@ -241,7 +242,7 @@ function checkOr(state, {
|
|
|
241
242
|
return guards.some(guard => evaluateGuard(guard, context, event, state));
|
|
242
243
|
}
|
|
243
244
|
function or(guards) {
|
|
244
|
-
function or(
|
|
245
|
+
function or(args, params) {
|
|
245
246
|
return false;
|
|
246
247
|
}
|
|
247
248
|
or.check = checkOr;
|
|
@@ -264,22 +265,17 @@ function evaluateGuard(guard, context, event, state) {
|
|
|
264
265
|
}
|
|
265
266
|
const guardArgs = {
|
|
266
267
|
context,
|
|
267
|
-
event
|
|
268
|
-
guard: isInline ? undefined : typeof guard === 'string' ? {
|
|
269
|
-
type: guard
|
|
270
|
-
} : typeof guard.params === 'function' ? {
|
|
271
|
-
type: guard.type,
|
|
272
|
-
params: guard.params({
|
|
273
|
-
context,
|
|
274
|
-
event
|
|
275
|
-
})
|
|
276
|
-
} : guard
|
|
268
|
+
event
|
|
277
269
|
};
|
|
270
|
+
const guardParams = isInline || typeof guard === 'string' ? undefined : 'params' in guard ? typeof guard.params === 'function' ? guard.params({
|
|
271
|
+
context,
|
|
272
|
+
event
|
|
273
|
+
}) : guard.params : undefined;
|
|
278
274
|
if (!('check' in resolved)) {
|
|
279
275
|
// the existing type of `.guards` assumes non-nullable `TExpressionGuard`
|
|
280
276
|
// inline guards expect `TExpressionGuard` to be set to `undefined`
|
|
281
277
|
// it's fine to cast this here, our logic makes sure that we call those 2 "variants" correctly
|
|
282
|
-
return resolved(guardArgs);
|
|
278
|
+
return resolved(guardArgs, guardParams);
|
|
283
279
|
}
|
|
284
280
|
const builtinGuard = resolved;
|
|
285
281
|
return builtinGuard.check(state, guardArgs, resolved // this holds all params
|
|
@@ -857,11 +853,6 @@ function areConfigurationsEqual(previousConfiguration, nextConfigurationSet) {
|
|
|
857
853
|
|
|
858
854
|
/**
|
|
859
855
|
* https://www.w3.org/TR/scxml/#microstepProcedure
|
|
860
|
-
*
|
|
861
|
-
* @private
|
|
862
|
-
* @param transitions
|
|
863
|
-
* @param currentState
|
|
864
|
-
* @param mutConfiguration
|
|
865
856
|
*/
|
|
866
857
|
function microstep(transitions, currentState, actorCtx, event, isInitial, internalQueue) {
|
|
867
858
|
if (!transitions.length) {
|
|
@@ -928,7 +919,10 @@ function enterStates(currentState, event, actorCtx, filteredTransitions, mutConf
|
|
|
928
919
|
// Add entry actions
|
|
929
920
|
actions.push(...stateNodeToEnter.entry);
|
|
930
921
|
for (const invokeDef of stateNodeToEnter.invoke) {
|
|
931
|
-
actions.push(
|
|
922
|
+
actions.push(spawn(invokeDef.src, {
|
|
923
|
+
...invokeDef,
|
|
924
|
+
syncSnapshot: !!invokeDef.onSnapshot
|
|
925
|
+
}));
|
|
932
926
|
}
|
|
933
927
|
if (statesForDefaultEntry.has(stateNodeToEnter)) {
|
|
934
928
|
const initialActions = stateNodeToEnter.initial.actions;
|
|
@@ -1092,31 +1086,24 @@ function resolveActionsAndContextWorker(currentState, event, actorCtx, actions,
|
|
|
1092
1086
|
context: intermediateState.context,
|
|
1093
1087
|
event,
|
|
1094
1088
|
self: actorCtx?.self,
|
|
1095
|
-
system: actorCtx?.system
|
|
1096
|
-
action: isInline ? undefined : typeof action === 'string' ? {
|
|
1097
|
-
type: action
|
|
1098
|
-
} : typeof action.params === 'function' ? {
|
|
1099
|
-
type: action.type,
|
|
1100
|
-
params: action.params({
|
|
1101
|
-
context: intermediateState.context,
|
|
1102
|
-
event
|
|
1103
|
-
})
|
|
1104
|
-
} :
|
|
1105
|
-
// TS isn't able to narrow it down here
|
|
1106
|
-
action
|
|
1089
|
+
system: actorCtx?.system
|
|
1107
1090
|
};
|
|
1091
|
+
const actionParams = isInline || typeof action === 'string' ? undefined : 'params' in action ? typeof action.params === 'function' ? action.params({
|
|
1092
|
+
context: intermediateState.context,
|
|
1093
|
+
event
|
|
1094
|
+
}) : action.params : undefined;
|
|
1108
1095
|
if (!('resolve' in resolvedAction)) {
|
|
1109
1096
|
if (actorCtx?.self.status === ActorStatus.Running) {
|
|
1110
|
-
resolvedAction(actionArgs);
|
|
1097
|
+
resolvedAction(actionArgs, actionParams);
|
|
1111
1098
|
} else {
|
|
1112
1099
|
actorCtx?.defer(() => {
|
|
1113
|
-
resolvedAction(actionArgs);
|
|
1100
|
+
resolvedAction(actionArgs, actionParams);
|
|
1114
1101
|
});
|
|
1115
1102
|
}
|
|
1116
1103
|
continue;
|
|
1117
1104
|
}
|
|
1118
1105
|
const builtinAction = resolvedAction;
|
|
1119
|
-
const [nextState, params, actions] = builtinAction.resolve(actorCtx, intermediateState, actionArgs, resolvedAction,
|
|
1106
|
+
const [nextState, params, actions] = builtinAction.resolve(actorCtx, intermediateState, actionArgs, actionParams, resolvedAction,
|
|
1120
1107
|
// this holds all params
|
|
1121
1108
|
extra);
|
|
1122
1109
|
intermediateState = nextState;
|
|
@@ -1153,7 +1140,9 @@ function macrostep(state, event, actorCtx, internalQueue = []) {
|
|
|
1153
1140
|
|
|
1154
1141
|
// Handle stop event
|
|
1155
1142
|
if (event.type === XSTATE_STOP) {
|
|
1156
|
-
nextState = stopChildren(nextState, event, actorCtx)
|
|
1143
|
+
nextState = cloneState(stopChildren(nextState, event, actorCtx), {
|
|
1144
|
+
status: 'stopped'
|
|
1145
|
+
});
|
|
1157
1146
|
states.push(nextState);
|
|
1158
1147
|
return {
|
|
1159
1148
|
state: nextState,
|
|
@@ -1410,17 +1399,17 @@ function getPersistedState(state) {
|
|
|
1410
1399
|
for (const id in children) {
|
|
1411
1400
|
const child = children[id];
|
|
1412
1401
|
childrenJson[id] = {
|
|
1413
|
-
state: child.getPersistedState
|
|
1414
|
-
src: child.src
|
|
1402
|
+
state: child.getPersistedState(),
|
|
1403
|
+
src: child.src,
|
|
1404
|
+
systemId: child._systemId
|
|
1415
1405
|
};
|
|
1416
1406
|
}
|
|
1417
|
-
|
|
1407
|
+
const persisted = {
|
|
1418
1408
|
...jsonValues,
|
|
1419
|
-
// TODO: this makes `PersistedMachineState`'s type kind of a lie
|
|
1420
|
-
// it doesn't truly use `TContext` but rather some kind of a derived form of it
|
|
1421
1409
|
context: persistContext(context),
|
|
1422
1410
|
children: childrenJson
|
|
1423
1411
|
};
|
|
1412
|
+
return persisted;
|
|
1424
1413
|
}
|
|
1425
1414
|
function persistContext(contextPart) {
|
|
1426
1415
|
let copy;
|
|
@@ -1449,7 +1438,7 @@ function persistContext(contextPart) {
|
|
|
1449
1438
|
return copy ?? contextPart;
|
|
1450
1439
|
}
|
|
1451
1440
|
|
|
1452
|
-
function resolveRaise(_, state, args, {
|
|
1441
|
+
function resolveRaise(_, state, args, actionParams, {
|
|
1453
1442
|
event: eventOrExpr,
|
|
1454
1443
|
id,
|
|
1455
1444
|
delay
|
|
@@ -1460,13 +1449,13 @@ function resolveRaise(_, state, args, {
|
|
|
1460
1449
|
if (typeof eventOrExpr === 'string') {
|
|
1461
1450
|
throw new Error(`Only event objects may be used with raise; use raise({ type: "${eventOrExpr}" }) instead`);
|
|
1462
1451
|
}
|
|
1463
|
-
const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args) : eventOrExpr;
|
|
1452
|
+
const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args, actionParams) : eventOrExpr;
|
|
1464
1453
|
let resolvedDelay;
|
|
1465
1454
|
if (typeof delay === 'string') {
|
|
1466
1455
|
const configDelay = delaysMap && delaysMap[delay];
|
|
1467
|
-
resolvedDelay = typeof configDelay === 'function' ? configDelay(args) : configDelay;
|
|
1456
|
+
resolvedDelay = typeof configDelay === 'function' ? configDelay(args, actionParams) : configDelay;
|
|
1468
1457
|
} else {
|
|
1469
|
-
resolvedDelay = typeof delay === 'function' ? delay(args) : delay;
|
|
1458
|
+
resolvedDelay = typeof delay === 'function' ? delay(args, actionParams) : delay;
|
|
1470
1459
|
}
|
|
1471
1460
|
if (typeof resolvedDelay !== 'number') {
|
|
1472
1461
|
internalQueue.push(resolvedEvent);
|
|
@@ -1490,7 +1479,7 @@ function executeRaise(actorContext, params) {
|
|
|
1490
1479
|
* @param eventType The event to raise.
|
|
1491
1480
|
*/
|
|
1492
1481
|
function raise(eventOrExpr, options) {
|
|
1493
|
-
function raise(
|
|
1482
|
+
function raise(args, params) {
|
|
1494
1483
|
}
|
|
1495
1484
|
raise.type = 'xstate.raise';
|
|
1496
1485
|
raise.event = eventOrExpr;
|
|
@@ -1501,4 +1490,4 @@ function raise(eventOrExpr, options) {
|
|
|
1501
1490
|
return raise;
|
|
1502
1491
|
}
|
|
1503
1492
|
|
|
1504
|
-
export { raise as A, stop as B, State as S, formatTransition as a, formatInitialTransition as b, getCandidates as c, getConfiguration as d, evaluateGuard as e, formatTransitions as f, getDelayedTransitions as g, getStateNodes as h, isInFinalState as i, cloneState as j, macrostep as k, getInitialConfiguration as l, memo as m, resolveActionsAndContext as n, microstep as o, getInitialStateNodes as p, isStateId as q, resolveStateValue as r, getStateNodeByPath as s, transitionNode as t, getPersistedState as u, and as v, not as w, or as x, stateIn as y, cancel as z };
|
|
1493
|
+
export { raise as A, stop as B, spawn as C, State as S, formatTransition as a, formatInitialTransition as b, getCandidates as c, getConfiguration as d, evaluateGuard as e, formatTransitions as f, getDelayedTransitions as g, getStateNodes as h, isInFinalState as i, cloneState as j, macrostep as k, getInitialConfiguration as l, memo as m, resolveActionsAndContext as n, microstep as o, getInitialStateNodes as p, isStateId as q, resolveStateValue as r, getStateNodeByPath as s, transitionNode as t, getPersistedState as u, and as v, not as w, or as x, stateIn as y, cancel as z };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
4
|
-
var interpreter = require('./interpreter-
|
|
3
|
+
var guards_dist_xstateGuards = require('./raise-7faa9b3b.cjs.js');
|
|
4
|
+
var interpreter = require('./interpreter-b6f22ee2.cjs.js');
|
|
5
5
|
|
|
6
6
|
function createSpawner(actorContext, {
|
|
7
7
|
machine,
|
|
@@ -41,9 +41,7 @@ function createSpawner(actorContext, {
|
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
|
-
error: () => {
|
|
45
|
-
/* TODO */
|
|
46
|
-
}
|
|
44
|
+
error: () => {}
|
|
47
45
|
});
|
|
48
46
|
}
|
|
49
47
|
return actorRef;
|
|
@@ -67,9 +65,7 @@ function createSpawner(actorContext, {
|
|
|
67
65
|
});
|
|
68
66
|
}
|
|
69
67
|
},
|
|
70
|
-
error: () => {
|
|
71
|
-
/* TODO */
|
|
72
|
-
}
|
|
68
|
+
error: () => {}
|
|
73
69
|
});
|
|
74
70
|
}
|
|
75
71
|
return actorRef;
|
|
@@ -93,7 +89,7 @@ function createSpawner(actorContext, {
|
|
|
93
89
|
};
|
|
94
90
|
}
|
|
95
91
|
|
|
96
|
-
function resolveAssign(actorContext, state, actionArgs, {
|
|
92
|
+
function resolveAssign(actorContext, state, actionArgs, actionParams, {
|
|
97
93
|
assignment
|
|
98
94
|
}) {
|
|
99
95
|
if (!state.context) {
|
|
@@ -103,18 +99,17 @@ function resolveAssign(actorContext, state, actionArgs, {
|
|
|
103
99
|
const assignArgs = {
|
|
104
100
|
context: state.context,
|
|
105
101
|
event: actionArgs.event,
|
|
106
|
-
action: actionArgs.action,
|
|
107
102
|
spawn: createSpawner(actorContext, state, actionArgs.event, spawnedChildren),
|
|
108
103
|
self: actorContext?.self,
|
|
109
104
|
system: actorContext?.system
|
|
110
105
|
};
|
|
111
106
|
let partialUpdate = {};
|
|
112
107
|
if (typeof assignment === 'function') {
|
|
113
|
-
partialUpdate = assignment(assignArgs);
|
|
108
|
+
partialUpdate = assignment(assignArgs, actionParams);
|
|
114
109
|
} else {
|
|
115
110
|
for (const key of Object.keys(assignment)) {
|
|
116
111
|
const propAssignment = assignment[key];
|
|
117
|
-
partialUpdate[key] = typeof propAssignment === 'function' ? propAssignment(assignArgs) : propAssignment;
|
|
112
|
+
partialUpdate[key] = typeof propAssignment === 'function' ? propAssignment(assignArgs, actionParams) : propAssignment;
|
|
118
113
|
}
|
|
119
114
|
}
|
|
120
115
|
const updatedContext = Object.assign({}, state.context, partialUpdate);
|
|
@@ -132,7 +127,7 @@ function resolveAssign(actorContext, state, actionArgs, {
|
|
|
132
127
|
* @param assignment An object that represents the partial context to update.
|
|
133
128
|
*/
|
|
134
129
|
function assign(assignment) {
|
|
135
|
-
function assign(
|
|
130
|
+
function assign(args, params) {
|
|
136
131
|
}
|
|
137
132
|
assign.type = 'xstate.assign';
|
|
138
133
|
assign.assignment = assignment;
|
|
@@ -140,7 +135,7 @@ function assign(assignment) {
|
|
|
140
135
|
return assign;
|
|
141
136
|
}
|
|
142
137
|
|
|
143
|
-
function resolveChoose(_, state, actionArgs, {
|
|
138
|
+
function resolveChoose(_, state, actionArgs, _actionParams, {
|
|
144
139
|
branches
|
|
145
140
|
}) {
|
|
146
141
|
const matchedActions = branches.find(condition => {
|
|
@@ -149,7 +144,7 @@ function resolveChoose(_, state, actionArgs, {
|
|
|
149
144
|
return [state, undefined, interpreter.toArray(matchedActions)];
|
|
150
145
|
}
|
|
151
146
|
function choose(branches) {
|
|
152
|
-
function choose(
|
|
147
|
+
function choose(args, params) {
|
|
153
148
|
}
|
|
154
149
|
choose.type = 'xstate.choose';
|
|
155
150
|
choose.branches = branches;
|
|
@@ -157,12 +152,12 @@ function choose(branches) {
|
|
|
157
152
|
return choose;
|
|
158
153
|
}
|
|
159
154
|
|
|
160
|
-
function resolveLog(_, state, actionArgs, {
|
|
155
|
+
function resolveLog(_, state, actionArgs, actionParams, {
|
|
161
156
|
value,
|
|
162
157
|
label
|
|
163
158
|
}) {
|
|
164
159
|
return [state, {
|
|
165
|
-
value: typeof value === 'function' ? value(actionArgs) : value,
|
|
160
|
+
value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
|
|
166
161
|
label
|
|
167
162
|
}];
|
|
168
163
|
}
|
|
@@ -193,7 +188,7 @@ function log(value = ({
|
|
|
193
188
|
context,
|
|
194
189
|
event
|
|
195
190
|
}), label) {
|
|
196
|
-
function log(
|
|
191
|
+
function log(args, params) {
|
|
197
192
|
}
|
|
198
193
|
log.type = 'xstate.log';
|
|
199
194
|
log.value = value;
|
|
@@ -203,7 +198,7 @@ function log(value = ({
|
|
|
203
198
|
return log;
|
|
204
199
|
}
|
|
205
200
|
|
|
206
|
-
function resolvePure(_, state, args, {
|
|
201
|
+
function resolvePure(_, state, args, _actionParams, {
|
|
207
202
|
get
|
|
208
203
|
}) {
|
|
209
204
|
return [state, undefined, interpreter.toArray(get({
|
|
@@ -212,7 +207,7 @@ function resolvePure(_, state, args, {
|
|
|
212
207
|
}))];
|
|
213
208
|
}
|
|
214
209
|
function pure(getActions) {
|
|
215
|
-
function pure(
|
|
210
|
+
function pure(args, params) {
|
|
216
211
|
}
|
|
217
212
|
pure.type = 'xstate.pure';
|
|
218
213
|
pure.get = getActions;
|
|
@@ -221,6 +216,9 @@ function pure(getActions) {
|
|
|
221
216
|
}
|
|
222
217
|
|
|
223
218
|
/**
|
|
219
|
+
*
|
|
220
|
+
* @remarks
|
|
221
|
+
*
|
|
224
222
|
* `T | unknown` reduces to `unknown` and that can be problematic when it comes to contextual typing.
|
|
225
223
|
* It especially is a problem when the union has a function member, like here:
|
|
226
224
|
*
|
|
@@ -241,7 +239,10 @@ function pure(getActions) {
|
|
|
241
239
|
/**
|
|
242
240
|
* The string or object representing the state value relative to the parent state node.
|
|
243
241
|
*
|
|
242
|
+
* @remarks
|
|
243
|
+
*
|
|
244
244
|
* - For a child atomic state node, this is a string, e.g., `"pending"`.
|
|
245
|
+
*
|
|
245
246
|
* - For complex state nodes, this is an object, e.g., `{ success: "someChildState" }`.
|
|
246
247
|
*/
|
|
247
248
|
|
|
@@ -255,7 +256,7 @@ let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
|
|
|
255
256
|
return SpecialTargets;
|
|
256
257
|
}({});
|
|
257
258
|
|
|
258
|
-
function resolveSendTo(actorContext, state, args, {
|
|
259
|
+
function resolveSendTo(actorContext, state, args, actionParams, {
|
|
259
260
|
to,
|
|
260
261
|
event: eventOrExpr,
|
|
261
262
|
id,
|
|
@@ -265,15 +266,15 @@ function resolveSendTo(actorContext, state, args, {
|
|
|
265
266
|
if (typeof eventOrExpr === 'string') {
|
|
266
267
|
throw new Error(`Only event objects may be used with sendTo; use sendTo({ type: "${eventOrExpr}" }) instead`);
|
|
267
268
|
}
|
|
268
|
-
const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args) : eventOrExpr;
|
|
269
|
+
const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args, actionParams) : eventOrExpr;
|
|
269
270
|
let resolvedDelay;
|
|
270
271
|
if (typeof delay === 'string') {
|
|
271
272
|
const configDelay = delaysMap && delaysMap[delay];
|
|
272
|
-
resolvedDelay = typeof configDelay === 'function' ? configDelay(args) : configDelay;
|
|
273
|
+
resolvedDelay = typeof configDelay === 'function' ? configDelay(args, actionParams) : configDelay;
|
|
273
274
|
} else {
|
|
274
|
-
resolvedDelay = typeof delay === 'function' ? delay(args) : delay;
|
|
275
|
+
resolvedDelay = typeof delay === 'function' ? delay(args, actionParams) : delay;
|
|
275
276
|
}
|
|
276
|
-
const resolvedTarget = typeof to === 'function' ? to(args) : to;
|
|
277
|
+
const resolvedTarget = typeof to === 'function' ? to(args, actionParams) : to;
|
|
277
278
|
let targetActorRef;
|
|
278
279
|
if (typeof resolvedTarget === 'string') {
|
|
279
280
|
if (resolvedTarget === SpecialTargets.Parent) {
|
|
@@ -331,7 +332,7 @@ function executeSendTo(actorContext, params) {
|
|
|
331
332
|
* - `delay` - The number of milliseconds to delay the sending of the event.
|
|
332
333
|
*/
|
|
333
334
|
function sendTo(to, eventOrExpr, options) {
|
|
334
|
-
function sendTo(
|
|
335
|
+
function sendTo(args, params) {
|
|
335
336
|
}
|
|
336
337
|
sendTo.type = 'xstate.sendTo';
|
|
337
338
|
sendTo.to = to;
|