@whitesev/utils 1.0.5 → 1.0.8

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 (59) hide show
  1. package/dist/index.amd.js +2123 -2269
  2. package/dist/index.amd.js.map +1 -1
  3. package/dist/index.cjs.js +2123 -2269
  4. package/dist/index.cjs.js.map +1 -1
  5. package/dist/index.esm.js +2123 -2269
  6. package/dist/index.esm.js.map +1 -1
  7. package/dist/index.iife.js +2123 -2269
  8. package/dist/index.iife.js.map +1 -1
  9. package/dist/index.system.js +2123 -2269
  10. package/dist/index.system.js.map +1 -1
  11. package/dist/index.umd.js +2123 -2269
  12. package/dist/index.umd.js.map +1 -1
  13. package/dist/src/Dictionary.d.ts +82 -0
  14. package/dist/src/Hooks.d.ts +11 -0
  15. package/dist/src/Httpx.d.ts +1201 -0
  16. package/dist/src/LockFunction.d.ts +31 -0
  17. package/dist/src/Log.d.ts +96 -0
  18. package/dist/src/Progress.d.ts +37 -0
  19. package/dist/src/UtilsGMMenu.d.ts +156 -0
  20. package/dist/src/index.d.ts +20 -27
  21. package/dist/src/indexedDB.d.ts +73 -0
  22. package/dist/src/tryCatch.d.ts +31 -0
  23. package/package.json +36 -36
  24. package/src/Dictionary.ts +152 -0
  25. package/src/{Hooks/Hooks.js → Hooks.ts} +31 -17
  26. package/src/{Httpx/index.d.ts → Httpx.ts} +837 -46
  27. package/src/LockFunction.ts +62 -0
  28. package/src/Log.ts +281 -0
  29. package/src/Progress.ts +143 -0
  30. package/src/UtilsGMMenu.ts +530 -0
  31. package/src/index.ts +17 -29
  32. package/src/indexedDB.ts +421 -0
  33. package/src/tryCatch.ts +107 -0
  34. package/tsconfig.json +1 -1
  35. package/dist/src/Dictionary/Dictionary.d.ts +0 -85
  36. package/dist/src/Hooks/Hooks.d.ts +0 -5
  37. package/dist/src/Httpx/Httpx.d.ts +0 -50
  38. package/dist/src/LockFunction/LockFunction.d.ts +0 -16
  39. package/dist/src/Log/Log.d.ts +0 -66
  40. package/dist/src/Progress/Progress.d.ts +0 -6
  41. package/dist/src/UtilsGMMenu/UtilsGMMenu.d.ts +0 -119
  42. package/dist/src/indexedDB/indexedDB.d.ts +0 -165
  43. package/dist/src/tryCatch/tryCatch.d.ts +0 -31
  44. package/src/Dictionary/Dictionary.js +0 -157
  45. package/src/Dictionary/index.d.ts +0 -52
  46. package/src/Hooks/index.d.ts +0 -16
  47. package/src/Httpx/Httpx.js +0 -747
  48. package/src/LockFunction/LockFunction.js +0 -35
  49. package/src/LockFunction/index.d.ts +0 -47
  50. package/src/Log/Log.js +0 -256
  51. package/src/Log/index.d.ts +0 -91
  52. package/src/Progress/Progress.js +0 -98
  53. package/src/Progress/index.d.ts +0 -30
  54. package/src/UtilsGMMenu/UtilsGMMenu.js +0 -464
  55. package/src/UtilsGMMenu/index.d.ts +0 -224
  56. package/src/indexedDB/index.d.ts +0 -128
  57. package/src/indexedDB/indexedDB.js +0 -355
  58. package/src/tryCatch/index.d.ts +0 -6
  59. package/src/tryCatch/tryCatch.js +0 -100
