@verbaly/compiler 0.32.0 → 0.34.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.
@@ -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,53 +1,10 @@
1
- import { MessageTree, RichLink } from "verbaly";
1
+ import { RichLink } from "verbaly";
2
2
  import MagicString from "magic-string";
3
- //#region src/analyze.d.ts
4
- interface TaggedParam {
5
- name: string;
6
- start: number;
7
- end: number;
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 StrayImport {
33
- name: string;
34
- source: string;
35
- file: string;
36
- }
37
- interface Analysis {
38
- tagged: TaggedMessage[];
39
- usedKeys: UsedKey[];
40
- strayImports: StrayImport[];
41
- }
42
- interface AnalyzeOptions {
43
- tNames?: readonly string[];
44
- }
45
- declare function analyze(code: string, file: string, options?: AnalyzeOptions): Analysis;
46
- //#endregion
47
- //#region src/sfc.d.ts
48
- declare const SFC_FILE_RE: RegExp;
49
- declare function analyzeFile(code: string, file: string): Analysis;
50
- 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;
51
8
  //#endregion
52
9
  //#region src/translate.d.ts
53
10
  interface TranslateRequest {
@@ -70,7 +27,6 @@ interface TranslateResult {
70
27
  }
71
28
  declare function translateCatalogs(cfg: ResolvedConfig, catalogs: Catalogs, provider: TranslateProvider, options?: TranslateOptions): Promise<TranslateResult>;
72
29
  declare function resolveProvider(cfg: ResolvedConfig, model?: string): Promise<TranslateProvider>;
73
- declare function structureMatches(source: string, translated: string): boolean;
74
30
  //#endregion
75
31
  //#region src/config.d.ts
76
32
  interface TranslateConfig {
@@ -110,19 +66,48 @@ interface ResolvedConfig {
110
66
  render: RenderConfig;
111
67
  }
112
68
  declare function resolveConfig(config?: VerbalyConfig): ResolvedConfig;
113
- declare function findConfigFile(root: string): string | undefined;
114
- declare function loadConfigFile(root: string): Promise<VerbalyConfig>;
115
- declare function targetLocales(cfg: ResolvedConfig, override?: string[]): string[];
116
69
  declare function loadConfig(root: string, overrides?: VerbalyConfig): Promise<ResolvedConfig>;
117
70
  //#endregion
118
- //#region src/catalog.d.ts
119
- type Catalog = Record<string, string>;
120
- type Catalogs = Record<string, Catalog>;
121
- declare function catalogPath(cfg: ResolvedConfig, locale: string): string;
122
- declare function readCatalog(cfg: ResolvedConfig, locale: string): Catalog;
123
- declare function loadCatalogs(cfg: ResolvedConfig): Catalogs;
124
- declare function serializeCatalog(catalog: Catalog): string;
125
- declare function writeCatalog(cfg: ResolvedConfig, locale: string, catalog: Catalog): string;
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
+ parseError?: string;
110
+ }
126
111
  //#endregion
127
112
  //#region src/registry.d.ts
128
113
  declare class MessageRegistry {
@@ -132,50 +117,26 @@ declare class MessageRegistry {
132
117
  messages(): Map<string, TaggedMessage>;
133
118
  usedKeys(): Map<string, string[]>;
134
119
  strayImports(): StrayImport[];
120
+ parseErrors(): {
121
+ file: string;
122
+ message: string;
123
+ }[];
135
124
  origins(): Map<string, string[]>;
136
125
  }
137
126
  //#endregion
138
- //#region src/validate.d.ts
139
- declare const PLURAL_CATEGORIES: Set<string>;
140
- type IssueSeverity = 'error' | 'warning';
141
- interface StructureIssue {
142
- severity: IssueSeverity;
143
- message: string;
127
+ //#region src/extract.d.ts
128
+ declare function extractProject(cfg: ResolvedConfig): Promise<MessageRegistry>;
129
+ declare function collectOrigins(cfg: ResolvedConfig): Promise<Record<string, string[]>>;
130
+ interface SyncResult {
131
+ added: Record<string, string[]>;
144
132
  }
145
- declare function validateMessage(message: string, locale?: string): StructureIssue[];
146
- declare function validatePair(source: string, translated: string): StructureIssue[];
133
+ declare function syncCatalogs(cfg: ResolvedConfig, catalogs: Catalogs, registry: MessageRegistry): SyncResult;
134
+ declare function pruneCatalogs(cfg: ResolvedConfig, catalogs: Catalogs, registry: MessageRegistry): Record<string, string[]>;
147
135
  //#endregion
148
- //#region src/check.d.ts
149
- interface MissingEntry {
150
- locale: string;
151
- key: string;
152
- source?: string;
153
- }
154
- interface UnknownEntry {
155
- key: string;
156
- files: string[];
157
- }
158
- interface BrokenEntry {
159
- locale: string;
160
- key: string;
161
- severity: IssueSeverity;
162
- issue: string;
163
- }
164
- interface CheckResult {
165
- ok: boolean;
166
- missing: MissingEntry[];
167
- unknown: UnknownEntry[];
168
- broken: BrokenEntry[];
169
- }
170
- declare function gatePasses(result: Omit<CheckResult, 'ok'>): boolean;
171
- declare function check(cfg: ResolvedConfig, catalogs: Catalogs, registry: MessageRegistry): CheckResult;
172
- declare function formatCheckResult(result: CheckResult): string;
173
- declare function checkNextSteps(result: CheckResult): string;
174
- declare function formatCheckWarnings(result: CheckResult): string;
175
- declare function githubCheckAnnotations(result: CheckResult, registry: MessageRegistry, root: string): string[];
136
+ //#region src/key.d.ts
137
+ declare function stableKey(message: string): string;
176
138
  //#endregion
177
139
  //#region src/codegen.d.ts
178
- declare const VIRTUAL_ID = "virtual:verbaly";
179
140
  interface RuntimeModuleOptions {
180
141
  localeImport?: (locale: string) => string;
181
142
  extraExports?: string;
@@ -204,150 +165,64 @@ declare function loadVirtualModule(id: string, cfg: ResolvedConfig, catalogs: Ca
204
165
  declare function isTransformTarget(id: string): boolean;
205
166
  declare function createSourceFilter(cfg: ResolvedConfig): (id: string) => boolean;
206
167
  declare function transformSource(code: string, id: string, registry: MessageRegistry): {
207
- analysis: Analysis;
168
+ messages: Catalog;
208
169
  result: TransformResult | null;
209
170
  };
210
171
  declare function runBuildGate(cfg: ResolvedConfig, registry: MessageRegistry, failOnMissing?: boolean): void;
211
172
  //#endregion
212
- //#region src/doctor.d.ts
213
- interface DoctorEntry {
214
- level: 'ok' | 'warn' | 'error';
215
- check: string;
216
- message: string;
217
- fix?: string;
173
+ //#region src/validate.d.ts
174
+ type IssueSeverity = 'error' | 'warning';
175
+ //#endregion
176
+ //#region src/check.d.ts
177
+ interface MissingEntry {
178
+ locale: string;
179
+ key: string;
180
+ source?: string;
181
+ }
182
+ interface UnknownEntry {
183
+ key: string;
184
+ files: string[];
218
185
  }
219
- interface DoctorResult {
186
+ interface BrokenEntry {
187
+ locale: string;
188
+ key: string;
189
+ severity: IssueSeverity;
190
+ issue: string;
191
+ }
192
+ interface CheckResult {
220
193
  ok: boolean;
221
- entries: DoctorEntry[];
194
+ missing: MissingEntry[];
195
+ unknown: UnknownEntry[];
196
+ broken: BrokenEntry[];
222
197
  }
223
- declare function doctor(cfg: ResolvedConfig): Promise<DoctorResult>;
198
+ declare function check(cfg: ResolvedConfig, catalogs: Catalogs, registry: MessageRegistry): CheckResult;
199
+ declare function formatCheckResult(result: CheckResult): string;
200
+ declare function formatCheckWarnings(result: CheckResult): string;
224
201
  //#endregion
225
202
  //#region src/drafts.d.ts
226
- declare const DRAFTS_FILE = ".verbaly-drafts.json";
227
203
  type Drafts = Record<string, string[]>;
228
204
  declare function loadDrafts(cfg: ResolvedConfig): Drafts;
229
205
  declare function saveDrafts(cfg: ResolvedConfig, drafts: Drafts): void;
230
206
  declare function markDrafts(drafts: Drafts, locale: string, keys: string[]): void;
231
- declare function clearDrafts(drafts: Drafts, locale: string, keys?: string[]): void;
232
207
  declare function effectiveDrafts(drafts: Drafts, catalogs: Catalogs): Drafts;
233
208
  //#endregion
234
- //#region src/exchange.d.ts
235
- type ExchangeFormat = 'xliff' | 'csv' | 'po';
236
- type MobileFormat = 'android-xml' | 'ios-strings';
237
- type ExportFormat = ExchangeFormat | MobileFormat;
238
- declare function isMobileFormat(format: ExportFormat): format is MobileFormat;
239
- interface ExportOptions {
240
- locales?: string[];
241
- format?: ExportFormat;
242
- out?: string;
243
- missing?: boolean;
244
- origins?: Record<string, string[]>;
245
- }
246
- interface ExportedFile {
209
+ //#region src/status.d.ts
210
+ interface LocaleStatus {
247
211
  locale: string;
248
- path: string;
212
+ translated: number;
249
213
  total: number;
250
- untranslated: number;
251
- }
252
- interface ExportResult {
253
- format: ExportFormat;
254
- dir: string;
255
- files: ExportedFile[];
256
- }
257
- interface ImportOptions {
258
- locale?: string;
259
- overwrite?: boolean;
260
- dryRun?: boolean;
261
- }
262
- interface ImportResult {
263
- imported: Record<string, string[]>;
264
- rejected: Record<string, string[]>;
265
- skipped: Record<string, string[]>;
266
- unknown: Record<string, string[]>;
267
- }
268
- declare function exportCatalogs(cfg: ResolvedConfig, catalogs: Catalogs, options?: ExportOptions): ExportResult;
269
- declare function importCatalogs(cfg: ResolvedConfig, catalogs: Catalogs, files: string[], options?: ImportOptions): ImportResult;
270
- interface ParsedFile {
271
- locale: string;
272
- entries: Record<string, string>;
273
- }
274
- declare function parseExchangeFile(file: string, localeOverride?: string): ParsedFile;
275
- //#endregion
276
- //#region src/extract.d.ts
277
- declare function extractProject(cfg: ResolvedConfig): Promise<MessageRegistry>;
278
- declare function collectOrigins(cfg: ResolvedConfig): Promise<Record<string, string[]>>;
279
- interface SyncResult {
280
- added: Record<string, string[]>;
281
- }
282
- declare function syncCatalogs(cfg: ResolvedConfig, catalogs: Catalogs, registry: MessageRegistry): SyncResult;
283
- declare function pruneCatalogs(cfg: ResolvedConfig, catalogs: Catalogs, registry: MessageRegistry): Record<string, string[]>;
284
- //#endregion
285
- //#region src/init.d.ts
286
- interface InitOptions {
287
- root?: string;
288
- dir?: string;
289
- sourceLocale?: string;
290
- locales?: string[];
291
- }
292
- interface InitResult {
293
- created: string[];
294
- skipped: string[];
295
- host: Host | undefined;
296
- configFile: string;
297
- next: string[];
298
- }
299
- type Host = 'nuxt' | 'next' | 'sveltekit' | 'astro' | 'vite' | 'webpack' | 'rspack' | 'rollup' | 'esbuild';
300
- interface HostSetup {
301
- name: Host;
302
- pkg: string;
303
- wire: string;
214
+ drafts: number;
215
+ broken: number;
304
216
  }
305
- declare const WIRING_PACKAGES: string[];
306
- declare function readDependencies(root: string): Record<string, string>;
307
- declare function detectHost(root: string): HostSetup | undefined;
308
- declare function init(options?: InitOptions): InitResult;
309
- //#endregion
310
- //#region src/key.d.ts
311
- declare function stableKey(message: string): string;
312
- //#endregion
313
- //#region src/params.d.ts
314
- type ParamType = 'number' | 'string' | 'date' | 'unknown';
315
- declare function collectParams(message: string): Map<string, Set<ParamType>>;
316
- declare function renderParamType(types: Set<ParamType>): string;
317
- //#endregion
318
- //#region src/providers/claude.d.ts
319
- interface ClaudeProviderOptions {
320
- model?: string;
321
- apiKey?: string;
322
- maxTokens?: number;
217
+ interface StatusResult {
218
+ messages: number;
219
+ source: string;
220
+ locales: LocaleStatus[];
323
221
  }
324
- declare function claudeProvider(options?: ClaudeProviderOptions): TranslateProvider;
325
- //#endregion
326
- //#region src/pseudo.d.ts
327
- declare const PSEUDO_LOCALE = "en-XA";
328
- declare function pseudoLocalize(message: string): string;
329
- declare function pseudoCatalogs(cfg: ResolvedConfig, catalogs: Catalogs, locale?: string): string[];
222
+ declare function status(cfg: ResolvedConfig, catalogs: Catalogs, registry: MessageRegistry, drafts?: Drafts): StatusResult;
223
+ declare function formatStatusResult(result: StatusResult): string;
330
224
  //#endregion
331
225
  //#region src/render.d.ts
332
- interface Alternate {
333
- hreflang: string;
334
- href: string;
335
- }
336
- interface RenderHtmlOptions {
337
- locale: string;
338
- catalogs: Catalogs | Record<string, MessageTree>;
339
- sourceLocale?: string;
340
- attribute?: string;
341
- richTags?: string[];
342
- richLinks?: Record<string, RichLink>;
343
- setLang?: boolean;
344
- alternates?: Alternate[];
345
- }
346
- interface RenderHtmlResult {
347
- html: string;
348
- missing: string[];
349
- }
350
- declare function renderHtml(html: string, options: RenderHtmlOptions): RenderHtmlResult;
351
226
  interface RenderSiteOptions {
352
227
  site?: string;
353
228
  locales?: string[];
@@ -366,58 +241,5 @@ interface RenderSiteResult {
366
241
  }
367
242
  declare function renderSite(cfg: ResolvedConfig, options?: RenderSiteOptions): Promise<RenderSiteResult>;
368
243
  //#endregion
369
- //#region src/status.d.ts
370
- interface LocaleStatus {
371
- locale: string;
372
- translated: number;
373
- total: number;
374
- drafts: number;
375
- broken: number;
376
- }
377
- interface StatusResult {
378
- messages: number;
379
- source: string;
380
- locales: LocaleStatus[];
381
- }
382
- declare function status(cfg: ResolvedConfig, catalogs: Catalogs, registry: MessageRegistry, drafts?: Drafts): StatusResult;
383
- declare function formatStatusResult(result: StatusResult): string;
384
- //#endregion
385
- //#region src/watch.d.ts
386
- interface WatchProjectOptions {
387
- debounce?: number;
388
- }
389
- declare function watchProject(cfg: ResolvedConfig, run: () => Promise<void>, options?: WatchProjectOptions): () => void;
390
- //#endregion
391
- //#region src/wrap.d.ts
392
- interface WrapEntry {
393
- file: string;
394
- line: number;
395
- text: string;
396
- kind: 'text' | 'attribute';
397
- attribute?: string;
398
- }
399
- interface WrapSkip {
400
- file: string;
401
- line: number;
402
- text: string;
403
- reason: string;
404
- }
405
- interface WrapResult {
406
- files: number;
407
- changed: string[];
408
- wrapped: WrapEntry[];
409
- skipped: WrapSkip[];
410
- }
411
- interface WrapOptions {
412
- write?: boolean;
413
- }
414
- declare function wrapProject(cfg: ResolvedConfig, options?: WrapOptions): Promise<WrapResult>;
415
- interface WrapCodeResult {
416
- code?: string;
417
- wrapped: WrapEntry[];
418
- skipped: WrapSkip[];
419
- }
420
- declare function wrapCode(code: string, file: string): WrapCodeResult;
421
- //#endregion
422
- 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 StrayImport, 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 };
244
+ 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 };
423
245
  //# sourceMappingURL=index.d.ts.map