intl-messageformat 11.2.7 → 11.2.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.
@@ -1781,6 +1781,37 @@ function matchIdentifierAtIndex(s, index) {
1781
1781
  IDENTIFIER_PREFIX_RE.lastIndex = index;
1782
1782
  return IDENTIFIER_PREFIX_RE.exec(s)[1] ?? "";
1783
1783
  }
1784
+ function plainTopLevelEndPosition(message) {
1785
+ if (message.length === 0) return null;
1786
+ let line = 1;
1787
+ let column = 1;
1788
+ for (let offset = 0; offset < message.length;) {
1789
+ const code = message.charCodeAt(offset);
1790
+ switch (code) {
1791
+ case 35:
1792
+ case 39:
1793
+ case 60:
1794
+ case 123:
1795
+ case 125: return null;
1796
+ }
1797
+ if (code === 10) {
1798
+ line++;
1799
+ column = 1;
1800
+ offset++;
1801
+ } else {
1802
+ column++;
1803
+ if (code >= 55296 && code <= 56319 && offset + 1 < message.length) {
1804
+ const next = message.charCodeAt(offset + 1);
1805
+ offset += next >= 56320 && next <= 57343 ? 2 : 1;
1806
+ } else offset++;
1807
+ }
1808
+ }
1809
+ return {
1810
+ offset: message.length,
1811
+ line,
1812
+ column
1813
+ };
1814
+ }
1784
1815
  var Parser = class {
1785
1816
  constructor(message, options = {}) {
1786
1817
  this.message = message;
@@ -1796,6 +1827,24 @@ var Parser = class {
1796
1827
  }
1797
1828
  parse() {
1798
1829
  if (this.offset() !== 0) throw Error("parser can only be used once");
1830
+ if (this.message.length > 0) {
1831
+ const firstCode = this.message.charCodeAt(0);
1832
+ if (firstCode !== 35 && firstCode !== 39 && firstCode !== 60 && firstCode !== 123 && firstCode !== 125) {
1833
+ const plainEndPosition = plainTopLevelEndPosition(this.message);
1834
+ if (plainEndPosition) {
1835
+ const start = this.clonePosition();
1836
+ this.position = plainEndPosition;
1837
+ return {
1838
+ val: [{
1839
+ type: 0,
1840
+ value: this.message,
1841
+ location: createLocation(start, this.clonePosition())
1842
+ }],
1843
+ err: null
1844
+ };
1845
+ }
1846
+ }
1847
+ }
1799
1848
  return this.parseMessage(0, "", false);
1800
1849
  }
1801
1850
  parseMessage(nestingLevel, parentArgType, expectingCloseTag) {
package/package.json CHANGED
@@ -1,28 +1,7 @@
1
1
  {
2
2
  "name": "intl-messageformat",
3
+ "version": "11.2.8",
3
4
  "description": "Formats ICU Message strings with number, date, plural, and select placeholders to create localized messages.",
4
- "version": "11.2.7",
5
- "license": "BSD-3-Clause",
6
- "author": "Eric Ferraiuolo <eferraiuolo@gmail.com>",
7
- "type": "module",
8
- "sideEffects": false,
9
- "types": "index.d.ts",
10
- "exports": {
11
- ".": "./index.js"
12
- },
13
- "dependencies": {
14
- "@formatjs/fast-memoize": "3.1.5",
15
- "@formatjs/icu-messageformat-parser": "3.5.10"
16
- },
17
- "bugs": "https://github.com/formatjs/formatjs/issues",
18
- "contributors": [
19
- "Anthony Pipkin <a.pipkin@yahoo.com>",
20
- "Caridy Patino <caridy@gmail.com>",
21
- "Drew Folta <drew@folta.net>",
22
- "Long Ho <holevietlong@gmail.com>"
23
- ],
24
- "gitHead": "a7842673d8ad205171ad7c8cb8bb2f318b427c0c",
25
- "homepage": "https://github.com/formatjs/formatjs",
26
5
  "keywords": [
27
6
  "globalization",
28
7
  "i18n",
@@ -34,5 +13,25 @@
34
13
  "parser",
35
14
  "plural"
36
15
  ],
37
- "repository": "git@github.com:formatjs/formatjs.git"
16
+ "homepage": "https://github.com/formatjs/formatjs",
17
+ "bugs": "https://github.com/formatjs/formatjs/issues",
18
+ "license": "BSD-3-Clause",
19
+ "author": "Eric Ferraiuolo <eferraiuolo@gmail.com>",
20
+ "contributors": [
21
+ "Anthony Pipkin <a.pipkin@yahoo.com>",
22
+ "Caridy Patino <caridy@gmail.com>",
23
+ "Drew Folta <drew@folta.net>",
24
+ "Long Ho <holevietlong@gmail.com>"
25
+ ],
26
+ "repository": "git@github.com:formatjs/formatjs.git",
27
+ "type": "module",
28
+ "sideEffects": false,
29
+ "types": "index.d.ts",
30
+ "exports": {
31
+ ".": "./index.js"
32
+ },
33
+ "dependencies": {
34
+ "@formatjs/fast-memoize": "3.1.6",
35
+ "@formatjs/icu-messageformat-parser": "3.5.11"
36
+ }
38
37
  }