@player-ui/common-expressions-plugin 0.15.0-next.5 → 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.
@@ -4840,7 +4840,6 @@ var CommonExpressionsPlugin = function() {
4840
4840
  this.ASTMap = /* @__PURE__ */ new Map();
4841
4841
  this.logger = options.logger;
4842
4842
  this.idCache = /* @__PURE__ */ new Set();
4843
- this.AsyncIdMap = /* @__PURE__ */ new Map();
4844
4843
  }
4845
4844
  _create_class(Resolver, [
4846
4845
  {
@@ -4851,27 +4850,44 @@ var CommonExpressionsPlugin = function() {
4851
4850
  },
4852
4851
  {
4853
4852
  key: "update",
4854
- value: function update(changes, asyncChanges) {
4855
- var _this = this;
4856
- this.hooks.beforeUpdate.call(changes);
4853
+ value: function update(dataChanges, nodeChanges) {
4854
+ this.hooks.beforeUpdate.call(dataChanges);
4857
4855
  var resolveCache = /* @__PURE__ */ new Map();
4858
4856
  this.idCache.clear();
4859
4857
  var prevASTMap = new Map(this.ASTMap);
4860
4858
  this.ASTMap.clear();
4861
- var prevAsyncIdMap = new Map(this.AsyncIdMap);
4862
- var nextAsyncIdMap = /* @__PURE__ */ new Map();
4863
- asyncChanges === null || asyncChanges === void 0 ? void 0 : asyncChanges.forEach(function(id) {
4864
- var current = prevAsyncIdMap.get(id);
4865
- while(current && prevASTMap.has(current)){
4866
- var next = prevASTMap.get(current);
4867
- if (next && _this.resolveCache.has(next)) {
4868
- _this.resolveCache.delete(next);
4859
+ var realNodeChanges = /* @__PURE__ */ new Set();
4860
+ var _nodeChanges_values;
4861
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
4862
+ try {
4863
+ 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){
4864
+ var node = _step.value;
4865
+ var current = node;
4866
+ while(current){
4867
+ var _prevASTMap_get;
4868
+ var original = (_prevASTMap_get = prevASTMap.get(current)) !== null && _prevASTMap_get !== void 0 ? _prevASTMap_get : current;
4869
+ if (realNodeChanges.has(original)) {
4870
+ break;
4871
+ }
4872
+ realNodeChanges.add(original);
4873
+ current = current.parent;
4869
4874
  }
4870
- current = current.parent;
4871
4875
  }
4872
- });
4873
- var updated = this.computeTree(this.root, void 0, changes, resolveCache, toNodeResolveOptions(this.options), void 0, prevASTMap, nextAsyncIdMap);
4874
- this.AsyncIdMap = nextAsyncIdMap;
4876
+ } catch (err) {
4877
+ _didIteratorError = true;
4878
+ _iteratorError = err;
4879
+ } finally{
4880
+ try {
4881
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
4882
+ _iterator.return();
4883
+ }
4884
+ } finally{
4885
+ if (_didIteratorError) {
4886
+ throw _iteratorError;
4887
+ }
4888
+ }
4889
+ }
4890
+ var updated = this.computeTree(this.root, void 0, dataChanges, resolveCache, toNodeResolveOptions(this.options), void 0, prevASTMap, realNodeChanges);
4875
4891
  this.resolveCache = resolveCache;
4876
4892
  this.hooks.afterUpdate.call(updated.value);
4877
4893
  return updated.value;
@@ -4925,7 +4941,7 @@ var CommonExpressionsPlugin = function() {
4925
4941
  },
4926
4942
  {
4927
4943
  key: "computeTree",
4928
- value: function computeTree(node, rawParent, dataChanges, cacheUpdate, options, partiallyResolvedParent, prevASTMap, nextAsyncIdMap) {
4944
+ value: function computeTree(node, rawParent, dataChanges, cacheUpdate, options, partiallyResolvedParent, prevASTMap, nodeChanges) {
4929
4945
  var _this = this;
4930
4946
  var dependencyModel = new DependencyModel(options.data.model);
4931
4947
  dependencyModel.trackSubset("core");
@@ -4943,8 +4959,9 @@ var CommonExpressionsPlugin = function() {
4943
4959
  }), node);
4944
4960
  var previousResult = this.getPreviousResult(node);
4945
4961
  var previousDeps = previousResult === null || previousResult === void 0 ? void 0 : previousResult.dependencies;
4962
+ var isChanged = nodeChanges.has(node);
4946
4963
  var dataChanged = caresAboutDataChanges(dataChanges, previousDeps);
4947
- var shouldUseLastValue = this.hooks.skipResolve.call(!dataChanged, node, resolveOptions);
4964
+ var shouldUseLastValue = this.hooks.skipResolve.call(!dataChanged && !isChanged, node, resolveOptions);
4948
4965
  if (previousResult && shouldUseLastValue) {
4949
4966
  var update2 = _object_spread_props(_object_spread({}, previousResult), {
4950
4967
  updated: false
@@ -4956,30 +4973,6 @@ var CommonExpressionsPlugin = function() {
4956
4973
  updated: false
4957
4974
  });
4958
4975
  cacheUpdate.set(AST, resolvedUpdate);
4959
- if (resolvedUpdate.node.type === "async") {
4960
- nextAsyncIdMap.set(resolvedUpdate.node.id, resolvedUpdate.node);
4961
- }
4962
- var _resolvedUpdate_node_asyncNodesResolved;
4963
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
4964
- try {
4965
- 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){
4966
- var key = _step.value;
4967
- nextAsyncIdMap.set(key, resolvedUpdate.node);
4968
- }
4969
- } catch (err) {
4970
- _didIteratorError = true;
4971
- _iteratorError = err;
4972
- } finally{
4973
- try {
4974
- if (!_iteratorNormalCompletion && _iterator.return != null) {
4975
- _iterator.return();
4976
- }
4977
- } finally{
4978
- if (_didIteratorError) {
4979
- throw _iteratorError;
4980
- }
4981
- }
4982
- }
4983
4976
  var handleChildNode = function(childNode) {
4984
4977
  var _prevASTMap_get;
4985
4978
  var originalChildNode = (_prevASTMap_get = prevASTMap.get(childNode)) !== null && _prevASTMap_get !== void 0 ? _prevASTMap_get : childNode;
@@ -5010,30 +5003,6 @@ var CommonExpressionsPlugin = function() {
5010
5003
  type: "empty"
5011
5004
  };
5012
5005
  resolvedAST.parent = partiallyResolvedParent;
5013
- if (resolvedAST.type === "async") {
5014
- nextAsyncIdMap.set(resolvedAST.id, resolvedAST);
5015
- }
5016
- var _resolvedAST_asyncNodesResolved;
5017
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
5018
- try {
5019
- for(var _iterator = ((_resolvedAST_asyncNodesResolved = resolvedAST.asyncNodesResolved) !== null && _resolvedAST_asyncNodesResolved !== void 0 ? _resolvedAST_asyncNodesResolved : [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
5020
- var id = _step.value;
5021
- nextAsyncIdMap.set(id, resolvedAST);
5022
- }
5023
- } catch (err) {
5024
- _didIteratorError = true;
5025
- _iteratorError = err;
5026
- } finally{
5027
- try {
5028
- if (!_iteratorNormalCompletion && _iterator.return != null) {
5029
- _iterator.return();
5030
- }
5031
- } finally{
5032
- if (_didIteratorError) {
5033
- throw _iteratorError;
5034
- }
5035
- }
5036
- }
5037
5006
  resolveOptions.node = resolvedAST;
5038
5007
  this.ASTMap.set(resolvedAST, node);
5039
5008
  var resolved = this.hooks.resolve.call(void 0, resolvedAST, resolveOptions);
@@ -5046,7 +5015,7 @@ var CommonExpressionsPlugin = function() {
5046
5015
  if ("children" in resolvedAST) {
5047
5016
  var _resolvedAST_children;
5048
5017
  var newChildren = (_resolvedAST_children = resolvedAST.children) === null || _resolvedAST_children === void 0 ? void 0 : _resolvedAST_children.map(function(child) {
5049
- var computedChildTree = _this.computeTree(child.value, node, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap, nextAsyncIdMap);
5018
+ var computedChildTree = _this.computeTree(child.value, node, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap, nodeChanges);
5050
5019
  var childTreeDeps = computedChildTree.dependencies, childNode = computedChildTree.node, childUpdated = computedChildTree.updated, childValue = computedChildTree.value;
5051
5020
  childTreeDeps.forEach(function(binding) {
5052
5021
  return childDependencies.add(binding);
@@ -5069,7 +5038,7 @@ var CommonExpressionsPlugin = function() {
5069
5038
  var childValue = [];
5070
5039
  var rawParentToPassIn = node;
5071
5040
  resolvedAST.values = resolvedAST.values.map(function(mValue) {
5072
- var mTree = _this.computeTree(mValue, rawParentToPassIn, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap, nextAsyncIdMap);
5041
+ var mTree = _this.computeTree(mValue, rawParentToPassIn, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap, nodeChanges);
5073
5042
  if (mTree.value !== void 0 && mTree.value !== null) {
5074
5043
  mTree.dependencies.forEach(function(bindingDep) {
5075
5044
  return childDependencies.add(bindingDep);
@@ -5173,19 +5142,17 @@ var CommonExpressionsPlugin = function() {
5173
5142
  }
5174
5143
  _create_class(ViewInstance, [
5175
5144
  {
5176
- key: "updateAsync",
5145
+ /** @deprecated use ViewController.updateViewAST */ key: "updateAsync",
5177
5146
  value: function updateAsync(asyncNode) {
5178
5147
  var _this_resolver;
5179
- var update = (_this_resolver = this.resolver) === null || _this_resolver === void 0 ? void 0 : _this_resolver.update(/* @__PURE__ */ new Set(), /* @__PURE__ */ new Set([
5180
- asyncNode
5181
- ]));
5148
+ var update = (_this_resolver = this.resolver) === null || _this_resolver === void 0 ? void 0 : _this_resolver.update();
5182
5149
  this.lastUpdate = update;
5183
5150
  this.hooks.onUpdate.call(update);
5184
5151
  }
5185
5152
  },
5186
5153
  {
5187
5154
  key: "update",
5188
- value: function update(changes) {
5155
+ value: function update(changes, nodeChanges) {
5189
5156
  var _this_resolver;
5190
5157
  if (this.rootNode === void 0) {
5191
5158
  this.validationProvider = new CrossfieldProvider(this.initialView, this.resolverOptions.parseBinding, this.resolverOptions.logger);
@@ -5203,7 +5170,7 @@ var CommonExpressionsPlugin = function() {
5203
5170
  }));
5204
5171
  this.hooks.resolver.call(this.resolver);
5205
5172
  }
5206
- var update = (_this_resolver = this.resolver) === null || _this_resolver === void 0 ? void 0 : _this_resolver.update(changes);
5173
+ var update = (_this_resolver = this.resolver) === null || _this_resolver === void 0 ? void 0 : _this_resolver.update(changes, nodeChanges);
5207
5174
  if (this.lastUpdate === update) {
5208
5175
  return this.lastUpdate;
5209
5176
  }
@@ -6993,6 +6960,10 @@ var CommonExpressionsPlugin = function() {
6993
6960
  ]);
6994
6961
  return ValidationController;
6995
6962
  }();
6963
+ var mergeSets = function(setA, setB) {
6964
+ var _setA_values, _setB_values;
6965
+ 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 : [])));
6966
+ };
6996
6967
  var ViewController = /*#__PURE__*/ function() {
6997
6968
  function ViewController(initialViews, options) {
6998
6969
  var _this = this;
@@ -7022,7 +6993,7 @@ var CommonExpressionsPlugin = function() {
7022
6993
  var silent = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
7023
6994
  if (_this1.currentView) {
7024
6995
  if (_this1.optimizeUpdates) {
7025
- _this1.queueUpdate(updates, silent);
6996
+ _this1.queueUpdate(updates, void 0, silent);
7026
6997
  } else {
7027
6998
  _this1.currentView.update();
7028
6999
  }
@@ -7052,25 +7023,26 @@ var CommonExpressionsPlugin = function() {
7052
7023
  _create_class(ViewController, [
7053
7024
  {
7054
7025
  key: "queueUpdate",
7055
- value: function queueUpdate(bindings) {
7026
+ value: function queueUpdate(bindings, nodes) {
7056
7027
  var _this = this;
7057
- var silent = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
7058
- var _this_pendingUpdate;
7059
- if ((_this_pendingUpdate = this.pendingUpdate) === null || _this_pendingUpdate === void 0 ? void 0 : _this_pendingUpdate.changedBindings) {
7060
- this.pendingUpdate.changedBindings = /* @__PURE__ */ new Set(_to_consumable_array(this.pendingUpdate.changedBindings).concat(_to_consumable_array(bindings)));
7061
- } else {
7028
+ var silent = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
7029
+ if (!this.pendingUpdate) {
7062
7030
  this.pendingUpdate = {
7063
- changedBindings: bindings,
7064
7031
  scheduled: false
7065
7032
  };
7066
7033
  }
7034
+ this.pendingUpdate = _object_spread_props(_object_spread({}, this.pendingUpdate), {
7035
+ changedBindings: mergeSets(this.pendingUpdate.changedBindings, bindings),
7036
+ changedNodes: mergeSets(this.pendingUpdate.changedNodes, nodes)
7037
+ });
7067
7038
  if (!this.pendingUpdate.scheduled && !silent) {
7068
7039
  this.pendingUpdate.scheduled = true;
7069
7040
  (0, import_queue_microtask2.default)(function() {
7070
- var _this_pendingUpdate, _this_currentView;
7071
- var updates = (_this_pendingUpdate = _this.pendingUpdate) === null || _this_pendingUpdate === void 0 ? void 0 : _this_pendingUpdate.changedBindings;
7041
+ var _this_currentView;
7042
+ var _this_pendingUpdate;
7043
+ var _ref = (_this_pendingUpdate = _this.pendingUpdate) !== null && _this_pendingUpdate !== void 0 ? _this_pendingUpdate : {}, changedBindings = _ref.changedBindings, changedNodes = _ref.changedNodes;
7072
7044
  _this.pendingUpdate = void 0;
7073
- (_this_currentView = _this.currentView) === null || _this_currentView === void 0 ? void 0 : _this_currentView.update(updates);
7045
+ (_this_currentView = _this.currentView) === null || _this_currentView === void 0 ? void 0 : _this_currentView.update(changedBindings, changedNodes);
7074
7046
  });
7075
7047
  }
7076
7048
  }
@@ -7147,6 +7119,15 @@ var CommonExpressionsPlugin = function() {
7147
7119
  new MultiNodePlugin()
7148
7120
  ];
7149
7121
  }
7122
+ },
7123
+ {
7124
+ /** 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.
7125
+ *
7126
+ * 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.
7127
+ */ key: "updateViewAST",
7128
+ value: function updateViewAST(nodes) {
7129
+ this.queueUpdate(void 0, nodes);
7130
+ }
7150
7131
  }
7151
7132
  ]);
7152
7133
  return ViewController;
@@ -7519,8 +7500,8 @@ var CommonExpressionsPlugin = function() {
7519
7500
  ref: Symbol("not-started"),
7520
7501
  status: "not-started"
7521
7502
  };
7522
- var PLAYER_VERSION = true ? "0.15.0-next.5" : "unknown";
7523
- var COMMIT = true ? "b332f0c87e29054ff2a1df91873b9a4ac4c1084f" : "unknown";
7503
+ var PLAYER_VERSION = true ? "0.15.0-next.6" : "unknown";
7504
+ var COMMIT = true ? "9b22cee7078ed75d77b3c31bc306c758ea07da8b" : "unknown";
7524
7505
  var _Player = /*#__PURE__*/ function() {
7525
7506
  function _Player2(config) {
7526
7507
  var _this = this;