@verbaly/compiler 0.11.0 → 0.12.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,93 @@
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;
85
87
  declare function loadConfigFile(root: string): Promise<VerbalyConfig>;
86
88
  declare function loadConfig(root: string, overrides?: VerbalyConfig): Promise<ResolvedConfig>;
87
-
89
+ //#endregion
90
+ //#region src/catalog.d.ts
88
91
  type Catalog = Record<string, string>;
89
92
  type Catalogs = Record<string, Catalog>;
90
93
  declare function catalogPath(cfg: ResolvedConfig, locale: string): string;
@@ -92,94 +95,122 @@ declare function readCatalog(cfg: ResolvedConfig, locale: string): Catalog;
92
95
  declare function loadCatalogs(cfg: ResolvedConfig): Catalogs;
93
96
  declare function serializeCatalog(catalog: Catalog): string;
94
97
  declare function writeCatalog(cfg: ResolvedConfig, locale: string, catalog: Catalog): string;
95
-
98
+ //#endregion
99
+ //#region src/registry.d.ts
96
100
  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
-
101
+ private files;
102
+ update(file: string, analysis: Analysis): void;
103
+ remove(file: string): void;
104
+ messages(): Map<string, TaggedMessage>;
105
+ usedKeys(): Map<string, string[]>;
106
+ }
107
+ //#endregion
108
+ //#region src/check.d.ts
104
109
  interface MissingEntry {
105
- locale: string;
106
- key: string;
107
- source?: string;
110
+ locale: string;
111
+ key: string;
112
+ source?: string;
108
113
  }
109
114
  interface UnknownEntry {
110
- key: string;
111
- files: string[];
115
+ key: string;
116
+ files: string[];
112
117
  }
113
118
  interface CheckResult {
114
- ok: boolean;
115
- missing: MissingEntry[];
116
- unknown: UnknownEntry[];
119
+ ok: boolean;
120
+ missing: MissingEntry[];
121
+ unknown: UnknownEntry[];
117
122
  }
118
123
  declare function check(cfg: ResolvedConfig, catalogs: Catalogs, registry: MessageRegistry): CheckResult;
119
124
  declare function formatCheckResult(result: CheckResult): string;
120
-
125
+ //#endregion
126
+ //#region src/codegen.d.ts
121
127
  declare const VIRTUAL_ID = "virtual:verbaly";
122
128
  declare function generateRuntimeModule(cfg: ResolvedConfig): string;
123
129
  declare function generateLocaleModule(catalog: Catalog): string;
124
130
  declare function generateDts(entries: Map<string, string>): string;
125
131
  declare function writeDts(cfg: ResolvedConfig, entries: Map<string, string>): void;
126
-
132
+ //#endregion
133
+ //#region src/extract.d.ts
127
134
  declare function extractProject(cfg: ResolvedConfig): Promise<MessageRegistry>;
128
135
  interface SyncResult {
129
- added: Record<string, string[]>;
136
+ added: Record<string, string[]>;
130
137
  }
131
138
  declare function syncCatalogs(cfg: ResolvedConfig, catalogs: Catalogs, registry: MessageRegistry): SyncResult;
132
139
  declare function pruneCatalogs(cfg: ResolvedConfig, catalogs: Catalogs, registry: MessageRegistry): Record<string, string[]>;
133
-
140
+ //#endregion
141
+ //#region src/init.d.ts
142
+ interface InitOptions {
143
+ root?: string;
144
+ dir?: string;
145
+ sourceLocale?: string;
146
+ locales?: string[];
147
+ }
148
+ interface InitResult {
149
+ created: string[];
150
+ skipped: string[];
151
+ bundler: 'vite' | 'webpack' | 'rollup' | 'rspack' | 'esbuild' | undefined;
152
+ configFile: string;
153
+ next: string[];
154
+ }
155
+ declare function detectBundler(root: string): InitResult['bundler'];
156
+ declare function init(options?: InitOptions): InitResult;
157
+ //#endregion
158
+ //#region src/key.d.ts
134
159
  declare function stableKey(message: string): string;
135
-
160
+ //#endregion
161
+ //#region src/params.d.ts
136
162
  type ParamType = 'number' | 'string' | 'date' | 'unknown';
137
163
  declare function collectParams(message: string): Map<string, Set<ParamType>>;
138
164
  declare function renderParamType(types: Set<ParamType>): string;
139
-
165
+ //#endregion
166
+ //#region src/providers/claude.d.ts
140
167
  interface ClaudeProviderOptions {
141
- model?: string;
142
- apiKey?: string;
143
- maxTokens?: number;
168
+ model?: string;
169
+ apiKey?: string;
170
+ maxTokens?: number;
144
171
  }
145
172
  declare function claudeProvider(options?: ClaudeProviderOptions): TranslateProvider;
146
-
173
+ //#endregion
174
+ //#region src/pseudo.d.ts
147
175
  declare const PSEUDO_LOCALE = "en-XA";
148
176
  declare function pseudoLocalize(message: string): string;
149
177
  declare function pseudoCatalogs(cfg: ResolvedConfig, catalogs: Catalogs, locale?: string): string[];
150
-
178
+ //#endregion
179
+ //#region src/render.d.ts
151
180
  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;
181
+ locale: string;
182
+ catalogs: Catalogs;
183
+ sourceLocale?: string;
184
+ attribute?: string;
185
+ richTags?: string[];
186
+ richLinks?: Record<string, RichLink>;
187
+ setLang?: boolean;
159
188
  }
160
189
  interface RenderHtmlResult {
161
- html: string;
162
- missing: string[];
190
+ html: string;
191
+ missing: string[];
163
192
  }
164
193
  declare function renderHtml(html: string, options: RenderHtmlOptions): RenderHtmlResult;
165
194
  interface RenderSiteOptions {
166
- site?: string;
167
- locales?: string[];
168
- attribute?: string;
169
- richTags?: string[];
170
- richLinks?: Record<string, RichLink>;
195
+ site?: string;
196
+ locales?: string[];
197
+ attribute?: string;
198
+ richTags?: string[];
199
+ richLinks?: Record<string, RichLink>;
171
200
  }
172
201
  interface RenderSiteResult {
173
- files: number;
174
- locales: string[];
175
- missing: Record<string, string[]>;
202
+ files: number;
203
+ locales: string[];
204
+ missing: Record<string, string[]>;
176
205
  }
177
206
  declare function renderSite(cfg: ResolvedConfig, options?: RenderSiteOptions): Promise<RenderSiteResult>;
178
-
207
+ //#endregion
208
+ //#region src/transform.d.ts
179
209
  interface TransformResult {
180
- code: string;
181
- map: ReturnType<MagicString['generateMap']>;
210
+ code: string;
211
+ map: ReturnType<MagicString['generateMap']>;
182
212
  }
183
213
  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 };
214
+ //#endregion
215
+ export { type Analysis, type Catalog, type Catalogs, type CheckResult, type ClaudeProviderOptions, 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, extractProject, formatCheckResult, generateDts, generateLocaleModule, generateRuntimeModule, init, loadCatalogs, loadConfig, loadConfigFile, pruneCatalogs, pseudoCatalogs, pseudoLocalize, readCatalog, renderHtml, renderParamType, renderSite, resolveConfig, serializeCatalog, stableKey, structureMatches, syncCatalogs, transformCode, translateCatalogs, writeCatalog, writeDts };
216
+ //# sourceMappingURL=index.d.ts.map