@virid/vue 0.0.1 → 0.1.0
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/LICENSE +190 -0
- package/README.md +1 -294
- package/README.zh.md +1 -279
- package/dist/index.cjs +14 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +109 -0
- package/dist/index.d.ts +69 -23
- package/dist/index.js +14 -559
- package/dist/index.js.map +1 -0
- package/package.json +29 -20
- package/dist/index.d.mts +0 -63
- package/dist/index.mjs +0 -525
package/dist/index.d.ts
CHANGED
|
@@ -1,27 +1,84 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { CCSSystemContext } from '@virid/core';
|
|
1
|
+
import { Newable, BaseMessage, ViridPlugin } from '@virid/core';
|
|
3
2
|
import { WatchOptions } from 'vue';
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* @description: vue的hooks适配器,注入IOC容器中的Controller实例,并挂在vue的各种方法
|
|
6
|
+
* @param token
|
|
7
|
+
* @return {*}
|
|
8
|
+
*/
|
|
9
|
+
declare function useController<T>(token: new (...args: any[]) => T, options?: {
|
|
10
|
+
id?: string;
|
|
11
|
+
context?: any;
|
|
12
|
+
}): T;
|
|
13
|
+
|
|
14
|
+
interface WatchItem {
|
|
15
|
+
type: "component" | "local";
|
|
16
|
+
componentClass: Newable<any> | null;
|
|
17
|
+
source: (instance: any) => any | Promise<any>;
|
|
18
|
+
options: WatchOptions;
|
|
19
|
+
methodName: string;
|
|
20
|
+
}
|
|
21
|
+
type WatchMetadata = WatchItem[];
|
|
22
|
+
interface ProjectItem {
|
|
23
|
+
key: string;
|
|
24
|
+
isAccessor: boolean;
|
|
25
|
+
type: "component" | "local";
|
|
26
|
+
componentClass: Newable<any> | null;
|
|
27
|
+
source: (instance: any) => any;
|
|
28
|
+
}
|
|
29
|
+
type ProjectMetadata = ProjectItem[];
|
|
30
|
+
interface ResponsiveItem {
|
|
31
|
+
key: string;
|
|
32
|
+
shallow: boolean;
|
|
33
|
+
}
|
|
34
|
+
type ResponsiveMetadata = ResponsiveItem[];
|
|
35
|
+
interface OnHookItem {
|
|
36
|
+
hookName: "onMounted" | "onUnmounted" | "onUpdated" | "onActivated" | "onDeactivated" | "onSetup";
|
|
37
|
+
methodName: string;
|
|
38
|
+
}
|
|
39
|
+
type OnHookMetadata = OnHookItem[];
|
|
40
|
+
interface UseItem {
|
|
41
|
+
key: string;
|
|
42
|
+
hookFactory: () => any;
|
|
43
|
+
}
|
|
44
|
+
type UseMetadata = UseItem[];
|
|
45
|
+
interface InheritItem {
|
|
46
|
+
key: string;
|
|
47
|
+
token: Newable<any>;
|
|
48
|
+
id: string;
|
|
49
|
+
selector: (instance: any) => any;
|
|
50
|
+
}
|
|
51
|
+
type InheritMetadata = InheritItem[];
|
|
52
|
+
interface ListenerItem {
|
|
53
|
+
key: string;
|
|
54
|
+
messageClass: Newable<any>;
|
|
55
|
+
priority: number;
|
|
56
|
+
single: boolean;
|
|
57
|
+
}
|
|
58
|
+
type ListenerMetadata = ListenerItem[];
|
|
59
|
+
interface ListenerConfig<T> {
|
|
60
|
+
messageClass: Newable<T>;
|
|
61
|
+
priority?: number;
|
|
62
|
+
single?: boolean;
|
|
6
63
|
}
|
|
7
64
|
|
|
8
65
|
/**
|
|
9
66
|
* @description:实现Watch
|
|
10
|
-
* 用法:@Watch('a.b.c') 或 @Watch(instance => instance.a.b.c)
|
|
11
67
|
*/
|
|
12
|
-
declare function Watch<T>(source: (instance: T) => any
|
|
13
|
-
declare function Watch<C>(component:
|
|
68
|
+
declare function Watch<T>(source: (instance: T) => any | Promise<any>, options?: WatchOptions): any;
|
|
69
|
+
declare function Watch<C>(component: Newable<C>, source: (comp: C) => any | Promise<any>, options?: WatchOptions): any;
|
|
14
70
|
/**
|
|
15
71
|
* @description: 实现数据投影
|
|
16
72
|
* 用法:@Project() 或 @Project('a.b.c')
|
|
17
73
|
*/
|
|
18
74
|
declare function Project<T>(source: (instance: T) => any): any;
|
|
19
75
|
declare function Project<C>(component: new (...args: any[]) => C, source: (comp: C) => any): any;
|
|
76
|
+
declare function Project<T>(): any;
|
|
20
77
|
/**
|
|
21
78
|
* @description: 给数据增加响应式
|
|
22
79
|
* 用法:@Responsive()
|
|
23
80
|
*/
|
|
24
|
-
declare function Responsive(shallow?: boolean): (target: any,
|
|
81
|
+
declare function Responsive(shallow?: boolean): (target: any, key: string) => void;
|
|
25
82
|
/**
|
|
26
83
|
* @description: 声明式生命周期钩子
|
|
27
84
|
* 用法:@OnHook("onMounted")
|
|
@@ -31,12 +88,12 @@ declare function OnHook(hookName: "onMounted" | "onUnmounted" | "onUpdated" | "o
|
|
|
31
88
|
* @description: 万能 Hook 注入装饰器
|
|
32
89
|
* 用法:@Use(() => useRoute()) public route!: RouteLocationNormalized
|
|
33
90
|
*/
|
|
34
|
-
declare function Use(hookFactory: () => any): (target: any,
|
|
91
|
+
declare function Use(hookFactory: () => any): (target: any, key: string) => void;
|
|
35
92
|
/**
|
|
36
93
|
* @description: Inherit注入装饰器
|
|
37
|
-
* 用法:@Inherit(
|
|
94
|
+
* 用法:@Inherit(Controller,(instance) => instance.xxxx) public data!: SomeType
|
|
38
95
|
*/
|
|
39
|
-
declare function Inherit<T>(token:
|
|
96
|
+
declare function Inherit<T>(token: Newable<T>, id: string, selector?: (instance: T) => any): (target: any, key: string) => void;
|
|
40
97
|
/**
|
|
41
98
|
* @description: 标记一个属性是从外部环境(context)注入的
|
|
42
99
|
* 纯元数据标记,什么也不干,方便后期做自动化文档或 TS 类型提示
|
|
@@ -44,20 +101,9 @@ declare function Inherit<T>(token: new (...args: any[]) => T, id: string, select
|
|
|
44
101
|
declare function Env(): (_target: any, _propertyKey: string) => void;
|
|
45
102
|
/**
|
|
46
103
|
* @description: Listener 装饰器 - 标记 Controller 的成员方法为消息监听器
|
|
47
|
-
* 模仿 Bevy 的即时响应机制,但严格限制其只能处理 UI 逻辑
|
|
48
104
|
*/
|
|
49
|
-
declare function Listener<T extends
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* @description: vue的hooks适配器,注入IOC容器中的Controller实例,并挂在vue的各种方法
|
|
53
|
-
* @param token
|
|
54
|
-
* @return {*}
|
|
55
|
-
*/
|
|
56
|
-
declare function useController<T>(token: new (...args: any[]) => T, options?: {
|
|
57
|
-
id?: string;
|
|
58
|
-
context?: any;
|
|
59
|
-
}): T;
|
|
105
|
+
declare function Listener<T extends BaseMessage>({ messageClass, priority, single, }: ListenerConfig<T>): (target: any, key: string) => void;
|
|
60
106
|
|
|
61
107
|
declare const VuePlugin: ViridPlugin;
|
|
62
108
|
|
|
63
|
-
export {
|
|
109
|
+
export { Env, Inherit, type InheritItem, type InheritMetadata, Listener, type ListenerConfig, type ListenerItem, type ListenerMetadata, OnHook, type OnHookItem, type OnHookMetadata, Project, type ProjectItem, type ProjectMetadata, Responsive, type ResponsiveItem, type ResponsiveMetadata, Use, type UseItem, type UseMetadata, VuePlugin, Watch, type WatchItem, type WatchMetadata, useController };
|