@player-ui/common-types-plugin 0.10.5-next.1 → 0.11.0--canary.614.21244

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.
@@ -4900,6 +4900,7 @@ var CommonTypesPlugin = function() {
4900
4900
  ]);
4901
4901
  return ViewInstance;
4902
4902
  }();
4903
+ var templateSymbol = Symbol("template");
4903
4904
  var TemplatePlugin = /*#__PURE__*/ function() {
4904
4905
  function TemplatePlugin(options) {
4905
4906
  _class_call_check(this, TemplatePlugin);
@@ -4970,6 +4971,9 @@ var CommonTypesPlugin = function() {
4970
4971
  override: false,
4971
4972
  values: values
4972
4973
  };
4974
+ if (node.placement !== void 0) {
4975
+ result[templateSymbol] = node.placement;
4976
+ }
4973
4977
  return result;
4974
4978
  }
4975
4979
  },
@@ -4983,6 +4987,38 @@ var CommonTypesPlugin = function() {
4983
4987
  }
4984
4988
  return node;
4985
4989
  });
4990
+ function getTemplateSymbolValue(node) {
4991
+ if (node.type === "multi-node") {
4992
+ return node[templateSymbol];
4993
+ } else if (node.type === "template") {
4994
+ return node.placement;
4995
+ }
4996
+ return void 0;
4997
+ }
4998
+ parser.hooks.onCreateASTNode.tap("template-sort", function(node) {
4999
+ if (node && (node.type === "view" || node.type === "asset") && Array.isArray(node.children)) {
5000
+ node.children = node.children.sort(function(a, b) {
5001
+ var pathsEqual = a.path.join() === b.path.join();
5002
+ if (pathsEqual) {
5003
+ var aPlacement = getTemplateSymbolValue(a.value);
5004
+ var bPlacement = getTemplateSymbolValue(b.value);
5005
+ if (aPlacement !== void 0 && bPlacement === void 0) {
5006
+ return aPlacement === "prepend" ? -1 : 1;
5007
+ } else if (bPlacement !== void 0 && aPlacement === void 0) {
5008
+ return bPlacement === "prepend" ? 1 : -1;
5009
+ } else if (aPlacement !== void 0 && bPlacement !== void 0) {
5010
+ if (aPlacement === bPlacement) {
5011
+ return 0;
5012
+ }
5013
+ return aPlacement === "prepend" ? -1 : 1;
5014
+ }
5015
+ return 0;
5016
+ }
5017
+ return 0;
5018
+ });
5019
+ }
5020
+ return node;
5021
+ });
4986
5022
  parser.hooks.parseNode.tap("template", function(obj, _nodeType, options, childOptions) {
4987
5023
  if (childOptions && hasTemplateKey(childOptions.key)) {
4988
5024
  return obj.map(function(template) {
@@ -4992,7 +5028,8 @@ var CommonTypesPlugin = function() {
4992
5028
  depth: (_options_templateDepth = options.templateDepth) !== null && _options_templateDepth !== void 0 ? _options_templateDepth : 0,
4993
5029
  data: template.data,
4994
5030
  template: template.value,
4995
- dynamic: (_template_dynamic = template.dynamic) !== null && _template_dynamic !== void 0 ? _template_dynamic : false
5031
+ dynamic: (_template_dynamic = template.dynamic) !== null && _template_dynamic !== void 0 ? _template_dynamic : false,
5032
+ placement: template.placement
4996
5033
  }, template);
4997
5034
  if (!templateAST) return;
4998
5035
  if (templateAST.type === "multi-node") {
@@ -5028,6 +5065,7 @@ var CommonTypesPlugin = function() {
5028
5065
  value: function apply(view) {
5029
5066
  view.hooks.parser.tap("template", this.applyParser.bind(this));
5030
5067
  view.hooks.resolver.tap("template", this.applyResolverHooks.bind(this));
5068
+ view.hooks.onTemplatePluginCreated.call(this);
5031
5069
  }
5032
5070
  }
5033
5071
  ]);