@whitesev/utils 2.8.0 → 2.8.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 (71) hide show
  1. package/README.md +176 -176
  2. package/dist/index.amd.js +896 -875
  3. package/dist/index.amd.js.map +1 -1
  4. package/dist/index.cjs.js +896 -875
  5. package/dist/index.cjs.js.map +1 -1
  6. package/dist/index.esm.js +896 -875
  7. package/dist/index.esm.js.map +1 -1
  8. package/dist/index.iife.js +896 -875
  9. package/dist/index.iife.js.map +1 -1
  10. package/dist/index.system.js +896 -875
  11. package/dist/index.system.js.map +1 -1
  12. package/dist/index.umd.js +896 -875
  13. package/dist/index.umd.js.map +1 -1
  14. package/dist/types/src/CommonUtil.d.ts +59 -59
  15. package/dist/types/src/DOMUtils.d.ts +1 -1
  16. package/dist/types/src/Dictionary.d.ts +1 -1
  17. package/dist/types/src/Httpx.d.ts +2 -2
  18. package/dist/types/src/Progress.d.ts +0 -4
  19. package/dist/types/src/TryCatch.d.ts +2 -2
  20. package/dist/types/src/Utils.d.ts +365 -365
  21. package/dist/types/src/UtilsGMCookie.d.ts +2 -2
  22. package/dist/types/src/UtilsGMMenu.d.ts +1 -1
  23. package/dist/types/src/indexedDB.d.ts +3 -3
  24. package/dist/types/src/types/Event.d.ts +188 -188
  25. package/dist/types/src/types/Httpx.d.ts +1344 -1343
  26. package/dist/types/src/types/Log.d.ts +19 -19
  27. package/dist/types/src/types/Progress.d.ts +20 -20
  28. package/dist/types/src/types/React.d.ts +119 -119
  29. package/dist/types/src/types/TryCatch.d.ts +9 -9
  30. package/dist/types/src/types/UtilsGMCookie.d.ts +93 -93
  31. package/dist/types/src/types/UtilsGMMenu.d.ts +77 -77
  32. package/dist/types/src/types/Vue2.d.ts +166 -166
  33. package/dist/types/src/types/WindowApi.d.ts +14 -14
  34. package/dist/types/src/types/ajaxHooker.d.ts +151 -151
  35. package/dist/types/src/types/env.d.ts +7 -2
  36. package/dist/types/src/types/global.d.ts +31 -31
  37. package/index.ts +3 -0
  38. package/package.json +19 -8
  39. package/src/ColorConversion.ts +105 -106
  40. package/src/CommonUtil.ts +280 -279
  41. package/src/DOMUtils.ts +251 -272
  42. package/src/Dictionary.ts +153 -154
  43. package/src/GBKEncoder.ts +108 -112
  44. package/src/Hooks.ts +73 -81
  45. package/src/Httpx.ts +1457 -1466
  46. package/src/LockFunction.ts +62 -62
  47. package/src/Log.ts +258 -259
  48. package/src/ModuleRaid.js +1 -0
  49. package/src/Progress.ts +108 -114
  50. package/src/TryCatch.ts +86 -86
  51. package/src/Utils.ts +4773 -4825
  52. package/src/UtilsCommon.ts +14 -14
  53. package/src/UtilsGMCookie.ts +254 -261
  54. package/src/UtilsGMMenu.ts +445 -454
  55. package/src/Vue.ts +233 -229
  56. package/src/WindowApi.ts +59 -59
  57. package/src/ajaxHooker/ajaxHooker.js +1 -0
  58. package/src/indexedDB.ts +497 -502
  59. package/src/types/Event.d.ts +188 -188
  60. package/src/types/Httpx.d.ts +1344 -1343
  61. package/src/types/Log.d.ts +19 -19
  62. package/src/types/Progress.d.ts +20 -20
  63. package/src/types/React.d.ts +119 -119
  64. package/src/types/TryCatch.d.ts +9 -9
  65. package/src/types/UtilsGMCookie.d.ts +93 -93
  66. package/src/types/UtilsGMMenu.d.ts +77 -77
  67. package/src/types/Vue2.d.ts +166 -166
  68. package/src/types/WindowApi.d.ts +14 -14
  69. package/src/types/ajaxHooker.d.ts +151 -151
  70. package/src/types/env.d.ts +7 -2
  71. package/src/types/global.d.ts +31 -31
