@noxfly/noxus 2.5.0 → 3.0.0-dev.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 +403 -341
- package/dist/app-injector-Bz3Upc0y.d.mts +125 -0
- package/dist/app-injector-Bz3Upc0y.d.ts +125 -0
- package/dist/child.d.mts +48 -22
- package/dist/child.d.ts +48 -22
- package/dist/child.js +1111 -1341
- package/dist/child.mjs +1087 -1295
- package/dist/main.d.mts +301 -309
- package/dist/main.d.ts +301 -309
- package/dist/main.js +1471 -1650
- package/dist/main.mjs +1420 -1570
- package/dist/renderer.d.mts +3 -3
- package/dist/renderer.d.ts +3 -3
- package/dist/renderer.js +109 -135
- package/dist/renderer.mjs +109 -135
- package/dist/request-BlTtiHbi.d.ts +112 -0
- package/dist/request-qJ9EiDZc.d.mts +112 -0
- package/package.json +7 -7
- package/src/DI/app-injector.ts +95 -106
- package/src/DI/injector-explorer.ts +93 -119
- package/src/DI/token.ts +53 -0
- package/src/app.ts +141 -168
- package/src/bootstrap.ts +78 -54
- package/src/decorators/controller.decorator.ts +38 -27
- package/src/decorators/guards.decorator.ts +5 -64
- package/src/decorators/injectable.decorator.ts +68 -15
- package/src/decorators/method.decorator.ts +40 -81
- package/src/decorators/middleware.decorator.ts +5 -72
- package/src/index.ts +2 -0
- package/src/main.ts +4 -8
- package/src/non-electron-process.ts +0 -1
- package/src/preload-bridge.ts +1 -1
- package/src/renderer-client.ts +2 -2
- package/src/renderer-events.ts +1 -1
- package/src/request.ts +3 -3
- package/src/router.ts +190 -431
- package/src/routes.ts +78 -0
- package/src/socket.ts +4 -4
- package/src/window/window-manager.ts +255 -0
- package/tsconfig.json +5 -10
- package/tsup.config.ts +2 -2
- package/dist/app-injector-B3MvgV3k.d.mts +0 -95
- package/dist/app-injector-B3MvgV3k.d.ts +0 -95
- package/dist/request-CdpZ9qZL.d.ts +0 -167
- package/dist/request-Dx_5Prte.d.mts +0 -167
- package/src/decorators/inject.decorator.ts +0 -24
- package/src/decorators/injectable.metadata.ts +0 -15
- package/src/decorators/module.decorator.ts +0 -75
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright 2025 NoxFly
|
|
3
|
+
* @license MIT
|
|
4
|
+
* @author NoxFly
|
|
5
|
+
*/
|
|
6
|
+
interface Type<T> extends Function {
|
|
7
|
+
new (...args: any[]): T;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Represents a generic type that can be either a value or a promise resolving to that value.
|
|
11
|
+
*/
|
|
12
|
+
type MaybeAsync<T> = T | Promise<T>;
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A function that returns a type.
|
|
17
|
+
* Used for forward references to types that are not yet defined.
|
|
18
|
+
*/
|
|
19
|
+
interface ForwardRefFn<T = any> {
|
|
20
|
+
(): Type<T>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A wrapper class for forward referenced types.
|
|
24
|
+
*/
|
|
25
|
+
declare class ForwardReference<T = any> {
|
|
26
|
+
readonly forwardRefFn: ForwardRefFn<T>;
|
|
27
|
+
constructor(forwardRefFn: ForwardRefFn<T>);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Creates a forward reference to a type.
|
|
31
|
+
* @param fn A function that returns the type.
|
|
32
|
+
* @returns A ForwardReference instance.
|
|
33
|
+
*/
|
|
34
|
+
declare function forwardRef<T = any>(fn: ForwardRefFn<T>): ForwardReference<T>;
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A DI token uniquely identifies a dependency.
|
|
39
|
+
* It can wrap a class (Type<T>) or be a named symbol token.
|
|
40
|
+
*
|
|
41
|
+
* Using tokens instead of reflect-metadata means dependencies are
|
|
42
|
+
* declared explicitly — no magic type inference, no emitDecoratorMetadata.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* // Class token (most common)
|
|
46
|
+
* const MY_SERVICE = token(MyService);
|
|
47
|
+
*
|
|
48
|
+
* // Named symbol token (for interfaces or non-class values)
|
|
49
|
+
* const DB_URL = token<string>('DB_URL');
|
|
50
|
+
*/
|
|
51
|
+
declare class Token<T> {
|
|
52
|
+
readonly target: Type<T> | string;
|
|
53
|
+
readonly description: string;
|
|
54
|
+
constructor(target: Type<T> | string);
|
|
55
|
+
toString(): string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Creates a DI token for a class type or a named value.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* export const MY_SERVICE = token(MyService);
|
|
62
|
+
* export const DB_URL = token<string>('DB_URL');
|
|
63
|
+
*/
|
|
64
|
+
declare function token<T>(target: Type<T> | string): Token<T>;
|
|
65
|
+
/**
|
|
66
|
+
* The key used to look up a class token in the registry.
|
|
67
|
+
* For class tokens, the key is the class constructor itself.
|
|
68
|
+
* For named tokens, the key is the Token instance.
|
|
69
|
+
*/
|
|
70
|
+
type TokenKey<T = unknown> = Type<T> | Token<T>;
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Lifetime of a binding in the DI container.
|
|
75
|
+
* - singleton: created once, shared for the lifetime of the app.
|
|
76
|
+
* - scope: created once per request scope.
|
|
77
|
+
* - transient: new instance every time it is resolved.
|
|
78
|
+
*/
|
|
79
|
+
type Lifetime = 'singleton' | 'scope' | 'transient';
|
|
80
|
+
/**
|
|
81
|
+
* Internal representation of a registered binding.
|
|
82
|
+
*/
|
|
83
|
+
interface IBinding<T = unknown> {
|
|
84
|
+
lifetime: Lifetime;
|
|
85
|
+
implementation: Type<T>;
|
|
86
|
+
/** Explicit constructor dependencies, declared by the class itself. */
|
|
87
|
+
deps: ReadonlyArray<TokenKey>;
|
|
88
|
+
instance?: T;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* AppInjector is the core DI container.
|
|
92
|
+
* It no longer uses reflect-metadata — all dependency information
|
|
93
|
+
* comes from explicitly declared `deps` arrays on each binding.
|
|
94
|
+
*/
|
|
95
|
+
declare class AppInjector {
|
|
96
|
+
readonly name: string | null;
|
|
97
|
+
readonly bindings: Map<Type<unknown> | Token<unknown>, IBinding<unknown>>;
|
|
98
|
+
readonly singletons: Map<Type<unknown> | Token<unknown>, unknown>;
|
|
99
|
+
readonly scoped: Map<Type<unknown> | Token<unknown>, unknown>;
|
|
100
|
+
constructor(name?: string | null);
|
|
101
|
+
/**
|
|
102
|
+
* Creates a child scope for per-request lifetime resolution.
|
|
103
|
+
*/
|
|
104
|
+
createScope(): AppInjector;
|
|
105
|
+
/**
|
|
106
|
+
* Registers a binding explicitly.
|
|
107
|
+
*/
|
|
108
|
+
register<T>(key: TokenKey<T>, implementation: Type<T>, lifetime: Lifetime, deps?: ReadonlyArray<TokenKey>): void;
|
|
109
|
+
/**
|
|
110
|
+
* Resolves a dependency by token or class reference.
|
|
111
|
+
*/
|
|
112
|
+
resolve<T>(target: TokenKey<T> | ForwardReference<T>): T;
|
|
113
|
+
private _resolveForwardRef;
|
|
114
|
+
private _instantiate;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The global root injector. All singletons live here.
|
|
118
|
+
*/
|
|
119
|
+
declare const RootInjector: AppInjector;
|
|
120
|
+
/**
|
|
121
|
+
* Convenience function: resolve a token from the root injector.
|
|
122
|
+
*/
|
|
123
|
+
declare function inject<T>(t: TokenKey<T> | ForwardReference<T>): T;
|
|
124
|
+
|
|
125
|
+
export { AppInjector as A, type ForwardRefFn as F, type IBinding as I, type Lifetime as L, type MaybeAsync as M, RootInjector as R, type Type as T, type TokenKey as a, ForwardReference as b, Token as c, forwardRef as f, inject as i, token as t };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright 2025 NoxFly
|
|
3
|
+
* @license MIT
|
|
4
|
+
* @author NoxFly
|
|
5
|
+
*/
|
|
6
|
+
interface Type<T> extends Function {
|
|
7
|
+
new (...args: any[]): T;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Represents a generic type that can be either a value or a promise resolving to that value.
|
|
11
|
+
*/
|
|
12
|
+
type MaybeAsync<T> = T | Promise<T>;
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A function that returns a type.
|
|
17
|
+
* Used for forward references to types that are not yet defined.
|
|
18
|
+
*/
|
|
19
|
+
interface ForwardRefFn<T = any> {
|
|
20
|
+
(): Type<T>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A wrapper class for forward referenced types.
|
|
24
|
+
*/
|
|
25
|
+
declare class ForwardReference<T = any> {
|
|
26
|
+
readonly forwardRefFn: ForwardRefFn<T>;
|
|
27
|
+
constructor(forwardRefFn: ForwardRefFn<T>);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Creates a forward reference to a type.
|
|
31
|
+
* @param fn A function that returns the type.
|
|
32
|
+
* @returns A ForwardReference instance.
|
|
33
|
+
*/
|
|
34
|
+
declare function forwardRef<T = any>(fn: ForwardRefFn<T>): ForwardReference<T>;
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A DI token uniquely identifies a dependency.
|
|
39
|
+
* It can wrap a class (Type<T>) or be a named symbol token.
|
|
40
|
+
*
|
|
41
|
+
* Using tokens instead of reflect-metadata means dependencies are
|
|
42
|
+
* declared explicitly — no magic type inference, no emitDecoratorMetadata.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* // Class token (most common)
|
|
46
|
+
* const MY_SERVICE = token(MyService);
|
|
47
|
+
*
|
|
48
|
+
* // Named symbol token (for interfaces or non-class values)
|
|
49
|
+
* const DB_URL = token<string>('DB_URL');
|
|
50
|
+
*/
|
|
51
|
+
declare class Token<T> {
|
|
52
|
+
readonly target: Type<T> | string;
|
|
53
|
+
readonly description: string;
|
|
54
|
+
constructor(target: Type<T> | string);
|
|
55
|
+
toString(): string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Creates a DI token for a class type or a named value.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* export const MY_SERVICE = token(MyService);
|
|
62
|
+
* export const DB_URL = token<string>('DB_URL');
|
|
63
|
+
*/
|
|
64
|
+
declare function token<T>(target: Type<T> | string): Token<T>;
|
|
65
|
+
/**
|
|
66
|
+
* The key used to look up a class token in the registry.
|
|
67
|
+
* For class tokens, the key is the class constructor itself.
|
|
68
|
+
* For named tokens, the key is the Token instance.
|
|
69
|
+
*/
|
|
70
|
+
type TokenKey<T = unknown> = Type<T> | Token<T>;
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Lifetime of a binding in the DI container.
|
|
75
|
+
* - singleton: created once, shared for the lifetime of the app.
|
|
76
|
+
* - scope: created once per request scope.
|
|
77
|
+
* - transient: new instance every time it is resolved.
|
|
78
|
+
*/
|
|
79
|
+
type Lifetime = 'singleton' | 'scope' | 'transient';
|
|
80
|
+
/**
|
|
81
|
+
* Internal representation of a registered binding.
|
|
82
|
+
*/
|
|
83
|
+
interface IBinding<T = unknown> {
|
|
84
|
+
lifetime: Lifetime;
|
|
85
|
+
implementation: Type<T>;
|
|
86
|
+
/** Explicit constructor dependencies, declared by the class itself. */
|
|
87
|
+
deps: ReadonlyArray<TokenKey>;
|
|
88
|
+
instance?: T;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* AppInjector is the core DI container.
|
|
92
|
+
* It no longer uses reflect-metadata — all dependency information
|
|
93
|
+
* comes from explicitly declared `deps` arrays on each binding.
|
|
94
|
+
*/
|
|
95
|
+
declare class AppInjector {
|
|
96
|
+
readonly name: string | null;
|
|
97
|
+
readonly bindings: Map<Type<unknown> | Token<unknown>, IBinding<unknown>>;
|
|
98
|
+
readonly singletons: Map<Type<unknown> | Token<unknown>, unknown>;
|
|
99
|
+
readonly scoped: Map<Type<unknown> | Token<unknown>, unknown>;
|
|
100
|
+
constructor(name?: string | null);
|
|
101
|
+
/**
|
|
102
|
+
* Creates a child scope for per-request lifetime resolution.
|
|
103
|
+
*/
|
|
104
|
+
createScope(): AppInjector;
|
|
105
|
+
/**
|
|
106
|
+
* Registers a binding explicitly.
|
|
107
|
+
*/
|
|
108
|
+
register<T>(key: TokenKey<T>, implementation: Type<T>, lifetime: Lifetime, deps?: ReadonlyArray<TokenKey>): void;
|
|
109
|
+
/**
|
|
110
|
+
* Resolves a dependency by token or class reference.
|
|
111
|
+
*/
|
|
112
|
+
resolve<T>(target: TokenKey<T> | ForwardReference<T>): T;
|
|
113
|
+
private _resolveForwardRef;
|
|
114
|
+
private _instantiate;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The global root injector. All singletons live here.
|
|
118
|
+
*/
|
|
119
|
+
declare const RootInjector: AppInjector;
|
|
120
|
+
/**
|
|
121
|
+
* Convenience function: resolve a token from the root injector.
|
|
122
|
+
*/
|
|
123
|
+
declare function inject<T>(t: TokenKey<T> | ForwardReference<T>): T;
|
|
124
|
+
|
|
125
|
+
export { AppInjector as A, type ForwardRefFn as F, type IBinding as I, type Lifetime as L, type MaybeAsync as M, RootInjector as R, type Type as T, type TokenKey as a, ForwardReference as b, Token as c, forwardRef as f, inject as i, token as t };
|
package/dist/child.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as Lifetime } from './app-injector-
|
|
2
|
-
export { A as AppInjector, F as ForwardRefFn,
|
|
1
|
+
import { L as Lifetime, a as TokenKey } from './app-injector-Bz3Upc0y.mjs';
|
|
2
|
+
export { A as AppInjector, F as ForwardRefFn, b as ForwardReference, I as IBinding, M as MaybeAsync, R as RootInjector, c as Token, T as Type, f as forwardRef, i as inject } from './app-injector-Bz3Upc0y.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @copyright 2025 NoxFly
|
|
@@ -81,29 +81,55 @@ declare class NetworkConnectTimeoutException extends ResponseException {
|
|
|
81
81
|
readonly status = 599;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
declare const INJECTABLE_METADATA_KEY: unique symbol;
|
|
85
|
-
declare function getInjectableMetadata(target: Function): Lifetime | undefined;
|
|
86
|
-
declare function hasInjectableMetadata(target: Function): boolean;
|
|
87
84
|
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
85
|
+
interface InjectableOptions {
|
|
86
|
+
/**
|
|
87
|
+
* Lifetime of this injectable.
|
|
88
|
+
* @default 'scope'
|
|
89
|
+
*/
|
|
90
|
+
lifetime?: Lifetime;
|
|
91
|
+
/**
|
|
92
|
+
* Explicit list of constructor dependencies, in the same order as the constructor parameters.
|
|
93
|
+
* Each entry is either a class constructor or a Token created with token().
|
|
94
|
+
*
|
|
95
|
+
* This replaces reflect-metadata / emitDecoratorMetadata entirely.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* @Injectable({ lifetime: 'singleton', deps: [MyRepo, DB_URL] })
|
|
99
|
+
* class MyService {
|
|
100
|
+
* constructor(private repo: MyRepo, private dbUrl: string) {}
|
|
101
|
+
* }
|
|
102
|
+
*/
|
|
103
|
+
deps?: ReadonlyArray<TokenKey>;
|
|
104
|
+
}
|
|
100
105
|
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
106
|
+
* Marks a class as injectable into the Noxus DI container.
|
|
107
|
+
*
|
|
108
|
+
* Unlike the v2 @Injectable, this decorator:
|
|
109
|
+
* - Does NOT require reflect-metadata or emitDecoratorMetadata.
|
|
110
|
+
* - Requires you to declare deps explicitly when the class has constructor parameters.
|
|
111
|
+
* - Supports standalone usage — no module declaration needed.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* // No dependencies
|
|
115
|
+
* @Injectable()
|
|
116
|
+
* class Logger {}
|
|
117
|
+
*
|
|
118
|
+
* // With dependencies
|
|
119
|
+
* @Injectable({ lifetime: 'singleton', deps: [Logger, MyRepo] })
|
|
120
|
+
* class MyService {
|
|
121
|
+
* constructor(private logger: Logger, private repo: MyRepo) {}
|
|
122
|
+
* }
|
|
123
|
+
*
|
|
124
|
+
* // With a named token
|
|
125
|
+
* const DB_URL = token<string>('DB_URL');
|
|
103
126
|
*
|
|
104
|
-
* @
|
|
127
|
+
* @Injectable({ deps: [DB_URL] })
|
|
128
|
+
* class DbService {
|
|
129
|
+
* constructor(private url: string) {}
|
|
130
|
+
* }
|
|
105
131
|
*/
|
|
106
|
-
declare function
|
|
132
|
+
declare function Injectable(options?: InjectableOptions): ClassDecorator;
|
|
107
133
|
|
|
108
134
|
/**
|
|
109
135
|
* Logger is a utility class for logging messages to the console.
|
|
@@ -206,4 +232,4 @@ declare namespace Logger {
|
|
|
206
232
|
};
|
|
207
233
|
}
|
|
208
234
|
|
|
209
|
-
export { BadGatewayException, BadRequestException, ConflictException, ForbiddenException, GatewayTimeoutException, HttpVersionNotSupportedException,
|
|
235
|
+
export { BadGatewayException, BadRequestException, ConflictException, ForbiddenException, GatewayTimeoutException, HttpVersionNotSupportedException, Injectable, type InjectableOptions, InsufficientStorageException, InternalServerException, Lifetime, type LogLevel, Logger, LoopDetectedException, MethodNotAllowedException, NetworkAuthenticationRequiredException, NetworkConnectTimeoutException, NotAcceptableException, NotExtendedException, NotFoundException, NotImplementedException, PaymentRequiredException, RequestTimeoutException, ResponseException, ServiceUnavailableException, TokenKey, TooManyRequestsException, UnauthorizedException, UpgradeRequiredException, VariantAlsoNegotiatesException };
|
package/dist/child.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as Lifetime } from './app-injector-
|
|
2
|
-
export { A as AppInjector, F as ForwardRefFn,
|
|
1
|
+
import { L as Lifetime, a as TokenKey } from './app-injector-Bz3Upc0y.js';
|
|
2
|
+
export { A as AppInjector, F as ForwardRefFn, b as ForwardReference, I as IBinding, M as MaybeAsync, R as RootInjector, c as Token, T as Type, f as forwardRef, i as inject } from './app-injector-Bz3Upc0y.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @copyright 2025 NoxFly
|
|
@@ -81,29 +81,55 @@ declare class NetworkConnectTimeoutException extends ResponseException {
|
|
|
81
81
|
readonly status = 599;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
declare const INJECTABLE_METADATA_KEY: unique symbol;
|
|
85
|
-
declare function getInjectableMetadata(target: Function): Lifetime | undefined;
|
|
86
|
-
declare function hasInjectableMetadata(target: Function): boolean;
|
|
87
84
|
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
85
|
+
interface InjectableOptions {
|
|
86
|
+
/**
|
|
87
|
+
* Lifetime of this injectable.
|
|
88
|
+
* @default 'scope'
|
|
89
|
+
*/
|
|
90
|
+
lifetime?: Lifetime;
|
|
91
|
+
/**
|
|
92
|
+
* Explicit list of constructor dependencies, in the same order as the constructor parameters.
|
|
93
|
+
* Each entry is either a class constructor or a Token created with token().
|
|
94
|
+
*
|
|
95
|
+
* This replaces reflect-metadata / emitDecoratorMetadata entirely.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* @Injectable({ lifetime: 'singleton', deps: [MyRepo, DB_URL] })
|
|
99
|
+
* class MyService {
|
|
100
|
+
* constructor(private repo: MyRepo, private dbUrl: string) {}
|
|
101
|
+
* }
|
|
102
|
+
*/
|
|
103
|
+
deps?: ReadonlyArray<TokenKey>;
|
|
104
|
+
}
|
|
100
105
|
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
106
|
+
* Marks a class as injectable into the Noxus DI container.
|
|
107
|
+
*
|
|
108
|
+
* Unlike the v2 @Injectable, this decorator:
|
|
109
|
+
* - Does NOT require reflect-metadata or emitDecoratorMetadata.
|
|
110
|
+
* - Requires you to declare deps explicitly when the class has constructor parameters.
|
|
111
|
+
* - Supports standalone usage — no module declaration needed.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* // No dependencies
|
|
115
|
+
* @Injectable()
|
|
116
|
+
* class Logger {}
|
|
117
|
+
*
|
|
118
|
+
* // With dependencies
|
|
119
|
+
* @Injectable({ lifetime: 'singleton', deps: [Logger, MyRepo] })
|
|
120
|
+
* class MyService {
|
|
121
|
+
* constructor(private logger: Logger, private repo: MyRepo) {}
|
|
122
|
+
* }
|
|
123
|
+
*
|
|
124
|
+
* // With a named token
|
|
125
|
+
* const DB_URL = token<string>('DB_URL');
|
|
103
126
|
*
|
|
104
|
-
* @
|
|
127
|
+
* @Injectable({ deps: [DB_URL] })
|
|
128
|
+
* class DbService {
|
|
129
|
+
* constructor(private url: string) {}
|
|
130
|
+
* }
|
|
105
131
|
*/
|
|
106
|
-
declare function
|
|
132
|
+
declare function Injectable(options?: InjectableOptions): ClassDecorator;
|
|
107
133
|
|
|
108
134
|
/**
|
|
109
135
|
* Logger is a utility class for logging messages to the console.
|
|
@@ -206,4 +232,4 @@ declare namespace Logger {
|
|
|
206
232
|
};
|
|
207
233
|
}
|
|
208
234
|
|
|
209
|
-
export { BadGatewayException, BadRequestException, ConflictException, ForbiddenException, GatewayTimeoutException, HttpVersionNotSupportedException,
|
|
235
|
+
export { BadGatewayException, BadRequestException, ConflictException, ForbiddenException, GatewayTimeoutException, HttpVersionNotSupportedException, Injectable, type InjectableOptions, InsufficientStorageException, InternalServerException, Lifetime, type LogLevel, Logger, LoopDetectedException, MethodNotAllowedException, NetworkAuthenticationRequiredException, NetworkConnectTimeoutException, NotAcceptableException, NotExtendedException, NotFoundException, NotImplementedException, PaymentRequiredException, RequestTimeoutException, ResponseException, ServiceUnavailableException, TokenKey, TooManyRequestsException, UnauthorizedException, UpgradeRequiredException, VariantAlsoNegotiatesException };
|