@noxfly/noxus 1.1.10 → 2.0.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.
@@ -1,225 +1,11 @@
1
+ import { R as Request, I as IResponse, M as MaybeAsync, T as Type, a as IGuard, L as Lifetime, b as IPortRequester } from './index-CI3OMzNR.mjs';
2
+ export { A as AppInjector, j as AtomicHttpMethod, e as Authorize, D as Delete, G as Get, H as HttpMethod, p as IBatchRequestItem, q as IBatchRequestPayload, r as IBatchResponsePayload, c as IBinding, t as IRendererEventMessage, o as IRequest, h as IRouteMetadata, N as NoxRendererClient, m as Patch, P as Post, l as Put, s as RENDERER_EVENT_TYPE, n as ROUTE_METADATA_KEY, z as RendererClientOptions, w as RendererEventHandler, y as RendererEventRegistry, x as RendererEventSubscription, d as RootInjector, u as createRendererEventMessage, g as getGuardForController, f as getGuardForControllerAction, k as getRouteMetadata, i as inject, v as isRendererEventMessage } from './index-CI3OMzNR.mjs';
3
+
1
4
  /**
2
5
  * @copyright 2025 NoxFly
3
6
  * @license MIT
4
7
  * @author NoxFly
5
8
  */
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
- * Represents a lifetime of a binding in the dependency injection system.
17
- * It can be one of the following:
18
- * - 'singleton': The instance is created once and shared across the application.
19
- * - 'scope': The instance is created once per scope (e.g., per request).
20
- * - 'transient': A new instance is created every time it is requested.
21
- */
22
- type Lifetime = 'singleton' | 'scope' | 'transient';
23
- /**
24
- * Represents a binding in the dependency injection system.
25
- * It contains the lifetime of the binding, the implementation type, and optionally an instance.
26
- */
27
- interface IBinding {
28
- lifetime: Lifetime;
29
- implementation: Type<unknown>;
30
- instance?: InstanceType<Type<unknown>>;
31
- }
32
- /**
33
- * AppInjector is the root dependency injection container.
34
- * It is used to register and resolve dependencies in the application.
35
- * It supports different lifetimes for dependencies:
36
- * This should not be manually instantiated, outside of the framework.
37
- * Use the `RootInjector` instance instead.
38
- */
39
- declare class AppInjector {
40
- readonly name: string | null;
41
- bindings: Map<Type<unknown>, IBinding>;
42
- singletons: Map<Type<unknown>, unknown>;
43
- scoped: Map<Type<unknown>, unknown>;
44
- constructor(name?: string | null);
45
- /**
46
- * Typically used to create a dependency injection scope
47
- * at the "scope" level (i.e., per-request lifetime).
48
- *
49
- * SHOULD NOT BE USED by anything else than the framework itself.
50
- */
51
- createScope(): AppInjector;
52
- /**
53
- * Called when resolving a dependency,
54
- * i.e., retrieving the instance of a given class.
55
- */
56
- resolve<T extends Type<unknown>>(target: T): InstanceType<T>;
57
- /**
58
- *
59
- */
60
- private instantiate;
61
- }
62
- /**
63
- * Injects a type from the dependency injection system.
64
- * This function is used to retrieve an instance of a type that has been registered in the dependency injection system.
65
- * It is typically used in the constructor of a class to inject dependencies.
66
- * @param t - The type to inject.
67
- * @returns An instance of the type.
68
- * @throws If the type is not registered in the dependency injection system.
69
- */
70
- declare function inject<T>(t: Type<T>): T;
71
- declare const RootInjector: AppInjector;
72
-
73
-
74
- /**
75
- * IRouteMetadata interface defines the metadata for a route.
76
- * It includes the HTTP method, path, handler name, and guards associated with the route.
77
- * This metadata is used to register the route in the application.
78
- * This is the configuration that waits a route's decorator.
79
- */
80
- interface IRouteMetadata {
81
- method: HttpMethod;
82
- path: string;
83
- handler: string;
84
- guards: Type<IGuard>[];
85
- }
86
- /**
87
- * The different HTTP methods that can be used in the application.
88
- */
89
- type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'BATCH';
90
- /**
91
- * Atomic HTTP verbs supported by controllers. BATCH is handled at the router level only.
92
- */
93
- type AtomicHttpMethod = Exclude<HttpMethod, 'BATCH'>;
94
- /**
95
- * Gets the route metadata for a given target class.
96
- * This metadata includes the HTTP method, path, handler, and guards defined by the route decorators.
97
- * @see Get
98
- * @see Post
99
- * @see Put
100
- * @see Patch
101
- * @see Delete
102
- * @param target The target class to get the route metadata from.
103
- * @returns An array of route metadata if it exists, otherwise an empty array.
104
- */
105
- declare function getRouteMetadata(target: Type<unknown>): IRouteMetadata[];
106
- /**
107
- * Route decorator that defines a leaf in the routing tree, attaching it to a controller method
108
- * that will be called when the route is matched.
109
- * This route will have to be called with the GET method.
110
- */
111
- declare const Get: (path: string) => MethodDecorator;
112
- /**
113
- * Route decorator that defines a leaf in the routing tree, attaching it to a controller method
114
- * that will be called when the route is matched.
115
- * This route will have to be called with the POST method.
116
- */
117
- declare const Post: (path: string) => MethodDecorator;
118
- /**
119
- * Route decorator that defines a leaf in the routing tree, attaching it to a controller method
120
- * that will be called when the route is matched.
121
- * This route will have to be called with the PUT method.
122
- */
123
- declare const Put: (path: string) => MethodDecorator;
124
- /**
125
- * Route decorator that defines a leaf in the routing tree, attaching it to a controller method
126
- * that will be called when the route is matched.
127
- * This route will have to be called with the PATCH method.
128
- */
129
- declare const Patch: (path: string) => MethodDecorator;
130
- /**
131
- * Route decorator that defines a leaf in the routing tree, attaching it to a controller method
132
- * that will be called when the route is matched.
133
- * This route will have to be called with the DELETE method.
134
- */
135
- declare const Delete: (path: string) => MethodDecorator;
136
- declare const ROUTE_METADATA_KEY: unique symbol;
137
-
138
-
139
- /**
140
- * The Request class represents an HTTP request in the Noxus framework.
141
- * It encapsulates the request data, including the event, ID, method, path, and body.
142
- * It also provides a context for dependency injection through the AppInjector.
143
- */
144
- declare class Request {
145
- readonly event: Electron.MessageEvent;
146
- readonly id: string;
147
- readonly method: HttpMethod;
148
- readonly path: string;
149
- readonly body: any;
150
- readonly context: AppInjector;
151
- readonly params: Record<string, string>;
152
- constructor(event: Electron.MessageEvent, id: string, method: HttpMethod, path: string, body: any);
153
- }
154
- /**
155
- * The IRequest interface defines the structure of a request object.
156
- * It includes properties for the sender ID, request ID, path, method, and an optional body.
157
- * This interface is used to standardize the request data across the application.
158
- */
159
- interface IRequest<TBody = unknown> {
160
- senderId: number;
161
- requestId: string;
162
- path: string;
163
- method: HttpMethod;
164
- body?: TBody;
165
- }
166
- interface IBatchRequestItem<TBody = unknown> {
167
- requestId?: string;
168
- path: string;
169
- method: AtomicHttpMethod;
170
- body?: TBody;
171
- }
172
- interface IBatchRequestPayload {
173
- requests: IBatchRequestItem[];
174
- }
175
- /**
176
- * Creates a Request object from the IPC event data.
177
- * This function extracts the necessary information from the IPC event and constructs a Request instance.
178
- */
179
- interface IResponse<TBody = unknown> {
180
- requestId: string;
181
- status: number;
182
- body?: TBody;
183
- error?: string;
184
- stack?: string;
185
- }
186
- interface IBatchResponsePayload {
187
- responses: IResponse[];
188
- }
189
-
190
-
191
- /**
192
- * IGuard interface defines a guard that can be used to protect routes.
193
- * It has a `canActivate` method that takes a request and returns a MaybeAsync boolean.
194
- * The `canActivate` method can return either a value or a Promise.
195
- * Use it on a class that should be registered as a guard in the application.
196
- * Guards can be used to protect routes or controller actions.
197
- * For example, you can use guards to check if the user is authenticated or has the right permissions.
198
- * You can use the `Authorize` decorator to register guards for a controller or a controller action.
199
- * @see Authorize
200
- */
201
- interface IGuard {
202
- canActivate(request: Request): MaybeAsync<boolean>;
203
- }
204
- /**
205
- * Can be used to protect the routes of a controller.
206
- * Can be used on a controller class or on a controller method.
207
- */
208
- declare function Authorize(...guardClasses: Type<IGuard>[]): MethodDecorator & ClassDecorator;
209
- /**
210
- * Gets the guards for a controller or a controller action.
211
- * @param controllerName The name of the controller to get the guards for.
212
- * @returns An array of guards for the controller.
213
- */
214
- declare function getGuardForController(controllerName: string): Type<IGuard>[];
215
- /**
216
- * Gets the guards for a controller action.
217
- * @param controllerName The name of the controller to get the guards for.
218
- * @param actionName The name of the action to get the guards for.
219
- * @returns An array of guards for the controller action.
220
- */
221
- declare function getGuardForControllerAction(controllerName: string, actionName: string): Type<IGuard>[];
222
-
223
9
 
