Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fabric

Package Overview
Dependencies
Maintainers
2
Versions
304
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fabric - npm Package Compare versions

Comparing version 4.3.1 to 4.4.0-browser

old-travis-reference.yml

2

HEADER.js
/*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */
var fabric = fabric || { version: '4.3.1' };
var fabric = fabric || { version: '4.4.0' };
if (typeof exports !== 'undefined') {

@@ -5,0 +5,0 @@ exports.fabric = fabric;

{
"name": "fabric",
"description": "Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.",
"homepage": "http://fabricjs.com/",
"version": "4.3.1",
"author": "Juriy Zaytsev <kangax@gmail.com>",
"contributors": [
{
"name": "Andrea Bogazzi",
"email": "andreabogazzi79@gmail.com"
}
],
"keywords": [
"canvas",
"graphic",
"graphics",
"SVG",
"node-canvas",
"parser",
"HTML5",
"object model"
],
"browser": {
"canvas": false,
"fs": false,
"jsdom": false,
"jsdom/lib/jsdom/living/generated/utils": false,
"jsdom/lib/jsdom/utils": false,
"http": false,
"https": false,
"xmldom": false,
"url": false
},
"repository": {
"type": "git",
"url": "https://github.com/fabricjs/fabric.js"
},
"bugs": {
"url": "https://github.com/fabricjs/fabric.js/issues"
},
"license": "MIT",
"scripts": {
"build": "node build.js modules=ALL requirejs exclude=gestures,accessors",
"build:fast": "node build.js modules=ALL requirejs fast exclude=gestures,accessors",
"build:watch": "onchange 'src/**/**' 'HEADER.js' 'lib/**/**' -- npm run build_export",
"link:watch": "onchange 'src/**/**' 'HEADER.js' 'lib/**/**' -- npm link",
"build_with_gestures": "node build.js modules=ALL exclude=accessors",
"build_export": "npm run build:fast && npm run export_dist_to_site",
"test:single": "qunit test/node_test_setup.js test/lib",
"test": "nyc qunit test/node_test_setup.js test/lib test/unit",
"test:visual": "qunit test/node_test_setup.js test/lib test/visual",
"test:visual:single": "qunit test/node_test_setup.js test/lib",
"test:all": "npm run test && npm run test:visual",
"lint": "eslint --config .eslintrc.json src",
"lint_tests": "eslint test/unit --config .eslintrc_tests && eslint test/visual --config .eslintrc_tests",
"export_gesture_to_site": "cp dist/fabric.js ../fabricjs.com/lib/fabric_with_gestures.js",
"export_dist_to_site": "cp dist/fabric.js ../fabricjs.com/lib/fabric.js && cp package.json ../fabricjs.com/lib/package.json && cp -r src HEADER.js lib ../fabricjs.com/build/files/",
"export_tests_to_site": "cp test/unit/*.js ../fabricjs.com/test/unit && cp -r test/visual/* ../fabricjs.com/test/visual && cp -r test/fixtures/* ../fabricjs.com/test/fixtures && cp -r test/lib/* ../fabricjs.com/test/lib",
"all": "npm run build && npm run test && npm run test:visual && npm run lint && npm run lint_tests && npm run export_dist_to_site && npm run export_tests_to_site",
"testem": "testem .",
"testem:visual": "testem --file testem-visual.json",
"testem:ci": "testem ci"
},
"optionalDependencies": {
"canvas": "^2.6.1",
"jsdom": "^15.2.1"
},
"devDependencies": {
"chalk": "^2.4.1",
"eslint": "4.18.x",
"nyc": "^15.1.0",
"onchange": "^3.x.x",
"pixelmatch": "^4.0.2",
"qunit": "^2.13.0",
"testem": "^3.2.0",
"uglify-js": "3.3.x"
},
"engines": {
"node": ">=8.0.0"
},
"main": "./dist/fabric.js",
"dependencies": {}
}
"name": "fabric",
"description": "Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.",
"homepage": "http://fabricjs.com/",
"version": "4.4.0-browser",
"author": "Juriy Zaytsev <kangax@gmail.com>",
"contributors": [
{
"name": "Andrea Bogazzi",
"email": "andreabogazzi79@gmail.com"
}
],
"keywords": [
"canvas",
"graphic",
"graphics",
"SVG",
"node-canvas",
"parser",
"HTML5",
"object model"
],
"browser": {
"canvas": false,
"fs": false,
"jsdom": false,
"jsdom/lib/jsdom/living/generated/utils": false,
"jsdom/lib/jsdom/utils": false,
"http": false,
"https": false,
"xmldom": false,
"url": false
},
"repository": {
"type": "git",
"url": "https://github.com/fabricjs/fabric.js"
},
"bugs": {
"url": "https://github.com/fabricjs/fabric.js/issues"
},
"license": "MIT",
"scripts": {
"build": "node build.js modules=ALL requirejs exclude=gestures,accessors",
"build:fast": "node build.js modules=ALL requirejs fast exclude=gestures,accessors",
"build:watch": "onchange 'src/**/**' 'HEADER.js' 'lib/**/**' -- npm run build_export",
"link:watch": "onchange 'src/**/**' 'HEADER.js' 'lib/**/**' -- npm link",
"build_with_gestures": "node build.js modules=ALL exclude=accessors",
"build_export": "npm run build:fast && npm run export_dist_to_site",
"test:single": "qunit test/node_test_setup.js test/lib",
"test:coverage": "nyc --silent qunit test/node_test_setup.js test/lib test/unit",
"test:visual:coverage": "nyc --silent --no-clean qunit test/node_test_setup.js test/lib test/visual",
"coverage:report": "nyc report --reporter=lcov --reporter=text",
"test": "qunit test/node_test_setup.js test/lib test/unit",
"test:visual": "qunit test/node_test_setup.js test/lib test/visual",
"test:visual:single": "qunit test/node_test_setup.js test/lib",
"test:all": "npm run test && npm run test:visual",
"lint": "eslint --config .eslintrc.json src",
"lint_tests": "eslint test/unit --config .eslintrc_tests && eslint test/visual --config .eslintrc_tests",
"export_gesture_to_site": "cp dist/fabric.js ../fabricjs.com/lib/fabric_with_gestures.js",
"export_dist_to_site": "cp dist/fabric.js ../fabricjs.com/lib/fabric.js && cp package.json ../fabricjs.com/lib/package.json && cp -r src HEADER.js lib ../fabricjs.com/build/files/",
"export_tests_to_site": "cp test/unit/*.js ../fabricjs.com/test/unit && cp -r test/visual/* ../fabricjs.com/test/visual && cp -r test/fixtures/* ../fabricjs.com/test/fixtures && cp -r test/lib/* ../fabricjs.com/test/lib",
"all": "npm run build && npm run test && npm run test:visual && npm run lint && npm run lint_tests && npm run export_dist_to_site && npm run export_tests_to_site",
"testem": "testem .",
"testem:ci": "testem ci"
},
"optionalDependencies": {},
"devDependencies": {
"chalk": "^2.4.1",
"eslint": "4.18.x",
"nyc": "^15.1.0",
"onchange": "^3.x.x",
"pixelmatch": "^4.0.2",
"qunit": "^2.13.0",
"testem": "^3.2.0",
"uglify-js": "3.3.x"
},
"engines": {
"node": ">=8.0.0"
},
"main": "./dist/fabric.js",
"dependencies": {}
}

