@verbaly/compiler 0.76.0 → 0.77.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.
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ct as isModuleNotFound, st as counted } from "./run-
|
|
2
|
-
|
|
1
|
+
import { ct as isModuleNotFound, st as counted } from "./run-D9RNsrMs.js";
|
|
2
|
+
// src/providers/claude.ts
|
|
3
3
|
const DEFAULT_MODEL = "claude-sonnet-5-5";
|
|
4
4
|
const FALLBACK_MODELS = /* @__PURE__ */ new Set([
|
|
5
5
|
"claude-sonnet-5-5",
|
|
@@ -88,5 +88,4 @@ async function loadSdk(load = () => import("@anthropic-ai/sdk")) {
|
|
|
88
88
|
throw error;
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
//#endregion
|
|
92
91
|
export { claudeProvider };
|
package/dist/cli.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { n as runCli, t as formatCliError } from "./run-
|
|
3
|
-
|
|
2
|
+
import { n as runCli, t as formatCliError } from "./run-D9RNsrMs.js";
|
|
3
|
+
// src/cli.ts
|
|
4
4
|
runCli().catch((error) => {
|
|
5
5
|
console.error(formatCliError(error));
|
|
6
6
|
process.exitCode = 1;
|
|
7
7
|
});
|
|
8
|
-
//#endregion
|
|
9
8
|
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { RichLink, Routing, TrailingSlash } from "verbaly";
|
|
2
2
|
import MagicString from "magic-string";
|
|
3
|
-
//#region src/host.d.ts
|
|
4
3
|
type Host = 'nuxt' | 'next' | 'sveltekit' | 'astro' | 'vite' | 'webpack' | 'rspack' | 'rollup' | 'esbuild';
|
|
5
|
-
//#endregion
|
|
6
|
-
//#region src/catalog.d.ts
|
|
7
4
|
type Catalog = Record<string, string>;
|
|
8
5
|
type Catalogs = Record<string, Catalog>;
|
|
9
6
|
export declare function readCatalog(cfg: ResolvedConfig, locale: string): Catalog;
|
|
@@ -12,8 +9,6 @@ export declare function loadCatalogs(cfg: ResolvedConfig): Catalogs;
|
|
|
12
9
|
export declare function writeCatalog(cfg: ResolvedConfig, locale: string, catalog: Catalog): string;
|
|
13
10
|
export declare function needsIcu(catalogs: Catalogs): boolean;
|
|
14
11
|
export declare function needsRelative(catalogs: Catalogs): boolean;
|
|
15
|
-
//#endregion
|
|
16
|
-
//#region src/analyze.d.ts
|
|
17
12
|
interface TaggedParam {
|
|
18
13
|
name: string;
|
|
19
14
|
start: number;
|
|
@@ -62,8 +57,6 @@ interface Analysis {
|
|
|
62
57
|
missed: MissedCall[];
|
|
63
58
|
parseError?: string;
|
|
64
59
|
}
|
|
65
|
-
//#endregion
|
|
66
|
-
//#region src/registry.d.ts
|
|
67
60
|
interface Collision {
|
|
68
61
|
key: string;
|
|
69
62
|
kept: TaggedMessage;
|
|
@@ -85,8 +78,6 @@ export declare class MessageRegistry {
|
|
|
85
78
|
origins(): Map<string, string[]>;
|
|
86
79
|
private inOrder;
|
|
87
80
|
}
|
|
88
|
-
//#endregion
|
|
89
|
-
//#region src/translate.d.ts
|
|
90
81
|
interface TranslateRequest {
|
|
91
82
|
sourceLocale: string;
|
|
92
83
|
targetLocale: string;
|
|
@@ -143,8 +134,6 @@ interface WriteDraftsOptions {
|
|
|
143
134
|
export declare function writeDrafts(cfg: ResolvedConfig, locale: string, entries: DraftEntry[], options?: WriteDraftsOptions): WriteDraftsResult;
|
|
144
135
|
export declare function formatTranslateFailures(failed: TranslateFailure[]): string[];
|
|
145
136
|
export declare function resolveProvider(cfg: ResolvedConfig, model?: string): Promise<TranslateProvider>;
|
|
146
|
-
//#endregion
|
|
147
|
-
//#region src/config.d.ts
|
|
148
137
|
type GlossaryEntry = string | Record<string, string>;
|
|
149
138
|
interface TranslateConfig {
|
|
150
139
|
provider?: 'claude' | TranslateProvider;
|
|
@@ -214,11 +203,7 @@ export declare function targetLocales(cfg: ResolvedConfig, override?: string[]):
|
|
|
214
203
|
export declare function loadConfig(root: string, overrides?: VerbalyConfig, from?: {
|
|
215
204
|
plugin?: boolean;
|
|
216
205
|
}): Promise<ResolvedConfig>;
|
|
217
|
-
//#endregion
|
|
218
|
-
//#region src/bundle.d.ts
|
|
219
206
|
export declare function clientCatalogs(cfg: ResolvedConfig, catalogs: Catalogs): Catalogs;
|
|
220
|
-
//#endregion
|
|
221
|
-
//#region src/extract.d.ts
|
|
222
207
|
export declare function extractProject(cfg: ResolvedConfig, options?: {
|
|
223
208
|
keepSource?: boolean;
|
|
224
209
|
}): Promise<MessageRegistry>;
|
|
@@ -236,8 +221,6 @@ export declare function shippedCatalogs(cfg: ResolvedConfig, catalogs: Catalogs,
|
|
|
236
221
|
newKeys?: boolean;
|
|
237
222
|
}): Catalogs;
|
|
238
223
|
export declare function pruneCatalogs(cfg: ResolvedConfig, catalogs: Catalogs, registry: MessageRegistry): Record<string, string[]>;
|
|
239
|
-
//#endregion
|
|
240
|
-
//#region src/state.d.ts
|
|
241
224
|
export declare const STATE_FILE = "verbaly.lock";
|
|
242
225
|
type Drafts = Record<string, string[]>;
|
|
243
226
|
type Fingerprints = Record<string, Record<string, string>>;
|
|
@@ -278,8 +261,6 @@ export declare function effectiveDrafts(drafts: Drafts, catalogs: Catalogs): Dra
|
|
|
278
261
|
export declare function markDrafts(drafts: Drafts, locale: string, keys: string[]): void;
|
|
279
262
|
export declare function clearDrafts(drafts: Drafts, locale: string, keys?: string[]): void;
|
|
280
263
|
export declare function outdatedTranslations(cfg: ResolvedConfig, catalogs: Catalogs, fingerprints: Fingerprints): OutdatedEntry[];
|
|
281
|
-
//#endregion
|
|
282
|
-
//#region src/findings.d.ts
|
|
283
264
|
interface SourceSite {
|
|
284
265
|
file: string;
|
|
285
266
|
line?: number;
|
|
@@ -337,8 +318,6 @@ interface DevReporter {
|
|
|
337
318
|
report(channel: string, findings: Finding[]): void;
|
|
338
319
|
}
|
|
339
320
|
export declare function createDevReporter(root: string, print?: (line: string) => void, cap?: number): DevReporter;
|
|
340
|
-
//#endregion
|
|
341
|
-
//#region src/project.d.ts
|
|
342
321
|
interface SyncProjectOptions {
|
|
343
322
|
prune?: boolean;
|
|
344
323
|
dryRun?: boolean;
|
|
@@ -362,11 +341,7 @@ interface SyncProjectResult {
|
|
|
362
341
|
stateProblem?: string;
|
|
363
342
|
}
|
|
364
343
|
export declare function syncProject(cfg: ResolvedConfig, options?: SyncProjectOptions): Promise<SyncProjectResult>;
|
|
365
|
-
//#endregion
|
|
366
|
-
//#region src/key.d.ts
|
|
367
344
|
export declare function stableKey(message: string): string;
|
|
368
|
-
//#endregion
|
|
369
|
-
//#region src/codegen.d.ts
|
|
370
345
|
interface RuntimeModuleOptions {
|
|
371
346
|
localeImport?: (locale: string) => string;
|
|
372
347
|
extraExports?: string;
|
|
@@ -386,17 +361,14 @@ interface DtsWrite {
|
|
|
386
361
|
changed: boolean;
|
|
387
362
|
}
|
|
388
363
|
export declare function writeDts(cfg: ResolvedConfig, catalog: Catalog, file?: string | false): DtsWrite | undefined;
|
|
389
|
-
//#endregion
|
|
390
|
-
//#region src/transform.d.ts
|
|
391
364
|
interface TransformResult {
|
|
392
365
|
code: string;
|
|
393
366
|
map: ReturnType<MagicString['generateMap']>;
|
|
394
367
|
}
|
|
395
368
|
export declare function transformCode(code: string, file: string, analysis?: Analysis): TransformResult | null;
|
|
396
|
-
//#endregion
|
|
397
|
-
//#region src/plugin.d.ts
|
|
398
369
|
interface PluginOptions extends VerbalyConfig {
|
|
399
370
|
failOnMissing?: boolean;
|
|
371
|
+
liveExtraction?: boolean;
|
|
400
372
|
}
|
|
401
373
|
export declare const RESOLVED_VIRTUAL_ID: string;
|
|
402
374
|
export declare const LOCALE_MODULE_PREFIX = "\0virtual:verbaly/locale/";
|
|
@@ -410,11 +382,7 @@ export declare function transformSource(code: string, id: string, registry: Mess
|
|
|
410
382
|
result: TransformResult | null;
|
|
411
383
|
};
|
|
412
384
|
export declare function runBuildGate(cfg: ResolvedConfig, registry: MessageRegistry, failOnMissing?: boolean): void;
|
|
413
|
-
//#endregion
|
|
414
|
-
//#region src/scope.d.ts
|
|
415
385
|
export declare function reportOutsideInclude(cfg: ResolvedConfig): Promise<void>;
|
|
416
|
-
//#endregion
|
|
417
|
-
//#region src/validate.d.ts
|
|
418
386
|
type IssueSeverity = 'error' | 'warning';
|
|
419
387
|
interface StructureIssue {
|
|
420
388
|
severity: IssueSeverity;
|
|
@@ -422,8 +390,6 @@ interface StructureIssue {
|
|
|
422
390
|
}
|
|
423
391
|
export declare function validateMessage(message: string, locale?: string): StructureIssue[];
|
|
424
392
|
export declare function validatePair(source: string, translated: string): StructureIssue[];
|
|
425
|
-
//#endregion
|
|
426
|
-
//#region src/check.d.ts
|
|
427
393
|
interface MissingEntry {
|
|
428
394
|
locale: string;
|
|
429
395
|
key: string;
|
|
@@ -465,12 +431,8 @@ interface CheckReportOptions {
|
|
|
465
431
|
outdatedFails?: boolean;
|
|
466
432
|
}
|
|
467
433
|
export declare function formatCheckWarnings(result: CheckResult, root?: string, options?: CheckReportOptions): string;
|
|
468
|
-
//#endregion
|
|
469
|
-
//#region src/drafts.d.ts
|
|
470
434
|
export declare function loadDrafts(cfg: ResolvedConfig): Drafts;
|
|
471
435
|
export declare function saveDrafts(cfg: ResolvedConfig, drafts: Drafts): void;
|
|
472
|
-
//#endregion
|
|
473
|
-
//#region src/status.d.ts
|
|
474
436
|
interface LocaleStatus {
|
|
475
437
|
locale: string;
|
|
476
438
|
translated: number;
|
|
@@ -486,22 +448,14 @@ interface StatusResult {
|
|
|
486
448
|
}
|
|
487
449
|
export declare function status(cfg: ResolvedConfig, catalogs: Catalogs, registry: MessageRegistry, drafts?: Drafts, fingerprints?: Fingerprints): StatusResult;
|
|
488
450
|
export declare function formatStatusResult(result: StatusResult): string;
|
|
489
|
-
//#endregion
|
|
490
|
-
//#region src/text.d.ts
|
|
491
451
|
export declare function counted(count: number, noun: string, many?: string): string;
|
|
492
|
-
//#endregion
|
|
493
|
-
//#region src/run.d.ts
|
|
494
452
|
export declare function formatCliError(error: unknown): string;
|
|
495
|
-
//#endregion
|
|
496
|
-
//#region src/watch.d.ts
|
|
497
453
|
interface TreeOptions {
|
|
498
454
|
keep?: string;
|
|
499
455
|
native?: boolean;
|
|
500
456
|
persistent?: boolean;
|
|
501
457
|
}
|
|
502
458
|
export declare function watchTree(root: string, options: TreeOptions, onFile: (file: string) => void): () => void;
|
|
503
|
-
//#endregion
|
|
504
|
-
//#region src/doctor.d.ts
|
|
505
459
|
interface DoctorEntry {
|
|
506
460
|
level: 'ok' | 'warn' | 'error';
|
|
507
461
|
check: string;
|
|
@@ -515,8 +469,6 @@ interface DoctorResult {
|
|
|
515
469
|
export declare function formatDoctorEntry(entry: DoctorEntry): string;
|
|
516
470
|
export declare function formatDoctorHealth(result: DoctorResult): string;
|
|
517
471
|
export declare function doctor(cfg: ResolvedConfig): Promise<DoctorResult>;
|
|
518
|
-
//#endregion
|
|
519
|
-
//#region src/init.d.ts
|
|
520
472
|
interface InitOptions {
|
|
521
473
|
root?: string;
|
|
522
474
|
dir?: string;
|
|
@@ -537,8 +489,6 @@ interface InitResult {
|
|
|
537
489
|
found?: string;
|
|
538
490
|
}
|
|
539
491
|
export declare function init(input?: InitOptions): Promise<InitResult>;
|
|
540
|
-
//#endregion
|
|
541
|
-
//#region src/wrap.d.ts
|
|
542
492
|
interface WrapEntry {
|
|
543
493
|
file: string;
|
|
544
494
|
line: number;
|
|
@@ -568,8 +518,6 @@ interface WrapOptions {
|
|
|
568
518
|
write?: boolean;
|
|
569
519
|
}
|
|
570
520
|
export declare function wrapProject(cfg: ResolvedConfig, options?: WrapOptions): Promise<WrapResult>;
|
|
571
|
-
//#endregion
|
|
572
|
-
//#region src/render.d.ts
|
|
573
521
|
interface RenderSiteOptions {
|
|
574
522
|
site?: string;
|
|
575
523
|
locales?: string[];
|
|
@@ -592,5 +540,4 @@ interface RenderSiteResult {
|
|
|
592
540
|
}
|
|
593
541
|
export declare function renderSite(cfg: ResolvedConfig, options?: RenderSiteOptions): Promise<RenderSiteResult>;
|
|
594
542
|
export declare function formatRenderWarnings(result: RenderSiteResult, sourceLocale: string): string[];
|
|
595
|
-
//#endregion
|
|
596
543
|
export type { BrokenEntry, BundleConfig, Catalog, Catalogs, CheckResult, CollisionEntry, DevReporter, DivergentEntry, DoctorEntry, DoctorResult, DraftEntry, Drafts, DtsOptions, ExtraEntry, Finding, Fingerprints, GlossaryEntry, Host, InitOptions, InitResult, IssueSeverity, LocaleStatus, MissingEntry, OutdatedEntry, PluginOptions, RedirectConfig, RenderConfig, RenderSiteOptions, RenderSiteResult, ResolvedConfig, RuntimeModuleOptions, SourceSite, State, StatusResult, StructureIssue, SyncProjectResult, SyncResult, TransformResult, TranslateConfig, TranslateFailure, TranslateOptions, TranslateProgress, TranslateProvider, TranslateRequest, TranslateResult, TranslationWrite, TreeOptions, UnknownEntry, VerbalyConfig, WrapBlocked, WrapEntry, WrapOptions, WrapResult, WrapSkip, WriteDraftsResult };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { $ as collectOrigins, A as formatCheckWarnings, B as recordTranslations, C as loadVirtualModule, D as transformCode, E as transformSource, F as effectiveDrafts, G as formatCollision, H as updateState, I as loadState, J as generateLocaleModule, K as formatFinding, L as markDrafts, M as syncProject, N as STATE_FILE, O as check, P as clearDrafts, Q as validatePair, R as outdatedTranslations, S as isTransformTarget, T as runBuildGate, U as collisionEntries, V as saveState, W as createDevReporter, X as writeDts, Y as generateRuntimeModule, Z as validateMessage, _ as reportOutsideInclude, _t as writeCatalog, a as formatRenderWarnings, at as MessageRegistry, b as SOURCE_FILE_RE, c as mergeTranslations, d as writeDrafts, dt as targetLocales, et as extractProject, f as doctor, ft as loadCatalogs, g as status, gt as readCatalog, h as formatStatusResult, ht as parseCatalog, i as watchTree, it as stableKey, j as init, k as formatCheckResult, l as resolveProvider, lt as loadConfig, m as formatDoctorHealth, mt as needsRelative, nt as shippedCatalogs, o as renderSite, ot as clientCatalogs, p as formatDoctorEntry, pt as needsIcu, q as generateDts, r as wrapProject, rt as syncCatalogs, s as formatTranslateFailures, st as counted, t as formatCliError, tt as pruneCatalogs, u as translateCatalogs, ut as resolveConfig, v as LOCALE_MODULE_PREFIX, w as resolveVirtualId, x as createSourceFilter, y as RESOLVED_VIRTUAL_ID, z as readState } from "./run-
|
|
2
|
-
|
|
1
|
+
import { $ as collectOrigins, A as formatCheckWarnings, B as recordTranslations, C as loadVirtualModule, D as transformCode, E as transformSource, F as effectiveDrafts, G as formatCollision, H as updateState, I as loadState, J as generateLocaleModule, K as formatFinding, L as markDrafts, M as syncProject, N as STATE_FILE, O as check, P as clearDrafts, Q as validatePair, R as outdatedTranslations, S as isTransformTarget, T as runBuildGate, U as collisionEntries, V as saveState, W as createDevReporter, X as writeDts, Y as generateRuntimeModule, Z as validateMessage, _ as reportOutsideInclude, _t as writeCatalog, a as formatRenderWarnings, at as MessageRegistry, b as SOURCE_FILE_RE, c as mergeTranslations, d as writeDrafts, dt as targetLocales, et as extractProject, f as doctor, ft as loadCatalogs, g as status, gt as readCatalog, h as formatStatusResult, ht as parseCatalog, i as watchTree, it as stableKey, j as init, k as formatCheckResult, l as resolveProvider, lt as loadConfig, m as formatDoctorHealth, mt as needsRelative, nt as shippedCatalogs, o as renderSite, ot as clientCatalogs, p as formatDoctorEntry, pt as needsIcu, q as generateDts, r as wrapProject, rt as syncCatalogs, s as formatTranslateFailures, st as counted, t as formatCliError, tt as pruneCatalogs, u as translateCatalogs, ut as resolveConfig, v as LOCALE_MODULE_PREFIX, w as resolveVirtualId, x as createSourceFilter, y as RESOLVED_VIRTUAL_ID, z as readState } from "./run-D9RNsrMs.js";
|
|
2
|
+
// src/drafts.ts
|
|
3
3
|
function loadDrafts(cfg) {
|
|
4
4
|
return loadState(cfg).drafts;
|
|
5
5
|
}
|
|
@@ -10,5 +10,4 @@ function saveDrafts(cfg, drafts) {
|
|
|
10
10
|
drafts
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
|
-
//#endregion
|
|
14
13
|
export { LOCALE_MODULE_PREFIX, MessageRegistry, RESOLVED_VIRTUAL_ID, SOURCE_FILE_RE, STATE_FILE, check, clearDrafts, clientCatalogs, collectOrigins, collisionEntries, counted, createDevReporter, createSourceFilter, doctor, effectiveDrafts, extractProject, formatCheckResult, formatCheckWarnings, formatCliError, formatCollision, formatDoctorEntry, formatDoctorHealth, formatFinding, formatRenderWarnings, formatStatusResult, formatTranslateFailures, generateDts, generateLocaleModule, generateRuntimeModule, init, isTransformTarget, loadCatalogs, loadConfig, loadDrafts, loadState, loadVirtualModule, markDrafts, mergeTranslations, needsIcu, needsRelative, outdatedTranslations, parseCatalog, pruneCatalogs, readCatalog, readState, recordTranslations, renderSite, reportOutsideInclude, resolveConfig, resolveProvider, resolveVirtualId, runBuildGate, saveDrafts, shippedCatalogs, stableKey, status, syncCatalogs, syncProject, targetLocales, transformCode, transformSource, translateCatalogs, updateState, validateMessage, validatePair, watchTree, wrapProject, writeCatalog, writeDrafts, writeDts };
|
|
@@ -10,7 +10,7 @@ import { applyEdits, modify, parse as parse$2 } from "jsonc-parser";
|
|
|
10
10
|
import picomatch from "picomatch";
|
|
11
11
|
import MagicString from "magic-string";
|
|
12
12
|
import { parseArgs } from "node:util";
|
|
13
|
-
|
|
13
|
+
// src/host.ts
|
|
14
14
|
const HOSTS = [
|
|
15
15
|
{
|
|
16
16
|
name: "nuxt",
|
|
@@ -145,14 +145,12 @@ function defaultTypesPath(root, host = detectHost(root)?.name) {
|
|
|
145
145
|
if (slot) return join(root, ...slot);
|
|
146
146
|
return existsSync(join(root, "src")) ? join(root, "src", "verbaly.d.ts") : join(root, "verbaly.d.ts");
|
|
147
147
|
}
|
|
148
|
-
|
|
149
|
-
//#region src/eol.ts
|
|
148
|
+
// src/eol.ts
|
|
150
149
|
function withLineEndings(text, existing) {
|
|
151
150
|
const first = existing?.indexOf("\n") ?? -1;
|
|
152
151
|
return first > 0 && existing[first - 1] === "\r" ? text.replace(/\r?\n/g, "\r\n") : text;
|
|
153
152
|
}
|
|
154
|
-
|
|
155
|
-
//#region src/catalog.ts
|
|
153
|
+
// src/catalog.ts
|
|
156
154
|
function emptyCatalog() {
|
|
157
155
|
return Object.create(null);
|
|
158
156
|
}
|
|
@@ -307,8 +305,7 @@ function someLeaf(tree, pattern) {
|
|
|
307
305
|
} else if (isTree(value) && someLeaf(value, pattern)) return true;
|
|
308
306
|
return false;
|
|
309
307
|
}
|
|
310
|
-
|
|
311
|
-
//#region src/pseudo.ts
|
|
308
|
+
// src/pseudo.ts
|
|
312
309
|
const PSEUDO_LOCALE = "en-XA";
|
|
313
310
|
const ACCENTS = {
|
|
314
311
|
a: "á",
|
|
@@ -426,8 +423,7 @@ function pseudoCatalogs(cfg, catalogs, locale = PSEUDO_LOCALE) {
|
|
|
426
423
|
catalogs[locale] = target;
|
|
427
424
|
return Object.keys(target).filter((key) => target[key]);
|
|
428
425
|
}
|
|
429
|
-
|
|
430
|
-
//#region src/warn.ts
|
|
426
|
+
// src/warn.ts
|
|
431
427
|
const warned = /* @__PURE__ */ new Set();
|
|
432
428
|
function warnOnce(message, dedupeKey = message) {
|
|
433
429
|
if (warned.has(dedupeKey)) return;
|
|
@@ -437,8 +433,7 @@ function warnOnce(message, dedupeKey = message) {
|
|
|
437
433
|
function warnParseError(file, message) {
|
|
438
434
|
warnOnce(`${file}: could not be parsed (${message}), its messages were not extracted`);
|
|
439
435
|
}
|
|
440
|
-
|
|
441
|
-
//#region src/config.ts
|
|
436
|
+
// src/config.ts
|
|
442
437
|
const SOURCE_EXTENSIONS = "{js,jsx,ts,tsx,mjs,mts,svelte,vue,astro}";
|
|
443
438
|
function resolveConfig(config = {}) {
|
|
444
439
|
const root = resolve(config.root ?? process.cwd());
|
|
@@ -555,8 +550,7 @@ function warnPluginOnly(root, file, overrides) {
|
|
|
555
550
|
function definedOnly(config) {
|
|
556
551
|
return Object.fromEntries(Object.entries(config).filter(([, value]) => value !== void 0));
|
|
557
552
|
}
|
|
558
|
-
|
|
559
|
-
//#region src/text.ts
|
|
553
|
+
// src/text.ts
|
|
560
554
|
function counted(count, noun, many = `${noun}s`) {
|
|
561
555
|
return `${count} ${count === 1 ? noun : many}`;
|
|
562
556
|
}
|
|
@@ -566,8 +560,7 @@ function truncate(text, max) {
|
|
|
566
560
|
function byCodeUnit(a, b) {
|
|
567
561
|
return a < b ? -1 : a > b ? 1 : 0;
|
|
568
562
|
}
|
|
569
|
-
|
|
570
|
-
//#region src/bundle.ts
|
|
563
|
+
// src/bundle.ts
|
|
571
564
|
function isExcluded(key, prefixes) {
|
|
572
565
|
return prefixes.some((prefix) => key === prefix || key.startsWith(`${prefix}.`));
|
|
573
566
|
}
|
|
@@ -610,8 +603,7 @@ function auditBundle(cfg, catalogs, registry) {
|
|
|
610
603
|
function formatBundleIssue(issue) {
|
|
611
604
|
return `bundle.exclude "${issue.prefix}" ${issue.problem}`;
|
|
612
605
|
}
|
|
613
|
-
|
|
614
|
-
//#region src/registry.ts
|
|
606
|
+
// src/registry.ts
|
|
615
607
|
var MessageRegistry = class {
|
|
616
608
|
files = /* @__PURE__ */ new Map();
|
|
617
609
|
update(file, analysis) {
|
|
@@ -684,13 +676,11 @@ var MessageRegistry = class {
|
|
|
684
676
|
function earlier(a, b) {
|
|
685
677
|
return a.file === b.file ? a.start < b.start : a.file < b.file;
|
|
686
678
|
}
|
|
687
|
-
|
|
688
|
-
//#region src/key.ts
|
|
679
|
+
// src/key.ts
|
|
689
680
|
function stableKey(message) {
|
|
690
681
|
return createHash("sha256").update(message).digest("base64url").slice(0, 8);
|
|
691
682
|
}
|
|
692
|
-
|
|
693
|
-
//#region src/analyze.ts
|
|
683
|
+
// src/analyze.ts
|
|
694
684
|
function parseErrorMessage(error) {
|
|
695
685
|
return error instanceof Error ? error.message : String(error);
|
|
696
686
|
}
|
|
@@ -1216,8 +1206,7 @@ function walk$1(node, visit) {
|
|
|
1216
1206
|
function isNode(value) {
|
|
1217
1207
|
return typeof value === "object" && value !== null && typeof value.type === "string";
|
|
1218
1208
|
}
|
|
1219
|
-
|
|
1220
|
-
//#region src/sfc.ts
|
|
1209
|
+
// src/sfc.ts
|
|
1221
1210
|
const SFC_FILE_RE = /\.(?:svelte|vue|astro)$/;
|
|
1222
1211
|
function analyzeFile(code, file) {
|
|
1223
1212
|
if (SFC_FILE_RE.test(file)) return analyzeSfc(code, file);
|
|
@@ -1407,8 +1396,7 @@ function stringEnd(code, start) {
|
|
|
1407
1396
|
else i += 1;
|
|
1408
1397
|
return code.length;
|
|
1409
1398
|
}
|
|
1410
|
-
|
|
1411
|
-
//#region src/extract.ts
|
|
1399
|
+
// src/extract.ts
|
|
1412
1400
|
const kept = /* @__PURE__ */ new WeakMap();
|
|
1413
1401
|
async function extractProject(cfg, options = {}) {
|
|
1414
1402
|
const files = await glob(cfg.include, {
|
|
@@ -1493,8 +1481,7 @@ function pruneCatalogs(cfg, catalogs, registry) {
|
|
|
1493
1481
|
}
|
|
1494
1482
|
return removed;
|
|
1495
1483
|
}
|
|
1496
|
-
|
|
1497
|
-
//#region src/validate.ts
|
|
1484
|
+
// src/validate.ts
|
|
1498
1485
|
let remembered = /* @__PURE__ */ new Map();
|
|
1499
1486
|
let reading;
|
|
1500
1487
|
function read(message) {
|
|
@@ -1705,8 +1692,7 @@ function reachableCategories(locale, ordinal) {
|
|
|
1705
1692
|
reachable.set(cacheKey, out);
|
|
1706
1693
|
return out;
|
|
1707
1694
|
}
|
|
1708
|
-
|
|
1709
|
-
//#region src/params.ts
|
|
1695
|
+
// src/params.ts
|
|
1710
1696
|
const NUMBER_FORMATS = /* @__PURE__ */ new Set([
|
|
1711
1697
|
"number",
|
|
1712
1698
|
"integer",
|
|
@@ -1748,8 +1734,7 @@ function renderParamType(types) {
|
|
|
1748
1734
|
]) members.add(m);
|
|
1749
1735
|
return [...members].join(" | ");
|
|
1750
1736
|
}
|
|
1751
|
-
|
|
1752
|
-
//#region src/tsconfig.ts
|
|
1737
|
+
// src/tsconfig.ts
|
|
1753
1738
|
function readTsconfig(root) {
|
|
1754
1739
|
const path = join(root, "tsconfig.json");
|
|
1755
1740
|
let text;
|
|
@@ -2076,8 +2061,7 @@ function removeRootDts(cfg, target) {
|
|
|
2076
2061
|
rmSync(old);
|
|
2077
2062
|
warnOnce(`the types live in ${relative(cfg.root, target).replaceAll("\\", "/")} now, so the verbaly.d.ts Verbaly wrote at the root was removed`);
|
|
2078
2063
|
}
|
|
2079
|
-
|
|
2080
|
-
//#region src/findings.ts
|
|
2064
|
+
// src/findings.ts
|
|
2081
2065
|
function siteOf(msg) {
|
|
2082
2066
|
return {
|
|
2083
2067
|
file: msg.file,
|
|
@@ -2198,8 +2182,7 @@ function createDevReporter(root, print = (line) => console.warn(`[verbaly] ${lin
|
|
|
2198
2182
|
if (fresh.length > cap) print(`and ${fresh.length - cap} more: \`npx verbaly doctor\` names them`);
|
|
2199
2183
|
} };
|
|
2200
2184
|
}
|
|
2201
|
-
|
|
2202
|
-
//#region src/state.ts
|
|
2185
|
+
// src/state.ts
|
|
2203
2186
|
const STATE_FILE = "verbaly.lock";
|
|
2204
2187
|
const LOCK_VERSION = 1;
|
|
2205
2188
|
const README = "Written by Verbaly: the source text each translation was made for, which ones are drafts, and which languages migrate converted. Commit it with your catalogs and never edit it: deleting it marks every draft as reviewed.";
|
|
@@ -2532,8 +2515,7 @@ function readFingerprints(value) {
|
|
|
2532
2515
|
}
|
|
2533
2516
|
return out;
|
|
2534
2517
|
}
|
|
2535
|
-
|
|
2536
|
-
//#region src/project.ts
|
|
2518
|
+
// src/project.ts
|
|
2537
2519
|
async function syncProject(cfg, options = {}) {
|
|
2538
2520
|
const registry = options.registry ?? await extractProject(cfg);
|
|
2539
2521
|
const catalogs = options.catalogs ?? loadCatalogs(cfg);
|
|
@@ -2589,8 +2571,7 @@ function confirmFromDisk(cfg, catalogs, registry) {
|
|
|
2589
2571
|
registry.update(file, analyzeFile(code, file));
|
|
2590
2572
|
}
|
|
2591
2573
|
}
|
|
2592
|
-
|
|
2593
|
-
//#region src/migrate.ts
|
|
2574
|
+
// src/migrate.ts
|
|
2594
2575
|
const KNOWN = [
|
|
2595
2576
|
"i18next",
|
|
2596
2577
|
"react-i18next",
|
|
@@ -2808,8 +2789,7 @@ function migrateCatalogs(cfg, options = {}) {
|
|
|
2808
2789
|
remembered
|
|
2809
2790
|
};
|
|
2810
2791
|
}
|
|
2811
|
-
|
|
2812
|
-
//#region src/tag.ts
|
|
2792
|
+
// src/tag.ts
|
|
2813
2793
|
function isLocaleTag(tag) {
|
|
2814
2794
|
try {
|
|
2815
2795
|
Intl.getCanonicalLocales(tag);
|
|
@@ -2827,8 +2807,7 @@ function projectLocale(tag, locales) {
|
|
|
2827
2807
|
const plain = (value) => value.replace(/_/g, "-").toLowerCase();
|
|
2828
2808
|
return locales.find((locale) => plain(locale) === plain(tag));
|
|
2829
2809
|
}
|
|
2830
|
-
|
|
2831
|
-
//#region src/init.ts
|
|
2810
|
+
// src/init.ts
|
|
2832
2811
|
const CATALOG_DIRS = [
|
|
2833
2812
|
"locales",
|
|
2834
2813
|
"src/locales",
|
|
@@ -2942,8 +2921,7 @@ async function init(input = {}) {
|
|
|
2942
2921
|
found
|
|
2943
2922
|
};
|
|
2944
2923
|
}
|
|
2945
|
-
|
|
2946
|
-
//#region src/check.ts
|
|
2924
|
+
// src/check.ts
|
|
2947
2925
|
function gatePasses(result) {
|
|
2948
2926
|
return result.missing.length === 0 && result.unknown.length === 0 && result.collisions.length === 0 && !result.broken.some((entry) => entry.severity === "error");
|
|
2949
2927
|
}
|
|
@@ -3175,8 +3153,7 @@ function escapeData(text) {
|
|
|
3175
3153
|
function escapeProperty(text) {
|
|
3176
3154
|
return escapeData(text).replaceAll(":", "%3A").replaceAll(",", "%2C");
|
|
3177
3155
|
}
|
|
3178
|
-
|
|
3179
|
-
//#region src/transform.ts
|
|
3156
|
+
// src/transform.ts
|
|
3180
3157
|
function quote(text, single) {
|
|
3181
3158
|
if (!single) return JSON.stringify(text);
|
|
3182
3159
|
return `'${text.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
|
|
@@ -3206,8 +3183,7 @@ function transformCode(code, file, analysis) {
|
|
|
3206
3183
|
map: s.generateMap({ hires: true })
|
|
3207
3184
|
};
|
|
3208
3185
|
}
|
|
3209
|
-
|
|
3210
|
-
//#region src/plugin.ts
|
|
3186
|
+
// src/plugin.ts
|
|
3211
3187
|
const RESOLVED_VIRTUAL_ID = "\0virtual:verbaly";
|
|
3212
3188
|
const LOCALE_MODULE_PREFIX = `${RESOLVED_VIRTUAL_ID}/locale/`;
|
|
3213
3189
|
const SOURCE_FILE_RE = /\.(?:[cm]?[jt]sx?|svelte|vue|astro)$/;
|
|
@@ -3289,8 +3265,7 @@ function buildFingerprints(cfg) {
|
|
|
3289
3265
|
if (problem) warnOnce(`${problem}, so outdated translations are not reported`, "gate:state");
|
|
3290
3266
|
return state.fingerprints;
|
|
3291
3267
|
}
|
|
3292
|
-
|
|
3293
|
-
//#region src/scope.ts
|
|
3268
|
+
// src/scope.ts
|
|
3294
3269
|
const TAGGED_HINT = /(?<![\w$.])\$?t(?:\.id\s*\([^)]*\))?\s*`/;
|
|
3295
3270
|
const NOT_SOURCE = [
|
|
3296
3271
|
"**/node_modules/**",
|
|
@@ -3356,8 +3331,7 @@ async function filesOutsideInclude(cfg) {
|
|
|
3356
3331
|
}
|
|
3357
3332
|
return found;
|
|
3358
3333
|
}
|
|
3359
|
-
|
|
3360
|
-
//#region src/status.ts
|
|
3334
|
+
// src/status.ts
|
|
3361
3335
|
function status(cfg, catalogs, registry, drafts = {}, fingerprints = {}) {
|
|
3362
3336
|
const extracted = registry.messages();
|
|
3363
3337
|
const flat = {};
|
|
@@ -3414,8 +3388,7 @@ function formatStatusResult(result) {
|
|
|
3414
3388
|
}
|
|
3415
3389
|
return lines.join("\n");
|
|
3416
3390
|
}
|
|
3417
|
-
|
|
3418
|
-
//#region src/doctor.ts
|
|
3391
|
+
// src/doctor.ts
|
|
3419
3392
|
const PREVIEW = 5;
|
|
3420
3393
|
function readRoutingChoice(root, configFile) {
|
|
3421
3394
|
try {
|
|
@@ -3641,8 +3614,7 @@ function preview(keys) {
|
|
|
3641
3614
|
const head = keys.slice(0, PREVIEW).join(", ");
|
|
3642
3615
|
return keys.length > PREVIEW ? `${head}, …` : head;
|
|
3643
3616
|
}
|
|
3644
|
-
|
|
3645
|
-
//#region src/inline.ts
|
|
3617
|
+
// src/inline.ts
|
|
3646
3618
|
const OPEN_TAG = /^<([a-zA-Z][a-zA-Z0-9-]*)\s*(\/?)>/;
|
|
3647
3619
|
const BREAK = /^(?:br|wbr)$/;
|
|
3648
3620
|
function messageToInline(text) {
|
|
@@ -3858,8 +3830,7 @@ function attr(attrs, name) {
|
|
|
3858
3830
|
const value = new RegExp(`\\b${name}\\s*=\\s*"([^"]*)"`).exec(attrs)?.[1];
|
|
3859
3831
|
return value === void 0 ? void 0 : unescapeXml(value);
|
|
3860
3832
|
}
|
|
3861
|
-
|
|
3862
|
-
//#region src/mobile.ts
|
|
3833
|
+
// src/mobile.ts
|
|
3863
3834
|
function androidValuesDir(locale, sourceLocale) {
|
|
3864
3835
|
if (locale === sourceLocale) return "values";
|
|
3865
3836
|
const parts = locale.split("-");
|
|
@@ -3897,8 +3868,7 @@ function androidText(text) {
|
|
|
3897
3868
|
function iosText(text) {
|
|
3898
3869
|
return text.replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/\n/g, "\\n").replace(/\t/g, "\\t");
|
|
3899
3870
|
}
|
|
3900
|
-
|
|
3901
|
-
//#region src/po.ts
|
|
3871
|
+
// src/po.ts
|
|
3902
3872
|
function toPo(sourceLocale, locale, entries) {
|
|
3903
3873
|
return [
|
|
3904
3874
|
[
|
|
@@ -3993,8 +3963,7 @@ function poUnquote(text) {
|
|
|
3993
3963
|
return ch;
|
|
3994
3964
|
});
|
|
3995
3965
|
}
|
|
3996
|
-
|
|
3997
|
-
//#region src/translate.ts
|
|
3966
|
+
// src/translate.ts
|
|
3998
3967
|
const RETRY_STATUS = /* @__PURE__ */ new Set([
|
|
3999
3968
|
408,
|
|
4000
3969
|
409,
|
|
@@ -4173,7 +4142,7 @@ function formatTranslateFailures(failed) {
|
|
|
4173
4142
|
async function resolveProvider(cfg, model) {
|
|
4174
4143
|
const configured = cfg.translate.provider;
|
|
4175
4144
|
if (typeof configured === "function") return configured;
|
|
4176
|
-
const { claudeProvider } = await import("./claude-
|
|
4145
|
+
const { claudeProvider } = await import("./claude-CHpftMVn.js");
|
|
4177
4146
|
return claudeProvider({ model: model ?? cfg.translate.model });
|
|
4178
4147
|
}
|
|
4179
4148
|
function structureMatches(source, translated) {
|
|
@@ -4203,8 +4172,7 @@ function glossaryFor(cfg, locale, messages) {
|
|
|
4203
4172
|
}
|
|
4204
4173
|
return Object.keys(out).length > 0 ? out : void 0;
|
|
4205
4174
|
}
|
|
4206
|
-
|
|
4207
|
-
//#region src/exchange.ts
|
|
4175
|
+
// src/exchange.ts
|
|
4208
4176
|
function isMobileFormat(format) {
|
|
4209
4177
|
return format === "android-xml" || format === "ios-strings";
|
|
4210
4178
|
}
|
|
@@ -4464,8 +4432,7 @@ function csvRows(content) {
|
|
|
4464
4432
|
if (row.some((cell) => cell !== "")) rows.push(row);
|
|
4465
4433
|
return rows;
|
|
4466
4434
|
}
|
|
4467
|
-
|
|
4468
|
-
//#region src/render.ts
|
|
4435
|
+
// src/render.ts
|
|
4469
4436
|
function localeInstance(catalogs, locale, sourceLocale) {
|
|
4470
4437
|
return createVerbaly({
|
|
4471
4438
|
locale,
|
|
@@ -4914,8 +4881,7 @@ function escapeAttr(text) {
|
|
|
4914
4881
|
function decodeEntities(text) {
|
|
4915
4882
|
return text.replace(/"/g, "\"").replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&");
|
|
4916
4883
|
}
|
|
4917
|
-
|
|
4918
|
-
//#region src/watch.ts
|
|
4884
|
+
// src/watch.ts
|
|
4919
4885
|
const NATIVE_TREE = process.platform === "darwin" || process.platform === "win32";
|
|
4920
4886
|
function watchTree(root, options, onFile) {
|
|
4921
4887
|
const watchers = /* @__PURE__ */ new Map();
|
|
@@ -5000,8 +4966,7 @@ function watchProject(cfg, run, options = {}) {
|
|
|
5000
4966
|
close();
|
|
5001
4967
|
};
|
|
5002
4968
|
}
|
|
5003
|
-
|
|
5004
|
-
//#region src/wrap.ts
|
|
4969
|
+
// src/wrap.ts
|
|
5005
4970
|
const WRAP_ATTRS = /* @__PURE__ */ new Set([
|
|
5006
4971
|
"title",
|
|
5007
4972
|
"alt",
|
|
@@ -5276,8 +5241,7 @@ function trailingWs(text) {
|
|
|
5276
5241
|
function line(node) {
|
|
5277
5242
|
return node.loc?.start?.line ?? 1;
|
|
5278
5243
|
}
|
|
5279
|
-
|
|
5280
|
-
//#region src/run.ts
|
|
5244
|
+
// src/run.ts
|
|
5281
5245
|
const HELP = `verbaly · i18n compiler
|
|
5282
5246
|
|
|
5283
5247
|
Usage:
|
|
@@ -5869,5 +5833,4 @@ function rejectStrayFlags(command, values) {
|
|
|
5869
5833
|
process.exitCode = 1;
|
|
5870
5834
|
return true;
|
|
5871
5835
|
}
|
|
5872
|
-
//#endregion
|
|
5873
5836
|
export { collectOrigins as $, formatCheckWarnings as A, recordTranslations as B, loadVirtualModule as C, transformCode as D, transformSource as E, effectiveDrafts as F, formatCollision as G, updateState as H, loadState as I, generateLocaleModule as J, formatFinding as K, markDrafts as L, syncProject as M, STATE_FILE as N, check as O, clearDrafts as P, validatePair as Q, outdatedTranslations as R, isTransformTarget as S, runBuildGate as T, collisionEntries as U, saveState as V, createDevReporter as W, writeDts as X, generateRuntimeModule as Y, validateMessage as Z, reportOutsideInclude as _, writeCatalog as _t, formatRenderWarnings as a, MessageRegistry as at, SOURCE_FILE_RE as b, mergeTranslations as c, isModuleNotFound as ct, writeDrafts as d, targetLocales as dt, extractProject as et, doctor as f, loadCatalogs as ft, status as g, readCatalog as gt, formatStatusResult as h, parseCatalog as ht, watchTree as i, stableKey as it, init as j, formatCheckResult as k, resolveProvider as l, loadConfig as lt, formatDoctorHealth as m, needsRelative as mt, runCli as n, shippedCatalogs as nt, renderSite as o, clientCatalogs as ot, formatDoctorEntry as p, needsIcu as pt, generateDts as q, wrapProject as r, syncCatalogs as rt, formatTranslateFailures as s, counted as st, formatCliError as t, pruneCatalogs as tt, translateCatalogs as u, resolveConfig as ut, LOCALE_MODULE_PREFIX as v, resolveVirtualId as w, createSourceFilter as x, RESOLVED_VIRTUAL_ID as y, readState as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verbaly/compiler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.77.0",
|
|
4
4
|
"description": "Message extraction and type-safe codegen for Verbaly.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"i18n",
|
|
@@ -19,6 +19,10 @@
|
|
|
19
19
|
"bugs": {
|
|
20
20
|
"url": "https://github.com/AronSoto/verbaly/issues"
|
|
21
21
|
},
|
|
22
|
+
"funding": {
|
|
23
|
+
"type": "github",
|
|
24
|
+
"url": "https://github.com/sponsors/AronSoto"
|
|
25
|
+
},
|
|
22
26
|
"type": "module",
|
|
23
27
|
"types": "./dist/index.d.ts",
|
|
24
28
|
"exports": {
|
|
@@ -42,13 +46,13 @@
|
|
|
42
46
|
"access": "public"
|
|
43
47
|
},
|
|
44
48
|
"dependencies": {
|
|
45
|
-
"@babel/parser": "^8.0.
|
|
49
|
+
"@babel/parser": "^8.0.10",
|
|
46
50
|
"jiti": "^2.7.0",
|
|
47
51
|
"jsonc-parser": "^3.3.1",
|
|
48
|
-
"magic-string": "^1.4.
|
|
52
|
+
"magic-string": "^1.4.5",
|
|
49
53
|
"picomatch": "^4.0.7",
|
|
50
54
|
"tinyglobby": "^0.2.17",
|
|
51
|
-
"verbaly": "0.
|
|
55
|
+
"verbaly": "0.77.0"
|
|
52
56
|
},
|
|
53
57
|
"peerDependencies": {
|
|
54
58
|
"@anthropic-ai/sdk": ">=0.110.0"
|
|
@@ -59,7 +63,7 @@
|
|
|
59
63
|
}
|
|
60
64
|
},
|
|
61
65
|
"devDependencies": {
|
|
62
|
-
"@anthropic-ai/sdk": "^1.
|
|
66
|
+
"@anthropic-ai/sdk": "^1.3.0",
|
|
63
67
|
"@types/picomatch": "^4.0.3",
|
|
64
68
|
"esbuild": "^0.28.2",
|
|
65
69
|
"fast-check": "^4.10.2",
|