@myinterview/widget-react 1.1.21-development-51cf6ea → 1.1.21-development-1c53386
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/dist/cjs/index.js +458 -173
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +458 -173
- package/dist/esm/index.js.map +1 -1
- package/package.json +2 -2
package/dist/esm/index.js
CHANGED
|
@@ -19877,6 +19877,9 @@ function toObserver(nextHandler, errorHandler, completionHandler) {
|
|
|
19877
19877
|
function createInvokeId(stateNodeId, index) {
|
|
19878
19878
|
return "".concat(stateNodeId, ":invocation[").concat(index, "]");
|
|
19879
19879
|
}
|
|
19880
|
+
function isRaisableAction(action) {
|
|
19881
|
+
return (action.type === raise$3 || action.type === send$4 && action.to === SpecialTargets.Internal) && typeof action.delay !== 'number';
|
|
19882
|
+
}
|
|
19880
19883
|
|
|
19881
19884
|
var initEvent$1 = /*#__PURE__*/toSCXMLEvent({
|
|
19882
19885
|
type: init$1
|
|
@@ -19953,28 +19956,40 @@ function toActivityDefinition$1(action) {
|
|
|
19953
19956
|
* @param eventType The event to raise.
|
|
19954
19957
|
*/
|
|
19955
19958
|
|
|
19956
|
-
function raise$2(event) {
|
|
19957
|
-
if (!isString$1(event)) {
|
|
19958
|
-
return send$3(event, {
|
|
19959
|
-
to: SpecialTargets.Internal
|
|
19960
|
-
});
|
|
19961
|
-
}
|
|
19962
|
-
|
|
19959
|
+
function raise$2(event, options) {
|
|
19963
19960
|
return {
|
|
19964
19961
|
type: raise$3,
|
|
19965
|
-
event: event
|
|
19962
|
+
event: typeof event === 'function' ? event : toEventObject(event),
|
|
19963
|
+
delay: options ? options.delay : undefined,
|
|
19964
|
+
id: options === null || options === void 0 ? void 0 : options.id
|
|
19966
19965
|
};
|
|
19967
19966
|
}
|
|
19968
|
-
function resolveRaise$1(action) {
|
|
19969
|
-
|
|
19970
|
-
|
|
19971
|
-
_event: toSCXMLEvent(action.event)
|
|
19967
|
+
function resolveRaise$1(action, ctx, _event, delaysMap) {
|
|
19968
|
+
var meta = {
|
|
19969
|
+
_event: _event
|
|
19972
19970
|
};
|
|
19971
|
+
var resolvedEvent = toSCXMLEvent(isFunction$2(action.event) ? action.event(ctx, _event.data, meta) : action.event);
|
|
19972
|
+
var resolvedDelay;
|
|
19973
|
+
|
|
19974
|
+
if (isString$1(action.delay)) {
|
|
19975
|
+
var configDelay = delaysMap && delaysMap[action.delay];
|
|
19976
|
+
resolvedDelay = isFunction$2(configDelay) ? configDelay(ctx, _event.data, meta) : configDelay;
|
|
19977
|
+
} else {
|
|
19978
|
+
resolvedDelay = isFunction$2(action.delay) ? action.delay(ctx, _event.data, meta) : action.delay;
|
|
19979
|
+
}
|
|
19980
|
+
|
|
19981
|
+
return __assign$2(__assign$2({}, action), {
|
|
19982
|
+
type: raise$3,
|
|
19983
|
+
_event: resolvedEvent,
|
|
19984
|
+
delay: resolvedDelay
|
|
19985
|
+
});
|
|
19973
19986
|
}
|
|
19974
19987
|
/**
|
|
19975
19988
|
* Sends an event. This returns an action that will be read by an interpreter to
|
|
19976
19989
|
* send the event in the next step, after the current step is finished executing.
|
|
19977
19990
|
*
|
|
19991
|
+
* @deprecated Use the `sendTo(...)` action creator instead.
|
|
19992
|
+
*
|
|
19978
19993
|
* @param event The event to send.
|
|
19979
19994
|
* @param options Options to pass into the send event:
|
|
19980
19995
|
* - `id` - The unique send event identifier (used with `cancel()`).
|
|
@@ -19988,6 +20003,8 @@ function send$3(event, options) {
|
|
|
19988
20003
|
type: send$4,
|
|
19989
20004
|
event: isFunction$2(event) ? event : toEventObject(event),
|
|
19990
20005
|
delay: options ? options.delay : undefined,
|
|
20006
|
+
// TODO: don't auto-generate IDs here like that
|
|
20007
|
+
// there is too big chance of the ID collision
|
|
19991
20008
|
id: options && options.id !== undefined ? options.id : isFunction$2(event) ? event.name : getEventType(event)
|
|
19992
20009
|
};
|
|
19993
20010
|
}
|
|
@@ -20167,39 +20184,83 @@ function error$2(id, data) {
|
|
|
20167
20184
|
|
|
20168
20185
|
return eventObject;
|
|
20169
20186
|
}
|
|
20170
|
-
|
|
20187
|
+
|
|
20188
|
+
var pluckAssigns$1 = function (actionBlocks) {
|
|
20189
|
+
var e_1, _a;
|
|
20190
|
+
|
|
20191
|
+
var assignActions = [];
|
|
20192
|
+
|
|
20193
|
+
try {
|
|
20194
|
+
for (var actionBlocks_1 = __values$1(actionBlocks), actionBlocks_1_1 = actionBlocks_1.next(); !actionBlocks_1_1.done; actionBlocks_1_1 = actionBlocks_1.next()) {
|
|
20195
|
+
var block = actionBlocks_1_1.value;
|
|
20196
|
+
var i = 0;
|
|
20197
|
+
|
|
20198
|
+
while (i < block.actions.length) {
|
|
20199
|
+
if (block.actions[i].type === assign$4) {
|
|
20200
|
+
assignActions.push(block.actions[i]);
|
|
20201
|
+
block.actions.splice(i, 1);
|
|
20202
|
+
continue;
|
|
20203
|
+
}
|
|
20204
|
+
|
|
20205
|
+
i++;
|
|
20206
|
+
}
|
|
20207
|
+
}
|
|
20208
|
+
} catch (e_1_1) {
|
|
20209
|
+
e_1 = {
|
|
20210
|
+
error: e_1_1
|
|
20211
|
+
};
|
|
20212
|
+
} finally {
|
|
20213
|
+
try {
|
|
20214
|
+
if (actionBlocks_1_1 && !actionBlocks_1_1.done && (_a = actionBlocks_1.return)) _a.call(actionBlocks_1);
|
|
20215
|
+
} finally {
|
|
20216
|
+
if (e_1) throw e_1.error;
|
|
20217
|
+
}
|
|
20218
|
+
}
|
|
20219
|
+
|
|
20220
|
+
return assignActions;
|
|
20221
|
+
};
|
|
20222
|
+
|
|
20223
|
+
function resolveActions$1(machine, currentState, currentContext, _event, actionBlocks, predictableExec, preserveActionOrder) {
|
|
20171
20224
|
if (preserveActionOrder === void 0) {
|
|
20172
20225
|
preserveActionOrder = false;
|
|
20173
20226
|
}
|
|
20174
20227
|
|
|
20175
|
-
var
|
|
20176
|
-
return action.type === assign$4;
|
|
20177
|
-
}), 2),
|
|
20178
|
-
assignActions = _a[0],
|
|
20179
|
-
otherActions = _a[1];
|
|
20180
|
-
|
|
20228
|
+
var assignActions = preserveActionOrder ? [] : pluckAssigns$1(actionBlocks);
|
|
20181
20229
|
var updatedContext = assignActions.length ? updateContext(currentContext, _event, assignActions, currentState) : currentContext;
|
|
20182
20230
|
var preservedContexts = preserveActionOrder ? [currentContext] : undefined;
|
|
20183
|
-
var
|
|
20231
|
+
var deferredToBlockEnd = [];
|
|
20232
|
+
|
|
20233
|
+
function handleAction(blockType, actionObject) {
|
|
20184
20234
|
var _a;
|
|
20185
20235
|
|
|
20186
20236
|
switch (actionObject.type) {
|
|
20187
20237
|
case raise$3:
|
|
20188
20238
|
{
|
|
20189
|
-
|
|
20239
|
+
var raisedAction = resolveRaise$1(actionObject, updatedContext, _event, machine.options.delays);
|
|
20240
|
+
|
|
20241
|
+
if (predictableExec && typeof raisedAction.delay === 'number') {
|
|
20242
|
+
predictableExec(raisedAction, updatedContext, _event);
|
|
20243
|
+
}
|
|
20244
|
+
|
|
20245
|
+
return raisedAction;
|
|
20190
20246
|
}
|
|
20191
20247
|
|
|
20192
20248
|
case send$4:
|
|
20193
20249
|
var sendAction = resolveSend$1(actionObject, updatedContext, _event, machine.options.delays); // TODO: fix ActionTypes.Init
|
|
20194
20250
|
|
|
20195
20251
|
if (!IS_PRODUCTION$1) {
|
|
20196
|
-
// warn after resolving as we can create better contextual message here
|
|
20197
|
-
|
|
20198
|
-
|
|
20252
|
+
var configuredDelay = actionObject.delay; // warn after resolving as we can create better contextual message here
|
|
20253
|
+
|
|
20254
|
+
warn$1(!isString$1(configuredDelay) || typeof sendAction.delay === 'number', // tslint:disable-next-line:max-line-length
|
|
20255
|
+
"No delay reference for delay expression '".concat(configuredDelay, "' was found on machine '").concat(machine.id, "'"));
|
|
20199
20256
|
}
|
|
20200
20257
|
|
|
20201
|
-
if (sendAction.to !== SpecialTargets.Internal) {
|
|
20202
|
-
|
|
20258
|
+
if (predictableExec && sendAction.to !== SpecialTargets.Internal) {
|
|
20259
|
+
if (blockType === 'entry') {
|
|
20260
|
+
deferredToBlockEnd.push(sendAction);
|
|
20261
|
+
} else {
|
|
20262
|
+
predictableExec(sendAction, updatedContext, _event);
|
|
20263
|
+
}
|
|
20203
20264
|
}
|
|
20204
20265
|
|
|
20205
20266
|
return sendAction;
|
|
@@ -20223,7 +20284,10 @@ function resolveActions$1(machine, currentState, currentContext, _event, actions
|
|
|
20223
20284
|
return [];
|
|
20224
20285
|
}
|
|
20225
20286
|
|
|
20226
|
-
var _b = __read$3(resolveActions$1(machine, currentState, updatedContext, _event,
|
|
20287
|
+
var _b = __read$3(resolveActions$1(machine, currentState, updatedContext, _event, [{
|
|
20288
|
+
type: blockType,
|
|
20289
|
+
actions: toActionObjects$1(toArray$1(matchedActions), machine.options.actions)
|
|
20290
|
+
}], predictableExec, preserveActionOrder), 2),
|
|
20227
20291
|
resolvedActionsFromChoose = _b[0],
|
|
20228
20292
|
resolvedContextFromChoose = _b[1];
|
|
20229
20293
|
|
|
@@ -20240,7 +20304,10 @@ function resolveActions$1(machine, currentState, currentContext, _event, actions
|
|
|
20240
20304
|
return [];
|
|
20241
20305
|
}
|
|
20242
20306
|
|
|
20243
|
-
var _c = __read$3(resolveActions$1(machine, currentState, updatedContext, _event,
|
|
20307
|
+
var _c = __read$3(resolveActions$1(machine, currentState, updatedContext, _event, [{
|
|
20308
|
+
type: blockType,
|
|
20309
|
+
actions: toActionObjects$1(toArray$1(matchedActions), machine.options.actions)
|
|
20310
|
+
}], predictableExec, preserveActionOrder), 2),
|
|
20244
20311
|
resolvedActionsFromPure = _c[0],
|
|
20245
20312
|
resolvedContext = _c[1];
|
|
20246
20313
|
|
|
@@ -20252,7 +20319,7 @@ function resolveActions$1(machine, currentState, currentContext, _event, actions
|
|
|
20252
20319
|
case stop$3:
|
|
20253
20320
|
{
|
|
20254
20321
|
var resolved = resolveStop$1(actionObject, updatedContext, _event);
|
|
20255
|
-
predictableExec === null || predictableExec === void 0 ? void 0 : predictableExec(resolved,
|
|
20322
|
+
predictableExec === null || predictableExec === void 0 ? void 0 : predictableExec(resolved, currentContext, _event);
|
|
20256
20323
|
return resolved;
|
|
20257
20324
|
}
|
|
20258
20325
|
|
|
@@ -20271,7 +20338,8 @@ function resolveActions$1(machine, currentState, currentContext, _event, actions
|
|
|
20271
20338
|
predictableExec(resolvedActionObject, updatedContext, _event);
|
|
20272
20339
|
} else if (exec_1 && preservedContexts) {
|
|
20273
20340
|
var contextIndex_1 = preservedContexts.length - 1;
|
|
20274
|
-
|
|
20341
|
+
|
|
20342
|
+
var wrapped = __assign$2(__assign$2({}, resolvedActionObject), {
|
|
20275
20343
|
exec: function (_ctx) {
|
|
20276
20344
|
var args = [];
|
|
20277
20345
|
|
|
@@ -20282,13 +20350,48 @@ function resolveActions$1(machine, currentState, currentContext, _event, actions
|
|
|
20282
20350
|
exec_1.apply(void 0, __spreadArray$1([preservedContexts[contextIndex_1]], __read$3(args), false));
|
|
20283
20351
|
}
|
|
20284
20352
|
});
|
|
20353
|
+
|
|
20354
|
+
resolvedActionObject = wrapped;
|
|
20285
20355
|
}
|
|
20286
20356
|
|
|
20287
20357
|
return resolvedActionObject;
|
|
20288
20358
|
}
|
|
20289
|
-
}
|
|
20290
|
-
|
|
20291
|
-
|
|
20359
|
+
}
|
|
20360
|
+
|
|
20361
|
+
function processBlock(block) {
|
|
20362
|
+
var e_2, _a;
|
|
20363
|
+
|
|
20364
|
+
var resolvedActions = [];
|
|
20365
|
+
|
|
20366
|
+
try {
|
|
20367
|
+
for (var _b = __values$1(block.actions), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
20368
|
+
var action = _c.value;
|
|
20369
|
+
var resolved = handleAction(block.type, action);
|
|
20370
|
+
|
|
20371
|
+
if (resolved) {
|
|
20372
|
+
resolvedActions = resolvedActions.concat(resolved);
|
|
20373
|
+
}
|
|
20374
|
+
}
|
|
20375
|
+
} catch (e_2_1) {
|
|
20376
|
+
e_2 = {
|
|
20377
|
+
error: e_2_1
|
|
20378
|
+
};
|
|
20379
|
+
} finally {
|
|
20380
|
+
try {
|
|
20381
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
20382
|
+
} finally {
|
|
20383
|
+
if (e_2) throw e_2.error;
|
|
20384
|
+
}
|
|
20385
|
+
}
|
|
20386
|
+
|
|
20387
|
+
deferredToBlockEnd.forEach(function (action) {
|
|
20388
|
+
predictableExec(action, updatedContext, _event);
|
|
20389
|
+
});
|
|
20390
|
+
deferredToBlockEnd.length = 0;
|
|
20391
|
+
return resolvedActions;
|
|
20392
|
+
}
|
|
20393
|
+
|
|
20394
|
+
var resolvedActions = flatten(actionBlocks.map(processBlock));
|
|
20292
20395
|
return [resolvedActions, updatedContext];
|
|
20293
20396
|
}
|
|
20294
20397
|
|
|
@@ -21140,12 +21243,12 @@ function () {
|
|
|
21140
21243
|
* @param options Interpreter options
|
|
21141
21244
|
*/
|
|
21142
21245
|
function Interpreter(machine, options) {
|
|
21143
|
-
var _this = this;
|
|
21144
|
-
|
|
21145
21246
|
if (options === void 0) {
|
|
21146
21247
|
options = Interpreter.defaultOptions;
|
|
21147
21248
|
}
|
|
21148
21249
|
|
|
21250
|
+
var _this = this;
|
|
21251
|
+
|
|
21149
21252
|
this.machine = machine;
|
|
21150
21253
|
this.delayedEventsMap = {};
|
|
21151
21254
|
this.listeners = new Set();
|
|
@@ -21162,6 +21265,7 @@ function () {
|
|
|
21162
21265
|
this.status = InterpreterStatus.NotStarted;
|
|
21163
21266
|
this.children = new Map();
|
|
21164
21267
|
this.forwardTo = new Set();
|
|
21268
|
+
this._outgoingQueue = [];
|
|
21165
21269
|
/**
|
|
21166
21270
|
* Alias for Interpreter.prototype.start
|
|
21167
21271
|
*/
|
|
@@ -21213,9 +21317,9 @@ function () {
|
|
|
21213
21317
|
// tslint:disable-next-line:semicolon
|
|
21214
21318
|
};
|
|
21215
21319
|
|
|
21216
|
-
this.sendTo = function (event, to) {
|
|
21320
|
+
this.sendTo = function (event, to, immediate) {
|
|
21217
21321
|
var isParent = _this.parent && (to === SpecialTargets.Parent || _this.parent.id === to);
|
|
21218
|
-
var target = isParent ? _this.parent : isString$1(to) ? _this.children.get(to) || registry.get(to) : isActor$1(to) ? to : undefined;
|
|
21322
|
+
var target = isParent ? _this.parent : isString$1(to) ? to === SpecialTargets.Internal ? _this : _this.children.get(to) || registry.get(to) : isActor$1(to) ? to : undefined;
|
|
21219
21323
|
|
|
21220
21324
|
if (!target) {
|
|
21221
21325
|
if (!isParent) {
|
|
@@ -21236,14 +21340,24 @@ function () {
|
|
|
21236
21340
|
if (_this.status !== InterpreterStatus.Stopped || _this.parent !== target || // we need to send events to the parent from exit handlers of a machine that reached its final state
|
|
21237
21341
|
_this.state.done) {
|
|
21238
21342
|
// Send SCXML events to machines
|
|
21239
|
-
|
|
21343
|
+
var scxmlEvent = __assign$2(__assign$2({}, event), {
|
|
21240
21344
|
name: event.name === error$3 ? "".concat(error$2(_this.id)) : event.name,
|
|
21241
21345
|
origin: _this.sessionId
|
|
21242
|
-
})
|
|
21346
|
+
});
|
|
21347
|
+
|
|
21348
|
+
if (!immediate && _this.machine.config.predictableActionArguments) {
|
|
21349
|
+
_this._outgoingQueue.push([target, scxmlEvent]);
|
|
21350
|
+
} else {
|
|
21351
|
+
target.send(scxmlEvent);
|
|
21352
|
+
}
|
|
21243
21353
|
}
|
|
21244
21354
|
} else {
|
|
21245
21355
|
// Send normal events to other targets
|
|
21246
|
-
|
|
21356
|
+
if (!immediate && _this.machine.config.predictableActionArguments) {
|
|
21357
|
+
_this._outgoingQueue.push([target, event.data]);
|
|
21358
|
+
} else {
|
|
21359
|
+
target.send(event.data);
|
|
21360
|
+
}
|
|
21247
21361
|
}
|
|
21248
21362
|
};
|
|
21249
21363
|
|
|
@@ -21278,6 +21392,16 @@ function () {
|
|
|
21278
21392
|
}
|
|
21279
21393
|
|
|
21280
21394
|
switch (action.type) {
|
|
21395
|
+
case raise$3:
|
|
21396
|
+
{
|
|
21397
|
+
// if raise action reached the interpreter then it's a delayed one
|
|
21398
|
+
var sendAction_1 = action;
|
|
21399
|
+
|
|
21400
|
+
_this.defer(sendAction_1);
|
|
21401
|
+
|
|
21402
|
+
break;
|
|
21403
|
+
}
|
|
21404
|
+
|
|
21281
21405
|
case send$4:
|
|
21282
21406
|
var sendAction = action;
|
|
21283
21407
|
|
|
@@ -21287,7 +21411,7 @@ function () {
|
|
|
21287
21411
|
return;
|
|
21288
21412
|
} else {
|
|
21289
21413
|
if (sendAction.to) {
|
|
21290
|
-
_this.sendTo(sendAction._event, sendAction.to);
|
|
21414
|
+
_this.sendTo(sendAction._event, sendAction.to, _event === initEvent$1);
|
|
21291
21415
|
} else {
|
|
21292
21416
|
_this.send(sendAction._event);
|
|
21293
21417
|
}
|
|
@@ -21381,8 +21505,9 @@ function () {
|
|
|
21381
21505
|
}
|
|
21382
21506
|
|
|
21383
21507
|
case log$2:
|
|
21384
|
-
var
|
|
21385
|
-
|
|
21508
|
+
var _a = action,
|
|
21509
|
+
label = _a.label,
|
|
21510
|
+
value = _a.value;
|
|
21386
21511
|
|
|
21387
21512
|
if (label) {
|
|
21388
21513
|
_this.logger(label, value);
|
|
@@ -21436,6 +21561,9 @@ function () {
|
|
|
21436
21561
|
configurable: true
|
|
21437
21562
|
});
|
|
21438
21563
|
Object.defineProperty(Interpreter.prototype, "state", {
|
|
21564
|
+
/**
|
|
21565
|
+
* @deprecated Use `.getSnapshot()` instead.
|
|
21566
|
+
*/
|
|
21439
21567
|
get: function () {
|
|
21440
21568
|
if (!IS_PRODUCTION$1) {
|
|
21441
21569
|
warn$1(this.status !== InterpreterStatus.NotStarted, "Attempted to read state from uninitialized service '".concat(this.id, "'. Make sure the service is started first."));
|
|
@@ -21488,6 +21616,12 @@ function () {
|
|
|
21488
21616
|
// we can't just recompute it (and execute actions while doing so) because we try to preserve identity of actors created within initial assigns
|
|
21489
21617
|
_event === initEvent$1) && this.options.execute) {
|
|
21490
21618
|
this.execute(this.state);
|
|
21619
|
+
} else {
|
|
21620
|
+
var item = void 0;
|
|
21621
|
+
|
|
21622
|
+
while (item = this._outgoingQueue.shift()) {
|
|
21623
|
+
item[0].send(item[1]);
|
|
21624
|
+
}
|
|
21491
21625
|
} // Update children
|
|
21492
21626
|
|
|
21493
21627
|
|
|
@@ -21559,11 +21693,12 @@ function () {
|
|
|
21559
21693
|
return sn.type === 'final' && sn.parent === _this.machine;
|
|
21560
21694
|
});
|
|
21561
21695
|
var doneData = finalChildStateNode && finalChildStateNode.doneData ? mapContext(finalChildStateNode.doneData, state.context, _event) : undefined;
|
|
21696
|
+
this._doneEvent = doneInvoke$1(this.id, doneData);
|
|
21562
21697
|
|
|
21563
21698
|
try {
|
|
21564
21699
|
for (var _l = __values$1(this.doneListeners), _m = _l.next(); !_m.done; _m = _l.next()) {
|
|
21565
21700
|
var listener = _m.value;
|
|
21566
|
-
listener(
|
|
21701
|
+
listener(this._doneEvent);
|
|
21567
21702
|
}
|
|
21568
21703
|
} catch (e_5_1) {
|
|
21569
21704
|
e_5 = {
|
|
@@ -21580,6 +21715,8 @@ function () {
|
|
|
21580
21715
|
this._stop();
|
|
21581
21716
|
|
|
21582
21717
|
this._stopChildren();
|
|
21718
|
+
|
|
21719
|
+
registry.free(this.sessionId);
|
|
21583
21720
|
}
|
|
21584
21721
|
};
|
|
21585
21722
|
/*
|
|
@@ -21683,7 +21820,12 @@ function () {
|
|
|
21683
21820
|
|
|
21684
21821
|
|
|
21685
21822
|
Interpreter.prototype.onDone = function (listener) {
|
|
21686
|
-
this.
|
|
21823
|
+
if (this.status === InterpreterStatus.Stopped && this._doneEvent) {
|
|
21824
|
+
listener(this._doneEvent);
|
|
21825
|
+
} else {
|
|
21826
|
+
this.doneListeners.add(listener);
|
|
21827
|
+
}
|
|
21828
|
+
|
|
21687
21829
|
return this;
|
|
21688
21830
|
};
|
|
21689
21831
|
/**
|
|
@@ -21885,7 +22027,10 @@ function () {
|
|
|
21885
22027
|
return toActionObjects$1(stateNode.onExit, _this.machine.options.actions);
|
|
21886
22028
|
}));
|
|
21887
22029
|
|
|
21888
|
-
var _a = __read$3(resolveActions$1(_this.machine, _this.state, _this.state.context, _event,
|
|
22030
|
+
var _a = __read$3(resolveActions$1(_this.machine, _this.state, _this.state.context, _event, [{
|
|
22031
|
+
type: 'exit',
|
|
22032
|
+
actions: exitActions
|
|
22033
|
+
}], _this.machine.config.predictableActionArguments ? _this._exec : undefined, _this.machine.config.predictableActionArguments || _this.machine.config.preserveActionOrder), 2),
|
|
21889
22034
|
resolvedActions = _a[0],
|
|
21890
22035
|
updatedContext = _a[1];
|
|
21891
22036
|
|
|
@@ -21897,7 +22042,7 @@ function () {
|
|
|
21897
22042
|
historyValue: undefined,
|
|
21898
22043
|
history: _this.state,
|
|
21899
22044
|
actions: resolvedActions.filter(function (action) {
|
|
21900
|
-
return
|
|
22045
|
+
return !isRaisableAction(action);
|
|
21901
22046
|
}),
|
|
21902
22047
|
activities: {},
|
|
21903
22048
|
events: [],
|
|
@@ -21934,6 +22079,11 @@ function () {
|
|
|
21934
22079
|
"".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."));
|
|
21935
22080
|
}
|
|
21936
22081
|
|
|
22082
|
+
if (!events.length) {
|
|
22083
|
+
return;
|
|
22084
|
+
}
|
|
22085
|
+
|
|
22086
|
+
var exec = !!this.machine.config.predictableActionArguments && this._exec;
|
|
21937
22087
|
this.scheduler.schedule(function () {
|
|
21938
22088
|
var e_11, _a;
|
|
21939
22089
|
|
|
@@ -21947,9 +22097,9 @@ function () {
|
|
|
21947
22097
|
_this.forward(_event);
|
|
21948
22098
|
|
|
21949
22099
|
nextState = provide(_this, function () {
|
|
21950
|
-
return _this.machine.transition(nextState, _event);
|
|
22100
|
+
return _this.machine.transition(nextState, _event, undefined, exec || undefined);
|
|
21951
22101
|
});
|
|
21952
|
-
batchedActions.push.apply(batchedActions, __spreadArray$1([], __read$3(nextState.actions.map(function (a) {
|
|
22102
|
+
batchedActions.push.apply(batchedActions, __spreadArray$1([], __read$3(_this.machine.config.predictableActionArguments ? nextState.actions : nextState.actions.map(function (a) {
|
|
21953
22103
|
return bindActionToState(a, nextState);
|
|
21954
22104
|
})), false));
|
|
21955
22105
|
batchChanged = batchChanged || !!nextState.changed;
|
|
@@ -22053,13 +22203,17 @@ function () {
|
|
|
22053
22203
|
Interpreter.prototype.defer = function (sendAction) {
|
|
22054
22204
|
var _this = this;
|
|
22055
22205
|
|
|
22056
|
-
|
|
22057
|
-
if (sendAction.to) {
|
|
22058
|
-
_this.sendTo(sendAction._event, sendAction.to);
|
|
22206
|
+
var timerId = this.clock.setTimeout(function () {
|
|
22207
|
+
if ('to' in sendAction && sendAction.to) {
|
|
22208
|
+
_this.sendTo(sendAction._event, sendAction.to, true);
|
|
22059
22209
|
} else {
|
|
22060
22210
|
_this.send(sendAction._event);
|
|
22061
22211
|
}
|
|
22062
22212
|
}, sendAction.delay);
|
|
22213
|
+
|
|
22214
|
+
if (sendAction.id) {
|
|
22215
|
+
this.delayedEventsMap[sendAction.id] = timerId;
|
|
22216
|
+
}
|
|
22063
22217
|
};
|
|
22064
22218
|
|
|
22065
22219
|
Interpreter.prototype.cancel = function (sendId) {
|
|
@@ -22636,12 +22790,12 @@ function () {
|
|
|
22636
22790
|
*/
|
|
22637
22791
|
_context, // TODO: this is unsafe, but we're removing it in v5 anyway
|
|
22638
22792
|
_stateInfo) {
|
|
22639
|
-
var _this = this;
|
|
22640
|
-
|
|
22641
22793
|
if (_context === void 0) {
|
|
22642
22794
|
_context = 'context' in config ? config.context : undefined;
|
|
22643
22795
|
}
|
|
22644
22796
|
|
|
22797
|
+
var _this = this;
|
|
22798
|
+
|
|
22645
22799
|
var _a;
|
|
22646
22800
|
|
|
22647
22801
|
this.config = config;
|
|
@@ -23104,15 +23258,11 @@ function () {
|
|
|
23104
23258
|
return this.next(state, _event);
|
|
23105
23259
|
}
|
|
23106
23260
|
|
|
23107
|
-
var entryNodes = flatten(stateTransitions.map(function (t) {
|
|
23108
|
-
return t.entrySet;
|
|
23109
|
-
}));
|
|
23110
23261
|
var configuration = flatten(Object.keys(transitionMap).map(function (key) {
|
|
23111
23262
|
return transitionMap[key].configuration;
|
|
23112
23263
|
}));
|
|
23113
23264
|
return {
|
|
23114
23265
|
transitions: enabledTransitions,
|
|
23115
|
-
entrySet: entryNodes,
|
|
23116
23266
|
exitSet: flatten(stateTransitions.map(function (t) {
|
|
23117
23267
|
return t.exitSet;
|
|
23118
23268
|
})),
|
|
@@ -23199,7 +23349,6 @@ function () {
|
|
|
23199
23349
|
if (!nextStateNodes.length) {
|
|
23200
23350
|
return {
|
|
23201
23351
|
transitions: [selectedTransition],
|
|
23202
|
-
entrySet: [],
|
|
23203
23352
|
exitSet: [],
|
|
23204
23353
|
configuration: state.value ? [this] : [],
|
|
23205
23354
|
source: state,
|
|
@@ -23211,30 +23360,28 @@ function () {
|
|
|
23211
23360
|
return _this.getRelativeStateNodes(stateNode, state.historyValue);
|
|
23212
23361
|
}));
|
|
23213
23362
|
var isInternal = !!selectedTransition.internal;
|
|
23214
|
-
var reentryNodes = [];
|
|
23215
|
-
|
|
23216
|
-
if (!isInternal) {
|
|
23217
|
-
nextStateNodes.forEach(function (targetNode) {
|
|
23218
|
-
reentryNodes.push.apply(reentryNodes, __spreadArray$1([], __read$3(_this.getExternalReentryNodes(targetNode)), false));
|
|
23219
|
-
});
|
|
23220
|
-
}
|
|
23221
|
-
|
|
23222
23363
|
return {
|
|
23223
23364
|
transitions: [selectedTransition],
|
|
23224
|
-
|
|
23225
|
-
|
|
23365
|
+
exitSet: isInternal ? [] : flatten(nextStateNodes.map(function (targetNode) {
|
|
23366
|
+
return _this.getPotentiallyReenteringNodes(targetNode);
|
|
23367
|
+
})),
|
|
23226
23368
|
configuration: allNextStateNodes,
|
|
23227
23369
|
source: state,
|
|
23228
23370
|
actions: actions
|
|
23229
23371
|
};
|
|
23230
|
-
};
|
|
23372
|
+
}; // even though the name of this function mentions reentry nodes
|
|
23373
|
+
// we are pushing its result into `exitSet`
|
|
23374
|
+
// that's because what we exit might be reentered (it's an invariant of reentrancy)
|
|
23231
23375
|
|
|
23232
|
-
StateNode.prototype.getExternalReentryNodes = function (targetNode) {
|
|
23233
|
-
var nodes = [];
|
|
23234
23376
|
|
|
23235
|
-
|
|
23236
|
-
|
|
23237
|
-
|
|
23377
|
+
StateNode.prototype.getPotentiallyReenteringNodes = function (targetNode) {
|
|
23378
|
+
if (this.order < targetNode.order) {
|
|
23379
|
+
return [this];
|
|
23380
|
+
}
|
|
23381
|
+
|
|
23382
|
+
var nodes = [];
|
|
23383
|
+
var marker = this;
|
|
23384
|
+
var possibleAncestor = targetNode;
|
|
23238
23385
|
|
|
23239
23386
|
while (marker && marker !== possibleAncestor) {
|
|
23240
23387
|
nodes.push(marker);
|
|
@@ -23251,17 +23398,22 @@ function () {
|
|
|
23251
23398
|
return nodes;
|
|
23252
23399
|
};
|
|
23253
23400
|
|
|
23254
|
-
StateNode.prototype.getActions = function (resolvedConfig, isDone, transition, currentContext, _event, prevState) {
|
|
23401
|
+
StateNode.prototype.getActions = function (resolvedConfig, isDone, transition, currentContext, _event, prevState, predictableExec) {
|
|
23255
23402
|
var e_4, _a, e_5, _b;
|
|
23256
23403
|
|
|
23257
|
-
var
|
|
23404
|
+
var _this = this;
|
|
23405
|
+
|
|
23406
|
+
var prevConfig = prevState ? getConfiguration([], this.getStateNodes(prevState.value)) : [];
|
|
23407
|
+
var entrySet = new Set();
|
|
23258
23408
|
|
|
23259
23409
|
try {
|
|
23260
|
-
for (var
|
|
23261
|
-
|
|
23410
|
+
for (var _c = __values$1(Array.from(resolvedConfig).sort(function (a, b) {
|
|
23411
|
+
return a.order - b.order;
|
|
23412
|
+
})), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
23413
|
+
var sn = _d.value;
|
|
23262
23414
|
|
|
23263
|
-
if (!has(prevConfig, sn) || has(transition.
|
|
23264
|
-
|
|
23415
|
+
if (!has(prevConfig, sn) || has(transition.exitSet, sn) || sn.parent && entrySet.has(sn.parent)) {
|
|
23416
|
+
entrySet.add(sn);
|
|
23265
23417
|
}
|
|
23266
23418
|
}
|
|
23267
23419
|
} catch (e_4_1) {
|
|
@@ -23270,7 +23422,7 @@ function () {
|
|
|
23270
23422
|
};
|
|
23271
23423
|
} finally {
|
|
23272
23424
|
try {
|
|
23273
|
-
if (
|
|
23425
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
23274
23426
|
} finally {
|
|
23275
23427
|
if (e_4) throw e_4.error;
|
|
23276
23428
|
}
|
|
@@ -23296,7 +23448,14 @@ function () {
|
|
|
23296
23448
|
}
|
|
23297
23449
|
}
|
|
23298
23450
|
|
|
23299
|
-
|
|
23451
|
+
transition.exitSet.sort(function (a, b) {
|
|
23452
|
+
return b.order - a.order;
|
|
23453
|
+
});
|
|
23454
|
+
var entryStates = Array.from(entrySet).sort(function (a, b) {
|
|
23455
|
+
return a.order - b.order;
|
|
23456
|
+
});
|
|
23457
|
+
var exitStates = new Set(transition.exitSet);
|
|
23458
|
+
var doneEvents = flatten(entryStates.map(function (sn) {
|
|
23300
23459
|
var events = [];
|
|
23301
23460
|
|
|
23302
23461
|
if (sn.type !== 'final') {
|
|
@@ -23323,28 +23482,33 @@ function () {
|
|
|
23323
23482
|
|
|
23324
23483
|
return events;
|
|
23325
23484
|
}));
|
|
23326
|
-
|
|
23327
|
-
|
|
23485
|
+
var entryActions = entryStates.map(function (stateNode) {
|
|
23486
|
+
var entryActions = stateNode.onEntry;
|
|
23487
|
+
var invokeActions = stateNode.activities.map(function (activity) {
|
|
23488
|
+
return start$2(activity);
|
|
23489
|
+
});
|
|
23490
|
+
return {
|
|
23491
|
+
type: 'entry',
|
|
23492
|
+
actions: toActionObjects$1(predictableExec ? __spreadArray$1(__spreadArray$1([], __read$3(entryActions), false), __read$3(invokeActions), false) : __spreadArray$1(__spreadArray$1([], __read$3(invokeActions), false), __read$3(entryActions), false), _this.machine.options.actions)
|
|
23493
|
+
};
|
|
23494
|
+
}).concat({
|
|
23495
|
+
type: 'state_done',
|
|
23496
|
+
actions: doneEvents.map(function (event) {
|
|
23497
|
+
return raise$2(event);
|
|
23498
|
+
})
|
|
23328
23499
|
});
|
|
23329
|
-
|
|
23330
|
-
return
|
|
23500
|
+
var exitActions = Array.from(exitStates).map(function (stateNode) {
|
|
23501
|
+
return {
|
|
23502
|
+
type: 'exit',
|
|
23503
|
+
actions: toActionObjects$1(__spreadArray$1(__spreadArray$1([], __read$3(stateNode.onExit), false), __read$3(stateNode.activities.map(function (activity) {
|
|
23504
|
+
return stop$2(activity);
|
|
23505
|
+
})), false), _this.machine.options.actions)
|
|
23506
|
+
};
|
|
23331
23507
|
});
|
|
23332
|
-
var
|
|
23333
|
-
|
|
23334
|
-
|
|
23335
|
-
|
|
23336
|
-
return __spreadArray$1(__spreadArray$1([], __read$3(stateNode.activities.map(function (activity) {
|
|
23337
|
-
return start$2(activity);
|
|
23338
|
-
})), false), __read$3(stateNode.onEntry), false);
|
|
23339
|
-
})).concat(doneEvents.map(raise$2)), flatten(Array.from(exitStates).map(function (stateNode) {
|
|
23340
|
-
return __spreadArray$1(__spreadArray$1([], __read$3(stateNode.onExit), false), __read$3(stateNode.activities.map(function (activity) {
|
|
23341
|
-
return stop$2(activity);
|
|
23342
|
-
})), false);
|
|
23343
|
-
}))], 2),
|
|
23344
|
-
entryActions = _c[0],
|
|
23345
|
-
exitActions = _c[1];
|
|
23346
|
-
|
|
23347
|
-
var actions = toActionObjects$1(exitActions.concat(transition.actions).concat(entryActions), this.machine.options.actions);
|
|
23508
|
+
var actions = exitActions.concat({
|
|
23509
|
+
type: 'transition',
|
|
23510
|
+
actions: toActionObjects$1(transition.actions, this.machine.options.actions)
|
|
23511
|
+
}).concat(entryActions);
|
|
23348
23512
|
|
|
23349
23513
|
if (isDone) {
|
|
23350
23514
|
var stopActions = toActionObjects$1(flatten(__spreadArray$1([], __read$3(resolvedConfig), false).sort(function (a, b) {
|
|
@@ -23352,9 +23516,12 @@ function () {
|
|
|
23352
23516
|
}).map(function (stateNode) {
|
|
23353
23517
|
return stateNode.onExit;
|
|
23354
23518
|
})), this.machine.options.actions).filter(function (action) {
|
|
23355
|
-
return
|
|
23519
|
+
return !isRaisableAction(action);
|
|
23520
|
+
});
|
|
23521
|
+
return actions.concat({
|
|
23522
|
+
type: 'stop',
|
|
23523
|
+
actions: stopActions
|
|
23356
23524
|
});
|
|
23357
|
-
return actions.concat(stopActions);
|
|
23358
23525
|
}
|
|
23359
23526
|
|
|
23360
23527
|
return actions;
|
|
@@ -23398,7 +23565,6 @@ function () {
|
|
|
23398
23565
|
var stateTransition = this._transition(currentState.value, currentState, _event) || {
|
|
23399
23566
|
transitions: [],
|
|
23400
23567
|
configuration: [],
|
|
23401
|
-
entrySet: [],
|
|
23402
23568
|
exitSet: [],
|
|
23403
23569
|
source: currentState,
|
|
23404
23570
|
actions: []
|
|
@@ -23425,7 +23591,7 @@ function () {
|
|
|
23425
23591
|
};
|
|
23426
23592
|
|
|
23427
23593
|
StateNode.prototype.resolveTransition = function (stateTransition, currentState, context, predictableExec, _event) {
|
|
23428
|
-
var e_6, _a;
|
|
23594
|
+
var e_6, _a, e_7, _b;
|
|
23429
23595
|
|
|
23430
23596
|
var _this = this;
|
|
23431
23597
|
|
|
@@ -23442,17 +23608,33 @@ function () {
|
|
|
23442
23608
|
var isDone = isInFinalState(resolvedConfiguration, this);
|
|
23443
23609
|
var resolvedStateValue = willTransition ? getValue(this.machine, configuration) : undefined;
|
|
23444
23610
|
var historyValue = currentState ? currentState.historyValue ? currentState.historyValue : stateTransition.source ? this.machine.historyValue(currentState.value) : undefined : undefined;
|
|
23445
|
-
var
|
|
23611
|
+
var actionBlocks = this.getActions(new Set(resolvedConfiguration), isDone, stateTransition, context, _event, currentState, predictableExec);
|
|
23446
23612
|
var activities = currentState ? __assign$2({}, currentState.activities) : {};
|
|
23447
23613
|
|
|
23448
23614
|
try {
|
|
23449
|
-
for (var
|
|
23450
|
-
var
|
|
23615
|
+
for (var actionBlocks_1 = __values$1(actionBlocks), actionBlocks_1_1 = actionBlocks_1.next(); !actionBlocks_1_1.done; actionBlocks_1_1 = actionBlocks_1.next()) {
|
|
23616
|
+
var block = actionBlocks_1_1.value;
|
|
23451
23617
|
|
|
23452
|
-
|
|
23453
|
-
|
|
23454
|
-
|
|
23455
|
-
|
|
23618
|
+
try {
|
|
23619
|
+
for (var _c = (e_7 = void 0, __values$1(block.actions)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
23620
|
+
var action = _d.value;
|
|
23621
|
+
|
|
23622
|
+
if (action.type === start$3) {
|
|
23623
|
+
activities[action.activity.id || action.activity.type] = action;
|
|
23624
|
+
} else if (action.type === stop$3) {
|
|
23625
|
+
activities[action.activity.id || action.activity.type] = false;
|
|
23626
|
+
}
|
|
23627
|
+
}
|
|
23628
|
+
} catch (e_7_1) {
|
|
23629
|
+
e_7 = {
|
|
23630
|
+
error: e_7_1
|
|
23631
|
+
};
|
|
23632
|
+
} finally {
|
|
23633
|
+
try {
|
|
23634
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
23635
|
+
} finally {
|
|
23636
|
+
if (e_7) throw e_7.error;
|
|
23637
|
+
}
|
|
23456
23638
|
}
|
|
23457
23639
|
}
|
|
23458
23640
|
} catch (e_6_1) {
|
|
@@ -23461,21 +23643,19 @@ function () {
|
|
|
23461
23643
|
};
|
|
23462
23644
|
} finally {
|
|
23463
23645
|
try {
|
|
23464
|
-
if (
|
|
23646
|
+
if (actionBlocks_1_1 && !actionBlocks_1_1.done && (_a = actionBlocks_1.return)) _a.call(actionBlocks_1);
|
|
23465
23647
|
} finally {
|
|
23466
23648
|
if (e_6) throw e_6.error;
|
|
23467
23649
|
}
|
|
23468
23650
|
}
|
|
23469
23651
|
|
|
23470
|
-
var
|
|
23471
|
-
resolvedActions =
|
|
23472
|
-
updatedContext =
|
|
23652
|
+
var _e = __read$3(resolveActions$1(this, currentState, context, _event, actionBlocks, predictableExec, this.machine.config.predictableActionArguments || this.machine.config.preserveActionOrder), 2),
|
|
23653
|
+
resolvedActions = _e[0],
|
|
23654
|
+
updatedContext = _e[1];
|
|
23473
23655
|
|
|
23474
|
-
var
|
|
23475
|
-
|
|
23476
|
-
|
|
23477
|
-
raisedEvents = _c[0],
|
|
23478
|
-
nonRaisedActions = _c[1];
|
|
23656
|
+
var _f = __read$3(partition(resolvedActions, isRaisableAction), 2),
|
|
23657
|
+
raisedEvents = _f[0],
|
|
23658
|
+
nonRaisedActions = _f[1];
|
|
23479
23659
|
|
|
23480
23660
|
var invokeActions = resolvedActions.filter(function (action) {
|
|
23481
23661
|
var _a;
|
|
@@ -23728,7 +23908,6 @@ function () {
|
|
|
23728
23908
|
var configuration = this.getStateNodes(stateValue);
|
|
23729
23909
|
return this.resolveTransition({
|
|
23730
23910
|
configuration: configuration,
|
|
23731
|
-
entrySet: __spreadArray$1([], __read$3(configuration), false),
|
|
23732
23911
|
exitSet: [],
|
|
23733
23912
|
transitions: [],
|
|
23734
23913
|
source: undefined,
|
|
@@ -23924,7 +24103,7 @@ function () {
|
|
|
23924
24103
|
* All the event types accepted by this state node and its descendants.
|
|
23925
24104
|
*/
|
|
23926
24105
|
get: function () {
|
|
23927
|
-
var
|
|
24106
|
+
var e_8, _a, e_9, _b;
|
|
23928
24107
|
|
|
23929
24108
|
if (this.__cache.events) {
|
|
23930
24109
|
return this.__cache.events;
|
|
@@ -23941,32 +24120,32 @@ function () {
|
|
|
23941
24120
|
|
|
23942
24121
|
if (state.states) {
|
|
23943
24122
|
try {
|
|
23944
|
-
for (var _e = (
|
|
24123
|
+
for (var _e = (e_9 = void 0, __values$1(state.events)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
23945
24124
|
var event_1 = _f.value;
|
|
23946
24125
|
events.add("".concat(event_1));
|
|
23947
24126
|
}
|
|
23948
|
-
} catch (
|
|
23949
|
-
|
|
23950
|
-
error:
|
|
24127
|
+
} catch (e_9_1) {
|
|
24128
|
+
e_9 = {
|
|
24129
|
+
error: e_9_1
|
|
23951
24130
|
};
|
|
23952
24131
|
} finally {
|
|
23953
24132
|
try {
|
|
23954
24133
|
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
23955
24134
|
} finally {
|
|
23956
|
-
if (
|
|
24135
|
+
if (e_9) throw e_9.error;
|
|
23957
24136
|
}
|
|
23958
24137
|
}
|
|
23959
24138
|
}
|
|
23960
24139
|
}
|
|
23961
|
-
} catch (
|
|
23962
|
-
|
|
23963
|
-
error:
|
|
24140
|
+
} catch (e_8_1) {
|
|
24141
|
+
e_8 = {
|
|
24142
|
+
error: e_8_1
|
|
23964
24143
|
};
|
|
23965
24144
|
} finally {
|
|
23966
24145
|
try {
|
|
23967
24146
|
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
23968
24147
|
} finally {
|
|
23969
|
-
if (
|
|
24148
|
+
if (e_8) throw e_8.error;
|
|
23970
24149
|
}
|
|
23971
24150
|
}
|
|
23972
24151
|
}
|
|
@@ -24061,7 +24240,7 @@ function () {
|
|
|
24061
24240
|
};
|
|
24062
24241
|
|
|
24063
24242
|
StateNode.prototype.formatTransitions = function () {
|
|
24064
|
-
var
|
|
24243
|
+
var e_10, _a;
|
|
24065
24244
|
|
|
24066
24245
|
var _this = this;
|
|
24067
24246
|
|
|
@@ -24125,15 +24304,15 @@ function () {
|
|
|
24125
24304
|
var delayedTransition = delayedTransitions_1_1.value;
|
|
24126
24305
|
formattedTransitions.push(delayedTransition);
|
|
24127
24306
|
}
|
|
24128
|
-
} catch (
|
|
24129
|
-
|
|
24130
|
-
error:
|
|
24307
|
+
} catch (e_10_1) {
|
|
24308
|
+
e_10 = {
|
|
24309
|
+
error: e_10_1
|
|
24131
24310
|
};
|
|
24132
24311
|
} finally {
|
|
24133
24312
|
try {
|
|
24134
24313
|
if (delayedTransitions_1_1 && !delayedTransitions_1_1.done && (_a = delayedTransitions_1.return)) _a.call(delayedTransitions_1);
|
|
24135
24314
|
} finally {
|
|
24136
|
-
if (
|
|
24315
|
+
if (e_10) throw e_10.error;
|
|
24137
24316
|
}
|
|
24138
24317
|
}
|
|
24139
24318
|
|
|
@@ -24145,7 +24324,7 @@ function () {
|
|
|
24145
24324
|
|
|
24146
24325
|
var warned = false;
|
|
24147
24326
|
function createMachine(config, options) {
|
|
24148
|
-
if (!IS_PRODUCTION$1 && !
|
|
24327
|
+
if (!IS_PRODUCTION$1 && !('predictableActionArguments' in config) && !warned) {
|
|
24149
24328
|
warned = true;
|
|
24150
24329
|
console.warn('It is highly recommended to set `predictableActionArguments` to `true` when using `createMachine`. https://xstate.js.org/docs/guides/actions.html');
|
|
24151
24330
|
}
|
|
@@ -38920,6 +39099,8 @@ environment$1.IS_PRODUCTION = IS_PRODUCTION;
|
|
|
38920
39099
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
38921
39100
|
|
|
38922
39101
|
var _tslib = _tslib$1;
|
|
39102
|
+
var types = types$2;
|
|
39103
|
+
var actionTypes = actionTypes$1;
|
|
38923
39104
|
var constants$1 = constants;
|
|
38924
39105
|
var environment = environment$1;
|
|
38925
39106
|
|
|
@@ -39539,6 +39720,9 @@ environment$1.IS_PRODUCTION = IS_PRODUCTION;
|
|
|
39539
39720
|
function createInvokeId(stateNodeId, index) {
|
|
39540
39721
|
return "".concat(stateNodeId, ":invocation[").concat(index, "]");
|
|
39541
39722
|
}
|
|
39723
|
+
function isRaisableAction(action) {
|
|
39724
|
+
return (action.type === actionTypes.raise || action.type === actionTypes.send && action.to === types.SpecialTargets.Internal) && typeof action.delay !== 'number';
|
|
39725
|
+
}
|
|
39542
39726
|
|
|
39543
39727
|
exports.createInvokeId = createInvokeId;
|
|
39544
39728
|
exports.evaluateGuard = evaluateGuard;
|
|
@@ -39554,6 +39738,7 @@ environment$1.IS_PRODUCTION = IS_PRODUCTION;
|
|
|
39554
39738
|
exports.isMachine = isMachine;
|
|
39555
39739
|
exports.isObservable = isObservable;
|
|
39556
39740
|
exports.isPromiseLike = isPromiseLike;
|
|
39741
|
+
exports.isRaisableAction = isRaisableAction;
|
|
39557
39742
|
exports.isStateLike = isStateLike;
|
|
39558
39743
|
exports.isString = isString;
|
|
39559
39744
|
exports.keys = keys;
|
|
@@ -39669,28 +39854,40 @@ function toActivityDefinition(action) {
|
|
|
39669
39854
|
* @param eventType The event to raise.
|
|
39670
39855
|
*/
|
|
39671
39856
|
|
|
39672
|
-
function raise(event) {
|
|
39673
|
-
if (!utils.isString(event)) {
|
|
39674
|
-
return send(event, {
|
|
39675
|
-
to: types.SpecialTargets.Internal
|
|
39676
|
-
});
|
|
39677
|
-
}
|
|
39678
|
-
|
|
39857
|
+
function raise(event, options) {
|
|
39679
39858
|
return {
|
|
39680
39859
|
type: actionTypes.raise,
|
|
39681
|
-
event: event
|
|
39860
|
+
event: typeof event === 'function' ? event : utils.toEventObject(event),
|
|
39861
|
+
delay: options ? options.delay : undefined,
|
|
39862
|
+
id: options === null || options === void 0 ? void 0 : options.id
|
|
39682
39863
|
};
|
|
39683
39864
|
}
|
|
39684
|
-
function resolveRaise(action) {
|
|
39685
|
-
|
|
39686
|
-
|
|
39687
|
-
_event: utils.toSCXMLEvent(action.event)
|
|
39865
|
+
function resolveRaise(action, ctx, _event, delaysMap) {
|
|
39866
|
+
var meta = {
|
|
39867
|
+
_event: _event
|
|
39688
39868
|
};
|
|
39869
|
+
var resolvedEvent = utils.toSCXMLEvent(utils.isFunction(action.event) ? action.event(ctx, _event.data, meta) : action.event);
|
|
39870
|
+
var resolvedDelay;
|
|
39871
|
+
|
|
39872
|
+
if (utils.isString(action.delay)) {
|
|
39873
|
+
var configDelay = delaysMap && delaysMap[action.delay];
|
|
39874
|
+
resolvedDelay = utils.isFunction(configDelay) ? configDelay(ctx, _event.data, meta) : configDelay;
|
|
39875
|
+
} else {
|
|
39876
|
+
resolvedDelay = utils.isFunction(action.delay) ? action.delay(ctx, _event.data, meta) : action.delay;
|
|
39877
|
+
}
|
|
39878
|
+
|
|
39879
|
+
return _tslib.__assign(_tslib.__assign({}, action), {
|
|
39880
|
+
type: actionTypes.raise,
|
|
39881
|
+
_event: resolvedEvent,
|
|
39882
|
+
delay: resolvedDelay
|
|
39883
|
+
});
|
|
39689
39884
|
}
|
|
39690
39885
|
/**
|
|
39691
39886
|
* Sends an event. This returns an action that will be read by an interpreter to
|
|
39692
39887
|
* send the event in the next step, after the current step is finished executing.
|
|
39693
39888
|
*
|
|
39889
|
+
* @deprecated Use the `sendTo(...)` action creator instead.
|
|
39890
|
+
*
|
|
39694
39891
|
* @param event The event to send.
|
|
39695
39892
|
* @param options Options to pass into the send event:
|
|
39696
39893
|
* - `id` - The unique send event identifier (used with `cancel()`).
|
|
@@ -39704,6 +39901,8 @@ function send(event, options) {
|
|
|
39704
39901
|
type: actionTypes.send,
|
|
39705
39902
|
event: utils.isFunction(event) ? event : utils.toEventObject(event),
|
|
39706
39903
|
delay: options ? options.delay : undefined,
|
|
39904
|
+
// TODO: don't auto-generate IDs here like that
|
|
39905
|
+
// there is too big chance of the ID collision
|
|
39707
39906
|
id: options && options.id !== undefined ? options.id : utils.isFunction(event) ? event.name : utils.getEventType(event)
|
|
39708
39907
|
};
|
|
39709
39908
|
}
|
|
@@ -40014,39 +40213,83 @@ function choose(conds) {
|
|
|
40014
40213
|
conds: conds
|
|
40015
40214
|
};
|
|
40016
40215
|
}
|
|
40017
|
-
|
|
40216
|
+
|
|
40217
|
+
var pluckAssigns = function (actionBlocks) {
|
|
40218
|
+
var e_1, _a;
|
|
40219
|
+
|
|
40220
|
+
var assignActions = [];
|
|
40221
|
+
|
|
40222
|
+
try {
|
|
40223
|
+
for (var actionBlocks_1 = _tslib.__values(actionBlocks), actionBlocks_1_1 = actionBlocks_1.next(); !actionBlocks_1_1.done; actionBlocks_1_1 = actionBlocks_1.next()) {
|
|
40224
|
+
var block = actionBlocks_1_1.value;
|
|
40225
|
+
var i = 0;
|
|
40226
|
+
|
|
40227
|
+
while (i < block.actions.length) {
|
|
40228
|
+
if (block.actions[i].type === actionTypes.assign) {
|
|
40229
|
+
assignActions.push(block.actions[i]);
|
|
40230
|
+
block.actions.splice(i, 1);
|
|
40231
|
+
continue;
|
|
40232
|
+
}
|
|
40233
|
+
|
|
40234
|
+
i++;
|
|
40235
|
+
}
|
|
40236
|
+
}
|
|
40237
|
+
} catch (e_1_1) {
|
|
40238
|
+
e_1 = {
|
|
40239
|
+
error: e_1_1
|
|
40240
|
+
};
|
|
40241
|
+
} finally {
|
|
40242
|
+
try {
|
|
40243
|
+
if (actionBlocks_1_1 && !actionBlocks_1_1.done && (_a = actionBlocks_1.return)) _a.call(actionBlocks_1);
|
|
40244
|
+
} finally {
|
|
40245
|
+
if (e_1) throw e_1.error;
|
|
40246
|
+
}
|
|
40247
|
+
}
|
|
40248
|
+
|
|
40249
|
+
return assignActions;
|
|
40250
|
+
};
|
|
40251
|
+
|
|
40252
|
+
function resolveActions(machine, currentState, currentContext, _event, actionBlocks, predictableExec, preserveActionOrder) {
|
|
40018
40253
|
if (preserveActionOrder === void 0) {
|
|
40019
40254
|
preserveActionOrder = false;
|
|
40020
40255
|
}
|
|
40021
40256
|
|
|
40022
|
-
var
|
|
40023
|
-
return action.type === actionTypes.assign;
|
|
40024
|
-
}), 2),
|
|
40025
|
-
assignActions = _a[0],
|
|
40026
|
-
otherActions = _a[1];
|
|
40027
|
-
|
|
40257
|
+
var assignActions = preserveActionOrder ? [] : pluckAssigns(actionBlocks);
|
|
40028
40258
|
var updatedContext = assignActions.length ? utils.updateContext(currentContext, _event, assignActions, currentState) : currentContext;
|
|
40029
40259
|
var preservedContexts = preserveActionOrder ? [currentContext] : undefined;
|
|
40030
|
-
var
|
|
40260
|
+
var deferredToBlockEnd = [];
|
|
40261
|
+
|
|
40262
|
+
function handleAction(blockType, actionObject) {
|
|
40031
40263
|
var _a;
|
|
40032
40264
|
|
|
40033
40265
|
switch (actionObject.type) {
|
|
40034
40266
|
case actionTypes.raise:
|
|
40035
40267
|
{
|
|
40036
|
-
|
|
40268
|
+
var raisedAction = resolveRaise(actionObject, updatedContext, _event, machine.options.delays);
|
|
40269
|
+
|
|
40270
|
+
if (predictableExec && typeof raisedAction.delay === 'number') {
|
|
40271
|
+
predictableExec(raisedAction, updatedContext, _event);
|
|
40272
|
+
}
|
|
40273
|
+
|
|
40274
|
+
return raisedAction;
|
|
40037
40275
|
}
|
|
40038
40276
|
|
|
40039
40277
|
case actionTypes.send:
|
|
40040
40278
|
var sendAction = resolveSend(actionObject, updatedContext, _event, machine.options.delays); // TODO: fix ActionTypes.Init
|
|
40041
40279
|
|
|
40042
40280
|
if (!environment.IS_PRODUCTION) {
|
|
40043
|
-
// warn after resolving as we can create better contextual message here
|
|
40044
|
-
|
|
40045
|
-
|
|
40281
|
+
var configuredDelay = actionObject.delay; // warn after resolving as we can create better contextual message here
|
|
40282
|
+
|
|
40283
|
+
utils.warn(!utils.isString(configuredDelay) || typeof sendAction.delay === 'number', // tslint:disable-next-line:max-line-length
|
|
40284
|
+
"No delay reference for delay expression '".concat(configuredDelay, "' was found on machine '").concat(machine.id, "'"));
|
|
40046
40285
|
}
|
|
40047
40286
|
|
|
40048
|
-
if (sendAction.to !== types.SpecialTargets.Internal) {
|
|
40049
|
-
|
|
40287
|
+
if (predictableExec && sendAction.to !== types.SpecialTargets.Internal) {
|
|
40288
|
+
if (blockType === 'entry') {
|
|
40289
|
+
deferredToBlockEnd.push(sendAction);
|
|
40290
|
+
} else {
|
|
40291
|
+
predictableExec(sendAction, updatedContext, _event);
|
|
40292
|
+
}
|
|
40050
40293
|
}
|
|
40051
40294
|
|
|
40052
40295
|
return sendAction;
|
|
@@ -40070,7 +40313,10 @@ function resolveActions(machine, currentState, currentContext, _event, actions,
|
|
|
40070
40313
|
return [];
|
|
40071
40314
|
}
|
|
40072
40315
|
|
|
40073
|
-
var _b = _tslib.__read(resolveActions(machine, currentState, updatedContext, _event,
|
|
40316
|
+
var _b = _tslib.__read(resolveActions(machine, currentState, updatedContext, _event, [{
|
|
40317
|
+
type: blockType,
|
|
40318
|
+
actions: toActionObjects(utils.toArray(matchedActions), machine.options.actions)
|
|
40319
|
+
}], predictableExec, preserveActionOrder), 2),
|
|
40074
40320
|
resolvedActionsFromChoose = _b[0],
|
|
40075
40321
|
resolvedContextFromChoose = _b[1];
|
|
40076
40322
|
|
|
@@ -40087,7 +40333,10 @@ function resolveActions(machine, currentState, currentContext, _event, actions,
|
|
|
40087
40333
|
return [];
|
|
40088
40334
|
}
|
|
40089
40335
|
|
|
40090
|
-
var _c = _tslib.__read(resolveActions(machine, currentState, updatedContext, _event,
|
|
40336
|
+
var _c = _tslib.__read(resolveActions(machine, currentState, updatedContext, _event, [{
|
|
40337
|
+
type: blockType,
|
|
40338
|
+
actions: toActionObjects(utils.toArray(matchedActions), machine.options.actions)
|
|
40339
|
+
}], predictableExec, preserveActionOrder), 2),
|
|
40091
40340
|
resolvedActionsFromPure = _c[0],
|
|
40092
40341
|
resolvedContext = _c[1];
|
|
40093
40342
|
|
|
@@ -40099,7 +40348,7 @@ function resolveActions(machine, currentState, currentContext, _event, actions,
|
|
|
40099
40348
|
case actionTypes.stop:
|
|
40100
40349
|
{
|
|
40101
40350
|
var resolved = resolveStop(actionObject, updatedContext, _event);
|
|
40102
|
-
predictableExec === null || predictableExec === void 0 ? void 0 : predictableExec(resolved,
|
|
40351
|
+
predictableExec === null || predictableExec === void 0 ? void 0 : predictableExec(resolved, currentContext, _event);
|
|
40103
40352
|
return resolved;
|
|
40104
40353
|
}
|
|
40105
40354
|
|
|
@@ -40118,7 +40367,8 @@ function resolveActions(machine, currentState, currentContext, _event, actions,
|
|
|
40118
40367
|
predictableExec(resolvedActionObject, updatedContext, _event);
|
|
40119
40368
|
} else if (exec_1 && preservedContexts) {
|
|
40120
40369
|
var contextIndex_1 = preservedContexts.length - 1;
|
|
40121
|
-
|
|
40370
|
+
|
|
40371
|
+
var wrapped = _tslib.__assign(_tslib.__assign({}, resolvedActionObject), {
|
|
40122
40372
|
exec: function (_ctx) {
|
|
40123
40373
|
var args = [];
|
|
40124
40374
|
|
|
@@ -40129,13 +40379,48 @@ function resolveActions(machine, currentState, currentContext, _event, actions,
|
|
|
40129
40379
|
exec_1.apply(void 0, _tslib.__spreadArray([preservedContexts[contextIndex_1]], _tslib.__read(args), false));
|
|
40130
40380
|
}
|
|
40131
40381
|
});
|
|
40382
|
+
|
|
40383
|
+
resolvedActionObject = wrapped;
|
|
40132
40384
|
}
|
|
40133
40385
|
|
|
40134
40386
|
return resolvedActionObject;
|
|
40135
40387
|
}
|
|
40136
|
-
}
|
|
40137
|
-
|
|
40138
|
-
|
|
40388
|
+
}
|
|
40389
|
+
|
|
40390
|
+
function processBlock(block) {
|
|
40391
|
+
var e_2, _a;
|
|
40392
|
+
|
|
40393
|
+
var resolvedActions = [];
|
|
40394
|
+
|
|
40395
|
+
try {
|
|
40396
|
+
for (var _b = _tslib.__values(block.actions), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
40397
|
+
var action = _c.value;
|
|
40398
|
+
var resolved = handleAction(block.type, action);
|
|
40399
|
+
|
|
40400
|
+
if (resolved) {
|
|
40401
|
+
resolvedActions = resolvedActions.concat(resolved);
|
|
40402
|
+
}
|
|
40403
|
+
}
|
|
40404
|
+
} catch (e_2_1) {
|
|
40405
|
+
e_2 = {
|
|
40406
|
+
error: e_2_1
|
|
40407
|
+
};
|
|
40408
|
+
} finally {
|
|
40409
|
+
try {
|
|
40410
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
40411
|
+
} finally {
|
|
40412
|
+
if (e_2) throw e_2.error;
|
|
40413
|
+
}
|
|
40414
|
+
}
|
|
40415
|
+
|
|
40416
|
+
deferredToBlockEnd.forEach(function (action) {
|
|
40417
|
+
predictableExec(action, updatedContext, _event);
|
|
40418
|
+
});
|
|
40419
|
+
deferredToBlockEnd.length = 0;
|
|
40420
|
+
return resolvedActions;
|
|
40421
|
+
}
|
|
40422
|
+
|
|
40423
|
+
var resolvedActions = utils.flatten(actionBlocks.map(processBlock));
|
|
40139
40424
|
return [resolvedActions, updatedContext];
|
|
40140
40425
|
}
|
|
40141
40426
|
|