xstate 4.26.0 → 4.26.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.
package/es/interpreter.js CHANGED
@@ -87,14 +87,15 @@ function () {
87
87
  if (_this.status === InterpreterStatus.Stopped) {
88
88
  // do nothing
89
89
  if (!IS_PRODUCTION) {
90
- warn(false, "Event \"" + _event.name + "\" was sent to stopped service \"" + _this.machine.id + "\". This service has already reached its final state, and will not transition.\nEvent: " + JSON.stringify(_event.data));
90
+ warn(false, "Event \"".concat(_event.name, "\" was sent to stopped service \"").concat(_this.machine.id, "\". This service has already reached its final state, and will not transition.\nEvent: ").concat(JSON.stringify(_event.data)));
91
91
  }
92
92
 
93
93
  return _this.state;
94
94
  }
95
95
 
96
96
  if (_this.status !== InterpreterStatus.Running && !_this.options.deferEvents) {
97
- throw new Error("Event \"" + _event.name + "\" was sent to uninitialized service \"" + _this.machine.id + "\". Make sure .start() is called for this service, or set { deferEvents: true } in the service options.\nEvent: " + JSON.stringify(_event.data));
97
+ throw new Error("Event \"".concat(_event.name, "\" was sent to uninitialized service \"").concat(_this.machine.id // tslint:disable-next-line:max-line-length
98
+ , "\". Make sure .start() is called for this service, or set { deferEvents: true } in the service options.\nEvent: ").concat(JSON.stringify(_event.data)));
98
99
  }
99
100
 
100
101
  _this.scheduler.schedule(function () {
@@ -116,12 +117,12 @@ function () {
116
117
 
117
118
  if (!target) {
118
119
  if (!isParent) {
119
- throw new Error("Unable to send event to child '" + to + "' from service '" + _this.id + "'.");
120
+ throw new Error("Unable to send event to child '".concat(to, "' from service '").concat(_this.id, "'."));
120
121
  } // tslint:disable-next-line:no-console
121
122
 
122
123
 
123
124
  if (!IS_PRODUCTION) {
124
- warn(false, "Service '" + _this.id + "' has no parent: unable to send event " + event.type);
125
+ warn(false, "Service '".concat(_this.id, "' has no parent: unable to send event ").concat(event.type));
125
126
  }
126
127
 
127
128
  return;
@@ -130,7 +131,7 @@ function () {
130
131
  if ('machine' in target) {
131
132
  // Send SCXML events to machines
132
133
  target.send(__assign(__assign({}, event), {
133
- name: event.name === error$1 ? "" + error(_this.id) : event.name,
134
+ name: event.name === error$1 ? "".concat(error(_this.id)) : event.name,
134
135
  origin: _this.sessionId
135
136
  }));
136
137
  } else {
@@ -176,7 +177,7 @@ function () {
176
177
  Object.defineProperty(Interpreter.prototype, "state", {
177
178
  get: function () {
178
179
  if (!IS_PRODUCTION) {
179
- warn(this.status !== InterpreterStatus.NotStarted, "Attempted to read state from uninitialized service '" + this.id + "'. Make sure the service is started first.");
180
+ warn(this.status !== InterpreterStatus.NotStarted, "Attempted to read state from uninitialized service '".concat(this.id, "'. Make sure the service is started first."));
180
181
  }
181
182
 
182
183
  return this._state;
@@ -616,11 +617,11 @@ function () {
616
617
  if (this.status === InterpreterStatus.NotStarted && this.options.deferEvents) {
617
618
  // tslint:disable-next-line:no-console
618
619
  if (!IS_PRODUCTION) {
619
- warn(false, events.length + " event(s) were sent to uninitialized service \"" + this.machine.id + "\" and are deferred. Make sure .start() is called for this service.\nEvent: " + JSON.stringify(event));
620
+ warn(false, "".concat(events.length, " event(s) were sent to uninitialized service \"").concat(this.machine.id, "\" and are deferred. Make sure .start() is called for this service.\nEvent: ").concat(JSON.stringify(event)));
620
621
  }
621
622
  } else if (this.status !== InterpreterStatus.Running) {
622
623
  throw new Error( // tslint:disable-next-line:max-line-length
623
- events.length + " event(s) were sent to uninitialized service \"" + this.machine.id + "\". Make sure .start() is called for this service, or set { deferEvents: true } in the service options.");
624
+ "".concat(events.length, " event(s) were sent to uninitialized service \"").concat(this.machine.id, "\". Make sure .start() is called for this service, or set { deferEvents: true } in the service options."));
624
625
  }
625
626
 
626
627
  this.scheduler.schedule(function () {
@@ -640,7 +641,7 @@ function () {
640
641
  });
641
642
  batchedActions.push.apply(batchedActions, __spreadArray([], __read(nextState.actions.map(function (a) {
642
643
  return bindActionToState(a, nextState);
643
- }))));
644
+ })), false));
644
645
  batchChanged = batchChanged || !!nextState.changed;
645
646
  };
646
647
 
@@ -713,7 +714,7 @@ function () {
713
714
  var child = this.children.get(id);
714
715
 
715
716
  if (!child) {
716
- throw new Error("Unable to forward event '" + event + "' from interpreter '" + this.id + "' to nonexistant child '" + id + "'.");
717
+ throw new Error("Unable to forward event '".concat(event, "' from interpreter '").concat(this.id, "' to nonexistant child '").concat(id, "'."));
717
718
  }
718
719
 
719
720
  child.send(event);
@@ -817,7 +818,7 @@ function () {
817
818
 
818
819
  if (!IS_PRODUCTION) {
819
820
  warn(!('forward' in activity), // tslint:disable-next-line:max-line-length
820
- "`forward` property is deprecated (found in invocation of '" + activity.src + "' in in machine '" + this.machine.id + "'). " + "Please use `autoForward` instead.");
821
+ "`forward` property is deprecated (found in invocation of '".concat(activity.src, "' in in machine '").concat(this.machine.id, "'). ") + "Please use `autoForward` instead.");
821
822
  }
822
823
 
823
824
  var autoForward = 'autoForward' in activity ? activity.autoForward : !!activity.forward;
@@ -825,7 +826,7 @@ function () {
825
826
  if (!serviceCreator) {
826
827
  // tslint:disable-next-line:no-console
827
828
  if (!IS_PRODUCTION) {
828
- warn(false, "No service found for invocation '" + activity.src + "' in machine '" + this.machine.id + "'.");
829
+ warn(false, "No service found for invocation '".concat(activity.src, "' in machine '").concat(this.machine.id, "'."));
829
830
  }
830
831
 
831
832
  return;
@@ -886,7 +887,7 @@ function () {
886
887
 
887
888
  default:
888
889
  if (!IS_PRODUCTION) {
889
- warn(false, "No implementation found for action type '" + action.type + "'");
890
+ warn(false, "No implementation found for action type '".concat(action.type, "'"));
890
891
  }
891
892
 
892
893
  break;
@@ -935,7 +936,7 @@ function () {
935
936
  } else if (isBehavior(entity)) {
936
937
  return this.spawnBehavior(entity, name);
937
938
  } else {
938
- throw new Error("Unable to spawn entity \"" + name + "\" of type \"" + typeof entity + "\".");
939
+ throw new Error("Unable to spawn entity \"".concat(name, "\" of type \"").concat(typeof entity, "\"."));
939
940
  }
940
941
  };
941
942
 
@@ -1211,7 +1212,7 @@ function () {
1211
1212
 
1212
1213
  if (!implementation) {
1213
1214
  if (!IS_PRODUCTION) {
1214
- warn(false, "No implementation found for activity '" + activity.type + "'");
1215
+ warn(false, "No implementation found for activity '".concat(activity.type, "'"));
1215
1216
  } // tslint:disable-next-line:no-console
1216
1217
 
1217
1218
 
@@ -1343,7 +1344,7 @@ function spawn(entity, nameOrOptions) {
1343
1344
  return consume(function (service) {
1344
1345
  if (!IS_PRODUCTION) {
1345
1346
  var isLazyEntity = isMachine(entity) || isFunction(entity);
1346
- warn(!!service || isLazyEntity, "Attempted to spawn an Actor (ID: \"" + (isMachine(entity) ? entity.id : 'undefined') + "\") outside of a service. This will have no effect.");
1347
+ warn(!!service || isLazyEntity, "Attempted to spawn an Actor (ID: \"".concat(isMachine(entity) ? entity.id : 'undefined', "\") outside of a service. This will have no effect."));
1347
1348
  }
1348
1349
 
1349
1350
  if (service) {
package/es/registry.js CHANGED
@@ -2,7 +2,7 @@ var children = /*#__PURE__*/new Map();
2
2
  var sessionIdIndex = 0;
3
3
  var registry = {
4
4
  bookId: function () {
5
- return "x:" + sessionIdIndex++;
5
+ return "x:".concat(sessionIdIndex++);
6
6
  },
7
7
  register: function (id, actor) {
8
8
  children.set(id, actor);
package/es/stateUtils.js CHANGED
@@ -222,7 +222,7 @@ function has(iterable, item) {
222
222
  function nextEvents(configuration) {
223
223
  return __spreadArray([], __read(new Set(flatten(__spreadArray([], __read(configuration.map(function (sn) {
224
224
  return sn.ownEvents;
225
- })))))));
225
+ })), false)))), false);
226
226
  }
227
227
  function isInFinalState(configuration, stateNode) {
228
228
  if (stateNode.type === 'compound') {
package/es/types.d.ts CHANGED
@@ -81,14 +81,6 @@ export interface StateValueMap {
81
81
  * - For complex state nodes, this is an object, e.g., `{ success: "someChildState" }`.
82
82
  */
83
83
  export declare type StateValue = string | StateValueMap;
84
- declare type KeysWithStates<TStates extends Record<string, StateSchema> | undefined> = TStates extends object ? {
85
- [K in keyof TStates]-?: TStates[K] extends {
86
- states: object;
87
- } ? K : never;
88
- }[keyof TStates] : never;
89
- export declare type ExtractStateValue<TSchema extends Required<Pick<StateSchema<any>, 'states'>>> = keyof TSchema['states'] | (KeysWithStates<TSchema['states']> extends never ? never : {
90
- [K in KeysWithStates<TSchema['states']>]?: ExtractStateValue<TSchema['states'][K]>;
91
- });
92
84
  export interface HistoryValue {
93
85
  states: Record<string, HistoryValue | undefined>;
94
86
  current: StateValue | undefined;
package/es/utils.js CHANGED
@@ -36,7 +36,7 @@ function matchesState(parentStateId, childStateId, delimiter) {
36
36
  }
37
37
  function getEventType(event) {
38
38
  try {
39
- return isString(event) || typeof event === 'number' ? "" + event : event.type;
39
+ return isString(event) || typeof event === 'number' ? "".concat(event) : event.type;
40
40
  } catch (e) {
41
41
  throw new Error('Events must be strings or objects with a string event.type property.');
42
42
  }
@@ -49,7 +49,7 @@ function toStatePath(stateId, delimiter) {
49
49
 
50
50
  return stateId.toString().split(delimiter);
51
51
  } catch (e) {
52
- throw new Error("'" + stateId + "' is not a valid state path.");
52
+ throw new Error("'".concat(stateId, "' is not a valid state path."));
53
53
  }
54
54
  }
55
55
  function isStateLike(state) {
@@ -218,7 +218,7 @@ function toStatePaths(stateValue) {
218
218
  function flatten(array) {
219
219
  var _a;
220
220
 
221
- return (_a = []).concat.apply(_a, __spreadArray([], __read(array)));
221
+ return (_a = []).concat.apply(_a, __spreadArray([], __read(array), false));
222
222
  }
223
223
  function toArrayStrict(value) {
224
224
  if (isArray(value)) {
@@ -395,7 +395,7 @@ if (!IS_PRODUCTION) {
395
395
  }
396
396
 
397
397
  if (console !== undefined) {
398
- var args = ["Warning: " + message];
398
+ var args = ["Warning: ".concat(message)];
399
399
 
400
400
  if (error) {
401
401
  args.push(error);
@@ -524,15 +524,15 @@ function normalizeTarget(target) {
524
524
  }
525
525
  function reportUnhandledExceptionOnInvocation(originalError, currentError, id) {
526
526
  if (!IS_PRODUCTION) {
527
- var originalStackTrace = originalError.stack ? " Stacktrace was '" + originalError.stack + "'" : '';
527
+ var originalStackTrace = originalError.stack ? " Stacktrace was '".concat(originalError.stack, "'") : '';
528
528
 
529
529
  if (originalError === currentError) {
530
530
  // tslint:disable-next-line:no-console
531
- console.error("Missing onError handler for invocation '" + id + "', error was '" + originalError + "'." + originalStackTrace);
531
+ console.error("Missing onError handler for invocation '".concat(id, "', error was '").concat(originalError, "'.").concat(originalStackTrace));
532
532
  } else {
533
- var stackTrace = currentError.stack ? " Stacktrace was '" + currentError.stack + "'" : ''; // tslint:disable-next-line:no-console
533
+ var stackTrace = currentError.stack ? " Stacktrace was '".concat(currentError.stack, "'") : ''; // tslint:disable-next-line:no-console
534
534
 
535
- console.error("Missing onError handler and/or unhandled exception/promise rejection for invocation '" + id + "'. " + ("Original error: '" + originalError + "'. " + originalStackTrace + " Current error is '" + currentError + "'." + stackTrace));
535
+ console.error("Missing onError handler and/or unhandled exception/promise rejection for invocation '".concat(id, "'. ") + "Original error: '".concat(originalError, "'. ").concat(originalStackTrace, " Current error is '").concat(currentError, "'.").concat(stackTrace));
536
536
  }
537
537
  }
538
538
  }
@@ -551,7 +551,7 @@ function evaluateGuard(machine, guard, context, _event, state) {
551
551
  var condFn = guards[guard.type];
552
552
 
553
553
  if (!condFn) {
554
- throw new Error("Guard '" + guard.type + "' is not implemented on machine '" + machine.id + "'.");
554
+ throw new Error("Guard '".concat(guard.type, "' is not implemented on machine '").concat(machine.id, "'."));
555
555
  }
556
556
 
557
557
  return condFn(context, _event.data, guardMeta);
@@ -15,10 +15,14 @@ var __read = (this && this.__read) || function (o, n) {
15
15
  }
16
16
  return ar;
17
17
  };
18
- var __spreadArray = (this && this.__spreadArray) || function (to, from) {
19
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
20
- to[j] = from[i];
21
- return to;
18
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
19
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
20
+ if (ar || !(i in from)) {
21
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
22
+ ar[i] = from[i];
23
+ }
24
+ }
25
+ return to.concat(ar || Array.prototype.slice.call(from));
22
26
  };
23
27
  Object.defineProperty(exports, "__esModule", { value: true });
24
28
  exports.SimulatedClock = void 0;
@@ -55,7 +59,7 @@ var SimulatedClock = /** @class */ (function () {
55
59
  };
56
60
  SimulatedClock.prototype.flushTimeouts = function () {
57
61
  var _this = this;
58
- __spreadArray([], __read(this.timeouts)).sort(function (_a, _b) {
62
+ __spreadArray([], __read(this.timeouts), false).sort(function (_a, _b) {
59
63
  var _c = __read(_a, 2), _idA = _c[0], timeoutA = _c[1];
60
64
  var _d = __read(_b, 2), _idB = _d[0], timeoutB = _d[1];
61
65
  var endA = timeoutA.start + timeoutA.timeout;
package/lib/State.d.ts CHANGED
@@ -88,7 +88,7 @@ export declare class State<TContext, TEvent extends EventObject = EventObject, T
88
88
  * @param delimiter The character(s) that separate each subpath in the string state node path.
89
89
  */
90
90
  toStrings(stateValue?: StateValue, delimiter?: string): string[];
91
- toJSON(): Omit<this, "configuration" | "transitions" | "tags" | "machine"> & {
91
+ toJSON(): Omit<this, "machine" | "tags" | "transitions" | "configuration"> & {
92
92
  tags: string[];
93
93
  };
94
94
  /**
package/lib/State.js CHANGED
@@ -215,7 +215,7 @@ function () {
215
215
  return _this.toStrings(stateValue[key], delimiter).map(function (s) {
216
216
  return key + delimiter + s;
217
217
  });
218
- }))));
218
+ })), false));
219
219
  };
220
220
 
221
221
  State.prototype.toJSON = function () {
package/lib/StateNode.js CHANGED
@@ -37,8 +37,8 @@ var validateArrayifiedTransitions = function (stateNode, event, transitions) {
37
37
  var hasNonLastUnguardedTarget = transitions.slice(0, -1).some(function (transition) {
38
38
  return !('cond' in transition) && !('in' in transition) && (utils.isString(transition.target) || utils.isMachine(transition.target));
39
39
  });
40
- var eventText = event === NULL_EVENT ? 'the transient event' : "event '" + event + "'";
41
- utils.warn(!hasNonLastUnguardedTarget, "One or more transitions for " + eventText + " on state '" + stateNode.id + "' are unreachable. " + "Make sure that the default transition is the last one defined.");
40
+ var eventText = event === NULL_EVENT ? 'the transient event' : "event '".concat(event, "'");
41
+ utils.warn(!hasNonLastUnguardedTarget, "One or more transitions for ".concat(eventText, " on state '").concat(stateNode.id, "' are unreachable. ") + "Make sure that the default transition is the last one defined.");
42
42
  };
43
43
 
44
44
  var StateNode =
@@ -90,14 +90,14 @@ function () {
90
90
  this.machine = this.parent ? this.parent.machine : this;
91
91
  this.path = this.parent ? this.parent.path.concat(this.key) : [];
92
92
  this.delimiter = this.config.delimiter || (this.parent ? this.parent.delimiter : constants.STATE_DELIMITER);
93
- this.id = this.config.id || _tslib.__spreadArray([this.machine.key], _tslib.__read(this.path)).join(this.delimiter);
93
+ this.id = this.config.id || _tslib.__spreadArray([this.machine.key], _tslib.__read(this.path), false).join(this.delimiter);
94
94
  this.version = this.parent ? this.parent.version : this.config.version;
95
95
  this.type = this.config.type || (this.config.parallel ? 'parallel' : this.config.states && utils.keys(this.config.states).length ? 'compound' : this.config.history ? 'history' : 'atomic');
96
96
  this.schema = this.parent ? this.machine.schema : (_a = this.config.schema) !== null && _a !== void 0 ? _a : {};
97
97
  this.description = this.config.description;
98
98
 
99
99
  if (!environment.IS_PRODUCTION) {
100
- utils.warn(!('parallel' in this.config), "The \"parallel\" property is deprecated and will be removed in version 4.1. " + (this.config.parallel ? "Replace with `type: 'parallel'`" : "Use `type: '" + this.type + "'`") + " in the config for state node '" + this.id + "' instead.");
100
+ utils.warn(!('parallel' in this.config), "The \"parallel\" property is deprecated and will be removed in version 4.1. ".concat(this.config.parallel ? "Replace with `type: 'parallel'`" : "Use `type: '".concat(this.type, "'`"), " in the config for state node '").concat(this.id, "' instead."));
101
101
  }
102
102
 
103
103
  this.initial = this.config.initial;
@@ -170,7 +170,7 @@ function () {
170
170
  src: invokeConfig.src
171
171
  }));
172
172
  } else if (utils.isMachine(invokeConfig.src) || utils.isFunction(invokeConfig.src)) {
173
- var invokeSrc = _this.id + ":invocation[" + i + "]"; // TODO: util function
173
+ var invokeSrc = "".concat(_this.id, ":invocation[").concat(i, "]"); // TODO: util function
174
174
 
175
175
  _this.machine.options.services = _tslib.__assign((_b = {}, _b[invokeSrc] = invokeConfig.src, _b), _this.machine.options.services);
176
176
  return invokeUtils.toInvokeDefinition(_tslib.__assign(_tslib.__assign({
@@ -351,7 +351,7 @@ function () {
351
351
  }
352
352
 
353
353
  var mutateEntryExit = function (delay, i) {
354
- var delayRef = utils.isFunction(delay) ? _this.id + ":delay[" + i + "]" : delay;
354
+ var delayRef = utils.isFunction(delay) ? "".concat(_this.id, ":delay[").concat(i, "]") : delay;
355
355
  var eventType = actions.after(delayRef, _this.id);
356
356
 
357
357
  _this.onEntry.push(actions.send(eventType, {
@@ -584,7 +584,7 @@ function () {
584
584
  try {
585
585
  guardPassed = !cond || utils.evaluateGuard(this.machine, cond, resolvedContext, _event, state);
586
586
  } catch (err) {
587
- throw new Error("Unable to evaluate guard '" + (cond.name || cond.type) + "' in transition for event '" + eventName + "' in state node '" + this.id + "':\n" + err.message);
587
+ throw new Error("Unable to evaluate guard '".concat(cond.name || cond.type, "' in transition for event '").concat(eventName, "' in state node '").concat(this.id, "':\n").concat(err.message));
588
588
  }
589
589
 
590
590
  if (guardPassed && isInState) {
@@ -592,7 +592,7 @@ function () {
592
592
  nextStateNodes = candidate.target;
593
593
  }
594
594
 
595
- actions.push.apply(actions, _tslib.__spreadArray([], _tslib.__read(candidate.actions)));
595
+ actions.push.apply(actions, _tslib.__spreadArray([], _tslib.__read(candidate.actions), false));
596
596
  selectedTransition = candidate;
597
597
  break;
598
598
  }
@@ -773,11 +773,11 @@ function () {
773
773
  var _c = _tslib.__read([utils.flatten(Array.from(entryStates).map(function (stateNode) {
774
774
  return _tslib.__spreadArray(_tslib.__spreadArray([], _tslib.__read(stateNode.activities.map(function (activity) {
775
775
  return actions.start(activity);
776
- }))), _tslib.__read(stateNode.onEntry));
776
+ })), false), _tslib.__read(stateNode.onEntry), false);
777
777
  })).concat(doneEvents.map(actions.raise)), utils.flatten(Array.from(exitStates).map(function (stateNode) {
778
- return _tslib.__spreadArray(_tslib.__spreadArray([], _tslib.__read(stateNode.onExit)), _tslib.__read(stateNode.activities.map(function (activity) {
778
+ return _tslib.__spreadArray(_tslib.__spreadArray([], _tslib.__read(stateNode.onExit), false), _tslib.__read(stateNode.activities.map(function (activity) {
779
779
  return actions.stop(activity);
780
- })));
780
+ })), false);
781
781
  }))], 2),
782
782
  entryActions = _c[0],
783
783
  exitActions = _c[1];
@@ -812,12 +812,12 @@ function () {
812
812
  }
813
813
 
814
814
  if (!environment.IS_PRODUCTION && _event.name === WILDCARD) {
815
- throw new Error("An event cannot have the wildcard type ('" + WILDCARD + "')");
815
+ throw new Error("An event cannot have the wildcard type ('".concat(WILDCARD, "')"));
816
816
  }
817
817
 
818
818
  if (this.strict) {
819
819
  if (!this.events.includes(_event.name) && !utils.isBuiltInEvent(_event.name)) {
820
- throw new Error("Machine '" + this.id + "' does not accept event '" + _event.name + "'");
820
+ throw new Error("Machine '".concat(this.id, "' does not accept event '").concat(_event.name, "'"));
821
821
  }
822
822
  }
823
823
 
@@ -831,7 +831,7 @@ function () {
831
831
  };
832
832
  var prevConfig = stateUtils.getConfiguration([], this.getStateNodes(currentState.value));
833
833
  var resolvedConfig = stateTransition.configuration.length ? stateUtils.getConfiguration(prevConfig, stateTransition.configuration) : prevConfig;
834
- stateTransition.configuration = _tslib.__spreadArray([], _tslib.__read(resolvedConfig));
834
+ stateTransition.configuration = _tslib.__spreadArray([], _tslib.__read(resolvedConfig), false);
835
835
  return this.resolveTransition(stateTransition, currentState, _event);
836
836
  };
837
837
 
@@ -845,7 +845,7 @@ function () {
845
845
  state._event = originalEvent;
846
846
  state.event = originalEvent.data;
847
847
 
848
- (_a = state.actions).unshift.apply(_a, _tslib.__spreadArray([], _tslib.__read(currentActions)));
848
+ (_a = state.actions).unshift.apply(_a, _tslib.__spreadArray([], _tslib.__read(currentActions), false));
849
849
 
850
850
  return state;
851
851
  };
@@ -996,13 +996,13 @@ function () {
996
996
  }
997
997
 
998
998
  if (!this.states) {
999
- throw new Error("Unable to retrieve child state '" + stateKey + "' from '" + this.id + "'; no child states exist.");
999
+ throw new Error("Unable to retrieve child state '".concat(stateKey, "' from '").concat(this.id, "'; no child states exist."));
1000
1000
  }
1001
1001
 
1002
1002
  var result = this.states[stateKey];
1003
1003
 
1004
1004
  if (!result) {
1005
- throw new Error("Child state '" + stateKey + "' does not exist on '" + this.id + "'");
1005
+ throw new Error("Child state '".concat(stateKey, "' does not exist on '").concat(this.id, "'"));
1006
1006
  }
1007
1007
 
1008
1008
  return result;
@@ -1024,7 +1024,7 @@ function () {
1024
1024
  var stateNode = this.machine.idMap[resolvedStateId];
1025
1025
 
1026
1026
  if (!stateNode) {
1027
- throw new Error("Child state node '#" + resolvedStateId + "' does not exist on machine '" + this.id + "'");
1027
+ throw new Error("Child state node '#".concat(resolvedStateId, "' does not exist on machine '").concat(this.id, "'"));
1028
1028
  }
1029
1029
 
1030
1030
  return stateNode;
@@ -1111,7 +1111,7 @@ function () {
1111
1111
  var stateNode = this.machine.idMap[stateIdentifier.slice(STATE_IDENTIFIER.length)];
1112
1112
 
1113
1113
  if (!stateNode) {
1114
- throw new Error("Unable to find state node '" + stateIdentifier + "'");
1114
+ throw new Error("Unable to find state node '".concat(stateIdentifier, "'"));
1115
1115
  }
1116
1116
 
1117
1117
  return stateNode.path;
@@ -1138,7 +1138,7 @@ function () {
1138
1138
  });
1139
1139
  } else if (this.initial !== undefined) {
1140
1140
  if (!this.states[this.initial]) {
1141
- throw new Error("Initial state '" + this.initial + "' not found on '" + this.key + "'");
1141
+ throw new Error("Initial state '".concat(this.initial, "' not found on '").concat(this.key, "'"));
1142
1142
  }
1143
1143
 
1144
1144
  initialStateValue = stateUtils.isLeafNode(this.states[this.initial]) ? this.initial : (_a = {}, _a[this.initial] = this.states[this.initial].initialStateValue, _a);
@@ -1178,7 +1178,7 @@ function () {
1178
1178
  var initialStateValue = this.initialStateValue;
1179
1179
 
1180
1180
  if (!initialStateValue) {
1181
- throw new Error("Cannot retrieve initial state from simple state '" + this.id + "'.");
1181
+ throw new Error("Cannot retrieve initial state from simple state '".concat(this.id, "'."));
1182
1182
  }
1183
1183
 
1184
1184
  return this.getInitialState(initialStateValue);
@@ -1236,7 +1236,7 @@ function () {
1236
1236
 
1237
1237
  if (this.type === 'compound' && !this.initial) {
1238
1238
  if (!environment.IS_PRODUCTION) {
1239
- utils.warn(false, "Compound state node '" + this.id + "' has no initial state.");
1239
+ utils.warn(false, "Compound state node '".concat(this.id, "' has no initial state."));
1240
1240
  }
1241
1241
 
1242
1242
  return [this];
@@ -1267,7 +1267,7 @@ function () {
1267
1267
  childStatePath = _a.slice(1);
1268
1268
 
1269
1269
  if (!this.states) {
1270
- throw new Error("Cannot retrieve subPath '" + stateKey + "' from node with no states");
1270
+ throw new Error("Cannot retrieve subPath '".concat(stateKey, "' from node with no states"));
1271
1271
  }
1272
1272
 
1273
1273
  var childStateNode = this.getStateNode(stateKey);
@@ -1277,7 +1277,7 @@ function () {
1277
1277
  }
1278
1278
 
1279
1279
  if (!this.states[stateKey]) {
1280
- throw new Error("Child state '" + stateKey + "' does not exist on '" + this.id + "'");
1280
+ throw new Error("Child state '".concat(stateKey, "' does not exist on '").concat(this.id, "'"));
1281
1281
  }
1282
1282
 
1283
1283
  return this.states[stateKey].getFromRelativePath(childStatePath);
@@ -1376,7 +1376,7 @@ function () {
1376
1376
  try {
1377
1377
  for (var _e = (e_8 = void 0, _tslib.__values(state.events)), _f = _e.next(); !_f.done; _f = _e.next()) {
1378
1378
  var event_1 = _f.value;
1379
- events.add("" + event_1);
1379
+ events.add("".concat(event_1));
1380
1380
  }
1381
1381
  } catch (e_8_1) {
1382
1382
  e_8 = {
@@ -1455,7 +1455,7 @@ function () {
1455
1455
 
1456
1456
  return targetStateNode;
1457
1457
  } catch (err) {
1458
- throw new Error("Invalid transition definition for state node '" + _this.id + "':\n" + err.message);
1458
+ throw new Error("Invalid transition definition for state node '".concat(_this.id, "':\n").concat(err.message));
1459
1459
  }
1460
1460
  } else {
1461
1461
  return _this.getStateNodeByPath(resolvedTarget);
@@ -1483,9 +1483,9 @@ function () {
1483
1483
  toJSON: function () {
1484
1484
  return _tslib.__assign(_tslib.__assign({}, transition), {
1485
1485
  target: transition.target ? transition.target.map(function (t) {
1486
- return "#" + t.id;
1486
+ return "#".concat(t.id);
1487
1487
  }) : undefined,
1488
- source: "#" + _this.id
1488
+ source: "#".concat(_this.id)
1489
1489
  });
1490
1490
  }
1491
1491
  });
@@ -1513,7 +1513,7 @@ function () {
1513
1513
 
1514
1514
  onConfig = utils.flatten(utils.keys(strictTransitionConfigs_1).map(function (key) {
1515
1515
  if (!environment.IS_PRODUCTION && key === NULL_EVENT) {
1516
- utils.warn(false, "Empty string transition configs (e.g., `{ on: { '': ... }}`) for transient transitions are deprecated. Specify the transition in the `{ always: ... }` property instead. " + ("Please check the `on` configuration for \"#" + _this.id + "\"."));
1516
+ utils.warn(false, "Empty string transition configs (e.g., `{ on: { '': ... }}`) for transient transitions are deprecated. Specify the transition in the `{ always: ... }` property instead. " + "Please check the `on` configuration for \"#".concat(_this.id, "\"."));
1517
1517
  }
1518
1518
 
1519
1519
  var transitionConfigArray = utils.toTransitionConfigArray(key, strictTransitionConfigs_1[key]);
@@ -1530,24 +1530,24 @@ function () {
1530
1530
  var doneConfig = this.config.onDone ? utils.toTransitionConfigArray(String(actions.done(this.id)), this.config.onDone) : [];
1531
1531
 
1532
1532
  if (!environment.IS_PRODUCTION) {
1533
- utils.warn(!(this.config.onDone && !this.parent), "Root nodes cannot have an \".onDone\" transition. Please check the config of \"" + this.id + "\".");
1533
+ utils.warn(!(this.config.onDone && !this.parent), "Root nodes cannot have an \".onDone\" transition. Please check the config of \"".concat(this.id, "\"."));
1534
1534
  }
1535
1535
 
1536
1536
  var invokeConfig = utils.flatten(this.invoke.map(function (invokeDef) {
1537
1537
  var settleTransitions = [];
1538
1538
 
1539
1539
  if (invokeDef.onDone) {
1540
- settleTransitions.push.apply(settleTransitions, _tslib.__spreadArray([], _tslib.__read(utils.toTransitionConfigArray(String(actions.doneInvoke(invokeDef.id)), invokeDef.onDone))));
1540
+ settleTransitions.push.apply(settleTransitions, _tslib.__spreadArray([], _tslib.__read(utils.toTransitionConfigArray(String(actions.doneInvoke(invokeDef.id)), invokeDef.onDone)), false));
1541
1541
  }
1542
1542
 
1543
1543
  if (invokeDef.onError) {
1544
- settleTransitions.push.apply(settleTransitions, _tslib.__spreadArray([], _tslib.__read(utils.toTransitionConfigArray(String(actions.error(invokeDef.id)), invokeDef.onError))));
1544
+ settleTransitions.push.apply(settleTransitions, _tslib.__spreadArray([], _tslib.__read(utils.toTransitionConfigArray(String(actions.error(invokeDef.id)), invokeDef.onError)), false));
1545
1545
  }
1546
1546
 
1547
1547
  return settleTransitions;
1548
1548
  }));
1549
1549
  var delayedTransitions = this.after;
1550
- var formattedTransitions = utils.flatten(_tslib.__spreadArray(_tslib.__spreadArray(_tslib.__spreadArray(_tslib.__spreadArray([], _tslib.__read(doneConfig)), _tslib.__read(invokeConfig)), _tslib.__read(onConfig)), _tslib.__read(eventlessConfig)).map(function (transitionConfig) {
1550
+ var formattedTransitions = utils.flatten(_tslib.__spreadArray(_tslib.__spreadArray(_tslib.__spreadArray(_tslib.__spreadArray([], _tslib.__read(doneConfig), false), _tslib.__read(invokeConfig), false), _tslib.__read(onConfig), false), _tslib.__read(eventlessConfig), false).map(function (transitionConfig) {
1551
1551
  return utils.toArray(transitionConfig).map(function (transition) {
1552
1552
  return _this.formatTransition(transition);
1553
1553
  });
@@ -69,10 +69,14 @@ function __read(o, n) {
69
69
  return ar;
70
70
  }
71
71
 
72
- function __spreadArray(to, from) {
73
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
74
- to[j] = from[i];
75
- return to;
72
+ function __spreadArray(to, from, pack) {
73
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
74
+ if (ar || !(i in from)) {
75
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
76
+ ar[i] = from[i];
77
+ }
78
+ }
79
+ return to.concat(ar || Array.prototype.slice.call(from));
76
80
  }
77
81
 
78
82
  exports.__read = __read;
package/lib/actions.js CHANGED
@@ -287,8 +287,8 @@ var assign = function (assignment) {
287
287
  */
288
288
 
289
289
  function after(delayRef, id) {
290
- var idSuffix = id ? "#" + id : '';
291
- return types.ActionTypes.After + "(" + delayRef + ")" + idSuffix;
290
+ var idSuffix = id ? "#".concat(id) : '';
291
+ return "".concat(types.ActionTypes.After, "(").concat(delayRef, ")").concat(idSuffix);
292
292
  }
293
293
  /**
294
294
  * Returns an event that represents that a final state node
@@ -299,7 +299,7 @@ function after(delayRef, id) {
299
299
  */
300
300
 
301
301
  function done(id, data) {
302
- var type = types.ActionTypes.DoneState + "." + id;
302
+ var type = "".concat(types.ActionTypes.DoneState, ".").concat(id);
303
303
  var eventObject = {
304
304
  type: type,
305
305
  data: data
@@ -322,7 +322,7 @@ function done(id, data) {
322
322
  */
323
323
 
324
324
  function doneInvoke(id, data) {
325
- var type = types.ActionTypes.DoneInvoke + "." + id;
325
+ var type = "".concat(types.ActionTypes.DoneInvoke, ".").concat(id);
326
326
  var eventObject = {
327
327
  type: type,
328
328
  data: data
@@ -335,7 +335,7 @@ function doneInvoke(id, data) {
335
335
  return eventObject;
336
336
  }
337
337
  function error(id, data) {
338
- var type = types.ActionTypes.ErrorPlatform + "." + id;
338
+ var type = "".concat(types.ActionTypes.ErrorPlatform, ".").concat(id);
339
339
  var eventObject = {
340
340
  type: type,
341
341
  data: data
@@ -417,7 +417,7 @@ function resolveActions(machine, currentState, currentContext, _event, actions,
417
417
  if (!environment.IS_PRODUCTION) {
418
418
  // warn after resolving as we can create better contextual message here
419
419
  utils.warn(!utils.isString(actionObject.delay) || typeof sendAction.delay === 'number', // tslint:disable-next-line:max-line-length
420
- "No delay reference for delay expression '" + actionObject.delay + "' was found on machine '" + machine.id + "'");
420
+ "No delay reference for delay expression '".concat(actionObject.delay, "' was found on machine '").concat(machine.id, "'"));
421
421
  }
422
422
 
423
423
  return sendAction;
@@ -489,7 +489,7 @@ function resolveActions(machine, currentState, currentContext, _event, actions,
489
489
  args[_i - 1] = arguments[_i];
490
490
  }
491
491
 
492
- exec_1.apply(void 0, _tslib.__spreadArray([preservedContexts[contextIndex_1]], _tslib.__read(args)));
492
+ exec_1.apply(void 0, _tslib.__spreadArray([preservedContexts[contextIndex_1]], _tslib.__read(args), false));
493
493
  }
494
494
  });
495
495
  }
package/lib/devTools.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { Interpreter } from '.';
3
2
  import { AnyInterpreter } from './types';
4
3
  declare type ServiceListener = (service: AnyInterpreter) => void;
@@ -10,7 +9,7 @@ export interface XStateDevInterface {
10
9
  };
11
10
  services: Set<Interpreter<any>>;
12
11
  }
13
- export declare function getGlobal(): (Window & typeof globalThis) | (NodeJS.Global & typeof globalThis) | undefined;
12
+ export declare function getGlobal(): typeof globalThis | undefined;
14
13
  export declare function registerService(service: AnyInterpreter): void;
15
14
  export {};
16
15
  //# sourceMappingURL=devTools.d.ts.map
package/lib/devTools.js CHANGED
@@ -4,6 +4,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  // From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis
6
6
  function getGlobal() {
7
+ if (typeof globalThis !== 'undefined') {
8
+ return globalThis;
9
+ }
10
+
7
11
  if (typeof self !== 'undefined') {
8
12
  return self;
9
13
  }