diginext-utils 2.0.0 → 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 +27 -0
- package/dist/Checker.mjs +25 -0
- package/dist/EventDispatcher.js +51 -0
- package/dist/EventDispatcher.mjs +51 -0
- package/dist/FileUpload.js +60 -0
- package/dist/FileUpload.mjs +60 -0
- package/dist/Slug.js +329 -0
- package/dist/Slug.mjs +327 -0
- package/dist/Timer.js +11 -0
- package/dist/Timer.mjs +2 -0
- package/dist/Validation.js +33 -0
- package/dist/Validation.mjs +33 -0
- package/dist/array.js +210 -0
- package/dist/array.mjs +3 -0
- package/dist/backend/file/createDir.js +21 -0
- package/dist/backend/file/createDir.mjs +13 -0
- package/dist/backend/file/fileMove.js +37 -0
- package/dist/backend/file/fileMove.mjs +29 -0
- package/dist/backend/file/findFilesByExt.js +48 -0
- 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 +69 -0
- package/dist/color.mjs +62 -0
- package/dist/console/enableConsole.js +15 -0
- package/dist/console/enableConsole.mjs +2 -0
- package/dist/console/index.js +19 -0
- package/dist/console/index.mjs +2 -0
- package/dist/device/browser.js +40 -0
- package/dist/device/browser.mjs +2 -0
- package/dist/device/camera.js +164 -0
- package/dist/device/camera.mjs +3 -0
- package/dist/device.js +173 -0
- package/dist/device.mjs +2 -0
- package/dist/index.mjs +14 -820
- package/dist/math/diffDate.js +10 -0
- package/dist/math/diffDate.mjs +10 -0
- package/dist/math/positiveNumber.js +28 -0
- package/dist/math/positiveNumber.mjs +16 -0
- package/dist/math.js +51 -0
- package/dist/math.mjs +2 -0
- package/dist/object.js +56 -0
- package/dist/object.mjs +2 -0
- package/dist/permission/requestCamera.js +29 -0
- package/dist/permission/requestCamera.mjs +2 -0
- package/dist/permission/requestDeviceOrientationControl.js +176 -0
- package/dist/permission/requestDeviceOrientationControl.mjs +3 -0
- package/dist/string/formatNumber.js +28 -0
- package/dist/string/formatNumber.mjs +10 -0
- package/dist/string/generatePassword.js +27 -0
- package/dist/string/generatePassword.mjs +16 -0
- package/dist/string/generateUUID.js +14 -0
- package/dist/string/generateUUID.mjs +14 -0
- package/dist/string/name/en.js +19 -0
- package/dist/string/name/en.mjs +17 -0
- package/dist/string/name/vi.js +37 -0
- package/dist/string/name/vi.mjs +20 -0
- package/dist/string/random.js +26 -0
- package/dist/string/random.mjs +2 -0
- package/dist/string/trimNull.js +20 -0
- package/dist/string/trimNull.mjs +14 -0
- package/dist/string/url.js +89 -0
- package/dist/string/url.mjs +3 -0
- package/dist/string.js +107 -0
- package/dist/string.mjs +3 -0
- package/package.json +2 -2
- package/dist/index.d.ts +0 -280
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { __require } from '../../chunk-AKU6F3WT.mjs';
|
|
2
|
+
|
|
3
|
+
// src/backend/file/fileMove.ts
|
|
4
|
+
var fs = __require("fs");
|
|
5
|
+
function fileMove(oldPath, newPath, callback) {
|
|
6
|
+
fs.rename(oldPath, newPath, function(err) {
|
|
7
|
+
if (err) {
|
|
8
|
+
if (err.code === "EXDEV") {
|
|
9
|
+
copy();
|
|
10
|
+
} else {
|
|
11
|
+
callback(err);
|
|
12
|
+
}
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
callback();
|
|
16
|
+
});
|
|
17
|
+
function copy() {
|
|
18
|
+
var readStream = fs.createReadStream(oldPath);
|
|
19
|
+
var writeStream = fs.createWriteStream(newPath);
|
|
20
|
+
readStream.on("error", callback);
|
|
21
|
+
writeStream.on("error", callback);
|
|
22
|
+
readStream.on("close", function() {
|
|
23
|
+
fs.unlink(oldPath, callback);
|
|
24
|
+
});
|
|
25
|
+
readStream.pipe(writeStream);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { fileMove as default };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
4
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
5
|
+
}) : x)(function(x) {
|
|
6
|
+
if (typeof require !== "undefined")
|
|
7
|
+
return require.apply(this, arguments);
|
|
8
|
+
throw new Error('Dynamic require of "' + x + '" is not supported');
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
// src/backend/file/findFilesByExt.ts
|
|
12
|
+
var path = __require("path");
|
|
13
|
+
var fs = __require("fs");
|
|
14
|
+
var forEachFileByExt = (base, ext, cb) => {
|
|
15
|
+
var walk = function(directoryName) {
|
|
16
|
+
try {
|
|
17
|
+
fs.readdir(directoryName, function(e, files) {
|
|
18
|
+
if (e) {
|
|
19
|
+
console.log("Error: ", e);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
files.forEach(function(file) {
|
|
23
|
+
var fullPath = path.join(directoryName, file);
|
|
24
|
+
fs.stat(fullPath, function(e2, f) {
|
|
25
|
+
if (e2) {
|
|
26
|
+
console.log("Error: ", e2);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (f.isDirectory()) {
|
|
30
|
+
walk(fullPath);
|
|
31
|
+
} else {
|
|
32
|
+
if (fullPath.toLowerCase().indexOf(ext.toLowerCase()) > -1) {
|
|
33
|
+
if (cb)
|
|
34
|
+
cb(fullPath);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
} catch (error) {
|
|
41
|
+
console.log("error", error);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
walk(base);
|
|
45
|
+
};
|
|
46
|
+
var findFilesByExt_default = forEachFileByExt;
|
|
47
|
+
|
|
48
|
+
module.exports = findFilesByExt_default;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { __require } from '../../chunk-AKU6F3WT.mjs';
|
|
2
|
+
|
|
3
|
+
// src/backend/file/findFilesByExt.ts
|
|
4
|
+
var path = __require("path");
|
|
5
|
+
var fs = __require("fs");
|
|
6
|
+
var forEachFileByExt = (base, ext, cb) => {
|
|
7
|
+
var walk = function(directoryName) {
|
|
8
|
+
try {
|
|
9
|
+
fs.readdir(directoryName, function(e, files) {
|
|
10
|
+
if (e) {
|
|
11
|
+
console.log("Error: ", e);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
files.forEach(function(file) {
|
|
15
|
+
var fullPath = path.join(directoryName, file);
|
|
16
|
+
fs.stat(fullPath, function(e2, f) {
|
|
17
|
+
if (e2) {
|
|
18
|
+
console.log("Error: ", e2);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (f.isDirectory()) {
|
|
22
|
+
walk(fullPath);
|
|
23
|
+
} else {
|
|
24
|
+
if (fullPath.toLowerCase().indexOf(ext.toLowerCase()) > -1) {
|
|
25
|
+
if (cb)
|
|
26
|
+
cb(fullPath);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.log("error", error);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
walk(base);
|
|
37
|
+
};
|
|
38
|
+
var findFilesByExt_default = forEachFileByExt;
|
|
39
|
+
|
|
40
|
+
export { findFilesByExt_default as default };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// src/object.ts
|
|
2
|
+
var isNull = (object) => {
|
|
3
|
+
if (typeof object == "undefined")
|
|
4
|
+
return true;
|
|
5
|
+
if (object == "")
|
|
6
|
+
return true;
|
|
7
|
+
if (Array.isArray(object))
|
|
8
|
+
return object.length == 0;
|
|
9
|
+
if (JSON.stringify(object) == "{}")
|
|
10
|
+
return true;
|
|
11
|
+
return object == null;
|
|
12
|
+
};
|
|
13
|
+
var toBool = (object) => {
|
|
14
|
+
if (isNull(object))
|
|
15
|
+
return false;
|
|
16
|
+
object = object.toString();
|
|
17
|
+
return object === "true" || object == "1";
|
|
18
|
+
};
|
|
19
|
+
var toInt = (object) => {
|
|
20
|
+
if (isNull(object))
|
|
21
|
+
return 0;
|
|
22
|
+
object = object.toString();
|
|
23
|
+
return parseInt(object, 10);
|
|
24
|
+
};
|
|
25
|
+
var toFloat = (object) => {
|
|
26
|
+
if (isNull(object))
|
|
27
|
+
return 0;
|
|
28
|
+
object = object.toString();
|
|
29
|
+
return parseFloat(object);
|
|
30
|
+
};
|
|
31
|
+
var toArray = (obj) => {
|
|
32
|
+
if (isNull(obj))
|
|
33
|
+
return [];
|
|
34
|
+
if (!Array.isArray(obj)) {
|
|
35
|
+
obj = [obj];
|
|
36
|
+
}
|
|
37
|
+
return obj;
|
|
38
|
+
};
|
|
39
|
+
var objectToArray = (obj) => {
|
|
40
|
+
const array = [];
|
|
41
|
+
for (const key in obj) {
|
|
42
|
+
array.push(obj[key]);
|
|
43
|
+
}
|
|
44
|
+
return array;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export { isNull, objectToArray, toArray, toBool, toFloat, toInt };
|
|
@@ -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
|
+
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 };
|