phecda-core 2.1.2-alpha.0 → 3.0.0-alpha.10

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
@@ -4,13 +4,14 @@ interface NameSpace {
4
4
  interface InjectData {
5
5
  [key: string]: any;
6
6
  }
7
+ type Construct<T = any> = new (...args: any[]) => T;
8
+ type AbConstruct<T = any> = abstract new (...args: any[]) => T;
7
9
  interface Handler {
8
10
  [key: string]: any;
9
11
  }
10
12
  interface Phecda {
11
13
  prototype: any;
12
14
  _namespace: {
13
- __INIT_EVENT__: Set<PropertyKey>;
14
15
  __EXPOSE_VAR__: Set<PropertyKey>;
15
16
  __IGNORE_VAR__: Set<PropertyKey>;
16
17
  __STATE_VAR__: Set<PropertyKey>;
@@ -24,66 +25,83 @@ type ClassValue<I> = {
24
25
  interface Events {
25
26
  }
26
27
 
27
- declare function Init(target: any, key: PropertyKey): void;
28
- declare function Bind(value: any): (target: any, k: PropertyKey) => void;
29
- declare function Ignore(target: any, key: PropertyKey): void;
30
- declare function Clear(target: any, key: PropertyKey): void;
31
- declare function Err<Fn extends (...args: any) => any>(cb: Fn): (target: any, key: PropertyKey) => void;
32
- declare function Expose(target: any, key: PropertyKey): void;
33
- declare function To(cb: (arg: any, instance: any, key: string) => any): (obj: any, key: PropertyKey) => void;
34
- declare function Tag(tag: string): (target: any) => void;
35
- declare function Assign(cb: (instance?: any) => any): (target: any) => void;
36
- declare function Global(target: any): void;
37
- declare function Empty(_target: any): void;
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;
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;
38
41
  declare const DataMap: InjectData;
39
42
  declare function Provide<K extends keyof InjectData>(key: K, value: InjectData[K]): void;
40
43
  declare function Inject<K extends keyof InjectData>(key: K): InjectData[K];
41
- declare function Nested<M extends new (...args: any) => any>(Model: M): (obj: any, key: PropertyKey) => void;
44
+ declare function Nested<M extends new (...args: any) => any>(module: M): (proto: any, key: PropertyKey) => void;
45
+ declare function Isolate(): (target: any) => void;
42
46
 
43
- declare function getTag<M extends new (...args: any) => any>(Model: M): any;
44
- declare function getSymbol<M extends new (...args: any) => any>(instance: InstanceType<M>): any;
45
- declare function getBind<M extends new (...args: any) => any>(Model: M): any;
46
- declare function plainToClass<M extends new (...args: any) => any, Data extends Record<PropertyKey, any>>(Model: M, input: Data): InstanceType<M>;
47
- declare function transformClass<M extends new (...args: any) => any>(instance: InstanceType<M>, force?: boolean): Promise<string[]>;
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[]>;
48
51
  declare function classToValue<M>(instance: M): ClassValue<M>;
49
- declare function snapShot<T extends new (...args: any) => any>(data: InstanceType<T>): {
52
+ declare function snapShot<T extends Construct>(data: InstanceType<T>): {
50
53
  data: InstanceType<T>;
51
54
  clear(): void;
52
55
  apply(): void;
53
56
  };
54
- declare function addDecoToClass<M extends new (...args: any) => any>(c: M, key: keyof InstanceType<M> | string, handler: ((target: any, key: PropertyKey) => void), type?: 'static' | 'class' | 'normal'): void;
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;
55
58
  declare function Pipeline(...decos: ((...args: any) => void)[]): (...args: any) => void;
56
59
 
57
- declare function isPhecda(target: any): boolean;
58
- declare function init(target: Phecda): void;
59
- declare function regisInitEvent(target: Phecda, key: string): void;
60
- declare function getOwnInitEvent(target: Phecda): string[];
61
- declare function getInitEvent(target: Phecda): PropertyKey[];
62
- declare function setModelVar(target: Phecda, key: PropertyKey): void;
63
- declare function setExposeKey(target: Phecda, key: PropertyKey): void;
64
- declare function setIgnoreKey(target: Phecda, key: PropertyKey): void;
65
- declare function getOwnModelState(target: Phecda): string[];
66
- declare function getModelState(target: Phecda): PropertyKey[];
67
- declare function getOwnExposeKey(target: Phecda): string[];
68
- declare function getExposeKey(target: Phecda): PropertyKey[];
69
- declare function getOwnIgnoreKey(target: Phecda): string[];
70
- declare function regisHandler(target: Phecda, key: PropertyKey, handler: Handler): void;
71
- declare function getOwnHandler(target: Phecda, key: PropertyKey): Handler[];
72
- declare function getHandler(target: Phecda, key: PropertyKey): any[];
73
- declare function setState(target: Phecda, key: PropertyKey, state: Record<string, any>): void;
74
- declare function getOwnState(target: Phecda, key: PropertyKey): Object;
75
- declare function getState(target: Phecda, key: PropertyKey): any;
76
- declare function register(instance: Phecda): void;
77
- declare function registerAsync(instance: Phecda): Promise<void>;
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
78
 
79
+ interface StorageParam {
80
+ key?: string;
81
+ instance: any;
82
+ tag: string;
83
+ toJSON: (str: string) => any;
84
+ toString: (arg: any) => string;
85
+ }
86
+ interface WatcherParam {
87
+ key: string;
88
+ instance: any;
89
+ eventName: string;
90
+ options?: {
91
+ once?: boolean;
92
+ };
93
+ }
79
94
  declare const activeInstance: Record<string, any>;
80
95
  declare function injectProperty(key: string, value: any): Record<string, any>;
81
96
  declare function getProperty(key: string): any;
82
-
83
97
  declare function Watcher(eventName: keyof Events, options?: {
84
- once: boolean;
85
- }): (obj: any, key: string) => void;
86
- declare function Effect(eventName: string, options?: any): (obj: any, key: string) => void;
87
- declare function Storage(storeKey?: string): (target: any, key?: PropertyKey) => void;
98
+ once?: boolean;
99
+ }): (proto: any, key: string) => void;
100
+ declare function Effect(eventName: string, options?: any): (proto: any, key: string) => void;
101
+ declare function Storage({ key: storeKey, toJSON, toString }?: {
102
+ toJSON?: (str: string) => any;
103
+ toString?: (arg: any) => string;
104
+ key?: string;
105
+ }): (proto: any, key?: PropertyKey) => void;
88
106
 
89
- export { Assign, Bind, ClassValue, Clear, DataMap, Effect, Empty, Err, Events, Expose, Global, Handler, Ignore, Init, Inject, InjectData, NameSpace, Nested, Phecda, Pipeline, Provide, Storage, Tag, To, Watcher, activeInstance, addDecoToClass, classToValue, getBind, getExposeKey, getHandler, getInitEvent, getModelState, getOwnExposeKey, getOwnHandler, getOwnIgnoreKey, getOwnInitEvent, getOwnModelState, getOwnState, getProperty, getState, getSymbol, getTag, init, injectProperty, isPhecda, plainToClass, regisHandler, regisInitEvent, register, registerAsync, setExposeKey, setIgnoreKey, setModelVar, setState, snapShot, transformClass };
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 };