@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/LICENSE +21 -201
- package/README.md +65 -53
- package/dist/claude-BhP-eK5E.js +53 -0
- package/dist/claude-BhP-eK5E.js.map +1 -0
- package/dist/cli.js +1018 -955
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +138 -99
- package/dist/index.js +972 -949
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/dist/claude-RQATA6OI.js +0 -63
- package/dist/claude-RQATA6OI.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,84 +1,93 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { RichLink } from "verbaly";
|
|
2
|
+
import MagicString from "magic-string";
|
|
3
|
+
//#region src/analyze.d.ts
|
|
3
4
|
interface TaggedParam {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
name: string;
|
|
6
|
+
start: number;
|
|
7
|
+
end: number;
|
|
7
8
|
}
|
|
8
9
|
interface TransComponent {
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
name: string;
|
|
11
|
+
source: string;
|
|
11
12
|
}
|
|
12
13
|
interface TaggedMessage {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
28
|
-
|
|
28
|
+
key: string;
|
|
29
|
+
file: string;
|
|
29
30
|
}
|
|
30
31
|
interface Analysis {
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
locales?: string[];
|
|
46
|
+
batchSize?: number;
|
|
47
|
+
dryRun?: boolean;
|
|
46
48
|
}
|
|
47
49
|
interface TranslateResult {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
|
|
100
|
-
|
|
101
|
-
|
|
110
|
+
locale: string;
|
|
111
|
+
key: string;
|
|
112
|
+
source?: string;
|
|
102
113
|
}
|
|
103
114
|
interface UnknownEntry {
|
|
104
|
-
|
|
105
|
-
|
|
115
|
+
key: string;
|
|
116
|
+
files: string[];
|
|
106
117
|
}
|
|
107
118
|
interface CheckResult {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
-
|
|
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
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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
|
-
|
|
155
|
-
|
|
190
|
+
html: string;
|
|
191
|
+
missing: string[];
|
|
156
192
|
}
|
|
157
193
|
declare function renderHtml(html: string, options: RenderHtmlOptions): RenderHtmlResult;
|
|
158
194
|
interface RenderSiteOptions {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
195
|
+
site?: string;
|
|
196
|
+
locales?: string[];
|
|
197
|
+
attribute?: string;
|
|
198
|
+
richTags?: string[];
|
|
199
|
+
richLinks?: Record<string, RichLink>;
|
|
163
200
|
}
|
|
164
201
|
interface RenderSiteResult {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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
|
-
|
|
173
|
-
|
|
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
|