@player-ui/player 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.
@@ -3552,9 +3552,6 @@ var Player = function() {
3552
3552
  },
3553
3553
  setDataVal: function() {
3554
3554
  return setDataVal;
3555
- },
3556
- waitFor: function() {
3557
- return waitFor;
3558
3555
  }
3559
3556
  });
3560
3557
  var setDataVal = function(_context, binding, value) {
@@ -3582,27 +3579,6 @@ var Player = function() {
3582
3579
  return null;
3583
3580
  };
3584
3581
  conditional.resolveParams = false;
3585
- var waitFor = function() {
3586
- var _ref = _async_to_generator(function(ctx, promise) {
3587
- return _ts_generator(this, function(_state) {
3588
- switch(_state.label){
3589
- case 0:
3590
- return [
3591
- 4,
3592
- promise
3593
- ];
3594
- case 1:
3595
- return [
3596
- 2,
3597
- _state.sent()
3598
- ];
3599
- }
3600
- });
3601
- });
3602
- return function waitFor(ctx, promise) {
3603
- return _ref.apply(this, arguments);
3604
- };
3605
- }();
3606
3582
  function findClosestNodeAtPosition(node, position) {
3607
3583
  switch(node.type){
3608
3584
  case "Modification":
@@ -3788,12 +3764,7 @@ var Player = function() {
3788
3764
  this.operators = {
3789
3765
  binary: new Map(Object.entries(DEFAULT_BINARY_OPERATORS)),
3790
3766
  unary: new Map(Object.entries(DEFAULT_UNARY_OPERATORS)),
3791
- expressions: new Map(_to_consumable_array(Object.entries(evaluator_functions_exports)).concat([
3792
- [
3793
- "await",
3794
- waitFor
3795
- ]
3796
- ]))
3767
+ expressions: new Map(Object.entries(evaluator_functions_exports))
3797
3768
  };
3798
3769
  this.defaultHookOptions = _object_spread_props(_object_spread({}, defaultOptions), {
3799
3770
  evaluate: function(expr) {
@@ -3803,12 +3774,7 @@ var Player = function() {
3803
3774
  return _this._execAST(node, _this.defaultHookOptions);
3804
3775
  }
3805
3776
  });
3806
- this.hooks.resolve.tap("ExpressionEvaluator", function(result, node, options) {
3807
- if (options.async) {
3808
- return _this._resolveNodeAsync(result, node, options);
3809
- }
3810
- return _this._resolveNode(result, node, options);
3811
- });
3777
+ this.hooks.resolve.tap("ExpressionEvaluator", this._resolveNode.bind(this));
3812
3778
  this.evaluate = this.evaluate.bind(this);
3813
3779
  }
3814
3780
  _create_class(ExpressionEvaluator, [
@@ -3846,14 +3812,6 @@ var Player = function() {
3846
3812
  return this._execString(String(expression), resolvedOpts);
3847
3813
  }
3848
3814
  },
3849
- {
3850
- key: "evaluateAsync",
3851
- value: function evaluateAsync(expr, options) {
3852
- return this.evaluate(expr, _object_spread_props(_object_spread({}, options), {
3853
- async: true
3854
- }));
3855
- }
3856
- },
3857
3815
  {
3858
3816
  key: "addExpressionFunction",
3859
3817
  value: function addExpressionFunction(name, handler) {
@@ -3899,10 +3857,8 @@ var Player = function() {
3899
3857
  var matches = exp.match(/^@\[(.*)\]@$/);
3900
3858
  var matchedExp = exp;
3901
3859
  if (matches) {
3902
- var _Array_from = _sliced_to_array(Array.from(matches), 2), matched = _Array_from[1];
3903
- if (matched) {
3904
- matchedExp = matched;
3905
- }
3860
+ var ref;
3861
+ ref = _sliced_to_array(Array.from(matches), 2), matchedExp = ref[1], ref;
3906
3862
  }
3907
3863
  var storedAST;
3908
3864
  try {
@@ -4063,452 +4019,6 @@ var Player = function() {
4063
4019
  return resolveNode(node.left);
4064
4020
  }
4065
4021
  }
4066
- },
4067
- {
4068
- key: "_resolveNodeAsync",
4069
- value: function _resolveNodeAsync(_currentValue, node, options) {
4070
- var _this = this;
4071
- return _async_to_generator(function() {
4072
- var resolveNode, model, expressionContext, operator, _tmp, _tmp1, operator1, _tmp2, _tmp3, attributes, resolvedAttributes, expressionName, operator2, args, obj, prop, value, value1, result, operation, newValue, _tmp4, _tmp5;
4073
- return _ts_generator(this, function(_state) {
4074
- switch(_state.label){
4075
- case 0:
4076
- resolveNode = options.resolveNode, model = options.model;
4077
- expressionContext = _object_spread_props(_object_spread({}, options), {
4078
- evaluate: function(expr) {
4079
- return _this.evaluate(expr, options);
4080
- }
4081
- });
4082
- if (!(node.type === "BinaryExpression" || node.type === "LogicalExpression")) return [
4083
- 3,
4084
- 7
4085
- ];
4086
- operator = _this.operators.binary.get(node.operator);
4087
- if (!operator) return [
4088
- 3,
4089
- 6
4090
- ];
4091
- if (!("resolveParams" in operator)) return [
4092
- 3,
4093
- 3
4094
- ];
4095
- if (operator.resolveParams === false) {
4096
- return [
4097
- 2,
4098
- operator(expressionContext, node.left, node.right)
4099
- ];
4100
- }
4101
- _tmp = [
4102
- expressionContext
4103
- ];
4104
- return [
4105
- 4,
4106
- resolveNode(node.left)
4107
- ];
4108
- case 1:
4109
- _tmp = _tmp.concat([
4110
- _state.sent()
4111
- ]);
4112
- return [
4113
- 4,
4114
- resolveNode(node.right)
4115
- ];
4116
- case 2:
4117
- return [
4118
- 2,
4119
- operator.apply(void 0, _tmp.concat([
4120
- _state.sent()
4121
- ]))
4122
- ];
4123
- case 3:
4124
- return [
4125
- 4,
4126
- resolveNode(node.left)
4127
- ];
4128
- case 4:
4129
- _tmp1 = [
4130
- _state.sent()
4131
- ];
4132
- return [
4133
- 4,
4134
- resolveNode(node.right)
4135
- ];
4136
- case 5:
4137
- return [
4138
- 2,
4139
- operator.apply(void 0, _tmp1.concat([
4140
- _state.sent()
4141
- ]))
4142
- ];
4143
- case 6:
4144
- return [
4145
- 2
4146
- ];
4147
- case 7:
4148
- if (!(node.type === "UnaryExpression")) return [
4149
- 3,
4150
- 14
4151
- ];
4152
- operator1 = _this.operators.unary.get(node.operator);
4153
- if (!operator1) return [
4154
- 3,
4155
- 13
4156
- ];
4157
- if (!("resolveParams" in operator1)) return [
4158
- 3,
4159
- 11
4160
- ];
4161
- _tmp2 = [
4162
- expressionContext
4163
- ];
4164
- if (!(operator1.resolveParams === false)) return [
4165
- 3,
4166
- 8
4167
- ];
4168
- _tmp3 = node.argument;
4169
- return [
4170
- 3,
4171
- 10
4172
- ];
4173
- case 8:
4174
- return [
4175
- 4,
4176
- resolveNode(node.argument)
4177
- ];
4178
- case 9:
4179
- _tmp3 = _state.sent();
4180
- _state.label = 10;
4181
- case 10:
4182
- return [
4183
- 2,
4184
- operator1.apply(void 0, _tmp2.concat([
4185
- _tmp3
4186
- ]))
4187
- ];
4188
- case 11:
4189
- return [
4190
- 4,
4191
- resolveNode(node.argument)
4192
- ];
4193
- case 12:
4194
- return [
4195
- 2,
4196
- operator1.apply(void 0, [
4197
- _state.sent()
4198
- ])
4199
- ];
4200
- case 13:
4201
- return [
4202
- 2
4203
- ];
4204
- case 14:
4205
- if (!(node.type === "Object")) return [
4206
- 3,
4207
- 16
4208
- ];
4209
- attributes = node.attributes;
4210
- resolvedAttributes = {};
4211
- return [
4212
- 4,
4213
- Promise.all(attributes.map(function() {
4214
- var _ref = _async_to_generator(function(attr) {
4215
- var key, value;
4216
- return _ts_generator(this, function(_state) {
4217
- switch(_state.label){
4218
- case 0:
4219
- return [
4220
- 4,
4221
- resolveNode(attr.key)
4222
- ];
4223
- case 1:
4224
- key = _state.sent();
4225
- return [
4226
- 4,
4227
- resolveNode(attr.value)
4228
- ];
4229
- case 2:
4230
- value = _state.sent();
4231
- resolvedAttributes[key] = value;
4232
- return [
4233
- 2
4234
- ];
4235
- }
4236
- });
4237
- });
4238
- return function(attr) {
4239
- return _ref.apply(this, arguments);
4240
- };
4241
- }()))
4242
- ];
4243
- case 15:
4244
- _state.sent();
4245
- return [
4246
- 2,
4247
- resolvedAttributes
4248
- ];
4249
- case 16:
4250
- if (!(node.type === "CallExpression")) return [
4251
- 3,
4252
- 18
4253
- ];
4254
- expressionName = node.callTarget.name;
4255
- operator2 = _this.operators.expressions.get(expressionName);
4256
- if (!operator2) {
4257
- throw new Error("Unknown expression function: ".concat(expressionName));
4258
- }
4259
- if ("resolveParams" in operator2 && operator2.resolveParams === false) {
4260
- return [
4261
- 2,
4262
- operator2.apply(void 0, [
4263
- expressionContext
4264
- ].concat(_to_consumable_array(node.args)))
4265
- ];
4266
- }
4267
- return [
4268
- 4,
4269
- Promise.all(node.args.map(function() {
4270
- var _ref = _async_to_generator(function(n) {
4271
- return _ts_generator(this, function(_state) {
4272
- switch(_state.label){
4273
- case 0:
4274
- return [
4275
- 4,
4276
- resolveNode(n)
4277
- ];
4278
- case 1:
4279
- return [
4280
- 2,
4281
- _state.sent()
4282
- ];
4283
- }
4284
- });
4285
- });
4286
- return function(n) {
4287
- return _ref.apply(this, arguments);
4288
- };
4289
- }()))
4290
- ];
4291
- case 17:
4292
- args = _state.sent();
4293
- return [
4294
- 2,
4295
- operator2.apply(void 0, [
4296
- expressionContext
4297
- ].concat(_to_consumable_array(args)))
4298
- ];
4299
- case 18:
4300
- if (node.type === "ModelRef") {
4301
- return [
4302
- 2,
4303
- model.get(node.ref, {
4304
- context: {
4305
- model: options.model
4306
- }
4307
- })
4308
- ];
4309
- }
4310
- if (!(node.type === "MemberExpression")) return [
4311
- 3,
4312
- 21
4313
- ];
4314
- return [
4315
- 4,
4316
- resolveNode(node.object)
4317
- ];
4318
- case 19:
4319
- obj = _state.sent();
4320
- return [
4321
- 4,
4322
- resolveNode(node.property)
4323
- ];
4324
- case 20:
4325
- prop = _state.sent();
4326
- return [
4327
- 2,
4328
- obj[prop]
4329
- ];
4330
- case 21:
4331
- if (!(node.type === "Assignment")) return [
4332
- 3,
4333
- 26
4334
- ];
4335
- if (!(node.left.type === "ModelRef")) return [
4336
- 3,
4337
- 23
4338
- ];
4339
- return [
4340
- 4,
4341
- resolveNode(node.right)
4342
- ];
4343
- case 22:
4344
- value = _state.sent();
4345
- model.set([
4346
- [
4347
- node.left.ref,
4348
- value
4349
- ]
4350
- ]);
4351
- return [
4352
- 2,
4353
- value
4354
- ];
4355
- case 23:
4356
- if (!(node.left.type === "Identifier")) return [
4357
- 3,
4358
- 25
4359
- ];
4360
- return [
4361
- 4,
4362
- resolveNode(node.right)
4363
- ];
4364
- case 24:
4365
- value1 = _state.sent();
4366
- _this.vars[node.left.name] = value1;
4367
- return [
4368
- 2,
4369
- value1
4370
- ];
4371
- case 25:
4372
- return [
4373
- 2
4374
- ];
4375
- case 26:
4376
- if (!(node.type === "ConditionalExpression")) return [
4377
- 3,
4378
- 28
4379
- ];
4380
- return [
4381
- 4,
4382
- resolveNode(node.test)
4383
- ];
4384
- case 27:
4385
- result = _state.sent() ? node.consequent : node.alternate;
4386
- return [
4387
- 2,
4388
- resolveNode(result)
4389
- ];
4390
- case 28:
4391
- if (node.type === "ArrayExpression") {
4392
- return [
4393
- 2,
4394
- Promise.all(node.elements.map(function() {
4395
- var _ref = _async_to_generator(function(ele) {
4396
- return _ts_generator(this, function(_state) {
4397
- switch(_state.label){
4398
- case 0:
4399
- return [
4400
- 4,
4401
- resolveNode(ele)
4402
- ];
4403
- case 1:
4404
- return [
4405
- 2,
4406
- _state.sent()
4407
- ];
4408
- }
4409
- });
4410
- });
4411
- return function(ele) {
4412
- return _ref.apply(this, arguments);
4413
- };
4414
- }()))
4415
- ];
4416
- }
4417
- if (!(node.type === "Modification")) return [
4418
- 3,
4419
- 38
4420
- ];
4421
- operation = _this.operators.binary.get(node.operator);
4422
- if (!operation) return [
4423
- 3,
4424
- 37
4425
- ];
4426
- if (!("resolveParams" in operation)) return [
4427
- 3,
4428
- 33
4429
- ];
4430
- if (!(operation.resolveParams === false)) return [
4431
- 3,
4432
- 29
4433
- ];
4434
- newValue = operation(expressionContext, node.left, node.right);
4435
- return [
4436
- 3,
4437
- 32
4438
- ];
4439
- case 29:
4440
- _tmp4 = [
4441
- expressionContext
4442
- ];
4443
- return [
4444
- 4,
4445
- resolveNode(node.left)
4446
- ];
4447
- case 30:
4448
- _tmp4 = _tmp4.concat([
4449
- _state.sent()
4450
- ]);
4451
- return [
4452
- 4,
4453
- resolveNode(node.right)
4454
- ];
4455
- case 31:
4456
- newValue = operation.apply(void 0, _tmp4.concat([
4457
- _state.sent()
4458
- ]));
4459
- _state.label = 32;
4460
- case 32:
4461
- return [
4462
- 3,
4463
- 36
4464
- ];
4465
- case 33:
4466
- return [
4467
- 4,
4468
- resolveNode(node.left)
4469
- ];
4470
- case 34:
4471
- _tmp5 = [
4472
- _state.sent()
4473
- ];
4474
- return [
4475
- 4,
4476
- resolveNode(node.right)
4477
- ];
4478
- case 35:
4479
- newValue = operation.apply(void 0, _tmp5.concat([
4480
- _state.sent()
4481
- ]));
4482
- _state.label = 36;
4483
- case 36:
4484
- if (node.left.type === "ModelRef") {
4485
- model.set([
4486
- [
4487
- node.left.ref,
4488
- newValue
4489
- ]
4490
- ]);
4491
- } else if (node.left.type === "Identifier") {
4492
- _this.vars[node.left.name] = newValue;
4493
- }
4494
- return [
4495
- 2,
4496
- newValue
4497
- ];
4498
- case 37:
4499
- return [
4500
- 2,
4501
- resolveNode(node.left)
4502
- ];
4503
- case 38:
4504
- return [
4505
- 2,
4506
- _this._resolveNode(_currentValue, node, options)
4507
- ];
4508
- }
4509
- });
4510
- })();
4511
- }
4512
4022
  }
4513
4023
  ]);
4514
4024
  return ExpressionEvaluator;
@@ -8430,56 +7940,15 @@ var Player = function() {
8430
7940
  validationController.reset();
8431
7941
  }
8432
7942
  });
8433
- flow.hooks.afterTransition.tap("player", function() {
8434
- var _ref = _async_to_generator(function(flowInstance) {
8435
- var _flowInstance_currentState, value, exp, result, e;
8436
- return _ts_generator(this, function(_state) {
8437
- switch(_state.label){
8438
- case 0:
8439
- value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
8440
- if (!(value && value.state_type === "ACTION")) return [
8441
- 3,
8442
- 4
8443
- ];
8444
- exp = value.exp;
8445
- _state.label = 1;
8446
- case 1:
8447
- _state.trys.push([
8448
- 1,
8449
- 3,
8450
- ,
8451
- 4
8452
- ]);
8453
- return [
8454
- 4,
8455
- expressionEvaluator.evaluateAsync(exp)
8456
- ];
8457
- case 2:
8458
- result = _state.sent();
8459
- flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(result));
8460
- return [
8461
- 3,
8462
- 4
8463
- ];
8464
- case 3:
8465
- e = _state.sent();
8466
- flowResultDeferred.reject(e);
8467
- return [
8468
- 3,
8469
- 4
8470
- ];
8471
- case 4:
8472
- expressionEvaluator.reset();
8473
- return [
8474
- 2
8475
- ];
8476
- }
8477
- });
8478
- });
8479
- return function(flowInstance) {
8480
- return _ref.apply(this, arguments);
8481
- };
8482
- }());
7943
+ flow.hooks.afterTransition.tap("player", function(flowInstance) {
7944
+ var _flowInstance_currentState;
7945
+ var value = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.value;
7946
+ if (value && value.state_type === "ACTION") {
7947
+ var exp = value.exp;
7948
+ flowController === null || flowController === void 0 ? void 0 : flowController.transition(String(expressionEvaluator === null || expressionEvaluator === void 0 ? void 0 : expressionEvaluator.evaluate(exp)));
7949
+ }
7950
+ expressionEvaluator.reset();
7951
+ });
8483
7952
  });
8484
7953
  this.hooks.dataController.call(dataController);
8485
7954
  validationController.setOptions({