util-helpers 4.21.5 → 4.21.6
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 +6 -5
- 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 +2 -1
- package/esm/download.js +2 -2
- package/esm/index.js +1 -1
- package/esm/isChinese.js +2 -2
- package/esm/utils/native.js +2 -1
- package/lib/VERSION.js +1 -1
- package/lib/compressImage.js +2 -1
- package/lib/download.js +1 -1
- package/lib/index.js +1 -1
- package/lib/isChinese.js +1 -1
- package/lib/utils/native.js +1 -0
- package/package.json +1 -1
- package/types/utils/native.d.ts +1 -0
package/esm/VERSION.js
CHANGED
package/esm/compressImage.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { toNumber } from 'ut2';
|
|
2
2
|
import loadImageWithBlob from './loadImageWithBlob.js';
|
|
3
|
+
import { nativeUndefined } from './utils/native.js';
|
|
3
4
|
|
|
4
5
|
function canvasToBlob(canvas, type, quality) {
|
|
5
6
|
return new Promise(function (resolve) {
|
|
@@ -41,7 +42,7 @@ var compressImage = function (img, options) {
|
|
|
41
42
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
42
43
|
}
|
|
43
44
|
var internalOffset = [0, 0];
|
|
44
|
-
if (rotate !==
|
|
45
|
+
if (rotate !== nativeUndefined) {
|
|
45
46
|
ctx.translate(image.width / 2, image.height / 2);
|
|
46
47
|
internalOffset = [-image.width / 2, -image.height / 2];
|
|
47
48
|
ctx.rotate((rotate * Math.PI) / 180);
|
package/esm/download.js
CHANGED
|
@@ -3,7 +3,7 @@ import { isBlob, isPromiseLike } from 'ut2';
|
|
|
3
3
|
import dataURLToBlob from './dataURLToBlob.js';
|
|
4
4
|
import isUrl from './isUrl.js';
|
|
5
5
|
import ajax from './ajax.js';
|
|
6
|
-
import { createObjectURL, revokeObjectURL } from './utils/native.js';
|
|
6
|
+
import { createObjectURL, revokeObjectURL, nativeUndefined } from './utils/native.js';
|
|
7
7
|
|
|
8
8
|
function saver(blobUrl, fileName) {
|
|
9
9
|
if (fileName === void 0) { fileName = ''; }
|
|
@@ -59,7 +59,7 @@ function download(data, options) {
|
|
|
59
59
|
case 5:
|
|
60
60
|
res = _a.sent();
|
|
61
61
|
currentFileName = fileName || data.split('?')[0].split('#')[0].split('/').pop();
|
|
62
|
-
return [2, download(res, { fileName: currentFileName, type: type || (isBlob(res) ? res.type :
|
|
62
|
+
return [2, download(res, { fileName: currentFileName, type: type || (isBlob(res) ? res.type : nativeUndefined) })];
|
|
63
63
|
case 6:
|
|
64
64
|
payload = new Blob([data], { type: type || 'text/plain' });
|
|
65
65
|
_a.label = 7;
|
package/esm/index.js
CHANGED
package/esm/isChinese.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { toString } from 'ut2';
|
|
2
|
-
import { objectValues } from './utils/native.js';
|
|
2
|
+
import { objectValues, nativeUndefined } from './utils/native.js';
|
|
3
3
|
|
|
4
4
|
var chineseDictionary = {
|
|
5
5
|
chineseBasic: '[\u4e00-\u9fa5]',
|
|
@@ -29,7 +29,7 @@ function isChinese(value, options) {
|
|
|
29
29
|
var extendRegExp = loose ? looseChineseExtendRegExp : chineseExtendRegExp;
|
|
30
30
|
var hasExtend = useExtend && supportRegExpUnicode;
|
|
31
31
|
var resultRegExp = hasExtend ? extendRegExp : basicRegExp;
|
|
32
|
-
var flag = hasExtend ? 'u' :
|
|
32
|
+
var flag = hasExtend ? 'u' : nativeUndefined;
|
|
33
33
|
var reg = new RegExp(resultRegExp, flag);
|
|
34
34
|
return reg.test(valueStr);
|
|
35
35
|
}
|
package/esm/utils/native.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { constant, noop } from 'ut2';
|
|
2
2
|
import { URLExisted } from './setup.js';
|
|
3
3
|
|
|
4
|
+
var nativeUndefined = void 0;
|
|
4
5
|
var objectKeys = Object.keys;
|
|
5
6
|
var objectValues = Object.values;
|
|
6
7
|
var createObjectURL = URLExisted ? URL.createObjectURL : constant('');
|
|
7
8
|
var revokeObjectURL = URLExisted ? URL.revokeObjectURL : noop;
|
|
8
9
|
|
|
9
|
-
export { createObjectURL, objectKeys, objectValues, revokeObjectURL };
|
|
10
|
+
export { createObjectURL, nativeUndefined, objectKeys, objectValues, revokeObjectURL };
|
package/lib/VERSION.js
CHANGED
package/lib/compressImage.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var ut2 = require('ut2');
|
|
4
4
|
var loadImageWithBlob = require('./loadImageWithBlob.js');
|
|
5
|
+
var native = require('./utils/native.js');
|
|
5
6
|
|
|
6
7
|
function canvasToBlob(canvas, type, quality) {
|
|
7
8
|
return new Promise(function (resolve) {
|
|
@@ -43,7 +44,7 @@ var compressImage = function (img, options) {
|
|
|
43
44
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
44
45
|
}
|
|
45
46
|
var internalOffset = [0, 0];
|
|
46
|
-
if (rotate !==
|
|
47
|
+
if (rotate !== native.nativeUndefined) {
|
|
47
48
|
ctx.translate(image.width / 2, image.height / 2);
|
|
48
49
|
internalOffset = [-image.width / 2, -image.height / 2];
|
|
49
50
|
ctx.rotate((rotate * Math.PI) / 180);
|
package/lib/download.js
CHANGED
|
@@ -61,7 +61,7 @@ function download(data, options) {
|
|
|
61
61
|
case 5:
|
|
62
62
|
res = _a.sent();
|
|
63
63
|
currentFileName = fileName || data.split('?')[0].split('#')[0].split('/').pop();
|
|
64
|
-
return [2, download(res, { fileName: currentFileName, type: type || (ut2.isBlob(res) ? res.type :
|
|
64
|
+
return [2, download(res, { fileName: currentFileName, type: type || (ut2.isBlob(res) ? res.type : native.nativeUndefined) })];
|
|
65
65
|
case 6:
|
|
66
66
|
payload = new Blob([data], { type: type || 'text/plain' });
|
|
67
67
|
_a.label = 7;
|
package/lib/index.js
CHANGED
|
@@ -66,7 +66,7 @@ var findTreeSelect = require('./findTreeSelect.js');
|
|
|
66
66
|
var config = require('./utils/config.js');
|
|
67
67
|
var VERSION = require('./VERSION.js');
|
|
68
68
|
|
|
69
|
-
exports.version = "4.21.
|
|
69
|
+
exports.version = "4.21.6";
|
|
70
70
|
|
|
71
71
|
exports.isMobile = isMobile;
|
|
72
72
|
exports.isTelephone = isTelephone;
|
package/lib/isChinese.js
CHANGED
|
@@ -31,7 +31,7 @@ function isChinese(value, options) {
|
|
|
31
31
|
var extendRegExp = loose ? looseChineseExtendRegExp : chineseExtendRegExp;
|
|
32
32
|
var hasExtend = useExtend && supportRegExpUnicode;
|
|
33
33
|
var resultRegExp = hasExtend ? extendRegExp : basicRegExp;
|
|
34
|
-
var flag = hasExtend ? 'u' :
|
|
34
|
+
var flag = hasExtend ? 'u' : native.nativeUndefined;
|
|
35
35
|
var reg = new RegExp(resultRegExp, flag);
|
|
36
36
|
return reg.test(valueStr);
|
|
37
37
|
}
|
package/lib/utils/native.js
CHANGED
package/package.json
CHANGED
package/types/utils/native.d.ts
CHANGED