@menapo/vi18n 0.0.0-stage → 0.1.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 (100) hide show
  1. package/LICENSE +49 -0
  2. package/README.md +110 -2
  3. package/dist/apply-Bre-lY9J.js +228 -0
  4. package/dist/captured-Bj8bO6vd.js +1034 -0
  5. package/dist/check-BIKEuu6B.js +201 -0
  6. package/dist/check-HsmmpJZg.js +1 -0
  7. package/dist/cli.d.ts +1 -0
  8. package/dist/cli.js +41 -0
  9. package/dist/codec-DuvU2VQy.js +207 -0
  10. package/dist/collect-Cx4_SKOe.js +13 -0
  11. package/dist/collisions-CfpZU8e4.js +217 -0
  12. package/dist/compile-BaDh0cHG.js +245 -0
  13. package/dist/compile-Cc97JaW2.js +2502 -0
  14. package/dist/concurrency-C9UUWuDC.js +96 -0
  15. package/dist/concurrency-DONL7t4V.js +1 -0
  16. package/dist/config.d.ts +21 -0
  17. package/dist/config.js +39 -0
  18. package/dist/dir-zw6bGMKQ.js +290 -0
  19. package/dist/duplicates-yuRljQ6h.js +185 -0
  20. package/dist/engine-C2ENBRJe.js +531 -0
  21. package/dist/engine.d.ts +43 -0
  22. package/dist/engine.js +1241 -0
  23. package/dist/exclude-Du-Zd_qI.js +26 -0
  24. package/dist/export-C9Sy6UWv.js +103 -0
  25. package/dist/extract-C3S8btx0.js +298 -0
  26. package/dist/formats-9unqj_fZ.js +781 -0
  27. package/dist/i18next-9HAoxwUI.js +1 -0
  28. package/dist/i18next-BEJgv_S8.js +1596 -0
  29. package/dist/import-nANvQutw.js +225 -0
  30. package/dist/index.d.ts +156 -0
  31. package/dist/index.js +239 -0
  32. package/dist/init-C2ScuW6a.js +792 -0
  33. package/dist/library-D5CWvTQs.js +1882 -0
  34. package/dist/lingui-zUiCl9Um.js +833 -0
  35. package/dist/lint.d.ts +105 -0
  36. package/dist/lint.js +971 -0
  37. package/dist/load-CQRz4PpM.js +2950 -0
  38. package/dist/load-gW-oJt1Q.js +747 -0
  39. package/dist/locales-DX4MOBFE.js +827 -0
  40. package/dist/lsp-RMMMc88P.js +31 -0
  41. package/dist/match-BGr8EXB3.js +89 -0
  42. package/dist/mcp-CHVwBoRP.js +28 -0
  43. package/dist/merge-driver-BTX87aVm.js +422 -0
  44. package/dist/messages-BfjIExyB.js +166 -0
  45. package/dist/migrate-IpLDMXmq.js +1484 -0
  46. package/dist/migrate-rCQuOGsf.js +1 -0
  47. package/dist/openai-CTaMDcl-.js +346 -0
  48. package/dist/output-DWE3SIUA.js +164 -0
  49. package/dist/parse.d.ts +62 -0
  50. package/dist/parse.js +156 -0
  51. package/dist/pipeline-C9Dbotkh.js +2031 -0
  52. package/dist/pipeline-DbX6rlo5.js +1 -0
  53. package/dist/project-Bw9UPIdx.js +1046 -0
  54. package/dist/project-C4GpaN-n.js +381 -0
  55. package/dist/pseudo-DRv30iN5.js +145 -0
  56. package/dist/raw-C4Y6vyGY.js +4708 -0
  57. package/dist/react-intl-BP0u-D5m.js +519 -0
  58. package/dist/restore-CiYv-jxS.js +175 -0
  59. package/dist/rewrite-EsIw_lsq.js +803 -0
  60. package/dist/rich-DCUKl5HM.js +97 -0
  61. package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
  62. package/dist/run-BEcnBbu-.js +694 -0
  63. package/dist/runtime-DTMmliT1.js +64 -0
  64. package/dist/scan-worker.d.ts +62 -0
  65. package/dist/scan-worker.js +1 -0
  66. package/dist/scoped-BMYpSthj.js +44 -0
  67. package/dist/server-Da1Ot9IN.js +10485 -0
  68. package/dist/server-deBOq2vq.js +11823 -0
  69. package/dist/server.d.ts +169 -0
  70. package/dist/server.js +1234 -0
  71. package/dist/sitemap-DJXzKoza.js +159 -0
  72. package/dist/sources-D19czDSA.js +2242 -0
  73. package/dist/status-zr4jY59Y.js +149 -0
  74. package/dist/stdio-CVaJfxA7.js +29 -0
  75. package/dist/stdio-FPOKQAgu.js +95 -0
  76. package/dist/sync-B9V2KFwb.js +658 -0
  77. package/dist/t-DC-c9zE5.js +454 -0
  78. package/dist/test.d.ts +116 -0
  79. package/dist/test.js +319 -0
  80. package/dist/translate-CQnJfLjO.js +299 -0
  81. package/dist/ts-BaU5yOf0.js +4863 -0
  82. package/dist/types-CgUCkFU1.d.ts +707 -0
  83. package/dist/types-D3QGM8XO.js +146 -0
  84. package/dist/types-DsdWBG0b.d.ts +558 -0
  85. package/dist/types-DtvQ7UdD.js +1948 -0
  86. package/dist/types-wSh9fCBY.js +11 -0
  87. package/dist/units-CQ5Q99RC.js +150 -0
  88. package/dist/url-CRfCOhUI.js +172 -0
  89. package/dist/url-CsBkRaJy.js +225 -0
  90. package/dist/validate-BxpupdAf.js +2615 -0
  91. package/dist/validate-D6DJepZv.js +365 -0
  92. package/dist/version-Byqi2guX.js +28 -0
  93. package/dist/vite-scan-CT_vsp4g.js +242 -0
  94. package/dist/vite.d.ts +34 -0
  95. package/dist/vite.js +7558 -0
  96. package/dist/vue-i18n-g0iGy6CZ.js +651 -0
  97. package/dist/which-BOemZ5Q8.js +116 -0
  98. package/dist/worker-84U6uYB3.js +1656 -0
  99. package/package.json +97 -3
  100. package/schemas/catalog.json +57 -0
