xstate 5.0.0-alpha.0 → 5.0.0-alpha.1

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 (83) hide show
  1. package/README.md +23 -13
  2. package/actions/dist/xstate-actions.cjs.dev.js +22 -24
  3. package/actions/dist/xstate-actions.cjs.prod.js +22 -24
  4. package/actions/dist/xstate-actions.esm.js +1 -1
  5. package/actions/dist/xstate-actions.umd.min.js +2 -0
  6. package/actions/dist/xstate-actions.umd.min.js.map +1 -0
  7. package/actions/dynamicAction.ts +4 -4
  8. package/actions/package.json +5 -1
  9. package/actors/dist/xstate-actors.cjs.dev.js +12 -13
  10. package/actors/dist/xstate-actors.cjs.prod.js +12 -13
  11. package/actors/dist/xstate-actors.esm.js +1 -1
  12. package/actors/dist/xstate-actors.umd.min.js +2 -0
  13. package/actors/dist/xstate-actors.umd.min.js.map +1 -0
  14. package/actors/package.json +5 -1
  15. package/dev/dist/xstate-dev.umd.min.js +2 -0
  16. package/dev/dist/xstate-dev.umd.min.js.map +1 -0
  17. package/dev/package.json +5 -1
  18. package/dist/{actions-70094c93.cjs.prod.js → actions-7ea9280f.cjs.prod.js} +3118 -3209
  19. package/dist/{actions-6b86876d.cjs.dev.js → actions-b08d0da8.cjs.dev.js} +3105 -3202
  20. package/dist/{actions-ff512f16.esm.js → actions-b673cb13.esm.js} +3092 -3189
  21. package/dist/declarations/actions/dynamicAction.d.ts +5 -3
  22. package/dist/declarations/src/Machine.d.ts +4 -4
  23. package/dist/declarations/src/Mailbox.d.ts +12 -12
  24. package/dist/declarations/src/SimulatedClock.d.ts +16 -16
  25. package/dist/declarations/src/State.d.ts +97 -104
  26. package/dist/declarations/src/StateMachine.d.ts +120 -112
  27. package/dist/declarations/src/StateNode.d.ts +127 -127
  28. package/dist/declarations/src/actionTypes.d.ts +16 -17
  29. package/dist/declarations/src/actions/assign.d.ts +7 -7
  30. package/dist/declarations/src/actions/cancel.d.ts +10 -10
  31. package/dist/declarations/src/actions/choose.d.ts +3 -3
  32. package/dist/declarations/src/actions/invoke.d.ts +3 -3
  33. package/dist/declarations/src/actions/log.d.ts +11 -11
  34. package/dist/declarations/src/actions/pure.d.ts +3 -3
  35. package/dist/declarations/src/actions/raise.d.ts +9 -9
  36. package/dist/declarations/src/actions/send.d.ts +51 -55
  37. package/dist/declarations/src/actions/stop.d.ts +7 -8
  38. package/dist/declarations/src/actions.d.ts +43 -44
  39. package/dist/declarations/src/actors.d.ts +37 -38
  40. package/dist/declarations/src/constants.d.ts +5 -5
  41. package/dist/declarations/src/dev/index.d.ts +14 -14
  42. package/dist/declarations/src/environment.d.ts +1 -1
  43. package/dist/declarations/src/guards.d.ts +8 -9
  44. package/dist/declarations/src/index.d.ts +44 -47
  45. package/dist/declarations/src/interpreter.d.ts +108 -147
  46. package/dist/declarations/src/mapState.d.ts +3 -3
  47. package/dist/declarations/src/memo.d.ts +2 -1
  48. package/dist/declarations/src/registry.d.ts +8 -8
  49. package/dist/declarations/src/schema.d.ts +2 -2
  50. package/dist/declarations/src/spawn.d.ts +2 -2
  51. package/dist/declarations/src/stateUtils.d.ts +70 -85
  52. package/dist/declarations/src/symbolObservable.d.ts +1 -0
  53. package/dist/declarations/src/typegenTypes.d.ts +132 -132
  54. package/dist/declarations/src/types.d.ts +1001 -1026
  55. package/dist/declarations/src/utils.d.ts +54 -56
  56. package/dist/xstate.cjs.dev.js +856 -80
  57. package/dist/xstate.cjs.prod.js +856 -80
  58. package/dist/xstate.esm.js +815 -35
  59. package/dist/xstate.umd.min.js +2 -0
  60. package/dist/xstate.umd.min.js.map +1 -0
  61. package/guards/dist/xstate-guards.cjs.dev.js +7 -7
  62. package/guards/dist/xstate-guards.cjs.prod.js +7 -7
  63. package/guards/dist/xstate-guards.esm.js +1 -1
  64. package/guards/dist/xstate-guards.umd.min.js +2 -0
  65. package/guards/dist/xstate-guards.umd.min.js.map +1 -0
  66. package/guards/package.json +5 -1
  67. package/package.json +25 -2
  68. package/CHANGELOG.md +0 -1986
  69. package/actions/ExecutableAction.ts +0 -58
  70. package/dist/Machine-9ce74c11.cjs.dev.js +0 -755
  71. package/dist/Machine-dca041dc.cjs.prod.js +0 -749
  72. package/dist/Machine-fb2f47f5.esm.js +0 -751
  73. package/dist/declarations/actions/ExecutableAction.d.ts +0 -23
  74. package/dist/declarations/src/ObservableActorRef.d.ts +0 -25
  75. package/dist/declarations/src/match.d.ts +0 -5
  76. package/dist/declarations/src/model.d.ts +0 -5
  77. package/dist/declarations/src/model.types.d.ts +0 -53
  78. package/model/dist/xstate-model.cjs.d.ts +0 -1
  79. package/model/dist/xstate-model.cjs.dev.js +0 -41
  80. package/model/dist/xstate-model.cjs.js +0 -7
  81. package/model/dist/xstate-model.cjs.prod.js +0 -41
  82. package/model/dist/xstate-model.esm.js +0 -37
  83. package/model/package.json +0 -4
