fabric-vectr 6.7.11 → 6.7.13

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.
Files changed (52) hide show
  1. package/dist/index.js +34 -9
  2. package/dist/index.js.map +1 -1
  3. package/dist/index.min.js +1 -1
  4. package/dist/index.min.js.map +1 -1
  5. package/dist/index.min.mjs +1 -1
  6. package/dist/index.min.mjs.map +1 -1
  7. package/dist/index.mjs +34 -9
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/index.node.cjs +34 -9
  10. package/dist/index.node.cjs.map +1 -1
  11. package/dist/index.node.d.ts +6 -6
  12. package/dist/index.node.mjs +34 -9
  13. package/dist/index.node.mjs.map +1 -1
  14. package/dist/package.json.min.mjs +1 -1
  15. package/dist/package.json.mjs +1 -1
  16. package/dist/src/Pattern/Pattern.d.ts.map +1 -1
  17. package/dist/src/Pattern/Pattern.min.mjs +1 -1
  18. package/dist/src/Pattern/Pattern.min.mjs.map +1 -1
  19. package/dist/src/Pattern/Pattern.mjs +5 -1
  20. package/dist/src/Pattern/Pattern.mjs.map +1 -1
  21. package/dist/src/shapes/Group.d.ts.map +1 -1
  22. package/dist/src/shapes/Group.min.mjs +1 -1
  23. package/dist/src/shapes/Group.min.mjs.map +1 -1
  24. package/dist/src/shapes/Group.mjs +11 -1
  25. package/dist/src/shapes/Group.mjs.map +1 -1
  26. package/dist/src/shapes/Image.d.ts +2 -2
  27. package/dist/src/shapes/Image.d.ts.map +1 -1
  28. package/dist/src/shapes/Image.min.mjs +1 -1
  29. package/dist/src/shapes/Image.min.mjs.map +1 -1
  30. package/dist/src/shapes/Image.mjs +4 -2
  31. package/dist/src/shapes/Image.mjs.map +1 -1
  32. package/dist/src/util/misc/objectEnlive.d.ts +6 -1
  33. package/dist/src/util/misc/objectEnlive.d.ts.map +1 -1
  34. package/dist/src/util/misc/objectEnlive.min.mjs +1 -1
  35. package/dist/src/util/misc/objectEnlive.min.mjs.map +1 -1
  36. package/dist/src/util/misc/objectEnlive.mjs +16 -5
  37. package/dist/src/util/misc/objectEnlive.mjs.map +1 -1
  38. package/dist-extensions/src/Pattern/Pattern.d.ts.map +1 -1
  39. package/dist-extensions/src/shapes/Group.d.ts.map +1 -1
  40. package/dist-extensions/src/shapes/Image.d.ts +2 -2
  41. package/dist-extensions/src/shapes/Image.d.ts.map +1 -1
  42. package/dist-extensions/src/util/misc/objectEnlive.d.ts +6 -1
  43. package/dist-extensions/src/util/misc/objectEnlive.d.ts.map +1 -1
  44. package/package.json +1 -1
  45. package/src/Pattern/Pattern.spec.ts +63 -0
  46. package/src/Pattern/Pattern.ts +3 -1
  47. package/src/shapes/Group.spec.ts +40 -0
  48. package/src/shapes/Group.ts +20 -1
  49. package/src/shapes/Image.spec.ts +21 -2
  50. package/src/shapes/Image.ts +24 -12
  51. package/src/util/misc/objectEnlive.spec.ts +49 -2
  52. package/src/util/misc/objectEnlive.ts +29 -5
package/dist/index.js CHANGED
@@ -366,7 +366,7 @@
366
366
  }
367
367
  const cache = new Cache();
368
368
 
369
- var version = "6.7.11";
369
+ var version = "6.7.13";
370
370
 
371
371
  // use this syntax so babel plugin see this import here
372
372
  const VERSION = version;
