diginext-utils 2.0.5 → 2.0.8

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 (178) hide show
  1. package/dist/Checker.d.ts +0 -1
  2. package/dist/Checker.js +27 -45
  3. package/dist/Checker.js.map +1 -0
  4. package/dist/EventDispatcher.d.ts +1 -3
  5. package/dist/EventDispatcher.js +47 -70
  6. package/dist/EventDispatcher.js.map +1 -0
  7. package/dist/FileUpload.d.ts +0 -1
  8. package/dist/FileUpload.js +61 -79
  9. package/dist/FileUpload.js.map +1 -0
  10. package/dist/Slug.d.ts +0 -1
  11. package/dist/Slug.js +329 -347
  12. package/dist/Slug.js.map +1 -0
  13. package/dist/Timer.d.ts +1 -3
  14. package/dist/Timer.js +8 -32
  15. package/dist/Timer.js.map +1 -0
  16. package/dist/Validation.d.ts +1 -3
  17. package/dist/Validation.js +38 -55
  18. package/dist/Validation.js.map +1 -0
  19. package/dist/array.d.ts +19 -21
  20. package/dist/array.js +264 -242
  21. package/dist/array.js.map +1 -0
  22. package/dist/color.d.ts +7 -9
  23. package/dist/color.js +78 -87
  24. package/dist/color.js.map +1 -0
  25. package/dist/console/enableConsole.d.ts +1 -3
  26. package/dist/console/enableConsole.js +10 -36
  27. package/dist/console/enableConsole.js.map +1 -0
  28. package/dist/console/index.d.ts +3 -5
  29. package/dist/console/index.js +15 -42
  30. package/dist/console/index.js.map +1 -0
  31. package/dist/device/browser.d.ts +5 -7
  32. package/dist/device/browser.js +33 -60
  33. package/dist/device/browser.js.map +1 -0
  34. package/dist/device/camera.d.ts +7 -16
  35. package/dist/device/camera.js +167 -187
  36. package/dist/device/camera.js.map +1 -0
  37. package/dist/device.d.ts +4 -6
  38. package/dist/device.js +210 -190
  39. package/dist/device.js.map +1 -0
  40. package/dist/file/createDir.d.ts +1 -2
  41. package/dist/file/createDir.js +14 -34
  42. package/dist/file/createDir.js.map +1 -0
  43. package/dist/file/fileMove.d.ts +1 -3
  44. package/dist/file/fileMove.js +30 -49
  45. package/dist/file/fileMove.js.map +1 -0
  46. package/dist/file/findFilesByExt.d.ts +0 -1
  47. package/dist/file/findFilesByExt.js +40 -58
  48. package/dist/file/findFilesByExt.js.map +1 -0
  49. package/dist/index.d.ts +16 -12
  50. package/dist/index.js +33 -906
  51. package/dist/index.js.map +1 -0
  52. package/dist/math/diffDate.d.ts +1 -3
  53. package/dist/math/diffDate.js +11 -31
  54. package/dist/math/diffDate.js.map +1 -0
  55. package/dist/math/index.d.ts +8 -10
  56. package/dist/math/index.js +87 -71
  57. package/dist/math/index.js.map +1 -0
  58. package/dist/math/positiveNumber.d.ts +1 -3
  59. package/dist/math/positiveNumber.js +14 -51
  60. package/dist/math/positiveNumber.js.map +1 -0
  61. package/dist/name/en.d.ts +1 -3
  62. package/dist/name/en.js +18 -34
  63. package/dist/name/en.js.map +1 -0
  64. package/dist/name/vi.d.ts +1 -3
  65. package/dist/name/vi.js +24 -60
  66. package/dist/name/vi.js.map +1 -0
  67. package/dist/object.d.ts +9 -11
  68. package/dist/object.js +57 -82
  69. package/dist/object.js.map +1 -0
  70. package/dist/permission/requestCamera.d.ts +2 -3
  71. package/dist/permission/requestCamera.js +38 -47
  72. package/dist/permission/requestCamera.js.map +1 -0
  73. package/dist/permission/requestDeviceOrientationControl.d.ts +0 -1
  74. package/dist/permission/requestDeviceOrientationControl.js +36 -198
  75. package/dist/permission/requestDeviceOrientationControl.js.map +1 -0
  76. package/dist/string/formatNumber.d.ts +1 -3
  77. package/dist/string/formatNumber.js +12 -51
  78. package/dist/string/formatNumber.js.map +1 -0
  79. package/dist/string/generatePassword.d.ts +1 -3
  80. package/dist/string/generatePassword.js +21 -50
  81. package/dist/string/generatePassword.js.map +1 -0
  82. package/dist/string/generateUUID.d.ts +1 -3
  83. package/dist/string/generateUUID.js +34 -35
  84. package/dist/string/generateUUID.js.map +1 -0
  85. package/dist/string/index.d.ts +8 -10
  86. package/dist/string/index.js +119 -127
  87. package/dist/string/index.js.map +1 -0
  88. package/dist/string/random.d.ts +6 -8
  89. package/dist/string/random.js +21 -50
  90. package/dist/string/random.js.map +1 -0
  91. package/dist/string/trimNull.d.ts +1 -3
  92. package/dist/string/trimNull.js +15 -41
  93. package/dist/string/trimNull.js.map +1 -0
  94. package/dist/string/url.d.ts +7 -14
  95. package/dist/string/url.js +93 -108
  96. package/dist/string/url.js.map +1 -0
  97. package/package.json +6 -9
  98. package/src/Checker.ts +27 -0
  99. package/src/EventDispatcher.ts +60 -0
  100. package/src/FileUpload.ts +65 -0
  101. package/src/Slug.ts +364 -0
  102. package/src/Timer.ts +5 -0
  103. package/src/Validation.ts +35 -0
  104. package/src/array.ts +261 -0
  105. package/src/color.ts +89 -0
  106. package/src/console/enableConsole.ts +6 -0
  107. package/src/console/index.ts +11 -0
  108. package/src/device/browser.ts +29 -0
  109. package/src/device/camera.ts +209 -0
  110. package/src/device.ts +223 -0
  111. package/src/file/createDir.ts +14 -0
  112. package/src/file/fileMove.ts +32 -0
  113. package/src/file/findFilesByExt.ts +39 -0
  114. package/src/index.ts +17 -0
  115. package/src/math/diffDate.ts +8 -0
  116. package/src/math/index.ts +88 -0
  117. package/src/math/positiveNumber.ts +10 -0
  118. package/src/name/en.ts +24 -0
  119. package/src/name/vi.ts +21 -0
  120. package/src/object.ts +49 -0
  121. package/src/permission/requestCamera.ts +43 -0
  122. package/src/permission/requestDeviceOrientationControl.ts +33 -0
  123. package/src/string/formatNumber.ts +10 -0
  124. package/src/string/generatePassword.ts +16 -0
  125. package/src/string/generateUUID.ts +35 -0
  126. package/src/string/index.ts +145 -0
  127. package/src/string/random.ts +20 -0
  128. package/src/string/trimNull.ts +11 -0
  129. package/src/string/url.ts +109 -0
  130. package/dist/.DS_Store +0 -0
  131. package/dist/Checker.mjs +0 -26
  132. package/dist/EventDispatcher.mjs +0 -52
  133. package/dist/FileUpload.mjs +0 -60
  134. package/dist/Slug.mjs +0 -328
  135. package/dist/Timer.mjs +0 -7
  136. package/dist/Validation.mjs +0 -34
  137. package/dist/array.mjs +0 -44
  138. package/dist/chunk-2R5DRG2S.mjs +0 -28
  139. package/dist/chunk-3NMJTC44.mjs +0 -146
  140. package/dist/chunk-5AL36RZR.mjs +0 -54
  141. package/dist/chunk-7UXN7I4K.mjs +0 -96
  142. package/dist/chunk-A4YWYLCH.mjs +0 -23
  143. package/dist/chunk-AHFJBIQJ.mjs +0 -10
  144. package/dist/chunk-AKU6F3WT.mjs +0 -11
  145. package/dist/chunk-ALNAD4H7.mjs +0 -10
  146. package/dist/chunk-FOWYH6LL.mjs +0 -38
  147. package/dist/chunk-FTE6FZSH.mjs +0 -24
  148. package/dist/chunk-LXQIKFED.mjs +0 -17
  149. package/dist/chunk-NLQXFCPR.mjs +0 -30
  150. package/dist/chunk-QXFH3X2K.mjs +0 -49
  151. package/dist/chunk-R2BH5I6O.mjs +0 -9
  152. package/dist/chunk-S2U7F2JJ.mjs +0 -207
  153. package/dist/chunk-UKRVCU5M.mjs +0 -171
  154. package/dist/color.mjs +0 -68
  155. package/dist/console/enableConsole.mjs +0 -11
  156. package/dist/console/index.mjs +0 -18
  157. package/dist/device/browser.mjs +0 -39
  158. package/dist/device/camera.mjs +0 -146
  159. package/dist/device.mjs +0 -13
  160. package/dist/file/createDir.mjs +0 -16
  161. package/dist/file/fileMove.mjs +0 -32
  162. package/dist/file/findFilesByExt.mjs +0 -42
  163. package/dist/index.mjs +0 -143
  164. package/dist/math/diffDate.mjs +0 -11
  165. package/dist/math/index.mjs +0 -21
  166. package/dist/math/positiveNumber.mjs +0 -19
  167. package/dist/name/en.mjs +0 -18
  168. package/dist/name/vi.mjs +0 -34
  169. package/dist/object.mjs +0 -17
  170. package/dist/permission/requestCamera.mjs +0 -7
  171. package/dist/permission/requestDeviceOrientationControl.mjs +0 -176
  172. package/dist/string/formatNumber.mjs +0 -13
  173. package/dist/string/generatePassword.mjs +0 -22
  174. package/dist/string/generateUUID.mjs +0 -15
  175. package/dist/string/index.mjs +0 -96
  176. package/dist/string/random.mjs +0 -17
  177. package/dist/string/trimNull.mjs +0 -16
  178. package/dist/string/url.mjs +0 -79
