@menapo/vi18n 0.0.0-stage → 0.1.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/LICENSE +49 -0
- package/README.md +110 -2
- package/dist/apply-Bre-lY9J.js +228 -0
- package/dist/captured-Bj8bO6vd.js +1034 -0
- package/dist/check-D34P-S--.js +1 -0
- package/dist/check-DyrAbv73.js +201 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +41 -0
- package/dist/codec-DuvU2VQy.js +207 -0
- package/dist/collect-Cx4_SKOe.js +13 -0
- package/dist/collisions-CfpZU8e4.js +217 -0
- package/dist/compile-B5Mz6WJm.js +245 -0
- package/dist/compile-Cc97JaW2.js +2502 -0
- package/dist/concurrency-C9UUWuDC.js +96 -0
- package/dist/concurrency-DONL7t4V.js +1 -0
- package/dist/config.d.ts +21 -0
- package/dist/config.js +39 -0
- package/dist/dir-zw6bGMKQ.js +290 -0
- package/dist/duplicates-yuRljQ6h.js +185 -0
- package/dist/engine-B7p40M__.js +531 -0
- package/dist/engine.d.ts +43 -0
- package/dist/engine.js +1241 -0
- package/dist/exclude-Du-Zd_qI.js +26 -0
- package/dist/export-DGsMbcTZ.js +103 -0
- package/dist/extract-Dujlsgnk.js +298 -0
- package/dist/formats-KPIg-08V.js +781 -0
- package/dist/i18next-CrUnKFfh.js +1596 -0
- package/dist/i18next-Rgo-v9l0.js +1 -0
- package/dist/import-Cwdhcywt.js +225 -0
- package/dist/index.d.ts +156 -0
- package/dist/index.js +239 -0
- package/dist/init-BecCTvKi.js +792 -0
- package/dist/library-D5CWvTQs.js +1882 -0
- package/dist/lingui--PcOOYry.js +833 -0
- package/dist/lint.d.ts +105 -0
- package/dist/lint.js +971 -0
- package/dist/load-CQRz4PpM.js +2950 -0
- package/dist/load-gW-oJt1Q.js +747 -0
- package/dist/locales-DX4MOBFE.js +827 -0
- package/dist/lsp-Cq1Nuu-Q.js +31 -0
- package/dist/match-BGr8EXB3.js +89 -0
- package/dist/mcp-Cf0T7qPW.js +28 -0
- package/dist/merge-driver-CpiiSVIc.js +422 -0
- package/dist/messages-Cxa-5tR0.js +166 -0
- package/dist/migrate-CntqvrW4.js +1 -0
- package/dist/migrate-dPgq9uzy.js +1484 -0
- package/dist/openai-CTaMDcl-.js +346 -0
- package/dist/output-DsaHKHEt.js +164 -0
- package/dist/parse.d.ts +62 -0
- package/dist/parse.js +156 -0
- package/dist/pipeline-C7g11THL.js +2031 -0
- package/dist/pipeline-wxS0SApG.js +1 -0
- package/dist/project-Dwx7iPm6.js +381 -0
- package/dist/project-pXipT8iG.js +1046 -0
- package/dist/pseudo-DRv30iN5.js +145 -0
- package/dist/raw-C4Y6vyGY.js +4708 -0
- package/dist/react-intl-CaBVwJ9u.js +519 -0
- package/dist/restore-Btq66Tid.js +175 -0
- package/dist/rewrite-CiTRAICl.js +803 -0
- package/dist/rich-DCUKl5HM.js +97 -0
- package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
- package/dist/run-DYD_VXKy.js +694 -0
- package/dist/runtime-DTMmliT1.js +64 -0
- package/dist/scan-worker.d.ts +62 -0
- package/dist/scan-worker.js +1 -0
- package/dist/scoped-BMYpSthj.js +44 -0
- package/dist/server-BDkykMjb.js +11823 -0
- package/dist/server-qv3mz70d.js +10485 -0
- package/dist/server.d.ts +169 -0
- package/dist/server.js +1234 -0
- package/dist/sitemap-DV3o8QD7.js +159 -0
- package/dist/sources-D19czDSA.js +2242 -0
- package/dist/status-DZArW5aE.js +149 -0
- package/dist/stdio-CVaJfxA7.js +29 -0
- package/dist/stdio-FPOKQAgu.js +95 -0
- package/dist/sync-CcVzger_.js +658 -0
- package/dist/t-DC-c9zE5.js +454 -0
- package/dist/test.d.ts +116 -0
- package/dist/test.js +319 -0
- package/dist/translate-DZR3MkSA.js +299 -0
- package/dist/ts-BaU5yOf0.js +4863 -0
- package/dist/types-CgUCkFU1.d.ts +707 -0
- package/dist/types-D3QGM8XO.js +146 -0
- package/dist/types-DsdWBG0b.d.ts +558 -0
- package/dist/types-DtvQ7UdD.js +1948 -0
- package/dist/types-wSh9fCBY.js +11 -0
- package/dist/units-CQ5Q99RC.js +150 -0
- package/dist/url-CRfCOhUI.js +172 -0
- package/dist/url-CsBkRaJy.js +225 -0
- package/dist/validate-BxpupdAf.js +2615 -0
- package/dist/validate-D6DJepZv.js +365 -0
- package/dist/version-BlyLGlOa.js +28 -0
- package/dist/vite-scan-B_YW4X_a.js +242 -0
- package/dist/vite.d.ts +34 -0
- package/dist/vite.js +7558 -0
- package/dist/vue-i18n-CEMnpv7k.js +651 -0
- package/dist/which-C6PFI1Dm.js +116 -0
- package/dist/worker-84U6uYB3.js +1656 -0
- package/package.json +97 -3
- package/schemas/catalog.json +57 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { s as catalogPath } from "./library-D5CWvTQs.js";
|
|
2
|
+
import { a as table, i as rootRelative } from "./output-DsaHKHEt.js";
|
|
3
|
+
import { t as EXIT } from "./types-wSh9fCBY.js";
|
|
4
|
+
import { a as loadCatalogs, c as ownStatus, d as referencedMessages, f as scan, i as hasErrors, l as percent, o as loadProject, p as targetLocales } from "./project-Dwx7iPm6.js";
|
|
5
|
+
import { dirname, join, relative } from "node:path";
|
|
6
|
+
import { readFile, stat } from "node:fs/promises";
|
|
7
|
+
//#region src/cli/commands/status.ts
|
|
8
|
+
/**
|
|
9
|
+
* `vi18n status [--json] [--locale l]…` (INTERNALS §2.14, PLAN §5.19): per
|
|
10
|
+
* target locale, how many referenced messages (code plus `keep` ids) its own
|
|
11
|
+
* catalog translates, by people or AI; per bundle from the last client build
|
|
12
|
+
* report when there is one. `--json` lists the entries counted as missing
|
|
13
|
+
* because they are invalid or fuzzy, for agents to fix.
|
|
14
|
+
*/
|
|
15
|
+
/** The client environment's report (INTERNALS §2.9.8); server builds plan no bundles. */
|
|
16
|
+
const REPORT = join("vi18n", "report-client.json");
|
|
17
|
+
async function status(ctx, flags) {
|
|
18
|
+
const project = await loadProject(ctx);
|
|
19
|
+
const { config } = project;
|
|
20
|
+
const locales = targetLocales(config, flags.locales);
|
|
21
|
+
const scanned = await scan(project);
|
|
22
|
+
const loaded = await loadCatalogs(project);
|
|
23
|
+
ctx.out.report(loaded.diagnostics.filter((d) => d.severity === "error"));
|
|
24
|
+
const referenced = referencedMessages(project, scanned.messages, loaded.set);
|
|
25
|
+
ctx.out.report(referenced.diagnostics);
|
|
26
|
+
const data = {
|
|
27
|
+
sourceLocale: config.sourceLocale,
|
|
28
|
+
locales: [],
|
|
29
|
+
invalid: []
|
|
30
|
+
};
|
|
31
|
+
for (const locale of locales) {
|
|
32
|
+
const catalog = loaded.set.get(locale);
|
|
33
|
+
const own = ownStatus(project, locale, catalog, referenced.identities);
|
|
34
|
+
data.locales.push({
|
|
35
|
+
locale,
|
|
36
|
+
total: own.total,
|
|
37
|
+
translated: own.translated,
|
|
38
|
+
ai: own.ai,
|
|
39
|
+
missing: own.missing,
|
|
40
|
+
percent: percent(own.translated + own.ai, own.total)
|
|
41
|
+
});
|
|
42
|
+
const file = rootRelative(config.root, catalog?.path ?? catalogPath(config, locale));
|
|
43
|
+
for (const item of own.invalid) data.invalid.push({
|
|
44
|
+
locale,
|
|
45
|
+
id: item.id,
|
|
46
|
+
reason: item.reason,
|
|
47
|
+
file,
|
|
48
|
+
line: item.line
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
const report = await readReport(ctx, project);
|
|
52
|
+
if (report !== null) {
|
|
53
|
+
const bundles = [];
|
|
54
|
+
for (const locale of locales) {
|
|
55
|
+
const coverage = report.coverage[locale];
|
|
56
|
+
if (coverage === void 0) continue;
|
|
57
|
+
for (const key of Object.keys(coverage).sort()) {
|
|
58
|
+
const c = coverage[key];
|
|
59
|
+
bundles.push({
|
|
60
|
+
key,
|
|
61
|
+
locale,
|
|
62
|
+
total: c.total,
|
|
63
|
+
translated: c.translated,
|
|
64
|
+
ai: c.ai,
|
|
65
|
+
missing: c.missing,
|
|
66
|
+
percent: percent(c.translated + c.ai, c.total)
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
data.bundles = bundles;
|
|
71
|
+
}
|
|
72
|
+
const row = (r) => [
|
|
73
|
+
r.locale,
|
|
74
|
+
r.total,
|
|
75
|
+
r.translated,
|
|
76
|
+
r.ai,
|
|
77
|
+
r.missing,
|
|
78
|
+
r.percent
|
|
79
|
+
];
|
|
80
|
+
ctx.out.result(table([
|
|
81
|
+
"locale",
|
|
82
|
+
"total",
|
|
83
|
+
"translated",
|
|
84
|
+
"ai",
|
|
85
|
+
"missing",
|
|
86
|
+
"%"
|
|
87
|
+
], data.locales.map(row)));
|
|
88
|
+
if (data.bundles !== void 0 && data.bundles.length > 0) {
|
|
89
|
+
ctx.out.result("");
|
|
90
|
+
ctx.out.result(table([
|
|
91
|
+
"bundle",
|
|
92
|
+
"locale",
|
|
93
|
+
"total",
|
|
94
|
+
"translated",
|
|
95
|
+
"ai",
|
|
96
|
+
"missing",
|
|
97
|
+
"%"
|
|
98
|
+
], data.bundles.map((r) => [r.key, ...row(r)])));
|
|
99
|
+
}
|
|
100
|
+
if (data.invalid.length > 0) ctx.out.result(`\n${data.invalid.length} entries are counted as missing because they are invalid or fuzzy; run vi18n check for details`);
|
|
101
|
+
return {
|
|
102
|
+
exitCode: hasErrors(ctx.out.diagnostics) ? EXIT.failure : EXIT.ok,
|
|
103
|
+
data
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The newest `report-client.json` under a Vite cache directory the project
|
|
108
|
+
* can have: Vite's default `node_modules/.vite` of the config root, or of
|
|
109
|
+
* any directory between an include entry and the root (an app inside a
|
|
110
|
+
* workspace whose config sits at the repository root). The CLI cannot load
|
|
111
|
+
* the Vite config, so a custom `cacheDir` is not seen. A report built with
|
|
112
|
+
* another id scheme describes other ids and is ignored.
|
|
113
|
+
*/
|
|
114
|
+
async function readReport(ctx, project) {
|
|
115
|
+
const { config, codec } = project;
|
|
116
|
+
const dirs = /* @__PURE__ */ new Set([config.root]);
|
|
117
|
+
for (const entry of config.project.include) for (let dir = dirname(entry);; dir = dirname(dir)) {
|
|
118
|
+
const rel = relative(config.root, dir);
|
|
119
|
+
if (rel.startsWith("..") || dir === dirname(dir)) break;
|
|
120
|
+
dirs.add(dir);
|
|
121
|
+
if (rel === "") break;
|
|
122
|
+
}
|
|
123
|
+
let best = null;
|
|
124
|
+
for (const dir of dirs) {
|
|
125
|
+
const file = join(dir, "node_modules", ".vite", REPORT);
|
|
126
|
+
try {
|
|
127
|
+
const info = await stat(file);
|
|
128
|
+
if (best === null || info.mtimeMs > best.mtime) best = {
|
|
129
|
+
file,
|
|
130
|
+
mtime: info.mtimeMs
|
|
131
|
+
};
|
|
132
|
+
} catch {}
|
|
133
|
+
}
|
|
134
|
+
if (best === null) return null;
|
|
135
|
+
try {
|
|
136
|
+
const report = JSON.parse(await readFile(best.file, "utf8"));
|
|
137
|
+
if (report.version !== 1 || typeof report.coverage !== "object" || report.coverage === null) return null;
|
|
138
|
+
if (report.idScheme !== codec.idScheme) {
|
|
139
|
+
ctx.out.note(`vi18n: ignoring ${ctx.out.display(best.file)}: built with ${report.idScheme}, not ${codec.idScheme}; rebuild for per-bundle numbers`);
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
return report;
|
|
143
|
+
} catch {
|
|
144
|
+
ctx.out.note(`vi18n: ignoring ${ctx.out.display(best.file)}: not a vi18n build report`);
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
//#endregion
|
|
149
|
+
export { status };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { format } from "node:util";
|
|
2
|
+
//#region src/cli/stdio.ts
|
|
3
|
+
/**
|
|
4
|
+
* For the commands that speak a protocol on stdout (`lsp`, `mcp`): one stray
|
|
5
|
+
* `console.log` (from a config module, a framework compiler, Vite) would be
|
|
6
|
+
* read by the client as a malformed message, so while they run the console
|
|
7
|
+
* writes to stderr, which editors and agents show as the server's log.
|
|
8
|
+
*/
|
|
9
|
+
function protocolConsole(output) {
|
|
10
|
+
if (output !== process.stdout) return () => {};
|
|
11
|
+
const { log, info, debug } = console;
|
|
12
|
+
const toStderr = (...args) => {
|
|
13
|
+
process.stderr.write(format(...args) + "\n");
|
|
14
|
+
};
|
|
15
|
+
Object.assign(console, {
|
|
16
|
+
log: toStderr,
|
|
17
|
+
info: toStderr,
|
|
18
|
+
debug: toStderr
|
|
19
|
+
});
|
|
20
|
+
return () => {
|
|
21
|
+
Object.assign(console, {
|
|
22
|
+
log,
|
|
23
|
+
info,
|
|
24
|
+
debug
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { protocolConsole as t };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { y as JSONRPCMessageSchema } from "./types-DtvQ7UdD.js";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
/**
|
|
4
|
+
* Buffers a continuous stdio stream into discrete JSON-RPC messages.
|
|
5
|
+
*/
|
|
6
|
+
var ReadBuffer = class {
|
|
7
|
+
constructor(options) {
|
|
8
|
+
this._maxBufferSize = options?.maxBufferSize ?? 10485760;
|
|
9
|
+
}
|
|
10
|
+
append(chunk) {
|
|
11
|
+
if ((this._buffer?.length ?? 0) + chunk.length > this._maxBufferSize) {
|
|
12
|
+
this.clear();
|
|
13
|
+
throw new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);
|
|
14
|
+
}
|
|
15
|
+
this._buffer = this._buffer ? Buffer.concat([this._buffer, chunk]) : chunk;
|
|
16
|
+
}
|
|
17
|
+
readMessage() {
|
|
18
|
+
if (!this._buffer) return null;
|
|
19
|
+
const index = this._buffer.indexOf("\n");
|
|
20
|
+
if (index === -1) return null;
|
|
21
|
+
const line = this._buffer.toString("utf8", 0, index).replace(/\r$/, "");
|
|
22
|
+
this._buffer = this._buffer.subarray(index + 1);
|
|
23
|
+
return deserializeMessage(line);
|
|
24
|
+
}
|
|
25
|
+
clear() {
|
|
26
|
+
this._buffer = void 0;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
function deserializeMessage(line) {
|
|
30
|
+
return JSONRPCMessageSchema.parse(JSON.parse(line));
|
|
31
|
+
}
|
|
32
|
+
function serializeMessage(message) {
|
|
33
|
+
return JSON.stringify(message) + "\n";
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_supports-color@10.2.2_zod@4.6.7/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
|
|
37
|
+
/**
|
|
38
|
+
* Server transport for stdio: this communicates with an MCP client by reading from the current process' stdin and writing to stdout.
|
|
39
|
+
*
|
|
40
|
+
* This transport is only available in Node.js environments.
|
|
41
|
+
*/
|
|
42
|
+
var StdioServerTransport = class {
|
|
43
|
+
constructor(_stdin = process.stdin, _stdout = process.stdout, options) {
|
|
44
|
+
this._stdin = _stdin;
|
|
45
|
+
this._stdout = _stdout;
|
|
46
|
+
this._started = false;
|
|
47
|
+
this._ondata = (chunk) => {
|
|
48
|
+
try {
|
|
49
|
+
this._readBuffer.append(chunk);
|
|
50
|
+
this.processReadBuffer();
|
|
51
|
+
} catch (error) {
|
|
52
|
+
this.onerror?.(error);
|
|
53
|
+
this.close().catch(() => {});
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
this._onerror = (error) => {
|
|
57
|
+
this.onerror?.(error);
|
|
58
|
+
};
|
|
59
|
+
this._readBuffer = new ReadBuffer({ maxBufferSize: options?.maxBufferSize });
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Starts listening for messages on stdin.
|
|
63
|
+
*/
|
|
64
|
+
async start() {
|
|
65
|
+
if (this._started) throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");
|
|
66
|
+
this._started = true;
|
|
67
|
+
this._stdin.on("data", this._ondata);
|
|
68
|
+
this._stdin.on("error", this._onerror);
|
|
69
|
+
}
|
|
70
|
+
processReadBuffer() {
|
|
71
|
+
while (true) try {
|
|
72
|
+
const message = this._readBuffer.readMessage();
|
|
73
|
+
if (message === null) break;
|
|
74
|
+
this.onmessage?.(message);
|
|
75
|
+
} catch (error) {
|
|
76
|
+
this.onerror?.(error);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async close() {
|
|
80
|
+
this._stdin.off("data", this._ondata);
|
|
81
|
+
this._stdin.off("error", this._onerror);
|
|
82
|
+
if (this._stdin.listenerCount("data") === 0) this._stdin.pause();
|
|
83
|
+
this._readBuffer.clear();
|
|
84
|
+
this.onclose?.();
|
|
85
|
+
}
|
|
86
|
+
send(message) {
|
|
87
|
+
return new Promise((resolve) => {
|
|
88
|
+
const json = serializeMessage(message);
|
|
89
|
+
if (this._stdout.write(json)) resolve();
|
|
90
|
+
else this._stdout.once("drain", resolve);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
//#endregion
|
|
95
|
+
export { StdioServerTransport };
|