xstate 5.18.2 → 5.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +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/dev/dist/xstate-dev.cjs.js +1 -1
- package/dev/dist/xstate-dev.development.cjs.js +1 -1
- package/dev/dist/xstate-dev.development.esm.js +1 -1
- package/dev/dist/xstate-dev.esm.js +1 -1
- package/dev/dist/xstate-dev.umd.min.js.map +1 -1
- package/dist/declarations/src/State.d.ts +1 -1
- package/dist/declarations/src/actions/raise.d.ts +9 -1
- package/dist/declarations/src/actions/send.d.ts +10 -1
- package/dist/declarations/src/createActor.d.ts +2 -1
- package/dist/declarations/src/getNextSnapshot.d.ts +2 -0
- package/dist/declarations/src/index.d.ts +1 -0
- package/dist/declarations/src/inspection.d.ts +1 -1
- package/dist/declarations/src/spawn.d.ts +19 -11
- package/dist/declarations/src/stateUtils.d.ts +17 -7
- package/dist/declarations/src/transition.d.ts +16 -0
- package/dist/declarations/src/types.d.ts +48 -14
- package/dist/declarations/src/utils.d.ts +1 -1
- package/dist/{log-38475d87.development.esm.js → log-0acd9069.development.esm.js} +32 -33
- package/dist/{log-15d0f775.esm.js → log-3d9d72a9.esm.js} +31 -29
- package/dist/{log-b7ed1b61.development.cjs.js → log-8aa651a0.development.cjs.js} +32 -33
- package/dist/{log-98fcce74.cjs.js → log-a019fbd0.cjs.js} +31 -29
- package/dist/{raise-5ea71f04.development.esm.js → raise-1db27a82.development.esm.js} +98 -72
- package/dist/{raise-e919c5d4.development.cjs.js → raise-4acdb210.development.cjs.js} +98 -72
- package/dist/{raise-b1e0b9a9.cjs.js → raise-60cebf03.cjs.js} +94 -70
- package/dist/{raise-0f7cf128.esm.js → raise-c17ec2bc.esm.js} +94 -70
- package/dist/xstate.cjs.js +57 -15
- package/dist/xstate.cjs.mjs +2 -0
- package/dist/xstate.development.cjs.js +57 -15
- package/dist/xstate.development.cjs.mjs +2 -0
- package/dist/xstate.development.esm.js +58 -18
- package/dist/xstate.esm.js +58 -18
- 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 +1 -1
- package/guards/dist/xstate-guards.umd.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,41 +1,37 @@
|
|
|
1
|
-
import { T as ProcessingStatus, z as resolveReferencedActor, A as createActor, U as cloneMachineSnapshot, V as XSTATE_ERROR, W as createErrorActorEvent, e as evaluateGuard, M as cancel, O as raise, P as spawnChild, R as stopChild } from './raise-
|
|
1
|
+
import { T as ProcessingStatus, z as resolveReferencedActor, A as createActor, U as cloneMachineSnapshot, V as XSTATE_ERROR, W as createErrorActorEvent, e as evaluateGuard, M as cancel, O as raise, P as spawnChild, R as stopChild } from './raise-c17ec2bc.esm.js';
|
|
2
2
|
|
|
3
3
|
function createSpawner(actorScope, {
|
|
4
4
|
machine,
|
|
5
5
|
context
|
|
6
6
|
}, event, spawnedChildren) {
|
|
7
|
-
const spawn = (src, options
|
|
8
|
-
const {
|
|
9
|
-
systemId,
|
|
10
|
-
input
|
|
11
|
-
} = options;
|
|
7
|
+
const spawn = (src, options) => {
|
|
12
8
|
if (typeof src === 'string') {
|
|
13
9
|
const logic = resolveReferencedActor(machine, src);
|
|
14
10
|
if (!logic) {
|
|
15
11
|
throw new Error(`Actor logic '${src}' not implemented in machine '${machine.id}'`);
|
|
16
12
|
}
|
|
17
13
|
const actorRef = createActor(logic, {
|
|
18
|
-
id: options
|
|
14
|
+
id: options?.id,
|
|
19
15
|
parent: actorScope.self,
|
|
20
|
-
syncSnapshot: options
|
|
21
|
-
input: typeof input === 'function' ? input({
|
|
16
|
+
syncSnapshot: options?.syncSnapshot,
|
|
17
|
+
input: typeof options?.input === 'function' ? options.input({
|
|
22
18
|
context,
|
|
23
19
|
event,
|
|
24
20
|
self: actorScope.self
|
|
25
|
-
}) : input,
|
|
21
|
+
}) : options?.input,
|
|
26
22
|
src,
|
|
27
|
-
systemId
|
|
23
|
+
systemId: options?.systemId
|
|
28
24
|
});
|
|
29
25
|
spawnedChildren[actorRef.id] = actorRef;
|
|
30
26
|
return actorRef;
|
|
31
27
|
} else {
|
|
32
28
|
const actorRef = createActor(src, {
|
|
33
|
-
id: options
|
|
29
|
+
id: options?.id,
|
|
34
30
|
parent: actorScope.self,
|
|
35
|
-
syncSnapshot: options
|
|
36
|
-
input: options
|
|
31
|
+
syncSnapshot: options?.syncSnapshot,
|
|
32
|
+
input: options?.input,
|
|
37
33
|
src,
|
|
38
|
-
systemId
|
|
34
|
+
systemId: options?.systemId
|
|
39
35
|
});
|
|
40
36
|
return actorRef;
|
|
41
37
|
}
|
|
@@ -83,7 +79,7 @@ function resolveAssign(actorScope, snapshot, actionArgs, actionParams, {
|
|
|
83
79
|
...snapshot.children,
|
|
84
80
|
...spawnedChildren
|
|
85
81
|
} : snapshot.children
|
|
86
|
-
})];
|
|
82
|
+
}), undefined, undefined];
|
|
87
83
|
}
|
|
88
84
|
/**
|
|
89
85
|
* Updates the current context of the machine.
|
|
@@ -120,7 +116,7 @@ function resolveAssign(actorScope, snapshot, actionArgs, actionParams, {
|
|
|
120
116
|
* update.
|
|
121
117
|
*/
|
|
122
118
|
function assign(assignment) {
|
|
123
|
-
function assign(
|
|
119
|
+
function assign(_args, _params) {
|
|
124
120
|
}
|
|
125
121
|
assign.type = 'xstate.assign';
|
|
126
122
|
assign.assignment = assignment;
|
|
@@ -134,7 +130,7 @@ function resolveEmit(_, snapshot, args, actionParams, {
|
|
|
134
130
|
const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args, actionParams) : eventOrExpr;
|
|
135
131
|
return [snapshot, {
|
|
136
132
|
event: resolvedEvent
|
|
137
|
-
}];
|
|
133
|
+
}, undefined];
|
|
138
134
|
}
|
|
139
135
|
function executeEmit(actorScope, {
|
|
140
136
|
event
|
|
@@ -179,7 +175,7 @@ function executeEmit(actorScope, {
|
|
|
179
175
|
*/
|
|
180
176
|
function emit(/** The event to emit, or an expression that returns an event to emit. */
|
|
181
177
|
eventOrExpr) {
|
|
182
|
-
function emit(
|
|
178
|
+
function emit(_args, _params) {
|
|
183
179
|
}
|
|
184
180
|
emit.type = 'xstate.emit';
|
|
185
181
|
emit.event = eventOrExpr;
|
|
@@ -224,8 +220,6 @@ eventOrExpr) {
|
|
|
224
220
|
* "someChildState" }`.
|
|
225
221
|
*/
|
|
226
222
|
|
|
227
|
-
// TODO: remove once TS fixes this type-widening issue
|
|
228
|
-
|
|
229
223
|
/** @deprecated Use `AnyMachineSnapshot` instead */
|
|
230
224
|
|
|
231
225
|
// TODO: possibly refactor this somehow, use even a simpler type, and maybe even make `machine.options` private or something
|
|
@@ -256,6 +250,8 @@ let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
|
|
|
256
250
|
|
|
257
251
|
/** @deprecated */
|
|
258
252
|
|
|
253
|
+
// TODO: cover all that can be actually returned
|
|
254
|
+
|
|
259
255
|
function resolveSendTo(actorScope, snapshot, args, actionParams, {
|
|
260
256
|
to,
|
|
261
257
|
event: eventOrExpr,
|
|
@@ -264,7 +260,9 @@ function resolveSendTo(actorScope, snapshot, args, actionParams, {
|
|
|
264
260
|
}, extra) {
|
|
265
261
|
const delaysMap = snapshot.machine.implementations.delays;
|
|
266
262
|
if (typeof eventOrExpr === 'string') {
|
|
267
|
-
throw new Error(
|
|
263
|
+
throw new Error(
|
|
264
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
265
|
+
`Only event objects may be used with sendTo; use sendTo({ type: "${eventOrExpr}" }) instead`);
|
|
268
266
|
}
|
|
269
267
|
const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args, actionParams) : eventOrExpr;
|
|
270
268
|
let resolvedDelay;
|
|
@@ -277,9 +275,12 @@ function resolveSendTo(actorScope, snapshot, args, actionParams, {
|
|
|
277
275
|
const resolvedTarget = typeof to === 'function' ? to(args, actionParams) : to;
|
|
278
276
|
let targetActorRef;
|
|
279
277
|
if (typeof resolvedTarget === 'string') {
|
|
278
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
|
|
280
279
|
if (resolvedTarget === SpecialTargets.Parent) {
|
|
281
280
|
targetActorRef = actorScope.self._parent;
|
|
282
|
-
}
|
|
281
|
+
}
|
|
282
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
|
|
283
|
+
else if (resolvedTarget === SpecialTargets.Internal) {
|
|
283
284
|
targetActorRef = actorScope.self;
|
|
284
285
|
} else if (resolvedTarget.startsWith('#_')) {
|
|
285
286
|
// SCXML compatibility: https://www.w3.org/TR/scxml/#SCXMLEventProcessor
|
|
@@ -296,10 +297,11 @@ function resolveSendTo(actorScope, snapshot, args, actionParams, {
|
|
|
296
297
|
}
|
|
297
298
|
return [snapshot, {
|
|
298
299
|
to: targetActorRef,
|
|
300
|
+
targetId: typeof resolvedTarget === 'string' ? resolvedTarget : undefined,
|
|
299
301
|
event: resolvedEvent,
|
|
300
302
|
id,
|
|
301
303
|
delay: resolvedDelay
|
|
302
|
-
}];
|
|
304
|
+
}, undefined];
|
|
303
305
|
}
|
|
304
306
|
function retryResolveSendTo(_, snapshot, params) {
|
|
305
307
|
if (typeof params.to === 'string') {
|
|
@@ -338,9 +340,9 @@ function executeSendTo(actorScope, params) {
|
|
|
338
340
|
* - `delay` - The number of milliseconds to delay the sending of the event.
|
|
339
341
|
*/
|
|
340
342
|
function sendTo(to, eventOrExpr, options) {
|
|
341
|
-
function sendTo(
|
|
343
|
+
function sendTo(_args, _params) {
|
|
342
344
|
}
|
|
343
|
-
sendTo.type = '
|
|
345
|
+
sendTo.type = 'xstate.sendTo';
|
|
344
346
|
sendTo.to = to;
|
|
345
347
|
sendTo.event = eventOrExpr;
|
|
346
348
|
sendTo.id = options?.id;
|
|
@@ -440,7 +442,7 @@ function resolveEnqueueActions(actorScope, snapshot, args, actionParams, {
|
|
|
440
442
|
* ```
|
|
441
443
|
*/
|
|
442
444
|
function enqueueActions(collect) {
|
|
443
|
-
function enqueueActions(
|
|
445
|
+
function enqueueActions(_args, _params) {
|
|
444
446
|
}
|
|
445
447
|
enqueueActions.type = 'xstate.enqueueActions';
|
|
446
448
|
enqueueActions.collect = collect;
|
|
@@ -455,7 +457,7 @@ function resolveLog(_, snapshot, actionArgs, actionParams, {
|
|
|
455
457
|
return [snapshot, {
|
|
456
458
|
value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
|
|
457
459
|
label
|
|
458
|
-
}];
|
|
460
|
+
}, undefined];
|
|
459
461
|
}
|
|
460
462
|
function executeLog({
|
|
461
463
|
logger
|
|
@@ -485,7 +487,7 @@ function log(value = ({
|
|
|
485
487
|
context,
|
|
486
488
|
event
|
|
487
489
|
}), label) {
|
|
488
|
-
function log(
|
|
490
|
+
function log(_args, _params) {
|
|
489
491
|
}
|
|
490
492
|
log.type = 'xstate.log';
|
|
491
493
|
log.value = value;
|
|
@@ -1,43 +1,39 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
3
|
+
var guards_dist_xstateGuards = require('./raise-4acdb210.development.cjs.js');
|
|
4
4
|
|
|
5
5
|
function createSpawner(actorScope, {
|
|
6
6
|
machine,
|
|
7
7
|
context
|
|
8
8
|
}, event, spawnedChildren) {
|
|
9
|
-
const spawn = (src, options
|
|
10
|
-
const {
|
|
11
|
-
systemId,
|
|
12
|
-
input
|
|
13
|
-
} = options;
|
|
9
|
+
const spawn = (src, options) => {
|
|
14
10
|
if (typeof src === 'string') {
|
|
15
11
|
const logic = guards_dist_xstateGuards.resolveReferencedActor(machine, src);
|
|
16
12
|
if (!logic) {
|
|
17
13
|
throw new Error(`Actor logic '${src}' not implemented in machine '${machine.id}'`);
|
|
18
14
|
}
|
|
19
15
|
const actorRef = guards_dist_xstateGuards.createActor(logic, {
|
|
20
|
-
id: options
|
|
16
|
+
id: options?.id,
|
|
21
17
|
parent: actorScope.self,
|
|
22
|
-
syncSnapshot: options
|
|
23
|
-
input: typeof input === 'function' ? input({
|
|
18
|
+
syncSnapshot: options?.syncSnapshot,
|
|
19
|
+
input: typeof options?.input === 'function' ? options.input({
|
|
24
20
|
context,
|
|
25
21
|
event,
|
|
26
22
|
self: actorScope.self
|
|
27
|
-
}) : input,
|
|
23
|
+
}) : options?.input,
|
|
28
24
|
src,
|
|
29
|
-
systemId
|
|
25
|
+
systemId: options?.systemId
|
|
30
26
|
});
|
|
31
27
|
spawnedChildren[actorRef.id] = actorRef;
|
|
32
28
|
return actorRef;
|
|
33
29
|
} else {
|
|
34
30
|
const actorRef = guards_dist_xstateGuards.createActor(src, {
|
|
35
|
-
id: options
|
|
31
|
+
id: options?.id,
|
|
36
32
|
parent: actorScope.self,
|
|
37
|
-
syncSnapshot: options
|
|
38
|
-
input: options
|
|
33
|
+
syncSnapshot: options?.syncSnapshot,
|
|
34
|
+
input: options?.input,
|
|
39
35
|
src,
|
|
40
|
-
systemId
|
|
36
|
+
systemId: options?.systemId
|
|
41
37
|
});
|
|
42
38
|
return actorRef;
|
|
43
39
|
}
|
|
@@ -85,7 +81,7 @@ function resolveAssign(actorScope, snapshot, actionArgs, actionParams, {
|
|
|
85
81
|
...snapshot.children,
|
|
86
82
|
...spawnedChildren
|
|
87
83
|
} : snapshot.children
|
|
88
|
-
})];
|
|
84
|
+
}), undefined, undefined];
|
|
89
85
|
}
|
|
90
86
|
/**
|
|
91
87
|
* Updates the current context of the machine.
|
|
@@ -125,7 +121,7 @@ function assign(assignment) {
|
|
|
125
121
|
if (guards_dist_xstateGuards.executingCustomAction) {
|
|
126
122
|
console.warn('Custom actions should not call `assign()` directly, as it is not imperative. See https://stately.ai/docs/actions#built-in-actions for more details.');
|
|
127
123
|
}
|
|
128
|
-
function assign(
|
|
124
|
+
function assign(_args, _params) {
|
|
129
125
|
{
|
|
130
126
|
throw new Error(`This isn't supposed to be called`);
|
|
131
127
|
}
|
|
@@ -139,13 +135,10 @@ function assign(assignment) {
|
|
|
139
135
|
function resolveEmit(_, snapshot, args, actionParams, {
|
|
140
136
|
event: eventOrExpr
|
|
141
137
|
}) {
|
|
142
|
-
if (typeof eventOrExpr === 'string') {
|
|
143
|
-
throw new Error(`Only event objects may be used with emit; use emit({ type: "${eventOrExpr}" }) instead`);
|
|
144
|
-
}
|
|
145
138
|
const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args, actionParams) : eventOrExpr;
|
|
146
139
|
return [snapshot, {
|
|
147
140
|
event: resolvedEvent
|
|
148
|
-
}];
|
|
141
|
+
}, undefined];
|
|
149
142
|
}
|
|
150
143
|
function executeEmit(actorScope, {
|
|
151
144
|
event
|
|
@@ -193,7 +186,7 @@ eventOrExpr) {
|
|
|
193
186
|
if (guards_dist_xstateGuards.executingCustomAction) {
|
|
194
187
|
console.warn('Custom actions should not call `emit()` directly, as it is not imperative. See https://stately.ai/docs/actions#built-in-actions for more details.');
|
|
195
188
|
}
|
|
196
|
-
function emit(
|
|
189
|
+
function emit(_args, _params) {
|
|
197
190
|
{
|
|
198
191
|
throw new Error(`This isn't supposed to be called`);
|
|
199
192
|
}
|
|
@@ -241,8 +234,6 @@ eventOrExpr) {
|
|
|
241
234
|
* "someChildState" }`.
|
|
242
235
|
*/
|
|
243
236
|
|
|
244
|
-
// TODO: remove once TS fixes this type-widening issue
|
|
245
|
-
|
|
246
237
|
/** @deprecated Use `AnyMachineSnapshot` instead */
|
|
247
238
|
|
|
248
239
|
// TODO: possibly refactor this somehow, use even a simpler type, and maybe even make `machine.options` private or something
|
|
@@ -273,6 +264,8 @@ let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
|
|
|
273
264
|
|
|
274
265
|
/** @deprecated */
|
|
275
266
|
|
|
267
|
+
// TODO: cover all that can be actually returned
|
|
268
|
+
|
|
276
269
|
function resolveSendTo(actorScope, snapshot, args, actionParams, {
|
|
277
270
|
to,
|
|
278
271
|
event: eventOrExpr,
|
|
@@ -281,7 +274,9 @@ function resolveSendTo(actorScope, snapshot, args, actionParams, {
|
|
|
281
274
|
}, extra) {
|
|
282
275
|
const delaysMap = snapshot.machine.implementations.delays;
|
|
283
276
|
if (typeof eventOrExpr === 'string') {
|
|
284
|
-
throw new Error(
|
|
277
|
+
throw new Error(
|
|
278
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
279
|
+
`Only event objects may be used with sendTo; use sendTo({ type: "${eventOrExpr}" }) instead`);
|
|
285
280
|
}
|
|
286
281
|
const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args, actionParams) : eventOrExpr;
|
|
287
282
|
let resolvedDelay;
|
|
@@ -294,9 +289,12 @@ function resolveSendTo(actorScope, snapshot, args, actionParams, {
|
|
|
294
289
|
const resolvedTarget = typeof to === 'function' ? to(args, actionParams) : to;
|
|
295
290
|
let targetActorRef;
|
|
296
291
|
if (typeof resolvedTarget === 'string') {
|
|
292
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
|
|
297
293
|
if (resolvedTarget === SpecialTargets.Parent) {
|
|
298
294
|
targetActorRef = actorScope.self._parent;
|
|
299
|
-
}
|
|
295
|
+
}
|
|
296
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
|
|
297
|
+
else if (resolvedTarget === SpecialTargets.Internal) {
|
|
300
298
|
targetActorRef = actorScope.self;
|
|
301
299
|
} else if (resolvedTarget.startsWith('#_')) {
|
|
302
300
|
// SCXML compatibility: https://www.w3.org/TR/scxml/#SCXMLEventProcessor
|
|
@@ -313,10 +311,11 @@ function resolveSendTo(actorScope, snapshot, args, actionParams, {
|
|
|
313
311
|
}
|
|
314
312
|
return [snapshot, {
|
|
315
313
|
to: targetActorRef,
|
|
314
|
+
targetId: typeof resolvedTarget === 'string' ? resolvedTarget : undefined,
|
|
316
315
|
event: resolvedEvent,
|
|
317
316
|
id,
|
|
318
317
|
delay: resolvedDelay
|
|
319
|
-
}];
|
|
318
|
+
}, undefined];
|
|
320
319
|
}
|
|
321
320
|
function retryResolveSendTo(_, snapshot, params) {
|
|
322
321
|
if (typeof params.to === 'string') {
|
|
@@ -356,14 +355,14 @@ function executeSendTo(actorScope, params) {
|
|
|
356
355
|
*/
|
|
357
356
|
function sendTo(to, eventOrExpr, options) {
|
|
358
357
|
if (guards_dist_xstateGuards.executingCustomAction) {
|
|
359
|
-
console.warn('Custom actions should not call `
|
|
358
|
+
console.warn('Custom actions should not call `sendTo()` directly, as it is not imperative. See https://stately.ai/docs/actions#built-in-actions for more details.');
|
|
360
359
|
}
|
|
361
|
-
function sendTo(
|
|
360
|
+
function sendTo(_args, _params) {
|
|
362
361
|
{
|
|
363
362
|
throw new Error(`This isn't supposed to be called`);
|
|
364
363
|
}
|
|
365
364
|
}
|
|
366
|
-
sendTo.type = '
|
|
365
|
+
sendTo.type = 'xstate.sendTo';
|
|
367
366
|
sendTo.to = to;
|
|
368
367
|
sendTo.event = eventOrExpr;
|
|
369
368
|
sendTo.id = options?.id;
|
|
@@ -473,7 +472,7 @@ function resolveEnqueueActions(actorScope, snapshot, args, actionParams, {
|
|
|
473
472
|
* ```
|
|
474
473
|
*/
|
|
475
474
|
function enqueueActions(collect) {
|
|
476
|
-
function enqueueActions(
|
|
475
|
+
function enqueueActions(_args, _params) {
|
|
477
476
|
{
|
|
478
477
|
throw new Error(`This isn't supposed to be called`);
|
|
479
478
|
}
|
|
@@ -491,7 +490,7 @@ function resolveLog(_, snapshot, actionArgs, actionParams, {
|
|
|
491
490
|
return [snapshot, {
|
|
492
491
|
value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
|
|
493
492
|
label
|
|
494
|
-
}];
|
|
493
|
+
}, undefined];
|
|
495
494
|
}
|
|
496
495
|
function executeLog({
|
|
497
496
|
logger
|
|
@@ -521,7 +520,7 @@ function log(value = ({
|
|
|
521
520
|
context,
|
|
522
521
|
event
|
|
523
522
|
}), label) {
|
|
524
|
-
function log(
|
|
523
|
+
function log(_args, _params) {
|
|
525
524
|
{
|
|
526
525
|
throw new Error(`This isn't supposed to be called`);
|
|
527
526
|
}
|
|
@@ -1,43 +1,39 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
3
|
+
var guards_dist_xstateGuards = require('./raise-60cebf03.cjs.js');
|
|
4
4
|
|
|
5
5
|
function createSpawner(actorScope, {
|
|
6
6
|
machine,
|
|
7
7
|
context
|
|
8
8
|
}, event, spawnedChildren) {
|
|
9
|
-
const spawn = (src, options
|
|
10
|
-
const {
|
|
11
|
-
systemId,
|
|
12
|
-
input
|
|
13
|
-
} = options;
|
|
9
|
+
const spawn = (src, options) => {
|
|
14
10
|
if (typeof src === 'string') {
|
|
15
11
|
const logic = guards_dist_xstateGuards.resolveReferencedActor(machine, src);
|
|
16
12
|
if (!logic) {
|
|
17
13
|
throw new Error(`Actor logic '${src}' not implemented in machine '${machine.id}'`);
|
|
18
14
|
}
|
|
19
15
|
const actorRef = guards_dist_xstateGuards.createActor(logic, {
|
|
20
|
-
id: options
|
|
16
|
+
id: options?.id,
|
|
21
17
|
parent: actorScope.self,
|
|
22
|
-
syncSnapshot: options
|
|
23
|
-
input: typeof input === 'function' ? input({
|
|
18
|
+
syncSnapshot: options?.syncSnapshot,
|
|
19
|
+
input: typeof options?.input === 'function' ? options.input({
|
|
24
20
|
context,
|
|
25
21
|
event,
|
|
26
22
|
self: actorScope.self
|
|
27
|
-
}) : input,
|
|
23
|
+
}) : options?.input,
|
|
28
24
|
src,
|
|
29
|
-
systemId
|
|
25
|
+
systemId: options?.systemId
|
|
30
26
|
});
|
|
31
27
|
spawnedChildren[actorRef.id] = actorRef;
|
|
32
28
|
return actorRef;
|
|
33
29
|
} else {
|
|
34
30
|
const actorRef = guards_dist_xstateGuards.createActor(src, {
|
|
35
|
-
id: options
|
|
31
|
+
id: options?.id,
|
|
36
32
|
parent: actorScope.self,
|
|
37
|
-
syncSnapshot: options
|
|
38
|
-
input: options
|
|
33
|
+
syncSnapshot: options?.syncSnapshot,
|
|
34
|
+
input: options?.input,
|
|
39
35
|
src,
|
|
40
|
-
systemId
|
|
36
|
+
systemId: options?.systemId
|
|
41
37
|
});
|
|
42
38
|
return actorRef;
|
|
43
39
|
}
|
|
@@ -85,7 +81,7 @@ function resolveAssign(actorScope, snapshot, actionArgs, actionParams, {
|
|
|
85
81
|
...snapshot.children,
|
|
86
82
|
...spawnedChildren
|
|
87
83
|
} : snapshot.children
|
|
88
|
-
})];
|
|
84
|
+
}), undefined, undefined];
|
|
89
85
|
}
|
|
90
86
|
/**
|
|
91
87
|
* Updates the current context of the machine.
|
|
@@ -122,7 +118,7 @@ function resolveAssign(actorScope, snapshot, actionArgs, actionParams, {
|
|
|
122
118
|
* update.
|
|
123
119
|
*/
|
|
124
120
|
function assign(assignment) {
|
|
125
|
-
function assign(
|
|
121
|
+
function assign(_args, _params) {
|
|
126
122
|
}
|
|
127
123
|
assign.type = 'xstate.assign';
|
|
128
124
|
assign.assignment = assignment;
|
|
@@ -136,7 +132,7 @@ function resolveEmit(_, snapshot, args, actionParams, {
|
|
|
136
132
|
const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args, actionParams) : eventOrExpr;
|
|
137
133
|
return [snapshot, {
|
|
138
134
|
event: resolvedEvent
|
|
139
|
-
}];
|
|
135
|
+
}, undefined];
|
|
140
136
|
}
|
|
141
137
|
function executeEmit(actorScope, {
|
|
142
138
|
event
|
|
@@ -181,7 +177,7 @@ function executeEmit(actorScope, {
|
|
|
181
177
|
*/
|
|
182
178
|
function emit(/** The event to emit, or an expression that returns an event to emit. */
|
|
183
179
|
eventOrExpr) {
|
|
184
|
-
function emit(
|
|
180
|
+
function emit(_args, _params) {
|
|
185
181
|
}
|
|
186
182
|
emit.type = 'xstate.emit';
|
|
187
183
|
emit.event = eventOrExpr;
|
|
@@ -226,8 +222,6 @@ eventOrExpr) {
|
|
|
226
222
|
* "someChildState" }`.
|
|
227
223
|
*/
|
|
228
224
|
|
|
229
|
-
// TODO: remove once TS fixes this type-widening issue
|
|
230
|
-
|
|
231
225
|
/** @deprecated Use `AnyMachineSnapshot` instead */
|
|
232
226
|
|
|
233
227
|
// TODO: possibly refactor this somehow, use even a simpler type, and maybe even make `machine.options` private or something
|
|
@@ -258,6 +252,8 @@ let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
|
|
|
258
252
|
|
|
259
253
|
/** @deprecated */
|
|
260
254
|
|
|
255
|
+
// TODO: cover all that can be actually returned
|
|
256
|
+
|
|
261
257
|
function resolveSendTo(actorScope, snapshot, args, actionParams, {
|
|
262
258
|
to,
|
|
263
259
|
event: eventOrExpr,
|
|
@@ -266,7 +262,9 @@ function resolveSendTo(actorScope, snapshot, args, actionParams, {
|
|
|
266
262
|
}, extra) {
|
|
267
263
|
const delaysMap = snapshot.machine.implementations.delays;
|
|
268
264
|
if (typeof eventOrExpr === 'string') {
|
|
269
|
-
throw new Error(
|
|
265
|
+
throw new Error(
|
|
266
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
267
|
+
`Only event objects may be used with sendTo; use sendTo({ type: "${eventOrExpr}" }) instead`);
|
|
270
268
|
}
|
|
271
269
|
const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args, actionParams) : eventOrExpr;
|
|
272
270
|
let resolvedDelay;
|
|
@@ -279,9 +277,12 @@ function resolveSendTo(actorScope, snapshot, args, actionParams, {
|
|
|
279
277
|
const resolvedTarget = typeof to === 'function' ? to(args, actionParams) : to;
|
|
280
278
|
let targetActorRef;
|
|
281
279
|
if (typeof resolvedTarget === 'string') {
|
|
280
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
|
|
282
281
|
if (resolvedTarget === SpecialTargets.Parent) {
|
|
283
282
|
targetActorRef = actorScope.self._parent;
|
|
284
|
-
}
|
|
283
|
+
}
|
|
284
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
|
|
285
|
+
else if (resolvedTarget === SpecialTargets.Internal) {
|
|
285
286
|
targetActorRef = actorScope.self;
|
|
286
287
|
} else if (resolvedTarget.startsWith('#_')) {
|
|
287
288
|
// SCXML compatibility: https://www.w3.org/TR/scxml/#SCXMLEventProcessor
|
|
@@ -298,10 +299,11 @@ function resolveSendTo(actorScope, snapshot, args, actionParams, {
|
|
|
298
299
|
}
|
|
299
300
|
return [snapshot, {
|
|
300
301
|
to: targetActorRef,
|
|
302
|
+
targetId: typeof resolvedTarget === 'string' ? resolvedTarget : undefined,
|
|
301
303
|
event: resolvedEvent,
|
|
302
304
|
id,
|
|
303
305
|
delay: resolvedDelay
|
|
304
|
-
}];
|
|
306
|
+
}, undefined];
|
|
305
307
|
}
|
|
306
308
|
function retryResolveSendTo(_, snapshot, params) {
|
|
307
309
|
if (typeof params.to === 'string') {
|
|
@@ -340,9 +342,9 @@ function executeSendTo(actorScope, params) {
|
|
|
340
342
|
* - `delay` - The number of milliseconds to delay the sending of the event.
|
|
341
343
|
*/
|
|
342
344
|
function sendTo(to, eventOrExpr, options) {
|
|
343
|
-
function sendTo(
|
|
345
|
+
function sendTo(_args, _params) {
|
|
344
346
|
}
|
|
345
|
-
sendTo.type = '
|
|
347
|
+
sendTo.type = 'xstate.sendTo';
|
|
346
348
|
sendTo.to = to;
|
|
347
349
|
sendTo.event = eventOrExpr;
|
|
348
350
|
sendTo.id = options?.id;
|
|
@@ -442,7 +444,7 @@ function resolveEnqueueActions(actorScope, snapshot, args, actionParams, {
|
|
|
442
444
|
* ```
|
|
443
445
|
*/
|
|
444
446
|
function enqueueActions(collect) {
|
|
445
|
-
function enqueueActions(
|
|
447
|
+
function enqueueActions(_args, _params) {
|
|
446
448
|
}
|
|
447
449
|
enqueueActions.type = 'xstate.enqueueActions';
|
|
448
450
|
enqueueActions.collect = collect;
|
|
@@ -457,7 +459,7 @@ function resolveLog(_, snapshot, actionArgs, actionParams, {
|
|
|
457
459
|
return [snapshot, {
|
|
458
460
|
value: typeof value === 'function' ? value(actionArgs, actionParams) : value,
|
|
459
461
|
label
|
|
460
|
-
}];
|
|
462
|
+
}, undefined];
|
|
461
463
|
}
|
|
462
464
|
function executeLog({
|
|
463
465
|
logger
|
|
@@ -487,7 +489,7 @@ function log(value = ({
|
|
|
487
489
|
context,
|
|
488
490
|
event
|
|
489
491
|
}), label) {
|
|
490
|
-
function log(
|
|
492
|
+
function log(_args, _params) {
|
|
491
493
|
}
|
|
492
494
|
log.type = 'xstate.log';
|
|
493
495
|
log.value = value;
|