@threekit-tools/treble 0.0.46 → 0.0.50
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/Snapshots.js +0 -26
- package/dist/Treble/Treble.d.ts +2 -1
- package/dist/Treble/Treble.js +2 -2
- package/dist/Treble/Wishlist.d.ts +3 -2
- package/dist/Treble/Wishlist.js +12 -12
- package/dist/components/Accordion/index.d.ts +1 -1
- package/dist/components/Player/index.js +5 -3
- package/dist/components/Tabs/index.d.ts +4 -7
- package/dist/components/ThreekitProvider/index.d.ts +3 -1
- package/dist/components/ThreekitProvider/index.js +3 -3
- package/dist/components/TrebleApp/index.js +2 -2
- package/dist/components/containers/formInputContainer.d.ts +1 -1
- package/dist/hooks/useAttribute/index.js +3 -3
- package/dist/hooks/useConfigurator/index.js +3 -3
- package/dist/hooks/useMetadata/index.js +2 -2
- package/dist/hooks/useName/index.js +2 -2
- package/dist/hooks/usePlayerLoadingStatus/index.js +2 -2
- package/dist/hooks/usePlayerPortal/index.js +2 -3
- package/dist/hooks/usePrice/index.d.ts +1 -1
- package/dist/hooks/usePrice/index.js +2 -2
- package/dist/hooks/useShare/index.js +2 -2
- package/dist/hooks/useSnapshot/index.js +2 -2
- package/dist/hooks/useThreekitInitStatus/index.js +2 -2
- package/dist/hooks/useWishlist/index.js +8 -7
- package/dist/store/attributes.d.ts +20 -0
- package/dist/store/attributes.js +135 -0
- package/dist/store/index.d.ts +67 -7
- package/dist/store/index.js +36 -4
- package/dist/store/price.d.ts +32 -0
- package/dist/store/price.js +56 -0
- package/dist/store/product.d.ts +21 -0
- package/dist/store/product.js +46 -0
- package/dist/store/translations.d.ts +21 -0
- package/dist/store/translations.js +46 -0
- package/dist/store/treble.d.ts +41 -0
- package/dist/store/{threekit.js → treble.js} +53 -224
- package/dist/store/wishlist.d.ts +24 -0
- package/dist/store/wishlist.js +101 -0
- package/dist/threekit.d.ts +1 -1
- package/package.json +1 -1
- package/dist/store/threekit.d.ts +0 -68
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.setConfiguration = exports.getAttributes = exports.setAttributes = void 0;
|
|
40
|
+
var toolkit_1 = require("@reduxjs/toolkit");
|
|
41
|
+
var treble_1 = require("./treble");
|
|
42
|
+
// export interface AttributesState {
|
|
43
|
+
// attributes: Record<string, IThreekitDisplayAttribute>;
|
|
44
|
+
// }
|
|
45
|
+
/*****************************************************
|
|
46
|
+
* Actions
|
|
47
|
+
****************************************************/
|
|
48
|
+
exports.setAttributes = (0, toolkit_1.createAction)('setAttributes');
|
|
49
|
+
/*****************************************************
|
|
50
|
+
* State and Data
|
|
51
|
+
****************************************************/
|
|
52
|
+
var initialState = {};
|
|
53
|
+
/*****************************************************
|
|
54
|
+
* Slice
|
|
55
|
+
****************************************************/
|
|
56
|
+
var reducer = (0, toolkit_1.createSlice)({
|
|
57
|
+
name: 'attributes',
|
|
58
|
+
initialState: initialState,
|
|
59
|
+
reducers: {},
|
|
60
|
+
extraReducers: function (builder) {
|
|
61
|
+
builder.addCase(exports.setAttributes, function (state, action) {
|
|
62
|
+
state = action.payload.reduce(function (output, attr) {
|
|
63
|
+
var _a;
|
|
64
|
+
return Object.assign(output, (_a = {}, _a[attr.name] = attr, _a));
|
|
65
|
+
}, {});
|
|
66
|
+
return state;
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
}).reducer;
|
|
70
|
+
/*****************************************************
|
|
71
|
+
* Standard Selectors
|
|
72
|
+
****************************************************/
|
|
73
|
+
// Attributes
|
|
74
|
+
var getAttributes = function (state) {
|
|
75
|
+
// const { isThreekitLoaded, attributes, language, translations } =
|
|
76
|
+
// state.threekit;
|
|
77
|
+
var attributes = state.attributes;
|
|
78
|
+
var isThreekitInitialized = state.treble.isThreekitInitialized;
|
|
79
|
+
var _a = state.translations, language = _a.language, translations = _a.translations;
|
|
80
|
+
if (!isThreekitInitialized)
|
|
81
|
+
return undefined;
|
|
82
|
+
if (!attributes)
|
|
83
|
+
return undefined;
|
|
84
|
+
var hasTranslation = !!language && !!translations;
|
|
85
|
+
return Object.values(attributes).reduce(function (output, attribute) {
|
|
86
|
+
var _a;
|
|
87
|
+
var _b;
|
|
88
|
+
return Object.assign(output, (_a = {},
|
|
89
|
+
_a[attribute.name] = Object.assign({}, attribute, {
|
|
90
|
+
label: hasTranslation
|
|
91
|
+
? ((_b = translations === null || translations === void 0 ? void 0 : translations[attribute.name]) === null || _b === void 0 ? void 0 : _b[language]) || attribute.name
|
|
92
|
+
: attribute.name,
|
|
93
|
+
}, attribute.type === 'String'
|
|
94
|
+
? {
|
|
95
|
+
values: attribute.values.map(function (el) {
|
|
96
|
+
var _a;
|
|
97
|
+
return Object.assign({}, el, {
|
|
98
|
+
label: hasTranslation
|
|
99
|
+
? ((_a = translations === null || translations === void 0 ? void 0 : translations[el.label]) === null || _a === void 0 ? void 0 : _a[language]) || el.label
|
|
100
|
+
: el.label,
|
|
101
|
+
});
|
|
102
|
+
}),
|
|
103
|
+
}
|
|
104
|
+
: attribute.type === 'Asset'
|
|
105
|
+
? {
|
|
106
|
+
values: attribute.values.map(function (el) {
|
|
107
|
+
var _a;
|
|
108
|
+
return Object.assign({}, el, {
|
|
109
|
+
label: hasTranslation
|
|
110
|
+
? ((_a = translations === null || translations === void 0 ? void 0 : translations[el.name]) === null || _a === void 0 ? void 0 : _a[language]) || el.name
|
|
111
|
+
: el.name,
|
|
112
|
+
});
|
|
113
|
+
}),
|
|
114
|
+
}
|
|
115
|
+
: undefined),
|
|
116
|
+
_a));
|
|
117
|
+
}, {});
|
|
118
|
+
};
|
|
119
|
+
exports.getAttributes = getAttributes;
|
|
120
|
+
// Configurator
|
|
121
|
+
var setConfiguration = function (config) { return function (dispatch) { return __awaiter(void 0, void 0, void 0, function () {
|
|
122
|
+
return __generator(this, function (_a) {
|
|
123
|
+
switch (_a.label) {
|
|
124
|
+
case 0:
|
|
125
|
+
dispatch((0, treble_1.setPlayerLoading)(true));
|
|
126
|
+
return [4 /*yield*/, window.threekit.configurator.setConfiguration(config)];
|
|
127
|
+
case 1:
|
|
128
|
+
_a.sent();
|
|
129
|
+
dispatch((0, treble_1.setPlayerLoading)(false));
|
|
130
|
+
return [2 /*return*/];
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}); }; };
|
|
134
|
+
exports.setConfiguration = setConfiguration;
|
|
135
|
+
exports.default = reducer;
|
package/dist/store/index.d.ts
CHANGED
|
@@ -1,19 +1,79 @@
|
|
|
1
1
|
import { TypedUseSelectorHook } from 'react-redux';
|
|
2
|
+
import { Reducer } from 'redux';
|
|
2
3
|
declare const store: import("@reduxjs/toolkit").EnhancedStore<{
|
|
3
|
-
|
|
4
|
+
treble: import("./treble").TrebleState;
|
|
5
|
+
product: import("./product").ProductState;
|
|
6
|
+
attributes: import("./attributes").AttributesState;
|
|
7
|
+
translations: import("./translations").TranslationsState;
|
|
8
|
+
wishlist: import("../Treble").WishlistArray;
|
|
9
|
+
price: import("./price").PriceState;
|
|
4
10
|
}, import("redux").AnyAction, import("@reduxjs/toolkit").MiddlewareArray<import("redux").Middleware<{}, any, import("redux").Dispatch<import("redux").AnyAction>> | import("redux-thunk").ThunkMiddleware<{
|
|
5
|
-
|
|
11
|
+
treble: import("./treble").TrebleState;
|
|
12
|
+
product: import("./product").ProductState;
|
|
13
|
+
attributes: import("./attributes").AttributesState;
|
|
14
|
+
translations: import("./translations").TranslationsState;
|
|
15
|
+
wishlist: import("../Treble").WishlistArray;
|
|
16
|
+
price: import("./price").PriceState;
|
|
6
17
|
}, import("redux").AnyAction, null> | import("redux-thunk").ThunkMiddleware<{
|
|
7
|
-
|
|
18
|
+
treble: import("./treble").TrebleState;
|
|
19
|
+
product: import("./product").ProductState;
|
|
20
|
+
attributes: import("./attributes").AttributesState;
|
|
21
|
+
translations: import("./translations").TranslationsState;
|
|
22
|
+
wishlist: import("../Treble").WishlistArray;
|
|
23
|
+
price: import("./price").PriceState;
|
|
8
24
|
}, import("redux").AnyAction, undefined> | import("redux").Middleware<{}, {
|
|
9
|
-
|
|
25
|
+
treble: import("./treble").TrebleState;
|
|
26
|
+
product: import("./product").ProductState;
|
|
27
|
+
attributes: import("./attributes").AttributesState;
|
|
28
|
+
translations: import("./translations").TranslationsState;
|
|
29
|
+
wishlist: import("../Treble").WishlistArray;
|
|
30
|
+
price: import("./price").PriceState;
|
|
31
|
+
}, import("redux").Dispatch<import("redux").AnyAction>>>>;
|
|
32
|
+
export declare const createStore: (reducer?: Record<string, Reducer<any, import("redux").AnyAction>> | undefined) => import("@reduxjs/toolkit").EnhancedStore<{
|
|
33
|
+
treble: import("./treble").TrebleState;
|
|
34
|
+
product: import("./product").ProductState;
|
|
35
|
+
attributes: import("./attributes").AttributesState;
|
|
36
|
+
translations: import("./translations").TranslationsState;
|
|
37
|
+
wishlist: import("../Treble").WishlistArray;
|
|
38
|
+
price: import("./price").PriceState;
|
|
39
|
+
}, import("redux").AnyAction, import("@reduxjs/toolkit").MiddlewareArray<import("redux").Middleware<{}, any, import("redux").Dispatch<import("redux").AnyAction>> | import("redux-thunk").ThunkMiddleware<{
|
|
40
|
+
treble: import("./treble").TrebleState;
|
|
41
|
+
product: import("./product").ProductState;
|
|
42
|
+
attributes: import("./attributes").AttributesState;
|
|
43
|
+
translations: import("./translations").TranslationsState;
|
|
44
|
+
wishlist: import("../Treble").WishlistArray;
|
|
45
|
+
price: import("./price").PriceState;
|
|
46
|
+
}, import("redux").AnyAction, null> | import("redux-thunk").ThunkMiddleware<{
|
|
47
|
+
treble: import("./treble").TrebleState;
|
|
48
|
+
product: import("./product").ProductState;
|
|
49
|
+
attributes: import("./attributes").AttributesState;
|
|
50
|
+
translations: import("./translations").TranslationsState;
|
|
51
|
+
wishlist: import("../Treble").WishlistArray;
|
|
52
|
+
price: import("./price").PriceState;
|
|
53
|
+
}, import("redux").AnyAction, undefined> | import("redux").Middleware<{}, {
|
|
54
|
+
treble: import("./treble").TrebleState;
|
|
55
|
+
product: import("./product").ProductState;
|
|
56
|
+
attributes: import("./attributes").AttributesState;
|
|
57
|
+
translations: import("./translations").TranslationsState;
|
|
58
|
+
wishlist: import("../Treble").WishlistArray;
|
|
59
|
+
price: import("./price").PriceState;
|
|
10
60
|
}, import("redux").Dispatch<import("redux").AnyAction>>>>;
|
|
11
61
|
export declare type RootState = ReturnType<typeof store.getState>;
|
|
12
62
|
export declare type ThreekitDispatch = typeof store.dispatch;
|
|
13
63
|
export declare const useThreekitDispatch: () => import("redux").Dispatch<import("redux").AnyAction> & import("@reduxjs/toolkit").ThunkDispatch<{
|
|
14
|
-
|
|
64
|
+
treble: import("./treble").TrebleState;
|
|
65
|
+
product: import("./product").ProductState;
|
|
66
|
+
attributes: import("./attributes").AttributesState;
|
|
67
|
+
translations: import("./translations").TranslationsState;
|
|
68
|
+
wishlist: import("../Treble").WishlistArray;
|
|
69
|
+
price: import("./price").PriceState;
|
|
15
70
|
}, null, import("redux").AnyAction> & import("@reduxjs/toolkit").ThunkDispatch<{
|
|
16
|
-
|
|
71
|
+
treble: import("./treble").TrebleState;
|
|
72
|
+
product: import("./product").ProductState;
|
|
73
|
+
attributes: import("./attributes").AttributesState;
|
|
74
|
+
translations: import("./translations").TranslationsState;
|
|
75
|
+
wishlist: import("../Treble").WishlistArray;
|
|
76
|
+
price: import("./price").PriceState;
|
|
17
77
|
}, undefined, import("redux").AnyAction>;
|
|
18
78
|
export declare const useThreekitSelector: TypedUseSelectorHook<RootState>;
|
|
19
|
-
export default
|
|
79
|
+
export default createStore;
|
package/dist/store/index.js
CHANGED
|
@@ -1,18 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
15
|
};
|
|
5
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.useThreekitSelector = exports.useThreekitDispatch = void 0;
|
|
17
|
+
exports.useThreekitSelector = exports.useThreekitDispatch = exports.createStore = void 0;
|
|
7
18
|
var toolkit_1 = require("@reduxjs/toolkit");
|
|
8
19
|
var react_redux_1 = require("react-redux");
|
|
9
20
|
var redux_logger_1 = __importDefault(require("redux-logger"));
|
|
10
|
-
var
|
|
21
|
+
var treble_1 = __importDefault(require("./treble"));
|
|
22
|
+
var product_1 = __importDefault(require("./product"));
|
|
23
|
+
var attributes_1 = __importDefault(require("./attributes"));
|
|
24
|
+
var wishlist_1 = __importDefault(require("./wishlist"));
|
|
25
|
+
var translations_1 = __importDefault(require("./translations"));
|
|
26
|
+
var price_1 = __importDefault(require("./price"));
|
|
11
27
|
var store = (0, toolkit_1.configureStore)({
|
|
12
|
-
reducer: {
|
|
28
|
+
reducer: {
|
|
29
|
+
treble: treble_1.default,
|
|
30
|
+
product: product_1.default,
|
|
31
|
+
attributes: attributes_1.default,
|
|
32
|
+
translations: translations_1.default,
|
|
33
|
+
wishlist: wishlist_1.default,
|
|
34
|
+
price: price_1.default,
|
|
35
|
+
},
|
|
13
36
|
middleware: function (getDefaultMiddleware) { return getDefaultMiddleware().concat(redux_logger_1.default); },
|
|
14
37
|
});
|
|
38
|
+
var createStore = function (reducer) {
|
|
39
|
+
if (!reducer)
|
|
40
|
+
return store;
|
|
41
|
+
return (0, toolkit_1.configureStore)({
|
|
42
|
+
reducer: __assign(__assign({}, reducer), { treble: treble_1.default, product: product_1.default, attributes: attributes_1.default, translations: translations_1.default, wishlist: wishlist_1.default, price: price_1.default }),
|
|
43
|
+
middleware: function (getDefaultMiddleware) { return getDefaultMiddleware().concat(redux_logger_1.default); },
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
exports.createStore = createStore;
|
|
15
47
|
var useThreekitDispatch = function () { return (0, react_redux_1.useDispatch)(); };
|
|
16
48
|
exports.useThreekitDispatch = useThreekitDispatch;
|
|
17
49
|
exports.useThreekitSelector = react_redux_1.useSelector;
|
|
18
|
-
exports.default =
|
|
50
|
+
exports.default = exports.createStore;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { RootState, ThreekitDispatch } from './index';
|
|
2
|
+
/*****************************************************
|
|
3
|
+
* Types and Interfaces
|
|
4
|
+
****************************************************/
|
|
5
|
+
export interface PriceState {
|
|
6
|
+
id: undefined | string;
|
|
7
|
+
currency: undefined | string;
|
|
8
|
+
price: undefined | number;
|
|
9
|
+
}
|
|
10
|
+
export interface IPriceConfig {
|
|
11
|
+
id: string;
|
|
12
|
+
currency: string;
|
|
13
|
+
}
|
|
14
|
+
export interface IPrice {
|
|
15
|
+
currency: string;
|
|
16
|
+
price: number;
|
|
17
|
+
}
|
|
18
|
+
/*****************************************************
|
|
19
|
+
* Actions
|
|
20
|
+
****************************************************/
|
|
21
|
+
export declare const setPriceConfig: import("@reduxjs/toolkit").ActionCreatorWithPayload<IPriceConfig, string>;
|
|
22
|
+
export declare const setPrice: import("@reduxjs/toolkit").ActionCreatorWithPayload<number, string>;
|
|
23
|
+
declare const reducer: import("redux").Reducer<PriceState, import("redux").AnyAction>;
|
|
24
|
+
/*****************************************************
|
|
25
|
+
* Standard Selectors
|
|
26
|
+
****************************************************/
|
|
27
|
+
export declare const getPrice: (state: RootState) => undefined | IPrice;
|
|
28
|
+
/*****************************************************
|
|
29
|
+
* Complex Actions
|
|
30
|
+
****************************************************/
|
|
31
|
+
export declare const updatePrice: () => (dispatch: ThreekitDispatch, getState: () => RootState) => void;
|
|
32
|
+
export default reducer;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updatePrice = exports.getPrice = exports.setPrice = exports.setPriceConfig = void 0;
|
|
4
|
+
var toolkit_1 = require("@reduxjs/toolkit");
|
|
5
|
+
/*****************************************************
|
|
6
|
+
* Actions
|
|
7
|
+
****************************************************/
|
|
8
|
+
// Actions to be used only internally
|
|
9
|
+
exports.setPriceConfig = (0, toolkit_1.createAction)('setPriceConfig');
|
|
10
|
+
exports.setPrice = (0, toolkit_1.createAction)('setPrice');
|
|
11
|
+
/*****************************************************
|
|
12
|
+
* State
|
|
13
|
+
****************************************************/
|
|
14
|
+
var initialState = {
|
|
15
|
+
// Selected language
|
|
16
|
+
id: undefined,
|
|
17
|
+
currency: undefined,
|
|
18
|
+
price: undefined,
|
|
19
|
+
};
|
|
20
|
+
var reducer = (0, toolkit_1.createSlice)({
|
|
21
|
+
name: 'price',
|
|
22
|
+
initialState: initialState,
|
|
23
|
+
extraReducers: function (builder) {
|
|
24
|
+
builder.addCase(exports.setPriceConfig, function (state, action) {
|
|
25
|
+
var _a = action.payload, id = _a.id, currency = _a.currency;
|
|
26
|
+
state.id = id;
|
|
27
|
+
state.currency = currency;
|
|
28
|
+
state.price = window.threekit.configurator.getPrice(id, currency);
|
|
29
|
+
});
|
|
30
|
+
builder.addCase(exports.setPrice, function (state, action) {
|
|
31
|
+
state.price = action.payload;
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
reducers: {},
|
|
35
|
+
}).reducer;
|
|
36
|
+
/*****************************************************
|
|
37
|
+
* Standard Selectors
|
|
38
|
+
****************************************************/
|
|
39
|
+
var getPrice = function (state) {
|
|
40
|
+
var _a = state.price, price = _a.price, currency = _a.currency;
|
|
41
|
+
if (!price || !currency)
|
|
42
|
+
return undefined;
|
|
43
|
+
return { price: price, currency: currency };
|
|
44
|
+
};
|
|
45
|
+
exports.getPrice = getPrice;
|
|
46
|
+
/*****************************************************
|
|
47
|
+
* Complex Actions
|
|
48
|
+
****************************************************/
|
|
49
|
+
var updatePrice = function () { return function (dispatch, getState) {
|
|
50
|
+
var price = getState().price;
|
|
51
|
+
if (!price.id || !price.currency)
|
|
52
|
+
return;
|
|
53
|
+
dispatch((0, exports.setPrice)(window.threekit.configurator.getPrice(price.id, price.currency)));
|
|
54
|
+
}; };
|
|
55
|
+
exports.updatePrice = updatePrice;
|
|
56
|
+
exports.default = reducer;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RootState } from './index';
|
|
2
|
+
import { IMetadata } from '../threekit';
|
|
3
|
+
/*****************************************************
|
|
4
|
+
* Types and Interfaces
|
|
5
|
+
****************************************************/
|
|
6
|
+
export interface ProductState {
|
|
7
|
+
name: undefined | string;
|
|
8
|
+
metadata: undefined | IMetadata;
|
|
9
|
+
}
|
|
10
|
+
/*****************************************************
|
|
11
|
+
* Actions
|
|
12
|
+
****************************************************/
|
|
13
|
+
export declare const setName: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, string>;
|
|
14
|
+
export declare const setMetadata: import("@reduxjs/toolkit").ActionCreatorWithPayload<IMetadata, string>;
|
|
15
|
+
declare const reducer: import("redux").Reducer<ProductState, import("redux").AnyAction>;
|
|
16
|
+
/*****************************************************
|
|
17
|
+
* Standard Selectors
|
|
18
|
+
****************************************************/
|
|
19
|
+
export declare const getName: (state: RootState) => undefined | string;
|
|
20
|
+
export declare const getMetadata: (state: RootState) => undefined | IMetadata;
|
|
21
|
+
export default reducer;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMetadata = exports.getName = exports.setMetadata = exports.setName = void 0;
|
|
4
|
+
var toolkit_1 = require("@reduxjs/toolkit");
|
|
5
|
+
/*****************************************************
|
|
6
|
+
* Actions
|
|
7
|
+
****************************************************/
|
|
8
|
+
// Actions to be used only internally
|
|
9
|
+
exports.setName = (0, toolkit_1.createAction)('setName');
|
|
10
|
+
exports.setMetadata = (0, toolkit_1.createAction)('setMetadata');
|
|
11
|
+
/*****************************************************
|
|
12
|
+
* State
|
|
13
|
+
****************************************************/
|
|
14
|
+
var initialState = {
|
|
15
|
+
// Name of the Initialized Item
|
|
16
|
+
name: undefined,
|
|
17
|
+
// Initialized item's metadata
|
|
18
|
+
metadata: undefined,
|
|
19
|
+
};
|
|
20
|
+
var reducer = (0, toolkit_1.createSlice)({
|
|
21
|
+
name: 'product',
|
|
22
|
+
initialState: initialState,
|
|
23
|
+
extraReducers: function (builder) {
|
|
24
|
+
// Language
|
|
25
|
+
builder.addCase(exports.setName, function (state, action) {
|
|
26
|
+
state.name = action.payload;
|
|
27
|
+
});
|
|
28
|
+
builder.addCase(exports.setMetadata, function (state, action) {
|
|
29
|
+
state.metadata = action.payload;
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
reducers: {},
|
|
33
|
+
}).reducer;
|
|
34
|
+
/*****************************************************
|
|
35
|
+
* Standard Selectors
|
|
36
|
+
****************************************************/
|
|
37
|
+
var getName = function (state) {
|
|
38
|
+
return state.product.name;
|
|
39
|
+
};
|
|
40
|
+
exports.getName = getName;
|
|
41
|
+
// Metadata
|
|
42
|
+
var getMetadata = function (state) {
|
|
43
|
+
return state.product.metadata;
|
|
44
|
+
};
|
|
45
|
+
exports.getMetadata = getMetadata;
|
|
46
|
+
exports.default = reducer;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RootState } from './index';
|
|
2
|
+
import { ITranslationMap } from '../api/products';
|
|
3
|
+
/*****************************************************
|
|
4
|
+
* Types and Interfaces
|
|
5
|
+
****************************************************/
|
|
6
|
+
export interface TranslationsState {
|
|
7
|
+
translations: undefined | ITranslationMap;
|
|
8
|
+
language: string | undefined;
|
|
9
|
+
}
|
|
10
|
+
/*****************************************************
|
|
11
|
+
* Actions
|
|
12
|
+
****************************************************/
|
|
13
|
+
export declare const setTranslations: import("@reduxjs/toolkit").ActionCreatorWithPayload<ITranslationMap, string>;
|
|
14
|
+
export declare const setLanguage: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, string>;
|
|
15
|
+
declare const reducer: import("redux").Reducer<TranslationsState, import("redux").AnyAction>;
|
|
16
|
+
/*****************************************************
|
|
17
|
+
* Standard Selectors
|
|
18
|
+
****************************************************/
|
|
19
|
+
export declare const getLanguage: (state: RootState) => undefined | string;
|
|
20
|
+
export declare const getLanguageOptions: (state: RootState) => Array<string>;
|
|
21
|
+
export default reducer;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getLanguageOptions = exports.getLanguage = exports.setLanguage = exports.setTranslations = void 0;
|
|
4
|
+
var toolkit_1 = require("@reduxjs/toolkit");
|
|
5
|
+
/*****************************************************
|
|
6
|
+
* Actions
|
|
7
|
+
****************************************************/
|
|
8
|
+
// Actions to be used only internally
|
|
9
|
+
exports.setTranslations = (0, toolkit_1.createAction)('setTranslations');
|
|
10
|
+
exports.setLanguage = (0, toolkit_1.createAction)('setLanguage');
|
|
11
|
+
/*****************************************************
|
|
12
|
+
* State
|
|
13
|
+
****************************************************/
|
|
14
|
+
var initialState = {
|
|
15
|
+
// Selected language
|
|
16
|
+
translations: undefined,
|
|
17
|
+
language: undefined,
|
|
18
|
+
};
|
|
19
|
+
var reducer = (0, toolkit_1.createSlice)({
|
|
20
|
+
name: 'translations',
|
|
21
|
+
initialState: initialState,
|
|
22
|
+
extraReducers: function (builder) {
|
|
23
|
+
// Language
|
|
24
|
+
builder.addCase(exports.setTranslations, function (state, action) {
|
|
25
|
+
state.translations = action.payload;
|
|
26
|
+
});
|
|
27
|
+
builder.addCase(exports.setLanguage, function (state, action) {
|
|
28
|
+
state.language = action.payload;
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
reducers: {},
|
|
32
|
+
}).reducer;
|
|
33
|
+
/*****************************************************
|
|
34
|
+
* Standard Selectors
|
|
35
|
+
****************************************************/
|
|
36
|
+
var getLanguage = function (state) {
|
|
37
|
+
return state.translations.language;
|
|
38
|
+
};
|
|
39
|
+
exports.getLanguage = getLanguage;
|
|
40
|
+
var getLanguageOptions = function (state) {
|
|
41
|
+
if (!state.treble.isThreekitInitialized || !state.translations.translations)
|
|
42
|
+
return [];
|
|
43
|
+
return Object.keys(Object.values(state.translations.translations)[0]);
|
|
44
|
+
};
|
|
45
|
+
exports.getLanguageOptions = getLanguageOptions;
|
|
46
|
+
exports.default = reducer;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { RootState, ThreekitDispatch } from './index';
|
|
2
|
+
import { IProject, IPlayerConfig, IThreekitDisplayAttribute, ISetConfiguration } from '../threekit';
|
|
3
|
+
/*****************************************************
|
|
4
|
+
* Types and Interfaces
|
|
5
|
+
****************************************************/
|
|
6
|
+
export interface ILaunchConfig {
|
|
7
|
+
threekitEnv: string;
|
|
8
|
+
locale: string;
|
|
9
|
+
project: IProject;
|
|
10
|
+
playerConfig: IPlayerConfig;
|
|
11
|
+
eventHandlers: EventHandlers;
|
|
12
|
+
}
|
|
13
|
+
export interface TrebleState {
|
|
14
|
+
isPlayerLoading: boolean;
|
|
15
|
+
isThreekitInitialized: boolean;
|
|
16
|
+
playerElId: undefined | string;
|
|
17
|
+
}
|
|
18
|
+
interface EventHandlers {
|
|
19
|
+
postConfigurationChange?: (updatedAttributes: Array<IThreekitDisplayAttribute>, configurationChange: ISetConfiguration, previousConfiguration: Array<IThreekitDisplayAttribute>) => void | Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
/*****************************************************
|
|
22
|
+
* Actions
|
|
23
|
+
****************************************************/
|
|
24
|
+
export declare const setThreekitInitialized: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<undefined, string>;
|
|
25
|
+
export declare const setPlayerLoading: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, string>;
|
|
26
|
+
export declare const setPlayerElement: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, string>;
|
|
27
|
+
/*****************************************************
|
|
28
|
+
* Slice
|
|
29
|
+
****************************************************/
|
|
30
|
+
declare const reducer: import("redux").Reducer<TrebleState, import("redux").AnyAction>;
|
|
31
|
+
/*****************************************************
|
|
32
|
+
* Standard Selectors
|
|
33
|
+
****************************************************/
|
|
34
|
+
export declare const isThreekitInitialized: (state: RootState) => boolean;
|
|
35
|
+
export declare const isPlayerLoading: (state: RootState) => boolean;
|
|
36
|
+
export declare const getPlayerElementId: (state: RootState) => undefined | string;
|
|
37
|
+
/*****************************************************
|
|
38
|
+
* Complex Actions
|
|
39
|
+
****************************************************/
|
|
40
|
+
export declare const launch: (launchConfig?: Partial<ILaunchConfig> | undefined) => (dispatch: ThreekitDispatch) => Promise<void>;
|
|
41
|
+
export default reducer;
|