@threekit-tools/treble 0.0.38 → 0.0.39
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/README.md +1 -5
- package/dist/components/Player/index.js +5 -1
- package/dist/components/TrebleApp/index.js +0 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +2 -1
- package/dist/hooks/usePlayerPortal/index.d.ts +2 -1
- package/dist/hooks/usePlayerPortal/index.js +28 -7
- package/dist/hooks/useZoom/index.d.ts +2 -1
- package/dist/store/threekit.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -261,11 +261,10 @@ The `<Player />` component renders the **Threekit Player**.
|
|
|
261
261
|
|
|
262
262
|
```jsx
|
|
263
263
|
import { ThreekitProvider, Player } from '@threekit-tools/treble';
|
|
264
|
-
import threekitConfig from './threekit.config.js';
|
|
265
264
|
|
|
266
265
|
const ThreekitApp = () => {
|
|
267
266
|
return (
|
|
268
|
-
<ThreekitProvider
|
|
267
|
+
<ThreekitProvider>
|
|
269
268
|
<Player />
|
|
270
269
|
</ThreekitProvider>
|
|
271
270
|
);
|
|
@@ -278,7 +277,6 @@ The Player Component also comes with **widget containers** that can be used to p
|
|
|
278
277
|
|
|
279
278
|
```jsx
|
|
280
279
|
import { ThreekitProvider, Player } from '@threekit-tools/treble';
|
|
281
|
-
import threekitConfig from './threekit.config.js';
|
|
282
280
|
|
|
283
281
|
// We can separate out the widget container component
|
|
284
282
|
// or use the component directly from the Player component
|
|
@@ -311,7 +309,6 @@ The `<FlatForm>` component is used to render out the configurator for the initia
|
|
|
311
309
|
|
|
312
310
|
```jsx
|
|
313
311
|
import { ThreekitProvider, FlatForm } from '@threekit-tools/treble';
|
|
314
|
-
import threekitConfig from './threekit.config.js';
|
|
315
312
|
|
|
316
313
|
const App = () => {
|
|
317
314
|
return (
|
|
@@ -357,7 +354,6 @@ By default the Form will not render reserved attributes. This can be controlled/
|
|
|
357
354
|
|
|
358
355
|
```jsx
|
|
359
356
|
import { ThreekitProvider, FlatForm } from '@threekit-tools/treble';
|
|
360
|
-
import threekitConfig from './threekit.config.js';
|
|
361
357
|
|
|
362
358
|
const App = () => {
|
|
363
359
|
const attributes = {
|
|
@@ -36,12 +36,16 @@ var Player = function (props) {
|
|
|
36
36
|
width: '100%',
|
|
37
37
|
}, props), height = _a.height, width = _a.width, minHeight = _a.minHeight, children = _a.children;
|
|
38
38
|
var hasMoved = (0, react_1.useRef)(false);
|
|
39
|
-
var
|
|
39
|
+
var _b = (0, usePlayerPortal_1.default)(), portalPlayerTo = _b[0], portalBack = _b[1];
|
|
40
40
|
(0, react_1.useEffect)(function () {
|
|
41
41
|
if (portalPlayerTo && !hasMoved.current) {
|
|
42
42
|
portalPlayerTo(exports.PLAYER_DIV_ID);
|
|
43
43
|
hasMoved.current = true;
|
|
44
44
|
}
|
|
45
|
+
return function () {
|
|
46
|
+
if (portalBack)
|
|
47
|
+
portalBack();
|
|
48
|
+
};
|
|
45
49
|
});
|
|
46
50
|
return (react_1.default.createElement(player_styles_1.Wrapper, { height: height, width: width, minHeight: minHeight, className: className },
|
|
47
51
|
react_1.default.createElement("div", { id: exports.PLAYER_DIV_ID }),
|
|
@@ -33,7 +33,6 @@ function TrebleApp(props) {
|
|
|
33
33
|
var _a;
|
|
34
34
|
var project = props.project, productId = props.productId, playerConfig = props.playerConfig, threekitEnv = props.threekitEnv, locale = props.locale, theme = props.theme;
|
|
35
35
|
var config = constants_1.IS_TREBLE_SCRIPTS ? (0, utils_1.loadTrebleConfig)() : {};
|
|
36
|
-
console.log(config);
|
|
37
36
|
if (!((_a = config.treble) === null || _a === void 0 ? void 0 : _a.productsCtx)) {
|
|
38
37
|
console.error('Treble Config is not setup correctly');
|
|
39
38
|
return null;
|
package/dist/constants.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export declare const TK_SAVED_CONFIG_PARAM_KEY = "tkConfigId";
|
|
|
21
21
|
/*****************************************************
|
|
22
22
|
* Threekit Player Initialization Defaults
|
|
23
23
|
****************************************************/
|
|
24
|
+
export declare const TK_PLAYER_LOADER_DIV = "tk-ply-loader";
|
|
24
25
|
export declare const TK_PLAYER_ROOT_DIV = "tk-ply-root";
|
|
25
26
|
export declare const DEFAULT_PLAYER_CONFIG: {
|
|
26
27
|
showConfigurator: boolean;
|
package/dist/constants.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
****************************************************/
|
|
5
5
|
var _a;
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.WISHLIST_LOCALSTORAGE_KEY = exports.SNAPSHOT_OUTPUTS = exports.SNAPSHOT_FORMATS = exports.METADATA_RESERVED = exports.ATTRIBUTES_RESERVED = exports.SORT_OPTIONS = exports.ATTRIBUTE_TYPES = exports.DEFAULT_PLAYER_CONFIG = exports.TK_PLAYER_ROOT_DIV = exports.TK_SAVED_CONFIG_PARAM_KEY = exports.TK_PRODUCT_ID_PARAM_KEY = exports.IS_TREBLE_SCRIPTS = exports.FORM_CLASS_NAME = exports.DISPLAY_CLASS_NAME = exports.TOOL_CLASS_NAME = exports.LAYOUT_CLASS_NAME = exports.WIDGET_CLASS_NAME = exports.INPUT_COMPONENT_CLASS_NAME = exports.CLASS_NAME_PREFIX = exports.DEFAULT_CLASS_NAME = void 0;
|
|
7
|
+
exports.WISHLIST_LOCALSTORAGE_KEY = exports.SNAPSHOT_OUTPUTS = exports.SNAPSHOT_FORMATS = exports.METADATA_RESERVED = exports.ATTRIBUTES_RESERVED = exports.SORT_OPTIONS = exports.ATTRIBUTE_TYPES = exports.DEFAULT_PLAYER_CONFIG = exports.TK_PLAYER_ROOT_DIV = exports.TK_PLAYER_LOADER_DIV = exports.TK_SAVED_CONFIG_PARAM_KEY = exports.TK_PRODUCT_ID_PARAM_KEY = exports.IS_TREBLE_SCRIPTS = exports.FORM_CLASS_NAME = exports.DISPLAY_CLASS_NAME = exports.TOOL_CLASS_NAME = exports.LAYOUT_CLASS_NAME = exports.WIDGET_CLASS_NAME = exports.INPUT_COMPONENT_CLASS_NAME = exports.CLASS_NAME_PREFIX = exports.DEFAULT_CLASS_NAME = void 0;
|
|
8
8
|
exports.DEFAULT_CLASS_NAME = 'threekit-react';
|
|
9
9
|
exports.CLASS_NAME_PREFIX = 'tk';
|
|
10
10
|
exports.INPUT_COMPONENT_CLASS_NAME = "".concat(exports.DEFAULT_CLASS_NAME, " ").concat(exports.CLASS_NAME_PREFIX, "-input");
|
|
@@ -25,6 +25,7 @@ exports.TK_SAVED_CONFIG_PARAM_KEY = 'tkConfigId';
|
|
|
25
25
|
/*****************************************************
|
|
26
26
|
* Threekit Player Initialization Defaults
|
|
27
27
|
****************************************************/
|
|
28
|
+
exports.TK_PLAYER_LOADER_DIV = 'tk-ply-loader';
|
|
28
29
|
exports.TK_PLAYER_ROOT_DIV = 'tk-ply-root';
|
|
29
30
|
exports.DEFAULT_PLAYER_CONFIG = {
|
|
30
31
|
// authToken: undefined,
|
|
@@ -1,22 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var react_1 = require("react");
|
|
3
4
|
var react_redux_1 = require("react-redux");
|
|
4
5
|
var threekit_1 = require("../../store/threekit");
|
|
6
|
+
var constants_1 = require("../../constants");
|
|
5
7
|
var usePlayerPortal = function () {
|
|
8
|
+
var htmlElements = (0, react_1.useRef)({
|
|
9
|
+
player: null,
|
|
10
|
+
playerLoader: null,
|
|
11
|
+
playerWrapper: null,
|
|
12
|
+
});
|
|
6
13
|
var playerElementId = (0, react_redux_1.useSelector)(threekit_1.getPlayerElementId);
|
|
7
14
|
if (!playerElementId)
|
|
8
|
-
return undefined;
|
|
15
|
+
return [undefined, undefined];
|
|
9
16
|
var portalPlayerTo = function (toEl) {
|
|
10
17
|
if (!toEl)
|
|
11
18
|
return;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
19
|
+
if (!htmlElements.current.player)
|
|
20
|
+
htmlElements.current.player = document.getElementById(playerElementId);
|
|
21
|
+
htmlElements.current.playerWrapper = document.getElementById(toEl);
|
|
22
|
+
if (!htmlElements.current.player)
|
|
15
23
|
throw new Error('Move from element not found');
|
|
16
|
-
if (!
|
|
24
|
+
if (!htmlElements.current.playerWrapper)
|
|
17
25
|
throw new Error('Move To element not found');
|
|
18
|
-
|
|
26
|
+
htmlElements.current.playerWrapper.appendChild(htmlElements.current.player);
|
|
19
27
|
};
|
|
20
|
-
|
|
28
|
+
var returnPlayer = function () {
|
|
29
|
+
constants_1.TK_PLAYER_LOADER_DIV;
|
|
30
|
+
if (!htmlElements.current.player)
|
|
31
|
+
htmlElements.current.player = document.getElementById(playerElementId);
|
|
32
|
+
if (!htmlElements.current.playerLoader)
|
|
33
|
+
htmlElements.current.playerLoader =
|
|
34
|
+
document.getElementById(constants_1.TK_PLAYER_LOADER_DIV);
|
|
35
|
+
if (!htmlElements.current.player)
|
|
36
|
+
throw new Error('Move from element not found');
|
|
37
|
+
if (!htmlElements.current.playerLoader)
|
|
38
|
+
throw new Error('Player Loader element not found');
|
|
39
|
+
htmlElements.current.playerLoader.appendChild(htmlElements.current.player);
|
|
40
|
+
};
|
|
41
|
+
return [portalPlayerTo, returnPlayer];
|
|
21
42
|
};
|
|
22
43
|
exports.default = usePlayerPortal;
|
package/dist/store/threekit.js
CHANGED
|
@@ -75,7 +75,7 @@ var createPlayerLoaderEl = function (elementId) {
|
|
|
75
75
|
playerElement.setAttribute('id', elementId);
|
|
76
76
|
playerElement.style.height = '100%';
|
|
77
77
|
var playerLoader = document.createElement('div');
|
|
78
|
-
playerLoader.setAttribute('id',
|
|
78
|
+
playerLoader.setAttribute('id', constants_1.TK_PLAYER_LOADER_DIV);
|
|
79
79
|
playerLoader.appendChild(playerElement);
|
|
80
80
|
playerLoader.style.opacity = '0';
|
|
81
81
|
playerLoader.style.height = '1px';
|