@player-ui/async-node-plugin 0.11.2--canary.649.23032 → 0.11.2-next.1

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.
@@ -3579,9 +3579,6 @@ var AsyncNodePlugin = function() {
3579
3579
  },
3580
3580
  setDataVal: function() {
3581
3581
  return setDataVal;
3582
- },
3583
- waitFor: function() {
3584
- return waitFor;
3585
3582
  }
3586
3583
  });
3587
3584
  var setDataVal = function(_context, binding, value) {
@@ -3609,27 +3606,6 @@ var AsyncNodePlugin = function() {
3609
3606
  return null;
3610
3607
  };
3611
3608
  conditional.resolveParams = false;
3612
- var waitFor = function() {
3613
- var _ref = _async_to_generator(function(ctx, promise) {
3614
- return _ts_generator(this, function(_state) {
3615
- switch(_state.label){
3616
- case 0:
3617
- return [
3618
- 4,
3619
- promise
3620
- ];
3621
- case 1:
3622
- return [
3623
- 2,
3624
- _state.sent()
3625
- ];
3626
- }
3627
- });
3628
- });
3629
- return function waitFor(ctx, promise) {
3630
- return _ref.apply(this, arguments);
3631
- };
3632
- }();
3633
3609
  var andandOperator = function(ctx, a, b) {
3634
3610
  return ctx.evaluate(a) && ctx.evaluate(b);
3635
3611
  };
@@ -3735,12 +3711,7 @@ var AsyncNodePlugin = function() {
3735
3711
  this.operators = {
3736
3712
  binary: new Map(Object.entries(DEFAULT_BINARY_OPERATORS)),
3737
3713
  unary: new Map(Object.entries(DEFAULT_UNARY_OPERATORS)),
3738
- expressions: new Map(_to_consumable_array(Object.entries(evaluator_functions_exports)).concat([
3739
- [
3740
- "await",
3741
- waitFor
3742
- ]
3743
- ]))
3714
+ expressions: new Map(Object.entries(evaluator_functions_exports))
3744
3715
  };
3745
3716
  this.defaultHookOptions = _object_spread_props(_object_spread({}, defaultOptions), {
3746
3717
  evaluate: function(expr) {
@@ -3750,12 +3721,7 @@ var AsyncNodePlugin = function() {
3750
3721
  return _this._execAST(node, _this.defaultHookOptions);
3751
3722
  }
3752
3723
  });
3753
- this.hooks.resolve.tap("ExpressionEvaluator", function(result, node, options) {
3754
- if (options.async) {
3755
- return _this._resolveNodeAsync(result, node, options);
3756
- }
3757
- return _this._resolveNode(result, node, options);
3758
- });
3724
+ this.hooks.resolve.tap("ExpressionEvaluator", this._resolveNode.bind(this));
3759
3725
  this.evaluate = this.evaluate.bind(this);
3760
3726
  }
3761
3727
  _create_class(ExpressionEvaluator, [
@@ -3793,14 +3759,6 @@ var AsyncNodePlugin = function() {
3793
3759
  return this._execString(String(expression), resolvedOpts);
3794
3760
  }
3795
3761
  },
3796
- {
3797
- key: "evaluateAsync",
3798
- value: function evaluateAsync(expr, options) {
3799
- return this.evaluate(expr, _object_spread_props(_object_spread({}, options), {
3800
- async: true
3801
- }));
3802
- }
3803
- },
3804
3762
  {
3805
3763
  key: "addExpressionFunction",
3806
3764
  value: function addExpressionFunction(name, handler) {
@@ -3846,10 +3804,8 @@ var AsyncNodePlugin = function() {
3846
3804
  var matches = exp.match(/^@\[(.*)\]@$/);
3847
3805
  var matchedExp = exp;
3848
3806
  if (matches) {
3849
- var _Array_from = _sliced_to_array(Array.from(matches), 2), matched = _Array_from[1];
3850
- if (matched) {
3851
- matchedExp = matched;
3852
- }
3807
+ var ref;
3808
+ ref = _sliced_to_array(Array.from(matches), 2), matchedExp = ref[1], ref;
3853
3809
  }
3854
3810
  var storedAST;
3855
3811
  try {
@@ -4010,452 +3966,6 @@ var AsyncNodePlugin = function() {
4010
3966
  return resolveNode(node.left);
4011
3967
  }
4012
3968
  }
4013
- },
4014
- {
4015
- key: "_resolveNodeAsync",
4016
- value: function _resolveNodeAsync(_currentValue, node, options) {
4017
- var _this = this;
4018
- return _async_to_generator(function() {
4019
- var resolveNode, model, expressionContext, operator, _tmp, _tmp1, operator1, _tmp2, _tmp3, attributes, resolvedAttributes, expressionName, operator2, args, obj, prop, value, value1, result, operation, newValue, _tmp4, _tmp5;
4020
- return _ts_generator(this, function(_state) {
4021
- switch(_state.label){
4022
- case 0:
4023
- resolveNode = options.resolveNode, model = options.model;
4024
- expressionContext = _object_spread_props(_object_spread({}, options), {
4025
- evaluate: function(expr) {
4026
- return _this.evaluate(expr, options);
4027
- }
4028
- });
4029
- if (!(node.type === "BinaryExpression" || node.type === "LogicalExpression")) return [
4030
- 3,
4031
- 7
4032
- ];
4033
- operator = _this.operators.binary.get(node.operator);
4034
- if (!operator) return [
4035
- 3,
4036
- 6
4037
- ];
4038
- if (!("resolveParams" in operator)) return [
4039
- 3,
4040
- 3
4041
- ];
4042
- if (operator.resolveParams === false) {
4043
- return [
4044
- 2,
4045
- operator(expressionContext, node.left, node.right)
4046
- ];
4047
- }
4048
- _tmp = [
4049
- expressionContext
4050
- ];
4051
- return [
4052
- 4,
4053
- resolveNode(node.left)
4054
- ];
4055
- case 1:
4056
- _tmp = _tmp.concat([
4057
- _state.sent()
4058
- ]);
4059
- return [
4060
- 4,
4061
- resolveNode(node.right)
4062
- ];
4063
- case 2:
4064
- return [
4065
- 2,
4066
- operator.apply(void 0, _tmp.concat([
4067
- _state.sent()
4068
- ]))
4069
- ];
4070
- case 3:
4071
- return [
4072
- 4,
4073
- resolveNode(node.left)
4074
- ];
4075
- case 4:
4076
- _tmp1 = [
4077
- _state.sent()
4078
- ];
4079
- return [
4080
- 4,
4081
- resolveNode(node.right)
4082
- ];
4083
- case 5:
4084
- return [
4085
- 2,
4086
- operator.apply(void 0, _tmp1.concat([
4087
- _state.sent()
4088
- ]))
4089
- ];
4090
- case 6:
4091
- return [
4092
- 2
4093
- ];
4094
- case 7:
4095
- if (!(node.type === "UnaryExpression")) return [
4096
- 3,
4097
- 14
4098
- ];
4099
- operator1 = _this.operators.unary.get(node.operator);
4100
- if (!operator1) return [
4101
- 3,
4102
- 13
4103
- ];
4104
- if (!("resolveParams" in operator1)) return [
4105
- 3,
4106
- 11
4107
- ];
4108
- _tmp2 = [
4109
- expressionContext
4110
- ];
4111
- if (!(operator1.resolveParams === false)) return [
4112
- 3,
4113
- 8
4114
- ];
4115
- _tmp3 = node.argument;
4116
- return [
4117
- 3,
4118
- 10
4119
- ];
4120
- case 8:
4121
- return [
4122
- 4,
4123
- resolveNode(node.argument)
4124
- ];
4125
- case 9:
4126
- _tmp3 = _state.sent();
4127
- _state.label = 10;
4128
- case 10:
4129
- return [
4130
- 2,
4131
- operator1.apply(void 0, _tmp2.concat([
4132
- _tmp3
4133
- ]))
4134
- ];
4135
- case 11:
4136
- return [
4137
- 4,
4138
- resolveNode(node.argument)
4139
- ];
4140
- case 12:
4141
- return [
4142
- 2,
4143
- operator1.apply(void 0, [
4144
- _state.sent()
4145
- ])
4146
- ];
4147
- case 13:
4148
- return [
4149
- 2
4150
- ];
4151
- case 14:
4152
- if (!(node.type === "Object")) return [
4153
- 3,
4154
- 16
4155
- ];
4156
- attributes = node.attributes;
4157
- resolvedAttributes = {};
4158
- return [
4159
- 4,
4160
- Promise.all(attributes.map(function() {
4161
- var _ref = _async_to_generator(function(attr) {
4162
- var key, value;
4163
- return _ts_generator(this, function(_state) {
4164
- switch(_state.label){
4165
- case 0:
4166
- return [
4167
- 4,
4168
- resolveNode(attr.key)
4169
- ];
4170
- case 1:
4171
- key = _state.sent();
4172
- return [
4173
- 4,
4174
- resolveNode(attr.value)
4175
- ];
4176
- case 2:
4177
- value = _state.sent();
4178
- resolvedAttributes[key] = value;
4179
- return [
4180
- 2
4181
- ];
4182
- }
4183
- });
4184
- });
4185
- return function(attr) {
4186
- return _ref.apply(this, arguments);
4187
- };
4188
- }()))
4189
- ];
4190
- case 15:
4191
- _state.sent();
4192
- return [
4193
- 2,
4194
- resolvedAttributes
4195
- ];
4196
- case 16:
4197
- if (!(node.type === "CallExpression")) return [
4198
- 3,
4199
- 18
4200
- ];
4201
- expressionName = node.callTarget.name;
4202
- operator2 = _this.operators.expressions.get(expressionName);
4203
- if (!operator2) {
4204
- throw new Error("Unknown expression function: ".concat(expressionName));
4205
- }
4206
- if ("resolveParams" in operator2 && operator2.resolveParams === false) {
4207
- return [
4208
- 2,
4209
- operator2.apply(void 0, [
4210
- expressionContext
4211
- ].concat(_to_consumable_array(node.args)))
4212
- ];
4213
- }
4214
- return [
4215
- 4,
4216
- Promise.all(node.args.map(function() {
4217
- var _ref = _async_to_generator(function(n) {
4218
- return _ts_generator(this, function(_state) {
4219
- switch(_state.label){
4220
- case 0:
4221
- return [
4222
- 4,
4223
- resolveNode(n)
4224
- ];
4225
- case 1:
4226
- return [
4227
- 2,
4228
- _state.sent()
4229
- ];
4230
- }
4231
- });
4232
- });
4233
- return function(n) {
4234
- return _ref.apply(this, arguments);
4235
- };
4236
- }()))
4237
- ];
4238
- case 17:
4239
- args = _state.sent();
4240
- return [
4241
- 2,
4242
- operator2.apply(void 0, [
4243
- expressionContext
4244
- ].concat(_to_consumable_array(args)))
4245
- ];
4246
- case 18:
4247
- if (node.type === "ModelRef") {
4248
- return [
4249
- 2,
4250
- model.get(node.ref, {
4251
- context: {
4252
- model: options.model
4253
- }
4254
- })
4255
- ];
4256
- }
4257
- if (!(node.type === "MemberExpression")) return [
4258
- 3,
4259
- 21
4260
- ];
4261
- return [
4262
- 4,
4263
- resolveNode(node.object)
4264
- ];
4265
- case 19:
4266
- obj = _state.sent();
4267
- return [
4268
- 4,
4269
- resolveNode(node.property)
4270
- ];
4271
- case 20:
4272
- prop = _state.sent();
4273
- return [
4274
- 2,
4275
- obj[prop]
4276
- ];
4277
- case 21:
4278
- if (!(node.type === "Assignment")) return [
4279
- 3,
4280
- 26
4281
- ];
4282
- if (!(node.left.type === "ModelRef")) return [
4283
- 3,
4284
- 23
4285
- ];
4286
- return [
4287
- 4,
4288
- resolveNode(node.right)
4289
- ];
4290
- case 22:
4291
- value = _state.sent();
4292
- model.set([
4293
- [
4294
- node.left.ref,
4295
- value
4296
- ]
4297
- ]);
4298
- return [
4299
- 2,
4300
- value
4301
- ];
4302
- case 23:
4303
- if (!(node.left.type === "Identifier")) return [
4304
- 3,
4305
- 25
4306
- ];
4307
- return [
4308
- 4,
4309
- resolveNode(node.right)
4310
- ];
4311
- case 24:
4312
- value1 = _state.sent();
4313
- _this.vars[node.left.name] = value1;
4314
- return [
4315
- 2,
4316
- value1
4317
- ];
4318
- case 25:
4319
- return [
4320
- 2
4321
- ];
4322
- case 26:
4323
- if (!(node.type === "ConditionalExpression")) return [
4324
- 3,
4325
- 28
4326
- ];
4327
- return [
4328
- 4,
4329
- resolveNode(node.test)
4330
- ];
4331
- case 27:
4332
- result = _state.sent() ? node.consequent : node.alternate;
4333
- return [
4334
- 2,
4335
- resolveNode(result)
4336
- ];
4337
- case 28:
4338
- if (node.type === "ArrayExpression") {
4339
- return [
4340
- 2,
4341
- Promise.all(node.elements.map(function() {
4342
- var _ref = _async_to_generator(function(ele) {
4343
- return _ts_generator(this, function(_state) {
4344
- switch(_state.label){
4345
- case 0:
4346
- return [
4347
- 4,
4348
- resolveNode(ele)
4349
- ];
4350
- case 1:
4351
- return [
4352
- 2,
4353
- _state.sent()
4354
- ];
4355
- }
4356
- });
4357
- });
4358
- return function(ele) {
4359
- return _ref.apply(this, arguments);
4360
- };
4361
- }()))
4362
- ];
4363
- }
4364
- if (!(node.type === "Modification")) return [
4365
- 3,
4366
- 38
4367
- ];
4368
- operation = _this.operators.binary.get(node.operator);
4369
- if (!operation) return [
4370
- 3,
4371
- 37
4372
- ];
4373
- if (!("resolveParams" in operation)) return [
4374
- 3,
4375
- 33
4376
- ];
4377
- if (!(operation.resolveParams === false)) return [
4378
- 3,
4379
- 29
4380
- ];
4381
- newValue = operation(expressionContext, node.left, node.right);
4382
- return [
4383
- 3,
4384
- 32
4385
- ];
4386
- case 29:
4387
- _tmp4 = [
4388
- expressionContext
4389
- ];
4390
- return [
4391
- 4,
4392
- resolveNode(node.left)
4393
- ];
4394
- case 30:
4395
- _tmp4 = _tmp4.concat([
4396
- _state.sent()
4397
- ]);
4398
- return [
4399
- 4,
4400
- resolveNode(node.right)
4401
- ];
4402
- case 31:
4403
- newValue = operation.apply(void 0, _tmp4.concat([
4404
- _state.sent()
4405
- ]));
4406
- _state.label = 32;
4407
- case 32:
4408
- return [
4409
- 3,
4410
- 36
4411
- ];
4412
- case 33:
4413
- return [
4414
- 4,
4415
- resolveNode(node.left)
4416
- ];
4417
- case 34:
4418
- _tmp5 = [
4419
- _state.sent()
4420
- ];
4421
- return [
4422
- 4,
4423
- resolveNode(node.right)
4424
- ];
4425
- case 35:
4426
- newValue = operation.apply(void 0, _tmp5.concat([
4427
- _state.sent()
4428
- ]));
4429
- _state.label = 36;
4430
- case 36:
4431
- if (node.left.type === "ModelRef") {
4432
- model.set([
4433
- [
4434
- node.left.ref,
4435
- newValue
4436
- ]
4437
- ]);
4438
- } else if (node.left.type === "Identifier") {
4439
- _this.vars[node.left.name] = newValue;
4440
- }
4441
- return [
4442
- 2,
4443
- newValue
4444
- ];
4445
- case 37:
4446
- return [
4447
- 2,
4448
- resolveNode(node.left)
4449
- ];
4450
- case 38:
4451
- return [
4452
- 2,
4453
- _this._resolveNode(_currentValue, node, options)
4454
- ];
4455
- }
4456
- });
4457
- })();
4458
- }
4459
3969
  }
4460
3970
  ]);
4461
3971
  return ExpressionEvaluator;
@@ -8020,56 +7530,15 @@ var AsyncNodePlugin = function() {
8020
7530
  validationController.reset();
8021
7531
  }
8022
7532
  });
8023
- flow.hooks.afterTransition.tap("player", function() {
8024
- var _ref = _async_to_generator(function(flowInstance) {
8025
- var _flowInstance_currentState, value, exp, result, e;
8026
- return _ts_generator(this, function(_state) {
8027
- switch(_state.label){
8028
- case 0:
8029
- value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
8030
- if (!(value && value.state_type === "ACTION")) return [
8031
- 3,
8032
- 4
8033
- ];
8034
- exp = value.exp;
8035
- _state.label = 1;
8036
- case 1:
8037
- _state.trys.push([
8038
- 1,
8039
- 3,
8040
- ,
8041
- 4
8042
- ]);
8043
- return [
8044
- 4,
8045
- expressionEvaluator.evaluateAsync(exp)
8046
- ];
8047
- case 2:
8048
- result = _state.sent();
8049
- flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
8050
- return [
8051
- 3,
8052
- 4
8053
- ];
8054
- case 3:
8055
- e = _state.sent();
8056
- flowResultDeferred.reject(e);
8057
- return [
8058
- 3,
8059
- 4
8060
- ];
8061
- case 4:
8062
- expressionEvaluator.reset();
8063
- return [
8064
- 2
8065
- ];
8066
- }
8067
- });
8068
- });
8069
- return function(flowInstance) {
8070
- return _ref.apply(this, arguments);
8071
- };
8072
- }());
7533
+ flow.hooks.afterTransition.tap("player", function(flowInstance) {
7534
+ var _flowInstance_currentState;
7535
+ var value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
7536
+ if (value && value.state_type === "ACTION") {
7537
+ var exp = value.exp;
7538
+ flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(expressionEvaluator === null || expressionEvaluator === void 0 ? void 0 : expressionEvaluator.evaluate(exp)));
7539
+ }
7540
+ expressionEvaluator.reset();
7541
+ });
8073
7542
  });
8074
7543
  this.hooks.dataController.call(dataController);
8075
7544
  validationController.setOptions({