@lingui/format-json 4.4.2 → 4.6.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.
package/README.md CHANGED
@@ -52,6 +52,13 @@ export type JsonFormatterOptions = {
52
52
  * @default "lingui"
53
53
  */
54
54
  style?: "lingui" | "minimal"
55
+
56
+ /**
57
+ * Indentation of output JSON
58
+ *
59
+ * @default 2
60
+ */
61
+ indentation?: number
55
62
  }
56
63
  ```
57
64
 
package/dist/json.cjs CHANGED
@@ -2,7 +2,8 @@
2
2
 
3
3
  const R = require('ramda');
4
4
 
5
- function _interopNamespaceDefault(e) {
5
+ function _interopNamespaceCompat(e) {
6
+ if (e && typeof e === 'object' && 'default' in e) return e;
6
7
  const n = Object.create(null);
7
8
  if (e) {
8
9
  for (const k in e) {
@@ -13,7 +14,7 @@ function _interopNamespaceDefault(e) {
13
14
  return n;
14
15
  }
15
16
 
16
- const R__namespace = /*#__PURE__*/_interopNamespaceDefault(R);
17
+ const R__namespace = /*#__PURE__*/_interopNamespaceCompat(R);
17
18
 
18
19
  const serializeMinimal = R__namespace.map(
19
20
  (message) => message.translation || ""
@@ -52,7 +53,7 @@ function formatter(options = {}) {
52
53
  if (options.style === "minimal") {
53
54
  outputCatalog = serializeMinimal(outputCatalog);
54
55
  }
55
- return JSON.stringify(outputCatalog, null, 2) + trailingNewLine;
56
+ return JSON.stringify(outputCatalog, null, options.indentation ?? 2) + trailingNewLine;
56
57
  },
57
58
  parse(content) {
58
59
  const catalog = JSON.parse(content);
@@ -0,0 +1,31 @@
1
+ import { CatalogFormatter } from '@lingui/conf';
2
+
3
+ type JsonFormatterOptions = {
4
+ /**
5
+ * Print places where message is used
6
+ *
7
+ * @default true
8
+ */
9
+ origins?: boolean;
10
+ /**
11
+ * Print line numbers in origins
12
+ *
13
+ * @default true
14
+ */
15
+ lineNumbers?: boolean;
16
+ /**
17
+ * Different styles of how information could be printed
18
+ *
19
+ * @default "lingui"
20
+ */
21
+ style?: "lingui" | "minimal";
22
+ /**
23
+ * Indentation of output JSON
24
+ *
25
+ * @default 2
26
+ */
27
+ indentation?: number;
28
+ };
29
+ declare function formatter(options?: JsonFormatterOptions): CatalogFormatter;
30
+
31
+ export { type JsonFormatterOptions, formatter };
@@ -0,0 +1,31 @@
1
+ import { CatalogFormatter } from '@lingui/conf';
2
+
3
+ type JsonFormatterOptions = {
4
+ /**
5
+ * Print places where message is used
6
+ *
7
+ * @default true
8
+ */
9
+ origins?: boolean;
10
+ /**
11
+ * Print line numbers in origins
12
+ *
13
+ * @default true
14
+ */
15
+ lineNumbers?: boolean;
16
+ /**
17
+ * Different styles of how information could be printed
18
+ *
19
+ * @default "lingui"
20
+ */
21
+ style?: "lingui" | "minimal";
22
+ /**
23
+ * Indentation of output JSON
24
+ *
25
+ * @default 2
26
+ */
27
+ indentation?: number;
28
+ };
29
+ declare function formatter(options?: JsonFormatterOptions): CatalogFormatter;
30
+
31
+ export { type JsonFormatterOptions, formatter };
package/dist/json.d.ts CHANGED
@@ -19,7 +19,13 @@ type JsonFormatterOptions = {
19
19
  * @default "lingui"
20
20
  */
21
21
  style?: "lingui" | "minimal";
22
+ /**
23
+ * Indentation of output JSON
24
+ *
25
+ * @default 2
26
+ */
27
+ indentation?: number;
22
28
  };
23
29
  declare function formatter(options?: JsonFormatterOptions): CatalogFormatter;
24
30
 
25
- export { JsonFormatterOptions, formatter };
31
+ export { type JsonFormatterOptions, formatter };
package/dist/json.mjs CHANGED
@@ -37,7 +37,7 @@ function formatter(options = {}) {
37
37
  if (options.style === "minimal") {
38
38
  outputCatalog = serializeMinimal(outputCatalog);
39
39
  }
40
- return JSON.stringify(outputCatalog, null, 2) + trailingNewLine;
40
+ return JSON.stringify(outputCatalog, null, options.indentation ?? 2) + trailingNewLine;
41
41
  },
42
42
  parse(content) {
43
43
  const catalog = JSON.parse(content);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingui/format-json",
3
- "version": "4.4.2",
3
+ "version": "4.6.0",
4
4
  "description": "JSON format for Lingui Catalogs",
5
5
  "main": "./dist/json.cjs",
6
6
  "module": "./dist/json.mjs",
@@ -39,12 +39,12 @@
39
39
  "dist/"
40
40
  ],
41
41
  "dependencies": {
42
- "@lingui/conf": "4.4.2",
42
+ "@lingui/conf": "4.6.0",
43
43
  "ramda": "^0.28.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "tsd": "^0.28.0",
47
- "unbuild": "^1.1.2"
47
+ "unbuild": "^2.0.0"
48
48
  },
49
- "gitHead": "316a004ec82721fcceb8f3c4a5aeb4a48d367927"
49
+ "gitHead": "2afa0efb2d0cd1d47adc76e1eec9f5e57e34ae18"
50
50
  }