xstate 4.30.2 → 4.30.5

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/lib/index.d.ts CHANGED
@@ -1,17 +1,19 @@
1
- import { matchesState } from './utils';
2
- import { mapState } from './mapState';
3
- import { StateNode } from './StateNode';
4
- import { State } from './State';
5
- import { Machine, createMachine } from './Machine';
6
- import { Actor, toActorRef } from './Actor';
7
1
  import * as actions from './actions';
8
- import { interpret, Interpreter, spawn, InterpreterStatus } from './interpreter';
2
+ import { Actor, toActorRef } from './Actor';
3
+ import { interpret, Interpreter, InterpreterStatus, spawn } from './interpreter';
4
+ import { createMachine, Machine } from './Machine';
5
+ import { mapState } from './mapState';
9
6
  import { matchState } from './match';
10
7
  import { createSchema, t } from './schema';
11
- declare const assign: <TContext, TEvent extends import("./types").EventObject = import("./types").EventObject>(assignment: import("./types").Assigner<TContext, TEvent> | import("./types").PropertyAssigner<TContext, TEvent>) => import("./types").AssignAction<TContext, TEvent>, send: typeof actions.send, sendParent: typeof actions.sendParent, sendUpdate: typeof actions.sendUpdate, forwardTo: typeof actions.forwardTo, doneInvoke: typeof actions.doneInvoke;
12
- export { Actor, toActorRef, Machine, StateNode, State, matchesState, mapState, actions, assign, send, sendParent, sendUpdate, forwardTo, interpret, Interpreter, InterpreterStatus, matchState, spawn, doneInvoke, createMachine, createSchema, t };
13
- export * from './types';
8
+ import { State } from './State';
9
+ import { StateNode } from './StateNode';
10
+ export { spawnBehavior } from './behaviors';
11
+ export { XStateDevInterface } from './devTools';
14
12
  export * from './typegenTypes';
13
+ export * from './types';
14
+ export { matchesState, toEventObject, toObserver, toSCXMLEvent } from './utils';
15
+ export { Actor, toActorRef, Machine, StateNode, State, mapState, actions, assign, send, sendParent, sendUpdate, forwardTo, interpret, Interpreter, InterpreterStatus, matchState, spawn, doneInvoke, createMachine, createSchema, t };
16
+ declare const assign: <TContext, TEvent extends import("./types").EventObject = import("./types").EventObject>(assignment: import("./types").Assigner<TContext, TEvent> | import("./types").PropertyAssigner<TContext, TEvent>) => import("./types").AssignAction<TContext, TEvent>, send: typeof actions.send, sendParent: typeof actions.sendParent, sendUpdate: typeof actions.sendUpdate, forwardTo: typeof actions.forwardTo, doneInvoke: typeof actions.doneInvoke;
15
17
  declare global {
16
18
  interface SymbolConstructor {
17
19
  readonly observable: symbol;
package/lib/index.js CHANGED
@@ -2,17 +2,18 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var utils = require('./utils.js');
6
- var mapState = require('./mapState.js');
7
- var types = require('./types.js');
8
5
  var actions = require('./actions.js');
9
- var State = require('./State.js');
10
6
  var Actor = require('./Actor.js');
11
- var StateNode = require('./StateNode.js');
12
- var Machine = require('./Machine.js');
13
7
  var interpreter = require('./interpreter.js');
8
+ var Machine = require('./Machine.js');
9
+ var mapState = require('./mapState.js');
14
10
  var match = require('./match.js');
15
11
  var schema = require('./schema.js');
12
+ var State = require('./State.js');
13
+ var StateNode = require('./StateNode.js');
14
+ var behaviors = require('./behaviors.js');
15
+ var types = require('./types.js');
16
+ var utils = require('./utils.js');
16
17
 
17
18
  var assign = actions.assign,
18
19
  send = actions.send,
@@ -21,38 +22,36 @@ var assign = actions.assign,
21
22
  forwardTo = actions.forwardTo,
22
23
  doneInvoke = actions.doneInvoke;
23
24
 
24
- exports.matchesState = utils.matchesState;
25
- exports.mapState = mapState.mapState;
26
- Object.defineProperty(exports, 'ActionTypes', {
27
- enumerable: true,
28
- get: function () {
29
- return types.ActionTypes;
30
- }
31
- });
32
- Object.defineProperty(exports, 'SpecialTargets', {
33
- enumerable: true,
34
- get: function () {
35
- return types.SpecialTargets;
36
- }
37
- });
38
25
  exports.actions = actions;
39
- exports.State = State.State;
40
26
  exports.toActorRef = Actor.toActorRef;
41
- exports.StateNode = StateNode.StateNode;
42
- exports.Machine = Machine.Machine;
43
- exports.createMachine = Machine.createMachine;
44
27
  exports.Interpreter = interpreter.Interpreter;
45
28
  Object.defineProperty(exports, 'InterpreterStatus', {
46
29
  enumerable: true,
47
- get: function () {
48
- return interpreter.InterpreterStatus;
49
- }
30
+ get: function () { return interpreter.InterpreterStatus; }
50
31
  });
51
32
  exports.interpret = interpreter.interpret;
52
33
  exports.spawn = interpreter.spawn;
34
+ exports.Machine = Machine.Machine;
35
+ exports.createMachine = Machine.createMachine;
36
+ exports.mapState = mapState.mapState;
53
37
  exports.matchState = match.matchState;
54
38
  exports.createSchema = schema.createSchema;
55
39
  exports.t = schema.t;
40
+ exports.State = State.State;
41
+ exports.StateNode = StateNode.StateNode;
42
+ exports.spawnBehavior = behaviors.spawnBehavior;
43
+ Object.defineProperty(exports, 'ActionTypes', {
44
+ enumerable: true,
45
+ get: function () { return types.ActionTypes; }
46
+ });
47
+ Object.defineProperty(exports, 'SpecialTargets', {
48
+ enumerable: true,
49
+ get: function () { return types.SpecialTargets; }
50
+ });
51
+ exports.matchesState = utils.matchesState;
52
+ exports.toEventObject = utils.toEventObject;
53
+ exports.toObserver = utils.toObserver;
54
+ exports.toSCXMLEvent = utils.toSCXMLEvent;
56
55
  exports.assign = assign;
57
56
  exports.doneInvoke = doneInvoke;
58
57
  exports.forwardTo = forwardTo;
@@ -23,6 +23,7 @@ export declare enum InterpreterStatus {
23
23
  Running = 1,
24
24
  Stopped = 2
25
25
  }
26
+ /** @ts-ignore [symbolObservable] creates problems for people without `skipLibCheck` who are on older versions of TS, remove this comment when we drop support for TS@<4.3 */
26
27
  export declare class Interpreter<TContext, TStateSchema extends StateSchema = any, TEvent extends EventObject = EventObject, TTypestate extends Typestate<TContext> = {
27
28
  value: any;
28
29
  context: TContext;
@@ -189,6 +190,7 @@ export declare class Interpreter<TContext, TStateSchema extends StateSchema = an
189
190
  toJSON(): {
190
191
  id: string;
191
192
  };
193
+ /** @ts-ignore this creates problems for people without `skipLibCheck` who are on older versions of TS, remove this comment when we drop support for TS@<4.3 */
192
194
  [symbolObservable](): InteropSubscribable<State<TContext, TEvent, TStateSchema, TTypestate, TResolvedTypesMeta>>;
193
195
  getSnapshot(): State<TContext, TEvent, TStateSchema, TTypestate, TResolvedTypesMeta>;
194
196
  }
@@ -3,30 +3,33 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _tslib = require('./_virtual/_tslib.js');
6
- var environment = require('./environment.js');
7
- var utils = require('./utils.js');
8
6
  var types = require('./types.js');
9
- var stateUtils = require('./stateUtils.js');
7
+ var State = require('./State.js');
10
8
  var actionTypes = require('./actionTypes.js');
11
9
  var actions = require('./actions.js');
12
- var State = require('./State.js');
13
- var serviceScope = require('./serviceScope.js');
14
- var Actor = require('./Actor.js');
10
+ var environment = require('./environment.js');
11
+ var utils = require('./utils.js');
15
12
  var scheduler = require('./scheduler.js');
13
+ var Actor = require('./Actor.js');
14
+ var stateUtils = require('./stateUtils.js');
16
15
  var registry = require('./registry.js');
17
16
  var devTools = require('./devTools.js');
17
+ var serviceScope = require('./serviceScope.js');
18
18
  var behaviors = require('./behaviors.js');
19
19
 
20
20
  var DEFAULT_SPAWN_OPTIONS = {
21
21
  sync: false,
22
22
  autoForward: false
23
23
  };
24
+ exports.InterpreterStatus = void 0;
24
25
 
25
26
  (function (InterpreterStatus) {
26
27
  InterpreterStatus[InterpreterStatus["NotStarted"] = 0] = "NotStarted";
27
28
  InterpreterStatus[InterpreterStatus["Running"] = 1] = "Running";
28
29
  InterpreterStatus[InterpreterStatus["Stopped"] = 2] = "Stopped";
29
30
  })(exports.InterpreterStatus || (exports.InterpreterStatus = {}));
31
+ /** @ts-ignore [symbolObservable] creates problems for people without `skipLibCheck` who are on older versions of TS, remove this comment when we drop support for TS@<4.3 */
32
+
30
33
 
31
34
  var Interpreter =
32
35
  /*#__PURE__*/
@@ -594,7 +597,7 @@ function () {
594
597
 
595
598
  try {
596
599
  // Cancel all delayed events
597
- for (var _p = _tslib.__values(utils.keys(this.delayedEventsMap)), _q = _p.next(); !_q.done; _q = _p.next()) {
600
+ for (var _p = _tslib.__values(Object.keys(this.delayedEventsMap)), _q = _p.next(); !_q.done; _q = _p.next()) {
598
601
  var key = _q.value;
599
602
  this.clock.clearTimeout(this.delayedEventsMap[key]);
600
603
  }
@@ -1311,6 +1314,8 @@ function () {
1311
1314
  id: this.id
1312
1315
  };
1313
1316
  };
1317
+ /** @ts-ignore this creates problems for people without `skipLibCheck` who are on older versions of TS, remove this comment when we drop support for TS@<4.3 */
1318
+
1314
1319
 
1315
1320
  Interpreter.prototype[utils.symbolObservable] = function () {
1316
1321
  return this;
@@ -3,10 +3,10 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _tslib = require('./_virtual/_tslib.js');
6
- require('./environment.js');
7
- require('./utils.js');
8
6
  require('./types.js');
9
7
  var actionTypes = require('./actionTypes.js');
8
+ require('./utils.js');
9
+ require('./environment.js');
10
10
 
11
11
  function toInvokeSource(src) {
12
12
  if (typeof src === 'string') {
@@ -29,9 +29,9 @@ function toInvokeDefinition(invokeConfig) {
29
29
  type: actionTypes.invoke
30
30
  }, invokeConfig), {
31
31
  toJSON: function () {
32
- var onDone = invokeConfig.onDone,
33
- onError = invokeConfig.onError,
34
- invokeDef = _tslib.__rest(invokeConfig, ["onDone", "onError"]);
32
+ invokeConfig.onDone;
33
+ invokeConfig.onError;
34
+ var invokeDef = _tslib.__rest(invokeConfig, ["onDone", "onError"]);
35
35
 
36
36
  return _tslib.__assign(_tslib.__assign({}, invokeDef), {
37
37
  type: actionTypes.invoke,
package/lib/json.js CHANGED
@@ -1,85 +1,94 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.jsonify = exports.parse = exports.stringify = exports.machineToJSON = exports.stringifyFunction = void 0;
4
- var utils_1 = require("./utils");
5
- // tslint:disable-next-line:ban-types
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var utils = require('./utils.js');
6
+
6
7
  function stringifyFunction(fn) {
7
- return {
8
- $function: fn.toString()
9
- };
8
+ return {
9
+ $function: fn.toString()
10
+ };
10
11
  }
11
- exports.stringifyFunction = stringifyFunction;
12
+
12
13
  function getStateNodeId(stateNode) {
13
- return "#".concat(stateNode.id);
14
- }
15
- // derive config from machine
14
+ return "#".concat(stateNode.id);
15
+ } // derive config from machine
16
+
17
+
16
18
  function machineToJSON(stateNode) {
17
- var config = {
18
- type: stateNode.type,
19
- initial: stateNode.initial === undefined ? undefined : String(stateNode.initial),
20
- id: stateNode.id,
21
- key: stateNode.key,
22
- entry: stateNode.onEntry,
23
- exit: stateNode.onExit,
24
- on: (0, utils_1.mapValues)(stateNode.on, function (transition) {
25
- return transition.map(function (t) {
26
- return {
27
- target: t.target ? t.target.map(getStateNodeId) : [],
28
- source: getStateNodeId(t.source),
29
- actions: t.actions,
30
- cond: t.cond,
31
- eventType: t.eventType
32
- };
33
- });
34
- }),
35
- invoke: stateNode.invoke,
36
- states: {}
37
- };
38
- Object.values(stateNode.states).forEach(function (sn) {
39
- config.states[sn.key] = machineToJSON(sn);
40
- });
41
- return config;
19
+ var config = {
20
+ type: stateNode.type,
21
+ initial: stateNode.initial === undefined ? undefined : String(stateNode.initial),
22
+ id: stateNode.id,
23
+ key: stateNode.key,
24
+ entry: stateNode.onEntry,
25
+ exit: stateNode.onExit,
26
+ on: utils.mapValues(stateNode.on, function (transition) {
27
+ return transition.map(function (t) {
28
+ return {
29
+ target: t.target ? t.target.map(getStateNodeId) : [],
30
+ source: getStateNodeId(t.source),
31
+ actions: t.actions,
32
+ cond: t.cond,
33
+ eventType: t.eventType
34
+ };
35
+ });
36
+ }),
37
+ invoke: stateNode.invoke,
38
+ states: {}
39
+ };
40
+ Object.values(stateNode.states).forEach(function (sn) {
41
+ config.states[sn.key] = machineToJSON(sn);
42
+ });
43
+ return config;
42
44
  }
43
- exports.machineToJSON = machineToJSON;
44
45
  function stringify(machine) {
45
- return JSON.stringify(machineToJSON(machine), function (_, value) {
46
- if ((0, utils_1.isFunction)(value)) {
47
- return { $function: value.toString() };
48
- }
49
- return value;
50
- });
46
+ return JSON.stringify(machineToJSON(machine), function (_, value) {
47
+ if (utils.isFunction(value)) {
48
+ return {
49
+ $function: value.toString()
50
+ };
51
+ }
52
+
53
+ return value;
54
+ });
51
55
  }
52
- exports.stringify = stringify;
53
56
  function parse(machineString) {
54
- var config = JSON.parse(machineString, function (_, value) {
55
- if (typeof value === 'object' && '$function' in value) {
56
- return new Function(value.value);
57
- }
58
- return value;
59
- });
60
- return config;
57
+ var config = JSON.parse(machineString, function (_, value) {
58
+ if (typeof value === 'object' && '$function' in value) {
59
+ return new Function(value.value);
60
+ }
61
+
62
+ return value;
63
+ });
64
+ return config;
61
65
  }
62
- exports.parse = parse;
63
66
  function jsonify(value) {
64
- Object.defineProperty(value, 'toJSON', {
65
- value: function () {
66
- return (0, utils_1.mapValues)(value, function (subValue) {
67
- if ((0, utils_1.isFunction)(subValue)) {
68
- return stringifyFunction(subValue);
69
- }
70
- else if (typeof subValue === 'object' && !Array.isArray(subValue)) {
71
- // mostly for assignments
72
- return (0, utils_1.mapValues)(subValue, function (subSubValue) {
73
- if ((0, utils_1.isFunction)(subSubValue)) {
74
- return stringifyFunction(subSubValue);
75
- }
76
- return subSubValue;
77
- });
78
- }
79
- return subValue;
80
- });
67
+ Object.defineProperty(value, 'toJSON', {
68
+ value: function () {
69
+ return utils.mapValues(value, function (subValue) {
70
+ if (utils.isFunction(subValue)) {
71
+ return stringifyFunction(subValue);
72
+ } else if (typeof subValue === 'object' && !Array.isArray(subValue)) {
73
+ // mostly for assignments
74
+ return utils.mapValues(subValue, function (subSubValue) {
75
+ if (utils.isFunction(subSubValue)) {
76
+ return stringifyFunction(subSubValue);
77
+ }
78
+
79
+ return subSubValue;
80
+ });
81
81
  }
82
- });
83
- return value;
82
+
83
+ return subValue;
84
+ });
85
+ }
86
+ });
87
+ return value;
84
88
  }
89
+
85
90
  exports.jsonify = jsonify;
91
+ exports.machineToJSON = machineToJSON;
92
+ exports.parse = parse;
93
+ exports.stringify = stringify;
94
+ exports.stringifyFunction = stringifyFunction;
package/lib/mapState.js CHANGED
@@ -11,7 +11,7 @@ function mapState(stateMap, stateId) {
11
11
  var foundStateId;
12
12
 
13
13
  try {
14
- for (var _b = _tslib.__values(utils.keys(stateMap)), _c = _b.next(); !_c.done; _c = _b.next()) {
14
+ for (var _b = _tslib.__values(Object.keys(stateMap)), _c = _b.next(); !_c.done; _c = _b.next()) {
15
15
  var mappedStateId = _c.value;
16
16
 
17
17
  if (utils.matchesState(mappedStateId, stateId) && (!foundStateId || stateId.length > foundStateId.length)) {
package/lib/model.js CHANGED
@@ -1,74 +1,54 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __read = (this && this.__read) || function (o, n) {
14
- var m = typeof Symbol === "function" && o[Symbol.iterator];
15
- if (!m) return o;
16
- var i = m.call(o), r, ar = [], e;
17
- try {
18
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
19
- }
20
- catch (error) { e = { error: error }; }
21
- finally {
22
- try {
23
- if (r && !r.done && (m = i["return"])) m.call(i);
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _tslib = require('./_virtual/_tslib.js');
6
+ var actions = require('./actions.js');
7
+ var Machine = require('./Machine.js');
8
+ var utils = require('./utils.js');
9
+
10
+ function createModel(initialContext, creators) {
11
+ var eventCreators = creators === null || creators === void 0 ? void 0 : creators.events;
12
+ var actionCreators = creators === null || creators === void 0 ? void 0 : creators.actions;
13
+ var model = {
14
+ initialContext: initialContext,
15
+ assign: actions.assign,
16
+ events: eventCreators ? utils.mapValues(eventCreators, function (fn, eventType) {
17
+ return function () {
18
+ var args = [];
19
+
20
+ for (var _i = 0; _i < arguments.length; _i++) {
21
+ args[_i] = arguments[_i];
24
22
  }
25
- finally { if (e) throw e.error; }
26
- }
27
- return ar;
28
- };
29
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
30
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
31
- if (ar || !(i in from)) {
32
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
33
- ar[i] = from[i];
23
+
24
+ return _tslib.__assign(_tslib.__assign({}, fn.apply(void 0, _tslib.__spreadArray([], _tslib.__read(args), false))), {
25
+ type: eventType
26
+ });
27
+ };
28
+ }) : undefined,
29
+ actions: actionCreators ? utils.mapValues(actionCreators, function (fn, actionType) {
30
+ return function () {
31
+ var args = [];
32
+
33
+ for (var _i = 0; _i < arguments.length; _i++) {
34
+ args[_i] = arguments[_i];
34
35
  }
36
+
37
+ return _tslib.__assign(_tslib.__assign({}, fn.apply(void 0, _tslib.__spreadArray([], _tslib.__read(args), false))), {
38
+ type: actionType
39
+ });
40
+ };
41
+ }) : undefined,
42
+ reset: function () {
43
+ return actions.assign(initialContext);
44
+ },
45
+ createMachine: function (config, implementations) {
46
+ return Machine.createMachine('context' in config ? config : _tslib.__assign(_tslib.__assign({}, config), {
47
+ context: initialContext
48
+ }), implementations);
35
49
  }
36
- return to.concat(ar || Array.prototype.slice.call(from));
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.createModel = void 0;
40
- var actions_1 = require("./actions");
41
- var Machine_1 = require("./Machine");
42
- var utils_1 = require("./utils");
43
- function createModel(initialContext, creators) {
44
- var eventCreators = creators === null || creators === void 0 ? void 0 : creators.events;
45
- var actionCreators = creators === null || creators === void 0 ? void 0 : creators.actions;
46
- var model = {
47
- initialContext: initialContext,
48
- assign: actions_1.assign,
49
- events: (eventCreators
50
- ? (0, utils_1.mapValues)(eventCreators, function (fn, eventType) { return function () {
51
- var args = [];
52
- for (var _i = 0; _i < arguments.length; _i++) {
53
- args[_i] = arguments[_i];
54
- }
55
- return (__assign(__assign({}, fn.apply(void 0, __spreadArray([], __read(args), false))), { type: eventType }));
56
- }; })
57
- : undefined),
58
- actions: actionCreators
59
- ? (0, utils_1.mapValues)(actionCreators, function (fn, actionType) { return function () {
60
- var args = [];
61
- for (var _i = 0; _i < arguments.length; _i++) {
62
- args[_i] = arguments[_i];
63
- }
64
- return (__assign(__assign({}, fn.apply(void 0, __spreadArray([], __read(args), false))), { type: actionType }));
65
- }; })
66
- : undefined,
67
- reset: function () { return (0, actions_1.assign)(initialContext); },
68
- createMachine: function (config, implementations) {
69
- return (0, Machine_1.createMachine)('context' in config ? config : __assign(__assign({}, config), { context: initialContext }), implementations);
70
- }
71
- };
72
- return model;
50
+ };
51
+ return model;
73
52
  }
53
+
74
54
  exports.createModel = createModel;
package/lib/patterns.js CHANGED
@@ -1,61 +1,53 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.sequence = exports.toggle = void 0;
15
- var utils_1 = require("./utils");
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _tslib = require('./_virtual/_tslib.js');
6
+ var utils = require('./utils.js');
7
+
16
8
  function toggle(onState, offState, eventType) {
17
- var _a, _b, _c;
18
- return _a = {},
19
- _a[onState] = {
20
- on: (_b = {}, _b[eventType] = offState, _b)
21
- },
22
- _a[offState] = {
23
- on: (_c = {}, _c[eventType] = onState, _c)
24
- },
25
- _a;
9
+ var _a, _b, _c;
10
+
11
+ return _a = {}, _a[onState] = {
12
+ on: (_b = {}, _b[eventType] = offState, _b)
13
+ }, _a[offState] = {
14
+ on: (_c = {}, _c[eventType] = onState, _c)
15
+ }, _a;
26
16
  }
27
- exports.toggle = toggle;
28
17
  var defaultSequencePatternOptions = {
29
- nextEvent: 'NEXT',
30
- prevEvent: 'PREV'
18
+ nextEvent: 'NEXT',
19
+ prevEvent: 'PREV'
31
20
  };
32
21
  function sequence(items, options) {
33
- var resolvedOptions = __assign(__assign({}, defaultSequencePatternOptions), options);
34
- var states = {};
35
- var nextEventObject = resolvedOptions.nextEvent === undefined
36
- ? undefined
37
- : (0, utils_1.toEventObject)(resolvedOptions.nextEvent);
38
- var prevEventObject = resolvedOptions.prevEvent === undefined
39
- ? undefined
40
- : (0, utils_1.toEventObject)(resolvedOptions.prevEvent);
41
- items.forEach(function (item, i) {
42
- var state = {
43
- on: {}
44
- };
45
- if (i + 1 === items.length) {
46
- state.type = 'final';
47
- }
48
- if (nextEventObject && i + 1 < items.length) {
49
- state.on[nextEventObject.type] = items[i + 1];
50
- }
51
- if (prevEventObject && i > 0) {
52
- state.on[prevEventObject.type] = items[i - 1];
53
- }
54
- states[item] = state;
55
- });
56
- return {
57
- initial: items[0],
58
- states: states
22
+ var resolvedOptions = _tslib.__assign(_tslib.__assign({}, defaultSequencePatternOptions), options);
23
+
24
+ var states = {};
25
+ var nextEventObject = resolvedOptions.nextEvent === undefined ? undefined : utils.toEventObject(resolvedOptions.nextEvent);
26
+ var prevEventObject = resolvedOptions.prevEvent === undefined ? undefined : utils.toEventObject(resolvedOptions.prevEvent);
27
+ items.forEach(function (item, i) {
28
+ var state = {
29
+ on: {}
59
30
  };
31
+
32
+ if (i + 1 === items.length) {
33
+ state.type = 'final';
34
+ }
35
+
36
+ if (nextEventObject && i + 1 < items.length) {
37
+ state.on[nextEventObject.type] = items[i + 1];
38
+ }
39
+
40
+ if (prevEventObject && i > 0) {
41
+ state.on[prevEventObject.type] = items[i - 1];
42
+ }
43
+
44
+ states[item] = state;
45
+ });
46
+ return {
47
+ initial: items[0],
48
+ states: states
49
+ };
60
50
  }
51
+
61
52
  exports.sequence = sequence;
53
+ exports.toggle = toggle;
package/lib/scxml.js CHANGED
@@ -108,7 +108,7 @@ function delayToMs(delay) {
108
108
  }
109
109
  var evaluateExecutableContent = function (context, _ev, meta, body) {
110
110
  var datamodel = context
111
- ? (0, utils_1.keys)(context)
111
+ ? Object.keys(context)
112
112
  .map(function (key) { return "const ".concat(key, " = context['").concat(key, "'];"); })
113
113
  .join('\n')
114
114
  : '';
package/lib/stateUtils.js CHANGED
@@ -9,7 +9,7 @@ var isLeafNode = function (stateNode) {
9
9
  return stateNode.type === 'atomic' || stateNode.type === 'final';
10
10
  };
11
11
  function getChildren(stateNode) {
12
- return utils.keys(stateNode.states).map(function (key) {
12
+ return Object.keys(stateNode.states).map(function (key) {
13
13
  return stateNode.states[key];
14
14
  });
15
15
  }