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
@@ -2,9 +2,9 @@ import type { JpegConfig, PngConfig } from 'canvas';
2
2
  import { Canvas as CanvasBase, StaticCanvas as StaticCanvasBase } from './fabric';
3
3
  export * from './fabric';
4
4
  export declare class StaticCanvas extends StaticCanvasBase {
5
- getNodeCanvas(): NodeCanvas;
6
- createPNGStream(opts?: PngConfig): any;
7
- createJPEGStream(opts?: JpegConfig): any;
5
+ getNodeCanvas(): import("canvas").Canvas;
6
+ createPNGStream(opts?: PngConfig): import("canvas").PNGStream;
7
+ createJPEGStream(opts?: JpegConfig): import("canvas").JPEGStream;
8
8
  }
9
9
  /**
10
10
  * **NOTICE**:
@@ -13,8 +13,8 @@ export declare class StaticCanvas extends StaticCanvasBase {
13
13
  * Use {@link StaticCanvas} instead.
14
14
  */
15
15
  export declare class Canvas extends CanvasBase {
16
- getNodeCanvas(): NodeCanvas;
17
- createPNGStream(opts?: PngConfig): any;
18
- createJPEGStream(opts?: JpegConfig): any;
16
+ getNodeCanvas(): import("canvas").Canvas;
17
+ createPNGStream(opts?: PngConfig): import("canvas").PNGStream;
18
+ createJPEGStream(opts?: JpegConfig): import("canvas").JPEGStream;
19
19
  }
20
20
  //# sourceMappingURL=index.node.d.ts.map
@@ -416,7 +416,7 @@ class Cache {
416
416
  }
417
417
  const cache = new Cache();
418
418
 
419
- var version = "6.7.11";
419
+ var version = "6.7.13";
420
420
 
421
421
  // use this syntax so babel plugin see this import here
422
422
  const VERSION = version;
@@ -1864,7 +1864,8 @@ const composeMatrix = options => {
1864
1864
  const loadImage = function (url) {
1865
1865
  let {
1866
1866
  signal,
1867
- crossOrigin = null
1867
+ crossOrigin = null,
1868
+ fallbackToEmptyImage = false
1868
1869
  } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1869
1870
  return new Promise(function (resolve, reject) {
1870
1871
  if (signal && signal.aborted) {
@@ -1881,9 +1882,12 @@ const loadImage = function (url) {
1881
1882
  once: true
1882
1883
  });
1883
1884
  }
1884
- const done = function () {
1885
+ const cleanup = function () {
1885
1886
  img.onload = img.onerror = null;
1886
1887
  abort && (signal === null || signal === void 0 ? void 0 : signal.removeEventListener('abort', abort));
1888
+ };
1889
+ const done = function () {
1890
+ cleanup();
1887
1891
  resolve(img);
1888
1892
  };
1889
1893
  if (!url) {
@@ -1892,8 +1896,15 @@ const loadImage = function (url) {
1892
1896
  }
1893
1897
  img.onload = done;
1894
1898
  img.onerror = function () {
1895
- abort && (signal === null || signal === void 0 ? void 0 : signal.removeEventListener('abort', abort));
1896
- reject(new FabricError(`Error loading ${img.src}`));
1899
+ const failedSrc = img.src;
1900
+ cleanup();
1901
+ if (fallbackToEmptyImage) {
1902
+ log('warn', 'Image failed to load, continuing with an empty image source', failedSrc);
1903
+ img.src = '';
1904
+ resolve(img);
1905
+ return;
1906
+ }
1907
+ reject(new FabricError(`Error loading ${failedSrc}`));
1897
1908
  };
1898
1909
  crossOrigin && (img.crossOrigin = crossOrigin);
1899
1910
  img.src = url;
@@ -4096,9 +4107,13 @@ class Pattern {
4096
4107
  patternTransform,
4097
4108
  ...otherOptions
4098
4109
  } = _ref2;
4110
+ const {
4111
+ crossOrigin
4112
+ } = otherOptions;
4099
4113
  const img = await loadImage(source, {
4100
4114
  ...options,
4101
- crossOrigin: otherOptions.crossOrigin
4115
+ crossOrigin,
4116
+ fallbackToEmptyImage: true
4102
4117
  });
4103
4118
  return new this({
4104
4119
  ...otherOptions,
@@ -12290,9 +12305,17 @@ class Group extends createCollectionMixin(FabricObject) {
12290
12305
  _toSVG(reviver) {
12291
12306
  const svgString = ['<g ', 'COMMON_PARTS', ' >\n'];
12292
12307
  const bg = this._createSVGBgRect(reviver);
12308
+ const groupTransformMatrix = this.calcTransformMatrix();
12293
12309
  bg && svgString.push('\t\t', bg);
12294
12310
  for (let i = 0; i < this._objects.length; i++) {
12295
- svgString.push('\t\t', this._objects[i].toSVG(reviver));
12311
+ const object = this._objects[i];
12312
+ if (object.group && object.group !== this) {
12313
+ // 组内对象被 ActiveSelection 临时接管时,需要补回当前组坐标系的变换。
12314
+ const planeChangeMatrix = calcPlaneChangeMatrix(object.group.calcTransformMatrix(), groupTransformMatrix);
12315
+ svgString.push('\t\t<g transform="', matrixToSVG(planeChangeMatrix), '">\n\t\t', object.toSVG(reviver), '\t\t</g>\n');
12316
+ continue;
12317
+ }
12318
+ svgString.push('\t\t', object.toSVG(reviver));
12296
12319
  }
12297
12320
  svgString.push('</g>\n');
12298
12321
  return svgString;
@@ -25992,11 +26015,13 @@ class FabricImage extends FabricObject {
25992
26015
  } = _ref;
25993
26016
  return Promise.all([loadImage(src, {
25994
26017
  ...options,
25995
- crossOrigin
26018
+ crossOrigin,
26019
+ fallbackToEmptyImage: true
25996
26020
  }), f && enlivenObjects(f, options),
25997
26021
  // TODO: redundant - handled by enlivenObjectEnlivables
25998
26022
  rf && enlivenObjects([rf], options), enlivenObjectEnlivables(object, options)]).then(_ref2 => {
25999
- let [el, filters = [], [resizeFilter] = [], hydratedProps = {}] = _ref2;
26023
+ let [el, filters = [], resizeFilters = [], hydratedProps = {}] = _ref2;
26024
+ const [resizeFilter] = resizeFilters;
26000
26025
  return new this(el, {
26001
26026
  ...object,
26002
26027
  // TODO: this creates a difference between image creation and restoring from JSON