@whitesev/utils 1.0.2 → 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.
Files changed (59) hide show
  1. package/dist/index.amd.js +1814 -6002
  2. package/dist/index.amd.js.map +1 -1
  3. package/dist/index.cjs.js +1430 -5616
  4. package/dist/index.cjs.js.map +1 -1
  5. package/dist/index.d.ts +1 -1
  6. package/dist/index.esm.js +1427 -5611
  7. package/dist/index.esm.js.map +1 -1
  8. package/dist/index.iife.js +1814 -6003
  9. package/dist/index.iife.js.map +1 -1
  10. package/dist/index.system.js +1826 -6017
  11. package/dist/index.system.js.map +1 -1
  12. package/dist/index.umd.js +1814 -6006
  13. package/dist/index.umd.js.map +1 -1
  14. package/dist/src/UtilsCore.d.ts +7 -0
  15. package/dist/src/ajaxHooker/ajaxHooker.d.ts +6 -0
  16. package/dist/src/{Utils.d.ts → index.d.ts} +206 -1
  17. package/index.ts +1 -1
  18. package/package.json +37 -35
  19. package/rollup.config.js +14 -1
  20. package/src/GBKEncoder.ts +2 -0
  21. package/src/UtilsCore.ts +9 -0
  22. package/src/UtilsGMCookie.ts +1 -1
  23. package/src/ajaxHooker/ajaxHooker.js +574 -0
  24. package/src/{Utils.ts → index.ts} +267 -17
  25. package/tsconfig.json +1 -2
  26. package/dist/src/ajaxHooker.d.ts +0 -6
  27. package/src/GBKEncoder.js +0 -111
  28. package/src/ajaxHooker.js +0 -558
  29. package/src/types/DOMUtils.d.ts +0 -188
  30. package/src/types/UtilsCore.d.ts +0 -7
  31. package/src/types/global.d.ts +0 -58
  32. /package/dist/src/{Dictionary.d.ts → Dictionary/Dictionary.d.ts} +0 -0
  33. /package/dist/src/{Hooks.d.ts → Hooks/Hooks.d.ts} +0 -0
  34. /package/dist/src/{Httpx.d.ts → Httpx/Httpx.d.ts} +0 -0
  35. /package/dist/src/{LockFunction.d.ts → LockFunction/LockFunction.d.ts} +0 -0
  36. /package/dist/src/{Log.d.ts → Log/Log.d.ts} +0 -0
  37. /package/dist/src/{Progress.d.ts → Progress/Progress.d.ts} +0 -0
  38. /package/dist/src/{UtilsGMMenu.d.ts → UtilsGMMenu/UtilsGMMenu.d.ts} +0 -0
  39. /package/dist/src/{indexedDB.d.ts → indexedDB/indexedDB.d.ts} +0 -0
  40. /package/dist/src/{tryCatch.d.ts → tryCatch/tryCatch.d.ts} +0 -0
  41. /package/src/{Dictionary.js → Dictionary/Dictionary.js} +0 -0
  42. /package/src/{types/Dictionary.d.ts → Dictionary/index.d.ts} +0 -0
  43. /package/src/{Hooks.js → Hooks/Hooks.js} +0 -0
  44. /package/src/{types/Hook.d.ts → Hooks/index.d.ts} +0 -0
  45. /package/src/{Httpx.js → Httpx/Httpx.js} +0 -0
  46. /package/src/{types/Httpx.d.ts → Httpx/index.d.ts} +0 -0
  47. /package/src/{LockFunction.js → LockFunction/LockFunction.js} +0 -0
  48. /package/src/{types/LockFunction.d.ts → LockFunction/index.d.ts} +0 -0
  49. /package/src/{Log.js → Log/Log.js} +0 -0
  50. /package/src/{types/Log.d.ts → Log/index.d.ts} +0 -0
  51. /package/src/{Progress.js → Progress/Progress.js} +0 -0
  52. /package/src/{types/Progress.d.ts → Progress/index.d.ts} +0 -0
  53. /package/src/{UtilsGMMenu.js → UtilsGMMenu/UtilsGMMenu.js} +0 -0
  54. /package/src/{types/UtilsGMMenu.d.ts → UtilsGMMenu/index.d.ts} +0 -0
  55. /package/src/{types/AjaxHooker.d.ts → ajaxHooker/index.d.ts} +0 -0
  56. /package/src/{types/Indexdb.d.ts → indexedDB/index.d.ts} +0 -0
  57. /package/src/{indexedDB.js → indexedDB/indexedDB.js} +0 -0
  58. /package/src/{types/TryCatch.d.ts → tryCatch/index.d.ts} +0 -0
  59. /package/src/{tryCatch.js → tryCatch/tryCatch.js} +0 -0
@@ -1,3 +1,10 @@
1
+ declare interface UtilsCoreOption {
2
+ document: Document;
3
+ window: Window;
4
+ globalThis: typeof globalThis;
5
+ self: typeof globalThis;
6
+ top: Window;
7
+ }
1
8
  declare const UtilsCore: {
2
9
  init(option?: UtilsCoreOption): void;
3
10
  readonly document: Document;
@@ -0,0 +1,6 @@
1
+ export function AjaxHooker(): {
2
+ hook: (fn: any) => number;
3
+ filter: (arr: any) => void;
4
+ protect: () => void;
5
+ unhook: () => void;
6
+ };
@@ -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
@@ -1,3 +1,3 @@
1
- import { Utils } from "./src/Utils";
1
+ import { Utils } from "./src";
2
2
 
3
3
  export default Utils;
package/package.json CHANGED
@@ -1,35 +1,37 @@
1
- {
2
- "name": "@whitesev/utils",
3
- "version": "1.0.2",
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
- "tslib": "^2.6.2"
31
- },
32
- "devDependencies": {
33
- "typescript": "^5.4.5"
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,10 +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
 
12
+ // 模块名
8
13
  const moduleName = "Utils";
9
14
  module.exports = {
10
- plugins: [nodeResolve(), commonjs(), typescript()],
15
+ plugins: [
16
+ cleaner({
17
+ targets: ["./dist"],
18
+ }),
19
+ dts(),
20
+ nodeResolve(),
21
+ commonjs(),
22
+ typescript(),
23
+ ],
11
24
  input: "./index.ts", // 源文件入口
12
25
  output: [
13
26
  {
package/src/GBKEncoder.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { type AnyObject } from ".";
2
+
1
3
  class GBKEncoder {
2
4
  #data: RegExpMatchArray = [] as any;
3
5
  #U2Ghash: AnyObject = {};
package/src/UtilsCore.ts CHANGED
@@ -1,3 +1,12 @@
1
+ declare interface UtilsCoreOption {
2
+ document: Document;
3
+ window: Window;
4
+ globalThis: typeof globalThis;
5
+ self: typeof globalThis;
6
+ top: Window;
7
+ }
8
+
9
+
1
10
  const UtilsCoreDefaultEnv: UtilsCoreOption = {
2
11
  document: document,
3
12
  window: window,
@@ -1,4 +1,4 @@
1
- import { Utils } from "./Utils";
1
+ import { Utils } from ".";
2
2
 
3
3
  declare interface UtilsGMCookieListResult {
4
4
  /** 为 window.location.hostname */