xstate 5.0.0-beta.45 → 5.0.0-beta.46

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 (42) hide show
  1. package/actions/dist/xstate-actions.cjs.js +2 -2
  2. package/actions/dist/xstate-actions.development.cjs.js +2 -2
  3. package/actions/dist/xstate-actions.development.esm.js +2 -2
  4. package/actions/dist/xstate-actions.esm.js +2 -2
  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 +42 -5
  8. package/actors/dist/xstate-actors.development.cjs.js +42 -5
  9. package/actors/dist/xstate-actors.development.esm.js +42 -5
  10. package/actors/dist/xstate-actors.esm.js +42 -5
  11. package/actors/dist/xstate-actors.umd.min.js.map +1 -1
  12. package/dist/declarations/src/State.d.ts +16 -26
  13. package/dist/declarations/src/StateMachine.d.ts +11 -29
  14. package/dist/declarations/src/StateNode.d.ts +8 -6
  15. package/dist/declarations/src/actors/observable.d.ts +41 -4
  16. package/dist/declarations/src/createMachine.d.ts +3 -3
  17. package/dist/declarations/src/index.d.ts +1 -1
  18. package/dist/declarations/src/setup.d.ts +11 -8
  19. package/dist/declarations/src/types.d.ts +41 -15
  20. package/dist/declarations/src/utils.d.ts +2 -1
  21. package/dist/{raise-2b5a4e4c.esm.js → raise-1682abb7.esm.js} +23 -36
  22. package/dist/{raise-fabffc3d.cjs.js → raise-a1d3d7e9.cjs.js} +23 -35
  23. package/dist/{raise-b3fb3c65.development.cjs.js → raise-a9e7e31c.development.cjs.js} +23 -35
  24. package/dist/{raise-90139fbc.development.esm.js → raise-fa23c2b9.development.esm.js} +23 -36
  25. package/dist/{send-c124176f.cjs.js → send-2fa3a204.cjs.js} +22 -1
  26. package/dist/{send-d0bc7eed.development.cjs.js → send-5b256a89.development.cjs.js} +22 -1
  27. package/dist/{send-24cc8018.development.esm.js → send-9acdf858.development.esm.js} +22 -1
  28. package/dist/{send-8e7e41e7.esm.js → send-a237e4e8.esm.js} +22 -1
  29. package/dist/xstate.cjs.js +59 -81
  30. package/dist/xstate.cjs.mjs +1 -0
  31. package/dist/xstate.development.cjs.js +59 -81
  32. package/dist/xstate.development.cjs.mjs +1 -0
  33. package/dist/xstate.development.esm.js +60 -83
  34. package/dist/xstate.esm.js +60 -83
  35. package/dist/xstate.umd.min.js +1 -1
  36. package/dist/xstate.umd.min.js.map +1 -1
  37. package/guards/dist/xstate-guards.cjs.js +1 -1
  38. package/guards/dist/xstate-guards.development.cjs.js +1 -1
  39. package/guards/dist/xstate-guards.development.esm.js +1 -1
  40. package/guards/dist/xstate-guards.esm.js +1 -1
  41. package/guards/dist/xstate-guards.umd.min.js.map +1 -1
  42. package/package.json +1 -1
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var guards_dist_xstateGuards = require('../../dist/raise-fabffc3d.cjs.js');
5
+ var guards_dist_xstateGuards = require('../../dist/raise-a1d3d7e9.cjs.js');
6
6
  require('../../dev/dist/xstate-dev.cjs.js');
7
7
 
8
8
  /**
@@ -231,6 +231,7 @@ function fromCallback(invokeCallback) {
231
231
  * - `input` - Data that was provided to the observable actor
232
232
  * - `self` - The parent actor
233
233
  * - `system` - The actor system to which the observable actor belongs
234
+ *
234
235
  * It should return a {@link Subscribable}, which is compatible with an RxJS Observable, although RxJS is not required to create them.
235
236
  *
236
237
  * @example
@@ -365,12 +366,48 @@ function fromObservable(observableCreator) {
365
366
  }
366
367
 
367
368
  /**
368
- * Creates event observable logic that listens to an observable
369
- * that delivers event objects.
369
+ * Creates event observable logic that listens to an observable that delivers event objects.
370
+ *
371
+ * Event observable actor logic is described by an observable stream of {@link https://stately.ai/docs/transitions#event-objects | event objects}. Actors created from event observable logic (“event observable actors”) can:
372
+ *
373
+ * - Implicitly send events to its parent actor
374
+ * - Emit snapshots of its emitted event objects
375
+ *
376
+ * Sending events to event observable actors will have no effect.
370
377
  *
378
+ * @param lazyObservable A function that creates an observable that delivers event objects. It receives one argument, an object with the following properties:
379
+ *
380
+ * - `input` - Data that was provided to the event observable actor
381
+ * - `self` - The parent actor
382
+ * - `system` - The actor system to which the event observable actor belongs.
383
+ *
384
+ * It should return a {@link Subscribable}, which is compatible with an RxJS Observable, although RxJS is not required to create them.
371
385
  *
372
- * @param lazyObservable A function that creates an observable
373
- * @returns Event observable logic
386
+ * @example
387
+ * ```ts
388
+ * import {
389
+ * fromEventObservable,
390
+ * Subscribable,
391
+ * EventObject,
392
+ * createMachine,
393
+ * createActor
394
+ * } from 'xstate';
395
+ * import { fromEvent } from 'rxjs';
396
+ *
397
+ * const mouseClickLogic = fromEventObservable(() =>
398
+ * fromEvent(document.body, 'click') as Subscribable<EventObject>
399
+ * );
400
+ *
401
+ * const canvasMachine = createMachine({
402
+ * invoke: {
403
+ * // Will send mouse `click` events to the canvas actor
404
+ * src: mouseClickLogic,
405
+ * }
406
+ * });
407
+ *
408
+ * const canvasActor = createActor(canvasMachine);
409
+ * canvasActor.start();
410
+ * ```
374
411
  */
