@player-ui/player 0.11.0-next.2 → 0.11.0-next.4

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.
@@ -3170,10 +3170,32 @@ var Builder = class _Builder {
3170
3170
  node.children.push(newChild);
3171
3171
  return node;
3172
3172
  }
3173
+ /**
3174
+ * Updates children of a node of the same path and preserves order
3175
+ *
3176
+ * @param node - The node to update children for
3177
+ * @param pathToMatch - The path to match against child paths
3178
+ * @param mapFn - Function to transform matching children
3179
+ */
3180
+ static updateChildrenByPath(node, pathToMatch, updateFn) {
3181
+ if (!node.children)
3182
+ return node;
3183
+ const updatedChildren = node.children.map(
3184
+ (child) => (
3185
+ // Check if paths match exactly
3186
+ child.path.join() === pathToMatch.join() ? { ...child, value: updateFn(child) } : child
3187
+ )
3188
+ );
3189
+ return {
3190
+ ...node,
3191
+ children: updatedChildren
3192
+ };
3193
+ }
3173
3194
  };
3174
3195
 
3175
3196
  // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/view/plugins/template.ts
3176
3197
  var import_tapable_ts9 = require("tapable-ts");
3198
+ var templateSymbol = Symbol("template");
3177
3199
  var TemplatePlugin = class {
3178
3200
  constructor(options) {
3179
3201
  this.hooks = {
@@ -3225,6 +3247,9 @@ var TemplatePlugin = class {
3225
3247
  override: false,
3226
3248
  values
3227
3249
  };
3250
+ if (node.placement !== void 0) {
3251
+ result[templateSymbol] = node.placement;
3252
+ }
3228
3253
  return result;
3229
3254
  }
3230
3255
  applyParser(parser) {
@@ -3238,6 +3263,40 @@ var TemplatePlugin = class {
3238
3263
  }
3239
3264
  return node;
3240
3265
  });
3266
+ parser.hooks.onCreateASTNode.tap("template", (node) => {
3267
+ function getTemplateSymbolValue(node2) {
3268
+ if (node2.type === "multi-node" /* MultiNode */) {
3269
+ return node2[templateSymbol];
3270
+ } else if (node2.type === "template" /* Template */) {
3271
+ return node2.placement;
3272
+ }
3273
+ return void 0;
3274
+ }
3275
+ if (node && (node.type === "view" /* View */ || node.type === "asset" /* Asset */) && Array.isArray(node.children)) {
3276
+ node.children = node.children.sort((a, b) => {
3277
+ const aPath = a.path.join();
3278
+ const bPath = b.path.join();
3279
+ const pathsEqual = aPath === bPath;
3280
+ if (pathsEqual) {
3281
+ const aPlacement = getTemplateSymbolValue(a.value);
3282
+ const bPlacement = getTemplateSymbolValue(b.value);
3283
+ if (aPlacement !== void 0 && bPlacement === void 0) {
3284
+ return aPlacement === "prepend" ? -1 : 1;
3285
+ } else if (bPlacement !== void 0 && aPlacement === void 0) {
3286
+ return bPlacement === "prepend" ? 1 : -1;
3287
+ } else if (aPlacement !== void 0 && bPlacement !== void 0) {
3288
+ if (aPlacement === bPlacement) {
3289
+ return 0;
3290
+ }
3291
+ return aPlacement === "prepend" ? -1 : 1;
3292
+ }
3293
+ return 0;
3294
+ }
3295
+ return aPath > bPath ? 1 : -1;
3296
+ });
3297
+ }
3298
+ return node;
3299
+ });
3241
3300
  parser.hooks.parseNode.tap(
3242
3301
  "template",
3243
3302
  (obj, _nodeType, options, childOptions) => {
@@ -3249,7 +3308,8 @@ var TemplatePlugin = class {
3249
3308
  depth: options.templateDepth ?? 0,
3250
3309
  data: template.data,
3251
3310
  template: template.value,
3252
- dynamic: template.dynamic ?? false
3311
+ dynamic: template.dynamic ?? false,
3312
+ placement: template.placement
3253
3313
  },
3254
3314
  template
3255
3315
  );