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.
Files changed (81) hide show
  1. package/dist/Checker.js +7 -8
  2. package/dist/Checker.mjs +25 -0
  3. package/dist/EventDispatcher.js +20 -19
  4. package/dist/EventDispatcher.mjs +51 -0
  5. package/dist/FileUpload.js +24 -29
  6. package/dist/FileUpload.mjs +60 -0
  7. package/dist/Slug.js +286 -340
  8. package/dist/Slug.mjs +327 -0
  9. package/dist/Timer.js +8 -11
  10. package/dist/Timer.mjs +2 -0
  11. package/dist/Validation.js +11 -19
  12. package/dist/Validation.mjs +33 -0
  13. package/dist/array.js +100 -203
  14. package/dist/array.mjs +3 -0
  15. package/dist/backend/file/createDir.js +13 -13
  16. package/dist/backend/file/createDir.mjs +13 -0
  17. package/dist/backend/file/fileMove.js +14 -14
  18. package/dist/backend/file/fileMove.mjs +29 -0
  19. package/dist/backend/file/findFilesByExt.js +22 -22
  20. package/dist/backend/file/findFilesByExt.mjs +40 -0
  21. package/dist/chunk-5AL36RZR.mjs +47 -0
  22. package/dist/chunk-7IYY7BKN.mjs +136 -0
  23. package/dist/chunk-ACLBWYEO.mjs +85 -0
  24. package/dist/chunk-AHFJBIQJ.mjs +9 -0
  25. package/dist/chunk-AKU6F3WT.mjs +9 -0
  26. package/dist/chunk-FOWYH6LL.mjs +32 -0
  27. package/dist/chunk-FTE6FZSH.mjs +17 -0
  28. package/dist/chunk-JKYSZLBF.mjs +27 -0
  29. package/dist/chunk-LXQIKFED.mjs +13 -0
  30. package/dist/chunk-Q5R25OIS.mjs +185 -0
  31. package/dist/chunk-R2BH5I6O.mjs +9 -0
  32. package/dist/chunk-UKRVCU5M.mjs +166 -0
  33. package/dist/chunk-VFKAZAWF.mjs +40 -0
  34. package/dist/chunk-VZGV2BTL.mjs +27 -0
  35. package/dist/chunk-Y4ZTQWPA.mjs +68 -0
  36. package/dist/color.js +44 -61
  37. package/dist/color.mjs +62 -0
  38. package/dist/console/enableConsole.js +14 -11
  39. package/dist/console/enableConsole.mjs +2 -0
  40. package/dist/console/index.js +14 -11
  41. package/dist/console/index.mjs +2 -0
  42. package/dist/device/browser.js +29 -27
  43. package/dist/device/browser.mjs +2 -0
  44. package/dist/device/camera.js +65 -125
  45. package/dist/device/camera.mjs +3 -0
  46. package/dist/device.js +76 -181
  47. package/dist/device.mjs +2 -0
  48. package/dist/index.js +879 -135
  49. package/dist/index.mjs +14 -0
  50. package/dist/math/diffDate.js +8 -15
  51. package/dist/math/diffDate.mjs +10 -0
  52. package/dist/math/positiveNumber.js +24 -10
  53. package/dist/math/positiveNumber.mjs +16 -0
  54. package/dist/math.js +27 -217
  55. package/dist/math.mjs +2 -0
  56. package/dist/object.js +33 -36
  57. package/dist/object.mjs +2 -0
  58. package/dist/permission/requestCamera.js +14 -37
  59. package/dist/permission/requestCamera.mjs +2 -0
  60. package/dist/permission/requestDeviceOrientationControl.js +161 -20
  61. package/dist/permission/requestDeviceOrientationControl.mjs +3 -0
  62. package/dist/string/formatNumber.js +27 -18
  63. package/dist/string/formatNumber.mjs +10 -0
  64. package/dist/string/generatePassword.js +25 -23
  65. package/dist/string/generatePassword.mjs +16 -0
  66. package/dist/string/generateUUID.js +11 -17
  67. package/dist/string/generateUUID.mjs +14 -0
  68. package/dist/string/name/en.js +6 -14
  69. package/dist/string/name/en.mjs +17 -0
  70. package/dist/string/name/vi.js +29 -22
  71. package/dist/string/name/vi.mjs +20 -0
  72. package/dist/string/random.js +16 -30
  73. package/dist/string/random.mjs +2 -0
  74. package/dist/string/trimNull.js +14 -14
  75. package/dist/string/trimNull.mjs +14 -0
  76. package/dist/string/url.js +45 -74
  77. package/dist/string/url.mjs +3 -0
  78. package/dist/string.js +43 -394
  79. package/dist/string.mjs +3 -0
  80. package/package.json +23 -28
  81. package/dist/backend/zip/extractZip.js +0 -59
