@verbaly/compiler 0.31.0 → 0.33.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/README.md +56 -5
- package/dist/claude-CrAkiSVP.js +53 -0
- package/dist/claude-CrAkiSVP.js.map +1 -0
- package/dist/cli.js +60 -7
- package/dist/cli.js.map +1 -1
- package/dist/config-D8gkaunO.js +68 -0
- package/dist/config-D8gkaunO.js.map +1 -0
- package/dist/index.d.ts +93 -269
- package/dist/index.js +329 -1678
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
2
|
+
import { join, resolve } from "node:path";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
//#endregion
|
|
5
|
+
//#region src/config.ts
|
|
6
|
+
function resolveConfig(config = {}) {
|
|
7
|
+
const root = resolve(config.root ?? process.cwd());
|
|
8
|
+
const dir = resolve(root, config.dir ?? "locales");
|
|
9
|
+
const sourceLocale = config.sourceLocale ?? "en";
|
|
10
|
+
const locales = /* @__PURE__ */ new Set([sourceLocale, ...config.locales ?? []]);
|
|
11
|
+
if (existsSync(dir)) {
|
|
12
|
+
for (const file of readdirSync(dir)) if (file.endsWith(".json") && !file.startsWith(".") && file !== `en-XA.json`) locales.add(file.slice(0, -5));
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
root,
|
|
16
|
+
dir,
|
|
17
|
+
sourceLocale,
|
|
18
|
+
locales: [...locales],
|
|
19
|
+
include: config.include ?? ["{src,app}/**/*.{js,jsx,ts,tsx,mjs,mts,svelte,vue,astro}"],
|
|
20
|
+
exclude: config.exclude ?? ["**/node_modules/**", "**/dist/**"],
|
|
21
|
+
dts: typeof config.dts === "string" ? resolve(root, config.dts) : config.dts,
|
|
22
|
+
translate: config.translate ?? {},
|
|
23
|
+
render: config.render ?? {}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
async function loadConfigFile(root) {
|
|
27
|
+
for (const name of ["verbaly.config.js", "verbaly.config.mjs"]) {
|
|
28
|
+
const path = join(root, name);
|
|
29
|
+
if (existsSync(path)) return (await import(pathToFileURL(path).href)).default ?? {};
|
|
30
|
+
}
|
|
31
|
+
for (const name of ["verbaly.config.ts", "verbaly.config.mts"]) {
|
|
32
|
+
const path = join(root, name);
|
|
33
|
+
if (existsSync(path)) return loadTsConfig(path);
|
|
34
|
+
}
|
|
35
|
+
const jsonPath = join(root, "verbaly.config.json");
|
|
36
|
+
if (existsSync(jsonPath)) return JSON.parse(readFileSync(jsonPath, "utf8"));
|
|
37
|
+
return {};
|
|
38
|
+
}
|
|
39
|
+
async function loadTsConfig(path) {
|
|
40
|
+
try {
|
|
41
|
+
const { bundleRequire } = await import("bundle-require");
|
|
42
|
+
const { mod } = await bundleRequire({ filepath: path });
|
|
43
|
+
return mod.default ?? {};
|
|
44
|
+
} catch (error) {
|
|
45
|
+
if (isModuleNotFound(error, "esbuild")) throw new Error(`[verbaly] ${path} needs esbuild: install it with pnpm add -D esbuild`, { cause: error });
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function isModuleNotFound(error, name) {
|
|
50
|
+
return error instanceof Error && error.code === "ERR_MODULE_NOT_FOUND" && error.message.includes(name);
|
|
51
|
+
}
|
|
52
|
+
function targetLocales(cfg, override) {
|
|
53
|
+
return (override ?? cfg.locales).filter((locale) => locale !== cfg.sourceLocale && cfg.locales.includes(locale));
|
|
54
|
+
}
|
|
55
|
+
async function loadConfig(root, overrides = {}) {
|
|
56
|
+
return resolveConfig({
|
|
57
|
+
...await loadConfigFile(root),
|
|
58
|
+
...definedOnly(overrides),
|
|
59
|
+
root
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function definedOnly(config) {
|
|
63
|
+
return Object.fromEntries(Object.entries(config).filter(([, value]) => value !== void 0));
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
export { targetLocales as i, loadConfig as n, resolveConfig as r, isModuleNotFound as t };
|
|
67
|
+
|
|
68
|
+
//# sourceMappingURL=config-D8gkaunO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-D8gkaunO.js","names":[],"sources":["../src/pseudo.ts","../src/config.ts"],"sourcesContent":["import type { Catalog, Catalogs } from './catalog';\nimport type { ResolvedConfig } from './config';\n\nexport const PSEUDO_LOCALE = 'en-XA';\n\nconst ACCENTS: Record<string, string> = {\n a: 'á',\n b: 'ƀ',\n c: 'ç',\n d: 'đ',\n e: 'é',\n f: 'ƒ',\n g: 'ğ',\n h: 'ĥ',\n i: 'í',\n j: 'ĵ',\n k: 'ķ',\n l: 'ĺ',\n m: 'ɱ',\n n: 'ñ',\n o: 'ó',\n p: 'þ',\n q: 'ǫ',\n r: 'ŕ',\n s: 'š',\n t: 'ţ',\n u: 'ú',\n v: 'ṽ',\n w: 'ŵ',\n x: 'ẋ',\n y: 'ý',\n z: 'ž',\n A: 'Á',\n B: 'Ɓ',\n C: 'Ç',\n D: 'Đ',\n E: 'É',\n F: 'Ƒ',\n G: 'Ğ',\n H: 'Ĥ',\n I: 'Í',\n J: 'Ĵ',\n K: 'Ķ',\n L: 'Ĺ',\n M: 'Ḿ',\n N: 'Ñ',\n O: 'Ó',\n P: 'Þ',\n Q: 'Ǫ',\n R: 'Ŕ',\n S: 'Š',\n T: 'Ţ',\n U: 'Ú',\n V: 'Ṽ',\n W: 'Ŵ',\n X: 'Ẍ',\n Y: 'Ý',\n Z: 'Ž',\n};\n\nconst TAG_AT = /<\\/?[a-zA-Z][\\w-]*\\/?>/y;\n\n// params, variant blocks, tags and escapes survive verbatim\nexport function pseudoLocalize(message: string): string {\n let out = '';\n let letters = 0;\n let i = 0;\n while (i < message.length) {\n const two = message.slice(i, i + 2);\n if (two === '{{' || two === '}}' || two === '||' || two === '##') {\n out += two;\n i += 2;\n continue;\n }\n const ch = message[i]!;\n if (ch === '{') {\n const end = matchBrace(message, i);\n out += message.slice(i, end);\n i = end;\n continue;\n }\n if (ch === '<') {\n TAG_AT.lastIndex = i;\n const m = TAG_AT.exec(message);\n if (m) {\n out += m[0];\n i += m[0].length;\n continue;\n }\n }\n const mapped = ACCENTS[ch];\n if (mapped) {\n out += mapped;\n letters += 1;\n } else {\n out += ch;\n }\n i += 1;\n }\n const pad = '~'.repeat(Math.ceil(letters / 3));\n return `⟦${out}${pad ? ' ' + pad : ''}⟧`;\n}\n\nfunction matchBrace(message: string, start: number): number {\n let depth = 0;\n for (let i = start; i < message.length; i++) {\n const two = message.slice(i, i + 2);\n if (two === '{{' || two === '}}') {\n i += 1;\n continue;\n }\n const ch = message[i];\n if (ch === '{') depth += 1;\n else if (ch === '}') {\n depth -= 1;\n if (depth === 0) return i + 1;\n }\n }\n return message.length; // unbalanced → verbatim\n}\n\n// regenerates the whole pseudo catalog from the source catalog\nexport function pseudoCatalogs(\n cfg: ResolvedConfig,\n catalogs: Catalogs,\n locale: string = PSEUDO_LOCALE,\n): string[] {\n const source = catalogs[cfg.sourceLocale] ?? {};\n const target: Catalog = {};\n for (const [key, msg] of Object.entries(source)) {\n target[key] = msg ? pseudoLocalize(msg) : '';\n }\n catalogs[locale] = target;\n return Object.keys(target).filter((key) => target[key]);\n}\n","import { existsSync, readFileSync, readdirSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport type { RichLink } from 'verbaly';\nimport { PSEUDO_LOCALE } from './pseudo';\nimport type { TranslateProvider } from './translate';\n\nexport interface TranslateConfig {\n provider?: 'claude' | TranslateProvider;\n model?: string;\n batchSize?: number;\n}\n\nexport interface RenderConfig {\n links?: Record<string, RichLink>;\n site?: string;\n attribute?: string;\n baseUrl?: string;\n hreflang?: boolean;\n sitemap?: boolean | string;\n clean?: boolean;\n}\n\nexport interface VerbalyConfig {\n root?: string;\n dir?: string;\n sourceLocale?: string;\n locales?: string[];\n include?: string[];\n exclude?: string[];\n dts?: string | false;\n translate?: TranslateConfig;\n render?: RenderConfig;\n}\n\nexport interface ResolvedConfig {\n root: string;\n dir: string;\n sourceLocale: string;\n locales: string[];\n include: string[];\n exclude: string[];\n dts: string | false | undefined;\n translate: TranslateConfig;\n render: RenderConfig;\n}\n\nexport function resolveConfig(config: VerbalyConfig = {}): ResolvedConfig {\n const root = resolve(config.root ?? process.cwd());\n const dir = resolve(root, config.dir ?? 'locales');\n const sourceLocale = config.sourceLocale ?? 'en';\n\n const locales = new Set<string>([sourceLocale, ...(config.locales ?? [])]);\n if (existsSync(dir)) {\n for (const file of readdirSync(dir)) {\n if (file.endsWith('.json') && !file.startsWith('.') && file !== `${PSEUDO_LOCALE}.json`) {\n locales.add(file.slice(0, -5));\n }\n }\n }\n\n return {\n root,\n dir,\n sourceLocale,\n locales: [...locales],\n include: config.include ?? ['{src,app}/**/*.{js,jsx,ts,tsx,mjs,mts,svelte,vue,astro}'],\n exclude: config.exclude ?? ['**/node_modules/**', '**/dist/**'],\n dts: typeof config.dts === 'string' ? resolve(root, config.dts) : config.dts,\n translate: config.translate ?? {},\n render: config.render ?? {},\n };\n}\n\nconst CONFIG_FILES = [\n 'verbaly.config.js',\n 'verbaly.config.mjs',\n 'verbaly.config.ts',\n 'verbaly.config.mts',\n 'verbaly.config.json',\n];\n\nexport function findConfigFile(root: string): string | undefined {\n return CONFIG_FILES.find((name) => existsSync(join(root, name)));\n}\n\nexport async function loadConfigFile(root: string): Promise<VerbalyConfig> {\n for (const name of ['verbaly.config.js', 'verbaly.config.mjs']) {\n const path = join(root, name);\n if (existsSync(path)) {\n const mod = (await import(pathToFileURL(path).href)) as { default?: VerbalyConfig };\n return mod.default ?? {};\n }\n }\n for (const name of ['verbaly.config.ts', 'verbaly.config.mts']) {\n const path = join(root, name);\n if (existsSync(path)) return loadTsConfig(path);\n }\n const jsonPath = join(root, 'verbaly.config.json');\n if (existsSync(jsonPath)) {\n return JSON.parse(readFileSync(jsonPath, 'utf8')) as VerbalyConfig;\n }\n return {};\n}\n\nasync function loadTsConfig(path: string): Promise<VerbalyConfig> {\n try {\n const { bundleRequire } = await import('bundle-require');\n const { mod } = await bundleRequire<{ default?: VerbalyConfig }>({ filepath: path });\n return mod.default ?? {};\n } catch (error) {\n if (isModuleNotFound(error, 'esbuild')) {\n throw new Error(`[verbaly] ${path} needs esbuild: install it with pnpm add -D esbuild`, {\n cause: error,\n });\n }\n throw error;\n }\n}\n\nexport function isModuleNotFound(error: unknown, name: string): boolean {\n return (\n error instanceof Error &&\n (error as { code?: string }).code === 'ERR_MODULE_NOT_FOUND' &&\n error.message.includes(name)\n );\n}\n\n// non-source locales a command may write to (optional CLI override, always config-bounded)\nexport function targetLocales(cfg: ResolvedConfig, override?: string[]): string[] {\n return (override ?? cfg.locales).filter(\n (locale) => locale !== cfg.sourceLocale && cfg.locales.includes(locale),\n );\n}\n\n// file config + inline overrides\nexport async function loadConfig(\n root: string,\n overrides: VerbalyConfig = {},\n): Promise<ResolvedConfig> {\n const fileConfig = await loadConfigFile(root);\n return resolveConfig({ ...fileConfig, ...definedOnly(overrides), root });\n}\n\nfunction definedOnly(config: VerbalyConfig): VerbalyConfig {\n return Object.fromEntries(\n Object.entries(config).filter(([, value]) => value !== undefined),\n ) as VerbalyConfig;\n}\n"],"mappings":";;;;;AC+CA,SAAgB,cAAc,SAAwB,CAAC,GAAmB;CACxE,MAAM,OAAO,QAAQ,OAAO,QAAQ,QAAQ,IAAI,CAAC;CACjD,MAAM,MAAM,QAAQ,MAAM,OAAO,OAAO,SAAS;CACjD,MAAM,eAAe,OAAO,gBAAgB;CAE5C,MAAM,0BAAU,IAAI,IAAY,CAAC,cAAc,GAAI,OAAO,WAAW,CAAC,CAAE,CAAC;CACzE,IAAI,WAAW,GAAG,GACX;OAAA,MAAM,QAAQ,YAAY,GAAG,GAChC,IAAI,KAAK,SAAS,OAAO,KAAK,CAAC,KAAK,WAAW,GAAG,KAAK,SAAS,cAC9D,QAAQ,IAAI,KAAK,MAAM,GAAG,EAAE,CAAC;CAAA;CAKnC,OAAO;EACL;EACA;EACA;EACA,SAAS,CAAC,GAAG,OAAO;EACpB,SAAS,OAAO,WAAW,CAAC,yDAAyD;EACrF,SAAS,OAAO,WAAW,CAAC,sBAAsB,YAAY;EAC9D,KAAK,OAAO,OAAO,QAAQ,WAAW,QAAQ,MAAM,OAAO,GAAG,IAAI,OAAO;EACzE,WAAW,OAAO,aAAa,CAAC;EAChC,QAAQ,OAAO,UAAU,CAAC;CAC5B;AACF;AAcA,eAAsB,eAAe,MAAsC;CACzE,KAAK,MAAM,QAAQ,CAAC,qBAAqB,oBAAoB,GAAG;EAC9D,MAAM,OAAO,KAAK,MAAM,IAAI;EAC5B,IAAI,WAAW,IAAI,GAEjB,QAAO,MADY,OAAO,cAAc,IAAI,CAAC,CAAC,MAAA,CACnC,WAAW,CAAC;CAE3B;CACA,KAAK,MAAM,QAAQ,CAAC,qBAAqB,oBAAoB,GAAG;EAC9D,MAAM,OAAO,KAAK,MAAM,IAAI;EAC5B,IAAI,WAAW,IAAI,GAAG,OAAO,aAAa,IAAI;CAChD;CACA,MAAM,WAAW,KAAK,MAAM,qBAAqB;CACjD,IAAI,WAAW,QAAQ,GACrB,OAAO,KAAK,MAAM,aAAa,UAAU,MAAM,CAAC;CAElD,OAAO,CAAC;AACV;AAEA,eAAe,aAAa,MAAsC;CAChE,IAAI;EACF,MAAM,EAAE,kBAAkB,MAAM,OAAO;EACvC,MAAM,EAAE,QAAQ,MAAM,cAA2C,EAAE,UAAU,KAAK,CAAC;EACnF,OAAO,IAAI,WAAW,CAAC;CACzB,SAAS,OAAO;EACd,IAAI,iBAAiB,OAAO,SAAS,GACnC,MAAM,IAAI,MAAM,aAAa,KAAK,sDAAsD,EACtF,OAAO,MACT,CAAC;EAEH,MAAM;CACR;AACF;AAEA,SAAgB,iBAAiB,OAAgB,MAAuB;CACtE,OACE,iBAAiB,SAChB,MAA4B,SAAS,0BACtC,MAAM,QAAQ,SAAS,IAAI;AAE/B;AAGA,SAAgB,cAAc,KAAqB,UAA+B;CAChF,QAAQ,YAAY,IAAI,QAAA,CAAS,QAC9B,WAAW,WAAW,IAAI,gBAAgB,IAAI,QAAQ,SAAS,MAAM,CACxE;AACF;AAGA,eAAsB,WACpB,MACA,YAA2B,CAAC,GACH;CAEzB,OAAO,cAAc;EAAE,GAAG,MADD,eAAe,IAAI;EACN,GAAG,YAAY,SAAS;EAAG;CAAK,CAAC;AACzE;AAEA,SAAS,YAAY,QAAsC;CACzD,OAAO,OAAO,YACZ,OAAO,QAAQ,MAAM,CAAC,CAAC,QAAQ,GAAG,WAAW,UAAU,KAAA,CAAS,CAClE;AACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,47 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RichLink } from "verbaly";
|
|
2
2
|
import MagicString from "magic-string";
|
|
3
|
-
//#region src/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
interface TransComponent {
|
|
10
|
-
name: string;
|
|
11
|
-
source: string;
|
|
12
|
-
}
|
|
13
|
-
interface TaggedMessage {
|
|
14
|
-
key: string;
|
|
15
|
-
message: string;
|
|
16
|
-
params: TaggedParam[];
|
|
17
|
-
start: number;
|
|
18
|
-
end: number;
|
|
19
|
-
tagStart: number;
|
|
20
|
-
tagEnd: number;
|
|
21
|
-
file: string;
|
|
22
|
-
jsx?: {
|
|
23
|
-
name: string;
|
|
24
|
-
components: TransComponent[];
|
|
25
|
-
};
|
|
26
|
-
singleQuote?: boolean;
|
|
27
|
-
}
|
|
28
|
-
interface UsedKey {
|
|
29
|
-
key: string;
|
|
30
|
-
file: string;
|
|
31
|
-
}
|
|
32
|
-
interface Analysis {
|
|
33
|
-
tagged: TaggedMessage[];
|
|
34
|
-
usedKeys: UsedKey[];
|
|
35
|
-
}
|
|
36
|
-
interface AnalyzeOptions {
|
|
37
|
-
tNames?: readonly string[];
|
|
38
|
-
}
|
|
39
|
-
declare function analyze(code: string, file: string, options?: AnalyzeOptions): Analysis;
|
|
40
|
-
//#endregion
|
|
41
|
-
//#region src/sfc.d.ts
|
|
42
|
-
declare const SFC_FILE_RE: RegExp;
|
|
43
|
-
declare function analyzeFile(code: string, file: string): Analysis;
|
|
44
|
-
declare function analyzeSfc(code: string, file: string): Analysis;
|
|
3
|
+
//#region src/catalog.d.ts
|
|
4
|
+
type Catalog = Record<string, string>;
|
|
5
|
+
type Catalogs = Record<string, Catalog>;
|
|
6
|
+
declare function loadCatalogs(cfg: ResolvedConfig): Catalogs;
|
|
7
|
+
declare function writeCatalog(cfg: ResolvedConfig, locale: string, catalog: Catalog): string;
|
|
45
8
|
//#endregion
|
|
46
9
|
//#region src/translate.d.ts
|
|
47
10
|
interface TranslateRequest {
|
|
@@ -64,7 +27,6 @@ interface TranslateResult {
|
|
|
64
27
|
}
|
|
65
28
|
declare function translateCatalogs(cfg: ResolvedConfig, catalogs: Catalogs, provider: TranslateProvider, options?: TranslateOptions): Promise<TranslateResult>;
|
|
66
29
|
declare function resolveProvider(cfg: ResolvedConfig, model?: string): Promise<TranslateProvider>;
|
|
67
|
-
declare function structureMatches(source: string, translated: string): boolean;
|
|
68
30
|
//#endregion
|
|
69
31
|
//#region src/config.d.ts
|
|
70
32
|
interface TranslateConfig {
|
|
@@ -104,19 +66,47 @@ interface ResolvedConfig {
|
|
|
104
66
|
render: RenderConfig;
|
|
105
67
|
}
|
|
106
68
|
declare function resolveConfig(config?: VerbalyConfig): ResolvedConfig;
|
|
107
|
-
declare function findConfigFile(root: string): string | undefined;
|
|
108
|
-
declare function loadConfigFile(root: string): Promise<VerbalyConfig>;
|
|
109
|
-
declare function targetLocales(cfg: ResolvedConfig, override?: string[]): string[];
|
|
110
69
|
declare function loadConfig(root: string, overrides?: VerbalyConfig): Promise<ResolvedConfig>;
|
|
111
70
|
//#endregion
|
|
112
|
-
//#region src/
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
71
|
+
//#region src/analyze.d.ts
|
|
72
|
+
interface TaggedParam {
|
|
73
|
+
name: string;
|
|
74
|
+
start: number;
|
|
75
|
+
end: number;
|
|
76
|
+
}
|
|
77
|
+
interface TransComponent {
|
|
78
|
+
name: string;
|
|
79
|
+
source: string;
|
|
80
|
+
}
|
|
81
|
+
interface TaggedMessage {
|
|
82
|
+
key: string;
|
|
83
|
+
message: string;
|
|
84
|
+
params: TaggedParam[];
|
|
85
|
+
start: number;
|
|
86
|
+
end: number;
|
|
87
|
+
tagStart: number;
|
|
88
|
+
tagEnd: number;
|
|
89
|
+
file: string;
|
|
90
|
+
jsx?: {
|
|
91
|
+
name: string;
|
|
92
|
+
components: TransComponent[];
|
|
93
|
+
};
|
|
94
|
+
singleQuote?: boolean;
|
|
95
|
+
}
|
|
96
|
+
interface UsedKey {
|
|
97
|
+
key: string;
|
|
98
|
+
file: string;
|
|
99
|
+
}
|
|
100
|
+
interface StrayImport {
|
|
101
|
+
name: string;
|
|
102
|
+
source: string;
|
|
103
|
+
file: string;
|
|
104
|
+
}
|
|
105
|
+
interface Analysis {
|
|
106
|
+
tagged: TaggedMessage[];
|
|
107
|
+
usedKeys: UsedKey[];
|
|
108
|
+
strayImports: StrayImport[];
|
|
109
|
+
}
|
|
120
110
|
//#endregion
|
|
121
111
|
//#region src/registry.d.ts
|
|
122
112
|
declare class MessageRegistry {
|
|
@@ -125,50 +115,23 @@ declare class MessageRegistry {
|
|
|
125
115
|
remove(file: string): void;
|
|
126
116
|
messages(): Map<string, TaggedMessage>;
|
|
127
117
|
usedKeys(): Map<string, string[]>;
|
|
118
|
+
strayImports(): StrayImport[];
|
|
128
119
|
origins(): Map<string, string[]>;
|
|
129
120
|
}
|
|
130
121
|
//#endregion
|
|
131
|
-
//#region src/
|
|
132
|
-
declare
|
|
133
|
-
|
|
134
|
-
interface
|
|
135
|
-
|
|
136
|
-
message: string;
|
|
122
|
+
//#region src/extract.d.ts
|
|
123
|
+
declare function extractProject(cfg: ResolvedConfig): Promise<MessageRegistry>;
|
|
124
|
+
declare function collectOrigins(cfg: ResolvedConfig): Promise<Record<string, string[]>>;
|
|
125
|
+
interface SyncResult {
|
|
126
|
+
added: Record<string, string[]>;
|
|
137
127
|
}
|
|
138
|
-
declare function
|
|
139
|
-
declare function
|
|
128
|
+
declare function syncCatalogs(cfg: ResolvedConfig, catalogs: Catalogs, registry: MessageRegistry): SyncResult;
|
|
129
|
+
declare function pruneCatalogs(cfg: ResolvedConfig, catalogs: Catalogs, registry: MessageRegistry): Record<string, string[]>;
|
|
140
130
|
//#endregion
|
|
141
|
-
//#region src/
|
|
142
|
-
|
|
143
|
-
locale: string;
|
|
144
|
-
key: string;
|
|
145
|
-
source?: string;
|
|
146
|
-
}
|
|
147
|
-
interface UnknownEntry {
|
|
148
|
-
key: string;
|
|
149
|
-
files: string[];
|
|
150
|
-
}
|
|
151
|
-
interface BrokenEntry {
|
|
152
|
-
locale: string;
|
|
153
|
-
key: string;
|
|
154
|
-
severity: IssueSeverity;
|
|
155
|
-
issue: string;
|
|
156
|
-
}
|
|
157
|
-
interface CheckResult {
|
|
158
|
-
ok: boolean;
|
|
159
|
-
missing: MissingEntry[];
|
|
160
|
-
unknown: UnknownEntry[];
|
|
161
|
-
broken: BrokenEntry[];
|
|
162
|
-
}
|
|
163
|
-
declare function gatePasses(result: Omit<CheckResult, 'ok'>): boolean;
|
|
164
|
-
declare function check(cfg: ResolvedConfig, catalogs: Catalogs, registry: MessageRegistry): CheckResult;
|
|
165
|
-
declare function formatCheckResult(result: CheckResult): string;
|
|
166
|
-
declare function checkNextSteps(result: CheckResult): string;
|
|
167
|
-
declare function formatCheckWarnings(result: CheckResult): string;
|
|
168
|
-
declare function githubCheckAnnotations(result: CheckResult, registry: MessageRegistry, root: string): string[];
|
|
131
|
+
//#region src/key.d.ts
|
|
132
|
+
declare function stableKey(message: string): string;
|
|
169
133
|
//#endregion
|
|
170
134
|
//#region src/codegen.d.ts
|
|
171
|
-
declare const VIRTUAL_ID = "virtual:verbaly";
|
|
172
135
|
interface RuntimeModuleOptions {
|
|
173
136
|
localeImport?: (locale: string) => string;
|
|
174
137
|
extraExports?: string;
|
|
@@ -197,150 +160,64 @@ declare function loadVirtualModule(id: string, cfg: ResolvedConfig, catalogs: Ca
|
|
|
197
160
|
declare function isTransformTarget(id: string): boolean;
|
|
198
161
|
declare function createSourceFilter(cfg: ResolvedConfig): (id: string) => boolean;
|
|
199
162
|
declare function transformSource(code: string, id: string, registry: MessageRegistry): {
|
|
200
|
-
|
|
163
|
+
messages: Catalog;
|
|
201
164
|
result: TransformResult | null;
|
|
202
165
|
};
|
|
203
166
|
declare function runBuildGate(cfg: ResolvedConfig, registry: MessageRegistry, failOnMissing?: boolean): void;
|
|
204
167
|
//#endregion
|
|
205
|
-
//#region src/
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
168
|
+
//#region src/validate.d.ts
|
|
169
|
+
type IssueSeverity = 'error' | 'warning';
|
|
170
|
+
//#endregion
|
|
171
|
+
//#region src/check.d.ts
|
|
172
|
+
interface MissingEntry {
|
|
173
|
+
locale: string;
|
|
174
|
+
key: string;
|
|
175
|
+
source?: string;
|
|
211
176
|
}
|
|
212
|
-
interface
|
|
177
|
+
interface UnknownEntry {
|
|
178
|
+
key: string;
|
|
179
|
+
files: string[];
|
|
180
|
+
}
|
|
181
|
+
interface BrokenEntry {
|
|
182
|
+
locale: string;
|
|
183
|
+
key: string;
|
|
184
|
+
severity: IssueSeverity;
|
|
185
|
+
issue: string;
|
|
186
|
+
}
|
|
187
|
+
interface CheckResult {
|
|
213
188
|
ok: boolean;
|
|
214
|
-
|
|
189
|
+
missing: MissingEntry[];
|
|
190
|
+
unknown: UnknownEntry[];
|
|
191
|
+
broken: BrokenEntry[];
|
|
215
192
|
}
|
|
216
|
-
declare function
|
|
193
|
+
declare function check(cfg: ResolvedConfig, catalogs: Catalogs, registry: MessageRegistry): CheckResult;
|
|
194
|
+
declare function formatCheckResult(result: CheckResult): string;
|
|
195
|
+
declare function formatCheckWarnings(result: CheckResult): string;
|
|
217
196
|
//#endregion
|
|
218
197
|
//#region src/drafts.d.ts
|
|
219
|
-
declare const DRAFTS_FILE = ".verbaly-drafts.json";
|
|
220
198
|
type Drafts = Record<string, string[]>;
|
|
221
199
|
declare function loadDrafts(cfg: ResolvedConfig): Drafts;
|
|
222
200
|
declare function saveDrafts(cfg: ResolvedConfig, drafts: Drafts): void;
|
|
223
201
|
declare function markDrafts(drafts: Drafts, locale: string, keys: string[]): void;
|
|
224
|
-
declare function clearDrafts(drafts: Drafts, locale: string, keys?: string[]): void;
|
|
225
202
|
declare function effectiveDrafts(drafts: Drafts, catalogs: Catalogs): Drafts;
|
|
226
203
|
//#endregion
|
|
227
|
-
//#region src/
|
|
228
|
-
|
|
229
|
-
type MobileFormat = 'android-xml' | 'ios-strings';
|
|
230
|
-
type ExportFormat = ExchangeFormat | MobileFormat;
|
|
231
|
-
declare function isMobileFormat(format: ExportFormat): format is MobileFormat;
|
|
232
|
-
interface ExportOptions {
|
|
233
|
-
locales?: string[];
|
|
234
|
-
format?: ExportFormat;
|
|
235
|
-
out?: string;
|
|
236
|
-
missing?: boolean;
|
|
237
|
-
origins?: Record<string, string[]>;
|
|
238
|
-
}
|
|
239
|
-
interface ExportedFile {
|
|
204
|
+
//#region src/status.d.ts
|
|
205
|
+
interface LocaleStatus {
|
|
240
206
|
locale: string;
|
|
241
|
-
|
|
207
|
+
translated: number;
|
|
242
208
|
total: number;
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
interface ExportResult {
|
|
246
|
-
format: ExportFormat;
|
|
247
|
-
dir: string;
|
|
248
|
-
files: ExportedFile[];
|
|
249
|
-
}
|
|
250
|
-
interface ImportOptions {
|
|
251
|
-
locale?: string;
|
|
252
|
-
overwrite?: boolean;
|
|
253
|
-
dryRun?: boolean;
|
|
254
|
-
}
|
|
255
|
-
interface ImportResult {
|
|
256
|
-
imported: Record<string, string[]>;
|
|
257
|
-
rejected: Record<string, string[]>;
|
|
258
|
-
skipped: Record<string, string[]>;
|
|
259
|
-
unknown: Record<string, string[]>;
|
|
260
|
-
}
|
|
261
|
-
declare function exportCatalogs(cfg: ResolvedConfig, catalogs: Catalogs, options?: ExportOptions): ExportResult;
|
|
262
|
-
declare function importCatalogs(cfg: ResolvedConfig, catalogs: Catalogs, files: string[], options?: ImportOptions): ImportResult;
|
|
263
|
-
interface ParsedFile {
|
|
264
|
-
locale: string;
|
|
265
|
-
entries: Record<string, string>;
|
|
266
|
-
}
|
|
267
|
-
declare function parseExchangeFile(file: string, localeOverride?: string): ParsedFile;
|
|
268
|
-
//#endregion
|
|
269
|
-
//#region src/extract.d.ts
|
|
270
|
-
declare function extractProject(cfg: ResolvedConfig): Promise<MessageRegistry>;
|
|
271
|
-
declare function collectOrigins(cfg: ResolvedConfig): Promise<Record<string, string[]>>;
|
|
272
|
-
interface SyncResult {
|
|
273
|
-
added: Record<string, string[]>;
|
|
274
|
-
}
|
|
275
|
-
declare function syncCatalogs(cfg: ResolvedConfig, catalogs: Catalogs, registry: MessageRegistry): SyncResult;
|
|
276
|
-
declare function pruneCatalogs(cfg: ResolvedConfig, catalogs: Catalogs, registry: MessageRegistry): Record<string, string[]>;
|
|
277
|
-
//#endregion
|
|
278
|
-
//#region src/init.d.ts
|
|
279
|
-
interface InitOptions {
|
|
280
|
-
root?: string;
|
|
281
|
-
dir?: string;
|
|
282
|
-
sourceLocale?: string;
|
|
283
|
-
locales?: string[];
|
|
284
|
-
}
|
|
285
|
-
interface InitResult {
|
|
286
|
-
created: string[];
|
|
287
|
-
skipped: string[];
|
|
288
|
-
host: Host | undefined;
|
|
289
|
-
configFile: string;
|
|
290
|
-
next: string[];
|
|
291
|
-
}
|
|
292
|
-
type Host = 'nuxt' | 'next' | 'sveltekit' | 'astro' | 'vite' | 'webpack' | 'rspack' | 'rollup' | 'esbuild';
|
|
293
|
-
interface HostSetup {
|
|
294
|
-
name: Host;
|
|
295
|
-
pkg: string;
|
|
296
|
-
wire: string;
|
|
209
|
+
drafts: number;
|
|
210
|
+
broken: number;
|
|
297
211
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
//#endregion
|
|
303
|
-
//#region src/key.d.ts
|
|
304
|
-
declare function stableKey(message: string): string;
|
|
305
|
-
//#endregion
|
|
306
|
-
//#region src/params.d.ts
|
|
307
|
-
type ParamType = 'number' | 'string' | 'date' | 'unknown';
|
|
308
|
-
declare function collectParams(message: string): Map<string, Set<ParamType>>;
|
|
309
|
-
declare function renderParamType(types: Set<ParamType>): string;
|
|
310
|
-
//#endregion
|
|
311
|
-
//#region src/providers/claude.d.ts
|
|
312
|
-
interface ClaudeProviderOptions {
|
|
313
|
-
model?: string;
|
|
314
|
-
apiKey?: string;
|
|
315
|
-
maxTokens?: number;
|
|
212
|
+
interface StatusResult {
|
|
213
|
+
messages: number;
|
|
214
|
+
source: string;
|
|
215
|
+
locales: LocaleStatus[];
|
|
316
216
|
}
|
|
317
|
-
declare function
|
|
318
|
-
|
|
319
|
-
//#region src/pseudo.d.ts
|
|
320
|
-
declare const PSEUDO_LOCALE = "en-XA";
|
|
321
|
-
declare function pseudoLocalize(message: string): string;
|
|
322
|
-
declare function pseudoCatalogs(cfg: ResolvedConfig, catalogs: Catalogs, locale?: string): string[];
|
|
217
|
+
declare function status(cfg: ResolvedConfig, catalogs: Catalogs, registry: MessageRegistry, drafts?: Drafts): StatusResult;
|
|
218
|
+
declare function formatStatusResult(result: StatusResult): string;
|
|
323
219
|
//#endregion
|
|
324
220
|
//#region src/render.d.ts
|
|
325
|
-
interface Alternate {
|
|
326
|
-
hreflang: string;
|
|
327
|
-
href: string;
|
|
328
|
-
}
|
|
329
|
-
interface RenderHtmlOptions {
|
|
330
|
-
locale: string;
|
|
331
|
-
catalogs: Catalogs | Record<string, MessageTree>;
|
|
332
|
-
sourceLocale?: string;
|
|
333
|
-
attribute?: string;
|
|
334
|
-
richTags?: string[];
|
|
335
|
-
richLinks?: Record<string, RichLink>;
|
|
336
|
-
setLang?: boolean;
|
|
337
|
-
alternates?: Alternate[];
|
|
338
|
-
}
|
|
339
|
-
interface RenderHtmlResult {
|
|
340
|
-
html: string;
|
|
341
|
-
missing: string[];
|
|
342
|
-
}
|
|
343
|
-
declare function renderHtml(html: string, options: RenderHtmlOptions): RenderHtmlResult;
|
|
344
221
|
interface RenderSiteOptions {
|
|
345
222
|
site?: string;
|
|
346
223
|
locales?: string[];
|
|
@@ -359,58 +236,5 @@ interface RenderSiteResult {
|
|
|
359
236
|
}
|
|
360
237
|
declare function renderSite(cfg: ResolvedConfig, options?: RenderSiteOptions): Promise<RenderSiteResult>;
|
|
361
238
|
//#endregion
|
|
362
|
-
|
|
363
|
-
interface LocaleStatus {
|
|
364
|
-
locale: string;
|
|
365
|
-
translated: number;
|
|
366
|
-
total: number;
|
|
367
|
-
drafts: number;
|
|
368
|
-
broken: number;
|
|
369
|
-
}
|
|
370
|
-
interface StatusResult {
|
|
371
|
-
messages: number;
|
|
372
|
-
source: string;
|
|
373
|
-
locales: LocaleStatus[];
|
|
374
|
-
}
|
|
375
|
-
declare function status(cfg: ResolvedConfig, catalogs: Catalogs, registry: MessageRegistry, drafts?: Drafts): StatusResult;
|
|
376
|
-
declare function formatStatusResult(result: StatusResult): string;
|
|
377
|
-
//#endregion
|
|
378
|
-
//#region src/watch.d.ts
|
|
379
|
-
interface WatchProjectOptions {
|
|
380
|
-
debounce?: number;
|
|
381
|
-
}
|
|
382
|
-
declare function watchProject(cfg: ResolvedConfig, run: () => Promise<void>, options?: WatchProjectOptions): () => void;
|
|
383
|
-
//#endregion
|
|
384
|
-
//#region src/wrap.d.ts
|
|
385
|
-
interface WrapEntry {
|
|
386
|
-
file: string;
|
|
387
|
-
line: number;
|
|
388
|
-
text: string;
|
|
389
|
-
kind: 'text' | 'attribute';
|
|
390
|
-
attribute?: string;
|
|
391
|
-
}
|
|
392
|
-
interface WrapSkip {
|
|
393
|
-
file: string;
|
|
394
|
-
line: number;
|
|
395
|
-
text: string;
|
|
396
|
-
reason: string;
|
|
397
|
-
}
|
|
398
|
-
interface WrapResult {
|
|
399
|
-
files: number;
|
|
400
|
-
changed: string[];
|
|
401
|
-
wrapped: WrapEntry[];
|
|
402
|
-
skipped: WrapSkip[];
|
|
403
|
-
}
|
|
404
|
-
interface WrapOptions {
|
|
405
|
-
write?: boolean;
|
|
406
|
-
}
|
|
407
|
-
declare function wrapProject(cfg: ResolvedConfig, options?: WrapOptions): Promise<WrapResult>;
|
|
408
|
-
interface WrapCodeResult {
|
|
409
|
-
code?: string;
|
|
410
|
-
wrapped: WrapEntry[];
|
|
411
|
-
skipped: WrapSkip[];
|
|
412
|
-
}
|
|
413
|
-
declare function wrapCode(code: string, file: string): WrapCodeResult;
|
|
414
|
-
//#endregion
|
|
415
|
-
export { type Alternate, type Analysis, type AnalyzeOptions, type BrokenEntry, type Catalog, type Catalogs, type CheckResult, type ClaudeProviderOptions, DRAFTS_FILE, type DoctorEntry, type DoctorResult, type Drafts, type ExchangeFormat, type ExportFormat, type ExportOptions, type ExportResult, type ExportedFile, type Host, type HostSetup, type ImportOptions, type ImportResult, type InitOptions, type InitResult, type IssueSeverity, LOCALE_MODULE_PREFIX, type LocaleStatus, MessageRegistry, type MissingEntry, type MobileFormat, PLURAL_CATEGORIES, PSEUDO_LOCALE, type ParamType, type PluginOptions, RESOLVED_VIRTUAL_ID, type RenderConfig, type RenderHtmlOptions, type RenderHtmlResult, type RenderSiteOptions, type RenderSiteResult, type ResolvedConfig, type RuntimeModuleOptions, SFC_FILE_RE, SOURCE_FILE_RE, type StatusResult, type StructureIssue, type SyncResult, type TaggedMessage, type TaggedParam, type TransComponent, type TransformResult, type TranslateConfig, type TranslateOptions, type TranslateProvider, type TranslateRequest, type TranslateResult, type UnknownEntry, type UsedKey, VIRTUAL_ID, type VerbalyConfig, WIRING_PACKAGES, type WatchProjectOptions, type WrapCodeResult, type WrapEntry, type WrapOptions, type WrapResult, type WrapSkip, analyze, analyzeFile, analyzeSfc, catalogPath, check, checkNextSteps, claudeProvider, clearDrafts, collectOrigins, collectParams, createSourceFilter, detectHost, doctor, effectiveDrafts, exportCatalogs, extractProject, findConfigFile, formatCheckResult, formatCheckWarnings, formatStatusResult, gatePasses, generateDts, generateLocaleModule, generateRuntimeModule, githubCheckAnnotations, importCatalogs, init, isMobileFormat, isTransformTarget, loadCatalogs, loadConfig, loadConfigFile, loadDrafts, loadVirtualModule, markDrafts, parseExchangeFile, pruneCatalogs, pseudoCatalogs, pseudoLocalize, readCatalog, readDependencies, renderHtml, renderParamType, renderSite, resolveConfig, resolveProvider, resolveVirtualId, runBuildGate, saveDrafts, serializeCatalog, stableKey, status, structureMatches, syncCatalogs, targetLocales, transformCode, transformSource, translateCatalogs, validateMessage, validatePair, watchProject, wrapCode, wrapProject, writeCatalog, writeDts };
|
|
239
|
+
export { type BrokenEntry, type Catalog, type Catalogs, type CheckResult, type Drafts, type IssueSeverity, LOCALE_MODULE_PREFIX, type LocaleStatus, MessageRegistry, type MissingEntry, type PluginOptions, RESOLVED_VIRTUAL_ID, type RenderConfig, type RenderSiteOptions, type RenderSiteResult, type ResolvedConfig, type RuntimeModuleOptions, SOURCE_FILE_RE, type StatusResult, type SyncResult, type TransformResult, type TranslateConfig, type TranslateOptions, type TranslateProvider, type TranslateRequest, type TranslateResult, type UnknownEntry, type VerbalyConfig, check, collectOrigins, createSourceFilter, effectiveDrafts, extractProject, formatCheckResult, formatCheckWarnings, formatStatusResult, generateDts, generateLocaleModule, generateRuntimeModule, isTransformTarget, loadCatalogs, loadConfig, loadDrafts, loadVirtualModule, markDrafts, pruneCatalogs, renderSite, resolveConfig, resolveProvider, resolveVirtualId, runBuildGate, saveDrafts, stableKey, status, syncCatalogs, transformCode, transformSource, translateCatalogs, writeCatalog, writeDts };
|
|
416
240
|
//# sourceMappingURL=index.d.ts.map
|