Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAJOR feat(fabric) remove callbacks in for Promise support #7657

Merged
merged 43 commits into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
498a72b
this is all broken
asturur Feb 6, 2022
6733893
rect test pass
asturur Feb 6, 2022
7374726
clone ok
asturur Feb 6, 2022
3f42f35
fix active selection test
asturur Feb 11, 2022
935c33f
fix active selection test
asturur Feb 11, 2022
1bad76e
canvas fixed
asturur Feb 12, 2022
9e067cb
fix static canvas tests
asturur Feb 13, 2022
39a5a19
fixed group circle ellipse
asturur Feb 13, 2022
9b2c0a0
more progress
asturur Feb 13, 2022
9efe6b6
fixed images
asturur Feb 13, 2022
af37cbc
solved more
asturur Feb 13, 2022
f57d124
solved more
asturur Feb 13, 2022
2480b0f
solved more
asturur Feb 13, 2022
18580ff
more
asturur Feb 13, 2022
06a5d24
ok
asturur Feb 13, 2022
db7abc9
more test fixed
asturur Feb 13, 2022
3be7749
visual fixed
asturur Feb 13, 2022
d886bc9
ut passing
asturur Feb 13, 2022
b04f686
fix lint
asturur Feb 13, 2022
751b6ef
test lint
asturur Feb 13, 2022
1e7722b
removed this thing here
asturur Feb 13, 2022
78ef400
WTF
asturur Feb 13, 2022
83171df
fix generic enliving
asturur Feb 14, 2022
174d940
small errors removed
asturur Feb 14, 2022
e259205
try this
asturur Feb 14, 2022
1675215
another shot in the darl
asturur Feb 14, 2022
4e1bc07
Merge branch 'master' into promises-support
asturur Feb 14, 2022
fee8547
updated master
asturur Feb 14, 2022
5be02de
JSDOC
ShaMan123 Feb 14, 2022
041111d
Merge branch 'master' into promises-support
asturur Feb 14, 2022
4120f24
typo
ShaMan123 Feb 15, 2022
38d3bfe
more tests
asturur Feb 15, 2022
1beba19
more tests
asturur Feb 15, 2022
7b78236
removed death methods
asturur Feb 15, 2022
9f5ef64
use real class for Object.fromObject
asturur Feb 15, 2022
b2e5c66
Update eraser_brush.mixin.js
ShaMan123 Feb 15, 2022
683fc2d
lint + comment out Map until proper js
ShaMan123 Feb 15, 2022
0a9e403
Update blendimage_filter.class.js
ShaMan123 Feb 15, 2022
1cebdd5
jsdoc
ShaMan123 Feb 15, 2022
7c05e4f
Update circle.class.js
ShaMan123 Feb 15, 2022
73b2b73
Update object.class.js
ShaMan123 Feb 15, 2022
938140f
jsdoc
ShaMan123 Feb 15, 2022
dc7429c
Update canvas_serialization.mixin.js
asturur Feb 16, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"browser": true
},
"globals": {
"ActiveXObject": true,
ShaMan123 marked this conversation as resolved.
Show resolved Hide resolved
"Promise": true,
"define": true,
"eventjs": true,
"exports": true,
Expand Down
12 changes: 8 additions & 4 deletions src/filters/base_filter.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,12 @@ fabric.Image.filters.BaseFilter = fabric.util.createClass(/** @lends fabric.Imag
}
});

fabric.Image.filters.BaseFilter.fromObject = function(object, callback) {
var filter = new fabric.Image.filters[object.type](object);
callback && callback(filter);
return filter;
/**
* Create filter instance from an object representation
* @static
* @param {Object} object Object to create an instance from
* @returns {Promise<fabric.Image.filters.BaseFilter>}
*/
fabric.Image.filters.BaseFilter.fromObject = function(object) {
return Promise.resolve(new fabric.Image.filters[object.type](object));
};
5 changes: 2 additions & 3 deletions src/filters/blendcolor_filter.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,10 @@
});