@@ -0,0 +1,136 @@
1
+ import { requestCamera_default } from './chunk-JKYSZLBF.mjs';
2
+
3
+ // src/device/camera.ts
4
+ function getWebcam({
5
+ container,
6
+ facingMode = "environment",
7
+ audio = false
8
+ }) {
9
+ if (typeof window == "undefined")
10
+ return;
11
+ container = container || document.body;
12
+ return new Promise(async (resolve, reject) => {
13
+ const video = document.createElement("video");
14
+ video.style.position = "absolute";
15
+ video.style.top = "0";
16
+ video.style.left = "0";
17
+ video.style.width = "100%";
18
+ video.style.height = "100%";
19
+ container.append(video);
20
+ let inputCameras = [];
21
+ let currentCamera;
22
+ const requestedMediaConstraints = {
23
+ video: {
24
+ facingMode: { exact: facingMode }
25
+ },
26
+ audio
27
+ };
28
+ console.log("[Camera.js] Requesting:", requestedMediaConstraints);
29
+ const res = await requestCamera_default({ audio });
30
+ if (!res) {
31
+ setTimeout(function() {
32
+ handleError({ name: "Error", message: "NotSupported" });
33
+ }, 50);
34
+ }
35
+ navigator.mediaDevices.enumerateDevices().then(parseDevices).catch(handleError);
36
+ function parseDevices(devices) {
37
+ inputCameras = [];
38
+ let backCameras = [];
39
+ devices.forEach(function(device) {
40
+ if (device.kind == "videoinput" && typeof device.deviceId != "undefined" && device.deviceId != "") {
41
+ inputCameras.push(device);
42
+ }
43
+ });
44
+ console.log("[Camera.js] inputCameras:", inputCameras);
45
+ if (inputCameras.length > 0) {
46
+ let cams = "";
47
+ let backCamera;
48
+ inputCameras.map((cam, index) => {
49
+ cams += `[${cam.deviceId}] ${cam.kind} | ${cam.label}
50
+ `;
51
+ let label = cam.label.toLowerCase();
52
+ if (label.indexOf("back") > -1 || label.indexOf("facetime") > -1) {
53
+ backCamera = cam;
54
+ backCameras.push(backCamera);
55
+ }
56
+ });
57
+ if (backCameras.length > 1) {
58
+ backCamera = backCameras[backCameras.length - 1];
59
+ }
60
+ console.log(`[Camera.js] All input sources:`, cams);
61
+ console.log(`[Camera.js] This device has ${backCameras.length} back camera${backCameras.length > 1 ? "s" : ""}.`);
62
+ console.log("[Camera.js] backCameras:", JSON.stringify(backCameras));
63
+ currentCamera = backCamera;
64
+ getStreamOfCameraId(backCamera.deviceId).then(onStreamReceived).catch((e) => {
65
+ if (backCameras.length > 1) {
66
+ backCamera = backCameras[backCameras.length - 2];
67
+ getStreamOfCameraId(backCamera.deviceId).then(onStreamReceived).catch(handleError);
68
+ } else if (backCameras.length > 2) {
69
+ backCamera = backCameras[backCameras.length - 3];
70
+ getStreamOfCameraId(backCamera.deviceId).then(onStreamReceived).catch(handleError);
71
+ } else {
72
+ handleError(e);
73
+ }
74
+ });
75
+ } else {
76
+ navigator.mediaDevices.getUserMedia(requestedMediaConstraints).then(onStreamReceived).catch(handleError);
77
+ }
78
+ }
79
+ function onStreamReceived(stream2) {
80
+ if (inputCameras.length == 0) {
81
+ console.log("[Camera.js] Not found any back cameras, request again?");
82
+ navigator.mediaDevices.enumerateDevices().then(parseDevices).catch(handleError);
83
+ return;
84
+ }
85
+ playWebcamVideo(stream2);
86
+ }
87
+ function playWebcamVideo(_stream) {
88
+ if ("srcObject" in video) {
89
+ video.srcObject = _stream;
90
+ } else {
91
+ video.src = window.URL.createObjectURL(_stream);
92
+ }
93
+ video.setAttribute("playsinline", "true");
94
+ video.setAttribute("muted", "true");
95
+ video.setAttribute("autoplay", "true");
96
+ video.muted = true;
97
+ video.autoplay = true;
98
+ video.style.objectFit = "cover";
99
+ video.play();
100
+ video.addEventListener("canplay", function(e) {
101
+ });
102
+ video.addEventListener("canplaythrough", function(e) {
103
+ });
104
+ video.addEventListener("error", (e) => console.log("[Camera.js] <video> error:", e));
105
+ video.addEventListener("stalled", function(e) {
106
+ console.log("[Camera.js] <video> stalled:", e);
107
+ reject();
108
+ });
109
+ video.addEventListener("loadedmetadata", function(e) {
110
+ if (currentCamera.label.toLowerCase().indexOf("facetime") > -1) {
111
+ video.style.transform = "scaleX(-1)";
112
+ video.style.webkitTransform = "scaleX(-1)";
113
+ }
114
+ video.play();
115
+ resolve(video);
116
+ });
117
+ }
118
+ function getStreamOfCameraId(id) {
119
+ const constraints = {
120
+ video: { deviceId: { exact: id } },
121
+ audio: false
122
+ };
123
+ return new Promise((resolve2, reject2) => {
124
+ navigator.mediaDevices.getUserMedia(constraints).then(resolve2).catch(reject2);
125
+ });
126
+ }
127
+ function handleError(err) {
128
+ console.error(err);
129
+ const errMsg = "[Camera.js] " + err.name + ": " + err.message;
130
+ console.error(errMsg);
131
+ reject();
132
+ }
133
+ });
134
+ }
135
+
136
+ export { getWebcam };
@@ -0,0 +1,85 @@
1
+ import { isNull } from './chunk-5AL36RZR.mjs';
2
+
3
+ // src/string.ts
4
+ var char_map = { \u00C0: "A", \u00C1: "A", \u00C2: "A", \u00C3: "A", \u00C4: "A", \u00C5: "A", \u00C6: "AE", \u00C7: "C", \u00C8: "E", \u00C9: "E", \u00CA: "E", \u00CB: "E", \u00CC: "I", \u00CD: "I", \u00CE: "I", \u00CF: "I", \u00D0: "D", \u00D1: "N", \u00D2: "O", \u00D3: "O", \u00D4: "O", \u00D5: "O", \u00D6: "O", \u0150: "O", \u00D8: "O", \u00D9: "U", \u00DA: "U", \u00DB: "U", \u0170: "U", \u00DD: "Y", \u00DE: "TH", \u00DF: "ss", \u00E0: "a", \u00E1: "a", \u00E2: "a", \u00E3: "a", \u00E4: "a", \u00E5: "a", \u00E6: "ae", \u00E8: "e", \u00E9: "e", \u00EA: "e", \u00EB: "e", \u00EC: "i", \u00ED: "i", \u00EE: "i", \u00EF: "i", \u00F0: "d", \u00F1: "n", \u00F2: "o", \u00F3: "o", \u00F4: "o", \u00F5: "o", \u00F6: "o", \u0151: "o", \u00F8: "o", \u00F9: "u", \u00FA: "u", \u00FB: "u", \u0171: "u", \u00FD: "y", \u00FE: "th", \u00FF: "y", "\xA9": "(c)", \u0393: "G", \u0394: "D", \u0398: "8", \u039B: "L", \u039E: "3", \u03A0: "P", \u03A3: "S", \u03A6: "F", \u03A8: "PS", \u03A9: "W", \u0386: "A", \u0388: "E", \u038A: "I", \u038C: "O", \u038E: "Y", \u0389: "H", \u038F: "W", \u03AA: "I", \u03AB: "Y", \u03B2: "b", "\u03B3": "y", \u03B4: "d", \u03B5: "e", \u03B6: "z", \u03B7: "h", \u03B8: "8", \u03B9: "i", \u03BA: "k", \u03BB: "l", \u03BC: "m", \u03BD: "n", \u03BE: "3", \u03BF: "o", \u03C0: "p", \u03C1: "r", \u03C3: "s", \u03C4: "t", \u03C5: "y", \u03C6: "f", \u03C7: "x", \u03C8: "ps", \u03C9: "w", \u03AC: "a", \u03AD: "e", \u03AF: "i", \u03CC: "o", \u03CD: "y", \u03AE: "h", \u03CE: "w", \u03C2: "s", \u03CA: "i", \u03B0: "y", \u03CB: "y", \u0390: "i", \u015E: "S", \u0130: "I", \u00DC: "U", \u011E: "G", \u015F: "s", \u0131: "i", \u00E7: "c", \u00FC: "u", \u011F: "g", \u0410: "A", \u0411: "B", \u0412: "V", \u0413: "G", \u0414: "D", \u0415: "E", \u0401: "Yo", \u0416: "Zh", \u0417: "Z", \u0418: "I", \u0419: "J", \u041A: "K", \u041B: "L", \u041C: "M", \u041D: "N", \u041E: "O", \u041F: "P", \u0420: "R", \u0421: "S", \u0422: "T", \u0423: "U", \u0424: "F", \u0425: "H", \u0426: "C", \u0427: "Ch", \u0428: "Sh", \u0429: "Sh", \u042A: "", \u042B: "Y", \u042C: "", \u042D: "E", \u042E: "Yu", \u042F: "Ya", \u0430: "a", \u0431: "b", \u0432: "v", \u0433: "g", \u0434: "d", \u0435: "e", \u0451: "yo", \u0436: "zh", \u0437: "z", \u0438: "i", \u0439: "j", \u043A: "k", \u043B: "l", \u043C: "m", \u043D: "n", \u043E: "o", \u043F: "p", \u0440: "r", \u0441: "s", \u0442: "t", \u0443: "u", \u0444: "f", \u0445: "h", \u0446: "c", \u0447: "ch", \u0448: "sh", \u0449: "sh", \u044A: "", \u044B: "y", \u044C: "", \u044D: "e", \u044E: "yu", \u044F: "ya", \u0404: "Ye", \u0406: "I", \u0407: "Yi", \u0490: "G", \u0454: "ye", \u0456: "i", \u0457: "yi", \u0491: "g", \u010C: "C", \u010E: "D", \u011A: "E", \u0147: "N", \u0158: "R", \u0160: "S", \u0164: "T", \u016E: "U", \u017D: "Z", \u010D: "c", \u010F: "d", \u011B: "e", \u0148: "n", \u0159: "r", \u0161: "s", \u0165: "t", \u016F: "u", \u017E: "z", \u0104: "A", \u0106: "C", \u0118: "e", \u0141: "L", \u0143: "N", \u015A: "S", \u0179: "Z", \u017B: "Z", \u0105: "a", \u0107: "c", \u0119: "e", \u0142: "l", \u0144: "n", \u015B: "s", \u017A: "z", \u017C: "z", \u0100: "A", \u0112: "E", \u0122: "G", \u012A: "i", \u0136: "k", \u013B: "L", \u0145: "N", \u016A: "u", \u0101: "a", \u0113: "e", \u0123: "g", \u012B: "i", \u0137: "k", \u013C: "l", \u0146: "n", \u016B: "u" };
5
+ var getBetween = (text, str1, str2 = "") => {
6
+ if (!text)
7
+ return "";
8
+ if (text.indexOf(str1) <= -1)
9
+ return "";
10
+ const firstIndex = text.indexOf(str1) + str1.length;
11
+ const secondIndex = str2 ? text.indexOf(str2, firstIndex) : text.length;
12
+ return text.substring(firstIndex, secondIndex);
13
+ };
14
+ var makeString = (object = "") => {
15
+ if (isNull(object))
16
+ return "";
17
+ return "" + object;
18
+ };
19
+ var toUpperCase = (str = "") => {
20
+ return makeString(str).toUpperCase();
21
+ };
22
+ var toLowerCase = (str = "") => {
23
+ return makeString(str).toLowerCase();
24
+ };
25
+ var titleize = (str = "") => {
26
+ const regString = new RegExp(/(?:^|\s|-)\S/g);
27
+ return toLowerCase(str).replace(regString, function(c) {
28
+ return c.toUpperCase();
29
+ });
30
+ };
31
+ var capitalize = (str, lowercaseRest = 1) => {
32
+ str = makeString(str);
33
+ const remainingChars = !lowercaseRest ? str.slice(1) : str.slice(1).toLowerCase();
34
+ return str.charAt(0).toUpperCase() + remainingChars;
35
+ };
36
+ var capitalizeName = (str) => {
37
+ str = makeString(str);
38
+ str = str.trim();
39
+ str = str.replace(/^\s+|\s+$/gm, "");
40
+ str = str.toLowerCase();
41
+ const arr = str.split(" ");
42
+ str = arr.map((item) => {
43
+ return capitalize(item);
44
+ }).filter((x) => x).join(" ");
45
+ return str;
46
+ };
47
+ var clearUnicodeCharacters = (s, opt = {}) => {
48
+ s = makeString(s);
49
+ var defaults = {
50
+ delimiter: " ",
51
+ lowercase: true,
52
+ replacements: {},
53
+ transliterate: typeof XRegExp === "undefined" ? true : false
54
+ };
55
+ for (var k in defaults) {
56
+ if (!opt.hasOwnProperty(k)) {
57
+ opt[k] = defaults[k];
58
+ }
59
+ }
60
+ s = s.replace(/á|à|ả|ạ|ã|ă|ắ|ằ|ẳ|ẵ|ặ|â|ấ|ầ|ẩ|ẫ|ậ/gi, "a");
61
+ s = s.replace(/é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ/gi, "e");
62
+ s = s.replace(/i|í|ì|ỉ|ĩ|ị/gi, "i");
63
+ s = s.replace(/ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ/gi, "o");
64
+ s = s.replace(/ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự/gi, "u");
65
+ s = s.replace(/ý|ỳ|ỷ|ỹ|ỵ/gi, "y");
66
+ s = s.replace(/đ/gi, "d");
67
+ s = "@" + s + "@";
68
+ s = s.replace(/\@\-|\-\@|\@/gi, "");
69
+ for (var k in opt.replacements) {
70
+ s = s.replace(RegExp(k, "g"), opt.replacements[k]);
71
+ }
72
+ if (opt.transliterate) {
73
+ for (var k in char_map) {
74
+ s = s.replace(RegExp(k, "g"), char_map[k]);
75
+ }
76
+ }
77
+ var alnum = typeof XRegExp === "undefined" ? RegExp("[^a-z0-9]+", "ig") : XRegExp("[^\\p{L}\\p{N}]+", "ig");
78
+ s = s.replace(alnum, opt.delimiter);
79
+ s = s.replace(RegExp("[" + opt.delimiter + "]{2,}", "g"), opt.delimiter);
80
+ s = s.substring(0, opt.limit);
81
+ s = s.replace(RegExp("(^" + opt.delimiter + "|" + opt.delimiter + "$)", "g"), "");
82
+ return opt.lowercase ? s.toLowerCase() : s;
83
+ };
84
+
85
+ export { capitalize, capitalizeName, clearUnicodeCharacters, getBetween, makeString, titleize, toLowerCase, toUpperCase };
@@ -0,0 +1,9 @@
1
+ import cloneDeep from 'lodash/cloneDeep';
2
+
3
+ // src/console/enableConsole.ts
4
+ var _console = cloneDeep(console);
5
+ function enableConsole() {
6
+ return _console;
7
+ }
8
+
9
+ export { enableConsole };
@@ -0,0 +1,9 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined")
5
+ return require.apply(this, arguments);
6
+ throw new Error('Dynamic require of "' + x + '" is not supported');
7
+ });
8
+
9
+ export { __require };
@@ -0,0 +1,32 @@
1
+ // src/device/browser.ts
2
+ var isPotrait = () => {
3
+ if (typeof window == "undefined")
4
+ return false;
5
+ if (!window.orientation)
6
+ return window.matchMedia("(orientation: portrait)").matches;
7
+ return !(window.orientation === 90 || window.orientation === -90);
8
+ };
9
+ var isLandscape = () => {
10
+ return !isPotrait();
11
+ };
12
+ var ua = () => {
13
+ if (typeof navigator == "undefined")
14
+ return null;
15
+ if (typeof window == "undefined")
16
+ return null;
17
+ return navigator.userAgent || navigator.vendor || window.opera;
18
+ };
19
+ var isFacebookWebview = () => {
20
+ var ua2 = ua2();
21
+ if (typeof ua2 != "undefined")
22
+ return ua2.indexOf("FBAN") > -1 || ua2.indexOf("FBAV") > -1;
23
+ };
24
+ var isInAppWebview = () => {
25
+ const rules = ["WebView", "(iPhone|iPod|iPad)(?!.*Safari/)", "Android.*(wv|.0.0.0)"];
26
+ const regex = new RegExp(`(${rules.join("|")})`, "ig");
27
+ if (ua())
28
+ return Boolean(ua().match(regex));
29
+ return false;
30
+ };
31
+
32
+ export { isFacebookWebview, isInAppWebview, isLandscape, isPotrait, ua };
@@ -0,0 +1,17 @@
1
+ // src/string/random.ts
2
+ var textLowCase = "abcdefghijklmnopqrstuvwxyz";
3
+ var numeric = "0123456789";
4
+ var punctuation = "!@#$%^&*()_+~|}{[];?><,./-=";
5
+ var allCharacter = `\u0111\u0110a\xE1\xE0\u1EA3\xE3\u1EA1\u0103\u1EAF\u1EB1\u1EB3\u1EB5\u1EB7\xE2\u1EA5\u1EA7\u1EA9\u1EAB\u1EADe\xE9\xE8\u1EBB\u1EBD\u1EB9\xEA\u1EBF\u1EC1\u1EC3\u1EC5\u1EC7o\xF3\xF2\u1ECF\xF5\u1ECD\xF4\u1ED1\u1ED3\u1ED5\u1ED7\u1ED9\u01A1\u1EDB\u1EDD\u1EDF\u1EE1\u1EE3i\xED\xEC\u1EC9\u0129\u1ECBu\xFA\xF9\u1EE7\u0169\u1EE5\u01B0\u1EE9\u1EEB\u1EED\u1EEF\u1EF1y\xFD\u1EF3\u1EF7\u1EF9\u1EF5A\xC1\xC0\u1EA2\xC3\u1EA0\u0102\u1EAE\u1EB0\u1EB2\u1EB4\u1EB6\xC2\u1EA4\u1EA6\u1EA8\u1EAA\u1EACE\xC9\xC8\u1EBA\u1EBC\u1EB8\xCA\u1EBE\u1EC0\u1EC2\u1EC4\u1EC6O\xD3\xD2\u1ECE\xD5\u1ECC\xD4\u1ED0\u1ED2\u1ED4\u1ED6\u1ED8\u01A0\u1EDA\u1EDC\u1EDE\u1EE0\u1EE2I\xCD\xCC\u1EC8\u0128\u1ECAU\xDA\xD9\u1EE6\u0168\u1EE4\u01AF\u1EE8\u1EEA\u1EEC\u1EEE\u1EF0Y\xDD\u1EF2 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_\`abcdefghijklmnopqrstuvwxyz{|}`;
6
+ var randAllCharacterByLength = (length = 0) => {
7
+ return randomStringByLength(length, allCharacter);
8
+ };
9
+ var randomStringByLength = (length, str = textLowCase) => {
10
+ let result = "";
11
+ for (let i = 0; i < length; i++) {
12
+ result += str.charAt(Math.floor(Math.random() * str.length));
13
+ }
14
+ return result;
15
+ };
16
+
17
+ export { allCharacter, numeric, punctuation, randAllCharacterByLength, randomStringByLength, textLowCase };
@@ -0,0 +1,27 @@
1
+ // src/permission/requestCamera.ts
2
+ var requestCamera = ({ audio = true, video = true }) => {
3
+ if (typeof window == "undefined")
4
+ return false;
5
+ return new Promise((resolve, reject) => {
6
+ if (navigator.mediaDevices.getUserMedia === void 0) {
7
+ navigator.mediaDevices.getUserMedia = function(constraints) {
8
+ var getUserMedia = navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
9
+ if (!getUserMedia) {
10
+ return Promise.reject(new Error("getUserMedia is not implemented in this browser"));
11
+ }
12
+ return new Promise(function(resolve2, reject2) {
13
+ getUserMedia.call(navigator, constraints, resolve2, reject2);
14
+ });
15
+ };
16
+ }
17
+ navigator.mediaDevices.getUserMedia({ audio, video }).then(function(stream) {
18
+ resolve(true);
19
+ }).catch(function(err) {
20
+ console.log(err.name + ": " + err.message);
21
+ resolve(false);
22
+ });
23
+ });
24
+ };
25
+ var requestCamera_default = requestCamera;
26
+
27
+ export { requestCamera_default };
@@ -0,0 +1,13 @@
1
+ // src/console/index.ts
2
+ var disableConsole = (params) => {
3
+ for (var key in console) {
4
+ console[key] = function() {
5
+ };
6
+ }
7
+ };
8
+ var removeConsole = disableConsole;
9
+ var showCredit = (params) => {
10
+ console.log("Developed by Digitop | https://www.wearetopgroup.com/?utm_src=console");
11
+ };
12
+
13
+ export { disableConsole, removeConsole, showCredit };
@@ -0,0 +1,185 @@
1
+ import { randInt } from './chunk-VFKAZAWF.mjs';
2
+
3
+ // src/array.ts
4
+ var sumArray = (array, key) => {
5
+ if (!array) {
6
+ console.warn("ARRAY NOT EXITED !");
7
+ return 0;
8
+ }
9
+ if (key)
10
+ return array.reduce((c, v) => c + v[key], 0);
11
+ else
12
+ return array.reduce((c, v) => c + v, 0);
13
+ };
14
+ var averageArray = (array, key) => {
15
+ if (!array) {
16
+ console.warn("ARRAY NOT EXITED !");
17
+ return 0;
18
+ }
19
+ return sumArray(array, key) / array.length || 0;
20
+ };
21
+ var minArray = (array, key) => {
22
+ if (!array) {
23
+ console.warn("ARRAY NOT EXITED !");
24
+ return 0;
25
+ }
26
+ if (array.length > 0) {
27
+ if (key)
28
+ return array.reduce((c, v) => c < v[key] ? c : v[key]);
29
+ else
30
+ return array.reduce((c, v) => c < v ? c : v);
31
+ }
32
+ return 0;
33
+ };
34
+ var maxArray = (array, key) => {
35
+ if (!array) {
36
+ console.warn("ARRAY NOT EXITED !");
37
+ return 0;
38
+ }
39
+ if (array.length > 0) {
40
+ if (key)
41
+ return array.reduce((c, v) => c > v[key] ? c : v[key]);
42
+ else
43
+ return array.reduce((c, v) => c > v ? c : v);
44
+ }
45
+ return 0;
46
+ };
47
+ var sortElementByString = (array, key) => {
48
+ if (!Array.isArray(array))
49
+ return [];
50
+ if (key)
51
+ return array.sort((x, y) => {
52
+ var a = x[key].toUpperCase(), b = y[key].toUpperCase();
53
+ return a == b ? 0 : a > b ? 1 : -1;
54
+ });
55
+ console.log("NO KEY");
56
+ };
57
+ var sortElementByNumber = (array, key) => {
58
+ if (!Array.isArray(array))
59
+ return [];
60
+ if (key)
61
+ return array.sort((a, b) => {
62
+ return a[key] - b[key];
63
+ });
64
+ console.log("NO KEY");
65
+ };
66
+ var firstElement = (array) => {
67
+ if (array) {
68
+ if (array.length || array.length > 0)
69
+ return array[0];
70
+ }
71
+ return null;
72
+ };
73
+ var lastElement = (array) => {
74
+ if (array) {
75
+ if (array.length || array.length > 0)
76
+ return array[array.length - 1];
77
+ }
78
+ return null;
79
+ };
80
+ var randomIndex = (array) => {
81
+ if (array)
82
+ return randInt(0, array.length - 1);
83
+ return -1;
84
+ };
85
+ var randomElement = (array) => {
86
+ if (array)
87
+ return array[randomIndex(array)];
88
+ return null;
89
+ };
90
+ var mergeAndMakeUniqueElement = (list1, list2, key) => {
91
+ if (!list1 || !list2)
92
+ return;
93
+ if (key) {
94
+ return list1.concat(list2).filter((item, index, self) => {
95
+ return self.findIndex((x) => x[key] == item[key]) === index;
96
+ });
97
+ } else {
98
+ return list1.concat(list2).filter((x, index, self) => {
99
+ return self.indexOf(x) === index;
100
+ });
101
+ }
102
+ };
103
+ var allMatchInArray = (target, toMatch) => {
104
+ if (!target || !toMatch)
105
+ return false;
106
+ const found = toMatch.every((item) => {
107
+ return target.includes(item);
108
+ });
109
+ return found;
110
+ };
111
+ var removeItem = (item, array) => {
112
+ const index = array.indexOf(item);
113
+ if (index == -1) {
114
+ console.warn("[ArrayExtra.removeItem] Item not found.");
115
+ return array;
116
+ }
117
+ array.splice(index, 1);
118
+ return array;
119
+ };
120
+ var removeItemByKey = (key, value, array) => {
121
+ const foundIndex = array.findIndex((item) => {
122
+ return item[key] == value;
123
+ });
124
+ if (foundIndex < 0) {
125
+ console.warn("[ArrayExtra.removeItemByKey] Item not found.", key, value);
126
+ return array;
127
+ }
128
+ array.splice(foundIndex, 1);
129
+ return array;
130
+ };
131
+ var getRandom = (array, n) => {
132
+ var result = new Array(n), len = array.length, taken = new Array(len);
133
+ if (n > len)
134
+ throw new RangeError("getRandom: more elements taken than available");
135
+ while (n--) {
136
+ var x = Math.floor(Math.random() * len);
137
+ result[n] = array[x in taken ? taken[x] : x];
138
+ taken[x] = --len in taken ? taken[len] : len;
139
+ }
140
+ return result;
141
+ };
142
+ var getHalfRandom = (array, n) => {
143
+ var n = Math.ceil(array.length / 2);
144
+ return getRandom(array, n);
145
+ };
146
+ var shuffle = (array) => {
147
+ var i = array.length, j, temp;
148
+ if (array.length < 1)
149
+ return array;
150
+ while (--i) {
151
+ j = Math.floor(Math.random() * (i + 1));
152
+ temp = array[i];
153
+ array[i] = array[j];
154
+ array[j] = temp;
155
+ }
156
+ return array;
157
+ };
158
+ var moveIndex = (array, oldIndex, newIndex) => {
159
+ if (newIndex >= array.length) {
160
+ var k = newIndex - array.length + 1;
161
+ while (k--) {
162
+ array.push(void 0);
163
+ }
164
+ }
165
+ array.splice(newIndex, 0, array.splice(oldIndex, 1)[0]);
166
+ return array;
167
+ };
168
+ var moveArray = (array, oldIndex, newIndex) => {
169
+ while (oldIndex < 0) {
170
+ oldIndex += array.length;
171
+ }
172
+ while (newIndex < 0) {
173
+ newIndex += array.length;
174
+ }
175
+ if (newIndex >= array.length) {
176
+ var k = newIndex - array.length;
177
+ while (k-- + 1) {
178
+ array.push(999);
179
+ }
180
+ }
181
+ array.splice(newIndex, 0, array.splice(oldIndex, 1)[0]);
182
+ return array;
183
+ };
184
+
185
+ export { allMatchInArray, averageArray, firstElement, getHalfRandom, getRandom, lastElement, maxArray, mergeAndMakeUniqueElement, minArray, moveArray, moveIndex, randomElement, randomIndex, removeItem, removeItemByKey, shuffle, sortElementByNumber, sortElementByString, sumArray };
@@ -0,0 +1,9 @@
1
+ // src/Timer.ts
2
+ var Timer = {
3
+ wait: async (ms) => {
4
+ return new Promise((resolve) => setTimeout(resolve, ms));
5
+ }
6
+ };
7
+ var Timer_default = Timer;
8
+
9
+ export { Timer_default };