@menapo/vi18n 0.1.1 → 0.2.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.
Files changed (121) hide show
  1. package/README.md +19 -0
  2. package/dist/{apply-Bre-lY9J.js → apply-Bg-3rB2m.js} +69 -89
  3. package/dist/{captured-Bj8bO6vd.js → captured-DfLk50Ji.js} +196 -217
  4. package/dist/{check-BIKEuu6B.js → check-CunekuYs.js} +76 -85
  5. package/dist/cli.js +2 -3
  6. package/dist/{collect-Cx4_SKOe.js → collect-CYATDjdo.js} +1 -2
  7. package/dist/collisions-CDSdtLQm.js +215 -0
  8. package/dist/{compile-Cc97JaW2.js → compile-DqkofbiO.js} +376 -331
  9. package/dist/compile-hva0qjhZ.js +240 -0
  10. package/dist/concurrency-BCY_4zcr.js +1 -0
  11. package/dist/concurrency-Dy2ny50V.js +107 -0
  12. package/dist/config.d.ts +1 -5
  13. package/dist/config.js +4 -5
  14. package/dist/{types-D3QGM8XO.js → diagnostics-LgIWyeSp.js} +28 -27
  15. package/dist/{dir-zw6bGMKQ.js → dir-TGLYuOZb.js} +34 -37
  16. package/dist/{duplicates-yuRljQ6h.js → duplicates-8cudcHNj.js} +10 -27
  17. package/dist/engine-ecRD8-IE.js +556 -0
  18. package/dist/engine.d.ts +1 -5
  19. package/dist/engine.js +297 -168
  20. package/dist/exchange-DjwlrTQ9.js +41 -0
  21. package/dist/{exclude-Du-Zd_qI.js → exclude-BFETmvde.js} +2 -3
  22. package/dist/{export-C9Sy6UWv.js → export-D2tsqWIr.js} +17 -38
  23. package/dist/{extract-C3S8btx0.js → extract-BxYchVmY.js} +114 -82
  24. package/dist/{formats-9unqj_fZ.js → formats-BaryZ2N7.js} +352 -276
  25. package/dist/fs-ezCMZeDV.js +52 -0
  26. package/dist/i18next-COO6o0tX.js +1907 -0
  27. package/dist/i18next-Dr7DCQlQ.js +1 -0
  28. package/dist/{import-nANvQutw.js → import-vSC29Cn4.js} +81 -75
  29. package/dist/index.d.ts +1 -13
  30. package/dist/index.js +14 -16
  31. package/dist/{init-C2ScuW6a.js → init-Cc7A-8VX.js} +466 -501
  32. package/dist/{library-D5CWvTQs.js → library-tp_xqzSY.js} +975 -451
  33. package/dist/lingui-BnnlqGXT.js +902 -0
  34. package/dist/lint.d.ts +0 -4
  35. package/dist/lint.js +70 -82
  36. package/dist/{load-gW-oJt1Q.js → load-BSIeGJ5v.js} +275 -148
  37. package/dist/{load-CQRz4PpM.js → load-SSrAeJVB.js} +1214 -1116
  38. package/dist/{locales-DX4MOBFE.js → locales-D0U-yVRm.js} +271 -237
  39. package/dist/{lsp-RMMMc88P.js → lsp-DvC11pBZ.js} +4 -5
  40. package/dist/{match-BGr8EXB3.js → match-BLDcj610.js} +11 -4
  41. package/dist/{mcp-CHVwBoRP.js → mcp-D2zzOTBy.js} +4 -5
  42. package/dist/{merge-driver-BTX87aVm.js → merge-driver-BLI8OtAc.js} +138 -122
  43. package/dist/migrate-1r43OBfe.js +1 -0
  44. package/dist/migrate-ChDGhlC-.js +2169 -0
  45. package/dist/{openai-CTaMDcl-.js → openai-CLn4puY8.js} +128 -87
  46. package/dist/{output-DWE3SIUA.js → output-D5tAt8q4.js} +15 -9
  47. package/dist/parse.d.ts +1 -3
  48. package/dist/parse.js +7 -8
  49. package/dist/{pipeline-C9Dbotkh.js → pipeline-BJSkkRYC.js} +387 -359
  50. package/dist/{pipeline-DbX6rlo5.js → pipeline-BeCc441z.js} +1 -1
  51. package/dist/project-B5KIO0q-.js +544 -0
  52. package/dist/{pseudo-DRv30iN5.js → pseudo-B2DUpoLu.js} +126 -3
  53. package/dist/{raw-C4Y6vyGY.js → raw-YsYZMS9n.js} +52 -29
  54. package/dist/react-intl-C8JehBBL.js +634 -0
  55. package/dist/rename-ZVGq9ZG1.js +577 -0
  56. package/dist/repeated-uuI1tUGg.js +85 -0
  57. package/dist/restore-xlBIrtRt.js +199 -0
  58. package/dist/rewrite-BwzXoBiA.js +415 -0
  59. package/dist/{rich-DCUKl5HM.js → rich-ApY1Dm4S.js} +35 -28
  60. package/dist/rolldown-runtime-C1I3wEg2.js +43 -0
  61. package/dist/{rolldown-runtime-D7D4PA-g.js → rolldown-runtime-D8jQpDG7.js} +1 -2
  62. package/dist/run-CQ9pDLSa.js +674 -0
  63. package/dist/scan-worker.d.ts +2 -4
  64. package/dist/scan-worker.js +1 -1
  65. package/dist/{scoped-BMYpSthj.js → scoped-h3KE8XWW.js} +3 -4
  66. package/dist/{server-Da1Ot9IN.js → server-Br8tAuG2.js} +312 -386
  67. package/dist/{server-deBOq2vq.js → server-DJRpUQVZ.js} +1059 -333
  68. package/dist/server.d.ts +1 -17
  69. package/dist/server.js +419 -379
  70. package/dist/{sitemap-DJXzKoza.js → sitemap-CSAkm6oi.js} +21 -33
  71. package/dist/{sources-D19czDSA.js → sources-DNVbYsgs.js} +713 -373
  72. package/dist/{status-zr4jY59Y.js → status-q6M3rBrh.js} +30 -30
  73. package/dist/{stdio-FPOKQAgu.js → stdio-D9kTzyqB.js} +2 -4
  74. package/dist/{stdio-CVaJfxA7.js → stdio-FWIVU3P4.js} +1 -2
  75. package/dist/sync-BNIAwMhR.js +1352 -0
  76. package/dist/{t-DC-c9zE5.js → t-gvEXx25s.js} +76 -53
  77. package/dist/test.d.ts +5 -16
  78. package/dist/test.js +126 -56
  79. package/dist/translate-BP4iVhOR.js +336 -0
  80. package/dist/{ts-BaU5yOf0.js → ts-BX6kwig5.js} +25 -14
  81. package/dist/{types-DtvQ7UdD.js → types-3kwyaCAm.js} +1 -2
  82. package/dist/{types-DsdWBG0b.d.ts → types-B4wNX6PA.d.ts} +6 -8
  83. package/dist/{types-CgUCkFU1.d.ts → types-_4UdFhR9.d.ts} +24 -21
  84. package/dist/types-xR2exI3L.js +42 -0
  85. package/dist/{units-CQ5Q99RC.js → units-DPPfCN7j.js} +7 -16
  86. package/dist/{url-CRfCOhUI.js → url-Bpc6wLea.js} +24 -11
  87. package/dist/{url-CsBkRaJy.js → url-D2_VlEeH.js} +25 -12
  88. package/dist/{validate-BxpupdAf.js → validate-CgzaDdOY.js} +690 -377
  89. package/dist/{validate-D6DJepZv.js → validate-PGgMsasz.js} +3 -5
  90. package/dist/{version-Byqi2guX.js → version-DC-J5WvV.js} +3 -5
  91. package/dist/{vite-scan-CT_vsp4g.js → vite-scan-kM8Ta3rO.js} +87 -92
  92. package/dist/vite.d.ts +2 -6
  93. package/dist/vite.js +6500 -6032
  94. package/dist/vue-i18n-_uIXlFVh.js +806 -0
  95. package/dist/{which-BOemZ5Q8.js → which-DFWk_KwN.js} +44 -37
  96. package/dist/{worker-84U6uYB3.js → worker-zlhNj4y3.js} +454 -608
  97. package/package.json +5 -5
  98. package/dist/check-HsmmpJZg.js +0 -1
  99. package/dist/codec-DuvU2VQy.js +0 -207
  100. package/dist/collisions-CfpZU8e4.js +0 -217
  101. package/dist/compile-BaDh0cHG.js +0 -245
  102. package/dist/concurrency-C9UUWuDC.js +0 -96
  103. package/dist/concurrency-DONL7t4V.js +0 -1
  104. package/dist/engine-C2ENBRJe.js +0 -531
  105. package/dist/i18next-9HAoxwUI.js +0 -1
  106. package/dist/i18next-BEJgv_S8.js +0 -1596
  107. package/dist/lingui-zUiCl9Um.js +0 -833
  108. package/dist/messages-BfjIExyB.js +0 -166
  109. package/dist/migrate-IpLDMXmq.js +0 -1484
  110. package/dist/migrate-rCQuOGsf.js +0 -1
  111. package/dist/project-Bw9UPIdx.js +0 -1046
  112. package/dist/project-C4GpaN-n.js +0 -381
  113. package/dist/react-intl-BP0u-D5m.js +0 -519
  114. package/dist/restore-CiYv-jxS.js +0 -175
  115. package/dist/rewrite-EsIw_lsq.js +0 -803
  116. package/dist/run-BEcnBbu-.js +0 -694
  117. package/dist/runtime-DTMmliT1.js +0 -64
  118. package/dist/sync-B9V2KFwb.js +0 -658
  119. package/dist/translate-CQnJfLjO.js +0 -299
  120. package/dist/types-wSh9fCBY.js +0 -11
  121. package/dist/vue-i18n-g0iGy6CZ.js +0 -651
