phecda-core 3.0.0-alpha.10 → 3.0.0-alpha.12

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.d.ts CHANGED
@@ -1,3 +1,31 @@
1
+ declare function Init(proto: any, key: PropertyKey): void;
2
+ declare function Unmount(proto: any, key: PropertyKey): void;
3
+ declare function Bind(value: any): (proto: any, k: PropertyKey) => void;
4
+ declare function Ignore(proto: any, key: PropertyKey): void;
5
+ declare function Clear(proto: any, key: PropertyKey): void;
6
+ declare function Expose(proto: any, key: PropertyKey): void;
7
+ declare function Empty(module: any): void;
8
+
9
+ declare const SHARE_KEY: unique symbol;
10
+ declare const PHECDA_KEY: unique symbol;
11
+ declare function isPhecda(module: any): module is Construct;
12
+ declare function init(proto: Phecda): void;
13
+ declare function setStateVar(proto: Phecda, key: PropertyKey): void;
14
+ declare function setExposeKey(proto: Phecda, key: PropertyKey): void;
15
+ declare function setIgnoreKey(proto: Phecda, key: PropertyKey): void;
16
+ declare function setHandler(proto: Phecda, key: PropertyKey, handler: Handler): void;
17
+ declare function setState(proto: Phecda, key: PropertyKey, state: Record<string, any>): void;
18
+ declare function getOwnStateVars(target: any): string[];
19
+ declare function getStateVars(target: any): PropertyKey[];
20
+ declare function getOwnExposeKey(target: any): string[];
21
+ declare function getExposeKey(target: any): PropertyKey[];
22
+ declare function getOwnIgnoreKey(target: any): string[];
23
+ declare function getOwnHandler(target: any, key: PropertyKey): Handler[];
24
+ declare function getHandler(target: any, key: PropertyKey): any[];
25
+ declare function getState(target: any, key: PropertyKey): any;
26
+ declare function getOwnState(target: any, key: PropertyKey): Record<string, any>;
27
+ declare function invokeHandler(event: string, instance: Phecda): Promise<any[]>;
28
+
1
29
  interface NameSpace {
2
30
  [name: string]: Phecda;
3
31
  }
@@ -11,7 +39,7 @@ interface Handler {
11
39
  }
