@threekit-tools/treble 0.0.57 → 0.0.60
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 +32 -63
- package/dist/Treble/Treble.d.ts +8 -6
- package/dist/Treble/Treble.js +19 -4
- package/dist/Treble/Wishlist.d.ts +3 -3
- package/dist/Treble/Wishlist.js +1 -0
- package/dist/api/configurations.d.ts +2 -3
- package/dist/api/configurations.js +28 -22
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.js +2 -0
- package/dist/api/server.d.ts +2 -0
- package/dist/api/server.js +11 -0
- package/dist/components/Cards/index.js +3 -4
- package/dist/components/Dropdown/index.js +6 -10
- package/dist/components/Strips/index.js +3 -4
- package/dist/components/Swatch/index.js +3 -4
- package/dist/components/TextInput/index.d.ts +1 -0
- package/dist/components/TextInput/index.js +2 -2
- package/dist/components/TextInput/textInput.styles.js +1 -1
- package/dist/components/Tiles/index.js +3 -4
- package/dist/components/TilesGroup/index.js +3 -4
- package/dist/components/containers/formInputContainer.d.ts +8 -4
- package/dist/components/containers/formInputContainer.js +10 -15
- package/dist/connection.d.ts +4 -1
- package/dist/connection.js +4 -0
- package/dist/hooks/useAttribute/index.d.ts +2 -2
- package/dist/hooks/useAttribute/index.js +2 -4
- package/dist/hooks/useConfigurator/index.d.ts +2 -2
- package/dist/hooks/useConfigurator/index.js +1 -1
- package/dist/hooks/useProductCache/index.d.ts +14 -0
- package/dist/hooks/useProductCache/index.js +35 -0
- package/dist/hooks/useSingleAnimation/index.d.ts +17 -0
- package/dist/hooks/useSingleAnimation/index.js +264 -0
- package/dist/hooks/useWishlist/index.d.ts +3 -2
- package/dist/hooks/useWishlist/index.js +1 -3
- package/dist/http/configurations.d.ts +1 -0
- package/dist/http/index.d.ts +2 -0
- package/dist/http/index.js +2 -0
- package/dist/http/server.d.ts +14 -0
- package/dist/http/server.js +17 -0
- package/dist/index.js +2 -0
- package/dist/store/attributes.d.ts +15 -2
- package/dist/store/attributes.js +20 -12
- package/dist/store/price.js +2 -2
- package/dist/store/product.d.ts +38 -2
- package/dist/store/product.js +221 -10
- package/dist/store/translations.d.ts +1 -0
- package/dist/store/translations.js +3 -1
- package/dist/store/treble.d.ts +32 -2
- package/dist/store/treble.js +157 -34
- package/dist/store/wishlist.d.ts +3 -2
- package/dist/threekit.d.ts +20 -2
- package/dist/utils.d.ts +2 -10
- package/dist/utils.js +62 -58
- package/package.json +17 -2
- package/dist/hooks/useArrayAttribute/index.d.ts +0 -2
- package/dist/hooks/useArrayAttribute/index.js +0 -184
|
@@ -29,15 +29,13 @@ var prepAttributeForComponent = function (attribute, config) {
|
|
|
29
29
|
var descriptionKey = metadataKeyDescription || constants_1.METADATA_RESERVED.description;
|
|
30
30
|
var options;
|
|
31
31
|
var selected = attribute.value;
|
|
32
|
-
if (attribute.type ===
|
|
33
|
-
|
|
34
|
-
options = stringAttribute.values.map(function (el) { return (__assign(__assign({}, el), { name: el.label })); });
|
|
32
|
+
if (attribute.type === 'String') {
|
|
33
|
+
options = attribute.values.map(function (el) { return (__assign(__assign({}, el), { name: el.label })); });
|
|
35
34
|
}
|
|
36
|
-
else if (attribute.type ===
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
? assetAttribute.values
|
|
35
|
+
else if (attribute.type === 'Asset') {
|
|
36
|
+
selected = (_a = attribute.value) === null || _a === void 0 ? void 0 : _a.assetId;
|
|
37
|
+
options = attribute.values
|
|
38
|
+
? attribute.values
|
|
41
39
|
.map(function (el) { return prepCatalogItem(el); })
|
|
42
40
|
.sort(function (a, b) {
|
|
43
41
|
if (!sort || !Object.keys(constants_1.SORT_OPTIONS).includes(sort))
|
|
@@ -50,9 +48,8 @@ var prepAttributeForComponent = function (attribute, config) {
|
|
|
50
48
|
})
|
|
51
49
|
: [];
|
|
52
50
|
}
|
|
53
|
-
else if (attribute.type ===
|
|
54
|
-
|
|
55
|
-
selected = (0, utils_1.inflateRgb)(colorAttribute.value);
|
|
51
|
+
else if (attribute.type === 'Color') {
|
|
52
|
+
selected = (0, utils_1.inflateRgb)(attribute.value);
|
|
56
53
|
}
|
|
57
54
|
function prepCatalogItem(item) {
|
|
58
55
|
var _a, _b;
|
|
@@ -80,9 +77,7 @@ var prepAttributeForComponent = function (attribute, config) {
|
|
|
80
77
|
return { selected: selected, options: options };
|
|
81
78
|
};
|
|
82
79
|
exports.prepAttributeForComponent = prepAttributeForComponent;
|
|
83
|
-
function formComponentContainer(FormComponent
|
|
84
|
-
// FormComponent: IFormComponent<P>
|
|
85
|
-
) {
|
|
80
|
+
function formComponentContainer(FormComponent) {
|
|
86
81
|
return function (props) {
|
|
87
82
|
var attribute = props.attribute, metadataKeyThumbnail = props.metadataKeyThumbnail, metadataKeyDescription = props.metadataKeyDescription, metadataKeyPrice = props.metadataKeyPrice, hideAttributeTitle = props.hideAttributeTitle, sort = props.sort;
|
|
88
83
|
var isLoading = (0, usePlayerLoadingStatus_1.default)();
|
|
@@ -104,7 +99,7 @@ function formComponentContainer(FormComponent
|
|
|
104
99
|
sort: sort,
|
|
105
100
|
}), selected = _b.selected, options = _b.options;
|
|
106
101
|
var handleSetAttribute = function (value) {
|
|
107
|
-
return setAttribute
|
|
102
|
+
return setAttribute === null || setAttribute === void 0 ? void 0 : setAttribute(value);
|
|
108
103
|
};
|
|
109
104
|
var preppedProps = __assign({}, props);
|
|
110
105
|
if (!hideAttributeTitle && !preppedProps.title)
|
package/dist/connection.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
interface IConnectionConfig {
|
|
1
|
+
export interface IConnectionConfig {
|
|
2
2
|
authToken?: string;
|
|
3
3
|
orgId?: string;
|
|
4
4
|
assetId?: string;
|
|
5
5
|
threekitDomain?: string;
|
|
6
|
+
serverUrl?: string;
|
|
6
7
|
}
|
|
7
8
|
export declare class ThreekitConnection {
|
|
8
9
|
_authToken: string;
|
|
9
10
|
_orgId: string;
|
|
10
11
|
_assetId: string;
|
|
11
12
|
_threekitDomain: string;
|
|
13
|
+
_serverUrl: string;
|
|
12
14
|
constructor();
|
|
13
15
|
connect(config: IConnectionConfig): Promise<void>;
|
|
14
16
|
getConnection(): {
|
|
@@ -16,6 +18,7 @@ export declare class ThreekitConnection {
|
|
|
16
18
|
orgId: string;
|
|
17
19
|
assetId: string;
|
|
18
20
|
threekitDomain: string;
|
|
21
|
+
serverUrl: string;
|
|
19
22
|
};
|
|
20
23
|
}
|
|
21
24
|
declare const _default: ThreekitConnection;
|
package/dist/connection.js
CHANGED
|
@@ -42,6 +42,7 @@ var ThreekitConnection = /** @class */ (function () {
|
|
|
42
42
|
this._authToken = '';
|
|
43
43
|
this._orgId = '';
|
|
44
44
|
this._assetId = '';
|
|
45
|
+
this._serverUrl = '';
|
|
45
46
|
this._threekitDomain = 'https://admin-fts.threekit.com';
|
|
46
47
|
}
|
|
47
48
|
ThreekitConnection.prototype.connect = function (config) {
|
|
@@ -53,6 +54,8 @@ var ThreekitConnection = /** @class */ (function () {
|
|
|
53
54
|
this._orgId = config.orgId;
|
|
54
55
|
if (config.assetId)
|
|
55
56
|
this._assetId = config.assetId;
|
|
57
|
+
if (config.serverUrl)
|
|
58
|
+
this._serverUrl = config.serverUrl;
|
|
56
59
|
if (config.threekitDomain)
|
|
57
60
|
this._threekitDomain = "https://".concat(config.threekitDomain);
|
|
58
61
|
return [2 /*return*/];
|
|
@@ -68,6 +71,7 @@ var ThreekitConnection = /** @class */ (function () {
|
|
|
68
71
|
orgId: this._orgId,
|
|
69
72
|
assetId: this._assetId,
|
|
70
73
|
threekitDomain: this._threekitDomain,
|
|
74
|
+
serverUrl: this._serverUrl,
|
|
71
75
|
};
|
|
72
76
|
};
|
|
73
77
|
return ThreekitConnection;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IHydratedAttribute, IConfigurationColor } from '../../threekit';
|
|
2
2
|
export declare type RawAttributeValue = string | number | boolean | IConfigurationColor | File | undefined;
|
|
3
3
|
declare type UseAttributeError = [undefined, undefined];
|
|
4
4
|
declare type UseAttributeSuccess = [
|
|
5
|
-
|
|
5
|
+
IHydratedAttribute,
|
|
6
6
|
(val: RawAttributeValue) => Promise<void>
|
|
7
7
|
];
|
|
8
8
|
declare type UseAttributeHook = UseAttributeError | UseAttributeSuccess;
|
|
@@ -42,13 +42,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
42
42
|
var store_1 = require("../../store");
|
|
43
43
|
var attributes_1 = require("../../store/attributes");
|
|
44
44
|
var utils_1 = require("../../utils");
|
|
45
|
-
var constants_1 = require("../../constants");
|
|
46
45
|
var api_1 = __importDefault(require("../../api"));
|
|
47
46
|
var useAttribute = function (attributeName) {
|
|
48
47
|
if (!attributeName)
|
|
49
48
|
return [undefined, undefined];
|
|
50
49
|
var dispatch = (0, store_1.useThreekitDispatch)();
|
|
51
|
-
var attributes = (0, store_1.useThreekitSelector)(attributes_1.
|
|
50
|
+
var attributes = (0, store_1.useThreekitSelector)(attributes_1.getHydratedAttributes);
|
|
52
51
|
if (!attributeName || !attributes)
|
|
53
52
|
return [undefined, undefined];
|
|
54
53
|
var attribute = attributes[attributeName];
|
|
@@ -60,8 +59,7 @@ var useAttribute = function (attributeName) {
|
|
|
60
59
|
return __generator(this, function (_b) {
|
|
61
60
|
switch (_b.label) {
|
|
62
61
|
case 0:
|
|
63
|
-
if (!(attribute.type === 'Asset' &&
|
|
64
|
-
attribute.assetType === constants_1.ASSET_TYPES.upload)) return [3 /*break*/, 4];
|
|
62
|
+
if (!(attribute.type === 'Asset' && attribute.assetType === 'upload')) return [3 /*break*/, 4];
|
|
65
63
|
if (!!value) return [3 /*break*/, 1];
|
|
66
64
|
preppedValue = (0, utils_1.selectionToConfiguration)('', attribute.type);
|
|
67
65
|
return [3 /*break*/, 3];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ISetConfiguration,
|
|
1
|
+
import { ISetConfiguration, IHydratedAttribute } from '../../threekit';
|
|
2
2
|
declare type UseConfiguratorError = [undefined, undefined];
|
|
3
3
|
declare type UseConfiguratorSuccess = [
|
|
4
|
-
Record<string,
|
|
4
|
+
Record<string, IHydratedAttribute>,
|
|
5
5
|
(configuration: ISetConfiguration) => void
|
|
6
6
|
];
|
|
7
7
|
declare type UseConfiguratorHook = UseConfiguratorError | UseConfiguratorSuccess;
|
|
@@ -4,7 +4,7 @@ var attributes_1 = require("../../store/attributes");
|
|
|
4
4
|
var store_1 = require("../../store");
|
|
5
5
|
var useConfigurator = function () {
|
|
6
6
|
var dispatch = (0, store_1.useThreekitDispatch)();
|
|
7
|
-
var attributes = (0, store_1.useThreekitSelector)(attributes_1.
|
|
7
|
+
var attributes = (0, store_1.useThreekitSelector)(attributes_1.getHydratedAttributes);
|
|
8
8
|
if (!attributes)
|
|
9
9
|
return [undefined, undefined];
|
|
10
10
|
var handleChange = function (configuration) {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CachedProduct } from '../../store/product';
|
|
2
|
+
import { IReloadConfig } from '../../store/treble';
|
|
3
|
+
interface CacheData {
|
|
4
|
+
activeProductIdx: number;
|
|
5
|
+
cache: Array<Pick<CachedProduct, 'name' | 'label' | 'thumbnail'>>;
|
|
6
|
+
}
|
|
7
|
+
declare type UseProductCache = [
|
|
8
|
+
CacheData,
|
|
9
|
+
(config?: string | IReloadConfig) => Promise<void>,
|
|
10
|
+
(idx: number) => Promise<void>,
|
|
11
|
+
(idx: number) => Promise<void>
|
|
12
|
+
];
|
|
13
|
+
declare const useProductCache: () => UseProductCache;
|
|
14
|
+
export default useProductCache;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var product_1 = require("../../store/product");
|
|
4
|
+
var store_1 = require("../../store");
|
|
5
|
+
var useProductCache = function () {
|
|
6
|
+
var dispatch = (0, store_1.useThreekitDispatch)();
|
|
7
|
+
var cache = (0, store_1.useThreekitSelector)(product_1.getProductCache);
|
|
8
|
+
var activeProductIdx = (0, store_1.useThreekitSelector)(product_1.getActiveProductIdx);
|
|
9
|
+
var data = {
|
|
10
|
+
cache: cache,
|
|
11
|
+
activeProductIdx: activeProductIdx,
|
|
12
|
+
};
|
|
13
|
+
var handleChangeActiveProduct = function (idx) {
|
|
14
|
+
if (idx === undefined)
|
|
15
|
+
return Promise.resolve();
|
|
16
|
+
if (idx === activeProductIdx)
|
|
17
|
+
return Promise.resolve();
|
|
18
|
+
if (!cache || idx >= (cache === null || cache === void 0 ? void 0 : cache.length))
|
|
19
|
+
return Promise.resolve();
|
|
20
|
+
return dispatch((0, product_1.changeActiveProductIdx)(idx));
|
|
21
|
+
};
|
|
22
|
+
var handleLoadNewProduct = function (config) {
|
|
23
|
+
return dispatch((0, product_1.loadNewProduct)(config));
|
|
24
|
+
};
|
|
25
|
+
var handleRemoveProduct = function (idx) {
|
|
26
|
+
return dispatch((0, product_1.removeProductIdx)(idx));
|
|
27
|
+
};
|
|
28
|
+
return [
|
|
29
|
+
data,
|
|
30
|
+
handleLoadNewProduct,
|
|
31
|
+
handleChangeActiveProduct,
|
|
32
|
+
handleRemoveProduct,
|
|
33
|
+
];
|
|
34
|
+
};
|
|
35
|
+
exports.default = useProductCache;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ICoordinates } from '../../threekit';
|
|
2
|
+
interface NodeConfig {
|
|
3
|
+
nodeId: string;
|
|
4
|
+
paddingStart: number;
|
|
5
|
+
paddingEnd: number;
|
|
6
|
+
delay: number;
|
|
7
|
+
duration: number;
|
|
8
|
+
translation: ICoordinates;
|
|
9
|
+
rotation: ICoordinates;
|
|
10
|
+
scale: ICoordinates;
|
|
11
|
+
}
|
|
12
|
+
interface AnimationConfig {
|
|
13
|
+
duration: number;
|
|
14
|
+
nodes: Array<NodeConfig>;
|
|
15
|
+
}
|
|
16
|
+
declare const useAnimation: (animationConfig: AnimationConfig) => undefined[] | (boolean | (() => Promise<void>))[];
|
|
17
|
+
export default useAnimation;
|
|
@@ -0,0 +1,264 @@
|
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
var react_1 = require("react");
|
|
54
|
+
var useThreekitInitStatus_1 = __importDefault(require("../useThreekitInitStatus"));
|
|
55
|
+
var utils_1 = require("../../utils");
|
|
56
|
+
var prepAnimateConfig = function (config) {
|
|
57
|
+
return new Promise(function (resolve) { return __awaiter(void 0, void 0, void 0, function () {
|
|
58
|
+
var totalDuration, player, assetId, nodesRaw, nodes;
|
|
59
|
+
return __generator(this, function (_a) {
|
|
60
|
+
switch (_a.label) {
|
|
61
|
+
case 0:
|
|
62
|
+
totalDuration = config.duration * 1000 || 0;
|
|
63
|
+
player = window.threekit.player.enableApi('player');
|
|
64
|
+
return [4 /*yield*/, player.getAssetInstance(window.threekit.player.scene.find({
|
|
65
|
+
id: window.threekit.player.instanceId,
|
|
66
|
+
plug: 'Proxy',
|
|
67
|
+
property: 'asset',
|
|
68
|
+
}))];
|
|
69
|
+
case 1:
|
|
70
|
+
assetId = _a.sent();
|
|
71
|
+
nodesRaw = Object.entries(config.nodes).reduce(function (output, _a) {
|
|
72
|
+
var _b;
|
|
73
|
+
var name = _a[0], nodeData = _a[1];
|
|
74
|
+
var nodeId = window.threekit.player.scene.get({
|
|
75
|
+
from: assetId,
|
|
76
|
+
name: name,
|
|
77
|
+
}).id;
|
|
78
|
+
var node = Object.assign({ nodeId: nodeId }, { duration: (nodeData.duration || config.duration || 0) * 1000 }, { paddingStart: (nodeData.delay || 0) * 1000 }, 'translation' in nodeData
|
|
79
|
+
? {
|
|
80
|
+
translation: [
|
|
81
|
+
window.threekit.player.scene.get({
|
|
82
|
+
from: assetId,
|
|
83
|
+
id: nodeId,
|
|
84
|
+
plug: 'Transform',
|
|
85
|
+
property: 'translation',
|
|
86
|
+
}),
|
|
87
|
+
Object.assign({ x: 0, y: 0, z: 0 }, nodeData.translation),
|
|
88
|
+
],
|
|
89
|
+
}
|
|
90
|
+
: {}, 'rotation' in nodeData
|
|
91
|
+
? {
|
|
92
|
+
rotation: [
|
|
93
|
+
window.threekit.player.scene.get({
|
|
94
|
+
from: assetId,
|
|
95
|
+
id: nodeId,
|
|
96
|
+
plug: 'Transform',
|
|
97
|
+
property: 'rotation',
|
|
98
|
+
}),
|
|
99
|
+
Object.assign({ x: 0, y: 0, z: 0 }, nodeData.rotation),
|
|
100
|
+
],
|
|
101
|
+
}
|
|
102
|
+
: {}, 'scale' in nodeData
|
|
103
|
+
? {
|
|
104
|
+
scale: [
|
|
105
|
+
window.threekit.player.scene.get({
|
|
106
|
+
from: assetId,
|
|
107
|
+
id: nodeId,
|
|
108
|
+
plug: 'Transform',
|
|
109
|
+
property: 'scale',
|
|
110
|
+
}),
|
|
111
|
+
Object.assign({ x: 0, y: 0, z: 0 }, nodeData.scale),
|
|
112
|
+
],
|
|
113
|
+
}
|
|
114
|
+
: {});
|
|
115
|
+
var duration = node.duration + node.paddingStart;
|
|
116
|
+
if (duration > totalDuration)
|
|
117
|
+
totalDuration = duration;
|
|
118
|
+
return Object.assign(output, (_b = {}, _b[name] = node, _b));
|
|
119
|
+
}, {});
|
|
120
|
+
nodes = Object.entries(nodesRaw).reduce(function (output, _a) {
|
|
121
|
+
var _b;
|
|
122
|
+
var nodeName = _a[0], nodeData = _a[1];
|
|
123
|
+
var paddingEnd = 0;
|
|
124
|
+
if (totalDuration !== nodeData.duration + nodeData.paddingStart)
|
|
125
|
+
paddingEnd =
|
|
126
|
+
totalDuration - (nodeData.duration + nodeData.paddingStart);
|
|
127
|
+
return Object.assign(output, (_b = {},
|
|
128
|
+
_b[nodeName] = __assign(__assign({}, nodeData), { paddingEnd: paddingEnd }),
|
|
129
|
+
_b));
|
|
130
|
+
}, {});
|
|
131
|
+
resolve([assetId, totalDuration, nodes]);
|
|
132
|
+
return [2 /*return*/];
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}); });
|
|
136
|
+
};
|
|
137
|
+
var useAnimation = function (animationConfig) {
|
|
138
|
+
var _a = (0, react_1.useState)(false), animationInProgress = _a[0], setAnimationInProgress = _a[1];
|
|
139
|
+
var ref = (0, react_1.useRef)({
|
|
140
|
+
assetId: undefined,
|
|
141
|
+
startTime: 0,
|
|
142
|
+
totalDuration: 0,
|
|
143
|
+
nodes: {},
|
|
144
|
+
isTransformed: false,
|
|
145
|
+
});
|
|
146
|
+
var isLoaded = (0, useThreekitInitStatus_1.default)();
|
|
147
|
+
if (!isLoaded)
|
|
148
|
+
return [undefined, undefined];
|
|
149
|
+
var animateFrame = function (timestamp) {
|
|
150
|
+
// if (startTime.current === undefined) startTime.current = timestamp;
|
|
151
|
+
// const elapsed = timestamp - startTime.current;
|
|
152
|
+
if (ref.current.startTime === undefined)
|
|
153
|
+
ref.current.startTime = timestamp;
|
|
154
|
+
var elapsed = timestamp - ref.current.startTime;
|
|
155
|
+
Object.values(ref.current.nodes).forEach(function (nodeConfig) {
|
|
156
|
+
if (!ref.current.isTransformed) {
|
|
157
|
+
// If its too early we don't animate
|
|
158
|
+
if (elapsed < nodeConfig.paddingStart)
|
|
159
|
+
return;
|
|
160
|
+
// If its too early we don't animate
|
|
161
|
+
if (elapsed > nodeConfig.duration + nodeConfig.paddingStart)
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
else if (ref.current.isTransformed) {
|
|
165
|
+
// If its too early we don't animate
|
|
166
|
+
if (elapsed < nodeConfig.paddingEnd)
|
|
167
|
+
return;
|
|
168
|
+
// If its too early we don't animate
|
|
169
|
+
if (elapsed > nodeConfig.duration + nodeConfig.paddingEnd)
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
var progressTime = !ref.current.isTransformed
|
|
173
|
+
? elapsed - nodeConfig.paddingStart
|
|
174
|
+
: elapsed - nodeConfig.paddingEnd;
|
|
175
|
+
var animationPercent = (0, utils_1.easeInOutCubic)(progressTime / nodeConfig.duration);
|
|
176
|
+
var translation;
|
|
177
|
+
var rotation;
|
|
178
|
+
var scale;
|
|
179
|
+
if ('translation' in nodeConfig) {
|
|
180
|
+
translation = Object.keys(nodeConfig.translation[1]).reduce(function (output, axis) {
|
|
181
|
+
var _a;
|
|
182
|
+
var value = !ref.current.isTransformed
|
|
183
|
+
? nodeConfig.translation[0][axis] +
|
|
184
|
+
nodeConfig.translation[1][axis] * animationPercent
|
|
185
|
+
: nodeConfig.translation[1][axis] +
|
|
186
|
+
nodeConfig.translation[0][axis] -
|
|
187
|
+
nodeConfig.translation[1][axis] * animationPercent;
|
|
188
|
+
return Object.assign(output, (_a = {}, _a[axis] = value, _a));
|
|
189
|
+
}, {});
|
|
190
|
+
window.threekit.player.scene.set({
|
|
191
|
+
from: ref.current.assetId,
|
|
192
|
+
id: nodeConfig.nodeId,
|
|
193
|
+
plug: 'Transform',
|
|
194
|
+
property: 'translation',
|
|
195
|
+
}, translation);
|
|
196
|
+
}
|
|
197
|
+
if ('rotation' in nodeConfig) {
|
|
198
|
+
rotation = Object.keys(nodeConfig.rotation[1]).reduce(function (output, axis) {
|
|
199
|
+
var _a;
|
|
200
|
+
var value = !ref.current.isTransformed
|
|
201
|
+
? nodeConfig.rotation[0][axis] +
|
|
202
|
+
nodeConfig.rotation[1][axis] * animationPercent
|
|
203
|
+
: nodeConfig.rotation[1][axis] +
|
|
204
|
+
nodeConfig.rotation[0][axis] -
|
|
205
|
+
nodeConfig.rotation[1][axis] * animationPercent;
|
|
206
|
+
return Object.assign(output, (_a = {}, _a[axis] = value, _a));
|
|
207
|
+
}, {});
|
|
208
|
+
window.threekit.player.scene.set({
|
|
209
|
+
from: ref.current.assetId,
|
|
210
|
+
id: nodeConfig.nodeId,
|
|
211
|
+
plug: 'Transform',
|
|
212
|
+
property: 'rotation',
|
|
213
|
+
}, rotation);
|
|
214
|
+
}
|
|
215
|
+
if ('scale' in nodeConfig) {
|
|
216
|
+
scale = Object.keys(nodeConfig.scale[1]).reduce(function (output, axis) {
|
|
217
|
+
var _a;
|
|
218
|
+
var value = !ref.current.isTransformed
|
|
219
|
+
? nodeConfig.scale[0][axis] +
|
|
220
|
+
nodeConfig.scale[1][axis] * animationPercent
|
|
221
|
+
: nodeConfig.scale[1][axis] +
|
|
222
|
+
nodeConfig.scale[0][axis] -
|
|
223
|
+
nodeConfig.scale[1][axis] * animationPercent;
|
|
224
|
+
return Object.assign(output, (_a = {}, _a[axis] = value, _a));
|
|
225
|
+
}, {});
|
|
226
|
+
window.threekit.player.scene.set({
|
|
227
|
+
from: ref.current.assetId,
|
|
228
|
+
id: nodeConfig.nodeId,
|
|
229
|
+
plug: 'Transform',
|
|
230
|
+
property: 'scale',
|
|
231
|
+
}, scale);
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
if (elapsed < ref.current.totalDuration) {
|
|
235
|
+
window.requestAnimationFrame(animateFrame);
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
setAnimationInProgress(false);
|
|
239
|
+
ref.current.startTime = undefined;
|
|
240
|
+
ref.current.isTransformed = !ref.current.isTransformed;
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
var handleClickAnimate = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
244
|
+
var _a;
|
|
245
|
+
return __generator(this, function (_b) {
|
|
246
|
+
switch (_b.label) {
|
|
247
|
+
case 0:
|
|
248
|
+
ref.current.startTime = undefined;
|
|
249
|
+
if (!!ref.current.nodes) return [3 /*break*/, 2];
|
|
250
|
+
return [4 /*yield*/, prepAnimateConfig(animationConfig)];
|
|
251
|
+
case 1:
|
|
252
|
+
_a = _b.sent(), ref.current.assetId = _a[0], ref.current.totalDuration = _a[1], ref.current.nodes = _a[2];
|
|
253
|
+
ref.current.isTransformed = false;
|
|
254
|
+
_b.label = 2;
|
|
255
|
+
case 2:
|
|
256
|
+
setAnimationInProgress(true);
|
|
257
|
+
window.requestAnimationFrame(animateFrame);
|
|
258
|
+
return [2 /*return*/];
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
}); };
|
|
262
|
+
return [animationInProgress, handleClickAnimate];
|
|
263
|
+
};
|
|
264
|
+
exports.default = useAnimation;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WishlistArray } from '../../Treble';
|
|
2
|
+
import { ISaveConfiguration } from '../../api/configurations';
|
|
2
3
|
declare type UseWishlistHook = [
|
|
3
4
|
WishlistArray,
|
|
4
|
-
(config?:
|
|
5
|
+
(config?: Omit<ISaveConfiguration, 'configurator'>) => void,
|
|
5
6
|
(idx: number) => void,
|
|
6
7
|
(idx: number) => void,
|
|
7
8
|
(idx: number) => void,
|
|
@@ -14,9 +14,7 @@ var useWishlist = function () {
|
|
|
14
14
|
var wishlist = (0, store_1.useThreekitSelector)(wishlist_1.getWishlist);
|
|
15
15
|
if (!isLoaded)
|
|
16
16
|
return [undefined, undefined, undefined, undefined, undefined, undefined];
|
|
17
|
-
var handleAddToWishlist = function (config) {
|
|
18
|
-
return dispatch((0, wishlist_1.addToWishlist)(config));
|
|
19
|
-
};
|
|
17
|
+
var handleAddToWishlist = function (config) { return dispatch((0, wishlist_1.addToWishlist)(config)); };
|
|
20
18
|
var handleRemoveFromWishlist = function (idx) {
|
|
21
19
|
dispatch((0, wishlist_1.removeFromWishlist)(idx));
|
|
22
20
|
message_1.default.info('Item removed from wishlist');
|
|
@@ -13,6 +13,7 @@ export interface IConfigurationResponse {
|
|
|
13
13
|
shortId: string;
|
|
14
14
|
thumbnail: null | string;
|
|
15
15
|
variant: IConfiguration;
|
|
16
|
+
attachments: Record<string, string>;
|
|
16
17
|
}
|
|
17
18
|
interface IConfigurationsResponse extends IMultiPageResponse {
|
|
18
19
|
configurations: Array<IConfigurationResponse>;
|
package/dist/http/index.d.ts
CHANGED
|
@@ -3,11 +3,13 @@ import * as products from './products';
|
|
|
3
3
|
import * as configurations from './configurations';
|
|
4
4
|
import * as pricebook from './pricebook';
|
|
5
5
|
import * as catalog from './catalog';
|
|
6
|
+
import * as server from './server';
|
|
6
7
|
declare const _default: {
|
|
7
8
|
orders: typeof orders;
|
|
8
9
|
products: typeof products;
|
|
9
10
|
configurations: typeof configurations;
|
|
10
11
|
pricebook: typeof pricebook;
|
|
11
12
|
catalog: typeof catalog;
|
|
13
|
+
server: typeof server;
|
|
12
14
|
};
|
|
13
15
|
export default _default;
|
package/dist/http/index.js
CHANGED
|
@@ -24,10 +24,12 @@ var products = __importStar(require("./products"));
|
|
|
24
24
|
var configurations = __importStar(require("./configurations"));
|
|
25
25
|
var pricebook = __importStar(require("./pricebook"));
|
|
26
26
|
var catalog = __importStar(require("./catalog"));
|
|
27
|
+
var server = __importStar(require("./server"));
|
|
27
28
|
exports.default = {
|
|
28
29
|
orders: orders,
|
|
29
30
|
products: products,
|
|
30
31
|
configurations: configurations,
|
|
31
32
|
pricebook: pricebook,
|
|
32
33
|
catalog: catalog,
|
|
34
|
+
server: server,
|
|
33
35
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface IPostEmailRequest {
|
|
2
|
+
From: string;
|
|
3
|
+
To: string;
|
|
4
|
+
TemplateId: string;
|
|
5
|
+
TemplateModel: Record<string, any>;
|
|
6
|
+
}
|
|
7
|
+
export interface IPostEmailResponse {
|
|
8
|
+
To: string;
|
|
9
|
+
SubmittedAt: string;
|
|
10
|
+
MessageID: string;
|
|
11
|
+
ErrorCode: 0;
|
|
12
|
+
Message: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const postEmail: (data: IPostEmailRequest) => Promise<IPostEmailResponse>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.postEmail = void 0;
|
|
7
|
+
var axios_1 = __importDefault(require("axios"));
|
|
8
|
+
var connection_1 = __importDefault(require("../connection"));
|
|
9
|
+
var postEmail = function (data) {
|
|
10
|
+
if (!data)
|
|
11
|
+
throw new Error('data missing');
|
|
12
|
+
var serverUrl = connection_1.default.getConnection().serverUrl;
|
|
13
|
+
if (!serverUrl)
|
|
14
|
+
throw new Error('missing server-url');
|
|
15
|
+
return axios_1.default.post("".concat(serverUrl, "/api/email"), data);
|
|
16
|
+
};
|
|
17
|
+
exports.postEmail = postEmail;
|
package/dist/index.js
CHANGED
|
@@ -39,6 +39,8 @@ var useShare_1 = __importDefault(require("./hooks/useShare"));
|
|
|
39
39
|
exports.useShare = useShare_1.default;
|
|
40
40
|
var usePlayerPortal_1 = __importDefault(require("./hooks/usePlayerPortal"));
|
|
41
41
|
exports.usePlayerPortal = usePlayerPortal_1.default;
|
|
42
|
+
// import useSingleAnimation from './hooks/useSingleAnimation';
|
|
43
|
+
// import useProductCache from './hooks/useProductCache';
|
|
42
44
|
// Components
|
|
43
45
|
var ThreekitProvider_1 = __importDefault(require("./components/ThreekitProvider"));
|
|
44
46
|
exports.ThreekitProvider = ThreekitProvider_1.default;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { RootState, ThreekitDispatch } from './index';
|
|
2
|
-
import { ISetConfiguration, IThreekitDisplayAttribute } from '../threekit';
|
|
2
|
+
import { ISetConfiguration, IThreekitDisplayAttribute, IHydratedAttribute } from '../threekit';
|
|
3
|
+
import { ITranslationMap } from '../api/products';
|
|
3
4
|
/*****************************************************
|
|
4
5
|
* Types and Interfaces
|
|
5
6
|
****************************************************/
|
|
@@ -15,6 +16,18 @@ declare const reducer: import("redux").Reducer<AttributesState, import("redux").
|
|
|
15
16
|
/*****************************************************
|
|
16
17
|
* Standard Selectors
|
|
17
18
|
****************************************************/
|
|
18
|
-
export declare const getAttributes: (state: RootState) =>
|
|
19
|
+
export declare const getAttributes: (state: RootState) => AttributesState;
|
|
20
|
+
export declare const getHydratedAttributes: ((state: {
|
|
21
|
+
treble: import("./treble").TrebleState;
|
|
22
|
+
product: import("./product").ProductState;
|
|
23
|
+
attributes: AttributesState;
|
|
24
|
+
translations: import("./translations").TranslationsState;
|
|
25
|
+
wishlist: import("../Treble").WishlistArray;
|
|
26
|
+
price: import("./price").PriceState;
|
|
27
|
+
}) => Record<string, IHydratedAttribute>) & import("reselect").OutputSelectorFields<(args_0: AttributesState, args_1: ITranslationMap | undefined, args_2: string | undefined) => Record<string, IHydratedAttribute> & {
|
|
28
|
+
clearCache: () => void;
|
|
29
|
+
}> & {
|
|
30
|
+
clearCache: () => void;
|
|
31
|
+
};
|
|
19
32
|
export declare const setConfiguration: (config: ISetConfiguration) => (dispatch: ThreekitDispatch) => Promise<void>;
|
|
20
33
|
export default reducer;
|