@player-ui/check-path-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.
@@ -4821,6 +4821,7 @@ var CheckPathPlugin = function() {
4821
4821
  ]);
4822
4822
  return ViewInstance;
4823
4823
  }();
4824
+ var templateSymbol = Symbol("template");
4824
4825
  var TemplatePlugin = /*#__PURE__*/ function() {
4825
4826
  function TemplatePlugin(options) {
4826
4827
  _class_call_check(this, TemplatePlugin);
@@ -4891,6 +4892,9 @@ var CheckPathPlugin = function() {
4891
4892
  override: false,
4892
4893
  values: values
4893
4894
  };
4895
+ if (node.placement !== void 0) {
4896
+ result[templateSymbol] = node.placement;
4897
+ }
4894
4898
  return result;
4895
4899
  }
4896
4900
  },
@@ -4904,6 +4908,38 @@ var CheckPathPlugin = function() {
4904
4908
  }
4905
4909
  return node;
4906
4910
  });
4911
+ function getTemplateSymbolValue(node) {
4912
+ if (node.type === "multi-node") {
4913
+ return node[templateSymbol];
4914
+ } else if (node.type === "template") {
4915
+ return node.placement;
4916
+ }
4917
+ return void 0;
4918
+ }
4919
+ parser.hooks.onCreateASTNode.tap("template-sort", function(node) {
4920
+ if (node && (node.type === "view" || node.type === "asset") && Array.isArray(node.children)) {
4921
+ node.children = node.children.sort(function(a, b) {
4922
+ var pathsEqual = a.path.join() === b.path.join();
4923
+ if (pathsEqual) {
4924
+ var aPlacement = getTemplateSymbolValue(a.value);
4925
+ var bPlacement = getTemplateSymbolValue(b.value);
4926
+ if (aPlacement !== void 0 && bPlacement === void 0) {
4927
+ return aPlacement === "prepend" ? -1 : 1;
4928
+ } else if (bPlacement !== void 0 && aPlacement === void 0) {
4929
+ return bPlacement === "prepend" ? 1 : -1;
4930
+ } else if (aPlacement !== void 0 && bPlacement !== void 0) {
4931
+ if (aPlacement === bPlacement) {
4932
+ return 0;
4933
+ }
4934
+ return aPlacement === "prepend" ? -1 : 1;
4935
+ }
4936
+ return 0;
4937
+ }
4938
+ return 0;
4939
+ });
4940
+ }
4941
+ return node;
4942
+ });
4907
4943
  parser.hooks.parseNode.tap("template", function(obj, _nodeType, options, childOptions) {
4908
4944
  if (childOptions && hasTemplateKey(childOptions.key)) {
4909
4945
  return obj.map(function(template) {
@@ -4913,7 +4949,8 @@ var CheckPathPlugin = function() {
4913
4949
  depth: (_options_templateDepth = options.templateDepth) !== null && _options_templateDepth !== void 0 ? _options_templateDepth : 0,
4914
4950
  data: template.data,
4915
4951
  template: template.value,
4916
- dynamic: (_template_dynamic = template.dynamic) !== null && _template_dynamic !== void 0 ? _template_dynamic : false
4952
+ dynamic: (_template_dynamic = template.dynamic) !== null && _template_dynamic !== void 0 ? _template_dynamic : false,
4953
+ placement: template.placement
4917
4954
  }, template);
4918
4955
  if (!templateAST) return;
4919
4956
  if (templateAST.type === "multi-node") {
@@ -4949,6 +4986,7 @@ var CheckPathPlugin = function() {
4949
4986
  value: function apply(view) {
4950
4987
  view.hooks.parser.tap("template", this.applyParser.bind(this));
4951
4988
  view.hooks.resolver.tap("template", this.applyResolverHooks.bind(this));
4989
+ view.hooks.onTemplatePluginCreated.call(this);
4952
4990
  }
4953
4991
  }
4954
4992
  ]);