diginext-utils 2.0.4 → 2.0.6

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 (97) hide show
  1. package/dist/console/enableConsole.js +12 -34
  2. package/dist/console/index.js +7 -30
  3. package/dist/device/browser.js +9 -34
  4. package/dist/device/camera.js +4 -33
  5. package/dist/{chunk-QXFH3X2K.mjs → esm/chunk-5HIQS7HE.js} +1 -10
  6. package/dist/{chunk-AKU6F3WT.mjs → esm/chunk-EZUCZHGV.js} +1 -3
  7. package/dist/{chunk-A4YWYLCH.mjs → esm/chunk-HDM7KM5F.js} +1 -4
  8. package/dist/{chunk-FTE6FZSH.mjs → esm/chunk-LNLCKCWC.js} +1 -8
  9. package/dist/{chunk-2R5DRG2S.mjs → esm/chunk-X3K4KC75.js} +1 -3
  10. package/dist/esm/console/enableConsole.js +9 -0
  11. package/dist/{chunk-LXQIKFED.mjs → esm/console/index.js} +3 -5
  12. package/dist/{chunk-FOWYH6LL.mjs → esm/device/browser.js} +3 -7
  13. package/dist/{chunk-3NMJTC44.mjs → esm/device/camera.js} +3 -12
  14. package/dist/{file/createDir.mjs → esm/file/createDir.js} +3 -6
  15. package/dist/{file/fileMove.mjs → esm/file/fileMove.js} +3 -6
  16. package/dist/{file/findFilesByExt.mjs → esm/file/findFilesByExt.js} +3 -6
  17. package/dist/{math/diffDate.mjs → esm/math/diffDate.js} +3 -4
  18. package/dist/esm/math/index.js +2 -0
  19. package/dist/{math/positiveNumber.mjs → esm/math/positiveNumber.js} +4 -7
  20. package/dist/{name/en.mjs → esm/name/en.js} +3 -4
  21. package/dist/{name/vi.mjs → esm/name/vi.js} +4 -7
  22. package/dist/esm/permission/requestCamera.js +2 -0
  23. package/dist/{permission/requestDeviceOrientationControl.mjs → esm/permission/requestDeviceOrientationControl.js} +3 -4
  24. package/dist/{string/formatNumber.mjs → esm/string/formatNumber.js} +4 -7
  25. package/dist/{string/generatePassword.mjs → esm/string/generatePassword.js} +4 -10
  26. package/dist/{string/generateUUID.mjs → esm/string/generateUUID.js} +3 -4
  27. package/dist/{chunk-7UXN7I4K.mjs → esm/string/index.js} +3 -13
  28. package/dist/esm/string/random.js +2 -0
  29. package/dist/{string/trimNull.mjs → esm/string/trimNull.js} +4 -6
  30. package/dist/{string/url.mjs → esm/string/url.js} +4 -14
  31. package/dist/file/createDir.js +14 -27
  32. package/dist/file/fileMove.js +14 -27
  33. package/dist/file/findFilesByExt.js +15 -28
  34. package/dist/math/diffDate.js +5 -26
  35. package/dist/math/index.js +12 -40
  36. package/dist/math/positiveNumber.js +4 -27
  37. package/dist/name/en.js +5 -26
  38. package/dist/name/vi.js +4 -29
  39. package/dist/permission/requestCamera.js +5 -26
  40. package/dist/permission/requestDeviceOrientationControl.js +4 -27
  41. package/dist/string/formatNumber.js +4 -27
  42. package/dist/string/generatePassword.js +4 -27
  43. package/dist/string/generateUUID.js +5 -26
  44. package/dist/string/index.js +11 -41
  45. package/dist/string/random.js +10 -36
  46. package/dist/string/trimNull.js +12 -34
  47. package/dist/string/url.js +10 -40
  48. package/package.json +2 -2
  49. package/dist/.DS_Store +0 -0
  50. package/dist/Checker.d.ts +0 -6
  51. package/dist/Checker.js +0 -48
  52. package/dist/Checker.mjs +0 -26
  53. package/dist/EventDispatcher.d.ts +0 -13
  54. package/dist/EventDispatcher.js +0 -74
  55. package/dist/EventDispatcher.mjs +0 -52
  56. package/dist/FileUpload.d.ts +0 -12
  57. package/dist/FileUpload.js +0 -82
  58. package/dist/FileUpload.mjs +0 -60
  59. package/dist/Slug.d.ts +0 -5
  60. package/dist/Slug.js +0 -350
  61. package/dist/Slug.mjs +0 -328
  62. package/dist/Timer.d.ts +0 -5
  63. package/dist/Timer.js +0 -33
  64. package/dist/Timer.mjs +0 -7
  65. package/dist/Validation.d.ts +0 -6
  66. package/dist/Validation.js +0 -56
  67. package/dist/Validation.mjs +0 -34
  68. package/dist/array.d.ts +0 -93
  69. package/dist/array.js +0 -253
  70. package/dist/array.mjs +0 -44
  71. package/dist/chunk-5AL36RZR.mjs +0 -54
  72. package/dist/chunk-AHFJBIQJ.mjs +0 -10
  73. package/dist/chunk-ALNAD4H7.mjs +0 -10
  74. package/dist/chunk-NLQXFCPR.mjs +0 -30
  75. package/dist/chunk-R2BH5I6O.mjs +0 -9
  76. package/dist/chunk-S2U7F2JJ.mjs +0 -207
  77. package/dist/chunk-UKRVCU5M.mjs +0 -171
  78. package/dist/color.d.ts +0 -12
  79. package/dist/color.js +0 -95
  80. package/dist/color.mjs +0 -68
  81. package/dist/console/enableConsole.mjs +0 -11
  82. package/dist/console/index.mjs +0 -18
  83. package/dist/device/browser.mjs +0 -39
  84. package/dist/device/camera.mjs +0 -146
  85. package/dist/device.d.ts +0 -6
  86. package/dist/device.js +0 -197
  87. package/dist/device.mjs +0 -13
  88. package/dist/index.d.ts +0 -12
  89. package/dist/index.js +0 -906
  90. package/dist/index.mjs +0 -143
  91. package/dist/math/index.mjs +0 -21
  92. package/dist/object.d.ts +0 -25
  93. package/dist/object.js +0 -82
  94. package/dist/object.mjs +0 -17
  95. package/dist/permission/requestCamera.mjs +0 -7
  96. package/dist/string/index.mjs +0 -96
  97. package/dist/string/random.mjs +0 -17
