@fluojs/di 1.0.0-beta.3 → 1.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ko.md +1 -0
- package/README.md +1 -0
- package/dist/container.d.ts +19 -3
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +108 -24
- package/package.json +1 -1
package/README.ko.md
CHANGED
|
@@ -145,6 +145,7 @@ const service = await container.resolve(DataService);
|
|
|
145
145
|
| `resolve<T>(token)` | 토큰을 인스턴스로 비동기 해석합니다. |
|
|
146
146
|
| `createRequestScope()` | 요청 스코프 의존성을 위한 자식 컨테이너를 생성합니다. |
|
|
147
147
|
| `has(token)` | 컨테이너나 부모에 토큰이 등록되어 있는지 확인합니다. |
|
|
148
|
+
| `hasRequestScopedDependency(token)` | 토큰 해석 시 provider 그래프에 request-scoped 의존성이나 순환이 있어 request-scope 컨테이너가 필요할 수 있는지 확인합니다. |
|
|
148
149
|
|
|
149
150
|
## 관련 패키지
|
|
150
151
|
|
package/README.md
CHANGED
|
@@ -145,6 +145,7 @@ Ensure all required providers are registered in the container. If you use `creat
|
|
|
145
145
|
| `resolve<T>(token)` | Asynchronously resolves a token to an instance. |
|
|
146
146
|
| `createRequestScope()` | Creates a child container for request-scoped dependencies. |
|
|
147
147
|
| `has(token)` | Checks if a token is registered in the container or its parents. |
|
|
148
|
+
| `hasRequestScopedDependency(token)` | Checks whether resolving a token may require a request-scope container because its provider graph contains request-scoped dependencies or is cyclic. |
|
|
148
149
|
|
|
149
150
|
## Related Packages
|
|
150
151
|
|
package/dist/container.d.ts
CHANGED
|
@@ -9,16 +9,17 @@ export declare class Container {
|
|
|
9
9
|
private readonly registrations;
|
|
10
10
|
private readonly multiRegistrations;
|
|
11
11
|
private readonly multiOverriddenTokens;
|
|
12
|
-
private
|
|
13
|
-
private
|
|
12
|
+
private requestCache;
|
|
13
|
+
private multiRequestCache;
|
|
14
14
|
private readonly multiSingletonCache;
|
|
15
15
|
private readonly staleDisposalTasks;
|
|
16
16
|
private readonly staleDisposalErrors;
|
|
17
17
|
private readonly singletonCache;
|
|
18
18
|
private readonly forwardRefTokenCache;
|
|
19
|
-
private
|
|
19
|
+
private childScopes;
|
|
20
20
|
private disposePromise;
|
|
21
21
|
private disposed;
|
|
22
|
+
private trackedByRoot;
|
|
22
23
|
constructor(parent?: Container | undefined, requestScopeEnabled?: boolean, singletonCache?: Map<Token, Promise<unknown>>);
|
|
23
24
|
/**
|
|
24
25
|
* Registers providers in the current container scope.
|
|
@@ -53,6 +54,13 @@ export declare class Container {
|
|
|
53
54
|
* @returns `true` when a single or multi provider exists for the token.
|
|
54
55
|
*/
|
|
55
56
|
has(token: Token): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Returns whether resolving a token may require a request-scope container.
|
|
59
|
+
*
|
|
60
|
+
* @param token Provider token to inspect through aliases, multi providers, and dependencies.
|
|
61
|
+
* @returns `true` when the provider graph contains request-scoped dependencies or is cyclic.
|
|
62
|
+
*/
|
|
63
|
+
hasRequestScopedDependency(token: Token): boolean;
|
|
56
64
|
/**
|
|
57
65
|
* Creates a child request-scope container that shares root singleton cache.
|
|
58
66
|
*
|
|
@@ -79,6 +87,7 @@ export declare class Container {
|
|
|
79
87
|
*/
|
|
80
88
|
dispose(): Promise<void>;
|
|
81
89
|
private disposeAll;
|
|
90
|
+
private isDisposedInHierarchy;
|
|
82
91
|
private hasMulti;
|
|
83
92
|
private assertNoRegistrationConflict;
|
|
84
93
|
private hasAncestorSingleRegistration;
|
|
@@ -86,6 +95,10 @@ export declare class Container {
|
|
|
86
95
|
private hasAncestorMultiRegistration;
|
|
87
96
|
private hasMultiRegistration;
|
|
88
97
|
private collectMultiProviders;
|
|
98
|
+
private providerGraphRequiresRequestScope;
|
|
99
|
+
private unregisteredClassRequiresRequestScope;
|
|
100
|
+
private normalizedProviderRequiresRequestScope;
|
|
101
|
+
private dependencyEntryRequiresRequestScope;
|
|
89
102
|
private resolveWithChain;
|
|
90
103
|
private resolveFromRegisteredProviders;
|
|
91
104
|
private requireProvider;
|
|
@@ -101,6 +114,9 @@ export declare class Container {
|
|
|
101
114
|
private resolveDepToken;
|
|
102
115
|
private withTokenInChain;
|
|
103
116
|
private root;
|
|
117
|
+
private ensureTrackedRequestScope;
|
|
118
|
+
private requestCacheForWrite;
|
|
119
|
+
private multiRequestCacheForWrite;
|
|
104
120
|
private lookupProvider;
|
|
105
121
|
/**
|
|
106
122
|
* Resolve the cache map that should hold the instance for `provider`.
|
package/dist/container.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../src/container.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,KAAK,KAAK,EAAE,MAAM,cAAc,CAAC;AAW3E,OAAO,KAAK,EASV,QAAQ,EAET,MAAM,YAAY,CAAC;AAuIpB;;GAEG;AACH,qBAAa,SAAS;
|
|
1
|
+
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../src/container.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,KAAK,KAAK,EAAE,MAAM,cAAc,CAAC;AAW3E,OAAO,KAAK,EASV,QAAQ,EAET,MAAM,YAAY,CAAC;AAuIpB;;GAEG;AACH,qBAAa,SAAS;IAiBlB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;IACxB,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IAjBtC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAwC;IACtE,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAA0C;IAC7E,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAoB;IAC1D,OAAO,CAAC,YAAY,CAA2C;IAC/D,OAAO,CAAC,iBAAiB,CAAwD;IACjF,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAmD;IACvF,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAA4B;IAC/D,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAiB;IACrD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA+B;IAC9D,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAsC;IAC3E,OAAO,CAAC,WAAW,CAA6B;IAChD,OAAO,CAAC,cAAc,CAA4B;IAClD,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,aAAa,CAAS;gBAGX,MAAM,CAAC,EAAE,SAAS,YAAA,EAClB,mBAAmB,UAAQ,EAC5C,cAAc,CAAC,EAAE,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAK/C;;;;;;;;;OASG;IACH,QAAQ,CAAC,GAAG,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAI;IAyCxC;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,GAAG,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAI;IA6BxC;;;;;OAKG;IACH,GAAG,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO;IAI1B;;;;;OAKG;IACH,0BAA0B,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO;IAIjD;;;;;OAKG;IACH,kBAAkB,IAAI,SAAS;IAW/B;;;;;;;;;OASG;IACG,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAW7C;;;;;OAKG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;YAiBhB,UAAU;IAiBxB,OAAO,CAAC,qBAAqB;IAQ7B,OAAO,CAAC,QAAQ;IAMhB,OAAO,CAAC,4BAA4B;IAsBpC,OAAO,CAAC,6BAA6B;IAIrC,OAAO,CAAC,qBAAqB;IAM7B,OAAO,CAAC,4BAA4B;IAIpC,OAAO,CAAC,oBAAoB;IAM5B,OAAO,CAAC,qBAAqB;IAgB7B,OAAO,CAAC,iCAAiC;IAyBzC,OAAO,CAAC,qCAAqC;IAc7C,OAAO,CAAC,sCAAsC;IAY9C,OAAO,CAAC,mCAAmC;YAa7B,gBAAgB;YAehB,8BAA8B;IAqC5C,OAAO,CAAC,eAAe;YAgBT,kBAAkB;IAMhC,OAAO,CAAC,mCAAmC;YAoB7B,6BAA6B;YAc7B,4BAA4B;IA4B1C,OAAO,CAAC,6BAA6B;YAQvB,gCAAgC;IAuB9C,OAAO,CAAC,kCAAkC;IAY1C,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,kCAAkC;YAI5B,eAAe;YAwBf,gBAAgB;IAiB9B,OAAO,CAAC,IAAI;IAIZ,OAAO,CAAC,yBAAyB;IAWjC,OAAO,CAAC,oBAAoB;IAM5B,OAAO,CAAC,yBAAyB;IAMjC,OAAO,CAAC,cAAc;IAUtB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,QAAQ;IAuBhB,OAAO,CAAC,aAAa;IAuBrB,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,oBAAoB;YAkBd,YAAY;YAaZ,0BAA0B;YA0B1B,8BAA8B;IAc5C,OAAO,CAAC,mBAAmB;YAWb,yBAAyB;IAMvC,OAAO,CAAC,qBAAqB;IAoB7B,OAAO,CAAC,mBAAmB;IAU3B,OAAO,CAAC,YAAY;YAIN,WAAW;IA+BzB,OAAO,CAAC,+BAA+B;IAsBvC,OAAO,CAAC,wBAAwB;IA6BhC,OAAO,CAAC,8BAA8B;IAYtC,OAAO,CAAC,sBAAsB;YAUhB,mBAAmB;IAUjC,OAAO,CAAC,qBAAqB;CAmD9B"}
|
package/dist/container.js
CHANGED
|
@@ -119,16 +119,17 @@ export class Container {
|
|
|
119
119
|
registrations = new Map();
|
|
120
120
|
multiRegistrations = new Map();
|
|
121
121
|
multiOverriddenTokens = new Set();
|
|
122
|
-
requestCache
|
|
123
|
-
multiRequestCache
|
|
122
|
+
requestCache;
|
|
123
|
+
multiRequestCache;
|
|
124
124
|
multiSingletonCache = new Map();
|
|
125
125
|
staleDisposalTasks = new Set();
|
|
126
126
|
staleDisposalErrors = [];
|
|
127
127
|
singletonCache;
|
|
128
128
|
forwardRefTokenCache = new WeakMap();
|
|
129
|
-
childScopes
|
|
129
|
+
childScopes;
|
|
130
130
|
disposePromise;
|
|
131
131
|
disposed = false;
|
|
132
|
+
trackedByRoot = false;
|
|
132
133
|
constructor(parent, requestScopeEnabled = false, singletonCache) {
|
|
133
134
|
this.parent = parent;
|
|
134
135
|
this.requestScopeEnabled = requestScopeEnabled;
|
|
@@ -146,7 +147,7 @@ export class Container {
|
|
|
146
147
|
* @throws {InvalidProviderError} When a provider definition is structurally invalid.
|
|
147
148
|
*/
|
|
148
149
|
register(...providers) {
|
|
149
|
-
if (this.
|
|
150
|
+
if (this.isDisposedInHierarchy()) {
|
|
150
151
|
throw new ContainerResolutionError('Container has been disposed and can no longer register providers.', {
|
|
151
152
|
hint: 'Ensure providers are registered before calling container.dispose().'
|
|
152
153
|
});
|
|
@@ -190,7 +191,7 @@ export class Container {
|
|
|
190
191
|
* @throws {InvalidProviderError} When a provider definition is structurally invalid.
|
|
191
192
|
*/
|
|
192
193
|
override(...providers) {
|
|
193
|
-
if (this.
|
|
194
|
+
if (this.isDisposedInHierarchy()) {
|
|
194
195
|
throw new ContainerResolutionError('Container has been disposed and can no longer override providers.', {
|
|
195
196
|
hint: 'Ensure overrides are applied before calling container.dispose().'
|
|
196
197
|
});
|
|
@@ -222,6 +223,16 @@ export class Container {
|
|
|
222
223
|
return this.lookupProvider(token) !== undefined || this.hasMulti(token);
|
|
223
224
|
}
|
|
224
225
|
|
|
226
|
+
/**
|
|
227
|
+
* Returns whether resolving a token may require a request-scope container.
|
|
228
|
+
*
|
|
229
|
+
* @param token Provider token to inspect through aliases, multi providers, and dependencies.
|
|
230
|
+
* @returns `true` when the provider graph contains request-scoped dependencies or is cyclic.
|
|
231
|
+
*/
|
|
232
|
+
hasRequestScopedDependency(token) {
|
|
233
|
+
return this.providerGraphRequiresRequestScope(token, new Set());
|
|
234
|
+
}
|
|
235
|
+
|
|
225
236
|
/**
|
|
226
237
|
* Creates a child request-scope container that shares root singleton cache.
|
|
227
238
|
*
|
|
@@ -229,14 +240,12 @@ export class Container {
|
|
|
229
240
|
* @throws {ContainerResolutionError} When called after the container was disposed.
|
|
230
241
|
*/
|
|
231
242
|
createRequestScope() {
|
|
232
|
-
if (this.
|
|
243
|
+
if (this.isDisposedInHierarchy()) {
|
|
233
244
|
throw new ContainerResolutionError('Container has been disposed and can no longer create request scopes.', {
|
|
234
245
|
hint: 'Create request scopes before calling container.dispose().'
|
|
235
246
|
});
|
|
236
247
|
}
|
|
237
|
-
|
|
238
|
-
this.root().childScopes.add(child);
|
|
239
|
-
return child;
|
|
248
|
+
return new Container(this, true, this.root().singletonCache);
|
|
240
249
|
}
|
|
241
250
|
|
|
242
251
|
/**
|
|
@@ -250,7 +259,7 @@ export class Container {
|
|
|
250
259
|
* @throws {CircularDependencyError} When provider dependency resolution detects a cycle.
|
|
251
260
|
*/
|
|
252
261
|
async resolve(token) {
|
|
253
|
-
if (this.
|
|
262
|
+
if (this.isDisposedInHierarchy()) {
|
|
254
263
|
throw new ContainerResolutionError('Container has been disposed and can no longer resolve providers.', {
|
|
255
264
|
token,
|
|
256
265
|
hint: 'Ensure all resolves complete before calling container.dispose().'
|
|
@@ -282,17 +291,24 @@ export class Container {
|
|
|
282
291
|
async disposeAll() {
|
|
283
292
|
try {
|
|
284
293
|
// Dispose all live request-scope children first (root only)
|
|
285
|
-
if (!this.parent && this.childScopes.size > 0) {
|
|
294
|
+
if (!this.parent && this.childScopes && this.childScopes.size > 0) {
|
|
286
295
|
await Promise.all(Array.from(this.childScopes).map(child => child.dispose()));
|
|
287
296
|
this.childScopes.clear();
|
|
288
297
|
}
|
|
289
298
|
await this.disposeCache(this.disposalCacheEntries());
|
|
290
299
|
} finally {
|
|
291
|
-
if (this.parent) {
|
|
292
|
-
this.root().childScopes
|
|
300
|
+
if (this.parent && this.trackedByRoot) {
|
|
301
|
+
this.root().childScopes?.delete(this);
|
|
302
|
+
this.trackedByRoot = false;
|
|
293
303
|
}
|
|
294
304
|
}
|
|
295
305
|
}
|
|
306
|
+
isDisposedInHierarchy() {
|
|
307
|
+
if (this.disposed) {
|
|
308
|
+
return true;
|
|
309
|
+
}
|
|
310
|
+
return this.parent?.isDisposedInHierarchy() ?? false;
|
|
311
|
+
}
|
|
296
312
|
hasMulti(token) {
|
|
297
313
|
if (this.multiRegistrations.has(token)) return true;
|
|
298
314
|
return this.parent?.hasMulti(token) ?? false;
|
|
@@ -339,6 +355,51 @@ export class Container {
|
|
|
339
355
|
}
|
|
340
356
|
return fromParent;
|
|
341
357
|
}
|
|
358
|
+
providerGraphRequiresRequestScope(token, visited) {
|
|
359
|
+
if (visited.has(token)) {
|
|
360
|
+
return true;
|
|
361
|
+
}
|
|
362
|
+
visited.add(token);
|
|
363
|
+
try {
|
|
364
|
+
const provider = this.lookupProvider(token);
|
|
365
|
+
const multiProviders = this.collectMultiProviders(token);
|
|
366
|
+
if (!provider && multiProviders.length === 0) {
|
|
367
|
+
return this.unregisteredClassRequiresRequestScope(token, visited);
|
|
368
|
+
}
|
|
369
|
+
if (provider && this.normalizedProviderRequiresRequestScope(provider, visited)) {
|
|
370
|
+
return true;
|
|
371
|
+
}
|
|
372
|
+
return multiProviders.some(multiProvider => this.normalizedProviderRequiresRequestScope(multiProvider, visited));
|
|
373
|
+
} finally {
|
|
374
|
+
visited.delete(token);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
unregisteredClassRequiresRequestScope(token, visited) {
|
|
378
|
+
if (typeof token !== 'function') {
|
|
379
|
+
return false;
|
|
380
|
+
}
|
|
381
|
+
const metadata = getClassDiMetadata(token);
|
|
382
|
+
if (metadata?.scope === Scope.REQUEST) {
|
|
383
|
+
return true;
|
|
384
|
+
}
|
|
385
|
+
return (metadata?.inject ?? []).some(depEntry => this.dependencyEntryRequiresRequestScope(depEntry, visited));
|
|
386
|
+
}
|
|
387
|
+
normalizedProviderRequiresRequestScope(provider, visited) {
|
|
388
|
+
if (provider.scope === Scope.REQUEST) {
|
|
389
|
+
return true;
|
|
390
|
+
}
|
|
391
|
+
if (provider.type === 'existing' && provider.useExisting !== undefined) {
|
|
392
|
+
return this.providerGraphRequiresRequestScope(provider.useExisting, visited);
|
|
393
|
+
}
|
|
394
|
+
return provider.inject.some(depEntry => this.dependencyEntryRequiresRequestScope(depEntry, visited));
|
|
395
|
+
}
|
|
396
|
+
dependencyEntryRequiresRequestScope(depEntry, visited) {
|
|
397
|
+
const depToken = this.resolveProviderDependencyToken(depEntry);
|
|
398
|
+
if (isOptionalToken(depEntry) && !this.has(depToken)) {
|
|
399
|
+
return false;
|
|
400
|
+
}
|
|
401
|
+
return this.providerGraphRequiresRequestScope(depToken, visited);
|
|
402
|
+
}
|
|
342
403
|
async resolveWithChain(token, chain, activeTokens, allowForwardRef = false) {
|
|
343
404
|
const cachedForwardRef = this.resolveForwardRefCircularDependency(token, chain, activeTokens, allowForwardRef);
|
|
344
405
|
if (cachedForwardRef !== undefined) {
|
|
@@ -478,6 +539,25 @@ export class Container {
|
|
|
478
539
|
root() {
|
|
479
540
|
return this.parent ? this.parent.root() : this;
|
|
480
541
|
}
|
|
542
|
+
ensureTrackedRequestScope() {
|
|
543
|
+
if (!this.requestScopeEnabled || !this.parent || this.trackedByRoot) {
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
const root = this.root();
|
|
547
|
+
root.childScopes ??= new Set();
|
|
548
|
+
root.childScopes.add(this);
|
|
549
|
+
this.trackedByRoot = true;
|
|
550
|
+
}
|
|
551
|
+
requestCacheForWrite() {
|
|
552
|
+
this.ensureTrackedRequestScope();
|
|
553
|
+
this.requestCache ??= new Map();
|
|
554
|
+
return this.requestCache;
|
|
555
|
+
}
|
|
556
|
+
multiRequestCacheForWrite() {
|
|
557
|
+
this.ensureTrackedRequestScope();
|
|
558
|
+
this.multiRequestCache ??= new Map();
|
|
559
|
+
return this.multiRequestCache;
|
|
560
|
+
}
|
|
481
561
|
lookupProvider(token) {
|
|
482
562
|
const local = this.registrations.get(token);
|
|
483
563
|
if (local) {
|
|
@@ -500,7 +580,7 @@ export class Container {
|
|
|
500
580
|
cacheFor(provider) {
|
|
501
581
|
if (provider.scope === Scope.DEFAULT) {
|
|
502
582
|
if (this.requestScopeEnabled && this.registrations.has(provider.provide)) {
|
|
503
|
-
return this.
|
|
583
|
+
return this.requestCacheForWrite();
|
|
504
584
|
}
|
|
505
585
|
return this.root().singletonCache;
|
|
506
586
|
}
|
|
@@ -511,12 +591,12 @@ export class Container {
|
|
|
511
591
|
hint: 'Wrap the resolve call inside a request-scoped child container created via container.createRequestScope().'
|
|
512
592
|
});
|
|
513
593
|
}
|
|
514
|
-
return this.
|
|
594
|
+
return this.requestCacheForWrite();
|
|
515
595
|
}
|
|
516
596
|
multiCacheFor(provider) {
|
|
517
597
|
if (provider.scope === Scope.DEFAULT) {
|
|
518
598
|
if (this.requestScopeEnabled && this.hasLocalMultiProvider(provider)) {
|
|
519
|
-
return this.
|
|
599
|
+
return this.multiRequestCacheForWrite();
|
|
520
600
|
}
|
|
521
601
|
return this.root().multiSingletonCache;
|
|
522
602
|
}
|
|
@@ -527,15 +607,15 @@ export class Container {
|
|
|
527
607
|
hint: 'Wrap the resolve call inside a request-scoped child container created via container.createRequestScope().'
|
|
528
608
|
});
|
|
529
609
|
}
|
|
530
|
-
return this.
|
|
610
|
+
return this.multiRequestCacheForWrite();
|
|
531
611
|
}
|
|
532
612
|
hasLocalMultiProvider(provider) {
|
|
533
613
|
return this.multiRegistrations.get(provider.provide)?.includes(provider) ?? false;
|
|
534
614
|
}
|
|
535
615
|
disposalCacheEntries() {
|
|
536
616
|
if (this.parent) {
|
|
537
|
-
const entries = Array.from(this.requestCache
|
|
538
|
-
for (const [provider, promise] of this.multiRequestCache
|
|
617
|
+
const entries = Array.from(this.requestCache?.entries() ?? []);
|
|
618
|
+
for (const [provider, promise] of this.multiRequestCache?.entries() ?? []) {
|
|
539
619
|
entries.push([provider, promise]);
|
|
540
620
|
}
|
|
541
621
|
return entries;
|
|
@@ -591,8 +671,8 @@ export class Container {
|
|
|
591
671
|
}
|
|
592
672
|
clearDisposalCaches() {
|
|
593
673
|
if (this.parent) {
|
|
594
|
-
this.requestCache
|
|
595
|
-
this.multiRequestCache
|
|
674
|
+
this.requestCache?.clear();
|
|
675
|
+
this.multiRequestCache?.clear();
|
|
596
676
|
return;
|
|
597
677
|
}
|
|
598
678
|
this.singletonCache.clear();
|
|
@@ -716,7 +796,7 @@ export class Container {
|
|
|
716
796
|
return deps;
|
|
717
797
|
}
|
|
718
798
|
invalidateCachedEntry(token, scope) {
|
|
719
|
-
if (this.requestCache
|
|
799
|
+
if (this.requestCache?.has(token)) {
|
|
720
800
|
const cached = this.requestCache.get(token);
|
|
721
801
|
if (cached) {
|
|
722
802
|
this.scheduleStaleDisposal(cached);
|
|
@@ -742,12 +822,16 @@ export class Container {
|
|
|
742
822
|
this.multiSingletonCache.delete(provider);
|
|
743
823
|
}
|
|
744
824
|
}
|
|
745
|
-
|
|
825
|
+
const multiRequestCache = this.multiRequestCache;
|
|
826
|
+
if (!multiRequestCache) {
|
|
827
|
+
return;
|
|
828
|
+
}
|
|
829
|
+
for (const [provider, cached] of multiRequestCache.entries()) {
|
|
746
830
|
if (provider.provide !== token) {
|
|
747
831
|
continue;
|
|
748
832
|
}
|
|
749
833
|
this.scheduleStaleDisposal(cached);
|
|
750
|
-
|
|
834
|
+
multiRequestCache.delete(provider);
|
|
751
835
|
}
|
|
752
836
|
}
|
|
753
837
|
}
|