@threedddplus/logoeditor 0.0.122 → 0.0.124

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.
@@ -1815,6 +1815,9 @@ var toastMessages =
1815
1815
  },
1816
1816
  noIteminCanvas: function noIteminCanvas() {
1817
1817
  return CustomToast('warning', 'No item in canvas to save', 10);
1818
+ },
1819
+ fileSize: function fileSize() {
1820
+ return CustomToast('warning', 'We cannot process this file because it is larger than 25MB. Please decrease the size and try again.', 11);
1818
1821
  }
1819
1822
  };
1820
1823
 
@@ -2169,6 +2172,59 @@ var lambdaSlice = function lambdaSlice(_set, _get) {
2169
2172
  return _saveLogo.apply(this, arguments);
2170
2173
  }
2171
2174
  return saveLogo;
2175
+ }(),
2176
+ vectorize: function () {
2177
+ var _vectorize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(data) {
2178
+ var formData, config, response;
2179
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
2180
+ while (1) switch (_context4.prev = _context4.next) {
2181
+ case 0:
2182
+ formData = new FormData();
2183
+ formData.append('image', data);
2184
+ console.log(data, formData);
2185
+ config = {
2186
+ headers: {
2187
+ 'Content-Type': 'multipart/form-data'
2188
+ }
2189
+ };
2190
+ _context4.prev = 4;
2191
+ use3dddPlus.setState({
2192
+ loading: true
2193
+ });
2194
+ if (requests) {
2195
+ _context4.next = 8;
2196
+ break;
2197
+ }
2198
+ throw new Error('lambdaClient Not Found');
2199
+ case 8:
2200
+ _context4.next = 10;
2201
+ return requests.post('/image-vectorizer', {
2202
+ 'image': data
2203
+ }, config);
2204
+ case 10:
2205
+ response = _context4.sent;
2206
+ use3dddPlus.setState({
2207
+ loading: false
2208
+ });
2209
+ return _context4.abrupt("return", response);
2210
+ case 15:
2211
+ _context4.prev = 15;
2212
+ _context4.t0 = _context4["catch"](4);
2213
+ console.error(_context4.t0);
2214
+ use3dddPlus.setState({
2215
+ loading: false
2216
+ });
2217
+ throw new Error(_context4.t0);
2218
+ case 20:
2219
+ case "end":
2220
+ return _context4.stop();
2221
+ }
2222
+ }, _callee4, null, [[4, 15]]);
2223
+ }));
2224
+ function vectorize(_x3) {
2225
+ return _vectorize.apply(this, arguments);
2226
+ }
2227
+ return vectorize;
2172
2228
  }()
2173
2229
  };
2174
2230
  };
@@ -6676,7 +6732,6 @@ var PopUpCanvas = function PopUpCanvas() {
6676
6732
  if (document.getElementById('imageCanvas')) {
6677
6733
  var _canvas = use3dddPlus.getState().popupCanv;
6678
6734
  var outerCanvasContainer = document.getElementById('imageCanvas');
6679
- console.log(outerCanvasContainer);
6680
6735
  var containerWidth = outerCanvasContainer.clientWidth;
6681
6736
  var scale = containerWidth / _canvas.getWidth();
6682
6737
  var zoom = _canvas.getZoom() * scale;
@@ -6867,20 +6922,6 @@ var PopUpCanvas = function PopUpCanvas() {
6867
6922
  return '';
6868
6923
  }
6869
6924
  };
6870
- /*
6871
- const resetHandler = () => {
6872
- console.log(use3dddPlus.getState().forPopupCanvasReset);
6873
- popupCanvas.clear();
6874
- popupCanvas.loadFromJSON(
6875
- use3dddPlus.getState().forPopupCanvasReset,
6876
- function () {
6877
- use3dddPlus.setState({
6878
- colorFill: { ...use3dddPlus.getState().forPopupCanvasColor },
6879
- });
6880
- popupCanvas.renderAll();
6881
- }
6882
- );
6883
- };*/
6884
6925
  var resetHandler = function resetHandler() {
6885
6926
  use3dddPlus.getState().popUpCanvasUpdateModification(true);
6886
6927
  var colors = use3dddPlus.getState().popupCanvasStoreHistory[0].colorFill;
@@ -7317,22 +7358,32 @@ var PopUpCanvas = function PopUpCanvas() {
7317
7358
  }));