@@ -60,2 +60,11 @@ /**

/**
* When `true`, the free drawing is limited to the whiteboard size. Default to false.
* @type Boolean
* @default false
*/
limitedToCanvasSize: false,
/**
* Sets brush styles

@@ -124,3 +133,12 @@ * @private

ctx.shadowBlur = ctx.shadowOffsetX = ctx.shadowOffsetY = 0;
},
/**
* Check is pointer is outside canvas boundaries
* @param {Object} pointer
* @private
*/
_isOutSideCanvas: function(pointer) {
return pointer.x < 0 || pointer.x > this.canvas.getWidth() || pointer.y < 0 || pointer.y > this.canvas.getHeight();
}
});

@@ -73,2 +73,5 @@ /**

onMouseMove: function(pointer) {
if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) {
return;
}
if (this.needsFullRender()) {

@@ -75,0 +78,0 @@ this.canvas.clearContext(this.canvas.contextTop);

@@ -59,2 +59,5 @@ (function() {

}
if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) {
return;
}
if (this._captureDrawingPath(pointer) && this._points.length > 1) {

@@ -61,0 +64,0 @@ if (this.needsFullRender()) {

@@ -77,2 +77,5 @@ /**

onMouseMove: function(pointer) {
if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) {
return;
}
this.addSprayChunk(pointer);

@@ -79,0 +82,0 @@ this.render(this.sprayChunkPoints);

@@ -500,9 +500,2 @@ (function() {

target === this._activeObject && target._renderControls(ctx, {
hasBorders: false,
transparentCorners: false
}, {
hasBorders: false,
});
target.selectionBackgroundColor = originalColor;

@@ -769,3 +762,4 @@

activeTarget, activeTargetSubs,
isTouch = isTouchEvent(e);
isTouch = isTouchEvent(e),
shouldLookForActive = (aObjects.length > 1 && !skipGroup) || aObjects.length === 1;

@@ -777,7 +771,7 @@ // first check current group (if one exists)

if (aObjects.length > 1 && !skipGroup && activeObject === this._searchPossibleTargets([activeObject], pointer)) {
// if we hit the corner of an activeObject, let's return that.
if (shouldLookForActive && activeObject._findTargetCorner(pointer, isTouch)) {
return activeObject;
}
// if we hit the corner of an activeObject, let's return that.
if (aObjects.length === 1 && activeObject._findTargetCorner(pointer, isTouch)) {
if (aObjects.length > 1 && !skipGroup && activeObject === this._searchPossibleTargets([activeObject], pointer)) {
return activeObject;

@@ -818,3 +812,3 @@ }

// http://idav.ucdavis.edu/~okreylos/TAship/Spring2000/PointInPolygon.html
(obj.containsPoint(pointer) || !!obj._findTargetCorner(pointer))
obj.containsPoint(pointer)
) {

@@ -1095,7 +1089,10 @@ if ((this.perPixelTargetFind || obj.perPixelTargetFind) && !obj.isEditing) {

var somethingChanged = false, objects = this.getActiveObjects(),
added = [], removed = [], opt = { e: e };
added = [], removed = [];
oldObjects.forEach(function(oldObject) {
if (objects.indexOf(oldObject) === -1) {
somethingChanged = true;
oldObject.fire('deselected', opt);
oldObject.fire('deselected', {
e: e,
target: oldObject
});
removed.push(oldObject);

@@ -1107,3 +1104,6 @@ }

somethingChanged = true;
object.fire('selected', opt);
object.fire('selected', {
e: e,
target: object
});
added.push(object);

@@ -1113,18 +1113,24 @@ }

if (oldObjects.length > 0 && objects.length > 0) {
opt.selected = added;
opt.deselected = removed;
// added for backward compatibility
opt.updated = added[0] || removed[0];
opt.target = this._activeObject;
somethingChanged && this.fire('selection:updated', opt);
somethingChanged && this.fire('selection:updated', {
e: e,
selected: added,
deselected: removed,
// added for backward compatibility
// deprecated
updated: added[0] || removed[0],
target: this._activeObject,
});
}
else if (objects.length > 0) {
opt.selected = added;
// added for backward compatibility
opt.target = this._activeObject;
this.fire('selection:created', opt);
this.fire('selection:created', {
e: e,
selected: added,
target: this._activeObject,
});
}
else if (oldObjects.length > 0) {
opt.deselected = removed;
this.fire('selection:cleared', opt);
this.fire('selection:cleared', {
e: e,
deselected: removed,
});
}

@@ -1148,2 +1154,6 @@ },

/**
* This is a private method for now.
* This is supposed to be equivalent to setActiveObject but without firing
* any event. There is commitment to have this stay this way.
* This is the functional part of setActiveObject.
* @private

@@ -1169,2 +1179,9 @@ * @param {Object} object to set as active

/**
* This is a private method for now.
* This is supposed to be equivalent to discardActiveObject but without firing
* any events. There is commitment to have this stay this way.
* This is the functional part of discardActiveObject.
* @param {Event} [e] Event (passed along when firing "object:deselected")
* @param {Object} object to set as active
* @return {Boolean} true if the selection happened
* @private

@@ -1280,3 +1297,3 @@ */

});
this._activeObject.realizeTransform(instance);
fabric.util.addTransformToObject(instance, this._activeObject.calcOwnMatrix());
return originalValues;

