xstate 5.0.0-beta.23 → 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 (41) 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-f6b5002d.development.esm.js → actions-194e6dcc.development.esm.js} +91 -134
  13. package/dist/{actions-0fcd4d15.development.cjs.js → actions-43f7d40e.development.cjs.js} +90 -134
  14. package/dist/{actions-e83129c5.cjs.js → actions-6a8cda73.cjs.js} +86 -138
  15. package/dist/{actions-bf7f6679.esm.js → actions-7b182232.esm.js} +87 -138
  16. package/dist/declarations/src/Machine.d.ts +1 -1
  17. package/dist/declarations/src/StateMachine.d.ts +8 -6
  18. package/dist/declarations/src/StateNode.d.ts +6 -6
  19. package/dist/declarations/src/actions/choose.d.ts +2 -2
  20. package/dist/declarations/src/actions/pure.d.ts +3 -2
  21. package/dist/declarations/src/actions/send.d.ts +1 -1
  22. package/dist/declarations/src/guards.d.ts +17 -8
  23. package/dist/declarations/src/stateUtils.d.ts +4 -4
  24. package/dist/declarations/src/typegenTypes.d.ts +6 -2
  25. package/dist/declarations/src/types.d.ts +77 -113
  26. package/dist/declarations/src/utils.d.ts +3 -3
  27. package/dist/xstate.cjs.js +5 -3
  28. package/dist/xstate.development.cjs.js +5 -3
  29. package/dist/xstate.development.esm.js +6 -4
  30. package/dist/xstate.esm.js +6 -4
  31. package/dist/xstate.umd.min.js +1 -1
  32. package/dist/xstate.umd.min.js.map +1 -1
  33. package/guards/dist/xstate-guards.cjs.js +1 -2
  34. package/guards/dist/xstate-guards.cjs.mjs +1 -2
  35. package/guards/dist/xstate-guards.development.cjs.js +1 -2
  36. package/guards/dist/xstate-guards.development.cjs.mjs +1 -2
  37. package/guards/dist/xstate-guards.development.esm.js +1 -1
  38. package/guards/dist/xstate-guards.esm.js +1 -1
  39. package/guards/dist/xstate-guards.umd.min.js +1 -1
  40. package/guards/dist/xstate-guards.umd.min.js.map +1 -1
  41. 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,
