xstate 5.14.0 → 5.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actions/dist/xstate-actions.cjs.js +2 -2
- package/actions/dist/xstate-actions.development.cjs.js +2 -2
- package/actions/dist/xstate-actions.development.esm.js +2 -2
- package/actions/dist/xstate-actions.esm.js +2 -2
- package/actions/dist/xstate-actions.umd.min.js +1 -1
- package/actions/dist/xstate-actions.umd.min.js.map +1 -1
- package/actors/dist/xstate-actors.cjs.js +272 -65
- package/actors/dist/xstate-actors.development.cjs.js +272 -65
- package/actors/dist/xstate-actors.development.esm.js +272 -65
- package/actors/dist/xstate-actors.esm.js +272 -65
- package/actors/dist/xstate-actors.umd.min.js.map +1 -1
- package/dist/declarations/src/State.d.ts +23 -27
- package/dist/declarations/src/StateMachine.d.ts +19 -31
- package/dist/declarations/src/StateNode.d.ts +29 -51
- package/dist/declarations/src/actions/assign.d.ts +29 -27
- package/dist/declarations/src/actions/cancel.d.ts +28 -22
- package/dist/declarations/src/actions/emit.d.ts +33 -33
- package/dist/declarations/src/actions/enqueueActions.d.ts +21 -18
- package/dist/declarations/src/actions/log.d.ts +5 -4
- package/dist/declarations/src/actions/send.d.ts +5 -3
- package/dist/declarations/src/actors/callback.d.ts +65 -26
- package/dist/declarations/src/actors/index.d.ts +4 -4
- package/dist/declarations/src/actors/observable.d.ts +65 -22
- package/dist/declarations/src/actors/promise.d.ts +86 -9
- package/dist/declarations/src/actors/transition.d.ts +89 -15
- package/dist/declarations/src/assert.d.ts +21 -20
- package/dist/declarations/src/createActor.d.ts +51 -42
- package/dist/declarations/src/createMachine.d.ts +40 -54
- package/dist/declarations/src/getNextSnapshot.d.ts +27 -24
- package/dist/declarations/src/guards.d.ts +67 -66
- package/dist/declarations/src/index.d.ts +1 -2
- package/dist/declarations/src/inspection.d.ts +1 -0
- package/dist/declarations/src/setup.d.ts +1 -2
- package/dist/declarations/src/spawn.d.ts +2 -5
- package/dist/declarations/src/stateUtils.d.ts +5 -10
- package/dist/declarations/src/toPromise.d.ts +1 -0
- package/dist/declarations/src/types.d.ts +164 -189
- package/dist/declarations/src/waitFor.d.ts +9 -9
- package/dist/{log-c943e6aa.development.esm.js → log-17f4495d.development.esm.js} +115 -117
- package/dist/{log-505687fd.development.cjs.js → log-31321d85.development.cjs.js} +115 -117
- package/dist/{log-b87cb6bd.esm.js → log-8320f5e6.esm.js} +115 -117
- package/dist/{log-7ae0ddf8.cjs.js → log-f9587b82.cjs.js} +115 -117
- package/dist/{raise-4e39e875.esm.js → raise-2cfe6b8f.esm.js} +164 -154
- package/dist/{raise-0f400094.development.esm.js → raise-7d030497.development.esm.js} +164 -154
- package/dist/{raise-f79d2832.cjs.js → raise-a6298350.cjs.js} +164 -154
- package/dist/{raise-0cd7e521.development.cjs.js → raise-bad6a97b.development.cjs.js} +164 -154
- package/dist/xstate.cjs.js +134 -157
- package/dist/xstate.development.cjs.js +134 -157
- package/dist/xstate.development.esm.js +136 -159
- package/dist/xstate.esm.js +136 -159
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +1 -1
- package/guards/dist/xstate-guards.cjs.js +1 -1
- package/guards/dist/xstate-guards.development.cjs.js +1 -1
- package/guards/dist/xstate-guards.development.esm.js +1 -1
- package/guards/dist/xstate-guards.esm.js +1 -1
- package/guards/dist/xstate-guards.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/dist/declarations/src/typegenTypes.d.ts +0 -168
package/dist/xstate.cjs.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var actors_dist_xstateActors = require('../actors/dist/xstate-actors.cjs.js');
|
|
6
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
7
|
-
var log = require('./log-
|
|
6
|
+
var guards_dist_xstateGuards = require('./raise-a6298350.cjs.js');
|
|
7
|
+
var log = require('./log-f9587b82.cjs.js');
|
|
8
8
|
require('../dev/dist/xstate-dev.cjs.js');
|
|
9
9
|
|
|
10
10
|
class SimulatedClock {
|
|
@@ -107,71 +107,58 @@ const toSerializableAction = action => {
|
|
|
107
107
|
return action;
|
|
108
108
|
};
|
|
109
109
|
class StateNode {
|
|
110
|
-
constructor(
|
|
111
|
-
/**
|
|
112
|
-
* The raw config used to create the machine.
|
|
113
|
-
*/
|
|
110
|
+
constructor( /** The raw config used to create the machine. */
|
|
114
111
|
config, options) {
|
|
115
112
|
this.config = config;
|
|
116
113
|
/**
|
|
117
|
-
* The relative key of the state node, which represents its location in the
|
|
114
|
+
* The relative key of the state node, which represents its location in the
|
|
115
|
+
* overall state value.
|
|
118
116
|
*/
|
|
119
117
|
this.key = void 0;
|
|
120
|
-
/**
|
|
121
|
-
* The unique ID of the state node.
|
|
122
|
-
*/
|
|
118
|
+
/** The unique ID of the state node. */
|
|
123
119
|
this.id = void 0;
|
|
124
120
|
/**
|
|
125
121
|
* The type of this state node:
|
|
126
122
|
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
123
|
+
* - `'atomic'` - no child state nodes
|
|
124
|
+
* - `'compound'` - nested child state nodes (XOR)
|
|
125
|
+
* - `'parallel'` - orthogonal nested child state nodes (AND)
|
|
126
|
+
* - `'history'` - history state node
|
|
127
|
+
* - `'final'` - final state node
|
|
132
128
|
*/
|
|
133
129
|
this.type = void 0;
|
|
134
|
-
/**
|
|
135
|
-
* The string path from the root machine node to this node.
|
|
136
|
-
*/
|
|
130
|
+
/** The string path from the root machine node to this node. */
|
|
137
131
|
this.path = void 0;
|
|
138
|
-
/**
|
|
139
|
-
* The child state nodes.
|
|
140
|
-
*/
|
|
132
|
+
/** The child state nodes. */
|
|
141
133
|
this.states = void 0;
|
|
142
134
|
/**
|
|
143
135
|
* The type of history on this state node. Can be:
|
|
144
136
|
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
137
|
+
* - `'shallow'` - recalls only top-level historical state value
|
|
138
|
+
* - `'deep'` - recalls historical state value at all levels
|
|
147
139
|
*/
|
|
148
140
|
this.history = void 0;
|
|
149
|
-
/**
|
|
150
|
-
* The action(s) to be executed upon entering the state node.
|
|
151
|
-
*/
|
|
141
|
+
/** The action(s) to be executed upon entering the state node. */
|
|
152
142
|
this.entry = void 0;
|
|
153
|
-
/**
|
|
154
|
-
* The action(s) to be executed upon exiting the state node.
|
|
155
|
-
*/
|
|
143
|
+
/** The action(s) to be executed upon exiting the state node. */
|
|
156
144
|
this.exit = void 0;
|
|
157
|
-
/**
|
|
158
|
-
* The parent state node.
|
|
159
|
-
*/
|
|
145
|
+
/** The parent state node. */
|
|
160
146
|
this.parent = void 0;
|
|
161
|
-
/**
|
|
162
|
-
* The root machine node.
|
|
163
|
-
*/
|
|
147
|
+
/** The root machine node. */
|
|
164
148
|
this.machine = void 0;
|
|
165
149
|
/**
|
|
166
|
-
* The meta data associated with this state node, which will be returned in
|
|
150
|
+
* The meta data associated with this state node, which will be returned in
|
|
151
|
+
* State instances.
|
|
167
152
|
*/
|
|
168
153
|
this.meta = void 0;
|
|
169
154
|
/**
|
|
170
|
-
* The output data sent with the "xstate.done.state._id_" event if this is a
|
|
155
|
+
* The output data sent with the "xstate.done.state._id_" event if this is a
|
|
156
|
+
* final state node.
|
|
171
157
|
*/
|
|
172
158
|
this.output = void 0;
|
|
173
159
|
/**
|
|
174
|
-
* The order this state node appears. Corresponds to the implicit document
|
|
160
|
+
* The order this state node appears. Corresponds to the implicit document
|
|
161
|
+
* order.
|
|
175
162
|
*/
|
|
176
163
|
this.order = -1;
|
|
177
164
|
this.description = void 0;
|
|
@@ -219,9 +206,7 @@ class StateNode {
|
|
|
219
206
|
});
|
|
220
207
|
}
|
|
221
208
|
|
|
222
|
-
/**
|
|
223
|
-
* The well-structured state node definition.
|
|
224
|
-
*/
|
|
209
|
+
/** The well-structured state node definition. */
|
|
225
210
|
get definition() {
|
|
226
211
|
return {
|
|
227
212
|
id: this.id,
|
|
@@ -266,9 +251,7 @@ class StateNode {
|
|
|
266
251
|
return this.definition;
|
|
267
252
|
}
|
|
268
253
|
|
|
269
|
-
/**
|
|
270
|
-
* The logic invoked as actors by this state node.
|
|
271
|
-
*/
|
|
254
|
+
/** The logic invoked as actors by this state node. */
|
|
272
255
|
get invoke() {
|
|
273
256
|
return memo(this, 'invoke', () => guards_dist_xstateGuards.toArray(this.config.invoke).map((invokeConfig, i) => {
|
|
274
257
|
const {
|
|
@@ -299,9 +282,7 @@ class StateNode {
|
|
|
299
282
|
}));
|
|
300
283
|
}
|
|
301
284
|
|
|
302
|
-
/**
|
|
303
|
-
* The mapping of events to transitions.
|
|
304
|
-
*/
|
|
285
|
+
/** The mapping of events to transitions. */
|
|
305
286
|
get on() {
|
|
306
287
|
return memo(this, 'on', () => {
|
|
307
288
|
const transitions = this.transitions;
|
|
@@ -346,9 +327,7 @@ class StateNode {
|
|
|
346
327
|
return selectedTransition ? [selectedTransition] : undefined;
|
|
347
328
|
}
|
|
348
329
|
|
|
349
|
-
/**
|
|
350
|
-
* All the event types accepted by this state node and its descendants.
|
|
351
|
-
*/
|
|
330
|
+
/** All the event types accepted by this state node and its descendants. */
|
|
352
331
|
get events() {
|
|
353
332
|
return memo(this, 'events', () => {
|
|
354
333
|
const {
|
|
@@ -384,15 +363,10 @@ class StateNode {
|
|
|
384
363
|
|
|
385
364
|
const STATE_IDENTIFIER = '#';
|
|
386
365
|
class StateMachine {
|
|
387
|
-
constructor(
|
|
388
|
-
/**
|
|
389
|
-
* The raw config used to create the machine.
|
|
390
|
-
*/
|
|
366
|
+
constructor( /** The raw config used to create the machine. */
|
|
391
367
|
config, implementations) {
|
|
392
368
|
this.config = config;
|
|
393
|
-
/**
|
|
394
|
-
* The machine's own version.
|
|
395
|
-
*/
|
|
369
|
+
/** The machine's own version. */
|
|
396
370
|
this.version = void 0;
|
|
397
371
|
this.schemas = void 0;
|
|
398
372
|
this.implementations = void 0;
|
|
@@ -404,10 +378,6 @@ class StateMachine {
|
|
|
404
378
|
this.id = void 0;
|
|
405
379
|
this.states = void 0;
|
|
406
380
|
this.events = void 0;
|
|
407
|
-
/**
|
|
408
|
-
* @deprecated an internal property that was acting as a "phantom" type, it's not used by anything right now but it's kept around for compatibility reasons
|
|
409
|
-
**/
|
|
410
|
-
this.__TResolvedTypesMeta = void 0;
|
|
411
381
|
this.id = config.id || '(machine)';
|
|
412
382
|
this.implementations = {
|
|
413
383
|
actors: implementations?.actors ?? {},
|
|
@@ -432,12 +402,11 @@ class StateMachine {
|
|
|
432
402
|
}
|
|
433
403
|
|
|
434
404
|
/**
|
|
435
|
-
* Clones this state machine with the provided implementations
|
|
436
|
-
*
|
|
437
|
-
*
|
|
438
|
-
* @param implementations Options (`actions`, `guards`, `actors`, `delays`, `context`)
|
|
439
|
-
* to recursively merge with the existing options.
|
|
405
|
+
* Clones this state machine with the provided implementations and merges the
|
|
406
|
+
* `context` (if provided).
|
|
440
407
|
*
|
|
408
|
+
* @param implementations Options (`actions`, `guards`, `actors`, `delays`,
|
|
409
|
+
* `context`) to recursively merge with the existing options.
|
|
441
410
|
* @returns A new `StateMachine` instance with the provided implementations.
|
|
442
411
|
*/
|
|
443
412
|
provide(implementations) {
|
|
@@ -481,8 +450,8 @@ class StateMachine {
|
|
|
481
450
|
}
|
|
482
451
|
|
|
483
452
|
/**
|
|
484
|
-
* Determines the next snapshot given the current `snapshot` and received
|
|
485
|
-
* Calculates a full macrostep from all microsteps.
|
|
453
|
+
* Determines the next snapshot given the current `snapshot` and received
|
|
454
|
+
* `event`. Calculates a full macrostep from all microsteps.
|
|
486
455
|
*
|
|
487
456
|
* @param snapshot The current snapshot
|
|
488
457
|
* @param event The received event
|
|
@@ -492,8 +461,8 @@ class StateMachine {
|
|
|
492
461
|
}
|
|
493
462
|
|
|
494
463
|
/**
|
|
495
|
-
* Determines the next state given the current `state` and `event`.
|
|
496
|
-
*
|
|
464
|
+
* Determines the next state given the current `state` and `event`. Calculates
|
|
465
|
+
* a microstep.
|
|
497
466
|
*
|
|
498
467
|
* @param state The current state
|
|
499
468
|
* @param event The received event
|
|
@@ -506,8 +475,8 @@ class StateMachine {
|
|
|
506
475
|
}
|
|
507
476
|
|
|
508
477
|
/**
|
|
509
|
-
* The initial state _before_ evaluating any microsteps.
|
|
510
|
-
*
|
|
478
|
+
* The initial state _before_ evaluating any microsteps. This "pre-initial"
|
|
479
|
+
* state is provided to initial actions executed in the initial state.
|
|
511
480
|
*/
|
|
512
481
|
getPreInitialState(actorScope, initEvent, internalQueue) {
|
|
513
482
|
const {
|
|
@@ -535,7 +504,8 @@ class StateMachine {
|
|
|
535
504
|
}
|
|
536
505
|
|
|
537
506
|
/**
|
|
538
|
-
* Returns the initial `State` instance, with reference to `self` as an
|
|
507
|
+
* Returns the initial `State` instance, with reference to `self` as an
|
|
508
|
+
* `ActorRef`.
|
|
539
509
|
*/
|
|
540
510
|
getInitialSnapshot(actorScope, input) {
|
|
541
511
|
const initEvent = guards_dist_xstateGuards.createInitEvent(input); // TODO: fix;
|
|
@@ -633,14 +603,14 @@ const defaultWaitForOptions = {
|
|
|
633
603
|
};
|
|
634
604
|
|
|
635
605
|
/**
|
|
636
|
-
* Subscribes to an actor ref and waits for its emitted value to satisfy
|
|
637
|
-
*
|
|
638
|
-
*
|
|
639
|
-
* (defaults to Infinity).
|
|
606
|
+
* Subscribes to an actor ref and waits for its emitted value to satisfy a
|
|
607
|
+
* predicate, and then resolves with that value. Will throw if the desired state
|
|
608
|
+
* is not reached after an optional timeout. (defaults to Infinity).
|
|
640
609
|
*
|
|
641
610
|
* @example
|
|
611
|
+
*
|
|
642
612
|
* ```js
|
|
643
|
-
* const state = await waitFor(someService, state => {
|
|
613
|
+
* const state = await waitFor(someService, (state) => {
|
|
644
614
|
* return state.hasTag('loaded');
|
|
645
615
|
* });
|
|
646
616
|
*
|
|
@@ -650,8 +620,8 @@ const defaultWaitForOptions = {
|
|
|
650
620
|
* @param actorRef The actor ref to subscribe to
|
|
651
621
|
* @param predicate Determines if a value matches the condition to wait for
|
|
652
622
|
* @param options
|
|
653
|
-
* @returns A promise that eventually resolves to the emitted value
|
|
654
|
-
*
|
|
623
|
+
* @returns A promise that eventually resolves to the emitted value that matches
|
|
624
|
+
* the condition
|
|
655
625
|
*/
|
|
656
626
|
function waitFor(actorRef, predicate, options) {
|
|
657
627
|
const resolvedOptions = {
|
|
@@ -707,40 +677,42 @@ function waitFor(actorRef, predicate, options) {
|
|
|
707
677
|
*
|
|
708
678
|
* The state machine represents the pure logic of a state machine actor.
|
|
709
679
|
*
|
|
710
|
-
* @param config The state machine configuration.
|
|
711
|
-
* @param options DEPRECATED: use `setup({ ... })` or `machine.provide({ ... })` to provide machine implementations instead.
|
|
712
|
-
*
|
|
713
680
|
* @example
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
681
|
+
*
|
|
682
|
+
* ```ts
|
|
683
|
+
* import { createMachine } from 'xstate';
|
|
684
|
+
*
|
|
685
|
+
* const lightMachine = createMachine({
|
|
686
|
+
* id: 'light',
|
|
687
|
+
* initial: 'green',
|
|
688
|
+
* states: {
|
|
689
|
+
* green: {
|
|
690
|
+
* on: {
|
|
691
|
+
* TIMER: { target: 'yellow' }
|
|
692
|
+
* }
|
|
693
|
+
* },
|
|
694
|
+
* yellow: {
|
|
695
|
+
* on: {
|
|
696
|
+
* TIMER: { target: 'red' }
|
|
697
|
+
* }
|
|
698
|
+
* },
|
|
699
|
+
* red: {
|
|
700
|
+
* on: {
|
|
701
|
+
* TIMER: { target: 'green' }
|
|
702
|
+
* }
|
|
703
|
+
* }
|
|
704
|
+
* }
|
|
705
|
+
* });
|
|
706
|
+
*
|
|
707
|
+
* const lightActor = createActor(lightMachine);
|
|
708
|
+
* lightActor.start();
|
|
709
|
+
*
|
|
710
|
+
* lightActor.send({ type: 'TIMER' });
|
|
711
|
+
* ```
|
|
712
|
+
*
|
|
713
|
+
* @param config The state machine configuration.
|
|
714
|
+
* @param options DEPRECATED: use `setup({ ... })` or `machine.provide({ ... })`
|
|
715
|
+
* to provide machine implementations instead.
|
|
744
716
|
*/
|
|
745
717
|
function createMachine(config, implementations) {
|
|
746
718
|
return new StateMachine(config, implementations);
|
|
@@ -767,33 +739,36 @@ function getInitialSnapshot(actorLogic, ...[input]) {
|
|
|
767
739
|
}
|
|
768
740
|
|
|
769
741
|
/**
|
|
770
|
-
* Determines the next snapshot for the given `actorLogic` based on
|
|
771
|
-
*
|
|
742
|
+
* Determines the next snapshot for the given `actorLogic` based on the given
|
|
743
|
+
* `snapshot` and `event`.
|
|
772
744
|
*
|
|
773
|
-
* If the `snapshot` is `undefined`, the initial snapshot of the
|
|
774
|
-
*
|
|
745
|
+
* If the `snapshot` is `undefined`, the initial snapshot of the `actorLogic` is
|
|
746
|
+
* used.
|
|
775
747
|
*
|
|
776
748
|
* @example
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
749
|
+
*
|
|
750
|
+
* ```ts
|
|
751
|
+
* import { getNextSnapshot } from 'xstate';
|
|
752
|
+
* import { trafficLightMachine } from './trafficLightMachine.ts';
|
|
753
|
+
*
|
|
754
|
+
* const nextSnapshot = getNextSnapshot(
|
|
755
|
+
* trafficLightMachine, // actor logic
|
|
756
|
+
* undefined, // snapshot (or initial state if undefined)
|
|
757
|
+
* { type: 'TIMER' }
|
|
758
|
+
* ); // event object
|
|
759
|
+
*
|
|
760
|
+
* console.log(nextSnapshot.value);
|
|
761
|
+
* // => 'yellow'
|
|
762
|
+
*
|
|
763
|
+
* const nextSnapshot2 = getNextSnapshot(
|
|
764
|
+
* trafficLightMachine, // actor logic
|
|
765
|
+
* nextSnapshot, // snapshot
|
|
766
|
+
* { type: 'TIMER' }
|
|
767
|
+
* ); // event object
|
|
768
|
+
*
|
|
769
|
+
* console.log(nextSnapshot2.value);
|
|
770
|
+
* // =>'red'
|
|
771
|
+
* ```
|
|
797
772
|
*/
|
|
798
773
|
function getNextSnapshot(actorLogic, snapshot, event) {
|
|
799
774
|
const inertActorScope = createInertActorScope(actorLogic);
|
|
@@ -827,6 +802,7 @@ function setup({
|
|
|
827
802
|
* Returns a promise that resolves to the `output` of the actor when it is done.
|
|
828
803
|
*
|
|
829
804
|
* @example
|
|
805
|
+
*
|
|
830
806
|
* ```ts
|
|
831
807
|
* const machine = createMachine({
|
|
832
808
|
* // ...
|
|
@@ -857,26 +833,27 @@ function toPromise(actor) {
|
|
|
857
833
|
}
|
|
858
834
|
|
|
859
835
|
/**
|
|
860
|
-
* Asserts that the given event object is of the specified type or types.
|
|
861
|
-
*
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
836
|
+
* Asserts that the given event object is of the specified type or types. Throws
|
|
837
|
+
* an error if the event object is not of the specified types.
|
|
838
|
+
*
|
|
839
|
+
* @example
|
|
840
|
+
*
|
|
841
|
+
* ```ts
|
|
842
|
+
* // ...
|
|
843
|
+
* entry: ({ event }) => {
|
|
844
|
+
* assertEvent(event, 'doNothing');
|
|
845
|
+
* // event is { type: 'doNothing' }
|
|
846
|
+
* },
|
|
847
|
+
* // ...
|
|
848
|
+
* exit: ({ event }) => {
|
|
849
|
+
* assertEvent(event, 'greet');
|
|
850
|
+
* // event is { type: 'greet'; message: string }
|
|
851
|
+
*
|
|
852
|
+
* assertEvent(event, ['greet', 'notify']);
|
|
853
|
+
* // event is { type: 'greet'; message: string }
|
|
854
|
+
* // or { type: 'notify'; message: string; level: 'info' | 'error' }
|
|
855
|
+
* },
|
|
856
|
+
* ```
|
|
880
857
|
*/
|
|
881
858
|
function assertEvent(event, type) {
|
|
882
859
|
const types = guards_dist_xstateGuards.toArray(type);
|