@etsoo/shared 1.2.52 → 1.2.55

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 (106) hide show
  1. package/.github/workflows/main.yml +6 -5
  2. package/__tests__/ArrayUtils.ts +126 -126
  3. package/__tests__/ColorUtils.ts +24 -24
  4. package/__tests__/ContentDisposition.ts +18 -18
  5. package/__tests__/DataTypes.ts +222 -204
  6. package/__tests__/DateUtils.ts +82 -82
  7. package/__tests__/DomUtils.ts +352 -352
  8. package/__tests__/EHistory.ts +62 -62
  9. package/__tests__/ExtendUtils.ts +40 -40
  10. package/__tests__/Keyboard.ts +14 -14
  11. package/__tests__/NumberUtils.ts +37 -39
  12. package/__tests__/StorageUtils.ts +27 -27
  13. package/__tests__/Utils.ts +361 -363
  14. package/__tests__/tsconfig.json +15 -15
  15. package/lib/cjs/ActionResult.d.ts +1 -1
  16. package/lib/cjs/ActionResult.js +3 -3
  17. package/lib/cjs/ArrayUtils.d.ts +1 -1
  18. package/lib/cjs/ArrayUtils.js +4 -4
  19. package/lib/cjs/ColorUtils.d.ts +1 -1
  20. package/lib/cjs/ColorUtils.js +2 -2
  21. package/lib/cjs/DataTypes.d.ts +6 -6
  22. package/lib/cjs/DataTypes.js +50 -51
  23. package/lib/cjs/DateUtils.d.ts +1 -1
  24. package/lib/cjs/DateUtils.js +27 -28
  25. package/lib/cjs/DomUtils.d.ts +3 -3
  26. package/lib/cjs/DomUtils.js +64 -73
  27. package/lib/cjs/ExtendUtils.d.ts +1 -1
  28. package/lib/cjs/ExtendUtils.js +6 -6
  29. package/lib/cjs/IActionResult.d.ts +1 -1
  30. package/lib/cjs/NumberUtils.d.ts +1 -1
  31. package/lib/cjs/NumberUtils.js +9 -9
  32. package/lib/cjs/StorageUtils.js +2 -2
  33. package/lib/cjs/Utils.d.ts +4 -4
  34. package/lib/cjs/Utils.js +58 -62
  35. package/lib/cjs/index.d.ts +22 -22
  36. package/lib/cjs/storage/WindowStorage.d.ts +1 -1
  37. package/lib/cjs/types/ContentDisposition.d.ts +2 -2
  38. package/lib/cjs/types/ContentDisposition.js +11 -13
  39. package/lib/cjs/types/EColor.js +5 -7
  40. package/lib/cjs/types/EHistory.d.ts +3 -3
  41. package/lib/cjs/types/EHistory.js +4 -4
  42. package/lib/cjs/types/ErrorData.d.ts +1 -1
  43. package/lib/cjs/types/EventClass.js +1 -1
  44. package/lib/mjs/ActionResult.d.ts +1 -1
  45. package/lib/mjs/ActionResult.js +3 -3
  46. package/lib/mjs/ArrayUtils.d.ts +1 -1
  47. package/lib/mjs/ArrayUtils.js +5 -5
  48. package/lib/mjs/ColorUtils.d.ts +1 -1
  49. package/lib/mjs/ColorUtils.js +3 -3
  50. package/lib/mjs/DataTypes.d.ts +6 -6
  51. package/lib/mjs/DataTypes.js +50 -51
  52. package/lib/mjs/DateUtils.d.ts +1 -1
  53. package/lib/mjs/DateUtils.js +27 -28
  54. package/lib/mjs/DomUtils.d.ts +3 -3
  55. package/lib/mjs/DomUtils.js +67 -76
  56. package/lib/mjs/ExtendUtils.d.ts +1 -1
  57. package/lib/mjs/ExtendUtils.js +6 -6
  58. package/lib/mjs/IActionResult.d.ts +1 -1
  59. package/lib/mjs/NumberUtils.d.ts +1 -1
  60. package/lib/mjs/NumberUtils.js +9 -9
  61. package/lib/mjs/StorageUtils.js +4 -4
  62. package/lib/mjs/Utils.d.ts +4 -4
  63. package/lib/mjs/Utils.js +61 -65
  64. package/lib/mjs/index.d.ts +22 -22
  65. package/lib/mjs/index.js +22 -22
  66. package/lib/mjs/storage/WindowStorage.d.ts +1 -1
  67. package/lib/mjs/storage/WindowStorage.js +2 -2
  68. package/lib/mjs/types/ContentDisposition.d.ts +2 -2
  69. package/lib/mjs/types/ContentDisposition.js +12 -14
  70. package/lib/mjs/types/EColor.js +5 -7
  71. package/lib/mjs/types/EHistory.d.ts +3 -3
  72. package/lib/mjs/types/EHistory.js +5 -5
  73. package/lib/mjs/types/ErrorData.d.ts +1 -1
  74. package/lib/mjs/types/EventClass.js +1 -1
  75. package/package.json +61 -63
  76. package/src/ActionResult.ts +23 -23
  77. package/src/ArrayUtils.ts +164 -172
  78. package/src/ColorUtils.ts +80 -82
  79. package/src/DataTypes.ts +745 -754
  80. package/src/DateUtils.ts +266 -268
  81. package/src/DomUtils.ts +806 -831
  82. package/src/ExtendUtils.ts +191 -191
  83. package/src/IActionResult.ts +42 -42
  84. package/src/Keyboard.ts +258 -258
  85. package/src/NumberUtils.ts +135 -135
  86. package/src/StorageUtils.ts +117 -117
  87. package/src/Utils.ts +908 -930
  88. package/src/index.ts +22 -22
  89. package/src/node/Storage.ts +53 -53
  90. package/src/storage/IStorage.ts +62 -62
  91. package/src/storage/WindowStorage.ts +140 -140
  92. package/src/types/ContentDisposition.ts +59 -63
  93. package/src/types/DataError.ts +15 -15
  94. package/src/types/DelayedExecutorType.ts +15 -15
  95. package/src/types/EColor.ts +241 -248
  96. package/src/types/EHistory.ts +151 -151
  97. package/src/types/ErrorData.ts +11 -11
  98. package/src/types/EventClass.ts +220 -220
  99. package/src/types/FormData.ts +25 -25
  100. package/src/types/ParsedPath.ts +5 -5
  101. package/tsconfig.cjs.json +16 -16
  102. package/tsconfig.json +16 -16
  103. package/.eslintignore +0 -3
  104. package/.eslintrc.json +0 -29
  105. package/.prettierignore +0 -5
  106. package/.prettierrc +0 -6
