@player-ui/reference-assets-plugin 0.12.1-next.0 → 0.13.0-next.0
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/ReferenceAssetsPlugin.native.js +444 -61
- package/dist/ReferenceAssetsPlugin.native.js.map +1 -1
- package/dist/xlr/ActionAsset.json +2 -2
- package/dist/xlr/ChatMessageAsset.json +1 -1
- package/dist/xlr/ChoiceAsset.json +5 -5
- package/dist/xlr/CollectionAsset.json +1 -1
- package/dist/xlr/ImageAsset.json +2 -2
- package/dist/xlr/InfoAsset.json +1 -1
- package/dist/xlr/InputAsset.json +2 -2
- package/dist/xlr/TextAsset.json +4 -4
- package/package.json +5 -5
|
@@ -1276,12 +1276,61 @@ var ReferenceAssetsPlugin = function() {
|
|
|
1276
1276
|
};
|
|
1277
1277
|
}
|
|
1278
1278
|
};
|
|
1279
|
+
var isPromiseLike = function isPromiseLike(value) {
|
|
1280
|
+
var // Check for standard Promise constructor name
|
|
1281
|
+
_value_constructor;
|
|
1282
|
+
return value != null && typeof value === "object" && typeof value.then === "function" && // Additional safeguards against false positives
|
|
1283
|
+
(_instanceof(value, Promise) || ((_value_constructor = value.constructor) === null || _value_constructor === void 0 ? void 0 : _value_constructor.name) === "Promise" || // Verify it has other Promise-like methods to reduce false positives
|
|
1284
|
+
typeof value.catch === "function" && typeof value.finally === "function");
|
|
1285
|
+
};
|
|
1286
|
+
var isAwaitable = function isAwaitable(val) {
|
|
1287
|
+
return isPromiseLike(val) && val[AwaitableSymbol] !== void 0;
|
|
1288
|
+
};
|
|
1289
|
+
var collateAwaitable = function collateAwaitable(promises) {
|
|
1290
|
+
var result = Promise.all(promises);
|
|
1291
|
+
return makeAwaitable(result);
|
|
1292
|
+
};
|
|
1279
1293
|
var isObjectExpression = function isObjectExpression(expr) {
|
|
1280
1294
|
if (isExpressionNode(expr)) {
|
|
1281
1295
|
return false;
|
|
1282
1296
|
}
|
|
1283
1297
|
return typeof expr === "object" && expr !== null && !Array.isArray(expr) && "value" in expr;
|
|
1284
1298
|
};
|
|
1299
|
+
var makePromiseAwareBinaryOp = function makePromiseAwareBinaryOp(operation) {
|
|
1300
|
+
return function(a, b, async) {
|
|
1301
|
+
if (async && (isAwaitable(a) || isAwaitable(b))) {
|
|
1302
|
+
return collateAwaitable([
|
|
1303
|
+
Promise.resolve(a),
|
|
1304
|
+
Promise.resolve(b)
|
|
1305
|
+
]).awaitableThen(function(param) {
|
|
1306
|
+
var _param = _sliced_to_array(param, 2), resolvedA = _param[0], resolvedB = _param[1];
|
|
1307
|
+
return operation(resolvedA, resolvedB);
|
|
1308
|
+
});
|
|
1309
|
+
}
|
|
1310
|
+
return operation(a, b);
|
|
1311
|
+
};
|
|
1312
|
+
};
|
|
1313
|
+
var makePromiseAwareUnaryOp = function makePromiseAwareUnaryOp(operation) {
|
|
1314
|
+
return function(a, async) {
|
|
1315
|
+
if (async && isAwaitable(a)) {
|
|
1316
|
+
return a.awaitableThen(function(resolved) {
|
|
1317
|
+
return operation(resolved);
|
|
1318
|
+
});
|
|
1319
|
+
}
|
|
1320
|
+
return operation(a);
|
|
1321
|
+
};
|
|
1322
|
+
};
|
|
1323
|
+
var handleConditionalBranching = function handleConditionalBranching(testValue, getTrueBranch, getFalseBranch, resolveNode, async) {
|
|
1324
|
+
if (async && isAwaitable(testValue)) {
|
|
1325
|
+
return testValue.awaitableThen(function(resolved) {
|
|
1326
|
+
var branch2 = resolved ? getTrueBranch() : getFalseBranch();
|
|
1327
|
+
var branchResult = resolveNode(branch2);
|
|
1328
|
+
return isAwaitable(branchResult) ? Promise.resolve(branchResult) : branchResult;
|
|
1329
|
+
});
|
|
1330
|
+
}
|
|
1331
|
+
var branch = testValue ? getTrueBranch() : getFalseBranch();
|
|
1332
|
+
return resolveNode(branch);
|
|
1333
|
+
};
|
|
1285
1334
|
var parse2 = function parse2(schema) {
|
|
1286
1335
|
var _loop = function() {
|
|
1287
1336
|
var next = parseQueue.shift();
|
|
@@ -3807,8 +3856,19 @@ var ReferenceAssetsPlugin = function() {
|
|
|
3807
3856
|
},
|
|
3808
3857
|
setDataVal: function() {
|
|
3809
3858
|
return setDataVal;
|
|
3859
|
+
},
|
|
3860
|
+
waitFor: function() {
|
|
3861
|
+
return waitFor;
|
|
3810
3862
|
}
|
|
3811
3863
|
});
|
|
3864
|
+
var AwaitableSymbol = Symbol("Awaitable");
|
|
3865
|
+
function makeAwaitable(promise) {
|
|
3866
|
+
promise[AwaitableSymbol] = AwaitableSymbol;
|
|
3867
|
+
promise.awaitableThen = function(arg) {
|
|
3868
|
+
return makeAwaitable(promise.then(arg));
|
|
3869
|
+
};
|
|
3870
|
+
return promise;
|
|
3871
|
+
}
|
|
3812
3872
|
var setDataVal = function(_context, binding, value) {
|
|
3813
3873
|
_context.model.set([
|
|
3814
3874
|
[
|
|
@@ -3824,8 +3884,19 @@ var ReferenceAssetsPlugin = function() {
|
|
|
3824
3884
|
return _context.model.delete(binding);
|
|
3825
3885
|
};
|
|
3826
3886
|
var conditional = function(ctx, condition, ifTrue, ifFalse) {
|
|
3827
|
-
var
|
|
3828
|
-
if (
|
|
3887
|
+
var testResult = ctx.evaluate(condition);
|
|
3888
|
+
if (isAwaitable(testResult)) {
|
|
3889
|
+
return testResult.awaitableThen(function(resolvedTest) {
|
|
3890
|
+
if (resolvedTest) {
|
|
3891
|
+
return ctx.evaluate(ifTrue);
|
|
3892
|
+
}
|
|
3893
|
+
if (ifFalse) {
|
|
3894
|
+
return ctx.evaluate(ifFalse);
|
|
3895
|
+
}
|
|
3896
|
+
return null;
|
|
3897
|
+
});
|
|
3898
|
+
}
|
|
3899
|
+
if (testResult) {
|
|
3829
3900
|
return ctx.evaluate(ifTrue);
|
|
3830
3901
|
}
|
|
3831
3902
|
if (ifFalse) {
|
|
@@ -3834,12 +3905,15 @@ var ReferenceAssetsPlugin = function() {
|
|
|
3834
3905
|
return null;
|
|
3835
3906
|
};
|
|
3836
3907
|
conditional.resolveParams = false;
|
|
3837
|
-
var
|
|
3838
|
-
return
|
|
3908
|
+
var waitFor = function(ctx, promise) {
|
|
3909
|
+
return makeAwaitable(promise);
|
|
3910
|
+
};
|
|
3911
|
+
var andandOperator = function(ctx, a, b, async) {
|
|
3912
|
+
return LogicalOperators.and(ctx, a, b, async);
|
|
3839
3913
|
};
|
|
3840
3914
|
andandOperator.resolveParams = false;
|
|
3841
|
-
var ororOperator = function(ctx, a, b) {
|
|
3842
|
-
return
|
|
3915
|
+
var ororOperator = function(ctx, a, b, async) {
|
|
3916
|
+
return LogicalOperators.or(ctx, a, b, async);
|
|
3843
3917
|
};
|
|
3844
3918
|
ororOperator.resolveParams = false;
|
|
3845
3919
|
var DEFAULT_BINARY_OPERATORS = {
|
|
@@ -3859,34 +3933,35 @@ var ReferenceAssetsPlugin = function() {
|
|
|
3859
3933
|
"%": function(a, b) {
|
|
3860
3934
|
return a % b;
|
|
3861
3935
|
},
|
|
3936
|
+
// Promise-aware comparison operators
|
|
3862
3937
|
// eslint-disable-next-line
|
|
3863
|
-
"==": function(a, b) {
|
|
3938
|
+
"==": makePromiseAwareBinaryOp(function(a, b) {
|
|
3864
3939
|
return a == b;
|
|
3865
|
-
},
|
|
3940
|
+
}),
|
|
3866
3941
|
// eslint-disable-next-line
|
|
3867
|
-
"!=": function(a, b) {
|
|
3942
|
+
"!=": makePromiseAwareBinaryOp(function(a, b) {
|
|
3868
3943
|
return a != b;
|
|
3869
|
-
},
|
|
3870
|
-
">": function(a, b) {
|
|
3944
|
+
}),
|
|
3945
|
+
">": makePromiseAwareBinaryOp(function(a, b) {
|
|
3871
3946
|
return a > b;
|
|
3872
|
-
},
|
|
3873
|
-
">=": function(a, b) {
|
|
3947
|
+
}),
|
|
3948
|
+
">=": makePromiseAwareBinaryOp(function(a, b) {
|
|
3874
3949
|
return a >= b;
|
|
3875
|
-
},
|
|
3876
|
-
"<": function(a, b) {
|
|
3950
|
+
}),
|
|
3951
|
+
"<": makePromiseAwareBinaryOp(function(a, b) {
|
|
3877
3952
|
return a < b;
|
|
3878
|
-
},
|
|
3879
|
-
"<=": function(a, b) {
|
|
3953
|
+
}),
|
|
3954
|
+
"<=": makePromiseAwareBinaryOp(function(a, b) {
|
|
3880
3955
|
return a <= b;
|
|
3881
|
-
},
|
|
3882
|
-
"
|
|
3883
|
-
"||": ororOperator,
|
|
3884
|
-
"!==": function(a, b) {
|
|
3956
|
+
}),
|
|
3957
|
+
"!==": makePromiseAwareBinaryOp(function(a, b) {
|
|
3885
3958
|
return a !== b;
|
|
3886
|
-
},
|
|
3887
|
-
"===": function(a, b) {
|
|
3959
|
+
}),
|
|
3960
|
+
"===": makePromiseAwareBinaryOp(function(a, b) {
|
|
3888
3961
|
return a === b;
|
|
3889
|
-
},
|
|
3962
|
+
}),
|
|
3963
|
+
"&&": andandOperator,
|
|
3964
|
+
"||": ororOperator,
|
|
3890
3965
|
// eslint-disable-next-line
|
|
3891
3966
|
"|": function(a, b) {
|
|
3892
3967
|
return a | b;
|
|
@@ -3917,8 +3992,73 @@ var ReferenceAssetsPlugin = function() {
|
|
|
3917
3992
|
"+": function(a) {
|
|
3918
3993
|
return Number(a);
|
|
3919
3994
|
},
|
|
3920
|
-
"!": function(a) {
|
|
3995
|
+
"!": makePromiseAwareUnaryOp(function(a) {
|
|
3921
3996
|
return !a;
|
|
3997
|
+
})
|
|
3998
|
+
};
|
|
3999
|
+
var PromiseCollectionHandler = {
|
|
4000
|
+
/**
|
|
4001
|
+
* Handle array with potential Promise elements
|
|
4002
|
+
*/ handleArray: function handleArray(items, async) {
|
|
4003
|
+
if (!async) {
|
|
4004
|
+
return items;
|
|
4005
|
+
}
|
|
4006
|
+
var hasPromises = items.some(function(item) {
|
|
4007
|
+
return isAwaitable(item);
|
|
4008
|
+
});
|
|
4009
|
+
return hasPromises ? collateAwaitable(items) : items;
|
|
4010
|
+
},
|
|
4011
|
+
/**
|
|
4012
|
+
* Handle object with potential Promise keys/values
|
|
4013
|
+
*/ handleObject: function handleObject(attributes, resolveNode, async) {
|
|
4014
|
+
var resolvedAttributes = {};
|
|
4015
|
+
var promises = [];
|
|
4016
|
+
var hasPromises = false;
|
|
4017
|
+
attributes.forEach(function(attr) {
|
|
4018
|
+
var key = resolveNode(attr.key);
|
|
4019
|
+
var value = resolveNode(attr.value);
|
|
4020
|
+
if (async && (isAwaitable(key) || isAwaitable(value))) {
|
|
4021
|
+
hasPromises = true;
|
|
4022
|
+
var keyPromise = Promise.resolve(key);
|
|
4023
|
+
var valuePromise = Promise.resolve(value);
|
|
4024
|
+
promises.push(collateAwaitable([
|
|
4025
|
+
keyPromise,
|
|
4026
|
+
valuePromise
|
|
4027
|
+
]).awaitableThen(function(param) {
|
|
4028
|
+
var _param = _sliced_to_array(param, 2), resolvedKey = _param[0], resolvedValue = _param[1];
|
|
4029
|
+
resolvedAttributes[resolvedKey] = resolvedValue;
|
|
4030
|
+
}));
|
|
4031
|
+
} else {
|
|
4032
|
+
resolvedAttributes[key] = value;
|
|
4033
|
+
}
|
|
4034
|
+
});
|
|
4035
|
+
return hasPromises ? collateAwaitable(promises).awaitableThen(function() {
|
|
4036
|
+
return resolvedAttributes;
|
|
4037
|
+
}) : resolvedAttributes;
|
|
4038
|
+
}
|
|
4039
|
+
};
|
|
4040
|
+
var LogicalOperators = {
|
|
4041
|
+
and: function(ctx, leftNode, rightNode, async) {
|
|
4042
|
+
var leftResult = ctx.evaluate(leftNode);
|
|
4043
|
+
if (async && isAwaitable(leftResult)) {
|
|
4044
|
+
return leftResult.awaitableThen(function(awaitedLeft) {
|
|
4045
|
+
if (!awaitedLeft) return awaitedLeft;
|
|
4046
|
+
var rightResult = ctx.evaluate(rightNode);
|
|
4047
|
+
return isAwaitable(rightResult) ? rightResult : Promise.resolve(rightResult);
|
|
4048
|
+
});
|
|
4049
|
+
}
|
|
4050
|
+
return leftResult && ctx.evaluate(rightNode);
|
|
4051
|
+
},
|
|
4052
|
+
or: function(ctx, leftNode, rightNode, async) {
|
|
4053
|
+
var leftResult = ctx.evaluate(leftNode);
|
|
4054
|
+
if (async && isAwaitable(leftResult)) {
|
|
4055
|
+
return leftResult.awaitableThen(function(awaitedLeft) {
|
|
4056
|
+
if (awaitedLeft) return awaitedLeft;
|
|
4057
|
+
var rightResult = ctx.evaluate(rightNode);
|
|
4058
|
+
return isAwaitable(rightResult) ? rightResult : Promise.resolve(rightResult);
|
|
4059
|
+
});
|
|
4060
|
+
}
|
|
4061
|
+
return leftResult || ctx.evaluate(rightNode);
|
|
3922
4062
|
}
|
|
3923
4063
|
};
|
|
3924
4064
|
var ExpressionEvaluator = /*#__PURE__*/ function() {
|
|
@@ -3939,7 +4079,12 @@ var ReferenceAssetsPlugin = function() {
|
|
|
3939
4079
|
this.operators = {
|
|
3940
4080
|
binary: new Map(Object.entries(DEFAULT_BINARY_OPERATORS)),
|
|
3941
4081
|
unary: new Map(Object.entries(DEFAULT_UNARY_OPERATORS)),
|
|
3942
|
-
expressions: new Map(Object.entries(evaluator_functions_exports))
|
|
4082
|
+
expressions: new Map(_to_consumable_array(Object.entries(evaluator_functions_exports)).concat([
|
|
4083
|
+
[
|
|
4084
|
+
"await",
|
|
4085
|
+
waitFor
|
|
4086
|
+
]
|
|
4087
|
+
]))
|
|
3943
4088
|
};
|
|
3944
4089
|
this.defaultHookOptions = _object_spread_props(_object_spread({}, defaultOptions), {
|
|
3945
4090
|
evaluate: function(expr) {
|
|
@@ -3949,7 +4094,9 @@ var ReferenceAssetsPlugin = function() {
|
|
|
3949
4094
|
return _this._execAST(node, _this.defaultHookOptions);
|
|
3950
4095
|
}
|
|
3951
4096
|
});
|
|
3952
|
-
this.hooks.resolve.tap("ExpressionEvaluator",
|
|
4097
|
+
this.hooks.resolve.tap("ExpressionEvaluator", function(result, node, options) {
|
|
4098
|
+
return _this._resolveNode(result, node, options);
|
|
4099
|
+
});
|
|
3953
4100
|
this.evaluate = this.evaluate.bind(this);
|
|
3954
4101
|
}
|
|
3955
4102
|
_create_class(ExpressionEvaluator, [
|
|
@@ -3987,6 +4134,38 @@ var ReferenceAssetsPlugin = function() {
|
|
|
3987
4134
|
return this._execString(String(expression), resolvedOpts);
|
|
3988
4135
|
}
|
|
3989
4136
|
},
|
|
4137
|
+
{
|
|
4138
|
+
/**
|
|
4139
|
+
* Evaluate functions in an async context
|
|
4140
|
+
* @experimental These Player APIs are in active development and may change. Use with caution
|
|
4141
|
+
*/ key: "evaluateAsync",
|
|
4142
|
+
value: function evaluateAsync(expr, options) {
|
|
4143
|
+
if (Array.isArray(expr)) {
|
|
4144
|
+
var _this = this;
|
|
4145
|
+
return collateAwaitable(expr.map(function() {
|
|
4146
|
+
var _ref = _async_to_generator(function(exp) {
|
|
4147
|
+
return _ts_generator(this, function(_state) {
|
|
4148
|
+
return [
|
|
4149
|
+
2,
|
|
4150
|
+
_this.evaluate(exp, _object_spread_props(_object_spread({}, options), {
|
|
4151
|
+
async: true
|
|
4152
|
+
}))
|
|
4153
|
+
];
|
|
4154
|
+
});
|
|
4155
|
+
});
|
|
4156
|
+
return function(exp) {
|
|
4157
|
+
return _ref.apply(this, arguments);
|
|
4158
|
+
};
|
|
4159
|
+
}())).awaitableThen(function(values) {
|
|
4160
|
+
return values.pop();
|
|
4161
|
+
});
|
|
4162
|
+
} else {
|
|
4163
|
+
return this.evaluate(expr, _object_spread_props(_object_spread({}, options), {
|
|
4164
|
+
async: true
|
|
4165
|
+
}));
|
|
4166
|
+
}
|
|
4167
|
+
}
|
|
4168
|
+
},
|
|
3990
4169
|
{
|
|
3991
4170
|
key: "addExpressionFunction",
|
|
3992
4171
|
value: function addExpressionFunction(name, handler) {
|
|
@@ -4032,8 +4211,10 @@ var ReferenceAssetsPlugin = function() {
|
|
|
4032
4211
|
var matches = exp.match(/^@\[(.*)\]@$/);
|
|
4033
4212
|
var matchedExp = exp;
|
|
4034
4213
|
if (matches) {
|
|
4035
|
-
var
|
|
4036
|
-
|
|
4214
|
+
var _Array_from = _sliced_to_array(Array.from(matches), 2), matched = _Array_from[1];
|
|
4215
|
+
if (matched) {
|
|
4216
|
+
matchedExp = matched;
|
|
4217
|
+
}
|
|
4037
4218
|
}
|
|
4038
4219
|
var storedAST;
|
|
4039
4220
|
try {
|
|
@@ -4062,6 +4243,8 @@ var ReferenceAssetsPlugin = function() {
|
|
|
4062
4243
|
value: function _resolveNode(_currentValue, node, options) {
|
|
4063
4244
|
var _this = this;
|
|
4064
4245
|
var resolveNode = options.resolveNode, model = options.model;
|
|
4246
|
+
var _options_async;
|
|
4247
|
+
var isAsync = (_options_async = options.async) !== null && _options_async !== void 0 ? _options_async : false;
|
|
4065
4248
|
var expressionContext = _object_spread_props(_object_spread({}, options), {
|
|
4066
4249
|
evaluate: function(expr) {
|
|
4067
4250
|
return _this.evaluate(expr, options);
|
|
@@ -4081,11 +4264,33 @@ var ReferenceAssetsPlugin = function() {
|
|
|
4081
4264
|
if (operator) {
|
|
4082
4265
|
if ("resolveParams" in operator) {
|
|
4083
4266
|
if (operator.resolveParams === false) {
|
|
4084
|
-
return operator(expressionContext, node.left, node.right);
|
|
4267
|
+
return operator(expressionContext, node.left, node.right, isAsync);
|
|
4268
|
+
}
|
|
4269
|
+
var left2 = resolveNode(node.left);
|
|
4270
|
+
var right2 = resolveNode(node.right);
|
|
4271
|
+
if (options.async && (isAwaitable(left2) || isAwaitable(right2))) {
|
|
4272
|
+
return collateAwaitable([
|
|
4273
|
+
left2,
|
|
4274
|
+
right2
|
|
4275
|
+
]).awaitableThen(function(param) {
|
|
4276
|
+
var _param = _sliced_to_array(param, 2), leftVal = _param[0], rightVal = _param[1];
|
|
4277
|
+
return operator(expressionContext, leftVal, rightVal, isAsync);
|
|
4278
|
+
});
|
|
4085
4279
|
}
|
|
4086
|
-
return operator(expressionContext,
|
|
4280
|
+
return operator(expressionContext, left2, right2, isAsync);
|
|
4281
|
+
}
|
|
4282
|
+
var left = resolveNode(node.left);
|
|
4283
|
+
var right = resolveNode(node.right);
|
|
4284
|
+
if (options.async && (isAwaitable(left) || isAwaitable(right))) {
|
|
4285
|
+
return collateAwaitable([
|
|
4286
|
+
left,
|
|
4287
|
+
right
|
|
4288
|
+
]).awaitableThen(function(param) {
|
|
4289
|
+
var _param = _sliced_to_array(param, 2), leftVal = _param[0], rightVal = _param[1];
|
|
4290
|
+
return operator(leftVal, rightVal, isAsync);
|
|
4291
|
+
});
|
|
4087
4292
|
}
|
|
4088
|
-
return operator(
|
|
4293
|
+
return operator(left, right, isAsync);
|
|
4089
4294
|
}
|
|
4090
4295
|
return;
|
|
4091
4296
|
}
|
|
@@ -4093,21 +4298,29 @@ var ReferenceAssetsPlugin = function() {
|
|
|
4093
4298
|
var operator1 = this.operators.unary.get(node.operator);
|
|
4094
4299
|
if (operator1) {
|
|
4095
4300
|
if ("resolveParams" in operator1) {
|
|
4096
|
-
|
|
4301
|
+
if (operator1.resolveParams === false) {
|
|
4302
|
+
return operator1(expressionContext, node.argument, isAsync);
|
|
4303
|
+
}
|
|
4304
|
+
var arg2 = resolveNode(node.argument);
|
|
4305
|
+
if (options.async && isAwaitable(arg2)) {
|
|
4306
|
+
return arg2.awaitableThen(function(argVal) {
|
|
4307
|
+
return operator1(expressionContext, argVal, isAsync);
|
|
4308
|
+
});
|
|
4309
|
+
}
|
|
4310
|
+
return operator1(expressionContext, arg2, isAsync);
|
|
4097
4311
|
}
|
|
4098
|
-
|
|
4312
|
+
var arg = resolveNode(node.argument);
|
|
4313
|
+
if (options.async && isAwaitable(arg)) {
|
|
4314
|
+
return arg.awaitableThen(function(argVal) {
|
|
4315
|
+
return operator1(argVal, isAsync);
|
|
4316
|
+
});
|
|
4317
|
+
}
|
|
4318
|
+
return operator1(arg, isAsync);
|
|
4099
4319
|
}
|
|
4100
4320
|
return;
|
|
4101
4321
|
}
|
|
4102
4322
|
if (node.type === "Object") {
|
|
4103
|
-
|
|
4104
|
-
var resolvedAttributes = {};
|
|
4105
|
-
attributes.forEach(function(attr) {
|
|
4106
|
-
var key = resolveNode(attr.key);
|
|
4107
|
-
var value = resolveNode(attr.value);
|
|
4108
|
-
resolvedAttributes[key] = value;
|
|
4109
|
-
});
|
|
4110
|
-
return resolvedAttributes;
|
|
4323
|
+
return PromiseCollectionHandler.handleObject(node.attributes, resolveNode, options.async || false);
|
|
4111
4324
|
}
|
|
4112
4325
|
if (node.type === "CallExpression") {
|
|
4113
4326
|
var expressionName = node.callTarget.name;
|
|
@@ -4115,6 +4328,9 @@ var ReferenceAssetsPlugin = function() {
|
|
|
4115
4328
|
if (!operator2) {
|
|
4116
4329
|
throw new Error("Unknown expression function: ".concat(expressionName));
|
|
4117
4330
|
}
|
|
4331
|
+
if (operator2.name === waitFor.name && !options.async) {
|
|
4332
|
+
throw new Error("Usage of await outside of async context");
|
|
4333
|
+
}
|
|
4118
4334
|
if ("resolveParams" in operator2 && operator2.resolveParams === false) {
|
|
4119
4335
|
return operator2.apply(void 0, [
|
|
4120
4336
|
expressionContext
|
|
@@ -4123,6 +4339,16 @@ var ReferenceAssetsPlugin = function() {
|
|
|
4123
4339
|
var args = node.args.map(function(n) {
|
|
4124
4340
|
return resolveNode(n);
|
|
4125
4341
|
});
|
|
4342
|
+
if (options.async) {
|
|
4343
|
+
var hasPromises = args.some(isAwaitable);
|
|
4344
|
+
if (hasPromises) {
|
|
4345
|
+
return collateAwaitable(args).awaitableThen(function(resolvedArgs) {
|
|
4346
|
+
return operator2.apply(void 0, [
|
|
4347
|
+
expressionContext
|
|
4348
|
+
].concat(_to_consumable_array(resolvedArgs)));
|
|
4349
|
+
});
|
|
4350
|
+
}
|
|
4351
|
+
}
|
|
4126
4352
|
return operator2.apply(void 0, [
|
|
4127
4353
|
expressionContext
|
|
4128
4354
|
].concat(_to_consumable_array(args)));
|
|
@@ -4137,11 +4363,36 @@ var ReferenceAssetsPlugin = function() {
|
|
|
4137
4363
|
if (node.type === "MemberExpression") {
|
|
4138
4364
|
var obj = resolveNode(node.object);
|
|
4139
4365
|
var prop = resolveNode(node.property);
|
|
4366
|
+
if (options.async && (isAwaitable(obj) || isAwaitable(prop))) {
|
|
4367
|
+
return collateAwaitable([
|
|
4368
|
+
obj,
|
|
4369
|
+
prop
|
|
4370
|
+
]).awaitableThen(function(param) {
|
|
4371
|
+
var _param = _sliced_to_array(param, 2), objVal = _param[0], propVal = _param[1];
|
|
4372
|
+
return objVal[propVal];
|
|
4373
|
+
});
|
|
4374
|
+
}
|
|
4140
4375
|
return obj[prop];
|
|
4141
4376
|
}
|
|
4142
4377
|
if (node.type === "Assignment") {
|
|
4143
4378
|
if (node.left.type === "ModelRef") {
|
|
4144
4379
|
var value = resolveNode(node.right);
|
|
4380
|
+
if (isPromiseLike(value)) {
|
|
4381
|
+
if (options.async && isAwaitable(value)) {
|
|
4382
|
+
return value.awaitableThen(function(resolvedValue) {
|
|
4383
|
+
model.set([
|
|
4384
|
+
[
|
|
4385
|
+
node.left.ref,
|
|
4386
|
+
resolvedValue
|
|
4387
|
+
]
|
|
4388
|
+
]);
|
|
4389
|
+
return resolvedValue;
|
|
4390
|
+
});
|
|
4391
|
+
} else {
|
|
4392
|
+
var _options_logger;
|
|
4393
|
+
(_options_logger = options.logger) === null || _options_logger === void 0 ? void 0 : _options_logger.warn("Unawaited promise written to mode, this behavior is undefined and may change in future releases");
|
|
4394
|
+
}
|
|
4395
|
+
}
|
|
4145
4396
|
model.set([
|
|
4146
4397
|
[
|
|
4147
4398
|
node.left.ref,
|
|
@@ -4152,19 +4403,30 @@ var ReferenceAssetsPlugin = function() {
|
|
|
4152
4403
|
}
|
|
4153
4404
|
if (node.left.type === "Identifier") {
|
|
4154
4405
|
var value1 = resolveNode(node.right);
|
|
4406
|
+
if (options.async && isAwaitable(value1)) {
|
|
4407
|
+
return value1.awaitableThen(function(resolvedValue) {
|
|
4408
|
+
_this.vars[node.left.name] = resolvedValue;
|
|
4409
|
+
return resolvedValue;
|
|
4410
|
+
});
|
|
4411
|
+
}
|
|
4155
4412
|
this.vars[node.left.name] = value1;
|
|
4156
4413
|
return value1;
|
|
4157
4414
|
}
|
|
4158
4415
|
return;
|
|
4159
4416
|
}
|
|
4160
4417
|
if (node.type === "ConditionalExpression") {
|
|
4161
|
-
var
|
|
4162
|
-
return
|
|
4418
|
+
var testResult = resolveNode(node.test);
|
|
4419
|
+
return handleConditionalBranching(testResult, function() {
|
|
4420
|
+
return node.consequent;
|
|
4421
|
+
}, function() {
|
|
4422
|
+
return node.alternate;
|
|
4423
|
+
}, resolveNode, isAsync);
|
|
4163
4424
|
}
|
|
4164
4425
|
if (node.type === "ArrayExpression") {
|
|
4165
|
-
|
|
4426
|
+
var results = node.elements.map(function(ele) {
|
|
4166
4427
|
return resolveNode(ele);
|
|
4167
4428
|
});
|
|
4429
|
+
return PromiseCollectionHandler.handleArray(results, isAsync);
|
|
4168
4430
|
}
|
|
4169
4431
|
if (node.type === "Modification") {
|
|
4170
4432
|
var operation = this.operators.binary.get(node.operator);
|
|
@@ -4172,14 +4434,49 @@ var ReferenceAssetsPlugin = function() {
|
|
|
4172
4434
|
var newValue;
|
|
4173
4435
|
if ("resolveParams" in operation) {
|
|
4174
4436
|
if (operation.resolveParams === false) {
|
|
4175
|
-
newValue = operation(expressionContext, node.left, node.right);
|
|
4437
|
+
newValue = operation(expressionContext, node.left, node.right, isAsync);
|
|
4176
4438
|
} else {
|
|
4177
|
-
|
|
4439
|
+
var left1 = resolveNode(node.left);
|
|
4440
|
+
var right1 = resolveNode(node.right);
|
|
4441
|
+
if (options.async && (isAwaitable(left1) || isAwaitable(right1))) {
|
|
4442
|
+
newValue = collateAwaitable([
|
|
4443
|
+
left1,
|
|
4444
|
+
right1
|
|
4445
|
+
]).awaitableThen(function(param) {
|
|
4446
|
+
var _param = _sliced_to_array(param, 2), leftVal = _param[0], rightVal = _param[1];
|
|
4447
|
+
return operation(expressionContext, leftVal, rightVal, isAsync);
|
|
4448
|
+
});
|
|
4449
|
+
} else {
|
|
4450
|
+
newValue = operation(expressionContext, left1, right1, isAsync);
|
|
4451
|
+
}
|
|
4178
4452
|
}
|
|
4179
4453
|
} else {
|
|
4180
|
-
|
|
4454
|
+
var left3 = resolveNode(node.left);
|
|
4455
|
+
var right3 = resolveNode(node.right);
|
|
4456
|
+
if (options.async && (isAwaitable(left3) || isAwaitable(right3))) {
|
|
4457
|
+
newValue = collateAwaitable([
|
|
4458
|
+
left3,
|
|
4459
|
+
right3
|
|
4460
|
+
]).awaitableThen(function(param) {
|
|
4461
|
+
var _param = _sliced_to_array(param, 2), leftVal = _param[0], rightVal = _param[1];
|
|
4462
|
+
return operation(leftVal, rightVal, isAsync);
|
|
4463
|
+
});
|
|
4464
|
+
} else {
|
|
4465
|
+
newValue = operation(left3, right3, isAsync);
|
|
4466
|
+
}
|
|
4181
4467
|
}
|
|
4182
4468
|
if (node.left.type === "ModelRef") {
|
|
4469
|
+
if (options.async && isAwaitable(newValue)) {
|
|
4470
|
+
return newValue.awaitableThen(function(resolvedValue) {
|
|
4471
|
+
model.set([
|
|
4472
|
+
[
|
|
4473
|
+
node.left.ref,
|
|
4474
|
+
resolvedValue
|
|
4475
|
+
]
|
|
4476
|
+
]);
|
|
4477
|
+
return resolvedValue;
|
|
4478
|
+
});
|
|
4479
|
+
}
|
|
4183
4480
|
model.set([
|
|
4184
4481
|
[
|
|
4185
4482
|
node.left.ref,
|
|
@@ -4187,6 +4484,12 @@ var ReferenceAssetsPlugin = function() {
|
|
|
4187
4484
|
]
|
|
4188
4485
|
]);
|
|
4189
4486
|
} else if (node.left.type === "Identifier") {
|
|
4487
|
+
if (options.async && isAwaitable(newValue)) {
|
|
4488
|
+
return newValue.awaitableThen(function(resolvedValue) {
|
|
4489
|
+
_this.vars[node.left.name] = resolvedValue;
|
|
4490
|
+
return resolvedValue;
|
|
4491
|
+
});
|
|
4492
|
+
}
|
|
4190
4493
|
this.vars[node.left.name] = newValue;
|
|
4191
4494
|
}
|
|
4192
4495
|
return newValue;
|
|
@@ -7537,18 +7840,18 @@ var ReferenceAssetsPlugin = function() {
|
|
|
7537
7840
|
this.constantsController = new ConstantsController();
|
|
7538
7841
|
this.state = NOT_STARTED_STATE;
|
|
7539
7842
|
this.hooks = {
|
|
7540
|
-
|
|
7541
|
-
|
|
7542
|
-
|
|
7543
|
-
|
|
7544
|
-
|
|
7545
|
-
|
|
7546
|
-
|
|
7547
|
-
|
|
7548
|
-
|
|
7549
|
-
|
|
7550
|
-
|
|
7551
|
-
|
|
7843
|
+
flowController: new SyncHook(),
|
|
7844
|
+
viewController: new SyncHook(),
|
|
7845
|
+
view: new SyncHook(),
|
|
7846
|
+
expressionEvaluator: new SyncHook(),
|
|
7847
|
+
dataController: new SyncHook(),
|
|
7848
|
+
schema: new SyncHook(),
|
|
7849
|
+
validationController: new SyncHook(),
|
|
7850
|
+
bindingParser: new SyncHook(),
|
|
7851
|
+
state: new SyncHook(),
|
|
7852
|
+
onStart: new SyncHook(),
|
|
7853
|
+
onEnd: new SyncHook(),
|
|
7854
|
+
resolveFlowContent: new SyncWaterfallHook()
|
|
7552
7855
|
};
|
|
7553
7856
|
if (config === null || config === void 0 ? void 0 : config.logger) {
|
|
7554
7857
|
this.logger.addHandler(config.logger);
|
|
@@ -7748,10 +8051,90 @@ var ReferenceAssetsPlugin = function() {
|
|
|
7748
8051
|
var value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
|
|
7749
8052
|
if (value && value.state_type === "ACTION") {
|
|
7750
8053
|
var exp = value.exp;
|
|
7751
|
-
|
|
8054
|
+
var result = expressionEvaluator.evaluate(exp);
|
|
8055
|
+
if (isPromiseLike(result)) {
|
|
8056
|
+
_this.logger.warn("Async expression used as return value in in non-async context, transitioning with '*' value");
|
|
8057
|
+
}
|
|
8058
|
+
flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
|
|
7752
8059
|
}
|
|
7753
8060
|
expressionEvaluator.reset();
|
|
7754
8061
|
});
|
|
8062
|
+
var _this1 = _this;
|
|
8063
|
+
flow.hooks.afterTransition.tap("player", function() {
|
|
8064
|
+
var _ref = _async_to_generator(function(flowInstance) {
|
|
8065
|
+
var _flowInstance_currentState, value, exp, result, e;
|
|
8066
|
+
return _ts_generator(this, function(_state) {
|
|
8067
|
+
switch(_state.label){
|
|
8068
|
+
case 0:
|
|
8069
|
+
value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
|
|
8070
|
+
if (!(value && value.state_type === "ASYNC_ACTION")) return [
|
|
8071
|
+
3,
|
|
8072
|
+
8
|
|
8073
|
+
];
|
|
8074
|
+
exp = value.exp;
|
|
8075
|
+
_state.label = 1;
|
|
8076
|
+
case 1:
|
|
8077
|
+
_state.trys.push([
|
|
8078
|
+
1,
|
|
8079
|
+
7,
|
|
8080
|
+
,
|
|
8081
|
+
8
|
|
8082
|
+
]);
|
|
8083
|
+
result = expressionEvaluator.evaluateAsync(exp);
|
|
8084
|
+
if (!isPromiseLike(result)) return [
|
|
8085
|
+
3,
|
|
8086
|
+
5
|
|
8087
|
+
];
|
|
8088
|
+
if (!value.await) return [
|
|
8089
|
+
3,
|
|
8090
|
+
3
|
|
8091
|
+
];
|
|
8092
|
+
return [
|
|
8093
|
+
4,
|
|
8094
|
+
result
|
|
8095
|
+
];
|
|
8096
|
+
case 2:
|
|
8097
|
+
result = _state.sent();
|
|
8098
|
+
return [
|
|
8099
|
+
3,
|
|
8100
|
+
4
|
|
8101
|
+
];
|
|
8102
|
+
case 3:
|
|
8103
|
+
_this1.logger.warn("Unawaited promise used as return value in in non-async context, transitioning with '*' value");
|
|
8104
|
+
_state.label = 4;
|
|
8105
|
+
case 4:
|
|
8106
|
+
return [
|
|
8107
|
+
3,
|
|
8108
|
+
6
|
|
8109
|
+
];
|
|
8110
|
+
case 5:
|
|
8111
|
+
_this1.logger.warn("Non async expression used in async action node");
|
|
8112
|
+
_state.label = 6;
|
|
8113
|
+
case 6:
|
|
8114
|
+
flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
|
|
8115
|
+
return [
|
|
8116
|
+
3,
|
|
8117
|
+
8
|
|
8118
|
+
];
|
|
8119
|
+
case 7:
|
|
8120
|
+
e = _state.sent();
|
|
8121
|
+
flowResultDeferred.reject(e);
|
|
8122
|
+
return [
|
|
8123
|
+
3,
|
|
8124
|
+
8
|
|
8125
|
+
];
|
|
8126
|
+
case 8:
|
|
8127
|
+
expressionEvaluator.reset();
|
|
8128
|
+
return [
|
|
8129
|
+
2
|
|
8130
|
+
];
|
|
8131
|
+
}
|
|
8132
|
+
});
|
|
8133
|
+
});
|
|
8134
|
+
return function(flowInstance) {
|
|
8135
|
+
return _ref.apply(this, arguments);
|
|
8136
|
+
};
|
|
8137
|
+
}());
|
|
7755
8138
|
});
|
|
7756
8139
|
this.hooks.dataController.call(dataController);
|
|
7757
8140
|
validationController.setOptions({
|