@noxfly/noxus 3.0.0-dev.1 → 3.0.0-dev.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +121 -8
  2. package/dist/child.d.mts +8 -2
  3. package/dist/child.d.ts +8 -2
  4. package/dist/child.js +405 -862
  5. package/dist/child.js.map +1 -0
  6. package/dist/child.mjs +396 -854
  7. package/dist/child.mjs.map +1 -0
  8. package/dist/main.d.mts +180 -132
  9. package/dist/main.d.ts +180 -132
  10. package/dist/main.js +1087 -926
  11. package/dist/main.js.map +1 -0
  12. package/dist/main.mjs +1038 -877
  13. package/dist/main.mjs.map +1 -0
  14. package/dist/preload.js.map +1 -0
  15. package/dist/preload.mjs.map +1 -0
  16. package/dist/renderer.d.mts +30 -4
  17. package/dist/renderer.d.ts +30 -4
  18. package/dist/renderer.js +191 -128
  19. package/dist/renderer.js.map +1 -0
  20. package/dist/renderer.mjs +180 -116
  21. package/dist/renderer.mjs.map +1 -0
  22. package/package.json +18 -9
  23. package/.editorconfig +0 -16
  24. package/.github/copilot-instructions.md +0 -32
  25. package/.vscode/settings.json +0 -3
  26. package/eslint.config.js +0 -109
  27. package/scripts/postbuild.js +0 -31
  28. package/src/DI/app-injector.ts +0 -151
  29. package/src/DI/injector-explorer.ts +0 -143
  30. package/src/DI/token.ts +0 -53
  31. package/src/decorators/controller.decorator.ts +0 -58
  32. package/src/decorators/guards.decorator.ts +0 -15
  33. package/src/decorators/injectable.decorator.ts +0 -81
  34. package/src/decorators/method.decorator.ts +0 -66
  35. package/src/decorators/middleware.decorator.ts +0 -15
  36. package/src/index.ts +0 -10
  37. package/src/internal/app.ts +0 -217
  38. package/src/internal/bootstrap.ts +0 -108
  39. package/src/internal/exceptions.ts +0 -57
  40. package/src/internal/preload-bridge.ts +0 -75
  41. package/src/internal/renderer-client.ts +0 -338
  42. package/src/internal/renderer-events.ts +0 -110
  43. package/src/internal/request.ts +0 -97
  44. package/src/internal/router.ts +0 -353
  45. package/src/internal/routes.ts +0 -78
  46. package/src/internal/socket.ts +0 -73
  47. package/src/main.ts +0 -26
  48. package/src/non-electron-process.ts +0 -22
  49. package/src/preload.ts +0 -10
  50. package/src/renderer.ts +0 -13
  51. package/src/utils/forward-ref.ts +0 -31
  52. package/src/utils/logger.ts +0 -430
  53. package/src/utils/radix-tree.ts +0 -210
  54. package/src/utils/types.ts +0 -21
  55. package/src/window/window-manager.ts +0 -255
  56. package/tsconfig.json +0 -29
  57. package/tsup.config.ts +0 -50
package/dist/child.mjs CHANGED
@@ -7,6 +7,7 @@ var __defProp = Object.defineProperty;
7
7
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
8
8
  var __getOwnPropNames = Object.getOwnPropertyNames;
9
9
  var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
