@noxfly/noxus 3.0.0-dev.8 → 3.0.0-dev.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.d.mts CHANGED
@@ -258,6 +258,7 @@ declare class Router {
258
258
  private readonly routes;
259
259
  private readonly rootMiddlewares;
260
260
  private readonly lazyRoutes;
261
+ private lazyLoadLock;
261
262
  registerController(controllerClass: Type<unknown>, pathPrefix: string, routeGuards?: Guard[], routeMiddlewares?: Middleware[]): this;
262
263
  registerLazyRoute(pathPrefix: string, load: () => Promise<unknown>, guards?: Guard[], middlewares?: Middleware[]): this;
263
264
  defineRootMiddleware(middleware: Middleware): this;
package/dist/main.d.ts CHANGED
@@ -258,6 +258,7 @@ declare class Router {
258
258
  private readonly routes;
259
259
  private readonly rootMiddlewares;
260
260
  private readonly lazyRoutes;
261
+ private lazyLoadLock;
261
262
  registerController(controllerClass: Type<unknown>, pathPrefix: string, routeGuards?: Guard[], routeMiddlewares?: Middleware[]): this;
262
263
  registerLazyRoute(pathPrefix: string, load: () => Promise<unknown>, guards?: Guard[], middlewares?: Middleware[]): this;
263
264
  defineRootMiddleware(middleware: Middleware): this;
package/dist/main.js CHANGED
@@ -1154,6 +1154,7 @@ var Router = class {
1154
1154
  this.routes = new RadixTree();
1155
1155
  this.rootMiddlewares = [];
1156
1156
  this.lazyRoutes = /* @__PURE__ */ new Map();
1157
+ this.lazyLoadLock = Promise.resolve();
1157
1158
  }
1158
1159
  // -------------------------------------------------------------------------
1159
1160
  // Registration
@@ -1282,15 +1283,19 @@ var Router = class {
1282
1283
  }
1283
1284
  }
1284
1285
  }
1285
- async loadLazyModule(prefix, entry) {
1286
- const t0 = performance.now();
1287
- InjectorExplorer.beginAccumulate();
1288
- await entry.load?.();
1289
- entry.loading = null;
1290
- entry.load = null;
1291
- await InjectorExplorer.flushAccumulated(entry.guards, entry.middlewares, prefix);
1292
- entry.loaded = true;
1293
- Logger.info(`Lazy-loaded module for prefix {${prefix}} in ${Math.round(performance.now() - t0)}ms`);
1286
+ loadLazyModule(prefix, entry) {
1287
+ const task = this.lazyLoadLock.then(async () => {
1288
+ const t0 = performance.now();
1289
+ InjectorExplorer.beginAccumulate();
1290
+ await entry.load?.();
1291
+ entry.load = null;
1292
+ await InjectorExplorer.flushAccumulated(entry.guards, entry.middlewares, prefix);
1293
+ entry.loaded = true;
1294
+ entry.loading = null;
1295
+ Logger.info(`Lazy-loaded module for prefix {${prefix}} in ${Math.round(performance.now() - t0)}ms`);
1296
+ });
1297
+ this.lazyLoadLock = task;
1298
+ return task;
1294
1299
  }
1295
1300
  // -------------------------------------------------------------------------
1296
1301
  // Pipeline