@verbaly/compiler 0.11.0 → 0.13.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/dist/index.d.ts CHANGED
@@ -1,90 +1,94 @@
1
- import { RichLink } from 'verbaly';
2
- import MagicString from 'magic-string';
3
-
1
+ import { RichLink } from "verbaly";
2
+ import MagicString from "magic-string";
3
+ //#region src/analyze.d.ts
4
4
  interface TaggedParam {
5
- name: string;
6
- start: number;
7
- end: number;
5
+ name: string;
6
+ start: number;
7
+ end: number;
8
8
  }
9
9
  interface TransComponent {
10
- name: string;
11
- source: string;
10
+ name: string;
11
+ source: string;
12
12
  }
13
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
- };
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
26
  }
27
27
  interface UsedKey {
28
- key: string;
29
- file: string;
28
+ key: string;
29
+ file: string;
30
30
  }
31
31
  interface Analysis {
32
- tagged: TaggedMessage[];
33
- usedKeys: UsedKey[];
32
+ tagged: TaggedMessage[];
33
+ usedKeys: UsedKey[];
34
34
  }
35
35
  declare function analyze(code: string, file: string): Analysis;
36
-
36
+ //#endregion
37
+ //#region src/translate.d.ts
37
38
  interface TranslateRequest {
38
- sourceLocale: string;
39
- targetLocale: string;
40
- messages: Record<string, string>;
39
+ sourceLocale: string;
40
+ targetLocale: string;
41
+ messages: Record<string, string>;
41
42
  }
42
43
  type TranslateProvider = (request: TranslateRequest) => Promise<Record<string, string>>;
43
44
  interface TranslateOptions {
44
- locales?: string[];
45
- batchSize?: number;
46
- dryRun?: boolean;
45
+ locales?: string[];
46
+ batchSize?: number;
47
+ dryRun?: boolean;
47
48
  }
48
49
  interface TranslateResult {
49
- translated: Record<string, string[]>;
50
- invalid: Record<string, string[]>;
51
- pending: Record<string, string[]>;
50
+ translated: Record<string, string[]>;
51
+ invalid: Record<string, string[]>;
52
+ pending: Record<string, string[]>;
52
53
  }
53
54
  declare function translateCatalogs(cfg: ResolvedConfig, catalogs: Catalogs, provider: TranslateProvider, options?: TranslateOptions): Promise<TranslateResult>;
54
55
  declare function structureMatches(source: string, translated: string): boolean;
55
-
56
+ //#endregion
57
+ //#region src/config.d.ts
56
58
  interface TranslateConfig {
57
- provider?: 'claude' | TranslateProvider;
58
- model?: string;
59
- batchSize?: number;
59
+ provider?: 'claude' | TranslateProvider;
60
+ model?: string;
61
+ batchSize?: number;
60
62
  }
61
63
  interface RenderConfig {
62
- links?: Record<string, RichLink>;
64
+ links?: Record<string, RichLink>;
63
65
  }
64
66
  interface VerbalyConfig {
65
- root?: string;
66
- dir?: string;
67
- sourceLocale?: string;
68
- locales?: string[];
69
- include?: string[];
70
- exclude?: string[];
71
- translate?: TranslateConfig;
72
- render?: RenderConfig;
67
+ root?: string;
68
+ dir?: string;
69
+ sourceLocale?: string;
70
+ locales?: string[];
71
+ include?: string[];
72
+ exclude?: string[];
73
+ translate?: TranslateConfig;
74
+ render?: RenderConfig;
73
75
  }
74
76
  interface ResolvedConfig {
75
- root: string;
76
- dir: string;
77
- sourceLocale: string;
78
- locales: string[];
79
- include: string[];
80
- exclude: string[];
81
- translate: TranslateConfig;
82
- render: RenderConfig;
77
+ root: string;
78
+ dir: string;
79
+ sourceLocale: string;
80
+ locales: string[];
81
+ include: string[];
82
+ exclude: string[];
83
+ translate: TranslateConfig;
84
+ render: RenderConfig;
83
85
  }
84
86
  declare function resolveConfig(config?: VerbalyConfig): ResolvedConfig;
87
+ declare function findConfigFile(root: string): string | undefined;
85
88
  declare function loadConfigFile(root: string): Promise<VerbalyConfig>;
86
89
  declare function loadConfig(root: string, overrides?: VerbalyConfig): Promise<ResolvedConfig>;
87
-
90
+ //#endregion
91
+ //#region src/catalog.d.ts
88
92
  type Catalog = Record<string, string>;
89
93
  type Catalogs = Record<string, Catalog>;
90
94
  declare function catalogPath(cfg: ResolvedConfig, locale: string): string;
