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.mjs CHANGED
@@ -360,7 +360,7 @@ class Cache {
360
360
  }
361
361
  const cache = new Cache();
362
362
 
363
- var version = "6.7.11";
363
+ var version = "6.7.13";
364
364
 
365
365
  // use this syntax so babel plugin see this import here
366
366
  const VERSION = version;
@@ -1808,7 +1808,8 @@ const composeMatrix = options => {
1808
1808
  const loadImage = function (url) {
1809
1809
  let {
1810
1810
  signal,
1811
- crossOrigin = null
1811
+ crossOrigin = null,
1812
+ fallbackToEmptyImage = false
1812
1813
  } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1813
1814
  return new Promise(function (resolve, reject) {
1814
1815
  if (signal && signal.aborted) {
@@ -1825,9 +1826,12 @@ const loadImage = function (url) {
1825
1826
  once: true
1826
1827
  });
1827
1828
  }
1828
- const done = function () {
1829
+ const cleanup = function () {
1829
1830
  img.onload = img.onerror = null;
1830
1831
  abort && (signal === null || signal === void 0 ? void 0 : signal.removeEventListener('abort', abort));
1832
+ };
1833
+ const done = function () {
1834
+ cleanup();
1831
1835
  resolve(img);
1832
1836
  };
1833
1837
  if (!url) {
@@ -1836,8 +1840,15 @@ const loadImage = function (url) {
1836
1840
  }
1837
1841
  img.onload = done;
1838
1842
  img.onerror = function () {
1839
- abort && (signal === null || signal === void 0 ? void 0 : signal.removeEventListener('abort', abort));
1840
- reject(new FabricError(`Error loading ${img.src}`));
1843
+ const failedSrc = img.src;
1844
+ cleanup();
1845
+ if (fallbackToEmptyImage) {
1846
+ log('warn', 'Image failed to load, continuing with an empty image source', failedSrc);
1847
+ img.src = '';
1848
+ resolve(img);
1849
+ return;
1850
+ }
1851
+ reject(new FabricError(`Error loading ${failedSrc}`));
1841
1852
  };
1842
1853
  crossOrigin && (img.crossOrigin = crossOrigin);
1843
1854
  img.src = url;
@@ -4040,9 +4051,13 @@ class Pattern {
4040
4051
  patternTransform,
4041
4052
  ...otherOptions
4042
4053
  } = _ref2;
4054
+ const {
4055
+ crossOrigin
4056
+ } = otherOptions;
4043
4057
  const img = await loadImage(source, {
4044
4058
  ...options,
4045
- crossOrigin: otherOptions.crossOrigin
4059
+ crossOrigin,
4060
+ fallbackToEmptyImage: true
4046
4061
  });
4047
4062
  return new this({
4048
4063
  ...otherOptions,
@@ -12234,9 +12249,17 @@ class Group extends createCollectionMixin(FabricObject) {
12234
12249
  _toSVG(reviver) {
12235
12250
  const svgString = ['<g ', 'COMMON_PARTS', ' >\n'];
12236
12251
  const bg = this._createSVGBgRect(reviver);
12252
+ const groupTransformMatrix = this.calcTransformMatrix();
12237
12253
  bg && svgString.push('\t\t', bg);
12238
12254
  for (let i = 0; i < this._objects.length; i++) {
12239
- svgString.push('\t\t', this._objects[i].toSVG(reviver));
12255
+ const object = this._objects[i];
12256
+ if (object.group && object.group !== this) {
12257
+ // 组内对象被 ActiveSelection 临时接管时,需要补回当前组坐标系的变换。
12258
+ const planeChangeMatrix = calcPlaneChangeMatrix(object.group.calcTransformMatrix(), groupTransformMatrix);
12259
+ svgString.push('\t\t<g transform="', matrixToSVG(planeChangeMatrix), '">\n\t\t', object.toSVG(reviver), '\t\t</g>\n');
12260
+ continue;
12261
+ }
12262
+ svgString.push('\t\t', object.toSVG(reviver));
12240
12263
  }
12241
12264
  svgString.push('</g>\n');
12242
12265
  return svgString;
@@ -25936,11 +25959,13 @@ class FabricImage extends FabricObject {
25936
25959
  } = _ref;
25937
25960
  return Promise.all([loadImage(src, {
25938
25961
  ...options,
25939
- crossOrigin
25962
+ crossOrigin,
25963
+ fallbackToEmptyImage: true
25940
25964
  }), f && enlivenObjects(f, options),
25941
25965
  // TODO: redundant - handled by enlivenObjectEnlivables
25942
25966
  rf && enlivenObjects([rf], options), enlivenObjectEnlivables(object, options)]).then(_ref2 => {
25943
- let [el, filters = [], [resizeFilter] = [], hydratedProps = {}] = _ref2;
25967
+ let [el, filters = [], resizeFilters = [], hydratedProps = {}] = _ref2;
25968
+ const [resizeFilter] = resizeFilters;
25944
25969
  return new this(el, {
25945
25970
  ...object,
25946
25971
  // TODO: this creates a difference between image creation and restoring from JSON