@@ -0,0 +1,116 @@
1
+ import { S as entryKey } from "./library-D5CWvTQs.js";
2
+ import { r as resolveDuplicates } from "./duplicates-yuRljQ6h.js";
3
+ import { c as sourceIndexOf, i as entrySource, r as canonicalOrNull } from "./units-CQ5Q99RC.js";
4
+ import { i as rootRelative, r as plural } from "./output-DWE3SIUA.js";
5
+ import { t as EXIT } from "./types-wSh9fCBY.js";
6
+ import { a as loadCatalogs, f as scan, o as loadProject, t as CliExit } from "./project-C4GpaN-n.js";
7
+ //#region src/cli/commands/which.ts
8
+ /**
9
+ * `vi18n which <id|prefix|text>` (PLAN §4.3, §5.19, INTERNALS §2.14): from
10
+ * an id in an `onMissing` report, a log line or a catalog, to the text and
11
+ * the code that uses it; or from text to its id. The first tier that
12
+ * matches wins: the whole id, the exact source text (canonicalised, so ICU
13
+ * spacing does not matter), the start of an id, then part of a text
14
+ * (ignoring case). Catalog entries no code uses are found too.
15
+ */
16
+ /** Matches listed in full; the rest are counted (a one-letter prefix matches thousands). */
17
+ const LIMIT = 50;
18
+ async function which(ctx, flags) {
19
+ const project = await loadProject(ctx);
20
+ const { config, codec, layout } = project;
21
+ const scanned = await scan(project);
22
+ const loaded = await loadCatalogs(project);
23
+ const known = /* @__PURE__ */ new Map();
24
+ for (const [id, message] of scanned.messages) known.set(id, {
25
+ id,
26
+ manual: message.manual,
27
+ source: message.canonical,
28
+ match: "id",
29
+ locations: message.locations.map((location) => ({ ...location })),
30
+ catalogs: []
31
+ });
32
+ const sourceIndex = sourceIndexOf(loaded.set.get(config.sourceLocale)?.catalog ?? null, layout, codec);
33
+ const order = [config.sourceLocale, ...config.locales.filter((l) => l !== config.sourceLocale)];
34
+ for (const locale of order) {
35
+ const file = loaded.set.get(locale);
36
+ if (file === void 0 || file.catalog === null) continue;
37
+ const shown = rootRelative(config.root, file.path);
38
+ const seen = /* @__PURE__ */ new Set();
39
+ for (const entry of resolveDuplicates(file.catalog, codec).catalog.entries) {
40
+ const key = entryKey(entry, layout, codec);
41
+ if (key === null || seen.has(key)) continue;
42
+ seen.add(key);
43
+ let match = known.get(key);
44
+ if (match === void 0) {
45
+ const source = entrySource(entry, key, {
46
+ layout,
47
+ codec,
48
+ sourceIndex
49
+ });
50
+ if (source === null) continue;
51
+ match = {
52
+ id: key,
53
+ manual: entry.manualId !== null,
54
+ source: source.canonical,
55
+ match: "id",
56
+ locations: [],
57
+ catalogs: []
58
+ };
59
+ known.set(key, match);
60
+ }
61
+ const state = locale === config.sourceLocale ? "source" : stateOf(entry);
62
+ match.catalogs.push({
63
+ locale,
64
+ file: shown,
65
+ line: entry.line,
66
+ state
67
+ });
68
+ }
69
+ }
70
+ const query = flags.query;
71
+ const all = [...known.values()];
72
+ const canonical = canonicalOrNull(query, codec);
73
+ const tiers = [
74
+ ["id", (match) => match.id === query],
75
+ ["text", (match) => canonical !== null && match.source === canonical],
76
+ ["prefix", (match) => match.id.startsWith(query)],
77
+ ["contains", (match) => match.source.toLowerCase().includes(query.toLowerCase())]
78
+ ];
79
+ let found = [];
80
+ for (const [kind, test] of tiers) {
81
+ found = all.filter(test).map((match) => ({
82
+ ...match,
83
+ match: kind
84
+ }));
85
+ if (found.length > 0) break;
86
+ }
87
+ found.sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0);
88
+ const data = {
89
+ query,
90
+ matches: found.slice(0, LIMIT),
91
+ more: Math.max(0, found.length - LIMIT)
92
+ };
93
+ if (found.length === 0) {
94
+ ctx.out.note(`vi18n which: no message matches ${JSON.stringify(query)}`);
95
+ throw new CliExit(EXIT.failure, [], data);
96
+ }
97
+ const lines = [];
98
+ for (const match of data.matches) {
99
+ lines.push(`${match.id} ${match.source}`);
100
+ for (const at of match.locations) lines.push(` ${ctx.out.display(at.file)}:${at.line}:${at.column}`);
101
+ if (match.locations.length === 0) lines.push(config.extraction.keep.includes(match.id) ? " (no code uses it; kept by extraction.keep)" : " (no code uses it; vi18n extract deletes it)");
102
+ for (const entry of match.catalogs) lines.push(` ${ctx.out.display(entry.file)}:${entry.line} ${entry.locale} ${entry.state}`);
103
+ }
104
+ if (data.more > 0) lines.push(`… and ${plural(data.more, "more match", "more matches")}`);
105
+ ctx.out.result(lines.join("\n"));
106
+ return {
107
+ exitCode: EXIT.ok,
108
+ data
109
+ };
110
+ }
111
+ function stateOf(entry) {
112
+ if (entry.fuzzy && entry.translation !== "") return "fuzzy";
113
+ return entry.translation === "" ? "untranslated" : entry.state;
114
+ }
115
+ //#endregion
116
+ export { which };