@@ -92,94 +96,135 @@ declare function readCatalog(cfg: ResolvedConfig, locale: string): Catalog;
92
96
  declare function loadCatalogs(cfg: ResolvedConfig): Catalogs;
93
97
  declare function serializeCatalog(catalog: Catalog): string;
94
98
  declare function writeCatalog(cfg: ResolvedConfig, locale: string, catalog: Catalog): string;
95
-
99
+ //#endregion
100
+ //#region src/registry.d.ts
96
101
  declare class MessageRegistry {
97
- private files;
98
- update(file: string, analysis: Analysis): void;
99
- remove(file: string): void;
100
- messages(): Map<string, TaggedMessage>;
101
- usedKeys(): Map<string, string[]>;
102
- }
103
-
102
+ private files;
103
+ update(file: string, analysis: Analysis): void;
104
+ remove(file: string): void;
105
+ messages(): Map<string, TaggedMessage>;
106
+ usedKeys(): Map<string, string[]>;
107
+ }
108
+ //#endregion
109
+ //#region src/check.d.ts
104
110
  interface MissingEntry {
105
- locale: string;
106
- key: string;
107
- source?: string;
111
+ locale: string;
112
+ key: string;
113
+ source?: string;
108
114
  }
109
115
  interface UnknownEntry {
110
- key: string;
111
- files: string[];
116
+ key: string;
117
+ files: string[];
112
118
  }
113
119
  interface CheckResult {
114
- ok: boolean;
115
- missing: MissingEntry[];
116
- unknown: UnknownEntry[];
120
+ ok: boolean;
121
+ missing: MissingEntry[];
122
+ unknown: UnknownEntry[];
117
123
  }
118
124
  declare function check(cfg: ResolvedConfig, catalogs: Catalogs, registry: MessageRegistry): CheckResult;
119
125
  declare function formatCheckResult(result: CheckResult): string;
120
-
126
+ //#endregion
127
+ //#region src/codegen.d.ts
121
128
  declare const VIRTUAL_ID = "virtual:verbaly";
122
129
  declare function generateRuntimeModule(cfg: ResolvedConfig): string;
123
130
  declare function generateLocaleModule(catalog: Catalog): string;
124
131
  declare function generateDts(entries: Map<string, string>): string;
125
132
  declare function writeDts(cfg: ResolvedConfig, entries: Map<string, string>): void;
126
-
133
+ //#endregion
134
+ //#region src/doctor.d.ts
135
+ interface DoctorEntry {
136
+ level: 'ok' | 'warn' | 'error';
137
+ check: string;
138
+ message: string;
139
+ fix?: string;
140
+ }
141
+ interface DoctorResult {
142
+ ok: boolean;
143
+ entries: DoctorEntry[];
144
+ }
145
+ declare function doctor(cfg: ResolvedConfig): Promise<DoctorResult>;
146
+ //#endregion
147
+ //#region src/extract.d.ts
127
148
  declare function extractProject(cfg: ResolvedConfig): Promise<MessageRegistry>;
128
149
  interface SyncResult {
129
- added: Record<string, string[]>;
150
+ added: Record<string, string[]>;
130
151
  }
131
152
  declare function syncCatalogs(cfg: ResolvedConfig, catalogs: Catalogs, registry: MessageRegistry): SyncResult;
132
153
  declare function pruneCatalogs(cfg: ResolvedConfig, catalogs: Catalogs, registry: MessageRegistry): Record<string, string[]>;
133
-
154
+ //#endregion
155
+ //#region src/init.d.ts
156
+ interface InitOptions {
157
+ root?: string;
158
+ dir?: string;
159
+ sourceLocale?: string;
160
+ locales?: string[];
161
+ }
162
+ interface InitResult {
163
+ created: string[];
164
+ skipped: string[];
165
+ bundler: 'vite' | 'webpack' | 'rollup' | 'rspack' | 'esbuild' | undefined;
166
+ configFile: string;
167
+ next: string[];
168
+ }
169
+ declare function detectBundler(root: string): InitResult['bundler'];
170
+ declare function init(options?: InitOptions): InitResult;
171
+ //#endregion
172
+ //#region src/key.d.ts
134
173
  declare function stableKey(message: string): string;
135
-
174
+ //#endregion
175
+ //#region src/params.d.ts
136
176
  type ParamType = 'number' | 'string' | 'date' | 'unknown';
137
177
  declare function collectParams(message: string): Map<string, Set<ParamType>>;
138
178
  declare function renderParamType(types: Set<ParamType>): string;
