@verbaly/compiler 0.76.0 → 0.78.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 +7 -7
- package/dist/{claude-BS6CeLiA.js → claude-DZkzlC5g.js} +2 -3
- package/dist/cli.js +2 -3
- package/dist/index.d.ts +3 -54
- package/dist/index.js +3 -4
- package/dist/{run-CfZ-z1Io.js → run-kySCrf3Z.js} +70 -87
- package/package.json +9 -5
package/README.md
CHANGED
|
@@ -112,13 +112,13 @@ A message keeps its text in exactly one place, and that place is where you edit
|
|
|
112
112
|
**Keys first** is the third row: the text lives only in the catalog, and a literal `t('settings.save')` counts as a use, so `--prune` keeps it. When a key comes from data instead of a literal, declare the keys with `defineKeys`, so the compiler sees them and TypeScript checks them where you write them:
|
|
113
113
|
|
|
114
114
|
```ts
|
|
115
|
-
import { defineKeys } from '
|
|
115
|
+
import { defineKeys } from 'verbaly/app';
|
|
116
116
|
|
|
117
117
|
const titles = defineKeys({ verbaly: 'project.verbaly.title', blog: 'project.blog.title' });
|
|
118
118
|
t(titles[slug]);
|
|
119
119
|
```
|
|
120
120
|
|
|
121
|
-
`defineKeys` is detected by name, like `t`. It comes from `
|
|
121
|
+
`defineKeys` is detected by name, like `t`. It comes from `verbaly/app`, the module generated for your project, which is the one the framework provider already loads.
|
|
122
122
|
|
|
123
123
|
**A translation knows which source text it was written for.** For readable keys, the second and third rows, Verbaly keeps a short fingerprint of the source text and of the translation in `verbaly.lock`, next to your config. It is taken the moment the translation is written, by `translate`, `import`, Studio or an agent, so a source that changes right after is still caught; `import` takes it from the source text the translator's file carries, so a file made for an older text reads as outdated at once. When the source text changes and the translation does not, the translation is **outdated**: `status`, `check` and `doctor` say so, `review` lists it with both texts, and `review --approve` keeps it if it still holds. Editing the translation clears it on its own. Hash keys never need this, because a new text is a new key.
|
|
124
124
|
|
|
@@ -133,7 +133,7 @@ Four details that catch people out:
|
|
|
133
133
|
|
|
134
134
|
## 🔑 Typed keys, and where the types live
|
|
135
135
|
|
|
136
|
-
Every `t` your project holds checks its keys and their params: the one from `
|
|
136
|
+
Every `t` your project holds checks its keys and their params: the one from `verbaly/app`, `useT()` in React, Vue and Svelte, `getT()` in Next, and the `t` of an instance from `createInstance` or `createRequestInstance`. A key no catalog has does not compile, a message with a `{name}` asks for it, and Next's `getRequestLocale()` returns one of your locales instead of any string:
|
|
137
137
|
|
|
138
138
|
```ts
|
|
139
139
|
const t = useT();
|
|
@@ -223,10 +223,10 @@ export default {
|
|
|
223
223
|
|
|
224
224
|
Pick by surface, not by taste: [Google recommends a different URL per language](https://developers.google.com/search/docs/specialty/international/managing-multi-regional-sites) rather than cookies or browser settings, so anything people reach through search wants the language in the address. An app behind a login loses nothing with `no-prefix`.
|
|
225
225
|
|
|
226
|
-
`
|
|
226
|
+
`verbaly/app` exports `routing`, `localePath`, `localeFromPath` and **`switchLocale`, already bound** to your locales, source and mode. The switcher is one line and it is the same line in every mode:
|
|
227
227
|
|
|
228
228
|
```ts
|
|
229
|
-
import { switchLocale } from '
|
|
229
|
+
import { switchLocale } from 'verbaly/app';
|
|
230
230
|
|
|
231
231
|
await switchLocale('es');
|
|
232
232
|
```
|
|
@@ -325,7 +325,7 @@ export default {
|
|
|
325
325
|
**Use it for text `render` covers.** A key that is excluded and then asked for at runtime resolves to itself, like any absent key, and `bindDom` leaves the pre-rendered text alone rather than painting the key over it. The build says so when a prefix matches nothing, and when your code reads an excluded key through `t()`. To use an excluded group at runtime anyway, load it yourself:
|
|
326
326
|
|
|
327
327
|
```ts
|
|
328
|
-
import { verbaly } from '
|
|
328
|
+
import { verbaly } from 'verbaly/app';
|
|
329
329
|
|
|
330
330
|
const extra = await import(`./i18n/changelog/${locale}.json`);
|
|
331
331
|
verbaly.addMessages(locale, extra.default);
|
|
@@ -357,7 +357,7 @@ The package exports two layers, and **nothing else is public**. Anything you can
|
|
|
357
357
|
| Config & catalogs | `loadConfig` `resolveConfig` `targetLocales` `loadCatalogs` `readCatalog` `parseCatalog` `writeCatalog` `clientCatalogs` `needsIcu` `needsRelative` · types `Catalog` `Catalogs` |
|
|
358
358
|
| Extraction | `syncProject` `extractProject` `collectOrigins` `syncCatalogs` `shippedCatalogs` `pruneCatalogs` `MessageRegistry` `stableKey` `watchTree` · types `SyncProjectResult` `SyncResult` `TreeOptions` |
|
|
359
359
|
| Codegen | `generateDts` `writeDts` `generateRuntimeModule` `generateLocaleModule` · types `DtsOptions` `RuntimeModuleOptions` |
|
|
360
|
-
| Bundler plumbing | `transformSource` `transformCode` `runBuildGate` `createSourceFilter` `reportOutsideInclude` `isTransformTarget` `resolveVirtualId` `loadVirtualModule` `RESOLVED_VIRTUAL_ID` `LOCALE_MODULE_PREFIX` `SOURCE_FILE_RE` · types `PluginOptions` `TransformResult`
|
|
360
|
+
| Bundler plumbing | `transformSource` `transformCode` `runBuildGate` `createSourceFilter` `reportOutsideInclude` `isTransformTarget` `resolveVirtualId` `loadVirtualModule` `APP_ID` `LOCALE_IMPORT` `RESOLVED_VIRTUAL_ID` `LOCALE_MODULE_PREFIX` `SOURCE_FILE_RE` · types `PluginOptions` `TransformResult` |
|
|
361
361
|
| The gate | `check` `validateMessage` `validatePair` `formatCheckResult` `formatCheckWarnings` `collisionEntries` `formatCollision` `formatFinding` `createDevReporter` · types `Finding` `DevReporter` `CheckResult` `MissingEntry` `UnknownEntry` `BrokenEntry` `ExtraEntry` `CollisionEntry` `DivergentEntry` `OutdatedEntry` `SourceSite` `StructureIssue` `IssueSeverity` |
|
|
362
362
|
| Coverage | `status` `formatStatusResult` `counted` · types `StatusResult` `LocaleStatus` |
|
|
363
363
|
| Review state | `loadDrafts` `saveDrafts` `markDrafts` `clearDrafts` `effectiveDrafts` `loadState` `readState` `updateState` `recordTranslations` `outdatedTranslations` `STATE_FILE` · types `Drafts` `State` `Fingerprints` `TranslationWrite` |
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { lt as counted, ut as isModuleNotFound } from "./run-kySCrf3Z.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-kySCrf3Z.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,16 @@ interface DtsWrite {
|
|
|
386
361
|
changed: boolean;
|
|
387
362
|
}
|
|
388
363
|
export declare function writeDts(cfg: ResolvedConfig, catalog: Catalog, file?: string | false): DtsWrite | undefined;
|
|
389
|
-
|
|
390
|
-
|
|
364
|
+
export declare const APP_ID = "verbaly/app";
|
|
365
|
+
export declare const LOCALE_IMPORT = "@verbaly/app/locale/";
|
|
391
366
|
interface TransformResult {
|
|
392
367
|
code: string;
|
|
393
368
|
map: ReturnType<MagicString['generateMap']>;
|
|
394
369
|
}
|
|
395
370
|
export declare function transformCode(code: string, file: string, analysis?: Analysis): TransformResult | null;
|
|
396
|
-
//#endregion
|
|
397
|
-
//#region src/plugin.d.ts
|
|
398
371
|
interface PluginOptions extends VerbalyConfig {
|
|
399
372
|
failOnMissing?: boolean;
|
|
373
|
+
liveExtraction?: boolean;
|
|
400
374
|
}
|
|
401
375
|
export declare const RESOLVED_VIRTUAL_ID: string;
|
|
402
376
|
export declare const LOCALE_MODULE_PREFIX = "\0virtual:verbaly/locale/";
|
|
@@ -410,11 +384,7 @@ export declare function transformSource(code: string, id: string, registry: Mess
|
|
|
410
384
|
result: TransformResult | null;
|
|
411
385
|
};
|
|
412
386
|
export declare function runBuildGate(cfg: ResolvedConfig, registry: MessageRegistry, failOnMissing?: boolean): void;
|
|
413
|
-
//#endregion
|
|
414
|
-
//#region src/scope.d.ts
|
|
415
387
|
export declare function reportOutsideInclude(cfg: ResolvedConfig): Promise<void>;
|
|
416
|
-
//#endregion
|
|
417
|
-
//#region src/validate.d.ts
|
|
418
388
|
type IssueSeverity = 'error' | 'warning';
|
|
419
389
|
interface StructureIssue {
|
|
420
390
|
severity: IssueSeverity;
|
|
@@ -422,8 +392,6 @@ interface StructureIssue {
|
|
|
422
392
|
}
|
|
423
393
|
export declare function validateMessage(message: string, locale?: string): StructureIssue[];
|
|
424
394
|
export declare function validatePair(source: string, translated: string): StructureIssue[];
|
|
425
|
-
//#endregion
|
|
426
|
-
//#region src/check.d.ts
|
|
427
395
|
interface MissingEntry {
|
|
428
396
|
locale: string;
|
|
429
397
|
key: string;
|
|
@@ -465,12 +433,8 @@ interface CheckReportOptions {
|
|
|
465
433
|
outdatedFails?: boolean;
|
|
466
434
|
}
|
|
467
435
|
export declare function formatCheckWarnings(result: CheckResult, root?: string, options?: CheckReportOptions): string;
|
|
468
|
-
//#endregion
|
|
469
|
-
//#region src/drafts.d.ts
|
|
470
436
|
export declare function loadDrafts(cfg: ResolvedConfig): Drafts;
|
|
471
437
|
export declare function saveDrafts(cfg: ResolvedConfig, drafts: Drafts): void;
|
|
472
|
-
//#endregion
|
|
473
|
-
//#region src/status.d.ts
|
|
474
438
|
interface LocaleStatus {
|
|
475
439
|
locale: string;
|
|
476
440
|
translated: number;
|
|
@@ -486,22 +450,14 @@ interface StatusResult {
|
|
|
486
450
|
}
|
|
487
451
|
export declare function status(cfg: ResolvedConfig, catalogs: Catalogs, registry: MessageRegistry, drafts?: Drafts, fingerprints?: Fingerprints): StatusResult;
|
|
488
452
|
export declare function formatStatusResult(result: StatusResult): string;
|
|
489
|
-
//#endregion
|
|
490
|
-
//#region src/text.d.ts
|
|
491
453
|
export declare function counted(count: number, noun: string, many?: string): string;
|
|
492
|
-
//#endregion
|
|
493
|
-
//#region src/run.d.ts
|
|
494
454
|
export declare function formatCliError(error: unknown): string;
|
|
495
|
-
//#endregion
|
|
496
|
-
//#region src/watch.d.ts
|
|
497
455
|
interface TreeOptions {
|
|
498
456
|
keep?: string;
|
|
499
457
|
native?: boolean;
|
|
500
458
|
persistent?: boolean;
|
|
501
459
|
}
|
|
502
460
|
export declare function watchTree(root: string, options: TreeOptions, onFile: (file: string) => void): () => void;
|
|
503
|
-
//#endregion
|
|
504
|
-
//#region src/doctor.d.ts
|
|
505
461
|
interface DoctorEntry {
|
|
506
462
|
level: 'ok' | 'warn' | 'error';
|
|
507
463
|
check: string;
|
|
@@ -515,8 +471,6 @@ interface DoctorResult {
|
|
|
515
471
|
export declare function formatDoctorEntry(entry: DoctorEntry): string;
|
|
516
472
|
export declare function formatDoctorHealth(result: DoctorResult): string;
|
|
517
473
|
export declare function doctor(cfg: ResolvedConfig): Promise<DoctorResult>;
|
|
518
|
-
//#endregion
|
|
519
|
-
//#region src/init.d.ts
|
|
520
474
|
interface InitOptions {
|
|
521
475
|
root?: string;
|
|
522
476
|
dir?: string;
|
|
@@ -537,8 +491,6 @@ interface InitResult {
|
|
|
537
491
|
found?: string;
|
|
538
492
|
}
|
|
539
493
|
export declare function init(input?: InitOptions): Promise<InitResult>;
|
|
540
|
-
//#endregion
|
|
541
|
-
//#region src/wrap.d.ts
|
|
542
494
|
interface WrapEntry {
|
|
543
495
|
file: string;
|
|
544
496
|
line: number;
|
|
@@ -568,8 +520,6 @@ interface WrapOptions {
|
|
|
568
520
|
write?: boolean;
|
|
569
521
|
}
|
|
570
522
|
export declare function wrapProject(cfg: ResolvedConfig, options?: WrapOptions): Promise<WrapResult>;
|
|
571
|
-
//#endregion
|
|
572
|
-
//#region src/render.d.ts
|
|
573
523
|
interface RenderSiteOptions {
|
|
574
524
|
site?: string;
|
|
575
525
|
locales?: string[];
|
|
@@ -592,5 +542,4 @@ interface RenderSiteResult {
|
|
|
592
542
|
}
|
|
593
543
|
export declare function renderSite(cfg: ResolvedConfig, options?: RenderSiteOptions): Promise<RenderSiteResult>;
|
|
594
544
|
export declare function formatRenderWarnings(result: RenderSiteResult, sourceLocale: string): string[];
|
|
595
|
-
//#endregion
|
|
596
545
|
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
|
|
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 parseCatalog, a as formatRenderWarnings, at as APP_ID, b as SOURCE_FILE_RE, c as mergeTranslations, ct as clientCatalogs, d as writeDrafts, dt as loadConfig, et as extractProject, f as doctor, ft as resolveConfig, g as status, gt as needsRelative, h as formatStatusResult, ht as needsIcu, i as watchTree, it as stableKey, j as init, k as formatCheckResult, l as resolveProvider, lt as counted, m as formatDoctorHealth, mt as loadCatalogs, nt as shippedCatalogs, o as renderSite, ot as LOCALE_IMPORT, p as formatDoctorEntry, pt as targetLocales, q as generateDts, r as wrapProject, rt as syncCatalogs, s as formatTranslateFailures, st as MessageRegistry, t as formatCliError, tt as pruneCatalogs, u as translateCatalogs, v as LOCALE_MODULE_PREFIX, vt as readCatalog, w as resolveVirtualId, x as createSourceFilter, y as RESOLVED_VIRTUAL_ID, yt as writeCatalog, z as readState } from "./run-kySCrf3Z.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
|
-
|
|
14
|
-
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 };
|
|
13
|
+
export { APP_ID, LOCALE_IMPORT, 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,18 @@ 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
|
-
|
|
679
|
+
// src/ids.ts
|
|
680
|
+
const VIRTUAL_ID = "virtual:verbaly";
|
|
681
|
+
const APP_ID = "verbaly/app";
|
|
682
|
+
const LOCALE_IMPORT = "@verbaly/app/locale/";
|
|
683
|
+
function isAppModule(source) {
|
|
684
|
+
return source === "verbaly/app" || source === "virtual:verbaly";
|
|
685
|
+
}
|
|
686
|
+
// src/key.ts
|
|
689
687
|
function stableKey(message) {
|
|
690
688
|
return createHash("sha256").update(message).digest("base64url").slice(0, 8);
|
|
691
689
|
}
|
|
692
|
-
|
|
693
|
-
//#region src/analyze.ts
|
|
690
|
+
// src/analyze.ts
|
|
694
691
|
function parseErrorMessage(error) {
|
|
695
692
|
return error instanceof Error ? error.message : String(error);
|
|
696
693
|
}
|
|
@@ -810,7 +807,7 @@ function analyzeScript(code, file, options = {}) {
|
|
|
810
807
|
function lineOf(node) {
|
|
811
808
|
return node.loc?.start.line ?? 1;
|
|
812
809
|
}
|
|
813
|
-
const VERBALY_SOURCE = /^(?:verbaly
|
|
810
|
+
const VERBALY_SOURCE = /^(?:verbaly|@verbaly\/[\w-]+(?:\/[\w-]+)*)$/;
|
|
814
811
|
const T_FACTORIES = /* @__PURE__ */ new Map([["useT", "call"], ["getT", "await"]]);
|
|
815
812
|
const INSTANCE_FACTORIES = /* @__PURE__ */ new Set(["useVerbaly", "getVerbaly"]);
|
|
816
813
|
var Bindings = class {
|
|
@@ -833,7 +830,7 @@ var Bindings = class {
|
|
|
833
830
|
source,
|
|
834
831
|
imported
|
|
835
832
|
});
|
|
836
|
-
if (source
|
|
833
|
+
if (isAppModule(source) && imported === "t") this.direct.add(local);
|
|
837
834
|
}
|
|
838
835
|
}
|
|
839
836
|
addDeclarator(node) {
|
|
@@ -893,7 +890,7 @@ var Bindings = class {
|
|
|
893
890
|
imported: local
|
|
894
891
|
};
|
|
895
892
|
return {
|
|
896
|
-
verbaly: VERBALY_SOURCE.test(found.source),
|
|
893
|
+
verbaly: VERBALY_SOURCE.test(found.source) || isAppModule(found.source),
|
|
897
894
|
imported: found.imported
|
|
898
895
|
};
|
|
899
896
|
}
|
|
@@ -1216,8 +1213,7 @@ function walk$1(node, visit) {
|
|
|
1216
1213
|
function isNode(value) {
|
|
1217
1214
|
return typeof value === "object" && value !== null && typeof value.type === "string";
|
|
1218
1215
|
}
|
|
1219
|
-
|
|
1220
|
-
//#region src/sfc.ts
|
|
1216
|
+
// src/sfc.ts
|
|
1221
1217
|
const SFC_FILE_RE = /\.(?:svelte|vue|astro)$/;
|
|
1222
1218
|
function analyzeFile(code, file) {
|
|
1223
1219
|
if (SFC_FILE_RE.test(file)) return analyzeSfc(code, file);
|
|
@@ -1407,8 +1403,7 @@ function stringEnd(code, start) {
|
|
|
1407
1403
|
else i += 1;
|
|
1408
1404
|
return code.length;
|
|
1409
1405
|
}
|
|
1410
|
-
|
|
1411
|
-
//#region src/extract.ts
|
|
1406
|
+
// src/extract.ts
|
|
1412
1407
|
const kept = /* @__PURE__ */ new WeakMap();
|
|
1413
1408
|
async function extractProject(cfg, options = {}) {
|
|
1414
1409
|
const files = await glob(cfg.include, {
|
|
@@ -1493,8 +1488,7 @@ function pruneCatalogs(cfg, catalogs, registry) {
|
|
|
1493
1488
|
}
|
|
1494
1489
|
return removed;
|
|
1495
1490
|
}
|
|
1496
|
-
|
|
1497
|
-
//#region src/validate.ts
|
|
1491
|
+
// src/validate.ts
|
|
1498
1492
|
let remembered = /* @__PURE__ */ new Map();
|
|
1499
1493
|
let reading;
|
|
1500
1494
|
function read(message) {
|
|
@@ -1705,8 +1699,7 @@ function reachableCategories(locale, ordinal) {
|
|
|
1705
1699
|
reachable.set(cacheKey, out);
|
|
1706
1700
|
return out;
|
|
1707
1701
|
}
|
|
1708
|
-
|
|
1709
|
-
//#region src/params.ts
|
|
1702
|
+
// src/params.ts
|
|
1710
1703
|
const NUMBER_FORMATS = /* @__PURE__ */ new Set([
|
|
1711
1704
|
"number",
|
|
1712
1705
|
"integer",
|
|
@@ -1748,8 +1741,7 @@ function renderParamType(types) {
|
|
|
1748
1741
|
]) members.add(m);
|
|
1749
1742
|
return [...members].join(" | ");
|
|
1750
1743
|
}
|
|
1751
|
-
|
|
1752
|
-
//#region src/tsconfig.ts
|
|
1744
|
+
// src/tsconfig.ts
|
|
1753
1745
|
function readTsconfig(root) {
|
|
1754
1746
|
const path = join(root, "tsconfig.json");
|
|
1755
1747
|
let text;
|
|
@@ -1808,6 +1800,7 @@ function includeTypes(root, file) {
|
|
|
1808
1800
|
writeFileSync(read.path, applyEdits(read.text, edits));
|
|
1809
1801
|
return "added";
|
|
1810
1802
|
}
|
|
1803
|
+
// src/codegen.ts
|
|
1811
1804
|
const DTS_HEADER = "// generated by verbaly: do not edit";
|
|
1812
1805
|
const SLICE_HELPERS = `function readSlice(root, path) {
|
|
1813
1806
|
const locale = readPath({ supported: locales, path });
|
|
@@ -1824,7 +1817,7 @@ export function adoptPage(options) {
|
|
|
1824
1817
|
|
|
1825
1818
|
`;
|
|
1826
1819
|
function generateRuntimeModule(cfg, options = {}) {
|
|
1827
|
-
const importPath = options.localeImport ?? ((locale) =>
|
|
1820
|
+
const importPath = options.localeImport ?? ((locale) => "@verbaly/app/locale/" + locale);
|
|
1828
1821
|
const others = cfg.locales.filter((locale) => locale !== cfg.sourceLocale);
|
|
1829
1822
|
const src = JSON.stringify(cfg.sourceLocale);
|
|
1830
1823
|
const loaders = others.map((locale) => ` ${JSON.stringify(locale)}: () => import('${importPath(locale)}'),`).join("\n");
|
|
@@ -1860,8 +1853,10 @@ export function defineKeys(keys) {
|
|
|
1860
1853
|
}
|
|
1861
1854
|
|
|
1862
1855
|
// the whole switch a language control needs, in either mode: catalog or navigation, then persistence
|
|
1856
|
+
// instance: the one the page renders with, where a framework builds one per request
|
|
1863
1857
|
export function switchLocale(locale, options) {
|
|
1864
|
-
|
|
1858
|
+
const { instance, ...rest } = options ?? {};
|
|
1859
|
+
return runSwitch(instance ?? v, locale, { supported: locales, sourceLocale, routing, trailingSlash, ...rest });
|
|
1865
1860
|
}
|
|
1866
1861
|
|
|
1867
1862
|
const localeLoaders = {
|
|
@@ -1950,7 +1945,7 @@ function generateDts(catalog, options = {}) {
|
|
|
1950
1945
|
// biome-ignore-all lint: generated by verbaly
|
|
1951
1946
|
// biome-ignore-all format: generated by verbaly
|
|
1952
1947
|
// prettier-ignore
|
|
1953
|
-
declare module '
|
|
1948
|
+
declare module '${APP_ID}' {
|
|
1954
1949
|
export interface VerbalyMessages {
|
|
1955
1950
|
${lines.join("\n")}
|
|
1956
1951
|
}
|
|
@@ -2009,7 +2004,10 @@ ${lines.join("\n")}
|
|
|
2009
2004
|
options?: Omit<
|
|
2010
2005
|
import('verbaly').SwitchLocaleOptions,
|
|
2011
2006
|
'routing' | 'supported' | 'sourceLocale' | 'trailingSlash'
|
|
2012
|
-
|
|
2007
|
+
> & {
|
|
2008
|
+
// the instance the page renders with, where the framework builds one per request
|
|
2009
|
+
instance?: Pick<import('verbaly').Verbaly, 'loadLocale' | 'setLocale'>;
|
|
2010
|
+
},
|
|
2013
2011
|
): Promise<void>;
|
|
2014
2012
|
export function getLocale(): string;
|
|
2015
2013
|
export function subscribe(listener: () => void): () => void;
|
|
@@ -2024,7 +2022,12 @@ ${lines.join("\n")}
|
|
|
2024
2022
|
}
|
|
2025
2023
|
|
|
2026
2024
|
// prettier-ignore
|
|
2027
|
-
declare module '
|
|
2025
|
+
declare module '${VIRTUAL_ID}' {
|
|
2026
|
+
export * from '${APP_ID}';
|
|
2027
|
+
}
|
|
2028
|
+
|
|
2029
|
+
// prettier-ignore
|
|
2030
|
+
declare module '${LOCALE_IMPORT}*' {
|
|
2028
2031
|
const messages: Record<string, string>;
|
|
2029
2032
|
export default messages;
|
|
2030
2033
|
}
|
|
@@ -2076,8 +2079,7 @@ function removeRootDts(cfg, target) {
|
|
|
2076
2079
|
rmSync(old);
|
|
2077
2080
|
warnOnce(`the types live in ${relative(cfg.root, target).replaceAll("\\", "/")} now, so the verbaly.d.ts Verbaly wrote at the root was removed`);
|
|
2078
2081
|
}
|
|
2079
|
-
|
|
2080
|
-
//#region src/findings.ts
|
|
2082
|
+
// src/findings.ts
|
|
2081
2083
|
function siteOf(msg) {
|
|
2082
2084
|
return {
|
|
2083
2085
|
file: msg.file,
|
|
@@ -2198,8 +2200,7 @@ function createDevReporter(root, print = (line) => console.warn(`[verbaly] ${lin
|
|
|
2198
2200
|
if (fresh.length > cap) print(`and ${fresh.length - cap} more: \`npx verbaly doctor\` names them`);
|
|
2199
2201
|
} };
|
|
2200
2202
|
}
|
|
2201
|
-
|
|
2202
|
-
//#region src/state.ts
|
|
2203
|
+
// src/state.ts
|
|
2203
2204
|
const STATE_FILE = "verbaly.lock";
|
|
2204
2205
|
const LOCK_VERSION = 1;
|
|
2205
2206
|
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 +2533,7 @@ function readFingerprints(value) {
|
|
|
2532
2533
|
}
|
|
2533
2534
|
return out;
|
|
2534
2535
|
}
|
|
2535
|
-
|
|
2536
|
-
//#region src/project.ts
|
|
2536
|
+
// src/project.ts
|
|
2537
2537
|
async function syncProject(cfg, options = {}) {
|
|
2538
2538
|
const registry = options.registry ?? await extractProject(cfg);
|
|
2539
2539
|
const catalogs = options.catalogs ?? loadCatalogs(cfg);
|
|
@@ -2589,8 +2589,7 @@ function confirmFromDisk(cfg, catalogs, registry) {
|
|
|
2589
2589
|
registry.update(file, analyzeFile(code, file));
|
|
2590
2590
|
}
|
|
2591
2591
|
}
|
|
2592
|
-
|
|
2593
|
-
//#region src/migrate.ts
|
|
2592
|
+
// src/migrate.ts
|
|
2594
2593
|
const KNOWN = [
|
|
2595
2594
|
"i18next",
|
|
2596
2595
|
"react-i18next",
|
|
@@ -2808,8 +2807,7 @@ function migrateCatalogs(cfg, options = {}) {
|
|
|
2808
2807
|
remembered
|
|
2809
2808
|
};
|
|
2810
2809
|
}
|
|
2811
|
-
|
|
2812
|
-
//#region src/tag.ts
|
|
2810
|
+
// src/tag.ts
|
|
2813
2811
|
function isLocaleTag(tag) {
|
|
2814
2812
|
try {
|
|
2815
2813
|
Intl.getCanonicalLocales(tag);
|
|
@@ -2827,8 +2825,7 @@ function projectLocale(tag, locales) {
|
|
|
2827
2825
|
const plain = (value) => value.replace(/_/g, "-").toLowerCase();
|
|
2828
2826
|
return locales.find((locale) => plain(locale) === plain(tag));
|
|
2829
2827
|
}
|
|
2830
|
-
|
|
2831
|
-
//#region src/init.ts
|
|
2828
|
+
// src/init.ts
|
|
2832
2829
|
const CATALOG_DIRS = [
|
|
2833
2830
|
"locales",
|
|
2834
2831
|
"src/locales",
|
|
@@ -2942,8 +2939,7 @@ async function init(input = {}) {
|
|
|
2942
2939
|
found
|
|
2943
2940
|
};
|
|
2944
2941
|
}
|
|
2945
|
-
|
|
2946
|
-
//#region src/check.ts
|
|
2942
|
+
// src/check.ts
|
|
2947
2943
|
function gatePasses(result) {
|
|
2948
2944
|
return result.missing.length === 0 && result.unknown.length === 0 && result.collisions.length === 0 && !result.broken.some((entry) => entry.severity === "error");
|
|
2949
2945
|
}
|
|
@@ -3175,8 +3171,7 @@ function escapeData(text) {
|
|
|
3175
3171
|
function escapeProperty(text) {
|
|
3176
3172
|
return escapeData(text).replaceAll(":", "%3A").replaceAll(",", "%2C");
|
|
3177
3173
|
}
|
|
3178
|
-
|
|
3179
|
-
//#region src/transform.ts
|
|
3174
|
+
// src/transform.ts
|
|
3180
3175
|
function quote(text, single) {
|
|
3181
3176
|
if (!single) return JSON.stringify(text);
|
|
3182
3177
|
return `'${text.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
|
|
@@ -3206,13 +3201,14 @@ function transformCode(code, file, analysis) {
|
|
|
3206
3201
|
map: s.generateMap({ hires: true })
|
|
3207
3202
|
};
|
|
3208
3203
|
}
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
const RESOLVED_VIRTUAL_ID = "\0virtual:verbaly";
|
|
3204
|
+
// src/plugin.ts
|
|
3205
|
+
const RESOLVED_VIRTUAL_ID = "\0" + VIRTUAL_ID;
|
|
3212
3206
|
const LOCALE_MODULE_PREFIX = `${RESOLVED_VIRTUAL_ID}/locale/`;
|
|
3213
3207
|
const SOURCE_FILE_RE = /\.(?:[cm]?[jt]sx?|svelte|vue|astro)$/;
|
|
3214
3208
|
function resolveVirtualId(id) {
|
|
3215
|
-
if (id
|
|
3209
|
+
if (isAppModule(id)) return RESOLVED_VIRTUAL_ID;
|
|
3210
|
+
if (id.startsWith("@verbaly/app/locale/")) return LOCALE_MODULE_PREFIX + id.slice(20);
|
|
3211
|
+
if (id.startsWith(`virtual:verbaly/`)) return "\0" + id;
|
|
3216
3212
|
}
|
|
3217
3213
|
function loadVirtualModule(id, cfg, catalogs) {
|
|
3218
3214
|
const client = clientCatalogs(cfg, catalogs);
|
|
@@ -3289,8 +3285,7 @@ function buildFingerprints(cfg) {
|
|
|
3289
3285
|
if (problem) warnOnce(`${problem}, so outdated translations are not reported`, "gate:state");
|
|
3290
3286
|
return state.fingerprints;
|
|
3291
3287
|
}
|
|
3292
|
-
|
|
3293
|
-
//#region src/scope.ts
|
|
3288
|
+
// src/scope.ts
|
|
3294
3289
|
const TAGGED_HINT = /(?<![\w$.])\$?t(?:\.id\s*\([^)]*\))?\s*`/;
|
|
3295
3290
|
const NOT_SOURCE = [
|
|
3296
3291
|
"**/node_modules/**",
|
|
@@ -3356,8 +3351,7 @@ async function filesOutsideInclude(cfg) {
|
|
|
3356
3351
|
}
|
|
3357
3352
|
return found;
|
|
3358
3353
|
}
|
|
3359
|
-
|
|
3360
|
-
//#region src/status.ts
|
|
3354
|
+
// src/status.ts
|
|
3361
3355
|
function status(cfg, catalogs, registry, drafts = {}, fingerprints = {}) {
|
|
3362
3356
|
const extracted = registry.messages();
|
|
3363
3357
|
const flat = {};
|
|
@@ -3414,8 +3408,7 @@ function formatStatusResult(result) {
|
|
|
3414
3408
|
}
|
|
3415
3409
|
return lines.join("\n");
|
|
3416
3410
|
}
|
|
3417
|
-
|
|
3418
|
-
//#region src/doctor.ts
|
|
3411
|
+
// src/doctor.ts
|
|
3419
3412
|
const PREVIEW = 5;
|
|
3420
3413
|
function readRoutingChoice(root, configFile) {
|
|
3421
3414
|
try {
|
|
@@ -3558,7 +3551,7 @@ async function doctor(cfg) {
|
|
|
3558
3551
|
const stray = registry.strayImports();
|
|
3559
3552
|
if (stray.length > 0) {
|
|
3560
3553
|
const files = [...new Set(stray.map((entry) => rel(entry.file)))];
|
|
3561
|
-
error("imports", `t is imported from a verbaly package, which never exports it, in ${counted(files.length, "file")} (${preview(files)})`, "t comes from your instance (React: const t = useT()) or from
|
|
3554
|
+
error("imports", `t is imported from a verbaly package, which never exports it, in ${counted(files.length, "file")} (${preview(files)})`, "t comes from your instance (React: const t = useT()) or from verbaly/app");
|
|
3562
3555
|
}
|
|
3563
3556
|
const missed = registry.missed();
|
|
3564
3557
|
if (missed.length > 0) {
|
|
@@ -3641,8 +3634,7 @@ function preview(keys) {
|
|
|
3641
3634
|
const head = keys.slice(0, PREVIEW).join(", ");
|
|
3642
3635
|
return keys.length > PREVIEW ? `${head}, …` : head;
|
|
3643
3636
|
}
|
|
3644
|
-
|
|
3645
|
-
//#region src/inline.ts
|
|
3637
|
+
// src/inline.ts
|
|
3646
3638
|
const OPEN_TAG = /^<([a-zA-Z][a-zA-Z0-9-]*)\s*(\/?)>/;
|
|
3647
3639
|
const BREAK = /^(?:br|wbr)$/;
|
|
3648
3640
|
function messageToInline(text) {
|
|
@@ -3858,8 +3850,7 @@ function attr(attrs, name) {
|
|
|
3858
3850
|
const value = new RegExp(`\\b${name}\\s*=\\s*"([^"]*)"`).exec(attrs)?.[1];
|
|
3859
3851
|
return value === void 0 ? void 0 : unescapeXml(value);
|
|
3860
3852
|
}
|
|
3861
|
-
|
|
3862
|
-
//#region src/mobile.ts
|
|
3853
|
+
// src/mobile.ts
|
|
3863
3854
|
function androidValuesDir(locale, sourceLocale) {
|
|
3864
3855
|
if (locale === sourceLocale) return "values";
|
|
3865
3856
|
const parts = locale.split("-");
|
|
@@ -3897,8 +3888,7 @@ function androidText(text) {
|
|
|
3897
3888
|
function iosText(text) {
|
|
3898
3889
|
return text.replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/\n/g, "\\n").replace(/\t/g, "\\t");
|
|
3899
3890
|
}
|
|
3900
|
-
|
|
3901
|
-
//#region src/po.ts
|
|
3891
|
+
// src/po.ts
|
|
3902
3892
|
function toPo(sourceLocale, locale, entries) {
|
|
3903
3893
|
return [
|
|
3904
3894
|
[
|
|
@@ -3993,8 +3983,7 @@ function poUnquote(text) {
|
|
|
3993
3983
|
return ch;
|
|
3994
3984
|
});
|
|
3995
3985
|
}
|
|
3996
|
-
|
|
3997
|
-
//#region src/translate.ts
|
|
3986
|
+
// src/translate.ts
|
|
3998
3987
|
const RETRY_STATUS = /* @__PURE__ */ new Set([
|
|
3999
3988
|
408,
|
|
4000
3989
|
409,
|
|
@@ -4173,7 +4162,7 @@ function formatTranslateFailures(failed) {
|
|
|
4173
4162
|
async function resolveProvider(cfg, model) {
|
|
4174
4163
|
const configured = cfg.translate.provider;
|
|
4175
4164
|
if (typeof configured === "function") return configured;
|
|
4176
|
-
const { claudeProvider } = await import("./claude-
|
|
4165
|
+
const { claudeProvider } = await import("./claude-DZkzlC5g.js");
|
|
4177
4166
|
return claudeProvider({ model: model ?? cfg.translate.model });
|
|
4178
4167
|
}
|
|
4179
4168
|
function structureMatches(source, translated) {
|
|
@@ -4203,8 +4192,7 @@ function glossaryFor(cfg, locale, messages) {
|
|
|
4203
4192
|
}
|
|
4204
4193
|
return Object.keys(out).length > 0 ? out : void 0;
|
|
4205
4194
|
}
|
|
4206
|
-
|
|
4207
|
-
//#region src/exchange.ts
|
|
4195
|
+
// src/exchange.ts
|
|
4208
4196
|
function isMobileFormat(format) {
|
|
4209
4197
|
return format === "android-xml" || format === "ios-strings";
|
|
4210
4198
|
}
|
|
@@ -4464,8 +4452,7 @@ function csvRows(content) {
|
|
|
4464
4452
|
if (row.some((cell) => cell !== "")) rows.push(row);
|
|
4465
4453
|
return rows;
|
|
4466
4454
|
}
|
|
4467
|
-
|
|
4468
|
-
//#region src/render.ts
|
|
4455
|
+
// src/render.ts
|
|
4469
4456
|
function localeInstance(catalogs, locale, sourceLocale) {
|
|
4470
4457
|
return createVerbaly({
|
|
4471
4458
|
locale,
|
|
@@ -4914,8 +4901,7 @@ function escapeAttr(text) {
|
|
|
4914
4901
|
function decodeEntities(text) {
|
|
4915
4902
|
return text.replace(/"/g, "\"").replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&");
|
|
4916
4903
|
}
|
|
4917
|
-
|
|
4918
|
-
//#region src/watch.ts
|
|
4904
|
+
// src/watch.ts
|
|
4919
4905
|
const NATIVE_TREE = process.platform === "darwin" || process.platform === "win32";
|
|
4920
4906
|
function watchTree(root, options, onFile) {
|
|
4921
4907
|
const watchers = /* @__PURE__ */ new Map();
|
|
@@ -5000,8 +4986,7 @@ function watchProject(cfg, run, options = {}) {
|
|
|
5000
4986
|
close();
|
|
5001
4987
|
};
|
|
5002
4988
|
}
|
|
5003
|
-
|
|
5004
|
-
//#region src/wrap.ts
|
|
4989
|
+
// src/wrap.ts
|
|
5005
4990
|
const WRAP_ATTRS = /* @__PURE__ */ new Set([
|
|
5006
4991
|
"title",
|
|
5007
4992
|
"alt",
|
|
@@ -5276,8 +5261,7 @@ function trailingWs(text) {
|
|
|
5276
5261
|
function line(node) {
|
|
5277
5262
|
return node.loc?.start?.line ?? 1;
|
|
5278
5263
|
}
|
|
5279
|
-
|
|
5280
|
-
//#region src/run.ts
|
|
5264
|
+
// src/run.ts
|
|
5281
5265
|
const HELP = `verbaly · i18n compiler
|
|
5282
5266
|
|
|
5283
5267
|
Usage:
|
|
@@ -5869,5 +5853,4 @@ function rejectStrayFlags(command, values) {
|
|
|
5869
5853
|
process.exitCode = 1;
|
|
5870
5854
|
return true;
|
|
5871
5855
|
}
|
|
5872
|
-
|
|
5873
|
-
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 };
|
|
5856
|
+
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 _, parseCatalog as _t, formatRenderWarnings as a, APP_ID as at, SOURCE_FILE_RE as b, mergeTranslations as c, clientCatalogs as ct, writeDrafts as d, loadConfig as dt, extractProject as et, doctor as f, resolveConfig as ft, status as g, needsRelative as gt, formatStatusResult as h, needsIcu as ht, watchTree as i, stableKey as it, init as j, formatCheckResult as k, resolveProvider as l, counted as lt, formatDoctorHealth as m, loadCatalogs as mt, runCli as n, shippedCatalogs as nt, renderSite as o, LOCALE_IMPORT as ot, formatDoctorEntry as p, targetLocales as pt, generateDts as q, wrapProject as r, syncCatalogs as rt, formatTranslateFailures as s, MessageRegistry as st, formatCliError as t, pruneCatalogs as tt, translateCatalogs as u, isModuleNotFound as ut, LOCALE_MODULE_PREFIX as v, readCatalog as vt, resolveVirtualId as w, createSourceFilter as x, RESOLVED_VIRTUAL_ID as y, writeCatalog as yt, readState as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verbaly/compiler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.78.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.78.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",
|