@configuratorware/configurator-frontendgui 1.51.0 → 1.51.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.
@@ -44,7 +44,7 @@ var getGalleryImages = (0, _createSelector["default"])(function (imageGallerySta
44
44
  var host = (0, _configuration.getConf)('network.host');
45
45
  return images.map(function (image) {
46
46
  return _objectSpread(_objectSpread({}, image), {}, {
47
- url: "".concat(host).concat(image.thumbUrl)
47
+ url: image.thumbUrl.startsWith('http') ? image.thumbUrl : "".concat(host).concat(image.thumbUrl)
48
48
  });
49
49
  });
50
50
  });
@@ -121,32 +121,33 @@ var ImageEditDialogContainer = exports.ImageEditDialogContainer = /*#__PURE__*/f
121
121
  });
122
122
  _defineProperty(_assertThisInitialized(_this), "lastImageUpdateData", null);
123
123
  _defineProperty(_assertThisInitialized(_this), "updateOriginalPreview", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
124
- var image, previewUrl, isSvg, svgContent, preview;
124
+ var image, url, previewUrl, isSvg, svgContent, preview;
125
125
  return _regeneratorRuntime().wrap(function _callee$(_context) {
126
126
  while (1) switch (_context.prev = _context.next) {
127
127
  case 0:
128
128
  image = _this.props.image;
129
- previewUrl = "".concat((0, _configuration.getConf)('network.host')).concat(image.preview.url);
129
+ url = (0, _get["default"])(image, 'preview.url', '');
130
+ previewUrl = url.startsWith('http') ? url : "".concat((0, _configuration.getConf)('network.host')).concat(url);
130
131
  isSvg = previewUrl && /\.svg$/.test(previewUrl);
131
132
  if (!isSvg) {
132
- _context.next = 11;
133
+ _context.next = 12;
133
134
  break;
134
135
  }
135
- _context.next = 6;
136
+ _context.next = 7;
136
137
  return (0, _DesignDataService.getSvgContent)(previewUrl, true);
137
- case 6:
138
+ case 7:
138
139
  svgContent = _context.sent;
139
140
  preview = (0, _DesignDataService.applySvgContentOperations)(image.preview, null, svgContent);
140
141
  _this.setState({
141
142
  originalImagePreview: preview
142
143
  });
143
- _context.next = 12;
144
+ _context.next = 13;
144
145
  break;
145
- case 11:
146
+ case 12:
146
147
  _this.setState({
147
148
  originalImagePreview: previewUrl
148
149
  });
149
- case 12:
150
+ case 13:
150
151
  case "end":
151
152
  return _context.stop();
152
153
  }
@@ -425,7 +426,7 @@ var ImageEditDialogContainer = exports.ImageEditDialogContainer = /*#__PURE__*/f
425
426
  break;
426
427
  }
427
428
  _context6.next = 13;
428
- return (0, _DesignDataService.getSvgContent)(image.preview.url, false, forceFetch);
429
+ return (0, _DesignDataService.getSvgContent)(image.preview.url, image.preview.url.startsWith('http'), forceFetch);
429
430
  case 13:
430
431
  svgContent = _context6.sent;
431
432
  case 14:
@@ -876,7 +877,7 @@ var getUserImages = (0, _createSelector["default"])(function (imageGalleryState)
876
877
  });
877
878
  return userImages.map(function (image) {
878
879
  return _objectSpread(_objectSpread({}, image), {}, {
879
- url: "".concat(host).concat(image.thumbnail.url)
880
+ url: image.thumbnail.url.startsWith('http') ? image.thumbnail.url : "".concat(host).concat(image.thumbnail.url)
880
881
  });
881
882
  });
882
883
  });
@@ -23,7 +23,7 @@ var getPreviewUrlFromImageData = exports.getPreviewUrlFromImageData = function g
23
23
  }
24
24
  var _options$host = options.host,
25
25
  host = _options$host === void 0 ? (0, _configuration.getConf)('network.host', '') : _options$host;
26
- return "".concat(host).concat(previewUrl);
26
+ return previewUrl.startsWith('http') ? previewUrl : "".concat(host).concat(previewUrl);
27
27
  };
