@whitesev/utils 1.0.1 → 1.0.3

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.
@@ -1,6 +1,6 @@
1
- export namespace ajaxHooker {
2
- function hook(fn: any): number;
3
- function filter(arr: any): void;
4
- function protect(): void;
5
- function unhook(): void;
6
- }
1
+ export function AjaxHooker(): {
2
+ hook: (fn: any) => number;
3
+ filter: (arr: any) => void;
4
+ protect: () => void;
5
+ unhook: () => void;
6
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whitesev/utils",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "一个常用的工具库",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/node/index.esm.js",
@@ -23,6 +23,7 @@
23
23
  "author": "WhiteSev",
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
+ "@rollup/plugin-babel": "^6.0.4",
26
27
  "@rollup/plugin-commonjs": "^25.0.8",
27
28
  "@rollup/plugin-node-resolve": "^15.2.3",
28
29
  "@rollup/plugin-typescript": "^11.1.6",
package/rollup.config.js CHANGED
@@ -1,9 +1,12 @@
1
1
  // 允许使用 node 或 umd 包
2
2
  const commonjs = require("@rollup/plugin-commonjs");
3
+ // 解析导入的依赖模块路径,以便 Rollup 能够正确找到依赖模块。
3
4
  const { nodeResolve } = require("@rollup/plugin-node-resolve");
4
5
  // 编译 TS 代码
5
6
  const typescript = require("@rollup/plugin-typescript");
6
7
 
8
+ // 模块名
9
+ const moduleName = "Utils";
7
10
  module.exports = {
8
11
  plugins: [nodeResolve(), commonjs(), typescript()],
9
12
  input: "./index.ts", // 源文件入口
@@ -20,9 +23,26 @@ module.exports = {
20
23
  },
21
24
  {
22
25
  file: "dist/index.umd.js",
23
- name: "Utils", // 模块名
26
+ name: moduleName, // 模块名
24
27
  format: "umd", // umd 兼容形式的包, 可以直接应用于网页 script
25
28
  sourcemap: true,
26
29
  },
30
+ {
31
+ file: "dist/index.amd.js",
32
+ format: "amd", // amd 兼容形式的包, 适用于浏览器环境中使用 AMD 加载器加载模块
33
+ sourcemap: true,
34
+ },
35
+ {
36
+ file: "dist/index.iife.js",
37
+ name: moduleName, // 模块名
38
+ format: "iife", // iife 兼容形式的包, 将模块包裹在一个立即执行的函数中。适用于直接在浏览器中使用
39
+ sourcemap: true,
40
+ },
41
+ {
42
+ file: "dist/index.system.js",
43
+ name: moduleName, // 模块名
44
+ format: "system", // system 兼容形式的包, 可以在浏览器和 Node.js 环境下加载
45
+ sourcemap: true,
46
+ },
27
47
  ],
28
48
  };
package/src/Utils.ts CHANGED
@@ -2,7 +2,7 @@ import { ColorConversion } from "./ColorConversion";
2
2
  import { GBKEncoder } from "./GBKEncoder";
3
3
  import { UtilsCore } from "./UtilsCore";
4
4
  import { UtilsGMCookie } from "./UtilsGMCookie";
5
- import { ajaxHooker } from "./ajaxHooker";
5
+ import { AjaxHooker } from "./ajaxHooker";
6
6
  import { GMMenu } from "./UtilsGMMenu";
7
7
  import { Hooks } from "./Hooks";
8
8
  import { Httpx } from "./Httpx";
@@ -15,7 +15,7 @@ import { UtilsDictionary } from "./Dictionary";
15
15
 
16
16
  class Utils {
17
17
  /** 版本号 */
18
- version = "2024.5.24";
18
+ version = "2024.5.25";
19
19
 
20
20
  /**
21
21
  * 在页面中增加style元素,如果html节点存在子节点,添加子节点第一个,反之,添加到html节点的子节点最后一个
@@ -186,7 +186,7 @@ class Utils {
186
186
  * + 版本:1.4.1
187
187
  * + 文档:https://scriptcat.org/zh-CN/script-show-page/637/
188
188
  */
189
- ajaxHooker: UtilsAjaxHookResult = ajaxHooker;
189
+ ajaxHooker: UtilsAjaxHookResult = AjaxHooker as any;
190
190
  /**
191
191
  * 根据坐标点击canvas元素的内部位置
192
192
  * @param canvasElement 画布元素