@player-ui/async-node-plugin 0.12.0--canary.649.24150 → 0.12.0--canary.677.24206
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.
|
@@ -1184,61 +1184,12 @@ var AsyncNodePlugin = function() {
|
|
|
1184
1184
|
};
|
|
1185
1185
|
}
|
|
1186
1186
|
};
|
|
1187
|
-
var isPromiselike = function isPromiselike(value) {
|
|
1188
|
-
var // Check for standard Promise constructor name
|
|
1189
|
-
_value_constructor;
|
|
1190
|
-
return value != null && typeof value === "object" && typeof value.then === "function" && // Additional safeguards against false positives
|
|
1191
|
-
(_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
|
|
1192
|
-
typeof value.catch === "function" && typeof value.finally === "function");
|
|
1193
|
-
};
|
|
1194
|
-
var isAwaitable = function isAwaitable(val) {
|
|
1195
|
-
return isPromiselike(val) && val[AwaitableSymbol] !== void 0;
|
|
1196
|
-
};
|
|
1197
|
-
var collateAwaitable = function collateAwaitable(promises) {
|
|
1198
|
-
var result = Promise.all(promises);
|
|
1199
|
-
return makeAwaitable(result);
|
|
1200
|
-
};
|
|
1201
1187
|
var isObjectExpression = function isObjectExpression(expr) {
|
|
1202
1188
|
if (isExpressionNode(expr)) {
|
|
1203
1189
|
return false;
|
|
1204
1190
|
}
|
|
1205
1191
|
return typeof expr === "object" && expr !== null && !Array.isArray(expr) && "value" in expr;
|
|
1206
1192
|
};
|
|
1207
|
-
var makePromiseAwareBinaryOp = function makePromiseAwareBinaryOp(operation) {
|
|
1208
|
-
return function(a, b, async) {
|
|
1209
|
-
if (async && (isAwaitable(a) || isAwaitable(b))) {
|
|
1210
|
-
return collateAwaitable([
|
|
1211
|
-
Promise.resolve(a),
|
|
1212
|
-
Promise.resolve(b)
|
|
1213
|
-
]).awaitableThen(function(param) {
|
|
1214
|
-
var _param = _sliced_to_array(param, 2), resolvedA = _param[0], resolvedB = _param[1];
|
|
1215
|
-
return operation(resolvedA, resolvedB);
|
|
1216
|
-
});
|
|
1217
|
-
}
|
|
1218
|
-
return operation(a, b);
|
|
1219
|
-
};
|
|
1220
|
-
};
|
|
1221
|
-
var makePromiseAwareUnaryOp = function makePromiseAwareUnaryOp(operation) {
|
|
1222
|
-
return function(a, async) {
|
|
1223
|
-
if (async && isAwaitable(a)) {
|
|
1224
|
-
return a.awaitableThen(function(resolved) {
|
|
1225
|
-
return operation(resolved);
|
|
1226
|
-
});
|
|
1227
|
-
}
|
|
1228
|
-
return operation(a);
|
|
1229
|
-
};
|
|
1230
|
-
};
|
|
1231
|
-
var handleConditionalBranching = function handleConditionalBranching(testValue, getTrueBranch, getFalseBranch, resolveNode, async) {
|
|
1232
|
-
if (async && isAwaitable(testValue)) {
|
|
1233
|
-
return testValue.awaitableThen(function(resolved) {
|
|
1234
|
-
var branch2 = resolved ? getTrueBranch() : getFalseBranch();
|
|
1235
|
-
var branchResult = resolveNode(branch2);
|
|
1236
|
-
return isAwaitable(branchResult) ? Promise.resolve(branchResult) : branchResult;
|
|
1237
|
-
});
|
|
1238
|
-
}
|
|
1239
|
-
var branch = testValue ? getTrueBranch() : getFalseBranch();
|
|
1240
|
-
return resolveNode(branch);
|
|
1241
|
-
};
|
|
1242
1193
|
var parse2 = function parse2(schema) {
|
|
1243
1194
|
var _loop = function() {
|
|
1244
1195
|
var next = parseQueue.shift();
|
|
@@ -3628,19 +3579,8 @@ var AsyncNodePlugin = function() {
|
|
|
3628
3579
|
},
|
|
3629
3580
|
setDataVal: function() {
|
|
3630
3581
|
return setDataVal;
|
|
3631
|
-
},
|
|
3632
|
-
waitFor: function() {
|
|
3633
|
-
return waitFor;
|
|
3634
3582
|
}
|
|
3635
3583
|
});
|
|
3636
|
-
var AwaitableSymbol = Symbol("Awaitable");
|
|
3637
|
-
function makeAwaitable(promise) {
|
|
3638
|
-
promise[AwaitableSymbol] = AwaitableSymbol;
|
|
3639
|
-
promise.awaitableThen = function(arg) {
|
|
3640
|
-
return makeAwaitable(promise.then(arg));
|
|
3641
|
-
};
|
|
3642
|
-
return promise;
|
|
3643
|
-
}
|
|
3644
3584
|
var setDataVal = function(_context, binding, value) {
|
|
3645
3585
|
_context.model.set([
|
|
3646
3586
|
[
|
|
@@ -3656,19 +3596,8 @@ var AsyncNodePlugin = function() {
|
|
|
3656
3596
|
return _context.model.delete(binding);
|
|
3657
3597
|
};
|
|
3658
3598
|
var conditional = function(ctx, condition, ifTrue, ifFalse) {
|
|
3659
|
-
var
|
|
3660
|
-
if (
|
|
3661
|
-
return testResult.awaitableThen(function(resolvedTest) {
|
|
3662
|
-
if (resolvedTest) {
|
|
3663
|
-
return ctx.evaluate(ifTrue);
|
|
3664
|
-
}
|
|
3665
|
-
if (ifFalse) {
|
|
3666
|
-
return ctx.evaluate(ifFalse);
|
|
3667
|
-
}
|
|
3668
|
-
return null;
|
|
3669
|
-
});
|
|
3670
|
-
}
|
|
3671
|
-
if (testResult) {
|
|
3599
|
+
var resolution = ctx.evaluate(condition);
|
|
3600
|
+
if (resolution) {
|
|
3672
3601
|
return ctx.evaluate(ifTrue);
|
|
3673
3602
|
}
|
|
3674
3603
|
if (ifFalse) {
|
|
@@ -3677,15 +3606,12 @@ var AsyncNodePlugin = function() {
|
|
|
3677
3606
|
return null;
|
|
3678
3607
|
};
|
|
3679
3608
|
conditional.resolveParams = false;
|
|
3680
|
-
var
|
|
3681
|
-
return
|
|
3682
|
-
};
|
|
3683
|
-
var andandOperator = function(ctx, a, b, async) {
|
|
3684
|
-
return LogicalOperators.and(ctx, a, b, async);
|
|
3609
|
+
var andandOperator = function(ctx, a, b) {
|
|
3610
|
+
return ctx.evaluate(a) && ctx.evaluate(b);
|
|
3685
3611
|
};
|
|
3686
3612
|
andandOperator.resolveParams = false;
|
|
3687
|
-
var ororOperator = function(ctx, a, b
|
|
3688
|
-
return
|
|
3613
|
+
var ororOperator = function(ctx, a, b) {
|
|
3614
|
+
return ctx.evaluate(a) || ctx.evaluate(b);
|
|
3689
3615
|
};
|
|
3690
3616
|
ororOperator.resolveParams = false;
|
|
3691
3617
|
var DEFAULT_BINARY_OPERATORS = {
|
|
@@ -3705,35 +3631,34 @@ var AsyncNodePlugin = function() {
|
|
|
3705
3631
|
"%": function(a, b) {
|
|
3706
3632
|
return a % b;
|
|
3707
3633
|
},
|
|
3708
|
-
// Promise-aware comparison operators
|
|
3709
3634
|
// eslint-disable-next-line
|
|
3710
|
-
"==":
|
|
3635
|
+
"==": function(a, b) {
|
|
3711
3636
|
return a == b;
|
|
3712
|
-
}
|
|
3637
|
+
},
|
|
3713
3638
|
// eslint-disable-next-line
|
|
3714
|
-
"!=":
|
|
3639
|
+
"!=": function(a, b) {
|
|
3715
3640
|
return a != b;
|
|
3716
|
-
}
|
|
3717
|
-
">":
|
|
3641
|
+
},
|
|
3642
|
+
">": function(a, b) {
|
|
3718
3643
|
return a > b;
|
|
3719
|
-
}
|
|
3720
|
-
">=":
|
|
3644
|
+
},
|
|
3645
|
+
">=": function(a, b) {
|
|
3721
3646
|
return a >= b;
|
|
3722
|
-
}
|
|
3723
|
-
"<":
|
|
3647
|
+
},
|
|
3648
|
+
"<": function(a, b) {
|
|
3724
3649
|
return a < b;
|
|
3725
|
-
}
|
|
3726
|
-
"<=":
|
|
3650
|
+
},
|
|
3651
|
+
"<=": function(a, b) {
|
|
3727
3652
|
return a <= b;
|
|
3728
|
-
}
|
|
3729
|
-
"!==": makePromiseAwareBinaryOp(function(a, b) {
|
|
3730
|
-
return a !== b;
|
|
3731
|
-
}),
|
|
3732
|
-
"===": makePromiseAwareBinaryOp(function(a, b) {
|
|
3733
|
-
return a === b;
|
|
3734
|
-
}),
|
|
3653
|
+
},
|
|
3735
3654
|
"&&": andandOperator,
|
|
3736
3655
|
"||": ororOperator,
|
|
3656
|
+
"!==": function(a, b) {
|
|
3657
|
+
return a !== b;
|
|
3658
|
+
},
|
|
3659
|
+
"===": function(a, b) {
|
|
3660
|
+
return a === b;
|
|
3661
|
+
},
|
|
3737
3662
|
// eslint-disable-next-line
|
|
3738
3663
|
"|": function(a, b) {
|
|
3739
3664
|
return a | b;
|
|
@@ -3764,73 +3689,8 @@ var AsyncNodePlugin = function() {
|
|
|
3764
3689
|
"+": function(a) {
|
|
3765
3690
|
return Number(a);
|
|
3766
3691
|
},
|
|
3767
|
-
"!":
|
|
3692
|
+
"!": function(a) {
|
|
3768
3693
|
return !a;
|
|
3769
|
-
})
|
|
3770
|
-
};
|
|
3771
|
-
var PromiseCollectionHandler = {
|
|
3772
|
-
/**
|
|
3773
|
-
* Handle array with potential Promise elements
|
|
3774
|
-
*/ handleArray: function handleArray(items, async) {
|
|
3775
|
-
if (!async) {
|
|
3776
|
-
return items;
|
|
3777
|
-
}
|
|
3778
|
-
var hasPromises = items.some(function(item) {
|
|
3779
|
-
return isAwaitable(item);
|
|
3780
|
-
});
|
|
3781
|
-
return hasPromises ? collateAwaitable(items) : items;
|
|
3782
|
-
},
|
|
3783
|
-
/**
|
|
3784
|
-
* Handle object with potential Promise keys/values
|
|
3785
|
-
*/ handleObject: function handleObject(attributes, resolveNode, async) {
|
|
3786
|
-
var resolvedAttributes = {};
|
|
3787
|
-
var promises = [];
|
|
3788
|
-
var hasPromises = false;
|
|
3789
|
-
attributes.forEach(function(attr) {
|
|
3790
|
-
var key = resolveNode(attr.key);
|
|
3791
|
-
var value = resolveNode(attr.value);
|
|
3792
|
-
if (async && (isAwaitable(key) || isAwaitable(value))) {
|
|
3793
|
-
hasPromises = true;
|
|
3794
|
-
var keyPromise = Promise.resolve(key);
|
|
3795
|
-
var valuePromise = Promise.resolve(value);
|
|
3796
|
-
promises.push(collateAwaitable([
|
|
3797
|
-
keyPromise,
|
|
3798
|
-
valuePromise
|
|
3799
|
-
]).awaitableThen(function(param) {
|
|
3800
|
-
var _param = _sliced_to_array(param, 2), resolvedKey = _param[0], resolvedValue = _param[1];
|
|
3801
|
-
resolvedAttributes[resolvedKey] = resolvedValue;
|
|
3802
|
-
}));
|
|
3803
|
-
} else {
|
|
3804
|
-
resolvedAttributes[key] = value;
|
|
3805
|
-
}
|
|
3806
|
-
});
|
|
3807
|
-
return hasPromises ? collateAwaitable(promises).awaitableThen(function() {
|
|
3808
|
-
return resolvedAttributes;
|
|
3809
|
-
}) : resolvedAttributes;
|
|
3810
|
-
}
|
|
3811
|
-
};
|
|
3812
|
-
var LogicalOperators = {
|
|
3813
|
-
and: function(ctx, leftNode, rightNode, async) {
|
|
3814
|
-
var leftResult = ctx.evaluate(leftNode);
|
|
3815
|
-
if (async && isAwaitable(leftResult)) {
|
|
3816
|
-
return leftResult.awaitableThen(function(awaitedLeft) {
|
|
3817
|
-
if (!awaitedLeft) return awaitedLeft;
|
|
3818
|
-
var rightResult = ctx.evaluate(rightNode);
|
|
3819
|
-
return isAwaitable(rightResult) ? rightResult : Promise.resolve(rightResult);
|
|
3820
|
-
});
|
|
3821
|
-
}
|
|
3822
|
-
return leftResult && ctx.evaluate(rightNode);
|
|
3823
|
-
},
|
|
3824
|
-
or: function(ctx, leftNode, rightNode, async) {
|
|
3825
|
-
var leftResult = ctx.evaluate(leftNode);
|
|
3826
|
-
if (async && isAwaitable(leftResult)) {
|
|
3827
|
-
return leftResult.awaitableThen(function(awaitedLeft) {
|
|
3828
|
-
if (awaitedLeft) return awaitedLeft;
|
|
3829
|
-
var rightResult = ctx.evaluate(rightNode);
|
|
3830
|
-
return isAwaitable(rightResult) ? rightResult : Promise.resolve(rightResult);
|
|
3831
|
-
});
|
|
3832
|
-
}
|
|
3833
|
-
return leftResult || ctx.evaluate(rightNode);
|
|
3834
3694
|
}
|
|
3835
3695
|
};
|
|
3836
3696
|
var ExpressionEvaluator = /*#__PURE__*/ function() {
|
|
@@ -3851,12 +3711,7 @@ var AsyncNodePlugin = function() {
|
|
|
3851
3711
|
this.operators = {
|
|
3852
3712
|
binary: new Map(Object.entries(DEFAULT_BINARY_OPERATORS)),
|
|
3853
3713
|
unary: new Map(Object.entries(DEFAULT_UNARY_OPERATORS)),
|
|
3854
|
-
expressions: new Map(
|
|
3855
|
-
[
|
|
3856
|
-
"await",
|
|
3857
|
-
waitFor
|
|
3858
|
-
]
|
|
3859
|
-
]))
|
|
3714
|
+
expressions: new Map(Object.entries(evaluator_functions_exports))
|
|
3860
3715
|
};
|
|
3861
3716
|
this.defaultHookOptions = _object_spread_props(_object_spread({}, defaultOptions), {
|
|
3862
3717
|
evaluate: function(expr) {
|
|
@@ -3866,9 +3721,7 @@ var AsyncNodePlugin = function() {
|
|
|
3866
3721
|
return _this._execAST(node, _this.defaultHookOptions);
|
|
3867
3722
|
}
|
|
3868
3723
|
});
|
|
3869
|
-
this.hooks.resolve.tap("ExpressionEvaluator",
|
|
3870
|
-
return _this._resolveNode(result, node, options);
|
|
3871
|
-
});
|
|
3724
|
+
this.hooks.resolve.tap("ExpressionEvaluator", this._resolveNode.bind(this));
|
|
3872
3725
|
this.evaluate = this.evaluate.bind(this);
|
|
3873
3726
|
}
|
|
3874
3727
|
_create_class(ExpressionEvaluator, [
|
|
@@ -3906,38 +3759,6 @@ var AsyncNodePlugin = function() {
|
|
|
3906
3759
|
return this._execString(String(expression), resolvedOpts);
|
|
3907
3760
|
}
|
|
3908
3761
|
},
|
|
3909
|
-
{
|
|
3910
|
-
/**
|
|
3911
|
-
* Evaluate functions in an async context
|
|
3912
|
-
* @experimental These Player APIs are in active development and may change. Use with caution
|
|
3913
|
-
*/ key: "evaluateAsync",
|
|
3914
|
-
value: function evaluateAsync(expr, options) {
|
|
3915
|
-
if (Array.isArray(expr)) {
|
|
3916
|
-
var _this = this;
|
|
3917
|
-
return collateAwaitable(expr.map(function() {
|
|
3918
|
-
var _ref = _async_to_generator(function(exp) {
|
|
3919
|
-
return _ts_generator(this, function(_state) {
|
|
3920
|
-
return [
|
|
3921
|
-
2,
|
|
3922
|
-
_this.evaluate(exp, _object_spread_props(_object_spread({}, options), {
|
|
3923
|
-
async: true
|
|
3924
|
-
}))
|
|
3925
|
-
];
|
|
3926
|
-
});
|
|
3927
|
-
});
|
|
3928
|
-
return function(exp) {
|
|
3929
|
-
return _ref.apply(this, arguments);
|
|
3930
|
-
};
|
|
3931
|
-
}())).awaitableThen(function(values) {
|
|
3932
|
-
return values.pop();
|
|
3933
|
-
});
|
|
3934
|
-
} else {
|
|
3935
|
-
return this.evaluate(expr, _object_spread_props(_object_spread({}, options), {
|
|
3936
|
-
async: true
|
|
3937
|
-
}));
|
|
3938
|
-
}
|
|
3939
|
-
}
|
|
3940
|
-
},
|
|
3941
3762
|
{
|
|
3942
3763
|
key: "addExpressionFunction",
|
|
3943
3764
|
value: function addExpressionFunction(name, handler) {
|
|
@@ -3983,10 +3804,8 @@ var AsyncNodePlugin = function() {
|
|
|
3983
3804
|
var matches = exp.match(/^@\[(.*)\]@$/);
|
|
3984
3805
|
var matchedExp = exp;
|
|
3985
3806
|
if (matches) {
|
|
3986
|
-
var
|
|
3987
|
-
|
|
3988
|
-
matchedExp = matched;
|
|
3989
|
-
}
|
|
3807
|
+
var ref;
|
|
3808
|
+
ref = _sliced_to_array(Array.from(matches), 2), matchedExp = ref[1], ref;
|
|
3990
3809
|
}
|
|
3991
3810
|
var storedAST;
|
|
3992
3811
|
try {
|
|
@@ -4015,8 +3834,6 @@ var AsyncNodePlugin = function() {
|
|
|
4015
3834
|
value: function _resolveNode(_currentValue, node, options) {
|
|
4016
3835
|
var _this = this;
|
|
4017
3836
|
var resolveNode = options.resolveNode, model = options.model;
|
|
4018
|
-
var _options_async;
|
|
4019
|
-
var isAsync = (_options_async = options.async) !== null && _options_async !== void 0 ? _options_async : false;
|
|
4020
3837
|
var expressionContext = _object_spread_props(_object_spread({}, options), {
|
|
4021
3838
|
evaluate: function(expr) {
|
|
4022
3839
|
return _this.evaluate(expr, options);
|
|
@@ -4036,33 +3853,11 @@ var AsyncNodePlugin = function() {
|
|
|
4036
3853
|
if (operator) {
|
|
4037
3854
|
if ("resolveParams" in operator) {
|
|
4038
3855
|
if (operator.resolveParams === false) {
|
|
4039
|
-
return operator(expressionContext, node.left, node.right
|
|
3856
|
+
return operator(expressionContext, node.left, node.right);
|
|
4040
3857
|
}
|
|
4041
|
-
|
|
4042
|
-
var right2 = resolveNode(node.right);
|
|
4043
|
-
if (options.async && (isAwaitable(left2) || isAwaitable(right2))) {
|
|
4044
|
-
return collateAwaitable([
|
|
4045
|
-
left2,
|
|
4046
|
-
right2
|
|
4047
|
-
]).awaitableThen(function(param) {
|
|
4048
|
-
var _param = _sliced_to_array(param, 2), leftVal = _param[0], rightVal = _param[1];
|
|
4049
|
-
return operator(expressionContext, leftVal, rightVal, isAsync);
|
|
4050
|
-
});
|
|
4051
|
-
}
|
|
4052
|
-
return operator(expressionContext, left2, right2, isAsync);
|
|
4053
|
-
}
|
|
4054
|
-
var left = resolveNode(node.left);
|
|
4055
|
-
var right = resolveNode(node.right);
|
|
4056
|
-
if (options.async && (isAwaitable(left) || isAwaitable(right))) {
|
|
4057
|
-
return collateAwaitable([
|
|
4058
|
-
left,
|
|
4059
|
-
right
|
|
4060
|
-
]).awaitableThen(function(param) {
|
|
4061
|
-
var _param = _sliced_to_array(param, 2), leftVal = _param[0], rightVal = _param[1];
|
|
4062
|
-
return operator(leftVal, rightVal, isAsync);
|
|
4063
|
-
});
|
|
3858
|
+
return operator(expressionContext, resolveNode(node.left), resolveNode(node.right));
|
|
4064
3859
|
}
|
|
4065
|
-
return operator(left, right
|
|
3860
|
+
return operator(resolveNode(node.left), resolveNode(node.right));
|
|
4066
3861
|
}
|
|
4067
3862
|
return;
|
|
4068
3863
|
}
|
|
@@ -4070,29 +3865,21 @@ var AsyncNodePlugin = function() {
|
|
|
4070
3865
|
var operator1 = this.operators.unary.get(node.operator);
|
|
4071
3866
|
if (operator1) {
|
|
4072
3867
|
if ("resolveParams" in operator1) {
|
|
4073
|
-
|
|
4074
|
-
return operator1(expressionContext, node.argument, isAsync);
|
|
4075
|
-
}
|
|
4076
|
-
var arg2 = resolveNode(node.argument);
|
|
4077
|
-
if (options.async && isAwaitable(arg2)) {
|
|
4078
|
-
return arg2.awaitableThen(function(argVal) {
|
|
4079
|
-
return operator1(expressionContext, argVal, isAsync);
|
|
4080
|
-
});
|
|
4081
|
-
}
|
|
4082
|
-
return operator1(expressionContext, arg2, isAsync);
|
|
4083
|
-
}
|
|
4084
|
-
var arg = resolveNode(node.argument);
|
|
4085
|
-
if (options.async && isAwaitable(arg)) {
|
|
4086
|
-
return arg.awaitableThen(function(argVal) {
|
|
4087
|
-
return operator1(argVal, isAsync);
|
|
4088
|
-
});
|
|
3868
|
+
return operator1(expressionContext, operator1.resolveParams === false ? node.argument : resolveNode(node.argument));
|
|
4089
3869
|
}
|
|
4090
|
-
return operator1(
|
|
3870
|
+
return operator1(resolveNode(node.argument));
|
|
4091
3871
|
}
|
|
4092
3872
|
return;
|
|
4093
3873
|
}
|
|
4094
3874
|
if (node.type === "Object") {
|
|
4095
|
-
|
|
3875
|
+
var attributes = node.attributes;
|
|
3876
|
+
var resolvedAttributes = {};
|
|
3877
|
+
attributes.forEach(function(attr) {
|
|
3878
|
+
var key = resolveNode(attr.key);
|
|
3879
|
+
var value = resolveNode(attr.value);
|
|
3880
|
+
resolvedAttributes[key] = value;
|
|
3881
|
+
});
|
|
3882
|
+
return resolvedAttributes;
|
|
4096
3883
|
}
|
|
4097
3884
|
if (node.type === "CallExpression") {
|
|
4098
3885
|
var expressionName = node.callTarget.name;
|
|
@@ -4100,9 +3887,6 @@ var AsyncNodePlugin = function() {
|
|
|
4100
3887
|
if (!operator2) {
|
|
4101
3888
|
throw new Error("Unknown expression function: ".concat(expressionName));
|
|
4102
3889
|
}
|
|
4103
|
-
if (operator2.name === "waitFor" && !options.async) {
|
|
4104
|
-
throw new Error("Usage of await outside of async context");
|
|
4105
|
-
}
|
|
4106
3890
|
if ("resolveParams" in operator2 && operator2.resolveParams === false) {
|
|
4107
3891
|
return operator2.apply(void 0, [
|
|
4108
3892
|
expressionContext
|
|
@@ -4111,16 +3895,6 @@ var AsyncNodePlugin = function() {
|
|
|
4111
3895
|
var args = node.args.map(function(n) {
|
|
4112
3896
|
return resolveNode(n);
|
|
4113
3897
|
});
|
|
4114
|
-
if (options.async) {
|
|
4115
|
-
var hasPromises = args.some(isAwaitable);
|
|
4116
|
-
if (hasPromises) {
|
|
4117
|
-
return collateAwaitable(args).awaitableThen(function(resolvedArgs) {
|
|
4118
|
-
return operator2.apply(void 0, [
|
|
4119
|
-
expressionContext
|
|
4120
|
-
].concat(_to_consumable_array(resolvedArgs)));
|
|
4121
|
-
});
|
|
4122
|
-
}
|
|
4123
|
-
}
|
|
4124
3898
|
return operator2.apply(void 0, [
|
|
4125
3899
|
expressionContext
|
|
4126
3900
|
].concat(_to_consumable_array(args)));
|
|
@@ -4135,36 +3909,11 @@ var AsyncNodePlugin = function() {
|
|
|
4135
3909
|
if (node.type === "MemberExpression") {
|
|
4136
3910
|
var obj = resolveNode(node.object);
|
|
4137
3911
|
var prop = resolveNode(node.property);
|
|
4138
|
-
if (options.async && (isAwaitable(obj) || isAwaitable(prop))) {
|
|
4139
|
-
return collateAwaitable([
|
|
4140
|
-
obj,
|
|
4141
|
-
prop
|
|
4142
|
-
]).awaitableThen(function(param) {
|
|
4143
|
-
var _param = _sliced_to_array(param, 2), objVal = _param[0], propVal = _param[1];
|
|
4144
|
-
return objVal[propVal];
|
|
4145
|
-
});
|
|
4146
|
-
}
|
|
4147
3912
|
return obj[prop];
|
|
4148
3913
|
}
|
|
4149
3914
|
if (node.type === "Assignment") {
|
|
4150
3915
|
if (node.left.type === "ModelRef") {
|
|
4151
3916
|
var value = resolveNode(node.right);
|
|
4152
|
-
if (isPromiselike(value)) {
|
|
4153
|
-
if (options.async && isAwaitable(value)) {
|
|
4154
|
-
return value.awaitableThen(function(resolvedValue) {
|
|
4155
|
-
model.set([
|
|
4156
|
-
[
|
|
4157
|
-
node.left.ref,
|
|
4158
|
-
resolvedValue
|
|
4159
|
-
]
|
|
4160
|
-
]);
|
|
4161
|
-
return resolvedValue;
|
|
4162
|
-
});
|
|
4163
|
-
} else {
|
|
4164
|
-
var _options_logger;
|
|
4165
|
-
(_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");
|
|
4166
|
-
}
|
|
4167
|
-
}
|
|
4168
3917
|
model.set([
|
|
4169
3918
|
[
|
|
4170
3919
|
node.left.ref,
|
|
@@ -4175,30 +3924,19 @@ var AsyncNodePlugin = function() {
|
|
|
4175
3924
|
}
|
|
4176
3925
|
if (node.left.type === "Identifier") {
|
|
4177
3926
|
var value1 = resolveNode(node.right);
|
|
4178
|
-
if (options.async && isAwaitable(value1)) {
|
|
4179
|
-
return value1.awaitableThen(function(resolvedValue) {
|
|
4180
|
-
_this.vars[node.left.name] = resolvedValue;
|
|
4181
|
-
return resolvedValue;
|
|
4182
|
-
});
|
|
4183
|
-
}
|
|
4184
3927
|
this.vars[node.left.name] = value1;
|
|
4185
3928
|
return value1;
|
|
4186
3929
|
}
|
|
4187
3930
|
return;
|
|
4188
3931
|
}
|
|
4189
3932
|
if (node.type === "ConditionalExpression") {
|
|
4190
|
-
var
|
|
4191
|
-
return
|
|
4192
|
-
return node.consequent;
|
|
4193
|
-
}, function() {
|
|
4194
|
-
return node.alternate;
|
|
4195
|
-
}, resolveNode, isAsync);
|
|
3933
|
+
var result = resolveNode(node.test) ? node.consequent : node.alternate;
|
|
3934
|
+
return resolveNode(result);
|
|
4196
3935
|
}
|
|
4197
3936
|
if (node.type === "ArrayExpression") {
|
|
4198
|
-
|
|
3937
|
+
return node.elements.map(function(ele) {
|
|
4199
3938
|
return resolveNode(ele);
|
|
4200
3939
|
});
|
|
4201
|
-
return PromiseCollectionHandler.handleArray(results, isAsync);
|
|
4202
3940
|
}
|
|
4203
3941
|
if (node.type === "Modification") {
|
|
4204
3942
|
var operation = this.operators.binary.get(node.operator);
|
|
@@ -4206,49 +3944,14 @@ var AsyncNodePlugin = function() {
|
|
|
4206
3944
|
var newValue;
|
|
4207
3945
|
if ("resolveParams" in operation) {
|
|
4208
3946
|
if (operation.resolveParams === false) {
|
|
4209
|
-
newValue = operation(expressionContext, node.left, node.right
|
|
3947
|
+
newValue = operation(expressionContext, node.left, node.right);
|
|
4210
3948
|
} else {
|
|
4211
|
-
|
|
4212
|
-
var right1 = resolveNode(node.right);
|
|
4213
|
-
if (options.async && (isAwaitable(left1) || isAwaitable(right1))) {
|
|
4214
|
-
newValue = collateAwaitable([
|
|
4215
|
-
left1,
|
|
4216
|
-
right1
|
|
4217
|
-
]).awaitableThen(function(param) {
|
|
4218
|
-
var _param = _sliced_to_array(param, 2), leftVal = _param[0], rightVal = _param[1];
|
|
4219
|
-
return operation(expressionContext, leftVal, rightVal, isAsync);
|
|
4220
|
-
});
|
|
4221
|
-
} else {
|
|
4222
|
-
newValue = operation(expressionContext, left1, right1, isAsync);
|
|
4223
|
-
}
|
|
3949
|
+
newValue = operation(expressionContext, resolveNode(node.left), resolveNode(node.right));
|
|
4224
3950
|
}
|
|
4225
3951
|
} else {
|
|
4226
|
-
|
|
4227
|
-
var right3 = resolveNode(node.right);
|
|
4228
|
-
if (options.async && (isAwaitable(left3) || isAwaitable(right3))) {
|
|
4229
|
-
newValue = collateAwaitable([
|
|
4230
|
-
left3,
|
|
4231
|
-
right3
|
|
4232
|
-
]).awaitableThen(function(param) {
|
|
4233
|
-
var _param = _sliced_to_array(param, 2), leftVal = _param[0], rightVal = _param[1];
|
|
4234
|
-
return operation(leftVal, rightVal, isAsync);
|
|
4235
|
-
});
|
|
4236
|
-
} else {
|
|
4237
|
-
newValue = operation(left3, right3, isAsync);
|
|
4238
|
-
}
|
|
3952
|
+
newValue = operation(resolveNode(node.left), resolveNode(node.right));
|
|
4239
3953
|
}
|
|
4240
3954
|
if (node.left.type === "ModelRef") {
|
|
4241
|
-
if (options.async && isAwaitable(newValue)) {
|
|
4242
|
-
return newValue.awaitableThen(function(resolvedValue) {
|
|
4243
|
-
model.set([
|
|
4244
|
-
[
|
|
4245
|
-
node.left.ref,
|
|
4246
|
-
resolvedValue
|
|
4247
|
-
]
|
|
4248
|
-
]);
|
|
4249
|
-
return resolvedValue;
|
|
4250
|
-
});
|
|
4251
|
-
}
|
|
4252
3955
|
model.set([
|
|
4253
3956
|
[
|
|
4254
3957
|
node.left.ref,
|
|
@@ -4256,12 +3959,6 @@ var AsyncNodePlugin = function() {
|
|
|
4256
3959
|
]
|
|
4257
3960
|
]);
|
|
4258
3961
|
} else if (node.left.type === "Identifier") {
|
|
4259
|
-
if (options.async && isAwaitable(newValue)) {
|
|
4260
|
-
return newValue.awaitableThen(function(resolvedValue) {
|
|
4261
|
-
_this.vars[node.left.name] = resolvedValue;
|
|
4262
|
-
return resolvedValue;
|
|
4263
|
-
});
|
|
4264
|
-
}
|
|
4265
3962
|
this.vars[node.left.name] = newValue;
|
|
4266
3963
|
}
|
|
4267
3964
|
return newValue;
|
|
@@ -7836,90 +7533,10 @@ var AsyncNodePlugin = function() {
|
|
|
7836
7533
|
var value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
|
|
7837
7534
|
if (value && value.state_type === "ACTION") {
|
|
7838
7535
|
var exp = value.exp;
|
|
7839
|
-
|
|
7840
|
-
if (isPromiselike(result)) {
|
|
7841
|
-
_this.logger.warn("Async expression used as return value in in non-async context, transitioning with '*' value");
|
|
7842
|
-
}
|
|
7843
|
-
flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
|
|
7536
|
+
flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(expressionEvaluator === null || expressionEvaluator === void 0 ? void 0 : expressionEvaluator.evaluate(exp)));
|
|
7844
7537
|
}
|
|
7845
7538
|
expressionEvaluator.reset();
|
|
7846
7539
|
});
|
|
7847
|
-
var _this1 = _this;
|
|
7848
|
-
flow.hooks.afterTransition.tap("player", function() {
|
|
7849
|
-
var _ref = _async_to_generator(function(flowInstance) {
|
|
7850
|
-
var _flowInstance_currentState, value, exp, result, e;
|
|
7851
|
-
return _ts_generator(this, function(_state) {
|
|
7852
|
-
switch(_state.label){
|
|
7853
|
-
case 0:
|
|
7854
|
-
value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
|
|
7855
|
-
if (!(value && value.state_type === "ASYNC_ACTION")) return [
|
|
7856
|
-
3,
|
|
7857
|
-
8
|
|
7858
|
-
];
|
|
7859
|
-
exp = value.exp;
|
|
7860
|
-
_state.label = 1;
|
|
7861
|
-
case 1:
|
|
7862
|
-
_state.trys.push([
|
|
7863
|
-
1,
|
|
7864
|
-
7,
|
|
7865
|
-
,
|
|
7866
|
-
8
|
|
7867
|
-
]);
|
|
7868
|
-
result = expressionEvaluator.evaluateAsync(exp);
|
|
7869
|
-
if (!isPromiselike(result)) return [
|
|
7870
|
-
3,
|
|
7871
|
-
5
|
|
7872
|
-
];
|
|
7873
|
-
if (!value.await) return [
|
|
7874
|
-
3,
|
|
7875
|
-
3
|
|
7876
|
-
];
|
|
7877
|
-
return [
|
|
7878
|
-
4,
|
|
7879
|
-
result
|
|
7880
|
-
];
|
|
7881
|
-
case 2:
|
|
7882
|
-
result = _state.sent();
|
|
7883
|
-
return [
|
|
7884
|
-
3,
|
|
7885
|
-
4
|
|
7886
|
-
];
|
|
7887
|
-
case 3:
|
|
7888
|
-
_this1.logger.warn("Unawaited promise used as return value in in non-async context, transitioning with '*' value");
|
|
7889
|
-
_state.label = 4;
|
|
7890
|
-
case 4:
|
|
7891
|
-
return [
|
|
7892
|
-
3,
|
|
7893
|
-
6
|
|
7894
|
-
];
|
|
7895
|
-
case 5:
|
|
7896
|
-
_this1.logger.warn("Non async expression used in async action node");
|
|
7897
|
-
_state.label = 6;
|
|
7898
|
-
case 6:
|
|
7899
|
-
flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
|
|
7900
|
-
return [
|
|
7901
|
-
3,
|
|
7902
|
-
8
|
|
7903
|
-
];
|
|
7904
|
-
case 7:
|
|
7905
|
-
e = _state.sent();
|
|
7906
|
-
flowResultDeferred.reject(e);
|
|
7907
|
-
return [
|
|
7908
|
-
3,
|
|
7909
|
-
8
|
|
7910
|
-
];
|
|
7911
|
-
case 8:
|
|
7912
|
-
expressionEvaluator.reset();
|
|
7913
|
-
return [
|
|
7914
|
-
2
|
|
7915
|
-
];
|
|
7916
|
-
}
|
|
7917
|
-
});
|
|
7918
|
-
});
|
|
7919
|
-
return function(flowInstance) {
|
|
7920
|
-
return _ref.apply(this, arguments);
|
|
7921
|
-
};
|
|
7922
|
-
}());
|
|
7923
7540
|
});
|
|
7924
7541
|
this.hooks.dataController.call(dataController);
|
|
7925
7542
|
validationController.setOptions({
|