@@ -1283,0 +1300,0 @@ }

@@ -81,3 +81,3 @@ (function(global) {

ctx.fillStyle = styleOverride.cornerColor || fabricObject.cornerColor;
ctx.strokeStyle = styleOverride.strokeCornerColor || fabricObject.strokeCornerColor;
ctx.strokeStyle = styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor;
// this is still wrong

@@ -84,0 +84,0 @@ ctx.lineWidth = 1;

@@ -454,12 +454,18 @@ (function() {

if (target) {
var corner = target._findTargetCorner(
this.getPointer(e, true),
fabric.util.isTouchEvent(e)
);
var control = target.controls[corner],
mouseUpHandler = control && control.getMouseUpHandler(e, target, control);
if (mouseUpHandler) {
var pointer = this.getPointer(e);
mouseUpHandler(e, transform, pointer.x, pointer.y);
if (target.selectable && target !== this._activeObject && target.activeOn === 'up') {
this.setActiveObject(target, e);
shouldRender = true;
}
else {
var corner = target._findTargetCorner(
this.getPointer(e, true),
fabric.util.isTouchEvent(e)
);
var control = target.controls[corner],
mouseUpHandler = control && control.getMouseUpHandler(e, target, control);
if (mouseUpHandler) {
var pointer = this.getPointer(e);
mouseUpHandler(e, transform, pointer.x, pointer.y);
}
}
target.isMoving = false;

@@ -719,3 +725,3 @@ }

var alreadySelected = target === this._activeObject;
if (target.selectable) {
if (target.selectable && target.activeOn === 'down') {
this.setActiveObject(target, e);

@@ -929,3 +935,2 @@ }

transform.reset = false;
transform.target.isMoving = true;
transform.shiftKey = e.shiftKey;

@@ -954,2 +959,3 @@ transform.altKey = e[this.centeredKey];

if (action === 'drag' && actionPerformed) {
transform.target.isMoving = true;
this.setCursor(transform.target.moveCursor || this.moveCursor);

@@ -956,0 +962,0 @@ }

@@ -159,5 +159,10 @@ (function(global) {

addWithUpdate: function(object) {
var nested = !!this.group;
this._restoreObjectsState();
fabric.util.resetObjectTransform(this);
if (object) {
if (nested) {
// if this group is inside another group, we need to pre transform the object
fabric.util.removeTransformFromObject(object, this.group.calcTransformMatrix());
}
this._objects.push(object);

@@ -169,4 +174,9 @@ object.group = this;

this._updateObjectsCoords();
this.setCoords();
this.dirty = true;
if (nested) {
this.group.addWithUpdate();
}
else {
this.setCoords();
}
return this;

@@ -362,3 +372,6 @@ },

* Restores original state of each of group objects (original state is that which was before group was created).
* if the nested boolean is true, the original state will be restored just for the
* first group and not for all the group chain
* @private
* @param {Boolean} nested tell the function to restore object state up to the parent group and not more
* @return {fabric.Group} thisArg

@@ -368,3 +381,9 @@ * @chainable

_restoreObjectsState: function() {
this._objects.forEach(this._restoreObjectState, this);
var groupMatrix = this.calcOwnMatrix();
this._objects.forEach(function(object) {
// instead of using _this = this;
fabric.util.addTransformToObject(object, groupMatrix);
delete object.group;
object.setCoords();
});
return this;

@@ -378,17 +397,13 @@ },

* object.
* Warning: this method is not useful anymore, it has been kept to no break the api.
* is not used in the fabricJS codebase
* this method will be reduced to using the utility.
* @private
* @deprecated
* @param {fabric.Object} object
* @param {Array} parentMatrix parent transformation
* @return {fabric.Object} transformedObject
*/
realizeTransform: function(object) {
var matrix = object.calcTransformMatrix(),
options = fabric.util.qrDecompose(matrix),
center = new fabric.Point(options.translateX, options.translateY);
object.flipX = false;
object.flipY = false;
object.set('scaleX', options.scaleX);
object.set('scaleY', options.scaleY);
object.skewX = options.skewX;
object.skewY = options.skewY;
object.angle = options.angle;
object.setPositionByOrigin(center, 'center', 'center');
realizeTransform: function(object, parentMatrix) {
fabric.util.addTransformToObject(object, parentMatrix);
return object;

@@ -398,15 +413,2 @@ },

/**
* Restores original state of a specified object in group
* @private
* @param {fabric.Object} object
* @return {fabric.Group} thisArg
*/
_restoreObjectState: function(object) {
this.realizeTransform(object);
delete object.group;
object.setCoords();
return this;
},
/**
* Destroys a group (restoring state of its objects)

@@ -483,3 +485,3 @@ * @return {fabric.Group} thisArg

aY = [],
o, prop,
o, prop, coords,
props = ['tr', 'br', 'bl', 'tl'],

@@ -491,8 +493,9 @@ i = 0, iLen = this._objects.length,

o = this._objects[i];
o.aCoords = o.calcACoords();
coords = o.calcACoords();
for (j = 0; j < jLen; j++) {
prop = props[j];
aX.push(o.aCoords[prop].x);
aY.push(o.aCoords[prop].y);
aX.push(coords[prop].x);
aY.push(coords[prop].y);
}
o.aCoords = coords;
}

@@ -499,0 +502,0 @@

@@ -96,2 +96,11 @@ (function(global) {

/**
* List of properties to consider when checking if cache needs refresh
* Those properties are checked by statefullCache ON ( or lazy mode if we want ) or from single
* calls to Object.set(key, value). If the key is in this list, the object is marked as dirty
* and refreshed at the next render
* @type Array
*/
cacheProperties: fabric.Object.prototype.cacheProperties.concat('cropX', 'cropY'),
/**
* key used to retrieve the texture representing this image

@@ -131,3 +140,7 @@ * @since 2.0.0

* Constructor
* @param {HTMLImageElement | String} element Image element
* Image can be initialized with any canvas drawable or a string.
* The string should be a url and will be loaded as an image.
* Canvas and Image element work out of the box, while videos require extra code to work.
* Please check video element events for seeking.
* @param {HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | String} element Image element
* @param {Object} [options] Options object

@@ -557,3 +570,3 @@ * @param {function} [callback] callback function to call after eventual filters applied.

maxDestW = min(w, elWidth / scaleX - cropX),
maxDestH = min(h, elHeight / scaleX - cropY);
maxDestH = min(h, elHeight / scaleY - cropY);

@@ -560,0 +573,0 @@ elementToDraw && ctx.drawImage(elementToDraw, sX, sY, sW, sH, x, y, maxDestW, maxDestH);

@@ -474,4 +474,5 @@ (function() {

* Returns color (fill) of char at the current cursor
* Unused from the library, is for the end user
* @return {String} Character color (fill)
* if the text object has a pattern or gradient for filler, it will return that.
* Unused by the library, is for the end user
* @return {String | fabric.Gradient | fabric.Pattern} Character color (fill)
*/

@@ -478,0 +479,0 @@ getCurrentCharColor: function() {

@@ -200,2 +200,10 @@ (function(global) {

/**
* fabric.Path that the text can follow.
* This feature is in BETA.
* @type fabric.Path
* @default
*/
path: null,
/**
* @private

@@ -1307,3 +1315,4 @@ */

) {
lastDecoration && lastFill &&
if (lastDecoration && lastFill) {
ctx.fillStyle = lastFill;
ctx.fillRect(

@@ -1315,2 +1324,3 @@ leftOffset + lineLeftOffset + boxStart,

);
}
boxStart = charBox.left;

@@ -1418,5 +1428,7 @@ boxWidth = charBox.width;

'charSpacing',
'path'
].concat(propertiesToInclude);
var obj = this.callSuper('toObject', additionalProperties);
obj.styles = clone(this.styles, true);
obj.path = this.path && this.path.toObject();
return obj;

@@ -1577,7 +1589,19 @@ },

* @memberOf fabric.Text
* @param {Object} object Object to create an instance from
* @param {Object} object plain js Object to create an instance from
* @param {Function} [callback] Callback to invoke when an fabric.Text instance is created
*/
fabric.Text.fromObject = function(object, callback) {
return fabric.Object._fromObject('Text', object, callback, 'text');
var objectCopy = clone(object), path = object.path;
delete objectCopy.path;
return fabric.Object._fromObject('Text', objectCopy, function(textInstance) {
if (path) {
fabric.Object._fromObject('Path', path, function(pathInstance) {
textInstance.set('path', pathInstance);
callback(textInstance);
}, 'path');
}
else {
callback(textInstance);
}
}, 'text');
};

@@ -1584,0 +1608,0 @@

@@ -973,2 +973,55 @@ (function(global) {

/**
* given an object and a transform, apply the inverse transform to the object,
* this is equivalent to remove from that object that transformation, so that
* added in a space with the removed transform, the object will be the same as before.
* Removing from an object a transform that scale by 2 is like scaling it by 1/2.
* Removing from an object a transfrom that rotate by 30deg is like rotating by 30deg
* in the opposite direction.
* This util is used to add objects inside transformed groups or nested groups.
* @memberOf fabric.util
* @param {fabric.Object} object the object you want to transform
* @param {Array} transform the destination transform
*/
removeTransformFromObject: function(object, transform) {
var inverted = fabric.util.invertTransform(transform),
finalTransform = fabric.util.multiplyTransformMatrices(inverted, object.calcOwnMatrix());
fabric.util.applyTransformToObject(object, finalTransform);
},
/**
* given an object and a transform, apply the transform to the object.
* this is equivalent to change the space where the object is drawn.
* Adding to an object a transform that scale by 2 is like scaling it by 2.
* This is used when removing an object from an active selection for example.
* @memberOf fabric.util
* @param {fabric.Object} object the object you want to transform
* @param {Array} transform the destination transform
*/
addTransformToObject: function(object, transform) {
fabric.util.applyTransformToObject(
object,
fabric.util.multiplyTransformMatrices(transform, object.calcOwnMatrix())
);
},
/**
* discard an object transform state and apply the one from the matrix.
* @memberOf fabric.util
* @param {fabric.Object} object the object you want to transform
* @param {Array} transform the destination transform
*/
applyTransformToObject: function(object, transform) {
var options = fabric.util.qrDecompose(transform),
center = new fabric.Point(options.translateX, options.translateY);
object.flipX = false;
object.flipY = false;
object.set('scaleX', options.scaleX);
object.set('scaleY', options.scaleY);
object.skewX = options.skewX;
object.skewY = options.skewY;
object.angle = options.angle;
object.setPositionByOrigin(center, 'center', 'center');
},
/**
* given a width and height, return the size of the bounding box

@@ -975,0 +1028,0 @@ * that can contains the box with width/height with applied transform

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc