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

fabric

Package Overview
Dependencies
Maintainers
2
Versions
302
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 5.2.1 to 5.2.2-browser

179

package.json
{
"name": "fabric",
"description": "Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.",
"homepage": "http://fabricjs.com/",
"version": "5.2.1",
"author": "Juriy Zaytsev <kangax@gmail.com>",
"contributors": [
{
"name": "Andrea Bogazzi",
"email": "andreabogazzi79@gmail.com"
},
{
"name": "Steve Eberhardt",
"email": "melchiar2@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": {
"changelog": "auto-changelog -o change-output.md --unreleased-only",
"build": "node build.js modules=ALL requirejs exclude=gestures,accessors,erasing",
"build:fast": "node build.js modules=ALL requirejs fast exclude=gestures,accessors,erasing",
"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 --require ./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": {
"canvas": "^2.8.0",
"jsdom": "^19.0.0"
},
"devDependencies": {
"auto-changelog": "^2.3.0",
"chalk": "^2.4.1",
"deep-object-diff": "^1.1.7",
"eslint": "4.18.x",
"nyc": "^15.1.0",
"onchange": "^7.1.0",
"pixelmatch": "^4.0.2",
"qunit": "^2.17.2",
"testem": "^3.2.0",
"uglify-js": "3.3.x"
},
"engines": {
"node": ">=14.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": "5.2.2-browser",
"author": "Juriy Zaytsev <kangax@gmail.com>",
"contributors": [
{
"name": "Andrea Bogazzi",
"email": "andreabogazzi79@gmail.com"
},
{
"name": "Steve Eberhardt",
"email": "melchiar2@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": {
"changelog": "auto-changelog -o change-output.md --unreleased-only",
"build": "node build.js modules=ALL requirejs exclude=gestures,accessors,erasing",
"build:fast": "node build.js modules=ALL requirejs fast exclude=gestures,accessors,erasing",
"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 --require ./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": {
"auto-changelog": "^2.3.0",
"chalk": "^2.4.1",
"deep-object-diff": "^1.1.7",
"eslint": "4.18.x",
"nyc": "^15.1.0",
"onchange": "^7.1.0",
"pixelmatch": "^4.0.2",
"qunit": "^2.17.2",
"testem": "^3.2.0",
"uglify-js": "3.3.x"
},
"engines": {
"node": ">=14.0.0"
},
"main": "./dist/fabric.js",
"dependencies": {}
}

@@ -155,10 +155,2 @@ (function() {

this._hoveredTargets = [];
if (this._iTextInstances) {
this._iTextInstances.forEach(function(obj) {
if (obj.isEditing) {
obj.hiddenTextarea.focus();
}
});
}
},

@@ -165,0 +157,0 @@

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

// regain focus
document.activeElement !== this.hiddenTextarea && this.hiddenTextarea.focus();
var newSelectionStart = this.getSelectionStartFromPointer(options.e),

@@ -391,0 +394,0 @@ currentStart = this.selectionStart,

@@ -523,3 +523,3 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.prototype */ {

}
if (typeof newValue !== undefined && this[prop] !== newValue) {
if (typeof newValue !== 'undefined' && this[prop] !== newValue) {
this[prop] = newValue;

@@ -526,0 +526,0 @@ return true;

@@ -145,3 +145,3 @@ /* _TO_SVG_START_ */

nextStyle = this.getCompleteStyleDeclaration(lineIndex, i + 1);
timeToRender = this._hasStyleChangedForSvg(actualStyle, nextStyle);
timeToRender = fabric.util.hasStyleChanged(actualStyle, nextStyle, true);
}

@@ -148,0 +148,0 @@ if (timeToRender) {

@@ -572,4 +572,14 @@ (function(global) {

var group = fabric.util.groupSVGElements(elements, object, objects);
var clipPath = options.clipPath;
delete options.clipPath;
group.set(options);
callback && callback(group);
if (clipPath) {
fabric.util.enlivenObjects([clipPath], function(elivenedObjects) {
group.clipPath = elivenedObjects[0];
callback && callback(group);
});
}
else {
callback && callback(group);
}
});

@@ -579,4 +589,2 @@ return;

fabric.util.enlivenObjects(objects, function (enlivenedObjects) {
var options = fabric.util.object.clone(object, true);
delete options.objects;
fabric.util.enlivenObjectEnlivables(object, options, function () {

@@ -587,3 +595,2 @@ callback && callback(new fabric.Group(enlivenedObjects, options, true));

};
})(typeof exports !== 'undefined' ? exports : this);

@@ -513,12 +513,15 @@ (function() {

fabric.IText.fromObject = function(object, callback) {
parseDecoration(object);
if (object.styles) {
for (var i in object.styles) {
for (var j in object.styles[i]) {
parseDecoration(object.styles[i][j]);
var styles = fabric.util.stylesFromArray(object.styles, object.text);
//copy object to prevent mutation
var objCopy = Object.assign({}, object, { styles: styles });
parseDecoration(objCopy);
if (objCopy.styles) {
for (var i in objCopy.styles) {
for (var j in objCopy.styles[i]) {
parseDecoration(objCopy.styles[i][j]);
}
}
}
fabric.Object._fromObject('IText', object, callback, 'text');
fabric.Object._fromObject('IText', objCopy, callback, 'text');
};
})();

@@ -343,3 +343,11 @@ (function(global) {

path.setOptions(object);
callback && callback(path);
if (object.clipPath) {
fabric.util.enlivenObjects([object.clipPath], function(elivenedObjects) {
path.clipPath = elivenedObjects[0];
callback && callback(path);
});
}
else {
callback && callback(path);
}
});

@@ -346,0 +354,0 @@ }

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

nextStyle = this.getCompleteStyleDeclaration(lineIndex, i + 1);
timeToRender = this._hasStyleChanged(actualStyle, nextStyle);
timeToRender = fabric.util.hasStyleChanged(actualStyle, nextStyle, false);
}

@@ -1255,30 +1255,2 @@ if (timeToRender) {

* @private
* @param {Object} prevStyle
* @param {Object} thisStyle
*/
_hasStyleChanged: function(prevStyle, thisStyle) {
return prevStyle.fill !== thisStyle.fill ||
prevStyle.stroke !== thisStyle.stroke ||
prevStyle.strokeWidth !== thisStyle.strokeWidth ||
prevStyle.fontSize !== thisStyle.fontSize ||
prevStyle.fontFamily !== thisStyle.fontFamily ||
prevStyle.fontWeight !== thisStyle.fontWeight ||
prevStyle.fontStyle !== thisStyle.fontStyle ||
prevStyle.deltaY !== thisStyle.deltaY;
},
/**
* @private
* @param {Object} prevStyle
* @param {Object} thisStyle
*/
_hasStyleChangedForSvg: function(prevStyle, thisStyle) {
return this._hasStyleChanged(prevStyle, thisStyle) ||
prevStyle.overline !== thisStyle.overline ||
prevStyle.underline !== thisStyle.underline ||
prevStyle.linethrough !== thisStyle.linethrough;
},
/**
* @private
* @param {Number} lineIndex index text line

@@ -1543,4 +1515,3 @@ * @return {Number} Line left offset

var obj = this.callSuper('toObject', allProperties);
// styles will be overridden with a properly cloned structure
obj.styles = clone(this.styles, true);
obj.styles = fabric.util.stylesToArray(this.styles, this.text);
if (obj.path) {

@@ -1711,2 +1682,3 @@ obj.path = this.path.toObject();

return fabric.Object._fromObject('Text', objectCopy, function(textInstance) {
textInstance.styles = fabric.util.stylesFromArray(object.styles, object.text);
if (path) {

@@ -1713,0 +1685,0 @@ fabric.Object._fromObject('Path', path, function(pathInstance) {

@@ -456,4 +456,7 @@ (function(global) {

fabric.Textbox.fromObject = function(object, callback) {
return fabric.Object._fromObject('Textbox', object, callback, 'text');
var styles = fabric.util.stylesFromArray(object.styles, object.text);
//copy object to prevent mutation
var objCopy = Object.assign({}, object, { styles: styles });
return fabric.Object._fromObject('Textbox', objCopy, callback, 'text');
};
})(typeof exports !== 'undefined' ? exports : this);

@@ -29,3 +29,3 @@ (function () {

: property;
elementStyle[normalizedProperty] = styles[property];
elementStyle.setProperty(normalizedProperty, styles[property]);
}

@@ -32,0 +32,0 @@ }

@@ -654,2 +654,5 @@ (function(global) {

if (elements && elements.length === 1) {
if (typeof path !== 'undefined') {
elements[0].sourcePath = path;
}
return elements[0];

@@ -1219,3 +1222,110 @@ }

},
/**
* @memberOf fabric.util
* @param {Object} prevStyle first style to compare
* @param {Object} thisStyle second style to compare
* @param {boolean} forTextSpans whether to check overline, underline, and line-through properties
* @return {boolean} true if the style changed
*/
hasStyleChanged: function(prevStyle, thisStyle, forTextSpans) {
forTextSpans = forTextSpans || false;
return (prevStyle.fill !== thisStyle.fill ||
prevStyle.stroke !== thisStyle.stroke ||
prevStyle.strokeWidth !== thisStyle.strokeWidth ||
prevStyle.fontSize !== thisStyle.fontSize ||
prevStyle.fontFamily !== thisStyle.fontFamily ||
prevStyle.fontWeight !== thisStyle.fontWeight ||
prevStyle.fontStyle !== thisStyle.fontStyle ||
prevStyle.deltaY !== thisStyle.deltaY) ||
(forTextSpans &&
(prevStyle.overline !== thisStyle.overline ||
prevStyle.underline !== thisStyle.underline ||
prevStyle.linethrough !== thisStyle.linethrough));
},
/**
* Returns the array form of a text object's inline styles property with styles grouped in ranges
* rather than per character. This format is less verbose, and is better suited for storage
* so it is used in serialization (not during runtime).
* @memberOf fabric.util
* @param {object} styles per character styles for a text object
* @param {String} text the text string that the styles are applied to
* @return {{start: number, end: number, style: object}[]}
*/
stylesToArray: function(styles, text) {
// clone style structure to prevent mutation
var styles = fabric.util.object.clone(styles, true),
textLines = text.split('\n'),
charIndex = -1, prevStyle = {}, stylesArray = [];
//loop through each textLine
for (var i = 0; i < textLines.length; i++) {
if (!styles[i]) {
//no styles exist for this line, so add the line's length to the charIndex total
charIndex += textLines[i].length;
continue;
}
//loop through each character of the current line
for (var c = 0; c < textLines[i].length; c++) {
charIndex++;
var thisStyle = styles[i][c];
//check if style exists for this character
if (thisStyle) {
var styleChanged = fabric.util.hasStyleChanged(prevStyle, thisStyle, true);
if (styleChanged) {
stylesArray.push({
start: charIndex,
end: charIndex + 1,
style: thisStyle
});
}
else {
//if style is the same as previous character, increase end index
stylesArray[stylesArray.length - 1].end++;
}
}
prevStyle = thisStyle || {};
}
}
return stylesArray;
},
/**
* Returns the object form of the styles property with styles that are assigned per
* character rather than grouped by range. This format is more verbose, and is
* only used during runtime (not for serialization/storage)
* @memberOf fabric.util
* @param {Array} styles the serialized form of a text object's styles
* @param {String} text the text string that the styles are applied to
* @return {Object}
*/
stylesFromArray: function(styles, text) {
if (!Array.isArray(styles)) {
return styles;
}
var textLines = text.split('\n'),
charIndex = -1, styleIndex = 0, stylesObject = {};
//loop through each textLine
for (var i = 0; i < textLines.length; i++) {
//loop through each character of the current line
for (var c = 0; c < textLines[i].length; c++) {
charIndex++;
//check if there's a style collection that includes the current character
if (styles[styleIndex]
&& styles[styleIndex].start <= charIndex
&& charIndex < styles[styleIndex].end) {
//create object for line index if it doesn't exist
stylesObject[i] = stylesObject[i] || {};
//assign a style at this character's index
stylesObject[i][c] = Object.assign({}, styles[styleIndex].style);
//if character is at the end of the current style collection, move to the next
if (charIndex === styles[styleIndex].end - 1) {
styleIndex++;
}
}
}
}
return stylesObject;
}
};
})(typeof exports !== 'undefined' ? exports : this);

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