@verbaly/compiler 0.77.0 → 0.79.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 +9 -9
- package/dist/{claude-CHpftMVn.js → claude-BtdaNZEw.js} +2 -2
- package/dist/cli.js +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -3
- package/dist/{run-D9RNsrMs.js → run-DobJrwby.js} +1465 -1414
- package/package.json +2 -2
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();
|
|
@@ -154,7 +154,7 @@ The types are one generated file, written where your framework's TypeScript alre
|
|
|
154
154
|
| Nuxt | `.nuxt/verbaly.d.ts`, the slot Nuxt gives modules |
|
|
155
155
|
| Vite, SvelteKit, webpack, Rollup, esbuild, Rspack, or the CLI alone | `src/verbaly.d.ts`, the folder every app template includes, or `verbaly.d.ts` when there is no `src/` |
|
|
156
156
|
|
|
157
|
-
`extract`, `typegen`, the dev servers, Studio and the MCP server all write that same file, and `dts` in your config still names another one (`dts: false` writes none). A `verbaly.d.ts` an older Verbaly left at the root is removed the first time the new one is written, because the two would declare the same module; one you wrote yourself, without the generated header, is left alone.
|
|
157
|
+
`extract`, `typegen`, the dev servers, every build, Studio and the MCP server all write that same file, and `dts` in your config still names another one (`dts: false` writes none). A `verbaly.d.ts` an older Verbaly left at the root is removed the first time the new one is written, because the two would declare the same module; one you wrote yourself, without the generated header, is left alone.
|
|
158
158
|
|
|
159
159
|
In CI, write the types before you check them, since a fresh clone has none: `npx verbaly typegen && tsc --noEmit`. In Next, `next typegen` writes them as well, because it loads the same config: `next typegen && tsc --noEmit`.
|
|
160
160
|
|
|
@@ -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` `writeBuildTypes` `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` |
|
|
@@ -391,7 +391,7 @@ runBuildGate(cfg, registry);
|
|
|
391
391
|
|
|
392
392
|
Your plugin's options go second and `{ plugin: true }` third: when one the command line also reads (`sourceLocale`, `locales`, `dir`, `include`, `exclude`) differs from `verbaly.config`, the build says once to move it there, since `verbaly check` never reads a bundler config.
|
|
393
393
|
|
|
394
|
-
A build that scans first, as the Vite plugin does to sync the catalogs, keeps that scan with `extractProject(cfg, { keepSource: true })` and passes it as the fourth argument of `transformSource`: a file it read unchanged is not parsed a second time. Call `reportOutsideInclude(cfg)` once when your build starts: it names every file outside `include` that writes a `` t`…` ``, which no build translates. It reads the project itself, so a cached transform never hides one. `writeDts(cfg, catalog)` writes the types where the config resolves them and returns the file and whether it changed.
|
|
394
|
+
A build that scans first, as the Vite plugin does to sync the catalogs, keeps that scan with `extractProject(cfg, { keepSource: true })` and passes it as the fourth argument of `transformSource`: a file it read unchanged is not parsed a second time. Call `reportOutsideInclude(cfg)` once when your build starts: it names every file outside `include` that writes a `` t`…` ``, which no build translates. It reads the project itself, so a cached transform never hides one. `writeDts(cfg, catalog)` writes the types where the config resolves them and returns the file and whether it changed. A build calls `writeBuildTypes(cfg, catalogs)` once it has synced the catalogs: it writes the same file, and a checkout it cannot write gets a warning instead of a failed build.
|
|
395
395
|
|
|
396
396
|
A dev server that writes the catalogs goes through `syncProject`, the same path `extract`, the MCP server and Studio take: it scans (or takes the registry you hold), syncs, writes the catalogs and the types, and keeps `verbaly.lock` in step, in that order; its `findings` say once when that file first appears. Pass `confirm: true` when your registry is built file by file, so a file that changed on disk unseen is read again before its text is written back. `createDevReporter` then says each of its findings once, says it again if it goes away and comes back, and keeps a long list to a few lines.
|
|
397
397
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
// src/providers/claude.ts
|
|
1
|
+
import { _t as isModuleNotFound, ut as counted } from "./run-DobJrwby.js";
|
|
2
|
+
// src/exchange/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",
|
package/dist/cli.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -361,6 +361,8 @@ interface DtsWrite {
|
|
|
361
361
|
changed: boolean;
|
|
362
362
|
}
|
|
363
363
|
export declare function writeDts(cfg: ResolvedConfig, catalog: Catalog, file?: string | false): DtsWrite | undefined;
|
|
364
|
+
export declare const APP_ID = "verbaly/app";
|
|
365
|
+
export declare const LOCALE_IMPORT = "@verbaly/app/locale/";
|
|
364
366
|
interface TransformResult {
|
|
365
367
|
code: string;
|
|
366
368
|
map: ReturnType<MagicString['generateMap']>;
|
|
@@ -381,6 +383,7 @@ export declare function transformSource(code: string, id: string, registry: Mess
|
|
|
381
383
|
messages: Catalog;
|
|
382
384
|
result: TransformResult | null;
|
|
383
385
|
};
|
|
386
|
+
export declare function writeBuildTypes(cfg: ResolvedConfig, catalogs: Catalogs): void;
|
|
384
387
|
export declare function runBuildGate(cfg: ResolvedConfig, registry: MessageRegistry, failOnMissing?: boolean): void;
|
|
385
388
|
export declare function reportOutsideInclude(cfg: ResolvedConfig): Promise<void>;
|
|
386
389
|
type IssueSeverity = 'error' | 'warning';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
// src/drafts.ts
|
|
1
|
+
import { $ as validatePair, A as check, B as readState, C as isTransformTarget, D as transformSource, E as runBuildGate, F as clearDrafts, G as createDevReporter, H as saveState, I as effectiveDrafts, J as generateDts, K as formatCollision, L as loadState, M as formatCheckWarnings, N as syncProject, O as writeBuildTypes, P as STATE_FILE, Q as validateMessage, R as markDrafts, S as createSourceFilter, T as resolveVirtualId, U as updateState, V as recordTranslations, W as collisionEntries, X as generateRuntimeModule, Y as generateLocaleModule, Z as writeDts, _ as status, a as renderSite, at as stableKey, b as RESOLVED_VIRTUAL_ID, bt as targetLocales, c as formatTranslateFailures, ct as MessageRegistry, d as translateCatalogs, dt as loadCatalogs, et as collectOrigins, f as writeDrafts, ft as needsIcu, g as formatStatusResult, gt as writeCatalog, h as formatDoctorHealth, ht as readCatalog, i as formatRenderWarnings, it as syncCatalogs, j as formatCheckResult, k as transformCode, l as mergeTranslations, lt as clientCatalogs, m as formatDoctorEntry, mt as parseCatalog, nt as pruneCatalogs, o as init, ot as APP_ID, p as doctor, pt as needsRelative, q as formatFinding, r as wrapProject, rt as shippedCatalogs, s as watchTree, st as LOCALE_IMPORT, t as formatCliError, tt as extractProject, u as resolveProvider, ut as counted, v as reportOutsideInclude, vt as loadConfig, w as loadVirtualModule, x as SOURCE_FILE_RE, y as LOCALE_MODULE_PREFIX, yt as resolveConfig, z as outdatedTranslations } from "./run-DobJrwby.js";
|
|
2
|
+
// src/catalog/drafts.ts
|
|
3
3
|
function loadDrafts(cfg) {
|
|
4
4
|
return loadState(cfg).drafts;
|
|
5
5
|
}
|
|
@@ -10,4 +10,4 @@ function saveDrafts(cfg, drafts) {
|
|
|
10
10
|
drafts
|
|
11
11
|
});
|
|
12
12
|
}
|
|
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 };
|
|
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, writeBuildTypes, writeCatalog, writeDrafts, writeDts };
|