@player-ui/stage-revert-data-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.
@@ -3512,9 +3512,6 @@ var StageRevertDataPlugin = function() {
3512
3512
  },
3513
3513
  setDataVal: function() {
3514
3514
  return setDataVal;
3515
- },
3516
- waitFor: function() {
3517
- return waitFor;
3518
3515
  }
3519
3516
  });
3520
3517
  var setDataVal = function(_context, binding, value) {
@@ -3542,27 +3539,6 @@ var StageRevertDataPlugin = function() {
3542
3539
  return null;
3543
3540
  };
3544
3541
  conditional.resolveParams = false;
3545
- var waitFor = function() {
3546
- var _ref = _async_to_generator(function(ctx, promise) {
3547
- return _ts_generator(this, function(_state) {
3548
- switch(_state.label){
3549
- case 0:
3550
- return [
3551
- 4,
3552
- promise
3553
- ];
3554
- case 1:
3555
- return [
3556
- 2,
3557
- _state.sent()
3558
- ];
3559
- }
3560
- });
3561
- });
3562
- return function waitFor(ctx, promise) {
3563
- return _ref.apply(this, arguments);
3564
- };
3565
- }();
3566
3542
  var andandOperator = function(ctx, a, b) {
3567
3543
  return ctx.evaluate(a) && ctx.evaluate(b);
3568
3544
  };
@@ -3668,12 +3644,7 @@ var StageRevertDataPlugin = function() {
3668
3644
  this.operators = {
3669
3645
  binary: new Map(Object.entries(DEFAULT_BINARY_OPERATORS)),
3670
3646
  unary: new Map(Object.entries(DEFAULT_UNARY_OPERATORS)),
3671
- expressions: new Map(_to_consumable_array(Object.entries(evaluator_functions_exports)).concat([
3672
- [
3673
- "await",
3674
- waitFor
3675
- ]
3676
- ]))
3647
+ expressions: new Map(Object.entries(evaluator_functions_exports))
3677
3648
  };
3678
3649
  this.defaultHookOptions = _object_spread_props(_object_spread({}, defaultOptions), {
3679
3650
  evaluate: function(expr) {
@@ -3683,12 +3654,7 @@ var StageRevertDataPlugin = function() {
3683
3654
  return _this._execAST(node, _this.defaultHookOptions);
3684
3655
  }
3685
3656
  });
3686
- this.hooks.resolve.tap("ExpressionEvaluator", function(result, node, options) {
3687
- if (options.async) {
3688
- return _this._resolveNodeAsync(result, node, options);
3689
- }
3690
- return _this._resolveNode(result, node, options);
3691
- });
3657
+ this.hooks.resolve.tap("ExpressionEvaluator", this._resolveNode.bind(this));
3692
3658
  this.evaluate = this.evaluate.bind(this);
3693
3659
  }
3694
3660
  _create_class(ExpressionEvaluator, [
@@ -3726,14 +3692,6 @@ var StageRevertDataPlugin = function() {
3726
3692
  return this._execString(String(expression), resolvedOpts);
3727
3693
  }
3728
3694
  },
3729
- {
3730
- key: "evaluateAsync",
3731
- value: function evaluateAsync(expr, options) {
3732
- return this.evaluate(expr, _object_spread_props(_object_spread({}, options), {
3733
- async: true
3734
- }));
3735
- }
3736
- },
3737
3695
  {
3738
3696
  key: "addExpressionFunction",
3739
3697
  value: function addExpressionFunction(name, handler) {
@@ -3779,10 +3737,8 @@ var StageRevertDataPlugin = function() {
3779
3737
  var matches = exp.match(/^@\[(.*)\]@$/);
3780
3738
  var matchedExp = exp;
3781
3739
  if (matches) {
3782
- var _Array_from = _sliced_to_array(Array.from(matches), 2), matched = _Array_from[1];
3783
- if (matched) {
3784
- matchedExp = matched;
3785
- }
3740
+ var ref;
3741
+ ref = _sliced_to_array(Array.from(matches), 2), matchedExp = ref[1], ref;
3786
3742
  }
3787
3743
  var storedAST;
3788
3744
  try {
@@ -3943,452 +3899,6 @@ var StageRevertDataPlugin = function() {
3943
3899
  return resolveNode(node.left);
3944
3900
  }
3945
3901
  }
3946
- },
3947
- {
3948
- key: "_resolveNodeAsync",
3949
- value: function _resolveNodeAsync(_currentValue, node, options) {
3950
- var _this = this;
3951
- return _async_to_generator(function() {
3952
- var resolveNode, model, expressionContext, operator, _tmp, _tmp1, operator1, _tmp2, _tmp3, attributes, resolvedAttributes, expressionName, operator2, args, obj, prop, value, value1, result, operation, newValue, _tmp4, _tmp5;
3953
- return _ts_generator(this, function(_state) {
3954
- switch(_state.label){
3955
- case 0:
3956
- resolveNode = options.resolveNode, model = options.model;
3957
- expressionContext = _object_spread_props(_object_spread({}, options), {
3958
- evaluate: function(expr) {
3959
- return _this.evaluate(expr, options);
3960
- }
3961
- });
3962
- if (!(node.type === "BinaryExpression" || node.type === "LogicalExpression")) return [
3963
- 3,
3964
- 7
3965
- ];
3966
- operator = _this.operators.binary.get(node.operator);
3967
- if (!operator) return [
3968
- 3,
3969
- 6
3970
- ];
3971
- if (!("resolveParams" in operator)) return [
3972
- 3,
3973
- 3
3974
- ];
3975
- if (operator.resolveParams === false) {
3976
- return [
3977
- 2,
3978
- operator(expressionContext, node.left, node.right)
3979
- ];
3980
- }
3981
- _tmp = [
3982
- expressionContext
3983
- ];
3984
- return [
3985
- 4,
3986
- resolveNode(node.left)
3987
- ];
3988
- case 1:
3989
- _tmp = _tmp.concat([
3990
- _state.sent()
3991
- ]);
3992
- return [
3993
- 4,
3994
- resolveNode(node.right)
3995
- ];
3996
- case 2:
3997
- return [
3998
- 2,
3999
- operator.apply(void 0, _tmp.concat([
4000
- _state.sent()
4001
- ]))
4002
- ];
4003
- case 3:
4004
- return [
4005
- 4,
4006
- resolveNode(node.left)
4007
- ];
4008
- case 4:
4009
- _tmp1 = [
4010
- _state.sent()
4011
- ];
4012
- return [
4013
- 4,
4014
- resolveNode(node.right)
4015
- ];
4016
- case 5:
4017
- return [
4018
- 2,
4019
- operator.apply(void 0, _tmp1.concat([
4020
- _state.sent()
4021
- ]))
4022
- ];
4023
- case 6:
4024
- return [
4025
- 2
4026
- ];
4027
- case 7:
4028
- if (!(node.type === "UnaryExpression")) return [
4029
- 3,
4030
- 14
4031
- ];
4032
- operator1 = _this.operators.unary.get(node.operator);
4033
- if (!operator1) return [
4034
- 3,
4035
- 13
4036
- ];
4037
- if (!("resolveParams" in operator1)) return [
4038
- 3,
4039
- 11
4040
- ];
4041
- _tmp2 = [
4042
- expressionContext
4043
- ];
4044
- if (!(operator1.resolveParams === false)) return [
4045
- 3,
4046
- 8
4047
- ];
4048
- _tmp3 = node.argument;
4049
- return [
4050
- 3,
4051
- 10
4052
- ];
4053
- case 8:
4054
- return [
4055
- 4,
4056
- resolveNode(node.argument)
4057
- ];
4058
- case 9:
4059
- _tmp3 = _state.sent();
4060
- _state.label = 10;
4061
- case 10:
4062
- return [
4063
- 2,
4064
- operator1.apply(void 0, _tmp2.concat([
4065
- _tmp3
4066
- ]))
4067
- ];
4068
- case 11:
4069
- return [
4070
- 4,
4071
- resolveNode(node.argument)
4072
- ];
4073
- case 12:
4074
- return [
4075
- 2,
4076
- operator1.apply(void 0, [
4077
- _state.sent()
4078
- ])
4079
- ];
4080
- case 13:
4081
- return [
4082
- 2
4083
- ];
4084
- case 14:
4085
- if (!(node.type === "Object")) return [
4086
- 3,
4087
- 16
4088
- ];
4089
- attributes = node.attributes;
4090
- resolvedAttributes = {};
4091
- return [
4092
- 4,
4093
- Promise.all(attributes.map(function() {
4094
- var _ref = _async_to_generator(function(attr) {
4095
- var key, value;
4096
- return _ts_generator(this, function(_state) {
4097
- switch(_state.label){
4098
- case 0:
4099
- return [
4100
- 4,
4101
- resolveNode(attr.key)
4102
- ];
4103
- case 1:
4104
- key = _state.sent();
4105
- return [
4106
- 4,
4107
- resolveNode(attr.value)
4108
- ];
4109
- case 2:
4110
- value = _state.sent();
4111
- resolvedAttributes[key] = value;
4112
- return [
4113
- 2
4114
- ];
4115
- }
4116
- });
4117
- });
4118
- return function(attr) {
4119
- return _ref.apply(this, arguments);
4120
- };
4121
- }()))
4122
- ];
4123
- case 15:
4124
- _state.sent();
4125
- return [
4126
- 2,
4127
- resolvedAttributes
4128
- ];
4129
- case 16:
4130
- if (!(node.type === "CallExpression")) return [
4131
- 3,
4132
- 18
4133
- ];
4134
- expressionName = node.callTarget.name;
4135
- operator2 = _this.operators.expressions.get(expressionName);
4136
- if (!operator2) {
4137
- throw new Error("Unknown expression function: ".concat(expressionName));
4138
- }
4139
- if ("resolveParams" in operator2 && operator2.resolveParams === false) {
4140
- return [
4141
- 2,
4142
- operator2.apply(void 0, [
4143
- expressionContext
4144
- ].concat(_to_consumable_array(node.args)))
4145
- ];
4146
- }
4147
- return [
4148
- 4,
4149
- Promise.all(node.args.map(function() {
4150
- var _ref = _async_to_generator(function(n) {
4151
- return _ts_generator(this, function(_state) {
4152
- switch(_state.label){
4153
- case 0:
4154
- return [
4155
- 4,
4156
- resolveNode(n)
4157
- ];
4158
- case 1:
4159
- return [
4160
- 2,
4161
- _state.sent()
4162
- ];
4163
- }
4164
- });
4165
- });
4166
- return function(n) {
4167
- return _ref.apply(this, arguments);
4168
- };
4169
- }()))
4170
- ];
4171
- case 17:
4172
- args = _state.sent();
4173
- return [
4174
- 2,
4175
- operator2.apply(void 0, [
4176
- expressionContext
4177
- ].concat(_to_consumable_array(args)))
4178
- ];
4179
- case 18:
4180
- if (node.type === "ModelRef") {
4181
- return [
4182
- 2,
4183
- model.get(node.ref, {
4184
- context: {
4185
- model: options.model
4186
- }
4187
- })
4188
- ];
4189
- }
4190
- if (!(node.type === "MemberExpression")) return [
4191
- 3,
4192
- 21
4193
- ];
4194
- return [
4195
- 4,
4196
- resolveNode(node.object)
4197
- ];
4198
- case 19:
4199
- obj = _state.sent();
4200
- return [
4201
- 4,
4202
- resolveNode(node.property)
4203
- ];
4204
- case 20:
4205
- prop = _state.sent();
4206
- return [
4207
- 2,
4208
- obj[prop]
4209
- ];
4210
- case 21:
4211
- if (!(node.type === "Assignment")) return [
4212
- 3,
4213
- 26
4214
- ];
4215
- if (!(node.left.type === "ModelRef")) return [
4216
- 3,
4217
- 23
4218
- ];
4219
- return [
4220
- 4,
4221
- resolveNode(node.right)
4222
- ];
4223
- case 22:
4224
- value = _state.sent();
4225
- model.set([
4226
- [
4227
- node.left.ref,
4228
- value
4229
- ]
4230
- ]);
4231
- return [
4232
- 2,
4233
- value
4234
- ];
4235
- case 23:
4236
- if (!(node.left.type === "Identifier")) return [
4237
- 3,
4238
- 25
4239
- ];
4240
- return [
4241
- 4,
4242
- resolveNode(node.right)
4243
- ];
4244
- case 24:
4245
- value1 = _state.sent();
4246
- _this.vars[node.left.name] = value1;
4247
- return [
4248
- 2,
4249
- value1
4250
- ];
4251
- case 25:
4252
- return [
4253
- 2
4254
- ];
4255
- case 26:
4256
- if (!(node.type === "ConditionalExpression")) return [
4257
- 3,
4258
- 28
4259
- ];
4260
- return [
4261
- 4,
4262
- resolveNode(node.test)
4263
- ];
4264
- case 27:
4265
- result = _state.sent() ? node.consequent : node.alternate;
4266
- return [
4267
- 2,
4268
- resolveNode(result)
4269
- ];
4270
- case 28:
4271
- if (node.type === "ArrayExpression") {
4272
- return [
4273
- 2,
4274
- Promise.all(node.elements.map(function() {
4275
- var _ref = _async_to_generator(function(ele) {
4276
- return _ts_generator(this, function(_state) {
4277
- switch(_state.label){
4278
- case 0:
4279
- return [
4280
- 4,
4281
- resolveNode(ele)
4282
- ];
4283
- case 1:
4284
- return [
4285
- 2,
4286
- _state.sent()
4287
- ];
4288
- }
4289
- });
4290
- });
4291
- return function(ele) {
4292
- return _ref.apply(this, arguments);
4293
- };
4294
- }()))
4295
- ];
4296
- }
4297
- if (!(node.type === "Modification")) return [
4298
- 3,
4299
- 38
4300
- ];
4301
- operation = _this.operators.binary.get(node.operator);
4302
- if (!operation) return [
4303
- 3,
4304
- 37
4305
- ];
4306
- if (!("resolveParams" in operation)) return [
4307
- 3,
4308
- 33
4309
- ];
4310
- if (!(operation.resolveParams === false)) return [
4311
- 3,
4312
- 29
4313
- ];
4314
- newValue = operation(expressionContext, node.left, node.right);
4315
- return [
4316
- 3,
4317
- 32
4318
- ];
4319
- case 29:
4320
- _tmp4 = [
4321
- expressionContext
4322
- ];
4323
- return [
4324
- 4,
4325
- resolveNode(node.left)
4326
- ];
4327
- case 30:
4328
- _tmp4 = _tmp4.concat([
4329
- _state.sent()
4330
- ]);
4331
- return [
4332
- 4,
4333
- resolveNode(node.right)
4334
- ];
4335
- case 31:
4336
- newValue = operation.apply(void 0, _tmp4.concat([
4337
- _state.sent()
4338
- ]));
4339
- _state.label = 32;
4340
- case 32:
4341
- return [
4342
- 3,
4343
- 36
4344
- ];
4345
- case 33:
4346
- return [
4347
- 4,
4348
- resolveNode(node.left)
4349
- ];
4350
- case 34:
4351
- _tmp5 = [
4352
- _state.sent()
4353
- ];
4354
- return [
4355
- 4,
4356
- resolveNode(node.right)
4357
- ];
4358
- case 35:
4359
- newValue = operation.apply(void 0, _tmp5.concat([
4360
- _state.sent()
4361
- ]));
4362
- _state.label = 36;
4363
- case 36:
4364
- if (node.left.type === "ModelRef") {
4365
- model.set([
4366
- [
4367
- node.left.ref,
4368
- newValue
4369
- ]
4370
- ]);
4371
- } else if (node.left.type === "Identifier") {
4372
- _this.vars[node.left.name] = newValue;
4373
- }
4374
- return [
4375
- 2,
4376
- newValue
4377
- ];
4378
- case 37:
4379
- return [
4380
- 2,
4381
- resolveNode(node.left)
4382
- ];
4383
- case 38:
4384
- return [
4385
- 2,
4386
- _this._resolveNode(_currentValue, node, options)
4387
- ];
4388
- }
4389
- });
4390
- })();
4391
- }
4392
3902
  }
4393
3903
  ]);
4394
3904
  return ExpressionEvaluator;
@@ -7813,56 +7323,15 @@ var StageRevertDataPlugin = function() {
7813
7323
  validationController.reset();
7814
7324
  }
7815
7325
  });
7816
- flow.hooks.afterTransition.tap("player", function() {
7817
- var _ref = _async_to_generator(function(flowInstance) {
7818
- var _flowInstance_currentState, value, exp, result, e;
7819
- return _ts_generator(this, function(_state) {
7820
- switch(_state.label){
7821
- case 0:
7822
- value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
7823
- if (!(value && value.state_type === "ACTION")) return [
7824
- 3,
7825
- 4
7826
- ];
7827
- exp = value.exp;
7828
- _state.label = 1;
7829
- case 1:
7830
- _state.trys.push([
7831
- 1,
7832
- 3,
7833
- ,
7834
- 4
7835
- ]);
7836
- return [
7837
- 4,
7838
- expressionEvaluator.evaluateAsync(exp)
7839
- ];
7840
- case 2:
7841
- result = _state.sent();
7842
- flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
7843
- return [
7844
- 3,
7845
- 4
7846
- ];
7847
- case 3:
7848
- e = _state.sent();
7849
- flowResultDeferred.reject(e);
7850
- return [
7851
- 3,
7852
- 4
7853
- ];
7854
- case 4:
7855
- expressionEvaluator.reset();
7856
- return [
7857
- 2
7858
- ];
7859
- }
7860
- });
7861
- });
7862
- return function(flowInstance) {
7863
- return _ref.apply(this, arguments);
7864
- };
7865
- }());
7326
+ flow.hooks.afterTransition.tap("player", function(flowInstance) {
7327
+ var _flowInstance_currentState;
7328
+ var value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
7329
+ if (value && value.state_type === "ACTION") {
7330
+ var exp = value.exp;
7331
+ flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(expressionEvaluator === null || expressionEvaluator === void 0 ? void 0 : expressionEvaluator.evaluate(exp)));
7332
+ }
7333
+ expressionEvaluator.reset();
7334
+ });
7866
7335
  });
7867
7336
  this.hooks.dataController.call(dataController);
7868
7337
  validationController.setOptions({