intl-messageformat 9.6.4 → 9.6.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,20 +8,16 @@ var IntlMessageFormat = (function() {
8
8
  var __markAsModule = function(target) {
9
9
  return __defProp(target, "__esModule", {value: true});
10
10
  };
11
- var __commonJS = function(callback, module) {
11
+ var __commonJS = function(cb, mod) {
12
12
  return function() {
13
- if (!module) {
14
- module = {exports: {}};
15
- callback(module.exports, module);
16
- }
17
- return module.exports;
13
+ return mod || cb((mod = {exports: {}}).exports, mod), mod.exports;
18
14
  };
19
15
  };
20
16
  var __export = function(target, all) {
21
17
  for (var name in all)
22
18
  __defProp(target, name, {get: all[name], enumerable: true});
23
19
  };
24
- var __exportStar = function(target, module, desc) {
20
+ var __reExport = function(target, module, desc) {
25
21
  if (module && typeof module === "object" || typeof module === "function")
26
22
  for (var keys = __getOwnPropNames(module), i = 0, n = keys.length, key; i < n; i++) {
27
23
  key = keys[i];
@@ -33,9 +29,9 @@ var IntlMessageFormat = (function() {
33
29
  return target;
34
30
  };
35
31
  var __toModule = function(module) {
36
- if (module && module.__esModule)
37
- return module;
38
- return __exportStar(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", {value: module, enumerable: true})), module);
32
+ return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? {get: function() {
33
+ return module.default;
34
+ }, enumerable: true} : {value: module, enumerable: true})), module);
39
35
  };
40
36
 
41
37
  // external/npm/node_modules/tslib/tslib.js
@@ -62,7 +58,7 @@ var IntlMessageFormat = (function() {
62
58
  var __metadata;
63
59
  var __awaiter;
64
60
  var __generator;
65
- var __exportStar2;
61
+ var __exportStar;
66
62
  var __values;
67
63
  var __read;
68
64
  var __spread;
@@ -261,7 +257,7 @@ var IntlMessageFormat = (function() {
261
257
  return {value: op[0] ? op[1] : void 0, done: true};
262
258
  }
263
259
  };
264
- __exportStar2 = function(m, o) {
260
+ __exportStar = function(m, o) {
265
261
  for (var p in m)
266
262
  if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
267
263
  __createBinding(o, m, p);
@@ -430,18 +426,21 @@ var IntlMessageFormat = (function() {
430
426
  __importDefault = function(mod) {
431
427
  return mod && mod.__esModule ? mod : {default: mod};
432
428
  };
433
- __classPrivateFieldGet = function(receiver, privateMap) {
434
- if (!privateMap.has(receiver)) {
435
- throw new TypeError("attempted to get private field on non-instance");
436
- }
437
- return privateMap.get(receiver);
429
+ __classPrivateFieldGet = function(receiver, state, kind, f) {
430
+ if (kind === "a" && !f)
431
+ throw new TypeError("Private accessor was defined without a getter");
432
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
433
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
434
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
438
435
  };
439
- __classPrivateFieldSet = function(receiver, privateMap, value) {
440
- if (!privateMap.has(receiver)) {
441
- throw new TypeError("attempted to set private field on non-instance");
442
- }
443
- privateMap.set(receiver, value);
444
- return value;
436
+ __classPrivateFieldSet = function(receiver, state, value, kind, f) {
437
+ if (kind === "m")
438
+ throw new TypeError("Private method is not writable");
439
+ if (kind === "a" && !f)
440
+ throw new TypeError("Private accessor was defined without a setter");
441
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
442
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
443
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
445
444
  };
446
445
  exporter("__extends", __extends2);
447
446
  exporter("__assign", __assign2);
@@ -451,7 +450,7 @@ var IntlMessageFormat = (function() {
451
450
  exporter("__metadata", __metadata);
452
451
  exporter("__awaiter", __awaiter);
453
452
  exporter("__generator", __generator);
454
- exporter("__exportStar", __exportStar2);
453
+ exporter("__exportStar", __exportStar);
455
454
  exporter("__createBinding", __createBinding);
456
455
  exporter("__values", __values);
457
456
  exporter("__read", __read);
@@ -993,6 +992,7 @@ var IntlMessageFormat = (function() {
993
992
  // bazel-out/darwin-fastbuild/bin/packages/icu-messageformat-parser/parser.js
994
993
  var require_parser = __commonJS(function(exports) {
995
994
  "use strict";
995
+ var _a;
996
996
  Object.defineProperty(exports, "__esModule", {value: true});
997
997
  exports.Parser = void 0;
998
998
  var tslib_1 = require_tslib();
@@ -1015,10 +1015,12 @@ var IntlMessageFormat = (function() {
1015
1015
  };
1016
1016
  var REGEX_SUPPORTS_U_AND_Y = true;
1017
1017
  try {
1018
- RE("([^\\p{White_Space}\\p{Pattern_Syntax}]*)", "yu");
1018
+ re = RE("([^\\p{White_Space}\\p{Pattern_Syntax}]*)", "yu");
1019
+ REGEX_SUPPORTS_U_AND_Y = ((_a = re.exec("a")) === null || _a === void 0 ? void 0 : _a[0]) === "a";
1019
1020
  } catch (_) {
1020
1021
  REGEX_SUPPORTS_U_AND_Y = false;
1021
1022
  }
1023
+ var re;
1022
1024
  var startsWith = hasNativeStartsWith ? function startsWith2(s, search, position) {
1023
1025
  return s.startsWith(search, position);
1024
1026
  } : function startsWith2(s, search, position) {
@@ -1044,7 +1046,7 @@ var IntlMessageFormat = (function() {
1044
1046
  var fromEntries = hasNativeFromEntries ? Object.fromEntries : function fromEntries2(entries) {
1045
1047
  var obj = {};
1046
1048
  for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
1047
- var _a = entries_1[_i], k = _a[0], v = _a[1];
1049
+ var _a2 = entries_1[_i], k = _a2[0], v = _a2[1];
1048
1050
  obj[k] = v;
1049
1051
  }
1050
1052
  return obj;
@@ -1077,10 +1079,10 @@ var IntlMessageFormat = (function() {
1077
1079
  if (REGEX_SUPPORTS_U_AND_Y) {
1078
1080
  IDENTIFIER_PREFIX_RE_1 = RE("([^\\p{White_Space}\\p{Pattern_Syntax}]*)", "yu");
1079
1081
  matchIdentifierAtIndex = function matchIdentifierAtIndex2(s, index) {
1080
- var _a;
1082
+ var _a2;
1081
1083
  IDENTIFIER_PREFIX_RE_1.lastIndex = index;
1082
1084
  var match = IDENTIFIER_PREFIX_RE_1.exec(s);
1083
- return (_a = match[1]) !== null && _a !== void 0 ? _a : "";
1085
+ return (_a2 = match[1]) !== null && _a2 !== void 0 ? _a2 : "";
1084
1086
  };
1085
1087
  } else {
1086
1088
  matchIdentifierAtIndex = function matchIdentifierAtIndex2(s, index) {
@@ -1355,7 +1357,7 @@ var IntlMessageFormat = (function() {
1355
1357
  return {value: value, location: location};
1356
1358
  };
1357
1359
  Parser2.prototype.parseArgumentOptions = function(nestingLevel, expectingCloseTag, value, openingBracePosition) {
1358
- var _a;
1360
+ var _a2;
1359
1361
  var typeStartPosition = this.clonePosition();
1360
1362
  var argType = this.parseIdentifierIfPossible().value;
1361
1363
  var typeEndPosition = this.clonePosition();
@@ -1419,7 +1421,7 @@ var IntlMessageFormat = (function() {
1419
1421
  type: argType === "number" ? types_1.TYPE.number : argType === "date" ? types_1.TYPE.date : types_1.TYPE.time,
1420
1422
  value: value,
1421
1423
  location: location_1,
1422
- style: (_a = styleAndLocation === null || styleAndLocation === void 0 ? void 0 : styleAndLocation.style) !== null && _a !== void 0 ? _a : null
1424
+ style: (_a2 = styleAndLocation === null || styleAndLocation === void 0 ? void 0 : styleAndLocation.style) !== null && _a2 !== void 0 ? _a2 : null
1423
1425
  },
1424
1426
  err: null
1425
1427
  };
@@ -1551,7 +1553,7 @@ var IntlMessageFormat = (function() {
1551
1553
  };
1552
1554
  };
1553
1555
  Parser2.prototype.tryParsePluralOrSelectOptions = function(nestingLevel, parentArgType, expectCloseTag, parsedFirstIdentifier) {
1554
- var _a;
1556
+ var _a2;
1555
1557
  var hasOtherClause = false;
1556
1558
  var options = [];
1557
1559
  var parsedSelectors = new Set();
@@ -1598,7 +1600,7 @@ var IntlMessageFormat = (function() {
1598
1600
  ]);
1599
1601
  parsedSelectors.add(selector);
1600
1602
  this.bumpSpace();
1601
- _a = this.parseIdentifierIfPossible(), selector = _a.value, selectorLocation = _a.location;
1603
+ _a2 = this.parseIdentifierIfPossible(), selector = _a2.value, selectorLocation = _a2.location;
1602
1604
  }
1603
1605
  if (options.length === 0) {
1604
1606
  return this.error(parentArgType === "select" ? error_1.ErrorKind.EXPECT_SELECT_ARGUMENT_SELECTOR : error_1.ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR, createLocation(this.clonePosition(), this.clonePosition()));
@@ -1742,7 +1744,7 @@ var IntlMessageFormat = (function() {
1742
1744
  }();
1743
1745
  exports.Parser = Parser;
1744
1746
  function _isAlpha(codepoint) {
1745
- return codepoint >= 97 && codepoint <= 122;
1747
+ return codepoint >= 97 && codepoint <= 122 || codepoint >= 65 && codepoint <= 90;
1746
1748
  }
1747
1749
  function _isAlphaOrSlash(codepoint) {
1748
1750
  return _isAlpha(codepoint) || codepoint === 47;
@@ -1793,6 +1795,7 @@ var IntlMessageFormat = (function() {
1793
1795
  if (result.err) {
1794
1796
  var error = SyntaxError(error_1.ErrorKind[result.err.kind]);
1795
1797
  error.location = result.err.location;
1798
+ error.originalMessage = result.err.message;
1796
1799
  throw error;
1797
1800
  }
1798
1801
  if (!(opts === null || opts === void 0 ? void 0 : opts.captureLocation)) {
@@ -1931,7 +1934,7 @@ var IntlMessageFormat = (function() {
1931
1934
  ErrorCode2["MISSING_INTL_API"] = "MISSING_INTL_API";
1932
1935
  })(ErrorCode || (ErrorCode = {}));
1933
1936
  var FormatError = function(_super) {
1934
- import_tslib.__extends(FormatError2, _super);
1937
+ (0, import_tslib.__extends)(FormatError2, _super);
1935
1938
  function FormatError2(msg, code, originalMessage) {
1936
1939
  var _this = _super.call(this, msg) || this;
1937
1940
  _this.code = code;
@@ -1944,21 +1947,21 @@ var IntlMessageFormat = (function() {
1944
1947
  return FormatError2;
1945
1948
  }(Error);
1946
1949
  var InvalidValueError = function(_super) {
1947
- import_tslib.__extends(InvalidValueError2, _super);
1950
+ (0, import_tslib.__extends)(InvalidValueError2, _super);
1948
1951
  function InvalidValueError2(variableId, value, options, originalMessage) {
1949
1952
  return _super.call(this, 'Invalid values for "' + variableId + '": "' + value + '". Options are "' + Object.keys(options).join('", "') + '"', ErrorCode.INVALID_VALUE, originalMessage) || this;
1950
1953
  }
1951
1954
  return InvalidValueError2;
1952
1955
  }(FormatError);
1953
1956
  var InvalidValueTypeError = function(_super) {
1954
- import_tslib.__extends(InvalidValueTypeError2, _super);
1957
+ (0, import_tslib.__extends)(InvalidValueTypeError2, _super);
1955
1958
  function InvalidValueTypeError2(value, type, originalMessage) {
1956
1959
  return _super.call(this, 'Value for "' + value + '" must be of type ' + type, ErrorCode.INVALID_VALUE, originalMessage) || this;
1957
1960
  }
1958
1961
  return InvalidValueTypeError2;
1959
1962
  }(FormatError);
1960
1963
  var MissingValueError = function(_super) {
1961
- import_tslib.__extends(MissingValueError2, _super);
1964
+ (0, import_tslib.__extends)(MissingValueError2, _super);
1962
1965
  function MissingValueError2(variableId, originalMessage) {
1963
1966
  return _super.call(this, 'The intl string context variable "' + variableId + '" was not provided to the string "' + originalMessage + '"', ErrorCode.MISSING_VALUE, originalMessage) || this;
1964
1967
  }
@@ -1989,7 +1992,7 @@ var IntlMessageFormat = (function() {
1989
1992
  return typeof el === "function";
1990
1993
  }
1991
1994
  function formatToParts(els, locales, formatters, formats, values, currentPluralValue, originalMessage) {
1992
- if (els.length === 1 && import_icu_messageformat_parser.isLiteralElement(els[0])) {
1995
+ if (els.length === 1 && (0, import_icu_messageformat_parser.isLiteralElement)(els[0])) {
1993
1996
  return [
1994
1997
  {
1995
1998
  type: PART_TYPE.literal,
@@ -2000,14 +2003,14 @@ var IntlMessageFormat = (function() {
2000
2003
  var result = [];
2001
2004
  for (var _i = 0, els_1 = els; _i < els_1.length; _i++) {
2002
2005
  var el = els_1[_i];
2003
- if (import_icu_messageformat_parser.isLiteralElement(el)) {
2006
+ if ((0, import_icu_messageformat_parser.isLiteralElement)(el)) {
2004
2007
  result.push({
2005
2008
  type: PART_TYPE.literal,
2006
2009
  value: el.value
2007
2010
  });
2008
2011
  continue;
2009
2012
  }
2010
- if (import_icu_messageformat_parser.isPoundElement(el)) {
2013
+ if ((0, import_icu_messageformat_parser.isPoundElement)(el)) {
2011
2014
  if (typeof currentPluralValue === "number") {
2012
2015
  result.push({
2013
2016
  type: PART_TYPE.literal,
@@ -2021,7 +2024,7 @@ var IntlMessageFormat = (function() {
2021
2024
  throw new MissingValueError(varName, originalMessage);
2022
2025
  }
2023
2026
  var value = values[varName];
2024
- if (import_icu_messageformat_parser.isArgumentElement(el)) {
2027
+ if ((0, import_icu_messageformat_parser.isArgumentElement)(el)) {
2025
2028
  if (!value || typeof value === "string" || typeof value === "number") {
2026
2029
  value = typeof value === "string" || typeof value === "number" ? String(value) : "";
2027
2030
  }
@@ -2031,24 +2034,24 @@ var IntlMessageFormat = (function() {
2031
2034
  });
2032
2035
  continue;
2033
2036
  }
2034
- if (import_icu_messageformat_parser.isDateElement(el)) {
2035
- var style = typeof el.style === "string" ? formats.date[el.style] : import_icu_messageformat_parser.isDateTimeSkeleton(el.style) ? el.style.parsedOptions : void 0;
2037
+ if ((0, import_icu_messageformat_parser.isDateElement)(el)) {
2038
+ var style = typeof el.style === "string" ? formats.date[el.style] : (0, import_icu_messageformat_parser.isDateTimeSkeleton)(el.style) ? el.style.parsedOptions : void 0;
2036
2039
  result.push({
2037
2040
  type: PART_TYPE.literal,
2038
2041
  value: formatters.getDateTimeFormat(locales, style).format(value)
2039
2042
  });
2040
2043
  continue;
2041
2044
  }
2042
- if (import_icu_messageformat_parser.isTimeElement(el)) {
2043
- var style = typeof el.style === "string" ? formats.time[el.style] : import_icu_messageformat_parser.isDateTimeSkeleton(el.style) ? el.style.parsedOptions : void 0;
2045
+ if ((0, import_icu_messageformat_parser.isTimeElement)(el)) {
2046
+ var style = typeof el.style === "string" ? formats.time[el.style] : (0, import_icu_messageformat_parser.isDateTimeSkeleton)(el.style) ? el.style.parsedOptions : void 0;
2044
2047
  result.push({
2045
2048
  type: PART_TYPE.literal,
2046
2049
  value: formatters.getDateTimeFormat(locales, style).format(value)
2047
2050
  });
2048
2051
  continue;
2049
2052
  }
2050
- if (import_icu_messageformat_parser.isNumberElement(el)) {
2051
- var style = typeof el.style === "string" ? formats.number[el.style] : import_icu_messageformat_parser.isNumberSkeleton(el.style) ? el.style.parsedOptions : void 0;
2053
+ if ((0, import_icu_messageformat_parser.isNumberElement)(el)) {
2054
+ var style = typeof el.style === "string" ? formats.number[el.style] : (0, import_icu_messageformat_parser.isNumberSkeleton)(el.style) ? el.style.parsedOptions : void 0;
2052
2055
  if (style && style.scale) {
2053
2056
  value = value * (style.scale || 1);
2054
2057
  }
@@ -2058,7 +2061,7 @@ var IntlMessageFormat = (function() {
2058
2061
  });
2059
2062
  continue;
2060
2063
  }
2061
- if (import_icu_messageformat_parser.isTagElement(el)) {
2064
+ if ((0, import_icu_messageformat_parser.isTagElement)(el)) {
2062
2065
  var children = el.children, value_1 = el.value;
2063
2066
  var formatFn = values[value_1];
2064
2067
  if (!isFormatXMLElementFn(formatFn)) {
@@ -2078,7 +2081,7 @@ var IntlMessageFormat = (function() {
2078
2081
  };
2079
2082
  }));
2080
2083
  }
2081
- if (import_icu_messageformat_parser.isSelectElement(el)) {
2084
+ if ((0, import_icu_messageformat_parser.isSelectElement)(el)) {
2082
2085
  var opt = el.options[value] || el.options.other;
2083
2086
  if (!opt) {
2084
2087
  throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);
@@ -2086,7 +2089,7 @@ var IntlMessageFormat = (function() {
2086
2089
  result.push.apply(result, formatToParts(opt.value, locales, formatters, formats, values));
2087
2090
  continue;
2088
2091
  }
2089
- if (import_icu_messageformat_parser.isPluralElement(el)) {
2092
+ if ((0, import_icu_messageformat_parser.isPluralElement)(el)) {
2090
2093
  var opt = el.options["=" + value];
2091
2094
  if (!opt) {
2092
2095
  if (!Intl.PluralRules) {
@@ -2110,8 +2113,8 @@ var IntlMessageFormat = (function() {
2110
2113
  if (!c2) {
2111
2114
  return c1;
2112
2115
  }
2113
- return import_tslib2.__assign(import_tslib2.__assign(import_tslib2.__assign({}, c1 || {}), c2 || {}), Object.keys(c1).reduce(function(all, k) {
2114
- all[k] = import_tslib2.__assign(import_tslib2.__assign({}, c1[k]), c2[k] || {});
2116
+ return (0, import_tslib2.__assign)((0, import_tslib2.__assign)((0, import_tslib2.__assign)({}, c1 || {}), c2 || {}), Object.keys(c1).reduce(function(all, k) {
2117
+ all[k] = (0, import_tslib2.__assign)((0, import_tslib2.__assign)({}, c1[k]), c2[k] || {});
2115
2118
  return all;
2116
2119
  }, {}));
2117
2120
  }
@@ -2122,7 +2125,7 @@ var IntlMessageFormat = (function() {
2122
2125
  return Object.keys(defaultConfig).reduce(function(all, k) {
2123
2126
  all[k] = mergeConfig(defaultConfig[k], configs[k]);
2124
2127
  return all;
2125
- }, import_tslib2.__assign({}, defaultConfig));
2128
+ }, (0, import_tslib2.__assign)({}, defaultConfig));
2126
2129
  }
2127
2130
  function createFastMemoizeCache(store) {
2128
2131
  return {
@@ -2158,7 +2161,7 @@ var IntlMessageFormat = (function() {
2158
2161
  for (var _i = 0; _i < arguments.length; _i++) {
2159
2162
  args[_i] = arguments[_i];
2160
2163
  }
2161
- return new ((_a = Intl.NumberFormat).bind.apply(_a, import_tslib2.__spreadArray([void 0], args)))();
2164
+ return new ((_a = Intl.NumberFormat).bind.apply(_a, (0, import_tslib2.__spreadArray)([void 0], args)))();
2162
2165
  }, {
2163
2166
  cache: createFastMemoizeCache(cache.number),
2164
2167
  strategy: memoizeIntl.strategies.variadic
@@ -2169,7 +2172,7 @@ var IntlMessageFormat = (function() {
2169
2172
  for (var _i = 0; _i < arguments.length; _i++) {
2170
2173
  args[_i] = arguments[_i];
2171
2174
  }
2172
- return new ((_a = Intl.DateTimeFormat).bind.apply(_a, import_tslib2.__spreadArray([void 0], args)))();
2175
+ return new ((_a = Intl.DateTimeFormat).bind.apply(_a, (0, import_tslib2.__spreadArray)([void 0], args)))();
2173
2176
  }, {
2174
2177
  cache: createFastMemoizeCache(cache.dateTime),
2175
2178
  strategy: memoizeIntl.strategies.variadic
@@ -2180,7 +2183,7 @@ var IntlMessageFormat = (function() {
2180
2183
  for (var _i = 0; _i < arguments.length; _i++) {
2181
2184
  args[_i] = arguments[_i];
2182
2185
  }
2183
- return new ((_a = Intl.PluralRules).bind.apply(_a, import_tslib2.__spreadArray([void 0], args)))();
2186
+ return new ((_a = Intl.PluralRules).bind.apply(_a, (0, import_tslib2.__spreadArray)([void 0], args)))();
2184
2187
  }, {
2185
2188
  cache: createFastMemoizeCache(cache.pluralRules),
2186
2189
  strategy: memoizeIntl.strategies.variadic
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intl-messageformat",
3
- "version": "9.6.4",
3
+ "version": "9.6.8",
4
4
  "description": "Formats ICU Message strings with number, date, plural, and select placeholders to create localized messages.",
5
5
  "keywords": [
6
6
  "i18n",
@@ -31,7 +31,7 @@
31
31
  "module": "lib/index.js",
32
32
  "types": "index.d.ts",
33
33
  "dependencies": {
34
- "@formatjs/icu-messageformat-parser": "1.1.2",
34
+ "@formatjs/icu-messageformat-parser": "1.1.6",
35
35
  "fast-memoize": "^2.5.2",
36
36
  "tslib": "^2.1.0"
37
37
  },