phecda-core 3.0.0-alpha.9 → 3.0.0-beta.14

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