xstate 5.15.0 → 5.17.0
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/dist/{raise-a6298350.cjs.js → State-30c95050.cjs.js} +199 -191
- package/dist/{raise-7d030497.development.esm.js → State-34039d2a.development.esm.js} +215 -207
- package/dist/{raise-bad6a97b.development.cjs.js → State-a2464a1e.development.cjs.js} +214 -206
- package/dist/{raise-2cfe6b8f.esm.js → State-cdbc7940.esm.js} +200 -192
- package/dist/declarations/src/State.d.ts +9 -9
- package/dist/declarations/src/StateMachine.d.ts +11 -13
- package/dist/declarations/src/actions/enqueueActions.d.ts +3 -2
- package/dist/declarations/src/actions/stopChild.d.ts +1 -0
- package/dist/declarations/src/actors/callback.d.ts +3 -2
- package/dist/declarations/src/createActor.d.ts +6 -6
- package/dist/declarations/src/index.d.ts +11 -12
- package/dist/declarations/src/inspection.d.ts +3 -2
- package/dist/declarations/src/setup.d.ts +1 -1
- package/dist/declarations/src/stateUtils.d.ts +1 -13
- package/dist/declarations/src/system.d.ts +3 -2
- package/dist/declarations/src/types.d.ts +9 -2
- package/dist/declarations/src/utils.d.ts +1 -5
- package/dist/{log-b8c93ee3.cjs.js → log-19086852.cjs.js} +4 -1
- package/dist/{log-63de2429.esm.js → log-4a38a98a.esm.js} +4 -1
- package/dist/{log-e9953143.development.esm.js → log-62f17756.development.esm.js} +4 -1
- package/dist/{log-d2c282d6.development.cjs.js → log-ec36113c.development.cjs.js} +4 -1
- package/dist/xstate.cjs.js +92 -92
- package/dist/xstate.development.cjs.js +95 -95
- package/dist/xstate.development.esm.js +91 -91
- package/dist/xstate.esm.js +88 -88
- 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 -3
|
@@ -321,7 +321,9 @@ function createSystem(rootActor, options) {
|
|
|
321
321
|
const timeout = timerMap[scheduledEventId];
|
|
322
322
|
delete timerMap[scheduledEventId];
|
|
323
323
|
delete system._snapshot._scheduledEvents[scheduledEventId];
|
|
324
|
-
|
|
324
|
+
if (timeout !== undefined) {
|
|
325
|
+
clock.clearTimeout(timeout);
|
|
326
|
+
}
|
|
325
327
|
},
|
|
326
328
|
cancelAll: actorRef => {
|
|
327
329
|
for (const scheduledEventId in system._snapshot._scheduledEvents) {
|
|
@@ -418,6 +420,7 @@ function createSystem(rootActor, options) {
|
|
|
418
420
|
}
|
|
419
421
|
|
|
420
422
|
const $$ACTOR_TYPE = 1;
|
|
423
|
+
|
|
421
424
|
// those values are currently used by @xstate/react directly so it's important to keep the assigned values in sync
|
|
422
425
|
let ProcessingStatus = /*#__PURE__*/function (ProcessingStatus) {
|
|
423
426
|
ProcessingStatus[ProcessingStatus["NotStarted"] = 0] = "NotStarted";
|
|
@@ -1055,10 +1058,14 @@ function createActor(logic, ...[options]) {
|
|
|
1055
1058
|
* options, if any.
|
|
1056
1059
|
*
|
|
1057
1060
|
* @deprecated Use `createActor` instead
|
|
1061
|
+
* @alias
|
|
1058
1062
|
*/
|
|
1059
1063
|
const interpret = createActor;
|
|
1060
1064
|
|
|
1061
|
-
/**
|
|
1065
|
+
/**
|
|
1066
|
+
* @deprecated Use `Actor` instead.
|
|
1067
|
+
* @alias
|
|
1068
|
+
*/
|
|
1062
1069
|
|
|
1063
1070
|
function resolveCancel(_, snapshot, actionArgs, actionParams, {
|
|
1064
1071
|
sendId
|
|
@@ -1113,135 +1120,6 @@ function cancel(sendId) {
|
|
|
1113
1120
|
return cancel;
|
|
1114
1121
|
}
|
|
1115
1122
|
|
|
1116
|
-
function resolveSpawn(actorScope, snapshot, actionArgs, _actionParams, {
|
|
1117
|
-
id,
|
|
1118
|
-
systemId,
|
|
1119
|
-
src,
|
|
1120
|
-
input,
|
|
1121
|
-
syncSnapshot
|
|
1122
|
-
}) {
|
|
1123
|
-
const logic = typeof src === 'string' ? resolveReferencedActor(snapshot.machine, src) : src;
|
|
1124
|
-
const resolvedId = typeof id === 'function' ? id(actionArgs) : id;
|
|
1125
|
-
let actorRef;
|
|
1126
|
-
if (logic) {
|
|
1127
|
-
actorRef = createActor(logic, {
|
|
1128
|
-
id: resolvedId,
|
|
1129
|
-
src,
|
|
1130
|
-
parent: actorScope.self,
|
|
1131
|
-
syncSnapshot,
|
|
1132
|
-
systemId,
|
|
1133
|
-
input: typeof input === 'function' ? input({
|
|
1134
|
-
context: snapshot.context,
|
|
1135
|
-
event: actionArgs.event,
|
|
1136
|
-
self: actorScope.self
|
|
1137
|
-
}) : input
|
|
1138
|
-
});
|
|
1139
|
-
}
|
|
1140
|
-
return [cloneMachineSnapshot(snapshot, {
|
|
1141
|
-
children: {
|
|
1142
|
-
...snapshot.children,
|
|
1143
|
-
[resolvedId]: actorRef
|
|
1144
|
-
}
|
|
1145
|
-
}), {
|
|
1146
|
-
id,
|
|
1147
|
-
actorRef
|
|
1148
|
-
}];
|
|
1149
|
-
}
|
|
1150
|
-
function executeSpawn(actorScope, {
|
|
1151
|
-
id,
|
|
1152
|
-
actorRef
|
|
1153
|
-
}) {
|
|
1154
|
-
if (!actorRef) {
|
|
1155
|
-
return;
|
|
1156
|
-
}
|
|
1157
|
-
actorScope.defer(() => {
|
|
1158
|
-
if (actorRef._processingStatus === ProcessingStatus.Stopped) {
|
|
1159
|
-
return;
|
|
1160
|
-
}
|
|
1161
|
-
actorRef.start();
|
|
1162
|
-
});
|
|
1163
|
-
}
|
|
1164
|
-
function spawnChild(...[src, {
|
|
1165
|
-
id,
|
|
1166
|
-
systemId,
|
|
1167
|
-
input,
|
|
1168
|
-
syncSnapshot = false
|
|
1169
|
-
} = {}]) {
|
|
1170
|
-
function spawnChild(args, params) {
|
|
1171
|
-
}
|
|
1172
|
-
spawnChild.type = 'snapshot.spawnChild';
|
|
1173
|
-
spawnChild.id = id;
|
|
1174
|
-
spawnChild.systemId = systemId;
|
|
1175
|
-
spawnChild.src = src;
|
|
1176
|
-
spawnChild.input = input;
|
|
1177
|
-
spawnChild.syncSnapshot = syncSnapshot;
|
|
1178
|
-
spawnChild.resolve = resolveSpawn;
|
|
1179
|
-
spawnChild.execute = executeSpawn;
|
|
1180
|
-
return spawnChild;
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
function resolveStop(_, snapshot, args, actionParams, {
|
|
1184
|
-
actorRef
|
|
1185
|
-
}) {
|
|
1186
|
-
const actorRefOrString = typeof actorRef === 'function' ? actorRef(args, actionParams) : actorRef;
|
|
1187
|
-
const resolvedActorRef = typeof actorRefOrString === 'string' ? snapshot.children[actorRefOrString] : actorRefOrString;
|
|
1188
|
-
let children = snapshot.children;
|
|
1189
|
-
if (resolvedActorRef) {
|
|
1190
|
-
children = {
|
|
1191
|
-
...children
|
|
1192
|
-
};
|
|
1193
|
-
delete children[resolvedActorRef.id];
|
|
1194
|
-
}
|
|
1195
|
-
return [cloneMachineSnapshot(snapshot, {
|
|
1196
|
-
children
|
|
1197
|
-
}), resolvedActorRef];
|
|
1198
|
-
}
|
|
1199
|
-
function executeStop(actorScope, actorRef) {
|
|
1200
|
-
if (!actorRef) {
|
|
1201
|
-
return;
|
|
1202
|
-
}
|
|
1203
|
-
|
|
1204
|
-
// we need to eagerly unregister it here so a new actor with the same systemId can be registered immediately
|
|
1205
|
-
// since we defer actual stopping of the actor but we don't defer actor creations (and we can't do that)
|
|
1206
|
-
// this could throw on `systemId` collision, for example, when dealing with reentering transitions
|
|
1207
|
-
actorScope.system._unregister(actorRef);
|
|
1208
|
-
|
|
1209
|
-
// this allows us to prevent an actor from being started if it gets stopped within the same macrostep
|
|
1210
|
-
// this can happen, for example, when the invoking state is being exited immediately by an always transition
|
|
1211
|
-
if (actorRef._processingStatus !== ProcessingStatus.Running) {
|
|
1212
|
-
actorScope.stopChild(actorRef);
|
|
1213
|
-
return;
|
|
1214
|
-
}
|
|
1215
|
-
// stopping a child enqueues a stop event in the child actor's mailbox
|
|
1216
|
-
// we need for all of the already enqueued events to be processed before we stop the child
|
|
1217
|
-
// the parent itself might want to send some events to a child (for example from exit actions on the invoking state)
|
|
1218
|
-
// and we don't want to ignore those events
|
|
1219
|
-
actorScope.defer(() => {
|
|
1220
|
-
actorScope.stopChild(actorRef);
|
|
1221
|
-
});
|
|
1222
|
-
}
|
|
1223
|
-
/**
|
|
1224
|
-
* Stops a child actor.
|
|
1225
|
-
*
|
|
1226
|
-
* @param actorRef The actor to stop.
|
|
1227
|
-
*/
|
|
1228
|
-
function stopChild(actorRef) {
|
|
1229
|
-
function stop(args, params) {
|
|
1230
|
-
}
|
|
1231
|
-
stop.type = 'xstate.stopChild';
|
|
1232
|
-
stop.actorRef = actorRef;
|
|
1233
|
-
stop.resolve = resolveStop;
|
|
1234
|
-
stop.execute = executeStop;
|
|
1235
|
-
return stop;
|
|
1236
|
-
}
|
|
1237
|
-
|
|
1238
|
-
/**
|
|
1239
|
-
* Stops a child actor.
|
|
1240
|
-
*
|
|
1241
|
-
* @deprecated Use `stopChild(...)` instead
|
|
1242
|
-
*/
|
|
1243
|
-
const stop = stopChild;
|
|
1244
|
-
|
|
1245
1123
|
function checkStateIn(snapshot, _, {
|
|
1246
1124
|
stateValue
|
|
1247
1125
|
}) {
|
|
@@ -1430,6 +1308,196 @@ function evaluateGuard(guard, context, event, snapshot) {
|
|
|
1430
1308
|
);
|
|
1431
1309
|
}
|
|
1432
1310
|
|
|
1311
|
+
function resolveRaise(_, snapshot, args, actionParams, {
|
|
1312
|
+
event: eventOrExpr,
|
|
1313
|
+
id,
|
|
1314
|
+
delay
|
|
1315
|
+
}, {
|
|
1316
|
+
internalQueue
|
|
1317
|
+
}) {
|
|
1318
|
+
const delaysMap = snapshot.machine.implementations.delays;
|
|
1319
|
+
if (typeof eventOrExpr === 'string') {
|
|
1320
|
+
throw new Error(`Only event objects may be used with raise; use raise({ type: "${eventOrExpr}" }) instead`);
|
|
1321
|
+
}
|
|
1322
|
+
const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args, actionParams) : eventOrExpr;
|
|
1323
|
+
let resolvedDelay;
|
|
1324
|
+
if (typeof delay === 'string') {
|
|
1325
|
+
const configDelay = delaysMap && delaysMap[delay];
|
|
1326
|
+
resolvedDelay = typeof configDelay === 'function' ? configDelay(args, actionParams) : configDelay;
|
|
1327
|
+
} else {
|
|
1328
|
+
resolvedDelay = typeof delay === 'function' ? delay(args, actionParams) : delay;
|
|
1329
|
+
}
|
|
1330
|
+
if (typeof resolvedDelay !== 'number') {
|
|
1331
|
+
internalQueue.push(resolvedEvent);
|
|
1332
|
+
}
|
|
1333
|
+
return [snapshot, {
|
|
1334
|
+
event: resolvedEvent,
|
|
1335
|
+
id,
|
|
1336
|
+
delay: resolvedDelay
|
|
1337
|
+
}];
|
|
1338
|
+
}
|
|
1339
|
+
function executeRaise(actorScope, params) {
|
|
1340
|
+
const {
|
|
1341
|
+
event,
|
|
1342
|
+
delay,
|
|
1343
|
+
id
|
|
1344
|
+
} = params;
|
|
1345
|
+
if (typeof delay === 'number') {
|
|
1346
|
+
actorScope.defer(() => {
|
|
1347
|
+
const self = actorScope.self;
|
|
1348
|
+
actorScope.system.scheduler.schedule(self, self, event, delay, id);
|
|
1349
|
+
});
|
|
1350
|
+
return;
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
/**
|
|
1354
|
+
* Raises an event. This places the event in the internal event queue, so that
|
|
1355
|
+
* the event is immediately consumed by the machine in the current step.
|
|
1356
|
+
*
|
|
1357
|
+
* @param eventType The event to raise.
|
|
1358
|
+
*/
|
|
1359
|
+
function raise(eventOrExpr, options) {
|
|
1360
|
+
function raise(args, params) {
|
|
1361
|
+
}
|
|
1362
|
+
raise.type = 'xstate.raise';
|
|
1363
|
+
raise.event = eventOrExpr;
|
|
1364
|
+
raise.id = options?.id;
|
|
1365
|
+
raise.delay = options?.delay;
|
|
1366
|
+
raise.resolve = resolveRaise;
|
|
1367
|
+
raise.execute = executeRaise;
|
|
1368
|
+
return raise;
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
function resolveSpawn(actorScope, snapshot, actionArgs, _actionParams, {
|
|
1372
|
+
id,
|
|
1373
|
+
systemId,
|
|
1374
|
+
src,
|
|
1375
|
+
input,
|
|
1376
|
+
syncSnapshot
|
|
1377
|
+
}) {
|
|
1378
|
+
const logic = typeof src === 'string' ? resolveReferencedActor(snapshot.machine, src) : src;
|
|
1379
|
+
const resolvedId = typeof id === 'function' ? id(actionArgs) : id;
|
|
1380
|
+
let actorRef;
|
|
1381
|
+
if (logic) {
|
|
1382
|
+
actorRef = createActor(logic, {
|
|
1383
|
+
id: resolvedId,
|
|
1384
|
+
src,
|
|
1385
|
+
parent: actorScope.self,
|
|
1386
|
+
syncSnapshot,
|
|
1387
|
+
systemId,
|
|
1388
|
+
input: typeof input === 'function' ? input({
|
|
1389
|
+
context: snapshot.context,
|
|
1390
|
+
event: actionArgs.event,
|
|
1391
|
+
self: actorScope.self
|
|
1392
|
+
}) : input
|
|
1393
|
+
});
|
|
1394
|
+
}
|
|
1395
|
+
return [cloneMachineSnapshot(snapshot, {
|
|
1396
|
+
children: {
|
|
1397
|
+
...snapshot.children,
|
|
1398
|
+
[resolvedId]: actorRef
|
|
1399
|
+
}
|
|
1400
|
+
}), {
|
|
1401
|
+
id,
|
|
1402
|
+
actorRef
|
|
1403
|
+
}];
|
|
1404
|
+
}
|
|
1405
|
+
function executeSpawn(actorScope, {
|
|
1406
|
+
id,
|
|
1407
|
+
actorRef
|
|
1408
|
+
}) {
|
|
1409
|
+
if (!actorRef) {
|
|
1410
|
+
return;
|
|
1411
|
+
}
|
|
1412
|
+
actorScope.defer(() => {
|
|
1413
|
+
if (actorRef._processingStatus === ProcessingStatus.Stopped) {
|
|
1414
|
+
return;
|
|
1415
|
+
}
|
|
1416
|
+
actorRef.start();
|
|
1417
|
+
});
|
|
1418
|
+
}
|
|
1419
|
+
function spawnChild(...[src, {
|
|
1420
|
+
id,
|
|
1421
|
+
systemId,
|
|
1422
|
+
input,
|
|
1423
|
+
syncSnapshot = false
|
|
1424
|
+
} = {}]) {
|
|
1425
|
+
function spawnChild(args, params) {
|
|
1426
|
+
}
|
|
1427
|
+
spawnChild.type = 'snapshot.spawnChild';
|
|
1428
|
+
spawnChild.id = id;
|
|
1429
|
+
spawnChild.systemId = systemId;
|
|
1430
|
+
spawnChild.src = src;
|
|
1431
|
+
spawnChild.input = input;
|
|
1432
|
+
spawnChild.syncSnapshot = syncSnapshot;
|
|
1433
|
+
spawnChild.resolve = resolveSpawn;
|
|
1434
|
+
spawnChild.execute = executeSpawn;
|
|
1435
|
+
return spawnChild;
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
function resolveStop(_, snapshot, args, actionParams, {
|
|
1439
|
+
actorRef
|
|
1440
|
+
}) {
|
|
1441
|
+
const actorRefOrString = typeof actorRef === 'function' ? actorRef(args, actionParams) : actorRef;
|
|
1442
|
+
const resolvedActorRef = typeof actorRefOrString === 'string' ? snapshot.children[actorRefOrString] : actorRefOrString;
|
|
1443
|
+
let children = snapshot.children;
|
|
1444
|
+
if (resolvedActorRef) {
|
|
1445
|
+
children = {
|
|
1446
|
+
...children
|
|
1447
|
+
};
|
|
1448
|
+
delete children[resolvedActorRef.id];
|
|
1449
|
+
}
|
|
1450
|
+
return [cloneMachineSnapshot(snapshot, {
|
|
1451
|
+
children
|
|
1452
|
+
}), resolvedActorRef];
|
|
1453
|
+
}
|
|
1454
|
+
function executeStop(actorScope, actorRef) {
|
|
1455
|
+
if (!actorRef) {
|
|
1456
|
+
return;
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
// we need to eagerly unregister it here so a new actor with the same systemId can be registered immediately
|
|
1460
|
+
// since we defer actual stopping of the actor but we don't defer actor creations (and we can't do that)
|
|
1461
|
+
// this could throw on `systemId` collision, for example, when dealing with reentering transitions
|
|
1462
|
+
actorScope.system._unregister(actorRef);
|
|
1463
|
+
|
|
1464
|
+
// this allows us to prevent an actor from being started if it gets stopped within the same macrostep
|
|
1465
|
+
// this can happen, for example, when the invoking state is being exited immediately by an always transition
|
|
1466
|
+
if (actorRef._processingStatus !== ProcessingStatus.Running) {
|
|
1467
|
+
actorScope.stopChild(actorRef);
|
|
1468
|
+
return;
|
|
1469
|
+
}
|
|
1470
|
+
// stopping a child enqueues a stop event in the child actor's mailbox
|
|
1471
|
+
// we need for all of the already enqueued events to be processed before we stop the child
|
|
1472
|
+
// the parent itself might want to send some events to a child (for example from exit actions on the invoking state)
|
|
1473
|
+
// and we don't want to ignore those events
|
|
1474
|
+
actorScope.defer(() => {
|
|
1475
|
+
actorScope.stopChild(actorRef);
|
|
1476
|
+
});
|
|
1477
|
+
}
|
|
1478
|
+
/**
|
|
1479
|
+
* Stops a child actor.
|
|
1480
|
+
*
|
|
1481
|
+
* @param actorRef The actor to stop.
|
|
1482
|
+
*/
|
|
1483
|
+
function stopChild(actorRef) {
|
|
1484
|
+
function stop(args, params) {
|
|
1485
|
+
}
|
|
1486
|
+
stop.type = 'xstate.stopChild';
|
|
1487
|
+
stop.actorRef = actorRef;
|
|
1488
|
+
stop.resolve = resolveStop;
|
|
1489
|
+
stop.execute = executeStop;
|
|
1490
|
+
return stop;
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
/**
|
|
1494
|
+
* Stops a child actor.
|
|
1495
|
+
*
|
|
1496
|
+
* @deprecated Use `stopChild(...)` instead
|
|
1497
|
+
* @alias
|
|
1498
|
+
*/
|
|
1499
|
+
const stop = stopChild;
|
|
1500
|
+
|
|
1433
1501
|
const isAtomicStateNode = stateNode => stateNode.type === 'atomic' || stateNode.type === 'final';
|
|
1434
1502
|
function getChildren(stateNode) {
|
|
1435
1503
|
return Object.values(stateNode.states).filter(sn => sn.type !== 'history');
|
|
@@ -2534,64 +2602,4 @@ function persistContext(contextPart) {
|
|
|
2534
2602
|
return copy ?? contextPart;
|
|
2535
2603
|
}
|
|
2536
2604
|
|
|
2537
|
-
|
|
2538
|
-
event: eventOrExpr,
|
|
2539
|
-
id,
|
|
2540
|
-
delay
|
|
2541
|
-
}, {
|
|
2542
|
-
internalQueue
|
|
2543
|
-
}) {
|
|
2544
|
-
const delaysMap = snapshot.machine.implementations.delays;
|
|
2545
|
-
if (typeof eventOrExpr === 'string') {
|
|
2546
|
-
throw new Error(`Only event objects may be used with raise; use raise({ type: "${eventOrExpr}" }) instead`);
|
|
2547
|
-
}
|
|
2548
|
-
const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args, actionParams) : eventOrExpr;
|
|
2549
|
-
let resolvedDelay;
|
|
2550
|
-
if (typeof delay === 'string') {
|
|
2551
|
-
const configDelay = delaysMap && delaysMap[delay];
|
|
2552
|
-
resolvedDelay = typeof configDelay === 'function' ? configDelay(args, actionParams) : configDelay;
|
|
2553
|
-
} else {
|
|
2554
|
-
resolvedDelay = typeof delay === 'function' ? delay(args, actionParams) : delay;
|
|
2555
|
-
}
|
|
2556
|
-
if (typeof resolvedDelay !== 'number') {
|
|
2557
|
-
internalQueue.push(resolvedEvent);
|
|
2558
|
-
}
|
|
2559
|
-
return [snapshot, {
|
|
2560
|
-
event: resolvedEvent,
|
|
2561
|
-
id,
|
|
2562
|
-
delay: resolvedDelay
|
|
2563
|
-
}];
|
|
2564
|
-
}
|
|
2565
|
-
function executeRaise(actorScope, params) {
|
|
2566
|
-
const {
|
|
2567
|
-
event,
|
|
2568
|
-
delay,
|
|
2569
|
-
id
|
|
2570
|
-
} = params;
|
|
2571
|
-
if (typeof delay === 'number') {
|
|
2572
|
-
actorScope.defer(() => {
|
|
2573
|
-
const self = actorScope.self;
|
|
2574
|
-
actorScope.system.scheduler.schedule(self, self, event, delay, id);
|
|
2575
|
-
});
|
|
2576
|
-
return;
|
|
2577
|
-
}
|
|
2578
|
-
}
|
|
2579
|
-
/**
|
|
2580
|
-
* Raises an event. This places the event in the internal event queue, so that
|
|
2581
|
-
* the event is immediately consumed by the machine in the current step.
|
|
2582
|
-
*
|
|
2583
|
-
* @param eventType The event to raise.
|
|
2584
|
-
*/
|
|
2585
|
-
function raise(eventOrExpr, options) {
|
|
2586
|
-
function raise(args, params) {
|
|
2587
|
-
}
|
|
2588
|
-
raise.type = 'xstate.raise';
|
|
2589
|
-
raise.event = eventOrExpr;
|
|
2590
|
-
raise.id = options?.id;
|
|
2591
|
-
raise.delay = options?.delay;
|
|
2592
|
-
raise.resolve = resolveRaise;
|
|
2593
|
-
raise.execute = executeRaise;
|
|
2594
|
-
return raise;
|
|
2595
|
-
}
|
|
2596
|
-
|
|
2597
|
-
export { $$ACTOR_TYPE as $, createActor as A, Actor as B, interpret as C, isMachineSnapshot as D, and as E, not as F, or as G, stateIn as H, getAllOwnEventDescriptors as I, matchesState as J, pathToStateValue as K, toObserver as L, cancel as M, NULL_EVENT as N, raise as O, spawnChild as P, stop as Q, stopChild as R, STATE_DELIMITER as S, ProcessingStatus as T, cloneMachineSnapshot as U, XSTATE_ERROR as V, createErrorActorEvent as W, XSTATE_STOP as X, toTransitionConfigArray as a, formatTransition as b, createInvokeId as c, formatInitialTransition as d, evaluateGuard as e, formatTransitions as f, getDelayedTransitions as g, getCandidates as h, getAllStateNodes as i, getStateNodes as j, createMachineSnapshot as k, isInFinalState as l, mapValues as m, macrostep as n, transitionNode as o, resolveActionsAndContext as p, createInitEvent as q, resolveStateValue as r, microstep as s, toArray as t, getInitialStateNodes as u, toStatePath as v, isStateId as w, getStateNodeByPath as x, getPersistedSnapshot as y, resolveReferencedActor as z };
|
|
2605
|
+
export { $$ACTOR_TYPE as $, createActor as A, isMachineSnapshot as B, Actor as C, interpret as D, and as E, not as F, or as G, stateIn as H, getAllOwnEventDescriptors as I, matchesState as J, pathToStateValue as K, toObserver as L, cancel as M, NULL_EVENT as N, raise as O, spawnChild as P, stop as Q, stopChild as R, STATE_DELIMITER as S, ProcessingStatus as T, cloneMachineSnapshot as U, XSTATE_ERROR as V, createErrorActorEvent as W, XSTATE_STOP as X, toTransitionConfigArray as a, formatTransition as b, createInvokeId as c, formatInitialTransition as d, evaluateGuard as e, formatTransitions as f, getDelayedTransitions as g, getCandidates as h, getAllStateNodes as i, getStateNodes as j, createMachineSnapshot as k, isInFinalState as l, mapValues as m, macrostep as n, transitionNode as o, resolveActionsAndContext as p, createInitEvent as q, resolveStateValue as r, microstep as s, toArray as t, getInitialStateNodes as u, toStatePath as v, isStateId as w, getStateNodeByPath as x, getPersistedSnapshot as y, resolveReferencedActor as z };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { StateNode } from "./StateNode.js";
|
|
2
2
|
import type { StateMachine } from "./StateMachine.js";
|
|
3
|
-
import type { ProvidedActor, AnyMachineSnapshot, AnyStateMachine, EventObject, HistoryValue, MachineContext, StateConfig, StateValue, AnyActorRef, Snapshot, ParameterizedObject, IsNever, MetaObject } from "./types.js";
|
|
3
|
+
import type { ProvidedActor, AnyMachineSnapshot, AnyStateMachine, EventObject, HistoryValue, MachineContext, StateConfig, StateValue, AnyActorRef, Snapshot, ParameterizedObject, IsNever, MetaObject, StateSchema, StateId, SnapshotStatus } from "./types.js";
|
|
4
4
|
type ToTestStateValue<TStateValue extends StateValue> = TStateValue extends string ? TStateValue : IsNever<keyof TStateValue> extends true ? never : keyof TStateValue | {
|
|
5
5
|
[K in keyof TStateValue]?: ToTestStateValue<NonNullable<TStateValue[K]>>;
|
|
6
6
|
};
|
|
7
7
|
export declare function isMachineSnapshot<TContext extends MachineContext, TEvent extends EventObject>(value: unknown): value is AnyMachineSnapshot;
|
|
8
|
-
interface MachineSnapshotBase<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TOutput, TMeta,
|
|
8
|
+
interface MachineSnapshotBase<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TOutput, TMeta, TConfig extends StateSchema = StateSchema> {
|
|
9
9
|
/** The state machine that produced this state snapshot. */
|
|
10
10
|
machine: StateMachine<TContext, TEvent, TChildren, ProvidedActor, ParameterizedObject, ParameterizedObject, string, TStateValue, TTag, unknown, TOutput, EventObject, // TEmitted
|
|
11
11
|
any>;
|
|
@@ -34,7 +34,7 @@ interface MachineSnapshotBase<TContext extends MachineContext, TEvent extends Ev
|
|
|
34
34
|
*/
|
|
35
35
|
value: TStateValue;
|
|
36
36
|
/** The current status of this snapshot. */
|
|
37
|
-
status:
|
|
37
|
+
status: SnapshotStatus;
|
|
38
38
|
error: unknown;
|
|
39
39
|
context: TContext;
|
|
40
40
|
historyValue: Readonly<HistoryValue<TContext, TEvent>>;
|
|
@@ -64,30 +64,30 @@ interface MachineSnapshotBase<TContext extends MachineContext, TEvent extends Ev
|
|
|
64
64
|
* @returns Whether the event will cause a transition
|
|
65
65
|
*/
|
|
66
66
|
can: (event: TEvent) => boolean;
|
|
67
|
-
getMeta: () => Record<string, TMeta | undefined>;
|
|
67
|
+
getMeta: () => Record<StateId<TConfig> & string, TMeta | undefined>;
|
|
68
68
|
toJSON: () => unknown;
|
|
69
69
|
}
|
|
70
|
-
interface ActiveMachineSnapshot<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TOutput, TMeta extends MetaObject> extends MachineSnapshotBase<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta> {
|
|
70
|
+
interface ActiveMachineSnapshot<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TOutput, TMeta extends MetaObject, TConfig extends StateSchema> extends MachineSnapshotBase<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig> {
|
|
71
71
|
status: 'active';
|
|
72
72
|
output: undefined;
|
|
73
73
|
error: undefined;
|
|
74
74
|
}
|
|
75
|
-
interface DoneMachineSnapshot<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TOutput, TMeta extends MetaObject> extends MachineSnapshotBase<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta> {
|
|
75
|
+
interface DoneMachineSnapshot<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TOutput, TMeta extends MetaObject, TConfig extends StateSchema> extends MachineSnapshotBase<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig> {
|
|
76
76
|
status: 'done';
|
|
77
77
|
output: TOutput;
|
|
78
78
|
error: undefined;
|
|
79
79
|
}
|
|
80
|
-
interface ErrorMachineSnapshot<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TOutput, TMeta extends MetaObject> extends MachineSnapshotBase<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta> {
|
|
80
|
+
interface ErrorMachineSnapshot<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TOutput, TMeta extends MetaObject, TConfig extends StateSchema = StateSchema> extends MachineSnapshotBase<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig> {
|
|
81
81
|
status: 'error';
|
|
82
82
|
output: undefined;
|
|
83
83
|
error: unknown;
|
|
84
84
|
}
|
|
85
|
-
interface StoppedMachineSnapshot<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TOutput, TMeta extends MetaObject> extends MachineSnapshotBase<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta> {
|
|
85
|
+
interface StoppedMachineSnapshot<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TOutput, TMeta extends MetaObject, TConfig extends StateSchema = StateSchema> extends MachineSnapshotBase<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig> {
|
|
86
86
|
status: 'stopped';
|
|
87
87
|
output: undefined;
|
|
88
88
|
error: undefined;
|
|
89
89
|
}
|
|
90
|
-
export type MachineSnapshot<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TOutput, TMeta extends MetaObject,
|
|
90
|
+
export type MachineSnapshot<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TOutput, TMeta extends MetaObject, TConfig extends StateSchema = StateSchema> = ActiveMachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig> | DoneMachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig> | ErrorMachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig> | StoppedMachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>;
|
|
91
91
|
export declare function createMachineSnapshot<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TMeta extends MetaObject>(config: StateConfig<TContext, TEvent>, machine: AnyStateMachine): MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, undefined, TMeta>;
|
|
92
92
|
export declare function cloneMachineSnapshot<TState extends AnyMachineSnapshot>(snapshot: TState, config?: Partial<StateConfig<any, any>>): TState;
|
|
93
93
|
export declare function getPersistedSnapshot<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TOutput, TMeta extends MetaObject>(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta>, options?: unknown): Snapshot<unknown>;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { MachineSnapshot } from "./State.js";
|
|
2
2
|
import { StateNode } from "./StateNode.js";
|
|
3
3
|
import { AnyActorSystem } from "./system.js";
|
|
4
|
-
import type { ActorLogic, ActorScope, AnyActorRef, AnyActorScope, DoNotInfer, Equals, EventDescriptor, EventObject, HistoryValue, InternalMachineImplementations, MachineConfig, MachineContext, MachineImplementationsSimplified, MetaObject, ParameterizedObject, ProvidedActor, Snapshot, StateMachineDefinition, StateValue, TransitionDefinition, ResolvedStateMachineTypes } from "./types.js";
|
|
5
|
-
export declare const STATE_IDENTIFIER = "#";
|
|
6
|
-
export declare const WILDCARD = "*";
|
|
4
|
+
import type { ActorLogic, ActorScope, AnyActorRef, AnyActorScope, DoNotInfer, Equals, EventDescriptor, EventObject, HistoryValue, InternalMachineImplementations, MachineConfig, MachineContext, MachineImplementationsSimplified, MetaObject, ParameterizedObject, ProvidedActor, Snapshot, StateMachineDefinition, StateValue, TransitionDefinition, ResolvedStateMachineTypes, StateSchema, SnapshotStatus } from "./types.js";
|
|
7
5
|
export declare class StateMachine<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TActor extends ProvidedActor, TAction extends ParameterizedObject, TGuard extends ParameterizedObject, TDelay extends string, TStateValue extends StateValue, TTag extends string, TInput, TOutput, TEmitted extends EventObject = EventObject, // TODO: remove default
|
|
8
|
-
TMeta extends MetaObject = MetaObject> implements ActorLogic<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta>, TEvent, TInput, AnyActorSystem, TEmitted> {
|
|
6
|
+
TMeta extends MetaObject = MetaObject, TConfig extends StateSchema = StateSchema> implements ActorLogic<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, TEvent, TInput, AnyActorSystem, TEmitted> {
|
|
9
7
|
/** The raw config used to create the machine. */
|
|
10
8
|
config: MachineConfig<TContext, TEvent, any, any, any, any, any, any, TOutput, any, // TEmitted
|
|
11
9
|
any> & {
|
|
@@ -38,12 +36,12 @@ TMeta extends MetaObject = MetaObject> implements ActorLogic<MachineSnapshot<TCo
|
|
|
38
36
|
value: StateValue;
|
|
39
37
|
context?: TContext;
|
|
40
38
|
historyValue?: HistoryValue<TContext, TEvent>;
|
|
41
|
-
status?:
|
|
39
|
+
status?: SnapshotStatus;
|
|
42
40
|
output?: TOutput;
|
|
43
41
|
error?: unknown;
|
|
44
42
|
} & (Equals<TContext, MachineContext> extends false ? {
|
|
45
43
|
context: unknown;
|
|
46
|
-
} : {})): MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta>;
|
|
44
|
+
} : {})): MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>;
|
|
47
45
|
/**
|
|
48
46
|
* Determines the next snapshot given the current `snapshot` and received
|
|
49
47
|
* `event`. Calculates a full macrostep from all microsteps.
|
|
@@ -51,7 +49,7 @@ TMeta extends MetaObject = MetaObject> implements ActorLogic<MachineSnapshot<TCo
|
|
|
51
49
|
* @param snapshot The current snapshot
|
|
52
50
|
* @param event The received event
|
|
53
51
|
*/
|
|
54
|
-
transition(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta>, event: TEvent, actorScope: ActorScope<typeof snapshot, TEvent, AnyActorSystem, TEmitted>): MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta>;
|
|
52
|
+
transition(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, event: TEvent, actorScope: ActorScope<typeof snapshot, TEvent, AnyActorSystem, TEmitted>): MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>;
|
|
55
53
|
/**
|
|
56
54
|
* Determines the next state given the current `state` and `event`. Calculates
|
|
57
55
|
* a microstep.
|
|
@@ -59,8 +57,8 @@ TMeta extends MetaObject = MetaObject> implements ActorLogic<MachineSnapshot<TCo
|
|
|
59
57
|
* @param state The current state
|
|
60
58
|
* @param event The received event
|
|
61
59
|
*/
|
|
62
|
-
microstep(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta>, event: TEvent, actorScope: AnyActorScope): Array<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta>>;
|
|
63
|
-
getTransitionData(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta>, event: TEvent): Array<TransitionDefinition<TContext, TEvent>>;
|
|
60
|
+
microstep(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, event: TEvent, actorScope: AnyActorScope): Array<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>>;
|
|
61
|
+
getTransitionData(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, event: TEvent): Array<TransitionDefinition<TContext, TEvent>>;
|
|
64
62
|
/**
|
|
65
63
|
* The initial state _before_ evaluating any microsteps. This "pre-initial"
|
|
66
64
|
* state is provided to initial actions executed in the initial state.
|
|
@@ -70,11 +68,11 @@ TMeta extends MetaObject = MetaObject> implements ActorLogic<MachineSnapshot<TCo
|
|
|
70
68
|
* Returns the initial `State` instance, with reference to `self` as an
|
|
71
69
|
* `ActorRef`.
|
|
72
70
|
*/
|
|
73
|
-
getInitialSnapshot(actorScope: ActorScope<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta>, TEvent, AnyActorSystem, TEmitted>, input?: TInput): MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta>;
|
|
74
|
-
start(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta>): void;
|
|
71
|
+
getInitialSnapshot(actorScope: ActorScope<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, TEvent, AnyActorSystem, TEmitted>, input?: TInput): MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>;
|
|
72
|
+
start(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>): void;
|
|
75
73
|
getStateNodeById(stateId: string): StateNode<TContext, TEvent>;
|
|
76
74
|
get definition(): StateMachineDefinition<TContext, TEvent>;
|
|
77
75
|
toJSON(): StateMachineDefinition<TContext, TEvent>;
|
|
78
|
-
getPersistedSnapshot(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta>, options?: unknown): Snapshot<unknown>;
|
|
79
|
-
restoreSnapshot(snapshot: Snapshot<unknown>, _actorScope: ActorScope<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta>, TEvent, AnyActorSystem, TEmitted>): MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta>;
|
|
76
|
+
getPersistedSnapshot(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, options?: unknown): Snapshot<unknown>;
|
|
77
|
+
restoreSnapshot(snapshot: Snapshot<unknown>, _actorScope: ActorScope<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, TEvent, AnyActorSystem, TEmitted>): MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>;
|
|
80
78
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Guard } from "../guards.js";
|
|
2
|
-
import { Action, ActionArgs, ActionFunction, AnyActorRef, EventObject, MachineContext, ParameterizedObject, ProvidedActor, UnifiedArg } from "../types.js";
|
|
2
|
+
import { Action, ActionArgs, ActionFunction, AnyActorRef, AnyEventObject, EventObject, MachineContext, ParameterizedObject, ProvidedActor, UnifiedArg } from "../types.js";
|
|
3
3
|
import { assign } from "./assign.js";
|
|
4
4
|
import { cancel } from "./cancel.js";
|
|
5
5
|
import { emit } from "./emit.js";
|
|
6
6
|
import { raise } from "./raise.js";
|
|
7
|
-
import { sendTo } from "./send.js";
|
|
7
|
+
import { sendParent, sendTo } from "./send.js";
|
|
8
8
|
import { spawnChild } from "./spawnChild.js";
|
|
9
9
|
import { stopChild } from "./stopChild.js";
|
|
10
10
|
interface ActionEnqueuer<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject, TActor extends ProvidedActor, TAction extends ParameterizedObject, TGuard extends ParameterizedObject, TDelay extends string, TEmitted extends EventObject> {
|
|
@@ -13,6 +13,7 @@ interface ActionEnqueuer<TContext extends MachineContext, TExpressionEvent exten
|
|
|
13
13
|
cancel: (...args: Parameters<typeof cancel<TContext, TExpressionEvent, undefined, TEvent>>) => void;
|
|
14
14
|
raise: (...args: Parameters<typeof raise<TContext, TExpressionEvent, TEvent, undefined, TDelay, TDelay>>) => void;
|
|
15
15
|
sendTo: <TTargetActor extends AnyActorRef>(...args: Parameters<typeof sendTo<TContext, TExpressionEvent, undefined, TTargetActor, TEvent, TDelay, TDelay>>) => void;
|
|
16
|
+
sendParent: (...args: Parameters<typeof sendParent<TContext, TExpressionEvent, undefined, AnyEventObject, TEvent, TDelay, TDelay>>) => void;
|
|
16
17
|
spawnChild: (...args: Parameters<typeof spawnChild<TContext, TExpressionEvent, undefined, TEvent, TActor>>) => void;
|
|
17
18
|
stopChild: (...args: Parameters<typeof stopChild<TContext, TExpressionEvent, undefined, TEvent>>) => void;
|
|
18
19
|
emit: (...args: Parameters<typeof emit<TContext, TExpressionEvent, undefined, TEvent, TEmitted>>) => void;
|
|
@@ -39,10 +39,10 @@ export type CallbackActorLogic<TEvent extends EventObject, TInput = NonReducible
|
|
|
39
39
|
* @see {@link fromCallback}
|
|
40
40
|
*/
|
|
41
41
|
export type CallbackActorRef<TEvent extends EventObject, TInput = NonReducibleUnknown> = ActorRefFrom<CallbackActorLogic<TEvent, TInput>>;
|
|
42
|
-
|
|
42
|
+
type Receiver<TEvent extends EventObject> = (listener: {
|
|
43
43
|
bivarianceHack(event: TEvent): void;
|
|
44
44
|
}['bivarianceHack']) => void;
|
|
45
|
-
|
|
45
|
+
type InvokeCallback<TEvent extends EventObject = AnyEventObject, TSentEvent extends EventObject = AnyEventObject, TInput = NonReducibleUnknown, TEmitted extends EventObject = EventObject> = ({ input, system, self, sendBack, receive, emit }: {
|
|
46
46
|
/**
|
|
47
47
|
* Data that was provided to the callback actor
|
|
48
48
|
*
|
|
@@ -130,3 +130,4 @@ export type InvokeCallback<TEvent extends EventObject = AnyEventObject, TSentEve
|
|
|
130
130
|
* @see {@link https://stately.ai/docs/input | Input docs} for more information about how input is passed
|
|
131
131
|
*/
|
|
132
132
|
export declare function fromCallback<TEvent extends EventObject, TInput = NonReducibleUnknown, TEmitted extends EventObject = EventObject>(invokeCallback: InvokeCallback<TEvent, AnyEventObject, TInput, TEmitted>): CallbackActorLogic<TEvent, TInput, TEmitted>;
|
|
133
|
+
export {};
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { symbolObservable } from "./symbolObservable.js";
|
|
2
2
|
import { AnyActorSystem, Clock } from "./system.js";
|
|
3
3
|
import type { AnyActorLogic, AnyActorRef, ConditionalRequired, EmittedFrom, EventFromLogic, InputFrom, IsNotNever, Snapshot, SnapshotFrom } from "./types.js";
|
|
4
|
-
import { ActorOptions, ActorRef,
|
|
4
|
+
import { ActorOptions, ActorRef, InteropSubscribable, Observer, Subscription } from "./types.js";
|
|
5
5
|
export declare const $$ACTOR_TYPE = 1;
|
|
6
|
-
export type SnapshotListener<TLogic extends AnyActorLogic> = (snapshot: SnapshotFrom<TLogic>) => void;
|
|
7
|
-
export type EventListener<TEvent extends EventObject = EventObject> = (event: TEvent) => void;
|
|
8
|
-
export type Listener = () => void;
|
|
9
|
-
export type ErrorListener = (error: any) => void;
|
|
10
6
|
export declare enum ProcessingStatus {
|
|
11
7
|
NotStarted = 0,
|
|
12
8
|
Running = 1,
|
|
@@ -219,8 +215,12 @@ export declare function createActor<TLogic extends AnyActorLogic>(logic: TLogic,
|
|
|
219
215
|
* options, if any.
|
|
220
216
|
*
|
|
221
217
|
* @deprecated Use `createActor` instead
|
|
218
|
+
* @alias
|
|
222
219
|
*/
|
|
223
220
|
export declare const interpret: typeof createActor;
|
|
224
|
-
/**
|
|
221
|
+
/**
|
|
222
|
+
* @deprecated Use `Actor` instead.
|
|
223
|
+
* @alias
|
|
224
|
+
*/
|
|
225
225
|
export type Interpreter = typeof Actor;
|
|
226
226
|
export {};
|