intl-messageformat 11.1.3 → 11.2.0

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,37 +1,9 @@
1
1
  var IntlMessageFormat = (() => {
2
2
  var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
6
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
- var __spreadValues = (a, b) => {
12
- for (var prop in b || (b = {}))
13
- if (__hasOwnProp.call(b, prop))
14
- __defNormalProp(a, prop, b[prop]);
15
- if (__getOwnPropSymbols)
16
- for (var prop of __getOwnPropSymbols(b)) {
17
- if (__propIsEnum.call(b, prop))
18
- __defNormalProp(a, prop, b[prop]);
19
- }
20
- return a;
21
- };
22
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
23
- var __objRest = (source, exclude) => {
24
- var target = {};
25
- for (var prop in source)
26
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
27
- target[prop] = source[prop];
28
- if (source != null && __getOwnPropSymbols)
29
- for (var prop of __getOwnPropSymbols(source)) {
30
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
31
- target[prop] = source[prop];
32
- }
33
- return target;
34
- };
35
7
  var __export = (target, all) => {
36
8
  for (var name in all)
37
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -411,14 +383,24 @@ var IntlMessageFormat = (() => {
411
383
  result.compactDisplay = "long";
412
384
  continue;
413
385
  case "scientific":
414
- result = __spreadValues(__spreadProps(__spreadValues({}, result), {
415
- notation: "scientific"
416
- }), token.options.reduce((all, opt) => __spreadValues(__spreadValues({}, all), parseNotationOptions(opt)), {}));
386
+ result = {
387
+ ...result,
388
+ notation: "scientific",
389
+ ...token.options.reduce((all, opt) => ({
390
+ ...all,
391
+ ...parseNotationOptions(opt)
392
+ }), {})
393
+ };
417
394
  continue;
418
395
  case "engineering":
419
- result = __spreadValues(__spreadProps(__spreadValues({}, result), {
420
- notation: "engineering"
421
- }), token.options.reduce((all, opt) => __spreadValues(__spreadValues({}, all), parseNotationOptions(opt)), {}));
396
+ result = {
397
+ ...result,
398
+ notation: "engineering",
399
+ ...token.options.reduce((all, opt) => ({
400
+ ...all,
401
+ ...parseNotationOptions(opt)
402
+ }), {})
403
+ };
422
404
  continue;
423
405
  case "notation-simple":
424
406
  result.notation = "standard";
@@ -502,25 +484,38 @@ var IntlMessageFormat = (() => {
502
484
  });
503
485
  const opt = token.options[0];
504
486
  if (opt === "w") {
505
- result = __spreadProps(__spreadValues({}, result), {
487
+ result = {
488
+ ...result,
506
489
  trailingZeroDisplay: "stripIfInteger"
507
- });
490
+ };
508
491
  } else if (opt) {
509
- result = __spreadValues(__spreadValues({}, result), parseSignificantPrecision(opt));
492
+ result = {
493
+ ...result,
494
+ ...parseSignificantPrecision(opt)
495
+ };
510
496
  }
511
497
  continue;
512
498
  }
513
499
  if (SIGNIFICANT_PRECISION_REGEX.test(token.stem)) {
514
- result = __spreadValues(__spreadValues({}, result), parseSignificantPrecision(token.stem));
500
+ result = {
501
+ ...result,
502
+ ...parseSignificantPrecision(token.stem)
503
+ };
515
504
  continue;
516
505
  }
517
506
  const signOpts = parseSign(token.stem);
518
507
  if (signOpts) {
519
- result = __spreadValues(__spreadValues({}, result), signOpts);
508
+ result = {
509
+ ...result,
510
+ ...signOpts
511
+ };
520
512
  }
521
513
  const conciseScientificAndEngineeringOpts = parseConciseScientificAndEngineeringStem(token.stem);
522
514
  if (conciseScientificAndEngineeringOpts) {
523
- result = __spreadValues(__spreadValues({}, result), conciseScientificAndEngineeringOpts);
515
+ result = {
516
+ ...result,
517
+ ...conciseScientificAndEngineeringOpts
518
+ };
524
519
  }
525
520
  }
526
521
  return result;
@@ -1868,10 +1863,9 @@ var IntlMessageFormat = (() => {
1868
1863
  };
1869
1864
  var IDENTIFIER_PREFIX_RE = new RegExp("([^\\p{White_Space}\\p{Pattern_Syntax}]*)", "yu");
1870
1865
  function matchIdentifierAtIndex(s, index) {
1871
- var _a;
1872
1866
  IDENTIFIER_PREFIX_RE.lastIndex = index;
1873
1867
  const match = IDENTIFIER_PREFIX_RE.exec(s);
1874
- return (_a = match[1]) != null ? _a : "";
1868
+ return match[1] ?? "";
1875
1869
  }
1876
1870
  var Parser = class {
1877
1871
  constructor(message, options = {}) {
@@ -2179,7 +2173,6 @@ var IntlMessageFormat = (() => {
2179
2173
  };
2180
2174
  }
2181
2175
  parseArgumentOptions(nestingLevel, expectingCloseTag, value, openingBracePosition) {
2182
- var _a;
2183
2176
  let typeStartPosition = this.clonePosition();
2184
2177
  let argType = this.parseIdentifierIfPossible().value;
2185
2178
  let typeEndPosition = this.clonePosition();
@@ -2260,7 +2253,7 @@ var IntlMessageFormat = (() => {
2260
2253
  type: argType === "number" ? TYPE.number : argType === "date" ? TYPE.date : TYPE.time,
2261
2254
  value,
2262
2255
  location,
2263
- style: (_a = styleAndLocation == null ? void 0 : styleAndLocation.style) != null ? _a : null
2256
+ style: styleAndLocation?.style ?? null
2264
2257
  },
2265
2258
  err: null
2266
2259
  };
@@ -2271,7 +2264,7 @@ var IntlMessageFormat = (() => {
2271
2264
  const typeEndPosition2 = this.clonePosition();
2272
2265
  this.bumpSpace();
2273
2266
  if (!this.bumpIf(",")) {
2274
- return this.error(ErrorKind.EXPECT_SELECT_ARGUMENT_OPTIONS, createLocation(typeEndPosition2, __spreadValues({}, typeEndPosition2)));
2267
+ return this.error(ErrorKind.EXPECT_SELECT_ARGUMENT_OPTIONS, createLocation(typeEndPosition2, { ...typeEndPosition2 }));
2275
2268
  }
2276
2269
  this.bumpSpace();
2277
2270
  let identifierAndLocation = this.parseIdentifierIfPossible();
@@ -2384,7 +2377,7 @@ var IntlMessageFormat = (() => {
2384
2377
  let tokens = [];
2385
2378
  try {
2386
2379
  tokens = parseNumberSkeletonFromString(skeleton);
2387
- } catch (e) {
2380
+ } catch {
2388
2381
  return this.error(ErrorKind.INVALID_NUMBER_SKELETON, location);
2389
2382
  }
2390
2383
  return {
@@ -2619,7 +2612,7 @@ var IntlMessageFormat = (() => {
2619
2612
  const code = this.char();
2620
2613
  const offset = this.offset();
2621
2614
  const nextCode = this.message.charCodeAt(offset + (code >= 65536 ? 2 : 1));
2622
- return nextCode != null ? nextCode : null;
2615
+ return nextCode ?? null;
2623
2616
  }
2624
2617
  };
2625
2618
  function _isAlpha(codepoint) {
@@ -2654,10 +2647,11 @@ var IntlMessageFormat = (() => {
2654
2647
  });
2655
2648
  }
2656
2649
  function parse(message, opts = {}) {
2657
- opts = __spreadValues({
2650
+ opts = {
2658
2651
  shouldParseSkeletons: true,
2659
- requiresOtherClause: true
2660
- }, opts);
2652
+ requiresOtherClause: true,
2653
+ ...opts
2654
+ };
2661
2655
  const result = new Parser(message, opts).parse();
2662
2656
  if (result.err) {
2663
2657
  const error = SyntaxError(ErrorKind[result.err.kind]);
@@ -2665,7 +2659,7 @@ var IntlMessageFormat = (() => {
2665
2659
  error.originalMessage = result.err.message;
2666
2660
  throw error;
2667
2661
  }
2668
- if (!(opts == null ? void 0 : opts.captureLocation)) {
2662
+ if (!opts?.captureLocation) {
2669
2663
  pruneLocation(result.val);
2670
2664
  }
2671
2665
  return result.val;
@@ -2919,10 +2913,17 @@ Try polyfilling it using "@formatjs/intl-pluralrules"
2919
2913
  if (!c2) {
2920
2914
  return c1;
2921
2915
  }
2922
- return __spreadValues(__spreadValues(__spreadValues({}, c1), c2), Object.keys(c1).reduce((all, k) => {
2923
- all[k] = __spreadValues(__spreadValues({}, c1[k]), c2[k]);
2924
- return all;
2925
- }, {}));
2916
+ return {
2917
+ ...c1,
2918
+ ...c2,
2919
+ ...Object.keys(c1).reduce((all, k) => {
2920
+ all[k] = {
2921
+ ...c1[k],
2922
+ ...c2[k]
2923
+ };
2924
+ return all;
2925
+ }, {})
2926
+ };
2926
2927
  }
2927
2928
  function mergeConfigs(defaultConfig, configs) {
2928
2929
  if (!configs) {
@@ -2933,7 +2934,7 @@ Try polyfilling it using "@formatjs/intl-pluralrules"
2933
2934
  all[k] = mergeConfig(defaultConfig[k], configs[k]);
2934
2935
  return all;
2935
2936
  },
2936
- __spreadValues({}, defaultConfig)
2937
+ { ...defaultConfig }
2937
2938
  );
2938
2939
  }
2939
2940
  function createFastMemoizeCache(store) {
@@ -3013,12 +3014,9 @@ Try polyfilling it using "@formatjs/intl-pluralrules"
3013
3014
  void 0,
3014
3015
  this.message
3015
3016
  ));
3016
- __publicField(this, "resolvedOptions", () => {
3017
- var _a;
3018
- return {
3019
- locale: ((_a = this.resolvedLocale) == null ? void 0 : _a.toString()) || Intl.NumberFormat.supportedLocalesOf(this.locales)[0]
3020
- };
3021
- });
3017
+ __publicField(this, "resolvedOptions", () => ({
3018
+ locale: this.resolvedLocale?.toString() || Intl.NumberFormat.supportedLocalesOf(this.locales)[0]
3019
+ }));
3022
3020
  __publicField(this, "getAst", () => this.ast);
3023
3021
  this.locales = locales;
3024
3022
  this.resolvedLocale = _IntlMessageFormat.resolveLocale(locales);
@@ -3029,10 +3027,11 @@ Try polyfilling it using "@formatjs/intl-pluralrules"
3029
3027
  "IntlMessageFormat.__parse must be set to process `message` of type `string`"
3030
3028
  );
3031
3029
  }
3032
- const parseOpts = __objRest(opts || {}, []);
3033
- this.ast = _IntlMessageFormat.__parse(message, __spreadProps(__spreadValues({}, parseOpts), {
3030
+ const { ...parseOpts } = opts || {};
3031
+ this.ast = _IntlMessageFormat.__parse(message, {
3032
+ ...parseOpts,
3034
3033
  locale: this.resolvedLocale
3035
- }));
3034
+ });
3036
3035
  } else {
3037
3036
  this.ast = message;
3038
3037
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "intl-messageformat",
3
3
  "description": "Formats ICU Message strings with number, date, plural, and select placeholders to create localized messages.",
4
- "version": "11.1.3",
4
+ "version": "11.2.0",
5
5
  "license": "BSD-3-Clause",
6
6
  "author": "Eric Ferraiuolo <eferraiuolo@gmail.com>",
7
7
  "type": "module",
@@ -11,8 +11,8 @@
11
11
  ".": "./index.js"
12
12
  },
13
13
  "dependencies": {
14
- "@formatjs/ecma402-abstract": "3.1.2",
15
- "@formatjs/icu-messageformat-parser": "3.5.2",
14
+ "@formatjs/ecma402-abstract": "3.2.0",
15
+ "@formatjs/icu-messageformat-parser": "3.5.3",
16
16
  "@formatjs/fast-memoize": "3.1.1"
17
17
  },
18
18
  "bugs": "https://github.com/formatjs/formatjs/issues",