@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/README.md +3 -1
- package/dist/claude-Bi_Ex2hm.js +53 -0
- package/dist/claude-Bi_Ex2hm.js.map +1 -0
- package/dist/cli.js +1150 -975
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +150 -105
- package/dist/index.js +1080 -968
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/claude-XSRCRBAQ.js +0 -63
- package/dist/claude-XSRCRBAQ.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,90 +1,94 @@
|
|
|
1
|
-
import { RichLink } from
|
|
2
|
-
import MagicString from
|
|
3
|
-
|
|
1
|
+
import { RichLink } from "verbaly";
|
|
2
|
+
import MagicString from "magic-string";
|
|
3
|
+
//#region src/analyze.d.ts
|
|
4
4
|
interface TaggedParam {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
name: string;
|
|
6
|
+
start: number;
|
|
7
|
+
end: number;
|
|
8
8
|
}
|
|
9
9
|
interface TransComponent {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
name: string;
|
|
11
|
+
source: string;
|
|
12
12
|
}
|
|
13
13
|
interface TaggedMessage {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
29
|
-
|
|
28
|
+
key: string;
|
|
29
|
+
file: string;
|
|
30
30
|
}
|
|
31
31
|
interface Analysis {
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
locales?: string[];
|
|
46
|
+
batchSize?: number;
|
|
47
|
+
dryRun?: boolean;
|
|
47
48
|
}
|
|
48
49
|
interface TranslateResult {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
provider?: 'claude' | TranslateProvider;
|
|
60
|
+
model?: string;
|
|
61
|
+
batchSize?: number;
|
|
60
62
|
}
|
|
61
63
|
interface RenderConfig {
|
|
62
|
-
|
|
64
|
+
links?: Record<string, RichLink>;
|
|
63
65
|
}
|
|
64
66
|
interface VerbalyConfig {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
111
|
+
locale: string;
|
|
112
|
+
key: string;
|
|
113
|
+
source?: string;
|
|
108
114
|
}
|
|
109
115
|
interface UnknownEntry {
|
|
110
|
-
|
|
111
|
-
|
|
116
|
+
key: string;
|
|
117
|
+
files: string[];
|
|
112
118
|
}
|
|
113
119
|
interface CheckResult {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
-
|
|
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
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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
|
-
|
|
162
|
-
|
|
204
|
+
html: string;
|
|
205
|
+
missing: string[];
|
|
163
206
|
}
|
|
164
207
|
declare function renderHtml(html: string, options: RenderHtmlOptions): RenderHtmlResult;
|
|
165
208
|
interface RenderSiteOptions {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
209
|
+
site?: string;
|
|
210
|
+
locales?: string[];
|
|
211
|
+
attribute?: string;
|
|
212
|
+
richTags?: string[];
|
|
213
|
+
richLinks?: Record<string, RichLink>;
|
|
171
214
|
}
|
|
172
215
|
interface RenderSiteResult {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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
|
-
|
|
181
|
-
|
|
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
|