(
moduleRef: Module,
name: InjectionToken,
wrapper: InstanceWrapper,
moduleRegistry: Set<string> = new Set<string>(),
resolutionContext: ResolutionContext = { contextId: STATIC_CONTEXT },
keyOrIndex?: symbol | string | number,
isTraversing?: boolean,
)
| 659 | } |
| 660 | |
| 661 | public async lookupComponentInImports( |
| 662 | moduleRef: Module, |
| 663 | name: InjectionToken, |
| 664 | wrapper: InstanceWrapper, |
| 665 | moduleRegistry: Set<string> = new Set<string>(), |
| 666 | resolutionContext: ResolutionContext = { contextId: STATIC_CONTEXT }, |
| 667 | keyOrIndex?: symbol | string | number, |
| 668 | isTraversing?: boolean, |
| 669 | ): Promise<any> { |
| 670 | let instanceWrapperRef: InstanceWrapper | null = null; |
| 671 | const imports = moduleRef.imports || new Set<Module>(); |
| 672 | const identity = (item: any) => item; |
| 673 | |
| 674 | let children = [...imports.values()].filter(identity); |
| 675 | if (isTraversing) { |
| 676 | const contextModuleExports = moduleRef.exports; |
| 677 | children = children.filter(child => |
| 678 | contextModuleExports.has(child.metatype), |
| 679 | ); |
| 680 | } |
| 681 | for (const relatedModule of children) { |
| 682 | if (moduleRegistry.has(relatedModule.id)) { |
| 683 | continue; |
| 684 | } |
| 685 | this.printLookingForProviderLog(name, relatedModule); |
| 686 | moduleRegistry.add(relatedModule.id); |
| 687 | |
| 688 | const { providers, exports } = relatedModule; |
| 689 | if (!exports.has(name) || !providers.has(name)) { |
| 690 | const instanceRef = await this.lookupComponentInImports( |
| 691 | relatedModule, |
| 692 | name, |
| 693 | wrapper, |
| 694 | moduleRegistry, |
| 695 | resolutionContext, |
| 696 | keyOrIndex, |
| 697 | true, |
| 698 | ); |
| 699 | if (instanceRef) { |
| 700 | this.addDependencyMetadata(keyOrIndex!, wrapper, instanceRef); |
| 701 | return instanceRef; |
| 702 | } |
| 703 | continue; |
| 704 | } |
| 705 | this.printFoundInModuleLog(name, relatedModule); |
| 706 | instanceWrapperRef = providers.get(name)!; |
| 707 | this.addDependencyMetadata(keyOrIndex!, wrapper, instanceWrapperRef); |
| 708 | |
| 709 | const inquirerId = this.getContextInquirerId(resolutionContext); |
| 710 | const instanceHost = instanceWrapperRef.getInstanceByContextId( |
| 711 | this.getContextId(resolutionContext.contextId, instanceWrapperRef), |
| 712 | inquirerId, |
| 713 | ); |
| 714 | if (!instanceHost.isResolved && !instanceWrapperRef.forwardRef) { |
| 715 | /* |
| 716 | * Provider will be loaded shortly in resolveComponentHost() once we pass the current |
| 717 | * Barrier. We cannot load it here because doing so could incorrectly evaluate the |
| 718 | * staticity of the dependency tree and lead to undefined / null injection. |
no test coverage detected