@noxfly/noxus 2.5.0 → 3.0.0-dev.1

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 (58) hide show
  1. package/README.md +405 -340
  2. package/dist/app-injector-Bz3Upc0y.d.mts +125 -0
  3. package/dist/app-injector-Bz3Upc0y.d.ts +125 -0
  4. package/dist/child.d.mts +157 -23
  5. package/dist/child.d.ts +157 -23
  6. package/dist/child.js +1111 -1341
  7. package/dist/child.mjs +1086 -1294
  8. package/dist/main.d.mts +720 -284
  9. package/dist/main.d.ts +720 -284
  10. package/dist/main.js +1471 -1650
  11. package/dist/main.mjs +1409 -1559
  12. package/dist/preload.d.mts +28 -0
  13. package/dist/preload.d.ts +28 -0
  14. package/dist/preload.js +95 -0
  15. package/dist/preload.mjs +70 -0
  16. package/dist/renderer.d.mts +159 -22
  17. package/dist/renderer.d.ts +159 -22
  18. package/dist/renderer.js +104 -177
  19. package/dist/renderer.mjs +100 -172
  20. package/dist/request-BlTtiHbi.d.ts +112 -0
  21. package/dist/request-qJ9EiDZc.d.mts +112 -0
  22. package/package.json +24 -19
  23. package/src/DI/app-injector.ts +95 -106
  24. package/src/DI/injector-explorer.ts +93 -119
  25. package/src/DI/token.ts +53 -0
  26. package/src/decorators/controller.decorator.ts +38 -27
  27. package/src/decorators/guards.decorator.ts +5 -64
  28. package/src/decorators/injectable.decorator.ts +68 -15
  29. package/src/decorators/method.decorator.ts +40 -81
  30. package/src/decorators/middleware.decorator.ts +5 -72
  31. package/src/index.ts +4 -5
  32. package/src/internal/app.ts +217 -0
  33. package/src/internal/bootstrap.ts +108 -0
  34. package/src/{preload-bridge.ts → internal/preload-bridge.ts} +1 -1
  35. package/src/{renderer-client.ts → internal/renderer-client.ts} +2 -2
  36. package/src/{renderer-events.ts → internal/renderer-events.ts} +1 -1
  37. package/src/{request.ts → internal/request.ts} +3 -3
  38. package/src/internal/router.ts +353 -0
  39. package/src/internal/routes.ts +78 -0
  40. package/src/{socket.ts → internal/socket.ts} +4 -4
  41. package/src/main.ts +10 -14
  42. package/src/non-electron-process.ts +1 -2
  43. package/src/preload.ts +10 -0
  44. package/src/renderer.ts +13 -0
  45. package/src/window/window-manager.ts +255 -0
  46. package/tsconfig.json +5 -10
  47. package/tsup.config.ts +29 -13
  48. package/dist/app-injector-B3MvgV3k.d.mts +0 -95
  49. package/dist/app-injector-B3MvgV3k.d.ts +0 -95
  50. package/dist/request-CdpZ9qZL.d.ts +0 -167
  51. package/dist/request-Dx_5Prte.d.mts +0 -167
  52. package/src/app.ts +0 -244
  53. package/src/bootstrap.ts +0 -84
  54. package/src/decorators/inject.decorator.ts +0 -24
  55. package/src/decorators/injectable.metadata.ts +0 -15
  56. package/src/decorators/module.decorator.ts +0 -75
  57. package/src/router.ts +0 -594
  58. /package/src/{exceptions.ts → internal/exceptions.ts} +0 -0
