@player-ui/async-node-plugin 0.11.0--canary.609.21441 → 0.11.0--canary.614.21623
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.
|
@@ -4966,10 +4966,32 @@ var AsyncNodePlugin = function() {
|
|
|
4966
4966
|
node.children.push(newChild);
|
|
4967
4967
|
return node;
|
|
4968
4968
|
}
|
|
4969
|
+
},
|
|
4970
|
+
{
|
|
4971
|
+
key: "updateChildrenByPath",
|
|
4972
|
+
value: /**
|
|
4973
|
+
* Updates children of a node of the same path and preserves order
|
|
4974
|
+
*
|
|
4975
|
+
* @param node - The node to update children for
|
|
4976
|
+
* @param pathToMatch - The path to match against child paths
|
|
4977
|
+
* @param mapFn - Function to transform matching children
|
|
4978
|
+
*/ function updateChildrenByPath(node, pathToMatch, updateFn) {
|
|
4979
|
+
if (!node.children) return node;
|
|
4980
|
+
var updatedChildren = node.children.map(function(child) {
|
|
4981
|
+
return(// Check if paths match exactly
|
|
4982
|
+
child.path.join() === pathToMatch.join() ? _object_spread_props(_object_spread({}, child), {
|
|
4983
|
+
value: updateFn(child)
|
|
4984
|
+
}) : child);
|
|
4985
|
+
});
|
|
4986
|
+
return _object_spread_props(_object_spread({}, node), {
|
|
4987
|
+
children: updatedChildren
|
|
4988
|
+
});
|
|
4989
|
+
}
|
|
4969
4990
|
}
|
|
4970
4991
|
]);
|
|
4971
4992
|
return _Builder;
|
|
4972
4993
|
}();
|
|
4994
|
+
var templateSymbol = Symbol("template");
|
|
4973
4995
|
var TemplatePlugin = /*#__PURE__*/ function() {
|
|
4974
4996
|
function TemplatePlugin(options) {
|
|
4975
4997
|
_class_call_check(this, TemplatePlugin);
|
|
@@ -5040,6 +5062,9 @@ var AsyncNodePlugin = function() {
|
|
|
5040
5062
|
override: false,
|
|
5041
5063
|
values: values
|
|
5042
5064
|
};
|
|
5065
|
+
if (node.placement !== void 0) {
|
|
5066
|
+
result[templateSymbol] = node.placement;
|
|
5067
|
+
}
|
|
5043
5068
|
return result;
|
|
5044
5069
|
}
|
|
5045
5070
|
},
|
|
@@ -5053,6 +5078,38 @@ var AsyncNodePlugin = function() {
|
|
|
5053
5078
|
}
|
|
5054
5079
|
return node;
|
|
5055
5080
|
});
|
|
5081
|
+
parser.hooks.onCreateASTNode.tap("template-sort", function(node) {
|
|
5082
|
+
var getTemplateSymbolValue = function getTemplateSymbolValue(node2) {
|
|
5083
|
+
if (node2.type === "multi-node") {
|
|
5084
|
+
return node2[templateSymbol];
|
|
5085
|
+
} else if (node2.type === "template") {
|
|
5086
|
+
return node2.placement;
|
|
5087
|
+
}
|
|
5088
|
+
return void 0;
|
|
5089
|
+
};
|
|
5090
|
+
if (node && (node.type === "view" || node.type === "asset") && Array.isArray(node.children)) {
|
|
5091
|
+
node.children = node.children.sort(function(a, b) {
|
|
5092
|
+
var pathsEqual = a.path.join() === b.path.join();
|
|
5093
|
+
if (pathsEqual) {
|
|
5094
|
+
var aPlacement = getTemplateSymbolValue(a.value);
|
|
5095
|
+
var bPlacement = getTemplateSymbolValue(b.value);
|
|
5096
|
+
if (aPlacement !== void 0 && bPlacement === void 0) {
|
|
5097
|
+
return aPlacement === "prepend" ? -1 : 1;
|
|
5098
|
+
} else if (bPlacement !== void 0 && aPlacement === void 0) {
|
|
5099
|
+
return bPlacement === "prepend" ? 1 : -1;
|
|
5100
|
+
} else if (aPlacement !== void 0 && bPlacement !== void 0) {
|
|
5101
|
+
if (aPlacement === bPlacement) {
|
|
5102
|
+
return 0;
|
|
5103
|
+
}
|
|
5104
|
+
return aPlacement === "prepend" ? -1 : 1;
|
|
5105
|
+
}
|
|
5106
|
+
return 0;
|
|
5107
|
+
}
|
|
5108
|
+
return 0;
|
|
5109
|
+
});
|
|
5110
|
+
}
|
|
5111
|
+
return node;
|
|
5112
|
+
});
|
|
5056
5113
|
parser.hooks.parseNode.tap("template", function(obj, _nodeType, options, childOptions) {
|
|
5057
5114
|
if (childOptions && hasTemplateKey(childOptions.key)) {
|
|
5058
5115
|
return obj.map(function(template) {
|
|
@@ -5062,7 +5119,8 @@ var AsyncNodePlugin = function() {
|
|
|
5062
5119
|
depth: (_options_templateDepth = options.templateDepth) !== null && _options_templateDepth !== void 0 ? _options_templateDepth : 0,
|
|
5063
5120
|
data: template.data,
|
|
5064
5121
|
template: template.value,
|
|
5065
|
-
dynamic: (_template_dynamic = template.dynamic) !== null && _template_dynamic !== void 0 ? _template_dynamic : false
|
|
5122
|
+
dynamic: (_template_dynamic = template.dynamic) !== null && _template_dynamic !== void 0 ? _template_dynamic : false,
|
|
5123
|
+
placement: template.placement
|
|
5066
5124
|
}, template);
|
|
5067
5125
|
if (!templateAST) return;
|
|
5068
5126
|
if (templateAST.type === "multi-node") {
|