xstate 5.0.0-beta.52 → 5.0.0-beta.53
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 +2 -2
- package/actions/dist/xstate-actions.development.cjs.js +2 -2
- package/actions/dist/xstate-actions.development.esm.js +2 -2
- package/actions/dist/xstate-actions.esm.js +2 -2
- 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 +17 -17
- package/actors/dist/xstate-actors.development.cjs.js +17 -17
- package/actors/dist/xstate-actors.development.esm.js +17 -17
- package/actors/dist/xstate-actors.esm.js +17 -17
- 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/StateNode.d.ts +1 -1
- package/dist/declarations/src/actors/transition.d.ts +1 -1
- package/dist/declarations/src/guards.d.ts +1 -1
- package/dist/declarations/src/interpreter.d.ts +5 -5
- package/dist/declarations/src/stateUtils.d.ts +9 -9
- package/dist/declarations/src/types.d.ts +14 -10
- package/dist/{log-826c9895.development.esm.js → log-1fd7d00a.development.esm.js} +23 -23
- package/dist/{log-6bc0e1e7.esm.js → log-60ab9eaf.esm.js} +23 -23
- package/dist/{log-3d815f5e.cjs.js → log-717bb5a1.cjs.js} +23 -23
- package/dist/{log-d160285c.development.cjs.js → log-c8797128.development.cjs.js} +23 -23
- package/dist/{raise-1caefe80.development.esm.js → raise-953b1eb5.development.esm.js} +127 -127
- package/dist/{raise-367eeb6f.cjs.js → raise-a8367773.cjs.js} +127 -127
- package/dist/{raise-f71460d6.esm.js → raise-be2f20bc.esm.js} +127 -127
- package/dist/{raise-9dd3e757.development.cjs.js → raise-d9fd8932.development.cjs.js} +127 -127
- package/dist/xstate.cjs.js +17 -17
- package/dist/xstate.development.cjs.js +17 -17
- package/dist/xstate.development.esm.js +19 -19
- package/dist/xstate.esm.js +19 -19
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +1 -1
- package/guards/dist/xstate-guards.cjs.js +1 -1
- package/guards/dist/xstate-guards.development.cjs.js +1 -1
- package/guards/dist/xstate-guards.development.esm.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
|
@@ -614,10 +614,14 @@ export interface ActorOptions<TLogic extends AnyActorLogic> {
|
|
|
614
614
|
* Actions from machine actors will not be re-executed, because they are assumed to have been already executed.
|
|
615
615
|
* However, invocations will be restarted, and spawned actors will be restored recursively.
|
|
616
616
|
*
|
|
617
|
-
* Can be generated with {@link Actor.
|
|
617
|
+
* Can be generated with {@link Actor.getPersistedSnapshot}.
|
|
618
618
|
*
|
|
619
619
|
* @see https://stately.ai/docs/persistence
|
|
620
620
|
*/
|
|
621
|
+
snapshot?: Snapshot<unknown>;
|
|
622
|
+
/**
|
|
623
|
+
* @deprecated Use `snapshot` instead.
|
|
624
|
+
*/
|
|
621
625
|
state?: Snapshot<unknown>;
|
|
622
626
|
/**
|
|
623
627
|
* The source definition.
|
|
@@ -738,7 +742,7 @@ export interface ActorRef<TSnapshot extends Snapshot<unknown>, TEvent extends Ev
|
|
|
738
742
|
send: (event: TEvent) => void;
|
|
739
743
|
start: () => void;
|
|
740
744
|
getSnapshot: () => TSnapshot;
|
|
741
|
-
|
|
745
|
+
getPersistedSnapshot: () => Snapshot<unknown>;
|
|
742
746
|
stop: () => void;
|
|
743
747
|
toJSON?: () => any;
|
|
744
748
|
_parent?: ActorRef<any, any>;
|
|
@@ -806,7 +810,7 @@ export interface ActorLogic<TSnapshot extends Snapshot<unknown>, TEvent extends
|
|
|
806
810
|
/**
|
|
807
811
|
* Transition function that processes the current state and an incoming message
|
|
808
812
|
* to produce a new state.
|
|
809
|
-
* @param
|
|
813
|
+
* @param snapshot - The current state.
|
|
810
814
|
* @param message - The incoming message.
|
|
811
815
|
* @param ctx - The actor scope.
|
|
812
816
|
* @returns The new state.
|
|
@@ -821,25 +825,25 @@ export interface ActorLogic<TSnapshot extends Snapshot<unknown>, TEvent extends
|
|
|
821
825
|
getInitialState: (actorScope: ActorScope<TSnapshot, TEvent, TSystem>, input: TInput) => TSnapshot;
|
|
822
826
|
/**
|
|
823
827
|
* Called when Actor is created to restore the internal state of the actor given a persisted state.
|
|
824
|
-
* The persisted state can be created by `
|
|
828
|
+
* The persisted state can be created by `getPersistedSnapshot`.
|
|
825
829
|
* @param persistedState - The persisted state to restore from.
|
|
826
830
|
* @param actorScope - The actor scope.
|
|
827
831
|
* @returns The restored state.
|
|
828
832
|
*/
|
|
829
|
-
|
|
833
|
+
restoreSnapshot?: (persistedState: Snapshot<unknown>, actorScope: ActorScope<TSnapshot, TEvent>) => TSnapshot;
|
|
830
834
|
/**
|
|
831
835
|
* Called when the actor is started.
|
|
832
|
-
* @param
|
|
836
|
+
* @param snapshot - The starting state.
|
|
833
837
|
* @param actorScope - The actor scope.
|
|
834
838
|
*/
|
|
835
|
-
start?: (
|
|
839
|
+
start?: (snapshot: TSnapshot, actorScope: ActorScope<TSnapshot, TEvent>) => void;
|
|
836
840
|
/**
|
|
837
841
|
* Obtains the internal state of the actor in a representation which can be be persisted.
|
|
838
|
-
* The persisted state can be restored by `
|
|
839
|
-
* @param
|
|
842
|
+
* The persisted state can be restored by `restoreSnapshot`.
|
|
843
|
+
* @param snapshot - The current state.
|
|
840
844
|
* @returns The a representation of the internal state to be persisted.
|
|
841
845
|
*/
|
|
842
|
-
|
|
846
|
+
getPersistedSnapshot: (snapshot: TSnapshot, options?: unknown) => Snapshot<unknown>;
|
|
843
847
|
}
|
|
844
848
|
export type AnyActorLogic = ActorLogic<any, // snapshot
|
|
845
849
|
any, // event
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as ProcessingStatus, y as resolveReferencedActor, z as createActor, T as cloneMachineSnapshot, U as XSTATE_ERROR, V as createErrorActorEvent, e as evaluateGuard, L as cancel, M as raise, O as spawnChild, Q as stopChild } from './raise-
|
|
1
|
+
import { R as ProcessingStatus, y as resolveReferencedActor, z as createActor, T as cloneMachineSnapshot, U as XSTATE_ERROR, V as createErrorActorEvent, e as evaluateGuard, L as cancel, M as raise, O as spawnChild, Q as stopChild } from './raise-953b1eb5.development.esm.js';
|
|
2
2
|
|
|
3
3
|
function createSpawner(actorScope, {
|
|
4
4
|
machine,
|
|
@@ -53,17 +53,17 @@ function createSpawner(actorScope, {
|
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
function resolveAssign(actorScope,
|
|
56
|
+
function resolveAssign(actorScope, snapshot, actionArgs, actionParams, {
|
|
57
57
|
assignment
|
|
58
58
|
}) {
|
|
59
|
-
if (!
|
|
59
|
+
if (!snapshot.context) {
|
|
60
60
|
throw new Error('Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.');
|
|
61
61
|
}
|
|
62
62
|
const spawnedChildren = {};
|
|
63
63
|
const assignArgs = {
|
|
64
|
-
context:
|
|
64
|
+
context: snapshot.context,
|
|
65
65
|
event: actionArgs.event,
|
|
66
|
-
spawn: createSpawner(actorScope,
|
|
66
|
+
spawn: createSpawner(actorScope, snapshot, actionArgs.event, spawnedChildren),
|
|
67
67
|
self: actorScope?.self,
|
|
68
68
|
system: actorScope?.system
|
|
69
69
|
};
|
|
@@ -76,13 +76,13 @@ function resolveAssign(actorScope, state, actionArgs, actionParams, {
|
|
|
76
76
|
partialUpdate[key] = typeof propAssignment === 'function' ? propAssignment(assignArgs, actionParams) : propAssignment;
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
const updatedContext = Object.assign({},
|
|
80
|
-
return [cloneMachineSnapshot(
|
|
79
|
+
const updatedContext = Object.assign({}, snapshot.context, partialUpdate);
|
|
80
|
+
return [cloneMachineSnapshot(snapshot, {
|
|
81
81
|
context: updatedContext,
|
|
82
82
|
children: Object.keys(spawnedChildren).length ? {
|
|
83
|
-
...
|
|
83
|
+
...snapshot.children,
|
|
84
84
|
...spawnedChildren
|
|
85
|
-
} :
|
|
85
|
+
} : snapshot.children
|
|
86
86
|
})];
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
@@ -166,13 +166,13 @@ let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
|
|
|
166
166
|
* @template TSystem - The type of the actor system.
|
|
167
167
|
*/
|
|
168
168
|
|
|
169
|
-
function resolveSendTo(actorScope,
|
|
169
|
+
function resolveSendTo(actorScope, snapshot, args, actionParams, {
|
|
170
170
|
to,
|
|
171
171
|
event: eventOrExpr,
|
|
172
172
|
id,
|
|
173
173
|
delay
|
|
174
174
|
}, extra) {
|
|
175
|
-
const delaysMap =
|
|
175
|
+
const delaysMap = snapshot.machine.implementations.delays;
|
|
176
176
|
if (typeof eventOrExpr === 'string') {
|
|
177
177
|
throw new Error(`Only event objects may be used with sendTo; use sendTo({ type: "${eventOrExpr}" }) instead`);
|
|
178
178
|
}
|
|
@@ -194,26 +194,26 @@ function resolveSendTo(actorScope, state, args, actionParams, {
|
|
|
194
194
|
} else if (resolvedTarget.startsWith('#_')) {
|
|
195
195
|
// SCXML compatibility: https://www.w3.org/TR/scxml/#SCXMLEventProcessor
|
|
196
196
|
// #_invokeid. If the target is the special term '#_invokeid', where invokeid is the invokeid of an SCXML session that the sending session has created by <invoke>, the Processor must add the event to the external queue of that session.
|
|
197
|
-
targetActorRef =
|
|
197
|
+
targetActorRef = snapshot.children[resolvedTarget.slice(2)];
|
|
198
198
|
} else {
|
|
199
|
-
targetActorRef = extra.deferredActorIds?.includes(resolvedTarget) ? resolvedTarget :
|
|
199
|
+
targetActorRef = extra.deferredActorIds?.includes(resolvedTarget) ? resolvedTarget : snapshot.children[resolvedTarget];
|
|
200
200
|
}
|
|
201
201
|
if (!targetActorRef) {
|
|
202
|
-
throw new Error(`Unable to send event to actor '${resolvedTarget}' from machine '${
|
|
202
|
+
throw new Error(`Unable to send event to actor '${resolvedTarget}' from machine '${snapshot.machine.id}'.`);
|
|
203
203
|
}
|
|
204
204
|
} else {
|
|
205
205
|
targetActorRef = resolvedTarget || actorScope?.self;
|
|
206
206
|
}
|
|
207
|
-
return [
|
|
207
|
+
return [snapshot, {
|
|
208
208
|
to: targetActorRef,
|
|
209
209
|
event: resolvedEvent,
|
|
210
210
|
id,
|
|
211
211
|
delay: resolvedDelay
|
|
212
212
|
}];
|
|
213
213
|
}
|
|
214
|
-
function retryResolveSendTo(_,
|
|
214
|
+
function retryResolveSendTo(_, snapshot, params) {
|
|
215
215
|
if (typeof params.to === 'string') {
|
|
216
|
-
params.to =
|
|
216
|
+
params.to = snapshot.children[params.to];
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
function executeSendTo(actorScope, params) {
|
|
@@ -247,7 +247,7 @@ function sendTo(to, eventOrExpr, options) {
|
|
|
247
247
|
throw new Error(`This isn't supposed to be called`);
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
|
-
sendTo.type = '
|
|
250
|
+
sendTo.type = 'xsnapshot.sendTo';
|
|
251
251
|
sendTo.to = to;
|
|
252
252
|
sendTo.event = eventOrExpr;
|
|
253
253
|
sendTo.id = options?.id;
|
|
@@ -305,7 +305,7 @@ function escalate(errorData, options) {
|
|
|
305
305
|
}, options);
|
|
306
306
|
}
|
|
307
307
|
|
|
308
|
-
function resolveEnqueueActions(_,
|
|
308
|
+
function resolveEnqueueActions(_, snapshot, args, _actionParams, {
|
|
309
309
|
collect
|
|
310
310
|
}) {
|
|
311
311
|
const actions = [];
|
|
@@ -334,9 +334,9 @@ function resolveEnqueueActions(_, state, args, _actionParams, {
|
|
|
334
334
|
context: args.context,
|
|
335
335
|
event: args.event,
|
|
336
336
|
enqueue,
|
|
337
|
-
check: guard => evaluateGuard(guard,
|
|
337
|
+
check: guard => evaluateGuard(guard, snapshot.context, args.event, snapshot)
|
|
338
338
|
});
|
|
339
|
-
return [
|
|
339
|
+
return [snapshot, undefined, actions];
|
|
340
340
|
}
|
|
341
341
|
function enqueueActions(collect) {
|
|
342
342
|
function enqueueActions(args, params) {
|
|
@@ -350,11 +350,11 @@ function enqueueActions(collect) {
|
|
|
350
350
|
return enqueueActions;
|
|
351
351
|
}
|
|
352
352
|
|
|
353
|
-
function resolveLog(_,
|
|
353
|
+
function resolveLog(_, snapshot, actionArgs, actionParams, {
|
|
354
354
|
value,
|
|
355
355
|
label
|
|
356
356
|
}) {
|
|
357
|
-
return [
|
|
357
|
+
return [snapshot, {
|
|
358
358
|
value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
|
|
359
359
|
label
|
|
360
360
|
}];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as ProcessingStatus, y as resolveReferencedActor, z as createActor, T as cloneMachineSnapshot, U as XSTATE_ERROR, V as createErrorActorEvent, e as evaluateGuard, L as cancel, M as raise, O as spawnChild, Q as stopChild } from './raise-
|
|
1
|
+
import { R as ProcessingStatus, y as resolveReferencedActor, z as createActor, T as cloneMachineSnapshot, U as XSTATE_ERROR, V as createErrorActorEvent, e as evaluateGuard, L as cancel, M as raise, O as spawnChild, Q as stopChild } from './raise-be2f20bc.esm.js';
|
|
2
2
|
|
|
3
3
|
function createSpawner(actorScope, {
|
|
4
4
|
machine,
|
|
@@ -53,17 +53,17 @@ function createSpawner(actorScope, {
|
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
function resolveAssign(actorScope,
|
|
56
|
+
function resolveAssign(actorScope, snapshot, actionArgs, actionParams, {
|
|
57
57
|
assignment
|
|
58
58
|
}) {
|
|
59
|
-
if (!
|
|
59
|
+
if (!snapshot.context) {
|
|
60
60
|
throw new Error('Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.');
|
|
61
61
|
}
|
|
62
62
|
const spawnedChildren = {};
|
|
63
63
|
const assignArgs = {
|
|
64
|
-
context:
|
|
64
|
+
context: snapshot.context,
|
|
65
65
|
event: actionArgs.event,
|
|
66
|
-
spawn: createSpawner(actorScope,
|
|
66
|
+
spawn: createSpawner(actorScope, snapshot, actionArgs.event, spawnedChildren),
|
|
67
67
|
self: actorScope?.self,
|
|
68
68
|
system: actorScope?.system
|
|
69
69
|
};
|
|
@@ -76,13 +76,13 @@ function resolveAssign(actorScope, state, actionArgs, actionParams, {
|
|
|
76
76
|
partialUpdate[key] = typeof propAssignment === 'function' ? propAssignment(assignArgs, actionParams) : propAssignment;
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
const updatedContext = Object.assign({},
|
|
80
|
-
return [cloneMachineSnapshot(
|
|
79
|
+
const updatedContext = Object.assign({}, snapshot.context, partialUpdate);
|
|
80
|
+
return [cloneMachineSnapshot(snapshot, {
|
|
81
81
|
context: updatedContext,
|
|
82
82
|
children: Object.keys(spawnedChildren).length ? {
|
|
83
|
-
...
|
|
83
|
+
...snapshot.children,
|
|
84
84
|
...spawnedChildren
|
|
85
|
-
} :
|
|
85
|
+
} : snapshot.children
|
|
86
86
|
})];
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
@@ -163,13 +163,13 @@ let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
|
|
|
163
163
|
* @template TSystem - The type of the actor system.
|
|
164
164
|
*/
|
|
165
165
|
|
|
166
|
-
function resolveSendTo(actorScope,
|
|
166
|
+
function resolveSendTo(actorScope, snapshot, args, actionParams, {
|
|
167
167
|
to,
|
|
168
168
|
event: eventOrExpr,
|
|
169
169
|
id,
|
|
170
170
|
delay
|
|
171
171
|
}, extra) {
|
|
172
|
-
const delaysMap =
|
|
172
|
+
const delaysMap = snapshot.machine.implementations.delays;
|
|
173
173
|
if (typeof eventOrExpr === 'string') {
|
|
174
174
|
throw new Error(`Only event objects may be used with sendTo; use sendTo({ type: "${eventOrExpr}" }) instead`);
|
|
175
175
|
}
|
|
@@ -191,26 +191,26 @@ function resolveSendTo(actorScope, state, args, actionParams, {
|
|
|
191
191
|
} else if (resolvedTarget.startsWith('#_')) {
|
|
192
192
|
// SCXML compatibility: https://www.w3.org/TR/scxml/#SCXMLEventProcessor
|
|
193
193
|
// #_invokeid. If the target is the special term '#_invokeid', where invokeid is the invokeid of an SCXML session that the sending session has created by <invoke>, the Processor must add the event to the external queue of that session.
|
|
194
|
-
targetActorRef =
|
|
194
|
+
targetActorRef = snapshot.children[resolvedTarget.slice(2)];
|
|
195
195
|
} else {
|
|
196
|
-
targetActorRef = extra.deferredActorIds?.includes(resolvedTarget) ? resolvedTarget :
|
|
196
|
+
targetActorRef = extra.deferredActorIds?.includes(resolvedTarget) ? resolvedTarget : snapshot.children[resolvedTarget];
|
|
197
197
|
}
|
|
198
198
|
if (!targetActorRef) {
|
|
199
|
-
throw new Error(`Unable to send event to actor '${resolvedTarget}' from machine '${
|
|
199
|
+
throw new Error(`Unable to send event to actor '${resolvedTarget}' from machine '${snapshot.machine.id}'.`);
|
|
200
200
|
}
|
|
201
201
|
} else {
|
|
202
202
|
targetActorRef = resolvedTarget || actorScope?.self;
|
|
203
203
|
}
|
|
204
|
-
return [
|
|
204
|
+
return [snapshot, {
|
|
205
205
|
to: targetActorRef,
|
|
206
206
|
event: resolvedEvent,
|
|
207
207
|
id,
|
|
208
208
|
delay: resolvedDelay
|
|
209
209
|
}];
|
|
210
210
|
}
|
|
211
|
-
function retryResolveSendTo(_,
|
|
211
|
+
function retryResolveSendTo(_, snapshot, params) {
|
|
212
212
|
if (typeof params.to === 'string') {
|
|
213
|
-
params.to =
|
|
213
|
+
params.to = snapshot.children[params.to];
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
function executeSendTo(actorScope, params) {
|
|
@@ -241,7 +241,7 @@ function executeSendTo(actorScope, params) {
|
|
|
241
241
|
function sendTo(to, eventOrExpr, options) {
|
|
242
242
|
function sendTo(args, params) {
|
|
243
243
|
}
|
|
244
|
-
sendTo.type = '
|
|
244
|
+
sendTo.type = 'xsnapshot.sendTo';
|
|
245
245
|
sendTo.to = to;
|
|
246
246
|
sendTo.event = eventOrExpr;
|
|
247
247
|
sendTo.id = options?.id;
|
|
@@ -289,7 +289,7 @@ function escalate(errorData, options) {
|
|
|
289
289
|
}, options);
|
|
290
290
|
}
|
|
291
291
|
|
|
292
|
-
function resolveEnqueueActions(_,
|
|
292
|
+
function resolveEnqueueActions(_, snapshot, args, _actionParams, {
|
|
293
293
|
collect
|
|
294
294
|
}) {
|
|
295
295
|
const actions = [];
|
|
@@ -318,9 +318,9 @@ function resolveEnqueueActions(_, state, args, _actionParams, {
|
|
|
318
318
|
context: args.context,
|
|
319
319
|
event: args.event,
|
|
320
320
|
enqueue,
|
|
321
|
-
check: guard => evaluateGuard(guard,
|
|
321
|
+
check: guard => evaluateGuard(guard, snapshot.context, args.event, snapshot)
|
|
322
322
|
});
|
|
323
|
-
return [
|
|
323
|
+
return [snapshot, undefined, actions];
|
|
324
324
|
}
|
|
325
325
|
function enqueueActions(collect) {
|
|
326
326
|
function enqueueActions(args, params) {
|
|
@@ -331,11 +331,11 @@ function enqueueActions(collect) {
|
|
|
331
331
|
return enqueueActions;
|
|
332
332
|
}
|
|
333
333
|
|
|
334
|
-
function resolveLog(_,
|
|
334
|
+
function resolveLog(_, snapshot, actionArgs, actionParams, {
|
|
335
335
|
value,
|
|
336
336
|
label
|
|
337
337
|
}) {
|
|
338
|
-
return [
|
|
338
|
+
return [snapshot, {
|
|
339
339
|
value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
|
|
340
340
|
label
|
|
341
341
|
}];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
3
|
+
var guards_dist_xstateGuards = require('./raise-a8367773.cjs.js');
|
|
4
4
|
|
|
5
5
|
function createSpawner(actorScope, {
|
|
6
6
|
machine,
|
|
@@ -55,17 +55,17 @@ function createSpawner(actorScope, {
|
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
function resolveAssign(actorScope,
|
|
58
|
+
function resolveAssign(actorScope, snapshot, actionArgs, actionParams, {
|
|
59
59
|
assignment
|
|
60
60
|
}) {
|
|
61
|
-
if (!
|
|
61
|
+
if (!snapshot.context) {
|
|
62
62
|
throw new Error('Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.');
|
|
63
63
|
}
|
|
64
64
|
const spawnedChildren = {};
|
|
65
65
|
const assignArgs = {
|
|
66
|
-
context:
|
|
66
|
+
context: snapshot.context,
|
|
67
67
|
event: actionArgs.event,
|
|
68
|
-
spawn: createSpawner(actorScope,
|
|
68
|
+
spawn: createSpawner(actorScope, snapshot, actionArgs.event, spawnedChildren),
|
|
69
69
|
self: actorScope?.self,
|
|
70
70
|
system: actorScope?.system
|
|
71
71
|
};
|
|
@@ -78,13 +78,13 @@ function resolveAssign(actorScope, state, actionArgs, actionParams, {
|
|
|
78
78
|
partialUpdate[key] = typeof propAssignment === 'function' ? propAssignment(assignArgs, actionParams) : propAssignment;
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
-
const updatedContext = Object.assign({},
|
|
82
|
-
return [guards_dist_xstateGuards.cloneMachineSnapshot(
|
|
81
|
+
const updatedContext = Object.assign({}, snapshot.context, partialUpdate);
|
|
82
|
+
return [guards_dist_xstateGuards.cloneMachineSnapshot(snapshot, {
|
|
83
83
|
context: updatedContext,
|
|
84
84
|
children: Object.keys(spawnedChildren).length ? {
|
|
85
|
-
...
|
|
85
|
+
...snapshot.children,
|
|
86
86
|
...spawnedChildren
|
|
87
|
-
} :
|
|
87
|
+
} : snapshot.children
|
|
88
88
|
})];
|
|
89
89
|
}
|
|
90
90
|
/**
|
|
@@ -165,13 +165,13 @@ let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
|
|
|
165
165
|
* @template TSystem - The type of the actor system.
|
|
166
166
|
*/
|
|
167
167
|
|
|
168
|
-
function resolveSendTo(actorScope,
|
|
168
|
+
function resolveSendTo(actorScope, snapshot, args, actionParams, {
|
|
169
169
|
to,
|
|
170
170
|
event: eventOrExpr,
|
|
171
171
|
id,
|
|
172
172
|
delay
|
|
173
173
|
}, extra) {
|
|
174
|
-
const delaysMap =
|
|
174
|
+
const delaysMap = snapshot.machine.implementations.delays;
|
|
175
175
|
if (typeof eventOrExpr === 'string') {
|
|
176
176
|
throw new Error(`Only event objects may be used with sendTo; use sendTo({ type: "${eventOrExpr}" }) instead`);
|
|
177
177
|
}
|
|
@@ -193,26 +193,26 @@ function resolveSendTo(actorScope, state, args, actionParams, {
|
|
|
193
193
|
} else if (resolvedTarget.startsWith('#_')) {
|
|
194
194
|
// SCXML compatibility: https://www.w3.org/TR/scxml/#SCXMLEventProcessor
|
|
195
195
|
// #_invokeid. If the target is the special term '#_invokeid', where invokeid is the invokeid of an SCXML session that the sending session has created by <invoke>, the Processor must add the event to the external queue of that session.
|
|
196
|
-
targetActorRef =
|
|
196
|
+
targetActorRef = snapshot.children[resolvedTarget.slice(2)];
|
|
197
197
|
} else {
|
|
198
|
-
targetActorRef = extra.deferredActorIds?.includes(resolvedTarget) ? resolvedTarget :
|
|
198
|
+
targetActorRef = extra.deferredActorIds?.includes(resolvedTarget) ? resolvedTarget : snapshot.children[resolvedTarget];
|
|
199
199
|
}
|
|
200
200
|
if (!targetActorRef) {
|
|
201
|
-
throw new Error(`Unable to send event to actor '${resolvedTarget}' from machine '${
|
|
201
|
+
throw new Error(`Unable to send event to actor '${resolvedTarget}' from machine '${snapshot.machine.id}'.`);
|
|
202
202
|
}
|
|
203
203
|
} else {
|
|
204
204
|
targetActorRef = resolvedTarget || actorScope?.self;
|
|
205
205
|
}
|
|
206
|
-
return [
|
|
206
|
+
return [snapshot, {
|
|
207
207
|
to: targetActorRef,
|
|
208
208
|
event: resolvedEvent,
|
|
209
209
|
id,
|
|
210
210
|
delay: resolvedDelay
|
|
211
211
|
}];
|
|
212
212
|
}
|
|
213
|
-
function retryResolveSendTo(_,
|
|
213
|
+
function retryResolveSendTo(_, snapshot, params) {
|
|
214
214
|
if (typeof params.to === 'string') {
|
|
215
|
-
params.to =
|
|
215
|
+
params.to = snapshot.children[params.to];
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
function executeSendTo(actorScope, params) {
|
|
@@ -243,7 +243,7 @@ function executeSendTo(actorScope, params) {
|
|
|
243
243
|
function sendTo(to, eventOrExpr, options) {
|
|
244
244
|
function sendTo(args, params) {
|
|
245
245
|
}
|
|
246
|
-
sendTo.type = '
|
|
246
|
+
sendTo.type = 'xsnapshot.sendTo';
|
|
247
247
|
sendTo.to = to;
|
|
248
248
|
sendTo.event = eventOrExpr;
|
|
249
249
|
sendTo.id = options?.id;
|
|
@@ -291,7 +291,7 @@ function escalate(errorData, options) {
|
|
|
291
291
|
}, options);
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
-
function resolveEnqueueActions(_,
|
|
294
|
+
function resolveEnqueueActions(_, snapshot, args, _actionParams, {
|
|
295
295
|
collect
|
|
296
296
|
}) {
|
|
297
297
|
const actions = [];
|
|
@@ -320,9 +320,9 @@ function resolveEnqueueActions(_, state, args, _actionParams, {
|
|
|
320
320
|
context: args.context,
|
|
321
321
|
event: args.event,
|
|
322
322
|
enqueue,
|
|
323
|
-
check: guard => guards_dist_xstateGuards.evaluateGuard(guard,
|
|
323
|
+
check: guard => guards_dist_xstateGuards.evaluateGuard(guard, snapshot.context, args.event, snapshot)
|
|
324
324
|
});
|
|
325
|
-
return [
|
|
325
|
+
return [snapshot, undefined, actions];
|
|
326
326
|
}
|
|
327
327
|
function enqueueActions(collect) {
|
|
328
328
|
function enqueueActions(args, params) {
|
|
@@ -333,11 +333,11 @@ function enqueueActions(collect) {
|
|
|
333
333
|
return enqueueActions;
|
|
334
334
|
}
|
|
335
335
|
|
|
336
|
-
function resolveLog(_,
|
|
336
|
+
function resolveLog(_, snapshot, actionArgs, actionParams, {
|
|
337
337
|
value,
|
|
338
338
|
label
|
|
339
339
|
}) {
|
|
340
|
-
return [
|
|
340
|
+
return [snapshot, {
|
|
341
341
|
value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
|
|
342
342
|
label
|
|
343
343
|
}];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
3
|
+
var guards_dist_xstateGuards = require('./raise-d9fd8932.development.cjs.js');
|
|
4
4
|
|
|
5
5
|
function createSpawner(actorScope, {
|
|
6
6
|
machine,
|
|
@@ -55,17 +55,17 @@ function createSpawner(actorScope, {
|
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
function resolveAssign(actorScope,
|
|
58
|
+
function resolveAssign(actorScope, snapshot, actionArgs, actionParams, {
|
|
59
59
|
assignment
|
|
60
60
|
}) {
|
|
61
|
-
if (!
|
|
61
|
+
if (!snapshot.context) {
|
|
62
62
|
throw new Error('Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.');
|
|
63
63
|
}
|
|
64
64
|
const spawnedChildren = {};
|
|
65
65
|
const assignArgs = {
|
|
66
|
-
context:
|
|
66
|
+
context: snapshot.context,
|
|
67
67
|
event: actionArgs.event,
|
|
68
|
-
spawn: createSpawner(actorScope,
|
|
68
|
+
spawn: createSpawner(actorScope, snapshot, actionArgs.event, spawnedChildren),
|
|
69
69
|
self: actorScope?.self,
|
|
70
70
|
system: actorScope?.system
|
|
71
71
|
};
|
|
@@ -78,13 +78,13 @@ function resolveAssign(actorScope, state, actionArgs, actionParams, {
|
|
|
78
78
|
partialUpdate[key] = typeof propAssignment === 'function' ? propAssignment(assignArgs, actionParams) : propAssignment;
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
-
const updatedContext = Object.assign({},
|
|
82
|
-
return [guards_dist_xstateGuards.cloneMachineSnapshot(
|
|
81
|
+
const updatedContext = Object.assign({}, snapshot.context, partialUpdate);
|
|
82
|
+
return [guards_dist_xstateGuards.cloneMachineSnapshot(snapshot, {
|
|
83
83
|
context: updatedContext,
|
|
84
84
|
children: Object.keys(spawnedChildren).length ? {
|
|
85
|
-
...
|
|
85
|
+
...snapshot.children,
|
|
86
86
|
...spawnedChildren
|
|
87
|
-
} :
|
|
87
|
+
} : snapshot.children
|
|
88
88
|
})];
|
|
89
89
|
}
|
|
90
90
|
/**
|
|
@@ -168,13 +168,13 @@ let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
|
|
|
168
168
|
* @template TSystem - The type of the actor system.
|
|
169
169
|
*/
|
|
170
170
|
|
|
171
|
-
function resolveSendTo(actorScope,
|
|
171
|
+
function resolveSendTo(actorScope, snapshot, args, actionParams, {
|
|
172
172
|
to,
|
|
173
173
|
event: eventOrExpr,
|
|
174
174
|
id,
|
|
175
175
|
delay
|
|
176
176
|
}, extra) {
|
|
177
|
-
const delaysMap =
|
|
177
|
+
const delaysMap = snapshot.machine.implementations.delays;
|
|
178
178
|
if (typeof eventOrExpr === 'string') {
|
|
179
179
|
throw new Error(`Only event objects may be used with sendTo; use sendTo({ type: "${eventOrExpr}" }) instead`);
|
|
180
180
|
}
|
|
@@ -196,26 +196,26 @@ function resolveSendTo(actorScope, state, args, actionParams, {
|
|
|
196
196
|
} else if (resolvedTarget.startsWith('#_')) {
|
|
197
197
|
// SCXML compatibility: https://www.w3.org/TR/scxml/#SCXMLEventProcessor
|
|
198
198
|
// #_invokeid. If the target is the special term '#_invokeid', where invokeid is the invokeid of an SCXML session that the sending session has created by <invoke>, the Processor must add the event to the external queue of that session.
|
|
199
|
-
targetActorRef =
|
|
199
|
+
targetActorRef = snapshot.children[resolvedTarget.slice(2)];
|
|
200
200
|
} else {
|
|
201
|
-
targetActorRef = extra.deferredActorIds?.includes(resolvedTarget) ? resolvedTarget :
|
|
201
|
+
targetActorRef = extra.deferredActorIds?.includes(resolvedTarget) ? resolvedTarget : snapshot.children[resolvedTarget];
|
|
202
202
|
}
|
|
203
203
|
if (!targetActorRef) {
|
|
204
|
-
throw new Error(`Unable to send event to actor '${resolvedTarget}' from machine '${
|
|
204
|
+
throw new Error(`Unable to send event to actor '${resolvedTarget}' from machine '${snapshot.machine.id}'.`);
|
|
205
205
|
}
|
|
206
206
|
} else {
|
|
207
207
|
targetActorRef = resolvedTarget || actorScope?.self;
|
|
208
208
|
}
|
|
209
|
-
return [
|
|
209
|
+
return [snapshot, {
|
|
210
210
|
to: targetActorRef,
|
|
211
211
|
event: resolvedEvent,
|
|
212
212
|
id,
|
|
213
213
|
delay: resolvedDelay
|
|
214
214
|
}];
|
|
215
215
|
}
|
|
216
|
-
function retryResolveSendTo(_,
|
|
216
|
+
function retryResolveSendTo(_, snapshot, params) {
|
|
217
217
|
if (typeof params.to === 'string') {
|
|
218
|
-
params.to =
|
|
218
|
+
params.to = snapshot.children[params.to];
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
function executeSendTo(actorScope, params) {
|
|
@@ -249,7 +249,7 @@ function sendTo(to, eventOrExpr, options) {
|
|
|
249
249
|
throw new Error(`This isn't supposed to be called`);
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
|
-
sendTo.type = '
|
|
252
|
+
sendTo.type = 'xsnapshot.sendTo';
|
|
253
253
|
sendTo.to = to;
|
|
254
254
|
sendTo.event = eventOrExpr;
|
|
255
255
|
sendTo.id = options?.id;
|
|
@@ -307,7 +307,7 @@ function escalate(errorData, options) {
|
|
|
307
307
|
}, options);
|
|
308
308
|
}
|
|
309
309
|
|
|
310
|
-
function resolveEnqueueActions(_,
|
|
310
|
+
function resolveEnqueueActions(_, snapshot, args, _actionParams, {
|
|
311
311
|
collect
|
|
312
312
|
}) {
|
|
313
313
|
const actions = [];
|
|
@@ -336,9 +336,9 @@ function resolveEnqueueActions(_, state, args, _actionParams, {
|
|
|
336
336
|
context: args.context,
|
|
337
337
|
event: args.event,
|
|
338
338
|
enqueue,
|
|
339
|
-
check: guard => guards_dist_xstateGuards.evaluateGuard(guard,
|
|
339
|
+
check: guard => guards_dist_xstateGuards.evaluateGuard(guard, snapshot.context, args.event, snapshot)
|
|
340
340
|
});
|
|
341
|
-
return [
|
|
341
|
+
return [snapshot, undefined, actions];
|
|
342
342
|
}
|
|
343
343
|
function enqueueActions(collect) {
|
|
344
344
|
function enqueueActions(args, params) {
|
|
@@ -352,11 +352,11 @@ function enqueueActions(collect) {
|
|
|
352
352
|
return enqueueActions;
|
|
353
353
|
}
|
|
354
354
|
|
|
355
|
-
function resolveLog(_,
|
|
355
|
+
function resolveLog(_, snapshot, actionArgs, actionParams, {
|
|
356
356
|
value,
|
|
357
357
|
label
|
|
358
358
|
}) {
|
|
359
|
-
return [
|
|
359
|
+
return [snapshot, {
|
|
360
360
|
value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
|
|
361
361
|
label
|
|
362
362
|
}];
|