phecda-core 1.5.0 → 1.6.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
@@ -5,6 +5,9 @@ interface UsePipeOptions {
5
5
  transform?: boolean;
6
6
  collectError?: boolean;
7
7
  }
8
+ interface PhecdaInjectData {
9
+ [key: string]: any;
10
+ }
8
11
  interface PhecdaHandler {
9
12
  [key: string]: any;
10
13
  }
@@ -82,6 +85,10 @@ declare function Pipe(v: ReturnType<typeof to>): (obj: any, key: PropertyKey) =>
82
85
  declare function Tag(tag: string): (target: any) => void;
83
86
  declare function Assign(cb: (instance?: any) => any): (target: any) => void;
84
87
  declare function Global(target: any): void;
88
+ declare function Empty(_target: any): void;
89
+ declare const DataMap: PhecdaInjectData;
90
+ declare function Provide<K extends keyof PhecdaInjectData>(key: K, value: PhecdaInjectData[K]): void;
91
+ declare function Inject<K extends keyof PhecdaInjectData>(key: K): PhecdaInjectData[K];
85
92
 
86
93
  declare function validate(p: RegExp | string | Function | Object | Number, v: any): Promise<any>;
87
94
  declare function getTag<M extends new (...args: any) => any>(Model: M): any;
@@ -113,4 +120,4 @@ declare function Watcher(eventName: keyof Events, options?: {
113
120
  }): (obj: any, key: string) => void;
114
121
  declare function Storage(storeKey?: string): (target: any, key?: PropertyKey) => void;
115
122
 
116
- export { Assign, Bind, ClassValue, Clear, Err, Events, Expose, Global, Ignore, Init, NameSpace, Phecda, PhecdaHandler, Pipe, Rule, Storage, Tag, UsePipeOptions, Watcher, activeInstance, addDecoToClass, classToValue, getBind, getExposeKey, getHandler, getIgnoreKey, getInitEvent, getModelState, getProperty, getState, getTag, init, injectProperty, isPhecda, mergeOptions, mergeState, plainToClass, regisHandler, regisInitEvent, register, registerAsync, setExposeKey, setIgnoreKey, setModalVar, snapShot, to, validate };
123
+ export { Assign, Bind, ClassValue, Clear, DataMap, Empty, Err, Events, Expose, Global, Ignore, Init, Inject, NameSpace, Phecda, PhecdaHandler, PhecdaInjectData, Pipe, Provide, Rule, Storage, Tag, UsePipeOptions, Watcher, activeInstance, addDecoToClass, classToValue, getBind, getExposeKey, getHandler, getIgnoreKey, getInitEvent, getModelState, getProperty, getState, getTag, init, injectProperty, isPhecda, mergeOptions, mergeState, plainToClass, regisHandler, regisInitEvent, register, registerAsync, setExposeKey, setIgnoreKey, setModalVar, snapShot, to, validate };
@@ -25,12 +25,16 @@ var Phecda = (() => {
25
25
  Assign: () => Assign,
26
26
  Bind: () => Bind,
27
27
  Clear: () => Clear,
28
+ DataMap: () => DataMap,
29
+ Empty: () => Empty,
28
30
  Err: () => Err,
29
31
  Expose: () => Expose,
30
32
  Global: () => Global,
31
33
  Ignore: () => Ignore,
32
34
  Init: () => Init,
35
+ Inject: () => Inject,
33
36
  Pipe: () => Pipe,
37
+ Provide: () => Provide,
34
38
  Rule: () => Rule,
35
39
  Storage: () => Storage,
36
40
  Tag: () => Tag,
@@ -318,6 +322,18 @@ var Phecda = (() => {
318
322
  globalThis.__PHECDA__[tag] = target;
319
323
  }
320
324
  __name(Global, "Global");
325
+ function Empty(_target) {
326
+ }
327
+ __name(Empty, "Empty");
328
+ var DataMap = {};
329
+ function Provide(key, value) {
330
+ DataMap[key] = value;
331
+ }
332
+ __name(Provide, "Provide");
333
+ function Inject(key) {
334
+ return DataMap[key] || (() => Empty);
335
+ }
336
+ __name(Inject, "Inject");
321
337
 
322
338
  // src/helper.ts
323
339
  function getBind(Model) {
package/dist/index.js CHANGED
@@ -24,12 +24,16 @@ __export(src_exports, {
24
24
  Assign: () => Assign,
25
25
  Bind: () => Bind,
26
26
  Clear: () => Clear,
27
+ DataMap: () => DataMap,
28
+ Empty: () => Empty,
27
29
  Err: () => Err,
28
30
  Expose: () => Expose,
29
31
  Global: () => Global,
30
32
  Ignore: () => Ignore,
31
33
  Init: () => Init,
34
+ Inject: () => Inject,
32
35
  Pipe: () => Pipe,
36
+ Provide: () => Provide,
33
37
  Rule: () => Rule,
34
38
  Storage: () => Storage,
35
39
  Tag: () => Tag,
@@ -318,6 +322,18 @@ function Global(target) {
318
322
  globalThis.__PHECDA__[tag] = target;
319
323
  }
320
324
  __name(Global, "Global");
325
+ function Empty(_target) {
326
+ }
327
+ __name(Empty, "Empty");
328
+ var DataMap = {};
329
+ function Provide(key, value) {
330
+ DataMap[key] = value;
331
+ }
332
+ __name(Provide, "Provide");
333
+ function Inject(key) {
334
+ return DataMap[key] || (() => Empty);
335
+ }
336
+ __name(Inject, "Inject");
321
337
 
322
338
  // src/helper.ts
323
339
  function getBind(Model) {
@@ -475,12 +491,16 @@ __name(Storage, "Storage");
475
491
  Assign,
476
492
  Bind,
477
493
  Clear,
494
+ DataMap,
495
+ Empty,
478
496
  Err,
479
497
  Expose,
480
498
  Global,
481
499
  Ignore,
482
500
  Init,
501
+ Inject,
483
502
  Pipe,
503
+ Provide,
484
504
  Rule,
485
505
  Storage,
486
506
  Tag,
package/dist/index.mjs CHANGED
@@ -254,6 +254,18 @@ function Global(target) {
254
254
  globalThis.__PHECDA__[tag] = target;
255
255
  }
256
256
  __name(Global, "Global");
257
+ function Empty(_target) {
258
+ }
259
+ __name(Empty, "Empty");
260
+ var DataMap = {};
261
+ function Provide(key, value) {
262
+ DataMap[key] = value;
263
+ }
264
+ __name(Provide, "Provide");
265
+ function Inject(key) {
266
+ return DataMap[key] || (() => Empty);
267
+ }
268
+ __name(Inject, "Inject");
257
269
 
258
270
  // src/helper.ts
259
271
  function getBind(Model) {
@@ -410,12 +422,16 @@ export {
410
422
  Assign,
411
423
  Bind,
412
424
  Clear,
425
+ DataMap,
426
+ Empty,
413
427
  Err,
414
428
  Expose,
415
429
  Global,
416
430
  Ignore,
417
431
  Init,
432
+ Inject,
418
433
  Pipe,
434
+ Provide,
419
435
  Rule,
420
436
  Storage,
421
437
  Tag,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phecda-core",
3
- "version": "1.5.0",
3
+ "version": "1.6.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",