1 | /// <amd-module name="@angular/compiler-cli/linker/src/file_linker/partial_linkers/partial_linker_selector" />
|
---|
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 { Range } from 'semver';
|
---|
10 | import { AbsoluteFsPath } from '../../../../src/ngtsc/file_system';
|
---|
11 | import { Logger } from '../../../../src/ngtsc/logging';
|
---|
12 | import { LinkerEnvironment } from '../linker_environment';
|
---|
13 | import { PartialLinker } from './partial_linker';
|
---|
14 | export declare const ɵɵngDeclareDirective = "\u0275\u0275ngDeclareDirective";
|
---|
15 | export declare const ɵɵngDeclareClassMetadata = "\u0275\u0275ngDeclareClassMetadata";
|
---|
16 | export declare const ɵɵngDeclareComponent = "\u0275\u0275ngDeclareComponent";
|
---|
17 | export declare const ɵɵngDeclareFactory = "\u0275\u0275ngDeclareFactory";
|
---|
18 | export declare const ɵɵngDeclareInjectable = "\u0275\u0275ngDeclareInjectable";
|
---|
19 | export declare const ɵɵngDeclareInjector = "\u0275\u0275ngDeclareInjector";
|
---|
20 | export declare const ɵɵngDeclareNgModule = "\u0275\u0275ngDeclareNgModule";
|
---|
21 | export declare const ɵɵngDeclarePipe = "\u0275\u0275ngDeclarePipe";
|
---|
22 | export declare const declarationFunctions: string[];
|
---|
23 | export interface LinkerRange<TExpression> {
|
---|
24 | range: Range;
|
---|
25 | linker: PartialLinker<TExpression>;
|
---|
26 | }
|
---|
27 | /**
|
---|
28 | * Create a mapping between partial-declaration call name and collections of partial-linkers.
|
---|
29 | *
|
---|
30 | * Each collection of partial-linkers will contain a version range that will be matched against the
|
---|
31 | * `minVersion` of the partial-declaration. (Additionally, a partial-linker may modify its behaviour
|
---|
32 | * internally based on the `version` property of the declaration.)
|
---|
33 | *
|
---|
34 | * Versions should be sorted in ascending order. The most recent partial-linker will be used as the
|
---|
35 | * fallback linker if none of the other version ranges match. For example:
|
---|
36 | *
|
---|
37 | * ```
|
---|
38 | * {range: getRange('<=', '13.0.0'), linker PartialDirectiveLinkerVersion2(...) },
|
---|
39 | * {range: getRange('<=', '13.1.0'), linker PartialDirectiveLinkerVersion3(...) },
|
---|
40 | * {range: getRange('<=', '14.0.0'), linker PartialDirectiveLinkerVersion4(...) },
|
---|
41 | * {range: LATEST_VERSION_RANGE, linker: new PartialDirectiveLinkerVersion1(...)},
|
---|
42 | * ```
|
---|
43 | *
|
---|
44 | * If the `LATEST_VERSION_RANGE` is `<=15.0.0` then the fallback linker would be
|
---|
45 | * `PartialDirectiveLinkerVersion1` for any version greater than `15.0.0`.
|
---|
46 | *
|
---|
47 | * When there is a change to a declaration interface that requires a new partial-linker, the
|
---|
48 | * `minVersion` of the partial-declaration should be updated, the new linker implementation should
|
---|
49 | * be added to the end of the collection, and the version of the previous linker should be updated.
|
---|
50 | */
|
---|
51 | export declare function createLinkerMap<TStatement, TExpression>(environment: LinkerEnvironment<TStatement, TExpression>, sourceUrl: AbsoluteFsPath, code: string): Map<string, LinkerRange<TExpression>[]>;
|
---|
52 | /**
|
---|
53 | * A helper that selects the appropriate `PartialLinker` for a given declaration.
|
---|
54 | *
|
---|
55 | * The selection is made from a database of linker instances, chosen if their given semver range
|
---|
56 | * satisfies the `minVersion` of the partial declaration to be linked.
|
---|
57 | *
|
---|
58 | * Note that the ranges are checked in order, and the first matching range will be selected. So
|
---|
59 | * ranges should be most restrictive first. In practice, since ranges are always `<=X.Y.Z` this
|
---|
60 | * means that ranges should be in ascending order.
|
---|
61 | *
|
---|
62 | * Note that any "pre-release" versions are stripped from ranges. Therefore if a `minVersion` is
|
---|
63 | * `11.1.0-next.1` then this would match `11.1.0-next.2` and also `12.0.0-next.1`. (This is
|
---|
64 | * different to standard semver range checking, where pre-release versions do not cross full version
|
---|
65 | * boundaries.)
|
---|
66 | */
|
---|
67 | export declare class PartialLinkerSelector<TExpression> {
|
---|
68 | private readonly linkers;
|
---|
69 | private readonly logger;
|
---|
70 | private readonly unknownDeclarationVersionHandling;
|
---|
71 | constructor(linkers: Map<string, LinkerRange<TExpression>[]>, logger: Logger, unknownDeclarationVersionHandling: 'ignore' | 'warn' | 'error');
|
---|
72 | /**
|
---|
73 | * Returns true if there are `PartialLinker` classes that can handle functions with this name.
|
---|
74 | */
|
---|
75 | supportsDeclaration(functionName: string): boolean;
|
---|
76 | /**
|
---|
77 | * Returns the `PartialLinker` that can handle functions with the given name and version.
|
---|
78 | * Throws an error if there is none.
|
---|
79 | */
|
---|
80 | getLinker(functionName: string, minVersion: string, version: string): PartialLinker<TExpression>;
|
---|
81 | }
|
---|