@verbaly/compiler 0.78.0 → 0.80.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 CHANGED
@@ -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
 
@@ -231,7 +231,7 @@ import { switchLocale } from 'verbaly/app';
231
231
  await switchLocale('es');
232
232
  ```
233
233
 
234
- Under a prefix mode that goes to `/es/…`, which is already rendered in Spanish, so there is no catalog to fetch and no flash. Under `no-prefix` it swaps the text where it stands and the address never changes. Either way it remembers the choice, in the cookie a server reads **and** in the storage the pre-paint redirect reads, and it sets `<html lang>` and `<html dir>`. Pass your framework's router so the app survives the switch:
234
+ Under a prefix mode that goes to `/es/…`, which is already rendered in Spanish, so there is no catalog to fetch and no flash. Under `no-prefix` it swaps the text where it stands and the address never changes. Either way it remembers the choice, in the cookie a server reads **and** in the storage the pre-paint redirect reads, and it sets `<html lang>` and `<html dir>`. A single-page app has neither a server nor a redirect, and starts in its source language: read the choice back before the first render with `setLocale(resolveLocale({ supported: locales, path: false })).then(render)`. Pass your framework's router so the app survives the switch:
235
235
 
236
236
  ```ts
237
237
  await switchLocale('es', { navigate: (path) => router.push(path) });
@@ -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` `APP_ID` `LOCALE_IMPORT` `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,9 @@ 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
+ `transformSource` also loads `verbaly/app` in a file that imports `@verbaly/react`, `@verbaly/vue` or `@verbaly/svelte`, on that import's own line, since their hooks read its instance when no provider is above them. `transformCode` alone, which Next's loader calls, does not.
395
+
396
+ 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
397
 
396
398
  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
399
 
@@ -1,5 +1,5 @@
1
- import { lt as counted, ut as isModuleNotFound } from "./run-kySCrf3Z.js";
2
- // src/providers/claude.ts
1
+ import { _t as isModuleNotFound, ut as counted } from "./run-DTmm0EUF.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
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { n as runCli, t as formatCliError } from "./run-kySCrf3Z.js";
2
+ import { n as runCli, t as formatCliError } from "./run-DTmm0EUF.js";
3
3
  // src/cli.ts
4
4
  runCli().catch((error) => {
5
5
  console.error(formatCliError(error));
package/dist/index.d.ts CHANGED
@@ -56,6 +56,8 @@ interface Analysis {
56
56
  strayImports: StrayImport[];
57
57
  missed: MissedCall[];
58
58
  parseError?: string;
59
+ adapterImport?: number;
60
+ appImported?: true;
59
61
  }
60
62
  interface Collision {
61
63
  key: string;
@@ -367,7 +369,9 @@ interface TransformResult {
367
369
  code: string;
368
370
  map: ReturnType<MagicString['generateMap']>;
369
371
  }
370
- export declare function transformCode(code: string, file: string, analysis?: Analysis): TransformResult | null;
372
+ export declare function transformCode(code: string, file: string, analysis?: Analysis, options?: {
373
+ appImport?: boolean;
374
+ }): TransformResult | null;
371
375
  interface PluginOptions extends VerbalyConfig {
372
376
  failOnMissing?: boolean;
373
377
  liveExtraction?: boolean;
@@ -383,6 +387,7 @@ export declare function transformSource(code: string, id: string, registry: Mess
383
387
  messages: Catalog;
384
388
  result: TransformResult | null;
385
389
  };
390
+ export declare function writeBuildTypes(cfg: ResolvedConfig, catalogs: Catalogs): void;
386
391
  export declare function runBuildGate(cfg: ResolvedConfig, registry: MessageRegistry, failOnMissing?: boolean): void;
387
392
  export declare function reportOutsideInclude(cfg: ResolvedConfig): Promise<void>;
388
393
  type IssueSeverity = 'error' | 'warning';
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 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
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-DTmm0EUF.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 { 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 };
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 };