xstate 5.0.0-beta.20 → 5.0.0-beta.22

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 (46) hide show
  1. package/actions/dist/xstate-actions.cjs.js +1 -1
  2. package/actions/dist/xstate-actions.development.cjs.js +1 -1
  3. package/actions/dist/xstate-actions.development.esm.js +1 -1
  4. package/actions/dist/xstate-actions.esm.js +1 -1
  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 +1 -1
  8. package/actors/dist/xstate-actors.development.cjs.js +1 -1
  9. package/actors/dist/xstate-actors.development.esm.js +1 -1
  10. package/actors/dist/xstate-actors.esm.js +1 -1
  11. package/actors/dist/xstate-actors.umd.min.js +1 -1
  12. package/actors/dist/xstate-actors.umd.min.js.map +1 -1
  13. package/dev/dist/xstate-dev.umd.min.js.map +1 -1
  14. package/dist/{actions-d1c41ed3.development.cjs.js → actions-4b70fc8d.development.cjs.js} +174 -82
  15. package/dist/{actions-069d9805.cjs.js → actions-8f2e997e.cjs.js} +172 -83
  16. package/dist/{actions-b299d008.development.esm.js → actions-d4305983.development.esm.js} +171 -82
  17. package/dist/{actions-a8a9433c.esm.js → actions-fb7384f8.esm.js} +169 -83
  18. package/dist/declarations/src/Machine.d.ts +2 -2
  19. package/dist/declarations/src/State.d.ts +4 -7
  20. package/dist/declarations/src/StateMachine.d.ts +7 -6
  21. package/dist/declarations/src/StateNode.d.ts +3 -3
  22. package/dist/declarations/src/actions/send.d.ts +1 -1
  23. package/dist/declarations/src/actions/stop.d.ts +1 -1
  24. package/dist/declarations/src/actions.d.ts +2 -2
  25. package/dist/declarations/src/actors/callback.d.ts +4 -4
  26. package/dist/declarations/src/actors/observable.d.ts +7 -4
  27. package/dist/declarations/src/actors/promise.d.ts +4 -4
  28. package/dist/declarations/src/dev/index.d.ts +6 -6
  29. package/dist/declarations/src/index.d.ts +3 -2
  30. package/dist/declarations/src/interpreter.d.ts +30 -16
  31. package/dist/declarations/src/types.d.ts +52 -33
  32. package/dist/declarations/src/utils.d.ts +2 -2
  33. package/dist/xstate.cjs.js +17 -14
  34. package/dist/xstate.cjs.mjs +3 -1
  35. package/dist/xstate.development.cjs.js +17 -14
  36. package/dist/xstate.development.cjs.mjs +3 -1
  37. package/dist/xstate.development.esm.js +14 -13
  38. package/dist/xstate.esm.js +14 -13
  39. package/dist/xstate.umd.min.js +1 -1
  40. package/dist/xstate.umd.min.js.map +1 -1
  41. package/guards/dist/xstate-guards.cjs.js +1 -1
  42. package/guards/dist/xstate-guards.development.cjs.js +1 -1
  43. package/guards/dist/xstate-guards.development.esm.js +1 -1
  44. package/guards/dist/xstate-guards.esm.js +1 -1
  45. package/guards/dist/xstate-guards.umd.min.js.map +1 -1
  46. package/package.json +1 -1
@@ -1,5 +1,17 @@
1
1
  import { devToolsAdapter } from '../dev/dist/xstate-dev.development.esm.js';
2
2
 
3
+ /**
4
+ * `T | unknown` reduces to `unknown` and that can be problematic when it comes to contextual typing.
5
+ * It especially is a problem when the union has a function member, like here:
6
+ *
7
+ * ```ts
8
+ * declare function test(cbOrVal: ((arg: number) => unknown) | unknown): void;
9
+ * test((arg) => {}) // oops, implicit any
10
+ * ```
11
+ *
12
+ * This type can be used to avoid this problem. This union represents the same value space as `unknown`.
13
+ */
14
+
3
15
  // https://github.com/microsoft/TypeScript/issues/23182#issuecomment-379091887
4
16
 