@@ -1,34 +1,6 @@
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);
1
+ 'use strict';
18
2
 
19
- // src/string/index.ts
20
- var string_exports = {};
21
- __export(string_exports, {
22
- capitalize: () => capitalize,
23
- capitalizeName: () => capitalizeName,
24
- clearUnicodeCharacters: () => clearUnicodeCharacters,
25
- getBetween: () => getBetween,
26
- makeString: () => makeString,
27
- titleize: () => titleize,
28
- toLowerCase: () => toLowerCase,
29
- toUpperCase: () => toUpperCase
30
- });
31
- module.exports = __toCommonJS(string_exports);
3
+ Object.defineProperty(exports, '__esModule', { value: true });
32
4
 
33
5
  // src/object.ts
34
6
  var isNull = (object) => {
@@ -124,14 +96,12 @@ var clearUnicodeCharacters = (s, opt = {}) => {
124
96
  s = s.replace(RegExp("(^" + opt.delimiter + "|" + opt.delimiter + "$)", "g"), "");
125
97
  return opt.lowercase ? s.toLowerCase() : s;
126
98
  };
127
- // Annotate the CommonJS export names for ESM import in node:
128
- 0 && (module.exports = {
129
- capitalize,
130
- capitalizeName,
131
- clearUnicodeCharacters,
132
- getBetween,
133
- makeString,
134
- titleize,
135
- toLowerCase,
136
- toUpperCase
137
- });
99
+
100
+ exports.capitalize = capitalize;
101
+ exports.capitalizeName = capitalizeName;
102
+ exports.clearUnicodeCharacters = clearUnicodeCharacters;
103
+ exports.getBetween = getBetween;
104
+ exports.makeString = makeString;
105
+ exports.titleize = titleize;
106
+ exports.toLowerCase = toLowerCase;
107
+ exports.toUpperCase = toUpperCase;
@@ -1,32 +1,8 @@
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);
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
18
4
 
