diff options
Diffstat (limited to 'xstatic/pkg/angular/data/angular-message-format.js')
-rw-r--r-- | xstatic/pkg/angular/data/angular-message-format.js | 156 |
1 files changed, 72 insertions, 84 deletions
diff --git a/xstatic/pkg/angular/data/angular-message-format.js b/xstatic/pkg/angular/data/angular-message-format.js index f128916..09ccb57 100644 --- a/xstatic/pkg/angular/data/angular-message-format.js +++ b/xstatic/pkg/angular/data/angular-message-format.js @@ -1,6 +1,6 @@ /** - * @license AngularJS v1.5.8 - * (c) 2010-2016 Google, Inc. http://angularjs.org + * @license AngularJS v1.8.2 + * (c) 2010-2020 Google, Inc. http://angularjs.org * License: MIT */ (function(window, angular) {'use strict'; @@ -13,22 +13,14 @@ /* global isFunction: false */ /* global noop: false */ /* global toJson: false */ - -function stringify(value) { - if (value == null /* null/undefined */) { return ''; } - switch (typeof value) { - case 'string': return value; - case 'number': return '' + value; - default: return toJson(value); - } -} +/* global $$stringify: false */ // Convert an index into the string into line/column for use in error messages // As such, this doesn't have to be efficient. function indexToLineAndColumn(text, index) { var lines = text.split(/\n/g); - for (var i=0; i < lines.length; i++) { - var line=lines[i]; + for (var i = 0; i < lines.length; i++) { + var line = lines[i]; if (index >= line.length) { index -= line.length; } else { @@ -47,7 +39,7 @@ function parseTextLiteral(text) { parsedFn['$$watchDelegate'] = function watchDelegate(scope, listener, objectEquality) { var unwatch = scope['$watch'](noop, function textLiteralWatcher() { - if (isFunction(listener)) { listener.call(null, text, text, scope); } + listener(text, text, scope); unwatch(); }, objectEquality); @@ -64,14 +56,14 @@ function subtractOffset(expressionFn, offset) { return expressionFn; } function minusOffset(value) { - return (value == void 0) ? value : value - offset; + return (value == null) ? value : value - offset; } function parsedFn(context) { return minusOffset(expressionFn(context)); } var unwatch; parsedFn['$$watchDelegate'] = function watchDelegate(scope, listener, objectEquality) { unwatch = scope['$watch'](expressionFn, function pluralExpressionWatchListener(newValue, oldValue) { - if (isFunction(listener)) { listener.call(null, minusOffset(newValue), minusOffset(oldValue), scope); } + listener(minusOffset(newValue), minusOffset(oldValue), scope); }, objectEquality); return unwatch; @@ -96,7 +88,7 @@ function MessageSelectorBase(expressionFn, choices) { var self = this; this.expressionFn = expressionFn; this.choices = choices; - if (choices["other"] === void 0) { + if (choices['other'] === undefined) { throw $interpolateMinErr('reqother', '“other” is a required option.'); } this.parsedFn = function(context) { return self.getResult(context); }; @@ -130,7 +122,7 @@ function MessageSelectorWatchers(msgSelector, scope, listener, objectEquality) { this.msgSelector = msgSelector; this.listener = listener; this.objectEquality = objectEquality; - this.lastMessage = void 0; + this.lastMessage = undefined; this.messageFnWatcher = noop; var expressionFnListener = function(newValue, oldValue) { return self.expressionFnListener(newValue, oldValue); }; this.expressionFnWatcher = scope['$watch'](msgSelector.expressionFn, expressionFnListener, objectEquality); @@ -145,9 +137,7 @@ MessageSelectorWatchers.prototype.expressionFnListener = function expressionFnLi }; MessageSelectorWatchers.prototype.messageFnListener = function messageFnListener(newMessage, oldMessage) { - if (isFunction(this.listener)) { - this.listener.call(null, newMessage, newMessage === oldMessage ? newMessage : this.lastMessage, this.scope); - } + this.listener.call(null, newMessage, newMessage === oldMessage ? newMessage : this.lastMessage, this.scope); this.lastMessage = newMessage; }; @@ -170,7 +160,7 @@ SelectMessageProto.prototype = MessageSelectorBase.prototype; SelectMessage.prototype = new SelectMessageProto(); SelectMessage.prototype.categorizeValue = function categorizeSelectValue(value) { - return (this.choices[value] !== void 0) ? value : "other"; + return (this.choices[value] !== undefined) ? value : 'other'; }; /** @@ -190,12 +180,12 @@ PluralMessageProto.prototype = MessageSelectorBase.prototype; PluralMessage.prototype = new PluralMessageProto(); PluralMessage.prototype.categorizeValue = function categorizePluralValue(value) { if (isNaN(value)) { - return "other"; - } else if (this.choices[value] !== void 0) { + return 'other'; + } else if (this.choices[value] !== undefined) { return value; } else { var category = this.pluralCat(value - this.offset); - return (this.choices[category] !== void 0) ? category : "other"; + return (this.choices[category] !== undefined) ? category : 'other'; } }; @@ -264,7 +254,7 @@ InterpolationParts.prototype.getExpressionValues = function getExpressionValues( InterpolationParts.prototype.getResult = function getResult(expressionValues) { for (var i = 0; i < this.expressionIndices.length; i++) { var expressionValue = expressionValues[i]; - if (this.allOrNothing && expressionValue === void 0) return; + if (this.allOrNothing && expressionValue === undefined) return; this.textParts[this.expressionIndices[i]] = expressionValue; } return this.textParts.join(''); @@ -275,7 +265,7 @@ InterpolationParts.prototype.toParsedFn = function toParsedFn(mustHaveExpression var self = this; this.flushPartialText(); if (mustHaveExpression && this.expressionFns.length === 0) { - return void 0; + return undefined; } if (this.textParts.length === 0) { return parseTextLiteral(''); @@ -284,7 +274,7 @@ InterpolationParts.prototype.toParsedFn = function toParsedFn(mustHaveExpression $interpolateMinErr['throwNoconcat'](originalText); } if (this.expressionFns.length === 0) { - if (this.textParts.length != 1) { this.errorInParseLogic(); } + if (this.textParts.length !== 1) { this.errorInParseLogic(); } return parseTextLiteral(this.textParts[0]); } var parsedFn = function(context) { @@ -311,7 +301,7 @@ InterpolationParts.prototype.watchDelegate = function watchDelegate(scope, liste function InterpolationPartsWatcher(interpolationParts, scope, listener, objectEquality) { this.interpolationParts = interpolationParts; this.scope = scope; - this.previousResult = (void 0); + this.previousResult = (undefined); this.listener = listener; var self = this; this.expressionFnsWatcher = scope['$watchGroup'](interpolationParts.expressionFns, function(newExpressionValues, oldExpressionValues) { @@ -321,9 +311,7 @@ function InterpolationPartsWatcher(interpolationParts, scope, listener, objectEq InterpolationPartsWatcher.prototype.watchListener = function watchListener(newExpressionValues, oldExpressionValues) { var result = this.interpolationParts.getResult(newExpressionValues); - if (isFunction(this.listener)) { - this.listener.call(null, result, newExpressionValues === oldExpressionValues ? result : this.previousResult, this.scope); - } + this.listener.call(null, result, newExpressionValues === oldExpressionValues ? result : this.previousResult, this.scope); this.previousResult = result; }; @@ -423,7 +411,7 @@ MessageFormatParser.prototype.popState = function popState() { MessageFormatParser.prototype.matchRe = function matchRe(re, search) { re.lastIndex = this.index; var match = re.exec(this.text); - if (match != null && (search === true || (match.index == this.index))) { + if (match != null && (search === true || (match.index === this.index))) { this.index = re.lastIndex; return match; } @@ -461,7 +449,7 @@ MessageFormatParser.prototype.errorInParseLogic = function errorInParseLogic() { }; MessageFormatParser.prototype.assertRuleOrNull = function assertRuleOrNull(rule) { - if (rule === void 0) { + if (rule === undefined) { this.errorInParseLogic(); } }; @@ -477,7 +465,7 @@ MessageFormatParser.prototype.errorExpecting = function errorExpecting() { position.line, position.column, this.text); } var word = match[1]; - if (word == "select" || word == "plural") { + if (word === 'select' || word === 'plural') { position = indexToLineAndColumn(this.text, this.index); throw $interpolateMinErr('reqcomma', 'Expected a comma after the keyword “{0}” at line {1}, column {2} of text “{3}”', @@ -505,7 +493,7 @@ MessageFormatParser.prototype.ruleString = function ruleString() { MessageFormatParser.prototype.startStringAtMatch = function startStringAtMatch(match) { this.stringStartIndex = match.index; this.stringQuote = match[0]; - this.stringInterestsRe = this.stringQuote == "'" ? SQUOTED_STRING_INTEREST_RE : DQUOTED_STRING_INTEREST_RE; + this.stringInterestsRe = this.stringQuote === '\'' ? SQUOTED_STRING_INTEREST_RE : DQUOTED_STRING_INTEREST_RE; this.rule = this.ruleInsideString; }; @@ -519,8 +507,7 @@ MessageFormatParser.prototype.ruleInsideString = function ruleInsideString() { 'The string beginning at line {0}, column {1} is unterminated in text “{2}”', position.line, position.column, this.text); } - var chars = match[0]; - if (match == this.stringQuote) { + if (match[0] === this.stringQuote) { this.rule = null; } }; @@ -533,8 +520,8 @@ MessageFormatParser.prototype.rulePluralOrSelect = function rulePluralOrSelect() } var argType = match[1]; switch (argType) { - case "plural": this.rule = this.rulePluralStyle; break; - case "select": this.rule = this.ruleSelectStyle; break; + case 'plural': this.rule = this.rulePluralStyle; break; + case 'select': this.rule = this.ruleSelectStyle; break; default: this.errorInParseLogic(); } }; @@ -552,7 +539,7 @@ MessageFormatParser.prototype.ruleSelectStyle = function ruleSelectStyle() { }; var NUMBER_RE = /[0]|(?:[1-9][0-9]*)/g; -var PLURAL_OFFSET_RE = new RegExp("\\s*offset\\s*:\\s*(" + NUMBER_RE.source + ")", "g"); +var PLURAL_OFFSET_RE = new RegExp('\\s*offset\\s*:\\s*(' + NUMBER_RE.source + ')', 'g'); MessageFormatParser.prototype.rulePluralOffset = function rulePluralOffset() { var match = this.matchRe(PLURAL_OFFSET_RE); @@ -562,7 +549,7 @@ MessageFormatParser.prototype.rulePluralOffset = function rulePluralOffset() { }; MessageFormatParser.prototype.assertChoiceKeyIsNew = function assertChoiceKeyIsNew(choiceKey, index) { - if (this.choices[choiceKey] !== void 0) { + if (this.choices[choiceKey] !== undefined) { var position = indexToLineAndColumn(this.text, index); throw $interpolateMinErr('dupvalue', 'The choice “{0}” is specified more than once. Duplicate key is at line {1}, column {2} in text “{3}”', @@ -583,7 +570,7 @@ MessageFormatParser.prototype.ruleSelectKeyword = function ruleSelectKeyword() { this.rule = this.ruleMessageText; }; -var EXPLICIT_VALUE_OR_KEYWORD_RE = new RegExp("\\s*(?:(?:=(" + NUMBER_RE.source + "))|(\\w+))", "g"); +var EXPLICIT_VALUE_OR_KEYWORD_RE = new RegExp('\\s*(?:(?:=(' + NUMBER_RE.source + '))|(\\w+))', 'g'); MessageFormatParser.prototype.rulePluralValueOrKeyword = function rulePluralValueOrKeyword() { var match = this.matchRe(EXPLICIT_VALUE_OR_KEYWORD_RE); if (match == null) { @@ -600,7 +587,7 @@ MessageFormatParser.prototype.rulePluralValueOrKeyword = function rulePluralValu this.rule = this.ruleMessageText; }; -var BRACE_OPEN_RE = /\s*{/g; +var BRACE_OPEN_RE = /\s*\{/g; var BRACE_CLOSE_RE = /}/g; MessageFormatParser.prototype.ruleMessageText = function ruleMessageText() { if (!this.consumeRe(BRACE_OPEN_RE)) { @@ -620,7 +607,7 @@ var INTERP_OR_END_MESSAGE_RE = /\\.|{{|}/g; var INTERP_OR_PLURALVALUE_OR_END_MESSAGE_RE = /\\.|{{|#|}/g; var ESCAPE_OR_MUSTACHE_BEGIN_RE = /\\.|{{/g; MessageFormatParser.prototype.advanceInInterpolationOrMessageText = function advanceInInterpolationOrMessageText() { - var currentIndex = this.index, match, re; + var currentIndex = this.index, match; if (this.ruleChoiceKeyword == null) { // interpolation match = this.searchRe(ESCAPE_OR_MUSTACHE_BEGIN_RE); if (match == null) { // End of interpolation text. Nothing more to process. @@ -629,7 +616,7 @@ MessageFormatParser.prototype.advanceInInterpolationOrMessageText = function adv return null; } } else { - match = this.searchRe(this.ruleChoiceKeyword == this.rulePluralValueOrKeyword ? + match = this.searchRe(this.ruleChoiceKeyword === this.rulePluralValueOrKeyword ? INTERP_OR_PLURALVALUE_OR_END_MESSAGE_RE : INTERP_OR_END_MESSAGE_RE); if (match == null) { var position = indexToLineAndColumn(this.text, this.msgStartIndex); @@ -654,20 +641,20 @@ MessageFormatParser.prototype.ruleInInterpolationOrMessageText = function ruleIn this.rule = null; return; } - if (token[0] == "\\") { + if (token[0] === '\\') { // unescape next character and continue this.interpolationParts.addText(this.textPart + token[1]); return; } this.interpolationParts.addText(this.textPart); - if (token == "{{") { + if (token === '{{') { this.pushState(); this.ruleStack.push(this.ruleEndMustacheInInterpolationOrMessage); this.rule = this.ruleEnteredMustache; - } else if (token == "}") { + } else if (token === '}') { this.choices[this.choiceKey] = this.interpolationParts.toParsedFn(/*mustHaveExpression=*/false, this.text); this.rule = this.ruleChoiceKeyword; - } else if (token == "#") { + } else if (token === '#') { this.interpolationParts.addExpressionFn(this.expressionMinusOffsetFn); } else { this.errorInParseLogic(); @@ -691,7 +678,7 @@ MessageFormatParser.prototype.ruleInInterpolation = function ruleInInterpolation return; } var token = match[0]; - if (token[0] == "\\") { + if (token[0] === '\\') { // unescape next character and continue this.interpolationParts.addText(this.text.substring(currentIndex, match.index) + token[1]); return; @@ -738,7 +725,7 @@ MessageFormatParser.prototype.ruleEndMustache = function ruleEndMustache() { // day), then the result *has* to be a string and those rules would have already set // this.parsedFn. If there was no MessageFormat extension, then there is no requirement to // stringify the result and parsedFn isn't set. We set it here. While we could have set it - // unconditionally when exiting the Angular expression, I intend for us to not just replace + // unconditionally when exiting the AngularJS expression, I intend for us to not just replace // $interpolate, but also to replace $parse in a future version (so ng-bind can work), and in // such a case we do not want to unnecessarily stringify something if it's not going to be used // in a string context. @@ -757,18 +744,18 @@ MessageFormatParser.prototype.ruleAngularExpression = function ruleAngularExpres function getEndOperator(opBegin) { switch (opBegin) { - case "{": return "}"; - case "[": return "]"; - case "(": return ")"; + case '{': return '}'; + case '[': return ']'; + case '(': return ')'; default: return null; } } function getBeginOperator(opEnd) { switch (opEnd) { - case "}": return "{"; - case "]": return "["; - case ")": return "("; + case '}': return '{'; + case ']': return '['; + case ')': return '('; default: return null; } } @@ -778,12 +765,11 @@ function getBeginOperator(opEnd) { // should support any other type of start/end interpolation symbol. var INTERESTING_OPERATORS_RE = /[[\]{}()'",]/g; MessageFormatParser.prototype.ruleInAngularExpression = function ruleInAngularExpression() { - var startIndex = this.index; var match = this.searchRe(INTERESTING_OPERATORS_RE); var position; if (match == null) { if (this.angularOperatorStack.length === 0) { - // This is the end of the Angular expression so this is actually a + // This is the end of the AngularJS expression so this is actually a // success. Note that when inside an interpolation, this means we even // consumed the closing interpolation symbols if they were curlies. This // is NOT an error at this point but will become an error further up the @@ -799,16 +785,16 @@ MessageFormatParser.prototype.ruleInAngularExpression = function ruleInAngularEx } var innermostOperator = this.angularOperatorStack[0]; throw $interpolateMinErr('badexpr', - 'Unexpected end of Angular expression. Expecting operator “{0}” at the end of the text “{1}”', + 'Unexpected end of AngularJS expression. Expecting operator “{0}” at the end of the text “{1}”', this.getEndOperator(innermostOperator), this.text); } var operator = match[0]; - if (operator == "'" || operator == '"') { + if (operator === '\'' || operator === '"') { this.ruleStack.push(this.ruleInAngularExpression); this.startStringAtMatch(match); return; } - if (operator == ",") { + if (operator === ',') { if (this.trustedContext) { position = indexToLineAndColumn(this.text, this.index); throw $interpolateMinErr('unsafe', @@ -836,7 +822,7 @@ MessageFormatParser.prototype.ruleInAngularExpression = function ruleInAngularEx this.errorInParseLogic(); } if (this.angularOperatorStack.length > 0) { - if (beginOperator == this.angularOperatorStack[0]) { + if (beginOperator === this.angularOperatorStack[0]) { this.angularOperatorStack.shift(); return; } @@ -864,7 +850,6 @@ MessageFormatParser.prototype.ruleInAngularExpression = function ruleInAngularEx /* global noop: true */ /* global toJson: true */ /* global MessageFormatParser: false */ -/* global stringify: false */ /** * @ngdoc module @@ -875,7 +860,7 @@ MessageFormatParser.prototype.ruleInAngularExpression = function ruleInAngularEx * * ## What is ngMessageFormat? * - * The ngMessageFormat module extends the Angular {@link ng.$interpolate `$interpolate`} service + * The ngMessageFormat module extends the AngularJS {@link ng.$interpolate `$interpolate`} service * with a syntax for handling pluralization and gender specific messages, which is based on the * [ICU MessageFormat syntax][ICU]. * @@ -909,9 +894,9 @@ MessageFormatParser.prototype.ruleInAngularExpression = function ruleInAngularEx * this.gender = gender; * } * - * var alice = new Person("Alice", "female"), - * bob = new Person("Bob", "male"), - * ashley = new Person("Ashley", ""); + * var alice = new Person('Alice', 'female'), + * bob = new Person('Bob', 'male'), + * ashley = new Person('Ashley', ''); * * angular.module('msgFmtExample', ['ngMessageFormat']) * .controller('AppController', ['$scope', function($scope) { @@ -952,11 +937,11 @@ MessageFormatParser.prototype.ruleInAngularExpression = function ruleInAngularEx * this.gender = gender; * } * - * var alice = new Person("Alice", "female"), - * bob = new Person("Bob", "male"), - * sarah = new Person("Sarah", "female"), - * harry = new Person("Harry Potter", "male"), - * ashley = new Person("Ashley", ""); + * var alice = new Person('Alice', 'female'), + * bob = new Person('Bob', 'male'), + * sarah = new Person('Sarah', 'female'), + * harry = new Person('Harry Potter', 'male'), + * ashley = new Person('Ashley', ''); * * angular.module('msgFmtExample', ['ngMessageFormat']) * .controller('AppController', ['$scope', function($scope) { @@ -1012,10 +997,10 @@ MessageFormatParser.prototype.ruleInAngularExpression = function ruleInAngularEx * this.gender = gender; * } * - * var alice = new Person("Alice", "female"), - * bob = new Person("Bob", "male"), - * harry = new Person("Harry Potter", "male"), - * ashley = new Person("Ashley", ""); + * var alice = new Person('Alice', 'female'), + * bob = new Person('Bob', 'male'), + * harry = new Person('Harry Potter', 'male'), + * ashley = new Person('Ashley', ''); * * angular.module('msgFmtExample', ['ngMessageFormat']) * .controller('AppController', ['$scope', function($scope) { @@ -1028,13 +1013,13 @@ MessageFormatParser.prototype.ruleInAngularExpression = function ruleInAngularEx */ var $$MessageFormatFactory = ['$parse', '$locale', '$sce', '$exceptionHandler', function $$messageFormat( - $parse, $locale, $sce, $exceptionHandler) { + $parse, $locale, $sce, $exceptionHandler) { function getStringifier(trustedContext, allOrNothing, text) { return function stringifier(value) { try { value = trustedContext ? $sce['getTrusted'](trustedContext, value) : $sce['valueOf'](value); - return allOrNothing && (value === void 0) ? value : stringify(value); + return allOrNothing && (value === undefined) ? value : $$stringify(value); } catch (err) { $exceptionHandler($interpolateMinErr['interr'](text, err)); } @@ -1055,7 +1040,7 @@ var $$MessageFormatFactory = ['$parse', '$locale', '$sce', '$exceptionHandler', }]; var $$interpolateDecorator = ['$$messageFormat', '$delegate', function $$interpolateDecorator($$messageFormat, $interpolate) { - if ($interpolate['startSymbol']() != "{{" || $interpolate['endSymbol']() != "}}") { + if ($interpolate['startSymbol']() !== '{{' || $interpolate['endSymbol']() !== '}}') { throw $interpolateMinErr('nochgmustache', 'angular-message-format.js currently does not allow you to use custom start and end symbols for interpolation.'); } var interpolate = $$messageFormat['interpolate']; @@ -1068,14 +1053,17 @@ var $interpolateMinErr; var isFunction; var noop; var toJson; +var $$stringify; -var module = window['angular']['module']('ngMessageFormat', ['ng']); -module['factory']('$$messageFormat', $$MessageFormatFactory); -module['config'](['$provide', function($provide) { +var ngModule = window['angular']['module']('ngMessageFormat', ['ng']); +ngModule['info']({ 'angularVersion': '"1.8.2"' }); +ngModule['factory']('$$messageFormat', $$MessageFormatFactory); +ngModule['config'](['$provide', function($provide) { $interpolateMinErr = window['angular']['$interpolateMinErr']; isFunction = window['angular']['isFunction']; noop = window['angular']['noop']; toJson = window['angular']['toJson']; + $$stringify = window['angular']['$$stringify']; $provide['decorator']('$interpolate', $$interpolateDecorator); }]); |