375
412
 
376
413
  function fromEventObservable(lazyObservable) {
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var guards_dist_xstateGuards = require('../../dist/raise-b3fb3c65.development.cjs.js');
5
+ var guards_dist_xstateGuards = require('../../dist/raise-a9e7e31c.development.cjs.js');
6
6
  require('../../dev/dist/xstate-dev.development.cjs.js');
7
7
 
8
8
  /**
@@ -231,6 +231,7 @@ function fromCallback(invokeCallback) {
231
231
  * - `input` - Data that was provided to the observable actor
232
232
  * - `self` - The parent actor
233
233
  * - `system` - The actor system to which the observable actor belongs
234
+ *
234
235
  * It should return a {@link Subscribable}, which is compatible with an RxJS Observable, although RxJS is not required to create them.
235
236
  *
236
237
  * @example
@@ -365,12 +366,48 @@ function fromObservable(observableCreator) {
365
366
  }
366
367
 
367
368
  /**
368
- * Creates event observable logic that listens to an observable
369
- * that delivers event objects.
369
+ * Creates event observable logic that listens to an observable that delivers event objects.
370
+ *
371
+ * Event observable actor logic is described by an observable stream of {@link https://stately.ai/docs/transitions#event-objects | event objects}. Actors created from event observable logic (“event observable actors”) can:
372
+ *
373
+ * - Implicitly send events to its parent actor
374
+ * - Emit snapshots of its emitted event objects
375
+ *
376
+ * Sending events to event observable actors will have no effect.
370
377
  *
378
+ * @param lazyObservable A function that creates an observable that delivers event objects. It receives one argument, an object with the following properties:
379
+ *
380
+ * - `input` - Data that was provided to the event observable actor
381
+ * - `self` - The parent actor
382
+ * - `system` - The actor system to which the event observable actor belongs.
383
+ *
384
+ * It should return a {@link Subscribable}, which is compatible with an RxJS Observable, although RxJS is not required to create them.
371
385
  *
372
- * @param lazyObservable A function that creates an observable
373
- * @returns Event observable logic
386
+ * @example
387
+ * ```ts
388
+ * import {
389
+ * fromEventObservable,
390
+ * Subscribable,
391
+ * EventObject,
392
+ * createMachine,
393
+ * createActor
394
+ * } from 'xstate';
395
+ * import { fromEvent } from 'rxjs';
396
+ *
397
+ * const mouseClickLogic = fromEventObservable(() =>
398
+ * fromEvent(document.body, 'click') as Subscribable<EventObject>
399
+ * );
400
+ *
401
+ * const canvasMachine = createMachine({
402
+ * invoke: {
403
+ * // Will send mouse `click` events to the canvas actor
404
+ * src: mouseClickLogic,
405
+ * }
406
+ * });
407
+ *
408
+ * const canvasActor = createActor(canvasMachine);
409
+ * canvasActor.start();
410
+ * ```
374
411
  */
375
412
 
376
413
  function fromEventObservable(lazyObservable) {
@@ -1,4 +1,4 @@
1
- import { X as XSTATE_STOP, B as createActor } from '../../dist/raise-90139fbc.development.esm.js';
1
+ import { X as XSTATE_STOP, C as createActor } from '../../dist/raise-fa23c2b9.development.esm.js';
2
2
  import '../../dev/dist/xstate-dev.development.esm.js';
3
3
 
4
4
  /**
@@ -227,6 +227,7 @@ function fromCallback(invokeCallback) {
227
227
  * - `input` - Data that was provided to the observable actor
228
228
  * - `self` - The parent actor
229
229
  * - `system` - The actor system to which the observable actor belongs
230
+ *
230
231
  * It should return a {@link Subscribable}, which is compatible with an RxJS Observable, although RxJS is not required to create them.
231
232
  *
232
233
  * @example
@@ -361,12 +362,48 @@ function fromObservable(observableCreator) {
361
362
  }
362
363
 
363
364
  /**
364
- * Creates event observable logic that listens to an observable
365
- * that delivers event objects.
365
+ * Creates event observable logic that listens to an observable that delivers event objects.
366
+ *
367
+ * Event observable actor logic is described by an observable stream of {@link https://stately.ai/docs/transitions#event-objects | event objects}. Actors created from event observable logic (“event observable actors”) can:
368
+ *
369
+ * - Implicitly send events to its parent actor
370
+ * - Emit snapshots of its emitted event objects
371
+ *
372
+ * Sending events to event observable actors will have no effect.
366
373
  *
374
+ * @param lazyObservable A function that creates an observable that delivers event objects. It receives one argument, an object with the following properties:
375
+ *
376
+ * - `input` - Data that was provided to the event observable actor
377
+ * - `self` - The parent actor
378
+ * - `system` - The actor system to which the event observable actor belongs.
379
+ *
380
+ * It should return a {@link Subscribable}, which is compatible with an RxJS Observable, although RxJS is not required to create them.
367
381
  *
368
- * @param lazyObservable A function that creates an observable
369
- * @returns Event observable logic
382
+ * @example
383
+ * ```ts
384
+ * import {
385
+ * fromEventObservable,
386
+ * Subscribable,
387
+ * EventObject,
388
+ * createMachine,
389
+ * createActor
390
+ * } from 'xstate';
391
+ * import { fromEvent } from 'rxjs';
392
+ *
393
+ * const mouseClickLogic = fromEventObservable(() =>
394
+ * fromEvent(document.body, 'click') as Subscribable<EventObject>
395
+ * );
396
+ *
397
+ * const canvasMachine = createMachine({
398
+ * invoke: {
399
+ * // Will send mouse `click` events to the canvas actor
400
+ * src: mouseClickLogic,
401
+ * }
402
+ * });
403
+ *
404
+ * const canvasActor = createActor(canvasMachine);
405
+ * canvasActor.start();
406
+ * ```
370
407
  */
371
408
 
372
409
  function fromEventObservable(lazyObservable) {
@@ -1,4 +1,4 @@
1
- import { X as XSTATE_STOP, B as createActor } from '../../dist/raise-2b5a4e4c.esm.js';
1
+ import { X as XSTATE_STOP, C as createActor } from '../../dist/raise-1682abb7.esm.js';
2
2
  import '../../dev/dist/xstate-dev.esm.js';
3
3
 
4
4
  /**
@@ -227,6 +227,7 @@ function fromCallback(invokeCallback) {
227
227
  * - `input` - Data that was provided to the observable actor
228
228
  * - `self` - The parent actor
229
229
  * - `system` - The actor system to which the observable actor belongs
230
+ *
230
231
  * It should return a {@link Subscribable}, which is compatible with an RxJS Observable, although RxJS is not required to create them.
231
232
  *
232
233
  * @example
@@ -361,12 +362,48 @@ function fromObservable(observableCreator) {
361
362
  }
362
363
 
363
364
  /**
364
- * Creates event observable logic that listens to an observable
365
- * that delivers event objects.
365
+ * Creates event observable logic that listens to an observable that delivers event objects.
366
+ *
367
+ * Event observable actor logic is described by an observable stream of {@link https://stately.ai/docs/transitions#event-objects | event objects}. Actors created from event observable logic (“event observable actors”) can:
368
+ *
369
+ * - Implicitly send events to its parent actor
370
+ * - Emit snapshots of its emitted event objects
371
+ *
372
+ * Sending events to event observable actors will have no effect.
366
373
  *
374
+ * @param lazyObservable A function that creates an observable that delivers event objects. It receives one argument, an object with the following properties:
375
+ *
376
+ * - `input` - Data that was provided to the event observable actor
377
+ * - `self` - The parent actor
378
+ * - `system` - The actor system to which the event observable actor belongs.
379
+ *
380
+ * It should return a {@link Subscribable}, which is compatible with an RxJS Observable, although RxJS is not required to create them.
367
381
  *
368
- * @param lazyObservable A function that creates an observable
369
- * @returns Event observable logic
382
+ * @example
383
+ * ```ts
384
+ * import {
385
+ * fromEventObservable,
386
+ * Subscribable,
387
+ * EventObject,
388
+ * createMachine,
389
+ * createActor
390
+ * } from 'xstate';
391
+ * import { fromEvent } from 'rxjs';
392
+ *
393
+ * const mouseClickLogic = fromEventObservable(() =>
394
+ * fromEvent(document.body, 'click') as Subscribable<EventObject>
395
+ * );
396
+ *
397
+ * const canvasMachine = createMachine({
398
+ * invoke: {
399
+ * // Will send mouse `click` events to the canvas actor
400
+ * src: mouseClickLogic,
401
+ * }
402
+ * });
403
+ *
404
+ * const canvasActor = createActor(canvasMachine);
405
+ * canvasActor.start();
406
+ * ```
370
407
  */
371
408
 
372
409
  function fromEventObservable(lazyObservable) {