@configuratorware/configurator-frontendgui 1.54.3 → 1.55.2

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.
@@ -12,7 +12,7 @@ var _AddGalleryImage = _interopRequireDefault(require("../Components/AddGalleryI
12
12
  var _Progress = _interopRequireDefault(require("../../../Shared/Components/Progress/Progress"));
13
13
  var _Actions = require("../../../Reducers/ImageGallery/Actions");
14
14
  var _Selectors = require("../../../Reducers/UI/Selectors");
15
- var _configuration = require("../../../configuration");
15
+ var _getUrl = require("../../../Utils/getUrl");
16
16
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
17
17
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
18
18
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -41,10 +41,9 @@ var getTags = (0, _createSelector["default"])(function (imageGalleryState) {
41
41
  var getGalleryImages = (0, _createSelector["default"])(function (imageGalleryState) {
42
42
  return imageGalleryState.gallery;
43
43
  }, function (images) {
44
- var host = (0, _configuration.getConf)('network.host');
45
44
  return images.map(function (image) {
46
45
  return _objectSpread(_objectSpread({}, image), {}, {
47
- url: image.thumbUrl.startsWith('http') ? image.thumbUrl : "".concat(host).concat(image.thumbUrl)
46
+ url: (0, _getUrl.getUrl)(image.thumbUrl)
48
47
  });
49
48
  });
50
49
  });
@@ -28,6 +28,7 @@ var _DesignDataService = require("../../../Services/DesignDataService");
28
28
  var _AddGalleryImage = _interopRequireDefault(require("./AddGalleryImage"));
29
29
  var _createSelector = _interopRequireDefault(require("../../../../Utils/Function/createSelector"));
30
30
  var _configuration = require("../../../configuration");
31
+ var _getUrl = require("../../../Utils/getUrl");
31
32
  var _Constant = require("../../../Constant");
32
33
  var _ImageEditUtils = require("../Utils/ImageEditUtils");
33
34
  var _Transformers = require("../Utils/Transformers");
@@ -127,7 +128,7 @@ var ImageEditDialogContainer = exports.ImageEditDialogContainer = /*#__PURE__*/f
127
128
  case 0:
128
129
  image = _this.props.image;
129
130
  url = (0, _get["default"])(image, 'preview.url', '');
130
- previewUrl = url.startsWith('http') ? url : "".concat((0, _configuration.getConf)('network.host')).concat(url);
131
+ previewUrl = (0, _getUrl.getUrl)(url);
131
132
  isSvg = previewUrl && /\.svg$/.test(previewUrl);
132
133
  if (!isSvg) {
133
134
  _context.n = 2;
@@ -863,13 +864,12 @@ _defineProperty(ImageEditDialogContainer, "defaultProps", {
863
864
  var getUserImages = (0, _createSelector["default"])(function (imageGalleryState) {
864
865
  return imageGalleryState.userImages;
865
866
  }, function (images) {
866
- var host = (0, _configuration.getConf)('network.host');
867
867
  var userImages = images.filter(function (image) {
868
868
  return !image.isPlaceHolderImage;
869
869
  });
870
870
  return userImages.map(function (image) {
871
871
  return _objectSpread(_objectSpread({}, image), {}, {
872
- url: image.thumbnail.url.startsWith('http') ? image.thumbnail.url : "".concat(host).concat(image.thumbnail.url)
872
+ url: (0, _getUrl.getUrl)(image.thumbnail.url)
873
873
  });
874
874
  });
875
875
  });
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.prepareObjectData = exports.prepareImageObjectData = exports.prepareCanvasData = exports.noCache = exports.isOriginalVector = exports.getRasterURL = exports.fixSrcURL = exports.calculateScaleFactor = void 0;
7
7
  var _get = _interopRequireDefault(require("lodash/get"));
8
8
  var _isArray = _interopRequireDefault(require("lodash/isArray"));
9
- var _configuration = require("../../../configuration");
9
+ var _getUrl = require("../../../Utils/getUrl");
10
10
  var _Selectors = require("../../../Reducers/ImageGallery/Selectors");
11
11
  var _DesignDataService = require("../../../Services/DesignDataService");
12
12
  var _excluded = ["objects"];
@@ -32,7 +32,7 @@ var calculateScaleFactor = exports.calculateScaleFactor = function calculateScal
32
32
  return 1;
33
33
  };
34
34
  var fixSrcURL = exports.fixSrcURL = function fixSrcURL(src) {
35
- return src && src[0] === '/' ? "".concat((0, _configuration.getConf)('network.host')).concat(src) : src;
35
+ return (0, _getUrl.getUrl)(src);
36
36
  };
37
37
  var getRasterURL = exports.getRasterURL = function getRasterURL(imageURL) {
38
38
  return ('' + imageURL).replace(/svg$/, 'png');
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.receiveFonts = exports.fetchFonts = exports.addFontFamilyToDOM = exports.addCustomFonts = exports.addCustomFont = exports.RECEIVE_FONTS = exports.ADD_FONTS = exports.ADD_FONT = void 0;
7
- var _configuration = require("../../configuration");
7
+ var _getUrl = require("../../Utils/getUrl");
8
8
  var _Actions = require("../Actions");
9
9
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
10
10
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
@@ -26,7 +26,6 @@ var addFontFamilyToDOM = exports.addFontFamilyToDOM = function addFontFamilyToDO
26
26
  };
27
27
  var receiveFonts = exports.receiveFonts = function receiveFonts(data) {
28
28
  return function (dispatch) {
29
- var host = (0, _configuration.getConf)('network.host');
30
29
  var fonts = [];
31
30
  var _iterator = _createForOfIteratorHelper(data),
32
31
  _step;
@@ -67,7 +66,7 @@ var receiveFonts = exports.receiveFonts = function receiveFonts(data) {
67
66
  var fontField = _fontFields[_i];
68
67
  var fontPath = customFont[fontField.field];
69
68
  if (fontPath) {
70
- var fontUrl = host + fontPath;
69
+ var fontUrl = (0, _getUrl.getUrl)(fontPath);
71
70
  var urlFieldName = 'url' + fontField.property.charAt(0).toUpperCase() + fontField.property.slice(1);
72
71
  font[fontField.property] = true;
73
72
  font[urlFieldName] = fontUrl;
@@ -9,6 +9,7 @@ var _find = _interopRequireDefault(require("lodash/find"));
9
9
  var _isString = _interopRequireDefault(require("lodash/isString"));
10
10
  var _flatten = _interopRequireDefault(require("lodash/flatten"));
11
11
  var _configuration = require("../../configuration");
12
+ var _getUrl = require("../../Utils/getUrl");
12
13
  var _Selectors = require("../Configurator/Selectors");
13
14
  var _Reducer = require("../DesignData/Reducer");
14
15
  var _Actions = require("./Actions");
@@ -22,9 +23,7 @@ var getPreviewUrlFromImageData = exports.getPreviewUrlFromImageData = function g
22
23
  if (/^data:image/.test(previewUrl)) {
23
24
  return previewUrl;
24
25
  }
25
- var _options$host = options.host,
26
- host = _options$host === void 0 ? (0, _configuration.getConf)('network.host', '') : _options$host;
27
- return previewUrl.startsWith('http') ? previewUrl : "".concat(host).concat(previewUrl);
26
+ return (0, _getUrl.getUrl)(previewUrl, options.host);
28
27
  };
29
28
  var isEditableVectorImage = exports.isEditableVectorImage = function isEditableVectorImage(preview) {
30
29
  return preview && preview.url && (/.svg$/.test(preview.url) || /^data:image\/svg\+xml/.test(preview.url));
@@ -14,7 +14,7 @@ var _merge = _interopRequireDefault(require("lodash/merge"));
14
14
  var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
15
15
  var _set = _interopRequireDefault(require("lodash/set"));
16
16
  var _Selectors = require("../../Reducers/Configurator/Selectors");
17
- var _configuration = require("../../configuration");
17
+ var _getUrl = require("../../Utils/getUrl");
18
18
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
19
19
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
20
20
  var darkTextColor = '#282828';
@@ -228,8 +228,7 @@ var createThemeFromClientTheme = function createThemeFromClientTheme(clientTheme
228
228
  (0, _set["default"])(theme, 'overrides.Designer-Editor.graphicsEditorContainer.borderColor', clientTheme.highlightColor);
229
229
  }
230
230
  if (clientTheme.font) {
231
- var host = (0, _configuration.getConf)('network.host');
232
- var fontUrl = host + clientTheme.font;
231
+ var fontUrl = (0, _getUrl.getUrl)(clientTheme.font);
233
232
  var fontName = clientTheme.font.substring(clientTheme.font.lastIndexOf('/') + 1, clientTheme.font.indexOf('.'));
234
233
  loadClientFont(fontName, fontUrl);
235
234
  (0, _set["default"])(theme, 'typography.fontFamily', fontName);
@@ -11,9 +11,11 @@ var _get2 = _interopRequireDefault(require("lodash/get"));
11
11
  var _find = _interopRequireDefault(require("lodash/find"));
12
12
  var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
13
13
  var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
14
+ var _merge = _interopRequireDefault(require("lodash/merge"));
14
15
  var _i18n = require("../../Framework/i18n");
15
16
  var _ServiceLocator = require("../ServiceLocator");
16
17
  var _configuration = require("../configuration");
18
+ var _getUrl = require("../Utils/getUrl");
17
19
  var _Observable = _interopRequireDefault(require("../../Utils/Decorators/Observable"));
18
20
  var _setupDesigner = _interopRequireDefault(require("../Modules/Designer/setupDesigner"));
19
21
  var _Actions = require("../Reducers/DesignData/Actions");
@@ -158,7 +160,7 @@ var calculateImageBrightness = exports.calculateImageBrightness = function calcu
158
160
  var thumbnail = (0, _get2["default"])(image, 'data.thumbnail.url', null);
159
161
  var imageUrl = null;
160
162
  if (thumbnail) {
161
- imageUrl = thumbnail.startsWith('http') ? thumbnail : "".concat((0, _configuration.getConf)('network.host')).concat(thumbnail);
163
+ imageUrl = (0, _getUrl.getUrl)(thumbnail);
162
164
  }
163
165
  var fuzzy = 0.1;
164
166
  return new Promise(function (resolve, reject) {
@@ -302,7 +304,7 @@ var getSvgContent = exports.getSvgContent = function () {
302
304
  return function getSvgContent(url) {
303
305
  var absolute = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
304
306
  var forceFetch = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
305
- var absUrl = absolute ? url : "".concat((0, _configuration.getConf)('network.host')).concat(url);
307
+ var absUrl = (0, _getUrl.getUrl)(url, absolute ? undefined : (0, _configuration.getConf)('network.host'));
306
308
  if (!forceFetch && svgContentMap.has(absUrl)) {
307
309
  return svgContentMap.get(absUrl);
308
310
  }
@@ -1835,18 +1837,27 @@ var DesignDataService = exports["default"] = /*#__PURE__*/function () {
1835
1837
  value: (function () {
1836
1838
  var _redrawAllDesignAreas = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee21(getDrawingContext, updateEventObject) {
1837
1839
  var _this8 = this;
1838
- var state, showHighlight, textureBuilderConfig, variantIdentifier, effectEnabled, drawingFn, _t10;
1840
+ var options,
1841
+ state,
1842
+ showHighlight,
1843
+ textureBuilderConfig,
1844
+ variantIdentifier,
1845
+ effectEnabled,
1846
+ drawingFn,
1847
+ _args22 = arguments,
1848
+ _t11;
1839
1849
  return _regenerator().w(function (_context22) {
1840
1850
  while (1) switch (_context22.p = _context22.n) {
1841
1851
  case 0:
1852
+ options = _args22.length > 2 && _args22[2] !== undefined ? _args22[2] : {};
1842
1853
  state = _ServiceLocator.Services.store.state;
1843
1854
  showHighlight = (0, _get2["default"])(state, 'designArea.showHighlight');
1844
- textureBuilderConfig = {
1855
+ textureBuilderConfig = (0, _merge["default"])({
1845
1856
  highlight: {
1846
1857
  borderColor: (0, _Selectors3.getClientHighlightColor)(state),
1847
1858
  backgroundColor: (0, _configuration.getConf)('visualization.designAreaHighlightBackgroundColor')
1848
1859
  }
1849
- };
1860
+ }, options.textureBuilderConfig);
1850
1861
  variantIdentifier = (0, _get2["default"])(updateEventObject, 'data.variant', false);
1851
1862
  effectEnabled = !(0, _Selectors3.isDesignerProductPreviewMode)();
1852
1863
  drawingFn = /*#__PURE__*/function () {
@@ -1855,19 +1866,30 @@ var DesignDataService = exports["default"] = /*#__PURE__*/function () {
1855
1866
  _getTextureBuilder,
1856
1867
  getTextureImage,
1857
1868
  drawCanvasToArea,
1858
- highlightDesignAreas,
1869
+ drawCanvasToAreaDirect,
1870
+ highlightDesignArea,
1859
1871
  drawOn,
1860
1872
  getParams,
1861
1873
  _iterator9,
1862
1874
  _step9,
1875
+ designArea,
1876
+ canvas,
1877
+ releaseLock,
1878
+ maskHandler,
1879
+ restoreOutlineVisibility,
1880
+ restoreOutlineOnly,
1881
+ drawToContext,
1882
+ _iterator0,
1883
+ _step0,
1863
1884
  _loop,
1864
1885
  _args21 = arguments,
1865
- _t1;
1886
+ _t1,
1887
+ _t10;
1866
1888
  return _regenerator().w(function (_context21) {
1867
1889
  while (1) switch (_context21.p = _context21.n) {
1868
1890
  case 0:
1869
1891
  designAreas = _args21.length > 2 && _args21[2] !== undefined ? _args21[2] : _this8.getDesignAreas();
1870
- _getTextureBuilder = getTextureBuilder(textureBuilderConfig), getTextureImage = _getTextureBuilder.getTextureImage, drawCanvasToArea = _getTextureBuilder.drawCanvasToArea, highlightDesignAreas = _getTextureBuilder.highlightDesignAreas, drawOn = _getTextureBuilder.drawOn, getParams = _getTextureBuilder.getParams;
1892
+ _getTextureBuilder = getTextureBuilder(textureBuilderConfig), getTextureImage = _getTextureBuilder.getTextureImage, drawCanvasToArea = _getTextureBuilder.drawCanvasToArea, drawCanvasToAreaDirect = _getTextureBuilder.drawCanvasToAreaDirect, highlightDesignArea = _getTextureBuilder.highlightDesignArea, drawOn = _getTextureBuilder.drawOn, getParams = _getTextureBuilder.getParams;
1871
1893
  if (getTextureImage()) {
1872
1894
  _context21.n = 1;
1873
1895
  break;
@@ -1876,94 +1898,152 @@ var DesignDataService = exports["default"] = /*#__PURE__*/function () {
1876
1898
  console.warn('Texture image is missing!', designAreas);
1877
1899
  return _context21.a(2);
1878
1900
  case 1:
1879
- if (showHighlight) {
1880
- // highlight only the design areas with no mask
1881
- // for the others the outline is added by the maskHandler
1882
- highlightDesignAreas(designAreas.filter(function (designArea) {
1883
- return !(0, _Selectors.designAreaAppliesMask)(state, designArea);
1884
- }));
1901
+ if (!showHighlight) {
1902
+ _context21.n = 13;
1903
+ break;
1885
1904
  }
1886
1905
  _iterator9 = _createForOfIteratorHelper(designAreas);
1887
1906
  _context21.p = 2;
1907
+ _iterator9.s();
1908
+ case 3:
1909
+ if ((_step9 = _iterator9.n()).done) {
1910
+ _context21.n = 10;
1911
+ break;
1912
+ }
1913
+ designArea = _step9.value;
1914
+ canvas = _this8._getCanvas(_this8.getDesignAreaByIdentifier(designArea.identifier));
1915
+ if (canvas) {
1916
+ _context21.n = 4;
1917
+ break;
1918
+ }
1919
+ return _context21.a(3, 9);
1920
+ case 4:
1921
+ _context21.n = 5;
1922
+ return (0, _ObjectLock.requestLock)(canvas);
1923
+ case 5:
1924
+ releaseLock = _context21.v;
1925
+ maskHandler = canvas.getMaskHandler();
1926
+ if (!((0, _Selectors.designAreaAppliesMask)(state, designArea) && maskHandler)) {
1927
+ _context21.n = 7;
1928
+ break;
1929
+ }
1930
+ restoreOutlineVisibility = maskHandler.toggleOutline(true, {
1931
+ getZoomFactor: function getZoomFactor(_ref18) {
1932
+ var zoom = _ref18.zoom;
1933
+ // currentZoom is only available for 2D, for 3D it is always 1
1934
+ var threeFactor = Math.min(getParams().currentZoom, 1) || 1;
1935
+ return zoom * threeFactor;
1936
+ }
1937
+ });
1938
+ restoreOutlineOnly = maskHandler.showOutlineOnly();
1939
+ drawToContext = canvas.drawToContext.bind(canvas);
1940
+ _context21.n = 6;
1941
+ return drawCanvasToAreaDirect({
1942
+ drawToContext: drawToContext,
1943
+ designArea: designArea
1944
+ });
1945
+ case 6:
1946
+ restoreOutlineVisibility === null || restoreOutlineVisibility === void 0 || restoreOutlineVisibility();
1947
+ restoreOutlineOnly === null || restoreOutlineOnly === void 0 || restoreOutlineOnly();
1948
+ _context21.n = 8;
1949
+ break;
1950
+ case 7:
1951
+ highlightDesignArea(designArea);
1952
+ case 8:
1953
+ releaseLock();
1954
+ case 9:
1955
+ _context21.n = 3;
1956
+ break;
1957
+ case 10:
1958
+ _context21.n = 12;
1959
+ break;
1960
+ case 11:
1961
+ _context21.p = 11;
1962
+ _t1 = _context21.v;
1963
+ _iterator9.e(_t1);
1964
+ case 12:
1965
+ _context21.p = 12;
1966
+ _iterator9.f();
1967
+ return _context21.f(12);
1968
+ case 13:
1969
+ _iterator0 = _createForOfIteratorHelper(designAreas);
1970
+ _context21.p = 14;
1888
1971
  _loop = /*#__PURE__*/_regenerator().m(function _loop() {
1889
- var designArea, canvas, _canvas$getColorOverl, releaseLock, selectedObject, maskHandler, restoreOutlineVisibility, restoreColorOverlayVisibility, drawToContext, getSvg;
1972
+ var _canvas$getColorOverl, _canvas$getMaskHandle;
1973
+ var designArea, canvas, releaseLock, selectedObject, restoreColorOverlayVisibility, restoreOutlineVisibility, drawToContext, getSvg;
1890
1974
  return _regenerator().w(function (_context20) {
1891
1975
  while (1) switch (_context20.n) {
1892
1976
  case 0:
1893
- designArea = _step9.value;
1977
+ designArea = _step0.value;
1894
1978
  canvas = _this8._getCanvas(_this8.getDesignAreaByIdentifier(designArea.identifier));
1895
- if (!canvas) {
1896
- _context20.n = 3;
1979
+ if (canvas) {
1980
+ _context20.n = 1;
1897
1981
  break;
1898
1982
  }
1899
- _context20.n = 1;
1900
- return (0, _ObjectLock.requestLock)(canvas);
1983
+ return _context20.a(2, 1);
1901
1984
  case 1:
1985
+ _context20.n = 2;
1986
+ return (0, _ObjectLock.requestLock)(canvas);
1987
+ case 2:
1902
1988
  releaseLock = _context20.v;
1903
1989
  selectedObject = (0, _get2["default"])(canvas, 'selectedObject');
1904
1990
  if (selectedObject) {
1905
1991
  selectedObject.selected = false;
1906
1992
  }
1907
- maskHandler = canvas.getMaskHandler();
1908
- if (maskHandler) {
1909
- restoreOutlineVisibility = maskHandler.toggleOutline(showHighlight, {
1910
- getZoomFactor: function getZoomFactor(_ref18) {
1911
- var zoom = _ref18.zoom;
1912
- // currentZoom is only available for 2D, for 3D it is always 1
1913
- var threeFactor = Math.min(getParams().currentZoom, 1) || 1;
1914
- return zoom * threeFactor;
1915
- }
1916
- });
1917
- }
1918
1993
  restoreColorOverlayVisibility = (_canvas$getColorOverl = canvas.getColorOverlay()) === null || _canvas$getColorOverl === void 0 ? void 0 : _canvas$getColorOverl.toggle(false);
1994
+ restoreOutlineVisibility = (_canvas$getMaskHandle = canvas.getMaskHandler()) === null || _canvas$getMaskHandle === void 0 ? void 0 : _canvas$getMaskHandle.toggleOutline(false);
1919
1995
  drawToContext = canvas.drawToContext.bind(canvas);
1920
1996
  getSvg = function getSvg() {
1921
1997
  return canvas.getScreenshot((0, _Selectors4.getFontMapping)(state));
1922
1998
  };
1923
- _context20.n = 2;
1999
+ _context20.n = 3;
1924
2000
  return drawCanvasToArea(_objectSpread({
1925
2001
  drawToContext: drawToContext,
1926
2002
  designArea: designArea,
1927
2003
  getSvg: getSvg
1928
2004
  }, effectEnabled && (0, _Selectors.getVisualizationEffectWithOptions)(state, designArea, variantIdentifier)));
1929
- case 2:
1930
- if (maskHandler) {
1931
- restoreOutlineVisibility();
1932
- }
1933
- restoreColorOverlayVisibility && restoreColorOverlayVisibility();
1934
- releaseLock();
1935
2005
  case 3:
2006
+ restoreColorOverlayVisibility === null || restoreColorOverlayVisibility === void 0 || restoreColorOverlayVisibility();
2007
+ restoreOutlineVisibility === null || restoreOutlineVisibility === void 0 || restoreOutlineVisibility();
2008
+ releaseLock();
2009
+ case 4:
1936
2010
  return _context20.a(2);
1937
2011
  }
1938
2012
  }, _loop);
1939
2013
  });
1940
- _iterator9.s();
1941
- case 3:
1942
- if ((_step9 = _iterator9.n()).done) {
1943
- _context21.n = 5;
2014
+ _iterator0.s();
2015
+ case 15:
2016
+ if ((_step0 = _iterator0.n()).done) {
2017
+ _context21.n = 18;
1944
2018
  break;
1945
2019
  }
1946
- return _context21.d(_regeneratorValues(_loop()), 4);
1947
- case 4:
1948
- _context21.n = 3;
2020
+ return _context21.d(_regeneratorValues(_loop()), 16);
2021
+ case 16:
2022
+ if (!_context21.v) {
2023
+ _context21.n = 17;
2024
+ break;
2025
+ }
2026
+ return _context21.a(3, 17);
2027
+ case 17:
2028
+ _context21.n = 15;
1949
2029
  break;
1950
- case 5:
1951
- _context21.n = 7;
2030
+ case 18:
2031
+ _context21.n = 20;
1952
2032
  break;
1953
- case 6:
1954
- _context21.p = 6;
1955
- _t1 = _context21.v;
1956
- _iterator9.e(_t1);
1957
- case 7:
1958
- _context21.p = 7;
1959
- _iterator9.f();
1960
- return _context21.f(7);
1961
- case 8:
2033
+ case 19:
2034
+ _context21.p = 19;
2035
+ _t10 = _context21.v;
2036
+ _iterator0.e(_t10);
2037
+ case 20:
2038
+ _context21.p = 20;
2039
+ _iterator0.f();
2040
+ return _context21.f(20);
2041
+ case 21:
1962
2042
  drawOn(textureCtx);
1963
- case 9:
2043
+ case 22:
1964
2044
  return _context21.a(2);
1965
2045
  }
1966
- }, _callee20, null, [[2, 6, 7, 8]]);
2046
+ }, _callee20, null, [[14, 19, 20, 21], [2, 11, 12, 13]]);
1967
2047
  }));
1968
2048
  return function drawingFn(_x22, _x23) {
1969
2049
  return _ref17.apply(this, arguments);
@@ -1977,9 +2057,9 @@ var DesignDataService = exports["default"] = /*#__PURE__*/function () {
1977
2057
  break;
1978
2058
  case 3:
1979
2059
  _context22.p = 3;
1980
- _t10 = _context22.v;
2060
+ _t11 = _context22.v;
1981
2061
  // eslint-disable-next-line no-console
1982
- console.warn('Could not get drawing context, texture update is skipped!', _t10.message);
2062
+ console.warn('Could not get drawing context, texture update is skipped!', _t11.message);
1983
2063
  case 4:
1984
2064
  return _context22.a(2);
1985
2065
  }
@@ -2059,8 +2139,8 @@ var DesignDataService = exports["default"] = /*#__PURE__*/function () {
2059
2139
  return canvas && canvas[screenshotFn] && canvas.objects && canvas.objects.length > 0;
2060
2140
  }).map(/*#__PURE__*/function () {
2061
2141
  var _ref22 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee23(_ref21) {
2062
- var _canvas$getColorOverl2;
2063
- var id, canvas, releaseLock, maskHandler, restoreOutlineVisibility, restoreColorOverlayVisibility, result, _t11, _t12;
2142
+ var _canvas$getMaskHandle2, _canvas$getColorOverl2;
2143
+ var id, canvas, releaseLock, restoreOutlineVisibility, restoreColorOverlayVisibility, result, _t12, _t13;
2064
2144
  return _regenerator().w(function (_context24) {
2065
2145
  while (1) switch (_context24.n) {
2066
2146
  case 0:
@@ -2069,17 +2149,16 @@ var DesignDataService = exports["default"] = /*#__PURE__*/function () {
2069
2149
  return (0, _ObjectLock.requestLock)(canvas);
2070
2150
  case 1:
2071
2151
  releaseLock = _context24.v;
2072
- maskHandler = canvas.getMaskHandler();
2073
- restoreOutlineVisibility = maskHandler && maskHandler.toggleOutline(false);
2152
+ restoreOutlineVisibility = (_canvas$getMaskHandle2 = canvas.getMaskHandler()) === null || _canvas$getMaskHandle2 === void 0 ? void 0 : _canvas$getMaskHandle2.toggleOutline(false);
2074
2153
  restoreColorOverlayVisibility = (_canvas$getColorOverl2 = canvas.getColorOverlay()) === null || _canvas$getColorOverl2 === void 0 ? void 0 : _canvas$getColorOverl2.toggle(false);
2075
- _t11 = id;
2154
+ _t12 = id;
2076
2155
  _context24.n = 2;
2077
2156
  return canvas[screenshotFn](fontMapping);
2078
2157
  case 2:
2079
- _t12 = _context24.v;
2080
- result = [_t11, _t12];
2081
- restoreOutlineVisibility && restoreOutlineVisibility();
2082
- restoreColorOverlayVisibility && restoreColorOverlayVisibility();
2158
+ _t13 = _context24.v;
2159
+ result = [_t12, _t13];
2160
+ restoreOutlineVisibility === null || restoreOutlineVisibility === void 0 || restoreOutlineVisibility();
2161
+ restoreColorOverlayVisibility === null || restoreColorOverlayVisibility === void 0 || restoreColorOverlayVisibility();
2083
2162
  releaseLock();
2084
2163
  return _context24.a(2, result);
2085
2164
  }
@@ -2334,11 +2413,11 @@ var DesignDataService = exports["default"] = /*#__PURE__*/function () {
2334
2413
  if (preSelectionDesignAreaIdentifier) {
2335
2414
  this.selectDesignArea(preSelectionDesignAreaIdentifier);
2336
2415
  }
2337
- var _iterator0 = _createForOfIteratorHelper(filteredDesignAreas),
2338
- _step0;
2416
+ var _iterator1 = _createForOfIteratorHelper(filteredDesignAreas),
2417
+ _step1;
2339
2418
  try {
2340
- for (_iterator0.s(); !(_step0 = _iterator0.n()).done;) {
2341
- var area = _step0.value;
2419
+ for (_iterator1.s(); !(_step1 = _iterator1.n()).done;) {
2420
+ var area = _step1.value;
2342
2421
  var selectedDesignArea = (0, _Selectors.getDesignAreaPreSelection)(area.identifier);
2343
2422
  if (selectedDesignArea.identifier) {
2344
2423
  var preSelectionColorAmount = +(0, _get2["default"])(selectedDesignArea, 'colorAmount', 1);
@@ -2350,9 +2429,9 @@ var DesignDataService = exports["default"] = /*#__PURE__*/function () {
2350
2429
  }
2351
2430
  }
2352
2431
  } catch (err) {
2353
- _iterator0.e(err);
2432
+ _iterator1.e(err);
2354
2433
  } finally {
2355
- _iterator0.f();
2434
+ _iterator1.f();
2356
2435
  }
2357
2436
  }
2358
2437
  }, {
@@ -2367,7 +2446,7 @@ var DesignDataService = exports["default"] = /*#__PURE__*/function () {
2367
2446
  key: "setImageAndTextColor",
2368
2447
  value: function () {
2369
2448
  var _setImageAndTextColor = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee29(color) {
2370
- var designArea, designData, objects, hasmultipleObjects, canvas, isImageSelected, selectedImageIdentifier, _iterator1, _step1, object, image, operations, _t13;
2449
+ var designArea, designData, objects, hasmultipleObjects, canvas, isImageSelected, selectedImageIdentifier, _iterator10, _step10, object, image, operations, _t14;
2371
2450
  return _regenerator().w(function (_context30) {
2372
2451
  while (1) switch (_context30.p = _context30.n) {
2373
2452
  case 0:
@@ -2391,15 +2470,15 @@ var DesignDataService = exports["default"] = /*#__PURE__*/function () {
2391
2470
  isImageSelected = canvas.selectedObject && canvas.selectedObject.type === 'Image';
2392
2471
  selectedImageIdentifier = isImageSelected ? (0, _get2["default"])(_ServiceLocator.Services.store.state, 'imageGallery.selectedImage.identifier', null) : null;
2393
2472
  _ServiceLocator.Services.store.dispatch((0, _Actions.setDesignAreaTextsColor)(designArea.identifier, color));
2394
- _iterator1 = _createForOfIteratorHelper(objects);
2473
+ _iterator10 = _createForOfIteratorHelper(objects);
2395
2474
  _context30.p = 3;
2396
- _iterator1.s();
2475
+ _iterator10.s();
2397
2476
  case 4:
2398
- if ((_step1 = _iterator1.n()).done) {
2477
+ if ((_step10 = _iterator10.n()).done) {
2399
2478
  _context30.n = 6;
2400
2479
  break;
2401
2480
  }
2402
- object = _step1.value;
2481
+ object = _step10.value;
2403
2482
  if (!(object.type === 'Image' && object.imageData.identifier !== selectedImageIdentifier)) {
2404
2483
  _context30.n = 5;
2405
2484
  break;
@@ -2416,11 +2495,11 @@ var DesignDataService = exports["default"] = /*#__PURE__*/function () {
2416
2495
  break;
2417
2496
  case 7:
2418
2497
  _context30.p = 7;
2419
- _t13 = _context30.v;
2420
- _iterator1.e(_t13);
2498
+ _t14 = _context30.v;
2499
+ _iterator10.e(_t14);
2421
2500
  case 8:
2422
2501
  _context30.p = 8;
2423
- _iterator1.f();
2502
+ _iterator10.f();
2424
2503
  return _context30.f(8);
2425
2504
  case 9:
2426
2505
  _context30.n = 10;
@@ -13,6 +13,7 @@ var _i18n = require("../../Framework/i18n");
13
13
  var _Transformers = require("../Modules/Designer/Utils/Transformers");
14
14
  var _ServiceLocator = require("../ServiceLocator");
15
15
  var _configuration = require("../configuration");
16
+ var _getUrl = require("../Utils/getUrl");
16
17
  var _Selectors = require("../Reducers/ImageGallery/Selectors");
17
18
  var _Actions = require("../Reducers/ImageGallery/Actions");
18
19
  var _Selectors2 = require("../Reducers/DesignArea/Selectors");
@@ -256,7 +257,7 @@ var DesignerService = exports["default"] = /*#__PURE__*/function () {
256
257
  throw new Error('Preview image url is not specified!');
257
258
  case 3:
258
259
  _ServiceLocator.Services.store.dispatch((0, _Actions.updateUploadDelayed)(false));
259
- return _context5.a(2, url.startsWith('http') ? url : "".concat((0, _configuration.getConf)('network.host')).concat(url));
260
+ return _context5.a(2, (0, _getUrl.getUrl)(url));
260
261
  }
261
262
  }, _callee5);
262
263
  }));
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getUrl = getUrl;
7
+ var _configuration = require("../configuration");
8
+ /**
9
+ * Resolves a resource URL: absolute URLs (starting with "http") are returned as-is,
10
+ * otherwise the host is prepended.
11
+ * @param {string} url - Resource path or absolute URL
12
+ * @param {string} [host=getConf('network.host')] - Host to prepend for relative URLs (uses default if falsy)
13
+ * @returns {string} Resolved URL
14
+ */
15
+ function getUrl(url, host) {
16
+ if (url == null || url === '') {
17
+ return url;
18
+ }
19
+ var resolvedHost = host || (0, _configuration.getConf)('network.host');
20
+ return url.startsWith('http') ? url : "".concat(resolvedHost).concat(url);
21
+ }
@@ -20,6 +20,13 @@ var _Api = _interopRequireDefault(require("../Framework/Api"));
20
20
  var _hyphenatedDe = _interopRequireDefault(require("hyphenated-de"));
21
21
  var _Reducer = require("./Reducers/Configurator/Reducer");
22
22
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
23
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
24
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
25
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
26
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
27
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
28
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
29
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
23
30
  var DEVELOPMENT_HOST_INT = 'http://int.configuratorware-dev.local';
24
31
 
25
32
  // eslint-disable-next-line no-unused-vars
@@ -203,7 +210,10 @@ var applicationConfiguration = {
203
210
  // automatically show the vectorization preview in colorizing step
204
211
  autoPreviewVectorization: true,
205
212
  // switch to the previously selected view when selecting a component that has no view specified
206
- switchViewOnComponentSelection: true
213
+ switchViewOnComponentSelection: true,
214
+ parameterParser: function parameterParser(name, value) {
215
+ return value;
216
+ }
207
217
  };
208
218
  function preventLeavingPage() {
209
219
  if (process.env.NODE_ENV === 'production' && !getConf('adminMode')) {
@@ -228,12 +238,15 @@ function init() {
228
238
  if (externalConfig) {
229
239
  applicationConfiguration = (0, _merge["default"])(applicationConfiguration, externalConfig);
230
240
  }
231
- applicationConfiguration = (0, _merge["default"])(applicationConfiguration, getQueryParams());
241
+ applicationConfiguration = (0, _merge["default"])(applicationConfiguration, getQueryParams(applicationConfiguration.parameterParser));
232
242
  _Api["default"].init(applicationConfiguration.network);
233
243
  preventLeavingPage();
234
244
  return applicationConfiguration;
235
245
  }
236
246
  function getQueryParams() {
247
+ var parameterParser = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function (_name, value) {
248
+ return value;
249
+ };
237
250
  var query = new URLSearchParams(location.search);
238
251
  var queryConf = {};
239
252
 
@@ -306,6 +319,30 @@ function getQueryParams() {
306
319
  console.error('Wrong JSON provided for _switch_options:', optionsToSwitchJSON);
307
320
  }
308
321
  }
322
+ if (query.has('_country')) {
323
+ var country = query.get('_country');
324
+ if (country && country.length === 2) {
325
+ _Api["default"].setGETParameter('_country', country);
326
+ }
327
+ }
328
+
329
+ // Forward all query parameters starting with "_" to Api.setGETParameter
330
+ var _iterator = _createForOfIteratorHelper(query.entries()),
331
+ _step;
332
+ try {
333
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
334
+ var _step$value = _slicedToArray(_step.value, 2),
335
+ name = _step$value[0],
336
+ value = _step$value[1];
337
+ if (name.startsWith('_')) {
338
+ _Api["default"].setGETParameter(name, parameterParser(name, value));
339
+ }
340
+ }
341
+ } catch (err) {
342
+ _iterator.e(err);
343
+ } finally {
344
+ _iterator.f();
345
+ }
309
346
  return queryConf;
310
347
  }
311
348
  function setConfiguration(customApplicationConfiguration) {
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@configuratorware/configurator-frontendgui",
3
- "version": "1.54.3",
3
+ "version": "1.55.2",
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.54.3",
9
+ "@configuratorware/scripts": "1.55.2",
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.54.3",
40
- "redhotmagma-visualization": "1.54.3",
39
+ "redhotmagma-graphics-editor": "1.55.2",
40
+ "redhotmagma-visualization": "1.55.2",
41
41
  "redux": "^4.1.0",
42
42
  "redux-logger": "^3.0.6",
43
43
  "redux-persist": "^5.10.0",
@@ -12,7 +12,7 @@ import {
12
12
  WN_LOAD_TAGS,
13
13
  } from 'App/Reducers/ImageGallery/Actions';
14
14
  import { createBackgroundWorkStateSelector } from 'App/Reducers/UI/Selectors';
15
- import { getConf } from 'App/configuration';
15
+ import { getUrl } from 'App/Utils/getUrl';
16
16
 
17
17
  const getTags = createSelector(
18
18
  imageGalleryState => imageGalleryState.tags,
@@ -33,13 +33,11 @@ const getTags = createSelector(
33
33
 
34
34
  const getGalleryImages = createSelector(
35
35
  imageGalleryState => imageGalleryState.gallery,
36
- images => {
37
- const host = getConf('network.host');
38
- return images.map(image => ({
36
+ images =>
37
+ images.map(image => ({
39
38
  ...image,
40
- url: image.thumbUrl.startsWith('http') ? image.thumbUrl : `${host}${image.thumbUrl}`,
41
- }));
42
- }
39
+ url: getUrl(image.thumbUrl),
40
+ }))
43
41
  );
44
42
 
45
43
  const getLoadingState = createBackgroundWorkStateSelector(WN_LOAD_TAGS, WN_LOAD_IMAGES);
@@ -49,6 +49,7 @@ import { applySvgContentOperations, getSvgContent } from 'App/Services/DesignDat
49
49
  import AddGalleryImage from './AddGalleryImage';
50
50
  import createSelector from 'Utils/Function/createSelector';
51
51
  import { getConf } from 'App/configuration';
52
+ import { getUrl } from 'App/Utils/getUrl';
52
53
  import { EventTypes } from 'App/Constant';
53
54
  import { expandVectorizeColorsMap, getClosestColorFromMap } from '../Utils/ImageEditUtils';
54
55
  import { isOriginalVector } from '../Utils/Transformers';
@@ -319,7 +320,7 @@ export class ImageEditDialogContainer extends React.Component {
319
320
  updateOriginalPreview = async () => {
320
321
  const { image } = this.props;
321
322
  const url = get(image, 'preview.url', '');
322
- const previewUrl = url.startsWith('http') ? url : `${getConf('network.host')}${url}`;
323
+ const previewUrl = getUrl(url);
323
324
  const isSvg = previewUrl && /\.svg$/.test(previewUrl);
324
325
  if (isSvg) {
325
326
  const svgContent = await getSvgContent(previewUrl, true);
@@ -821,14 +822,11 @@ export class ImageEditDialogContainer extends React.Component {
821
822
  const getUserImages = createSelector(
822
823
  imageGalleryState => imageGalleryState.userImages,
823
824
  images => {
824
- const host = getConf('network.host');
825
825
  const userImages = images.filter(image => !image.isPlaceHolderImage);
826
826
  return userImages.map(image => {
827
827
  return {
828
828
  ...image,
829
- url: image.thumbnail.url.startsWith('http')
830
- ? image.thumbnail.url
831
- : `${host}${image.thumbnail.url}`,
829
+ url: getUrl(image.thumbnail.url),
832
830
  };
833
831
  });
834
832
  }
@@ -1,6 +1,6 @@
1
1
  import get from 'lodash/get';
2
2
  import isArray from 'lodash/isArray';
3
- import { getConf } from '../../../configuration';
3
+ import { getUrl } from '../../../Utils/getUrl';
4
4
  import { isEditableVectorImage } from '../../../Reducers/ImageGallery/Selectors';
5
5
  import { getSvgContent, applySvgContentOperations } from '../../../Services/DesignDataService';
6
6
 
@@ -13,9 +13,7 @@ export const calculateScaleFactor = imageData => {
13
13
  return 1;
14
14
  };
15
15
 
16
- export const fixSrcURL = src => {
17
- return src && src[0] === '/' ? `${getConf('network.host')}${src}` : src;
18
- };
16
+ export const fixSrcURL = src => getUrl(src);
19
17
 
20
18
  export const getRasterURL = imageURL => ('' + imageURL).replace(/svg$/, 'png');
21
19
 
@@ -1,4 +1,4 @@
1
- import { getConf } from '../../configuration';
1
+ import { getUrl } from '../../Utils/getUrl';
2
2
  import { fetchDataAsync } from '../Actions';
3
3
 
4
4
  export const RECEIVE_FONTS = 'RECEIVE_FONTS';
@@ -24,7 +24,6 @@ export const addFontFamilyToDOM = (name, url, bold, italic) => {
24
24
  };
25
25
 
26
26
  export const receiveFonts = data => dispatch => {
27
- const host = getConf('network.host');
28
27
  const fonts = [];
29
28
 
30
29
  for (const customFont of data) {
@@ -49,7 +48,7 @@ export const receiveFonts = data => dispatch => {
49
48
  const fontPath = customFont[fontField.field];
50
49
 
51
50
  if (fontPath) {
52
- const fontUrl = host + fontPath;
51
+ const fontUrl = getUrl(fontPath);
53
52
  const urlFieldName =
54
53
  'url' + fontField.property.charAt(0).toUpperCase() + fontField.property.slice(1);
55
54
 
@@ -3,6 +3,7 @@ import find from 'lodash/find';
3
3
  import isString from 'lodash/isString';
4
4
  import flatten from 'lodash/flatten';
5
5
  import { getConf } from '../../configuration';
6
+ import { getUrl } from '../../Utils/getUrl';
6
7
  import { getConfiguration, getConfigurator } from '../Configurator/Selectors';
7
8
  import { getDesignData } from '../DesignData/Reducer';
8
9
  import { ImageGalleryModes } from './Actions';
@@ -23,8 +24,7 @@ export const getPreviewUrlFromImageData = (preview, options = {}) => {
23
24
  if (/^data:image/.test(previewUrl)) {
24
25
  return previewUrl;
25
26
  }
26
- const { host = getConf('network.host', '') } = options;
27
- return previewUrl.startsWith('http') ? previewUrl : `${host}${previewUrl}`;
27
+ return getUrl(previewUrl, options.host);
28
28
  };
29
29
 
30
30
  export const isEditableVectorImage = preview => {
@@ -7,7 +7,7 @@ import merge from 'lodash/merge';
7
7
  import cloneDeep from 'lodash/cloneDeep';
8
8
  import set from 'lodash/set';
9
9
  import { getClient } from '../../Reducers/Configurator/Selectors';
10
- import { getConf } from '../../configuration';
10
+ import { getUrl } from '../../Utils/getUrl';
11
11
 
12
12
  const darkTextColor = '#282828';
13
13
 
@@ -229,8 +229,7 @@ const createThemeFromClientTheme = (clientTheme, customTheme) => {
229
229
  );
230
230
  }
231
231
  if (clientTheme.font) {
232
- const host = getConf('network.host');
233
- const fontUrl = host + clientTheme.font;
232
+ const fontUrl = getUrl(clientTheme.font);
234
233
  const fontName = clientTheme.font.substring(
235
234
  clientTheme.font.lastIndexOf('/') + 1,
236
235
  clientTheme.font.indexOf('.')
@@ -4,10 +4,12 @@ import get from 'lodash/get';
4
4
  import find from 'lodash/find';
5
5
  import isEmpty from 'lodash/isEmpty';
6
6
  import isEqual from 'lodash/isEqual';
7
+ import merge from 'lodash/merge';
7
8
  import { t } from 'Framework/i18n';
8
9
 
9
10
  import { Services } from '../ServiceLocator';
10
11
  import { getConf } from '../configuration';
12
+ import { getUrl } from '../Utils/getUrl';
11
13
 
12
14
  import Observable from '../../Utils/Decorators/Observable';
13
15
  import setupDesigner from '../Modules/Designer/setupDesigner';
@@ -232,7 +234,7 @@ export const calculateImageBrightness = image => {
232
234
  const thumbnail = get(image, 'data.thumbnail.url', null);
233
235
  let imageUrl = null;
234
236
  if (thumbnail) {
235
- imageUrl = thumbnail.startsWith('http') ? thumbnail : `${getConf('network.host')}${thumbnail}`;
237
+ imageUrl = getUrl(thumbnail);
236
238
  }
237
239
  const fuzzy = 0.1;
238
240
 
@@ -383,7 +385,7 @@ export const makeOperationsCompatible = (operations, compatibilityInfo, colorPal
383
385
  export const getSvgContent = (() => {
384
386
  const svgContentMap = new Map();
385
387
  return function getSvgContent(url, absolute = false, forceFetch = false) {
386
- const absUrl = absolute ? url : `${getConf('network.host')}${url}`;
388
+ const absUrl = getUrl(url, absolute ? undefined : getConf('network.host'));
387
389
  if (!forceFetch && svgContentMap.has(absUrl)) {
388
390
  return svgContentMap.get(absUrl);
389
391
  }
@@ -1562,17 +1564,20 @@ export default class DesignDataService {
1562
1564
  * @param {function} getDrawingContext
1563
1565
  * @param {object} updateEventObject
1564
1566
  */
1565
- async redrawAllDesignAreas(getDrawingContext, updateEventObject) {
1567
+ async redrawAllDesignAreas(getDrawingContext, updateEventObject, options = {}) {
1566
1568
  const state = Services.store.state;
1567
1569
 
1568
1570
  const showHighlight = get(state, 'designArea.showHighlight');
1569
1571
 
1570
- const textureBuilderConfig = {
1571
- highlight: {
1572
- borderColor: getClientHighlightColor(state),
1573
- backgroundColor: getConf('visualization.designAreaHighlightBackgroundColor'),
1572
+ const textureBuilderConfig = merge(
1573
+ {
1574
+ highlight: {
1575
+ borderColor: getClientHighlightColor(state),
1576
+ backgroundColor: getConf('visualization.designAreaHighlightBackgroundColor'),
1577
+ },
1574
1578
  },
1575
- };
1579
+ options.textureBuilderConfig
1580
+ );
1576
1581
 
1577
1582
  const variantIdentifier = get(updateEventObject, 'data.variant', false);
1578
1583
 
@@ -1582,7 +1587,8 @@ export default class DesignDataService {
1582
1587
  const {
1583
1588
  getTextureImage,
1584
1589
  drawCanvasToArea,
1585
- highlightDesignAreas,
1590
+ drawCanvasToAreaDirect,
1591
+ highlightDesignArea,
1586
1592
  drawOn,
1587
1593
  getParams,
1588
1594
  } = getTextureBuilder(textureBuilderConfig);
@@ -1594,54 +1600,65 @@ export default class DesignDataService {
1594
1600
  }
1595
1601
 
1596
1602
  if (showHighlight) {
1597
- // highlight only the design areas with no mask
1598
- // for the others the outline is added by the maskHandler
1599
- highlightDesignAreas(
1600
- designAreas.filter(designArea => !designAreaAppliesMask(state, designArea))
1601
- );
1602
- }
1603
-
1604
- for (const designArea of designAreas) {
1605
- const canvas = this._getCanvas(this.getDesignAreaByIdentifier(designArea.identifier));
1606
- if (canvas) {
1607
- const releaseLock = await requestLock(canvas);
1608
-
1609
- const selectedObject = get(canvas, 'selectedObject');
1610
- if (selectedObject) {
1611
- selectedObject.selected = false;
1603
+ for (const designArea of designAreas) {
1604
+ const canvas = this._getCanvas(this.getDesignAreaByIdentifier(designArea.identifier));
1605
+ if (!canvas) {
1606
+ continue;
1612
1607
  }
1613
-
1608
+ const releaseLock = await requestLock(canvas);
1614
1609
  const maskHandler = canvas.getMaskHandler();
1615
- let restoreOutlineVisibility;
1616
- if (maskHandler) {
1617
- restoreOutlineVisibility = maskHandler.toggleOutline(showHighlight, {
1610
+ if (designAreaAppliesMask(state, designArea) && maskHandler) {
1611
+ const restoreOutlineVisibility = maskHandler.toggleOutline(true, {
1618
1612
  getZoomFactor: ({ zoom }) => {
1619
1613
  // currentZoom is only available for 2D, for 3D it is always 1
1620
1614
  const threeFactor = Math.min(getParams().currentZoom, 1) || 1;
1621
1615
  return zoom * threeFactor;
1622
1616
  },
1623
1617
  });
1618
+ const restoreOutlineOnly = maskHandler.showOutlineOnly();
1619
+ const drawToContext = canvas.drawToContext.bind(canvas);
1620
+ await drawCanvasToAreaDirect({
1621
+ drawToContext,
1622
+ designArea,
1623
+ });
1624
+ restoreOutlineVisibility?.();
1625
+ restoreOutlineOnly?.();
1626
+ } else {
1627
+ highlightDesignArea(designArea);
1624
1628
  }
1625
- const restoreColorOverlayVisibility = canvas.getColorOverlay()?.toggle(false);
1626
-
1627
- const drawToContext = canvas.drawToContext.bind(canvas);
1628
- const getSvg = () => canvas.getScreenshot(getFontMapping(state));
1629
- await drawCanvasToArea({
1630
- drawToContext,
1631
- designArea,
1632
- getSvg,
1633
- ...(effectEnabled &&
1634
- getVisualizationEffectWithOptions(state, designArea, variantIdentifier)),
1635
- });
1636
- if (maskHandler) {
1637
- restoreOutlineVisibility();
1638
- }
1639
- restoreColorOverlayVisibility && restoreColorOverlayVisibility();
1640
-
1641
1629
  releaseLock();
1642
1630
  }
1643
1631
  }
1644
1632
 
1633
+ for (const designArea of designAreas) {
1634
+ const canvas = this._getCanvas(this.getDesignAreaByIdentifier(designArea.identifier));
1635
+ if (!canvas) {
1636
+ continue;
1637
+ }
1638
+ const releaseLock = await requestLock(canvas);
1639
+
1640
+ const selectedObject = get(canvas, 'selectedObject');
1641
+ if (selectedObject) {
1642
+ selectedObject.selected = false;
1643
+ }
1644
+
1645
+ const restoreColorOverlayVisibility = canvas.getColorOverlay()?.toggle(false);
1646
+ const restoreOutlineVisibility = canvas.getMaskHandler()?.toggleOutline(false);
1647
+
1648
+ const drawToContext = canvas.drawToContext.bind(canvas);
1649
+ const getSvg = () => canvas.getScreenshot(getFontMapping(state));
1650
+ await drawCanvasToArea({
1651
+ drawToContext,
1652
+ designArea,
1653
+ getSvg,
1654
+ ...(effectEnabled &&
1655
+ getVisualizationEffectWithOptions(state, designArea, variantIdentifier)),
1656
+ });
1657
+ restoreColorOverlayVisibility?.();
1658
+ restoreOutlineVisibility?.();
1659
+ releaseLock();
1660
+ }
1661
+
1645
1662
  drawOn(textureCtx);
1646
1663
  };
1647
1664
 
@@ -1708,12 +1725,11 @@ export default class DesignDataService {
1708
1725
  )
1709
1726
  .map(async ({ id, canvas }) => {
1710
1727
  const releaseLock = await requestLock(canvas);
1711
- const maskHandler = canvas.getMaskHandler();
1712
- const restoreOutlineVisibility = maskHandler && maskHandler.toggleOutline(false);
1728
+ const restoreOutlineVisibility = canvas.getMaskHandler()?.toggleOutline(false);
1713
1729
  const restoreColorOverlayVisibility = canvas.getColorOverlay()?.toggle(false);
1714
1730
  const result = [id, await canvas[screenshotFn](fontMapping)];
1715
- restoreOutlineVisibility && restoreOutlineVisibility();
1716
- restoreColorOverlayVisibility && restoreColorOverlayVisibility();
1731
+ restoreOutlineVisibility?.();
1732
+ restoreColorOverlayVisibility?.();
1717
1733
  releaseLock();
1718
1734
  return result;
1719
1735
  })
@@ -7,6 +7,7 @@ import { t } from 'Framework/i18n';
7
7
  import { prepareImageObjectData, prepareObjectData } from 'App/Modules/Designer/Utils/Transformers';
8
8
  import { Services } from '../ServiceLocator';
9
9
  import { getConf } from '../configuration';
10
+ import { getUrl } from '../Utils/getUrl';
10
11
  import {
11
12
  getPreviewUrlFromImageData,
12
13
  isEditMode,
@@ -187,7 +188,7 @@ export default class DesignerService {
187
188
  throw new Error('Preview image url is not specified!');
188
189
  }
189
190
  Services.store.dispatch(updateUploadDelayed(false));
190
- return url.startsWith('http') ? url : `${getConf('network.host')}${url}`;
191
+ return getUrl(url);
191
192
  }
192
193
 
193
194
  async addImageFromUrl(canvas, url, imageData, options = {}) {
@@ -0,0 +1,16 @@
1
+ import { getConf } from '../configuration';
2
+
3
+ /**
4
+ * Resolves a resource URL: absolute URLs (starting with "http") are returned as-is,
5
+ * otherwise the host is prepended.
6
+ * @param {string} url - Resource path or absolute URL
7
+ * @param {string} [host=getConf('network.host')] - Host to prepend for relative URLs (uses default if falsy)
8
+ * @returns {string} Resolved URL
9
+ */
10
+ export function getUrl(url, host) {
11
+ if (url == null || url === '') {
12
+ return url;
13
+ }
14
+ const resolvedHost = host || getConf('network.host');
15
+ return url.startsWith('http') ? url : `${resolvedHost}${url}`;
16
+ }
@@ -225,6 +225,9 @@ let applicationConfiguration = {
225
225
 
226
226
  // switch to the previously selected view when selecting a component that has no view specified
227
227
  switchViewOnComponentSelection: true,
228
+ parameterParser: (name, value) => {
229
+ return value;
230
+ },
228
231
  };
229
232
 
230
233
  function preventLeavingPage() {
@@ -251,7 +254,10 @@ export function init() {
251
254
  if (externalConfig) {
252
255
  applicationConfiguration = merge(applicationConfiguration, externalConfig);
253
256
  }
254
- applicationConfiguration = merge(applicationConfiguration, getQueryParams());
257
+ applicationConfiguration = merge(
258
+ applicationConfiguration,
259
+ getQueryParams(applicationConfiguration.parameterParser)
260
+ );
255
261
 
256
262
  Api.init(applicationConfiguration.network);
257
263
 
@@ -260,7 +266,7 @@ export function init() {
260
266
  return applicationConfiguration;
261
267
  }
262
268
 
263
- export function getQueryParams() {
269
+ export function getQueryParams(parameterParser = (_name, value) => value) {
264
270
  const query = new URLSearchParams(location.search);
265
271
 
266
272
  const queryConf = {};
@@ -347,6 +353,20 @@ export function getQueryParams() {
347
353
  }
348
354
  }
349
355
 
356
+ if (query.has('_country')) {
357
+ const country = query.get('_country');
358
+ if (country && country.length === 2) {
359
+ Api.setGETParameter('_country', country);
360
+ }
361
+ }
362
+
363
+ // Forward all query parameters starting with "_" to Api.setGETParameter
364
+ for (const [name, value] of query.entries()) {
365
+ if (name.startsWith('_')) {
366
+ Api.setGETParameter(name, parameterParser(name, value));
367
+ }
368
+ }
369
+
350
370
  return queryConf;
351
371
  }
352
372