@player-ui/check-path-plugin 0.12.0-next.3 → 0.12.0-next.5
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.
|
@@ -5424,6 +5424,178 @@ var CheckPathPlugin = function() {
|
|
|
5424
5424
|
]);
|
|
5425
5425
|
return AssetPlugin;
|
|
5426
5426
|
}();
|
|
5427
|
+
var LocalStateStore = /*#__PURE__*/ function() {
|
|
5428
|
+
function LocalStateStore(onUpdate) {
|
|
5429
|
+
_class_call_check(this, LocalStateStore);
|
|
5430
|
+
this.updateCallback = onUpdate;
|
|
5431
|
+
this.state = /* @__PURE__ */ new Map();
|
|
5432
|
+
}
|
|
5433
|
+
_create_class(LocalStateStore, [
|
|
5434
|
+
{
|
|
5435
|
+
key: "removeKey",
|
|
5436
|
+
value: function removeKey(key) {
|
|
5437
|
+
this.state.delete(key);
|
|
5438
|
+
}
|
|
5439
|
+
},
|
|
5440
|
+
{
|
|
5441
|
+
key: "reset",
|
|
5442
|
+
value: function reset() {
|
|
5443
|
+
this.state.clear();
|
|
5444
|
+
}
|
|
5445
|
+
},
|
|
5446
|
+
{
|
|
5447
|
+
key: "useSharedState",
|
|
5448
|
+
value: function useSharedState(key) {
|
|
5449
|
+
var _this = this;
|
|
5450
|
+
return function(initialState) {
|
|
5451
|
+
if (!_this.state.has(key)) {
|
|
5452
|
+
_this.state.set(key, initialState);
|
|
5453
|
+
}
|
|
5454
|
+
return [
|
|
5455
|
+
_this.state.get(key),
|
|
5456
|
+
function(newState) {
|
|
5457
|
+
var current = _this.state.get(key);
|
|
5458
|
+
_this.state.set(key, newState);
|
|
5459
|
+
if (current !== newState) {
|
|
5460
|
+
var _this_updateCallback, _this1;
|
|
5461
|
+
(_this_updateCallback = (_this1 = _this).updateCallback) === null || _this_updateCallback === void 0 ? void 0 : _this_updateCallback.call(_this1);
|
|
5462
|
+
}
|
|
5463
|
+
}
|
|
5464
|
+
];
|
|
5465
|
+
};
|
|
5466
|
+
}
|
|
5467
|
+
},
|
|
5468
|
+
{
|
|
5469
|
+
key: "getLocalStateFunction",
|
|
5470
|
+
value: function getLocalStateFunction(key, countKey) {
|
|
5471
|
+
var _this = this;
|
|
5472
|
+
return function(initialState) {
|
|
5473
|
+
if (!_this.state.has(key)) {
|
|
5474
|
+
_this.state.set(key, []);
|
|
5475
|
+
}
|
|
5476
|
+
if (!_this.state.has(countKey)) {
|
|
5477
|
+
_this.state.set(countKey, 0);
|
|
5478
|
+
}
|
|
5479
|
+
var localState = _this.state.get(key);
|
|
5480
|
+
var oldCount = _this.state.get(countKey);
|
|
5481
|
+
_this.state.set(countKey, oldCount + 1);
|
|
5482
|
+
if (localState.length <= oldCount) {
|
|
5483
|
+
localState.push(initialState);
|
|
5484
|
+
}
|
|
5485
|
+
var value = localState[oldCount];
|
|
5486
|
+
return [
|
|
5487
|
+
value,
|
|
5488
|
+
function(newState) {
|
|
5489
|
+
var oldValue = localState[oldCount];
|
|
5490
|
+
localState[oldCount] = newState;
|
|
5491
|
+
if (oldValue !== newState) {
|
|
5492
|
+
var _this_updateCallback, _this1;
|
|
5493
|
+
(_this_updateCallback = (_this1 = _this).updateCallback) === null || _this_updateCallback === void 0 ? void 0 : _this_updateCallback.call(_this1);
|
|
5494
|
+
}
|
|
5495
|
+
}
|
|
5496
|
+
];
|
|
5497
|
+
};
|
|
5498
|
+
}
|
|
5499
|
+
}
|
|
5500
|
+
]);
|
|
5501
|
+
return LocalStateStore;
|
|
5502
|
+
}();
|
|
5503
|
+
function findUp(node, target) {
|
|
5504
|
+
if (node === target) {
|
|
5505
|
+
return true;
|
|
5506
|
+
}
|
|
5507
|
+
if (node.parent) {
|
|
5508
|
+
return findUp(node.parent, target);
|
|
5509
|
+
}
|
|
5510
|
+
return false;
|
|
5511
|
+
}
|
|
5512
|
+
var AssetTransformCorePlugin = /*#__PURE__*/ function() {
|
|
5513
|
+
function AssetTransformCorePlugin(registry) {
|
|
5514
|
+
_class_call_check(this, AssetTransformCorePlugin);
|
|
5515
|
+
this.registry = registry;
|
|
5516
|
+
this.stateStore = /* @__PURE__ */ new Map();
|
|
5517
|
+
this.beforeResolveSymbol = Symbol("before resolve");
|
|
5518
|
+
this.resolveSymbol = Symbol("resolve");
|
|
5519
|
+
this.beforeResolveCountSymbol = Symbol("before resolve count");
|
|
5520
|
+
this.resolveCountSymbol = Symbol("resolve count");
|
|
5521
|
+
}
|
|
5522
|
+
_create_class(AssetTransformCorePlugin, [
|
|
5523
|
+
{
|
|
5524
|
+
key: "apply",
|
|
5525
|
+
value: function apply(view) {
|
|
5526
|
+
var _this = this;
|
|
5527
|
+
this.stateStore.clear();
|
|
5528
|
+
view.hooks.resolver.tap("asset-transform", function(resolver) {
|
|
5529
|
+
var lastUpdatedNode;
|
|
5530
|
+
var updateState = function(node) {
|
|
5531
|
+
lastUpdatedNode = node;
|
|
5532
|
+
view.update(/* @__PURE__ */ new Set());
|
|
5533
|
+
};
|
|
5534
|
+
var getStore = function(node, stepKey) {
|
|
5535
|
+
var store;
|
|
5536
|
+
var countKey = stepKey === _this.resolveSymbol ? _this.resolveCountSymbol : _this.beforeResolveCountSymbol;
|
|
5537
|
+
var storedState = _this.stateStore.get(node);
|
|
5538
|
+
if (storedState) {
|
|
5539
|
+
store = storedState;
|
|
5540
|
+
store.removeKey(countKey);
|
|
5541
|
+
} else {
|
|
5542
|
+
store = new LocalStateStore(function() {
|
|
5543
|
+
updateState(node);
|
|
5544
|
+
});
|
|
5545
|
+
_this.stateStore.set(node, store);
|
|
5546
|
+
}
|
|
5547
|
+
return {
|
|
5548
|
+
useSharedState: function(key) {
|
|
5549
|
+
return store.useSharedState(key);
|
|
5550
|
+
},
|
|
5551
|
+
useLocalState: function(initialState) {
|
|
5552
|
+
return store.getLocalStateFunction(stepKey, countKey)(initialState);
|
|
5553
|
+
}
|
|
5554
|
+
};
|
|
5555
|
+
};
|
|
5556
|
+
resolver.hooks.beforeResolve.tap("asset-transform", function(node, options) {
|
|
5557
|
+
if (node && (node.type === "asset" || node.type === "view")) {
|
|
5558
|
+
var transform = _this.registry.get(node.value);
|
|
5559
|
+
if (transform === null || transform === void 0 ? void 0 : transform.beforeResolve) {
|
|
5560
|
+
var _options_node;
|
|
5561
|
+
var store = getStore((_options_node = options.node) !== null && _options_node !== void 0 ? _options_node : node, _this.beforeResolveSymbol);
|
|
5562
|
+
return transform.beforeResolve(node, options, store);
|
|
5563
|
+
}
|
|
5564
|
+
}
|
|
5565
|
+
return node;
|
|
5566
|
+
});
|
|
5567
|
+
resolver.hooks.afterUpdate.tap("asset-transform", function() {
|
|
5568
|
+
lastUpdatedNode = void 0;
|
|
5569
|
+
});
|
|
5570
|
+
resolver.hooks.skipResolve.tap("asset-transform", function(skip, node) {
|
|
5571
|
+
if (!skip || !lastUpdatedNode) {
|
|
5572
|
+
return skip;
|
|
5573
|
+
}
|
|
5574
|
+
var isParentOfUpdated = findUp(lastUpdatedNode, node);
|
|
5575
|
+
var isChildOfUpdated = findUp(node, lastUpdatedNode);
|
|
5576
|
+
return !isParentOfUpdated && !isChildOfUpdated;
|
|
5577
|
+
});
|
|
5578
|
+
resolver.hooks.afterResolve.tap("asset-transform", function(value, node, options) {
|
|
5579
|
+
if (node.type !== "asset" && node.type !== "view") {
|
|
5580
|
+
return value;
|
|
5581
|
+
}
|
|
5582
|
+
var originalNode = resolver.getSourceNode(node);
|
|
5583
|
+
if (!originalNode) {
|
|
5584
|
+
return value;
|
|
5585
|
+
}
|
|
5586
|
+
var transform = _this.registry.get(value);
|
|
5587
|
+
if (transform === null || transform === void 0 ? void 0 : transform.resolve) {
|
|
5588
|
+
var store = getStore(originalNode, _this.resolveSymbol);
|
|
5589
|
+
return transform === null || transform === void 0 ? void 0 : transform.resolve(value, options, store);
|
|
5590
|
+
}
|
|
5591
|
+
return value;
|
|
5592
|
+
});
|
|
5593
|
+
});
|
|
5594
|
+
}
|
|
5595
|
+
}
|
|
5596
|
+
]);
|
|
5597
|
+
return AssetTransformCorePlugin;
|
|
5598
|
+
}();
|
|
5427
5599
|
var FlowInstance = /*#__PURE__*/ function() {
|
|
5428
5600
|
function FlowInstance(id, flow, options) {
|
|
5429
5601
|
_class_call_check(this, FlowInstance);
|
|
@@ -6453,180 +6625,6 @@ var CheckPathPlugin = function() {
|
|
|
6453
6625
|
]);
|
|
6454
6626
|
return ValidationController;
|
|
6455
6627
|
}();
|
|
6456
|
-
var LocalStateStore = /*#__PURE__*/ function() {
|
|
6457
|
-
function LocalStateStore(onUpdate) {
|
|
6458
|
-
_class_call_check(this, LocalStateStore);
|
|
6459
|
-
this.updateCallback = onUpdate;
|
|
6460
|
-
this.state = /* @__PURE__ */ new Map();
|
|
6461
|
-
}
|
|
6462
|
-
_create_class(LocalStateStore, [
|
|
6463
|
-
{
|
|
6464
|
-
key: "removeKey",
|
|
6465
|
-
value: function removeKey(key) {
|
|
6466
|
-
this.state.delete(key);
|
|
6467
|
-
}
|
|
6468
|
-
},
|
|
6469
|
-
{
|
|
6470
|
-
key: "reset",
|
|
6471
|
-
value: function reset() {
|
|
6472
|
-
this.state.clear();
|
|
6473
|
-
}
|
|
6474
|
-
},
|
|
6475
|
-
{
|
|
6476
|
-
key: "useSharedState",
|
|
6477
|
-
value: function useSharedState(key) {
|
|
6478
|
-
var _this = this;
|
|
6479
|
-
return function(initialState) {
|
|
6480
|
-
if (!_this.state.has(key)) {
|
|
6481
|
-
_this.state.set(key, initialState);
|
|
6482
|
-
}
|
|
6483
|
-
return [
|
|
6484
|
-
_this.state.get(key),
|
|
6485
|
-
function(newState) {
|
|
6486
|
-
var current = _this.state.get(key);
|
|
6487
|
-
_this.state.set(key, newState);
|
|
6488
|
-
if (current !== newState) {
|
|
6489
|
-
var _this_updateCallback, _this1;
|
|
6490
|
-
(_this_updateCallback = (_this1 = _this).updateCallback) === null || _this_updateCallback === void 0 ? void 0 : _this_updateCallback.call(_this1);
|
|
6491
|
-
}
|
|
6492
|
-
}
|
|
6493
|
-
];
|
|
6494
|
-
};
|
|
6495
|
-
}
|
|
6496
|
-
},
|
|
6497
|
-
{
|
|
6498
|
-
key: "getLocalStateFunction",
|
|
6499
|
-
value: function getLocalStateFunction(key, countKey) {
|
|
6500
|
-
var _this = this;
|
|
6501
|
-
return function(initialState) {
|
|
6502
|
-
if (!_this.state.has(key)) {
|
|
6503
|
-
_this.state.set(key, []);
|
|
6504
|
-
}
|
|
6505
|
-
if (!_this.state.has(countKey)) {
|
|
6506
|
-
_this.state.set(countKey, 0);
|
|
6507
|
-
}
|
|
6508
|
-
var localState = _this.state.get(key);
|
|
6509
|
-
var oldCount = _this.state.get(countKey);
|
|
6510
|
-
_this.state.set(countKey, oldCount + 1);
|
|
6511
|
-
if (localState.length <= oldCount) {
|
|
6512
|
-
localState.push(initialState);
|
|
6513
|
-
}
|
|
6514
|
-
var value = localState[oldCount];
|
|
6515
|
-
return [
|
|
6516
|
-
value,
|
|
6517
|
-
function(newState) {
|
|
6518
|
-
var oldValue = localState[oldCount];
|
|
6519
|
-
localState[oldCount] = newState;
|
|
6520
|
-
if (oldValue !== newState) {
|
|
6521
|
-
var _this_updateCallback, _this1;
|
|
6522
|
-
(_this_updateCallback = (_this1 = _this).updateCallback) === null || _this_updateCallback === void 0 ? void 0 : _this_updateCallback.call(_this1);
|
|
6523
|
-
}
|
|
6524
|
-
}
|
|
6525
|
-
];
|
|
6526
|
-
};
|
|
6527
|
-
}
|
|
6528
|
-
}
|
|
6529
|
-
]);
|
|
6530
|
-
return LocalStateStore;
|
|
6531
|
-
}();
|
|
6532
|
-
function findUp(node, target) {
|
|
6533
|
-
if (node === target) {
|
|
6534
|
-
return true;
|
|
6535
|
-
}
|
|
6536
|
-
if (node.parent) {
|
|
6537
|
-
return findUp(node.parent, target);
|
|
6538
|
-
}
|
|
6539
|
-
return false;
|
|
6540
|
-
}
|
|
6541
|
-
var AssetTransformCorePlugin = /*#__PURE__*/ function() {
|
|
6542
|
-
function AssetTransformCorePlugin(registry) {
|
|
6543
|
-
_class_call_check(this, AssetTransformCorePlugin);
|
|
6544
|
-
this.registry = registry;
|
|
6545
|
-
this.stateStore = /* @__PURE__ */ new Map();
|
|
6546
|
-
this.beforeResolveSymbol = Symbol("before resolve");
|
|
6547
|
-
this.resolveSymbol = Symbol("resolve");
|
|
6548
|
-
this.beforeResolveCountSymbol = Symbol("before resolve count");
|
|
6549
|
-
this.resolveCountSymbol = Symbol("resolve count");
|
|
6550
|
-
}
|
|
6551
|
-
_create_class(AssetTransformCorePlugin, [
|
|
6552
|
-
{
|
|
6553
|
-
key: "apply",
|
|
6554
|
-
value: function apply(viewController) {
|
|
6555
|
-
var _this = this;
|
|
6556
|
-
viewController.hooks.view.tap("asset-transform", function(view) {
|
|
6557
|
-
_this.stateStore.clear();
|
|
6558
|
-
view.hooks.resolver.tap("asset-transform", function(resolver) {
|
|
6559
|
-
var lastUpdatedNode;
|
|
6560
|
-
var updateState = function(node) {
|
|
6561
|
-
lastUpdatedNode = node;
|
|
6562
|
-
view.update(/* @__PURE__ */ new Set());
|
|
6563
|
-
};
|
|
6564
|
-
var getStore = function(node, stepKey) {
|
|
6565
|
-
var store;
|
|
6566
|
-
var countKey = stepKey === _this.resolveSymbol ? _this.resolveCountSymbol : _this.beforeResolveCountSymbol;
|
|
6567
|
-
var storedState = _this.stateStore.get(node);
|
|
6568
|
-
if (storedState) {
|
|
6569
|
-
store = storedState;
|
|
6570
|
-
store.removeKey(countKey);
|
|
6571
|
-
} else {
|
|
6572
|
-
store = new LocalStateStore(function() {
|
|
6573
|
-
updateState(node);
|
|
6574
|
-
});
|
|
6575
|
-
_this.stateStore.set(node, store);
|
|
6576
|
-
}
|
|
6577
|
-
return {
|
|
6578
|
-
useSharedState: function(key) {
|
|
6579
|
-
return store.useSharedState(key);
|
|
6580
|
-
},
|
|
6581
|
-
useLocalState: function(initialState) {
|
|
6582
|
-
return store.getLocalStateFunction(stepKey, countKey)(initialState);
|
|
6583
|
-
}
|
|
6584
|
-
};
|
|
6585
|
-
};
|
|
6586
|
-
resolver.hooks.beforeResolve.tap("asset-transform", function(node, options) {
|
|
6587
|
-
if (node && (node.type === "asset" || node.type === "view")) {
|
|
6588
|
-
var transform = _this.registry.get(node.value);
|
|
6589
|
-
if (transform === null || transform === void 0 ? void 0 : transform.beforeResolve) {
|
|
6590
|
-
var _options_node;
|
|
6591
|
-
var store = getStore((_options_node = options.node) !== null && _options_node !== void 0 ? _options_node : node, _this.beforeResolveSymbol);
|
|
6592
|
-
return transform.beforeResolve(node, options, store);
|
|
6593
|
-
}
|
|
6594
|
-
}
|
|
6595
|
-
return node;
|
|
6596
|
-
});
|
|
6597
|
-
resolver.hooks.afterUpdate.tap("asset-transform", function() {
|
|
6598
|
-
lastUpdatedNode = void 0;
|
|
6599
|
-
});
|
|
6600
|
-
resolver.hooks.skipResolve.tap("asset-transform", function(skip, node) {
|
|
6601
|
-
if (!skip || !lastUpdatedNode) {
|
|
6602
|
-
return skip;
|
|
6603
|
-
}
|
|
6604
|
-
var isParentOfUpdated = findUp(lastUpdatedNode, node);
|
|
6605
|
-
var isChildOfUpdated = findUp(node, lastUpdatedNode);
|
|
6606
|
-
return !isParentOfUpdated && !isChildOfUpdated;
|
|
6607
|
-
});
|
|
6608
|
-
resolver.hooks.afterResolve.tap("asset-transform", function(value, node, options) {
|
|
6609
|
-
if (node.type !== "asset" && node.type !== "view") {
|
|
6610
|
-
return value;
|
|
6611
|
-
}
|
|
6612
|
-
var originalNode = resolver.getSourceNode(node);
|
|
6613
|
-
if (!originalNode) {
|
|
6614
|
-
return value;
|
|
6615
|
-
}
|
|
6616
|
-
var transform = _this.registry.get(value);
|
|
6617
|
-
if (transform === null || transform === void 0 ? void 0 : transform.resolve) {
|
|
6618
|
-
var store = getStore(originalNode, _this.resolveSymbol);
|
|
6619
|
-
return transform === null || transform === void 0 ? void 0 : transform.resolve(value, options, store);
|
|
6620
|
-
}
|
|
6621
|
-
return value;
|
|
6622
|
-
});
|
|
6623
|
-
});
|
|
6624
|
-
});
|
|
6625
|
-
}
|
|
6626
|
-
}
|
|
6627
|
-
]);
|
|
6628
|
-
return AssetTransformCorePlugin;
|
|
6629
|
-
}();
|
|
6630
6628
|
var ViewController = /*#__PURE__*/ function() {
|
|
6631
6629
|
function ViewController(initialViews, options) {
|
|
6632
6630
|
var _this = this;
|
|
@@ -6644,7 +6642,6 @@ var CheckPathPlugin = function() {
|
|
|
6644
6642
|
viewMap[view.id] = view;
|
|
6645
6643
|
return viewMap;
|
|
6646
6644
|
}, {});
|
|
6647
|
-
new AssetTransformCorePlugin(this.transformRegistry).apply(this);
|
|
6648
6645
|
options.flowController.hooks.flow.tap("viewController", function(flow) {
|
|
6649
6646
|
flow.hooks.transition.tap("viewController", function(_oldState, newState) {
|
|
6650
6647
|
if (newState.value.state_type === "VIEW") {
|
|
@@ -7129,6 +7126,7 @@ var CheckPathPlugin = function() {
|
|
|
7129
7126
|
new AssetPlugin().apply(view);
|
|
7130
7127
|
new SwitchPlugin(pluginOptions).apply(view);
|
|
7131
7128
|
new ApplicabilityPlugin().apply(view);
|
|
7129
|
+
new AssetTransformCorePlugin(viewController.transformRegistry).apply(view);
|
|
7132
7130
|
new StringResolverPlugin().apply(view);
|
|
7133
7131
|
var templatePlugin = new TemplatePlugin(pluginOptions);
|
|
7134
7132
|
templatePlugin.apply(view);
|