@verbaly/next 0.81.0 → 0.83.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 +4 -0
- package/dist/index.cjs +10 -35
- package/dist/index.js +10 -35
- package/dist/server.js +9 -12
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
8
|
<a href="https://www.npmjs.com/package/@verbaly/next"><img src="https://img.shields.io/npm/v/@verbaly/next?logo=npm&color=cb3837" alt="npm version" /></a>
|
|
9
|
+
<a href="https://verbaly-web.vercel.app/docs/frameworks/react#next"><img src="https://img.shields.io/npm/dependency-version/@verbaly/next/peer/next?logo=nextdotjs&logoColor=white&label=Next.js&color=000000" alt="supported Next.js versions" /></a>
|
|
10
|
+
<a href="https://github.com/AronSoto/verbaly/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/AronSoto/verbaly/ci.yml?logo=github&label=CI" alt="CI" /></a>
|
|
11
|
+
<a href="https://scorecard.dev/viewer/?uri=github.com/AronSoto/verbaly"><img src="https://api.scorecard.dev/projects/github.com/AronSoto/verbaly/badge" alt="OpenSSF Scorecard" /></a>
|
|
12
|
+
<a href="https://www.npmjs.com/package/@verbaly/next#provenance"><img src="https://img.shields.io/badge/provenance-SLSA%20v1-3fb950?logo=npm" alt="published with npm provenance" /></a>
|
|
9
13
|
<a href="https://github.com/AronSoto/verbaly/blob/develop/LICENSE"><img src="https://img.shields.io/npm/l/@verbaly/next?color=blue" alt="MIT" /></a>
|
|
10
14
|
</p>
|
|
11
15
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
|
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`),
|
|
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;
|
|
@@ -227,11 +202,11 @@ function withVerbaly(nextConfig, options = {}) {
|
|
|
227
202
|
const root = verbalyConfig.root ?? process.cwd();
|
|
228
203
|
if (phase !== DEV_PHASE && phase !== BUILD_PHASE && phase !== ANALYZE_PHASE) return composeConfig(base, root);
|
|
229
204
|
const compiler = await import("@verbaly/compiler");
|
|
230
|
-
const
|
|
205
|
+
const overrides = {
|
|
231
206
|
trailingSlash: base.trailingSlash ? "always" : "never",
|
|
232
207
|
...verbalyConfig
|
|
233
208
|
};
|
|
234
|
-
const cfg = await compiler.loadConfig(root,
|
|
209
|
+
const cfg = await compiler.loadConfig(root, overrides, { plugin: true });
|
|
235
210
|
const catalogs = compiler.loadCatalogs(cfg);
|
|
236
211
|
const registry = await compiler.extractProject(cfg);
|
|
237
212
|
await compiler.reportOutsideInclude(cfg);
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
|
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`),
|
|
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;
|
|
@@ -226,11 +201,11 @@ function withVerbaly(nextConfig, options = {}) {
|
|
|
226
201
|
const root = verbalyConfig.root ?? process.cwd();
|
|
227
202
|
if (phase !== DEV_PHASE && phase !== BUILD_PHASE && phase !== ANALYZE_PHASE) return composeConfig(base, root);
|
|
228
203
|
const compiler = await import("@verbaly/compiler");
|
|
229
|
-
const
|
|
204
|
+
const overrides = {
|
|
230
205
|
trailingSlash: base.trailingSlash ? "always" : "never",
|
|
231
206
|
...verbalyConfig
|
|
232
207
|
};
|
|
233
|
-
const cfg = await compiler.loadConfig(root,
|
|
208
|
+
const cfg = await compiler.loadConfig(root, overrides, { plugin: true });
|
|
234
209
|
const catalogs = compiler.loadCatalogs(cfg);
|
|
235
210
|
const registry = await compiler.extractProject(cfg);
|
|
236
211
|
await compiler.reportOutsideInclude(cfg);
|
package/dist/server.js
CHANGED
|
@@ -16,23 +16,23 @@ function setRequestLocale(locale) {
|
|
|
16
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");
|
|
17
17
|
holder().locale = locale;
|
|
18
18
|
}
|
|
19
|
+
function projectLocale(name) {
|
|
20
|
+
return localeFromPath({
|
|
21
|
+
supported: locales,
|
|
22
|
+
path: `/${name}`
|
|
23
|
+
});
|
|
24
|
+
}
|
|
19
25
|
async function declaredLocale() {
|
|
20
26
|
const raw = holder().locale;
|
|
21
27
|
if (raw !== void 0) {
|
|
22
|
-
const match =
|
|
23
|
-
supported: locales,
|
|
24
|
-
path: `/${raw}`
|
|
25
|
-
});
|
|
28
|
+
const match = projectLocale(raw);
|
|
26
29
|
if (match) return match;
|
|
27
30
|
warnOnce(`setRequestLocale was given a locale the project does not have, so it was ignored`);
|
|
28
31
|
return;
|
|
29
32
|
}
|
|
30
33
|
const segment = await rootSegment();
|
|
31
34
|
if (segment === void 0) return void 0;
|
|
32
|
-
const match =
|
|
33
|
-
supported: locales,
|
|
34
|
-
path: `/${segment}`
|
|
35
|
-
});
|
|
35
|
+
const match = projectLocale(segment);
|
|
36
36
|
if (match) return match;
|
|
37
37
|
warnOnce(`the locale segment of the url holds a locale the project does not have, so it was ignored`);
|
|
38
38
|
}
|
|
@@ -44,10 +44,7 @@ async function rootSegment() {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
function namedLocale(raw) {
|
|
47
|
-
const match =
|
|
48
|
-
supported: locales,
|
|
49
|
-
path: `/${raw}`
|
|
50
|
-
});
|
|
47
|
+
const match = projectLocale(raw);
|
|
51
48
|
if (match) return match;
|
|
52
49
|
warnOnce(`getT was asked for a locale the project does not have, so it answers in the source`);
|
|
53
50
|
return sourceLocale;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verbaly/next",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.83.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.
|
|
71
|
+
"@verbaly/compiler": "^0.83.0"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
|
-
"@verbaly/react": "^0.
|
|
74
|
+
"@verbaly/react": "^0.83.0",
|
|
75
75
|
"next": "^15.0.0 || ^16.0.0",
|
|
76
76
|
"react": "^18.0.0 || ^19.0.0",
|
|
77
|
-
"verbaly": "^0.
|
|
77
|
+
"verbaly": "^0.83.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.
|
|
82
|
+
"@verbaly/react": "^0.83.0",
|
|
83
83
|
"happy-dom": "^21.0.4",
|
|
84
|
-
"next": "^16.4.
|
|
84
|
+
"next": "^16.4.6",
|
|
85
85
|
"react": "^19.3.1",
|
|
86
86
|
"react-dom": "^19.3.1",
|
|
87
|
-
"verbaly": "^0.
|
|
87
|
+
"verbaly": "^0.83.0"
|
|
88
88
|
},
|
|
89
89
|
"scripts": {
|
|
90
90
|
"build": "tsdown",
|