@@ -2409,7 +2359,7 @@ function resolveActionsAndContext(actions, event, currentState, actorCtx) {
2409
2359
  if (!resolved) {
2410
2360
  continue;
2411
2361
  }
2412
- const args = {
2362
+ const actionArgs = {
2413
2363
  context: intermediateState.context,
2414
2364
  event,
2415
2365
  self: actorCtx?.self,
@@ -2420,14 +2370,14 @@ function resolveActionsAndContext(actions, event, currentState, actorCtx) {
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;
@@ -2975,8 +2925,7 @@ function resolve$1(_, state, actionArgs, {
2975
2925
  branches
2976
2926
  }) {
2977
2927
  const matchedActions = branches.find(condition => {
2978
- const guard = condition.guard && toGuardDefinition(condition.guard, guardType => state.machine.implementations.guards[guardType]);
2979
- return !guard || evaluateGuard(guard, state.context, actionArgs.event, state);
2928
+ return !condition.guard || evaluateGuard(condition.guard, state.context, actionArgs.event, state);
2980
2929
  })?.actions;
2981
2930
  return [state, undefined, toArray(matchedActions)];
2982
2931
  }
@@ -3141,7 +3090,6 @@ exports.stopSignal = stopSignal;
3141
3090
  exports.stopSignalType = stopSignalType;
3142
3091
  exports.toActorRef = toActorRef;
3143
3092
  exports.toArray = toArray;
3144
- exports.toGuardDefinition = toGuardDefinition;
3145
3093
  exports.toInvokeConfig = toInvokeConfig;
3146
3094
  exports.toObserver = toObserver;
3147
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,
@@ -2407,7 +2357,7 @@ function resolveActionsAndContext(actions, event, currentState, actorCtx) {
2407
2357
  if (!resolved) {
2408
2358
  continue;
2409
2359
  }
2410
- const args = {
2360
+ const actionArgs = {
2411
2361
  context: intermediateState.context,
2412
2362
  event,
2413
2363
  self: actorCtx?.self,
@@ -2418,14 +2368,14 @@ function resolveActionsAndContext(actions, event, currentState, actorCtx) {
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;
@@ -2973,8 +2923,7 @@ function resolve$1(_, state, actionArgs, {
2973
2923
  branches
2974
2924
  }) {
2975
2925
  const matchedActions = branches.find(condition => {
2976
- const guard = condition.guard && toGuardDefinition(condition.guard, guardType => state.machine.implementations.guards[guardType]);
2977
- return !guard || evaluateGuard(guard, state.context, actionArgs.event, state);
2926
+ return !condition.guard || evaluateGuard(condition.guard, state.context, actionArgs.event, state);
2978
2927
  })?.actions;
2979
2928
  return [state, undefined, toArray(matchedActions)];
2980
2929
  }
@@ -3067,4 +3016,4 @@ function createInitEvent(input) {
3067
3016
  };
3068
3017
  }
3069
3018
 
3070
- 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
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, TOutput = NonReducibleUnknown, TAction extends ParameterizedObject = ParameterizedObject, TTypesMeta extends TypegenConstraint = TypegenDisabled>(config: MachineConfig<TContext, TEvent, TAction, TActor, TInput, TOutput, TTypesMeta>, implementations?: InternalMachineImplementations<TContext, TEvent, TAction, TActor, ResolveTypegenMeta<TTypesMeta, TEvent, TAction, TActor>>): StateMachine<TContext, TEvent, TAction, TActor, TInput, TOutput, ResolveTypegenMeta<TTypesMeta, TEvent, TAction, 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>>;
@@ -4,17 +4,17 @@ import type { AreAllImplementationsAssumedToBeProvided, MarkAllImplementationsAs
4
4
  import type { ActorContext, ActorLogic, EventObject, InternalMachineImplementations, MachineConfig, MachineContext, MachineImplementationsSimplified, MachineTypes, NoInfer, StateConfig, StateMachineDefinition, StateValue, TransitionDefinition, PersistedMachineState, ParameterizedObject, AnyActorContext, ProvidedActor, Equals, TODO } from "./types.js";
5
5
  export declare const STATE_IDENTIFIER = "#";
6
6
  export declare const WILDCARD = "*";
7
- export declare class StateMachine<TContext extends MachineContext, TEvent extends EventObject, TAction extends ParameterizedObject, TActor extends ProvidedActor, TInput, TOutput, TResolvedTypesMeta = ResolveTypegenMeta<TypegenDisabled, NoInfer<TEvent>, TAction, TActor>> implements ActorLogic<TEvent, State<TContext, TEvent, TActor, TOutput, TResolvedTypesMeta>, State<TContext, TEvent, TActor, TOutput, TResolvedTypesMeta>, PersistedMachineState<State<TContext, TEvent, TActor, TOutput, TResolvedTypesMeta>>, TODO, TInput, TOutput> {
7
+ export declare class StateMachine<TContext extends MachineContext, TEvent extends EventObject, TActor extends ProvidedActor, TAction extends ParameterizedObject, TGuard extends ParameterizedObject, TInput, TOutput, TResolvedTypesMeta = ResolveTypegenMeta<TypegenDisabled, NoInfer<TEvent>, TActor, TAction, TGuard>> implements ActorLogic<TEvent, State<TContext, TEvent, TActor, TOutput, TResolvedTypesMeta>, State<TContext, TEvent, TActor, TOutput, TResolvedTypesMeta>, PersistedMachineState<State<TContext, TEvent, TActor, TOutput, TResolvedTypesMeta>>, TODO, TInput, TOutput> {
8
8
  /**
9
9
  * The raw config used to create the machine.
10
10
  */
11
- config: MachineConfig<TContext, TEvent, any, any, any, TOutput, any>;
11
+ config: MachineConfig<TContext, TEvent, any, any, any, any, TOutput, any>;
12
12
  /**
13
13
  * The machine's own version.
14
14
  */
15
15
  version?: string;
16
16
  implementations: MachineImplementationsSimplified<TContext, TEvent>;
17
- types: MachineTypes<TContext, TEvent, TAction, TActor, TInput, TOutput>;
17
+ types: MachineTypes<TContext, TEvent, TAction, TGuard, TActor, TInput, TOutput, TResolvedTypesMeta>;
18
18
  __xstatenode: true;
19
19
  idMap: Map<string, StateNode<TContext, TEvent>>;
20
20
  root: StateNode<TContext, TEvent>;
@@ -25,7 +25,7 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
25
25
  /**
26
26
  * The raw config used to create the machine.
27
27
  */
28
- config: MachineConfig<TContext, TEvent, any, any, any, TOutput, any>, implementations?: MachineImplementationsSimplified<TContext, TEvent>);
28
+ config: MachineConfig<TContext, TEvent, any, any, any, any, TOutput, any>, implementations?: MachineImplementationsSimplified<TContext, TEvent>);
29
29
  /**
30
30
  * Clones this state machine with the provided implementations
31
31
  * and merges the `context` (if provided).
@@ -35,7 +35,7 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
35
35
  *
36
36
  * @returns A new `StateMachine` instance with the provided implementations.
37
37
  */
38
- provide(implementations: InternalMachineImplementations<TContext, TEvent, TAction, TActor, TResolvedTypesMeta, true>): StateMachine<TContext, TEvent, TAction, TActor, TInput, TOutput, AreAllImplementationsAssumedToBeProvided<TResolvedTypesMeta> extends false ? MarkAllImplementationsAsProvided<TResolvedTypesMeta> : TResolvedTypesMeta>;
38
+ provide(implementations: InternalMachineImplementations<TContext, TEvent, TActor, TAction, TResolvedTypesMeta, true>): StateMachine<TContext, TEvent, TActor, TAction, TGuard, TInput, TOutput, AreAllImplementationsAssumedToBeProvided<TResolvedTypesMeta> extends false ? MarkAllImplementationsAsProvided<TResolvedTypesMeta> : TResolvedTypesMeta>;
39
39
  /**
40
40
  * Resolves the given `state` to a new `State` instance relative to this machine.
41
41
  *
@@ -93,9 +93,11 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
93
93
  /** @deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
94
94
  __TEvent: TEvent;
95
95
  /** @deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
96
+ __TActor: TActor;
97
+ /** @deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
96
98
  __TAction: TAction;
97
99
  /** @deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
98
- __TActor: TActor;
100
+ __TGuard: TGuard;
99
101
  /** @deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
100
102
  __TInput: TInput;
101
103
  /** @deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */