phecda-core 1.3.1 → 1.4.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/dist/index.d.ts CHANGED
@@ -78,6 +78,7 @@ declare function Err<Fn extends (...args: any) => any>(cb: Fn): (target: any, ke
78
78
  declare function P(target: any, key: PropertyKey): void;
79
79
  declare function Pipe(v: ReturnType<typeof to>): (obj: any, key: PropertyKey) => void;
80
80
  declare function Tag(tag: string): (target: any) => void;
81
+ declare function Assign(cb: (instance?: any) => any): (target: any) => void;
81
82
  declare function Global(target: any): void;
82
83
 
83
84
  declare function validate(p: RegExp | string | Function | Object | Number, v: any): Promise<any>;
@@ -110,4 +111,4 @@ declare function Watcher(eventName: keyof Events, options?: {
110
111
  }): (obj: any, key: string) => void;
111
112
  declare function Storage(storeKey?: string): (target: any, key?: PropertyKey) => void;
112
113
 
113
- export { ClassValue, Clear, Err, Events, Global, Ignore, Init, NameSpace, P, Phecda, PhecdaHandler, Pipe, Rule, Storage, Tag, UsePipeOptions, Watcher, activeInstance, addDecoToClass, classToValue, getExposeKey, getHandler, getIgnoreKey, getInitEvent, getModelState, getProperty, getState, getTag, init, injectProperty, isPhecda, mergeOptions, mergeState, plainToClass, regisHandler, regisInitEvent, register, registerAsync, setExposeKey, setIgnoreKey, setModalVar, snapShot, to, validate };
114
+ export { Assign, ClassValue, Clear, Err, Events, Global, Ignore, Init, NameSpace, P, Phecda, PhecdaHandler, Pipe, Rule, Storage, Tag, UsePipeOptions, Watcher, activeInstance, addDecoToClass, classToValue, getExposeKey, getHandler, getIgnoreKey, getInitEvent, getModelState, getProperty, getState, getTag, init, injectProperty, isPhecda, mergeOptions, mergeState, plainToClass, regisHandler, regisInitEvent, register, registerAsync, setExposeKey, setIgnoreKey, setModalVar, snapShot, to, validate };
@@ -22,6 +22,7 @@ var Phecda = (() => {
22
22
  // src/index.ts
23
23
  var src_exports = {};
24
24
  __export(src_exports, {
25
+ Assign: () => Assign,
25
26
  Clear: () => Clear,
26
27
  Err: () => Err,
27
28
  Global: () => Global,
@@ -282,6 +283,22 @@ var Phecda = (() => {
282
283
  };
283
284
  }
284
285
  __name(Tag, "Tag");
286
+ function Assign(cb) {
287
+ return (target) => {
288
+ init(target.prototype);
289
+ setModalVar(target.prototype, "__CLASS");
290
+ regisHandler(target.prototype, "__CLASS", {
291
+ init: async (instance) => {
292
+ const value = await cb(instance);
293
+ if (value && typeof value === "object" && !Array.isArray(value)) {
294
+ for (const i in value)
295
+ instance[i] = value[i];
296
+ }
297
+ }
298
+ });
299
+ };
300
+ }
301
+ __name(Assign, "Assign");
285
302
  function Global(target) {
286
303
  if (!globalThis.__PHECDA__)
287
304
  globalThis.__PHECDA__ = {};
package/dist/index.js CHANGED
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  // src/index.ts
22
22
  var src_exports = {};
23
23
  __export(src_exports, {
24
+ Assign: () => Assign,
24
25
  Clear: () => Clear,
25
26
  Err: () => Err,
26
27
  Global: () => Global,
@@ -282,6 +283,22 @@ function Tag(tag) {
282
283
  };
283
284
  }
284
285
  __name(Tag, "Tag");
286
+ function Assign(cb) {
287
+ return (target) => {
288
+ init(target.prototype);
289
+ setModalVar(target.prototype, "__CLASS");
290
+ regisHandler(target.prototype, "__CLASS", {
291
+ init: async (instance) => {
292
+ const value = await cb(instance);
293
+ if (value && typeof value === "object" && !Array.isArray(value)) {
294
+ for (const i in value)
295
+ instance[i] = value[i];
296
+ }
297
+ }
298
+ });
299
+ };
300
+ }
301
+ __name(Assign, "Assign");
285
302
  function Global(target) {
286
303
  if (!globalThis.__PHECDA__)
287
304
  globalThis.__PHECDA__ = {};
@@ -432,6 +449,7 @@ function Storage(storeKey) {
432
449
  __name(Storage, "Storage");
433
450
  // Annotate the CommonJS export names for ESM import in node:
434
451
  0 && (module.exports = {
452
+ Assign,
435
453
  Clear,
436
454
  Err,
437
455
  Global,
package/dist/index.mjs CHANGED
@@ -221,6 +221,22 @@ function Tag(tag) {
221
221
  };
222
222
  }
223
223
  __name(Tag, "Tag");
224
+ function Assign(cb) {
225
+ return (target) => {
226
+ init(target.prototype);
227
+ setModalVar(target.prototype, "__CLASS");
228
+ regisHandler(target.prototype, "__CLASS", {
229
+ init: async (instance) => {
230
+ const value = await cb(instance);
231
+ if (value && typeof value === "object" && !Array.isArray(value)) {
232
+ for (const i in value)
233
+ instance[i] = value[i];
234
+ }
235
+ }
236
+ });
237
+ };
238
+ }
239
+ __name(Assign, "Assign");
224
240
  function Global(target) {
225
241
  if (!globalThis.__PHECDA__)
226
242
  globalThis.__PHECDA__ = {};
@@ -370,6 +386,7 @@ function Storage(storeKey) {
370
386
  }
371
387
  __name(Storage, "Storage");
372
388
  export {
389
+ Assign,
373
390
  Clear,
374
391
  Err,
375
392
  Global,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phecda-core",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
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",