@illuma/core 0.2.0 → 1.1.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/README.md +170 -170
- package/dist/index.cjs +20 -101
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +76 -120
- package/dist/index.d.ts +76 -120
- package/dist/index.js +20 -99
- package/dist/index.js.map +1 -1
- package/dist/{injection-D22uAh1O.d.ts → injection-CSxu56ds.d.cts} +1 -1
- package/dist/{injection-CJGqGWJ6.d.cts → injection-Y_bVmBSk.d.ts} +1 -1
- package/dist/{plugin-container-CUw26ZhP.d.ts → plugin-container-CwkVlVS4.d.ts} +18 -21
- package/dist/{plugin-container-n0FIqLbh.d.cts → plugin-container-D8Zwpigq.d.cts} +18 -21
- package/dist/plugins.d.cts +3 -3
- package/dist/plugins.d.ts +3 -3
- package/dist/{token-BvQrvm-Q.d.cts → providers-D9YA8L_g.d.cts} +73 -73
- package/dist/{token-BvQrvm-Q.d.ts → providers-D9YA8L_g.d.ts} +73 -73
- package/dist/testkit.cjs +20 -62
- package/dist/testkit.cjs.map +1 -1
- package/dist/testkit.d.cts +2 -2
- package/dist/testkit.d.ts +2 -2
- package/dist/testkit.js +20 -62
- package/dist/testkit.js.map +1 -1
- package/package.json +74 -74
- package/CHANGELOG.md +0 -12
package/dist/index.d.cts
CHANGED
|
@@ -1,66 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { e as extractToken, g as iNodeAliasProvider, f as iNodeClassProvider, d as iNodeFactoryProvider, h as iNodeProvider, b as iNodeTokenBaseOptions, c as iNodeValueProvider, i as isNodeBase } from './
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { i as iInjectionNode, T as TreeNode, I as Illuma } from './plugin-container-n0FIqLbh.cjs';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Symbol used to mark classes as injectable and store their associated token.
|
|
9
|
-
* @internal
|
|
10
|
-
*/
|
|
11
|
-
declare const INJECTION_SYMBOL: unique symbol;
|
|
12
|
-
/**
|
|
13
|
-
* Decorator that marks a class as injectable in the dependency injection system.
|
|
14
|
-
* Automatically creates and associates a NodeToken with the class.
|
|
15
|
-
*
|
|
16
|
-
* @template T - The type of the class being decorated
|
|
17
|
-
* @returns A class decorator function
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```typescript
|
|
21
|
-
* @NodeInjectable()
|
|
22
|
-
* class UserService {
|
|
23
|
-
* public getUser() {
|
|
24
|
-
* return { id: 1, name: 'John' };
|
|
25
|
-
* }
|
|
26
|
-
* }
|
|
27
|
-
*
|
|
28
|
-
* container.provide(UserService);
|
|
29
|
-
* container.bootstrap();
|
|
30
|
-
* const service = container.get(UserService);
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
declare function NodeInjectable<T>(): (ctor: Ctor<T>) => Ctor<T>;
|
|
34
|
-
/**
|
|
35
|
-
* Alternative function to mark a class as injectable in the dependency injection system for environments
|
|
36
|
-
* that do not support decorators.
|
|
37
|
-
* @param ctor
|
|
38
|
-
* @returns
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* ```typescript
|
|
42
|
-
* import { makeInjectable } from '@illuma/core';
|
|
43
|
-
*
|
|
44
|
-
* class _UserService {
|
|
45
|
-
* public getUser() {
|
|
46
|
-
* return { id: 1, name: "John Doe" };
|
|
47
|
-
* }
|
|
48
|
-
* }
|
|
49
|
-
*
|
|
50
|
-
* export type UserService = _UserService;
|
|
51
|
-
* export const UserService = makeInjectable(_UserService);
|
|
52
|
-
* ```
|
|
53
|
-
*/
|
|
54
|
-
declare function makeInjectable<T>(ctor: Ctor<T>): Ctor<T>;
|
|
55
|
-
/** @internal */
|
|
56
|
-
declare function isInjectable<T>(ctor: unknown): ctor is Ctor<T> & {
|
|
57
|
-
[INJECTION_SYMBOL]: NodeToken<T>;
|
|
58
|
-
};
|
|
59
|
-
/** @internal */
|
|
60
|
-
declare function getInjectableToken<T>(ctor: Ctor<T> & {
|
|
61
|
-
[INJECTION_SYMBOL]: NodeToken<T>;
|
|
62
|
-
}): NodeToken<T>;
|
|
63
|
-
declare function isConstructor(fn: unknown): fn is Ctor<any>;
|
|
1
|
+
import { N as NodeBase, P as Provider, T as Token, M as MultiNodeToken, a as NodeToken, C as Ctor } from './providers-D9YA8L_g.cjs';
|
|
2
|
+
export { e as extractToken, g as iNodeAliasProvider, f as iNodeClassProvider, d as iNodeFactoryProvider, h as iNodeProvider, b as iNodeTokenBaseOptions, c as iNodeValueProvider, i as isNodeBase } from './providers-D9YA8L_g.cjs';
|
|
3
|
+
export { E as ExtractInjectedType, N as NodeInjectFn, i as iNodeInjectorOptions, n as nodeInject } from './injection-CSxu56ds.cjs';
|
|
4
|
+
import { i as iInjectionNode, T as TreeNode, I as Illuma } from './plugin-container-D8Zwpigq.cjs';
|
|
64
5
|
|
|
65
6
|
/** @internal */
|
|
66
7
|
type InjectorFn = (token: NodeBase<any>, optional?: boolean) => any;
|
|
@@ -103,37 +44,6 @@ declare abstract class InjectionContext {
|
|
|
103
44
|
static closeAndReport(): Set<iInjectionNode<any>>;
|
|
104
45
|
}
|
|
105
46
|
|
|
106
|
-
/**
|
|
107
|
-
* Configuration options for the NodeContainer.
|
|
108
|
-
*/
|
|
109
|
-
interface iContainerOptions {
|
|
110
|
-
/**
|
|
111
|
-
* When true, logs the bootstrap time to the console based on performance.now()
|
|
112
|
-
* difference before and after bootstrap.
|
|
113
|
-
* @default false
|
|
114
|
-
*/
|
|
115
|
-
measurePerformance?: boolean;
|
|
116
|
-
/**
|
|
117
|
-
* When true, enables diagnostics reporting after bootstrap.
|
|
118
|
-
* @default false
|
|
119
|
-
*/
|
|
120
|
-
diagnostics?: boolean;
|
|
121
|
-
/**
|
|
122
|
-
* @internal
|
|
123
|
-
* The parent container for hierarchical dependency resolution.
|
|
124
|
-
*/
|
|
125
|
-
parent?: iDIContainer;
|
|
126
|
-
/**
|
|
127
|
-
* @experimental
|
|
128
|
-
* Whether to instantiate dependencies immediately.
|
|
129
|
-
* If disabled, providers instantiation will happen when first requested.
|
|
130
|
-
* This helps improve startup performance for large containers.
|
|
131
|
-
* Enabled by default until stable.
|
|
132
|
-
*
|
|
133
|
-
* @default true
|
|
134
|
-
*/
|
|
135
|
-
instant?: boolean;
|
|
136
|
-
}
|
|
137
47
|
/**
|
|
138
48
|
* Interface for dependency injection containers.
|
|
139
49
|
* Defines the core methods that all DI containers must implement.
|
|
@@ -164,6 +74,77 @@ interface iDIContainer {
|
|
|
164
74
|
produce<T>(fn: Ctor<T> | (() => T)): T;
|
|
165
75
|
}
|
|
166
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Symbol used to mark classes as injectable and store their associated token.
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
81
|
+
declare const INJECTION_SYMBOL: unique symbol;
|
|
82
|
+
/**
|
|
83
|
+
* Decorator that marks a class as injectable in the dependency injection system.
|
|
84
|
+
* Automatically creates and associates a NodeToken with the class.
|
|
85
|
+
*
|
|
86
|
+
* @template T - The type of the class being decorated
|
|
87
|
+
* @returns A class decorator function
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* @NodeInjectable()
|
|
92
|
+
* class UserService {
|
|
93
|
+
* public getUser() {
|
|
94
|
+
* return { id: 1, name: 'John' };
|
|
95
|
+
* }
|
|
96
|
+
* }
|
|
97
|
+
*
|
|
98
|
+
* container.provide(UserService);
|
|
99
|
+
* container.bootstrap();
|
|
100
|
+
* const service = container.get(UserService);
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
declare function NodeInjectable<T>(): (ctor: Ctor<T>) => Ctor<T>;
|
|
104
|
+
/**
|
|
105
|
+
* Alternative function to mark a class as injectable in the dependency injection system for environments
|
|
106
|
+
* that do not support decorators.
|
|
107
|
+
* @param ctor
|
|
108
|
+
* @returns
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* import { makeInjectable } from '@illuma/core';
|
|
113
|
+
*
|
|
114
|
+
* class _UserService {
|
|
115
|
+
* public getUser() {
|
|
116
|
+
* return { id: 1, name: "John Doe" };
|
|
117
|
+
* }
|
|
118
|
+
* }
|
|
119
|
+
*
|
|
120
|
+
* export type UserService = _UserService;
|
|
121
|
+
* export const UserService = makeInjectable(_UserService);
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
declare function makeInjectable<T>(ctor: Ctor<T>): Ctor<T>;
|
|
125
|
+
/** @internal */
|
|
126
|
+
declare function isInjectable<T>(ctor: unknown): ctor is Ctor<T> & {
|
|
127
|
+
[INJECTION_SYMBOL]: NodeToken<T>;
|
|
128
|
+
};
|
|
129
|
+
/** @internal */
|
|
130
|
+
declare function getInjectableToken<T>(ctor: Ctor<T> & {
|
|
131
|
+
[INJECTION_SYMBOL]: NodeToken<T>;
|
|
132
|
+
}): NodeToken<T>;
|
|
133
|
+
declare function isConstructor(fn: unknown): fn is Ctor<any>;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Configuration options for the NodeContainer.
|
|
137
|
+
*/
|
|
138
|
+
interface iContainerOptions {
|
|
139
|
+
/**
|
|
140
|
+
* When true, logs the bootstrap time to the console based on performance.now()
|
|
141
|
+
* difference before and after bootstrap.
|
|
142
|
+
* @default false
|
|
143
|
+
*/
|
|
144
|
+
measurePerformance?: boolean;
|
|
145
|
+
diagnostics?: boolean;
|
|
146
|
+
parent?: iDIContainer;
|
|
147
|
+
}
|
|
167
148
|
declare class NodeContainer extends Illuma implements iDIContainer {
|
|
168
149
|
private readonly _opts?;
|
|
169
150
|
private _bootstrapped;
|
|
@@ -257,24 +238,6 @@ declare class NodeContainer extends Illuma implements iDIContainer {
|
|
|
257
238
|
produce<T>(fn: Ctor<T> | (() => T)): T;
|
|
258
239
|
}
|
|
259
240
|
|
|
260
|
-
declare const ERR_CODES: {
|
|
261
|
-
readonly DUPLICATE_PROVIDER: 100;
|
|
262
|
-
readonly DUPLICATE_FACTORY: 101;
|
|
263
|
-
readonly INVALID_CTOR: 102;
|
|
264
|
-
readonly INVALID_PROVIDER: 103;
|
|
265
|
-
readonly INVALID_ALIAS: 200;
|
|
266
|
-
readonly LOOP_ALIAS: 201;
|
|
267
|
-
readonly NOT_BOOTSTRAPPED: 300;
|
|
268
|
-
readonly BOOTSTRAPPED: 301;
|
|
269
|
-
readonly DOUBLE_BOOTSTRAP: 302;
|
|
270
|
-
readonly NOT_FOUND: 400;
|
|
271
|
-
readonly CIRCULAR_DEPENDENCY: 401;
|
|
272
|
-
readonly UNTRACKED: 500;
|
|
273
|
-
readonly OUTSIDE_CONTEXT: 501;
|
|
274
|
-
readonly CALLED_UTILS_OUTSIDE_CONTEXT: 502;
|
|
275
|
-
readonly INSTANCE_ACCESS_FAILED: 503;
|
|
276
|
-
readonly ACCESS_FAILED: 504;
|
|
277
|
-
};
|
|
278
241
|
declare class InjectionError extends Error {
|
|
279
242
|
readonly code: number;
|
|
280
243
|
constructor(code: number, message: string);
|
|
@@ -296,12 +259,6 @@ declare class InjectionError extends Error {
|
|
|
296
259
|
static accessFailed(): InjectionError;
|
|
297
260
|
}
|
|
298
261
|
|
|
299
|
-
declare function injectDefer<N>(token: N, options: iNodeInjectorOptions & {
|
|
300
|
-
optional: true;
|
|
301
|
-
}): () => N extends MultiNodeToken<infer V> ? V[] : N extends NodeToken<infer U> ? U | null : N extends new (...args: any[]) => infer T ? T | null : never;
|
|
302
|
-
declare function injectDefer<N>(token: N, options?: iNodeInjectorOptions): () => N extends MultiNodeToken<infer V> ? V[] : N extends NodeToken<infer U> ? U : N extends new (...args: any) => infer T ? T : never;
|
|
303
|
-
declare function injectDefer<N extends NodeToken<unknown> | MultiNodeToken<unknown>>(token: N, options?: iNodeInjectorOptions): () => ExtractInjectedType<N>;
|
|
304
|
-
|
|
305
262
|
interface iInjector {
|
|
306
263
|
/** The DI container associated with this injector */
|
|
307
264
|
readonly container: iDIContainer;
|
|
@@ -343,7 +300,6 @@ declare class InjectorImpl implements iInjector {
|
|
|
343
300
|
* @example
|
|
344
301
|
* ```typescript
|
|
345
302
|
* import { Injector, nodeInject, NodeInjectable, NodeContainer } from "@illuma/core";
|
|
346
|
-
import { iDIContainer } from '../container/types';
|
|
347
303
|
*
|
|
348
304
|
* @NodeInjectable()
|
|
349
305
|
* class MyService {
|
|
@@ -419,4 +375,4 @@ declare function injectEntryAsync<T>(fn: MaybeAsyncFactory<iEntrypointConfig<Nod
|
|
|
419
375
|
declare function injectEntryAsync<T>(fn: MaybeAsyncFactory<iEntrypointConfig<Ctor<T>>>, opts?: iInjectionOptions): () => Promise<T>;
|
|
420
376
|
declare function injectEntryAsync<T>(fn: MaybeAsyncFactory<iEntrypointConfig<MultiNodeToken<T>>>, opts?: iInjectionOptions): () => Promise<T>;
|
|
421
377
|
|
|
422
|
-
export { Ctor,
|
|
378
|
+
export { Ctor, INJECTION_SYMBOL, InjectionContext, InjectionError, Injector, type InjectorFn, InjectorImpl, MultiNodeToken, NodeBase, NodeContainer, NodeInjectable, NodeToken, Provider, Token, getInjectableToken, type iDIContainer, type iEntrypointConfig, iInjectionNode, type iInjector, injectAsync, injectEntryAsync, injectGroupAsync, isConstructor, isInjectable, makeInjectable };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,66 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { e as extractToken, g as iNodeAliasProvider, f as iNodeClassProvider, d as iNodeFactoryProvider, h as iNodeProvider, b as iNodeTokenBaseOptions, c as iNodeValueProvider, i as isNodeBase } from './
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { i as iInjectionNode, T as TreeNode, I as Illuma } from './plugin-container-CUw26ZhP.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Symbol used to mark classes as injectable and store their associated token.
|
|
9
|
-
* @internal
|
|
10
|
-
*/
|
|
11
|
-
declare const INJECTION_SYMBOL: unique symbol;
|
|
12
|
-
/**
|
|
13
|
-
* Decorator that marks a class as injectable in the dependency injection system.
|
|
14
|
-
* Automatically creates and associates a NodeToken with the class.
|
|
15
|
-
*
|
|
16
|
-
* @template T - The type of the class being decorated
|
|
17
|
-
* @returns A class decorator function
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```typescript
|
|
21
|
-
* @NodeInjectable()
|
|
22
|
-
* class UserService {
|
|
23
|
-
* public getUser() {
|
|
24
|
-
* return { id: 1, name: 'John' };
|
|
25
|
-
* }
|
|
26
|
-
* }
|
|
27
|
-
*
|
|
28
|
-
* container.provide(UserService);
|
|
29
|
-
* container.bootstrap();
|
|
30
|
-
* const service = container.get(UserService);
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
declare function NodeInjectable<T>(): (ctor: Ctor<T>) => Ctor<T>;
|
|
34
|
-
/**
|
|
35
|
-
* Alternative function to mark a class as injectable in the dependency injection system for environments
|
|
36
|
-
* that do not support decorators.
|
|
37
|
-
* @param ctor
|
|
38
|
-
* @returns
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* ```typescript
|
|
42
|
-
* import { makeInjectable } from '@illuma/core';
|
|
43
|
-
*
|
|
44
|
-
* class _UserService {
|
|
45
|
-
* public getUser() {
|
|
46
|
-
* return { id: 1, name: "John Doe" };
|
|
47
|
-
* }
|
|
48
|
-
* }
|
|
49
|
-
*
|
|
50
|
-
* export type UserService = _UserService;
|
|
51
|
-
* export const UserService = makeInjectable(_UserService);
|
|
52
|
-
* ```
|
|
53
|
-
*/
|
|
54
|
-
declare function makeInjectable<T>(ctor: Ctor<T>): Ctor<T>;
|
|
55
|
-
/** @internal */
|
|
56
|
-
declare function isInjectable<T>(ctor: unknown): ctor is Ctor<T> & {
|
|
57
|
-
[INJECTION_SYMBOL]: NodeToken<T>;
|
|
58
|
-
};
|
|
59
|
-
/** @internal */
|
|
60
|
-
declare function getInjectableToken<T>(ctor: Ctor<T> & {
|
|
61
|
-
[INJECTION_SYMBOL]: NodeToken<T>;
|
|
62
|
-
}): NodeToken<T>;
|
|
63
|
-
declare function isConstructor(fn: unknown): fn is Ctor<any>;
|
|
1
|
+
import { N as NodeBase, P as Provider, T as Token, M as MultiNodeToken, a as NodeToken, C as Ctor } from './providers-D9YA8L_g.js';
|
|
2
|
+
export { e as extractToken, g as iNodeAliasProvider, f as iNodeClassProvider, d as iNodeFactoryProvider, h as iNodeProvider, b as iNodeTokenBaseOptions, c as iNodeValueProvider, i as isNodeBase } from './providers-D9YA8L_g.js';
|
|
3
|
+
export { E as ExtractInjectedType, N as NodeInjectFn, i as iNodeInjectorOptions, n as nodeInject } from './injection-Y_bVmBSk.js';
|
|
4
|
+
import { i as iInjectionNode, T as TreeNode, I as Illuma } from './plugin-container-CwkVlVS4.js';
|
|
64
5
|
|
|
65
6
|
/** @internal */
|
|
66
7
|
type InjectorFn = (token: NodeBase<any>, optional?: boolean) => any;
|
|
@@ -103,37 +44,6 @@ declare abstract class InjectionContext {
|
|
|
103
44
|
static closeAndReport(): Set<iInjectionNode<any>>;
|
|
104
45
|
}
|
|
105
46
|
|
|
106
|
-
/**
|
|
107
|
-
* Configuration options for the NodeContainer.
|
|
108
|
-
*/
|
|
109
|
-
interface iContainerOptions {
|
|
110
|
-
/**
|
|
111
|
-
* When true, logs the bootstrap time to the console based on performance.now()
|
|
112
|
-
* difference before and after bootstrap.
|
|
113
|
-
* @default false
|
|
114
|
-
*/
|
|
115
|
-
measurePerformance?: boolean;
|
|
116
|
-
/**
|
|
117
|
-
* When true, enables diagnostics reporting after bootstrap.
|
|
118
|
-
* @default false
|
|
119
|
-
*/
|
|
120
|
-
diagnostics?: boolean;
|
|
121
|
-
/**
|
|
122
|
-
* @internal
|
|
123
|
-
* The parent container for hierarchical dependency resolution.
|
|
124
|
-
*/
|
|
125
|
-
parent?: iDIContainer;
|
|
126
|
-
/**
|
|
127
|
-
* @experimental
|
|
128
|
-
* Whether to instantiate dependencies immediately.
|
|
129
|
-
* If disabled, providers instantiation will happen when first requested.
|
|
130
|
-
* This helps improve startup performance for large containers.
|
|
131
|
-
* Enabled by default until stable.
|
|
132
|
-
*
|
|
133
|
-
* @default true
|
|
134
|
-
*/
|
|
135
|
-
instant?: boolean;
|
|
136
|
-
}
|
|
137
47
|
/**
|
|
138
48
|
* Interface for dependency injection containers.
|
|
139
49
|
* Defines the core methods that all DI containers must implement.
|
|
@@ -164,6 +74,77 @@ interface iDIContainer {
|
|
|
164
74
|
produce<T>(fn: Ctor<T> | (() => T)): T;
|
|
165
75
|
}
|
|
166
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Symbol used to mark classes as injectable and store their associated token.
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
81
|
+
declare const INJECTION_SYMBOL: unique symbol;
|
|
82
|
+
/**
|
|
83
|
+
* Decorator that marks a class as injectable in the dependency injection system.
|
|
84
|
+
* Automatically creates and associates a NodeToken with the class.
|
|
85
|
+
*
|
|
86
|
+
* @template T - The type of the class being decorated
|
|
87
|
+
* @returns A class decorator function
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* @NodeInjectable()
|
|
92
|
+
* class UserService {
|
|
93
|
+
* public getUser() {
|
|
94
|
+
* return { id: 1, name: 'John' };
|
|
95
|
+
* }
|
|
96
|
+
* }
|
|
97
|
+
*
|
|
98
|
+
* container.provide(UserService);
|
|
99
|
+
* container.bootstrap();
|
|
100
|
+
* const service = container.get(UserService);
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
declare function NodeInjectable<T>(): (ctor: Ctor<T>) => Ctor<T>;
|
|
104
|
+
/**
|
|
105
|
+
* Alternative function to mark a class as injectable in the dependency injection system for environments
|
|
106
|
+
* that do not support decorators.
|
|
107
|
+
* @param ctor
|
|
108
|
+
* @returns
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* import { makeInjectable } from '@illuma/core';
|
|
113
|
+
*
|
|
114
|
+
* class _UserService {
|
|
115
|
+
* public getUser() {
|
|
116
|
+
* return { id: 1, name: "John Doe" };
|
|
117
|
+
* }
|
|
118
|
+
* }
|
|
119
|
+
*
|
|
120
|
+
* export type UserService = _UserService;
|
|
121
|
+
* export const UserService = makeInjectable(_UserService);
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
declare function makeInjectable<T>(ctor: Ctor<T>): Ctor<T>;
|
|
125
|
+
/** @internal */
|
|
126
|
+
declare function isInjectable<T>(ctor: unknown): ctor is Ctor<T> & {
|
|
127
|
+
[INJECTION_SYMBOL]: NodeToken<T>;
|
|
128
|
+
};
|
|
129
|
+
/** @internal */
|
|
130
|
+
declare function getInjectableToken<T>(ctor: Ctor<T> & {
|
|
131
|
+
[INJECTION_SYMBOL]: NodeToken<T>;
|
|
132
|
+
}): NodeToken<T>;
|
|
133
|
+
declare function isConstructor(fn: unknown): fn is Ctor<any>;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Configuration options for the NodeContainer.
|
|
137
|
+
*/
|
|
138
|
+
interface iContainerOptions {
|
|
139
|
+
/**
|
|
140
|
+
* When true, logs the bootstrap time to the console based on performance.now()
|
|
141
|
+
* difference before and after bootstrap.
|
|
142
|
+
* @default false
|
|
143
|
+
*/
|
|
144
|
+
measurePerformance?: boolean;
|
|
145
|
+
diagnostics?: boolean;
|
|
146
|
+
parent?: iDIContainer;
|
|
147
|
+
}
|
|
167
148
|
declare class NodeContainer extends Illuma implements iDIContainer {
|
|
168
149
|
private readonly _opts?;
|
|
169
150
|
private _bootstrapped;
|
|
@@ -257,24 +238,6 @@ declare class NodeContainer extends Illuma implements iDIContainer {
|
|
|
257
238
|
produce<T>(fn: Ctor<T> | (() => T)): T;
|
|
258
239
|
}
|
|
259
240
|
|
|
260
|
-
declare const ERR_CODES: {
|
|
261
|
-
readonly DUPLICATE_PROVIDER: 100;
|
|
262
|
-
readonly DUPLICATE_FACTORY: 101;
|
|
263
|
-
readonly INVALID_CTOR: 102;
|
|
264
|
-
readonly INVALID_PROVIDER: 103;
|
|
265
|
-
readonly INVALID_ALIAS: 200;
|
|
266
|
-
readonly LOOP_ALIAS: 201;
|
|
267
|
-
readonly NOT_BOOTSTRAPPED: 300;
|
|
268
|
-
readonly BOOTSTRAPPED: 301;
|
|
269
|
-
readonly DOUBLE_BOOTSTRAP: 302;
|
|
270
|
-
readonly NOT_FOUND: 400;
|
|
271
|
-
readonly CIRCULAR_DEPENDENCY: 401;
|
|
272
|
-
readonly UNTRACKED: 500;
|
|
273
|
-
readonly OUTSIDE_CONTEXT: 501;
|
|
274
|
-
readonly CALLED_UTILS_OUTSIDE_CONTEXT: 502;
|
|
275
|
-
readonly INSTANCE_ACCESS_FAILED: 503;
|
|
276
|
-
readonly ACCESS_FAILED: 504;
|
|
277
|
-
};
|
|
278
241
|
declare class InjectionError extends Error {
|
|
279
242
|
readonly code: number;
|
|
280
243
|
constructor(code: number, message: string);
|
|
@@ -296,12 +259,6 @@ declare class InjectionError extends Error {
|
|
|
296
259
|
static accessFailed(): InjectionError;
|
|
297
260
|
}
|
|
298
261
|
|
|
299
|
-
declare function injectDefer<N>(token: N, options: iNodeInjectorOptions & {
|
|
300
|
-
optional: true;
|
|
301
|
-
}): () => N extends MultiNodeToken<infer V> ? V[] : N extends NodeToken<infer U> ? U | null : N extends new (...args: any[]) => infer T ? T | null : never;
|
|
302
|
-
declare function injectDefer<N>(token: N, options?: iNodeInjectorOptions): () => N extends MultiNodeToken<infer V> ? V[] : N extends NodeToken<infer U> ? U : N extends new (...args: any) => infer T ? T : never;
|
|
303
|
-
declare function injectDefer<N extends NodeToken<unknown> | MultiNodeToken<unknown>>(token: N, options?: iNodeInjectorOptions): () => ExtractInjectedType<N>;
|
|
304
|
-
|
|
305
262
|
interface iInjector {
|
|
306
263
|
/** The DI container associated with this injector */
|
|
307
264
|
readonly container: iDIContainer;
|
|
@@ -343,7 +300,6 @@ declare class InjectorImpl implements iInjector {
|
|
|
343
300
|
* @example
|
|
344
301
|
* ```typescript
|
|
345
302
|
* import { Injector, nodeInject, NodeInjectable, NodeContainer } from "@illuma/core";
|
|
346
|
-
import { iDIContainer } from '../container/types';
|
|
347
303
|
*
|
|
348
304
|
* @NodeInjectable()
|
|
349
305
|
* class MyService {
|
|
@@ -419,4 +375,4 @@ declare function injectEntryAsync<T>(fn: MaybeAsyncFactory<iEntrypointConfig<Nod
|
|
|
419
375
|
declare function injectEntryAsync<T>(fn: MaybeAsyncFactory<iEntrypointConfig<Ctor<T>>>, opts?: iInjectionOptions): () => Promise<T>;
|
|
420
376
|
declare function injectEntryAsync<T>(fn: MaybeAsyncFactory<iEntrypointConfig<MultiNodeToken<T>>>, opts?: iInjectionOptions): () => Promise<T>;
|
|
421
377
|
|
|
422
|
-
export { Ctor,
|
|
378
|
+
export { Ctor, INJECTION_SYMBOL, InjectionContext, InjectionError, Injector, type InjectorFn, InjectorImpl, MultiNodeToken, NodeBase, NodeContainer, NodeInjectable, NodeToken, Provider, Token, getInjectableToken, type iDIContainer, type iEntrypointConfig, iInjectionNode, type iInjector, injectAsync, injectEntryAsync, injectGroupAsync, isConstructor, isInjectable, makeInjectable };
|