intl-messageformat 9.9.1 → 9.9.2

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.
@@ -1,5 +1,8 @@
1
1
  var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __require = typeof require !== "undefined" ? require : (x) => {
4
+ throw new Error('Dynamic require of "' + x + '" is not supported');
5
+ };
3
6
  var __publicField = (obj, key, value) => {
4
7
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
8
  return value;
@@ -231,7 +234,7 @@ function parseNumberSkeletonFromString(skeleton) {
231
234
  throw new Error("Invalid number skeleton");
232
235
  }
233
236
  }
234
- tokens.push({stem, options});
237
+ tokens.push({ stem, options });
235
238
  }
236
239
  return tokens;
237
240
  }
@@ -378,12 +381,12 @@ function parseNumberSkeleton(tokens) {
378
381
  result.compactDisplay = "long";
379
382
  continue;
380
383
  case "scientific":
381
- result = __assign(__assign(__assign({}, result), {notation: "scientific"}), token.options.reduce(function(all, opt) {
384
+ result = __assign(__assign(__assign({}, result), { notation: "scientific" }), token.options.reduce(function(all, opt) {
382
385
  return __assign(__assign({}, all), parseNotationOptions(opt));
383
386
  }, {}));
384
387
  continue;
385
388
  case "engineering":
386
- result = __assign(__assign(__assign({}, result), {notation: "engineering"}), token.options.reduce(function(all, opt) {
389
+ result = __assign(__assign(__assign({}, result), { notation: "engineering" }), token.options.reduce(function(all, opt) {
387
390
  return __assign(__assign({}, all), parseNotationOptions(opt));
388
391
  }, {}));
389
392
  continue;
@@ -472,7 +475,7 @@ var _a;
472
475
  var SPACE_SEPARATOR_START_REGEX = new RegExp("^" + SPACE_SEPARATOR_REGEX.source + "*");
473
476
  var SPACE_SEPARATOR_END_REGEX = new RegExp(SPACE_SEPARATOR_REGEX.source + "*$");
474
477
  function createLocation(start, end) {
475
- return {start, end};
478
+ return { start, end };
476
479
  }
477
480
  var hasNativeStartsWith = !!String.prototype.startsWith;
478
481
  var hasNativeFromCodePoint = !!String.fromCodePoint;
@@ -576,7 +579,7 @@ var Parser = function() {
576
579
  options = {};
577
580
  }
578
581
  this.message = message;
579
- this.position = {offset: 0, line: 1, column: 1};
582
+ this.position = { offset: 0, line: 1, column: 1 };
580
583
  this.ignoreTag = !!options.ignoreTag;
581
584
  this.requiresOtherClause = !!options.requiresOtherClause;
582
585
  this.shouldParseSkeletons = !!options.shouldParseSkeletons;
@@ -626,7 +629,7 @@ var Parser = function() {
626
629
  elements.push(result.val);
627
630
  }
628
631
  }
629
- return {val: elements, err: null};
632
+ return { val: elements, err: null };
630
633
  };
631
634
  Parser2.prototype.parseTag = function(nestingLevel, parentArgType) {
632
635
  var startPosition = this.clonePosition();
@@ -709,7 +712,7 @@ var Parser = function() {
709
712
  }
710
713
  var location = createLocation(start, this.clonePosition());
711
714
  return {
712
- val: {type: TYPE.literal, value, location},
715
+ val: { type: TYPE.literal, value, location },
713
716
  err: null
714
717
  };
715
718
  };
@@ -825,7 +828,7 @@ var Parser = function() {
825
828
  this.bumpTo(endOffset);
826
829
  var endPosition = this.clonePosition();
827
830
  var location = createLocation(startingPosition, endPosition);
828
- return {value, location};
831
+ return { value, location };
829
832
  };
830
833
  Parser2.prototype.parseArgumentOptions = function(nestingLevel, expectingCloseTag, value, openingBracePosition) {
831
834
  var _a2;
@@ -852,7 +855,7 @@ var Parser = function() {
852
855
  return this.error(ErrorKind.EXPECT_ARGUMENT_STYLE, createLocation(this.clonePosition(), this.clonePosition()));
853
856
  }
854
857
  var styleLocation = createLocation(styleStartPosition, this.clonePosition());
855
- styleAndLocation = {style, styleLocation};
858
+ styleAndLocation = { style, styleLocation };
856
859
  }
857
860
  var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
858
861
  if (argCloseResult.err) {
@@ -867,7 +870,7 @@ var Parser = function() {
867
870
  return result;
868
871
  }
869
872
  return {
870
- val: {type: TYPE.number, value, location: location_1, style: result.val},
873
+ val: { type: TYPE.number, value, location: location_1, style: result.val },
871
874
  err: null
872
875
  };
873
876
  } else {
@@ -882,7 +885,7 @@ var Parser = function() {
882
885
  };
883
886
  var type = argType === "date" ? TYPE.date : TYPE.time;
884
887
  return {
885
- val: {type, value, location: location_1, style},
888
+ val: { type, value, location: location_1, style },
886
889
  err: null
887
890
  };
888
891
  }
@@ -963,7 +966,7 @@ var Parser = function() {
963
966
  return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
964
967
  }
965
968
  this.bump();
966
- return {val: true, err: null};
969
+ return { val: true, err: null };
967
970
  };
968
971
  Parser2.prototype.parseSimpleArgStyleIfPossible = function() {
969
972
  var nestedBraces = 0;
@@ -1079,7 +1082,7 @@ var Parser = function() {
1079
1082
  if (this.requiresOtherClause && !hasOtherClause) {
1080
1083
  return this.error(ErrorKind.MISSING_OTHER_CLAUSE, createLocation(this.clonePosition(), this.clonePosition()));
1081
1084
  }
1082
- return {val: options, err: null};
1085
+ return { val: options, err: null };
1083
1086
  };
1084
1087
  Parser2.prototype.tryParseDecimalInteger = function(expectNumberError, invalidNumberError) {
1085
1088
  var sign = 1;
@@ -1108,7 +1111,7 @@ var Parser = function() {
1108
1111
  if (!isSafeInteger(decimal)) {
1109
1112
  return this.error(invalidNumberError, location);
1110
1113
  }
1111
- return {val: decimal, err: null};
1114
+ return { val: decimal, err: null };
1112
1115
  };
1113
1116
  Parser2.prototype.offset = function() {
1114
1117
  return this.position.offset;
@@ -1251,7 +1254,7 @@ function parse(message, opts) {
1251
1254
  if (opts === void 0) {
1252
1255
  opts = {};
1253
1256
  }
1254
- opts = __assign({shouldParseSkeletons: true, requiresOtherClause: true}, opts);
1257
+ opts = __assign({ shouldParseSkeletons: true, requiresOtherClause: true }, opts);
1255
1258
  var result = new Parser(message, opts).parse();
1256
1259
  if (result.err) {
1257
1260
  var error = SyntaxError(ErrorKind[result.err.kind]);
@@ -1417,7 +1420,7 @@ function formatToParts(els, locales, formatters, formats, values, currentPluralV
1417
1420
  }
1418
1421
  continue;
1419
1422
  }
1420
- const {value: varName} = el;
1423
+ const { value: varName } = el;
1421
1424
  if (!(values && varName in values)) {
1422
1425
  throw new MissingValueError(varName, originalMessage);
1423
1426
  }
@@ -1460,7 +1463,7 @@ function formatToParts(els, locales, formatters, formats, values, currentPluralV
1460
1463
  continue;
1461
1464
  }
1462
1465
  if (isTagElement(el)) {
1463
- const {children, value: value2} = el;
1466
+ const { children, value: value2 } = el;
1464
1467
  const formatFn = values[value2];
1465
1468
  if (!isFormatXMLElementFn(formatFn)) {
1466
1469
  throw new InvalidValueTypeError(value2, "function", originalMessage);
@@ -1493,7 +1496,7 @@ function formatToParts(els, locales, formatters, formats, values, currentPluralV
1493
1496
  Try polyfilling it using "@formatjs/intl-pluralrules"
1494
1497
  `, ErrorCode.MISSING_INTL_API, originalMessage);
1495
1498
  }
1496
- const rule = formatters.getPluralRules(locales, {type: el.pluralType}).select(value - (el.offset || 0));
1499
+ const rule = formatters.getPluralRules(locales, { type: el.pluralType }).select(value - (el.offset || 0));
1497
1500
  opt = el.options[rule] || el.options.other;
1498
1501
  }
1499
1502
  if (!opt) {
@@ -1530,7 +1533,7 @@ function mergeConfigs(defaultConfig, configs) {
1530
1533
  return Object.keys(defaultConfig).reduce((all, k) => {
1531
1534
  all[k] = mergeConfig(defaultConfig[k], configs[k]);
1532
1535
  return all;
1533
- }, {...defaultConfig});
1536
+ }, { ...defaultConfig });
1534
1537
  }
1535
1538
  function createFastMemoizeCache(store) {
1536
1539
  return {
@@ -1,8 +1,15 @@
1
1
  var IntlMessageFormat = (function() {
2
2
  var __defProp = Object.defineProperty;
3
+ var __markAsModule = function(target) {
4
+ return __defProp(target, "__esModule", { value: true });
5
+ };
6
+ var __require = typeof require !== "undefined" ? require : function(x) {
7
+ throw new Error('Dynamic require of "' + x + '" is not supported');
8
+ };
3
9
  var __export = function(target, all) {
10
+ __markAsModule(target);
4
11
  for (var name in all)
5
- __defProp(target, name, {get: all[name], enumerable: true});
12
+ __defProp(target, name, { get: all[name], enumerable: true });
6
13
  };
7
14
 
8
15
  // bazel-out/darwin-fastbuild/bin/packages/intl-messageformat/lib/index.js
@@ -42,7 +49,7 @@ var IntlMessageFormat = (function() {
42
49
 
43
50
  // node_modules/tslib/tslib.es6.js
44
51
  var extendStatics = function(d, b) {
45
- extendStatics = Object.setPrototypeOf || {__proto__: []} instanceof Array && function(d2, b2) {
52
+ extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
46
53
  d2.__proto__ = b2;
47
54
  } || function(d2, b2) {
48
55
  for (var p in b2)
@@ -296,7 +303,7 @@ var IntlMessageFormat = (function() {
296
303
  throw new Error("Invalid number skeleton");
297
304
  }
298
305
  }
299
- tokens.push({stem: stem, options: options});
306
+ tokens.push({ stem: stem, options: options });
300
307
  }
301
308
  return tokens;
302
309
  }
@@ -443,12 +450,12 @@ var IntlMessageFormat = (function() {
443
450
  result.compactDisplay = "long";
444
451
  continue;
445
452
  case "scientific":
446
- result = __assign(__assign(__assign({}, result), {notation: "scientific"}), token.options.reduce(function(all, opt) {
453
+ result = __assign(__assign(__assign({}, result), { notation: "scientific" }), token.options.reduce(function(all, opt) {
447
454
  return __assign(__assign({}, all), parseNotationOptions(opt));
448
455
  }, {}));
449
456
  continue;
450
457
  case "engineering":
451
- result = __assign(__assign(__assign({}, result), {notation: "engineering"}), token.options.reduce(function(all, opt) {
458
+ result = __assign(__assign(__assign({}, result), { notation: "engineering" }), token.options.reduce(function(all, opt) {
452
459
  return __assign(__assign({}, all), parseNotationOptions(opt));
453
460
  }, {}));
454
461
  continue;
@@ -537,7 +544,7 @@ var IntlMessageFormat = (function() {
537
544
  var SPACE_SEPARATOR_START_REGEX = new RegExp("^" + SPACE_SEPARATOR_REGEX.source + "*");
538
545
  var SPACE_SEPARATOR_END_REGEX = new RegExp(SPACE_SEPARATOR_REGEX.source + "*$");
539
546
  function createLocation(start, end) {
540
- return {start: start, end: end};
547
+ return { start: start, end: end };
541
548
  }
542
549
  var hasNativeStartsWith = !!String.prototype.startsWith;
543
550
  var hasNativeFromCodePoint = !!String.fromCodePoint;
@@ -641,7 +648,7 @@ var IntlMessageFormat = (function() {
641
648
  options = {};
642
649
  }
643
650
  this.message = message;
644
- this.position = {offset: 0, line: 1, column: 1};
651
+ this.position = { offset: 0, line: 1, column: 1 };
645
652
  this.ignoreTag = !!options.ignoreTag;
646
653
  this.requiresOtherClause = !!options.requiresOtherClause;
647
654
  this.shouldParseSkeletons = !!options.shouldParseSkeletons;
@@ -691,7 +698,7 @@ var IntlMessageFormat = (function() {
691
698
  elements.push(result.val);
692
699
  }
693
700
  }
694
- return {val: elements, err: null};
701
+ return { val: elements, err: null };
695
702
  };
696
703
  Parser2.prototype.parseTag = function(nestingLevel, parentArgType) {
697
704
  var startPosition = this.clonePosition();
@@ -774,7 +781,7 @@ var IntlMessageFormat = (function() {
774
781
  }
775
782
  var location = createLocation(start, this.clonePosition());
776
783
  return {
777
- val: {type: TYPE.literal, value: value, location: location},
784
+ val: { type: TYPE.literal, value: value, location: location },
778
785
  err: null
779
786
  };
780
787
  };
@@ -890,7 +897,7 @@ var IntlMessageFormat = (function() {
890
897
  this.bumpTo(endOffset);
891
898
  var endPosition = this.clonePosition();
892
899
  var location = createLocation(startingPosition, endPosition);
893
- return {value: value, location: location};
900
+ return { value: value, location: location };
894
901
  };
895
902
  Parser2.prototype.parseArgumentOptions = function(nestingLevel, expectingCloseTag, value, openingBracePosition) {
896
903
  var _a2;
@@ -917,7 +924,7 @@ var IntlMessageFormat = (function() {
917
924
  return this.error(ErrorKind.EXPECT_ARGUMENT_STYLE, createLocation(this.clonePosition(), this.clonePosition()));
918
925
  }
919
926
  var styleLocation = createLocation(styleStartPosition, this.clonePosition());
920
- styleAndLocation = {style: style, styleLocation: styleLocation};
927
+ styleAndLocation = { style: style, styleLocation: styleLocation };
921
928
  }
922
929
  var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
923
930
  if (argCloseResult.err) {
@@ -932,7 +939,7 @@ var IntlMessageFormat = (function() {
932
939
  return result;
933
940
  }
934
941
  return {
935
- val: {type: TYPE.number, value: value, location: location_1, style: result.val},
942
+ val: { type: TYPE.number, value: value, location: location_1, style: result.val },
936
943
  err: null
937
944
  };
938
945
  } else {
@@ -947,7 +954,7 @@ var IntlMessageFormat = (function() {
947
954
  };
948
955
  var type = argType === "date" ? TYPE.date : TYPE.time;
949
956
  return {
950
- val: {type: type, value: value, location: location_1, style: style},
957
+ val: { type: type, value: value, location: location_1, style: style },
951
958
  err: null
952
959
  };
953
960
  }
@@ -1028,7 +1035,7 @@ var IntlMessageFormat = (function() {
1028
1035
  return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
1029
1036
  }
1030
1037
  this.bump();
1031
- return {val: true, err: null};
1038
+ return { val: true, err: null };
1032
1039
  };
1033
1040
  Parser2.prototype.parseSimpleArgStyleIfPossible = function() {
1034
1041
  var nestedBraces = 0;
@@ -1144,7 +1151,7 @@ var IntlMessageFormat = (function() {
1144
1151
  if (this.requiresOtherClause && !hasOtherClause) {
1145
1152
  return this.error(ErrorKind.MISSING_OTHER_CLAUSE, createLocation(this.clonePosition(), this.clonePosition()));
1146
1153
  }
1147
- return {val: options, err: null};
1154
+ return { val: options, err: null };
1148
1155
  };
1149
1156
  Parser2.prototype.tryParseDecimalInteger = function(expectNumberError, invalidNumberError) {
1150
1157
  var sign = 1;
@@ -1173,7 +1180,7 @@ var IntlMessageFormat = (function() {
1173
1180
  if (!isSafeInteger(decimal)) {
1174
1181
  return this.error(invalidNumberError, location);
1175
1182
  }
1176
- return {val: decimal, err: null};
1183
+ return { val: decimal, err: null };
1177
1184
  };
1178
1185
  Parser2.prototype.offset = function() {
1179
1186
  return this.position.offset;
@@ -1316,7 +1323,7 @@ var IntlMessageFormat = (function() {
1316
1323
  if (opts === void 0) {
1317
1324
  opts = {};
1318
1325
  }
1319
- opts = __assign({shouldParseSkeletons: true, requiresOtherClause: true}, opts);
1326
+ opts = __assign({ shouldParseSkeletons: true, requiresOtherClause: true }, opts);
1320
1327
  var result = new Parser(message, opts).parse();
1321
1328
  if (result.err) {
1322
1329
  var error = SyntaxError(ErrorKind[result.err.kind]);
@@ -1566,7 +1573,7 @@ var IntlMessageFormat = (function() {
1566
1573
  if (!Intl.PluralRules) {
1567
1574
  throw new FormatError('Intl.PluralRules is not available in this environment.\nTry polyfilling it using "@formatjs/intl-pluralrules"\n', ErrorCode.MISSING_INTL_API, originalMessage);
1568
1575
  }
1569
- var rule = formatters.getPluralRules(locales, {type: el.pluralType}).select(value - (el.offset || 0));
1576
+ var rule = formatters.getPluralRules(locales, { type: el.pluralType }).select(value - (el.offset || 0));
1570
1577
  opt = el.options[rule] || el.options.other;
1571
1578
  }
1572
1579
  if (!opt) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intl-messageformat",
3
- "version": "9.9.1",
3
+ "version": "9.9.2",
4
4
  "description": "Formats ICU Message strings with number, date, plural, and select placeholders to create localized messages.",
5
5
  "keywords": [
6
6
  "i18n",
@@ -32,7 +32,7 @@
32
32
  "types": "index.d.ts",
33
33
  "dependencies": {
34
34
  "@formatjs/fast-memoize": "1.2.0",
35
- "@formatjs/icu-messageformat-parser": "2.0.11",
35
+ "@formatjs/icu-messageformat-parser": "2.0.12",
36
36
  "tslib": "^2.1.0"
37
37
  },
38
38
  "sideEffects": false,