xstate 5.0.0-beta.18 → 5.0.0-beta.20

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 (43) 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.map +1 -1
  6. package/actors/dist/xstate-actors.cjs.js +1 -1
  7. package/actors/dist/xstate-actors.development.cjs.js +1 -1
  8. package/actors/dist/xstate-actors.development.esm.js +1 -1
  9. package/actors/dist/xstate-actors.esm.js +1 -1
  10. package/actors/dist/xstate-actors.umd.min.js +1 -1
  11. package/actors/dist/xstate-actors.umd.min.js.map +1 -1
  12. package/dist/{actions-5fb9f10d.cjs.js → actions-069d9805.cjs.js} +311 -311
  13. package/dist/{actions-4d6514d2.esm.js → actions-a8a9433c.esm.js} +311 -311
  14. package/dist/{actions-13190b25.development.esm.js → actions-b299d008.development.esm.js} +311 -311
  15. package/dist/{actions-40bd643f.development.cjs.js → actions-d1c41ed3.development.cjs.js} +311 -311
  16. package/dist/declarations/src/Machine.d.ts +2 -2
  17. package/dist/declarations/src/State.d.ts +15 -4
  18. package/dist/declarations/src/StateMachine.d.ts +16 -16
  19. package/dist/declarations/src/StateNode.d.ts +4 -4
  20. package/dist/declarations/src/actions/send.d.ts +1 -1
  21. package/dist/declarations/src/actions/stop.d.ts +1 -1
  22. package/dist/declarations/src/actors/callback.d.ts +14 -2
  23. package/dist/declarations/src/actors/index.d.ts +4 -4
  24. package/dist/declarations/src/actors/observable.d.ts +11 -7
  25. package/dist/declarations/src/actors/promise.d.ts +14 -5
  26. package/dist/declarations/src/actors/transition.d.ts +7 -4
  27. package/dist/declarations/src/guards.d.ts +2 -2
  28. package/dist/declarations/src/stateUtils.d.ts +8 -8
  29. package/dist/declarations/src/typegenTypes.d.ts +15 -17
  30. package/dist/declarations/src/types.d.ts +103 -58
  31. package/dist/declarations/src/utils.d.ts +2 -2
  32. package/dist/xstate.cjs.js +2 -3
  33. package/dist/xstate.development.cjs.js +2 -3
  34. package/dist/xstate.development.esm.js +3 -4
  35. package/dist/xstate.esm.js +3 -4
  36. package/dist/xstate.umd.min.js +1 -1
  37. package/dist/xstate.umd.min.js.map +1 -1
  38. package/guards/dist/xstate-guards.cjs.js +1 -1
  39. package/guards/dist/xstate-guards.development.cjs.js +1 -1
  40. package/guards/dist/xstate-guards.development.esm.js +1 -1
  41. package/guards/dist/xstate-guards.esm.js +1 -1
  42. package/guards/dist/xstate-guards.umd.min.js.map +1 -1
  43. package/package.json +1 -1
@@ -4,9 +4,6 @@ var dev_dist_xstateDev = require('../dev/dist/xstate-dev.development.cjs.js');
4
4
 
5
5
  // https://github.com/microsoft/TypeScript/issues/23182#issuecomment-379091887
6
6
 
7
- // TODO: replace in v5 with:
8
- // export type IndexByType<T extends { type: string }> = { [E in T as E['type']]: E; };
9
-
10
7
  /**
11
8
  * The full definition of an event, with a string `type`.
12
9
  */
@@ -15,8 +12,6 @@ var dev_dist_xstateDev = require('../dev/dist/xstate-dev.development.cjs.js');
15
12
  // we should also accept a raw machine as actor logic here
16
13
  // or just make machine actor logic
17
14
 
18
- // TODO: narrow this to logic from machine
19
-
20
15
  /**
21
16
  * The string or object representing the state value relative to the parent state node.
22
17
  *
@@ -323,7 +318,7 @@ const symbolObservable = (() => typeof Symbol === 'function' && Symbol.observabl
323
318
  * @returns Actor logic
324
319
  */
