Skip to content

Commit bf87894

Browse files
committed
bump 6.6.1
1 parent a6374b4 commit bf87894

11 files changed

+89
-43
lines changed

Diff for: CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## [next]
44

5+
## [6.6.1]
6+
57
- fix(): FabricImage was missing cachekey when filtering [#10441](https://github.com/fabricjs/fabric.js/pull/10441)
68

79
## [6.6.0]

Diff for: dist/index.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: dist/index.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: dist/index.min.mjs

+1-1
Large diffs are not rendered by default.

Diff for: dist/index.min.mjs.map

+1-1
Large diffs are not rendered by default.

Diff for: dist/index.mjs

+39-17
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ class Cache {
405405
}
406406
const cache = new Cache();
407407

408-
var version = "6.5.3";
408+
var version = "6.6.1";
409409

410410
// use this syntax so babel plugin see this import here
411411
const VERSION = version;
@@ -1579,6 +1579,9 @@ const toDataURL = (canvasEl, format, quality) => canvasEl.toDataURL("image/".con
15791579
const isHTMLCanvas = canvas => {
15801580
return !!canvas && canvas.getContext !== undefined;
15811581
};
1582+
const toBlob = (canvasEl, format, quality) => new Promise((resolve, _) => {
1583+
canvasEl.toBlob(resolve, "image/".concat(format), quality);
1584+
});
15821585

15831586
/**
15841587
* Transforms degrees to radians.
@@ -4140,6 +4143,17 @@ class StaticCanvas extends createCollectionMixin(CommonMethods) {
41404143
const finalMultiplier = multiplier * (enableRetinaScaling ? this.getRetinaScaling() : 1);
41414144
return toDataURL(this.toCanvasElement(finalMultiplier, options), format, quality);
41424145
}
4146+
toBlob() {
4147+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4148+
const {
4149+
format = 'png',
4150+
quality = 1,
4151+
multiplier = 1,
4152+
enableRetinaScaling = false
4153+
} = options;
4154+
const finalMultiplier = multiplier * (enableRetinaScaling ? this.getRetinaScaling() : 1);
4155+
return toBlob(this.toCanvasElement(finalMultiplier, options), format, quality);
4156+
}
41434157

41444158
/**
41454159
* Create a new HTMLCanvas element painted with the current canvas content.
@@ -7123,14 +7137,15 @@ let FabricObject$1 = class FabricObject extends ObjectGeometry {
71237137
}
71247138

71257139
/**
7126-
* When set to `true`, force the object to have its own cache, even if it is inside a group
7140+
* When returns `true`, force the object to have its own cache, even if it is inside a group
71277141
* it may be needed when your object behave in a particular way on the cache and always needs
71287142
* its own isolated canvas to render correctly.
71297143
* Created to be overridden
71307144
* since 1.7.12
71317145
* @returns Boolean
71327146
*/
71337147
needsItsOwnCache() {
7148+
// TODO re-evaluate this shadow condition
71347149
if (this.paintFirst === STROKE && this.hasFill() && this.hasStroke() && !!this.shadow) {
71357150
return true;
71367151
}
@@ -7144,13 +7159,13 @@ let FabricObject$1 = class FabricObject extends ObjectGeometry {
71447159
* Decide if the object should cache or not. Create its own cache level
71457160
* objectCaching is a global flag, wins over everything
71467161
* needsItsOwnCache should be used when the object drawing method requires
7147-
* a cache step. None of the fabric classes requires it.
7162+
* a cache step.
71487163
* Generally you do not cache objects in groups because the group outside is cached.
71497164
* Read as: cache if is needed, or if the feature is enabled but we are not already caching.
71507165
* @return {Boolean}
71517166
*/
71527167
shouldCache() {
7153-
this.ownCaching = this.needsItsOwnCache() || this.objectCaching && (!this.parent || !this.parent.isOnACache());
7168+
this.ownCaching = this.objectCaching && (!this.parent || !this.parent.isOnACache()) || this.needsItsOwnCache();
71547169
return this.ownCaching;
71557170
}
71567171

@@ -7250,7 +7265,10 @@ let FabricObject$1 = class FabricObject extends ObjectGeometry {
72507265
}
72517266

72527267
/**
7253-
* Check if cache is dirty
7268+
* Check if cache is dirty and if is dirty clear the context.
7269+
* This check has a big side effect, it changes the underlying cache canvas if necessary.
7270+
* Do not call this method on your own to check if the cache is dirty, because if it is,
7271+
* it is also going to wipe the cache. This is badly designed and needs to be fixed.
72547272
* @param {Boolean} skipCanvas skip canvas checks because this object is painted
72557273
* on parent canvas.
72567274
*/
@@ -7683,6 +7701,10 @@ let FabricObject$1 = class FabricObject extends ObjectGeometry {
76837701
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
76847702
return toDataURL(this.toCanvasElement(options), options.format || 'png', options.quality || 1);
76857703
}
7704+
toBlob() {
7705+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
7706+
return toBlob(this.toCanvasElement(options), options.format || 'png', options.quality || 1);
7707+
}
76867708

76877709
/**
76887710
* Returns true if any of the specified types is identical to the type of an instance
@@ -11662,9 +11684,9 @@ class Group extends createCollectionMixin(FabricObject) {
1166211684
}
1166311685

1166411686
/**
11665-
* Decide if the object should cache or not. Create its own cache level
11687+
* Decide if the group should cache or not. Create its own cache level
1166611688
* needsItsOwnCache should be used when the object drawing method requires
11667-
* a cache step. None of the fabric classes requires it.
11689+
* a cache step.
1166811690
* Generally you do not cache objects in groups because the group is already cached.
1166911691
* @return {Boolean}
1167011692
*/
@@ -13036,6 +13058,7 @@ var index$1 = /*#__PURE__*/Object.freeze({
1303613058
string: lang_string,
1303713059
stylesFromArray: stylesFromArray,
1303813060
stylesToArray: stylesToArray,
13061+
toBlob: toBlob,
1303913062
toDataURL: toDataURL,
1304013063
toFixed: toFixed,
1304113064
transformPath: transformPath,
@@ -23662,11 +23685,7 @@ class ActiveSelection extends Group {
2366223685
}
2366323686

2366423687
/**
23665-
* Decide if the object should cache or not. Create its own cache level
23666-
* objectCaching is a global flag, wins over everything
23667-
* needsItsOwnCache should be used when the object drawing method requires
23668-
* a cache step. None of the fabric classes requires it.
23669-
* Generally you do not cache objects in groups because the group outside is cached.
23688+
* Decide if the object should cache or not. The Active selection never caches
2367023689
* @return {Boolean}
2367123690
*/
2367223691
shouldCache() {
@@ -24192,13 +24211,14 @@ class FabricImage extends FabricObject {
2419224211
* @param {Partial<TSize>} [size] Options object
2419324212
*/
2419424213
setElement(element) {
24214+
var _element$classList;
2419524215
let size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2419624216
this.removeTexture(this.cacheKey);
2419724217
this.removeTexture("".concat(this.cacheKey, "_filtered"));
2419824218
this._element = element;
2419924219
this._originalElement = element;
2420024220
this._setWidthHeight(size);
24201-
element.classList.add(FabricImage.CSS_CANVAS);
24221+
(_element$classList = element.classList) === null || _element$classList === void 0 || _element$classList.add(FabricImage.CSS_CANVAS);
2420224222
if (this.filters.length !== 0) {
2420324223
this.applyFilters();
2420424224
}
@@ -24486,7 +24506,7 @@ class FabricImage extends FabricObject {
2448624506
this._lastScaleX = 1;
2448724507
this._lastScaleY = 1;
2448824508
}
24489-
getFilterBackend().applyFilters(filters, this._originalElement, sourceWidth, sourceHeight, this._element);
24509+
getFilterBackend().applyFilters(filters, this._originalElement, sourceWidth, sourceHeight, this._element, this.cacheKey);
2449024510
if (this._originalElement.width !== this._element.width || this._originalElement.height !== this._element.height) {
2449124511
this._filterScalingX = this._element.width / this._originalElement.width;
2449224512
this._filterScalingY = this._element.height / this._originalElement.height;
@@ -24517,11 +24537,11 @@ class FabricImage extends FabricObject {
2451724537
}
2451824538

2451924539
/**
24520-
* Decide if the object should cache or not. Create its own cache level
24540+
* Decide if the FabricImage should cache or not. Create its own cache level
2452124541
* needsItsOwnCache should be used when the object drawing method requires
24522-
* a cache step. None of the fabric classes requires it.
24542+
* a cache step.
2452324543
* Generally you do not cache objects in groups because the group outside is cached.
24524-
* This is the special image version where we would like to avoid caching where possible.
24544+
* This is the special Image version where we would like to avoid caching where possible.
2452524545
* Essentially images do not benefit from caching. They may require caching, and in that
2452624546
* case we do it. Also caching an image usually ends in a loss of details.
2452724547
* A full performance audit should be done.
@@ -24665,7 +24685,9 @@ class FabricImage extends FabricObject {
2466524685

2466624686
/**
2466724687
* Default CSS class name for canvas
24688+
* Will be removed from fabric 7
2466824689
* @static
24690+
* @deprecated
2466924691
* @type String
2467024692
* @default
2467124693
*/

Diff for: dist/index.mjs.map

+1-1
Large diffs are not rendered by default.

Diff for: dist/index.node.mjs

+39-17
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ class Cache {
461461
}
462462
const cache = new Cache();
463463

464-
var version = "6.5.3";
464+
var version = "6.6.1";
465465

466466
// use this syntax so babel plugin see this import here
467467
const VERSION = version;
@@ -1635,6 +1635,9 @@ const toDataURL = (canvasEl, format, quality) => canvasEl.toDataURL("image/".con
16351635
const isHTMLCanvas = canvas => {
16361636
return !!canvas && canvas.getContext !== undefined;
16371637
};
1638+
const toBlob = (canvasEl, format, quality) => new Promise((resolve, _) => {
1639+
canvasEl.toBlob(resolve, "image/".concat(format), quality);
1640+
});
16381641

16391642
/**
16401643
* Transforms degrees to radians.
@@ -4196,6 +4199,17 @@ let StaticCanvas$1 = class StaticCanvas extends createCollectionMixin(CommonMeth
41964199
const finalMultiplier = multiplier * (enableRetinaScaling ? this.getRetinaScaling() : 1);
41974200
return toDataURL(this.toCanvasElement(finalMultiplier, options), format, quality);
41984201
}
4202+
toBlob() {
4203+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4204+
const {
4205+
format = 'png',
4206+
quality = 1,
4207+
multiplier = 1,
4208+
enableRetinaScaling = false
4209+
} = options;
4210+
const finalMultiplier = multiplier * (enableRetinaScaling ? this.getRetinaScaling() : 1);
4211+
return toBlob(this.toCanvasElement(finalMultiplier, options), format, quality);
4212+
}
41994213

42004214
/**
42014215
* Create a new HTMLCanvas element painted with the current canvas content.
@@ -7179,14 +7193,15 @@ let FabricObject$1 = class FabricObject extends ObjectGeometry {
71797193
}
71807194

71817195
/**
7182-
* When set to `true`, force the object to have its own cache, even if it is inside a group
7196+
* When returns `true`, force the object to have its own cache, even if it is inside a group
71837197
* it may be needed when your object behave in a particular way on the cache and always needs
71847198
* its own isolated canvas to render correctly.
71857199
* Created to be overridden
71867200
* since 1.7.12
71877201
* @returns Boolean
71887202
*/
71897203
needsItsOwnCache() {
7204+
// TODO re-evaluate this shadow condition
71907205
if (this.paintFirst === STROKE && this.hasFill() && this.hasStroke() && !!this.shadow) {
71917206
return true;
71927207
}
@@ -7200,13 +7215,13 @@ let FabricObject$1 = class FabricObject extends ObjectGeometry {
72007215
* Decide if the object should cache or not. Create its own cache level
72017216
* objectCaching is a global flag, wins over everything
72027217
* needsItsOwnCache should be used when the object drawing method requires
7203-
* a cache step. None of the fabric classes requires it.
7218+
* a cache step.
72047219
* Generally you do not cache objects in groups because the group outside is cached.
72057220
* Read as: cache if is needed, or if the feature is enabled but we are not already caching.
72067221
* @return {Boolean}
72077222
*/
72087223
shouldCache() {
7209-
this.ownCaching = this.needsItsOwnCache() || this.objectCaching && (!this.parent || !this.parent.isOnACache());
7224+
this.ownCaching = this.objectCaching && (!this.parent || !this.parent.isOnACache()) || this.needsItsOwnCache();
72107225
return this.ownCaching;
72117226
}
72127227

@@ -7306,7 +7321,10 @@ let FabricObject$1 = class FabricObject extends ObjectGeometry {
73067321
}
73077322

73087323
/**
7309-
* Check if cache is dirty
7324+
* Check if cache is dirty and if is dirty clear the context.
7325+
* This check has a big side effect, it changes the underlying cache canvas if necessary.
7326+
* Do not call this method on your own to check if the cache is dirty, because if it is,
7327+
* it is also going to wipe the cache. This is badly designed and needs to be fixed.
73107328
* @param {Boolean} skipCanvas skip canvas checks because this object is painted
73117329
* on parent canvas.
73127330
*/
@@ -7739,6 +7757,10 @@ let FabricObject$1 = class FabricObject extends ObjectGeometry {
77397757
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
77407758
return toDataURL(this.toCanvasElement(options), options.format || 'png', options.quality || 1);
77417759
}
7760+
toBlob() {
7761+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
7762+
return toBlob(this.toCanvasElement(options), options.format || 'png', options.quality || 1);
7763+
}
77427764

77437765
/**
77447766
* Returns true if any of the specified types is identical to the type of an instance
@@ -11718,9 +11740,9 @@ class Group extends createCollectionMixin(FabricObject) {
1171811740
}
1171911741

1172011742
/**
11721-
* Decide if the object should cache or not. Create its own cache level
11743+
* Decide if the group should cache or not. Create its own cache level
1172211744
* needsItsOwnCache should be used when the object drawing method requires
11723-
* a cache step. None of the fabric classes requires it.
11745+
* a cache step.
1172411746
* Generally you do not cache objects in groups because the group is already cached.
1172511747
* @return {Boolean}
1172611748
*/
@@ -13092,6 +13114,7 @@ var index$1 = /*#__PURE__*/Object.freeze({
1309213114
string: lang_string,
1309313115
stylesFromArray: stylesFromArray,
1309413116
stylesToArray: stylesToArray,
13117+
toBlob: toBlob,
1309513118
toDataURL: toDataURL,
1309613119
toFixed: toFixed,
1309713120
transformPath: transformPath,
@@ -23718,11 +23741,7 @@ class ActiveSelection extends Group {
2371823741
}
2371923742

2372023743
/**
23721-
* Decide if the object should cache or not. Create its own cache level
23722-
* objectCaching is a global flag, wins over everything
23723-
* needsItsOwnCache should be used when the object drawing method requires
23724-
* a cache step. None of the fabric classes requires it.
23725-
* Generally you do not cache objects in groups because the group outside is cached.
23744+
* Decide if the object should cache or not. The Active selection never caches
2372623745
* @return {Boolean}
2372723746
*/
2372823747
shouldCache() {
@@ -24248,13 +24267,14 @@ class FabricImage extends FabricObject {
2424824267
* @param {Partial<TSize>} [size] Options object
2424924268
*/
2425024269
setElement(element) {
24270+
var _element$classList;
2425124271
let size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2425224272
this.removeTexture(this.cacheKey);
2425324273
this.removeTexture("".concat(this.cacheKey, "_filtered"));
2425424274
this._element = element;
2425524275
this._originalElement = element;
2425624276
this._setWidthHeight(size);
24257-
element.classList.add(FabricImage.CSS_CANVAS);
24277+
(_element$classList = element.classList) === null || _element$classList === void 0 || _element$classList.add(FabricImage.CSS_CANVAS);
2425824278
if (this.filters.length !== 0) {
2425924279
this.applyFilters();
2426024280
}
@@ -24542,7 +24562,7 @@ class FabricImage extends FabricObject {
2454224562
this._lastScaleX = 1;
2454324563
this._lastScaleY = 1;
2454424564
}
24545-
getFilterBackend().applyFilters(filters, this._originalElement, sourceWidth, sourceHeight, this._element);
24565+
getFilterBackend().applyFilters(filters, this._originalElement, sourceWidth, sourceHeight, this._element, this.cacheKey);
2454624566
if (this._originalElement.width !== this._element.width || this._originalElement.height !== this._element.height) {
2454724567
this._filterScalingX = this._element.width / this._originalElement.width;
2454824568
this._filterScalingY = this._element.height / this._originalElement.height;
@@ -24573,11 +24593,11 @@ class FabricImage extends FabricObject {
2457324593
}
2457424594

2457524595
/**
24576-
* Decide if the object should cache or not. Create its own cache level
24596+
* Decide if the FabricImage should cache or not. Create its own cache level
2457724597
* needsItsOwnCache should be used when the object drawing method requires
24578-
* a cache step. None of the fabric classes requires it.
24598+
* a cache step.
2457924599
* Generally you do not cache objects in groups because the group outside is cached.
24580-
* This is the special image version where we would like to avoid caching where possible.
24600+
* This is the special Image version where we would like to avoid caching where possible.
2458124601
* Essentially images do not benefit from caching. They may require caching, and in that
2458224602
* case we do it. Also caching an image usually ends in a loss of details.
2458324603
* A full performance audit should be done.
@@ -24721,7 +24741,9 @@ class FabricImage extends FabricObject {
2472124741

2472224742
/**
2472324743
* Default CSS class name for canvas
24744+
* Will be removed from fabric 7
2472424745
* @static
24746+
* @deprecated
2472524747
* @type String
2472624748
* @default
2472724749
*/

Diff for: dist/index.node.mjs.map

+1-1
Large diffs are not rendered by default.

Diff for: package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "fabric",
33
"description": "Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.",
44
"homepage": "http://fabricjs.com/",
5-
"version": "6.6.0",
5+
"version": "6.6.1",
66
"author": "Juriy Zaytsev <[email protected]>",
77
"contributors": [
88
{

0 commit comments

Comments
 (0)