@threekit-tools/treble 0.0.22 → 0.0.23
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.
|
@@ -5,7 +5,7 @@ interface IProducts {
|
|
|
5
5
|
ctx: __WebpackModuleApi.RequireContext;
|
|
6
6
|
}
|
|
7
7
|
interface ProductLoaderProps extends Omit<ThreekitProviderProps, 'children'> {
|
|
8
|
-
productId
|
|
8
|
+
productId?: string;
|
|
9
9
|
products: IProducts;
|
|
10
10
|
}
|
|
11
11
|
export default function ProductLoader(props: ProductLoaderProps): JSX.Element | null;
|
|
@@ -24,12 +24,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
var react_1 = __importStar(require("react"));
|
|
26
26
|
var ThreekitProvider_1 = __importDefault(require("../ThreekitProvider"));
|
|
27
|
+
var utils_1 = require("../../utils");
|
|
27
28
|
var productAssetId = {};
|
|
28
29
|
var productComponents = [];
|
|
29
30
|
var productToComponentMap = {};
|
|
30
31
|
function ProductLoader(props) {
|
|
31
32
|
var productId = props.productId, products = props.products, credentials = props.credentials, playerConfig = props.playerConfig, theme = props.theme, threekitEnv = props.threekitEnv;
|
|
32
|
-
if (!
|
|
33
|
+
if (!products)
|
|
33
34
|
return null;
|
|
34
35
|
if (!productComponents.length) {
|
|
35
36
|
products.ctx.keys().forEach(function (fileName) {
|
|
@@ -67,10 +68,17 @@ function ProductLoader(props) {
|
|
|
67
68
|
});
|
|
68
69
|
});
|
|
69
70
|
}
|
|
70
|
-
var
|
|
71
|
+
var params = (0, utils_1.getParams)();
|
|
72
|
+
var id = productId;
|
|
73
|
+
if (!id && params['tkProduct']) {
|
|
74
|
+
id = Object.keys(productToComponentMap).find(function (el) { return params['tkProduct'] === el; });
|
|
75
|
+
}
|
|
76
|
+
if (!id)
|
|
77
|
+
return null;
|
|
78
|
+
var Product = productComponents[productToComponentMap[id]];
|
|
71
79
|
if (!Product)
|
|
72
80
|
return null;
|
|
73
|
-
var assetId = productAssetId[
|
|
81
|
+
var assetId = productAssetId[id];
|
|
74
82
|
var env = threekitEnv || 'preview';
|
|
75
83
|
var preppedCredentials = Object.assign({}, credentials);
|
|
76
84
|
preppedCredentials[env] = Object.assign(preppedCredentials[env], {
|