@threekit-tools/treble 0.0.47 → 0.0.51
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 +3 -1
- package/dist/Treble/Treble.js +14 -3
- 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/ThreekitProvider/index.d.ts +3 -1
- package/dist/components/ThreekitProvider/index.js +3 -3
- 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.d.ts +1 -1
- package/dist/hooks/useWishlist/index.js +8 -7
- package/dist/store/attributes.d.ts +20 -0
- package/dist/store/attributes.js +139 -0
- package/dist/store/index.d.ts +67 -7
- package/dist/store/index.js +36 -4
- package/dist/store/price.d.ts +33 -0
- package/dist/store/price.js +116 -0
- package/dist/store/product.d.ts +22 -0
- package/dist/store/product.js +65 -0
- package/dist/store/translations.d.ts +22 -0
- package/dist/store/translations.js +100 -0
- package/dist/store/treble.d.ts +41 -0
- package/dist/store/treble.js +257 -0
- package/dist/store/wishlist.d.ts +23 -0
- package/dist/store/wishlist.js +114 -0
- package/dist/threekit.d.ts +1 -1
- package/package.json +1 -1
- package/dist/store/threekit.d.ts +0 -68
- package/dist/store/threekit.js +0 -450
|
@@ -0,0 +1,139 @@
|
|
|
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
|
+
/*****************************************************
|
|
43
|
+
* Actions
|
|
44
|
+
****************************************************/
|
|
45
|
+
exports.setAttributes = (0, toolkit_1.createAction)('treble/attributes/set-attributes', function (attributes) {
|
|
46
|
+
var payload = attributes.reduce(function (output, attr) {
|
|
47
|
+
var _a;
|
|
48
|
+
return Object.assign(output, (_a = {}, _a[attr.name] = attr, _a));
|
|
49
|
+
}, {});
|
|
50
|
+
return { payload: payload };
|
|
51
|
+
});
|
|
52
|
+
/*****************************************************
|
|
53
|
+
* State and Data
|
|
54
|
+
****************************************************/
|
|
55
|
+
var initialState = {};
|
|
56
|
+
/*****************************************************
|
|
57
|
+
* Slice
|
|
58
|
+
****************************************************/
|
|
59
|
+
var reducer = (0, toolkit_1.createSlice)({
|
|
60
|
+
name: 'attributes',
|
|
61
|
+
initialState: initialState,
|
|
62
|
+
reducers: {},
|
|
63
|
+
extraReducers: function (builder) {
|
|
64
|
+
builder.addCase(treble_1.setThreekitInitialized, function () {
|
|
65
|
+
var attributes = window.threekit.configurator.getDisplayAttributes();
|
|
66
|
+
return attributes.reduce(function (output, attr) {
|
|
67
|
+
var _a;
|
|
68
|
+
return Object.assign(output, (_a = {}, _a[attr.name] = attr, _a));
|
|
69
|
+
}, {});
|
|
70
|
+
});
|
|
71
|
+
builder.addCase(exports.setAttributes, function (_, action) {
|
|
72
|
+
return action.payload;
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
}).reducer;
|
|
76
|
+
/*****************************************************
|
|
77
|
+
* Standard Selectors
|
|
78
|
+
****************************************************/
|
|
79
|
+
// Attributes
|
|
80
|
+
var getAttributes = function (state) {
|
|
81
|
+
var attributes = state.attributes;
|
|
82
|
+
var isThreekitInitialized = state.treble.isThreekitInitialized;
|
|
83
|
+
var _a = state.translations, language = _a.language, translations = _a.translations;
|
|
84
|
+
if (!isThreekitInitialized)
|
|
85
|
+
return undefined;
|
|
86
|
+
if (!attributes)
|
|
87
|
+
return undefined;
|
|
88
|
+
var hasTranslation = !!language && !!translations;
|
|
89
|
+
return Object.values(attributes).reduce(function (output, attribute) {
|
|
90
|
+
var _a;
|
|
91
|
+
var _b;
|
|
92
|
+
return Object.assign(output, (_a = {},
|
|
93
|
+
_a[attribute.name] = Object.assign({}, attribute, {
|
|
94
|
+
label: hasTranslation
|
|
95
|
+
? ((_b = translations === null || translations === void 0 ? void 0 : translations[attribute.name]) === null || _b === void 0 ? void 0 : _b[language]) || attribute.name
|
|
96
|
+
: attribute.name,
|
|
97
|
+
}, attribute.type === 'String'
|
|
98
|
+
? {
|
|
99
|
+
values: attribute.values.map(function (el) {
|
|
100
|
+
var _a;
|
|
101
|
+
return Object.assign({}, el, {
|
|
102
|
+
label: hasTranslation
|
|
103
|
+
? ((_a = translations === null || translations === void 0 ? void 0 : translations[el.label]) === null || _a === void 0 ? void 0 : _a[language]) || el.label
|
|
104
|
+
: el.label,
|
|
105
|
+
});
|
|
106
|
+
}),
|
|
107
|
+
}
|
|
108
|
+
: attribute.type === 'Asset'
|
|
109
|
+
? {
|
|
110
|
+
values: attribute.values.map(function (el) {
|
|
111
|
+
var _a;
|
|
112
|
+
return Object.assign({}, el, {
|
|
113
|
+
label: hasTranslation
|
|
114
|
+
? ((_a = translations === null || translations === void 0 ? void 0 : translations[el.name]) === null || _a === void 0 ? void 0 : _a[language]) || el.name
|
|
115
|
+
: el.name,
|
|
116
|
+
});
|
|
117
|
+
}),
|
|
118
|
+
}
|
|
119
|
+
: undefined),
|
|
120
|
+
_a));
|
|
121
|
+
}, {});
|
|
122
|
+
};
|
|
123
|
+
exports.getAttributes = getAttributes;
|
|
124
|
+
// Configurator
|
|
125
|
+
var setConfiguration = function (config) { return function (dispatch) { return __awaiter(void 0, void 0, void 0, function () {
|
|
126
|
+
return __generator(this, function (_a) {
|
|
127
|
+
switch (_a.label) {
|
|
128
|
+
case 0:
|
|
129
|
+
dispatch((0, treble_1.setPlayerLoading)(true));
|
|
130
|
+
return [4 /*yield*/, window.threekit.configurator.setConfiguration(config)];
|
|
131
|
+
case 1:
|
|
132
|
+
_a.sent();
|
|
133
|
+
dispatch((0, treble_1.setPlayerLoading)(false));
|
|
134
|
+
return [2 /*return*/];
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}); }; };
|
|
138
|
+
exports.setConfiguration = setConfiguration;
|
|
139
|
+
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,33 @@
|
|
|
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
|
+
export declare const initPrice: () => (dispatch: ThreekitDispatch) => Promise<void>;
|
|
24
|
+
declare const reducer: import("redux").Reducer<PriceState, import("redux").AnyAction>;
|
|
25
|
+
/*****************************************************
|
|
26
|
+
* Standard Selectors
|
|
27
|
+
****************************************************/
|
|
28
|
+
export declare const getPrice: (state: RootState) => undefined | IPrice;
|
|
29
|
+
/*****************************************************
|
|
30
|
+
* Complex Actions
|
|
31
|
+
****************************************************/
|
|
32
|
+
export declare const updatePrice: () => (dispatch: ThreekitDispatch, getState: () => RootState) => void;
|
|
33
|
+
export default reducer;
|
|
@@ -0,0 +1,116 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.updatePrice = exports.getPrice = exports.initPrice = exports.setPrice = exports.setPriceConfig = void 0;
|
|
43
|
+
var toolkit_1 = require("@reduxjs/toolkit");
|
|
44
|
+
var api_1 = __importDefault(require("../api"));
|
|
45
|
+
/*****************************************************
|
|
46
|
+
* Actions
|
|
47
|
+
****************************************************/
|
|
48
|
+
// Actions to be used only internally
|
|
49
|
+
exports.setPriceConfig = (0, toolkit_1.createAction)('treble/price/set-price-config');
|
|
50
|
+
exports.setPrice = (0, toolkit_1.createAction)('treble/price/set-price');
|
|
51
|
+
var initPrice = function () { return function (dispatch) { return __awaiter(void 0, void 0, void 0, function () {
|
|
52
|
+
var pricebook, id, currency, price;
|
|
53
|
+
return __generator(this, function (_a) {
|
|
54
|
+
switch (_a.label) {
|
|
55
|
+
case 0: return [4 /*yield*/, api_1.default.price.getPricebooksList()];
|
|
56
|
+
case 1:
|
|
57
|
+
pricebook = _a.sent();
|
|
58
|
+
id = pricebook[0].id;
|
|
59
|
+
currency = pricebook[0].currencies[0];
|
|
60
|
+
if (pricebook.length) {
|
|
61
|
+
dispatch((0, exports.setPriceConfig)({ id: id, currency: currency }));
|
|
62
|
+
price = window.threekit.configurator.getPrice(id, currency);
|
|
63
|
+
dispatch((0, exports.setPrice)(price));
|
|
64
|
+
}
|
|
65
|
+
return [2 /*return*/];
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}); }; };
|
|
69
|
+
exports.initPrice = initPrice;
|
|
70
|
+
/*****************************************************
|
|
71
|
+
* State
|
|
72
|
+
****************************************************/
|
|
73
|
+
var initialState = {
|
|
74
|
+
// Selected language
|
|
75
|
+
id: undefined,
|
|
76
|
+
currency: undefined,
|
|
77
|
+
price: undefined,
|
|
78
|
+
};
|
|
79
|
+
var reducer = (0, toolkit_1.createSlice)({
|
|
80
|
+
name: 'price',
|
|
81
|
+
initialState: initialState,
|
|
82
|
+
extraReducers: function (builder) {
|
|
83
|
+
builder.addCase(exports.setPriceConfig, function (state, action) {
|
|
84
|
+
var _a = action.payload, id = _a.id, currency = _a.currency;
|
|
85
|
+
state.id = id;
|
|
86
|
+
state.currency = currency;
|
|
87
|
+
return state;
|
|
88
|
+
});
|
|
89
|
+
builder.addCase(exports.setPrice, function (state, action) {
|
|
90
|
+
state.price = action.payload;
|
|
91
|
+
return state;
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
reducers: {},
|
|
95
|
+
}).reducer;
|
|
96
|
+
/*****************************************************
|
|
97
|
+
* Standard Selectors
|
|
98
|
+
****************************************************/
|
|
99
|
+
var getPrice = function (state) {
|
|
100
|
+
var _a = state.price, price = _a.price, currency = _a.currency;
|
|
101
|
+
if (!price || !currency)
|
|
102
|
+
return undefined;
|
|
103
|
+
return { price: price, currency: currency };
|
|
104
|
+
};
|
|
105
|
+
exports.getPrice = getPrice;
|
|
106
|
+
/*****************************************************
|
|
107
|
+
* Complex Actions
|
|
108
|
+
****************************************************/
|
|
109
|
+
var updatePrice = function () { return function (dispatch, getState) {
|
|
110
|
+
var price = getState().price;
|
|
111
|
+
if (!price.id || !price.currency)
|
|
112
|
+
return;
|
|
113
|
+
dispatch((0, exports.setPrice)(window.threekit.configurator.getPrice(price.id, price.currency)));
|
|
114
|
+
}; };
|
|
115
|
+
exports.updatePrice = updatePrice;
|
|
116
|
+
exports.default = reducer;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { RootState, ThreekitDispatch } 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
|
+
export declare const initProduct: () => (dispatch: ThreekitDispatch) => void;
|
|
16
|
+
declare const reducer: import("redux").Reducer<ProductState, import("redux").AnyAction>;
|
|
17
|
+
/*****************************************************
|
|
18
|
+
* Standard Selectors
|
|
19
|
+
****************************************************/
|
|
20
|
+
export declare const getName: (state: RootState) => undefined | string;
|
|
21
|
+
export declare const getMetadata: (state: RootState) => undefined | IMetadata;
|
|
22
|
+
export default reducer;
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.getMetadata = exports.getName = exports.initProduct = exports.setMetadata = exports.setName = void 0;
|
|
15
|
+
var toolkit_1 = require("@reduxjs/toolkit");
|
|
16
|
+
/*****************************************************
|
|
17
|
+
* Actions
|
|
18
|
+
****************************************************/
|
|
19
|
+
// Actions to be used only internally
|
|
20
|
+
exports.setName = (0, toolkit_1.createAction)('treble/product/set-name');
|
|
21
|
+
exports.setMetadata = (0, toolkit_1.createAction)('treble/product/set-metadata');
|
|
22
|
+
var initProduct = function () { return function (dispatch) {
|
|
23
|
+
var name = window.threekit.player.scene.get({
|
|
24
|
+
id: window.threekit.player.assetId,
|
|
25
|
+
}).name;
|
|
26
|
+
var metadata = window.threekit.configurator.getMetadata();
|
|
27
|
+
dispatch((0, exports.setName)(name));
|
|
28
|
+
dispatch((0, exports.setMetadata)(metadata));
|
|
29
|
+
}; };
|
|
30
|
+
exports.initProduct = initProduct;
|
|
31
|
+
/*****************************************************
|
|
32
|
+
* State
|
|
33
|
+
****************************************************/
|
|
34
|
+
var initialState = {
|
|
35
|
+
// Name of the Initialized Item
|
|
36
|
+
name: undefined,
|
|
37
|
+
// Initialized item's metadata
|
|
38
|
+
metadata: undefined,
|
|
39
|
+
};
|
|
40
|
+
var reducer = (0, toolkit_1.createSlice)({
|
|
41
|
+
name: 'product',
|
|
42
|
+
initialState: initialState,
|
|
43
|
+
extraReducers: function (builder) {
|
|
44
|
+
builder.addCase(exports.setName, function (state, action) {
|
|
45
|
+
return __assign(__assign({}, state), { name: action.payload });
|
|
46
|
+
});
|
|
47
|
+
builder.addCase(exports.setMetadata, function (state, action) {
|
|
48
|
+
return __assign(__assign({}, state), { metadata: action.payload });
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
reducers: {},
|
|
52
|
+
}).reducer;
|
|
53
|
+
/*****************************************************
|
|
54
|
+
* Standard Selectors
|
|
55
|
+
****************************************************/
|
|
56
|
+
var getName = function (state) {
|
|
57
|
+
return state.product.name;
|
|
58
|
+
};
|
|
59
|
+
exports.getName = getName;
|
|
60
|
+
// Metadata
|
|
61
|
+
var getMetadata = function (state) {
|
|
62
|
+
return state.product.metadata;
|
|
63
|
+
};
|
|
64
|
+
exports.getMetadata = getMetadata;
|
|
65
|
+
exports.default = reducer;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { RootState, ThreekitDispatch } 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
|
+
export declare const initTranslations: (language?: string | undefined) => (dispatch: ThreekitDispatch) => Promise<void>;
|
|
16
|
+
declare const reducer: import("redux").Reducer<TranslationsState, import("redux").AnyAction>;
|
|
17
|
+
/*****************************************************
|
|
18
|
+
* Standard Selectors
|
|
19
|
+
****************************************************/
|
|
20
|
+
export declare const getLanguage: (state: RootState) => undefined | string;
|
|
21
|
+
export declare const getLanguageOptions: (state: RootState) => Array<string>;
|
|
22
|
+
export default reducer;
|
|
@@ -0,0 +1,100 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.getLanguageOptions = exports.getLanguage = exports.initTranslations = exports.setLanguage = exports.setTranslations = void 0;
|
|
43
|
+
var toolkit_1 = require("@reduxjs/toolkit");
|
|
44
|
+
var api_1 = __importDefault(require("../api"));
|
|
45
|
+
/*****************************************************
|
|
46
|
+
* Actions
|
|
47
|
+
****************************************************/
|
|
48
|
+
// Actions to be used only internally
|
|
49
|
+
exports.setTranslations = (0, toolkit_1.createAction)('treble/translations/set-translations');
|
|
50
|
+
exports.setLanguage = (0, toolkit_1.createAction)('treble/translations/set-language');
|
|
51
|
+
var initTranslations = function (language) { return function (dispatch) { return __awaiter(void 0, void 0, void 0, function () {
|
|
52
|
+
var translations;
|
|
53
|
+
return __generator(this, function (_a) {
|
|
54
|
+
switch (_a.label) {
|
|
55
|
+
case 0: return [4 /*yield*/, api_1.default.products.fetchTranslations()];
|
|
56
|
+
case 1:
|
|
57
|
+
translations = _a.sent();
|
|
58
|
+
dispatch((0, exports.setTranslations)(translations));
|
|
59
|
+
if (language)
|
|
60
|
+
dispatch((0, exports.setLanguage)(language));
|
|
61
|
+
return [2 /*return*/];
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}); }; };
|
|
65
|
+
exports.initTranslations = initTranslations;
|
|
66
|
+
/*****************************************************
|
|
67
|
+
* State
|
|
68
|
+
****************************************************/
|
|
69
|
+
var initialState = {
|
|
70
|
+
// Selected language
|
|
71
|
+
translations: undefined,
|
|
72
|
+
language: undefined,
|
|
73
|
+
};
|
|
74
|
+
var reducer = (0, toolkit_1.createSlice)({
|
|
75
|
+
name: 'translations',
|
|
76
|
+
initialState: initialState,
|
|
77
|
+
extraReducers: function (builder) {
|
|
78
|
+
builder.addCase(exports.setTranslations, function (state, action) {
|
|
79
|
+
state.translations = action.payload;
|
|
80
|
+
});
|
|
81
|
+
builder.addCase(exports.setLanguage, function (state, action) {
|
|
82
|
+
state.language = action.payload;
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
reducers: {},
|
|
86
|
+
}).reducer;
|
|
87
|
+
/*****************************************************
|
|
88
|
+
* Standard Selectors
|
|
89
|
+
****************************************************/
|
|
90
|
+
var getLanguage = function (state) {
|
|
91
|
+
return state.translations.language;
|
|
92
|
+
};
|
|
93
|
+
exports.getLanguage = getLanguage;
|
|
94
|
+
var getLanguageOptions = function (state) {
|
|
95
|
+
if (!state.treble.isThreekitInitialized || !state.translations.translations)
|
|
96
|
+
return [];
|
|
97
|
+
return Object.keys(Object.values(state.translations.translations)[0]);
|
|
98
|
+
};
|
|
99
|
+
exports.getLanguageOptions = getLanguageOptions;
|
|
100
|
+
exports.default = reducer;
|