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