diginext-utils 2.0.31 → 2.0.33
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/README.md +162 -162
- package/dist/Checker.d.ts +8 -7
- package/dist/Checker.js +48 -28
- package/dist/Checker.mjs +29 -0
- package/dist/EventDispatcher.d.ts +12 -12
- package/dist/EventDispatcher.js +72 -47
- package/dist/EventDispatcher.mjs +54 -0
- package/dist/FileUpload.d.ts +11 -11
- package/dist/FileUpload.js +81 -61
- package/dist/FileUpload.mjs +62 -0
- package/dist/Slug.d.ts +9 -8
- package/dist/Slug.js +350 -330
- package/dist/Slug.mjs +331 -0
- package/dist/Timer-7b0c4e7c.d.ts +11 -0
- package/dist/Timer.d.ts +1 -4
- package/dist/Timer.js +31 -7
- package/dist/Timer.mjs +7 -0
- package/dist/Validation.d.ts +5 -4
- package/dist/Validation.js +54 -37
- package/dist/Validation.mjs +35 -0
- package/dist/array-dc599632.d.ts +158 -0
- package/dist/array.d.ts +1 -113
- package/dist/array.js +246 -266
- package/dist/array.mjs +49 -0
- package/dist/browser-8d042ffe.d.ts +22 -0
- package/dist/camera-1a859d72.d.ts +15 -0
- package/dist/chunk-5NTK5JAI.mjs +57 -0
- package/dist/chunk-5UEMANWE.mjs +91 -0
- package/dist/chunk-5ZOWNKSD.mjs +166 -0
- package/dist/chunk-6GNGTFNC.mjs +118 -0
- package/dist/chunk-7MK72U4O.mjs +19 -0
- package/dist/chunk-7XKT3AQX.mjs +17 -0
- package/dist/chunk-7ZCEZM7K.mjs +41 -0
- package/dist/chunk-AMBWJGSW.mjs +151 -0
- package/dist/chunk-C7S43KGB.mjs +15 -0
- package/dist/chunk-CJM7T7ON.mjs +24 -0
- package/dist/chunk-CKILLYAP.mjs +16 -0
- package/dist/chunk-DX7MUT3M.mjs +51 -0
- package/dist/chunk-EGUJQ5VF.mjs +32 -0
- package/dist/chunk-ETEIHDWU.mjs +25 -0
- package/dist/chunk-FJXSVGL7.mjs +22 -0
- package/dist/chunk-GJCAEOND.mjs +20 -0
- package/dist/chunk-GNJDIUYM.mjs +40 -0
- package/dist/chunk-IA7GINWD.mjs +39 -0
- package/dist/chunk-JEI7BOXY.mjs +21 -0
- package/dist/chunk-K4KENOE6.mjs +20 -0
- package/dist/chunk-KMERW6KS.mjs +34 -0
- package/dist/chunk-KPO3RH5G.mjs +27 -0
- package/dist/chunk-KWG5LYNK.mjs +100 -0
- package/dist/chunk-NUTQDHLQ.mjs +40 -0
- package/dist/chunk-O64XUDAH.mjs +35 -0
- package/dist/chunk-OYRPWQUA.mjs +257 -0
- package/dist/chunk-PNZ4KGXL.mjs +56 -0
- package/dist/chunk-QZYX26HT.mjs +24 -0
- package/dist/chunk-RDGP2CKM.mjs +195 -0
- package/dist/chunk-VFG5VU6S.mjs +12 -0
- package/dist/chunk-X3IMFCZG.mjs +23 -0
- package/dist/chunk-ZHNGZMRD.mjs +17 -0
- package/dist/color.d.ts +23 -22
- package/dist/color.js +96 -79
- package/dist/color.mjs +78 -0
- package/dist/console/enableConsole.d.ts +1 -2
- package/dist/console/enableConsole.js +38 -10
- package/dist/console/enableConsole.mjs +9 -0
- package/dist/console/index.d.ts +2 -11
- package/dist/console/index.js +58 -15
- package/dist/console/index.mjs +14 -0
- package/dist/console/log.d.ts +15 -14
- package/dist/console/log.js +74 -44
- package/dist/console/log.mjs +19 -0
- package/dist/createDir-220e0081.d.ts +13 -0
- package/dist/device/browser.d.ts +1 -5
- package/dist/device/browser.js +60 -32
- package/dist/device/browser.mjs +15 -0
- package/dist/device/camera.d.ts +1 -7
- package/dist/device/camera.js +184 -166
- package/dist/device/camera.mjs +8 -0
- package/dist/device/index.d.ts +1 -5
- package/dist/device/index.js +201 -216
- package/dist/device/index.mjs +15 -0
- package/dist/device/os.d.ts +11 -10
- package/dist/device/os.js +55 -28
- package/dist/device/os.mjs +33 -0
- package/dist/enableConsole-ddc24282.d.ts +11 -0
- package/dist/file/createDir.d.ts +1 -5
- package/dist/file/createDir.js +34 -13
- package/dist/file/createDir.mjs +7 -0
- package/dist/file/fileMove.d.ts +1 -4
- package/dist/file/fileMove.js +49 -29
- package/dist/file/fileMove.mjs +7 -0
- package/dist/file/findFilesByExt.d.ts +1 -13
- package/dist/file/findFilesByExt.js +64 -45
- package/dist/file/findFilesByExt.mjs +11 -0
- package/dist/file/index.d.ts +10 -8
- package/dist/file/index.js +104 -9
- package/dist/file/index.mjs +17 -0
- package/dist/fileMove-3a09e429.d.ts +13 -0
- package/dist/findFilesByExt-753e91d7.d.ts +24 -0
- package/dist/images/index.d.ts +2 -2
- package/dist/images/index.js +131 -8
- package/dist/images/index.mjs +15 -0
- package/dist/images/loadImage.d.ts +3 -0
- package/dist/images/loadImage.js +42 -0
- package/dist/images/loadImage.mjs +21 -0
- package/dist/images/resize.d.ts +3 -2
- package/dist/images/resize.js +60 -34
- package/dist/images/resize.mjs +9 -0
- package/dist/images/upload.d.ts +10 -9
- package/dist/images/upload.js +130 -25
- package/dist/images/upload.mjs +14 -0
- package/dist/index-1f738e52.d.ts +22 -0
- package/dist/index-22309f0c.d.ts +23 -0
- package/dist/index-6ae3c86b.d.ts +63 -0
- package/dist/index-c8fffc86.d.ts +90 -0
- package/dist/index-d652ed2c.d.ts +26 -0
- package/dist/index.d.ts +47 -36
- package/dist/index.js +1352 -62
- package/dist/index.mjs +87 -0
- package/dist/json.d.ts +8 -7
- package/dist/json.js +48 -28
- package/dist/json.mjs +29 -0
- package/dist/math/diffDate.d.ts +6 -5
- package/dist/math/diffDate.js +33 -11
- package/dist/math/diffDate.mjs +9 -0
- package/dist/math/index.d.ts +3 -30
- package/dist/math/index.js +159 -92
- package/dist/math/index.mjs +34 -0
- package/dist/math/positiveNumber.d.ts +3 -2
- package/dist/math/positiveNumber.js +53 -14
- package/dist/math/positiveNumber.mjs +10 -0
- package/dist/name/en.d.ts +5 -4
- package/dist/name/en.js +37 -19
- package/dist/name/en.mjs +9 -0
- package/dist/name/index.d.ts +3 -12
- package/dist/name/index.js +87 -12
- package/dist/name/index.mjs +20 -0
- package/dist/name/vi.d.ts +5 -4
- package/dist/name/vi.js +63 -25
- package/dist/name/vi.mjs +14 -0
- package/{esm/object.d.ts → dist/object-43aaaf92.d.ts} +79 -58
- package/dist/object.d.ts +1 -59
- package/dist/object.js +96 -71
- package/dist/object.mjs +21 -0
- package/dist/permission/index.d.ts +8 -7
- package/dist/permission/index.js +230 -6
- package/dist/permission/index.mjs +15 -0
- package/dist/permission/requestCamera.d.ts +1 -5
- package/dist/permission/requestCamera.js +49 -38
- package/dist/permission/requestCamera.mjs +9 -0
- package/dist/permission/requestDeviceOrientationControl.d.ts +1 -2
- package/dist/permission/requestDeviceOrientationControl.js +203 -36
- package/dist/permission/requestDeviceOrientationControl.mjs +10 -0
- package/dist/requestCamera-32b7dfc7.d.ts +14 -0
- package/dist/requestDeviceOrientationControl-b6458660.d.ts +11 -0
- package/dist/response/index.d.ts +49 -48
- package/dist/response/index.js +92 -47
- package/dist/response/index.mjs +16 -0
- package/dist/string/formatNumber.d.ts +7 -6
- package/dist/string/formatNumber.js +53 -12
- package/dist/string/formatNumber.mjs +10 -0
- package/dist/string/generatePassword.d.ts +10 -9
- package/dist/string/generatePassword.js +52 -21
- package/dist/string/generatePassword.mjs +10 -0
- package/dist/string/generateUUID.d.ts +3 -2
- package/dist/string/generateUUID.js +37 -34
- package/dist/string/generateUUID.mjs +9 -0
- package/dist/string/index.d.ts +6 -65
- package/dist/string/index.js +312 -157
- package/dist/string/index.mjs +31 -0
- package/dist/string/makeDaySlug.d.ts +31 -30
- package/dist/string/makeDaySlug.js +43 -19
- package/dist/string/makeDaySlug.mjs +9 -0
- package/dist/string/random.d.ts +14 -13
- package/dist/string/random.js +53 -22
- package/dist/string/random.mjs +19 -0
- package/dist/string/trimNull.d.ts +3 -2
- package/dist/string/trimNull.js +45 -17
- package/dist/string/trimNull.mjs +9 -0
- package/dist/string/url.d.ts +1 -36
- package/dist/string/url.js +115 -97
- package/dist/string/url.mjs +22 -0
- package/dist/url-60657387.d.ts +57 -0
- package/package.json +66 -66
- package/src/Checker.ts +29 -29
- package/src/EventDispatcher.ts +62 -62
- package/src/FileUpload.ts +66 -66
- package/src/Slug.ts +365 -365
- package/src/Timer.ts +7 -7
- package/src/Validation.ts +36 -36
- package/src/array.ts +285 -285
- package/src/color.ts +87 -87
- package/src/console/enableConsole.ts +8 -8
- package/src/console/index.ts +17 -17
- package/src/console/log.ts +39 -39
- package/src/device/browser.ts +29 -29
- package/src/device/camera.ts +207 -207
- package/src/device/index.ts +230 -230
- package/src/device/os.ts +29 -29
- package/src/file/createDir.ts +14 -14
- package/src/file/fileMove.ts +32 -32
- package/src/file/findFilesByExt.ts +46 -46
- package/src/file/index.ts +7 -7
- package/src/images/index.ts +3 -3
- package/src/images/loadImage.ts +16 -0
- package/src/images/resize.ts +35 -35
- package/src/images/upload.ts +24 -24
- package/src/index.ts +39 -39
- package/src/json.ts +29 -29
- package/src/math/diffDate.ts +10 -10
- package/src/math/index.ts +90 -90
- package/src/math/positiveNumber.ts +12 -12
- package/src/name/en.ts +27 -27
- package/src/name/index.ts +8 -8
- package/src/name/vi.ts +23 -23
- package/src/object.ts +72 -72
- package/src/permission/index.ts +6 -6
- package/src/permission/requestCamera.ts +43 -43
- package/src/permission/requestDeviceOrientationControl.ts +33 -33
- package/src/response/index.ts +45 -45
- package/src/string/formatNumber.ts +12 -12
- package/src/string/generatePassword.ts +18 -18
- package/src/string/generateUUID.ts +37 -37
- package/src/string/index.ts +180 -180
- package/src/string/makeDaySlug.ts +40 -40
- package/src/string/random.ts +24 -24
- package/src/string/trimNull.ts +16 -16
- package/src/string/url.ts +116 -116
- package/dist/Checker.js.map +0 -1
- package/dist/EventDispatcher.js.map +0 -1
- package/dist/FileUpload.js.map +0 -1
- package/dist/Slug.js.map +0 -1
- package/dist/Timer.js.map +0 -1
- package/dist/Validation.js.map +0 -1
- package/dist/array.js.map +0 -1
- package/dist/color.js.map +0 -1
- package/dist/console/enableConsole.js.map +0 -1
- package/dist/console/index.js.map +0 -1
- package/dist/console/log.js.map +0 -1
- package/dist/device/browser.js.map +0 -1
- package/dist/device/camera.js.map +0 -1
- package/dist/device/index.js.map +0 -1
- package/dist/device/os.js.map +0 -1
- package/dist/file/createDir.js.map +0 -1
- package/dist/file/fileMove.js.map +0 -1
- package/dist/file/findFilesByExt.js.map +0 -1
- package/dist/file/index.js.map +0 -1
- package/dist/images/index.js.map +0 -1
- package/dist/images/resize.js.map +0 -1
- package/dist/images/upload.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/json.js.map +0 -1
- package/dist/math/diffDate.js.map +0 -1
- package/dist/math/index.js.map +0 -1
- package/dist/math/positiveNumber.js.map +0 -1
- package/dist/name/en.js.map +0 -1
- package/dist/name/index.js.map +0 -1
- package/dist/name/vi.js.map +0 -1
- package/dist/object.js.map +0 -1
- package/dist/permission/index.js.map +0 -1
- package/dist/permission/requestCamera.js.map +0 -1
- package/dist/permission/requestDeviceOrientationControl.js.map +0 -1
- package/dist/response/index.js.map +0 -1
- package/dist/string/formatNumber.js.map +0 -1
- package/dist/string/generatePassword.js.map +0 -1
- package/dist/string/generateUUID.js.map +0 -1
- package/dist/string/index.js.map +0 -1
- package/dist/string/makeDaySlug.js.map +0 -1
- package/dist/string/random.js.map +0 -1
- package/dist/string/trimNull.js.map +0 -1
- package/dist/string/url.js.map +0 -1
- package/esm/Checker.d.ts +0 -8
- package/esm/Checker.js +0 -28
- package/esm/Checker.js.map +0 -1
- package/esm/EventDispatcher.d.ts +0 -13
- package/esm/EventDispatcher.js +0 -49
- package/esm/EventDispatcher.js.map +0 -1
- package/esm/FileUpload.d.ts +0 -12
- package/esm/FileUpload.js +0 -62
- package/esm/FileUpload.js.map +0 -1
- package/esm/Slug.d.ts +0 -9
- package/esm/Slug.js +0 -330
- package/esm/Slug.js.map +0 -1
- package/esm/Timer.d.ts +0 -4
- package/esm/Timer.js +0 -7
- package/esm/Timer.js.map +0 -1
- package/esm/Validation.d.ts +0 -5
- package/esm/Validation.js +0 -37
- package/esm/Validation.js.map +0 -1
- package/esm/array.d.ts +0 -113
- package/esm/array.js +0 -275
- package/esm/array.js.map +0 -1
- package/esm/color.d.ts +0 -23
- package/esm/color.js +0 -80
- package/esm/color.js.map +0 -1
- package/esm/console/enableConsole.d.ts +0 -2
- package/esm/console/enableConsole.js +0 -7
- package/esm/console/enableConsole.js.map +0 -1
- package/esm/console/index.d.ts +0 -11
- package/esm/console/index.js +0 -13
- package/esm/console/index.js.map +0 -1
- package/esm/console/log.d.ts +0 -15
- package/esm/console/log.js +0 -33
- package/esm/console/log.js.map +0 -1
- package/esm/device/browser.d.ts +0 -5
- package/esm/device/browser.js +0 -30
- package/esm/device/browser.js.map +0 -1
- package/esm/device/camera.d.ts +0 -7
- package/esm/device/camera.js +0 -168
- package/esm/device/camera.js.map +0 -1
- package/esm/device/index.d.ts +0 -5
- package/esm/device/index.js +0 -217
- package/esm/device/index.js.map +0 -1
- package/esm/device/os.d.ts +0 -11
- package/esm/device/os.js +0 -28
- package/esm/device/os.js.map +0 -1
- package/esm/file/createDir.d.ts +0 -5
- package/esm/file/createDir.js +0 -13
- package/esm/file/createDir.js.map +0 -1
- package/esm/file/fileMove.d.ts +0 -4
- package/esm/file/fileMove.js +0 -29
- package/esm/file/fileMove.js.map +0 -1
- package/esm/file/findFilesByExt.d.ts +0 -13
- package/esm/file/findFilesByExt.js +0 -46
- package/esm/file/findFilesByExt.js.map +0 -1
- package/esm/file/index.d.ts +0 -9
- package/esm/file/index.js +0 -6
- package/esm/file/index.js.map +0 -1
- package/esm/images/index.d.ts +0 -2
- package/esm/images/index.js +0 -4
- package/esm/images/index.js.map +0 -1
- package/esm/images/resize.d.ts +0 -2
- package/esm/images/resize.js +0 -31
- package/esm/images/resize.js.map +0 -1
- package/esm/images/upload.d.ts +0 -10
- package/esm/images/upload.js +0 -20
- package/esm/images/upload.js.map +0 -1
- package/esm/index.d.ts +0 -37
- package/esm/index.js +0 -38
- package/esm/index.js.map +0 -1
- package/esm/json.d.ts +0 -8
- package/esm/json.js +0 -28
- package/esm/json.js.map +0 -1
- package/esm/math/diffDate.d.ts +0 -5
- package/esm/math/diffDate.js +0 -10
- package/esm/math/diffDate.js.map +0 -1
- package/esm/math/index.d.ts +0 -30
- package/esm/math/index.js +0 -78
- package/esm/math/index.js.map +0 -1
- package/esm/math/positiveNumber.d.ts +0 -2
- package/esm/math/positiveNumber.js +0 -13
- package/esm/math/positiveNumber.js.map +0 -1
- package/esm/name/en.d.ts +0 -5
- package/esm/name/en.js +0 -22
- package/esm/name/en.js.map +0 -1
- package/esm/name/index.d.ts +0 -12
- package/esm/name/index.js +0 -6
- package/esm/name/index.js.map +0 -1
- package/esm/name/vi.d.ts +0 -5
- package/esm/name/vi.js +0 -24
- package/esm/name/vi.js.map +0 -1
- package/esm/object.js +0 -70
- package/esm/object.js.map +0 -1
- package/esm/permission/index.d.ts +0 -8
- package/esm/permission/index.js +0 -5
- package/esm/permission/index.js.map +0 -1
- package/esm/permission/requestCamera.d.ts +0 -5
- package/esm/permission/requestCamera.js +0 -39
- package/esm/permission/requestCamera.js.map +0 -1
- package/esm/permission/requestDeviceOrientationControl.d.ts +0 -2
- package/esm/permission/requestDeviceOrientationControl.js +0 -35
- package/esm/permission/requestDeviceOrientationControl.js.map +0 -1
- package/esm/response/index.d.ts +0 -49
- package/esm/response/index.js +0 -46
- package/esm/response/index.js.map +0 -1
- package/esm/string/formatNumber.d.ts +0 -6
- package/esm/string/formatNumber.js +0 -11
- package/esm/string/formatNumber.js.map +0 -1
- package/esm/string/generatePassword.d.ts +0 -9
- package/esm/string/generatePassword.js +0 -20
- package/esm/string/generatePassword.js.map +0 -1
- package/esm/string/generateUUID.d.ts +0 -2
- package/esm/string/generateUUID.js +0 -33
- package/esm/string/generateUUID.js.map +0 -1
- package/esm/string/index.d.ts +0 -65
- package/esm/string/index.js +0 -150
- package/esm/string/index.js.map +0 -1
- package/esm/string/makeDaySlug.d.ts +0 -31
- package/esm/string/makeDaySlug.js +0 -16
- package/esm/string/makeDaySlug.js.map +0 -1
- package/esm/string/random.d.ts +0 -14
- package/esm/string/random.js +0 -20
- package/esm/string/random.js.map +0 -1
- package/esm/string/trimNull.d.ts +0 -2
- package/esm/string/trimNull.js +0 -14
- package/esm/string/trimNull.js.map +0 -1
- package/esm/string/url.d.ts +0 -36
- package/esm/string/url.js +0 -98
- package/esm/string/url.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "diginext-utils",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"sideEffects": false,
|
|
5
|
-
"readme": "README.md",
|
|
6
|
-
"homepage": "https://wearetopgroup.com",
|
|
7
|
-
"author": {
|
|
8
|
-
"name": "TOP GROUP (a.k.a Digitop)",
|
|
9
|
-
"email": "dev@wearetopgroup.com"
|
|
10
|
-
},
|
|
11
|
-
"keywords": [
|
|
12
|
-
"utils",
|
|
13
|
-
"plugins",
|
|
14
|
-
"diginext",
|
|
15
|
-
"diginext-utils",
|
|
16
|
-
"utilities",
|
|
17
|
-
"helper",
|
|
18
|
-
"extra"
|
|
19
|
-
],
|
|
20
|
-
"main": "./dist/index.js",
|
|
21
|
-
"files": [
|
|
22
|
-
"dist",
|
|
23
|
-
"esm",
|
|
24
|
-
"src"
|
|
25
|
-
],
|
|
26
|
-
"scripts": {
|
|
27
|
-
"build": "
|
|
28
|
-
"build_tsup": "tsup src/**/*.ts --format esm,cjs --dts --legacy-output",
|
|
29
|
-
"prebuild": "rm -rf dist && rm -rf esm",
|
|
30
|
-
"release": "
|
|
31
|
-
"dev": "
|
|
32
|
-
"test": "mocha test/*.test.js",
|
|
33
|
-
"publish": "
|
|
34
|
-
"lint": "TIMING=1 eslint src --fix",
|
|
35
|
-
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
|
|
36
|
-
},
|
|
37
|
-
"dependencies": {
|
|
38
|
-
"@types/jest": "^26.0.22",
|
|
39
|
-
"@types/node": "^18.8.5",
|
|
40
|
-
"@types/react": "^17.0.13",
|
|
41
|
-
"@types/react-dom": "^17.0.8",
|
|
42
|
-
"blueimp-load-image": "^5.16.0",
|
|
43
|
-
"chalk": "4.1.2",
|
|
44
|
-
"concurrently": "^7.2.2",
|
|
45
|
-
"config": "*",
|
|
46
|
-
"core-js": "^3.24.1",
|
|
47
|
-
"dayjs": "^1.11.5",
|
|
48
|
-
"esm": "^3.2.25",
|
|
49
|
-
"gsap": "^3.10.4",
|
|
50
|
-
"lodash": "^4.17.21",
|
|
51
|
-
"tsconfig": "*",
|
|
52
|
-
"tsup": "^6.1.3",
|
|
53
|
-
"typescript": "^4.5.3"
|
|
54
|
-
},
|
|
55
|
-
"publishConfig": {
|
|
56
|
-
"access": "public"
|
|
57
|
-
},
|
|
58
|
-
"devDependencies": {
|
|
59
|
-
"@types/blueimp-load-image": "^5.16.0",
|
|
60
|
-
"@types/lodash": "^4.14.186",
|
|
61
|
-
"eslint": "^7.16.0",
|
|
62
|
-
"eslint-plugin-import": "^2.26.0",
|
|
63
|
-
"esm": "^3.2.25",
|
|
64
|
-
"mocha": "^10.0.0"
|
|
65
|
-
}
|
|
66
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "diginext-utils",
|
|
3
|
+
"version": "2.0.33",
|
|
4
|
+
"sideEffects": false,
|
|
5
|
+
"readme": "README.md",
|
|
6
|
+
"homepage": "https://wearetopgroup.com",
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "TOP GROUP (a.k.a Digitop)",
|
|
9
|
+
"email": "dev@wearetopgroup.com"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"utils",
|
|
13
|
+
"plugins",
|
|
14
|
+
"diginext",
|
|
15
|
+
"diginext-utils",
|
|
16
|
+
"utilities",
|
|
17
|
+
"helper",
|
|
18
|
+
"extra"
|
|
19
|
+
],
|
|
20
|
+
"main": "./dist/index.js",
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"esm",
|
|
24
|
+
"src"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "npm run prebuild && tsc --module commonjs --outDir dist && tsc --module esnext --outDir esm && npm run test",
|
|
28
|
+
"build_tsup": "tsup src/**/*.ts --format esm,cjs --dts --legacy-output",
|
|
29
|
+
"prebuild": "rm -rf dist && rm -rf esm",
|
|
30
|
+
"release": "npm run prebuild && npm run build && npm run publish",
|
|
31
|
+
"dev": "npm run prebuild && concurrently \"tsup src/**/*.ts --format esm,cjs --dts --watch\"",
|
|
32
|
+
"test": "mocha test/*.test.js",
|
|
33
|
+
"publish": "npm run build && npm run test && npm publish",
|
|
34
|
+
"lint": "TIMING=1 eslint src --fix",
|
|
35
|
+
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@types/jest": "^26.0.22",
|
|
39
|
+
"@types/node": "^18.8.5",
|
|
40
|
+
"@types/react": "^17.0.13",
|
|
41
|
+
"@types/react-dom": "^17.0.8",
|
|
42
|
+
"blueimp-load-image": "^5.16.0",
|
|
43
|
+
"chalk": "4.1.2",
|
|
44
|
+
"concurrently": "^7.2.2",
|
|
45
|
+
"config": "*",
|
|
46
|
+
"core-js": "^3.24.1",
|
|
47
|
+
"dayjs": "^1.11.5",
|
|
48
|
+
"esm": "^3.2.25",
|
|
49
|
+
"gsap": "^3.10.4",
|
|
50
|
+
"lodash": "^4.17.21",
|
|
51
|
+
"tsconfig": "*",
|
|
52
|
+
"tsup": "^6.1.3",
|
|
53
|
+
"typescript": "^4.5.3"
|
|
54
|
+
},
|
|
55
|
+
"publishConfig": {
|
|
56
|
+
"access": "public"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@types/blueimp-load-image": "^5.16.0",
|
|
60
|
+
"@types/lodash": "^4.14.186",
|
|
61
|
+
"eslint": "^7.16.0",
|
|
62
|
+
"eslint-plugin-import": "^2.26.0",
|
|
63
|
+
"esm": "^3.2.25",
|
|
64
|
+
"mocha": "^10.0.0"
|
|
65
|
+
}
|
|
66
|
+
}
|
package/src/Checker.ts
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Check if the object or string is in JSON format
|
|
3
|
-
*/
|
|
4
|
-
export const isJSON = (content: object | string) => {
|
|
5
|
-
if (typeof content == "object") {
|
|
6
|
-
try {
|
|
7
|
-
content = JSON.stringify(content);
|
|
8
|
-
} catch (err) {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (typeof content == "string") {
|
|
14
|
-
try {
|
|
15
|
-
content = JSON.parse(content);
|
|
16
|
-
} catch (err) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (typeof content != "object") {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
return true;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const Checker = { isJSON };
|
|
28
|
-
|
|
29
|
-
export default Checker;
|
|
1
|
+
/**
|
|
2
|
+
* Check if the object or string is in JSON format
|
|
3
|
+
*/
|
|
4
|
+
export const isJSON = (content: object | string) => {
|
|
5
|
+
if (typeof content == "object") {
|
|
6
|
+
try {
|
|
7
|
+
content = JSON.stringify(content);
|
|
8
|
+
} catch (err) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (typeof content == "string") {
|
|
14
|
+
try {
|
|
15
|
+
content = JSON.parse(content);
|
|
16
|
+
} catch (err) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (typeof content != "object") {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
return true;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const Checker = { isJSON };
|
|
28
|
+
|
|
29
|
+
export default Checker;
|
package/src/EventDispatcher.ts
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
class EventDispatcher {
|
|
2
|
-
constructor() {}
|
|
3
|
-
|
|
4
|
-
_listeners: any;
|
|
5
|
-
|
|
6
|
-
addEventListener(type: string, listener: any) {
|
|
7
|
-
if (this._listeners === undefined) this._listeners = {};
|
|
8
|
-
|
|
9
|
-
const listeners = this._listeners;
|
|
10
|
-
|
|
11
|
-
if (listeners[type] === undefined) {
|
|
12
|
-
listeners[type] = [];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (listeners[type].indexOf(listener) === -1) {
|
|
16
|
-
listeners[type].push(listener);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
hasEventListener(type: string, listener: any) {
|
|
21
|
-
if (this._listeners === undefined) return false;
|
|
22
|
-
|
|
23
|
-
const listeners = this._listeners;
|
|
24
|
-
|
|
25
|
-
return listeners[type] !== undefined && listeners[type].indexOf(listener) !== -1;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
removeEventListener(type: string, listener: any) {
|
|
29
|
-
if (this._listeners === undefined) return;
|
|
30
|
-
|
|
31
|
-
const listeners = this._listeners;
|
|
32
|
-
const listenerArray = listeners[type];
|
|
33
|
-
|
|
34
|
-
if (listenerArray !== undefined) {
|
|
35
|
-
const index = listenerArray.indexOf(listener);
|
|
36
|
-
|
|
37
|
-
if (index !== -1) {
|
|
38
|
-
listenerArray.splice(index, 1);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
dispatchEvent(event: { type: string; target: any }) {
|
|
44
|
-
if (this._listeners === undefined) return;
|
|
45
|
-
|
|
46
|
-
const listeners = this._listeners;
|
|
47
|
-
const listenerArray = listeners[event.type];
|
|
48
|
-
|
|
49
|
-
if (listenerArray !== undefined) {
|
|
50
|
-
event.target = this;
|
|
51
|
-
|
|
52
|
-
// Make a copy, in case listeners are removed while iterating.
|
|
53
|
-
const array = listenerArray.slice(0);
|
|
54
|
-
|
|
55
|
-
for (let i = 0, l = array.length; i < l; i++) {
|
|
56
|
-
array[i].call(this, event);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
export { EventDispatcher };
|
|
62
|
-
export default EventDispatcher;
|
|
1
|
+
class EventDispatcher {
|
|
2
|
+
constructor() {}
|
|
3
|
+
|
|
4
|
+
_listeners: any;
|
|
5
|
+
|
|
6
|
+
addEventListener(type: string, listener: any) {
|
|
7
|
+
if (this._listeners === undefined) this._listeners = {};
|
|
8
|
+
|
|
9
|
+
const listeners = this._listeners;
|
|
10
|
+
|
|
11
|
+
if (listeners[type] === undefined) {
|
|
12
|
+
listeners[type] = [];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (listeners[type].indexOf(listener) === -1) {
|
|
16
|
+
listeners[type].push(listener);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
hasEventListener(type: string, listener: any) {
|
|
21
|
+
if (this._listeners === undefined) return false;
|
|
22
|
+
|
|
23
|
+
const listeners = this._listeners;
|
|
24
|
+
|
|
25
|
+
return listeners[type] !== undefined && listeners[type].indexOf(listener) !== -1;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
removeEventListener(type: string, listener: any) {
|
|
29
|
+
if (this._listeners === undefined) return;
|
|
30
|
+
|
|
31
|
+
const listeners = this._listeners;
|
|
32
|
+
const listenerArray = listeners[type];
|
|
33
|
+
|
|
34
|
+
if (listenerArray !== undefined) {
|
|
35
|
+
const index = listenerArray.indexOf(listener);
|
|
36
|
+
|
|
37
|
+
if (index !== -1) {
|
|
38
|
+
listenerArray.splice(index, 1);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
dispatchEvent(event: { type: string; target: any }) {
|
|
44
|
+
if (this._listeners === undefined) return;
|
|
45
|
+
|
|
46
|
+
const listeners = this._listeners;
|
|
47
|
+
const listenerArray = listeners[event.type];
|
|
48
|
+
|
|
49
|
+
if (listenerArray !== undefined) {
|
|
50
|
+
event.target = this;
|
|
51
|
+
|
|
52
|
+
// Make a copy, in case listeners are removed while iterating.
|
|
53
|
+
const array = listenerArray.slice(0);
|
|
54
|
+
|
|
55
|
+
for (let i = 0, l = array.length; i < l; i++) {
|
|
56
|
+
array[i].call(this, event);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export { EventDispatcher };
|
|
62
|
+
export default EventDispatcher;
|
package/src/FileUpload.ts
CHANGED
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
var logFile = "[FileUpload.js] ";
|
|
2
|
-
|
|
3
|
-
type UploadParams = { blob: Blob; url: string; params: any; onComplete: any; onError: any };
|
|
4
|
-
|
|
5
|
-
const FileUpload = {
|
|
6
|
-
uploadBlob(props: UploadParams) {
|
|
7
|
-
const { blob, url, params, onComplete, onError } = props;
|
|
8
|
-
|
|
9
|
-
var formData = new FormData();
|
|
10
|
-
formData.append("upload", blob, "img_" + +new Date() + ".jpg");
|
|
11
|
-
|
|
12
|
-
if (params) {
|
|
13
|
-
Object.keys(params).forEach((key) => {
|
|
14
|
-
var val = params[key];
|
|
15
|
-
formData.append(key, val);
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
var request = new XMLHttpRequest();
|
|
20
|
-
request.open("POST", url);
|
|
21
|
-
request.send(formData);
|
|
22
|
-
|
|
23
|
-
request.onreadystatechange = function () {
|
|
24
|
-
if (this.readyState == 4) {
|
|
25
|
-
// Typical action to be performed when the document is ready:
|
|
26
|
-
if (this.status == 200) {
|
|
27
|
-
// var response = JSON.parse(request.response) || "";
|
|
28
|
-
var response: { status?: boolean; data?: any } = {};
|
|
29
|
-
try {
|
|
30
|
-
response = JSON.parse(request.response) || "";
|
|
31
|
-
} catch (error) {
|
|
32
|
-
console.error(logFile, "Can't part JSON of the response");
|
|
33
|
-
}
|
|
34
|
-
var statusOfSafety = response.status || 0;
|
|
35
|
-
|
|
36
|
-
if (statusOfSafety == 1) {
|
|
37
|
-
console.log(logFile, "request: ", request);
|
|
38
|
-
var data = response.data || {};
|
|
39
|
-
console.log(logFile, data);
|
|
40
|
-
|
|
41
|
-
var _url = data["url"];
|
|
42
|
-
|
|
43
|
-
if (onComplete) onComplete(_url);
|
|
44
|
-
} else {
|
|
45
|
-
var errMsg = "Ảnh có nội dung không phù hợp.";
|
|
46
|
-
console.error(logFile, errMsg);
|
|
47
|
-
if (onError) onError(errMsg);
|
|
48
|
-
}
|
|
49
|
-
} else {
|
|
50
|
-
var errMsg = "Upload ảnh không thành công!";
|
|
51
|
-
console.error(logFile, errMsg);
|
|
52
|
-
if (onError) onError(errMsg);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
request.onerror = function (res) {
|
|
58
|
-
var errMsg = "Upload ảnh không thành công!";
|
|
59
|
-
console.error(logFile, errMsg, "=>", res);
|
|
60
|
-
if (onError) onError(errMsg);
|
|
61
|
-
};
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export { FileUpload };
|
|
66
|
-
export default FileUpload;
|
|
1
|
+
var logFile = "[FileUpload.js] ";
|
|
2
|
+
|
|
3
|
+
type UploadParams = { blob: Blob; url: string; params: any; onComplete: any; onError: any };
|
|
4
|
+
|
|
5
|
+
const FileUpload = {
|
|
6
|
+
uploadBlob(props: UploadParams) {
|
|
7
|
+
const { blob, url, params, onComplete, onError } = props;
|
|
8
|
+
|
|
9
|
+
var formData = new FormData();
|
|
10
|
+
formData.append("upload", blob, "img_" + +new Date() + ".jpg");
|
|
11
|
+
|
|
12
|
+
if (params) {
|
|
13
|
+
Object.keys(params).forEach((key) => {
|
|
14
|
+
var val = params[key];
|
|
15
|
+
formData.append(key, val);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
var request = new XMLHttpRequest();
|
|
20
|
+
request.open("POST", url);
|
|
21
|
+
request.send(formData);
|
|
22
|
+
|
|
23
|
+
request.onreadystatechange = function () {
|
|
24
|
+
if (this.readyState == 4) {
|
|
25
|
+
// Typical action to be performed when the document is ready:
|
|
26
|
+
if (this.status == 200) {
|
|
27
|
+
// var response = JSON.parse(request.response) || "";
|
|
28
|
+
var response: { status?: boolean; data?: any } = {};
|
|
29
|
+
try {
|
|
30
|
+
response = JSON.parse(request.response) || "";
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.error(logFile, "Can't part JSON of the response");
|
|
33
|
+
}
|
|
34
|
+
var statusOfSafety = response.status || 0;
|
|
35
|
+
|
|
36
|
+
if (statusOfSafety == 1) {
|
|
37
|
+
console.log(logFile, "request: ", request);
|
|
38
|
+
var data = response.data || {};
|
|
39
|
+
console.log(logFile, data);
|
|
40
|
+
|
|
41
|
+
var _url = data["url"];
|
|
42
|
+
|
|
43
|
+
if (onComplete) onComplete(_url);
|
|
44
|
+
} else {
|
|
45
|
+
var errMsg = "Ảnh có nội dung không phù hợp.";
|
|
46
|
+
console.error(logFile, errMsg);
|
|
47
|
+
if (onError) onError(errMsg);
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
var errMsg = "Upload ảnh không thành công!";
|
|
51
|
+
console.error(logFile, errMsg);
|
|
52
|
+
if (onError) onError(errMsg);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
request.onerror = function (res) {
|
|
58
|
+
var errMsg = "Upload ảnh không thành công!";
|
|
59
|
+
console.error(logFile, errMsg, "=>", res);
|
|
60
|
+
if (onError) onError(errMsg);
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export { FileUpload };
|
|
66
|
+
export default FileUpload;
|