224
10
  /**
225
11
  * NextFunction is a function that is called to continue the middleware chain.
@@ -374,6 +160,20 @@ declare class Router {
374
160
  private extractParams;
375
161
  }
376
162
 
163
+ interface RendererChannels {
164
+ request: Electron.MessageChannelMain;
165
+ socket: Electron.MessageChannelMain;
166
+ }
167
+ declare class NoxSocket {
168
+ private readonly channels;
169
+ register(senderId: number, requestChannel: Electron.MessageChannelMain, socketChannel: Electron.MessageChannelMain): void;
170
+ get(senderId: number): RendererChannels | undefined;
171
+ unregister(senderId: number): void;
172
+ getSenderIds(): number[];
173
+ emit<TPayload = unknown>(eventName: string, payload?: TPayload, targetSenderIds?: number[]): number;
174
+ emitToRenderer<TPayload = unknown>(senderId: number, eventName: string, payload?: TPayload): boolean;
175
+ }
176
+
377
177
 
378
178
  /**
379
179
  * The application service should implement this interface, as
@@ -391,9 +191,13 @@ interface IApp {
391
191
  */
392
192
  declare class NoxApp {
393
193
  private readonly router;
394
- private readonly messagePorts;
194
+ private readonly socket;
395
195
  private app;
396
- constructor(router: Router);
196
+ /**
197
+ *
198
+ */
199
+ private readonly onRendererMessage;
200
+ constructor(router: Router, socket: NoxSocket);
397
201
  /**
398
202
  * Initializes the NoxApp instance.
399
203
  * This method sets up the IPC communication, registers event listeners,
@@ -407,11 +211,6 @@ declare class NoxApp {
407
211
  * to the renderer process using the MessageChannel.
408
212
  */
409
213
  private giveTheRendererAPort;
410
- /**
411
- * Electron specific message handling.
412
- * Replaces HTTP calls by using Electron's IPC mechanism.
413
- */
414
- private onRendererMessage;
415
214
  /**
416
215
  * MacOS specific behavior.
417
216
  */
@@ -560,6 +359,10 @@ declare function Controller(path: string): ClassDecorator;
560
359
  declare function getControllerMetadata(target: Type<unknown>): IControllerMetadata | undefined;
561
360
  declare const CONTROLLER_METADATA_KEY: unique symbol;
562
361
 
362
+ declare const INJECTABLE_METADATA_KEY: unique symbol;
363
+ declare function getInjectableMetadata(target: Function): Lifetime | undefined;
364
+ declare function hasInjectableMetadata(target: Function): boolean;
365
+
563
366
 
564
367
  /**
565
368
  * The Injectable decorator marks a class as injectable.
@@ -569,14 +372,6 @@ declare const CONTROLLER_METADATA_KEY: unique symbol;
569
372
  * @param lifetime - The lifetime of the injectable. Can be 'singleton', 'scope', or 'transient'.
570
373
  */
571
374
  declare function Injectable(lifetime?: Lifetime): ClassDecorator;
572
- /**
573
- * Gets the injectable metadata for a given target class.
574
- * This metadata includes the lifetime of the injectable defined by the @Injectable decorator.
575
- * @param target - The target class to get the injectable metadata from.
576
- * @returns The lifetime of the injectable if it exists, otherwise undefined.
577
- */
578
- declare function getInjectableMetadata(target: Type<unknown>): Lifetime | undefined;
579
- declare const INJECTABLE_METADATA_KEY: unique symbol;
580
375
 
581
376
 
582
377
  interface IModuleMetadata {
@@ -595,6 +390,23 @@ declare function Module(metadata: IModuleMetadata): ClassDecorator;
595
390
  declare function getModuleMetadata(target: Function): IModuleMetadata | undefined;
596
391
  declare const MODULE_METADATA_KEY: unique symbol;
597
392
 
393
+
394
+ interface NoxusPreloadAPI extends IPortRequester {
395
+ }
396
+ interface NoxusPreloadOptions {
397
+ exposeAs?: string;
398
+ initMessageType?: string;
399
+ requestChannel?: string;
400
+ responseChannel?: string;
401
+ targetWindow?: Window;
402
+ }
403
+ /**
404
+ * Exposes a minimal bridge in the isolated preload context so renderer processes
405
+ * can request the two MessagePorts required by Noxus. The bridge forwards both
406
+ * request/response and socket ports to the renderer via window.postMessage.
407
+ */
408
+ declare function exposeNoxusBridge(options?: NoxusPreloadOptions): NoxusPreloadAPI;
409
+
598
410
  /**
599
411
  * Logger is a utility class for logging messages to the console.
600
412
  */
@@ -670,4 +482,4 @@ declare namespace Logger {
670
482
  };
671
483
  }
672
484
 
673
- export { AppInjector, type AtomicHttpMethod, Authorize, BadGatewayException, BadRequestException, CONTROLLER_METADATA_KEY, ConflictException, Controller, type ControllerAction, Delete, ForbiddenException, GatewayTimeoutException, Get, type HttpMethod, HttpVersionNotSupportedException, type IApp, type IBatchRequestItem, type IBatchRequestPayload, type IBatchResponsePayload, type IBinding, type IControllerMetadata, type IGuard, type IMiddleware, type IModuleMetadata, INJECTABLE_METADATA_KEY, type IRequest, type IResponse, type IRouteDefinition, type IRouteMetadata, Injectable, InsufficientStorageException, InternalServerException, type Lifetime, type LogLevel, Logger, LoopDetectedException, MODULE_METADATA_KEY, type MaybeAsync, MethodNotAllowedException, Module, NetworkAuthenticationRequiredException, NetworkConnectTimeoutException, type NextFunction, NotAcceptableException, NotExtendedException, NotFoundException, NotImplementedException, NoxApp, Patch, PaymentRequiredException, Post, Put, ROUTE_METADATA_KEY, Request, RequestTimeoutException, ResponseException, RootInjector, Router, ServiceUnavailableException, TooManyRequestsException, type Type, UnauthorizedException, UpgradeRequiredException, UseMiddlewares, VariantAlsoNegotiatesException, bootstrapApplication, getControllerMetadata, getGuardForController, getGuardForControllerAction, getInjectableMetadata, getMiddlewaresForController, getMiddlewaresForControllerAction, getModuleMetadata, getRouteMetadata, inject };
485
+ export { BadGatewayException, BadRequestException, CONTROLLER_METADATA_KEY, ConflictException, Controller, type ControllerAction, ForbiddenException, GatewayTimeoutException, HttpVersionNotSupportedException, type IApp, type IControllerMetadata, IGuard, type IMiddleware, type IModuleMetadata, INJECTABLE_METADATA_KEY, IPortRequester, IResponse, type IRouteDefinition, Injectable, InsufficientStorageException, InternalServerException, Lifetime, type LogLevel, Logger, LoopDetectedException, MODULE_METADATA_KEY, MaybeAsync, MethodNotAllowedException, Module, NetworkAuthenticationRequiredException, NetworkConnectTimeoutException, type NextFunction, NotAcceptableException, NotExtendedException, NotFoundException, NotImplementedException, NoxApp, NoxSocket, type NoxusPreloadAPI, type NoxusPreloadOptions, PaymentRequiredException, Request, RequestTimeoutException, ResponseException, Router, ServiceUnavailableException, TooManyRequestsException, Type, UnauthorizedException, UpgradeRequiredException, UseMiddlewares, VariantAlsoNegotiatesException, bootstrapApplication, exposeNoxusBridge, getControllerMetadata, getInjectableMetadata, getMiddlewaresForController, getMiddlewaresForControllerAction, getModuleMetadata, hasInjectableMetadata };
@@ -1,225 +1,11 @@
1
+ import { R as Request, I as IResponse, M as MaybeAsync, T as Type, a as IGuard, L as Lifetime, b as IPortRequester } from './index-CI3OMzNR.js';
2
+ export { A as AppInjector, j as AtomicHttpMethod, e as Authorize, D as Delete, G as Get, H as HttpMethod, p as IBatchRequestItem, q as IBatchRequestPayload, r as IBatchResponsePayload, c as IBinding, t as IRendererEventMessage, o as IRequest, h as IRouteMetadata, N as NoxRendererClient, m as Patch, P as Post, l as Put, s as RENDERER_EVENT_TYPE, n as ROUTE_METADATA_KEY, z as RendererClientOptions, w as RendererEventHandler, y as RendererEventRegistry, x as RendererEventSubscription, d as RootInjector, u as createRendererEventMessage, g as getGuardForController, f as getGuardForControllerAction, k as getRouteMetadata, i as inject, v as isRendererEventMessage } from './index-CI3OMzNR.js';
3
+
1
4
  /**
2
5
  * @copyright 2025 NoxFly
3
6
  * @license MIT
4
7
  * @author NoxFly
5
8
  */
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
- * Represents a lifetime of a binding in the dependency injection system.
17
- * It can be one of the following:
18
- * - 'singleton': The instance is created once and shared across the application.
19
- * - 'scope': The instance is created once per scope (e.g., per request).
20
- * - 'transient': A new instance is created every time it is requested.
21
- */
22
- type Lifetime = 'singleton' | 'scope' | 'transient';
23
- /**
24
- * Represents a binding in the dependency injection system.
25
- * It contains the lifetime of the binding, the implementation type, and optionally an instance.
26
- */
27
- interface IBinding {
28
- lifetime: Lifetime;
29
- implementation: Type<unknown>;
30
- instance?: InstanceType<Type<unknown>>;
31
- }
32
- /**
33
- * AppInjector is the root dependency injection container.
34
- * It is used to register and resolve dependencies in the application.
35
- * It supports different lifetimes for dependencies:
36
- * This should not be manually instantiated, outside of the framework.
37
- * Use the `RootInjector` instance instead.
38
- */
39
- declare class AppInjector {
40
- readonly name: string | null;
41
- bindings: Map<Type<unknown>, IBinding>;
42
- singletons: Map<Type<unknown>, unknown>;
43
- scoped: Map<Type<unknown>, unknown>;
44
- constructor(name?: string | null);
45
- /**
46
- * Typically used to create a dependency injection scope
47
- * at the "scope" level (i.e., per-request lifetime).
48
- *
49
- * SHOULD NOT BE USED by anything else than the framework itself.
50
- */
51
- createScope(): AppInjector;
52
- /**
53
- * Called when resolving a dependency,
54
- * i.e., retrieving the instance of a given class.
55
- */
56
- resolve<T extends Type<unknown>>(target: T): InstanceType<T>;
57
- /**
58
- *
59
- */
60
- private instantiate;
61
- }
62
- /**
63
- * Injects a type from the dependency injection system.
64
- * This function is used to retrieve an instance of a type that has been registered in the dependency injection system.
65
- * It is typically used in the constructor of a class to inject dependencies.
66
- * @param t - The type to inject.
67
- * @returns An instance of the type.
68
- * @throws If the type is not registered in the dependency injection system.
69
- */
70
- declare function inject<T>(t: Type<T>): T;
71
- declare const RootInjector: AppInjector;
72
-
73
-
74
- /**
75
- * IRouteMetadata interface defines the metadata for a route.
76
- * It includes the HTTP method, path, handler name, and guards associated with the route.
77
- * This metadata is used to register the route in the application.
78
- * This is the configuration that waits a route's decorator.
79
- */
80
- interface IRouteMetadata {
81
- method: HttpMethod;
82
- path: string;
83
- handler: string;
84
- guards: Type<IGuard>[];
85
- }
86
- /**
87
- * The different HTTP methods that can be used in the application.
88
- */
89
- type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'BATCH';
90
- /**
91
- * Atomic HTTP verbs supported by controllers. BATCH is handled at the router level only.
92
- */
93
- type AtomicHttpMethod = Exclude<HttpMethod, 'BATCH'>;
94
- /**
95
- * Gets the route metadata for a given target class.
96
- * This metadata includes the HTTP method, path, handler, and guards defined by the route decorators.
97
- * @see Get
98
- * @see Post
99
- * @see Put
100
- * @see Patch
101
- * @see Delete
102
- * @param target The target class to get the route metadata from.
103
- * @returns An array of route metadata if it exists, otherwise an empty array.
104
- */
105
- declare function getRouteMetadata(target: Type<unknown>): IRouteMetadata[];
106
- /**
107
- * Route decorator that defines a leaf in the routing tree, attaching it to a controller method
108
- * that will be called when the route is matched.
109
- * This route will have to be called with the GET method.
110
- */
111
- declare const Get: (path: string) => MethodDecorator;
112
- /**
113
- * Route decorator that defines a leaf in the routing tree, attaching it to a controller method
114
- * that will be called when the route is matched.
115
- * This route will have to be called with the POST method.
116
- */
117
- declare const Post: (path: string) => MethodDecorator;
118
- /**
119
- * Route decorator that defines a leaf in the routing tree, attaching it to a controller method
120
- * that will be called when the route is matched.
121
- * This route will have to be called with the PUT method.
122
- */
123
- declare const Put: (path: string) => MethodDecorator;
124
- /**
125
- * Route decorator that defines a leaf in the routing tree, attaching it to a controller method
126
- * that will be called when the route is matched.
127
- * This route will have to be called with the PATCH method.
128
- */
129
- declare const Patch: (path: string) => MethodDecorator;
130
- /**
131
- * Route decorator that defines a leaf in the routing tree, attaching it to a controller method
132
- * that will be called when the route is matched.
133
- * This route will have to be called with the DELETE method.
134
- */
135
- declare const Delete: (path: string) => MethodDecorator;
136
- declare const ROUTE_METADATA_KEY: unique symbol;
137
-
138
-
139
- /**
140
- * The Request class represents an HTTP request in the Noxus framework.
141
- * It encapsulates the request data, including the event, ID, method, path, and body.
142
- * It also provides a context for dependency injection through the AppInjector.
143
- */
144
- declare class Request {
145
- readonly event: Electron.MessageEvent;
146
- readonly id: string;
147
- readonly method: HttpMethod;
148
- readonly path: string;
149
- readonly body: any;
150
- readonly context: AppInjector;
151
- readonly params: Record<string, string>;
152
- constructor(event: Electron.MessageEvent, id: string, method: HttpMethod, path: string, body: any);
153
- }
154
- /**
155
- * The IRequest interface defines the structure of a request object.
156
- * It includes properties for the sender ID, request ID, path, method, and an optional body.
157
- * This interface is used to standardize the request data across the application.
158
- */
159
- interface IRequest<TBody = unknown> {
160
- senderId: number;
161
- requestId: string;
162
- path: string;
163
- method: HttpMethod;
164
- body?: TBody;
165
- }
166
- interface IBatchRequestItem<TBody = unknown> {
167
- requestId?: string;
168
- path: string;
169
- method: AtomicHttpMethod;
170
- body?: TBody;
171
- }
172
- interface IBatchRequestPayload {
173
- requests: IBatchRequestItem[];
174
- }
175
- /**
176
- * Creates a Request object from the IPC event data.
177
- * This function extracts the necessary information from the IPC event and constructs a Request instance.
178
- */
179
- interface IResponse<TBody = unknown> {
180
- requestId: string;
181
- status: number;
182
- body?: TBody;
183
- error?: string;
184
- stack?: string;
185
- }
186
- interface IBatchResponsePayload {
187
- responses: IResponse[];
188
- }
189
-
190
-
191
- /**
192
- * IGuard interface defines a guard that can be used to protect routes.
193
- * It has a `canActivate` method that takes a request and returns a MaybeAsync boolean.
194
- * The `canActivate` method can return either a value or a Promise.
195
- * Use it on a class that should be registered as a guard in the application.
196
- * Guards can be used to protect routes or controller actions.
197
- * For example, you can use guards to check if the user is authenticated or has the right permissions.
198
- * You can use the `Authorize` decorator to register guards for a controller or a controller action.
199
- * @see Authorize
200
- */
201
- interface IGuard {
202
- canActivate(request: Request): MaybeAsync<boolean>;
203
- }
204
- /**
205
- * Can be used to protect the routes of a controller.
206
- * Can be used on a controller class or on a controller method.
207
- */
208
- declare function Authorize(...guardClasses: Type<IGuard>[]): MethodDecorator & ClassDecorator;
209
- /**
210
- * Gets the guards for a controller or a controller action.
211
- * @param controllerName The name of the controller to get the guards for.
212
- * @returns An array of guards for the controller.
213
- */
214
- declare function getGuardForController(controllerName: string): Type<IGuard>[];
215
- /**
216
- * Gets the guards for a controller action.
217
- * @param controllerName The name of the controller to get the guards for.
218
- * @param actionName The name of the action to get the guards for.
219
- * @returns An array of guards for the controller action.
220
- */
221
- declare function getGuardForControllerAction(controllerName: string, actionName: string): Type<IGuard>[];
222
-
223
9
 
224
10
  /**
225
11
  * NextFunction is a function that is called to continue the middleware chain.
@@ -374,6 +160,20 @@ declare class Router {
374
160
  private extractParams;
375
161
  }
376
162
 
163
+ interface RendererChannels {
164
+ request: Electron.MessageChannelMain;
165
+ socket: Electron.MessageChannelMain;
166
+ }
167
+ declare class NoxSocket {
168
+ private readonly channels;
169
+ register(senderId: number, requestChannel: Electron.MessageChannelMain, socketChannel: Electron.MessageChannelMain): void;
170
+ get(senderId: number): RendererChannels | undefined;
171
+ unregister(senderId: number): void;
172
+ getSenderIds(): number[];
173
+ emit<TPayload = unknown>(eventName: string, payload?: TPayload, targetSenderIds?: number[]): number;
174
+ emitToRenderer<TPayload = unknown>(senderId: number, eventName: string, payload?: TPayload): boolean;
175
+ }
176
+
377
177
 
378
178
  /**
379
179
  * The application service should implement this interface, as
@@ -391,9 +191,13 @@ interface IApp {
391
191
  */
392
192
  declare class NoxApp {
393
193
  private readonly router;
394
- private readonly messagePorts;
194
+ private readonly socket;
395
195
  private app;
396
- constructor(router: Router);
196
+ /**
197
+ *
198
+ */
199
+ private readonly onRendererMessage;
200
+ constructor(router: Router, socket: NoxSocket);
397
201
  /**
398
202
  * Initializes the NoxApp instance.
399
203
  * This method sets up the IPC communication, registers event listeners,
@@ -407,11 +211,6 @@ declare class NoxApp {
407
211
  * to the renderer process using the MessageChannel.
408
212
  */
409
213
  private giveTheRendererAPort;
410
- /**
411
- * Electron specific message handling.
412
- * Replaces HTTP calls by using Electron's IPC mechanism.
413
- */
414
- private onRendererMessage;
415
214
  /**
416
215
  * MacOS specific behavior.
417
216
  */
@@ -560,6 +359,10 @@ declare function Controller(path: string): ClassDecorator;
560
359
  declare function getControllerMetadata(target: Type<unknown>): IControllerMetadata | undefined;
561
360
  declare const CONTROLLER_METADATA_KEY: unique symbol;
562
361
 
362
+ declare const INJECTABLE_METADATA_KEY: unique symbol;
363
+ declare function getInjectableMetadata(target: Function): Lifetime | undefined;
364
+ declare function hasInjectableMetadata(target: Function): boolean;
365
+
563
366
 
564
367
  /**
565
368
  * The Injectable decorator marks a class as injectable.
@@ -569,14 +372,6 @@ declare const CONTROLLER_METADATA_KEY: unique symbol;
569
372
  * @param lifetime - The lifetime of the injectable. Can be 'singleton', 'scope', or 'transient'.
570
373
  */
571
374
  declare function Injectable(lifetime?: Lifetime): ClassDecorator;
572
- /**
573
- * Gets the injectable metadata for a given target class.
574
- * This metadata includes the lifetime of the injectable defined by the @Injectable decorator.
575
- * @param target - The target class to get the injectable metadata from.
576
- * @returns The lifetime of the injectable if it exists, otherwise undefined.
577
- */
578
- declare function getInjectableMetadata(target: Type<unknown>): Lifetime | undefined;
579
- declare const INJECTABLE_METADATA_KEY: unique symbol;
580
375
 
581
376
 
582
377
  interface IModuleMetadata {
@@ -595,6 +390,23 @@ declare function Module(metadata: IModuleMetadata): ClassDecorator;
595
390
  declare function getModuleMetadata(target: Function): IModuleMetadata | undefined;
596
391
  declare const MODULE_METADATA_KEY: unique symbol;
597
392
 
393
+
394
+ interface NoxusPreloadAPI extends IPortRequester {
395
+ }
396
+ interface NoxusPreloadOptions {
397
+ exposeAs?: string;
398
+ initMessageType?: string;
399
+ requestChannel?: string;
400
+ responseChannel?: string;
401
+ targetWindow?: Window;
402
+ }
403
+ /**
404
+ * Exposes a minimal bridge in the isolated preload context so renderer processes
405
+ * can request the two MessagePorts required by Noxus. The bridge forwards both
406
+ * request/response and socket ports to the renderer via window.postMessage.
407
+ */
408
+ declare function exposeNoxusBridge(options?: NoxusPreloadOptions): NoxusPreloadAPI;
409
+
598
410
  /**
599
411
  * Logger is a utility class for logging messages to the console.
600
412
  */
@@ -670,4 +482,4 @@ declare namespace Logger {
670
482
  };
671
483
  }
672
484
 
673
- export { AppInjector, type AtomicHttpMethod, Authorize, BadGatewayException, BadRequestException, CONTROLLER_METADATA_KEY, ConflictException, Controller, type ControllerAction, Delete, ForbiddenException, GatewayTimeoutException, Get, type HttpMethod, HttpVersionNotSupportedException, type IApp, type IBatchRequestItem, type IBatchRequestPayload, type IBatchResponsePayload, type IBinding, type IControllerMetadata, type IGuard, type IMiddleware, type IModuleMetadata, INJECTABLE_METADATA_KEY, type IRequest, type IResponse, type IRouteDefinition, type IRouteMetadata, Injectable, InsufficientStorageException, InternalServerException, type Lifetime, type LogLevel, Logger, LoopDetectedException, MODULE_METADATA_KEY, type MaybeAsync, MethodNotAllowedException, Module, NetworkAuthenticationRequiredException, NetworkConnectTimeoutException, type NextFunction, NotAcceptableException, NotExtendedException, NotFoundException, NotImplementedException, NoxApp, Patch, PaymentRequiredException, Post, Put, ROUTE_METADATA_KEY, Request, RequestTimeoutException, ResponseException, RootInjector, Router, ServiceUnavailableException, TooManyRequestsException, type Type, UnauthorizedException, UpgradeRequiredException, UseMiddlewares, VariantAlsoNegotiatesException, bootstrapApplication, getControllerMetadata, getGuardForController, getGuardForControllerAction, getInjectableMetadata, getMiddlewaresForController, getMiddlewaresForControllerAction, getModuleMetadata, getRouteMetadata, inject };
485
+ export { BadGatewayException, BadRequestException, CONTROLLER_METADATA_KEY, ConflictException, Controller, type ControllerAction, ForbiddenException, GatewayTimeoutException, HttpVersionNotSupportedException, type IApp, type IControllerMetadata, IGuard, type IMiddleware, type IModuleMetadata, INJECTABLE_METADATA_KEY, IPortRequester, IResponse, type IRouteDefinition, Injectable, InsufficientStorageException, InternalServerException, Lifetime, type LogLevel, Logger, LoopDetectedException, MODULE_METADATA_KEY, MaybeAsync, MethodNotAllowedException, Module, NetworkAuthenticationRequiredException, NetworkConnectTimeoutException, type NextFunction, NotAcceptableException, NotExtendedException, NotFoundException, NotImplementedException, NoxApp, NoxSocket, type NoxusPreloadAPI, type NoxusPreloadOptions, PaymentRequiredException, Request, RequestTimeoutException, ResponseException, Router, ServiceUnavailableException, TooManyRequestsException, Type, UnauthorizedException, UpgradeRequiredException, UseMiddlewares, VariantAlsoNegotiatesException, bootstrapApplication, exposeNoxusBridge, getControllerMetadata, getInjectableMetadata, getMiddlewaresForController, getMiddlewaresForControllerAction, getModuleMetadata, hasInjectableMetadata };