@threekit-tools/treble 0.0.81 → 0.0.84
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/Treble/Treble.d.ts +11 -5
- package/dist/Treble/Treble.js +41 -12
- package/dist/Treble/index.d.ts +2 -2
- package/dist/Treble/index.js +7 -3
- package/dist/Treble/{Snapshots.d.ts → snapshots.d.ts} +4 -9
- package/dist/Treble/snapshots.js +247 -0
- package/dist/Treble/{Wishlist.d.ts → wishlist.d.ts} +2 -6
- package/dist/Treble/wishlist.js +135 -0
- package/dist/api/catalog.js +6 -6
- package/dist/api/configurations.js +3 -3
- package/dist/api/datatables.js +5 -5
- package/dist/api/index.js +5 -1
- package/dist/api/orders.d.ts +5 -7
- package/dist/api/orders.js +12 -12
- package/dist/api/price.js +2 -2
- package/dist/api/products.js +2 -2
- package/dist/components/Accordion/index.js +6 -7
- package/dist/components/AttributeTitle/index.d.ts +0 -9
- package/dist/components/AttributeTitle/index.js +0 -9
- package/dist/components/AttributeValue/index.d.ts +0 -6
- package/dist/components/AttributeValue/index.js +2 -8
- package/dist/components/Button/index.d.ts +0 -27
- package/dist/components/Button/index.js +0 -27
- package/dist/components/Cards/index.d.ts +2 -55
- package/dist/components/Cards/index.js +3 -60
- package/dist/components/Drawer/index.js +7 -16
- package/dist/components/Dropdown/index.d.ts +2 -59
- package/dist/components/Dropdown/index.js +11 -72
- package/dist/components/FlatForm/index.d.ts +0 -21
- package/dist/components/FlatForm/index.js +10 -25
- package/dist/components/Modal/index.js +2 -15
- package/dist/components/Player/index.d.ts +1 -1
- package/dist/components/PortalToArOverlay/index.js +5 -1
- package/dist/components/PortalToElement/index.js +0 -8
- package/dist/components/ProductDescription/index.d.ts +0 -6
- package/dist/components/ProductDescription/index.js +0 -6
- package/dist/components/ProductName/index.d.ts +0 -9
- package/dist/components/ProductName/index.js +0 -9
- package/dist/components/Share/index.d.ts +0 -12
- package/dist/components/Share/index.js +2 -14
- package/dist/components/Snapshots/index.d.ts +0 -8
- package/dist/components/Snapshots/index.js +2 -10
- package/dist/components/Strips/index.d.ts +2 -55
- package/dist/components/Strips/index.js +3 -60
- package/dist/components/Swatch/index.d.ts +2 -64
- package/dist/components/Swatch/index.js +3 -69
- package/dist/components/Switch/index.d.ts +2 -34
- package/dist/components/Switch/index.js +2 -38
- package/dist/components/Tabs/index.js +5 -1
- package/dist/components/TextInput/index.d.ts +2 -1
- package/dist/components/TextInput/index.js +2 -3
- package/dist/components/ThreekitProvider/index.js +5 -1
- package/dist/components/Tiles/index.d.ts +2 -29
- package/dist/components/Tiles/index.js +3 -33
- package/dist/components/TilesGroup/index.d.ts +2 -26
- package/dist/components/TilesGroup/index.js +3 -30
- package/dist/components/TotalPrice/index.d.ts +0 -6
- package/dist/components/TotalPrice/index.js +0 -6
- package/dist/components/TrebleApp/index.js +5 -1
- package/dist/components/Upload/index.d.ts +2 -1
- package/dist/components/Upload/index.js +21 -17
- package/dist/components/UploadArea/index.d.ts +2 -1
- package/dist/components/UploadArea/index.js +18 -15
- package/dist/components/Wishlist/index.d.ts +0 -3
- package/dist/components/Wishlist/index.js +12 -10
- package/dist/components/Zoom/index.d.ts +0 -17
- package/dist/components/Zoom/index.js +5 -21
- package/dist/components/formComponents.d.ts +12 -0
- package/dist/components/formComponents.js +10 -8
- package/dist/components/message/index.d.ts +0 -9
- package/dist/components/message/index.js +4 -31
- package/dist/connection.js +2 -2
- package/dist/constants.d.ts +0 -49
- package/dist/constants.js +1 -59
- package/dist/hooks/useAttribute/index.d.ts +1 -1
- package/dist/hooks/useAttribute/index.js +6 -6
- package/dist/hooks/useConfigurationLoader/index.js +5 -5
- package/dist/hooks/useNestedConfigurator/index.js +2 -2
- package/dist/hooks/useShare/index.js +3 -3
- package/dist/hooks/useSingleAnimation/index.js +20 -25
- package/dist/http/datatables.js +0 -1
- package/dist/http/index.js +5 -1
- package/dist/http/orders.d.ts +6 -8
- package/dist/icons/Spinner.js +5 -1
- package/dist/icons/index.d.ts +0 -41
- package/dist/icons/index.js +0 -42
- package/dist/index.d.ts +42 -3
- package/dist/index.js +84 -26
- package/dist/store/attributes.d.ts +0 -12
- package/dist/store/attributes.js +2 -15
- package/dist/store/index.d.ts +1 -1
- package/dist/store/price.d.ts +0 -12
- package/dist/store/price.js +2 -16
- package/dist/store/product.d.ts +6 -21
- package/dist/store/product.js +26 -38
- package/dist/store/translations.d.ts +1 -13
- package/dist/store/translations.js +2 -12
- package/dist/store/treble.d.ts +1 -16
- package/dist/store/treble.js +31 -66
- package/dist/store/wishlist.d.ts +0 -12
- package/dist/store/wishlist.js +4 -17
- package/dist/types.d.ts +118 -65
- package/dist/types.js +54 -0
- package/dist/utils.d.ts +10 -10
- package/dist/utils.js +8 -16
- package/package.json +16 -4
- package/dist/Treble/Snapshots.js +0 -251
- package/dist/Treble/Wishlist.js +0 -136
- package/dist/hooks/useImageEditor/index.d.ts +0 -14
- package/dist/hooks/useImageEditor/index.js +0 -320
package/dist/store/attributes.js
CHANGED
|
@@ -40,9 +40,6 @@ exports.setConfiguration = exports.getHydrationData = exports.getAttributes = ex
|
|
|
40
40
|
var toolkit_1 = require("@reduxjs/toolkit");
|
|
41
41
|
var treble_1 = require("./treble");
|
|
42
42
|
var translations_1 = require("./translations");
|
|
43
|
-
/*****************************************************
|
|
44
|
-
* Actions
|
|
45
|
-
****************************************************/
|
|
46
43
|
exports.setAttributes = (0, toolkit_1.createAction)('treble/attributes/set-attributes', function (attributes) {
|
|
47
44
|
var payload = attributes.reduce(function (output, attr) {
|
|
48
45
|
var _a;
|
|
@@ -50,13 +47,7 @@ exports.setAttributes = (0, toolkit_1.createAction)('treble/attributes/set-attri
|
|
|
50
47
|
}, {});
|
|
51
48
|
return { payload: payload };
|
|
52
49
|
});
|
|
53
|
-
/*****************************************************
|
|
54
|
-
* State and Data
|
|
55
|
-
****************************************************/
|
|
56
50
|
var initialState = {};
|
|
57
|
-
/*****************************************************
|
|
58
|
-
* Slice
|
|
59
|
-
****************************************************/
|
|
60
51
|
var reducer = (0, toolkit_1.createSlice)({
|
|
61
52
|
name: 'attributes',
|
|
62
53
|
initialState: initialState,
|
|
@@ -74,25 +65,21 @@ var reducer = (0, toolkit_1.createSlice)({
|
|
|
74
65
|
});
|
|
75
66
|
},
|
|
76
67
|
}).reducer;
|
|
77
|
-
/*****************************************************
|
|
78
|
-
* Standard Selectors
|
|
79
|
-
****************************************************/
|
|
80
68
|
var getAttributes = function (state) { return state.attributes; };
|
|
81
69
|
exports.getAttributes = getAttributes;
|
|
82
70
|
exports.getHydrationData = (0, toolkit_1.createSelector)(exports.getAttributes, translations_1.getLanguage, function (attributes, language) {
|
|
83
71
|
return [attributes, translations_1.TRANSLATIONS, language];
|
|
84
72
|
});
|
|
85
|
-
// Configurator
|
|
86
73
|
var setConfiguration = function (config) { return function (dispatch) { return __awaiter(void 0, void 0, void 0, function () {
|
|
87
74
|
return __generator(this, function (_a) {
|
|
88
75
|
switch (_a.label) {
|
|
89
76
|
case 0:
|
|
90
77
|
dispatch((0, treble_1.setPlayerLoading)(true));
|
|
91
|
-
return [4
|
|
78
|
+
return [4, window.threekit.configurator.setConfiguration(config)];
|
|
92
79
|
case 1:
|
|
93
80
|
_a.sent();
|
|
94
81
|
dispatch((0, treble_1.setPlayerLoading)(false));
|
|
95
|
-
return [2
|
|
82
|
+
return [2];
|
|
96
83
|
}
|
|
97
84
|
});
|
|
98
85
|
}); }; };
|
package/dist/store/index.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ declare const store: import("@reduxjs/toolkit").EnhancedStore<{
|
|
|
29
29
|
wishlist: import("../Treble").WishlistArray;
|
|
30
30
|
price: import("./price").PriceState;
|
|
31
31
|
}, import("redux").Dispatch<import("redux").AnyAction>>>>;
|
|
32
|
-
export declare const createStore: (reducer?: Record<string, Reducer
|
|
32
|
+
export declare const createStore: (reducer?: Record<string, Reducer>) => import("@reduxjs/toolkit").EnhancedStore<{
|
|
33
33
|
treble: import("./treble").TrebleState;
|
|
34
34
|
product: import("./product").ProductState;
|
|
35
35
|
attributes: import("./attributes").AttributesState;
|
package/dist/store/price.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { RootState, ThreekitDispatch } from './index';
|
|
2
|
-
/*****************************************************
|
|
3
|
-
* Types and Interfaces
|
|
4
|
-
****************************************************/
|
|
5
2
|
export interface IPriceConfig {
|
|
6
3
|
id: string;
|
|
7
4
|
currency: string;
|
|
@@ -15,20 +12,11 @@ export interface PriceState {
|
|
|
15
12
|
currency: undefined | string;
|
|
16
13
|
price: undefined | number;
|
|
17
14
|
}
|
|
18
|
-
/*****************************************************
|
|
19
|
-
* Actions
|
|
20
|
-
****************************************************/
|
|
21
15
|
export declare const setPriceConfig: import("@reduxjs/toolkit").ActionCreatorWithPayload<IPriceConfig, string>;
|
|
22
16
|
export declare const setPrice: import("@reduxjs/toolkit").ActionCreatorWithPayload<number, string>;
|
|
23
17
|
export declare const initPrice: () => (dispatch: ThreekitDispatch) => Promise<void>;
|
|
24
18
|
declare const reducer: import("redux").Reducer<PriceState, import("redux").AnyAction>;
|
|
25
|
-
/*****************************************************
|
|
26
|
-
* Standard Selectors
|
|
27
|
-
****************************************************/
|
|
28
19
|
export declare const getPrice: (state: RootState) => undefined | IPrice;
|
|
29
20
|
export declare const getPriceConfig: (state: RootState) => undefined | IPriceConfig;
|
|
30
|
-
/*****************************************************
|
|
31
|
-
* Complex Actions
|
|
32
|
-
****************************************************/
|
|
33
21
|
export declare const updatePrice: () => (dispatch: ThreekitDispatch, getState: () => RootState) => void;
|
|
34
22
|
export default reducer;
|
package/dist/store/price.js
CHANGED
|
@@ -42,17 +42,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
42
42
|
exports.updatePrice = exports.getPriceConfig = exports.getPrice = exports.initPrice = exports.setPrice = exports.setPriceConfig = void 0;
|
|
43
43
|
var toolkit_1 = require("@reduxjs/toolkit");
|
|
44
44
|
var api_1 = __importDefault(require("../api"));
|
|
45
|
-
/*****************************************************
|
|
46
|
-
* Actions
|
|
47
|
-
****************************************************/
|
|
48
|
-
// Actions to be used only internally
|
|
49
45
|
exports.setPriceConfig = (0, toolkit_1.createAction)('treble/price/set-price-config');
|
|
50
46
|
exports.setPrice = (0, toolkit_1.createAction)('treble/price/set-price');
|
|
51
47
|
var initPrice = function () { return function (dispatch) { return __awaiter(void 0, void 0, void 0, function () {
|
|
52
48
|
var pricebook, id, currency, price;
|
|
53
49
|
return __generator(this, function (_a) {
|
|
54
50
|
switch (_a.label) {
|
|
55
|
-
case 0: return [4
|
|
51
|
+
case 0: return [4, api_1.default.price.getPricebooksList()];
|
|
56
52
|
case 1:
|
|
57
53
|
pricebook = _a.sent();
|
|
58
54
|
if (pricebook.length) {
|
|
@@ -62,16 +58,12 @@ var initPrice = function () { return function (dispatch) { return __awaiter(void
|
|
|
62
58
|
price = window.threekit.configurator.getPrice(id, currency);
|
|
63
59
|
dispatch((0, exports.setPrice)(price));
|
|
64
60
|
}
|
|
65
|
-
return [2
|
|
61
|
+
return [2];
|
|
66
62
|
}
|
|
67
63
|
});
|
|
68
64
|
}); }; };
|
|
69
65
|
exports.initPrice = initPrice;
|
|
70
|
-
/*****************************************************
|
|
71
|
-
* State
|
|
72
|
-
****************************************************/
|
|
73
66
|
var initialState = {
|
|
74
|
-
// Selected language
|
|
75
67
|
id: undefined,
|
|
76
68
|
currency: undefined,
|
|
77
69
|
price: undefined,
|
|
@@ -93,9 +85,6 @@ var reducer = (0, toolkit_1.createSlice)({
|
|
|
93
85
|
},
|
|
94
86
|
reducers: {},
|
|
95
87
|
}).reducer;
|
|
96
|
-
/*****************************************************
|
|
97
|
-
* Standard Selectors
|
|
98
|
-
****************************************************/
|
|
99
88
|
var getPrice = function (state) {
|
|
100
89
|
var _a = state.price, price = _a.price, currency = _a.currency;
|
|
101
90
|
if (!price || !currency)
|
|
@@ -110,9 +99,6 @@ var getPriceConfig = function (state) {
|
|
|
110
99
|
return { id: id, currency: currency };
|
|
111
100
|
};
|
|
112
101
|
exports.getPriceConfig = getPriceConfig;
|
|
113
|
-
/*****************************************************
|
|
114
|
-
* Complex Actions
|
|
115
|
-
****************************************************/
|
|
116
102
|
var updatePrice = function () { return function (dispatch, getState) {
|
|
117
103
|
var price = getState().price;
|
|
118
104
|
if (!price.id || !price.currency)
|
package/dist/store/product.d.ts
CHANGED
|
@@ -2,9 +2,6 @@ import { RootState, ThreekitDispatch } from './index';
|
|
|
2
2
|
import { IMetadata, IConfiguration, IProduct } from '../types';
|
|
3
3
|
import { IConnectionConfig } from '../connection';
|
|
4
4
|
import { IReloadConfig } from './treble';
|
|
5
|
-
/*****************************************************
|
|
6
|
-
* Types and Interfaces
|
|
7
|
-
****************************************************/
|
|
8
5
|
export interface CachedProduct {
|
|
9
6
|
id: undefined | string;
|
|
10
7
|
name?: string;
|
|
@@ -30,16 +27,10 @@ export interface ProductState {
|
|
|
30
27
|
cache: Array<CachedProductState>;
|
|
31
28
|
activeCacheIdx: number;
|
|
32
29
|
}
|
|
33
|
-
/*****************************************************
|
|
34
|
-
* Constants
|
|
35
|
-
****************************************************/
|
|
36
30
|
export declare let PRODUCTS: IHydratedProducts;
|
|
37
|
-
/*****************************************************
|
|
38
|
-
* Actions
|
|
39
|
-
****************************************************/
|
|
40
31
|
export declare const setProductId: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<string | undefined, string>;
|
|
41
|
-
export declare const setName: import("@reduxjs/toolkit").
|
|
42
|
-
export declare const setMetadata: import("@reduxjs/toolkit").
|
|
32
|
+
export declare const setName: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<string | undefined, string>;
|
|
33
|
+
export declare const setMetadata: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<IMetadata | undefined, string>;
|
|
43
34
|
export declare const appendToCache: import("@reduxjs/toolkit").ActionCreatorWithPayload<CachedProductState, string>;
|
|
44
35
|
export declare const updateActiveProductCache: import("@reduxjs/toolkit").ActionCreatorWithPayload<CachedProductState, string>;
|
|
45
36
|
export declare const removeFromCache: import("@reduxjs/toolkit").ActionCreatorWithPayload<number, string>;
|
|
@@ -47,24 +38,18 @@ export declare const setActiveCacheIdx: import("@reduxjs/toolkit").ActionCreator
|
|
|
47
38
|
export declare const incrementActiveCacheIdx: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<undefined, string>;
|
|
48
39
|
export declare const decrementActiveCacheIdx: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<undefined, string>;
|
|
49
40
|
declare const reducer: import("redux").Reducer<ProductState, import("redux").AnyAction>;
|
|
50
|
-
/*****************************************************
|
|
51
|
-
* Standard Selectors
|
|
52
|
-
****************************************************/
|
|
53
41
|
export declare const getProductId: (state: RootState) => undefined | string;
|
|
54
42
|
export declare const getName: (state: RootState) => undefined | string;
|
|
55
43
|
export declare const getMetadata: (state: RootState) => undefined | IMetadata;
|
|
56
44
|
export declare const getActiveCacheIdx: (state: RootState) => number;
|
|
57
45
|
export declare const getProductCache: (state: RootState) => Array<Pick<CachedProduct, 'name' | 'label' | 'thumbnail'>>;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
****************************************************/
|
|
61
|
-
export declare const initProduct: (prods?: IHydratedProducts | undefined) => (dispatch: ThreekitDispatch, getState: () => RootState) => void;
|
|
62
|
-
export declare const cacheActiveProduct: (config?: Pick<IReloadConfig, "label" | "thumbnail"> | undefined) => (dispatch: ThreekitDispatch, getState: () => RootState) => {
|
|
46
|
+
export declare const initProduct: (prods?: IHydratedProducts) => (dispatch: ThreekitDispatch, getState: () => RootState) => void;
|
|
47
|
+
export declare const cacheActiveProduct: (config?: Pick<IReloadConfig, 'label' | 'thumbnail'>) => (dispatch: ThreekitDispatch, getState: () => RootState) => {
|
|
63
48
|
payload: CachedProductState;
|
|
64
49
|
type: string;
|
|
65
50
|
};
|
|
66
|
-
export declare const loadProduct: (id: string, config?: LoadProductConfig
|
|
51
|
+
export declare const loadProduct: (id: string, config?: LoadProductConfig) => (dispatch: ThreekitDispatch, getState: () => RootState) => Promise<void>;
|
|
67
52
|
export declare const loadNewProduct: (config: undefined | string | IReloadConfig) => (dispatch: ThreekitDispatch) => Promise<void>;
|
|
68
53
|
export declare const changeActiveCacheIdx: (idx: number) => (dispatch: ThreekitDispatch, getState: () => RootState) => Promise<void>;
|
|
69
|
-
export declare const removeProductIdx: (idx?: number
|
|
54
|
+
export declare const removeProductIdx: (idx?: number) => (dispatch: ThreekitDispatch, getState: () => RootState) => Promise<void>;
|
|
70
55
|
export default reducer;
|
package/dist/store/product.js
CHANGED
|
@@ -52,12 +52,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
53
|
exports.removeProductIdx = exports.changeActiveCacheIdx = exports.loadNewProduct = exports.loadProduct = exports.cacheActiveProduct = exports.initProduct = exports.getProductCache = exports.getActiveCacheIdx = exports.getMetadata = exports.getName = exports.getProductId = exports.decrementActiveCacheIdx = exports.incrementActiveCacheIdx = exports.setActiveCacheIdx = exports.removeFromCache = exports.updateActiveProductCache = exports.appendToCache = exports.setMetadata = exports.setName = exports.setProductId = exports.PRODUCTS = void 0;
|
|
54
54
|
var toolkit_1 = require("@reduxjs/toolkit");
|
|
55
|
+
var types_1 = require("../types");
|
|
55
56
|
var connection_1 = __importDefault(require("../connection"));
|
|
56
57
|
var treble_1 = require("./treble");
|
|
57
|
-
/*****************************************************
|
|
58
|
-
* Actions
|
|
59
|
-
****************************************************/
|
|
60
|
-
// Actions to be used only internally
|
|
61
58
|
exports.setProductId = (0, toolkit_1.createAction)('treble/set-product-id');
|
|
62
59
|
exports.setName = (0, toolkit_1.createAction)('treble/set-product-name');
|
|
63
60
|
exports.setMetadata = (0, toolkit_1.createAction)('treble/set-metadata');
|
|
@@ -67,17 +64,10 @@ exports.removeFromCache = (0, toolkit_1.createAction)('treble/remove-from-cache'
|
|
|
67
64
|
exports.setActiveCacheIdx = (0, toolkit_1.createAction)('treble/set-active-cache-idx');
|
|
68
65
|
exports.incrementActiveCacheIdx = (0, toolkit_1.createAction)('treble/increment-active-cache-idx');
|
|
69
66
|
exports.decrementActiveCacheIdx = (0, toolkit_1.createAction)('treble/decrement-active-cache-idx');
|
|
70
|
-
/*****************************************************
|
|
71
|
-
* State
|
|
72
|
-
****************************************************/
|
|
73
67
|
var initialState = {
|
|
74
|
-
// ID of initialized item
|
|
75
68
|
id: undefined,
|
|
76
|
-
// Name of the Initialized Item
|
|
77
69
|
name: undefined,
|
|
78
|
-
// Initialized item's metadata
|
|
79
70
|
metadata: undefined,
|
|
80
|
-
// cached products. Does not include the active product
|
|
81
71
|
cache: [],
|
|
82
72
|
activeCacheIdx: 0,
|
|
83
73
|
};
|
|
@@ -89,10 +79,13 @@ var reducer = (0, toolkit_1.createSlice)({
|
|
|
89
79
|
return __assign(__assign({}, state), { id: action.payload });
|
|
90
80
|
});
|
|
91
81
|
builder.addCase(exports.setName, function (state, action) {
|
|
92
|
-
|
|
82
|
+
var name = window.threekit.player.scene.get({
|
|
83
|
+
id: window.threekit.player.assetId,
|
|
84
|
+
}).name;
|
|
85
|
+
return __assign(__assign({}, state), { name: action.payload || name });
|
|
93
86
|
});
|
|
94
87
|
builder.addCase(exports.setMetadata, function (state, action) {
|
|
95
|
-
return __assign(__assign({}, state), { metadata: action.payload });
|
|
88
|
+
return __assign(__assign({}, state), { metadata: action.payload || window.threekit.configurator.getMetadata() });
|
|
96
89
|
});
|
|
97
90
|
builder.addCase(exports.appendToCache, function (state, action) {
|
|
98
91
|
state.cache.push(action.payload);
|
|
@@ -125,9 +118,6 @@ var reducer = (0, toolkit_1.createSlice)({
|
|
|
125
118
|
},
|
|
126
119
|
reducers: {},
|
|
127
120
|
}).reducer;
|
|
128
|
-
/*****************************************************
|
|
129
|
-
* Standard Selectors
|
|
130
|
-
****************************************************/
|
|
131
121
|
var getProductId = function (state) {
|
|
132
122
|
return state.product.id;
|
|
133
123
|
};
|
|
@@ -136,12 +126,10 @@ var getName = function (state) {
|
|
|
136
126
|
return state.product.name;
|
|
137
127
|
};
|
|
138
128
|
exports.getName = getName;
|
|
139
|
-
// Metadata
|
|
140
129
|
var getMetadata = function (state) {
|
|
141
130
|
return state.product.metadata;
|
|
142
131
|
};
|
|
143
132
|
exports.getMetadata = getMetadata;
|
|
144
|
-
// Product Cache
|
|
145
133
|
var getActiveCacheIdx = function (state) {
|
|
146
134
|
return state.product.activeCacheIdx;
|
|
147
135
|
};
|
|
@@ -154,13 +142,12 @@ var getProductCache = function (state) {
|
|
|
154
142
|
});
|
|
155
143
|
};
|
|
156
144
|
exports.getProductCache = getProductCache;
|
|
157
|
-
/*****************************************************
|
|
158
|
-
* Complex Actions
|
|
159
|
-
****************************************************/
|
|
160
145
|
var initProduct = function (prods) {
|
|
161
146
|
return function (dispatch, getState) {
|
|
162
147
|
if (prods)
|
|
163
148
|
exports.PRODUCTS = prods;
|
|
149
|
+
if (!window.threekit)
|
|
150
|
+
return;
|
|
164
151
|
var state = getState();
|
|
165
152
|
var name = window.threekit.player.scene.get({
|
|
166
153
|
id: window.threekit.player.assetId,
|
|
@@ -182,7 +169,8 @@ var cacheActiveProduct = function (config) {
|
|
|
182
169
|
var thumbnail = config === null || config === void 0 ? void 0 : config.thumbnail;
|
|
183
170
|
var connectionObj = connection_1.default.getConnection();
|
|
184
171
|
delete connectionObj.threekitDomain;
|
|
185
|
-
var
|
|
172
|
+
var player = window.threekit.player.enableApi(types_1.PRIVATE_APIS.PLAYER);
|
|
173
|
+
var configuration = player.configurator.getFullConfiguration();
|
|
186
174
|
var data = { connection: connectionObj, configuration: configuration };
|
|
187
175
|
var product = Object.assign({
|
|
188
176
|
id: state.product.id,
|
|
@@ -203,19 +191,19 @@ var loadProduct = function (id, config) {
|
|
|
203
191
|
state = getState();
|
|
204
192
|
productsList = Object.keys(exports.PRODUCTS);
|
|
205
193
|
if (!productsList.includes(id))
|
|
206
|
-
return [2
|
|
194
|
+
return [2];
|
|
207
195
|
productConfig = exports.PRODUCTS[id][state.treble.threekitEnv];
|
|
208
196
|
dispatch((0, exports.setProductId)(id));
|
|
209
197
|
if (cacheProduct)
|
|
210
198
|
dispatch((0, exports.cacheActiveProduct)());
|
|
211
|
-
return [4
|
|
199
|
+
return [4, dispatch((0, treble_1.reloadPlayer)(productConfig))];
|
|
212
200
|
case 1:
|
|
213
201
|
_a.sent();
|
|
214
202
|
if (cacheProduct) {
|
|
215
203
|
dispatch((0, exports.incrementActiveCacheIdx)());
|
|
216
204
|
dispatch((0, exports.cacheActiveProduct)());
|
|
217
205
|
}
|
|
218
|
-
return [2
|
|
206
|
+
return [2];
|
|
219
207
|
}
|
|
220
208
|
});
|
|
221
209
|
}); };
|
|
@@ -238,14 +226,14 @@ var loadNewProduct = function (config) {
|
|
|
238
226
|
dispatch((0, exports.cacheActiveProduct)({ label: label, thumbnail: thumbnail }));
|
|
239
227
|
if (config)
|
|
240
228
|
dispatch((0, exports.setProductId)(undefined));
|
|
241
|
-
return [4
|
|
229
|
+
return [4, dispatch((0, treble_1.reloadPlayer)(config))];
|
|
242
230
|
case 1:
|
|
243
231
|
_a.sent();
|
|
244
232
|
if (shouldCacheProduct) {
|
|
245
233
|
dispatch((0, exports.incrementActiveCacheIdx)());
|
|
246
234
|
dispatch((0, exports.cacheActiveProduct)({ label: label, thumbnail: thumbnail }));
|
|
247
235
|
}
|
|
248
|
-
return [2
|
|
236
|
+
return [2];
|
|
249
237
|
}
|
|
250
238
|
});
|
|
251
239
|
}); };
|
|
@@ -260,20 +248,20 @@ var changeActiveCacheIdx = function (idx) {
|
|
|
260
248
|
state = getState();
|
|
261
249
|
cache = state.product.cache;
|
|
262
250
|
if (idx >= cache.length)
|
|
263
|
-
return [2
|
|
251
|
+
return [2, Promise.resolve()];
|
|
264
252
|
dispatch((0, exports.cacheActiveProduct)());
|
|
265
253
|
cachedProduct = __assign({}, state.product.cache[idx]);
|
|
266
254
|
data = JSON.parse(cachedProduct.data);
|
|
267
255
|
connection_1.default.connect(data.connection);
|
|
268
256
|
dispatch((0, exports.setActiveCacheIdx)(idx));
|
|
269
257
|
dispatch((0, exports.setProductId)(cachedProduct.id));
|
|
270
|
-
return [4
|
|
258
|
+
return [4, dispatch((0, treble_1.reloadPlayer)({
|
|
271
259
|
assetId: data.connection.assetId,
|
|
272
260
|
configuration: data.configuration,
|
|
273
261
|
}))];
|
|
274
262
|
case 1:
|
|
275
263
|
_a.sent();
|
|
276
|
-
return [2
|
|
264
|
+
return [2];
|
|
277
265
|
}
|
|
278
266
|
});
|
|
279
267
|
}); };
|
|
@@ -288,21 +276,21 @@ var removeProductIdx = function (idx) {
|
|
|
288
276
|
state = getState();
|
|
289
277
|
_a = state.product, cache = _a.cache, activeCacheIdx = _a.activeCacheIdx;
|
|
290
278
|
if (cache.length <= 1)
|
|
291
|
-
return [2
|
|
292
|
-
if (!(!idx || idx === activeCacheIdx)) return [3
|
|
293
|
-
if (!(activeCacheIdx === state.product.cache.length - 1)) return [3
|
|
294
|
-
return [4
|
|
279
|
+
return [2, Promise.resolve()];
|
|
280
|
+
if (!(!idx || idx === activeCacheIdx)) return [3, 5];
|
|
281
|
+
if (!(activeCacheIdx === state.product.cache.length - 1)) return [3, 2];
|
|
282
|
+
return [4, dispatch((0, exports.changeActiveCacheIdx)(activeCacheIdx - 1))];
|
|
295
283
|
case 1:
|
|
296
284
|
_b.sent();
|
|
297
285
|
dispatch((0, exports.removeFromCache)(activeCacheIdx));
|
|
298
|
-
return [3
|
|
286
|
+
return [3, 4];
|
|
299
287
|
case 2:
|
|
300
288
|
dispatch((0, exports.removeFromCache)(activeCacheIdx));
|
|
301
|
-
return [4
|
|
289
|
+
return [4, dispatch((0, exports.changeActiveCacheIdx)(activeCacheIdx))];
|
|
302
290
|
case 3:
|
|
303
291
|
_b.sent();
|
|
304
292
|
_b.label = 4;
|
|
305
|
-
case 4: return [3
|
|
293
|
+
case 4: return [3, 6];
|
|
306
294
|
case 5:
|
|
307
295
|
if (idx >= activeCacheIdx) {
|
|
308
296
|
dispatch((0, exports.removeFromCache)(idx));
|
|
@@ -312,7 +300,7 @@ var removeProductIdx = function (idx) {
|
|
|
312
300
|
dispatch((0, exports.removeFromCache)(idx));
|
|
313
301
|
}
|
|
314
302
|
_b.label = 6;
|
|
315
|
-
case 6: return [2
|
|
303
|
+
case 6: return [2, Promise.resolve()];
|
|
316
304
|
}
|
|
317
305
|
});
|
|
318
306
|
}); };
|
|
@@ -1,24 +1,12 @@
|
|
|
1
1
|
import { RootState, ThreekitDispatch } from './index';
|
|
2
2
|
import { ITranslationMap } from '../api/products';
|
|
3
|
-
/*****************************************************
|
|
4
|
-
* Types and Interfaces
|
|
5
|
-
****************************************************/
|
|
6
3
|
export interface TranslationsState {
|
|
7
4
|
language: string | undefined;
|
|
8
5
|
}
|
|
9
|
-
/*****************************************************
|
|
10
|
-
* Constants
|
|
11
|
-
****************************************************/
|
|
12
6
|
export declare let TRANSLATIONS: undefined | ITranslationMap;
|
|
13
|
-
/*****************************************************
|
|
14
|
-
* Actions
|
|
15
|
-
****************************************************/
|
|
16
7
|
export declare const setLanguage: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, string>;
|
|
17
|
-
export declare const initTranslations: (language?: string
|
|
8
|
+
export declare const initTranslations: (language?: string) => (dispatch: ThreekitDispatch) => Promise<void>;
|
|
18
9
|
declare const reducer: import("redux").Reducer<TranslationsState, import("redux").AnyAction>;
|
|
19
|
-
/*****************************************************
|
|
20
|
-
* Standard Selectors
|
|
21
|
-
****************************************************/
|
|
22
10
|
export declare const getLanguage: (state: RootState) => undefined | string;
|
|
23
11
|
export declare const getLanguageOptions: (state: RootState) => Array<string>;
|
|
24
12
|
export default reducer;
|
|
@@ -42,28 +42,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
42
42
|
exports.getLanguageOptions = exports.getLanguage = exports.initTranslations = exports.setLanguage = exports.TRANSLATIONS = void 0;
|
|
43
43
|
var toolkit_1 = require("@reduxjs/toolkit");
|
|
44
44
|
var api_1 = __importDefault(require("../api"));
|
|
45
|
-
/*****************************************************
|
|
46
|
-
* Actions
|
|
47
|
-
****************************************************/
|
|
48
45
|
exports.setLanguage = (0, toolkit_1.createAction)('treble/translations/set-language');
|
|
49
46
|
var initTranslations = function (language) { return function (dispatch) { return __awaiter(void 0, void 0, void 0, function () {
|
|
50
47
|
return __generator(this, function (_a) {
|
|
51
48
|
switch (_a.label) {
|
|
52
|
-
case 0: return [4
|
|
49
|
+
case 0: return [4, api_1.default.products.fetchTranslations()];
|
|
53
50
|
case 1:
|
|
54
51
|
exports.TRANSLATIONS = _a.sent();
|
|
55
52
|
if (language)
|
|
56
53
|
dispatch((0, exports.setLanguage)(language));
|
|
57
|
-
return [2
|
|
54
|
+
return [2];
|
|
58
55
|
}
|
|
59
56
|
});
|
|
60
57
|
}); }; };
|
|
61
58
|
exports.initTranslations = initTranslations;
|
|
62
|
-
/*****************************************************
|
|
63
|
-
* State
|
|
64
|
-
****************************************************/
|
|
65
59
|
var initialState = {
|
|
66
|
-
// Selected language
|
|
67
60
|
language: undefined,
|
|
68
61
|
};
|
|
69
62
|
var reducer = (0, toolkit_1.createSlice)({
|
|
@@ -76,9 +69,6 @@ var reducer = (0, toolkit_1.createSlice)({
|
|
|
76
69
|
},
|
|
77
70
|
reducers: {},
|
|
78
71
|
}).reducer;
|
|
79
|
-
/*****************************************************
|
|
80
|
-
* Standard Selectors
|
|
81
|
-
****************************************************/
|
|
82
72
|
var getLanguage = function (state) {
|
|
83
73
|
return state.translations.language;
|
|
84
74
|
};
|
package/dist/store/treble.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { RootState, ThreekitDispatch } from './index';
|
|
2
2
|
import { IProject, IPlayerConfig, IThreekitDisplayAttribute, ISetConfiguration, IConfiguration } from '../types';
|
|
3
|
-
/*****************************************************
|
|
4
|
-
* Types and Interfaces
|
|
5
|
-
****************************************************/
|
|
6
3
|
export interface IPlayerInit {
|
|
7
4
|
el: HTMLElement;
|
|
8
5
|
authToken: string;
|
|
@@ -48,32 +45,20 @@ export interface NotificationEvent extends Event {
|
|
|
48
45
|
interface EventHandlers {
|
|
49
46
|
postConfigurationChange?: (updatedAttributes: Array<IThreekitDisplayAttribute>, configurationChange: ISetConfiguration, previousConfiguration: Array<IThreekitDisplayAttribute>) => void | Promise<void>;
|
|
50
47
|
}
|
|
51
|
-
/*****************************************************
|
|
52
|
-
* Actions
|
|
53
|
-
****************************************************/
|
|
54
48
|
export declare const setThreekitEnv: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, string>;
|
|
55
49
|
export declare const setThreekitInitialized: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, string>;
|
|
56
50
|
export declare const setPlayerLoading: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, string>;
|
|
57
51
|
export declare const setPlayerElement: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, string>;
|
|
58
52
|
export declare const reloadTreble: import("@reduxjs/toolkit").ActionCreatorWithPayload<Partial<TrebleState>, string>;
|
|
59
53
|
export declare const updateLoadingProgress: import("@reduxjs/toolkit").ActionCreatorWithPayload<number, string>;
|
|
60
|
-
/*****************************************************
|
|
61
|
-
* Slice
|
|
62
|
-
****************************************************/
|
|
63
54
|
declare const reducer: import("redux").Reducer<TrebleState, import("redux").AnyAction>;
|
|
64
|
-
/*****************************************************
|
|
65
|
-
* Standard Selectors
|
|
66
|
-
****************************************************/
|
|
67
55
|
export declare const getThreekitEnv: (state: RootState) => string;
|
|
68
56
|
export declare const isThreekitInitialized: (state: RootState) => boolean;
|
|
69
57
|
export declare const isPlayerLoading: (state: RootState) => boolean;
|
|
70
58
|
export declare const getPlayerElementId: (state: RootState) => undefined | string;
|
|
71
59
|
export declare const getLoadingProgress: (state: RootState) => number;
|
|
72
|
-
/*****************************************************
|
|
73
|
-
* Complex Actions
|
|
74
|
-
****************************************************/
|
|
75
60
|
export declare const initPlayer: (config: IPlayerInit) => (dispatch: ThreekitDispatch, getState: () => RootState) => Promise<void>;
|
|
76
|
-
export declare const launch: (launchConfig?: Partial<ILaunchConfig>
|
|
61
|
+
export declare const launch: (launchConfig?: Partial<ILaunchConfig>) => (dispatch: ThreekitDispatch) => Promise<void>;
|
|
77
62
|
export declare const unloadPlayer: () => (dispatch: ThreekitDispatch) => Promise<void>;
|
|
78
63
|
export declare const reloadPlayer: (config: undefined | string | Pick<IReloadConfig, 'assetId' | 'stageId' | 'configurationId' | 'configuration'>) => (dispatch: ThreekitDispatch, getState: () => RootState) => Promise<void>;
|
|
79
64
|
export default reducer;
|