@etsoo/shared 1.2.51 → 1.2.54
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/.github/workflows/main.yml +6 -5
- package/README.md +1 -1
- package/lib/cjs/ActionResult.d.ts +1 -1
- package/lib/cjs/ActionResult.js +3 -3
- package/lib/cjs/ArrayUtils.d.ts +1 -1
- package/lib/cjs/ArrayUtils.js +4 -4
- package/lib/cjs/ColorUtils.d.ts +1 -1
- package/lib/cjs/ColorUtils.js +2 -2
- package/lib/cjs/DataTypes.d.ts +6 -6
- package/lib/cjs/DataTypes.js +50 -51
- package/lib/cjs/DateUtils.d.ts +1 -1
- package/lib/cjs/DateUtils.js +27 -28
- package/lib/cjs/DomUtils.d.ts +3 -3
- package/lib/cjs/DomUtils.js +64 -73
- package/lib/cjs/ExtendUtils.d.ts +1 -1
- package/lib/cjs/ExtendUtils.js +6 -6
- package/lib/cjs/IActionResult.d.ts +15 -2
- package/lib/cjs/NumberUtils.d.ts +1 -1
- package/lib/cjs/NumberUtils.js +9 -9
- package/lib/cjs/StorageUtils.js +2 -2
- package/lib/cjs/Utils.d.ts +4 -4
- package/lib/cjs/Utils.js +58 -62
- package/lib/cjs/index.d.ts +22 -22
- package/lib/cjs/storage/WindowStorage.d.ts +1 -1
- package/lib/cjs/types/ContentDisposition.d.ts +2 -2
- package/lib/cjs/types/ContentDisposition.js +11 -13
- package/lib/cjs/types/EColor.js +5 -7
- package/lib/cjs/types/EHistory.d.ts +3 -3
- package/lib/cjs/types/EHistory.js +4 -4
- package/lib/cjs/types/ErrorData.d.ts +1 -1
- package/lib/cjs/types/EventClass.js +1 -1
- package/lib/mjs/ActionResult.d.ts +1 -1
- package/lib/mjs/ActionResult.js +3 -3
- package/lib/mjs/ArrayUtils.d.ts +1 -1
- package/lib/mjs/ArrayUtils.js +5 -5
- package/lib/mjs/ColorUtils.d.ts +1 -1
- package/lib/mjs/ColorUtils.js +3 -3
- package/lib/mjs/DataTypes.d.ts +6 -6
- package/lib/mjs/DataTypes.js +50 -51
- package/lib/mjs/DateUtils.d.ts +1 -1
- package/lib/mjs/DateUtils.js +27 -28
- package/lib/mjs/DomUtils.d.ts +3 -3
- package/lib/mjs/DomUtils.js +67 -76
- package/lib/mjs/ExtendUtils.d.ts +1 -1
- package/lib/mjs/ExtendUtils.js +6 -6
- package/lib/mjs/IActionResult.d.ts +15 -2
- package/lib/mjs/NumberUtils.d.ts +1 -1
- package/lib/mjs/NumberUtils.js +9 -9
- package/lib/mjs/StorageUtils.js +4 -4
- package/lib/mjs/Utils.d.ts +4 -4
- package/lib/mjs/Utils.js +61 -65
- package/lib/mjs/index.d.ts +22 -22
- package/lib/mjs/index.js +22 -22
- package/lib/mjs/storage/WindowStorage.d.ts +1 -1
- package/lib/mjs/storage/WindowStorage.js +2 -2
- package/lib/mjs/types/ContentDisposition.d.ts +2 -2
- package/lib/mjs/types/ContentDisposition.js +12 -14
- package/lib/mjs/types/EColor.js +5 -7
- package/lib/mjs/types/EHistory.d.ts +3 -3
- package/lib/mjs/types/EHistory.js +5 -5
- package/lib/mjs/types/ErrorData.d.ts +1 -1
- package/lib/mjs/types/EventClass.js +1 -1
- package/package.json +61 -63
- package/src/ActionResult.ts +23 -23
- package/src/ArrayUtils.ts +164 -172
- package/src/ColorUtils.ts +80 -82
- package/src/DataTypes.ts +745 -754
- package/src/DateUtils.ts +266 -268
- package/src/DomUtils.ts +806 -831
- package/src/ExtendUtils.ts +191 -191
- package/src/IActionResult.ts +55 -40
- package/src/Keyboard.ts +258 -258
- package/src/NumberUtils.ts +135 -135
- package/src/StorageUtils.ts +117 -117
- package/src/Utils.ts +908 -930
- package/src/index.ts +22 -22
- package/src/node/Storage.ts +53 -53
- package/src/storage/IStorage.ts +62 -62
- package/src/storage/WindowStorage.ts +140 -140
- package/src/types/ContentDisposition.ts +59 -63
- package/src/types/DataError.ts +15 -15
- package/src/types/DelayedExecutorType.ts +15 -15
- package/src/types/EColor.ts +241 -248
- package/src/types/EHistory.ts +151 -151
- package/src/types/ErrorData.ts +11 -11
- package/src/types/EventClass.ts +220 -220
- package/src/types/FormData.ts +25 -25
- package/src/types/ParsedPath.ts +5 -5
- package/tsconfig.cjs.json +16 -16
- package/tsconfig.json +16 -16
- package/.eslintignore +0 -3
- package/.eslintrc.json +0 -29
- package/.prettierignore +0 -5
- package/.prettierrc +0 -6
|
@@ -1,81 +1,77 @@
|
|
|
1
|
-
import { Utils } from
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
38
|
+
const parts = header.trim().split(/\s*;\s*/g);
|
|
39
|
+
const len = parts.length;
|
|
40
|
+
if (len < 2) return undefined;
|
|
47
41
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
const type = parts[0];
|
|
43
|
+
let name: string | undefined;
|
|
44
|
+
let filename: string = "";
|
|
51
45
|
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
|
|
56
|
-
|
|
50
|
+
// case-insensitive
|
|
51
|
+
field = field.toLowerCase();
|
|
57
52
|
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
72
|
-
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
67
|
+
if (type === "form-data") {
|
|
68
|
+
return new ContentDisposition(type, filename, name ?? "file");
|
|
69
|
+
}
|
|
78
70
|
|
|
79
|
-
|
|
71
|
+
if (type === "inline" || type === "attachment") {
|
|
72
|
+
return new ContentDisposition(type, filename);
|
|
80
73
|
}
|
|
74
|
+
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
81
77
|
}
|
package/src/types/DataError.ts
CHANGED
|
@@ -4,22 +4,22 @@
|
|
|
4
4
|
*
|
|
5
5
|
*/
|
|
6
6
|
export class DataError<T = Record<string, unknown>> extends Error {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Custom data
|
|
9
|
+
*/
|
|
10
|
+
public readonly data: T;
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
20
|
+
this.data = data;
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Clear
|
|
11
|
+
*/
|
|
12
|
+
clear(): void;
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Is running or not
|
|
16
|
+
* @returns Result
|
|
17
|
+
*/
|
|
18
|
+
isRunning(): boolean;
|
|
19
19
|
};
|