xstate 6.0.0-alpha.2 → 6.0.0-alpha.3

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 (36) hide show
  1. package/dist/{StateMachine-8d22a79c.development.cjs.js → StateMachine-0770ac71.development.cjs.js} +1 -1
  2. package/dist/{StateMachine-2dcdb1f5.esm.js → StateMachine-8249d511.esm.js} +1 -1
  3. package/dist/{StateMachine-64813f46.cjs.js → StateMachine-e1048cd6.cjs.js} +1 -1
  4. package/dist/{StateMachine-2ea0a7fa.development.esm.js → StateMachine-e6ad61d0.development.esm.js} +1 -1
  5. package/dist/declarations/src/StateMachine.d.ts +4 -4
  6. package/dist/declarations/src/createActor.d.ts +0 -2
  7. package/dist/declarations/src/index.d.ts +1 -3
  8. package/dist/declarations/src/serialize.d.ts +13 -8
  9. package/dist/declarations/src/types.d.ts +0 -4
  10. package/dist/declarations/src/types.v6.d.ts +11 -9
  11. package/dist/{index-f6ef20d1.development.cjs.js → index-269d256d.development.cjs.js} +10 -689
  12. package/dist/{index-e61170ba.development.esm.js → index-66ff64a6.development.esm.js} +11 -685
  13. package/dist/{index-93edd3bd.esm.js → index-a7e3d8b3.esm.js} +11 -685
  14. package/dist/{index-9cb3b3a0.cjs.js → index-dda021d5.cjs.js} +10 -689
  15. package/dist/xstate-actors.cjs.js +1 -1
  16. package/dist/xstate-actors.development.cjs.js +1 -1
  17. package/dist/xstate-actors.development.esm.js +1 -1
  18. package/dist/xstate-actors.esm.js +1 -1
  19. package/dist/xstate-actors.umd.min.js +1 -1
  20. package/dist/xstate-actors.umd.min.js.map +1 -1
  21. package/dist/xstate-graph.cjs.js +2 -2
  22. package/dist/xstate-graph.development.cjs.js +2 -2
  23. package/dist/xstate-graph.development.esm.js +2 -2
  24. package/dist/xstate-graph.esm.js +2 -2
  25. package/dist/xstate-graph.umd.min.js +1 -1
  26. package/dist/xstate-graph.umd.min.js.map +1 -1
  27. package/dist/xstate.cjs.js +85 -32
  28. package/dist/xstate.cjs.mjs +0 -5
  29. package/dist/xstate.development.cjs.js +85 -32
  30. package/dist/xstate.development.cjs.mjs +0 -5
  31. package/dist/xstate.development.esm.js +87 -29
  32. package/dist/xstate.esm.js +87 -29
  33. package/dist/xstate.umd.min.js +1 -1
  34. package/dist/xstate.umd.min.js.map +1 -1
  35. package/package.json +1 -1
  36. package/dist/declarations/src/atom.d.ts +0 -81
@@ -1,18 +1,5 @@
1
1
  'use strict';
2
2
 