@@ -1,77 +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
+ 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,166 +1,166 @@
1
- /**
2
- * Vue2实例
3
- */
4
- export declare interface Vue2Instance {
5
- $attrs: any;
6
- $children: Vue2Instance[];
7
- $createElement: (...args: any[]) => any;
8
- $el: HTMLElement;
9
- $listeners: any;
10
- $options: any;
11
- $parent: Vue2Instance;
12
- $refs: any;
13
- $root: Vue2Instance;
14
- $scopedSlots: any;
15
- $slots: any;
16
- $store: any;
17
- $vnode: any;
18
-
19
- _data: any;
20
- _directInactive: boolean;
21
- _events: any;
22
- _hasHookEvent: boolean;
23
- _isBeingDestroyed: boolean;
24
- _isDestroyed: boolean;
25
- _isMounted: boolean;
26
- _isVue: boolean;
27
-
28
- $data: any;
29
- $isServer: boolean;
30
- $props: any;
31
- $route: {
32
- fullPath: string;
33
- hash: string;
34
- matched: any[];
35
- meta: any;
36
- name: string;
37
- params: any;
38
- path: string;
39
- query: any;
40
- [key: string]: any;
41
- };
42
- $router: {
43
- afterHooks: Function[];
44
- app: Vue2Instance;
45
- apps: Vue2Instance[];
46
- beforeHooks: Function[];
47
- fallback: boolean;
48
- history: {
49
- base: string;
50
- current: Vue2Instance["$route"];
51
- listeners: any[];
52
- router: Vue2Instance["$router"];
53
- /**
54
- *
55
- * @param delta 访问的距离。如果 delta < 0 则后退相应数量的记录,如果 > 0 则前进。
56
- * @param triggerListeners 是否应该触发连接到该历史的监听器
57
- */
58
- go: (delta: number, triggerListeners?: boolean) => void;
59
- /**
60
- *
61
- * @param to 要设置的地址
62
- * @param data 可选的 HistoryState 以关联该导航记录
63
- */
64
- push: (to: string, data?: any) => void;
65
- /**
66
- *
67
- * @param to 要设置的地址
68
- * @param data 可选的 HistoryState 以关联该导航记录
69
- */
70
- replace: (to: string, data?: any) => void;
71
- [key: string]: any;
72
- };
73
- matcher: {
74
- addRoute: (...args: any[]) => any;
75
- addRoutes: (...args: any[]) => any;
76
- getRoutes: () => any;
77
- match: (...args: any[]) => any;
78
- [key: string]: any;
79
- };
80
- mode: string;
81
- options: {
82
- mode: string;
83
- routes: any[];
84
- scrollBehavior: (...args: any[]) => any;
85
- [key: string]: any;
86
- };
87
- resolveHooks: ((...args: any[]) => any)[];
88
- currentRoute: Vue2Instance["$route"];
89
- beforeEach: (
90
- callback:
91
- | ((
92
- /** 即将要进入的目标 路由对象 */
93
- to: Vue2Instance["$route"],
94
- /** 当前导航正要离开的路由 */
95
- from: Vue2Instance["$route"],
96
- /**
97
- *
98
- * + next(): 进行管道中的下一个钩子。如果全部钩子执行完了,则导航的状态就是 confirmed (确认的)。
99
- * + next(false): 中断当前的导航。如果浏览器的 URL 改变了 (可能是用户手动或者浏览器后退按钮),那么 URL 地址会重置到 from 路由对应的地址。
100
- * + next('/') 或者 next({ path: '/' }): 跳转到一个不同的地址。当前的导航被中断,然后进行一个新的导航。你可以向 next 传递任意位置对象,且允许设置诸如 replace: true、name: 'home' 之类的选项以及任何用在 router-link 的 to prop 或 router.push 中的选项。
101
- * + next(error): (2.4.0+) 如果传入 next 的参数是一个 Error 实例,则导航会被终止且该错误会被传递给 router.onError() 注册过的回调。
102
- */
103
- next: Function
104
- ) => void)
105
- /** 移除上一个添加的监听 */
106
- | (() => void)
107
- ) => void;
108
-
109
- afterEach: (
110
- callback:
111
- | ((
112
- /** 即将要进入的目标 路由对象 */
113
- to: Vue2Instance["$route"],
114
- /** 当前导航正要离开的路由 */
115
- from: Vue2Instance["$route"]
116
- ) => void)
117
- /** 移除上一个添加的监听 */
118
- | (() => void)
119
- ) => void;
120
- push: (...args: any[]) => void;
121
- back: () => void;
122
- go: (...args: any[]) => void;
123
- replace: (...args: any[]) => void;
124
- /** 添加路由 */
125
- addRoute: (...args: any[]) => void;
126
- addRoutes: (...args: any[]) => void;
127
- [key: string]: any;
128
- };
129
- $ssrContext: any;
130
- /** 观察者 @returns 取消观察者 */
131
- $watch: (
132
- /** 需要观察的属性 */
133
- key: string | string[] | (() => any),
134
- /** 属性改变时触发的回调 */
135
- handler: (
136
- this: Vue2Instance,
137
- /** 新值,也就是改变后的值 */
138
- newVal: any,
139
- /** 旧值,也就是改变前的值 */
140
- oldVal: any
141
- ) => void,
142
- /** 监听配置 */
143
- options?: {
144
- /** 是否立即执行handler */
145
- immediate?: boolean;
146
- /** 是否深度监听 */
147
- deep?: boolean;
148
- }
149
- ) => Function;
150
-
151
- [key: string]: any;
152
- }
153
-
154
- /**
155
- * 包含vue属性的HTMLElement
156
- */
157
- export declare interface Vue2HTMLElement extends HTMLElement {
158
- __vue__: Vue2Instance;
159
- }
160
-
161
- /**
162
- * 包含vue属性的HTMLElement
163
- */
164
- export declare interface Vue2HTMLDivElement extends HTMLDivElement {
165
- __vue__: Vue2Instance;
166
- }
1
+ /**
2
+ * Vue2实例
3
+ */
4
+ export declare interface Vue2Instance {
5
+ $attrs: any;
6
+ $children: Vue2Instance[];
7
+ $createElement: (...args: any[]) => any;
8
+ $el: HTMLElement;
9
+ $listeners: any;
10
+ $options: any;
11
+ $parent: Vue2Instance;
12
+ $refs: any;
13
+ $root: Vue2Instance;
14
+ $scopedSlots: any;
15
+ $slots: any;
16
+ $store: any;
17
+ $vnode: any;
18
+
19
+ _data: any;
20
+ _directInactive: boolean;
21
+ _events: any;
22
+ _hasHookEvent: boolean;
23
+ _isBeingDestroyed: boolean;
24
+ _isDestroyed: boolean;
25
+ _isMounted: boolean;
26
+ _isVue: boolean;
27
+
28
+ $data: any;
29
+ $isServer: boolean;
30
+ $props: any;
31
+ $route: {
32
+ fullPath: string;
33
+ hash: string;
34
+ matched: any[];
35
+ meta: any;
36
+ name: string;
37
+ params: any;
38
+ path: string;
39
+ query: any;
40
+ [key: string]: any;
41
+ };
42
+ $router: {
43
+ afterHooks: ((...args: any[]) => any)[];
44
+ app: Vue2Instance;
45
+ apps: Vue2Instance[];
46
+ beforeHooks: ((...args: any[]) => any)[];
47
+ fallback: boolean;
48
+ history: {
49
+ base: string;
50
+ current: Vue2Instance["$route"];
51
+ listeners: any[];
52
+ router: Vue2Instance["$router"];
53
+ /**
54
+ *
55
+ * @param delta 访问的距离。如果 delta < 0 则后退相应数量的记录,如果 > 0 则前进。
56
+ * @param triggerListeners 是否应该触发连接到该历史的监听器
57
+ */
58
+ go: (delta: number, triggerListeners?: boolean) => void;
59
+ /**
60
+ *
61
+ * @param to 要设置的地址
62
+ * @param data 可选的 HistoryState 以关联该导航记录
63
+ */
64
+ push: (to: string, data?: any) => void;
65
+ /**
66
+ *
67
+ * @param to 要设置的地址
68
+ * @param data 可选的 HistoryState 以关联该导航记录
69
+ */
70
+ replace: (to: string, data?: any) => void;
71
+ [key: string]: any;
72
+ };
73
+ matcher: {
74
+ addRoute: (...args: any[]) => any;
75
+ addRoutes: (...args: any[]) => any;
76
+ getRoutes: () => any;
77
+ match: (...args: any[]) => any;
78
+ [key: string]: any;
79
+ };
80
+ mode: string;
81
+ options: {
82
+ mode: string;
83
+ routes: any[];
84
+ scrollBehavior: (...args: any[]) => any;
85
+ [key: string]: any;
86
+ };
87
+ resolveHooks: ((...args: any[]) => any)[];
88
+ currentRoute: Vue2Instance["$route"];
89
+ beforeEach: (
90
+ callback:
91
+ | ((
92
+ /** 即将要进入的目标 路由对象 */
93
+ to: Vue2Instance["$route"],
94
+ /** 当前导航正要离开的路由 */
95
+ from: Vue2Instance["$route"],
96
+ /**
97
+ *
98
+ * + next(): 进行管道中的下一个钩子。如果全部钩子执行完了,则导航的状态就是 confirmed (确认的)。
99
+ * + next(false): 中断当前的导航。如果浏览器的 URL 改变了 (可能是用户手动或者浏览器后退按钮),那么 URL 地址会重置到 from 路由对应的地址。
100
+ * + next('/') 或者 next({ path: '/' }): 跳转到一个不同的地址。当前的导航被中断,然后进行一个新的导航。你可以向 next 传递任意位置对象,且允许设置诸如 replace: true、name: 'home' 之类的选项以及任何用在 router-link 的 to prop 或 router.push 中的选项。
101
+ * + next(error): (2.4.0+) 如果传入 next 的参数是一个 Error 实例,则导航会被终止且该错误会被传递给 router.onError() 注册过的回调。
102
+ */
103
+ next: (...args: any[]) => any
104
+ ) => void)
105
+ /** 移除上一个添加的监听 */
106
+ | (() => void)
107
+ ) => void;
108
+
109
+ afterEach: (
110
+ callback:
111
+ | ((
112
+ /** 即将要进入的目标 路由对象 */
113
+ to: Vue2Instance["$route"],
114
+ /** 当前导航正要离开的路由 */
115
+ from: Vue2Instance["$route"]
116
+ ) => void)
117
+ /** 移除上一个添加的监听 */
118
+ | (() => void)
119
+ ) => void;
120
+ push: (...args: any[]) => void;
121
+ back: () => void;
122
+ go: (...args: any[]) => void;
123
+ replace: (...args: any[]) => void;
124
+ /** 添加路由 */
125
+ addRoute: (...args: any[]) => void;
126
+ addRoutes: (...args: any[]) => void;
127
+ [key: string]: any;
128
+ };
129
+ $ssrContext: any;
130
+ /** 观察者 @returns 取消观察者 */
131
+ $watch: (
132
+ /** 需要观察的属性 */
133
+ key: string | string[] | (() => any),
134
+ /** 属性改变时触发的回调 */
135
+ handler: (
136
+ this: Vue2Instance,
137
+ /** 新值,也就是改变后的值 */
138
+ newVal: any,
139
+ /** 旧值,也就是改变前的值 */
140
+ oldVal: any
141
+ ) => void,
142
+ /** 监听配置 */
143
+ options?: {
144
+ /** 是否立即执行handler */
145
+ immediate?: boolean;
146
+ /** 是否深度监听 */
147
+ deep?: boolean;
148
+ }
149
+ ) => (...args: any[]) => any;
150
+
151
+ [key: string]: any;
152
+ }
153
+
154
+ /**
155
+ * 包含vue属性的HTMLElement
156
+ */
157
+ export declare interface Vue2HTMLElement extends HTMLElement {
158
+ __vue__: Vue2Instance;
159
+ }
160
+
161
+ /**
162
+ * 包含vue属性的HTMLElement
163
+ */
164
+ export declare interface Vue2HTMLDivElement extends HTMLDivElement {
165
+ __vue__: Vue2Instance;
166
+ }
@@ -1,14 +1,14 @@
1
- /**
2
- * 配置类型
3
- */
4
- export type WindowApiOption = {
5
- document: Document;
6
- window: Window & typeof globalThis;
7
- globalThis?: typeof globalThis | Window;
8
- self?: Window & typeof globalThis;
9
- top: Window;
10
- setTimeout: Window["setTimeout"];
11
- setInterval: Window["setInterval"];
12
- clearTimeout: Window["clearTimeout"];
13
- clearInterval: Window["clearInterval"];
14
- };
1
+ /**
2
+ * 配置类型
3
+ */
4
+ export type WindowApiOption = {
5
+ document: Document;
6
+ window: Window & typeof globalThis;
7
+ globalThis?: typeof globalThis | Window;
8
+ self?: Window & typeof globalThis;
9
+ top: Window;
10
+ setTimeout: Window["setTimeout"];
11
+ setInterval: Window["setInterval"];
12
+ clearTimeout: Window["clearTimeout"];
13
+ clearInterval: Window["clearInterval"];
14
+ };