(function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); if (v !== undefined) module.exports = v; } else if (typeof define === "function" && define.amd) { define("@angular/compiler/src/render3/partial/directive", ["require", "exports", "@angular/compiler/src/output/output_ast", "@angular/compiler/src/render3/r3_identifiers", "@angular/compiler/src/render3/view/compiler", "@angular/compiler/src/render3/view/util", "@angular/compiler/src/render3/partial/util"], factory); } })(function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createDirectiveDefinitionMap = exports.compileDeclareDirectiveFromMetadata = void 0; /** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var o = require("@angular/compiler/src/output/output_ast"); var r3_identifiers_1 = require("@angular/compiler/src/render3/r3_identifiers"); var compiler_1 = require("@angular/compiler/src/render3/view/compiler"); var util_1 = require("@angular/compiler/src/render3/view/util"); var util_2 = require("@angular/compiler/src/render3/partial/util"); /** * Every time we make a breaking change to the declaration interface or partial-linker behavior, we * must update this constant to prevent old partial-linkers from incorrectly processing the * declaration. * * Do not include any prerelease in these versions as they are ignored. */ var MINIMUM_PARTIAL_LINKER_VERSION = '12.0.0'; /** * Compile a directive declaration defined by the `R3DirectiveMetadata`. */ function compileDeclareDirectiveFromMetadata(meta) { var definitionMap = createDirectiveDefinitionMap(meta); var expression = o.importExpr(r3_identifiers_1.Identifiers.declareDirective).callFn([definitionMap.toLiteralMap()]); var type = compiler_1.createDirectiveType(meta); return { expression: expression, type: type, statements: [] }; } exports.compileDeclareDirectiveFromMetadata = compileDeclareDirectiveFromMetadata; /** * Gathers the declaration fields for a directive into a `DefinitionMap`. This allows for reusing * this logic for components, as they extend the directive metadata. */ function createDirectiveDefinitionMap(meta) { var definitionMap = new util_1.DefinitionMap(); definitionMap.set('minVersion', o.literal(MINIMUM_PARTIAL_LINKER_VERSION)); definitionMap.set('version', o.literal('12.2.13')); // e.g. `type: MyDirective` definitionMap.set('type', meta.internalType); // e.g. `selector: 'some-dir'` if (meta.selector !== null) { definitionMap.set('selector', o.literal(meta.selector)); } definitionMap.set('inputs', util_1.conditionallyCreateMapObjectLiteral(meta.inputs, true)); definitionMap.set('outputs', util_1.conditionallyCreateMapObjectLiteral(meta.outputs)); definitionMap.set('host', compileHostMetadata(meta.host)); definitionMap.set('providers', meta.providers); if (meta.queries.length > 0) { definitionMap.set('queries', o.literalArr(meta.queries.map(compileQuery))); } if (meta.viewQueries.length > 0) { definitionMap.set('viewQueries', o.literalArr(meta.viewQueries.map(compileQuery))); } if (meta.exportAs !== null) { definitionMap.set('exportAs', util_1.asLiteral(meta.exportAs)); } if (meta.usesInheritance) { definitionMap.set('usesInheritance', o.literal(true)); } if (meta.lifecycle.usesOnChanges) { definitionMap.set('usesOnChanges', o.literal(true)); } definitionMap.set('ngImport', o.importExpr(r3_identifiers_1.Identifiers.core)); return definitionMap; } exports.createDirectiveDefinitionMap = createDirectiveDefinitionMap; /** * Compiles the metadata of a single query into its partial declaration form as declared * by `R3DeclareQueryMetadata`. */ function compileQuery(query) { var meta = new util_1.DefinitionMap(); meta.set('propertyName', o.literal(query.propertyName)); if (query.first) { meta.set('first', o.literal(true)); } meta.set('predicate', Array.isArray(query.predicate) ? util_1.asLiteral(query.predicate) : query.predicate); if (!query.emitDistinctChangesOnly) { // `emitDistinctChangesOnly` is special because we expect it to be `true`. // Therefore we explicitly emit the field, and explicitly place it only when it's `false`. meta.set('emitDistinctChangesOnly', o.literal(false)); } else { // The linker will assume that an absent `emitDistinctChangesOnly` flag is by default `true`. } if (query.descendants) { meta.set('descendants', o.literal(true)); } meta.set('read', query.read); if (query.static) { meta.set('static', o.literal(true)); } return meta.toLiteralMap(); } /** * Compiles the host metadata into its partial declaration form as declared * in `R3DeclareDirectiveMetadata['host']` */ function compileHostMetadata(meta) { var hostMetadata = new util_1.DefinitionMap(); hostMetadata.set('attributes', util_2.toOptionalLiteralMap(meta.attributes, function (expression) { return expression; })); hostMetadata.set('listeners', util_2.toOptionalLiteralMap(meta.listeners, o.literal)); hostMetadata.set('properties', util_2.toOptionalLiteralMap(meta.properties, o.literal)); if (meta.specialAttributes.styleAttr) { hostMetadata.set('styleAttribute', o.literal(meta.specialAttributes.styleAttr)); } if (meta.specialAttributes.classAttr) { hostMetadata.set('classAttribute', o.literal(meta.specialAttributes.classAttr)); } if (hostMetadata.values.length > 0) { return hostMetadata.toLiteralMap(); } else { return null; } } }); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGlyZWN0aXZlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvY29tcGlsZXIvc3JjL3JlbmRlcjMvcGFydGlhbC9kaXJlY3RpdmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7O0lBQUE7Ozs7OztPQU1HO0lBQ0gsMkRBQTZDO0lBQzdDLCtFQUFvRDtJQUdwRCx3RUFBcUQ7SUFDckQsZ0VBQTJGO0lBRTNGLG1FQUE0QztJQUU1Qzs7Ozs7O09BTUc7SUFDSCxJQUFNLDhCQUE4QixHQUFHLFFBQVEsQ0FBQztJQUVoRDs7T0FFRztJQUNILFNBQWdCLG1DQUFtQyxDQUFDLElBQXlCO1FBRTNFLElBQU0sYUFBYSxHQUFHLDRCQUE0QixDQUFDLElBQUksQ0FBQyxDQUFDO1FBRXpELElBQU0sVUFBVSxHQUFHLENBQUMsQ0FBQyxVQUFVLENBQUMsNEJBQUUsQ0FBQyxnQkFBZ0IsQ0FBQyxDQUFDLE1BQU0sQ0FBQyxDQUFDLGFBQWEsQ0FBQyxZQUFZLEVBQUUsQ0FBQyxDQUFDLENBQUM7UUFDNUYsSUFBTSxJQUFJLEdBQUcsOEJBQW1CLENBQUMsSUFBSSxDQUFDLENBQUM7UUFFdkMsT0FBTyxFQUFDLFVBQVUsWUFBQSxFQUFFLElBQUksTUFBQS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