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
@@ -418,7 +418,7 @@ class Cache {
418
418
  }
419
419
  const cache = new Cache();
420
420
 
421
- var version = "6.7.11";
421
+ var version = "6.7.13";
422
422
 
423
423
  // use this syntax so babel plugin see this import here
424
424
  const VERSION = version;
@@ -1866,7 +1866,8 @@ const composeMatrix = options => {
1866
1866
  const loadImage = function (url) {
1867
1867
  let {
1868
1868
  signal,
1869
- crossOrigin = null
1869
+ crossOrigin = null,
1870
+ fallbackToEmptyImage = false
1870
1871
  } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1871
1872
  return new Promise(function (resolve, reject) {
1872
1873
  if (signal && signal.aborted) {
@@ -1883,9 +1884,12 @@ const loadImage = function (url) {
1883
1884
  once: true
1884
1885
  });
1885
1886
  }
1886
- const done = function () {
1887
+ const cleanup = function () {
1887
1888
  img.onload = img.onerror = null;
1888
1889
  abort && (signal === null || signal === void 0 ? void 0 : signal.removeEventListener('abort', abort));
1890
+ };
1891
+ const done = function () {
1892
+ cleanup();
1889
1893
  resolve(img);
1890
1894
  };
1891
1895
  if (!url) {
@@ -1894,8 +1898,15 @@ const loadImage = function (url) {
1894
1898
  }
1895
1899
  img.onload = done;
1896
1900
  img.onerror = function () {
1897
- abort && (signal === null || signal === void 0 ? void 0 : signal.removeEventListener('abort', abort));
1898
- reject(new FabricError(`Error loading ${img.src}`));
1901
+ const failedSrc = img.src;
1902
+ cleanup();
1903
+ if (fallbackToEmptyImage) {
1904
+ log('warn', 'Image failed to load, continuing with an empty image source', failedSrc);
1905
+ img.src = '';
1906
+ resolve(img);
1907
+ return;
1908
+ }
1909
+ reject(new FabricError(`Error loading ${failedSrc}`));
1899
1910
  };
1900
1911
  crossOrigin && (img.crossOrigin = crossOrigin);
1901
1912
  img.src = url;
@@ -4098,9 +4109,13 @@ class Pattern {
4098
4109
  patternTransform,
4099
4110
  ...otherOptions
4100
4111
  } = _ref2;
4112
+ const {
4113
+ crossOrigin
4114
+ } = otherOptions;
4101
4115
  const img = await loadImage(source, {
4102
4116
  ...options,
4103
- crossOrigin: otherOptions.crossOrigin
4117
+ crossOrigin,
4118
+ fallbackToEmptyImage: true
4104
4119
  });
4105
4120
  return new this({
4106
4121
  ...otherOptions,
@@ -12292,9 +12307,17 @@ class Group extends createCollectionMixin(FabricObject) {
12292
12307
  _toSVG(reviver) {
12293
12308
  const svgString = ['<g ', 'COMMON_PARTS', ' >\n'];
12294
12309
  const bg = this._createSVGBgRect(reviver);
12310
+ const groupTransformMatrix = this.calcTransformMatrix();
12295
12311
  bg && svgString.push('\t\t', bg);
12296
12312
  for (let i = 0; i < this._objects.length; i++) {
12297
- svgString.push('\t\t', this._objects[i].toSVG(reviver));
12313
+ const object = this._objects[i];
12314
+ if (object.group && object.group !== this) {
12315
+ // 组内对象被 ActiveSelection 临时接管时,需要补回当前组坐标系的变换。
12316
+ const planeChangeMatrix = calcPlaneChangeMatrix(object.group.calcTransformMatrix(), groupTransformMatrix);
12317
+ svgString.push('\t\t<g transform="', matrixToSVG(planeChangeMatrix), '">\n\t\t', object.toSVG(reviver), '\t\t</g>\n');
12318
+ continue;
12319
+ }
12320
+ svgString.push('\t\t', object.toSVG(reviver));
12298
12321
  }
12299
12322
  svgString.push('</g>\n');
12300
12323
  return svgString;
@@ -25994,11 +26017,13 @@ class FabricImage extends FabricObject {
25994
26017
  } = _ref;
25995
26018
  return Promise.all([loadImage(src, {
25996
26019
  ...options,
25997
- crossOrigin
26020
+ crossOrigin,
26021
+ fallbackToEmptyImage: true
25998
26022
  }), f && enlivenObjects(f, options),
25999
26023
  // TODO: redundant - handled by enlivenObjectEnlivables
26000
26024
  rf && enlivenObjects([rf], options), enlivenObjectEnlivables(object, options)]).then(_ref2 => {
26001
- let [el, filters = [], [resizeFilter] = [], hydratedProps = {}] = _ref2;
26025
+ let [el, filters = [], resizeFilters = [], hydratedProps = {}] = _ref2;
26026
+ const [resizeFilter] = resizeFilters;
26002
26027
  return new this(el, {
26003
26028
  ...object,
26004
26029
  // TODO: this creates a difference between image creation and restoring from JSON