@threekit-tools/treble 0.0.78 → 0.0.81

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.
@@ -17,11 +17,11 @@ interface IGetSnapshot {
17
17
  }
18
18
  interface ISnapshots {
19
19
  getSnapshot(snapshotConfig: IGetSnapshot): Promise<string>;
20
- takeSnapshots(cameras: ISnapshotsCameras, config: ITakeSnapshotsConfig): Promise<void | string[] | Blob[] | null>;
20
+ takeSnapshots(cameras: ISnapshotsCameras, config: ITakeSnapshotsConfig): Promise<void | string[] | Blob[] | File[] | null>;
21
21
  }
22
22
  declare class Snapshots implements ISnapshots {
23
23
  constructor();
24
24
  getSnapshot: ({ size, format }: IGetSnapshot) => Promise<string>;
25
- takeSnapshots: (camerasList: ISnapshotsCameras, snapshotsConfig: ITakeSnapshotsConfig) => Promise<void | string[] | Blob[] | null>;
25
+ takeSnapshots: (camerasList: ISnapshotsCameras, snapshotsConfig: ITakeSnapshotsConfig) => Promise<void | string[] | Blob[] | File[] | null>;
26
26
  }
27
27
  export default Snapshots;
@@ -1,3 +1,4 @@
1
+ import threekitAPI from '../api';
1
2
  import { IThreekitPlayer, IThreekitPrivatePlayer, IConfiguration, ISetConfiguration, IThreekitPrivateConfigurator } from '../types';
2
3
  import { IWishlist } from './Wishlist';
3
4
  import Snapshots from './Snapshots';
@@ -13,6 +14,7 @@ interface IEmailShareCredentials {
13
14
  templateId: string;
14
15
  }
