@threekit-tools/treble 0.0.84 → 0.0.85-next-1

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.
@@ -1,10 +1,10 @@
1
1
  import threekitAPI from '../api';
2
- import { IThreekitPlayer, IThreekitPrivatePlayer, IConfiguration, ISetConfiguration, IThreekitPrivateConfigurator } from '../types';
3
- import { IWishlist } from './wishlist';
2
+ import type { IThreekitPlayer, IThreekitPrivatePlayer, IConfiguration, ISetConfiguration, IThreekitPrivateConfigurator } from '../types';
3
+ import type { IWishlist } from './wishlist';
4
4
  import snapshots from './snapshots';
5
- import { ISaveConfiguration } from '../api/configurations';
6
- import { ICreateOrder } from '../api/orders';
7
- import { ICartItem } from '../http/orders';
5
+ import type { ISaveConfiguration } from '../api/configurations';
6
+ import type { ICreateOrder } from '../api/orders';
7
+ import type { ICartItem } from '../http/orders';
8
8
  interface ITreble {
9
9
  player: IThreekitPlayer;
10
10
  orgId: string;
@@ -18,6 +18,9 @@ interface IEmailShareCredentials {
18
18
  interface IOrder extends Omit<ICreateOrder, 'cart'> {
19
19
  cart?: Array<ICartItem>;
20
20
  }
21
+ interface ISaveConfigurationObject extends Omit<ISaveConfiguration, 'configuraiton'> {
22
+ saveSceneGraphState: boolean;
23
+ }
21
24
  declare class Treble {
22
25
  _api: typeof threekitAPI;
23
26
  _player: IThreekitPrivatePlayer;
@@ -28,7 +31,7 @@ declare class Treble {
28
31
  _debugMode: boolean;
29
32
  constructor({ player, orgId, initialConfiguration }: ITreble);
30
33
  createOrder: (order?: IOrder) => Promise<import("../http/orders").IOrderResponse>;
31
- saveConfiguration: (config?: Partial<Omit<ISaveConfiguration, 'configuration'>>) => Promise<{
34
+ saveConfiguration: (config?: Partial<ISaveConfigurationObject>) => Promise<{
32
35
  resumableUrl: string;
33
36
  } & import("../http/configurations").IConfigurationResponse & {
34
37
  thumbnail: string;
@@ -46,6 +46,7 @@ var constants_1 = require("../constants");
46
46
  var utils_1 = require("../utils");
47
47
  var wishlist_1 = __importDefault(require("./wishlist"));
48
48
  var snapshots_1 = __importDefault(require("./snapshots"));
49
+ var shortid_1 = __importDefault(require("shortid"));
49
50
  var Treble = (function () {
50
51
  function Treble(_a) {
51
52
  var player = _a.player, orgId = _a.orgId, initialConfiguration = _a.initialConfiguration;
@@ -80,24 +81,32 @@ var Treble = (function () {
80
81
  });
81
82
  }); };
82
83
  this.saveConfiguration = function (config) { return __awaiter(_this, void 0, void 0, function () {
83
- var threekitDomain, _a, customerId, metadata, productVersion, attachments, player, response, params, url;
84
+ var threekitDomain, _a, customerId, metadata, productVersion, attachments, saveSceneGraphState, player, sceneGraphState, sceneGraphResponse, response, params, url;
84
85
  var _b;
85
86
  var _c;
86
87
  return __generator(this, function (_d) {
87
88
  switch (_d.label) {
88
89
  case 0:
89
90
  threekitDomain = connection_1.default.getConnection().threekitDomain;
90
- _a = Object.assign({}, config), customerId = _a.customerId, metadata = _a.metadata, productVersion = _a.productVersion, attachments = _a.attachments;
91
+ _a = Object.assign({}, config), customerId = _a.customerId, metadata = _a.metadata, productVersion = _a.productVersion, attachments = _a.attachments, saveSceneGraphState = _a.saveSceneGraphState;
91
92
  player = window.threekit.player.enableApi(types_1.PRIVATE_APIS.PLAYER);
92
- return [4, api_1.default.configurations.save({
93
- assetId: window.threekit.player.assetId,
94
- configuration: player.getConfigurator().getFullConfiguration(),
95
- customerId: customerId,
96
- metadata: metadata,
97
- productVersion: productVersion,
98
- attachments: attachments,
99
- })];
93
+ if (!(saveSceneGraphState && player.saveSceneGraphState)) return [3, 2];
94
+ return [4, api_1.default.files.saveFile(player.saveSceneGraphState())];
100
95
  case 1:
96
+ sceneGraphResponse = _d.sent();
97
+ sceneGraphState = sceneGraphResponse.files[0].hash;
98
+ _d.label = 2;
99
+ case 2: return [4, api_1.default.configurations.save({
100
+ shortId: shortid_1.default.generate(),
101
+ assetId: window.threekit.player.assetId,
102
+ configuration: player.getConfigurator().getFullConfiguration(),
103
+ customerId: customerId,
104
+ metadata: metadata,
105
+ productVersion: productVersion,
106
+ attachments: attachments,
107
+ sceneGraphState: sceneGraphState,
108
+ })];
109
+ case 3:
101
110
  response = _d.sent();
102
111
  params = Object.assign((0, utils_1.getParams)(), (_b = {},
103
112
  _b[constants_1.TK_SAVED_CONFIG_PARAM_KEY] = response.data.shortId,
@@ -1,12 +1,14 @@
1
1
  import { IConfigurationResponse } from '../http/configurations';
2
2
  import { IConfiguration, IMetadata } from '../types';
3
3
  export interface ISaveConfiguration {
4
+ shortId?: string;
4
5
  assetId: string;
5
6
  customerId?: string;
6
7
  configuration: IConfiguration;
7
8
  metadata?: IMetadata;
8
9
  productVersion?: string;
9
10
  attachments?: Record<string, File>;
11
+ sceneGraphState?: string;
10
12
  }
11
13
  export declare const save: (saveConfig: ISaveConfiguration) => Promise<import("axios").AxiosResponse<IConfigurationResponse>>;
12
14
  export declare const fetch: (configurationId: string) => Promise<import("axios").AxiosResponse<IConfigurationResponse>>;
@@ -42,9 +42,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
42
42
  exports.fetchAll = exports.fetch = exports.save = void 0;
43
43
  var http_1 = __importDefault(require("../http"));
44
44
  var save = function (saveConfig) { return __awaiter(void 0, void 0, void 0, function () {
45
- var assetId, customerId, configuration, metadata, productVersion, attachments, error, fd, attachmentsPrepped_1;
45
+ var assetId, customerId, configuration, metadata, productVersion, attachments, sceneGraphState, error, fd, attachmentsPrepped_1;
46
46
  return __generator(this, function (_a) {
47
- assetId = saveConfig.assetId, customerId = saveConfig.customerId, configuration = saveConfig.configuration, metadata = saveConfig.metadata, productVersion = saveConfig.productVersion, attachments = saveConfig.attachments;
47
+ assetId = saveConfig.assetId, customerId = saveConfig.customerId, configuration = saveConfig.configuration, metadata = saveConfig.metadata, productVersion = saveConfig.productVersion, attachments = saveConfig.attachments, sceneGraphState = saveConfig.sceneGraphState;
48
48
  if (!assetId)
49
49
  error = 'Requires Asset Id';
50
50
  if (!configuration)
@@ -59,6 +59,8 @@ var save = function (saveConfig) { return __awaiter(void 0, void 0, void 0, func
59
59
  fd.append('metadata', JSON.stringify(metadata));
60
60
  if (customerId)
61
61
  fd.append('customerId', customerId);
62
+ if (sceneGraphState)
63
+ fd.append('sceneGraphState', sceneGraphState);
62
64
  if (attachments && Object.keys(attachments).length) {
63
65
  attachmentsPrepped_1 = {};
64
66
  Object.entries(attachments).forEach(function (_a) {
@@ -0,0 +1 @@
1
+ export declare const saveFile: (files: BlobPart | Array<BlobPart>) => Promise<import("../http/files").IFileResponse>;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ 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;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.saveFile = void 0;
43
+ var http_1 = __importDefault(require("../http"));
44
+ var connection_1 = __importDefault(require("../connection"));
45
+ var saveFile = function (files) { return __awaiter(void 0, void 0, void 0, function () {
46
+ var orgId, fd, data;
47
+ return __generator(this, function (_a) {
48
+ switch (_a.label) {
49
+ case 0:
50
+ orgId = connection_1.default.getConnection().orgId;
51
+ fd = new FormData();
52
+ fd.append('orgId', orgId);
53
+ fd.append("files", new Blob(Array.isArray(files) ? files : [files], {
54
+ type: 'application/json',
55
+ }));
56
+ return [4, http_1.default.files.postFile(fd)];
57
+ case 1:
58
+ data = (_a.sent()).data;
59
+ return [2, data];
60
+ }
61
+ });
62
+ }); };
63
+ exports.saveFile = saveFile;
@@ -1,3 +1,4 @@
1
+ import * as files from './files';
1
2
  import * as products from './products';
2
3
  import * as configurations from './configurations';
3
4
  import * as price from './price';
@@ -6,6 +7,7 @@ import * as catalog from './catalog';
6
7
  import * as datatables from './datatables';
7
8
  import * as server from './server';
8
9
  declare const _default: {
10
+ files: typeof files;
9
11
  products: typeof products;
10
12
  configurations: typeof configurations;
11
13
  price: typeof price;
package/dist/api/index.js CHANGED
@@ -23,6 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
+ var files = __importStar(require("./files"));
26
27
  var products = __importStar(require("./products"));
27
28
  var configurations = __importStar(require("./configurations"));
28
29
  var price = __importStar(require("./price"));
@@ -31,6 +32,7 @@ var catalog = __importStar(require("./catalog"));
31
32
  var datatables = __importStar(require("./datatables"));
32
33
  var server = __importStar(require("./server"));
33
34
  exports.default = {
35
+ files: files,
34
36
  products: products,
35
37
  configurations: configurations,
36
38
  price: price,
@@ -1,11 +1,14 @@
1
1
  /// <reference types="react" />
2
2
  import PropTypes from 'prop-types';
3
3
  import { BUTTON_SHAPES, BUTTON_TYPES } from '../Button';
4
+ import type { Positions } from './share.styles';
4
5
  interface ShareProps {
5
6
  shape?: BUTTON_SHAPES;
6
7
  type?: BUTTON_TYPES;
7
8
  className?: string;
8
9
  message?: string;
10
+ position: Positions;
11
+ saveSceneGraphState?: boolean;
9
12
  }
10
13
  export declare const Share: {
11
14
  (props: ShareProps): JSX.Element | null;
@@ -20,6 +23,7 @@ export declare const Share: {
20
23
  shape: string;
21
24
  type: string;
22
25
  message: string;
26
+ saveSceneGraphState: boolean;
23
27
  };
24
28
  };
25
29
  export default Share;
@@ -1,27 +1,160 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __generator = (this && this.__generator) || function (thisArg, body) {
35
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
36
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
37
+ function verb(n) { return function (v) { return step([n, v]); }; }
38
+ function step(op) {
39
+ if (f) throw new TypeError("Generator is already executing.");
40
+ while (_) try {
41
+ 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;
42
+ if (y = 0, t) op = [op[0] & 2, t.value];
43
+ switch (op[0]) {
44
+ case 0: case 1: t = op; break;
45
+ case 4: _.label++; return { value: op[1], done: false };
46
+ case 5: _.label++; y = op[1]; op = [0]; continue;
47
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
48
+ default:
49
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
50
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
51
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
52
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
53
+ if (t[2]) _.ops.pop();
54
+ _.trys.pop(); continue;
55
+ }
56
+ op = body.call(thisArg, _);
57
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
58
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
59
+ }
60
+ };
2
61
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
62
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
63
  };
5
64
  Object.defineProperty(exports, "__esModule", { value: true });
6
65
  exports.Share = void 0;
7
- var react_1 = __importDefault(require("react"));
66
+ var react_1 = __importStar(require("react"));
8
67
  var prop_types_1 = __importDefault(require("prop-types"));
9
68
  var Button_1 = __importDefault(require("../Button"));
69
+ var message_1 = __importDefault(require("../message"));
10
70
  var Share_1 = __importDefault(require("../../icons/Share"));
11
71
  var useThreekitInitStatus_1 = __importDefault(require("../../hooks/useThreekitInitStatus"));
12
- var useShare_1 = __importDefault(require("../../hooks/useShare"));
13
72
  var utils_1 = require("../../utils");
73
+ var share_styles_1 = require("./share.styles");
14
74
  var Share = function (props) {
15
- var _a = Object.assign({ type: 'threekit', shape: 'round', message: 'Link copied!' }, props), shape = _a.shape, type = _a.type, className = _a.className, message = _a.message;
75
+ var _a = Object.assign({
76
+ type: 'threekit',
77
+ shape: 'round',
78
+ message: 'Link copied!',
79
+ position: 'bottom-right',
80
+ saveSceneGraphState: false,
81
+ }, props), shape = _a.shape, type = _a.type, className = _a.className, msg = _a.message, position = _a.position, saveSceneGraphState = _a.saveSceneGraphState;
16
82
  var hasLoaded = (0, useThreekitInitStatus_1.default)();
17
- var handleShare = (0, useShare_1.default)();
18
- if (!hasLoaded || !handleShare)
83
+ var _b = (0, react_1.useState)(false), show = _b[0], setShow = _b[1];
84
+ var _c = (0, react_1.useState)(null), resumeUrl = _c[0], setResumeUrl = _c[1];
85
+ var resumeUrlElRef = (0, react_1.useRef)(null);
86
+ var shareButtonRef = (0, react_1.useRef)(null);
87
+ var shareContentRef = (0, react_1.useRef)(null);
88
+ (0, react_1.useEffect)(function () {
89
+ var handleClickOutside = function (e) {
90
+ var _a, _b;
91
+ if (!e)
92
+ return;
93
+ if (!((_a = shareButtonRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target)) &&
94
+ !((_b = shareContentRef.current) === null || _b === void 0 ? void 0 : _b.contains(e.target))) {
95
+ setShow(false);
96
+ e.stopPropagation();
97
+ }
98
+ };
99
+ document.addEventListener('mousedown', handleClickOutside);
100
+ return function () {
101
+ document.removeEventListener('mousedown', handleClickOutside);
102
+ };
103
+ }, [show, shareButtonRef, shareContentRef]);
104
+ if (!hasLoaded)
19
105
  return null;
20
106
  var cls = (0, utils_1.generateWidgetClassName)('share', className);
21
- var handleClick = function () {
22
- handleShare(message);
23
- };
24
- return (react_1.default.createElement(Button_1.default, { className: cls, shape: shape, type: type, icon: Share_1.default.iconName, onClick: handleClick }));
107
+ var handleClick = function () { return __awaiter(void 0, void 0, void 0, function () {
108
+ var configuration, e_1;
109
+ return __generator(this, function (_a) {
110
+ switch (_a.label) {
111
+ case 0:
112
+ if (show) {
113
+ setResumeUrl(null);
114
+ setShow(!show);
115
+ return [2];
116
+ }
117
+ return [4, window.threekit.treble.saveConfiguration({
118
+ saveSceneGraphState: saveSceneGraphState,
119
+ })];
120
+ case 1:
121
+ configuration = _a.sent();
122
+ _a.label = 2;
123
+ case 2:
124
+ _a.trys.push([2, 4, , 5]);
125
+ return [4, navigator.clipboard.writeText(configuration.resumableUrl)];
126
+ case 3:
127
+ _a.sent();
128
+ if (msg === null || msg === void 0 ? void 0 : msg.length)
129
+ message_1.default.info(msg);
130
+ return [3, 5];
131
+ case 4:
132
+ e_1 = _a.sent();
133
+ setResumeUrl(configuration.resumableUrl);
134
+ setShow(!show);
135
+ return [3, 5];
136
+ case 5: return [2];
137
+ }
138
+ });
139
+ }); };
140
+ var handleClickCopy = function () { return __awaiter(void 0, void 0, void 0, function () {
141
+ var _a;
142
+ return __generator(this, function (_b) {
143
+ if (!((_a = resumeUrlElRef.current) === null || _a === void 0 ? void 0 : _a.value))
144
+ return [2];
145
+ navigator.clipboard.writeText(resumeUrlElRef.current.value);
146
+ if (msg === null || msg === void 0 ? void 0 : msg.length)
147
+ message_1.default.info(msg);
148
+ return [2];
149
+ });
150
+ }); };
151
+ return (react_1.default.createElement(share_styles_1.Wrapper, { ref: shareButtonRef },
152
+ react_1.default.createElement(Button_1.default, { className: cls, shape: shape, type: type, icon: Share_1.default.iconName, onClick: handleClick }),
153
+ show ? (react_1.default.createElement(share_styles_1.ShareWrapper, { position: position },
154
+ react_1.default.createElement(share_styles_1.Content, { ref: shareContentRef },
155
+ react_1.default.createElement("input", { type: "text", ref: resumeUrlElRef, value: resumeUrl || '', onChange: function () { } }),
156
+ react_1.default.createElement("button", { type: "button", onClick: handleClickCopy }, "copy link")),
157
+ react_1.default.createElement(share_styles_1.Caret, null))) : null));
25
158
  };
26
159
  exports.Share = Share;
27
160
  exports.Share.propTypes = {
@@ -35,5 +168,6 @@ exports.Share.defaultProps = {
35
168
  shape: 'round',
36
169
  type: 'threekit',
37
170
  message: 'Link copied!',
171
+ saveSceneGraphState: false,
38
172
  };
39
173
  exports.default = exports.Share;
@@ -0,0 +1,9 @@
1
+ export declare type Positions = 'top-right' | 'bottom-right' | 'bottom-left' | 'top-left';
2
+ interface PositionProps {
3
+ position: Positions;
4
+ }
5
+ export declare const Wrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
6
+ export declare const Content: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
7
+ export declare const Caret: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
8
+ export declare const ShareWrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, PositionProps, never>;
9
+ export {};
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
+ return cooked;
5
+ };
6
+ var __importDefault = (this && this.__importDefault) || function (mod) {
7
+ return (mod && mod.__esModule) ? mod : { "default": mod };
8
+ };
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.ShareWrapper = exports.Caret = exports.Content = exports.Wrapper = void 0;
11
+ var styled_components_1 = __importDefault(require("styled-components"));
12
+ exports.Wrapper = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n height: 40px;\n width: 40px;\n position: relative;\n"], ["\n height: 40px;\n width: 40px;\n position: relative;\n"])));
13
+ var ShareWrapperStyles = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n position: relative;\n"], ["\n position: relative;\n"])));
14
+ exports.Content = styled_components_1.default.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n padding: 24px 18px;\n border-radius: 4px;\n background: rgba(0, 0, 0, 0.9);\n color: white;\n font-size: 16px;\n width: 290px;\n\n display: flex;\n flex-direction: row;\n justify-content: center;\n\n input {\n background: #555555;\n color: #ffffff;\n border: none;\n outline: none;\n padding: 9px;\n border-radius: 4px;\n font-size: 13px;\n text-overflow: ellipsis;\n width: 180px;\n }\n\n button {\n color: #2a94f5;\n font-size: 13px;\n background: none;\n outline: none;\n border: none;\n cursor: pointer;\n }\n"], ["\n padding: 24px 18px;\n border-radius: 4px;\n background: rgba(0, 0, 0, 0.9);\n color: white;\n font-size: 16px;\n width: 290px;\n\n display: flex;\n flex-direction: row;\n justify-content: center;\n\n input {\n background: #555555;\n color: #ffffff;\n border: none;\n outline: none;\n padding: 9px;\n border-radius: 4px;\n font-size: 13px;\n text-overflow: ellipsis;\n width: 180px;\n }\n\n button {\n color: #2a94f5;\n font-size: 13px;\n background: none;\n outline: none;\n border: none;\n cursor: pointer;\n }\n"])));
15
+ exports.Caret = styled_components_1.default.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n width: 0;\n height: 0;\n border-left: 10px solid transparent;\n border-right: 10px solid transparent;\n border-top: 8px solid rgba(0, 0, 0, 0.9);\n\n position: absolute;\n"], ["\n width: 0;\n height: 0;\n border-left: 10px solid transparent;\n border-right: 10px solid transparent;\n border-top: 8px solid rgba(0, 0, 0, 0.9);\n\n position: absolute;\n"])));
16
+ exports.ShareWrapper = (0, styled_components_1.default)(ShareWrapperStyles)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n top: ", ";\n left: ", ";\n transform: ", ";\n\n ", " {\n left: ", ";\n top: ", ";\n\n transform: ", ";\n }\n"], ["\n top: ", ";\n left: ", ";\n transform: ", ";\n\n ", " {\n left: ", ";\n top: ", ";\n\n transform: ", ";\n }\n"])), function (props) { return (props.position.includes('top') ? '14px' : '-100%'); }, function (props) { return (props.position.includes('right') ? '-250px' : 'auto'); }, function (props) {
17
+ return props.position.includes('top')
18
+ ? ''
19
+ : 'translateY(calc(0px - 14px - 100%))';
20
+ }, exports.Caret, function (props) { return (props.position.includes('right') ? '260px' : '10px'); }, function (props) { return (props.position.includes('top') ? '0' : 'auto'); }, function (props) {
21
+ return props.position.includes('top') ? 'translateY(-100%) scaleY(-1)' : '';
22
+ });
23
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
@@ -14,6 +14,7 @@ export interface IConfigurationResponse {
14
14
  thumbnail: null | string;
15
15
  variant: IConfiguration;
16
16
  attachments: Record<string, string>;
17
+ sceneGraphState: null | string;
17
18
  }
18
19
  interface IConfigurationsResponse extends IMultiPageResponse {
19
20
  configurations: Array<IConfigurationResponse>;
@@ -0,0 +1,21 @@
1
+ declare enum ENCODING_OPTIONS {
2
+ RAW = "raw",
3
+ GZIP = "gzip",
4
+ BROTLI = "brotli"
5
+ }
6
+ interface IFile {
7
+ id: string;
8
+ userId: string;
9
+ hash: string;
10
+ encodings: Partial<Record<ENCODING_OPTIONS, {
11
+ size: number;
12
+ }>>;
13
+ filename: string;
14
+ size: number;
15
+ extension: string;
16
+ }
17
+ export interface IFileResponse {
18
+ files: Array<IFile>;
19
+ }
20
+ export declare const postFile: (formData: FormData) => Promise<import("axios").AxiosResponse<IFileResponse>>;
21
+ export {};
@@ -0,0 +1,26 @@
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.postFile = void 0;
7
+ var request_1 = __importDefault(require("./request"));
8
+ var FILES_API_ROUTE = "/api/files";
9
+ var ENCODING_OPTIONS;
10
+ (function (ENCODING_OPTIONS) {
11
+ ENCODING_OPTIONS["RAW"] = "raw";
12
+ ENCODING_OPTIONS["GZIP"] = "gzip";
13
+ ENCODING_OPTIONS["BROTLI"] = "brotli";
14
+ })(ENCODING_OPTIONS || (ENCODING_OPTIONS = {}));
15
+ var postFile = function (formData) {
16
+ var error;
17
+ if (!formData)
18
+ error = 'Requires Form Data';
19
+ if (error)
20
+ throw new Error(error);
21
+ return request_1.default.post({
22
+ url: FILES_API_ROUTE,
23
+ formData: formData,
24
+ });
25
+ };
26
+ exports.postFile = postFile;
@@ -1,3 +1,4 @@
1
+ import * as files from './files';
1
2
  import * as orders from './orders';
2
3
  import * as products from './products';
3
4
  import * as configurations from './configurations';
@@ -6,6 +7,7 @@ import * as catalog from './catalog';
6
7
  import * as datatables from './datatables';
7
8
  import * as server from './server';
8
9
  declare const _default: {
10
+ files: typeof files;
9
11
  orders: typeof orders;
10
12
  products: typeof products;
11
13
  configurations: typeof configurations;
@@ -23,6 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
+ var files = __importStar(require("./files"));
26
27
  var orders = __importStar(require("./orders"));
27
28
  var products = __importStar(require("./products"));
28
29
  var configurations = __importStar(require("./configurations"));
@@ -31,6 +32,7 @@ var catalog = __importStar(require("./catalog"));
31
32
  var datatables = __importStar(require("./datatables"));
32
33
  var server = __importStar(require("./server"));
33
34
  exports.default = {
35
+ files: files,
34
36
  orders: orders,
35
37
  products: products,
36
38
  configurations: configurations,
@@ -5,6 +5,7 @@ export interface IPlayerInit {
5
5
  authToken: string;
6
6
  assetId: string;
7
7
  stageId?: string;
8
+ configurationId?: string;
8
9
  orgId: string;
9
10
  playerConfig: IPlayerConfig;
10
11
  initialConfiguration?: IConfiguration;
@@ -147,12 +147,12 @@ var getLoadingProgress = function (state) {
147
147
  exports.getLoadingProgress = getLoadingProgress;
148
148
  var initPlayer = function (config) {
149
149
  return function (dispatch, getState) { return __awaiter(void 0, void 0, void 0, function () {
150
- var el, authToken, assetId, stageId, orgId, playerConfig, initialConfiguration, player, configurator;
150
+ var el, authToken, assetId, stageId, configurationId, orgId, playerConfig, initialConfiguration, player, configurator;
151
151
  return __generator(this, function (_a) {
152
152
  switch (_a.label) {
153
153
  case 0:
154
- el = config.el, authToken = config.authToken, assetId = config.assetId, stageId = config.stageId, orgId = config.orgId, playerConfig = config.playerConfig, initialConfiguration = config.initialConfiguration;
155
- return [4, window.threekitPlayer(__assign(__assign({ el: el, authToken: authToken, stageId: stageId, assetId: assetId }, playerConfig), { initialConfiguration: initialConfiguration, onLoadingProgress: function (progress) {
154
+ el = config.el, authToken = config.authToken, assetId = config.assetId, stageId = config.stageId, configurationId = config.configurationId, orgId = config.orgId, playerConfig = config.playerConfig, initialConfiguration = config.initialConfiguration;
155
+ return [4, window.threekitPlayer(__assign(__assign({ el: el, authToken: authToken, stageId: stageId, assetId: assetId, configurationId: configurationId }, playerConfig), { initialConfiguration: initialConfiguration, onLoadingProgress: function (progress) {
156
156
  var _a;
157
157
  dispatch((0, exports.updateLoadingProgress)(progress));
158
158
  (_a = playerConfig === null || playerConfig === void 0 ? void 0 : playerConfig.onLoadingProgress) === null || _a === void 0 ? void 0 : _a.call(playerConfig, progress);
@@ -324,6 +324,7 @@ var launch = function (launchConfig) {
324
324
  authToken: authToken,
325
325
  stageId: stageId,
326
326
  assetId: updatedAssetId,
327
+ configurationId: configId,
327
328
  playerConfig: playerConfig,
328
329
  initialConfiguration: initialConfiguration,
329
330
  }))];
package/dist/types.d.ts CHANGED
@@ -291,12 +291,14 @@ export interface IThreekitPrivatePlayer {
291
291
  };
292
292
  calculateLogs: () => Promise<Record<string, any>>;
293
293
  getAssetInstance: (query: ISceneQueryNode | string) => Promise<string>;
294
+ saveSceneGraphState: () => string;
294
295
  }
295
296
  export interface ThreekitInitConfig {
296
297
  authToken: string;
297
298
  el: HTMLElement;
298
299
  assetId: string;
299
300
  stageId?: string;
301
+ configurationId?: string;
300
302
  orgId?: string;
301
303
  showConfigurator?: boolean;
302
304
  initialConfiguration?: Record<string, any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threekit-tools/treble",
3
- "version": "0.0.84",
3
+ "version": "0.0.85-next-1",
4
4
  "author": "Amaan Saeed",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -42,11 +42,15 @@
42
42
  },
43
43
  "dependencies": {
44
44
  "@reduxjs/toolkit": "^1.6.2",
45
+ "@types/shortid": "^0.0.29",
45
46
  "axios": "^0.22.0",
47
+ "chokidar": "^3.5.3",
48
+ "live-server": "^1.2.2",
46
49
  "react-redux": "^7.2.6",
47
50
  "redux": "^4.1.2",
48
51
  "redux-logger": "^3.0.6",
49
52
  "reselect": "^4.1.2",
53
+ "shortid": "^2.2.16",
50
54
  "styled-components": "^5.3.3"
51
55
  },
52
56
  "devDependencies": {