(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/parse_util", ["require", "exports", "@angular/compiler/src/aot/static_symbol", "@angular/compiler/src/chars", "@angular/compiler/src/util"], factory); } })(function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.sanitizeIdentifier = exports.identifierModuleUrl = exports.identifierName = exports.getParseErrors = exports.isSyntaxError = exports.syntaxError = exports.r3JitTypeSourceSpan = exports.typeSourceSpan = exports.ParseError = exports.ParseErrorLevel = exports.ParseSourceSpan = exports.ParseSourceFile = exports.ParseLocation = 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 static_symbol_1 = require("@angular/compiler/src/aot/static_symbol"); var chars = require("@angular/compiler/src/chars"); var util_1 = require("@angular/compiler/src/util"); var ParseLocation = /** @class */ (function () { function ParseLocation(file, offset, line, col) { this.file = file; this.offset = offset; this.line = line; this.col = col; } ParseLocation.prototype.toString = function () { return this.offset != null ? this.file.url + "@" + this.line + ":" + this.col : this.file.url; }; ParseLocation.prototype.moveBy = function (delta) { var source = this.file.content; var len = source.length; var offset = this.offset; var line = this.line; var col = this.col; while (offset > 0 && delta < 0) { offset--; delta++; var ch = source.charCodeAt(offset); if (ch == chars.$LF) { line--; var priorLine = source.substr(0, offset - 1).lastIndexOf(String.fromCharCode(chars.$LF)); col = priorLine > 0 ? offset - priorLine : offset; } else { col--; } } while (offset < len && delta > 0) { var ch = source.charCodeAt(offset); offset++; delta--; if (ch == chars.$LF) { line++; col = 0; } else { col++; } } return new ParseLocation(this.file, offset, line, col); }; // Return the source around the location // Up to `maxChars` or `maxLines` on each side of the location ParseLocation.prototype.getContext = function (maxChars, maxLines) { var content = this.file.content; var startOffset = this.offset; if (startOffset != null) { if (startOffset > content.length - 1) { startOffset = content.length - 1; } var endOffset = startOffset; var ctxChars = 0; var ctxLines = 0; while (ctxChars < maxChars && startOffset > 0) { startOffset--; ctxChars++; if (content[startOffset] == '\n') { if (++ctxLines == maxLines) { break; } } } ctxChars = 0; ctxLines = 0; while (ctxChars < maxChars && endOffset < content.length - 1) { endOffset++; ctxChars++; if (content[endOffset] == '\n') { if (++ctxLines == maxLines) { break; } } } return { before: content.substring(startOffset, this.offset), after: content.substring(this.offset, endOffset + 1), }; } return null; }; return ParseLocation; }()); exports.ParseLocation = ParseLocation; var ParseSourceFile = /** @class */ (function () { function ParseSourceFile(content, url) { this.content = content; this.url = url; } return ParseSourceFile; }()); exports.ParseSourceFile = ParseSourceFile; var ParseSourceSpan = /** @class */ (function () { /** * Create an object that holds information about spans of tokens/nodes captured during * lexing/parsing of text. * * @param start * The location of the start of the span (having skipped leading trivia). * Skipping leading trivia makes source-spans more "user friendly", since things like HTML * elements will appear to begin at the start of the opening tag, rather than at the start of any * leading trivia, which could include newlines. * * @param end * The location of the end of the span. * * @param fullStart * The start of the token without skipping the leading trivia. * This is used by tooling that splits tokens further, such as extracting Angular interpolations * from text tokens. Such tooling creates new source-spans relative to the original token's * source-span. If leading trivia characters have been skipped then the new source-spans may be * incorrectly offset. * * @param details * Additional information (such as identifier names) that should be associated with the span. */ function ParseSourceSpan(start, end, fullStart, details) { if (fullStart === void 0) { fullStart = start; } if (details === void 0) { details = null; } this.start = start; this.end = end; this.fullStart = fullStart; this.details = details; } ParseSourceSpan.prototype.toString = function () { return this.start.file.content.substring(this.start.offset, this.end.offset); }; return ParseSourceSpan; }()); exports.ParseSourceSpan = ParseSourceSpan; var ParseErrorLevel; (function (ParseErrorLevel) { ParseErrorLevel[ParseErrorLevel["WARNING"] = 0] = "WARNING"; ParseErrorLevel[ParseErrorLevel["ERROR"] = 1] = "ERROR"; })(ParseErrorLevel = exports.ParseErrorLevel || (exports.ParseErrorLevel = {})); var ParseError = /** @class */ (function () { function ParseError(span, msg, level) { if (level === void 0) { level = ParseErrorLevel.ERROR; } this.span = span; this.msg = msg; this.level = level; } ParseError.prototype.contextualMessage = function () { var ctx = this.span.start.getContext(100, 3); return ctx ? this.msg + " (\"" + ctx.before + "[" + ParseErrorLevel[this.level] + " ->]" + ctx.after + "\")" : this.msg; }; ParseError.prototype.toString = function () { var details = this.span.details ? ", " + this.span.details : ''; return this.contextualMessage() + ": " + this.span.start + details; }; return ParseError; }()); exports.ParseError = ParseError; function typeSourceSpan(kind, type) { var moduleUrl = identifierModuleUrl(type); var sourceFileName = moduleUrl != null ? "in " + kind + " " + identifierName(type) + " in " + moduleUrl : "in " + kind + " " + identifierName(type); var sourceFile = new ParseSourceFile('', sourceFileName); return new ParseSourceSpan(new ParseLocation(sourceFile, -1, -1, -1), new ParseLocation(sourceFile, -1, -1, -1)); } exports.typeSourceSpan = typeSourceSpan; /** * Generates Source Span object for a given R3 Type for JIT mode. * * @param kind Component or Directive. * @param typeName name of the Component or Directive. * @param sourceUrl reference to Component or Directive source. * @returns instance of ParseSourceSpan that represent a given Component or Directive. */ function r3JitTypeSourceSpan(kind, typeName, sourceUrl) { var sourceFileName = "in " + kind + " " + typeName + " in " + sourceUrl; var sourceFile = new ParseSourceFile('', sourceFileName); return new ParseSourceSpan(new ParseLocation(sourceFile, -1, -1, -1), new ParseLocation(sourceFile, -1, -1, -1)); } exports.r3JitTypeSourceSpan = r3JitTypeSourceSpan; function syntaxError(msg, parseErrors) { var error = Error(msg); error[ERROR_SYNTAX_ERROR] = true; if (parseErrors) error[ERROR_PARSE_ERRORS] = parseErrors; return error; } exports.syntaxError = syntaxError; var ERROR_SYNTAX_ERROR = 'ngSyntaxError'; var ERROR_PARSE_ERRORS = 'ngParseErrors'; function isSyntaxError(error) { return error[ERROR_SYNTAX_ERROR]; } exports.isSyntaxError = isSyntaxError; function getParseErrors(error) { return error[ERROR_PARSE_ERRORS] || []; } exports.getParseErrors = getParseErrors; var _anonymousTypeIndex = 0; function identifierName(compileIdentifier) { if (!compileIdentifier || !compileIdentifier.reference) { return null; } var ref = compileIdentifier.reference; if (ref instanceof static_symbol_1.StaticSymbol) { return ref.name; } if (ref['__anonymousType']) { return ref['__anonymousType']; } if (ref['__forward_ref__']) { // We do not want to try to stringify a `forwardRef()` function because that would cause the // inner function to be evaluated too early, defeating the whole point of the `forwardRef`. return '__forward_ref__'; } var identifier = util_1.stringify(ref); if (identifier.indexOf('(') >= 0) { // case: anonymous functions! identifier = "anonymous_" + _anonymousTypeIndex++; ref['__anonymousType'] = identifier; } else { identifier = sanitizeIdentifier(identifier); } return identifier; } exports.identifierName = identifierName; function identifierModuleUrl(compileIdentifier) { var ref = compileIdentifier.reference; if (ref instanceof static_symbol_1.StaticSymbol) { return ref.filePath; } // Runtime type return "./" + util_1.stringify(ref); } exports.identifierModuleUrl = identifierModuleUrl; function sanitizeIdentifier(name) { return name.replace(/\W/g, '_'); } exports.sanitizeIdentifier = sanitizeIdentifier; }); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGFyc2VfdXRpbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL2NvbXBpbGVyL3NyYy9wYXJzZV91dGlsLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7OztJQUFBOzs7Ozs7T0FNRztJQUNILHlFQUFpRDtJQUNqRCxtREFBaUM7SUFDakMsbURBQWlDO0lBRWpDO1FBQ0UsdUJBQ1csSUFBcUIsRUFBUyxNQUFjLEVBQVMsSUFBWSxFQUNqRSxHQUFXO1lBRFgsU0FBSSxHQUFKLElBQUksQ0FBaUI7WUFBUyxXQUFNLEdBQU4sTUFBTSxDQUFRO1lBQVMsU0FBSSxHQUFKLElBQUksQ0FBUTtZQUNqRSxRQUFHLEdBQUgsR0FBRyxDQUFRO1FBQUcsQ0FBQztRQUUxQixnQ0FBUSxHQUFSO1lBQ0UsT0FBTyxJQUFJLENBQUMsTUFBTSxJQUFJLEl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Y29udGVudDtcbiAgICBsZXQgc3RhcnRPZmZzZXQgPSB0aGlzLm9mZnNldDtcblxuICAgIGlmIChzdGFydE9mZnNldCAhPSBudWxsKSB7XG4gICAgICBpZiAoc3RhcnRPZmZzZXQgPiBjb250ZW50Lmxlbmd0aCAtIDEpIHtcbiAgICAgICAgc3RhcnRPZmZzZXQgPSBjb250ZW50Lmxlbmd0aCAtIDE7XG4gICAgICB9XG4gICAgICBsZXQgZW5kT2Zmc2V0ID0gc3RhcnRPZmZzZXQ7XG4gICAgICBsZXQgY3R4Q2hhcnMgPSAwO1xuICAgICAgbGV0IGN0eExpbmVzID0gMDtcblxuICAgICAgd2hpbGUgKGN0eENoYXJzIDwgbWF4Q2hhcnMgJiYgc3RhcnRPZmZzZXQgPiAwKSB7XG4gICAgICAgIHN0YXJ0T2Zmc2V0LS07XG4gICAgICAgIGN0eENoYXJzKys7XG4gICAgICAgIGlmIChjb250ZW50W3N0YXJ0T2Zmc2V0XSA9PSAnXFxuJykge1xuICAgICAgICAgIGlmICgrK2N0eExpbmVzID09IG1heExpbmVzKSB7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH1cblxuICAgICAgY3R4Q2hhcnMgPSAwO1xuICAgICAgY3R4TGluZXMgPSAwO1xuICAgICAgd2hpbGUgKGN0eENoYXJzIDwgbWF4Q2hhcnMgJiYgZW5kT2Zmc2V0IDwgY29udGVudC5sZW5ndGggLSAxKSB7XG4gICAgICAgIGVuZE9mZnNldCsrO1xuICAgICAgICBjdHhDaGFycysrO1xuICAgICAgICBpZiAoY29udGVudFtlbmRPZmZzZXRdID09ICdcXG4nKSB7XG4gICAgICAgICAgaWYgKCsrY3R4TGluZXMgPT0gbWF4TGluZXMpIHtcbiAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfVxuXG4gICAgICByZXR1cm4ge1xuICAgICAgICBiZWZvcmU6IGNvbnRlbnQuc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