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/src/transformers/compiler_host" />
|
---|
9 | import { AotCompilerHost, GeneratedFile, ParseSourceSpan } from '@angular/compiler';
|
---|
10 | import * as ts from 'typescript';
|
---|
11 | import { TypeCheckHost } from '../diagnostics/translate_diagnostics';
|
---|
12 | import { ModuleMetadata } from '../metadata/index';
|
---|
13 | import { CompilerHost, CompilerOptions, LibrarySummary } from './api';
|
---|
14 | export declare function setWrapHostForTest(wrapFn: ((host: ts.CompilerHost) => ts.CompilerHost) | null): void;
|
---|
15 | export declare function createCompilerHost({ options, tsHost }: {
|
---|
16 | options: CompilerOptions;
|
---|
17 | tsHost?: ts.CompilerHost;
|
---|
18 | }): CompilerHost;
|
---|
19 | export interface MetadataProvider {
|
---|
20 | getMetadata(sourceFile: ts.SourceFile): ModuleMetadata | undefined;
|
---|
21 | }
|
---|
22 | export interface CodeGenerator {
|
---|
23 | generateFile(genFileName: string, baseFileName?: string): GeneratedFile;
|
---|
24 | findGeneratedFileNames(fileName: string): string[];
|
---|
25 | }
|
---|
26 | /**
|
---|
27 | * Implements the following hosts based on an api.CompilerHost:
|
---|
28 | * - ts.CompilerHost to be consumed by a ts.Program
|
---|
29 | * - AotCompilerHost for @angular/compiler
|
---|
30 | * - TypeCheckHost for mapping ts errors to ng errors (via translateDiagnostics)
|
---|
31 | */
|
---|
32 | export declare class TsCompilerAotCompilerTypeCheckHostAdapter implements ts.CompilerHost, AotCompilerHost, TypeCheckHost {
|
---|
33 | private rootFiles;
|
---|
34 | private options;
|
---|
35 | private context;
|
---|
36 | private metadataProvider;
|
---|
37 | private codeGenerator;
|
---|
38 | private librarySummaries;
|
---|
39 | private metadataReaderCache;
|
---|
40 | private fileNameToModuleNameCache;
|
---|
41 | private flatModuleIndexCache;
|
---|
42 | private flatModuleIndexNames;
|
---|
43 | private flatModuleIndexRedirectNames;
|
---|
44 | private rootDirs;
|
---|
45 | private moduleResolutionCache;
|
---|
46 | private originalSourceFiles;
|
---|
47 | private originalFileExistsCache;
|
---|
48 | private generatedSourceFiles;
|
---|
49 | private generatedCodeFor;
|
---|
50 | private emitter;
|
---|
51 | private metadataReaderHost;
|
---|
52 | getCancellationToken: () => ts.CancellationToken;
|
---|
53 | getDefaultLibLocation: () => string;
|
---|
54 | trace: (s: string) => void;
|
---|
55 | getDirectories: (path: string) => string[];
|
---|
56 | resolveTypeReferenceDirectives?: (names: string[], containingFile: string) => ts.ResolvedTypeReferenceDirective[];
|
---|
57 | directoryExists?: (directoryName: string) => boolean;
|
---|
58 | constructor(rootFiles: ReadonlyArray<string>, options: CompilerOptions, context: CompilerHost, metadataProvider: MetadataProvider, codeGenerator: CodeGenerator, librarySummaries?: Map<string, LibrarySummary>);
|
---|
59 | private resolveModuleName;
|
---|
60 | resolveModuleNames(moduleNames: string[], containingFile: string): ts.ResolvedModule[];
|
---|
61 | moduleNameToFileName(m: string, containingFile?: string): string | null;
|
---|
62 | /**
|
---|
63 | * We want a moduleId that will appear in import statements in the generated code
|
---|
64 | * which will be written to `containingFile`.
|
---|
65 | *
|
---|
66 | * Note that we also generate files for files in node_modules, as libraries
|
---|
67 | * only ship .metadata.json files but not the generated code.
|
---|
68 | *
|
---|
69 | * Logic:
|
---|
70 | * 1. if the importedFile and the containingFile are from the project sources
|
---|
71 | * or from the same node_modules package, use a relative path
|
---|
72 | * 2. if the importedFile is in a node_modules package,
|
---|
73 | * use a path that starts with the package name.
|
---|
74 | * 3. Error if the containingFile is in the node_modules package
|
---|
75 | * and the importedFile is in the project soures,
|
---|
76 | * as that is a violation of the principle that node_modules packages cannot
|
---|
77 | * import project sources.
|
---|
78 | */
|
---|
79 | fileNameToModuleName(importedFile: string, containingFile: string): string;
|
---|
80 | resourceNameToFileName(resourceName: string, containingFile: string): string | null;
|
---|
81 | toSummaryFileName(fileName: string, referringSrcFileName: string): string;
|
---|
82 | fromSummaryFileName(fileName: string, referringLibFileName: string): string;
|
---|
83 | parseSourceSpanOf(fileName: string, line: number, character: number): ParseSourceSpan | null;
|
---|
84 | private getOriginalSourceFile;
|
---|
85 | updateGeneratedFile(genFile: GeneratedFile): ts.SourceFile;
|
---|
86 | private addGeneratedFile;
|
---|
87 | shouldGenerateFile(fileName: string): {
|
---|
88 | generate: boolean;
|
---|
89 | baseFileName?: string;
|
---|
90 | };
|
---|
91 | shouldGenerateFilesFor(fileName: string): string | boolean | null;
|
---|
92 | getSourceFile(fileName: string, languageVersion: ts.ScriptTarget, onError?: ((message: string) => void) | undefined): ts.SourceFile;
|
---|
93 | private getGeneratedFile;
|
---|
94 | private originalFileExists;
|
---|
95 | fileExists(fileName: string): boolean;
|
---|
96 | loadSummary(filePath: string): string | null;
|
---|
97 | isSourceFile(filePath: string): boolean;
|
---|
98 | readFile(fileName: string): string | undefined;
|
---|
99 | getMetadataFor(filePath: string): ModuleMetadata[] | undefined;
|
---|
100 | loadResource(filePath: string): Promise<string> | string;
|
---|
101 | getOutputName(filePath: string): string;
|
---|
102 | private hasBundleIndex;
|
---|
103 | getDefaultLibFileName: (options: ts.CompilerOptions) => string;
|
---|
104 | getCurrentDirectory: () => string;
|
---|
105 | getCanonicalFileName: (fileName: string) => string;
|
---|
106 | useCaseSensitiveFileNames: () => boolean;
|
---|
107 | getNewLine: () => string;
|
---|
108 | realpath: (p: string) => string;
|
---|
109 | writeFile: ts.WriteFileCallback;
|
---|
110 | }
|
---|
111 | export declare function getOriginalReferences(sourceFile: ts.SourceFile): ts.FileReference[] | undefined;
|
---|