@@ -0,0 +1,530 @@
1
+ import { Utils } from ".";
2
+
3
+ declare interface UtilsGMMenuClickCallBackData {
4
+ /** 菜单键名 */
5
+ key: string;
6
+ /** 是否启用 */
7
+ enable: boolean;
8
+ /** 点击前的enable值 */
9
+ oldEnable: boolean;
10
+ /** 触发的事件 */
11
+ event: MouseEvent | KeyboardEvent;
12
+ /** 将enable值写入本地的回调,设置参数false就不保存到本地 */
13
+ storeValue(enable: boolean): void;
14
+ }
15
+
16
+ declare interface UtilsGMMenuOption {
17
+ /** 菜单的本地键key,不可重复,会覆盖 */
18
+ key: string;
19
+ /** 菜单的文本 */
20
+ text: string;
21
+ /** (可选)菜单的开启状态,默认为false */
22
+ enable?: boolean;
23
+ /** (可选)使用条件:TamperMonkey版本>5.0,如果id和已注册的菜单id相同,可修改当前已注册菜单的options */
24
+ id?: number;
25
+ /** (可选)An optional access key. Please see the description below. Either options or accessKey can be specified. */
26
+ accessKey?: string;
27
+ /** (可选)自动关闭菜单,可不设置 */
28
+ autoClose?: boolean;
29
+ /** 使用条件:TamperMonkey版本>5.0,使用菜单项的鼠标悬浮上的工具提示*/
30
+ title?: string;
31
+ /** (可选)点击菜单后自动刷新网页,默认为true */
32
+ autoReload?: boolean;
33
+ /** 菜单的显示文本,未设置的话则自动根据enable在前面加上图标 */
34
+ showText(text: string, enable: boolean): string;
35
+ /** 点击菜单的回调 */
36
+ callback(data: UtilsGMMenuClickCallBackData): void;
37
+ /** 是否允许菜单进行存储值,默认true允许 */
38
+ isStoreValue?: boolean;
39
+ }
40
+
41
+ declare interface UtilsGMMenuHandledOption extends UtilsGMMenuOption {
42
+ /**
43
+ * 删除该菜单
44
+ */
45
+ deleteMenu(): void;
46
+ }
47
+
48
+ declare interface UtilsGMMenuOptionData {
49
+ /**
50
+ * 菜单id
51
+ */
52
+ id?: number;
53
+ /**
54
+ * 菜单配置
55
+ */
56
+ data: UtilsGMMenuOption;
57
+ /**
58
+ * 处理后的菜单配置
59
+ * 对autoReload进行处理,如果未赋值,按默认的true赋值
60
+ * 对isStoreValue进行处理,如果未赋值,按默认的true赋值
61
+ * 新增一个deleteMenu
62
+ */
63
+ handleData: UtilsGMMenuHandledOption;
64
+ }
65
+
66
+ declare interface UtilsGMMenuConstructorOptions {
67
+ /** (可选)配置*/
68
+ data?: UtilsGMMenuOption[];
69
+ /** (可选)全局菜单点击菜单后自动刷新网页,默认为true */
70
+ autoReload?: boolean;
71
+ /** 油猴函数 @grant GM_getValue */
72
+ GM_getValue: any;
73
+ /** 油猴函数 @grant GM_setValue */
74
+ GM_setValue: any;
75
+ /** 油猴函数 @grant GM_registerMenuCommand */
76
+ GM_registerMenuCommand: any;
77
+ /** 油猴函数 @grant GM_unregisterMenuCommand */
78
+ GM_unregisterMenuCommand: any;
79
+ }
80
+
81
+ class GMMenu {
82
+ private GM_Api = {
83
+ /**
84
+ * 获取存储的数据
85
+ */
86
+ getValue: null as any,
87
+ /**
88
+ * 设置数据到存储
89
+ */
90
+ setValue: null as any,
91
+ /**
92
+ * 注册菜单
93
+ */
94
+ registerMenuCommand: null as any,
95
+ /**
96
+ * 卸载菜单
97
+ */
98
+ unregisterMenuCommand: null as any,
99
+ };
100
+ private MenuHandle = {
101
+ context: this,
102
+ $data: {
103
+ /**
104
+ * 菜单数据
105
+ */
106
+ data: <UtilsGMMenuOptionData[]>[],
107
+ /**
108
+ * 本地存储的键名
109
+ */
110
+ key: "GM_Menu_Local_Map",
111
+ },
112
+ $default: {
113
+ /** 自动刷新网页,默认为true */
114
+ autoReload: true,
115
+ /**
116
+ * 菜单isStoreValue的默认值
117
+ */
118
+ isStoreValue: true,
119
+ },
120
+ $emoji: {
121
+ /**
122
+ * 菜单enable为true的emoji
123
+ */
124
+ success: "✅",
125
+ /**
126
+ * 菜单enable为false的emoji
127
+ */
128
+ error: "❌",
129
+ },
130
+ /**
131
+ * 初始化数据
132
+ */
133
+ init() {
134
+ for (let index = 0; index < this.$data.data.length; index++) {
135
+ let menuOption = this.$data.data[index]["data"];
136
+ menuOption.enable = Boolean(
137
+ this.getLocalMenuData(menuOption.key, menuOption.enable as boolean)
138
+ );
139
+ if (typeof menuOption.showText !== "function") {
140
+ menuOption.showText = (menuText, menuEnable) => {
141
+ if (menuEnable) {
142
+ return this.$emoji.success + " " + menuText;
143
+ } else {
144
+ return this.$emoji.error + " " + menuText;
145
+ }
146
+ };
147
+ }
148
+ }
149
+ },
150
+ /**
151
+ * 注册油猴菜单
152
+ * @param menuOptions 如果存在,使用它
153
+ */
154
+ register(menuOptions?: UtilsGMMenuOptionData[]) {
155
+ let that = this;
156
+ if (menuOptions == null) {
157
+ throw new TypeError("register菜单数据不能为空");
158
+ }
159
+ if (!Array.isArray(menuOptions)) {
160
+ menuOptions = [menuOptions];
161
+ }
162
+ for (let index = 0; index < menuOptions.length; index++) {
163
+ let cloneMenuOptionData = Utils.deepClone(menuOptions[index].data);
164
+ const { showText, clickCallBack } = this.handleMenuData(
165
+ cloneMenuOptionData as Required<UtilsGMMenuOption>
166
+ );
167
+ let menuId = that.context.GM_Api.registerMenuCommand(
168
+ showText,
169
+ clickCallBack
170
+ );
171
+ menuOptions[index].id = menuId;
172
+ (cloneMenuOptionData as any).deleteMenu = function () {
173
+ that.context.GM_Api.unregisterMenuCommand(menuId);
174
+ };
175
+ Reflect.deleteProperty(menuOptions[index], "handleData");
176
+ (menuOptions[index] as any).handleData = cloneMenuOptionData;
177
+ }
178
+ },
179
+ /**
180
+ * 获取本地存储菜单键值
181
+ * @param {string} key 键
182
+ */
183
+ getLocalMenuData(key: string, defaultValue: boolean): boolean {
184
+ let localData = this.context.GM_Api.getValue(this.$data.key, {});
185
+ if (key in localData) {
186
+ return (localData as any)[key];
187
+ } else {
188
+ return defaultValue;
189
+ }
190
+ },
191
+ /**
192
+ * 设置本地存储菜单键值
193
+ * @param key 键
194
+ * @param value 值
195
+ */
196
+ setLocalMenuData(key: string, value: boolean) {
197
+ let localData = this.context.GM_Api.getValue(this.$data.key, {});
198
+ (localData as any)[key] = value;
199
+ this.context.GM_Api.setValue(this.$data.key, localData);
200
+ },
201
+ /**
202
+ * 处理初始化配置
203
+ * @param menuOption
204
+ */
205
+ handleInitDetail(menuOption: Required<UtilsGMMenuOption>) {
206
+ menuOption.enable = Boolean(
207
+ this.getLocalMenuData(menuOption.key, menuOption.enable)
208
+ );
209
+ if (typeof menuOption.showText !== "function") {
210
+ menuOption.showText = (menuText, menuEnable) => {
211
+ if (menuEnable) {
212
+ return this.$emoji.success + " " + menuText;
213
+ } else {
214
+ return this.$emoji.error + " " + menuText;
215
+ }
216
+ };
217
+ }
218
+ return menuOption;
219
+ },
220
+ /**
221
+ * 对菜单数据进行处理
222
+ * @param menuOption
223
+ */
224
+ handleMenuData(menuOption: Required<UtilsGMMenuOption>) {
225
+ let that = this;
226
+ let menuLocalDataItemKey = menuOption.key;
227
+ /* 菜单默认开启的状态 */
228
+ let defaultEnable = Boolean(
229
+ this.getLocalMenuData(menuLocalDataItemKey, menuOption.enable)
230
+ );
231
+ /** 油猴菜单上显示的文本 */
232
+ let showText = menuOption.showText(menuOption.text, defaultEnable);
233
+ const GMMenuOptions = {
234
+ /**
235
+ * 菜单的id
236
+ */
237
+ id: menuOption.id,
238
+ /**
239
+ * 点击菜单项后是否应关闭弹出菜单
240
+ */
241
+ autoClose: menuOption.autoClose,
242
+ /**
243
+ * 菜单项的可选访问键
244
+ */
245
+ accessKey: menuOption.accessKey,
246
+ /**
247
+ * 菜单项的鼠标悬浮上的工具提示
248
+ */
249
+ title: menuOption.title,
250
+ };
251
+ /* 点击菜单后触发callback后的网页是否刷新 */
252
+ menuOption.autoReload =
253
+ typeof menuOption.autoReload !== "boolean"
254
+ ? this.$default.autoReload
255
+ : menuOption.autoReload;
256
+ /* 点击菜单后触发callback后的网页是否存储值 */
257
+ menuOption.isStoreValue =
258
+ typeof menuOption.isStoreValue !== "boolean"
259
+ ? this.$default.isStoreValue
260
+ : menuOption.isStoreValue;
261
+ /**
262
+ * 用户点击菜单后的回调函数
263
+ * @param event
264
+ */
265
+ function clickCallBack(event: MouseEvent | PointerEvent) {
266
+ let localEnable = Boolean(
267
+ that.getLocalMenuData(menuLocalDataItemKey, defaultEnable)
268
+ );
269
+ if (menuOption.isStoreValue) {
270
+ that.setLocalMenuData(menuLocalDataItemKey, !localEnable);
271
+ }
272
+ if (typeof menuOption.callback === "function") {
273
+ menuOption.callback({
274
+ key: menuLocalDataItemKey,
275
+ enable: !localEnable,
276
+ oldEnable: localEnable,
277
+ event: event,
278
+ storeValue(value) {
279
+ that.setLocalMenuData(menuLocalDataItemKey, value);
280
+ },
281
+ });
282
+ }
283
+ /* 不刷新网页就刷新菜单 */
284
+ if (menuOption.autoReload) {
285
+ window.location.reload();
286
+ } else {
287
+ that.context.update();
288
+ }
289
+ }
290
+
291
+ return {
292
+ showText,
293
+ clickCallBack,
294
+ };
295
+ },
296
+ /**
297
+ * 获取目标菜单配置数据
298
+ * @param menuKey 菜单-键key
299
+ */
300
+ getMenuData(menuKey: string) {
301
+ return this.$data.data.find((item) => item.data.key === menuKey);
302
+ },
303
+ /**
304
+ * 获取目标菜单配置
305
+ * @param menuKey 菜单-键key
306
+ */
307
+ getMenuOption(menuKey: string) {
308
+ return this.$data.data.find((item) => item.data.key === menuKey)?.data;
309
+ },
310
+ /**
311
+ * 获取目标菜单处理后的配置
312
+ * @param menuKey 菜单-键key
313
+ */
314
+ getMenuHandledOption(menuKey: string) {
315
+ return this.$data.data.find((item) => item!.handleData!.key === menuKey)
316
+ ?.handleData;
317
+ },
318
+ };
319
+ constructor(details: UtilsGMMenuConstructorOptions) {
320
+ this.GM_Api.getValue = details.GM_getValue;
321
+ this.GM_Api.setValue = details.GM_setValue;
322
+ this.GM_Api.registerMenuCommand = details.GM_registerMenuCommand;
323
+ this.GM_Api.unregisterMenuCommand = details.GM_unregisterMenuCommand;
324
+ this.MenuHandle.$default.autoReload =
325
+ typeof details.autoReload === "boolean" ? details.autoReload : true;
326
+ for (const keyName of Object.keys(this.GM_Api)) {
327
+ if (typeof (this.GM_Api as any)[keyName] !== "function") {
328
+ throw new Error(
329
+ `Utils.GM_Menu 请在脚本开头加上 @grant ${keyName},且传入该对象`
330
+ );
331
+ }
332
+ }
333
+ this.add(details?.data || []);
334
+ }
335
+ /**
336
+ * 新增菜单数据
337
+ * @param paramData
338
+ */
339
+ add(paramData: UtilsGMMenuOption[] | UtilsGMMenuOption) {
340
+ if (Array.isArray(paramData)) {
341
+ for (const _paramData of paramData) {
342
+ // @ts-ignore
343
+ this.MenuHandle.$data.data.push({
344
+ data: _paramData,
345
+ id: void 0,
346
+ });
347
+ }
348
+ } else {
349
+ // @ts-ignore
350
+ this.MenuHandle.$data.data.push({
351
+ data: paramData,
352
+ id: void 0,
353
+ });
354
+ }
355
+ this.update();
356
+ }
357
+ /**
358
+ * 更新菜单数据
359
+ * @param options 数据
360
+ */
361
+ update(options?: UtilsGMMenuOption[] | UtilsGMMenuOption) {
362
+ let optionsList: UtilsGMMenuOption[] = [];
363
+ if (Array.isArray(options)) {
364
+ optionsList = [...optionsList, ...options];
365
+ } else if (options != null) {
366
+ optionsList = [...optionsList, options];
367
+ }
368
+ optionsList.forEach((item) => {
369
+ let targetMenu = this.MenuHandle.getMenuOption(item.key);
370
+ if (targetMenu) {
371
+ Object.assign(targetMenu, item);
372
+ }
373
+ });
374
+ this.MenuHandle.$data.data.forEach((value) => {
375
+ if (value.handleData) {
376
+ value.handleData.deleteMenu();
377
+ }
378
+ });
379
+ this.MenuHandle.init();
380
+ this.MenuHandle.register(this.MenuHandle.$data.data);
381
+ }
382
+ /**
383
+ * 卸载菜单
384
+ * @param menuId 已注册的菜单id
385
+ */
386
+ delete(menuId: number) {
387
+ this.GM_Api.unregisterMenuCommand(menuId);
388
+ }
389
+ /**
390
+ * 根据键值获取enable值
391
+ * @param menuKey 菜单-键key
392
+ */
393
+ get(menuKey: string): boolean {
394
+ return this.getEnable(menuKey);
395
+ }
396
+ /**
397
+ * 根据键值获取enable值
398
+ * @param menuKey 菜单-键key
399
+ */
400
+ getEnable(menuKey: string): boolean {
401
+ return this.MenuHandle.getMenuHandledOption(menuKey)!.enable as boolean;
402
+ }
403
+ /**
404
+ * 根据键值获取text值
405
+ * @param menuKey 菜单-键key
406
+ */
407
+ getText(menuKey: string): string {
408
+ return this.MenuHandle.getMenuHandledOption(menuKey)!.text;
409
+ }
410
+ /**
411
+ * 根据键值获取showText函数的值
412
+ * @param menuKey 菜单-键key
413
+ */
414
+ getShowTextValue(menuKey: string): string {
415
+ return this.MenuHandle.getMenuHandledOption(menuKey)!.showText(
416
+ this.getText(menuKey),
417
+ this.get(menuKey)
418
+ );
419
+ }
420
+ /**
421
+ * 获取当前已注册菜单的id
422
+ * @param menuKey
423
+ */
424
+ getMenuId(menuKey: string): number | undefined | null {
425
+ let result = null;
426
+ for (let index = 0; index < this.MenuHandle.$data.data.length; index++) {
427
+ const optionData = this.MenuHandle.$data.data[index];
428
+ if (optionData!.handleData!.key === menuKey) {
429
+ result = optionData.id;
430
+ break;
431
+ }
432
+ }
433
+ return result;
434
+ }
435
+ /**
436
+ * 根据键值获取accessKey值
437
+ * @param menuKey 菜单-键key
438
+ */
439
+ getAccessKey(menuKey: string): string | undefined {
440
+ return this.MenuHandle.getMenuHandledOption(menuKey)?.accessKey;
441
+ }
442
+ /**
443
+ * 根据键值获取autoClose值
444
+ * @param menuKey 菜单-键key
445
+ */
446
+ getAutoClose(menuKey: string): boolean | undefined {
447
+ return this.MenuHandle.getMenuHandledOption(menuKey)?.autoClose;
448
+ }
449
+ /**
450
+ * 根据键值获取autoReload值
451
+ * @param menuKey 菜单-键key
452
+ */
453
+ getAutoReload(menuKey: string): boolean | undefined {
454
+ return this.MenuHandle.getMenuHandledOption(menuKey)?.autoReload;
455
+ }
456
+ /**
457
+ * 根据键值获取callback函数
458
+ * @param menuKey 菜单-键key
459
+ */
460
+ getCallBack(menuKey: string): Function | undefined {
461
+ return this.MenuHandle.getMenuHandledOption(menuKey)?.callback;
462
+ }
463
+ /**
464
+ * 获取当enable为true时默认显示在菜单中前面的emoji图标
465
+ */
466
+ getEnableTrueEmoji() {
467
+ return this.MenuHandle.$emoji.success;
468
+ }
469
+ /**
470
+ * 获取当enable为false时默认显示在菜单中前面的emoji图标
471
+ */
472
+ getEnableFalseEmoji() {
473
+ return this.MenuHandle.$emoji.error;
474
+ }
475
+ /**
476
+ * 获取本地存储的菜单外部的键名
477
+ * @param keyName
478
+ */
479
+ getLocalStorageKeyName() {
480
+ return this.MenuHandle.$data.key;
481
+ }
482
+ /**
483
+ * 设置菜单的值
484
+ * @param menuKey 菜单-键key
485
+ * @param value 需要设置的值
486
+ */
487
+ setValue(menuKey: string, value: any) {
488
+ this.MenuHandle.setLocalMenuData(menuKey, value);
489
+ }
490
+ /**
491
+ * 设置菜单的值
492
+ * @param menuKey 菜单-键key
493
+ * @param value 需要设置的值
494
+ */
495
+ setEnable(menuKey: string, value: boolean) {
496
+ this.setValue(menuKey, Boolean(value));
497
+ }
498
+ /**
499
+ * 设置当enable为true时默认显示在菜单中前面的emoji图标
500
+ * @param emojiString
501
+ */
502
+ setEnableTrueEmoji(emojiString: string) {
503
+ if (typeof emojiString !== "string") {
504
+ throw new Error("参数emojiString必须是string类型");
505
+ }
506
+ this.MenuHandle.$emoji.success = emojiString;
507
+ }
508
+ /**
509
+ * 设置当enable为false时默认显示在菜单中前面的emoji图标
510
+ * @param emojiString
511
+ */
512
+ setEnableFalseEmoji(emojiString: string) {
513
+ if (typeof emojiString !== "string") {
514
+ throw new Error("参数emojiString必须是string类型");
515
+ }
516
+ this.MenuHandle.$emoji.error = emojiString;
517
+ }
518
+ /**
519
+ * 设置本地存储的菜单外部的键名
520
+ * @param keyName
521
+ */
522
+ setLocalStorageKeyName(keyName: string) {
523
+ if (typeof keyName !== "string") {
524
+ throw new Error("参数keyName必须是string类型");
525
+ }
526
+ this.MenuHandle.$data.key = keyName;
527
+ }
528
+ }
529
+
530
+ export { GMMenu };
package/src/index.ts CHANGED
@@ -1,27 +1,18 @@
1
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" />
11
2
  import { ColorConversion } from "./ColorConversion";
