@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
package/dist/main.d.mts CHANGED
@@ -1,402 +1,838 @@
1
- import { M as MaybeAsync, T as Type } from './app-injector-B3MvgV3k.mjs';
2
- export { A as AppInjector, F as ForwardRefFn, a as ForwardReference, I as IBinding, L as Lifetime, R as RootInjector, f as forwardRef, i as inject } from './app-injector-B3MvgV3k.mjs';
3
- import { R as Request, a as IResponse, h as IGuard } from './request-Dx_5Prte.mjs';
4
- export { A as AtomicHttpMethod, j as Authorize, D as Delete, G as Get, H as HttpMethod, c as IBatchRequestItem, e as IBatchRequestPayload, d as IBatchResponsePayload, I as IRendererEventMessage, b as IRequest, m as IRouteMetadata, p as Patch, P as Post, o as Put, f as RENDERER_EVENT_TYPE, q as ROUTE_METADATA_KEY, g as createRendererEventMessage, k as getGuardForController, l as getGuardForControllerAction, n as getRouteMetadata, i as isRendererEventMessage } from './request-Dx_5Prte.mjs';
5
1
  import { BrowserWindow } from 'electron/main';
6
- export { BadGatewayException, BadRequestException, ConflictException, ForbiddenException, GatewayTimeoutException, HttpVersionNotSupportedException, INJECTABLE_METADATA_KEY, INJECT_METADATA_KEY, Inject, Injectable, InsufficientStorageException, InternalServerException, LogLevel, Logger, LoopDetectedException, MethodNotAllowedException, NetworkAuthenticationRequiredException, NetworkConnectTimeoutException, NotAcceptableException, NotExtendedException, NotFoundException, NotImplementedException, PaymentRequiredException, RequestTimeoutException, ResponseException, ServiceUnavailableException, TooManyRequestsException, UnauthorizedException, UpgradeRequiredException, VariantAlsoNegotiatesException, getInjectableMetadata, hasInjectableMetadata } from './child.mjs';
7
2
 
8
3
  /**
9
4
  * @copyright 2025 NoxFly
10
5
  * @license MIT
11
6
  * @author NoxFly
12
7
  */
8
+ interface Type<T> extends Function {
9
+ new (...args: any[]): T;
10
+ }
11
+ /**
12
+ * Represents a generic type that can be either a value or a promise resolving to that value.
13
+ */
14
+ type MaybeAsync<T> = T | Promise<T>;
15
+
13
16
 
14
17
  /**
15
- * NextFunction is a function that is called to continue the middleware chain.
16
- * It returns an Promise that emits when the next middleware is done.
18
+ * A function that returns a type.
19
+ * Used for forward references to types that are not yet defined.
17
20
  */
18
- type NextFunction = () => Promise<void>;
21
+ interface ForwardRefFn<T = any> {
22
+ (): Type<T>;
23
+ }
24
+ /**
25
+ * A wrapper class for forward referenced types.
26
+ */
27
+ declare class ForwardReference<T = any> {
28
+ readonly forwardRefFn: ForwardRefFn<T>;
29
+ constructor(forwardRefFn: ForwardRefFn<T>);
30
+ }
19
31
  /**
20
- * IMiddleware interface defines a middleware that can be used in the application.
21
- * It has an `invoke` method that takes a request, a response, and a next function.
22
- * The `invoke` method can return a MaybeAsync, which means it can return either a value or a Promise.
32
+ * Creates a forward reference to a type.
33
+ * @param fn A function that returns the type.
34
+ * @returns A ForwardReference instance.
35
+ */
36
+ declare function forwardRef<T = any>(fn: ForwardRefFn<T>): ForwardReference<T>;
37
+
38
+
39
+ /**
40
+ * A DI token uniquely identifies a dependency.
41
+ * It can wrap a class (Type<T>) or be a named symbol token.
23
42
  *
24
- * Use it on a class that should be registered as a middleware in the application.
43
+ * Using tokens instead of reflect-metadata means dependencies are
44
+ * declared explicitly — no magic type inference, no emitDecoratorMetadata.
45
+ *
46
+ * @example
47
+ * // Class token (most common)
48
+ * const MY_SERVICE = token(MyService);
49
+ *
50
+ * // Named symbol token (for interfaces or non-class values)
51
+ * const DB_URL = token<string>('DB_URL');
25
52
  */
