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