@noxfly/noxus 3.0.0-dev.3 → 3.0.0-dev.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +114 -7
- package/dist/child.d.mts +7 -1
- package/dist/child.d.ts +7 -1
- package/dist/child.js +402 -862
- package/dist/child.js.map +1 -0
- package/dist/child.mjs +389 -850
- package/dist/child.mjs.map +1 -0
- package/dist/main.d.mts +171 -125
- package/dist/main.d.ts +171 -125
- package/dist/main.js +967 -886
- package/dist/main.js.map +1 -0
- package/dist/main.mjs +914 -834
- package/dist/main.mjs.map +1 -0
- package/dist/preload.js.map +1 -0
- package/dist/preload.mjs.map +1 -0
- package/dist/renderer.d.mts +17 -2
- package/dist/renderer.d.ts +17 -2
- package/dist/renderer.js +161 -118
- package/dist/renderer.js.map +1 -0
- package/dist/renderer.mjs +150 -106
- package/dist/renderer.mjs.map +1 -0
- package/package.json +10 -9
- package/.editorconfig +0 -16
- package/.github/copilot-instructions.md +0 -32
- package/.vscode/settings.json +0 -3
- package/eslint.config.js +0 -109
- package/scripts/postbuild.js +0 -31
- package/src/DI/app-injector.ts +0 -160
- package/src/DI/injector-explorer.ts +0 -143
- package/src/DI/token.ts +0 -53
- package/src/decorators/controller.decorator.ts +0 -58
- package/src/decorators/guards.decorator.ts +0 -15
- package/src/decorators/injectable.decorator.ts +0 -81
- package/src/decorators/method.decorator.ts +0 -66
- package/src/decorators/middleware.decorator.ts +0 -15
- package/src/index.ts +0 -10
- package/src/internal/app.ts +0 -217
- package/src/internal/bootstrap.ts +0 -109
- package/src/internal/exceptions.ts +0 -57
- package/src/internal/preload-bridge.ts +0 -75
- package/src/internal/renderer-client.ts +0 -338
- package/src/internal/renderer-events.ts +0 -110
- package/src/internal/request.ts +0 -97
- package/src/internal/router.ts +0 -353
- package/src/internal/routes.ts +0 -78
- package/src/internal/socket.ts +0 -73
- package/src/main.ts +0 -26
- package/src/non-electron-process.ts +0 -22
- package/src/preload.ts +0 -10
- package/src/renderer.ts +0 -13
- package/src/utils/forward-ref.ts +0 -31
- package/src/utils/logger.ts +0 -430
- package/src/utils/radix-tree.ts +0 -210
- package/src/utils/types.ts +0 -21
- package/src/window/window-manager.ts +0 -268
- package/tsconfig.json +0 -29
- package/tsup.config.ts +0 -50
package/dist/renderer.mjs
CHANGED
|
@@ -4,131 +4,155 @@
|
|
|
4
4
|
* @author NoxFly
|
|
5
5
|
*/
|
|
6
6
|
var __defProp = Object.defineProperty;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
8
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
var __esm = (fn, res) => function __init() {
|
|
10
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
11
|
+
};
|
|
8
12
|
|
|
9
13
|
// src/utils/forward-ref.ts
|
|
10
|
-
var _ForwardReference
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
var _ForwardReference, ForwardReference;
|
|
15
|
+
var init_forward_ref = __esm({
|
|
16
|
+
"src/utils/forward-ref.ts"() {
|
|
17
|
+
"use strict";
|
|
18
|
+
_ForwardReference = class _ForwardReference {
|
|
19
|
+
constructor(forwardRefFn) {
|
|
20
|
+
this.forwardRefFn = forwardRefFn;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
__name(_ForwardReference, "ForwardReference");
|
|
24
|
+
ForwardReference = _ForwardReference;
|
|
13
25
|
}
|
|
14
|
-
};
|
|
15
|
-
__name(_ForwardReference, "ForwardReference");
|
|
16
|
-
var ForwardReference = _ForwardReference;
|
|
26
|
+
});
|
|
17
27
|
|
|
18
28
|
// src/DI/token.ts
|
|
19
|
-
var _Token
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
29
|
+
var _Token, Token;
|
|
30
|
+
var init_token = __esm({
|
|
31
|
+
"src/DI/token.ts"() {
|
|
32
|
+
"use strict";
|
|
33
|
+
_Token = class _Token {
|
|
34
|
+
constructor(target) {
|
|
35
|
+
this.target = target;
|
|
36
|
+
this.description = typeof target === "string" ? target : target.name;
|
|
37
|
+
}
|
|
38
|
+
toString() {
|
|
39
|
+
return `Token(${this.description})`;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
__name(_Token, "Token");
|
|
43
|
+
Token = _Token;
|
|
26
44
|
}
|
|
27
|
-
};
|
|
28
|
-
__name(_Token, "Token");
|
|
29
|
-
var Token = _Token;
|
|
45
|
+
});
|
|
30
46
|
|
|
31
47
|
// src/DI/app-injector.ts
|
|
32
48
|
function keyOf(k) {
|
|
33
49
|
return k;
|
|
34
50
|
}
|
|
35
|
-
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (!this.bindings.has(k)) {
|
|
58
|
-
this.bindings.set(k, { lifetime, implementation, deps });
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Resolves a dependency by token or class reference.
|
|
63
|
-
*/
|
|
64
|
-
resolve(target) {
|
|
65
|
-
if (target instanceof ForwardReference) {
|
|
66
|
-
return this._resolveForwardRef(target);
|
|
67
|
-
}
|
|
68
|
-
const k = keyOf(target);
|
|
69
|
-
if (this.singletons.has(k)) {
|
|
70
|
-
return this.singletons.get(k);
|
|
71
|
-
}
|
|
72
|
-
const binding = this.bindings.get(k);
|
|
73
|
-
if (!binding) {
|
|
74
|
-
const name = target instanceof Token ? target.description : target.name ?? "unknown";
|
|
75
|
-
throw new Error(
|
|
76
|
-
`[Noxus DI] No binding found for "${name}".
|
|
77
|
-
Did you forget to declare it in @Injectable({ deps }) or in bootstrapApplication({ singletons })?`
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
switch (binding.lifetime) {
|
|
81
|
-
case "transient":
|
|
82
|
-
return this._instantiate(binding);
|
|
83
|
-
case "scope": {
|
|
84
|
-
if (this.scoped.has(k)) return this.scoped.get(k);
|
|
85
|
-
const inst = this._instantiate(binding);
|
|
86
|
-
this.scoped.set(k, inst);
|
|
87
|
-
return inst;
|
|
51
|
+
var _AppInjector, AppInjector, RootInjector;
|
|
52
|
+
var init_app_injector = __esm({
|
|
53
|
+
"src/DI/app-injector.ts"() {
|
|
54
|
+
"use strict";
|
|
55
|
+
init_forward_ref();
|
|
56
|
+
init_token();
|
|
57
|
+
__name(keyOf, "keyOf");
|
|
58
|
+
_AppInjector = class _AppInjector {
|
|
59
|
+
constructor(name = null) {
|
|
60
|
+
this.name = name;
|
|
61
|
+
this.bindings = /* @__PURE__ */ new Map();
|
|
62
|
+
this.singletons = /* @__PURE__ */ new Map();
|
|
63
|
+
this.scoped = /* @__PURE__ */ new Map();
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Creates a child scope for per-request lifetime resolution.
|
|
67
|
+
*/
|
|
68
|
+
createScope() {
|
|
69
|
+
const scope = new _AppInjector();
|
|
70
|
+
scope.bindings = this.bindings;
|
|
71
|
+
scope.singletons = this.singletons;
|
|
72
|
+
return scope;
|
|
88
73
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Registers a binding explicitly.
|
|
76
|
+
*/
|
|
77
|
+
register(key, implementation, lifetime, deps = []) {
|
|
78
|
+
const k = keyOf(key);
|
|
79
|
+
if (!this.bindings.has(k)) {
|
|
80
|
+
this.bindings.set(k, { lifetime, implementation, deps });
|
|
95
81
|
}
|
|
96
|
-
return inst;
|
|
97
82
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
83
|
+
/**
|
|
84
|
+
* Resolves a dependency by token or class reference.
|
|
85
|
+
*/
|
|
86
|
+
resolve(target) {
|
|
87
|
+
if (target instanceof ForwardReference) {
|
|
88
|
+
return this._resolveForwardRef(target);
|
|
89
|
+
}
|
|
90
|
+
const k = keyOf(target);
|
|
91
|
+
if (this.singletons.has(k)) {
|
|
92
|
+
return this.singletons.get(k);
|
|
93
|
+
}
|
|
94
|
+
const binding = this.bindings.get(k);
|
|
95
|
+
if (!binding) {
|
|
96
|
+
const name = target instanceof Token ? target.description : target.name ?? "unknown";
|
|
97
|
+
throw new Error(
|
|
98
|
+
`[Noxus DI] No binding found for "${name}".
|
|
99
|
+
Did you forget to declare it in @Injectable({ deps }) or in bootstrapApplication({ singletons })?`
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
switch (binding.lifetime) {
|
|
103
|
+
case "transient":
|
|
104
|
+
return this._instantiate(binding);
|
|
105
|
+
case "scope": {
|
|
106
|
+
if (this.scoped.has(k)) return this.scoped.get(k);
|
|
107
|
+
const inst = this._instantiate(binding);
|
|
108
|
+
this.scoped.set(k, inst);
|
|
109
|
+
return inst;
|
|
110
|
+
}
|
|
111
|
+
case "singleton": {
|
|
112
|
+
if (this.singletons.has(k)) return this.singletons.get(k);
|
|
113
|
+
const inst = this._instantiate(binding);
|
|
114
|
+
this.singletons.set(k, inst);
|
|
115
|
+
if (binding.instance === void 0) {
|
|
116
|
+
binding.instance = inst;
|
|
117
|
+
}
|
|
118
|
+
return inst;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// -------------------------------------------------------------------------
|
|
123
|
+
_resolveForwardRef(ref) {
|
|
124
|
+
let resolved;
|
|
125
|
+
return new Proxy({}, {
|
|
126
|
+
get: /* @__PURE__ */ __name((_obj, prop, receiver) => {
|
|
127
|
+
resolved ?? (resolved = this.resolve(ref.forwardRefFn()));
|
|
128
|
+
const value = Reflect.get(resolved, prop, receiver);
|
|
129
|
+
return typeof value === "function" ? value.bind(resolved) : value;
|
|
130
|
+
}, "get"),
|
|
131
|
+
set: /* @__PURE__ */ __name((_obj, prop, value, receiver) => {
|
|
132
|
+
resolved ?? (resolved = this.resolve(ref.forwardRefFn()));
|
|
133
|
+
return Reflect.set(resolved, prop, value, receiver);
|
|
134
|
+
}, "set"),
|
|
135
|
+
getPrototypeOf: /* @__PURE__ */ __name(() => {
|
|
136
|
+
resolved ?? (resolved = this.resolve(ref.forwardRefFn()));
|
|
137
|
+
return Object.getPrototypeOf(resolved);
|
|
138
|
+
}, "getPrototypeOf")
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
_instantiate(binding) {
|
|
142
|
+
const resolvedDeps = binding.deps.map((dep) => this.resolve(dep));
|
|
143
|
+
return new binding.implementation(...resolvedDeps);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
__name(_AppInjector, "AppInjector");
|
|
147
|
+
AppInjector = _AppInjector;
|
|
148
|
+
RootInjector = new AppInjector("root");
|
|
123
149
|
}
|
|
124
|
-
};
|
|
125
|
-
__name(_AppInjector, "AppInjector");
|
|
126
|
-
var AppInjector = _AppInjector;
|
|
127
|
-
var RootInjector = new AppInjector("root");
|
|
150
|
+
});
|
|
128
151
|
|
|
129
152
|
// src/internal/request.ts
|
|
153
|
+
init_app_injector();
|
|
130
154
|
var _Request = class _Request {
|
|
131
|
-
constructor(event, senderId, id, method, path, body) {
|
|
155
|
+
constructor(event, senderId, id, method, path, body, query) {
|
|
132
156
|
this.event = event;
|
|
133
157
|
this.senderId = senderId;
|
|
134
158
|
this.id = id;
|
|
@@ -138,6 +162,7 @@ var _Request = class _Request {
|
|
|
138
162
|
this.context = RootInjector.createScope();
|
|
139
163
|
this.params = {};
|
|
140
164
|
this.path = path.replace(/^\/|\/$/g, "");
|
|
165
|
+
this.query = query ?? {};
|
|
141
166
|
}
|
|
142
167
|
};
|
|
143
168
|
__name(_Request, "Request");
|
|
@@ -340,6 +365,9 @@ var _NoxRendererClient = class _NoxRendererClient {
|
|
|
340
365
|
console.error(`[Noxus] No pending handler found for request ${response.requestId}.`);
|
|
341
366
|
return;
|
|
342
367
|
}
|
|
368
|
+
if (pending.timer !== void 0) {
|
|
369
|
+
clearTimeout(pending.timer);
|
|
370
|
+
}
|
|
343
371
|
this.pendingRequests.delete(response.requestId);
|
|
344
372
|
this.onRequestCompleted(pending, response);
|
|
345
373
|
if (response.status >= 400) {
|
|
@@ -353,6 +381,8 @@ var _NoxRendererClient = class _NoxRendererClient {
|
|
|
353
381
|
this.bridge = resolvedBridge ?? null;
|
|
354
382
|
this.initMessageType = options.initMessageType ?? DEFAULT_INIT_EVENT;
|
|
355
383
|
this.generateRequestId = options.generateRequestId ?? defaultRequestId;
|
|
384
|
+
this.requestTimeout = options.requestTimeout ?? 1e4;
|
|
385
|
+
this.enableLogging = options.enableLogging ?? true;
|
|
356
386
|
}
|
|
357
387
|
async setup() {
|
|
358
388
|
if (this.isReady) {
|
|
@@ -380,6 +410,11 @@ var _NoxRendererClient = class _NoxRendererClient {
|
|
|
380
410
|
this.socketPort = void 0;
|
|
381
411
|
this.senderId = void 0;
|
|
382
412
|
this.isReady = false;
|
|
413
|
+
for (const pending of this.pendingRequests.values()) {
|
|
414
|
+
if (pending.timer !== void 0) {
|
|
415
|
+
clearTimeout(pending.timer);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
383
418
|
this.pendingRequests.clear();
|
|
384
419
|
}
|
|
385
420
|
async request(request) {
|
|
@@ -404,6 +439,12 @@ var _NoxRendererClient = class _NoxRendererClient {
|
|
|
404
439
|
request: message,
|
|
405
440
|
submittedAt: Date.now()
|
|
406
441
|
};
|
|
442
|
+
if (this.requestTimeout > 0) {
|
|
443
|
+
pending.timer = setTimeout(() => {
|
|
444
|
+
this.pendingRequests.delete(message.requestId);
|
|
445
|
+
reject(this.createErrorResponse(message.requestId, `Request timed out after ${this.requestTimeout}ms`));
|
|
446
|
+
}, this.requestTimeout);
|
|
447
|
+
}
|
|
407
448
|
this.pendingRequests.set(message.requestId, pending);
|
|
408
449
|
this.requestPort.postMessage(message);
|
|
409
450
|
});
|
|
@@ -421,6 +462,9 @@ var _NoxRendererClient = class _NoxRendererClient {
|
|
|
421
462
|
return this.senderId;
|
|
422
463
|
}
|
|
423
464
|
onRequestCompleted(pending, response) {
|
|
465
|
+
if (!this.enableLogging) {
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
424
468
|
if (typeof console.groupCollapsed === "function") {
|
|
425
469
|
console.groupCollapsed(`${response.status} ${pending.request.method} /${pending.request.path}`);
|
|
426
470
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/forward-ref.ts","../src/DI/token.ts","../src/DI/app-injector.ts","../src/internal/request.ts","../src/internal/renderer-events.ts","../src/internal/renderer-client.ts"],"sourcesContent":["/**\r\n * @copyright 2025 NoxFly\r\n * @license MIT\r\n * @author NoxFly\r\n */\r\n\r\nimport { Type } from \"./types\";\r\n\r\n/**\r\n * A function that returns a type.\r\n * Used for forward references to types that are not yet defined.\r\n */\r\nexport interface ForwardRefFn<T = any> {\r\n (): Type<T>;\r\n}\r\n\r\n/**\r\n * A wrapper class for forward referenced types.\r\n */\r\nexport class ForwardReference<T = any> {\r\n constructor(public readonly forwardRefFn: ForwardRefFn<T>) {}\r\n}\r\n\r\n/**\r\n * Creates a forward reference to a type.\r\n * @param fn A function that returns the type.\r\n * @returns A ForwardReference instance.\r\n */\r\nexport function forwardRef<T = any>(fn: ForwardRefFn<T>): ForwardReference<T> {\r\n return new ForwardReference(fn);\r\n}\r\n","/**\r\n * @copyright 2025 NoxFly\r\n * @license MIT\r\n * @author NoxFly\r\n */\r\n\r\nimport { Type } from '../utils/types';\r\n\r\n/**\r\n * A DI token uniquely identifies a dependency.\r\n * It can wrap a class (Type<T>) or be a named symbol token.\r\n *\r\n * Using tokens instead of reflect-metadata means dependencies are\r\n * declared explicitly — no magic type inference, no emitDecoratorMetadata.\r\n *\r\n * @example\r\n * // Class token (most common)\r\n * const MY_SERVICE = token(MyService);\r\n *\r\n * // Named symbol token (for interfaces or non-class values)\r\n * const DB_URL = token<string>('DB_URL');\r\n */\r\nexport class Token<T> {\r\n public readonly description: string;\r\n\r\n constructor(\r\n public readonly target: Type<T> | string,\r\n ) {\r\n this.description = typeof target === 'string' ? target : target.name;\r\n }\r\n\r\n public toString(): string {\r\n return `Token(${this.description})`;\r\n }\r\n}\r\n\r\n/**\r\n * Creates a DI token for a class type or a named value.\r\n *\r\n * @example\r\n * export const MY_SERVICE = token(MyService);\r\n * export const DB_URL = token<string>('DB_URL');\r\n */\r\nexport function token<T>(target: Type<T> | string): Token<T> {\r\n return new Token<T>(target);\r\n}\r\n\r\n/**\r\n * The key used to look up a class token in the registry.\r\n * For class tokens, the key is the class constructor itself.\r\n * For named tokens, the key is the Token instance.\r\n */\r\nexport type TokenKey<T = unknown> = Type<T> | Token<T>;\r\n","/**\r\n * @copyright 2025 NoxFly\r\n * @license MIT\r\n * @author NoxFly\r\n */\r\n\r\nimport { ForwardReference } from '../utils/forward-ref';\r\nimport { Type } from '../utils/types';\r\nimport { Token, TokenKey } from './token';\r\n\r\n/**\r\n * Lifetime of a binding in the DI container.\r\n * - singleton: created once, shared for the lifetime of the app.\r\n * - scope: created once per request scope.\r\n * - transient: new instance every time it is resolved.\r\n */\r\nexport type Lifetime = 'singleton' | 'scope' | 'transient';\r\n\r\n/**\r\n * Internal representation of a registered binding.\r\n */\r\nexport interface IBinding<T = unknown> {\r\n lifetime: Lifetime;\r\n implementation: Type<T>;\r\n /** Explicit constructor dependencies, declared by the class itself. */\r\n deps: ReadonlyArray<TokenKey>;\r\n instance?: T;\r\n}\r\n\r\nfunction keyOf<T>(k: TokenKey<T>): Type<T> | Token<T> {\r\n return k;\r\n}\r\n\r\n/**\r\n * AppInjector is the core DI container.\r\n * It no longer uses reflect-metadata — all dependency information\r\n * comes from explicitly declared `deps` arrays on each binding.\r\n */\r\nexport class AppInjector {\r\n public readonly bindings = new Map<Type<unknown> | Token<unknown>, IBinding<unknown>>();\r\n public readonly singletons = new Map<Type<unknown> | Token<unknown>, unknown>();\r\n public readonly scoped = new Map<Type<unknown> | Token<unknown>, unknown>();\r\n\r\n constructor(public readonly name: string | null = null) {}\r\n\r\n /**\r\n * Creates a child scope for per-request lifetime resolution.\r\n */\r\n public createScope(): AppInjector {\r\n const scope = new AppInjector();\r\n (scope as any).bindings = this.bindings;\r\n (scope as any).singletons = this.singletons;\r\n return scope;\r\n }\r\n\r\n /**\r\n * Registers a binding explicitly.\r\n */\r\n public register<T>(\r\n key: TokenKey<T>,\r\n implementation: Type<T>,\r\n lifetime: Lifetime,\r\n deps: ReadonlyArray<TokenKey> = [],\r\n ): void {\r\n const k = keyOf(key) as TokenKey<unknown>;\r\n if (!this.bindings.has(k)) {\r\n this.bindings.set(k, { lifetime, implementation: implementation as Type<unknown>, deps });\r\n }\r\n }\r\n\r\n /**\r\n * Resolves a dependency by token or class reference.\r\n */\r\n public resolve<T>(target: TokenKey<T> | ForwardReference<T>): T {\r\n if (target instanceof ForwardReference) {\r\n return this._resolveForwardRef(target);\r\n }\r\n\r\n const k = keyOf(target) as TokenKey<unknown>;\r\n\r\n if (this.singletons.has(k)) {\r\n return this.singletons.get(k) as T;\r\n }\r\n\r\n const binding = this.bindings.get(k);\r\n\r\n if (!binding) {\r\n const name = target instanceof Token\r\n ? target.description\r\n : (target as Type<unknown>).name\r\n ?? 'unknown';\r\n\r\n throw new Error(\r\n `[Noxus DI] No binding found for \"${name}\".\\n`\r\n + `Did you forget to declare it in @Injectable({ deps }) or in bootstrapApplication({ singletons })?`,\r\n );\r\n }\r\n\r\n switch (binding.lifetime) {\r\n case 'transient':\r\n return this._instantiate(binding) as T;\r\n\r\n case 'scope': {\r\n if (this.scoped.has(k)) return this.scoped.get(k) as T;\r\n const inst = this._instantiate(binding);\r\n this.scoped.set(k, inst);\r\n return inst as T;\r\n }\r\n\r\n case 'singleton': {\r\n if (this.singletons.has(k)) return this.singletons.get(k) as T;\r\n const inst = this._instantiate(binding);\r\n this.singletons.set(k, inst);\r\n if (binding.instance === undefined) {\r\n (binding as IBinding<unknown>).instance = inst as unknown;\r\n }\r\n return inst as T;\r\n }\r\n }\r\n }\r\n\r\n // -------------------------------------------------------------------------\r\n\r\n private _resolveForwardRef<T>(ref: ForwardReference<T>): T {\r\n let resolved: T | undefined;\r\n return new Proxy({} as object, {\r\n get: (_obj, prop, receiver) => {\r\n resolved ??= this.resolve(ref.forwardRefFn()) as T;\r\n const value = Reflect.get(resolved as object, prop, receiver);\r\n return typeof value === 'function' ? (value as Function).bind(resolved) : value;\r\n },\r\n set: (_obj, prop, value, receiver) => {\r\n resolved ??= this.resolve(ref.forwardRefFn()) as T;\r\n return Reflect.set(resolved as object, prop, value, receiver);\r\n },\r\n getPrototypeOf: () => {\r\n resolved ??= this.resolve(ref.forwardRefFn()) as T;\r\n return Object.getPrototypeOf(resolved);\r\n },\r\n }) as T;\r\n }\r\n\r\n private _instantiate<T>(binding: IBinding<T>): T {\r\n const resolvedDeps = binding.deps.map((dep) => this.resolve(dep));\r\n return new binding.implementation(...resolvedDeps) as T;\r\n }\r\n}\r\n\r\n/**\r\n * The global root injector. All singletons live here.\r\n */\r\nexport const RootInjector = new AppInjector('root');\r\n\r\n/**\r\n * Resets the root injector to a clean state.\r\n * **Intended for testing only** — clears all bindings, singletons, and scoped instances\r\n * so that each test can start from a fresh DI container without restarting the process.\r\n */\r\nexport function resetRootInjector(): void {\r\n RootInjector.bindings.clear();\r\n RootInjector.singletons.clear();\r\n RootInjector.scoped.clear();\r\n // Lazy import to avoid circular dependency (InjectorExplorer → app-injector → InjectorExplorer)\r\n const { InjectorExplorer } = require('./injector-explorer') as typeof import('./injector-explorer');\r\n InjectorExplorer.reset();\r\n}\r\n\r\n/**\r\n * Convenience function: resolve a token from the root injector.\r\n */\r\nexport function inject<T>(t: TokenKey<T> | ForwardReference<T>): T {\r\n return RootInjector.resolve(t);\r\n}\r\n","/**\r\n * @copyright 2025 NoxFly\r\n * @license MIT\r\n * @author NoxFly\r\n */\r\n\r\n\r\nimport { AtomicHttpMethod, HttpMethod } from '../decorators/method.decorator';\r\nimport { AppInjector, RootInjector } from '../DI/app-injector';\r\n\r\n/**\r\n * The Request class represents an HTTP request in the Noxus framework.\r\n * It encapsulates the request data, including the event, ID, method, path, and body.\r\n * It also provides a context for dependency injection through the AppInjector.\r\n */\r\nexport class Request {\r\n public readonly context: AppInjector = RootInjector.createScope();\r\n\r\n public readonly params: Record<string, string> = {};\r\n public readonly query: Record<string, string>;\r\n\r\n constructor(\r\n public readonly event: Electron.MessageEvent,\r\n public readonly senderId: number,\r\n public readonly id: string,\r\n public readonly method: HttpMethod,\r\n public readonly path: string,\r\n public readonly body: unknown,\r\n query?: Record<string, string>,\r\n ) {\r\n this.path = path.replace(/^\\/|\\/$/g, '');\r\n this.query = query ?? {};\r\n }\r\n}\r\n\r\n/**\r\n * The IRequest interface defines the structure of a request object.\r\n * It includes properties for the sender ID, request ID, path, method, and an optional body.\r\n * This interface is used to standardize the request data across the application.\r\n */\r\nexport interface IRequest<TBody = unknown> {\r\n senderId: number;\r\n requestId: string;\r\n path: string;\r\n method: HttpMethod;\r\n body?: TBody;\r\n query?: Record<string, string>;\r\n}\r\n\r\nexport interface IBatchRequestItem<TBody = unknown> {\r\n requestId?: string;\r\n path: string;\r\n method: AtomicHttpMethod;\r\n body?: TBody;\r\n query?: Record<string, string>;\r\n}\r\n\r\nexport interface IBatchRequestPayload {\r\n requests: IBatchRequestItem[];\r\n}\r\n\r\n/**\r\n * Creates a Request object from the IPC event data.\r\n * This function extracts the necessary information from the IPC event and constructs a Request instance.\r\n */\r\nexport interface IResponse<TBody = unknown> {\r\n requestId: string;\r\n status: number;\r\n body?: TBody;\r\n error?: string;\r\n stack?: string;\r\n}\r\n\r\nexport interface IBatchResponsePayload {\r\n responses: IResponse[];\r\n}\r\n\r\nexport const RENDERER_EVENT_TYPE = 'noxus:event';\r\n\r\nexport interface IRendererEventMessage<TPayload = unknown> {\r\n type: typeof RENDERER_EVENT_TYPE;\r\n event: string;\r\n payload?: TPayload;\r\n}\r\n\r\nexport function createRendererEventMessage<TPayload = unknown>(event: string, payload?: TPayload): IRendererEventMessage<TPayload> {\r\n return {\r\n type: RENDERER_EVENT_TYPE,\r\n event,\r\n payload,\r\n };\r\n}\r\n\r\nexport function isRendererEventMessage(value: unknown): value is IRendererEventMessage {\r\n if(value === null || typeof value !== 'object') {\r\n return false;\r\n }\r\n\r\n const possibleMessage = value as Partial<IRendererEventMessage>;\r\n\r\n return possibleMessage.type === RENDERER_EVENT_TYPE && typeof possibleMessage.event === 'string';\r\n}\r\n","/**\r\n * @copyright 2025 NoxFly\r\n * @license MIT\r\n * @author NoxFly\r\n */\r\n\r\n/**\r\n * Lightweight event registry to help renderer processes subscribe to\r\n * push messages sent by the main process through Noxus.\r\n */\r\nimport { IRendererEventMessage, isRendererEventMessage } from './request';\r\n\r\nexport type RendererEventHandler<TPayload = unknown> = (payload: TPayload) => void;\r\n\r\nexport interface RendererEventSubscription {\r\n unsubscribe(): void;\r\n}\r\n\r\nexport class RendererEventRegistry {\r\n private readonly listeners = new Map<string, Set<RendererEventHandler>>();\r\n\r\n /**\r\n *\r\n */\r\n public subscribe<TPayload>(eventName: string, handler: RendererEventHandler<TPayload>): RendererEventSubscription {\r\n const normalizedEventName = eventName.trim();\r\n\r\n if(normalizedEventName.length === 0) {\r\n throw new Error('Renderer event name must be a non-empty string.');\r\n }\r\n\r\n const handlers = this.listeners.get(normalizedEventName) ?? new Set<RendererEventHandler>();\r\n\r\n handlers.add(handler as RendererEventHandler);\r\n this.listeners.set(normalizedEventName, handlers);\r\n\r\n return {\r\n unsubscribe: () => this.unsubscribe(normalizedEventName, handler as RendererEventHandler),\r\n };\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public unsubscribe<TPayload>(eventName: string, handler: RendererEventHandler<TPayload>): void {\r\n const handlers = this.listeners.get(eventName);\r\n\r\n if(!handlers) {\r\n return;\r\n }\r\n\r\n handlers.delete(handler as RendererEventHandler);\r\n\r\n if(handlers.size === 0) {\r\n this.listeners.delete(eventName);\r\n }\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public clear(eventName?: string): void {\r\n if(eventName) {\r\n this.listeners.delete(eventName);\r\n return;\r\n }\r\n\r\n this.listeners.clear();\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public dispatch<TPayload>(message: IRendererEventMessage<TPayload>): void {\r\n const handlers = this.listeners.get(message.event);\r\n\r\n if(!handlers || handlers.size === 0) {\r\n return;\r\n }\r\n\r\n handlers.forEach((handler) => {\r\n try {\r\n handler(message.payload as TPayload);\r\n }\r\n catch(error) {\r\n console.error(`[Noxus] Renderer event handler for \"${message.event}\" threw an error.`, error);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public tryDispatchFromMessageEvent(event: MessageEvent): boolean {\r\n if(!isRendererEventMessage(event.data)) {\r\n return false;\r\n }\r\n\r\n this.dispatch(event.data);\r\n return true;\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public hasHandlers(eventName: string): boolean {\r\n const handlers = this.listeners.get(eventName);\r\n return !!handlers && handlers.size > 0;\r\n }\r\n}\r\n","/**\r\n * @copyright 2025 NoxFly\r\n * @license MIT\r\n * @author NoxFly\r\n */\r\n\r\nimport { IBatchRequestItem, IBatchResponsePayload, IRequest, IResponse } from './request';\r\nimport { RendererEventRegistry } from './renderer-events';\r\n\r\nexport interface IPortRequester {\r\n requestPort(): void;\r\n}\r\n\r\nexport interface RendererClientOptions {\r\n bridge?: IPortRequester | null;\r\n bridgeName?: string | string[];\r\n initMessageType?: string;\r\n windowRef?: Window;\r\n generateRequestId?: () => string;\r\n /**\r\n * Timeout in milliseconds for IPC requests.\r\n * If the main process does not respond within this duration,\r\n * the request Promise is rejected and the pending entry cleaned up.\r\n * Defaults to 10 000 ms. Set to 0 to disable.\r\n */\r\n requestTimeout?: number;\r\n /** @default true */\r\n enableLogging?: boolean;\r\n}\r\n\r\ninterface PendingRequest<T = unknown> {\r\n resolve: (value: T) => void;\r\n reject: (reason: IResponse<T>) => void;\r\n request: IRequest;\r\n submittedAt: number;\r\n timer?: ReturnType<typeof setTimeout>;\r\n}\r\n\r\nconst DEFAULT_INIT_EVENT = 'init-port';\r\nconst DEFAULT_BRIDGE_NAMES = ['noxus', 'ipcRenderer'];\r\n\r\nfunction defaultRequestId(): string {\r\n if(typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\r\n return crypto.randomUUID();\r\n }\r\n\r\n return `${Date.now().toString(16)}-${Math.floor(Math.random() * 1e8).toString(16)}`;\r\n}\r\n\r\nfunction normalizeBridgeNames(preferred?: string | string[]): string[] {\r\n const names: string[] = [];\r\n\r\n const add = (name: string | undefined): void => {\r\n if(!name)\r\n return;\r\n\r\n if(!names.includes(name)) {\r\n names.push(name);\r\n }\r\n };\r\n\r\n if(Array.isArray(preferred)) {\r\n for(const name of preferred) {\r\n add(name);\r\n }\r\n }\r\n else {\r\n add(preferred);\r\n }\r\n\r\n for(const fallback of DEFAULT_BRIDGE_NAMES) {\r\n add(fallback);\r\n }\r\n\r\n return names;\r\n}\r\n\r\nfunction resolveBridgeFromWindow(windowRef: Window, preferred?: string | string[]): IPortRequester | null {\r\n const names = normalizeBridgeNames(preferred);\r\n const globalRef = windowRef as unknown as Record<string, unknown> | null | undefined;\r\n\r\n if(!globalRef) {\r\n return null;\r\n }\r\n\r\n for(const name of names) {\r\n const candidate = globalRef[name];\r\n\r\n if(candidate && typeof (candidate as IPortRequester).requestPort === 'function') {\r\n return candidate as IPortRequester;\r\n }\r\n }\r\n\r\n return null;\r\n}\r\n\r\nexport class NoxRendererClient {\r\n public readonly events = new RendererEventRegistry();\r\n\r\n protected readonly pendingRequests = new Map<string, PendingRequest>();\r\n\r\n protected requestPort: MessagePort | undefined;\r\n protected socketPort: MessagePort | undefined;\r\n protected senderId: number | undefined;\r\n\r\n private readonly bridge: IPortRequester | null;\r\n private readonly initMessageType: string;\r\n private readonly windowRef: Window;\r\n private readonly generateRequestId: () => string;\r\n private readonly requestTimeout: number;\r\n\r\n private isReady = false;\r\n private setupPromise: Promise<void> | undefined;\r\n private setupResolve: (() => void) | undefined;\r\n private setupReject: ((reason: Error) => void) | undefined;\r\n\r\n private enableLogging: boolean;\r\n\r\n constructor(options: RendererClientOptions = {}) {\r\n this.windowRef = options.windowRef ?? window;\r\n const resolvedBridge = options.bridge ?? resolveBridgeFromWindow(this.windowRef, options.bridgeName);\r\n this.bridge = resolvedBridge ?? null;\r\n this.initMessageType = options.initMessageType ?? DEFAULT_INIT_EVENT;\r\n this.generateRequestId = options.generateRequestId ?? defaultRequestId;\r\n this.requestTimeout = options.requestTimeout ?? 10_000;\r\n this.enableLogging = options.enableLogging ?? true;\r\n }\r\n\r\n public async setup(): Promise<void> {\r\n if(this.isReady) {\r\n return Promise.resolve();\r\n }\r\n\r\n if(this.setupPromise) {\r\n return this.setupPromise;\r\n }\r\n\r\n if(!this.bridge || typeof this.bridge.requestPort !== 'function') {\r\n throw new Error('[Noxus] Renderer bridge is missing requestPort().');\r\n }\r\n\r\n this.setupPromise = new Promise<void>((resolve, reject) => {\r\n this.setupResolve = resolve;\r\n this.setupReject = reject;\r\n });\r\n\r\n this.windowRef.addEventListener('message', this.onWindowMessage);\r\n this.bridge.requestPort();\r\n\r\n return this.setupPromise;\r\n }\r\n\r\n public dispose(): void {\r\n this.windowRef.removeEventListener('message', this.onWindowMessage);\r\n\r\n this.requestPort?.close();\r\n this.socketPort?.close();\r\n\r\n this.requestPort = undefined;\r\n this.socketPort = undefined;\r\n this.senderId = undefined;\r\n this.isReady = false;\r\n\r\n for(const pending of this.pendingRequests.values()) {\r\n if(pending.timer !== undefined) {\r\n clearTimeout(pending.timer);\r\n }\r\n }\r\n\r\n this.pendingRequests.clear();\r\n }\r\n\r\n public async request<TResponse, TBody = unknown>(request: Omit<IRequest<TBody>, 'requestId' | 'senderId'>): Promise<TResponse> {\r\n const senderId = this.senderId;\r\n const requestId = this.generateRequestId();\r\n\r\n if(senderId === undefined) {\r\n return Promise.reject(this.createErrorResponse(requestId, 'MessagePort is not available'));\r\n }\r\n\r\n const readinessError = this.validateReady(requestId);\r\n\r\n if(readinessError) {\r\n return Promise.reject(readinessError as IResponse<TResponse>);\r\n }\r\n\r\n const message: IRequest<TBody> = {\r\n requestId,\r\n senderId,\r\n ...request,\r\n };\r\n\r\n return new Promise<TResponse>((resolve, reject) => {\r\n const pending: PendingRequest<TResponse> = {\r\n resolve,\r\n reject: (response: IResponse<TResponse>) => reject(response),\r\n request: message,\r\n submittedAt: Date.now(),\r\n };\r\n\r\n if(this.requestTimeout > 0) {\r\n pending.timer = setTimeout(() => {\r\n this.pendingRequests.delete(message.requestId);\r\n reject(this.createErrorResponse<TResponse>(message.requestId, `Request timed out after ${this.requestTimeout}ms`) as IResponse<TResponse>);\r\n }, this.requestTimeout);\r\n }\r\n\r\n this.pendingRequests.set(message.requestId, pending as PendingRequest);\r\n\r\n this.requestPort!.postMessage(message);\r\n });\r\n }\r\n\r\n public async batch(requests: Omit<IBatchRequestItem<unknown>, 'requestId'>[]): Promise<IBatchResponsePayload> {\r\n return this.request<IBatchResponsePayload>({\r\n method: 'BATCH',\r\n path: '',\r\n body: {\r\n requests,\r\n },\r\n });\r\n }\r\n\r\n public getSenderId(): number | undefined {\r\n return this.senderId;\r\n }\r\n\r\n private readonly onWindowMessage = (event: MessageEvent): void => {\r\n if(event.data?.type !== this.initMessageType) {\r\n return;\r\n }\r\n\r\n if(!Array.isArray(event.ports) || event.ports.length < 2) {\r\n const error = new Error('[Noxus] Renderer expected two MessagePorts (request + socket).');\r\n\r\n console.error(error);\r\n this.setupReject?.(error);\r\n this.resetSetupState();\r\n return;\r\n }\r\n\r\n this.windowRef.removeEventListener('message', this.onWindowMessage);\r\n\r\n this.requestPort = event.ports[0];\r\n this.socketPort = event.ports[1];\r\n this.senderId = event.data.senderId;\r\n\r\n if(this.requestPort === undefined || this.socketPort === undefined) {\r\n const error = new Error('[Noxus] Renderer failed to receive valid MessagePorts.');\r\n console.error(error);\r\n this.setupReject?.(error);\r\n this.resetSetupState();\r\n return;\r\n }\r\n\r\n this.attachRequestPort(this.requestPort);\r\n this.attachSocketPort(this.socketPort);\r\n\r\n this.isReady = true;\r\n this.setupResolve?.();\r\n this.resetSetupState(true);\r\n };\r\n\r\n private readonly onSocketMessage = (event: MessageEvent): void => {\r\n if(this.events.tryDispatchFromMessageEvent(event)) {\r\n return;\r\n }\r\n\r\n console.warn('[Noxus] Received a socket message that is not a renderer event payload.', event.data);\r\n };\r\n\r\n private readonly onRequestMessage = (event: MessageEvent): void => {\r\n if(this.events.tryDispatchFromMessageEvent(event)) {\r\n return;\r\n }\r\n\r\n const response: IResponse = event.data;\r\n\r\n if(!response || typeof response.requestId !== 'string') {\r\n console.error('[Noxus] Renderer received an invalid response payload.', response);\r\n return;\r\n }\r\n\r\n const pending = this.pendingRequests.get(response.requestId);\r\n\r\n if(!pending) {\r\n console.error(`[Noxus] No pending handler found for request ${response.requestId}.`);\r\n return;\r\n }\r\n\r\n if(pending.timer !== undefined) {\r\n clearTimeout(pending.timer);\r\n }\r\n\r\n this.pendingRequests.delete(response.requestId);\r\n\r\n this.onRequestCompleted(pending, response);\r\n\r\n if(response.status >= 400) {\r\n pending.reject(response as IResponse<any>);\r\n return;\r\n }\r\n\r\n pending.resolve(response.body as unknown);\r\n };\r\n\r\n protected onRequestCompleted(pending: PendingRequest, response: IResponse): void {\r\n if(!this.enableLogging) {\r\n return;\r\n }\r\n\r\n if(typeof console.groupCollapsed === 'function') {\r\n console.groupCollapsed(`${response.status} ${pending.request.method} /${pending.request.path}`);\r\n }\r\n\r\n if(response.error) {\r\n console.error('error message:', response.error);\r\n }\r\n\r\n if(response.body !== undefined) {\r\n console.info('response:', response.body);\r\n }\r\n\r\n console.info('request:', pending.request);\r\n console.info(`Request duration: ${Date.now() - pending.submittedAt} ms`);\r\n\r\n if(typeof console.groupCollapsed === 'function') {\r\n console.groupEnd();\r\n }\r\n }\r\n\r\n private attachRequestPort(port: MessagePort): void {\r\n port.onmessage = this.onRequestMessage;\r\n port.start();\r\n }\r\n\r\n private attachSocketPort(port: MessagePort): void {\r\n port.onmessage = this.onSocketMessage;\r\n port.start();\r\n }\r\n\r\n private validateReady(requestId: string): IResponse | undefined {\r\n if(!this.isElectronEnvironment()) {\r\n return this.createErrorResponse(requestId, 'Not running in Electron environment');\r\n }\r\n\r\n if(!this.requestPort) {\r\n return this.createErrorResponse(requestId, 'MessagePort is not available');\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n private createErrorResponse<T>(requestId: string, message: string): IResponse<T> {\r\n return {\r\n status: 500,\r\n requestId,\r\n error: message,\r\n };\r\n }\r\n\r\n private resetSetupState(success = false): void {\r\n if(!success) {\r\n this.setupPromise = undefined;\r\n }\r\n\r\n this.setupResolve = undefined;\r\n this.setupReject = undefined;\r\n }\r\n\r\n public isElectronEnvironment(): boolean {\r\n return typeof window !== 'undefined' && /Electron/.test(window.navigator.userAgent);\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;;AAAA,IAmBa;AAnBb;AAAA;AAAA;AAmBO,IAAM,oBAAN,MAAM,kBAA0B;AAAA,MACnC,YAA4B,cAA+B;AAA/B;AAAA,MAAgC;AAAA,IAChE;AAFuC;AAAhC,IAAM,mBAAN;AAAA;AAAA;;;ACnBP,IAsBa;AAtBb;AAAA;AAAA;AAsBO,IAAM,SAAN,MAAM,OAAS;AAAA,MAGlB,YACoB,QAClB;AADkB;AAEhB,aAAK,cAAc,OAAO,WAAW,WA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Ac;AAAA,EACvB;AAAA,EAEO,wBAAiC;AACpC,WAAO,OAAO,WAAW,eAAe,WAAW,KAAK,OAAO,UAAU,SAAS;AAAA,EACtF;AACJ;AArR+B;AAAxB,IAAM,oBAAN;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noxfly/noxus",
|
|
3
|
-
"version": "3.0.0-dev.
|
|
3
|
+
"version": "3.0.0-dev.5",
|
|
4
|
+
"author": "NoxFly",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"description": "Lightweight HTTP-like IPC framework for Electron with standalone controllers, explicit DI, and lazy route loading. No reflect-metadata required.",
|
|
7
|
+
"homepage": "https://github.com/NoxFly/noxus",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/NoxFly/noxus.git"
|
|
11
|
+
},
|
|
12
|
+
"files": ["dist"],
|
|
4
13
|
"main": "dist/main.js",
|
|
5
14
|
"module": "dist/main.mjs",
|
|
6
15
|
"types": "dist/main.d.ts",
|
|
@@ -64,14 +73,6 @@
|
|
|
64
73
|
"standalone",
|
|
65
74
|
"lazy-loading"
|
|
66
75
|
],
|
|
67
|
-
"author": "NoxFly",
|
|
68
|
-
"license": "MIT",
|
|
69
|
-
"description": "Lightweight HTTP-like IPC framework for Electron with standalone controllers, explicit DI, and lazy route loading. No reflect-metadata required.",
|
|
70
|
-
"homepage": "https://github.com/NoxFly/noxus",
|
|
71
|
-
"repository": {
|
|
72
|
-
"type": "git",
|
|
73
|
-
"url": "git+https://github.com/NoxFly/noxus.git"
|
|
74
|
-
},
|
|
75
76
|
"engines": {
|
|
76
77
|
"node": ">= 20"
|
|
77
78
|
},
|
package/.editorconfig
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# Editor configuration, see https://editorconfig.org
|
|
2
|
-
root = true
|
|
3
|
-
|
|
4
|
-
[*]
|
|
5
|
-
charset = utf-8
|
|
6
|
-
indent_style = space
|
|
7
|
-
indent_size = 4
|
|
8
|
-
insert_final_newline = true
|
|
9
|
-
trim_trailing_whitespace = true
|
|
10
|
-
|
|
11
|
-
[*.ts]
|
|
12
|
-
quote_type = single
|
|
13
|
-
|
|
14
|
-
[*.md]
|
|
15
|
-
max_line_length = off
|
|
16
|
-
trim_trailing_whitespace = false
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# Copilot Instructions
|
|
2
|
-
## Core Architecture
|
|
3
|
-
- bootstrapApplication in [src/bootstrap.ts](src/bootstrap.ts) waits for Electron app readiness, resolves NoxApp via DI, and returns a configured instance.
|
|
4
|
-
- [src/app.ts](src/app.ts) wires ipcMain events, spawns paired request/socket MessageChannels per renderer, and delegates handling to Router and NoxSocket.
|
|
5
|
-
- Package exports are split between renderer and main targets in [package.json](package.json); import Electron main APIs from @noxfly/noxus/main and renderer helpers from @noxfly/noxus or @noxfly/noxus/renderer.
|
|
6
|
-
- Dependency injection centers on RootInjector in [src/DI/app-injector.ts](src/DI/app-injector.ts); @Injectable triggers auto-registration through [src/DI/injector-explorer.ts](src/DI/injector-explorer.ts) and supports singleton, scope, and transient lifetimes.
|
|
7
|
-
- Modules decorated via [src/decorators/module.decorator.ts](src/decorators/module.decorator.ts) compose providers, controllers, and nested modules; bootstrapApplication rejects roots lacking Module metadata.
|
|
8
|
-
## Request Lifecycle
|
|
9
|
-
- Request objects from [src/request.ts](src/request.ts) wrap Electron MessageEvents and spawn per-request DI scopes on Request.context.
|
|
10
|
-
- Router in [src/router.ts](src/router.ts) indexes routes in a radix tree, merges controller-level and method-level decorators, and enforces root middlewares, route middlewares, then guards before invoking controller actions.
|
|
11
|
-
- ResponseException subclasses in [src/exceptions.ts](src/exceptions.ts) propagate status codes; throwing one short-circuits the pipeline so Router returns a structured error payload.
|
|
12
|
-
- Batch requests use HTTP method BATCH and normalization logic in Router.handleBatch; payloads must satisfy IBatchRequestPayload to fan out atomic subrequests.
|
|
13
|
-
## Communication Channels
|
|
14
|
-
- ipcMain listens for gimme-my-port and posts two transferable ports back to the renderer: index 0 carries request/response traffic, index 1 is reserved for socket-style push messages.
|
|
15
|
-
- NoxSocket in [src/socket.ts](src/socket.ts) maps sender IDs to {request, socket} channels and emits renderer events exclusively through channels.socket.port1.
|
|
16
|
-
- Renderer helpers in [src/renderer-events.ts](src/renderer-events.ts) expose RendererEventRegistry.tryDispatchFromMessageEvent to route push events; the preload script must start both ports and hand the second to this registry.
|
|
17
|
-
- Renderer-facing bootstrap lives in [src/renderer-client.ts](src/renderer-client.ts); NoxRendererClient requests ports, wires request/socket handlers, tracks pending promises, and surfaces RendererEventRegistry for push consumption.
|
|
18
|
-
- Preload scripts should call exposeNoxusBridge from [src/preload-bridge.ts](src/preload-bridge.ts) to publish window.noxus.requestPort; the helper sends 'gimme-my-port' and forwards both transferable ports with the configured init message.
|
|
19
|
-
- When adjusting preload or renderer glue, ensure window.postMessage('init-port', ...) forwards both ports so the socket channel stays alive alongside the request channel.
|
|
20
|
-
## Decorator Conventions
|
|
21
|
-
- Controller paths omit leading/trailing slashes; method decorators (Get, Post, etc.) auto-trim segments via [src/decorators/method.decorator.ts](src/decorators/method.decorator.ts).
|
|
22
|
-
- Guards registered through Authorize in [src/decorators/guards.decorator.ts](src/decorators/guards.decorator.ts) aggregate at controller and action scope; they must resolve truthy or Router throws UnauthorizedException.
|
|
23
|
-
- Injectable lifetimes default to scope; use singleton for app-wide utilities (window managers, sockets) and transient for short-lived resources.
|
|
24
|
-
## Logging and Utilities
|
|
25
|
-
- Logger in [src/utils/logger.ts](src/utils/logger.ts) standardizes color-coded log, warn, error, and comment output; use it when extending framework behavior.
|
|
26
|
-
- Path resolution relies on RadixTree from [src/utils/radix-tree.ts](src/utils/radix-tree.ts); normalize controller and route paths to avoid duplicate slashes.
|
|
27
|
-
- Request.params are filled by Router.extractParams; controllers read route params directly from Request without decorator helpers yet.
|
|
28
|
-
## Build and Tooling
|
|
29
|
-
- Run npm run build to invoke tsup with dual ESM/CJS outputs configured in [tsup.config.ts](tsup.config.ts); the postbuild script at [scripts/postbuild.js](scripts/postbuild.js) deduplicates license banners.
|
|
30
|
-
- Node 20 or newer is required; reflect-metadata is a peer dependency so host apps must install and import it before using decorators.
|
|
31
|
-
- Source uses baseUrl ./ with tsc-alias, so prefer absolute imports like src/module/file when editing framework code to match existing style.
|
|
32
|
-
- Dist artifacts live under dist/ and are published outputs; regenerate them via the build script rather than editing directly.
|
package/.vscode/settings.json
DELETED
package/eslint.config.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
const eslint = require("@eslint/js");
|
|
3
|
-
const tseslint = require("typescript-eslint");
|
|
4
|
-
const stylistic = require("@stylistic/eslint-plugin");
|
|
5
|
-
|
|
6
|
-
module.exports = tseslint.config(
|
|
7
|
-
{
|
|
8
|
-
files: ["src/**/*.ts"],
|
|
9
|
-
extends: [
|
|
10
|
-
eslint.configs.recommended,
|
|
11
|
-
...tseslint.configs.recommended,
|
|
12
|
-
...tseslint.configs.stylistic,
|
|
13
|
-
],
|
|
14
|
-
languageOptions: {
|
|
15
|
-
parserOptions: {
|
|
16
|
-
ecmaVersion: 2020,
|
|
17
|
-
sourceType: "module",
|
|
18
|
-
project: ["./tsconfig.json"],
|
|
19
|
-
tsconfigRootDir: __dirname,
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
plugins: {
|
|
23
|
-
"@stylistic": stylistic,
|
|
24
|
-
},
|
|
25
|
-
rules: {
|
|
26
|
-
"@typescript-eslint/no-empty-object-type": "off",
|
|
27
|
-
|
|
28
|
-
"@typescript-eslint/no-require-imports": "off",
|
|
29
|
-
|
|
30
|
-
"@typescript-eslint/explicit-member-accessibility": [
|
|
31
|
-
"error",
|
|
32
|
-
{
|
|
33
|
-
"overrides": {
|
|
34
|
-
"constructors": "no-public",
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
],
|
|
38
|
-
"@typescript-eslint/explicit-function-return-type": [
|
|
39
|
-
"error",
|
|
40
|
-
{
|
|
41
|
-
"allowExpressions": true,
|
|
42
|
-
"allowHigherOrderFunctions": true,
|
|
43
|
-
"allowIIFEs": true,
|
|
44
|
-
}
|
|
45
|
-
],
|
|
46
|
-
"@typescript-eslint/consistent-type-definitions": "off",
|
|
47
|
-
"@typescript-eslint/no-explicit-any": "off",
|
|
48
|
-
"@typescript-eslint/no-inferrable-types": "off",
|
|
49
|
-
"@typescript-eslint/no-empty-function": "off",
|
|
50
|
-
"@typescript-eslint/no-unused-vars": "off",
|
|
51
|
-
"@typescript-eslint/no-namespace": "off",
|
|
52
|
-
"@typescript-eslint/no-unsafe-function-type": "off",
|
|
53
|
-
"@typescript-eslint/prefer-readonly": "warn",
|
|
54
|
-
|
|
55
|
-
"@stylistic/object-curly-spacing": ["warn", "always"],
|
|
56
|
-
"@stylistic/no-whitespace-before-property": "error",
|
|
57
|
-
"@stylistic/space-before-blocks": ["warn", "always"],
|
|
58
|
-
"@stylistic/comma-spacing": [
|
|
59
|
-
"warn",
|
|
60
|
-
{
|
|
61
|
-
"before": false,
|
|
62
|
-
"after": true
|
|
63
|
-
}
|
|
64
|
-
],
|
|
65
|
-
"@stylistic/block-spacing": ["warn", "always"],
|
|
66
|
-
"@stylistic/brace-style": [
|
|
67
|
-
"error",
|
|
68
|
-
"stroustrup",
|
|
69
|
-
{
|
|
70
|
-
"allowSingleLine": true
|
|
71
|
-
}
|
|
72
|
-
],
|
|
73
|
-
"@stylistic/function-call-spacing": ["error", "never"],
|
|
74
|
-
"@stylistic/arrow-spacing": "error",
|
|
75
|
-
"@stylistic/computed-property-spacing": "warn",
|
|
76
|
-
"@stylistic/generator-star-spacing": "error",
|
|
77
|
-
"@stylistic/indent": ["error", 4, { "SwitchCase": 1 }],
|
|
78
|
-
"@stylistic/semi": [2, "always"],
|
|
79
|
-
"@stylistic/no-extra-semi": "warn",
|
|
80
|
-
"@stylistic/semi-spacing": "warn",
|
|
81
|
-
"@stylistic/quotes": "off",
|
|
82
|
-
"@stylistic/keyword-spacing": [
|
|
83
|
-
"warn",
|
|
84
|
-
{
|
|
85
|
-
"overrides": {
|
|
86
|
-
"if": { "after": false },
|
|
87
|
-
"for": { "after": false },
|
|
88
|
-
"catch": { "after": false },
|
|
89
|
-
"while": { "after": false },
|
|
90
|
-
"as": { "after": false },
|
|
91
|
-
"switch": { "after": false }
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
],
|
|
95
|
-
|
|
96
|
-
"eqeqeq": "error",
|
|
97
|
-
"no-duplicate-imports": "error",
|
|
98
|
-
"no-empty": "off",
|
|
99
|
-
"no-empty-function": "off",
|
|
100
|
-
"no-extra-boolean-cast": "off",
|
|
101
|
-
"no-inner-declarations": "off",
|
|
102
|
-
"no-unsafe-finally": "off",
|
|
103
|
-
"no-unsafe-optional-chaining": "error",
|
|
104
|
-
"no-unused-vars": "off",
|
|
105
|
-
"no-var": "error",
|
|
106
|
-
"no-useless-catch": "off",
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
);
|
package/scripts/postbuild.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
function uniqueDocBlocks(filepath) {
|
|
5
|
-
if(!fs.existsSync(filepath)) {
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const content = fs.readFileSync(filepath, 'utf8');
|
|
10
|
-
|
|
11
|
-
const reg = /\/\*\*[\t ]*\n(?: \*.*\n)*? \* *@copyright.*\n(?: \*.*\n)*? \*\/\n?/gm;
|
|
12
|
-
|
|
13
|
-
let first = true;
|
|
14
|
-
const deduped = content.replace(reg, (match) => {
|
|
15
|
-
if (first) {
|
|
16
|
-
first = false;
|
|
17
|
-
return match; // keep the first
|
|
18
|
-
}
|
|
19
|
-
return ''; // remove others
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
fs.writeFileSync(filepath, deduped);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const distDir = path.join(__dirname, '../dist');
|
|
26
|
-
|
|
27
|
-
for(const filename of fs.readdirSync(distDir)) {
|
|
28
|
-
if(filename.endsWith('.d.ts') || filename.endsWith('.d.mts')) {
|
|
29
|
-
uniqueDocBlocks(path.join(distDir, filename));
|
|
30
|
-
}
|
|
31
|
-
}
|