@player-ui/player 0.8.0-next.1 → 0.8.0-next.10

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.
Files changed (37) hide show
  1. package/dist/Player.native.js +246 -252
  2. package/dist/Player.native.js.map +1 -1
  3. package/dist/cjs/index.cjs +208 -268
  4. package/dist/cjs/index.cjs.map +1 -1
  5. package/dist/index.legacy-esm.js +206 -270
  6. package/dist/index.mjs +206 -270
  7. package/dist/index.mjs.map +1 -1
  8. package/package.json +4 -4
  9. package/src/plugins/default-view-plugin.ts +4 -0
  10. package/src/view/__tests__/view.immutable.test.ts +8 -1
  11. package/src/view/__tests__/view.test.ts +59 -1
  12. package/src/view/parser/__tests__/parser.test.ts +16 -1
  13. package/src/view/parser/index.ts +46 -262
  14. package/src/view/parser/utils.ts +23 -3
  15. package/src/view/plugins/__tests__/__snapshots__/asset.test.ts.snap +215 -0
  16. package/src/view/plugins/__tests__/__snapshots__/multi-node.test.ts.snap +67 -0
  17. package/src/view/plugins/__tests__/__snapshots__/template.test.ts.snap +56 -54
  18. package/src/view/plugins/__tests__/applicability.test.ts +24 -16
  19. package/src/view/plugins/__tests__/asset.test.ts +140 -0
  20. package/src/view/plugins/__tests__/multi-node.test.ts +38 -0
  21. package/src/view/plugins/__tests__/template.test.ts +48 -388
  22. package/src/view/plugins/applicability.ts +39 -23
  23. package/src/view/plugins/asset.ts +42 -0
  24. package/src/view/plugins/index.ts +3 -1
  25. package/src/view/plugins/multi-node.ts +73 -0
  26. package/src/view/plugins/switch.ts +81 -50
  27. package/src/view/plugins/{template-plugin.ts → template.ts} +38 -24
  28. package/src/view/resolver/__tests__/edgecases.test.ts +14 -1
  29. package/src/view/view.ts +2 -7
  30. package/types/view/parser/index.d.ts +6 -11
  31. package/types/view/parser/utils.d.ts +11 -2
  32. package/types/view/plugins/applicability.d.ts +1 -0
  33. package/types/view/plugins/asset.d.ts +8 -0
  34. package/types/view/plugins/index.d.ts +3 -1
  35. package/types/view/plugins/multi-node.d.ts +8 -0
  36. package/types/view/plugins/switch.d.ts +2 -1
  37. package/types/view/plugins/{template-plugin.d.ts → template.d.ts} +2 -2
@@ -1333,9 +1333,17 @@ var Player = function() {
1333
1333
  }
1334
1334
  }
1335
1335
  };