325
320
  function fromTransition(transition, initialState) {
326
- const logic = {
321
+ return {
327
322
  config: transition,
328
323
  transition: (state, event, actorContext) => {
329
324
  return transition(state, event, actorContext);
@@ -337,95 +332,260 @@ function fromTransition(transition, initialState) {
337
332
  getPersistedState: state => state,
338
333
  restoreState: state => state
339
334
  };
340
- return logic;
341
335
  }
342
336
 
343
- const resolveEventType = '$$xstate.resolve';
344
- const rejectEventType = '$$xstate.reject';
345
- function fromPromise(
346
- // TODO: add types
347
- promiseCreator) {
348
- // TODO: add event types, consider making the `PromiseEvent` a private type or smth alike
337
+ function matchesState(parentStateId, childStateId) {
338
+ const parentStateValue = toStateValue(parentStateId);
339
+ const childStateValue = toStateValue(childStateId);
340
+ if (typeof childStateValue === 'string') {
341
+ if (typeof parentStateValue === 'string') {
342
+ return childStateValue === parentStateValue;
343
+ }
344
+
345
+ // Parent more specific than child
346
+ return false;
347
+ }
348
+ if (typeof parentStateValue === 'string') {
349
+ return parentStateValue in childStateValue;
350
+ }
351
+ return Object.keys(parentStateValue).every(key => {
352
+ if (!(key in childStateValue)) {
353
+ return false;
354
+ }
355
+ return matchesState(parentStateValue[key], childStateValue[key]);
356
+ });
357
+ }
358
+ function toStatePath(stateId) {
359
+ try {
360
+ if (isArray(stateId)) {
361
+ return stateId;
362
+ }
363
+ return stateId.toString().split(STATE_DELIMITER);
364
+ } catch (e) {
365
+ throw new Error(`'${stateId}' is not a valid state path.`);
366
+ }
367
+ }
368
+ function isStateLike(state) {
369
+ return typeof state === 'object' && 'value' in state && 'context' in state && 'event' in state;
370
+ }
371
+ function toStateValue(stateValue) {
372
+ if (isStateLike(stateValue)) {
373
+ return stateValue.value;
374
+ }
375
+ if (isArray(stateValue)) {
376
+ return pathToStateValue(stateValue);
377
+ }
378
+ if (typeof stateValue !== 'string') {
379
+ return stateValue;
380
+ }
381
+ const statePath = toStatePath(stateValue);
382
+ return pathToStateValue(statePath);
383
+ }
384
+ function pathToStateValue(statePath) {
385
+ if (statePath.length === 1) {
386
+ return statePath[0];
387
+ }
388
+ const value = {};
389
+ let marker = value;
390
+ for (let i = 0; i < statePath.length - 1; i++) {
391
+ if (i === statePath.length - 2) {
392
+ marker[statePath[i]] = statePath[i + 1];
393
+ } else {
394
+ const previous = marker;
395
+ marker = {};
396
+ previous[statePath[i]] = marker;
397
+ }
398
+ }
399
+ return value;
400
+ }
401
+ function mapValues(collection, iteratee) {
402
+ const result = {};
403
+ const collectionKeys = Object.keys(collection);
404
+ for (let i = 0; i < collectionKeys.length; i++) {
405
+ const key = collectionKeys[i];
406
+ result[key] = iteratee(collection[key], key, collection, i);
407
+ }
408
+ return result;
409
+ }
410
+ function flatten(array) {
411
+ return [].concat(...array);
412
+ }
413
+ function toArrayStrict(value) {
414
+ if (isArray(value)) {
415
+ return value;
416
+ }
417
+ return [value];
418
+ }
419
+ function toArray(value) {
420
+ if (value === undefined) {
421
+ return [];
422
+ }
423
+ return toArrayStrict(value);
424
+ }
425
+ function mapContext(mapper, context, event) {
426
+ if (typeof mapper === 'function') {
427
+ return mapper({
428
+ context,
429
+ event
430
+ });
431
+ }
432
+ const result = {};
433
+ const args = {
434
+ context,
435
+ event
436
+ };
437
+ for (const key of Object.keys(mapper)) {
438
+ const subMapper = mapper[key];
439
+ if (typeof subMapper === 'function') {
440
+ result[key] = subMapper(args);
441
+ } else {
442
+ result[key] = subMapper;
443
+ }
444
+ }
445
+ return result;
446
+ }
447
+ function isPromiseLike(value) {
448
+ if (value instanceof Promise) {
449
+ return true;
450
+ }
451
+ // Check if shape matches the Promise/A+ specification for a "thenable".
452
+ if (value !== null && (typeof value === 'function' || typeof value === 'object') && typeof value.then === 'function') {
453
+ return true;
454
+ }
455
+ return false;
456
+ }
457
+ function isArray(value) {
458
+ return Array.isArray(value);
459
+ }
460
+ function isErrorEvent(event) {
461
+ return typeof event.type === 'string' && (event.type === errorExecution || event.type.startsWith(errorPlatform));
462
+ }
463
+ function toTransitionConfigArray(configLike) {
464
+ return toArrayStrict(configLike).map(transitionLike => {
465
+ if (typeof transitionLike === 'undefined' || typeof transitionLike === 'string') {
466
+ return {
467
+ target: transitionLike
468
+ };
469
+ }
470
+ return transitionLike;
471
+ });
472
+ }
473
+ function normalizeTarget(target) {
474
+ if (target === undefined || target === TARGETLESS_KEY) {
475
+ return undefined;
476
+ }
477
+ return toArray(target);
478
+ }
479
+ function toInvokeConfig(invocable, id) {
480
+ if (typeof invocable === 'object') {
481
+ if ('src' in invocable) {
482
+ return invocable;
483
+ }
484
+ if ('transition' in invocable) {
485
+ return {
486
+ id,
487
+ src: invocable
488
+ };
489
+ }
490
+ }
491
+ return {
492
+ id,
493
+ src: invocable
494
+ };
495
+ }
496
+ function toObserver(nextHandler, errorHandler, completionHandler) {
497
+ const noop = () => {};
498
+ const isObserver = typeof nextHandler === 'object';
499
+ const self = isObserver ? nextHandler : null;
500
+ return {
501
+ next: ((isObserver ? nextHandler.next : nextHandler) || noop).bind(self),
502
+ error: ((isObserver ? nextHandler.error : errorHandler) || noop).bind(self),
503
+ complete: ((isObserver ? nextHandler.complete : completionHandler) || noop).bind(self)
504
+ };
505
+ }
506
+ function createInvokeId(stateNodeId, index) {
507
+ return `${stateNodeId}:invocation[${index}]`;
508
+ }
509
+ function resolveReferencedActor(referenced) {
510
+ return referenced ? 'transition' in referenced ? {
511
+ src: referenced,
512
+ input: undefined
513
+ } : referenced : undefined;
514
+ }
515
+
516
+ function fromCallback(invokeCallback) {
349
517
  const logic = {
350
- config: promiseCreator,
351
- transition: (state, event) => {
352
- if (state.status !== 'active') {
353
- return state;
354
- }
355
- switch (event.type) {
356
- case resolveEventType:
357
- return {
358
- ...state,
359
- status: 'done',
360
- data: event.data,
361
- input: undefined
362
- };
363
- case rejectEventType:
364
- return {
365
- ...state,
366
- status: 'error',
367
- data: event.data,
368
- input: undefined
369
- };
370
- case stopSignalType:
371
- return {
372
- ...state,
373
- status: 'canceled',
374
- input: undefined
375
- };
376
- default:
377
- return state;
378
- }
518
+ config: invokeCallback,
519
+ start: (_state, {
520
+ self
521
+ }) => {
522
+ self.send({
523
+ type: startSignalType
524
+ });
379
525
  },
380
- start: (state, {
526
+ transition: (state, event, {
381
527
  self,
528
+ id,
382
529
  system
383
530
  }) => {
384
- // TODO: determine how to allow customizing this so that promises
385
- // can be restarted if necessary
386
- if (state.status !== 'active') {
387
- return;
388
- }
389
- const resolvedPromise = Promise.resolve(promiseCreator({
390
- input: state.input,
391
- system
392
- }));
393
- resolvedPromise.then(response => {
394
- // TODO: remove this condition once dead letter queue lands
395
- if (self._state.status !== 'active') {
396
- return;
397
- }
398
- self.send({
399
- type: resolveEventType,
400
- data: response
531
+ if (event.type === startSignalType) {
532
+ const sendBack = eventForParent => {
533
+ if (state.canceled) {
534
+ return;
535
+ }
536
+ self._parent?.send(eventForParent);
537
+ };
538
+ const receive = newListener => {
539
+ state.receivers.add(newListener);
540
+ };
541
+ state.dispose = invokeCallback({
542
+ input: state.input,
543
+ system,
544
+ self: self,
545
+ sendBack,
546
+ receive
401
547
  });
402
- }, errorData => {
403
- // TODO: remove this condition once dead letter queue lands
404
- if (self._state.status !== 'active') {
405
- return;
548
+ if (isPromiseLike(state.dispose)) {
549
+ state.dispose.then(resolved => {
550
+ self._parent?.send(doneInvoke(id, resolved));
551
+ state.canceled = true;
552
+ }, errorData => {
553
+ state.canceled = true;
554
+ self._parent?.send(error(id, errorData));
555
+ });
406
556
  }
407
- self.send({
408
- type: rejectEventType,
409
- data: errorData
410
- });
411
- });
557
+ return state;
558
+ }
559
+ if (event.type === stopSignalType) {
560
+ state.canceled = true;
561
+ if (typeof state.dispose === 'function') {
562
+ state.dispose();
563
+ }
564
+ return state;
565
+ }
566
+ if (isSignal(event)) {
567
+ // TODO: unrecognized signal
568
+ return state;
569
+ }
570
+ state.receivers.forEach(receiver => receiver(event));
571
+ return state;
412
572
  },
413
573
  getInitialState: (_, input) => {
414
574
  return {
415
- status: 'active',
416
- data: undefined,
575
+ canceled: false,
576
+ receivers: new Set(),
577
+ dispose: undefined,
417
578
  input
418
579
  };
419
580
  },
420
- getSnapshot: state => state.data,
421
- getStatus: state => state,
422
- getPersistedState: state => state,
423
- restoreState: state => state
581
+ getSnapshot: () => undefined,
582
+ getPersistedState: ({
583
+ input
584
+ }) => input
424
585
  };
425
586
  return logic;
426
587
  }
427
588
 
428
- // TODO: this likely shouldn't accept TEvent, observable actor doesn't accept external events
429
589
  function fromObservable(observableCreator) {
430
590
  const nextEventType = '$$xstate.next';
431
591
  const errorEventType = '$$xstate.error';
@@ -501,7 +661,8 @@ function fromObservable(observableCreator) {
501
661
  }
502
662
  state.subscription = observableCreator({
503
663
  input: state.input,
504
- system
664
+ system,
665
+ self
505
666
  }).subscribe({
506
667
  next: value => {
507
668
  self.send({
@@ -607,7 +768,8 @@ function fromEventObservable(lazyObservable) {
607
768
  }
608
769
  state.subscription = lazyObservable({
609
770
  input: state.input,
610
- system
771
+ system,
772
+ self
611
773
  }).subscribe({
612
774
  next: value => {
613
775
  self._parent?.send(value);
@@ -644,251 +806,88 @@ function fromEventObservable(lazyObservable) {
644
806
  return logic;
645
807
  }
646
808
 
647
- function matchesState(parentStateId, childStateId) {
648
- const parentStateValue = toStateValue(parentStateId);
649
- const childStateValue = toStateValue(childStateId);
650
- if (typeof childStateValue === 'string') {
651
- if (typeof parentStateValue === 'string') {
652
- return childStateValue === parentStateValue;
653
- }
654
-
655
- // Parent more specific than child
656
- return false;
657
- }
658
- if (typeof parentStateValue === 'string') {
659
- return parentStateValue in childStateValue;
660
- }
661
- return Object.keys(parentStateValue).every(key => {
662
- if (!(key in childStateValue)) {
663
- return false;
664
- }
665
- return matchesState(parentStateValue[key], childStateValue[key]);
666
- });
667
- }
668
- function toStatePath(stateId) {
669
- try {
670
- if (isArray(stateId)) {
671
- return stateId;
672
- }
673
- return stateId.toString().split(STATE_DELIMITER);
674
- } catch (e) {
675
- throw new Error(`'${stateId}' is not a valid state path.`);
676
- }
677
- }
678
- function isStateLike(state) {
679
- return typeof state === 'object' && 'value' in state && 'context' in state && 'event' in state;
680
- }
681
- function toStateValue(stateValue) {
682
- if (isStateLike(stateValue)) {
683
- return stateValue.value;
684
- }
685
- if (isArray(stateValue)) {
686
- return pathToStateValue(stateValue);
687
- }
688
- if (typeof stateValue !== 'string') {
689
- return stateValue;
690
- }
691
- const statePath = toStatePath(stateValue);
692
- return pathToStateValue(statePath);
693
- }
694
- function pathToStateValue(statePath) {
695
- if (statePath.length === 1) {
696
- return statePath[0];
697
- }
698
- const value = {};
699
- let marker = value;
700
- for (let i = 0; i < statePath.length - 1; i++) {
701
- if (i === statePath.length - 2) {
702
- marker[statePath[i]] = statePath[i + 1];
703
- } else {
704
- const previous = marker;
705
- marker = {};
706
- previous[statePath[i]] = marker;
707
- }
708
- }
709
- return value;
710
- }
711
- function mapValues(collection, iteratee) {
712
- const result = {};
713
- const collectionKeys = Object.keys(collection);
714
- for (let i = 0; i < collectionKeys.length; i++) {
715
- const key = collectionKeys[i];
716
- result[key] = iteratee(collection[key], key, collection, i);
717
- }
718
- return result;
719
- }
720
- function flatten(array) {
721
- return [].concat(...array);
722
- }
723
- function toArrayStrict(value) {
724
- if (isArray(value)) {
725
- return value;
726
- }
727
- return [value];
728
- }
729
- function toArray(value) {
730
- if (value === undefined) {
731
- return [];
732
- }
733
- return toArrayStrict(value);
734
- }
735
- function mapContext(mapper, context, event) {
736
- if (typeof mapper === 'function') {
737
- return mapper({
738
- context,
739
- event
740
- });
741
- }
742
- const result = {};
743
- const args = {
744
- context,
745
- event
746
- };
747
- for (const key of Object.keys(mapper)) {
748
- const subMapper = mapper[key];
749
- if (typeof subMapper === 'function') {
750
- result[key] = subMapper(args);
751
- } else {
752
- result[key] = subMapper;
753
- }
754
- }
755
- return result;
756
- }
757
- function isPromiseLike(value) {
758
- if (value instanceof Promise) {
759
- return true;
760
- }
761
- // Check if shape matches the Promise/A+ specification for a "thenable".
762
- if (value !== null && (typeof value === 'function' || typeof value === 'object') && typeof value.then === 'function') {
763
- return true;
764
- }
765
- return false;
766
- }
767
- function isArray(value) {
768
- return Array.isArray(value);
769
- }
770
- function isErrorEvent(event) {
771
- return typeof event.type === 'string' && (event.type === errorExecution || event.type.startsWith(errorPlatform));
772
- }
773
- function toTransitionConfigArray(configLike) {
774
- return toArrayStrict(configLike).map(transitionLike => {
775
- if (typeof transitionLike === 'undefined' || typeof transitionLike === 'string') {
776
- return {
777
- target: transitionLike
778
- };
779
- }
780
- return transitionLike;
781
- });
782
- }
783
- function normalizeTarget(target) {
784
- if (target === undefined || target === TARGETLESS_KEY) {
785
- return undefined;
786
- }
787
- return toArray(target);
788
- }
789
- function toInvokeConfig(invocable, id) {
790
- if (typeof invocable === 'object') {
791
- if ('src' in invocable) {
792
- return invocable;
793
- }
794
- if ('transition' in invocable) {
795
- return {
796
- id,
797
- src: invocable
798
- };
799
- }
800
- }
801
- return {
802
- id,
803
- src: invocable
804
- };
805
- }
806
- function toObserver(nextHandler, errorHandler, completionHandler) {
807
- const noop = () => {};
808
- const isObserver = typeof nextHandler === 'object';
809
- const self = isObserver ? nextHandler : null;
810
- return {
811
- next: ((isObserver ? nextHandler.next : nextHandler) || noop).bind(self),
812
- error: ((isObserver ? nextHandler.error : errorHandler) || noop).bind(self),
813
- complete: ((isObserver ? nextHandler.complete : completionHandler) || noop).bind(self)
814
- };
815
- }
816
- function createInvokeId(stateNodeId, index) {
817
- return `${stateNodeId}:invocation[${index}]`;
818
- }
819
- function resolveReferencedActor(referenced) {
820
- return referenced ? 'transition' in referenced ? {
821
- src: referenced,
822
- input: undefined
823
- } : referenced : undefined;
824
- }
825
-
826
- function fromCallback(invokeCallback) {
809
+ const resolveEventType = '$$xstate.resolve';
810
+ const rejectEventType = '$$xstate.reject';
811
+ function fromPromise(
812
+ // TODO: add types
813
+ promiseCreator) {
814
+ // TODO: add event types
827
815
  const logic = {
828
- config: invokeCallback,
829
- start: (_state, {
830
- self
831
- }) => {
832
- self.send({
833
- type: startSignalType
834
- });
816
+ config: promiseCreator,
817
+ transition: (state, event) => {
818
+ if (state.status !== 'active') {
819
+ return state;
820
+ }
821
+ switch (event.type) {
822
+ case resolveEventType:
823
+ return {
824
+ ...state,
825
+ status: 'done',
826
+ data: event.data,
827
+ input: undefined
828
+ };
829
+ case rejectEventType:
830
+ return {
831
+ ...state,
832
+ status: 'error',
833
+ data: event.data,
834
+ input: undefined
835
+ };
836
+ case stopSignalType:
837
+ return {
838
+ ...state,
839
+ status: 'canceled',
840
+ input: undefined
841
+ };
842
+ default:
843
+ return state;
844
+ }
835
845
  },
836
- transition: (state, event, {
846
+ start: (state, {
837
847
  self,
838
- id,
839
848
  system
840
849
  }) => {
841
- if (event.type === startSignalType) {
842
- const sender = eventForParent => {
843
- if (state.canceled) {
844
- return;
845
- }
846
- self._parent?.send(eventForParent);
847
- };
848
- const receiver = newListener => {
849
- state.receivers.add(newListener);
850
- };
851
- state.dispose = invokeCallback(sender, receiver, {
852
- input: state.input,
853
- system
854
- });
855
- if (isPromiseLike(state.dispose)) {
856
- state.dispose.then(resolved => {
857
- self._parent?.send(doneInvoke(id, resolved));
858
- state.canceled = true;
859
- }, errorData => {
860
- state.canceled = true;
861
- self._parent?.send(error(id, errorData));
862
- });
863
- }
864
- return state;
850
+ // TODO: determine how to allow customizing this so that promises
851
+ // can be restarted if necessary
852
+ if (state.status !== 'active') {
853
+ return;
865
854
  }
866
- if (event.type === stopSignalType) {
867
- state.canceled = true;
868
- if (typeof state.dispose === 'function') {
869
- state.dispose();
855
+ const resolvedPromise = Promise.resolve(promiseCreator({
856
+ input: state.input,
857
+ system,
858
+ self
859
+ }));
860
+ resolvedPromise.then(response => {
861
+ // TODO: remove this condition once dead letter queue lands
862
+ if (self._state.status !== 'active') {
863
+ return;
870
864
  }
871
- return state;
872
- }
873
- if (isSignal(event)) {
874
- // TODO: unrecognized signal
875
- return state;
876
- }
877
- state.receivers.forEach(receiver => receiver(event));
878
- return state;
865
+ self.send({
866
+ type: resolveEventType,
867
+ data: response
868
+ });
869
+ }, errorData => {
870
+ // TODO: remove this condition once dead letter queue lands
871
+ if (self._state.status !== 'active') {
872
+ return;
873
+ }
874
+ self.send({
875
+ type: rejectEventType,
876
+ data: errorData
877
+ });
878
+ });
879
879
  },
880
880
  getInitialState: (_, input) => {
881
881
  return {
882
- canceled: false,
883
- receivers: new Set(),
884
- dispose: undefined,
882
+ status: 'active',
883
+ data: undefined,
885
884
  input
886
885
  };
887
886
  },
888
- getSnapshot: () => undefined,
889
- getPersistedState: ({
890
- input
891
- }) => input
887
+ getSnapshot: state => state.data,
888
+ getStatus: state => state,
889
+ getPersistedState: state => state,
890
+ restoreState: state => state
892
891
  };
893
892
  return logic;
894
893
  }
@@ -927,6 +926,7 @@ function toActorRef(actorRefLike) {
927
926
  id: 'anonymous',
928
927
  sessionId: '',
929
928
  getSnapshot: () => undefined,
929
+ // TODO: this isn't safe
930
930
  [symbolObservable]: function () {
931
931
  return this;
932
932
  },
@@ -2820,7 +2820,7 @@ function createSpawner(actorContext, {
2820
2820
  }
2821
2821
  };
2822
2822
  return (src, options) => {
2823
- const actorRef = spawn(src, options);
2823
+ const actorRef = spawn(src, options); // TODO: fix types
2824
2824
  spawnedChildren[actorRef.id] = actorRef;
2825
2825
  actorContext.defer(() => {
2826
2826
  if (actorRef.status === ActorStatus.Stopped) {