5
17
  /**
@@ -420,27 +432,18 @@ function toArray(value) {
420
432
  }
421
433
  return toArrayStrict(value);
422
434
  }
423
- function mapContext(mapper, context, event) {
435
+ function mapContext(mapper, context, event, self) {
424
436
  if (typeof mapper === 'function') {
425
437
  return mapper({
426
438
  context,
427
- event
439
+ event,
440
+ self
428
441
  });
429
442
  }
430
- const result = {};
431
- const args = {
432
- context,
433
- event
434
- };
435
- for (const key of Object.keys(mapper)) {
436
- const subMapper = mapper[key];
437
- if (typeof subMapper === 'function') {
438
- result[key] = subMapper(args);
439
- } else {
440
- result[key] = subMapper;
441
- }
443
+ if (typeof mapper === 'object' && Object.values(mapper).some(val => typeof val === 'function')) {
444
+ console.warn(`Dynamically mapping values to individual properties is deprecated. Use a single function that returns the mapped object instead.\nFound object containing properties whose values are possibly mapping functions: ${Object.entries(mapper).filter(([key, value]) => typeof value === 'function').map(([key, value]) => `\n - ${key}: ${value.toString().replace(/\n\s*/g, '')}`).join('')}`);
442
445
  }
443
- return result;
446
+ return mapper;
444
447
  }
