xstate 5.0.0-beta.22 → 5.0.0-beta.24

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.
Files changed (48) hide show
  1. package/actions/dist/xstate-actions.cjs.js +1 -1
  2. package/actions/dist/xstate-actions.development.cjs.js +1 -1
  3. package/actions/dist/xstate-actions.development.esm.js +1 -1
  4. package/actions/dist/xstate-actions.esm.js +1 -1
  5. package/actions/dist/xstate-actions.umd.min.js +1 -1
  6. package/actions/dist/xstate-actions.umd.min.js.map +1 -1
  7. package/actors/dist/xstate-actors.cjs.js +1 -1
  8. package/actors/dist/xstate-actors.development.cjs.js +1 -1
  9. package/actors/dist/xstate-actors.development.esm.js +1 -1
  10. package/actors/dist/xstate-actors.esm.js +1 -1
  11. package/actors/dist/xstate-actors.umd.min.js.map +1 -1
  12. package/dist/{actions-d4305983.development.esm.js → actions-194e6dcc.development.esm.js} +100 -144
  13. package/dist/{actions-4b70fc8d.development.cjs.js → actions-43f7d40e.development.cjs.js} +99 -144
  14. package/dist/{actions-8f2e997e.cjs.js → actions-6a8cda73.cjs.js} +95 -148
  15. package/dist/{actions-fb7384f8.esm.js → actions-7b182232.esm.js} +96 -148
  16. package/dist/declarations/src/Machine.d.ts +2 -2
  17. package/dist/declarations/src/State.d.ts +5 -5
  18. package/dist/declarations/src/StateMachine.d.ts +27 -19
  19. package/dist/declarations/src/StateNode.d.ts +9 -9
  20. package/dist/declarations/src/actions/assign.d.ts +6 -6
  21. package/dist/declarations/src/actions/cancel.d.ts +7 -7
  22. package/dist/declarations/src/actions/choose.d.ts +4 -10
  23. package/dist/declarations/src/actions/log.d.ts +7 -7
  24. package/dist/declarations/src/actions/pure.d.ts +6 -17
  25. package/dist/declarations/src/actions/raise.d.ts +3 -3
  26. package/dist/declarations/src/actions/send.d.ts +22 -22
  27. package/dist/declarations/src/actions/stop.d.ts +7 -7
  28. package/dist/declarations/src/guards.d.ts +17 -8
  29. package/dist/declarations/src/interpreter.d.ts +1 -1
  30. package/dist/declarations/src/stateUtils.d.ts +12 -12
  31. package/dist/declarations/src/typegenTypes.d.ts +6 -2
  32. package/dist/declarations/src/types.d.ts +130 -192
  33. package/dist/declarations/src/utils.d.ts +8 -8
  34. package/dist/xstate.cjs.js +10 -7
  35. package/dist/xstate.development.cjs.js +10 -7
  36. package/dist/xstate.development.esm.js +11 -8
  37. package/dist/xstate.esm.js +11 -8
  38. package/dist/xstate.umd.min.js +1 -1
  39. package/dist/xstate.umd.min.js.map +1 -1
  40. package/guards/dist/xstate-guards.cjs.js +1 -2
  41. package/guards/dist/xstate-guards.cjs.mjs +1 -2
  42. package/guards/dist/xstate-guards.development.cjs.js +1 -2
  43. package/guards/dist/xstate-guards.development.cjs.mjs +1 -2
  44. package/guards/dist/xstate-guards.development.esm.js +1 -1
  45. package/guards/dist/xstate-guards.esm.js +1 -1
  46. package/guards/dist/xstate-guards.umd.min.js +1 -1
  47. package/guards/dist/xstate-guards.umd.min.js.map +1 -1
  48. package/package.json +1 -1