139
-
179
+ //#endregion
180
+ //#region src/providers/claude.d.ts
140
181
  interface ClaudeProviderOptions {
141
- model?: string;
142
- apiKey?: string;
143
- maxTokens?: number;
182
+ model?: string;
183
+ apiKey?: string;
184
+ maxTokens?: number;
144
185
  }
145
186
  declare function claudeProvider(options?: ClaudeProviderOptions): TranslateProvider;
146
-
187
+ //#endregion
188
+ //#region src/pseudo.d.ts
147
189
  declare const PSEUDO_LOCALE = "en-XA";
148
190
  declare function pseudoLocalize(message: string): string;
149
191
  declare function pseudoCatalogs(cfg: ResolvedConfig, catalogs: Catalogs, locale?: string): string[];
150
-
192
+ //#endregion
193
+ //#region src/render.d.ts
151
194
  interface RenderHtmlOptions {
152
- locale: string;
153
- catalogs: Catalogs;
154
- sourceLocale?: string;
155
- attribute?: string;
156
- richTags?: string[];
157
- richLinks?: Record<string, RichLink>;
158
- setLang?: boolean;
195
+ locale: string;
196
+ catalogs: Catalogs;
197
+ sourceLocale?: string;
198
+ attribute?: string;
199
+ richTags?: string[];
200
+ richLinks?: Record<string, RichLink>;
201
+ setLang?: boolean;
159
202
  }
160
203
  interface RenderHtmlResult {
161
- html: string;
162
- missing: string[];
204
+ html: string;
205
+ missing: string[];
163
206
  }
164
207
  declare function renderHtml(html: string, options: RenderHtmlOptions): RenderHtmlResult;
165
208
  interface RenderSiteOptions {
166
- site?: string;
167
- locales?: string[];
168
- attribute?: string;
169
- richTags?: string[];
170
- richLinks?: Record<string, RichLink>;
209
+ site?: string;
210
+ locales?: string[];
211
+ attribute?: string;
212
+ richTags?: string[];
213
+ richLinks?: Record<string, RichLink>;
171
214
  }
172
215
  interface RenderSiteResult {
173
- files: number;
174
- locales: string[];
175
- missing: Record<string, string[]>;
216
+ files: number;
217
+ locales: string[];
218
+ missing: Record<string, string[]>;
176
219
  }
177
220
  declare function renderSite(cfg: ResolvedConfig, options?: RenderSiteOptions): Promise<RenderSiteResult>;
178
-
221
+ //#endregion
222
+ //#region src/transform.d.ts
179
223
  interface TransformResult {
180
- code: string;
181
- map: ReturnType<MagicString['generateMap']>;
224
+ code: string;
225
+ map: ReturnType<MagicString['generateMap']>;
182
226
  }
183
227
  declare function transformCode(code: string, file: string, analysis?: Analysis): TransformResult | null;
184
-
185
- export { type Analysis, type Catalog, type Catalogs, type CheckResult, type ClaudeProviderOptions, MessageRegistry, type MissingEntry, PSEUDO_LOCALE, type ParamType, type RenderConfig, type RenderHtmlOptions, type RenderHtmlResult, type RenderSiteOptions, type RenderSiteResult, type ResolvedConfig, 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, analyze, catalogPath, check, claudeProvider, collectParams, extractProject, formatCheckResult, generateDts, generateLocaleModule, generateRuntimeModule, loadCatalogs, loadConfig, loadConfigFile, pruneCatalogs, pseudoCatalogs, pseudoLocalize, readCatalog, renderHtml, renderParamType, renderSite, resolveConfig, serializeCatalog, stableKey, structureMatches, syncCatalogs, transformCode, translateCatalogs, writeCatalog, writeDts };
228
+ //#endregion
229
+ export { type Analysis, type Catalog, type Catalogs, type CheckResult, type ClaudeProviderOptions, type DoctorEntry, type DoctorResult, type InitOptions, type InitResult, MessageRegistry, type MissingEntry, PSEUDO_LOCALE, type ParamType, type RenderConfig, type RenderHtmlOptions, type RenderHtmlResult, type RenderSiteOptions, type RenderSiteResult, type ResolvedConfig, 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, analyze, catalogPath, check, claudeProvider, collectParams, detectBundler, doctor, extractProject, findConfigFile, formatCheckResult, generateDts, generateLocaleModule, generateRuntimeModule, init, loadCatalogs, loadConfig, loadConfigFile, pruneCatalogs, pseudoCatalogs, pseudoLocalize, readCatalog, renderHtml, renderParamType, renderSite, resolveConfig, serializeCatalog, stableKey, structureMatches, syncCatalogs, transformCode, translateCatalogs, writeCatalog, writeDts };
230
+ //# sourceMappingURL=index.d.ts.map