@player-ui/reference-assets-plugin 0.13.0 → 0.14.0-next.0

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.
@@ -1546,22 +1546,6 @@ var ReferenceAssetsPlugin = function() {
1546
1546
  }
1547
1547
  });
1548
1548
  };
1549
- var unpackNode = function unpackNode(item) {
1550
- var _item_children_, _item_children, _item_children_1, _item_children1;
1551
- var unpacked = [];
1552
- if ("children" in item && ((_item_children = item.children) === null || _item_children === void 0 ? void 0 : (_item_children_ = _item_children[0]) === null || _item_children_ === void 0 ? void 0 : _item_children_.value.type) === "asset" && ((_item_children1 = item.children) === null || _item_children1 === void 0 ? void 0 : (_item_children_1 = _item_children1[0]) === null || _item_children_1 === void 0 ? void 0 : _item_children_1.value).children) {
1553
- var _item_children__value_children_, _item_children__value_children, _item_children_2, _item_children2;
1554
- if (((_item_children__value_children = ((_item_children2 = item.children) === null || _item_children2 === void 0 ? void 0 : (_item_children_2 = _item_children2[0]) === null || _item_children_2 === void 0 ? void 0 : _item_children_2.value).children) === null || _item_children__value_children === void 0 ? void 0 : (_item_children__value_children_ = _item_children__value_children[0]) === null || _item_children__value_children_ === void 0 ? void 0 : _item_children__value_children_.value.type) === "multi-node") {
1555
- var _item_children__value_children_1, _item_children__value_children1, _item_children_3, _item_children3;
1556
- ((_item_children__value_children1 = ((_item_children3 = item.children) === null || _item_children3 === void 0 ? void 0 : (_item_children_3 = _item_children3[0]) === null || _item_children_3 === void 0 ? void 0 : _item_children_3.value).children) === null || _item_children__value_children1 === void 0 ? void 0 : (_item_children__value_children_1 = _item_children__value_children1[0]) === null || _item_children__value_children_1 === void 0 ? void 0 : _item_children__value_children_1.value).values.forEach(function(value) {
1557
- unpacked.push(value);
1558
- });
1559
- }
1560
- } else {
1561
- unpacked.push(item);
1562
- }
1563
- return unpacked;
1564
- };
1565
1549
  var hasSomethingToResolve = function hasSomethingToResolve(str) {
1566
1550
  return bindingResolveLookup(str) || expressionResolveLookup(str);
1567
1551
  };
@@ -1891,7 +1875,7 @@ var ReferenceAssetsPlugin = function() {
1891
1875
  exports.merge = merge;
1892
1876
  exports.mergeDeep = mergeDeep;
1893
1877
  exports.mergeIn = mergeIn;
1894
- exports.omit = omit4;
1878
+ exports.omit = omit3;
1895
1879
  exports.addDefaults = addDefaults;
1896
1880
  exports.default = void 0;
1897
1881
  var INVALID_ARGS = "INVALID_ARGS";
@@ -2065,7 +2049,7 @@ var ReferenceAssetsPlugin = function() {
2065
2049
  }
2066
2050
  return setIn8(a, path, nextVal);
2067
2051
  }
