@player-ui/markdown-plugin 0.12.0-next.0 → 0.12.0-next.10
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.
|
@@ -9721,6 +9721,178 @@ var MarkdownPlugin = function() {
|
|
|
9721
9721
|
]);
|
|
9722
9722
|
return AssetPlugin;
|
|
9723
9723
|
}();
|
|
9724
|
+
var LocalStateStore = /*#__PURE__*/ function() {
|
|
9725
|
+
function LocalStateStore(onUpdate) {
|
|
9726
|
+
_class_call_check(this, LocalStateStore);
|
|
9727
|
+
this.updateCallback = onUpdate;
|
|
9728
|
+
this.state = /* @__PURE__ */ new Map();
|
|
9729
|
+
}
|
|
9730
|
+
_create_class(LocalStateStore, [
|
|
9731
|
+
{
|
|
9732
|
+
key: "removeKey",
|
|
9733
|
+
value: function removeKey(key) {
|
|
9734
|
+
this.state.delete(key);
|
|
9735
|
+
}
|
|
9736
|
+
},
|
|
9737
|
+
{
|
|
9738
|
+
key: "reset",
|
|
9739
|
+
value: function reset() {
|
|
9740
|
+
this.state.clear();
|
|
9741
|
+
}
|
|
9742
|
+
},
|
|
9743
|
+
{
|
|
9744
|
+
key: "useSharedState",
|
|
9745
|
+
value: function useSharedState(key) {
|
|
9746
|
+
var _this = this;
|
|
9747
|
+
return function(initialState) {
|
|
9748
|
+
if (!_this.state.has(key)) {
|
|
9749
|
+
_this.state.set(key, initialState);
|
|
9750
|
+
}
|
|
9751
|
+
return [
|
|
9752
|
+
_this.state.get(key),
|
|
9753
|
+
function(newState) {
|
|
9754
|
+
var current = _this.state.get(key);
|
|
9755
|
+
_this.state.set(key, newState);
|
|
9756
|
+
if (current !== newState) {
|
|
9757
|
+
var _this_updateCallback, _this1;
|
|
9758
|
+
(_this_updateCallback = (_this1 = _this).updateCallback) === null || _this_updateCallback === void 0 ? void 0 : _this_updateCallback.call(_this1);
|
|
9759
|
+
}
|
|
9760
|
+
}
|
|
9761
|
+
];
|
|
9762
|
+
};
|
|
9763
|
+
}
|
|
9764
|
+
},
|
|
9765
|
+
{
|
|
9766
|
+
key: "getLocalStateFunction",
|
|
9767
|
+
value: function getLocalStateFunction(key, countKey) {
|
|
9768
|
+
var _this = this;
|
|
9769
|
+
return function(initialState) {
|
|
9770
|
+
if (!_this.state.has(key)) {
|
|
9771
|
+
_this.state.set(key, []);
|
|
9772
|
+
}
|
|
9773
|
+
if (!_this.state.has(countKey)) {
|
|
9774
|
+
_this.state.set(countKey, 0);
|
|
9775
|
+
}
|
|
9776
|
+
var localState = _this.state.get(key);
|
|
9777
|
+
var oldCount = _this.state.get(countKey);
|
|
9778
|
+
_this.state.set(countKey, oldCount + 1);
|
|
9779
|
+
if (localState.length <= oldCount) {
|
|
9780
|
+
localState.push(initialState);
|
|
9781
|
+
}
|
|
9782
|
+
var value = localState[oldCount];
|
|
9783
|
+
return [
|
|
9784
|
+
value,
|
|
9785
|
+
function(newState) {
|
|
9786
|
+
var oldValue = localState[oldCount];
|
|
9787
|
+
localState[oldCount] = newState;
|
|
9788
|
+
if (oldValue !== newState) {
|
|
9789
|
+
var _this_updateCallback, _this1;
|
|
9790
|
+
(_this_updateCallback = (_this1 = _this).updateCallback) === null || _this_updateCallback === void 0 ? void 0 : _this_updateCallback.call(_this1);
|
|
9791
|
+
}
|
|
9792
|
+
}
|
|
9793
|
+
];
|
|
9794
|
+
};
|
|
9795
|
+
}
|
|
9796
|
+
}
|
|
9797
|
+
]);
|
|
9798
|
+
return LocalStateStore;
|
|
9799
|
+
}();
|
|
9800
|
+
function findUp(node2, target) {
|
|
9801
|
+
if (node2 === target) {
|
|
9802
|
+
return true;
|
|
9803
|
+
}
|
|
9804
|
+
if (node2.parent) {
|
|
9805
|
+
return findUp(node2.parent, target);
|
|
9806
|
+
}
|
|
9807
|
+
return false;
|
|
9808
|
+
}
|
|
9809
|
+
var AssetTransformCorePlugin = /*#__PURE__*/ function() {
|
|
9810
|
+
function AssetTransformCorePlugin(registry) {
|
|
9811
|
+
_class_call_check(this, AssetTransformCorePlugin);
|
|
9812
|
+
this.registry = registry;
|
|
9813
|
+
this.stateStore = /* @__PURE__ */ new Map();
|
|
9814
|
+
this.beforeResolveSymbol = Symbol("before resolve");
|
|
9815
|
+
this.resolveSymbol = Symbol("resolve");
|
|
9816
|
+
this.beforeResolveCountSymbol = Symbol("before resolve count");
|
|
9817
|
+
this.resolveCountSymbol = Symbol("resolve count");
|
|
9818
|
+
}
|
|
9819
|
+
_create_class(AssetTransformCorePlugin, [
|
|
9820
|
+
{
|
|
9821
|
+
key: "apply",
|
|
9822
|
+
value: function apply(view) {
|
|
9823
|
+
var _this = this;
|
|
9824
|
+
this.stateStore.clear();
|
|
9825
|
+
view.hooks.resolver.tap("asset-transform", function(resolver2) {
|
|
9826
|
+
var lastUpdatedNode;
|
|
9827
|
+
var updateState = function(node2) {
|
|
9828
|
+
lastUpdatedNode = node2;
|
|
9829
|
+
view.update(/* @__PURE__ */ new Set());
|
|
9830
|
+
};
|
|
9831
|
+
var getStore = function(node2, stepKey) {
|
|
9832
|
+
var store;
|
|
9833
|
+
var countKey = stepKey === _this.resolveSymbol ? _this.resolveCountSymbol : _this.beforeResolveCountSymbol;
|
|
9834
|
+
var storedState = _this.stateStore.get(node2);
|
|
9835
|
+
if (storedState) {
|
|
9836
|
+
store = storedState;
|
|
9837
|
+
store.removeKey(countKey);
|
|
9838
|
+
} else {
|
|
9839
|
+
store = new LocalStateStore(function() {
|
|
9840
|
+
updateState(node2);
|
|
9841
|
+
});
|
|
9842
|
+
_this.stateStore.set(node2, store);
|
|
9843
|
+
}
|
|
9844
|
+
return {
|
|
9845
|
+
useSharedState: function(key) {
|
|
9846
|
+
return store.useSharedState(key);
|
|
9847
|
+
},
|
|
9848
|
+
useLocalState: function(initialState) {
|
|
9849
|
+
return store.getLocalStateFunction(stepKey, countKey)(initialState);
|
|
9850
|
+
}
|
|
9851
|
+
};
|
|
9852
|
+
};
|
|
9853
|
+
resolver2.hooks.beforeResolve.tap("asset-transform", function(node2, options) {
|
|
9854
|
+
if (node2 && (node2.type === "asset" || node2.type === "view")) {
|
|
9855
|
+
var transform = _this.registry.get(node2.value);
|
|
9856
|
+
if (transform === null || transform === void 0 ? void 0 : transform.beforeResolve) {
|
|
9857
|
+
var _options_node;
|
|
9858
|
+
var store = getStore((_options_node = options.node) !== null && _options_node !== void 0 ? _options_node : node2, _this.beforeResolveSymbol);
|
|
9859
|
+
return transform.beforeResolve(node2, options, store);
|
|
9860
|
+
}
|
|
9861
|
+
}
|
|
9862
|
+
return node2;
|
|
9863
|
+
});
|
|
9864
|
+
resolver2.hooks.afterUpdate.tap("asset-transform", function() {
|
|
9865
|
+
lastUpdatedNode = void 0;
|
|
9866
|
+
});
|
|
9867
|
+
resolver2.hooks.skipResolve.tap("asset-transform", function(skip, node2) {
|
|
9868
|
+
if (!skip || !lastUpdatedNode) {
|
|
9869
|
+
return skip;
|
|
9870
|
+
}
|
|
9871
|
+
var isParentOfUpdated = findUp(lastUpdatedNode, node2);
|
|
9872
|
+
var isChildOfUpdated = findUp(node2, lastUpdatedNode);
|
|
9873
|
+
return !isParentOfUpdated && !isChildOfUpdated;
|
|
9874
|
+
});
|
|
9875
|
+
resolver2.hooks.afterResolve.tap("asset-transform", function(value, node2, options) {
|
|
9876
|
+
if (node2.type !== "asset" && node2.type !== "view") {
|
|
9877
|
+
return value;
|
|
9878
|
+
}
|
|
9879
|
+
var originalNode = resolver2.getSourceNode(node2);
|
|
9880
|
+
if (!originalNode) {
|
|
9881
|
+
return value;
|
|
9882
|
+
}
|
|
9883
|
+
var transform = _this.registry.get(value);
|
|
9884
|
+
if (transform === null || transform === void 0 ? void 0 : transform.resolve) {
|
|
9885
|
+
var store = getStore(originalNode, _this.resolveSymbol);
|
|
9886
|
+
return transform === null || transform === void 0 ? void 0 : transform.resolve(value, options, store);
|
|
9887
|
+
}
|
|
9888
|
+
return value;
|
|
9889
|
+
});
|
|
9890
|
+
});
|
|
9891
|
+
}
|
|
9892
|
+
}
|
|
9893
|
+
]);
|
|
9894
|
+
return AssetTransformCorePlugin;
|
|
9895
|
+
}();
|
|
9724
9896
|
var FlowInstance = /*#__PURE__*/ function() {
|
|
9725
9897
|
function FlowInstance(id, flow3, options) {
|
|
9726
9898
|
_class_call_check(this, FlowInstance);
|
|
@@ -10750,180 +10922,6 @@ var MarkdownPlugin = function() {
|
|
|
10750
10922
|
]);
|
|
10751
10923
|
return ValidationController;
|
|
10752
10924
|
}();
|
|
10753
|
-
var LocalStateStore = /*#__PURE__*/ function() {
|
|
10754
|
-
function LocalStateStore(onUpdate) {
|
|
10755
|
-
_class_call_check(this, LocalStateStore);
|
|
10756
|
-
this.updateCallback = onUpdate;
|
|
10757
|
-
this.state = /* @__PURE__ */ new Map();
|
|
10758
|
-
}
|
|
10759
|
-
_create_class(LocalStateStore, [
|
|
10760
|
-
{
|
|
10761
|
-
key: "removeKey",
|
|
10762
|
-
value: function removeKey(key) {
|
|
10763
|
-
this.state.delete(key);
|
|
10764
|
-
}
|
|
10765
|
-
},
|
|
10766
|
-
{
|
|
10767
|
-
key: "reset",
|
|
10768
|
-
value: function reset() {
|
|
10769
|
-
this.state.clear();
|
|
10770
|
-
}
|
|
10771
|
-
},
|
|
10772
|
-
{
|
|
10773
|
-
key: "useSharedState",
|
|
10774
|
-
value: function useSharedState(key) {
|
|
10775
|
-
var _this = this;
|
|
10776
|
-
return function(initialState) {
|
|
10777
|
-
if (!_this.state.has(key)) {
|
|
10778
|
-
_this.state.set(key, initialState);
|
|
10779
|
-
}
|
|
10780
|
-
return [
|
|
10781
|
-
_this.state.get(key),
|
|
10782
|
-
function(newState) {
|
|
10783
|
-
var current = _this.state.get(key);
|
|
10784
|
-
_this.state.set(key, newState);
|
|
10785
|
-
if (current !== newState) {
|
|
10786
|
-
var _this_updateCallback, _this1;
|
|
10787
|
-
(_this_updateCallback = (_this1 = _this).updateCallback) === null || _this_updateCallback === void 0 ? void 0 : _this_updateCallback.call(_this1);
|
|
10788
|
-
}
|
|
10789
|
-
}
|
|
10790
|
-
];
|
|
10791
|
-
};
|
|
10792
|
-
}
|
|
10793
|
-
},
|
|
10794
|
-
{
|
|
10795
|
-
key: "getLocalStateFunction",
|
|
10796
|
-
value: function getLocalStateFunction(key, countKey) {
|
|
10797
|
-
var _this = this;
|
|
10798
|
-
return function(initialState) {
|
|
10799
|
-
if (!_this.state.has(key)) {
|
|
10800
|
-
_this.state.set(key, []);
|
|
10801
|
-
}
|
|
10802
|
-
if (!_this.state.has(countKey)) {
|
|
10803
|
-
_this.state.set(countKey, 0);
|
|
10804
|
-
}
|
|
10805
|
-
var localState = _this.state.get(key);
|
|
10806
|
-
var oldCount = _this.state.get(countKey);
|
|
10807
|
-
_this.state.set(countKey, oldCount + 1);
|
|
10808
|
-
if (localState.length <= oldCount) {
|
|
10809
|
-
localState.push(initialState);
|
|
10810
|
-
}
|
|
10811
|
-
var value = localState[oldCount];
|
|
10812
|
-
return [
|
|
10813
|
-
value,
|
|
10814
|
-
function(newState) {
|
|
10815
|
-
var oldValue = localState[oldCount];
|
|
10816
|
-
localState[oldCount] = newState;
|
|
10817
|
-
if (oldValue !== newState) {
|
|
10818
|
-
var _this_updateCallback, _this1;
|
|
10819
|
-
(_this_updateCallback = (_this1 = _this).updateCallback) === null || _this_updateCallback === void 0 ? void 0 : _this_updateCallback.call(_this1);
|
|
10820
|
-
}
|
|
10821
|
-
}
|
|
10822
|
-
];
|
|
10823
|
-
};
|
|
10824
|
-
}
|
|
10825
|
-
}
|
|
10826
|
-
]);
|
|
10827
|
-
return LocalStateStore;
|
|
10828
|
-
}();
|
|
10829
|
-
function findUp(node2, target) {
|
|
10830
|
-
if (node2 === target) {
|
|
10831
|
-
return true;
|
|
10832
|
-
}
|
|
10833
|
-
if (node2.parent) {
|
|
10834
|
-
return findUp(node2.parent, target);
|
|
10835
|
-
}
|
|
10836
|
-
return false;
|
|
10837
|
-
}
|
|
10838
|
-
var AssetTransformCorePlugin = /*#__PURE__*/ function() {
|
|
10839
|
-
function AssetTransformCorePlugin(registry) {
|
|
10840
|
-
_class_call_check(this, AssetTransformCorePlugin);
|
|
10841
|
-
this.registry = registry;
|
|
10842
|
-
this.stateStore = /* @__PURE__ */ new Map();
|
|
10843
|
-
this.beforeResolveSymbol = Symbol("before resolve");
|
|
10844
|
-
this.resolveSymbol = Symbol("resolve");
|
|
10845
|
-
this.beforeResolveCountSymbol = Symbol("before resolve count");
|
|
10846
|
-
this.resolveCountSymbol = Symbol("resolve count");
|
|
10847
|
-
}
|
|
10848
|
-
_create_class(AssetTransformCorePlugin, [
|
|
10849
|
-
{
|
|
10850
|
-
key: "apply",
|
|
10851
|
-
value: function apply(viewController) {
|
|
10852
|
-
var _this = this;
|
|
10853
|
-
viewController.hooks.view.tap("asset-transform", function(view) {
|
|
10854
|
-
_this.stateStore.clear();
|
|
10855
|
-
view.hooks.resolver.tap("asset-transform", function(resolver2) {
|
|
10856
|
-
var lastUpdatedNode;
|
|
10857
|
-
var updateState = function(node2) {
|
|
10858
|
-
lastUpdatedNode = node2;
|
|
10859
|
-
view.update(/* @__PURE__ */ new Set());
|
|
10860
|
-
};
|
|
10861
|
-
var getStore = function(node2, stepKey) {
|
|
10862
|
-
var store;
|
|
10863
|
-
var countKey = stepKey === _this.resolveSymbol ? _this.resolveCountSymbol : _this.beforeResolveCountSymbol;
|
|
10864
|
-
var storedState = _this.stateStore.get(node2);
|
|
10865
|
-
if (storedState) {
|
|
10866
|
-
store = storedState;
|
|
10867
|
-
store.removeKey(countKey);
|
|
10868
|
-
} else {
|
|
10869
|
-
store = new LocalStateStore(function() {
|
|
10870
|
-
updateState(node2);
|
|
10871
|
-
});
|
|
10872
|
-
_this.stateStore.set(node2, store);
|
|
10873
|
-
}
|
|
10874
|
-
return {
|
|
10875
|
-
useSharedState: function(key) {
|
|
10876
|
-
return store.useSharedState(key);
|
|
10877
|
-
},
|
|
10878
|
-
useLocalState: function(initialState) {
|
|
10879
|
-
return store.getLocalStateFunction(stepKey, countKey)(initialState);
|
|
10880
|
-
}
|
|
10881
|
-
};
|
|
10882
|
-
};
|
|
10883
|
-
resolver2.hooks.beforeResolve.tap("asset-transform", function(node2, options) {
|
|
10884
|
-
if (node2 && (node2.type === "asset" || node2.type === "view")) {
|
|
10885
|
-
var transform = _this.registry.get(node2.value);
|
|
10886
|
-
if (transform === null || transform === void 0 ? void 0 : transform.beforeResolve) {
|
|
10887
|
-
var _options_node;
|
|
10888
|
-
var store = getStore((_options_node = options.node) !== null && _options_node !== void 0 ? _options_node : node2, _this.beforeResolveSymbol);
|
|
10889
|
-
return transform.beforeResolve(node2, options, store);
|
|
10890
|
-
}
|
|
10891
|
-
}
|
|
10892
|
-
return node2;
|
|
10893
|
-
});
|
|
10894
|
-
resolver2.hooks.afterUpdate.tap("asset-transform", function() {
|
|
10895
|
-
lastUpdatedNode = void 0;
|
|
10896
|
-
});
|
|
10897
|
-
resolver2.hooks.skipResolve.tap("asset-transform", function(skip, node2) {
|
|
10898
|
-
if (!skip || !lastUpdatedNode) {
|
|
10899
|
-
return skip;
|
|
10900
|
-
}
|
|
10901
|
-
var isParentOfUpdated = findUp(lastUpdatedNode, node2);
|
|
10902
|
-
var isChildOfUpdated = findUp(node2, lastUpdatedNode);
|
|
10903
|
-
return !isParentOfUpdated && !isChildOfUpdated;
|
|
10904
|
-
});
|
|
10905
|
-
resolver2.hooks.afterResolve.tap("asset-transform", function(value, node2, options) {
|
|
10906
|
-
if (node2.type !== "asset" && node2.type !== "view") {
|
|
10907
|
-
return value;
|
|
10908
|
-
}
|
|
10909
|
-
var originalNode = resolver2.getSourceNode(node2);
|
|
10910
|
-
if (!originalNode) {
|
|
10911
|
-
return value;
|
|
10912
|
-
}
|
|
10913
|
-
var transform = _this.registry.get(value);
|
|
10914
|
-
if (transform === null || transform === void 0 ? void 0 : transform.resolve) {
|
|
10915
|
-
var store = getStore(originalNode, _this.resolveSymbol);
|
|
10916
|
-
return transform === null || transform === void 0 ? void 0 : transform.resolve(value, options, store);
|
|
10917
|
-
}
|
|
10918
|
-
return value;
|
|
10919
|
-
});
|
|
10920
|
-
});
|
|
10921
|
-
});
|
|
10922
|
-
}
|
|
10923
|
-
}
|
|
10924
|
-
]);
|
|
10925
|
-
return AssetTransformCorePlugin;
|
|
10926
|
-
}();
|
|
10927
10925
|
var ViewController = /*#__PURE__*/ function() {
|
|
10928
10926
|
function ViewController(initialViews, options) {
|
|
10929
10927
|
var _this = this;
|
|
@@ -10941,7 +10939,6 @@ var MarkdownPlugin = function() {
|
|
|
10941
10939
|
viewMap[view.id] = view;
|
|
10942
10940
|
return viewMap;
|
|
10943
10941
|
}, {});
|
|
10944
|
-
new AssetTransformCorePlugin(this.transformRegistry).apply(this);
|
|
10945
10942
|
options.flowController.hooks.flow.tap("viewController", function(flow3) {
|
|
10946
10943
|
flow3.hooks.transition.tap("viewController", function(_oldState, newState) {
|
|
10947
10944
|
if (newState.value.state_type === "VIEW") {
|
|
@@ -11426,6 +11423,7 @@ var MarkdownPlugin = function() {
|
|
|
11426
11423
|
new AssetPlugin().apply(view);
|
|
11427
11424
|
new SwitchPlugin(pluginOptions).apply(view);
|
|
11428
11425
|
new ApplicabilityPlugin().apply(view);
|
|
11426
|
+
new AssetTransformCorePlugin(viewController.transformRegistry).apply(view);
|
|
11429
11427
|
new StringResolverPlugin().apply(view);
|
|
11430
11428
|
var templatePlugin = new TemplatePlugin(pluginOptions);
|
|
11431
11429
|
templatePlugin.apply(view);
|
|
@@ -11701,9 +11699,11 @@ var MarkdownPlugin = function() {
|
|
|
11701
11699
|
}),
|
|
11702
11700
|
constants: this.constantsController
|
|
11703
11701
|
});
|
|
11704
|
-
|
|
11705
|
-
|
|
11706
|
-
|
|
11702
|
+
this.hooks.viewController.tap("player", function(vc) {
|
|
11703
|
+
vc.hooks.view.tap("player", function(view) {
|
|
11704
|
+
validationController.onView(view);
|
|
11705
|
+
_this.hooks.view.call(view);
|
|
11706
|
+
});
|
|
11707
11707
|
});
|
|
11708
11708
|
this.hooks.viewController.call(viewController);
|
|
11709
11709
|
return {
|