diginext-utils 2.0.33 → 2.0.35
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/package.json +1 -1
- package/src/console/index.ts +2 -2
- package/src/string/url.ts +2 -2
- package/dist/Checker.d.ts +0 -9
- package/dist/Checker.js +0 -52
- package/dist/Checker.mjs +0 -29
- package/dist/EventDispatcher.d.ts +0 -13
- package/dist/EventDispatcher.js +0 -77
- package/dist/EventDispatcher.mjs +0 -54
- package/dist/FileUpload.d.ts +0 -12
- package/dist/FileUpload.js +0 -85
- package/dist/FileUpload.mjs +0 -62
- package/dist/Slug.d.ts +0 -10
- package/dist/Slug.js +0 -354
- package/dist/Slug.mjs +0 -331
- package/dist/Timer-7b0c4e7c.d.ts +0 -11
- package/dist/Timer.d.ts +0 -1
- package/dist/Timer.js +0 -33
- package/dist/Timer.mjs +0 -7
- package/dist/Validation.d.ts +0 -6
- package/dist/Validation.js +0 -56
- package/dist/Validation.mjs +0 -35
- package/dist/array-dc599632.d.ts +0 -158
- package/dist/array.d.ts +0 -1
- package/dist/array.js +0 -277
- package/dist/array.mjs +0 -49
- package/dist/browser-8d042ffe.d.ts +0 -22
- package/dist/camera-1a859d72.d.ts +0 -15
- package/dist/chunk-5NTK5JAI.mjs +0 -57
- package/dist/chunk-5UEMANWE.mjs +0 -91
- package/dist/chunk-5ZOWNKSD.mjs +0 -166
- package/dist/chunk-6GNGTFNC.mjs +0 -118
- package/dist/chunk-7MK72U4O.mjs +0 -19
- package/dist/chunk-7XKT3AQX.mjs +0 -17
- package/dist/chunk-7ZCEZM7K.mjs +0 -41
- package/dist/chunk-AMBWJGSW.mjs +0 -151
- package/dist/chunk-C7S43KGB.mjs +0 -15
- package/dist/chunk-CJM7T7ON.mjs +0 -24
- package/dist/chunk-CKILLYAP.mjs +0 -16
- package/dist/chunk-DX7MUT3M.mjs +0 -51
- package/dist/chunk-EGUJQ5VF.mjs +0 -32
- package/dist/chunk-ETEIHDWU.mjs +0 -25
- package/dist/chunk-FJXSVGL7.mjs +0 -22
- package/dist/chunk-GJCAEOND.mjs +0 -20
- package/dist/chunk-GNJDIUYM.mjs +0 -40
- package/dist/chunk-IA7GINWD.mjs +0 -39
- package/dist/chunk-JEI7BOXY.mjs +0 -21
- package/dist/chunk-K4KENOE6.mjs +0 -20
- package/dist/chunk-KMERW6KS.mjs +0 -34
- package/dist/chunk-KPO3RH5G.mjs +0 -27
- package/dist/chunk-KWG5LYNK.mjs +0 -100
- package/dist/chunk-NUTQDHLQ.mjs +0 -40
- package/dist/chunk-O64XUDAH.mjs +0 -35
- package/dist/chunk-OYRPWQUA.mjs +0 -257
- package/dist/chunk-PNZ4KGXL.mjs +0 -56
- package/dist/chunk-QZYX26HT.mjs +0 -24
- package/dist/chunk-RDGP2CKM.mjs +0 -195
- package/dist/chunk-VFG5VU6S.mjs +0 -12
- package/dist/chunk-X3IMFCZG.mjs +0 -23
- package/dist/chunk-ZHNGZMRD.mjs +0 -17
- package/dist/color.d.ts +0 -24
- package/dist/color.js +0 -106
- package/dist/color.mjs +0 -78
- package/dist/console/enableConsole.d.ts +0 -1
- package/dist/console/enableConsole.js +0 -42
- package/dist/console/enableConsole.mjs +0 -9
- package/dist/console/index.d.ts +0 -2
- package/dist/console/index.js +0 -61
- package/dist/console/index.mjs +0 -14
- package/dist/console/log.d.ts +0 -16
- package/dist/console/log.js +0 -75
- package/dist/console/log.mjs +0 -19
- package/dist/createDir-220e0081.d.ts +0 -13
- package/dist/device/browser.d.ts +0 -1
- package/dist/device/browser.js +0 -66
- package/dist/device/browser.mjs +0 -15
- package/dist/device/camera.d.ts +0 -1
- package/dist/device/camera.js +0 -190
- package/dist/device/camera.mjs +0 -8
- package/dist/device/index.d.ts +0 -1
- package/dist/device/index.js +0 -210
- package/dist/device/index.mjs +0 -15
- package/dist/device/os.d.ts +0 -12
- package/dist/device/os.js +0 -65
- package/dist/device/os.mjs +0 -33
- package/dist/enableConsole-ddc24282.d.ts +0 -11
- package/dist/file/createDir.d.ts +0 -1
- package/dist/file/createDir.js +0 -37
- package/dist/file/createDir.mjs +0 -7
- package/dist/file/fileMove.d.ts +0 -1
- package/dist/file/fileMove.js +0 -53
- package/dist/file/fileMove.mjs +0 -7
- package/dist/file/findFilesByExt.d.ts +0 -1
- package/dist/file/findFilesByExt.js +0 -69
- package/dist/file/findFilesByExt.mjs +0 -11
- package/dist/file/index.d.ts +0 -11
- package/dist/file/index.js +0 -106
- package/dist/file/index.mjs +0 -17
- package/dist/fileMove-3a09e429.d.ts +0 -13
- package/dist/findFilesByExt-753e91d7.d.ts +0 -24
- package/dist/images/index.d.ts +0 -2
- package/dist/images/index.js +0 -132
- package/dist/images/index.mjs +0 -15
- package/dist/images/loadImage.d.ts +0 -3
- package/dist/images/loadImage.js +0 -42
- package/dist/images/loadImage.mjs +0 -21
- package/dist/images/resize.d.ts +0 -3
- package/dist/images/resize.js +0 -64
- package/dist/images/resize.mjs +0 -9
- package/dist/images/upload.d.ts +0 -11
- package/dist/images/upload.js +0 -132
- package/dist/images/upload.mjs +0 -14
- package/dist/index-1f738e52.d.ts +0 -22
- package/dist/index-22309f0c.d.ts +0 -23
- package/dist/index-6ae3c86b.d.ts +0 -63
- package/dist/index-c8fffc86.d.ts +0 -90
- package/dist/index-d652ed2c.d.ts +0 -26
- package/dist/index.d.ts +0 -48
- package/dist/index.js +0 -1353
- package/dist/index.mjs +0 -87
- package/dist/json.d.ts +0 -9
- package/dist/json.js +0 -52
- package/dist/json.mjs +0 -29
- package/dist/math/diffDate.d.ts +0 -6
- package/dist/math/diffDate.js +0 -36
- package/dist/math/diffDate.mjs +0 -9
- package/dist/math/index.d.ts +0 -3
- package/dist/math/index.js +0 -160
- package/dist/math/index.mjs +0 -34
- package/dist/math/positiveNumber.d.ts +0 -3
- package/dist/math/positiveNumber.js +0 -56
- package/dist/math/positiveNumber.mjs +0 -10
- package/dist/name/en.d.ts +0 -6
- package/dist/name/en.js +0 -44
- package/dist/name/en.mjs +0 -9
- package/dist/name/index.d.ts +0 -3
- package/dist/name/index.js +0 -88
- package/dist/name/index.mjs +0 -20
- package/dist/name/vi.d.ts +0 -6
- package/dist/name/vi.js +0 -66
- package/dist/name/vi.mjs +0 -14
- package/dist/object-43aaaf92.d.ts +0 -80
- package/dist/object.d.ts +0 -1
- package/dist/object.js +0 -105
- package/dist/object.mjs +0 -21
- package/dist/permission/index.d.ts +0 -9
- package/dist/permission/index.js +0 -231
- package/dist/permission/index.mjs +0 -15
- package/dist/permission/requestCamera.d.ts +0 -1
- package/dist/permission/requestCamera.js +0 -54
- package/dist/permission/requestCamera.mjs +0 -9
- package/dist/permission/requestDeviceOrientationControl.d.ts +0 -1
- package/dist/permission/requestDeviceOrientationControl.js +0 -206
- package/dist/permission/requestDeviceOrientationControl.mjs +0 -10
- package/dist/requestCamera-32b7dfc7.d.ts +0 -14
- package/dist/requestDeviceOrientationControl-b6458660.d.ts +0 -11
- package/dist/response/index.d.ts +0 -50
- package/dist/response/index.js +0 -97
- package/dist/response/index.mjs +0 -16
- package/dist/string/formatNumber.d.ts +0 -7
- package/dist/string/formatNumber.js +0 -56
- package/dist/string/formatNumber.mjs +0 -10
- package/dist/string/generatePassword.d.ts +0 -10
- package/dist/string/generatePassword.js +0 -55
- package/dist/string/generatePassword.mjs +0 -10
- package/dist/string/generateUUID.d.ts +0 -3
- package/dist/string/generateUUID.js +0 -40
- package/dist/string/generateUUID.mjs +0 -9
- package/dist/string/index.d.ts +0 -6
- package/dist/string/index.js +0 -316
- package/dist/string/index.mjs +0 -31
- package/dist/string/makeDaySlug.d.ts +0 -32
- package/dist/string/makeDaySlug.js +0 -47
- package/dist/string/makeDaySlug.mjs +0 -9
- package/dist/string/random.d.ts +0 -15
- package/dist/string/random.js +0 -56
- package/dist/string/random.mjs +0 -19
- package/dist/string/trimNull.d.ts +0 -3
- package/dist/string/trimNull.js +0 -49
- package/dist/string/trimNull.mjs +0 -9
- package/dist/string/url.d.ts +0 -1
- package/dist/string/url.js +0 -126
- package/dist/string/url.mjs +0 -22
- package/dist/url-60657387.d.ts +0 -57
package/package.json
CHANGED
package/src/console/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const disableConsole = (
|
|
1
|
+
export const disableConsole = () => {
|
|
2
2
|
for (var key in console) {
|
|
3
3
|
(console as any)[key] = function () {};
|
|
4
4
|
}
|
|
@@ -6,7 +6,7 @@ export const disableConsole = (params: any) => {
|
|
|
6
6
|
|
|
7
7
|
export const removeConsole = disableConsole;
|
|
8
8
|
|
|
9
|
-
export const showCredit = (
|
|
9
|
+
export const showCredit = () => {
|
|
10
10
|
console.log("Developed by Digitop | https://www.wearetopgroup.com/?utm_src=console");
|
|
11
11
|
};
|
|
12
12
|
|
package/src/string/url.ts
CHANGED
|
@@ -102,10 +102,10 @@ export const getFileExtension = (url: string) => {
|
|
|
102
102
|
export const isImage = (url: string) => {
|
|
103
103
|
if (!url) return false;
|
|
104
104
|
|
|
105
|
-
const arr = ["png", "jpg", "jpeg", "jpe", "jif", "jfif", "gif", "svg"];
|
|
105
|
+
const arr = [".png", ".jpg", ".jpeg", ".jpe", ".jif", ".jfif", ".gif", ".svg"];
|
|
106
106
|
|
|
107
107
|
const index = arr.findIndex((item) => {
|
|
108
|
-
return
|
|
108
|
+
return url.indexOf(item) >= 0;
|
|
109
109
|
});
|
|
110
110
|
|
|
111
111
|
return index >= 0;
|
package/dist/Checker.d.ts
DELETED
package/dist/Checker.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/Checker.ts
|
|
21
|
-
var Checker_exports = {};
|
|
22
|
-
__export(Checker_exports, {
|
|
23
|
-
default: () => Checker_default,
|
|
24
|
-
isJSON: () => isJSON
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(Checker_exports);
|
|
27
|
-
var isJSON = (content) => {
|
|
28
|
-
if (typeof content == "object") {
|
|
29
|
-
try {
|
|
30
|
-
content = JSON.stringify(content);
|
|
31
|
-
} catch (err) {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
if (typeof content == "string") {
|
|
36
|
-
try {
|
|
37
|
-
content = JSON.parse(content);
|
|
38
|
-
} catch (err) {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
if (typeof content != "object") {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
return true;
|
|
46
|
-
};
|
|
47
|
-
var Checker = { isJSON };
|
|
48
|
-
var Checker_default = Checker;
|
|
49
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
-
0 && (module.exports = {
|
|
51
|
-
isJSON
|
|
52
|
-
});
|
package/dist/Checker.mjs
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import "./chunk-ZHNGZMRD.mjs";
|
|
2
|
-
|
|
3
|
-
// src/Checker.ts
|
|
4
|
-
var isJSON = (content) => {
|
|
5
|
-
if (typeof content == "object") {
|
|
6
|
-
try {
|
|
7
|
-
content = JSON.stringify(content);
|
|
8
|
-
} catch (err) {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
if (typeof content == "string") {
|
|
13
|
-
try {
|
|
14
|
-
content = JSON.parse(content);
|
|
15
|
-
} catch (err) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
if (typeof content != "object") {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
return true;
|
|
23
|
-
};
|
|
24
|
-
var Checker = { isJSON };
|
|
25
|
-
var Checker_default = Checker;
|
|
26
|
-
export {
|
|
27
|
-
Checker_default as default,
|
|
28
|
-
isJSON
|
|
29
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
declare class EventDispatcher {
|
|
2
|
-
constructor();
|
|
3
|
-
_listeners: any;
|
|
4
|
-
addEventListener(type: string, listener: any): void;
|
|
5
|
-
hasEventListener(type: string, listener: any): boolean;
|
|
6
|
-
removeEventListener(type: string, listener: any): void;
|
|
7
|
-
dispatchEvent(event: {
|
|
8
|
-
type: string;
|
|
9
|
-
target: any;
|
|
10
|
-
}): void;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export { EventDispatcher, EventDispatcher as default };
|
package/dist/EventDispatcher.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/EventDispatcher.ts
|
|
21
|
-
var EventDispatcher_exports = {};
|
|
22
|
-
__export(EventDispatcher_exports, {
|
|
23
|
-
EventDispatcher: () => EventDispatcher,
|
|
24
|
-
default: () => EventDispatcher_default
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(EventDispatcher_exports);
|
|
27
|
-
var EventDispatcher = class {
|
|
28
|
-
constructor() {
|
|
29
|
-
}
|
|
30
|
-
addEventListener(type, listener) {
|
|
31
|
-
if (this._listeners === void 0)
|
|
32
|
-
this._listeners = {};
|
|
33
|
-
const listeners = this._listeners;
|
|
34
|
-
if (listeners[type] === void 0) {
|
|
35
|
-
listeners[type] = [];
|
|
36
|
-
}
|
|
37
|
-
if (listeners[type].indexOf(listener) === -1) {
|
|
38
|
-
listeners[type].push(listener);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
hasEventListener(type, listener) {
|
|
42
|
-
if (this._listeners === void 0)
|
|
43
|
-
return false;
|
|
44
|
-
const listeners = this._listeners;
|
|
45
|
-
return listeners[type] !== void 0 && listeners[type].indexOf(listener) !== -1;
|
|
46
|
-
}
|
|
47
|
-
removeEventListener(type, listener) {
|
|
48
|
-
if (this._listeners === void 0)
|
|
49
|
-
return;
|
|
50
|
-
const listeners = this._listeners;
|
|
51
|
-
const listenerArray = listeners[type];
|
|
52
|
-
if (listenerArray !== void 0) {
|
|
53
|
-
const index = listenerArray.indexOf(listener);
|
|
54
|
-
if (index !== -1) {
|
|
55
|
-
listenerArray.splice(index, 1);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
dispatchEvent(event) {
|
|
60
|
-
if (this._listeners === void 0)
|
|
61
|
-
return;
|
|
62
|
-
const listeners = this._listeners;
|
|
63
|
-
const listenerArray = listeners[event.type];
|
|
64
|
-
if (listenerArray !== void 0) {
|
|
65
|
-
event.target = this;
|
|
66
|
-
const array = listenerArray.slice(0);
|
|
67
|
-
for (let i = 0, l = array.length; i < l; i++) {
|
|
68
|
-
array[i].call(this, event);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
var EventDispatcher_default = EventDispatcher;
|
|
74
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
75
|
-
0 && (module.exports = {
|
|
76
|
-
EventDispatcher
|
|
77
|
-
});
|
package/dist/EventDispatcher.mjs
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import "./chunk-ZHNGZMRD.mjs";
|
|
2
|
-
|
|
3
|
-
// src/EventDispatcher.ts
|
|
4
|
-
var EventDispatcher = class {
|
|
5
|
-
constructor() {
|
|
6
|
-
}
|
|
7
|
-
addEventListener(type, listener) {
|
|
8
|
-
if (this._listeners === void 0)
|
|
9
|
-
this._listeners = {};
|
|
10
|
-
const listeners = this._listeners;
|
|
11
|
-
if (listeners[type] === void 0) {
|
|
12
|
-
listeners[type] = [];
|
|
13
|
-
}
|
|
14
|
-
if (listeners[type].indexOf(listener) === -1) {
|
|
15
|
-
listeners[type].push(listener);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
hasEventListener(type, listener) {
|
|
19
|
-
if (this._listeners === void 0)
|
|
20
|
-
return false;
|
|
21
|
-
const listeners = this._listeners;
|
|
22
|
-
return listeners[type] !== void 0 && listeners[type].indexOf(listener) !== -1;
|
|
23
|
-
}
|
|
24
|
-
removeEventListener(type, listener) {
|
|
25
|
-
if (this._listeners === void 0)
|
|
26
|
-
return;
|
|
27
|
-
const listeners = this._listeners;
|
|
28
|
-
const listenerArray = listeners[type];
|
|
29
|
-
if (listenerArray !== void 0) {
|
|
30
|
-
const index = listenerArray.indexOf(listener);
|
|
31
|
-
if (index !== -1) {
|
|
32
|
-
listenerArray.splice(index, 1);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
dispatchEvent(event) {
|
|
37
|
-
if (this._listeners === void 0)
|
|
38
|
-
return;
|
|
39
|
-
const listeners = this._listeners;
|
|
40
|
-
const listenerArray = listeners[event.type];
|
|
41
|
-
if (listenerArray !== void 0) {
|
|
42
|
-
event.target = this;
|
|
43
|
-
const array = listenerArray.slice(0);
|
|
44
|
-
for (let i = 0, l = array.length; i < l; i++) {
|
|
45
|
-
array[i].call(this, event);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
var EventDispatcher_default = EventDispatcher;
|
|
51
|
-
export {
|
|
52
|
-
EventDispatcher,
|
|
53
|
-
EventDispatcher_default as default
|
|
54
|
-
};
|
package/dist/FileUpload.d.ts
DELETED
package/dist/FileUpload.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/FileUpload.ts
|
|
21
|
-
var FileUpload_exports = {};
|
|
22
|
-
__export(FileUpload_exports, {
|
|
23
|
-
FileUpload: () => FileUpload,
|
|
24
|
-
default: () => FileUpload_default
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(FileUpload_exports);
|
|
27
|
-
var logFile = "[FileUpload.js] ";
|
|
28
|
-
var FileUpload = {
|
|
29
|
-
uploadBlob(props) {
|
|
30
|
-
const { blob, url, params, onComplete, onError } = props;
|
|
31
|
-
var formData = new FormData();
|
|
32
|
-
formData.append("upload", blob, "img_" + +new Date() + ".jpg");
|
|
33
|
-
if (params) {
|
|
34
|
-
Object.keys(params).forEach((key) => {
|
|
35
|
-
var val = params[key];
|
|
36
|
-
formData.append(key, val);
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
var request = new XMLHttpRequest();
|
|
40
|
-
request.open("POST", url);
|
|
41
|
-
request.send(formData);
|
|
42
|
-
request.onreadystatechange = function() {
|
|
43
|
-
if (this.readyState == 4) {
|
|
44
|
-
if (this.status == 200) {
|
|
45
|
-
var response = {};
|
|
46
|
-
try {
|
|
47
|
-
response = JSON.parse(request.response) || "";
|
|
48
|
-
} catch (error) {
|
|
49
|
-
console.error(logFile, "Can't part JSON of the response");
|
|
50
|
-
}
|
|
51
|
-
var statusOfSafety = response.status || 0;
|
|
52
|
-
if (statusOfSafety == 1) {
|
|
53
|
-
console.log(logFile, "request: ", request);
|
|
54
|
-
var data = response.data || {};
|
|
55
|
-
console.log(logFile, data);
|
|
56
|
-
var _url = data["url"];
|
|
57
|
-
if (onComplete)
|
|
58
|
-
onComplete(_url);
|
|
59
|
-
} else {
|
|
60
|
-
var errMsg = "\u1EA2nh c\xF3 n\u1ED9i dung kh\xF4ng ph\xF9 h\u1EE3p.";
|
|
61
|
-
console.error(logFile, errMsg);
|
|
62
|
-
if (onError)
|
|
63
|
-
onError(errMsg);
|
|
64
|
-
}
|
|
65
|
-
} else {
|
|
66
|
-
var errMsg = "Upload \u1EA3nh kh\xF4ng th\xE0nh c\xF4ng!";
|
|
67
|
-
console.error(logFile, errMsg);
|
|
68
|
-
if (onError)
|
|
69
|
-
onError(errMsg);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
request.onerror = function(res) {
|
|
74
|
-
var errMsg = "Upload \u1EA3nh kh\xF4ng th\xE0nh c\xF4ng!";
|
|
75
|
-
console.error(logFile, errMsg, "=>", res);
|
|
76
|
-
if (onError)
|
|
77
|
-
onError(errMsg);
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
var FileUpload_default = FileUpload;
|
|
82
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
83
|
-
0 && (module.exports = {
|
|
84
|
-
FileUpload
|
|
85
|
-
});
|
package/dist/FileUpload.mjs
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import "./chunk-ZHNGZMRD.mjs";
|
|
2
|
-
|
|
3
|
-
// src/FileUpload.ts
|
|
4
|
-
var logFile = "[FileUpload.js] ";
|
|
5
|
-
var FileUpload = {
|
|
6
|
-
uploadBlob(props) {
|
|
7
|
-
const { blob, url, params, onComplete, onError } = props;
|
|
8
|
-
var formData = new FormData();
|
|
9
|
-
formData.append("upload", blob, "img_" + +new Date() + ".jpg");
|
|
10
|
-
if (params) {
|
|
11
|
-
Object.keys(params).forEach((key) => {
|
|
12
|
-
var val = params[key];
|
|
13
|
-
formData.append(key, val);
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
var request = new XMLHttpRequest();
|
|
17
|
-
request.open("POST", url);
|
|
18
|
-
request.send(formData);
|
|
19
|
-
request.onreadystatechange = function() {
|
|
20
|
-
if (this.readyState == 4) {
|
|
21
|
-
if (this.status == 200) {
|
|
22
|
-
var response = {};
|
|
23
|
-
try {
|
|
24
|
-
response = JSON.parse(request.response) || "";
|
|
25
|
-
} catch (error) {
|
|
26
|
-
console.error(logFile, "Can't part JSON of the response");
|
|
27
|
-
}
|
|
28
|
-
var statusOfSafety = response.status || 0;
|
|
29
|
-
if (statusOfSafety == 1) {
|
|
30
|
-
console.log(logFile, "request: ", request);
|
|
31
|
-
var data = response.data || {};
|
|
32
|
-
console.log(logFile, data);
|
|
33
|
-
var _url = data["url"];
|
|
34
|
-
if (onComplete)
|
|
35
|
-
onComplete(_url);
|
|
36
|
-
} else {
|
|
37
|
-
var errMsg = "\u1EA2nh c\xF3 n\u1ED9i dung kh\xF4ng ph\xF9 h\u1EE3p.";
|
|
38
|
-
console.error(logFile, errMsg);
|
|
39
|
-
if (onError)
|
|
40
|
-
onError(errMsg);
|
|
41
|
-
}
|
|
42
|
-
} else {
|
|
43
|
-
var errMsg = "Upload \u1EA3nh kh\xF4ng th\xE0nh c\xF4ng!";
|
|
44
|
-
console.error(logFile, errMsg);
|
|
45
|
-
if (onError)
|
|
46
|
-
onError(errMsg);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
request.onerror = function(res) {
|
|
51
|
-
var errMsg = "Upload \u1EA3nh kh\xF4ng th\xE0nh c\xF4ng!";
|
|
52
|
-
console.error(logFile, errMsg, "=>", res);
|
|
53
|
-
if (onError)
|
|
54
|
-
onError(errMsg);
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
var FileUpload_default = FileUpload;
|
|
59
|
-
export {
|
|
60
|
-
FileUpload,
|
|
61
|
-
FileUpload_default as default
|
|
62
|
-
};
|