@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/README.md +2 -1
- package/dist/claude-BhP-eK5E.js +53 -0
- package/dist/claude-BhP-eK5E.js.map +1 -0
- package/dist/cli.js +1017 -973
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +136 -105
- package/dist/index.js +970 -966
- 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,93 @@
|
|
|
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;
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
110
|
+
locale: string;
|
|
111
|
+
key: string;
|
|
112
|
+
source?: string;
|
|
108
113
|
}
|
|
109
114
|
interface UnknownEntry {
|
|
110
|
-
|
|
111
|
-
|
|
115
|
+
key: string;
|
|
116
|
+
files: string[];
|
|
112
117
|
}
|
|
113
118
|
interface CheckResult {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
-
|
|
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
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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
|
-
|
|
162
|
-
|
|
190
|
+
html: string;
|
|
191
|
+
missing: string[];
|
|
163
192
|
}
|
|
164
193
|
declare function renderHtml(html: string, options: RenderHtmlOptions): RenderHtmlResult;
|
|
165
194
|
interface RenderSiteOptions {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
195
|
+
site?: string;
|
|
196
|
+
locales?: string[];
|
|
197
|
+
attribute?: string;
|
|
198
|
+
richTags?: string[];
|
|
199
|
+
richLinks?: Record<string, RichLink>;
|
|
171
200
|
}
|
|
172
201
|
interface RenderSiteResult {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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
|
-
|
|
181
|
-
|
|
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
|