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.
@@ -1366,6 +1366,31 @@ var _excluded = ["mimeType", "quality", "dpi", "dpiMetadata"],
1366
1366
  _excluded2 = ["mimeType", "quality"],
1367
1367
  _excluded3 = ["fileName"],
1368
1368
  _excluded4 = ["fileName"];
1369
+
1370
+ // Detect embedded base64 data URLs (data:...;base64,...).
1371
+ // These bloat exported JSON significantly (a single image can be 1MB+).
1372
+ // Regular http/https/blob URLs are preserved.
1373
+ var isBase64DataUrl = function isBase64DataUrl(v) {
1374
+ return typeof v === 'string' && v.startsWith('data:') && v.includes(';base64,');
1375
+ };
1376
+ var _stripBase64FromElement = function stripBase64FromElement(el) {
1377
+ var out = _objectSpread2({}, el);
1378
+ if (isBase64DataUrl(out.src)) out.src = '';
1379
+ if (isBase64DataUrl(out.clipSrc)) out.clipSrc = '';
1380
+ if (Array.isArray(out.children)) {
1381
+ out.children = out.children.map(_stripBase64FromElement);
1382
+ }
1383
+ return out;
1384
+ };
1385
+ var stripBase64FromExport = function stripBase64FromExport(data) {
1386
+ return _objectSpread2(_objectSpread2({}, data), {}, {
1387
+ pages: (data.pages || []).map(function (page) {
1388
+ return _objectSpread2(_objectSpread2({}, page), {}, {
1389
+ children: (page.children || []).map(_stripBase64FromElement)
1390
+ });
1391
+ })
1392
+ });
1393
+ };
1369
1394
  var Font = types.model('Font', {
1370
1395
  fontFamily: types.string,
1371
1396
  url: types.optional(types.string, ''),
@@ -2070,8 +2095,11 @@ var Store = types.model('Store', {
2070
2095
  saveAsJSON: function saveAsJSON() {
2071
2096
  var _ref0 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
2072
2097
  _ref0$fileName = _ref0.fileName,
2073
- fileName = _ref0$fileName === void 0 ? 'design.json' : _ref0$fileName;
2074
- var json = JSON.stringify(self.toJSON(), null, 2);
2098
+ fileName = _ref0$fileName === void 0 ? 'design.json' : _ref0$fileName,
2099
+ _ref0$stripBase = _ref0.stripBase64,
2100
+ stripBase64 = _ref0$stripBase === void 0 ? true : _ref0$stripBase;
2101
+ var data = stripBase64 ? stripBase64FromExport(self.toJSON()) : self.toJSON();
2102
+ var json = JSON.stringify(data, null, 2);
2075
2103
  var blob = new Blob([json], {
2076
2104
  type: 'application/json'
2077
2105
  });