@player-ui/reference-assets-plugin 0.11.3--canary.649.23399 → 0.11.3--canary.649.23416

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.
@@ -3869,8 +3869,19 @@ var ReferenceAssetsPlugin = function() {
3869
3869
  return _context.model.delete(binding);
3870
3870
  };
3871
3871
  var conditional = function(ctx, condition, ifTrue, ifFalse) {
3872
- var resolution = ctx.evaluate(condition);
3873
- if (resolution) {
3872
+ var testResult = ctx.evaluate(condition);
3873
+ if (_instanceof(testResult, Promise)) {
3874
+ return testResult.then(function(resolvedTest) {
3875
+ if (resolvedTest) {
3876
+ return ctx.evaluate(ifTrue);
3877
+ }
3878
+ if (ifFalse) {
3879
+ return ctx.evaluate(ifFalse);
3880
+ }
3881
+ return null;
3882
+ });
3883
+ }
3884
+ if (testResult) {
3874
3885
  return ctx.evaluate(ifTrue);
3875
3886
  }
3876
3887
  if (ifFalse) {
@@ -4084,9 +4095,6 @@ var ReferenceAssetsPlugin = function() {
4084
4095
  }
4085
4096
  });
4086
4097
  this.hooks.resolve.tap("ExpressionEvaluator", function(result, node, options) {
4087
- if (options.async) {
4088
- return _this._resolveNodeAsync(result, node, options);
4089
- }
4090
4098
  return _this._resolveNode(result, node, options);
4091
4099
  });
4092
4100
  this.evaluate = this.evaluate.bind(this);
@@ -4232,9 +4240,31 @@ var ReferenceAssetsPlugin = function() {
4232
4240
  if (operator.resolveParams === false) {
4233
4241
  return operator(expressionContext, node.left, node.right);
4234
4242
  }
4235
- return operator(expressionContext, resolveNode(node.left), resolveNode(node.right));
4243
+ var left2 = resolveNode(node.left);
4244
+ var right2 = resolveNode(node.right);
4245
+ if (isPromiselike(left2) || isPromiselike(right2)) {
4246
+ return Promise.all([
4247
+ left2,
4248
+ right2
4249
+ ]).then(function(param) {
4250
+ var _param = _sliced_to_array(param, 2), leftVal = _param[0], rightVal = _param[1];
4251
+ return operator(expressionContext, leftVal, rightVal);
4252
+ });
4253
+ }
4254
+ return operator(expressionContext, left2, right2);
4255
+ }
4256
+ var left = resolveNode(node.left);
4257
+ var right = resolveNode(node.right);
4258
+ if (isPromiselike(left) || isPromiselike(right)) {
4259
+ return Promise.all([
4260
+ left,
4261
+ right
4262
+ ]).then(function(param) {
4263
+ var _param = _sliced_to_array(param, 2), leftVal = _param[0], rightVal = _param[1];
4264
+ return operator(leftVal, rightVal);
4265
+ });
4236
4266
  }
4237
- return operator(resolveNode(node.left), resolveNode(node.right));
4267
+ return operator(left, right);
4238
4268
  }
4239
4269
  return;
4240
4270
  }
@@ -4242,9 +4272,24 @@ var ReferenceAssetsPlugin = function() {
4242
4272
  var operator1 = this.operators.unary.get(node.operator);
4243
4273
  if (operator1) {
4244
4274
  if ("resolveParams" in operator1) {
4245
- return operator1(expressionContext, operator1.resolveParams === false ? node.argument : resolveNode(node.argument));
4275
+ if (operator1.resolveParams === false) {
4276
+ return operator1(expressionContext, node.argument);
4277
+ }
4278
+ var arg2 = resolveNode(node.argument);
4279
+ if (isPromiselike(arg2)) {
4280
+ return arg2.then(function(argVal) {
4281
+ return operator1(expressionContext, argVal);
4282
+ });
4283
+ }
4284
+ return operator1(expressionContext, arg2);
4246
4285
  }
4247
- return operator1(resolveNode(node.argument));
4286
+ var arg = resolveNode(node.argument);
4287
+ if (isPromiselike(arg)) {
4288
+ return arg.then(function(argVal) {
4289
+ return operator1(argVal);
4290
+ });
4291
+ }
4292
+ return operator1(arg);
4248
4293
  }
4249
4294
  return;
4250
4295
  }
