util-helpers 4.21.0 → 4.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/util-helpers.js +25 -15
- package/dist/util-helpers.js.map +1 -1
- package/dist/util-helpers.min.js +1 -1
- package/dist/util-helpers.min.js.map +1 -1
- package/esm/VERSION.js +1 -1
- package/esm/compressImage.js +7 -1
- package/esm/index.js +1 -1
- package/esm/loadImage.js +0 -3
- package/esm/loadImageWithBlob.js +0 -1
- package/lib/VERSION.js +1 -1
- package/lib/compressImage.js +7 -1
- package/lib/index.js +1 -1
- package/lib/loadImage.js +0 -3
- package/lib/loadImageWithBlob.js +0 -1
- package/package.json +4 -1
- package/types/getImageInfo.d.ts +2 -0
- package/types/loadImage.d.ts +2 -0
- package/types/loadImageWithBlob.d.ts +2 -0
package/dist/util-helpers.js
CHANGED
|
@@ -26,11 +26,15 @@
|
|
|
26
26
|
|
|
27
27
|
function isObject(value) {
|
|
28
28
|
var type = typeof value;
|
|
29
|
-
return
|
|
29
|
+
return type === 'function' || (type === 'object' && !!value);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function getTag(value) {
|
|
33
|
+
return objectProtoToString.call(value);
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
function isSymbol(value) {
|
|
33
|
-
return typeof value === 'symbol' ||
|
|
37
|
+
return typeof value === 'symbol' || getTag(value) === symbolTag;
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
var reIsBinary = /^0b[01]+$/i;
|
|
@@ -67,22 +71,26 @@
|
|
|
67
71
|
return remainder ? result - remainder : result;
|
|
68
72
|
}
|
|
69
73
|
|
|
74
|
+
function isNil(value) {
|
|
75
|
+
return value == null;
|
|
76
|
+
}
|
|
77
|
+
|
|
70
78
|
var symbolToString = symbolProto ? symbolProto.toString : undefined;
|
|
71
79
|
function baseToString(value) {
|
|
72
80
|
if (typeof value === 'string') {
|
|
73
81
|
return value;
|
|
74
82
|
}
|
|
75
83
|
if (isArray(value)) {
|
|
76
|
-
return
|
|
84
|
+
return '' + value.map(baseToString);
|
|
77
85
|
}
|
|
78
86
|
if (isSymbol(value)) {
|
|
79
87
|
return symbolToString ? symbolToString.call(value) : '';
|
|
80
88
|
}
|
|
81
89
|
var result = '' + value;
|
|
82
|
-
return result
|
|
90
|
+
return result === '0' && 1 / value === -Infinity ? '-0' : result;
|
|
83
91
|
}
|
|
84
92
|
function toString(value) {
|
|
85
|
-
return value
|
|
93
|
+
return isNil(value) ? '' : baseToString(value);
|
|
86
94
|
}
|
|
87
95
|
|
|
88
96
|
var blobExisted = typeof Blob !== 'undefined';
|
|
@@ -90,7 +98,7 @@
|
|
|
90
98
|
if (blobExisted && value instanceof Blob) {
|
|
91
99
|
return true;
|
|
92
100
|
}
|
|
93
|
-
return
|
|
101
|
+
return getTag(value) === blobTag;
|
|
94
102
|
}
|
|
95
103
|
|
|
96
104
|
var freeGlobalThis = globalThisExisted && globalThis.Object === Object && globalThis;
|
|
@@ -104,7 +112,7 @@
|
|
|
104
112
|
}
|
|
105
113
|
|
|
106
114
|
function isNumber(value) {
|
|
107
|
-
return typeof value === 'number' ||
|
|
115
|
+
return typeof value === 'number' || getTag(value) === numberTag;
|
|
108
116
|
}
|
|
109
117
|
|
|
110
118
|
function isNaN(value) {
|
|
@@ -116,7 +124,7 @@
|
|
|
116
124
|
}
|
|
117
125
|
|
|
118
126
|
function isString(value) {
|
|
119
|
-
return typeof value === 'string' ||
|
|
127
|
+
return typeof value === 'string' || getTag(value) === stringTag;
|
|
120
128
|
}
|
|
121
129
|
|
|
122
130
|
function decimalAdjust(type, value, precision) {
|
|
@@ -1425,7 +1433,6 @@
|
|
|
1425
1433
|
var url = createObjectURL(blob);
|
|
1426
1434
|
var image = new Image();
|
|
1427
1435
|
image.onload = function () {
|
|
1428
|
-
revokeObjectURL(url);
|
|
1429
1436
|
var result = { blob: blob, image: image };
|
|
1430
1437
|
if (useCache) {
|
|
1431
1438
|
cacheImage$2 = img;
|
|
@@ -1488,7 +1495,13 @@
|
|
|
1488
1495
|
}
|
|
1489
1496
|
var outOffset = typeof offset === 'function' ? offset(info, options) : offset;
|
|
1490
1497
|
beforeDraw === null || beforeDraw === void 0 ? void 0 : beforeDraw(info, options);
|
|
1491
|
-
|
|
1498
|
+
var dx = internalOffset[0] + toNumber(outOffset[0]);
|
|
1499
|
+
var dy = internalOffset[1] + toNumber(outOffset[1]);
|
|
1500
|
+
ctx.drawImage(image, dx, dy, image.width, image.height);
|
|
1501
|
+
if (type === 'image/png') {
|
|
1502
|
+
ctx.globalCompositeOperation = 'destination-in';
|
|
1503
|
+
ctx.drawImage(image, dx, dy, image.width, image.height);
|
|
1504
|
+
}
|
|
1492
1505
|
afterDraw === null || afterDraw === void 0 ? void 0 : afterDraw(info, options);
|
|
1493
1506
|
if (format === 'blob') {
|
|
1494
1507
|
canvasToBlob(canvas, type, numQuality).then(resolve).catch(reject);
|
|
@@ -1637,9 +1650,6 @@
|
|
|
1637
1650
|
image_1.crossOrigin = 'anonymous';
|
|
1638
1651
|
}
|
|
1639
1652
|
image_1.onload = function () {
|
|
1640
|
-
if (imgIsBlob_1) {
|
|
1641
|
-
revokeObjectURL(url_1);
|
|
1642
|
-
}
|
|
1643
1653
|
if (useCache) {
|
|
1644
1654
|
cacheImage = img;
|
|
1645
1655
|
cacheResult = image_1;
|
|
@@ -1991,9 +2001,9 @@
|
|
|
1991
2001
|
return internalFindTreeSelect(tree, predicate, childrenField);
|
|
1992
2002
|
}
|
|
1993
2003
|
|
|
1994
|
-
var VERSION = "4.21.
|
|
2004
|
+
var VERSION = "4.21.1";
|
|
1995
2005
|
|
|
1996
|
-
var version = "4.21.
|
|
2006
|
+
var version = "4.21.1";
|
|
1997
2007
|
|
|
1998
2008
|
exports.VERSION = VERSION;
|
|
1999
2009
|
exports.ajax = ajax;
|