28
28
  var isEditableVectorImage = exports.isEditableVectorImage = function isEditableVectorImage(preview) {
29
29
  return preview && preview.url && (/.svg$/.test(preview.url) || /^data:image\/svg\+xml/.test(preview.url));
@@ -70,7 +70,7 @@ var prepareImageData = function createImageDataPreProcessor() {
70
70
  break;
71
71
  }
72
72
  _context.next = 11;
73
- return (0, _DesignDataService.getSvgContent)(imageData.preview.url, false, true);
73
+ return (0, _DesignDataService.getSvgContent)(imageData.preview.url, imageData.preview.url.startsWith('http'), true);
74
74
  case 11:
75
75
  svgContent = _context.sent;
76
76
  svgColors = (0, _DesignDataService.getSvgColors)(svgContent, designProductionMethod);
@@ -153,7 +153,11 @@ var calculateImageBrightness = exports.calculateImageBrightness = function calcu
153
153
  if (!image) {
154
154
  return;
155
155
  }
156
- var imageUrl = image.data && image.data.thumbnail ? "".concat((0, _configuration.getConf)('network.host')).concat(image.data.thumbnail.url) : null;
156
+ var thumbnail = (0, _get2["default"])(image, 'data.thumbnail.url', null);
157
+ var imageUrl = null;
158
+ if (thumbnail) {
159
+ imageUrl = thumbnail.startsWith('http') ? thumbnail : "".concat((0, _configuration.getConf)('network.host')).concat(thumbnail);
160
+ }
157
161
  var fuzzy = 0.1;
158
162
  return new Promise(function (resolve, reject) {
159
163
  var downloadedImg = new Image(200, 200);
@@ -2457,7 +2461,7 @@ var DesignDataService = exports["default"] = /*#__PURE__*/function () {
2457
2461
  while (1) switch (_context33.prev = _context33.next) {
2458
2462
  case 0:
2459
2463
  _context33.next = 2;
2460
- return getSvgContent(url);
2464
+ return getSvgContent(url, url.startsWith('http'));
2461
2465
  case 2:
2462
2466
  svgContent = _context33.sent;
2463
2467
  designProductionMethod = (0, _Selectors.getSelectedDesignProductionMethod)(_ServiceLocator.Services.store.state);
@@ -2483,7 +2487,7 @@ var DesignDataService = exports["default"] = /*#__PURE__*/function () {
2483
2487
  while (1) switch (_context34.prev = _context34.next) {
2484
2488
  case 0:
2485
2489
  _context34.next = 2;
2486
- return getSvgContent(url);
2490
+ return getSvgContent(url, url.startsWith('http'));
2487
2491
  case 2:
2488
2492
  svgContent = _context34.sent;
2489
2493
  svgTag = (_svgContent$match = svgContent.match(/<svg[^>]+>/)) === null || _svgContent$match === void 0 ? void 0 : _svgContent$match[0];
@@ -2688,7 +2692,7 @@ var DesignDataService = exports["default"] = /*#__PURE__*/function () {
2688
2692
  }
2689
2693
  _designProductionMethod = (0, _Selectors.getSelectedDesignProductionMethod)(_ServiceLocator.Services.store.state);
2690
2694
  _context36.next = 35;
2691
- return getSvgContent(preview.url, false, !operationsMatching);
2695
+ return getSvgContent(preview.url, preview.url.startsWith('http'), !operationsMatching);
2692
2696
  case 35:
2693
2697
  svgContent = _context36.sent;
2694
2698
  svgColors = getSvgColors(svgContent, _designProductionMethod);
@@ -40,9 +40,10 @@ function getCanvasImageScalingWithImageData(canvasImage, imageData) {
40
40
  return canvasImage.scaling * (currentPreview.width / nextPreview.width);
41
41
  }
42
42
  function updateCanvasImageWithImageData(canvasImage, imageData) {
43
+ var _imageData$preview$ur;
43
44
  return canvasImage.updateOptions((0, _Transformers.prepareImageObjectData)({
44
45
  imageData: imageData,
45
- src: "".concat((0, _configuration.getConf)('network.host')).concat(imageData.preview.url),
46
+ src: (_imageData$preview$ur = imageData.preview.url) !== null && _imageData$preview$ur !== void 0 && _imageData$preview$ur.startsWith('http') ? imageData.preview.url : "".concat((0, _configuration.getConf)('network.host')).concat(imageData.preview.url),
46
47
  scaling: getCanvasImageScalingWithImageData(canvasImage, imageData)
47
48
  }));
48
49
  }
@@ -259,7 +260,7 @@ var DesignerService = exports["default"] = /*#__PURE__*/function () {
259
260
  throw new Error('Preview image url is not specified!');
260
261
  case 10:
261
262
  _ServiceLocator.Services.store.dispatch((0, _Actions.updateUploadDelayed)(false));
262
- return _context5.abrupt("return", "".concat((0, _configuration.getConf)('network.host')).concat(url));
263
+ return _context5.abrupt("return", url.startsWith('http') ? url : "".concat((0, _configuration.getConf)('network.host')).concat(url));
263
264
  case 12:
264
265
  case "end":
265
266
  return _context5.stop();
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@configuratorware/configurator-frontendgui",
3
- "version": "1.51.0",
3
+ "version": "1.51.1",
4
4
  "license": "UNLICENSED",
5
5
  "private": false,
6
6
  "main": "./index.js",
7
7
  "dependencies": {
8
8
  "@babel/polyfill": "^7.12.1",
9
- "@configuratorware/scripts": "1.51.0",
9
+ "@configuratorware/scripts": "1.51.1",
10
10
  "@material-ui/core": "^4.12.4",
11
11
  "@material-ui/icons": "^4.11.3",
12
12
  "@material-ui/lab": "^4.0.0-alpha.61",
@@ -36,8 +36,8 @@
36
36
  "react-router-dom": "^5.3.4",
37
37
  "react-swipeable": "^5.5.1",
38
38
  "react-zoom-pan-pinch": "^2.1.3",
39
- "redhotmagma-graphics-editor": "1.51.0",
40
- "redhotmagma-visualization": "1.51.0",
39
+ "redhotmagma-graphics-editor": "1.51.1",
40
+ "redhotmagma-visualization": "1.51.1",
41
41
  "redux": "^4.1.0",
42
42
  "redux-logger": "^3.0.6",
43
43
  "redux-persist": "^5.10.0",
@@ -37,7 +37,7 @@ const getGalleryImages = createSelector(
37
37
  const host = getConf('network.host');
38
38
  return images.map(image => ({
39
39
  ...image,
40
- url: `${host}${image.thumbUrl}`,
40
+ url: image.thumbUrl.startsWith('http') ? image.thumbUrl : `${host}${image.thumbUrl}`,
41
41
  }));
42
42
  }
43
43
  );
@@ -318,7 +318,8 @@ export class ImageEditDialogContainer extends React.Component {
318
318
 
319
319
  updateOriginalPreview = async () => {
320
320
  const { image } = this.props;
321
- const previewUrl = `${getConf('network.host')}${image.preview.url}`;
321
+ const url = get(image, 'preview.url', '');
322
+ const previewUrl = url.startsWith('http') ? url : `${getConf('network.host')}${url}`;
322
323
  const isSvg = previewUrl && /\.svg$/.test(previewUrl);
323
324
  if (isSvg) {
324
325
  const svgContent = await getSvgContent(previewUrl, true);
@@ -528,7 +529,11 @@ export class ImageEditDialogContainer extends React.Component {
528
529
 
529
530
  if (updateSVG) {
530
531
  if (!svgContent) {
531
- svgContent = await getSvgContent(image.preview.url, false, forceFetch);
532
+ svgContent = await getSvgContent(
533
+ image.preview.url,
534
+ image.preview.url.startsWith('http'),
535
+ forceFetch
536
+ );
532
537
  }
533
538
 
534
539
  preview = applySvgContentOperations(
@@ -820,7 +825,9 @@ const getUserImages = createSelector(
820
825
  return userImages.map(image => {
821
826
  return {
822
827
  ...image,
823
- url: `${host}${image.thumbnail.url}`,
828
+ url: image.thumbnail.url.startsWith('http')
829
+ ? image.thumbnail.url
830
+ : `${host}${image.thumbnail.url}`,
824
831
  };
825
832
  });
826
833
  }
@@ -22,7 +22,7 @@ export const getPreviewUrlFromImageData = (preview, options = {}) => {
22
22
  return previewUrl;
23
23
  }
24
24
  const { host = getConf('network.host', '') } = options;
25
- return `${host}${previewUrl}`;
25
+ return previewUrl.startsWith('http') ? previewUrl : `${host}${previewUrl}`;
26
26
  };
27
27
 
28
28
  export const isEditableVectorImage = preview => {
@@ -55,7 +55,11 @@ const prepareImageData = (function createImageDataPreProcessor() {
55
55
 
56
56
  if (colorPreviewRequired) {
57
57
  // creating the color map, as it was added from the image edit dialog
58
- const svgContent = await getSvgContent(imageData.preview.url, false, true);
58
+ const svgContent = await getSvgContent(
59
+ imageData.preview.url,
60
+ imageData.preview.url.startsWith('http'),
61
+ true
62
+ );
59
63
  const svgColors = getSvgColors(svgContent, designProductionMethod);
60
64
  const vectorizeColorsMap = createVectorizeColorsMap({}, svgColors);
61
65
  patchedImageData = {
@@ -228,9 +228,11 @@ export const calculateImageBrightness = image => {
228
228
  if (!image) {
229
229
  return;
230
230
  }
231
-
232
- const imageUrl =
233
- image.data && image.data.thumbnail ? `${getConf('network.host')}${image.data.thumbnail.url}` : null;
231
+ const thumbnail = get(image, 'data.thumbnail.url', null);
232
+ let imageUrl = null;
233
+ if (thumbnail) {
234
+ imageUrl = thumbnail.startsWith('http') ? thumbnail : `${getConf('network.host')}${thumbnail}`;
235
+ }
234
236
  const fuzzy = 0.1;
235
237
 
236
238
  return new Promise((resolve, reject) => {
@@ -1888,7 +1890,7 @@ export default class DesignDataService {
1888
1890
  }
1889
1891
 
1890
1892
  async getGalleryImageColors(url) {
1891
- const svgContent = await getSvgContent(url);
1893
+ const svgContent = await getSvgContent(url, url.startsWith('http'));
1892
1894
 
1893
1895
  const designProductionMethod = getSelectedDesignProductionMethod(Services.store.state);
1894
1896
 
@@ -1896,7 +1898,7 @@ export default class DesignDataService {
1896
1898
  }
1897
1899
 
1898
1900
  async getSVGImageSize(url) {
1899
- const svgContent = await getSvgContent(url);
1901
+ const svgContent = await getSvgContent(url, url.startsWith('http'));
1900
1902
  const svgTag = svgContent.match(/<svg[^>]+>/)?.[0];
1901
1903
  const width = svgContent.match(/width="([^"]+)"/)?.[1];
1902
1904
  const height = svgContent.match(/height="([^"]+)"/)?.[1];
@@ -2043,7 +2045,11 @@ export default class DesignDataService {
2043
2045
 
2044
2046
  if (isEditableVectorImage(preview)) {
2045
2047
  const designProductionMethod = getSelectedDesignProductionMethod(Services.store.state);
2046
- const svgContent = await getSvgContent(preview.url, false, !operationsMatching);
2048
+ const svgContent = await getSvgContent(
2049
+ preview.url,
2050
+ preview.url.startsWith('http'),
2051
+ !operationsMatching
2052
+ );
2047
2053
  const svgColors = getSvgColors(svgContent, designProductionMethod);
2048
2054
 
2049
2055
  const vectorizeColorsMap = createVectorizeColorsMap(operations.vectorizeColorsMap, svgColors);
@@ -48,7 +48,9 @@ function updateCanvasImageWithImageData(canvasImage, imageData) {
48
48
  return canvasImage.updateOptions(
49
49
  prepareImageObjectData({
50
50
  imageData,
51
- src: `${getConf('network.host')}${imageData.preview.url}`,
51
+ src: imageData.preview.url?.startsWith('http')
52
+ ? imageData.preview.url
53
+ : `${getConf('network.host')}${imageData.preview.url}`,
52
54
  scaling: getCanvasImageScalingWithImageData(canvasImage, imageData),
53
55
  })
54
56
  );
@@ -184,7 +186,7 @@ export default class DesignerService {
184
186
  throw new Error('Preview image url is not specified!');
185
187
  }
186
188
  Services.store.dispatch(updateUploadDelayed(false));
187
- return `${getConf('network.host')}${url}`;
189
+ return url.startsWith('http') ? url : `${getConf('network.host')}${url}`;
188
190
  }
189
191
 
190
192
  async addImageFromUrl(canvas, url, imageData, options = {}) {