@tunnelbox/core 0.1.18 → 0.1.21
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/index.js +1191 -22
- package/locales/de-DE.json +307 -166
- package/locales/en-US.json +307 -166
- package/locales/es-ES.json +307 -166
- package/locales/fr-FR.json +307 -166
- package/locales/ja-JP.json +307 -166
- package/locales/ko-KR.json +307 -166
- package/locales/zh-CN.json +307 -166
- package/locales/zh-TW.json +307 -166
- package/package.json +2 -1
- package/src/cli.ts +58 -2
- package/src/qr.ts +2 -1
- package/src/state.ts +6 -5
- package/src/types.ts +2 -0
package/src/state.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { randomBytes } from "node:crypto";
|
|
|
9
9
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
10
10
|
import { homedir } from "node:os";
|
|
11
11
|
import { dirname, join } from "node:path";
|
|
12
|
-
import { normalizeLang, type Lang } from "./i18n";
|
|
12
|
+
import { normalizeLang, resolveLang, t, type Lang } from "./i18n";
|
|
13
13
|
|
|
14
14
|
export interface State {
|
|
15
15
|
agentId: string;
|
|
@@ -39,7 +39,7 @@ export function saveState(st: State, type?: string): void {
|
|
|
39
39
|
mkdirSync(dirname(p), { recursive: true });
|
|
40
40
|
writeFileSync(p, JSON.stringify(st, null, 2), "utf8");
|
|
41
41
|
} catch (e) {
|
|
42
|
-
console.error(
|
|
42
|
+
console.error(`[tunnelbox] ${t(st.lang ?? resolveLang(), "state.errSaveState")}`, e);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -70,12 +70,13 @@ export function loadState(type?: string): State {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
/**
|
|
74
|
-
export function writePairingFile(code: string, type?: string): string {
|
|
73
|
+
/** 把配对码写入本地文件,作为终端日志被吞时的兜底。文案走 i18n(lang 缺省按系统解析)。 */
|
|
74
|
+
export function writePairingFile(code: string, type?: string, lang?: Lang): string {
|
|
75
75
|
const p = join(baseName(), `remote-pairing${suffix(type)}.txt`);
|
|
76
76
|
try {
|
|
77
77
|
mkdirSync(dirname(p), { recursive: true });
|
|
78
|
-
|
|
78
|
+
const label = t(lang ?? resolveLang(), "qr.codeLabel");
|
|
79
|
+
writeFileSync(p, `${label}: ${code}\n`, "utf8");
|
|
79
80
|
} catch {
|
|
80
81
|
/* ignore */
|
|
81
82
|
}
|