@threekit-tools/treble 0.0.37-codepen-0 → 0.0.40
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/ProductName/index.js +1 -1
- package/dist/components/ThreekitProvider/index.js +1 -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/dist/utils.js +24 -18
- package/package.json +6 -8
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 }),
|
|
@@ -15,7 +15,7 @@ var ProductName = function (props) {
|
|
|
15
15
|
if (!(title === null || title === void 0 ? void 0 : title.length) && !name)
|
|
16
16
|
return null;
|
|
17
17
|
var cls = (0, utils_1.generateDisplayClassName)('title', customClassName);
|
|
18
|
-
return (react_1.default.createElement(productName_styles_1.Wrapper, { align: align, className: cls },
|
|
18
|
+
return (react_1.default.createElement(productName_styles_1.Wrapper, { align: align, className: cls }, title || name));
|
|
19
19
|
};
|
|
20
20
|
exports.ProductName = ProductName;
|
|
21
21
|
exports.ProductName.propTypes = {
|
|
@@ -38,7 +38,7 @@ var App = function (props) {
|
|
|
38
38
|
};
|
|
39
39
|
init();
|
|
40
40
|
return;
|
|
41
|
-
}, [props.project, props.threekitEnv,
|
|
41
|
+
}, [props.project, props.threekitEnv, props.playerConfig]);
|
|
42
42
|
return react_1.default.createElement(react_1.default.Fragment, null, props.children);
|
|
43
43
|
};
|
|
44
44
|
var ThreekitProvider = function (props) {
|
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';
|
package/dist/utils.js
CHANGED
|
@@ -351,24 +351,30 @@ var isUuid = function (str) {
|
|
|
351
351
|
exports.isUuid = isUuid;
|
|
352
352
|
var loadTrebleConfig = function () {
|
|
353
353
|
var config = {};
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
354
|
+
try {
|
|
355
|
+
var project = require("/threekit.config.js").default;
|
|
356
|
+
if (project)
|
|
357
|
+
config.project = project;
|
|
358
|
+
}
|
|
359
|
+
catch (e) {
|
|
360
|
+
console.log(e);
|
|
361
|
+
}
|
|
362
|
+
try {
|
|
363
|
+
var player = require('/.treble/player.config.js').default;
|
|
364
|
+
if (player)
|
|
365
|
+
config.player = player;
|
|
366
|
+
}
|
|
367
|
+
catch (e) {
|
|
368
|
+
console.log(e);
|
|
369
|
+
}
|
|
370
|
+
try {
|
|
371
|
+
var treble = require('/.treble/treble.config.js').default;
|
|
372
|
+
if (treble)
|
|
373
|
+
config.treble = treble;
|
|
374
|
+
}
|
|
375
|
+
catch (e) {
|
|
376
|
+
console.log(e);
|
|
377
|
+
}
|
|
372
378
|
return config;
|
|
373
379
|
};
|
|
374
380
|
exports.loadTrebleConfig = loadTrebleConfig;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@threekit-tools/treble",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.40",
|
|
4
4
|
"author": "Amaan Saeed",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -32,10 +32,6 @@
|
|
|
32
32
|
"reselect": "^4.1.2",
|
|
33
33
|
"styled-components": "^5.3.3"
|
|
34
34
|
},
|
|
35
|
-
"peerDependencies": {
|
|
36
|
-
"react": "^17.0.2",
|
|
37
|
-
"react-dom": "^17.0.2"
|
|
38
|
-
},
|
|
39
35
|
"devDependencies": {
|
|
40
36
|
"@babel/core": "^7.15.8",
|
|
41
37
|
"@storybook/addon-actions": "^6.3.12",
|
|
@@ -45,16 +41,18 @@
|
|
|
45
41
|
"@storybook/addon-storysource": "^6.3.12",
|
|
46
42
|
"@storybook/react": "^6.3.12",
|
|
47
43
|
"@types/node": "^16.10.3",
|
|
48
|
-
"@types/react": "
|
|
49
|
-
"@types/react-dom": "
|
|
44
|
+
"@types/react": ">=17.0.27",
|
|
45
|
+
"@types/react-dom": ">=17.0.9",
|
|
50
46
|
"@types/redux-logger": "^3.0.9",
|
|
51
47
|
"@types/styled-components": "^5.1.15",
|
|
52
48
|
"@types/webpack-env": "^1.16.3",
|
|
53
49
|
"babel-loader": "^8.2.2",
|
|
50
|
+
"react": ">=17.0.2",
|
|
51
|
+
"react-dom": ">=17.0.2",
|
|
54
52
|
"rimraf": "^3.0.2",
|
|
55
53
|
"serve": "^12.0.1",
|
|
56
54
|
"storybook-addon-styled-component-theme": "^2.0.0",
|
|
57
|
-
"typescript": "
|
|
55
|
+
"typescript": ">=4.4.4"
|
|
58
56
|
},
|
|
59
57
|
"gitHead": "2e16bcf98f81e16bb1768072fdb3968122e7966f"
|
|
60
58
|
}
|