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

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,13 @@ interface NameSpace {
4
4
  interface InjectData {
5
5
  [key: string]: any;
6
6
  }
7
+ type Construct<T = any> = new (...args: any[]) => T;
7
8
  interface Handler {
8
9
  [key: string]: any;
9
10
  }
10
11
  interface Phecda {
11
12
  prototype: any;
12
13
  _namespace: {
13
- __INIT_EVENT__: Set<PropertyKey>;
14
14
  __EXPOSE_VAR__: Set<PropertyKey>;
15
15
  __IGNORE_VAR__: Set<PropertyKey>;
16
16
  __STATE_VAR__: Set<PropertyKey>;
@@ -24,26 +24,26 @@ type ClassValue<I> = {
24
24
  interface Events {
25
25
  }
26
26
 
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;
27
+ declare function Init(proto: any, key: PropertyKey): void;
28
+ declare function Bind(value: any): (proto: any, k: PropertyKey) => void;
29
+ declare function Ignore(proto: any, key: PropertyKey): void;
30
+ declare function Clear(proto: any, key: PropertyKey): void;
31
+ declare function Err<Fn extends (...args: any) => any>(cb: Fn): (proto: any, key: PropertyKey) => void;
32
+ declare function Expose(proto: any, key: PropertyKey): void;
33
+ declare function To(cb: (arg: any, instance: any, key: string) => any): (proto: any, key: PropertyKey) => void;
34
+ declare function Tag(tag: string): (module: any) => void;
35
+ declare function Assign(cb: (instance?: any) => any): (module: any) => void;
36
+ declare function Global(module: any): void;
37
+ declare function Empty(module: any): void;
38
38
  declare const DataMap: InjectData;
39
39
  declare function Provide<K extends keyof InjectData>(key: K, value: InjectData[K]): void;
40
40
  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;
41
+ declare function Nested<M extends new (...args: any) => any>(module: M): (proto: any, key: PropertyKey) => void;
42
42
 
43
- declare function getTag<M extends new (...args: any) => any>(Model: M): any;
43
+ declare function getTag<M extends new (...args: any) => any>(module: M): any;
44
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>;
45
+ declare function getBind<M extends new (...args: any) => any>(module: M): any;
46
+ declare function plainToClass<M extends new (...args: any) => any, Data extends Record<PropertyKey, any>>(module: M, input: Data): InstanceType<M>;
47
47
  declare function transformClass<M extends new (...args: any) => any>(instance: InstanceType<M>, force?: boolean): Promise<string[]>;
48
48
  declare function classToValue<M>(instance: M): ClassValue<M>;
49
49
  declare function snapShot<T extends new (...args: any) => any>(data: InstanceType<T>): {
@@ -51,39 +51,36 @@ declare function snapShot<T extends new (...args: any) => any>(data: InstanceTyp
51
51
  clear(): void;
52
52
  apply(): void;
53
53
  };
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;
54
+ declare function addDecoToClass<M extends new (...args: any) => any>(c: M, key: keyof InstanceType<M> | string, handler: ((target: any, key: PropertyKey) => void), type?: 'property' | 'class'): void;
55
55
  declare function Pipeline(...decos: ((...args: any) => void)[]): (...args: any) => void;
56
56
 
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;
57
+ declare function isPhecda(module: any): module is Construct;
58
+ declare const SHARE_KEY: unique symbol;
59
+ declare function init(proto: Phecda): void;
60
+ declare function setVar(proto: Phecda, key: PropertyKey): void;
61
+ declare function setExposeKey(proto: Phecda, key: PropertyKey): void;
62
+ declare function setIgnoreKey(proto: Phecda, key: PropertyKey): void;
63
+ declare function getOwnModuleState(instance: Phecda): string[];
64
+ declare function getModuleState(instance: Phecda): PropertyKey[];
65
+ declare function getOwnExposeKey(instance: Phecda): string[];
66
+ declare function getExposeKey(instance: Phecda): PropertyKey[];
67
+ declare function getOwnIgnoreKey(instance: Phecda): string[];
68
+ declare function regisHandler(proto: Phecda, key: PropertyKey, handler: Handler): void;
69
+ declare function getOwnHandler(instance: Phecda, key: PropertyKey): Handler[];
70
+ declare function getHandler(instance: Phecda, key: PropertyKey): any[];
71
+ declare function setState(proto: Phecda, key: PropertyKey, state: Record<string, any>): void;
72
+ declare function getOwnState(instance: Phecda, key: PropertyKey): Object;
73
+ declare function getState(instance: Phecda, key: PropertyKey): any;
76
74
  declare function register(instance: Phecda): void;
77
75
  declare function registerAsync(instance: Phecda): Promise<void>;
78
76
 
79
77
  declare const activeInstance: Record<string, any>;
80
78
  declare function injectProperty(key: string, value: any): Record<string, any>;
81
79
  declare function getProperty(key: string): any;
82
-
83
80
  declare function Watcher(eventName: keyof Events, options?: {
84
81
  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;
82
+ }): (proto: any, key: string) => void;
83
+ declare function Effect(eventName: string, options?: any): (proto: any, key: string) => void;
84
+ declare function Storage(storeKey?: string): (proto: any, key?: PropertyKey) => void;
88
85
 
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 };
86
+ export { Assign, Bind, ClassValue, Clear, Construct, DataMap, Effect, Empty, Err, Events, Expose, Global, Handler, Ignore, Init, Inject, InjectData, NameSpace, Nested, Phecda, Pipeline, Provide, SHARE_KEY, Storage, Tag, To, Watcher, activeInstance, addDecoToClass, classToValue, getBind, getExposeKey, getHandler, getModuleState, getOwnExposeKey, getOwnHandler, getOwnIgnoreKey, getOwnModuleState, getOwnState, getProperty, getState, getSymbol, getTag, init, injectProperty, isPhecda, plainToClass, regisHandler, register, registerAsync, setExposeKey, setIgnoreKey, setState, setVar, snapShot, transformClass };
package/dist/index.js CHANGED
@@ -36,6 +36,7 @@ __export(src_exports, {
36
36
  Nested: () => Nested,
37
37
  Pipeline: () => Pipeline,
38
38
  Provide: () => Provide,
39
+ SHARE_KEY: () => SHARE_KEY,
39
40
  Storage: () => Storage,
40
41
  Tag: () => Tag,
41
42
  To: () => To,
@@ -46,13 +47,11 @@ __export(src_exports, {
46
47
  getBind: () => getBind,
47
48
  getExposeKey: () => getExposeKey,
48
49
  getHandler: () => getHandler,
49
- getInitEvent: () => getInitEvent,
50
- getModelState: () => getModelState,
50
+ getModuleState: () => getModuleState,
51
51
  getOwnExposeKey: () => getOwnExposeKey,
52
52
  getOwnHandler: () => getOwnHandler,
53
53
  getOwnIgnoreKey: () => getOwnIgnoreKey,
54
- getOwnInitEvent: () => getOwnInitEvent,
55
- getOwnModelState: () => getOwnModelState,
54
+ getOwnModuleState: () => getOwnModuleState,
56
55
  getOwnState: () => getOwnState,
57
56
  getProperty: () => getProperty,
58
57
  getState: () => getState,
@@ -63,32 +62,30 @@ __export(src_exports, {
63
62
  isPhecda: () => isPhecda,
64
63
  plainToClass: () => plainToClass,
65
64
  regisHandler: () => regisHandler,
66
- regisInitEvent: () => regisInitEvent,
67
65
  register: () => register,
68
66
  registerAsync: () => registerAsync,
69
67
  setExposeKey: () => setExposeKey,
70
68
  setIgnoreKey: () => setIgnoreKey,
71
- setModelVar: () => setModelVar,
72
69
  setState: () => setState,
70
+ setVar: () => setVar,
73
71
  snapShot: () => snapShot,
74
72
  transformClass: () => transformClass
75
73
  });
76
74
  module.exports = __toCommonJS(src_exports);
77
75
 
78
76
  // src/core.ts
79
- function isPhecda(target) {
80
- if (typeof target === "function") {
81
- return !!target.prototype?._namespace;
82
- }
77
+ function isPhecda(module2) {
78
+ if (typeof module2 === "function")
79
+ return !!module2.prototype?._namespace;
83
80
  return false;
84
81
  }
85
82
  __name(isPhecda, "isPhecda");
86
- function init(target) {
87
- if (!target)
83
+ var SHARE_KEY = Symbol("phecda-core");
84
+ function init(proto) {
85
+ if (!proto)
88
86
  return;
89
- if (!target.hasOwnProperty("_namespace")) {
90
- target._namespace = {
91
- __INIT_EVENT__: /* @__PURE__ */ new Set(),
87
+ if (!proto.hasOwnProperty("_namespace")) {
88
+ proto._namespace = {
92
89
  __EXPOSE_VAR__: /* @__PURE__ */ new Set(),
93
90
  __IGNORE_VAR__: /* @__PURE__ */ new Set(),
94
91
  __STATE_VAR__: /* @__PURE__ */ new Set(),
@@ -98,56 +95,31 @@ function init(target) {
98
95
  }
99
96
  }
100
97
  __name(init, "init");
101
- function regisInitEvent(target, key) {
102
- init(target);
103
- target._namespace.__INIT_EVENT__.add(key);
98
+ function setVar(proto, key) {
99
+ init(proto);
100
+ proto._namespace.__STATE_VAR__.add(key);
101
+ setExposeKey(proto, key);
104
102
  }
105
- __name(regisInitEvent, "regisInitEvent");
106
- function getOwnInitEvent(target) {
107
- if (!target?._namespace)
108
- return [];
109
- return [
110
- ...target._namespace.__INIT_EVENT__
111
- ];
112
- }
113
- __name(getOwnInitEvent, "getOwnInitEvent");
114
- function getInitEvent(target) {
115
- let proto = Object.getPrototypeOf(target);
116
- const set = /* @__PURE__ */ new Set();
117
- while (proto?._namespace) {
118
- proto._namespace.__INIT_EVENT__.forEach((item) => set.add(item));
119
- proto = Object.getPrototypeOf(proto);
120
- }
121
- return [
122
- ...set
123
- ];
124
- }
125
- __name(getInitEvent, "getInitEvent");
126
- function setModelVar(target, key) {
127
- init(target);
128
- target._namespace.__STATE_VAR__.add(key);
129
- setExposeKey(target, key);
130
- }
131
- __name(setModelVar, "setModelVar");
132
- function setExposeKey(target, key) {
133
- init(target);
134
- target._namespace.__EXPOSE_VAR__.add(key);
103
+ __name(setVar, "setVar");
104
+ function setExposeKey(proto, key) {
105
+ init(proto);
106
+ proto._namespace.__EXPOSE_VAR__.add(key);
135
107
  }
136
108
  __name(setExposeKey, "setExposeKey");
137
- function setIgnoreKey(target, key) {
138
- init(target);
139
- target._namespace.__IGNORE_VAR__.add(key);
109
+ function setIgnoreKey(proto, key) {
110
+ init(proto);
111
+ proto._namespace.__IGNORE_VAR__.add(key);
140
112
  }
141
113
  __name(setIgnoreKey, "setIgnoreKey");
142
- function getOwnModelState(target) {
143
- target = Object.getPrototypeOf(target);
114
+ function getOwnModuleState(instance) {
115
+ instance = Object.getPrototypeOf(instance);
144
116
  return [
145
- ...target._namespace.__STATE_VAR__
117
+ ...instance._namespace.__STATE_VAR__
146
118
  ];
147
119
  }
148
- __name(getOwnModelState, "getOwnModelState");
149
- function getModelState(target) {
150
- let proto = Object.getPrototypeOf(target);
120
+ __name(getOwnModuleState, "getOwnModuleState");
121
+ function getModuleState(instance) {
122
+ let proto = Object.getPrototypeOf(instance);
151
123
  const set = /* @__PURE__ */ new Set();
152
124
  while (proto?._namespace) {
153
125
  proto._namespace.__STATE_VAR__.forEach((item) => set.add(item));
@@ -157,16 +129,16 @@ function getModelState(target) {
157
129
  ...set
158
130
  ];
159
131
  }
160
- __name(getModelState, "getModelState");
161
- function getOwnExposeKey(target) {
162
- target = Object.getPrototypeOf(target);
132
+ __name(getModuleState, "getModuleState");
133
+ function getOwnExposeKey(instance) {
134
+ instance = Object.getPrototypeOf(instance);
163
135
  return [
164
- ...target._namespace.__EXPOSE_VAR__
165
- ].filter((item) => !target._namespace.__IGNORE_VAR__.has(item));
136
+ ...instance._namespace.__EXPOSE_VAR__
137
+ ].filter((item) => !instance._namespace.__IGNORE_VAR__.has(item));
166
138
  }
167
139
  __name(getOwnExposeKey, "getOwnExposeKey");
168
- function getExposeKey(target) {
169
- let proto = Object.getPrototypeOf(target);
140
+ function getExposeKey(instance) {
141
+ let proto = Object.getPrototypeOf(instance);
170
142
  const set = /* @__PURE__ */ new Set();
171
143
  while (proto?._namespace) {
172
144
  [
@@ -179,32 +151,32 @@ function getExposeKey(target) {
179
151
  ];
180
152
  }
181
153
  __name(getExposeKey, "getExposeKey");
182
- function getOwnIgnoreKey(target) {
183
- if (!target?._namespace)
154
+ function getOwnIgnoreKey(instance) {
155
+ if (!instance?._namespace)
184
156
  return [];
185
157
  return [
186
- ...target._namespace.__IGNORE_VAR__
158
+ ...instance._namespace.__IGNORE_VAR__
187
159
  ];
188
160
  }
189
161
  __name(getOwnIgnoreKey, "getOwnIgnoreKey");
190
- function regisHandler(target, key, handler) {
191
- init(target);
192
- if (!target._namespace.__STATE_HANDLER__.has(key))
193
- target._namespace.__STATE_HANDLER__.set(key, [
162
+ function regisHandler(proto, key, handler) {
163
+ init(proto);
164
+ if (!proto._namespace.__STATE_HANDLER__.has(key))
165
+ proto._namespace.__STATE_HANDLER__.set(key, [
194
166
  handler
195
167
  ]);
196
168
  else
197
- target._namespace.__STATE_HANDLER__.get(key).push(handler);
169
+ proto._namespace.__STATE_HANDLER__.get(key).push(handler);
198
170
  }
199
171
  __name(regisHandler, "regisHandler");
200
- function getOwnHandler(target, key) {
201
- if (!target?._namespace)
172
+ function getOwnHandler(instance, key) {
173
+ if (!instance?._namespace)
202
174
  return [];
203
- return target._namespace.__STATE_HANDLER__.get(key) || [];
175
+ return instance._namespace.__STATE_HANDLER__.get(key) || [];
204
176
  }
205
177
  __name(getOwnHandler, "getOwnHandler");
206
- function getHandler(target, key) {
207
- let proto = Object.getPrototypeOf(target);
178
+ function getHandler(instance, key) {
179
+ let proto = Object.getPrototypeOf(instance);
208
180
  const set = /* @__PURE__ */ new Set();
209
181
  while (proto?._namespace) {
210
182
  proto._namespace.__STATE_HANDLER__.get(key)?.forEach((item) => set.add(item));
@@ -215,19 +187,19 @@ function getHandler(target, key) {
215
187
  ];
216
188
  }
217
189
  __name(getHandler, "getHandler");
218
- function setState(target, key, state) {
219
- init(target);
220
- const namespace = target._namespace.__STATE_NAMESPACE__;
190
+ function setState(proto, key, state) {
191
+ init(proto);
192
+ const namespace = proto._namespace.__STATE_NAMESPACE__;
221
193
  namespace.set(key, state);
222
194
  }
223
195
  __name(setState, "setState");
224
- function getOwnState(target, key) {
225
- target = Object.getPrototypeOf(target);
226
- return target._namespace.__STATE_NAMESPACE__.get(key) || {};
196
+ function getOwnState(instance, key) {
197
+ instance = Object.getPrototypeOf(instance);
198
+ return instance._namespace.__STATE_NAMESPACE__.get(key) || {};
227
199
  }
228
200
  __name(getOwnState, "getOwnState");
229
- function getState(target, key) {
230
- let proto = Object.getPrototypeOf(target);
201
+ function getState(instance, key) {
202
+ let proto = Object.getPrototypeOf(instance);
231
203
  let ret = {};
232
204
  while (proto?._namespace) {
233
205
  const state = proto._namespace.__STATE_NAMESPACE__.get(key);
@@ -261,18 +233,18 @@ async function registerAsync(instance) {
261
233
  __name(registerAsync, "registerAsync");
262
234
 
263
235
  // src/helper.ts
264
- function getTag(Model) {
265
- return Model.prototype?.__TAG__;
236
+ function getTag(module2) {
237
+ return module2.prototype?.__TAG__;
266
238
  }
267
239
  __name(getTag, "getTag");
268
240
  function getSymbol(instance) {
269
- const Model = instance.constructor;
270
- return getTag(Model) || Model.name;
241
+ const module2 = instance.constructor;
242
+ return getTag(module2) || module2.name;
271
243
  }
272
244
  __name(getSymbol, "getSymbol");
273
- function getBind(Model) {
274
- const instance = new Model();
275
- const keys = getModelState(instance);
245
+ function getBind(module2) {
246
+ const instance = new module2();
247
+ const keys = getModuleState(instance);
276
248
  const ret = {};
277
249
  for (const item of keys) {
278
250
  const state = getState(instance, item);
@@ -282,8 +254,8 @@ function getBind(Model) {
282
254
  return ret;
283
255
  }
284
256
  __name(getBind, "getBind");
285
- function plainToClass(Model, input) {
286
- const instance = new Model();
257
+ function plainToClass(module2, input) {
258
+ const instance = new module2();
287
259
  const keys = getExposeKey(instance);
288
260
  for (const item of keys)
289
261
  instance[item] = input[item];
@@ -292,7 +264,7 @@ function plainToClass(Model, input) {
292
264
  __name(plainToClass, "plainToClass");
293
265
  async function transformClass(instance, force = false) {
294
266
  const err = [];
295
- const stateVars = getModelState(instance);
267
+ const stateVars = getModuleState(instance);
296
268
  for (const item of stateVars) {
297
269
  const handlers = getHandler(instance, item);
298
270
  if (handlers) {
@@ -336,8 +308,8 @@ function snapShot(data) {
336
308
  };
337
309
  }
338
310
  __name(snapShot, "snapShot");
339
- function addDecoToClass(c, key, handler, type = "normal") {
340
- handler(type === "normal" ? c.prototype : c, key);
311
+ function addDecoToClass(c, key, handler, type = "class") {
312
+ handler(type === "class" ? c.prototype : c, key);
341
313
  }
342
314
  __name(addDecoToClass, "addDecoToClass");
343
315
  function Pipeline(...decos) {
@@ -349,9 +321,9 @@ function Pipeline(...decos) {
349
321
  __name(Pipeline, "Pipeline");
350
322
 
351
323
  // src/decorators.ts
352
- function Init(target, key) {
353
- setModelVar(target, key);
354
- regisHandler(target, key, {
324
+ function Init(proto, key) {
325
+ setVar(proto, key);
326
+ regisHandler(proto, key, {
355
327
  async init(instance) {
356
328
  instance[key]();
357
329
  }
@@ -359,45 +331,44 @@ function Init(target, key) {
359
331
  }
360
332
  __name(Init, "Init");
361
333
  function Bind(value) {
362
- return (target, k) => {
363
- setModelVar(target, k);
364
- setState(target, k, {
334
+ return (proto, k) => {
335
+ setVar(proto, k);
336
+ setState(proto, k, {
365
337
  value
366
338
  });
367
339
  };
368
340
  }
369
341
  __name(Bind, "Bind");
370
- function Ignore(target, key) {
371
- setIgnoreKey(target, key);
342
+ function Ignore(proto, key) {
343
+ setIgnoreKey(proto, key);
372
344
  }
373
345
  __name(Ignore, "Ignore");
374
- function Clear(target, key) {
375
- init(target);
376
- target._namespace.__INIT_EVENT__.delete(key);
377
- target._namespace.__EXPOSE_VAR__.delete(key);
378
- target._namespace.__IGNORE_VAR__.delete(key);
379
- target._namespace.__STATE_VAR__.delete(key);
380
- target._namespace.__STATE_HANDLER__.delete(key);
381
- target._namespace.__STATE_NAMESPACE__.delete(key);
346
+ function Clear(proto, key) {
347
+ init(proto);
348
+ proto._namespace.__EXPOSE_VAR__.delete(key);
349
+ proto._namespace.__IGNORE_VAR__.delete(key);
350
+ proto._namespace.__STATE_VAR__.delete(key);
351
+ proto._namespace.__STATE_HANDLER__.delete(key);
352
+ proto._namespace.__STATE_NAMESPACE__.delete(key);
382
353
  }
383
354
  __name(Clear, "Clear");
384
355
  function Err(cb) {
385
- return (target, key) => {
386
- setModelVar(target, key);
387
- regisHandler(target, key, {
356
+ return (proto, key) => {
357
+ setVar(proto, key);
358
+ regisHandler(proto, key, {
388
359
  error: cb
389
360
  });
390
361
  };
391
362
  }
392
363
  __name(Err, "Err");
393
- function Expose(target, key) {
394
- setExposeKey(target, key);
364
+ function Expose(proto, key) {
365
+ setExposeKey(proto, key);
395
366
  }
396
367
  __name(Expose, "Expose");
397
368
  function To(cb) {
398
- return (obj, key) => {
399
- setModelVar(obj, key);
400
- regisHandler(obj, key, {
369
+ return (proto, key) => {
370
+ setVar(proto, key);
371
+ regisHandler(proto, key, {
401
372
  async pipe(instance) {
402
373
  instance[key] = await cb(instance[key], instance, key);
403
374
  }
@@ -406,17 +377,17 @@ function To(cb) {
406
377
  }
407
378
  __name(To, "To");
408
379
  function Tag(tag) {
409
- return (target) => {
410
- init(target.prototype);
411
- target.prototype.__TAG__ = tag;
380
+ return (module2) => {
381
+ init(module2.prototype);
382
+ module2.prototype.__TAG__ = tag;
412
383
  };
413
384
  }
414
385
  __name(Tag, "Tag");
415
386
  function Assign(cb) {
416
- return (target) => {
417
- init(target.prototype);
418
- setModelVar(target.prototype, "__CLASS");
419
- regisHandler(target.prototype, "__CLASS", {
387
+ return (module2) => {
388
+ init(module2.prototype);
389
+ setVar(module2.prototype, SHARE_KEY);
390
+ regisHandler(module2.prototype, SHARE_KEY, {
420
391
  init: async (instance) => {
421
392
  const value = await cb(instance);
422
393
  if (value && typeof value === "object" && !Array.isArray(value)) {
@@ -428,10 +399,10 @@ function Assign(cb) {
428
399
  };
429
400
  }
430
401
  __name(Assign, "Assign");
431
- function Global(target) {
432
- init(target.prototype);
433
- setModelVar(target.prototype, "__CLASS");
434
- regisHandler(target.prototype, "__CLASS", {
402
+ function Global(module2) {
403
+ init(module2.prototype);
404
+ setVar(module2.prototype, SHARE_KEY);
405
+ regisHandler(module2.prototype, SHARE_KEY, {
435
406
  init: async (instance) => {
436
407
  const tag = instance.__TAG__;
437
408
  if (!tag)
@@ -443,8 +414,8 @@ function Global(target) {
443
414
  });
444
415
  }
445
416
  __name(Global, "Global");
446
- function Empty(_target) {
447
- init(_target.prototype);
417
+ function Empty(module2) {
418
+ init(module2.prototype);
448
419
  }
449
420
  __name(Empty, "Empty");
450
421
  var DataMap = {};
@@ -461,9 +432,9 @@ function Inject(key) {
461
432
  return DataMap[key] || EmptyProxy;
462
433
  }
463
434
  __name(Inject, "Inject");
464
- function Nested(Model) {
435
+ function Nested(module2) {
465
436
  return To(async (property) => {
466
- const instance = plainToClass(Model, property);
437
+ const instance = plainToClass(module2, property);
467
438
  const err = await transformClass(instance);
468
439
  if (err.length > 0)
469
440
  throw new Error(err[0]);
@@ -472,7 +443,7 @@ function Nested(Model) {
472
443
  }
473
444
  __name(Nested, "Nested");
474
445
 
475
- // src/namespace.ts
446
+ // src/custom/decorator.ts
476
447
  var activeInstance = {};
477
448
  function injectProperty(key, value) {
478
449
  activeInstance[key] = value;
@@ -483,12 +454,10 @@ function getProperty(key) {
483
454
  return activeInstance[key];
484
455
  }
485
456
  __name(getProperty, "getProperty");
486
-
487
- // src/custom/decorator.ts
488
457
  function Watcher(eventName, options) {
489
- return (obj, key) => {
490
- setModelVar(obj, key);
491
- regisHandler(obj, key, {
458
+ return (proto, key) => {
459
+ setVar(proto, key);
460
+ regisHandler(proto, key, {
492
461
  init(instance) {
493
462
  getProperty("watcher")?.({
494
463
  eventName,
@@ -502,9 +471,9 @@ function Watcher(eventName, options) {
502
471
  }
503
472
  __name(Watcher, "Watcher");
504
473
  function Effect(eventName, options) {
505
- return (obj, key) => {
506
- setModelVar(obj, key);
507
- regisHandler(obj, key, {
474
+ return (proto, key) => {
475
+ setVar(proto, key);
476
+ regisHandler(proto, key, {
508
477
  init(instance) {
509
478
  instance[`$_${key}`] = instance[key];
510
479
  Object.defineProperty(instance, key, {
@@ -528,14 +497,14 @@ function Effect(eventName, options) {
528
497
  }
529
498
  __name(Effect, "Effect");
530
499
  function Storage(storeKey) {
531
- return (target, key) => {
500
+ return (proto, key) => {
532
501
  let tag;
533
502
  if (key) {
534
- init(target);
535
- tag = storeKey || target.__TAG__;
503
+ init(proto);
504
+ tag = storeKey || proto.__TAG__;
536
505
  const uniTag = Symbol(tag);
537
- setModelVar(target, uniTag);
538
- regisHandler(target, uniTag, {
506
+ setVar(proto, uniTag);
507
+ regisHandler(proto, uniTag, {
539
508
  init: (instance) => {
540
509
  getProperty("storage")?.({
541
510
  instance,
@@ -545,11 +514,11 @@ function Storage(storeKey) {
545
514
  }
546
515
  });
547
516
  } else {
548
- init(target.prototype);
549
- tag = storeKey || `${target.prototype.__TAG__}_${key}`;
517
+ init(proto.prototype);
518
+ tag = storeKey || `${proto.prototype.__TAG__}_${key}`;
550
519
  const uniTag = Symbol(tag);
551
- setModelVar(target.prototype, uniTag);
552
- regisHandler(target.prototype, uniTag, {
520
+ setVar(proto.prototype, uniTag);
521
+ regisHandler(proto.prototype, uniTag, {
553
522
  init: (instance) => {
554
523
  getProperty("storage")?.({
555
524
  instance,
@@ -579,6 +548,7 @@ __name(Storage, "Storage");
579
548
  Nested,
580
549
  Pipeline,
581
550
  Provide,
551
+ SHARE_KEY,
582
552
  Storage,
583
553
  Tag,
584
554
  To,
@@ -589,13 +559,11 @@ __name(Storage, "Storage");
589
559
  getBind,
590
560
  getExposeKey,
591
561
  getHandler,
592
- getInitEvent,
593
- getModelState,
562
+ getModuleState,
594
563
  getOwnExposeKey,
595
564
  getOwnHandler,
596
565
  getOwnIgnoreKey,
597
- getOwnInitEvent,
598
- getOwnModelState,
566
+ getOwnModuleState,
599
567
  getOwnState,
600
568
  getProperty,
601
569
  getState,
@@ -606,13 +574,12 @@ __name(Storage, "Storage");
606
574
  isPhecda,
607
575
  plainToClass,
608
576
  regisHandler,
609
- regisInitEvent,
610
577
  register,
611
578
  registerAsync,
612
579
  setExposeKey,
613
580
  setIgnoreKey,
614
- setModelVar,
615
581
  setState,
582
+ setVar,
616
583
  snapShot,
617
584
  transformClass
618
585
  });
package/dist/index.mjs CHANGED
@@ -2,19 +2,18 @@ var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
 
4
4
  // src/core.ts
5
- function isPhecda(target) {
6
- if (typeof target === "function") {
7
- return !!target.prototype?._namespace;
8
- }
5
+ function isPhecda(module) {
6
+ if (typeof module === "function")
7
+ return !!module.prototype?._namespace;
9
8
  return false;
10
9
  }
11
10
  __name(isPhecda, "isPhecda");
12
- function init(target) {
13
- if (!target)
11
+ var SHARE_KEY = Symbol("phecda-core");
12
+ function init(proto) {
13
+ if (!proto)
14
14
  return;
15
- if (!target.hasOwnProperty("_namespace")) {
16
- target._namespace = {
17
- __INIT_EVENT__: /* @__PURE__ */ new Set(),
15
+ if (!proto.hasOwnProperty("_namespace")) {
16
+ proto._namespace = {
18
17
  __EXPOSE_VAR__: /* @__PURE__ */ new Set(),
19
18
  __IGNORE_VAR__: /* @__PURE__ */ new Set(),
20
19
  __STATE_VAR__: /* @__PURE__ */ new Set(),
@@ -24,56 +23,31 @@ function init(target) {
24
23
  }
25
24
  }
26
25
  __name(init, "init");
27
- function regisInitEvent(target, key) {
28
- init(target);
29
- target._namespace.__INIT_EVENT__.add(key);
26
+ function setVar(proto, key) {
27
+ init(proto);
28
+ proto._namespace.__STATE_VAR__.add(key);
29
+ setExposeKey(proto, key);
30
30
  }
31
- __name(regisInitEvent, "regisInitEvent");
32
- function getOwnInitEvent(target) {
33
- if (!target?._namespace)
34
- return [];
35
- return [
36
- ...target._namespace.__INIT_EVENT__
37
- ];
38
- }
39
- __name(getOwnInitEvent, "getOwnInitEvent");
40
- function getInitEvent(target) {
41
- let proto = Object.getPrototypeOf(target);
42
- const set = /* @__PURE__ */ new Set();
43
- while (proto?._namespace) {
44
- proto._namespace.__INIT_EVENT__.forEach((item) => set.add(item));
45
- proto = Object.getPrototypeOf(proto);
46
- }
47
- return [
48
- ...set
49
- ];
50
- }
51
- __name(getInitEvent, "getInitEvent");
52
- function setModelVar(target, key) {
53
- init(target);
54
- target._namespace.__STATE_VAR__.add(key);
55
- setExposeKey(target, key);
56
- }
57
- __name(setModelVar, "setModelVar");
58
- function setExposeKey(target, key) {
59
- init(target);
60
- target._namespace.__EXPOSE_VAR__.add(key);
31
+ __name(setVar, "setVar");
32
+ function setExposeKey(proto, key) {
33
+ init(proto);
34
+ proto._namespace.__EXPOSE_VAR__.add(key);
61
35
  }
62
36
  __name(setExposeKey, "setExposeKey");
63
- function setIgnoreKey(target, key) {
64
- init(target);
65
- target._namespace.__IGNORE_VAR__.add(key);
37
+ function setIgnoreKey(proto, key) {
38
+ init(proto);
39
+ proto._namespace.__IGNORE_VAR__.add(key);
66
40
  }
67
41
  __name(setIgnoreKey, "setIgnoreKey");
68
- function getOwnModelState(target) {
69
- target = Object.getPrototypeOf(target);
42
+ function getOwnModuleState(instance) {
43
+ instance = Object.getPrototypeOf(instance);
70
44
  return [
71
- ...target._namespace.__STATE_VAR__
45
+ ...instance._namespace.__STATE_VAR__
72
46
  ];
73
47
  }
74
- __name(getOwnModelState, "getOwnModelState");
75
- function getModelState(target) {
76
- let proto = Object.getPrototypeOf(target);
48
+ __name(getOwnModuleState, "getOwnModuleState");
49
+ function getModuleState(instance) {
50
+ let proto = Object.getPrototypeOf(instance);
77
51
  const set = /* @__PURE__ */ new Set();
78
52
  while (proto?._namespace) {
79
53
  proto._namespace.__STATE_VAR__.forEach((item) => set.add(item));
@@ -83,16 +57,16 @@ function getModelState(target) {
83
57
  ...set
84
58
  ];
85
59
  }
86
- __name(getModelState, "getModelState");
87
- function getOwnExposeKey(target) {
88
- target = Object.getPrototypeOf(target);
60
+ __name(getModuleState, "getModuleState");
61
+ function getOwnExposeKey(instance) {
62
+ instance = Object.getPrototypeOf(instance);
89
63
  return [
90
- ...target._namespace.__EXPOSE_VAR__
91
- ].filter((item) => !target._namespace.__IGNORE_VAR__.has(item));
64
+ ...instance._namespace.__EXPOSE_VAR__
65
+ ].filter((item) => !instance._namespace.__IGNORE_VAR__.has(item));
92
66
  }
93
67
  __name(getOwnExposeKey, "getOwnExposeKey");
94
- function getExposeKey(target) {
95
- let proto = Object.getPrototypeOf(target);
68
+ function getExposeKey(instance) {
69
+ let proto = Object.getPrototypeOf(instance);
96
70
  const set = /* @__PURE__ */ new Set();
97
71
  while (proto?._namespace) {
98
72
  [
@@ -105,32 +79,32 @@ function getExposeKey(target) {
105
79
  ];
106
80
  }
107
81
  __name(getExposeKey, "getExposeKey");
108
- function getOwnIgnoreKey(target) {
109
- if (!target?._namespace)
82
+ function getOwnIgnoreKey(instance) {
83
+ if (!instance?._namespace)
110
84
  return [];
111
85
  return [
112
- ...target._namespace.__IGNORE_VAR__
86
+ ...instance._namespace.__IGNORE_VAR__
113
87
  ];
114
88
  }
115
89
  __name(getOwnIgnoreKey, "getOwnIgnoreKey");
116
- function regisHandler(target, key, handler) {
117
- init(target);
118
- if (!target._namespace.__STATE_HANDLER__.has(key))
119
- target._namespace.__STATE_HANDLER__.set(key, [
90
+ function regisHandler(proto, key, handler) {
91
+ init(proto);
92
+ if (!proto._namespace.__STATE_HANDLER__.has(key))
93
+ proto._namespace.__STATE_HANDLER__.set(key, [
120
94
  handler
121
95
  ]);
122
96
  else
123
- target._namespace.__STATE_HANDLER__.get(key).push(handler);
97
+ proto._namespace.__STATE_HANDLER__.get(key).push(handler);
124
98
  }
125
99
  __name(regisHandler, "regisHandler");
126
- function getOwnHandler(target, key) {
127
- if (!target?._namespace)
100
+ function getOwnHandler(instance, key) {
101
+ if (!instance?._namespace)
128
102
  return [];
129
- return target._namespace.__STATE_HANDLER__.get(key) || [];
103
+ return instance._namespace.__STATE_HANDLER__.get(key) || [];
130
104
  }
131
105
  __name(getOwnHandler, "getOwnHandler");
132
- function getHandler(target, key) {
133
- let proto = Object.getPrototypeOf(target);
106
+ function getHandler(instance, key) {
107
+ let proto = Object.getPrototypeOf(instance);
134
108
  const set = /* @__PURE__ */ new Set();
135
109
  while (proto?._namespace) {
136
110
  proto._namespace.__STATE_HANDLER__.get(key)?.forEach((item) => set.add(item));
@@ -141,19 +115,19 @@ function getHandler(target, key) {
141
115
  ];
142
116
  }
143
117
  __name(getHandler, "getHandler");
144
- function setState(target, key, state) {
145
- init(target);
146
- const namespace = target._namespace.__STATE_NAMESPACE__;
118
+ function setState(proto, key, state) {
119
+ init(proto);
120
+ const namespace = proto._namespace.__STATE_NAMESPACE__;
147
121
  namespace.set(key, state);
148
122
  }
149
123
  __name(setState, "setState");
150
- function getOwnState(target, key) {
151
- target = Object.getPrototypeOf(target);
152
- return target._namespace.__STATE_NAMESPACE__.get(key) || {};
124
+ function getOwnState(instance, key) {
125
+ instance = Object.getPrototypeOf(instance);
126
+ return instance._namespace.__STATE_NAMESPACE__.get(key) || {};
153
127
  }
154
128
  __name(getOwnState, "getOwnState");
155
- function getState(target, key) {
156
- let proto = Object.getPrototypeOf(target);
129
+ function getState(instance, key) {
130
+ let proto = Object.getPrototypeOf(instance);
157
131
  let ret = {};
158
132
  while (proto?._namespace) {
159
133
  const state = proto._namespace.__STATE_NAMESPACE__.get(key);
@@ -187,18 +161,18 @@ async function registerAsync(instance) {
187
161
  __name(registerAsync, "registerAsync");
188
162
 
189
163
  // src/helper.ts
190
- function getTag(Model) {
191
- return Model.prototype?.__TAG__;
164
+ function getTag(module) {
165
+ return module.prototype?.__TAG__;
192
166
  }
193
167
  __name(getTag, "getTag");
194
168
  function getSymbol(instance) {
195
- const Model = instance.constructor;
196
- return getTag(Model) || Model.name;
169
+ const module = instance.constructor;
170
+ return getTag(module) || module.name;
197
171
  }
198
172
  __name(getSymbol, "getSymbol");
199
- function getBind(Model) {
200
- const instance = new Model();
201
- const keys = getModelState(instance);
173
+ function getBind(module) {
174
+ const instance = new module();
175
+ const keys = getModuleState(instance);
202
176
  const ret = {};
203
177
  for (const item of keys) {
204
178
  const state = getState(instance, item);
@@ -208,8 +182,8 @@ function getBind(Model) {
208
182
  return ret;
209
183
  }
210
184
  __name(getBind, "getBind");
211
- function plainToClass(Model, input) {
212
- const instance = new Model();
185
+ function plainToClass(module, input) {
186
+ const instance = new module();
213
187
  const keys = getExposeKey(instance);
214
188
  for (const item of keys)
215
189
  instance[item] = input[item];
@@ -218,7 +192,7 @@ function plainToClass(Model, input) {
218
192
  __name(plainToClass, "plainToClass");
219
193
  async function transformClass(instance, force = false) {
220
194
  const err = [];
221
- const stateVars = getModelState(instance);
195
+ const stateVars = getModuleState(instance);
222
196
  for (const item of stateVars) {
223
197
  const handlers = getHandler(instance, item);
224
198
  if (handlers) {
@@ -262,8 +236,8 @@ function snapShot(data) {
262
236
  };
263
237
  }
264
238
  __name(snapShot, "snapShot");
265
- function addDecoToClass(c, key, handler, type = "normal") {
266
- handler(type === "normal" ? c.prototype : c, key);
239
+ function addDecoToClass(c, key, handler, type = "class") {
240
+ handler(type === "class" ? c.prototype : c, key);
267
241
  }
268
242
  __name(addDecoToClass, "addDecoToClass");
269
243
  function Pipeline(...decos) {
@@ -275,9 +249,9 @@ function Pipeline(...decos) {
275
249
  __name(Pipeline, "Pipeline");
276
250
 
277
251
  // src/decorators.ts
278
- function Init(target, key) {
279
- setModelVar(target, key);
280
- regisHandler(target, key, {
252
+ function Init(proto, key) {
253
+ setVar(proto, key);
254
+ regisHandler(proto, key, {
281
255
  async init(instance) {
282
256
  instance[key]();
283
257
  }
@@ -285,45 +259,44 @@ function Init(target, key) {
285
259
  }
286
260
  __name(Init, "Init");
287
261
  function Bind(value) {
288
- return (target, k) => {
289
- setModelVar(target, k);
290
- setState(target, k, {
262
+ return (proto, k) => {
263
+ setVar(proto, k);
264
+ setState(proto, k, {
291
265
  value
292
266
  });
293
267
  };
294
268
  }
295
269
  __name(Bind, "Bind");
296
- function Ignore(target, key) {
297
- setIgnoreKey(target, key);
270
+ function Ignore(proto, key) {
271
+ setIgnoreKey(proto, key);
298
272
  }
299
273
  __name(Ignore, "Ignore");
300
- function Clear(target, key) {
301
- init(target);
302
- target._namespace.__INIT_EVENT__.delete(key);
303
- target._namespace.__EXPOSE_VAR__.delete(key);
304
- target._namespace.__IGNORE_VAR__.delete(key);
305
- target._namespace.__STATE_VAR__.delete(key);
306
- target._namespace.__STATE_HANDLER__.delete(key);
307
- target._namespace.__STATE_NAMESPACE__.delete(key);
274
+ function Clear(proto, key) {
275
+ init(proto);
276
+ proto._namespace.__EXPOSE_VAR__.delete(key);
277
+ proto._namespace.__IGNORE_VAR__.delete(key);
278
+ proto._namespace.__STATE_VAR__.delete(key);
279
+ proto._namespace.__STATE_HANDLER__.delete(key);
280
+ proto._namespace.__STATE_NAMESPACE__.delete(key);
308
281
  }
309
282
  __name(Clear, "Clear");
310
283
  function Err(cb) {
311
- return (target, key) => {
312
- setModelVar(target, key);
313
- regisHandler(target, key, {
284
+ return (proto, key) => {
285
+ setVar(proto, key);
286
+ regisHandler(proto, key, {
314
287
  error: cb
315
288
  });
316
289
  };
317
290
  }
318
291
  __name(Err, "Err");
319
- function Expose(target, key) {
320
- setExposeKey(target, key);
292
+ function Expose(proto, key) {
293
+ setExposeKey(proto, key);
321
294
  }
322
295
  __name(Expose, "Expose");
323
296
  function To(cb) {
324
- return (obj, key) => {
325
- setModelVar(obj, key);
326
- regisHandler(obj, key, {
297
+ return (proto, key) => {
298
+ setVar(proto, key);
299
+ regisHandler(proto, key, {
327
300
  async pipe(instance) {
328
301
  instance[key] = await cb(instance[key], instance, key);
329
302
  }
@@ -332,17 +305,17 @@ function To(cb) {
332
305
  }
333
306
  __name(To, "To");
334
307
  function Tag(tag) {
335
- return (target) => {
336
- init(target.prototype);
337
- target.prototype.__TAG__ = tag;
308
+ return (module) => {
309
+ init(module.prototype);
310
+ module.prototype.__TAG__ = tag;
338
311
  };
339
312
  }
340
313
  __name(Tag, "Tag");
341
314
  function Assign(cb) {
342
- return (target) => {
343
- init(target.prototype);
344
- setModelVar(target.prototype, "__CLASS");
345
- regisHandler(target.prototype, "__CLASS", {
315
+ return (module) => {
316
+ init(module.prototype);
317
+ setVar(module.prototype, SHARE_KEY);
318
+ regisHandler(module.prototype, SHARE_KEY, {
346
319
  init: async (instance) => {
347
320
  const value = await cb(instance);
348
321
  if (value && typeof value === "object" && !Array.isArray(value)) {
@@ -354,10 +327,10 @@ function Assign(cb) {
354
327
  };
355
328
  }
356
329
  __name(Assign, "Assign");
357
- function Global(target) {
358
- init(target.prototype);
359
- setModelVar(target.prototype, "__CLASS");
360
- regisHandler(target.prototype, "__CLASS", {
330
+ function Global(module) {
331
+ init(module.prototype);
332
+ setVar(module.prototype, SHARE_KEY);
333
+ regisHandler(module.prototype, SHARE_KEY, {
361
334
  init: async (instance) => {
362
335
  const tag = instance.__TAG__;
363
336
  if (!tag)
@@ -369,8 +342,8 @@ function Global(target) {
369
342
  });
370
343
  }
371
344
  __name(Global, "Global");
372
- function Empty(_target) {
373
- init(_target.prototype);
345
+ function Empty(module) {
346
+ init(module.prototype);
374
347
  }
375
348
  __name(Empty, "Empty");
376
349
  var DataMap = {};
@@ -387,9 +360,9 @@ function Inject(key) {
387
360
  return DataMap[key] || EmptyProxy;
388
361
  }
389
362
  __name(Inject, "Inject");
390
- function Nested(Model) {
363
+ function Nested(module) {
391
364
  return To(async (property) => {
392
- const instance = plainToClass(Model, property);
365
+ const instance = plainToClass(module, property);
393
366
  const err = await transformClass(instance);
394
367
  if (err.length > 0)
395
368
  throw new Error(err[0]);
@@ -398,7 +371,7 @@ function Nested(Model) {
398
371
  }
399
372
  __name(Nested, "Nested");
400
373
 
401
- // src/namespace.ts
374
+ // src/custom/decorator.ts
402
375
  var activeInstance = {};
403
376
  function injectProperty(key, value) {
404
377
  activeInstance[key] = value;
@@ -409,12 +382,10 @@ function getProperty(key) {
409
382
  return activeInstance[key];
410
383
  }
411
384
  __name(getProperty, "getProperty");
412
-
413
- // src/custom/decorator.ts
414
385
  function Watcher(eventName, options) {
415
- return (obj, key) => {
416
- setModelVar(obj, key);
417
- regisHandler(obj, key, {
386
+ return (proto, key) => {
387
+ setVar(proto, key);
388
+ regisHandler(proto, key, {
418
389
  init(instance) {
419
390
  getProperty("watcher")?.({
420
391
  eventName,
@@ -428,9 +399,9 @@ function Watcher(eventName, options) {
428
399
  }
429
400
  __name(Watcher, "Watcher");
430
401
  function Effect(eventName, options) {
431
- return (obj, key) => {
432
- setModelVar(obj, key);
433
- regisHandler(obj, key, {
402
+ return (proto, key) => {
403
+ setVar(proto, key);
404
+ regisHandler(proto, key, {
434
405
  init(instance) {
435
406
  instance[`$_${key}`] = instance[key];
436
407
  Object.defineProperty(instance, key, {
@@ -454,14 +425,14 @@ function Effect(eventName, options) {
454
425
  }
455
426
  __name(Effect, "Effect");
456
427
  function Storage(storeKey) {
457
- return (target, key) => {
428
+ return (proto, key) => {
458
429
  let tag;
459
430
  if (key) {
460
- init(target);
461
- tag = storeKey || target.__TAG__;
431
+ init(proto);
432
+ tag = storeKey || proto.__TAG__;
462
433
  const uniTag = Symbol(tag);
463
- setModelVar(target, uniTag);
464
- regisHandler(target, uniTag, {
434
+ setVar(proto, uniTag);
435
+ regisHandler(proto, uniTag, {
465
436
  init: (instance) => {
466
437
  getProperty("storage")?.({
467
438
  instance,
@@ -471,11 +442,11 @@ function Storage(storeKey) {
471
442
  }
472
443
  });
473
444
  } else {
474
- init(target.prototype);
475
- tag = storeKey || `${target.prototype.__TAG__}_${key}`;
445
+ init(proto.prototype);
446
+ tag = storeKey || `${proto.prototype.__TAG__}_${key}`;
476
447
  const uniTag = Symbol(tag);
477
- setModelVar(target.prototype, uniTag);
478
- regisHandler(target.prototype, uniTag, {
448
+ setVar(proto.prototype, uniTag);
449
+ regisHandler(proto.prototype, uniTag, {
479
450
  init: (instance) => {
480
451
  getProperty("storage")?.({
481
452
  instance,
@@ -504,6 +475,7 @@ export {
504
475
  Nested,
505
476
  Pipeline,
506
477
  Provide,
478
+ SHARE_KEY,
507
479
  Storage,
508
480
  Tag,
509
481
  To,
@@ -514,13 +486,11 @@ export {
514
486
  getBind,
515
487
  getExposeKey,
516
488
  getHandler,
517
- getInitEvent,
518
- getModelState,
489
+ getModuleState,
519
490
  getOwnExposeKey,
520
491
  getOwnHandler,
521
492
  getOwnIgnoreKey,
522
- getOwnInitEvent,
523
- getOwnModelState,
493
+ getOwnModuleState,
524
494
  getOwnState,
525
495
  getProperty,
526
496
  getState,
@@ -531,13 +501,12 @@ export {
531
501
  isPhecda,
532
502
  plainToClass,
533
503
  regisHandler,
534
- regisInitEvent,
535
504
  register,
536
505
  registerAsync,
537
506
  setExposeKey,
538
507
  setIgnoreKey,
539
- setModelVar,
540
508
  setState,
509
+ setVar,
541
510
  snapShot,
542
511
  transformClass
543
512
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phecda-core",
3
- "version": "2.1.2-alpha.0",
3
+ "version": "3.0.0-alpha.2",
4
4
  "description": "provide base function and abstract limit to other phecda module ",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",