@whitesev/utils 2.7.1 → 2.7.2

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 (45) hide show
  1. package/dist/index.amd.js +168 -212
  2. package/dist/index.amd.js.map +1 -1
  3. package/dist/index.cjs.js +168 -212
  4. package/dist/index.cjs.js.map +1 -1
  5. package/dist/index.esm.js +168 -212
  6. package/dist/index.esm.js.map +1 -1
  7. package/dist/index.iife.js +168 -212
  8. package/dist/index.iife.js.map +1 -1
  9. package/dist/index.system.js +168 -212
  10. package/dist/index.system.js.map +1 -1
  11. package/dist/index.umd.js +168 -212
  12. package/dist/index.umd.js.map +1 -1
  13. package/dist/types/src/ColorConversion.d.ts +3 -8
  14. package/dist/types/src/Dictionary.d.ts +21 -14
  15. package/dist/types/src/GBKEncoder.d.ts +1 -2
  16. package/dist/types/src/Hooks.d.ts +1 -2
  17. package/dist/types/src/Httpx.d.ts +45 -46
  18. package/dist/types/src/LockFunction.d.ts +1 -2
  19. package/dist/types/src/Log.d.ts +1 -2
  20. package/dist/types/src/Progress.d.ts +1 -2
  21. package/dist/types/src/UtilsGMMenu.d.ts +1 -2
  22. package/dist/types/src/WindowApi.d.ts +1 -2
  23. package/dist/types/src/indexedDB.d.ts +1 -2
  24. package/dist/types/src/types/Httpx.d.ts +73 -67
  25. package/dist/types/src/types/env.d.ts +2 -0
  26. package/dist/types/src/types/global.d.ts +3 -0
  27. package/package.json +1 -1
  28. package/src/ColorConversion.ts +14 -25
  29. package/src/DOMUtils.ts +14 -16
  30. package/src/Dictionary.ts +39 -35
  31. package/src/GBKEncoder.ts +8 -12
  32. package/src/Hooks.ts +1 -3
  33. package/src/Httpx.ts +194 -174
  34. package/src/LockFunction.ts +3 -3
  35. package/src/Log.ts +1 -3
  36. package/src/Progress.ts +1 -3
  37. package/src/TryCatch.ts +4 -4
  38. package/src/Utils.ts +27 -43
  39. package/src/UtilsGMMenu.ts +19 -22
  40. package/src/Vue.ts +4 -7
  41. package/src/WindowApi.ts +2 -5
  42. package/src/indexedDB.ts +8 -8
  43. package/src/types/Httpx.d.ts +73 -67
  44. package/src/types/env.d.ts +2 -0
  45. 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
- * #ff0000 rgba(123,123,123, 0.4)
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 | null;
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(): UtilsDictionary<K, V>;
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
- get [Symbol.iterator](): () => IterableIterator<[K, V]>;
83
+ forEach(callbackfn: (value: V, key: K, dictionary: UtilsDictionary<K, V>) => void): void;
76
84
  }
