docs-i18n 0.7.2 → 0.7.4
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/admin/dist/client/assets/main-Ds-UH1id.js +17 -0
- package/admin/dist/client/assets/routes-C369Oboq.js +3 -0
- package/admin/dist/client/assets/styles-DJ6QEJmN.css +1 -0
- package/admin/dist/server/assets/_tanstack-start-manifest_v-sC90W3ET.js +17 -0
- package/admin/dist/server/assets/createServerRpc-CMjjCE8A.js +12 -0
- package/admin/dist/server/assets/init-AJSQ7K_l.js +41740 -0
- package/admin/dist/server/assets/jobs-CwDb0Zyp.js +50 -0
- package/admin/dist/server/assets/misc-CqYhnW23.js +94 -0
- package/admin/dist/server/assets/models-D9Sd95EX.js +49 -0
- package/admin/dist/server/assets/router-D00bP5CU.js +67 -0
- package/admin/dist/server/assets/routes-C2UFxDWZ.js +24 -0
- package/admin/dist/server/assets/routes-vEKXnl0r.js +1574 -0
- package/admin/dist/server/assets/start-BrsoKfWS.js +4 -0
- package/admin/dist/server/assets/status-D48jcwYI.js +81 -0
- package/admin/dist/server/server.js +5374 -0
- package/admin/package.json +7 -3
- package/admin/serve.mjs +87 -0
- package/dist/cli.js +36 -10
- package/package.json +2 -2
- package/template/package.json +1 -1
package/admin/package.json
CHANGED
|
@@ -8,14 +8,18 @@
|
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"dev": "vite dev",
|
|
11
|
-
"build": "vite build"
|
|
11
|
+
"build": "vite build",
|
|
12
|
+
"start": "node dist/server/server.js"
|
|
12
13
|
},
|
|
13
14
|
"dependencies": {
|
|
15
|
+
"@tanstack/react-query": "^5.0.0",
|
|
16
|
+
"@tanstack/react-router": "^1.120.3",
|
|
17
|
+
"@tanstack/react-start": "^1.120.3",
|
|
18
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
14
19
|
"hono": "^4.12.0",
|
|
15
20
|
"react": "^19.1.0",
|
|
16
21
|
"react-dom": "^19.1.0",
|
|
17
|
-
"vite": "^8.0.1"
|
|
18
|
-
"@vitejs/plugin-react": "^6.0.1"
|
|
22
|
+
"vite": "^8.0.1"
|
|
19
23
|
},
|
|
20
24
|
"devDependencies": {
|
|
21
25
|
"@types/node": "^22.0.0",
|
package/admin/serve.mjs
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal Node.js HTTP adapter for TanStack Start's fetch-based server.
|
|
3
|
+
* Usage: node serve.mjs
|
|
4
|
+
*/
|
|
5
|
+
import { createServer } from 'node:http';
|
|
6
|
+
import { resolve, dirname } from 'node:path';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
8
|
+
import { readFileSync, existsSync } from 'node:fs';
|
|
9
|
+
|
|
10
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
|
|
12
|
+
// Import the built server entry
|
|
13
|
+
const { default: app } = await import('./dist/server/server.js');
|
|
14
|
+
|
|
15
|
+
// Static asset serving from dist/client/
|
|
16
|
+
const clientDir = resolve(__dirname, 'dist', 'client');
|
|
17
|
+
|
|
18
|
+
const mimeTypes = {
|
|
19
|
+
'.html': 'text/html',
|
|
20
|
+
'.js': 'application/javascript',
|
|
21
|
+
'.css': 'text/css',
|
|
22
|
+
'.json': 'application/json',
|
|
23
|
+
'.png': 'image/png',
|
|
24
|
+
'.svg': 'image/svg+xml',
|
|
25
|
+
'.ico': 'image/x-icon',
|
|
26
|
+
'.woff2': 'font/woff2',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
function getMime(path) {
|
|
30
|
+
const ext = path.match(/\.[^.]+$/)?.[0] || '';
|
|
31
|
+
return mimeTypes[ext] || 'application/octet-stream';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const port = Number(process.env.PORT || 3456);
|
|
35
|
+
|
|
36
|
+
const server = createServer(async (req, res) => {
|
|
37
|
+
const url = new URL(req.url, `http://localhost:${port}`);
|
|
38
|
+
|
|
39
|
+
// Try static files first
|
|
40
|
+
const staticPath = resolve(clientDir, url.pathname.slice(1));
|
|
41
|
+
if (staticPath.startsWith(clientDir) && existsSync(staticPath) && !url.pathname.endsWith('/')) {
|
|
42
|
+
try {
|
|
43
|
+
const data = readFileSync(staticPath);
|
|
44
|
+
res.writeHead(200, {
|
|
45
|
+
'Content-Type': getMime(staticPath),
|
|
46
|
+
'Cache-Control': url.pathname.includes('/assets/') ? 'public, max-age=31536000, immutable' : 'no-cache',
|
|
47
|
+
});
|
|
48
|
+
res.end(data);
|
|
49
|
+
return;
|
|
50
|
+
} catch {}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Proxy to TanStack Start fetch handler
|
|
54
|
+
const headers = new Headers();
|
|
55
|
+
for (const [key, value] of Object.entries(req.headers)) {
|
|
56
|
+
if (value) headers.set(key, Array.isArray(value) ? value.join(', ') : value);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const body = ['GET', 'HEAD'].includes(req.method)
|
|
60
|
+
? undefined
|
|
61
|
+
: await new Promise((resolve) => {
|
|
62
|
+
const chunks = [];
|
|
63
|
+
req.on('data', (c) => chunks.push(c));
|
|
64
|
+
req.on('end', () => resolve(Buffer.concat(chunks)));
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const request = new Request(url.href, {
|
|
68
|
+
method: req.method,
|
|
69
|
+
headers,
|
|
70
|
+
body,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
const response = await app.fetch(request);
|
|
75
|
+
res.writeHead(response.status, Object.fromEntries(response.headers.entries()));
|
|
76
|
+
const buffer = await response.arrayBuffer();
|
|
77
|
+
res.end(Buffer.from(buffer));
|
|
78
|
+
} catch (err) {
|
|
79
|
+
console.error('Server error:', err);
|
|
80
|
+
res.writeHead(500);
|
|
81
|
+
res.end('Internal Server Error');
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
server.listen(port, () => {
|
|
86
|
+
console.log(`Admin dashboard: http://localhost:${port}/`);
|
|
87
|
+
});
|
package/dist/cli.js
CHANGED
|
@@ -6,11 +6,12 @@ import "./chunk-PNKVD2UK.js";
|
|
|
6
6
|
|
|
7
7
|
// src/cli.ts
|
|
8
8
|
import { createRequire } from "module";
|
|
9
|
+
var require2 = createRequire(import.meta.url);
|
|
10
|
+
var pkg = require2("../package.json");
|
|
11
|
+
var version = pkg.version;
|
|
9
12
|
var args = process.argv.slice(2);
|
|
10
13
|
if (args[0] === "--version" || args[0] === "-v") {
|
|
11
|
-
|
|
12
|
-
const pkg = require2("../package.json");
|
|
13
|
-
console.log(pkg.version);
|
|
14
|
+
console.log(version);
|
|
14
15
|
process.exit(0);
|
|
15
16
|
}
|
|
16
17
|
var command = args[0];
|
|
@@ -22,6 +23,7 @@ function hasFlag(name) {
|
|
|
22
23
|
return args.includes(`--${name}`);
|
|
23
24
|
}
|
|
24
25
|
async function handleSiteCommand() {
|
|
26
|
+
console.log(`docs-i18n v${version}`);
|
|
25
27
|
const validSub = /* @__PURE__ */ new Set(["dev", "build", "upload", "deploy"]);
|
|
26
28
|
const subCommand = args.slice(1).find((a) => validSub.has(a));
|
|
27
29
|
const port = Number(getOpt("port", "3000"));
|
|
@@ -187,19 +189,43 @@ Options:
|
|
|
187
189
|
break;
|
|
188
190
|
}
|
|
189
191
|
case "admin": {
|
|
192
|
+
console.log(`docs-i18n v${version}`);
|
|
190
193
|
const port = Number(getOpt("port", "3456"));
|
|
191
194
|
const { resolve: res, dirname: dn } = await import("path");
|
|
192
195
|
const { fileURLToPath: toPath } = await import("url");
|
|
193
|
-
const { existsSync: ex, realpathSync: rp } = await import("fs");
|
|
196
|
+
const { existsSync: ex, realpathSync: rp, writeFileSync: wf } = await import("fs");
|
|
197
|
+
const { spawn: sp } = await import("child_process");
|
|
198
|
+
const { tmpdir: tmp } = await import("os");
|
|
194
199
|
const coreRoot = res(dn(toPath(import.meta.url)), "..");
|
|
195
200
|
const adminNm = res(coreRoot, "node_modules", "@docs-i18n", "admin");
|
|
196
201
|
const adminRoot = ex(adminNm) ? rp(adminNm) : res(coreRoot, "admin");
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
);
|
|
201
|
-
|
|
202
|
-
|
|
202
|
+
wf(res(tmp(), "docs-i18n-project-root"), process.cwd());
|
|
203
|
+
const adminEnv = { ...process.env, DOCS_I18N_PROJECT_ROOT: process.cwd(), PORT: String(port) };
|
|
204
|
+
const serveEntry = res(adminRoot, "serve.mjs");
|
|
205
|
+
const builtServer = res(adminRoot, "dist", "server", "server.js");
|
|
206
|
+
if (ex(builtServer) && ex(serveEntry)) {
|
|
207
|
+
const child = sp("node", [serveEntry], {
|
|
208
|
+
cwd: adminRoot,
|
|
209
|
+
stdio: "inherit",
|
|
210
|
+
env: adminEnv
|
|
211
|
+
});
|
|
212
|
+
child.on("exit", (code) => process.exit(code ?? 0));
|
|
213
|
+
} else {
|
|
214
|
+
const { execSync: execS } = await import("child_process");
|
|
215
|
+
if (!ex(res(adminRoot, "node_modules"))) {
|
|
216
|
+
console.log("Installing admin dependencies...");
|
|
217
|
+
execS("npm install --no-audit --no-fund", { cwd: adminRoot, stdio: "inherit" });
|
|
218
|
+
}
|
|
219
|
+
const adminVite = res(adminRoot, "node_modules", ".bin", "vite");
|
|
220
|
+
const child = sp(adminVite, ["--port", String(port)], {
|
|
221
|
+
cwd: adminRoot,
|
|
222
|
+
stdio: "inherit",
|
|
223
|
+
env: adminEnv
|
|
224
|
+
});
|
|
225
|
+
child.on("exit", (code) => process.exit(code ?? 0));
|
|
226
|
+
}
|
|
227
|
+
await new Promise(() => {
|
|
228
|
+
});
|
|
203
229
|
}
|
|
204
230
|
default:
|
|
205
231
|
console.error(`Unknown command: ${command}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docs-i18n",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4",
|
|
4
4
|
"description": "Universal documentation translation engine — parse, translate, cache, assemble, manage.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"typecheck": "tsc --noEmit",
|
|
26
26
|
"prepack": "rm -rf admin template && cp -r ../admin admin && cp -r ../template template && rm -rf admin/node_modules template/node_modules && node -e \"const fs=require('fs');const p=JSON.parse(fs.readFileSync('template/package.json','utf8'));delete p.dependencies['docs-i18n'];fs.writeFileSync('template/package.json',JSON.stringify(p,null,2)+'\\n');const a=JSON.parse(fs.readFileSync('admin/package.json','utf8'));delete a.dependencies['docs-i18n'];fs.writeFileSync('admin/package.json',JSON.stringify(a,null,2)+'\\n')\"",
|
|
27
27
|
"postpack": "rm -rf admin template",
|
|
28
|
-
"prepublishOnly": "rm -rf dist && tsup && chmod +x dist/cli.js"
|
|
28
|
+
"prepublishOnly": "rm -rf dist && tsup && chmod +x dist/cli.js && cd ../admin && npx vite build"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"better-sqlite3": "^12.8.0",
|