7318
7359
  };
7319
7360
 
7320
- // import axios from 'axios';
7361
+ // import axios, { AxiosRequestConfig } from 'axios';
7321
7362
  var UploadLogo = function UploadLogo() {
7322
7363
  var _useState = useState(null),
7323
7364
  setSelectedFile = _useState[1];
7324
7365
  var _use3dddPlus = use3dddPlus(function (state) {
7325
7366
  return [state.tiffConvert, state.imageToSVG, state.setFile, state.uploadImageModalDisplay,
7326
7367
  // state.pdfConverter,
7327
- state.aiConvert];
7368
+ state.aiConvert,
7369
+ // state.loadImageFromURL,
7370
+ state.vectorize];
7328
7371
  }, shallow),
7329
7372
  tiffConvert = _use3dddPlus[0],
7330
7373
  imageToSVG = _use3dddPlus[1],
7331
7374
  setFile = _use3dddPlus[2],
7332
7375
  uploadImageModalDisplay = _use3dddPlus[3],
7333
7376
  // pdfConverter,
7334
- aiConvert = _use3dddPlus[4];
7377
+ aiConvert = _use3dddPlus[4],
7378
+ vectorize = _use3dddPlus[5];
7335
7379
  var handleFileSelect = function handleFileSelect(file) {
7380
+ var fileSize = file.size;
7381
+ var fileSizeInKB = fileSize / 1024;
7382
+ var fileSizeInMB = fileSizeInKB / 1024;
7383
+ if (fileSizeInMB > 24) {
7384
+ use3dddPlus.getState().toastMessages.fileSize();
7385
+ return;
7386
+ }
7336
7387
  setSelectedFile(file);
7337
7388
  setFile(file);
7338
7389
  svgConverter(file);
@@ -7341,7 +7392,7 @@ var UploadLogo = function UploadLogo() {
7341
7392
 
7342
7393
  var svgConverter = /*#__PURE__*/function () {
7343
7394
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(data) {
7344
- var ext, tiffData, aiToSvg, formData, response;
7395
+ var ext, tiffData, aiToSvg, vectorizeImage;
7345
7396
  return _regeneratorRuntime().wrap(function _callee$(_context) {
7346
7397
  while (1) switch (_context.prev = _context.next) {
7347
7398
  case 0:
@@ -7355,7 +7406,7 @@ var UploadLogo = function UploadLogo() {
7355
7406
  break;
7356
7407
  }
7357
7408
  imageToSVG(data, ext, true);
7358
- _context.next = 27;
7409
+ _context.next = 28;
7359
7410
  break;
7360
7411
  case 6:
7361
7412
  if (!(ext === 'tif' || ext === 'tiff')) {
@@ -7367,11 +7418,11 @@ var UploadLogo = function UploadLogo() {
7367
7418
  case 9:
7368
7419
  tiffData = _context.sent;
7369
7420
  imageToSVG(tiffData, ext);
7370
- _context.next = 27;
7421
+ _context.next = 28;
7371
7422
  break;
7372
7423
  case 13:
7373
7424
  if (!(ext === 'ai' || ext === 'pdf')) {
7374
- _context.next = 21;
7425
+ _context.next = 22;
7375
7426
  break;
7376
7427
  }
7377
7428
  use3dddPlus.setState({
@@ -7381,6 +7432,7 @@ var UploadLogo = function UploadLogo() {
7381
7432
  return aiConvert(data);
7382
7433
  case 17:
7383
7434
  aiToSvg = _context.sent;
7435
+ console.log(aiToSvg);
7384
7436
  fetch(aiToSvg.s3_file_url + '?timestamp=' + Date.now()).then(function (response) {
7385
7437
  return response.text();
7386
7438
  }).then(function (svgText) {
@@ -7391,44 +7443,33 @@ var UploadLogo = function UploadLogo() {
7391
7443
  loading: false
7392
7444
  });
7393
7445
  });
7394
- _context.next = 27;
7446
+ _context.next = 28;
7395
7447
  break;
7396
- case 21:
7397
- formData = new FormData();
7398
- formData.append('image', data);
7399
- /* axios({
7400
- url: "https://vectorizer.ai/api/v1/vectorize",
7401
- method: "POST",
7402
- headers :{
7403
- user: 'vks34swmmj4s8wg',
7404
- pass: 'f9ivolvk1mc5khc7ja53bp2rst5d4cuk5q02oqfoj3mn1ag3sig2',
7405
- },
7406
- data: formData,
7407
- })
7408
- .then((res) => {console.log(res);})
7409
- .catch((err) => {console.log(err)});*/
7410
- _context.next = 25;
7411
- return fetch('https://vectorizer.ai/api/v1/vectorize', {
7412
- method: 'POST',
7413
- headers: {
7414
- user: 'vks34swmmj4s8wg',
7415
- pass: 'f9ivolvk1mc5khc7ja53bp2rst5d4cuk5q02oqfoj3mn1ag3sig2'
7416
- },
7417
- body: formData
7448
+ case 22:
7449
+ use3dddPlus.setState({
7450
+ loading: true
7418
7451
  });
7452
+ _context.next = 25;
7453
+ return vectorize(data);
7419
7454
  case 25:
7420
- response = _context.sent;
7421
- if (response.ok) {
7422
- console.log(response);
7423
- // const blob = await response.blob();
7424
- // const imageUrl = URL.createObjectURL(blob);
7425
- // imageToSVG(imageUrl, ext);
7426
- } else {
7427
- alert('Failed to process the image');
7428
- }
7429
- case 27:
7430
- setSelectedFile(null);
7455
+ vectorizeImage = _context.sent;
7456
+ console.log(vectorizeImage.svg_url);
7457
+ fetch(vectorizeImage.svg_url).then(function (response) {
7458
+ return response.text();
7459
+ }).then(function (svgText) {
7460
+ imageToSVG(svgText, 'svg', false, false);
7461
+ use3dddPlus.setState({
7462
+ loading: false
7463
+ });
7464
+ })["catch"](function (ex) {
7465
+ console.log(ex);
7466
+ use3dddPlus.setState({
7467
+ loading: false
7468
+ });
7469
+ });
7431
7470
  case 28:
7471
+ setSelectedFile(null);
7472
+ case 29:
7432
7473
  case "end":
7433
7474
  return _context.stop();
7434
7475
  }
@@ -14316,6 +14357,7 @@ var SaveDesign = function SaveDesign(_ref) {
14316
14357
  return _context.abrupt("return");
14317
14358
  case 3:
14318
14359
  setIsSaving(true);
14360
+ canvas.backgroundColor = null;
14319
14361
  canvasGetobject = canvas.getObjects();
14320
14362
  canvasGetobject.forEach(function (obj) {
14321
14363
  if (obj.type === 'line') {
@@ -14361,11 +14403,10 @@ var SaveDesign = function SaveDesign(_ref) {
14361
14403
  }
14362
14404
  }
14363
14405
  dataCh = JSON.stringify(canvasData);
14364
- _context.next = 15;
14406
+ _context.next = 16;
14365
14407
  return uploadLogoConfig(dataCh, use3dddPlus.getState().customerId);
14366
- case 15:
14408
+ case 16:
14367
14409
  S3UrlPath = _context.sent;
14368
- canvas.backgroundColor = null;
14369
14410
  canvasSvg = canvas.toSVG();
14370
14411
  closeModal('', false, '', {});
14371
14412
  raw = JSON.stringify({