@player-ui/beacon-plugin 0.10.5-next.2 → 0.11.0--canary.614.21345

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.
@@ -4481,8 +4481,8 @@ var BeaconPlugin = function() {
4481
4481
  return Parser;
4482
4482
  }();
4483
4483
  function unpackAndPush(item, initial) {
4484
- if (Array.isArray(item)) {
4485
- item.forEach(function(i) {
4484
+ if (item.asset.values && Array.isArray(item.asset.values)) {
4485
+ item.asset.values.forEach(function(i) {
4486
4486
  unpackAndPush(i, initial);
4487
4487
  });
4488
4488
  } else {
@@ -4710,9 +4710,7 @@ var BeaconPlugin = function() {
4710
4710
  var mTree = _this.computeTree(mValue, rawParentToPassIn, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap);
4711
4711
  if (mTree.value !== void 0 && mTree.value !== null) {
4712
4712
  if (mValue.type === "async" && mValue.flatten && mTree.value.asset && Array.isArray(mTree.value.asset.values)) {
4713
- mTree.value.asset.values.forEach(function(v) {
4714
- unpackAndPush(v, childValue);
4715
- });
4713
+ unpackAndPush(mTree.value, childValue);
4716
4714
  } else {
4717
4715
  childValue.push(mTree.value);
4718
4716
  }
@@ -4870,6 +4868,7 @@ var BeaconPlugin = function() {
4870
4868
  ]);
4871
4869
  return ViewInstance;
4872
4870
  }();
4871
+ var templateSymbol = Symbol("template");
4873
4872
  var TemplatePlugin = /*#__PURE__*/ function() {
4874
4873
  function TemplatePlugin(options) {
4875
4874
  _class_call_check(this, TemplatePlugin);
@@ -4940,6 +4939,9 @@ var BeaconPlugin = function() {
4940
4939
  override: false,
4941
4940
  values: values
4942
4941
  };
4942
+ if (node.placement !== void 0) {
4943
+ result[templateSymbol] = node.placement;
4944
+ }
4943
4945
  return result;
4944
4946
  }
4945
4947
  },
@@ -4953,6 +4955,38 @@ var BeaconPlugin = function() {
4953
4955
  }
4954
4956
  return node;
4955
4957
  });
4958
+ parser.hooks.onCreateASTNode.tap("template-sort", function(node) {
4959
+ var getTemplateSymbolValue = function getTemplateSymbolValue(node2) {
4960
+ if (node2.type === "multi-node") {
4961
+ return node2[templateSymbol];
4962
+ } else if (node2.type === "template") {
4963
+ return node2.placement;
4964
+ }
4965
+ return void 0;
4966
+ };
4967
+ if (node && (node.type === "view" || node.type === "asset") && Array.isArray(node.children)) {
4968
+ node.children = node.children.sort(function(a, b) {
4969
+ var pathsEqual = a.path.join() === b.path.join();
4970
+ if (pathsEqual) {
4971
+ var aPlacement = getTemplateSymbolValue(a.value);
4972
+ var bPlacement = getTemplateSymbolValue(b.value);
4973
+ if (aPlacement !== void 0 && bPlacement === void 0) {
4974
+ return aPlacement === "prepend" ? -1 : 1;
4975
+ } else if (bPlacement !== void 0 && aPlacement === void 0) {
4976
+ return bPlacement === "prepend" ? 1 : -1;
4977
+ } else if (aPlacement !== void 0 && bPlacement !== void 0) {
4978
+ if (aPlacement === bPlacement) {
4979
+ return 0;
4980
+ }
4981
+ return aPlacement === "prepend" ? -1 : 1;
4982
+ }
4983
+ return 0;
4984
+ }
4985
+ return 0;
4986
+ });
4987
+ }
4988
+ return node;
4989
+ });
4956
4990
  parser.hooks.parseNode.tap("template", function(obj, _nodeType, options, childOptions) {
4957
4991
  if (childOptions && hasTemplateKey(childOptions.key)) {
4958
4992
  return obj.map(function(template) {
@@ -4962,7 +4996,8 @@ var BeaconPlugin = function() {
4962
4996
  depth: (_options_templateDepth = options.templateDepth) !== null && _options_templateDepth !== void 0 ? _options_templateDepth : 0,
4963
4997
  data: template.data,
4964
4998
  template: template.value,
4965
- dynamic: (_template_dynamic = template.dynamic) !== null && _template_dynamic !== void 0 ? _template_dynamic : false
4999
+ dynamic: (_template_dynamic = template.dynamic) !== null && _template_dynamic !== void 0 ? _template_dynamic : false,
5000
+ placement: template.placement
4966
5001
  }, template);
4967
5002
  if (!templateAST) return;
4968
5003
  if (templateAST.type === "multi-node") {