/**
* Returns filter instance from an object representation
* Create filter instance from an object representation
* @static
* @param {Object} object Object to create an instance from
* @param {function} [callback] to be invoked after filter creation
* @return {fabric.Image.filters.BlendColor} Instance of fabric.Image.filters.BlendColor
* @returns {Promise<fabric.Image.filters.BlendColor>}
*/
fabric.Image.filters.BlendColor.fromObject = fabric.Image.filters.BaseFilter.fromObject;

Expand Down
11 changes: 5 additions & 6 deletions src/filters/blendimage_filter.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,17 +230,16 @@
});

/**
* Returns filter instance from an object representation
* Create filter instance from an object representation
* @static
* @param {Object} object Object to create an instance from
* @param {function} callback to be invoked after filter creation
* @return {fabric.Image.filters.BlendImage} Instance of fabric.Image.filters.BlendImage
* @returns {Promise<fabric.Image.filters.BlendImage>}
*/
fabric.Image.filters.BlendImage.fromObject = function(object, callback) {
fabric.Image.fromObject(object.image, function(image) {
fabric.Image.filters.BlendImage.fromObject = function(object) {
return fabric.Image.fromObject(object.image).then(function(image) {
var options = fabric.util.object.clone(object);
options.image = image;
callback(new fabric.Image.filters.BlendImage(options));
return new fabric.Image.filters.BlendImage(options);
});
};

Expand Down
5 changes: 4 additions & 1 deletion src/filters/blur_filter.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,10 @@
});

/**
* Deserialize a JSON definition of a BlurFilter into a concrete instance.
* Create filter instance from an object representation
* @static
* @param {Object} object Object to create an instance from
* @returns {Promise<fabric.Image.filters.Blur>}
*/
filters.Blur.fromObject = fabric.Image.filters.BaseFilter.fromObject;

Expand Down
5 changes: 2 additions & 3 deletions src/filters/brightness_filter.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,10 @@
});

/**
* Returns filter instance from an object representation
* Create filter instance from an object representation
* @static
* @param {Object} object Object to create an instance from
* @param {function} [callback] to be invoked after filter creation
* @return {fabric.Image.filters.Brightness} Instance of fabric.Image.filters.Brightness
* @returns {Promise<fabric.Image.filters.Brightness>}
*/
fabric.Image.filters.Brightness.fromObject = fabric.Image.filters.BaseFilter.fromObject;

Expand Down
5 changes: 2 additions & 3 deletions src/filters/colormatrix_filter.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,10 @@
});

/**
* Returns filter instance from an object representation
* Create filter instance from an object representation
* @static
* @param {Object} object Object to create an instance from
* @param {function} [callback] function to invoke after filter creation
* @return {fabric.Image.filters.ColorMatrix} Instance of fabric.Image.filters.ColorMatrix
* @returns {Promise<fabric.Image.filters.ColorMatrix>}
*/
fabric.Image.filters.ColorMatrix.fromObject = fabric.Image.filters.BaseFilter.fromObject;
})(typeof exports !== 'undefined' ? exports : this);
15 changes: 7 additions & 8 deletions src/filters/composed_filter.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,12 @@
/**
* Deserialize a JSON definition of a ComposedFilter into a concrete instance.
*/
fabric.Image.filters.Composed.fromObject = function(object, callback) {
var filters = object.subFilters || [],
subFilters = filters.map(function(filter) {
return new fabric.Image.filters[filter.type](filter);
}),
instance = new fabric.Image.filters.Composed({ subFilters: subFilters });
callback && callback(instance);
return instance;
fabric.Image.filters.Composed.fromObject = function(object) {
var filters = object.subFilters || [];
return Promise.all(filters.map(function(filter) {
return fabric.Image.filters[filter.type].fromObject(filter);
})).then(function(enlivedFilters) {
return new fabric.Image.filters.Composed({ subFilters: enlivedFilters });
});
};
})(typeof exports !== 'undefined' ? exports : this);
5 changes: 2 additions & 3 deletions src/filters/contrast_filter.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,10 @@
});

