docs-i18n 0.2.4 → 0.3.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.
- package/dist/{assemble-IOHQYYHI.js → assemble-7H4QCW35.js} +3 -4
- package/dist/{chunk-QSVWLTGQ.js → chunk-A3YQNPKZ.js} +1 -1
- package/dist/chunk-SKKZIV3L.js +54 -0
- package/dist/{chunk-SUIDX6IZ.js → chunk-YN4VJHCQ.js} +1 -1
- package/dist/cli.js +6 -7
- package/dist/{rescan-VB2PILB2.js → rescan-O5D3CYC2.js} +2 -3
- package/dist/{server-HUXOPTUA.js → server-2FW3TPYF.js} +36 -13
- package/dist/{status-EWQEACVF.js → status-F4MYIAAY.js} +1 -2
- package/dist/{translate-F3AQFN6X.js → translate-FI4IXXOP.js} +5 -7
- package/package.json +7 -6
- package/src/admin/server/index.ts +34 -10
- package/dist/build-4EQEL4NI.js +0 -12
- package/dist/build2-3W5WMFHZ.js +0 -4901
- package/dist/chunk-3YNFMSJH.js +0 -30
- package/dist/chunk-55MBYBVK.js +0 -368
- package/dist/chunk-AKLW2MUS.js +0 -54
- package/dist/chunk-FYDB7MZX.js +0 -38944
- package/dist/chunk-O35QHRY6.js +0 -6
- package/dist/chunk-PTIH4GGE.js +0 -44
- package/dist/chunk-VKKNQBDN.js +0 -6487
- package/dist/dist-6C32URTL.js +0 -19
- package/dist/dist-HOWMMQFV.js +0 -6677
- package/dist/false-JGP4AGWN.js +0 -7
- package/dist/main-QVE5TVA3.js +0 -2505
- package/dist/node-4GLCLDJ6.js +0 -875
- package/dist/node-NUDVMOF2.js +0 -129
- package/dist/postcss-3SK7VUC2.js +0 -5886
- package/dist/postcss-import-JD46KA2Z.js +0 -458
- package/dist/prompt-BYQIwEjg-TG7DLENB.js +0 -915
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
assemble
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-A3YQNPKZ.js";
|
|
4
|
+
import "./chunk-YN4VJHCQ.js";
|
|
5
5
|
import {
|
|
6
6
|
TranslationCache
|
|
7
7
|
} from "./chunk-XEOYZUHS.js";
|
|
8
8
|
import {
|
|
9
9
|
flattenSources
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-AKLW2MUS.js";
|
|
10
|
+
} from "./chunk-SKKZIV3L.js";
|
|
12
11
|
|
|
13
12
|
// src/commands/assemble.ts
|
|
14
13
|
import {
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __esm = (fn, res) => function __init() {
|
|
6
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
7
|
+
};
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/config.ts
|
|
23
|
+
async function loadConfig(path) {
|
|
24
|
+
const configPath = path ?? "docs-i18n.config.ts";
|
|
25
|
+
try {
|
|
26
|
+
const mod = await import(
|
|
27
|
+
/* @vite-ignore */
|
|
28
|
+
`${process.cwd()}/${configPath}`
|
|
29
|
+
);
|
|
30
|
+
return mod.default ?? mod;
|
|
31
|
+
} catch {
|
|
32
|
+
throw new Error(`Cannot load config from ${configPath}. Create a docs-i18n.config.ts file.`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function flattenSources(config) {
|
|
36
|
+
const projects = Object.entries(config.projects);
|
|
37
|
+
const singleProject = projects.length === 1;
|
|
38
|
+
return projects.flatMap(
|
|
39
|
+
([projectId, project]) => Object.entries(project.sources).map(([version, sourcePath]) => ({
|
|
40
|
+
project: projectId,
|
|
41
|
+
version,
|
|
42
|
+
sourcePath,
|
|
43
|
+
versionKey: singleProject ? version : `${projectId}/${version}`
|
|
44
|
+
}))
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export {
|
|
49
|
+
__esm,
|
|
50
|
+
__export,
|
|
51
|
+
__toCommonJS,
|
|
52
|
+
loadConfig,
|
|
53
|
+
flattenSources
|
|
54
|
+
};
|
package/dist/cli.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
loadConfig
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-AKLW2MUS.js";
|
|
4
|
+
} from "./chunk-SKKZIV3L.js";
|
|
6
5
|
|
|
7
6
|
// src/cli.ts
|
|
8
7
|
var args = process.argv.slice(2);
|
|
@@ -50,7 +49,7 @@ Options:
|
|
|
50
49
|
console.error("Error: --lang is required");
|
|
51
50
|
process.exit(1);
|
|
52
51
|
}
|
|
53
|
-
const { translate } = await import("./translate-
|
|
52
|
+
const { translate } = await import("./translate-FI4IXXOP.js");
|
|
54
53
|
await translate(config, {
|
|
55
54
|
lang,
|
|
56
55
|
project: getOpt("project") || void 0,
|
|
@@ -66,7 +65,7 @@ Options:
|
|
|
66
65
|
break;
|
|
67
66
|
}
|
|
68
67
|
case "assemble": {
|
|
69
|
-
const { assembleAll } = await import("./assemble-
|
|
68
|
+
const { assembleAll } = await import("./assemble-7H4QCW35.js");
|
|
70
69
|
await assembleAll(config, {
|
|
71
70
|
project: getOpt("project") || void 0,
|
|
72
71
|
version: getOpt("version") || void 0,
|
|
@@ -75,7 +74,7 @@ Options:
|
|
|
75
74
|
break;
|
|
76
75
|
}
|
|
77
76
|
case "rescan": {
|
|
78
|
-
const { rescan } = await import("./rescan-
|
|
77
|
+
const { rescan } = await import("./rescan-O5D3CYC2.js");
|
|
79
78
|
await rescan(config, {
|
|
80
79
|
project: getOpt("project") || void 0,
|
|
81
80
|
version: getOpt("version") || void 0
|
|
@@ -83,13 +82,13 @@ Options:
|
|
|
83
82
|
break;
|
|
84
83
|
}
|
|
85
84
|
case "status": {
|
|
86
|
-
const { status } = await import("./status-
|
|
85
|
+
const { status } = await import("./status-F4MYIAAY.js");
|
|
87
86
|
await status(config, { lang: getOpt("lang") || void 0 });
|
|
88
87
|
break;
|
|
89
88
|
}
|
|
90
89
|
case "admin": {
|
|
91
90
|
const port = Number(getOpt("port", "3456"));
|
|
92
|
-
const { startAdmin } = await import("./server-
|
|
91
|
+
const { startAdmin } = await import("./server-2FW3TPYF.js");
|
|
93
92
|
await startAdmin(config, port);
|
|
94
93
|
break;
|
|
95
94
|
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
init_parser,
|
|
3
3
|
parseMdx
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-YN4VJHCQ.js";
|
|
5
5
|
import {
|
|
6
6
|
TranslationCache
|
|
7
7
|
} from "./chunk-XEOYZUHS.js";
|
|
8
8
|
import {
|
|
9
9
|
flattenSources
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-AKLW2MUS.js";
|
|
10
|
+
} from "./chunk-SKKZIV3L.js";
|
|
12
11
|
|
|
13
12
|
// src/commands/rescan.ts
|
|
14
13
|
import { existsSync, readdirSync, readFileSync } from "fs";
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
init_parser,
|
|
3
3
|
parseMdx
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-YN4VJHCQ.js";
|
|
5
5
|
import {
|
|
6
6
|
TranslationCache
|
|
7
7
|
} from "./chunk-XEOYZUHS.js";
|
|
8
8
|
import {
|
|
9
9
|
flattenSources
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-AKLW2MUS.js";
|
|
10
|
+
} from "./chunk-SKKZIV3L.js";
|
|
12
11
|
|
|
13
12
|
// src/admin/server/index.ts
|
|
13
|
+
import { spawn as nodeSpawn } from "child_process";
|
|
14
14
|
import { createServer } from "http";
|
|
15
15
|
import { resolve as resolve2 } from "path";
|
|
16
16
|
import { Hono as Hono4 } from "hono";
|
|
@@ -489,22 +489,25 @@ async function startAdmin(config, port = 3456) {
|
|
|
489
489
|
if (!fullPath.startsWith(process.cwd())) return c.json({ error: "Invalid path" }, 400);
|
|
490
490
|
const candidates = process.env.EDITOR_CMD ? [process.env.EDITOR_CMD] : ["code", "cursor", "zed"];
|
|
491
491
|
for (const cmd of candidates) {
|
|
492
|
-
const
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
492
|
+
const found = await new Promise((r) => {
|
|
493
|
+
const p = nodeSpawn("which", [cmd], { stdio: "ignore" });
|
|
494
|
+
p.on("exit", (code) => r(code === 0));
|
|
495
|
+
p.on("error", () => r(false));
|
|
496
|
+
});
|
|
497
|
+
if (found) {
|
|
498
|
+
nodeSpawn(cmd, [fullPath], { stdio: "ignore", detached: true }).unref();
|
|
496
499
|
return c.json({ opened: fullPath, editor: cmd });
|
|
497
500
|
}
|
|
498
501
|
}
|
|
499
502
|
const fallback = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
|
|
500
|
-
|
|
503
|
+
nodeSpawn(fallback, [fullPath], { stdio: "ignore", detached: true }).unref();
|
|
501
504
|
return c.json({ opened: fullPath, editor: fallback });
|
|
502
505
|
});
|
|
503
506
|
const thisFile = new URL(import.meta.url).pathname;
|
|
504
507
|
const pkgRoot = resolve2(thisFile, "..", "..");
|
|
505
508
|
const adminRoot = resolve2(pkgRoot, "src", "admin");
|
|
506
509
|
try {
|
|
507
|
-
const { createServer: createViteServer } = await import("
|
|
510
|
+
const { createServer: createViteServer } = await import("vite");
|
|
508
511
|
const vite = await createViteServer({
|
|
509
512
|
root: adminRoot,
|
|
510
513
|
server: { middlewareMode: true },
|
|
@@ -539,10 +542,30 @@ async function startAdmin(config, port = 3456) {
|
|
|
539
542
|
server.listen(port, () => {
|
|
540
543
|
console.log(`\u{1F310} docs-i18n admin \u2192 http://localhost:${port}`);
|
|
541
544
|
});
|
|
542
|
-
} catch {
|
|
543
|
-
console.error("Failed to start admin UI
|
|
544
|
-
|
|
545
|
-
|
|
545
|
+
} catch (err) {
|
|
546
|
+
console.error("Failed to start admin UI with Vite:", err.message);
|
|
547
|
+
console.log("Starting API-only mode...");
|
|
548
|
+
const server = createServer(async (req, res) => {
|
|
549
|
+
const url = req.url ?? "/";
|
|
550
|
+
const headers = new Headers();
|
|
551
|
+
for (const [k, v] of Object.entries(req.headers)) {
|
|
552
|
+
if (v) headers.set(k, Array.isArray(v) ? v.join(", ") : v);
|
|
553
|
+
}
|
|
554
|
+
const body = req.method !== "GET" && req.method !== "HEAD" ? await new Promise((r) => {
|
|
555
|
+
let data = "";
|
|
556
|
+
req.on("data", (c) => {
|
|
557
|
+
data += c.toString();
|
|
558
|
+
});
|
|
559
|
+
req.on("end", () => r(data));
|
|
560
|
+
}) : void 0;
|
|
561
|
+
const webReq = new Request(`http://localhost:${port}${url}`, { method: req.method, headers, body });
|
|
562
|
+
const webRes = await app4.fetch(webReq);
|
|
563
|
+
res.writeHead(webRes.status, Object.fromEntries(webRes.headers.entries()));
|
|
564
|
+
res.end(Buffer.from(await webRes.arrayBuffer()));
|
|
565
|
+
});
|
|
566
|
+
server.listen(port, () => {
|
|
567
|
+
console.log(`\u{1F310} docs-i18n admin (API only) \u2192 http://localhost:${port}`);
|
|
568
|
+
});
|
|
546
569
|
}
|
|
547
570
|
}
|
|
548
571
|
export {
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import "./chunk-
|
|
1
|
+
import "./chunk-A3YQNPKZ.js";
|
|
2
2
|
import {
|
|
3
3
|
FRONTMATTER_TRANSLATABLE_FIELDS,
|
|
4
4
|
init_parser
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-YN4VJHCQ.js";
|
|
6
6
|
import {
|
|
7
7
|
TranslationCache
|
|
8
8
|
} from "./chunk-XEOYZUHS.js";
|
|
9
|
-
import {
|
|
10
|
-
flattenSources
|
|
11
|
-
} from "./chunk-3YNFMSJH.js";
|
|
12
9
|
import {
|
|
13
10
|
__esm,
|
|
14
11
|
__export,
|
|
15
|
-
__toCommonJS
|
|
16
|
-
|
|
12
|
+
__toCommonJS,
|
|
13
|
+
flattenSources
|
|
14
|
+
} from "./chunk-SKKZIV3L.js";
|
|
17
15
|
|
|
18
16
|
// src/core/frontmatter.ts
|
|
19
17
|
var frontmatter_exports = {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docs-i18n",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Universal documentation translation engine — parse, translate, cache, assemble, manage.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -27,16 +27,17 @@
|
|
|
27
27
|
"prepublishOnly": "tsup && chmod +x dist/cli.js"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@mdx-js/mdx": "^3.1.1",
|
|
31
|
-
"@tanstack/react-query": "^5.94.5",
|
|
32
30
|
"better-sqlite3": "^12.8.0",
|
|
33
31
|
"glob": "^11.0.2",
|
|
34
32
|
"hono": "^4.12.0",
|
|
35
33
|
"openai": "^5.1.1",
|
|
36
|
-
"react": "^19.2.4",
|
|
37
|
-
"react-dom": "^19.2.4",
|
|
38
34
|
"remark": "^15.0.1",
|
|
39
|
-
"yaml": "^2.8.2"
|
|
35
|
+
"yaml": "^2.8.2",
|
|
36
|
+
"vite": "^6.0.0 || ^7.0.0 || ^8.0.0",
|
|
37
|
+
"@vitejs/plugin-react": "^4.0.0 || ^5.0.0 || ^6.0.0",
|
|
38
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
39
|
+
"react-dom": "^18.0.0 || ^19.0.0",
|
|
40
|
+
"@tanstack/react-query": "^5.0.0"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
42
43
|
"@biomejs/biome": "^2.0.0",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { spawn as nodeSpawn } from 'node:child_process';
|
|
1
2
|
import { createServer } from 'node:http';
|
|
2
3
|
import { resolve } from 'node:path';
|
|
3
4
|
import { Hono } from 'hono';
|
|
@@ -26,15 +27,18 @@ export async function startAdmin(config: DocsI18nConfig, port = 3456) {
|
|
|
26
27
|
|
|
27
28
|
const candidates = process.env.EDITOR_CMD ? [process.env.EDITOR_CMD] : ['code', 'cursor', 'zed'];
|
|
28
29
|
for (const cmd of candidates) {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
const found = await new Promise<boolean>((r) => {
|
|
31
|
+
const p = nodeSpawn('which', [cmd], { stdio: 'ignore' });
|
|
32
|
+
p.on('exit', (code) => r(code === 0));
|
|
33
|
+
p.on('error', () => r(false));
|
|
34
|
+
});
|
|
35
|
+
if (found) {
|
|
36
|
+
nodeSpawn(cmd, [fullPath], { stdio: 'ignore', detached: true }).unref();
|
|
33
37
|
return c.json({ opened: fullPath, editor: cmd });
|
|
34
38
|
}
|
|
35
39
|
}
|
|
36
40
|
const fallback = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'start' : 'xdg-open';
|
|
37
|
-
|
|
41
|
+
nodeSpawn(fallback, [fullPath], { stdio: 'ignore', detached: true }).unref();
|
|
38
42
|
return c.json({ opened: fullPath, editor: fallback });
|
|
39
43
|
});
|
|
40
44
|
|
|
@@ -84,10 +88,30 @@ export async function startAdmin(config: DocsI18nConfig, port = 3456) {
|
|
|
84
88
|
server.listen(port, () => {
|
|
85
89
|
console.log(`🌐 docs-i18n admin → http://localhost:${port}`);
|
|
86
90
|
});
|
|
87
|
-
} catch {
|
|
88
|
-
console.error('Failed to start admin UI (
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
91
|
+
} catch (err) {
|
|
92
|
+
console.error('Failed to start admin UI with Vite:', (err as Error).message);
|
|
93
|
+
console.log('Starting API-only mode...');
|
|
94
|
+
// Fallback: Hono on Node http server without Vite
|
|
95
|
+
const server = createServer(async (req, res) => {
|
|
96
|
+
const url = req.url ?? '/';
|
|
97
|
+
const headers = new Headers();
|
|
98
|
+
for (const [k, v] of Object.entries(req.headers)) {
|
|
99
|
+
if (v) headers.set(k, Array.isArray(v) ? v.join(', ') : v);
|
|
100
|
+
}
|
|
101
|
+
const body = req.method !== 'GET' && req.method !== 'HEAD'
|
|
102
|
+
? await new Promise<string>((r) => {
|
|
103
|
+
let data = '';
|
|
104
|
+
req.on('data', (c: Buffer) => { data += c.toString(); });
|
|
105
|
+
req.on('end', () => r(data));
|
|
106
|
+
})
|
|
107
|
+
: undefined;
|
|
108
|
+
const webReq = new Request(`http://localhost:${port}${url}`, { method: req.method, headers, body });
|
|
109
|
+
const webRes = await app.fetch(webReq);
|
|
110
|
+
res.writeHead(webRes.status, Object.fromEntries(webRes.headers.entries()));
|
|
111
|
+
res.end(Buffer.from(await webRes.arrayBuffer()));
|
|
112
|
+
});
|
|
113
|
+
server.listen(port, () => {
|
|
114
|
+
console.log(`🌐 docs-i18n admin (API only) → http://localhost:${port}`);
|
|
115
|
+
});
|
|
92
116
|
}
|
|
93
117
|
}
|
package/dist/build-4EQEL4NI.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createBuilder,
|
|
3
|
-
resolveBuildPlugins
|
|
4
|
-
} from "./chunk-FYDB7MZX.js";
|
|
5
|
-
import "./chunk-PTIH4GGE.js";
|
|
6
|
-
import "./chunk-VKKNQBDN.js";
|
|
7
|
-
import "./chunk-O35QHRY6.js";
|
|
8
|
-
import "./chunk-AKLW2MUS.js";
|
|
9
|
-
export {
|
|
10
|
-
createBuilder,
|
|
11
|
-
resolveBuildPlugins
|
|
12
|
-
};
|