@whitesev/utils 2.3.8 → 2.4.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/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 +533 -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
package/dist/types/src/Log.d.ts
CHANGED
|
@@ -1,22 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
declare 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
|
-
}
|
|
1
|
+
import type { UtilsLogOptions } from "./types/Log";
|
|
20
2
|
declare class Log {
|
|
21
3
|
#private;
|
|
22
4
|
/** 前面的TAG标志 */
|
|
@@ -1,23 +1,4 @@
|
|
|
1
|
-
|
|
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
|
-
}
|
|
1
|
+
import type { ProgressParamConfig } from "./types/Progress";
|
|
21
2
|
declare class Progress {
|
|
22
3
|
#private;
|
|
23
4
|
/**
|
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
}
|
|
4
|
-
/** tryCatch */
|
|
5
|
-
export declare interface UtilsTryCatchType {
|
|
6
|
-
run: UtilsTryCatchType;
|
|
7
|
-
config: UtilsTryCatchType;
|
|
8
|
-
error: UtilsTryCatchType;
|
|
9
|
-
}
|
|
10
|
-
declare const TryCatch: (...args: any) => {
|
|
1
|
+
import type { UtilsTryCatchConfig, UtilsTryCatchType } from "./types/TryCatch";
|
|
2
|
+
export declare const TryCatch: (...args: any) => {
|
|
11
3
|
/**
|
|
12
4
|
*
|
|
13
5
|
* @param paramDetails 配置
|
|
@@ -28,4 +20,3 @@ declare const TryCatch: (...args: any) => {
|
|
|
28
20
|
*/
|
|
29
21
|
run<A extends any[], R>(callback: ((...args: A) => R) | string | Function, __context__?: any): UtilsTryCatchType;
|
|
30
22
|
};
|
|
31
|
-
export { TryCatch };
|
|
@@ -9,35 +9,11 @@ import { LockFunction } from "./LockFunction";
|
|
|
9
9
|
import { Log } from "./Log";
|
|
10
10
|
import { Progress } from "./Progress";
|
|
11
11
|
import { UtilsDictionary } from "./Dictionary";
|
|
12
|
-
import type { DOMUtils_EventType } from "./Event";
|
|
13
|
-
import type {
|
|
14
|
-
import type { UtilsAjaxHookResult } from "./AjaxHookerType";
|
|
15
|
-
import { type UtilsWindowApiOption } from "./WindowApi";
|
|
12
|
+
import type { DOMUtils_EventType } from "./types/Event";
|
|
13
|
+
import type { UtilsAjaxHookResult } from "./types/ajaxHooker";
|
|
16
14
|
import { Vue } from "./Vue";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
string: string;
|
|
20
|
-
number: number;
|
|
21
|
-
boolean: boolean;
|
|
22
|
-
object: object;
|
|
23
|
-
symbol: symbol;
|
|
24
|
-
bigint: bigint;
|
|
25
|
-
undefined: undefined;
|
|
26
|
-
null: null;
|
|
27
|
-
};
|
|
28
|
-
export type JSTypeNames = keyof JSTypeMap;
|
|
29
|
-
export type ArgsType<T extends JSTypeNames[]> = {
|
|
30
|
-
[I in keyof T]: JSTypeMap[T[I]];
|
|
31
|
-
};
|
|
32
|
-
export declare interface UtilsOwnObject<V extends any> {
|
|
33
|
-
[key: string]: V | UtilsOwnObject<V>;
|
|
34
|
-
}
|
|
35
|
-
export declare interface AnyObject {
|
|
36
|
-
[key: string]: any | AnyObject;
|
|
37
|
-
toString(): string;
|
|
38
|
-
}
|
|
39
|
-
export declare interface Vue2Context extends Vue2Object {
|
|
40
|
-
}
|
|
15
|
+
import { type ArgsType, type JSTypeNames, type UtilsOwnObject } from "./types/global";
|
|
16
|
+
import type { UtilsWindowApiOption } from "./types/WindowApi";
|
|
41
17
|
declare class Utils {
|
|
42
18
|
private windowApi;
|
|
43
19
|
constructor(option?: UtilsWindowApiOption);
|
|
@@ -184,7 +160,7 @@ declare class Utils {
|
|
|
184
160
|
* @example
|
|
185
161
|
* Utils.dispatchEvent(document.querySelector("input","input"))
|
|
186
162
|
*/
|
|
187
|
-
dispatchEvent(element: HTMLElement | Document, eventName: DOMUtils_EventType | DOMUtils_EventType[], details?:
|
|
163
|
+
dispatchEvent(element: HTMLElement | Document, eventName: DOMUtils_EventType | DOMUtils_EventType[], details?: any): void;
|
|
188
164
|
/**
|
|
189
165
|
* 主动触发事件
|
|
190
166
|
* @param element 元素
|
|
@@ -195,7 +171,7 @@ declare class Utils {
|
|
|
195
171
|
* @example
|
|
196
172
|
* Utils.dispatchEvent(document.querySelector("input","input"))
|
|
197
173
|
*/
|
|
198
|
-
dispatchEvent(element: HTMLElement | Document, eventName: string, details?:
|
|
174
|
+
dispatchEvent(element: HTMLElement | Document, eventName: string, details?: any): void;
|
|
199
175
|
/**
|
|
200
176
|
* 下载base64格式的数据
|
|
201
177
|
* @param base64Data 需要转换的base64数据
|
|
@@ -1400,9 +1376,9 @@ declare class Utils {
|
|
|
1400
1376
|
* > ()=>{throw new Error('测试错误')}出现错误
|
|
1401
1377
|
*/
|
|
1402
1378
|
tryCatch: (...args: any) => {
|
|
1403
|
-
config(paramDetails: import("./TryCatch").UtilsTryCatchConfig): any;
|
|
1379
|
+
config(paramDetails: import("./types/TryCatch").UtilsTryCatchConfig): any;
|
|
1404
1380
|
error(handler: ((...args: any[]) => any) | string | Function): any;
|
|
1405
|
-
run<A extends any[], R>(callback: ((...args: A) => R) | string | Function, __context__?: any): import("./TryCatch").UtilsTryCatchType;
|
|
1381
|
+
run<A extends any[], R>(callback: ((...args: A) => R) | string | Function, __context__?: any): import("./types/TryCatch").UtilsTryCatchType;
|
|
1406
1382
|
};
|
|
1407
1383
|
/**
|
|
1408
1384
|
* 数组去重,去除重复的值
|
|
@@ -1,54 +1,4 @@
|
|
|
1
|
-
|
|
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
|
-
declare interface UtilsGMCookieListOptions {
|
|
15
|
-
/** 默认为当前的url */
|
|
16
|
-
url: string;
|
|
17
|
-
/** 默认为当前的域名(window.location.hostname) */
|
|
18
|
-
domain: string;
|
|
19
|
-
/** 需要检索的Cookie的名字 */
|
|
20
|
-
name: string | RegExp;
|
|
21
|
-
/** 需要检索的Cookie的路径,默认为"/" */
|
|
22
|
-
path: string;
|
|
23
|
-
}
|
|
24
|
-
declare interface UtilsGMCookieSetOptions {
|
|
25
|
-
/** 默认为当前的url */
|
|
26
|
-
url?: string;
|
|
27
|
-
/** 默认为当前的域名(window.location.hostname) */
|
|
28
|
-
domain?: string;
|
|
29
|
-
/** 需要检索的Cookie的名字 */
|
|
30
|
-
name?: string;
|
|
31
|
-
/** 需要检索的Cookie的路径,默认为"/" */
|
|
32
|
-
path?: string;
|
|
33
|
-
/** 值 */
|
|
34
|
-
value?: string | number;
|
|
35
|
-
/** 确保Cookie只在通过安全协议(如HTTPS)的情况下传输 */
|
|
36
|
-
secure?: boolean;
|
|
37
|
-
/** 是否防止JavaScript代码访问Cookie */
|
|
38
|
-
httpOnly?: boolean;
|
|
39
|
-
/** Cookie过期时间,默认为30天 */
|
|
40
|
-
expirationDate?: number;
|
|
41
|
-
}
|
|
42
|
-
declare interface UtilsGMCookieDeleteOptions {
|
|
43
|
-
/** 默认为当前的url */
|
|
44
|
-
url: string;
|
|
45
|
-
/** 需要检索的Cookie的名字 */
|
|
46
|
-
name: string;
|
|
47
|
-
}
|
|
48
|
-
interface WindowApiOption {
|
|
49
|
-
window: Window & typeof globalThis;
|
|
50
|
-
document: Document;
|
|
51
|
-
}
|
|
1
|
+
import type { UtilsGMCookieDeleteOptions, UtilsGMCookieListOptions, UtilsGMCookieResult, UtilsGMCookieSetOptions, WindowApiOption } from "./types/UtilsGMCookie";
|
|
52
2
|
declare class UtilsGMCookie {
|
|
53
3
|
private windowApi;
|
|
54
4
|
constructor(windowApiOption?: WindowApiOption);
|
|
@@ -1,53 +1,4 @@
|
|
|
1
|
-
|
|
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
|
-
declare interface UtilsGMMenuOption {
|
|
14
|
-
/** 菜单的本地键key,不可重复,会覆盖 */
|
|
15
|
-
key: string;
|
|
16
|
-
/** 菜单的文本 */
|
|
17
|
-
text: string;
|
|
18
|
-
/** (可选)菜单的开启状态,默认为false */
|
|
19
|
-
enable?: boolean;
|
|
20
|
-
/** (可选)使用条件:TamperMonkey版本>5.0,如果id和已注册的菜单id相同,可修改当前已注册菜单的options */
|
|
21
|
-
id?: number;
|
|
22
|
-
/** (可选)An optional access key. Please see the description below. Either options or accessKey can be specified. */
|
|
23
|
-
accessKey?: string;
|
|
24
|
-
/** (可选)自动关闭菜单,可不设置 */
|
|
25
|
-
autoClose?: boolean;
|
|
26
|
-
/** 使用条件:TamperMonkey版本>5.0,使用菜单项的鼠标悬浮上的工具提示*/
|
|
27
|
-
title?: string;
|
|
28
|
-
/** (可选)点击菜单后自动刷新网页,默认为true */
|
|
29
|
-
autoReload?: boolean;
|
|
30
|
-
/** 菜单的显示文本,未设置的话则自动根据enable在前面加上图标 */
|
|
31
|
-
showText(text: string, enable: boolean): string;
|
|
32
|
-
/** 点击菜单的回调 */
|
|
33
|
-
callback(data: UtilsGMMenuClickCallBackData): void;
|
|
34
|
-
/** 是否允许菜单进行存储值,默认true允许 */
|
|
35
|
-
isStoreValue?: boolean;
|
|
36
|
-
}
|
|
37
|
-
declare interface UtilsGMMenuConstructorOptions {
|
|
38
|
-
/** (可选)配置*/
|
|
39
|
-
data?: UtilsGMMenuOption[];
|
|
40
|
-
/** (可选)全局菜单点击菜单后自动刷新网页,默认为true */
|
|
41
|
-
autoReload?: boolean;
|
|
42
|
-
/** 油猴函数 @grant GM_getValue */
|
|
43
|
-
GM_getValue: any;
|
|
44
|
-
/** 油猴函数 @grant GM_setValue */
|
|
45
|
-
GM_setValue: any;
|
|
46
|
-
/** 油猴函数 @grant GM_registerMenuCommand */
|
|
47
|
-
GM_registerMenuCommand: any;
|
|
48
|
-
/** 油猴函数 @grant GM_unregisterMenuCommand */
|
|
49
|
-
GM_unregisterMenuCommand: any;
|
|
50
|
-
}
|
|
1
|
+
import type { UtilsGMMenuConstructorOptions, UtilsGMMenuOption } from "./types/UtilsGMMenu";
|
|
51
2
|
declare class GMMenu {
|
|
52
3
|
private GM_Api;
|
|
53
4
|
private MenuHandle;
|
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
export type UtilsWindowApiOption = {
|
|
5
|
-
document: Document;
|
|
6
|
-
window: Window & typeof globalThis;
|
|
7
|
-
globalThis: typeof globalThis | Window;
|
|
8
|
-
self: Window & typeof globalThis;
|
|
9
|
-
top: Window;
|
|
10
|
-
};
|
|
11
|
-
export declare class WindowApi {
|
|
1
|
+
import type { UtilsWindowApiOption } from "./types/WindowApi";
|
|
2
|
+
declare class WindowApi {
|
|
12
3
|
/** 默认的配置 */
|
|
13
4
|
private defaultApi;
|
|
14
5
|
/** 使用的配置 */
|
|
@@ -20,3 +11,4 @@ export declare class WindowApi {
|
|
|
20
11
|
get self(): Window & typeof globalThis;
|
|
21
12
|
get top(): Window;
|
|
22
13
|
}
|
|
14
|
+
export { WindowApi };
|