@player-ui/reference-assets-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.
- package/dist/ReferenceAssetsPlugin.native.js +173 -175
- package/dist/ReferenceAssetsPlugin.native.js.map +1 -1
- package/dist/xlr/ActionAsset.json +2 -2
- package/dist/xlr/ChatMessageAsset.json +1 -1
- package/dist/xlr/ChoiceAsset.json +5 -5
- package/dist/xlr/CollectionAsset.json +1 -1
- package/dist/xlr/ImageAsset.json +2 -2
- package/dist/xlr/InfoAsset.json +1 -1
- package/dist/xlr/InputAsset.json +2 -2
- package/dist/xlr/TextAsset.json +4 -4
- package/package.json +5 -5
|
@@ -5811,6 +5811,178 @@ var ReferenceAssetsPlugin = function() {
|
|
|
5811
5811
|
]);
|
|
5812
5812
|
return AssetPlugin;
|
|
5813
5813
|
}();
|
|
5814
|
+
var LocalStateStore = /*#__PURE__*/ function() {
|
|
5815
|
+
function LocalStateStore(onUpdate) {
|
|
5816
|
+
_class_call_check(this, LocalStateStore);
|
|
5817
|
+
this.updateCallback = onUpdate;
|
|
5818
|
+
this.state = /* @__PURE__ */ new Map();
|
|
5819
|
+
}
|
|
5820
|
+
_create_class(LocalStateStore, [
|
|
5821
|
+
{
|
|
5822
|
+
key: "removeKey",
|
|
5823
|
+
value: function removeKey(key) {
|
|
5824
|
+
this.state.delete(key);
|
|
5825
|
+
}
|
|
5826
|
+
},
|
|
5827
|
+
{
|
|
5828
|
+
key: "reset",
|
|
5829
|
+
value: function reset() {
|
|
5830
|
+
this.state.clear();
|
|
5831
|
+
}
|
|
5832
|
+
},
|
|
5833
|
+
{
|
|
5834
|
+
key: "useSharedState",
|
|
5835
|
+
value: function useSharedState(key) {
|
|
5836
|
+
var _this = this;
|
|
5837
|
+
return function(initialState) {
|
|
5838
|
+
if (!_this.state.has(key)) {
|
|
5839
|
+
_this.state.set(key, initialState);
|
|
5840
|
+
}
|
|
5841
|
+
return [
|
|
5842
|
+
_this.state.get(key),
|
|
5843
|
+
function(newState) {
|
|
5844
|
+
var current = _this.state.get(key);
|
|
5845
|
+
_this.state.set(key, newState);
|
|
5846
|
+
if (current !== newState) {
|
|
5847
|
+
var _this_updateCallback, _this1;
|
|
5848
|
+
(_this_updateCallback = (_this1 = _this).updateCallback) === null || _this_updateCallback === void 0 ? void 0 : _this_updateCallback.call(_this1);
|
|
5849
|
+
}
|
|
5850
|
+
}
|
|
5851
|
+
];
|
|
5852
|
+
};
|
|
5853
|
+
}
|
|
5854
|
+
},
|
|
5855
|
+
{
|
|
5856
|
+
key: "getLocalStateFunction",
|
|
5857
|
+
value: function getLocalStateFunction(key, countKey) {
|
|
5858
|
+
var _this = this;
|
|
5859
|
+
return function(initialState) {
|
|
5860
|
+
if (!_this.state.has(key)) {
|
|
5861
|
+
_this.state.set(key, []);
|
|
5862
|
+
}
|
|
5863
|
+
if (!_this.state.has(countKey)) {
|
|
5864
|
+
_this.state.set(countKey, 0);
|
|
5865
|
+
}
|
|
5866
|
+
var localState = _this.state.get(key);
|
|
5867
|
+
var oldCount = _this.state.get(countKey);
|
|
5868
|
+
_this.state.set(countKey, oldCount + 1);
|
|
5869
|
+
if (localState.length <= oldCount) {
|
|
5870
|
+
localState.push(initialState);
|
|
5871
|
+
}
|
|
5872
|
+
var value = localState[oldCount];
|
|
5873
|
+
return [
|
|
5874
|
+
value,
|
|
5875
|
+
function(newState) {
|
|
5876
|
+
var oldValue = localState[oldCount];
|
|
5877
|
+
localState[oldCount] = newState;
|
|
5878
|
+
if (oldValue !== newState) {
|
|
5879
|
+
var _this_updateCallback, _this1;
|
|
5880
|
+
(_this_updateCallback = (_this1 = _this).updateCallback) === null || _this_updateCallback === void 0 ? void 0 : _this_updateCallback.call(_this1);
|
|
5881
|
+
}
|
|
5882
|
+
}
|
|
5883
|
+
];
|
|
5884
|
+
};
|
|
5885
|
+
}
|
|
5886
|
+
}
|
|
5887
|
+
]);
|
|
5888
|
+
return LocalStateStore;
|
|
5889
|
+
}();
|
|
5890
|
+
function findUp(node, target) {
|
|
5891
|
+
if (node === target) {
|
|
5892
|
+
return true;
|
|
5893
|
+
}
|
|
5894
|
+
if (node.parent) {
|
|
5895
|
+
return findUp(node.parent, target);
|
|
5896
|
+
}
|
|
5897
|
+
return false;
|
|
5898
|
+
}
|
|
5899
|
+
var AssetTransformCorePlugin = /*#__PURE__*/ function() {
|
|
5900
|
+
function AssetTransformCorePlugin(registry) {
|
|
5901
|
+
_class_call_check(this, AssetTransformCorePlugin);
|
|
5902
|
+
this.registry = registry;
|
|
5903
|
+
this.stateStore = /* @__PURE__ */ new Map();
|
|
5904
|
+
this.beforeResolveSymbol = Symbol("before resolve");
|
|
5905
|
+
this.resolveSymbol = Symbol("resolve");
|
|
5906
|
+
this.beforeResolveCountSymbol = Symbol("before resolve count");
|
|
5907
|
+
this.resolveCountSymbol = Symbol("resolve count");
|
|
5908
|
+
}
|
|
5909
|
+
_create_class(AssetTransformCorePlugin, [
|
|
5910
|
+
{
|
|
5911
|
+
key: "apply",
|
|
5912
|
+
value: function apply(view) {
|
|
5913
|
+
var _this = this;
|
|
5914
|
+
this.stateStore.clear();
|
|
5915
|
+
view.hooks.resolver.tap("asset-transform", function(resolver) {
|
|
5916
|
+
var lastUpdatedNode;
|
|
5917
|
+
var updateState = function(node) {
|
|
5918
|
+
lastUpdatedNode = node;
|
|
5919
|
+
view.update(/* @__PURE__ */ new Set());
|
|
5920
|
+
};
|
|
5921
|
+
var getStore = function(node, stepKey) {
|
|
5922
|
+
var store;
|
|
5923
|
+
var countKey = stepKey === _this.resolveSymbol ? _this.resolveCountSymbol : _this.beforeResolveCountSymbol;
|
|
5924
|
+
var storedState = _this.stateStore.get(node);
|
|
5925
|
+
if (storedState) {
|
|
5926
|
+
store = storedState;
|
|
5927
|
+
store.removeKey(countKey);
|
|
5928
|
+
} else {
|
|
5929
|
+
store = new LocalStateStore(function() {
|
|
5930
|
+
updateState(node);
|
|
5931
|
+
});
|
|
5932
|
+
_this.stateStore.set(node, store);
|
|
5933
|
+
}
|
|
5934
|
+
return {
|
|
5935
|
+
useSharedState: function(key) {
|
|
5936
|
+
return store.useSharedState(key);
|
|
5937
|
+
},
|
|
5938
|
+
useLocalState: function(initialState) {
|
|
5939
|
+
return store.getLocalStateFunction(stepKey, countKey)(initialState);
|
|
5940
|
+
}
|
|
5941
|
+
};
|
|
5942
|
+
};
|
|
5943
|
+
resolver.hooks.beforeResolve.tap("asset-transform", function(node, options) {
|
|
5944
|
+
if (node && (node.type === "asset" || node.type === "view")) {
|
|
5945
|
+
var transform3 = _this.registry.get(node.value);
|
|
5946
|
+
if (transform3 === null || transform3 === void 0 ? void 0 : transform3.beforeResolve) {
|
|
5947
|
+
var _options_node;
|
|
5948
|
+
var store = getStore((_options_node = options.node) !== null && _options_node !== void 0 ? _options_node : node, _this.beforeResolveSymbol);
|
|
5949
|
+
return transform3.beforeResolve(node, options, store);
|
|
5950
|
+
}
|
|
5951
|
+
}
|
|
5952
|
+
return node;
|
|
5953
|
+
});
|
|
5954
|
+
resolver.hooks.afterUpdate.tap("asset-transform", function() {
|
|
5955
|
+
lastUpdatedNode = void 0;
|
|
5956
|
+
});
|
|
5957
|
+
resolver.hooks.skipResolve.tap("asset-transform", function(skip, node) {
|
|
5958
|
+
if (!skip || !lastUpdatedNode) {
|
|
5959
|
+
return skip;
|
|
5960
|
+
}
|
|
5961
|
+
var isParentOfUpdated = findUp(lastUpdatedNode, node);
|
|
5962
|
+
var isChildOfUpdated = findUp(node, lastUpdatedNode);
|
|
5963
|
+
return !isParentOfUpdated && !isChildOfUpdated;
|
|
5964
|
+
});
|
|
5965
|
+
resolver.hooks.afterResolve.tap("asset-transform", function(value, node, options) {
|
|
5966
|
+
if (node.type !== "asset" && node.type !== "view") {
|
|
5967
|
+
return value;
|
|
5968
|
+
}
|
|
5969
|
+
var originalNode = resolver.getSourceNode(node);
|
|
5970
|
+
if (!originalNode) {
|
|
5971
|
+
return value;
|
|
5972
|
+
}
|
|
5973
|
+
var transform3 = _this.registry.get(value);
|
|
5974
|
+
if (transform3 === null || transform3 === void 0 ? void 0 : transform3.resolve) {
|
|
5975
|
+
var store = getStore(originalNode, _this.resolveSymbol);
|
|
5976
|
+
return transform3 === null || transform3 === void 0 ? void 0 : transform3.resolve(value, options, store);
|
|
5977
|
+
}
|
|
5978
|
+
return value;
|
|
5979
|
+
});
|
|
5980
|
+
});
|
|
5981
|
+
}
|
|
5982
|
+
}
|
|
5983
|
+
]);
|
|
5984
|
+
return AssetTransformCorePlugin;
|
|
5985
|
+
}();
|
|
5814
5986
|
var FlowInstance = /*#__PURE__*/ function() {
|
|
5815
5987
|
function FlowInstance(id, flow, options) {
|
|
5816
5988
|
_class_call_check(this, FlowInstance);
|
|
@@ -6840,180 +7012,6 @@ var ReferenceAssetsPlugin = function() {
|
|
|
6840
7012
|
]);
|
|
6841
7013
|
return ValidationController;
|
|
6842
7014
|
}();
|
|
6843
|
-
var LocalStateStore = /*#__PURE__*/ function() {
|
|
6844
|
-
function LocalStateStore(onUpdate) {
|
|
6845
|
-
_class_call_check(this, LocalStateStore);
|
|
6846
|
-
this.updateCallback = onUpdate;
|
|
6847
|
-
this.state = /* @__PURE__ */ new Map();
|
|
6848
|
-
}
|
|
6849
|
-
_create_class(LocalStateStore, [
|
|
6850
|
-
{
|
|
6851
|
-
key: "removeKey",
|
|
6852
|
-
value: function removeKey(key) {
|
|
6853
|
-
this.state.delete(key);
|
|
6854
|
-
}
|
|
6855
|
-
},
|
|
6856
|
-
{
|
|
6857
|
-
key: "reset",
|
|
6858
|
-
value: function reset() {
|
|
6859
|
-
this.state.clear();
|
|
6860
|
-
}
|
|
6861
|
-
},
|
|
6862
|
-
{
|
|
6863
|
-
key: "useSharedState",
|
|
6864
|
-
value: function useSharedState(key) {
|
|
6865
|
-
var _this = this;
|
|
6866
|
-
return function(initialState) {
|
|
6867
|
-
if (!_this.state.has(key)) {
|
|
6868
|
-
_this.state.set(key, initialState);
|
|
6869
|
-
}
|
|
6870
|
-
return [
|
|
6871
|
-
_this.state.get(key),
|
|
6872
|
-
function(newState) {
|
|
6873
|
-
var current = _this.state.get(key);
|
|
6874
|
-
_this.state.set(key, newState);
|
|
6875
|
-
if (current !== newState) {
|
|
6876
|
-
var _this_updateCallback, _this1;
|
|
6877
|
-
(_this_updateCallback = (_this1 = _this).updateCallback) === null || _this_updateCallback === void 0 ? void 0 : _this_updateCallback.call(_this1);
|
|
6878
|
-
}
|
|
6879
|
-
}
|
|
6880
|
-
];
|
|
6881
|
-
};
|
|
6882
|
-
}
|
|
6883
|
-
},
|
|
6884
|
-
{
|
|
6885
|
-
key: "getLocalStateFunction",
|
|
6886
|
-
value: function getLocalStateFunction(key, countKey) {
|
|
6887
|
-
var _this = this;
|
|
6888
|
-
return function(initialState) {
|
|
6889
|
-
if (!_this.state.has(key)) {
|
|
6890
|
-
_this.state.set(key, []);
|
|
6891
|
-
}
|
|
6892
|
-
if (!_this.state.has(countKey)) {
|
|
6893
|
-
_this.state.set(countKey, 0);
|
|
6894
|
-
}
|
|
6895
|
-
var localState = _this.state.get(key);
|
|
6896
|
-
var oldCount = _this.state.get(countKey);
|
|
6897
|
-
_this.state.set(countKey, oldCount + 1);
|
|
6898
|
-
if (localState.length <= oldCount) {
|
|
6899
|
-
localState.push(initialState);
|
|
6900
|
-
}
|
|
6901
|
-
var value = localState[oldCount];
|
|
6902
|
-
return [
|
|
6903
|
-
value,
|
|
6904
|
-
function(newState) {
|
|
6905
|
-
var oldValue = localState[oldCount];
|
|
6906
|
-
localState[oldCount] = newState;
|
|
6907
|
-
if (oldValue !== newState) {
|
|
6908
|
-
var _this_updateCallback, _this1;
|
|
6909
|
-
(_this_updateCallback = (_this1 = _this).updateCallback) === null || _this_updateCallback === void 0 ? void 0 : _this_updateCallback.call(_this1);
|
|
6910
|
-
}
|
|
6911
|
-
}
|
|
6912
|
-
];
|
|
6913
|
-
};
|
|
6914
|
-
}
|
|
6915
|
-
}
|
|
6916
|
-
]);
|
|
6917
|
-
return LocalStateStore;
|
|
6918
|
-
}();
|
|
6919
|
-
function findUp(node, target) {
|
|
6920
|
-
if (node === target) {
|
|
6921
|
-
return true;
|
|
6922
|
-
}
|
|
6923
|
-
if (node.parent) {
|
|
6924
|
-
return findUp(node.parent, target);
|
|
6925
|
-
}
|
|
6926
|
-
return false;
|
|
6927
|
-
}
|
|
6928
|
-
var AssetTransformCorePlugin = /*#__PURE__*/ function() {
|
|
6929
|
-
function AssetTransformCorePlugin(registry) {
|
|
6930
|
-
_class_call_check(this, AssetTransformCorePlugin);
|
|
6931
|
-
this.registry = registry;
|
|
6932
|
-
this.stateStore = /* @__PURE__ */ new Map();
|
|
6933
|
-
this.beforeResolveSymbol = Symbol("before resolve");
|
|
6934
|
-
this.resolveSymbol = Symbol("resolve");
|
|
6935
|
-
this.beforeResolveCountSymbol = Symbol("before resolve count");
|
|
6936
|
-
this.resolveCountSymbol = Symbol("resolve count");
|
|
6937
|
-
}
|
|
6938
|
-
_create_class(AssetTransformCorePlugin, [
|
|
6939
|
-
{
|
|
6940
|
-
key: "apply",
|
|
6941
|
-
value: function apply(viewController) {
|
|
6942
|
-
var _this = this;
|
|
6943
|
-
viewController.hooks.view.tap("asset-transform", function(view) {
|
|
6944
|
-
_this.stateStore.clear();
|
|
6945
|
-
view.hooks.resolver.tap("asset-transform", function(resolver) {
|
|
6946
|
-
var lastUpdatedNode;
|
|
6947
|
-
var updateState = function(node) {
|
|
6948
|
-
lastUpdatedNode = node;
|
|
6949
|
-
view.update(/* @__PURE__ */ new Set());
|
|
6950
|
-
};
|
|
6951
|
-
var getStore = function(node, stepKey) {
|
|
6952
|
-
var store;
|
|
6953
|
-
var countKey = stepKey === _this.resolveSymbol ? _this.resolveCountSymbol : _this.beforeResolveCountSymbol;
|
|
6954
|
-
var storedState = _this.stateStore.get(node);
|
|
6955
|
-
if (storedState) {
|
|
6956
|
-
store = storedState;
|
|
6957
|
-
store.removeKey(countKey);
|
|
6958
|
-
} else {
|
|
6959
|
-
store = new LocalStateStore(function() {
|
|
6960
|
-
updateState(node);
|
|
6961
|
-
});
|
|
6962
|
-
_this.stateStore.set(node, store);
|
|
6963
|
-
}
|
|
6964
|
-
return {
|
|
6965
|
-
useSharedState: function(key) {
|
|
6966
|
-
return store.useSharedState(key);
|
|
6967
|
-
},
|
|
6968
|
-
useLocalState: function(initialState) {
|
|
6969
|
-
return store.getLocalStateFunction(stepKey, countKey)(initialState);
|
|
6970
|
-
}
|
|
6971
|
-
};
|
|
6972
|
-
};
|
|
6973
|
-
resolver.hooks.beforeResolve.tap("asset-transform", function(node, options) {
|
|
6974
|
-
if (node && (node.type === "asset" || node.type === "view")) {
|
|
6975
|
-
var transform3 = _this.registry.get(node.value);
|
|
6976
|
-
if (transform3 === null || transform3 === void 0 ? void 0 : transform3.beforeResolve) {
|
|
6977
|
-
var _options_node;
|
|
6978
|
-
var store = getStore((_options_node = options.node) !== null && _options_node !== void 0 ? _options_node : node, _this.beforeResolveSymbol);
|
|
6979
|
-
return transform3.beforeResolve(node, options, store);
|
|
6980
|
-
}
|
|
6981
|
-
}
|
|
6982
|
-
return node;
|
|
6983
|
-
});
|
|
6984
|
-
resolver.hooks.afterUpdate.tap("asset-transform", function() {
|
|
6985
|
-
lastUpdatedNode = void 0;
|
|
6986
|
-
});
|
|
6987
|
-
resolver.hooks.skipResolve.tap("asset-transform", function(skip, node) {
|
|
6988
|
-
if (!skip || !lastUpdatedNode) {
|
|
6989
|
-
return skip;
|
|
6990
|
-
}
|
|
6991
|
-
var isParentOfUpdated = findUp(lastUpdatedNode, node);
|
|
6992
|
-
var isChildOfUpdated = findUp(node, lastUpdatedNode);
|
|
6993
|
-
return !isParentOfUpdated && !isChildOfUpdated;
|
|
6994
|
-
});
|
|
6995
|
-
resolver.hooks.afterResolve.tap("asset-transform", function(value, node, options) {
|
|
6996
|
-
if (node.type !== "asset" && node.type !== "view") {
|
|
6997
|
-
return value;
|
|
6998
|
-
}
|
|
6999
|
-
var originalNode = resolver.getSourceNode(node);
|
|
7000
|
-
if (!originalNode) {
|
|
7001
|
-
return value;
|
|
7002
|
-
}
|
|
7003
|
-
var transform3 = _this.registry.get(value);
|
|
7004
|
-
if (transform3 === null || transform3 === void 0 ? void 0 : transform3.resolve) {
|
|
7005
|
-
var store = getStore(originalNode, _this.resolveSymbol);
|
|
7006
|
-
return transform3 === null || transform3 === void 0 ? void 0 : transform3.resolve(value, options, store);
|
|
7007
|
-
}
|
|
7008
|
-
return value;
|
|
7009
|
-
});
|
|
7010
|
-
});
|
|
7011
|
-
});
|
|
7012
|
-
}
|
|
7013
|
-
}
|
|
7014
|
-
]);
|
|
7015
|
-
return AssetTransformCorePlugin;
|
|
7016
|
-
}();
|
|
7017
7015
|
var ViewController = /*#__PURE__*/ function() {
|
|
7018
7016
|
function ViewController(initialViews, options) {
|
|
7019
7017
|
var _this = this;
|
|
@@ -7031,7 +7029,6 @@ var ReferenceAssetsPlugin = function() {
|
|
|
7031
7029
|
viewMap[view.id] = view;
|
|
7032
7030
|
return viewMap;
|
|
7033
7031
|
}, {});
|
|
7034
|
-
new AssetTransformCorePlugin(this.transformRegistry).apply(this);
|
|
7035
7032
|
options.flowController.hooks.flow.tap("viewController", function(flow) {
|
|
7036
7033
|
flow.hooks.transition.tap("viewController", function(_oldState, newState) {
|
|
7037
7034
|
if (newState.value.state_type === "VIEW") {
|
|
@@ -7516,6 +7513,7 @@ var ReferenceAssetsPlugin = function() {
|
|
|
7516
7513
|
new AssetPlugin().apply(view);
|
|
7517
7514
|
new SwitchPlugin(pluginOptions).apply(view);
|
|
7518
7515
|
new ApplicabilityPlugin().apply(view);
|
|
7516
|
+
new AssetTransformCorePlugin(viewController.transformRegistry).apply(view);
|
|
7519
7517
|
new StringResolverPlugin().apply(view);
|
|
7520
7518
|
var templatePlugin = new TemplatePlugin(pluginOptions);
|
|
7521
7519
|
templatePlugin.apply(view);
|