@whitesev/utils 2.7.1 → 2.7.3
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/dist/index.amd.js +260 -409
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +260 -409
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +260 -409
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +260 -409
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +260 -409
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +260 -409
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/ColorConversion.d.ts +3 -8
- package/dist/types/src/Dictionary.d.ts +21 -14
- package/dist/types/src/GBKEncoder.d.ts +1 -2
- package/dist/types/src/Hooks.d.ts +1 -2
- package/dist/types/src/Httpx.d.ts +45 -46
- package/dist/types/src/LockFunction.d.ts +1 -2
- package/dist/types/src/Log.d.ts +1 -2
- package/dist/types/src/Progress.d.ts +1 -2
- package/dist/types/src/Utils.d.ts +30 -2
- package/dist/types/src/UtilsGMMenu.d.ts +1 -2
- package/dist/types/src/WindowApi.d.ts +1 -2
- package/dist/types/src/indexedDB.d.ts +1 -2
- package/dist/types/src/types/Event.d.ts +1 -2
- package/dist/types/src/types/Httpx.d.ts +75 -86
- package/dist/types/src/types/ajaxHooker.d.ts +1 -5
- package/dist/types/src/types/env.d.ts +2 -0
- package/dist/types/src/types/global.d.ts +3 -0
- package/package.json +1 -1
- package/src/ColorConversion.ts +13 -37
- package/src/CommonUtil.ts +8 -31
- package/src/DOMUtils.ts +9 -24
- package/src/Dictionary.ts +37 -38
- package/src/GBKEncoder.ts +9 -18
- package/src/Hooks.ts +2 -7
- package/src/Httpx.ts +257 -412
- package/src/LockFunction.ts +1 -3
- package/src/Log.ts +8 -26
- package/src/Progress.ts +3 -13
- package/src/TryCatch.ts +4 -12
- package/src/Utils.ts +233 -595
- package/src/UtilsCommon.ts +5 -9
- package/src/UtilsGMCookie.ts +1 -4
- package/src/UtilsGMMenu.ts +29 -51
- package/src/Vue.ts +6 -18
- package/src/WindowApi.ts +2 -5
- package/src/indexedDB.ts +11 -20
- package/src/types/Event.d.ts +1 -2
- package/src/types/Httpx.d.ts +75 -86
- package/src/types/ajaxHooker.d.ts +1 -5
- package/src/types/env.d.ts +2 -0
- package/src/types/global.d.ts +3 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare class ColorConversion {
|
|
1
|
+
export declare class ColorConversion {
|
|
2
2
|
/**
|
|
3
3
|
* 判断是否是16进制颜色
|
|
4
4
|
* @param str
|
|
@@ -7,7 +7,7 @@ declare class ColorConversion {
|
|
|
7
7
|
/**
|
|
8
8
|
* 16进制颜色转rgba
|
|
9
9
|
*
|
|
10
|
-
*
|
|
10
|
+
* 例如:`#ff0000` 转为 `rgba(123,123,123, 0.4)`
|
|
11
11
|
* @param hex
|
|
12
12
|
* @param opacity
|
|
13
13
|
*/
|
|
@@ -15,30 +15,25 @@ declare class ColorConversion {
|
|
|
15
15
|
/**
|
|
16
16
|
* hex转rgb
|
|
17
17
|
* @param str
|
|
18
|
-
* @returns
|
|
19
18
|
*/
|
|
20
|
-
hexToRgb(str: string): RegExpMatchArray
|
|
19
|
+
hexToRgb(str: string): RegExpMatchArray;
|
|
21
20
|
/**
|
|
22
21
|
* rgb转hex
|
|
23
22
|
* @param redValue
|
|
24
23
|
* @param greenValue
|
|
25
24
|
* @param blueValue
|
|
26
|
-
* @returns
|
|
27
25
|
*/
|
|
28
26
|
rgbToHex(redValue: string | number, greenValue: string | number, blueValue: string | number): string;
|
|
29
27
|
/**
|
|
30
28
|
* 获取颜色变暗或亮
|
|
31
29
|
* @param color 颜色
|
|
32
30
|
* @param level 0~1.0
|
|
33
|
-
* @returns
|
|
34
31
|
*/
|
|
35
32
|
getDarkColor(color: string, level: string): string;
|
|
36
33
|
/**
|
|
37
34
|
* 获取颜色变亮
|
|
38
35
|
* @param color 颜色
|
|
39
36
|
* @param level 0~1.0
|
|
40
|
-
* @returns
|
|
41
37
|
*/
|
|
42
38
|
getLightColor(color: string, level: number): string;
|
|
43
39
|
}
|
|
44
|
-
export { ColorConversion };
|
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
declare class UtilsDictionary<K, V> {
|
|
1
|
+
export declare class UtilsDictionary<K extends string | number | symbol, V extends unknown> {
|
|
2
2
|
private items;
|
|
3
3
|
constructor();
|
|
4
4
|
constructor(key: K, value: V);
|
|
5
|
+
/**
|
|
6
|
+
* 获取字典的长度,同this.size
|
|
7
|
+
*/
|
|
8
|
+
get length(): number;
|
|
9
|
+
/**
|
|
10
|
+
* 迭代器
|
|
11
|
+
*/
|
|
12
|
+
get entries(): () => IterableIterator<[K, V]>;
|
|
13
|
+
/**
|
|
14
|
+
* 是否可遍历
|
|
15
|
+
*/
|
|
16
|
+
get [Symbol.iterator](): () => IterableIterator<[K, V]>;
|
|
5
17
|
/**
|
|
6
18
|
* 检查是否有某一个键
|
|
7
19
|
* @param key 键
|
|
@@ -54,24 +66,19 @@ declare class UtilsDictionary<K, V> {
|
|
|
54
66
|
/**
|
|
55
67
|
* 返回字典本身
|
|
56
68
|
*/
|
|
57
|
-
getItems():
|
|
69
|
+
getItems(): {
|
|
70
|
+
[key: string]: V;
|
|
71
|
+
[key: number]: V;
|
|
72
|
+
[key: symbol]: V;
|
|
73
|
+
};
|
|
58
74
|
/**
|
|
59
75
|
* 合并另一个字典
|
|
60
76
|
* @param data 需要合并的字典
|
|
61
77
|
*/
|
|
62
78
|
concat(data: UtilsDictionary<K, V>): void;
|
|
63
|
-
forEach(callbackfn: (value: V, key: K, dictionary: UtilsDictionary<K, V>) => void): void;
|
|
64
|
-
/**
|
|
65
|
-
* 获取字典的长度,同this.size
|
|
66
|
-
*/
|
|
67
|
-
get length(): number;
|
|
68
|
-
/**
|
|
69
|
-
* 迭代器
|
|
70
|
-
*/
|
|
71
|
-
get entries(): () => IterableIterator<[K, V]>;
|
|
72
79
|
/**
|
|
73
|
-
*
|
|
80
|
+
* 迭代字典
|
|
81
|
+
* @param callbackfn 回调函数
|
|
74
82
|
*/
|
|
75
|
-
|
|
83
|
+
forEach(callbackfn: (value: V, key: K, dictionary: UtilsDictionary<K, V>) => void): void;
|
|
76
84
|
}
|
|
77
|
-
export { UtilsDictionary };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { HttpxHookErrorData, HttpxRequestOption, HttpxResponse, HttpxResponseData, HttpxPromise, HttpxInitOption } from "./types/Httpx";
|
|
2
|
-
declare class Httpx {
|
|
2
|
+
export declare class Httpx {
|
|
3
3
|
#private;
|
|
4
4
|
private GM_Api;
|
|
5
5
|
private HttpxRequestHook;
|
|
6
6
|
private HttpxResponseHook;
|
|
7
7
|
private HttpxRequestOption;
|
|
8
|
-
private
|
|
8
|
+
private HttpxResponseCallBack;
|
|
9
9
|
private HttpxRequest;
|
|
10
10
|
/**
|
|
11
11
|
* 实例化
|
|
@@ -70,11 +70,6 @@ declare class Httpx {
|
|
|
70
70
|
* @param httpRequest 网络请求函数
|
|
71
71
|
*/
|
|
72
72
|
setXMLHttpRequest(httpRequest: Function): void;
|
|
73
|
-
/**
|
|
74
|
-
* GET 请求
|
|
75
|
-
* @param url 网址
|
|
76
|
-
*/
|
|
77
|
-
get<T extends HttpxRequestOption>(url: string): HttpxPromise<HttpxResponse<T>>;
|
|
78
73
|
/**
|
|
79
74
|
* GET 请求
|
|
80
75
|
* @param details 配置
|
|
@@ -82,26 +77,31 @@ declare class Httpx {
|
|
|
82
77
|
get<T extends HttpxRequestOption>(details: T): HttpxPromise<HttpxResponse<T>>;
|
|
83
78
|
/**
|
|
84
79
|
* GET 请求
|
|
85
|
-
* @param url
|
|
80
|
+
* @param url 请求的url
|
|
86
81
|
* @param details 配置
|
|
87
82
|
*/
|
|
88
|
-
get<T extends HttpxRequestOption
|
|
83
|
+
get<T extends Omit<HttpxRequestOption, "url">>(url: string, details?: T): HttpxPromise<HttpxResponse<T & {
|
|
84
|
+
/**
|
|
85
|
+
* 请求的url
|
|
86
|
+
*/
|
|
87
|
+
url: string;
|
|
88
|
+
}>>;
|
|
89
89
|
/**
|
|
90
90
|
* POST 请求
|
|
91
91
|
* @param details 配置
|
|
92
92
|
*/
|
|
93
|
-
post<T extends HttpxRequestOption>(details
|
|
94
|
-
/**
|
|
95
|
-
* POST 请求
|
|
96
|
-
* @param url 网址
|
|
97
|
-
*/
|
|
98
|
-
post<T extends HttpxRequestOption>(url: string): HttpxPromise<HttpxResponse<T>>;
|
|
93
|
+
post<T extends HttpxRequestOption>(details?: T): HttpxPromise<HttpxResponse<T>>;
|
|
99
94
|
/**
|
|
100
95
|
* POST 请求
|
|
101
|
-
* @param url
|
|
96
|
+
* @param url 请求的url
|
|
102
97
|
* @param details 配置
|
|
103
98
|
*/
|
|
104
|
-
post<T extends HttpxRequestOption
|
|
99
|
+
post<T extends Omit<HttpxRequestOption, "url">>(url: string, details?: T): HttpxPromise<HttpxResponse<T & {
|
|
100
|
+
/**
|
|
101
|
+
* 请求的url
|
|
102
|
+
*/
|
|
103
|
+
url: string;
|
|
104
|
+
}>>;
|
|
105
105
|
/**
|
|
106
106
|
* HEAD 请求
|
|
107
107
|
* @param details 配置
|
|
@@ -109,15 +109,15 @@ declare class Httpx {
|
|
|
109
109
|
head<T extends HttpxRequestOption>(details: T): HttpxPromise<HttpxResponse<T>>;
|
|
110
110
|
/**
|
|
111
111
|
* HEAD 请求
|
|
112
|
-
* @param url
|
|
113
|
-
*/
|
|
114
|
-
head<T extends HttpxRequestOption>(url: string): HttpxPromise<HttpxResponse<T>>;
|
|
115
|
-
/**
|
|
116
|
-
* HEAD 请求
|
|
117
|
-
* @param url 网址
|
|
112
|
+
* @param url 请求的url
|
|
118
113
|
* @param details 配置
|
|
119
114
|
*/
|
|
120
|
-
head<T extends HttpxRequestOption
|
|
115
|
+
head<T extends Omit<HttpxRequestOption, "url">>(url: string, details?: T): HttpxPromise<HttpxResponse<T & {
|
|
116
|
+
/**
|
|
117
|
+
* 请求的url
|
|
118
|
+
*/
|
|
119
|
+
url: string;
|
|
120
|
+
}>>;
|
|
121
121
|
/**
|
|
122
122
|
* OPTIONS 请求
|
|
123
123
|
* @param details 配置
|
|
@@ -125,15 +125,15 @@ declare class Httpx {
|
|
|
125
125
|
options<T extends HttpxRequestOption>(details: T): HttpxPromise<HttpxResponse<T>>;
|
|
126
126
|
/**
|
|
127
127
|
* OPTIONS 请求
|
|
128
|
-
* @param url
|
|
129
|
-
*/
|
|
130
|
-
options<T extends HttpxRequestOption>(url: string): HttpxPromise<HttpxResponse<T>>;
|
|
131
|
-
/**
|
|
132
|
-
* OPTIONS 请求
|
|
133
|
-
* @param url 网址
|
|
128
|
+
* @param url 请求的url
|
|
134
129
|
* @param details 配置
|
|
135
130
|
*/
|
|
136
|
-
options<T extends HttpxRequestOption
|
|
131
|
+
options<T extends Omit<HttpxRequestOption, "url">>(url: string, details?: T): HttpxPromise<HttpxResponse<T & {
|
|
132
|
+
/**
|
|
133
|
+
* 请求的url
|
|
134
|
+
*/
|
|
135
|
+
url: string;
|
|
136
|
+
}>>;
|
|
137
137
|
/**
|
|
138
138
|
* DELETE 请求
|
|
139
139
|
* @param details 配置
|
|
@@ -141,15 +141,15 @@ declare class Httpx {
|
|
|
141
141
|
delete<T extends HttpxRequestOption>(details: T): HttpxPromise<HttpxResponse<T>>;
|
|
142
142
|
/**
|
|
143
143
|
* DELETE 请求
|
|
144
|
-
* @param url
|
|
145
|
-
*/
|
|
146
|
-
delete<T extends HttpxRequestOption>(url: string): HttpxPromise<HttpxResponse<T>>;
|
|
147
|
-
/**
|
|
148
|
-
* DELETE 请求
|
|
149
|
-
* @param url 网址
|
|
144
|
+
* @param url 请求的url
|
|
150
145
|
* @param details 配置
|
|
151
146
|
*/
|
|
152
|
-
delete<T extends HttpxRequestOption
|
|
147
|
+
delete<T extends Omit<HttpxRequestOption, "url">>(url: string, details?: T): HttpxPromise<HttpxResponse<T & {
|
|
148
|
+
/**
|
|
149
|
+
* 请求的url
|
|
150
|
+
*/
|
|
151
|
+
url: string;
|
|
152
|
+
}>>;
|
|
153
153
|
/**
|
|
154
154
|
* PUT 请求
|
|
155
155
|
* @param details 配置
|
|
@@ -157,15 +157,15 @@ declare class Httpx {
|
|
|
157
157
|
put<T extends HttpxRequestOption>(details: T): HttpxPromise<HttpxResponse<T>>;
|
|
158
158
|
/**
|
|
159
159
|
* PUT 请求
|
|
160
|
-
* @param url
|
|
161
|
-
*/
|
|
162
|
-
put<T extends HttpxRequestOption>(url: string): HttpxPromise<HttpxResponse<T>>;
|
|
163
|
-
/**
|
|
164
|
-
* PUT 请求
|
|
165
|
-
* @param url 网址
|
|
160
|
+
* @param url 请求的url
|
|
166
161
|
* @param details 配置
|
|
167
162
|
*/
|
|
168
|
-
put<T extends HttpxRequestOption
|
|
163
|
+
put<T extends Omit<HttpxRequestOption, "url">>(url: string, details?: T): HttpxPromise<HttpxResponse<T & {
|
|
164
|
+
/**
|
|
165
|
+
* 请求的url
|
|
166
|
+
*/
|
|
167
|
+
url: string;
|
|
168
|
+
}>>;
|
|
169
169
|
/**
|
|
170
170
|
* 发送请求
|
|
171
171
|
* @param details 配置
|
|
@@ -173,4 +173,3 @@ declare class Httpx {
|
|
|
173
173
|
*/
|
|
174
174
|
request<T extends HttpxRequestOption>(details: T, beforeRequestOption?: (option: Required<T>) => void): HttpxPromise<HttpxResponse<T>>;
|
|
175
175
|
}
|
|
176
|
-
export { Httpx };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare class LockFunction<K extends (...args: any[]) => any | Promise<any> | void> {
|
|
1
|
+
export declare class LockFunction<K extends (...args: any[]) => any | Promise<any> | void> {
|
|
2
2
|
#private;
|
|
3
3
|
lock: () => void;
|
|
4
4
|
unlock: () => void;
|
|
@@ -16,4 +16,3 @@ declare class LockFunction<K extends (...args: any[]) => any | Promise<any> | vo
|
|
|
16
16
|
*/
|
|
17
17
|
constructor(callback: K, context?: any, delayTime?: number);
|
|
18
18
|
}
|
|
19
|
-
export { LockFunction };
|
package/dist/types/src/Log.d.ts
CHANGED
|
@@ -1763,7 +1763,24 @@ declare class Utils {
|
|
|
1763
1763
|
* @param target 待获取的对象
|
|
1764
1764
|
* @param handler 获取属性的回调
|
|
1765
1765
|
*/
|
|
1766
|
-
queryProperty(target: any, handler: (target:
|
|
1766
|
+
queryProperty<T extends any = any>(target: any, handler: (target: T) => {
|
|
1767
|
+
/**
|
|
1768
|
+
* 是否是需要的属性
|
|
1769
|
+
* + `true` 将目标值赋值给data
|
|
1770
|
+
* + `false` 不是需要的,data为下一个处理的对象
|
|
1771
|
+
*/
|
|
1772
|
+
isFind: boolean;
|
|
1773
|
+
/**
|
|
1774
|
+
* 对象/目标值
|
|
1775
|
+
*/
|
|
1776
|
+
data: any;
|
|
1777
|
+
}): any;
|
|
1778
|
+
/**
|
|
1779
|
+
* 异步-深度获取对象属性
|
|
1780
|
+
* @param target 待获取的对象
|
|
1781
|
+
* @param handler 获取属性的回调
|
|
1782
|
+
*/
|
|
1783
|
+
asyncQueryProperty<T extends any = any>(target: any, handler: (target: T) => {
|
|
1767
1784
|
/**
|
|
1768
1785
|
* 是否是需要的属性
|
|
1769
1786
|
* + true 将目标值赋值给data
|
|
@@ -1774,7 +1791,18 @@ declare class Utils {
|
|
|
1774
1791
|
* 对象/目标值
|
|
1775
1792
|
*/
|
|
1776
1793
|
data: any;
|
|
1777
|
-
}
|
|
1794
|
+
} | Promise<{
|
|
1795
|
+
/**
|
|
1796
|
+
* 是否是需要的属性
|
|
1797
|
+
* + true 将目标值赋值给data
|
|
1798
|
+
* + false 不是需要的,data为下一个处理的对象
|
|
1799
|
+
*/
|
|
1800
|
+
isFind: boolean;
|
|
1801
|
+
/**
|
|
1802
|
+
* 对象/目标值
|
|
1803
|
+
*/
|
|
1804
|
+
data: any;
|
|
1805
|
+
}>): Promise<Awaited<T>>;
|
|
1778
1806
|
/**
|
|
1779
1807
|
* 创建一个新的Utils实例
|
|
1780
1808
|
* @param option
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { UtilsGMMenuConstructorOptions, UtilsGMMenuOption } from "./types/UtilsGMMenu";
|
|
2
|
-
declare class GMMenu {
|
|
2
|
+
export declare class GMMenu {
|
|
3
3
|
private GM_Api;
|
|
4
4
|
private MenuHandle;
|
|
5
5
|
constructor(details: UtilsGMMenuConstructorOptions);
|
|
@@ -118,4 +118,3 @@ declare class GMMenu {
|
|
|
118
118
|
*/
|
|
119
119
|
setLocalStorageKeyName(keyName: string): void;
|
|
120
120
|
}
|
|
121
|
-
export { GMMenu };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { WindowApiOption } from "./types/WindowApi";
|
|
2
|
-
declare class WindowApi {
|
|
2
|
+
export declare class WindowApi {
|
|
3
3
|
/** 默认的配置 */
|
|
4
4
|
private defaultApi;
|
|
5
5
|
/** 使用的配置 */
|
|
@@ -11,4 +11,3 @@ declare class WindowApi {
|
|
|
11
11
|
get self(): Window & typeof globalThis;
|
|
12
12
|
get top(): Window;
|
|
13
13
|
}
|
|
14
|
-
export { WindowApi };
|
|
@@ -40,8 +40,7 @@ declare interface DOMUtils_Frame_Object_Event {
|
|
|
40
40
|
scroll: Event;
|
|
41
41
|
unload: Event;
|
|
42
42
|
}
|
|
43
|
-
declare type DOMUtils_Frame_Object_EventType =
|
|
44
|
-
keyof DOMUtils_Frame_Object_Event;
|
|
43
|
+
declare type DOMUtils_Frame_Object_EventType = keyof DOMUtils_Frame_Object_Event;
|
|
45
44
|
/**
|
|
46
45
|
* 表单事件
|
|
47
46
|
*/
|