@player-ui/check-path-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.
@@ -3534,9 +3534,6 @@ var CheckPathPlugin = function() {
3534
3534
  },
3535
3535
  setDataVal: function() {
3536
3536
  return setDataVal;
3537
- },
3538
- waitFor: function() {
3539
- return waitFor;
3540
3537
  }
3541
3538
  });
3542
3539
  var setDataVal = function(_context, binding, value) {
@@ -3564,27 +3561,6 @@ var CheckPathPlugin = function() {
3564
3561
  return null;
3565
3562
  };
3566
3563
  conditional.resolveParams = false;
3567
- var waitFor = function() {
3568
- var _ref = _async_to_generator(function(ctx, promise) {
3569
- return _ts_generator(this, function(_state) {
3570
- switch(_state.label){
3571
- case 0:
3572
- return [
3573
- 4,
3574
- promise
3575
- ];
3576
- case 1:
3577
- return [
3578
- 2,
3579
- _state.sent()
3580
- ];
3581
- }
3582
- });
3583
- });
3584
- return function waitFor(ctx, promise) {
3585
- return _ref.apply(this, arguments);
3586
- };
3587
- }();
3588
3564
  var andandOperator = function(ctx, a, b) {
3589
3565
  return ctx.evaluate(a) && ctx.evaluate(b);
3590
3566
  };
@@ -3690,12 +3666,7 @@ var CheckPathPlugin = function() {
3690
3666
  this.operators = {
3691
3667
  binary: new Map(Object.entries(DEFAULT_BINARY_OPERATORS)),
3692
3668
  unary: new Map(Object.entries(DEFAULT_UNARY_OPERATORS)),
3693
- expressions: new Map(_to_consumable_array(Object.entries(evaluator_functions_exports)).concat([
3694
- [
3695
- "await",
3696
- waitFor
3697
- ]
3698
- ]))
3669
+ expressions: new Map(Object.entries(evaluator_functions_exports))
3699
3670
  };
3700
3671
  this.defaultHookOptions = _object_spread_props(_object_spread({}, defaultOptions), {
3701
3672
  evaluate: function(expr) {
@@ -3705,12 +3676,7 @@ var CheckPathPlugin = function() {
3705
3676
  return _this._execAST(node, _this.defaultHookOptions);
3706
3677
  }
3707
3678
  });
3708
- this.hooks.resolve.tap("ExpressionEvaluator", function(result, node, options) {
3709
- if (options.async) {
3710
- return _this._resolveNodeAsync(result, node, options);
3711
- }
3712
- return _this._resolveNode(result, node, options);
3713
- });
3679
+ this.hooks.resolve.tap("ExpressionEvaluator", this._resolveNode.bind(this));
3714
3680
  this.evaluate = this.evaluate.bind(this);
3715
3681
  }
3716
3682
  _create_class(ExpressionEvaluator, [
@@ -3748,14 +3714,6 @@ var CheckPathPlugin = function() {
3748
3714
  return this._execString(String(expression), resolvedOpts);
3749
3715
  }
3750
3716
  },
3751
- {
3752
- key: "evaluateAsync",
3753
- value: function evaluateAsync(expr, options) {
3754
- return this.evaluate(expr, _object_spread_props(_object_spread({}, options), {
3755
- async: true
3756
- }));
3757
- }
3758
- },
3759
3717
  {
3760
3718
  key: "addExpressionFunction",
3761
3719
  value: function addExpressionFunction(name, handler) {
@@ -3801,10 +3759,8 @@ var CheckPathPlugin = function() {
3801
3759
  var matches = exp.match(/^@\[(.*)\]@$/);
3802
3760
  var matchedExp = exp;
3803
3761
  if (matches) {
3804
- var _Array_from = _sliced_to_array(Array.from(matches), 2), matched = _Array_from[1];
3805
- if (matched) {
3806
- matchedExp = matched;
3807
- }
3762
+ var ref;
3763
+ ref = _sliced_to_array(Array.from(matches), 2), matchedExp = ref[1], ref;
3808
3764
  }
3809
3765
  var storedAST;
3810
3766
  try {
@@ -3965,452 +3921,6 @@ var CheckPathPlugin = function() {
3965
3921
  return resolveNode(node.left);
3966
3922
  }
3967
3923
  }
3968
- },
3969
- {
3970
- key: "_resolveNodeAsync",
3971
- value: function _resolveNodeAsync(_currentValue, node, options) {
3972
- var _this = this;
3973
- return _async_to_generator(function() {
3974
- var resolveNode, model, expressionContext, operator, _tmp, _tmp1, operator1, _tmp2, _tmp3, attributes, resolvedAttributes, expressionName, operator2, args, obj, prop, value, value1, result, operation, newValue, _tmp4, _tmp5;
3975
- return _ts_generator(this, function(_state) {
3976
- switch(_state.label){
3977
- case 0:
3978
- resolveNode = options.resolveNode, model = options.model;
3979
- expressionContext = _object_spread_props(_object_spread({}, options), {
3980
- evaluate: function(expr) {
3981
- return _this.evaluate(expr, options);
3982
- }
3983
- });
3984
- if (!(node.type === "BinaryExpression" || node.type === "LogicalExpression")) return [
3985
- 3,
3986
- 7
3987
- ];
3988
- operator = _this.operators.binary.get(node.operator);
3989
- if (!operator) return [
3990
- 3,
3991
- 6
3992
- ];
3993
- if (!("resolveParams" in operator)) return [
3994
- 3,
3995
- 3
3996
- ];
3997
- if (operator.resolveParams === false) {
3998
- return [
3999
- 2,
4000
- operator(expressionContext, node.left, node.right)
4001
- ];
4002
- }
4003
- _tmp = [
4004
- expressionContext
4005
- ];
4006
- return [
4007
- 4,
4008
- resolveNode(node.left)
4009
- ];
4010
- case 1:
4011
- _tmp = _tmp.concat([
4012
- _state.sent()
4013
- ]);
4014
- return [
4015
- 4,
4016
- resolveNode(node.right)
4017
- ];
4018
- case 2:
4019
- return [
4020
- 2,
4021
- operator.apply(void 0, _tmp.concat([
4022
- _state.sent()
4023
- ]))
4024
- ];
4025
- case 3:
4026
- return [
4027
- 4,
4028
- resolveNode(node.left)
4029
- ];
4030
- case 4:
4031
- _tmp1 = [
4032
- _state.sent()
4033
- ];
4034
- return [
4035
- 4,
4036
- resolveNode(node.right)
4037
- ];
4038
- case 5:
4039
- return [
4040
- 2,
4041
- operator.apply(void 0, _tmp1.concat([
4042
- _state.sent()
4043
- ]))
4044
- ];
4045
- case 6:
4046
- return [
4047
- 2
4048
- ];
4049
- case 7:
4050
- if (!(node.type === "UnaryExpression")) return [
4051
- 3,
4052
- 14
4053
- ];
4054
- operator1 = _this.operators.unary.get(node.operator);
4055
- if (!operator1) return [
4056
- 3,
4057
- 13
4058
- ];
4059
- if (!("resolveParams" in operator1)) return [
4060
- 3,
4061
- 11
4062
- ];
4063
- _tmp2 = [
4064
- expressionContext
4065
- ];
4066
- if (!(operator1.resolveParams === false)) return [
4067
- 3,
4068
- 8
4069
- ];
4070
- _tmp3 = node.argument;
4071
- return [
4072
- 3,
4073
- 10
4074
- ];
4075
- case 8:
4076
- return [
4077
- 4,
4078
- resolveNode(node.argument)
4079
- ];
4080
- case 9:
4081
- _tmp3 = _state.sent();
4082
- _state.label = 10;
4083
- case 10:
4084
- return [
4085
- 2,
4086
- operator1.apply(void 0, _tmp2.concat([
4087
- _tmp3
4088
- ]))
4089
- ];
4090
- case 11:
4091
- return [
4092
- 4,
4093
- resolveNode(node.argument)
4094
- ];
4095
- case 12:
4096
- return [
4097
- 2,
4098
- operator1.apply(void 0, [
4099
- _state.sent()
4100
- ])
4101
- ];
4102
- case 13:
4103
- return [
4104
- 2
4105
- ];
4106
- case 14:
4107
- if (!(node.type === "Object")) return [
4108
- 3,
4109
- 16
4110
- ];
4111
- attributes = node.attributes;
4112
- resolvedAttributes = {};
4113
- return [
4114
- 4,
4115
- Promise.all(attributes.map(function() {
4116
- var _ref = _async_to_generator(function(attr) {
4117
- var key, value;
4118
- return _ts_generator(this, function(_state) {
4119
- switch(_state.label){
4120
- case 0:
4121
- return [
4122
- 4,
4123
- resolveNode(attr.key)
4124
- ];
4125
- case 1:
4126
- key = _state.sent();
4127
- return [
4128
- 4,
4129
- resolveNode(attr.value)
4130
- ];
4131
- case 2:
4132
- value = _state.sent();
4133
- resolvedAttributes[key] = value;
4134
- return [
4135
- 2
4136
- ];
4137
- }
4138
- });
4139
- });
4140
- return function(attr) {
4141
- return _ref.apply(this, arguments);
4142
- };
4143
- }()))
4144
- ];
4145
- case 15:
4146
- _state.sent();
4147
- return [
4148
- 2,
4149
- resolvedAttributes
4150
- ];
4151
- case 16:
4152
- if (!(node.type === "CallExpression")) return [
4153
- 3,
4154
- 18
4155
- ];
4156
- expressionName = node.callTarget.name;
4157
- operator2 = _this.operators.expressions.get(expressionName);
4158
- if (!operator2) {
4159
- throw new Error("Unknown expression function: ".concat(expressionName));
4160
- }
4161
- if ("resolveParams" in operator2 && operator2.resolveParams === false) {
4162
- return [
4163
- 2,
4164
- operator2.apply(void 0, [
4165
- expressionContext
4166
- ].concat(_to_consumable_array(node.args)))
4167
- ];
4168
- }
4169
- return [
4170
- 4,
4171
- Promise.all(node.args.map(function() {
4172
- var _ref = _async_to_generator(function(n) {
4173
- return _ts_generator(this, function(_state) {
4174
- switch(_state.label){
4175
- case 0:
4176
- return [
4177
- 4,
4178
- resolveNode(n)
4179
- ];
4180
- case 1:
4181
- return [
4182
- 2,
4183
- _state.sent()
4184
- ];
4185
- }
4186
- });
4187
- });
4188
- return function(n) {
4189
- return _ref.apply(this, arguments);
4190
- };
4191
- }()))
4192
- ];
4193
- case 17:
4194
- args = _state.sent();
4195
- return [
4196
- 2,
4197
- operator2.apply(void 0, [
4198
- expressionContext
4199
- ].concat(_to_consumable_array(args)))
4200
- ];
4201
- case 18:
4202
- if (node.type === "ModelRef") {
4203
- return [
4204
- 2,
4205
- model.get(node.ref, {
4206
- context: {
4207
- model: options.model
4208
- }
4209
- })
4210
- ];
4211
- }
4212
- if (!(node.type === "MemberExpression")) return [
4213
- 3,
4214
- 21
4215
- ];
4216
- return [
4217
- 4,
4218
- resolveNode(node.object)
4219
- ];
4220
- case 19:
4221
- obj = _state.sent();
4222
- return [
4223
- 4,
4224
- resolveNode(node.property)
4225
- ];
4226
- case 20:
4227
- prop = _state.sent();
4228
- return [
4229
- 2,
4230
- obj[prop]
4231
- ];
4232
- case 21:
4233
- if (!(node.type === "Assignment")) return [
4234
- 3,
4235
- 26
4236
- ];
4237
- if (!(node.left.type === "ModelRef")) return [
4238
- 3,
4239
- 23
4240
- ];
4241
- return [
4242
- 4,
4243
- resolveNode(node.right)
4244
- ];
4245
- case 22:
4246
- value = _state.sent();
4247
- model.set([
4248
- [
4249
- node.left.ref,
4250
- value
4251
- ]
4252
- ]);
4253
- return [
4254
- 2,
4255
- value
4256
- ];
4257
- case 23:
4258
- if (!(node.left.type === "Identifier")) return [
4259
- 3,
4260
- 25
4261
- ];
4262
- return [
4263
- 4,
4264
- resolveNode(node.right)
4265
- ];
4266
- case 24:
4267
- value1 = _state.sent();
4268
- _this.vars[node.left.name] = value1;
4269
- return [
4270
- 2,
4271
- value1
4272
- ];
4273
- case 25:
4274
- return [
4275
- 2
4276
- ];
4277
- case 26:
4278
- if (!(node.type === "ConditionalExpression")) return [
4279
- 3,
4280
- 28
4281
- ];
4282
- return [
4283
- 4,
4284
- resolveNode(node.test)
4285
- ];
4286
- case 27:
4287
- result = _state.sent() ? node.consequent : node.alternate;
4288
- return [
4289
- 2,
4290
- resolveNode(result)
4291
- ];
4292
- case 28:
4293
- if (node.type === "ArrayExpression") {
4294
- return [
4295
- 2,
4296
- Promise.all(node.elements.map(function() {
4297
- var _ref = _async_to_generator(function(ele) {
4298
- return _ts_generator(this, function(_state) {
4299
- switch(_state.label){
4300
- case 0:
4301
- return [
4302
- 4,
4303
- resolveNode(ele)
4304
- ];
4305
- case 1:
4306
- return [
4307
- 2,
4308
- _state.sent()
4309
- ];
4310
- }
4311
- });
4312
- });
4313
- return function(ele) {
4314
- return _ref.apply(this, arguments);
4315
- };
4316
- }()))
4317
- ];
4318
- }
4319
- if (!(node.type === "Modification")) return [
4320
- 3,
4321
- 38
4322
- ];
4323
- operation = _this.operators.binary.get(node.operator);
4324
- if (!operation) return [
4325
- 3,
4326
- 37
4327
- ];
4328
- if (!("resolveParams" in operation)) return [
4329
- 3,
4330
- 33
4331
- ];
4332
- if (!(operation.resolveParams === false)) return [
4333
- 3,
4334
- 29
4335
- ];
4336
- newValue = operation(expressionContext, node.left, node.right);
4337
- return [
4338
- 3,
4339
- 32
4340
- ];
4341
- case 29:
4342
- _tmp4 = [
4343
- expressionContext
4344
- ];
4345
- return [
4346
- 4,
4347
- resolveNode(node.left)
4348
- ];
4349
- case 30:
4350
- _tmp4 = _tmp4.concat([
4351
- _state.sent()
4352
- ]);
4353
- return [
4354
- 4,
4355
- resolveNode(node.right)
4356
- ];
4357
- case 31:
4358
- newValue = operation.apply(void 0, _tmp4.concat([
4359
- _state.sent()
4360
- ]));
4361
- _state.label = 32;
4362
- case 32:
4363
- return [
4364
- 3,
4365
- 36
4366
- ];
4367
- case 33:
4368
- return [
4369
- 4,
4370
- resolveNode(node.left)
4371
- ];
4372
- case 34:
4373
- _tmp5 = [
4374
- _state.sent()
4375
- ];
4376
- return [
4377
- 4,
4378
- resolveNode(node.right)
4379
- ];
4380
- case 35:
4381
- newValue = operation.apply(void 0, _tmp5.concat([
4382
- _state.sent()
4383
- ]));
4384
- _state.label = 36;
4385
- case 36:
4386
- if (node.left.type === "ModelRef") {
4387
- model.set([
4388
- [
4389
- node.left.ref,
4390
- newValue
4391
- ]
4392
- ]);
4393
- } else if (node.left.type === "Identifier") {
4394
- _this.vars[node.left.name] = newValue;
4395
- }
4396
- return [
4397
- 2,
4398
- newValue
4399
- ];
4400
- case 37:
4401
- return [
4402
- 2,
4403
- resolveNode(node.left)
4404
- ];
4405
- case 38:
4406
- return [
4407
- 2,
4408
- _this._resolveNode(_currentValue, node, options)
4409
- ];
4410
- }
4411
- });
4412
- })();
4413
- }
4414
3924
  }
4415
3925
  ]);
4416
3926
  return ExpressionEvaluator;
@@ -7848,56 +7358,15 @@ var CheckPathPlugin = function() {
7848
7358
  validationController.reset();
7849
7359
  }
7850
7360
  });
7851
- flow.hooks.afterTransition.tap("player", function() {
7852
- var _ref = _async_to_generator(function(flowInstance) {
7853
- var _flowInstance_currentState, value, exp, result, e;
7854
- return _ts_generator(this, function(_state) {
7855
- switch(_state.label){
7856
- case 0:
7857
- value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
7858
- if (!(value && value.state_type === "ACTION")) return [
7859
- 3,
7860
- 4
7861
- ];
7862
- exp = value.exp;
7863
- _state.label = 1;
7864
- case 1:
7865
- _state.trys.push([
7866
- 1,
7867
- 3,
7868
- ,
7869
- 4
7870
- ]);
7871
- return [
7872
- 4,
7873
- expressionEvaluator.evaluateAsync(exp)
7874
- ];
7875
- case 2:
7876
- result = _state.sent();
7877
- flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
7878
- return [
7879
- 3,
7880
- 4
7881
- ];
7882
- case 3:
7883
- e = _state.sent();
7884
- flowResultDeferred.reject(e);
7885
- return [
7886
- 3,
7887
- 4
7888
- ];
7889
- case 4:
7890
- expressionEvaluator.reset();
7891
- return [
7892
- 2
7893
- ];
7894
- }
7895
- });
7896
- });
7897
- return function(flowInstance) {
7898
- return _ref.apply(this, arguments);
7899
- };
7900
- }());
7361
+ flow.hooks.afterTransition.tap("player", function(flowInstance) {
7362
+ var _flowInstance_currentState;
7363
+ var value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
7364
+ if (value && value.state_type === "ACTION") {
7365
+ var exp = value.exp;
7366
+ flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(expressionEvaluator === null || expressionEvaluator === void 0 ? void 0 : expressionEvaluator.evaluate(exp)));
7367
+ }
7368
+ expressionEvaluator.reset();
7369
+ });
7901
7370
  });
7902
7371
  this.hooks.dataController.call(dataController);
7903
7372
  validationController.setOptions({