@whitesev/utils 2.4.6 → 2.4.7
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 +10 -1
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +10 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +10 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +10 -1
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +10 -1
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +10 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/Utils.d.ts +3 -3
- package/dist/types/src/WindowApi.d.ts +2 -2
- package/dist/types/src/types/WindowApi.d.ts +3 -3
- package/package.json +1 -1
- package/src/Utils.ts +5 -5
- package/src/WindowApi.ts +13 -4
- package/src/types/WindowApi.d.ts +3 -3
|
@@ -13,10 +13,10 @@ import type { DOMUtils_EventType } from "./types/Event";
|
|
|
13
13
|
import type { UtilsAjaxHookResult } from "./types/ajaxHooker";
|
|
14
14
|
import { Vue } from "./Vue";
|
|
15
15
|
import { type ArgsType, type JSTypeNames, type UtilsOwnObject } from "./types/global";
|
|
16
|
-
import type {
|
|
16
|
+
import type { WindowApiOption } from "./types/WindowApi";
|
|
17
17
|
declare class Utils {
|
|
18
18
|
private windowApi;
|
|
19
|
-
constructor(option?:
|
|
19
|
+
constructor(option?: WindowApiOption);
|
|
20
20
|
/** 版本号 */
|
|
21
21
|
version: string;
|
|
22
22
|
/**
|
|
@@ -1720,7 +1720,7 @@ declare class Utils {
|
|
|
1720
1720
|
* @param option
|
|
1721
1721
|
* @returns
|
|
1722
1722
|
*/
|
|
1723
|
-
createUtils(option?:
|
|
1723
|
+
createUtils(option?: WindowApiOption): Utils;
|
|
1724
1724
|
/**
|
|
1725
1725
|
* 将对象转换为FormData
|
|
1726
1726
|
* @param data 待转换的对象
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { WindowApiOption } from "./types/WindowApi";
|
|
2
2
|
declare class WindowApi {
|
|
3
3
|
/** 默认的配置 */
|
|
4
4
|
private defaultApi;
|
|
5
5
|
/** 使用的配置 */
|
|
6
6
|
private api;
|
|
7
|
-
constructor(option?:
|
|
7
|
+
constructor(option?: WindowApiOption);
|
|
8
8
|
get document(): Document;
|
|
9
9
|
get window(): Window & typeof globalThis;
|
|
10
10
|
get globalThis(): typeof globalThis | Window;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 配置类型
|
|
3
3
|
*/
|
|
4
|
-
export type
|
|
4
|
+
export type WindowApiOption = {
|
|
5
5
|
document: Document;
|
|
6
6
|
window: Window & typeof globalThis;
|
|
7
|
-
globalThis
|
|
8
|
-
self
|
|
7
|
+
globalThis?: typeof globalThis | Window;
|
|
8
|
+
self?: Window & typeof globalThis;
|
|
9
9
|
top: Window;
|
|
10
10
|
};
|
package/package.json
CHANGED
package/src/Utils.ts
CHANGED
|
@@ -21,15 +21,15 @@ import {
|
|
|
21
21
|
type JSTypeNames,
|
|
22
22
|
type UtilsOwnObject,
|
|
23
23
|
} from "./types/global";
|
|
24
|
-
import type {
|
|
24
|
+
import type { WindowApiOption } from "./types/WindowApi";
|
|
25
25
|
|
|
26
26
|
class Utils {
|
|
27
|
-
private windowApi: WindowApi;
|
|
28
|
-
constructor(option?:
|
|
27
|
+
private windowApi: typeof WindowApi.prototype;
|
|
28
|
+
constructor(option?: WindowApiOption) {
|
|
29
29
|
this.windowApi = new WindowApi(option);
|
|
30
30
|
}
|
|
31
31
|
/** 版本号 */
|
|
32
|
-
version = "2024.11.
|
|
32
|
+
version = "2024.11.6";
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* 在页面中增加style元素,如果html节点存在子节点,添加子节点第一个,反之,添加到html节点的子节点最后一个
|
|
@@ -4978,7 +4978,7 @@ class Utils {
|
|
|
4978
4978
|
* @param option
|
|
4979
4979
|
* @returns
|
|
4980
4980
|
*/
|
|
4981
|
-
createUtils(option?:
|
|
4981
|
+
createUtils(option?: WindowApiOption) {
|
|
4982
4982
|
return new Utils(option);
|
|
4983
4983
|
}
|
|
4984
4984
|
|
package/src/WindowApi.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { WindowApiOption } from "./types/WindowApi";
|
|
2
2
|
|
|
3
3
|
class WindowApi {
|
|
4
4
|
/** 默认的配置 */
|
|
5
|
-
private defaultApi:
|
|
5
|
+
private defaultApi: Required<WindowApiOption> = {
|
|
6
6
|
document: document,
|
|
7
7
|
window: window,
|
|
8
8
|
globalThis: globalThis,
|
|
@@ -10,11 +10,20 @@ class WindowApi {
|
|
|
10
10
|
top: top!,
|
|
11
11
|
};
|
|
12
12
|
/** 使用的配置 */
|
|
13
|
-
private api:
|
|
14
|
-
constructor(option?:
|
|
13
|
+
private api: Required<WindowApiOption>;
|
|
14
|
+
constructor(option?: WindowApiOption) {
|
|
15
|
+
if (option) {
|
|
16
|
+
if (option.globalThis == null) {
|
|
17
|
+
option.globalThis = option.window;
|
|
18
|
+
}
|
|
19
|
+
if (option.self == null) {
|
|
20
|
+
option.self = option.window;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
15
23
|
if (!option) {
|
|
16
24
|
option = Object.assign({}, this.defaultApi);
|
|
17
25
|
}
|
|
26
|
+
// @ts-ignore
|
|
18
27
|
this.api = Object.assign({}, option);
|
|
19
28
|
}
|
|
20
29
|
get document() {
|
package/src/types/WindowApi.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 配置类型
|
|
3
3
|
*/
|
|
4
|
-
export type
|
|
4
|
+
export type WindowApiOption = {
|
|
5
5
|
document: Document;
|
|
6
6
|
window: Window & typeof globalThis;
|
|
7
|
-
globalThis
|
|
8
|
-
self
|
|
7
|
+
globalThis?: typeof globalThis | Window;
|
|
8
|
+
self?: Window & typeof globalThis;
|
|
9
9
|
top: Window;
|
|
10
10
|
};
|