UNPKG

@ng-doc/builder

Version:

<!-- PROJECT LOGO --> <br /> <div align="center"> <a href="https://github.com/ng-doc/ng-doc"> <img src="https://ng-doc.com/assets/images/ng-doc.svg?raw=true" alt="Logo" height="150px"> </a>

30 lines 1.74 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getComponentDecorator = getComponentDecorator; const ts_morph_1 = require("ts-morph"); const string_expression_1 = require("../string-expression"); const typescript_1 = require("../typescript"); /** * Resolves the component decorator and return its properties. * @param cls - class declaration */ function getComponentDecorator(cls) { const decorator = cls.getDecorator('Component'); const decoratorArgument = decorator?.getArguments()[0]; if (ts_morph_1.Node.isObjectLiteralExpression(decoratorArgument)) { const standaloneProperty = decoratorArgument.getProperty('standalone'); const selectorProperty = decoratorArgument.getProperty('selector'); const templateProperty = decoratorArgument.getProperty('templateUrl'); const styleUrlProperty = decoratorArgument.getProperty('styleUrl'); const styleUrlsProperty = decoratorArgument.getProperty('styleUrls'); return { standalone: (0, string_expression_1.stringExpression)((0, typescript_1.getPropertyAssignment)(standaloneProperty)), selector: (0, string_expression_1.stringExpression)((0, typescript_1.getPropertyAssignment)(selectorProperty)), templateUrl: (0, string_expression_1.stringExpression)((0, typescript_1.getPropertyAssignment)(templateProperty)), styleUrl: (0, string_expression_1.stringExpression)((0, typescript_1.getPropertyAssignment)(styleUrlProperty)), styleUrls: (0, string_expression_1.stringExpression)((0, typescript_1.getPropertyAssignment)(styleUrlsProperty)), }; } return undefined; } //# sourceMappingURL=get-component-decorator.js.map