@threekit-tools/treble 0.0.82 → 0.0.85
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 +9 -3
- package/dist/Treble/Treble.js +40 -11
- package/dist/Treble/index.d.ts +2 -2
- package/dist/Treble/index.js +2 -2
- package/dist/Treble/{Snapshots.d.ts → snapshots.d.ts} +4 -9
- package/dist/Treble/snapshots.js +247 -0
- package/dist/Treble/{Wishlist.d.ts → wishlist.d.ts} +2 -6
- package/dist/Treble/wishlist.js +135 -0
- package/dist/api/catalog.js +6 -6
- package/dist/api/configurations.js +3 -3
- package/dist/api/datatables.js +5 -5
- package/dist/api/orders.d.ts +5 -7
- package/dist/api/orders.js +12 -12
- package/dist/api/price.js +2 -2
- package/dist/api/products.js +2 -2
- package/dist/components/Accordion/index.js +1 -6
- package/dist/components/AttributeTitle/index.d.ts +0 -9
- package/dist/components/AttributeTitle/index.js +0 -9
- package/dist/components/AttributeValue/index.d.ts +0 -6
- package/dist/components/AttributeValue/index.js +2 -8
- package/dist/components/Button/index.d.ts +0 -27
- package/dist/components/Button/index.js +0 -27
- package/dist/components/Cards/index.d.ts +2 -55
- package/dist/components/Cards/index.js +3 -60
- package/dist/components/Drawer/index.js +0 -13
- package/dist/components/Dropdown/index.d.ts +2 -59
- package/dist/components/Dropdown/index.js +4 -69
- package/dist/components/FlatForm/index.d.ts +0 -21
- package/dist/components/FlatForm/index.js +5 -24
- package/dist/components/Modal/index.js +0 -13
- package/dist/components/Player/index.d.ts +1 -1
- package/dist/components/PortalToElement/index.js +0 -8
- package/dist/components/ProductDescription/index.d.ts +0 -6
- package/dist/components/ProductDescription/index.js +0 -6
- package/dist/components/ProductName/index.d.ts +0 -9
- package/dist/components/ProductName/index.js +0 -9
- package/dist/components/Share/index.d.ts +2 -12
- package/dist/components/Share/index.js +139 -21
- package/dist/components/Share/share.styles.d.ts +9 -0
- package/dist/components/Share/share.styles.js +23 -0
- package/dist/components/Snapshots/index.d.ts +0 -8
- package/dist/components/Snapshots/index.js +0 -8
- package/dist/components/Strips/index.d.ts +2 -55
- package/dist/components/Strips/index.js +3 -60
- package/dist/components/Swatch/index.d.ts +2 -64
- package/dist/components/Swatch/index.js +3 -69
- package/dist/components/Switch/index.d.ts +2 -34
- package/dist/components/Switch/index.js +2 -38
- package/dist/components/TextInput/index.d.ts +2 -1
- package/dist/components/TextInput/index.js +2 -3
- package/dist/components/Tiles/index.d.ts +2 -29
- package/dist/components/Tiles/index.js +3 -33
- package/dist/components/TilesGroup/index.d.ts +2 -26
- package/dist/components/TilesGroup/index.js +3 -30
- package/dist/components/TotalPrice/index.d.ts +0 -6
- package/dist/components/TotalPrice/index.js +0 -6
- package/dist/components/Upload/index.d.ts +2 -1
- package/dist/components/Upload/index.js +7 -8
- package/dist/components/UploadArea/index.d.ts +2 -1
- package/dist/components/UploadArea/index.js +6 -7
- package/dist/components/Wishlist/index.d.ts +1 -4
- package/dist/components/Wishlist/index.js +2 -5
- package/dist/components/Zoom/index.d.ts +1 -18
- package/dist/components/Zoom/index.js +0 -17
- package/dist/components/formComponents.d.ts +12 -0
- package/dist/components/formComponents.js +5 -7
- package/dist/components/message/index.d.ts +0 -9
- package/dist/components/message/index.js +0 -9
- package/dist/connection.js +2 -2
- package/dist/constants.d.ts +0 -49
- package/dist/constants.js +1 -59
- package/dist/hooks/useAttribute/index.js +6 -6
- package/dist/hooks/useConfigurationLoader/index.js +5 -5
- package/dist/hooks/useNestedConfigurator/index.js +2 -2
- package/dist/hooks/useShare/index.js +3 -3
- package/dist/hooks/useSingleAnimation/index.js +20 -25
- package/dist/http/datatables.js +0 -1
- package/dist/http/orders.d.ts +6 -8
- package/dist/icons/index.d.ts +0 -41
- package/dist/icons/index.js +0 -42
- package/dist/index.d.ts +42 -3
- package/dist/index.js +84 -30
- package/dist/store/attributes.d.ts +0 -12
- package/dist/store/attributes.js +2 -15
- package/dist/store/price.d.ts +0 -12
- package/dist/store/price.js +2 -16
- package/dist/store/product.d.ts +2 -17
- package/dist/store/product.js +26 -38
- package/dist/store/translations.d.ts +0 -12
- package/dist/store/translations.js +2 -12
- package/dist/store/treble.d.ts +0 -15
- package/dist/store/treble.js +31 -66
- package/dist/store/wishlist.d.ts +0 -12
- package/dist/store/wishlist.js +4 -17
- package/dist/types.d.ts +71 -58
- package/dist/types.js +54 -0
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +8 -16
- package/package.json +18 -4
- package/dist/Treble/Snapshots.js +0 -251
- package/dist/Treble/Wishlist.js +0 -136
package/dist/Treble/Treble.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import threekitAPI from '../api';
|
|
2
2
|
import { IThreekitPlayer, IThreekitPrivatePlayer, IConfiguration, ISetConfiguration, IThreekitPrivateConfigurator } from '../types';
|
|
3
|
-
import { IWishlist } from './
|
|
4
|
-
import
|
|
3
|
+
import { IWishlist } from './wishlist';
|
|
4
|
+
import snapshots from './snapshots';
|
|
5
5
|
import { ISaveConfiguration } from '../api/configurations';
|
|
6
|
+
import { ICreateOrder } from '../api/orders';
|
|
7
|
+
import { ICartItem } from '../http/orders';
|
|
6
8
|
interface ITreble {
|
|
7
9
|
player: IThreekitPlayer;
|
|
8
10
|
orgId: string;
|
|
@@ -13,15 +15,19 @@ interface IEmailShareCredentials {
|
|
|
13
15
|
from: string;
|
|
14
16
|
templateId: string;
|
|
15
17
|
}
|
|
18
|
+
interface IOrder extends Omit<ICreateOrder, 'cart'> {
|
|
19
|
+
cart?: Array<ICartItem>;
|
|
20
|
+
}
|
|
16
21
|
declare class Treble {
|
|
17
22
|
_api: typeof threekitAPI;
|
|
18
23
|
_player: IThreekitPrivatePlayer;
|
|
19
24
|
wishlist: IWishlist;
|
|
20
25
|
private _initialConfiguration;
|
|
21
26
|
private _snapshots;
|
|
22
|
-
takeSnapshots:
|
|
27
|
+
takeSnapshots: typeof snapshots['takeSnapshots'];
|
|
23
28
|
_debugMode: boolean;
|
|
24
29
|
constructor({ player, orgId, initialConfiguration }: ITreble);
|
|
30
|
+
createOrder: (order?: IOrder) => Promise<import("../http/orders").IOrderResponse>;
|
|
25
31
|
saveConfiguration: (config?: Partial<Omit<ISaveConfiguration, 'configuration'>>) => Promise<{
|
|
26
32
|
resumableUrl: string;
|
|
27
33
|
} & import("../http/configurations").IConfigurationResponse & {
|
package/dist/Treble/Treble.js
CHANGED
|
@@ -41,14 +41,44 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
42
|
var api_1 = __importDefault(require("../api"));
|
|
43
43
|
var connection_1 = __importDefault(require("../connection"));
|
|
44
|
+
var types_1 = require("../types");
|
|
44
45
|
var constants_1 = require("../constants");
|
|
45
46
|
var utils_1 = require("../utils");
|
|
46
|
-
var
|
|
47
|
-
var
|
|
48
|
-
var Treble =
|
|
47
|
+
var wishlist_1 = __importDefault(require("./wishlist"));
|
|
48
|
+
var snapshots_1 = __importDefault(require("./snapshots"));
|
|
49
|
+
var Treble = (function () {
|
|
49
50
|
function Treble(_a) {
|
|
50
51
|
var player = _a.player, orgId = _a.orgId, initialConfiguration = _a.initialConfiguration;
|
|
51
52
|
var _this = this;
|
|
53
|
+
this.createOrder = function (order) { return __awaiter(_this, void 0, void 0, function () {
|
|
54
|
+
var updatedOrder, configuration, response;
|
|
55
|
+
var _a;
|
|
56
|
+
return __generator(this, function (_b) {
|
|
57
|
+
switch (_b.label) {
|
|
58
|
+
case 0:
|
|
59
|
+
updatedOrder = Object.assign({}, order, (order === null || order === void 0 ? void 0 : order.cart) ? { cart: order.cart } : { cart: [] });
|
|
60
|
+
if (!!(order === null || order === void 0 ? void 0 : order.cart)) return [3, 2];
|
|
61
|
+
return [4, this.saveConfiguration()];
|
|
62
|
+
case 1:
|
|
63
|
+
configuration = _b.sent();
|
|
64
|
+
updatedOrder = Object.assign({}, order, ((_a = order === null || order === void 0 ? void 0 : order.cart) === null || _a === void 0 ? void 0 : _a.length)
|
|
65
|
+
? { cart: order.cart }
|
|
66
|
+
: {
|
|
67
|
+
cart: [
|
|
68
|
+
{
|
|
69
|
+
count: 1,
|
|
70
|
+
configurationId: configuration.id,
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
});
|
|
74
|
+
_b.label = 2;
|
|
75
|
+
case 2: return [4, api_1.default.orders.createOrder(updatedOrder)];
|
|
76
|
+
case 3:
|
|
77
|
+
response = _b.sent();
|
|
78
|
+
return [2, response];
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}); };
|
|
52
82
|
this.saveConfiguration = function (config) { return __awaiter(_this, void 0, void 0, function () {
|
|
53
83
|
var threekitDomain, _a, customerId, metadata, productVersion, attachments, player, response, params, url;
|
|
54
84
|
var _b;
|
|
@@ -58,8 +88,8 @@ var Treble = /** @class */ (function () {
|
|
|
58
88
|
case 0:
|
|
59
89
|
threekitDomain = connection_1.default.getConnection().threekitDomain;
|
|
60
90
|
_a = Object.assign({}, config), customerId = _a.customerId, metadata = _a.metadata, productVersion = _a.productVersion, attachments = _a.attachments;
|
|
61
|
-
player = window.threekit.player.enableApi(
|
|
62
|
-
return [4
|
|
91
|
+
player = window.threekit.player.enableApi(types_1.PRIVATE_APIS.PLAYER);
|
|
92
|
+
return [4, api_1.default.configurations.save({
|
|
63
93
|
assetId: window.threekit.player.assetId,
|
|
64
94
|
configuration: player.getConfigurator().getFullConfiguration(),
|
|
65
95
|
customerId: customerId,
|
|
@@ -73,7 +103,7 @@ var Treble = /** @class */ (function () {
|
|
|
73
103
|
_b[constants_1.TK_SAVED_CONFIG_PARAM_KEY] = response.data.shortId,
|
|
74
104
|
_b));
|
|
75
105
|
url = window.location.href.replace(window.location.search, '');
|
|
76
|
-
return [2
|
|
106
|
+
return [2, Object.assign({
|
|
77
107
|
resumableUrl: "".concat(url).concat((0, utils_1.objectToQueryStr)(params)),
|
|
78
108
|
}, response.data, ((_c = response.data.thumbnail) === null || _c === void 0 ? void 0 : _c.length)
|
|
79
109
|
? {
|
|
@@ -86,7 +116,7 @@ var Treble = /** @class */ (function () {
|
|
|
86
116
|
this.getNestedConfigurator = function (address) {
|
|
87
117
|
if (!address)
|
|
88
118
|
return undefined;
|
|
89
|
-
var player = window.threekit.player.enableApi(
|
|
119
|
+
var player = window.threekit.player.enableApi(types_1.PRIVATE_APIS.PLAYER);
|
|
90
120
|
var addressArr = Array.isArray(address) ? address : [address];
|
|
91
121
|
return addressArr.reduce(function (configurator, attributeName) {
|
|
92
122
|
var _a;
|
|
@@ -120,12 +150,11 @@ var Treble = /** @class */ (function () {
|
|
|
120
150
|
}, { TemplateModel: templateData });
|
|
121
151
|
return api_1.default.server.sendEmail(data);
|
|
122
152
|
};
|
|
123
|
-
// Threekit API
|
|
124
153
|
this._api = api_1.default;
|
|
125
|
-
this.wishlist = (0,
|
|
126
|
-
this._snapshots =
|
|
154
|
+
this.wishlist = (0, wishlist_1.default)(orgId);
|
|
155
|
+
this._snapshots = snapshots_1.default;
|
|
127
156
|
this.takeSnapshots = this._snapshots.takeSnapshots;
|
|
128
|
-
this._player = player.enableApi(
|
|
157
|
+
this._player = player.enableApi(types_1.PRIVATE_APIS.PLAYER);
|
|
129
158
|
this._initialConfiguration = JSON.stringify(initialConfiguration);
|
|
130
159
|
this._debugMode = constants_1.TREBLE_DEBUG;
|
|
131
160
|
}
|
package/dist/Treble/index.d.ts
CHANGED
package/dist/Treble/index.js
CHANGED
|
@@ -19,6 +19,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
20
|
var Treble_1 = __importDefault(require("./Treble"));
|
|
21
21
|
__exportStar(require("./Treble"), exports);
|
|
22
|
-
__exportStar(require("./
|
|
23
|
-
__exportStar(require("./
|
|
22
|
+
__exportStar(require("./snapshots"), exports);
|
|
23
|
+
__exportStar(require("./wishlist"), exports);
|
|
24
24
|
exports.default = Treble_1.default;
|
|
@@ -15,13 +15,8 @@ interface IGetSnapshot {
|
|
|
15
15
|
size: SnapshotSize;
|
|
16
16
|
format: string;
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
getSnapshot(snapshotConfig: IGetSnapshot): Promise<string>;
|
|
20
|
-
takeSnapshots(cameras: ISnapshotsCameras, config: ITakeSnapshotsConfig): Promise<void | string[] | Blob[] | File[] | null>;
|
|
21
|
-
}
|
|
22
|
-
declare class Snapshots implements ISnapshots {
|
|
23
|
-
constructor();
|
|
18
|
+
declare const _default: {
|
|
24
19
|
getSnapshot: ({ size, format }: IGetSnapshot) => Promise<string>;
|
|
25
|
-
takeSnapshots: (camerasList: ISnapshotsCameras, snapshotsConfig: ITakeSnapshotsConfig) => Promise<void | string[] |
|
|
26
|
-
}
|
|
27
|
-
export default
|
|
20
|
+
takeSnapshots: (camerasList: ISnapshotsCameras, snapshotsConfig: ITakeSnapshotsConfig) => Promise<void | string[] | File[] | Blob[] | null>;
|
|
21
|
+
};
|
|
22
|
+
export default _default;
|
|
@@ -0,0 +1,247 @@
|
|
|
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
|
+
var api_1 = __importDefault(require("../api"));
|
|
43
|
+
var constants_1 = require("../constants");
|
|
44
|
+
var types_1 = require("../types");
|
|
45
|
+
var utils_1 = require("../utils");
|
|
46
|
+
var DEFAULT_CAMERA_CONFIG = {
|
|
47
|
+
filename: "snapshot",
|
|
48
|
+
size: { width: 1920, height: 1080 },
|
|
49
|
+
format: types_1.SNAPSHOT_FORMATS.PNG,
|
|
50
|
+
attributeName: constants_1.ATTRIBUTES_RESERVED.camera,
|
|
51
|
+
output: types_1.SNAPSHOT_OUTPUTS.BLOB,
|
|
52
|
+
useStage: false,
|
|
53
|
+
};
|
|
54
|
+
var cameraValues;
|
|
55
|
+
var getCameraValue = function (configurator, cameraAttrName) {
|
|
56
|
+
if (cameraAttrName === void 0) { cameraAttrName = constants_1.ATTRIBUTES_RESERVED.camera; }
|
|
57
|
+
var attribute = configurator
|
|
58
|
+
.getDisplayAttributes()
|
|
59
|
+
.find(function (el) { return el.name === cameraAttrName; });
|
|
60
|
+
if (!attribute)
|
|
61
|
+
return undefined;
|
|
62
|
+
return attribute.value;
|
|
63
|
+
};
|
|
64
|
+
var getCamerasMap = function (configurator, cameraAttrName) {
|
|
65
|
+
if (cameraAttrName === void 0) { cameraAttrName = constants_1.ATTRIBUTES_RESERVED.camera; }
|
|
66
|
+
if (cameraValues)
|
|
67
|
+
return cameraValues;
|
|
68
|
+
var attribute = configurator
|
|
69
|
+
.getDisplayAttributes()
|
|
70
|
+
.find(function (el) { return el.name === cameraAttrName; });
|
|
71
|
+
if (!attribute) {
|
|
72
|
+
cameraValues = {};
|
|
73
|
+
return cameraValues;
|
|
74
|
+
}
|
|
75
|
+
var cameraAttribute = attribute;
|
|
76
|
+
cameraAttribute.values.forEach(function (el) {
|
|
77
|
+
var _a;
|
|
78
|
+
var value = cameraAttribute.type === types_1.ATTRIBUTE_TYPES.ASSET
|
|
79
|
+
? { assetId: el.assetId }
|
|
80
|
+
: el.value;
|
|
81
|
+
cameraValues = Object.assign(cameraValues || {}, (_a = {},
|
|
82
|
+
_a[el.label] = value,
|
|
83
|
+
_a));
|
|
84
|
+
}, {});
|
|
85
|
+
return cameraValues;
|
|
86
|
+
};
|
|
87
|
+
var getSnapshot = function (_a) {
|
|
88
|
+
var size = _a.size, format = _a.format;
|
|
89
|
+
return window.threekit.player.snapshotAsync({
|
|
90
|
+
size: size,
|
|
91
|
+
mimeType: "image/".concat(types_1.SNAPSHOT_FORMATS[format]),
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
var getSnapshots = function (cameras, snapshotConfig) { return __awaiter(void 0, void 0, void 0, function () {
|
|
95
|
+
var attributeName, size, format, configurator, _a, camerasMap, snapshots;
|
|
96
|
+
return __generator(this, function (_b) {
|
|
97
|
+
switch (_b.label) {
|
|
98
|
+
case 0:
|
|
99
|
+
attributeName = snapshotConfig.attributeName || DEFAULT_CAMERA_CONFIG.attributeName;
|
|
100
|
+
size = snapshotConfig.size || DEFAULT_CAMERA_CONFIG.size;
|
|
101
|
+
format = snapshotConfig.format || DEFAULT_CAMERA_CONFIG.format;
|
|
102
|
+
if (!(snapshotConfig === null || snapshotConfig === void 0 ? void 0 : snapshotConfig.useStage)) return [3, 2];
|
|
103
|
+
return [4, window.threekit.player.getStageConfigurator()];
|
|
104
|
+
case 1:
|
|
105
|
+
_a = _b.sent();
|
|
106
|
+
return [3, 3];
|
|
107
|
+
case 2:
|
|
108
|
+
_a = window.threekit.configurator;
|
|
109
|
+
_b.label = 3;
|
|
110
|
+
case 3:
|
|
111
|
+
configurator = _a;
|
|
112
|
+
camerasMap = getCamerasMap(configurator, attributeName);
|
|
113
|
+
if (!camerasMap)
|
|
114
|
+
return [2, Promise.resolve([])];
|
|
115
|
+
snapshots = [];
|
|
116
|
+
return [2, cameras.reduce(function (snapshotPromise, camera) {
|
|
117
|
+
return snapshotPromise.then(function () {
|
|
118
|
+
return new Promise(function (resolve) { return __awaiter(void 0, void 0, void 0, function () {
|
|
119
|
+
var snapshotStr;
|
|
120
|
+
var _a;
|
|
121
|
+
return __generator(this, function (_b) {
|
|
122
|
+
switch (_b.label) {
|
|
123
|
+
case 0:
|
|
124
|
+
if (!camera) return [3, 2];
|
|
125
|
+
return [4, configurator.setConfiguration((_a = {},
|
|
126
|
+
_a[attributeName] = camerasMap[camera],
|
|
127
|
+
_a))];
|
|
128
|
+
case 1:
|
|
129
|
+
_b.sent();
|
|
130
|
+
_b.label = 2;
|
|
131
|
+
case 2: return [4, getSnapshot({ size: size, format: format })];
|
|
132
|
+
case 3:
|
|
133
|
+
snapshotStr = _b.sent();
|
|
134
|
+
snapshots.push(snapshotStr);
|
|
135
|
+
resolve(snapshots);
|
|
136
|
+
return [2];
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}); });
|
|
140
|
+
});
|
|
141
|
+
}, Promise.resolve(snapshots))];
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}); };
|
|
145
|
+
var takeSnapshots = function (camerasList, snapshotsConfig) { return __awaiter(void 0, void 0, void 0, function () {
|
|
146
|
+
var filename, size, format, attributeName, output, configurator, _a, cameras, snapshotsRaw, snapshotData, camerasMap_1, currentCamera, cameraPosition, _b, attachments, response, urlsArray, snapshotBlobs, snapshotFiles;
|
|
147
|
+
var _c;
|
|
148
|
+
return __generator(this, function (_d) {
|
|
149
|
+
switch (_d.label) {
|
|
150
|
+
case 0:
|
|
151
|
+
filename = (snapshotsConfig === null || snapshotsConfig === void 0 ? void 0 : snapshotsConfig.filename) || DEFAULT_CAMERA_CONFIG.filename;
|
|
152
|
+
size = (snapshotsConfig === null || snapshotsConfig === void 0 ? void 0 : snapshotsConfig.size) || DEFAULT_CAMERA_CONFIG.size;
|
|
153
|
+
format = (snapshotsConfig === null || snapshotsConfig === void 0 ? void 0 : snapshotsConfig.format) || DEFAULT_CAMERA_CONFIG.format;
|
|
154
|
+
attributeName = (snapshotsConfig === null || snapshotsConfig === void 0 ? void 0 : snapshotsConfig.attributeName) || DEFAULT_CAMERA_CONFIG.attributeName;
|
|
155
|
+
output = (snapshotsConfig === null || snapshotsConfig === void 0 ? void 0 : snapshotsConfig.output) || DEFAULT_CAMERA_CONFIG.output;
|
|
156
|
+
if (!(snapshotsConfig === null || snapshotsConfig === void 0 ? void 0 : snapshotsConfig.useStage)) return [3, 2];
|
|
157
|
+
return [4, window.threekit.player.getStageConfigurator()];
|
|
158
|
+
case 1:
|
|
159
|
+
_a = _d.sent();
|
|
160
|
+
return [3, 3];
|
|
161
|
+
case 2:
|
|
162
|
+
_a = window.threekit.configurator;
|
|
163
|
+
_d.label = 3;
|
|
164
|
+
case 3:
|
|
165
|
+
configurator = _a;
|
|
166
|
+
cameras = Array.isArray(camerasList) ? camerasList : [camerasList];
|
|
167
|
+
if (!(cameras.length === 1 && cameras[0] === undefined)) return [3, 5];
|
|
168
|
+
return [4, getSnapshot({ size: size, format: format })];
|
|
169
|
+
case 4:
|
|
170
|
+
snapshotData = _d.sent();
|
|
171
|
+
snapshotsRaw = [snapshotData];
|
|
172
|
+
return [3, 8];
|
|
173
|
+
case 5:
|
|
174
|
+
camerasMap_1 = getCamerasMap(configurator, attributeName);
|
|
175
|
+
if (!camerasMap_1)
|
|
176
|
+
return [2, null];
|
|
177
|
+
cameras = cameras.filter(function (el) { return el === undefined || Object.keys(camerasMap_1).includes(el); });
|
|
178
|
+
currentCamera = getCameraValue(configurator, attributeName);
|
|
179
|
+
cameraPosition = (0, utils_1.getCameraPosition)(window.threekit.player.camera);
|
|
180
|
+
return [4, getSnapshots(cameras, snapshotsConfig)];
|
|
181
|
+
case 6:
|
|
182
|
+
snapshotsRaw = _d.sent();
|
|
183
|
+
return [4, configurator.setConfiguration((_c = {},
|
|
184
|
+
_c[attributeName] = currentCamera,
|
|
185
|
+
_c))];
|
|
186
|
+
case 7:
|
|
187
|
+
_d.sent();
|
|
188
|
+
(0, utils_1.setCameraPosition)(window.threekit.player.camera, cameraPosition);
|
|
189
|
+
_d.label = 8;
|
|
190
|
+
case 8:
|
|
191
|
+
_b = output;
|
|
192
|
+
switch (_b) {
|
|
193
|
+
case types_1.SNAPSHOT_OUTPUTS.URL: return [3, 9];
|
|
194
|
+
case types_1.SNAPSHOT_OUTPUTS.DOWNLOAD: return [3, 11];
|
|
195
|
+
case types_1.SNAPSHOT_OUTPUTS.BLOB: return [3, 12];
|
|
196
|
+
case types_1.SNAPSHOT_OUTPUTS.FILE: return [3, 13];
|
|
197
|
+
case types_1.SNAPSHOT_OUTPUTS.DATA_URL: return [3, 14];
|
|
198
|
+
}
|
|
199
|
+
return [3, 14];
|
|
200
|
+
case 9:
|
|
201
|
+
attachments = snapshotsRaw.reduce(function (output, el, idx) {
|
|
202
|
+
var _a;
|
|
203
|
+
var cameraName = (camerasList === null || camerasList === void 0 ? void 0 : camerasList[idx])
|
|
204
|
+
? (0, utils_1.regularToKebabCase)(camerasList[idx] || 'default')
|
|
205
|
+
: filename;
|
|
206
|
+
var preppedFilename = cameraName === filename
|
|
207
|
+
? "".concat(filename, ".").concat(format)
|
|
208
|
+
: "".concat(filename, "-").concat(cameraName, ".").concat(format);
|
|
209
|
+
var file = (0, utils_1.dataURItoFile)(el, preppedFilename);
|
|
210
|
+
return Object.assign(output, (_a = {}, _a[cameraName] = file, _a));
|
|
211
|
+
}, {});
|
|
212
|
+
return [4, api_1.default.configurations.save({
|
|
213
|
+
assetId: window.threekit.player.assetId,
|
|
214
|
+
configuration: window.threekit.configurator.getConfiguration(),
|
|
215
|
+
attachments: attachments,
|
|
216
|
+
})];
|
|
217
|
+
case 10:
|
|
218
|
+
response = _d.sent();
|
|
219
|
+
urlsArray = Object.values(response.data.attachments);
|
|
220
|
+
return [2, Promise.resolve(urlsArray)];
|
|
221
|
+
case 11:
|
|
222
|
+
snapshotsRaw.forEach(function (snapshotBlob, idx) {
|
|
223
|
+
var cameraName = (camerasList === null || camerasList === void 0 ? void 0 : camerasList[idx])
|
|
224
|
+
? "-".concat((0, utils_1.regularToKebabCase)(camerasList[idx] || 'default'))
|
|
225
|
+
: '';
|
|
226
|
+
(0, utils_1.downloadSnapshot)(snapshotBlob, "".concat(filename).concat(cameraName, ".").concat(format));
|
|
227
|
+
});
|
|
228
|
+
return [2, Promise.resolve()];
|
|
229
|
+
case 12:
|
|
230
|
+
snapshotBlobs = snapshotsRaw.map(function (el) { return (0, utils_1.dataURItoBlob)(el); });
|
|
231
|
+
return [2, Promise.resolve(snapshotBlobs)];
|
|
232
|
+
case 13:
|
|
233
|
+
snapshotFiles = snapshotsRaw.map(function (el, idx) {
|
|
234
|
+
var cameraName = (camerasList === null || camerasList === void 0 ? void 0 : camerasList[idx])
|
|
235
|
+
? "-".concat((0, utils_1.regularToKebabCase)(camerasList[idx] || 'default'))
|
|
236
|
+
: '';
|
|
237
|
+
return (0, utils_1.dataURItoFile)(el, "".concat(filename).concat(cameraName, ".").concat(format));
|
|
238
|
+
});
|
|
239
|
+
return [2, Promise.resolve(snapshotFiles)];
|
|
240
|
+
case 14: return [2, Promise.resolve(snapshotsRaw)];
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
}); };
|
|
244
|
+
exports.default = {
|
|
245
|
+
getSnapshot: getSnapshot,
|
|
246
|
+
takeSnapshots: takeSnapshots,
|
|
247
|
+
};
|
|
@@ -7,13 +7,9 @@ export interface IWishlist {
|
|
|
7
7
|
removeItemByIdx(idx: number): Array<IConfigurationResponse>;
|
|
8
8
|
clearWishlist(): Array<IConfigurationResponse>;
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
_wishlistKey: string;
|
|
12
|
-
constructor(orgId: string);
|
|
10
|
+
export default function createWishlist(orgId: string): {
|
|
13
11
|
getWishlist: () => Promise<WishlistArray>;
|
|
14
12
|
addItem: () => Promise<WishlistArray>;
|
|
15
13
|
removeItemByIdx: (idx: number) => WishlistArray;
|
|
16
14
|
clearWishlist: () => WishlistArray;
|
|
17
|
-
}
|
|
18
|
-
export default function createWishlist(orgId: string): Wishlist;
|
|
19
|
-
export {};
|
|
15
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
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 __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
39
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
40
|
+
if (ar || !(i in from)) {
|
|
41
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
42
|
+
ar[i] = from[i];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
|
+
};
|
|
47
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
48
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
|
+
};
|
|
50
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
+
var api_1 = __importDefault(require("../api"));
|
|
52
|
+
var constants_1 = require("../constants");
|
|
53
|
+
var wishlistData;
|
|
54
|
+
var wishlistKey;
|
|
55
|
+
var getWishlist = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
56
|
+
var wishlistListStr, wishlistList, wishlistDataRaw;
|
|
57
|
+
return __generator(this, function (_a) {
|
|
58
|
+
switch (_a.label) {
|
|
59
|
+
case 0:
|
|
60
|
+
if (wishlistData)
|
|
61
|
+
return [2, wishlistData];
|
|
62
|
+
wishlistListStr = localStorage.getItem(wishlistKey);
|
|
63
|
+
wishlistList = JSON.parse(wishlistListStr || '[]');
|
|
64
|
+
return [4, Promise.all(wishlistList.map(function (el) { return api_1.default.configurations.fetch(el); }))];
|
|
65
|
+
case 1:
|
|
66
|
+
wishlistDataRaw = _a.sent();
|
|
67
|
+
wishlistData = wishlistDataRaw.map(function (el) { return el.data; });
|
|
68
|
+
return [2, wishlistData];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}); };
|
|
72
|
+
var addItem = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
73
|
+
var thumbnails, savedConfiguration, wishlistListStr, wishlistList;
|
|
74
|
+
return __generator(this, function (_a) {
|
|
75
|
+
switch (_a.label) {
|
|
76
|
+
case 0:
|
|
77
|
+
if (!wishlistData) {
|
|
78
|
+
wishlistData = [];
|
|
79
|
+
localStorage.setItem(wishlistKey, JSON.stringify([]));
|
|
80
|
+
}
|
|
81
|
+
return [4, window.threekit.treble.takeSnapshots(undefined, {
|
|
82
|
+
output: 'file',
|
|
83
|
+
filename: 'thumbnail',
|
|
84
|
+
})];
|
|
85
|
+
case 1:
|
|
86
|
+
thumbnails = (_a.sent());
|
|
87
|
+
return [4, window.threekit.treble.saveConfiguration({
|
|
88
|
+
attachments: { thumbnail: thumbnails[0] },
|
|
89
|
+
})];
|
|
90
|
+
case 2:
|
|
91
|
+
savedConfiguration = _a.sent();
|
|
92
|
+
if (!savedConfiguration)
|
|
93
|
+
return [2, wishlistData];
|
|
94
|
+
wishlistData = __spreadArray(__spreadArray([], wishlistData, true), [savedConfiguration], false);
|
|
95
|
+
wishlistListStr = localStorage.getItem(wishlistKey);
|
|
96
|
+
wishlistList = JSON.parse(wishlistListStr || '[]');
|
|
97
|
+
wishlistList.push(savedConfiguration.shortId);
|
|
98
|
+
localStorage.setItem(wishlistKey, JSON.stringify(wishlistList));
|
|
99
|
+
return [2, getWishlist()];
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}); };
|
|
103
|
+
var removeItemByIdx = function (idx) {
|
|
104
|
+
if (!(wishlistData === null || wishlistData === void 0 ? void 0 : wishlistData.length)) {
|
|
105
|
+
wishlistData = [];
|
|
106
|
+
localStorage.setItem(wishlistKey, JSON.stringify([]));
|
|
107
|
+
return wishlistData;
|
|
108
|
+
}
|
|
109
|
+
if (idx > (wishlistData === null || wishlistData === void 0 ? void 0 : wishlistData.length) - 1)
|
|
110
|
+
return wishlistData;
|
|
111
|
+
var updatedWishlist = __spreadArray([], wishlistData, true);
|
|
112
|
+
updatedWishlist.splice(idx, 1);
|
|
113
|
+
wishlistData = updatedWishlist;
|
|
114
|
+
var wishlistListStr = localStorage.getItem(wishlistKey);
|
|
115
|
+
var wishlistList = JSON.parse(wishlistListStr || '[]');
|
|
116
|
+
wishlistList.splice(idx, 1);
|
|
117
|
+
localStorage.setItem(wishlistKey, JSON.stringify(wishlistList));
|
|
118
|
+
return wishlistData;
|
|
119
|
+
};
|
|
120
|
+
var clearWishlist = function () {
|
|
121
|
+
wishlistData = [];
|
|
122
|
+
localStorage.setItem(wishlistKey, JSON.stringify([]));
|
|
123
|
+
return wishlistData;
|
|
124
|
+
};
|
|
125
|
+
function createWishlist(orgId) {
|
|
126
|
+
wishlistKey = "".concat(constants_1.WISHLIST_LOCALSTORAGE_KEY, "_").concat(orgId);
|
|
127
|
+
getWishlist();
|
|
128
|
+
return {
|
|
129
|
+
getWishlist: getWishlist,
|
|
130
|
+
addItem: addItem,
|
|
131
|
+
removeItemByIdx: removeItemByIdx,
|
|
132
|
+
clearWishlist: clearWishlist,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
exports.default = createWishlist;
|
package/dist/api/catalog.js
CHANGED
|
@@ -52,20 +52,20 @@ var uploadAsset = function (file) { return __awaiter(void 0, void 0, void 0, fun
|
|
|
52
52
|
throw new Error(error);
|
|
53
53
|
formData = new FormData();
|
|
54
54
|
formData.append('files', file, file.name);
|
|
55
|
-
return [4
|
|
55
|
+
return [4, http_1.default.catalog.uploadAsset(formData)];
|
|
56
56
|
case 1:
|
|
57
57
|
uploadResponse = _a.sent();
|
|
58
58
|
jobId = uploadResponse.data[0].jobId;
|
|
59
59
|
count = 30;
|
|
60
60
|
_a.label = 2;
|
|
61
61
|
case 2:
|
|
62
|
-
if (!(count > 1 && !assetId)) return [3
|
|
63
|
-
return [4
|
|
62
|
+
if (!(count > 1 && !assetId)) return [3, 5];
|
|
63
|
+
return [4, new Promise(function (resolve) {
|
|
64
64
|
return setTimeout(function () { return resolve(undefined); }, 0.5 * 1000);
|
|
65
65
|
})];
|
|
66
66
|
case 3:
|
|
67
67
|
_a.sent();
|
|
68
|
-
return [4
|
|
68
|
+
return [4, http_1.default.catalog.getJobStatus(jobId)];
|
|
69
69
|
case 4:
|
|
70
70
|
checkRes = _a.sent();
|
|
71
71
|
++count;
|
|
@@ -78,8 +78,8 @@ var uploadAsset = function (file) { return __awaiter(void 0, void 0, void 0, fun
|
|
|
78
78
|
assetId = output.vector[0].assetId;
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
-
return [3
|
|
82
|
-
case 5: return [2
|
|
81
|
+
return [3, 2];
|
|
82
|
+
case 5: return [2, assetId];
|
|
83
83
|
}
|
|
84
84
|
});
|
|
85
85
|
}); };
|
|
@@ -71,7 +71,7 @@ var save = function (saveConfig) { return __awaiter(void 0, void 0, void 0, func
|
|
|
71
71
|
});
|
|
72
72
|
fd.append('attachments', JSON.stringify(attachmentsPrepped_1));
|
|
73
73
|
}
|
|
74
|
-
return [2
|
|
74
|
+
return [2, http_1.default.configurations.postConfiguration(fd)];
|
|
75
75
|
});
|
|
76
76
|
}); };
|
|
77
77
|
exports.save = save;
|
|
@@ -89,11 +89,11 @@ var fetchAll = function () {
|
|
|
89
89
|
var configurations;
|
|
90
90
|
return __generator(this, function (_a) {
|
|
91
91
|
switch (_a.label) {
|
|
92
|
-
case 0: return [4
|
|
92
|
+
case 0: return [4, http_1.default.configurations.getConfigurations()];
|
|
93
93
|
case 1:
|
|
94
94
|
configurations = _a.sent();
|
|
95
95
|
resolve(configurations.data.configurations);
|
|
96
|
-
return [2
|
|
96
|
+
return [2];
|
|
97
97
|
}
|
|
98
98
|
});
|
|
99
99
|
}); });
|
package/dist/api/datatables.js
CHANGED
|
@@ -51,15 +51,15 @@ var getDatatable = function (datatableId, config) { return __awaiter(void 0, voi
|
|
|
51
51
|
if (!datatableId)
|
|
52
52
|
message = 'Requires a datatable ID';
|
|
53
53
|
if (message)
|
|
54
|
-
return [2
|
|
54
|
+
return [2, Promise.resolve(undefined)];
|
|
55
55
|
format = Object.assign({ format: constants_1.DATATABLE_FORMATS.json }, config).format;
|
|
56
|
-
return [4
|
|
56
|
+
return [4, http_1.default.datatables.getDatatable(datatableId)];
|
|
57
57
|
case 1:
|
|
58
58
|
response = _a.sent();
|
|
59
59
|
if (response.status !== 200)
|
|
60
|
-
return [2
|
|
60
|
+
return [2, Promise.resolve(undefined)];
|
|
61
61
|
if (format.toLowerCase() === constants_1.DATATABLE_FORMATS.csv)
|
|
62
|
-
return [2
|
|
62
|
+
return [2, Promise.resolve(response.data)];
|
|
63
63
|
csvData = response.data
|
|
64
64
|
.replace(/"/g, '')
|
|
65
65
|
.split('\n')
|
|
@@ -81,7 +81,7 @@ var getDatatable = function (datatableId, config) { return __awaiter(void 0, voi
|
|
|
81
81
|
output.push(rowOutput);
|
|
82
82
|
return output;
|
|
83
83
|
}, []);
|
|
84
|
-
return [2
|
|
84
|
+
return [2, Promise.resolve(datatableJson)];
|
|
85
85
|
}
|
|
86
86
|
});
|
|
87
87
|
}); };
|