@verbaly/next 0.75.0 → 0.77.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -138,8 +138,13 @@ export default {
138
138
  };
139
139
  ```
140
140
 
141
- Then hand Verbaly the segment. This is what keeps the route statically rendered, because the
142
- alternative is reading request headers:
141
+ Then hand Verbaly the segment. **On Next 16.3 and later there is nothing to write**: with the
142
+ segment in your root layout (`app/[locale]/layout.tsx`), Verbaly reads it through
143
+ `next/root-params` in every layout, page, `generateMetadata` and `'use cache'` function, so the
144
+ route prerenders and no request header is read. **On Next 15 up to 16.2, call `setRequestLocale` in
145
+ every layout and every page of the tree**: Next can render a page without running its layout, and
146
+ a page that finds no locale reads the cookie instead of the url (it warns once when that happens).
147
+ Inside a `'use cache'` function there, pass the language: `getT({ locale })`.
143
148
 
144
149
  ```tsx
145
150
  // app/[locale]/layout.tsx
@@ -158,13 +163,13 @@ export async function generateMetadata({ params }: { params: Promise<{ locale: s
158
163
 
159
164
  export default async function LocaleLayout({ children, params }) {
160
165
  const { locale } = await params;
161
- setRequestLocale(locale); // before any getT() in this tree
166
+ setRequestLocale(locale); // Next 15 to 16.2: in every layout and page of the tree
162
167
  return <VerbalyProvider {...await getVerbalyProps()}>{children}</VerbalyProvider>;
163
168
  }
164
169
  ```
165
170
 
166
- Without `setRequestLocale`, Verbaly negotiates from the cookie and `Accept-Language`, and that read
167
- is what makes the route dynamic. With it, no header is read at all.
171
+ Where neither declares the language, Verbaly negotiates from the cookie and `Accept-Language`, and
172
+ that read is what makes the route dynamic. With either, no header is read at all.
168
173
 
169
174
  **Keys are typed.** `getT()` and `useT()` check every key and its params against your catalog, and `getRequestLocale()` returns one of your locales, so `ogLocale[await getRequestLocale()]` needs no cast. The types live in `.verbaly/types.d.ts`, next to the generated modules and never committed; TypeScript skips a dot folder, so Verbaly adds that file to the `include` of your `tsconfig.json`, the way Next adds `.next/types`. On a fresh clone, `next typegen && tsc --noEmit` writes them before it checks them.
170
175
 
@@ -176,14 +181,16 @@ The report rides on `compiler.runAfterProductionCompile`, and `withVerbaly` keep
176
181
 
177
182
  Second argument of `withVerbaly`: every [`verbaly.config`](https://www.npmjs.com/package/@verbaly/compiler) option, plus:
178
183
 
179
- | Option | What it does |
180
- | --------------- | ------------------------------------------------------------------------------------------------------- |
181
- | `cookie` | Cookie read/written for the user's choice (default `verbaly-locale`); `false` = `Accept-Language` only. |
182
- | `fallback` | Locale when nothing matches (defaults to the source locale). |
183
- | `failOnMissing` | `true` stops `next build` on whatever fails `verbaly check`; by default the build reports and goes on. |
184
+ | Option | What it does |
185
+ | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
186
+ | `cookie` | Cookie read/written for the user's choice (default `verbaly-locale`); `false` = `Accept-Language` only. |
187
+ | `fallback` | Locale when nothing matches (defaults to the source locale). |
188
+ | `failOnMissing` | `true` stops `next build` on whatever fails `verbaly check`; by default the build reports and goes on. |
189
+ | `liveExtraction` | `false` keeps `next dev` from writing your translation files: new texts render from memory, as in a build, and `npx verbaly extract` writes them. |
184
190
 
185
- - **Negotiation reads `headers()`/`cookies()`, which makes a route dynamic.** Call `setRequestLocale` with your `[locale]` segment and that read never happens, so the route prerenders. For a fully static site with no server at all, [`verbaly render`](https://www.npmjs.com/package/@verbaly/compiler) mirrors the output per locale.
191
+ - **Negotiation reads `headers()`/`cookies()`, which makes a route dynamic.** With your `[locale]` segment in the root layout (read by itself on Next 16.3 and later, or declared with `setRequestLocale` before that) that read never happens, so the route prerenders. For a fully static site with no server at all, [`verbaly render`](https://www.npmjs.com/package/@verbaly/compiler) mirrors the output per locale.
186
192
  - `getAlternates({ path, baseUrl? })` returns `{ canonical, languages }` for `generateMetadata`, the same hreflang set the static mirror writes. It is empty under `no-prefix` routing, where one URL answers every language.
193
+ - Every url Verbaly builds (`getAlternates`, `localePath`, `useSwitchLocale`) follows your `trailingSlash` in `next.config`, so by default the Spanish home is `/es`, the form Next serves, and never `/es/`, which it redirects.
187
194
  - The generated `.verbaly/` directory is build output (it ships its own `.gitignore`).
188
195
 
189
196
  ## 📚 Docs
package/dist/client.d.ts CHANGED
@@ -2,12 +2,9 @@ import { VerbalyProviderProps as VerbalyProviderProps$1 } from "./server.js";
2
2
  import { ReactElement, ReactNode } from "react";
3
3
  import { SwitchLocaleOptions } from "verbaly";
4
4
  import { Trans, useLocale, useT, useVerbaly } from "@verbaly/react";
5
- //#region src/client.d.ts
6
5
  export interface VerbalyProviderProps extends VerbalyProviderProps$1 {
7
6
  children?: ReactNode;
8
7
  }
9
8
  export declare function VerbalyProvider(props: VerbalyProviderProps): ReactElement;
10
9
  export declare function useSwitchLocale(): (locale: string, options?: SwitchLocaleOptions) => Promise<void>;
11
- //#endregion
12
- export { Trans, useLocale, useT, useVerbaly };
13
- //# sourceMappingURL=client.d.ts.map
10
+ export { Trans, useLocale, useT, useVerbaly };
package/dist/client.js CHANGED
@@ -1,10 +1,10 @@
1
1
  "use client";
2
2
  import { createElement, useCallback, useEffect, useState } from "react";
3
3
  import { switchLocale } from "verbaly";
4
- import { createInstance, locales, requestOptions, routing, sourceLocale } from "virtual:verbaly";
4
+ import { createInstance, locales, requestOptions, routing, sourceLocale, trailingSlash } from "virtual:verbaly";
5
5
  import { useRouter } from "next/navigation";
6
6
  import { Trans, VerbalyProvider as VerbalyProvider$1, useLocale, useT, useVerbaly, useVerbaly as useVerbaly$1 } from "@verbaly/react";
7
- //#region src/client.ts
7
+ // src/client.ts
8
8
  function VerbalyProvider(props) {
9
9
  const [instance] = useState(() => {
10
10
  const created = createInstance({
@@ -36,6 +36,7 @@ function useSwitchLocale() {
36
36
  routing,
37
37
  supported: locales,
38
38
  sourceLocale,
39
+ trailingSlash,
39
40
  navigate: (path) => router.push(path),
40
41
  ...options
41
42
  };
@@ -44,7 +45,4 @@ function useSwitchLocale() {
44
45
  if (!routed) router.refresh();
45
46
  }, [instance, router]);
46
47
  }
47
- //#endregion
48
48
  export { Trans, VerbalyProvider, useLocale, useSwitchLocale, useT, useVerbaly };
49
-
50
- //# sourceMappingURL=client.js.map
package/dist/index.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let node_path = require("node:path");
2
3
  let node_fs = require("node:fs");
3
4
  let node_module = require("node:module");
4
- let node_path = require("node:path");
5
- //#region src/report.ts
5
+ // src/report.ts
6
6
  const reporters = /* @__PURE__ */ new Map();
7
7
  const brokenState = /* @__PURE__ */ new Set();
8
8
  function reportDev(compiler, cfg, result, previous) {
@@ -37,8 +37,81 @@ function reportDev(compiler, cfg, result, previous) {
37
37
  else brokenState.delete(cfg.root);
38
38
  return new Map([...result.registry.messages()].map(([key, msg]) => [key, msg.message]));
39
39
  }
40
- //#endregion
41
- //#region src/codegen.ts
40
+ // src/root-params.ts
41
+ const ROOT_PARAMS_SINCE = [16, 3];
42
+ const LAYOUT_FILE = /^layout\.[cm]?[jt]sx?$/;
43
+ const DYNAMIC_SEGMENT = /^\[([A-Za-z_$][\w$]*)\]$/;
44
+ const MAX_DEPTH = 4;
45
+ function resolveFromNext(root, file) {
46
+ for (let dir = root;; dir = (0, node_path.dirname)(dir)) {
47
+ if ((0, node_fs.existsSync)((0, node_path.join)(dir, "node_modules", "next", "package.json"))) {
48
+ const path = (0, node_path.join)(dir, "node_modules", file);
49
+ return (0, node_fs.existsSync)(path) ? path : void 0;
50
+ }
51
+ if ((0, node_path.dirname)(dir) === dir) break;
52
+ }
53
+ if (!process.versions.pnp) return void 0;
54
+ try {
55
+ return (0, node_module.createRequire)((0, node_path.join)(root, "package.json")).resolve(file);
56
+ } catch {
57
+ return;
58
+ }
59
+ }
60
+ const supported = /* @__PURE__ */ new Map();
61
+ function hasRootParams(root) {
62
+ let answer = supported.get(root);
63
+ if (answer === void 0) {
64
+ answer = readRootParamsSupport(root);
65
+ supported.set(root, answer);
66
+ }
67
+ return answer;
68
+ }
69
+ function readRootParamsSupport(root) {
70
+ const manifest = resolveFromNext(root, "next/package.json");
71
+ if (!manifest) return false;
72
+ try {
73
+ const [release = "", prerelease] = String(JSON.parse((0, node_fs.readFileSync)(manifest, "utf8")).version).split("-");
74
+ const [major = 0, minor = 0, patch = 0] = release.split(".").map(Number);
75
+ const [sinceMajor, sinceMinor] = ROOT_PARAMS_SINCE;
76
+ if (prerelease !== void 0 && major === sinceMajor && minor === sinceMinor && patch === 0) return false;
77
+ return major > sinceMajor || major === sinceMajor && minor >= sinceMinor;
78
+ } catch {
79
+ return false;
80
+ }
81
+ }
82
+ function findRootParam(root) {
83
+ const app = [(0, node_path.join)(root, "app"), (0, node_path.join)(root, "src", "app")].find((dir) => (0, node_fs.existsSync)(dir));
84
+ if (!app) return void 0;
85
+ const found = /* @__PURE__ */ new Set();
86
+ const walk = (dir, params, depth) => {
87
+ let entries;
88
+ try {
89
+ entries = (0, node_fs.readdirSync)(dir, { withFileTypes: true });
90
+ } catch {
91
+ return;
92
+ }
93
+ if (entries.some((entry) => entry.isFile() && LAYOUT_FILE.test(entry.name))) {
94
+ found.add(params.length === 1 ? params[0] : void 0);
95
+ return;
96
+ }
97
+ if (depth === MAX_DEPTH) return;
98
+ for (const entry of entries) {
99
+ if (!entry.isDirectory() || /^[_@.]/.test(entry.name) || entry.name === "node_modules") continue;
100
+ const segment = DYNAMIC_SEGMENT.exec(entry.name)?.[1];
101
+ walk((0, node_path.join)(dir, entry.name), segment ? [...params, segment] : params, depth + 1);
102
+ }
103
+ };
104
+ walk(app, [], 0);
105
+ const [only] = found;
106
+ return found.size === 1 ? only : void 0;
107
+ }
108
+ function generateServerModule(cfg) {
109
+ const param = cfg.routing !== "no-prefix" && hasRootParams(cfg.root) ? findRootParam(cfg.root) : void 0;
110
+ if (!param) return "// generated by @verbaly/next: no root segment to read, setRequestLocale declares it\nexport const rootLocale = undefined;\n";
111
+ return `// generated by @verbaly/next: the [${param}] segment of the root layout, through next/root-params\nimport { ${param} as segment } from 'next/root-params';\nexport const rootLocale = segment;
112
+ `;
113
+ }
114
+ // src/codegen.ts
42
115
  const GENERATED_DIR = ".verbaly";
43
116
  function generatedDir(root) {
44
117
  return (0, node_path.join)(root, GENERATED_DIR);
@@ -50,12 +123,14 @@ function writeIfChanged(file, content) {
50
123
  (0, node_fs.writeFileSync)(file, content);
51
124
  return true;
52
125
  }
53
- async function syncAndWrite(compiler, cfg, catalogs, registry, requestOptions, previous) {
126
+ async function syncAndWrite(compiler, cfg, catalogs, registry, requestOptions, previous, live = true) {
54
127
  const result = await compiler.syncProject(cfg, {
55
128
  registry,
56
129
  catalogs,
57
- write: "changed"
130
+ write: "changed",
131
+ dryRun: !live
58
132
  });
133
+ if (!live) compiler.writeDts(cfg, result.catalogs[cfg.sourceLocale] ?? {});
59
134
  writeGeneratedModules(compiler, cfg, result.catalogs, requestOptions);
60
135
  return reportDev(compiler, cfg, result, previous);
61
136
  }
@@ -73,6 +148,7 @@ function writeGeneratedModules(compiler, cfg, catalogs, requestOptions = {}) {
73
148
  inlineCatalog: cfg.render.inlineCatalog === true
74
149
  });
75
150
  changed = writeIfChanged((0, node_path.join)(dir, "index.js"), runtime) || changed;
151
+ changed = writeIfChanged((0, node_path.join)(dir, "server.js"), generateServerModule(cfg)) || changed;
76
152
  const expected = new Set(cfg.locales.map((locale) => `${locale}.js`));
77
153
  for (const locale of cfg.locales) changed = writeIfChanged((0, node_path.join)(localeDir, `${locale}.js`), compiler.generateLocaleModule(client[locale] ?? {})) || changed;
78
154
  for (const file of (0, node_fs.readdirSync)(localeDir)) if (!expected.has(file)) {
@@ -81,10 +157,9 @@ function writeGeneratedModules(compiler, cfg, catalogs, requestOptions = {}) {
81
157
  }
82
158
  return changed;
83
159
  }
84
- //#endregion
85
- //#region src/watch.ts
160
+ // src/watch.ts
86
161
  const active = /* @__PURE__ */ new Map();
87
- function startWatcher(compiler, cfg, requestOptions, startTexts) {
162
+ function startWatcher(compiler, cfg, requestOptions, startTexts, live = true) {
88
163
  const existing = active.get(cfg.root);
89
164
  if (existing) return existing;
90
165
  const catalogDir = (0, node_path.relative)(cfg.root, cfg.dir).replaceAll("\\", "/");
@@ -99,7 +174,7 @@ function startWatcher(compiler, cfg, requestOptions, startTexts) {
99
174
  }
100
175
  running = true;
101
176
  try {
102
- texts = await syncAndWrite(compiler, cfg, compiler.loadCatalogs(cfg), await compiler.extractProject(cfg), requestOptions, texts);
177
+ texts = await syncAndWrite(compiler, cfg, compiler.loadCatalogs(cfg), await compiler.extractProject(cfg), requestOptions, texts, live);
103
178
  } catch (error) {
104
179
  const reason = compiler.formatCliError(error).replace(/^\[verbaly\] /, "");
105
180
  console.warn(`[verbaly] live extraction paused: ${reason}`);
@@ -133,15 +208,15 @@ function startWatcher(compiler, cfg, requestOptions, startTexts) {
133
208
  active.set(cfg.root, dispose);
134
209
  return dispose;
135
210
  }
136
- //#endregion
137
- //#region src/index.ts
211
+ // src/index.ts
138
212
  const DEV_PHASE = "phase-development-server";
139
213
  const BUILD_PHASE = "phase-production-build";
140
214
  const ANALYZE_PHASE = "phase-analyze";
141
215
  const LOADER = "@verbaly/next/loader";
216
+ const SERVER_ID = "virtual:verbaly/server";
142
217
  const SOURCE_PATH_RE = /\.[cm]?[jt]sx?$/;
143
218
  function withVerbaly(nextConfig, options = {}) {
144
- const { failOnMissing, cookie, fallback, ...verbalyConfig } = options;
219
+ const { failOnMissing, liveExtraction, cookie, fallback, ...verbalyConfig } = options;
145
220
  const requestOptions = {
146
221
  cookie,
147
222
  fallback
@@ -151,14 +226,19 @@ function withVerbaly(nextConfig, options = {}) {
151
226
  const root = verbalyConfig.root ?? process.cwd();
152
227
  if (phase !== DEV_PHASE && phase !== BUILD_PHASE && phase !== ANALYZE_PHASE) return composeConfig(base, root);
153
228
  const compiler = await import("@verbaly/compiler");
154
- const cfg = await compiler.loadConfig(root, verbalyConfig, { plugin: true });
229
+ const options = {
230
+ trailingSlash: base.trailingSlash ? "always" : "never",
231
+ ...verbalyConfig
232
+ };
233
+ const cfg = await compiler.loadConfig(root, options, { plugin: true });
155
234
  const catalogs = compiler.loadCatalogs(cfg);
156
235
  const registry = await compiler.extractProject(cfg);
157
236
  await compiler.reportOutsideInclude(cfg);
158
237
  let gate;
159
238
  if (phase === DEV_PHASE) {
160
- const texts = await syncAndWrite(compiler, cfg, catalogs, registry, requestOptions);
161
- startWatcher(compiler, cfg, requestOptions, texts);
239
+ const live = liveExtraction !== false;
240
+ const texts = await syncAndWrite(compiler, cfg, catalogs, registry, requestOptions, void 0, live);
241
+ startWatcher(compiler, cfg, requestOptions, texts, live);
162
242
  } else {
163
243
  compiler.syncCatalogs(cfg, catalogs, registry);
164
244
  writeGeneratedModules(compiler, cfg, catalogs, requestOptions);
@@ -179,21 +259,11 @@ function withVerbaly(nextConfig, options = {}) {
179
259
  }
180
260
  const HOOK_FILE = "next/dist/build/after-production-compile.js";
181
261
  function hasAfterCompileHook(root) {
182
- for (let dir = root;; dir = (0, node_path.dirname)(dir)) {
183
- const next = (0, node_path.join)(dir, "node_modules", "next");
184
- if ((0, node_fs.existsSync)((0, node_path.join)(next, "package.json"))) return (0, node_fs.existsSync)((0, node_path.join)(dir, "node_modules", HOOK_FILE));
185
- if ((0, node_path.dirname)(dir) === dir) break;
186
- }
187
- if (!process.versions.pnp) return false;
188
- try {
189
- (0, node_module.createRequire)((0, node_path.join)(root, "package.json")).resolve(HOOK_FILE);
190
- return true;
191
- } catch {
192
- return false;
193
- }
262
+ return resolveFromNext(root, HOOK_FILE) !== void 0;
194
263
  }
195
264
  function composeConfig(base, root, scope, gate) {
196
265
  const runtimeModule = (0, node_path.join)(generatedDir(root), "index.js");
266
+ const serverModule = (0, node_path.join)(generatedDir(root), "server.js");
197
267
  const { webpack: userWebpack, turbopack, compiler: userCompiler } = base;
198
268
  const loader = scope ? {
199
269
  loader: LOADER,
@@ -224,7 +294,8 @@ function composeConfig(base, root, scope, gate) {
224
294
  ...turbopack,
225
295
  resolveAlias: {
226
296
  ...turbopack?.resolveAlias,
227
- "virtual:verbaly": `./${GENERATED_DIR}/index.js`
297
+ "virtual:verbaly": `./${GENERATED_DIR}/index.js`,
298
+ [SERVER_ID]: `./${GENERATED_DIR}/server.js`
228
299
  },
229
300
  rules
230
301
  },
@@ -232,11 +303,12 @@ function composeConfig(base, root, scope, gate) {
232
303
  const { webpack: webpackInstance } = context ?? {};
233
304
  if (webpackInstance?.NormalModuleReplacementPlugin) {
234
305
  config.plugins ??= [];
235
- config.plugins.push(new webpackInstance.NormalModuleReplacementPlugin(/^virtual:verbaly$/, runtimeModule));
306
+ config.plugins.push(new webpackInstance.NormalModuleReplacementPlugin(/^virtual:verbaly$/, runtimeModule), new webpackInstance.NormalModuleReplacementPlugin(/^virtual:verbaly[/]server$/, serverModule));
236
307
  }
237
308
  config.resolve ??= {};
238
309
  config.resolve.alias ??= {};
239
310
  config.resolve.alias["virtual:verbaly"] = runtimeModule;
311
+ config.resolve.alias[SERVER_ID] = serverModule;
240
312
  config.module ??= {};
241
313
  config.module.rules ??= [];
242
314
  config.module.rules.push({
@@ -249,7 +321,4 @@ function composeConfig(base, root, scope, gate) {
249
321
  }
250
322
  };
251
323
  }
252
- //#endregion
253
324
  exports.withVerbaly = withVerbaly;
254
-
255
- //# sourceMappingURL=index.cjs.map
package/dist/index.d.cts CHANGED
@@ -1,11 +1,8 @@
1
1
  import { PluginOptions, VerbalyConfig } from "@verbaly/compiler";
2
- //#region src/codegen.d.ts
3
2
  interface RequestOptions {
4
3
  cookie?: string | false;
5
4
  fallback?: string;
6
5
  }
7
- //#endregion
8
- //#region src/index.d.ts
9
6
  export interface NextVerbalyOptions extends PluginOptions {
10
7
  cookie?: string | false;
11
8
  fallback?: string;
@@ -41,6 +38,4 @@ export type NextConfigInput<C extends object> = C | ((phase: string, context: {
41
38
  export declare function withVerbaly<C extends object>(nextConfig?: NextConfigInput<C>, options?: NextVerbalyOptions): (phase: string, context?: {
42
39
  defaultConfig?: unknown;
43
40
  }) => Promise<C>;
44
- //#endregion
45
- export type { RequestOptions, VerbalyConfig };
46
- //# sourceMappingURL=index.d.cts.map
41
+ export type { RequestOptions, VerbalyConfig };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,8 @@
1
1
  import { PluginOptions, VerbalyConfig } from "@verbaly/compiler";
2
- //#region src/codegen.d.ts
3
2
  interface RequestOptions {
4
3
  cookie?: string | false;
5
4
  fallback?: string;
6
5
  }
7
- //#endregion
8
- //#region src/index.d.ts
9
6
  export interface NextVerbalyOptions extends PluginOptions {
10
7
  cookie?: string | false;
11
8
  fallback?: string;
@@ -41,6 +38,4 @@ export type NextConfigInput<C extends object> = C | ((phase: string, context: {
41
38
  export declare function withVerbaly<C extends object>(nextConfig?: NextConfigInput<C>, options?: NextVerbalyOptions): (phase: string, context?: {
42
39
  defaultConfig?: unknown;
43
40
  }) => Promise<C>;
44
- //#endregion
45
- export type { RequestOptions, VerbalyConfig };
46
- //# sourceMappingURL=index.d.ts.map
41
+ export type { RequestOptions, VerbalyConfig };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from "node:module";
2
- import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
3
2
  import { basename, dirname, join, relative } from "node:path";
4
- //#region src/report.ts
3
+ import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
4
+ // src/report.ts
5
5
  const reporters = /* @__PURE__ */ new Map();
6
6
  const brokenState = /* @__PURE__ */ new Set();
7
7
  function reportDev(compiler, cfg, result, previous) {
@@ -36,8 +36,81 @@ function reportDev(compiler, cfg, result, previous) {
36
36
  else brokenState.delete(cfg.root);
37
37
  return new Map([...result.registry.messages()].map(([key, msg]) => [key, msg.message]));
38
38
  }
39
- //#endregion
40
- //#region src/codegen.ts
39
+ // src/root-params.ts
40
+ const ROOT_PARAMS_SINCE = [16, 3];
41
+ const LAYOUT_FILE = /^layout\.[cm]?[jt]sx?$/;
42
+ const DYNAMIC_SEGMENT = /^\[([A-Za-z_$][\w$]*)\]$/;
43
+ const MAX_DEPTH = 4;
44
+ function resolveFromNext(root, file) {
45
+ for (let dir = root;; dir = dirname(dir)) {
46
+ if (existsSync(join(dir, "node_modules", "next", "package.json"))) {
47
+ const path = join(dir, "node_modules", file);
48
+ return existsSync(path) ? path : void 0;
49
+ }
50
+ if (dirname(dir) === dir) break;
51
+ }
52
+ if (!process.versions.pnp) return void 0;
53
+ try {
54
+ return createRequire(join(root, "package.json")).resolve(file);
55
+ } catch {
56
+ return;
57
+ }
58
+ }
59
+ const supported = /* @__PURE__ */ new Map();
60
+ function hasRootParams(root) {
61
+ let answer = supported.get(root);
62
+ if (answer === void 0) {
63
+ answer = readRootParamsSupport(root);
64
+ supported.set(root, answer);
65
+ }
66
+ return answer;
67
+ }
68
+ function readRootParamsSupport(root) {
69
+ const manifest = resolveFromNext(root, "next/package.json");
70
+ if (!manifest) return false;
71
+ try {
72
+ const [release = "", prerelease] = String(JSON.parse(readFileSync(manifest, "utf8")).version).split("-");
73
+ const [major = 0, minor = 0, patch = 0] = release.split(".").map(Number);
74
+ const [sinceMajor, sinceMinor] = ROOT_PARAMS_SINCE;
75
+ if (prerelease !== void 0 && major === sinceMajor && minor === sinceMinor && patch === 0) return false;
76
+ return major > sinceMajor || major === sinceMajor && minor >= sinceMinor;
77
+ } catch {
78
+ return false;
79
+ }
80
+ }
81
+ function findRootParam(root) {
82
+ const app = [join(root, "app"), join(root, "src", "app")].find((dir) => existsSync(dir));
83
+ if (!app) return void 0;
84
+ const found = /* @__PURE__ */ new Set();
85
+ const walk = (dir, params, depth) => {
86
+ let entries;
87
+ try {
88
+ entries = readdirSync(dir, { withFileTypes: true });
89
+ } catch {
90
+ return;
91
+ }
92
+ if (entries.some((entry) => entry.isFile() && LAYOUT_FILE.test(entry.name))) {
93
+ found.add(params.length === 1 ? params[0] : void 0);
94
+ return;
95
+ }
96
+ if (depth === MAX_DEPTH) return;
97
+ for (const entry of entries) {
98
+ if (!entry.isDirectory() || /^[_@.]/.test(entry.name) || entry.name === "node_modules") continue;
99
+ const segment = DYNAMIC_SEGMENT.exec(entry.name)?.[1];
100
+ walk(join(dir, entry.name), segment ? [...params, segment] : params, depth + 1);
101
+ }
102
+ };
103
+ walk(app, [], 0);
104
+ const [only] = found;
105
+ return found.size === 1 ? only : void 0;
106
+ }
107
+ function generateServerModule(cfg) {
108
+ const param = cfg.routing !== "no-prefix" && hasRootParams(cfg.root) ? findRootParam(cfg.root) : void 0;
109
+ if (!param) return "// generated by @verbaly/next: no root segment to read, setRequestLocale declares it\nexport const rootLocale = undefined;\n";
110
+ return `// generated by @verbaly/next: the [${param}] segment of the root layout, through next/root-params\nimport { ${param} as segment } from 'next/root-params';\nexport const rootLocale = segment;
111
+ `;
112
+ }
113
+ // src/codegen.ts
41
114
  const GENERATED_DIR = ".verbaly";
42
115
  function generatedDir(root) {
43
116
  return join(root, GENERATED_DIR);
@@ -49,12 +122,14 @@ function writeIfChanged(file, content) {
49
122
  writeFileSync(file, content);
50
123
  return true;
51
124
  }
52
- async function syncAndWrite(compiler, cfg, catalogs, registry, requestOptions, previous) {
125
+ async function syncAndWrite(compiler, cfg, catalogs, registry, requestOptions, previous, live = true) {
53
126
  const result = await compiler.syncProject(cfg, {
54
127
  registry,
55
128
  catalogs,
56
- write: "changed"
129
+ write: "changed",
130
+ dryRun: !live
57
131
  });
132
+ if (!live) compiler.writeDts(cfg, result.catalogs[cfg.sourceLocale] ?? {});
58
133
  writeGeneratedModules(compiler, cfg, result.catalogs, requestOptions);
59
134
  return reportDev(compiler, cfg, result, previous);
60
135
  }
@@ -72,6 +147,7 @@ function writeGeneratedModules(compiler, cfg, catalogs, requestOptions = {}) {
72
147
  inlineCatalog: cfg.render.inlineCatalog === true
73
148
  });
74
149
  changed = writeIfChanged(join(dir, "index.js"), runtime) || changed;
150
+ changed = writeIfChanged(join(dir, "server.js"), generateServerModule(cfg)) || changed;
75
151
  const expected = new Set(cfg.locales.map((locale) => `${locale}.js`));
76
152
  for (const locale of cfg.locales) changed = writeIfChanged(join(localeDir, `${locale}.js`), compiler.generateLocaleModule(client[locale] ?? {})) || changed;
77
153
  for (const file of readdirSync(localeDir)) if (!expected.has(file)) {
@@ -80,10 +156,9 @@ function writeGeneratedModules(compiler, cfg, catalogs, requestOptions = {}) {
80
156
  }
81
157
  return changed;
82
158
  }
83
- //#endregion
84
- //#region src/watch.ts
159
+ // src/watch.ts
85
160
  const active = /* @__PURE__ */ new Map();
86
- function startWatcher(compiler, cfg, requestOptions, startTexts) {
161
+ function startWatcher(compiler, cfg, requestOptions, startTexts, live = true) {
87
162
  const existing = active.get(cfg.root);
88
163
  if (existing) return existing;
89
164
  const catalogDir = relative(cfg.root, cfg.dir).replaceAll("\\", "/");
@@ -98,7 +173,7 @@ function startWatcher(compiler, cfg, requestOptions, startTexts) {
98
173
  }
99
174
  running = true;
100
175
  try {
101
- texts = await syncAndWrite(compiler, cfg, compiler.loadCatalogs(cfg), await compiler.extractProject(cfg), requestOptions, texts);
176
+ texts = await syncAndWrite(compiler, cfg, compiler.loadCatalogs(cfg), await compiler.extractProject(cfg), requestOptions, texts, live);
102
177
  } catch (error) {
103
178
  const reason = compiler.formatCliError(error).replace(/^\[verbaly\] /, "");
104
179
  console.warn(`[verbaly] live extraction paused: ${reason}`);
@@ -132,15 +207,15 @@ function startWatcher(compiler, cfg, requestOptions, startTexts) {
132
207
  active.set(cfg.root, dispose);
133
208
  return dispose;
134
209
  }
135
- //#endregion
136
- //#region src/index.ts
210
+ // src/index.ts
137
211
  const DEV_PHASE = "phase-development-server";
138
212
  const BUILD_PHASE = "phase-production-build";
139
213
  const ANALYZE_PHASE = "phase-analyze";
140
214
  const LOADER = "@verbaly/next/loader";
215
+ const SERVER_ID = "virtual:verbaly/server";
141
216
  const SOURCE_PATH_RE = /\.[cm]?[jt]sx?$/;
142
217
  function withVerbaly(nextConfig, options = {}) {
143
- const { failOnMissing, cookie, fallback, ...verbalyConfig } = options;
218
+ const { failOnMissing, liveExtraction, cookie, fallback, ...verbalyConfig } = options;
144
219
  const requestOptions = {
145
220
  cookie,
146
221
  fallback
@@ -150,14 +225,19 @@ function withVerbaly(nextConfig, options = {}) {
150
225
  const root = verbalyConfig.root ?? process.cwd();
151
226
  if (phase !== DEV_PHASE && phase !== BUILD_PHASE && phase !== ANALYZE_PHASE) return composeConfig(base, root);
152
227
  const compiler = await import("@verbaly/compiler");
153
- const cfg = await compiler.loadConfig(root, verbalyConfig, { plugin: true });
228
+ const options = {
229
+ trailingSlash: base.trailingSlash ? "always" : "never",
230
+ ...verbalyConfig
231
+ };
232
+ const cfg = await compiler.loadConfig(root, options, { plugin: true });
154
233
  const catalogs = compiler.loadCatalogs(cfg);
155
234
  const registry = await compiler.extractProject(cfg);
156
235
  await compiler.reportOutsideInclude(cfg);
157
236
  let gate;
158
237
  if (phase === DEV_PHASE) {
159
- const texts = await syncAndWrite(compiler, cfg, catalogs, registry, requestOptions);
160
- startWatcher(compiler, cfg, requestOptions, texts);
238
+ const live = liveExtraction !== false;
239
+ const texts = await syncAndWrite(compiler, cfg, catalogs, registry, requestOptions, void 0, live);
240
+ startWatcher(compiler, cfg, requestOptions, texts, live);
161
241
  } else {
162
242
  compiler.syncCatalogs(cfg, catalogs, registry);
163
243
  writeGeneratedModules(compiler, cfg, catalogs, requestOptions);
@@ -178,21 +258,11 @@ function withVerbaly(nextConfig, options = {}) {
178
258
  }
179
259
  const HOOK_FILE = "next/dist/build/after-production-compile.js";
180
260
  function hasAfterCompileHook(root) {
181
- for (let dir = root;; dir = dirname(dir)) {
182
- const next = join(dir, "node_modules", "next");
183
- if (existsSync(join(next, "package.json"))) return existsSync(join(dir, "node_modules", HOOK_FILE));
184
- if (dirname(dir) === dir) break;
185
- }
186
- if (!process.versions.pnp) return false;
187
- try {
188
- createRequire(join(root, "package.json")).resolve(HOOK_FILE);
189
- return true;
190
- } catch {
191
- return false;
192
- }
261
+ return resolveFromNext(root, HOOK_FILE) !== void 0;
193
262
  }
194
263
  function composeConfig(base, root, scope, gate) {
195
264
  const runtimeModule = join(generatedDir(root), "index.js");
265
+ const serverModule = join(generatedDir(root), "server.js");
196
266
  const { webpack: userWebpack, turbopack, compiler: userCompiler } = base;
197
267
  const loader = scope ? {
198
268
  loader: LOADER,
@@ -223,7 +293,8 @@ function composeConfig(base, root, scope, gate) {
223
293
  ...turbopack,
224
294
  resolveAlias: {
225
295
  ...turbopack?.resolveAlias,
226
- "virtual:verbaly": `./${GENERATED_DIR}/index.js`
296
+ "virtual:verbaly": `./${GENERATED_DIR}/index.js`,
297
+ [SERVER_ID]: `./${GENERATED_DIR}/server.js`
227
298
  },
228
299
  rules
229
300
  },
@@ -231,11 +302,12 @@ function composeConfig(base, root, scope, gate) {
231
302
  const { webpack: webpackInstance } = context ?? {};
232
303
  if (webpackInstance?.NormalModuleReplacementPlugin) {
233
304
  config.plugins ??= [];
234
- config.plugins.push(new webpackInstance.NormalModuleReplacementPlugin(/^virtual:verbaly$/, runtimeModule));
305
+ config.plugins.push(new webpackInstance.NormalModuleReplacementPlugin(/^virtual:verbaly$/, runtimeModule), new webpackInstance.NormalModuleReplacementPlugin(/^virtual:verbaly[/]server$/, serverModule));
235
306
  }
236
307
  config.resolve ??= {};
237
308
  config.resolve.alias ??= {};
238
309
  config.resolve.alias["virtual:verbaly"] = runtimeModule;
310
+ config.resolve.alias[SERVER_ID] = serverModule;
239
311
  config.module ??= {};
240
312
  config.module.rules ??= [];
241
313
  config.module.rules.push({
@@ -248,7 +320,4 @@ function composeConfig(base, root, scope, gate) {
248
320
  }
249
321
  };
250
322
  }
251
- //#endregion
252
323
  export { withVerbaly };
253
-
254
- //# sourceMappingURL=index.js.map
package/dist/loader.cjs CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/loader.ts
1
+ // src/loader.ts
2
2
  let compiler;
3
3
  const filters = /* @__PURE__ */ new Map();
4
4
  function inScope(load, options, file) {
@@ -33,7 +33,4 @@ function verbalyLoader(source) {
33
33
  } else callback(null, source);
34
34
  }).catch((error) => callback(error));
35
35
  }
36
- //#endregion
37
36
  module.exports = verbalyLoader;
38
-
39
- //# sourceMappingURL=loader.cjs.map
package/dist/server.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { TransProps } from "@verbaly/react/server";
2
2
  import * as React from "react";
3
3
  import { Locale, Translate, Verbaly } from "verbaly";
4
- //#region src/server.d.ts
5
4
  export declare function setRequestLocale(locale: string): void;
6
5
  export interface AlternatesOptions {
7
6
  path: string;
@@ -22,6 +21,4 @@ export interface VerbalyProviderProps {
22
21
  locale: string;
23
22
  messages?: Record<string, string>;
24
23
  }
25
- export declare function getVerbalyProps(): Promise<VerbalyProviderProps>;
26
- //#endregion
27
- //# sourceMappingURL=server.d.ts.map
24
+ export declare function getVerbalyProps(): Promise<VerbalyProviderProps>;
package/dist/server.js CHANGED
@@ -2,8 +2,9 @@ import { renderTrans } from "@verbaly/react/server";
2
2
  import { cookies, headers } from "next/headers";
3
3
  import * as React from "react";
4
4
  import { LOCALE_STORAGE_KEY, alternateLinks, localeFromPath, resolveRequestLocale, warnOnce } from "verbaly";
5
- import { createRequestInstance, loadMessages, locales, requestOptions, routing, sourceLocale } from "virtual:verbaly";
6
- //#region src/server.ts
5
+ import { createRequestInstance, loadMessages, locales, requestOptions, routing, sourceLocale, trailingSlash } from "virtual:verbaly";
6
+ import { rootLocale } from "virtual:verbaly/server";
7
+ // src/server.ts
7
8
  const perRequest = React.cache ?? ((fn) => fn);
8
9
  const scopedHolder = perRequest(() => ({}));
9
10
  const moduleHolder = {};
@@ -15,15 +16,32 @@ function setRequestLocale(locale) {
15
16
  if (routing === "no-prefix") warnOnce("setRequestLocale got a locale segment while routing is \"no-prefix\": if your urls start with the locale, set routing to 'prefix-all' or 'prefix-except-source' in your verbaly config");
16
17
  holder().locale = locale;
17
18
  }
18
- function declaredLocale() {
19
+ async function declaredLocale() {
19
20
  const raw = holder().locale;
20
- if (raw === void 0) return void 0;
21
+ if (raw !== void 0) {
22
+ const match = localeFromPath({
23
+ supported: locales,
24
+ path: `/${raw}`
25
+ });
26
+ if (match) return match;
27
+ warnOnce(`setRequestLocale was given a locale the project does not have, so it was ignored`);
28
+ return;
29
+ }
30
+ const segment = await rootSegment();
31
+ if (segment === void 0) return void 0;
21
32
  const match = localeFromPath({
22
33
  supported: locales,
23
- path: `/${raw}`
34
+ path: `/${segment}`
24
35
  });
25
36
  if (match) return match;
26
- warnOnce(`setRequestLocale was given a locale the project does not have, so it was ignored`);
37
+ warnOnce(`the locale segment of the url holds a locale the project does not have, so it was ignored`);
38
+ }
39
+ async function rootSegment() {
40
+ try {
41
+ return await rootLocale?.();
42
+ } catch {
43
+ return;
44
+ }
27
45
  }
28
46
  function namedLocale(raw) {
29
47
  const match = localeFromPath({
@@ -36,6 +54,7 @@ function namedLocale(raw) {
36
54
  }
37
55
  const instanceFor = perRequest((locale) => createRequestInstance(locale));
38
56
  async function negotiate() {
57
+ if (routing !== "no-prefix" && !rootLocale) warnOnce("getT() found no locale for this segment, so it read the cookie: under your locale segment, call setRequestLocale in this page or layout too, or pass getT({ locale }) (Next 16.3 and later read the segment by themselves)");
39
58
  const cookieName = requestOptions?.cookie ?? LOCALE_STORAGE_KEY;
40
59
  const headerStore = await headers();
41
60
  const cookieValue = cookieName === false ? void 0 : (await cookies()).get(cookieName)?.value;
@@ -48,7 +67,7 @@ async function negotiate() {
48
67
  });
49
68
  }
50
69
  const getRequestState = perRequest(async () => {
51
- const locale = declaredLocale() ?? await negotiate();
70
+ const locale = await declaredLocale() ?? await negotiate();
52
71
  return {
53
72
  locale,
54
73
  instance: await createRequestInstance(locale)
@@ -60,7 +79,8 @@ function getAlternates(options) {
60
79
  sourceLocale,
61
80
  routing,
62
81
  path: options.path,
63
- baseUrl: options.baseUrl
82
+ baseUrl: options.baseUrl,
83
+ trailingSlash
64
84
  });
65
85
  const languages = {};
66
86
  for (const link of links) languages[link.hreflang] = link.href;
@@ -93,7 +113,4 @@ async function getVerbalyProps() {
93
113
  messages: await loadMessages(locale)
94
114
  };
95
115
  }
96
- //#endregion
97
116
  export { Trans, getAlternates, getRequestLocale, getT, getVerbaly, getVerbalyProps, setRequestLocale };
98
-
99
- //# sourceMappingURL=server.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verbaly/next",
3
- "version": "0.75.0",
3
+ "version": "0.77.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",
@@ -23,6 +23,10 @@
23
23
  "bugs": {
24
24
  "url": "https://github.com/AronSoto/verbaly/issues"
25
25
  },
26
+ "funding": {
27
+ "type": "github",
28
+ "url": "https://github.com/sponsors/AronSoto"
29
+ },
26
30
  "type": "module",
27
31
  "main": "./dist/index.cjs",
28
32
  "module": "./dist/index.js",
@@ -64,23 +68,23 @@
64
68
  "access": "public"
65
69
  },
66
70
  "dependencies": {
67
- "@verbaly/compiler": "^0.75.0"
71
+ "@verbaly/compiler": "^0.77.0"
68
72
  },
69
73
  "peerDependencies": {
70
- "@verbaly/react": "^0.75.0",
74
+ "@verbaly/react": "^0.77.0",
71
75
  "next": "^15.0.0 || ^16.0.0",
72
76
  "react": "^18.0.0 || ^19.0.0",
73
- "verbaly": "^0.75.0"
77
+ "verbaly": "^0.77.0"
74
78
  },
75
79
  "devDependencies": {
76
80
  "@types/react": "^19.3.0",
77
81
  "@types/react-dom": "^19.3.0",
78
- "@verbaly/react": "^0.75.0",
79
- "happy-dom": "^21.0.3",
80
- "next": "^16.4.2",
82
+ "@verbaly/react": "^0.77.0",
83
+ "happy-dom": "^21.0.4",
84
+ "next": "^16.4.3",
81
85
  "react": "^19.3.1",
82
86
  "react-dom": "^19.3.1",
83
- "verbaly": "^0.75.0"
87
+ "verbaly": "^0.77.0"
84
88
  },
85
89
  "scripts": {
86
90
  "build": "tsdown",
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.js","names":["ReactVerbalyProvider","useVerbaly"],"sources":["../src/client.ts"],"sourcesContent":["'use client';\n\nimport { useRouter } from 'next/navigation';\nimport {\n createElement,\n useCallback,\n useEffect,\n useState,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport { VerbalyProvider as ReactVerbalyProvider, useVerbaly } from '@verbaly/react';\nimport { switchLocale, type SwitchLocaleOptions } from 'verbaly';\nimport { createInstance, locales, requestOptions, routing, sourceLocale } from 'virtual:verbaly';\nimport type { VerbalyProviderProps as SerializableProps } from './server';\n\nexport { Trans, useLocale, useT, useVerbaly } from '@verbaly/react';\n\n// the serializable props getVerbalyProps() produces, plus the client-side children\nexport interface VerbalyProviderProps extends SerializableProps {\n children?: ReactNode;\n}\n\nexport function VerbalyProvider(props: VerbalyProviderProps): ReactElement {\n // getVerbalyProps omits them for the source locale, so messages here were passed on purpose\n const [instance] = useState(() => {\n // the server already sent this catalog: marked as arrived, so the chunk is not fetched again\n const created = createInstance({\n locale: props.locale,\n partial: props.messages ? [props.locale] : undefined,\n });\n if (props.messages) created.addMessages(props.locale, props.messages);\n return created;\n });\n\n // server changed the locale out-of-band (cookie edit + refresh): follow it\n useEffect(() => {\n if (props.locale === instance.locale) return;\n if (props.messages) {\n instance.addMessages(props.locale, props.messages, { partial: true });\n instance.setLocale(props.locale);\n } else {\n void instance.loadLocale(props.locale).then(() => instance.setLocale(props.locale));\n }\n }, [props.locale, props.messages, instance]);\n\n return createElement(ReactVerbalyProvider, { instance }, props.children);\n}\n\n// core switchLocale in the project's own routing, with the app router as the navigation\nexport function useSwitchLocale(): (\n locale: string,\n options?: SwitchLocaleOptions,\n) => Promise<void> {\n const instance = useVerbaly();\n const router = useRouter();\n return useCallback(\n async (locale, options) => {\n // the project's routing unless told otherwise: under a [locale] segment the url must change\n const settings: SwitchLocaleOptions = {\n cookie: requestOptions?.cookie,\n routing,\n supported: locales,\n sourceLocale,\n // a full load would throw away the react tree the app router exists to keep\n navigate: (path) => router.push(path),\n ...options,\n };\n const routed = settings.routing !== undefined && settings.routing !== 'no-prefix';\n await switchLocale(instance, locale, settings);\n // the navigation already re-rendered the tree, so refreshing on top of it is a second render\n if (!routed) router.refresh();\n },\n [instance, router],\n );\n}\n"],"mappings":";;;;;;;AAuBA,SAAgB,gBAAgB,OAA2C;CAEzE,MAAM,CAAC,YAAY,eAAe;EAEhC,MAAM,UAAU,eAAe;GAC7B,QAAQ,MAAM;GACd,SAAS,MAAM,WAAW,CAAC,MAAM,MAAM,IAAI,KAAA;EAC7C,CAAC;EACD,IAAI,MAAM,UAAU,QAAQ,YAAY,MAAM,QAAQ,MAAM,QAAQ;EACpE,OAAO;CACT,CAAC;CAGD,gBAAgB;EACd,IAAI,MAAM,WAAW,SAAS,QAAQ;EACtC,IAAI,MAAM,UAAU;GAClB,SAAS,YAAY,MAAM,QAAQ,MAAM,UAAU,EAAE,SAAS,KAAK,CAAC;GACpE,SAAS,UAAU,MAAM,MAAM;EACjC,OACE,SAAc,WAAW,MAAM,MAAM,CAAC,CAAC,WAAW,SAAS,UAAU,MAAM,MAAM,CAAC;CAEtF,GAAG;EAAC,MAAM;EAAQ,MAAM;EAAU;CAAQ,CAAC;CAE3C,OAAO,cAAcA,mBAAsB,EAAE,SAAS,GAAG,MAAM,QAAQ;AACzE;AAGA,SAAgB,kBAGG;CACjB,MAAM,WAAWC,aAAW;CAC5B,MAAM,SAAS,UAAU;CACzB,OAAO,YACL,OAAO,QAAQ,YAAY;EAEzB,MAAM,WAAgC;GACpC,QAAQ,gBAAgB;GACxB;GACA,WAAW;GACX;GAEA,WAAW,SAAS,OAAO,KAAK,IAAI;GACpC,GAAG;EACL;EACA,MAAM,SAAS,SAAS,YAAY,KAAA,KAAa,SAAS,YAAY;EACtE,MAAM,aAAa,UAAU,QAAQ,QAAQ;EAE7C,IAAI,CAAC,QAAQ,OAAO,QAAQ;CAC9B,GACA,CAAC,UAAU,MAAM,CACnB;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","names":["join","readFileSync","readdirSync","relative","basename","dirname","join","existsSync"],"sources":["../src/report.ts","../src/codegen.ts","../src/watch.ts","../src/index.ts"],"sourcesContent":["import type { DevReporter, Finding, ResolvedConfig, SyncProjectResult } from '@verbaly/compiler';\nimport type { Compiler } from './codegen';\n\n// one per project: next.config can be evaluated more than once, and the watcher outlives it\nconst reporters = new Map<string, DevReporter>();\nconst brokenState = new Set<string>();\n\n// the code texts of the last run tell an edit in the code from an edit in the catalog\nexport type CodeTexts = Map<string, string>;\n\nexport function reportDev(\n compiler: Compiler,\n cfg: ResolvedConfig,\n result: SyncProjectResult,\n previous: CodeTexts | undefined,\n): CodeTexts {\n let reporter = reporters.get(cfg.root);\n if (!reporter) {\n reporter = compiler.createDevReporter(cfg.root);\n reporters.set(cfg.root, reporter);\n }\n const replaced: Finding[] = [];\n const code: Finding[] = [];\n const lock: Finding[] = [];\n for (const finding of result.findings) {\n if (finding.kind === 'collision' || finding.kind === 'renamed') code.push(finding);\n if (finding.kind === 'lock') lock.push(finding);\n if (finding.kind !== 'replaced') continue;\n // the code changed this text since the last run, which is how a text it owns is edited\n if (previous && previous.get(finding.key) !== finding.site.message) continue;\n replaced.push({ ...finding, edited: previous !== undefined });\n }\n reporter.report('replaced', replaced);\n reporter.report('code', code);\n reporter.report('lock', lock);\n const outdated = result.state\n ? compiler.outdatedTranslations(cfg, result.catalogs, result.state.fingerprints)\n : [];\n reporter.report(\n 'outdated',\n outdated.map((entry): Finding => ({ kind: 'outdated', ...entry })),\n );\n\n // a broken lock must not stop next dev: said once, and again if it breaks after a fix\n if (result.stateProblem && !brokenState.has(cfg.root)) {\n console.warn(`[verbaly] ${result.stateProblem}, so drafts are not tracked`);\n }\n if (result.stateProblem) brokenState.add(cfg.root);\n else brokenState.delete(cfg.root);\n\n return new Map([...result.registry.messages()].map(([key, msg]) => [key, msg.message]));\n}\n\n// test hook: each test starts from a server that said nothing\nexport function resetReported(): void {\n reporters.clear();\n brokenState.clear();\n}\n","import type { Catalogs, ResolvedConfig } from '@verbaly/compiler';\nimport { mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { reportDev, type CodeTexts } from './report';\n\nexport type Compiler = typeof import('@verbaly/compiler');\nexport type Registry = Awaited<ReturnType<Compiler['extractProject']>>;\n\nexport interface RequestOptions {\n cookie?: string | false;\n fallback?: string;\n}\n\nexport const GENERATED_DIR = '.verbaly';\n\nexport function generatedDir(root: string): string {\n return join(root, GENERATED_DIR);\n}\n\n// content compare: identical rewrites must not retrigger the bundler\nfunction writeIfChanged(file: string, content: string): boolean {\n try {\n if (readFileSync(file, 'utf8') === content) return false;\n } catch {\n // new file\n }\n writeFileSync(file, content);\n return true;\n}\n\n// dev pipeline shared by withVerbaly and the watcher: the compiler's sync, then the runtime modules\nexport async function syncAndWrite(\n compiler: Compiler,\n cfg: ResolvedConfig,\n catalogs: Catalogs,\n registry: Registry,\n requestOptions: RequestOptions,\n previous?: CodeTexts,\n): Promise<CodeTexts> {\n // 'changed': a catalog nothing happened to keeps the formatting its author gave it\n const result = await compiler.syncProject(cfg, { registry, catalogs, write: 'changed' });\n writeGeneratedModules(compiler, cfg, result.catalogs, requestOptions);\n return reportDev(compiler, cfg, result, previous);\n}\n\n// real-file replacement for virtual:verbaly: Turbopack has no virtual modules\nexport function writeGeneratedModules(\n compiler: Compiler,\n cfg: ResolvedConfig,\n catalogs: Catalogs,\n requestOptions: RequestOptions = {},\n): boolean {\n const dir = generatedDir(cfg.root);\n const localeDir = join(dir, 'locale');\n mkdirSync(localeDir, { recursive: true });\n\n let changed = writeIfChanged(join(dir, '.gitignore'), '*\\n');\n\n // these files are the client module here, so bundle.exclude has to be applied on this path too\n const client = compiler.clientCatalogs(cfg, catalogs);\n const runtime = compiler.generateRuntimeModule(cfg, {\n localeImport: (locale) => `./locale/${locale}.js`,\n extraExports: `export const requestOptions = ${JSON.stringify(requestOptions)};\\n`,\n icu: cfg.icu ?? compiler.needsIcu(client),\n relative: cfg.relative ?? compiler.needsRelative(client),\n inlineCatalog: cfg.render.inlineCatalog === true,\n });\n changed = writeIfChanged(join(dir, 'index.js'), runtime) || changed;\n\n const expected = new Set(cfg.locales.map((locale) => `${locale}.js`));\n for (const locale of cfg.locales) {\n changed =\n writeIfChanged(\n join(localeDir, `${locale}.js`),\n compiler.generateLocaleModule(client[locale] ?? {}),\n ) || changed;\n }\n for (const file of readdirSync(localeDir)) {\n if (!expected.has(file)) {\n rmSync(join(localeDir, file));\n changed = true;\n }\n }\n return changed;\n}\n","import type { ResolvedConfig } from '@verbaly/compiler';\nimport { basename, relative } from 'node:path';\nimport { GENERATED_DIR, syncAndWrite, type Compiler, type RequestOptions } from './codegen';\nimport type { CodeTexts } from './report';\n\n// one watcher per project root: next.config can be evaluated more than once\nconst active = new Map<string, () => void>();\n\nexport function startWatcher(\n compiler: Compiler,\n cfg: ResolvedConfig,\n requestOptions: RequestOptions,\n startTexts?: CodeTexts,\n): () => void {\n const existing = active.get(cfg.root);\n if (existing) return existing;\n\n const catalogDir = relative(cfg.root, cfg.dir).replaceAll('\\\\', '/');\n let timer: ReturnType<typeof setTimeout> | undefined;\n let running = false;\n let queued = false;\n let texts = startTexts;\n\n async function refresh(): Promise<void> {\n if (running) {\n queued = true;\n return;\n }\n running = true;\n try {\n const catalogs = compiler.loadCatalogs(cfg);\n const registry = await compiler.extractProject(cfg);\n texts = await syncAndWrite(compiler, cfg, catalogs, registry, requestOptions, texts);\n } catch (error) {\n // a catalog saved half-typed is broken JSON for a moment: one line, never a stack trace\n const reason = compiler.formatCliError(error).replace(/^\\[verbaly\\] /, '');\n console.warn(`[verbaly] live extraction paused: ${reason}`);\n } finally {\n running = false;\n if (queued) {\n queued = false;\n schedule();\n }\n }\n }\n\n function schedule(): void {\n clearTimeout(timer);\n timer = setTimeout(() => void refresh(), 150);\n }\n\n const keep = catalogDir.split('/')[0];\n const close = compiler.watchTree(cfg.root, { keep, persistent: false }, (filename) => {\n if (!filename) return;\n const file = filename.replaceAll('\\\\', '/');\n if (\n file.startsWith(`${GENERATED_DIR}/`) ||\n file.startsWith('.next/') ||\n file.includes('node_modules/') ||\n file.endsWith('.d.ts')\n ) {\n return;\n }\n // a dotfile there is an older state file, which the next save moves: it changes no message\n const isCatalog =\n file.startsWith(`${catalogDir}/`) &&\n file.endsWith('.json') &&\n !basename(file).startsWith('.');\n if (isCatalog || compiler.SOURCE_FILE_RE.test(file)) schedule();\n });\n\n const dispose = (): void => {\n clearTimeout(timer);\n close();\n active.delete(cfg.root);\n };\n active.set(cfg.root, dispose);\n return dispose;\n}\n\n// test hook\nexport function stopWatcher(root: string): void {\n active.get(root)?.();\n}\n","import type { PluginOptions } from '@verbaly/compiler';\nimport { existsSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { dirname, join } from 'node:path';\nimport {\n GENERATED_DIR,\n generatedDir,\n syncAndWrite,\n writeGeneratedModules,\n type Compiler,\n type RequestOptions,\n} from './codegen';\nimport type { LoaderOptions } from './loader';\nimport { startWatcher } from './watch';\n\nexport type { VerbalyConfig } from '@verbaly/compiler';\nexport type { RequestOptions } from './codegen';\n\nexport interface NextVerbalyOptions extends PluginOptions {\n cookie?: string | false;\n fallback?: string;\n}\n\n// structural NextConfig subset (compat asserted in tests): no index signatures, Next has none\nexport interface WebpackConfigLike {\n resolve?: { alias?: Record<string, unknown>; [key: string]: unknown };\n module?: { rules?: unknown[]; [key: string]: unknown };\n plugins?: unknown[];\n [key: string]: unknown;\n}\n\ninterface WebpackContextLike {\n webpack?: {\n NormalModuleReplacementPlugin: new (test: RegExp, resource: string) => unknown;\n };\n}\n\n// context param is `never` so Next's real webpack fn (specific context type) stays assignable\nexport type WebpackFn = (config: WebpackConfigLike, context: never) => unknown;\n\nexport interface TurbopackLike {\n resolveAlias?: Record<string, unknown>;\n rules?: Record<string, unknown>;\n}\n\n// metadata is `never` for the same reason as the webpack context: Next's own type stays assignable\nexport interface CompilerLike {\n runAfterProductionCompile?: (metadata: never) => Promise<void>;\n}\n\nexport interface NextConfigLike {\n webpack?: WebpackFn | null;\n turbopack?: TurbopackLike;\n compiler?: CompilerLike;\n}\n\n// constraint is object, not NextConfigLike: an all-optional target rejects by weak-type\nexport type NextConfigInput<C extends object> =\n C | ((phase: string, context: { defaultConfig?: unknown }) => C | Promise<C>);\n\n// next/constants values: literal to keep this module import-free of next\nconst DEV_PHASE = 'phase-development-server';\nconst BUILD_PHASE = 'phase-production-build';\n// next experimental-analyze compiles the app as well, so it needs the generated modules on disk\nconst ANALYZE_PHASE = 'phase-analyze';\n\nconst LOADER = '@verbaly/next/loader';\n// matched via condition.path: a bare extension glob also hits Next's App Router entry\nconst SOURCE_PATH_RE = /\\.[cm]?[jt]sx?$/;\n\nexport function withVerbaly<C extends object>(\n nextConfig?: NextConfigInput<C>,\n options: NextVerbalyOptions = {},\n): (phase: string, context?: { defaultConfig?: unknown }) => Promise<C> {\n const { failOnMissing, cookie, fallback, ...verbalyConfig } = options;\n const requestOptions: RequestOptions = { cookie, fallback };\n\n return async (phase, context = {}) => {\n const base: C =\n typeof nextConfig === 'function'\n ? await nextConfig(phase, context)\n : (nextConfig ?? ({} as C));\n const root = verbalyConfig.root ?? process.cwd();\n\n // production server / export: everything is bundled, so no FS work, config only\n if (phase !== DEV_PHASE && phase !== BUILD_PHASE && phase !== ANALYZE_PHASE) {\n return composeConfig(base, root);\n }\n\n // dynamic: the compiler is ESM-only and this entry is also consumed as CJS\n const compiler: Compiler = await import('@verbaly/compiler');\n\n const cfg = await compiler.loadConfig(root, verbalyConfig, { plugin: true });\n const catalogs = compiler.loadCatalogs(cfg);\n const registry = await compiler.extractProject(cfg);\n // once per phase, from the config: a loader result can come from Turbopack's cache\n await compiler.reportOutsideInclude(cfg);\n let gate: (() => void) | undefined;\n\n if (phase === DEV_PHASE) {\n const texts = await syncAndWrite(compiler, cfg, catalogs, registry, requestOptions);\n startWatcher(compiler, cfg, requestOptions, texts);\n } else {\n // the code's text ships, as it does in dev: a catalog edit of a text it owns never wins\n compiler.syncCatalogs(cfg, catalogs, registry);\n writeGeneratedModules(compiler, cfg, catalogs, requestOptions);\n // next build and next typegen check types, and .verbaly/ is never committed\n compiler.writeDts(cfg, catalogs[cfg.sourceLocale] ?? {});\n if (phase === BUILD_PHASE) {\n const runGate = (): void => compiler.runBuildGate(cfg, registry, failOnMissing);\n // typegen loads this config in the build phase too, and only a real build runs the hook\n if (hasAfterCompileHook(cfg.root)) gate = runGate;\n else runGate();\n }\n }\n\n // the loader rewrites exactly what extract reads: a file outside include keeps its t`…`\n const scope: LoaderOptions = { root: cfg.root, include: cfg.include, exclude: cfg.exclude };\n return composeConfig(base, cfg.root, scope, gate);\n };\n}\n\nconst HOOK_FILE = 'next/dist/build/after-production-compile.js';\n\n// next build calls compiler.runAfterProductionCompile since 15.4; NODE_PATH may name another next\nfunction hasAfterCompileHook(root: string): boolean {\n for (let dir = root; ; dir = dirname(dir)) {\n const next = join(dir, 'node_modules', 'next');\n if (existsSync(join(next, 'package.json')))\n return existsSync(join(dir, 'node_modules', HOOK_FILE));\n if (dirname(dir) === dir) break;\n }\n // Yarn PnP has no node_modules, and its resolver finds the project's own next, never NODE_PATH's\n if (!process.versions.pnp) return false;\n try {\n createRequire(join(root, 'package.json')).resolve(HOOK_FILE);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction composeConfig<C extends object>(\n base: C,\n root: string,\n scope?: LoaderOptions,\n gate?: () => void,\n): C {\n const runtimeModule = join(generatedDir(root), 'index.js');\n const { webpack: userWebpack, turbopack, compiler: userCompiler } = base as NextConfigLike;\n const loader = scope ? { loader: LOADER, options: scope } : LOADER;\n\n const rules: Record<string, unknown> = { ...turbopack?.rules };\n const verbalyRule = {\n condition: { all: [{ not: 'foreign' }, { path: SOURCE_PATH_RE }] },\n loaders: [loader],\n };\n const existing = rules['*'];\n rules['*'] = existing\n ? [...(Array.isArray(existing) ? existing : [existing]), verbalyRule]\n : verbalyRule;\n\n return {\n ...base,\n ...(gate && {\n compiler: {\n ...userCompiler,\n // after the compile, so next typegen, which loads this config too, never meets the gate\n async runAfterProductionCompile(metadata: never) {\n await userCompiler?.runAfterProductionCompile?.(metadata);\n try {\n gate();\n } catch (error) {\n // Next prints a failed hook twice: the report goes out once, and the throw stays short\n console.error((error as Error).message);\n // eslint-disable-next-line preserve-caught-error -- a cause would print the report again\n throw new Error('[verbaly] build blocked, the reason is printed above');\n }\n },\n },\n }),\n turbopack: {\n ...turbopack,\n resolveAlias: {\n ...turbopack?.resolveAlias,\n 'virtual:verbaly': `./${GENERATED_DIR}/index.js`,\n },\n rules,\n },\n webpack(config: WebpackConfigLike, context: unknown) {\n // webpack 5 parses 'virtual:' as a URI scheme, so resolve.alias never fires\n const { webpack: webpackInstance } = (context ?? {}) as WebpackContextLike;\n if (webpackInstance?.NormalModuleReplacementPlugin) {\n config.plugins ??= [];\n config.plugins.push(\n new webpackInstance.NormalModuleReplacementPlugin(/^virtual:verbaly$/, runtimeModule),\n );\n }\n config.resolve ??= {};\n config.resolve.alias ??= {};\n (config.resolve.alias as Record<string, unknown>)['virtual:verbaly'] = runtimeModule;\n config.module ??= {};\n config.module.rules ??= [];\n config.module.rules.push({\n test: SOURCE_PATH_RE,\n exclude: /node_modules/,\n enforce: 'pre',\n use: [typeof loader === 'string' ? { loader } : loader],\n });\n return userWebpack ? userWebpack(config, context as never) : config;\n },\n } as C;\n}\n"],"mappings":";;;;;AAIA,MAAM,4BAAY,IAAI,IAAyB;AAC/C,MAAM,8BAAc,IAAI,IAAY;AAKpC,SAAgB,UACd,UACA,KACA,QACA,UACW;CACX,IAAI,WAAW,UAAU,IAAI,IAAI,IAAI;CACrC,IAAI,CAAC,UAAU;EACb,WAAW,SAAS,kBAAkB,IAAI,IAAI;EAC9C,UAAU,IAAI,IAAI,MAAM,QAAQ;CAClC;CACA,MAAM,WAAsB,CAAC;CAC7B,MAAM,OAAkB,CAAC;CACzB,MAAM,OAAkB,CAAC;CACzB,KAAK,MAAM,WAAW,OAAO,UAAU;EACrC,IAAI,QAAQ,SAAS,eAAe,QAAQ,SAAS,WAAW,KAAK,KAAK,OAAO;EACjF,IAAI,QAAQ,SAAS,QAAQ,KAAK,KAA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AAW,MAAM;CACvB,MAAM,OAAO,WACT,CAAC,GAAI,MAAM,QAAQ,QAAQ,IAAI,WAAW,CAAC,QAAQ,GAAI,WAAW,IAClE;CAEJ,OAAO;EACL,GAAG;EACH,GAAI,QAAQ,EACV,UAAU;GACR,GAAG;GAEH,MAAM,0BAA0B,UAAiB;IAC/C,MAAM,cAAc,4BAA4B,QAAQ;IACxD,IAAI;KACF,KAAK;IACP,SAAS,OAAO;KAEd,QAAQ,MAAO,MAAgB,OAAO;KAEtC,MAAM,IAAI,MAAM,sDAAsD;IACxE;GACF;EACF,EACF;EACA,WAAW;GACT,GAAG;GACH,cAAc;IACZ,GAAG,WAAW;IACd,mBAAmB,KAAK,cAAc;GACxC;GACA;EACF;EACA,QAAQ,QAA2B,SAAkB;GAEnD,MAAM,EAAE,SAAS,oBAAqB,WAAW,CAAC;GAClD,IAAI,iBAAiB,+BAA+B;IAClD,OAAO,YAAY,CAAC;IACpB,OAAO,QAAQ,KACb,IAAI,gBAAgB,8BAA8B,qBAAqB,aAAa,CACtF;GACF;GACA,OAAO,YAAY,CAAC;GACpB,OAAO,QAAQ,UAAU,CAAC;GAC1B,OAAQ,QAAQ,MAAkC,qBAAqB;GACvE,OAAO,WAAW,CAAC;GACnB,OAAO,OAAO,UAAU,CAAC;GACzB,OAAO,OAAO,MAAM,KAAK;IACvB,MAAM;IACN,SAAS;IACT,SAAS;IACT,KAAK,CAAC,OAAO,WAAW,WAAW,EAAE,OAAO,IAAI,MAAM;GACxD,CAAC;GACD,OAAO,cAAc,YAAY,QAAQ,OAAgB,IAAI;EAC/D;CACF;AACF"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/report.ts","../src/codegen.ts","../src/watch.ts","../src/index.ts"],"sourcesContent":["import type { DevReporter, Finding, ResolvedConfig, SyncProjectResult } from '@verbaly/compiler';\nimport type { Compiler } from './codegen';\n\n// one per project: next.config can be evaluated more than once, and the watcher outlives it\nconst reporters = new Map<string, DevReporter>();\nconst brokenState = new Set<string>();\n\n// the code texts of the last run tell an edit in the code from an edit in the catalog\nexport type CodeTexts = Map<string, string>;\n\nexport function reportDev(\n compiler: Compiler,\n cfg: ResolvedConfig,\n result: SyncProjectResult,\n previous: CodeTexts | undefined,\n): CodeTexts {\n let reporter = reporters.get(cfg.root);\n if (!reporter) {\n reporter = compiler.createDevReporter(cfg.root);\n reporters.set(cfg.root, reporter);\n }\n const replaced: Finding[] = [];\n const code: Finding[] = [];\n const lock: Finding[] = [];\n for (const finding of result.findings) {\n if (finding.kind === 'collision' || finding.kind === 'renamed') code.push(finding);\n if (finding.kind === 'lock') lock.push(finding);\n if (finding.kind !== 'replaced') continue;\n // the code changed this text since the last run, which is how a text it owns is edited\n if (previous && previous.get(finding.key) !== finding.site.message) continue;\n replaced.push({ ...finding, edited: previous !== undefined });\n }\n reporter.report('replaced', replaced);\n reporter.report('code', code);\n reporter.report('lock', lock);\n const outdated = result.state\n ? compiler.outdatedTranslations(cfg, result.catalogs, result.state.fingerprints)\n : [];\n reporter.report(\n 'outdated',\n outdated.map((entry): Finding => ({ kind: 'outdated', ...entry })),\n );\n\n // a broken lock must not stop next dev: said once, and again if it breaks after a fix\n if (result.stateProblem && !brokenState.has(cfg.root)) {\n console.warn(`[verbaly] ${result.stateProblem}, so drafts are not tracked`);\n }\n if (result.stateProblem) brokenState.add(cfg.root);\n else brokenState.delete(cfg.root);\n\n return new Map([...result.registry.messages()].map(([key, msg]) => [key, msg.message]));\n}\n\n// test hook: each test starts from a server that said nothing\nexport function resetReported(): void {\n reporters.clear();\n brokenState.clear();\n}\n","import type { Catalogs, ResolvedConfig } from '@verbaly/compiler';\nimport { mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { reportDev, type CodeTexts } from './report';\n\nexport type Compiler = typeof import('@verbaly/compiler');\nexport type Registry = Awaited<ReturnType<Compiler['extractProject']>>;\n\nexport interface RequestOptions {\n cookie?: string | false;\n fallback?: string;\n}\n\nexport const GENERATED_DIR = '.verbaly';\n\nexport function generatedDir(root: string): string {\n return join(root, GENERATED_DIR);\n}\n\n// content compare: identical rewrites must not retrigger the bundler\nfunction writeIfChanged(file: string, content: string): boolean {\n try {\n if (readFileSync(file, 'utf8') === content) return false;\n } catch {\n // new file\n }\n writeFileSync(file, content);\n return true;\n}\n\n// dev pipeline shared by withVerbaly and the watcher: the compiler's sync, then the runtime modules\nexport async function syncAndWrite(\n compiler: Compiler,\n cfg: ResolvedConfig,\n catalogs: Catalogs,\n registry: Registry,\n requestOptions: RequestOptions,\n previous?: CodeTexts,\n): Promise<CodeTexts> {\n // 'changed': a catalog nothing happened to keeps the formatting its author gave it\n const result = await compiler.syncProject(cfg, { registry, catalogs, write: 'changed' });\n writeGeneratedModules(compiler, cfg, result.catalogs, requestOptions);\n return reportDev(compiler, cfg, result, previous);\n}\n\n// real-file replacement for virtual:verbaly: Turbopack has no virtual modules\nexport function writeGeneratedModules(\n compiler: Compiler,\n cfg: ResolvedConfig,\n catalogs: Catalogs,\n requestOptions: RequestOptions = {},\n): boolean {\n const dir = generatedDir(cfg.root);\n const localeDir = join(dir, 'locale');\n mkdirSync(localeDir, { recursive: true });\n\n let changed = writeIfChanged(join(dir, '.gitignore'), '*\\n');\n\n // these files are the client module here, so bundle.exclude has to be applied on this path too\n const client = compiler.clientCatalogs(cfg, catalogs);\n const runtime = compiler.generateRuntimeModule(cfg, {\n localeImport: (locale) => `./locale/${locale}.js`,\n extraExports: `export const requestOptions = ${JSON.stringify(requestOptions)};\\n`,\n icu: cfg.icu ?? compiler.needsIcu(client),\n relative: cfg.relative ?? compiler.needsRelative(client),\n inlineCatalog: cfg.render.inlineCatalog === true,\n });\n changed = writeIfChanged(join(dir, 'index.js'), runtime) || changed;\n\n const expected = new Set(cfg.locales.map((locale) => `${locale}.js`));\n for (const locale of cfg.locales) {\n changed =\n writeIfChanged(\n join(localeDir, `${locale}.js`),\n compiler.generateLocaleModule(client[locale] ?? {}),\n ) || changed;\n }\n for (const file of readdirSync(localeDir)) {\n if (!expected.has(file)) {\n rmSync(join(localeDir, file));\n changed = true;\n }\n }\n return changed;\n}\n","import type { ResolvedConfig } from '@verbaly/compiler';\nimport { basename, relative } from 'node:path';\nimport { GENERATED_DIR, syncAndWrite, type Compiler, type RequestOptions } from './codegen';\nimport type { CodeTexts } from './report';\n\n// one watcher per project root: next.config can be evaluated more than once\nconst active = new Map<string, () => void>();\n\nexport function startWatcher(\n compiler: Compiler,\n cfg: ResolvedConfig,\n requestOptions: RequestOptions,\n startTexts?: CodeTexts,\n): () => void {\n const existing = active.get(cfg.root);\n if (existing) return existing;\n\n const catalogDir = relative(cfg.root, cfg.dir).replaceAll('\\\\', '/');\n let timer: ReturnType<typeof setTimeout> | undefined;\n let running = false;\n let queued = false;\n let texts = startTexts;\n\n async function refresh(): Promise<void> {\n if (running) {\n queued = true;\n return;\n }\n running = true;\n try {\n const catalogs = compiler.loadCatalogs(cfg);\n const registry = await compiler.extractProject(cfg);\n texts = await syncAndWrite(compiler, cfg, catalogs, registry, requestOptions, texts);\n } catch (error) {\n // a catalog saved half-typed is broken JSON for a moment: one line, never a stack trace\n const reason = compiler.formatCliError(error).replace(/^\\[verbaly\\] /, '');\n console.warn(`[verbaly] live extraction paused: ${reason}`);\n } finally {\n running = false;\n if (queued) {\n queued = false;\n schedule();\n }\n }\n }\n\n function schedule(): void {\n clearTimeout(timer);\n timer = setTimeout(() => void refresh(), 150);\n }\n\n const keep = catalogDir.split('/')[0];\n const close = compiler.watchTree(cfg.root, { keep, persistent: false }, (filename) => {\n if (!filename) return;\n const file = filename.replaceAll('\\\\', '/');\n if (\n file.startsWith(`${GENERATED_DIR}/`) ||\n file.startsWith('.next/') ||\n file.includes('node_modules/') ||\n file.endsWith('.d.ts')\n ) {\n return;\n }\n // a dotfile there is an older state file, which the next save moves: it changes no message\n const isCatalog =\n file.startsWith(`${catalogDir}/`) &&\n file.endsWith('.json') &&\n !basename(file).startsWith('.');\n if (isCatalog || compiler.SOURCE_FILE_RE.test(file)) schedule();\n });\n\n const dispose = (): void => {\n clearTimeout(timer);\n close();\n active.delete(cfg.root);\n };\n active.set(cfg.root, dispose);\n return dispose;\n}\n\n// test hook\nexport function stopWatcher(root: string): void {\n active.get(root)?.();\n}\n","import type { PluginOptions } from '@verbaly/compiler';\nimport { existsSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { dirname, join } from 'node:path';\nimport {\n GENERATED_DIR,\n generatedDir,\n syncAndWrite,\n writeGeneratedModules,\n type Compiler,\n type RequestOptions,\n} from './codegen';\nimport type { LoaderOptions } from './loader';\nimport { startWatcher } from './watch';\n\nexport type { VerbalyConfig } from '@verbaly/compiler';\nexport type { RequestOptions } from './codegen';\n\nexport interface NextVerbalyOptions extends PluginOptions {\n cookie?: string | false;\n fallback?: string;\n}\n\n// structural NextConfig subset (compat asserted in tests): no index signatures, Next has none\nexport interface WebpackConfigLike {\n resolve?: { alias?: Record<string, unknown>; [key: string]: unknown };\n module?: { rules?: unknown[]; [key: string]: unknown };\n plugins?: unknown[];\n [key: string]: unknown;\n}\n\ninterface WebpackContextLike {\n webpack?: {\n NormalModuleReplacementPlugin: new (test: RegExp, resource: string) => unknown;\n };\n}\n\n// context param is `never` so Next's real webpack fn (specific context type) stays assignable\nexport type WebpackFn = (config: WebpackConfigLike, context: never) => unknown;\n\nexport interface TurbopackLike {\n resolveAlias?: Record<string, unknown>;\n rules?: Record<string, unknown>;\n}\n\n// metadata is `never` for the same reason as the webpack context: Next's own type stays assignable\nexport interface CompilerLike {\n runAfterProductionCompile?: (metadata: never) => Promise<void>;\n}\n\nexport interface NextConfigLike {\n webpack?: WebpackFn | null;\n turbopack?: TurbopackLike;\n compiler?: CompilerLike;\n}\n\n// constraint is object, not NextConfigLike: an all-optional target rejects by weak-type\nexport type NextConfigInput<C extends object> =\n C | ((phase: string, context: { defaultConfig?: unknown }) => C | Promise<C>);\n\n// next/constants values: literal to keep this module import-free of next\nconst DEV_PHASE = 'phase-development-server';\nconst BUILD_PHASE = 'phase-production-build';\n// next experimental-analyze compiles the app as well, so it needs the generated modules on disk\nconst ANALYZE_PHASE = 'phase-analyze';\n\nconst LOADER = '@verbaly/next/loader';\n// matched via condition.path: a bare extension glob also hits Next's App Router entry\nconst SOURCE_PATH_RE = /\\.[cm]?[jt]sx?$/;\n\nexport function withVerbaly<C extends object>(\n nextConfig?: NextConfigInput<C>,\n options: NextVerbalyOptions = {},\n): (phase: string, context?: { defaultConfig?: unknown }) => Promise<C> {\n const { failOnMissing, cookie, fallback, ...verbalyConfig } = options;\n const requestOptions: RequestOptions = { cookie, fallback };\n\n return async (phase, context = {}) => {\n const base: C =\n typeof nextConfig === 'function'\n ? await nextConfig(phase, context)\n : (nextConfig ?? ({} as C));\n const root = verbalyConfig.root ?? process.cwd();\n\n // production server / export: everything is bundled, so no FS work, config only\n if (phase !== DEV_PHASE && phase !== BUILD_PHASE && phase !== ANALYZE_PHASE) {\n return composeConfig(base, root);\n }\n\n // dynamic: the compiler is ESM-only and this entry is also consumed as CJS\n const compiler: Compiler = await import('@verbaly/compiler');\n\n const cfg = await compiler.loadConfig(root, verbalyConfig, { plugin: true });\n const catalogs = compiler.loadCatalogs(cfg);\n const registry = await compiler.extractProject(cfg);\n // once per phase, from the config: a loader result can come from Turbopack's cache\n await compiler.reportOutsideInclude(cfg);\n let gate: (() => void) | undefined;\n\n if (phase === DEV_PHASE) {\n const texts = await syncAndWrite(compiler, cfg, catalogs, registry, requestOptions);\n startWatcher(compiler, cfg, requestOptions, texts);\n } else {\n // the code's text ships, as it does in dev: a catalog edit of a text it owns never wins\n compiler.syncCatalogs(cfg, catalogs, registry);\n writeGeneratedModules(compiler, cfg, catalogs, requestOptions);\n // next build and next typegen check types, and .verbaly/ is never committed\n compiler.writeDts(cfg, catalogs[cfg.sourceLocale] ?? {});\n if (phase === BUILD_PHASE) {\n const runGate = (): void => compiler.runBuildGate(cfg, registry, failOnMissing);\n // typegen loads this config in the build phase too, and only a real build runs the hook\n if (hasAfterCompileHook(cfg.root)) gate = runGate;\n else runGate();\n }\n }\n\n // the loader rewrites exactly what extract reads: a file outside include keeps its t`…`\n const scope: LoaderOptions = { root: cfg.root, include: cfg.include, exclude: cfg.exclude };\n return composeConfig(base, cfg.root, scope, gate);\n };\n}\n\nconst HOOK_FILE = 'next/dist/build/after-production-compile.js';\n\n// next build calls compiler.runAfterProductionCompile since 15.4; NODE_PATH may name another next\nfunction hasAfterCompileHook(root: string): boolean {\n for (let dir = root; ; dir = dirname(dir)) {\n const next = join(dir, 'node_modules', 'next');\n if (existsSync(join(next, 'package.json')))\n return existsSync(join(dir, 'node_modules', HOOK_FILE));\n if (dirname(dir) === dir) break;\n }\n // Yarn PnP has no node_modules, and its resolver finds the project's own next, never NODE_PATH's\n if (!process.versions.pnp) return false;\n try {\n createRequire(join(root, 'package.json')).resolve(HOOK_FILE);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction composeConfig<C extends object>(\n base: C,\n root: string,\n scope?: LoaderOptions,\n gate?: () => void,\n): C {\n const runtimeModule = join(generatedDir(root), 'index.js');\n const { webpack: userWebpack, turbopack, compiler: userCompiler } = base as NextConfigLike;\n const loader = scope ? { loader: LOADER, options: scope } : LOADER;\n\n const rules: Record<string, unknown> = { ...turbopack?.rules };\n const verbalyRule = {\n condition: { all: [{ not: 'foreign' }, { path: SOURCE_PATH_RE }] },\n loaders: [loader],\n };\n const existing = rules['*'];\n rules['*'] = existing\n ? [...(Array.isArray(existing) ? existing : [existing]), verbalyRule]\n : verbalyRule;\n\n return {\n ...base,\n ...(gate && {\n compiler: {\n ...userCompiler,\n // after the compile, so next typegen, which loads this config too, never meets the gate\n async runAfterProductionCompile(metadata: never) {\n await userCompiler?.runAfterProductionCompile?.(metadata);\n try {\n gate();\n } catch (error) {\n // Next prints a failed hook twice: the report goes out once, and the throw stays short\n console.error((error as Error).message);\n // eslint-disable-next-line preserve-caught-error -- a cause would print the report again\n throw new Error('[verbaly] build blocked, the reason is printed above');\n }\n },\n },\n }),\n turbopack: {\n ...turbopack,\n resolveAlias: {\n ...turbopack?.resolveAlias,\n 'virtual:verbaly': `./${GENERATED_DIR}/index.js`,\n },\n rules,\n },\n webpack(config: WebpackConfigLike, context: unknown) {\n // webpack 5 parses 'virtual:' as a URI scheme, so resolve.alias never fires\n const { webpack: webpackInstance } = (context ?? {}) as WebpackContextLike;\n if (webpackInstance?.NormalModuleReplacementPlugin) {\n config.plugins ??= [];\n config.plugins.push(\n new webpackInstance.NormalModuleReplacementPlugin(/^virtual:verbaly$/, runtimeModule),\n );\n }\n config.resolve ??= {};\n config.resolve.alias ??= {};\n (config.resolve.alias as Record<string, unknown>)['virtual:verbaly'] = runtimeModule;\n config.module ??= {};\n config.module.rules ??= [];\n config.module.rules.push({\n test: SOURCE_PATH_RE,\n exclude: /node_modules/,\n enforce: 'pre',\n use: [typeof loader === 'string' ? { loader } : loader],\n });\n return userWebpack ? userWebpack(config, context as never) : config;\n },\n } as C;\n}\n"],"mappings":";;;;AAIA,MAAM,4BAAY,IAAI,IAAyB;AAC/C,MAAM,8BAAc,IAAI,IAAY;AAKpC,SAAgB,UACd,UACA,KACA,QACA,UACW;CACX,IAAI,WAAW,UAAU,IAAI,IAAI,IAAI;CACrC,IAAI,CAAC,UAAU;EACb,WAAW,SAAS,kBAAkB,IAAI,IAAI;EAC9C,UAAU,IAAI,IAAI,MAAM,QAAQ;CAClC;CACA,MAAM,WAAsB,CAAC;CAC7B,MAAM,OAAkB,CAAC;CACzB,MAAM,OAAkB,CAAC;CACzB,KAAK,MAAM,WAAW,OAAO,UAAU;EACrC,IAAI,QAAQ,SAAS,eAAe,QAAQ,SAAS,WAAW,KAAK,KAAK,OAAO;EACjF,IAAI,QAAQ,SAAS,QAAQ,KAAK,KAAK,OAAO;EAC9C,IAAI,QAAQ,SAAS,YAAY;EAEjC,IAAI,YAAY,SAAS,IAAI,QAAQ,GAAG,MAAM,QAAQ,KAAK,SAAS;EACpE,SAAS,KA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AAa,CACtF;GACF;GACA,OAAO,YAAY,CAAC;GACpB,OAAO,QAAQ,UAAU,CAAC;GAC1B,OAAQ,QAAQ,MAAkC,qBAAqB;GACvE,OAAO,WAAW,CAAC;GACnB,OAAO,OAAO,UAAU,CAAC;GACzB,OAAO,OAAO,MAAM,KAAK;IACvB,MAAM;IACN,SAAS;IACT,SAAS;IACT,KAAK,CAAC,OAAO,WAAW,WAAW,EAAE,OAAO,IAAI,MAAM;GACxD,CAAC;GACD,OAAO,cAAc,YAAY,QAAQ,OAAgB,IAAI;EAC/D;CACF;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"loader.cjs","names":[],"sources":["../src/loader.ts"],"sourcesContent":["// webpack/turbopack loader: async because @verbaly/compiler is ESM-only (dynamic import)\n\n// what withVerbaly passes: the scope extract reads, so the loader rewrites nothing outside it\nexport interface LoaderOptions {\n root?: string;\n include?: string[];\n exclude?: string[];\n}\n\nexport interface LoaderContext {\n resourcePath: string;\n async(): (error: unknown, code?: string, map?: unknown) => void;\n getOptions?(): LoaderOptions;\n}\n\ntype Compiler = typeof import('@verbaly/compiler');\n\nlet compiler: Promise<Compiler> | undefined;\n// one matcher per scope: the loader runs once per module and picomatch compiles the globs\nconst filters = new Map<string, (id: string) => boolean>();\n\nfunction inScope(load: Compiler, options: LoaderOptions, file: string): boolean {\n // wired by hand with no options, the loader keeps rewriting every source file it is given\n if (!options.root || !options.include) return true;\n const key = JSON.stringify(options);\n let filter = filters.get(key);\n if (!filter) {\n const scope = { root: options.root, include: options.include, exclude: options.exclude ?? [] };\n filter = load.createSourceFilter(scope as Parameters<Compiler['createSourceFilter']>[0]);\n filters.set(key, filter);\n }\n return filter(file);\n}\n\nexport default function verbalyLoader(this: LoaderContext, source: string): void {\n const callback = this.async();\n const file = this.resourcePath;\n const options = this.getOptions?.() ?? {};\n compiler ??= import('@verbaly/compiler');\n compiler\n .then((load) => {\n if (!load.isTransformTarget(file) || !inScope(load, options, file)) {\n callback(null, source);\n return;\n }\n const result = load.transformCode(source, file);\n if (result) {\n // MagicString maps carry an empty source and Turbopack panics resolving it to a directory\n result.map.sources = [file];\n callback(null, result.code, result.map);\n } else {\n callback(null, source);\n }\n })\n .catch((error: unknown) => callback(error));\n}\n"],"mappings":";AAiBA,IAAI;AAEJ,MAAM,0BAAU,IAAI,IAAqC;AAEzD,SAAS,QAAQ,MAAgB,SAAwB,MAAuB;CAE9E,IAAI,CAAC,QAAQ,QAAQ,CAAC,QAAQ,SAAS,OAAO;CAC9C,MAAM,MAAM,KAAK,UAAU,OAAO;CAClC,IAAI,SAAS,QAAQ,IAAI,GAAG;CAC5B,IAAI,CAAC,QAAQ;EACX,MAAM,QAAQ;GAAE,MAAM,QAAQ;GAAM,SAAS,QAAQ;GAAS,SAAS,QAAQ,WAAW,CAAC;EAAE;EAC7F,SAAS,KAAK,mBAAmB,KAAsD;EACvF,QAAQ,IAAI,KAAK,MAAM;CACzB;CACA,OAAO,OAAO,IAAI;AACpB;AAEA,SAAwB,cAAmC,QAAsB;CAC/E,MAAM,WAAW,KAAK,MAAM;CAC5B,MAAM,OAAO,KAAK;CAClB,MAAM,UAAU,KAAK,aAAa,KAAK,CAAC;CACxC,aAAa,OAAO;CACpB,SACG,MAAM,SAAS;EACd,IAAI,CAAC,KAAK,kBAAkB,IAAI,KAAK,CAAC,QAAQ,MAAM,SAAS,IAAI,GAAG;GAClE,SAAS,MAAM,MAAM;GACrB;EACF;EACA,MAAM,SAAS,KAAK,cAAc,QAAQ,IAAI;EAC9C,IAAI,QAAQ;GAEV,OAAO,IAAI,UAAU,CAAC,IAAI;GAC1B,SAAS,MAAM,OAAO,MAAM,OAAO,GAAG;EACxC,OACE,SAAS,MAAM,MAAM;CAEzB,CAAC,CAAC,CACD,OAAO,UAAmB,SAAS,KAAK,CAAC;AAC9C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.js","names":[],"sources":["../src/server.ts"],"sourcesContent":["import { renderTrans, type TransProps } from '@verbaly/react/server';\nimport { cookies, headers } from 'next/headers';\nimport * as React from 'react';\nimport {\n alternateLinks,\n localeFromPath,\n LOCALE_STORAGE_KEY,\n resolveRequestLocale,\n warnOnce,\n type AlternateLink,\n type Locale,\n type Translate,\n type Verbaly,\n} from 'verbaly';\nimport {\n createRequestInstance,\n loadMessages,\n locales,\n requestOptions,\n routing,\n sourceLocale,\n} from 'virtual:verbaly';\n\ninterface RequestState {\n locale: string;\n instance: Verbaly;\n}\n\n// React.cache = per-request dedupe in RSC; identity fallback keeps plain-node tests runnable\nconst perRequest: <T extends (...args: never[]) => unknown>(fn: T) => T =\n (React as { cache?: <T>(fn: T) => T }).cache ?? ((fn) => fn);\n\ninterface LocaleHolder {\n locale?: string;\n}\n\nconst scopedHolder = perRequest((): LocaleHolder => ({}));\nconst moduleHolder: LocaleHolder = {};\n\n// React.cache only holds inside a request, and outside one there is a single request to hold for\nfunction holder(): LocaleHolder {\n const scoped = scopedHolder();\n return scoped === scopedHolder() ? scoped : moduleHolder;\n}\n\n// call it from the layout with the [locale] segment: reading headers() kills static rendering\nexport function setRequestLocale(locale: string): void {\n // a segment says the url carries the locale, and no-prefix tells every url helper it does not\n if (routing === 'no-prefix') {\n warnOnce(\n `setRequestLocale got a locale segment while routing is \"no-prefix\": if your urls start ` +\n `with the locale, set routing to 'prefix-all' or 'prefix-except-source' in your verbaly config`,\n );\n }\n holder().locale = locale;\n}\n\n// a route segment is a url segment, so it narrows like one: a slug must never become a locale\nfunction declaredLocale(): string | undefined {\n const raw = holder().locale;\n if (raw === undefined) return undefined;\n const match = localeFromPath({ supported: locales, path: `/${raw}` });\n if (match) return match;\n warnOnce(`setRequestLocale was given a locale the project does not have, so it was ignored`);\n return undefined;\n}\n\n// a locale asked for by name narrows the same way, and one the project lacks falls to the source\nfunction namedLocale(raw: string): string {\n const match = localeFromPath({ supported: locales, path: `/${raw}` });\n if (match) return match;\n warnOnce(`getT was asked for a locale the project does not have, so it answers in the source`);\n return sourceLocale;\n}\n\n// one instance per locale and request: an OG image, a sitemap or an email asks without headers()\nconst instanceFor = perRequest((locale: string) => createRequestInstance(locale));\n\n// only reached when no segment declared it: this read is what opts a route out of static\nasync function negotiate(): Promise<string> {\n const cookieName = requestOptions?.cookie ?? LOCALE_STORAGE_KEY;\n const headerStore = await headers();\n const cookieValue = cookieName === false ? undefined : (await cookies()).get(cookieName)?.value;\n return resolveRequestLocale({\n supported: locales,\n routing,\n cookie: cookieValue,\n header: headerStore.get('accept-language'),\n fallback: requestOptions?.fallback ?? sourceLocale,\n });\n}\n\nconst getRequestState = perRequest(async (): Promise<RequestState> => {\n const locale = declaredLocale() ?? (await negotiate());\n return { locale, instance: await createRequestInstance(locale) };\n});\n\nexport interface AlternatesOptions {\n path: string;\n baseUrl?: string;\n}\n\n// the hreflang set for generateMetadata, in the shape Next's alternates field takes\nexport function getAlternates(options: AlternatesOptions): {\n canonical?: string;\n languages: Record<string, string>;\n} {\n const links: AlternateLink[] = alternateLinks({\n supported: locales,\n sourceLocale,\n routing,\n path: options.path,\n baseUrl: options.baseUrl,\n });\n const languages: Record<string, string> = {};\n for (const link of links) languages[link.hreflang] = link.href;\n const self = localeFromPath({ supported: locales, path: options.path }) ?? sourceLocale;\n return { canonical: languages[self], languages };\n}\n\n// request-scoped instance: never the virtual:verbaly singleton (locale would leak between requests)\nexport async function getVerbaly(): Promise<Verbaly> {\n return (await getRequestState()).instance;\n}\n\nexport interface GetTOptions {\n locale?: string;\n}\n\n// with a locale it never reads headers(), so a route that only renders it stays static\nexport async function getT(options: GetTOptions = {}): Promise<Translate> {\n if (options.locale !== undefined) return (await instanceFor(namedLocale(options.locale))).t;\n return (await getRequestState()).instance.t;\n}\n\nexport async function getRequestLocale(): Promise<Locale> {\n return (await getRequestState()).locale as Locale;\n}\n\n// a Server Component: the request's instance, so a server render needs no provider\nexport async function Trans(props: TransProps): Promise<React.ReactElement> {\n return renderTrans(props.instance ?? (await getVerbaly()), props);\n}\n\nexport interface VerbalyProviderProps {\n locale: string;\n messages?: Record<string, string>;\n}\n\n// messages omitted for the source locale: it already ships inline in the client bundle\nexport async function getVerbalyProps(): Promise<VerbalyProviderProps> {\n const { locale } = await getRequestState();\n if (locale === sourceLocale) return { locale };\n return { locale, messages: await loadMessages(locale) };\n}\n"],"mappings":";;;;;;AA6BA,MAAM,aACH,MAAsC,WAAW,OAAO;AAM3D,MAAM,eAAe,kBAAgC,CAAC,EAAE;AACxD,MAAM,eAA6B,CAAC;AAGpC,SAAS,SAAuB;CAC9B,MAAM,SAAS,aAAa;CAC5B,OAAO,WAAW,aAAa,IAAI,SAAS;AAC9C;AAGA,SAAgB,iBAAiB,QAAsB;CAErD,IAAI,YAAY,aACd,SACE,wLAEF;CAEF,OAAO,CAAC,CAAC,SAAS;AACpB;AAGA,SAAS,iBAAqC;CAC5C,MAAM,MAAM,OAAO,CAAC,CAAC;CACrB,IAAI,QAAQ,KAAA,GAAW,OAAO,KAAA;CAC9B,MAAM,QAAQ,eAAe;EAAE,WAAW;EAAS,MAAM,IAAI;CAAM,CAAC;CACpE,IAAI,OAAO,OAAO;CAClB,SAAS,kFAAkF;AAE7F;AAGA,SAAS,YAAY,KAAqB;CACxC,MAAM,QAAQ,eAAe;EAAE,WAAW;EAAS,MAAM,IAAI;CAAM,CAAC;CACpE,IAAI,OAAO,OAAO;CAClB,SAAS,oFAAoF;CAC7F,OAAO;AACT;AAGA,MAAM,cAAc,YAAY,WAAmB,sBAAsB,MAAM,CAAC;AAGhF,eAAe,YAA6B;CAC1C,MAAM,aAAa,gBAAgB,UAAU;CAC7C,MAAM,cAAc,MAAM,QAAQ;CAClC,MAAM,cAAc,eAAe,QAAQ,KAAA,KAAa,MAAM,QAAQ,EAAA,CAAG,IAAI,UAAU,CAAC,EAAE;CAC1F,OAAO,qBAAqB;EAC1B,WAAW;EACX;EACA,QAAQ;EACR,QAAQ,YAAY,IAAI,iBAAiB;EACzC,UAAU,gBAAgB,YAAY;CACxC,CAAC;AACH;AAEA,MAAM,kBAAkB,WAAW,YAAmC;CACpE,M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