@@ -1,81 +1,77 @@
1
- import { Utils } from '../Utils';
1
+ import { Utils } from "../Utils";
2
2
 
3
3
  /**
4
4
  * Content disposition of HTTP
5
5
  * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition
6
6
  */
7
7
  export class ContentDisposition {
8
- constructor(type: 'inline' | 'attachment', filename: string);
9
- constructor(type: 'form-data', filename: string, name: string);
10
- constructor(
11
- public readonly type: string,
12
- public readonly filename: string,
13
- public readonly name?: string
14
- ) {}
8
+ constructor(type: "inline" | "attachment", filename: string);
9
+ constructor(type: "form-data", filename: string, name: string);
10
+ constructor(
11
+ public readonly type: string,
12
+ public readonly filename: string,
13
+ public readonly name?: string
14
+ ) {}
15
15
 
16
- /**
17
- * Format to standard output
18
- * @returns Result
19
- */
20
- format() {
21
- const items = [this.type];
22
- if (this.name) items.push(`name="${this.name}"`);
23
- const filename1 = this.filename.replace(/[^a-zA-Z0-9\.-]/g, '_');
24
- items.push(`filename="${filename1}"`);
25
- if (filename1 != this.filename)
26
- items.push(
27
- `filename*="UTF-8''${encodeURIComponent(this.filename)}"`
28
- );
29
- return items.join('; ');
30
- }
31
-
32
- /**
33
- * Parse header value
34
- * @param header Content-Disposition header value
35
- * @returns Object
36
- */
37
- static parse(header: string | undefined | null) {
38
- if (!header) return undefined;
16
+ /**
17
+ * Format to standard output
18
+ * @returns Result
19
+ */
20
+ format() {
21
+ const items = [this.type];
22
+ if (this.name) items.push(`name="${this.name}"`);
23
+ const filename1 = this.filename.replace(/[^a-zA-Z0-9\.-]/g, "_");
24
+ items.push(`filename="${filename1}"`);
25
+ if (filename1 != this.filename)
26
+ items.push(`filename*="UTF-8''${encodeURIComponent(this.filename)}"`);
27
+ return items.join("; ");
28
+ }
39
29
 
40
- const parts = header.trim().split(/\s*;\s*/g);
41
- const len = parts.length;
42
- if (len < 2) return undefined;
30
+ /**
31
+ * Parse header value
32
+ * @param header Content-Disposition header value
33
+ * @returns Object
34
+ */
35
+ static parse(header: string | undefined | null) {
36
+ if (!header) return undefined;
43
37
 
44
- const type = parts[0];
45
- let name: string | undefined;
46
- let filename: string = '';
38
+ const parts = header.trim().split(/\s*;\s*/g);
39
+ const len = parts.length;
40
+ if (len < 2) return undefined;
47
41
 
48
- for (let i = 1; i < len; i++) {
49
- const part = parts[i];
50
- let [field, value] = part.split(/\s*=\s*/g);
42
+ const type = parts[0];
43
+ let name: string | undefined;
44
+ let filename: string = "";
51
45
 
52
- // case-insensitive
53
- field = field.toLowerCase();
46
+ for (let i = 1; i < len; i++) {
47
+ const part = parts[i];
48
+ let [field, value] = part.split(/\s*=\s*/g);
54
49
 
55
- // Remove quotes
56
- value = Utils.trim(value, '"');
50
+ // case-insensitive
51
+ field = field.toLowerCase();
57
52
 
58
- if (field === 'name') {
59
- name = value;
60
- } else if (field === 'filename') {
61
- if (filename === '') filename = value;
62
- } else if (field === 'filename*') {
63
- const pos = value.indexOf("''");
64
- filename =
65
- pos == -1
66
- ? value
67
- : decodeURIComponent(value.substring(pos + 2));
68
- }
69
- }
53
+ // Remove quotes
54
+ value = Utils.trim(value, '"');
70
55
 
71
- if (type === 'form-data') {
72
- return new ContentDisposition(type, filename, name ?? 'file');
73
- }
56
+ if (field === "name") {
57
+ name = value;
58
+ } else if (field === "filename") {
59
+ if (filename === "") filename = value;
60
+ } else if (field === "filename*") {
61
+ const pos = value.indexOf("''");
62
+ filename =
63
+ pos == -1 ? value : decodeURIComponent(value.substring(pos + 2));
64
+ }
65
+ }
74
66
 
75
- if (type === 'inline' || type === 'attachment') {
76
- return new ContentDisposition(type, filename);
77
- }
67
+ if (type === "form-data") {
68
+ return new ContentDisposition(type, filename, name ?? "file");
69
+ }
78
70
 
79
- return undefined;
71
+ if (type === "inline" || type === "attachment") {
72
+ return new ContentDisposition(type, filename);
80
73
  }
74
+
75
+ return undefined;
76
+ }
81
77
  }
@@ -4,22 +4,22 @@
4
4
  *
5
5
  */
6
6
  export class DataError<T = Record<string, unknown>> extends Error {
7
- /**
8
- * Custom data
9
- */
10
- public readonly data: T;
7
+ /**
8
+ * Custom data
9
+ */
10
+ public readonly data: T;
11
11
 
12
- /**
13
- * Constructor
14
- * @param message Error message
15
- * @param data Custom data
16
- */
17
- constructor(message: string, data: T) {
18
- super(message);
12
+ /**
13
+ * Constructor
14
+ * @param message Error message
15
+ * @param data Custom data
16
+ */
17
+ constructor(message: string, data: T) {
18
+ super(message);
19
19
 
20
- this.data = data;
20
+ this.data = data;
21
21
 
22
- // Set the prototype explicitly to ensure instanceof works correctly
23
- Object.setPrototypeOf(this, DataError.prototype);
24
- }
22
+ // Set the prototype explicitly to ensure instanceof works correctly
23
+ Object.setPrototypeOf(this, DataError.prototype);
24
+ }
25
25
  }
@@ -1,19 +1,19 @@
1
1
  export type DelayedExecutorType<P extends any[] = []> = {
2
- /**
3
- * Call the function
4
- * @param miliseconds Delayed miliseconds for this call
5
- * @param args Args
6
- */
7
- call(miliseconds?: number, ...args: P): void;
2
+ /**
3
+ * Call the function
4
+ * @param miliseconds Delayed miliseconds for this call
5
+ * @param args Args
6
+ */
7
+ call(miliseconds?: number, ...args: P): void;
8
8
 
9
- /**
10
- * Clear
11
- */
12
- clear(): void;
9
+ /**
10
+ * Clear
11
+ */
12
+ clear(): void;
13
13
 
14
- /**
15
- * Is running or not
16
- * @returns Result
17
- */
18
- isRunning(): boolean;
14
+ /**
15
+ * Is running or not
16
+ * @returns Result
17
+ */
18
+ isRunning(): boolean;
19
19
  };