react-obsidian 2.20.1 → 2.21.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.
Files changed (122) hide show
  1. package/babel.config.legacy.js +13 -0
  2. package/dist/src/decorators/Graph.d.ts +2 -2
  3. package/dist/src/decorators/Graph.d.ts.map +1 -1
  4. package/dist/src/decorators/Graph.js +3 -3
  5. package/dist/src/decorators/Graph.js.map +1 -1
  6. package/dist/src/decorators/inject/Inject.d.ts +1 -1
  7. package/dist/src/decorators/inject/Inject.d.ts.map +1 -1
  8. package/dist/src/decorators/inject/Inject.js +7 -7
  9. package/dist/src/decorators/inject/Inject.js.map +1 -1
  10. package/dist/src/decorators/inject/inject.legacy.d.ts +2 -0
  11. package/dist/src/decorators/inject/inject.legacy.d.ts.map +1 -0
  12. package/dist/src/decorators/inject/inject.legacy.js +12 -0
  13. package/dist/src/decorators/inject/inject.legacy.js.map +1 -0
  14. package/dist/src/decorators/inject/inject.modern.d.ts +5 -0
  15. package/dist/src/decorators/inject/inject.modern.d.ts.map +1 -0
  16. package/dist/src/decorators/inject/{LateInject.js → inject.modern.js} +6 -6
  17. package/dist/src/decorators/inject/inject.modern.js.map +1 -0
  18. package/dist/src/decorators/injectable/Injectable.d.ts.map +1 -0
  19. package/dist/src/decorators/injectable/Injectable.js.map +1 -0
  20. package/dist/src/decorators/lateInject/LateInject.d.ts.map +1 -0
  21. package/dist/src/decorators/lateInject/LateInject.js +14 -0
  22. package/dist/src/decorators/lateInject/LateInject.js.map +1 -0
  23. package/dist/src/decorators/lateInject/lateInject.legacy.d.ts +2 -0
  24. package/dist/src/decorators/lateInject/lateInject.legacy.d.ts.map +1 -0
  25. package/dist/src/decorators/lateInject/lateInject.legacy.js +12 -0
  26. package/dist/src/decorators/lateInject/lateInject.legacy.js.map +1 -0
  27. package/dist/src/decorators/lateInject/lateInject.modern.d.ts +5 -0
  28. package/dist/src/decorators/lateInject/lateInject.modern.d.ts.map +1 -0
  29. package/dist/src/decorators/lateInject/lateInject.modern.js +14 -0
  30. package/dist/src/decorators/lateInject/lateInject.modern.js.map +1 -0
  31. package/dist/src/decorators/provides/Provides.d.ts +1 -2
  32. package/dist/src/decorators/provides/Provides.d.ts.map +1 -1
  33. package/dist/src/decorators/provides/Provides.js +7 -8
  34. package/dist/src/decorators/provides/Provides.js.map +1 -1
  35. package/dist/src/decorators/provides/provides.legacy.d.ts +3 -0
  36. package/dist/src/decorators/provides/provides.legacy.d.ts.map +1 -0
  37. package/dist/src/decorators/provides/provides.legacy.js +13 -0
  38. package/dist/src/decorators/provides/provides.legacy.js.map +1 -0
  39. package/dist/src/decorators/provides/provides.modern.d.ts +2 -0
  40. package/dist/src/decorators/provides/provides.modern.d.ts.map +1 -0
  41. package/dist/src/decorators/provides/provides.modern.js +34 -0
  42. package/dist/src/decorators/provides/provides.modern.js.map +1 -0
  43. package/dist/src/decorators/singleton/Singleton.d.ts +2 -0
  44. package/dist/src/decorators/singleton/Singleton.d.ts.map +1 -0
  45. package/dist/src/decorators/singleton/Singleton.js +14 -0
  46. package/dist/src/decorators/singleton/Singleton.js.map +1 -0
  47. package/dist/src/decorators/singleton/singleton.legacy.d.ts +4 -0
  48. package/dist/src/decorators/singleton/singleton.legacy.d.ts.map +1 -0
  49. package/dist/src/decorators/singleton/singleton.legacy.js +10 -0
  50. package/dist/src/decorators/singleton/singleton.legacy.js.map +1 -0
  51. package/dist/src/decorators/singleton/singleton.modern.d.ts +2 -0
  52. package/dist/src/decorators/singleton/singleton.modern.d.ts.map +1 -0
  53. package/dist/src/decorators/singleton/singleton.modern.js +9 -0
  54. package/dist/src/decorators/singleton/singleton.modern.js.map +1 -0
  55. package/dist/src/index.d.ts +6 -6
  56. package/dist/src/index.d.ts.map +1 -1
  57. package/dist/src/index.js +6 -6
  58. package/dist/src/index.js.map +1 -1
  59. package/dist/src/utils/decorators.d.ts +2 -0
  60. package/dist/src/utils/decorators.d.ts.map +1 -0
  61. package/dist/src/utils/decorators.js +7 -0
  62. package/dist/src/utils/decorators.js.map +1 -0
  63. package/dist/test/fixtures/CircularDependencyFromSubgraph.js +66 -21
  64. package/dist/test/fixtures/CircularDependencyFromSubgraph.js.map +1 -1
  65. package/dist/test/fixtures/CircularDependencyGraph.js +66 -21
  66. package/dist/test/fixtures/CircularDependencyGraph.js.map +1 -1
  67. package/dist/test/fixtures/CircularDependencyGraph2.js +78 -39
  68. package/dist/test/fixtures/CircularDependencyGraph2.js.map +1 -1
  69. package/dist/test/fixtures/GraphWithMultipleDependencies.js +84 -48
  70. package/dist/test/fixtures/GraphWithMultipleDependencies.js.map +1 -1
  71. package/dist/test/fixtures/GraphWithOnBind.js +69 -24
  72. package/dist/test/fixtures/GraphWithOnBind.js.map +1 -1
  73. package/dist/test/fixtures/LifecycleBoundGraph.js +79 -41
  74. package/dist/test/fixtures/LifecycleBoundGraph.js.map +1 -1
  75. package/dist/test/fixtures/LifecycleBoundWithLifecycleBoundSubgraph.js +66 -22
  76. package/dist/test/fixtures/LifecycleBoundWithLifecycleBoundSubgraph.js.map +1 -1
  77. package/dist/test/fixtures/MainGraph.js +72 -31
  78. package/dist/test/fixtures/MainGraph.js.map +1 -1
  79. package/dist/test/fixtures/ScopedLifecycleBoundGraph.js +56 -11
  80. package/dist/test/fixtures/ScopedLifecycleBoundGraph.js.map +1 -1
  81. package/dist/test/fixtures/SingletonGraph.js +67 -27
  82. package/dist/test/fixtures/SingletonGraph.js.map +1 -1
  83. package/dist/test/fixtures/Subgraph.js +84 -48
  84. package/dist/test/fixtures/Subgraph.js.map +1 -1
  85. package/dist/test/fixtures/SubgraphWithCircularDependency.js +72 -31
  86. package/dist/test/fixtures/SubgraphWithCircularDependency.js.map +1 -1
  87. package/dist/test/fixtures/ThrowingMainGraph.js +66 -21
  88. package/dist/test/fixtures/ThrowingMainGraph.js.map +1 -1
  89. package/dist/test/fixtures/UniqueNumberGraph.js +73 -37
  90. package/dist/test/fixtures/UniqueNumberGraph.js.map +1 -1
  91. package/jest.config.legacy.js +26 -0
  92. package/package.json +21 -17
  93. package/src/decorators/Graph.ts +5 -5
  94. package/src/decorators/inject/Inject.ts +7 -8
  95. package/src/decorators/inject/inject.legacy.ts +11 -0
  96. package/src/decorators/inject/inject.modern.ts +12 -0
  97. package/src/decorators/lateInject/LateInject.ts +11 -0
  98. package/src/decorators/lateInject/lateInject.legacy.ts +11 -0
  99. package/src/decorators/lateInject/lateInject.modern.ts +12 -0
  100. package/src/decorators/provides/Provides.ts +8 -7
  101. package/src/decorators/provides/provides.legacy.ts +13 -0
  102. package/src/decorators/provides/provides.modern.ts +36 -0
  103. package/src/decorators/singleton/Singleton.ts +11 -0
  104. package/src/decorators/singleton/singleton.legacy.ts +13 -0
  105. package/src/decorators/singleton/singleton.modern.ts +8 -0
  106. package/src/index.ts +6 -6
  107. package/src/utils/decorators.ts +3 -0
  108. package/wallaby.legacy.js +9 -0
  109. package/dist/src/decorators/Singleton.d.ts +0 -4
  110. package/dist/src/decorators/Singleton.d.ts.map +0 -1
  111. package/dist/src/decorators/Singleton.js +0 -12
  112. package/dist/src/decorators/Singleton.js.map +0 -1
  113. package/dist/src/decorators/inject/Injectable.d.ts.map +0 -1
  114. package/dist/src/decorators/inject/Injectable.js.map +0 -1
  115. package/dist/src/decorators/inject/LateInject.d.ts.map +0 -1
  116. package/dist/src/decorators/inject/LateInject.js.map +0 -1
  117. package/src/decorators/Singleton.ts +0 -15
  118. package/src/decorators/inject/LateInject.ts +0 -8
  119. /package/dist/src/decorators/{inject → injectable}/Injectable.d.ts +0 -0
  120. /package/dist/src/decorators/{inject → injectable}/Injectable.js +0 -0
  121. /package/dist/src/decorators/{inject → lateInject}/LateInject.d.ts +0 -0
  122. /package/src/decorators/{inject → injectable}/Injectable.ts +0 -0
