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