@navios/openapi-bun 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/lib/index.cjs +197 -447
- package/lib/index.cjs.map +1 -1
- package/lib/index.mjs +197 -447
- package/lib/index.mjs.map +1 -1
- package/package.json +9 -9
package/lib/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
let
|
|
1
|
+
let node_async_hooks = require("node:async_hooks");
|
|
2
2
|
let _navios_builder = require("@navios/builder");
|
|
3
3
|
let _navios_core = require("@navios/core");
|
|
4
4
|
let _navios_openapi = require("@navios/openapi");
|
|
@@ -6,8 +6,7 @@ let zod = require("zod");
|
|
|
6
6
|
let yaml = require("yaml");
|
|
7
7
|
let _scalar_core_libs_html_rendering = require("@scalar/core/libs/html-rendering");
|
|
8
8
|
|
|
9
|
-
//#region ../di/lib/
|
|
10
|
-
var __require = /* @__PURE__ */ (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
9
|
+
//#region ../di/lib/container-DAKOvAgr.mjs
|
|
11
10
|
let InjectableScope = /* @__PURE__ */ function(InjectableScope$1) {
|
|
12
11
|
/**
|
|
13
12
|
* Singleton scope: The instance is created once and shared across the application.
|
|
@@ -99,6 +98,7 @@ var FactoryInjectionToken = class {
|
|
|
99
98
|
}
|
|
100
99
|
};
|
|
101
100
|
var Registry = class {
|
|
101
|
+
parent;
|
|
102
102
|
factories = /* @__PURE__ */ new Map();
|
|
103
103
|
constructor(parent) {
|
|
104
104
|
this.parent = parent;
|
|
@@ -127,6 +127,23 @@ var Registry = class {
|
|
|
127
127
|
delete(token) {
|
|
128
128
|
this.factories.delete(token.id);
|
|
129
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* Updates the scope of an already registered factory.
|
|
132
|
+
* This is useful when you need to dynamically change a service's scope
|
|
133
|
+
* (e.g., when a singleton controller has request-scoped dependencies).
|
|
134
|
+
*
|
|
135
|
+
* @param token The injection token to update
|
|
136
|
+
* @param scope The new scope to set
|
|
137
|
+
* @returns true if the scope was updated, false if the token was not found
|
|
138
|
+
*/ updateScope(token, scope) {
|
|
139
|
+
const factory = this.factories.get(token.id);
|
|
140
|
+
if (factory) {
|
|
141
|
+
factory.scope = scope;
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
if (this.parent) return this.parent.updateScope(token, scope);
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
130
147
|
};
|
|
131
148
|
const globalRegistry = new Registry();
|
|
132
149
|
const InjectableTokenMeta = Symbol.for("InjectableTokenMeta");
|
|
@@ -181,86 +198,29 @@ var DIError = class DIError$1 extends Error {
|
|
|
181
198
|
return new DIError$1(DIErrorCode.CircularDependency, `Circular dependency detected: ${cycleStr}`, { cycle });
|
|
182
199
|
}
|
|
183
200
|
};
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
* This is acceptable for browser environments where:
|
|
195
|
-
* 1. Constructors are typically synchronous
|
|
196
|
-
* 2. Circular dependency detection mainly needs sync tracking
|
|
197
|
-
*/ var SyncLocalStorage = class {
|
|
198
|
-
stack = [];
|
|
199
|
-
/**
|
|
200
|
-
* Runs a function within the given store context.
|
|
201
|
-
* The context is only available synchronously within the function.
|
|
202
|
-
*/ run(store, fn) {
|
|
203
|
-
this.stack.push(store);
|
|
204
|
-
try {
|
|
205
|
-
return fn();
|
|
206
|
-
} finally {
|
|
207
|
-
this.stack.pop();
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Gets the current store value, or undefined if not in a context.
|
|
212
|
-
*/ getStore() {
|
|
213
|
-
return this.stack.length > 0 ? this.stack[this.stack.length - 1] : void 0;
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Exits the current context and runs the function without any store.
|
|
217
|
-
* This matches AsyncLocalStorage.exit() behavior.
|
|
218
|
-
*/ exit(fn) {
|
|
219
|
-
const savedStack = this.stack;
|
|
220
|
-
this.stack = [];
|
|
221
|
-
try {
|
|
222
|
-
return fn();
|
|
223
|
-
} finally {
|
|
224
|
-
this.stack = savedStack;
|
|
201
|
+
const isProduction$1 = process.env.NODE_ENV === "production";
|
|
202
|
+
let loadedModule = null;
|
|
203
|
+
function getModule() {
|
|
204
|
+
if (loadedModule) return loadedModule;
|
|
205
|
+
if (isProduction$1) {
|
|
206
|
+
class NoopLocalStorage {
|
|
207
|
+
run(_store, fn) {
|
|
208
|
+
return fn();
|
|
209
|
+
}
|
|
210
|
+
getStore() {}
|
|
225
211
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
* Detects if we're running in a Node.js-like environment with async_hooks support.
|
|
236
|
-
*/ function hasAsyncHooksSupport() {
|
|
237
|
-
if (typeof process !== "undefined" && process.versions && process.versions.node) return true;
|
|
238
|
-
if (typeof process !== "undefined" && process.versions && "bun" in process.versions) return true;
|
|
239
|
-
if (typeof globalThis.Deno !== "undefined") return true;
|
|
240
|
-
return false;
|
|
241
|
-
}
|
|
242
|
-
let AsyncLocalStorageClass = null;
|
|
243
|
-
let initialized = false;
|
|
244
|
-
/**
|
|
245
|
-
* Gets the appropriate AsyncLocalStorage implementation for the current environment.
|
|
246
|
-
*
|
|
247
|
-
* - On Node.js/Bun/Deno: Returns the native AsyncLocalStorage
|
|
248
|
-
* - On browsers: Returns SyncLocalStorage polyfill
|
|
249
|
-
*/ function getAsyncLocalStorageClass() {
|
|
250
|
-
if (initialized) return AsyncLocalStorageClass;
|
|
251
|
-
initialized = true;
|
|
252
|
-
if (hasAsyncHooksSupport()) try {
|
|
253
|
-
AsyncLocalStorageClass = __require("node:async_hooks").AsyncLocalStorage;
|
|
254
|
-
} catch {
|
|
255
|
-
AsyncLocalStorageClass = SyncLocalStorage;
|
|
256
|
-
}
|
|
257
|
-
else AsyncLocalStorageClass = SyncLocalStorage;
|
|
258
|
-
return AsyncLocalStorageClass;
|
|
212
|
+
loadedModule = {
|
|
213
|
+
createAsyncLocalStorage: () => new NoopLocalStorage(),
|
|
214
|
+
isUsingNativeAsyncLocalStorage: () => false
|
|
215
|
+
};
|
|
216
|
+
} else loadedModule = {
|
|
217
|
+
createAsyncLocalStorage: () => new node_async_hooks.AsyncLocalStorage(),
|
|
218
|
+
isUsingNativeAsyncLocalStorage: () => true
|
|
219
|
+
};
|
|
220
|
+
return loadedModule;
|
|
259
221
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
*/ function createAsyncLocalStorage() {
|
|
263
|
-
return new (getAsyncLocalStorageClass())();
|
|
222
|
+
function createAsyncLocalStorage() {
|
|
223
|
+
return getModule().createAsyncLocalStorage();
|
|
264
224
|
}
|
|
265
225
|
/**
|
|
266
226
|
* AsyncLocalStorage for tracking the current resolution context.
|
|
@@ -268,7 +228,16 @@ let initialized = false;
|
|
|
268
228
|
* This allows tracking which service is being instantiated even across
|
|
269
229
|
* async boundaries (like when inject() is called inside a constructor).
|
|
270
230
|
* Essential for circular dependency detection.
|
|
271
|
-
|
|
231
|
+
*
|
|
232
|
+
* The actual implementation varies by environment:
|
|
233
|
+
* - Production: No-op (returns undefined, run() just calls fn directly)
|
|
234
|
+
* - Development: Real AsyncLocalStorage with full async tracking
|
|
235
|
+
* - Browser: SyncLocalStorage for synchronous-only tracking
|
|
236
|
+
*/ let resolutionContext = null;
|
|
237
|
+
function getResolutionContext() {
|
|
238
|
+
if (!resolutionContext) resolutionContext = createAsyncLocalStorage();
|
|
239
|
+
return resolutionContext;
|
|
240
|
+
}
|
|
272
241
|
/**
|
|
273
242
|
* Runs a function within a resolution context.
|
|
274
243
|
*
|
|
@@ -279,7 +248,7 @@ let initialized = false;
|
|
|
279
248
|
* @param getHolder Function to retrieve holders by name
|
|
280
249
|
* @param fn The function to run within the context
|
|
281
250
|
*/ function withResolutionContext(waiterHolder, getHolder, fn) {
|
|
282
|
-
return
|
|
251
|
+
return getResolutionContext().run({
|
|
283
252
|
waiterHolder,
|
|
284
253
|
getHolder
|
|
285
254
|
}, fn);
|
|
@@ -290,7 +259,7 @@ let initialized = false;
|
|
|
290
259
|
* Returns undefined if we're not inside a resolution context
|
|
291
260
|
* (e.g., when resolving a top-level service that has no parent).
|
|
292
261
|
*/ function getCurrentResolutionContext() {
|
|
293
|
-
return
|
|
262
|
+
return getResolutionContext().getStore();
|
|
294
263
|
}
|
|
295
264
|
/**
|
|
296
265
|
* Runs a function outside any resolution context.
|
|
@@ -300,7 +269,7 @@ let initialized = false;
|
|
|
300
269
|
*
|
|
301
270
|
* @param fn The function to run without resolution context
|
|
302
271
|
*/ function withoutResolutionContext(fn) {
|
|
303
|
-
return
|
|
272
|
+
return getResolutionContext().run(void 0, fn);
|
|
304
273
|
}
|
|
305
274
|
function getInjectors() {
|
|
306
275
|
let currentFactoryContext = null;
|
|
@@ -425,11 +394,17 @@ const optional = defaultInjectors.optional;
|
|
|
425
394
|
const wrapSyncInit = defaultInjectors.wrapSyncInit;
|
|
426
395
|
const provideFactoryContext = defaultInjectors.provideFactoryContext;
|
|
427
396
|
/**
|
|
397
|
+
* Whether we're running in production mode.
|
|
398
|
+
* In production, circular dependency detection is skipped for performance.
|
|
399
|
+
*/ const isProduction = process.env.NODE_ENV === "production";
|
|
400
|
+
/**
|
|
428
401
|
* Detects circular dependencies by analyzing the waitingFor relationships
|
|
429
402
|
* between service holders.
|
|
430
403
|
*
|
|
431
404
|
* Uses BFS to traverse the waitingFor graph starting from a target holder
|
|
432
405
|
* and checks if following the chain leads back to the waiter, indicating a circular dependency.
|
|
406
|
+
*
|
|
407
|
+
* Note: In production (NODE_ENV === 'production'), detection is skipped for performance.
|
|
433
408
|
*/ var CircularDetector = class {
|
|
434
409
|
/**
|
|
435
410
|
* Detects if waiting for `targetName` from `waiterName` would create a cycle.
|
|
@@ -437,11 +412,14 @@ const provideFactoryContext = defaultInjectors.provideFactoryContext;
|
|
|
437
412
|
* This works by checking if `targetName` (or any holder in its waitingFor chain)
|
|
438
413
|
* is currently waiting for `waiterName`. If so, waiting would create a deadlock.
|
|
439
414
|
*
|
|
415
|
+
* In production mode, this always returns null to skip the BFS traversal overhead.
|
|
416
|
+
*
|
|
440
417
|
* @param waiterName The name of the holder that wants to wait
|
|
441
418
|
* @param targetName The name of the holder being waited on
|
|
442
419
|
* @param getHolder Function to retrieve a holder by name
|
|
443
420
|
* @returns The cycle path if a cycle is detected, null otherwise
|
|
444
421
|
*/ static detectCycle(waiterName, targetName, getHolder) {
|
|
422
|
+
if (isProduction) return null;
|
|
445
423
|
const visited = /* @__PURE__ */ new Set();
|
|
446
424
|
const queue = [{
|
|
447
425
|
name: targetName,
|
|
@@ -487,9 +465,14 @@ const provideFactoryContext = defaultInjectors.provideFactoryContext;
|
|
|
487
465
|
*/ var BaseHolderManager = class BaseHolderManager$1 {
|
|
488
466
|
logger;
|
|
489
467
|
_holders;
|
|
468
|
+
/**
|
|
469
|
+
* Reverse dependency index: maps a dependency name to the set of holder names that depend on it.
|
|
470
|
+
* This allows O(1) lookup of dependents instead of O(n) iteration.
|
|
471
|
+
*/ _dependents;
|
|
490
472
|
constructor(logger = null) {
|
|
491
473
|
this.logger = logger;
|
|
492
474
|
this._holders = /* @__PURE__ */ new Map();
|
|
475
|
+
this._dependents = /* @__PURE__ */ new Map();
|
|
493
476
|
}
|
|
494
477
|
/**
|
|
495
478
|
* Protected getter for accessing the holders map from subclasses.
|
|
@@ -497,23 +480,81 @@ const provideFactoryContext = defaultInjectors.provideFactoryContext;
|
|
|
497
480
|
return this._holders;
|
|
498
481
|
}
|
|
499
482
|
/**
|
|
500
|
-
* Deletes a holder by name.
|
|
483
|
+
* Deletes a holder by name and cleans up the reverse dependency index.
|
|
501
484
|
* @param name The name of the holder to delete
|
|
502
485
|
* @returns true if the holder was deleted, false if it didn't exist
|
|
503
486
|
*/ delete(name) {
|
|
487
|
+
const holder = this._holders.get(name);
|
|
488
|
+
if (holder) this.removeFromDependentsIndex(name, holder.deps);
|
|
504
489
|
return this._holders.delete(name);
|
|
505
490
|
}
|
|
506
491
|
/**
|
|
492
|
+
* Registers a holder's dependencies in the reverse index.
|
|
493
|
+
* Call this after creating a holder with dependencies.
|
|
494
|
+
* @param holderName The name of the holder that has dependencies
|
|
495
|
+
* @param deps The set of dependency names
|
|
496
|
+
*/ registerDependencies(holderName, deps) {
|
|
497
|
+
for (const dep of deps) {
|
|
498
|
+
let dependents = this._dependents.get(dep);
|
|
499
|
+
if (!dependents) {
|
|
500
|
+
dependents = /* @__PURE__ */ new Set();
|
|
501
|
+
this._dependents.set(dep, dependents);
|
|
502
|
+
}
|
|
503
|
+
dependents.add(holderName);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Removes a holder from the reverse dependency index.
|
|
508
|
+
* @param holderName The name of the holder to remove
|
|
509
|
+
* @param deps The set of dependency names to clean up
|
|
510
|
+
*/ removeFromDependentsIndex(holderName, deps) {
|
|
511
|
+
for (const dep of deps) {
|
|
512
|
+
const dependents = this._dependents.get(dep);
|
|
513
|
+
if (dependents) {
|
|
514
|
+
dependents.delete(holderName);
|
|
515
|
+
if (dependents.size === 0) this._dependents.delete(dep);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Gets all holder names that depend on the given instance name.
|
|
521
|
+
* O(1) lookup using the reverse dependency index.
|
|
522
|
+
* @param instanceName The instance name to find dependents for
|
|
523
|
+
* @returns Array of holder names that depend on this instance
|
|
524
|
+
*/ getDependents(instanceName) {
|
|
525
|
+
const dependents = this._dependents.get(instanceName);
|
|
526
|
+
return dependents ? Array.from(dependents) : [];
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
507
529
|
* Filters holders based on a predicate function.
|
|
508
530
|
* @param predicate Function to test each holder
|
|
509
531
|
* @returns A new Map containing only the holders that match the predicate
|
|
532
|
+
* @deprecated Use forEachHolder() for iteration to avoid allocations
|
|
510
533
|
*/ filter(predicate) {
|
|
511
|
-
|
|
534
|
+
const result = /* @__PURE__ */ new Map();
|
|
535
|
+
for (const [key, value] of this._holders) if (predicate(value, key)) result.set(key, value);
|
|
536
|
+
return result;
|
|
537
|
+
}
|
|
538
|
+
/**
|
|
539
|
+
* Iterates over holders with a callback. More efficient than filter() as it
|
|
540
|
+
* avoids creating intermediate arrays and Maps.
|
|
541
|
+
* @param callback Function called for each holder with (holder, name)
|
|
542
|
+
*/ forEachHolder(callback) {
|
|
543
|
+
for (const [name, holder] of this._holders) callback(holder, name);
|
|
512
544
|
}
|
|
513
545
|
/**
|
|
514
|
-
*
|
|
546
|
+
* Finds the first holder matching a predicate. More efficient than filter()
|
|
547
|
+
* when only one result is needed.
|
|
548
|
+
* @param predicate Function to test each holder
|
|
549
|
+
* @returns The first matching holder or undefined
|
|
550
|
+
*/ findHolder(predicate) {
|
|
551
|
+
for (const [name, holder] of this._holders) if (predicate(holder, name)) return holder;
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* Clears all holders from this manager and the reverse dependency index.
|
|
515
555
|
*/ clear() {
|
|
516
556
|
this._holders.clear();
|
|
557
|
+
this._dependents.clear();
|
|
517
558
|
}
|
|
518
559
|
/**
|
|
519
560
|
* Gets the number of holders currently managed.
|
|
@@ -597,12 +638,14 @@ const provideFactoryContext = defaultInjectors.provideFactoryContext;
|
|
|
597
638
|
if (waiterHolder && getHolder) {
|
|
598
639
|
const cycle = CircularDetector.detectCycle(waiterHolder.name, holder.name, getHolder);
|
|
599
640
|
if (cycle) return [DIError.circularDependency(cycle)];
|
|
600
|
-
waiterHolder.waitingFor.add(holder.name);
|
|
641
|
+
if (process.env.NODE_ENV !== "production") waiterHolder.waitingFor.add(holder.name);
|
|
601
642
|
}
|
|
602
643
|
try {
|
|
603
644
|
await holder.creationPromise;
|
|
604
645
|
} finally {
|
|
605
|
-
if (
|
|
646
|
+
if (process.env.NODE_ENV !== "production") {
|
|
647
|
+
if (waiterHolder) waiterHolder.waitingFor.delete(holder.name);
|
|
648
|
+
}
|
|
606
649
|
}
|
|
607
650
|
return BaseHolderManager$1.waitForHolderReady(holder, waiterHolder, getHolder);
|
|
608
651
|
case InstanceStatus.Destroying: return [DIError.instanceDestroying(holder.name)];
|
|
@@ -717,10 +760,11 @@ const provideFactoryContext = defaultInjectors.provideFactoryContext;
|
|
|
717
760
|
return null;
|
|
718
761
|
}
|
|
719
762
|
findDependents(instanceName) {
|
|
720
|
-
const
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
return
|
|
763
|
+
const requestDependents = this.contextHolder.getDependents(instanceName);
|
|
764
|
+
const singletonDependents = this.holderManager.getDependents(instanceName);
|
|
765
|
+
if (requestDependents.length === 0) return singletonDependents;
|
|
766
|
+
if (singletonDependents.length === 0) return requestDependents;
|
|
767
|
+
return [...requestDependents, ...singletonDependents];
|
|
724
768
|
}
|
|
725
769
|
};
|
|
726
770
|
/**
|
|
@@ -856,7 +900,8 @@ const provideFactoryContext = defaultInjectors.provideFactoryContext;
|
|
|
856
900
|
*/ async resolveRequestScoped(token, args) {
|
|
857
901
|
const instanceName = this.parent.getServiceLocator().getInstanceIdentifier(token, args);
|
|
858
902
|
const existingHolder = this.requestContextHolder.get(instanceName);
|
|
859
|
-
if (existingHolder)
|
|
903
|
+
if (existingHolder) if (existingHolder.status === InstanceStatus.Error) this.requestContextHolder.delete(instanceName);
|
|
904
|
+
else {
|
|
860
905
|
const [error, readyHolder] = await BaseHolderManager.waitForHolderReady(existingHolder);
|
|
861
906
|
if (error) throw error;
|
|
862
907
|
return readyHolder.instance;
|
|
@@ -918,16 +963,13 @@ const provideFactoryContext = defaultInjectors.provideFactoryContext;
|
|
|
918
963
|
return this.manager.getAllNames();
|
|
919
964
|
}
|
|
920
965
|
forEach(callback) {
|
|
921
|
-
|
|
966
|
+
this.manager.forEachHolder((holder, name) => callback(name, holder));
|
|
922
967
|
}
|
|
923
968
|
findByInstance(instance) {
|
|
924
|
-
|
|
925
|
-
return null;
|
|
969
|
+
return this.manager.findHolder((h) => h.instance === instance) ?? null;
|
|
926
970
|
}
|
|
927
971
|
findDependents(instanceName) {
|
|
928
|
-
|
|
929
|
-
for (const [name, holder] of this.manager.filter(() => true)) if (holder.deps.has(instanceName)) dependents.push(name);
|
|
930
|
-
return dependents;
|
|
972
|
+
return this.manager.getDependents(instanceName);
|
|
931
973
|
}
|
|
932
974
|
};
|
|
933
975
|
/**
|
|
@@ -1020,7 +1062,12 @@ const provideFactoryContext = defaultInjectors.provideFactoryContext;
|
|
|
1020
1062
|
return [void 0, readyResult[1].instance];
|
|
1021
1063
|
}
|
|
1022
1064
|
return null;
|
|
1023
|
-
default:
|
|
1065
|
+
default:
|
|
1066
|
+
if (holder) {
|
|
1067
|
+
this.logger?.log(`[InstanceResolver] Removing failed instance ${instanceName} from storage to allow retry`);
|
|
1068
|
+
storage.delete(instanceName);
|
|
1069
|
+
}
|
|
1070
|
+
return null;
|
|
1024
1071
|
}
|
|
1025
1072
|
}
|
|
1026
1073
|
/**
|
|
@@ -1147,6 +1194,8 @@ const provideFactoryContext = defaultInjectors.provideFactoryContext;
|
|
|
1147
1194
|
*/ async handleInstantiationSuccess(instanceName, holder, ctx, deferred, instance, scopedContainer) {
|
|
1148
1195
|
holder.instance = instance;
|
|
1149
1196
|
holder.status = InstanceStatus.Created;
|
|
1197
|
+
if (ctx.deps.size > 0) if (scopedContainer) scopedContainer.getRequestContextHolder().registerDependencies(instanceName, ctx.deps);
|
|
1198
|
+
else this.manager.registerDependencies(instanceName, ctx.deps);
|
|
1150
1199
|
if (ctx.deps.size > 0) ctx.deps.forEach((dependency) => {
|
|
1151
1200
|
holder.destroyListeners.push(this.serviceLocator.getEventBus().on(dependency, "destroy", () => {
|
|
1152
1201
|
this.logger?.log(`[InstanceResolver] Dependency ${dependency} destroyed, invalidating ${instanceName}`);
|
|
@@ -1587,12 +1636,42 @@ const provideFactoryContext = defaultInjectors.provideFactoryContext;
|
|
|
1587
1636
|
}
|
|
1588
1637
|
};
|
|
1589
1638
|
/**
|
|
1639
|
+
* Simple LRU cache for instance name generation.
|
|
1640
|
+
* Uses a Map which maintains insertion order for efficient LRU eviction.
|
|
1641
|
+
*/ var InstanceNameCache = class {
|
|
1642
|
+
cache = /* @__PURE__ */ new Map();
|
|
1643
|
+
maxSize;
|
|
1644
|
+
constructor(maxSize = 1e3) {
|
|
1645
|
+
this.maxSize = maxSize;
|
|
1646
|
+
}
|
|
1647
|
+
get(key) {
|
|
1648
|
+
const value = this.cache.get(key);
|
|
1649
|
+
if (value !== void 0) {
|
|
1650
|
+
this.cache.delete(key);
|
|
1651
|
+
this.cache.set(key, value);
|
|
1652
|
+
}
|
|
1653
|
+
return value;
|
|
1654
|
+
}
|
|
1655
|
+
set(key, value) {
|
|
1656
|
+
if (this.cache.has(key)) this.cache.delete(key);
|
|
1657
|
+
else if (this.cache.size >= this.maxSize) {
|
|
1658
|
+
const firstKey = this.cache.keys().next().value;
|
|
1659
|
+
if (firstKey !== void 0) this.cache.delete(firstKey);
|
|
1660
|
+
}
|
|
1661
|
+
this.cache.set(key, value);
|
|
1662
|
+
}
|
|
1663
|
+
clear() {
|
|
1664
|
+
this.cache.clear();
|
|
1665
|
+
}
|
|
1666
|
+
};
|
|
1667
|
+
/**
|
|
1590
1668
|
* Handles token validation, normalization, and instance name generation.
|
|
1591
1669
|
*
|
|
1592
1670
|
* Provides utilities for resolving tokens to their underlying InjectionToken,
|
|
1593
1671
|
* validating arguments against schemas, and generating unique instance identifiers.
|
|
1594
1672
|
*/ var TokenProcessor = class {
|
|
1595
1673
|
logger;
|
|
1674
|
+
instanceNameCache = new InstanceNameCache();
|
|
1596
1675
|
constructor(logger = null) {
|
|
1597
1676
|
this.logger = logger;
|
|
1598
1677
|
}
|
|
@@ -1651,10 +1730,16 @@ const provideFactoryContext = defaultInjectors.provideFactoryContext;
|
|
|
1651
1730
|
}
|
|
1652
1731
|
/**
|
|
1653
1732
|
* Generates a unique instance name based on token and arguments.
|
|
1733
|
+
* Results are cached using an LRU cache for performance.
|
|
1654
1734
|
*/ generateInstanceName(token, args) {
|
|
1655
1735
|
if (!args) return token.toString();
|
|
1656
|
-
const
|
|
1657
|
-
|
|
1736
|
+
const tokenStr = token.toString();
|
|
1737
|
+
const cacheKey = `${tokenStr}:${JSON.stringify(args)}`;
|
|
1738
|
+
const cached = this.instanceNameCache.get(cacheKey);
|
|
1739
|
+
if (cached !== void 0) return cached;
|
|
1740
|
+
const result = `${tokenStr}:${Object.entries(args).sort(([keyA], [keyB]) => keyA.localeCompare(keyB)).map(([key, value]) => `${key}=${this.formatArgValue(value)}`).join(",").replaceAll(/"/g, "").replaceAll(/:/g, "=")}`;
|
|
1741
|
+
this.instanceNameCache.set(cacheKey, result);
|
|
1742
|
+
return result;
|
|
1658
1743
|
}
|
|
1659
1744
|
/**
|
|
1660
1745
|
* Formats a single argument value for instance name generation.
|
|
@@ -1796,7 +1881,7 @@ const provideFactoryContext = defaultInjectors.provideFactoryContext;
|
|
|
1796
1881
|
return this.tokenProcessor.generateInstanceName(token, args);
|
|
1797
1882
|
}
|
|
1798
1883
|
};
|
|
1799
|
-
function applyDecs2203RFactory$
|
|
1884
|
+
function applyDecs2203RFactory$5() {
|
|
1800
1885
|
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
1801
1886
|
return function addInitializer(initializer) {
|
|
1802
1887
|
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
@@ -2070,18 +2155,18 @@ function applyDecs2203RFactory$1$1() {
|
|
|
2070
2155
|
};
|
|
2071
2156
|
};
|
|
2072
2157
|
}
|
|
2073
|
-
function _apply_decs_2203_r$
|
|
2074
|
-
return (_apply_decs_2203_r$
|
|
2158
|
+
function _apply_decs_2203_r$5(targetClass, memberDecs, classDecs, parentClass) {
|
|
2159
|
+
return (_apply_decs_2203_r$5 = applyDecs2203RFactory$5())(targetClass, memberDecs, classDecs, parentClass);
|
|
2075
2160
|
}
|
|
2076
|
-
var _dec$
|
|
2077
|
-
let _Container
|
|
2078
|
-
_dec$
|
|
2161
|
+
var _dec$2, _initClass$2;
|
|
2162
|
+
let _Container;
|
|
2163
|
+
_dec$2 = Injectable$1();
|
|
2079
2164
|
(class {
|
|
2080
2165
|
registry;
|
|
2081
2166
|
logger;
|
|
2082
2167
|
injectors;
|
|
2083
2168
|
static {
|
|
2084
|
-
({c: [_Container
|
|
2169
|
+
({c: [_Container, _initClass$2]} = _apply_decs_2203_r$5(this, [], [_dec$2]));
|
|
2085
2170
|
}
|
|
2086
2171
|
constructor(registry = globalRegistry, logger = null, injectors = defaultInjectors) {
|
|
2087
2172
|
this.registry = registry;
|
|
@@ -2093,7 +2178,7 @@ _dec$1$1 = Injectable$1();
|
|
|
2093
2178
|
serviceLocator;
|
|
2094
2179
|
activeRequestIds = /* @__PURE__ */ new Set();
|
|
2095
2180
|
registerSelf() {
|
|
2096
|
-
const token = getInjectableToken(_Container
|
|
2181
|
+
const token = getInjectableToken(_Container);
|
|
2097
2182
|
const instanceName = this.serviceLocator.getInstanceIdentifier(token);
|
|
2098
2183
|
this.serviceLocator.getManager().storeCreatedHolder(instanceName, this, InjectableType.Class, InjectableScope.Singleton);
|
|
2099
2184
|
}
|
|
@@ -2210,341 +2295,6 @@ _dec$1$1 = Injectable$1();
|
|
|
2210
2295
|
*/ clear() {
|
|
2211
2296
|
return this.serviceLocator.clearAll();
|
|
2212
2297
|
}
|
|
2213
|
-
static {
|
|
2214
|
-
_initClass$1$1();
|
|
2215
|
-
}
|
|
2216
|
-
});
|
|
2217
|
-
function applyDecs2203RFactory$5() {
|
|
2218
|
-
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
2219
|
-
return function addInitializer(initializer) {
|
|
2220
|
-
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
2221
|
-
assertCallable(initializer, "An initializer");
|
|
2222
|
-
initializers.push(initializer);
|
|
2223
|
-
};
|
|
2224
|
-
}
|
|
2225
|
-
function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
|
|
2226
|
-
var kindStr;
|
|
2227
|
-
switch (kind) {
|
|
2228
|
-
case 1:
|
|
2229
|
-
kindStr = "accessor";
|
|
2230
|
-
break;
|
|
2231
|
-
case 2:
|
|
2232
|
-
kindStr = "method";
|
|
2233
|
-
break;
|
|
2234
|
-
case 3:
|
|
2235
|
-
kindStr = "getter";
|
|
2236
|
-
break;
|
|
2237
|
-
case 4:
|
|
2238
|
-
kindStr = "setter";
|
|
2239
|
-
break;
|
|
2240
|
-
default: kindStr = "field";
|
|
2241
|
-
}
|
|
2242
|
-
var ctx = {
|
|
2243
|
-
kind: kindStr,
|
|
2244
|
-
name: isPrivate ? "#" + name : name,
|
|
2245
|
-
static: isStatic,
|
|
2246
|
-
private: isPrivate,
|
|
2247
|
-
metadata
|
|
2248
|
-
};
|
|
2249
|
-
var decoratorFinishedRef = { v: false };
|
|
2250
|
-
ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
|
|
2251
|
-
var get, set;
|
|
2252
|
-
if (kind === 0) if (isPrivate) {
|
|
2253
|
-
get = desc.get;
|
|
2254
|
-
set = desc.set;
|
|
2255
|
-
} else {
|
|
2256
|
-
get = function() {
|
|
2257
|
-
return this[name];
|
|
2258
|
-
};
|
|
2259
|
-
set = function(v) {
|
|
2260
|
-
this[name] = v;
|
|
2261
|
-
};
|
|
2262
|
-
}
|
|
2263
|
-
else if (kind === 2) get = function() {
|
|
2264
|
-
return desc.value;
|
|
2265
|
-
};
|
|
2266
|
-
else {
|
|
2267
|
-
if (kind === 1 || kind === 3) get = function() {
|
|
2268
|
-
return desc.get.call(this);
|
|
2269
|
-
};
|
|
2270
|
-
if (kind === 1 || kind === 4) set = function(v) {
|
|
2271
|
-
desc.set.call(this, v);
|
|
2272
|
-
};
|
|
2273
|
-
}
|
|
2274
|
-
ctx.access = get && set ? {
|
|
2275
|
-
get,
|
|
2276
|
-
set
|
|
2277
|
-
} : get ? { get } : { set };
|
|
2278
|
-
try {
|
|
2279
|
-
return dec(value, ctx);
|
|
2280
|
-
} finally {
|
|
2281
|
-
decoratorFinishedRef.v = true;
|
|
2282
|
-
}
|
|
2283
|
-
}
|
|
2284
|
-
function assertNotFinished(decoratorFinishedRef, fnName) {
|
|
2285
|
-
if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
|
|
2286
|
-
}
|
|
2287
|
-
function assertCallable(fn, hint) {
|
|
2288
|
-
if (typeof fn !== "function") throw new TypeError(hint + " must be a function");
|
|
2289
|
-
}
|
|
2290
|
-
function assertValidReturnValue(kind, value) {
|
|
2291
|
-
var type = typeof value;
|
|
2292
|
-
if (kind === 1) {
|
|
2293
|
-
if (type !== "object" || value === null) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
2294
|
-
if (value.get !== void 0) assertCallable(value.get, "accessor.get");
|
|
2295
|
-
if (value.set !== void 0) assertCallable(value.set, "accessor.set");
|
|
2296
|
-
if (value.init !== void 0) assertCallable(value.init, "accessor.init");
|
|
2297
|
-
} else if (type !== "function") {
|
|
2298
|
-
var hint;
|
|
2299
|
-
if (kind === 0) hint = "field";
|
|
2300
|
-
else if (kind === 10) hint = "class";
|
|
2301
|
-
else hint = "method";
|
|
2302
|
-
throw new TypeError(hint + " decorators must return a function or void 0");
|
|
2303
|
-
}
|
|
2304
|
-
}
|
|
2305
|
-
function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
|
|
2306
|
-
var decs = decInfo[0];
|
|
2307
|
-
var desc, init, value;
|
|
2308
|
-
if (isPrivate) if (kind === 0 || kind === 1) desc = {
|
|
2309
|
-
get: decInfo[3],
|
|
2310
|
-
set: decInfo[4]
|
|
2311
|
-
};
|
|
2312
|
-
else if (kind === 3) desc = { get: decInfo[3] };
|
|
2313
|
-
else if (kind === 4) desc = { set: decInfo[3] };
|
|
2314
|
-
else desc = { value: decInfo[3] };
|
|
2315
|
-
else if (kind !== 0) desc = Object.getOwnPropertyDescriptor(base, name);
|
|
2316
|
-
if (kind === 1) value = {
|
|
2317
|
-
get: desc.get,
|
|
2318
|
-
set: desc.set
|
|
2319
|
-
};
|
|
2320
|
-
else if (kind === 2) value = desc.value;
|
|
2321
|
-
else if (kind === 3) value = desc.get;
|
|
2322
|
-
else if (kind === 4) value = desc.set;
|
|
2323
|
-
var newValue, get, set;
|
|
2324
|
-
if (typeof decs === "function") {
|
|
2325
|
-
newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
2326
|
-
if (newValue !== void 0) {
|
|
2327
|
-
assertValidReturnValue(kind, newValue);
|
|
2328
|
-
if (kind === 0) init = newValue;
|
|
2329
|
-
else if (kind === 1) {
|
|
2330
|
-
init = newValue.init;
|
|
2331
|
-
get = newValue.get || value.get;
|
|
2332
|
-
set = newValue.set || value.set;
|
|
2333
|
-
value = {
|
|
2334
|
-
get,
|
|
2335
|
-
set
|
|
2336
|
-
};
|
|
2337
|
-
} else value = newValue;
|
|
2338
|
-
}
|
|
2339
|
-
} else for (var i = decs.length - 1; i >= 0; i--) {
|
|
2340
|
-
var dec = decs[i];
|
|
2341
|
-
newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
2342
|
-
if (newValue !== void 0) {
|
|
2343
|
-
assertValidReturnValue(kind, newValue);
|
|
2344
|
-
var newInit;
|
|
2345
|
-
if (kind === 0) newInit = newValue;
|
|
2346
|
-
else if (kind === 1) {
|
|
2347
|
-
newInit = newValue.init;
|
|
2348
|
-
get = newValue.get || value.get;
|
|
2349
|
-
set = newValue.set || value.set;
|
|
2350
|
-
value = {
|
|
2351
|
-
get,
|
|
2352
|
-
set
|
|
2353
|
-
};
|
|
2354
|
-
} else value = newValue;
|
|
2355
|
-
if (newInit !== void 0) if (init === void 0) init = newInit;
|
|
2356
|
-
else if (typeof init === "function") init = [init, newInit];
|
|
2357
|
-
else init.push(newInit);
|
|
2358
|
-
}
|
|
2359
|
-
}
|
|
2360
|
-
if (kind === 0 || kind === 1) {
|
|
2361
|
-
if (init === void 0) init = function(instance, init$1) {
|
|
2362
|
-
return init$1;
|
|
2363
|
-
};
|
|
2364
|
-
else if (typeof init !== "function") {
|
|
2365
|
-
var ownInitializers = init;
|
|
2366
|
-
init = function(instance, init$1) {
|
|
2367
|
-
var value$1 = init$1;
|
|
2368
|
-
for (var i$1 = 0; i$1 < ownInitializers.length; i$1++) value$1 = ownInitializers[i$1].call(instance, value$1);
|
|
2369
|
-
return value$1;
|
|
2370
|
-
};
|
|
2371
|
-
} else {
|
|
2372
|
-
var originalInitializer = init;
|
|
2373
|
-
init = function(instance, init$1) {
|
|
2374
|
-
return originalInitializer.call(instance, init$1);
|
|
2375
|
-
};
|
|
2376
|
-
}
|
|
2377
|
-
ret.push(init);
|
|
2378
|
-
}
|
|
2379
|
-
if (kind !== 0) {
|
|
2380
|
-
if (kind === 1) {
|
|
2381
|
-
desc.get = value.get;
|
|
2382
|
-
desc.set = value.set;
|
|
2383
|
-
} else if (kind === 2) desc.value = value;
|
|
2384
|
-
else if (kind === 3) desc.get = value;
|
|
2385
|
-
else if (kind === 4) desc.set = value;
|
|
2386
|
-
if (isPrivate) if (kind === 1) {
|
|
2387
|
-
ret.push(function(instance, args) {
|
|
2388
|
-
return value.get.call(instance, args);
|
|
2389
|
-
});
|
|
2390
|
-
ret.push(function(instance, args) {
|
|
2391
|
-
return value.set.call(instance, args);
|
|
2392
|
-
});
|
|
2393
|
-
} else if (kind === 2) ret.push(value);
|
|
2394
|
-
else ret.push(function(instance, args) {
|
|
2395
|
-
return value.call(instance, args);
|
|
2396
|
-
});
|
|
2397
|
-
else Object.defineProperty(base, name, desc);
|
|
2398
|
-
}
|
|
2399
|
-
}
|
|
2400
|
-
function applyMemberDecs(Class, decInfos, metadata) {
|
|
2401
|
-
var ret = [];
|
|
2402
|
-
var protoInitializers;
|
|
2403
|
-
var staticInitializers;
|
|
2404
|
-
var existingProtoNonFields = /* @__PURE__ */ new Map();
|
|
2405
|
-
var existingStaticNonFields = /* @__PURE__ */ new Map();
|
|
2406
|
-
for (var i = 0; i < decInfos.length; i++) {
|
|
2407
|
-
var decInfo = decInfos[i];
|
|
2408
|
-
if (!Array.isArray(decInfo)) continue;
|
|
2409
|
-
var kind = decInfo[1];
|
|
2410
|
-
var name = decInfo[2];
|
|
2411
|
-
var isPrivate = decInfo.length > 3;
|
|
2412
|
-
var isStatic = kind >= 5;
|
|
2413
|
-
var base;
|
|
2414
|
-
var initializers;
|
|
2415
|
-
if (isStatic) {
|
|
2416
|
-
base = Class;
|
|
2417
|
-
kind = kind - 5;
|
|
2418
|
-
staticInitializers = staticInitializers || [];
|
|
2419
|
-
initializers = staticInitializers;
|
|
2420
|
-
} else {
|
|
2421
|
-
base = Class.prototype;
|
|
2422
|
-
protoInitializers = protoInitializers || [];
|
|
2423
|
-
initializers = protoInitializers;
|
|
2424
|
-
}
|
|
2425
|
-
if (kind !== 0 && !isPrivate) {
|
|
2426
|
-
var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
|
|
2427
|
-
var existingKind = existingNonFields.get(name) || 0;
|
|
2428
|
-
if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
|
|
2429
|
-
else if (!existingKind && kind > 2) existingNonFields.set(name, kind);
|
|
2430
|
-
else existingNonFields.set(name, true);
|
|
2431
|
-
}
|
|
2432
|
-
applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
|
|
2433
|
-
}
|
|
2434
|
-
pushInitializers(ret, protoInitializers);
|
|
2435
|
-
pushInitializers(ret, staticInitializers);
|
|
2436
|
-
return ret;
|
|
2437
|
-
}
|
|
2438
|
-
function pushInitializers(ret, initializers) {
|
|
2439
|
-
if (initializers) ret.push(function(instance) {
|
|
2440
|
-
for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
|
|
2441
|
-
return instance;
|
|
2442
|
-
});
|
|
2443
|
-
}
|
|
2444
|
-
function applyClassDecs(targetClass, classDecs, metadata) {
|
|
2445
|
-
if (classDecs.length > 0) {
|
|
2446
|
-
var initializers = [];
|
|
2447
|
-
var newClass = targetClass;
|
|
2448
|
-
var name = targetClass.name;
|
|
2449
|
-
for (var i = classDecs.length - 1; i >= 0; i--) {
|
|
2450
|
-
var decoratorFinishedRef = { v: false };
|
|
2451
|
-
try {
|
|
2452
|
-
var nextNewClass = classDecs[i](newClass, {
|
|
2453
|
-
kind: "class",
|
|
2454
|
-
name,
|
|
2455
|
-
addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
|
|
2456
|
-
metadata
|
|
2457
|
-
});
|
|
2458
|
-
} finally {
|
|
2459
|
-
decoratorFinishedRef.v = true;
|
|
2460
|
-
}
|
|
2461
|
-
if (nextNewClass !== void 0) {
|
|
2462
|
-
assertValidReturnValue(10, nextNewClass);
|
|
2463
|
-
newClass = nextNewClass;
|
|
2464
|
-
}
|
|
2465
|
-
}
|
|
2466
|
-
return [defineMetadata(newClass, metadata), function() {
|
|
2467
|
-
for (var i$1 = 0; i$1 < initializers.length; i$1++) initializers[i$1].call(newClass);
|
|
2468
|
-
}];
|
|
2469
|
-
}
|
|
2470
|
-
}
|
|
2471
|
-
function defineMetadata(Class, metadata) {
|
|
2472
|
-
return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
|
|
2473
|
-
configurable: true,
|
|
2474
|
-
enumerable: true,
|
|
2475
|
-
value: metadata
|
|
2476
|
-
});
|
|
2477
|
-
}
|
|
2478
|
-
return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
|
|
2479
|
-
if (parentClass !== void 0) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
2480
|
-
var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
|
|
2481
|
-
var e = applyMemberDecs(targetClass, memberDecs, metadata);
|
|
2482
|
-
if (!classDecs.length) defineMetadata(targetClass, metadata);
|
|
2483
|
-
return {
|
|
2484
|
-
e,
|
|
2485
|
-
get c() {
|
|
2486
|
-
return applyClassDecs(targetClass, classDecs, metadata);
|
|
2487
|
-
}
|
|
2488
|
-
};
|
|
2489
|
-
};
|
|
2490
|
-
}
|
|
2491
|
-
function _apply_decs_2203_r$5(targetClass, memberDecs, classDecs, parentClass) {
|
|
2492
|
-
return (_apply_decs_2203_r$5 = applyDecs2203RFactory$5())(targetClass, memberDecs, classDecs, parentClass);
|
|
2493
|
-
}
|
|
2494
|
-
var _dec$2, _initClass$2, _Container;
|
|
2495
|
-
/**
|
|
2496
|
-
* A binding builder for the TestContainer that allows chaining binding operations.
|
|
2497
|
-
*/ var TestBindingBuilder = class {
|
|
2498
|
-
container;
|
|
2499
|
-
token;
|
|
2500
|
-
constructor(container, token) {
|
|
2501
|
-
this.container = container;
|
|
2502
|
-
this.token = token;
|
|
2503
|
-
}
|
|
2504
|
-
/**
|
|
2505
|
-
* Binds the token to a specific value.
|
|
2506
|
-
* This is useful for testing with mock values or constants.
|
|
2507
|
-
* @param value The value to bind to the token
|
|
2508
|
-
*/ toValue(value) {
|
|
2509
|
-
const instanceName = this.container.getServiceLocator().getInstanceIdentifier(this.token);
|
|
2510
|
-
this.container.getServiceLocator().getManager().storeCreatedHolder(instanceName, value, InjectableType.Class, InjectableScope.Singleton);
|
|
2511
|
-
return this.container;
|
|
2512
|
-
}
|
|
2513
|
-
/**
|
|
2514
|
-
* Binds the token to a class constructor.
|
|
2515
|
-
* @param target The class constructor to bind to
|
|
2516
|
-
*/ toClass(target) {
|
|
2517
|
-
this.container["registry"].set(this.token, InjectableScope.Singleton, target, InjectableType.Class);
|
|
2518
|
-
return this.container;
|
|
2519
|
-
}
|
|
2520
|
-
};
|
|
2521
|
-
let _TestContainer;
|
|
2522
|
-
_dec$2 = Injectable$1();
|
|
2523
|
-
(class extends (_Container = _Container$1) {
|
|
2524
|
-
static {
|
|
2525
|
-
({c: [_TestContainer, _initClass$2]} = _apply_decs_2203_r$5(this, [], [_dec$2], _Container));
|
|
2526
|
-
}
|
|
2527
|
-
constructor(registry = globalRegistry, logger = null, injectors = void 0) {
|
|
2528
|
-
super(registry, logger, injectors);
|
|
2529
|
-
}
|
|
2530
|
-
bind(token) {
|
|
2531
|
-
let realToken = token;
|
|
2532
|
-
if (typeof token === "function") realToken = getInjectableToken(token);
|
|
2533
|
-
return new TestBindingBuilder(this, realToken);
|
|
2534
|
-
}
|
|
2535
|
-
bindValue(token, value) {
|
|
2536
|
-
return this.bind(token).toValue(value);
|
|
2537
|
-
}
|
|
2538
|
-
bindClass(token, target) {
|
|
2539
|
-
return this.bind(token).toClass(target);
|
|
2540
|
-
}
|
|
2541
|
-
/**
|
|
2542
|
-
* Creates a new TestContainer instance with the same configuration.
|
|
2543
|
-
* This is useful for creating isolated test containers.
|
|
2544
|
-
* @returns A new TestContainer instance
|
|
2545
|
-
*/ createChild() {
|
|
2546
|
-
return new _TestContainer(this.registry, this.logger, this.injectors);
|
|
2547
|
-
}
|
|
2548
2298
|
static {
|
|
2549
2299
|
_initClass$2();
|
|
2550
2300
|
}
|