19
5
  // src/string/random.ts
20
- var random_exports = {};
21
- __export(random_exports, {
22
- allCharacter: () => allCharacter,
23
- numeric: () => numeric,
24
- punctuation: () => punctuation,
25
- randAllCharacterByLength: () => randAllCharacterByLength,
26
- randomStringByLength: () => randomStringByLength,
27
- textLowCase: () => textLowCase
28
- });
29
- module.exports = __toCommonJS(random_exports);
30
6
  var textLowCase = "abcdefghijklmnopqrstuvwxyz";
31
7
  var numeric = "0123456789";
32
8
  var punctuation = "!@#$%^&*()_+~|}{[];?><,./-=";
@@ -41,12 +17,10 @@ var randomStringByLength = (length, str = textLowCase) => {
41
17
  }
42
18
  return result;
43
19
  };
44
- // Annotate the CommonJS export names for ESM import in node:
45
- 0 && (module.exports = {
46
- allCharacter,
47
- numeric,
48
- punctuation,
49
- randAllCharacterByLength,
50
- randomStringByLength,
51
- textLowCase
52
- });
20
+
21
+ exports.allCharacter = allCharacter;
22
+ exports.numeric = numeric;
23
+ exports.punctuation = punctuation;
24
+ exports.randAllCharacterByLength = randAllCharacterByLength;
25
+ exports.randomStringByLength = randomStringByLength;
26
+ exports.textLowCase = textLowCase;
@@ -1,44 +1,22 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
- mod
22
- ));
23
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var trim = require('lodash/trim');
6
+
7
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
+
9
+ var trim__default = /*#__PURE__*/_interopDefaultLegacy(trim);
24
10
 
25
11
  // src/string/trimNull.ts
26
- var trimNull_exports = {};
27
- __export(trimNull_exports, {
28
- trimNull: () => trimNull
29
- });
30
- module.exports = __toCommonJS(trimNull_exports);
31
- var import_trim = __toESM(require("lodash/trim"));
32
12
  function trimNull(str) {
33
13
  if (!str)
34
14
  return "";
35
15
  str = str.toString();
36
16
  str = str.replace(/\0/g, "");
37
17
  str = str.replaceAll(" ", "");
38
- str = (0, import_trim.default)(str);
18
+ str = trim__default["default"](str);
39
19
  return str;
40
20
  }
41
- // Annotate the CommonJS export names for ESM import in node:
42
- 0 && (module.exports = {
43
- trimNull
44
- });
21
+
22
+ exports.trimNull = trimNull;
@@ -1,33 +1,6 @@
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);
1
+ 'use strict';
18
2
 
19
- // src/string/url.ts
20
- var url_exports = {};
21
- __export(url_exports, {
22
- addQueryParam: () => addQueryParam,
23
- getFileExtension: () => getFileExtension,
24
- getFileNameWithExtension: () => getFileNameWithExtension,
25
- getFileNameWithoutExtension: () => getFileNameWithoutExtension,
26
- getUrlParams: () => getUrlParams,
27
- isImage: () => isImage,
28
- isLink: () => isLink
29
- });
30
- module.exports = __toCommonJS(url_exports);
3
+ Object.defineProperty(exports, '__esModule', { value: true });
31
4
 
32
5
  // src/object.ts
33
6
  var isNull = (object) => {
@@ -60,7 +33,6 @@ var getUrlParams = (parameter, staticURL, decode = true) => {
60
33
  var parr = parArr[i].split("=");
61
34
  if (parr[0] == parameter) {
62
35
  return decode ? decodeURIComponent(parr[1]) : parr[1];
63
- returnBool = true;
64
36
  } else {
65
37
  returnBool = false;
66
38
  }
@@ -107,13 +79,11 @@ var isImage = (url) => {
107
79
  });
108
80
  return index >= 0;
109
81
  };
