[6a3a178] | 1 | /// <amd-module name="@angular/compiler-cli/src/ngtsc/shims/api" />
|
---|
| 2 | /**
|
---|
| 3 | * @license
|
---|
| 4 | * Copyright Google LLC All Rights Reserved.
|
---|
| 5 | *
|
---|
| 6 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 7 | * found in the LICENSE file at https://angular.io/license
|
---|
| 8 | */
|
---|
| 9 | import * as ts from 'typescript';
|
---|
| 10 | import { AbsoluteFsPath } from '../file_system';
|
---|
| 11 | /**
|
---|
| 12 | * Generates a single shim file for the entire program.
|
---|
| 13 | */
|
---|
| 14 | export interface TopLevelShimGenerator {
|
---|
| 15 | /**
|
---|
| 16 | * Whether this shim should be emitted during TypeScript emit.
|
---|
| 17 | */
|
---|
| 18 | readonly shouldEmit: boolean;
|
---|
| 19 | /**
|
---|
| 20 | * Create a `ts.SourceFile` representing the shim, with the correct filename.
|
---|
| 21 | */
|
---|
| 22 | makeTopLevelShim(): ts.SourceFile;
|
---|
| 23 | }
|
---|
| 24 | /**
|
---|
| 25 | * Generates a shim file for each original `ts.SourceFile` in the user's program, with a file
|
---|
| 26 | * extension prefix.
|
---|
| 27 | */
|
---|
| 28 | export interface PerFileShimGenerator {
|
---|
| 29 | /**
|
---|
| 30 | * The extension prefix which will be used for the shim.
|
---|
| 31 | *
|
---|
| 32 | * Knowing this allows the `ts.CompilerHost` implementation which is consuming this shim generator
|
---|
| 33 | * to predict the shim filename, which is useful when a previous `ts.Program` already includes a
|
---|
| 34 | * generated version of the shim.
|
---|
| 35 | */
|
---|
| 36 | readonly extensionPrefix: string;
|
---|
| 37 | /**
|
---|
| 38 | * Whether shims produced by this generator should be emitted during TypeScript emit.
|
---|
| 39 | */
|
---|
| 40 | readonly shouldEmit: boolean;
|
---|
| 41 | /**
|
---|
| 42 | * Generate the shim for a given original `ts.SourceFile`, with the given filename.
|
---|
| 43 | */
|
---|
| 44 | generateShimForFile(sf: ts.SourceFile, genFilePath: AbsoluteFsPath, priorShimSf: ts.SourceFile | null): ts.SourceFile;
|
---|
| 45 | }
|
---|
| 46 | /**
|
---|
| 47 | * Maintains a mapping of which symbols in a .ngfactory file have been used.
|
---|
| 48 | *
|
---|
| 49 | * .ngfactory files are generated with one symbol per defined class in the source file, regardless
|
---|
| 50 | * of whether the classes in the source files are NgModules (because that isn't known at the time
|
---|
| 51 | * the factory files are generated). A `FactoryTracker` supports removing factory symbols which
|
---|
| 52 | * didn't end up being NgModules, by tracking the ones which are.
|
---|
| 53 | */
|
---|
| 54 | export interface FactoryTracker {
|
---|
| 55 | readonly sourceInfo: Map<string, FactoryInfo>;
|
---|
| 56 | track(sf: ts.SourceFile, moduleInfo: ModuleInfo): void;
|
---|
| 57 | }
|
---|
| 58 | export interface FactoryInfo {
|
---|
| 59 | sourceFilePath: string;
|
---|
| 60 | moduleSymbols: Map<string, ModuleInfo>;
|
---|
| 61 | }
|
---|
| 62 | export interface ModuleInfo {
|
---|
| 63 | name: string;
|
---|
| 64 | hasId: boolean;
|
---|
| 65 | }
|
---|