@player-ui/async-node-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.
@@ -4477,8 +4477,8 @@ var AsyncNodePlugin = function() {
4477
4477
  return Parser;
4478
4478
  }();
4479
4479
  function unpackAndPush(item, initial) {
4480
- if (Array.isArray(item)) {
4481
- item.forEach(function(i) {
4480
+ if (item.asset.values && Array.isArray(item.asset.values)) {
4481
+ item.asset.values.forEach(function(i) {
4482
4482
  unpackAndPush(i, initial);
4483
4483
  });
4484
4484
  } else {
@@ -4706,9 +4706,7 @@ var AsyncNodePlugin = function() {
4706
4706
  var mTree = _this.computeTree(mValue, rawParentToPassIn, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap);
4707
4707
  if (mTree.value !== void 0 && mTree.value !== null) {
4708
4708
  if (mValue.type === "async" && mValue.flatten && mTree.value.asset && Array.isArray(mTree.value.asset.values)) {
4709
- mTree.value.asset.values.forEach(function(v) {
4710
- unpackAndPush(v, childValue);
4711
- });
4709
+ unpackAndPush(mTree.value, childValue);
4712
4710
  } else {
4713
4711
  childValue.push(mTree.value);
4714
4712
  }
@@ -4972,6 +4970,7 @@ var AsyncNodePlugin = function() {
4972
4970
  ]);
4973
4971
  return _Builder;
4974
4972
  }();
4973
+ var templateSymbol = Symbol("template");
4975
4974
  var TemplatePlugin = /*#__PURE__*/ function() {
4976
4975
  function TemplatePlugin(options) {
4977
4976
  _class_call_check(this, TemplatePlugin);
@@ -5042,6 +5041,9 @@ var AsyncNodePlugin = function() {
5042
5041
  override: false,
5043
5042
  values: values
5044
5043
  };
5044
+ if (node.placement !== void 0) {
5045
+ result[templateSymbol] = node.placement;
5046
+ }
5045
5047
  return result;
5046
5048
  }
5047
5049
  },
@@ -5055,6 +5057,38 @@ var AsyncNodePlugin = function() {
5055
5057
  }
5056
5058
  return node;
5057
5059
  });
5060
+ parser.hooks.onCreateASTNode.tap("template-sort", function(node) {
5061
+ var getTemplateSymbolValue = function getTemplateSymbolValue(node2) {
5062
+ if (node2.type === "multi-node") {
5063
+ return node2[templateSymbol];
5064
+ } else if (node2.type === "template") {
5065
+ return node2.placement;
5066
+ }
5067
+ return void 0;
5068
+ };
5069
+ if (node && (node.type === "view" || node.type === "asset") && Array.isArray(node.children)) {
5070
+ node.children = node.children.sort(function(a, b) {
5071
+ var pathsEqual = a.path.join() === b.path.join();
5072
+ if (pathsEqual) {
5073
+ var aPlacement = getTemplateSymbolValue(a.value);
5074
+ var bPlacement = getTemplateSymbolValue(b.value);
5075
+ if (aPlacement !== void 0 && bPlacement === void 0) {
5076
+ return aPlacement === "prepend" ? -1 : 1;
5077
+ } else if (bPlacement !== void 0 && aPlacement === void 0) {
5078
+ return bPlacement === "prepend" ? 1 : -1;
5079
+ } else if (aPlacement !== void 0 && bPlacement !== void 0) {
5080
+ if (aPlacement === bPlacement) {
5081
+ return 0;
5082
+ }
5083
+ return aPlacement === "prepend" ? -1 : 1;
5084
+ }
5085
+ return 0;
5086
+ }
5087
+ return 0;
5088
+ });
5089
+ }
5090
+ return node;
5091
+ });
5058
5092
  parser.hooks.parseNode.tap("template", function(obj, _nodeType, options, childOptions) {
5059
5093
  if (childOptions && hasTemplateKey(childOptions.key)) {
5060
5094
  return obj.map(function(template) {
@@ -5064,7 +5098,8 @@ var AsyncNodePlugin = function() {
5064
5098
  depth: (_options_templateDepth = options.templateDepth) !== null && _options_templateDepth !== void 0 ? _options_templateDepth : 0,
5065
5099
  data: template.data,
5066
5100
  template: template.value,
5067
- dynamic: (_template_dynamic = template.dynamic) !== null && _template_dynamic !== void 0 ? _template_dynamic : false
5101
+ dynamic: (_template_dynamic = template.dynamic) !== null && _template_dynamic !== void 0 ? _template_dynamic : false,
5102
+ placement: template.placement
5068
5103
  }, template);
5069
5104
  if (!templateAST) return;
5070
5105
  if (templateAST.type === "multi-node") {