@whitesev/utils 1.0.3 → 1.0.4
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 +1814 -6017
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +1429 -5630
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +1429 -5628
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +1814 -6018
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +1826 -6032
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +1814 -6021
- package/dist/index.umd.js.map +1 -1
- package/dist/src/UtilsCore.d.ts +7 -0
- package/dist/src/{Utils.d.ts → index.d.ts} +206 -1
- package/index.ts +1 -1
- package/package.json +37 -35
- package/rollup.config.js +13 -1
- package/src/GBKEncoder.ts +2 -0
- package/src/UtilsCore.ts +9 -0
- package/src/UtilsGMCookie.ts +1 -1
- package/src/{ajaxHooker.js → ajaxHooker/ajaxHooker.js} +1 -0
- package/src/{Utils.ts → index.ts} +266 -16
- package/tsconfig.json +1 -2
- package/src/GBKEncoder.js +0 -111
- package/src/types/DOMUtils.d.ts +0 -188
- package/src/types/UtilsCore.d.ts +0 -7
- package/src/types/global.d.ts +0 -58
- /package/dist/src/{Dictionary.d.ts → Dictionary/Dictionary.d.ts} +0 -0
- /package/dist/src/{Hooks.d.ts → Hooks/Hooks.d.ts} +0 -0
- /package/dist/src/{Httpx.d.ts → Httpx/Httpx.d.ts} +0 -0
- /package/dist/src/{LockFunction.d.ts → LockFunction/LockFunction.d.ts} +0 -0
- /package/dist/src/{Log.d.ts → Log/Log.d.ts} +0 -0
- /package/dist/src/{Progress.d.ts → Progress/Progress.d.ts} +0 -0
- /package/dist/src/{UtilsGMMenu.d.ts → UtilsGMMenu/UtilsGMMenu.d.ts} +0 -0
- /package/dist/src/{ajaxHooker.d.ts → ajaxHooker/ajaxHooker.d.ts} +0 -0
- /package/dist/src/{indexedDB.d.ts → indexedDB/indexedDB.d.ts} +0 -0
- /package/dist/src/{tryCatch.d.ts → tryCatch/tryCatch.d.ts} +0 -0
- /package/src/{Dictionary.js → Dictionary/Dictionary.js} +0 -0
- /package/src/{types/Dictionary.d.ts → Dictionary/index.d.ts} +0 -0
- /package/src/{Hooks.js → Hooks/Hooks.js} +0 -0
- /package/src/{types/Hook.d.ts → Hooks/index.d.ts} +0 -0
- /package/src/{Httpx.js → Httpx/Httpx.js} +0 -0
- /package/src/{types/Httpx.d.ts → Httpx/index.d.ts} +0 -0
- /package/src/{LockFunction.js → LockFunction/LockFunction.js} +0 -0
- /package/src/{types/LockFunction.d.ts → LockFunction/index.d.ts} +0 -0
- /package/src/{Log.js → Log/Log.js} +0 -0
- /package/src/{types/Log.d.ts → Log/index.d.ts} +0 -0
- /package/src/{Progress.js → Progress/Progress.js} +0 -0
- /package/src/{types/Progress.d.ts → Progress/index.d.ts} +0 -0
- /package/src/{UtilsGMMenu.js → UtilsGMMenu/UtilsGMMenu.js} +0 -0
- /package/src/{types/UtilsGMMenu.d.ts → UtilsGMMenu/index.d.ts} +0 -0
- /package/src/{types/AjaxHooker.d.ts → ajaxHooker/index.d.ts} +0 -0
- /package/src/{types/Indexdb.d.ts → indexedDB/index.d.ts} +0 -0
- /package/src/{indexedDB.js → indexedDB/indexedDB.js} +0 -0
- /package/src/{types/TryCatch.d.ts → tryCatch/index.d.ts} +0 -0
- /package/src/{tryCatch.js → tryCatch/tryCatch.js} +0 -0
package/dist/src/UtilsCore.d.ts
CHANGED
|
@@ -1,6 +1,211 @@
|
|
|
1
|
+
/// <reference path="../../src/ajaxHooker/index.d.ts" />
|
|
2
|
+
/// <reference path="../../src/Dictionary/index.d.ts" />
|
|
3
|
+
/// <reference path="../../src/Hooks/index.d.ts" />
|
|
4
|
+
/// <reference path="../../src/Httpx/index.d.ts" />
|
|
5
|
+
/// <reference path="../../src/indexedDB/index.d.ts" />
|
|
6
|
+
/// <reference path="../../src/LockFunction/index.d.ts" />
|
|
7
|
+
/// <reference path="../../src/Log/index.d.ts" />
|
|
8
|
+
/// <reference path="../../src/Progress/index.d.ts" />
|
|
9
|
+
/// <reference path="../../src/tryCatch/index.d.ts" />
|
|
10
|
+
/// <reference path="../../src/UtilsGMMenu/index.d.ts" />
|
|
1
11
|
import { ColorConversion } from "./ColorConversion";
|
|
2
12
|
import { GBKEncoder } from "./GBKEncoder";
|
|
3
13
|
import { UtilsGMCookie } from "./UtilsGMCookie";
|
|
14
|
+
export declare var unsafeWindow: Window & typeof globalThis;
|
|
15
|
+
export type JSTypeMap = {
|
|
16
|
+
string: string;
|
|
17
|
+
number: number;
|
|
18
|
+
boolean: boolean;
|
|
19
|
+
object: object;
|
|
20
|
+
symbol: symbol;
|
|
21
|
+
bigint: bigint;
|
|
22
|
+
undefined: undefined;
|
|
23
|
+
null: null;
|
|
24
|
+
};
|
|
25
|
+
export type JSTypeNames = keyof JSTypeMap;
|
|
26
|
+
export type ArgsType<T extends JSTypeNames[]> = {
|
|
27
|
+
[I in keyof T]: JSTypeMap[T[I]];
|
|
28
|
+
};
|
|
29
|
+
export declare interface UtilsNestedObjectWithToString<V extends any> {
|
|
30
|
+
[key: string]: V | UtilsNestedObjectWithToString<V>;
|
|
31
|
+
}
|
|
32
|
+
export declare interface AnyObject {
|
|
33
|
+
[key: string]: any | AnyObject;
|
|
34
|
+
toString(): string;
|
|
35
|
+
}
|
|
36
|
+
export declare interface Vue2Context extends AnyObject {
|
|
37
|
+
_isVue: true;
|
|
38
|
+
$options: AnyObject;
|
|
39
|
+
$parent: Vue2Context;
|
|
40
|
+
$root: Vue2Context;
|
|
41
|
+
$children: Vue2Context[];
|
|
42
|
+
$vnode: AnyObject;
|
|
43
|
+
$slots: AnyObject;
|
|
44
|
+
$scopedSlots: AnyObject;
|
|
45
|
+
$attrs: AnyObject;
|
|
46
|
+
$listeners: AnyObject;
|
|
47
|
+
$store: AnyObject;
|
|
48
|
+
$watch: (key: string | string[], handler: (this: any, newVal: any, oldVal: any) => void, options?: {
|
|
49
|
+
immediate?: boolean;
|
|
50
|
+
deep?: boolean;
|
|
51
|
+
}) => void;
|
|
52
|
+
$el: Element;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* 鼠标事件
|
|
56
|
+
* + https://blog.csdn.net/weixin_68658847/article/details/126939879
|
|
57
|
+
*/
|
|
58
|
+
declare interface DOMUtils_MouseEvent {
|
|
59
|
+
click: MouseEvent | PointerEvent;
|
|
60
|
+
contextmenu: MouseEvent | PointerEvent;
|
|
61
|
+
dblclick: MouseEvent | PointerEvent;
|
|
62
|
+
mousedown: MouseEvent | PointerEvent;
|
|
63
|
+
mouseenter: MouseEvent | PointerEvent;
|
|
64
|
+
mouseleave: MouseEvent | PointerEvent;
|
|
65
|
+
mousemove: MouseEvent | PointerEvent;
|
|
66
|
+
mouseover: MouseEvent | PointerEvent;
|
|
67
|
+
mouseout: MouseEvent | PointerEvent;
|
|
68
|
+
mouseup: MouseEvent | PointerEvent;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 鼠标事件
|
|
72
|
+
*/
|
|
73
|
+
declare interface DOMUtils_KeyboardEvent {
|
|
74
|
+
keydown: KeyboardEvent;
|
|
75
|
+
keypress: KeyboardEvent;
|
|
76
|
+
keyup: KeyboardEvent;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* 框架/对象事件
|
|
80
|
+
*/
|
|
81
|
+
declare interface DOMUtils_Frame_Object_Event {
|
|
82
|
+
abort: Event;
|
|
83
|
+
beforeunload: Event;
|
|
84
|
+
error: Event;
|
|
85
|
+
hashchange: Event;
|
|
86
|
+
load: Event;
|
|
87
|
+
pageshow: Event;
|
|
88
|
+
pagehide: Event;
|
|
89
|
+
resize: Event;
|
|
90
|
+
scroll: Event;
|
|
91
|
+
unload: Event;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* 表单事件
|
|
95
|
+
*/
|
|
96
|
+
declare interface DOMUtils_FormEvent {
|
|
97
|
+
blur: Event;
|
|
98
|
+
change: Event;
|
|
99
|
+
focus: Event;
|
|
100
|
+
focusin: Event;
|
|
101
|
+
focusout: Event;
|
|
102
|
+
input: Event;
|
|
103
|
+
reset: Event;
|
|
104
|
+
search: Event;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* 剪贴板事件
|
|
108
|
+
*/
|
|
109
|
+
declare interface DOMUtils_ClipboardEvent {
|
|
110
|
+
copy: ClipboardEvent;
|
|
111
|
+
cut: ClipboardEvent;
|
|
112
|
+
paste: ClipboardEvent;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* 打印事件
|
|
116
|
+
*/
|
|
117
|
+
declare interface DOMUtils_PrintEvent {
|
|
118
|
+
afterprint: Event;
|
|
119
|
+
beforeprint: Event;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* 拖动事件
|
|
123
|
+
*/
|
|
124
|
+
declare interface DOMUtils_DragEvent {
|
|
125
|
+
drag: DragEvent;
|
|
126
|
+
dragend: DragEvent;
|
|
127
|
+
dragenter: DragEvent;
|
|
128
|
+
dragleave: DragEvent;
|
|
129
|
+
dragover: DragEvent;
|
|
130
|
+
dragstart: DragEvent;
|
|
131
|
+
drop: DragEvent;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* 多媒体(Media)事件
|
|
135
|
+
*/
|
|
136
|
+
declare interface DOMUtils_MediaEvent {
|
|
137
|
+
abort: Event;
|
|
138
|
+
canplay: Event;
|
|
139
|
+
canplaythrough: Event;
|
|
140
|
+
durationchange: Event;
|
|
141
|
+
emptied: Event;
|
|
142
|
+
ended: Event;
|
|
143
|
+
error: Event;
|
|
144
|
+
loadeddata: Event;
|
|
145
|
+
loadedmetadata: Event;
|
|
146
|
+
loadstart: Event;
|
|
147
|
+
pause: Event;
|
|
148
|
+
play: Event;
|
|
149
|
+
playing: Event;
|
|
150
|
+
progress: Event;
|
|
151
|
+
ratechange: Event;
|
|
152
|
+
seeked: Event;
|
|
153
|
+
seeking: Event;
|
|
154
|
+
stalled: Event;
|
|
155
|
+
suspend: Event;
|
|
156
|
+
timeupdate: Event;
|
|
157
|
+
volumechange: Event;
|
|
158
|
+
waiting: Event;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* 动画事件
|
|
162
|
+
*/
|
|
163
|
+
declare interface DOMUtils_AnimationEvent {
|
|
164
|
+
animationend: AnimationEvent;
|
|
165
|
+
animationiteration: AnimationEvent;
|
|
166
|
+
animationstart: AnimationEvent;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* 过渡事件
|
|
170
|
+
*/
|
|
171
|
+
declare interface DOMUtils_TransitionEvent {
|
|
172
|
+
transitionend: TransitionEvent;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* 触摸事件
|
|
176
|
+
*/
|
|
177
|
+
declare interface DOMUtils_TouchEvent {
|
|
178
|
+
touchstart: TouchEvent;
|
|
179
|
+
touchmove: TouchEvent;
|
|
180
|
+
touchend: TouchEvent;
|
|
181
|
+
touchcancel: TouchEvent;
|
|
182
|
+
touchenter: TouchEvent;
|
|
183
|
+
touchleave: TouchEvent;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* 其它事件
|
|
187
|
+
*/
|
|
188
|
+
declare interface DOMUtils_OtherEvent {
|
|
189
|
+
message: Event;
|
|
190
|
+
online: Event;
|
|
191
|
+
offline: Event;
|
|
192
|
+
popstate: Event;
|
|
193
|
+
show: Event;
|
|
194
|
+
storage: Event;
|
|
195
|
+
toggle: Event;
|
|
196
|
+
wheel: Event;
|
|
197
|
+
propertychange: Event;
|
|
198
|
+
fullscreenchange: Event;
|
|
199
|
+
DOMContentLoaded: Event;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* 全部事件
|
|
203
|
+
*/
|
|
204
|
+
declare type DOMUtils_Event = DOMUtils_MouseEvent & DOMUtils_KeyboardEvent & DOMUtils_Frame_Object_Event & DOMUtils_FormEvent & DOMUtils_ClipboardEvent & DOMUtils_PrintEvent & DOMUtils_DragEvent & DOMUtils_MediaEvent & DOMUtils_AnimationEvent & DOMUtils_TransitionEvent & DOMUtils_TouchEvent & DOMUtils_OtherEvent;
|
|
205
|
+
/**
|
|
206
|
+
* 事件类型
|
|
207
|
+
*/
|
|
208
|
+
declare type DOMUtils_EventType = keyof DOMUtils_Event;
|
|
4
209
|
declare class Utils {
|
|
5
210
|
/** 版本号 */
|
|
6
211
|
version: string;
|
|
@@ -43,7 +248,7 @@ declare class Utils {
|
|
|
43
248
|
* + 版本:1.4.1
|
|
44
249
|
* + 文档:https://scriptcat.org/zh-CN/script-show-page/637/
|
|
45
250
|
*/
|
|
46
|
-
ajaxHooker: UtilsAjaxHookResult;
|
|
251
|
+
ajaxHooker: () => UtilsAjaxHookResult;
|
|
47
252
|
/**
|
|
48
253
|
* 根据坐标点击canvas元素的内部位置
|
|
49
254
|
* @param canvasElement 画布元素
|
package/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,35 +1,37 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@whitesev/utils",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "一个常用的工具库",
|
|
5
|
-
"main": "dist/index.cjs.js",
|
|
6
|
-
"module": "dist/node/index.esm.js",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
|
-
"jsdelivr": "dist/index.umd.js",
|
|
9
|
-
"exports": {
|
|
10
|
-
"./package.json": "./package.json",
|
|
11
|
-
".": {
|
|
12
|
-
"import": "./dist/index.esm.js",
|
|
13
|
-
"require": "./dist/index.cjs.js",
|
|
14
|
-
"types": "./dist/index.d.ts"
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
"scripts": {
|
|
18
|
-
"build": "rollup --config"
|
|
19
|
-
},
|
|
20
|
-
"keywords": [
|
|
21
|
-
"typescript"
|
|
22
|
-
],
|
|
23
|
-
"author": "WhiteSev",
|
|
24
|
-
"license": "MIT",
|
|
25
|
-
"dependencies": {
|
|
26
|
-
"@rollup/plugin-babel": "^6.0.4",
|
|
27
|
-
"@rollup/plugin-commonjs": "^25.0.8",
|
|
28
|
-
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
29
|
-
"@rollup/plugin-typescript": "^11.1.6",
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@whitesev/utils",
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"description": "一个常用的工具库",
|
|
5
|
+
"main": "dist/index.cjs.js",
|
|
6
|
+
"module": "dist/node/index.esm.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"jsdelivr": "dist/index.umd.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
"./package.json": "./package.json",
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/index.esm.js",
|
|
13
|
+
"require": "./dist/index.cjs.js",
|
|
14
|
+
"types": "./dist/index.d.ts"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "rollup --config"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"typescript"
|
|
22
|
+
],
|
|
23
|
+
"author": "WhiteSev",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
27
|
+
"@rollup/plugin-commonjs": "^25.0.8",
|
|
28
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
29
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
30
|
+
"rollup-plugin-clear": "^2.0.7",
|
|
31
|
+
"rollup-plugin-dts": "^6.1.1",
|
|
32
|
+
"tslib": "^2.6.2"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"typescript": "^5.4.5"
|
|
36
|
+
}
|
|
37
|
+
}
|
package/rollup.config.js
CHANGED
|
@@ -4,11 +4,23 @@ const commonjs = require("@rollup/plugin-commonjs");
|
|
|
4
4
|
const { nodeResolve } = require("@rollup/plugin-node-resolve");
|
|
5
5
|
// 编译 TS 代码
|
|
6
6
|
const typescript = require("@rollup/plugin-typescript");
|
|
7
|
+
// 清空 dist
|
|
8
|
+
const cleaner = require("rollup-plugin-clear");
|
|
9
|
+
// 处理 .d.ts 声明文件
|
|
10
|
+
const { dts } = require("rollup-plugin-dts");
|
|
7
11
|
|
|
8
12
|
// 模块名
|
|
9
13
|
const moduleName = "Utils";
|
|
10
14
|
module.exports = {
|
|
11
|
-
plugins: [
|
|
15
|
+
plugins: [
|
|
16
|
+
cleaner({
|
|
17
|
+
targets: ["./dist"],
|
|
18
|
+
}),
|
|
19
|
+
dts(),
|
|
20
|
+
nodeResolve(),
|
|
21
|
+
commonjs(),
|
|
22
|
+
typescript(),
|
|
23
|
+
],
|
|
12
24
|
input: "./index.ts", // 源文件入口
|
|
13
25
|
output: [
|
|
14
26
|
{
|
package/src/GBKEncoder.ts
CHANGED
package/src/UtilsCore.ts
CHANGED
package/src/UtilsGMCookie.ts
CHANGED
|
@@ -1,17 +1,267 @@
|
|
|
1
|
+
/// <reference path="./ajaxHooker/index.d.ts" />
|
|
2
|
+
/// <reference path="./Dictionary/index.d.ts" />
|
|
3
|
+
/// <reference path="./Hooks/index.d.ts" />
|
|
4
|
+
/// <reference path="./Httpx/index.d.ts" />
|
|
5
|
+
/// <reference path="./indexedDB/index.d.ts" />
|
|
6
|
+
/// <reference path="./LockFunction/index.d.ts" />
|
|
7
|
+
/// <reference path="./Log/index.d.ts" />
|
|
8
|
+
/// <reference path="./Progress/index.d.ts" />
|
|
9
|
+
/// <reference path="./tryCatch/index.d.ts" />
|
|
10
|
+
/// <reference path="./UtilsGMMenu/index.d.ts" />
|
|
1
11
|
import { ColorConversion } from "./ColorConversion";
|
|
2
12
|
import { GBKEncoder } from "./GBKEncoder";
|
|
3
13
|
import { UtilsCore } from "./UtilsCore";
|
|
4
14
|
import { UtilsGMCookie } from "./UtilsGMCookie";
|
|
5
|
-
import { AjaxHooker } from "./ajaxHooker";
|
|
6
|
-
import { GMMenu } from "./UtilsGMMenu";
|
|
7
|
-
import { Hooks } from "./Hooks";
|
|
8
|
-
import { Httpx } from "./Httpx";
|
|
9
|
-
import { indexedDB } from "./indexedDB";
|
|
10
|
-
import { LockFunction } from "./LockFunction";
|
|
11
|
-
import { Log } from "./Log";
|
|
12
|
-
import { Progress } from "./Progress";
|
|
13
|
-
import { TryCatch } from "./tryCatch";
|
|
14
|
-
import { UtilsDictionary } from "./Dictionary";
|
|
15
|
+
import { AjaxHooker } from "./ajaxHooker/ajaxHooker.js";
|
|
16
|
+
import { GMMenu } from "./UtilsGMMenu/UtilsGMMenu";
|
|
17
|
+
import { Hooks } from "./Hooks/Hooks";
|
|
18
|
+
import { Httpx } from "./Httpx/Httpx";
|
|
19
|
+
import { indexedDB } from "./indexedDB/indexedDB";
|
|
20
|
+
import { LockFunction } from "./LockFunction/LockFunction";
|
|
21
|
+
import { Log } from "./Log/Log";
|
|
22
|
+
import { Progress } from "./Progress/Progress";
|
|
23
|
+
import { TryCatch } from "./tryCatch/tryCatch";
|
|
24
|
+
import { UtilsDictionary } from "./Dictionary/Dictionary";
|
|
25
|
+
|
|
26
|
+
export declare var unsafeWindow: Window & typeof globalThis;
|
|
27
|
+
|
|
28
|
+
export type JSTypeMap = {
|
|
29
|
+
string: string;
|
|
30
|
+
number: number;
|
|
31
|
+
boolean: boolean;
|
|
32
|
+
object: object;
|
|
33
|
+
symbol: symbol;
|
|
34
|
+
bigint: bigint;
|
|
35
|
+
undefined: undefined;
|
|
36
|
+
null: null;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type JSTypeNames = keyof JSTypeMap;
|
|
40
|
+
|
|
41
|
+
export type ArgsType<T extends JSTypeNames[]> = {
|
|
42
|
+
[I in keyof T]: JSTypeMap[T[I]];
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export declare interface UtilsNestedObjectWithToString<V extends any> {
|
|
46
|
+
[key: string]: V | UtilsNestedObjectWithToString<V>;
|
|
47
|
+
}
|
|
48
|
+
export declare interface AnyObject {
|
|
49
|
+
[key: string]: any | AnyObject;
|
|
50
|
+
toString(): string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export declare interface Vue2Context extends AnyObject {
|
|
54
|
+
_isVue: true;
|
|
55
|
+
$options: AnyObject;
|
|
56
|
+
$parent: Vue2Context;
|
|
57
|
+
$root: Vue2Context;
|
|
58
|
+
$children: Vue2Context[];
|
|
59
|
+
$vnode: AnyObject;
|
|
60
|
+
$slots: AnyObject;
|
|
61
|
+
$scopedSlots: AnyObject;
|
|
62
|
+
$attrs: AnyObject;
|
|
63
|
+
$listeners: AnyObject;
|
|
64
|
+
$store: AnyObject;
|
|
65
|
+
$watch: (
|
|
66
|
+
key: string | string[],
|
|
67
|
+
handler: (this: any, newVal: any, oldVal: any) => void,
|
|
68
|
+
options?: {
|
|
69
|
+
immediate?: boolean;
|
|
70
|
+
deep?: boolean;
|
|
71
|
+
}
|
|
72
|
+
) => void;
|
|
73
|
+
$el: Element;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* 鼠标事件
|
|
78
|
+
* + https://blog.csdn.net/weixin_68658847/article/details/126939879
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
declare interface DOMUtils_MouseEvent {
|
|
82
|
+
click: MouseEvent | PointerEvent;
|
|
83
|
+
contextmenu: MouseEvent | PointerEvent;
|
|
84
|
+
dblclick: MouseEvent | PointerEvent;
|
|
85
|
+
mousedown: MouseEvent | PointerEvent;
|
|
86
|
+
mouseenter: MouseEvent | PointerEvent;
|
|
87
|
+
mouseleave: MouseEvent | PointerEvent;
|
|
88
|
+
mousemove: MouseEvent | PointerEvent;
|
|
89
|
+
mouseover: MouseEvent | PointerEvent;
|
|
90
|
+
mouseout: MouseEvent | PointerEvent;
|
|
91
|
+
mouseup: MouseEvent | PointerEvent;
|
|
92
|
+
}
|
|
93
|
+
declare type DOMUtils_MouseEventType = keyof DOMUtils_MouseEvent;
|
|
94
|
+
/**
|
|
95
|
+
* 鼠标事件
|
|
96
|
+
*/
|
|
97
|
+
declare interface DOMUtils_KeyboardEvent {
|
|
98
|
+
keydown: KeyboardEvent;
|
|
99
|
+
keypress: KeyboardEvent;
|
|
100
|
+
keyup: KeyboardEvent;
|
|
101
|
+
}
|
|
102
|
+
declare type DOMUtils_KeyboardEventType = keyof DOMUtils_KeyboardEvent;
|
|
103
|
+
/**
|
|
104
|
+
* 框架/对象事件
|
|
105
|
+
*/
|
|
106
|
+
declare interface DOMUtils_Frame_Object_Event {
|
|
107
|
+
abort: Event;
|
|
108
|
+
beforeunload: Event;
|
|
109
|
+
error: Event;
|
|
110
|
+
hashchange: Event;
|
|
111
|
+
load: Event;
|
|
112
|
+
pageshow: Event;
|
|
113
|
+
pagehide: Event;
|
|
114
|
+
resize: Event;
|
|
115
|
+
scroll: Event;
|
|
116
|
+
unload: Event;
|
|
117
|
+
}
|
|
118
|
+
declare type DOMUtils_Frame_Object_EventType =
|
|
119
|
+
keyof DOMUtils_Frame_Object_Event;
|
|
120
|
+
/**
|
|
121
|
+
* 表单事件
|
|
122
|
+
*/
|
|
123
|
+
declare interface DOMUtils_FormEvent {
|
|
124
|
+
blur: Event;
|
|
125
|
+
change: Event;
|
|
126
|
+
focus: Event;
|
|
127
|
+
focusin: Event;
|
|
128
|
+
focusout: Event;
|
|
129
|
+
input: Event;
|
|
130
|
+
reset: Event;
|
|
131
|
+
search: Event;
|
|
132
|
+
}
|
|
133
|
+
declare type DOMUtils_FormEventType = keyof DOMUtils_FormEvent;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* 剪贴板事件
|
|
137
|
+
*/
|
|
138
|
+
declare interface DOMUtils_ClipboardEvent {
|
|
139
|
+
copy: ClipboardEvent;
|
|
140
|
+
cut: ClipboardEvent;
|
|
141
|
+
paste: ClipboardEvent;
|
|
142
|
+
}
|
|
143
|
+
declare type DOMUtils_ClipboardEventType = keyof DOMUtils_ClipboardEvent;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* 打印事件
|
|
147
|
+
*/
|
|
148
|
+
declare interface DOMUtils_PrintEvent {
|
|
149
|
+
afterprint: Event;
|
|
150
|
+
beforeprint: Event;
|
|
151
|
+
}
|
|
152
|
+
declare type DOMUtils_PrintEventType = keyof DOMUtils_PrintEvent;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* 拖动事件
|
|
156
|
+
*/
|
|
157
|
+
declare interface DOMUtils_DragEvent {
|
|
158
|
+
drag: DragEvent;
|
|
159
|
+
dragend: DragEvent;
|
|
160
|
+
dragenter: DragEvent;
|
|
161
|
+
dragleave: DragEvent;
|
|
162
|
+
dragover: DragEvent;
|
|
163
|
+
dragstart: DragEvent;
|
|
164
|
+
drop: DragEvent;
|
|
165
|
+
}
|
|
166
|
+
declare type DOMUtils_DragEventType = keyof DOMUtils_DragEvent;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* 多媒体(Media)事件
|
|
170
|
+
*/
|
|
171
|
+
declare interface DOMUtils_MediaEvent {
|
|
172
|
+
abort: Event;
|
|
173
|
+
canplay: Event;
|
|
174
|
+
canplaythrough: Event;
|
|
175
|
+
durationchange: Event;
|
|
176
|
+
emptied: Event;
|
|
177
|
+
ended: Event;
|
|
178
|
+
error: Event;
|
|
179
|
+
loadeddata: Event;
|
|
180
|
+
loadedmetadata: Event;
|
|
181
|
+
loadstart: Event;
|
|
182
|
+
pause: Event;
|
|
183
|
+
play: Event;
|
|
184
|
+
playing: Event;
|
|
185
|
+
progress: Event;
|
|
186
|
+
ratechange: Event;
|
|
187
|
+
seeked: Event;
|
|
188
|
+
seeking: Event;
|
|
189
|
+
stalled: Event;
|
|
190
|
+
suspend: Event;
|
|
191
|
+
timeupdate: Event;
|
|
192
|
+
volumechange: Event;
|
|
193
|
+
waiting: Event;
|
|
194
|
+
}
|
|
195
|
+
declare type DOMUtils_MediaEventType = keyof DOMUtils_MediaEvent;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* 动画事件
|
|
199
|
+
*/
|
|
200
|
+
declare interface DOMUtils_AnimationEvent {
|
|
201
|
+
animationend: AnimationEvent;
|
|
202
|
+
animationiteration: AnimationEvent;
|
|
203
|
+
animationstart: AnimationEvent;
|
|
204
|
+
}
|
|
205
|
+
declare type DOMUtils_AnimationEventType = keyof DOMUtils_AnimationEvent;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* 过渡事件
|
|
209
|
+
*/
|
|
210
|
+
declare interface DOMUtils_TransitionEvent {
|
|
211
|
+
transitionend: TransitionEvent;
|
|
212
|
+
}
|
|
213
|
+
declare type DOMUtils_TransitionEventType = keyof DOMUtils_TransitionEvent;
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* 触摸事件
|
|
217
|
+
*/
|
|
218
|
+
declare interface DOMUtils_TouchEvent {
|
|
219
|
+
touchstart: TouchEvent;
|
|
220
|
+
touchmove: TouchEvent;
|
|
221
|
+
touchend: TouchEvent;
|
|
222
|
+
touchcancel: TouchEvent;
|
|
223
|
+
touchenter: TouchEvent;
|
|
224
|
+
touchleave: TouchEvent;
|
|
225
|
+
}
|
|
226
|
+
declare type DOMUtils_TouchEventType = keyof DOMUtils_TouchEvent;
|
|
227
|
+
/**
|
|
228
|
+
* 其它事件
|
|
229
|
+
*/
|
|
230
|
+
declare interface DOMUtils_OtherEvent {
|
|
231
|
+
message: Event;
|
|
232
|
+
online: Event;
|
|
233
|
+
offline: Event;
|
|
234
|
+
popstate: Event;
|
|
235
|
+
show: Event;
|
|
236
|
+
storage: Event;
|
|
237
|
+
toggle: Event;
|
|
238
|
+
wheel: Event;
|
|
239
|
+
propertychange: Event;
|
|
240
|
+
fullscreenchange: Event;
|
|
241
|
+
DOMContentLoaded: Event;
|
|
242
|
+
}
|
|
243
|
+
declare type DOMUtils_OtherEventType = keyof DOMUtils_OtherEvent;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* 全部事件
|
|
247
|
+
*/
|
|
248
|
+
declare type DOMUtils_Event = DOMUtils_MouseEvent &
|
|
249
|
+
DOMUtils_KeyboardEvent &
|
|
250
|
+
DOMUtils_Frame_Object_Event &
|
|
251
|
+
DOMUtils_FormEvent &
|
|
252
|
+
DOMUtils_ClipboardEvent &
|
|
253
|
+
DOMUtils_PrintEvent &
|
|
254
|
+
DOMUtils_DragEvent &
|
|
255
|
+
DOMUtils_MediaEvent &
|
|
256
|
+
DOMUtils_AnimationEvent &
|
|
257
|
+
DOMUtils_TransitionEvent &
|
|
258
|
+
DOMUtils_TouchEvent &
|
|
259
|
+
DOMUtils_OtherEvent;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* 事件类型
|
|
263
|
+
*/
|
|
264
|
+
declare type DOMUtils_EventType = keyof DOMUtils_Event;
|
|
15
265
|
|
|
16
266
|
class Utils {
|
|
17
267
|
/** 版本号 */
|
|
@@ -186,7 +436,7 @@ class Utils {
|
|
|
186
436
|
* + 版本:1.4.1
|
|
187
437
|
* + 文档:https://scriptcat.org/zh-CN/script-show-page/637/
|
|
188
438
|
*/
|
|
189
|
-
ajaxHooker: UtilsAjaxHookResult = AjaxHooker
|
|
439
|
+
ajaxHooker: () => UtilsAjaxHookResult = AjaxHooker;
|
|
190
440
|
/**
|
|
191
441
|
* 根据坐标点击canvas元素的内部位置
|
|
192
442
|
* @param canvasElement 画布元素
|
|
@@ -379,7 +629,7 @@ class Utils {
|
|
|
379
629
|
delay?: number
|
|
380
630
|
): (...args: A) => void;
|
|
381
631
|
debounce<A extends any[], R>(fn: (...args: A) => R, delay = 0) {
|
|
382
|
-
let timer:
|
|
632
|
+
let timer: any = null as any;
|
|
383
633
|
const context = this;
|
|
384
634
|
return function (...args: A) {
|
|
385
635
|
clearTimeout(timer);
|
|
@@ -701,7 +951,7 @@ class Utils {
|
|
|
701
951
|
sizeData.NB = sizeData.BB * sizeData.KB;
|
|
702
952
|
sizeData.DB = sizeData.NB * sizeData.KB;
|
|
703
953
|
for (let key in sizeData) {
|
|
704
|
-
result = byteSize / sizeData[key];
|
|
954
|
+
result = byteSize / (sizeData as any)[key];
|
|
705
955
|
resultType = key;
|
|
706
956
|
if (sizeData.KB >= result) {
|
|
707
957
|
break;
|
|
@@ -1939,15 +2189,15 @@ class Utils {
|
|
|
1939
2189
|
let targetStrLength = 0;
|
|
1940
2190
|
for (const char of targetStr) {
|
|
1941
2191
|
if (Reflect.has(targetCharMap, char)) {
|
|
1942
|
-
targetCharMap[char]++;
|
|
2192
|
+
(targetCharMap as any)[char]++;
|
|
1943
2193
|
} else {
|
|
1944
|
-
targetCharMap[char] = 1;
|
|
2194
|
+
(targetCharMap as any)[char] = 1;
|
|
1945
2195
|
}
|
|
1946
2196
|
targetStrLength++;
|
|
1947
2197
|
}
|
|
1948
2198
|
let result = false;
|
|
1949
2199
|
for (const char in targetCharMap) {
|
|
1950
|
-
if (targetCharMap[char] / targetStrLength >= coefficient) {
|
|
2200
|
+
if ((targetCharMap as any)[char] / targetStrLength >= coefficient) {
|
|
1951
2201
|
result = true;
|
|
1952
2202
|
break;
|
|
1953
2203
|
}
|