@internationalized/string-compiler 3.3.0 → 3.4.1

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.
package/package.json CHANGED
@@ -1,23 +1,23 @@
1
1
  {
2
2
  "name": "@internationalized/string-compiler",
3
- "version": "3.3.0",
3
+ "version": "3.4.1",
4
4
  "description": "Localized string compiler for @internationalized/string",
5
5
  "license": "Apache-2.0",
6
- "main": "src/stringCompiler.js",
7
- "types": "src/stringCompiler.d.ts",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/adobe/react-spectrum"
9
+ },
8
10
  "files": [
9
11
  "src"
10
12
  ],
11
13
  "sideEffects": false,
12
- "repository": {
13
- "type": "git",
14
- "url": "https://github.com/adobe/react-spectrum"
14
+ "main": "src/stringCompiler.js",
15
+ "types": "src/stringCompiler.d.ts",
16
+ "publishConfig": {
17
+ "access": "public"
15
18
  },
16
19
  "dependencies": {
17
20
  "@formatjs/icu-messageformat-parser": "^2.4.0"
18
21
  },
19
- "publishConfig": {
20
- "access": "public"
21
- },
22
- "gitHead": "66e51757606b43a89ed02c574ca24517323a2ab9"
22
+ "gitHead": "3577a20859b9585a000010c720f6ee39c1c588cc"
23
23
  }
@@ -13,9 +13,10 @@
13
13
  interface Options {
14
14
  /**
15
15
  * Output module format.
16
+ *
16
17
  * @default 'cjs'
17
18
  */
18
- format?: 'cjs' | 'esm'
19
+ format?: 'cjs' | 'esm';
19
20
  }
20
21
 
21
22
  /** Compiles an object containing ICU message strings to a JavaScript module. */
@@ -13,7 +13,7 @@
13
13
  const {parse, TYPE} = require('@formatjs/icu-messageformat-parser');
14
14
 
15
15
  function compileStrings(messages, options) {
16
- let res = options?.format === 'esm' ? 'export default {' : 'module.exports = {';
16
+ let res = options?.format === 'esm' ? 'export default {' : 'module.exports = {';
17
17
  for (let key in messages) {
18
18
  res += ' ' + JSON.stringify(key) + ': ' + compileString(messages[key]) + ',\n';
19
19
  }
@@ -49,16 +49,23 @@ function compileParts(parts, inline = false, pluralValue = '') {
49
49
  break;
50
50
  case TYPE.plural: {
51
51
  let pluralValue = 'args.' + part.value + (part.offset ? ' - ' + part.offset : '');
52
- res += '${formatter.plural('
53
- + pluralValue
54
- + ', ' + compileOptions(part.options, pluralValue)
55
- + (part.pluralType !== 'cardinal' ? ', "ordinal"' : '')
56
- + ')}';
52
+ res +=
53
+ '${formatter.plural(' +
54
+ pluralValue +
55
+ ', ' +
56
+ compileOptions(part.options, pluralValue) +
57
+ (part.pluralType !== 'cardinal' ? ', "ordinal"' : '') +
58
+ ')}';
57
59
  usesFormatter = true;
58
60
  break;
59
61
  }
60
62
  case TYPE.select:
61
- res += '${formatter.select(' + compileOptions(part.options, pluralValue) + ', args.' + part.value + ')}';
63
+ res +=
64
+ '${formatter.select(' +
65
+ compileOptions(part.options, pluralValue) +
66
+ ', args.' +
67
+ part.value +
68
+ ')}';
62
69
  usesFormatter = true;
63
70
  break;
64
71
  case TYPE.pound: