@player-ui/markdown-plugin 0.15.0-next.5 → 0.15.0-next.7

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.
@@ -9083,7 +9083,6 @@ var MarkdownPlugin = function() {
9083
9083
  this.ASTMap = /* @__PURE__ */ new Map();
9084
9084
  this.logger = options.logger;
9085
9085
  this.idCache = /* @__PURE__ */ new Set();
9086
- this.AsyncIdMap = /* @__PURE__ */ new Map();
9087
9086
  }
9088
9087
  _create_class(Resolver, [
9089
9088
  {
@@ -9094,27 +9093,44 @@ var MarkdownPlugin = function() {
9094
9093
  },
9095
9094
  {
9096
9095
  key: "update",
9097
- value: function update(changes, asyncChanges) {
9098
- var _this = this;
9099
- this.hooks.beforeUpdate.call(changes);
9096
+ value: function update(dataChanges, nodeChanges) {
9097
+ this.hooks.beforeUpdate.call(dataChanges);
9100
9098
  var resolveCache = /* @__PURE__ */ new Map();
9101
9099
  this.idCache.clear();
9102
9100
  var prevASTMap = new Map(this.ASTMap);
9103
9101
  this.ASTMap.clear();
9104
- var prevAsyncIdMap = new Map(this.AsyncIdMap);
9105
- var nextAsyncIdMap = /* @__PURE__ */ new Map();
9106
- asyncChanges === null || asyncChanges === void 0 ? void 0 : asyncChanges.forEach(function(id) {
9107
- var current = prevAsyncIdMap.get(id);
9108
- while(current && prevASTMap.has(current)){
9109
- var next = prevASTMap.get(current);
9110
- if (next && _this.resolveCache.has(next)) {
9111
- _this.resolveCache.delete(next);
9102
+ var realNodeChanges = /* @__PURE__ */ new Set();
9103
+ var _nodeChanges_values;
9104
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
9105
+ try {
9106
+ 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){
9107
+ var node2 = _step.value;
9108
+ var current = node2;
9109
+ while(current){
9110
+ var _prevASTMap_get;
9111
+ var original = (_prevASTMap_get = prevASTMap.get(current)) !== null && _prevASTMap_get !== void 0 ? _prevASTMap_get : current;
9112
+ if (realNodeChanges.has(original)) {
9113
+ break;
9114
+ }
9115
+ realNodeChanges.add(original);
9116
+ current = current.parent;
9112
9117
  }
9113
- current = current.parent;
9114
9118
  }
9115
- });
9116
- var updated = this.computeTree(this.root, void 0, changes, resolveCache, toNodeResolveOptions(this.options), void 0, prevASTMap, nextAsyncIdMap);
9117
- this.AsyncIdMap = nextAsyncIdMap;
9119
+ } catch (err) {
9120
+ _didIteratorError = true;
9121
+ _iteratorError = err;
9122
+ } finally{
9123
+ try {
9124
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
9125
+ _iterator.return();
9126
+ }
9127
+ } finally{
9128
+ if (_didIteratorError) {
9129
+ throw _iteratorError;
9130
+ }
9131
+ }
9132
+ }
9133
+ var updated = this.computeTree(this.root, void 0, dataChanges, resolveCache, toNodeResolveOptions(this.options), void 0, prevASTMap, realNodeChanges);
9118
9134
  this.resolveCache = resolveCache;
9119
9135
  this.hooks.afterUpdate.call(updated.value);
9120
9136
  return updated.value;
@@ -9168,7 +9184,7 @@ var MarkdownPlugin = function() {
9168
9184
  },
9169
9185
  {
9170
9186
  key: "computeTree",
9171
- value: function computeTree(node2, rawParent, dataChanges, cacheUpdate, options, partiallyResolvedParent, prevASTMap, nextAsyncIdMap) {
9187
+ value: function computeTree(node2, rawParent, dataChanges, cacheUpdate, options, partiallyResolvedParent, prevASTMap, nodeChanges) {
9172
9188
  var _this = this;
9173
9189
  var dependencyModel = new DependencyModel(options.data.model);
9174
9190
  dependencyModel.trackSubset("core");
@@ -9186,8 +9202,9 @@ var MarkdownPlugin = function() {
9186
9202
  }), node2);
9187
9203
  var previousResult = this.getPreviousResult(node2);
9188
9204
  var previousDeps = previousResult === null || previousResult === void 0 ? void 0 : previousResult.dependencies;
9205
+ var isChanged = nodeChanges.has(node2);
9189
9206
  var dataChanged = caresAboutDataChanges(dataChanges, previousDeps);
9190
- var shouldUseLastValue = this.hooks.skipResolve.call(!dataChanged, node2, resolveOptions);
9207
+ var shouldUseLastValue = this.hooks.skipResolve.call(!dataChanged && !isChanged, node2, resolveOptions);
9191
9208
  if (previousResult && shouldUseLastValue) {
9192
9209
  var update2 = _object_spread_props(_object_spread({}, previousResult), {
9193
9210
  updated: false
@@ -9199,30 +9216,6 @@ var MarkdownPlugin = function() {
9199
9216
  updated: false
9200
9217
  });
9201
9218
  cacheUpdate.set(AST, resolvedUpdate);
9202
- if (resolvedUpdate.node.type === "async") {
9203
- nextAsyncIdMap.set(resolvedUpdate.node.id, resolvedUpdate.node);
9204
- }
9205
- var _resolvedUpdate_node_asyncNodesResolved;
9206
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
9207
- try {
9208
- 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){
9209
- var key = _step.value;
9210
- nextAsyncIdMap.set(key, resolvedUpdate.node);
9211
- }
9212
- } catch (err) {
9213
- _didIteratorError = true;
9214
- _iteratorError = err;
9215
- } finally{
9216
- try {
9217
- if (!_iteratorNormalCompletion && _iterator.return != null) {
9218
- _iterator.return();
9219
- }
9220
- } finally{
9221
- if (_didIteratorError) {
9222
- throw _iteratorError;
9223
- }
9224
- }
9225
- }
9226
9219
  var handleChildNode = function(childNode) {
9227
9220
  var _prevASTMap_get;
9228
9221
  var originalChildNode = (_prevASTMap_get = prevASTMap.get(childNode)) !== null && _prevASTMap_get !== void 0 ? _prevASTMap_get : childNode;
@@ -9253,30 +9246,6 @@ var MarkdownPlugin = function() {
9253
9246
  type: "empty"
9254
9247
  };
9255
9248
  resolvedAST.parent = partiallyResolvedParent;
9256
- if (resolvedAST.type === "async") {
9257
- nextAsyncIdMap.set(resolvedAST.id, resolvedAST);
9258
- }
9259
- var _resolvedAST_asyncNodesResolved;
9260
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
9261
- try {
9262
- for(var _iterator = ((_resolvedAST_asyncNodesResolved = resolvedAST.asyncNodesResolved) !== null && _resolvedAST_asyncNodesResolved !== void 0 ? _resolvedAST_asyncNodesResolved : [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
9263
- var id = _step.value;
9264
- nextAsyncIdMap.set(id, resolvedAST);
9265
- }
9266
- } catch (err) {
9267
- _didIteratorError = true;
9268
- _iteratorError = err;
9269
- } finally{
9270
- try {
9271
- if (!_iteratorNormalCompletion && _iterator.return != null) {
9272
- _iterator.return();
9273
- }
9274
- } finally{
9275
- if (_didIteratorError) {
9276
- throw _iteratorError;
9277
- }
9278
- }
9279
- }
9280
9249
  resolveOptions.node = resolvedAST;
9281
9250
  this.ASTMap.set(resolvedAST, node2);
9282
9251
  var resolved = this.hooks.resolve.call(void 0, resolvedAST, resolveOptions);
@@ -9289,7 +9258,7 @@ var MarkdownPlugin = function() {
9289
9258
  if ("children" in resolvedAST) {
9290
9259
  var _resolvedAST_children;
9291
9260
  var newChildren = (_resolvedAST_children = resolvedAST.children) === null || _resolvedAST_children === void 0 ? void 0 : _resolvedAST_children.map(function(child) {
9292
- var computedChildTree = _this.computeTree(child.value, node2, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap, nextAsyncIdMap);
9261
+ var computedChildTree = _this.computeTree(child.value, node2, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap, nodeChanges);
9293
9262
  var childTreeDeps = computedChildTree.dependencies, childNode = computedChildTree.node, childUpdated = computedChildTree.updated, childValue = computedChildTree.value;
9294
9263
  childTreeDeps.forEach(function(binding) {
9295
9264
  return childDependencies.add(binding);
@@ -9312,7 +9281,7 @@ var MarkdownPlugin = function() {
9312
9281
  var childValue = [];
9313
9282
  var rawParentToPassIn = node2;
9314
9283
  resolvedAST.values = resolvedAST.values.map(function(mValue) {
9315
- var mTree = _this.computeTree(mValue, rawParentToPassIn, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap, nextAsyncIdMap);
9284
+ var mTree = _this.computeTree(mValue, rawParentToPassIn, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap, nodeChanges);
9316
9285
  if (mTree.value !== void 0 && mTree.value !== null) {
9317
9286
  mTree.dependencies.forEach(function(bindingDep) {
9318
9287
  return childDependencies.add(bindingDep);
@@ -9416,19 +9385,17 @@ var MarkdownPlugin = function() {
9416
9385
  }
9417
9386
  _create_class(ViewInstance, [
9418
9387
  {
9419
- key: "updateAsync",
9388
+ /** @deprecated use ViewController.updateViewAST */ key: "updateAsync",
9420
9389
  value: function updateAsync(asyncNode) {
9421
9390
  var _this_resolver;
9422
- var update = (_this_resolver = this.resolver) === null || _this_resolver === void 0 ? void 0 : _this_resolver.update(/* @__PURE__ */ new Set(), /* @__PURE__ */ new Set([
9423
- asyncNode
9424
- ]));
9391
+ var update = (_this_resolver = this.resolver) === null || _this_resolver === void 0 ? void 0 : _this_resolver.update();
9425
9392
  this.lastUpdate = update;
9426
9393
  this.hooks.onUpdate.call(update);
9427
9394
  }
9428
9395
  },
9429
9396
  {
9430
9397
  key: "update",
9431
- value: function update(changes) {
9398
+ value: function update(changes, nodeChanges) {
9432
9399
  var _this_resolver;
9433
9400
  if (this.rootNode === void 0) {
9434
9401
  this.validationProvider = new CrossfieldProvider(this.initialView, this.resolverOptions.parseBinding, this.resolverOptions.logger);
@@ -9446,7 +9413,7 @@ var MarkdownPlugin = function() {
9446
9413
  }));
9447
9414
  this.hooks.resolver.call(this.resolver);
9448
9415
  }
9449
- var update = (_this_resolver = this.resolver) === null || _this_resolver === void 0 ? void 0 : _this_resolver.update(changes);
9416
+ var update = (_this_resolver = this.resolver) === null || _this_resolver === void 0 ? void 0 : _this_resolver.update(changes, nodeChanges);
9450
9417
  if (this.lastUpdate === update) {
9451
9418
  return this.lastUpdate;
9452
9419
  }
@@ -11236,6 +11203,10 @@ var MarkdownPlugin = function() {
11236
11203
  ]);
11237
11204
  return ValidationController;
11238
11205
  }();
11206
+ var mergeSets = function(setA, setB) {
11207
+ var _setA_values, _setB_values;
11208
+ 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 : [])));
11209
+ };
11239
11210
  var ViewController = /*#__PURE__*/ function() {
11240
11211
  function ViewController(initialViews, options) {
11241
11212
  var _this = this;
@@ -11265,7 +11236,7 @@ var MarkdownPlugin = function() {
11265
11236
  var silent = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
11266
11237
  if (_this1.currentView) {
11267
11238
  if (_this1.optimizeUpdates) {
11268
- _this1.queueUpdate(updates, silent);
11239
+ _this1.queueUpdate(updates, void 0, silent);
11269
11240
  } else {
11270
11241
  _this1.currentView.update();
11271
11242
  }
@@ -11295,25 +11266,26 @@ var MarkdownPlugin = function() {
11295
11266
  _create_class(ViewController, [
11296
11267
  {
11297
11268
  key: "queueUpdate",
11298
- value: function queueUpdate(bindings) {
11269
+ value: function queueUpdate(bindings, nodes) {
11299
11270
  var _this = this;
11300
- var silent = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
11301
- var _this_pendingUpdate;
11302
- if ((_this_pendingUpdate = this.pendingUpdate) === null || _this_pendingUpdate === void 0 ? void 0 : _this_pendingUpdate.changedBindings) {
11303
- this.pendingUpdate.changedBindings = /* @__PURE__ */ new Set(_to_consumable_array(this.pendingUpdate.changedBindings).concat(_to_consumable_array(bindings)));
11304
- } else {
11271
+ var silent = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
11272
+ if (!this.pendingUpdate) {
11305
11273
  this.pendingUpdate = {
11306
- changedBindings: bindings,
11307
11274
  scheduled: false
11308
11275
  };
11309
11276
  }
11277
+ this.pendingUpdate = _object_spread_props(_object_spread({}, this.pendingUpdate), {
11278
+ changedBindings: mergeSets(this.pendingUpdate.changedBindings, bindings),
11279
+ changedNodes: mergeSets(this.pendingUpdate.changedNodes, nodes)
11280
+ });
11310
11281
  if (!this.pendingUpdate.scheduled && !silent) {
11311
11282
  this.pendingUpdate.scheduled = true;
11312
11283
  (0, import_queue_microtask2.default)(function() {
11313
- var _this_pendingUpdate, _this_currentView;
11314
- var updates = (_this_pendingUpdate = _this.pendingUpdate) === null || _this_pendingUpdate === void 0 ? void 0 : _this_pendingUpdate.changedBindings;
11284
+ var _this_currentView;
11285
+ var _this_pendingUpdate;
11286
+ var _ref = (_this_pendingUpdate = _this.pendingUpdate) !== null && _this_pendingUpdate !== void 0 ? _this_pendingUpdate : {}, changedBindings = _ref.changedBindings, changedNodes = _ref.changedNodes;
11315
11287
  _this.pendingUpdate = void 0;
11316
- (_this_currentView = _this.currentView) === null || _this_currentView === void 0 ? void 0 : _this_currentView.update(updates);
11288
+ (_this_currentView = _this.currentView) === null || _this_currentView === void 0 ? void 0 : _this_currentView.update(changedBindings, changedNodes);
11317
11289
  });
11318
11290
  }
11319
11291
  }
@@ -11390,6 +11362,15 @@ var MarkdownPlugin = function() {
11390
11362
  new MultiNodePlugin()
11391
11363
  ];
11392
11364
  }
11365
+ },
11366
+ {
11367
+ /** 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.
11368
+ *
11369
+ * 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.
11370
+ */ key: "updateViewAST",
11371
+ value: function updateViewAST(nodes) {
11372
+ this.queueUpdate(void 0, nodes);
11373
+ }
11393
11374
  }
11394
11375
  ]);
11395
11376
  return ViewController;
@@ -11762,8 +11743,8 @@ var MarkdownPlugin = function() {
11762
11743
  ref: Symbol("not-started"),
11763
11744
  status: "not-started"
11764
11745
  };
11765
- var PLAYER_VERSION = true ? "0.15.0-next.5" : "unknown";
11766
- var COMMIT = true ? "b332f0c87e29054ff2a1df91873b9a4ac4c1084f" : "unknown";
11746
+ var PLAYER_VERSION = true ? "0.15.0-next.7" : "unknown";
11747
+ var COMMIT = true ? "e9286b2b534eb7bb93573410ef47386e211d95fe" : "unknown";
11767
11748
  var _Player = /*#__PURE__*/ function() {
11768
11749
  function _Player2(config) {
11769
11750
  var _this = this;