11
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
11
12
  var __esm = (fn, res) => function __init() {
12
13
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
@@ -24,14 +25,7 @@ var __copyProps = (to, from, except, desc) => {
24
25
  return to;
25
26
  };
26
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
- var __decorateClass = (decorators, target, key, kind) => {
28
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
29
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
30
- if (decorator = decorators[i])
31
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
32
- if (kind && result) __defProp(target, key, result);
33
- return result;
34
- };
28
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
35
29
 
36
30
  // src/utils/forward-ref.ts
37
31
  function forwardRef(fn) {
@@ -60,6 +54,7 @@ var init_token = __esm({
60
54
  _Token = class _Token {
61
55
  constructor(target) {
62
56
  this.target = target;
57
+ __publicField(this, "description");
63
58
  this.description = typeof target === "string" ? target : target.name;
64
59
  }
65
60
  toString() {
@@ -71,323 +66,6 @@ var init_token = __esm({
71
66
  }
72
67
  });
73
68
 
74
- // src/DI/app-injector.ts
75
- function keyOf(k) {
76
- return k;
77
- }
78
- function inject(t) {
79
- return RootInjector.resolve(t);
80
- }
81
- var _AppInjector, AppInjector, RootInjector;
82
- var init_app_injector = __esm({
83
- "src/DI/app-injector.ts"() {
84
- "use strict";
85
- init_forward_ref();
86
- init_token();
87
- __name(keyOf, "keyOf");
88
- _AppInjector = class _AppInjector {
89
- constructor(name = null) {
90
- this.name = name;
91
- this.bindings = /* @__PURE__ */ new Map();
92
- this.singletons = /* @__PURE__ */ new Map();
93
- this.scoped = /* @__PURE__ */ new Map();
94
- }
95
- /**
96
- * Creates a child scope for per-request lifetime resolution.
97
- */
98
- createScope() {
99
- const scope = new _AppInjector();
100
- scope.bindings = this.bindings;
101
- scope.singletons = this.singletons;
102
- return scope;
103
- }
104
- /**
105
- * Registers a binding explicitly.
106
- */
107
- register(key, implementation, lifetime, deps = []) {
108
- const k = keyOf(key);
109
- if (!this.bindings.has(k)) {
110
- this.bindings.set(k, { lifetime, implementation, deps });
111
- }
112
- }
113
- /**
114
- * Resolves a dependency by token or class reference.
115
- */
116
- resolve(target) {
117
- if (target instanceof ForwardReference) {
118
- return this._resolveForwardRef(target);
119
- }
120
- const k = keyOf(target);
121
- const binding = this.bindings.get(k);
122
- if (!binding) {
123
- const name = target instanceof Token ? target.description : target.name ?? "unknown";
124
- throw new Error(
125
- `[Noxus DI] No binding found for "${name}".
126
- Did you forget to declare it in @Injectable({ deps }) or in bootstrapApplication({ singletons })?`
127
- );
128
- }
129
- switch (binding.lifetime) {
130
- case "transient":
131
- return this._instantiate(binding);
132
- case "scope": {
133
- if (this.scoped.has(k)) return this.scoped.get(k);
134
- const inst = this._instantiate(binding);
135
- this.scoped.set(k, inst);
136
- return inst;
137
- }
138
- case "singleton": {
139
- if (this.singletons.has(k)) return this.singletons.get(k);
140
- const inst = this._instantiate(binding);
141
- this.singletons.set(k, inst);
142
- if (binding.instance === void 0) {
143
- binding.instance = inst;
144
- }
145
- return inst;
146
- }
147
- }
148
- }
149
- // -------------------------------------------------------------------------
150
- _resolveForwardRef(ref) {
151
- return new Proxy({}, {
152
- get: /* @__PURE__ */ __name((_obj, prop, receiver) => {
153
- const realType = ref.forwardRefFn();
154
- const instance = this.resolve(realType);
155
- const value = Reflect.get(instance, prop, receiver);
156
- return typeof value === "function" ? value.bind(instance) : value;
157
- }, "get"),
158
- set: /* @__PURE__ */ __name((_obj, prop, value, receiver) => {
159
- const realType = ref.forwardRefFn();
160
- const instance = this.resolve(realType);
161
- return Reflect.set(instance, prop, value, receiver);
162
- }, "set"),
163
- getPrototypeOf: /* @__PURE__ */ __name(() => {
164
- const realType = ref.forwardRefFn();
165
- return realType.prototype;
166
- }, "getPrototypeOf")
167
- });
168
- }
169
- _instantiate(binding) {
170
- const resolvedDeps = binding.deps.map((dep) => this.resolve(dep));
171
- return new binding.implementation(...resolvedDeps);
172
- }
173
- };
174
- __name(_AppInjector, "AppInjector");
175
- AppInjector = _AppInjector;
176
- RootInjector = new AppInjector("root");
177
- __name(inject, "inject");
178
- }
179
- });
180
-
181
- // src/internal/exceptions.ts
182
- var _ResponseException, ResponseException, _BadRequestException, BadRequestException, _UnauthorizedException, UnauthorizedException, _PaymentRequiredException, PaymentRequiredException, _ForbiddenException, ForbiddenException, _NotFoundException, NotFoundException, _MethodNotAllowedException, MethodNotAllowedException, _NotAcceptableException, NotAcceptableException, _RequestTimeoutException, RequestTimeoutException, _ConflictException, ConflictException, _UpgradeRequiredException, UpgradeRequiredException, _TooManyRequestsException, TooManyRequestsException, _InternalServerException, InternalServerException, _NotImplementedException, NotImplementedException, _BadGatewayException, BadGatewayException, _ServiceUnavailableException, ServiceUnavailableException, _GatewayTimeoutException, GatewayTimeoutException, _HttpVersionNotSupportedException, HttpVersionNotSupportedException, _VariantAlsoNegotiatesException, VariantAlsoNegotiatesException, _InsufficientStorageException, InsufficientStorageException, _LoopDetectedException, LoopDetectedException, _NotExtendedException, NotExtendedException, _NetworkAuthenticationRequiredException, NetworkAuthenticationRequiredException, _NetworkConnectTimeoutException, NetworkConnectTimeoutException;
183
- var init_exceptions = __esm({
184
- "src/internal/exceptions.ts"() {
185
- "use strict";
186
- _ResponseException = class _ResponseException extends Error {
187
- constructor(statusOrMessage, message) {
188
- let statusCode;
189
- if (typeof statusOrMessage === "number") {
190
- statusCode = statusOrMessage;
191
- } else if (typeof statusOrMessage === "string") {
192
- message = statusOrMessage;
193
- }
194
- super(message ?? "");
195
- this.status = 0;
196
- if (statusCode !== void 0) {
197
- this.status = statusCode;
198
- }
199
- this.name = this.constructor.name.replace(/([A-Z])/g, " $1");
200
- }
201
- };
202
- __name(_ResponseException, "ResponseException");
203
- ResponseException = _ResponseException;
204
- _BadRequestException = class _BadRequestException extends ResponseException {
205
- constructor() {
206
- super(...arguments);
207
- this.status = 400;
208
- }
209
- };
210
- __name(_BadRequestException, "BadRequestException");
211
- BadRequestException = _BadRequestException;
212
- _UnauthorizedException = class _UnauthorizedException extends ResponseException {
213
- constructor() {
214
- super(...arguments);
215
- this.status = 401;
216
- }
217
- };
218
- __name(_UnauthorizedException, "UnauthorizedException");
219
- UnauthorizedException = _UnauthorizedException;
220
- _PaymentRequiredException = class _PaymentRequiredException extends ResponseException {
221
- constructor() {
222
- super(...arguments);
223
- this.status = 402;
224
- }
225
- };
226
- __name(_PaymentRequiredException, "PaymentRequiredException");
227
- PaymentRequiredException = _PaymentRequiredException;
228
- _ForbiddenException = class _ForbiddenException extends ResponseException {
229
- constructor() {
230
- super(...arguments);
231
- this.status = 403;
232
- }
233
- };
234
- __name(_ForbiddenException, "ForbiddenException");
235
- ForbiddenException = _ForbiddenException;
236
- _NotFoundException = class _NotFoundException extends ResponseException {
237
- constructor() {
238
- super(...arguments);
239
- this.status = 404;
240
- }
241
- };
242
- __name(_NotFoundException, "NotFoundException");
243
- NotFoundException = _NotFoundException;
244
- _MethodNotAllowedException = class _MethodNotAllowedException extends ResponseException {
245
- constructor() {
246
- super(...arguments);
247
- this.status = 405;
248
- }
249
- };
250
- __name(_MethodNotAllowedException, "MethodNotAllowedException");
251
- MethodNotAllowedException = _MethodNotAllowedException;
252
- _NotAcceptableException = class _NotAcceptableException extends ResponseException {
253
- constructor() {
254
- super(...arguments);
255
- this.status = 406;
256
- }
257
- };
258
- __name(_NotAcceptableException, "NotAcceptableException");
259
- NotAcceptableException = _NotAcceptableException;
260
- _RequestTimeoutException = class _RequestTimeoutException extends ResponseException {
261
- constructor() {
262
- super(...arguments);
263
- this.status = 408;
264
- }
265
- };
266
- __name(_RequestTimeoutException, "RequestTimeoutException");
267
- RequestTimeoutException = _RequestTimeoutException;
268
- _ConflictException = class _ConflictException extends ResponseException {
269
- constructor() {
270
- super(...arguments);
271
- this.status = 409;
272
- }
273
- };
274
- __name(_ConflictException, "ConflictException");
275
- ConflictException = _ConflictException;
276
- _UpgradeRequiredException = class _UpgradeRequiredException extends ResponseException {
277
- constructor() {
278
- super(...arguments);
279
- this.status = 426;
280
- }
281
- };
282
- __name(_UpgradeRequiredException, "UpgradeRequiredException");
283
- UpgradeRequiredException = _UpgradeRequiredException;
284
- _TooManyRequestsException = class _TooManyRequestsException extends ResponseException {
285
- constructor() {
286
- super(...arguments);
287
- this.status = 429;
288
- }
289
- };
290
- __name(_TooManyRequestsException, "TooManyRequestsException");
291
- TooManyRequestsException = _TooManyRequestsException;
292
- _InternalServerException = class _InternalServerException extends ResponseException {
293
- constructor() {
294
- super(...arguments);
295
- this.status = 500;
296
- }
297
- };
298
- __name(_InternalServerException, "InternalServerException");
299
- InternalServerException = _InternalServerException;
300
- _NotImplementedException = class _NotImplementedException extends ResponseException {
301
- constructor() {
302
- super(...arguments);
303
- this.status = 501;
304
- }
305
- };
306
- __name(_NotImplementedException, "NotImplementedException");
307
- NotImplementedException = _NotImplementedException;
308
- _BadGatewayException = class _BadGatewayException extends ResponseException {
309
- constructor() {
310
- super(...arguments);
311
- this.status = 502;
312
- }
313
- };
314
- __name(_BadGatewayException, "BadGatewayException");
315
- BadGatewayException = _BadGatewayException;
316
- _ServiceUnavailableException = class _ServiceUnavailableException extends ResponseException {
317
- constructor() {
318
- super(...arguments);
319
- this.status = 503;
320
- }
321
- };
322
- __name(_ServiceUnavailableException, "ServiceUnavailableException");
323
- ServiceUnavailableException = _ServiceUnavailableException;
324
- _GatewayTimeoutException = class _GatewayTimeoutException extends ResponseException {
325
- constructor() {
326
- super(...arguments);
327
- this.status = 504;
328
- }
329
- };
330
- __name(_GatewayTimeoutException, "GatewayTimeoutException");
331
- GatewayTimeoutException = _GatewayTimeoutException;
332
- _HttpVersionNotSupportedException = class _HttpVersionNotSupportedException extends ResponseException {
333
- constructor() {
334
- super(...arguments);
335
- this.status = 505;
336
- }
337
- };
338
- __name(_HttpVersionNotSupportedException, "HttpVersionNotSupportedException");
339
- HttpVersionNotSupportedException = _HttpVersionNotSupportedException;
340
- _VariantAlsoNegotiatesException = class _VariantAlsoNegotiatesException extends ResponseException {
341
- constructor() {
342
- super(...arguments);
343
- this.status = 506;
344
- }
345
- };
346
- __name(_VariantAlsoNegotiatesException, "VariantAlsoNegotiatesException");
347
- VariantAlsoNegotiatesException = _VariantAlsoNegotiatesException;
348
- _InsufficientStorageException = class _InsufficientStorageException extends ResponseException {
349
- constructor() {
350
- super(...arguments);
351
- this.status = 507;
352
- }
353
- };
354
- __name(_InsufficientStorageException, "InsufficientStorageException");
355
- InsufficientStorageException = _InsufficientStorageException;
356
- _LoopDetectedException = class _LoopDetectedException extends ResponseException {
357
- constructor() {
358
- super(...arguments);
359
- this.status = 508;
360
- }
361
- };
362
- __name(_LoopDetectedException, "LoopDetectedException");
363
- LoopDetectedException = _LoopDetectedException;
364
- _NotExtendedException = class _NotExtendedException extends ResponseException {
365
- constructor() {
366
- super(...arguments);
367
- this.status = 510;
368
- }
369
- };
370
- __name(_NotExtendedException, "NotExtendedException");
371
- NotExtendedException = _NotExtendedException;
372
- _NetworkAuthenticationRequiredException = class _NetworkAuthenticationRequiredException extends ResponseException {
373
- constructor() {
374
- super(...arguments);
375
- this.status = 511;
376
- }
377
- };
378
- __name(_NetworkAuthenticationRequiredException, "NetworkAuthenticationRequiredException");
379
- NetworkAuthenticationRequiredException = _NetworkAuthenticationRequiredException;
380
- _NetworkConnectTimeoutException = class _NetworkConnectTimeoutException extends ResponseException {
381
- constructor() {
382
- super(...arguments);
383
- this.status = 599;
384
- }
385
- };
386
- __name(_NetworkConnectTimeoutException, "NetworkConnectTimeoutException");
387
- NetworkConnectTimeoutException = _NetworkConnectTimeoutException;
388
- }
389
- });
390
-
391
69
  // src/utils/logger.ts
392
70
  import * as fs from "fs";
393
71
  import * as path from "path";
@@ -635,502 +313,11 @@ var init_logger = __esm({
635
313
  }
636
314
  });
637
315
 
638
- // src/decorators/controller.decorator.ts
639
- function getControllerMetadata(target) {
640
- return controllerMetaMap.get(target);
641
- }
642
- var controllerMetaMap;
643
- var init_controller_decorator = __esm({
644
- "src/decorators/controller.decorator.ts"() {
645
- "use strict";
646
- init_injector_explorer();
647
- controllerMetaMap = /* @__PURE__ */ new WeakMap();
648
- __name(getControllerMetadata, "getControllerMetadata");
649
- }
650
- });
651
-
652
- // src/decorators/method.decorator.ts
653
- function isAtomicHttpMethod(m) {
654
- return typeof m === "string" && ATOMIC_METHODS.has(m);
655
- }
656
- function createRouteDecorator(verb) {
657
- return (path2, options = {}) => {
658
- return (target, propertyKey) => {
659
- const ctor = target.constructor;
660
- const existing = routeMetaMap.get(ctor) ?? [];
661
- existing.push({
662
- method: verb,
663
- path: (path2 ?? "").trim().replace(/^\/|\/$/g, ""),
664
- handler: propertyKey,
665
- guards: options.guards ?? [],
666
- middlewares: options.middlewares ?? []
667
- });
668
- routeMetaMap.set(ctor, existing);
669
- };
670
- };
671
- }
672
- function getRouteMetadata(target) {
673
- return routeMetaMap.get(target) ?? [];
674
- }
675
- var ATOMIC_METHODS, routeMetaMap, Get, Post, Put, Patch, Delete;
676
- var init_method_decorator = __esm({
677
- "src/decorators/method.decorator.ts"() {
678
- "use strict";
679
- ATOMIC_METHODS = /* @__PURE__ */ new Set(["GET", "POST", "PUT", "PATCH", "DELETE"]);
680
- __name(isAtomicHttpMethod, "isAtomicHttpMethod");
681
- routeMetaMap = /* @__PURE__ */ new WeakMap();
682
- __name(createRouteDecorator, "createRouteDecorator");
683
- __name(getRouteMetadata, "getRouteMetadata");
684
- Get = createRouteDecorator("GET");
685
- Post = createRouteDecorator("POST");
686
- Put = createRouteDecorator("PUT");
687
- Patch = createRouteDecorator("PATCH");
688
- Delete = createRouteDecorator("DELETE");
689
- }
690
- });
691
-
692
- // src/utils/radix-tree.ts
693
- var _RadixNode, RadixNode, _RadixTree, RadixTree;
694
- var init_radix_tree = __esm({
695
- "src/utils/radix-tree.ts"() {
696
- "use strict";
697
- _RadixNode = class _RadixNode {
698
- /**
699
- * Creates a new RadixNode.
700
- * @param segment - The segment of the path this node represents.
701
- */
702
- constructor(segment) {
703
- this.children = [];
704
- this.segment = segment;
705
- this.isParam = segment.startsWith(":");
706
- if (this.isParam) {
707
- this.paramName = segment.slice(1);
708
- }
709
- }
710
- /**
711
- * Matches a child node against a given segment.
712
- * This method checks if the segment matches any of the children nodes.
713
- * @param segment - The segment to match against the children of this node.
714
- * @returns A child node that matches the segment, or undefined if no match is found.
715
- */
716
- matchChild(segment) {
717
- for (const child of this.children) {
718
- if (child.isParam || segment.startsWith(child.segment))
719
- return child;
720
- }
721
- return void 0;
722
- }
723
- /**
724
- * Finds a child node that matches the segment exactly.
725
- * This method checks if there is a child node that matches the segment exactly.
726
- * @param segment - The segment to find an exact match for among the children of this node.
727
- * @returns A child node that matches the segment exactly, or undefined if no match is found.
728
- */
729
- findExactChild(segment) {
730
- return this.children.find((c) => c.segment === segment);
731
- }
732
- /**
733
- * Adds a child node to this node's children.
734
- * This method adds a new child node to the list of children for this node.
735
- * @param node - The child node to add to this node's children.
736
- */
737
- addChild(node) {
738
- this.children.push(node);
739
- }
740
- };
741
- __name(_RadixNode, "RadixNode");
742
- RadixNode = _RadixNode;
743
- _RadixTree = class _RadixTree {
744
- constructor() {
745
- this.root = new RadixNode("");
746
- }
747
- /**
748
- * Inserts a path and its associated value into the Radix Tree.
749
- * This method normalizes the path and inserts it into the tree, associating it with
750
- * @param path - The path to insert into the tree.
751
- * @param value - The value to associate with the path.
752
- */
753
- insert(path2, value) {
754
- const segments = this.normalize(path2);
755
- this.insertRecursive(this.root, segments, value);
756
- }
757
- /**
758
- * Recursively inserts a path into the Radix Tree.
759
- * This method traverses the tree and inserts the segments of the path, creating new nodes
760
- * @param node - The node to start inserting from.
761
- * @param segments - The segments of the path to insert.
762
- * @param value - The value to associate with the path.
763
- */
764
- insertRecursive(node, segments, value) {
765
- if (segments.length === 0) {
766
- node.value = value;
767
- return;
768
- }
769
- const segment = segments[0] ?? "";
770
- let child = node.children.find(
771
- (c) => c.isParam === segment.startsWith(":") && (c.isParam || c.segment === segment)
772
- );
773
- if (!child) {
774
- child = new RadixNode(segment);
775
- node.addChild(child);
776
- }
777
- this.insertRecursive(child, segments.slice(1), value);
778
- }
779
- /**
780
- * Searches for a path in the Radix Tree.
781
- * This method normalizes the path and searches for it in the tree, returning the node
782
- * @param path - The path to search for in the Radix Tree.
783
- * @returns An ISearchResult containing the node and parameters if a match is found, otherwise undefined.
784
- */
785
- search(path2) {
786
- const segments = this.normalize(path2);
787
- return this.searchRecursive(this.root, segments, {});
788
- }
789
- /**
790
- * Recursively searches for a path in the Radix Tree.
791
- * This method traverses the tree and searches for the segments of the path, collecting parameters
792
- * @param node - The node to start searching from.
793
- * @param segments - The segments of the path to search for.
794
- * @param params - The parameters collected during the search.
795
- * @returns An ISearchResult containing the node and parameters if a match is found, otherwise undefined.
796
- */
797
- searchRecursive(node, segments, params) {
798
- if (segments.length === 0) {
799
- if (node.value !== void 0) {
800
- return {
801
- node,
802
- params
803
- };
804
- }
805
- return void 0;
806
- }
807
- const [segment, ...rest] = segments;
808
- for (const child of node.children) {
809
- if (child.isParam) {
810
- const paramName = child.paramName;
811
- const childParams = {
812
- ...params,
813
- [paramName]: segment ?? ""
814
- };
815
- if (rest.length === 0) {
816
- return {
817
- node: child,
818
- params: childParams
819
- };
820
- }
821
- const result = this.searchRecursive(child, rest, childParams);
822
- if (result)
823
- return result;
824
- } else if (segment === child.segment) {
825
- if (rest.length === 0) {
826
- return {
827
- node: child,
828
- params
829
- };
830
- }
831
- const result = this.searchRecursive(child, rest, params);
832
- if (result)
833
- return result;
834
- }
835
- }
836
- return void 0;
837
- }
838
- /**
839
- * Normalizes a path into an array of segments.
840
- * This method removes leading and trailing slashes, splits the path by slashes, and
841
- * @param path - The path to normalize.
842
- * @returns An array of normalized path segments.
843
- */
844
- normalize(path2) {
845
- const segments = path2.replace(/^\/+|\/+$/g, "").split("/").filter(Boolean);
846
- return ["", ...segments];
847
- }
848
- };
849
- __name(_RadixTree, "RadixTree");
850
- RadixTree = _RadixTree;
851
- }
852
- });
853
-
854
- // src/internal/request.ts
855
- var _Request, Request;
856
- var init_request = __esm({
857
- "src/internal/request.ts"() {
858
- "use strict";
859
- init_app_injector();
860
- _Request = class _Request {
861
- constructor(event, senderId, id, method, path2, body) {
862
- this.event = event;
863
- this.senderId = senderId;
864
- this.id = id;
865
- this.method = method;
866
- this.path = path2;
867
- this.body = body;
868
- this.context = RootInjector.createScope();
869
- this.params = {};
870
- this.path = path2.replace(/^\/|\/$/g, "");
871
- }
872
- };
873
- __name(_Request, "Request");
874
- Request = _Request;
875
- }
876
- });
877
-
878
- // src/internal/router.ts
879
- var router_exports = {};
880
- __export(router_exports, {
881
- Router: () => Router
882
- });
883
- var Router;
884
- var init_router = __esm({
885
- "src/internal/router.ts"() {
886
- "use strict";
887
- init_controller_decorator();
888
- init_injectable_decorator();
889
- init_method_decorator();
890
- init_injector_explorer();
891
- init_logger();
892
- init_radix_tree();
893
- init_exceptions();
894
- init_request();
895
- Router = class {
896
- constructor() {
897
- this.routes = new RadixTree();
898
- this.rootMiddlewares = [];
899
- this.lazyRoutes = /* @__PURE__ */ new Map();
900
- }
901
- // -------------------------------------------------------------------------
902
- // Registration
903
- // -------------------------------------------------------------------------
904
- registerController(controllerClass, pathPrefix, routeGuards = [], routeMiddlewares = []) {
905
- const meta = getControllerMetadata(controllerClass);
906
- if (!meta) {
907
- throw new Error(`[Noxus] Missing @Controller decorator on ${controllerClass.name}`);
908
- }
909
- const routeMeta = getRouteMetadata(controllerClass);
910
- for (const def of routeMeta) {
911
- const fullPath = `${pathPrefix}/${def.path}`.replace(/\/+/g, "/").replace(/\/$/, "") || "/";
912
- const guards = [.../* @__PURE__ */ new Set([...routeGuards, ...def.guards])];
913
- const middlewares = [.../* @__PURE__ */ new Set([...routeMiddlewares, ...def.middlewares])];
914
- const routeDef = {
915
- method: def.method,
916
- path: fullPath,
917
- controller: controllerClass,
918
- handler: def.handler,
919
- guards,
920
- middlewares
921
- };
922
- this.routes.insert(fullPath + "/" + def.method, routeDef);
923
- const guardInfo = guards.length ? `<${guards.map((g) => g.name).join("|")}>` : "";
924
- Logger.log(`Mapped {${def.method} /${fullPath}}${guardInfo} route`);
925
- }
926
- const ctrlGuardInfo = routeGuards.length ? `<${routeGuards.map((g) => g.name).join("|")}>` : "";
927
- Logger.log(`Mapped ${controllerClass.name}${ctrlGuardInfo} controller's routes`);
928
- return this;
929
- }
930
- registerLazyRoute(pathPrefix, load, guards = [], middlewares = []) {
931
- const normalized = pathPrefix.replace(/^\/+|\/+$/g, "");
932
- this.lazyRoutes.set(normalized, { load, guards, middlewares, loading: null, loaded: false });
933
- Logger.log(`Registered lazy route prefix {${normalized}}`);
934
- return this;
935
- }
936
- defineRootMiddleware(middleware) {
937
- this.rootMiddlewares.push(middleware);
938
- return this;
939
- }
940
- // -------------------------------------------------------------------------
941
- // Request handling
942
- // -------------------------------------------------------------------------
943
- async handle(request) {
944
- return request.method === "BATCH" ? this.handleBatch(request) : this.handleAtomic(request);
945
- }
946
- async handleAtomic(request) {
947
- Logger.comment(`> ${request.method} /${request.path}`);
948
- const t0 = performance.now();
949
- const response = { requestId: request.id, status: 200, body: null };
950
- let isCritical = false;
951
- try {
952
- const routeDef = await this.findRoute(request);
953
- await this.resolveController(request, response, routeDef);
954
- if (response.status >= 400) throw new ResponseException(response.status, response.error);
955
- } catch (error) {
956
- this.fillErrorResponse(response, error, (c) => {
957
- isCritical = c;
958
- });
959
- } finally {
960
- this.logResponse(request, response, performance.now() - t0, isCritical);
961
- return response;
962
- }
963
- }
964
- async handleBatch(request) {
965
- Logger.comment(`> ${request.method} /${request.path}`);
966
- const t0 = performance.now();
967
- const response = {
968
- requestId: request.id,
969
- status: 200,
970
- body: { responses: [] }
971
- };
972
- let isCritical = false;
973
- try {
974
- const payload = this.normalizeBatchPayload(request.body);
975
- response.body.responses = await Promise.all(
976
- payload.requests.map((item, i) => {
977
- const id = item.requestId ?? `${request.id}:${i}`;
978
- return this.handleAtomic(new Request(request.event, request.senderId, id, item.method, item.path, item.body));
979
- })
980
- );
981
- } catch (error) {
982
- this.fillErrorResponse(response, error, (c) => {
983
- isCritical = c;
984
- });
985
- } finally {
986
- this.logResponse(request, response, performance.now() - t0, isCritical);
987
- return response;
988
- }
989
- }
990
- // -------------------------------------------------------------------------
991
- // Route resolution
992
- // -------------------------------------------------------------------------
993
- tryFindRoute(request) {
994
- const matched = this.routes.search(request.path);
995
- if (!matched?.node || matched.node.children.length === 0) return void 0;
996
- return matched.node.findExactChild(request.method)?.value;
997
- }
998
- async findRoute(request) {
999
- const direct = this.tryFindRoute(request);
1000
- if (direct) return direct;
1001
- await this.tryLoadLazyRoute(request.path);
1002
- const afterLazy = this.tryFindRoute(request);
1003
- if (afterLazy) return afterLazy;
1004
- throw new NotFoundException(`No route matches ${request.method} ${request.path}`);
1005
- }
1006
- async tryLoadLazyRoute(requestPath) {
1007
- const firstSegment = requestPath.replace(/^\/+/, "").split("/")[0] ?? "";
1008
- for (const [prefix, entry] of this.lazyRoutes) {
1009
- if (entry.loaded) continue;
1010
- const normalized = requestPath.replace(/^\/+/, "");
1011
- if (normalized === prefix || normalized.startsWith(prefix + "/") || firstSegment === prefix) {
1012
- if (!entry.loading) entry.loading = this.loadLazyModule(prefix, entry);
1013
- await entry.loading;
1014
- return;
1015
- }
1016
- }
1017
- }
1018
- async loadLazyModule(prefix, entry) {
1019
- const t0 = performance.now();
1020
- InjectorExplorer.beginAccumulate();
1021
- await entry.load?.();
1022
- entry.loading = null;
1023
- entry.load = null;
1024
- InjectorExplorer.flushAccumulated(entry.guards, entry.middlewares, prefix);
1025
- entry.loaded = true;
1026
- Logger.info(`Lazy-loaded module for prefix {${prefix}} in ${Math.round(performance.now() - t0)}ms`);
1027
- }
1028
- // -------------------------------------------------------------------------
1029
- // Pipeline
1030
- // -------------------------------------------------------------------------
1031
- async resolveController(request, response, routeDef) {
1032
- const instance = request.context.resolve(routeDef.controller);
1033
- Object.assign(request.params, this.extractParams(request.path, routeDef.path));
1034
- await this.runPipeline(request, response, routeDef, instance);
1035
- }
1036
- async runPipeline(request, response, routeDef, controllerInstance) {
1037
- const middlewares = [.../* @__PURE__ */ new Set([...this.rootMiddlewares, ...routeDef.middlewares])];
1038
- const mwMax = middlewares.length - 1;
1039
- const guardMax = mwMax + routeDef.guards.length;
1040
- let index = -1;
1041
- const dispatch = /* @__PURE__ */ __name(async (i) => {
1042
- if (i <= index) throw new Error("next() called multiple times");
1043
- index = i;
1044
- if (i <= mwMax) {
1045
- await this.runMiddleware(request, response, dispatch.bind(null, i + 1), middlewares[i]);
1046
- if (response.status >= 400) throw new ResponseException(response.status, response.error);
1047
- return;
1048
- }
1049
- if (i <= guardMax) {
1050
- await this.runGuard(request, routeDef.guards[i - middlewares.length]);
1051
- await dispatch(i + 1);
1052
- return;
1053
- }
1054
- const action = controllerInstance[routeDef.handler];
1055
- response.body = await action.call(controllerInstance, request, response);
1056
- if (response.body === void 0) response.body = {};
1057
- }, "dispatch");
1058
- await dispatch(0);
1059
- }
1060
- async runMiddleware(request, response, next, middleware) {
1061
- await middleware(request, response, next);
1062
- }
1063
- async runGuard(request, guard) {
1064
- if (!await guard(request)) {
1065
- throw new UnauthorizedException(`Unauthorized for ${request.method} ${request.path}`);
1066
- }
1067
- }
1068
- // -------------------------------------------------------------------------
1069
- // Utilities
1070
- // -------------------------------------------------------------------------
1071
- extractParams(actual, template) {
1072
- const aParts = actual.split("/");
1073
- const tParts = template.split("/");
1074
- const params = {};
1075
- tParts.forEach((part, i) => {
1076
- if (part.startsWith(":")) params[part.slice(1)] = aParts[i] ?? "";
1077
- });
1078
- return params;
1079
- }
1080
- normalizeBatchPayload(body) {
1081
- if (body === null || typeof body !== "object") {
1082
- throw new BadRequestException("Batch payload must be an object containing a requests array.");
1083
- }
1084
- const { requests } = body;
1085
- if (!Array.isArray(requests)) throw new BadRequestException("Batch payload must define a requests array.");
1086
- return { requests: requests.map((e, i) => this.normalizeBatchItem(e, i)) };
1087
- }
1088
- normalizeBatchItem(entry, index) {
1089
- if (entry === null || typeof entry !== "object") throw new BadRequestException(`Batch request at index ${index} must be an object.`);
1090
- const { requestId, path: path2, method, body } = entry;
1091
- if (requestId !== void 0 && typeof requestId !== "string") throw new BadRequestException(`Batch request at index ${index} has an invalid requestId.`);
1092
- if (typeof path2 !== "string" || !path2.length) throw new BadRequestException(`Batch request at index ${index} must define a non-empty path.`);
1093
- if (typeof method !== "string") throw new BadRequestException(`Batch request at index ${index} must define an HTTP method.`);
1094
- const normalized = method.toUpperCase();
1095
- if (!isAtomicHttpMethod(normalized)) throw new BadRequestException(`Batch request at index ${index} uses unsupported method ${method}.`);
1096
- return { requestId, path: path2, method: normalized, body };
1097
- }
1098
- fillErrorResponse(response, error, setCritical) {
1099
- response.body = void 0;
1100
- if (error instanceof ResponseException) {
1101
- response.status = error.status;
1102
- response.error = error.message;
1103
- response.stack = error.stack;
1104
- } else if (error instanceof Error) {
1105
- setCritical(true);
1106
- response.status = 500;
1107
- response.error = error.message || "Internal Server Error";
1108
- response.stack = error.stack;
1109
- } else {
1110
- setCritical(true);
1111
- response.status = 500;
1112
- response.error = "Unknown error occurred";
1113
- }
1114
- }
1115
- logResponse(request, response, ms, isCritical) {
1116
- const msg = `< ${response.status} ${request.method} /${request.path} ${Logger.colors.yellow}${Math.round(ms)}ms${Logger.colors.initial}`;
1117
- if (response.status < 400) Logger.log(msg);
1118
- else if (response.status < 500) Logger.warn(msg);
1119
- else isCritical ? Logger.critical(msg) : Logger.error(msg);
1120
- if (response.error) {
1121
- isCritical ? Logger.critical(response.error) : Logger.error(response.error);
1122
- if (response.stack) Logger.errorStack(response.stack);
1123
- }
1124
- }
1125
- };
1126
- __name(Router, "Router");
1127
- Router = __decorateClass([
1128
- Injectable({ lifetime: "singleton" })
1129
- ], Router);
1130
- }
1131
- });
1132
-
1133
316
  // src/DI/injector-explorer.ts
317
+ var injector_explorer_exports = {};
318
+ __export(injector_explorer_exports, {
319
+ InjectorExplorer: () => InjectorExplorer
320
+ });
1134
321
  var _InjectorExplorer, InjectorExplorer;
1135
322
  var init_injector_explorer = __esm({
1136
323
  "src/DI/injector-explorer.ts"() {
@@ -1141,6 +328,13 @@ var init_injector_explorer = __esm({
1141
328
  // -------------------------------------------------------------------------
1142
329
  // Public API
1143
330
  // -------------------------------------------------------------------------
331
+ /**
332
+ * Sets the callback used to register controllers.
333
+ * Must be called once before processPending (typically by bootstrapApplication).
334
+ */
335
+ static setControllerRegistrar(registrar) {
336
+ _InjectorExplorer.controllerRegistrar = registrar;
337
+ }
1144
338
  static enqueue(reg) {
1145
339
  if (_InjectorExplorer.processed && !_InjectorExplorer.accumulating) {
1146
340
  _InjectorExplorer._registerImmediate(reg);
@@ -1166,16 +360,37 @@ var init_injector_explorer = __esm({
1166
360
  /**
1167
361
  * Exits accumulation mode and flushes queued registrations
1168
362
  * with the same two-phase guarantee as processPending.
363
+ * Serialised through a lock to prevent concurrent lazy loads from corrupting the queue.
1169
364
  */
1170
365
  static flushAccumulated(routeGuards = [], routeMiddlewares = [], pathPrefix = "") {
1171
- _InjectorExplorer.accumulating = false;
1172
- const queue = [..._InjectorExplorer.pending];
366
+ _InjectorExplorer.loadingLock = _InjectorExplorer.loadingLock.then(() => {
367
+ _InjectorExplorer.accumulating = false;
368
+ const queue = [..._InjectorExplorer.pending];
369
+ _InjectorExplorer.pending.length = 0;
370
+ _InjectorExplorer._phaseOne(queue);
371
+ for (const reg of queue) {
372
+ if (reg.isController) reg.pathPrefix = pathPrefix;
373
+ }
374
+ _InjectorExplorer._phaseTwo(queue, void 0, routeGuards, routeMiddlewares);
375
+ });
376
+ return _InjectorExplorer.loadingLock;
377
+ }
378
+ /**
379
+ * Returns a Promise that resolves once all pending flushAccumulated calls
380
+ * have completed. Useful for awaiting lazy-load serialisation.
381
+ */
382
+ static waitForFlush() {
383
+ return _InjectorExplorer.loadingLock;
384
+ }
385
+ /**
386
+ * Resets the explorer state. Intended for tests only.
387
+ */
388
+ static reset() {
1173
389
  _InjectorExplorer.pending.length = 0;
1174
- _InjectorExplorer._phaseOne(queue);
1175
- for (const reg of queue) {
1176
- if (reg.isController) reg.pathPrefix = pathPrefix;
1177
- }
1178
- _InjectorExplorer._phaseTwo(queue, void 0, routeGuards, routeMiddlewares);
390
+ _InjectorExplorer.processed = false;
391
+ _InjectorExplorer.accumulating = false;
392
+ _InjectorExplorer.loadingLock = Promise.resolve();
393
+ _InjectorExplorer.controllerRegistrar = null;
1179
394
  }
1180
395
  // -------------------------------------------------------------------------
1181
396
  // Private helpers
@@ -1186,8 +401,15 @@ var init_injector_explorer = __esm({
1186
401
  RootInjector.register(reg.key, reg.implementation, reg.lifetime, reg.deps);
1187
402
  }
1188
403
  }
1189
- /** Phase 2: resolve singletons and register controllers in the router. */
404
+ /** Phase 2: validate deps, resolve singletons and register controllers via the registrar callback. */
1190
405
  static _phaseTwo(queue, overrides, routeGuards = [], routeMiddlewares = []) {
406
+ for (const reg of queue) {
407
+ for (const dep of reg.deps) {
408
+ if (!RootInjector.bindings.has(dep) && !RootInjector.singletons.has(dep)) {
409
+ Logger.warn(`[Noxus DI] "${reg.implementation.name}" declares dep "${dep.name ?? dep}" which has no binding`);
410
+ }
411
+ }
412
+ }
1191
413
  for (const reg of queue) {
1192
414
  if (overrides?.has(reg.key)) {
1193
415
  const override = overrides.get(reg.key);
@@ -1199,9 +421,15 @@ var init_injector_explorer = __esm({
1199
421
  RootInjector.resolve(reg.key);
1200
422
  }
1201
423
  if (reg.isController) {
1202
- const { Router: Router2 } = (init_router(), __toCommonJS(router_exports));
1203
- const router = RootInjector.resolve(Router2);
1204
- router.registerController(reg.implementation, reg.pathPrefix ?? "", routeGuards, routeMiddlewares);
424
+ if (!_InjectorExplorer.controllerRegistrar) {
425
+ throw new Error("[Noxus DI] No controller registrar set. Call InjectorExplorer.setControllerRegistrar() before processing.");
426
+ }
427
+ _InjectorExplorer.controllerRegistrar(
428
+ reg.implementation,
429
+ reg.pathPrefix ?? "",
430
+ routeGuards,
431
+ routeMiddlewares
432
+ );
1205
433
  } else if (reg.lifetime !== "singleton") {
1206
434
  Logger.log(`Registered ${reg.implementation.name} as ${reg.lifetime}`);
1207
435
  }
@@ -1212,28 +440,351 @@ var init_injector_explorer = __esm({
1212
440
  if (reg.lifetime === "singleton") {
1213
441
  RootInjector.resolve(reg.key);
1214
442
  }
1215
- if (reg.isController) {
1216
- const { Router: Router2 } = (init_router(), __toCommonJS(router_exports));
1217
- const router = RootInjector.resolve(Router2);
1218
- router.registerController(reg.implementation);
443
+ if (reg.isController && _InjectorExplorer.controllerRegistrar) {
444
+ _InjectorExplorer.controllerRegistrar(reg.implementation, "", [], []);
1219
445
  }
1220
446
  }
1221
447
  };
1222
448
  __name(_InjectorExplorer, "InjectorExplorer");
1223
- _InjectorExplorer.pending = [];
1224
- _InjectorExplorer.processed = false;
1225
- _InjectorExplorer.accumulating = false;
449
+ __publicField(_InjectorExplorer, "pending", []);
450
+ __publicField(_InjectorExplorer, "processed", false);
451
+ __publicField(_InjectorExplorer, "accumulating", false);
452
+ __publicField(_InjectorExplorer, "loadingLock", Promise.resolve());
453
+ __publicField(_InjectorExplorer, "controllerRegistrar", null);
1226
454
  InjectorExplorer = _InjectorExplorer;
1227
455
  }
1228
456
  });
1229
457
 
458
+ // src/DI/app-injector.ts
459
+ function keyOf(k) {
460
+ return k;
461
+ }
462
+ function resetRootInjector() {
463
+ RootInjector.bindings.clear();
464
+ RootInjector.singletons.clear();
465
+ RootInjector.scoped.clear();
466
+ const { InjectorExplorer: InjectorExplorer2 } = (init_injector_explorer(), __toCommonJS(injector_explorer_exports));
467
+ InjectorExplorer2.reset();
468
+ }
469
+ function inject(t) {
470
+ return RootInjector.resolve(t);
471
+ }
472
+ var _AppInjector, AppInjector, RootInjector;
473
+ var init_app_injector = __esm({
474
+ "src/DI/app-injector.ts"() {
475
+ "use strict";
476
+ init_forward_ref();
477
+ init_token();
478
+ __name(keyOf, "keyOf");
479
+ _AppInjector = class _AppInjector {
480
+ constructor(name = null) {
481
+ this.name = name;
482
+ __publicField(this, "bindings", /* @__PURE__ */ new Map());
483
+ __publicField(this, "singletons", /* @__PURE__ */ new Map());
484
+ __publicField(this, "scoped", /* @__PURE__ */ new Map());
485
+ }
486
+ /**
487
+ * Creates a child scope for per-request lifetime resolution.
488
+ */
489
+ createScope() {
490
+ const scope = new _AppInjector();
491
+ scope.bindings = this.bindings;
492
+ scope.singletons = this.singletons;
493
+ return scope;
494
+ }
495
+ /**
496
+ * Registers a binding explicitly.
497
+ */
498
+ register(key, implementation, lifetime, deps = []) {
499
+ const k = keyOf(key);
500
+ if (!this.bindings.has(k)) {
501
+ this.bindings.set(k, { lifetime, implementation, deps });
502
+ }
503
+ }
504
+ /**
505
+ * Resolves a dependency by token or class reference.
506
+ */
507
+ resolve(target) {
508
+ if (target instanceof ForwardReference) {
509
+ return this._resolveForwardRef(target);
510
+ }
511
+ const k = keyOf(target);
512
+ if (this.singletons.has(k)) {
513
+ return this.singletons.get(k);
514
+ }
515
+ const binding = this.bindings.get(k);
516
+ if (!binding) {
517
+ const name = target instanceof Token ? target.description : target.name ?? "unknown";
518
+ throw new Error(
519
+ `[Noxus DI] No binding found for "${name}".
520
+ Did you forget to declare it in @Injectable({ deps }) or in bootstrapApplication({ singletons })?`
521
+ );
522
+ }
523
+ switch (binding.lifetime) {
524
+ case "transient":
525
+ return this._instantiate(binding);
526
+ case "scope": {
527
+ if (this.scoped.has(k)) return this.scoped.get(k);
528
+ const inst = this._instantiate(binding);
529
+ this.scoped.set(k, inst);
530
+ return inst;
531
+ }
532
+ case "singleton": {
533
+ if (this.singletons.has(k)) return this.singletons.get(k);
534
+ const inst = this._instantiate(binding);
535
+ this.singletons.set(k, inst);
536
+ if (binding.instance === void 0) {
537
+ binding.instance = inst;
538
+ }
539
+ return inst;
540
+ }
541
+ }
542
+ }
543
+ // -------------------------------------------------------------------------
544
+ _resolveForwardRef(ref) {
545
+ let resolved;
546
+ return new Proxy({}, {
547
+ get: /* @__PURE__ */ __name((_obj, prop, receiver) => {
548
+ resolved ?? (resolved = this.resolve(ref.forwardRefFn()));
549
+ const value = Reflect.get(resolved, prop, receiver);
550
+ return typeof value === "function" ? value.bind(resolved) : value;
551
+ }, "get"),
552
+ set: /* @__PURE__ */ __name((_obj, prop, value, receiver) => {
553
+ resolved ?? (resolved = this.resolve(ref.forwardRefFn()));
554
+ return Reflect.set(resolved, prop, value, receiver);
555
+ }, "set"),
556
+ getPrototypeOf: /* @__PURE__ */ __name(() => {
557
+ resolved ?? (resolved = this.resolve(ref.forwardRefFn()));
558
+ return Object.getPrototypeOf(resolved);
559
+ }, "getPrototypeOf")
560
+ });
561
+ }
562
+ _instantiate(binding) {
563
+ const resolvedDeps = binding.deps.map((dep) => this.resolve(dep));
564
+ return new binding.implementation(...resolvedDeps);
565
+ }
566
+ };
567
+ __name(_AppInjector, "AppInjector");
568
+ AppInjector = _AppInjector;
569
+ RootInjector = new AppInjector("root");
570
+ __name(resetRootInjector, "resetRootInjector");
571
+ __name(inject, "inject");
572
+ }
573
+ });
574
+
575
+ // src/non-electron-process.ts
576
+ init_app_injector();
577
+
578
+ // src/internal/exceptions.ts
579
+ var _ResponseException = class _ResponseException extends Error {
580
+ constructor(statusOrMessage, message) {
581
+ let statusCode;
582
+ if (typeof statusOrMessage === "number") {
583
+ statusCode = statusOrMessage;
584
+ } else if (typeof statusOrMessage === "string") {
585
+ message = statusOrMessage;
586
+ }
587
+ super(message ?? "");
588
+ __publicField(this, "status", 0);
589
+ if (statusCode !== void 0) {
590
+ this.status = statusCode;
591
+ }
592
+ this.name = this.constructor.name.replace(/([A-Z])/g, " $1");
593
+ }
594
+ };
595
+ __name(_ResponseException, "ResponseException");
596
+ var ResponseException = _ResponseException;
597
+ var _BadRequestException = class _BadRequestException extends ResponseException {
598
+ constructor() {
599
+ super(...arguments);
600
+ __publicField(this, "status", 400);
601
+ }
602
+ };
603
+ __name(_BadRequestException, "BadRequestException");
604
+ var BadRequestException = _BadRequestException;
605
+ var _UnauthorizedException = class _UnauthorizedException extends ResponseException {
606
+ constructor() {
607
+ super(...arguments);
608
+ __publicField(this, "status", 401);
609
+ }
610
+ };
611
+ __name(_UnauthorizedException, "UnauthorizedException");
612
+ var UnauthorizedException = _UnauthorizedException;
613
+ var _PaymentRequiredException = class _PaymentRequiredException extends ResponseException {
614
+ constructor() {
615
+ super(...arguments);
616
+ __publicField(this, "status", 402);
617
+ }
618
+ };
619
+ __name(_PaymentRequiredException, "PaymentRequiredException");
620
+ var PaymentRequiredException = _PaymentRequiredException;
621
+ var _ForbiddenException = class _ForbiddenException extends ResponseException {
622
+ constructor() {
623
+ super(...arguments);
624
+ __publicField(this, "status", 403);
625
+ }
626
+ };
627
+ __name(_ForbiddenException, "ForbiddenException");
628
+ var ForbiddenException = _ForbiddenException;
629
+ var _NotFoundException = class _NotFoundException extends ResponseException {
630
+ constructor() {
631
+ super(...arguments);
632
+ __publicField(this, "status", 404);
633
+ }
634
+ };
635
+ __name(_NotFoundException, "NotFoundException");
636
+ var NotFoundException = _NotFoundException;
637
+ var _MethodNotAllowedException = class _MethodNotAllowedException extends ResponseException {
638
+ constructor() {
639
+ super(...arguments);
640
+ __publicField(this, "status", 405);
641
+ }
642
+ };
643
+ __name(_MethodNotAllowedException, "MethodNotAllowedException");
644
+ var MethodNotAllowedException = _MethodNotAllowedException;
645
+ var _NotAcceptableException = class _NotAcceptableException extends ResponseException {
646
+ constructor() {
647
+ super(...arguments);
648
+ __publicField(this, "status", 406);
649
+ }
650
+ };
651
+ __name(_NotAcceptableException, "NotAcceptableException");
652
+ var NotAcceptableException = _NotAcceptableException;
653
+ var _RequestTimeoutException = class _RequestTimeoutException extends ResponseException {
654
+ constructor() {
655
+ super(...arguments);
656
+ __publicField(this, "status", 408);
657
+ }
658
+ };
659
+ __name(_RequestTimeoutException, "RequestTimeoutException");
660
+ var RequestTimeoutException = _RequestTimeoutException;
661
+ var _ConflictException = class _ConflictException extends ResponseException {
662
+ constructor() {
663
+ super(...arguments);
664
+ __publicField(this, "status", 409);
665
+ }
666
+ };
667
+ __name(_ConflictException, "ConflictException");
668
+ var ConflictException = _ConflictException;
669
+ var _UpgradeRequiredException = class _UpgradeRequiredException extends ResponseException {
670
+ constructor() {
671
+ super(...arguments);
672
+ __publicField(this, "status", 426);
673
+ }
674
+ };
675
+ __name(_UpgradeRequiredException, "UpgradeRequiredException");
676
+ var UpgradeRequiredException = _UpgradeRequiredException;
677
+ var _TooManyRequestsException = class _TooManyRequestsException extends ResponseException {
678
+ constructor() {
679
+ super(...arguments);
680
+ __publicField(this, "status", 429);
681
+ }
682
+ };
683
+ __name(_TooManyRequestsException, "TooManyRequestsException");
684
+ var TooManyRequestsException = _TooManyRequestsException;
685
+ var _InternalServerException = class _InternalServerException extends ResponseException {
686
+ constructor() {
687
+ super(...arguments);
688
+ __publicField(this, "status", 500);
689
+ }
690
+ };
691
+ __name(_InternalServerException, "InternalServerException");
692
+ var InternalServerException = _InternalServerException;
693
+ var _NotImplementedException = class _NotImplementedException extends ResponseException {
694
+ constructor() {
695
+ super(...arguments);
696
+ __publicField(this, "status", 501);
697
+ }
698
+ };
699
+ __name(_NotImplementedException, "NotImplementedException");
700
+ var NotImplementedException = _NotImplementedException;
701
+ var _BadGatewayException = class _BadGatewayException extends ResponseException {
702
+ constructor() {
703
+ super(...arguments);
704
+ __publicField(this, "status", 502);
705
+ }
706
+ };
707
+ __name(_BadGatewayException, "BadGatewayException");
708
+ var BadGatewayException = _BadGatewayException;
709
+ var _ServiceUnavailableException = class _ServiceUnavailableException extends ResponseException {
710
+ constructor() {
711
+ super(...arguments);
712
+ __publicField(this, "status", 503);
713
+ }
714
+ };
715
+ __name(_ServiceUnavailableException, "ServiceUnavailableException");
716
+ var ServiceUnavailableException = _ServiceUnavailableException;
717
+ var _GatewayTimeoutException = class _GatewayTimeoutException extends ResponseException {
718
+ constructor() {
719
+ super(...arguments);
720
+ __publicField(this, "status", 504);
721
+ }
722
+ };
723
+ __name(_GatewayTimeoutException, "GatewayTimeoutException");
724
+ var GatewayTimeoutException = _GatewayTimeoutException;
725
+ var _HttpVersionNotSupportedException = class _HttpVersionNotSupportedException extends ResponseException {
726
+ constructor() {
727
+ super(...arguments);
728
+ __publicField(this, "status", 505);
729
+ }
730
+ };
731
+ __name(_HttpVersionNotSupportedException, "HttpVersionNotSupportedException");
732
+ var HttpVersionNotSupportedException = _HttpVersionNotSupportedException;
733
+ var _VariantAlsoNegotiatesException = class _VariantAlsoNegotiatesException extends ResponseException {
734
+ constructor() {
735
+ super(...arguments);
736
+ __publicField(this, "status", 506);
737
+ }
738
+ };
739
+ __name(_VariantAlsoNegotiatesException, "VariantAlsoNegotiatesException");
740
+ var VariantAlsoNegotiatesException = _VariantAlsoNegotiatesException;
741
+ var _InsufficientStorageException = class _InsufficientStorageException extends ResponseException {
742
+ constructor() {
743
+ super(...arguments);
744
+ __publicField(this, "status", 507);
745
+ }
746
+ };
747
+ __name(_InsufficientStorageException, "InsufficientStorageException");
748
+ var InsufficientStorageException = _InsufficientStorageException;
749
+ var _LoopDetectedException = class _LoopDetectedException extends ResponseException {
750
+ constructor() {
751
+ super(...arguments);
752
+ __publicField(this, "status", 508);
753
+ }
754
+ };
755
+ __name(_LoopDetectedException, "LoopDetectedException");
756
+ var LoopDetectedException = _LoopDetectedException;
757
+ var _NotExtendedException = class _NotExtendedException extends ResponseException {
758
+ constructor() {
759
+ super(...arguments);
760
+ __publicField(this, "status", 510);
761
+ }
762
+ };
763
+ __name(_NotExtendedException, "NotExtendedException");
764
+ var NotExtendedException = _NotExtendedException;
765
+ var _NetworkAuthenticationRequiredException = class _NetworkAuthenticationRequiredException extends ResponseException {
766
+ constructor() {
767
+ super(...arguments);
768
+ __publicField(this, "status", 511);
769
+ }
770
+ };
771
+ __name(_NetworkAuthenticationRequiredException, "NetworkAuthenticationRequiredException");
772
+ var NetworkAuthenticationRequiredException = _NetworkAuthenticationRequiredException;
773
+ var _NetworkConnectTimeoutException = class _NetworkConnectTimeoutException extends ResponseException {
774
+ constructor() {
775
+ super(...arguments);
776
+ __publicField(this, "status", 599);
777
+ }
778
+ };
779
+ __name(_NetworkConnectTimeoutException, "NetworkConnectTimeoutException");
780
+ var NetworkConnectTimeoutException = _NetworkConnectTimeoutException;
781
+
1230
782
  // src/decorators/injectable.decorator.ts
783
+ init_injector_explorer();
784
+ init_token();
1231
785
  function Injectable(options = {}) {
1232
786
  const { lifetime = "scope", deps = [] } = options;
1233
- return (target) => {
1234
- if (typeof target !== "function" || !target.prototype) {
1235
- throw new Error(`@Injectable can only be applied to classes, not ${typeof target}`);
1236
- }
787
+ return (target, _context) => {
1237
788
  const key = target;
1238
789
  InjectorExplorer.enqueue({
1239
790
  key,
@@ -1244,19 +795,9 @@ function Injectable(options = {}) {
1244
795
  });
1245
796
  };
1246
797
  }
1247
- var init_injectable_decorator = __esm({
1248
- "src/decorators/injectable.decorator.ts"() {
1249
- "use strict";
1250
- init_injector_explorer();
1251
- init_token();
1252
- __name(Injectable, "Injectable");
1253
- }
1254
- });
798
+ __name(Injectable, "Injectable");
1255
799
 
1256
800
  // src/non-electron-process.ts
1257
- init_app_injector();
1258
- init_exceptions();
1259
- init_injectable_decorator();
1260
801
  init_logger();
1261
802
  init_forward_ref();
1262
803
  export {
@@ -1291,7 +832,8 @@ export {
1291
832
  UpgradeRequiredException,
1292
833
  VariantAlsoNegotiatesException,
1293
834
  forwardRef,
1294
- inject
835
+ inject,
836
+ resetRootInjector
1295
837
  };
1296
838
  /**
1297
839
  * @copyright 2025 NoxFly