@@ -1466,148 +1466,101 @@ function invoke({
1466
1466
  return invoke;
1467
1467
  }
1468
1468
 
1469
+ function checkStateIn(state, _, {
1470
+ stateValue
1471
+ }) {
1472
+ if (typeof stateValue === 'string' && isStateId(stateValue)) {
1473
+ return state.configuration.some(sn => sn.id === stateValue.slice(1));
1474
+ }
1475
+ return state.matches(stateValue);
1476
+ }
1469
1477
  function stateIn(stateValue) {
1470
- return {
1471
- type: 'xstate.guard:in',
1472
- params: {
1473
- stateValue
1474
- },
1475
- predicate: ({
1476
- state
1477
- }) => {
1478
- if (typeof stateValue === 'string' && isStateId(stateValue)) {
1479
- return state.configuration.some(sn => sn.id === stateValue.slice(1));
1480
- }
1481
- return state.matches(stateValue);
1482
- }
1483
- };
1478
+ function stateIn(_) {
1479
+ return false;
1480
+ }
1481
+ stateIn.check = checkStateIn;
1482
+ stateIn.stateValue = stateValue;
1483
+ return stateIn;
1484
+ }
1485
+ function checkNot(state, {
1486
+ context,
1487
+ event
1488
+ }, {
1489
+ guards
1490
+ }) {
1491
+ return !evaluateGuard(guards[0], context, event, state);
1484
1492
  }
1485
1493
  function not(guard) {
1486
- return {
1487
- type: 'xstate.boolean',
1488
- params: {
1489
- op: 'not'
1490
- },
1491
- children: [toGuardDefinition(guard)],
1492
- predicate: ({
1493
- evaluate,
1494
- guard,
1495
- context,
1496
- event,
1497
- state
1498
- }) => {
1499
- return !evaluate(guard.children[0], context, event, state);
1500
- }
1501
- };
1494
+ function not(_) {
1495
+ return false;
1496
+ }
1497
+ not.check = checkNot;
1498
+ not.guards = [guard];
1499
+ return not;
1500
+ }
1501
+ function checkAnd(state, {
1502
+ context,
1503
+ event
1504
+ }, {
1505
+ guards
1506
+ }) {
1507
+ return guards.every(guard => evaluateGuard(guard, context, event, state));
1502
1508
  }
1503
1509
  function and(guards) {
1504
- return {
1505
- type: 'xstate.boolean',
1506
- params: {
1507
- op: 'and'
1508
- },
1509
- children: guards.map(guard => toGuardDefinition(guard)),
1510
- predicate: ({
1511
- evaluate,
1512
- guard,
1513
- context,
1514
- event,
1515
- state
1516
- }) => {
1517
- return guard.children.every(childGuard => {
1518
- return evaluate(childGuard, context, event, state);
1519
- });
1520
- }
1521
- };
1510
+ function and(_) {
1511
+ return false;
1512
+ }
1513
+ and.check = checkAnd;
1514
+ and.guards = guards;
1515
+ return and;
1516
+ }
1517
+ function checkOr(state, {
1518
+ context,
1519
+ event
1520
+ }, {
1521
+ guards
1522
+ }) {
1523
+ return guards.some(guard => evaluateGuard(guard, context, event, state));
1522
1524
  }
1523
1525
  function or(guards) {
1524
- return {
1525
- type: 'xstate.boolean',
1526
- params: {
1527
- op: 'or'
1528
- },
1529
- children: guards.map(guard => toGuardDefinition(guard)),
1530
- predicate: ({
1531
- evaluate,
1532
- guard,
1533
- context,
1534
- event,
1535
- state
1536
- }) => {
1537
- return guard.children.some(childGuard => {
1538
- return evaluate(childGuard, context, event, state);
1539
- });
1540
- }
1541
- };
1526
+ function or(_) {
1527
+ return false;
1528
+ }
1529
+ or.check = checkOr;
1530
+ or.guards = guards;
1531
+ return or;
1542
1532
  }
1533
+
1534
+ // TODO: throw on cycles (depth check should be enough)
1543
1535
  function evaluateGuard(guard, context, event, state) {
1544
1536
  const {
1545
1537
  machine
1546
1538
  } = state;
1547
- const predicate = machine?.implementations?.guards?.[guard.type] ?? guard.predicate;
1548
- if (!predicate) {
1549
- throw new Error(`Guard '${guard.type}' is not implemented.'.`);
1550
- }
1551
- return predicate({
1539
+ const isInline = typeof guard === 'function';
1540
+ const resolved = isInline ? guard :
1541
+ // the existing type of `.guards` assumes non-nullable `TExpressionGuard`
1542
+ // it's fine to cast this here to get a common type and lack of errors in the rest of the code
1543
+ // our logic below makes sure that we call those 2 "variants" correctly
1544
+ machine.implementations.guards[typeof guard === 'string' ? guard : guard.type];
1545
+ if (!isInline && !resolved) {
1546
+ throw new Error(`Guard '${typeof guard === 'string' ? guard : guard.type}' is not implemented.'.`);
1547
+ }
1548
+ if (typeof resolved !== 'function') {
1549
+ return evaluateGuard(resolved, context, event, state);
1550
+ }
1551
+ const guardArgs = {
1552
1552
  context,
1553
1553
  event,
1554
- state,
1555
- guard,
1556
- evaluate: evaluateGuard
1557
- });
1558
- }
1559
- function toGuardDefinition(guardConfig, getPredicate) {
1560
- // TODO: check for cycles and consider a refactor to more lazily evaluated guards
1561
- // TODO: resolve this more recursively: https://github.com/statelyai/xstate/pull/4064#discussion_r1229915724
1562
- if (typeof guardConfig === 'string') {
1563
- const predicateOrDef = getPredicate?.(guardConfig);
1564
- if (typeof predicateOrDef === 'function') {
1565
- return {
1566
- type: guardConfig,
1567
- predicate: predicateOrDef,
1568
- params: {
1569
- type: guardConfig
1570
- }
1571
- };
1572
- } else if (predicateOrDef) {
1573
- return predicateOrDef;
1574
- } else {
1575
- return {
1576
- type: guardConfig,
1577
- params: {
1578
- type: guardConfig
1579
- }
1580
- };
1581
- }
1582
- }
1583
- if (typeof guardConfig === 'function') {
1584
- return {
1585
- type: guardConfig.name,
1586
- predicate: guardConfig,
1587
- params: {
1588
- type: guardConfig.name,
1589
- name: guardConfig.name
1590
- }
1591
- };
1592
- }
1593
- const predicateOrDef = getPredicate?.(guardConfig.type);
1594
- if (typeof predicateOrDef === 'function') {
1595
- return {
1596
- type: guardConfig.type,
1597
- params: guardConfig.params || guardConfig,
1598
- children: guardConfig.children?.map(childGuard => toGuardDefinition(childGuard, getPredicate)),
1599
- predicate: getPredicate?.(guardConfig.type) || guardConfig.predicate
1600
- };
1601
- } else if (predicateOrDef) {
1602
- return predicateOrDef;
1603
- } else {
1604
- return {
1605
- type: guardConfig.type,
1606
- params: guardConfig.params || guardConfig,
1607
- children: guardConfig.children?.map(childGuard => toGuardDefinition(childGuard, getPredicate)),
1608
- predicate: guardConfig.predicate
1609
- };
1554
+ guard: isInline ? undefined : typeof guard === 'string' ? {
1555
+ type: guard
1556
+ } : guard
1557
+ };
1558
+ if (!('check' in resolved)) {
1559
+ return resolved(guardArgs);
1610
1560
  }
1561
+ const builtinGuard = resolved;
1562
+ return builtinGuard.check(state, guardArgs, resolved // this holds all params
1563
+ );
1611
1564
  }
1612
1565
 
1613
1566
  function getOutput(configuration, context, event, self) {
@@ -1797,14 +1750,11 @@ function getDelayedTransitions(stateNode) {
1797
1750
  function formatTransition(stateNode, descriptor, transitionConfig) {
1798
1751
  const normalizedTarget = normalizeTarget(transitionConfig.target);
1799
1752
  const reenter = transitionConfig.reenter ?? false;
1800
- const {
1801
- guards
1802
- } = stateNode.machine.implementations;
1803
1753
  const target = resolveTarget(stateNode, normalizedTarget);
1804
1754
  const transition = {
1805
1755
  ...transitionConfig,
1806
1756
  actions: toArray(transitionConfig.actions),
1807
- guard: transitionConfig.guard ? toGuardDefinition(transitionConfig.guard, guardType => guards[guardType]) : undefined,
1757
+ guard: transitionConfig.guard,
1808
1758
  target,
1809
1759
  source: stateNode,
1810
1760
  reenter,
@@ -2400,34 +2350,34 @@ function resolveActionsAndContext(actions, event, currentState, actorCtx) {
2400
2350
  _internalQueue: []
2401
2351
  });
2402
2352
  for (const action of actions) {
2403
- const resolved = typeof action === 'function' ? action : machine.implementations.actions[typeof action === 'string' ? action : action.type];
2353
+ const isInline = typeof action === 'function';
2354
+ const resolved = isInline ? action :
2355
+ // the existing type of `.actions` assumes non-nullable `TExpressionAction`
2356
+ // it's fine to cast this here to get a common type and lack of errors in the rest of the code
2357
+ // our logic below makes sure that we call those 2 "variants" correctly
2358
+ machine.implementations.actions[typeof action === 'string' ? action : action.type];
2404
2359
  if (!resolved) {
2405
2360
  continue;
2406
2361
  }
2407
- const args = {
2362
+ const actionArgs = {
2408
2363
  context: intermediateState.context,
2409
2364
  event,
2410
2365
  self: actorCtx?.self,
2411
2366
  system: actorCtx?.system,
2412
- // TODO: figure out story for `action` and inline actions
2413
- // what those ones should receive?
2414
- //
2415
- // entry: ({ action }) => {}
2416
- // exit: assign(({ action }) => {})
2417
- action: typeof action === 'string' ? {
2367
+ action: isInline ? undefined : typeof action === 'string' ? {
2418
2368
  type: action
2419
2369
  } : action
2420
2370
  };
2421
2371
  if (!('resolve' in resolved)) {
2422
2372
  if (actorCtx?.self.status === ActorStatus.Running) {
2423
- resolved(args);
2373
+ resolved(actionArgs);
2424
2374
  } else {
2425
- actorCtx?.defer(() => resolved(args));
2375
+ actorCtx?.defer(() => resolved(actionArgs));
2426
2376
  }
2427
2377
  continue;
2428
2378
  }
2429
2379
  const builtinAction = resolved;
2430
- const [nextState, params, actions] = builtinAction.resolve(actorCtx, intermediateState, args, resolved // this holds all params
2380
+ const [nextState, params, actions] = builtinAction.resolve(actorCtx, intermediateState, actionArgs, resolved // this holds all params
2431
2381
  );
2432
2382
 
2433
2383
  intermediateState = nextState;
@@ -2551,9 +2501,8 @@ class State {
2551
2501
  */
2552
2502
 
2553
2503
  /**
2554
- * The done data of the top-level finite state.
2504
+ * The output data of the top-level finite state.
2555
2505
  */
2556
- // TODO: add an explicit type for `output`
2557
2506
 
2558
2507
  /**
2559
2508
  * The enabled state nodes representative of the state value.
@@ -2976,8 +2925,7 @@ function resolve$1(_, state, actionArgs, {
2976
2925
  branches
2977
2926
  }) {
2978
2927
  const matchedActions = branches.find(condition => {
2979
- const guard = condition.guard && toGuardDefinition(condition.guard, guardType => state.machine.implementations.guards[guardType]);
2980
- return !guard || evaluateGuard(guard, state.context, actionArgs.event, state);
2928
+ return !condition.guard || evaluateGuard(condition.guard, state.context, actionArgs.event, state);
2981
2929
  })?.actions;
2982
2930
  return [state, undefined, toArray(matchedActions)];
2983
2931
  }
@@ -2994,7 +2942,7 @@ function resolve(_, state, args, {
2994
2942
  get
2995
2943
  }) {
2996
2944
  return [state, undefined, toArray(get({
2997
- context: state.context,
2945
+ context: args.context,
2998
2946
  event: args.event
2999
2947
  }))];
3000
2948
  }
@@ -3142,7 +3090,6 @@ exports.stopSignal = stopSignal;
3142
3090
  exports.stopSignalType = stopSignalType;
3143
3091
  exports.toActorRef = toActorRef;
3144
3092
  exports.toArray = toArray;
3145
- exports.toGuardDefinition = toGuardDefinition;
3146
3093
  exports.toInvokeConfig = toInvokeConfig;
3147
3094
  exports.toObserver = toObserver;
3148
3095
  exports.toTransitionConfigArray = toTransitionConfigArray;
@@ -1464,148 +1464,101 @@ function invoke({
1464
1464
  return invoke;
1465
1465
  }
1466
1466
 
1467
+ function checkStateIn(state, _, {
1468
+ stateValue
1469
+ }) {
1470
+ if (typeof stateValue === 'string' && isStateId(stateValue)) {
1471
+ return state.configuration.some(sn => sn.id === stateValue.slice(1));
1472
+ }
1473
+ return state.matches(stateValue);
1474
+ }
1467
1475
  function stateIn(stateValue) {
1468
- return {
1469
- type: 'xstate.guard:in',
1470
- params: {
1471
- stateValue
1472
- },
1473
- predicate: ({
1474
- state
1475
- }) => {
1476
- if (typeof stateValue === 'string' && isStateId(stateValue)) {
1477
- return state.configuration.some(sn => sn.id === stateValue.slice(1));
1478
- }
1479
- return state.matches(stateValue);
1480
- }
1481
- };
1476
+ function stateIn(_) {
1477
+ return false;
1478
+ }
1479
+ stateIn.check = checkStateIn;
1480
+ stateIn.stateValue = stateValue;
1481
+ return stateIn;
1482
+ }
1483
+ function checkNot(state, {
1484
+ context,
1485
+ event
1486
+ }, {
1487
+ guards
1488
+ }) {
1489
+ return !evaluateGuard(guards[0], context, event, state);
1482
1490
  }
1483
1491
  function not(guard) {
1484
- return {
1485
- type: 'xstate.boolean',
1486
- params: {
1487
- op: 'not'
1488
- },
1489
- children: [toGuardDefinition(guard)],
1490
- predicate: ({
1491
- evaluate,
1492
- guard,
1493
- context,
1494
- event,
1495
- state
1496
- }) => {
1497
- return !evaluate(guard.children[0], context, event, state);
1498
- }
1499
- };
1492
+ function not(_) {
1493
+ return false;
1494
+ }
1495
+ not.check = checkNot;
1496
+ not.guards = [guard];
1497
+ return not;
1498
+ }
1499
+ function checkAnd(state, {
1500
+ context,
1501
+ event
1502
+ }, {
1503
+ guards
1504
+ }) {
1505
+ return guards.every(guard => evaluateGuard(guard, context, event, state));
1500
1506
  }
1501
1507
  function and(guards) {
1502
- return {
1503
- type: 'xstate.boolean',
1504
- params: {
1505
- op: 'and'
1506
- },
1507
- children: guards.map(guard => toGuardDefinition(guard)),
1508
- predicate: ({
1509
- evaluate,
1510
- guard,
1511
- context,
1512
- event,
1513
- state
1514
- }) => {
1515
- return guard.children.every(childGuard => {
1516
- return evaluate(childGuard, context, event, state);
1517
- });
1518
- }
1519
- };
1508
+ function and(_) {
1509
+ return false;
1510
+ }
1511
+ and.check = checkAnd;
1512
+ and.guards = guards;
1513
+ return and;
1514
+ }
1515
+ function checkOr(state, {
1516
+ context,
1517
+ event
1518
+ }, {
1519
+ guards
1520
+ }) {
1521
+ return guards.some(guard => evaluateGuard(guard, context, event, state));
1520
1522
  }
1521
1523
  function or(guards) {
1522
- return {
1523
- type: 'xstate.boolean',
1524
- params: {
1525
- op: 'or'
1526
- },
1527
- children: guards.map(guard => toGuardDefinition(guard)),
1528
- predicate: ({
1529
- evaluate,
1530
- guard,
1531
- context,
1532
- event,
1533
- state
1534
- }) => {
1535
- return guard.children.some(childGuard => {
1536
- return evaluate(childGuard, context, event, state);
1537
- });
1538
- }
1539
- };
1524
+ function or(_) {
1525
+ return false;
1526
+ }
1527
+ or.check = checkOr;
1528
+ or.guards = guards;
1529
+ return or;
1540
1530
  }
1531
+
1532
+ // TODO: throw on cycles (depth check should be enough)
1541
1533
  function evaluateGuard(guard, context, event, state) {
1542
1534
  const {
1543
1535
  machine
1544
1536
  } = state;
1545
- const predicate = machine?.implementations?.guards?.[guard.type] ?? guard.predicate;
1546
- if (!predicate) {
1547
- throw new Error(`Guard '${guard.type}' is not implemented.'.`);
1548
- }
1549
- return predicate({
1537
+ const isInline = typeof guard === 'function';
1538
+ const resolved = isInline ? guard :
1539
+ // the existing type of `.guards` assumes non-nullable `TExpressionGuard`
1540
+ // it's fine to cast this here to get a common type and lack of errors in the rest of the code
1541
+ // our logic below makes sure that we call those 2 "variants" correctly
1542
+ machine.implementations.guards[typeof guard === 'string' ? guard : guard.type];
1543
+ if (!isInline && !resolved) {
1544
+ throw new Error(`Guard '${typeof guard === 'string' ? guard : guard.type}' is not implemented.'.`);
1545
+ }
1546
+ if (typeof resolved !== 'function') {
1547
+ return evaluateGuard(resolved, context, event, state);
1548
+ }
1549
+ const guardArgs = {
1550
1550
  context,
1551
1551
  event,
1552
- state,
1553
- guard,
1554
- evaluate: evaluateGuard
1555
- });
1556
- }
1557
- function toGuardDefinition(guardConfig, getPredicate) {
1558
- // TODO: check for cycles and consider a refactor to more lazily evaluated guards
1559
- // TODO: resolve this more recursively: https://github.com/statelyai/xstate/pull/4064#discussion_r1229915724
1560
- if (typeof guardConfig === 'string') {
1561
- const predicateOrDef = getPredicate?.(guardConfig);
1562
- if (typeof predicateOrDef === 'function') {
1563
- return {
1564
- type: guardConfig,
1565
- predicate: predicateOrDef,
1566
- params: {
1567
- type: guardConfig
1568
- }
1569
- };
1570
- } else if (predicateOrDef) {
1571
- return predicateOrDef;
1572
- } else {
1573
- return {
1574
- type: guardConfig,
1575
- params: {
1576
- type: guardConfig
1577
- }
1578
- };
1579
- }
1580
- }
1581
- if (typeof guardConfig === 'function') {
1582
- return {
1583
- type: guardConfig.name,
1584
- predicate: guardConfig,
1585
- params: {
1586
- type: guardConfig.name,
1587
- name: guardConfig.name
1588
- }
1589
- };
1590
- }
1591
- const predicateOrDef = getPredicate?.(guardConfig.type);
1592
- if (typeof predicateOrDef === 'function') {
1593
- return {
1594
- type: guardConfig.type,
1595
- params: guardConfig.params || guardConfig,
1596
- children: guardConfig.children?.map(childGuard => toGuardDefinition(childGuard, getPredicate)),
1597
- predicate: getPredicate?.(guardConfig.type) || guardConfig.predicate
1598
- };
1599
- } else if (predicateOrDef) {
1600
- return predicateOrDef;
1601
- } else {
1602
- return {
1603
- type: guardConfig.type,
1604
- params: guardConfig.params || guardConfig,
1605
- children: guardConfig.children?.map(childGuard => toGuardDefinition(childGuard, getPredicate)),
1606
- predicate: guardConfig.predicate
1607
- };
1552
+ guard: isInline ? undefined : typeof guard === 'string' ? {
1553
+ type: guard
1554
+ } : guard
1555
+ };
1556
+ if (!('check' in resolved)) {
1557
+ return resolved(guardArgs);
1608
1558
  }
1559
+ const builtinGuard = resolved;
1560
+ return builtinGuard.check(state, guardArgs, resolved // this holds all params
1561
+ );
1609
1562
  }
1610
1563
 
1611
1564
  function getOutput(configuration, context, event, self) {
@@ -1795,14 +1748,11 @@ function getDelayedTransitions(stateNode) {
1795
1748
  function formatTransition(stateNode, descriptor, transitionConfig) {
1796
1749
  const normalizedTarget = normalizeTarget(transitionConfig.target);
1797
1750
  const reenter = transitionConfig.reenter ?? false;
1798
- const {
1799
- guards
1800
- } = stateNode.machine.implementations;
1801
1751
  const target = resolveTarget(stateNode, normalizedTarget);
1802
1752
  const transition = {
1803
1753
  ...transitionConfig,
1804
1754
  actions: toArray(transitionConfig.actions),
1805
- guard: transitionConfig.guard ? toGuardDefinition(transitionConfig.guard, guardType => guards[guardType]) : undefined,
1755
+ guard: transitionConfig.guard,
1806
1756
  target,
1807
1757
  source: stateNode,
1808
1758
  reenter,
@@ -2398,34 +2348,34 @@ function resolveActionsAndContext(actions, event, currentState, actorCtx) {
2398
2348
  _internalQueue: []
2399
2349
  });
2400
2350
  for (const action of actions) {
2401
- const resolved = typeof action === 'function' ? action : machine.implementations.actions[typeof action === 'string' ? action : action.type];
2351
+ const isInline = typeof action === 'function';
2352
+ const resolved = isInline ? action :
2353
+ // the existing type of `.actions` assumes non-nullable `TExpressionAction`
2354
+ // it's fine to cast this here to get a common type and lack of errors in the rest of the code
2355
+ // our logic below makes sure that we call those 2 "variants" correctly
2356
+ machine.implementations.actions[typeof action === 'string' ? action : action.type];
2402
2357
  if (!resolved) {
2403
2358
  continue;
2404
2359
  }
2405
- const args = {
2360
+ const actionArgs = {
2406
2361
  context: intermediateState.context,
2407
2362
  event,
2408
2363
  self: actorCtx?.self,
2409
2364
  system: actorCtx?.system,
2410
- // TODO: figure out story for `action` and inline actions
2411
- // what those ones should receive?
2412
- //
2413
- // entry: ({ action }) => {}
2414
- // exit: assign(({ action }) => {})
2415
- action: typeof action === 'string' ? {
2365
+ action: isInline ? undefined : typeof action === 'string' ? {
2416
2366
  type: action
2417
2367
  } : action
2418
2368
  };
2419
2369
  if (!('resolve' in resolved)) {
2420
2370
  if (actorCtx?.self.status === ActorStatus.Running) {
2421
- resolved(args);
2371
+ resolved(actionArgs);
2422
2372
  } else {
2423
- actorCtx?.defer(() => resolved(args));
2373
+ actorCtx?.defer(() => resolved(actionArgs));
2424
2374
  }
2425
2375
  continue;
2426
2376
  }
2427
2377
  const builtinAction = resolved;
2428
- const [nextState, params, actions] = builtinAction.resolve(actorCtx, intermediateState, args, resolved // this holds all params
2378
+ const [nextState, params, actions] = builtinAction.resolve(actorCtx, intermediateState, actionArgs, resolved // this holds all params
2429
2379
  );
2430
2380
 
2431
2381
  intermediateState = nextState;
@@ -2549,9 +2499,8 @@ class State {
2549
2499
  */
2550
2500
 
2551
2501
  /**
2552
- * The done data of the top-level finite state.
2502
+ * The output data of the top-level finite state.
2553
2503
  */
2554
- // TODO: add an explicit type for `output`
2555
2504
 
2556
2505
  /**
2557
2506
  * The enabled state nodes representative of the state value.
@@ -2974,8 +2923,7 @@ function resolve$1(_, state, actionArgs, {
2974
2923
  branches
2975
2924
  }) {
2976
2925
  const matchedActions = branches.find(condition => {
2977
- const guard = condition.guard && toGuardDefinition(condition.guard, guardType => state.machine.implementations.guards[guardType]);
2978
- return !guard || evaluateGuard(guard, state.context, actionArgs.event, state);
2926
+ return !condition.guard || evaluateGuard(condition.guard, state.context, actionArgs.event, state);
2979
2927
  })?.actions;
2980
2928
  return [state, undefined, toArray(matchedActions)];
2981
2929
  }
@@ -2992,7 +2940,7 @@ function resolve(_, state, args, {
2992
2940
  get
2993
2941
  }) {
2994
2942
  return [state, undefined, toArray(get({
2995
- context: state.context,
2943
+ context: args.context,
2996
2944
  event: args.event
2997
2945
  }))];
2998
2946
  }
@@ -3068,4 +3016,4 @@ function createInitEvent(input) {
3068
3016
  };
3069
3017
  }
3070
3018
 
3071
- export { fromObservable as $, microstep as A, isAtomicStateNode as B, isStateId as C, getStateNodeByPath as D, getPersistedState as E, resolveReferencedActor as F, createActor as G, matchesState as H, sendTo as I, sendParent as J, forwardTo as K, interpret as L, Actor as M, NULL_EVENT as N, ActorStatus as O, InterpreterStatus as P, doneInvoke as Q, cancel as R, STATE_DELIMITER as S, choose as T, log as U, pure as V, raise as W, stop as X, pathToStateValue as Y, toObserver as Z, fromPromise as _, toTransitionConfigArray as a, fromCallback as a0, fromEventObservable as a1, fromTransition as a2, stateIn as a3, not as a4, and as a5, or as a6, ConstantPrefix as a7, SpecialTargets as a8, startSignalType as a9, stopSignalType as aa, startSignal as ab, stopSignal as ac, isSignal as ad, isActorRef as ae, toActorRef as af, createEmptyActor as ag, toGuardDefinition as ah, constantPrefixes as ai, after as aj, done as ak, error as al, escalate as am, formatTransition as b, memo as c, flatten as d, evaluateGuard as e, formatTransitions as f, createInvokeId as g, getDelayedTransitions as h, formatInitialTransition as i, getCandidates as j, toInvokeConfig as k, getConfiguration as l, mapValues as m, getStateNodes as n, isInFinalState as o, State as p, isErrorEvent as q, resolveStateValue as r, cloneState as s, toArray as t, macrostep as u, transitionNode as v, getInitialConfiguration as w, resolveActionsAndContext as x, assign as y, createInitEvent as z };
3019
+ export { fromObservable as $, microstep as A, isAtomicStateNode as B, isStateId as C, getStateNodeByPath as D, getPersistedState as E, resolveReferencedActor as F, createActor as G, matchesState as H, sendTo as I, sendParent as J, forwardTo as K, interpret as L, Actor as M, NULL_EVENT as N, ActorStatus as O, InterpreterStatus as P, doneInvoke as Q, cancel as R, STATE_DELIMITER as S, choose as T, log as U, pure as V, raise as W, stop as X, pathToStateValue as Y, toObserver as Z, fromPromise as _, toTransitionConfigArray as a, fromCallback as a0, fromEventObservable as a1, fromTransition as a2, stateIn as a3, not as a4, and as a5, or as a6, ConstantPrefix as a7, SpecialTargets as a8, startSignalType as a9, stopSignalType as aa, startSignal as ab, stopSignal as ac, isSignal as ad, isActorRef as ae, toActorRef as af, createEmptyActor as ag, constantPrefixes as ah, after as ai, done as aj, error as ak, escalate as al, formatTransition as b, memo as c, flatten as d, evaluateGuard as e, formatTransitions as f, createInvokeId as g, getDelayedTransitions as h, formatInitialTransition as i, getCandidates as j, toInvokeConfig as k, getConfiguration as l, mapValues as m, getStateNodes as n, isInFinalState as o, State as p, isErrorEvent as q, resolveStateValue as r, cloneState as s, toArray as t, macrostep as u, transitionNode as v, getInitialConfiguration as w, resolveActionsAndContext as x, assign as y, createInitEvent as z };
@@ -1,4 +1,4 @@
1
- import { MachineConfig, EventObject, MachineContext, InternalMachineImplementations, ParameterizedObject, ProvidedActor, AnyEventObject } from "./types.js";
1
+ import { MachineConfig, EventObject, MachineContext, InternalMachineImplementations, ParameterizedObject, ProvidedActor, AnyEventObject, NonReducibleUnknown } from "./types.js";
2
2
  import { TypegenConstraint, TypegenDisabled, ResolveTypegenMeta } from "./typegenTypes.js";
3
3
  import { StateMachine } from "./StateMachine.js";
4
- export declare function createMachine<TContext extends MachineContext, TEvent extends EventObject = AnyEventObject, TActor extends ProvidedActor = ProvidedActor, TInput = any, TTypesMeta extends TypegenConstraint = TypegenDisabled>(config: MachineConfig<TContext, TEvent, ParameterizedObject, TActor, TInput, TTypesMeta>, implementations?: InternalMachineImplementations<TContext, TEvent, ParameterizedObject, TActor, ResolveTypegenMeta<TTypesMeta, TEvent, ParameterizedObject, TActor>>): StateMachine<TContext, TEvent, ParameterizedObject, TActor, TInput, ResolveTypegenMeta<TTypesMeta, TEvent, ParameterizedObject, TActor>>;
4
+ export declare function createMachine<TContext extends MachineContext, TEvent extends EventObject = AnyEventObject, TActor extends ProvidedActor = ProvidedActor, TAction extends ParameterizedObject = ParameterizedObject, TGuard extends ParameterizedObject = ParameterizedObject, TInput = any, TOutput = NonReducibleUnknown, TTypesMeta extends TypegenConstraint = TypegenDisabled>(config: MachineConfig<TContext, TEvent, TAction, TGuard, TActor, TInput, TOutput, TTypesMeta>, implementations?: InternalMachineImplementations<TContext, TEvent, TActor, TAction, ResolveTypegenMeta<TTypesMeta, TEvent, TActor, TAction, TGuard>>): StateMachine<TContext, TEvent, TActor, TAction, TGuard, TInput, TOutput, ResolveTypegenMeta<TTypesMeta, TEvent, TActor, TAction, TGuard>>;