1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | /// <amd-module name="@angular/compiler-cli/ngcc/src/host/umd_host" />
|
---|
9 | import * as ts from 'typescript';
|
---|
10 | import { Logger } from '../../../src/ngtsc/logging';
|
---|
11 | import { Declaration, Import } from '../../../src/ngtsc/reflection';
|
---|
12 | import { BundleProgram } from '../packages/bundle_program';
|
---|
13 | import { FactoryMap } from '../utils';
|
---|
14 | import { Esm5ReflectionHost } from './esm5_host';
|
---|
15 | import { NgccClassSymbol } from './ngcc_host';
|
---|
16 | export declare class UmdReflectionHost extends Esm5ReflectionHost {
|
---|
17 | protected umdModules: FactoryMap<ts.SourceFile, UmdModule | null>;
|
---|
18 | protected umdExports: FactoryMap<ts.SourceFile, Map<string, Declaration<ts.Declaration>> | null>;
|
---|
19 | protected umdImportPaths: FactoryMap<ts.ParameterDeclaration, string | null>;
|
---|
20 | protected program: ts.Program;
|
---|
21 | protected compilerHost: ts.CompilerHost;
|
---|
22 | constructor(logger: Logger, isCore: boolean, src: BundleProgram, dts?: BundleProgram | null);
|
---|
23 | getImportOfIdentifier(id: ts.Identifier): Import | null;
|
---|
24 | getDeclarationOfIdentifier(id: ts.Identifier): Declaration | null;
|
---|
25 | getExportsOfModule(module: ts.Node): Map<string, Declaration> | null;
|
---|
26 | getUmdModule(sourceFile: ts.SourceFile): UmdModule | null;
|
---|
27 | getUmdImportPath(importParameter: ts.ParameterDeclaration): string | null;
|
---|
28 | /**
|
---|
29 | * Get the top level statements for a module.
|
---|
30 | *
|
---|
31 | * In UMD modules these are the body of the UMD factory function.
|
---|
32 | *
|
---|
33 | * @param sourceFile The module whose statements we want.
|
---|
34 | * @returns An array of top level statements for the given module.
|
---|
35 | */
|
---|
36 | protected getModuleStatements(sourceFile: ts.SourceFile): ts.Statement[];
|
---|
37 | protected getClassSymbolFromOuterDeclaration(declaration: ts.Node): NgccClassSymbol | undefined;
|
---|
38 | protected getClassSymbolFromInnerDeclaration(declaration: ts.Node): NgccClassSymbol | undefined;
|
---|
39 | /**
|
---|
40 | * Extract all "classes" from the `statement` and add them to the `classes` map.
|
---|
41 | */
|
---|
42 | protected addClassSymbolsFromStatement(classes: Map<ts.Symbol, NgccClassSymbol>, statement: ts.Statement): void;
|
---|
43 | /**
|
---|
44 | * Analyze the given statement to see if it corresponds with an exports declaration like
|
---|
45 | * `exports.MyClass = MyClass_1 = <class def>;`. If so, the declaration of `MyClass_1`
|
---|
46 | * is associated with the `MyClass` identifier.
|
---|
47 | *
|
---|
48 | * @param statement The statement that needs to be preprocessed.
|
---|
49 | */
|
---|
50 | protected preprocessStatement(statement: ts.Statement): void;
|
---|
51 | private computeUmdModule;
|
---|
52 | private computeExportsOfUmdModule;
|
---|
53 | private computeImportPath;
|
---|
54 | private extractBasicUmdExportDeclaration;
|
---|
55 | private extractUmdWildcardReexports;
|
---|
56 | private extractUmdDefinePropertyExportDeclaration;
|
---|
57 | /**
|
---|
58 | * Is the identifier a parameter on a UMD factory function, e.g. `function factory(this, core)`?
|
---|
59 | * If so then return its declaration.
|
---|
60 | */
|
---|
61 | private findUmdImportParameter;
|
---|
62 | private getUmdDeclaration;
|
---|
63 | private getExportsDeclaration;
|
---|
64 | private getUmdModuleDeclaration;
|
---|
65 | private getImportPathFromParameter;
|
---|
66 | private getImportPathFromRequireCall;
|
---|
67 | /**
|
---|
68 | * If this is an IIFE then try to grab the outer and inner classes otherwise fallback on the super
|
---|
69 | * class.
|
---|
70 | */
|
---|
71 | protected getDeclarationOfExpression(expression: ts.Expression): Declaration | null;
|
---|
72 | private resolveModuleName;
|
---|
73 | }
|
---|
74 | export declare function parseStatementForUmdModule(statement: ts.Statement): UmdModule | null;
|
---|
75 | export declare function getImportsOfUmdModule(umdModule: UmdModule): {
|
---|
76 | parameter: ts.ParameterDeclaration;
|
---|
77 | path: string;
|
---|
78 | }[];
|
---|
79 | interface UmdModule {
|
---|
80 | wrapperFn: ts.FunctionExpression;
|
---|
81 | factoryFn: ts.FunctionExpression;
|
---|
82 | }
|
---|
83 | export {};
|
---|