@threekit-tools/treble 0.0.87 → 0.0.88
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 +2 -5
- package/dist/Treble/Treble.js +1 -7
- package/dist/hooks/useProductCache/index.d.ts +1 -0
- package/dist/hooks/useProductCache/index.js +43 -1
- package/dist/hooks/useResetProduct/index.d.ts +3 -0
- package/dist/hooks/useResetProduct/index.js +55 -0
- package/dist/store/index.d.ts +29 -8
- package/dist/store/product.d.ts +4 -3
- package/dist/store/product.js +37 -19
- package/dist/store/treble.js +1 -2
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/Treble/Treble.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import threekitAPI from '../api';
|
|
2
|
-
import { IThreekitPlayer, IThreekitPrivatePlayer,
|
|
2
|
+
import { IThreekitPlayer, IThreekitPrivatePlayer, IThreekitPrivateConfigurator } from '../types';
|
|
3
3
|
import { IWishlist } from './wishlist';
|
|
4
4
|
import snapshots from './snapshots';
|
|
5
5
|
import { ISaveConfiguration } from '../api/configurations';
|
|
@@ -8,7 +8,6 @@ import { ICartItem } from '../http/orders';
|
|
|
8
8
|
interface ITreble {
|
|
9
9
|
player: IThreekitPlayer;
|
|
10
10
|
orgId: string;
|
|
11
|
-
initialConfiguration: IConfiguration;
|
|
12
11
|
}
|
|
13
12
|
interface IEmailShareCredentials {
|
|
14
13
|
to: string;
|
|
@@ -22,11 +21,10 @@ declare class Treble {
|
|
|
22
21
|
_api: typeof threekitAPI;
|
|
23
22
|
_player: IThreekitPrivatePlayer;
|
|
24
23
|
wishlist: IWishlist;
|
|
25
|
-
private _initialConfiguration;
|
|
26
24
|
private _snapshots;
|
|
27
25
|
takeSnapshots: typeof snapshots['takeSnapshots'];
|
|
28
26
|
_debugMode: boolean;
|
|
29
|
-
constructor({ player, orgId
|
|
27
|
+
constructor({ player, orgId }: ITreble);
|
|
30
28
|
createOrder: (order?: IOrder) => Promise<import("../http/orders").IOrderResponse>;
|
|
31
29
|
saveConfiguration: (config?: Partial<Omit<ISaveConfiguration, 'configuration'>>) => Promise<{
|
|
32
30
|
resumableUrl: string;
|
|
@@ -34,7 +32,6 @@ declare class Treble {
|
|
|
34
32
|
thumbnail: string;
|
|
35
33
|
}>;
|
|
36
34
|
getNestedConfigurator: (address: string | Array<string>) => undefined | IThreekitPrivateConfigurator;
|
|
37
|
-
resetConfiguration: (configuration?: ISetConfiguration) => void;
|
|
38
35
|
sendEmail: (credentials: IEmailShareCredentials, templateData: Record<string, any>) => Promise<import("../http/server").IPostEmailResponse>;
|
|
39
36
|
}
|
|
40
37
|
export default Treble;
|
package/dist/Treble/Treble.js
CHANGED
|
@@ -48,7 +48,7 @@ var wishlist_1 = __importDefault(require("./wishlist"));
|
|
|
48
48
|
var snapshots_1 = __importDefault(require("./snapshots"));
|
|
49
49
|
var Treble = (function () {
|
|
50
50
|
function Treble(_a) {
|
|
51
|
-
var player = _a.player, orgId = _a.orgId
|
|
51
|
+
var player = _a.player, orgId = _a.orgId;
|
|
52
52
|
var _this = this;
|
|
53
53
|
this.createOrder = function (order) { return __awaiter(_this, void 0, void 0, function () {
|
|
54
54
|
var updatedOrder, configuration, response;
|
|
@@ -129,11 +129,6 @@ var Treble = (function () {
|
|
|
129
129
|
})) === null || _a === void 0 ? void 0 : _a.configurator;
|
|
130
130
|
}, player.getConfigurator());
|
|
131
131
|
};
|
|
132
|
-
this.resetConfiguration = function (configuration) {
|
|
133
|
-
var initialConfiguration = JSON.parse(_this._initialConfiguration);
|
|
134
|
-
var updateConfiguration = Object.assign(initialConfiguration, configuration);
|
|
135
|
-
window.threekit.configurator.setConfiguration(updateConfiguration);
|
|
136
|
-
};
|
|
137
132
|
this.sendEmail = function (credentials, templateData) {
|
|
138
133
|
if (!credentials)
|
|
139
134
|
throw new Error('sendEmail is missing credentials object');
|
|
@@ -155,7 +150,6 @@ var Treble = (function () {
|
|
|
155
150
|
this._snapshots = snapshots_1.default;
|
|
156
151
|
this.takeSnapshots = this._snapshots.takeSnapshots;
|
|
157
152
|
this._player = player.enableApi(types_1.PRIVATE_APIS.PLAYER);
|
|
158
|
-
this._initialConfiguration = JSON.stringify(initialConfiguration);
|
|
159
153
|
this._debugMode = constants_1.TREBLE_DEBUG;
|
|
160
154
|
}
|
|
161
155
|
return Treble;
|
|
@@ -14,6 +14,7 @@ interface UseProductCache {
|
|
|
14
14
|
cache: Array<HydratedCacheProduct>;
|
|
15
15
|
products: Array<ISelectableProduct>;
|
|
16
16
|
onLoadNewProduct: (config?: string | IReloadConfig) => Promise<void>;
|
|
17
|
+
onResetProduct: () => Promise<void>;
|
|
17
18
|
}
|
|
18
19
|
declare const useProductCache: () => UseProductCache;
|
|
19
20
|
export default useProductCache;
|
|
@@ -1,4 +1,40 @@
|
|
|
1
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
|
+
};
|
|
2
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
39
|
var product_1 = require("../../store/product");
|
|
4
40
|
var store_1 = require("../../store");
|
|
@@ -9,6 +45,12 @@ var useProductCache = function () {
|
|
|
9
45
|
var onLoadNewProduct = function (config) {
|
|
10
46
|
return dispatch((0, product_1.loadNewProduct)(config));
|
|
11
47
|
};
|
|
48
|
+
var onResetProduct = function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
49
|
+
switch (_a.label) {
|
|
50
|
+
case 0: return [4, dispatch((0, product_1.resetProductConfiguration)())];
|
|
51
|
+
case 1: return [2, _a.sent()];
|
|
52
|
+
}
|
|
53
|
+
}); }); };
|
|
12
54
|
var hydratedCache = cache.map(function (el, i) {
|
|
13
55
|
return Object.assign({}, el, {
|
|
14
56
|
selected: activeProductIdx === i,
|
|
@@ -25,6 +67,6 @@ var useProductCache = function () {
|
|
|
25
67
|
return dispatch((0, product_1.loadProduct)(prod, config));
|
|
26
68
|
},
|
|
27
69
|
}); });
|
|
28
|
-
return { cache: hydratedCache, products: products, onLoadNewProduct: onLoadNewProduct };
|
|
70
|
+
return { cache: hydratedCache, products: products, onLoadNewProduct: onLoadNewProduct, onResetProduct: onResetProduct };
|
|
29
71
|
};
|
|
30
72
|
exports.default = useProductCache;
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
var store_1 = require("../../store");
|
|
40
|
+
var treble_1 = require("../../store/treble");
|
|
41
|
+
var product_1 = require("../../store/product");
|
|
42
|
+
var useResetProduct = function () {
|
|
43
|
+
var isLoaded = (0, store_1.useThreekitSelector)(treble_1.isThreekitInitialized);
|
|
44
|
+
var dispatch = (0, store_1.useThreekitDispatch)();
|
|
45
|
+
if (!isLoaded)
|
|
46
|
+
return undefined;
|
|
47
|
+
var handleReset = function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
48
|
+
switch (_a.label) {
|
|
49
|
+
case 0: return [4, dispatch((0, product_1.resetProductConfiguration)())];
|
|
50
|
+
case 1: return [2, _a.sent()];
|
|
51
|
+
}
|
|
52
|
+
}); }); };
|
|
53
|
+
return handleReset;
|
|
54
|
+
};
|
|
55
|
+
exports.default = useResetProduct;
|
package/dist/store/index.d.ts
CHANGED
|
@@ -7,21 +7,28 @@ declare const store: import("@reduxjs/toolkit").EnhancedStore<{
|
|
|
7
7
|
translations: import("./translations").TranslationsState;
|
|
8
8
|
wishlist: import("../Treble").WishlistArray;
|
|
9
9
|
price: import("./price").PriceState;
|
|
10
|
-
}, import("redux").AnyAction, import("@reduxjs/toolkit").MiddlewareArray<
|
|
10
|
+
}, import("redux").AnyAction, import("@reduxjs/toolkit").MiddlewareArray<import("redux-thunk").ThunkMiddleware<{
|
|
11
11
|
treble: import("./treble").TrebleState;
|
|
12
12
|
product: import("./product").ProductState;
|
|
13
13
|
attributes: import("./attributes").AttributesState;
|
|
14
14
|
translations: import("./translations").TranslationsState;
|
|
15
15
|
wishlist: import("../Treble").WishlistArray;
|
|
16
16
|
price: import("./price").PriceState;
|
|
17
|
-
}, import("redux").AnyAction,
|
|
17
|
+
}, import("redux").AnyAction, null> | import("redux-thunk").ThunkMiddleware<{
|
|
18
18
|
treble: import("./treble").TrebleState;
|
|
19
19
|
product: import("./product").ProductState;
|
|
20
20
|
attributes: import("./attributes").AttributesState;
|
|
21
21
|
translations: import("./translations").TranslationsState;
|
|
22
22
|
wishlist: import("../Treble").WishlistArray;
|
|
23
23
|
price: import("./price").PriceState;
|
|
24
|
-
}, import("redux").AnyAction, undefined
|
|
24
|
+
}, import("redux").AnyAction, undefined> | import("redux").Middleware<{}, {
|
|
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>>>>;
|
|
25
32
|
export declare const createStore: (reducer?: Record<string, Reducer>) => import("@reduxjs/toolkit").EnhancedStore<{
|
|
26
33
|
treble: import("./treble").TrebleState;
|
|
27
34
|
product: import("./product").ProductState;
|
|
@@ -29,30 +36,44 @@ export declare const createStore: (reducer?: Record<string, Reducer>) => import(
|
|
|
29
36
|
translations: import("./translations").TranslationsState;
|
|
30
37
|
wishlist: import("../Treble").WishlistArray;
|
|
31
38
|
price: import("./price").PriceState;
|
|
32
|
-
}, import("redux").AnyAction, import("@reduxjs/toolkit").MiddlewareArray<
|
|
39
|
+
}, import("redux").AnyAction, import("@reduxjs/toolkit").MiddlewareArray<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<{
|
|
33
47
|
treble: import("./treble").TrebleState;
|
|
34
48
|
product: import("./product").ProductState;
|
|
35
49
|
attributes: import("./attributes").AttributesState;
|
|
36
50
|
translations: import("./translations").TranslationsState;
|
|
37
51
|
wishlist: import("../Treble").WishlistArray;
|
|
38
52
|
price: import("./price").PriceState;
|
|
39
|
-
}, import("redux").AnyAction, undefined>
|
|
53
|
+
}, import("redux").AnyAction, undefined> | import("redux").Middleware<{}, {
|
|
40
54
|
treble: import("./treble").TrebleState;
|
|
41
55
|
product: import("./product").ProductState;
|
|
42
56
|
attributes: import("./attributes").AttributesState;
|
|
43
57
|
translations: import("./translations").TranslationsState;
|
|
44
58
|
wishlist: import("../Treble").WishlistArray;
|
|
45
59
|
price: import("./price").PriceState;
|
|
46
|
-
}, import("redux").
|
|
60
|
+
}, import("redux").Dispatch<import("redux").AnyAction>>>>;
|
|
47
61
|
export declare type RootState = ReturnType<typeof store.getState>;
|
|
48
62
|
export declare type ThreekitDispatch = typeof store.dispatch;
|
|
49
|
-
export declare const useThreekitDispatch: () => import("@reduxjs/toolkit").ThunkDispatch<{
|
|
63
|
+
export declare const useThreekitDispatch: () => import("redux").Dispatch<import("redux").AnyAction> & import("@reduxjs/toolkit").ThunkDispatch<{
|
|
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;
|
|
70
|
+
}, null, import("redux").AnyAction> & import("@reduxjs/toolkit").ThunkDispatch<{
|
|
50
71
|
treble: import("./treble").TrebleState;
|
|
51
72
|
product: import("./product").ProductState;
|
|
52
73
|
attributes: import("./attributes").AttributesState;
|
|
53
74
|
translations: import("./translations").TranslationsState;
|
|
54
75
|
wishlist: import("../Treble").WishlistArray;
|
|
55
76
|
price: import("./price").PriceState;
|
|
56
|
-
}, undefined, import("redux").AnyAction
|
|
77
|
+
}, undefined, import("redux").AnyAction>;
|
|
57
78
|
export declare const useThreekitSelector: TypedUseSelectorHook<RootState>;
|
|
58
79
|
export default createStore;
|
package/dist/store/product.d.ts
CHANGED
|
@@ -16,8 +16,7 @@ export interface LoadProductConfig {
|
|
|
16
16
|
export interface CachedProductState extends Pick<CachedProduct, 'id' | 'name' | 'label' | 'thumbnail'> {
|
|
17
17
|
data: string;
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
}
|
|
19
|
+
declare type IEnvConfig = Record<string, Partial<IProduct>>;
|
|
21
20
|
export interface IHydratedProducts extends Record<string, IEnvConfig> {
|
|
22
21
|
}
|
|
23
22
|
export interface ProductState {
|
|
@@ -43,7 +42,8 @@ export declare const getName: (state: RootState) => undefined | string;
|
|
|
43
42
|
export declare const getMetadata: (state: RootState) => undefined | IMetadata;
|
|
44
43
|
export declare const getActiveCacheIdx: (state: RootState) => number;
|
|
45
44
|
export declare const getProductCache: (state: RootState) => Array<Pick<CachedProduct, 'name' | 'label' | 'thumbnail'>>;
|
|
46
|
-
export declare const
|
|
45
|
+
export declare const setProducts: (products: IHydratedProducts) => IHydratedProducts;
|
|
46
|
+
export declare const initProduct: () => (dispatch: ThreekitDispatch, getState: () => RootState) => void;
|
|
47
47
|
export declare const cacheActiveProduct: (config?: Pick<IReloadConfig, 'label' | 'thumbnail'>) => (dispatch: ThreekitDispatch, getState: () => RootState) => {
|
|
48
48
|
payload: CachedProductState;
|
|
49
49
|
type: string;
|
|
@@ -52,4 +52,5 @@ export declare const loadProduct: (id: string, config?: LoadProductConfig) => (d
|
|
|
52
52
|
export declare const loadNewProduct: (config: undefined | string | IReloadConfig) => (dispatch: ThreekitDispatch) => Promise<void>;
|
|
53
53
|
export declare const changeActiveCacheIdx: (idx: number) => (dispatch: ThreekitDispatch, getState: () => RootState) => Promise<void>;
|
|
54
54
|
export declare const removeProductIdx: (idx?: number) => (dispatch: ThreekitDispatch, getState: () => RootState) => Promise<void>;
|
|
55
|
+
export declare const resetProductConfiguration: () => (dispatch: ThreekitDispatch, getState: () => RootState) => Promise<void>;
|
|
55
56
|
export default reducer;
|
package/dist/store/product.js
CHANGED
|
@@ -50,11 +50,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
50
50
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
51
|
};
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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;
|
|
53
|
+
exports.resetProductConfiguration = exports.removeProductIdx = exports.changeActiveCacheIdx = exports.loadNewProduct = exports.loadProduct = exports.cacheActiveProduct = exports.initProduct = exports.setProducts = 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
55
|
var types_1 = require("../types");
|
|
56
56
|
var connection_1 = __importDefault(require("../connection"));
|
|
57
57
|
var treble_1 = require("./treble");
|
|
58
|
+
var attributes_1 = require("./attributes");
|
|
59
|
+
var INITIAL_CONFIGURATIONS = {};
|
|
58
60
|
exports.setProductId = (0, toolkit_1.createAction)('treble/set-product-id');
|
|
59
61
|
exports.setName = (0, toolkit_1.createAction)('treble/set-product-name');
|
|
60
62
|
exports.setMetadata = (0, toolkit_1.createAction)('treble/set-metadata');
|
|
@@ -142,25 +144,29 @@ var getProductCache = function (state) {
|
|
|
142
144
|
});
|
|
143
145
|
};
|
|
144
146
|
exports.getProductCache = getProductCache;
|
|
145
|
-
var
|
|
146
|
-
return
|
|
147
|
-
if (prods)
|
|
148
|
-
exports.PRODUCTS = prods;
|
|
149
|
-
if (!window.threekit)
|
|
150
|
-
return;
|
|
151
|
-
var state = getState();
|
|
152
|
-
var name = window.threekit.player.scene.get({
|
|
153
|
-
id: window.threekit.player.assetId,
|
|
154
|
-
}).name;
|
|
155
|
-
var metadata = window.threekit.configurator.getMetadata();
|
|
156
|
-
dispatch((0, exports.setName)(name));
|
|
157
|
-
dispatch((0, exports.setMetadata)(metadata));
|
|
158
|
-
if (!state.product.cache.length) {
|
|
159
|
-
dispatch((0, exports.setActiveCacheIdx)(0));
|
|
160
|
-
dispatch((0, exports.cacheActiveProduct)());
|
|
161
|
-
}
|
|
162
|
-
};
|
|
147
|
+
var setProducts = function (products) {
|
|
148
|
+
return (exports.PRODUCTS = products);
|
|
163
149
|
};
|
|
150
|
+
exports.setProducts = setProducts;
|
|
151
|
+
var initProduct = function () { return function (dispatch, getState) {
|
|
152
|
+
var state = getState();
|
|
153
|
+
var name = window.threekit.player.scene.get({
|
|
154
|
+
id: window.threekit.player.assetId,
|
|
155
|
+
}).name;
|
|
156
|
+
var metadata = window.threekit.configurator.getMetadata();
|
|
157
|
+
var productId = state.product.id;
|
|
158
|
+
if (productId && !INITIAL_CONFIGURATIONS[productId]) {
|
|
159
|
+
var player = window.threekit.player.enableApi(types_1.PRIVATE_APIS.PLAYER);
|
|
160
|
+
var configuration = player.configurator.getFullConfiguration();
|
|
161
|
+
INITIAL_CONFIGURATIONS[productId] = JSON.stringify(configuration);
|
|
162
|
+
}
|
|
163
|
+
dispatch((0, exports.setName)(name));
|
|
164
|
+
dispatch((0, exports.setMetadata)(metadata));
|
|
165
|
+
if (!state.product.cache.length) {
|
|
166
|
+
dispatch((0, exports.setActiveCacheIdx)(0));
|
|
167
|
+
dispatch((0, exports.cacheActiveProduct)());
|
|
168
|
+
}
|
|
169
|
+
}; };
|
|
164
170
|
exports.initProduct = initProduct;
|
|
165
171
|
var cacheActiveProduct = function (config) {
|
|
166
172
|
return function (dispatch, getState) {
|
|
@@ -306,4 +312,16 @@ var removeProductIdx = function (idx) {
|
|
|
306
312
|
}); };
|
|
307
313
|
};
|
|
308
314
|
exports.removeProductIdx = removeProductIdx;
|
|
315
|
+
var resetProductConfiguration = function () { return function (dispatch, getState) { return __awaiter(void 0, void 0, void 0, function () {
|
|
316
|
+
var state, initialConfiguration;
|
|
317
|
+
return __generator(this, function (_a) {
|
|
318
|
+
state = getState();
|
|
319
|
+
if (!state.product.id)
|
|
320
|
+
return [2];
|
|
321
|
+
initialConfiguration = INITIAL_CONFIGURATIONS[state.product.id];
|
|
322
|
+
dispatch((0, attributes_1.setConfiguration)(JSON.parse(initialConfiguration)));
|
|
323
|
+
return [2];
|
|
324
|
+
});
|
|
325
|
+
}); }; };
|
|
326
|
+
exports.resetProductConfiguration = resetProductConfiguration;
|
|
309
327
|
exports.default = reducer;
|
package/dist/store/treble.js
CHANGED
|
@@ -199,7 +199,6 @@ var initPlayer = function (config) {
|
|
|
199
199
|
treble: new Treble_1.default({
|
|
200
200
|
player: player,
|
|
201
201
|
orgId: orgId,
|
|
202
|
-
initialConfiguration: configurator.getConfiguration(),
|
|
203
202
|
}),
|
|
204
203
|
};
|
|
205
204
|
dispatch((0, exports.setThreekitInitialized)(true));
|
|
@@ -306,7 +305,7 @@ var launch = function (launchConfig) {
|
|
|
306
305
|
}, {});
|
|
307
306
|
if (!Object.keys(credentials).length || !Object.keys(products).length)
|
|
308
307
|
return [2, console.error('Missing credentials')];
|
|
309
|
-
|
|
308
|
+
(0, product_1.setProducts)(products);
|
|
310
309
|
dispatch((0, product_1.setProductId)(productId));
|
|
311
310
|
threekitEnv = (launchConfig === null || launchConfig === void 0 ? void 0 : launchConfig.threekitEnv) || process.env.THREEKIT_ENV || 'preview';
|
|
312
311
|
serverUrl = (launchConfig === null || launchConfig === void 0 ? void 0 : launchConfig.serverUrl) || ((_g = config === null || config === void 0 ? void 0 : config.project) === null || _g === void 0 ? void 0 : _g.serverUrl);
|
package/dist/types.d.ts
CHANGED