@verbaly/compiler 0.80.0 → 0.81.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _t as isModuleNotFound, ut as counted } from "./run-
|
|
1
|
+
import { _t as isModuleNotFound, ut as counted } from "./run-DitFmP5s.js";
|
|
2
2
|
// src/exchange/providers/claude.ts
|
|
3
3
|
const DEFAULT_MODEL = "claude-sonnet-5-5";
|
|
4
4
|
const FALLBACK_MODELS = /* @__PURE__ */ new Set([
|
package/dist/cli.js
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as validatePair, A as check, B as readState, C as isTransformTarget, D as transformSource, E as runBuildGate, F as clearDrafts, G as createDevReporter, H as saveState, I as effectiveDrafts, J as generateDts, K as formatCollision, L as loadState, M as formatCheckWarnings, N as syncProject, O as writeBuildTypes, P as STATE_FILE, Q as validateMessage, R as markDrafts, S as createSourceFilter, T as resolveVirtualId, U as updateState, V as recordTranslations, W as collisionEntries, X as generateRuntimeModule, Y as generateLocaleModule, Z as writeDts, _ as status, a as renderSite, at as stableKey, b as RESOLVED_VIRTUAL_ID, bt as targetLocales, c as formatTranslateFailures, ct as MessageRegistry, d as translateCatalogs, dt as loadCatalogs, et as collectOrigins, f as writeDrafts, ft as needsIcu, g as formatStatusResult, gt as writeCatalog, h as formatDoctorHealth, ht as readCatalog, i as formatRenderWarnings, it as syncCatalogs, j as formatCheckResult, k as transformCode, l as mergeTranslations, lt as clientCatalogs, m as formatDoctorEntry, mt as parseCatalog, nt as pruneCatalogs, o as init, ot as APP_ID, p as doctor, pt as needsRelative, q as formatFinding, r as wrapProject, rt as shippedCatalogs, s as watchTree, st as LOCALE_IMPORT, t as formatCliError, tt as extractProject, u as resolveProvider, ut as counted, v as reportOutsideInclude, vt as loadConfig, w as loadVirtualModule, x as SOURCE_FILE_RE, y as LOCALE_MODULE_PREFIX, yt as resolveConfig, z as outdatedTranslations } from "./run-
|
|
1
|
+
import { $ as validatePair, A as check, B as readState, C as isTransformTarget, D as transformSource, E as runBuildGate, F as clearDrafts, G as createDevReporter, H as saveState, I as effectiveDrafts, J as generateDts, K as formatCollision, L as loadState, M as formatCheckWarnings, N as syncProject, O as writeBuildTypes, P as STATE_FILE, Q as validateMessage, R as markDrafts, S as createSourceFilter, T as resolveVirtualId, U as updateState, V as recordTranslations, W as collisionEntries, X as generateRuntimeModule, Y as generateLocaleModule, Z as writeDts, _ as status, a as renderSite, at as stableKey, b as RESOLVED_VIRTUAL_ID, bt as targetLocales, c as formatTranslateFailures, ct as MessageRegistry, d as translateCatalogs, dt as loadCatalogs, et as collectOrigins, f as writeDrafts, ft as needsIcu, g as formatStatusResult, gt as writeCatalog, h as formatDoctorHealth, ht as readCatalog, i as formatRenderWarnings, it as syncCatalogs, j as formatCheckResult, k as transformCode, l as mergeTranslations, lt as clientCatalogs, m as formatDoctorEntry, mt as parseCatalog, nt as pruneCatalogs, o as init, ot as APP_ID, p as doctor, pt as needsRelative, q as formatFinding, r as wrapProject, rt as shippedCatalogs, s as watchTree, st as LOCALE_IMPORT, t as formatCliError, tt as extractProject, u as resolveProvider, ut as counted, v as reportOutsideInclude, vt as loadConfig, w as loadVirtualModule, x as SOURCE_FILE_RE, y as LOCALE_MODULE_PREFIX, yt as resolveConfig, z as outdatedTranslations } from "./run-DitFmP5s.js";
|
|
2
2
|
// src/catalog/drafts.ts
|
|
3
3
|
function loadDrafts(cfg) {
|
|
4
4
|
return loadState(cfg).drafts;
|
|
@@ -55,6 +55,7 @@ const HOSTS = [
|
|
|
55
55
|
},
|
|
56
56
|
{
|
|
57
57
|
name: "vite",
|
|
58
|
+
bundler: true,
|
|
58
59
|
dep: "vite",
|
|
59
60
|
pkg: "@verbaly/vite",
|
|
60
61
|
install: ["verbaly", "@verbaly/vite"],
|
|
@@ -62,6 +63,7 @@ const HOSTS = [
|
|
|
62
63
|
},
|
|
63
64
|
{
|
|
64
65
|
name: "webpack",
|
|
66
|
+
bundler: true,
|
|
65
67
|
dep: "webpack",
|
|
66
68
|
pkg: "@verbaly/unplugin",
|
|
67
69
|
install: ["verbaly", "@verbaly/unplugin"],
|
|
@@ -69,6 +71,7 @@ const HOSTS = [
|
|
|
69
71
|
},
|
|
70
72
|
{
|
|
71
73
|
name: "rspack",
|
|
74
|
+
bundler: true,
|
|
72
75
|
dep: "@rspack/core",
|
|
73
76
|
pkg: "@verbaly/unplugin",
|
|
74
77
|
install: ["verbaly", "@verbaly/unplugin"],
|
|
@@ -76,6 +79,7 @@ const HOSTS = [
|
|
|
76
79
|
},
|
|
77
80
|
{
|
|
78
81
|
name: "rollup",
|
|
82
|
+
bundler: true,
|
|
79
83
|
dep: "rollup",
|
|
80
84
|
pkg: "@verbaly/unplugin",
|
|
81
85
|
install: ["verbaly", "@verbaly/unplugin"],
|
|
@@ -83,6 +87,7 @@ const HOSTS = [
|
|
|
83
87
|
},
|
|
84
88
|
{
|
|
85
89
|
name: "esbuild",
|
|
90
|
+
bundler: true,
|
|
86
91
|
dep: "esbuild",
|
|
87
92
|
pkg: "@verbaly/unplugin",
|
|
88
93
|
install: ["verbaly", "@verbaly/unplugin"],
|
|
@@ -103,9 +108,42 @@ function readDependencies(root) {
|
|
|
103
108
|
return {};
|
|
104
109
|
}
|
|
105
110
|
}
|
|
111
|
+
const ADAPTERS = [
|
|
112
|
+
["@verbaly/react", [
|
|
113
|
+
"react",
|
|
114
|
+
"preact",
|
|
115
|
+
"@verbaly/react"
|
|
116
|
+
]],
|
|
117
|
+
["@verbaly/vue", [
|
|
118
|
+
"vue",
|
|
119
|
+
"nuxt",
|
|
120
|
+
"@verbaly/vue"
|
|
121
|
+
]],
|
|
122
|
+
["@verbaly/svelte", [
|
|
123
|
+
"svelte",
|
|
124
|
+
"@sveltejs/kit",
|
|
125
|
+
"@verbaly/svelte"
|
|
126
|
+
]]
|
|
127
|
+
];
|
|
128
|
+
function adaptersIn(deps) {
|
|
129
|
+
return ADAPTERS.filter(([, libs]) => libs.some((lib) => deps[lib])).map(([adapter]) => adapter);
|
|
130
|
+
}
|
|
131
|
+
function componentAdapters(root) {
|
|
132
|
+
return adaptersIn(readDependencies(root));
|
|
133
|
+
}
|
|
106
134
|
function detectHost(root) {
|
|
107
135
|
const deps = readDependencies(root);
|
|
108
|
-
|
|
136
|
+
const host = HOSTS.find((entry) => deps[entry.dep]);
|
|
137
|
+
if (!host?.bundler) return host;
|
|
138
|
+
const install = [
|
|
139
|
+
...host.install.slice(0, 1),
|
|
140
|
+
...adaptersIn(deps),
|
|
141
|
+
...host.install.slice(1)
|
|
142
|
+
];
|
|
143
|
+
return {
|
|
144
|
+
...host,
|
|
145
|
+
install
|
|
146
|
+
};
|
|
109
147
|
}
|
|
110
148
|
const LOCKFILES = [
|
|
111
149
|
["pnpm-lock.yaml", "pnpm"],
|
|
@@ -3997,7 +4035,7 @@ function formatTranslateFailures(failed) {
|
|
|
3997
4035
|
async function resolveProvider(cfg, model) {
|
|
3998
4036
|
const configured = cfg.translate.provider;
|
|
3999
4037
|
if (typeof configured === "function") return configured;
|
|
4000
|
-
const { claudeProvider } = await import("./claude-
|
|
4038
|
+
const { claudeProvider } = await import("./claude-XvHG5Neu.js");
|
|
4001
4039
|
return claudeProvider({ model: model ?? cfg.translate.model });
|
|
4002
4040
|
}
|
|
4003
4041
|
function structureMatches(source, translated) {
|
|
@@ -5616,6 +5654,17 @@ const CODE_TAGS = /* @__PURE__ */ new Set([
|
|
|
5616
5654
|
const T_NAMES = /* @__PURE__ */ new Set(["t"]);
|
|
5617
5655
|
const LETTER = /\p{L}/u;
|
|
5618
5656
|
const WHITESPACE = /\s/;
|
|
5657
|
+
const JSX_ADAPTERS = /* @__PURE__ */ new Set(["@verbaly/react", "@verbaly/vue"]);
|
|
5658
|
+
function jsxAdapters(root) {
|
|
5659
|
+
const named = componentAdapters(root).filter((adapter) => JSX_ADAPTERS.has(adapter));
|
|
5660
|
+
return named.length > 0 ? named : ["@verbaly/react"];
|
|
5661
|
+
}
|
|
5662
|
+
function bindingFor(cfg, adapters, client) {
|
|
5663
|
+
if (cfg.host !== "next") return `in the component: \`const t = useT()\` from ${adapters().join(" or ")}`;
|
|
5664
|
+
const onClient = "`const t = useT()` from @verbaly/next/client";
|
|
5665
|
+
if (client) return `"use client", so ${onClient}`;
|
|
5666
|
+
return `no "use client": a Server Component takes \`const t = await getT()\` from @verbaly/next/server, a client one ${onClient}`;
|
|
5667
|
+
}
|
|
5619
5668
|
async function wrapProject(cfg, options = {}) {
|
|
5620
5669
|
const files = (await glob(cfg.include, {
|
|
5621
5670
|
cwd: cfg.root,
|
|
@@ -5629,6 +5678,8 @@ async function wrapProject(cfg, options = {}) {
|
|
|
5629
5678
|
skipped: [],
|
|
5630
5679
|
blocked: []
|
|
5631
5680
|
};
|
|
5681
|
+
let found;
|
|
5682
|
+
const adapters = () => found ??= jsxAdapters(cfg.root);
|
|
5632
5683
|
for (const file of files) {
|
|
5633
5684
|
const code = readFileSync(file, "utf8");
|
|
5634
5685
|
const label = relative(cfg.root, file).replaceAll("\\", "/");
|
|
@@ -5638,10 +5689,12 @@ async function wrapProject(cfg, options = {}) {
|
|
|
5638
5689
|
if (out.code === void 0) continue;
|
|
5639
5690
|
result.changed.push(label);
|
|
5640
5691
|
if (!out.hasT) {
|
|
5692
|
+
const binding = bindingFor(cfg, adapters, out.client);
|
|
5641
5693
|
result.blocked.push({
|
|
5642
5694
|
file: label,
|
|
5643
5695
|
texts: out.wrapped.length,
|
|
5644
|
-
client: out.client
|
|
5696
|
+
client: out.client,
|
|
5697
|
+
binding
|
|
5645
5698
|
});
|
|
5646
5699
|
continue;
|
|
5647
5700
|
}
|
|
@@ -5875,12 +5928,6 @@ function line(node) {
|
|
|
5875
5928
|
return node.loc?.start?.line ?? 1;
|
|
5876
5929
|
}
|
|
5877
5930
|
// src/cli/commands/wrap.ts
|
|
5878
|
-
function binding(cfg, client) {
|
|
5879
|
-
if (cfg.host !== "next") return "in the component: `const t = useT()` from @verbaly/react";
|
|
5880
|
-
const onClient = "`const t = useT()` from @verbaly/next/client";
|
|
5881
|
-
if (client) return `"use client", so ${onClient}`;
|
|
5882
|
-
return `no "use client": a Server Component takes \`const t = await getT()\` from @verbaly/next/server, a client one ${onClient}`;
|
|
5883
|
-
}
|
|
5884
5931
|
async function wrapCommand(cfg, values) {
|
|
5885
5932
|
const result = await wrapProject(cfg, { write: values.write });
|
|
5886
5933
|
if (result.wrapped.length === 0 && result.skipped.length === 0) {
|
|
@@ -5906,7 +5953,7 @@ async function wrapCommand(cfg, values) {
|
|
|
5906
5953
|
}
|
|
5907
5954
|
if (result.blocked.length > 0) {
|
|
5908
5955
|
console.log(` nothing written in ${counted(result.blocked.length, "file")} with no t in scope:`);
|
|
5909
|
-
for (const entry of result.blocked) console.log(` ${entry.file} ${counted(entry.texts, "text")}, ${
|
|
5956
|
+
for (const entry of result.blocked) console.log(` ${entry.file} ${counted(entry.texts, "text")}, ${entry.binding}`);
|
|
5910
5957
|
console.log(" next: add t there, run verbaly wrap --write again, then verbaly extract");
|
|
5911
5958
|
} else if (values.write && done.length > 0) console.log(" next: run verbaly extract");
|
|
5912
5959
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verbaly/compiler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.81.0",
|
|
4
4
|
"description": "Message extraction and type-safe codegen for Verbaly.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"i18n",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"magic-string": "^1.4.5",
|
|
53
53
|
"picomatch": "^4.0.7",
|
|
54
54
|
"tinyglobby": "^0.2.17",
|
|
55
|
-
"verbaly": "0.
|
|
55
|
+
"verbaly": "0.81.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"@anthropic-ai/sdk": ">=0.110.0"
|