package/dist/Checker.d.ts CHANGED
@@ -2,5 +2,4 @@
2
2
  * Check if the object or string is in JSON format
3
3
  */
4
4
  declare const isJSON: (content: object | string) => boolean;
5
-
6
5
  export { isJSON };
package/dist/Checker.js CHANGED
@@ -1,48 +1,30 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/Checker.ts
20
- var Checker_exports = {};
21
- __export(Checker_exports, {
22
- isJSON: () => isJSON
23
- });
24
- module.exports = __toCommonJS(Checker_exports);
25
- var isJSON = (content) => {
26
- if (typeof content == "object") {
27
- try {
28
- content = JSON.stringify(content);
29
- } catch (err) {
30
- return false;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isJSON = void 0;
4
+ /**
5
+ * Check if the object or string is in JSON format
6
+ */
7
+ const isJSON = (content) => {
8
+ if (typeof content == "object") {
9
+ try {
10
+ content = JSON.stringify(content);
11
+ }
12
+ catch (err) {
13
+ return false;
14
+ }
15
+ }
16
+ if (typeof content == "string") {
17
+ try {
18
+ content = JSON.parse(content);
19
+ }
20
+ catch (err) {
21
+ return false;
22
+ }
31
23
  }
32
- }
33
- if (typeof content == "string") {
34
- try {
35
- content = JSON.parse(content);
36
- } catch (err) {
37
- return false;
24
+ if (typeof content != "object") {
25
+ return false;
38
26
  }
39
- }
40
- if (typeof content != "object") {
41
- return false;
42
- }
43
- return true;
27
+ return true;
44
28
  };
45
- // Annotate the CommonJS export names for ESM import in node:
46
- 0 && (module.exports = {
47
- isJSON
48
- });
29
+ exports.isJSON = isJSON;
30
+ //# sourceMappingURL=Checker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Checker.js","sourceRoot":"","sources":["../src/Checker.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,MAAM,MAAM,GAAG,CAAC,OAAwB,EAAE,EAAE;IAC3C,IAAI,OAAO,OAAO,IAAI,QAAQ,EAAE;QAC/B,IAAI;YACH,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;SAClC;QAAC,OAAO,GAAG,EAAE;YACb,OAAO,KAAK,CAAC;SACb;KACD;IAED,IAAI,OAAO,OAAO,IAAI,QAAQ,EAAE;QAC/B,IAAI;YACH,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;SAC9B;QAAC,OAAO,GAAG,EAAE;YACb,OAAO,KAAK,CAAC;SACb;KACD;IAED,IAAI,OAAO,OAAO,IAAI,QAAQ,EAAE;QAC/B,OAAO,KAAK,CAAC;KACb;IACD,OAAO,IAAI,CAAC;AACb,CAAC,CAAC;AAEO,wBAAM"}
@@ -1,4 +1,4 @@
1
- declare class EventDispatcher {
1
+ export declare class EventDispatcher {
2
2
  constructor();
3
3
  _listeners: any;
4
4
  addEventListener(type: string, listener: any): void;
@@ -9,5 +9,3 @@ declare class EventDispatcher {
9
9
  target: any;
10
10
  }): void;
11
11
  }
12
-
13
- export { EventDispatcher };
@@ -1,74 +1,51 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/EventDispatcher.ts
20
- var EventDispatcher_exports = {};
21
- __export(EventDispatcher_exports, {
22
- EventDispatcher: () => EventDispatcher
23
- });
24
- module.exports = __toCommonJS(EventDispatcher_exports);
25
- var EventDispatcher = class {
26
- constructor() {
27
- }
28
- addEventListener(type, listener) {
29
- if (this._listeners === void 0)
30
- this._listeners = {};
31
- const listeners = this._listeners;
32
- if (listeners[type] === void 0) {
33
- listeners[type] = [];
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EventDispatcher = void 0;
4
+ class EventDispatcher {
5
+ constructor() { }
6
+ addEventListener(type, listener) {
7
+ if (this._listeners === undefined)
8
+ this._listeners = {};
9
+ const listeners = this._listeners;
10
+ if (listeners[type] === undefined) {
11
+ listeners[type] = [];
12
+ }
13
+ if (listeners[type].indexOf(listener) === -1) {
14
+ listeners[type].push(listener);
15
+ }
34
16
  }
35
- if (listeners[type].indexOf(listener) === -1) {
36
- listeners[type].push(listener);
17
+ hasEventListener(type, listener) {
18
+ if (this._listeners === undefined)
19
+ return false;
20
+ const listeners = this._listeners;
21
+ return listeners[type] !== undefined && listeners[type].indexOf(listener) !== -1;
37
22
  }
38
- }
39
- hasEventListener(type, listener) {
40
- if (this._listeners === void 0)
41
- return false;
42
- const listeners = this._listeners;
43
- return listeners[type] !== void 0 && listeners[type].indexOf(listener) !== -1;
44
- }
45
- removeEventListener(type, listener) {
46
- if (this._listeners === void 0)
47
- return;
48
- const listeners = this._listeners;
49
- const listenerArray = listeners[type];
50
- if (listenerArray !== void 0) {
51
- const index = listenerArray.indexOf(listener);
52
- if (index !== -1) {
53
- listenerArray.splice(index, 1);
54
- }
23
+ removeEventListener(type, listener) {
24
+ if (this._listeners === undefined)
25
+ return;
26
+ const listeners = this._listeners;
27
+ const listenerArray = listeners[type];
28
+ if (listenerArray !== undefined) {
29
+ const index = listenerArray.indexOf(listener);
30
+ if (index !== -1) {
31
+ listenerArray.splice(index, 1);
32
+ }
33
+ }
55
34
  }
56
- }
57
- dispatchEvent(event) {
58
- if (this._listeners === void 0)
59
- return;
60
- const listeners = this._listeners;
61
- const listenerArray = listeners[event.type];
62
- if (listenerArray !== void 0) {
63
- event.target = this;
64
- const array = listenerArray.slice(0);
65
- for (let i = 0, l = array.length; i < l; i++) {
66
- array[i].call(this, event);
67
- }
35
+ dispatchEvent(event) {
36
+ if (this._listeners === undefined)
37
+ return;
38
+ const listeners = this._listeners;
39
+ const listenerArray = listeners[event.type];
40
+ if (listenerArray !== undefined) {
41
+ event.target = this;
42
+ // Make a copy, in case listeners are removed while iterating.
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
+ }
68
48
  }
69
- }
70
- };
71
- // Annotate the CommonJS export names for ESM import in node:
72
- 0 && (module.exports = {
73
- EventDispatcher
74
- });
49
+ }
50
+ exports.EventDispatcher = EventDispatcher;
51
+ //# sourceMappingURL=EventDispatcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EventDispatcher.js","sourceRoot":"","sources":["../src/EventDispatcher.ts"],"names":[],"mappings":";;;AAAA,MAAa,eAAe;IAC3B,gBAAe,CAAC;IAIhB,gBAAgB,CAAC,IAAY,EAAE,QAAa;QAC3C,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS;YAAE,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QAExD,MAAM,SAAS,GAAG,IAA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C,IAAI,aAAa,KAAK,SAAS,EAAE;YAChC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC;YAEpB,8DAA8D;YAC9D,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAErC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;gBAC7C,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;aAC3B;SACD;IACF,CAAC;CACD;AA3DD,0CA2DC"}
@@ -8,5 +8,4 @@ declare type UploadParams = {
8
8
  declare const FileUpload: {
9
9
  uploadBlob(props: UploadParams): void;
10
10
  };
11
-
12
11
  export { FileUpload };
@@ -1,82 +1,64 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/FileUpload.ts
20
- var FileUpload_exports = {};
21
- __export(FileUpload_exports, {
22
- FileUpload: () => FileUpload
23
- });
24
- module.exports = __toCommonJS(FileUpload_exports);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FileUpload = void 0;
25
4
  var logFile = "[FileUpload.js] ";
26
- var FileUpload = {
27
- uploadBlob(props) {
28
- const { blob, url, params, onComplete, onError } = props;
29
- var formData = new FormData();
30
- formData.append("upload", blob, "img_" + +new Date() + ".jpg");
31
- if (params) {
32
- Object.keys(params).forEach((key) => {
33
- var val = params[key];
34
- formData.append(key, val);
35
- });
36
- }
37
- var request = new XMLHttpRequest();
38
- request.open("POST", url);
39
- request.send(formData);
40
- request.onreadystatechange = function() {
41
- if (this.readyState == 4) {
42
- if (this.status == 200) {
43
- var response = {};
44
- try {
45
- response = JSON.parse(request.response) || "";
46
- } catch (error) {
47
- console.error(logFile, "Can't part JSON of the response");
48
- }
49
- var statusOfSafety = response.status || 0;
50
- if (statusOfSafety == 1) {
51
- console.log(logFile, "request: ", request);
52
- var data = response.data || {};
53
- console.log(logFile, data);
54
- var _url = data["url"];
55
- if (onComplete)
56
- onComplete(_url);
57
- } else {
58
- var errMsg = "\u1EA2nh c\xF3 n\u1ED9i dung kh\xF4ng ph\xF9 h\u1EE3p.";
59
- console.error(logFile, errMsg);
60
- if (onError)
61
- onError(errMsg);
62
- }
63
- } else {
64
- var errMsg = "Upload \u1EA3nh kh\xF4ng th\xE0nh c\xF4ng!";
65
- console.error(logFile, errMsg);
66
- if (onError)
67
- onError(errMsg);
5
+ const 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
+ });
68
15
  }
69
- }
70
- };
71
- request.onerror = function(res) {
72
- var errMsg = "Upload \u1EA3nh kh\xF4ng th\xE0nh c\xF4ng!";
73
- console.error(logFile, errMsg, "=>", res);
74
- if (onError)
75
- onError(errMsg);
76
- };
77
- }
16
+ var request = new XMLHttpRequest();
17
+ request.open("POST", url);
18
+ request.send(formData);
19
+ request.onreadystatechange = function () {
20
+ if (this.readyState == 4) {
21
+ // Typical action to be performed when the document is ready:
22
+ if (this.status == 200) {
23
+ // var response = JSON.parse(request.response) || "";
24
+ var response = {};
25
+ try {
26
+ response = JSON.parse(request.response) || "";
27
+ }
28
+ catch (error) {
29
+ console.error(logFile, "Can't part JSON of the response");
30
+ }
31
+ var statusOfSafety = response.status || 0;
32
+ if (statusOfSafety == 1) {
33
+ console.log(logFile, "request: ", request);
34
+ var data = response.data || {};
35
+ console.log(logFile, data);
36
+ var _url = data["url"];
37
+ if (onComplete)
38
+ onComplete(_url);
39
+ }
40
+ else {
41
+ var errMsg = "Ảnh có nội dung không phù hợp.";
42
+ console.error(logFile, errMsg);
43
+ if (onError)
44
+ onError(errMsg);
45
+ }
46
+ }
47
+ else {
48
+ var errMsg = "Upload ảnh không thành công!";
49
+ console.error(logFile, errMsg);
50
+ if (onError)
51
+ onError(errMsg);
52
+ }
53
+ }
54
+ };
55
+ request.onerror = function (res) {
56
+ var errMsg = "Upload ảnh không thành công!";
57
+ console.error(logFile, errMsg, "=>", res);
58
+ if (onError)
59
+ onError(errMsg);
60
+ };
61
+ },
78
62
  };
79
- // Annotate the CommonJS export names for ESM import in node:
80
- 0 && (module.exports = {
81
- FileUpload
82
- });
63
+ exports.FileUpload = FileUpload;
64
+ //# sourceMappingURL=FileUpload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileUpload.js","sourceRoot":"","sources":["../src/FileUpload.ts"],"names":[],"mappings":";;;AAAA,IAAI,OAAO,GAAG,kBAAkB,CAAC;AAIjC,MAAM,UAAU,GAAG;IAClB,UAAU,CAAC,KAAmB;QAC7B,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;QAEzD,IAAI,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC9B,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,IAAI,IAAI,EAAE,GAAG,MAAM,CAAC,CAAC;QAE/D,IA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