@lingui/cli 5.9.3 → 6.0.0-next.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.
Files changed (98) hide show
  1. package/dist/api/ProgramExit.js +1 -5
  2. package/dist/api/catalog/extractFromFiles.d.ts +4 -4
  3. package/dist/api/catalog/extractFromFiles.js +38 -32
  4. package/dist/api/catalog/getCatalogDependentFiles.d.ts +1 -1
  5. package/dist/api/catalog/getCatalogDependentFiles.js +8 -47
  6. package/dist/api/catalog/getCatalogs.d.ts +2 -2
  7. package/dist/api/catalog/getCatalogs.js +35 -44
  8. package/dist/api/catalog/getFallbackListForLocale.js +5 -8
  9. package/dist/api/catalog/getTranslationsForCatalog.d.ts +1 -1
  10. package/dist/api/catalog/getTranslationsForCatalog.js +9 -13
  11. package/dist/api/catalog/mergeCatalog.d.ts +3 -3
  12. package/dist/api/catalog/mergeCatalog.js +13 -21
  13. package/dist/api/catalog.d.ts +15 -15
  14. package/dist/api/catalog.js +48 -45
  15. package/dist/api/compile/compileLocale.d.ts +3 -3
  16. package/dist/api/compile/compileLocale.js +28 -33
  17. package/dist/api/compile.js +13 -49
  18. package/dist/api/extractors/babel.d.ts +20 -4
  19. package/dist/api/extractors/babel.js +66 -56
  20. package/dist/api/extractors/index.js +16 -13
  21. package/dist/api/formats/formatterWrapper.d.ts +2 -2
  22. package/dist/api/formats/formatterWrapper.js +10 -12
  23. package/dist/api/formats/index.d.ts +3 -4
  24. package/dist/api/formats/index.js +5 -44
  25. package/dist/api/getPathsForCompileWatcher.d.ts +7 -0
  26. package/dist/api/getPathsForCompileWatcher.js +15 -0
  27. package/dist/api/getPathsForExtractWatcher.d.ts +8 -0
  28. package/dist/api/getPathsForExtractWatcher.js +14 -0
  29. package/dist/api/help.js +5 -7
  30. package/dist/api/index.d.ts +7 -7
  31. package/dist/api/index.js +7 -36
  32. package/dist/api/logger.d.ts +1 -1
  33. package/dist/api/logger.js +1 -2
  34. package/dist/api/messages.d.ts +2 -2
  35. package/dist/api/messages.js +5 -12
  36. package/dist/api/pseudoLocalize.js +3 -9
  37. package/dist/api/resolveWorkersOptions.js +3 -9
  38. package/dist/api/rethrownError.js +2 -5
  39. package/dist/api/stats.d.ts +3 -2
  40. package/dist/api/stats.js +7 -16
  41. package/dist/api/typedPool.d.ts +6 -0
  42. package/dist/api/typedPool.js +16 -0
  43. package/dist/api/types.js +1 -2
  44. package/dist/api/utils.d.ts +2 -2
  45. package/dist/api/utils.js +24 -41
  46. package/dist/api/workerLogger.d.ts +2 -2
  47. package/dist/api/workerLogger.js +2 -8
  48. package/dist/api/workerPools.d.ts +3 -0
  49. package/dist/api/workerPools.js +7 -0
  50. package/dist/extract-experimental/buildIncludeDepsFilter.js +1 -4
  51. package/dist/extract-experimental/bundleSource.d.ts +3 -2
  52. package/dist/extract-experimental/bundleSource.js +10 -13
  53. package/dist/extract-experimental/constants.js +2 -5
  54. package/dist/extract-experimental/extractFromBundleAndWrite.d.ts +3 -4
  55. package/dist/extract-experimental/extractFromBundleAndWrite.js +9 -22
  56. package/dist/extract-experimental/getExperimentalCatalogs.d.ts +4 -3
  57. package/dist/extract-experimental/getExperimentalCatalogs.js +10 -15
  58. package/dist/extract-experimental/linguiEsbuildPlugin.js +12 -19
  59. package/dist/extract-experimental/resolveCatalogPath.d.ts +1 -1
  60. package/dist/extract-experimental/resolveCatalogPath.js +7 -14
  61. package/dist/extract-experimental/resolveTemplatePath.js +7 -10
  62. package/dist/extract-experimental/workers/extractWorker.d.ts +5 -3
  63. package/dist/extract-experimental/workers/extractWorker.js +7 -10
  64. package/dist/extract-experimental/workers/extractWorkerWrapper.prod.d.ts +8 -0
  65. package/dist/extract-experimental/workers/extractWorkerWrapper.prod.js +2 -0
  66. package/dist/extract-experimental/writeCatalogs.d.ts +2 -2
  67. package/dist/extract-experimental/writeCatalogs.js +15 -22
  68. package/dist/index.js +1 -5
  69. package/dist/lingui-compile.d.ts +1 -1
  70. package/dist/lingui-compile.js +45 -59
  71. package/dist/lingui-extract-experimental.d.ts +3 -2
  72. package/dist/lingui-extract-experimental.js +58 -62
  73. package/dist/lingui-extract-template.d.ts +5 -4
  74. package/dist/lingui-extract-template.js +25 -27
  75. package/dist/lingui-extract.d.ts +3 -4
  76. package/dist/lingui-extract.js +62 -69
  77. package/dist/lingui.js +5 -10
  78. package/dist/services/translationIO/segment-converters.d.ts +1 -1
  79. package/dist/services/translationIO/segment-converters.js +16 -20
  80. package/dist/services/translationIO/translationio-api.d.ts +11 -7
  81. package/dist/services/translationIO/translationio-api.js +2 -19
  82. package/dist/services/translationIO.d.ts +4 -4
  83. package/dist/services/translationIO.js +28 -35
  84. package/dist/workers/compileWorker.d.ts +8 -11
  85. package/dist/workers/compileWorker.js +30 -36
  86. package/dist/workers/compileWorkerWrapper.prod.d.ts +7 -0
  87. package/dist/workers/compileWorkerWrapper.prod.js +2 -0
  88. package/dist/workers/extractWorker.d.ts +2 -3
  89. package/dist/workers/extractWorker.js +5 -12
  90. package/dist/workers/extractWorkerWrapper.prod.d.ts +6 -0
  91. package/dist/workers/extractWorkerWrapper.prod.js +2 -0
  92. package/package.json +26 -43
  93. package/dist/api/extractWorkerPool.d.ts +0 -1
  94. package/dist/api/extractWorkerPool.js +0 -8
  95. package/dist/api/extractors/typescript.d.ts +0 -3
  96. package/dist/api/extractors/typescript.js +0 -11
  97. package/dist/extract-experimental/getEntryPoints.d.ts +0 -1
  98. package/dist/extract-experimental/getEntryPoints.js +0 -7