12
40
  interface Phecda {
13
41
  prototype: any;
14
- _namespace: {
42
+ [PHECDA_KEY]: {
15
43
  __EXPOSE_VAR__: Set<PropertyKey>;
16
44
  __IGNORE_VAR__: Set<PropertyKey>;
17
45
  __STATE_VAR__: Set<PropertyKey>;
@@ -25,57 +53,13 @@ type ClassValue<I> = {
25
53
  interface Events {
26
54
  }
27
55
 
28
- declare function Init(proto: any, key: PropertyKey): void;
29
- declare function Unmount(proto: any, key: PropertyKey): void;
30
- declare function Bind(value: any): (proto: any, k: PropertyKey) => void;
31
- declare function Ignore(proto: any, key: PropertyKey): void;
32
- declare function Clear(proto: any, key: PropertyKey): void;
33
- declare function Err<Fn extends (...args: any) => any>(cb: Fn): (proto: any, key: PropertyKey) => void;
34
- declare function Expose(proto: any, key: PropertyKey): void;
35
- declare function To(...callbacks: ((arg: any, instance: any, key: string) => any)[]): (proto: any, key: PropertyKey) => void;
56
+ declare function Isolate(target: any): void;
36
57
  declare function Tag(tag: PropertyKey): (module: any) => void;
37
58
  declare function Unique(desc?: string): (module: any) => void;
38
59
  declare function Assign(cb: (instance?: any) => any): (module: any) => void;
39
60
  declare function Global(module: any): void;
40
- declare function Empty(module: any): void;
41
- declare const DataMap: InjectData;
42
- declare function Provide<K extends keyof InjectData>(key: K, value: InjectData[K]): void;
43
- declare function Inject<K extends keyof InjectData>(key: K): InjectData[K];
44
- declare function Nested<M extends new (...args: any) => any>(module: M): (proto: any, key: PropertyKey) => void;
45
- declare function Isolate(): (target: any) => void;
46
-
47
- declare function getTag<M extends Construct | AbConstruct>(moduleOrInstance: M | InstanceType<M>): PropertyKey;
48
- declare function getBind<M extends Construct | AbConstruct>(module: M): any;
49
- declare function plainToClass<M extends Construct, Data extends Record<PropertyKey, any>>(module: M, input: Data): InstanceType<M>;
50
- declare function transformClass<M extends Construct>(instance: InstanceType<M>, force?: boolean): Promise<string[]>;
51
- declare function classToValue<M>(instance: M): ClassValue<M>;
52
- declare function snapShot<T extends Construct>(data: InstanceType<T>): {
53
- data: InstanceType<T>;
54
- clear(): void;
55
- apply(): void;
56
- };
57
- declare function addDecoToClass<M extends Construct | AbConstruct>(c: M, key: keyof InstanceType<M> | string, handler: ((target: any, key: PropertyKey) => void), type?: 'property' | 'class'): void;
58
- declare function Pipeline(...decos: ((...args: any) => void)[]): (...args: any) => void;
59
-
60
- declare function isPhecda(module: any): module is Construct;
61
- declare const SHARE_KEY: unique symbol;
62
- declare function init(proto: Phecda): void;
63
- declare function setVar(proto: Phecda, key: PropertyKey): void;
64
- declare function setExposeKey(proto: Phecda, key: PropertyKey): void;
65
- declare function setIgnoreKey(proto: Phecda, key: PropertyKey): void;
66
- declare function getOwnModuleState(instance: Phecda): string[];
67
- declare function getModuleState(instance: Phecda): PropertyKey[];
68
- declare function getOwnExposeKey(instance: Phecda): string[];
69
- declare function getExposeKey(instance: Phecda): PropertyKey[];
70
- declare function getOwnIgnoreKey(instance: Phecda): string[];
71
- declare function regisHandler(proto: Phecda, key: PropertyKey, handler: Handler): void;
72
- declare function getOwnHandler(instance: Phecda, key: PropertyKey): Handler[];
73
- declare function getHandler(instance: Phecda, key: PropertyKey): any[];
74
- declare function setState(proto: Phecda, key: PropertyKey, state: Record<string, any>): void;
75
- declare function getOwnState(instance: Phecda, key: PropertyKey): Object;
76
- declare function getState(instance: Phecda, key: PropertyKey): any;
77
- declare function invokeHandler(event: string, instance: Phecda): Promise<any[]>;
78
-
61
+ declare function To(...callbacks: ((arg: any, instance: any, key: string) => any)[]): (proto: any, key: PropertyKey) => void;
62
+ declare function Err(cb: (e: Error | any, instance: any, key: string) => void, isCatch?: boolean): (proto: any, key: PropertyKey) => void;
79
63
  interface StorageParam {
80
64
  key?: string;
81
65
  instance: any;
@@ -91,9 +75,6 @@ interface WatcherParam {
91
75
  once?: boolean;
92
76
  };
93
77
  }
94
- declare const activeInstance: Record<string, any>;
95
- declare function injectProperty(key: string, value: any): Record<string, any>;
96
- declare function getProperty(key: string): any;
97
78
  declare function Watcher(eventName: keyof Events, options?: {
98
79
  once?: boolean;
99
80
  }): (proto: any, key: string) => void;
@@ -104,4 +85,26 @@ declare function Storage({ key: storeKey, toJSON, toString }?: {
104
85
  key?: string;
105
86
  }): (proto: any, key?: PropertyKey) => void;
106
87
 
107
- export { AbConstruct, Assign, Bind, ClassValue, Clear, Construct, DataMap, Effect, Empty, Err, Events, Expose, Global, Handler, Ignore, Init, Inject, InjectData, Isolate, NameSpace, Nested, Phecda, Pipeline, Provide, SHARE_KEY, Storage, StorageParam, Tag, To, Unique, Unmount, Watcher, WatcherParam, activeInstance, addDecoToClass, classToValue, getBind, getExposeKey, getHandler, getModuleState, getOwnExposeKey, getOwnHandler, getOwnIgnoreKey, getOwnModuleState, getOwnState, getProperty, getState, getTag, init, injectProperty, invokeHandler, isPhecda, plainToClass, regisHandler, setExposeKey, setIgnoreKey, setState, setVar, snapShot, transformClass };
88
+ declare function getTag<M extends Construct | AbConstruct>(moduleOrInstance: M | InstanceType<M>): PropertyKey;
89
+ declare function getBind<M extends Construct | AbConstruct>(module: M): any;
90
+ declare function plainToClass<M extends Construct, Data extends Record<PropertyKey, any>>(module: M, input: Data): InstanceType<M>;
91
+ declare function transformClass<M extends Construct>(instance: InstanceType<M>, force?: boolean): Promise<string[]>;
92
+ declare function transformProperty<M extends Construct>(instance: InstanceType<M>, property: string, force?: boolean): Promise<string[]>;
93
+ declare function classToPlain<M>(instance: M): ClassValue<M>;
94
+ declare function snapShot<T extends Construct>(data: InstanceType<T>): {
95
+ data: InstanceType<T>;
96
+ clear(): void;
97
+ apply(): void;
98
+ };
99
+ declare function addDecoToClass<M extends Construct | AbConstruct>(c: M, key: keyof InstanceType<M> | PropertyKey, handler: PropertyDecorator | ClassDecorator): void;
100
+ declare function Pipeline(...decos: ((...args: any) => void)[]): (...args: any) => void;
101
+ declare function isAsyncFunc(fn: Function): boolean;
102
+
103
+ declare const DataMap: InjectData;
104
+ declare function Provide<K extends keyof InjectData>(key: K, value: InjectData[K]): void;
105
+ declare function Inject<K extends keyof InjectData>(key: K): InjectData[K];
106
+ declare const activeInstance: Record<string, any>;
107
+ declare function injectProperty(key: string, value: any): Record<string, any>;
108
+ declare function getProperty(key: string): any;
109
+
110
+ export { AbConstruct, Assign, Bind, ClassValue, Clear, Construct, DataMap, Effect, Empty, Err, Events, Expose, Global, Handler, Ignore, Init, Inject, InjectData, Isolate, NameSpace, PHECDA_KEY, Phecda, Pipeline, Provide, SHARE_KEY, Storage, StorageParam, Tag, To, Unique, Unmount, Watcher, WatcherParam, activeInstance, addDecoToClass, classToPlain, getBind, getExposeKey, getHandler, getOwnExposeKey, getOwnHandler, getOwnIgnoreKey, getOwnState, getOwnStateVars, getProperty, getState, getStateVars, getTag, init, injectProperty, invokeHandler, isAsyncFunc, isPhecda, plainToClass, setExposeKey, setHandler, setIgnoreKey, setState, setStateVar, snapShot, transformClass, transformProperty };