@player-ui/check-path-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.
@@ -4752,7 +4752,6 @@ var CheckPathPlugin = function() {
4752
4752
  this.ASTMap = /* @__PURE__ */ new Map();
4753
4753
  this.logger = options.logger;
4754
4754
  this.idCache = /* @__PURE__ */ new Set();
4755
- this.AsyncIdMap = /* @__PURE__ */ new Map();
4756
4755
  }
4757
4756
  _create_class(Resolver, [
4758
4757
  {
@@ -4763,27 +4762,44 @@ var CheckPathPlugin = function() {
4763
4762
  },
4764
4763
  {
4765
4764
  key: "update",
4766
- value: function update(changes, asyncChanges) {
4767
- var _this = this;
4768
- this.hooks.beforeUpdate.call(changes);
4765
+ value: function update(dataChanges, nodeChanges) {
4766
+ this.hooks.beforeUpdate.call(dataChanges);
4769
4767
  var resolveCache = /* @__PURE__ */ new Map();
4770
4768
  this.idCache.clear();
4771
4769
  var prevASTMap = new Map(this.ASTMap);
4772
4770
  this.ASTMap.clear();
4773
- var prevAsyncIdMap = new Map(this.AsyncIdMap);
4774
- var nextAsyncIdMap = /* @__PURE__ */ new Map();
4775
- asyncChanges === null || asyncChanges === void 0 ? void 0 : asyncChanges.forEach(function(id) {
4776
- var current = prevAsyncIdMap.get(id);
4777
- while(current && prevASTMap.has(current)){
4778
- var next = prevASTMap.get(current);
4779
- if (next && _this.resolveCache.has(next)) {
4780
- _this.resolveCache.delete(next);
4771
+ var realNodeChanges = /* @__PURE__ */ new Set();
4772
+ var _nodeChanges_values;
4773
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
4774
+ try {
4775
+ 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){
4776
+ var node = _step.value;
4777
+ var current = node;
4778
+ while(current){
4779
+ var _prevASTMap_get;
4780
+ var original = (_prevASTMap_get = prevASTMap.get(current)) !== null && _prevASTMap_get !== void 0 ? _prevASTMap_get : current;
4781
+ if (realNodeChanges.has(original)) {
4782
+ break;
4783
+ }
4784
+ realNodeChanges.add(original);
4785
+ current = current.parent;
4781
4786
  }
4782
- current = current.parent;
4783
4787
  }
4784
- });
4785
- var updated = this.computeTree(this.root, void 0, changes, resolveCache, toNodeResolveOptions(this.options), void 0, prevASTMap, nextAsyncIdMap);
4786
- this.AsyncIdMap = nextAsyncIdMap;
4788
+ } catch (err) {
4789
+ _didIteratorError = true;
4790
+ _iteratorError = err;
4791
+ } finally{
4792
+ try {
4793
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
4794
+ _iterator.return();
4795
+ }
4796
+ } finally{
4797
+ if (_didIteratorError) {
4798
+ throw _iteratorError;
4799
+ }
4800
+ }
4801
+ }
4802
+ var updated = this.computeTree(this.root, void 0, dataChanges, resolveCache, toNodeResolveOptions(this.options), void 0, prevASTMap, realNodeChanges);
4787
4803
  this.resolveCache = resolveCache;
4788
4804
  this.hooks.afterUpdate.call(updated.value);
4789
4805
  return updated.value;
@@ -4837,7 +4853,7 @@ var CheckPathPlugin = function() {
4837
4853
  },
4838
4854
  {
4839
4855
  key: "computeTree",
4840
- value: function computeTree(node, rawParent, dataChanges, cacheUpdate, options, partiallyResolvedParent, prevASTMap, nextAsyncIdMap) {
4856
+ value: function computeTree(node, rawParent, dataChanges, cacheUpdate, options, partiallyResolvedParent, prevASTMap, nodeChanges) {
4841
4857
  var _this = this;
4842
4858
  var dependencyModel = new DependencyModel(options.data.model);
4843
4859
  dependencyModel.trackSubset("core");
@@ -4855,8 +4871,9 @@ var CheckPathPlugin = function() {
4855
4871
  }), node);
4856
4872
  var previousResult = this.getPreviousResult(node);
4857
4873
  var previousDeps = previousResult === null || previousResult === void 0 ? void 0 : previousResult.dependencies;
4874
+ var isChanged = nodeChanges.has(node);
4858
4875
  var dataChanged = caresAboutDataChanges(dataChanges, previousDeps);
4859
- var shouldUseLastValue = this.hooks.skipResolve.call(!dataChanged, node, resolveOptions);
4876
+ var shouldUseLastValue = this.hooks.skipResolve.call(!dataChanged && !isChanged, node, resolveOptions);
4860
4877
  if (previousResult && shouldUseLastValue) {
4861
4878
  var update2 = _object_spread_props(_object_spread({}, previousResult), {
4862
4879
  updated: false
@@ -4868,30 +4885,6 @@ var CheckPathPlugin = function() {
4868
4885
  updated: false
4869
4886
  });
4870
4887
  cacheUpdate.set(AST, resolvedUpdate);
4871
- if (resolvedUpdate.node.type === "async") {
4872
- nextAsyncIdMap.set(resolvedUpdate.node.id, resolvedUpdate.node);
4873
- }
4874
- var _resolvedUpdate_node_asyncNodesResolved;
4875
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
4876
- try {
4877
- 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){
4878
- var key = _step.value;
4879
- nextAsyncIdMap.set(key, resolvedUpdate.node);
4880
- }
4881
- } catch (err) {
4882
- _didIteratorError = true;
4883
- _iteratorError = err;
4884
- } finally{
4885
- try {
4886
- if (!_iteratorNormalCompletion && _iterator.return != null) {
4887
- _iterator.return();
4888
- }
4889
- } finally{
4890
- if (_didIteratorError) {
4891
- throw _iteratorError;
4892
- }
4893
- }
4894
- }
4895
4888
  var handleChildNode = function(childNode) {
4896
4889
  var _prevASTMap_get;
4897
4890
  var originalChildNode = (_prevASTMap_get = prevASTMap.get(childNode)) !== null && _prevASTMap_get !== void 0 ? _prevASTMap_get : childNode;
@@ -4922,30 +4915,6 @@ var CheckPathPlugin = function() {
4922
4915
  type: "empty"
4923
4916
  };
4924
4917
  resolvedAST.parent = partiallyResolvedParent;
4925
- if (resolvedAST.type === "async") {
4926
- nextAsyncIdMap.set(resolvedAST.id, resolvedAST);
4927
- }
4928
- var _resolvedAST_asyncNodesResolved;
4929
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
4930
- try {
4931
- for(var _iterator = ((_resolvedAST_asyncNodesResolved = resolvedAST.asyncNodesResolved) !== null && _resolvedAST_asyncNodesResolved !== void 0 ? _resolvedAST_asyncNodesResolved : [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
4932
- var id = _step.value;
4933
- nextAsyncIdMap.set(id, resolvedAST);
4934
- }
4935
- } catch (err) {
4936
- _didIteratorError = true;
4937
- _iteratorError = err;
4938
- } finally{
4939
- try {
4940
- if (!_iteratorNormalCompletion && _iterator.return != null) {
4941
- _iterator.return();
4942
- }
4943
- } finally{
4944
- if (_didIteratorError) {
4945
- throw _iteratorError;
4946
- }
4947
- }
4948
- }
4949
4918
  resolveOptions.node = resolvedAST;
4950
4919
  this.ASTMap.set(resolvedAST, node);
4951
4920
  var resolved = this.hooks.resolve.call(void 0, resolvedAST, resolveOptions);
@@ -4958,7 +4927,7 @@ var CheckPathPlugin = function() {
4958
4927
  if ("children" in resolvedAST) {
4959
4928
  var _resolvedAST_children;
4960
4929
  var newChildren = (_resolvedAST_children = resolvedAST.children) === null || _resolvedAST_children === void 0 ? void 0 : _resolvedAST_children.map(function(child) {
4961
- var computedChildTree = _this.computeTree(child.value, node, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap, nextAsyncIdMap);
4930
+ var computedChildTree = _this.computeTree(child.value, node, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap, nodeChanges);
4962
4931
  var childTreeDeps = computedChildTree.dependencies, childNode = computedChildTree.node, childUpdated = computedChildTree.updated, childValue = computedChildTree.value;
4963
4932
  childTreeDeps.forEach(function(binding) {
4964
4933
  return childDependencies.add(binding);
@@ -4981,7 +4950,7 @@ var CheckPathPlugin = function() {
4981
4950
  var childValue = [];
4982
4951
  var rawParentToPassIn = node;
4983
4952
  resolvedAST.values = resolvedAST.values.map(function(mValue) {
4984
- var mTree = _this.computeTree(mValue, rawParentToPassIn, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap, nextAsyncIdMap);
4953
+ var mTree = _this.computeTree(mValue, rawParentToPassIn, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap, nodeChanges);
4985
4954
  if (mTree.value !== void 0 && mTree.value !== null) {
4986
4955
  mTree.dependencies.forEach(function(bindingDep) {
4987
4956
  return childDependencies.add(bindingDep);
@@ -5085,19 +5054,17 @@ var CheckPathPlugin = function() {
5085
5054
  }
5086
5055
  _create_class(ViewInstance, [
5087
5056
  {
5088
- key: "updateAsync",
5057
+ /** @deprecated use ViewController.updateViewAST */ key: "updateAsync",
5089
5058
  value: function updateAsync(asyncNode) {
5090
5059
  var _this_resolver;
5091
- var update = (_this_resolver = this.resolver) === null || _this_resolver === void 0 ? void 0 : _this_resolver.update(/* @__PURE__ */ new Set(), /* @__PURE__ */ new Set([
5092
- asyncNode
5093
- ]));
5060
+ var update = (_this_resolver = this.resolver) === null || _this_resolver === void 0 ? void 0 : _this_resolver.update();
5094
5061
  this.lastUpdate = update;
5095
5062
  this.hooks.onUpdate.call(update);
5096
5063
  }
5097
5064
  },
5098
5065
  {
5099
5066
  key: "update",
5100
- value: function update(changes) {
5067
+ value: function update(changes, nodeChanges) {
5101
5068
  var _this_resolver;
5102
5069
  if (this.rootNode === void 0) {
5103
5070
  this.validationProvider = new CrossfieldProvider(this.initialView, this.resolverOptions.parseBinding, this.resolverOptions.logger);
@@ -5115,7 +5082,7 @@ var CheckPathPlugin = function() {
5115
5082
  }));
5116
5083
  this.hooks.resolver.call(this.resolver);
5117
5084
  }
5118
- var update = (_this_resolver = this.resolver) === null || _this_resolver === void 0 ? void 0 : _this_resolver.update(changes);
5085
+ var update = (_this_resolver = this.resolver) === null || _this_resolver === void 0 ? void 0 : _this_resolver.update(changes, nodeChanges);
5119
5086
  if (this.lastUpdate === update) {
5120
5087
  return this.lastUpdate;
5121
5088
  }
@@ -6905,6 +6872,10 @@ var CheckPathPlugin = function() {
6905
6872
  ]);
6906
6873
  return ValidationController;
6907
6874
  }();
6875
+ var mergeSets = function(setA, setB) {
6876
+ var _setA_values, _setB_values;
6877
+ 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 : [])));
6878
+ };
6908
6879
  var ViewController = /*#__PURE__*/ function() {
6909
6880
  function ViewController(initialViews, options) {
6910
6881
  var _this = this;
@@ -6934,7 +6905,7 @@ var CheckPathPlugin = function() {
6934
6905
  var silent = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
6935
6906
  if (_this1.currentView) {
6936
6907
  if (_this1.optimizeUpdates) {
6937
- _this1.queueUpdate(updates, silent);
6908
+ _this1.queueUpdate(updates, void 0, silent);
6938
6909
  } else {
6939
6910
  _this1.currentView.update();
6940
6911
  }
@@ -6964,25 +6935,26 @@ var CheckPathPlugin = function() {
6964
6935
  _create_class(ViewController, [
6965
6936
  {
6966
6937
  key: "queueUpdate",
6967
- value: function queueUpdate(bindings) {
6938
+ value: function queueUpdate(bindings, nodes) {
6968
6939
  var _this = this;
6969
- var silent = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
6970
- var _this_pendingUpdate;
6971
- if ((_this_pendingUpdate = this.pendingUpdate) === null || _this_pendingUpdate === void 0 ? void 0 : _this_pendingUpdate.changedBindings) {
6972
- this.pendingUpdate.changedBindings = /* @__PURE__ */ new Set(_to_consumable_array(this.pendingUpdate.changedBindings).concat(_to_consumable_array(bindings)));
6973
- } else {
6940
+ var silent = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
6941
+ if (!this.pendingUpdate) {
6974
6942
  this.pendingUpdate = {
6975
- changedBindings: bindings,
6976
6943
  scheduled: false
6977
6944
  };
6978
6945
  }
6946
+ this.pendingUpdate = _object_spread_props(_object_spread({}, this.pendingUpdate), {
6947
+ changedBindings: mergeSets(this.pendingUpdate.changedBindings, bindings),
6948
+ changedNodes: mergeSets(this.pendingUpdate.changedNodes, nodes)
6949
+ });
6979
6950
  if (!this.pendingUpdate.scheduled && !silent) {
6980
6951
  this.pendingUpdate.scheduled = true;
6981
6952
  (0, import_queue_microtask2.default)(function() {
6982
- var _this_pendingUpdate, _this_currentView;
6983
- var updates = (_this_pendingUpdate = _this.pendingUpdate) === null || _this_pendingUpdate === void 0 ? void 0 : _this_pendingUpdate.changedBindings;
6953
+ var _this_currentView;
6954
+ var _this_pendingUpdate;
6955
+ var _ref = (_this_pendingUpdate = _this.pendingUpdate) !== null && _this_pendingUpdate !== void 0 ? _this_pendingUpdate : {}, changedBindings = _ref.changedBindings, changedNodes = _ref.changedNodes;
6984
6956
  _this.pendingUpdate = void 0;
6985
- (_this_currentView = _this.currentView) === null || _this_currentView === void 0 ? void 0 : _this_currentView.update(updates);
6957
+ (_this_currentView = _this.currentView) === null || _this_currentView === void 0 ? void 0 : _this_currentView.update(changedBindings, changedNodes);
6986
6958
  });
6987
6959
  }
6988
6960
  }
@@ -7059,6 +7031,15 @@ var CheckPathPlugin = function() {
7059
7031
  new MultiNodePlugin()
7060
7032
  ];
7061
7033
  }
7034
+ },
7035
+ {
7036
+ /** 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.
7037
+ *
7038
+ * 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.
7039
+ */ key: "updateViewAST",
7040
+ value: function updateViewAST(nodes) {
7041
+ this.queueUpdate(void 0, nodes);
7042
+ }
7062
7043
  }
7063
7044
  ]);
7064
7045
  return ViewController;
@@ -7431,8 +7412,8 @@ var CheckPathPlugin = function() {
7431
7412
  ref: Symbol("not-started"),
7432
7413
  status: "not-started"
7433
7414
  };
7434
- var PLAYER_VERSION = true ? "0.15.0-next.4" : "unknown";
7435
- var COMMIT = true ? "12cdc54a63c8c74be236c6493bd8ab37a1ff2161" : "unknown";
7415
+ var PLAYER_VERSION = true ? "0.15.0-next.6" : "unknown";
7416
+ var COMMIT = true ? "9b22cee7078ed75d77b3c31bc306c758ea07da8b" : "unknown";
7436
7417
  var _Player = /*#__PURE__*/ function() {
7437
7418
  function _Player2(config) {
7438
7419
  var _this = this;