@player-ui/player 0.12.0-next.4 → 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/Player.native.js +175 -177
- package/dist/Player.native.js.map +1 -1
- package/dist/cjs/index.cjs +159 -159
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.legacy-esm.js +159 -159
- package/dist/index.mjs +159 -159
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/controllers/view/controller.ts +0 -3
- package/src/controllers/view/index.ts +0 -1
- package/src/plugins/default-view-plugin.ts +4 -0
- package/src/view/plugins/asset-transform.ts +146 -0
- package/src/view/plugins/index.ts +1 -0
- package/types/controllers/view/index.d.ts +0 -1
- package/types/{controllers/view → view/plugins}/asset-transform.d.ts +5 -6
- package/types/view/plugins/index.d.ts +1 -0
- package/src/controllers/view/asset-transform.ts +0 -149
package/dist/Player.native.js
CHANGED
|
@@ -5853,6 +5853,180 @@ var Player = function() {
|
|
|
5853
5853
|
]);
|
|
5854
5854
|
return AssetPlugin;
|
|
5855
5855
|
}();
|
|
5856
|
+
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/controllers/view/store.ts
|
|
5857
|
+
var LocalStateStore = /*#__PURE__*/ function() {
|
|
5858
|
+
function LocalStateStore(onUpdate) {
|
|
5859
|
+
_class_call_check(this, LocalStateStore);
|
|
5860
|
+
this.updateCallback = onUpdate;
|
|
5861
|
+
this.state = /* @__PURE__ */ new Map();
|
|
5862
|
+
}
|
|
5863
|
+
_create_class(LocalStateStore, [
|
|
5864
|
+
{
|
|
5865
|
+
key: "removeKey",
|
|
5866
|
+
value: function removeKey(key) {
|
|
5867
|
+
this.state.delete(key);
|
|
5868
|
+
}
|
|
5869
|
+
},
|
|
5870
|
+
{
|
|
5871
|
+
key: "reset",
|
|
5872
|
+
value: function reset() {
|
|
5873
|
+
this.state.clear();
|
|
5874
|
+
}
|
|
5875
|
+
},
|
|
5876
|
+
{
|
|
5877
|
+
key: "useSharedState",
|
|
5878
|
+
value: function useSharedState(key) {
|
|
5879
|
+
var _this = this;
|
|
5880
|
+
return function(initialState) {
|
|
5881
|
+
if (!_this.state.has(key)) {
|
|
5882
|
+
_this.state.set(key, initialState);
|
|
5883
|
+
}
|
|
5884
|
+
return [
|
|
5885
|
+
_this.state.get(key),
|
|
5886
|
+
function(newState) {
|
|
5887
|
+
var current = _this.state.get(key);
|
|
5888
|
+
_this.state.set(key, newState);
|
|
5889
|
+
if (current !== newState) {
|
|
5890
|
+
var _this_updateCallback, _this1;
|
|
5891
|
+
(_this_updateCallback = (_this1 = _this).updateCallback) === null || _this_updateCallback === void 0 ? void 0 : _this_updateCallback.call(_this1);
|
|
5892
|
+
}
|
|
5893
|
+
}
|
|
5894
|
+
];
|
|
5895
|
+
};
|
|
5896
|
+
}
|
|
5897
|
+
},
|
|
5898
|
+
{
|
|
5899
|
+
key: "getLocalStateFunction",
|
|
5900
|
+
value: function getLocalStateFunction(key, countKey) {
|
|
5901
|
+
var _this = this;
|
|
5902
|
+
return function(initialState) {
|
|
5903
|
+
if (!_this.state.has(key)) {
|
|
5904
|
+
_this.state.set(key, []);
|
|
5905
|
+
}
|
|
5906
|
+
if (!_this.state.has(countKey)) {
|
|
5907
|
+
_this.state.set(countKey, 0);
|
|
5908
|
+
}
|
|
5909
|
+
var localState = _this.state.get(key);
|
|
5910
|
+
var oldCount = _this.state.get(countKey);
|
|
5911
|
+
_this.state.set(countKey, oldCount + 1);
|
|
5912
|
+
if (localState.length <= oldCount) {
|
|
5913
|
+
localState.push(initialState);
|
|
5914
|
+
}
|
|
5915
|
+
var value = localState[oldCount];
|
|
5916
|
+
return [
|
|
5917
|
+
value,
|
|
5918
|
+
function(newState) {
|
|
5919
|
+
var oldValue = localState[oldCount];
|
|
5920
|
+
localState[oldCount] = newState;
|
|
5921
|
+
if (oldValue !== newState) {
|
|
5922
|
+
var _this_updateCallback, _this1;
|
|
5923
|
+
(_this_updateCallback = (_this1 = _this).updateCallback) === null || _this_updateCallback === void 0 ? void 0 : _this_updateCallback.call(_this1);
|
|
5924
|
+
}
|
|
5925
|
+
}
|
|
5926
|
+
];
|
|
5927
|
+
};
|
|
5928
|
+
}
|
|
5929
|
+
}
|
|
5930
|
+
]);
|
|
5931
|
+
return LocalStateStore;
|
|
5932
|
+
}();
|
|
5933
|
+
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/view/plugins/asset-transform.ts
|
|
5934
|
+
function findUp(node, target) {
|
|
5935
|
+
if (node === target) {
|
|
5936
|
+
return true;
|
|
5937
|
+
}
|
|
5938
|
+
if (node.parent) {
|
|
5939
|
+
return findUp(node.parent, target);
|
|
5940
|
+
}
|
|
5941
|
+
return false;
|
|
5942
|
+
}
|
|
5943
|
+
var AssetTransformCorePlugin = /*#__PURE__*/ function() {
|
|
5944
|
+
function AssetTransformCorePlugin(registry) {
|
|
5945
|
+
_class_call_check(this, AssetTransformCorePlugin);
|
|
5946
|
+
this.registry = registry;
|
|
5947
|
+
this.stateStore = /* @__PURE__ */ new Map();
|
|
5948
|
+
this.beforeResolveSymbol = Symbol("before resolve");
|
|
5949
|
+
this.resolveSymbol = Symbol("resolve");
|
|
5950
|
+
this.beforeResolveCountSymbol = Symbol("before resolve count");
|
|
5951
|
+
this.resolveCountSymbol = Symbol("resolve count");
|
|
5952
|
+
}
|
|
5953
|
+
_create_class(AssetTransformCorePlugin, [
|
|
5954
|
+
{
|
|
5955
|
+
key: "apply",
|
|
5956
|
+
value: function apply(view) {
|
|
5957
|
+
var _this = this;
|
|
5958
|
+
this.stateStore.clear();
|
|
5959
|
+
view.hooks.resolver.tap("asset-transform", function(resolver) {
|
|
5960
|
+
var lastUpdatedNode;
|
|
5961
|
+
var updateState = function(node) {
|
|
5962
|
+
lastUpdatedNode = node;
|
|
5963
|
+
view.update(/* @__PURE__ */ new Set());
|
|
5964
|
+
};
|
|
5965
|
+
var getStore = function(node, stepKey) {
|
|
5966
|
+
var store;
|
|
5967
|
+
var countKey = stepKey === _this.resolveSymbol ? _this.resolveCountSymbol : _this.beforeResolveCountSymbol;
|
|
5968
|
+
var storedState = _this.stateStore.get(node);
|
|
5969
|
+
if (storedState) {
|
|
5970
|
+
store = storedState;
|
|
5971
|
+
store.removeKey(countKey);
|
|
5972
|
+
} else {
|
|
5973
|
+
store = new LocalStateStore(function() {
|
|
5974
|
+
updateState(node);
|
|
5975
|
+
});
|
|
5976
|
+
_this.stateStore.set(node, store);
|
|
5977
|
+
}
|
|
5978
|
+
return {
|
|
5979
|
+
useSharedState: function(key) {
|
|
5980
|
+
return store.useSharedState(key);
|
|
5981
|
+
},
|
|
5982
|
+
useLocalState: function(initialState) {
|
|
5983
|
+
return store.getLocalStateFunction(stepKey, countKey)(initialState);
|
|
5984
|
+
}
|
|
5985
|
+
};
|
|
5986
|
+
};
|
|
5987
|
+
resolver.hooks.beforeResolve.tap("asset-transform", function(node, options) {
|
|
5988
|
+
if (node && (node.type === "asset" || node.type === "view")) {
|
|
5989
|
+
var transform = _this.registry.get(node.value);
|
|
5990
|
+
if (transform === null || transform === void 0 ? void 0 : transform.beforeResolve) {
|
|
5991
|
+
var _options_node;
|
|
5992
|
+
var store = getStore((_options_node = options.node) !== null && _options_node !== void 0 ? _options_node : node, _this.beforeResolveSymbol);
|
|
5993
|
+
return transform.beforeResolve(node, options, store);
|
|
5994
|
+
}
|
|
5995
|
+
}
|
|
5996
|
+
return node;
|
|
5997
|
+
});
|
|
5998
|
+
resolver.hooks.afterUpdate.tap("asset-transform", function() {
|
|
5999
|
+
lastUpdatedNode = void 0;
|
|
6000
|
+
});
|
|
6001
|
+
resolver.hooks.skipResolve.tap("asset-transform", function(skip, node) {
|
|
6002
|
+
if (!skip || !lastUpdatedNode) {
|
|
6003
|
+
return skip;
|
|
6004
|
+
}
|
|
6005
|
+
var isParentOfUpdated = findUp(lastUpdatedNode, node);
|
|
6006
|
+
var isChildOfUpdated = findUp(node, lastUpdatedNode);
|
|
6007
|
+
return !isParentOfUpdated && !isChildOfUpdated;
|
|
6008
|
+
});
|
|
6009
|
+
resolver.hooks.afterResolve.tap("asset-transform", function(value, node, options) {
|
|
6010
|
+
if (node.type !== "asset" /* Asset */ && node.type !== "view" /* View */ ) {
|
|
6011
|
+
return value;
|
|
6012
|
+
}
|
|
6013
|
+
var originalNode = resolver.getSourceNode(node);
|
|
6014
|
+
if (!originalNode) {
|
|
6015
|
+
return value;
|
|
6016
|
+
}
|
|
6017
|
+
var transform = _this.registry.get(value);
|
|
6018
|
+
if (transform === null || transform === void 0 ? void 0 : transform.resolve) {
|
|
6019
|
+
var store = getStore(originalNode, _this.resolveSymbol);
|
|
6020
|
+
return transform === null || transform === void 0 ? void 0 : transform.resolve(value, options, store);
|
|
6021
|
+
}
|
|
6022
|
+
return value;
|
|
6023
|
+
});
|
|
6024
|
+
});
|
|
6025
|
+
}
|
|
6026
|
+
}
|
|
6027
|
+
]);
|
|
6028
|
+
return AssetTransformCorePlugin;
|
|
6029
|
+
}();
|
|
5856
6030
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/player.ts
|
|
5857
6031
|
var import_timm9 = __toESM(require_timm());
|
|
5858
6032
|
var import_p_defer2 = __toESM(require_p_defer());
|
|
@@ -6893,182 +7067,6 @@ var Player = function() {
|
|
|
6893
7067
|
]);
|
|
6894
7068
|
return ValidationController;
|
|
6895
7069
|
}();
|
|
6896
|
-
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/controllers/view/store.ts
|
|
6897
|
-
var LocalStateStore = /*#__PURE__*/ function() {
|
|
6898
|
-
function LocalStateStore(onUpdate) {
|
|
6899
|
-
_class_call_check(this, LocalStateStore);
|
|
6900
|
-
this.updateCallback = onUpdate;
|
|
6901
|
-
this.state = /* @__PURE__ */ new Map();
|
|
6902
|
-
}
|
|
6903
|
-
_create_class(LocalStateStore, [
|
|
6904
|
-
{
|
|
6905
|
-
key: "removeKey",
|
|
6906
|
-
value: function removeKey(key) {
|
|
6907
|
-
this.state.delete(key);
|
|
6908
|
-
}
|
|
6909
|
-
},
|
|
6910
|
-
{
|
|
6911
|
-
key: "reset",
|
|
6912
|
-
value: function reset() {
|
|
6913
|
-
this.state.clear();
|
|
6914
|
-
}
|
|
6915
|
-
},
|
|
6916
|
-
{
|
|
6917
|
-
key: "useSharedState",
|
|
6918
|
-
value: function useSharedState(key) {
|
|
6919
|
-
var _this = this;
|
|
6920
|
-
return function(initialState) {
|
|
6921
|
-
if (!_this.state.has(key)) {
|
|
6922
|
-
_this.state.set(key, initialState);
|
|
6923
|
-
}
|
|
6924
|
-
return [
|
|
6925
|
-
_this.state.get(key),
|
|
6926
|
-
function(newState) {
|
|
6927
|
-
var current = _this.state.get(key);
|
|
6928
|
-
_this.state.set(key, newState);
|
|
6929
|
-
if (current !== newState) {
|
|
6930
|
-
var _this_updateCallback, _this1;
|
|
6931
|
-
(_this_updateCallback = (_this1 = _this).updateCallback) === null || _this_updateCallback === void 0 ? void 0 : _this_updateCallback.call(_this1);
|
|
6932
|
-
}
|
|
6933
|
-
}
|
|
6934
|
-
];
|
|
6935
|
-
};
|
|
6936
|
-
}
|
|
6937
|
-
},
|
|
6938
|
-
{
|
|
6939
|
-
key: "getLocalStateFunction",
|
|
6940
|
-
value: function getLocalStateFunction(key, countKey) {
|
|
6941
|
-
var _this = this;
|
|
6942
|
-
return function(initialState) {
|
|
6943
|
-
if (!_this.state.has(key)) {
|
|
6944
|
-
_this.state.set(key, []);
|
|
6945
|
-
}
|
|
6946
|
-
if (!_this.state.has(countKey)) {
|
|
6947
|
-
_this.state.set(countKey, 0);
|
|
6948
|
-
}
|
|
6949
|
-
var localState = _this.state.get(key);
|
|
6950
|
-
var oldCount = _this.state.get(countKey);
|
|
6951
|
-
_this.state.set(countKey, oldCount + 1);
|
|
6952
|
-
if (localState.length <= oldCount) {
|
|
6953
|
-
localState.push(initialState);
|
|
6954
|
-
}
|
|
6955
|
-
var value = localState[oldCount];
|
|
6956
|
-
return [
|
|
6957
|
-
value,
|
|
6958
|
-
function(newState) {
|
|
6959
|
-
var oldValue = localState[oldCount];
|
|
6960
|
-
localState[oldCount] = newState;
|
|
6961
|
-
if (oldValue !== newState) {
|
|
6962
|
-
var _this_updateCallback, _this1;
|
|
6963
|
-
(_this_updateCallback = (_this1 = _this).updateCallback) === null || _this_updateCallback === void 0 ? void 0 : _this_updateCallback.call(_this1);
|
|
6964
|
-
}
|
|
6965
|
-
}
|
|
6966
|
-
];
|
|
6967
|
-
};
|
|
6968
|
-
}
|
|
6969
|
-
}
|
|
6970
|
-
]);
|
|
6971
|
-
return LocalStateStore;
|
|
6972
|
-
}();
|
|
6973
|
-
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/controllers/view/asset-transform.ts
|
|
6974
|
-
function findUp(node, target) {
|
|
6975
|
-
if (node === target) {
|
|
6976
|
-
return true;
|
|
6977
|
-
}
|
|
6978
|
-
if (node.parent) {
|
|
6979
|
-
return findUp(node.parent, target);
|
|
6980
|
-
}
|
|
6981
|
-
return false;
|
|
6982
|
-
}
|
|
6983
|
-
var AssetTransformCorePlugin = /*#__PURE__*/ function() {
|
|
6984
|
-
function AssetTransformCorePlugin(registry) {
|
|
6985
|
-
_class_call_check(this, AssetTransformCorePlugin);
|
|
6986
|
-
this.registry = registry;
|
|
6987
|
-
this.stateStore = /* @__PURE__ */ new Map();
|
|
6988
|
-
this.beforeResolveSymbol = Symbol("before resolve");
|
|
6989
|
-
this.resolveSymbol = Symbol("resolve");
|
|
6990
|
-
this.beforeResolveCountSymbol = Symbol("before resolve count");
|
|
6991
|
-
this.resolveCountSymbol = Symbol("resolve count");
|
|
6992
|
-
}
|
|
6993
|
-
_create_class(AssetTransformCorePlugin, [
|
|
6994
|
-
{
|
|
6995
|
-
key: "apply",
|
|
6996
|
-
value: function apply(viewController) {
|
|
6997
|
-
var _this = this;
|
|
6998
|
-
viewController.hooks.view.tap("asset-transform", function(view) {
|
|
6999
|
-
_this.stateStore.clear();
|
|
7000
|
-
view.hooks.resolver.tap("asset-transform", function(resolver) {
|
|
7001
|
-
var lastUpdatedNode;
|
|
7002
|
-
var updateState = function(node) {
|
|
7003
|
-
lastUpdatedNode = node;
|
|
7004
|
-
view.update(/* @__PURE__ */ new Set());
|
|
7005
|
-
};
|
|
7006
|
-
var getStore = function(node, stepKey) {
|
|
7007
|
-
var store;
|
|
7008
|
-
var countKey = stepKey === _this.resolveSymbol ? _this.resolveCountSymbol : _this.beforeResolveCountSymbol;
|
|
7009
|
-
var storedState = _this.stateStore.get(node);
|
|
7010
|
-
if (storedState) {
|
|
7011
|
-
store = storedState;
|
|
7012
|
-
store.removeKey(countKey);
|
|
7013
|
-
} else {
|
|
7014
|
-
store = new LocalStateStore(function() {
|
|
7015
|
-
updateState(node);
|
|
7016
|
-
});
|
|
7017
|
-
_this.stateStore.set(node, store);
|
|
7018
|
-
}
|
|
7019
|
-
return {
|
|
7020
|
-
useSharedState: function(key) {
|
|
7021
|
-
return store.useSharedState(key);
|
|
7022
|
-
},
|
|
7023
|
-
useLocalState: function(initialState) {
|
|
7024
|
-
return store.getLocalStateFunction(stepKey, countKey)(initialState);
|
|
7025
|
-
}
|
|
7026
|
-
};
|
|
7027
|
-
};
|
|
7028
|
-
resolver.hooks.beforeResolve.tap("asset-transform", function(node, options) {
|
|
7029
|
-
if (node && (node.type === "asset" || node.type === "view")) {
|
|
7030
|
-
var transform = _this.registry.get(node.value);
|
|
7031
|
-
if (transform === null || transform === void 0 ? void 0 : transform.beforeResolve) {
|
|
7032
|
-
var _options_node;
|
|
7033
|
-
var store = getStore((_options_node = options.node) !== null && _options_node !== void 0 ? _options_node : node, _this.beforeResolveSymbol);
|
|
7034
|
-
return transform.beforeResolve(node, options, store);
|
|
7035
|
-
}
|
|
7036
|
-
}
|
|
7037
|
-
return node;
|
|
7038
|
-
});
|
|
7039
|
-
resolver.hooks.afterUpdate.tap("asset-transform", function() {
|
|
7040
|
-
lastUpdatedNode = void 0;
|
|
7041
|
-
});
|
|
7042
|
-
resolver.hooks.skipResolve.tap("asset-transform", function(skip, node) {
|
|
7043
|
-
if (!skip || !lastUpdatedNode) {
|
|
7044
|
-
return skip;
|
|
7045
|
-
}
|
|
7046
|
-
var isParentOfUpdated = findUp(lastUpdatedNode, node);
|
|
7047
|
-
var isChildOfUpdated = findUp(node, lastUpdatedNode);
|
|
7048
|
-
return !isParentOfUpdated && !isChildOfUpdated;
|
|
7049
|
-
});
|
|
7050
|
-
resolver.hooks.afterResolve.tap("asset-transform", function(value, node, options) {
|
|
7051
|
-
if (node.type !== "asset" /* Asset */ && node.type !== "view" /* View */ ) {
|
|
7052
|
-
return value;
|
|
7053
|
-
}
|
|
7054
|
-
var originalNode = resolver.getSourceNode(node);
|
|
7055
|
-
if (!originalNode) {
|
|
7056
|
-
return value;
|
|
7057
|
-
}
|
|
7058
|
-
var transform = _this.registry.get(value);
|
|
7059
|
-
if (transform === null || transform === void 0 ? void 0 : transform.resolve) {
|
|
7060
|
-
var store = getStore(originalNode, _this.resolveSymbol);
|
|
7061
|
-
return transform === null || transform === void 0 ? void 0 : transform.resolve(value, options, store);
|
|
7062
|
-
}
|
|
7063
|
-
return value;
|
|
7064
|
-
});
|
|
7065
|
-
});
|
|
7066
|
-
});
|
|
7067
|
-
}
|
|
7068
|
-
}
|
|
7069
|
-
]);
|
|
7070
|
-
return AssetTransformCorePlugin;
|
|
7071
|
-
}();
|
|
7072
7070
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/controllers/view/controller.ts
|
|
7073
7071
|
var import_queue_microtask = __toESM(require_queue_microtask());
|
|
7074
7072
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/@player-ui+partial-match-registry@0.0.0/node_modules/@player-ui/partial-match-registry/dist/index.mjs
|
|
@@ -7217,7 +7215,6 @@ var Player = function() {
|
|
|
7217
7215
|
viewMap[view.id] = view;
|
|
7218
7216
|
return viewMap;
|
|
7219
7217
|
}, {});
|
|
7220
|
-
new AssetTransformCorePlugin(this.transformRegistry).apply(this);
|
|
7221
7218
|
options.flowController.hooks.flow.tap("viewController", function(flow) {
|
|
7222
7219
|
flow.hooks.transition.tap("viewController", function(_oldState, newState) {
|
|
7223
7220
|
if (newState.value.state_type === "VIEW") {
|
|
@@ -7710,6 +7707,7 @@ var Player = function() {
|
|
|
7710
7707
|
new AssetPlugin().apply(view);
|
|
7711
7708
|
new SwitchPlugin(pluginOptions).apply(view);
|
|
7712
7709
|
new ApplicabilityPlugin().apply(view);
|
|
7710
|
+
new AssetTransformCorePlugin(viewController.transformRegistry).apply(view);
|
|
7713
7711
|
new StringResolverPlugin().apply(view);
|
|
7714
7712
|
var templatePlugin = new TemplatePlugin(pluginOptions);
|
|
7715
7713
|
templatePlugin.apply(view);
|