@player-ui/player 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.
- package/dist/Player.native.js +68 -87
- package/dist/Player.native.js.map +1 -1
- package/dist/cjs/index.cjs +47 -47
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.legacy-esm.js +47 -47
- package/dist/index.mjs +47 -47
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/controllers/view/controller.ts +34 -12
- package/src/view/parser/types.ts +0 -3
- package/src/view/resolver/__tests__/index.bench.ts +148 -0
- package/src/view/resolver/__tests__/index.test.ts +37 -51
- package/src/view/resolver/index.ts +22 -37
- package/src/view/view.ts +7 -3
- package/types/controllers/view/controller.d.ts +6 -0
- package/types/view/parser/types.d.ts +0 -2
- package/types/view/resolver/index.d.ts +1 -5
- package/types/view/view.d.ts +3 -1
package/dist/Player.native.js
CHANGED
|
@@ -5050,7 +5050,6 @@ var Player = function() {
|
|
|
5050
5050
|
this.ASTMap = /* @__PURE__ */ new Map();
|
|
5051
5051
|
this.logger = options.logger;
|
|
5052
5052
|
this.idCache = /* @__PURE__ */ new Set();
|
|
5053
|
-
this.AsyncIdMap = /* @__PURE__ */ new Map();
|
|
5054
5053
|
}
|
|
5055
5054
|
_create_class(Resolver, [
|
|
5056
5055
|
{
|
|
@@ -5061,27 +5060,44 @@ var Player = function() {
|
|
|
5061
5060
|
},
|
|
5062
5061
|
{
|
|
5063
5062
|
key: "update",
|
|
5064
|
-
value: function update(
|
|
5065
|
-
|
|
5066
|
-
this.hooks.beforeUpdate.call(changes);
|
|
5063
|
+
value: function update(dataChanges, nodeChanges) {
|
|
5064
|
+
this.hooks.beforeUpdate.call(dataChanges);
|
|
5067
5065
|
var resolveCache = /* @__PURE__ */ new Map();
|
|
5068
5066
|
this.idCache.clear();
|
|
5069
5067
|
var prevASTMap = new Map(this.ASTMap);
|
|
5070
5068
|
this.ASTMap.clear();
|
|
5071
|
-
var
|
|
5072
|
-
var
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
var
|
|
5077
|
-
|
|
5078
|
-
|
|
5069
|
+
var realNodeChanges = /* @__PURE__ */ new Set();
|
|
5070
|
+
var _nodeChanges_values;
|
|
5071
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5072
|
+
try {
|
|
5073
|
+
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){
|
|
5074
|
+
var node = _step.value;
|
|
5075
|
+
var current = node;
|
|
5076
|
+
while(current){
|
|
5077
|
+
var _prevASTMap_get;
|
|
5078
|
+
var original = (_prevASTMap_get = prevASTMap.get(current)) !== null && _prevASTMap_get !== void 0 ? _prevASTMap_get : current;
|
|
5079
|
+
if (realNodeChanges.has(original)) {
|
|
5080
|
+
break;
|
|
5081
|
+
}
|
|
5082
|
+
realNodeChanges.add(original);
|
|
5083
|
+
current = current.parent;
|
|
5079
5084
|
}
|
|
5080
|
-
current = current.parent;
|
|
5081
5085
|
}
|
|
5082
|
-
})
|
|
5083
|
-
|
|
5084
|
-
|
|
5086
|
+
} catch (err) {
|
|
5087
|
+
_didIteratorError = true;
|
|
5088
|
+
_iteratorError = err;
|
|
5089
|
+
} finally{
|
|
5090
|
+
try {
|
|
5091
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5092
|
+
_iterator.return();
|
|
5093
|
+
}
|
|
5094
|
+
} finally{
|
|
5095
|
+
if (_didIteratorError) {
|
|
5096
|
+
throw _iteratorError;
|
|
5097
|
+
}
|
|
5098
|
+
}
|
|
5099
|
+
}
|
|
5100
|
+
var updated = this.computeTree(this.root, void 0, dataChanges, resolveCache, toNodeResolveOptions(this.options), void 0, prevASTMap, realNodeChanges);
|
|
5085
5101
|
this.resolveCache = resolveCache;
|
|
5086
5102
|
this.hooks.afterUpdate.call(updated.value);
|
|
5087
5103
|
return updated.value;
|
|
@@ -5135,7 +5151,7 @@ var Player = function() {
|
|
|
5135
5151
|
},
|
|
5136
5152
|
{
|
|
5137
5153
|
key: "computeTree",
|
|
5138
|
-
value: function computeTree(node, rawParent, dataChanges, cacheUpdate, options, partiallyResolvedParent, prevASTMap,
|
|
5154
|
+
value: function computeTree(node, rawParent, dataChanges, cacheUpdate, options, partiallyResolvedParent, prevASTMap, nodeChanges) {
|
|
5139
5155
|
var _this = this;
|
|
5140
5156
|
var dependencyModel = new DependencyModel(options.data.model);
|
|
5141
5157
|
dependencyModel.trackSubset("core");
|
|
@@ -5153,8 +5169,9 @@ var Player = function() {
|
|
|
5153
5169
|
}), node);
|
|
5154
5170
|
var previousResult = this.getPreviousResult(node);
|
|
5155
5171
|
var previousDeps = previousResult === null || previousResult === void 0 ? void 0 : previousResult.dependencies;
|
|
5172
|
+
var isChanged = nodeChanges.has(node);
|
|
5156
5173
|
var dataChanged = caresAboutDataChanges(dataChanges, previousDeps);
|
|
5157
|
-
var shouldUseLastValue = this.hooks.skipResolve.call(!dataChanged, node, resolveOptions);
|
|
5174
|
+
var shouldUseLastValue = this.hooks.skipResolve.call(!dataChanged && !isChanged, node, resolveOptions);
|
|
5158
5175
|
if (previousResult && shouldUseLastValue) {
|
|
5159
5176
|
var update2 = _object_spread_props(_object_spread({}, previousResult), {
|
|
5160
5177
|
updated: false
|
|
@@ -5166,30 +5183,6 @@ var Player = function() {
|
|
|
5166
5183
|
updated: false
|
|
5167
5184
|
});
|
|
5168
5185
|
cacheUpdate.set(AST, resolvedUpdate);
|
|
5169
|
-
if (resolvedUpdate.node.type === "async" /* Async */ ) {
|
|
5170
|
-
nextAsyncIdMap.set(resolvedUpdate.node.id, resolvedUpdate.node);
|
|
5171
|
-
}
|
|
5172
|
-
var _resolvedUpdate_node_asyncNodesResolved;
|
|
5173
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5174
|
-
try {
|
|
5175
|
-
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){
|
|
5176
|
-
var key = _step.value;
|
|
5177
|
-
nextAsyncIdMap.set(key, resolvedUpdate.node);
|
|
5178
|
-
}
|
|
5179
|
-
} catch (err) {
|
|
5180
|
-
_didIteratorError = true;
|
|
5181
|
-
_iteratorError = err;
|
|
5182
|
-
} finally{
|
|
5183
|
-
try {
|
|
5184
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5185
|
-
_iterator.return();
|
|
5186
|
-
}
|
|
5187
|
-
} finally{
|
|
5188
|
-
if (_didIteratorError) {
|
|
5189
|
-
throw _iteratorError;
|
|
5190
|
-
}
|
|
5191
|
-
}
|
|
5192
|
-
}
|
|
5193
5186
|
var handleChildNode = function(childNode) {
|
|
5194
5187
|
var _prevASTMap_get;
|
|
5195
5188
|
var originalChildNode = (_prevASTMap_get = prevASTMap.get(childNode)) !== null && _prevASTMap_get !== void 0 ? _prevASTMap_get : childNode;
|
|
@@ -5220,30 +5213,6 @@ var Player = function() {
|
|
|
5220
5213
|
type: "empty" /* Empty */
|
|
5221
5214
|
};
|
|
5222
5215
|
resolvedAST.parent = partiallyResolvedParent;
|
|
5223
|
-
if (resolvedAST.type === "async" /* Async */ ) {
|
|
5224
|
-
nextAsyncIdMap.set(resolvedAST.id, resolvedAST);
|
|
5225
|
-
}
|
|
5226
|
-
var _resolvedAST_asyncNodesResolved;
|
|
5227
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5228
|
-
try {
|
|
5229
|
-
for(var _iterator = ((_resolvedAST_asyncNodesResolved = resolvedAST.asyncNodesResolved) !== null && _resolvedAST_asyncNodesResolved !== void 0 ? _resolvedAST_asyncNodesResolved : [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5230
|
-
var id = _step.value;
|
|
5231
|
-
nextAsyncIdMap.set(id, resolvedAST);
|
|
5232
|
-
}
|
|
5233
|
-
} catch (err) {
|
|
5234
|
-
_didIteratorError = true;
|
|
5235
|
-
_iteratorError = err;
|
|
5236
|
-
} finally{
|
|
5237
|
-
try {
|
|
5238
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5239
|
-
_iterator.return();
|
|
5240
|
-
}
|
|
5241
|
-
} finally{
|
|
5242
|
-
if (_didIteratorError) {
|
|
5243
|
-
throw _iteratorError;
|
|
5244
|
-
}
|
|
5245
|
-
}
|
|
5246
|
-
}
|
|
5247
5216
|
resolveOptions.node = resolvedAST;
|
|
5248
5217
|
this.ASTMap.set(resolvedAST, node);
|
|
5249
5218
|
var resolved = this.hooks.resolve.call(void 0, resolvedAST, resolveOptions);
|
|
@@ -5256,7 +5225,7 @@ var Player = function() {
|
|
|
5256
5225
|
if ("children" in resolvedAST) {
|
|
5257
5226
|
var _resolvedAST_children;
|
|
5258
5227
|
var newChildren = (_resolvedAST_children = resolvedAST.children) === null || _resolvedAST_children === void 0 ? void 0 : _resolvedAST_children.map(function(child) {
|
|
5259
|
-
var computedChildTree = _this.computeTree(child.value, node, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap,
|
|
5228
|
+
var computedChildTree = _this.computeTree(child.value, node, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap, nodeChanges);
|
|
5260
5229
|
var childTreeDeps = computedChildTree.dependencies, childNode = computedChildTree.node, childUpdated = computedChildTree.updated, childValue = computedChildTree.value;
|
|
5261
5230
|
childTreeDeps.forEach(function(binding) {
|
|
5262
5231
|
return childDependencies.add(binding);
|
|
@@ -5279,7 +5248,7 @@ var Player = function() {
|
|
|
5279
5248
|
var childValue = [];
|
|
5280
5249
|
var rawParentToPassIn = node;
|
|
5281
5250
|
resolvedAST.values = resolvedAST.values.map(function(mValue) {
|
|
5282
|
-
var mTree = _this.computeTree(mValue, rawParentToPassIn, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap,
|
|
5251
|
+
var mTree = _this.computeTree(mValue, rawParentToPassIn, dataChanges, cacheUpdate, resolveOptions, resolvedAST, prevASTMap, nodeChanges);
|
|
5283
5252
|
if (mTree.value !== void 0 && mTree.value !== null) {
|
|
5284
5253
|
mTree.dependencies.forEach(function(bindingDep) {
|
|
5285
5254
|
return childDependencies.add(bindingDep);
|
|
@@ -5384,19 +5353,17 @@ var Player = function() {
|
|
|
5384
5353
|
}
|
|
5385
5354
|
_create_class(ViewInstance, [
|
|
5386
5355
|
{
|
|
5387
|
-
key: "updateAsync",
|
|
5356
|
+
/** @deprecated use ViewController.updateViewAST */ key: "updateAsync",
|
|
5388
5357
|
value: function updateAsync(asyncNode) {
|
|
5389
5358
|
var _this_resolver;
|
|
5390
|
-
var update = (_this_resolver = this.resolver) === null || _this_resolver === void 0 ? void 0 : _this_resolver.update(
|
|
5391
|
-
asyncNode
|
|
5392
|
-
]));
|
|
5359
|
+
var update = (_this_resolver = this.resolver) === null || _this_resolver === void 0 ? void 0 : _this_resolver.update();
|
|
5393
5360
|
this.lastUpdate = update;
|
|
5394
5361
|
this.hooks.onUpdate.call(update);
|
|
5395
5362
|
}
|
|
5396
5363
|
},
|
|
5397
5364
|
{
|
|
5398
5365
|
key: "update",
|
|
5399
|
-
value: function update(changes) {
|
|
5366
|
+
value: function update(changes, nodeChanges) {
|
|
5400
5367
|
var _this_resolver;
|
|
5401
5368
|
if (this.rootNode === void 0) {
|
|
5402
5369
|
this.validationProvider = new CrossfieldProvider(this.initialView, this.resolverOptions.parseBinding, this.resolverOptions.logger);
|
|
@@ -5414,7 +5381,7 @@ var Player = function() {
|
|
|
5414
5381
|
}));
|
|
5415
5382
|
this.hooks.resolver.call(this.resolver);
|
|
5416
5383
|
}
|
|
5417
|
-
var update = (_this_resolver = this.resolver) === null || _this_resolver === void 0 ? void 0 : _this_resolver.update(changes);
|
|
5384
|
+
var update = (_this_resolver = this.resolver) === null || _this_resolver === void 0 ? void 0 : _this_resolver.update(changes, nodeChanges);
|
|
5418
5385
|
if (this.lastUpdate === update) {
|
|
5419
5386
|
return this.lastUpdate;
|
|
5420
5387
|
}
|
|
@@ -7486,6 +7453,10 @@ var Player = function() {
|
|
|
7486
7453
|
return Registry;
|
|
7487
7454
|
}();
|
|
7488
7455
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/controllers/view/controller.ts
|
|
7456
|
+
var mergeSets = function(setA, setB) {
|
|
7457
|
+
var _setA_values, _setB_values;
|
|
7458
|
+
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 : [])));
|
|
7459
|
+
};
|
|
7489
7460
|
var ViewController = /*#__PURE__*/ function() {
|
|
7490
7461
|
function ViewController(initialViews, options) {
|
|
7491
7462
|
var _this = this;
|
|
@@ -7515,7 +7486,7 @@ var Player = function() {
|
|
|
7515
7486
|
var silent = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
7516
7487
|
if (_this1.currentView) {
|
|
7517
7488
|
if (_this1.optimizeUpdates) {
|
|
7518
|
-
_this1.queueUpdate(updates, silent);
|
|
7489
|
+
_this1.queueUpdate(updates, void 0, silent);
|
|
7519
7490
|
} else {
|
|
7520
7491
|
_this1.currentView.update();
|
|
7521
7492
|
}
|
|
@@ -7545,25 +7516,26 @@ var Player = function() {
|
|
|
7545
7516
|
_create_class(ViewController, [
|
|
7546
7517
|
{
|
|
7547
7518
|
key: "queueUpdate",
|
|
7548
|
-
value: function queueUpdate(bindings) {
|
|
7519
|
+
value: function queueUpdate(bindings, nodes) {
|
|
7549
7520
|
var _this = this;
|
|
7550
|
-
var silent = arguments.length >
|
|
7551
|
-
|
|
7552
|
-
if ((_this_pendingUpdate = this.pendingUpdate) === null || _this_pendingUpdate === void 0 ? void 0 : _this_pendingUpdate.changedBindings) {
|
|
7553
|
-
this.pendingUpdate.changedBindings = /* @__PURE__ */ new Set(_to_consumable_array(this.pendingUpdate.changedBindings).concat(_to_consumable_array(bindings)));
|
|
7554
|
-
} else {
|
|
7521
|
+
var silent = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
|
|
7522
|
+
if (!this.pendingUpdate) {
|
|
7555
7523
|
this.pendingUpdate = {
|
|
7556
|
-
changedBindings: bindings,
|
|
7557
7524
|
scheduled: false
|
|
7558
7525
|
};
|
|
7559
7526
|
}
|
|
7527
|
+
this.pendingUpdate = _object_spread_props(_object_spread({}, this.pendingUpdate), {
|
|
7528
|
+
changedBindings: mergeSets(this.pendingUpdate.changedBindings, bindings),
|
|
7529
|
+
changedNodes: mergeSets(this.pendingUpdate.changedNodes, nodes)
|
|
7530
|
+
});
|
|
7560
7531
|
if (!this.pendingUpdate.scheduled && !silent) {
|
|
7561
7532
|
this.pendingUpdate.scheduled = true;
|
|
7562
7533
|
(0, import_queue_microtask.default)(function() {
|
|
7563
|
-
var
|
|
7564
|
-
var
|
|
7534
|
+
var _this_currentView;
|
|
7535
|
+
var _this_pendingUpdate;
|
|
7536
|
+
var _ref = (_this_pendingUpdate = _this.pendingUpdate) !== null && _this_pendingUpdate !== void 0 ? _this_pendingUpdate : {}, changedBindings = _ref.changedBindings, changedNodes = _ref.changedNodes;
|
|
7565
7537
|
_this.pendingUpdate = void 0;
|
|
7566
|
-
(_this_currentView = _this.currentView) === null || _this_currentView === void 0 ? void 0 : _this_currentView.update(
|
|
7538
|
+
(_this_currentView = _this.currentView) === null || _this_currentView === void 0 ? void 0 : _this_currentView.update(changedBindings, changedNodes);
|
|
7567
7539
|
});
|
|
7568
7540
|
}
|
|
7569
7541
|
}
|
|
@@ -7640,6 +7612,15 @@ var Player = function() {
|
|
|
7640
7612
|
new MultiNodePlugin()
|
|
7641
7613
|
];
|
|
7642
7614
|
}
|
|
7615
|
+
},
|
|
7616
|
+
{
|
|
7617
|
+
/** 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.
|
|
7618
|
+
*
|
|
7619
|
+
* 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.
|
|
7620
|
+
*/ key: "updateViewAST",
|
|
7621
|
+
value: function updateViewAST(nodes) {
|
|
7622
|
+
this.queueUpdate(void 0, nodes);
|
|
7623
|
+
}
|
|
7643
7624
|
}
|
|
7644
7625
|
]);
|
|
7645
7626
|
return ViewController;
|
|
@@ -8020,8 +8001,8 @@ var Player = function() {
|
|
|
8020
8001
|
status: "not-started"
|
|
8021
8002
|
};
|
|
8022
8003
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/player.ts
|
|
8023
|
-
var PLAYER_VERSION = true ? "0.15.0-next.
|
|
8024
|
-
var COMMIT = true ? "
|
|
8004
|
+
var PLAYER_VERSION = true ? "0.15.0-next.6" : "unknown";
|
|
8005
|
+
var COMMIT = true ? "9b22cee7078ed75d77b3c31bc306c758ea07da8b" : "unknown";
|
|
8025
8006
|
var _Player = /*#__PURE__*/ function() {
|
|
8026
8007
|
function _Player(config) {
|
|
8027
8008
|
var _this = this;
|