@player-ui/beacon-plugin 0.10.5-next.2 → 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.
|
@@ -4870,6 +4870,7 @@ var BeaconPlugin = function() {
|
|
|
4870
4870
|
]);
|
|
4871
4871
|
return ViewInstance;
|
|
4872
4872
|
}();
|
|
4873
|
+
var templateSymbol = Symbol("template");
|
|
4873
4874
|
var TemplatePlugin = /*#__PURE__*/ function() {
|
|
4874
4875
|
function TemplatePlugin(options) {
|
|
4875
4876
|
_class_call_check(this, TemplatePlugin);
|
|
@@ -4940,6 +4941,9 @@ var BeaconPlugin = function() {
|
|
|
4940
4941
|
override: false,
|
|
4941
4942
|
values: values
|
|
4942
4943
|
};
|
|
4944
|
+
if (node.placement !== void 0) {
|
|
4945
|
+
result[templateSymbol] = node.placement;
|
|
4946
|
+
}
|
|
4943
4947
|
return result;
|
|
4944
4948
|
}
|
|
4945
4949
|
},
|
|
@@ -4953,6 +4957,38 @@ var BeaconPlugin = function() {
|
|
|
4953
4957
|
}
|
|
4954
4958
|
return node;
|
|
4955
4959
|
});
|
|
4960
|
+
function getTemplateSymbolValue(node) {
|
|
4961
|
+
if (node.type === "multi-node") {
|
|
4962
|
+
return node[templateSymbol];
|
|
4963
|
+
} else if (node.type === "template") {
|
|
4964
|
+
return node.placement;
|
|
4965
|
+
}
|
|
4966
|
+
return void 0;
|
|
4967
|
+
}
|
|
4968
|
+
parser.hooks.onCreateASTNode.tap("template-sort", function(node) {
|
|
4969
|
+
if (node && (node.type === "view" || node.type === "asset") && Array.isArray(node.children)) {
|
|
4970
|
+
node.children = node.children.sort(function(a, b) {
|
|
4971
|
+
var pathsEqual = a.path.join() === b.path.join();
|
|
4972
|
+
if (pathsEqual) {
|
|
4973
|
+
var aPlacement = getTemplateSymbolValue(a.value);
|
|
4974
|
+
var bPlacement = getTemplateSymbolValue(b.value);
|
|
4975
|
+
if (aPlacement !== void 0 && bPlacement === void 0) {
|
|
4976
|
+
return aPlacement === "prepend" ? -1 : 1;
|
|
4977
|
+
} else if (bPlacement !== void 0 && aPlacement === void 0) {
|
|
4978
|
+
return bPlacement === "prepend" ? 1 : -1;
|
|
4979
|
+
} else if (aPlacement !== void 0 && bPlacement !== void 0) {
|
|
4980
|
+
if (aPlacement === bPlacement) {
|
|
4981
|
+
return 0;
|
|
4982
|
+
}
|
|
4983
|
+
return aPlacement === "prepend" ? -1 : 1;
|
|
4984
|
+
}
|
|
4985
|
+
return 0;
|
|
4986
|
+
}
|
|
4987
|
+
return 0;
|
|
4988
|
+
});
|
|
4989
|
+
}
|
|
4990
|
+
return node;
|
|
4991
|
+
});
|
|
4956
4992
|
parser.hooks.parseNode.tap("template", function(obj, _nodeType, options, childOptions) {
|
|
4957
4993
|
if (childOptions && hasTemplateKey(childOptions.key)) {
|
|
4958
4994
|
return obj.map(function(template) {
|
|
@@ -4962,7 +4998,8 @@ var BeaconPlugin = function() {
|
|
|
4962
4998
|
depth: (_options_templateDepth = options.templateDepth) !== null && _options_templateDepth !== void 0 ? _options_templateDepth : 0,
|
|
4963
4999
|
data: template.data,
|
|
4964
5000
|
template: template.value,
|
|
4965
|
-
dynamic: (_template_dynamic = template.dynamic) !== null && _template_dynamic !== void 0 ? _template_dynamic : false
|
|
5001
|
+
dynamic: (_template_dynamic = template.dynamic) !== null && _template_dynamic !== void 0 ? _template_dynamic : false,
|
|
5002
|
+
placement: template.placement
|
|
4966
5003
|
}, template);
|
|
4967
5004
|
if (!templateAST) return;
|
|
4968
5005
|
if (templateAST.type === "multi-node") {
|
|
@@ -4998,6 +5035,7 @@ var BeaconPlugin = function() {
|
|
|
4998
5035
|
value: function apply(view) {
|
|
4999
5036
|
view.hooks.parser.tap("template", this.applyParser.bind(this));
|
|
5000
5037
|
view.hooks.resolver.tap("template", this.applyResolverHooks.bind(this));
|
|
5038
|
+
view.hooks.onTemplatePluginCreated.call(this);
|
|
5001
5039
|
}
|
|
5002
5040
|
}
|
|
5003
5041
|
]);
|