labellife-design-tool 2.1.8 → 2.2.0

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/esm/index.js CHANGED
@@ -1427,6 +1427,31 @@ var _excluded$5 = ["mimeType", "quality", "dpi", "dpiMetadata"],
1427
1427
  _excluded2$1 = ["mimeType", "quality"],
1428
1428
  _excluded3$1 = ["fileName"],
1429
1429
  _excluded4 = ["fileName"];
1430
+
1431
+ // Detect embedded base64 data URLs (data:...;base64,...).
1432
+ // These bloat exported JSON significantly (a single image can be 1MB+).
1433
+ // Regular http/https/blob URLs are preserved.
1434
+ var isBase64DataUrl = function isBase64DataUrl(v) {
1435
+ return typeof v === 'string' && v.startsWith('data:') && v.includes(';base64,');
1436
+ };
1437
+ var _stripBase64FromElement = function stripBase64FromElement(el) {
1438
+ var out = _objectSpread2({}, el);
1439
+ if (isBase64DataUrl(out.src)) out.src = '';
1440
+ if (isBase64DataUrl(out.clipSrc)) out.clipSrc = '';
1441
+ if (Array.isArray(out.children)) {
1442
+ out.children = out.children.map(_stripBase64FromElement);
1443
+ }
1444
+ return out;
1445
+ };
1446
+ var stripBase64FromExport = function stripBase64FromExport(data) {
1447
+ return _objectSpread2(_objectSpread2({}, data), {}, {
1448
+ pages: (data.pages || []).map(function (page) {
1449
+ return _objectSpread2(_objectSpread2({}, page), {}, {
1450
+ children: (page.children || []).map(_stripBase64FromElement)
1451
+ });
1452
+ })
1453
+ });
1454
+ };
1430
1455
  var Font = types.model('Font', {
1431
1456
  fontFamily: types.string,
1432
1457
  url: types.optional(types.string, ''),
@@ -2131,8 +2156,11 @@ var Store = types.model('Store', {
2131
2156
  saveAsJSON: function saveAsJSON() {
2132
2157
  var _ref0 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
2133
2158
  _ref0$fileName = _ref0.fileName,
2134
- fileName = _ref0$fileName === void 0 ? 'design.json' : _ref0$fileName;
2135
- var json = JSON.stringify(self.toJSON(), null, 2);
2159
+ fileName = _ref0$fileName === void 0 ? 'design.json' : _ref0$fileName,
2160
+ _ref0$stripBase = _ref0.stripBase64,
2161
+ stripBase64 = _ref0$stripBase === void 0 ? true : _ref0$stripBase;
2162
+ var data = stripBase64 ? stripBase64FromExport(self.toJSON()) : self.toJSON();
2163
+ var json = JSON.stringify(data, null, 2);
2136
2164
  var blob = new Blob([json], {
2137
2165
  type: 'application/json'
2138
2166
  });
@@ -8467,7 +8495,9 @@ var DefaultDownloadButton = observer(function (_ref9) {
8467
8495
  _useState6 = _slicedToArray(_useState5, 2),
8468
8496
  fileType = _useState6[0],
8469
8497
  setFileType = _useState6[1];
8470
- var _useState7 = useState(1),
8498
+ // Default quality so pixelRatio=1 (output = template's own pixel size).
8499
+ // qualityToPixelRatio(q) = q * 3, so q = 1/3 → pixelRatio = 1.
8500
+ var _useState7 = useState(1 / 3),
8471
8501
  _useState8 = _slicedToArray(_useState7, 2),
8472
8502
  quality = _useState8[0],
8473
8503
  setQuality = _useState8[1];
@@ -8838,7 +8868,7 @@ var Toolbar = observer(function (_ref11) {
8838
8868
  children: [/*#__PURE__*/jsxs(Box, {
8839
8869
  sx: _objectSpread2(_objectSpread2({}, rowSx), {}, {
8840
8870
  minHeight: 52,
8841
- borderBottom: element ? '1px solid #f0f0f0' : 'none'
8871
+ borderBottom: '1px solid #f0f0f0'
8842
8872
  }),
8843
8873
  children: [/*#__PURE__*/jsx(Tooltip, {
8844
8874
  title: t('toolbar.undo', 'Undo'),
@@ -8951,12 +8981,13 @@ var Toolbar = observer(function (_ref11) {
8951
8981
  }), DownloadButton && /*#__PURE__*/jsx(DownloadButton, {
8952
8982
  store: store
8953
8983
  })]
8954
- }), element && /*#__PURE__*/jsx(Box, {
8984
+ }), /*#__PURE__*/jsx(Box, {
8955
8985
  sx: _objectSpread2(_objectSpread2({}, rowSx), {}, {
8956
8986
  minHeight: 44,
8957
- backgroundColor: '#fafafa'
8987
+ backgroundColor: '#fafafa',
8988
+ visibility: element ? 'visible' : 'hidden'
8958
8989
  }),
8959
- children: /*#__PURE__*/jsx(CommonControls, {
8990
+ children: element && /*#__PURE__*/jsx(CommonControls, {
8960
8991
  element: element,
8961
8992
  store: store
8962
8993
  })