@whitesev/utils 1.4.4 → 1.4.6

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.
@@ -12,6 +12,7 @@ import { Progress } from "./Progress";
12
12
  import { UtilsDictionary } from "./Dictionary";
13
13
  import type { DOMUtils_EventType } from "./Event";
14
14
  import type { UtilsCoreOption } from "./UtilsCore";
15
+ import type { Vue2Object } from "./VueObject";
15
16
  export declare var unsafeWindow: Window & typeof globalThis;
16
17
  export type JSTypeMap = {
17
18
  string: string;
@@ -34,93 +35,7 @@ export declare interface AnyObject {
34
35
  [key: string]: any | AnyObject;
35
36
  toString(): string;
36
37
  }
37
- export declare interface Vue2Context extends AnyObject {
38
- $attrs: AnyObject;
39
- $children: Vue2Context[];
40
- $createElement: (...args: any[]) => any;
41
- $el: HTMLElement;
42
- $listeners: AnyObject;
43
- $options: AnyObject;
44
- $parent: Vue2Context;
45
- $refs: AnyObject;
46
- $root: Vue2Context;
47
- $scopedSlots: AnyObject;
48
- $slots: AnyObject;
49
- $store: AnyObject;
50
- $vnode: AnyObject;
51
- _data: AnyObject;
52
- _directInactive: boolean;
53
- _events: AnyObject;
54
- _hasHookEvent: boolean;
55
- _isBeingDestroyed: boolean;
56
- _isDestroyed: boolean;
57
- _isMounted: boolean;
58
- _isVue: boolean;
59
- $data: AnyObject;
60
- $isServer: boolean;
61
- $props: AnyObject;
62
- $route: AnyObject & {
63
- fullPath: string;
64
- hash: string;
65
- matched: AnyObject[];
66
- meta: AnyObject;
67
- name: string;
68
- params: AnyObject;
69
- path: string;
70
- query: AnyObject;
71
- };
72
- $router: AnyObject & {
73
- afterHooks: AnyObject[];
74
- app: Vue2Context;
75
- apps: Vue2Context[];
76
- beforeHooks: ((...args: any[]) => any)[];
77
- fallback: boolean;
78
- history: AnyObject & {
79
- base: string;
80
- current: AnyObject;
81
- listeners: AnyObject[];
82
- router: Vue2Context["$router"];
83
- /**
84
- *
85
- * @param delta 访问的距离。如果 delta < 0 则后退相应数量的记录,如果 > 0 则前进。
86
- * @param triggerListeners 是否应该触发连接到该历史的监听器
87
- * @returns
88
- */
89
- go: (delta: number, triggerListeners?: boolean) => void;
90
- /**
91
- *
92
- * @param to 要设置的地址
93
- * @param data 可选的 HistoryState 以关联该导航记录
94
- * @returns
95
- */
96
- push: (to: string, data?: AnyObject) => void;
97
- /**
98
- *
99
- * @param to 要设置的地址
100
- * @param data 可选的 HistoryState 以关联该导航记录
101
- * @returns
102
- */
103
- replace: (to: string, data?: AnyObject) => void;
104
- };
105
- matcher: AnyObject & {
106
- addRoute: (...args: any[]) => any;
107
- addRoutes: (...args: any[]) => any;
108
- getRoutes: () => any;
109
- match: (...args: any[]) => any;
110
- };
111
- mode: string;
112
- resolveHooks: ((...args: any[]) => any)[];
113
- currentRoute: AnyObject;
114
- /**
115
- * 传空就移除上一个监听
116
- */
117
- afterEach: ((to: Vue2Context["$route"], from: Vue2Context["$route"]) => void) | null;
118
- };
119
- $ssrContext: AnyObject;
120
- $watch: (key: string | string[] | (() => any), handler: (this: any, newVal: any, oldVal: any) => void, options?: {
121
- immediate?: boolean;
122
- deep?: boolean;
123
- }) => void;
38
+ export declare interface Vue2Context extends Vue2Object {
124
39
  }
125
40
  declare class Utils {
126
41
  constructor(option?: UtilsCoreOption);
@@ -0,0 +1,107 @@
1
+ import type { AnyObject } from "./Utils";
2
+ export declare interface Vue2Object extends AnyObject {
3
+ $attrs: AnyObject;
4
+ $children: Vue2Object[];
5
+ $createElement: (...args: any[]) => any;
6
+ $el: HTMLElement;
7
+ $listeners: AnyObject;
8
+ $options: AnyObject;
9
+ $parent: Vue2Object;
10
+ $refs: AnyObject;
11
+ $root: Vue2Object;
12
+ $scopedSlots: AnyObject;
13
+ $slots: AnyObject;
14
+ $store: AnyObject;
15
+ $vnode: AnyObject;
16
+ _data: AnyObject;
17
+ _directInactive: boolean;
18
+ _events: AnyObject;
19
+ _hasHookEvent: boolean;
20
+ _isBeingDestroyed: boolean;
21
+ _isDestroyed: boolean;
22
+ _isMounted: boolean;
23
+ _isVue: boolean;
24
+ $data: AnyObject;
25
+ $isServer: boolean;
26
+ $props: AnyObject;
27
+ $route: AnyObject & {
28
+ fullPath: string;
29
+ hash: string;
30
+ matched: AnyObject[];
31
+ meta: AnyObject;
32
+ name: string;
33
+ params: AnyObject;
34
+ path: string;
35
+ query: AnyObject;
36
+ };
37
+ $router: AnyObject & {
38
+ afterHooks: Function[];
39
+ app: Vue2Object;
40
+ apps: Vue2Object[];
41
+ beforeHooks: Function[];
42
+ fallback: boolean;
43
+ history: AnyObject & {
44
+ base: string;
45
+ current: AnyObject;
46
+ listeners: AnyObject[];
47
+ router: Vue2Object["$router"];
48
+ /**
49
+ *
50
+ * @param delta 访问的距离。如果 delta < 0 则后退相应数量的记录,如果 > 0 则前进。
51
+ * @param triggerListeners 是否应该触发连接到该历史的监听器
52
+ * @returns
53
+ */
54
+ go: (delta: number, triggerListeners?: boolean) => void;
55
+ /**
56
+ *
57
+ * @param to 要设置的地址
58
+ * @param data 可选的 HistoryState 以关联该导航记录
59
+ * @returns
60
+ */
61
+ push: (to: string, data?: AnyObject) => void;
62
+ /**
63
+ *
64
+ * @param to 要设置的地址
65
+ * @param data 可选的 HistoryState 以关联该导航记录
66
+ * @returns
67
+ */
68
+ replace: (to: string, data?: AnyObject) => void;
69
+ };
70
+ matcher: AnyObject & {
71
+ addRoute: (...args: any[]) => any;
72
+ addRoutes: (...args: any[]) => any;
73
+ getRoutes: () => any;
74
+ match: (...args: any[]) => any;
75
+ };
76
+ mode: string;
77
+ resolveHooks: ((...args: any[]) => any)[];
78
+ currentRoute: AnyObject;
79
+ beforeEach: (callback: ((
80
+ /** 即将要进入的目标 路由对象 */
81
+ to: Vue2Object["$route"],
82
+ /** 当前导航正要离开的路由 */
83
+ from: Vue2Object["$route"],
84
+ /**
85
+ *
86
+ * + next(): 进行管道中的下一个钩子。如果全部钩子执行完了,则导航的状态就是 confirmed (确认的)。
87
+ * + next(false): 中断当前的导航。如果浏览器的 URL 改变了 (可能是用户手动或者浏览器后退按钮),那么 URL 地址会重置到 from 路由对应的地址。
88
+ * + next('/') 或者 next({ path: '/' }): 跳转到一个不同的地址。当前的导航被中断,然后进行一个新的导航。你可以向 next 传递任意位置对象,且允许设置诸如 replace: true、name: 'home' 之类的选项以及任何用在 router-link 的 to prop 或 router.push 中的选项。
89
+ * + next(error): (2.4.0+) 如果传入 next 的参数是一个 Error 实例,则导航会被终止且该错误会被传递给 router.onError() 注册过的回调。
90
+ */
91
+ next: Function) => void)
92
+ /** 移除上一个添加的监听 */
93
+ | (() => void)) => void;
94
+ afterEach: (callback: ((
95
+ /** 即将要进入的目标 路由对象 */
96
+ to: Vue2Object["$route"],
97
+ /** 当前导航正要离开的路由 */
98
+ from: Vue2Object["$route"]) => void)
99
+ /** 移除上一个添加的监听 */
100
+ | (() => void)) => void;
101
+ };
102
+ $ssrContext: AnyObject;
103
+ $watch: (key: string | string[] | (() => any), handler: (this: any, newVal: any, oldVal: any) => void, options?: {
104
+ immediate?: boolean;
105
+ deep?: boolean;
106
+ }) => void;
107
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whitesev/utils",
3
- "version": "1.4.4",
3
+ "version": "1.4.6",
4
4
  "description": "一个常用的工具库",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/node/index.esm.js",
package/src/Utils.ts CHANGED
@@ -15,6 +15,7 @@ import { TryCatch } from "./TryCatch";
15
15
  import { UtilsDictionary } from "./Dictionary";
16
16
  import type { DOMUtils_EventType } from "./Event";
17
17
  import type { UtilsCoreOption } from "./UtilsCore";
18
+ import type { Vue2Object } from "./VueObject";
18
19
 
19
20
  export declare var unsafeWindow: Window & typeof globalThis;
20
21
 
@@ -43,111 +44,14 @@ export declare interface AnyObject {
43
44
  toString(): string;
44
45
  }
45
46
 
46
- export declare interface Vue2Context extends AnyObject {
47
- $attrs: AnyObject;
48
- $children: Vue2Context[];
49
- $createElement: (...args: any[]) => any;
50
- $el: HTMLElement;
51
- $listeners: AnyObject;
52
- $options: AnyObject;
53
- $parent: Vue2Context;
54
- $refs: AnyObject;
55
- $root: Vue2Context;
56
- $scopedSlots: AnyObject;
57
- $slots: AnyObject;
58
- $store: AnyObject;
59
- $vnode: AnyObject;
60
-
61
- _data: AnyObject;
62
- _directInactive: boolean;
63
- _events: AnyObject;
64
- _hasHookEvent: boolean;
65
- _isBeingDestroyed: boolean;
66
- _isDestroyed: boolean;
67
- _isMounted: boolean;
68
- _isVue: boolean;
69
-
70
- $data: AnyObject;
71
- $isServer: boolean;
72
- $props: AnyObject;
73
- $route: AnyObject & {
74
- fullPath: string;
75
- hash: string;
76
- matched: AnyObject[];
77
- meta: AnyObject;
78
- name: string;
79
- params: AnyObject;
80
- path: string;
81
- query: AnyObject;
82
- };
83
- $router: AnyObject & {
84
- afterHooks: AnyObject[];
85
- app: Vue2Context;
86
- apps: Vue2Context[];
87
- beforeHooks: ((...args: any[]) => any)[];
88
- fallback: boolean;
89
- history: AnyObject & {
90
- base: string;
91
- current: AnyObject;
92
- listeners: AnyObject[];
93
- router: Vue2Context["$router"];
94
- /**
95
- *
96
- * @param delta 访问的距离。如果 delta < 0 则后退相应数量的记录,如果 > 0 则前进。
97
- * @param triggerListeners 是否应该触发连接到该历史的监听器
98
- * @returns
99
- */
100
- go: (delta: number, triggerListeners?: boolean) => void;
101
- /**
102
- *
103
- * @param to 要设置的地址
104
- * @param data 可选的 HistoryState 以关联该导航记录
105
- * @returns
106
- */
107
- push: (to: string, data?: AnyObject) => void;
108
- /**
109
- *
110
- * @param to 要设置的地址
111
- * @param data 可选的 HistoryState 以关联该导航记录
112
- * @returns
113
- */
114
- replace: (to: string, data?: AnyObject) => void;
115
- };
116
- matcher: AnyObject & {
117
- addRoute: (...args: any[]) => any;
118
- addRoutes: (...args: any[]) => any;
119
- getRoutes: () => any;
120
- match: (...args: any[]) => any;
121
- };
122
- mode: string;
123
- resolveHooks: ((...args: any[]) => any)[];
124
- currentRoute: AnyObject;
125
-
126
- /**
127
- * 传空就移除上一个监听
128
- */
129
- afterEach:
130
- | ((to: Vue2Context["$route"], from: Vue2Context["$route"]) => void)
131
- | null;
132
- };
133
- $ssrContext: AnyObject;
134
-
135
- $watch: (
136
- key: string | string[] | (() => any),
137
- handler: (this: any, newVal: any, oldVal: any) => void,
138
- options?: {
139
- immediate?: boolean;
140
- deep?: boolean;
141
- }
142
- ) => void;
143
- }
47
+ export declare interface Vue2Context extends Vue2Object {}
144
48
 
145
49
  class Utils {
146
50
  constructor(option?: UtilsCoreOption) {
147
51
  UtilsCore.init(option);
148
52
  }
149
53
  /** 版本号 */
150
- version = "2024.6.14";
54
+ version = "2024.6.16";
151
55
 
152
56
  /**
153
57
  * 在页面中增加style元素,如果html节点存在子节点,添加子节点第一个,反之,添加到html节点的子节点最后一个
@@ -0,0 +1,124 @@
1
+ import type { AnyObject } from "./Utils";
2
+
3
+ export declare interface Vue2Object extends AnyObject {
4
+ $attrs: AnyObject;
5
+ $children: Vue2Object[];
6
+ $createElement: (...args: any[]) => any;
7
+ $el: HTMLElement;
8
+ $listeners: AnyObject;
9
+ $options: AnyObject;
10
+ $parent: Vue2Object;
11
+ $refs: AnyObject;
12
+ $root: Vue2Object;
13
+ $scopedSlots: AnyObject;
14
+ $slots: AnyObject;
15
+ $store: AnyObject;
16
+ $vnode: AnyObject;
17
+
18
+ _data: AnyObject;
19
+ _directInactive: boolean;
20
+ _events: AnyObject;
21
+ _hasHookEvent: boolean;
22
+ _isBeingDestroyed: boolean;
23
+ _isDestroyed: boolean;
24
+ _isMounted: boolean;
25
+ _isVue: boolean;
26
+
27
+ $data: AnyObject;
28
+ $isServer: boolean;
29
+ $props: AnyObject;
30
+ $route: AnyObject & {
31
+ fullPath: string;
32
+ hash: string;
33
+ matched: AnyObject[];
34
+ meta: AnyObject;
35
+ name: string;
36
+ params: AnyObject;
37
+ path: string;
38
+ query: AnyObject;
39
+ };
40
+ $router: AnyObject & {
41
+ afterHooks: Function[];
42
+ app: Vue2Object;
43
+ apps: Vue2Object[];
44
+ beforeHooks: Function[];
45
+ fallback: boolean;
46
+ history: AnyObject & {
47
+ base: string;
48
+ current: AnyObject;
49
+ listeners: AnyObject[];
50
+ router: Vue2Object["$router"];
51
+ /**
52
+ *
53
+ * @param delta 访问的距离。如果 delta < 0 则后退相应数量的记录,如果 > 0 则前进。
54
+ * @param triggerListeners 是否应该触发连接到该历史的监听器
55
+ * @returns
56
+ */
57
+ go: (delta: number, triggerListeners?: boolean) => void;
58
+ /**
59
+ *
60
+ * @param to 要设置的地址
61
+ * @param data 可选的 HistoryState 以关联该导航记录
62
+ * @returns
63
+ */
64
+ push: (to: string, data?: AnyObject) => void;
65
+ /**
66
+ *
67
+ * @param to 要设置的地址
68
+ * @param data 可选的 HistoryState 以关联该导航记录
69
+ * @returns
70
+ */
71
+ replace: (to: string, data?: AnyObject) => void;
72
+ };
73
+ matcher: AnyObject & {
74
+ addRoute: (...args: any[]) => any;
75
+ addRoutes: (...args: any[]) => any;
76
+ getRoutes: () => any;
77
+ match: (...args: any[]) => any;
78
+ };
79
+ mode: string;
80
+ resolveHooks: ((...args: any[]) => any)[];
81
+ currentRoute: AnyObject;
82
+ beforeEach: (
83
+ callback:
84
+ | ((
85
+ /** 即将要进入的目标 路由对象 */
86
+ to: Vue2Object["$route"],
87
+ /** 当前导航正要离开的路由 */
88
+ from: Vue2Object["$route"],
89
+ /**
90
+ *
91
+ * + next(): 进行管道中的下一个钩子。如果全部钩子执行完了,则导航的状态就是 confirmed (确认的)。
92
+ * + next(false): 中断当前的导航。如果浏览器的 URL 改变了 (可能是用户手动或者浏览器后退按钮),那么 URL 地址会重置到 from 路由对应的地址。
93
+ * + next('/') 或者 next({ path: '/' }): 跳转到一个不同的地址。当前的导航被中断,然后进行一个新的导航。你可以向 next 传递任意位置对象,且允许设置诸如 replace: true、name: 'home' 之类的选项以及任何用在 router-link 的 to prop 或 router.push 中的选项。
94
+ * + next(error): (2.4.0+) 如果传入 next 的参数是一个 Error 实例,则导航会被终止且该错误会被传递给 router.onError() 注册过的回调。
95
+ */
96
+ next: Function
97
+ ) => void)
98
+ /** 移除上一个添加的监听 */
99
+ | (() => void)
100
+ ) => void;
101
+
102
+ afterEach: (
103
+ callback:
104
+ | ((
105
+ /** 即将要进入的目标 路由对象 */
106
+ to: Vue2Object["$route"],
107
+ /** 当前导航正要离开的路由 */
108
+ from: Vue2Object["$route"]
109
+ ) => void)
110
+ /** 移除上一个添加的监听 */
111
+ | (() => void)
112
+ ) => void;
113
+ };
114
+ $ssrContext: AnyObject;
115
+
116
+ $watch: (
117
+ key: string | string[] | (() => any),
118
+ handler: (this: any, newVal: any, oldVal: any) => void,
119
+ options?: {
120
+ immediate?: boolean;
121
+ deep?: boolean;
122
+ }
123
+ ) => void;
124
+ }