/**
* Returns filter instance from an object representation
* Create filter instance from an object representation
* @static
* @param {Object} object Object to create an instance from
* @param {function} [callback] to be invoked after filter creation
* @return {fabric.Image.filters.Contrast} Instance of fabric.Image.filters.Contrast
* @returns {Promise<fabric.Image.filters.Contrast>}
*/
fabric.Image.filters.Contrast.fromObject = fabric.Image.filters.BaseFilter.fromObject;

Expand Down
5 changes: 2 additions & 3 deletions src/filters/convolute_filter.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,10 @@
});

/**
* Returns filter instance from an object representation
* Create filter instance from an object representation
* @static
* @param {Object} object Object to create an instance from
* @param {function} [callback] to be invoked after filter creation
* @return {fabric.Image.filters.Convolute} Instance of fabric.Image.filters.Convolute
* @returns {Promise<fabric.Image.filters.Convolute>}
*/
fabric.Image.filters.Convolute.fromObject = fabric.Image.filters.BaseFilter.fromObject;

Expand Down
5 changes: 2 additions & 3 deletions src/filters/filter_boilerplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,10 @@
});

/**
* Returns filter instance from an object representation
* Create filter instance from an object representation
* @static
* @param {Object} object Object to create an instance from
* @param {function} [callback] to be invoked after filter creation
* @return {fabric.Image.filters.MyFilter} Instance of fabric.Image.filters.MyFilter
* @returns {Promise<fabric.Image.filters.MyFilter>}
*/
fabric.Image.filters.MyFilter.fromObject = fabric.Image.filters.BaseFilter.fromObject;

Expand Down
5 changes: 2 additions & 3 deletions src/filters/gamma_filter.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,10 @@
});

/**
* Returns filter instance from an object representation
* Create filter instance from an object representation
* @static
* @param {Object} object Object to create an instance from
* @param {function} [callback] to be invoked after filter creation
* @return {fabric.Image.filters.Gamma} Instance of fabric.Image.filters.Gamma
* @returns {Promise<fabric.Image.filters.Gamma>}
*/
fabric.Image.filters.Gamma.fromObject = fabric.Image.filters.BaseFilter.fromObject;

Expand Down
5 changes: 2 additions & 3 deletions src/filters/grayscale_filter.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,10 @@
});

/**
* Returns filter instance from an object representation
* Create filter instance from an object representation
* @static
* @param {Object} object Object to create an instance from
* @param {function} [callback] to be invoked after filter creation
* @return {fabric.Image.filters.Grayscale} Instance of fabric.Image.filters.Grayscale
* @returns {Promise<fabric.Image.filters.Grayscale>}
*/
fabric.Image.filters.Grayscale.fromObject = fabric.Image.filters.BaseFilter.fromObject;

Expand Down
5 changes: 2 additions & 3 deletions src/filters/hue_rotation.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,10 @@
});

/**
* Returns filter instance from an object representation
* Create filter instance from an object representation
* @static
* @param {Object} object Object to create an instance from
* @param {function} [callback] to be invoked after filter creation
* @return {fabric.Image.filters.HueRotation} Instance of fabric.Image.filters.HueRotation
* @returns {Promise<fabric.Image.filters.HueRotation>}
*/
fabric.Image.filters.HueRotation.fromObject = fabric.Image.filters.BaseFilter.fromObject;

Expand Down
5 changes: 2 additions & 3 deletions src/filters/invert_filter.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,10 @@
});

/**
* Returns filter instance from an object representation
* Create filter instance from an object representation
* @static
* @param {Object} object Object to create an instance from
* @param {function} [callback] to be invoked after filter creation
* @return {fabric.Image.filters.Invert} Instance of fabric.Image.filters.Invert
* @returns {Promise<fabric.Image.filters.Invert>}
*/
fabric.Image.filters.Invert.fromObject = fabric.Image.filters.BaseFilter.fromObject;