110
- // Annotate the CommonJS export names for ESM import in node:
111
- 0 && (module.exports = {
112
- addQueryParam,
113
- getFileExtension,
114
- getFileNameWithExtension,
115
- getFileNameWithoutExtension,
116
- getUrlParams,
117
- isImage,
118
- isLink
119
- });
82
+
83
+ exports.addQueryParam = addQueryParam;
84
+ exports.getFileExtension = getFileExtension;
85
+ exports.getFileNameWithExtension = getFileNameWithExtension;
86
+ exports.getFileNameWithoutExtension = getFileNameWithoutExtension;
87
+ exports.getUrlParams = getUrlParams;
88
+ exports.isImage = isImage;
89
+ exports.isLink = isLink;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginext-utils",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
4
4
  "sideEffects": false,
5
5
  "author": {
6
6
  "name": "TOP GROUP (a.k.a Digitop)",
@@ -15,7 +15,7 @@
15
15
  ".": "./dist"
16
16
  },
17
17
  "scripts": {
18
- "build": "tsup src/**/*.ts --format esm,cjs --dts",
18
+ "build": "tsup src/**/*.ts --format esm,cjs --dts --legacy-output --treeshake",
19
19
  "build2": "tsc src/**/*.ts --emitDeclarationOnly --declaration dist",
20
20
  "dev": "concurrently \"tsup src/**/*.ts --format esm,cjs --dts --watch\"",
21
21
  "test": "mocha test/*.test.js",
package/dist/.DS_Store DELETED
Binary file
package/dist/Checker.d.ts DELETED
@@ -1,6 +0,0 @@
1
- /**
2
- * Check if the object or string is in JSON format
3
- */
4
- declare const isJSON: (content: object | string) => boolean;
5
-
6
- export { isJSON };
package/dist/Checker.js DELETED
@@ -1,48 +0,0 @@
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;
31
- }
32
- }
33
- if (typeof content == "string") {
34
- try {
35
- content = JSON.parse(content);
36
- } catch (err) {
37
- return false;
38
- }
39
- }
40
- if (typeof content != "object") {
41
- return false;
42
- }
43
- return true;
44
- };
45
- // Annotate the CommonJS export names for ESM import in node:
46
- 0 && (module.exports = {
47
- isJSON
48
- });
package/dist/Checker.mjs DELETED
@@ -1,26 +0,0 @@
1
- import "./chunk-AKU6F3WT.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
- export {
25
- isJSON
26
- };
@@ -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 };
@@ -1,74 +0,0 @@
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] = [];
34
- }
35
- if (listeners[type].indexOf(listener) === -1) {
36
- listeners[type].push(listener);
37
- }
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
- }
55
- }
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
- }
68
- }
69
- }
70
- };
71
- // Annotate the CommonJS export names for ESM import in node:
72
- 0 && (module.exports = {
73
- EventDispatcher
74
- });
@@ -1,52 +0,0 @@
1
- import "./chunk-AKU6F3WT.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
- export {
51
- EventDispatcher
52
- };
@@ -1,12 +0,0 @@
1
- declare type UploadParams = {
2
- blob: Blob;
3
- url: string;
4
- params: any;
5
- onComplete: any;
6
- onError: any;
7
- };
8
- declare const FileUpload: {
9
- uploadBlob(props: UploadParams): void;
10
- };
11
-
12
- export { FileUpload };
@@ -1,82 +0,0 @@
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);
25
- 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);
68
- }
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
- }
78
- };
79
- // Annotate the CommonJS export names for ESM import in node:
80
- 0 && (module.exports = {
81
- FileUpload
82
- });
@@ -1,60 +0,0 @@
1
- import "./chunk-AKU6F3WT.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
- export {
59
- FileUpload
60
- };
package/dist/Slug.d.ts DELETED
@@ -1,5 +0,0 @@
1
- declare const makeSlug: (s: string, opt?: {
2
- [key: string]: any;
3
- }) => string;
4
-
5
- export { makeSlug };