UNPKG

@rxap/schematics-xml-parser

Version:

This package provides utilities for parsing XML templates within Angular Schematics. It includes functionality to locate templates in a file system, parse them using a specified DOMParser, and register custom elements for parsing. The package also offers

52 lines 1.84 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.StringTypeElement = exports.TypeElement = void 0; const tslib_1 = require("tslib"); const xml_parser_1 = require("@rxap/xml-parser"); const schematics_ts_morph_1 = require("@rxap/schematics-ts-morph"); let TypeElement = class TypeElement { get type() { if (this.nullable) { return [this.name, 'null'].join(' | '); } return this.name; } toValue({ sourceFile }) { if (this.from) { (0, schematics_ts_morph_1.CoerceImports)(sourceFile, { namedImports: [this.name], moduleSpecifier: this.from, }); } return this.type; } }; exports.TypeElement = TypeElement; tslib_1.__decorate([ (0, xml_parser_1.ElementChildTextContent)(), (0, xml_parser_1.ElementRequired)(), tslib_1.__metadata("design:type", String) ], TypeElement.prototype, "name", void 0); tslib_1.__decorate([ (0, xml_parser_1.ElementChildTextContent)(), tslib_1.__metadata("design:type", String) ], TypeElement.prototype, "from", void 0); tslib_1.__decorate([ (0, xml_parser_1.ElementAttribute)(), tslib_1.__metadata("design:type", Boolean) ], TypeElement.prototype, "nullable", void 0); exports.TypeElement = TypeElement = tslib_1.__decorate([ (0, xml_parser_1.ElementDef)('type') ], TypeElement); let StringTypeElement = class StringTypeElement extends TypeElement { constructor() { super(...arguments); this.name = 'string'; } }; exports.StringTypeElement = StringTypeElement; exports.StringTypeElement = StringTypeElement = tslib_1.__decorate([ (0, xml_parser_1.ElementExtends)(TypeElement), (0, xml_parser_1.ElementDef)('string-type') ], StringTypeElement); //# sourceMappingURL=type.element.js.map