mage-engine 3.21.0 → 3.21.2
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/.prettierrc.js +20 -0
- package/dist/mage.js +370 -16
- package/package.json +1 -1
- package/prettier.config.js +0 -7
package/.prettierrc.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
printWidth: 100,
|
|
5
|
+
trailingComma: "all",
|
|
6
|
+
arrowParens: "avoid",
|
|
7
|
+
semi: true,
|
|
8
|
+
tabWidth: 4,
|
|
9
|
+
|
|
10
|
+
overrides: [
|
|
11
|
+
{
|
|
12
|
+
files: ["*.md"],
|
|
13
|
+
options: { printWidth: 120 },
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
files: [".toolsharerc"],
|
|
17
|
+
options: { parser: "yaml" },
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
};
|
package/dist/mage.js
CHANGED
|
@@ -878,6 +878,27 @@ function updateContext(context, _event, assignActions, state) {
|
|
|
878
878
|
|
|
879
879
|
var warn = function () {};
|
|
880
880
|
|
|
881
|
+
if (!IS_PRODUCTION) {
|
|
882
|
+
warn = function (condition, message) {
|
|
883
|
+
var error = condition instanceof Error ? condition : undefined;
|
|
884
|
+
|
|
885
|
+
if (!error && condition) {
|
|
886
|
+
return;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
if (console !== undefined) {
|
|
890
|
+
var args = ["Warning: " + message];
|
|
891
|
+
|
|
892
|
+
if (error) {
|
|
893
|
+
args.push(error);
|
|
894
|
+
} // tslint:disable-next-line:no-console
|
|
895
|
+
|
|
896
|
+
|
|
897
|
+
console.warn.apply(console, args);
|
|
898
|
+
}
|
|
899
|
+
};
|
|
900
|
+
}
|
|
901
|
+
|
|
881
902
|
function isArray$4(value) {
|
|
882
903
|
return Array.isArray(value);
|
|
883
904
|
} // tslint:disable-next-line:ban-types
|
|
@@ -948,6 +969,16 @@ function isMachine(value) {
|
|
|
948
969
|
}
|
|
949
970
|
}
|
|
950
971
|
|
|
972
|
+
var uniqueId =
|
|
973
|
+
/*#__PURE__*/
|
|
974
|
+
function () {
|
|
975
|
+
var currentId = 0;
|
|
976
|
+
return function () {
|
|
977
|
+
currentId++;
|
|
978
|
+
return currentId.toString(16);
|
|
979
|
+
};
|
|
980
|
+
}();
|
|
981
|
+
|
|
951
982
|
function toEventObject(event, payload // id?: TEvent['type']
|
|
952
983
|
) {
|
|
953
984
|
if (isString$4(event) || typeof event === 'number') {
|
|
@@ -996,6 +1027,47 @@ function normalizeTarget(target) {
|
|
|
996
1027
|
}
|
|
997
1028
|
|
|
998
1029
|
return toArray$1(target);
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
function reportUnhandledExceptionOnInvocation(originalError, currentError, id) {
|
|
1033
|
+
if (!IS_PRODUCTION) {
|
|
1034
|
+
var originalStackTrace = originalError.stack ? " Stacktrace was '" + originalError.stack + "'" : '';
|
|
1035
|
+
|
|
1036
|
+
if (originalError === currentError) {
|
|
1037
|
+
// tslint:disable-next-line:no-console
|
|
1038
|
+
console.error("Missing onError handler for invocation '" + id + "', error was '" + originalError + "'." + originalStackTrace);
|
|
1039
|
+
} else {
|
|
1040
|
+
var stackTrace = currentError.stack ? " Stacktrace was '" + currentError.stack + "'" : ''; // tslint:disable-next-line:no-console
|
|
1041
|
+
|
|
1042
|
+
console.error("Missing onError handler and/or unhandled exception/promise rejection for invocation '" + id + "'. " + ("Original error: '" + originalError + "'. " + originalStackTrace + " Current error is '" + currentError + "'." + stackTrace));
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
}function mapState(stateMap, stateId) {
|
|
1046
|
+
var e_1, _a;
|
|
1047
|
+
|
|
1048
|
+
var foundStateId;
|
|
1049
|
+
|
|
1050
|
+
try {
|
|
1051
|
+
for (var _b = __values(keys(stateMap)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1052
|
+
var mappedStateId = _c.value;
|
|
1053
|
+
|
|
1054
|
+
if (matchesState(mappedStateId, stateId) && (!foundStateId || stateId.length > foundStateId.length)) {
|
|
1055
|
+
foundStateId = mappedStateId;
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
} catch (e_1_1) {
|
|
1059
|
+
e_1 = {
|
|
1060
|
+
error: e_1_1
|
|
1061
|
+
};
|
|
1062
|
+
} finally {
|
|
1063
|
+
try {
|
|
1064
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1065
|
+
} finally {
|
|
1066
|
+
if (e_1) throw e_1.error;
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
return stateMap[foundStateId];
|
|
999
1071
|
}var ActionTypes$1;
|
|
1000
1072
|
|
|
1001
1073
|
(function (ActionTypes) {
|
|
@@ -1031,10 +1103,10 @@ var raise$1 = ActionTypes$1.Raise;
|
|
|
1031
1103
|
var send$1 = ActionTypes$1.Send;
|
|
1032
1104
|
var cancel$1 = ActionTypes$1.Cancel;
|
|
1033
1105
|
var nullEvent = ActionTypes$1.NullEvent;
|
|
1034
|
-
var assign = ActionTypes$1.Assign;
|
|
1106
|
+
var assign$1 = ActionTypes$1.Assign;
|
|
1035
1107
|
ActionTypes$1.After;
|
|
1036
1108
|
ActionTypes$1.DoneState;
|
|
1037
|
-
var log = ActionTypes$1.Log;
|
|
1109
|
+
var log$1 = ActionTypes$1.Log;
|
|
1038
1110
|
var init = ActionTypes$1.Init;
|
|
1039
1111
|
var invoke = ActionTypes$1.Invoke;
|
|
1040
1112
|
ActionTypes$1.ErrorExecution;
|
|
@@ -1196,6 +1268,71 @@ function resolveSend(action, ctx, _event, delaysMap) {
|
|
|
1196
1268
|
delay: resolvedDelay
|
|
1197
1269
|
});
|
|
1198
1270
|
}
|
|
1271
|
+
/**
|
|
1272
|
+
* Sends an event to this machine's parent.
|
|
1273
|
+
*
|
|
1274
|
+
* @param event The event to send to the parent machine.
|
|
1275
|
+
* @param options Options to pass into the send event.
|
|
1276
|
+
*/
|
|
1277
|
+
|
|
1278
|
+
|
|
1279
|
+
function sendParent(event, options) {
|
|
1280
|
+
return send(event, __assign(__assign({}, options), {
|
|
1281
|
+
to: SpecialTargets.Parent
|
|
1282
|
+
}));
|
|
1283
|
+
}
|
|
1284
|
+
/**
|
|
1285
|
+
* Sends an update event to this machine's parent.
|
|
1286
|
+
*/
|
|
1287
|
+
|
|
1288
|
+
|
|
1289
|
+
function sendUpdate() {
|
|
1290
|
+
return sendParent(update);
|
|
1291
|
+
}
|
|
1292
|
+
/**
|
|
1293
|
+
* Sends an event back to the sender of the original event.
|
|
1294
|
+
*
|
|
1295
|
+
* @param event The event to send back to the sender
|
|
1296
|
+
* @param options Options to pass into the send event
|
|
1297
|
+
*/
|
|
1298
|
+
|
|
1299
|
+
|
|
1300
|
+
function respond(event, options) {
|
|
1301
|
+
return send(event, __assign(__assign({}, options), {
|
|
1302
|
+
to: function (_, __, _a) {
|
|
1303
|
+
var _event = _a._event;
|
|
1304
|
+
return _event.origin; // TODO: handle when _event.origin is undefined
|
|
1305
|
+
}
|
|
1306
|
+
}));
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
var defaultLogExpr = function (context, event) {
|
|
1310
|
+
return {
|
|
1311
|
+
context: context,
|
|
1312
|
+
event: event
|
|
1313
|
+
};
|
|
1314
|
+
};
|
|
1315
|
+
/**
|
|
1316
|
+
*
|
|
1317
|
+
* @param expr The expression function to evaluate which will be logged.
|
|
1318
|
+
* Takes in 2 arguments:
|
|
1319
|
+
* - `ctx` - the current state context
|
|
1320
|
+
* - `event` - the event that caused this action to be executed.
|
|
1321
|
+
* @param label The label to give to the logged expression.
|
|
1322
|
+
*/
|
|
1323
|
+
|
|
1324
|
+
|
|
1325
|
+
function log(expr, label) {
|
|
1326
|
+
if (expr === void 0) {
|
|
1327
|
+
expr = defaultLogExpr;
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
return {
|
|
1331
|
+
type: log$1,
|
|
1332
|
+
label: label,
|
|
1333
|
+
expr: expr
|
|
1334
|
+
};
|
|
1335
|
+
}
|
|
1199
1336
|
|
|
1200
1337
|
var resolveLog = function (action, ctx, _event) {
|
|
1201
1338
|
return __assign(__assign({}, action), {
|
|
@@ -1249,6 +1386,19 @@ function stop(activity) {
|
|
|
1249
1386
|
exec: undefined
|
|
1250
1387
|
};
|
|
1251
1388
|
}
|
|
1389
|
+
/**
|
|
1390
|
+
* Updates the current context of the machine.
|
|
1391
|
+
*
|
|
1392
|
+
* @param assignment An object that represents the partial context to update.
|
|
1393
|
+
*/
|
|
1394
|
+
|
|
1395
|
+
|
|
1396
|
+
var assign = function (assignment) {
|
|
1397
|
+
return {
|
|
1398
|
+
type: assign$1,
|
|
1399
|
+
assignment: assignment
|
|
1400
|
+
};
|
|
1401
|
+
};
|
|
1252
1402
|
/**
|
|
1253
1403
|
* Returns an event type that represents an implicit event that
|
|
1254
1404
|
* is sent after the specified `delay`.
|
|
@@ -1321,6 +1471,40 @@ function error(id, data) {
|
|
|
1321
1471
|
};
|
|
1322
1472
|
|
|
1323
1473
|
return eventObject;
|
|
1474
|
+
}
|
|
1475
|
+
/**
|
|
1476
|
+
* Forwards (sends) an event to a specified service.
|
|
1477
|
+
*
|
|
1478
|
+
* @param target The target service to forward the event to.
|
|
1479
|
+
* @param options Options to pass into the send action creator.
|
|
1480
|
+
*/
|
|
1481
|
+
|
|
1482
|
+
|
|
1483
|
+
function forwardTo(target, options) {
|
|
1484
|
+
return send(function (_, event) {
|
|
1485
|
+
return event;
|
|
1486
|
+
}, __assign(__assign({}, options), {
|
|
1487
|
+
to: target
|
|
1488
|
+
}));
|
|
1489
|
+
}
|
|
1490
|
+
/**
|
|
1491
|
+
* Escalates an error by sending it as an event to this machine's parent.
|
|
1492
|
+
*
|
|
1493
|
+
* @param errorData The error data to send, or the expression function that
|
|
1494
|
+
* takes in the `context`, `event`, and `meta`, and returns the error data to send.
|
|
1495
|
+
* @param options Options to pass into the send action creator.
|
|
1496
|
+
*/
|
|
1497
|
+
|
|
1498
|
+
|
|
1499
|
+
function escalate(errorData, options) {
|
|
1500
|
+
return sendParent(function (context, event, meta) {
|
|
1501
|
+
return {
|
|
1502
|
+
type: error$1,
|
|
1503
|
+
data: isFunction$4(errorData) ? errorData(context, event, meta) : errorData
|
|
1504
|
+
};
|
|
1505
|
+
}, __assign(__assign({}, options), {
|
|
1506
|
+
to: SpecialTargets.Parent
|
|
1507
|
+
}));
|
|
1324
1508
|
}var isLeafNode = function (stateNode) {
|
|
1325
1509
|
return stateNode.type === 'atomic' || stateNode.type === 'final';
|
|
1326
1510
|
};
|
|
@@ -1791,7 +1975,7 @@ function () {
|
|
|
1791
1975
|
};
|
|
1792
1976
|
|
|
1793
1977
|
return State;
|
|
1794
|
-
}();function createNullActor(id) {
|
|
1978
|
+
}();function createNullActor$1(id) {
|
|
1795
1979
|
return {
|
|
1796
1980
|
id: id,
|
|
1797
1981
|
send: function () {
|
|
@@ -1820,7 +2004,7 @@ function () {
|
|
|
1820
2004
|
|
|
1821
2005
|
|
|
1822
2006
|
function createInvocableActor(invokeDefinition) {
|
|
1823
|
-
var tempActor = createNullActor(invokeDefinition.id);
|
|
2007
|
+
var tempActor = createNullActor$1(invokeDefinition.id);
|
|
1824
2008
|
tempActor.meta = invokeDefinition;
|
|
1825
2009
|
return tempActor;
|
|
1826
2010
|
}
|
|
@@ -2701,7 +2885,7 @@ function () {
|
|
|
2701
2885
|
}
|
|
2702
2886
|
|
|
2703
2887
|
var _b = __read(partition$1(actions, function (action) {
|
|
2704
|
-
return action.type === assign;
|
|
2888
|
+
return action.type === assign$1;
|
|
2705
2889
|
}), 2),
|
|
2706
2890
|
assignActions = _b[0],
|
|
2707
2891
|
otherActions = _b[1];
|
|
@@ -2723,7 +2907,7 @@ function () {
|
|
|
2723
2907
|
|
|
2724
2908
|
return sendAction;
|
|
2725
2909
|
|
|
2726
|
-
case log:
|
|
2910
|
+
case log$1:
|
|
2727
2911
|
return resolveLog(actionObject, updatedContext, _event);
|
|
2728
2912
|
|
|
2729
2913
|
case pure:
|
|
@@ -3389,7 +3573,16 @@ function () {
|
|
|
3389
3573
|
};
|
|
3390
3574
|
|
|
3391
3575
|
return StateNode;
|
|
3392
|
-
}();function
|
|
3576
|
+
}();function Machine(config, options, initialContext) {
|
|
3577
|
+
if (initialContext === void 0) {
|
|
3578
|
+
initialContext = config.context;
|
|
3579
|
+
}
|
|
3580
|
+
|
|
3581
|
+
var resolvedInitialContext = typeof initialContext === 'function' ? initialContext() : initialContext;
|
|
3582
|
+
return new StateNode(config, options, resolvedInitialContext);
|
|
3583
|
+
}
|
|
3584
|
+
|
|
3585
|
+
function createMachine(config, options) {
|
|
3393
3586
|
var resolvedInitialContext = typeof config.context === 'function' ? config.context() : config.context;
|
|
3394
3587
|
return new StateNode(config, options, resolvedInitialContext);
|
|
3395
3588
|
}var defaultOptions = {
|
|
@@ -3484,7 +3677,27 @@ var registry = {
|
|
|
3484
3677
|
free: function (id) {
|
|
3485
3678
|
children.delete(id);
|
|
3486
3679
|
}
|
|
3487
|
-
};
|
|
3680
|
+
};function getDevTools() {
|
|
3681
|
+
var w = window;
|
|
3682
|
+
|
|
3683
|
+
if (!!w.__xstate__) {
|
|
3684
|
+
return w.__xstate__;
|
|
3685
|
+
}
|
|
3686
|
+
|
|
3687
|
+
return undefined;
|
|
3688
|
+
}
|
|
3689
|
+
|
|
3690
|
+
function registerService(service) {
|
|
3691
|
+
if (IS_PRODUCTION || typeof window === 'undefined') {
|
|
3692
|
+
return;
|
|
3693
|
+
}
|
|
3694
|
+
|
|
3695
|
+
var devTools = getDevTools();
|
|
3696
|
+
|
|
3697
|
+
if (devTools) {
|
|
3698
|
+
devTools.register(service);
|
|
3699
|
+
}
|
|
3700
|
+
}var DEFAULT_SPAWN_OPTIONS = {
|
|
3488
3701
|
sync: false,
|
|
3489
3702
|
autoForward: false
|
|
3490
3703
|
};
|
|
@@ -3656,6 +3869,9 @@ function () {
|
|
|
3656
3869
|
});
|
|
3657
3870
|
Object.defineProperty(Interpreter.prototype, "state", {
|
|
3658
3871
|
get: function () {
|
|
3872
|
+
if (!IS_PRODUCTION) {
|
|
3873
|
+
warn(this._status !== InterpreterStatus.NotStarted, "Attempted to read state from uninitialized service '" + this.id + "'. Make sure the service is started first.");
|
|
3874
|
+
}
|
|
3659
3875
|
|
|
3660
3876
|
return this._state;
|
|
3661
3877
|
},
|
|
@@ -4059,7 +4275,12 @@ function () {
|
|
|
4059
4275
|
Interpreter.prototype.batch = function (events) {
|
|
4060
4276
|
var _this = this;
|
|
4061
4277
|
|
|
4062
|
-
if (this._status === InterpreterStatus.NotStarted && this.options.deferEvents)
|
|
4278
|
+
if (this._status === InterpreterStatus.NotStarted && this.options.deferEvents) {
|
|
4279
|
+
// tslint:disable-next-line:no-console
|
|
4280
|
+
if (!IS_PRODUCTION) {
|
|
4281
|
+
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));
|
|
4282
|
+
}
|
|
4283
|
+
} else if (this._status !== InterpreterStatus.Running) {
|
|
4063
4284
|
throw new Error( // tslint:disable-next-line:max-line-length
|
|
4064
4285
|
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.");
|
|
4065
4286
|
}
|
|
@@ -4251,9 +4472,18 @@ function () {
|
|
|
4251
4472
|
var id = activity.id,
|
|
4252
4473
|
data = activity.data;
|
|
4253
4474
|
|
|
4475
|
+
if (!IS_PRODUCTION) {
|
|
4476
|
+
warn(!('forward' in activity), // tslint:disable-next-line:max-line-length
|
|
4477
|
+
"`forward` property is deprecated (found in invocation of '" + activity.src + "' in in machine '" + this.machine.id + "'). " + "Please use `autoForward` instead.");
|
|
4478
|
+
}
|
|
4479
|
+
|
|
4254
4480
|
var autoForward = 'autoForward' in activity ? activity.autoForward : !!activity.forward;
|
|
4255
4481
|
|
|
4256
4482
|
if (!serviceCreator) {
|
|
4483
|
+
// tslint:disable-next-line:no-console
|
|
4484
|
+
if (!IS_PRODUCTION) {
|
|
4485
|
+
warn(false, "No service found for invocation '" + activity.src + "' in machine '" + this.machine.id + "'.");
|
|
4486
|
+
}
|
|
4257
4487
|
|
|
4258
4488
|
return;
|
|
4259
4489
|
}
|
|
@@ -4286,7 +4516,7 @@ function () {
|
|
|
4286
4516
|
break;
|
|
4287
4517
|
}
|
|
4288
4518
|
|
|
4289
|
-
case log:
|
|
4519
|
+
case log$1:
|
|
4290
4520
|
var label = action.label,
|
|
4291
4521
|
value = action.value;
|
|
4292
4522
|
|
|
@@ -4296,6 +4526,13 @@ function () {
|
|
|
4296
4526
|
this.logger(value);
|
|
4297
4527
|
}
|
|
4298
4528
|
|
|
4529
|
+
break;
|
|
4530
|
+
|
|
4531
|
+
default:
|
|
4532
|
+
if (!IS_PRODUCTION) {
|
|
4533
|
+
warn(false, "No implementation found for action type '" + action.type + "'");
|
|
4534
|
+
}
|
|
4535
|
+
|
|
4299
4536
|
break;
|
|
4300
4537
|
}
|
|
4301
4538
|
|
|
@@ -4394,6 +4631,7 @@ function () {
|
|
|
4394
4631
|
origin: id
|
|
4395
4632
|
}));
|
|
4396
4633
|
} catch (error) {
|
|
4634
|
+
reportUnhandledExceptionOnInvocation(errorData, error, id);
|
|
4397
4635
|
|
|
4398
4636
|
if (_this.devTools) {
|
|
4399
4637
|
_this.devTools.send(errorEvent, _this.state);
|
|
@@ -4567,6 +4805,9 @@ function () {
|
|
|
4567
4805
|
var implementation = this.machine.options && this.machine.options.activities ? this.machine.options.activities[activity.type] : undefined;
|
|
4568
4806
|
|
|
4569
4807
|
if (!implementation) {
|
|
4808
|
+
if (!IS_PRODUCTION) {
|
|
4809
|
+
warn(false, "No implementation found for activity '" + activity.type + "'");
|
|
4810
|
+
} // tslint:disable-next-line:no-console
|
|
4570
4811
|
|
|
4571
4812
|
|
|
4572
4813
|
return;
|
|
@@ -4621,6 +4862,9 @@ function () {
|
|
|
4621
4862
|
}), this.machine);
|
|
4622
4863
|
this.devTools.init(this.state);
|
|
4623
4864
|
} // add XState-specific dev tooling hook
|
|
4865
|
+
|
|
4866
|
+
|
|
4867
|
+
registerService(this);
|
|
4624
4868
|
}
|
|
4625
4869
|
};
|
|
4626
4870
|
|
|
@@ -4663,6 +4907,57 @@ function () {
|
|
|
4663
4907
|
Interpreter.interpret = interpret;
|
|
4664
4908
|
return Interpreter;
|
|
4665
4909
|
}();
|
|
4910
|
+
|
|
4911
|
+
var createNullActor = function (name) {
|
|
4912
|
+
if (name === void 0) {
|
|
4913
|
+
name = 'null';
|
|
4914
|
+
}
|
|
4915
|
+
|
|
4916
|
+
return {
|
|
4917
|
+
id: name,
|
|
4918
|
+
send: function () {
|
|
4919
|
+
return void 0;
|
|
4920
|
+
},
|
|
4921
|
+
subscribe: function () {
|
|
4922
|
+
// tslint:disable-next-line:no-empty
|
|
4923
|
+
return {
|
|
4924
|
+
unsubscribe: function () {}
|
|
4925
|
+
};
|
|
4926
|
+
},
|
|
4927
|
+
toJSON: function () {
|
|
4928
|
+
return {
|
|
4929
|
+
id: name
|
|
4930
|
+
};
|
|
4931
|
+
}
|
|
4932
|
+
};
|
|
4933
|
+
};
|
|
4934
|
+
|
|
4935
|
+
var resolveSpawnOptions = function (nameOrOptions) {
|
|
4936
|
+
if (isString$4(nameOrOptions)) {
|
|
4937
|
+
return __assign(__assign({}, DEFAULT_SPAWN_OPTIONS), {
|
|
4938
|
+
name: nameOrOptions
|
|
4939
|
+
});
|
|
4940
|
+
}
|
|
4941
|
+
|
|
4942
|
+
return __assign(__assign(__assign({}, DEFAULT_SPAWN_OPTIONS), {
|
|
4943
|
+
name: uniqueId()
|
|
4944
|
+
}), nameOrOptions);
|
|
4945
|
+
};
|
|
4946
|
+
|
|
4947
|
+
function spawn(entity, nameOrOptions) {
|
|
4948
|
+
var resolvedOptions = resolveSpawnOptions(nameOrOptions);
|
|
4949
|
+
return withServiceScope(undefined, function (service) {
|
|
4950
|
+
if (!IS_PRODUCTION) {
|
|
4951
|
+
warn(!!service, "Attempted to spawn an Actor (ID: \"" + (isMachine(entity) ? entity.id : 'undefined') + "\") outside of a service. This will have no effect.");
|
|
4952
|
+
}
|
|
4953
|
+
|
|
4954
|
+
if (service) {
|
|
4955
|
+
return service.spawn(entity, resolvedOptions.name, resolvedOptions);
|
|
4956
|
+
} else {
|
|
4957
|
+
return createNullActor(resolvedOptions.name);
|
|
4958
|
+
}
|
|
4959
|
+
});
|
|
4960
|
+
}
|
|
4666
4961
|
/**
|
|
4667
4962
|
* Creates a new Interpreter instance for the given machine with the provided options, if any.
|
|
4668
4963
|
*
|
|
@@ -4674,7 +4969,50 @@ function () {
|
|
|
4674
4969
|
function interpret(machine, options) {
|
|
4675
4970
|
var interpreter = new Interpreter(machine, options);
|
|
4676
4971
|
return interpreter;
|
|
4677
|
-
}
|
|
4972
|
+
}function matchState(state, patterns, defaultValue) {
|
|
4973
|
+
var e_1, _a;
|
|
4974
|
+
|
|
4975
|
+
var resolvedState = State.from(state, state instanceof State ? state.context : undefined);
|
|
4976
|
+
|
|
4977
|
+
try {
|
|
4978
|
+
for (var patterns_1 = __values(patterns), patterns_1_1 = patterns_1.next(); !patterns_1_1.done; patterns_1_1 = patterns_1.next()) {
|
|
4979
|
+
var _b = __read(patterns_1_1.value, 2),
|
|
4980
|
+
stateValue = _b[0],
|
|
4981
|
+
getValue = _b[1];
|
|
4982
|
+
|
|
4983
|
+
if (resolvedState.matches(stateValue)) {
|
|
4984
|
+
return getValue(resolvedState);
|
|
4985
|
+
}
|
|
4986
|
+
}
|
|
4987
|
+
} catch (e_1_1) {
|
|
4988
|
+
e_1 = {
|
|
4989
|
+
error: e_1_1
|
|
4990
|
+
};
|
|
4991
|
+
} finally {
|
|
4992
|
+
try {
|
|
4993
|
+
if (patterns_1_1 && !patterns_1_1.done && (_a = patterns_1.return)) _a.call(patterns_1);
|
|
4994
|
+
} finally {
|
|
4995
|
+
if (e_1) throw e_1.error;
|
|
4996
|
+
}
|
|
4997
|
+
}
|
|
4998
|
+
|
|
4999
|
+
return defaultValue(resolvedState);
|
|
5000
|
+
}var actions = {
|
|
5001
|
+
raise: raise,
|
|
5002
|
+
send: send,
|
|
5003
|
+
sendParent: sendParent,
|
|
5004
|
+
sendUpdate: sendUpdate,
|
|
5005
|
+
log: log,
|
|
5006
|
+
cancel: cancel,
|
|
5007
|
+
start: start,
|
|
5008
|
+
stop: stop,
|
|
5009
|
+
assign: assign,
|
|
5010
|
+
after: after,
|
|
5011
|
+
done: done,
|
|
5012
|
+
respond: respond,
|
|
5013
|
+
forwardTo: forwardTo,
|
|
5014
|
+
escalate: escalate
|
|
5015
|
+
};var index$3=/*#__PURE__*/Object.freeze({__proto__:null,actions:actions,matchesState:matchesState,mapState:mapState,get ActionTypes(){return ActionTypes$1},get SpecialTargets(){return SpecialTargets},assign:assign,doneInvoke:doneInvoke,forwardTo:forwardTo,send:send,sendParent:sendParent,sendUpdate:sendUpdate,State:State,StateNode:StateNode,Machine:Machine,createMachine:createMachine,Interpreter:Interpreter,interpret:interpret,spawn:spawn,matchState:matchState});// threejs.org/license
|
|
4678
5016
|
const REVISION = '126';
|
|
4679
5017
|
const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
|
|
4680
5018
|
const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
|
|
@@ -57413,7 +57751,7 @@ function applyMiddleware() {
|
|
|
57413
57751
|
|
|
57414
57752
|
var thunk = createThunkMiddleware();
|
|
57415
57753
|
thunk.withExtraArgument = createThunkMiddleware;var name = "mage-engine";
|
|
57416
|
-
var version$1 = "3.21.
|
|
57754
|
+
var version$1 = "3.21.2";
|
|
57417
57755
|
var description = "A WebGL Javascript Game Engine, built on top of THREE.js and many other libraries.";
|
|
57418
57756
|
var main = "dist/mage.js";
|
|
57419
57757
|
var author$1 = {
|
|
@@ -59703,7 +60041,7 @@ var tweenTo = function tweenTo(origin, target) {
|
|
|
59703
60041
|
var _options$serializable = _options.serializable,
|
|
59704
60042
|
serializable = _options$serializable === void 0 ? true : _options$serializable,
|
|
59705
60043
|
_options$tag = _options.tag,
|
|
59706
|
-
tag = _options$tag === void 0 ?
|
|
60044
|
+
tag = _options$tag === void 0 ? "" : _options$tag,
|
|
59707
60045
|
_options$tags = _options.tags,
|
|
59708
60046
|
tags = _options$tags === void 0 ? [] : _options$tags;
|
|
59709
60047
|
_this = _super.call(this);
|
|
@@ -59952,7 +60290,7 @@ var tweenTo = function tweenTo(origin, target) {
|
|
|
59952
60290
|
var index = this.children.findIndex(function (m) {
|
|
59953
60291
|
return m.equals(element);
|
|
59954
60292
|
});
|
|
59955
|
-
if (index) this.children.splice(index, 1);
|
|
60293
|
+
if (index !== -1) this.children.splice(index, 1);
|
|
59956
60294
|
} else {
|
|
59957
60295
|
this.body.remove(element.getBody());
|
|
59958
60296
|
}
|
|
@@ -60118,6 +60456,7 @@ var tweenTo = function tweenTo(origin, target) {
|
|
|
60118
60456
|
type: ENTITY_EVENTS.DISPOSE
|
|
60119
60457
|
});
|
|
60120
60458
|
this.reset();
|
|
60459
|
+
this.disposed = true;
|
|
60121
60460
|
}
|
|
60122
60461
|
}, {
|
|
60123
60462
|
key: "addStateMachine",
|
|
@@ -60216,6 +60555,21 @@ var tweenTo = function tweenTo(origin, target) {
|
|
|
60216
60555
|
|
|
60217
60556
|
return script;
|
|
60218
60557
|
}
|
|
60558
|
+
}, {
|
|
60559
|
+
key: "removeScript",
|
|
60560
|
+
value: function removeScript(name) {
|
|
60561
|
+
var index = this.scripts.findIndex(function (script) {
|
|
60562
|
+
return script.name === name;
|
|
60563
|
+
});
|
|
60564
|
+
var script = this.scripts[index].script;
|
|
60565
|
+
|
|
60566
|
+
if (script) {
|
|
60567
|
+
script.onDispose();
|
|
60568
|
+
this.scripts.splice(index, 1);
|
|
60569
|
+
} else {
|
|
60570
|
+
console.log(SCRIPT_NOT_FOUND);
|
|
60571
|
+
}
|
|
60572
|
+
}
|
|
60219
60573
|
}, {
|
|
60220
60574
|
key: "enableScripts",
|
|
60221
60575
|
value: function enableScripts() {
|
|
@@ -60317,7 +60671,7 @@ var tweenTo = function tweenTo(origin, target) {
|
|
|
60317
60671
|
value: function getWorldTransform() {
|
|
60318
60672
|
var position = this.getBody().getWorldPosition(new Vector3$1());
|
|
60319
60673
|
var quaternion = this.getBody().getWorldQuaternion(new Quaternion(0, 0, 0, 1));
|
|
60320
|
-
var rotation = new Euler(0, 0, 0,
|
|
60674
|
+
var rotation = new Euler(0, 0, 0, "XYZ").setFromQuaternion(quaternion, "XYZ");
|
|
60321
60675
|
return {
|
|
60322
60676
|
position: position,
|
|
60323
60677
|
rotation: rotation,
|
|
@@ -92743,4 +93097,4 @@ var Shaders$1 = new Shaders();var Shader = function Shader(name, attributes, uni
|
|
|
92743
93097
|
} else {
|
|
92744
93098
|
this.instance = this.shader.instance;
|
|
92745
93099
|
}
|
|
92746
|
-
};var constants = _objectSpread2$1(_objectSpread2$1({}, lib_constants), light_contants);export{AUDIO_RAMPS,AmbientLight,AmbientSound,Atmosphere,Audio$1 as Audio,Axes,BUILTIN,BaseScript,Box,Camera,Color,Cone,Config$1 as Config,Controls$1 as Controls,Cube,CurveLine,Cylinder,DirectionalSound,ENTITY_EVENTS,ENTITY_TYPES,Element$1 as Element,Entity,EventDispatcher,FEATURES,Features$1 as Features,GameRunner$1 as GameRunner,Grid,HemisphereLight,INPUT_EVENTS,Images$1 as Images,Input$1 as Input,Label,LabelComponent,Level,LightLoader$1 as LightLoader,Lights$1 as Lights,Line,MeshLoader$1 as MeshLoader,Mirror,Models$1 as Models,Ocean,PALETTES,PARTICLES,constants$1 as PHYSICS_CONSTANTS,PHYSICS_EVENTS,ParticleEmitter,ParticleEmitterGroup,Particles$1 as Particles,index$1 as Partykals,Physics$1 as Physics,Plane,PointLight,PostProcessing$1 as PostProcessing,Proton,ProtonParticleEmitter,Provider,Router$1 as Router,Scene$1 as Scene,Scripts$1 as Scripts,Shader,Sky,Skybox,Sound,Sphere,SpotLight,Sprite,Stats$1 as Stats,SunLight,three_module as THREE,Universe$1 as Universe,Vector3$1 as Vector3,Water,author,connect,constants,createElement,easing,functions,hitbox as hitboxUtils,index_esm as inferno,math,utils as physicsUtils,index$2 as rxjs,index as store,strings,uuid$1 as uuid,workers};
|
|
93100
|
+
};var constants = _objectSpread2$1(_objectSpread2$1({}, lib_constants), light_contants);export{AUDIO_RAMPS,AmbientLight,AmbientSound,Atmosphere,Audio$1 as Audio,Axes,BUILTIN,BaseScript,Box,Camera,Color,Cone,Config$1 as Config,Controls$1 as Controls,Cube,CurveLine,Cylinder,DirectionalSound,ENTITY_EVENTS,ENTITY_TYPES,Element$1 as Element,Entity,EventDispatcher,FEATURES,Features$1 as Features,GameRunner$1 as GameRunner,Grid,HemisphereLight,INPUT_EVENTS,Images$1 as Images,Input$1 as Input,Label,LabelComponent,Level,LightLoader$1 as LightLoader,Lights$1 as Lights,Line,MeshLoader$1 as MeshLoader,Mirror,Models$1 as Models,Ocean,PALETTES,PARTICLES,constants$1 as PHYSICS_CONSTANTS,PHYSICS_EVENTS,ParticleEmitter,ParticleEmitterGroup,Particles$1 as Particles,index$1 as Partykals,Physics$1 as Physics,Plane,PointLight,PostProcessing$1 as PostProcessing,Proton,ProtonParticleEmitter,Provider,Router$1 as Router,Scene$1 as Scene,Scripts$1 as Scripts,Shader,Sky,Skybox,Sound,Sphere,SpotLight,Sprite,Stats$1 as Stats,SunLight,three_module as THREE,Universe$1 as Universe,Vector3$1 as Vector3,Water,author,connect,constants,createElement,easing,functions,hitbox as hitboxUtils,index_esm as inferno,math,utils as physicsUtils,index$2 as rxjs,index as store,strings,uuid$1 as uuid,workers,index$3 as xstate};
|
package/package.json
CHANGED