@verbaly/compiler 0.73.0 → 0.75.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 +3 -1
- package/dist/{claude-Baoc6pYL.js → claude-DcV4YBbO.js} +2 -2
- package/dist/{claude-Baoc6pYL.js.map → claude-DcV4YBbO.js.map} +1 -1
- package/dist/cli.js +77 -19
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +46 -23
- package/dist/index.js.map +1 -1
- package/dist/{text-BMBWE8tL.js → text-BtTS6qL7.js} +40 -4
- package/dist/text-BtTS6qL7.js.map +1 -0
- package/package.json +3 -2
- package/dist/text-BMBWE8tL.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -205,7 +205,9 @@ interface ResolvedConfig {
|
|
|
205
205
|
}
|
|
206
206
|
export declare function resolveConfig(config?: VerbalyConfig): ResolvedConfig;
|
|
207
207
|
export declare function targetLocales(cfg: ResolvedConfig, override?: string[]): string[];
|
|
208
|
-
export declare function loadConfig(root: string, overrides?: VerbalyConfig
|
|
208
|
+
export declare function loadConfig(root: string, overrides?: VerbalyConfig, from?: {
|
|
209
|
+
plugin?: boolean;
|
|
210
|
+
}): Promise<ResolvedConfig>;
|
|
209
211
|
//#endregion
|
|
210
212
|
//#region src/bundle.d.ts
|
|
211
213
|
export declare function clientCatalogs(cfg: ResolvedConfig, catalogs: Catalogs): Catalogs;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as findConfigFile, c as loadConfigFile, d as
|
|
1
|
+
import { a as findConfigFile, c as loadConfigFile, d as warnOnce, f as warnParseError, g as readDependencies, h as installCommand, i as SOURCE_EXTENSIONS, l as resolveConfig, m as detectHost, n as counted, p as WIRING_PACKAGES, r as truncate, s as loadConfig, t as byCodeUnit, u as targetLocales } from "./text-BtTS6qL7.js";
|
|
2
2
|
import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, rmSync, watch, writeFileSync } from "node:fs";
|
|
3
3
|
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
4
4
|
import { CATALOG_SCRIPT, LOCALE_STORAGE_KEY, RICH_TAGS, VOID_TAGS, alternateLinks, createVerbaly, flatten, localeDirection, normalizeLink, parse, parseIcu, parseTags, safeAttribute } from "verbaly";
|
|
@@ -752,11 +752,14 @@ function tokenText(token) {
|
|
|
752
752
|
}
|
|
753
753
|
function blockEnd(tokens, start, pairs) {
|
|
754
754
|
let depth = 0;
|
|
755
|
+
let head = true;
|
|
755
756
|
for (let k = start; k < tokens.length; k++) {
|
|
756
757
|
const token = tokens[k];
|
|
757
758
|
if (typeof token !== "string") {
|
|
758
759
|
if (token.head) depth += 1;
|
|
759
|
-
} else if (token === "
|
|
760
|
+
} else if (token === "|" && depth === 1) head = false;
|
|
761
|
+
else if (token === "}" && head && depth === 1) return k;
|
|
762
|
+
else if (token === "{" || token === "}") {
|
|
760
763
|
if (tokens[k + 1] === token && (token === "{" || !(pairs && depth > 1))) k += 1;
|
|
761
764
|
else {
|
|
762
765
|
depth += token === "{" ? 1 : -1;
|
|
@@ -1083,7 +1086,26 @@ function pruneCatalogs(cfg, catalogs, registry) {
|
|
|
1083
1086
|
}
|
|
1084
1087
|
//#endregion
|
|
1085
1088
|
//#region src/validate.ts
|
|
1086
|
-
|
|
1089
|
+
let remembered = /* @__PURE__ */ new Map();
|
|
1090
|
+
let reading;
|
|
1091
|
+
function read(message) {
|
|
1092
|
+
if (!reading) return parse(message, parseIcu);
|
|
1093
|
+
let tree = reading.get(message);
|
|
1094
|
+
if (!tree) {
|
|
1095
|
+
tree = remembered.get(message) ?? parse(message, parseIcu);
|
|
1096
|
+
reading.set(message, tree);
|
|
1097
|
+
}
|
|
1098
|
+
return tree;
|
|
1099
|
+
}
|
|
1100
|
+
function gatePass(run) {
|
|
1101
|
+
reading = /* @__PURE__ */ new Map();
|
|
1102
|
+
try {
|
|
1103
|
+
return run();
|
|
1104
|
+
} finally {
|
|
1105
|
+
remembered = reading;
|
|
1106
|
+
reading = void 0;
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1087
1109
|
const PLURAL_CATEGORIES = /* @__PURE__ */ new Set([
|
|
1088
1110
|
"zero",
|
|
1089
1111
|
"one",
|
|
@@ -1377,17 +1399,6 @@ function includeTypes(root, file) {
|
|
|
1377
1399
|
writeFileSync(read.path, applyEdits(read.text, edits));
|
|
1378
1400
|
return "added";
|
|
1379
1401
|
}
|
|
1380
|
-
//#endregion
|
|
1381
|
-
//#region src/warn.ts
|
|
1382
|
-
const warned = /* @__PURE__ */ new Set();
|
|
1383
|
-
function warnOnce(message, dedupeKey = message) {
|
|
1384
|
-
if (warned.has(dedupeKey)) return;
|
|
1385
|
-
warned.add(dedupeKey);
|
|
1386
|
-
console.warn(`[verbaly] ${message}`);
|
|
1387
|
-
}
|
|
1388
|
-
function warnParseError(file, message) {
|
|
1389
|
-
warnOnce(`${file}: could not be parsed (${message}), its messages were not extracted`);
|
|
1390
|
-
}
|
|
1391
1402
|
const DTS_HEADER = "// generated by verbaly: do not edit";
|
|
1392
1403
|
const SLICE_HELPERS = `function readSlice(root, path) {
|
|
1393
1404
|
const locale = readPath({ supported: locales, path });
|
|
@@ -1638,7 +1649,8 @@ function removeRootDts(cfg, target) {
|
|
|
1638
1649
|
}
|
|
1639
1650
|
if (head !== "// generated by verbaly: do not edit") return;
|
|
1640
1651
|
rmSync(old);
|
|
1641
|
-
|
|
1652
|
+
const moved = relative(cfg.root, target).replaceAll("\\", "/");
|
|
1653
|
+
warnOnce(`the types live in ${moved} now, so the verbaly.d.ts Verbaly wrote at the root was removed`);
|
|
1642
1654
|
}
|
|
1643
1655
|
//#endregion
|
|
1644
1656
|
//#region src/findings.ts
|
|
@@ -2316,6 +2328,9 @@ function warningCount(result) {
|
|
|
2316
2328
|
return result.broken.filter((entry) => entry.severity === "warning").length + result.extra.length + result.divergent.length + result.outdated.length;
|
|
2317
2329
|
}
|
|
2318
2330
|
function check(cfg, catalogs, registry, fingerprints = {}) {
|
|
2331
|
+
return gatePass(() => checkPass(cfg, catalogs, registry, fingerprints));
|
|
2332
|
+
}
|
|
2333
|
+
function checkPass(cfg, catalogs, registry, fingerprints) {
|
|
2319
2334
|
const extracted = registry.messages();
|
|
2320
2335
|
const flat = {};
|
|
2321
2336
|
for (const locale of cfg.locales) flat[locale] = flatten(catalogs[locale] ?? {});
|
|
@@ -2605,14 +2620,20 @@ function suggestedPattern(rel) {
|
|
|
2605
2620
|
const slash = rel.indexOf("/");
|
|
2606
2621
|
return slash < 0 ? rel : `${rel.slice(0, slash)}/**/*.${SOURCE_EXTENSIONS}`;
|
|
2607
2622
|
}
|
|
2608
|
-
function
|
|
2609
|
-
if (cfg.include.length === 0) return () => void 0;
|
|
2623
|
+
function outsidePath(cfg) {
|
|
2610
2624
|
const included = picomatch(cfg.include);
|
|
2611
2625
|
const excluded = picomatch(cfg.exclude);
|
|
2612
|
-
return (
|
|
2626
|
+
return (id) => {
|
|
2613
2627
|
const rel = relativeId(cfg, id);
|
|
2614
|
-
|
|
2615
|
-
|
|
2628
|
+
return rel.startsWith("..") || included(rel) || excluded(rel) ? void 0 : rel;
|
|
2629
|
+
};
|
|
2630
|
+
}
|
|
2631
|
+
function createOutsideCheck(cfg) {
|
|
2632
|
+
if (cfg.include.length === 0) return () => void 0;
|
|
2633
|
+
const outside = outsidePath(cfg);
|
|
2634
|
+
return (code, id) => {
|
|
2635
|
+
const rel = outside(id);
|
|
2636
|
+
if (rel === void 0 || !TAGGED_HINT.test(code)) return void 0;
|
|
2616
2637
|
if (analyzeFile(code, id).tagged.length === 0) return void 0;
|
|
2617
2638
|
return {
|
|
2618
2639
|
file: id,
|
|
@@ -2629,6 +2650,7 @@ async function reportOutsideInclude(cfg) {
|
|
|
2629
2650
|
async function filesOutsideInclude(cfg) {
|
|
2630
2651
|
if (cfg.include.length === 0) return [];
|
|
2631
2652
|
const check = createOutsideCheck(cfg);
|
|
2653
|
+
const outside = outsidePath(cfg);
|
|
2632
2654
|
const files = await glob([`**/*.${SOURCE_EXTENSIONS}`], {
|
|
2633
2655
|
cwd: cfg.root,
|
|
2634
2656
|
ignore: [...NOT_SOURCE, ...cfg.exclude],
|
|
@@ -2636,14 +2658,15 @@ async function filesOutsideInclude(cfg) {
|
|
|
2636
2658
|
});
|
|
2637
2659
|
const found = [];
|
|
2638
2660
|
for (const file of files.sort()) {
|
|
2661
|
+
if (outside(file) === void 0) continue;
|
|
2639
2662
|
let code;
|
|
2640
2663
|
try {
|
|
2641
2664
|
code = readFileSync(file, "utf8");
|
|
2642
2665
|
} catch {
|
|
2643
2666
|
continue;
|
|
2644
2667
|
}
|
|
2645
|
-
const
|
|
2646
|
-
if (
|
|
2668
|
+
const entry = check(code, file);
|
|
2669
|
+
if (entry) found.push(entry);
|
|
2647
2670
|
}
|
|
2648
2671
|
return found;
|
|
2649
2672
|
}
|
|
@@ -3123,7 +3146,7 @@ function formatTranslateFailures(failed) {
|
|
|
3123
3146
|
async function resolveProvider(cfg, model) {
|
|
3124
3147
|
const configured = cfg.translate.provider;
|
|
3125
3148
|
if (typeof configured === "function") return configured;
|
|
3126
|
-
const { claudeProvider } = await import("./claude-
|
|
3149
|
+
const { claudeProvider } = await import("./claude-DcV4YBbO.js");
|
|
3127
3150
|
return claudeProvider({ model: model ?? cfg.translate.model });
|
|
3128
3151
|
}
|
|
3129
3152
|
function structureMatches(source, translated) {
|