@threekit-tools/treble 0.0.74 → 0.0.77
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.d.ts +1 -2
- package/dist/Treble/Snapshots.js +110 -82
- package/dist/hooks/useNestedConfigurator/index.js +1 -1
- package/dist/hooks/useProductCache/index.d.ts +2 -2
- package/dist/hooks/useProductCache/index.js +3 -1
- package/dist/store/product.d.ts +4 -1
- package/dist/store/product.js +5 -5
- package/dist/types.d.ts +1 -0
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +3 -1
- package/package.json +1 -1
|
@@ -9,6 +9,7 @@ export interface ITakeSnapshotsConfig {
|
|
|
9
9
|
format?: string;
|
|
10
10
|
size?: SnapshotSize;
|
|
11
11
|
filename?: string;
|
|
12
|
+
useStage?: boolean;
|
|
12
13
|
}
|
|
13
14
|
interface IGetSnapshot {
|
|
14
15
|
size: SnapshotSize;
|
|
@@ -16,13 +17,11 @@ interface IGetSnapshot {
|
|
|
16
17
|
}
|
|
17
18
|
interface ISnapshots {
|
|
18
19
|
getSnapshot(snapshotConfig: IGetSnapshot): Promise<string>;
|
|
19
|
-
getSnapshots(cameras: Array<string | undefined>, snapshotConfig: Pick<ITakeSnapshotsConfig, 'attributeName' | 'format' | 'size'>): Promise<Array<string>>;
|
|
20
20
|
takeSnapshots(cameras: ISnapshotsCameras, config: ITakeSnapshotsConfig): Promise<void | string[] | Blob[] | null>;
|
|
21
21
|
}
|
|
22
22
|
declare class Snapshots implements ISnapshots {
|
|
23
23
|
constructor();
|
|
24
24
|
getSnapshot: ({ size, format }: IGetSnapshot) => Promise<string>;
|
|
25
|
-
getSnapshots: (cameras: Array<string | undefined>, snapshotConfig: Pick<ITakeSnapshotsConfig, 'attributeName' | 'format' | 'size'>) => Promise<string[]>;
|
|
26
25
|
takeSnapshots: (camerasList: ISnapshotsCameras, snapshotsConfig: ITakeSnapshotsConfig) => Promise<void | string[] | Blob[] | null>;
|
|
27
26
|
}
|
|
28
27
|
export default Snapshots;
|
package/dist/Treble/Snapshots.js
CHANGED
|
@@ -49,22 +49,23 @@ var DEFAULT_CAMERA_CONFIG = {
|
|
|
49
49
|
format: constants_1.SNAPSHOT_FORMATS.png,
|
|
50
50
|
attributeName: constants_1.ATTRIBUTES_RESERVED.camera,
|
|
51
51
|
output: constants_1.SNAPSHOT_OUTPUTS.blob,
|
|
52
|
+
useStage: false,
|
|
52
53
|
};
|
|
53
54
|
var cameraValues;
|
|
54
|
-
var getCameraValue = function (cameraAttrName) {
|
|
55
|
+
var getCameraValue = function (configurator, cameraAttrName) {
|
|
55
56
|
if (cameraAttrName === void 0) { cameraAttrName = constants_1.ATTRIBUTES_RESERVED.camera; }
|
|
56
|
-
var attribute =
|
|
57
|
+
var attribute = configurator
|
|
57
58
|
.getDisplayAttributes()
|
|
58
59
|
.find(function (el) { return el.name === cameraAttrName; });
|
|
59
60
|
if (!attribute)
|
|
60
61
|
return undefined;
|
|
61
62
|
return attribute.value;
|
|
62
63
|
};
|
|
63
|
-
var getCamerasMap = function (cameraAttrName) {
|
|
64
|
+
var getCamerasMap = function (configurator, cameraAttrName) {
|
|
64
65
|
if (cameraAttrName === void 0) { cameraAttrName = constants_1.ATTRIBUTES_RESERVED.camera; }
|
|
65
66
|
if (cameraValues)
|
|
66
67
|
return cameraValues;
|
|
67
|
-
var attribute =
|
|
68
|
+
var attribute = configurator
|
|
68
69
|
.getDisplayAttributes()
|
|
69
70
|
.find(function (el) { return el.name === cameraAttrName; });
|
|
70
71
|
if (!attribute) {
|
|
@@ -83,97 +84,124 @@ var getCamerasMap = function (cameraAttrName) {
|
|
|
83
84
|
}, {});
|
|
84
85
|
return cameraValues;
|
|
85
86
|
};
|
|
87
|
+
var getSnapshot = function (_a) {
|
|
88
|
+
var size = _a.size, format = _a.format;
|
|
89
|
+
return window.threekit.player.snapshotAsync({
|
|
90
|
+
size: size,
|
|
91
|
+
mimeType: "image/".concat(constants_1.SNAPSHOT_FORMATS[format]),
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
var getSnapshots = function (cameras, snapshotConfig) { return __awaiter(void 0, void 0, void 0, function () {
|
|
95
|
+
var attributeName, size, format, configurator, _a, camerasMap, snapshots;
|
|
96
|
+
return __generator(this, function (_b) {
|
|
97
|
+
switch (_b.label) {
|
|
98
|
+
case 0:
|
|
99
|
+
attributeName = snapshotConfig.attributeName || DEFAULT_CAMERA_CONFIG.attributeName;
|
|
100
|
+
size = snapshotConfig.size || DEFAULT_CAMERA_CONFIG.size;
|
|
101
|
+
format = snapshotConfig.format || DEFAULT_CAMERA_CONFIG.format;
|
|
102
|
+
if (!(snapshotConfig === null || snapshotConfig === void 0 ? void 0 : snapshotConfig.useStage)) return [3 /*break*/, 2];
|
|
103
|
+
return [4 /*yield*/, window.threekit.player.getStageConfigurator()];
|
|
104
|
+
case 1:
|
|
105
|
+
_a = _b.sent();
|
|
106
|
+
return [3 /*break*/, 3];
|
|
107
|
+
case 2:
|
|
108
|
+
_a = window.threekit.configurator;
|
|
109
|
+
_b.label = 3;
|
|
110
|
+
case 3:
|
|
111
|
+
configurator = _a;
|
|
112
|
+
camerasMap = getCamerasMap(configurator, attributeName);
|
|
113
|
+
if (!camerasMap)
|
|
114
|
+
return [2 /*return*/, Promise.resolve([])];
|
|
115
|
+
snapshots = [];
|
|
116
|
+
return [2 /*return*/, cameras.reduce(function (snapshotPromise, camera) {
|
|
117
|
+
return snapshotPromise.then(function () {
|
|
118
|
+
return new Promise(function (resolve) { return __awaiter(void 0, void 0, void 0, function () {
|
|
119
|
+
var snapshotStr;
|
|
120
|
+
var _a;
|
|
121
|
+
return __generator(this, function (_b) {
|
|
122
|
+
switch (_b.label) {
|
|
123
|
+
case 0:
|
|
124
|
+
if (!camera) return [3 /*break*/, 2];
|
|
125
|
+
return [4 /*yield*/, configurator.setConfiguration((_a = {},
|
|
126
|
+
_a[attributeName] = camerasMap[camera],
|
|
127
|
+
_a))];
|
|
128
|
+
case 1:
|
|
129
|
+
_b.sent();
|
|
130
|
+
_b.label = 2;
|
|
131
|
+
case 2: return [4 /*yield*/, getSnapshot({ size: size, format: format })];
|
|
132
|
+
case 3:
|
|
133
|
+
snapshotStr = _b.sent();
|
|
134
|
+
snapshots.push(snapshotStr);
|
|
135
|
+
resolve(snapshots);
|
|
136
|
+
return [2 /*return*/];
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}); });
|
|
140
|
+
});
|
|
141
|
+
}, Promise.resolve(snapshots))];
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}); };
|
|
86
145
|
var Snapshots = /** @class */ (function () {
|
|
87
146
|
function Snapshots() {
|
|
88
147
|
var _this = this;
|
|
89
|
-
this.getSnapshot =
|
|
90
|
-
var size = _a.size, format = _a.format;
|
|
91
|
-
return window.threekit.player.snapshotAsync({
|
|
92
|
-
size: size,
|
|
93
|
-
mimeType: "image/".concat(constants_1.SNAPSHOT_FORMATS[format]),
|
|
94
|
-
});
|
|
95
|
-
};
|
|
96
|
-
this.getSnapshots = function (cameras, snapshotConfig) {
|
|
97
|
-
var attributeName = snapshotConfig.attributeName || DEFAULT_CAMERA_CONFIG.attributeName;
|
|
98
|
-
var size = snapshotConfig.size || DEFAULT_CAMERA_CONFIG.size;
|
|
99
|
-
var format = snapshotConfig.format || DEFAULT_CAMERA_CONFIG.format;
|
|
100
|
-
var camerasMap = getCamerasMap(attributeName);
|
|
101
|
-
if (!camerasMap)
|
|
102
|
-
return Promise.resolve([]);
|
|
103
|
-
var snapshots = [];
|
|
104
|
-
return cameras.reduce(function (snapshotPromise, camera) {
|
|
105
|
-
return snapshotPromise.then(function () {
|
|
106
|
-
return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
|
|
107
|
-
var snapshotStr;
|
|
108
|
-
var _a;
|
|
109
|
-
return __generator(this, function (_b) {
|
|
110
|
-
switch (_b.label) {
|
|
111
|
-
case 0:
|
|
112
|
-
if (!camera) return [3 /*break*/, 2];
|
|
113
|
-
return [4 /*yield*/, window.threekit.configurator.setConfiguration((_a = {},
|
|
114
|
-
_a[attributeName] = camerasMap[camera],
|
|
115
|
-
_a))];
|
|
116
|
-
case 1:
|
|
117
|
-
_b.sent();
|
|
118
|
-
_b.label = 2;
|
|
119
|
-
case 2: return [4 /*yield*/, this.getSnapshot({ size: size, format: format })];
|
|
120
|
-
case 3:
|
|
121
|
-
snapshotStr = _b.sent();
|
|
122
|
-
snapshots.push(snapshotStr);
|
|
123
|
-
resolve(snapshots);
|
|
124
|
-
return [2 /*return*/];
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
}); });
|
|
128
|
-
});
|
|
129
|
-
}, Promise.resolve(snapshots));
|
|
130
|
-
};
|
|
148
|
+
this.getSnapshot = getSnapshot;
|
|
131
149
|
this.takeSnapshots = function (camerasList, snapshotsConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
132
|
-
var filename, size, format, attributeName, output, cameras, snapshotsRaw, snapshotData, camerasMap_1, currentCamera, cameraPosition,
|
|
133
|
-
var
|
|
134
|
-
return __generator(this, function (
|
|
135
|
-
switch (
|
|
150
|
+
var filename, size, format, attributeName, output, configurator, _a, cameras, snapshotsRaw, snapshotData, camerasMap_1, currentCamera, cameraPosition, _b, attachments, response, urlsArray, snapshotBlobs, snapshotFiles;
|
|
151
|
+
var _c;
|
|
152
|
+
return __generator(this, function (_d) {
|
|
153
|
+
switch (_d.label) {
|
|
136
154
|
case 0:
|
|
137
155
|
filename = (snapshotsConfig === null || snapshotsConfig === void 0 ? void 0 : snapshotsConfig.filename) || DEFAULT_CAMERA_CONFIG.filename;
|
|
138
156
|
size = (snapshotsConfig === null || snapshotsConfig === void 0 ? void 0 : snapshotsConfig.size) || DEFAULT_CAMERA_CONFIG.size;
|
|
139
157
|
format = (snapshotsConfig === null || snapshotsConfig === void 0 ? void 0 : snapshotsConfig.format) || DEFAULT_CAMERA_CONFIG.format;
|
|
140
158
|
attributeName = (snapshotsConfig === null || snapshotsConfig === void 0 ? void 0 : snapshotsConfig.attributeName) || DEFAULT_CAMERA_CONFIG.attributeName;
|
|
141
159
|
output = (snapshotsConfig === null || snapshotsConfig === void 0 ? void 0 : snapshotsConfig.output) || DEFAULT_CAMERA_CONFIG.output;
|
|
160
|
+
if (!(snapshotsConfig === null || snapshotsConfig === void 0 ? void 0 : snapshotsConfig.useStage)) return [3 /*break*/, 2];
|
|
161
|
+
return [4 /*yield*/, window.threekit.player.getStageConfigurator()];
|
|
162
|
+
case 1:
|
|
163
|
+
_a = _d.sent();
|
|
164
|
+
return [3 /*break*/, 3];
|
|
165
|
+
case 2:
|
|
166
|
+
_a = window.threekit.configurator;
|
|
167
|
+
_d.label = 3;
|
|
168
|
+
case 3:
|
|
169
|
+
configurator = _a;
|
|
142
170
|
cameras = Array.isArray(camerasList) ? camerasList : [camerasList];
|
|
143
|
-
if (!(cameras.length === 1 && cameras[0] === undefined)) return [3 /*break*/,
|
|
171
|
+
if (!(cameras.length === 1 && cameras[0] === undefined)) return [3 /*break*/, 5];
|
|
144
172
|
return [4 /*yield*/, this.getSnapshot({ size: size, format: format })];
|
|
145
|
-
case
|
|
146
|
-
snapshotData =
|
|
173
|
+
case 4:
|
|
174
|
+
snapshotData = _d.sent();
|
|
147
175
|
snapshotsRaw = [snapshotData];
|
|
148
|
-
return [3 /*break*/,
|
|
149
|
-
case
|
|
150
|
-
camerasMap_1 = getCamerasMap(attributeName);
|
|
176
|
+
return [3 /*break*/, 8];
|
|
177
|
+
case 5:
|
|
178
|
+
camerasMap_1 = getCamerasMap(configurator, attributeName);
|
|
151
179
|
if (!camerasMap_1)
|
|
152
180
|
return [2 /*return*/, null];
|
|
153
181
|
cameras = cameras.filter(function (el) { return el === undefined || Object.keys(camerasMap_1).includes(el); });
|
|
154
|
-
currentCamera = getCameraValue(attributeName);
|
|
182
|
+
currentCamera = getCameraValue(configurator, attributeName);
|
|
155
183
|
cameraPosition = (0, utils_1.getCameraPosition)(window.threekit.player.camera);
|
|
156
|
-
return [4 /*yield*/,
|
|
157
|
-
case
|
|
158
|
-
snapshotsRaw =
|
|
159
|
-
return [4 /*yield*/,
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
case
|
|
163
|
-
|
|
184
|
+
return [4 /*yield*/, getSnapshots(cameras, snapshotsConfig)];
|
|
185
|
+
case 6:
|
|
186
|
+
snapshotsRaw = _d.sent();
|
|
187
|
+
return [4 /*yield*/, configurator.setConfiguration((_c = {},
|
|
188
|
+
_c[attributeName] = currentCamera,
|
|
189
|
+
_c))];
|
|
190
|
+
case 7:
|
|
191
|
+
_d.sent();
|
|
164
192
|
(0, utils_1.setCameraPosition)(window.threekit.player.camera, cameraPosition);
|
|
165
|
-
|
|
166
|
-
case
|
|
167
|
-
|
|
168
|
-
switch (
|
|
169
|
-
case constants_1.SNAPSHOT_OUTPUTS.url: return [3 /*break*/,
|
|
170
|
-
case constants_1.SNAPSHOT_OUTPUTS.download: return [3 /*break*/,
|
|
171
|
-
case constants_1.SNAPSHOT_OUTPUTS.blob: return [3 /*break*/,
|
|
172
|
-
case constants_1.SNAPSHOT_OUTPUTS.file: return [3 /*break*/,
|
|
173
|
-
case constants_1.SNAPSHOT_OUTPUTS.dataUrl: return [3 /*break*/,
|
|
193
|
+
_d.label = 8;
|
|
194
|
+
case 8:
|
|
195
|
+
_b = output;
|
|
196
|
+
switch (_b) {
|
|
197
|
+
case constants_1.SNAPSHOT_OUTPUTS.url: return [3 /*break*/, 9];
|
|
198
|
+
case constants_1.SNAPSHOT_OUTPUTS.download: return [3 /*break*/, 11];
|
|
199
|
+
case constants_1.SNAPSHOT_OUTPUTS.blob: return [3 /*break*/, 12];
|
|
200
|
+
case constants_1.SNAPSHOT_OUTPUTS.file: return [3 /*break*/, 13];
|
|
201
|
+
case constants_1.SNAPSHOT_OUTPUTS.dataUrl: return [3 /*break*/, 14];
|
|
174
202
|
}
|
|
175
|
-
return [3 /*break*/,
|
|
176
|
-
case
|
|
203
|
+
return [3 /*break*/, 14];
|
|
204
|
+
case 9:
|
|
177
205
|
attachments = snapshotsRaw.reduce(function (output, el, idx) {
|
|
178
206
|
var _a;
|
|
179
207
|
var cameraName = (camerasList === null || camerasList === void 0 ? void 0 : camerasList[idx])
|
|
@@ -190,11 +218,11 @@ var Snapshots = /** @class */ (function () {
|
|
|
190
218
|
configuration: window.threekit.configurator.getConfiguration(),
|
|
191
219
|
attachments: attachments,
|
|
192
220
|
})];
|
|
193
|
-
case
|
|
194
|
-
response =
|
|
221
|
+
case 10:
|
|
222
|
+
response = _d.sent();
|
|
195
223
|
urlsArray = Object.values(response.data.attachments);
|
|
196
224
|
return [2 /*return*/, Promise.resolve(urlsArray)];
|
|
197
|
-
case
|
|
225
|
+
case 11:
|
|
198
226
|
snapshotsRaw.forEach(function (snapshotBlob, idx) {
|
|
199
227
|
var cameraName = (camerasList === null || camerasList === void 0 ? void 0 : camerasList[idx])
|
|
200
228
|
? "-".concat((0, utils_1.regularToKebabCase)(camerasList[idx] || 'default'))
|
|
@@ -202,10 +230,10 @@ var Snapshots = /** @class */ (function () {
|
|
|
202
230
|
(0, utils_1.downloadSnapshot)(snapshotBlob, "".concat(filename).concat(cameraName, ".").concat(format));
|
|
203
231
|
});
|
|
204
232
|
return [2 /*return*/, Promise.resolve()];
|
|
205
|
-
case
|
|
233
|
+
case 12:
|
|
206
234
|
snapshotBlobs = snapshotsRaw.map(function (el) { return (0, utils_1.dataURItoBlob)(el); });
|
|
207
235
|
return [2 /*return*/, Promise.resolve(snapshotBlobs)];
|
|
208
|
-
case
|
|
236
|
+
case 13:
|
|
209
237
|
snapshotFiles = snapshotsRaw.map(function (el, idx) {
|
|
210
238
|
var cameraName = (camerasList === null || camerasList === void 0 ? void 0 : camerasList[idx])
|
|
211
239
|
? "-".concat((0, utils_1.regularToKebabCase)(camerasList[idx] || 'default'))
|
|
@@ -213,7 +241,7 @@ var Snapshots = /** @class */ (function () {
|
|
|
213
241
|
return (0, utils_1.dataURItoFile)(el, "".concat(filename).concat(cameraName, ".").concat(format));
|
|
214
242
|
});
|
|
215
243
|
return [2 /*return*/, Promise.resolve(snapshotFiles)];
|
|
216
|
-
case
|
|
244
|
+
case 14: return [2 /*return*/, Promise.resolve(snapshotsRaw)];
|
|
217
245
|
}
|
|
218
246
|
});
|
|
219
247
|
}); };
|
|
@@ -65,7 +65,7 @@ var useNestedConfigurator = function (address) {
|
|
|
65
65
|
setAttributes(updatedAttrs);
|
|
66
66
|
metadataRef.current = configurator.current.getMetadata();
|
|
67
67
|
})();
|
|
68
|
-
}, [address, hasInitialized, playerLoading]);
|
|
68
|
+
}, [JSON.stringify(address), hasInitialized, playerLoading]);
|
|
69
69
|
if (!hasInitialized || !configurator.current || !attributes)
|
|
70
70
|
return [undefined, undefined, undefined, undefined];
|
|
71
71
|
var handleSelect = function (config) { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CachedProduct } from '../../store/product';
|
|
1
|
+
import { CachedProduct, LoadProductConfig } from '../../store/product';
|
|
2
2
|
import { IReloadConfig } from '../../store/treble';
|
|
3
3
|
interface HydratedCacheProduct extends Pick<CachedProduct, 'name' | 'label' | 'thumbnail'> {
|
|
4
4
|
selected: boolean;
|
|
@@ -8,7 +8,7 @@ interface HydratedCacheProduct extends Pick<CachedProduct, 'name' | 'label' | 't
|
|
|
8
8
|
interface ISelectableProduct {
|
|
9
9
|
id: string;
|
|
10
10
|
label: string;
|
|
11
|
-
handleSelect: () => void;
|
|
11
|
+
handleSelect: (config?: LoadProductConfig) => void;
|
|
12
12
|
}
|
|
13
13
|
interface CacheData {
|
|
14
14
|
cache: Array<HydratedCacheProduct>;
|
|
@@ -21,7 +21,9 @@ var useProductCache = function () {
|
|
|
21
21
|
var products = Object.keys(product_1.PRODUCTS).map(function (prod) { return ({
|
|
22
22
|
id: prod,
|
|
23
23
|
label: prod,
|
|
24
|
-
handleSelect: function () {
|
|
24
|
+
handleSelect: function (config) {
|
|
25
|
+
return dispatch((0, product_1.loadProduct)(prod, config));
|
|
26
|
+
},
|
|
25
27
|
}); });
|
|
26
28
|
return [{ cache: hydratedCache, products: products }, handleLoadNewProduct];
|
|
27
29
|
};
|
package/dist/store/product.d.ts
CHANGED
|
@@ -13,6 +13,9 @@ export interface CachedProduct {
|
|
|
13
13
|
connection: IConnectionConfig;
|
|
14
14
|
configuration: IConfiguration;
|
|
15
15
|
}
|
|
16
|
+
export interface LoadProductConfig {
|
|
17
|
+
cacheProduct: boolean;
|
|
18
|
+
}
|
|
16
19
|
export interface CachedProductState extends Pick<CachedProduct, 'id' | 'name' | 'label' | 'thumbnail'> {
|
|
17
20
|
data: string;
|
|
18
21
|
}
|
|
@@ -60,7 +63,7 @@ export declare const cacheActiveProduct: (config?: Pick<IReloadConfig, "label" |
|
|
|
60
63
|
payload: CachedProductState;
|
|
61
64
|
type: string;
|
|
62
65
|
};
|
|
63
|
-
export declare const loadProduct: (id: string) => (dispatch: ThreekitDispatch, getState: () => RootState) => Promise<void>;
|
|
66
|
+
export declare const loadProduct: (id: string, config?: LoadProductConfig | undefined) => (dispatch: ThreekitDispatch, getState: () => RootState) => Promise<void>;
|
|
64
67
|
export declare const loadNewProduct: (config: undefined | string | IReloadConfig) => (dispatch: ThreekitDispatch) => Promise<void>;
|
|
65
68
|
export declare const changeActiveCacheIdx: (idx: number) => (dispatch: ThreekitDispatch, getState: () => RootState) => Promise<void>;
|
|
66
69
|
export declare const removeProductIdx: (idx?: number | undefined) => (dispatch: ThreekitDispatch, getState: () => RootState) => Promise<void>;
|
package/dist/store/product.js
CHANGED
|
@@ -193,25 +193,25 @@ var cacheActiveProduct = function (config) {
|
|
|
193
193
|
};
|
|
194
194
|
};
|
|
195
195
|
exports.cacheActiveProduct = cacheActiveProduct;
|
|
196
|
-
var loadProduct = function (id) {
|
|
196
|
+
var loadProduct = function (id, config) {
|
|
197
197
|
return function (dispatch, getState) { return __awaiter(void 0, void 0, void 0, function () {
|
|
198
|
-
var state, productsList,
|
|
198
|
+
var cacheProduct, state, productsList, productConfig;
|
|
199
199
|
return __generator(this, function (_a) {
|
|
200
200
|
switch (_a.label) {
|
|
201
201
|
case 0:
|
|
202
|
+
cacheProduct = (config || { cacheProduct: true }).cacheProduct;
|
|
202
203
|
state = getState();
|
|
203
204
|
productsList = Object.keys(exports.PRODUCTS);
|
|
204
|
-
shouldCacheProduct = true;
|
|
205
205
|
if (!productsList.includes(id))
|
|
206
206
|
return [2 /*return*/];
|
|
207
207
|
productConfig = exports.PRODUCTS[id][state.treble.threekitEnv];
|
|
208
208
|
dispatch((0, exports.setProductId)(id));
|
|
209
|
-
if (
|
|
209
|
+
if (cacheProduct)
|
|
210
210
|
dispatch((0, exports.cacheActiveProduct)());
|
|
211
211
|
return [4 /*yield*/, dispatch((0, treble_1.reloadPlayer)(productConfig))];
|
|
212
212
|
case 1:
|
|
213
213
|
_a.sent();
|
|
214
|
-
if (
|
|
214
|
+
if (cacheProduct) {
|
|
215
215
|
dispatch((0, exports.incrementActiveCacheIdx)());
|
|
216
216
|
dispatch((0, exports.cacheActiveProduct)());
|
|
217
217
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -218,6 +218,7 @@ export interface IThreekitPlayer {
|
|
|
218
218
|
setActiveCamera: () => void;
|
|
219
219
|
on: (phase: SCENE_PHASES | string, callback: (args: any) => void) => void;
|
|
220
220
|
getConfigurator: () => Promise<IThreekitConfigurator>;
|
|
221
|
+
getStageConfigurator: () => Promise<IThreekitConfigurator>;
|
|
221
222
|
enableApi: (api: PRIVATE_APIS) => any;
|
|
222
223
|
snapshotAsync: (snapshotConfig: ISnapshotConfig) => Promise<string>;
|
|
223
224
|
unload: () => Promise<string>;
|
package/dist/utils.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export declare const generateLayoutClassName: (component: string, customClassNam
|
|
|
22
22
|
export declare const generateToolClassName: (component: string, customClassName?: string | undefined, title?: string | undefined) => string;
|
|
23
23
|
export declare const generateDisplayClassName: (component: string, customClassName?: string | undefined, title?: string | undefined) => string;
|
|
24
24
|
export declare const generateFormClassName: (component: string, customClassName?: string | undefined, title?: string | undefined) => string;
|
|
25
|
+
export declare const isIOS: () => RegExpMatchArray | null;
|
|
25
26
|
export declare const isJsonString: (str: string) => boolean;
|
|
26
27
|
export declare const objectToQueryStr: (obj: Record<string, any>) => string;
|
|
27
28
|
export declare const getParams: () => Record<string, string | {
|
package/dist/utils.js
CHANGED
|
@@ -45,7 +45,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
45
45
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
46
|
};
|
|
47
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
exports.loadTrebleConfig = exports.isUuid = exports.filterFormAttributes = exports.selectionToConfiguration = exports.hydrateAttribute = exports.metadataValueToObject = exports.easeInOutCubic = exports.copyToClipboard = exports.downloadSnapshot = exports.dataURItoFile = exports.dataURItoBlob = exports.setCameraPosition = exports.getCameraPosition = exports.findHitNode = exports.deflateRgb = exports.inflateRgb = exports.rgbToHex = exports.hexToRgb = exports.regularToKebabCase = exports.deepCompare = exports.shallowCompare = exports.getResumableUrl = exports.getParams = exports.objectToQueryStr = exports.isJsonString = exports.generateFormClassName = exports.generateDisplayClassName = exports.generateToolClassName = exports.generateLayoutClassName = exports.generateWidgetClassName = exports.generateInputClassName = exports.generateClassName = void 0;
|
|
48
|
+
exports.loadTrebleConfig = exports.isUuid = exports.filterFormAttributes = exports.selectionToConfiguration = exports.hydrateAttribute = exports.metadataValueToObject = exports.easeInOutCubic = exports.copyToClipboard = exports.downloadSnapshot = exports.dataURItoFile = exports.dataURItoBlob = exports.setCameraPosition = exports.getCameraPosition = exports.findHitNode = exports.deflateRgb = exports.inflateRgb = exports.rgbToHex = exports.hexToRgb = exports.regularToKebabCase = exports.deepCompare = exports.shallowCompare = exports.getResumableUrl = exports.getParams = exports.objectToQueryStr = exports.isJsonString = exports.isIOS = exports.generateFormClassName = exports.generateDisplayClassName = exports.generateToolClassName = exports.generateLayoutClassName = exports.generateWidgetClassName = exports.generateInputClassName = exports.generateClassName = void 0;
|
|
49
49
|
var constants_1 = require("./constants");
|
|
50
50
|
var generateClassName = function (baseClass) {
|
|
51
51
|
return function (component, customClassName, title) {
|
|
@@ -65,6 +65,8 @@ exports.generateLayoutClassName = (0, exports.generateClassName)(constants_1.LAY
|
|
|
65
65
|
exports.generateToolClassName = (0, exports.generateClassName)(constants_1.TOOL_CLASS_NAME);
|
|
66
66
|
exports.generateDisplayClassName = (0, exports.generateClassName)(constants_1.DISPLAY_CLASS_NAME);
|
|
67
67
|
exports.generateFormClassName = (0, exports.generateClassName)(constants_1.FORM_CLASS_NAME);
|
|
68
|
+
var isIOS = function () { return navigator.userAgent.match(/ipad|iphone/i); };
|
|
69
|
+
exports.isIOS = isIOS;
|
|
68
70
|
var isJsonString = function (str) {
|
|
69
71
|
try {
|
|
70
72
|
JSON.parse(str);
|