3
- /**
4
- * Reactivity interop between actors and atoms.
5
- *
6
- * `Actor#get()` calls this hook (when installed) so that computed atoms can
7
- * track actor reads as dependencies. The hook is installed by `atom.ts` on
8
- * module evaluation, which only happens when atoms are actually used — apps
9
- * that never import atoms don't bundle the reactive system.
10
- */
11
- let onActorRead;
12
- function installActorReadHook(hook) {
13
- onActorRead = hook;
14
- }
15
-
16
3
  class Mailbox {
17
4
  constructor(_process) {
18
5
  this._process = _process;
@@ -204,10 +191,9 @@ function createAttachedLogic(attach) {
204
191
  self,
205
192
  system
206
193
  }) => {
207
- // Don't attach if the target doesn't exist, or (for actors) is stopped.
208
- // Atoms have no `getSnapshot` / lifecycle, so they always attach.
194
+ // Don't attach if the target doesn't exist or is stopped.
209
195
  const target = state.input.actor;
210
- if (!target || typeof target.getSnapshot === 'function' && target.getSnapshot().status === 'stopped') {
196
+ if (!target || target.getSnapshot().status === 'stopped') {
211
197
  return;
212
198
  }
213
199
  const subscription = attach(state.input, {
@@ -309,620 +295,6 @@ function createListenerLogic() {
309
295
  // Singleton logic instance
310
296
  const listenerLogic = /* #__PURE__ */createListenerLogic();
311
297
 
312
- /* eslint-disable */
313
- // Adapted from Alien Signals
314
- // https://github.com/stackblitz/alien-signals/
315
-
316
- let ReactiveFlags = /*#__PURE__*/function (ReactiveFlags) {
317
- ReactiveFlags[ReactiveFlags["None"] = 0] = "None";
318
- ReactiveFlags[ReactiveFlags["Mutable"] = 1] = "Mutable";
319
- ReactiveFlags[ReactiveFlags["Watching"] = 2] = "Watching";
320
- ReactiveFlags[ReactiveFlags["RecursedCheck"] = 4] = "RecursedCheck";
321
- ReactiveFlags[ReactiveFlags["Recursed"] = 8] = "Recursed";
322
- ReactiveFlags[ReactiveFlags["Dirty"] = 16] = "Dirty";
323
- ReactiveFlags[ReactiveFlags["Pending"] = 32] = "Pending";
324
- return ReactiveFlags;
325
- }({});
326
- function createReactiveSystem({
327
- update,
328
- notify,
329
- unwatched
330
- }) {
331
- return {
332
- link,
333
- unlink,
334
- propagate,
335
- checkDirty,
336
- shallowPropagate
337
- };
338
- function link(dep, sub, version) {
339
- const prevDep = sub.depsTail;
340
- if (prevDep !== undefined && prevDep.dep === dep) {
341
- return;
342
- }
343
- const nextDep = prevDep !== undefined ? prevDep.nextDep : sub.deps;
344
- if (nextDep !== undefined && nextDep.dep === dep) {
345
- nextDep.version = version;
346
- sub.depsTail = nextDep;
347
- return;
348
- }
349
- const prevSub = dep.subsTail;
350
- if (prevSub !== undefined && prevSub.version === version && prevSub.sub === sub) {
351
- return;
352
- }
353
- const newLink = sub.depsTail = dep.subsTail = {
354
- version,
355
- dep,
356
- sub,
357
- prevDep,
358
- nextDep,
359
- prevSub,
360
- nextSub: undefined
361
- };
362
- if (nextDep !== undefined) {
363
- nextDep.prevDep = newLink;
364
- }
365
- if (prevDep !== undefined) {
366
- prevDep.nextDep = newLink;
367
- } else {
368
- sub.deps = newLink;
369
- }
370
- if (prevSub !== undefined) {
371
- prevSub.nextSub = newLink;
372
- } else {
373
- dep.subs = newLink;
374
- }
375
- }
376
- function unlink(link, sub = link.sub) {
377
- const dep = link.dep;
378
- const prevDep = link.prevDep;
379
- const nextDep = link.nextDep;
380
- const nextSub = link.nextSub;
381
- const prevSub = link.prevSub;
382
- if (nextDep !== undefined) {
383
- nextDep.prevDep = prevDep;
384
- } else {
385
- sub.depsTail = prevDep;
386
- }
387
- if (prevDep !== undefined) {
388
- prevDep.nextDep = nextDep;
389
- } else {
390
- sub.deps = nextDep;
391
- }
392
- if (nextSub !== undefined) {
393
- nextSub.prevSub = prevSub;
394
- } else {
395
- dep.subsTail = prevSub;
396
- }
397
- if (prevSub !== undefined) {
398
- prevSub.nextSub = nextSub;
399
- } else if ((dep.subs = nextSub) === undefined) {
400
- unwatched(dep);
401
- }
402
- return nextDep;
403
- }
404
- function propagate(link) {
405
- let next = link.nextSub;
406
- let stack;
407
- top: do {
408
- const sub = link.sub;
409
- let flags = sub.flags;
410
- if (!(flags & (ReactiveFlags.RecursedCheck | ReactiveFlags.Recursed | ReactiveFlags.Dirty | ReactiveFlags.Pending))) {
411
- sub.flags = flags | ReactiveFlags.Pending;
412
- } else if (!(flags & (ReactiveFlags.RecursedCheck | ReactiveFlags.Recursed))) {
413
- flags = ReactiveFlags.None;
414
- } else if (!(flags & ReactiveFlags.RecursedCheck)) {
415
- sub.flags = flags & ~ReactiveFlags.Recursed | ReactiveFlags.Pending;
416
- } else if (!(flags & (ReactiveFlags.Dirty | ReactiveFlags.Pending)) && isValidLink(link, sub)) {
417
- sub.flags = flags | (ReactiveFlags.Recursed | ReactiveFlags.Pending);
418
- flags &= ReactiveFlags.Mutable;
419
- } else {
420
- flags = ReactiveFlags.None;
421
- }
422
- if (flags & ReactiveFlags.Watching) {
423
- notify(sub);
424
- }
425
- if (flags & ReactiveFlags.Mutable) {
426
- const subSubs = sub.subs;
427
- if (subSubs !== undefined) {
428
- const nextSub = (link = subSubs).nextSub;
429
- if (nextSub !== undefined) {
430
- stack = {
431
- value: next,
432
- prev: stack
433
- };
434
- next = nextSub;
435
- }
436
- continue;
437
- }
438
- }
439
- if ((link = next) !== undefined) {
440
- next = link.nextSub;
441
- continue;
442
- }
443
- while (stack !== undefined) {
444
- link = stack.value;
445
- stack = stack.prev;
446
- if (link !== undefined) {
447
- next = link.nextSub;
448
- continue top;
449
- }
450
- }
451
- break;
452
- } while (true);
453
- }
454
- function checkDirty(link, sub) {
455
- let stack;
456
- let checkDepth = 0;
457
- let dirty = false;
458
- top: do {
459
- const dep = link.dep;
460
- const flags = dep.flags;
461
- if (sub.flags & ReactiveFlags.Dirty) {
462
- dirty = true;
463
- } else if ((flags & (ReactiveFlags.Mutable | ReactiveFlags.Dirty)) === (ReactiveFlags.Mutable | ReactiveFlags.Dirty)) {
464
- if (update(dep)) {
465
- const subs = dep.subs;
466
- if (subs.nextSub !== undefined) {
467
- shallowPropagate(subs);
468
- }
469
- dirty = true;
470
- }
471
- } else if ((flags & (ReactiveFlags.Mutable | ReactiveFlags.Pending)) === (ReactiveFlags.Mutable | ReactiveFlags.Pending)) {
472
- if (link.nextSub !== undefined || link.prevSub !== undefined) {
473
- stack = {
474
- value: link,
475
- prev: stack
476
- };
477
- }
478
- link = dep.deps;
479
- sub = dep;
480
- ++checkDepth;
481
- continue;
482
- }
483
- if (!dirty) {
484
- const nextDep = link.nextDep;
485
- if (nextDep !== undefined) {
486
- link = nextDep;
487
- continue;
488
- }
489
- }
490
- while (checkDepth--) {
491
- const firstSub = sub.subs;
492
- const hasMultipleSubs = firstSub.nextSub !== undefined;
493
- if (hasMultipleSubs) {
494
- link = stack.value;
495
- stack = stack.prev;
496
- } else {
497
- link = firstSub;
498
- }
499
- if (dirty) {
500
- if (update(sub)) {
501
- if (hasMultipleSubs) {
502
- shallowPropagate(firstSub);
503
- }
504
- sub = link.sub;
505
- continue;
506
- }
507
- dirty = false;
508
- } else {
509
- sub.flags &= ~ReactiveFlags.Pending;
510
- }
511
- sub = link.sub;
512
- const nextDep = link.nextDep;
513
- if (nextDep !== undefined) {
514
- link = nextDep;
515
- continue top;
516
- }
517
- }
518
- return dirty;
519
- } while (true);
520
- }
521
- function shallowPropagate(link) {
522
- do {
523
- const sub = link.sub;
524
- const flags = sub.flags;
525
- if ((flags & (ReactiveFlags.Pending | ReactiveFlags.Dirty)) === ReactiveFlags.Pending) {
526
- sub.flags = flags | ReactiveFlags.Dirty;
527
- if ((flags & (ReactiveFlags.Watching | ReactiveFlags.RecursedCheck)) === ReactiveFlags.Watching) {
528
- notify(sub);
529
- }
530
- }
531
- } while ((link = link.nextSub) !== undefined);
532
- }
533
- function isValidLink(checkLink, sub) {
534
- let link = sub.depsTail;
535
- while (link !== undefined) {
536
- if (link === checkLink) {
537
- return true;
538
- }
539
- link = link.prevDep;
540
- }
541
- return false;
542
- }
543
- }
544
-
545
- /**
546
- * Nominal brand (phantom, compile-time only) marking a value as an XState atom.
547
- * Real atoms get the runtime brand ({@link $$atom}) in `createAtom`; this type
548
- * brand keeps atom-only APIs (e.g. `enq.subscribeTo`) from structurally
549
- * accepting plain readables like `actor.select(...)` that would be dispatched
550
- * down the non-atom path at runtime.
551
- */
552
-
553
- /** Brand marking an object as an atom, so it can be detected structurally. */
554
- const $$atom = /* #__PURE__ */Symbol.for('xstate.atom');
555
-
556
- /**
557
- * Returns `true` if the value is an atom (writable, computed, async, or
558
- * reducer). Lets actor-consuming APIs (e.g. `enq.subscribeTo`) accept atoms
559
- * directly.
560
- */
561
- function isAtom(value) {
562
- return !!value && typeof value === 'object' && $$atom in value;
563
- }
564
- const queuedEffects = [];
565
- let cycle = 0;
566
- // Initialized lazily on first atom creation (instead of at module evaluation)
567
- // so the reactive system stays tree-shakeable for apps that never use atoms —
568
-
569
- // would be retained by consumer bundlers even when atoms are unused.
570
- let link;
571
- let unlink;
572
- let propagate;
573
- let checkDirty;
574
- let shallowPropagate;
575
- let reactiveSystemInstalled = false;
576
- function ensureReactiveSystem() {
577
- if (reactiveSystemInstalled) {
578
- return;
579
- }
580
- reactiveSystemInstalled = true;
581
- ({
582
- link,
583
- unlink,
584
- propagate,
585
- checkDirty,
586
- shallowPropagate
587
- } = createReactiveSystem({
588
- update(atom) {
589
- return atom._update();
590
- },
591
- notify(effect) {
592
- queuedEffects[queuedEffectsLength++] = effect;
593
- effect.flags &= ~ReactiveFlags.Watching;
594
- },
595
- unwatched(atom) {
596
- if (atom.depsTail !== undefined) {
597
- atom.depsTail = undefined;
598
- atom.flags = ReactiveFlags.Mutable | ReactiveFlags.Dirty;
599
- purgeDeps(atom);
600
- }
601
- }
602
- }));
603
- }
604
- let notifyIndex = 0;
605
- let queuedEffectsLength = 0;
606
- let activeSub;
607
- function purgeDeps(sub) {
608
- const depsTail = sub.depsTail;
609
- let dep = depsTail !== undefined ? depsTail.nextDep : sub.deps;
610
- while (dep !== undefined) {
611
- dep = unlink(dep, sub);
612
- }
613
- }
614
- function flush() {
615
- while (notifyIndex < queuedEffectsLength) {
616
- const effect = queuedEffects[notifyIndex];
617
- queuedEffects[notifyIndex++] = undefined;
618
- effect.notify();
619
- }
620
- notifyIndex = 0;
621
- queuedEffectsLength = 0;
622
- }
623
-
624
- /** The current state of an async atom. */
625
-
626
- /** Options passed to an async atom getter. */
627
-
628
- function compareAsyncAtomState(a, b) {
629
- if (a.status !== b.status) {
630
- return false;
631
- }
632
- if (a.status === 'done' && b.status === 'done') {
633
- return Object.is(a.data, b.data);
634
- }
635
- if (a.status === 'error' && b.status === 'error') {
636
- return Object.is(a.error, b.error);
637
- }
638
- // both 'pending'
639
- return true;
640
- }
641
- function updateAsyncAtom(atom, nextValue) {
642
- if (atom._update(nextValue)) {
643
- const subs = atom.subs;
644
- if (subs !== undefined) {
645
- propagate(subs);
646
- shallowPropagate(subs);
647
- flush();
648
- }
649
- }
650
- }
651
-
652
- /**
653
- * Creates a read-only atom whose value is loaded from an async getter.
654
- *
655
- * The getter receives an `AbortSignal`; when the async atom recomputes, the
656
- * previous signal is aborted and stale resolutions are ignored.
657
- */
658
- function createAsyncAtom(getValue, options) {
659
- const ref = {};
660
- let currentController;
661
- let currentRunId = 0;
662
- const atom = createAtom(() => {
663
- currentController?.abort();
664
- const controller = new AbortController();
665
- const runId = ++currentRunId;
666
- currentController = controller;
667
- getValue({
668
- signal: controller.signal
669
- }).then(data => {
670
- if (runId !== currentRunId || controller.signal.aborted) {
671
- return;
672
- }
673
- updateAsyncAtom(ref.current, {
674
- status: 'done',
675
- data
676
- });
677
- }, error => {
678
- if (runId !== currentRunId || controller.signal.aborted) {
679
- return;
680
- }
681
- updateAsyncAtom(ref.current, {
682
- status: 'error',
683
- error
684
- });
685
- });
686
- return {
687
- status: 'pending'
688
- };
689
- }, {
690
- compare: compareAsyncAtomState,
691
- ...options
692
- });
693
- ref.current = atom;
694
- return atom;
695
- }
696
-
697
- /**
698
- * Mirror atoms that bump a version whenever a tracked actor emits a snapshot,
699
- * letting computed atoms depend on `actor.get()` reads.
700
- *
701
- * The hook is installed lazily on first atom creation (not at module
702
- * evaluation) so that it remains tree-shakeable for apps that never use atoms —
703
- * any tracked read necessarily happens inside an atom computation, so first-use
704
- * installation is always early enough.
705
- */
706
- let actorInteropInstalled = false;
707
- function ensureActorInterop() {
708
- if (actorInteropInstalled) {
709
- return;
710
- }
711
- actorInteropInstalled = true;
712
- const actorVersions = new WeakMap();
713
- installActorReadHook(actorRef => {
714
- if (activeSub === undefined) {
715
- return;
716
- }
717
- let version = actorVersions.get(actorRef);
718
- if (version === undefined) {
719
- version = createAtom(0);
720
- actorVersions.set(actorRef, version);
721
- actorRef.subscribe({
722
- next: () => version.set(v => v + 1),
723
- error: () => {}
724
- });
725
- }
726
- version.get();
727
- });
728
- }
729
-
730
- /**
731
- * Creates an atom.
732
- *
733
- * Pass a value for a writable atom or a getter for a computed read-only atom.
734
- */
735
-
736
- function createAtom(valueOrFn, optionsOrInput) {
737
- ensureReactiveSystem();
738
- ensureActorInterop();
739
- const isComputed = typeof valueOrFn === 'function';
740
- const getter = valueOrFn;
741
-
742
- // Create plain object atom
743
- const atom = {
744
- _snapshot: isComputed ? undefined : valueOrFn,
745
- subs: undefined,
746
- subsTail: undefined,
747
- deps: undefined,
748
- depsTail: undefined,
749
- flags: isComputed ? ReactiveFlags.None : ReactiveFlags.Mutable,
750
- get() {
751
- if (activeSub !== undefined) {
752
- link(atom, activeSub, cycle);
753
- }
754
- return atom._snapshot;
755
- },
756
- subscribe(observerOrFn) {
757
- const observer = typeof observerOrFn === 'function' ? {
758
- next: observerOrFn
759
- } : observerOrFn;
760
- const observed = {
761
- current: false
762
- };
763
- const e = effect(() => {
764
- atom.get();
765
- if (!observed.current) {
766
- observed.current = true;
767
- } else {
768
- const prevSub = activeSub;
769
- activeSub = undefined;
770
- try {
771
- observer.next?.(atom._snapshot);
772
- } catch (err) {
773
- reportUnhandledError(err);
774
- } finally {
775
- activeSub = prevSub;
776
- }
777
-
778
- // If the observer synchronously updates any of our deps we'll be
779
- // marked as dirty preventing this effect from re-running. Request
780
- // the value again to reconcile any dirty deps.
781
- atom.get();
782
- }
783
- });
784
- return {
785
- unsubscribe: () => {
786
- e.stop();
787
- }
788
- };
789
- },
790
- _update(getValue) {
791
- const prevSub = activeSub;
792
- const compare = optionsOrInput?.compare ?? Object.is;
793
- activeSub = atom;
794
- ++cycle;
795
- atom.depsTail = undefined;
796
- if (isComputed) {
797
- atom.flags = ReactiveFlags.Mutable | ReactiveFlags.RecursedCheck;
798
- }
799
- try {
800
- const oldValue = atom._snapshot;
801
- const newValue = typeof getValue === 'function' ? getValue(oldValue) : getValue === undefined && isComputed ? getter(oldValue) : getValue;
802
- if (oldValue === undefined || !compare(oldValue, newValue)) {
803
- atom._snapshot = newValue;
804
- return true;
805
- }
806
- return false;
807
- } finally {
808
- activeSub = prevSub;
809
- if (isComputed) {
810
- atom.flags &= ~ReactiveFlags.RecursedCheck;
811
- }
812
- purgeDeps(atom);
813
- }
814
- }
815
- };
816
- if (isComputed) {
817
- atom.flags = ReactiveFlags.Mutable | ReactiveFlags.Dirty;
818
- atom.get = function () {
819
- const flags = atom.flags;
820
- if (flags & ReactiveFlags.Dirty || flags & ReactiveFlags.Pending && checkDirty(atom.deps, atom)) {
821
- if (atom._update()) {
822
- const subs = atom.subs;
823
- if (subs !== undefined) {
824
- shallowPropagate(subs);
825
- }
826
- }
827
- } else if (flags & ReactiveFlags.Pending) {
828
- atom.flags = flags & ~ReactiveFlags.Pending;
829
- }
830
- if (activeSub !== undefined) {
831
- link(atom, activeSub, cycle);
832
- }
833
- return atom._snapshot;
834
- };
835
- } else {
836
- atom.set = function (valueOrFn) {
837
- if (atom._update(valueOrFn)) {
838
- const subs = atom.subs;
839
- if (subs !== undefined) {
840
- propagate(subs);
841
- shallowPropagate(subs);
842
- flush();
843
- }
844
- }
845
- };
846
- }
847
- atom[$$atom] = true;
848
- return atom;
849
- }
850
-
851
- /**
852
- * Creates an inert atom config that can be instantiated later.
853
- *
854
- * Useful for framework hooks that need to create a stable local atom from
855
- * component input.
856
- */
857
-
858
- function createAtomConfig(initialValueOrFn, options) {
859
- return {
860
- createAtom(input) {
861
- const initialValue = typeof initialValueOrFn === 'function' ? initialValueOrFn(input) : initialValueOrFn;
862
- return createAtom(initialValue, options);
863
- }
864
- };
865
- }
866
-
867
- /** Creates an atom whose updates are handled by a reducer function. */
868
- function createReducerAtom(initialValue, reducer, options) {
869
- const atom = createAtom(initialValue, options);
870
- return {
871
- [$$atom]: true,
872
- get: atom.get.bind(atom),
873
- subscribe: atom.subscribe.bind(atom),
874
- send(event) {
875
- const prevSub = activeSub;
876
- activeSub = undefined;
877
- let nextState;
878
- try {
879
- nextState = reducer(atom.get(), event);
880
- } finally {
881
- activeSub = prevSub;
882
- }
883
- atom.set(nextState);
884
- }
885
- };
886
- }
887
- function effect(fn) {
888
- const run = () => {
889
- const prevSub = activeSub;
890
- activeSub = effectObj;
891
- ++cycle;
892
- effectObj.depsTail = undefined;
893
- effectObj.flags = ReactiveFlags.Watching | ReactiveFlags.RecursedCheck;
894
- try {
895
- return fn();
896
- } finally {
897
- activeSub = prevSub;
898
- effectObj.flags &= ~ReactiveFlags.RecursedCheck;
899
- purgeDeps(effectObj);
900
- }
901
- };
902
- const effectObj = {
903
- deps: undefined,
904
- depsTail: undefined,
905
- subs: undefined,
906
- subsTail: undefined,
907
- flags: ReactiveFlags.Watching | ReactiveFlags.RecursedCheck,
908
- notify() {
909
- const flags = this.flags;
910
- if (flags & ReactiveFlags.Dirty || flags & ReactiveFlags.Pending && checkDirty(this.deps, this)) {
911
- run();
912
- } else {
913
- this.flags = ReactiveFlags.Watching;
914
- }
915
- },
916
- stop() {
917
- this.flags = ReactiveFlags.None;
918
- this.depsTail = undefined;
919
- purgeDeps(this);
920
- }
921
- };
922
- run();
923
- return effectObj;
924
- }
925
-
926
298
  /**
927
299
  * Creates actor logic for subscribing to lifecycle events (done/error/snapshot)
928
300
  * from another actor. Used internally by `enq.subscribeTo()`.
@@ -940,15 +312,6 @@ function createSubscriptionLogic() {
940
312
  error,
941
313
  snapshot: onSnapshot
942
314
  } = mappers;
943
-
944
- // Atoms emit a raw value (no `status`) and have no done/error lifecycle —
945
- // pass the value straight to the `snapshot` mapper.
946
- if (isAtom(actor)) {
947
- if (!onSnapshot) {
948
- return;
949
- }
950
- return actor.subscribe(value => relayMappedToParent(self, system, () => onSnapshot(value)));
951
- }
952
315
  return actor.subscribe({
953
316
  next: snapshot => {
954
317
  if (snapshot.status === 'done' && done) {
@@ -1506,27 +869,13 @@ function formatRouteTransitions(rootStateNode) {
1506
869
  if ('$unserializable' in routeConfig) {
1507
870
  throw new Error(`State "${sn.id}" has a route that is not serializable. Re-provide the route function when reviving this machine.`);
1508
871
  }
1509
-
1510
- // Object-form route. A `guard` (string or function) on the object is
1511
- // only produced by the JSON layer (createMachineFromConfig) —
1512
- // authoring uses the function form above.
1513
- const userGuard = routeConfig.guard;
872
+ const {
873
+ guard: _guard,
874
+ ...routeOptions
875
+ } = routeConfig;
1514
876
  const transition = {
1515
- ...routeConfig,
1516
- guard: userGuard ? args => {
1517
- if (!routeMatches(args)) return false;
1518
- if (typeof userGuard === 'function') return userGuard(args);
1519
- if (typeof userGuard === 'string') {
1520
- const guardImpl = args.guards?.[userGuard];
1521
- if (!guardImpl) {
1522
- // A typo'd guard name must fail loudly — silently passing
1523
- // would allow the route and corrupt machine behavior.
1524
- throw new Error(`Guard '${userGuard}' is not implemented in machine '${rootStateNode.machine.id}'.`);
1525
- }
1526
- return guardImpl(args);
1527
- }
1528
- return true;
1529
- } : routeMatches,
877
+ ...routeOptions,
878
+ guard: routeMatches,
1530
879
  target: `#${routeId}`
1531
880
  };
1532
881
  routeTransitions.push(formatTransition(rootStateNode, 'xstate.route', transition));
@@ -2524,24 +1873,7 @@ function evaluateCandidate(candidate, event, snapshot, stateNode, self) {
2524
1873
  delays: stateNode.machine.implementations.delays,
2525
1874
  _snapshot: snapshot
2526
1875
  };
2527
- const guardConfig = candidate.guard;
2528
- const guardParams = typeof guardConfig?.params === 'function' ? guardConfig.params({
2529
- context: snapshot.context,
2530
- event
2531
- }) : guardConfig?.params;
2532
- let guardPassed = true;
2533
- if (typeof guardConfig === 'function') {
2534
- guardPassed = guardConfig(guardArgs, guardParams);
2535
- } else if (typeof guardConfig?.type === 'string') {
2536
- const guardImpl = stateNode.machine.implementations.guards[guardConfig.type];
2537
- if (!guardImpl) {
2538
- // A typo'd guard name must fail loudly — silently passing would
2539
- // take the guarded transition and corrupt machine behavior.
2540
- throw new Error(`Guard '${guardConfig.type}' is not implemented in machine '${stateNode.machine.id}'.`);
2541
- }
2542
- guardPassed = guardImpl(guardArgs, guardParams);
2543
- }
2544
- if (!guardPassed) {
1876
+ if (!candidate.guard(guardArgs)) {
2545
1877
  return false;
2546
1878
  }
2547
1879
  }
@@ -3828,7 +3160,7 @@ class Actor {
3828
3160
  complete: observer.complete
3829
3161
  });
3830
3162
  },
3831
- get: () => selector(this.get())
3163
+ get: () => selector(this.getSnapshot())
3832
3164
  };
3833
3165
  }
3834
3166
 
@@ -4107,12 +3439,6 @@ class Actor {
4107
3439
  * @see {@link Actor.getPersistedSnapshot} to persist the internal state of an actor (which is more than just a snapshot).
4108
3440
  */
4109
3441
  getSnapshot() {
4110
- return this.get();
4111
- }
4112
-
4113
- /** Read the actor's current snapshot as an atom value. */
4114
- get() {
4115
- onActorRead?.(this);
4116
3442
  return this._snapshot;
4117
3443
  }
4118
3444
  }
@@ -4917,10 +4243,7 @@ exports.TimeoutError = TimeoutError;
4917
4243
  exports.XSTATE_INIT = XSTATE_INIT;
4918
4244
  exports.checkStateIn = checkStateIn;
4919
4245
  exports.createActor = createActor;
4920
- exports.createAsyncAtom = createAsyncAtom;
4921
4246
  exports.createAsyncLogic = createAsyncLogic;
4922
- exports.createAtom = createAtom;
4923
- exports.createAtomConfig = createAtomConfig;
4924
4247
  exports.createCallbackLogic = createCallbackLogic;
4925
4248
  exports.createEmptyActor = createEmptyActor;
4926
4249
  exports.createEventObservableLogic = createEventObservableLogic;
@@ -4931,7 +4254,6 @@ exports.createListenerLogic = createListenerLogic;
4931
4254
  exports.createLogic = createLogic;
4932
4255
  exports.createMachineSnapshot = createMachineSnapshot;
4933
4256
  exports.createObservableLogic = createObservableLogic;
4934
- exports.createReducerAtom = createReducerAtom;
4935
4257
  exports.createSubscriptionLogic = createSubscriptionLogic;
4936
4258
  exports.evaluateCandidate = evaluateCandidate;
4937
4259
  exports.formatRouteTransitions = formatRouteTransitions;
@@ -4945,7 +4267,6 @@ exports.getProperAncestors = getProperAncestors;
4945
4267
  exports.getStateNodeByPath = getStateNodeByPath;
4946
4268
  exports.getStateNodes = getStateNodes;
4947
4269
  exports.initialMicrostep = initialMicrostep;
4948
- exports.isAtom = isAtom;
4949
4270
  exports.isAtomicStateNode = isAtomicStateNode;
4950
4271
  exports.isInFinalState = isInFinalState;
4951
4272
  exports.isMachineSnapshot = isMachineSnapshot;