xstate 5.17.4 → 5.18.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.map +1 -1
- package/actors/dist/xstate-actors.cjs.js +7 -8
- package/actors/dist/xstate-actors.development.cjs.js +7 -8
- package/actors/dist/xstate-actors.development.esm.js +7 -8
- package/actors/dist/xstate-actors.esm.js +7 -8
- package/actors/dist/xstate-actors.umd.min.js.map +1 -1
- package/dist/declarations/src/State.d.ts +3 -3
- package/dist/declarations/src/actors/callback.d.ts +5 -6
- package/dist/declarations/src/actors/index.d.ts +1 -1
- package/dist/declarations/src/createActor.d.ts +3 -4
- package/dist/declarations/src/index.d.ts +5 -5
- package/dist/declarations/src/setup.d.ts +1 -17
- package/dist/declarations/src/types.d.ts +20 -0
- package/dist/declarations/src/waitFor.d.ts +2 -0
- package/dist/{log-f7dcaa97.cjs.js → log-098d2ed5.cjs.js} +1 -1
- package/dist/{log-54d038f7.esm.js → log-a2c94240.esm.js} +1 -1
- package/dist/{log-4f8360d3.development.esm.js → log-c92a07bc.development.esm.js} +1 -1
- package/dist/{log-40d606d3.development.cjs.js → log-d26be77d.development.cjs.js} +1 -1
- package/dist/{State-34039d2a.development.esm.js → raise-206d3d29.development.esm.js} +206 -206
- package/dist/{State-cdbc7940.esm.js → raise-c0e3c984.esm.js} +191 -191
- package/dist/xstate.cjs.js +129 -103
- package/dist/xstate.development.cjs.js +129 -103
- package/dist/xstate.development.esm.js +125 -99
- package/dist/xstate.esm.js +125 -99
- 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/package.json +1 -1
- package/dist/{State-a2464a1e.development.cjs.js → raise-830a98f7.development.cjs.js} +205 -205
- package/dist/{State-30c95050.cjs.js → raise-cde45f56.cjs.js} +190 -190
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var guards_dist_xstateGuards = require('../../dist/
|
|
5
|
+
var guards_dist_xstateGuards = require('../../dist/raise-cde45f56.cjs.js');
|
|
6
6
|
require('../../dev/dist/xstate-dev.cjs.js');
|
|
7
7
|
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var guards_dist_xstateGuards = require('../../dist/
|
|
5
|
+
var guards_dist_xstateGuards = require('../../dist/raise-830a98f7.development.cjs.js');
|
|
6
6
|
require('../../dev/dist/xstate-dev.development.cjs.js');
|
|
7
7
|
|
|
8
8
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { D as and, e as evaluateGuard, E as not, F as or, G as stateIn } from '../../dist/raise-206d3d29.development.esm.js';
|
|
2
2
|
import '../../dev/dist/xstate-dev.development.esm.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { D as and, e as evaluateGuard, E as not, F as or, G as stateIn } from '../../dist/raise-c0e3c984.esm.js';
|
|
2
2
|
import '../../dev/dist/xstate-dev.esm.js';
|
package/package.json
CHANGED
|
@@ -1139,6 +1139,145 @@ function cancel(sendId) {
|
|
|
1139
1139
|
return cancel;
|
|
1140
1140
|
}
|
|
1141
1141
|
|
|
1142
|
+
function resolveSpawn(actorScope, snapshot, actionArgs, _actionParams, {
|
|
1143
|
+
id,
|
|
1144
|
+
systemId,
|
|
1145
|
+
src,
|
|
1146
|
+
input,
|
|
1147
|
+
syncSnapshot
|
|
1148
|
+
}) {
|
|
1149
|
+
const logic = typeof src === 'string' ? resolveReferencedActor(snapshot.machine, src) : src;
|
|
1150
|
+
const resolvedId = typeof id === 'function' ? id(actionArgs) : id;
|
|
1151
|
+
let actorRef;
|
|
1152
|
+
if (logic) {
|
|
1153
|
+
actorRef = createActor(logic, {
|
|
1154
|
+
id: resolvedId,
|
|
1155
|
+
src,
|
|
1156
|
+
parent: actorScope.self,
|
|
1157
|
+
syncSnapshot,
|
|
1158
|
+
systemId,
|
|
1159
|
+
input: typeof input === 'function' ? input({
|
|
1160
|
+
context: snapshot.context,
|
|
1161
|
+
event: actionArgs.event,
|
|
1162
|
+
self: actorScope.self
|
|
1163
|
+
}) : input
|
|
1164
|
+
});
|
|
1165
|
+
}
|
|
1166
|
+
if (!actorRef) {
|
|
1167
|
+
console.warn(`Actor type '${src}' not found in machine '${actorScope.id}'.`);
|
|
1168
|
+
}
|
|
1169
|
+
return [cloneMachineSnapshot(snapshot, {
|
|
1170
|
+
children: {
|
|
1171
|
+
...snapshot.children,
|
|
1172
|
+
[resolvedId]: actorRef
|
|
1173
|
+
}
|
|
1174
|
+
}), {
|
|
1175
|
+
id,
|
|
1176
|
+
actorRef
|
|
1177
|
+
}];
|
|
1178
|
+
}
|
|
1179
|
+
function executeSpawn(actorScope, {
|
|
1180
|
+
id,
|
|
1181
|
+
actorRef
|
|
1182
|
+
}) {
|
|
1183
|
+
if (!actorRef) {
|
|
1184
|
+
return;
|
|
1185
|
+
}
|
|
1186
|
+
actorScope.defer(() => {
|
|
1187
|
+
if (actorRef._processingStatus === ProcessingStatus.Stopped) {
|
|
1188
|
+
return;
|
|
1189
|
+
}
|
|
1190
|
+
actorRef.start();
|
|
1191
|
+
});
|
|
1192
|
+
}
|
|
1193
|
+
function spawnChild(...[src, {
|
|
1194
|
+
id,
|
|
1195
|
+
systemId,
|
|
1196
|
+
input,
|
|
1197
|
+
syncSnapshot = false
|
|
1198
|
+
} = {}]) {
|
|
1199
|
+
function spawnChild(args, params) {
|
|
1200
|
+
{
|
|
1201
|
+
throw new Error(`This isn't supposed to be called`);
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
spawnChild.type = 'snapshot.spawnChild';
|
|
1205
|
+
spawnChild.id = id;
|
|
1206
|
+
spawnChild.systemId = systemId;
|
|
1207
|
+
spawnChild.src = src;
|
|
1208
|
+
spawnChild.input = input;
|
|
1209
|
+
spawnChild.syncSnapshot = syncSnapshot;
|
|
1210
|
+
spawnChild.resolve = resolveSpawn;
|
|
1211
|
+
spawnChild.execute = executeSpawn;
|
|
1212
|
+
return spawnChild;
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
function resolveStop(_, snapshot, args, actionParams, {
|
|
1216
|
+
actorRef
|
|
1217
|
+
}) {
|
|
1218
|
+
const actorRefOrString = typeof actorRef === 'function' ? actorRef(args, actionParams) : actorRef;
|
|
1219
|
+
const resolvedActorRef = typeof actorRefOrString === 'string' ? snapshot.children[actorRefOrString] : actorRefOrString;
|
|
1220
|
+
let children = snapshot.children;
|
|
1221
|
+
if (resolvedActorRef) {
|
|
1222
|
+
children = {
|
|
1223
|
+
...children
|
|
1224
|
+
};
|
|
1225
|
+
delete children[resolvedActorRef.id];
|
|
1226
|
+
}
|
|
1227
|
+
return [cloneMachineSnapshot(snapshot, {
|
|
1228
|
+
children
|
|
1229
|
+
}), resolvedActorRef];
|
|
1230
|
+
}
|
|
1231
|
+
function executeStop(actorScope, actorRef) {
|
|
1232
|
+
if (!actorRef) {
|
|
1233
|
+
return;
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
// we need to eagerly unregister it here so a new actor with the same systemId can be registered immediately
|
|
1237
|
+
// since we defer actual stopping of the actor but we don't defer actor creations (and we can't do that)
|
|
1238
|
+
// this could throw on `systemId` collision, for example, when dealing with reentering transitions
|
|
1239
|
+
actorScope.system._unregister(actorRef);
|
|
1240
|
+
|
|
1241
|
+
// this allows us to prevent an actor from being started if it gets stopped within the same macrostep
|
|
1242
|
+
// this can happen, for example, when the invoking state is being exited immediately by an always transition
|
|
1243
|
+
if (actorRef._processingStatus !== ProcessingStatus.Running) {
|
|
1244
|
+
actorScope.stopChild(actorRef);
|
|
1245
|
+
return;
|
|
1246
|
+
}
|
|
1247
|
+
// stopping a child enqueues a stop event in the child actor's mailbox
|
|
1248
|
+
// we need for all of the already enqueued events to be processed before we stop the child
|
|
1249
|
+
// the parent itself might want to send some events to a child (for example from exit actions on the invoking state)
|
|
1250
|
+
// and we don't want to ignore those events
|
|
1251
|
+
actorScope.defer(() => {
|
|
1252
|
+
actorScope.stopChild(actorRef);
|
|
1253
|
+
});
|
|
1254
|
+
}
|
|
1255
|
+
/**
|
|
1256
|
+
* Stops a child actor.
|
|
1257
|
+
*
|
|
1258
|
+
* @param actorRef The actor to stop.
|
|
1259
|
+
*/
|
|
1260
|
+
function stopChild(actorRef) {
|
|
1261
|
+
function stop(args, params) {
|
|
1262
|
+
{
|
|
1263
|
+
throw new Error(`This isn't supposed to be called`);
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
stop.type = 'xstate.stopChild';
|
|
1267
|
+
stop.actorRef = actorRef;
|
|
1268
|
+
stop.resolve = resolveStop;
|
|
1269
|
+
stop.execute = executeStop;
|
|
1270
|
+
return stop;
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
/**
|
|
1274
|
+
* Stops a child actor.
|
|
1275
|
+
*
|
|
1276
|
+
* @deprecated Use `stopChild(...)` instead
|
|
1277
|
+
* @alias
|
|
1278
|
+
*/
|
|
1279
|
+
const stop = stopChild;
|
|
1280
|
+
|
|
1142
1281
|
function checkStateIn(snapshot, _, {
|
|
1143
1282
|
stateValue
|
|
1144
1283
|
}) {
|
|
@@ -1335,211 +1474,6 @@ function evaluateGuard(guard, context, event, snapshot) {
|
|
|
1335
1474
|
);
|
|
1336
1475
|
}
|
|
1337
1476
|
|
|
1338
|
-
function resolveRaise(_, snapshot, args, actionParams, {
|
|
1339
|
-
event: eventOrExpr,
|
|
1340
|
-
id,
|
|
1341
|
-
delay
|
|
1342
|
-
}, {
|
|
1343
|
-
internalQueue
|
|
1344
|
-
}) {
|
|
1345
|
-
const delaysMap = snapshot.machine.implementations.delays;
|
|
1346
|
-
if (typeof eventOrExpr === 'string') {
|
|
1347
|
-
throw new Error(`Only event objects may be used with raise; use raise({ type: "${eventOrExpr}" }) instead`);
|
|
1348
|
-
}
|
|
1349
|
-
const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args, actionParams) : eventOrExpr;
|
|
1350
|
-
let resolvedDelay;
|
|
1351
|
-
if (typeof delay === 'string') {
|
|
1352
|
-
const configDelay = delaysMap && delaysMap[delay];
|
|
1353
|
-
resolvedDelay = typeof configDelay === 'function' ? configDelay(args, actionParams) : configDelay;
|
|
1354
|
-
} else {
|
|
1355
|
-
resolvedDelay = typeof delay === 'function' ? delay(args, actionParams) : delay;
|
|
1356
|
-
}
|
|
1357
|
-
if (typeof resolvedDelay !== 'number') {
|
|
1358
|
-
internalQueue.push(resolvedEvent);
|
|
1359
|
-
}
|
|
1360
|
-
return [snapshot, {
|
|
1361
|
-
event: resolvedEvent,
|
|
1362
|
-
id,
|
|
1363
|
-
delay: resolvedDelay
|
|
1364
|
-
}];
|
|
1365
|
-
}
|
|
1366
|
-
function executeRaise(actorScope, params) {
|
|
1367
|
-
const {
|
|
1368
|
-
event,
|
|
1369
|
-
delay,
|
|
1370
|
-
id
|
|
1371
|
-
} = params;
|
|
1372
|
-
if (typeof delay === 'number') {
|
|
1373
|
-
actorScope.defer(() => {
|
|
1374
|
-
const self = actorScope.self;
|
|
1375
|
-
actorScope.system.scheduler.schedule(self, self, event, delay, id);
|
|
1376
|
-
});
|
|
1377
|
-
return;
|
|
1378
|
-
}
|
|
1379
|
-
}
|
|
1380
|
-
/**
|
|
1381
|
-
* Raises an event. This places the event in the internal event queue, so that
|
|
1382
|
-
* the event is immediately consumed by the machine in the current step.
|
|
1383
|
-
*
|
|
1384
|
-
* @param eventType The event to raise.
|
|
1385
|
-
*/
|
|
1386
|
-
function raise(eventOrExpr, options) {
|
|
1387
|
-
if (exports.executingCustomAction) {
|
|
1388
|
-
console.warn('Custom actions should not call `raise()` directly, as it is not imperative. See https://stately.ai/docs/actions#built-in-actions for more details.');
|
|
1389
|
-
}
|
|
1390
|
-
function raise(args, params) {
|
|
1391
|
-
{
|
|
1392
|
-
throw new Error(`This isn't supposed to be called`);
|
|
1393
|
-
}
|
|
1394
|
-
}
|
|
1395
|
-
raise.type = 'xstate.raise';
|
|
1396
|
-
raise.event = eventOrExpr;
|
|
1397
|
-
raise.id = options?.id;
|
|
1398
|
-
raise.delay = options?.delay;
|
|
1399
|
-
raise.resolve = resolveRaise;
|
|
1400
|
-
raise.execute = executeRaise;
|
|
1401
|
-
return raise;
|
|
1402
|
-
}
|
|
1403
|
-
|
|
1404
|
-
function resolveSpawn(actorScope, snapshot, actionArgs, _actionParams, {
|
|
1405
|
-
id,
|
|
1406
|
-
systemId,
|
|
1407
|
-
src,
|
|
1408
|
-
input,
|
|
1409
|
-
syncSnapshot
|
|
1410
|
-
}) {
|
|
1411
|
-
const logic = typeof src === 'string' ? resolveReferencedActor(snapshot.machine, src) : src;
|
|
1412
|
-
const resolvedId = typeof id === 'function' ? id(actionArgs) : id;
|
|
1413
|
-
let actorRef;
|
|
1414
|
-
if (logic) {
|
|
1415
|
-
actorRef = createActor(logic, {
|
|
1416
|
-
id: resolvedId,
|
|
1417
|
-
src,
|
|
1418
|
-
parent: actorScope.self,
|
|
1419
|
-
syncSnapshot,
|
|
1420
|
-
systemId,
|
|
1421
|
-
input: typeof input === 'function' ? input({
|
|
1422
|
-
context: snapshot.context,
|
|
1423
|
-
event: actionArgs.event,
|
|
1424
|
-
self: actorScope.self
|
|
1425
|
-
}) : input
|
|
1426
|
-
});
|
|
1427
|
-
}
|
|
1428
|
-
if (!actorRef) {
|
|
1429
|
-
console.warn(`Actor type '${src}' not found in machine '${actorScope.id}'.`);
|
|
1430
|
-
}
|
|
1431
|
-
return [cloneMachineSnapshot(snapshot, {
|
|
1432
|
-
children: {
|
|
1433
|
-
...snapshot.children,
|
|
1434
|
-
[resolvedId]: actorRef
|
|
1435
|
-
}
|
|
1436
|
-
}), {
|
|
1437
|
-
id,
|
|
1438
|
-
actorRef
|
|
1439
|
-
}];
|
|
1440
|
-
}
|
|
1441
|
-
function executeSpawn(actorScope, {
|
|
1442
|
-
id,
|
|
1443
|
-
actorRef
|
|
1444
|
-
}) {
|
|
1445
|
-
if (!actorRef) {
|
|
1446
|
-
return;
|
|
1447
|
-
}
|
|
1448
|
-
actorScope.defer(() => {
|
|
1449
|
-
if (actorRef._processingStatus === ProcessingStatus.Stopped) {
|
|
1450
|
-
return;
|
|
1451
|
-
}
|
|
1452
|
-
actorRef.start();
|
|
1453
|
-
});
|
|
1454
|
-
}
|
|
1455
|
-
function spawnChild(...[src, {
|
|
1456
|
-
id,
|
|
1457
|
-
systemId,
|
|
1458
|
-
input,
|
|
1459
|
-
syncSnapshot = false
|
|
1460
|
-
} = {}]) {
|
|
1461
|
-
function spawnChild(args, params) {
|
|
1462
|
-
{
|
|
1463
|
-
throw new Error(`This isn't supposed to be called`);
|
|
1464
|
-
}
|
|
1465
|
-
}
|
|
1466
|
-
spawnChild.type = 'snapshot.spawnChild';
|
|
1467
|
-
spawnChild.id = id;
|
|
1468
|
-
spawnChild.systemId = systemId;
|
|
1469
|
-
spawnChild.src = src;
|
|
1470
|
-
spawnChild.input = input;
|
|
1471
|
-
spawnChild.syncSnapshot = syncSnapshot;
|
|
1472
|
-
spawnChild.resolve = resolveSpawn;
|
|
1473
|
-
spawnChild.execute = executeSpawn;
|
|
1474
|
-
return spawnChild;
|
|
1475
|
-
}
|
|
1476
|
-
|
|
1477
|
-
function resolveStop(_, snapshot, args, actionParams, {
|
|
1478
|
-
actorRef
|
|
1479
|
-
}) {
|
|
1480
|
-
const actorRefOrString = typeof actorRef === 'function' ? actorRef(args, actionParams) : actorRef;
|
|
1481
|
-
const resolvedActorRef = typeof actorRefOrString === 'string' ? snapshot.children[actorRefOrString] : actorRefOrString;
|
|
1482
|
-
let children = snapshot.children;
|
|
1483
|
-
if (resolvedActorRef) {
|
|
1484
|
-
children = {
|
|
1485
|
-
...children
|
|
1486
|
-
};
|
|
1487
|
-
delete children[resolvedActorRef.id];
|
|
1488
|
-
}
|
|
1489
|
-
return [cloneMachineSnapshot(snapshot, {
|
|
1490
|
-
children
|
|
1491
|
-
}), resolvedActorRef];
|
|
1492
|
-
}
|
|
1493
|
-
function executeStop(actorScope, actorRef) {
|
|
1494
|
-
if (!actorRef) {
|
|
1495
|
-
return;
|
|
1496
|
-
}
|
|
1497
|
-
|
|
1498
|
-
// we need to eagerly unregister it here so a new actor with the same systemId can be registered immediately
|
|
1499
|
-
// since we defer actual stopping of the actor but we don't defer actor creations (and we can't do that)
|
|
1500
|
-
// this could throw on `systemId` collision, for example, when dealing with reentering transitions
|
|
1501
|
-
actorScope.system._unregister(actorRef);
|
|
1502
|
-
|
|
1503
|
-
// this allows us to prevent an actor from being started if it gets stopped within the same macrostep
|
|
1504
|
-
// this can happen, for example, when the invoking state is being exited immediately by an always transition
|
|
1505
|
-
if (actorRef._processingStatus !== ProcessingStatus.Running) {
|
|
1506
|
-
actorScope.stopChild(actorRef);
|
|
1507
|
-
return;
|
|
1508
|
-
}
|
|
1509
|
-
// stopping a child enqueues a stop event in the child actor's mailbox
|
|
1510
|
-
// we need for all of the already enqueued events to be processed before we stop the child
|
|
1511
|
-
// the parent itself might want to send some events to a child (for example from exit actions on the invoking state)
|
|
1512
|
-
// and we don't want to ignore those events
|
|
1513
|
-
actorScope.defer(() => {
|
|
1514
|
-
actorScope.stopChild(actorRef);
|
|
1515
|
-
});
|
|
1516
|
-
}
|
|
1517
|
-
/**
|
|
1518
|
-
* Stops a child actor.
|
|
1519
|
-
*
|
|
1520
|
-
* @param actorRef The actor to stop.
|
|
1521
|
-
*/
|
|
1522
|
-
function stopChild(actorRef) {
|
|
1523
|
-
function stop(args, params) {
|
|
1524
|
-
{
|
|
1525
|
-
throw new Error(`This isn't supposed to be called`);
|
|
1526
|
-
}
|
|
1527
|
-
}
|
|
1528
|
-
stop.type = 'xstate.stopChild';
|
|
1529
|
-
stop.actorRef = actorRef;
|
|
1530
|
-
stop.resolve = resolveStop;
|
|
1531
|
-
stop.execute = executeStop;
|
|
1532
|
-
return stop;
|
|
1533
|
-
}
|
|
1534
|
-
|
|
1535
|
-
/**
|
|
1536
|
-
* Stops a child actor.
|
|
1537
|
-
*
|
|
1538
|
-
* @deprecated Use `stopChild(...)` instead
|
|
1539
|
-
* @alias
|
|
1540
|
-
*/
|
|
1541
|
-
const stop = stopChild;
|
|
1542
|
-
|
|
1543
1477
|
const isAtomicStateNode = stateNode => stateNode.type === 'atomic' || stateNode.type === 'final';
|
|
1544
1478
|
function getChildren(stateNode) {
|
|
1545
1479
|
return Object.values(stateNode.states).filter(sn => sn.type !== 'history');
|
|
@@ -2664,6 +2598,72 @@ function persistContext(contextPart) {
|
|
|
2664
2598
|
return copy ?? contextPart;
|
|
2665
2599
|
}
|
|
2666
2600
|
|
|
2601
|
+
function resolveRaise(_, snapshot, args, actionParams, {
|
|
2602
|
+
event: eventOrExpr,
|
|
2603
|
+
id,
|
|
2604
|
+
delay
|
|
2605
|
+
}, {
|
|
2606
|
+
internalQueue
|
|
2607
|
+
}) {
|
|
2608
|
+
const delaysMap = snapshot.machine.implementations.delays;
|
|
2609
|
+
if (typeof eventOrExpr === 'string') {
|
|
2610
|
+
throw new Error(`Only event objects may be used with raise; use raise({ type: "${eventOrExpr}" }) instead`);
|
|
2611
|
+
}
|
|
2612
|
+
const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args, actionParams) : eventOrExpr;
|
|
2613
|
+
let resolvedDelay;
|
|
2614
|
+
if (typeof delay === 'string') {
|
|
2615
|
+
const configDelay = delaysMap && delaysMap[delay];
|
|
2616
|
+
resolvedDelay = typeof configDelay === 'function' ? configDelay(args, actionParams) : configDelay;
|
|
2617
|
+
} else {
|
|
2618
|
+
resolvedDelay = typeof delay === 'function' ? delay(args, actionParams) : delay;
|
|
2619
|
+
}
|
|
2620
|
+
if (typeof resolvedDelay !== 'number') {
|
|
2621
|
+
internalQueue.push(resolvedEvent);
|
|
2622
|
+
}
|
|
2623
|
+
return [snapshot, {
|
|
2624
|
+
event: resolvedEvent,
|
|
2625
|
+
id,
|
|
2626
|
+
delay: resolvedDelay
|
|
2627
|
+
}];
|
|
2628
|
+
}
|
|
2629
|
+
function executeRaise(actorScope, params) {
|
|
2630
|
+
const {
|
|
2631
|
+
event,
|
|
2632
|
+
delay,
|
|
2633
|
+
id
|
|
2634
|
+
} = params;
|
|
2635
|
+
if (typeof delay === 'number') {
|
|
2636
|
+
actorScope.defer(() => {
|
|
2637
|
+
const self = actorScope.self;
|
|
2638
|
+
actorScope.system.scheduler.schedule(self, self, event, delay, id);
|
|
2639
|
+
});
|
|
2640
|
+
return;
|
|
2641
|
+
}
|
|
2642
|
+
}
|
|
2643
|
+
/**
|
|
2644
|
+
* Raises an event. This places the event in the internal event queue, so that
|
|
2645
|
+
* the event is immediately consumed by the machine in the current step.
|
|
2646
|
+
*
|
|
2647
|
+
* @param eventType The event to raise.
|
|
2648
|
+
*/
|
|
2649
|
+
function raise(eventOrExpr, options) {
|
|
2650
|
+
if (exports.executingCustomAction) {
|
|
2651
|
+
console.warn('Custom actions should not call `raise()` directly, as it is not imperative. See https://stately.ai/docs/actions#built-in-actions for more details.');
|
|
2652
|
+
}
|
|
2653
|
+
function raise(args, params) {
|
|
2654
|
+
{
|
|
2655
|
+
throw new Error(`This isn't supposed to be called`);
|
|
2656
|
+
}
|
|
2657
|
+
}
|
|
2658
|
+
raise.type = 'xstate.raise';
|
|
2659
|
+
raise.event = eventOrExpr;
|
|
2660
|
+
raise.id = options?.id;
|
|
2661
|
+
raise.delay = options?.delay;
|
|
2662
|
+
raise.resolve = resolveRaise;
|
|
2663
|
+
raise.execute = executeRaise;
|
|
2664
|
+
return raise;
|
|
2665
|
+
}
|
|
2666
|
+
|
|
2667
2667
|
exports.$$ACTOR_TYPE = $$ACTOR_TYPE;
|
|
2668
2668
|
exports.Actor = Actor;
|
|
2669
2669
|
exports.NULL_EVENT = NULL_EVENT;
|