@noxfly/noxus 1.2.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/copilot-instructions.md +32 -0
- package/README.md +36 -127
- package/dist/{index-5OkVPHfI.d.mts → index-CI3OMzNR.d.mts} +52 -2
- package/dist/{index-5OkVPHfI.d.ts → index-CI3OMzNR.d.ts} +52 -2
- package/dist/main.d.mts +62 -16
- package/dist/main.d.ts +62 -16
- package/dist/main.js +586 -99
- package/dist/main.mjs +573 -99
- package/dist/renderer.d.mts +1 -1
- package/dist/renderer.d.ts +1 -1
- package/dist/renderer.js +251 -1
- package/dist/renderer.mjs +250 -1
- package/package.json +2 -2
- package/src/DI/injector-explorer.ts +1 -1
- package/src/app.ts +24 -15
- package/src/decorators/injectable.decorator.ts +6 -17
- package/src/decorators/injectable.metadata.ts +15 -0
- package/src/index.ts +1 -0
- package/src/main.ts +6 -0
- package/src/preload-bridge.ts +75 -0
- package/src/renderer-client.ts +338 -0
- package/src/request.ts +1 -0
- package/src/router.ts +45 -11
- package/src/socket.ts +14 -9
- package/src/utils/logger.ts +266 -87
package/dist/main.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as Request, I as IResponse, M as MaybeAsync, T as Type, a as IGuard, L as Lifetime } from './index-
|
|
2
|
-
export { A as AppInjector,
|
|
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
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @copyright 2025 NoxFly
|
|
@@ -160,10 +160,14 @@ declare class Router {
|
|
|
160
160
|
private extractParams;
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
+
interface RendererChannels {
|
|
164
|
+
request: Electron.MessageChannelMain;
|
|
165
|
+
socket: Electron.MessageChannelMain;
|
|
166
|
+
}
|
|
163
167
|
declare class NoxSocket {
|
|
164
|
-
private readonly
|
|
165
|
-
register(senderId: number,
|
|
166
|
-
get(senderId: number):
|
|
168
|
+
private readonly channels;
|
|
169
|
+
register(senderId: number, requestChannel: Electron.MessageChannelMain, socketChannel: Electron.MessageChannelMain): void;
|
|
170
|
+
get(senderId: number): RendererChannels | undefined;
|
|
167
171
|
unregister(senderId: number): void;
|
|
168
172
|
getSenderIds(): number[];
|
|
169
173
|
emit<TPayload = unknown>(eventName: string, payload?: TPayload, targetSenderIds?: number[]): number;
|
|
@@ -189,6 +193,9 @@ declare class NoxApp {
|
|
|
189
193
|
private readonly router;
|
|
190
194
|
private readonly socket;
|
|
191
195
|
private app;
|
|
196
|
+
/**
|
|
197
|
+
*
|
|
198
|
+
*/
|
|
192
199
|
private readonly onRendererMessage;
|
|
193
200
|
constructor(router: Router, socket: NoxSocket);
|
|
194
201
|
/**
|
|
@@ -352,6 +359,10 @@ declare function Controller(path: string): ClassDecorator;
|
|
|
352
359
|
declare function getControllerMetadata(target: Type<unknown>): IControllerMetadata | undefined;
|
|
353
360
|
declare const CONTROLLER_METADATA_KEY: unique symbol;
|
|
354
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
|
+
|
|
355
366
|
|
|
356
367
|
/**
|
|
357
368
|
* The Injectable decorator marks a class as injectable.
|
|
@@ -361,14 +372,6 @@ declare const CONTROLLER_METADATA_KEY: unique symbol;
|
|
|
361
372
|
* @param lifetime - The lifetime of the injectable. Can be 'singleton', 'scope', or 'transient'.
|
|
362
373
|
*/
|
|
363
374
|
declare function Injectable(lifetime?: Lifetime): ClassDecorator;
|
|
364
|
-
/**
|
|
365
|
-
* Gets the injectable metadata for a given target class.
|
|
366
|
-
* This metadata includes the lifetime of the injectable defined by the @Injectable decorator.
|
|
367
|
-
* @param target - The target class to get the injectable metadata from.
|
|
368
|
-
* @returns The lifetime of the injectable if it exists, otherwise undefined.
|
|
369
|
-
*/
|
|
370
|
-
declare function getInjectableMetadata(target: Type<unknown>): Lifetime | undefined;
|
|
371
|
-
declare const INJECTABLE_METADATA_KEY: unique symbol;
|
|
372
375
|
|
|
373
376
|
|
|
374
377
|
interface IModuleMetadata {
|
|
@@ -387,18 +390,40 @@ declare function Module(metadata: IModuleMetadata): ClassDecorator;
|
|
|
387
390
|
declare function getModuleMetadata(target: Function): IModuleMetadata | undefined;
|
|
388
391
|
declare const MODULE_METADATA_KEY: unique symbol;
|
|
389
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
|
+
|
|
390
410
|
/**
|
|
391
411
|
* Logger is a utility class for logging messages to the console.
|
|
392
412
|
*/
|
|
393
|
-
type LogLevel = '
|
|
413
|
+
type LogLevel = 'debug' | 'comment' | 'log' | 'info' | 'warn' | 'error' | 'critical';
|
|
394
414
|
declare namespace Logger {
|
|
395
415
|
/**
|
|
396
416
|
* Sets the log level for the logger.
|
|
397
417
|
* This function allows you to change the log level dynamically at runtime.
|
|
398
418
|
* This won't affect the startup logs.
|
|
419
|
+
*
|
|
420
|
+
* If the parameter is a single LogLevel, all log levels with equal or higher severity will be enabled.
|
|
421
|
+
|
|
422
|
+
* If the parameter is an array of LogLevels, only the specified levels will be enabled.
|
|
423
|
+
*
|
|
399
424
|
* @param level Sets the log level for the logger.
|
|
400
425
|
*/
|
|
401
|
-
function setLogLevel(level: LogLevel): void;
|
|
426
|
+
function setLogLevel(level: LogLevel | LogLevel[]): void;
|
|
402
427
|
/**
|
|
403
428
|
* Logs a message to the console with log level LOG.
|
|
404
429
|
* This function formats the message with a timestamp, process ID, and the name of the caller function or class.
|
|
@@ -427,6 +452,9 @@ declare namespace Logger {
|
|
|
427
452
|
* @param args The arguments to log.
|
|
428
453
|
*/
|
|
429
454
|
function error(...args: any[]): void;
|
|
455
|
+
/**
|
|
456
|
+
* Logs a message to the console with log level ERROR and a grey color scheme.
|
|
457
|
+
*/
|
|
430
458
|
function errorStack(...args: any[]): void;
|
|
431
459
|
/**
|
|
432
460
|
* Logs a message to the console with log level DEBUG.
|
|
@@ -442,6 +470,24 @@ declare namespace Logger {
|
|
|
442
470
|
* @param args The arguments to log.
|
|
443
471
|
*/
|
|
444
472
|
function comment(...args: any[]): void;
|
|
473
|
+
/**
|
|
474
|
+
* Logs a message to the console with log level CRITICAL.
|
|
475
|
+
* This function formats the message with a timestamp, process ID, and the name of the caller function or class.
|
|
476
|
+
* It uses different colors for different log levels to enhance readability.
|
|
477
|
+
* @param args The arguments to log.
|
|
478
|
+
*/
|
|
479
|
+
function critical(...args: any[]): void;
|
|
480
|
+
/**
|
|
481
|
+
* Enables logging to a file output for the specified log levels.
|
|
482
|
+
* @param filepath The path to the log file.
|
|
483
|
+
* @param levels The log levels to enable file logging for. Defaults to all levels.
|
|
484
|
+
*/
|
|
485
|
+
function enableFileLogging(filepath: string, levels?: LogLevel[]): void;
|
|
486
|
+
/**
|
|
487
|
+
* Disables logging to a file output for the specified log levels.
|
|
488
|
+
* @param levels The log levels to disable file logging for. Defaults to all levels.
|
|
489
|
+
*/
|
|
490
|
+
function disableFileLogging(levels?: LogLevel[]): void;
|
|
445
491
|
const colors: {
|
|
446
492
|
black: string;
|
|
447
493
|
grey: string;
|
|
@@ -462,4 +508,4 @@ declare namespace Logger {
|
|
|
462
508
|
};
|
|
463
509
|
}
|
|
464
510
|
|
|
465
|
-
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, 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, PaymentRequiredException, Request, RequestTimeoutException, ResponseException, Router, ServiceUnavailableException, TooManyRequestsException, Type, UnauthorizedException, UpgradeRequiredException, UseMiddlewares, VariantAlsoNegotiatesException, bootstrapApplication, getControllerMetadata, getInjectableMetadata, getMiddlewaresForController, getMiddlewaresForControllerAction, getModuleMetadata };
|
|
511
|
+
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 };
|