77
- export { UtilsDictionary };
@@ -1,4 +1,4 @@
1
- declare class GBKEncoder {
1
+ export declare class GBKEncoder {
2
2
  #private;
3
3
  constructor();
4
4
  private handleText;
@@ -14,4 +14,3 @@ declare class GBKEncoder {
14
14
  */
15
15
  decode(str: string): string;
16
16
  }
17
- export { GBKEncoder };
@@ -1,4 +1,4 @@
1
- declare class Hooks {
1
+ export declare class Hooks {
2
2
  /**
3
3
  * 在Function原型上添加自定义方法.hook和.unhook
4
4
  */
@@ -8,4 +8,3 @@ declare class Hooks {
8
8
  */
9
9
  cleanEnv(): boolean;
10
10
  }
11
- export { Hooks };
@@ -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 HttpxCallBack;
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>(url: string, details: T): HttpxPromise<HttpxResponse<T>>;
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: T): HttpxPromise<HttpxResponse<T>>;
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>(url: string, details: T): HttpxPromise<HttpxResponse<T>>;
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>(url: string, details: T): HttpxPromise<HttpxResponse<T>>;
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>(url: string, details: T): HttpxPromise<HttpxResponse<T>>;
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>(url: string, details: T): HttpxPromise<HttpxResponse<T>>;
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>(url: string, details: T): HttpxPromise<HttpxResponse<T>>;
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 };
@@ -1,5 +1,5 @@
1
1
  import type { UtilsLogOptions } from "./types/Log";
2
- declare class Log {
2
+ export declare class Log {
3
3
  #private;
4
4
  /** 前面的TAG标志 */
5
5
  tag: string;
@@ -73,4 +73,3 @@ declare class Log {
73
73
  /** 恢复输出 */
74
74
  recovery(): void;
75
75
  }
76
- export { Log };
@@ -1,5 +1,5 @@
1
1
  import type { ProgressParamConfig } from "./types/Progress";
2
- declare class Progress {
2
+ export declare class Progress {
3
3
  #private;
4
4
  /**
5
5
  *
@@ -15,4 +15,3 @@ declare class Progress {
15
15
  */
16
16
  draw(): void;
17
17
  }
18
- export { Progress };
@@ -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 };
@@ -1,4 +1,4 @@
1
- declare class indexedDB {
1
+ export declare class indexedDB {
2
2
  #private;
3
3
  /**
4
4
  * @param dbName 数据存储名,默认为:default_db
@@ -129,4 +129,3 @@ declare class indexedDB {
129
129
  } & Event;
130
130
  }>;
131
131
  }
132
- export { indexedDB };
@@ -1039,24 +1039,23 @@ export declare interface HttpxAllowInterceptConfig {
1039
1039
  */
1040
1040
  export declare interface HttpxRequestOption {
1041
1041
  /**
1042
- * 网址
1042
+ * 请求的url
1043
1043
  */
1044
- url?: string;
1044
+ url: string;
1045
1045
  /**
1046
1046
  * 请求方法
1047
1047
  * @default "GET"
1048
1048
  */
1049
1049
  method?: HttpxMethod;
1050
1050
  /**
1051
- * 超时时间,默认5000,可为空
1051
+ * 请求的超时时间
1052
1052
  *
1053
- * fetchtrue时,该值不生效
1053
+ * 当`fetch`为`true`时,该值不生效,也就是请求不会超时
1054
1054
  * @default 5000
1055
1055
  */
1056
1056
  timeout?: number;
1057
1057
  /**
1058
1058
  * 响应类型,默认document,可为空
1059
- *
1060
1059
  * @default "document"
1061
1060
  */
1062
1061
  responseType?: keyof HttpxResponseTypeMap;
@@ -1070,39 +1069,39 @@ export declare interface HttpxRequestOption {
1070
1069
  data?: string | FormData | object;
1071
1070
  /**
1072
1071
  * 是否自动对data进行处理
1073
- * @default true
1074
- * 处理以下请求类型
1075
- * + GET 自动进行URLSearchParams转换
1076
- * + HEAD 自动进行URLSearchParams转换
1077
- * + POST 处理Content-Type不为空的情况
1078
1072
  *
1079
- * application/json
1073
+ * ## 处理以下请求类型
1074
+ * + `GET` 自动进行`URLSearchParams`转换
1075
+ * + `HEAD` 自动进行`URLSearchParams`转换
1076
+ * + `POST` 处理`Content-Type`不为空的情况
1077
+ *
1078
+ * ### `application/json`
1080
1079
  *
1081
- * + string: 不做处理
1082
- * + FormData: 转为JSON并进行JSON.stringify处理
1083
- * + object: 进行JSON.stringify处理
1080
+ * + `string`: 不做处理
1081
+ * + `FormData`: 转为`JSON`并进行`JSON.stringify`处理
1082
+ * + `object`: 进行`JSON.stringify`处理
1084
1083
  *
1085
- * application/x-www-form-urlencoded
1084
+ * ### `application/x-www-form-urlencoded`
1086
1085
  *
1087
- * + string: 不做处理
1088
- * + FormData: 转为URLSearchParams,再转为string
1089
- * + object: 转为URLSearchParams,再转为string
1086
+ * + `string`: 不做处理
1087
+ * + `FormData`: 转为`URLSearchParams`,再转为`string`
1088
+ * + `object`: 转为`URLSearchParams`,再转为`string`
1090
1089
  *
1091
- * multipart/form-data
1092
- * (上传文件专用)
1093
- * + string: 不做处理
1094
- * + FormData: 移除Content-Type
1095
- * + object: 不做处理
1090
+ * ### `multipart/form-data`(上传文件专用)
1091
+ *
1092
+ * + `string`: 不做处理
1093
+ * + `FormData`: 移除`Content-Type`
1094
+ * + `object`: 不做处理
1095
+ * @default true
1096
1096
  */
1097
1097
  processData?: boolean;
1098
1098
  /**
1099
- * 当触发重定向的使用规则,默认follow,可为空
1100
- *
1099
+ * 当触发重定向的使用规则
1101
1100
  * @default "follow"
1102
1101
  */
1103
1102
  redirect?: HttpxRedirect;
1104
1103
  /**
1105
- * 自定义Cookie,可为空
1104
+ * 自定义的Cookie
1106
1105
  */
1107
1106
  cookie?: string;
1108
1107
  /**
@@ -1126,52 +1125,53 @@ export declare interface HttpxRequestOption {
1126
1125
  topLevelSite?: string;
1127
1126
  };
1128
1127
  /**
1129
- * 以二进制模式发送数据字符串,可为空
1128
+ * 以二进制模式发送数据字符串
1130
1129
  */
1131
1130
  binary?: HttpxBinary;
1132
1131
  /**
1133
- * 是否缓存资源,默认true,可为空
1132
+ * 是否缓存资源
1133
+ * @default true
1134
1134
  */
1135
1135
  nocache?: boolean;
1136
1136
  /**
1137
- * 是否重新验证可能缓存的内容,默认true,可为空
1137
+ * 是否重新验证可能缓存的内容
1138
+ * @default true
1138
1139
  */
1139
1140
  revalidate?: boolean;
1140
1141
  /**
1141
- * 将该对象添加到响应的属性中,可为空
1142
+ * 自定义对象(自动存在响应里)
1142
1143
  */
1143
1144
  context?: any;
1144
1145
  /**
1145
- * 重写mimeType,可为空
1146
+ * 重写mimeType,默认不重写
1146
1147
  */
1147
1148
  overrideMimeType?: string;
1148
1149
  /**
1149
- * 是否匿名不发送Cookie,默认为false,可为空
1150
- *
1150
+ * 是否匿名不发送Cookie
1151
1151
  * @default false
1152
1152
  */
1153
1153
  anonymous?: boolean;
1154
1154
  /**
1155
- * 是否使用fetch来发送请求,默认为false,可为空
1156
- *
1155
+ * 是否使用fetch来发送请求
1157
1156
  * @default false
1158
1157
  */
1159
1158
  fetch?: boolean;
1160
1159
  /**
1161
- * 使用fetch请求的配置
1160
+ * 当`fetch`为`true`时的配置项,默认使用自定义的配置
1162
1161
  */
1163
1162
  fetchInit?: HttpxRequestInit;
1164
1163
  /**
1165
1164
  * 拒绝拦截配置
1165
+ *
1166
1166
  * 如果设置了相关配置,那么intercept将不会生效
1167
1167
  */
1168
1168
  allowInterceptConfig?: Partial<HttpxAllowInterceptConfig> | boolean;
1169
1169
  /**
1170
- * 身份验证的用户名
1170
+ * (可选)身份验证的用户名
1171
1171
  */
1172
1172
  user?: string;
1173
1173
  /**
1174
- * 身份验证的密码
1174
+ * (可选)身份验证的密码
1175
1175
  */
1176
1176
  password?: string;
1177
1177
  /**
@@ -1197,13 +1197,13 @@ export declare interface HttpxRequestOption {
1197
1197
  /**
1198
1198
  * (可选)当请求状态改变,触发该回调
1199
1199
  *
1200
- * fetchtrue时该回调不触发
1200
+ * `fetch`为`true`时该回调不会触发
1201
1201
  */
1202
1202
  onreadystatechange?: (...args: any[]) => void;
1203
1203
  /**
1204
1204
  * (可选)当请求上传文件进度改变,触发该回调
1205
1205
  *
1206
- * fetchtrue时该回调不触发
1206
+ * `fetch`为`true`时该回调不会触发
1207
1207
  */
1208
1208
  onprogress?: (...args: any[]) => void;
1209
1209
  }
@@ -1216,12 +1216,12 @@ export declare interface HttpxRequestOptionConfig extends HttpxInitOption {}
1216
1216
  */
1217
1217
  export declare interface HttpxResponseData<T extends HttpxRequestOption> {
1218
1218
  /**
1219
- * 如果fetchtrue,且返回的headers中的Content-Type存在text/event-stream或者是主动设置的responseTypestream
1220
- * 则存在该属性为true
1219
+ * 当请求中配置`fetch`为`true`时,且返回的`headers`中的`Content-Type`存在`text/event-stream`或者是主动设置的`responseType`为`stream`
1220
+ * 则存在该属性为`true`
1221
1221
  */
1222
1222
  isStream?: boolean;
1223
1223
  /**
1224
- * 如果fetchtrue,则存在该属性为true
1224
+ * 当请求中配置`fetch`为`true`时,则存在该属性为`true`
1225
1225
  */
1226
1226
  isFetch?: boolean;
1227
1227
  /**
@@ -1230,31 +1230,31 @@ export declare interface HttpxResponseData<T extends HttpxRequestOption> {
1230
1230
  finalUrl: string;
1231
1231
  /**
1232
1232
  * 数据准备状态
1233
- * + 0 未初始化
1234
- * + 1 载入
1235
- * + 2 载入完成
1236
- * + 3 交互
1237
- * + 4 完成
1233
+ * + `0`:未初始化
1234
+ * + `1`:载入
1235
+ * + `2`:载入完成
1236
+ * + `3`:交互
1237
+ * + `4`:完成
1238
1238
  *
1239
- * 当请求头fetchtrue时,该值固定为4
1239
+ * 当请求中配置`fetch`为`true`时,该值固定为`4`
1240
1240
  */
1241
1241
  readyState: 0 | 1 | 2 | 3 | 4;
1242
1242
  /**
1243
- * 状态码,2xx为成功
1243
+ * 响应的状态码,2xx为成功
1244
1244
  */
1245
1245
  status: HttpxStatus | number;
1246
1246
  /**
1247
- * 关于status的解释
1247
+ * 对`status`的解释
1248
1248
  */
1249
1249
  statusText: "OK" | "" | string;
1250
1250
  /**
1251
- * 响应内容,根据responseType,如果是html,那就是Document类型,如果是json,那么类型是Object类型
1251
+ * 响应内容,根据`responseType`,如果是`html`,那就是`Document`类型,如果是`json`,那么类型是`Object`类型
1252
1252
  */
1253
1253
  response: T["responseType"] extends keyof HttpxResponseTypeMap
1254
1254
  ? HttpxResponseTypeMap[T["responseType"]]
1255
1255
  : HttpxResponseTypeMap["html"];
1256
1256
  /**
1257
- * 当请求头fetchtrue时,该属性存在
1257
+ * 当请求中配置`fetch`为`true`时,该属性存在
1258
1258
  */
1259
1259
  responseFetchHeaders?: Headers;
1260
1260
  /**
@@ -1266,7 +1266,7 @@ export declare interface HttpxResponseData<T extends HttpxRequestOption> {
1266
1266
  */
1267
1267
  responseText: string;
1268
1268
  /**
1269
- * 是请求中设置的responseType,没有设置的话默认为undefined
1269
+ * 请求中配置的`responseType`,没有的话默认为`undefined`
1270
1270
  */
1271
1271
  responseType?: T["responseType"];
1272
1272
  /**
@@ -1281,14 +1281,14 @@ export declare interface HttpxResponse<T extends HttpxRequestOption> {
1281
1281
  /**
1282
1282
  * 是否请求成功
1283
1283
  *
1284
- * 状态码在200-300之间为true,否则为false
1284
+ * 状态码在`200-300`之间为`true`,否则为`false`
1285
1285
  */
1286
1286
  status: boolean;
1287
1287
  /**
1288
1288
  * 响应状态码
1289
1289
  *
1290
- * + -1 onabort触发
1291
- * + 0 ontimeout触发
1290
+ * + `-1` 触发来源:`onabort`
1291
+ * + `0` 触发来源:`ontimeout`
1292
1292
  */
1293
1293
  statusCode: HttpxStatus | number;
1294
1294
  /**
@@ -1313,13 +1313,21 @@ export declare interface HttpxResponse<T extends HttpxRequestOption> {
1313
1313
  * httpx的hook错误的回调数据
1314
1314
  */
1315
1315
  export declare interface HttpxHookErrorData {
1316
- /** 触发的函数名 */
1316
+ /**
1317
+ * 触发的函数名
1318
+ */
1317
1319
  type: "onerror" | "ontimeout" | "onabort";
1318
- /** 触发的错误 */
1320
+ /**
1321
+ * 触发的错误
1322
+ */
1319
1323
  error: Error;
1320
- /** 触发的响应 */
1324
+ /**
1325
+ * 触发的响应
1326
+ */
1321
1327
  response: any;
1322
- /** 请求的配置 */
1328
+ /**
1329
+ * 请求的配置
1330
+ */
1323
1331
  details: HttpxRequestOption;
1324
1332
  }
1325
1333
 
@@ -1335,20 +1343,18 @@ export declare interface HttpxPromise<T> extends Promise<T> {
1335
1343
  */
1336
1344
  export declare interface HttpxInitOption extends HttpxRequestOption {
1337
1345
  /**
1338
- * 实例化,可传入GM_xmlhttpRequest,未传入则使用window.fetch
1346
+ * 实例化,可传入`GM_xmlhttpRequest`,未传入则使用`window.fetch`
1339
1347
  */
1340
1348
  xmlHttpRequest?: Function;
1341
1349
  /**
1342
1350
  * `baseURL` 将自动加在 `url` 前面,除非 `url` 是一个绝对 URL。
1343
1351
  */
1344
1352
  baseURL?: string | undefined;
1345
- /**
1346
- * 重试次数
1347
- * @default 0
1348
- */
1349
- retry?: number;
1350
1353
  /**
1351
1354
  * (可选)是否输出请求配置
1352
1355
  */
1353
1356
  logDetails?: boolean;
1354
1357
  }
1358
+
1359
+ export declare interface HttpxRequestOptionWithDoubleParams
1360
+ extends Omit<HttpxRequestOption, "url"> {}
@@ -0,0 +1,2 @@
1
+ declare var jQuery: any;
2
+ declare var unsafeWindow: Window;
@@ -18,11 +18,14 @@ export type ArgsType<T extends JSTypeNames[]> = {
18
18
  export declare interface UtilsOwnObject<V extends any> {
19
19
  [key: string]: V | UtilsOwnObject<V>;
20
20
  }
21
+
21
22
  export declare interface AnyObject {
22
23
  [key: string]: any | AnyObject;
23
24
  toString(): string;
24
25
  }
26
+
25
27
  export type PartialKeys<T, K extends keyof T> = {
26
28
  [P in K]?: T[P];
27
29
  };
30
+
28
31
  export type Values<T> = T[keyof T];