diginext-utils 1.2.4 → 2.0.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/Checker.js +7 -8
- package/dist/Checker.mjs +25 -0
- package/dist/EventDispatcher.js +20 -19
- package/dist/EventDispatcher.mjs +51 -0
- package/dist/FileUpload.js +24 -29
- package/dist/FileUpload.mjs +60 -0
- package/dist/Slug.js +286 -340
- package/dist/Slug.mjs +327 -0
- package/dist/Timer.js +8 -11
- package/dist/Timer.mjs +2 -0
- package/dist/Validation.js +11 -19
- package/dist/Validation.mjs +33 -0
- package/dist/array.js +100 -203
- package/dist/array.mjs +3 -0
- package/dist/backend/file/createDir.js +13 -13
- package/dist/backend/file/createDir.mjs +13 -0
- package/dist/backend/file/fileMove.js +14 -14
- package/dist/backend/file/fileMove.mjs +29 -0
- package/dist/backend/file/findFilesByExt.js +22 -22
- package/dist/backend/file/findFilesByExt.mjs +40 -0
- package/dist/chunk-5AL36RZR.mjs +47 -0
- package/dist/chunk-7IYY7BKN.mjs +136 -0
- package/dist/chunk-ACLBWYEO.mjs +85 -0
- package/dist/chunk-AHFJBIQJ.mjs +9 -0
- package/dist/chunk-AKU6F3WT.mjs +9 -0
- package/dist/chunk-FOWYH6LL.mjs +32 -0
- package/dist/chunk-FTE6FZSH.mjs +17 -0
- package/dist/chunk-JKYSZLBF.mjs +27 -0
- package/dist/chunk-LXQIKFED.mjs +13 -0
- package/dist/chunk-Q5R25OIS.mjs +185 -0
- package/dist/chunk-R2BH5I6O.mjs +9 -0
- package/dist/chunk-UKRVCU5M.mjs +166 -0
- package/dist/chunk-VFKAZAWF.mjs +40 -0
- package/dist/chunk-VZGV2BTL.mjs +27 -0
- package/dist/chunk-Y4ZTQWPA.mjs +68 -0
- package/dist/color.js +44 -61
- package/dist/color.mjs +62 -0
- package/dist/console/enableConsole.js +14 -11
- package/dist/console/enableConsole.mjs +2 -0
- package/dist/console/index.js +14 -11
- package/dist/console/index.mjs +2 -0
- package/dist/device/browser.js +29 -27
- package/dist/device/browser.mjs +2 -0
- package/dist/device/camera.js +65 -125
- package/dist/device/camera.mjs +3 -0
- package/dist/device.js +76 -181
- package/dist/device.mjs +2 -0
- package/dist/index.js +879 -135
- package/dist/index.mjs +14 -0
- package/dist/math/diffDate.js +8 -15
- package/dist/math/diffDate.mjs +10 -0
- package/dist/math/positiveNumber.js +24 -10
- package/dist/math/positiveNumber.mjs +16 -0
- package/dist/math.js +27 -217
- package/dist/math.mjs +2 -0
- package/dist/object.js +33 -36
- package/dist/object.mjs +2 -0
- package/dist/permission/requestCamera.js +14 -37
- package/dist/permission/requestCamera.mjs +2 -0
- package/dist/permission/requestDeviceOrientationControl.js +161 -20
- package/dist/permission/requestDeviceOrientationControl.mjs +3 -0
- package/dist/string/formatNumber.js +27 -18
- package/dist/string/formatNumber.mjs +10 -0
- package/dist/string/generatePassword.js +25 -23
- package/dist/string/generatePassword.mjs +16 -0
- package/dist/string/generateUUID.js +11 -17
- package/dist/string/generateUUID.mjs +14 -0
- package/dist/string/name/en.js +6 -14
- package/dist/string/name/en.mjs +17 -0
- package/dist/string/name/vi.js +29 -22
- package/dist/string/name/vi.mjs +20 -0
- package/dist/string/random.js +16 -30
- package/dist/string/random.mjs +2 -0
- package/dist/string/trimNull.js +14 -14
- package/dist/string/trimNull.mjs +14 -0
- package/dist/string/url.js +45 -74
- package/dist/string/url.mjs +3 -0
- package/dist/string.js +43 -394
- package/dist/string.mjs +3 -0
- package/package.json +23 -28
- package/dist/backend/zip/extractZip.js +0 -59
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// src/device.ts
|
|
2
|
+
var isIos = () => {
|
|
3
|
+
const deviceInfo2 = checkOS();
|
|
4
|
+
if (deviceInfo2)
|
|
5
|
+
return deviceInfo2.os.toLowerCase() == "ios";
|
|
6
|
+
console.log("Can't check OS");
|
|
7
|
+
return null;
|
|
8
|
+
};
|
|
9
|
+
var isAndroid = () => {
|
|
10
|
+
const deviceInfo2 = checkOS();
|
|
11
|
+
if (deviceInfo2)
|
|
12
|
+
return deviceInfo2.os.toLowerCase() == "android";
|
|
13
|
+
console.log("Can't check OS");
|
|
14
|
+
return null;
|
|
15
|
+
};
|
|
16
|
+
var isMobile = () => {
|
|
17
|
+
if (typeof navigator == "undefined")
|
|
18
|
+
return null;
|
|
19
|
+
if (navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/BlackBerry/i) || navigator.userAgent.match(/Windows Phone/i)) {
|
|
20
|
+
return true;
|
|
21
|
+
} else {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
var deviceInfo;
|
|
26
|
+
var checkOS = () => {
|
|
27
|
+
if (typeof window == "undefined")
|
|
28
|
+
return {};
|
|
29
|
+
if (typeof deviceInfo == "undefined") {
|
|
30
|
+
var unknown = "-";
|
|
31
|
+
var screenSize = "";
|
|
32
|
+
if (screen.width) {
|
|
33
|
+
var width = screen.width ? screen.width : "";
|
|
34
|
+
var height = screen.height ? screen.height : "";
|
|
35
|
+
screenSize += "" + width + " x " + height;
|
|
36
|
+
}
|
|
37
|
+
var nVer = navigator.appVersion;
|
|
38
|
+
var nAgt = navigator.userAgent;
|
|
39
|
+
var browser = navigator.appName;
|
|
40
|
+
var version = "" + parseFloat(navigator.appVersion);
|
|
41
|
+
var majorVersion = parseInt(navigator.appVersion, 10);
|
|
42
|
+
var nameOffset, verOffset, ix;
|
|
43
|
+
if ((verOffset = nAgt.indexOf("Opera")) != -1) {
|
|
44
|
+
browser = "Opera";
|
|
45
|
+
version = nAgt.substring(verOffset + 6);
|
|
46
|
+
if ((verOffset = nAgt.indexOf("Version")) != -1) {
|
|
47
|
+
version = nAgt.substring(verOffset + 8);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if ((verOffset = nAgt.indexOf("OPR")) != -1) {
|
|
51
|
+
browser = "Opera";
|
|
52
|
+
version = nAgt.substring(verOffset + 4);
|
|
53
|
+
} else if ((verOffset = nAgt.indexOf("Edge")) != -1) {
|
|
54
|
+
browser = "Microsoft Edge";
|
|
55
|
+
version = nAgt.substring(verOffset + 5);
|
|
56
|
+
} else if ((verOffset = nAgt.indexOf("MSIE")) != -1) {
|
|
57
|
+
browser = "Microsoft Internet Explorer";
|
|
58
|
+
version = nAgt.substring(verOffset + 5);
|
|
59
|
+
} else if ((verOffset = nAgt.indexOf("Chrome")) != -1) {
|
|
60
|
+
browser = "Chrome";
|
|
61
|
+
version = nAgt.substring(verOffset + 7);
|
|
62
|
+
} else if ((verOffset = nAgt.indexOf("Safari")) != -1) {
|
|
63
|
+
browser = "Safari";
|
|
64
|
+
version = nAgt.substring(verOffset + 7);
|
|
65
|
+
if ((verOffset = nAgt.indexOf("Version")) != -1) {
|
|
66
|
+
version = nAgt.substring(verOffset + 8);
|
|
67
|
+
}
|
|
68
|
+
} else if ((verOffset = nAgt.indexOf("Firefox")) != -1) {
|
|
69
|
+
browser = "Firefox";
|
|
70
|
+
version = nAgt.substring(verOffset + 8);
|
|
71
|
+
} else if (nAgt.indexOf("Trident/") != -1) {
|
|
72
|
+
browser = "Microsoft Internet Explorer";
|
|
73
|
+
version = nAgt.substring(nAgt.indexOf("rv:") + 3);
|
|
74
|
+
} else if ((nameOffset = nAgt.lastIndexOf(" ") + 1) < (verOffset = nAgt.lastIndexOf("/"))) {
|
|
75
|
+
browser = nAgt.substring(nameOffset, verOffset);
|
|
76
|
+
version = nAgt.substring(verOffset + 1);
|
|
77
|
+
if (browser.toLowerCase() == browser.toUpperCase()) {
|
|
78
|
+
browser = navigator.appName;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if ((ix = version.indexOf(";")) != -1)
|
|
82
|
+
version = version.substring(0, ix);
|
|
83
|
+
if ((ix = version.indexOf(" ")) != -1)
|
|
84
|
+
version = version.substring(0, ix);
|
|
85
|
+
if ((ix = version.indexOf(")")) != -1)
|
|
86
|
+
version = version.substring(0, ix);
|
|
87
|
+
majorVersion = parseInt("" + version, 10);
|
|
88
|
+
if (isNaN(majorVersion)) {
|
|
89
|
+
version = "" + parseFloat(navigator.appVersion);
|
|
90
|
+
majorVersion = parseInt(navigator.appVersion, 10);
|
|
91
|
+
}
|
|
92
|
+
var mobile = /Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test(nVer);
|
|
93
|
+
var cookieEnabled = navigator.cookieEnabled ? true : false;
|
|
94
|
+
if (typeof navigator.cookieEnabled == "undefined" && !cookieEnabled) {
|
|
95
|
+
document.cookie = "testcookie";
|
|
96
|
+
cookieEnabled = document.cookie.indexOf("testcookie") != -1 ? true : false;
|
|
97
|
+
}
|
|
98
|
+
var os = unknown;
|
|
99
|
+
var clientStrings = [
|
|
100
|
+
{ s: "Windows 10", r: /(Windows 10.0|Windows NT 10.0)/ },
|
|
101
|
+
{ s: "Windows 8.1", r: /(Windows 8.1|Windows NT 6.3)/ },
|
|
102
|
+
{ s: "Windows 8", r: /(Windows 8|Windows NT 6.2)/ },
|
|
103
|
+
{ s: "Windows 7", r: /(Windows 7|Windows NT 6.1)/ },
|
|
104
|
+
{ s: "Windows Vista", r: /Windows NT 6.0/ },
|
|
105
|
+
{ s: "Windows Server 2003", r: /Windows NT 5.2/ },
|
|
106
|
+
{ s: "Windows XP", r: /(Windows NT 5.1|Windows XP)/ },
|
|
107
|
+
{ s: "Windows 2000", r: /(Windows NT 5.0|Windows 2000)/ },
|
|
108
|
+
{ s: "Windows ME", r: /(Win 9x 4.90|Windows ME)/ },
|
|
109
|
+
{ s: "Windows 98", r: /(Windows 98|Win98)/ },
|
|
110
|
+
{ s: "Windows 95", r: /(Windows 95|Win95|Windows_95)/ },
|
|
111
|
+
{ s: "Windows NT 4.0", r: /(Windows NT 4.0|WinNT4.0|WinNT|Windows NT)/ },
|
|
112
|
+
{ s: "Windows CE", r: /Windows CE/ },
|
|
113
|
+
{ s: "Windows 3.11", r: /Win16/ },
|
|
114
|
+
{ s: "Android", r: /Android/ },
|
|
115
|
+
{ s: "Open BSD", r: /OpenBSD/ },
|
|
116
|
+
{ s: "Sun OS", r: /SunOS/ },
|
|
117
|
+
{ s: "Linux", r: /(Linux|X11)/ },
|
|
118
|
+
{ s: "iOS", r: /(iPhone|iPad|iPod)/ },
|
|
119
|
+
{ s: "Mac OS X", r: /Mac OS X/ },
|
|
120
|
+
{ s: "Mac OS", r: /(MacPPC|MacIntel|Mac_PowerPC|Macintosh)/ },
|
|
121
|
+
{ s: "QNX", r: /QNX/ },
|
|
122
|
+
{ s: "UNIX", r: /UNIX/ },
|
|
123
|
+
{ s: "BeOS", r: /BeOS/ },
|
|
124
|
+
{ s: "OS/2", r: /OS\/2/ },
|
|
125
|
+
{ s: "Search Bot", r: /(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\/Teoma|ia_archiver)/ }
|
|
126
|
+
];
|
|
127
|
+
for (var id in clientStrings) {
|
|
128
|
+
var cs = clientStrings[id];
|
|
129
|
+
if (cs.r.test(nAgt)) {
|
|
130
|
+
os = cs.s;
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
var osVersion = unknown;
|
|
135
|
+
if (/Windows/.test(os)) {
|
|
136
|
+
osVersion = /Windows (.*)/.exec(os)[1];
|
|
137
|
+
os = "Windows";
|
|
138
|
+
}
|
|
139
|
+
switch (os) {
|
|
140
|
+
case "Mac OS X":
|
|
141
|
+
osVersion = /Mac OS X (10[\.\_\d]+)/.exec(nAgt)[1];
|
|
142
|
+
break;
|
|
143
|
+
case "Android":
|
|
144
|
+
osVersion = /Android ([\.\_\d]+)/.exec(nAgt)[1];
|
|
145
|
+
break;
|
|
146
|
+
case "iOS":
|
|
147
|
+
const _osVersion = /OS (\d+)_(\d+)_?(\d+)?/.exec(nVer);
|
|
148
|
+
osVersion = _osVersion[1] + "." + _osVersion[2] + "." + (_osVersion[3] || 0);
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
const _deviceInfo = {
|
|
152
|
+
screen: screenSize,
|
|
153
|
+
browser,
|
|
154
|
+
browserVersion: version,
|
|
155
|
+
browserMajorVersion: majorVersion,
|
|
156
|
+
mobile,
|
|
157
|
+
os,
|
|
158
|
+
osVersion,
|
|
159
|
+
cookies: cookieEnabled
|
|
160
|
+
};
|
|
161
|
+
deviceInfo = _deviceInfo;
|
|
162
|
+
}
|
|
163
|
+
return deviceInfo;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
export { checkOS, isAndroid, isIos, isMobile };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// src/math.ts
|
|
2
|
+
var DEG2RAD = Math.PI / 180;
|
|
3
|
+
var RAD2DEG = 180 / Math.PI;
|
|
4
|
+
var randRound = (number) => {
|
|
5
|
+
return Math.round(Math.random() * number);
|
|
6
|
+
};
|
|
7
|
+
var rand = (number) => {
|
|
8
|
+
return (Math.random() - Math.random()) * number;
|
|
9
|
+
};
|
|
10
|
+
var randHalt = (number) => {
|
|
11
|
+
var rand2 = Math.random() - Math.random();
|
|
12
|
+
var res;
|
|
13
|
+
if (rand2 > 0) {
|
|
14
|
+
res = rand2 * (number / 2) + number / 2;
|
|
15
|
+
} else {
|
|
16
|
+
res = rand2 * (number / 2) - number / 2;
|
|
17
|
+
}
|
|
18
|
+
return Math.abs(res);
|
|
19
|
+
};
|
|
20
|
+
var randInt = (low, high) => {
|
|
21
|
+
return low + Math.floor(Math.random() * (high - low + 1));
|
|
22
|
+
};
|
|
23
|
+
var randFloat = (low, high) => {
|
|
24
|
+
return low + Math.random() * (high - low);
|
|
25
|
+
};
|
|
26
|
+
var degToRad = (degrees) => {
|
|
27
|
+
return degrees * DEG2RAD;
|
|
28
|
+
};
|
|
29
|
+
var radToDeg = (radians) => {
|
|
30
|
+
return radians * RAD2DEG;
|
|
31
|
+
};
|
|
32
|
+
var angleBetweenPoints = (cx, cy, ex, ey) => {
|
|
33
|
+
var dy = ey - cy;
|
|
34
|
+
var dx = ex - cx;
|
|
35
|
+
var theta = Math.atan2(dy, dx);
|
|
36
|
+
theta *= 180 / Math.PI;
|
|
37
|
+
return theta;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export { angleBetweenPoints, degToRad, radToDeg, rand, randFloat, randHalt, randInt, randRound };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { isAndroid } from './chunk-UKRVCU5M.mjs';
|
|
2
|
+
|
|
3
|
+
// src/permission/requestDeviceOrientationControl.ts
|
|
4
|
+
var requestDeviceOrientationControl = () => {
|
|
5
|
+
if (typeof window == "undefined")
|
|
6
|
+
return false;
|
|
7
|
+
return new Promise((resolve, reject) => {
|
|
8
|
+
if (isAndroid())
|
|
9
|
+
resolve(true);
|
|
10
|
+
if (typeof DeviceMotionEvent != "undefined" && DeviceMotionEvent.requestPermission) {
|
|
11
|
+
DeviceMotionEvent.requestPermission().then((response) => {
|
|
12
|
+
if (response == "granted") {
|
|
13
|
+
resolve(true);
|
|
14
|
+
} else {
|
|
15
|
+
resolve(false);
|
|
16
|
+
}
|
|
17
|
+
}).catch((response) => {
|
|
18
|
+
resolve(false);
|
|
19
|
+
});
|
|
20
|
+
} else {
|
|
21
|
+
resolve(false);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
var requestDeviceOrientationControl_default = requestDeviceOrientationControl;
|
|
26
|
+
|
|
27
|
+
export { requestDeviceOrientationControl_default };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { isNull } from './chunk-5AL36RZR.mjs';
|
|
2
|
+
|
|
3
|
+
// src/string/url.ts
|
|
4
|
+
var urlRegex = /(https?:\/\/[^\s]+)/g;
|
|
5
|
+
var addQueryParam = (_url, key, value) => {
|
|
6
|
+
_url += (_url.split("?")[1] ? "&" : "?") + `${key}=${value}`;
|
|
7
|
+
return _url;
|
|
8
|
+
};
|
|
9
|
+
var getUrlParams = (parameter, staticURL, decode = true) => {
|
|
10
|
+
if (typeof window == "undefined")
|
|
11
|
+
return "";
|
|
12
|
+
staticURL = staticURL == void 0 ? window.location.host : staticURL;
|
|
13
|
+
var currLocation = staticURL.length > 0 ? staticURL : window.location.search;
|
|
14
|
+
if (currLocation.split("?").length < 2)
|
|
15
|
+
return "";
|
|
16
|
+
var parArr = currLocation.split("?")[1].split("&"), returnBool = true;
|
|
17
|
+
for (var i = 0; i < parArr.length; i++) {
|
|
18
|
+
var parr = parArr[i].split("=");
|
|
19
|
+
if (parr[0] == parameter) {
|
|
20
|
+
return decode ? decodeURIComponent(parr[1]) : parr[1];
|
|
21
|
+
} else {
|
|
22
|
+
returnBool = false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (!returnBool)
|
|
26
|
+
return false;
|
|
27
|
+
};
|
|
28
|
+
var isLink = (str) => {
|
|
29
|
+
return urlRegex.test(str);
|
|
30
|
+
};
|
|
31
|
+
var getFileNameWithoutExtension = (url) => {
|
|
32
|
+
url = decodeURIComponent(url);
|
|
33
|
+
if (url) {
|
|
34
|
+
const m = url.toString().match(/.*\/(.+?)\./);
|
|
35
|
+
if (m && m.length > 1) {
|
|
36
|
+
return m[1];
|
|
37
|
+
}
|
|
38
|
+
if (!isNull(url)) {
|
|
39
|
+
return url.split(".").shift();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return "";
|
|
43
|
+
};
|
|
44
|
+
var getFileNameWithExtension = (url) => {
|
|
45
|
+
url = decodeURIComponent(url);
|
|
46
|
+
if (url) {
|
|
47
|
+
const m = url.toString().match(/.*\/(.*)$/);
|
|
48
|
+
if (m && m.length > 1) {
|
|
49
|
+
return m[1].split("/").pop().split("?")[0];
|
|
50
|
+
}
|
|
51
|
+
if (!isNull(url)) {
|
|
52
|
+
return url;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return "";
|
|
56
|
+
};
|
|
57
|
+
var getFileExtension = (url) => {
|
|
58
|
+
return getFileNameWithExtension(url).split(".").pop();
|
|
59
|
+
};
|
|
60
|
+
var isImage = (url) => {
|
|
61
|
+
const arr = ["png", "jpg", "jpeg", "jpe", "jif", "jfif", "gif", "svg"];
|
|
62
|
+
const index = arr.findIndex((item) => {
|
|
63
|
+
return getFileExtension(url).toLowerCase() == item;
|
|
64
|
+
});
|
|
65
|
+
return index >= 0;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export { addQueryParam, getFileExtension, getFileNameWithExtension, getFileNameWithoutExtension, getUrlParams, isImage, isLink };
|
package/dist/color.js
CHANGED
|
@@ -1,69 +1,49 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
require("core-js/modules/es.regexp.to-string.js");
|
|
8
|
-
require("core-js/modules/es.parse-int.js");
|
|
9
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
10
|
-
require("core-js/modules/es.parse-float.js");
|
|
11
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
12
|
-
const random = function random() {
|
|
13
|
-
let hex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
// src/color.ts
|
|
6
|
+
var random = (hex = false) => {
|
|
14
7
|
return (hex ? "#" : "") + Math.floor(Math.random() * 16777215).toString(16);
|
|
15
8
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const pSBC = (p, c0, c1, l) => {
|
|
23
|
-
let r,
|
|
24
|
-
g,
|
|
25
|
-
b,
|
|
26
|
-
P,
|
|
27
|
-
f,
|
|
28
|
-
t,
|
|
29
|
-
h,
|
|
30
|
-
i = parseInt,
|
|
31
|
-
m = Math.round,
|
|
32
|
-
a = typeof c1 == "string";
|
|
33
|
-
if (typeof p != "number" || p < -1 || p > 1 || typeof c0 != "string" || c0[0] != "r" && c0[0] != "#" || c1 && !a) return null;
|
|
34
|
-
const pSBCr = d => {
|
|
35
|
-
let n = d.length,
|
|
36
|
-
x = {};
|
|
9
|
+
var pSBC = (p, c0, c1, l) => {
|
|
10
|
+
let r, g, b, P, f, t, h, i = parseInt, m = Math.round, a = typeof c1 == "string";
|
|
11
|
+
if (typeof p != "number" || p < -1 || p > 1 || typeof c0 != "string" || c0[0] != "r" && c0[0] != "#" || c1 && !a)
|
|
12
|
+
return null;
|
|
13
|
+
const pSBCr = (d) => {
|
|
14
|
+
let n = d.length, x = { r: 0, g: 0, b: 0, a: 1 };
|
|
37
15
|
if (n > 9) {
|
|
38
16
|
[r, g, b, a] = d = d.split(","), n = d.length;
|
|
39
|
-
if (n < 3 || n > 4)
|
|
40
|
-
|
|
17
|
+
if (n < 3 || n > 4)
|
|
18
|
+
return null;
|
|
19
|
+
x.r = i(r[3] == "a" ? r.slice(5) : r.slice(4)), x.g = i(g), x.b = i(b), x.a = a ? parseFloat(a.toString()) : -1;
|
|
41
20
|
} else {
|
|
42
|
-
if (n == 8 || n == 6 || n < 4)
|
|
43
|
-
|
|
21
|
+
if (n == 8 || n == 6 || n < 4)
|
|
22
|
+
return null;
|
|
23
|
+
if (n < 6)
|
|
24
|
+
d = "#" + d[1] + d[1] + d[2] + d[2] + d[3] + d[3] + (n > 4 ? d[4] + d[4] : "");
|
|
44
25
|
d = i(d.slice(1), 16);
|
|
45
|
-
if (n == 9 || n == 5)
|
|
26
|
+
if (n == 9 || n == 5)
|
|
27
|
+
x.r = d >> 24 & 255, x.g = d >> 16 & 255, x.b = d >> 8 & 255, x.a = m((d & 255) / 0.255) / 1e3;
|
|
28
|
+
else
|
|
29
|
+
x.r = d >> 16, x.g = d >> 8 & 255, x.b = d & 255, x.a = -1;
|
|
46
30
|
}
|
|
47
31
|
return x;
|
|
48
32
|
};
|
|
49
|
-
h = c0.length > 9, h = a ? c1.length > 9 ? true : c1 == "c" ? !h : false : h, f = pSBCr(c0), P = p < 0, t = c1 && c1 != "c" ? pSBCr(c1) : P ? {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
r
|
|
56
|
-
g: 255,
|
|
57
|
-
b: 255,
|
|
58
|
-
a: -1
|
|
59
|
-
}, p = P ? p * -1 : p, P = 1 - p;
|
|
60
|
-
if (!f || !t) return null;
|
|
61
|
-
if (l) r = m(P * f.r + p * t.r), g = m(P * f.g + p * t.g), b = m(P * f.b + p * t.b);else r = m((P * f.r ** 2 + p * t.r ** 2) ** 0.5), g = m((P * f.g ** 2 + p * t.g ** 2) ** 0.5), b = m((P * f.b ** 2 + p * t.b ** 2) ** 0.5);
|
|
33
|
+
h = c0.length > 9, h = a ? c1.length > 9 ? true : c1 == "c" ? !h : false : h, f = pSBCr(c0), P = p < 0, t = c1 && c1 != "c" ? pSBCr(c1) : P ? { r: 0, g: 0, b: 0, a: -1 } : { r: 255, g: 255, b: 255, a: -1 }, p = P ? p * -1 : p, P = 1 - p;
|
|
34
|
+
if (!f || !t)
|
|
35
|
+
return null;
|
|
36
|
+
if (l)
|
|
37
|
+
r = m(P * f.r + p * t.r), g = m(P * f.g + p * t.g), b = m(P * f.b + p * t.b);
|
|
38
|
+
else
|
|
39
|
+
r = m((P * f.r ** 2 + p * t.r ** 2) ** 0.5), g = m((P * f.g ** 2 + p * t.g ** 2) ** 0.5), b = m((P * f.b ** 2 + p * t.b ** 2) ** 0.5);
|
|
62
40
|
a = f.a, t = t.a, f = a >= 0 || t >= 0, a = f ? a < 0 ? t : t < 0 ? a : a * P + t * p : 0;
|
|
63
|
-
if (h)
|
|
41
|
+
if (h)
|
|
42
|
+
return "rgb" + (f ? "a(" : "(") + r + "," + g + "," + b + (f ? "," + m(a * 1e3) / 1e3 : "") + ")";
|
|
43
|
+
else
|
|
44
|
+
return "#" + (4294967296 + r * 16777216 + g * 65536 + b * 256 + (f ? m(a * 255) : 0)).toString(16).slice(1, f ? void 0 : -2);
|
|
64
45
|
};
|
|
65
|
-
|
|
66
|
-
const hexToRgb = hex => {
|
|
46
|
+
var hexToRgb = (hex) => {
|
|
67
47
|
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
68
48
|
return result ? {
|
|
69
49
|
r: parseInt(result[1], 16),
|
|
@@ -71,16 +51,19 @@ const hexToRgb = hex => {
|
|
|
71
51
|
b: parseInt(result[3], 16)
|
|
72
52
|
} : null;
|
|
73
53
|
};
|
|
74
|
-
|
|
75
|
-
const hexDarken = (hex, amount) => {
|
|
54
|
+
var hexDarken = (hex, amount) => {
|
|
76
55
|
return pSBC(-amount, hex);
|
|
77
56
|
};
|
|
78
|
-
|
|
79
|
-
const hexLighten = (hex, amount) => {
|
|
57
|
+
var hexLighten = (hex, amount) => {
|
|
80
58
|
return pSBC(amount, hex);
|
|
81
59
|
};
|
|
82
|
-
|
|
83
|
-
const RGBToHex = rgb => {
|
|
60
|
+
var RGBToHex = (rgb) => {
|
|
84
61
|
return pSBC(0, rgb, "c", true);
|
|
85
62
|
};
|
|
86
|
-
|
|
63
|
+
|
|
64
|
+
exports.RGBToHex = RGBToHex;
|
|
65
|
+
exports.hexDarken = hexDarken;
|
|
66
|
+
exports.hexLighten = hexLighten;
|
|
67
|
+
exports.hexToRgb = hexToRgb;
|
|
68
|
+
exports.pSBC = pSBC;
|
|
69
|
+
exports.random = random;
|
package/dist/color.mjs
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import './chunk-AKU6F3WT.mjs';
|
|
2
|
+
|
|
3
|
+
// src/color.ts
|
|
4
|
+
var random = (hex = false) => {
|
|
5
|
+
return (hex ? "#" : "") + Math.floor(Math.random() * 16777215).toString(16);
|
|
6
|
+
};
|
|
7
|
+
var pSBC = (p, c0, c1, l) => {
|
|
8
|
+
let r, g, b, P, f, t, h, i = parseInt, m = Math.round, a = typeof c1 == "string";
|
|
9
|
+
if (typeof p != "number" || p < -1 || p > 1 || typeof c0 != "string" || c0[0] != "r" && c0[0] != "#" || c1 && !a)
|
|
10
|
+
return null;
|
|
11
|
+
const pSBCr = (d) => {
|
|
12
|
+
let n = d.length, x = { r: 0, g: 0, b: 0, a: 1 };
|
|
13
|
+
if (n > 9) {
|
|
14
|
+
[r, g, b, a] = d = d.split(","), n = d.length;
|
|
15
|
+
if (n < 3 || n > 4)
|
|
16
|
+
return null;
|
|
17
|
+
x.r = i(r[3] == "a" ? r.slice(5) : r.slice(4)), x.g = i(g), x.b = i(b), x.a = a ? parseFloat(a.toString()) : -1;
|
|
18
|
+
} else {
|
|
19
|
+
if (n == 8 || n == 6 || n < 4)
|
|
20
|
+
return null;
|
|
21
|
+
if (n < 6)
|
|
22
|
+
d = "#" + d[1] + d[1] + d[2] + d[2] + d[3] + d[3] + (n > 4 ? d[4] + d[4] : "");
|
|
23
|
+
d = i(d.slice(1), 16);
|
|
24
|
+
if (n == 9 || n == 5)
|
|
25
|
+
x.r = d >> 24 & 255, x.g = d >> 16 & 255, x.b = d >> 8 & 255, x.a = m((d & 255) / 0.255) / 1e3;
|
|
26
|
+
else
|
|
27
|
+
x.r = d >> 16, x.g = d >> 8 & 255, x.b = d & 255, x.a = -1;
|
|
28
|
+
}
|
|
29
|
+
return x;
|
|
30
|
+
};
|
|
31
|
+
h = c0.length > 9, h = a ? c1.length > 9 ? true : c1 == "c" ? !h : false : h, f = pSBCr(c0), P = p < 0, t = c1 && c1 != "c" ? pSBCr(c1) : P ? { r: 0, g: 0, b: 0, a: -1 } : { r: 255, g: 255, b: 255, a: -1 }, p = P ? p * -1 : p, P = 1 - p;
|
|
32
|
+
if (!f || !t)
|
|
33
|
+
return null;
|
|
34
|
+
if (l)
|
|
35
|
+
r = m(P * f.r + p * t.r), g = m(P * f.g + p * t.g), b = m(P * f.b + p * t.b);
|
|
36
|
+
else
|
|
37
|
+
r = m((P * f.r ** 2 + p * t.r ** 2) ** 0.5), g = m((P * f.g ** 2 + p * t.g ** 2) ** 0.5), b = m((P * f.b ** 2 + p * t.b ** 2) ** 0.5);
|
|
38
|
+
a = f.a, t = t.a, f = a >= 0 || t >= 0, a = f ? a < 0 ? t : t < 0 ? a : a * P + t * p : 0;
|
|
39
|
+
if (h)
|
|
40
|
+
return "rgb" + (f ? "a(" : "(") + r + "," + g + "," + b + (f ? "," + m(a * 1e3) / 1e3 : "") + ")";
|
|
41
|
+
else
|
|
42
|
+
return "#" + (4294967296 + r * 16777216 + g * 65536 + b * 256 + (f ? m(a * 255) : 0)).toString(16).slice(1, f ? void 0 : -2);
|
|
43
|
+
};
|
|
44
|
+
var hexToRgb = (hex) => {
|
|
45
|
+
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
46
|
+
return result ? {
|
|
47
|
+
r: parseInt(result[1], 16),
|
|
48
|
+
g: parseInt(result[2], 16),
|
|
49
|
+
b: parseInt(result[3], 16)
|
|
50
|
+
} : null;
|
|
51
|
+
};
|
|
52
|
+
var hexDarken = (hex, amount) => {
|
|
53
|
+
return pSBC(-amount, hex);
|
|
54
|
+
};
|
|
55
|
+
var hexLighten = (hex, amount) => {
|
|
56
|
+
return pSBC(amount, hex);
|
|
57
|
+
};
|
|
58
|
+
var RGBToHex = (rgb) => {
|
|
59
|
+
return pSBC(0, rgb, "c", true);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export { RGBToHex, hexDarken, hexLighten, hexToRgb, pSBC, random };
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var cloneDeep = require('lodash/cloneDeep');
|
|
4
|
+
|
|
5
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
6
|
+
|
|
7
|
+
var cloneDeep__default = /*#__PURE__*/_interopDefaultLegacy(cloneDeep);
|
|
8
|
+
|
|
9
|
+
// src/console/enableConsole.ts
|
|
10
|
+
var _console = cloneDeep__default["default"](console);
|
|
11
|
+
function enableConsole() {
|
|
11
12
|
return _console;
|
|
12
|
-
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
module.exports = enableConsole;
|
package/dist/console/index.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
// src/console/index.ts
|
|
6
|
+
var disableConsole = (params) => {
|
|
7
|
+
for (var key in console) {
|
|
8
|
+
console[key] = function() {
|
|
9
|
+
};
|
|
10
10
|
}
|
|
11
11
|
};
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
var removeConsole = disableConsole;
|
|
13
|
+
var showCredit = (params) => {
|
|
14
14
|
console.log("Developed by Digitop | https://www.wearetopgroup.com/?utm_src=console");
|
|
15
15
|
};
|
|
16
|
-
|
|
16
|
+
|
|
17
|
+
exports.disableConsole = disableConsole;
|
|
18
|
+
exports.removeConsole = removeConsole;
|
|
19
|
+
exports.showCredit = showCredit;
|
package/dist/device/browser.js
CHANGED
|
@@ -1,38 +1,40 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const isPotrait = params => {
|
|
12
|
-
if (typeof window == "undefined") return false;
|
|
13
|
-
if (!window.orientation) return window.matchMedia("(orientation: portrait)").matches;
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
// src/device/browser.ts
|
|
6
|
+
var isPotrait = () => {
|
|
7
|
+
if (typeof window == "undefined")
|
|
8
|
+
return false;
|
|
9
|
+
if (!window.orientation)
|
|
10
|
+
return window.matchMedia("(orientation: portrait)").matches;
|
|
14
11
|
return !(window.orientation === 90 || window.orientation === -90);
|
|
15
12
|
};
|
|
16
|
-
|
|
17
|
-
const isLandscape = params => {
|
|
13
|
+
var isLandscape = () => {
|
|
18
14
|
return !isPotrait();
|
|
19
15
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (typeof window == "undefined")
|
|
16
|
+
var ua = () => {
|
|
17
|
+
if (typeof navigator == "undefined")
|
|
18
|
+
return null;
|
|
19
|
+
if (typeof window == "undefined")
|
|
20
|
+
return null;
|
|
24
21
|
return navigator.userAgent || navigator.vendor || window.opera;
|
|
25
22
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
var isFacebookWebview = () => {
|
|
24
|
+
var ua2 = ua2();
|
|
25
|
+
if (typeof ua2 != "undefined")
|
|
26
|
+
return ua2.indexOf("FBAN") > -1 || ua2.indexOf("FBAV") > -1;
|
|
30
27
|
};
|
|
31
|
-
|
|
32
|
-
const isInAppWebview = params => {
|
|
28
|
+
var isInAppWebview = () => {
|
|
33
29
|
const rules = ["WebView", "(iPhone|iPod|iPad)(?!.*Safari/)", "Android.*(wv|.0.0.0)"];
|
|
34
|
-
const regex = new RegExp(
|
|
35
|
-
if (ua())
|
|
30
|
+
const regex = new RegExp(`(${rules.join("|")})`, "ig");
|
|
31
|
+
if (ua())
|
|
32
|
+
return Boolean(ua().match(regex));
|
|
36
33
|
return false;
|
|
37
34
|
};
|
|
38
|
-
|
|
35
|
+
|
|
36
|
+
exports.isFacebookWebview = isFacebookWebview;
|
|
37
|
+
exports.isInAppWebview = isInAppWebview;
|
|
38
|
+
exports.isLandscape = isLandscape;
|
|
39
|
+
exports.isPotrait = isPotrait;
|
|
40
|
+
exports.ua = ua;
|