2068
- function omit4(obj, attrs) {
2052
+ function omit3(obj, attrs) {
2069
2053
  var omitList = Array.isArray(attrs) ? attrs : [
2070
2054
  attrs
2071
2055
  ];
@@ -2151,7 +2135,7 @@ var ReferenceAssetsPlugin = function() {
2151
2135
  merge: merge,
2152
2136
  mergeDeep: mergeDeep,
2153
2137
  mergeIn: mergeIn,
2154
- omit: omit4,
2138
+ omit: omit3,
2155
2139
  addDefaults: addDefaults
2156
2140
  };
2157
2141
  var _default = timm;
@@ -3085,6 +3069,7 @@ var ReferenceAssetsPlugin = function() {
3085
3069
  }
3086
3070
  };
3087
3071
  var identifier = function() {
3072
+ var allowBoolValue = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
3088
3073
  if (!isIdentifierChar(ch)) {
3089
3074
  return;
3090
3075
  }
@@ -3095,6 +3080,14 @@ var ReferenceAssetsPlugin = function() {
3095
3080
  }
3096
3081
  value += ch;
3097
3082
  }
3083
+ if (allowBoolValue) {
3084
+ if (value === "true") {
3085
+ return toValue(true);
3086
+ }
3087
+ if (value === "false") {
3088
+ return toValue(false);
3089
+ }
3090
+ }
3098
3091
  if (value) {
3099
3092
  var maybeNumber = Number(value);
3100
3093
  value = isNaN(maybeNumber) ? value : maybeNumber;
@@ -3143,8 +3136,9 @@ var ReferenceAssetsPlugin = function() {
3143
3136
  }
3144
3137
  };
3145
3138
  var simpleSegment = function() {
3139
+ var allowBoolValue = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
3146
3140
  var _nestedPath, _ref;
3147
- return (_ref = (_nestedPath = nestedPath()) !== null && _nestedPath !== void 0 ? _nestedPath : expression()) !== null && _ref !== void 0 ? _ref : identifier();
3141
+ return (_ref = (_nestedPath = nestedPath()) !== null && _nestedPath !== void 0 ? _nestedPath : expression()) !== null && _ref !== void 0 ? _ref : identifier(allowBoolValue);
3148
3142
  };
3149
3143
  var segment = function() {
3150
3144
  var segments = [];
@@ -3159,6 +3153,7 @@ var ReferenceAssetsPlugin = function() {
3159
3153
  return toConcatenatedNode(segments);
3160
3154
  };
3161
3155
  var optionallyQuotedSegment = function() {
3156
+ var allowBoolValue = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
3162
3157
  whitespace();
3163
3158
  if (ch === SINGLE_QUOTE || ch === DOUBLE_QUOTE) {
3164
3159
  var singleQuote = ch === SINGLE_QUOTE;
@@ -3167,7 +3162,7 @@ var ReferenceAssetsPlugin = function() {
3167
3162
  next(singleQuote ? SINGLE_QUOTE : DOUBLE_QUOTE);
3168
3163
  return id;
3169
3164
  }
3170
- return simpleSegment();
3165
+ return simpleSegment(allowBoolValue);
3171
3166
  };
3172
3167
  var equals = function() {
3173
3168
  if (ch !== EQUALS) {
@@ -3187,7 +3182,7 @@ var ReferenceAssetsPlugin = function() {
3187
3182
  whitespace();
3188
3183
  if (equals()) {
3189
3184
  whitespace();
3190
- var second = optionallyQuotedSegment();
3185
+ var second = optionallyQuotedSegment(true);
3191
3186
  value = toQuery(value, second);
3192
3187
  whitespace();
3193
3188
  }
@@ -3375,7 +3370,7 @@ var ReferenceAssetsPlugin = function() {
3375
3370
  appendPathSegments(getValueForNode(resolvedNode));
3376
3371
  break;
3377
3372
  case "Value":
3378
- appendPathSegments(resolvedNode.value);
3373
+ appendPathSegments(typeof resolvedNode.value === "boolean" ? String(resolvedNode.value) : resolvedNode.value);
3379
3374
  break;
3380
3375
  case "Query":
3381
3376
  {
@@ -4955,23 +4950,8 @@ var ReferenceAssetsPlugin = function() {
4955
4950
  function Parser() {
4956
4951
  _class_call_check(this, Parser);
4957
4952
  this.hooks = {
4958
- /**
4959
- * A hook to interact with an object _before_ parsing it into an AST
4960
- *
4961
- * @param value - The object we're are about to parse
4962
- * @returns - A new value to parse.
4963
- * If undefined, the original value is used.
4964
- * If null, we stop parsing this node.
4965
- */ onParseObject: new SyncWaterfallHook(),
4966
- /**
4967
- * A callback to interact with an AST _after_ we parse it into the AST
4968
- *
4969
- * @param value - The object we parsed
4970
- * @param node - The AST node we generated
4971
- * @returns - A new AST node to use
4972
- * If undefined, the original value is used.
4973
- * If null, we ignore this node all together
4974
- */ onCreateASTNode: new SyncWaterfallHook(),
4953
+ onParseObject: new SyncWaterfallHook(),
4954
+ onCreateASTNode: new SyncWaterfallHook(),
4975
4955
  parseNode: new SyncBailHook()
4976
4956
  };
4977
4957
  }
@@ -5113,20 +5093,14 @@ var ReferenceAssetsPlugin = function() {
5113
5093
  function Resolver(root, options) {
5114
5094
  _class_call_check(this, Resolver);
5115
5095
  this.hooks = {
5116
- /** A hook to allow skipping of the resolution tree for a specific node */ skipResolve: new SyncWaterfallHook(),
5117
- /** An event emitted before calculating the next update */ beforeUpdate: new SyncHook(),
5118
- /** An event emitted after calculating the next update */ afterUpdate: new SyncHook(),
5119
- /** The options passed to a node to resolve it to an object */ resolveOptions: new SyncWaterfallHook(),
5120
- /** A hook to transform the AST node into a new AST node before resolving it */ beforeResolve: new SyncWaterfallHook(),
5121
- /**
5122
- * A hook to transform an AST node into it's resolved value.
5123
- * This runs _before_ any children are resolved
5124
- */ resolve: new SyncWaterfallHook(),
5125
- /**
5126
- * A hook to transform the resolved value of an AST node.
5127
- * This runs _after_ all children nodes are resolved
5128
- */ afterResolve: new SyncWaterfallHook(),
5129
- /** Called at the very end of a node's tree being updated */ afterNodeUpdate: new SyncHook()
5096
+ skipResolve: new SyncWaterfallHook(),
5097
+ beforeUpdate: new SyncHook(),
5098
+ afterUpdate: new SyncHook(),
5099
+ resolveOptions: new SyncWaterfallHook(),
5100
+ beforeResolve: new SyncWaterfallHook(),
5101
+ resolve: new SyncWaterfallHook(),
5102
+ afterResolve: new SyncWaterfallHook(),
5103
+ afterNodeUpdate: new SyncHook()
5130
5104
  };
5131
5105
  this.root = root;
5132
5106
  this.options = options;
@@ -5134,6 +5108,7 @@ var ReferenceAssetsPlugin = function() {
5134
5108
  this.ASTMap = /* @__PURE__ */ new Map();
5135
5109
  this.logger = options.logger;
5136
5110
  this.idCache = /* @__PURE__ */ new Set();
5111
+ this.AsyncIdMap = /* @__PURE__ */ new Map();
5137
5112
  }
5138
5113
  _create_class(Resolver, [
5139
5114
  {
@@ -5144,13 +5119,27 @@ var ReferenceAssetsPlugin = function() {
5144
5119
  },
5145
5120
  {
5146
5121
  key: "update",
5147
- value: function update(changes) {
5122
+ value: function update(changes, asyncChanges) {
5123
+ var _this = this;
5148
5124
  this.hooks.beforeUpdate.call(changes);
5149
5125
  var resolveCache = /* @__PURE__ */ new Map();
5150
5126
  this.idCache.clear();
5151
5127
  var prevASTMap = new Map(this.ASTMap);
5152
5128
  this.ASTMap.clear();
5153
- var updated = this.computeTree(this.root, void 0, changes, resolveCache, toNodeResolveOptions(this.options), void 0, prevASTMap);
5129
+ var prevAsyncIdMap = new Map(this.AsyncIdMap);
5130
+ var nextAsyncIdMap = /* @__PURE__ */ new Map();
5131
+ asyncChanges === null || asyncChanges === void 0 ? void 0 : asyncChanges.forEach(function(id) {
5132
+ var current = prevAsyncIdMap.get(id);
5133
+ while(current && prevASTMap.has(current)){
5134
+ var next = prevASTMap.get(current);
5135
+ if (next && _this.resolveCache.has(next)) {
5136
+ _this.resolveCache.delete(next);
5137
+ }
5138
+ current = current.parent;
5139
+ }
5140
+ });
5141
+ var updated = this.computeTree(this.root, void 0, changes, resolveCache, toNodeResolveOptions(this.options), void 0, prevASTMap, nextAsyncIdMap);
5142
+ this.AsyncIdMap = nextAsyncIdMap;
5154
5143
  this.resolveCache = resolveCache;
5155
5144
  this.hooks.afterUpdate.call(updated.value);
5156
5145
  return updated.value;
@@ -5204,9 +5193,8 @@ var ReferenceAssetsPlugin = function() {
5204
5193
  },
5205
5194
  {
5206
5195
  key: "computeTree",
5207
- value: function computeTree(node, rawParent, dataChanges, cacheUpdate, options, partiallyResolvedParent, prevASTMap) {
5196
+ value: function computeTree(node, rawParent, dataChanges, cacheUpdate, options, partiallyResolvedParent, prevASTMap, nextAsyncIdMap) {
5208
5197
  var _this = this;
5209
- var _partiallyResolvedParent_parent_parent, _partiallyResolvedParent_parent, _resolvedAST_parent, _partiallyResolvedParent_parent1;
5210
5198
  var dependencyModel = new DependencyModel(options.data.model);
5211
5199
  dependencyModel.trackSubset("core");
5212
5200
  var depModelWithParser = withContext(withParser(dependencyModel, this.options.parseBinding));
@@ -5225,15 +5213,6 @@ var ReferenceAssetsPlugin = function() {
5225
5213
  var previousDeps = previousResult === null || previousResult === void 0 ? void 0 : previousResult.dependencies;
5226
5214
  var dataChanged = caresAboutDataChanges(dataChanges, previousDeps);
5227
5215
  var shouldUseLastValue = this.hooks.skipResolve.call(!dataChanged, node, resolveOptions);
5228
- var clonedNode = _object_spread_props(_object_spread({}, this.cloneNode(node)), {
5229
- parent: partiallyResolvedParent
5230
- });
5231
- var _this_hooks_beforeResolve_call;
5232
- var resolvedAST = (_this_hooks_beforeResolve_call = this.hooks.beforeResolve.call(clonedNode, resolveOptions)) !== null && _this_hooks_beforeResolve_call !== void 0 ? _this_hooks_beforeResolve_call : {
5233
- type: "empty"
5234
- };
5235
- var isNestedMultiNodeWithAsync = resolvedAST.type === "multi-node" && (partiallyResolvedParent === null || partiallyResolvedParent === void 0 ? void 0 : (_partiallyResolvedParent_parent = partiallyResolvedParent.parent) === null || _partiallyResolvedParent_parent === void 0 ? void 0 : (_partiallyResolvedParent_parent_parent = _partiallyResolvedParent_parent.parent) === null || _partiallyResolvedParent_parent_parent === void 0 ? void 0 : _partiallyResolvedParent_parent_parent.type) === "multi-node" && partiallyResolvedParent.parent.type === "value" && ((_resolvedAST_parent = resolvedAST.parent) === null || _resolvedAST_parent === void 0 ? void 0 : _resolvedAST_parent.type) === "asset" && resolvedAST.parent.value.id.includes("async");
5236
- var isNestedMultiNode = resolvedAST.type === "multi-node" && (partiallyResolvedParent === null || partiallyResolvedParent === void 0 ? void 0 : (_partiallyResolvedParent_parent1 = partiallyResolvedParent.parent) === null || _partiallyResolvedParent_parent1 === void 0 ? void 0 : _partiallyResolvedParent_parent1.type) === "multi-node" && partiallyResolvedParent.type === "value";
5237
5216
  if (previousResult && shouldUseLastValue) {
5238
5217
  var update2 = _object_spread_props(_object_spread({}, previousResult), {
5239
5218
  updated: false
@@ -5245,6 +5224,30 @@ var ReferenceAssetsPlugin = function() {
5245
5224
  updated: false
5246
5225
  });
5247
5226
  cacheUpdate.set(AST, resolvedUpdate);
5227
+ if (resolvedUpdate.node.type === "async") {
5228
+ nextAsyncIdMap.set(resolvedUpdate.node.id, resolvedUpdate.node);
5229
+ }
5230
+ var _resolvedUpdate_node_asyncNodesResolved;
5231
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
5232
+ try {
5233
+ for(var _iterator = ((_resolvedUpdate_node_asyncNodesResolved = resolvedUpdate.node.asyncNodesResolved) !== null && _resolvedUpdate_node_asyncNodesResolved !== void 0 ? _resolvedUpdate_node_asyncNodesResolved : [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
5234
+ var key = _step.value;
5235
+ nextAsyncIdMap.set(key, resolvedUpdate.node);
5236
+ }
5237
+ } catch (err) {
5238
+ _didIteratorError = true;
5239
+ _iteratorError = err;
5240
+ } finally{
5241
+ try {
5242
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
5243
+ _iterator.return();
5244
+ }
5245
+ } finally{
5246
+ if (_didIteratorError) {
5247
+ throw _iteratorError;
5248
+ }
5249
+ }
5250
+ }
5248
5251
  var handleChildNode = function(childNode) {
5249
5252
  var _prevASTMap_get;
5250
5253
  var originalChildNode = (_prevASTMap_get = prevASTMap.get(childNode)) !== null && _prevASTMap_get !== void 0 ? _prevASTMap_get : childNode;
@@ -5267,10 +5270,37 @@ var ReferenceAssetsPlugin = function() {
5267
5270
  repopulateASTMapFromCache(previousResult, node, rawParent);
5268
5271
  return update2;
5269
5272
  }
5270
- if (isNestedMultiNodeWithAsync) {
5271
- resolvedAST.parent = partiallyResolvedParent.parent;
5272
- } else {
5273
- resolvedAST.parent = partiallyResolvedParent;
5273
+ var clonedNode = _object_spread_props(_object_spread({}, this.cloneNode(node)), {
5274
+ parent: partiallyResolvedParent
5275
+ });
5276
+ var _this_hooks_beforeResolve_call;
5277
+ var resolvedAST = (_this_hooks_beforeResolve_call = this.hooks.beforeResolve.call(clonedNode, resolveOptions)) !== null && _this_hooks_beforeResolve_call !== void 0 ? _this_hooks_beforeResolve_call : {
5278
+ type: "empty"
5279
+ };
5280
+ resolvedAST.parent = partiallyResolvedParent;
5281
+ if (resolvedAST.type === "async") {
5282
+ nextAsyncIdMap.set(resolvedAST.id, resolvedAST);
5283
+ }
5284
+ var _resolvedAST_asyncNodesResolved;
5285
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
5286
+ try {
5287
+ for(var _iterator = ((_resolvedAST_asyncNodesResolved = resolvedAST.asyncNodesResolved) !== null && _resolvedAST_asyncNodesResolved !== void 0 ? _resolvedAST_asyncNodesResolved : [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
5288
+ var id = _step.value;
5289
+ nextAsyncIdMap.set(id, resolvedAST);
5290
+ }
5291
+ } catch (err) {
5292
+ _didIteratorError = true;
5293
+ _iteratorError = err;
5294
+ } finally{
5295
+ try {
5296
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
5297
+ _iterator.return();
5298
+ }
5299
+ } finally{
5300
+ if (_didIteratorError) {
5301
+ throw _iteratorError;
5302
+ }
5303
+ }
5274
5304
  }
5275
5305
  resolveOptions.node = resolvedAST;
5276
5306
  this.ASTMap.set(resolvedAST, node);
@@ -5284,7 +5314,7 @@ var ReferenceAssetsPlugin = function() {
5284
5314
  if ("children" in resolvedAST) {
5285
5315
  var _resolvedAST_children;
5286
5316
  var newChildren = (_resolvedAST_children = resolvedAST.children) === null || _resolvedAST_children === void 0 ? void 0 : _resolvedAST_children.map(function(child) {
5287
- var computedChildTree = _this.computeTree(child.value, node, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap);
5317
+ var computedChildTree = _this.computeTree(child.value, node, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap, nextAsyncIdMap);
5288
5318
  var childTreeDeps = computedChildTree.dependencies, childNode = computedChildTree.node, childUpdated = computedChildTree.updated, childValue = computedChildTree.value;
5289
5319
  childTreeDeps.forEach(function(binding) {
5290
5320
  return childDependencies.add(binding);
@@ -5305,40 +5335,18 @@ var ReferenceAssetsPlugin = function() {
5305
5335
  resolvedAST.children = newChildren;
5306
5336
  } else if (resolvedAST.type === "multi-node") {
5307
5337
  var childValue = [];
5308
- var rawParentToPassIn = isNestedMultiNode ? partiallyResolvedParent === null || partiallyResolvedParent === void 0 ? void 0 : partiallyResolvedParent.parent : node;
5309
- var hasAsync = resolvedAST.values.map(function(value, index) {
5310
- return value.type === "async" ? index : -1;
5311
- }).filter(function(index) {
5312
- return index !== -1;
5313
- });
5314
- var newValues = resolvedAST.values.map(function(mValue) {
5315
- var mTree = _this.computeTree(mValue, rawParentToPassIn, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap);
5338
+ var rawParentToPassIn = node;
5339
+ resolvedAST.values = resolvedAST.values.map(function(mValue) {
5340
+ var mTree = _this.computeTree(mValue, rawParentToPassIn, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap, nextAsyncIdMap);
5316
5341
  if (mTree.value !== void 0 && mTree.value !== null) {
5317
- if (mValue.type === "async" && mValue.flatten && mTree.value.asset && Array.isArray(mTree.value.asset.values)) {
5318
- unpackAndPush(mTree.value, childValue);
5319
- } else {
5320
- childValue.push(mTree.value);
5321
- }
5342
+ mTree.dependencies.forEach(function(bindingDep) {
5343
+ return childDependencies.add(bindingDep);
5344
+ });
5345
+ updated = updated || mTree.updated;
5346
+ childValue.push(mTree.value);
5322
5347
  }
5323
- mTree.dependencies.forEach(function(bindingDep) {
5324
- return childDependencies.add(bindingDep);
5325
- });
5326
- updated = updated || mTree.updated;
5327
5348
  return mTree.node;
5328
5349
  });
5329
- if (hasAsync.length > 0) {
5330
- var copy = newValues;
5331
- hasAsync.forEach(function(index) {
5332
- var _copy;
5333
- if (copy[index]) (_copy = copy).splice.apply(_copy, [
5334
- index,
5335
- 1
5336
- ].concat(_to_consumable_array(unpackNode(copy[index]))));
5337
- });
5338
- resolvedAST.values = copy;
5339
- } else {
5340
- resolvedAST.values = newValues;
5341
- }
5342
5350
  resolved = childValue;
5343
5351
  }
5344
5352
  childDependencies.forEach(function(bindingDep) {
@@ -5359,7 +5367,7 @@ var ReferenceAssetsPlugin = function() {
5359
5367
  value: resolved,
5360
5368
  dependencies: /* @__PURE__ */ new Set(_to_consumable_array(dependencyModel.getDependencies()).concat(_to_consumable_array(childDependencies)))
5361
5369
  };
5362
- this.hooks.afterNodeUpdate.call(node, isNestedMultiNode ? partiallyResolvedParent === null || partiallyResolvedParent === void 0 ? void 0 : partiallyResolvedParent.parent : rawParent, update);
5370
+ this.hooks.afterNodeUpdate.call(node, rawParent, update);
5363
5371
  cacheUpdate.set(node, update);
5364
5372
  return update;
5365
5373
  }
@@ -5367,15 +5375,6 @@ var ReferenceAssetsPlugin = function() {
5367
5375
  ]);
5368
5376
  return Resolver;
5369
5377
  }();
5370
- function unpackAndPush(item, initial) {
5371
- if (item.asset.values && Array.isArray(item.asset.values)) {
5372
- item.asset.values.forEach(function(i) {
5373
- unpackAndPush(i, initial);
5374
- });
5375
- } else {
5376
- initial.push(item);
5377
- }
5378
- }
5379
5378
  var CrossfieldProvider = /*#__PURE__*/ function() {
5380
5379
  function CrossfieldProvider(initialView, parser, logger) {
5381
5380
  _class_call_check(this, CrossfieldProvider);
@@ -5443,9 +5442,11 @@ var ReferenceAssetsPlugin = function() {
5443
5442
  _create_class(ViewInstance, [
5444
5443
  {
5445
5444
  key: "updateAsync",
5446
- value: function updateAsync() {
5445
+ value: function updateAsync(asyncNode) {
5447
5446
  var _this_resolver;
5448
- var update = (_this_resolver = this.resolver) === null || _this_resolver === void 0 ? void 0 : _this_resolver.update();
5447
+ var update = (_this_resolver = this.resolver) === null || _this_resolver === void 0 ? void 0 : _this_resolver.update(/* @__PURE__ */ new Set(), /* @__PURE__ */ new Set([
5448
+ asyncNode
5449
+ ]));
5449
5450
  this.lastUpdate = update;
5450
5451
  this.hooks.onUpdate.call(update);
5451
5452
  }
@@ -5563,11 +5564,12 @@ var ReferenceAssetsPlugin = function() {
5563
5564
  *
5564
5565
  * @param id - the id of async node. It should be identical for each async node
5565
5566
  */ function asyncNode(id) {
5566
- var flatten2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
5567
+ var flatten2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true, onValueReceived = arguments.length > 2 ? arguments[2] : void 0;
5567
5568
  return {
5568
5569
  id: id,
5569
5570
  type: "async",
5570
5571
  flatten: flatten2,
5572
+ onValueReceived: onValueReceived,
5571
5573
  value: {
5572
5574
  type: "value",
5573
5575
  value: {
@@ -6113,7 +6115,7 @@ var ReferenceAssetsPlugin = function() {
6113
6115
  key: "applyParser",
6114
6116
  value: function applyParser(parser) {
6115
6117
  parser.hooks.parseNode.tap("multi-node", function(obj, nodeType, options, childOptions) {
6116
- if (childOptions && !hasTemplateKey(childOptions.key) && Array.isArray(obj)) {
6118
+ if ((childOptions === void 0 || !hasTemplateKey(childOptions.key)) && Array.isArray(obj)) {
6117
6119
  var values = obj.map(function(childVal) {
6118
6120
  return parser.parseObject(childVal, "value", options);
6119
6121
  }).filter(function(child) {
@@ -6124,7 +6126,7 @@ var ReferenceAssetsPlugin = function() {
6124
6126
  }
6125
6127
  var multiNode = parser.createASTNode({
6126
6128
  type: "multi-node",
6127
- override: !hasTemplateValues(childOptions.parentObj, childOptions.key),
6129
+ override: childOptions !== void 0 && !hasTemplateValues(childOptions.parentObj, childOptions.key),
6128
6130
  values: values
6129
6131
  }, obj);
6130
6132
  if (!multiNode) {
@@ -6135,7 +6137,7 @@ var ReferenceAssetsPlugin = function() {
6135
6137
  v.parent = multiNode;
6136
6138
  });
6137
6139
  }
6138
- return [
6140
+ return childOptions === void 0 ? multiNode : [
6139
6141
  {
6140
6142
  path: _to_consumable_array(childOptions.path).concat([
6141
6143
  childOptions.key
@@ -8333,26 +8335,134 @@ var ReferenceAssetsPlugin = function() {
8333
8335
  };
8334
8336
  // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/@player-ui+async-node-plugin@0.0.0/node_modules/@player-ui/async-node-plugin/dist/index.mjs
8335
8337
  var import_queue_microtask3 = __toESM(require_queue_microtask(), 1);
8336
- var import_timm10 = __toESM(require_timm(), 1);
8337
- var asyncTransform = function(assetId, wrapperAssetType, asset, flatten2) {
8338
- var id = "async-" + assetId;
8339
- var asyncNode = Builder.asyncNode(id, flatten2);
8340
- var multiNode;
8341
- var assetNode;
8342
- if (asset) {
8343
- assetNode = Builder.assetWrapper(asset);
8344
- multiNode = Builder.multiNode(assetNode, asyncNode);
8345
- } else {
8346
- multiNode = Builder.multiNode(asyncNode);
8338
+ var getMatchValue = function(pathA, pathB) {
8339
+ if (pathA.length > pathB.length) {
8340
+ return 0;
8341
+ }
8342
+ var matchCount = 0;
8343
+ for(var i = 0; i < pathA.length; i++){
8344
+ if (pathA[i] === pathB[i]) {
8345
+ matchCount++;
8346
+ } else {
8347
+ return 0;
8348
+ }
8349
+ }
8350
+ return matchCount;
8351
+ };
8352
+ var extractNodeFromPath = function(node, path) {
8353
+ if (path === void 0 || path.length === 0) {
8354
+ return node;
8355
+ }
8356
+ if (!("children" in node && node.children)) {
8357
+ return void 0;
8358
+ }
8359
+ var matchResult = 0;
8360
+ var bestMatch;
8361
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
8362
+ try {
8363
+ for(var _iterator = node.children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
8364
+ var child = _step.value;
8365
+ var matchValue = getMatchValue(child.path, path);
8366
+ if (matchValue > matchResult) {
8367
+ matchResult = matchValue;
8368
+ bestMatch = child;
8369
+ }
8370
+ }
8371
+ } catch (err) {
8372
+ _didIteratorError = true;
8373
+ _iteratorError = err;
8374
+ } finally{
8375
+ try {
8376
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
8377
+ _iterator.return();
8378
+ }
8379
+ } finally{
8380
+ if (_didIteratorError) {
8381
+ throw _iteratorError;
8382
+ }
8383
+ }
8384
+ }
8385
+ if (!bestMatch) {
8386
+ return void 0;
8387
+ }
8388
+ if (matchResult >= path.length) {
8389
+ return bestMatch.value;
8390
+ }
8391
+ return extractNodeFromPath(bestMatch.value, path.slice(matchResult));
8392
+ };
8393
+ var traverseAndReplace = function(node, replaceFn) {
8394
+ if (node.type === NodeType.MultiNode) {
8395
+ var index = 0;
8396
+ while(index < node.values.length){
8397
+ var child = node.values[index];
8398
+ if (!child) {
8399
+ index++;
8400
+ continue;
8401
+ }
8402
+ var result = replaceFn(child);
8403
+ if (result.type === NodeType.MultiNode) {
8404
+ node.values = _to_consumable_array(node.values.slice(0, index)).concat(_to_consumable_array(result.values), _to_consumable_array(node.values.slice(index + 1)));
8405
+ } else {
8406
+ node.values[index] = result;
8407
+ index++;
8408
+ }
8409
+ }
8410
+ return node;
8347
8411
  }
8348
- var wrapperAsset = Builder.asset({
8349
- id: wrapperAssetType + "-" + id,
8350
- type: wrapperAssetType
8412
+ return replaceFn(node);
8413
+ };
8414
+ var unwrapAsset = function(node) {
8415
+ var _node_children;
8416
+ if (node.type !== NodeType.Value) {
8417
+ return node;
8418
+ }
8419
+ var child = (_node_children = node.children) === null || _node_children === void 0 ? void 0 : _node_children.find(function(x) {
8420
+ return x.path.length === 1 && x.path[0] === "asset";
8351
8421
  });
8352
- Builder.addChild(wrapperAsset, [
8422
+ if (!child) {
8423
+ return node;
8424
+ }
8425
+ return child.value;
8426
+ };
8427
+ var defaultGetNodeId = function(node) {
8428
+ return "async-".concat(node.value.id);
8429
+ };
8430
+ var createAsyncTransform = function(options) {
8431
+ var transformAssetType = options.transformAssetType, wrapperAssetType = options.wrapperAssetType, getNestedAsset = options.getNestedAsset, _options_getAsyncNodeId = options.getAsyncNodeId, getAsyncNodeId = _options_getAsyncNodeId === void 0 ? defaultGetNodeId : _options_getAsyncNodeId, _options_path = options.path, path = _options_path === void 0 ? [
8353
8432
  "values"
8354
- ], multiNode);
8355
- return wrapperAsset;
8433
+ ] : _options_path, tmp = options.flatten, flatten2 = tmp === void 0 ? true : tmp;
8434
+ var replaceNode = function(node) {
8435
+ var unwrapped = unwrapAsset(node);
8436
+ if (unwrapped.type !== NodeType.Asset || unwrapped.value.type !== transformAssetType) {
8437
+ return node;
8438
+ }
8439
+ var transformed = asyncTransform2(unwrapped);
8440
+ var _extractNodeFromPath;
8441
+ return (_extractNodeFromPath = extractNodeFromPath(transformed, path)) !== null && _extractNodeFromPath !== void 0 ? _extractNodeFromPath : node;
8442
+ };
8443
+ var replacer = function(node) {
8444
+ return traverseAndReplace(node, replaceNode);
8445
+ };
8446
+ var asyncTransform2 = function(node) {
8447
+ var id = getAsyncNodeId(node);
8448
+ var asset = getNestedAsset === null || getNestedAsset === void 0 ? void 0 : getNestedAsset(node);
8449
+ var replaceFunction = flatten2 ? replacer : void 0;
8450
+ var asyncNode = Builder.asyncNode(id, flatten2, replaceFunction);
8451
+ var multiNode;
8452
+ if (asset) {
8453
+ var assetNode = Builder.assetWrapper(asset);
8454
+ multiNode = Builder.multiNode(assetNode, asyncNode);
8455
+ } else {
8456
+ multiNode = Builder.multiNode(asyncNode);
8457
+ }
8458
+ var wrapperAsset = Builder.asset({
8459
+ id: wrapperAssetType + "-" + id,
8460
+ type: wrapperAssetType
8461
+ });
8462
+ Builder.addChild(wrapperAsset, path, multiNode);
8463
+ return wrapperAsset;
8464
+ };
8465
+ return asyncTransform2;
8356
8466
  };
8357
8467
  var AsyncNodePluginSymbol = Symbol.for("AsyncNodePlugin");
8358
8468
  var _AsyncNodePlugin = /*#__PURE__*/ function() {
@@ -8439,6 +8549,9 @@ var ReferenceAssetsPlugin = function() {
8439
8549
  */ key: "parseNodeAndUpdate",
8440
8550
  value: function parseNodeAndUpdate(node, context, result, options) {
8441
8551
  var parsedNode = options.parseNode && result ? options.parseNode(result) : void 0;
8552
+ if (parsedNode && node.onValueReceived) {
8553
+ parsedNode = node.onValueReceived(parsedNode);
8554
+ }
8442
8555
  this.handleAsyncUpdate(node, context, parsedNode);
8443
8556
  }
8444
8557
  },
@@ -8456,10 +8569,17 @@ var ReferenceAssetsPlugin = function() {
8456
8569
  var nodeResolveCache = context.nodeResolveCache, view = context.view;
8457
8570
  if (nodeResolveCache.get(node.id) !== newNode) {
8458
8571
  nodeResolveCache.set(node.id, newNode ? newNode : node);
8459
- view.updateAsync();
8572
+ view.updateAsync(node.id);
8460
8573
  }
8461
8574
  }
8462
8575
  },
8576
+ {
8577
+ key: "hasValidMapping",
8578
+ value: function hasValidMapping(node, context) {
8579
+ var nodeResolveCache = context.nodeResolveCache;
8580
+ return nodeResolveCache.has(node.id) && nodeResolveCache.get(node.id) !== node;
8581
+ }
8582
+ },
8463
8583
  {
8464
8584
  /**
8465
8585
  * Handles the asynchronous API integration for resolving nodes.
@@ -8471,11 +8591,11 @@ var ReferenceAssetsPlugin = function() {
8471
8591
  var _this = this;
8472
8592
  resolver.hooks.beforeResolve.tap(this.name, function(node, options) {
8473
8593
  if (!_this.isAsync(node)) {
8474
- return node;
8594
+ return node === null ? node : _this.resolveAsyncChildren(node, context);
8475
8595
  }
8476
8596
  var resolvedNode = context.nodeResolveCache.get(node.id);
8477
8597
  if (resolvedNode !== void 0) {
8478
- return resolvedNode;
8598
+ return _this.resolveAsyncChildren(resolvedNode, context);
8479
8599
  }
8480
8600
  if (context.inProgressNodes.has(node.id)) {
8481
8601
  return node;
@@ -8488,6 +8608,52 @@ var ReferenceAssetsPlugin = function() {
8488
8608
  });
8489
8609
  }
8490
8610
  },
8611
+ {
8612
+ /**
8613
+ * Replaces child async nodes with their resolved content and flattens when necessary. Resolving the children directly helps manage the `parent` reference without needing as much work within the resolver itself.
8614
+ * Handles async node chains as well to make sure all applicable nodes can get flattened.
8615
+ * @param node - The node whose children need to be resolved.
8616
+ * @param context - the async plugin context needed to reach into the cache
8617
+ * @returns The same node but with async node children mapped to their resolved AST.
8618
+ */ key: "resolveAsyncChildren",
8619
+ value: function resolveAsyncChildren(node, context) {
8620
+ var _this = this;
8621
+ var _node_asyncNodesResolved;
8622
+ var asyncNodesResolved = (_node_asyncNodesResolved = node.asyncNodesResolved) !== null && _node_asyncNodesResolved !== void 0 ? _node_asyncNodesResolved : [];
8623
+ node.asyncNodesResolved = asyncNodesResolved;
8624
+ if (node.type === NodeType.MultiNode) {
8625
+ var index = 0;
8626
+ while(index < node.values.length){
8627
+ var childNode = node.values[index];
8628
+ if ((childNode === null || childNode === void 0 ? void 0 : childNode.type) !== NodeType.Async || !this.hasValidMapping(childNode, context)) {
8629
+ index++;
8630
+ continue;
8631
+ }
8632
+ var mappedNode = context.nodeResolveCache.get(childNode.id);
8633
+ asyncNodesResolved.push(childNode.id);
8634
+ if (mappedNode.type === NodeType.MultiNode && childNode.flatten) {
8635
+ mappedNode.values.forEach(function(v) {
8636
+ return v.parent = node;
8637
+ });
8638
+ node.values = _to_consumable_array(node.values.slice(0, index)).concat(_to_consumable_array(mappedNode.values), _to_consumable_array(node.values.slice(index + 1)));
8639
+ } else {
8640
+ node.values[index] = mappedNode;
8641
+ mappedNode.parent = node;
8642
+ }
8643
+ }
8644
+ } else if ("children" in node) {
8645
+ var _node_children;
8646
+ (_node_children = node.children) === null || _node_children === void 0 ? void 0 : _node_children.forEach(function(c) {
8647
+ while(c.value.type === NodeType.Async && _this.hasValidMapping(c.value, context)){
8648
+ asyncNodesResolved.push(c.value.id);
8649
+ c.value = context.nodeResolveCache.get(c.value.id);
8650
+ c.value.parent = node;
8651
+ }
8652
+ });
8653
+ }
8654
+ return node;
8655
+ }
8656
+ },
8491
8657
  {
8492
8658
  key: "runAsyncNode",
8493
8659
  value: function runAsyncNode(node, context, options) {
@@ -8556,7 +8722,7 @@ var ReferenceAssetsPlugin = function() {
8556
8722
  {
8557
8723
  key: "isDeterminedAsync",
8558
8724
  value: function isDeterminedAsync(obj) {
8559
- return obj && Object.prototype.hasOwnProperty.call(obj, "async");
8725
+ return typeof obj === "object" && obj !== null && Object.prototype.hasOwnProperty.call(obj, "async");
8560
8726
  }
8561
8727
  },
8562
8728
  {
@@ -8565,7 +8731,11 @@ var ReferenceAssetsPlugin = function() {
8565
8731
  var _this = this;
8566
8732
  parser.hooks.parseNode.tap(this.name, function(obj, nodeType, options, childOptions) {
8567
8733
  if (_this.isDeterminedAsync(obj)) {
8568
- var parsedAsync = parser.parseObject((0, import_timm10.omit)(obj, "async"), nodeType, options);
8734
+ var async = obj.async, flatten2 = obj.flatten, rest = _object_without_properties(obj, [
8735
+ "async",
8736
+ "flatten"
8737
+ ]);
8738
+ var parsedAsync = parser.parseObject(rest, nodeType, options);
8569
8739
  var parsedNodeId = getNodeID(parsedAsync);
8570
8740
  if (parsedAsync === null || !parsedNodeId) {
8571
8741
  return childOptions ? [] : null;
@@ -8573,7 +8743,8 @@ var ReferenceAssetsPlugin = function() {
8573
8743
  var asyncAST = parser.createASTNode({
8574
8744
  id: parsedNodeId,
8575
8745
  type: NodeType.Async,
8576
- value: parsedAsync
8746
+ value: parsedAsync,
8747
+ flatten: flatten2
8577
8748
  }, obj);
8578
8749
  if (childOptions) {
8579
8750
  return asyncAST ? [
@@ -8615,14 +8786,14 @@ var ReferenceAssetsPlugin = function() {
8615
8786
  return AsyncNodePluginPlugin;
8616
8787
  }();
8617
8788
  // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/core/src/assets/chat-message/transform.ts
8618
- var transform2 = function(asset) {
8619
- var _asset_children_, _asset_children;
8620
- var newAsset = (_asset_children = asset.children) === null || _asset_children === void 0 ? void 0 : (_asset_children_ = _asset_children[0]) === null || _asset_children_ === void 0 ? void 0 : _asset_children_.value;
8621
- if (!newAsset) {
8622
- return asyncTransform(asset.value.id, "collection");
8789
+ var transform2 = createAsyncTransform({
8790
+ transformAssetType: "chat-message",
8791
+ wrapperAssetType: "collection",
8792
+ getNestedAsset: function(node) {
8793
+ var _node_children_, _node_children;
8794
+ return (_node_children = node.children) === null || _node_children === void 0 ? void 0 : (_node_children_ = _node_children[0]) === null || _node_children_ === void 0 ? void 0 : _node_children_.value;
8623
8795
  }
8624
- return asyncTransform(asset.value.id, "collection", newAsset);
8625
- };
8796
+ });
8626
8797
  var chatMessageTransform = compose(composeBefore(transform2));
8627
8798
  // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/@player-ui+meta-plugin@0.0.0/node_modules/@player-ui/meta-plugin/dist/index.mjs
8628
8799
  var MetaPlugin = /*#__PURE__*/ function() {