1 | (function (factory) {
|
---|
2 | if (typeof module === "object" && typeof module.exports === "object") {
|
---|
3 | var v = factory(require, exports);
|
---|
4 | if (v !== undefined) module.exports = v;
|
---|
5 | }
|
---|
6 | else if (typeof define === "function" && define.amd) {
|
---|
7 | define("@angular/compiler/src/render3/r3_pipe_compiler", ["require", "exports", "@angular/compiler/src/output/output_ast", "@angular/compiler/src/render3/r3_identifiers", "@angular/compiler/src/render3/util"], factory);
|
---|
8 | }
|
---|
9 | })(function (require, exports) {
|
---|
10 | "use strict";
|
---|
11 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
12 | exports.createPipeType = exports.compilePipeFromMetadata = void 0;
|
---|
13 | /**
|
---|
14 | * @license
|
---|
15 | * Copyright Google LLC All Rights Reserved.
|
---|
16 | *
|
---|
17 | * Use of this source code is governed by an MIT-style license that can be
|
---|
18 | * found in the LICENSE file at https://angular.io/license
|
---|
19 | */
|
---|
20 | var o = require("@angular/compiler/src/output/output_ast");
|
---|
21 | var r3_identifiers_1 = require("@angular/compiler/src/render3/r3_identifiers");
|
---|
22 | var util_1 = require("@angular/compiler/src/render3/util");
|
---|
23 | function compilePipeFromMetadata(metadata) {
|
---|
24 | var definitionMapValues = [];
|
---|
25 | // e.g. `name: 'myPipe'`
|
---|
26 | definitionMapValues.push({ key: 'name', value: o.literal(metadata.pipeName), quoted: false });
|
---|
27 | // e.g. `type: MyPipe`
|
---|
28 | definitionMapValues.push({ key: 'type', value: metadata.type.value, quoted: false });
|
---|
29 | // e.g. `pure: true`
|
---|
30 | definitionMapValues.push({ key: 'pure', value: o.literal(metadata.pure), quoted: false });
|
---|
31 | var expression = o.importExpr(r3_identifiers_1.Identifiers.definePipe).callFn([o.literalMap(definitionMapValues)], undefined, true);
|
---|
32 | var type = createPipeType(metadata);
|
---|
33 | return { expression: expression, type: type, statements: [] };
|
---|
34 | }
|
---|
35 | exports.compilePipeFromMetadata = compilePipeFromMetadata;
|
---|
36 | function createPipeType(metadata) {
|
---|
37 | return new o.ExpressionType(o.importExpr(r3_identifiers_1.Identifiers.PipeDeclaration, [
|
---|
38 | util_1.typeWithParameters(metadata.type.type, metadata.typeArgumentCount),
|
---|
39 | new o.ExpressionType(new o.LiteralExpr(metadata.pipeName)),
|
---|
40 | ]));
|
---|
41 | }
|
---|
42 | exports.createPipeType = createPipeType;
|
---|
43 | });
|
---|
44 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicjNfcGlwZV9jb21waWxlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL2NvbXBpbGVyL3NyYy9yZW5kZXIzL3IzX3BpcGVfY29tcGlsZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7O0lBQUE7Ozs7OztPQU1HO0lBQ0gsMkRBQTBDO0lBRzFDLCtFQUFtRDtJQUNuRCwyREFBNkU7SUEyQzdFLFNBQWdCLHVCQUF1QixDQUFDLFFBQXdCO1FBQzlELElBQU0sbUJBQW1CLEdBQTBELEVBQUUsQ0FBQztRQUV0Rix3QkFBd0I7UUFDeEIsbUJBQW1CLENBQUMsSUFBSSxDQUFDLEVBQUMsR0FBRyxFQUFFLE1BQU0sRUFBRSxLQUFLLEVBQUUsQ0FBQyxDQUFDLE9BQU8sQ0FBQyxRQUFRLENBQUMsUUFBUSxDQUFDLEVBQUUsTUFBTSxFQUFFLEtBQUssRUFBQyxDQUFDLENBQUM7UUFFNUYsc0JBQXNCO1FBQ3RCLG1CQUFtQixDQUFDLElBQUksQ0FBQyxFQUFDLEdBQUcsRUFBRSxNQUFNLEVBQUUsS0FBSyxFQUFFLFFBQVEsQ0FBQyxJQUFJLENBQUMsS0FBSyxFQUFFLE1BQU0sRUFBRSxLQUFLLEVBQUMsQ0FBQyxDQUFDO1FBRW5GLG9CQUFvQjtRQUNwQixtQkFBbUIsQ0FBQyxJQUFJLENBQ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