@@ -0,0 +1,336 @@
1
+ import { t as adaptiveConcurrency } from "./concurrency-Dy2ny50V.js";
2
+ import { a as firstRequests, c as runTranslations, i as estimateUsage, n as catalogPersister, o as planTranslations, r as createProvider, s as replayProvider } from "./pipeline-BJSkkRYC.js";
3
+ import { a as ownedMessages, n as libraryCoverage } from "./library-tp_xqzSY.js";
4
+ import { n as isDiagnosticError } from "./diagnostics-LgIWyeSp.js";
5
+ import { a as table, r as plural } from "./output-D5tAt8q4.js";
6
+ import { a as hasErrors, f as readErrors, g as usageError, h as targetLocales, m as scan, o as loadCatalogs, s as loadProject, t as CliExit } from "./project-B5KIO0q-.js";
7
+ import { r as EXIT } from "./types-xR2exI3L.js";
8
+ // src/cli/commands/translate.ts
9
+ /**
10
+ * `vi18n translate [--locale l]… [--provider name] [--model id] [--tier t]
11
+ * [--retranslate ai|all] [--dry-run] [--max-cost usd]` (INTERNALS §2.15,
12
+ * PLAN §5.20): plan every locale against the catalogs on disk, estimate,
13
+ * then translate one locale after another, writing each finished batch
14
+ * before the next is paid for. Exit 1 when any item still failed after its
15
+ * retries.
16
+ *
17
+ * `--tier batch` first submits every locale's first requests as Gemini
18
+ * batch jobs and waits for them; their answers then replay into the same
19
+ * per-locale runs, whose retries go out synchronously.
20
+ */
21
+ async function translate(ctx, flags) {
22
+ const project = await loadProject(ctx);
23
+ const locales = targetLocales(project.config, flags.locales);
24
+ const scanned = await scan(project);
25
+ ctx.out.report(scanned.diagnostics.filter((d) => d.severity === "error"));
26
+ const loaded = await loadCatalogs(project);
27
+ const unreadable = readErrors(loaded.diagnostics);
28
+ const provider = providerFor(ctx, project.config, flags);
29
+ const run = new TranslateRun(ctx, flags, project, {
30
+ messages: scanned.messages,
31
+ set: loaded.set
32
+ });
33
+ run.data.provider = provider.name;
34
+ run.data.model = provider.model;
35
+ if (unreadable.length > 0) {
36
+ ctx.out.report(unreadable);
37
+ return run.result(EXIT.failure);
38
+ }
39
+ run.plan(locales, provider);
40
+ if (!run.withinBudget(provider)) {
41
+ if (flags.dryRun) printEstimate(ctx, run.data);
42
+ return run.result(EXIT.failure);
43
+ }
44
+ if (flags.dryRun) {
45
+ printEstimate(ctx, run.data);
46
+ return run.result(hasErrors(ctx.out.diagnostics) ? EXIT.failure : EXIT.ok);
47
+ }
48
+ if (run.data.estimate.requests > 0) {
49
+ const missing = provider.missingKey?.() ?? null;
50
+ if (missing !== null) {
51
+ ctx.out.report([missing]);
52
+ return run.result(EXIT.failure);
53
+ }
54
+ }
55
+ return run.translate(locales, provider);
56
+ }
57
+ /** The provider the flags and config name; its key is redacted from every output. */
58
+ function providerFor(ctx, config, flags) {
59
+ let provider;
60
+ try {
61
+ provider = createProvider(config, {
62
+ ...flags.model === null ? {} : { model: flags.model },
63
+ ...flags.provider === null ? {} : { provider: flags.provider },
64
+ tier: flags.tier,
65
+ ...ctx.io.fetch === void 0 ? {} : { fetch: ctx.io.fetch },
66
+ env: ctx.io.env
67
+ });
68
+ } catch (error) {
69
+ if (isDiagnosticError(error)) throw new CliExit(EXIT.usage, [error.diagnostic]);
70
+ throw error;
71
+ }
72
+ if (typeof provider.apiKeyEnv === "string") ctx.out.addSecret(ctx.io.env[provider.apiKeyEnv]);
73
+ const configured = config.ai.provider;
74
+ if (flags.model !== null && flags.provider === null && configured !== "gemini" && configured.withModel === void 0) ctx.out.note(`vi18n: --model is ignored: ai.provider is a custom provider (${provider.name}, ${provider.model})`);
75
+ return provider;
76
+ }
77
+ /** One `vi18n translate` run: the plans per locale, then the locales translated one after another. */
78
+ var TranslateRun = class {
79
+ data;
80
+ ctx;
81
+ flags;
82
+ project;
83
+ messages;
84
+ set;
85
+ plans = /* @__PURE__ */ new Map();
86
+ /** Locales whose summary is complete. */
87
+ finished = 0;
88
+ constructor(ctx, flags, project, input) {
89
+ this.ctx = ctx;
90
+ this.flags = flags;
91
+ this.project = project;
92
+ this.messages = input.messages;
93
+ this.set = input.set;
94
+ this.data = {
95
+ dryRun: flags.dryRun,
96
+ provider: "",
97
+ model: "",
98
+ tier: flags.tier,
99
+ locales: [],
100
+ estimate: {
101
+ requests: 0,
102
+ inputTokens: 0,
103
+ outputTokens: 0,
104
+ cost: 0
105
+ }
106
+ };
107
+ }
108
+ result(exitCode) {
109
+ return {
110
+ exitCode,
111
+ data: this.data
112
+ };
113
+ }
114
+ plan(locales, provider) {
115
+ const { config, codec, layout } = this.project;
116
+ const coverage = libraryCoverage(this.set, this.messages, config, codec);
117
+ for (const locale of locales) {
118
+ const plan = planTranslations({
119
+ config,
120
+ codec,
121
+ messages: ownedMessages(this.messages, locale, this.set.get(locale)?.catalog ?? null, coverage, {
122
+ sourceLocale: config.sourceLocale,
123
+ layout,
124
+ codec
125
+ }),
126
+ catalogs: this.set,
127
+ locale,
128
+ retranslate: this.flags.retranslate
129
+ });
130
+ this.plans.set(locale, plan);
131
+ const usage = estimateUsage({
132
+ config,
133
+ locale,
134
+ plan
135
+ });
136
+ const estimate = {
137
+ ...usage,
138
+ cost: costOf(provider, usage)
139
+ };
140
+ this.data.locales.push({
141
+ ...emptySummary(locale),
142
+ estimate
143
+ });
144
+ addEstimate(this.data.estimate, estimate);
145
+ }
146
+ }
147
+ /** `--max-cost`: false (reported) when the estimate is over it or has no price. */
148
+ withinBudget(provider) {
149
+ const { maxCost, dryRun } = this.flags;
150
+ const { estimate } = this.data;
151
+ if (maxCost === null || estimate.requests === 0) return true;
152
+ const cost = estimate.cost;
153
+ if (cost !== null && cost <= maxCost) return true;
154
+ this.ctx.out.report([{
155
+ code: "ai-cost-limit",
156
+ severity: "error",
157
+ message: cost === null ? `no price for ${provider.model}, so the cost of ${plural(estimate.requests, "request")} cannot be checked against --max-cost ${maxCost}; nothing was sent` : `the estimated cost ${usd(cost)} of ${plural(estimate.requests, "request")} is over --max-cost ${usd(maxCost)}; nothing was sent${dryRun ? "" : " (see vi18n translate --dry-run)"}`
158
+ }]);
159
+ return false;
160
+ }
161
+ async translate(locales, provider) {
162
+ let runner = provider;
163
+ if (this.flags.tier === "batch" && this.data.estimate.requests > 0) {
164
+ const batched = await this.submitBatch(locales, provider);
165
+ if ("exitCode" in batched) return batched;
166
+ runner = batched.provider;
167
+ }
168
+ const concurrency = adaptiveConcurrency(this.project.config.ai.concurrency);
169
+ let failed = false;
170
+ for (let i = 0; i < locales.length; i++) {
171
+ if (this.aborted()) return this.interrupted();
172
+ const summary = await this.translateLocale(i, locales[i], runner, concurrency);
173
+ if ("exitCode" in summary) return summary;
174
+ if (summary.failed.length > 0) failed = true;
175
+ }
176
+ const exitCode = failed || hasErrors(this.ctx.out.diagnostics) ? EXIT.failure : EXIT.ok;
177
+ return this.result(exitCode);
178
+ }
179
+ /** `--tier batch`: every locale's first requests as batch jobs, replayed into the per-locale runs. */
180
+ async submitBatch(locales, provider) {
181
+ const { config } = this.project;
182
+ const requests = [];
183
+ for (const locale of locales) requests.push(...firstRequests({
184
+ config,
185
+ locale,
186
+ plan: this.plans.get(locale) ?? []
187
+ }));
188
+ if (provider.translateBatch === void 0) throw usageError(`--tier batch needs a provider with a batch API, not ${provider.name}`);
189
+ this.ctx.out.note(`vi18n translate: sending ${plural(requests.length, "request")} as batch jobs; results can take minutes to hours (Ctrl-C cancels)`);
190
+ const states = /* @__PURE__ */ new Map();
191
+ try {
192
+ const answers = await provider.translateBatch(requests, {
193
+ ...this.signal(),
194
+ onProgress: ({ job, state }) => {
195
+ if (states.get(job) === state) return;
196
+ states.set(job, state);
197
+ this.ctx.out.note(`vi18n translate: ${job}: ${state}`);
198
+ }
199
+ });
200
+ return { provider: replayProvider(provider, requests, answers) };
201
+ } catch (error) {
202
+ return this.failure(error);
203
+ }
204
+ }
205
+ async translateLocale(index, locale, provider, concurrency) {
206
+ const { config, codec } = this.project;
207
+ const persist = catalogPersister({
208
+ config,
209
+ codec,
210
+ locale,
211
+ messages: this.messages,
212
+ catalog: this.set.get(locale),
213
+ sourceCatalog: this.set.get(config.sourceLocale),
214
+ model: provider.model
215
+ });
216
+ let summary;
217
+ try {
218
+ summary = await runTranslations({
219
+ provider,
220
+ config,
221
+ locale,
222
+ plan: this.plans.get(locale),
223
+ persist,
224
+ concurrency,
225
+ ...this.signal()
226
+ });
227
+ } catch (error) {
228
+ return this.failure(error, locale);
229
+ }
230
+ const entry = this.data.locales[index];
231
+ Object.assign(entry, summary, { estimate: entry.estimate });
232
+ this.ctx.out.report(summaryDiagnostics(summary));
233
+ if (summary.rateLimited !== void 0) this.ctx.out.note(`vi18n translate: ${locale} was rate-limited ${plural(summary.rateLimited.count, "time")}; requests in flight now ${summary.rateLimited.concurrency} of ${concurrency.max}`);
234
+ this.finished = index + 1;
235
+ this.ctx.out.result(`${locale}: ${summary.translated} translated, ${summary.reused} reused, ${summary.failed.length} failed of ${summary.requested} requested (${summary.usage.inputTokens} input / ${summary.usage.outputTokens} output tokens)`);
236
+ return summary;
237
+ }
238
+ /** A provider error ends the run (batches finished before it are already on disk); Ctrl-C is an interruption. */
239
+ failure(error, locale) {
240
+ if (this.aborted()) return this.interrupted();
241
+ if (!isDiagnosticError(error)) throw error;
242
+ const diagnostic = error.diagnostic;
243
+ this.ctx.out.report([locale === void 0 ? diagnostic : {
244
+ ...diagnostic,
245
+ locale: diagnostic.locale ?? locale
246
+ }]);
247
+ return this.result(EXIT.failure);
248
+ }
249
+ signal() {
250
+ return this.ctx.io.signal === void 0 ? {} : { signal: this.ctx.io.signal };
251
+ }
252
+ /** A method, not a narrowed property read: the signal flips while awaiting. */
253
+ aborted() {
254
+ return this.ctx.io.signal?.aborted === true;
255
+ }
256
+ interrupted() {
257
+ this.data.interrupted = true;
258
+ this.data.locales = this.data.locales.filter((_, index) => index < this.finished);
259
+ this.ctx.out.note("vi18n translate: interrupted; finished batches are saved, rerun to translate the rest");
260
+ return this.result(EXIT.failure);
261
+ }
262
+ };
263
+ function emptySummary(locale) {
264
+ return {
265
+ locale,
266
+ requested: 0,
267
+ translated: 0,
268
+ reused: 0,
269
+ identical: [],
270
+ failed: [],
271
+ usage: {
272
+ inputTokens: 0,
273
+ outputTokens: 0
274
+ }
275
+ };
276
+ }
277
+ /** USD from the provider's pinned price table; null when it has none for the model. */
278
+ function costOf(provider, usage) {
279
+ if (usage.inputTokens === 0 && usage.outputTokens === 0) return 0;
280
+ const cost = provider.estimateCost?.(usage) ?? NaN;
281
+ return Number.isFinite(cost) ? cost : null;
282
+ }
283
+ function addEstimate(total, part) {
284
+ total.requests += part.requests;
285
+ total.inputTokens += part.inputTokens;
286
+ total.outputTokens += part.outputTokens;
287
+ total.cost = total.cost === null || part.cost === null ? null : total.cost + part.cost;
288
+ }
289
+ function usd(value) {
290
+ return `$${value < .01 && value > 0 ? value.toFixed(4) : value.toFixed(2)}`;
291
+ }
292
+ function printEstimate(ctx, data) {
293
+ const rows = data.locales.map((l) => [
294
+ l.locale,
295
+ l.estimate.requests,
296
+ l.estimate.inputTokens,
297
+ l.estimate.outputTokens,
298
+ l.estimate.cost === null ? "no price" : usd(l.estimate.cost)
299
+ ]);
300
+ const t = data.estimate;
301
+ rows.push([
302
+ "total",
303
+ t.requests,
304
+ t.inputTokens,
305
+ t.outputTokens,
306
+ t.cost === null ? "no price" : usd(t.cost)
307
+ ]);
308
+ ctx.out.result(table([
309
+ "locale",
310
+ "requests",
311
+ "input tokens",
312
+ "output tokens",
313
+ "cost"
314
+ ], rows));
315
+ const tier = data.tier === "standard" ? "" : `, ${data.tier} tier`;
316
+ ctx.out.result(`dry run with ${data.model}${tier}: nothing was sent (tokens estimated at 4 characters each)`);
317
+ }
318
+ function summaryDiagnostics(summary) {
319
+ const out = [];
320
+ for (const id of summary.identical) out.push({
321
+ code: "ai-identical-output",
322
+ severity: "info",
323
+ message: `the ${summary.locale} translation of ${id} is identical to the source (often right for names and words like "OK"); review it if unexpected`,
324
+ locale: summary.locale,
325
+ id
326
+ });
327
+ for (const failure of summary.failed) out.push({
328
+ code: "ai-validation-failed",
329
+ severity: "error",
330
+ message: `${failure.id} was left untranslated after its retries: ${failure.checks.join("; ")}`,
331
+ locale: summary.locale,
332
+ id: failure.id
333
+ });
334
+ return out;
335
+ }
336
+ export { translate };
@@ -1,4 +1,4 @@
1
- //#region ../../node_modules/.pnpm/oxc-parser@0.154.0/node_modules/oxc-parser/src-js/generated/deserialize/ts.js
1
+ // ../../node_modules/.pnpm/oxc-parser@0.156.0/node_modules/oxc-parser/src-js/generated/deserialize/ts.js
2
2
  let uint8;