@@ -1,39 +1,33 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const worker_1 = require("threads/worker");
4
- const compileLocale_1 = require("../api/compile/compileLocale");
5
- const conf_1 = require("@lingui/conf");
6
- const workerLogger_1 = require("../api/workerLogger");
7
- const ProgramExit_1 = require("../api/ProgramExit");
8
- const getCatalogs_1 = require("../api/catalog/getCatalogs");
1
+ import { compileLocale } from "../api/compile/compileLocale.js";
2
+ import { getConfig } from "@lingui/conf";
3
+ import { WorkerLogger } from "../api/workerLogger.js";
4
+ import { ProgramExit } from "../api/ProgramExit.js";
5
+ import { getCatalogs } from "../api/catalog/getCatalogs.js";
9
6
  let linguiConfig;
10
7
  let catalogs;
11
- const compileWorker = {
12
- compileLocale: async (locale, options, doMerge, linguiConfigPath) => {
13
- if (!linguiConfig) {
14
- // initialize config once per worker, speed up workers follow execution
15
- linguiConfig = (0, conf_1.getConfig)({
16
- configPath: linguiConfigPath,
17
- skipValidation: true,
18
- });
19
- }
20
- if (!catalogs) {
21
- // catalogs holds path to the files and message catalogs, so it's kinda configuration object
22
- // it depends only on the config, so we can initialize it once per program execution
23
- catalogs = await (0, getCatalogs_1.getCatalogs)(linguiConfig);
24
- }
25
- const logger = new workerLogger_1.WorkerLogger();
26
- try {
27
- await (0, compileLocale_1.compileLocale)(catalogs, locale, options, linguiConfig, doMerge, logger);
28
- }
29
- catch (error) {
30
- return {
31
- logs: logger.flush(),
32
- error,
33
- exitProgram: error instanceof ProgramExit_1.ProgramExit,
34
- };
35
- }
36
- return { logs: logger.flush() };
37
- },
8
+ export const compileWorker = async (locale, options, doMerge, linguiConfigPath) => {
9
+ if (!linguiConfig) {
10
+ // initialize config once per worker, speed up workers follow execution
11
+ linguiConfig = getConfig({
12
+ configPath: linguiConfigPath,
13
+ skipValidation: true,
14
+ });
15
+ }
16
+ if (!catalogs) {
17
+ // catalogs holds path to the files and message catalogs, so it's kinda configuration object
18
+ // it depends only on the config, so we can initialize it once per program execution
19
+ catalogs = await getCatalogs(linguiConfig);
20
+ }
21
+ const logger = new WorkerLogger();
22
+ try {
23
+ await compileLocale(catalogs, locale, options, linguiConfig, doMerge, logger);
24
+ }
25
+ catch (error) {
26
+ return {
27
+ logs: logger.flush(),
28
+ error,
29
+ exitProgram: error instanceof ProgramExit,
30
+ };
31
+ }
32
+ return { logs: logger.flush() };
38
33
  };
39
- (0, worker_1.expose)(compileWorker);
@@ -0,0 +1,7 @@
1
+ import { compileWorker } from "./compileWorker.js";
2
+ declare const _default: (args: Parameters<typeof compileWorker>) => Promise<{
3
+ logs: import("../api/workerLogger.js").SerializedLogs;
4
+ error?: unknown;
5
+ exitProgram?: boolean;
6
+ }>;
7
+ export default _default;
@@ -0,0 +1,2 @@
1
+ import { compileWorker } from "./compileWorker.js";
2
+ export default (args) => compileWorker(...args);
@@ -1,7 +1,6 @@
1
1
  import { ExtractedMessage } from "@lingui/conf";
2
2
  export type ExtractWorkerFunction = typeof extractWorker;
3
- declare const extractWorker: (filename: string, linguiConfigPath: string) => Promise<{
4
- messages?: ExtractedMessage[];
3
+ export declare const extractWorker: (filename: string, linguiConfigPath: string) => Promise<{
4
+ messages: ExtractedMessage[];
5
5
  success: boolean;
6
6
  }>;
7
- export {};
@@ -1,24 +1,17 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const worker_1 = require("threads/worker");
7
- const conf_1 = require("@lingui/conf");
8
- const extractors_1 = __importDefault(require("../api/extractors"));
1
+ import { getConfig, } from "@lingui/conf";
2
+ import extract from "../api/extractors/index.js";
9
3
  let linguiConfig;
10
- const extractWorker = async (filename, linguiConfigPath) => {
4
+ export const extractWorker = async (filename, linguiConfigPath) => {
11
5
  if (!linguiConfig) {
12
6
  // initialize config once per worker, speed up workers follow execution
13
- linguiConfig = (0, conf_1.getConfig)({
7
+ linguiConfig = getConfig({
14
8
  configPath: linguiConfigPath,
15
9
  skipValidation: true,
16
10
  });
17
11
  }
18
12
  const messages = [];
19
- const success = await (0, extractors_1.default)(filename, (msg) => {
13
+ const success = await extract(filename, (msg) => {
20
14
  messages.push(msg);
21
15
  }, linguiConfig);
22
16
  return { success, messages };
23
17
  };
24
- (0, worker_1.expose)(extractWorker);
@@ -0,0 +1,6 @@
1
+ import { extractWorker } from "./extractWorker.js";
2
+ declare const _default: (args: Parameters<typeof extractWorker>) => Promise<{
3
+ messages: import("packages/conf/dist/index.mjs").ExtractedMessage[];
4
+ success: boolean;
5
+ }>;
6
+ export default _default;
@@ -0,0 +1,2 @@
1
+ import { extractWorker } from "./extractWorker.js";
2
+ export default (args) => extractWorker(...args);
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@lingui/cli",
3
- "version": "5.9.3",
3
+ "version": "6.0.0-next.1",
4
4
  "description": "CLI for working wit message catalogs",
5
+ "type": "module",
5
6
  "keywords": [
6
7
  "cli",
7
8
  "i18n",
@@ -28,28 +29,16 @@
28
29
  "lingui": "./dist/lingui.js"
29
30
  },
30
31
  "exports": {
31
- ".": {
32
- "types": "./dist/index.d.ts",
33
- "default": "./dist/index.js"
34
- },
35
- "./api": {
36
- "types": "./dist/api/index.d.ts",
37
- "default": "./dist/api/index.js"
38
- },
39
- "./api/extractors/babel": {
40
- "types": "./dist/api/extractors/babel.d.ts",
41
- "default": "./dist/api/extractors/babel.js"
42
- },
43
- "./api/extractors/typescript": {
44
- "types": "./dist/api/extractors/typescript.d.ts",
45
- "default": "./dist/api/extractors/typescript.js"
46
- }
32
+ ".": "./dist/index.js",
33
+ "./api": "./dist/api/index.js",
34
+ "./api/extractors/babel": "./dist/api/extractors/babel.js"
47
35
  },
48
36
  "scripts": {
49
- "build": "rimraf ./dist && tsc -p tsconfig.build.json"
37
+ "build": "tsc -p tsconfig.build.json",
38
+ "check-types": "tsc --noEmit"
50
39
  },
51
40
  "engines": {
52
- "node": ">=20.0.0"
41
+ "node": ">=22.19.0"
53
42
  },
54
43
  "files": [
55
44
  "LICENSE",
@@ -58,43 +47,37 @@
58
47
  ],
59
48
  "dependencies": {
60
49
  "@babel/core": "^7.21.0",
61
- "@babel/generator": "^7.21.1",
50
+ "@babel/generator": "^7.28.5",
62
51
  "@babel/parser": "^7.22.0",
63
- "@babel/runtime": "^7.21.0",
64
52
  "@babel/types": "^7.21.2",
65
- "@lingui/babel-plugin-extract-messages": "5.9.3",
66
- "@lingui/babel-plugin-lingui-macro": "5.9.3",
67
- "@lingui/conf": "5.9.3",
68
- "@lingui/core": "5.9.3",
69
- "@lingui/format-po": "5.9.3",
70
- "@lingui/message-utils": "5.9.3",
71
- "chokidar": "3.5.1",
72
- "cli-table": "^0.3.11",
73
- "commander": "^10.0.0",
74
- "convert-source-map": "^2.0.0",
75
- "date-fns": "^3.6.0",
53
+ "@lingui/babel-plugin-extract-messages": "6.0.0-next.1",
54
+ "@lingui/babel-plugin-lingui-macro": "6.0.0-next.1",
55
+ "@lingui/conf": "6.0.0-next.1",
56
+ "@lingui/core": "6.0.0-next.1",
57
+ "@lingui/format-po": "6.0.0-next.1",
58
+ "@lingui/message-utils": "6.0.0-next.1",
59
+ "chokidar": "5.0.0",
60
+ "cli-table3": "^0.6.5",
61
+ "commander": "^14.0.2",
76
62
  "esbuild": "^0.25.1",
77
- "glob": "^11.0.0",
63
+ "jiti": "^2.6.1",
78
64
  "micromatch": "^4.0.7",
79
65
  "ms": "^2.1.3",
80
66
  "normalize-path": "^3.0.0",
81
- "ora": "^5.1.0",
82
- "picocolors": "^1.1.1",
83
- "pofile": "^1.1.4",
84
- "pseudolocale": "^2.0.0",
67
+ "ora": "^9.1.0",
68
+ "pseudolocale": "^2.2.0",
85
69
  "source-map": "^0.7.6",
86
- "threads": "^1.7.0"
70
+ "tinypool": "^2.1.0"
87
71
  },
88
72
  "devDependencies": {
89
- "@lingui/jest-mocks": "*",
90
- "@types/convert-source-map": "^2.0.0",
73
+ "@lingui/test-utils": "3.0.3",
74
+ "@types/babel__generator": "^7.27.0",
91
75
  "@types/micromatch": "^4.0.1",
92
76
  "@types/ms": "^2.1.0",
93
77
  "@types/normalize-path": "^3.0.0",
94
78
  "mock-fs": "^5.2.0",
95
- "mockdate": "^3.0.5",
96
79
  "msw": "^2.12.7",
97
- "ts-node": "^10.9.2"
80
+ "vitest": "4.0.18"
98
81
  },
99
- "gitHead": "67be09ce3416ebd662822bf0689454dbb5e3261a"
82
+ "gitHead": "783af0c0371c7795e1fc43316f49dd253e161221"
100
83
  }
@@ -1 +0,0 @@
1
- export type ExtractWorkerPool = ReturnType<typeof createExtractWorkerPool>;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createExtractWorkerPool = createExtractWorkerPool;
4
- const threads_1 = require("threads");
5
- /** @internal */
6
- function createExtractWorkerPool(opts) {
7
- return (0, threads_1.Pool)(() => (0, threads_1.spawn)(new threads_1.Worker("../workers/extractWorker")), { size: opts.poolSize });
8
- }
@@ -1,3 +0,0 @@
1
- import { ExtractorType } from "@lingui/conf";
2
- declare const extractor: ExtractorType;
3
- export default extractor;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const extractor = {
4
- match(filename) {
5
- throw new Error("Typescript extractor was removed. " +
6
- "Lingui CLI can parse typescript out of the box. " +
7
- "Please remove it from your lingui.config.js");
8
- },
9
- extract() { },
10
- };
11
- exports.default = extractor;
@@ -1 +0,0 @@
1
- export declare function getEntryPoints(entries: string[]): string[];
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getEntryPoints = getEntryPoints;
4
- const glob_1 = require("glob");
5
- function getEntryPoints(entries) {
6
- return (0, glob_1.globSync)(entries, { mark: true });
7
- }