Expand Down
5 changes: 2 additions & 3 deletions src/filters/noise_filter.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,10 @@
});

/**
* Returns filter instance from an object representation
* Create filter instance from an object representation
* @static
* @param {Object} object Object to create an instance from
* @param {Function} [callback] to be invoked after filter creation
* @return {fabric.Image.filters.Noise} Instance of fabric.Image.filters.Noise
* @returns {Promise<fabric.Image.filters.Noise>}
*/
fabric.Image.filters.Noise.fromObject = fabric.Image.filters.BaseFilter.fromObject;

Expand Down
5 changes: 2 additions & 3 deletions src/filters/pixelate_filter.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,10 @@
});

/**
* Returns filter instance from an object representation
* Create filter instance from an object representation
* @static
* @param {Object} object Object to create an instance from
* @param {Function} [callback] to be invoked after filter creation
* @return {fabric.Image.filters.Pixelate} Instance of fabric.Image.filters.Pixelate
* @returns {Promise<fabric.Image.filters.Pixelate>}
*/
fabric.Image.filters.Pixelate.fromObject = fabric.Image.filters.BaseFilter.fromObject;

Expand Down
5 changes: 2 additions & 3 deletions src/filters/removecolor_filter.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,10 @@
});

/**
* Returns filter instance from an object representation
* Create filter instance from an object representation
* @static
* @param {Object} object Object to create an instance from
* @param {Function} [callback] to be invoked after filter creation
* @return {fabric.Image.filters.RemoveColor} Instance of fabric.Image.filters.RemoveWhite
* @returns {Promise<fabric.Image.filters.RemoveColor>}
*/
fabric.Image.filters.RemoveColor.fromObject = fabric.Image.filters.BaseFilter.fromObject;

Expand Down
5 changes: 2 additions & 3 deletions src/filters/resize_filter.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,11 +479,10 @@
});

/**
* Returns filter instance from an object representation
* Create filter instance from an object representation
* @static
* @param {Object} object Object to create an instance from
* @param {Function} [callback] to be invoked after filter creation
* @return {fabric.Image.filters.Resize} Instance of fabric.Image.filters.Resize
* @returns {Promise<fabric.Image.filters.Resize>}
*/
fabric.Image.filters.Resize.fromObject = fabric.Image.filters.BaseFilter.fromObject;

Expand Down
7 changes: 3 additions & 4 deletions src/filters/saturate_filter.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
* Saturation value, from -1 to 1.
* Increases/decreases the color saturation.
* A value of 0 has no effect.
*
*
* @param {Number} saturation
* @default
*/
Expand Down Expand Up @@ -108,11 +108,10 @@
});

/**
* Returns filter instance from an object representation
* Create filter instance from an object representation
* @static
* @param {Object} object Object to create an instance from
* @param {Function} [callback] to be invoked after filter creation
* @return {fabric.Image.filters.Saturation} Instance of fabric.Image.filters.Saturate
* @returns {Promise<fabric.Image.filters.Saturation>}
*/
fabric.Image.filters.Saturation.fromObject = fabric.Image.filters.BaseFilter.fromObject;

Expand Down
7 changes: 3 additions & 4 deletions src/filters/vibrance_filter.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
* Vibrance value, from -1 to 1.
* Increases/decreases the saturation of more muted colors with less effect on saturated colors.
* A value of 0 has no effect.
*
*
* @param {Number} vibrance
* @default
*/
Expand Down Expand Up @@ -111,11 +111,10 @@
});

/**
* Returns filter instance from an object representation
* Create filter instance from an object representation
* @static
* @param {Object} object Object to create an instance from
* @param {Function} [callback] to be invoked after filter creation
* @return {fabric.Image.filters.Vibrance} Instance of fabric.Image.filters.Vibrance
* @returns {Promise<fabric.Image.filters.Vibrance>}
*/
fabric.Image.filters.Vibrance.fromObject = fabric.Image.filters.BaseFilter.fromObject;

Expand Down
Loading