3
3
  let int32;
4
4
  let float64;
@@ -346,11 +346,10 @@ function deserializeTaggedTemplateExpression(pos) {
346
346
  return node;
347
347
  }
348
348
  function deserializeTemplateElement(pos) {
349
- let tail = deserializeBool(pos + 12), start = deserializeI32(pos) - 1, end = deserializeI32(pos + 4) + 2 - tail, value = deserializeTemplateElementValue(pos + 16);
350
- value.cooked !== null && deserializeBool(pos + 13) && (value.cooked = value.cooked.replace(/\uFFFD(.{4})/g, (_, hex) => String.fromCodePoint(parseInt(hex, 16))));
349
+ let tail = deserializeBool(pos + 12), start = deserializeI32(pos) - 1, end = deserializeI32(pos + 4) + 2 - tail;
351
350
  return {
352
351
  type: "TemplateElement",
353
- value,
352
+ value: deserializeTemplateElementValue(pos + 16),
354
353
  tail,
355
354
  start,
356
355
  end
@@ -359,7 +358,7 @@ function deserializeTemplateElement(pos) {
359
358
  function deserializeTemplateElementValue(pos) {
360
359
  return {
361
360
  raw: deserializeStr(pos),
362
- cooked: deserializeOptionStr(pos + 16)
361
+ cooked: deserializeOptionJSStr(pos + 16)
363
362
  };
364
363
  }
365
364
  function deserializeComputedMemberExpression(pos) {
@@ -2054,16 +2053,14 @@ function deserializeNumericLiteral(pos) {
2054
2053
  };
2055
2054
  }
2056
2055
  function deserializeStringLiteral(pos) {
2057
- let start = deserializeI32(pos), end = deserializeI32(pos + 4), node = {
2056
+ let start = deserializeI32(pos), end = deserializeI32(pos + 4);
2057
+ return {
2058
2058
  type: "Literal",
2059
- value: null,
2059
+ value: deserializeJSStr(pos + 16),
2060
2060
  raw: int32[(pos >> 2) + 8] === 0 && int32[(pos >> 2) + 9] === 0 ? null : sourceText.slice(start, end),
2061
2061
  start,
2062
2062
  end
2063
- }, value = deserializeStr(pos + 16);
2064
- deserializeBool(pos + 12) && (value = value.replace(/\uFFFD(.{4})/g, (_, hex) => String.fromCodePoint(parseInt(hex, 16))));
2065
- node.value = value;
2066
- return node;
2063
+ };
2067
2064
  }
2068
2065
  function deserializeBigIntLiteral(pos) {
2069
2066
  let start = deserializeI32(pos), end = deserializeI32(pos + 4), bigint = deserializeStr(pos + 16);
@@ -4082,8 +4079,20 @@ function deserializeBoxTSTypeParameterInstantiation(pos) {
4082
4079
  function deserializeOptionBoxTSTypeParameterInstantiation(pos) {
4083
4080
  return int32[pos >> 2] === 0 && int32[(pos >> 2) + 1] === 0 ? null : deserializeBoxTSTypeParameterInstantiation(pos);
4084
4081
  }
4085
- function deserializeOptionStr(pos) {
4086
- return int32[pos >> 2] === 0 && int32[(pos >> 2) + 1] === 0 ? null : deserializeStr(pos);
4082
+ function deserializeJSStr(pos) {
4083
+ if (uint8[pos + 12] === 0) return deserializeStr(pos);
4084
+ let buffer = uint8, pos32 = pos >> 2, len = int32[pos32 + 2];
4085
+ pos = int32[pos32];
4086
+ let end = pos + len, out = "";
4087
+ for (; pos < end;) {
4088
+ let first = buffer[pos++], codePoint;
4089
+ codePoint = first < 128 ? first : first < 224 ? (first & 31) << 6 | buffer[pos++] & 63 : first < 240 ? (first & 15) << 12 | (buffer[pos++] & 63) << 6 | buffer[pos++] & 63 : (first & 7) << 18 | (buffer[pos++] & 63) << 12 | (buffer[pos++] & 63) << 6 | buffer[pos++] & 63;
4090
+ out += String.fromCodePoint(codePoint);
4091
+ }
4092
+ return out;
4093
+ }
4094
+ function deserializeOptionJSStr(pos) {
4095
+ return uint8[pos + 12] === 2 ? null : deserializeJSStr(pos);
4087
4096
  }
4088
4097
  function deserializeBoxComputedMemberExpression(pos) {
4089
4098
  return deserializeComputedMemberExpression(int32[pos >> 2]);
@@ -4489,6 +4498,9 @@ function deserializeOptionModuleExportName(pos) {
4489
4498
  function deserializeF64(pos) {
4490
4499
  return float64[pos >> 3];
4491
4500
  }
4501
+ function deserializeOptionStr(pos) {
4502
+ return int32[pos >> 2] === 0 && int32[(pos >> 2) + 1] === 0 ? null : deserializeStr(pos);
4503
+ }
4492
4504
  function deserializeU8(pos) {
4493
4505
  return uint8[pos];
4494
4506
  }
@@ -4859,5 +4871,4 @@ function deserializeVecExportEntry(pos) {
4859
4871
  }
4860
4872
  return arr;
4861
4873
  }
4862
- //#endregion
4863
4874
  export { deserialize };
@@ -1,5 +1,5 @@
1
1
  import * as z from "zod/v4";
2
- //#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_supports-color@10.2.2_zod@4.6.7/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
2
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_supports-color@10.2.2_zod@4.6.7/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
3
3
  const LATEST_PROTOCOL_VERSION = "2025-11-25";
4
4
  const SUPPORTED_PROTOCOL_VERSIONS = [
5
5
  LATEST_PROTOCOL_VERSION,
@@ -1944,5 +1944,4 @@ var UrlElicitationRequiredError = class extends McpError {
1944
1944
  return this.data?.elicitations ?? [];
1945
1945
  }
1946
1946
  };
1947
- //#endregion
1948
1947
  export { PingRequestSchema as A, isJSONRPCNotification as B, ListResourcesRequestSchema as C, ListToolsRequestSchema as D, ListTasksResultSchema as E, SetLevelRequestSchema as F, isJSONRPCResultResponse as H, TaskStatusNotificationSchema as I, assertCompleteRequestPrompt as L, RELATED_TASK_META_KEY as M, ReadResourceRequestSchema as N, LoggingLevelSchema as O, SUPPORTED_PROTOCOL_VERSIONS as P, assertCompleteRequestResourceTemplate as R, ListResourceTemplatesRequestSchema as S, ListTasksRequestSchema as T, isTaskAugmentedRequestParams as U, isJSONRPCRequest as V, InitializeRequestSchema as _, CancelledNotificationSchema as a, LATEST_PROTOCOL_VERSION as b, CreateMessageResultWithToolsSchema as c, EmptyResultSchema as d, ErrorCode as f, GetTaskResultSchema as g, GetTaskRequestSchema as h, CancelTaskResultSchema as i, ProgressNotificationSchema as j, McpError as k, CreateTaskResultSchema as l, GetTaskPayloadRequestSchema as m, CallToolResultSchema as n, CompleteRequestSchema as o, GetPromptRequestSchema as p, CancelTaskRequestSchema as r, CreateMessageResultSchema as s, CallToolRequestSchema as t, ElicitResultSchema as u, InitializedNotificationSchema as v, ListRootsResultSchema as w, ListPromptsRequestSchema as x, JSONRPCMessageSchema as y, isJSONRPCErrorResponse as z };
@@ -1,4 +1,3 @@
1
- //#region src/runtime/typed.d.ts
2
1
  /**
3
2
  * Augmented by the generated `vi18n.gen.ts`:
4
3
  *
@@ -106,9 +105,9 @@ type DefaultTags = Register extends {
106
105
  defaultTags: infer T extends string;
107
106
  } ? T : never;
108
107
  /** The literal text of a message, `never` for anything typed as a runtime id. */
109
- type TextOf<M> = M extends string ? Record<never, never> extends Record<M, 1> ? never : M : M extends {
108
+ type TextOf<M> = M extends string ? Literal<M> : M extends {
110
109
  readonly message: infer T extends string;
111
- } ? Record<never, never> extends Record<T, 1> ? never : T : never;
110
+ } ? Literal<T> : never;
112
111
  type Untyped = [values?: Values];
113
112
  type Rich<S extends string, H, N, WithTags extends boolean> = [S] extends [never] ? Untyped : ValuesOf<S> extends (infer A) ? Unreadable extends A ? Untyped : (WithTags extends true ? TagsOf<S, never> : never) extends (infer Tg extends string) ? string extends Tg ? Untyped : Handlers<Tg, H, Args<A, N>> : never : never;
114
113
  /** The argument object of a `ValuesOf` result; a plain `{x}` takes nodes too. */
@@ -216,8 +215,6 @@ type Trim<S extends string> = S extends `${Space}${infer R}` ? Trim<R> : S exten
216
215
  * it, so marks wait in `Marks` until that is known.
217
216
  */
218
217
  type TrimEnd<S extends string, Marks extends string> = S extends `${infer R}${Space}` ? S extends `${R}\u200e` ? TrimEnd<R, `\u200e${Marks}`> : S extends `${R}\u200f` ? TrimEnd<R, `\u200f${Marks}`> : TrimEnd<R, ""> : `${S}${Marks}`;
219
- //#endregion
220
- //#region src/runtime/types.d.ts
221
218
  /**
222
219
  * A compiled message. Plain text stays a string (about 81 % of real messages),
223
220
  * everything else is a list of parts. Never a function: the IR has to cross
@@ -424,9 +421,11 @@ interface Scope {
424
421
  * Set only by `@menapo/vi18n/test` on the page scope (PLAN §5.22): the
425
422
  * message to render for every key, chosen with the descriptor that a
426
423
  * catalog map never sees (ids and pseudo modes, messages keyed by source
427
- * text). Builds never read it (INTERNALS §6 D189).
424
+ * text). Called as a method of the scope it renders for, so one hook
425
+ * serves the page and every `/server` scope. Builds never read it
426
+ * (INTERNALS §6 D189).
428
427
  */
429
- test?: (id: string, descriptor: CompiledDescriptor | undefined, text: string) => Message;
428
+ test?: (this: Scope, id: string, descriptor: CompiledDescriptor | undefined, text: string) => Message;
430
429
  /**
431
430
  * Dev only, set on the page scope by the in-context editor (`devtools`,
432
431
  * INTERNALS §2.18): hears every id the page looks up. Builds fold the
@@ -554,5 +553,4 @@ declare global {
554
553
  */
555
554
  var __VI18N_INLINE__: boolean | undefined;
556
555
  }
557
- //#endregion
558
556
  export { Locale as C, ValuesOf as D, RichValuesOf as E, LibraryMessages as S, RichPartsValuesOf as T, TagHandler as _, Message as a, Values as b, MissingHandler as c, RichHtmlFunction as d, RichPart as f, TFunction as g, Scope as h, HtmlTagHandler as i, MissingInfo as l, RuntimeConfig as m, Descriptor as n, MessageKey as o, RichPartsFunction as p, Fmt as r, MessageRef as s, DateInput as t, RichFunction as u, TemporalInput as v, Register as w, DefaultTags as x, Translator as y };
@@ -1,4 +1,7 @@
1
- //#region src/runtime/types.d.ts
1
+ /** Options handed to `Intl.NumberFormat` / `Intl.DateTimeFormat` as they are. */
2
+ type IntlOptions = {
3
+ [option: string]: string | number | boolean;
4
+ };
2
5
  /** Where a locale may come from, in `routing.strategy` order. */
3
6
  type LocaleStrategy = "url" | "cookie" | "header" | "localStorage" | "default";
4
7
  /** URL codec strategies (Nuxt i18n names); domains are `routing.domains` on top of `prefix_except_default`. */
@@ -37,14 +40,12 @@ declare global {
37
40
  */
38
41
  var __VI18N_INLINE__: boolean | undefined;
39
42
  }
40
- //#endregion
41
- //#region src/core/types.d.ts
42
43
  type Severity = "error" | "warning" | "info";
43
44
  /**
44
45
  * Every problem vi18n reports has one of these codes. The CLI prints them in
45
46
  * `--json` and as GitHub annotation titles (`vi18n(<code>)`).
46
47
  */
47
- type DiagnosticCode = "icu-syntax" | "icu-missing-other" | "icu-unsupported-type" | "icu-pattern-style" | "icu-pound-nested" | "icu-unknown-skeleton" | "icu-unknown-currency" | "icu-unknown-unit" | "icu-bidi-control" | "icu-unbalanced-isolate" | "icu-argument-mismatch" | "icu-tag-mismatch" | "icu-plural-missing-category" | "icu-plural-unused-category" | "icu-plural-one-literal" | "icu-apostrophe" | "icu-max-length" | "extract-dynamic-message" | "extract-non-literal-option" | "extract-invalid-manual-id" | "extract-module-scope" | "extract-html-sink" | "extract-captured-value" | "extract-wrapper-unused" | "extract-outside-include" | "extract-parse-error" | "extract-missing-compiler" | "extract-empty-root" | "id-collision" | "id-scheme-mismatch" | "catalog-parse" | "catalog-duplicate" | "catalog-wrapped" | "catalog-foreign-context" | "catalog-source-mismatch" | "catalog-fuzzy" | "catalog-invalid-translation" | "catalog-missing-translation" | "catalog-unused-entry" | "catalog-obsolete-dropped" | "catalog-safety-limit" | "catalog-drift" | "catalog-write-conflict" | "keep-missing-entry" | "import-parse" | "import-skipped" | "restore-git" | "merge-conflict" | "config-invalid" | "config-not-found" | "build-guard-skipped" | "build-dead-messages" | "ai-validation-failed" | "ai-identical-output" | "ai-provider-error" | "ai-missing-key" | "ai-cost-limit" | "migrate-dynamic-key" | "migrate-date-placeholder" | "migrate-manual" | "migrate-unconverted";
48
+ type DiagnosticCode = "icu-syntax" | "icu-missing-other" | "icu-unsupported-type" | "icu-pattern-style" | "icu-pound-nested" | "icu-unknown-skeleton" | "icu-unknown-currency" | "icu-unknown-unit" | "icu-bidi-control" | "icu-unbalanced-isolate" | "icu-argument-mismatch" | "icu-tag-mismatch" | "icu-plural-missing-category" | "icu-plural-unused-category" | "icu-plural-one-literal" | "icu-apostrophe" | "icu-max-length" | "extract-dynamic-message" | "extract-non-literal-option" | "extract-invalid-manual-id" | "extract-module-scope" | "extract-html-sink" | "extract-captured-value" | "extract-wrapper-unused" | "extract-outside-include" | "extract-parse-error" | "extract-missing-compiler" | "extract-empty-root" | "extract-repeated-text" | "extract-edited-text" | "id-collision" | "id-scheme-mismatch" | "catalog-parse" | "catalog-duplicate" | "catalog-wrapped" | "catalog-foreign-context" | "catalog-source-mismatch" | "catalog-fuzzy" | "catalog-invalid-translation" | "catalog-missing-translation" | "catalog-unused-entry" | "catalog-obsolete-dropped" | "catalog-safety-limit" | "catalog-drift" | "catalog-write-conflict" | "keep-missing-entry" | "import-parse" | "import-skipped" | "restore-git" | "rename-refused" | "merge-conflict" | "config-invalid" | "config-not-found" | "build-guard-skipped" | "build-dead-messages" | "ai-validation-failed" | "ai-identical-output" | "ai-provider-error" | "ai-missing-key" | "ai-cost-limit" | "migrate-dynamic-key" | "migrate-date-placeholder" | "migrate-manual" | "migrate-unconverted";
48
49
  interface Diagnostic {
49
50
  code: DiagnosticCode;
50
51
  severity: Severity;
@@ -104,9 +105,7 @@ interface IcuFormatted {
104
105
  * Intl options resolved by the parser (FormatJS `formats` tables for
105
106
  * keywords, skeleton conversion for `::…`). Null when Intl defaults apply.
106
107
  */
107
- options: {
108
- [option: string]: string | number | boolean;
109
- } | null;
108
+ options: IntlOptions | null;
110
109
  loc?: IcuLoc;
111
110
  }
112
111
  /**
@@ -195,14 +194,14 @@ interface MessageOccurrence {
195
194
  context?: string;
196
195
  maxLength?: number;
197
196
  callee: CalleeKind;
197
+ /** Under `vi18n-ignore`: the repeated-text check skips it. Set only when true. */
198
+ ignored?: true;
198
199
  /** Posix path relative to the config root (a `#:` reference). */
199
200
  file: string;
200
201
  /** 1-based position in the original file; 0 when not yet located. */
201
202
  line: number;
202
203
  column: number;
203
204
  }
204
- //#endregion
205
- //#region src/ai/types.d.ts
206
205
  /** Whatever a provider needs to answer one request. One target locale per request. */
207
206
  interface ProviderRequest {
208
207
  sourceLocale: string;
@@ -254,10 +253,12 @@ interface ProviderResponse {
254
253
  id: string;
255
254
  translation: string;
256
255
  }[];
257
- usage?: {
258
- inputTokens: number;
259
- outputTokens: number;
260
- };
256
+ usage?: TokenUsage;
257
+ }
258
+ /** Tokens a request, a run or an estimate counts. */
259
+ interface TokenUsage {
260
+ inputTokens: number;
261
+ outputTokens: number;
261
262
  }
262
263
  /** What the pipeline passes with each request. */
263
264
  interface TranslateOptions {
@@ -279,10 +280,7 @@ interface TranslationProvider {
279
280
  * `--dry-run` / `--max-cost`: estimated USD for the given token counts, from a
280
281
  * pinned price table; `NaN` when the model has no known price.
281
282
  */
282
- estimateCost?(usage: {
283
- inputTokens: number;
284
- outputTokens: number;
285
- }): number;
283
+ estimateCost?(usage: TokenUsage): number;
286
284
  /**
287
285
  * The environment variable the key is read from, null when no key is sent.
288
286
  * The CLI redacts its value from all output.
@@ -353,12 +351,11 @@ interface OpenAICompatibleOptions extends Omit<ProviderOptions, "tier"> {
353
351
  type JsonSchema = {
354
352
  [keyword: string]: unknown;
355
353
  };
356
- //#endregion
357
- //#region src/config/types.d.ts
358
354
  /** Severity of a `strict` rule. */
359
355
  type Level = "off" | "warn" | "error";
360
356
  /** The two generated pseudo-locales (PLAN §4.7, §5.21). */
361
- type PseudoLocale = "en-XA" | "ar-XB";
357
+ declare const PSEUDO_LOCALES: readonly ["en-XA", "ar-XB"];
358
+ type PseudoLocale = (typeof PSEUDO_LOCALES)[number];
362
359
  /** `vi18n.config.ts` as written. Every key is optional except where noted. */
363
360
  interface Vi18nConfig {
364
361
  /** Default `"en"`. Also the default locale of URL strategies and negotiation. */
@@ -393,6 +390,12 @@ interface Vi18nConfig {
393
390
  * (`package.json#vi18n`). Default `[]`.
394
391
  */
395
392
  dependencies?: string[];
393
+ /**
394
+ * `vi18n check` and the language server warn when one literal text is
395
+ * written at this many `t()`/`rich()` call sites or more (at least 2);
396
+ * `false` turns the warning off. Default 3.
397
+ */
398
+ repeatedText?: number | false;
396
399
  };
397
400
  ids?: {
398
401
  /** Base64url characters of every generated id, 8–16. Default 12. Changing it is a re-key. */
@@ -606,6 +609,7 @@ interface ResolvedConfig {
606
609
  globals: string[];
607
610
  keep: string[];
608
611
  dependencies: string[];
612
+ repeatedText: number | false;
609
613
  };
610
614
  ids: {
611
615
  length: number;
@@ -703,5 +707,4 @@ type TagDefault = string | {
703
707
  [name: string]: string;
704
708
  };
705
709
  };
706
- //#endregion
707
710
  export { MessageOccurrence as _, Vi18nConfig as a, OpenAICompatibleOptions as c, ProviderResponse as d, Tier as f, MessageCodec as g, Diagnostic as h, ResolvedConfig as i, ProviderOptions as l, TranslationProvider as m, OutputOptions as n, AiItem as o, TranslateOptions as p, PseudoLocale as r, BatchOptions as s, Level as t, ProviderRequest as u, LocaleStrategy as v, UrlStrategy as y };
@@ -0,0 +1,42 @@
1
+ // src/cli/types.ts
2
+ const COMMAND_NAMES = [
3
+ "init",
4
+ "extract",
5
+ "check",
6
+ "status",
7
+ "compile",
8
+ "translate",
9
+ "migrate",
10
+ "sitemap",
11
+ "export",
12
+ "import",
13
+ "restore",
14
+ "rename",
15
+ "which",
16
+ "merge-driver",
17
+ "lsp",
18
+ "mcp"
19
+ ];
20
+ const CHECK_CATEGORIES = [
21
+ "missing",
22
+ "placeholders",
23
+ "syntax"
24
+ ];
25
+ /** The libraries `migrate --from` converts (PLAN §5.19). */
26
+ const LIBRARIES = [
27
+ "i18next",
28
+ "react-intl",
29
+ "lingui",
30
+ "vue-i18n"
31
+ ];
32
+ /** What `migrate --from` converts: saas-i18n's key catalogue and the libraries. */
33
+ const MIGRATIONS = ["saas-i18n", ...LIBRARIES];
34
+ /** Exit codes of every command. */
35
+ const EXIT = {
36
+ ok: 0,
37
+ /** Errors found, drift, a safety refusal, failed translations. */
38
+ failure: 1,
39
+ /** Bad flags, no config, invalid config. */
40
+ usage: 2
41
+ };
42
+ export { MIGRATIONS as a, LIBRARIES as i, COMMAND_NAMES as n, EXIT as r, CHECK_CATEGORIES as t };