26
- interface IMiddleware {
27
- invoke(request: Request, response: IResponse, next: NextFunction): MaybeAsync<void>;
53
+ declare class Token<T> {
54
+ readonly target: Type<T> | string;
55
+ readonly description: string;
56
+ constructor(target: Type<T> | string);
57
+ toString(): string;
28
58
  }
29
59
  /**
30
- * UseMiddlewares decorator can be used to register middlewares for a controller or a controller action.
60
+ * Creates a DI token for a class type or a named value.
31
61
  *
32
- * @param mdlw - The middlewares list to register for the controller or the controller action.
62
+ * @example
63
+ * export const MY_SERVICE = token(MyService);
64
+ * export const DB_URL = token<string>('DB_URL');
65
+ */
66
+ declare function token<T>(target: Type<T> | string): Token<T>;
67
+ /**
68
+ * The key used to look up a class token in the registry.
69
+ * For class tokens, the key is the class constructor itself.
70
+ * For named tokens, the key is the Token instance.
33
71
  */
34
- declare function UseMiddlewares(mdlw: Type<IMiddleware>[]): ClassDecorator & MethodDecorator;
72
+ type TokenKey<T = unknown> = Type<T> | Token<T>;
73
+
74
+
35
75
  /**
36
- * Gets the middlewares for a controller or a controller action.
37
- * This function retrieves the middlewares registered with the UseMiddlewares decorator.
38
- * It returns an array of middleware classes that can be used to process requests for the specified controller.
39
- * @param controllerName The name of the controller to get the middlewares for.
40
- * @returns An array of middlewares for the controller.
76
+ * Lifetime of a binding in the DI container.
77
+ * - singleton: created once, shared for the lifetime of the app.
78
+ * - scope: created once per request scope.
79
+ * - transient: new instance every time it is resolved.
41
80
  */
42
- declare function getMiddlewaresForController(controllerName: string): Type<IMiddleware>[];
81
+ type Lifetime = 'singleton' | 'scope' | 'transient';
82
+ /**
83
+ * Internal representation of a registered binding.
84
+ */
85
+ interface IBinding<T = unknown> {
86
+ lifetime: Lifetime;
87
+ implementation: Type<T>;
88
+ /** Explicit constructor dependencies, declared by the class itself. */
89
+ deps: ReadonlyArray<TokenKey>;
90
+ instance?: T;
91
+ }
43
92
  /**
44
- * Gets the middlewares for a controller action.
45
- * This function retrieves the middlewares registered with the UseMiddlewares decorator for a specific action in a controller.
46
- * It returns an array of middleware classes that can be used to process requests for the specified controller action.
47
- * @param controllerName The name of the controller to get the middlewares for.
48
- * @param actionName The name of the action to get the middlewares for.
49
- * @returns An array of middlewares for the controller action.
93
+ * AppInjector is the core DI container.
94
+ * It no longer uses reflect-metadata all dependency information
95
+ * comes from explicitly declared `deps` arrays on each binding.
50
96
  */
51
- declare function getMiddlewaresForControllerAction(controllerName: string, actionName: string): Type<IMiddleware>[];
97
+ declare class AppInjector {
98
+ readonly name: string | null;
99
+ readonly bindings: Map<Type<unknown> | Token<unknown>, IBinding<unknown>>;
100
+ readonly singletons: Map<Type<unknown> | Token<unknown>, unknown>;
101
+ readonly scoped: Map<Type<unknown> | Token<unknown>, unknown>;
102
+ constructor(name?: string | null);
103
+ /**
104
+ * Creates a child scope for per-request lifetime resolution.
105
+ */
106
+ createScope(): AppInjector;
107
+ /**
108
+ * Registers a binding explicitly.
109
+ */
110
+ register<T>(key: TokenKey<T>, implementation: Type<T>, lifetime: Lifetime, deps?: ReadonlyArray<TokenKey>): void;
111
+ /**
112
+ * Resolves a dependency by token or class reference.
113
+ */
114
+ resolve<T>(target: TokenKey<T> | ForwardReference<T>): T;
115
+ private _resolveForwardRef;
116
+ private _instantiate;
117
+ }
118
+ /**
119
+ * The global root injector. All singletons live here.
120
+ */
121
+ declare const RootInjector: AppInjector;
122
+ /**
123
+ * Convenience function: resolve a token from the root injector.
124
+ */
125
+ declare function inject<T>(t: TokenKey<T> | ForwardReference<T>): T;
52
126
 
53
127
 
54
128
  /**
55
- * A lazy route entry maps a path prefix to a dynamic import function.
56
- * The module is loaded on the first request matching the prefix.
129
+ * A middleware intercepts requests before they reach guards and the handler.
130
+ * Implement this interface and pass the class to @Controller({ middlewares }) or per-route options.
57
131
  */
58
- interface ILazyRoute {
59
- /** Path prefix (e.g. "auth", "printing"). Matched against the first segment(s) of the request path. */
132
+ type Middleware = (request: Request, response: IResponse, next: NextFunction) => MaybeAsync<void>;
133
+ type NextFunction = () => Promise<void>;
134
+
135
+
136
+ type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'BATCH';
137
+ type AtomicHttpMethod = Exclude<HttpMethod, 'BATCH'>;
138
+ declare function isAtomicHttpMethod(m: unknown): m is AtomicHttpMethod;
139
+ interface IRouteOptions {
140
+ /**
141
+ * Guards specific to this route (merged with controller guards).
142
+ */
143
+ guards?: Guard[];
144
+ /**
145
+ * Middlewares specific to this route (merged with controller middlewares).
146
+ */
147
+ middlewares?: Middleware[];
148
+ }
149
+ interface IRouteMetadata {
150
+ method: HttpMethod;
60
151
  path: string;
61
- /** Dynamic import function returning the module file. */
62
- loadModule: () => Promise<unknown>;
152
+ handler: string;
153
+ guards: Guard[];
154
+ middlewares: Middleware[];
63
155
  }
156
+ declare function getRouteMetadata(target: object): IRouteMetadata[];
157
+ declare const Get: (path: string, options?: IRouteOptions) => MethodDecorator;
158
+ declare const Post: (path: string, options?: IRouteOptions) => MethodDecorator;
159
+ declare const Put: (path: string, options?: IRouteOptions) => MethodDecorator;
160
+ declare const Patch: (path: string, options?: IRouteOptions) => MethodDecorator;
161
+ declare const Delete: (path: string, options?: IRouteOptions) => MethodDecorator;
162
+
163
+
64
164
  /**
65
- * IRouteDefinition interface defines the structure of a route in the application.
66
- * It includes the HTTP method, path, controller class, handler method name,
67
- * guards, and middlewares associated with the route.
165
+ * The Request class represents an HTTP request in the Noxus framework.
166
+ * It encapsulates the request data, including the event, ID, method, path, and body.
167
+ * It also provides a context for dependency injection through the AppInjector.
68
168
  */
69
- interface IRouteDefinition {
70
- method: string;
169
+ declare class Request {
170
+ readonly event: Electron.MessageEvent;
171
+ readonly senderId: number;
172
+ readonly id: string;
173
+ readonly method: HttpMethod;
174
+ readonly path: string;
175
+ readonly body: any;
176
+ readonly context: AppInjector;
177
+ readonly params: Record<string, string>;
178
+ constructor(event: Electron.MessageEvent, senderId: number, id: string, method: HttpMethod, path: string, body: any);
179
+ }
180
+ /**
181
+ * The IRequest interface defines the structure of a request object.
182
+ * It includes properties for the sender ID, request ID, path, method, and an optional body.
183
+ * This interface is used to standardize the request data across the application.
184
+ */
185
+ interface IRequest<TBody = unknown> {
186
+ senderId: number;
187
+ requestId: string;
71
188
  path: string;
72
- controller: Type<any>;
73
- handler: string;
74
- guards: Type<IGuard>[];
75
- middlewares: Type<IMiddleware>[];
189
+ method: HttpMethod;
190
+ body?: TBody;
191
+ }
192
+ interface IBatchRequestItem<TBody = unknown> {
193
+ requestId?: string;
194
+ path: string;
195
+ method: AtomicHttpMethod;
196
+ body?: TBody;
197
+ }
198
+ interface IBatchRequestPayload {
199
+ requests: IBatchRequestItem[];
76
200
  }
77
201
  /**
78
- * This type defines a function that represents an action in a controller.
79
- * It takes a Request and an IResponse as parameters and returns a value or a Promise.
202
+ * Creates a Request object from the IPC event data.
203
+ * This function extracts the necessary information from the IPC event and constructs a Request instance.
80
204
  */
81
- type ControllerAction = (request: Request, response: IResponse) => any;
205
+ interface IResponse<TBody = unknown> {
206
+ requestId: string;
207
+ status: number;
208
+ body?: TBody;
209
+ error?: string;
210
+ stack?: string;
211
+ }
212
+ interface IBatchResponsePayload {
213
+ responses: IResponse[];
214
+ }
215
+ declare const RENDERER_EVENT_TYPE = "noxus:event";
216
+ interface IRendererEventMessage<TPayload = unknown> {
217
+ type: typeof RENDERER_EVENT_TYPE;
218
+ event: string;
219
+ payload?: TPayload;
220
+ }
221
+ declare function createRendererEventMessage<TPayload = unknown>(event: string, payload?: TPayload): IRendererEventMessage<TPayload>;
222
+ declare function isRendererEventMessage(value: unknown): value is IRendererEventMessage;
223
+
224
+
82
225
  /**
83
- * Router class is responsible for managing the application's routing.
84
- * It registers controllers, handles requests, and manages middlewares and guards.
226
+ * A guard decides whether an incoming request should reach the handler.
227
+ * Implement this interface and pass the class to @Controller({ guards }) or @Get('path', { guards }).
85
228
  */
229
+ type Guard = (request: Request) => MaybeAsync<boolean>;
230
+
231
+
232
+ interface ILazyRoute {
233
+ load: () => Promise<unknown>;
234
+ guards: Guard[];
235
+ middlewares: Middleware[];
236
+ loading: Promise<void> | null;
237
+ loaded: boolean;
238
+ }
239
+ interface IRouteDefinition {
240
+ method: string;
241
+ path: string;
242
+ controller: Type<unknown>;
243
+ handler: string;
244
+ guards: Guard[];
245
+ middlewares: Middleware[];
246
+ }
247
+ type ControllerAction = (request: Request, response: IResponse) => unknown;
86
248
  declare class Router {
87
249
  private readonly routes;
88
250
  private readonly rootMiddlewares;
89
251
  private readonly lazyRoutes;
90
- /**
91
- * Registers a controller class with the router.
92
- * This method extracts the route metadata from the controller class and registers it in the routing tree.
93
- * It also handles the guards and middlewares associated with the controller.
94
- * @param controllerClass - The controller class to register.
95
- */
96
- registerController(controllerClass: Type<unknown>): Router;
97
- /**
98
- * Registers a lazy route. The module behind this route prefix will only
99
- * be imported (and its controllers/services registered in DI) the first
100
- * time a request targets this prefix.
101
- *
102
- * @param pathPrefix - Route prefix (e.g. "auth"). Matched against the first segment of the request path.
103
- * @param loadModule - A function that returns a dynamic import promise.
104
- */
105
- registerLazyRoute(pathPrefix: string, loadModule: () => Promise<unknown>): Router;
106
- /**
107
- * Defines a middleware for the root of the application.
108
- * This method allows you to register a middleware that will be applied to all requests
109
- * to the application, regardless of the controller or action.
110
- * @param middleware - The middleware class to register.
111
- */
112
- defineRootMiddleware(middleware: Type<IMiddleware>): Router;
113
- /**
114
- * Shuts down the message channel for a specific sender ID.
115
- * This method closes the IPC channel for the specified sender ID and
116
- * removes it from the messagePorts map.
117
- * @param channelSenderId - The ID of the sender channel to shut down.
118
- */
252
+ registerController(controllerClass: Type<unknown>, pathPrefix: string, routeGuards?: Guard[], routeMiddlewares?: Middleware[]): this;
253
+ registerLazyRoute(pathPrefix: string, load: () => Promise<unknown>, guards?: Guard[], middlewares?: Middleware[]): this;
254
+ defineRootMiddleware(middleware: Middleware): this;
119
255
  handle(request: Request): Promise<IResponse>;
120
256
  private handleAtomic;
121
257
  private handleBatch;
258
+ private tryFindRoute;
259
+ private findRoute;
260
+ private tryLoadLazyRoute;
261
+ private loadLazyModule;
262
+ private resolveController;
263
+ private runPipeline;
264
+ private runMiddleware;
265
+ private runGuard;
266
+ private extractParams;
122
267
  private normalizeBatchPayload;
123
268
  private normalizeBatchItem;
269
+ private fillErrorResponse;
270
+ private logResponse;
271
+ }
272
+
273
+
274
+ interface WindowConfig extends Electron.BrowserWindowConstructorOptions {
124
275
  /**
125
- * Finds the route definition for a given request.
126
- * This method searches the routing tree for a matching route based on the request's path and method.
127
- * If no matching route is found, it throws a NotFoundException.
128
- * @param request - The Request object containing the method and path to search for.
129
- * @returns The IRouteDefinition for the matched route.
130
- */
131
- /**
132
- * Attempts to find a route definition for the given request.
133
- * Returns undefined instead of throwing when the route is not found,
134
- * so the caller can try lazy-loading first.
276
+ * If true, the window expands to fill the work area after creation
277
+ * using an animated setBounds. The content is loaded only after
278
+ * the animation completes, preventing the viewbox freeze issue.
279
+ * @default false
135
280
  */
136
- private tryFindRoute;
281
+ expandToWorkArea?: boolean;
137
282
  /**
138
- * Finds the route definition for a given request.
139
- * If no eagerly-registered route matches, attempts to load a lazy module
140
- * whose prefix matches the request path, then retries.
283
+ * Duration in ms to wait for the setBounds animation to complete
284
+ * before loading content. Only used when expandToWorkArea is true.
285
+ * @default 600
141
286
  */
142
- private findRoute;
143
- /**
144
- * Given a request path, checks whether a lazy route prefix matches
145
- * and triggers the dynamic import if it hasn't been loaded yet.
146
- */
147
- private tryLoadLazyRoute;
287
+ expandAnimationDuration?: number;
288
+ }
289
+ interface WindowRecord {
290
+ window: BrowserWindow;
291
+ id: number;
292
+ }
293
+ /**
294
+ * WindowManager is a singleton service that centralizes BrowserWindow lifecycle.
295
+ *
296
+ * Features:
297
+ * - Creates and tracks all application windows.
298
+ * - Handles the animated expand-to-work-area pattern correctly,
299
+ * loading content only after the animation ends to avoid the viewbox freeze.
300
+ * - Provides convenience methods to get windows by id, get the main window, etc.
301
+ * - Automatically removes windows from the registry on close.
302
+ *
303
+ * @example
304
+ * // In your IApp.onReady():
305
+ * const wm = inject(WindowManager);
306
+ *
307
+ * const win = await wm.create({
308
+ * width: 600, height: 600, center: true,
309
+ * expandToWorkArea: true,
310
+ * webPreferences: { preload: path.join(__dirname, 'preload.js') },
311
+ * });
312
+ *
313
+ * win.loadFile('index.html');
314
+ */
315
+ declare class WindowManager {
316
+ private readonly _windows;
317
+ private _mainWindowId;
148
318
  /**
149
- * Dynamically imports a lazy module and registers its decorated classes
150
- * (controllers, services) in the DI container using the two-phase strategy.
319
+ * Creates a BrowserWindow, optionally performs an animated expand to the
320
+ * work area, and registers it in the manager.
321
+ *
322
+ * If expandToWorkArea is true:
323
+ * 1. The window is created at the given initial size (defaults to 600×600, centered).
324
+ * 2. An animated setBounds expands it to the full work area.
325
+ * 3. The returned promise resolves only after the animation, so callers
326
+ * can safely call win.loadFile() without the viewbox freeze.
327
+ *
328
+ * @param config Window configuration.
329
+ * @param isMain Mark this window as the main window (accessible via getMain()).
151
330
  */
152
- private loadLazyModule;
331
+ create(config: WindowConfig, isMain?: boolean): Promise<BrowserWindow>;
153
332
  /**
154
- * Resolves the controller for a given route definition.
155
- * This method creates an instance of the controller class and prepares the request parameters.
156
- * It also runs the request pipeline, which includes executing middlewares and guards.
157
- * @param request - The Request object containing the request data.
158
- * @param response - The IResponse object to populate with the response data.
159
- * @param routeDef - The IRouteDefinition for the matched route.
160
- * @return A Promise that resolves when the controller action has been executed.
161
- * @throws UnauthorizedException if the request is not authorized by the guards.
333
+ * Creates the initial "splash" window that is shown immediately after
334
+ * app.whenReady(). It is displayed instantly (show: true, no preload
335
+ * loading) and then expanded to the work area with animation.
336
+ *
337
+ * After the animation completes you can call win.loadFile() without
338
+ * experiencing the viewbox freeze.
339
+ *
340
+ * This is the recommended way to get pixels on screen as fast as possible.
341
+ *
342
+ * @example
343
+ * const win = await wm.createSplash({
344
+ * webPreferences: { preload: path.join(__dirname, 'preload.js') }
345
+ * });
346
+ * win.loadFile('index.html');
162
347
  */
163
- private resolveController;
348
+ createSplash(options?: Electron.BrowserWindowConstructorOptions & {
349
+ animationDuration?: number;
350
+ }): Promise<BrowserWindow>;
351
+ /** Returns all currently open windows. */
352
+ getAll(): BrowserWindow[];
353
+ /** Returns the window designated as main, or undefined. */
354
+ getMain(): BrowserWindow | undefined;
355
+ /** Returns a window by its Electron id, or undefined. */
356
+ getById(id: number): BrowserWindow | undefined;
357
+ /** Returns the number of open windows. */
358
+ get count(): number;
359
+ /** Closes and destroys a window by id. */
360
+ close(id: number): void;
361
+ /** Closes all windows. */
362
+ closeAll(): void;
164
363
  /**
165
- * Runs the request pipeline for a given request.
166
- * This method executes the middlewares and guards associated with the route,
167
- * and finally calls the controller action.
168
- * @param request - The Request object containing the request data.
169
- * @param response - The IResponse object to populate with the response data.
170
- * @param routeDef - The IRouteDefinition for the matched route.
171
- * @param controllerInstance - The instance of the controller class.
172
- * @return A Promise that resolves when the request pipeline has been executed.
173
- * @throws ResponseException if the response status is not successful.
174
- */
175
- private runRequestPipeline;
176
- /**
177
- * Runs a middleware function in the request pipeline.
178
- * This method creates an instance of the middleware and invokes its `invoke` method,
179
- * passing the request, response, and next function.
180
- * @param request - The Request object containing the request data.
181
- * @param response - The IResponse object to populate with the response data.
182
- * @param next - The NextFunction to call to continue the middleware chain.
183
- * @param middlewareType - The type of the middleware to run.
184
- * @return A Promise that resolves when the middleware has been executed.
364
+ * Sends a message to a specific window via webContents.send.
365
+ * @param id Target window id.
366
+ * @param channel IPC channel name.
367
+ * @param args Payload.
185
368
  */
186
- private runMiddleware;
369
+ send(id: number, channel: string, ...args: unknown[]): void;
187
370
  /**
188
- * Runs a guard to check if the request is authorized.
189
- * This method creates an instance of the guard and calls its `canActivate` method.
190
- * If the guard returns false, it throws an UnauthorizedException.
191
- * @param request - The Request object containing the request data.
192
- * @param guardType - The type of the guard to run.
193
- * @return A Promise that resolves if the guard allows the request, or throws an UnauthorizedException if not.
194
- * @throws UnauthorizedException if the guard denies access to the request.
371
+ * Broadcasts a message to all open windows.
195
372
  */
196
- private runGuard;
373
+ broadcast(channel: string, ...args: unknown[]): void;
374
+ private _register;
197
375
  /**
198
- * Extracts parameters from the actual request path based on the template path.
199
- * This method splits the actual path and the template path into segments,
200
- * then maps the segments to parameters based on the template.
201
- * @param actual - The actual request path.
202
- * @param template - The template path to extract parameters from.
203
- * @returns An object containing the extracted parameters.
376
+ * Animates the window to the full work area of the primary display.
377
+ * Resolves only after the animation is complete, so that content loaded
378
+ * afterward gets the correct surface size (no viewbox freeze).
204
379
  */
205
- private extractParams;
206
- }
207
-
208
- interface RendererChannels {
209
- request: Electron.MessageChannelMain;
210
- socket: Electron.MessageChannelMain;
211
- }
212
- declare class NoxSocket {
213
- private readonly channels;
214
- register(senderId: number, requestChannel: Electron.MessageChannelMain, socketChannel: Electron.MessageChannelMain): void;
215
- get(senderId: number): RendererChannels | undefined;
216
- unregister(senderId: number): void;
217
- getSenderIds(): number[];
218
- emit<TPayload = unknown>(eventName: string, payload?: TPayload, targetSenderIds?: number[]): number;
219
- emitToRenderer<TPayload = unknown>(senderId: number, eventName: string, payload?: TPayload): boolean;
380
+ private _expandToWorkArea;
220
381
  }
221
382
 
222
383
 
223
384
  /**
224
- * The application service should implement this interface, as
225
- * the NoxApp class instance will use it to notify the given service
226
- * about application lifecycle events.
385
+ * Your application service should implement IApp.
386
+ * Noxus calls these lifecycle methods at the appropriate time.
387
+ *
388
+ * Unlike v2, IApp no longer receives a BrowserWindow in onReady.
389
+ * Use the injected WindowManager instead — it is more flexible and
390
+ * does not couple the lifecycle to a single pre-created window.
391
+ *
392
+ * @example
393
+ * @Injectable({ lifetime: 'singleton', deps: [WindowManager, MyService] })
394
+ * class AppService implements IApp {
395
+ * constructor(private wm: WindowManager, private svc: MyService) {}
396
+ *
397
+ * async onReady() {
398
+ * const win = await this.wm.createSplash({ webPreferences: { preload: ... } });
399
+ * win.loadFile('index.html');
400
+ * }
401
+ *
402
+ * async onActivated() { ... }
403
+ * async dispose() { ... }
404
+ * }
227
405
  */
228
406
  interface IApp {
229
407
  dispose(): Promise<void>;
230
- onReady(mainWindow?: BrowserWindow): Promise<void>;
408
+ onReady(): Promise<void>;
231
409
  onActivated(): Promise<void>;
232
410
  }
233
- /**
234
- * NoxApp is the main application class that manages the application lifecycle,
235
- * handles IPC communication, and integrates with the Router.
236
- */
237
411
  declare class NoxApp {
412
+ private appService;
238
413
  private readonly router;
239
414
  private readonly socket;
240
- private app;
241
- private mainWindow;
415
+ readonly windowManager: WindowManager;
416
+ init(): Promise<this>;
242
417
  /**
418
+ * Registers a lazy route. The file behind this prefix is dynamically
419
+ * imported on the first IPC request that targets it.
243
420
  *
421
+ * The import function should NOT statically reference heavy modules —
422
+ * the whole point is to defer their loading.
423
+ *
424
+ * @example
425
+ * noxApp.lazy('auth', () => import('./modules/auth/auth.controller.js'));
426
+ * noxApp.lazy('reporting', () => import('./modules/reporting/index.js'));
244
427
  */
245
- private readonly onRendererMessage;
246
- constructor(router: Router, socket: NoxSocket);
247
- /**
248
- * Initializes the NoxApp instance.
249
- * This method sets up the IPC communication, registers event listeners,
250
- * and prepares the application for use.
251
- */
252
- init(): Promise<NoxApp>;
428
+ lazy(pathPrefix: string, load: () => Promise<unknown>, guards?: Guard[], middlewares?: Middleware[]): this;
253
429
  /**
254
- * Handles the request from the renderer process.
255
- * This method creates a Request object from the IPC event data,
256
- * processes it through the Router, and sends the response back
257
- * to the renderer process using the MessageChannel.
430
+ * Eagerly loads a set of modules (controllers + services) before start().
431
+ * Use this for modules that provide services needed by your IApp.onReady().
432
+ *
433
+ * All imports run in parallel; DI is flushed with the two-phase guarantee.
258
434
  */
259
- private giveTheRendererAPort;
435
+ load(importFns: Array<() => Promise<unknown>>): Promise<this>;
260
436
  /**
261
- * MacOS specific behavior.
437
+ * Registers a global middleware applied to every route.
262
438
  */
263
- private onAppActivated;
439
+ use(middleware: Middleware): this;
264
440
  /**
265
- * Shuts down the message channel for a specific sender ID.
266
- * This method closes the IPC channel for the specified sender ID and
267
- * removes it from the messagePorts map.
268
- * @param channelSenderId - The ID of the sender channel to shut down.
269
- * @param remove - Whether to remove the channel from the messagePorts map.
441
+ * Sets the application service (implements IApp) that receives lifecycle events.
442
+ * @param appClass - Class decorated with @Injectable that implements IApp.
270
443
  */
271
- private shutdownChannel;
444
+ configure(appClass: Type<IApp>): this;
272
445
  /**
273
- * Handles the application shutdown process.
274
- * This method is called when all windows are closed, and it cleans up the message channels
446
+ * Calls IApp.onReady(). Should be called after configure() and any lazy()
447
+ * registrations are set up.
275
448
  */
449
+ start(): this;
450
+ private readonly onRendererMessage;
451
+ private giveTheRendererAPort;
452
+ private onAppActivated;
276
453
  private onAllWindowsClosed;
454
+ private shutdownChannel;
455
+ }
456
+
457
+
458
+ /**
459
+ * A single route entry in the application routing table.
460
+ */
461
+ interface RouteDefinition {
277
462
  /**
278
- * Sets the main BrowserWindow that was created early by bootstrapApplication.
279
- * This window will be passed to IApp.onReady when start() is called.
280
- * @param window - The BrowserWindow created during bootstrap.
463
+ * The path prefix for this route (e.g. 'users', 'orders').
464
+ * All actions defined in the controller will be prefixed with this path.
281
465
  */
282
- setMainWindow(window: BrowserWindow): void;
466
+ path: string;
283
467
  /**
284
- * Registers a lazy-loaded route. The module behind this path prefix
285
- * will only be dynamically imported when the first IPC request
286
- * targets this prefix — like Angular's loadChildren.
468
+ * Dynamic import function returning the controller file.
469
+ * The controller is loaded lazily on the first IPC request targeting this prefix.
287
470
  *
288
471
  * @example
289
- * ```ts
290
- * noxApp.lazy("auth", () => import("./modules/auth/auth.module.js"));
291
- * noxApp.lazy("printing", () => import("./modules/printing/printing.module.js"));
292
- * ```
293
- *
294
- * @param pathPrefix - The route prefix (e.g. "auth", "cash-register").
295
- * @param loadModule - A function returning a dynamic import promise.
296
- * @returns NoxApp instance for method chaining.
472
+ * load: () => import('./modules/users/users.controller')
297
473
  */
298
- lazy(pathPrefix: string, loadModule: () => Promise<unknown>): NoxApp;
474
+ load: () => Promise<unknown>;
299
475
  /**
300
- * Eagerly loads one or more modules with a two-phase DI guarantee.
301
- * Use this when a service needed at startup lives inside a module
302
- * (e.g. the Application service depends on LoaderService).
303
- *
304
- * All dynamic imports run in parallel; bindings are registered first,
305
- * then singletons are resolved — safe regardless of import ordering.
306
- *
307
- * @param importFns - Functions returning dynamic import promises.
476
+ * Guards applied to every action in this controller.
477
+ * Merged with action-level guards.
308
478
  */
309
- loadModules(importFns: Array<() => Promise<unknown>>): Promise<void>;
479
+ guards?: Guard[];
310
480
  /**
311
- * Configures the NoxApp instance with the provided application class.
312
- * This method allows you to set the application class that will handle lifecycle events.
313
- * @param app - The application class to configure.
314
- * @returns NoxApp instance for method chaining.
481
+ * Middlewares applied to every action in this controller.
482
+ * Merged with action-level middlewares.
315
483
  */
316
- configure(app: Type<IApp>): NoxApp;
484
+ middlewares?: Middleware[];
485
+ }
486
+ /**
487
+ * Defines the application routing table.
488
+ * Each entry maps a path prefix to a lazily-loaded controller.
489
+ *
490
+ * This is the single source of truth for routing — no path is declared
491
+ * in @Controller(), preventing duplicate route prefixes across controllers.
492
+ *
493
+ * @example
494
+ * export const routes = defineRoutes([
495
+ * {
496
+ * path: 'users',
497
+ * load: () => import('./modules/users/users.controller'),
498
+ * guards: [authGuard],
499
+ * },
500
+ * {
501
+ * path: 'orders',
502
+ * load: () => import('./modules/orders/orders.controller'),
503
+ * guards: [authGuard],
504
+ * middlewares: [logMiddleware],
505
+ * },
506
+ * ]);
507
+ */
508
+ declare function defineRoutes(routes: RouteDefinition[]): RouteDefinition[];
509
+
510
+
511
+ /**
512
+ * A singleton value override: provides an already-constructed instance
513
+ * for a given token, bypassing the DI factory.
514
+ *
515
+ * Useful for injecting external singletons (e.g. a database connection,
516
+ * a logger already configured, a third-party SDK wrapper) that cannot
517
+ * or should not be constructed by the DI container.
518
+ *
519
+ * @example
520
+ * { token: MikroORM, useValue: await MikroORM.init(config) }
521
+ * { token: DB_URL, useValue: process.env.DATABASE_URL }
522
+ */
523
+ interface SingletonOverride<T = unknown> {
524
+ token: TokenKey<T>;
525
+ useValue: T;
526
+ }
527
+ /**
528
+ * Configuration object for bootstrapApplication.
529
+ */
530
+ interface BootstrapConfig {
317
531
  /**
318
- * Registers a middleware for the root of the application.
319
- * This method allows you to define a middleware that will be applied to all requests
320
- * @param middleware - The middleware class to register.
321
- * @returns NoxApp instance for method chaining.
532
+ * Application routing table, produced by defineRoutes().
533
+ * All lazy routes are registered before the app starts.
322
534
  */
323
- use(middleware: Type<IMiddleware>): NoxApp;
535
+ routes?: RouteDefinition[];
324
536
  /**
325
- * Should be called after the bootstrapApplication function is called.
326
- * Passes the early-created BrowserWindow (if any) to the configured IApp service.
327
- * @returns NoxApp instance for method chaining.
537
+ * Pre-built singleton instances to inject into the DI container
538
+ * before the application starts.
539
+ *
540
+ * This replaces the v2 module/provider declaration pattern for
541
+ * external singletons.
542
+ *
543
+ * @example
544
+ * singletons: [
545
+ * { token: MikroORM, useValue: await MikroORM.init(ormConfig) },
546
+ * { token: DB_URL, useValue: process.env.DATABASE_URL! },
547
+ * ]
328
548
  */
329
- start(): NoxApp;
549
+ singletons?: SingletonOverride[];
550
+ /**
551
+ * Controllers and services to eagerly load before NoxApp.start() is called.
552
+ * Each entry is a dynamic import function — files are imported in parallel.
553
+ *
554
+ * Use this only for things needed at startup (e.g. if your IApp service
555
+ * depends on a service in an otherwise lazy module).
556
+ *
557
+ * Everything else should be registered via noxApp.lazy().
558
+ *
559
+ * @example
560
+ * eagerLoad: [
561
+ * () => import('./modules/auth/auth.controller.js'),
562
+ * ]
563
+ */
564
+ eagerLoad?: Array<() => Promise<unknown>>;
330
565
  }
331
-
332
-
333
566
  /**
334
- * Options for bootstrapping the Noxus application.
567
+ * Bootstraps the Noxus application.
335
568
  */
336
- interface BootstrapOptions {
569
+ declare function bootstrapApplication(config?: BootstrapConfig): Promise<NoxApp>;
570
+
571
+ declare class ResponseException extends Error {
572
+ readonly status: number;
573
+ constructor(message?: string);
574
+ constructor(statusCode?: number, message?: string);
575
+ }
576
+ declare class BadRequestException extends ResponseException {
577
+ readonly status = 400;
578
+ }
579
+ declare class UnauthorizedException extends ResponseException {
580
+ readonly status = 401;
581
+ }
582
+ declare class PaymentRequiredException extends ResponseException {
583
+ readonly status = 402;
584
+ }
585
+ declare class ForbiddenException extends ResponseException {
586
+ readonly status = 403;
587
+ }
588
+ declare class NotFoundException extends ResponseException {
589
+ readonly status = 404;
590
+ }
591
+ declare class MethodNotAllowedException extends ResponseException {
592
+ readonly status = 405;
593
+ }
594
+ declare class NotAcceptableException extends ResponseException {
595
+ readonly status = 406;
596
+ }
597
+ declare class RequestTimeoutException extends ResponseException {
598
+ readonly status = 408;
599
+ }
600
+ declare class ConflictException extends ResponseException {
601
+ readonly status = 409;
602
+ }
603
+ declare class UpgradeRequiredException extends ResponseException {
604
+ readonly status = 426;
605
+ }
606
+ declare class TooManyRequestsException extends ResponseException {
607
+ readonly status = 429;
608
+ }
609
+ declare class InternalServerException extends ResponseException {
610
+ readonly status = 500;
611
+ }
612
+ declare class NotImplementedException extends ResponseException {
613
+ readonly status = 501;
614
+ }
615
+ declare class BadGatewayException extends ResponseException {
616
+ readonly status = 502;
617
+ }
618
+ declare class ServiceUnavailableException extends ResponseException {
619
+ readonly status = 503;
620
+ }
621
+ declare class GatewayTimeoutException extends ResponseException {
622
+ readonly status = 504;
623
+ }
624
+ declare class HttpVersionNotSupportedException extends ResponseException {
625
+ readonly status = 505;
626
+ }
627
+ declare class VariantAlsoNegotiatesException extends ResponseException {
628
+ readonly status = 506;
629
+ }
630
+ declare class InsufficientStorageException extends ResponseException {
631
+ readonly status = 507;
632
+ }
633
+ declare class LoopDetectedException extends ResponseException {
634
+ readonly status = 508;
635
+ }
636
+ declare class NotExtendedException extends ResponseException {
637
+ readonly status = 510;
638
+ }
639
+ declare class NetworkAuthenticationRequiredException extends ResponseException {
640
+ readonly status = 511;
641
+ }
642
+ declare class NetworkConnectTimeoutException extends ResponseException {
643
+ readonly status = 599;
644
+ }
645
+
646
+
647
+ interface ControllerOptions {
337
648
  /**
338
- * If provided, Noxus creates a BrowserWindow immediately after Electron is ready,
339
- * before any DI processing occurs. This window is passed to the configured
340
- * IApp service via onReady(). It allows the user to see a window as fast as possible,
341
- * even before the application is fully initialized.
649
+ * Explicit constructor dependencies.
342
650
  */
343
- window?: Electron.BrowserWindowConstructorOptions;
651
+ deps?: ReadonlyArray<TokenKey>;
652
+ }
653
+ interface IControllerMetadata {
654
+ deps: ReadonlyArray<TokenKey>;
344
655
  }
345
656
  /**
346
- * Bootstraps the Noxus application.
347
- * This function initializes the application by creating an instance of NoxApp,
348
- * registering the root module, and starting the application.
657
+ * Marks a class as a Noxus controller.
658
+ * Controllers are always scope-scoped injectables.
659
+ * The route prefix and guards/middlewares are declared in defineRoutes(), not here.
349
660
  *
350
- * When {@link BootstrapOptions.window} is provided, a BrowserWindow is created
351
- * immediately after Electron readiness — before DI resolution — so the user
352
- * sees a window as quickly as possible.
661
+ * @example
662
+ * @Controller({ deps: [UserService] })
663
+ * export class UserController {
664
+ * constructor(private svc: UserService) {}
353
665
  *
354
- * @param rootModule - The root module of the application, decorated with @Module.
355
- * @param options - Optional bootstrap configuration.
356
- * @return A promise that resolves to the NoxApp instance.
357
- * @throws Error if the root module is not decorated with @Module, or if the electron process could not start.
666
+ * @Get('byId/:userId')
667
+ * getUserById(req: Request) { ... }
668
+ * }
358
669
  */
359
- declare function bootstrapApplication(rootModule?: Type<any> | null, options?: BootstrapOptions): Promise<NoxApp>;
670
+ declare function Controller(options?: ControllerOptions): ClassDecorator;
671
+ declare function getControllerMetadata(target: object): IControllerMetadata | undefined;
360
672
 
361
673
 
362
- /**
363
- * The configuration that waits a controller's decorator.
364
- */
365
- interface IControllerMetadata {
366
- path: string;
367
- guards: Type<IGuard>[];
674
+ interface InjectableOptions {
675
+ /**
676
+ * Lifetime of this injectable.
677
+ * @default 'scope'
678
+ */
679
+ lifetime?: Lifetime;
680
+ /**
681
+ * Explicit list of constructor dependencies, in the same order as the constructor parameters.
682
+ * Each entry is either a class constructor or a Token created with token().
683
+ *
684
+ * This replaces reflect-metadata / emitDecoratorMetadata entirely.
685
+ *
686
+ * @example
687
+ * @Injectable({ lifetime: 'singleton', deps: [MyRepo, DB_URL] })
688
+ * class MyService {
689
+ * constructor(private repo: MyRepo, private dbUrl: string) {}
690
+ * }
691
+ */
692
+ deps?: ReadonlyArray<TokenKey>;
368
693
  }
369
694
  /**
370
- * Controller decorator is used to define a controller in the application.
371
- * It is a kind of node in the routing tree, that can contains routes and middlewares.
695
+ * Marks a class as injectable into the Noxus DI container.
696
+ *
697
+ * Unlike the v2 @Injectable, this decorator:
698
+ * - Does NOT require reflect-metadata or emitDecoratorMetadata.
699
+ * - Requires you to declare deps explicitly when the class has constructor parameters.
700
+ * - Supports standalone usage — no module declaration needed.
701
+ *
702
+ * @example
703
+ * // No dependencies
704
+ * @Injectable()
705
+ * class Logger {}
706
+ *
707
+ * // With dependencies
708
+ * @Injectable({ lifetime: 'singleton', deps: [Logger, MyRepo] })
709
+ * class MyService {
710
+ * constructor(private logger: Logger, private repo: MyRepo) {}
711
+ * }
712
+ *
713
+ * // With a named token
714
+ * const DB_URL = token<string>('DB_URL');
372
715
  *
373
- * @param path - The path for the controller.
716
+ * @Injectable({ deps: [DB_URL] })
717
+ * class DbService {
718
+ * constructor(private url: string) {}
719
+ * }
374
720
  */
375
- declare function Controller(path: string): ClassDecorator;
721
+ declare function Injectable(options?: InjectableOptions): ClassDecorator;
722
+
376
723
  /**
377
- * Gets the controller metadata for a given target class.
378
- * This metadata includes the path and guards defined by the @Controller decorator.
379
- * @param target - The target class to get the controller metadata from.
380
- * @returns The controller metadata if it exists, otherwise undefined.
724
+ * Logger is a utility class for logging messages to the console.
381
725
  */
382
- declare function getControllerMetadata(target: Type<unknown>): IControllerMetadata | undefined;
383
- declare const CONTROLLER_METADATA_KEY: unique symbol;
726
+ type LogLevel = 'debug' | 'comment' | 'log' | 'info' | 'warn' | 'error' | 'critical';
727
+ declare namespace Logger {
728
+ /**
729
+ * Sets the log level for the logger.
730
+ * This function allows you to change the log level dynamically at runtime.
731
+ * This won't affect the startup logs.
732
+ *
733
+ * If the parameter is a single LogLevel, all log levels with equal or higher severity will be enabled.
384
734
 
735
+ * If the parameter is an array of LogLevels, only the specified levels will be enabled.
736
+ *
737
+ * @param level Sets the log level for the logger.
738
+ */
739
+ function setLogLevel(level: LogLevel | LogLevel[]): void;
740
+ /**
741
+ * Logs a message to the console with log level LOG.
742
+ * This function formats the message with a timestamp, process ID, and the name of the caller function or class.
743
+ * It uses different colors for different log levels to enhance readability.
744
+ * @param args The arguments to log.
745
+ */
746
+ function log(...args: any[]): void;
747
+ /**
748
+ * Logs a message to the console with log level INFO.
749
+ * This function formats the message with a timestamp, process ID, and the name of the caller function or class.
750
+ * It uses different colors for different log levels to enhance readability.
751
+ * @param args The arguments to log.
752
+ */
753
+ function info(...args: any[]): void;
754
+ /**
755
+ * Logs a message to the console with log level WARN.
756
+ * This function formats the message with a timestamp, process ID, and the name of the caller function or class.
757
+ * It uses different colors for different log levels to enhance readability.
758
+ * @param args The arguments to log.
759
+ */
760
+ function warn(...args: any[]): void;
761
+ /**
762
+ * Logs a message to the console with log level ERROR.
763
+ * This function formats the message with a timestamp, process ID, and the name of the caller function or class.
764
+ * It uses different colors for different log levels to enhance readability.
765
+ * @param args The arguments to log.
766
+ */
767
+ function error(...args: any[]): void;
768
+ /**
769
+ * Logs a message to the console with log level ERROR and a grey color scheme.
770
+ */
771
+ function errorStack(...args: any[]): void;
772
+ /**
773
+ * Logs a message to the console with log level DEBUG.
774
+ * This function formats the message with a timestamp, process ID, and the name of the caller function or class.
775
+ * It uses different colors for different log levels to enhance readability.
776
+ * @param args The arguments to log.
777
+ */
778
+ function debug(...args: any[]): void;
779
+ /**
780
+ * Logs a message to the console with log level COMMENT.
781
+ * This function formats the message with a timestamp, process ID, and the name of the caller function or class.
782
+ * It uses different colors for different log levels to enhance readability.
783
+ * @param args The arguments to log.
784
+ */
785
+ function comment(...args: any[]): void;
786
+ /**
787
+ * Logs a message to the console with log level CRITICAL.
788
+ * This function formats the message with a timestamp, process ID, and the name of the caller function or class.
789
+ * It uses different colors for different log levels to enhance readability.
790
+ * @param args The arguments to log.
791
+ */
792
+ function critical(...args: any[]): void;
793
+ /**
794
+ * Enables logging to a file output for the specified log levels.
795
+ * @param filepath The path to the log file.
796
+ * @param levels The log levels to enable file logging for. Defaults to all levels.
797
+ */
798
+ function enableFileLogging(filepath: string, levels?: LogLevel[]): void;
799
+ /**
800
+ * Disables logging to a file output for the specified log levels.
801
+ * @param levels The log levels to disable file logging for. Defaults to all levels.
802
+ */
803
+ function disableFileLogging(levels?: LogLevel[]): void;
804
+ const colors: {
805
+ black: string;
806
+ grey: string;
807
+ red: string;
808
+ green: string;
809
+ brown: string;
810
+ blue: string;
811
+ purple: string;
812
+ darkGrey: string;
813
+ lightRed: string;
814
+ lightGreen: string;
815
+ yellow: string;
816
+ lightBlue: string;
817
+ magenta: string;
818
+ cyan: string;
819
+ white: string;
820
+ initial: string;
821
+ };
822
+ }
385
823
 
386
- interface IModuleMetadata {
387
- imports?: Type<unknown>[];
388
- exports?: Type<unknown>[];
389
- providers?: Type<unknown>[];
390
- controllers?: Type<unknown>[];
824
+ interface RendererChannels {
825
+ request: Electron.MessageChannelMain;
826
+ socket: Electron.MessageChannelMain;
827
+ }
828
+ declare class NoxSocket {
829
+ private readonly channels;
830
+ register(senderId: number, requestChannel: Electron.MessageChannelMain, socketChannel: Electron.MessageChannelMain): void;
831
+ get(senderId: number): RendererChannels | undefined;
832
+ unregister(senderId: number): void;
833
+ getSenderIds(): number[];
834
+ emit<TPayload = unknown>(eventName: string, payload?: TPayload, targetSenderIds?: number[]): number;
835
+ emitToRenderer<TPayload = unknown>(senderId: number, eventName: string, payload?: TPayload): boolean;
391
836
  }
392
- /**
393
- * Module decorator is used to define a module in the application.
394
- * It is a kind of node in the routing tree, that can contains controllers, services, and other modules.
395
- *
396
- * @param metadata - The metadata for the module.
397
- */
398
- declare function Module(metadata: IModuleMetadata): ClassDecorator;
399
- declare function getModuleMetadata(target: Function): IModuleMetadata | undefined;
400
- declare const MODULE_METADATA_KEY: unique symbol;
401
837
 
402
- export { type BootstrapOptions, CONTROLLER_METADATA_KEY, Controller, type ControllerAction, type IApp, type IControllerMetadata, IGuard, type ILazyRoute, type IMiddleware, type IModuleMetadata, IResponse, type IRouteDefinition, MODULE_METADATA_KEY, MaybeAsync, Module, type NextFunction, NoxApp, NoxSocket, Request, Router, Type, UseMiddlewares, bootstrapApplication, getControllerMetadata, getMiddlewaresForController, getMiddlewaresForControllerAction, getModuleMetadata };
838
+ export { AppInjector, type AtomicHttpMethod, BadGatewayException, BadRequestException, type BootstrapConfig, ConflictException, Controller, type ControllerAction, type ControllerOptions, Delete, ForbiddenException, type ForwardRefFn, ForwardReference, GatewayTimeoutException, Get, type Guard, type HttpMethod, HttpVersionNotSupportedException, type IApp, type IBatchRequestItem, type IBatchRequestPayload, type IBatchResponsePayload, type IBinding, type IControllerMetadata, type ILazyRoute, type IRendererEventMessage, type IRequest, type IResponse, type IRouteDefinition, type IRouteMetadata, type IRouteOptions, Injectable, type InjectableOptions, InsufficientStorageException, InternalServerException, type Lifetime, type LogLevel, Logger, LoopDetectedException, type MaybeAsync, MethodNotAllowedException, type Middleware, NetworkAuthenticationRequiredException, NetworkConnectTimeoutException, type NextFunction, NotAcceptableException, NotExtendedException, NotFoundException, NotImplementedException, NoxApp, NoxSocket, Patch, PaymentRequiredException, Post, Put, RENDERER_EVENT_TYPE, Request, RequestTimeoutException, ResponseException, RootInjector, type RouteDefinition, Router, ServiceUnavailableException, type SingletonOverride, Token, type TokenKey, TooManyRequestsException, type Type, UnauthorizedException, UpgradeRequiredException, VariantAlsoNegotiatesException, type WindowConfig, WindowManager, type WindowRecord, bootstrapApplication, createRendererEventMessage, defineRoutes, forwardRef, getControllerMetadata, getRouteMetadata, inject, isAtomicHttpMethod, isRendererEventMessage, token };