@threekit-tools/treble 0.0.99 → 0.0.100
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 +1 -1
- package/dist/hooks/useAnalyticsSession/index.d.ts +1 -4
- package/dist/hooks/useAnalyticsSession/index.js +1 -12
- package/dist/hooks/useAttribute/index.js +0 -28
- package/dist/hooks/usePlayer/index.d.ts +2 -1
- package/dist/hooks/usePlayer/index.js +20 -22
- package/dist/hooks/useShare/index.js +0 -15
- package/dist/icons/types.d.ts +1 -1
- package/dist/utils.d.ts +0 -2
- package/dist/utils.js +1 -63
- package/package.json +2 -4
package/dist/Treble/Treble.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ declare class Treble {
|
|
|
22
22
|
_player: IThreekitPrivatePlayer;
|
|
23
23
|
wishlist: IWishlist;
|
|
24
24
|
private _snapshots;
|
|
25
|
-
takeSnapshots: typeof snapshots['takeSnapshots'];
|
|
25
|
+
takeSnapshots: (typeof snapshots)['takeSnapshots'];
|
|
26
26
|
_debugMode: boolean;
|
|
27
27
|
constructor({ player, orgId }: ITreble);
|
|
28
28
|
createOrder: (order?: IOrder) => Promise<import("../http/orders").IOrderResponse>;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
declare type UseAnalyticsSessionSuccess = Session;
|
|
3
|
-
declare type UseAnalyticsSessionError = undefined;
|
|
4
|
-
declare type UseAnalyticsSession = UseAnalyticsSessionSuccess | UseAnalyticsSessionError;
|
|
1
|
+
declare type UseAnalyticsSession = undefined;
|
|
5
2
|
declare const useAnalyticsSession: () => UseAnalyticsSession;
|
|
6
3
|
export default useAnalyticsSession;
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var analytics_1 = require("@threekit/analytics");
|
|
4
|
-
var connection_1 = require("../../connection");
|
|
5
3
|
var useAnalyticsSession = function () {
|
|
6
|
-
|
|
7
|
-
var auth = {
|
|
8
|
-
orgId: connection._orgId,
|
|
9
|
-
host: connection._threekitDomain,
|
|
10
|
-
publicToken: connection._authToken,
|
|
11
|
-
};
|
|
12
|
-
var analyticsSession = (0, analytics_1.getSession)({ auth: auth });
|
|
13
|
-
if (!analyticsSession)
|
|
14
|
-
return undefined;
|
|
15
|
-
return analyticsSession;
|
|
4
|
+
return undefined;
|
|
16
5
|
};
|
|
17
6
|
exports.default = useAnalyticsSession;
|
|
@@ -35,23 +35,17 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
39
|
var store_1 = require("../../store");
|
|
43
40
|
var attributes_1 = require("../../store/attributes");
|
|
44
41
|
var utils_1 = require("../../utils");
|
|
45
42
|
var utils_2 = require("../../utils");
|
|
46
|
-
var useAnalyticsSession_1 = __importDefault(require("../useAnalyticsSession"));
|
|
47
|
-
var rest_api_1 = require("@threekit/rest-api");
|
|
48
43
|
var useAttribute = function (attributeName) {
|
|
49
44
|
var _a;
|
|
50
45
|
if (!attributeName)
|
|
51
46
|
return [undefined, undefined];
|
|
52
47
|
var dispatch = (0, store_1.useThreekitDispatch)();
|
|
53
48
|
var _b = (0, store_1.useThreekitSelector)(attributes_1.getHydrationData), attributes = _b[0], translations = _b[1];
|
|
54
|
-
var analyticsSession = (0, useAnalyticsSession_1.default)();
|
|
55
49
|
if (!attributeName || !attributes)
|
|
56
50
|
return [undefined, undefined];
|
|
57
51
|
var attribute = attributes[attributeName];
|
|
@@ -71,17 +65,6 @@ var useAttribute = function (attributeName) {
|
|
|
71
65
|
case 1: return [4, window.threekit.player.uploadImage(value)];
|
|
72
66
|
case 2:
|
|
73
67
|
uploadId = _b.sent();
|
|
74
|
-
try {
|
|
75
|
-
analyticsSession === null || analyticsSession === void 0 ? void 0 : analyticsSession.imageUpload({
|
|
76
|
-
assetId: window.threekit.player.assetId,
|
|
77
|
-
imageUploadId: attributeName,
|
|
78
|
-
imageUploadFileId: uploadId,
|
|
79
|
-
configuration: window.threekit.configurator.getFullConfiguration(),
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
catch (e) {
|
|
83
|
-
console.log('v2Analytics: Error reporting imageUpload event:', e);
|
|
84
|
-
}
|
|
85
68
|
if (uploadId)
|
|
86
69
|
preppedValue = (0, utils_1.selectionToConfiguration)(uploadId, attribute.type);
|
|
87
70
|
_b.label = 3;
|
|
@@ -93,17 +76,6 @@ var useAttribute = function (attributeName) {
|
|
|
93
76
|
dispatch((0, attributes_1.setConfiguration)((_a = {},
|
|
94
77
|
_a[attributeName] = preppedValue,
|
|
95
78
|
_a)));
|
|
96
|
-
try {
|
|
97
|
-
analyticsSession === null || analyticsSession === void 0 ? void 0 : analyticsSession.optionInteraction({
|
|
98
|
-
optionsSetId: attribute.id,
|
|
99
|
-
optionId: attribute.name,
|
|
100
|
-
interactionType: rest_api_1.OptionInteractionType.Select,
|
|
101
|
-
configuration: window.threekit.configurator.getFullConfiguration(),
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
catch (e) {
|
|
105
|
-
console.log('v2Analytics: Error reporting optionInteraction event:', e);
|
|
106
|
-
}
|
|
107
79
|
return [2];
|
|
108
80
|
}
|
|
109
81
|
});
|
|
@@ -2,37 +2,35 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var react_1 = require("react");
|
|
4
4
|
var react_redux_1 = require("react-redux");
|
|
5
|
-
var treble_1 = require("../../store/treble");
|
|
6
5
|
var constants_1 = require("../../constants");
|
|
6
|
+
var treble_1 = require("../../store/treble");
|
|
7
7
|
var usePlayer = function () {
|
|
8
|
-
var playerElRef = (0, react_1.useRef)(null);
|
|
9
|
-
var playerLoaderRef = (0, react_1.useRef)(null);
|
|
10
|
-
var playerWrapperRef = (0, react_1.useRef)(null);
|
|
11
8
|
var playerElementId = (0, react_redux_1.useSelector)(treble_1.getPlayerElementId);
|
|
9
|
+
var playerWrapperRef = (0, react_1.useRef)(null);
|
|
10
|
+
var playerElRef = (0, react_1.useRef)(null);
|
|
12
11
|
var playerRef = (0, react_1.useCallback)(function (node) {
|
|
13
|
-
|
|
14
|
-
if (node !== null) {
|
|
15
|
-
playerWrapperRef.current = node;
|
|
16
|
-
if (!playerElementId)
|
|
17
|
-
return;
|
|
18
|
-
playerElRef.current = document.getElementById(playerElementId);
|
|
19
|
-
(_a = playerWrapperRef.current) === null || _a === void 0 ? void 0 : _a.appendChild(playerElRef.current);
|
|
12
|
+
if (node == null || !playerElementId)
|
|
20
13
|
return;
|
|
21
|
-
|
|
14
|
+
var playerNode = document.getElementById(playerElementId);
|
|
15
|
+
if (playerNode == null)
|
|
16
|
+
return;
|
|
17
|
+
playerWrapperRef.current = node;
|
|
18
|
+
playerElRef.current = playerNode;
|
|
19
|
+
node.appendChild(playerNode);
|
|
22
20
|
}, [playerElementId]);
|
|
23
|
-
(0, react_1.
|
|
24
|
-
|
|
21
|
+
(0, react_1.useLayoutEffect)(function () { return function () {
|
|
22
|
+
var node = playerWrapperRef.current;
|
|
23
|
+
var playerNode = playerElRef.current;
|
|
24
|
+
if (node == null || playerNode == null)
|
|
25
|
+
return;
|
|
26
|
+
var stillOwnsPlayer = node.contains(playerNode);
|
|
27
|
+
if (!stillOwnsPlayer)
|
|
25
28
|
return;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (!playerElRef.current)
|
|
29
|
-
throw new Error('Move from element not found');
|
|
30
|
-
if (!playerLoaderRef.current)
|
|
29
|
+
var loader = document.getElementById(constants_1.TK_PLAYER_LOADER_DIV);
|
|
30
|
+
if (!loader)
|
|
31
31
|
throw new Error('Player Loader element not found');
|
|
32
|
-
|
|
32
|
+
loader.appendChild(playerNode);
|
|
33
33
|
}; }, []);
|
|
34
|
-
if (!playerElementId)
|
|
35
|
-
return [undefined];
|
|
36
34
|
return [playerRef];
|
|
37
35
|
};
|
|
38
36
|
exports.default = usePlayer;
|
|
@@ -43,13 +43,10 @@ var store_1 = require("../../store");
|
|
|
43
43
|
var treble_1 = require("../../store/treble");
|
|
44
44
|
var message_1 = __importDefault(require("../../components/message"));
|
|
45
45
|
var utils_1 = require("../../utils");
|
|
46
|
-
var useAnalyticsSession_1 = __importDefault(require("../useAnalyticsSession"));
|
|
47
|
-
var rest_api_1 = require("@threekit/rest-api");
|
|
48
46
|
var useShare = function () {
|
|
49
47
|
var isLoaded = (0, store_1.useThreekitSelector)(treble_1.isThreekitInitialized);
|
|
50
48
|
if (!isLoaded)
|
|
51
49
|
return undefined;
|
|
52
|
-
var analyticsSession = (0, useAnalyticsSession_1.default)();
|
|
53
50
|
var handleShare = function (msg) {
|
|
54
51
|
if (msg === void 0) { msg = 'Link copied'; }
|
|
55
52
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -66,18 +63,6 @@ var useShare = function () {
|
|
|
66
63
|
(0, utils_1.copyToClipboard)(configuration.resumableUrl);
|
|
67
64
|
if (msg === null || msg === void 0 ? void 0 : msg.length)
|
|
68
65
|
message_1.default.info(msg);
|
|
69
|
-
try {
|
|
70
|
-
analyticsSession === null || analyticsSession === void 0 ? void 0 : analyticsSession.share({
|
|
71
|
-
shareLink: configuration.resumableUrl,
|
|
72
|
-
shareType: rest_api_1.ShareType.Share,
|
|
73
|
-
assetId: window.threekit.player.assetId,
|
|
74
|
-
configurationId: configuration.id,
|
|
75
|
-
configuration: window.threekit.configurator.getFullConfiguration(),
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
catch (e) {
|
|
79
|
-
console.log('v2Analytics: Error reporting share event.');
|
|
80
|
-
}
|
|
81
66
|
return [2, Promise.resolve((configuration === null || configuration === void 0 ? void 0 : configuration.resumableUrl) || undefined)];
|
|
82
67
|
}
|
|
83
68
|
});
|
package/dist/icons/types.d.ts
CHANGED
package/dist/utils.d.ts
CHANGED
|
@@ -48,8 +48,6 @@ export declare const downloadSnapshot: (snapshot: string, filename: string) => P
|
|
|
48
48
|
export declare const copyToClipboard: (data: string | Record<string, string | number | boolean>) => void;
|
|
49
49
|
export declare const easeInOutCubic: (val: number) => number;
|
|
50
50
|
export declare const metadataValueToObject: (data: string) => Record<string, string | number>;
|
|
51
|
-
export declare const recordOptionsShowAnalytics: (attributes: Record<string, IThreekitDisplayAttribute>) => void;
|
|
52
|
-
export declare const recordOptionInteractionAnalytics: (attribute: IThreekitDisplayAttribute, chosenAttribute: string, configuration?: IConfiguration) => void;
|
|
53
51
|
export declare const hydrateAttribute: (data: [Record<string, IThreekitDisplayAttribute>, ITranslationsMap], optionSelectionHandler: (config: ISetConfiguration) => Promise<void>, configuration?: IConfiguration) => Record<string, IHydratedAttribute>;
|
|
54
52
|
export declare const selectionToConfiguration: (value: RawAttributeValue, attributeType: ATTRIBUTE_TYPES) => string | number | boolean | File | IConfigurationColor | {
|
|
55
53
|
assetId: RawAttributeValue;
|
package/dist/utils.js
CHANGED
|
@@ -44,15 +44,10 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
44
44
|
}
|
|
45
45
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
46
|
};
|
|
47
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
48
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
|
-
};
|
|
50
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
-
exports.loadTrebleConfig = exports.runDebugger = exports.isUuid = exports.filterFormAttributes = exports.selectionToConfiguration = exports.hydrateAttribute = exports.
|
|
48
|
+
exports.loadTrebleConfig = exports.runDebugger = 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;
|
|
52
49
|
var constants_1 = require("./constants");
|
|
53
50
|
var types_1 = require("./types");
|
|
54
|
-
var useAnalyticsSession_1 = __importDefault(require("./hooks/useAnalyticsSession"));
|
|
55
|
-
var rest_api_1 = require("@threekit/rest-api");
|
|
56
51
|
var generateClassName = function (baseClass) {
|
|
57
52
|
return function (component, customClassName, title) {
|
|
58
53
|
var result = "".concat(baseClass, "-").concat(component);
|
|
@@ -308,65 +303,10 @@ var metadataValueToObject = function (data) {
|
|
|
308
303
|
}, {});
|
|
309
304
|
};
|
|
310
305
|
exports.metadataValueToObject = metadataValueToObject;
|
|
311
|
-
var recordOptionsShowAnalytics = function (attributes) {
|
|
312
|
-
var analyticsSession = (0, useAnalyticsSession_1.default)();
|
|
313
|
-
Object.values(attributes).forEach(function (attribute) {
|
|
314
|
-
if ((attribute.type === 'String' || attribute.type === 'Asset') &&
|
|
315
|
-
attribute.values.length) {
|
|
316
|
-
analyticsSession === null || analyticsSession === void 0 ? void 0 : analyticsSession.optionsShow({
|
|
317
|
-
optionsSetId: attribute.id,
|
|
318
|
-
optionsSetName: attribute.name,
|
|
319
|
-
options: attribute.values,
|
|
320
|
-
optionsType: attribute.type === 'Asset' ? rest_api_1.OptionsType.Asset : rest_api_1.OptionsType.Value,
|
|
321
|
-
});
|
|
322
|
-
}
|
|
323
|
-
});
|
|
324
|
-
};
|
|
325
|
-
exports.recordOptionsShowAnalytics = recordOptionsShowAnalytics;
|
|
326
|
-
var recordOptionInteractionAnalytics = function (attribute, chosenAttribute, configuration) {
|
|
327
|
-
var analyticsSession = (0, useAnalyticsSession_1.default)();
|
|
328
|
-
var castedConfiguration = configuration;
|
|
329
|
-
var id = attribute.type === 'Asset' ? attribute.value.assetId : attribute.id;
|
|
330
|
-
if (attribute.type === 'String') {
|
|
331
|
-
if (attribute.values.length > 0) {
|
|
332
|
-
analyticsSession === null || analyticsSession === void 0 ? void 0 : analyticsSession.optionInteraction({
|
|
333
|
-
optionsSetId: id,
|
|
334
|
-
optionId: chosenAttribute,
|
|
335
|
-
interactionType: rest_api_1.OptionInteractionType.Select,
|
|
336
|
-
configuration: castedConfiguration,
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
else {
|
|
340
|
-
analyticsSession === null || analyticsSession === void 0 ? void 0 : analyticsSession.personalizeText({
|
|
341
|
-
assetId: id,
|
|
342
|
-
configuration: castedConfiguration,
|
|
343
|
-
personalizeId: attribute.id,
|
|
344
|
-
personalizedText: attribute.value,
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
if (attribute.type === 'Asset' || attribute.type === 'Color') {
|
|
349
|
-
analyticsSession === null || analyticsSession === void 0 ? void 0 : analyticsSession.optionInteraction({
|
|
350
|
-
optionsSetId: id,
|
|
351
|
-
optionId: chosenAttribute,
|
|
352
|
-
interactionType: rest_api_1.OptionInteractionType.Select,
|
|
353
|
-
configuration: castedConfiguration,
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
if (attribute.type === 'Number') {
|
|
357
|
-
analyticsSession === null || analyticsSession === void 0 ? void 0 : analyticsSession.parametricValue({
|
|
358
|
-
parametricId: id,
|
|
359
|
-
parametricValue: attribute.value,
|
|
360
|
-
configuration: castedConfiguration,
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
};
|
|
364
|
-
exports.recordOptionInteractionAnalytics = recordOptionInteractionAnalytics;
|
|
365
306
|
var hydrateAttribute = function (data, optionSelectionHandler, configuration) {
|
|
366
307
|
var _a, _b;
|
|
367
308
|
var attributes = data[0], translations = data[1];
|
|
368
309
|
var resolvedConfig = configuration !== null && configuration !== void 0 ? configuration : (_b = (_a = window.threekit) === null || _a === void 0 ? void 0 : _a.configurator) === null || _b === void 0 ? void 0 : _b.getResolvedConfiguration();
|
|
369
|
-
(0, exports.recordOptionsShowAnalytics)(attributes);
|
|
370
310
|
return Object.values(attributes).reduce(function (output, attribute) {
|
|
371
311
|
var _a;
|
|
372
312
|
var _b;
|
|
@@ -381,7 +321,6 @@ var hydrateAttribute = function (data, optionSelectionHandler, configuration) {
|
|
|
381
321
|
label: (_a = translations[el.label]) !== null && _a !== void 0 ? _a : el.label,
|
|
382
322
|
handleSelect: function () {
|
|
383
323
|
var _a;
|
|
384
|
-
(0, exports.recordOptionInteractionAnalytics)(attribute, attribute.value, configuration);
|
|
385
324
|
optionSelectionHandler((_a = {},
|
|
386
325
|
_a[attribute.name] = el.value,
|
|
387
326
|
_a));
|
|
@@ -398,7 +337,6 @@ var hydrateAttribute = function (data, optionSelectionHandler, configuration) {
|
|
|
398
337
|
label: (_a = translations[el.name]) !== null && _a !== void 0 ? _a : el.name,
|
|
399
338
|
handleSelect: function () {
|
|
400
339
|
var _a;
|
|
401
|
-
(0, exports.recordOptionInteractionAnalytics)(attribute, attribute.label, configuration);
|
|
402
340
|
optionSelectionHandler((_a = {},
|
|
403
341
|
_a[attribute.name] = { assetId: el.assetId },
|
|
404
342
|
_a));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@threekit-tools/treble",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.100",
|
|
4
4
|
"author": "Amaan Saeed",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -82,10 +82,8 @@
|
|
|
82
82
|
"typescript": ">=4.4.4"
|
|
83
83
|
},
|
|
84
84
|
"peerDependencies": {
|
|
85
|
-
"@threekit/analytics": "0.2.13",
|
|
86
|
-
"@threekit/rest-api": ">=0.2.2",
|
|
87
85
|
"react": ">=17.0.2",
|
|
88
86
|
"react-dom": ">=17.0.2"
|
|
89
87
|
},
|
|
90
88
|
"gitHead": "2e16bcf98f81e16bb1768072fdb3968122e7966f"
|
|
91
|
-
}
|
|
89
|
+
}
|