@whitesev/utils 2.3.8 → 2.4.0
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 +379 -268
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +379 -268
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +379 -268
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +379 -268
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +379 -268
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +379 -268
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/Httpx.d.ts +25 -1178
- package/dist/types/src/Log.d.ts +1 -19
- package/dist/types/src/Progress.d.ts +1 -20
- package/dist/types/src/TryCatch.d.ts +2 -11
- package/dist/types/src/Utils.d.ts +8 -32
- package/dist/types/src/UtilsGMCookie.d.ts +1 -51
- package/dist/types/src/UtilsGMMenu.d.ts +1 -50
- package/dist/types/src/WindowApi.d.ts +3 -11
- package/dist/types/src/types/Httpx.d.ts +1316 -0
- package/dist/types/src/types/Log.d.ts +19 -0
- package/dist/types/src/types/Progress.d.ts +20 -0
- package/dist/types/src/types/TryCatch.d.ts +9 -0
- package/dist/types/src/types/UtilsGMCookie.d.ts +55 -0
- package/dist/types/src/types/UtilsGMMenu.d.ts +77 -0
- package/{src/VueObject.ts → dist/types/src/types/Vue2.d.ts} +28 -15
- package/dist/types/src/types/Vue3.d.ts +0 -0
- package/dist/types/src/types/WindowApi.d.ts +10 -0
- package/dist/types/src/types/global.d.ts +24 -1
- package/package.json +1 -1
- package/src/GBKEncoder.ts +1 -1
- package/src/Httpx.ts +535 -1627
- package/src/Log.ts +1 -19
- package/src/Progress.ts +1 -20
- package/src/TryCatch.ts +2 -12
- package/src/Utils.ts +15 -38
- package/src/UtilsGMCookie.ts +7 -56
- package/src/UtilsGMMenu.ts +5 -78
- package/src/WindowApi.ts +4 -11
- package/src/types/Event.d.ts +189 -0
- package/src/types/Httpx.d.ts +1316 -0
- package/src/types/Log.d.ts +19 -0
- package/src/types/Progress.d.ts +20 -0
- package/src/types/TryCatch.d.ts +9 -0
- package/src/types/UtilsGMCookie.d.ts +55 -0
- package/src/types/UtilsGMMenu.d.ts +77 -0
- package/src/types/Vue2.d.ts +154 -0
- package/src/types/Vue3.d.ts +0 -0
- package/src/types/WindowApi.d.ts +10 -0
- package/{dist/types/src/AjaxHookerType.d.ts → src/types/ajaxHooker.d.ts} +155 -147
- package/src/types/global.d.ts +24 -1
- package/dist/types/src/Event.d.ts +0 -156
- package/dist/types/src/VueObject.d.ts +0 -123
- /package/{src/Event.ts → dist/types/src/types/Event.d.ts} +0 -0
- /package/{src/AjaxHookerType.ts → dist/types/src/types/ajaxHooker.d.ts} +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Utils.Log的初始化配置 */
|
|
2
|
+
export interface UtilsLogOptions {
|
|
3
|
+
/** 是否输出Tag,false的话其它的颜色也不输出 @default true */
|
|
4
|
+
tag: boolean;
|
|
5
|
+
/** log.success的颜色 @default "#0000FF" */
|
|
6
|
+
successColor: string;
|
|
7
|
+
/** log.warn的颜色 @default "0" */
|
|
8
|
+
warnColor: string;
|
|
9
|
+
/** log.error的颜色 @default "#FF0000" */
|
|
10
|
+
errorColor: string;
|
|
11
|
+
/** log.info的颜色 @default "0" */
|
|
12
|
+
infoColor: string;
|
|
13
|
+
/** 是否开启debug模式,true会在控制台每次调用时输出调用函数的所在位置,false不会输出位置 @default false */
|
|
14
|
+
debug: boolean;
|
|
15
|
+
/** 当console输出超过logMaxCount数量自动清理控制台 @default false */
|
|
16
|
+
autoClearConsole: boolean;
|
|
17
|
+
/** console输出的最高数量,autoClearConsole开启则生效 @default 999 */
|
|
18
|
+
logMaxCount: number;
|
|
19
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface ProgressParamConfig {
|
|
2
|
+
/** canvas元素节点 */
|
|
3
|
+
canvasNode: HTMLCanvasElement;
|
|
4
|
+
/** 绘制角度,默认:95 */
|
|
5
|
+
deg: number;
|
|
6
|
+
/** 进度,默认:0 */
|
|
7
|
+
progress: number;
|
|
8
|
+
/** 绘制的线宽度,默认:10 */
|
|
9
|
+
lineWidth: number;
|
|
10
|
+
/** 绘制的背景颜色,默认:#1e637c */
|
|
11
|
+
lineBgColor: string;
|
|
12
|
+
/** 绘制的线的颜色,默认:#25deff */
|
|
13
|
+
lineColor: string;
|
|
14
|
+
/** 绘制的字体颜色,默认:#000000 */
|
|
15
|
+
textColor: string;
|
|
16
|
+
/** 绘制的字体大小(px),默认:22px */
|
|
17
|
+
fontSize: number;
|
|
18
|
+
/** 绘制的圆的半径,默认:50 */
|
|
19
|
+
circleRadius: number;
|
|
20
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export interface UtilsGMCookieResult {
|
|
2
|
+
/** 为 window.location.hostname */
|
|
3
|
+
domain: string;
|
|
4
|
+
expirationDate: null;
|
|
5
|
+
hostOnly: true;
|
|
6
|
+
httpOnly: false;
|
|
7
|
+
name: string;
|
|
8
|
+
path: "/";
|
|
9
|
+
sameSite: "unspecified";
|
|
10
|
+
secure: true;
|
|
11
|
+
session: false;
|
|
12
|
+
value: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface UtilsGMCookieListOptions {
|
|
16
|
+
/** 默认为当前的url */
|
|
17
|
+
url: string;
|
|
18
|
+
/** 默认为当前的域名(window.location.hostname) */
|
|
19
|
+
domain: string;
|
|
20
|
+
/** 需要检索的Cookie的名字 */
|
|
21
|
+
name: string | RegExp;
|
|
22
|
+
/** 需要检索的Cookie的路径,默认为"/" */
|
|
23
|
+
path: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface UtilsGMCookieSetOptions {
|
|
27
|
+
/** 默认为当前的url */
|
|
28
|
+
url?: string;
|
|
29
|
+
/** 默认为当前的域名(window.location.hostname) */
|
|
30
|
+
domain?: string;
|
|
31
|
+
/** 需要检索的Cookie的名字 */
|
|
32
|
+
name?: string;
|
|
33
|
+
/** 需要检索的Cookie的路径,默认为"/" */
|
|
34
|
+
path?: string;
|
|
35
|
+
/** 值 */
|
|
36
|
+
value?: string | number;
|
|
37
|
+
/** 确保Cookie只在通过安全协议(如HTTPS)的情况下传输 */
|
|
38
|
+
secure?: boolean;
|
|
39
|
+
/** 是否防止JavaScript代码访问Cookie */
|
|
40
|
+
httpOnly?: boolean;
|
|
41
|
+
/** Cookie过期时间,默认为30天 */
|
|
42
|
+
expirationDate?: number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface UtilsGMCookieDeleteOptions {
|
|
46
|
+
/** 默认为当前的url */
|
|
47
|
+
url: string;
|
|
48
|
+
/** 需要检索的Cookie的名字 */
|
|
49
|
+
name: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface WindowApiOption {
|
|
53
|
+
window: Window & typeof globalThis;
|
|
54
|
+
document: Document;
|
|
55
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export interface UtilsGMMenuClickCallBackData {
|
|
2
|
+
/** 菜单键名 */
|
|
3
|
+
key: string;
|
|
4
|
+
/** 是否启用 */
|
|
5
|
+
enable: boolean;
|
|
6
|
+
/** 点击前的enable值 */
|
|
7
|
+
oldEnable: boolean;
|
|
8
|
+
/** 触发的事件 */
|
|
9
|
+
event: MouseEvent | KeyboardEvent;
|
|
10
|
+
/** 将enable值写入本地的回调,设置参数false就不保存到本地 */
|
|
11
|
+
storeValue(enable: boolean): void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface UtilsGMMenuOption {
|
|
15
|
+
/** 菜单的本地键key,不可重复,会覆盖 */
|
|
16
|
+
key: string;
|
|
17
|
+
/** 菜单的文本 */
|
|
18
|
+
text: string;
|
|
19
|
+
/** (可选)菜单的开启状态,默认为false */
|
|
20
|
+
enable?: boolean;
|
|
21
|
+
/** (可选)使用条件:TamperMonkey版本>5.0,如果id和已注册的菜单id相同,可修改当前已注册菜单的options */
|
|
22
|
+
id?: number;
|
|
23
|
+
/** (可选)An optional access key. Please see the description below. Either options or accessKey can be specified. */
|
|
24
|
+
accessKey?: string;
|
|
25
|
+
/** (可选)自动关闭菜单,可不设置 */
|
|
26
|
+
autoClose?: boolean;
|
|
27
|
+
/** 使用条件:TamperMonkey版本>5.0,使用菜单项的鼠标悬浮上的工具提示*/
|
|
28
|
+
title?: string;
|
|
29
|
+
/** (可选)点击菜单后自动刷新网页,默认为true */
|
|
30
|
+
autoReload?: boolean;
|
|
31
|
+
/** 菜单的显示文本,未设置的话则自动根据enable在前面加上图标 */
|
|
32
|
+
showText(text: string, enable: boolean): string;
|
|
33
|
+
/** 点击菜单的回调 */
|
|
34
|
+
callback(data: UtilsGMMenuClickCallBackData): void;
|
|
35
|
+
/** 是否允许菜单进行存储值,默认true允许 */
|
|
36
|
+
isStoreValue?: boolean;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface UtilsGMMenuHandledOption extends UtilsGMMenuOption {
|
|
40
|
+
/**
|
|
41
|
+
* 删除该菜单
|
|
42
|
+
*/
|
|
43
|
+
deleteMenu(): void;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface UtilsGMMenuOptionData {
|
|
47
|
+
/**
|
|
48
|
+
* 菜单id
|
|
49
|
+
*/
|
|
50
|
+
id?: number;
|
|
51
|
+
/**
|
|
52
|
+
* 菜单配置
|
|
53
|
+
*/
|
|
54
|
+
data: UtilsGMMenuOption;
|
|
55
|
+
/**
|
|
56
|
+
* 处理后的菜单配置
|
|
57
|
+
* 对autoReload进行处理,如果未赋值,按默认的true赋值
|
|
58
|
+
* 对isStoreValue进行处理,如果未赋值,按默认的true赋值
|
|
59
|
+
* 新增一个deleteMenu
|
|
60
|
+
*/
|
|
61
|
+
handleData: UtilsGMMenuHandledOption;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface UtilsGMMenuConstructorOptions {
|
|
65
|
+
/** (可选)配置*/
|
|
66
|
+
data?: UtilsGMMenuOption[];
|
|
67
|
+
/** (可选)全局菜单点击菜单后自动刷新网页,默认为true */
|
|
68
|
+
autoReload?: boolean;
|
|
69
|
+
/** 油猴函数 @grant GM_getValue */
|
|
70
|
+
GM_getValue: any;
|
|
71
|
+
/** 油猴函数 @grant GM_setValue */
|
|
72
|
+
GM_setValue: any;
|
|
73
|
+
/** 油猴函数 @grant GM_registerMenuCommand */
|
|
74
|
+
GM_registerMenuCommand: any;
|
|
75
|
+
/** 油猴函数 @grant GM_unregisterMenuCommand */
|
|
76
|
+
GM_unregisterMenuCommand: any;
|
|
77
|
+
}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Vue2实例
|
|
3
|
+
*/
|
|
4
|
+
export declare interface Vue2Instance {
|
|
2
5
|
$attrs: any;
|
|
3
|
-
$children:
|
|
6
|
+
$children: Vue2Instance[];
|
|
4
7
|
$createElement: (...args: any[]) => any;
|
|
5
8
|
$el: HTMLElement;
|
|
6
9
|
$listeners: any;
|
|
7
10
|
$options: any;
|
|
8
|
-
$parent:
|
|
11
|
+
$parent: Vue2Instance;
|
|
9
12
|
$refs: any;
|
|
10
|
-
$root:
|
|
13
|
+
$root: Vue2Instance;
|
|
11
14
|
$scopedSlots: any;
|
|
12
15
|
$slots: any;
|
|
13
16
|
$store: any;
|
|
@@ -38,15 +41,15 @@ export declare interface Vue2Object {
|
|
|
38
41
|
};
|
|
39
42
|
$router: {
|
|
40
43
|
afterHooks: Function[];
|
|
41
|
-
app:
|
|
42
|
-
apps:
|
|
44
|
+
app: Vue2Instance;
|
|
45
|
+
apps: Vue2Instance[];
|
|
43
46
|
beforeHooks: Function[];
|
|
44
47
|
fallback: boolean;
|
|
45
48
|
history: {
|
|
46
49
|
base: string;
|
|
47
|
-
current:
|
|
50
|
+
current: Vue2Instance["$route"];
|
|
48
51
|
listeners: any[];
|
|
49
|
-
router:
|
|
52
|
+
router: Vue2Instance["$router"];
|
|
50
53
|
/**
|
|
51
54
|
*
|
|
52
55
|
* @param delta 访问的距离。如果 delta < 0 则后退相应数量的记录,如果 > 0 则前进。
|
|
@@ -82,14 +85,14 @@ export declare interface Vue2Object {
|
|
|
82
85
|
[key: string]: any;
|
|
83
86
|
};
|
|
84
87
|
resolveHooks: ((...args: any[]) => any)[];
|
|
85
|
-
currentRoute:
|
|
88
|
+
currentRoute: Vue2Instance["$route"];
|
|
86
89
|
beforeEach: (
|
|
87
90
|
callback:
|
|
88
91
|
| ((
|
|
89
92
|
/** 即将要进入的目标 路由对象 */
|
|
90
|
-
to:
|
|
93
|
+
to: Vue2Instance["$route"],
|
|
91
94
|
/** 当前导航正要离开的路由 */
|
|
92
|
-
from:
|
|
95
|
+
from: Vue2Instance["$route"],
|
|
93
96
|
/**
|
|
94
97
|
*
|
|
95
98
|
* + next(): 进行管道中的下一个钩子。如果全部钩子执行完了,则导航的状态就是 confirmed (确认的)。
|
|
@@ -107,9 +110,9 @@ export declare interface Vue2Object {
|
|
|
107
110
|
callback:
|
|
108
111
|
| ((
|
|
109
112
|
/** 即将要进入的目标 路由对象 */
|
|
110
|
-
to:
|
|
113
|
+
to: Vue2Instance["$route"],
|
|
111
114
|
/** 当前导航正要离开的路由 */
|
|
112
|
-
from:
|
|
115
|
+
from: Vue2Instance["$route"]
|
|
113
116
|
) => void)
|
|
114
117
|
/** 移除上一个添加的监听 */
|
|
115
118
|
| (() => void)
|
|
@@ -136,6 +139,16 @@ export declare interface Vue2Object {
|
|
|
136
139
|
[key: string]: any;
|
|
137
140
|
}
|
|
138
141
|
|
|
139
|
-
|
|
140
|
-
|
|
142
|
+
/**
|
|
143
|
+
* 包含vue属性的HTMLElement
|
|
144
|
+
*/
|
|
145
|
+
export declare interface Vue2HTMLElement extends HTMLElement {
|
|
146
|
+
__vue__: Vue2Instance;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* 包含vue属性的HTMLElement
|
|
151
|
+
*/
|
|
152
|
+
export declare interface Vue2HTMLDivElement extends HTMLDivElement {
|
|
153
|
+
__vue__: Vue2Instance;
|
|
141
154
|
}
|
|
File without changes
|
|
@@ -1 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
export type JSTypeMap = {
|
|
2
|
+
string: string;
|
|
3
|
+
number: number;
|
|
4
|
+
boolean: boolean;
|
|
5
|
+
object: object;
|
|
6
|
+
symbol: symbol;
|
|
7
|
+
bigint: bigint;
|
|
8
|
+
undefined: undefined;
|
|
9
|
+
null: null;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type JSTypeNames = keyof JSTypeMap;
|
|
13
|
+
|
|
14
|
+
export type ArgsType<T extends JSTypeNames[]> = {
|
|
15
|
+
[I in keyof T]: JSTypeMap[T[I]];
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export declare interface UtilsOwnObject<V extends any> {
|
|
19
|
+
[key: string]: V | UtilsOwnObject<V>;
|
|
20
|
+
}
|
|
21
|
+
export declare interface AnyObject {
|
|
22
|
+
[key: string]: any | AnyObject;
|
|
23
|
+
toString(): string;
|
|
24
|
+
}
|
package/package.json
CHANGED
package/src/GBKEncoder.ts
CHANGED