@@ -4265,6 +4310,14 @@ var ReferenceAssetsPlugin = function() {
4265
4310
  var args = node.args.map(function(n) {
4266
4311
  return resolveNode(n);
4267
4312
  });
4313
+ var hasPromises = args.some(isPromiselike);
4314
+ if (hasPromises) {
4315
+ return Promise.all(args).then(function(resolvedArgs) {
4316
+ return operator2.apply(void 0, [
4317
+ expressionContext
4318
+ ].concat(_to_consumable_array(resolvedArgs)));
4319
+ });
4320
+ }
4268
4321
  return operator2.apply(void 0, [
4269
4322
  expressionContext
4270
4323
  ].concat(_to_consumable_array(args)));
@@ -4279,11 +4332,31 @@ var ReferenceAssetsPlugin = function() {
4279
4332
  if (node.type === "MemberExpression") {
4280
4333
  var obj = resolveNode(node.object);
4281
4334
  var prop = resolveNode(node.property);
4335
+ if (isPromiselike(obj) || isPromiselike(prop)) {
4336
+ return Promise.all([
4337
+ obj,
4338
+ prop
4339
+ ]).then(function(param) {
4340
+ var _param = _sliced_to_array(param, 2), objVal = _param[0], propVal = _param[1];
4341
+ return objVal[propVal];
4342
+ });
4343
+ }
4282
4344
  return obj[prop];
4283
4345
  }
4284
4346
  if (node.type === "Assignment") {
4285
4347
  if (node.left.type === "ModelRef") {
4286
4348
  var value = resolveNode(node.right);
4349
+ if (isPromiselike(value)) {
4350
+ return value.then(function(resolvedValue) {
4351
+ model.set([
4352
+ [
4353
+ node.left.ref,
4354
+ resolvedValue
4355
+ ]
4356
+ ]);
4357
+ return resolvedValue;
4358
+ });
4359
+ }
4287
4360
  model.set([
4288
4361
  [
4289
4362
  node.left.ref,
@@ -4294,6 +4367,12 @@ var ReferenceAssetsPlugin = function() {
4294
4367
  }
4295
4368
  if (node.left.type === "Identifier") {
4296
4369
  var value1 = resolveNode(node.right);
4370
+ if (isPromiselike(value1)) {
4371
+ return value1.then(function(resolvedValue) {
4372
+ _this.vars[node.left.name] = resolvedValue;
4373
+ return resolvedValue;
4374
+ });
4375
+ }
4297
4376
  this.vars[node.left.name] = value1;
4298
4377
  return value1;
4299
4378
  }
@@ -4321,12 +4400,47 @@ var ReferenceAssetsPlugin = function() {
4321
4400
  if (operation.resolveParams === false) {
4322
4401
  newValue = operation(expressionContext, node.left, node.right);
4323
4402
  } else {
4324
- newValue = operation(expressionContext, resolveNode(node.left), resolveNode(node.right));
4403
+ var left1 = resolveNode(node.left);
4404
+ var right1 = resolveNode(node.right);
4405
+ if (isPromiselike(left1) || isPromiselike(right1)) {
4406
+ newValue = Promise.all([
4407
+ left1,
4408
+ right1
4409
+ ]).then(function(param) {
4410
+ var _param = _sliced_to_array(param, 2), leftVal = _param[0], rightVal = _param[1];
4411
+ return operation(expressionContext, leftVal, rightVal);
4412
+ });
4413
+ } else {
4414
+ newValue = operation(expressionContext, left1, right1);
4415
+ }
4325
4416
  }
4326
4417
  } else {
4327
- newValue = operation(resolveNode(node.left), resolveNode(node.right));
4418
+ var left3 = resolveNode(node.left);
4419
+ var right3 = resolveNode(node.right);
4420
+ if (isPromiselike(left3) || isPromiselike(right3)) {
4421
+ newValue = Promise.all([
4422
+ left3,
4423
+ right3
4424
+ ]).then(function(param) {
4425
+ var _param = _sliced_to_array(param, 2), leftVal = _param[0], rightVal = _param[1];
4426
+ return operation(leftVal, rightVal);
4427
+ });
4428
+ } else {
4429
+ newValue = operation(left3, right3);
4430
+ }
4328
4431
  }
4329
4432
  if (node.left.type === "ModelRef") {
4433
+ if (isPromiselike(newValue)) {
4434
+ return newValue.then(function(resolvedValue) {
4435
+ model.set([
4436
+ [
4437
+ node.left.ref,
4438
+ resolvedValue
4439
+ ]
4440
+ ]);
4441
+ return resolvedValue;
4442
+ });
4443
+ }
4330
4444
  model.set([
4331
4445
  [
4332
4446
  node.left.ref,
@@ -4334,6 +4448,12 @@ var ReferenceAssetsPlugin = function() {
4334
4448
  ]
4335
4449
  ]);
4336
4450
  } else if (node.left.type === "Identifier") {
4451
+ if (isPromiselike(newValue)) {
4452
+ return newValue.then(function(resolvedValue) {
4453
+ _this.vars[node.left.name] = resolvedValue;
4454
+ return resolvedValue;
4455
+ });
4456
+ }
4337
4457
  this.vars[node.left.name] = newValue;
4338
4458
  }
4339
4459
  return newValue;
@@ -4341,459 +4461,6 @@ var ReferenceAssetsPlugin = function() {
4341
4461
  return resolveNode(node.left);
4342
4462
  }
4343
4463
  }
4344
- },
4345
- {
4346
- key: "_resolveNodeAsync",
4347
- value: function _resolveNodeAsync(_currentValue, node, options) {
4348
- var _this = this;
4349
- return _async_to_generator(function() {
4350
- var resolveNode, model, expressionContext, operator, _tmp, _tmp1, operator1, _tmp2, _tmp3, attributes, resolvedAttributes, expressionName, operator2, args, obj, prop, value, value1, testResult, result, branchResult, operation, newValue, _tmp4, _tmp5;
4351
- return _ts_generator(this, function(_state) {
4352
- switch(_state.label){
4353
- case 0:
4354
- resolveNode = options.resolveNode, model = options.model;
4355
- expressionContext = _object_spread_props(_object_spread({}, options), {
4356
- evaluate: function(expr) {
4357
- return _this.evaluate(expr, options);
4358
- }
4359
- });
4360
- if (!(node.type === "BinaryExpression" || node.type === "LogicalExpression")) return [
4361
- 3,
4362
- 7
4363
- ];
4364
- operator = _this.operators.binary.get(node.operator);
4365
- if (!operator) return [
4366
- 3,
4367
- 6
4368
- ];
4369
- if (!("resolveParams" in operator)) return [
4370
- 3,
4371
- 3
4372
- ];
4373
- if (operator.resolveParams === false) {
4374
- return [
4375
- 2,
4376
- operator(expressionContext, node.left, node.right)
4377
- ];
4378
- }
4379
- _tmp = [
4380
- expressionContext
4381
- ];
4382
- return [
4383
- 4,
4384
- resolveNode(node.left)
4385
- ];
4386
- case 1:
4387
- _tmp = _tmp.concat([
4388
- _state.sent()
4389
- ]);
4390
- return [
4391
- 4,
4392
- resolveNode(node.right)
4393
- ];
4394
- case 2:
4395
- return [
4396
- 2,
4397
- operator.apply(void 0, _tmp.concat([
4398
- _state.sent()
4399
- ]))
4400
- ];
4401
- case 3:
4402
- return [
4403
- 4,
4404
- resolveNode(node.left)
4405
- ];
4406
- case 4:
4407
- _tmp1 = [
4408
- _state.sent()
4409
- ];
4410
- return [
4411
- 4,
4412
- resolveNode(node.right)
4413
- ];
4414
- case 5:
4415
- return [
4416
- 2,
4417
- operator.apply(void 0, _tmp1.concat([
4418
- _state.sent()
4419
- ]))
4420
- ];
4421
- case 6:
4422
- return [
4423
- 2
4424
- ];
4425
- case 7:
4426
- if (!(node.type === "UnaryExpression")) return [
4427
- 3,
4428
- 14
4429
- ];
4430
- operator1 = _this.operators.unary.get(node.operator);
4431
- if (!operator1) return [
4432
- 3,
4433
- 13
4434
- ];
4435
- if (!("resolveParams" in operator1)) return [
4436
- 3,
4437
- 11
4438
- ];
4439
- _tmp2 = [
4440
- expressionContext
4441
- ];
4442
- if (!(operator1.resolveParams === false)) return [
4443
- 3,
4444
- 8
4445
- ];
4446
- _tmp3 = node.argument;
4447
- return [
4448
- 3,
4449
- 10
4450
- ];
4451
- case 8:
4452
- return [
4453
- 4,
4454
- resolveNode(node.argument)
4455
- ];
4456
- case 9:
4457
- _tmp3 = _state.sent();
4458
- _state.label = 10;
4459
- case 10:
4460
- return [
4461
- 2,
4462
- operator1.apply(void 0, _tmp2.concat([
4463
- _tmp3
4464
- ]))
4465
- ];
4466
- case 11:
4467
- return [
4468
- 4,
4469
- resolveNode(node.argument)
4470
- ];
4471
- case 12:
4472
- return [
4473
- 2,
4474
- operator1.apply(void 0, [
4475
- _state.sent()
4476
- ])
4477
- ];
4478
- case 13:
4479
- return [
4480
- 2
4481
- ];
4482
- case 14:
4483
- if (!(node.type === "Object")) return [
4484
- 3,
4485
- 16
4486
- ];
4487
- attributes = node.attributes;
4488
- resolvedAttributes = {};
4489
- return [
4490
- 4,
4491
- Promise.all(attributes.map(function() {
4492
- var _ref = _async_to_generator(function(attr) {
4493
- var key, value;
4494
- return _ts_generator(this, function(_state) {
4495
- switch(_state.label){
4496
- case 0:
4497
- return [
4498
- 4,
4499
- resolveNode(attr.key)
4500
- ];
4501
- case 1:
4502
- key = _state.sent();
4503
- return [
4504
- 4,
4505
- resolveNode(attr.value)
4506
- ];
4507
- case 2:
4508
- value = _state.sent();
4509
- resolvedAttributes[key] = value;
4510
- return [
4511
- 2
4512
- ];
4513
- }
4514
- });
4515
- });
4516
- return function(attr) {
4517
- return _ref.apply(this, arguments);
4518
- };
4519
- }()))
4520
- ];
4521
- case 15:
4522
- _state.sent();
4523
- return [
4524
- 2,
4525
- resolvedAttributes
4526
- ];
4527
- case 16:
4528
- if (!(node.type === "CallExpression")) return [
4529
- 3,
4530
- 18
4531
- ];
4532
- expressionName = node.callTarget.name;
4533
- operator2 = _this.operators.expressions.get(expressionName);
4534
- if (!operator2) {
4535
- throw new Error("Unknown expression function: ".concat(expressionName));
4536
- }
4537
- if ("resolveParams" in operator2 && operator2.resolveParams === false) {
4538
- return [
4539
- 2,
4540
- operator2.apply(void 0, [
4541
- expressionContext
4542
- ].concat(_to_consumable_array(node.args)))
4543
- ];
4544
- }
4545
- return [
4546
- 4,
4547
- Promise.all(node.args.map(function() {
4548
- var _ref = _async_to_generator(function(n) {
4549
- return _ts_generator(this, function(_state) {
4550
- switch(_state.label){
4551
- case 0:
4552
- return [
4553
- 4,
4554
- resolveNode(n)
4555
- ];
4556
- case 1:
4557
- return [
4558
- 2,
4559
- _state.sent()
4560
- ];
4561
- }
4562
- });
4563
- });
4564
- return function(n) {
4565
- return _ref.apply(this, arguments);
4566
- };
4567
- }()))
4568
- ];
4569
- case 17:
4570
- args = _state.sent();
4571
- return [
4572
- 2,
4573
- operator2.apply(void 0, [
4574
- expressionContext
4575
- ].concat(_to_consumable_array(args)))
4576
- ];
4577
- case 18:
4578
- if (node.type === "ModelRef") {
4579
- return [
4580
- 2,
4581
- model.get(node.ref, {
4582
- context: {
4583
- model: options.model
4584
- }
4585
- })
4586
- ];
4587
- }
4588
- if (!(node.type === "MemberExpression")) return [
4589
- 3,
4590
- 21
4591
- ];
4592
- return [
4593
- 4,
4594
- resolveNode(node.object)
4595
- ];
4596
- case 19:
4597
- obj = _state.sent();
4598
- return [
4599
- 4,
4600
- resolveNode(node.property)
4601
- ];
4602
- case 20:
4603
- prop = _state.sent();
4604
- return [
4605
- 2,
4606
- obj[prop]
4607
- ];
4608
- case 21:
4609
- if (!(node.type === "Assignment")) return [
4610
- 3,
4611
- 26
4612
- ];
4613
- if (!(node.left.type === "ModelRef")) return [
4614
- 3,
4615
- 23
4616
- ];
4617
- return [
4618
- 4,
4619
- resolveNode(node.right)
4620
- ];
4621
- case 22:
4622
- value = _state.sent();
4623
- model.set([
4624
- [
4625
- node.left.ref,
4626
- value
4627
- ]
4628
- ]);
4629
- return [
4630
- 2,
4631
- value
4632
- ];
4633
- case 23:
4634
- if (!(node.left.type === "Identifier")) return [
4635
- 3,
4636
- 25
4637
- ];
4638
- return [
4639
- 4,
4640
- resolveNode(node.right)
4641
- ];
4642
- case 24:
4643
- value1 = _state.sent();
4644
- _this.vars[node.left.name] = value1;
4645
- return [
4646
- 2,
4647
- value1
4648
- ];
4649
- case 25:
4650
- return [
4651
- 2
4652
- ];
4653
- case 26:
4654
- if (!(node.type === "ConditionalExpression")) return [
4655
- 3,
4656
- 29
4657
- ];
4658
- return [
4659
- 4,
4660
- resolveNode(node.test)
4661
- ];
4662
- case 27:
4663
- testResult = _state.sent();
4664
- result = testResult ? node.consequent : node.alternate;
4665
- return [
4666
- 4,
4667
- resolveNode(result)
4668
- ];
4669
- case 28:
4670
- branchResult = _state.sent();
4671
- return [
4672
- 2,
4673
- branchResult
4674
- ];
4675
- case 29:
4676
- if (node.type === "ArrayExpression") {
4677
- return [
4678
- 2,
4679
- Promise.all(node.elements.map(function() {
4680
- var _ref = _async_to_generator(function(ele) {
4681
- return _ts_generator(this, function(_state) {
4682
- switch(_state.label){
4683
- case 0:
4684
- return [
4685
- 4,
4686
- resolveNode(ele)
4687
- ];
4688
- case 1:
4689
- return [
4690
- 2,
4691
- _state.sent()
4692
- ];
4693
- }
4694
- });
4695
- });
4696
- return function(ele) {
4697
- return _ref.apply(this, arguments);
4698
- };
4699
- }()))
4700
- ];
4701
- }
4702
- if (!(node.type === "Modification")) return [
4703
- 3,
4704
- 39
4705
- ];
4706
- operation = _this.operators.binary.get(node.operator);
4707
- if (!operation) return [
4708
- 3,
4709
- 38
4710
- ];
4711
- if (!("resolveParams" in operation)) return [
4712
- 3,
4713
- 34
4714
- ];
4715
- if (!(operation.resolveParams === false)) return [
4716
- 3,
4717
- 30
4718
- ];
4719
- newValue = operation(expressionContext, node.left, node.right);
4720
- return [
4721
- 3,
4722
- 33
4723
- ];
4724
- case 30:
4725
- _tmp4 = [
4726
- expressionContext
4727
- ];
4728
- return [
4729
- 4,
4730
- resolveNode(node.left)
4731
- ];
4732
- case 31:
4733
- _tmp4 = _tmp4.concat([
4734
- _state.sent()
4735
- ]);
4736
- return [
4737
- 4,
4738
- resolveNode(node.right)
4739
- ];
4740
- case 32:
4741
- newValue = operation.apply(void 0, _tmp4.concat([
4742
- _state.sent()
4743
- ]));
4744
- _state.label = 33;
4745
- case 33:
4746
- return [
4747
- 3,
4748
- 37
4749
- ];
4750
- case 34:
4751
- return [
4752
- 4,
4753
- resolveNode(node.left)
4754
- ];
4755
- case 35:
4756
- _tmp5 = [
4757
- _state.sent()
4758
- ];
4759
- return [
4760
- 4,
4761
- resolveNode(node.right)
4762
- ];
4763
- case 36:
4764
- newValue = operation.apply(void 0, _tmp5.concat([
4765
- _state.sent()
4766
- ]));
4767
- _state.label = 37;
4768
- case 37:
4769
- if (node.left.type === "ModelRef") {
4770
- model.set([
4771
- [
4772
- node.left.ref,
4773
- newValue
4774
- ]
4775
- ]);
4776
- } else if (node.left.type === "Identifier") {
4777
- _this.vars[node.left.name] = newValue;
4778
- }
4779
- return [
4780
- 2,
4781
- newValue
4782
- ];
4783
- case 38:
4784
- return [
4785
- 2,
4786
- resolveNode(node.left)
4787
- ];
4788
- case 39:
4789
- return [
4790
- 2,
4791
- _this._resolveNode(_currentValue, node, options)
4792
- ];
4793
- }
4794
- });
4795
- })();
4796
- }
4797
4464
  }
4798
4465
  ]);
4799
4466
  return ExpressionEvaluator;