@@ -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,11 +1,119 @@
1
- import { L as Lifetime } from './app-injector-B3MvgV3k.mjs';
2
- export { A as AppInjector, F as ForwardRefFn, a as ForwardReference, I as IBinding, M as MaybeAsync, R as RootInjector, T as Type, f as forwardRef, i as inject } from './app-injector-B3MvgV3k.mjs';
3
-
4
1
  /**
5
2
  * @copyright 2025 NoxFly
6
3
  * @license MIT
7
4
  * @author NoxFly
8
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
+ * The key used to look up a class token in the registry.
59
+ * For class tokens, the key is the class constructor itself.
60
+ * For named tokens, the key is the Token instance.
61
+ */
62
+ type TokenKey<T = unknown> = Type<T> | Token<T>;
63
+
64
+
65
+ /**
66
+ * Lifetime of a binding in the DI container.
67
+ * - singleton: created once, shared for the lifetime of the app.
68
+ * - scope: created once per request scope.
69
+ * - transient: new instance every time it is resolved.
70
+ */
71
+ type Lifetime = 'singleton' | 'scope' | 'transient';
72
+ /**
73
+ * Internal representation of a registered binding.
74
+ */
75
+ interface IBinding<T = unknown> {
76
+ lifetime: Lifetime;
77
+ implementation: Type<T>;
78
+ /** Explicit constructor dependencies, declared by the class itself. */
79
+ deps: ReadonlyArray<TokenKey>;
80
+ instance?: T;
81
+ }
82
+ /**
83
+ * AppInjector is the core DI container.
84
+ * It no longer uses reflect-metadata — all dependency information
85
+ * comes from explicitly declared `deps` arrays on each binding.
86
+ */
87
+ declare class AppInjector {
88
+ readonly name: string | null;
89
+ readonly bindings: Map<Type<unknown> | Token<unknown>, IBinding<unknown>>;
90
+ readonly singletons: Map<Type<unknown> | Token<unknown>, unknown>;
91
+ readonly scoped: Map<Type<unknown> | Token<unknown>, unknown>;
92
+ constructor(name?: string | null);
93
+ /**
94
+ * Creates a child scope for per-request lifetime resolution.
95
+ */
96
+ createScope(): AppInjector;
97
+ /**
98
+ * Registers a binding explicitly.
99
+ */
100
+ register<T>(key: TokenKey<T>, implementation: Type<T>, lifetime: Lifetime, deps?: ReadonlyArray<TokenKey>): void;
101
+ /**
102
+ * Resolves a dependency by token or class reference.
103
+ */
104
+ resolve<T>(target: TokenKey<T> | ForwardReference<T>): T;
105
+ private _resolveForwardRef;
106
+ private _instantiate;
107
+ }
108
+ /**
109
+ * The global root injector. All singletons live here.
110
+ */
111
+ declare const RootInjector: AppInjector;
112
+ /**
113
+ * Convenience function: resolve a token from the root injector.
114
+ */
115
+ declare function inject<T>(t: TokenKey<T> | ForwardReference<T>): T;
116
+
9
117
  declare class ResponseException extends Error {
10
118
  readonly status: number;
11
119
  constructor(message?: string);
@@ -81,29 +189,55 @@ declare class NetworkConnectTimeoutException extends ResponseException {
81
189
  readonly status = 599;
82
190
  }
83
191
 
84
- declare const INJECTABLE_METADATA_KEY: unique symbol;
85
- declare function getInjectableMetadata(target: Function): Lifetime | undefined;
86
- declare function hasInjectableMetadata(target: Function): boolean;
87
-
88
192
 
193
+ interface InjectableOptions {
194
+ /**
195
+ * Lifetime of this injectable.
196
+ * @default 'scope'
197
+ */
198
+ lifetime?: Lifetime;
199
+ /**
200
+ * Explicit list of constructor dependencies, in the same order as the constructor parameters.
201
+ * Each entry is either a class constructor or a Token created with token().
202
+ *
203
+ * This replaces reflect-metadata / emitDecoratorMetadata entirely.
204
+ *
205
+ * @example
206
+ * @Injectable({ lifetime: 'singleton', deps: [MyRepo, DB_URL] })
207
+ * class MyService {
208
+ * constructor(private repo: MyRepo, private dbUrl: string) {}
209
+ * }
210
+ */
211
+ deps?: ReadonlyArray<TokenKey>;
212
+ }
89
213
  /**
90
- * The Injectable decorator marks a class as injectable.
91
- * It allows the class to be registered in the dependency injection system.
92
- * A class decorated with @Injectable can be injected into other classes
93
- * either from the constructor of the class that needs it of from the `inject` function.
94
- * @param lifetime - The lifetime of the injectable. Can be 'singleton', 'scope', or 'transient'.
95
- */
96
- declare function Injectable(lifetime?: Lifetime): ClassDecorator;
97
-
98
-
99
- declare const INJECT_METADATA_KEY = "custom:inject";
100
- /**
101
- * Decorator to manually inject a dependency.
102
- * Useful for handling circular dependencies with `forwardRef` or injecting specific tokens.
214
+ * Marks a class as injectable into the Noxus DI container.
215
+ *
216
+ * Unlike the v2 @Injectable, this decorator:
217
+ * - Does NOT require reflect-metadata or emitDecoratorMetadata.
218
+ * - Requires you to declare deps explicitly when the class has constructor parameters.
219
+ * - Supports standalone usage — no module declaration needed.
220
+ *
221
+ * @example
222
+ * // No dependencies
223
+ * @Injectable()
224
+ * class Logger {}
225
+ *
226
+ * // With dependencies
227
+ * @Injectable({ lifetime: 'singleton', deps: [Logger, MyRepo] })
228
+ * class MyService {
229
+ * constructor(private logger: Logger, private repo: MyRepo) {}
230
+ * }
231
+ *
232
+ * // With a named token
233
+ * const DB_URL = token<string>('DB_URL');
103
234
  *
104
- * @param token The token or forward reference to inject.
235
+ * @Injectable({ deps: [DB_URL] })
236
+ * class DbService {
237
+ * constructor(private url: string) {}
238
+ * }
105
239
  */
106
- declare function Inject(token: any): ParameterDecorator;
240
+ declare function Injectable(options?: InjectableOptions): ClassDecorator;
107
241
 
108
242
  /**
109
243
  * Logger is a utility class for logging messages to the console.
@@ -206,4 +340,4 @@ declare namespace Logger {
206
340
  };
207
341
  }
208
342
 
209
- export { BadGatewayException, BadRequestException, ConflictException, ForbiddenException, GatewayTimeoutException, HttpVersionNotSupportedException, INJECTABLE_METADATA_KEY, INJECT_METADATA_KEY, Inject, Injectable, InsufficientStorageException, InternalServerException, Lifetime, type LogLevel, Logger, LoopDetectedException, MethodNotAllowedException, NetworkAuthenticationRequiredException, NetworkConnectTimeoutException, NotAcceptableException, NotExtendedException, NotFoundException, NotImplementedException, PaymentRequiredException, RequestTimeoutException, ResponseException, ServiceUnavailableException, TooManyRequestsException, UnauthorizedException, UpgradeRequiredException, VariantAlsoNegotiatesException, getInjectableMetadata, hasInjectableMetadata };
343
+ export { AppInjector, BadGatewayException, BadRequestException, ConflictException, ForbiddenException, type ForwardRefFn, ForwardReference, GatewayTimeoutException, HttpVersionNotSupportedException, type IBinding, Injectable, type InjectableOptions, InsufficientStorageException, InternalServerException, type Lifetime, type LogLevel, Logger, LoopDetectedException, type MaybeAsync, MethodNotAllowedException, NetworkAuthenticationRequiredException, NetworkConnectTimeoutException, NotAcceptableException, NotExtendedException, NotFoundException, NotImplementedException, PaymentRequiredException, RequestTimeoutException, ResponseException, RootInjector, ServiceUnavailableException, Token, type TokenKey, TooManyRequestsException, type Type, UnauthorizedException, UpgradeRequiredException, VariantAlsoNegotiatesException, forwardRef, inject };
package/dist/child.d.ts CHANGED
@@ -1,11 +1,119 @@
1
- import { L as Lifetime } from './app-injector-B3MvgV3k.js';
2
- export { A as AppInjector, F as ForwardRefFn, a as ForwardReference, I as IBinding, M as MaybeAsync, R as RootInjector, T as Type, f as forwardRef, i as inject } from './app-injector-B3MvgV3k.js';
3
-
4
1
  /**
5
2
  * @copyright 2025 NoxFly
6
3
  * @license MIT
7
4
  * @author NoxFly
8
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
+ * The key used to look up a class token in the registry.
59
+ * For class tokens, the key is the class constructor itself.
60
+ * For named tokens, the key is the Token instance.
61
+ */
62
+ type TokenKey<T = unknown> = Type<T> | Token<T>;
63
+
64
+
65
+ /**
66
+ * Lifetime of a binding in the DI container.
67
+ * - singleton: created once, shared for the lifetime of the app.
68
+ * - scope: created once per request scope.
69
+ * - transient: new instance every time it is resolved.
70
+ */
71
+ type Lifetime = 'singleton' | 'scope' | 'transient';
72
+ /**
73
+ * Internal representation of a registered binding.
74
+ */
75
+ interface IBinding<T = unknown> {
76
+ lifetime: Lifetime;
77
+ implementation: Type<T>;
78
+ /** Explicit constructor dependencies, declared by the class itself. */
79
+ deps: ReadonlyArray<TokenKey>;
80
+ instance?: T;
81
+ }
82
+ /**
83
+ * AppInjector is the core DI container.
84
+ * It no longer uses reflect-metadata — all dependency information
85
+ * comes from explicitly declared `deps` arrays on each binding.
86
+ */
87
+ declare class AppInjector {
88
+ readonly name: string | null;
89
+ readonly bindings: Map<Type<unknown> | Token<unknown>, IBinding<unknown>>;
90
+ readonly singletons: Map<Type<unknown> | Token<unknown>, unknown>;
91
+ readonly scoped: Map<Type<unknown> | Token<unknown>, unknown>;
92
+ constructor(name?: string | null);
93
+ /**
94
+ * Creates a child scope for per-request lifetime resolution.
95
+ */
96
+ createScope(): AppInjector;
97
+ /**
98
+ * Registers a binding explicitly.
99
+ */
100
+ register<T>(key: TokenKey<T>, implementation: Type<T>, lifetime: Lifetime, deps?: ReadonlyArray<TokenKey>): void;
101
+ /**
102
+ * Resolves a dependency by token or class reference.
103
+ */
104
+ resolve<T>(target: TokenKey<T> | ForwardReference<T>): T;
105
+ private _resolveForwardRef;
106
+ private _instantiate;
107
+ }
108
+ /**
109
+ * The global root injector. All singletons live here.
110
+ */
111
+ declare const RootInjector: AppInjector;
112
+ /**
113
+ * Convenience function: resolve a token from the root injector.
114
+ */
115
+ declare function inject<T>(t: TokenKey<T> | ForwardReference<T>): T;
116
+
9
117
  declare class ResponseException extends Error {
10
118
  readonly status: number;
11
119
  constructor(message?: string);
@@ -81,29 +189,55 @@ declare class NetworkConnectTimeoutException extends ResponseException {
81
189
  readonly status = 599;
82
190
  }
83
191
 
84
- declare const INJECTABLE_METADATA_KEY: unique symbol;
85
- declare function getInjectableMetadata(target: Function): Lifetime | undefined;
86
- declare function hasInjectableMetadata(target: Function): boolean;
87
-
88
192
 
193
+ interface InjectableOptions {
194
+ /**
195
+ * Lifetime of this injectable.
196
+ * @default 'scope'
197
+ */
198
+ lifetime?: Lifetime;
199
+ /**
200
+ * Explicit list of constructor dependencies, in the same order as the constructor parameters.
201
+ * Each entry is either a class constructor or a Token created with token().
202
+ *
203
+ * This replaces reflect-metadata / emitDecoratorMetadata entirely.
204
+ *
205
+ * @example
206
+ * @Injectable({ lifetime: 'singleton', deps: [MyRepo, DB_URL] })
207
+ * class MyService {
208
+ * constructor(private repo: MyRepo, private dbUrl: string) {}
209
+ * }
210
+ */
211
+ deps?: ReadonlyArray<TokenKey>;
212
+ }
89
213
  /**
90
- * The Injectable decorator marks a class as injectable.
91
- * It allows the class to be registered in the dependency injection system.
92
- * A class decorated with @Injectable can be injected into other classes
93
- * either from the constructor of the class that needs it of from the `inject` function.
94
- * @param lifetime - The lifetime of the injectable. Can be 'singleton', 'scope', or 'transient'.
95
- */
96
- declare function Injectable(lifetime?: Lifetime): ClassDecorator;
97
-
98
-
99
- declare const INJECT_METADATA_KEY = "custom:inject";
100
- /**
101
- * Decorator to manually inject a dependency.
102
- * Useful for handling circular dependencies with `forwardRef` or injecting specific tokens.
214
+ * Marks a class as injectable into the Noxus DI container.
215
+ *
216
+ * Unlike the v2 @Injectable, this decorator:
217
+ * - Does NOT require reflect-metadata or emitDecoratorMetadata.
218
+ * - Requires you to declare deps explicitly when the class has constructor parameters.
219
+ * - Supports standalone usage — no module declaration needed.
220
+ *
221
+ * @example
222
+ * // No dependencies
223
+ * @Injectable()
224
+ * class Logger {}
225
+ *
226
+ * // With dependencies
227
+ * @Injectable({ lifetime: 'singleton', deps: [Logger, MyRepo] })
228
+ * class MyService {
229
+ * constructor(private logger: Logger, private repo: MyRepo) {}
230
+ * }
231
+ *
232
+ * // With a named token
233
+ * const DB_URL = token<string>('DB_URL');
103
234
  *
104
- * @param token The token or forward reference to inject.
235
+ * @Injectable({ deps: [DB_URL] })
236
+ * class DbService {
237
+ * constructor(private url: string) {}
238
+ * }
105
239
  */
106
- declare function Inject(token: any): ParameterDecorator;
240
+ declare function Injectable(options?: InjectableOptions): ClassDecorator;
107
241
 
108
242
  /**
109
243
  * Logger is a utility class for logging messages to the console.
@@ -206,4 +340,4 @@ declare namespace Logger {
206
340
  };
207
341
  }
208
342
 
209
- export { BadGatewayException, BadRequestException, ConflictException, ForbiddenException, GatewayTimeoutException, HttpVersionNotSupportedException, INJECTABLE_METADATA_KEY, INJECT_METADATA_KEY, Inject, Injectable, InsufficientStorageException, InternalServerException, Lifetime, type LogLevel, Logger, LoopDetectedException, MethodNotAllowedException, NetworkAuthenticationRequiredException, NetworkConnectTimeoutException, NotAcceptableException, NotExtendedException, NotFoundException, NotImplementedException, PaymentRequiredException, RequestTimeoutException, ResponseException, ServiceUnavailableException, TooManyRequestsException, UnauthorizedException, UpgradeRequiredException, VariantAlsoNegotiatesException, getInjectableMetadata, hasInjectableMetadata };
343
+ export { AppInjector, BadGatewayException, BadRequestException, ConflictException, ForbiddenException, type ForwardRefFn, ForwardReference, GatewayTimeoutException, HttpVersionNotSupportedException, type IBinding, Injectable, type InjectableOptions, InsufficientStorageException, InternalServerException, type Lifetime, type LogLevel, Logger, LoopDetectedException, type MaybeAsync, MethodNotAllowedException, NetworkAuthenticationRequiredException, NetworkConnectTimeoutException, NotAcceptableException, NotExtendedException, NotFoundException, NotImplementedException, PaymentRequiredException, RequestTimeoutException, ResponseException, RootInjector, ServiceUnavailableException, Token, type TokenKey, TooManyRequestsException, type Type, UnauthorizedException, UpgradeRequiredException, VariantAlsoNegotiatesException, forwardRef, inject };