@player-ui/metrics-plugin 0.15.0-next.4 → 0.15.0-next.6

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.
@@ -4811,7 +4811,6 @@ var MetricsPlugin = function() {
4811
4811
  this.ASTMap = /* @__PURE__ */ new Map();
4812
4812
  this.logger = options.logger;
4813
4813
  this.idCache = /* @__PURE__ */ new Set();
4814
- this.AsyncIdMap = /* @__PURE__ */ new Map();
4815
4814
  }
4816
4815
  _create_class(Resolver, [
4817
4816
  {
@@ -4822,27 +4821,44 @@ var MetricsPlugin = function() {
4822
4821
  },
4823
4822
  {
4824
4823
  key: "update",
4825
- value: function update(changes, asyncChanges) {
4826
- var _this = this;
4827
- this.hooks.beforeUpdate.call(changes);
4824
+ value: function update(dataChanges, nodeChanges) {
4825
+ this.hooks.beforeUpdate.call(dataChanges);
4828
4826
  var resolveCache = /* @__PURE__ */ new Map();
4829
4827
  this.idCache.clear();
4830
4828
  var prevASTMap = new Map(this.ASTMap);
4831
4829
  this.ASTMap.clear();
4832
- var prevAsyncIdMap = new Map(this.AsyncIdMap);
4833
- var nextAsyncIdMap = /* @__PURE__ */ new Map();
4834
- asyncChanges === null || asyncChanges === void 0 ? void 0 : asyncChanges.forEach(function(id) {
4835
- var current = prevAsyncIdMap.get(id);
4836
- while(current && prevASTMap.has(current)){
4837
- var next = prevASTMap.get(current);
4838
- if (next && _this.resolveCache.has(next)) {
4839
- _this.resolveCache.delete(next);
4830
+ var realNodeChanges = /* @__PURE__ */ new Set();
4831
+ var _nodeChanges_values;
4832
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
4833
+ try {
4834
+ for(var _iterator = ((_nodeChanges_values = nodeChanges === null || nodeChanges === void 0 ? void 0 : nodeChanges.values()) !== null && _nodeChanges_values !== void 0 ? _nodeChanges_values : [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
4835
+ var node = _step.value;
4836
+ var current = node;
4837
+ while(current){
4838
+ var _prevASTMap_get;
4839
+ var original = (_prevASTMap_get = prevASTMap.get(current)) !== null && _prevASTMap_get !== void 0 ? _prevASTMap_get : current;
4840
+ if (realNodeChanges.has(original)) {
4841
+ break;
4842
+ }
4843
+ realNodeChanges.add(original);
4844
+ current = current.parent;
4840
4845
  }
4841
- current = current.parent;
4842
4846
  }
4843
- });
4844
- var updated = this.computeTree(this.root, void 0, changes, resolveCache, toNodeResolveOptions(this.options), void 0, prevASTMap, nextAsyncIdMap);
4845
- this.AsyncIdMap = nextAsyncIdMap;
4847
+ } catch (err) {
4848
+ _didIteratorError = true;
4849
+ _iteratorError = err;
4850
+ } finally{
4851
+ try {
4852
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
4853
+ _iterator.return();
4854
+ }
4855
+ } finally{
4856
+ if (_didIteratorError) {
4857
+ throw _iteratorError;
4858
+ }
4859
+ }
4860
+ }
4861
+ var updated = this.computeTree(this.root, void 0, dataChanges, resolveCache, toNodeResolveOptions(this.options), void 0, prevASTMap, realNodeChanges);
4846
4862
  this.resolveCache = resolveCache;
4847
4863
  this.hooks.afterUpdate.call(updated.value);
4848
4864
  return updated.value;
@@ -4896,7 +4912,7 @@ var MetricsPlugin = function() {
4896
4912
  },
4897
4913
  {
4898
4914
  key: "computeTree",
4899
- value: function computeTree(node, rawParent, dataChanges, cacheUpdate, options, partiallyResolvedParent, prevASTMap, nextAsyncIdMap) {
4915
+ value: function computeTree(node, rawParent, dataChanges, cacheUpdate, options, partiallyResolvedParent, prevASTMap, nodeChanges) {
4900
4916
  var _this = this;
4901
4917
  var dependencyModel = new DependencyModel(options.data.model);
4902
4918
  dependencyModel.trackSubset("core");
@@ -4914,8 +4930,9 @@ var MetricsPlugin = function() {
4914
4930
  }), node);
4915
4931
  var previousResult = this.getPreviousResult(node);
4916
4932
  var previousDeps = previousResult === null || previousResult === void 0 ? void 0 : previousResult.dependencies;
4933
+ var isChanged = nodeChanges.has(node);
4917
4934
  var dataChanged = caresAboutDataChanges(dataChanges, previousDeps);
4918
- var shouldUseLastValue = this.hooks.skipResolve.call(!dataChanged, node, resolveOptions);
4935
+ var shouldUseLastValue = this.hooks.skipResolve.call(!dataChanged && !isChanged, node, resolveOptions);
4919
4936
  if (previousResult && shouldUseLastValue) {
4920
4937
  var update2 = _object_spread_props(_object_spread({}, previousResult), {
4921
4938
  updated: false
@@ -4927,30 +4944,6 @@ var MetricsPlugin = function() {
4927
4944
  updated: false
4928
4945
  });
4929
4946
  cacheUpdate.set(AST, resolvedUpdate);
4930
- if (resolvedUpdate.node.type === "async") {
4931
- nextAsyncIdMap.set(resolvedUpdate.node.id, resolvedUpdate.node);
4932
- }
4933
- var _resolvedUpdate_node_asyncNodesResolved;
4934
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
4935
- try {
4936
- 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){
4937
- var key = _step.value;
4938
- nextAsyncIdMap.set(key, resolvedUpdate.node);
4939
- }
4940
- } catch (err) {
4941
- _didIteratorError = true;
4942
- _iteratorError = err;
4943
- } finally{
4944
- try {
4945
- if (!_iteratorNormalCompletion && _iterator.return != null) {
4946
- _iterator.return();
4947
- }
4948
- } finally{
4949
- if (_didIteratorError) {
4950
- throw _iteratorError;
4951
- }
4952
- }
4953
- }
4954
4947
  var handleChildNode = function(childNode) {
4955
4948
  var _prevASTMap_get;
4956
4949
  var originalChildNode = (_prevASTMap_get = prevASTMap.get(childNode)) !== null && _prevASTMap_get !== void 0 ? _prevASTMap_get : childNode;
@@ -4981,30 +4974,6 @@ var MetricsPlugin = function() {
4981
4974
  type: "empty"
4982
4975
  };
4983
4976
  resolvedAST.parent = partiallyResolvedParent;
4984
- if (resolvedAST.type === "async") {
4985
- nextAsyncIdMap.set(resolvedAST.id, resolvedAST);
4986
- }
4987
- var _resolvedAST_asyncNodesResolved;
4988
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
4989
- try {
4990
- for(var _iterator = ((_resolvedAST_asyncNodesResolved = resolvedAST.asyncNodesResolved) !== null && _resolvedAST_asyncNodesResolved !== void 0 ? _resolvedAST_asyncNodesResolved : [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
4991
- var id = _step.value;
4992
- nextAsyncIdMap.set(id, resolvedAST);
4993
- }
4994
- } catch (err) {
4995
- _didIteratorError = true;
4996
- _iteratorError = err;
4997
- } finally{
4998
- try {
4999
- if (!_iteratorNormalCompletion && _iterator.return != null) {
5000
- _iterator.return();
5001
- }
5002
- } finally{
5003
- if (_didIteratorError) {
5004
- throw _iteratorError;
5005
- }
5006
- }
5007
- }
5008
4977
  resolveOptions.node = resolvedAST;
5009
4978
  this.ASTMap.set(resolvedAST, node);
5010
4979
  var resolved = this.hooks.resolve.call(void 0, resolvedAST, resolveOptions);
@@ -5017,7 +4986,7 @@ var MetricsPlugin = function() {
5017
4986
  if ("children" in resolvedAST) {
5018
4987
  var _resolvedAST_children;
5019
4988
  var newChildren = (_resolvedAST_children = resolvedAST.children) === null || _resolvedAST_children === void 0 ? void 0 : _resolvedAST_children.map(function(child) {
5020
- var computedChildTree = _this.computeTree(child.value, node, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap, nextAsyncIdMap);
4989
+ var computedChildTree = _this.computeTree(child.value, node, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap, nodeChanges);
5021
4990
  var childTreeDeps = computedChildTree.dependencies, childNode = computedChildTree.node, childUpdated = computedChildTree.updated, childValue = computedChildTree.value;
5022
4991
  childTreeDeps.forEach(function(binding) {
5023
4992
  return childDependencies.add(binding);
@@ -5040,7 +5009,7 @@ var MetricsPlugin = function() {
5040
5009
  var childValue = [];
5041
5010
  var rawParentToPassIn = node;
5042
5011
  resolvedAST.values = resolvedAST.values.map(function(mValue) {
5043
- var mTree = _this.computeTree(mValue, rawParentToPassIn, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap, nextAsyncIdMap);
5012
+ var mTree = _this.computeTree(mValue, rawParentToPassIn, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap, nodeChanges);
5044
5013
  if (mTree.value !== void 0 && mTree.value !== null) {
5045
5014
  mTree.dependencies.forEach(function(bindingDep) {
5046
5015
  return childDependencies.add(bindingDep);
@@ -5144,19 +5113,17 @@ var MetricsPlugin = function() {
5144
5113
  }
5145
5114
  _create_class(ViewInstance, [
5146
5115
  {
5147
- key: "updateAsync",
5116
+ /** @deprecated use ViewController.updateViewAST */ key: "updateAsync",
5148
5117
  value: function updateAsync(asyncNode) {
5149
5118
  var _this_resolver;
5150
- var update = (_this_resolver = this.resolver) === null || _this_resolver === void 0 ? void 0 : _this_resolver.update(/* @__PURE__ */ new Set(), /* @__PURE__ */ new Set([
5151
- asyncNode
5152
- ]));
5119
+ var update = (_this_resolver = this.resolver) === null || _this_resolver === void 0 ? void 0 : _this_resolver.update();
5153
5120
  this.lastUpdate = update;
5154
5121
  this.hooks.onUpdate.call(update);
5155
5122
  }
5156
5123
  },
5157
5124
  {
5158
5125
  key: "update",
5159
- value: function update(changes) {
5126
+ value: function update(changes, nodeChanges) {
5160
5127
  var _this_resolver;
5161
5128
  if (this.rootNode === void 0) {
5162
5129
  this.validationProvider = new CrossfieldProvider(this.initialView, this.resolverOptions.parseBinding, this.resolverOptions.logger);
@@ -5174,7 +5141,7 @@ var MetricsPlugin = function() {
5174
5141
  }));
5175
5142
  this.hooks.resolver.call(this.resolver);
5176
5143
  }
5177
- var update = (_this_resolver = this.resolver) === null || _this_resolver === void 0 ? void 0 : _this_resolver.update(changes);
5144
+ var update = (_this_resolver = this.resolver) === null || _this_resolver === void 0 ? void 0 : _this_resolver.update(changes, nodeChanges);
5178
5145
  if (this.lastUpdate === update) {
5179
5146
  return this.lastUpdate;
5180
5147
  }
@@ -6964,6 +6931,10 @@ var MetricsPlugin = function() {
6964
6931
  ]);
6965
6932
  return ValidationController;
6966
6933
  }();
6934
+ var mergeSets = function(setA, setB) {
6935
+ var _setA_values, _setB_values;
6936
+ return /* @__PURE__ */ new Set(_to_consumable_array((_setA_values = setA === null || setA === void 0 ? void 0 : setA.values()) !== null && _setA_values !== void 0 ? _setA_values : []).concat(_to_consumable_array((_setB_values = setB === null || setB === void 0 ? void 0 : setB.values()) !== null && _setB_values !== void 0 ? _setB_values : [])));
6937
+ };
6967
6938
  var ViewController = /*#__PURE__*/ function() {
6968
6939
  function ViewController(initialViews, options) {
6969
6940
  var _this = this;
@@ -6993,7 +6964,7 @@ var MetricsPlugin = function() {
6993
6964
  var silent = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
6994
6965
  if (_this1.currentView) {
6995
6966
  if (_this1.optimizeUpdates) {
6996
- _this1.queueUpdate(updates, silent);
6967
+ _this1.queueUpdate(updates, void 0, silent);
6997
6968
  } else {
6998
6969
  _this1.currentView.update();
6999
6970
  }
@@ -7023,25 +6994,26 @@ var MetricsPlugin = function() {
7023
6994
  _create_class(ViewController, [
7024
6995
  {
7025
6996
  key: "queueUpdate",
7026
- value: function queueUpdate(bindings) {
6997
+ value: function queueUpdate(bindings, nodes) {
7027
6998
  var _this = this;
7028
- var silent = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
7029
- var _this_pendingUpdate;
7030
- if ((_this_pendingUpdate = this.pendingUpdate) === null || _this_pendingUpdate === void 0 ? void 0 : _this_pendingUpdate.changedBindings) {
7031
- this.pendingUpdate.changedBindings = /* @__PURE__ */ new Set(_to_consumable_array(this.pendingUpdate.changedBindings).concat(_to_consumable_array(bindings)));
7032
- } else {
6999
+ var silent = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
7000
+ if (!this.pendingUpdate) {
7033
7001
  this.pendingUpdate = {
7034
- changedBindings: bindings,
7035
7002
  scheduled: false
7036
7003
  };
7037
7004
  }
7005
+ this.pendingUpdate = _object_spread_props(_object_spread({}, this.pendingUpdate), {
7006
+ changedBindings: mergeSets(this.pendingUpdate.changedBindings, bindings),
7007
+ changedNodes: mergeSets(this.pendingUpdate.changedNodes, nodes)
7008
+ });
7038
7009
  if (!this.pendingUpdate.scheduled && !silent) {
7039
7010
  this.pendingUpdate.scheduled = true;
7040
7011
  (0, import_queue_microtask2.default)(function() {
7041
- var _this_pendingUpdate, _this_currentView;
7042
- var updates = (_this_pendingUpdate = _this.pendingUpdate) === null || _this_pendingUpdate === void 0 ? void 0 : _this_pendingUpdate.changedBindings;
7012
+ var _this_currentView;
7013
+ var _this_pendingUpdate;
7014
+ var _ref = (_this_pendingUpdate = _this.pendingUpdate) !== null && _this_pendingUpdate !== void 0 ? _this_pendingUpdate : {}, changedBindings = _ref.changedBindings, changedNodes = _ref.changedNodes;
7043
7015
  _this.pendingUpdate = void 0;
7044
- (_this_currentView = _this.currentView) === null || _this_currentView === void 0 ? void 0 : _this_currentView.update(updates);
7016
+ (_this_currentView = _this.currentView) === null || _this_currentView === void 0 ? void 0 : _this_currentView.update(changedBindings, changedNodes);
7045
7017
  });
7046
7018
  }
7047
7019
  }
@@ -7118,6 +7090,15 @@ var MetricsPlugin = function() {
7118
7090
  new MultiNodePlugin()
7119
7091
  ];
7120
7092
  }
7093
+ },
7094
+ {
7095
+ /** Marks all AST nodes in `nodes` as changed, triggering the view to update and re-resolve these nodes. View updates are triggered asynchronously and many calls to this in a short time will batch into a single update.
7096
+ *
7097
+ * NOTE: In most cases view updates are handled automatically by changes to data or any other built-in functionality that would require a view update. Only call this function if absolutely necessary.
7098
+ */ key: "updateViewAST",
7099
+ value: function updateViewAST(nodes) {
7100
+ this.queueUpdate(void 0, nodes);
7101
+ }
7121
7102
  }
7122
7103
  ]);
7123
7104
  return ViewController;
@@ -7490,8 +7471,8 @@ var MetricsPlugin = function() {
7490
7471
  ref: Symbol("not-started"),
7491
7472
  status: "not-started"
7492
7473
  };
7493
- var PLAYER_VERSION = true ? "0.15.0-next.4" : "unknown";
7494
- var COMMIT = true ? "12cdc54a63c8c74be236c6493bd8ab37a1ff2161" : "unknown";
7474
+ var PLAYER_VERSION = true ? "0.15.0-next.6" : "unknown";
7475
+ var COMMIT = true ? "9b22cee7078ed75d77b3c31bc306c758ea07da8b" : "unknown";
7495
7476
  var _Player = /*#__PURE__*/ function() {
7496
7477
  function _Player2(config) {
7497
7478
  var _this = this;