- Linting (ESLint): Prefer `addEventListener`, exponentiation operator, avoiding catastrophic regexes, prefer spread, prefer startsWith/endsWith, no fn ref in iterator

- npm: Update devDeps (rollup and eslint-config-ash-nazg)
master
Brett Zamir 2018-11-21 21:03:14 +08:00
parent efa8cbfb83
commit 845dbbd7d7
31 changed files with 605 additions and 340 deletions

63
dist/canvg.js vendored
View File

@ -1097,7 +1097,7 @@ var canvg = (function (exports) {
if (!this.hasValue()) return 0;
var n = parseFloat(this.value);
if (String(this.value).match(/%$/)) {
if (String(this.value).endsWith('%')) {
n /= 100.0;
}
@ -1205,15 +1205,15 @@ var canvg = (function (exports) {
value: function toPixels(viewPort, processPercent) {
if (!this.hasValue()) return 0;
var s = String(this.value);
if (s.match(/em$/)) return this.numValue() * this.getEM(viewPort);
if (s.match(/ex$/)) return this.numValue() * this.getEM(viewPort) / 2.0;
if (s.match(/px$/)) return this.numValue();
if (s.match(/pt$/)) return this.numValue() * this.getDPI(viewPort) * (1.0 / 72.0);
if (s.match(/pc$/)) return this.numValue() * 15;
if (s.match(/cm$/)) return this.numValue() * this.getDPI(viewPort) / 2.54;
if (s.match(/mm$/)) return this.numValue() * this.getDPI(viewPort) / 25.4;
if (s.match(/in$/)) return this.numValue() * this.getDPI(viewPort);
if (s.match(/%$/)) return this.numValue() * svg.ViewPort.ComputeSize(viewPort);
if (s.endsWith('em')) return this.numValue() * this.getEM(viewPort);
if (s.endsWith('ex')) return this.numValue() * this.getEM(viewPort) / 2.0;
if (s.endsWith('px')) return this.numValue();
if (s.endsWith('pt')) return this.numValue() * this.getDPI(viewPort) * (1.0 / 72.0);
if (s.endsWith('pc')) return this.numValue() * 15;
if (s.endsWith('cm')) return this.numValue() * this.getDPI(viewPort) / 2.54;
if (s.endsWith('mm')) return this.numValue() * this.getDPI(viewPort) / 25.4;
if (s.endsWith('in')) return this.numValue() * this.getDPI(viewPort);
if (s.endsWith('%')) return this.numValue() * svg.ViewPort.ComputeSize(viewPort);
var n = this.numValue();
if (processPercent && n < 1.0) return n * svg.ViewPort.ComputeSize(viewPort);
return n;
@ -1225,8 +1225,8 @@ var canvg = (function (exports) {
value: function toMilliseconds() {
if (!this.hasValue()) return 0;
var s = String(this.value);
if (s.match(/s$/)) return this.numValue() * 1000;
if (s.match(/ms$/)) return this.numValue();
if (s.endsWith('ms')) return this.numValue();
if (s.endsWith('s')) return this.numValue() * 1000;
return this.numValue();
} // angle extensions
// get the angle as radians
@ -1236,9 +1236,9 @@ var canvg = (function (exports) {
value: function toRadians() {
if (!this.hasValue()) return 0;
var s = String(this.value);
if (s.match(/deg$/)) return this.numValue() * (Math.PI / 180.0);
if (s.match(/grad$/)) return this.numValue() * (Math.PI / 200.0);
if (s.match(/rad$/)) return this.numValue();
if (s.endsWith('deg')) return this.numValue() * (Math.PI / 180.0);
if (s.endsWith('grad')) return this.numValue() * (Math.PI / 200.0);
if (s.endsWith('rad')) return this.numValue();
return this.numValue() * (Math.PI / 180.0);
}
}, {
@ -1734,10 +1734,10 @@ var canvg = (function (exports) {
ctx.translate(-scaleMin * refX.toPixels('x'), -scaleMin * refY.toPixels('y'));
} else {
// align
if (align.match(/^xMid/) && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) ctx.translate(width / 2.0 - desiredWidth / 2.0, 0);
if (align.match(/YMid$/) && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) ctx.translate(0, height / 2.0 - desiredHeight / 2.0);
if (align.match(/^xMax/) && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) ctx.translate(width - desiredWidth, 0);
if (align.match(/YMax$/) && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) ctx.translate(0, height - desiredHeight);
if (align.startsWith('xMid') && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) ctx.translate(width / 2.0 - desiredWidth / 2.0, 0);
if (align.endsWith('YMid') && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) ctx.translate(0, height / 2.0 - desiredHeight / 2.0);
if (align.startsWith('xMax') && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) ctx.translate(width - desiredWidth, 0);
if (align.endsWith('YMax') && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) ctx.translate(0, height - desiredHeight);
} // scale
@ -1893,7 +1893,7 @@ var canvg = (function (exports) {
key: "getHrefAttribute",
value: function getHrefAttribute() {
for (var a in this.attributes) {
if (a.match(/:href$/)) {
if (a.endsWith(':href')) {
return this.attributes[a];
}
}
@ -2516,9 +2516,9 @@ var canvg = (function (exports) {
.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm, '$1 $2') // separate commands from commands
.replace(/([MmZzLlHhVvCcSsQqTtAa])([^\s])/gm, '$1 $2') // separate commands from points
.replace(/([^\s])([MmZzLlHhVvCcSsQqTtAa])/gm, '$1 $2') // separate commands from points
.replace(/([0-9])([+-])/gm, '$1 $2') // separate digits when no comma
.replace(/(\.[0-9]*)(\.)/gm, '$1 $2') // separate digits when no comma
.replace(/([Aa](\s+[0-9]+){3})\s+([01])\s*([01])/gm, '$1 $3 $4 '); // shorthand elliptical arc path syntax
.replace(/(\d)([+-])/gm, '$1 $2') // separate digits when no comma
.replace(/(\.\d*)(\.)/gm, '$1 $2') // separate digits when no comma
.replace(/([Aa](\s+\d+)(\s+\d+)(\s+\d+))\s+([01])\s*([01])/gm, '$1 $5 $6 '); // shorthand elliptical arc path syntax
d = svg.compressSpaces(d); // compress multiple spaces
@ -3861,14 +3861,14 @@ var canvg = (function (exports) {
_this20.img.crossOrigin = 'Anonymous';
}
_this20.img.onload = function () {
_this20.img.addEventListener('load', function () {
_this20.loaded = true;
};
});
_this20.img.onerror = function () {
_this20.img.addEventListener('error', function () {
svg.log('ERROR: image "' + href + '" not found');
_this20.loaded = true;
};
});
_this20.img.src = href;
} else {
@ -4577,7 +4577,7 @@ var canvg = (function (exports) {
if (svg.opts.ignoreMouse !== true) {
ctx.canvas.onclick = function (e) {
ctx.canvas.addEventListener('click', function (e) {
var args = !isNullish(e) ? [e.clientX, e.clientY] : [event.clientX, event.clientY]; // eslint-disable-line no-restricted-globals
var _mapXY = mapXY(_construct(svg.Point, args)),
@ -4585,9 +4585,8 @@ var canvg = (function (exports) {
y = _mapXY.y;
svg.Mouse.onclick(x, y);
};
ctx.canvas.onmousemove = function (e) {
});
ctx.canvas.addEventListener('mousemove', function (e) {
var args = !isNullish(e) ? [e.clientX, e.clientY] : [event.clientX, event.clientY]; // eslint-disable-line no-restricted-globals
var _mapXY2 = mapXY(_construct(svg.Point, args)),
@ -4595,7 +4594,7 @@ var canvg = (function (exports) {
y = _mapXY2.y;
svg.Mouse.onmousemove(x, y);
};
});
}
var e = svg.CreateElement(dom.documentElement);

View File

@ -37,6 +37,8 @@ var svgEditorExtension_connector = (function () {
};
}
/* eslint-disable unicorn/no-fn-reference-in-iterator */
/**
* ext-connector.js
*

View File

@ -65,27 +65,37 @@ var svgEditorExtension_mathjax = (function () {
return new Promise(function (resolve, reject) {
// eslint-disable-line promise/avoid-new
var script = document.createElement('script');
/**
*
* @returns {undefined}
*/
function scriptOnError() {
reject(new Error("Failed to import: ".concat(url)));
destructor();
}
/**
*
* @returns {undefined}
*/
function scriptOnLoad() {
resolve();
destructor();
}
var destructor = function destructor() {
script.onerror = null;
script.onload = null;
script.removeEventListener('error', scriptOnError);
script.removeEventListener('load', scriptOnLoad);
script.remove();
script.src = '';
};
script.defer = 'defer';
addScriptAtts(script, atts);
script.onerror = function () {
reject(new Error("Failed to import: ".concat(url)));
destructor();
};
script.onload = function () {
resolve();
destructor();
};
script.addEventListener('error', scriptOnError);
script.addEventListener('load', scriptOnLoad);
script.src = url;
document.head.append(script);
});

View File

@ -1097,7 +1097,7 @@ var svgEditorExtension_server_moinsave = (function () {
if (!this.hasValue()) return 0;
var n = parseFloat(this.value);
if (String(this.value).match(/%$/)) {
if (String(this.value).endsWith('%')) {
n /= 100.0;
}
@ -1205,15 +1205,15 @@ var svgEditorExtension_server_moinsave = (function () {
value: function toPixels(viewPort, processPercent) {
if (!this.hasValue()) return 0;
var s = String(this.value);
if (s.match(/em$/)) return this.numValue() * this.getEM(viewPort);
if (s.match(/ex$/)) return this.numValue() * this.getEM(viewPort) / 2.0;
if (s.match(/px$/)) return this.numValue();
if (s.match(/pt$/)) return this.numValue() * this.getDPI(viewPort) * (1.0 / 72.0);
if (s.match(/pc$/)) return this.numValue() * 15;
if (s.match(/cm$/)) return this.numValue() * this.getDPI(viewPort) / 2.54;
if (s.match(/mm$/)) return this.numValue() * this.getDPI(viewPort) / 25.4;
if (s.match(/in$/)) return this.numValue() * this.getDPI(viewPort);
if (s.match(/%$/)) return this.numValue() * svg.ViewPort.ComputeSize(viewPort);
if (s.endsWith('em')) return this.numValue() * this.getEM(viewPort);
if (s.endsWith('ex')) return this.numValue() * this.getEM(viewPort) / 2.0;
if (s.endsWith('px')) return this.numValue();
if (s.endsWith('pt')) return this.numValue() * this.getDPI(viewPort) * (1.0 / 72.0);
if (s.endsWith('pc')) return this.numValue() * 15;
if (s.endsWith('cm')) return this.numValue() * this.getDPI(viewPort) / 2.54;
if (s.endsWith('mm')) return this.numValue() * this.getDPI(viewPort) / 25.4;
if (s.endsWith('in')) return this.numValue() * this.getDPI(viewPort);
if (s.endsWith('%')) return this.numValue() * svg.ViewPort.ComputeSize(viewPort);
var n = this.numValue();
if (processPercent && n < 1.0) return n * svg.ViewPort.ComputeSize(viewPort);
return n;
@ -1225,8 +1225,8 @@ var svgEditorExtension_server_moinsave = (function () {
value: function toMilliseconds() {
if (!this.hasValue()) return 0;
var s = String(this.value);
if (s.match(/s$/)) return this.numValue() * 1000;
if (s.match(/ms$/)) return this.numValue();
if (s.endsWith('ms')) return this.numValue();
if (s.endsWith('s')) return this.numValue() * 1000;
return this.numValue();
} // angle extensions
// get the angle as radians
@ -1236,9 +1236,9 @@ var svgEditorExtension_server_moinsave = (function () {
value: function toRadians() {
if (!this.hasValue()) return 0;
var s = String(this.value);
if (s.match(/deg$/)) return this.numValue() * (Math.PI / 180.0);
if (s.match(/grad$/)) return this.numValue() * (Math.PI / 200.0);
if (s.match(/rad$/)) return this.numValue();
if (s.endsWith('deg')) return this.numValue() * (Math.PI / 180.0);
if (s.endsWith('grad')) return this.numValue() * (Math.PI / 200.0);
if (s.endsWith('rad')) return this.numValue();
return this.numValue() * (Math.PI / 180.0);
}
}, {
@ -1734,10 +1734,10 @@ var svgEditorExtension_server_moinsave = (function () {
ctx.translate(-scaleMin * refX.toPixels('x'), -scaleMin * refY.toPixels('y'));
} else {
// align
if (align.match(/^xMid/) && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) ctx.translate(width / 2.0 - desiredWidth / 2.0, 0);
if (align.match(/YMid$/) && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) ctx.translate(0, height / 2.0 - desiredHeight / 2.0);
if (align.match(/^xMax/) && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) ctx.translate(width - desiredWidth, 0);
if (align.match(/YMax$/) && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) ctx.translate(0, height - desiredHeight);
if (align.startsWith('xMid') && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) ctx.translate(width / 2.0 - desiredWidth / 2.0, 0);
if (align.endsWith('YMid') && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) ctx.translate(0, height / 2.0 - desiredHeight / 2.0);
if (align.startsWith('xMax') && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) ctx.translate(width - desiredWidth, 0);
if (align.endsWith('YMax') && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) ctx.translate(0, height - desiredHeight);
} // scale
@ -1893,7 +1893,7 @@ var svgEditorExtension_server_moinsave = (function () {
key: "getHrefAttribute",
value: function getHrefAttribute() {
for (var a in this.attributes) {
if (a.match(/:href$/)) {
if (a.endsWith(':href')) {
return this.attributes[a];
}
}
@ -2516,9 +2516,9 @@ var svgEditorExtension_server_moinsave = (function () {
.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm, '$1 $2') // separate commands from commands
.replace(/([MmZzLlHhVvCcSsQqTtAa])([^\s])/gm, '$1 $2') // separate commands from points
.replace(/([^\s])([MmZzLlHhVvCcSsQqTtAa])/gm, '$1 $2') // separate commands from points
.replace(/([0-9])([+-])/gm, '$1 $2') // separate digits when no comma
.replace(/(\.[0-9]*)(\.)/gm, '$1 $2') // separate digits when no comma
.replace(/([Aa](\s+[0-9]+){3})\s+([01])\s*([01])/gm, '$1 $3 $4 '); // shorthand elliptical arc path syntax
.replace(/(\d)([+-])/gm, '$1 $2') // separate digits when no comma
.replace(/(\.\d*)(\.)/gm, '$1 $2') // separate digits when no comma
.replace(/([Aa](\s+\d+)(\s+\d+)(\s+\d+))\s+([01])\s*([01])/gm, '$1 $5 $6 '); // shorthand elliptical arc path syntax
d = svg.compressSpaces(d); // compress multiple spaces
@ -3861,14 +3861,14 @@ var svgEditorExtension_server_moinsave = (function () {
_this20.img.crossOrigin = 'Anonymous';
}
_this20.img.onload = function () {
_this20.img.addEventListener('load', function () {
_this20.loaded = true;
};
});
_this20.img.onerror = function () {
_this20.img.addEventListener('error', function () {
svg.log('ERROR: image "' + href + '" not found');
_this20.loaded = true;
};
});
_this20.img.src = href;
} else {
@ -4577,7 +4577,7 @@ var svgEditorExtension_server_moinsave = (function () {
if (svg.opts.ignoreMouse !== true) {
ctx.canvas.onclick = function (e) {
ctx.canvas.addEventListener('click', function (e) {
var args = !isNullish(e) ? [e.clientX, e.clientY] : [event.clientX, event.clientY]; // eslint-disable-line no-restricted-globals
var _mapXY = mapXY(_construct(svg.Point, args)),
@ -4585,9 +4585,8 @@ var svgEditorExtension_server_moinsave = (function () {
y = _mapXY.y;
svg.Mouse.onclick(x, y);
};
ctx.canvas.onmousemove = function (e) {
});
ctx.canvas.addEventListener('mousemove', function (e) {
var args = !isNullish(e) ? [e.clientX, e.clientY] : [event.clientX, event.clientY]; // eslint-disable-line no-restricted-globals
var _mapXY2 = mapXY(_construct(svg.Point, args)),
@ -4595,7 +4594,7 @@ var svgEditorExtension_server_moinsave = (function () {
y = _mapXY2.y;
svg.Mouse.onmousemove(x, y);
};
});
}
var e = svg.CreateElement(dom.documentElement);

View File

@ -1097,7 +1097,7 @@ var svgEditorExtension_server_opensave = (function () {
if (!this.hasValue()) return 0;
var n = parseFloat(this.value);
if (String(this.value).match(/%$/)) {
if (String(this.value).endsWith('%')) {
n /= 100.0;
}
@ -1205,15 +1205,15 @@ var svgEditorExtension_server_opensave = (function () {
value: function toPixels(viewPort, processPercent) {
if (!this.hasValue()) return 0;
var s = String(this.value);
if (s.match(/em$/)) return this.numValue() * this.getEM(viewPort);
if (s.match(/ex$/)) return this.numValue() * this.getEM(viewPort) / 2.0;
if (s.match(/px$/)) return this.numValue();
if (s.match(/pt$/)) return this.numValue() * this.getDPI(viewPort) * (1.0 / 72.0);
if (s.match(/pc$/)) return this.numValue() * 15;
if (s.match(/cm$/)) return this.numValue() * this.getDPI(viewPort) / 2.54;
if (s.match(/mm$/)) return this.numValue() * this.getDPI(viewPort) / 25.4;
if (s.match(/in$/)) return this.numValue() * this.getDPI(viewPort);
if (s.match(/%$/)) return this.numValue() * svg.ViewPort.ComputeSize(viewPort);
if (s.endsWith('em')) return this.numValue() * this.getEM(viewPort);
if (s.endsWith('ex')) return this.numValue() * this.getEM(viewPort) / 2.0;
if (s.endsWith('px')) return this.numValue();
if (s.endsWith('pt')) return this.numValue() * this.getDPI(viewPort) * (1.0 / 72.0);
if (s.endsWith('pc')) return this.numValue() * 15;
if (s.endsWith('cm')) return this.numValue() * this.getDPI(viewPort) / 2.54;
if (s.endsWith('mm')) return this.numValue() * this.getDPI(viewPort) / 25.4;
if (s.endsWith('in')) return this.numValue() * this.getDPI(viewPort);
if (s.endsWith('%')) return this.numValue() * svg.ViewPort.ComputeSize(viewPort);
var n = this.numValue();
if (processPercent && n < 1.0) return n * svg.ViewPort.ComputeSize(viewPort);
return n;
@ -1225,8 +1225,8 @@ var svgEditorExtension_server_opensave = (function () {
value: function toMilliseconds() {
if (!this.hasValue()) return 0;
var s = String(this.value);
if (s.match(/s$/)) return this.numValue() * 1000;
if (s.match(/ms$/)) return this.numValue();
if (s.endsWith('ms')) return this.numValue();
if (s.endsWith('s')) return this.numValue() * 1000;
return this.numValue();
} // angle extensions
// get the angle as radians
@ -1236,9 +1236,9 @@ var svgEditorExtension_server_opensave = (function () {
value: function toRadians() {
if (!this.hasValue()) return 0;
var s = String(this.value);
if (s.match(/deg$/)) return this.numValue() * (Math.PI / 180.0);
if (s.match(/grad$/)) return this.numValue() * (Math.PI / 200.0);
if (s.match(/rad$/)) return this.numValue();
if (s.endsWith('deg')) return this.numValue() * (Math.PI / 180.0);
if (s.endsWith('grad')) return this.numValue() * (Math.PI / 200.0);
if (s.endsWith('rad')) return this.numValue();
return this.numValue() * (Math.PI / 180.0);
}
}, {
@ -1734,10 +1734,10 @@ var svgEditorExtension_server_opensave = (function () {
ctx.translate(-scaleMin * refX.toPixels('x'), -scaleMin * refY.toPixels('y'));
} else {
// align
if (align.match(/^xMid/) && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) ctx.translate(width / 2.0 - desiredWidth / 2.0, 0);
if (align.match(/YMid$/) && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) ctx.translate(0, height / 2.0 - desiredHeight / 2.0);
if (align.match(/^xMax/) && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) ctx.translate(width - desiredWidth, 0);
if (align.match(/YMax$/) && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) ctx.translate(0, height - desiredHeight);
if (align.startsWith('xMid') && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) ctx.translate(width / 2.0 - desiredWidth / 2.0, 0);
if (align.endsWith('YMid') && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) ctx.translate(0, height / 2.0 - desiredHeight / 2.0);
if (align.startsWith('xMax') && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) ctx.translate(width - desiredWidth, 0);
if (align.endsWith('YMax') && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) ctx.translate(0, height - desiredHeight);
} // scale
@ -1893,7 +1893,7 @@ var svgEditorExtension_server_opensave = (function () {
key: "getHrefAttribute",
value: function getHrefAttribute() {
for (var a in this.attributes) {
if (a.match(/:href$/)) {
if (a.endsWith(':href')) {
return this.attributes[a];
}
}
@ -2516,9 +2516,9 @@ var svgEditorExtension_server_opensave = (function () {
.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm, '$1 $2') // separate commands from commands
.replace(/([MmZzLlHhVvCcSsQqTtAa])([^\s])/gm, '$1 $2') // separate commands from points
.replace(/([^\s])([MmZzLlHhVvCcSsQqTtAa])/gm, '$1 $2') // separate commands from points
.replace(/([0-9])([+-])/gm, '$1 $2') // separate digits when no comma
.replace(/(\.[0-9]*)(\.)/gm, '$1 $2') // separate digits when no comma
.replace(/([Aa](\s+[0-9]+){3})\s+([01])\s*([01])/gm, '$1 $3 $4 '); // shorthand elliptical arc path syntax
.replace(/(\d)([+-])/gm, '$1 $2') // separate digits when no comma
.replace(/(\.\d*)(\.)/gm, '$1 $2') // separate digits when no comma
.replace(/([Aa](\s+\d+)(\s+\d+)(\s+\d+))\s+([01])\s*([01])/gm, '$1 $5 $6 '); // shorthand elliptical arc path syntax
d = svg.compressSpaces(d); // compress multiple spaces
@ -3861,14 +3861,14 @@ var svgEditorExtension_server_opensave = (function () {
_this20.img.crossOrigin = 'Anonymous';
}
_this20.img.onload = function () {
_this20.img.addEventListener('load', function () {
_this20.loaded = true;
};
});
_this20.img.onerror = function () {
_this20.img.addEventListener('error', function () {
svg.log('ERROR: image "' + href + '" not found');
_this20.loaded = true;
};
});
_this20.img.src = href;
} else {
@ -4577,7 +4577,7 @@ var svgEditorExtension_server_opensave = (function () {
if (svg.opts.ignoreMouse !== true) {
ctx.canvas.onclick = function (e) {
ctx.canvas.addEventListener('click', function (e) {
var args = !isNullish(e) ? [e.clientX, e.clientY] : [event.clientX, event.clientY]; // eslint-disable-line no-restricted-globals
var _mapXY = mapXY(_construct(svg.Point, args)),
@ -4585,9 +4585,8 @@ var svgEditorExtension_server_opensave = (function () {
y = _mapXY.y;
svg.Mouse.onclick(x, y);
};
ctx.canvas.onmousemove = function (e) {
});
ctx.canvas.addEventListener('mousemove', function (e) {
var args = !isNullish(e) ? [e.clientX, e.clientY] : [event.clientX, event.clientY]; // eslint-disable-line no-restricted-globals
var _mapXY2 = mapXY(_construct(svg.Point, args)),
@ -4595,7 +4594,7 @@ var svgEditorExtension_server_opensave = (function () {
y = _mapXY2.y;
svg.Mouse.onmousemove(x, y);
};
});
}
var e = svg.CreateElement(dom.documentElement);

View File

@ -43,8 +43,7 @@
if (!href.includes('.svg')) {
var img = new Image();
img.onload = function () {
img.addEventListener('load', function () {
var canvas = document.createElement('canvas');
canvas.width = this.width;
canvas.height = this.height; // load the raster image into the canvas
@ -67,8 +66,7 @@
href: href,
data: data
});
};
});
img.src = href;
} else {
// Do ajax request for image's href value

86
dist/index-es.js vendored
View File

@ -8328,7 +8328,7 @@ var getPathBBox = function getPathBBox(path$$1) {
var getCalc = function getCalc(j, P1, P2, P3) {
return function (t) {
return Math.pow(1 - t, 3) * P0[j] + 3 * Math.pow(1 - t, 2) * t * P1[j] + 3 * (1 - t) * Math.pow(t, 2) * P2[j] + Math.pow(t, 3) * P3[j];
return 1 - Math.pow(t, 3) * P0[j] + 3 * 1 - Math.pow(t, 2) * t * P1[j] + 3 * (1 - t) * Math.pow(t, 2) * P2[j] + Math.pow(t, 3) * P3[j];
};
};
@ -9458,27 +9458,37 @@ function importScript(url) {
return new Promise(function (resolve, reject) {
// eslint-disable-line promise/avoid-new
var script = document.createElement('script');
/**
*
* @returns {undefined}
*/
function scriptOnError() {
reject(new Error("Failed to import: ".concat(url)));
destructor();
}
/**
*
* @returns {undefined}
*/
function scriptOnLoad() {
resolve();
destructor();
}
var destructor = function destructor() {
script.onerror = null;
script.onload = null;
script.removeEventListener('error', scriptOnError);
script.removeEventListener('load', scriptOnLoad);
script.remove();
script.src = '';
};
script.defer = 'defer';
addScriptAtts(script, atts);
script.onerror = function () {
reject(new Error("Failed to import: ".concat(url)));
destructor();
};
script.onload = function () {
resolve();
destructor();
};
script.addEventListener('error', scriptOnError);
script.addEventListener('load', scriptOnLoad);
script.src = url;
document.head.append(script);
});
@ -9510,11 +9520,30 @@ function importModule(url) {
// eslint-disable-line promise/avoid-new
var vector = '$importModule$' + Math.random().toString(32).slice(2);
var script = document.createElement('script');
/**
*
* @returns {undefined}
*/
function scriptOnError() {
reject(new Error("Failed to import: ".concat(url)));
destructor();
}
/**
*
* @returns {undefined}
*/
function scriptOnLoad() {
resolve(window[vector]);
destructor();
}
var destructor = function destructor() {
delete window[vector];
script.onerror = null;
script.onload = null;
script.removeEventListener('error', scriptOnError);
script.removeEventListener('load', scriptOnLoad);
script.remove();
URL.revokeObjectURL(script.src);
script.src = '';
@ -9523,17 +9552,8 @@ function importModule(url) {
addScriptAtts(script, atts);
script.defer = 'defer';
script.type = 'module';
script.onerror = function () {
reject(new Error("Failed to import: ".concat(url)));
destructor();
};
script.onload = function () {
resolve(window[vector]);
destructor();
};
script.addEventListener('error', scriptOnError);
script.addEventListener('load', scriptOnLoad);
var absURL = toAbsoluteURL(url);
var loader = "import * as m from '".concat(absURL.replace(/'/g, "\\'"), "'; window.").concat(vector, " = ").concat(returnDefault ? 'm.default || ' : '', "m;"); // export Module
@ -17434,7 +17454,9 @@ function SvgCanvas(container, config) {
if (elem) {
cleanupElement(elem);
var attrs = Array.from(elem.attributes);
var attrs = _toConsumableArray(elem.attributes);
var childs = elem.childNodes;
attrs.sort(function (a, b) {
return a.name > b.name ? -1 : 1;
@ -35854,13 +35876,11 @@ editor.init = function () {
var imgHeight = 100;
var img = new Image();
img.style.opacity = 0;
img.onload = function () {
img.addEventListener('load', function () {
imgWidth = img.offsetWidth || img.naturalWidth || img.width;
imgHeight = img.offsetHeight || img.naturalHeight || img.height;
insertNewImage(imgWidth, imgHeight);
};
});
img.src = result;
};
@ -36336,7 +36356,7 @@ editor.loadFromDataURI = function (str) {
if (pre) {
base64 = true;
} else {
pre = str.match(/^data:image\/svg\+xml(?:;(?:utf8)?)?,/);
pre = str.match(/^data:image\/svg\+xml(?:;|;utf8)?,/);
}
if (pre) {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

86
dist/index-umd.js vendored
View File

@ -8334,7 +8334,7 @@
var getCalc = function getCalc(j, P1, P2, P3) {
return function (t) {
return Math.pow(1 - t, 3) * P0[j] + 3 * Math.pow(1 - t, 2) * t * P1[j] + 3 * (1 - t) * Math.pow(t, 2) * P2[j] + Math.pow(t, 3) * P3[j];
return 1 - Math.pow(t, 3) * P0[j] + 3 * 1 - Math.pow(t, 2) * t * P1[j] + 3 * (1 - t) * Math.pow(t, 2) * P2[j] + Math.pow(t, 3) * P3[j];
};
};
@ -9464,27 +9464,37 @@
return new Promise(function (resolve, reject) {
// eslint-disable-line promise/avoid-new
var script = document.createElement('script');
/**
*
* @returns {undefined}
*/
function scriptOnError() {
reject(new Error("Failed to import: ".concat(url)));
destructor();
}
/**
*
* @returns {undefined}
*/
function scriptOnLoad() {
resolve();
destructor();
}
var destructor = function destructor() {
script.onerror = null;
script.onload = null;
script.removeEventListener('error', scriptOnError);
script.removeEventListener('load', scriptOnLoad);
script.remove();
script.src = '';
};
script.defer = 'defer';
addScriptAtts(script, atts);
script.onerror = function () {
reject(new Error("Failed to import: ".concat(url)));
destructor();
};
script.onload = function () {
resolve();
destructor();
};
script.addEventListener('error', scriptOnError);
script.addEventListener('load', scriptOnLoad);
script.src = url;
document.head.append(script);
});
@ -9516,11 +9526,30 @@
// eslint-disable-line promise/avoid-new
var vector = '$importModule$' + Math.random().toString(32).slice(2);
var script = document.createElement('script');
/**
*
* @returns {undefined}
*/
function scriptOnError() {
reject(new Error("Failed to import: ".concat(url)));
destructor();
}
/**
*
* @returns {undefined}
*/
function scriptOnLoad() {
resolve(window[vector]);
destructor();
}
var destructor = function destructor() {
delete window[vector];
script.onerror = null;
script.onload = null;
script.removeEventListener('error', scriptOnError);
script.removeEventListener('load', scriptOnLoad);
script.remove();
URL.revokeObjectURL(script.src);
script.src = '';
@ -9529,17 +9558,8 @@
addScriptAtts(script, atts);
script.defer = 'defer';
script.type = 'module';
script.onerror = function () {
reject(new Error("Failed to import: ".concat(url)));
destructor();
};
script.onload = function () {
resolve(window[vector]);
destructor();
};
script.addEventListener('error', scriptOnError);
script.addEventListener('load', scriptOnLoad);
var absURL = toAbsoluteURL(url);
var loader = "import * as m from '".concat(absURL.replace(/'/g, "\\'"), "'; window.").concat(vector, " = ").concat(returnDefault ? 'm.default || ' : '', "m;"); // export Module
@ -17440,7 +17460,9 @@
if (elem) {
cleanupElement(elem);
var attrs = Array.from(elem.attributes);
var attrs = _toConsumableArray(elem.attributes);
var childs = elem.childNodes;
attrs.sort(function (a, b) {
return a.name > b.name ? -1 : 1;
@ -35860,13 +35882,11 @@
var imgHeight = 100;
var img = new Image();
img.style.opacity = 0;
img.onload = function () {
img.addEventListener('load', function () {
imgWidth = img.offsetWidth || img.naturalWidth || img.width;
imgHeight = img.offsetHeight || img.naturalHeight || img.height;
insertNewImage(imgWidth, imgHeight);
};
});
img.src = result;
};
@ -36342,7 +36362,7 @@
if (pre) {
base64 = true;
} else {
pre = str.match(/^data:image\/svg\+xml(?:;(?:utf8)?)?,/);
pre = str.match(/^data:image\/svg\+xml(?:;|;utf8)?,/);
}
if (pre) {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -428,14 +428,16 @@
});
};
var numRgx = /[+-]?(?:\d+\.\d*|\d+|\.\d+)(?:[eE][+-]?\d+)?/g;
var numRgx = /[+-]?(?:\d+\.\d*|\d+|\.\d+)(?:[eE]\d+|[eE][+-]\d+)?/g;
var getLinesOptionsOfPoly = function getLinesOptionsOfPoly(node) {
var nums = node.getAttribute('points');
nums = nums && nums.match(numRgx) || [];
if (nums && nums.length) {
nums = nums.map(Number);
nums = nums.map(function (n) {
return Number(n);
});
if (nums.length % 2) {
nums.length--;

View File

@ -131,7 +131,7 @@ function build (opts) {
if (d === 'x') return this.width();
if (d === 'y') return this.height();
return Math.sqrt(
Math.pow(this.width(), 2) + Math.pow(this.height(), 2)
(this.width() ** 2) + (this.height() ** 2)
) / Math.sqrt(2);
}
};
@ -222,7 +222,7 @@ function build (opts) {
if (!this.hasValue()) return 0;
let n = parseFloat(this.value);
if (String(this.value).match(/%$/)) {
if (String(this.value).endsWith('%')) {
n /= 100.0;
}
return n;
@ -307,15 +307,15 @@ function build (opts) {
toPixels (viewPort, processPercent) {
if (!this.hasValue()) return 0;
const s = String(this.value);
if (s.match(/em$/)) return this.numValue() * this.getEM(viewPort);
if (s.match(/ex$/)) return this.numValue() * this.getEM(viewPort) / 2.0;
if (s.match(/px$/)) return this.numValue();
if (s.match(/pt$/)) return this.numValue() * this.getDPI(viewPort) * (1.0 / 72.0);
if (s.match(/pc$/)) return this.numValue() * 15;
if (s.match(/cm$/)) return this.numValue() * this.getDPI(viewPort) / 2.54;
if (s.match(/mm$/)) return this.numValue() * this.getDPI(viewPort) / 25.4;
if (s.match(/in$/)) return this.numValue() * this.getDPI(viewPort);
if (s.match(/%$/)) return this.numValue() * svg.ViewPort.ComputeSize(viewPort);
if (s.endsWith('em')) return this.numValue() * this.getEM(viewPort);
if (s.endsWith('ex')) return this.numValue() * this.getEM(viewPort) / 2.0;
if (s.endsWith('px')) return this.numValue();
if (s.endsWith('pt')) return this.numValue() * this.getDPI(viewPort) * (1.0 / 72.0);
if (s.endsWith('pc')) return this.numValue() * 15;
if (s.endsWith('cm')) return this.numValue() * this.getDPI(viewPort) / 2.54;
if (s.endsWith('mm')) return this.numValue() * this.getDPI(viewPort) / 25.4;
if (s.endsWith('in')) return this.numValue() * this.getDPI(viewPort);
if (s.endsWith('%')) return this.numValue() * svg.ViewPort.ComputeSize(viewPort);
const n = this.numValue();
if (processPercent && n < 1.0) return n * svg.ViewPort.ComputeSize(viewPort);
return n;
@ -326,8 +326,8 @@ function build (opts) {
toMilliseconds () {
if (!this.hasValue()) return 0;
const s = String(this.value);
if (s.match(/s$/)) return this.numValue() * 1000;
if (s.match(/ms$/)) return this.numValue();
if (s.endsWith('ms')) return this.numValue();
if (s.endsWith('s')) return this.numValue() * 1000;
return this.numValue();
}
@ -336,9 +336,9 @@ function build (opts) {
toRadians () {
if (!this.hasValue()) return 0;
const s = String(this.value);
if (s.match(/deg$/)) return this.numValue() * (Math.PI / 180.0);
if (s.match(/grad$/)) return this.numValue() * (Math.PI / 200.0);
if (s.match(/rad$/)) return this.numValue();
if (s.endsWith('deg')) return this.numValue() * (Math.PI / 180.0);
if (s.endsWith('grad')) return this.numValue() * (Math.PI / 200.0);
if (s.endsWith('rad')) return this.numValue();
return this.numValue() * (Math.PI / 180.0);
}
@ -503,10 +503,10 @@ function build (opts) {
for (let i = 0; i <= 1; i++) {
const f = function (t) {
return Math.pow(1 - t, 3) * p0[i] +
3 * Math.pow(1 - t, 2) * t * p1[i] +
3 * (1 - t) * Math.pow(t, 2) * p2[i] +
Math.pow(t, 3) * p3[i];
return ((1 - t) ** 3) * p0[i] +
3 * ((1 - t) ** 2) * t * p1[i] +
3 * (1 - t) * (t ** 2) * p2[i] +
(t ** 3) * p3[i];
};
const b = 6 * p0[i] - 12 * p1[i] + 6 * p2[i];
@ -523,7 +523,7 @@ function build (opts) {
continue;
}
const b2ac = Math.pow(b, 2) - 4 * c * a;
const b2ac = (b ** 2) - 4 * c * a;
if (b2ac < 0) continue;
const t1 = (-b + Math.sqrt(b2ac)) / (2 * a);
if (t1 > 0 && t1 < 1) {
@ -685,10 +685,10 @@ function build (opts) {
ctx.translate(-scaleMin * refX.toPixels('x'), -scaleMin * refY.toPixels('y'));
} else {
// align
if (align.match(/^xMid/) && ((meetOrSlice === 'meet' && scaleMin === scaleY) || (meetOrSlice === 'slice' && scaleMax === scaleY))) ctx.translate(width / 2.0 - desiredWidth / 2.0, 0);
if (align.match(/YMid$/) && ((meetOrSlice === 'meet' && scaleMin === scaleX) || (meetOrSlice === 'slice' && scaleMax === scaleX))) ctx.translate(0, height / 2.0 - desiredHeight / 2.0);
if (align.match(/^xMax/) && ((meetOrSlice === 'meet' && scaleMin === scaleY) || (meetOrSlice === 'slice' && scaleMax === scaleY))) ctx.translate(width - desiredWidth, 0);
if (align.match(/YMax$/) && ((meetOrSlice === 'meet' && scaleMin === scaleX) || (meetOrSlice === 'slice' && scaleMax === scaleX))) ctx.translate(0, height - desiredHeight);
if (align.startsWith('xMid') && ((meetOrSlice === 'meet' && scaleMin === scaleY) || (meetOrSlice === 'slice' && scaleMax === scaleY))) ctx.translate(width / 2.0 - desiredWidth / 2.0, 0);
if (align.endsWith('YMid') && ((meetOrSlice === 'meet' && scaleMin === scaleX) || (meetOrSlice === 'slice' && scaleMax === scaleX))) ctx.translate(0, height / 2.0 - desiredHeight / 2.0);
if (align.startsWith('xMax') && ((meetOrSlice === 'meet' && scaleMin === scaleY) || (meetOrSlice === 'slice' && scaleMax === scaleY))) ctx.translate(width - desiredWidth, 0);
if (align.endsWith('YMax') && ((meetOrSlice === 'meet' && scaleMin === scaleX) || (meetOrSlice === 'slice' && scaleMax === scaleX))) ctx.translate(0, height - desiredHeight);
}
// scale
@ -805,7 +805,7 @@ function build (opts) {
getHrefAttribute () {
for (const a in this.attributes) {
if (a.match(/:href$/)) {
if (a.endsWith(':href')) {
return this.attributes[a];
}
}
@ -1254,9 +1254,9 @@ function build (opts) {
.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm, '$1 $2') // separate commands from commands
.replace(/([MmZzLlHhVvCcSsQqTtAa])([^\s])/gm, '$1 $2') // separate commands from points
.replace(/([^\s])([MmZzLlHhVvCcSsQqTtAa])/gm, '$1 $2') // separate commands from points
.replace(/([0-9])([+-])/gm, '$1 $2') // separate digits when no comma
.replace(/(\.[0-9]*)(\.)/gm, '$1 $2') // separate digits when no comma
.replace(/([Aa](\s+[0-9]+){3})\s+([01])\s*([01])/gm, '$1 $3 $4 '); // shorthand elliptical arc path syntax
.replace(/(\d)([+-])/gm, '$1 $2') // separate digits when no comma
.replace(/(\.\d*)(\.)/gm, '$1 $2') // separate digits when no comma
.replace(/([Aa](\s+\d+)(\s+\d+)(\s+\d+))\s+([01])\s*([01])/gm, '$1 $5 $6 '); // shorthand elliptical arc path syntax
d = svg.compressSpaces(d); // compress multiple spaces
d = svg.trim(d);
this.PathParser = {
@ -1501,15 +1501,15 @@ function build (opts) {
-Math.sin(xAxisRotation) * (curr.x - cp.x) / 2.0 + Math.cos(xAxisRotation) * (curr.y - cp.y) / 2.0
);
// adjust radii
const l = Math.pow(currp.x, 2) / Math.pow(rx, 2) + Math.pow(currp.y, 2) / Math.pow(ry, 2);
const l = (currp.x ** 2) / (rx ** 2) + (currp.y ** 2) / (ry ** 2);
if (l > 1) {
rx *= Math.sqrt(l);
ry *= Math.sqrt(l);
}
// cx', cy'
let s = (largeArcFlag === sweepFlag ? -1 : 1) * Math.sqrt(
((Math.pow(rx, 2) * Math.pow(ry, 2)) - (Math.pow(rx, 2) * Math.pow(currp.y, 2)) - (Math.pow(ry, 2) * Math.pow(currp.x, 2))) /
(Math.pow(rx, 2) * Math.pow(currp.y, 2) + Math.pow(ry, 2) * Math.pow(currp.x, 2))
(((rx ** 2) * (ry ** 2)) - ((rx ** 2) * (currp.y ** 2)) - ((ry ** 2) * (currp.x ** 2))) /
((rx ** 2) * (currp.y ** 2) + (ry ** 2) * (currp.x ** 2))
);
if (isNaN(s)) s = 0;
const cpp = new svg.Point(s * rx * currp.y / ry, s * -ry * currp.x / rx);
@ -1520,7 +1520,7 @@ function build (opts) {
);
// vector magnitude
const m = function (v) {
return Math.sqrt(Math.pow(v[0], 2) + Math.pow(v[1], 2));
return Math.sqrt((v[0] ** 2) + (v[1] ** 2));
};
// ratio between two vectors
const r = function (u, v) {
@ -2281,13 +2281,13 @@ function build (opts) {
if (svg.opts.useCORS === true) {
this.img.crossOrigin = 'Anonymous';
}
this.img.onload = () => {
this.img.addEventListener('load', () => {
this.loaded = true;
};
this.img.onerror = () => {
});
this.img.addEventListener('error', () => {
svg.log('ERROR: image "' + href + '" not found');
this.loaded = true;
};
});
this.img.src = href;
} else {
svg.ajax(href, true).then((img) => { // eslint-disable-line promise/prefer-await-to-then, promise/always-return
@ -2769,20 +2769,20 @@ function build (opts) {
// bind mouse
if (svg.opts.ignoreMouse !== true) {
ctx.canvas.onclick = function (e) {
ctx.canvas.addEventListener('click', function (e) {
const args = !isNullish(e)
? [e.clientX, e.clientY]
: [event.clientX, event.clientY]; // eslint-disable-line no-restricted-globals
const {x, y} = mapXY(new svg.Point(...args));
svg.Mouse.onclick(x, y);
};
ctx.canvas.onmousemove = function (e) {
});
ctx.canvas.addEventListener('mousemove', function (e) {
const args = !isNullish(e)
? [e.clientX, e.clientY]
: [event.clientX, event.clientY]; // eslint-disable-line no-restricted-globals
const {x, y} = mapXY(new svg.Point(...args));
svg.Mouse.onmousemove(x, y);
};
});
}
const e = svg.CreateElement(dom.documentElement);

View File

@ -1,3 +1,4 @@
/* eslint-disable unicorn/no-fn-reference-in-iterator */
/**
* ext-connector.js
*

View File

@ -20,7 +20,7 @@ $('a').click(function () {
});
if (!href.includes('.svg')) {
const img = new Image();
img.onload = function () {
img.addEventListener('load', function () {
const canvas = document.createElement('canvas');
canvas.width = this.width;
canvas.height = this.height;
@ -37,7 +37,7 @@ $('a').click(function () {
data = '';
}
post({href, data});
};
});
img.src = href;
} else {
// Do ajax request for image's href value

View File

@ -79,22 +79,32 @@ export function importScript (url, atts = {}) {
}
return new Promise((resolve, reject) => { // eslint-disable-line promise/avoid-new
const script = document.createElement('script');
/**
*
* @returns {undefined}
*/
function scriptOnError () {
reject(new Error(`Failed to import: ${url}`));
destructor();
}
/**
*
* @returns {undefined}
*/
function scriptOnLoad () {
resolve();
destructor();
}
const destructor = () => {
script.onerror = null;
script.onload = null;
script.removeEventListener('error', scriptOnError);
script.removeEventListener('load', scriptOnLoad);
script.remove();
script.src = '';
};
script.defer = 'defer';
addScriptAtts(script, atts);
script.onerror = () => {
reject(new Error(`Failed to import: ${url}`));
destructor();
};
script.onload = () => {
resolve();
destructor();
};
script.addEventListener('error', scriptOnError);
script.addEventListener('load', scriptOnLoad);
script.src = url;
document.head.append(script);
@ -119,10 +129,26 @@ export function importModule (url, atts = {}, {returnDefault = false} = {}) {
return new Promise((resolve, reject) => { // eslint-disable-line promise/avoid-new
const vector = '$importModule$' + Math.random().toString(32).slice(2);
const script = document.createElement('script');
/**
*
* @returns {undefined}
*/
function scriptOnError () {
reject(new Error(`Failed to import: ${url}`));
destructor();
}
/**
*
* @returns {undefined}
*/
function scriptOnLoad () {
resolve(window[vector]);
destructor();
}
const destructor = () => {
delete window[vector];
script.onerror = null;
script.onload = null;
script.removeEventListener('error', scriptOnError);
script.removeEventListener('load', scriptOnLoad);
script.remove();
URL.revokeObjectURL(script.src);
script.src = '';
@ -130,14 +156,8 @@ export function importModule (url, atts = {}, {returnDefault = false} = {}) {
addScriptAtts(script, atts);
script.defer = 'defer';
script.type = 'module';
script.onerror = () => {
reject(new Error(`Failed to import: ${url}`));
destructor();
};
script.onload = () => {
resolve(window[vector]);
destructor();
};
script.addEventListener('error', scriptOnError);
script.addEventListener('load', scriptOnLoad);
const absURL = toAbsoluteURL(url);
const loader = `import * as m from '${absURL.replace(/'/g, "\\'")}'; window.${vector} = ${returnDefault ? 'm.default || ' : ''}m;`; // export Module
const blob = new Blob([loader], {type: 'text/javascript'});

View File

@ -1052,7 +1052,7 @@ export default function jQueryPluginJGraduate ($) {
switch (slider.type) {
case 'radius':
x = Math.pow(x * 2, 2.5);
x = (x * 2) ** 2.5;
if (x > 0.98 && x < 1.02) x = 1;
if (x <= 0.01) x = 0.01;
curGradient.setAttribute('r', x);
@ -1171,7 +1171,7 @@ export default function jQueryPluginJGraduate ($) {
switch (type) {
case 'radius':
if (isRad) curGradient.setAttribute('r', val / 100);
xpos = (Math.pow(val / 100, 1 / 2.5) / 2) * SLIDERW;
xpos = (((val / 100) ** (1 / 2.5)) / 2) * SLIDERW;
break;
case 'opacity':

View File

@ -26,7 +26,7 @@
*/
function toFixedNumeric (value, precision) {
if (precision === undefined) precision = 0;
return Math.round(value * Math.pow(10, precision)) / Math.pow(10, precision);
return Math.round(value * (10 ** precision)) / (10 ** precision);
}
/**

View File

@ -57,12 +57,12 @@ const removeAttributes = function (node, attributes) {
});
};
const numRgx = /[+-]?(?:\d+\.\d*|\d+|\.\d+)(?:[eE][+-]?\d+)?/g;
const numRgx = /[+-]?(?:\d+\.\d*|\d+|\.\d+)(?:[eE]\d+|[eE][+-]\d+)?/g;
const getLinesOptionsOfPoly = function (node) {
let nums = node.getAttribute('points');
nums = (nums && nums.match(numRgx)) || [];
if (nums && nums.length) {
nums = nums.map(Number);
nums = nums.map((n) => Number(n));
if (nums.length % 2) {
nums.length--;
}

View File

@ -1,3 +1,4 @@
/* eslint-disable unicorn/no-fn-reference-in-iterator */
/* globals jQuery */
/**
* Localizing script for SVG-edit UI

View File

@ -6138,11 +6138,11 @@ editor.init = function () {
let imgHeight = 100;
const img = new Image();
img.style.opacity = 0;
img.onload = function () {
img.addEventListener('load', function () {
imgWidth = img.offsetWidth || img.naturalWidth || img.width;
imgHeight = img.offsetHeight || img.naturalHeight || img.height;
insertNewImage(imgWidth, imgHeight);
};
});
img.src = result;
};
reader.readAsDataURL(file);
@ -6431,7 +6431,7 @@ editor.loadFromDataURI = function (str, {noAlert} = {}) {
if (pre) {
base64 = true;
} else {
pre = str.match(/^data:image\/svg\+xml(?:;(?:utf8)?)?,/);
pre = str.match(/^data:image\/svg\+xml(?:;|;utf8)?,/);
}
if (pre) {
pre = pre[0];

View File

@ -1,4 +1,4 @@
/* eslint-disable indent */
/* eslint-disable indent, unicorn/no-fn-reference-in-iterator */
/* globals jQuery, jsPDF */
/**
* Numerous tools for working with the editor's "canvas"
@ -3656,7 +3656,7 @@ this.svgToString = function (elem, indent) {
if (elem) {
cleanupElement(elem);
const attrs = Array.from(elem.attributes);
const attrs = [...elem.attributes];
const childs = elem.childNodes;
attrs.sort((a, b) => {
return a.name > b.name ? -1 : 1;

View File

@ -804,7 +804,7 @@ if (!('SVGPathSegList' in window) || !('appendItem' in window.SVGPathSegList.pro
number *= sign;
if (exponent) {
number *= Math.pow(10, expsign * exponent);
number *= 10 ** (expsign * exponent);
}
if (startIndex === this._currentIndex) {

View File

@ -497,10 +497,10 @@ export const getPathBBox = function (path) {
const getCalc = function (j, P1, P2, P3) {
return function (t) {
return Math.pow(1 - t, 3) * P0[j] +
3 * Math.pow(1 - t, 2) * t * P1[j] +
3 * (1 - t) * Math.pow(t, 2) * P2[j] +
Math.pow(t, 3) * P3[j];
return 1 - (t ** 3) * P0[j] +
3 * 1 - (t ** 2) * t * P1[j] +
3 * (1 - t) * (t ** 2) * P2[j] +
(t ** 3) * P3[j];
};
};
@ -533,7 +533,7 @@ export const getPathBBox = function (path) {
}
continue;
}
const b2ac = Math.pow(b, 2) - 4 * c * a;
const b2ac = (b ** 2) - 4 * c * a;
if (b2ac < 0) { continue; }
const t1 = (-b + Math.sqrt(b2ac)) / (2 * a);
if (t1 > 0 && t1 < 1) { bounds[j].push(calc(t1)); }

View File

@ -8331,7 +8331,7 @@
var getCalc = function getCalc(j, P1, P2, P3) {
return function (t) {
return Math.pow(1 - t, 3) * P0[j] + 3 * Math.pow(1 - t, 2) * t * P1[j] + 3 * (1 - t) * Math.pow(t, 2) * P2[j] + Math.pow(t, 3) * P3[j];
return 1 - Math.pow(t, 3) * P0[j] + 3 * 1 - Math.pow(t, 2) * t * P1[j] + 3 * (1 - t) * Math.pow(t, 2) * P2[j] + Math.pow(t, 3) * P3[j];
};
};
@ -9461,27 +9461,37 @@
return new Promise(function (resolve, reject) {
// eslint-disable-line promise/avoid-new
var script = document.createElement('script');
/**
*
* @returns {undefined}
*/
function scriptOnError() {
reject(new Error("Failed to import: ".concat(url)));
destructor();
}
/**
*
* @returns {undefined}
*/
function scriptOnLoad() {
resolve();
destructor();
}
var destructor = function destructor() {
script.onerror = null;
script.onload = null;
script.removeEventListener('error', scriptOnError);
script.removeEventListener('load', scriptOnLoad);
script.remove();
script.src = '';
};
script.defer = 'defer';
addScriptAtts(script, atts);
script.onerror = function () {
reject(new Error("Failed to import: ".concat(url)));
destructor();
};
script.onload = function () {
resolve();
destructor();
};
script.addEventListener('error', scriptOnError);
script.addEventListener('load', scriptOnLoad);
script.src = url;
document.head.append(script);
});
@ -9513,11 +9523,30 @@
// eslint-disable-line promise/avoid-new
var vector = '$importModule$' + Math.random().toString(32).slice(2);
var script = document.createElement('script');
/**
*
* @returns {undefined}
*/
function scriptOnError() {
reject(new Error("Failed to import: ".concat(url)));
destructor();
}
/**
*
* @returns {undefined}
*/
function scriptOnLoad() {
resolve(window[vector]);
destructor();
}
var destructor = function destructor() {
delete window[vector];
script.onerror = null;
script.onload = null;
script.removeEventListener('error', scriptOnError);
script.removeEventListener('load', scriptOnLoad);
script.remove();
URL.revokeObjectURL(script.src);
script.src = '';
@ -9526,17 +9555,8 @@
addScriptAtts(script, atts);
script.defer = 'defer';
script.type = 'module';
script.onerror = function () {
reject(new Error("Failed to import: ".concat(url)));
destructor();
};
script.onload = function () {
resolve(window[vector]);
destructor();
};
script.addEventListener('error', scriptOnError);
script.addEventListener('load', scriptOnLoad);
var absURL = toAbsoluteURL(url);
var loader = "import * as m from '".concat(absURL.replace(/'/g, "\\'"), "'; window.").concat(vector, " = ").concat(returnDefault ? 'm.default || ' : '', "m;"); // export Module
@ -17437,7 +17457,9 @@
if (elem) {
cleanupElement(elem);
var attrs = Array.from(elem.attributes);
var attrs = _toConsumableArray(elem.attributes);
var childs = elem.childNodes;
attrs.sort(function (a, b) {
return a.name > b.name ? -1 : 1;
@ -35857,13 +35879,11 @@
var imgHeight = 100;
var img = new Image();
img.style.opacity = 0;
img.onload = function () {
img.addEventListener('load', function () {
imgWidth = img.offsetWidth || img.naturalWidth || img.width;
imgHeight = img.offsetHeight || img.naturalHeight || img.height;
insertNewImage(imgWidth, imgHeight);
};
});
img.src = result;
};
@ -36339,7 +36359,7 @@
if (pre) {
base64 = true;
} else {
pre = str.match(/^data:image\/svg\+xml(?:;(?:utf8)?)?,/);
pre = str.match(/^data:image\/svg\+xml(?:;|;utf8)?,/);
}
if (pre) {

164
package-lock.json generated
View File

@ -2972,6 +2972,15 @@
}
}
},
"clean-regexp": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/clean-regexp/-/clean-regexp-1.0.0.tgz",
"integrity": "sha1-jffHquUf02h06PjQW5GAvBGj/tc=",
"dev": true,
"requires": {
"escape-string-regexp": "^1.0.5"
}
},
"cli-cursor": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz",
@ -3744,6 +3753,16 @@
}
}
},
"eslint-ast-utils": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/eslint-ast-utils/-/eslint-ast-utils-1.1.0.tgz",
"integrity": "sha512-otzzTim2/1+lVrlH19EfQQJEhVJSu0zOb9ygb3iapN6UlyaDtyRq4b5U1FuW0v1lRa9Fp/GJyHkSwm6NqABgCA==",
"dev": true,
"requires": {
"lodash.get": "^4.4.2",
"lodash.zip": "^4.2.0"
}
},
"eslint-config-airbnb-base": {
"version": "13.1.0",
"resolved": "https://registry.npmjs.org/eslint-config-airbnb-base/-/eslint-config-airbnb-base-13.1.0.tgz",
@ -3756,9 +3775,9 @@
}
},
"eslint-config-ash-nazg": {
"version": "0.0.4",
"resolved": "https://registry.npmjs.org/eslint-config-ash-nazg/-/eslint-config-ash-nazg-0.0.4.tgz",
"integrity": "sha512-/yyNXE57lbHHqHr+GfwoNt0wzYdVuIKJRFtBFuKm0J2FUv/ZBYaspBCow4Syk8s3Ax+pLsfv7Sksf3edAQpmqg==",
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/eslint-config-ash-nazg/-/eslint-config-ash-nazg-0.1.1.tgz",
"integrity": "sha512-iUDDkx0newCYMeuR+taRInJL2ONAXfvx5+b2CRMD0u+MUffLMP4bNY99C4GuGkD0gQ3/0a/VD7AQj7wE4KXmEQ==",
"dev": true
},
"eslint-config-standard": {
@ -3966,6 +3985,18 @@
}
}
},
"eslint-plugin-no-use-extend-native": {
"version": "0.3.12",
"resolved": "https://registry.npmjs.org/eslint-plugin-no-use-extend-native/-/eslint-plugin-no-use-extend-native-0.3.12.tgz",
"integrity": "sha1-OtmgDC3yO11/f2vpFVCYWkq3Aeo=",
"dev": true,
"requires": {
"is-get-set-prop": "^1.0.0",
"is-js-type": "^2.0.0",
"is-obj-prop": "^1.0.0",
"is-proto-prop": "^1.0.0"
}
},
"eslint-plugin-node": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-8.0.0.tgz",
@ -4012,6 +4043,22 @@
"integrity": "sha1-QIn2RtrbabE3agHX5ggYSQfmA2s=",
"dev": true
},
"eslint-plugin-unicorn": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-6.0.1.tgz",
"integrity": "sha512-hjy9LhTdtL7pz8WTrzS0CGXRkWK3VAPLDjihofj8JC+uxQLfXm0WwZPPPB7xKmcjRyoH+jruPHOCrHNEINpG/Q==",
"dev": true,
"requires": {
"clean-regexp": "^1.0.0",
"eslint-ast-utils": "^1.0.0",
"import-modules": "^1.1.0",
"lodash.camelcase": "^4.1.1",
"lodash.kebabcase": "^4.0.1",
"lodash.snakecase": "^4.0.1",
"lodash.upperfirst": "^4.2.0",
"safe-regex": "^1.1.0"
}
},
"eslint-restricted-globals": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/eslint-restricted-globals/-/eslint-restricted-globals-0.1.1.tgz",
@ -5212,6 +5259,12 @@
"integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=",
"dev": true
},
"get-set-props": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/get-set-props/-/get-set-props-0.1.0.tgz",
"integrity": "sha1-mYR1wXhEVobQsyJG2l3428++jqM=",
"dev": true
},
"get-stdin": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-6.0.0.tgz",
@ -5719,6 +5772,12 @@
"integrity": "sha512-8/gvXvX2JMn0F+CDlSC4l6kOmVaLOO3XLkksI7CI3Ud95KDYJuYur2b9P/PUt/i/pDAMd/DulQsNbbbmRRsDIQ==",
"dev": true
},
"import-modules": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/import-modules/-/import-modules-1.1.0.tgz",
"integrity": "sha1-dI23nFzEK7lwHvq0JPiU5yYA6dw=",
"dev": true
},
"imurmurhash": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz",
@ -5993,6 +6052,16 @@
"integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=",
"dev": true
},
"is-get-set-prop": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-get-set-prop/-/is-get-set-prop-1.0.0.tgz",
"integrity": "sha1-JzGHfk14pqae3M5rudaLB3nnYxI=",
"dev": true,
"requires": {
"get-set-props": "^0.1.0",
"lowercase-keys": "^1.0.0"
}
},
"is-glob": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.0.tgz",
@ -6014,6 +6083,15 @@
"integrity": "sha512-175UKecS8+U4hh2PSY0j4xnm2GKYzvSKnbh+naC93JjuBA7LgIo6YxlbcsSo6seFBdQO3RuIcH980yvqqD/2cA==",
"dev": true
},
"is-js-type": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/is-js-type/-/is-js-type-2.0.0.tgz",
"integrity": "sha1-c2FwBtZZtOtHKbunR9KHgt8PfiI=",
"dev": true,
"requires": {
"js-types": "^1.0.0"
}
},
"is-module": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz",
@ -6040,6 +6118,16 @@
}
}
},
"is-obj-prop": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-obj-prop/-/is-obj-prop-1.0.0.tgz",
"integrity": "sha1-s03nnEULjXxzqyzfZ9yHWtuF+A4=",
"dev": true,
"requires": {
"lowercase-keys": "^1.0.0",
"obj-props": "^1.0.0"
}
},
"is-object": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/is-object/-/is-object-1.0.1.tgz",
@ -6103,6 +6191,16 @@
"integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=",
"dev": true
},
"is-proto-prop": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/is-proto-prop/-/is-proto-prop-1.0.1.tgz",
"integrity": "sha512-dkmgrJB7nfJhH1ySK1/Qn9xLPMv3ZNlPSAPoyUseD6DQzBF6YmbgQnoyy9OM8derNUlDVJlUGdCEhYbcCPfN5A==",
"dev": true,
"requires": {
"lowercase-keys": "^1.0.0",
"proto-props": "^1.1.0"
}
},
"is-regex": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz",
@ -6236,6 +6334,12 @@
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
"dev": true
},
"js-types": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/js-types/-/js-types-1.0.0.tgz",
"integrity": "sha1-0kLmSU7Vcq08koCfyL7X92h8vwM=",
"dev": true
},
"js-yaml": {
"version": "3.12.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz",
@ -6721,6 +6825,12 @@
"integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==",
"dev": true
},
"lodash.camelcase": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz",
"integrity": "sha1-soqmKIorn8ZRA1x3EfZathkDMaY=",
"dev": true
},
"lodash.debounce": {
"version": "4.0.8",
"resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz",
@ -6733,12 +6843,36 @@
"integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=",
"dev": true
},
"lodash.kebabcase": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/lodash.kebabcase/-/lodash.kebabcase-4.1.1.tgz",
"integrity": "sha1-hImxyw0p/4gZXM7KRI/21swpXDY=",
"dev": true
},
"lodash.snakecase": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/lodash.snakecase/-/lodash.snakecase-4.1.1.tgz",
"integrity": "sha1-OdcUo1NXFHg3rv1ktdy7Fr7Nj40=",
"dev": true
},
"lodash.sortby": {
"version": "4.7.0",
"resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz",
"integrity": "sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=",
"dev": true
},
"lodash.upperfirst": {
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/lodash.upperfirst/-/lodash.upperfirst-4.3.1.tgz",
"integrity": "sha1-E2Xt9DFIBIHvDRxolXpe2Z1J984=",
"dev": true
},
"lodash.zip": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/lodash.zip/-/lodash.zip-4.2.0.tgz",
"integrity": "sha1-7GZi5IlkCO1KtsVCo5kLcswIACA=",
"dev": true
},
"log-update-async-hook": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/log-update-async-hook/-/log-update-async-hook-2.0.2.tgz",
@ -6790,6 +6924,12 @@
"signal-exit": "^3.0.0"
}
},
"lowercase-keys": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz",
"integrity": "sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA==",
"dev": true
},
"lru-cache": {
"version": "2.6.3",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.6.3.tgz",
@ -7365,6 +7505,12 @@
"integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==",
"dev": true
},
"obj-props": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/obj-props/-/obj-props-1.1.0.tgz",
"integrity": "sha1-YmMT+qRCvv1KROmgLDy2vek3tRE=",
"dev": true
},
"object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
@ -7946,6 +8092,12 @@
"pinkie-promise": "^2.0.0"
}
},
"proto-props": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/proto-props/-/proto-props-1.1.0.tgz",
"integrity": "sha512-A377CdhQBRjYVsSWrm2jo0KJa+N/IBew6lGLm0pdzZjtVqlUT23wEqg7q1/bk5gBEgVoBBbaErZY+UUNrcKOug==",
"dev": true
},
"prr": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz",
@ -8573,9 +8725,9 @@
}
},
"rollup": {
"version": "0.67.1",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-0.67.1.tgz",
"integrity": "sha512-BfwL9pw5VyxrAWx/G1tP8epgG+NH4KcR78aoWacV7+dFp1Mj6ynH8QTIC/lDQ3KlwzDakqZmJQ4LQ7TmLg+pBA==",
"version": "0.67.3",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-0.67.3.tgz",
"integrity": "sha512-TyNQCz97rKuVVbsKUTXfwIjV7UljWyTVd7cTMuE+aqlQ7WJslkYF5QaYGjMLR2BlQtUOO5CAxSVnpQ55iYp5jg==",
"dev": true,
"requires": {
"@types/estree": "0.0.39",

View File

@ -84,17 +84,19 @@
"axe-testcafe": "^1.1.0",
"babel-plugin-transform-object-rest-spread": "^7.0.0-beta.3",
"eslint": "5.9.0",
"eslint-config-ash-nazg": "0.0.4",
"eslint-config-ash-nazg": "0.1.1",
"eslint-config-standard": "12.0.0",
"eslint-plugin-compat": "2.6.3",
"eslint-plugin-import": "2.14.0",
"eslint-plugin-jsdoc": "https://github.com/brettz9/eslint-plugin-jsdoc#Deploy",
"eslint-plugin-markdown": "^1.0.0-rc.0",
"eslint-plugin-no-use-extend-native": "^0.3.12",
"eslint-plugin-node": "8.0.0",
"eslint-plugin-promise": "4.0.1",
"eslint-plugin-qunit": "^4.0.0",
"eslint-plugin-standard": "4.0.0",
"eslint-plugin-testcafe": "^0.2.1",
"eslint-plugin-unicorn": "^6.0.1",
"find-in-files": "^0.5.0",
"imageoptim-cli": "^2.0.4",
"jamilih": "^0.43.0",
@ -108,7 +110,7 @@
"qunit": "^2.8.0",
"remark-cli": "^6.0.1",
"remark-lint-ordered-list-marker-value": "^1.0.2",
"rollup": "0.67.1",
"rollup": "0.67.3",
"rollup-plugin-babel": "^4.0.3",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-json": "^3.1.0",

View File

@ -18,7 +18,7 @@ const isDirectory = (source) => {
return lstatSync(source).isDirectory();
};
const getDirectories = (source) => {
return readdirSync(source).map((nme) => join(source, nme)).filter(isDirectory);
return readdirSync(source).map((nme) => join(source, nme)).filter((i) => isDirectory(i));
};
const extensionLocaleDirs = getDirectories('editor/extensions/ext-locale');
const extensionLocaleFiles = [];

View File

@ -8331,7 +8331,7 @@
var getCalc = function getCalc(j, P1, P2, P3) {
return function (t) {
return Math.pow(1 - t, 3) * P0[j] + 3 * Math.pow(1 - t, 2) * t * P1[j] + 3 * (1 - t) * Math.pow(t, 2) * P2[j] + Math.pow(t, 3) * P3[j];
return 1 - Math.pow(t, 3) * P0[j] + 3 * 1 - Math.pow(t, 2) * t * P1[j] + 3 * (1 - t) * Math.pow(t, 2) * P2[j] + Math.pow(t, 3) * P3[j];
};
};
@ -9461,27 +9461,37 @@
return new Promise(function (resolve, reject) {
// eslint-disable-line promise/avoid-new
var script = document.createElement('script');
/**
*
* @returns {undefined}
*/
function scriptOnError() {
reject(new Error("Failed to import: ".concat(url)));
destructor();
}
/**
*
* @returns {undefined}
*/
function scriptOnLoad() {
resolve();
destructor();
}
var destructor = function destructor() {
script.onerror = null;
script.onload = null;
script.removeEventListener('error', scriptOnError);
script.removeEventListener('load', scriptOnLoad);
script.remove();
script.src = '';
};
script.defer = 'defer';
addScriptAtts(script, atts);
script.onerror = function () {
reject(new Error("Failed to import: ".concat(url)));
destructor();
};
script.onload = function () {
resolve();
destructor();
};
script.addEventListener('error', scriptOnError);
script.addEventListener('load', scriptOnLoad);
script.src = url;
document.head.append(script);
});
@ -9513,11 +9523,30 @@
// eslint-disable-line promise/avoid-new
var vector = '$importModule$' + Math.random().toString(32).slice(2);
var script = document.createElement('script');
/**
*
* @returns {undefined}
*/
function scriptOnError() {
reject(new Error("Failed to import: ".concat(url)));
destructor();
}
/**
*
* @returns {undefined}
*/
function scriptOnLoad() {
resolve(window[vector]);
destructor();
}
var destructor = function destructor() {
delete window[vector];
script.onerror = null;
script.onload = null;
script.removeEventListener('error', scriptOnError);
script.removeEventListener('load', scriptOnLoad);
script.remove();
URL.revokeObjectURL(script.src);
script.src = '';
@ -9526,17 +9555,8 @@
addScriptAtts(script, atts);
script.defer = 'defer';
script.type = 'module';
script.onerror = function () {
reject(new Error("Failed to import: ".concat(url)));
destructor();
};
script.onload = function () {
resolve(window[vector]);
destructor();
};
script.addEventListener('error', scriptOnError);
script.addEventListener('load', scriptOnLoad);
var absURL = toAbsoluteURL(url);
var loader = "import * as m from '".concat(absURL.replace(/'/g, "\\'"), "'; window.").concat(vector, " = ").concat(returnDefault ? 'm.default || ' : '', "m;"); // export Module
@ -17437,7 +17457,9 @@
if (elem) {
cleanupElement(elem);
var attrs = Array.from(elem.attributes);
var attrs = _toConsumableArray(elem.attributes);
var childs = elem.childNodes;
attrs.sort(function (a, b) {
return a.name > b.name ? -1 : 1;
@ -35857,13 +35879,11 @@
var imgHeight = 100;
var img = new Image();
img.style.opacity = 0;
img.onload = function () {
img.addEventListener('load', function () {
imgWidth = img.offsetWidth || img.naturalWidth || img.width;
imgHeight = img.offsetHeight || img.naturalHeight || img.height;
insertNewImage(imgWidth, imgHeight);
};
});
img.src = result;
};
@ -36339,7 +36359,7 @@
if (pre) {
base64 = true;
} else {
pre = str.match(/^data:image\/svg\+xml(?:;(?:utf8)?)?,/);
pre = str.match(/^data:image\/svg\+xml(?:;|;utf8)?,/);
}
if (pre) {

View File

@ -256,7 +256,7 @@ QUnit.test('Test getPathDFromElement', function (assert) {
attr: {id: 'roundrect', x: '0', y: '1', rx: '2', ry: '3', width: '10', height: '11'}
});
svgroot.append(elem);
const closeEnough = new RegExp('M0,4 C0,2.3[0-9]* 0.9[0-9]*,1 2,1 L8,1 C9.0[0-9]*,1 10,2.3[0-9]* 10,4 L10,9 C10,10.6[0-9]* 9.08675799086758,12 8,12 L2,12 C0.9[0-9]*,12 0,10.6[0-9]* 0,9 L0,4 Z');
const closeEnough = new RegExp('M0,4 C0,2.3\\d* 0.9\\d*,1 2,1 L8,1 C9.0\\d*,1 10,2.3\\d* 10,4 L10,9 C10,10.6\\d* 9.08675799086758,12 8,12 L2,12 C0.9\\d*,12 0,10.6\\d* 0,9 L0,4 Z');
assert.equal(closeEnough.test(getPathDFromElement(elem)), true);
elem.remove();