445
448
  function isPromiseLike(value) {
446
449
  if (value instanceof Promise) {
@@ -492,13 +495,12 @@ function toInvokeConfig(invocable, id) {
492
495
  };
493
496
  }
494
497
  function toObserver(nextHandler, errorHandler, completionHandler) {
495
- const noop = () => {};
496
498
  const isObserver = typeof nextHandler === 'object';
497
- const self = isObserver ? nextHandler : null;
499
+ const self = isObserver ? nextHandler : undefined;
498
500
  return {
499
- next: ((isObserver ? nextHandler.next : nextHandler) || noop).bind(self),
500
- error: ((isObserver ? nextHandler.error : errorHandler) || noop).bind(self),
501
- complete: ((isObserver ? nextHandler.complete : completionHandler) || noop).bind(self)
501
+ next: (isObserver ? nextHandler.next : nextHandler)?.bind(self),
502
+ error: (isObserver ? nextHandler.error : errorHandler)?.bind(self),
503
+ complete: (isObserver ? nextHandler.complete : completionHandler)?.bind(self)
502
504
  };
503
505
  }
504
506
  function createInvokeId(stateNodeId, index) {
@@ -512,7 +514,7 @@ function resolveReferencedActor(referenced) {
512
514
  }
513
515
 
514
516
  function fromCallback(invokeCallback) {
515
- const logic = {
517
+ return {
516
518
  config: invokeCallback,
517
519
  start: (_state, {
518
520
  self
@@ -578,19 +580,20 @@ function fromCallback(invokeCallback) {
578
580
  },
579
581
  getSnapshot: () => undefined,
580
582
  getPersistedState: ({
581
- input
582
- }) => input
583
+ input,
584
+ canceled
585
+ }) => ({
586
+ input,
587
+ canceled
588
+ })
583
589
  };
584
- return logic;
585
590
  }
586
591
 
587
592
  function fromObservable(observableCreator) {
588
593
  const nextEventType = '$$xstate.next';
589
594
  const errorEventType = '$$xstate.error';
590
595
  const completeEventType = '$$xstate.complete';
591
-
592
- // TODO: add event types
593
- const logic = {
596
+ return {
594
597
  config: observableCreator,
595
598
  transition: (state, event, {
596
599
  self,
@@ -620,6 +623,7 @@ function fromObservable(observableCreator) {
620
623
  status: 'error',
621
624
  input: undefined,
622
625
  data: event.data,
626
+ // TODO: if we keep this as `data` we should reflect this in the type
623
627
  subscription: undefined
624
628
  };
625
629
  case completeEventType:
@@ -697,7 +701,6 @@ function fromObservable(observableCreator) {
697
701
  subscription: undefined
698
702
  })
699
703
  };
700
- return logic;
701
704
  }
702
705
 
703
706
  /**
@@ -714,7 +717,7 @@ function fromEventObservable(lazyObservable) {
714
717
  const completeEventType = '$$xstate.complete';
715
718
 
716
719
  // TODO: event types
717
- const logic = {
720
+ return {
718
721
  config: lazyObservable,
719
722
  transition: (state, event) => {
720
723
  if (state.status !== 'active') {
@@ -727,6 +730,7 @@ function fromEventObservable(lazyObservable) {
727
730
  status: 'error',
728
731
  input: undefined,
729
732
  data: event.data,
733
+ // TODO: if we keep this as `data` we should reflect this in the type
730
734
  subscription: undefined
731
735
  };
732
736
  case completeEventType:
@@ -801,7 +805,6 @@ function fromEventObservable(lazyObservable) {
801
805
  subscription: undefined
802
806
  })
803
807
  };
804
- return logic;
805
808
  }
806
809
 
807
810
  const resolveEventType = '$$xstate.resolve';
@@ -829,6 +832,7 @@ promiseCreator) {
829
832
  ...state,
830
833
  status: 'error',
831
834
  data: event.data,
835
+ // TODO: if we keep this as `data` we should reflect this in the type
832
836
  input: undefined
833
837
  };
834
838
  case stopSignalType:
@@ -935,7 +939,20 @@ function toActorRef(actorRefLike) {
935
939
  }
936
940
  const emptyLogic = fromTransition(_ => undefined, undefined);
937
941
  function createEmptyActor() {
938
- return interpret(emptyLogic);
942
+ return createActor(emptyLogic);
943
+ }
944
+
945
+ /**
946
+ * This function makes sure that unhandled errors are thrown in a separate macrotask.
947
+ * It allows those errors to be detected by global error handlers and reported to bug tracking services
948
+ * without interrupting our own stack of execution.
949
+ *
950
+ * @param err error to be thrown
951
+ */
952
+ function reportUnhandledError(err) {
953
+ setTimeout(() => {
954
+ throw err;
955
+ });
939
956
  }
940
957
 
941
958
  function createSystem() {
@@ -978,6 +995,11 @@ let ActorStatus = /*#__PURE__*/function (ActorStatus) {
978
995
  ActorStatus[ActorStatus["Stopped"] = 2] = "Stopped";
979
996
  return ActorStatus;
980
997
  }({});
998
+
999
+ /**
1000
+ * @deprecated Use `ActorStatus` instead.
1001
+ */
1002
+ const InterpreterStatus = ActorStatus;
981
1003
  const defaultOptions = {
982
1004
  deferEvents: true,
983
1005
  clock: {
@@ -991,9 +1013,9 @@ const defaultOptions = {
991
1013
  logger: console.log.bind(console),
992
1014
  devTools: false
993
1015
  };
994
- class Interpreter {
1016
+ class Actor {
995
1017
  /**
996
- * The current state of the interpreted logic.
1018
+ * The current internal state of the actor.
997
1019
  */
998
1020
 
999
1021
  /**
@@ -1017,10 +1039,10 @@ class Interpreter {
1017
1039
  */
1018
1040
 
1019
1041
  /**
1020
- * Creates a new Interpreter instance (i.e., service) for the given logic with the provided options, if any.
1042
+ * Creates a new actor instance for the given logic with the provided options, if any.
1021
1043
  *
1022
- * @param logic The logic to be interpreted
1023
- * @param options Interpreter options
1044
+ * @param logic The logic to create an actor from
1045
+ * @param options Actor options
1024
1046
  */
1025
1047
  constructor(logic, options) {
1026
1048
  this.logic = logic;
@@ -1084,7 +1106,7 @@ class Interpreter {
1084
1106
  }
1085
1107
  };
1086
1108
 
1087
- // Ensure that the send method is bound to this interpreter instance
1109
+ // Ensure that the send method is bound to this Actor instance
1088
1110
  // if destructured
1089
1111
  this.send = this.send.bind(this);
1090
1112
  this._initState();
@@ -1106,29 +1128,38 @@ class Interpreter {
1106
1128
  deferredFn();
1107
1129
  }
1108
1130
  for (const observer of this.observers) {
1109
- observer.next?.(snapshot);
1131
+ // TODO: should observers be notified in case of the error?
1132
+ try {
1133
+ observer.next?.(snapshot);
1134
+ } catch (err) {
1135
+ reportUnhandledError(err);
1136
+ }
1110
1137
  }
1111
1138
  const status = this.logic.getStatus?.(state);
1112
1139
  switch (status?.status) {
1113
1140
  case 'done':
1114
1141
  this._stopProcedure();
1142
+ this._complete();
1115
1143
  this._doneEvent = doneInvoke(this.id, status.data);
1116
1144
  this._parent?.send(this._doneEvent);
1117
- this._complete();
1118
1145
  break;
1119
1146
  case 'error':
1120
1147
  this._stopProcedure();
1121
- this._parent?.send(error(this.id, status.data));
1122
1148
  this._error(status.data);
1149
+ this._parent?.send(error(this.id, status.data));
1123
1150
  break;
1124
1151
  }
1125
1152
  }
1126
1153
  subscribe(nextListenerOrObserver, errorListener, completeListener) {
1127
1154
  const observer = toObserver(nextListenerOrObserver, errorListener, completeListener);
1128
- this.observers.add(observer);
1129
- if (this.status === ActorStatus.Stopped) {
1130
- observer.complete?.();
1131
- this.observers.delete(observer);
1155
+ if (this.status !== ActorStatus.Stopped) {
1156
+ this.observers.add(observer);
1157
+ } else {
1158
+ try {
1159
+ observer.complete?.();
1160
+ } catch (err) {
1161
+ reportUnhandledError(err);
1162
+ }
1132
1163
  }
1133
1164
  return {
1134
1165
  unsubscribe: () => {
@@ -1138,7 +1169,7 @@ class Interpreter {
1138
1169
  }
1139
1170
 
1140
1171
  /**
1141
- * Starts the interpreter from the initial state
1172
+ * Starts the Actor from the initial state
1142
1173
  */
1143
1174
  start() {
1144
1175
  if (this.status === ActorStatus.Running) {
@@ -1150,8 +1181,26 @@ class Interpreter {
1150
1181
  this.system._set(this._systemId, this);
1151
1182
  }
1152
1183
  this.status = ActorStatus.Running;
1184
+ const status = this.logic.getStatus?.(this._state);
1185
+ switch (status?.status) {
1186
+ case 'done':
1187
+ // a state machine can be "done" upon intialization (it could reach a final state using initial microsteps)
1188
+ // we still need to complete observers, flush deferreds etc
1189
+ this.update(this._state);
1190
+ // fallthrough
1191
+ case 'error':
1192
+ // TODO: rethink cleanup of observers, mailbox, etc
1193
+ return this;
1194
+ }
1153
1195
  if (this.logic.start) {
1154
- this.logic.start(this._state, this._actorContext);
1196
+ try {
1197
+ this.logic.start(this._state, this._actorContext);
1198
+ } catch (err) {
1199
+ this._stopProcedure();
1200
+ this._error(err);
1201
+ this._parent?.send(error(this.id, err));
1202
+ return this;
1203
+ }
1155
1204
  }
1156
1205
 
1157
1206
  // TODO: this notifies all subscribers but usually this is redundant
@@ -1165,23 +1214,30 @@ class Interpreter {
1165
1214
  return this;
1166
1215
  }
1167
1216
  _process(event) {
1217
+ // TODO: reexamine what happens when an action (or a guard or smth) throws
1218
+ let nextState;
1219
+ let caughtError;
1168
1220
  try {
1169
- const nextState = this.logic.transition(this._state, event, this._actorContext);
1170
- this.update(nextState);
1171
- if (event.type === stopSignalType) {
1172
- this._stopProcedure();
1173
- this._complete();
1174
- }
1221
+ nextState = this.logic.transition(this._state, event, this._actorContext);
1175
1222
  } catch (err) {
1176
- // TODO: properly handle errors
1177
- if (this.observers.size > 0) {
1178
- this.observers.forEach(observer => {
1179
- observer.error?.(err);
1180
- });
1181
- this.stop();
1182
- } else {
1183
- throw err;
1184
- }
1223
+ // we wrap it in a box so we can rethrow it later even if falsy value gets caught here
1224
+ caughtError = {
1225
+ err
1226
+ };
1227
+ }
1228
+ if (caughtError) {
1229
+ const {
1230
+ err
1231
+ } = caughtError;
1232
+ this._stopProcedure();
1233
+ this._error(err);
1234
+ this._parent?.send(error(this.id, err));
1235
+ return;
1236
+ }
1237
+ this.update(nextState);
1238
+ if (event.type === stopSignalType) {
1239
+ this._stopProcedure();
1240
+ this._complete();
1185
1241
  }
1186
1242
  }
1187
1243
  _stop() {
@@ -1200,7 +1256,7 @@ class Interpreter {
1200
1256
  }
1201
1257
 
1202
1258
  /**
1203
- * Stops the interpreter and unsubscribe all listeners.
1259
+ * Stops the Actor and unsubscribe all listeners.
1204
1260
  */
1205
1261
  stop() {
1206
1262
  if (this._parent) {
@@ -1210,19 +1266,39 @@ class Interpreter {
1210
1266
  }
1211
1267
  _complete() {
1212
1268
  for (const observer of this.observers) {
1213
- observer.complete?.();
1269
+ try {
1270
+ observer.complete?.();
1271
+ } catch (err) {
1272
+ reportUnhandledError(err);
1273
+ }
1214
1274
  }
1215
1275
  this.observers.clear();
1216
1276
  }
1217
- _error(data) {
1277
+ _error(err) {
1278
+ if (!this.observers.size) {
1279
+ if (!this._parent) {
1280
+ reportUnhandledError(err);
1281
+ }
1282
+ return;
1283
+ }
1284
+ let reportError = false;
1218
1285
  for (const observer of this.observers) {
1219
- observer.error?.(data);
1286
+ const errorListener = observer.error;
1287
+ reportError ||= !errorListener;
1288
+ try {
1289
+ errorListener?.(err);
1290
+ } catch (err2) {
1291
+ reportUnhandledError(err2);
1292
+ }
1220
1293
  }
1221
1294
  this.observers.clear();
1295
+ if (reportError) {
1296
+ reportUnhandledError(err);
1297
+ }
1222
1298
  }
1223
1299
  _stopProcedure() {
1224
1300
  if (this.status !== ActorStatus.Running) {
1225
- // Interpreter already stopped; do nothing
1301
+ // Actor already stopped; do nothing
1226
1302
  return this;
1227
1303
  }
1228
1304
 
@@ -1244,7 +1320,7 @@ class Interpreter {
1244
1320
  }
1245
1321
 
1246
1322
  /**
1247
- * Sends an event to the running interpreter to trigger a transition.
1323
+ * Sends an event to the running Actor to trigger a transition.
1248
1324
  *
1249
1325
  * @param event The event to send
1250
1326
  */
@@ -1320,17 +1396,28 @@ class Interpreter {
1320
1396
  }
1321
1397
 
1322
1398
  /**
1323
- * Creates a new Interpreter instance for the given machine with the provided options, if any.
1399
+ * Creates a new `ActorRef` instance for the given machine with the provided options, if any.
1324
1400
  *
1325
- * @param machine The machine to interpret
1326
- * @param options Interpreter options
1401
+ * @param machine The machine to create an actor from
1402
+ * @param options `ActorRef` options
1327
1403
  */
1328
1404
 
1329
- function interpret(logic, options) {
1330
- const interpreter = new Interpreter(logic, options);
1405
+ function createActor(logic, options) {
1406
+ const interpreter = new Actor(logic, options);
1331
1407
  return interpreter;
1332
1408
  }
1333
1409
 
1410
+ /**
1411
+ * Creates a new Interpreter instance for the given machine with the provided options, if any.
1412
+ *
1413
+ * @deprecated Use `createActor` instead
1414
+ */
1415
+ const interpret = createActor;
1416
+
1417
+ /**
1418
+ * @deprecated Use `Actor` instead.
1419
+ */
1420
+
1334
1421
  function resolve$6(actorContext, state, actionArgs, {
1335
1422
  id,
1336
1423
  systemId,
@@ -1342,7 +1429,7 @@ function resolve$6(actorContext, state, actionArgs, {
1342
1429
  if (referenced) {
1343
1430
  // TODO: inline `input: undefined` should win over the referenced one
1344
1431
  const configuredInput = input || referenced.input;
1345
- actorRef = interpret(referenced.src, {
1432
+ actorRef = createActor(referenced.src, {
1346
1433
  id,
1347
1434
  src,
1348
1435
  parent: actorContext?.self,
@@ -1551,10 +1638,10 @@ function toGuardDefinition(guardConfig, getPredicate) {
1551
1638
  }
1552
1639
  }
1553
1640
 
1554
- function getOutput(configuration, context, event) {
1641
+ function getOutput(configuration, context, event, self) {
1555
1642
  const machine = configuration[0].machine;
1556
1643
  const finalChildStateNode = configuration.find(stateNode => stateNode.type === 'final' && stateNode.parent === machine.root);
1557
- return finalChildStateNode && finalChildStateNode.output ? mapContext(finalChildStateNode.output, context, event) : undefined;
1644
+ return finalChildStateNode && finalChildStateNode.output ? mapContext(finalChildStateNode.output, context, event, self) : undefined;
1558
1645
  }
1559
1646
  const isAtomicStateNode = stateNode => stateNode.type === 'atomic' || stateNode.type === 'final';
1560
1647
  function getChildren(stateNode) {
@@ -2181,7 +2268,7 @@ function microstepProcedure(transitions, currentState, mutConfiguration, event,
2181
2268
  actions.push(...filteredTransitions.flatMap(t => t.actions));
2182
2269
 
2183
2270
  // Enter states
2184
- enterStates(event, filteredTransitions, mutConfiguration, actions, internalQueue, currentState, historyValue, isInitial);
2271
+ enterStates(event, filteredTransitions, mutConfiguration, actions, internalQueue, currentState, historyValue, isInitial, actorCtx);
2185
2272
  const nextConfiguration = [...mutConfiguration];
2186
2273
  const done = isInFinalState(nextConfiguration);
2187
2274
  if (done) {
@@ -2190,7 +2277,7 @@ function microstepProcedure(transitions, currentState, mutConfiguration, event,
2190
2277
  }
2191
2278
  try {
2192
2279
  const nextState = resolveActionsAndContext(actions, event, currentState, actorCtx);
2193
- const output = done ? getOutput(nextConfiguration, nextState.context, event) : undefined;
2280
+ const output = done ? getOutput(nextConfiguration, nextState.context, event, actorCtx.self) : undefined;
2194
2281
  internalQueue.push(...nextState._internalQueue);
2195
2282
  return cloneState(currentState, {
2196
2283
  configuration: nextConfiguration,
@@ -2207,7 +2294,7 @@ function microstepProcedure(transitions, currentState, mutConfiguration, event,
2207
2294
  throw e;
2208
2295
  }
2209
2296
  }
2210
- function enterStates(event, filteredTransitions, mutConfiguration, actions, internalQueue, currentState, historyValue, isInitial) {
2297
+ function enterStates(event, filteredTransitions, mutConfiguration, actions, internalQueue, currentState, historyValue, isInitial, actorContext) {
2211
2298
  const statesToEnter = new Set();
2212
2299
  const statesForDefaultEntry = new Set();
2213
2300
  computeEntrySet(filteredTransitions, historyValue, statesForDefaultEntry, statesToEnter);
@@ -2235,7 +2322,7 @@ function enterStates(event, filteredTransitions, mutConfiguration, actions, inte
2235
2322
  if (!parent.parent) {
2236
2323
  continue;
2237
2324
  }
2238
- internalQueue.push(done(parent.id, stateNodeToEnter.output ? mapContext(stateNodeToEnter.output, currentState.context, event) : undefined));
2325
+ internalQueue.push(done(parent.id, stateNodeToEnter.output ? mapContext(stateNodeToEnter.output, currentState.context, event, actorContext.self) : undefined));
2239
2326
  if (parent.parent) {
2240
2327
  const grandparent = parent.parent;
2241
2328
  if (grandparent.type === 'parallel') {
@@ -2558,6 +2645,7 @@ class State {
2558
2645
  this.value = void 0;
2559
2646
  this.done = void 0;
2560
2647
  this.output = void 0;
2648
+ this.error = void 0;
2561
2649
  this.context = void 0;
2562
2650
  this.historyValue = {};
2563
2651
  this._internalQueue = void 0;
@@ -2574,6 +2662,7 @@ class State {
2574
2662
  this.tags = new Set(flatten(this.configuration.map(sn => sn.tags)));
2575
2663
  this.done = config.done ?? false;
2576
2664
  this.output = config.output;
2665
+ this.error = config.error;
2577
2666
  }
2578
2667
 
2579
2668
  /**
@@ -2795,7 +2884,7 @@ function createSpawner(actorContext, {
2795
2884
  const input = 'input' in options ? options.input : referenced.input;
2796
2885
 
2797
2886
  // TODO: this should also receive `src`
2798
- const actor = interpret(referenced.src, {
2887
+ const actor = createActor(referenced.src, {
2799
2888
  id: options.id,
2800
2889
  parent: actorContext.self,
2801
2890
  input: typeof input === 'function' ? input({
@@ -2809,7 +2898,7 @@ function createSpawner(actorContext, {
2809
2898
  return actor;
2810
2899
  } else {
2811
2900
  // TODO: this should also receive `src`
2812
- return interpret(src, {
2901
+ return createActor(src, {
2813
2902
  id: options.id,
2814
2903
  parent: actorContext.self,
2815
2904
  input: options.input,
@@ -3044,4 +3133,4 @@ function createInitEvent(input) {
3044
3133
  };
3045
3134
  }
3046
3135
 
3047
- export { fromEventObservable as $, isAtomicStateNode as A, error as B, isStateId as C, getStateNodeByPath as D, getPersistedState as E, resolveReferencedActor as F, interpret as G, matchesState as H, sendTo as I, sendParent as J, forwardTo as K, Interpreter as L, ActorStatus as M, NULL_EVENT as N, doneInvoke as O, cancel as P, choose as Q, log as R, STATE_DELIMITER as S, pure as T, raise as U, stop as V, pathToStateValue as W, toObserver as X, fromPromise as Y, fromObservable as Z, fromCallback as _, toTransitionConfigArray as a, fromTransition as a0, stateIn as a1, not as a2, and as a3, or as a4, ConstantPrefix as a5, SpecialTargets as a6, startSignalType as a7, stopSignalType as a8, startSignal as a9, stopSignal as aa, isSignal as ab, isActorRef as ac, toActorRef as ad, createEmptyActor as ae, toGuardDefinition as af, constantPrefixes as ag, after as ah, done as ai, escalate as aj, formatTransition as b, memo as c, flatten as d, evaluateGuard as e, formatTransitions as f, createInvokeId as g, getDelayedTransitions as h, formatInitialTransition as i, getCandidates as j, toInvokeConfig as k, getConfiguration as l, mapValues as m, getStateNodes as n, isInFinalState as o, State as p, isErrorEvent as q, resolveStateValue as r, macrostep as s, toArray as t, transitionNode as u, getInitialConfiguration as v, resolveActionsAndContext as w, assign as x, createInitEvent as y, microstep as z };
3136
+ export { fromObservable as $, microstep as A, isAtomicStateNode as B, isStateId as C, getStateNodeByPath as D, getPersistedState as E, resolveReferencedActor as F, createActor as G, matchesState as H, sendTo as I, sendParent as J, forwardTo as K, interpret as L, Actor as M, NULL_EVENT as N, ActorStatus as O, InterpreterStatus as P, doneInvoke as Q, cancel as R, STATE_DELIMITER as S, choose as T, log as U, pure as V, raise as W, stop as X, pathToStateValue as Y, toObserver as Z, fromPromise as _, toTransitionConfigArray as a, fromCallback as a0, fromEventObservable as a1, fromTransition as a2, stateIn as a3, not as a4, and as a5, or as a6, ConstantPrefix as a7, SpecialTargets as a8, startSignalType as a9, stopSignalType as aa, startSignal as ab, stopSignal as ac, isSignal as ad, isActorRef as ae, toActorRef as af, createEmptyActor as ag, toGuardDefinition as ah, constantPrefixes as ai, after as aj, done as ak, error as al, escalate as am, formatTransition as b, memo as c, flatten as d, evaluateGuard as e, formatTransitions as f, createInvokeId as g, getDelayedTransitions as h, formatInitialTransition as i, getCandidates as j, toInvokeConfig as k, getConfiguration as l, mapValues as m, getStateNodes as n, isInFinalState as o, State as p, isErrorEvent as q, resolveStateValue as r, cloneState as s, toArray as t, macrostep as u, transitionNode as v, getInitialConfiguration as w, resolveActionsAndContext as x, assign as y, createInitEvent as z };