@threedddplus/logoeditor 0.0.123 → 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.
@@ -1824,6 +1824,9 @@ var toastMessages =
1824
1824
  },
1825
1825
  noIteminCanvas: function noIteminCanvas() {
1826
1826
  return CustomToast('warning', 'No item in canvas to save', 10);
1827
+ },
1828
+ fileSize: function fileSize() {
1829
+ return CustomToast('warning', 'We cannot process this file because it is larger than 25MB. Please decrease the size and try again.', 11);
1827
1830
  }
1828
1831
  };
1829
1832
 
@@ -2178,6 +2181,59 @@ var lambdaSlice = function lambdaSlice(_set, _get) {
2178
2181
  return _saveLogo.apply(this, arguments);
2179
2182
  }
2180
2183
  return saveLogo;
2184
+ }(),
2185
+ vectorize: function () {
2186
+ var _vectorize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(data) {
2187
+ var formData, config, response;
2188
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
2189
+ while (1) switch (_context4.prev = _context4.next) {
2190
+ case 0:
2191
+ formData = new FormData();
2192
+ formData.append('image', data);
2193
+ console.log(data, formData);
2194
+ config = {
2195
+ headers: {
2196
+ 'Content-Type': 'multipart/form-data'
2197
+ }
2198
+ };
2199
+ _context4.prev = 4;
2200
+ use3dddPlus.setState({
2201
+ loading: true
2202
+ });
2203
+ if (requests) {
2204
+ _context4.next = 8;
2205
+ break;
2206
+ }
2207
+ throw new Error('lambdaClient Not Found');
2208
+ case 8:
2209
+ _context4.next = 10;
2210
+ return requests.post('/image-vectorizer', {
2211
+ 'image': data
2212
+ }, config);
2213
+ case 10:
2214
+ response = _context4.sent;
2215
+ use3dddPlus.setState({
2216
+ loading: false
2217
+ });
2218
+ return _context4.abrupt("return", response);
2219
+ case 15:
2220
+ _context4.prev = 15;
2221
+ _context4.t0 = _context4["catch"](4);
2222
+ console.error(_context4.t0);
2223
+ use3dddPlus.setState({
2224
+ loading: false
2225
+ });
2226
+ throw new Error(_context4.t0);
2227
+ case 20:
2228
+ case "end":
2229
+ return _context4.stop();
2230
+ }
2231
+ }, _callee4, null, [[4, 15]]);
2232
+ }));
2233
+ function vectorize(_x3) {
2234
+ return _vectorize.apply(this, arguments);
2235
+ }
2236
+ return vectorize;
2181
2237
  }()
2182
2238
  };
2183
2239
  };
@@ -6685,7 +6741,6 @@ var PopUpCanvas = function PopUpCanvas() {
6685
6741
  if (document.getElementById('imageCanvas')) {
6686
6742
  var _canvas = use3dddPlus.getState().popupCanv;
6687
6743
  var outerCanvasContainer = document.getElementById('imageCanvas');
6688
- console.log(outerCanvasContainer);
6689
6744
  var containerWidth = outerCanvasContainer.clientWidth;
6690
6745
  var scale = containerWidth / _canvas.getWidth();
6691
6746
  var zoom = _canvas.getZoom() * scale;
@@ -6876,20 +6931,6 @@ var PopUpCanvas = function PopUpCanvas() {
6876
6931
  return '';
6877
6932
  }
6878
6933
  };
6879
- /*
6880
- const resetHandler = () => {
6881
- console.log(use3dddPlus.getState().forPopupCanvasReset);
6882
- popupCanvas.clear();
6883
- popupCanvas.loadFromJSON(
6884
- use3dddPlus.getState().forPopupCanvasReset,
6885
- function () {
6886
- use3dddPlus.setState({
6887
- colorFill: { ...use3dddPlus.getState().forPopupCanvasColor },
6888
- });
6889
- popupCanvas.renderAll();
6890
- }
6891
- );
6892
- };*/
6893
6934
  var resetHandler = function resetHandler() {
6894
6935
  use3dddPlus.getState().popUpCanvasUpdateModification(true);
6895
6936
  var colors = use3dddPlus.getState().popupCanvasStoreHistory[0].colorFill;
@@ -7326,22 +7367,32 @@ var PopUpCanvas = function PopUpCanvas() {
7326
7367
  }));