12
3
  import { GBKEncoder } from "./GBKEncoder";
13
4
  import { UtilsCore } from "./UtilsCore";
14
5
  import { UtilsGMCookie } from "./UtilsGMCookie";
15
6
  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";
7
+ import { GMMenu } from "./UtilsGMMenu";
8
+ import { Hooks } from "./Hooks";
9
+ import { Httpx } from "./Httpx";
10
+ import { indexedDB } from "./indexedDB";
11
+ import { LockFunction } from "./LockFunction";
12
+ import { Log } from "./Log";
13
+ import { Progress } from "./Progress";
14
+ import { TryCatch } from "./tryCatch";
15
+ import { UtilsDictionary } from "./Dictionary";
25
16
 
26
17
  export declare var unsafeWindow: Window & typeof globalThis;
27
18
 
@@ -692,9 +683,7 @@ class Utils {
692
683
  * > true
693
684
  * dictionary.concat(dictionary2);
694
685
  **/
695
- Dictionary: {
696
- new <K, V>(): UtilsDictionaryConstructor<K, V>;
697
- } = UtilsDictionary as any;
686
+ Dictionary = UtilsDictionary;
698
687
  /**
699
688
  * 主动触发事件
700
689
  * @param element 元素
@@ -1845,7 +1834,7 @@ class Utils {
1845
1834
  // 删除键为menu_key的菜单
1846
1835
  GM_Menu.delete("menu_key");
1847
1836
  **/
1848
- GM_Menu: UtilsGMMenu = GMMenu as any;
1837
+ GM_Menu = GMMenu;
1849
1838
  /**
1850
1839
  * 基于Function prototype,能够勾住和释放任何函数
1851
1840
  *
@@ -1870,7 +1859,7 @@ class Utils {
1870
1859
  }
1871
1860
  testFunction.hook(testFunction,myFunction,window);
1872
1861
  **/
1873
- Hooks: UtilsHooks = Hooks;
1862
+ Hooks = Hooks;
1874
1863
 
1875
1864
  /**
1876
1865
  * 为减少代码量和回调,把GM_xmlhttpRequest封装
@@ -1910,7 +1899,7 @@ class Utils {
1910
1899
  })
1911
1900
  // 优先级为 默认details < 全局details < 单独的details
1912
1901
  */
1913
- Httpx: UtilsHttpx = Httpx;
1902
+ Httpx = Httpx;
1914
1903
  /**
1915
1904
  * 浏览器端的indexedDB操作封装
1916
1905
  * @example
@@ -1936,7 +1925,7 @@ class Utils {
1936
1925
  console.log(resolve,'清除数据库---->>>>>>name')
1937
1926
  })
1938
1927
  **/
1939
- indexedDB: UtilsIndexedDB = indexedDB;
1928
+ indexedDB = indexedDB;
1940
1929
  /**
1941
1930
  * 判断目标函数是否是Native Code
1942
1931
  * @param target
@@ -2590,7 +2579,7 @@ class Utils {
2590
2579
  await lock.run();
2591
2580
  > 1
2592
2581
  **/
2593
- LockFunction: UtilsLockFunction = LockFunction;
2582
+ LockFunction = LockFunction;
2594
2583
  /**
2595
2584
  * 日志对象
2596
2585
  * @param _GM_info_ 油猴管理器的API GM_info,或者是一个对象,如{"script":{name:"Utils.Log"}}
@@ -2620,7 +2609,7 @@ class Utils {
2620
2609
  log.success("颜色为#31dc02");
2621
2610
  > 颜色为#31dc02
2622
2611
  */
2623
- Log: UtilsLog = Log;
2612
+ Log = Log;
2624
2613
  /**
2625
2614
  * 合并数组内的JSON的值字符串
2626
2615
  * @param data 需要合并的数组
@@ -3214,7 +3203,7 @@ class Utils {
3214
3203
  let progress = new Utils.Process({canvasNode:document.querySelector("canvas")});
3215
3204
  progress.draw();
3216
3205
  * **/
3217
- Progress: UtilsProgress = Progress;
3206
+ Progress = Progress;
3218
3207
  /**
3219
3208
  * 劫持Event的isTrust为true,注入时刻,ducument-start
3220
3209
  * @param isTrustValue (可选)让isTrusted为true
@@ -4030,7 +4019,6 @@ class Utils {
4030
4019
  }
4031
4020
  /**
4032
4021
  * 提供一个封装了 try-catch 的函数,可以执行传入的函数并捕获其可能抛出的错误,并通过传入的错误处理函数进行处理。
4033
- * @returns 返回一个对象,其中包含 error 和 run 两个方法。
4034
4022
  * @example
4035
4023
  * Utils.tryCatch().error().run(()=>{console.log(1)});
4036
4024
  * > 1