@whitesev/utils 1.9.8 → 2.0.1
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/package.json +4 -3
- package/src/AjaxHookerType.ts +155 -0
- package/src/ColorConversion.ts +130 -0
- package/src/Dictionary.ts +161 -0
- package/src/Event.ts +189 -0
- package/src/GBKEncoder.ts +121 -0
- package/src/Hooks.ts +87 -0
- package/src/Httpx.ts +2524 -0
- package/src/LockFunction.ts +67 -0
- package/src/Log.ts +285 -0
- package/src/Progress.ts +149 -0
- package/src/TryCatch.ts +107 -0
- package/src/Utils.ts +4937 -0
- package/src/UtilsCommon.ts +20 -0
- package/src/UtilsCore.ts +47 -0
- package/src/UtilsGMCookie.ts +262 -0
- package/src/UtilsGMMenu.ts +532 -0
- package/src/VueObject.ts +128 -0
- package/src/ajaxHooker/ajaxHooker.js +566 -0
- package/src/indexedDB.ts +427 -0
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whitesev/utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "一个常用的工具库",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
|
-
"module": "dist/
|
|
6
|
+
"module": "dist/index.esm.js",
|
|
7
7
|
"types": "dist/types/index.d.ts",
|
|
8
8
|
"jsdelivr": "dist/index.umd.js",
|
|
9
9
|
"exports": {
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
18
|
-
"dist"
|
|
18
|
+
"dist",
|
|
19
|
+
"src"
|
|
19
20
|
],
|
|
20
21
|
"publishConfig": {
|
|
21
22
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import type { HttpxHeaders, HttpxMethod, HttpxStatus } from "./Httpx";
|
|
2
|
+
|
|
3
|
+
/** 请求的response配置 */
|
|
4
|
+
export declare interface UtilsAjaxHookResponseOptions {
|
|
5
|
+
/**
|
|
6
|
+
* (重定向后的)Url
|
|
7
|
+
*/
|
|
8
|
+
finalUrl: string;
|
|
9
|
+
/**
|
|
10
|
+
* 响应码
|
|
11
|
+
*/
|
|
12
|
+
status: HttpxStatus;
|
|
13
|
+
/**
|
|
14
|
+
* 响应头
|
|
15
|
+
*/
|
|
16
|
+
responseHeaders: HttpxHeaders;
|
|
17
|
+
/**
|
|
18
|
+
* 响应内容
|
|
19
|
+
*/
|
|
20
|
+
response?: string | Blob | ArrayBuffer | XMLDocument | FormData;
|
|
21
|
+
/**
|
|
22
|
+
* 响应内容文本
|
|
23
|
+
*/
|
|
24
|
+
responseText?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** hook请求的配置 */
|
|
28
|
+
export declare interface UtilsAjaxHookRequestOptions {
|
|
29
|
+
/**
|
|
30
|
+
* 只读属性。一个字符串,表明请求类型是xhr还是fetch
|
|
31
|
+
*/
|
|
32
|
+
type: "xhr";
|
|
33
|
+
/**
|
|
34
|
+
* 请求的Url
|
|
35
|
+
*/
|
|
36
|
+
url: string;
|
|
37
|
+
/**
|
|
38
|
+
* 请求的url和method,可以直接修改
|
|
39
|
+
*/
|
|
40
|
+
method: HttpxMethod;
|
|
41
|
+
/**
|
|
42
|
+
* 是否取消请求,设置为true即可取消本次请求
|
|
43
|
+
*/
|
|
44
|
+
abort: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* 请求头,可以直接修改
|
|
47
|
+
*/
|
|
48
|
+
headers: HttpxHeaders;
|
|
49
|
+
/**
|
|
50
|
+
* 请求携带的数据,可以直接修改
|
|
51
|
+
*/
|
|
52
|
+
data?: any;
|
|
53
|
+
/**
|
|
54
|
+
* 响应内容,必须通过一个回调函数进行读取和修改。
|
|
55
|
+
*
|
|
56
|
+
* 响应内容为一个对象,包含finalUrl、status、responseHeaders和被读取的响应数据,除响应数据可修改,其他属性是只读的。
|
|
57
|
+
*
|
|
58
|
+
* 响应数据是哪个属性取决于哪个属性被读取,xhr可能的属性为response、responseText、responseXML,fetch可能的属性为arrayBuffer、blob、formData、json、text。
|
|
59
|
+
*
|
|
60
|
+
* 在控制台输出时,xhr响应将包含所有属性,但只有被读取过的属性具有明确的值。修改对应属性即可影响读取结果,进而实现响应数据的修改。
|
|
61
|
+
*/
|
|
62
|
+
response?: (res: Required<UtilsAjaxHookResponseOptions>) => void;
|
|
63
|
+
/**
|
|
64
|
+
* 只读属性。异步请求为true,同步请求为false,异步特性无法作用于同步请求
|
|
65
|
+
*/
|
|
66
|
+
async: boolean;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** 过滤规则配置 */
|
|
70
|
+
export declare interface UtilsAjaxHookFilterOptions {
|
|
71
|
+
/**
|
|
72
|
+
* 应是xhr或fetch
|
|
73
|
+
*/
|
|
74
|
+
type?: "xhr" | "fetch";
|
|
75
|
+
/**
|
|
76
|
+
* 字符串或正则表达式,无需完全匹配
|
|
77
|
+
*/
|
|
78
|
+
url?: string;
|
|
79
|
+
/**
|
|
80
|
+
* 请求方法
|
|
81
|
+
*/
|
|
82
|
+
method?: HttpxMethod;
|
|
83
|
+
/**
|
|
84
|
+
* 是否异步
|
|
85
|
+
*/
|
|
86
|
+
async?: boolean;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Utils.ajaxHooker */
|
|
90
|
+
export declare interface UtilsAjaxHookResult {
|
|
91
|
+
/**
|
|
92
|
+
* 劫持
|
|
93
|
+
* @example
|
|
94
|
+
ajaxHooker.hook(request => {
|
|
95
|
+
if (request.url === 'https://www.example.com/') {
|
|
96
|
+
request.response = res => {
|
|
97
|
+
console.log(res);
|
|
98
|
+
res.responseText += 'test';
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
* @example
|
|
103
|
+
// 异步特性无法作用于同步请求,但同步修改仍然有效
|
|
104
|
+
// 你可以将以上所有可修改属性赋值为Promise,原请求将被阻塞直至Promise完成(若发生reject,数据将不会被修改)
|
|
105
|
+
// 此特性可用于异步劫持。以下是一个异步修改响应数据的例子
|
|
106
|
+
ajaxHooker.hook(request => {
|
|
107
|
+
request.response = res => {
|
|
108
|
+
const responseText = res.responseText; // 注意保存原数据
|
|
109
|
+
res.responseText = new Promise(resolve => {
|
|
110
|
+
setTimeout(() => {
|
|
111
|
+
resolve(responseText + 'test');
|
|
112
|
+
}, 3000);
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// 也可以传入async回调函数以实现异步
|
|
118
|
+
ajaxHooker.hook(async request => {
|
|
119
|
+
request.data = await modifyData(request.data);
|
|
120
|
+
request.response = async res => {
|
|
121
|
+
res.responseText = await modifyResponse(res.responseText);
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
*/
|
|
125
|
+
hook(
|
|
126
|
+
callback: (
|
|
127
|
+
request: UtilsAjaxHookRequestOptions
|
|
128
|
+
) => void | Promise<undefined>
|
|
129
|
+
): void;
|
|
130
|
+
/**
|
|
131
|
+
* 过滤
|
|
132
|
+
* @example
|
|
133
|
+
// 应于hook方法之前执行,此方法若尽早执行,有助于提升性能。
|
|
134
|
+
// 为hook方法设置过滤规则,只有符合规则的请求才会触发hook。过滤规则是一个对象数组,参考下例
|
|
135
|
+
ajaxHooker.filter([
|
|
136
|
+
{type: 'xhr', url: 'www.example.com', method: 'GET', async: true},
|
|
137
|
+
{url: /^http/},
|
|
138
|
+
]);
|
|
139
|
+
*/
|
|
140
|
+
filter(filterOptions: UtilsAjaxHookFilterOptions[]): void;
|
|
141
|
+
/**
|
|
142
|
+
* 阻止xhr和fetch被改写
|
|
143
|
+
* @example
|
|
144
|
+
// 如果库劫持失败,可能是其他代码对xhr/fetch进行了二次劫持,protect方法会尝试阻止xhr和fetch被改写。应于document-start阶段尽早执行,部分网页下可能引发错误,谨慎使用。
|
|
145
|
+
ajaxHooker.protect();
|
|
146
|
+
*/
|
|
147
|
+
protect(): void;
|
|
148
|
+
/**
|
|
149
|
+
* 取消劫持
|
|
150
|
+
* @example
|
|
151
|
+
// 将xhr和fetch恢复至劫持前的状态,调用此方法后,hook方法不再生效。
|
|
152
|
+
ajaxHooker.unhook();
|
|
153
|
+
*/
|
|
154
|
+
unhook(): void;
|
|
155
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
class ColorConversion {
|
|
2
|
+
/**
|
|
3
|
+
* 判断是否是16进制颜色
|
|
4
|
+
* @param str
|
|
5
|
+
*/
|
|
6
|
+
isHex(str: string): boolean {
|
|
7
|
+
if (typeof str !== "string") {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
if (!str.match(/^(\#|)[0-9a-fA-F]{6}$/)) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 16进制颜色转rgba
|
|
17
|
+
*
|
|
18
|
+
* #ff0000 转 rgba(123,123,123, 0.4)
|
|
19
|
+
* @param hex
|
|
20
|
+
* @param opacity
|
|
21
|
+
*/
|
|
22
|
+
hexToRgba(hex: string, opacity: number): string {
|
|
23
|
+
if (!this.isHex(hex)) {
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
throw new TypeError("输入错误的hex", hex);
|
|
26
|
+
}
|
|
27
|
+
return hex && hex.replace(/\s+/g, "").length === 7
|
|
28
|
+
? "rgba(" +
|
|
29
|
+
parseInt("0x" + hex.slice(1, 3)) +
|
|
30
|
+
"," +
|
|
31
|
+
parseInt("0x" + hex.slice(3, 5)) +
|
|
32
|
+
"," +
|
|
33
|
+
parseInt("0x" + hex.slice(5, 7)) +
|
|
34
|
+
"," +
|
|
35
|
+
opacity +
|
|
36
|
+
")"
|
|
37
|
+
: "";
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* hex转rgb
|
|
41
|
+
* @param str
|
|
42
|
+
* @returns
|
|
43
|
+
*/
|
|
44
|
+
hexToRgb(str: string) {
|
|
45
|
+
if (!this.isHex(str)) {
|
|
46
|
+
// @ts-ignore
|
|
47
|
+
throw new TypeError("输入错误的hex", str);
|
|
48
|
+
}
|
|
49
|
+
/* replace替换查找的到的字符串 */
|
|
50
|
+
str = str.replace("#", "");
|
|
51
|
+
/* match得到查询数组 */
|
|
52
|
+
let hxs = str.match(/../g);
|
|
53
|
+
for (let index = 0; index < 3; index++) {
|
|
54
|
+
// @ts-ignore
|
|
55
|
+
hxs[index] = parseInt(hxs[index], 16);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return hxs;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* rgb转hex
|
|
62
|
+
* @param redValue
|
|
63
|
+
* @param greenValue
|
|
64
|
+
* @param blueValue
|
|
65
|
+
* @returns
|
|
66
|
+
*/
|
|
67
|
+
rgbToHex(
|
|
68
|
+
redValue: string | number,
|
|
69
|
+
greenValue: string | number,
|
|
70
|
+
blueValue: string | number
|
|
71
|
+
): string {
|
|
72
|
+
/* 验证输入的rgb值是否合法 */
|
|
73
|
+
let validPattern = /^\d{1,3}$/;
|
|
74
|
+
if (
|
|
75
|
+
!validPattern.test(redValue.toString()) ||
|
|
76
|
+
!validPattern.test(greenValue.toString()) ||
|
|
77
|
+
!validPattern.test(blueValue.toString())
|
|
78
|
+
)
|
|
79
|
+
throw new TypeError("输入错误的rgb颜色值");
|
|
80
|
+
let hexs = [
|
|
81
|
+
redValue.toString(16),
|
|
82
|
+
greenValue.toString(16),
|
|
83
|
+
blueValue.toString(16),
|
|
84
|
+
];
|
|
85
|
+
for (let index = 0; index < 3; index++)
|
|
86
|
+
if (hexs[index].length == 1) hexs[index] = "0" + hexs[index];
|
|
87
|
+
return "#" + hexs.join("");
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* 获取颜色变暗或亮
|
|
91
|
+
* @param color 颜色
|
|
92
|
+
* @param level 0~1.0
|
|
93
|
+
* @returns
|
|
94
|
+
*/
|
|
95
|
+
getDarkColor(color: string, level: string): string {
|
|
96
|
+
if (!this.isHex(color)) {
|
|
97
|
+
// @ts-ignore
|
|
98
|
+
throw new TypeError("输入错误的hex", color);
|
|
99
|
+
}
|
|
100
|
+
let rgbc = this.hexToRgb(color);
|
|
101
|
+
for (let index = 0; index < 3; index++) {
|
|
102
|
+
// @ts-ignore
|
|
103
|
+
rgbc[index] = Math.floor(rgbc[index] * (1 - level));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// @ts-ignore
|
|
107
|
+
return this.rgbToHex(rgbc[0], rgbc[1], rgbc[2]);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* 获取颜色变亮
|
|
111
|
+
* @param color 颜色
|
|
112
|
+
* @param level 0~1.0
|
|
113
|
+
* @returns
|
|
114
|
+
*/
|
|
115
|
+
getLightColor(color: string, level: number): string {
|
|
116
|
+
if (!this.isHex(color)) {
|
|
117
|
+
// @ts-ignore
|
|
118
|
+
throw new TypeError("输入错误的hex", color);
|
|
119
|
+
}
|
|
120
|
+
let rgbc = this.hexToRgb(color);
|
|
121
|
+
for (let index = 0; index < 3; index++) {
|
|
122
|
+
// @ts-ignore
|
|
123
|
+
rgbc[index] = Math.floor((255 - rgbc[index]) * level + rgbc[index]);
|
|
124
|
+
}
|
|
125
|
+
// @ts-ignore
|
|
126
|
+
return this.rgbToHex(rgbc[0], rgbc[1], rgbc[2]);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export { ColorConversion };
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { Utils } from "./Utils";
|
|
2
|
+
|
|
3
|
+
class UtilsDictionary<K, V> {
|
|
4
|
+
private items: {
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
[key: K]: V;
|
|
7
|
+
} = {};
|
|
8
|
+
constructor();
|
|
9
|
+
constructor(key: K, value: V);
|
|
10
|
+
constructor(key?: K, value?: V) {
|
|
11
|
+
if (key != null) {
|
|
12
|
+
this.set(key, value!);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 检查是否有某一个键
|
|
17
|
+
* @param key 键
|
|
18
|
+
*/
|
|
19
|
+
has(key: K): boolean {
|
|
20
|
+
return Reflect.has(this.items, key as PropertyKey);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 检查已有的键中是否以xx开头
|
|
24
|
+
* @param key 需要匹配的键
|
|
25
|
+
*/
|
|
26
|
+
startsWith(key: K): boolean {
|
|
27
|
+
let allKeys = this.keys();
|
|
28
|
+
for (const keyName of allKeys) {
|
|
29
|
+
if (String(keyName).startsWith(String(key))) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 获取以xx开头的键的值
|
|
37
|
+
* @param key 需要匹配的键
|
|
38
|
+
*/
|
|
39
|
+
getStartsWith(key: K): V | undefined {
|
|
40
|
+
let allKeys = this.keys();
|
|
41
|
+
let result: V | undefined = void 0;
|
|
42
|
+
for (const keyName of allKeys) {
|
|
43
|
+
if (String(keyName).startsWith(String(key))) {
|
|
44
|
+
result = this.get(keyName as K)!;
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 为字典添加某一个值
|
|
52
|
+
* @param key 键
|
|
53
|
+
* @param val 值,默认为""
|
|
54
|
+
*/
|
|
55
|
+
set(key: K, val: V): void {
|
|
56
|
+
if (key === void 0) {
|
|
57
|
+
throw new Error("Utils.Dictionary().set 参数 key 不能为空");
|
|
58
|
+
}
|
|
59
|
+
Reflect.set(this.items, key as PropertyKey, val);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* 删除某一个键
|
|
63
|
+
* @param key 键
|
|
64
|
+
*/
|
|
65
|
+
delete(key: K): boolean {
|
|
66
|
+
if (this.has(key)) {
|
|
67
|
+
return Reflect.deleteProperty(this.items, key as string);
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* 获取某个键的值
|
|
73
|
+
* https://github.com/microsoft/TypeScript/issues/9619
|
|
74
|
+
* 微软到现在都没有修复has和get的联动
|
|
75
|
+
* @param key 键
|
|
76
|
+
*/
|
|
77
|
+
get(key: K): V {
|
|
78
|
+
return Reflect.get(this.items, key as PropertyKey) as V;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* 返回字典中的所有值
|
|
82
|
+
*/
|
|
83
|
+
values(): V[] {
|
|
84
|
+
let resultList: V[] = [];
|
|
85
|
+
for (let prop in this.getItems()) {
|
|
86
|
+
if (this.has(prop as K)) {
|
|
87
|
+
resultList.push(this.get(prop as K)!);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return resultList;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* 清空字典
|
|
94
|
+
*/
|
|
95
|
+
clear() {
|
|
96
|
+
this.items = null as any;
|
|
97
|
+
this.items = {};
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* 获取字典的长度
|
|
101
|
+
*/
|
|
102
|
+
size(): number {
|
|
103
|
+
return Object.keys(this.getItems()).length;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* 获取字典所有的键
|
|
107
|
+
*/
|
|
108
|
+
keys(): (string | symbol)[] {
|
|
109
|
+
return Reflect.ownKeys(this.items);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* 返回字典本身
|
|
113
|
+
*/
|
|
114
|
+
getItems(): UtilsDictionary<K, V> {
|
|
115
|
+
// @ts-ignore
|
|
116
|
+
return this.items;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* 合并另一个字典
|
|
120
|
+
* @param data 需要合并的字典
|
|
121
|
+
*/
|
|
122
|
+
concat(data: UtilsDictionary<K, V>) {
|
|
123
|
+
this.items = Utils.assign(this.items, data.getItems());
|
|
124
|
+
}
|
|
125
|
+
forEach(
|
|
126
|
+
callbackfn: (value: V, key: K, dictionary: UtilsDictionary<K, V>) => void
|
|
127
|
+
) {
|
|
128
|
+
for (const key in this.getItems()) {
|
|
129
|
+
callbackfn(this.get(key as any) as V, key as K, this.getItems() as any);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* 获取字典的长度,同this.size
|
|
134
|
+
*/
|
|
135
|
+
get length() {
|
|
136
|
+
return this.size();
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* 迭代器
|
|
140
|
+
*/
|
|
141
|
+
get entries() {
|
|
142
|
+
let that = this;
|
|
143
|
+
return function* (): IterableIterator<[K, V]> {
|
|
144
|
+
let itemKeys = Object.keys(that.getItems());
|
|
145
|
+
for (const keyName of itemKeys) {
|
|
146
|
+
yield [keyName as K, that.get(keyName as K) as V];
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* 是否可遍历
|
|
152
|
+
*/
|
|
153
|
+
get [Symbol.iterator]() {
|
|
154
|
+
let that = this;
|
|
155
|
+
return function () {
|
|
156
|
+
return that.entries();
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export { UtilsDictionary };
|
package/src/Event.ts
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 鼠标事件
|
|
3
|
+
* + https://blog.csdn.net/weixin_68658847/article/details/126939879
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
declare interface DOMUtils_MouseEvent {
|
|
7
|
+
click: MouseEvent | PointerEvent;
|
|
8
|
+
contextmenu: MouseEvent | PointerEvent;
|
|
9
|
+
dblclick: MouseEvent | PointerEvent;
|
|
10
|
+
mousedown: MouseEvent | PointerEvent;
|
|
11
|
+
mouseenter: MouseEvent | PointerEvent;
|
|
12
|
+
mouseleave: MouseEvent | PointerEvent;
|
|
13
|
+
mousemove: MouseEvent | PointerEvent;
|
|
14
|
+
mouseover: MouseEvent | PointerEvent;
|
|
15
|
+
mouseout: MouseEvent | PointerEvent;
|
|
16
|
+
mouseup: MouseEvent | PointerEvent;
|
|
17
|
+
}
|
|
18
|
+
declare type DOMUtils_MouseEventType = keyof DOMUtils_MouseEvent;
|
|
19
|
+
/**
|
|
20
|
+
* 鼠标事件
|
|
21
|
+
*/
|
|
22
|
+
declare interface DOMUtils_KeyboardEvent {
|
|
23
|
+
keydown: KeyboardEvent;
|
|
24
|
+
keypress: KeyboardEvent;
|
|
25
|
+
keyup: KeyboardEvent;
|
|
26
|
+
}
|
|
27
|
+
declare type DOMUtils_KeyboardEventType = keyof DOMUtils_KeyboardEvent;
|
|
28
|
+
/**
|
|
29
|
+
* 框架/对象事件
|
|
30
|
+
*/
|
|
31
|
+
declare interface DOMUtils_Frame_Object_Event {
|
|
32
|
+
abort: Event;
|
|
33
|
+
beforeunload: Event;
|
|
34
|
+
error: Event;
|
|
35
|
+
hashchange: Event;
|
|
36
|
+
load: Event;
|
|
37
|
+
pageshow: Event;
|
|
38
|
+
pagehide: Event;
|
|
39
|
+
resize: Event;
|
|
40
|
+
scroll: Event;
|
|
41
|
+
unload: Event;
|
|
42
|
+
}
|
|
43
|
+
declare type DOMUtils_Frame_Object_EventType =
|
|
44
|
+
keyof DOMUtils_Frame_Object_Event;
|
|
45
|
+
/**
|
|
46
|
+
* 表单事件
|
|
47
|
+
*/
|
|
48
|
+
declare interface DOMUtils_FormEvent {
|
|
49
|
+
blur: Event;
|
|
50
|
+
change: Event;
|
|
51
|
+
focus: Event;
|
|
52
|
+
focusin: Event;
|
|
53
|
+
focusout: Event;
|
|
54
|
+
input: Event;
|
|
55
|
+
reset: Event;
|
|
56
|
+
search: Event;
|
|
57
|
+
}
|
|
58
|
+
declare type DOMUtils_FormEventType = keyof DOMUtils_FormEvent;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 剪贴板事件
|
|
62
|
+
*/
|
|
63
|
+
declare interface DOMUtils_ClipboardEvent {
|
|
64
|
+
copy: ClipboardEvent;
|
|
65
|
+
cut: ClipboardEvent;
|
|
66
|
+
paste: ClipboardEvent;
|
|
67
|
+
}
|
|
68
|
+
declare type DOMUtils_ClipboardEventType = keyof DOMUtils_ClipboardEvent;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* 打印事件
|
|
72
|
+
*/
|
|
73
|
+
declare interface DOMUtils_PrintEvent {
|
|
74
|
+
afterprint: Event;
|
|
75
|
+
beforeprint: Event;
|
|
76
|
+
}
|
|
77
|
+
declare type DOMUtils_PrintEventType = keyof DOMUtils_PrintEvent;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* 拖动事件
|
|
81
|
+
*/
|
|
82
|
+
declare interface DOMUtils_DragEvent {
|
|
83
|
+
drag: DragEvent;
|
|
84
|
+
dragend: DragEvent;
|
|
85
|
+
dragenter: DragEvent;
|
|
86
|
+
dragleave: DragEvent;
|
|
87
|
+
dragover: DragEvent;
|
|
88
|
+
dragstart: DragEvent;
|
|
89
|
+
drop: DragEvent;
|
|
90
|
+
}
|
|
91
|
+
declare type DOMUtils_DragEventType = keyof DOMUtils_DragEvent;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* 多媒体(Media)事件
|
|
95
|
+
*/
|
|
96
|
+
declare interface DOMUtils_MediaEvent {
|
|
97
|
+
abort: Event;
|
|
98
|
+
canplay: Event;
|
|
99
|
+
canplaythrough: Event;
|
|
100
|
+
durationchange: Event;
|
|
101
|
+
emptied: Event;
|
|
102
|
+
ended: Event;
|
|
103
|
+
error: Event;
|
|
104
|
+
loadeddata: Event;
|
|
105
|
+
loadedmetadata: Event;
|
|
106
|
+
loadstart: Event;
|
|
107
|
+
pause: Event;
|
|
108
|
+
play: Event;
|
|
109
|
+
playing: Event;
|
|
110
|
+
progress: Event;
|
|
111
|
+
ratechange: Event;
|
|
112
|
+
seeked: Event;
|
|
113
|
+
seeking: Event;
|
|
114
|
+
stalled: Event;
|
|
115
|
+
suspend: Event;
|
|
116
|
+
timeupdate: Event;
|
|
117
|
+
volumechange: Event;
|
|
118
|
+
waiting: Event;
|
|
119
|
+
}
|
|
120
|
+
declare type DOMUtils_MediaEventType = keyof DOMUtils_MediaEvent;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* 动画事件
|
|
124
|
+
*/
|
|
125
|
+
declare interface DOMUtils_AnimationEvent {
|
|
126
|
+
animationend: AnimationEvent;
|
|
127
|
+
animationiteration: AnimationEvent;
|
|
128
|
+
animationstart: AnimationEvent;
|
|
129
|
+
}
|
|
130
|
+
declare type DOMUtils_AnimationEventType = keyof DOMUtils_AnimationEvent;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* 过渡事件
|
|
134
|
+
*/
|
|
135
|
+
declare interface DOMUtils_TransitionEvent {
|
|
136
|
+
transitionend: TransitionEvent;
|
|
137
|
+
}
|
|
138
|
+
declare type DOMUtils_TransitionEventType = keyof DOMUtils_TransitionEvent;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* 触摸事件
|
|
142
|
+
*/
|
|
143
|
+
declare interface DOMUtils_TouchEvent {
|
|
144
|
+
touchstart: TouchEvent;
|
|
145
|
+
touchmove: TouchEvent;
|
|
146
|
+
touchend: TouchEvent;
|
|
147
|
+
touchcancel: TouchEvent;
|
|
148
|
+
touchenter: TouchEvent;
|
|
149
|
+
touchleave: TouchEvent;
|
|
150
|
+
}
|
|
151
|
+
declare type DOMUtils_TouchEventType = keyof DOMUtils_TouchEvent;
|
|
152
|
+
/**
|
|
153
|
+
* 其它事件
|
|
154
|
+
*/
|
|
155
|
+
declare interface DOMUtils_OtherEvent {
|
|
156
|
+
message: Event;
|
|
157
|
+
online: Event;
|
|
158
|
+
offline: Event;
|
|
159
|
+
popstate: Event;
|
|
160
|
+
show: Event;
|
|
161
|
+
storage: Event;
|
|
162
|
+
toggle: Event;
|
|
163
|
+
wheel: Event;
|
|
164
|
+
propertychange: Event;
|
|
165
|
+
fullscreenchange: Event;
|
|
166
|
+
DOMContentLoaded: Event;
|
|
167
|
+
}
|
|
168
|
+
declare type DOMUtils_OtherEventType = keyof DOMUtils_OtherEvent;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* 全部事件
|
|
172
|
+
*/
|
|
173
|
+
export declare type DOMUtils_Event = DOMUtils_MouseEvent &
|
|
174
|
+
DOMUtils_KeyboardEvent &
|
|
175
|
+
DOMUtils_Frame_Object_Event &
|
|
176
|
+
DOMUtils_FormEvent &
|
|
177
|
+
DOMUtils_ClipboardEvent &
|
|
178
|
+
DOMUtils_PrintEvent &
|
|
179
|
+
DOMUtils_DragEvent &
|
|
180
|
+
DOMUtils_MediaEvent &
|
|
181
|
+
DOMUtils_AnimationEvent &
|
|
182
|
+
DOMUtils_TransitionEvent &
|
|
183
|
+
DOMUtils_TouchEvent &
|
|
184
|
+
DOMUtils_OtherEvent;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* 事件类型
|
|
188
|
+
*/
|
|
189
|
+
export declare type DOMUtils_EventType = keyof DOMUtils_Event;
|