@verbaly/next 0.80.0 → 0.82.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
@@ -11,7 +11,7 @@
11
11
 
12
12
  ---
13
13
 
14
- Server Components render already translated in the visitor's language (cookie first, then `Accept-Language`, then your fallback) and Client Components hydrate with the **same locale and the same catalog**: no flash of untranslated text, no hydration mismatch. Each request gets its **own instance** (React `cache()`): no locale leaking between concurrent users.
14
+ Server Components render already translated in the visitor's language (the address first when your URLs carry it, then the cookie, then `Accept-Language`, then your fallback) and Client Components hydrate with the **same locale and the same catalog**: no flash of untranslated text, no hydration mismatch. Each request gets its **own instance** (React `cache()`): no locale leaking between concurrent users.
15
15
 
16
16
  Works with **Turbopack** (the Next 16 default) and webpack: the config wrapper generates the runtime module as real files and wires the `t`-template compiler as a loader for both. The loader rewrites exactly the files `verbaly extract` reads (your config's `include` and `exclude`), so a code sample in a file outside them keeps its `` t`…` `` as written.
17
17
 
package/dist/index.cjs CHANGED
@@ -4,37 +4,16 @@ let node_fs = require("node:fs");
4
4
  let node_module = require("node:module");
5
5
  // src/report.ts
6
6
  const reporters = /* @__PURE__ */ new Map();
7
- const brokenState = /* @__PURE__ */ new Set();
8
7
  function reportDev(compiler, cfg, result, previous) {
9
8
  let reporter = reporters.get(cfg.root);
10
9
  if (!reporter) {
11
10
  reporter = compiler.createDevReporter(cfg.root);
12
11
  reporters.set(cfg.root, reporter);
13
12
  }
14
- const replaced = [];
15
- const code = [];
16
- const lock = [];
17
- for (const finding of result.findings) {
18
- if (finding.kind === "collision" || finding.kind === "renamed") code.push(finding);
19
- if (finding.kind === "lock") lock.push(finding);
20
- if (finding.kind !== "replaced") continue;
21
- if (previous && previous.get(finding.key) !== finding.site.message) continue;
22
- replaced.push({
23
- ...finding,
24
- edited: previous !== void 0
25
- });
26
- }
27
- reporter.report("replaced", replaced);
28
- reporter.report("code", code);
29
- reporter.report("lock", lock);
30
- const outdated = result.state ? compiler.outdatedTranslations(cfg, result.catalogs, result.state.fingerprints) : [];
31
- reporter.report("outdated", outdated.map((entry) => ({
32
- kind: "outdated",
33
- ...entry
34
- })));
35
- if (result.stateProblem && !brokenState.has(cfg.root)) console.warn(`[verbaly] ${result.stateProblem}, so drafts are not tracked`);
36
- if (result.stateProblem) brokenState.add(cfg.root);
37
- else brokenState.delete(cfg.root);
13
+ reporter.sync(cfg, result, (finding) => {
14
+ if (previous && previous.get(finding.key) !== finding.site.message) return void 0;
15
+ return previous !== void 0;
16
+ });
38
17
  return new Map([...result.registry.messages()].map(([key, msg]) => [key, msg.message]));
39
18
  }
40
19
  // src/root-params.ts
@@ -139,18 +118,14 @@ function writeGeneratedModules(compiler, cfg, catalogs, requestOptions = {}) {
139
118
  const localeDir = (0, node_path.join)(dir, "locale");
140
119
  (0, node_fs.mkdirSync)(localeDir, { recursive: true });
141
120
  let changed = writeIfChanged((0, node_path.join)(dir, ".gitignore"), "*\n");
142
- const client = compiler.clientCatalogs(cfg, catalogs);
143
- const runtime = compiler.generateRuntimeModule(cfg, {
121
+ const modules = compiler.clientModules(cfg, catalogs, {
144
122
  localeImport: (locale) => `./locale/${locale}.js`,
145
- extraExports: `export const requestOptions = ${JSON.stringify(requestOptions)};\n`,
146
- icu: cfg.icu ?? compiler.needsIcu(client),
147
- relative: cfg.relative ?? compiler.needsRelative(client),
148
- inlineCatalog: cfg.render.inlineCatalog === true
123
+ extraExports: `export const requestOptions = ${JSON.stringify(requestOptions)};\n`
149
124
  });
150
- changed = writeIfChanged((0, node_path.join)(dir, "index.js"), runtime) || changed;
125
+ changed = writeIfChanged((0, node_path.join)(dir, "index.js"), modules.runtime()) || changed;
151
126
  changed = writeIfChanged((0, node_path.join)(dir, "server.js"), generateServerModule(cfg)) || changed;
152
127
  const expected = new Set(cfg.locales.map((locale) => `${locale}.js`));
153
- for (const locale of cfg.locales) changed = writeIfChanged((0, node_path.join)(localeDir, `${locale}.js`), compiler.generateLocaleModule(client[locale] ?? {})) || changed;
128
+ for (const locale of cfg.locales) changed = writeIfChanged((0, node_path.join)(localeDir, `${locale}.js`), modules.locale(locale)) || changed;
154
129
  for (const file of (0, node_fs.readdirSync)(localeDir)) if (!expected.has(file)) {
155
130
  (0, node_fs.rmSync)((0, node_path.join)(localeDir, file));
156
131
  changed = true;
package/dist/index.js CHANGED
@@ -3,37 +3,16 @@ import { basename, dirname, join, relative } from "node:path";
3
3
  import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
4
4
  // src/report.ts
5
5
  const reporters = /* @__PURE__ */ new Map();
6
- const brokenState = /* @__PURE__ */ new Set();
7
6
  function reportDev(compiler, cfg, result, previous) {
8
7
  let reporter = reporters.get(cfg.root);
9
8
  if (!reporter) {
10
9
  reporter = compiler.createDevReporter(cfg.root);
11
10
  reporters.set(cfg.root, reporter);
12
11
  }
13
- const replaced = [];
14
- const code = [];
15
- const lock = [];
16
- for (const finding of result.findings) {
17
- if (finding.kind === "collision" || finding.kind === "renamed") code.push(finding);
18
- if (finding.kind === "lock") lock.push(finding);
19
- if (finding.kind !== "replaced") continue;
20
- if (previous && previous.get(finding.key) !== finding.site.message) continue;
21
- replaced.push({
22
- ...finding,
23
- edited: previous !== void 0
24
- });
25
- }
26
- reporter.report("replaced", replaced);
27
- reporter.report("code", code);
28
- reporter.report("lock", lock);
29
- const outdated = result.state ? compiler.outdatedTranslations(cfg, result.catalogs, result.state.fingerprints) : [];
30
- reporter.report("outdated", outdated.map((entry) => ({
31
- kind: "outdated",
32
- ...entry
33
- })));
34
- if (result.stateProblem && !brokenState.has(cfg.root)) console.warn(`[verbaly] ${result.stateProblem}, so drafts are not tracked`);
35
- if (result.stateProblem) brokenState.add(cfg.root);
36
- else brokenState.delete(cfg.root);
12
+ reporter.sync(cfg, result, (finding) => {
13
+ if (previous && previous.get(finding.key) !== finding.site.message) return void 0;
14
+ return previous !== void 0;
15
+ });
37
16
  return new Map([...result.registry.messages()].map(([key, msg]) => [key, msg.message]));
38
17
  }
39
18
  // src/root-params.ts
@@ -138,18 +117,14 @@ function writeGeneratedModules(compiler, cfg, catalogs, requestOptions = {}) {
138
117
  const localeDir = join(dir, "locale");
139
118
  mkdirSync(localeDir, { recursive: true });
140
119
  let changed = writeIfChanged(join(dir, ".gitignore"), "*\n");
141
- const client = compiler.clientCatalogs(cfg, catalogs);
142
- const runtime = compiler.generateRuntimeModule(cfg, {
120
+ const modules = compiler.clientModules(cfg, catalogs, {
143
121
  localeImport: (locale) => `./locale/${locale}.js`,
144
- extraExports: `export const requestOptions = ${JSON.stringify(requestOptions)};\n`,
145
- icu: cfg.icu ?? compiler.needsIcu(client),
146
- relative: cfg.relative ?? compiler.needsRelative(client),
147
- inlineCatalog: cfg.render.inlineCatalog === true
122
+ extraExports: `export const requestOptions = ${JSON.stringify(requestOptions)};\n`
148
123
  });
149
- changed = writeIfChanged(join(dir, "index.js"), runtime) || changed;
124
+ changed = writeIfChanged(join(dir, "index.js"), modules.runtime()) || changed;
150
125
  changed = writeIfChanged(join(dir, "server.js"), generateServerModule(cfg)) || changed;
151
126
  const expected = new Set(cfg.locales.map((locale) => `${locale}.js`));
152
- for (const locale of cfg.locales) changed = writeIfChanged(join(localeDir, `${locale}.js`), compiler.generateLocaleModule(client[locale] ?? {})) || changed;
127
+ for (const locale of cfg.locales) changed = writeIfChanged(join(localeDir, `${locale}.js`), modules.locale(locale)) || changed;
153
128
  for (const file of readdirSync(localeDir)) if (!expected.has(file)) {
154
129
  rmSync(join(localeDir, file));
155
130
  changed = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verbaly/next",
3
- "version": "0.80.0",
3
+ "version": "0.82.0",
4
4
  "description": "Next.js integration for Verbaly: App Router/RSC with per-request locale negotiation, Turbopack and webpack support, flash-free hydration.",
5
5
  "keywords": [
6
6
  "i18n",
@@ -68,23 +68,23 @@
68
68
  "access": "public"
69
69
  },
70
70
  "dependencies": {
71
- "@verbaly/compiler": "^0.80.0"
71
+ "@verbaly/compiler": "^0.82.0"
72
72
  },
73
73
  "peerDependencies": {
74
- "@verbaly/react": "^0.80.0",
74
+ "@verbaly/react": "^0.82.0",
75
75
  "next": "^15.0.0 || ^16.0.0",
76
76
  "react": "^18.0.0 || ^19.0.0",
77
- "verbaly": "^0.80.0"
77
+ "verbaly": "^0.82.0"
78
78
  },
79
79
  "devDependencies": {
80
80
  "@types/react": "^19.3.0",
81
81
  "@types/react-dom": "^19.3.0",
82
- "@verbaly/react": "^0.80.0",
82
+ "@verbaly/react": "^0.82.0",
83
83
  "happy-dom": "^21.0.4",
84
- "next": "^16.4.5",
84
+ "next": "^16.4.6",
85
85
  "react": "^19.3.1",
86
86
  "react-dom": "^19.3.1",
87
- "verbaly": "^0.80.0"
87
+ "verbaly": "^0.82.0"
88
88
  },
89
89
  "scripts": {
90
90
  "build": "tsdown",