@@ -1814,7 +1814,8 @@
1814
1814
  const loadImage = function (url) {
1815
1815
  let {
1816
1816
  signal,
1817
- crossOrigin = null
1817
+ crossOrigin = null,
1818
+ fallbackToEmptyImage = false
1818
1819
  } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1819
1820
  return new Promise(function (resolve, reject) {
1820
1821
  if (signal && signal.aborted) {
@@ -1831,9 +1832,12 @@
1831
1832
  once: true
1832
1833
  });
1833
1834
  }
1834
- const done = function () {
1835
+ const cleanup = function () {
1835
1836
  img.onload = img.onerror = null;
1836
1837
  abort && (signal === null || signal === void 0 ? void 0 : signal.removeEventListener('abort', abort));
1838
+ };
1839
+ const done = function () {
1840
+ cleanup();
1837
1841
  resolve(img);
1838
1842
  };
1839
1843
  if (!url) {
@@ -1842,8 +1846,15 @@
1842
1846
  }
1843
1847
  img.onload = done;
1844
1848
  img.onerror = function () {
1845
- abort && (signal === null || signal === void 0 ? void 0 : signal.removeEventListener('abort', abort));
1846
- reject(new FabricError(`Error loading ${img.src}`));
1849
+ const failedSrc = img.src;
1850
+ cleanup();
1851
+ if (fallbackToEmptyImage) {
1852
+ log('warn', 'Image failed to load, continuing with an empty image source', failedSrc);
1853
+ img.src = '';
1854
+ resolve(img);
1855
+ return;
1856
+ }
1857
+ reject(new FabricError(`Error loading ${failedSrc}`));
1847
1858
  };
1848
1859
  crossOrigin && (img.crossOrigin = crossOrigin);
1849
1860
  img.src = url;
@@ -4046,9 +4057,13 @@
4046
4057
  patternTransform,
4047
4058
  ...otherOptions
4048
4059
  } = _ref2;
4060
+ const {
4061
+ crossOrigin
4062
+ } = otherOptions;
4049
4063
  const img = await loadImage(source, {
4050
4064
  ...options,
4051
- crossOrigin: otherOptions.crossOrigin
4065
+ crossOrigin,
4066
+ fallbackToEmptyImage: true
4052
4067
  });
4053
4068
  return new this({
4054
4069
  ...otherOptions,
@@ -12240,9 +12255,17 @@
12240
12255
  _toSVG(reviver) {
12241
12256
  const svgString = ['<g ', 'COMMON_PARTS', ' >\n'];
12242
12257
  const bg = this._createSVGBgRect(reviver);
12258
+ const groupTransformMatrix = this.calcTransformMatrix();
12243
12259
  bg && svgString.push('\t\t', bg);
12244
12260
  for (let i = 0; i < this._objects.length; i++) {
12245
- svgString.push('\t\t', this._objects[i].toSVG(reviver));
12261
+ const object = this._objects[i];
12262
+ if (object.group && object.group !== this) {
12263
+ // 组内对象被 ActiveSelection 临时接管时,需要补回当前组坐标系的变换。
12264
+ const planeChangeMatrix = calcPlaneChangeMatrix(object.group.calcTransformMatrix(), groupTransformMatrix);
12265
+ svgString.push('\t\t<g transform="', matrixToSVG(planeChangeMatrix), '">\n\t\t', object.toSVG(reviver), '\t\t</g>\n');
12266
+ continue;
12267
+ }
12268
+ svgString.push('\t\t', object.toSVG(reviver));
12246
12269
  }
12247
12270
  svgString.push('</g>\n');
12248
12271
  return svgString;
@@ -25942,11 +25965,13 @@
25942
25965
  } = _ref;
25943
25966
  return Promise.all([loadImage(src, {
25944
25967
  ...options,
25945
- crossOrigin
25968
+ crossOrigin,
25969
+ fallbackToEmptyImage: true
25946
25970
  }), f && enlivenObjects(f, options),
25947
25971
  // TODO: redundant - handled by enlivenObjectEnlivables
25948
25972
  rf && enlivenObjects([rf], options), enlivenObjectEnlivables(object, options)]).then(_ref2 => {
25949
- let [el, filters = [], [resizeFilter] = [], hydratedProps = {}] = _ref2;
25973
+ let [el, filters = [], resizeFilters = [], hydratedProps = {}] = _ref2;
25974
+ const [resizeFilter] = resizeFilters;
25950
25975
  return new this(el, {
25951
25976
  ...object,
25952
25977
  // TODO: this creates a difference between image creation and restoring from JSON