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 | import * as o from '../../output/output_ast';
|
---|
9 | import { Identifiers as R3 } from '../r3_identifiers';
|
---|
10 | import { createPipeType } from '../r3_pipe_compiler';
|
---|
11 | import { DefinitionMap } from '../view/util';
|
---|
12 | /**
|
---|
13 | * Every time we make a breaking change to the declaration interface or partial-linker behavior, we
|
---|
14 | * must update this constant to prevent old partial-linkers from incorrectly processing the
|
---|
15 | * declaration.
|
---|
16 | *
|
---|
17 | * Do not include any prerelease in these versions as they are ignored.
|
---|
18 | */
|
---|
19 | const MINIMUM_PARTIAL_LINKER_VERSION = '12.0.0';
|
---|
20 | /**
|
---|
21 | * Compile a Pipe declaration defined by the `R3PipeMetadata`.
|
---|
22 | */
|
---|
23 | export function compileDeclarePipeFromMetadata(meta) {
|
---|
24 | const definitionMap = createPipeDefinitionMap(meta);
|
---|
25 | const expression = o.importExpr(R3.declarePipe).callFn([definitionMap.toLiteralMap()]);
|
---|
26 | const type = createPipeType(meta);
|
---|
27 | return { expression, type, statements: [] };
|
---|
28 | }
|
---|
29 | /**
|
---|
30 | * Gathers the declaration fields for a Pipe into a `DefinitionMap`.
|
---|
31 | */
|
---|
32 | export function createPipeDefinitionMap(meta) {
|
---|
33 | const definitionMap = new DefinitionMap();
|
---|
34 | definitionMap.set('minVersion', o.literal(MINIMUM_PARTIAL_LINKER_VERSION));
|
---|
35 | definitionMap.set('version', o.literal('12.2.13'));
|
---|
36 | definitionMap.set('ngImport', o.importExpr(R3.core));
|
---|
37 | // e.g. `type: MyPipe`
|
---|
38 | definitionMap.set('type', meta.internalType);
|
---|
39 | // e.g. `name: "myPipe"`
|
---|
40 | definitionMap.set('name', o.literal(meta.pipeName));
|
---|
41 | if (meta.pure === false) {
|
---|
42 | // e.g. `pure: false`
|
---|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