15
16
  declare class Treble {
17
+ _api: typeof threekitAPI;
16
18
  _player: IThreekitPrivatePlayer;
17
19
  wishlist: IWishlist;
18
20
  private _initialConfiguration;
@@ -20,7 +22,7 @@ declare class Treble {
20
22
  takeSnapshots: Snapshots['takeSnapshots'];
21
23
  _debugMode: boolean;
22
24
  constructor({ player, orgId, initialConfiguration }: ITreble);
23
- saveConfiguration: (config?: Omit<ISaveConfiguration, "configuration"> | undefined) => Promise<{
25
+ saveConfiguration: (config?: Partial<Omit<ISaveConfiguration, "configuration">> | undefined) => Promise<{
24
26
  resumableUrl: string;
25
27
  } & import("../http/configurations").IConfigurationResponse & {
26
28
  thumbnail: string;
@@ -121,6 +121,7 @@ var Treble = /** @class */ (function () {
121
121
  return api_1.default.server.sendEmail(data);
122
122
  };
123
123
  // Threekit API
124
+ this._api = api_1.default;
124
125
  this.wishlist = (0, Wishlist_1.default)(orgId);
125
126
  this._snapshots = new Snapshots_1.default();
126
127
  this.takeSnapshots = this._snapshots.takeSnapshots;
@@ -3,7 +3,7 @@ import { ISaveConfiguration } from '../api/configurations';
3
3
  export declare type WishlistArray = Array<IConfigurationResponse>;
4
4
  export interface IWishlist {
5
5
  getWishlist(): Promise<Array<IConfigurationResponse>>;
6
- addItem(config?: Omit<ISaveConfiguration, 'configurator'>): Promise<Array<IConfigurationResponse>>;
6
+ addItem(config?: Omit<ISaveConfiguration, 'configuration'>): Promise<Array<IConfigurationResponse>>;
7
7
  removeItemByIdx(idx: number): Array<IConfigurationResponse>;
8
8
  clearWishlist(): Array<IConfigurationResponse>;
9
9
  }
@@ -11,7 +11,7 @@ declare class Wishlist implements IWishlist {
11
11
  _wishlistKey: string;
12
12
  constructor(orgId: string);
13
13
  getWishlist: () => Promise<WishlistArray>;
14
- addItem: (config?: Omit<ISaveConfiguration, "configurator"> | undefined) => Promise<WishlistArray>;
14
+ addItem: () => Promise<WishlistArray>;
15
15
  removeItemByIdx: (idx: number) => WishlistArray;
16
16
  clearWishlist: () => WishlistArray;
17
17
  }
@@ -49,39 +49,30 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
49
49
  };
50
50
  Object.defineProperty(exports, "__esModule", { value: true });
51
51
  var api_1 = __importDefault(require("../api"));
52
- var connection_1 = __importDefault(require("../connection"));
53
52
  var constants_1 = require("../constants");
54
53
  var wishlistData;
55
54
  var Wishlist = /** @class */ (function () {
56
55
  function Wishlist(orgId) {
57
56
  var _this = this;
58
57
  this.getWishlist = function () { return __awaiter(_this, void 0, void 0, function () {
59
- var threekitDomain, wishlistListStr, wishlistList, wishlistDataRaw;
58
+ var wishlistListStr, wishlistList, wishlistDataRaw;
60
59
  return __generator(this, function (_a) {
61
60
  switch (_a.label) {
62
61
  case 0:
63
62
  if (wishlistData)
64
63
  return [2 /*return*/, wishlistData];
65
- threekitDomain = connection_1.default.getConnection().threekitDomain;
66
64
  wishlistListStr = localStorage.getItem(this._wishlistKey);
67
65
  wishlistList = JSON.parse(wishlistListStr || '[]');
68
66
  return [4 /*yield*/, Promise.all(wishlistList.map(function (el) { return api_1.default.configurations.fetch(el); }))];
69
67
  case 1:
70
68
  wishlistDataRaw = _a.sent();
71
- wishlistData = wishlistDataRaw.map(function (el) {
72
- var _a;
73
- return Object.assign({}, el.data, ((_a = el.data.thumbnail) === null || _a === void 0 ? void 0 : _a.length)
74
- ? {
75
- thumbnail: "".concat(threekitDomain, "/api/files/hash/").concat(el.data.thumbnail),
76
- }
77
- : undefined);
78
- });
69
+ wishlistData = wishlistDataRaw.map(function (el) { return el.data; });
79
70
  return [2 /*return*/, wishlistData];
80
71
  }
81
72
  });
82
73
  }); };
83
- this.addItem = function (config) { return __awaiter(_this, void 0, void 0, function () {
84
- var configPrepped, savedConfiguration, wishlistListStr, wishlistList;
74
+ this.addItem = function () { return __awaiter(_this, void 0, void 0, function () {
75
+ var thumbnails, savedConfiguration, wishlistListStr, wishlistList;
85
76
  return __generator(this, function (_a) {
86
77
  switch (_a.label) {
87
78
  case 0:
@@ -89,9 +80,16 @@ var Wishlist = /** @class */ (function () {
89
80
  wishlistData = [];
90
81
  localStorage.setItem(this._wishlistKey, JSON.stringify([]));
91
82
  }
92
- configPrepped = Object.assign({ snapshot: true }, config);
93
- return [4 /*yield*/, window.threekit.treble.saveConfiguration(configPrepped)];
83
+ return [4 /*yield*/, window.threekit.treble.takeSnapshots(undefined, {
84
+ output: 'file',
85
+ filename: 'thumbnail',
86
+ })];
94
87
  case 1:
88
+ thumbnails = (_a.sent());
89
+ return [4 /*yield*/, window.threekit.treble.saveConfiguration({
90
+ attachments: { thumbnail: thumbnails[0] },
91
+ })];
92
+ case 2:
95
93
  savedConfiguration = _a.sent();
96
94
  if (!savedConfiguration)
97
95
  return [2 /*return*/, wishlistData];
@@ -7,7 +7,6 @@ export interface PlayerProps extends IProps {
7
7
  width?: string;
8
8
  minHeight?: string;
9
9
  }
10
- export declare const PLAYER_DIV_ID = "tk-player-component";
11
10
  declare const Player: {
12
11
  (props: PlayerProps): JSX.Element;
13
12
  TopLeftWidgets(props: IProps): JSX.Element;
@@ -1,33 +1,12 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
22
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
23
4
  };
24
5
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.PLAYER_DIV_ID = void 0;
26
- var react_1 = __importStar(require("react"));
6
+ var react_1 = __importDefault(require("react"));
27
7
  var player_styles_1 = require("./player.styles");
28
8
  var constants_1 = require("../../constants");
29
- var usePlayerPortal_1 = __importDefault(require("../../hooks/usePlayerPortal"));
30
- exports.PLAYER_DIV_ID = 'tk-player-component';
9
+ var usePlayer_1 = __importDefault(require("../../hooks/usePlayer"));
31
10
  var className = "".concat(constants_1.DEFAULT_CLASS_NAME, " ").concat(constants_1.CLASS_NAME_PREFIX, "-player");
32
11
  var Player = function (props) {
33
12
  var _a = Object.assign({
@@ -35,22 +14,9 @@ var Player = function (props) {
35
14
  minHeight: '600px',
36
15
  width: '100%',
37
16
  }, props), height = _a.height, width = _a.width, minHeight = _a.minHeight, children = _a.children;
38
- var _b = (0, usePlayerPortal_1.default)(), portalPlayerTo = _b[0], portalBack = _b[1];
39
- var hasMoved = (0, react_1.useRef)(false);
40
- (0, react_1.useEffect)(function () {
41
- if (portalPlayerTo && !hasMoved.current) {
42
- portalPlayerTo(exports.PLAYER_DIV_ID);
43
- hasMoved.current = true;
44
- }
45
- return function () {
46
- if (portalBack) {
47
- portalBack();
48
- hasMoved.current = false;
49
- }
50
- };
51
- }, [portalPlayerTo]);
17
+ var playerRef = (0, usePlayer_1.default)()[0];
52
18
  return (react_1.default.createElement(player_styles_1.Wrapper, { height: height, width: width, minHeight: minHeight, className: className },
53
- react_1.default.createElement("div", { id: exports.PLAYER_DIV_ID }),
19
+ react_1.default.createElement("div", { ref: playerRef }),
54
20
  children));
55
21
  };
56
22
  Player.TopLeftWidgets = function (props) {
@@ -25,6 +25,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
25
25
  var react_1 = __importStar(require("react"));
26
26
  var store_1 = __importStar(require("../../store"));
27
27
  var treble_1 = require("../../store/treble");
28
+ var constants_1 = require("../../constants");
28
29
  var react_redux_1 = require("react-redux");
29
30
  var styled_components_1 = require("styled-components");
30
31
  var theme_1 = __importDefault(require("../../theme"));
@@ -32,12 +33,13 @@ var GlobalStyles_styles_1 = __importDefault(require("./GlobalStyles.styles"));
32
33
  var DevTools_1 = __importDefault(require("../DevTools"));
33
34
  var App = function (props) {
34
35
  var dispatch = (0, store_1.useThreekitDispatch)();
35
- var playerConfig = props.playerConfig, productId = props.productId, project = props.project, locale = props.locale, threekitEnv = props.threekitEnv, eventHandlers = props.eventHandlers;
36
+ var playerConfig = props.playerConfig, assetId = props.assetId, productId = props.productId, project = props.project, locale = props.locale, threekitEnv = props.threekitEnv, eventHandlers = props.eventHandlers;
36
37
  (0, react_1.useEffect)(function () {
37
38
  var init = function () {
38
39
  dispatch((0, treble_1.launch)({
39
40
  playerConfig: playerConfig,
40
41
  productId: productId,
42
+ assetId: assetId,
41
43
  project: project,
42
44
  locale: locale,
43
45
  threekitEnv: threekitEnv,
@@ -53,7 +55,7 @@ var ThreekitProvider = function (props) {
53
55
  return (react_1.default.createElement(react_redux_1.Provider, { store: (0, store_1.default)(props.reducer) },
54
56
  react_1.default.createElement(styled_components_1.ThemeProvider, { theme: theme_1.default },
55
57
  react_1.default.createElement(GlobalStyles_styles_1.default, null),
56
- react_1.default.createElement(App, { locale: props.locale, productId: props.productId, project: props.project, playerConfig: props.playerConfig, threekitEnv: props.threekitEnv, eventHandlers: props.eventHandlers }, props.children),
57
- react_1.default.createElement(DevTools_1.default, null))));
58
+ react_1.default.createElement(App, { locale: props.locale, assetId: props.assetId, productId: props.productId, project: props.project, playerConfig: props.playerConfig, threekitEnv: props.threekitEnv, eventHandlers: props.eventHandlers }, props.children),
59
+ constants_1.TREBLE_DEBUG ? null : react_1.default.createElement(DevTools_1.default, null))));
58
60
  };
59
61
  exports.default = ThreekitProvider;
@@ -0,0 +1,14 @@
1
+ /// <reference types="react" />
2
+ interface UseImageEditorConfig {
3
+ canvasHeight?: number;
4
+ canvasWidth?: number;
5
+ cornerCircleSize?: number;
6
+ cropRatio?: number;
7
+ }
8
+ declare function useImageEditor(image: string, config: UseImageEditorConfig): null[] | (import("react").MutableRefObject<HTMLCanvasElement | null> | {
9
+ handleCrop: () => void;
10
+ } | {
11
+ handleInvert: () => void;
12
+ handleGrayscale: () => void;
13
+ })[];
14
+ export default useImageEditor;
@@ -0,0 +1,320 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var react_1 = require("react");
4
+ var CANVAS_HEIGHT = 600;
5
+ var CANVAS_WIDTH = 900;
6
+ var INVERT_COLOR = false;
7
+ var APPLY_GRAYSCALE = false;
8
+ var CORNER_BOX_SIZE = 4;
9
+ var CROP_RATIO = 'custom';
10
+ function useImageEditor(image, config) {
11
+ var _a = Object.assign({}, {
12
+ canvasHeight: CANVAS_HEIGHT,
13
+ canvasWidth: CANVAS_WIDTH,
14
+ cornerCircleSize: CORNER_BOX_SIZE,
15
+ cropRatio: CROP_RATIO,
16
+ }, config), canvasHeight = _a.canvasHeight, canvasWidth = _a.canvasWidth, cornerCircleSize = _a.cornerCircleSize;
17
+ var _b = (0, react_1.useState)(INVERT_COLOR), invertColor = _b[0], setInvertColor = _b[1];
18
+ var _c = (0, react_1.useState)(APPLY_GRAYSCALE), applyGrayscale = _c[0], setApplyGrayscale = _c[1];
19
+ var imageRef = (0, react_1.useRef)(null);
20
+ var canvasRef = (0, react_1.useRef)(null);
21
+ var cropStartRef = (0, react_1.useRef)(null);
22
+ var cropBoxRef = (0, react_1.useRef)(null);
23
+ var moveCropBoxOffsetRef = (0, react_1.useRef)(null);
24
+ var resizeCropBoxOffsetRef = (0, react_1.useRef)(null);
25
+ (0, react_1.useEffect)(function () {
26
+ if (!image || !canvasRef.current)
27
+ return;
28
+ var ctx = canvasRef.current.getContext('2d');
29
+ if (!ctx)
30
+ return;
31
+ canvasRef.current.height = canvasHeight;
32
+ canvasRef.current.width = canvasWidth;
33
+ var background = new Image();
34
+ background.src = image;
35
+ background.onload = function () {
36
+ imageRef.current = background;
37
+ drawImage(ctx, background);
38
+ };
39
+ }, [image, canvasHeight, canvasWidth]);
40
+ (0, react_1.useEffect)(function () {
41
+ if (!image)
42
+ return function () { };
43
+ if (canvasRef && canvasRef.current) {
44
+ canvasRef.current.addEventListener('mousedown', handleMouseDown);
45
+ canvasRef.current.addEventListener('mousemove', handleMouseMove);
46
+ canvasRef.current.addEventListener('mouseup', handleMouseUp);
47
+ return function () {
48
+ var _a, _b, _c;
49
+ (_a = canvasRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('mousedown', handleMouseDown);
50
+ (_b = canvasRef.current) === null || _b === void 0 ? void 0 : _b.removeEventListener('mousemove', handleMouseMove);
51
+ (_c = canvasRef.current) === null || _c === void 0 ? void 0 : _c.removeEventListener('mouseup', handleMouseUp);
52
+ };
53
+ }
54
+ return function () { };
55
+ function handleMouseDown(e) {
56
+ if (cropBoxRef === null || cropBoxRef === void 0 ? void 0 : cropBoxRef.current) {
57
+ if (e.offsetX >= cropBoxRef.current.startX &&
58
+ e.offsetX <= cropBoxRef.current.startX + cropBoxRef.current.deltaX &&
59
+ e.offsetY >= cropBoxRef.current.startY &&
60
+ e.offsetY <= cropBoxRef.current.startY + cropBoxRef.current.deltaY) {
61
+ moveCropBoxOffsetRef.current = { x: e.offsetX, y: e.offsetY };
62
+ return;
63
+ }
64
+ if (e.offsetX >=
65
+ cropBoxRef.current.startX +
66
+ cropBoxRef.current.deltaX -
67
+ cornerCircleSize / 2 &&
68
+ e.offsetX <=
69
+ cropBoxRef.current.startX +
70
+ cropBoxRef.current.deltaX +
71
+ cornerCircleSize / 2 &&
72
+ e.offsetY >=
73
+ cropBoxRef.current.startY +
74
+ cropBoxRef.current.deltaY -
75
+ cornerCircleSize / 2 &&
76
+ e.offsetY <=
77
+ cropBoxRef.current.startY +
78
+ cropBoxRef.current.deltaY +
79
+ cornerCircleSize / 2) {
80
+ resizeCropBoxOffsetRef.current = { x: e.offsetX, y: e.offsetY };
81
+ return;
82
+ }
83
+ }
84
+ cropStartRef.current = { x: e.offsetX, y: e.offsetY };
85
+ cropBoxRef.current = null;
86
+ }
87
+ function handleMouseMove(e) {
88
+ var _a, _b, _c, _d;
89
+ var ctx = (_a = canvasRef.current) === null || _a === void 0 ? void 0 : _a.getContext('2d');
90
+ if (!ctx || !cropBoxRef.current)
91
+ return;
92
+ if ((_b = moveCropBoxOffsetRef.current) === null || _b === void 0 ? void 0 : _b.x) {
93
+ var deltaX = e.offsetX - moveCropBoxOffsetRef.current.x;
94
+ var deltaY = e.offsetY - moveCropBoxOffsetRef.current.y;
95
+ var rect_1 = Object.assign({}, cropBoxRef.current, {
96
+ startX: cropBoxRef.current.startX + deltaX,
97
+ startY: cropBoxRef.current.startY + deltaY,
98
+ });
99
+ draw(ctx, rect_1, { invertColor: invertColor, applyGrayscale: applyGrayscale });
100
+ return;
101
+ }
102
+ if ((_c = resizeCropBoxOffsetRef === null || resizeCropBoxOffsetRef === void 0 ? void 0 : resizeCropBoxOffsetRef.current) === null || _c === void 0 ? void 0 : _c.x) {
103
+ var deltaX = e.offsetX - resizeCropBoxOffsetRef.current.x;
104
+ var deltaY = e.offsetY - resizeCropBoxOffsetRef.current.y;
105
+ var rect_2 = Object.assign({}, cropBoxRef.current, {
106
+ deltaX: cropBoxRef.current.deltaX + deltaX,
107
+ deltaY: cropBoxRef.current.deltaY + deltaY,
108
+ });
109
+ draw(ctx, rect_2, { invertColor: invertColor, applyGrayscale: applyGrayscale });
110
+ return;
111
+ }
112
+ if (!((_d = cropStartRef === null || cropStartRef === void 0 ? void 0 : cropStartRef.current) === null || _d === void 0 ? void 0 : _d.x))
113
+ return;
114
+ var rect = {
115
+ startX: cropStartRef.current.x,
116
+ startY: cropStartRef.current.y,
117
+ deltaX: e.offsetX - cropStartRef.current.x,
118
+ deltaY: e.offsetY - cropStartRef.current.y,
119
+ };
120
+ draw(ctx, rect, { invertColor: invertColor, applyGrayscale: applyGrayscale });
121
+ }
122
+ function handleMouseUp(e) {
123
+ var _a, _b;
124
+ var ctx = (_a = canvasRef.current) === null || _a === void 0 ? void 0 : _a.getContext('2d');
125
+ if (!ctx || !cropBoxRef.current || !cropStartRef.current)
126
+ return;
127
+ if (moveCropBoxOffsetRef.current) {
128
+ var deltaX_1 = moveCropBoxOffsetRef.current.x - e.offsetX;
129
+ var deltaY_1 = moveCropBoxOffsetRef.current.y - e.offsetY;
130
+ var rect_3 = Object.assign(cropBoxRef.current, {
131
+ startX: cropBoxRef.current.startX - deltaX_1,
132
+ startY: cropBoxRef.current.startY - deltaY_1,
133
+ });
134
+ draw(ctx, rect_3, { drawCornerBoxes: true, invertColor: invertColor, applyGrayscale: applyGrayscale });
135
+ cropBoxRef.current = rect_3;
136
+ moveCropBoxOffsetRef.current = null;
137
+ return;
138
+ }
139
+ if ((_b = resizeCropBoxOffsetRef === null || resizeCropBoxOffsetRef === void 0 ? void 0 : resizeCropBoxOffsetRef.current) === null || _b === void 0 ? void 0 : _b.x) {
140
+ var deltaX_2 = e.offsetX - resizeCropBoxOffsetRef.current.x;
141
+ var deltaY_2 = e.offsetY - resizeCropBoxOffsetRef.current.y;
142
+ var rect_4 = Object.assign({}, cropBoxRef.current, {
143
+ deltaX: cropBoxRef.current.deltaX + deltaX_2,
144
+ deltaY: cropBoxRef.current.deltaY + deltaY_2,
145
+ });
146
+ draw(ctx, rect_4, { drawCornerBoxes: true, invertColor: invertColor, applyGrayscale: applyGrayscale });
147
+ cropBoxRef.current = rect_4;
148
+ resizeCropBoxOffsetRef.current = null;
149
+ return;
150
+ }
151
+ var deltaX = e.offsetX - cropStartRef.current.x;
152
+ var deltaY = e.offsetY - cropStartRef.current.y;
153
+ var rect = {
154
+ startX: deltaX > 0 ? cropStartRef.current.x : cropStartRef.current.x + deltaX,
155
+ startY: deltaY > 0 ? cropStartRef.current.y : cropStartRef.current.y + deltaY,
156
+ deltaX: Math.abs(deltaX),
157
+ deltaY: Math.abs(deltaY),
158
+ };
159
+ cropBoxRef.current = rect;
160
+ draw(ctx, rect, { drawCornerBoxes: true });
161
+ cropStartRef.current = null;
162
+ }
163
+ }, [image, canvasHeight, canvasWidth]);
164
+ // useEffect(() => {
165
+ // if (!image) return;
166
+ // if (canvasRef && canvasRef.current) {
167
+ // canvasRef.current.addEventListener("mousemove", handleMouseMove);
168
+ // return () => {
169
+ // canvasRef.current.removeEventListener("mousemove", handleMouseMove);
170
+ // };
171
+ // }
172
+ // function handleMouseMove(e) {
173
+ // if (cropBoxRef?.current) {
174
+ // if (
175
+ // e.offsetX >= cropBoxRef.current.startX &&
176
+ // e.offsetX <= cropBoxRef.current.startX + cropBoxRef.current.deltaX &&
177
+ // e.offsetY >= cropBoxRef.current.startY &&
178
+ // e.offsetY <= cropBoxRef.current.startY + cropBoxRef.current.deltaY
179
+ // ) {
180
+ // canvasRef.current.style.cursor = "move";
181
+ // return;
182
+ // }
183
+ // if (
184
+ // e.offsetX >=
185
+ // cropBoxRef.current.startX +
186
+ // cropBoxRef.current.deltaX -
187
+ // cornerCircleSize / 2 &&
188
+ // e.offsetX <=
189
+ // cropBoxRef.current.startX +
190
+ // cropBoxRef.current.deltaX +
191
+ // cornerCircleSize / 2 &&
192
+ // e.offsetY >=
193
+ // cropBoxRef.current.startY +
194
+ // cropBoxRef.current.deltaY -
195
+ // cornerCircleSize / 2 &&
196
+ // e.offsetY <=
197
+ // cropBoxRef.current.startY +
198
+ // cropBoxRef.current.deltaY +
199
+ // cornerCircleSize / 2
200
+ // ) {
201
+ // canvasRef.current.style.cursor = "pointer";
202
+ // return;
203
+ // }
204
+ // }
205
+ // canvasRef.current.style.cursor = "default";
206
+ // }
207
+ // }, [image, canvasHeight, canvasWidth]);
208
+ function drawImage(ctx, image, config) {
209
+ var _a = config || {}, invertColor = _a.invertColor, applyGrayscale = _a.applyGrayscale;
210
+ if (invertColor)
211
+ ctx.filter = 'invert(1)';
212
+ else if (applyGrayscale)
213
+ ctx.filter = 'grayscale(1)';
214
+ else
215
+ ctx.filter = 'invert(0)';
216
+ // else ctx.filter = "grayscale(0)";
217
+ var wRatio = ctx.canvas.width / image.width;
218
+ var hRatio = ctx.canvas.height / image.height;
219
+ var ratio = Math.min(wRatio, hRatio);
220
+ var centerOffsetX = (ctx.canvas.width - image.width * ratio) / 2;
221
+ var centerOffsetY = (ctx.canvas.height - image.height * ratio) / 2;
222
+ ctx.drawImage(image, 0, 0, image.width, image.height, centerOffsetX, centerOffsetY, image.width * ratio, image.height * ratio);
223
+ }
224
+ function draw(ctx, rect, config) {
225
+ var _a = config || {}, drawCornerBoxes = _a.drawCornerBoxes, invertColor = _a.invertColor;
226
+ // clear the canvas
227
+ ctx.clearRect(0, 0, canvasWidth, canvasHeight);
228
+ // redraw the image
229
+ if (!imageRef.current)
230
+ return;
231
+ drawImage(ctx, imageRef.current, { invertColor: invertColor });
232
+ if (!rect)
233
+ return;
234
+ // redraw one or more things based on their javascript objects
235
+ ctx.beginPath();
236
+ ctx.setLineDash([]);
237
+ ctx.rect(rect.startX, rect.startY, rect.deltaX, rect.deltaY);
238
+ ctx.rect(canvasWidth, 0, 0 - canvasWidth, canvasHeight);
239
+ ctx.closePath();
240
+ ctx.strokeStyle = '#fff';
241
+ ctx.stroke();
242
+ ctx.fillStyle = '#00000055';
243
+ ctx.fill();
244
+ if (!drawCornerBoxes)
245
+ return;
246
+ ctx.beginPath();
247
+ ctx.arc(rect.startX, rect.startY, cornerCircleSize, 0, 2 * Math.PI);
248
+ ctx.fillStyle = '#fff';
249
+ ctx.fill();
250
+ ctx.closePath();
251
+ ctx.beginPath();
252
+ ctx.arc(rect.startX, rect.startY + rect.deltaY, cornerCircleSize, 0, 2 * Math.PI);
253
+ ctx.fillStyle = '#fff';
254
+ ctx.fill();
255
+ ctx.closePath();
256
+ ctx.beginPath();
257
+ ctx.arc(rect.startX + rect.deltaX, rect.startY, cornerCircleSize, 0, 2 * Math.PI);
258
+ ctx.fillStyle = '#fff';
259
+ ctx.fill();
260
+ ctx.closePath();
261
+ ctx.beginPath();
262
+ ctx.arc(rect.startX + rect.deltaX, rect.startY + rect.deltaY, cornerCircleSize, 0, 2 * Math.PI);
263
+ ctx.fillStyle = '#fff';
264
+ ctx.fill();
265
+ ctx.closePath();
266
+ }
267
+ function handleCrop() {
268
+ var _a, _b;
269
+ if (!cropBoxRef.current)
270
+ return;
271
+ var ctx = (_a = canvasRef.current) === null || _a === void 0 ? void 0 : _a.getContext('2d');
272
+ if (!ctx || !imageRef.current)
273
+ return;
274
+ var rect = cropBoxRef.current;
275
+ ctx.clearRect(0, 0, canvasWidth, canvasHeight);
276
+ drawImage(ctx, imageRef.current, { invertColor: invertColor, applyGrayscale: applyGrayscale });
277
+ var imageData = ctx.getImageData(rect.startX, rect.startY, rect.deltaX, rect.deltaY);
278
+ var clone = (_b = canvasRef.current) === null || _b === void 0 ? void 0 : _b.cloneNode();
279
+ if (!clone)
280
+ return;
281
+ clone.width = rect.deltaX;
282
+ clone.height = rect.deltaY;
283
+ var cloneCtx = clone.getContext('2d');
284
+ if (!cloneCtx)
285
+ return;
286
+ cloneCtx.putImageData(imageData, 0, 0);
287
+ var url = clone.toDataURL();
288
+ console.log(url);
289
+ cropBoxRef.current = null;
290
+ }
291
+ function handleInvert() {
292
+ var _a;
293
+ if (!cropBoxRef.current)
294
+ return;
295
+ var updated = !invertColor;
296
+ setInvertColor(updated);
297
+ var ctx = (_a = canvasRef.current) === null || _a === void 0 ? void 0 : _a.getContext('2d');
298
+ if (!ctx)
299
+ return;
300
+ draw(ctx, cropBoxRef.current, {
301
+ invertColor: updated,
302
+ drawCornerBoxes: true,
303
+ applyGrayscale: applyGrayscale,
304
+ });
305
+ }
306
+ function handleGrayscale() {
307
+ setApplyGrayscale(!applyGrayscale);
308
+ }
309
+ if (!image)
310
+ return [null, null];
311
+ var crop = {
312
+ handleCrop: handleCrop,
313
+ };
314
+ var color = {
315
+ handleInvert: handleInvert,
316
+ handleGrayscale: handleGrayscale,
317
+ };
318
+ return [canvasRef, crop, color];
319
+ }
320
+ exports.default = useImageEditor;
@@ -0,0 +1,2 @@
1
+ declare const useLoadingProgress: () => number;
2
+ export default useLoadingProgress;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var store_1 = require("../../store");
4
+ var treble_1 = require("../../store/treble");
5
+ var useLoadingProgress = function () {
6
+ var progress = (0, store_1.useThreekitSelector)(treble_1.getLoadingProgress);
7
+ return progress;
8
+ };
9
+ exports.default = useLoadingProgress;
@@ -0,0 +1,3 @@
1
+ declare type UsePlayer = [undefined] | [(node: null | HTMLDivElement) => void];
2
+ declare const usePlayer: () => UsePlayer;
3
+ export default usePlayer;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var react_1 = require("react");
4
+ var react_redux_1 = require("react-redux");
5
+ var treble_1 = require("../../store/treble");
6
+ var constants_1 = require("../../constants");
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
+ var playerElementId = (0, react_redux_1.useSelector)(treble_1.getPlayerElementId);
12
+ var playerRef = (0, react_1.useCallback)(function (node) {
13
+ var _a;
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);
20
+ return;
21
+ }
22
+ }, [playerElementId]);
23
+ (0, react_1.useEffect)(function () { return function () {
24
+ if (!playerElRef.current)
25
+ return;
26
+ if (!playerLoaderRef.current)
27
+ playerLoaderRef.current = document.getElementById(constants_1.TK_PLAYER_LOADER_DIV);
28
+ if (!playerElRef.current)
29
+ throw new Error('Move from element not found');
30
+ if (!playerLoaderRef.current)
31
+ throw new Error('Player Loader element not found');
32
+ playerLoaderRef.current.appendChild(playerElRef.current);
33
+ }; }, []);
34
+ if (!playerElementId)
35
+ return [undefined];
36
+ return [playerRef];
37
+ };
38
+ exports.default = usePlayer;
@@ -1,3 +1,3 @@
1
1
  import { ISnapshotsCameras, ITakeSnapshotsConfig } from '../../Treble';
2
- declare const useSnapshot: (cameras: ISnapshotsCameras, config: ITakeSnapshotsConfig) => (() => Promise<void | string[] | Blob[] | null>) | undefined;
2
+ declare const useSnapshot: (cameras: ISnapshotsCameras, config: ITakeSnapshotsConfig) => (() => Promise<void | string[] | File[] | Blob[] | null>) | undefined;
3
3
  export default useSnapshot;
@@ -7,7 +7,7 @@ interface HydratedWishlistItem extends IConfigurationResponse {
7
7
  }
8
8
  declare type UseWishlistHook = [
9
9
  Array<HydratedWishlistItem>,
10
- (config?: Omit<ISaveConfiguration, 'configurator'>) => void,
10
+ (config?: Omit<ISaveConfiguration, 'configuration'>) => void,
11
11
  () => void
12
12
  ] | [undefined, undefined, undefined];
13
13
  declare const useWishlist: () => UseWishlistHook;
package/dist/index.d.ts CHANGED
@@ -13,6 +13,8 @@ import useShare from './hooks/useShare';
13
13
  import usePlayerPortal from './hooks/usePlayerPortal';
14
14
  import useProductCache from './hooks/useProductCache';
15
15
  import useNestedConfigurator from './hooks/useNestedConfigurator';
16
+ import useLoadingProgress from './hooks/useLoadingProgress';
17
+ import usePlayer from './hooks/usePlayer';
16
18
  import ThreekitProvider from './components/ThreekitProvider';
17
19
  import Player from './components/Player';
18
20
  import Button from './components/Button';
@@ -46,4 +48,4 @@ import icons from './icons';
46
48
  export * from './icons';
47
49
  import TrebleApp from './components/TrebleApp';
48
50
  import ProductLayout from './components/ProductLayout';
49
- export { useAttribute, useConfigurator, useConfigurationLoader, useMetadata, useName, usePlayerLoadingStatus, usePrice, useThreekitInitStatus, useZoom, useSnapshot, useWishlist, useShare, usePlayerPortal, useProductCache, useNestedConfigurator, ThreekitProvider, Player, Button, Cards, Dropdown, Strips, Swatch, Tiles, TilesGroup, Upload, Switch, ProductName, ProductDescription, AttributeTitle, AttributeValue, TotalPrice, message, Modal, Drawer, Accordion, Tabs, PortalToArOverlay, PortalToElement, AwaitThreekitLoad, FlatForm, Zoom, Snapshots, Wishlist, Share, icons, TrebleApp, ProductLayout, };
51
+ export { useAttribute, useConfigurator, useConfigurationLoader, useMetadata, useName, usePlayerLoadingStatus, usePrice, useThreekitInitStatus, useZoom, useSnapshot, useWishlist, useShare, usePlayerPortal, useProductCache, useNestedConfigurator, useLoadingProgress, usePlayer, ThreekitProvider, Player, Button, Cards, Dropdown, Strips, Swatch, Tiles, TilesGroup, Upload, Switch, ProductName, ProductDescription, AttributeTitle, AttributeValue, TotalPrice, message, Modal, Drawer, Accordion, Tabs, PortalToArOverlay, PortalToElement, AwaitThreekitLoad, FlatForm, Zoom, Snapshots, Wishlist, Share, icons, TrebleApp, ProductLayout, };
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  return (mod && mod.__esModule) ? mod : { "default": mod };
14
14
  };
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.ProductLayout = exports.TrebleApp = exports.icons = exports.Share = exports.Wishlist = exports.Snapshots = exports.Zoom = exports.FlatForm = exports.AwaitThreekitLoad = exports.PortalToElement = exports.PortalToArOverlay = exports.Tabs = exports.Accordion = exports.Drawer = exports.Modal = exports.message = exports.TotalPrice = exports.AttributeValue = exports.AttributeTitle = exports.ProductDescription = exports.ProductName = exports.Switch = exports.Upload = exports.TilesGroup = exports.Tiles = exports.Swatch = exports.Strips = exports.Dropdown = exports.Cards = exports.Button = exports.Player = exports.ThreekitProvider = exports.useNestedConfigurator = exports.useProductCache = exports.usePlayerPortal = exports.useShare = exports.useWishlist = exports.useSnapshot = exports.useZoom = exports.useThreekitInitStatus = exports.usePrice = exports.usePlayerLoadingStatus = exports.useName = exports.useMetadata = exports.useConfigurationLoader = exports.useConfigurator = exports.useAttribute = void 0;
16
+ exports.ProductLayout = exports.TrebleApp = exports.icons = exports.Share = exports.Wishlist = exports.Snapshots = exports.Zoom = exports.FlatForm = exports.AwaitThreekitLoad = exports.PortalToElement = exports.PortalToArOverlay = exports.Tabs = exports.Accordion = exports.Drawer = exports.Modal = exports.message = exports.TotalPrice = exports.AttributeValue = exports.AttributeTitle = exports.ProductDescription = exports.ProductName = exports.Switch = exports.Upload = exports.TilesGroup = exports.Tiles = exports.Swatch = exports.Strips = exports.Dropdown = exports.Cards = exports.Button = exports.Player = exports.ThreekitProvider = exports.usePlayer = exports.useLoadingProgress = exports.useNestedConfigurator = exports.useProductCache = exports.usePlayerPortal = exports.useShare = exports.useWishlist = exports.useSnapshot = exports.useZoom = exports.useThreekitInitStatus = exports.usePrice = exports.usePlayerLoadingStatus = exports.useName = exports.useMetadata = exports.useConfigurationLoader = exports.useConfigurator = exports.useAttribute = void 0;
17
17
  // Hooks
18
18
  var useAttribute_1 = __importDefault(require("./hooks/useAttribute"));
19
19
  exports.useAttribute = useAttribute_1.default;
@@ -46,6 +46,10 @@ var useProductCache_1 = __importDefault(require("./hooks/useProductCache"));
46
46
  exports.useProductCache = useProductCache_1.default;
47
47
  var useNestedConfigurator_1 = __importDefault(require("./hooks/useNestedConfigurator"));
48
48
  exports.useNestedConfigurator = useNestedConfigurator_1.default;
49
+ var useLoadingProgress_1 = __importDefault(require("./hooks/useLoadingProgress"));
50
+ exports.useLoadingProgress = useLoadingProgress_1.default;
51
+ var usePlayer_1 = __importDefault(require("./hooks/usePlayer"));
52
+ exports.usePlayer = usePlayer_1.default;
49
53
  // Components
50
54
  var ThreekitProvider_1 = __importDefault(require("./components/ThreekitProvider"));
51
55
  exports.ThreekitProvider = ThreekitProvider_1.default;
@@ -13,6 +13,7 @@ export interface IPlayerInit {
13
13
  initialConfiguration?: IConfiguration;
14
14
  }
15
15
  export interface ILaunchConfig {
16
+ assetId?: string;
16
17
  productId: string;
17
18
  threekitEnv: string;
18
19
  serverUrl: string;
@@ -36,6 +37,7 @@ export interface TrebleState {
36
37
  isThreekitInitialized: boolean;
37
38
  playerElId: undefined | string;
38
39
  notifications: boolean;
40
+ loadingProgress: number;
39
41
  }
40
42
  export interface NotificationEvent extends Event {
41
43
  detail: {
@@ -54,6 +56,7 @@ export declare const setThreekitInitialized: import("@reduxjs/toolkit").ActionCr
54
56
  export declare const setPlayerLoading: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, string>;
55
57
  export declare const setPlayerElement: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, string>;
56
58
  export declare const reloadTreble: import("@reduxjs/toolkit").ActionCreatorWithPayload<Partial<TrebleState>, string>;
59
+ export declare const updateLoadingProgress: import("@reduxjs/toolkit").ActionCreatorWithPayload<number, string>;
57
60
  /*****************************************************
58
61
  * Slice
59
62
  ****************************************************/
@@ -65,6 +68,7 @@ export declare const getThreekitEnv: (state: RootState) => string;
65
68
  export declare const isThreekitInitialized: (state: RootState) => boolean;
66
69
  export declare const isPlayerLoading: (state: RootState) => boolean;
67
70
  export declare const getPlayerElementId: (state: RootState) => undefined | string;
71
+ export declare const getLoadingProgress: (state: RootState) => number;
68
72
  /*****************************************************
69
73
  * Complex Actions
70
74
  ****************************************************/
@@ -50,7 +50,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
50
50
  return (mod && mod.__esModule) ? mod : { "default": mod };
51
51
  };
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
- exports.reloadPlayer = exports.unloadPlayer = exports.launch = exports.initPlayer = exports.getPlayerElementId = exports.isPlayerLoading = exports.isThreekitInitialized = exports.getThreekitEnv = exports.reloadTreble = exports.setPlayerElement = exports.setPlayerLoading = exports.setThreekitInitialized = exports.setThreekitEnv = void 0;
53
+ exports.reloadPlayer = exports.unloadPlayer = exports.launch = exports.initPlayer = exports.getLoadingProgress = exports.getPlayerElementId = exports.isPlayerLoading = exports.isThreekitInitialized = exports.getThreekitEnv = exports.updateLoadingProgress = exports.reloadTreble = exports.setPlayerElement = exports.setPlayerLoading = exports.setThreekitInitialized = exports.setThreekitEnv = void 0;
54
54
  var connection_1 = __importDefault(require("../connection"));
55
55
  var toolkit_1 = require("@reduxjs/toolkit");
56
56
  var api_1 = __importDefault(require("../api"));
@@ -103,6 +103,7 @@ var initialState = {
103
103
  isPlayerLoading: false,
104
104
  playerElId: undefined,
105
105
  notifications: true,
106
+ loadingProgress: 0,
106
107
  };
107
108
  /*****************************************************
108
109
  * Actions
@@ -112,6 +113,7 @@ exports.setThreekitInitialized = (0, toolkit_1.createAction)('treble/set-threeki
112
113
  exports.setPlayerLoading = (0, toolkit_1.createAction)('treble/set-player-loading');
113
114
  exports.setPlayerElement = (0, toolkit_1.createAction)('treble/set-player-element');
114
115
  exports.reloadTreble = (0, toolkit_1.createAction)('treble/reload');
116
+ exports.updateLoadingProgress = (0, toolkit_1.createAction)('treble/update-loading-progress');
115
117
  /*****************************************************
116
118
  * Slice
117
119
  ****************************************************/
@@ -139,6 +141,10 @@ var reducer = (0, toolkit_1.createSlice)({
139
141
  builder.addCase(exports.reloadTreble, function (state, action) {
140
142
  return __assign(__assign({}, state), action.payload);
141
143
  });
144
+ builder.addCase(exports.updateLoadingProgress, function (state, action) {
145
+ state.loadingProgress = Math.round(action.payload * 100);
146
+ return state;
147
+ });
142
148
  },
143
149
  }).reducer;
144
150
  /*****************************************************
@@ -163,6 +169,11 @@ var getPlayerElementId = function (state) {
163
169
  return state.treble.playerElId;
164
170
  };
165
171
  exports.getPlayerElementId = getPlayerElementId;
172
+ // Player's HTML element
173
+ var getLoadingProgress = function (state) {
174
+ return state.treble.loadingProgress;
175
+ };
176
+ exports.getLoadingProgress = getLoadingProgress;
166
177
  /*****************************************************
167
178
  * Complex Actions
168
179
  ****************************************************/
@@ -175,7 +186,11 @@ var initPlayer = function (config) {
175
186
  el = config.el, authToken = config.authToken, assetId = config.assetId, stageId = config.stageId, orgId = config.orgId, playerConfig = config.playerConfig, initialConfiguration = config.initialConfiguration;
176
187
  return [4 /*yield*/, window.threekitPlayer(__assign(__assign({ el: el,
177
188
  // Variables to sort out
178
- authToken: authToken, stageId: stageId, assetId: assetId }, playerConfig), { initialConfiguration: initialConfiguration }))];
189
+ authToken: authToken, stageId: stageId, assetId: assetId }, playerConfig), { initialConfiguration: initialConfiguration, onLoadingProgress: function (progress) {
190
+ var _a;
191
+ dispatch((0, exports.updateLoadingProgress)(progress));
192
+ (_a = playerConfig === null || playerConfig === void 0 ? void 0 : playerConfig.onLoadingProgress) === null || _a === void 0 ? void 0 : _a.call(playerConfig, progress);
193
+ } }))];
179
194
  case 1:
180
195
  player = _a.sent();
181
196
  return [4 /*yield*/, player.getConfigurator()];
@@ -200,6 +215,7 @@ var initPlayer = function (config) {
200
215
  };
201
216
  dispatch((0, exports.setThreekitInitialized)(true));
202
217
  dispatch((0, exports.setPlayerLoading)(false));
218
+ dispatch((0, exports.updateLoadingProgress)(1));
203
219
  if (window.threekit.treble._debugMode)
204
220
  (0, utils_1.runDebugger)();
205
221
  window.threekit.player.on('setConfiguration', function () { return __awaiter(void 0, void 0, void 0, function () {
@@ -211,8 +227,6 @@ var initPlayer = function (config) {
211
227
  attributes = getState().attributes;
212
228
  previousAttributes = Object.values(attributes);
213
229
  updatedAttributes = window.threekit.configurator.getDisplayAttributes();
214
- if (window.threekit.treble._debugMode)
215
- (0, utils_1.runDebugger)();
216
230
  dispatch((0, attributes_1.setAttributes)(updatedAttributes));
217
231
  return [4 /*yield*/, ((_a = EVENTS.postConfigurationChange) === null || _a === void 0 ? void 0 : _a.call(EVENTS, updatedAttributes, {}, previousAttributes))];
218
232
  case 1:
@@ -229,7 +243,7 @@ var initPlayer = function (config) {
229
243
  exports.initPlayer = initPlayer;
230
244
  var launch = function (launchConfig) {
231
245
  return function (dispatch) { return __awaiter(void 0, void 0, void 0, function () {
232
- var config, productId, credentials, productsRaw, products, threekitEnv, serverUrl, playerConfig, envCredentials, _a, assetId, stageId, configurationId, initialConfigurationRaw, threekitDomainRaw, orgId, authToken, el, threekitDomain, initialConfiguration, updatedAssetId, params, configId, configuration;
246
+ var config, productId, credentials, productsRaw, products, threekitEnv, serverUrl, playerConfig, envCredentials, _a, assetIdRaw, stageId, configurationId, initialConfigurationRaw, assetId, threekitDomainRaw, orgId, authToken, el, threekitDomain, initialConfiguration, updatedAssetId, params, configId, configuration;
233
247
  var _b, _c, _d, _e, _f, _g, _h;
234
248
  return __generator(this, function (_j) {
235
249
  switch (_j.label) {
@@ -287,7 +301,8 @@ var launch = function (launchConfig) {
287
301
  serverUrl = (launchConfig === null || launchConfig === void 0 ? void 0 : launchConfig.serverUrl) || ((_g = config === null || config === void 0 ? void 0 : config.project) === null || _g === void 0 ? void 0 : _g.serverUrl);
288
302
  playerConfig = Object.assign({}, constants_1.DEFAULT_PLAYER_CONFIG, config.player, launchConfig === null || launchConfig === void 0 ? void 0 : launchConfig.playerConfig);
289
303
  envCredentials = credentials[threekitEnv];
290
- _a = products[productId][threekitEnv], assetId = _a.assetId, stageId = _a.stageId, configurationId = _a.configurationId, initialConfigurationRaw = _a.initialConfiguration;
304
+ _a = products[productId][threekitEnv], assetIdRaw = _a.assetId, stageId = _a.stageId, configurationId = _a.configurationId, initialConfigurationRaw = _a.initialConfiguration;
305
+ assetId = (launchConfig === null || launchConfig === void 0 ? void 0 : launchConfig.assetId) || assetIdRaw;
291
306
  threekitDomainRaw = envCredentials.threekitDomain || "".concat(threekitEnv, ".threekit.com");
292
307
  orgId = envCredentials.orgId, authToken = envCredentials.publicToken;
293
308
  if (playerConfig.elementId) {
@@ -9,7 +9,7 @@ export declare type WishlistState = WishlistArray;
9
9
  * Standard Selectors
10
10
  ****************************************************/
11
11
  export declare const refreshWishlist: import("@reduxjs/toolkit").AsyncThunk<import("../http/configurations").IConfigurationResponse[], void, {}>;
12
- export declare const addToWishlist: import("@reduxjs/toolkit").AsyncThunk<import("../http/configurations").IConfigurationResponse[], Omit<ISaveConfiguration, "configurator">, {}>;
12
+ export declare const addToWishlist: import("@reduxjs/toolkit").AsyncThunk<import("../http/configurations").IConfigurationResponse[], Omit<ISaveConfiguration, "configuration">, {}>;
13
13
  export declare const clearWishlist: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[], import("../http/configurations").IConfigurationResponse[], "treble/wishlist/clear", never, never>;
14
14
  export declare const removeFromWishlist: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[idx: number], import("../http/configurations").IConfigurationResponse[], "treble/wishlist/remove-item", never, never>;
15
15
  /*****************************************************
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threekit-tools/treble",
3
- "version": "0.0.78",
3
+ "version": "0.0.81",
4
4
  "author": "Amaan Saeed",
5
5
  "license": "MIT",
6
6
  "files": [