@@ -1,23 +0,0 @@
1
- import type { State } from '../src/State';
2
- import { TypegenDisabled } from '../src/typegenTypes';
3
- import { BaseActionObject, EventObject, MachineContext } from '../src/types';
4
- export interface ResolvedActionObject<TContext extends MachineContext, TEvent extends EventObject, TResolvedTypesMeta = TypegenDisabled> {
5
- type: string;
6
- params: Record<string, any>;
7
- /**
8
- * The intermediate context
9
- */
10
- context: TContext | undefined;
11
- execute: (state: State<TContext, TEvent, TResolvedTypesMeta>) => any;
12
- }
13
- export declare class ExecutableAction<TContext extends object, TEvent extends EventObject, TResolvedTypesMeta = TypegenDisabled> implements ResolvedActionObject<TContext, TEvent, TResolvedTypesMeta> {
14
- actionObject: BaseActionObject;
15
- private _exec?;
16
- type: string;
17
- params: Record<string, any>;
18
- context: TContext | undefined;
19
- constructor(actionObject: BaseActionObject, _exec?: ((context: TContext, event: TEvent, meta: import("../src/types").ActionMeta<TContext, TEvent, BaseActionObject>) => void) | undefined);
20
- execute(state: State<TContext, TEvent, TResolvedTypesMeta>): void | undefined;
21
- setContext(context: TContext): void;
22
- }
23
- export declare function isExecutableAction(action: BaseActionObject | ResolvedActionObject<any, any, any>): action is ExecutableAction<any, any, any>;
@@ -1,25 +0,0 @@
1
- import { EventObject, ActorRef, Behavior } from './types';
2
- import { symbolObservable } from './utils';
3
- export declare class ObservableActorRef<TEvent extends EventObject, TSnapshot> implements ActorRef<TEvent, TSnapshot> {
4
- private behavior;
5
- name: string;
6
- private current;
7
- private context;
8
- private mailbox;
9
- private _observers;
10
- constructor(behavior: Behavior<TEvent, TSnapshot>, name: string);
11
- start(): this;
12
- stop(): this;
13
- subscribe(observer: any): {
14
- unsubscribe: () => void;
15
- };
16
- send(event: any): void;
17
- toJSON(): {
18
- name: string;
19
- current: TSnapshot;
20
- };
21
- getSnapshot(): TSnapshot;
22
- [symbolObservable](): this;
23
- private receive;
24
- private _process;
25
- }
@@ -1,5 +0,0 @@
1
- import { State } from './State';
2
- import { StateValue, EventObject, MachineContext } from './types';
3
- export declare type ValueFromStateGetter<T, TContext extends MachineContext, TEvent extends EventObject> = (state: State<TContext, TEvent>) => T;
4
- export declare type StatePatternTuple<T, TContext extends MachineContext, TEvent extends EventObject> = [StateValue, ValueFromStateGetter<T, TContext, TEvent>];
5
- export declare function matchState<T, TContext extends MachineContext, TEvent extends EventObject>(state: State<TContext, TEvent> | StateValue, patterns: Array<StatePatternTuple<T, TContext, TEvent>>, defaultValue: ValueFromStateGetter<T, TContext, TEvent>): T;
@@ -1,5 +0,0 @@
1
- import type { MachineContext, Cast, EventObject, BaseActionObject, Prop, IsNever } from './types';
2
- import { UnionFromCreatorsReturnTypes, FinalModelCreators, Model, ModelCreators } from './model.types';
3
- export declare function createModel<TContext extends MachineContext, TEvent extends EventObject, TAction extends BaseActionObject = BaseActionObject>(initialContext: TContext): Model<TContext, TEvent, TAction, void>;
4
- export declare function createModel<TContext extends MachineContext, TEvent extends EventObject>(initialContext: TContext): Model<TContext, TEvent, never>;
5
- export declare function createModel<TContext extends MachineContext, TModelCreators extends ModelCreators<TModelCreators>, TFinalModelCreators = FinalModelCreators<TModelCreators>, TComputedEvent = UnionFromCreatorsReturnTypes<Prop<TFinalModelCreators, 'events'>>, TComputedAction = UnionFromCreatorsReturnTypes<Prop<TFinalModelCreators, 'actions'>>>(initialContext: TContext, creators: TModelCreators): Model<TContext, Cast<TComputedEvent, EventObject>, IsNever<TComputedAction> extends true ? BaseActionObject : Cast<TComputedAction, BaseActionObject>, TFinalModelCreators>;
@@ -1,53 +0,0 @@
1
- import type { StateMachine } from './StateMachine';
2
- import { ResolveTypegenMeta, TypegenConstraint, TypegenDisabled } from './typegenTypes';
3
- import { ActorMap, AnyFunction, Assigner, BaseActionObject, Compute, DynamicAssignAction, EventObject, InternalMachineImplementations, MachineConfig, MachineContext, Prop, PropertyAssigner } from './types';
4
- declare type SimplisticExtractEvent<TEvent extends EventObject, TEventType extends TEvent['type']> = TEvent extends {
5
- type: TEventType;
6
- } ? TEvent : never;
7
- export interface Model<TContext extends MachineContext, TEvent extends EventObject, TAction extends BaseActionObject = BaseActionObject, TModelCreators = void> {
8
- initialContext: TContext;
9
- assign: <TEventType extends TEvent['type'] = TEvent['type']>(assigner: Assigner<TContext, SimplisticExtractEvent<TEvent, TEventType>> | PropertyAssigner<TContext, SimplisticExtractEvent<TEvent, TEventType>>, eventType?: TEventType) => DynamicAssignAction<TContext, SimplisticExtractEvent<TEvent, TEventType>>;
10
- events: Prop<TModelCreators, 'events'>;
11
- actions: Prop<TModelCreators, 'actions'>;
12
- reset: () => DynamicAssignAction<TContext, any>;
13
- createMachine: {
14
- <TActorMap extends ActorMap = ActorMap, TTypesMeta extends TypegenConstraint = TypegenDisabled>(config: MachineConfig<TContext, TEvent, TAction, TActorMap, TTypesMeta>, implementations?: InternalMachineImplementations<TContext, TEvent, ResolveTypegenMeta<TTypesMeta, TEvent, TAction, TActorMap>>): StateMachine<TContext, TEvent, TAction, TActorMap, ResolveTypegenMeta<TTypesMeta, TEvent, TAction, TActorMap>>;
15
- };
16
- }
17
- export declare type ModelContextFrom<TModel extends Model<any, any, any, any>> = TModel extends Model<infer TContext, any, any, any> ? TContext : never;
18
- export declare type ModelEventsFrom<TModel extends Model<any, any, any, any> | undefined> = TModel extends Model<any, infer TEvent, any, any> ? TEvent : EventObject;
19
- export declare type ModelActionsFrom<TModel extends Model<any, any, any, any>> = TModel extends Model<any, any, infer TAction, any> ? TAction : never;
20
- export declare type EventCreator<Self extends AnyFunction, Return = ReturnType<Self>> = Return extends object ? Return extends {
21
- type: any;
22
- } ? "An event creator can't return an object with a type property" : Self : 'An event creator must return an object';
23
- export declare type EventCreators<Self> = {
24
- [K in keyof Self]: Self[K] extends AnyFunction ? EventCreator<Self[K]> : 'An event creator must be a function';
25
- };
26
- export declare type FinalEventCreators<Self> = {
27
- [K in keyof Self]: Self[K] extends AnyFunction ? (...args: Parameters<Self[K]>) => Compute<ReturnType<Self[K]> & {
28
- type: K;
29
- }> : never;
30
- };
31
- export declare type ActionCreator<Self extends AnyFunction, Return = ReturnType<Self>> = Return extends object ? Return extends {
32
- type: any;
33
- } ? "An action creator can't return an object with a type property" : Self : 'An action creator must return an object';
34
- export declare type ActionCreators<Self> = {
35
- [K in keyof Self]: Self[K] extends AnyFunction ? ActionCreator<Self[K]> : 'An action creator must be a function';
36
- };
37
- export declare type FinalActionCreators<Self> = {
38
- [K in keyof Self]: Self[K] extends AnyFunction ? (...args: Parameters<Self[K]>) => Compute<ReturnType<Self[K]> & {
39
- type: K;
40
- }> : never;
41
- };
42
- export interface ModelCreators<Self> {
43
- events?: EventCreators<Prop<Self, 'events'>>;
44
- actions?: ActionCreators<Prop<Self, 'actions'>>;
45
- }
46
- export interface FinalModelCreators<Self> {
47
- events: FinalEventCreators<Prop<Self, 'events'>>;
48
- actions: FinalActionCreators<Prop<Self, 'actions'>>;
49
- }
50
- export declare type UnionFromCreatorsReturnTypes<TCreators> = {
51
- [K in keyof TCreators]: TCreators[K] extends AnyFunction ? ReturnType<TCreators[K]> : never;
52
- }[keyof TCreators];
53
- export {};
@@ -1 +0,0 @@
1
- export * from "../../dist/declarations/src/model";
@@ -1,41 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var guards_dist_xstateGuards = require('../../dist/actions-6b86876d.cjs.dev.js');
6
- require('../../dist/index-2a564d03.cjs.dev.js');
7
- var Machine = require('../../dist/Machine-9ce74c11.cjs.dev.js');
8
-
9
- function createModel(initialContext, creators) {
10
- var eventCreators = creators === null || creators === void 0 ? void 0 : creators.events;
11
- var actionCreators = creators === null || creators === void 0 ? void 0 : creators.actions;
12
- var model = {
13
- initialContext: initialContext,
14
- assign: guards_dist_xstateGuards.assign,
15
- events: eventCreators ? guards_dist_xstateGuards.mapValues(eventCreators, function (fn, eventType) {
16
- return function () {
17
- return guards_dist_xstateGuards._objectSpread2(guards_dist_xstateGuards._objectSpread2({}, fn.apply(void 0, arguments)), {}, {
18
- type: eventType
19
- });
20
- };
21
- }) : undefined,
22
- actions: actionCreators ? guards_dist_xstateGuards.mapValues(actionCreators, function (fn, actionType) {
23
- return function () {
24
- return guards_dist_xstateGuards._objectSpread2(guards_dist_xstateGuards._objectSpread2({}, fn.apply(void 0, arguments)), {}, {
25
- type: actionType
26
- });
27
- };
28
- }) : undefined,
29
- reset: function reset() {
30
- return guards_dist_xstateGuards.assign(initialContext);
31
- },
32
- createMachine: function createMachine(config, implementations) {
33
- return Machine.createMachine('context' in config ? config : guards_dist_xstateGuards._objectSpread2(guards_dist_xstateGuards._objectSpread2({}, config), {}, {
34
- context: initialContext
35
- }), implementations);
36
- }
37
- };
38
- return model;
39
- }
40
-
41
- exports.createModel = createModel;
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- if (process.env.NODE_ENV === "production") {
4
- module.exports = require("./xstate-model.cjs.prod.js");
5
- } else {
6
- module.exports = require("./xstate-model.cjs.dev.js");
7
- }
@@ -1,41 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var guards_dist_xstateGuards = require('../../dist/actions-70094c93.cjs.prod.js');
6
- require('../../dev/dist/xstate-dev.cjs.prod.js');
7
- var Machine = require('../../dist/Machine-dca041dc.cjs.prod.js');
8
-
9
- function createModel(initialContext, creators) {
10
- var eventCreators = creators === null || creators === void 0 ? void 0 : creators.events;
11
- var actionCreators = creators === null || creators === void 0 ? void 0 : creators.actions;
12
- var model = {
13
- initialContext: initialContext,
14
- assign: guards_dist_xstateGuards.assign,
15
- events: eventCreators ? guards_dist_xstateGuards.mapValues(eventCreators, function (fn, eventType) {
16
- return function () {
17
- return guards_dist_xstateGuards._objectSpread2(guards_dist_xstateGuards._objectSpread2({}, fn.apply(void 0, arguments)), {}, {
18
- type: eventType
19
- });
20
- };
21
- }) : undefined,
22
- actions: actionCreators ? guards_dist_xstateGuards.mapValues(actionCreators, function (fn, actionType) {
23
- return function () {
24
- return guards_dist_xstateGuards._objectSpread2(guards_dist_xstateGuards._objectSpread2({}, fn.apply(void 0, arguments)), {}, {
25
- type: actionType
26
- });
27
- };
28
- }) : undefined,
29
- reset: function reset() {
30
- return guards_dist_xstateGuards.assign(initialContext);
31
- },
32
- createMachine: function createMachine(config, implementations) {
33
- return Machine.createMachine('context' in config ? config : guards_dist_xstateGuards._objectSpread2(guards_dist_xstateGuards._objectSpread2({}, config), {}, {
34
- context: initialContext
35
- }), implementations);
36
- }
37
- };
38
- return model;
39
- }
40
-
41
- exports.createModel = createModel;
@@ -1,37 +0,0 @@
1
- import { n as assign, M as mapValues, X as _objectSpread2 } from '../../dist/actions-ff512f16.esm.js';
2
- import '../../dist/index-20b364c4.esm.js';
3
- import { c as createMachine } from '../../dist/Machine-fb2f47f5.esm.js';
4
-
5
- function createModel(initialContext, creators) {
6
- var eventCreators = creators === null || creators === void 0 ? void 0 : creators.events;
7
- var actionCreators = creators === null || creators === void 0 ? void 0 : creators.actions;
8
- var model = {
9
- initialContext: initialContext,
10
- assign: assign,
11
- events: eventCreators ? mapValues(eventCreators, function (fn, eventType) {
12
- return function () {
13
- return _objectSpread2(_objectSpread2({}, fn.apply(void 0, arguments)), {}, {
14
- type: eventType
15
- });
16
- };
17
- }) : undefined,
18
- actions: actionCreators ? mapValues(actionCreators, function (fn, actionType) {
19
- return function () {
20
- return _objectSpread2(_objectSpread2({}, fn.apply(void 0, arguments)), {}, {
21
- type: actionType
22
- });
23
- };
24
- }) : undefined,
25
- reset: function reset() {
26
- return assign(initialContext);
27
- },
28
- createMachine: function createMachine$1(config, implementations) {
29
- return createMachine('context' in config ? config : _objectSpread2(_objectSpread2({}, config), {}, {
30
- context: initialContext
31
- }), implementations);
32
- }
33
- };
34
- return model;
35
- }
36
-
37
- export { createModel };
@@ -1,4 +0,0 @@
1
- {
2
- "main": "dist/xstate-model.cjs.js",
3
- "module": "dist/xstate-model.esm.js"
4
- }