@@ -1,12 +1,11 @@
1
- import InjectionMetadata from '../../injectors/class/InjectionMetadata';
1
+ import { shouldUseModernDecorator } from '../../utils/decorators';
2
+ import { legacyDecorator } from './inject.legacy';
3
+ import { modernDecorator } from './inject.modern';
2
4
 
3
5
  export function inject(name?: string) {
4
- return (
5
- target: Object | any,
6
- _propertyKey?: string,
7
- _indexOrPropertyDescriptor?: number | PropertyDescriptor,
8
- ) => {
9
- const metadata = new InjectionMetadata();
10
- metadata.savePropertyMetadata(target.constructor, name!);
6
+ return (...args: any[]) => {
7
+ return shouldUseModernDecorator(args) ?
8
+ modernDecorator(name, args[0], args[1]) :
9
+ legacyDecorator(name, args[0], args[1], args[2]);
11
10
  };
12
11
  }
@@ -0,0 +1,11 @@
1
+ import InjectionMetadata from '../../injectors/class/InjectionMetadata';
2
+
3
+ export function legacyDecorator(
4
+ name: string | undefined,
5
+ target: Object | any,
6
+ propertyKey: string,
7
+ _indexOrPropertyDescriptor?: number | PropertyDescriptor,
8
+ ) {
9
+ const metadata = new InjectionMetadata();
10
+ metadata.savePropertyMetadata(target.constructor, name ?? propertyKey);
11
+ }
@@ -0,0 +1,12 @@
1
+ import InjectionMetadata from '../../injectors/class/InjectionMetadata';
2
+
3
+ export function modernDecorator<This, Args extends any[], Return>(
4
+ name: string | undefined,
5
+ _target: (this: This, ...args: Args) => Return,
6
+ context: { name: string | symbol; addInitializer: (callback: () => void) => void },
7
+ ) {
8
+ context.addInitializer(function initializer(this: any) {
9
+ const metadata = new InjectionMetadata();
10
+ metadata.savePropertyMetadata(this.constructor, name!);
11
+ });
12
+ }
@@ -0,0 +1,11 @@
1
+ import { shouldUseModernDecorator } from '../../utils/decorators';
2
+ import { legacyDecorator } from './lateInject.legacy';
3
+ import { modernDecorator } from './lateInject.modern';
4
+
5
+ export function lateInject(name?: string): any {
6
+ return (...args: any[]) => {
7
+ return shouldUseModernDecorator(args) ?
8
+ modernDecorator(name, args[0], args[1]) :
9
+ legacyDecorator(name, args[0], args[1], args[2]);
10
+ };
11
+ }
@@ -0,0 +1,11 @@
1
+ import InjectionMetadata from '../../injectors/class/InjectionMetadata';
2
+
3
+ export function legacyDecorator(
4
+ name: string | undefined,
5
+ target: Object | any,
6
+ propertyKey: string,
7
+ _indexOrPropertyDescriptor?: number | PropertyDescriptor,
8
+ ) {
9
+ const metadata = new InjectionMetadata();
10
+ metadata.saveLatePropertyMetadata(target.constructor, name ?? propertyKey);
11
+ }
@@ -0,0 +1,12 @@
1
+ import InjectionMetadata from '../../injectors/class/InjectionMetadata';
2
+
3
+ export function modernDecorator<This, Args extends any[], Return>(
4
+ name: string | undefined,
5
+ _target: (this: This, ...args: Args) => Return,
6
+ context: { name: string | symbol; addInitializer: (callback: () => void) => void },
7
+ ) {
8
+ context.addInitializer(function initializer(this: any) {
9
+ const metadata = new InjectionMetadata();
10
+ metadata.saveLatePropertyMetadata(this.constructor, name ?? String(context.name));
11
+ });
12
+ }
@@ -1,14 +1,15 @@
1
- import { Graph } from '../../graph/Graph';
2
- import providedPropertiesStore from '../../ProvidedPropertiesStore';
3
- import { memoizeDescriptor } from './MemoizeDescriptor';
1
+ import { shouldUseModernDecorator } from '../../utils/decorators';
2
+ import { legacyDecorator } from './provides.legacy';
3
+ import { modernDecorator } from './provides.modern';
4
4
 
5
5
  interface ProvidesParams {
6
6
  name: string;
7
7
  }
8
8
 
9
- export function provides({ name }: Partial<ProvidesParams> = {}) {
10
- return (graph: Graph, propertyKey: string, descriptor: PropertyDescriptor) => {
11
- providedPropertiesStore.set(graph, propertyKey, name!);
12
- return memoizeDescriptor(propertyKey, descriptor);
9
+ export function provides({ name }: Partial<ProvidesParams> = {}): any {
10
+ return (...args: any[]) => {
11
+ return shouldUseModernDecorator(args)
12
+ ? modernDecorator(name, args[0], args[1])
13
+ : legacyDecorator(name, args[0], args[1], args[2]);
13
14
  };
14
15
  }
@@ -0,0 +1,13 @@
1
+ import { Graph } from '../../graph/Graph';
2
+ import providedPropertiesStore from '../../ProvidedPropertiesStore';
3
+ import { memoizeDescriptor } from './MemoizeDescriptor';
4
+
5
+ export function legacyDecorator(
6
+ name: string | undefined,
7
+ graph: Graph,
8
+ propertyKey: string,
9
+ descriptor: PropertyDescriptor,
10
+ ) {
11
+ providedPropertiesStore.set(graph, propertyKey, name!);
12
+ return memoizeDescriptor(propertyKey, descriptor);
13
+ }
@@ -0,0 +1,36 @@
1
+ import { Graph } from '../../graph/Graph';
2
+ import providedPropertiesStore from '../../ProvidedPropertiesStore';
3
+ import { Reflect } from '../../utils/reflect';
4
+
5
+ export function modernDecorator<This, Args extends any[], Return>(
6
+ name: string | undefined,
7
+ target: (this: This, ...args: Args) => Return,
8
+ context: ClassMethodDecoratorContext<This, (this: This, ...args: Args) => Return>,
9
+ ) {
10
+ context.addInitializer(function initializer(this: This) {
11
+ const mangledProperty = String(context.name);
12
+ // @ts-ignore
13
+ this[mangledProperty] = this[mangledProperty].bind(this);
14
+ providedPropertiesStore.set(this as Graph, mangledProperty, name!);
15
+ });
16
+
17
+ function getMemoizationTarget(zis: This) {
18
+ if (Reflect.getMetadata('isSingleton', target)) {
19
+ return (zis as any).constructor;
20
+ }
21
+ return zis;
22
+ }
23
+
24
+ function replacementMethod(this: This, ...args: Args): Return {
25
+ const memoizationTarget = getMemoizationTarget(this);
26
+ const memoizedResult = Reflect.getMetadata(`memoized${name!}`, memoizationTarget);
27
+ if (memoizedResult === undefined) {
28
+ const result = target.call(this, ...args);
29
+ Reflect.defineMetadata(`memoized${name!}`, result, memoizationTarget);
30
+ return result;
31
+ }
32
+ return memoizedResult;
33
+ }
34
+
35
+ return replacementMethod;
36
+ }
@@ -0,0 +1,11 @@
1
+ import { modernDecorator } from './singleton.modern';
2
+ import { legacyDecorator } from './singleton.legacy';
3
+ import { shouldUseModernDecorator } from '../../utils/decorators';
4
+
5
+ export function singleton() {
6
+ return (...args: any[]) => {
7
+ return shouldUseModernDecorator(args) ?
8
+ modernDecorator(args[0]) :
9
+ legacyDecorator(args[0], args[1], args[2]);
10
+ };
11
+ }
@@ -0,0 +1,13 @@
1
+ import { Constructable } from '../../types';
2
+ import { ObjectGraph } from '../../graph/ObjectGraph';
3
+ import {Reflect} from '../../utils/reflect';
4
+
5
+ export function legacyDecorator(
6
+ constructorOrGraph: Constructable<ObjectGraph> | ObjectGraph,
7
+ _property?: string,
8
+ descriptor?: PropertyDescriptor,
9
+ ): any {
10
+ const target = descriptor || constructorOrGraph;
11
+ Reflect.defineMetadata('isSingleton', true, target);
12
+ return target;
13
+ }
@@ -0,0 +1,8 @@
1
+ import {Reflect} from '../../utils/reflect';
2
+
3
+ export function modernDecorator<This, Args extends any[], Return>(
4
+ target: (this: This, ...args: Args) => Return,
5
+ ): any {
6
+ Reflect.defineMetadata('isSingleton', true, target);
7
+ return target;
8
+ }
package/src/index.ts CHANGED
@@ -1,22 +1,22 @@
1
1
  import { graph } from './decorators/Graph';
2
2
  import { inject } from './decorators/inject/Inject';
3
- import { injectable } from './decorators/inject/Injectable';
4
- import { lateInject } from './decorators/inject/LateInject';
3
+ import { injectable } from './decorators/injectable/Injectable';
4
+ import { lateInject } from './decorators/lateInject/LateInject';
5
5
  import { lifecycleBound } from './decorators/LifecycleBound';
6
6
  import { provides } from './decorators/provides/Provides';
7
- import { singleton } from './decorators/Singleton';
7
+ import { singleton } from './decorators/singleton/Singleton';
8
8
  import _Obsidian from './Obsidian';
9
9
 
10
10
  export * from './types';
11
11
 
12
12
  export { graph } from './decorators/Graph';
13
- export { singleton } from './decorators/Singleton';
13
+ export { singleton } from './decorators/singleton/Singleton';
14
14
  export { ObjectGraph } from './graph/ObjectGraph';
15
15
  export { Graph as IGraph } from './graph/Graph';
16
16
  export { provides } from './decorators/provides/Provides';
17
- export { injectable } from './decorators/inject/Injectable';
17
+ export { injectable } from './decorators/injectable/Injectable';
18
18
  export { inject } from './decorators/inject/Inject';
19
- export { lateInject } from './decorators/inject/LateInject';
19
+ export { lateInject } from './decorators/lateInject/LateInject';
20
20
  export { lifecycleBound } from './decorators/LifecycleBound';
21
21
  export { GraphMiddleware } from './graph/registry/GraphMiddleware';
22
22
  export { GraphResolveChain as ResolveChain } from './graph/registry/GraphResolveChain';
@@ -0,0 +1,3 @@
1
+ export function shouldUseModernDecorator(args: any[]) {
2
+ return args.length === 2 && typeof args[1] === 'object' && 'addInitializer' in args[1];
3
+ }
@@ -0,0 +1,9 @@
1
+ module.exports = () => {
2
+ return {
3
+ autoDetect: true,
4
+ testFramework: {
5
+ configFile: 'jest.config.legacy.js',
6
+ },
7
+ env: {params: {env: 'NODE_OPTIONS="--max_old_space_size=4096"'}},
8
+ };
9
+ };
@@ -1,4 +0,0 @@
1
- import { Constructable } from '../types';
2
- import { ObjectGraph } from '../graph/ObjectGraph';
3
- export declare function singleton(): (constructorOrGraph: Constructable<ObjectGraph> | ObjectGraph, _property?: string, descriptor?: PropertyDescriptor) => any;
4
- //# sourceMappingURL=Singleton.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Singleton.d.ts","sourceRoot":"","sources":["../../../src/decorators/Singleton.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGnD,wBAAgB,SAAS,yBAED,aAAa,CAAC,WAAW,CAAC,GAAG,WAAW,cAChD,MAAM,eACL,kBAAkB,KAC9B,GAAG,CAKP"}
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.singleton = singleton;
4
- const reflect_1 = require("../utils/reflect");
5
- function singleton() {
6
- return (constructorOrGraph, _property, descriptor) => {
7
- const target = descriptor || constructorOrGraph;
8
- reflect_1.Reflect.defineMetadata('isSingleton', true, target);
9
- return target;
10
- };
11
- }
12
- //# sourceMappingURL=Singleton.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Singleton.js","sourceRoot":"","sources":["../../../src/decorators/Singleton.ts"],"names":[],"mappings":";;AAIA,8BAUC;AAZD,8CAAyC;AAEzC,SAAgB,SAAS;IACvB,OAAO,CACL,kBAA4D,EAC5D,SAAkB,EAClB,UAA+B,EAC1B,EAAE;QACP,MAAM,MAAM,GAAG,UAAU,IAAI,kBAAkB,CAAC;QAChD,iBAAO,CAAC,cAAc,CAAC,aAAa,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QACpD,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Injectable.d.ts","sourceRoot":"","sources":["../../../../src/decorators/inject/Injectable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAI1C,wBAAgB,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,GAAG,GAAG,CAEzE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Injectable.js","sourceRoot":"","sources":["../../../../src/decorators/inject/Injectable.ts"],"names":[],"mappings":";;;;;AAKA,gCAEC;AALD,uFAA+D;AAC/D,wFAAgE;AAEhE,SAAgB,UAAU,CAAC,UAAyC;IAClE,OAAO,IAAI,uBAAa,CAAC,uBAAa,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;AAC7D,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"LateInject.d.ts","sourceRoot":"","sources":["../../../../src/decorators/inject/LateInject.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,GAAG,CAK7C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"LateInject.js","sourceRoot":"","sources":["../../../../src/decorators/inject/LateInject.ts"],"names":[],"mappings":";;;;;AAEA,gCAKC;AAPD,gGAAwE;AAExE,SAAgB,UAAU,CAAC,IAAa;IACtC,OAAO,CAAC,MAAc,EAAE,EAAE;QACxB,MAAM,QAAQ,GAAG,IAAI,2BAAiB,EAAE,CAAC;QACzC,QAAQ,CAAC,wBAAwB,CAAC,MAAM,CAAC,WAAW,EAAE,IAAK,CAAC,CAAC;IAC/D,CAAC,CAAC;AACJ,CAAC"}
@@ -1,15 +0,0 @@
1
- import { Constructable } from '../types';
2
- import { ObjectGraph } from '../graph/ObjectGraph';
3
- import {Reflect} from '../utils/reflect';
4
-
5
- export function singleton() {
6
- return (
7
- constructorOrGraph: Constructable<ObjectGraph> | ObjectGraph,
8
- _property?: string,
9
- descriptor?: PropertyDescriptor,
10
- ): any => {
11
- const target = descriptor || constructorOrGraph;
12
- Reflect.defineMetadata('isSingleton', true, target);
13
- return target;
14
- };
15
- }
@@ -1,8 +0,0 @@
1
- import InjectionMetadata from '../../injectors/class/InjectionMetadata';
2
-
3
- export function lateInject(name?: string): any {
4
- return (target: object) => {
5
- const metadata = new InjectionMetadata();
6
- metadata.saveLatePropertyMetadata(target.constructor, name!);
7
- };
8
- }