@player-ui/metrics-plugin 0.12.0-next.4 → 0.12.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/MetricsPlugin.native.js +173 -175
- package/dist/MetricsPlugin.native.js.map +1 -1
- package/package.json +3 -3
|
@@ -5485,6 +5485,178 @@ var MetricsPlugin = function() {
|
|
|
5485
5485
|
]);
|
|
5486
5486
|
return AssetPlugin;
|
|
5487
5487
|
}();
|
|
5488
|
+
var LocalStateStore = /*#__PURE__*/ function() {
|
|
5489
|
+
function LocalStateStore(onUpdate) {
|
|
5490
|
+
_class_call_check(this, LocalStateStore);
|
|
5491
|
+
this.updateCallback = onUpdate;
|
|
5492
|
+
this.state = /* @__PURE__ */ new Map();
|
|
5493
|
+
}
|
|
5494
|
+
_create_class(LocalStateStore, [
|
|
5495
|
+
{
|
|
5496
|
+
key: "removeKey",
|
|
5497
|
+
value: function removeKey(key) {
|
|
5498
|
+
this.state.delete(key);
|
|
5499
|
+
}
|
|
5500
|
+
},
|
|
5501
|
+
{
|
|
5502
|
+
key: "reset",
|
|
5503
|
+
value: function reset() {
|
|
5504
|
+
this.state.clear();
|
|
5505
|
+
}
|
|
5506
|
+
},
|
|
5507
|
+
{
|
|
5508
|
+
key: "useSharedState",
|
|
5509
|
+
value: function useSharedState(key) {
|
|
5510
|
+
var _this = this;
|
|
5511
|
+
return function(initialState) {
|
|
5512
|
+
if (!_this.state.has(key)) {
|
|
5513
|
+
_this.state.set(key, initialState);
|
|
5514
|
+
}
|
|
5515
|
+
return [
|
|
5516
|
+
_this.state.get(key),
|
|
5517
|
+
function(newState) {
|
|
5518
|
+
var current = _this.state.get(key);
|
|
5519
|
+
_this.state.set(key, newState);
|
|
5520
|
+
if (current !== newState) {
|
|
5521
|
+
var _this_updateCallback, _this1;
|
|
5522
|
+
(_this_updateCallback = (_this1 = _this).updateCallback) === null || _this_updateCallback === void 0 ? void 0 : _this_updateCallback.call(_this1);
|
|
5523
|
+
}
|
|
5524
|
+
}
|
|
5525
|
+
];
|
|
5526
|
+
};
|
|
5527
|
+
}
|
|
5528
|
+
},
|
|
5529
|
+
{
|
|
5530
|
+
key: "getLocalStateFunction",
|
|
5531
|
+
value: function getLocalStateFunction(key, countKey) {
|
|
5532
|
+
var _this = this;
|
|
5533
|
+
return function(initialState) {
|
|
5534
|
+
if (!_this.state.has(key)) {
|
|
5535
|
+
_this.state.set(key, []);
|
|
5536
|
+
}
|
|
5537
|
+
if (!_this.state.has(countKey)) {
|
|
5538
|
+
_this.state.set(countKey, 0);
|
|
5539
|
+
}
|
|
5540
|
+
var localState = _this.state.get(key);
|
|
5541
|
+
var oldCount = _this.state.get(countKey);
|
|
5542
|
+
_this.state.set(countKey, oldCount + 1);
|
|
5543
|
+
if (localState.length <= oldCount) {
|
|
5544
|
+
localState.push(initialState);
|
|
5545
|
+
}
|
|
5546
|
+
var value = localState[oldCount];
|
|
5547
|
+
return [
|
|
5548
|
+
value,
|
|
5549
|
+
function(newState) {
|
|
5550
|
+
var oldValue = localState[oldCount];
|
|
5551
|
+
localState[oldCount] = newState;
|
|
5552
|
+
if (oldValue !== newState) {
|
|
5553
|
+
var _this_updateCallback, _this1;
|
|
5554
|
+
(_this_updateCallback = (_this1 = _this).updateCallback) === null || _this_updateCallback === void 0 ? void 0 : _this_updateCallback.call(_this1);
|
|
5555
|
+
}
|
|
5556
|
+
}
|
|
5557
|
+
];
|
|
5558
|
+
};
|
|
5559
|
+
}
|
|
5560
|
+
}
|
|
5561
|
+
]);
|
|
5562
|
+
return LocalStateStore;
|
|
5563
|
+
}();
|
|
5564
|
+
function findUp(node, target) {
|
|
5565
|
+
if (node === target) {
|
|
5566
|
+
return true;
|
|
5567
|
+
}
|
|
5568
|
+
if (node.parent) {
|
|
5569
|
+
return findUp(node.parent, target);
|
|
5570
|
+
}
|
|
5571
|
+
return false;
|
|
5572
|
+
}
|
|
5573
|
+
var AssetTransformCorePlugin = /*#__PURE__*/ function() {
|
|
5574
|
+
function AssetTransformCorePlugin(registry) {
|
|
5575
|
+
_class_call_check(this, AssetTransformCorePlugin);
|
|
5576
|
+
this.registry = registry;
|
|
5577
|
+
this.stateStore = /* @__PURE__ */ new Map();
|
|
5578
|
+
this.beforeResolveSymbol = Symbol("before resolve");
|
|
5579
|
+
this.resolveSymbol = Symbol("resolve");
|
|
5580
|
+
this.beforeResolveCountSymbol = Symbol("before resolve count");
|
|
5581
|
+
this.resolveCountSymbol = Symbol("resolve count");
|
|
5582
|
+
}
|
|
5583
|
+
_create_class(AssetTransformCorePlugin, [
|
|
5584
|
+
{
|
|
5585
|
+
key: "apply",
|
|
5586
|
+
value: function apply(view) {
|
|
5587
|
+
var _this = this;
|
|
5588
|
+
this.stateStore.clear();
|
|
5589
|
+
view.hooks.resolver.tap("asset-transform", function(resolver) {
|
|
5590
|
+
var lastUpdatedNode;
|
|
5591
|
+
var updateState = function(node) {
|
|
5592
|
+
lastUpdatedNode = node;
|
|
5593
|
+
view.update(/* @__PURE__ */ new Set());
|
|
5594
|
+
};
|
|
5595
|
+
var getStore = function(node, stepKey) {
|
|
5596
|
+
var store;
|
|
5597
|
+
var countKey = stepKey === _this.resolveSymbol ? _this.resolveCountSymbol : _this.beforeResolveCountSymbol;
|
|
5598
|
+
var storedState = _this.stateStore.get(node);
|
|
5599
|
+
if (storedState) {
|
|
5600
|
+
store = storedState;
|
|
5601
|
+
store.removeKey(countKey);
|
|
5602
|
+
} else {
|
|
5603
|
+
store = new LocalStateStore(function() {
|
|
5604
|
+
updateState(node);
|
|
5605
|
+
});
|
|
5606
|
+
_this.stateStore.set(node, store);
|
|
5607
|
+
}
|
|
5608
|
+
return {
|
|
5609
|
+
useSharedState: function(key) {
|
|
5610
|
+
return store.useSharedState(key);
|
|
5611
|
+
},
|
|
5612
|
+
useLocalState: function(initialState) {
|
|
5613
|
+
return store.getLocalStateFunction(stepKey, countKey)(initialState);
|
|
5614
|
+
}
|
|
5615
|
+
};
|
|
5616
|
+
};
|
|
5617
|
+
resolver.hooks.beforeResolve.tap("asset-transform", function(node, options) {
|
|
5618
|
+
if (node && (node.type === "asset" || node.type === "view")) {
|
|
5619
|
+
var transform = _this.registry.get(node.value);
|
|
5620
|
+
if (transform === null || transform === void 0 ? void 0 : transform.beforeResolve) {
|
|
5621
|
+
var _options_node;
|
|
5622
|
+
var store = getStore((_options_node = options.node) !== null && _options_node !== void 0 ? _options_node : node, _this.beforeResolveSymbol);
|
|
5623
|
+
return transform.beforeResolve(node, options, store);
|
|
5624
|
+
}
|
|
5625
|
+
}
|
|
5626
|
+
return node;
|
|
5627
|
+
});
|
|
5628
|
+
resolver.hooks.afterUpdate.tap("asset-transform", function() {
|
|
5629
|
+
lastUpdatedNode = void 0;
|
|
5630
|
+
});
|
|
5631
|
+
resolver.hooks.skipResolve.tap("asset-transform", function(skip, node) {
|
|
5632
|
+
if (!skip || !lastUpdatedNode) {
|
|
5633
|
+
return skip;
|
|
5634
|
+
}
|
|
5635
|
+
var isParentOfUpdated = findUp(lastUpdatedNode, node);
|
|
5636
|
+
var isChildOfUpdated = findUp(node, lastUpdatedNode);
|
|
5637
|
+
return !isParentOfUpdated && !isChildOfUpdated;
|
|
5638
|
+
});
|
|
5639
|
+
resolver.hooks.afterResolve.tap("asset-transform", function(value, node, options) {
|
|
5640
|
+
if (node.type !== "asset" && node.type !== "view") {
|
|
5641
|
+
return value;
|
|
5642
|
+
}
|
|
5643
|
+
var originalNode = resolver.getSourceNode(node);
|
|
5644
|
+
if (!originalNode) {
|
|
5645
|
+
return value;
|
|
5646
|
+
}
|
|
5647
|
+
var transform = _this.registry.get(value);
|
|
5648
|
+
if (transform === null || transform === void 0 ? void 0 : transform.resolve) {
|
|
5649
|
+
var store = getStore(originalNode, _this.resolveSymbol);
|
|
5650
|
+
return transform === null || transform === void 0 ? void 0 : transform.resolve(value, options, store);
|
|
5651
|
+
}
|
|
5652
|
+
return value;
|
|
5653
|
+
});
|
|
5654
|
+
});
|
|
5655
|
+
}
|
|
5656
|
+
}
|
|
5657
|
+
]);
|
|
5658
|
+
return AssetTransformCorePlugin;
|
|
5659
|
+
}();
|
|
5488
5660
|
var FlowInstance = /*#__PURE__*/ function() {
|
|
5489
5661
|
function FlowInstance(id, flow, options) {
|
|
5490
5662
|
_class_call_check(this, FlowInstance);
|
|
@@ -6514,180 +6686,6 @@ var MetricsPlugin = function() {
|
|
|
6514
6686
|
]);
|
|
6515
6687
|
return ValidationController;
|
|
6516
6688
|
}();
|
|
6517
|
-
var LocalStateStore = /*#__PURE__*/ function() {
|
|
6518
|
-
function LocalStateStore(onUpdate) {
|
|
6519
|
-
_class_call_check(this, LocalStateStore);
|
|
6520
|
-
this.updateCallback = onUpdate;
|
|
6521
|
-
this.state = /* @__PURE__ */ new Map();
|
|
6522
|
-
}
|
|
6523
|
-
_create_class(LocalStateStore, [
|
|
6524
|
-
{
|
|
6525
|
-
key: "removeKey",
|
|
6526
|
-
value: function removeKey(key) {
|
|
6527
|
-
this.state.delete(key);
|
|
6528
|
-
}
|
|
6529
|
-
},
|
|
6530
|
-
{
|
|
6531
|
-
key: "reset",
|
|
6532
|
-
value: function reset() {
|
|
6533
|
-
this.state.clear();
|
|
6534
|
-
}
|
|
6535
|
-
},
|
|
6536
|
-
{
|
|
6537
|
-
key: "useSharedState",
|
|
6538
|
-
value: function useSharedState(key) {
|
|
6539
|
-
var _this = this;
|
|
6540
|
-
return function(initialState) {
|
|
6541
|
-
if (!_this.state.has(key)) {
|
|
6542
|
-
_this.state.set(key, initialState);
|
|
6543
|
-
}
|
|
6544
|
-
return [
|
|
6545
|
-
_this.state.get(key),
|
|
6546
|
-
function(newState) {
|
|
6547
|
-
var current = _this.state.get(key);
|
|
6548
|
-
_this.state.set(key, newState);
|
|
6549
|
-
if (current !== newState) {
|
|
6550
|
-
var _this_updateCallback, _this1;
|
|
6551
|
-
(_this_updateCallback = (_this1 = _this).updateCallback) === null || _this_updateCallback === void 0 ? void 0 : _this_updateCallback.call(_this1);
|
|
6552
|
-
}
|
|
6553
|
-
}
|
|
6554
|
-
];
|
|
6555
|
-
};
|
|
6556
|
-
}
|
|
6557
|
-
},
|
|
6558
|
-
{
|
|
6559
|
-
key: "getLocalStateFunction",
|
|
6560
|
-
value: function getLocalStateFunction(key, countKey) {
|
|
6561
|
-
var _this = this;
|
|
6562
|
-
return function(initialState) {
|
|
6563
|
-
if (!_this.state.has(key)) {
|
|
6564
|
-
_this.state.set(key, []);
|
|
6565
|
-
}
|
|
6566
|
-
if (!_this.state.has(countKey)) {
|
|
6567
|
-
_this.state.set(countKey, 0);
|
|
6568
|
-
}
|
|
6569
|
-
var localState = _this.state.get(key);
|
|
6570
|
-
var oldCount = _this.state.get(countKey);
|
|
6571
|
-
_this.state.set(countKey, oldCount + 1);
|
|
6572
|
-
if (localState.length <= oldCount) {
|
|
6573
|
-
localState.push(initialState);
|
|
6574
|
-
}
|
|
6575
|
-
var value = localState[oldCount];
|
|
6576
|
-
return [
|
|
6577
|
-
value,
|
|
6578
|
-
function(newState) {
|
|
6579
|
-
var oldValue = localState[oldCount];
|
|
6580
|
-
localState[oldCount] = newState;
|
|
6581
|
-
if (oldValue !== newState) {
|
|
6582
|
-
var _this_updateCallback, _this1;
|
|
6583
|
-
(_this_updateCallback = (_this1 = _this).updateCallback) === null || _this_updateCallback === void 0 ? void 0 : _this_updateCallback.call(_this1);
|
|
6584
|
-
}
|
|
6585
|
-
}
|
|
6586
|
-
];
|
|
6587
|
-
};
|
|
6588
|
-
}
|
|
6589
|
-
}
|
|
6590
|
-
]);
|
|
6591
|
-
return LocalStateStore;
|
|
6592
|
-
}();
|
|
6593
|
-
function findUp(node, target) {
|
|
6594
|
-
if (node === target) {
|
|
6595
|
-
return true;
|
|
6596
|
-
}
|
|
6597
|
-
if (node.parent) {
|
|
6598
|
-
return findUp(node.parent, target);
|
|
6599
|
-
}
|
|
6600
|
-
return false;
|
|
6601
|
-
}
|
|
6602
|
-
var AssetTransformCorePlugin = /*#__PURE__*/ function() {
|
|
6603
|
-
function AssetTransformCorePlugin(registry) {
|
|
6604
|
-
_class_call_check(this, AssetTransformCorePlugin);
|
|
6605
|
-
this.registry = registry;
|
|
6606
|
-
this.stateStore = /* @__PURE__ */ new Map();
|
|
6607
|
-
this.beforeResolveSymbol = Symbol("before resolve");
|
|
6608
|
-
this.resolveSymbol = Symbol("resolve");
|
|
6609
|
-
this.beforeResolveCountSymbol = Symbol("before resolve count");
|
|
6610
|
-
this.resolveCountSymbol = Symbol("resolve count");
|
|
6611
|
-
}
|
|
6612
|
-
_create_class(AssetTransformCorePlugin, [
|
|
6613
|
-
{
|
|
6614
|
-
key: "apply",
|
|
6615
|
-
value: function apply(viewController) {
|
|
6616
|
-
var _this = this;
|
|
6617
|
-
viewController.hooks.view.tap("asset-transform", function(view) {
|
|
6618
|
-
_this.stateStore.clear();
|
|
6619
|
-
view.hooks.resolver.tap("asset-transform", function(resolver) {
|
|
6620
|
-
var lastUpdatedNode;
|
|
6621
|
-
var updateState = function(node) {
|
|
6622
|
-
lastUpdatedNode = node;
|
|
6623
|
-
view.update(/* @__PURE__ */ new Set());
|
|
6624
|
-
};
|
|
6625
|
-
var getStore = function(node, stepKey) {
|
|
6626
|
-
var store;
|
|
6627
|
-
var countKey = stepKey === _this.resolveSymbol ? _this.resolveCountSymbol : _this.beforeResolveCountSymbol;
|
|
6628
|
-
var storedState = _this.stateStore.get(node);
|
|
6629
|
-
if (storedState) {
|
|
6630
|
-
store = storedState;
|
|
6631
|
-
store.removeKey(countKey);
|
|
6632
|
-
} else {
|
|
6633
|
-
store = new LocalStateStore(function() {
|
|
6634
|
-
updateState(node);
|
|
6635
|
-
});
|
|
6636
|
-
_this.stateStore.set(node, store);
|
|
6637
|
-
}
|
|
6638
|
-
return {
|
|
6639
|
-
useSharedState: function(key) {
|
|
6640
|
-
return store.useSharedState(key);
|
|
6641
|
-
},
|
|
6642
|
-
useLocalState: function(initialState) {
|
|
6643
|
-
return store.getLocalStateFunction(stepKey, countKey)(initialState);
|
|
6644
|
-
}
|
|
6645
|
-
};
|
|
6646
|
-
};
|
|
6647
|
-
resolver.hooks.beforeResolve.tap("asset-transform", function(node, options) {
|
|
6648
|
-
if (node && (node.type === "asset" || node.type === "view")) {
|
|
6649
|
-
var transform = _this.registry.get(node.value);
|
|
6650
|
-
if (transform === null || transform === void 0 ? void 0 : transform.beforeResolve) {
|
|
6651
|
-
var _options_node;
|
|
6652
|
-
var store = getStore((_options_node = options.node) !== null && _options_node !== void 0 ? _options_node : node, _this.beforeResolveSymbol);
|
|
6653
|
-
return transform.beforeResolve(node, options, store);
|
|
6654
|
-
}
|
|
6655
|
-
}
|
|
6656
|
-
return node;
|
|
6657
|
-
});
|
|
6658
|
-
resolver.hooks.afterUpdate.tap("asset-transform", function() {
|
|
6659
|
-
lastUpdatedNode = void 0;
|
|
6660
|
-
});
|
|
6661
|
-
resolver.hooks.skipResolve.tap("asset-transform", function(skip, node) {
|
|
6662
|
-
if (!skip || !lastUpdatedNode) {
|
|
6663
|
-
return skip;
|
|
6664
|
-
}
|
|
6665
|
-
var isParentOfUpdated = findUp(lastUpdatedNode, node);
|
|
6666
|
-
var isChildOfUpdated = findUp(node, lastUpdatedNode);
|
|
6667
|
-
return !isParentOfUpdated && !isChildOfUpdated;
|
|
6668
|
-
});
|
|
6669
|
-
resolver.hooks.afterResolve.tap("asset-transform", function(value, node, options) {
|
|
6670
|
-
if (node.type !== "asset" && node.type !== "view") {
|
|
6671
|
-
return value;
|
|
6672
|
-
}
|
|
6673
|
-
var originalNode = resolver.getSourceNode(node);
|
|
6674
|
-
if (!originalNode) {
|
|
6675
|
-
return value;
|
|
6676
|
-
}
|
|
6677
|
-
var transform = _this.registry.get(value);
|
|
6678
|
-
if (transform === null || transform === void 0 ? void 0 : transform.resolve) {
|
|
6679
|
-
var store = getStore(originalNode, _this.resolveSymbol);
|
|
6680
|
-
return transform === null || transform === void 0 ? void 0 : transform.resolve(value, options, store);
|
|
6681
|
-
}
|
|
6682
|
-
return value;
|
|
6683
|
-
});
|
|
6684
|
-
});
|
|
6685
|
-
});
|
|
6686
|
-
}
|
|
6687
|
-
}
|
|
6688
|
-
]);
|
|
6689
|
-
return AssetTransformCorePlugin;
|
|
6690
|
-
}();
|
|
6691
6689
|
var ViewController = /*#__PURE__*/ function() {
|
|
6692
6690
|
function ViewController(initialViews, options) {
|
|
6693
6691
|
var _this = this;
|
|
@@ -6705,7 +6703,6 @@ var MetricsPlugin = function() {
|
|
|
6705
6703
|
viewMap[view.id] = view;
|
|
6706
6704
|
return viewMap;
|
|
6707
6705
|
}, {});
|
|
6708
|
-
new AssetTransformCorePlugin(this.transformRegistry).apply(this);
|
|
6709
6706
|
options.flowController.hooks.flow.tap("viewController", function(flow) {
|
|
6710
6707
|
flow.hooks.transition.tap("viewController", function(_oldState, newState) {
|
|
6711
6708
|
if (newState.value.state_type === "VIEW") {
|
|
@@ -7190,6 +7187,7 @@ var MetricsPlugin = function() {
|
|
|
7190
7187
|
new AssetPlugin().apply(view);
|
|
7191
7188
|
new SwitchPlugin(pluginOptions).apply(view);
|
|
7192
7189
|
new ApplicabilityPlugin().apply(view);
|
|
7190
|
+
new AssetTransformCorePlugin(viewController.transformRegistry).apply(view);
|
|
7193
7191
|
new StringResolverPlugin().apply(view);
|
|
7194
7192
|
var templatePlugin = new TemplatePlugin(pluginOptions);
|
|
7195
7193
|
templatePlugin.apply(view);
|