1336
- var hasAsync = // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/view/parser/utils.ts
1337
- function hasAsync(obj) {
1338
- return Object.prototype.hasOwnProperty.call(obj, "async");
1336
+ var hasTemplateValues = // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/view/parser/utils.ts
1337
+ function hasTemplateValues(obj, localKey) {
1338
+ return Object.hasOwnProperty.call(obj, "template") && Array.isArray(obj === null || obj === void 0 ? void 0 : obj.template) && obj.template.length && obj.template.find(function(tmpl) {
1339
+ return tmpl.output === localKey;
1340
+ });
1341
+ };
1342
+ var hasSwitchKey = function hasSwitchKey(localKey) {
1343
+ return localKey === "staticSwitch" || localKey === "dynamicSwitch";
1344
+ };
1345
+ var hasTemplateKey = function hasTemplateKey(localKey) {
1346
+ return localKey === "template";
1339
1347
  };
1340
1348
  var getNodeID = function getNodeID(node) {
1341
1349
  var _node_value;
@@ -1664,7 +1672,7 @@ var Player = function() {
1664
1672
  exports.merge = merge;
1665
1673
  exports.mergeDeep = mergeDeep;
1666
1674
  exports.mergeIn = mergeIn;
1667
- exports.omit = omit4;
1675
+ exports.omit = omit3;
1668
1676
  exports.addDefaults = addDefaults;
1669
1677
  exports.default = void 0;
1670
1678
  var INVALID_ARGS = "INVALID_ARGS";
@@ -1838,7 +1846,7 @@ var Player = function() {
1838
1846
  }
1839
1847
  return setIn8(a, path, nextVal);
1840
1848
  }
1841
- function omit4(obj, attrs) {
1849
+ function omit3(obj, attrs) {
1842
1850
  var omitList = Array.isArray(attrs) ? attrs : [
1843
1851
  attrs
1844
1852
  ];
@@ -1924,7 +1932,7 @@ var Player = function() {
1924
1932
  merge: merge,
1925
1933
  mergeDeep: mergeDeep,
1926
1934
  mergeIn: mergeIn,
1927
- omit: omit4,
1935
+ omit: omit3,
1928
1936
  addDefaults: addDefaults
1929
1937
  };
1930
1938
  var _default = timm;
@@ -2047,6 +2055,9 @@ var Player = function() {
2047
2055
  ApplicabilityPlugin: function() {
2048
2056
  return ApplicabilityPlugin;
2049
2057
  },
2058
+ AssetPlugin: function() {
2059
+ return AssetPlugin;
2060
+ },
2050
2061
  AssetTransformCorePlugin: function() {
2051
2062
  return AssetTransformCorePlugin;
2052
2063
  },
@@ -2104,6 +2115,9 @@ var Player = function() {
2104
2115
  LocalStateStore: function() {
2105
2116
  return LocalStateStore;
2106
2117
  },
2118
+ MultiNodePlugin: function() {
2119
+ return MultiNodePlugin;
2120
+ },
2107
2121
  NOOPDataModel: function() {
2108
2122
  return NOOPDataModel;
2109
2123
  },
@@ -2203,8 +2217,14 @@ var Player = function() {
2203
2217
  getNodeID: function() {
2204
2218
  return getNodeID;
2205
2219
  },
2206
- hasAsync: function() {
2207
- return hasAsync;
2220
+ hasSwitchKey: function() {
2221
+ return hasSwitchKey;
2222
+ },
2223
+ hasTemplateKey: function() {
2224
+ return hasTemplateKey;
2225
+ },
2226
+ hasTemplateValues: function() {
2227
+ return hasTemplateValues;
2208
2228
  },
2209
2229
  isBinding: function() {
2210
2230
  return isBinding;
@@ -4586,7 +4606,6 @@ var Player = function() {
4586
4606
  * If undefined, the original value is used.
4587
4607
  * If null, we ignore this node all together
4588
4608
  */ onCreateASTNode: new SyncWaterfallHook(),
4589
- determineNodeType: new SyncBailHook(),
4590
4609
  parseNode: new SyncBailHook()
4591
4610
  };
4592
4611
  }
@@ -4601,21 +4620,6 @@ var Player = function() {
4601
4620
  return viewNode;
4602
4621
  }
4603
4622
  },
4604
- {
4605
- key: "parseAsync",
4606
- value: function parseAsync(obj, type, options) {
4607
- var parsedAsync = this.parseObject((0, import_timm4.omit)(obj, "async"), type, options);
4608
- var parsedNodeId = getNodeID(parsedAsync);
4609
- if (parsedAsync !== null && parsedNodeId) {
4610
- return this.createASTNode({
4611
- id: parsedNodeId,
4612
- type: "async" /* Async */ ,
4613
- value: parsedAsync
4614
- }, obj);
4615
- }
4616
- return null;
4617
- }
4618
- },
4619
4623
  {
4620
4624
  key: "createASTNode",
4621
4625
  value: function createASTNode(node, value) {
@@ -4626,25 +4630,6 @@ var Player = function() {
4626
4630
  return tapped;
4627
4631
  }
4628
4632
  },
4629
- {
4630
- /**
4631
- * Checks if there are templated values in the object
4632
- *
4633
- * @param obj - The Parsed Object to check to see if we have a template array type for
4634
- * @param localKey - The key being checked
4635
- */ key: "hasTemplateValues",
4636
- value: function hasTemplateValues(obj, localKey) {
4637
- return Object.hasOwnProperty.call(obj, "template") && Array.isArray(obj === null || obj === void 0 ? void 0 : obj.template) && obj.template.length && obj.template.find(function(tmpl) {
4638
- return tmpl.output === localKey;
4639
- });
4640
- }
4641
- },
4642
- {
4643
- key: "hasSwitchKey",
4644
- value: function hasSwitchKey(localKey) {
4645
- return localKey === "staticSwitch";
4646
- }
4647
- },
4648
4633
  {
4649
4634
  key: "parseObject",
4650
4635
  value: function parseObject(obj) {
@@ -4652,12 +4637,9 @@ var Player = function() {
4652
4637
  templateDepth: 0
4653
4638
  };
4654
4639
  var _this = this;
4655
- var nodeType = this.hooks.determineNodeType.call(obj);
4656
- if (nodeType !== void 0) {
4657
- var parsedNode = this.hooks.parseNode.call(obj, type, options, nodeType);
4658
- if (parsedNode) {
4659
- return parsedNode;
4660
- }
4640
+ var parsedNode = this.hooks.parseNode.call(obj, type, options);
4641
+ if (parsedNode || parsedNode === null) {
4642
+ return parsedNode;
4661
4643
  }
4662
4644
  var parseLocalObject = function(currentValue, objToParse) {
4663
4645
  var path = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [];
@@ -4687,166 +4669,42 @@ var Player = function() {
4687
4669
  value: currentValue
4688
4670
  };
4689
4671
  var newValue = objEntries.reduce(function(accumulation, current) {
4690
- var children2 = accumulation.children, rest = _object_without_properties(accumulation, [
4691
- "children"
4692
- ]);
4672
+ var value2 = accumulation.value;
4673
+ var children2 = accumulation.children;
4693
4674
  var _current = _sliced_to_array(current, 2), localKey = _current[0], localValue = _current[1];
4694
- if (localKey === "asset" && typeof localValue === "object") {
4695
- var assetAST = _this.parseObject(localValue, "asset" /* Asset */ , options);
4696
- if (assetAST) {
4697
- return _object_spread_props(_object_spread({}, rest), {
4698
- children: _to_consumable_array(children2).concat([
4699
- {
4700
- path: _to_consumable_array(path).concat([
4701
- "asset"
4702
- ]),
4703
- value: assetAST
4704
- }
4705
- ])
4706
- });
4707
- }
4708
- } else if (_this.hooks.determineNodeType.call(localKey) === "template" /* Template */ && Array.isArray(localValue)) {
4709
- var templateChildren = localValue.map(function(template) {
4710
- var _options_templateDepth, _template_dynamic;
4711
- var templateAST = _this.hooks.onCreateASTNode.call({
4712
- type: "template" /* Template */ ,
4713
- depth: (_options_templateDepth = options.templateDepth) !== null && _options_templateDepth !== void 0 ? _options_templateDepth : 0,
4714
- data: template.data,
4715
- template: template.value,
4716
- dynamic: (_template_dynamic = template.dynamic) !== null && _template_dynamic !== void 0 ? _template_dynamic : false
4717
- }, template);
4718
- if ((templateAST === null || templateAST === void 0 ? void 0 : templateAST.type) === "multi-node" /* MultiNode */ ) {
4719
- templateAST.values.forEach(function(v) {
4720
- v.parent = templateAST;
4721
- });
4722
- }
4723
- if (templateAST) {
4724
- return {
4725
- path: _to_consumable_array(path).concat([
4726
- template.output
4727
- ]),
4728
- value: templateAST
4729
- };
4730
- }
4731
- return;
4732
- }).filter(function(element) {
4733
- return !!element;
4734
- });
4735
- return _object_spread_props(_object_spread({}, rest), {
4736
- children: _to_consumable_array(children2).concat(_to_consumable_array(templateChildren))
4737
- });
4738
- } else if (localValue && _this.hooks.determineNodeType.call(localValue) === "switch" /* Switch */ || _this.hasSwitchKey(localKey)) {
4739
- var _localSwitch_children;
4740
- var localSwitch = _this.hooks.parseNode.call(_this.hasSwitchKey(localKey) ? _define_property({}, localKey, localValue) : localValue, "value" /* Value */ , options, "switch" /* Switch */ );
4741
- if (localSwitch && localSwitch.type === "value" /* Value */ && ((_localSwitch_children = localSwitch.children) === null || _localSwitch_children === void 0 ? void 0 : _localSwitch_children.length) === 1 && localSwitch.value === void 0) {
4742
- var firstChild = localSwitch.children[0];
4743
- return _object_spread_props(_object_spread({}, rest), {
4744
- children: _to_consumable_array(children2).concat([
4745
- {
4746
- path: _to_consumable_array(path).concat([
4747
- localKey
4748
- ], _to_consumable_array(firstChild.path)),
4749
- value: firstChild.value
4750
- }
4751
- ])
4752
- });
4753
- }
4754
- if (localSwitch) {
4755
- return _object_spread_props(_object_spread({}, rest), {
4756
- children: _to_consumable_array(children2).concat([
4757
- {
4758
- path: _to_consumable_array(path).concat([
4759
- localKey
4760
- ]),
4761
- value: localSwitch
4762
- }
4763
- ])
4764
- });
4765
- }
4766
- } else if (localValue && hasAsync(localValue)) {
4767
- var localAsync = _this.parseAsync(localValue, "value" /* Value */ , options);
4768
- if (localAsync) {
4769
- children2.push({
4770
- path: _to_consumable_array(path).concat([
4771
- localKey
4772
- ]),
4773
- value: localAsync
4774
- });
4775
- }
4776
- } else if (localValue && Array.isArray(localValue)) {
4777
- var childValues = localValue.map(function(childVal) {
4778
- return _this.parseObject(childVal, "value" /* Value */ , options);
4779
- }).filter(function(child) {
4780
- return !!child;
4781
- });
4782
- if (childValues.length > 0) {
4783
- var multiNode = _this.hooks.onCreateASTNode.call({
4784
- type: "multi-node" /* MultiNode */ ,
4785
- override: !_this.hasTemplateValues(localObj, localKey),
4786
- values: childValues
4787
- }, localValue);
4788
- if ((multiNode === null || multiNode === void 0 ? void 0 : multiNode.type) === "multi-node" /* MultiNode */ ) {
4789
- multiNode.values.forEach(function(v) {
4790
- v.parent = multiNode;
4791
- });
4792
- }
4793
- if (multiNode) {
4794
- return _object_spread_props(_object_spread({}, rest), {
4795
- children: _to_consumable_array(children2).concat([
4796
- {
4797
- path: _to_consumable_array(path).concat([
4798
- localKey
4799
- ]),
4800
- value: multiNode
4801
- }
4802
- ])
4803
- });
4804
- }
4805
- }
4675
+ var newChildren = _this.hooks.parseNode.call(localValue, "value" /* Value */ , options, {
4676
+ path: path,
4677
+ key: localKey,
4678
+ parentObj: localObj
4679
+ });
4680
+ if (newChildren) {
4681
+ var _children2;
4682
+ (_children2 = children2).push.apply(_children2, _to_consumable_array(newChildren));
4806
4683
  } else if (localValue && typeof localValue === "object") {
4807
- var determineNodeType = _this.hooks.determineNodeType.call(localValue);
4808
- if (determineNodeType === "applicability" /* Applicability */ ) {
4809
- var parsedNode = _this.hooks.parseNode.call(localValue, "value" /* Value */ , options, determineNodeType);
4810
- if (parsedNode) {
4811
- return _object_spread_props(_object_spread({}, rest), {
4812
- children: _to_consumable_array(children2).concat([
4813
- {
4814
- path: _to_consumable_array(path).concat([
4815
- localKey
4816
- ]),
4817
- value: parsedNode
4818
- }
4819
- ])
4820
- });
4821
- }
4822
- } else {
4823
- var result = parseLocalObject(accumulation.value, localValue, _to_consumable_array(path).concat([
4824
- localKey
4825
- ]));
4826
- return {
4827
- value: result.value,
4828
- children: _to_consumable_array(children2).concat(_to_consumable_array(result.children))
4829
- };
4830
- }
4684
+ var _children21;
4685
+ var result = parseLocalObject(accumulation.value, localValue, _to_consumable_array(path).concat([
4686
+ localKey
4687
+ ]));
4688
+ value2 = result.value;
4689
+ (_children21 = children2).push.apply(_children21, _to_consumable_array(result.children));
4831
4690
  } else {
4832
- var value2 = (0, import_timm4.setIn)(accumulation.value, _to_consumable_array(path).concat([
4691
+ value2 = (0, import_timm4.setIn)(accumulation.value, _to_consumable_array(path).concat([
4833
4692
  localKey
4834
4693
  ]), localValue);
4835
- return {
4836
- children: children2,
4837
- value: value2
4838
- };
4839
4694
  }
4840
- return accumulation;
4695
+ return {
4696
+ value: value2,
4697
+ children: children2
4698
+ };
4841
4699
  }, defaultValue);
4842
4700
  return newValue;
4843
4701
  };
4844
4702
  var _parseLocalObject = parseLocalObject(void 0, obj), value = _parseLocalObject.value, children = _parseLocalObject.children;
4845
- var baseAst = value === void 0 && children.length === 0 ? void 0 : {
4703
+ var baseAst = value === void 0 && !children.length ? void 0 : {
4846
4704
  type: type,
4847
4705
  value: value
4848
4706
  };
4849
- if (baseAst !== void 0 && children.length > 0) {
4707
+ if (baseAst && children.length) {
4850
4708
  var parent = baseAst;
4851
4709
  parent.children = children;
4852
4710
  children.forEach(function(child) {
@@ -5331,7 +5189,7 @@ var Player = function() {
5331
5189
  ]);
5332
5190
  return Builder;
5333
5191
  }();
5334
- // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/view/plugins/template-plugin.ts
5192
+ // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/view/plugins/template.ts
5335
5193
  var TemplatePlugin = /*#__PURE__*/ function() {
5336
5194
  function TemplatePlugin(options) {
5337
5195
  _class_call_check(this, TemplatePlugin);
@@ -5415,24 +5273,30 @@ var Player = function() {
5415
5273
  }
5416
5274
  return node;
5417
5275
  });
5418
- parser.hooks.determineNodeType.tap("template", function(obj) {
5419
- if (obj === "template") {
5420
- return "template" /* Template */ ;
5421
- }
5422
- });
5423
- parser.hooks.parseNode.tap("template", function(obj, _nodeType, options, determinedNodeType) {
5424
- if (determinedNodeType === "template" /* Template */ ) {
5425
- var _options_templateDepth, _obj_dynamic;
5426
- var templateNode = parser.createASTNode({
5427
- type: "template" /* Template */ ,
5428
- depth: (_options_templateDepth = options.templateDepth) !== null && _options_templateDepth !== void 0 ? _options_templateDepth : 0,
5429
- data: obj.data,
5430
- template: obj.value,
5431
- dynamic: (_obj_dynamic = obj.dynamic) !== null && _obj_dynamic !== void 0 ? _obj_dynamic : false
5432
- }, obj);
5433
- if (templateNode) {
5434
- return templateNode;
5435
- }
5276
+ parser.hooks.parseNode.tap("template", function(obj, _nodeType, options, childOptions) {
5277
+ if (childOptions && hasTemplateKey(childOptions.key)) {
5278
+ return obj.map(function(template) {
5279
+ var _options_templateDepth, _template_dynamic;
5280
+ var templateAST = parser.createASTNode({
5281
+ type: "template" /* Template */ ,
5282
+ depth: (_options_templateDepth = options.templateDepth) !== null && _options_templateDepth !== void 0 ? _options_templateDepth : 0,
5283
+ data: template.data,
5284
+ template: template.value,
5285
+ dynamic: (_template_dynamic = template.dynamic) !== null && _template_dynamic !== void 0 ? _template_dynamic : false
5286
+ }, template);
5287
+ if (!templateAST) return;
5288
+ if (templateAST.type === "multi-node" /* MultiNode */ ) {
5289
+ templateAST.values.forEach(function(v) {
5290
+ v.parent = templateAST;
5291
+ });
5292
+ }
5293
+ return {
5294
+ path: _to_consumable_array(childOptions.path).concat([
5295
+ template.output
5296
+ ]),
5297
+ value: templateAST
5298
+ };
5299
+ }).filter(Boolean);
5436
5300
  }
5437
5301
  });
5438
5302
  }
@@ -5580,6 +5444,12 @@ var Player = function() {
5580
5444
  _class_call_check(this, ApplicabilityPlugin);
5581
5445
  }
5582
5446
  _create_class(ApplicabilityPlugin, [
5447
+ {
5448
+ key: "isApplicability",
5449
+ value: function isApplicability(obj) {
5450
+ return obj && Object.prototype.hasOwnProperty.call(obj, "applicability");
5451
+ }
5452
+ },
5583
5453
  {
5584
5454
  key: "applyResolver",
5585
5455
  value: function applyResolver(resolver) {
@@ -5599,25 +5469,32 @@ var Player = function() {
5599
5469
  {
5600
5470
  key: "applyParser",
5601
5471
  value: function applyParser(parser) {
5602
- parser.hooks.determineNodeType.tap("applicability", function(obj) {
5603
- if (Object.prototype.hasOwnProperty.call(obj, "applicability")) {
5604
- return "applicability" /* Applicability */ ;
5605
- }
5606
- });
5607
- parser.hooks.parseNode.tap("applicability", function(obj, nodeType, options, determinedNodeType) {
5608
- if (determinedNodeType === "applicability" /* Applicability */ ) {
5472
+ var _this = this;
5473
+ parser.hooks.parseNode.tap("applicability", function(obj, nodeType, options, childOptions) {
5474
+ if (_this.isApplicability(obj)) {
5609
5475
  var parsedApplicability = parser.parseObject((0, import_timm7.omit)(obj, "applicability"), nodeType, options);
5610
- if (parsedApplicability !== null) {
5611
- var applicabilityNode = parser.createASTNode({
5612
- type: "applicability" /* Applicability */ ,
5613
- expression: obj.applicability,
5614
- value: parsedApplicability
5615
- }, obj);
5616
- if ((applicabilityNode === null || applicabilityNode === void 0 ? void 0 : applicabilityNode.type) === "applicability" /* Applicability */ ) {
5617
- applicabilityNode.value.parent = applicabilityNode;
5618
- }
5619
- return applicabilityNode;
5476
+ if (!parsedApplicability) {
5477
+ return childOptions ? [] : null;
5620
5478
  }
5479
+ var applicabilityNode = parser.createASTNode({
5480
+ type: "applicability" /* Applicability */ ,
5481
+ expression: obj.applicability,
5482
+ value: parsedApplicability
5483
+ }, obj);
5484
+ if (!applicabilityNode) {
5485
+ return childOptions ? [] : null;
5486
+ }
5487
+ if (applicabilityNode.type === "applicability" /* Applicability */ ) {
5488
+ applicabilityNode.value.parent = applicabilityNode;
5489
+ }
5490
+ return childOptions ? [
5491
+ {
5492
+ path: _to_consumable_array(childOptions.path).concat([
5493
+ childOptions.key
5494
+ ]),
5495
+ value: applicabilityNode
5496
+ }
5497
+ ] : applicabilityNode;
5621
5498
  }
5622
5499
  });
5623
5500
  }
@@ -5668,6 +5545,12 @@ var Player = function() {
5668
5545
  return EMPTY_NODE;
5669
5546
  }
5670
5547
  },
5548
+ {
5549
+ key: "isSwitch",
5550
+ value: function isSwitch(obj) {
5551
+ return obj && (Object.prototype.hasOwnProperty.call(obj, "dynamicSwitch") || Object.prototype.hasOwnProperty.call(obj, "staticSwitch"));
5552
+ }
5553
+ },
5671
5554
  {
5672
5555
  key: "applyParser",
5673
5556
  value: function applyParser(parser) {
@@ -5678,42 +5561,56 @@ var Player = function() {
5678
5561
  }
5679
5562
  return node;
5680
5563
  });
5681
- parser.hooks.determineNodeType.tap("switch", function(obj) {
5682
- if (Object.prototype.hasOwnProperty.call(obj, "dynamicSwitch") || Object.prototype.hasOwnProperty.call(obj, "staticSwitch")) {
5683
- return "switch" /* Switch */ ;
5684
- }
5685
- });
5686
- parser.hooks.parseNode.tap("switch", function(obj, _nodeType, options, determinedNodeType) {
5687
- if (determinedNodeType === "switch" /* Switch */ ) {
5688
- var dynamic = "dynamicSwitch" in obj;
5689
- var switchContent = "dynamicSwitch" in obj ? obj.dynamicSwitch : obj.staticSwitch;
5690
- var cases = [];
5691
- switchContent.forEach(function(switchCase) {
5564
+ parser.hooks.parseNode.tap("switch", function(obj, _nodeType, options, childOptions) {
5565
+ if (_this.isSwitch(obj) || childOptions && hasSwitchKey(childOptions.key)) {
5566
+ var objToParse = childOptions && hasSwitchKey(childOptions.key) ? _define_property({}, childOptions.key, obj) : obj;
5567
+ var dynamic = "dynamicSwitch" in objToParse;
5568
+ var switchContent = dynamic ? objToParse.dynamicSwitch : objToParse.staticSwitch;
5569
+ var cases = switchContent.map(function(switchCase) {
5692
5570
  var switchCaseExpr = switchCase.case, switchBody = _object_without_properties(switchCase, [
5693
5571
  "case"
5694
5572
  ]);
5695
5573
  var value = parser.parseObject(switchBody, "value" /* Value */ , options);
5696
5574
  if (value) {
5697
- cases.push({
5575
+ return {
5698
5576
  case: switchCaseExpr,
5699
5577
  value: value
5700
- });
5578
+ };
5701
5579
  }
5702
- });
5703
- var switchAST = parser.hooks.onCreateASTNode.call({
5580
+ return;
5581
+ }).filter(Boolean);
5582
+ var switchAST = parser.createASTNode({
5704
5583
  type: "switch" /* Switch */ ,
5705
5584
  dynamic: dynamic,
5706
5585
  cases: cases
5707
- }, obj);
5708
- if ((switchAST === null || switchAST === void 0 ? void 0 : switchAST.type) === "switch" /* Switch */ ) {
5586
+ }, objToParse);
5587
+ if (!switchAST || switchAST.type === "empty" /* Empty */ ) {
5588
+ return childOptions ? [] : null;
5589
+ }
5590
+ if (switchAST.type === "switch" /* Switch */ ) {
5709
5591
  switchAST.cases.forEach(function(sCase) {
5710
5592
  sCase.value.parent = switchAST;
5711
5593
  });
5712
5594
  }
5713
- if ((switchAST === null || switchAST === void 0 ? void 0 : switchAST.type) === "empty" /* Empty */ ) {
5714
- return null;
5595
+ if (childOptions) {
5596
+ var _switchAST_children;
5597
+ var path = _to_consumable_array(childOptions.path).concat([
5598
+ childOptions.key
5599
+ ]);
5600
+ var value = switchAST;
5601
+ if (switchAST.type === "value" /* Value */ && ((_switchAST_children = switchAST.children) === null || _switchAST_children === void 0 ? void 0 : _switchAST_children.length) === 1 && switchAST.value === void 0) {
5602
+ var firstChild = switchAST.children[0];
5603
+ path = _to_consumable_array(path).concat(_to_consumable_array(firstChild.path));
5604
+ value = firstChild.value;
5605
+ }
5606
+ return [
5607
+ {
5608
+ path: path,
5609
+ value: value
5610
+ }
5611
+ ];
5715
5612
  }
5716
- return switchAST !== null && switchAST !== void 0 ? switchAST : null;
5613
+ return switchAST;
5717
5614
  }
5718
5615
  });
5719
5616
  }
@@ -5740,6 +5637,95 @@ var Player = function() {
5740
5637
  ]);
5741
5638
  return SwitchPlugin;
5742
5639
  }();
5640
+ // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/view/plugins/multi-node.ts
5641
+ var MultiNodePlugin = /*#__PURE__*/ function() {
5642
+ function MultiNodePlugin() {
5643
+ _class_call_check(this, MultiNodePlugin);
5644
+ }
5645
+ _create_class(MultiNodePlugin, [
5646
+ {
5647
+ key: "applyParser",
5648
+ value: function applyParser(parser) {
5649
+ parser.hooks.parseNode.tap("multi-node", function(obj, nodeType, options, childOptions) {
5650
+ if (childOptions && !hasTemplateKey(childOptions.key) && Array.isArray(obj)) {
5651
+ var values = obj.map(function(childVal) {
5652
+ return parser.parseObject(childVal, "value" /* Value */ , options);
5653
+ }).filter(function(child) {
5654
+ return !!child;
5655
+ });
5656
+ if (!values.length) {
5657
+ return [];
5658
+ }
5659
+ var multiNode = parser.createASTNode({
5660
+ type: "multi-node" /* MultiNode */ ,
5661
+ override: !hasTemplateValues(childOptions.parentObj, childOptions.key),
5662
+ values: values
5663
+ }, obj);
5664
+ if (!multiNode) {
5665
+ return [];
5666
+ }
5667
+ if (multiNode.type === "multi-node" /* MultiNode */ ) {
5668
+ multiNode.values.forEach(function(v) {
5669
+ v.parent = multiNode;
5670
+ });
5671
+ }
5672
+ return [
5673
+ {
5674
+ path: _to_consumable_array(childOptions.path).concat([
5675
+ childOptions.key
5676
+ ]),
5677
+ value: multiNode
5678
+ }
5679
+ ];
5680
+ }
5681
+ });
5682
+ }
5683
+ },
5684
+ {
5685
+ key: "apply",
5686
+ value: function apply(view) {
5687
+ view.hooks.parser.tap("multi-node", this.applyParser.bind(this));
5688
+ }
5689
+ }
5690
+ ]);
5691
+ return MultiNodePlugin;
5692
+ }();
5693
+ // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/view/plugins/asset.ts
5694
+ var AssetPlugin = /*#__PURE__*/ function() {
5695
+ function AssetPlugin() {
5696
+ _class_call_check(this, AssetPlugin);
5697
+ }
5698
+ _create_class(AssetPlugin, [
5699
+ {
5700
+ key: "applyParser",
5701
+ value: function applyParser(parser) {
5702
+ parser.hooks.parseNode.tap("asset", function(obj, nodeType, options, childOptions) {
5703
+ if ((childOptions === null || childOptions === void 0 ? void 0 : childOptions.key) === "asset" && typeof obj === "object") {
5704
+ var assetAST = parser.parseObject(obj, "asset" /* Asset */ , options);
5705
+ if (!assetAST) {
5706
+ return [];
5707
+ }
5708
+ return [
5709
+ {
5710
+ path: _to_consumable_array(childOptions.path).concat([
5711
+ childOptions.key
5712
+ ]),
5713
+ value: assetAST
5714
+ }
5715
+ ];
5716
+ }
5717
+ });
5718
+ }
5719
+ },
5720
+ {
5721
+ key: "apply",
5722
+ value: function apply(view) {
5723
+ view.hooks.parser.tap("asset", this.applyParser.bind(this));
5724
+ }
5725
+ }
5726
+ ]);
5727
+ return AssetPlugin;
5728
+ }();
5743
5729
  // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/player.ts
5744
5730
  var import_timm9 = __toESM(require_timm());
5745
5731
  var import_p_defer2 = __toESM(require_p_defer());
@@ -7077,6 +7063,12 @@ var Player = function() {
7077
7063
  value: function clear() {
7078
7064
  this.store = createSortedArray();
7079
7065
  }
7066
+ },
7067
+ {
7068
+ /** Check if the registry is empty*/ key: "isRegistryEmpty",
7069
+ value: function isRegistryEmpty() {
7070
+ return this.store.array.length === 0;
7071
+ }
7080
7072
  }
7081
7073
  ]);
7082
7074
  return Registry;
@@ -7589,12 +7581,14 @@ var Player = function() {
7589
7581
  player.hooks.viewController.tap(this.name, function(viewController) {
7590
7582
  viewController.hooks.view.tap(_this.name, function(view) {
7591
7583
  var pluginOptions = toNodeResolveOptions(view.resolverOptions);
7584
+ new AssetPlugin().apply(view);
7592
7585
  new SwitchPlugin(pluginOptions).apply(view);
7593
7586
  new ApplicabilityPlugin().apply(view);
7594
7587
  new StringResolverPlugin().apply(view);
7595
7588
  var templatePlugin = new TemplatePlugin(pluginOptions);
7596
7589
  templatePlugin.apply(view);
7597
7590
  view.hooks.onTemplatePluginCreated.call(templatePlugin);
7591
+ new MultiNodePlugin().apply(view);
7598
7592
  });
7599
7593
  });
7600
7594
  }