7327
7368
  };
7328
7369
 
7329
- // import axios from 'axios';
7370
+ // import axios, { AxiosRequestConfig } from 'axios';
7330
7371
  var UploadLogo = function UploadLogo() {
7331
7372
  var _useState = React.useState(null),
7332
7373
  setSelectedFile = _useState[1];
7333
7374
  var _use3dddPlus = use3dddPlus(function (state) {
7334
7375
  return [state.tiffConvert, state.imageToSVG, state.setFile, state.uploadImageModalDisplay,
7335
7376
  // state.pdfConverter,
7336
- state.aiConvert];
7377
+ state.aiConvert,
7378
+ // state.loadImageFromURL,
7379
+ state.vectorize];
7337
7380
  }, shallow.shallow),
7338
7381
  tiffConvert = _use3dddPlus[0],
7339
7382
  imageToSVG = _use3dddPlus[1],
7340
7383
  setFile = _use3dddPlus[2],
7341
7384
  uploadImageModalDisplay = _use3dddPlus[3],
7342
7385
  // pdfConverter,
7343
- aiConvert = _use3dddPlus[4];
7386
+ aiConvert = _use3dddPlus[4],
7387
+ vectorize = _use3dddPlus[5];
7344
7388
  var handleFileSelect = function handleFileSelect(file) {
7389
+ var fileSize = file.size;
7390
+ var fileSizeInKB = fileSize / 1024;
7391
+ var fileSizeInMB = fileSizeInKB / 1024;
7392
+ if (fileSizeInMB > 24) {
7393
+ use3dddPlus.getState().toastMessages.fileSize();
7394
+ return;
7395
+ }
7345
7396
  setSelectedFile(file);
7346
7397
  setFile(file);
7347
7398
  svgConverter(file);
@@ -7350,7 +7401,7 @@ var UploadLogo = function UploadLogo() {
7350
7401
 
7351
7402
  var svgConverter = /*#__PURE__*/function () {
7352
7403
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(data) {
7353
- var ext, tiffData, aiToSvg, formData, response, blob, imageUrl;
7404
+ var ext, tiffData, aiToSvg, vectorizeImage;
7354
7405
  return _regeneratorRuntime().wrap(function _callee$(_context) {
7355
7406
  while (1) switch (_context.prev = _context.next) {
7356
7407
  case 0:
@@ -7364,7 +7415,7 @@ var UploadLogo = function UploadLogo() {
7364
7415
  break;
7365
7416
  }
7366
7417
  imageToSVG(data, ext, true);
7367
- _context.next = 36;
7418
+ _context.next = 28;
7368
7419
  break;
7369
7420
  case 6:
7370
7421
  if (!(ext === 'tif' || ext === 'tiff')) {
@@ -7376,11 +7427,11 @@ var UploadLogo = function UploadLogo() {
7376
7427
  case 9:
7377
7428
  tiffData = _context.sent;
7378
7429
  imageToSVG(tiffData, ext);
7379
- _context.next = 36;
7430
+ _context.next = 28;
7380
7431
  break;
7381
7432
  case 13:
7382
7433
  if (!(ext === 'ai' || ext === 'pdf')) {
7383
- _context.next = 21;
7434
+ _context.next = 22;
7384
7435
  break;
7385
7436
  }
7386
7437
  use3dddPlus.setState({
@@ -7390,6 +7441,7 @@ var UploadLogo = function UploadLogo() {
7390
7441
  return aiConvert(data);
7391
7442
  case 17:
7392
7443
  aiToSvg = _context.sent;
7444
+ console.log(aiToSvg);
7393
7445
  fetch(aiToSvg.s3_file_url + '?timestamp=' + Date.now()).then(function (response) {
7394
7446
  return response.text();
7395
7447
  }).then(function (svgText) {
@@ -7400,51 +7452,33 @@ var UploadLogo = function UploadLogo() {
7400
7452
  loading: false
7401
7453
  });
7402
7454
  });
7403
- _context.next = 36;
7455
+ _context.next = 28;
7404
7456
  break;
7405
- case 21:
7406
- formData = new FormData();
7407
- formData.append('image', data);
7408
- /* axios({
7409
- url: "https://vectorizer.ai/api/v1/vectorize",
7410
- method: "POST",
7411
- headers :{
7412
- user: 'vks34swmmj4s8wg',
7413
- pass: 'f9ivolvk1mc5khc7ja53bp2rst5d4cuk5q02oqfoj3mn1ag3sig2',
7414
- },
7415
- data: formData,
7416
- })
7417
- .then((res) => {console.log(res);})
7418
- .catch((err) => {console.log(err)});*/
7419
- _context.next = 25;
7420
- return fetch('https://imagesharpher-f4b4o225iq-ue.a.run.app/upload', {
7421
- method: 'POST',
7422
- /*headers :{
7423
- user: 'vks34swmmj4s8wg',
7424
- pass: 'f9ivolvk1mc5khc7ja53bp2rst5d4cuk5q02oqfoj3mn1ag3sig2',
7425
- },*/
7426
- body: formData
7457
+ case 22:
7458
+ use3dddPlus.setState({
7459
+ loading: true
7427
7460
  });
7461
+ _context.next = 25;
7462
+ return vectorize(data);
7428
7463
  case 25:
7429
- response = _context.sent;
7430
- if (!response.ok) {
7431
- _context.next = 35;
7432
- break;
7433
- }
7434
- console.log(response);
7435
- _context.next = 30;
7436
- return response.blob();
7437
- case 30:
7438
- blob = _context.sent;
7439
- imageUrl = URL.createObjectURL(blob);
7440
- imageToSVG(imageUrl, ext);
7441
- _context.next = 36;
7442
- break;
7443
- case 35:
7444
- alert('Failed to process the image');
7445
- case 36:
7464
+ vectorizeImage = _context.sent;
7465
+ console.log(vectorizeImage.svg_url);
7466
+ fetch(vectorizeImage.svg_url).then(function (response) {
7467
+ return response.text();
7468
+ }).then(function (svgText) {
7469
+ imageToSVG(svgText, 'svg', false, false);
7470
+ use3dddPlus.setState({
7471
+ loading: false
7472
+ });
7473
+ })["catch"](function (ex) {
7474
+ console.log(ex);
7475
+ use3dddPlus.setState({
7476
+ loading: false
7477
+ });
7478
+ });
7479
+ case 28:
7446
7480
  setSelectedFile(null);
7447
- case 37:
7481
+ case 29:
7448
7482
  case "end":
7449
7483
  return _context.stop();
7450
7484
  }
@@ -14332,6 +14366,7 @@ var SaveDesign = function SaveDesign(_ref) {
14332
14366
  return _context.abrupt("return");
14333
14367
  case 3:
14334
14368
  setIsSaving(true);
14369
+ canvas.backgroundColor = null;
14335
14370
  canvasGetobject = canvas.getObjects();
14336
14371
  canvasGetobject.forEach(function (obj) {
14337
14372
  if (obj.type === 'line') {
@@ -14377,11 +14412,10 @@ var SaveDesign = function SaveDesign(_ref) {
14377
14412
  }
14378
14413
  }
14379
14414
  dataCh = JSON.stringify(canvasData);
14380
- _context.next = 15;
14415
+ _context.next = 16;
14381
14416
  return uploadLogoConfig(dataCh, use3dddPlus.getState().customerId);
14382
- case 15:
14417
+ case 16:
14383
14418
  S3UrlPath = _context.sent;
14384
- canvas.backgroundColor = null;
14385
14419
  canvasSvg = canvas.toSVG();
14386
14420
  closeModal('', false, '', {});
14387
14421
  raw = JSON.stringify({