@fluenti/cli 0.2.1 → 0.3.1

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.
Files changed (75) hide show
  1. package/dist/ai-provider.d.ts +14 -0
  2. package/dist/ai-provider.d.ts.map +1 -0
  3. package/dist/catalog.d.ts +1 -1
  4. package/dist/catalog.d.ts.map +1 -1
  5. package/dist/check.d.ts +47 -0
  6. package/dist/check.d.ts.map +1 -0
  7. package/dist/cli.cjs +12 -9
  8. package/dist/cli.cjs.map +1 -1
  9. package/dist/cli.js +638 -199
  10. package/dist/cli.js.map +1 -1
  11. package/dist/compile-CBSy1rNl.cjs +8 -0
  12. package/dist/compile-CBSy1rNl.cjs.map +1 -0
  13. package/dist/compile-cache.d.ts +26 -0
  14. package/dist/compile-cache.d.ts.map +1 -0
  15. package/dist/compile-jumIhf8m.js +192 -0
  16. package/dist/compile-jumIhf8m.js.map +1 -0
  17. package/dist/compile-runner.d.ts +4 -1
  18. package/dist/compile-runner.d.ts.map +1 -1
  19. package/dist/compile-worker.cjs +2 -0
  20. package/dist/compile-worker.cjs.map +1 -0
  21. package/dist/compile-worker.d.ts +18 -0
  22. package/dist/compile-worker.d.ts.map +1 -0
  23. package/dist/compile-worker.js +14 -0
  24. package/dist/compile-worker.js.map +1 -0
  25. package/dist/compile.d.ts.map +1 -1
  26. package/dist/config-loader.d.ts +1 -6
  27. package/dist/config-loader.d.ts.map +1 -1
  28. package/dist/config.d.ts +2 -2
  29. package/dist/config.d.ts.map +1 -1
  30. package/dist/extract-cache-CmnwPMdA.js +304 -0
  31. package/dist/extract-cache-CmnwPMdA.js.map +1 -0
  32. package/dist/extract-cache-IDp-S-ux.cjs +10 -0
  33. package/dist/extract-cache-IDp-S-ux.cjs.map +1 -0
  34. package/dist/extract-cache.d.ts +33 -0
  35. package/dist/extract-cache.d.ts.map +1 -0
  36. package/dist/extract-runner.d.ts +12 -0
  37. package/dist/extract-runner.d.ts.map +1 -0
  38. package/dist/glossary.d.ts +5 -0
  39. package/dist/glossary.d.ts.map +1 -0
  40. package/dist/index.cjs +1 -1
  41. package/dist/index.cjs.map +1 -1
  42. package/dist/index.d.ts +5 -1
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +117 -25
  45. package/dist/index.js.map +1 -1
  46. package/dist/lint.d.ts +36 -0
  47. package/dist/lint.d.ts.map +1 -0
  48. package/dist/migrate.d.ts.map +1 -1
  49. package/dist/parallel-compile.d.ts +26 -0
  50. package/dist/parallel-compile.d.ts.map +1 -0
  51. package/dist/translate.d.ts.map +1 -1
  52. package/dist/{tsx-extractor-CcFjsYI-.js → tsx-extractor-B9fnGNTG.js} +61 -53
  53. package/dist/tsx-extractor-B9fnGNTG.js.map +1 -0
  54. package/dist/tsx-extractor-j_z4fneM.cjs +2 -0
  55. package/dist/tsx-extractor-j_z4fneM.cjs.map +1 -0
  56. package/dist/tsx-extractor.d.ts +2 -2
  57. package/dist/tsx-extractor.d.ts.map +1 -1
  58. package/dist/validation.d.ts +16 -0
  59. package/dist/validation.d.ts.map +1 -0
  60. package/dist/vue-extractor.cjs +2 -2
  61. package/dist/vue-extractor.cjs.map +1 -1
  62. package/dist/vue-extractor.d.ts +2 -2
  63. package/dist/vue-extractor.d.ts.map +1 -1
  64. package/dist/vue-extractor.js +42 -42
  65. package/dist/vue-extractor.js.map +1 -1
  66. package/llms-full.txt +297 -0
  67. package/llms.txt +86 -0
  68. package/package.json +4 -3
  69. package/dist/config-loader-BgAoTfxH.js +0 -387
  70. package/dist/config-loader-BgAoTfxH.js.map +0 -1
  71. package/dist/config-loader-D3RGkK_r.cjs +0 -16
  72. package/dist/config-loader-D3RGkK_r.cjs.map +0 -1
  73. package/dist/tsx-extractor-CcFjsYI-.js.map +0 -1
  74. package/dist/tsx-extractor-D__s_cP8.cjs +0 -2
  75. package/dist/tsx-extractor-D__s_cP8.cjs.map +0 -1
@@ -0,0 +1,192 @@
1
+ import { hashMessage as e, parse as t } from "@fluenti/core/internal";
2
+ //#region \0rolldown/runtime.js
3
+ var n = Object.defineProperty, r = /* @__PURE__ */ ((e, t) => {
4
+ let r = {};
5
+ for (var i in e) n(r, i, {
6
+ get: e[i],
7
+ enumerable: !0
8
+ });
9
+ return t || n(r, Symbol.toStringTag, { value: "Module" }), r;
10
+ })({
11
+ CATALOG_VERSION: () => 1,
12
+ collectAllIds: () => b,
13
+ compileCatalog: () => _,
14
+ compileIndex: () => y,
15
+ compileTypeDeclaration: () => C,
16
+ extractMessageVariables: () => x
17
+ }), i = /\{(\w+)\}/g, a = /\{(\w+)\}/;
18
+ function o(e) {
19
+ return a.test(e);
20
+ }
21
+ function s(e) {
22
+ return e.replace(/\\/g, "\\\\").replace(/'/g, "\\'").replace(/\n/g, "\\n").replace(/\r/g, "\\r");
23
+ }
24
+ function c(e, t) {
25
+ return /^\d/.test(t) ? `${e}[${t}]` : `${e}.${t}`;
26
+ }
27
+ function l(e) {
28
+ return e.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$\{/g, "\\${").replace(/\n/g, "\\n").replace(/\r/g, "\\r");
29
+ }
30
+ function u(e) {
31
+ return e.replace(i, (e, t) => `\${${c("v", t)}}`);
32
+ }
33
+ var d = /\{(\w+),\s*(plural|select|selectordinal)\s*,/;
34
+ function f(e) {
35
+ return d.test(e);
36
+ }
37
+ function p(e, t) {
38
+ if (e.length === 0) return "''";
39
+ let n = e.map((e) => m(e, t));
40
+ return n.length === 1 ? n[0] : n.join(" + ");
41
+ }
42
+ function m(e, t) {
43
+ switch (e.type) {
44
+ case "text": return `'${s(e.value)}'`;
45
+ case "variable": return e.name === "#" ? "String(__c)" : `String(${c("v", e.name)} ?? '{${e.name}}')`;
46
+ case "plural": return h(e, t);
47
+ case "select": return g(e, t);
48
+ case "function": return `String(${c("v", e.variable)} ?? '')`;
49
+ }
50
+ }
51
+ function h(e, t) {
52
+ let n = e.offset ?? 0, r = c("v", e.variable), i = n ? `(${r} - ${n})` : r, a = [];
53
+ a.push("((c) => { const __c = c; ");
54
+ let o = Object.keys(e.options).filter((e) => e.startsWith("="));
55
+ if (o.length > 0) for (let n of o) {
56
+ let r = n.slice(1), i = p(e.options[n], t);
57
+ a.push(`if (c === ${r}) return ${i}; `);
58
+ }
59
+ let l = Object.keys(e.options).filter((e) => !e.startsWith("="));
60
+ if (l.length > 1 || l.length === 1 && l[0] !== "other") {
61
+ a.push(`const __cat = new Intl.PluralRules('${s(t)}').select(c); `);
62
+ for (let n of l) {
63
+ if (n === "other") continue;
64
+ let r = p(e.options[n], t);
65
+ a.push(`if (__cat === '${n}') return ${r}; `);
66
+ }
67
+ }
68
+ let u = e.options.other ? p(e.options.other, t) : "''";
69
+ return a.push(`return ${u}; `), a.push(`})(${i})`), a.join("");
70
+ }
71
+ function g(e, t) {
72
+ let n = [];
73
+ n.push("((s) => { ");
74
+ let r = Object.keys(e.options).filter((e) => e !== "other");
75
+ for (let i of r) {
76
+ let r = p(e.options[i], t);
77
+ n.push(`if (s === '${s(i)}') return ${r}; `);
78
+ }
79
+ let i = e.options.other ? p(e.options.other, t) : "''";
80
+ return n.push(`return ${i}; `), n.push(`})(String(${c("v", e.variable)} ?? ''))`), n.join("");
81
+ }
82
+ function _(n, r, i, a, c) {
83
+ let d = [];
84
+ d.push("// @fluenti/compiled v1"), d.push("// @ts-nocheck");
85
+ let m = [], h = 0, g = [], _ = /* @__PURE__ */ new Map();
86
+ for (let y of i) {
87
+ let i = e(y), b = _.get(i);
88
+ if (b !== void 0 && b !== y) throw Error(`Hash collision detected: messages "${b}" and "${y}" produce the same hash "${i}"`);
89
+ _.set(i, y);
90
+ let x = `_${i}`, S = n[y], C = v(S, y, r, a, c?.skipFuzzy);
91
+ if (C === void 0) d.push(`export const ${x} = undefined`), g.push(y);
92
+ else if (f(C)) {
93
+ let e = p(t(C), r);
94
+ d.push(`export const ${x} = (v) => ${e}`), h++;
95
+ } else if (o(C)) {
96
+ let e = u(l(C));
97
+ d.push(`export const ${x} = (v) => \`${e}\``), h++;
98
+ } else d.push(`export const ${x} = '${s(C)}'`), h++;
99
+ m.push({
100
+ id: y,
101
+ exportName: x
102
+ });
103
+ }
104
+ if (m.length === 0) return {
105
+ code: "// @fluenti/compiled v1\n// empty catalog\nexport default {}\n",
106
+ stats: {
107
+ compiled: 0,
108
+ missing: []
109
+ }
110
+ };
111
+ d.push(""), d.push("export default {");
112
+ for (let { id: e, exportName: t } of m) d.push(` '${s(e)}': ${t},`);
113
+ return d.push("}"), d.push(""), {
114
+ code: d.join("\n"),
115
+ stats: {
116
+ compiled: h,
117
+ missing: g
118
+ }
119
+ };
120
+ }
121
+ function v(e, t, n, r, i) {
122
+ let a = r ?? n;
123
+ if (e && !(i && e.fuzzy)) {
124
+ if (e.translation !== void 0 && e.translation.length > 0) return e.translation;
125
+ if (n === a) return e.message ?? t;
126
+ }
127
+ }
128
+ function y(e, t) {
129
+ let n = [];
130
+ n.push(`export const locales = ${JSON.stringify(e)}`), n.push(""), n.push("export const loaders = {");
131
+ for (let t of e) n.push(` '${s(t)}': () => import('./${s(t)}.js'),`);
132
+ return n.push("}"), n.push(""), n.join("\n");
133
+ }
134
+ function b(e) {
135
+ let t = /* @__PURE__ */ new Set();
136
+ for (let n of Object.values(e)) for (let [e, r] of Object.entries(n)) r.obsolete || t.add(e);
137
+ return [...t].sort();
138
+ }
139
+ function x(e) {
140
+ let n = t(e), r = /* @__PURE__ */ new Map();
141
+ return S(n, r), [...r.entries()].sort(([e], [t]) => e.localeCompare(t)).map(([e, t]) => ({
142
+ name: e,
143
+ type: t
144
+ }));
145
+ }
146
+ function S(e, t) {
147
+ for (let n of e) switch (n.type) {
148
+ case "variable":
149
+ n.name !== "#" && !t.has(n.name) && t.set(n.name, "string | number");
150
+ break;
151
+ case "plural": {
152
+ let e = n;
153
+ t.set(e.variable, "number");
154
+ for (let n of Object.values(e.options)) S(n, t);
155
+ break;
156
+ }
157
+ case "select": {
158
+ let e = n, r = Object.keys(e.options).filter((e) => e !== "other"), i = "other" in e.options, a = r.map((e) => `'${e}'`).join(" | "), o = i ? r.length > 0 ? `${a} | string` : "string" : r.length > 0 ? a : "string";
159
+ t.set(e.variable, o);
160
+ for (let n of Object.values(e.options)) S(n, t);
161
+ break;
162
+ }
163
+ case "function":
164
+ t.has(n.variable) || t.set(n.variable, "string | number");
165
+ break;
166
+ case "text": break;
167
+ }
168
+ }
169
+ function C(e, t, n) {
170
+ let r = [];
171
+ if (r.push("// Auto-generated by @fluenti/cli — do not edit"), r.push(""), r.push("export type { LocalizedString } from '@fluenti/core'"), r.push(""), e.length === 0) r.push("export type MessageId = never");
172
+ else {
173
+ r.push("export type MessageId =");
174
+ for (let t of e) r.push(` | '${s(t)}'`);
175
+ }
176
+ r.push(""), r.push("export interface MessageValues {");
177
+ for (let i of e) {
178
+ let e = x(t[n]?.[i]?.message ?? i), a = s(i);
179
+ if (e.length === 0) r.push(` '${a}': Record<string, never>`);
180
+ else {
181
+ let t = e.map((e) => `${e.name}: ${e.type}`).join("; ");
182
+ r.push(` '${a}': { ${t} }`);
183
+ }
184
+ }
185
+ r.push("}"), r.push("");
186
+ let i = Object.keys(t).map((e) => `'${s(e)}'`).join(" | ");
187
+ return r.push("// Auto-wiring: narrows t() and setLocale() to compiled types"), r.push("declare module '@fluenti/core' {"), r.push(" interface FluentiTypeConfig {"), r.push(` locale: ${i || "string"}`), r.push(" messageIds: MessageId"), r.push(" messageValues: MessageValues"), r.push(" }"), r.push("}"), r.push(""), r.join("\n");
188
+ }
189
+ //#endregion
190
+ export { r as a, C as i, _ as n, y as r, b as t };
191
+
192
+ //# sourceMappingURL=compile-jumIhf8m.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile-jumIhf8m.js","names":[],"sources":["../src/compile.ts"],"sourcesContent":["import type { CatalogData } from './catalog'\nimport { hashMessage, parse } from '@fluenti/core/internal'\nimport type { ASTNode, PluralNode, SelectNode, VariableNode, FunctionNode } from '@fluenti/core/internal'\n\nconst ICU_VAR_REGEX = /\\{(\\w+)\\}/g\nconst ICU_VAR_TEST = /\\{(\\w+)\\}/\n\nfunction hasVariables(message: string): boolean {\n return ICU_VAR_TEST.test(message)\n}\n\n\nfunction escapeStringLiteral(str: string): string {\n return str\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/'/g, \"\\\\'\")\n .replace(/\\n/g, '\\\\n')\n .replace(/\\r/g, '\\\\r')\n}\n\n/** Generate safe JS property access: `v.name` for identifiers, `v[0]` for numeric names */\nfunction propAccess(obj: string, name: string): string {\n return /^\\d/.test(name) ? `${obj}[${name}]` : `${obj}.${name}`\n}\n\nfunction escapeTemplateLiteral(str: string): string {\n return str\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/`/g, '\\\\`')\n .replace(/\\$\\{/g, '\\\\${')\n .replace(/\\n/g, '\\\\n')\n .replace(/\\r/g, '\\\\r')\n}\n\nfunction messageToTemplateString(message: string): string {\n return message.replace(ICU_VAR_REGEX, (_match, name: string) => `\\${${propAccess('v', name)}}`)\n}\n\n\n// ─── ICU → JS code generation for split mode ───────────────────────────────\n\nconst ICU_PLURAL_SELECT_REGEX = /\\{(\\w+),\\s*(plural|select|selectordinal)\\s*,/\n\n/** Check if message contains ICU plural/select syntax */\nfunction hasIcuPluralOrSelect(message: string): boolean {\n return ICU_PLURAL_SELECT_REGEX.test(message)\n}\n\n/**\n * Compile an ICU AST node array into a JS expression string.\n * Used for generating static code (not runtime evaluation).\n */\nfunction astToJsExpression(nodes: ASTNode[], locale: string): string {\n if (nodes.length === 0) return \"''\"\n\n const parts = nodes.map((node) => astNodeToJs(node, locale))\n\n if (parts.length === 1) return parts[0]!\n return parts.join(' + ')\n}\n\nfunction astNodeToJs(node: ASTNode, locale: string): string {\n switch (node.type) {\n case 'text':\n return `'${escapeStringLiteral(node.value)}'`\n\n case 'variable':\n if (node.name === '#') return 'String(__c)'\n return `String(${propAccess('v', node.name)} ?? '{${node.name}}')`\n\n case 'plural':\n return pluralToJs(node as PluralNode, locale)\n\n case 'select':\n return selectToJs(node as SelectNode, locale)\n\n case 'function':\n return `String(${propAccess('v', node.variable)} ?? '')`\n }\n}\n\nfunction pluralToJs(node: PluralNode, locale: string): string {\n const offset = node.offset ?? 0\n const access = propAccess('v', node.variable)\n const countExpr = offset ? `(${access} - ${offset})` : access\n\n const lines: string[] = []\n lines.push(`((c) => { const __c = c; `)\n\n // Exact matches first\n const exactKeys = Object.keys(node.options).filter((k) => k.startsWith('='))\n if (exactKeys.length > 0) {\n for (const key of exactKeys) {\n const num = key.slice(1)\n const body = astToJsExpression(node.options[key]!, locale)\n lines.push(`if (c === ${num}) return ${body}; `)\n }\n }\n\n // CLDR categories via Intl.PluralRules\n const cldrKeys = Object.keys(node.options).filter((k) => !k.startsWith('='))\n if (cldrKeys.length > 1 || (cldrKeys.length === 1 && cldrKeys[0] !== 'other')) {\n lines.push(`const __cat = new Intl.PluralRules('${escapeStringLiteral(locale)}').select(c); `)\n for (const key of cldrKeys) {\n if (key === 'other') continue\n const body = astToJsExpression(node.options[key]!, locale)\n lines.push(`if (__cat === '${key}') return ${body}; `)\n }\n }\n\n // Fallback to 'other'\n const otherBody = node.options['other']\n ? astToJsExpression(node.options['other'], locale)\n : \"''\"\n lines.push(`return ${otherBody}; `)\n lines.push(`})(${countExpr})`)\n\n return lines.join('')\n}\n\nfunction selectToJs(node: SelectNode, locale: string): string {\n const lines: string[] = []\n lines.push(`((s) => { `)\n\n const keys = Object.keys(node.options).filter((k) => k !== 'other')\n for (const key of keys) {\n const body = astToJsExpression(node.options[key]!, locale)\n lines.push(`if (s === '${escapeStringLiteral(key)}') return ${body}; `)\n }\n\n const otherBody = node.options['other']\n ? astToJsExpression(node.options['other'], locale)\n : \"''\"\n lines.push(`return ${otherBody}; `)\n lines.push(`})(String(${propAccess('v', node.variable)} ?? ''))`)\n\n return lines.join('')\n}\n\n/**\n * Compile a catalog to ES module with tree-shakeable named exports.\n * Each message becomes a `/* @__PURE__ *​/` annotated named export.\n * A default export maps message IDs to their compiled values for runtime lookup.\n */\n/** Catalog format version. Bump when the compiled output format changes. */\nexport const CATALOG_VERSION = 1\n\nexport interface CompileStats {\n compiled: number\n missing: string[]\n}\n\nexport interface CompileOptions {\n skipFuzzy?: boolean\n}\n\nexport function compileCatalog(\n catalog: CatalogData,\n locale: string,\n allIds: string[],\n sourceLocale?: string,\n options?: CompileOptions,\n): { code: string; stats: CompileStats } {\n const lines: string[] = []\n lines.push(`// @fluenti/compiled v${CATALOG_VERSION}`)\n lines.push(`// @ts-nocheck`)\n const exportNames: Array<{ id: string; exportName: string }> = []\n let compiled = 0\n const missing: string[] = []\n\n const hashToId = new Map<string, string>()\n\n for (const id of allIds) {\n const hash = hashMessage(id)\n\n const existingId = hashToId.get(hash)\n if (existingId !== undefined && existingId !== id) {\n throw new Error(\n `Hash collision detected: messages \"${existingId}\" and \"${id}\" produce the same hash \"${hash}\"`,\n )\n }\n hashToId.set(hash, id)\n\n const exportName = `_${hash}`\n const entry = catalog[id]\n const translated = resolveCompiledMessage(entry, id, locale, sourceLocale, options?.skipFuzzy)\n\n if (translated === undefined) {\n lines.push(`export const ${exportName} = undefined`)\n missing.push(id)\n } else if (hasIcuPluralOrSelect(translated)) {\n // Parse ICU and compile to JS\n const ast = parse(translated)\n const jsExpr = astToJsExpression(ast, locale)\n lines.push(`export const ${exportName} = (v) => ${jsExpr}`)\n compiled++\n } else if (hasVariables(translated)) {\n const templateStr = messageToTemplateString(escapeTemplateLiteral(translated))\n lines.push(`export const ${exportName} = (v) => \\`${templateStr}\\``)\n compiled++\n } else {\n lines.push(`export const ${exportName} = '${escapeStringLiteral(translated)}'`)\n compiled++\n }\n\n exportNames.push({ id, exportName })\n }\n\n if (exportNames.length === 0) {\n return {\n code: `// @fluenti/compiled v${CATALOG_VERSION}\\n// empty catalog\\nexport default {}\\n`,\n stats: { compiled: 0, missing: [] },\n }\n }\n\n // Default export maps message IDs → compiled values for runtime lookup\n lines.push('')\n lines.push('export default {')\n for (const { id, exportName } of exportNames) {\n lines.push(` '${escapeStringLiteral(id)}': ${exportName},`)\n }\n lines.push('}')\n lines.push('')\n\n return { code: lines.join('\\n'), stats: { compiled, missing } }\n}\n\nfunction resolveCompiledMessage(\n entry: CatalogData[string] | undefined,\n id: string,\n locale: string,\n sourceLocale: string | undefined,\n skipFuzzy?: boolean,\n): string | undefined {\n const effectiveSourceLocale = sourceLocale ?? locale\n\n if (!entry) {\n return undefined\n }\n\n if (skipFuzzy && entry.fuzzy) {\n return undefined\n }\n\n if (entry.translation !== undefined && entry.translation.length > 0) {\n return entry.translation\n }\n\n if (locale === effectiveSourceLocale) {\n return entry.message ?? id\n }\n\n return undefined\n}\n\n/**\n * Generate the index module that exports locale list and lazy loaders.\n */\nexport function compileIndex(locales: string[], _catalogDir: string): string {\n const lines: string[] = []\n lines.push(`export const locales = ${JSON.stringify(locales)}`)\n lines.push('')\n lines.push('export const loaders = {')\n for (const locale of locales) {\n lines.push(` '${escapeStringLiteral(locale)}': () => import('./${escapeStringLiteral(locale)}.js'),`)\n }\n lines.push('}')\n lines.push('')\n return lines.join('\\n')\n}\n\n/**\n * Collect the union of all message IDs across all locale catalogs.\n * Ensures every locale file exports the same names.\n */\nexport function collectAllIds(catalogs: Record<string, CatalogData>): string[] {\n const idSet = new Set<string>()\n for (const catalog of Object.values(catalogs)) {\n for (const [id, entry] of Object.entries(catalog)) {\n if (!entry.obsolete) {\n idSet.add(id)\n }\n }\n }\n return [...idSet].sort()\n}\n\n// ─── Type-safe message ID generation ─────────────────────────────────────────\n\nexport interface MessageVariable {\n name: string\n type: string\n}\n\n/**\n * Extract variable names and their TypeScript types from an ICU message string.\n */\nexport function extractMessageVariables(message: string): MessageVariable[] {\n const ast = parse(message)\n const vars = new Map<string, string>()\n collectVariablesFromNodes(ast, vars)\n return [...vars.entries()]\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([name, type]) => ({ name, type }))\n}\n\nfunction collectVariablesFromNodes(nodes: ASTNode[], vars: Map<string, string>): void {\n for (const node of nodes) {\n switch (node.type) {\n case 'variable':\n if (node.name !== '#' && !vars.has(node.name)) {\n vars.set((node as VariableNode).name, 'string | number')\n }\n break\n case 'plural': {\n const pn = node as PluralNode\n // Plural variable is always a number\n vars.set(pn.variable, 'number')\n // Recurse into plural option bodies\n for (const optionNodes of Object.values(pn.options)) {\n collectVariablesFromNodes(optionNodes, vars)\n }\n break\n }\n case 'select': {\n const sn = node as SelectNode\n const keys = Object.keys(sn.options).filter((k) => k !== 'other')\n const hasOther = 'other' in sn.options\n const literalTypes = keys.map((k) => `'${k}'`).join(' | ')\n const selectType = hasOther\n ? (keys.length > 0 ? `${literalTypes} | string` : 'string')\n : (keys.length > 0 ? literalTypes : 'string')\n vars.set(sn.variable, selectType)\n // Recurse into select option bodies\n for (const optionNodes of Object.values(sn.options)) {\n collectVariablesFromNodes(optionNodes, vars)\n }\n break\n }\n case 'function':\n if (!vars.has((node as FunctionNode).variable)) {\n vars.set((node as FunctionNode).variable, 'string | number')\n }\n break\n case 'text':\n break\n }\n }\n}\n\n/**\n * Generate a TypeScript declaration file with MessageId union and MessageValues interface.\n */\nexport function compileTypeDeclaration(\n allIds: string[],\n catalogs: Record<string, CatalogData>,\n sourceLocale: string,\n): string {\n const lines: string[] = []\n lines.push('// Auto-generated by @fluenti/cli — do not edit')\n lines.push('')\n lines.push('export type { LocalizedString } from \\'@fluenti/core\\'')\n lines.push('')\n\n // MessageId union\n if (allIds.length === 0) {\n lines.push('export type MessageId = never')\n } else {\n lines.push('export type MessageId =')\n for (const id of allIds) {\n lines.push(` | '${escapeStringLiteral(id)}'`)\n }\n }\n\n lines.push('')\n\n // MessageValues interface\n lines.push('export interface MessageValues {')\n for (const id of allIds) {\n // Use source locale catalog to get the message for variable extraction\n const sourceCatalog = catalogs[sourceLocale]\n const entry = sourceCatalog?.[id]\n const message = entry?.message ?? id\n const vars = extractMessageVariables(message)\n\n const escapedId = escapeStringLiteral(id)\n if (vars.length === 0) {\n lines.push(` '${escapedId}': Record<string, never>`)\n } else {\n const fields = vars.map((v) => `${v.name}: ${v.type}`).join('; ')\n lines.push(` '${escapedId}': { ${fields} }`)\n }\n }\n lines.push('}')\n lines.push('')\n\n // Module augmentation: auto-wire MessageId and MessageValues into CompileTimeT\n // Locale union from catalog keys\n const localeKeys = Object.keys(catalogs).map((l) => `'${escapeStringLiteral(l)}'`).join(' | ')\n\n lines.push('// Auto-wiring: narrows t() and setLocale() to compiled types')\n lines.push(\"declare module '@fluenti/core' {\")\n lines.push(' interface FluentiTypeConfig {')\n lines.push(` locale: ${localeKeys || 'string'}`)\n lines.push(' messageIds: MessageId')\n lines.push(' messageValues: MessageValues')\n lines.push(' }')\n lines.push('}')\n lines.push('')\n\n return lines.join('\\n')\n}\n"],"mappings":";;;;;;;;;;;;;;;;IAIM,IAAgB,cAChB,IAAe;AAErB,SAAS,EAAa,GAA0B;AAC9C,QAAO,EAAa,KAAK,EAAQ;;AAInC,SAAS,EAAoB,GAAqB;AAChD,QAAO,EACJ,QAAQ,OAAO,OAAO,CACtB,QAAQ,MAAM,MAAM,CACpB,QAAQ,OAAO,MAAM,CACrB,QAAQ,OAAO,MAAM;;AAI1B,SAAS,EAAW,GAAa,GAAsB;AACrD,QAAO,MAAM,KAAK,EAAK,GAAG,GAAG,EAAI,GAAG,EAAK,KAAK,GAAG,EAAI,GAAG;;AAG1D,SAAS,EAAsB,GAAqB;AAClD,QAAO,EACJ,QAAQ,OAAO,OAAO,CACtB,QAAQ,MAAM,MAAM,CACpB,QAAQ,SAAS,OAAO,CACxB,QAAQ,OAAO,MAAM,CACrB,QAAQ,OAAO,MAAM;;AAG1B,SAAS,EAAwB,GAAyB;AACxD,QAAO,EAAQ,QAAQ,IAAgB,GAAQ,MAAiB,MAAM,EAAW,KAAK,EAAK,CAAC,GAAG;;AAMjG,IAAM,IAA0B;AAGhC,SAAS,EAAqB,GAA0B;AACtD,QAAO,EAAwB,KAAK,EAAQ;;AAO9C,SAAS,EAAkB,GAAkB,GAAwB;AACnE,KAAI,EAAM,WAAW,EAAG,QAAO;CAE/B,IAAM,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S,CAAC,KAAK,MAAM,IAAI,EAAoB,EAAE,CAAC,GAAG,CAAC,KAAK,MAAM;AAY9F,QAVA,EAAM,KAAK,gEAAgE,EAC3E,EAAM,KAAK,mCAAmC,EAC9C,EAAM,KAAK,kCAAkC,EAC7C,EAAM,KAAK,eAAe,KAAc,WAAW,EACnD,EAAM,KAAK,4BAA4B,EACvC,EAAM,KAAK,mCAAmC,EAC9C,EAAM,KAAK,MAAM,EACjB,EAAM,KAAK,IAAI,EACf,EAAM,KAAK,GAAG,EAEP,EAAM,KAAK,KAAK"}
@@ -1,7 +1,10 @@
1
+ export interface RunCompileOptions {
2
+ parallel?: boolean;
3
+ }
1
4
  /**
2
5
  * Programmatic compile entry point.
3
6
  * Loads config from `cwd`, reads catalogs, and writes compiled output.
4
7
  * This is the in-process equivalent of `fluenti compile`.
5
8
  */
6
- export declare function runCompile(cwd: string): Promise<void>;
9
+ export declare function runCompile(cwd: string, options?: RunCompileOptions): Promise<void>;
7
10
  //# sourceMappingURL=compile-runner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compile-runner.d.ts","sourceRoot":"","sources":["../src/compile-runner.ts"],"names":[],"mappings":"AAcA;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAyB3D"}
1
+ {"version":3,"file":"compile-runner.d.ts","sourceRoot":"","sources":["../src/compile-runner.ts"],"names":[],"mappings":"AA4BA,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAuExF"}
@@ -0,0 +1,2 @@
1
+ require(`./extract-cache-IDp-S-ux.cjs`);const e=require(`./compile-CBSy1rNl.cjs`);let t=require(`node:worker_threads`);t.parentPort.on(`message`,n=>{let{code:r,stats:i}=e.n(n.catalog,n.locale,n.allIds,n.sourceLocale,n.options),a={locale:n.locale,code:r,stats:i};t.parentPort.postMessage(a)});
2
+ //# sourceMappingURL=compile-worker.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile-worker.cjs","names":[],"sources":["../src/compile-worker.ts"],"sourcesContent":["import { parentPort } from 'node:worker_threads'\nimport { compileCatalog } from './compile'\nimport type { CatalogData } from './catalog'\nimport type { CompileOptions } from './compile'\n\nexport interface CompileWorkerRequest {\n locale: string\n catalog: CatalogData\n allIds: string[]\n sourceLocale: string\n options?: CompileOptions | undefined\n}\n\nexport interface CompileWorkerResponse {\n locale: string\n code: string\n stats: { compiled: number; missing: string[] }\n}\n\nparentPort!.on('message', (req: CompileWorkerRequest) => {\n const { code, stats } = compileCatalog(req.catalog, req.locale, req.allIds, req.sourceLocale, req.options)\n const response: CompileWorkerResponse = { locale: req.locale, code, stats }\n parentPort!.postMessage(response)\n})\n"],"mappings":"uHAmBA,EAAA,WAAY,GAAG,UAAY,GAA8B,CACvD,GAAM,CAAE,OAAM,SAAU,EAAA,EAAe,EAAI,QAAS,EAAI,OAAQ,EAAI,OAAQ,EAAI,aAAc,EAAI,QAAQ,CACpG,EAAkC,CAAE,OAAQ,EAAI,OAAQ,OAAM,QAAO,CAC3E,EAAA,WAAY,YAAY,EAAS,EACjC"}
@@ -0,0 +1,18 @@
1
+ import { CatalogData } from './catalog';
2
+ import { CompileOptions } from './compile';
3
+ export interface CompileWorkerRequest {
4
+ locale: string;
5
+ catalog: CatalogData;
6
+ allIds: string[];
7
+ sourceLocale: string;
8
+ options?: CompileOptions | undefined;
9
+ }
10
+ export interface CompileWorkerResponse {
11
+ locale: string;
12
+ code: string;
13
+ stats: {
14
+ compiled: number;
15
+ missing: string[];
16
+ };
17
+ }
18
+ //# sourceMappingURL=compile-worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile-worker.d.ts","sourceRoot":"","sources":["../src/compile-worker.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAE/C,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,WAAW,CAAA;IACpB,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,YAAY,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,cAAc,GAAG,SAAS,CAAA;CACrC;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,CAAA;CAC/C"}
@@ -0,0 +1,14 @@
1
+ import { n as e } from "./compile-jumIhf8m.js";
2
+ import { parentPort as t } from "node:worker_threads";
3
+ //#region src/compile-worker.ts
4
+ t.on("message", (n) => {
5
+ let { code: r, stats: i } = e(n.catalog, n.locale, n.allIds, n.sourceLocale, n.options), a = {
6
+ locale: n.locale,
7
+ code: r,
8
+ stats: i
9
+ };
10
+ t.postMessage(a);
11
+ });
12
+ //#endregion
13
+
14
+ //# sourceMappingURL=compile-worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile-worker.js","names":[],"sources":["../src/compile-worker.ts"],"sourcesContent":["import { parentPort } from 'node:worker_threads'\nimport { compileCatalog } from './compile'\nimport type { CatalogData } from './catalog'\nimport type { CompileOptions } from './compile'\n\nexport interface CompileWorkerRequest {\n locale: string\n catalog: CatalogData\n allIds: string[]\n sourceLocale: string\n options?: CompileOptions | undefined\n}\n\nexport interface CompileWorkerResponse {\n locale: string\n code: string\n stats: { compiled: number; missing: string[] }\n}\n\nparentPort!.on('message', (req: CompileWorkerRequest) => {\n const { code, stats } = compileCatalog(req.catalog, req.locale, req.allIds, req.sourceLocale, req.options)\n const response: CompileWorkerResponse = { locale: req.locale, code, stats }\n parentPort!.postMessage(response)\n})\n"],"mappings":";;;AAmBA,EAAY,GAAG,YAAY,MAA8B;CACvD,IAAM,EAAE,SAAM,aAAU,EAAe,EAAI,SAAS,EAAI,QAAQ,EAAI,QAAQ,EAAI,cAAc,EAAI,QAAQ,EACpG,IAAkC;EAAE,QAAQ,EAAI;EAAQ;EAAM;EAAO;AAC3E,GAAY,YAAY,EAAS;EACjC"}
@@ -1 +1 @@
1
- {"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../src/compile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AA4I5C;;;;GAIG;AACH,4EAA4E;AAC5E,eAAO,MAAM,eAAe,IAAI,CAAA;AAEhC,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EAAE,EAChB,YAAY,CAAC,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,cAAc,GACvB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,YAAY,CAAA;CAAE,CA8DvC;AA8BD;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAW3E;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,MAAM,EAAE,CAU7E;AAID,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;GAEG;AACH,wBAAgB,uBAAuB,C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AAsB,CACpC,MAAM,EAAE,MAAM,EAAE,EAChB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EACrC,YAAY,EAAE,MAAM,GACnB,MAAM,CAsDR"}
@@ -1,7 +1,2 @@
1
- import { FluentiConfig } from '@fluenti/core';
2
- /**
3
- * Load Fluenti config from the given path or auto-discover it.
4
- * When `cwd` is provided, config paths are resolved relative to it.
5
- */
6
- export declare function loadConfig(configPath?: string, cwd?: string): Promise<FluentiConfig>;
1
+ export { loadConfig, loadConfigSync, DEFAULT_FLUENTI_CONFIG } from '@fluenti/core/config';
7
2
  //# sourceMappingURL=config-loader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config-loader.d.ts","sourceRoot":"","sources":["../src/config-loader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAWlD;;;GAGG;AACH,wBAAsB,UAAU,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAqB1F"}
1
+ {"version":3,"file":"config-loader.d.ts","sourceRoot":"","sources":["../src/config-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA"}
package/dist/config.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { FluentiConfig } from '@fluenti/core';
1
+ import { FluentiBuildConfig } from '@fluenti/core/internal';
2
2
  /**
3
3
  * Define a Fluenti configuration with full type inference and IDE autocompletion.
4
4
  *
@@ -17,5 +17,5 @@ import { FluentiConfig } from '@fluenti/core';
17
17
  * })
18
18
  * ```
19
19
  */
20
- export declare function defineConfig(config: Partial<FluentiConfig>): Partial<FluentiConfig>;
20
+ export declare function defineConfig(config: Partial<FluentiBuildConfig>): Partial<FluentiBuildConfig>;
21
21
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAElD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC,CAEnF"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAEhE;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,kBAAkB,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAE7F"}
@@ -0,0 +1,304 @@
1
+ import { hashMessage as e } from "@fluenti/core/internal";
2
+ import * as t from "gettext-parser";
3
+ import { loadConfig as n } from "@fluenti/core/config";
4
+ import { existsSync as r, mkdirSync as i, readFileSync as a, statSync as o, writeFileSync as s } from "node:fs";
5
+ import { dirname as c, resolve as l } from "node:path";
6
+ import { Worker as u } from "node:worker_threads";
7
+ import { availableParallelism as d } from "node:os";
8
+ import { fileURLToPath as f } from "node:url";
9
+ //#region src/catalog.ts
10
+ function p(e, t, n) {
11
+ let r = new Set(t.map((e) => e.id)), i = /* @__PURE__ */ new Set(), a = {}, o = 0, s = 0, c = 0;
12
+ for (let r of t) {
13
+ let t = e[r.id], c = t ? void 0 : h(e, r, i), l = `${r.origin.file}:${r.origin.line}`, u = t ?? c?.entry;
14
+ if (c && i.add(c.id), u) a[r.id] = {
15
+ ...u,
16
+ message: r.message ?? u.message,
17
+ context: r.context,
18
+ comment: r.comment,
19
+ origin: l,
20
+ obsolete: !1
21
+ }, s++;
22
+ else if (a[r.id]) {
23
+ let e = a[r.id];
24
+ a[r.id] = {
25
+ ...e,
26
+ origin: m(e.origin, l)
27
+ };
28
+ } else a[r.id] = {
29
+ message: r.message,
30
+ context: r.context,
31
+ comment: r.comment,
32
+ origin: l
33
+ }, o++;
34
+ if (n?.stripFuzzy) {
35
+ let { fuzzy: e, ...t } = a[r.id];
36
+ a[r.id] = t;
37
+ }
38
+ }
39
+ for (let [t, i] of Object.entries(e)) if (!r.has(t)) {
40
+ let { fuzzy: e, ...r } = i;
41
+ a[t] = n?.stripFuzzy ? {
42
+ ...r,
43
+ obsolete: !0
44
+ } : {
45
+ ...i,
46
+ obsolete: !0
47
+ }, c++;
48
+ }
49
+ return {
50
+ catalog: a,
51
+ result: {
52
+ added: o,
53
+ unchanged: s,
54
+ obsolete: c
55
+ }
56
+ };
57
+ }
58
+ function m(e, t) {
59
+ if (!e) return t;
60
+ let n = Array.isArray(e) ? e : [e], r = [...new Set([...n, t])];
61
+ return r.length === 1 ? r[0] : r;
62
+ }
63
+ function h(e, t, n) {
64
+ if (!t.context) return;
65
+ let r = `${t.origin.file}:${t.origin.line}`;
66
+ for (let [i, a] of Object.entries(e)) if (!n.has(i) && a.context === void 0 && a.message === t.message && g(a.origin, r)) return {
67
+ id: i,
68
+ entry: a
69
+ };
70
+ }
71
+ function g(e, t) {
72
+ return e ? (Array.isArray(e) ? e : [e]).some((e) => e === t || _(e) === _(t)) : !1;
73
+ }
74
+ function _(e) {
75
+ return e.match(/^(.*):\d+$/)?.[1] ?? e;
76
+ }
77
+ //#endregion
78
+ //#region src/json-format.ts
79
+ function v(e) {
80
+ let t = JSON.parse(e), n = {};
81
+ for (let [e, r] of Object.entries(t)) if (typeof r == "object" && r) {
82
+ let t = r;
83
+ n[e] = {
84
+ message: typeof t.message == "string" ? t.message : void 0,
85
+ context: typeof t.context == "string" ? t.context : void 0,
86
+ comment: typeof t.comment == "string" ? t.comment : void 0,
87
+ translation: typeof t.translation == "string" ? t.translation : void 0,
88
+ origin: typeof t.origin == "string" || Array.isArray(t.origin) && t.origin.every((e) => typeof e == "string") ? t.origin : void 0,
89
+ obsolete: typeof t.obsolete == "boolean" ? t.obsolete : void 0,
90
+ fuzzy: typeof t.fuzzy == "boolean" ? t.fuzzy : void 0
91
+ };
92
+ }
93
+ return n;
94
+ }
95
+ function y(e) {
96
+ let t = {};
97
+ for (let [n, r] of Object.entries(e)) {
98
+ let e = {};
99
+ r.message !== void 0 && (e.message = r.message), r.context !== void 0 && (e.context = r.context), r.comment !== void 0 && (e.comment = r.comment), r.translation !== void 0 && (e.translation = r.translation), r.origin !== void 0 && (e.origin = r.origin), r.obsolete && (e.obsolete = !0), r.fuzzy && (e.fuzzy = !0), t[n] = e;
100
+ }
101
+ return JSON.stringify(t, null, 2) + "\n";
102
+ }
103
+ //#endregion
104
+ //#region src/po-format.ts
105
+ var b = "fluenti-id:";
106
+ function x(n) {
107
+ let r = t.po.parse(n), i = {}, a = r.translations ?? {};
108
+ for (let [t, n] of Object.entries(a)) for (let [r, a] of Object.entries(n)) {
109
+ if (!r) continue;
110
+ let n = t || a.msgctxt || void 0, o = a.msgstr?.[0] ?? void 0, s = a.comments?.reference ?? void 0, c = s?.includes("\n") ? s.split("\n").map((e) => e.trim()).filter(Boolean) : s?.includes(" ") ? s.split(/\s+/).filter(Boolean) : s, l = Array.isArray(c) && c.length === 1 ? c[0] : c, u = a.comments?.flag?.includes("fuzzy") ?? !1, { comment: d, customId: f, sourceMessage: p } = C(a.comments?.extracted), m = p && e(p, n) === r ? p : void 0, h = f ?? (m ? r : e(r, n));
111
+ i[h] = {
112
+ message: m ?? r,
113
+ ...n === void 0 ? {} : { context: n },
114
+ ...d === void 0 ? {} : { comment: d },
115
+ ...o ? { translation: o } : {},
116
+ ...l === void 0 ? {} : { origin: l },
117
+ ...u ? { fuzzy: !0 } : {}
118
+ };
119
+ }
120
+ return i;
121
+ }
122
+ function S(e) {
123
+ let n = { "": { "": {
124
+ msgid: "",
125
+ msgstr: ["Content-Type: text/plain; charset=UTF-8\n"]
126
+ } } };
127
+ for (let [t, r] of Object.entries(e)) {
128
+ let e = {
129
+ msgid: r.message ?? t,
130
+ ...r.context === void 0 ? {} : { msgctxt: r.context },
131
+ msgstr: [r.translation ?? ""]
132
+ }, i = {};
133
+ r.origin && (i.reference = Array.isArray(r.origin) ? r.origin.join("\n") : r.origin);
134
+ let a = T(t, r.message ?? t, r.context, r.comment);
135
+ a && (i.extracted = a), r.fuzzy && (i.flag = "fuzzy"), (i.reference || i.extracted || i.flag) && (e.comments = i);
136
+ let o = r.context ?? "";
137
+ n[o] ??= {}, n[o][e.msgid] = e;
138
+ }
139
+ let r = {
140
+ headers: { "Content-Type": "text/plain; charset=UTF-8" },
141
+ translations: n
142
+ };
143
+ return t.po.compile(r).toString();
144
+ }
145
+ function C(e) {
146
+ if (!e) return {};
147
+ let t = e.split("\n").map((e) => e.trim()).filter(Boolean), n, r, i = [];
148
+ for (let e of t) {
149
+ if (e.startsWith(b)) {
150
+ n = e.slice(11).trim() || void 0;
151
+ continue;
152
+ }
153
+ if (e.startsWith("msg`") && e.endsWith("`")) {
154
+ r = e.slice(4, -1);
155
+ continue;
156
+ }
157
+ if (e.startsWith("Trans: ")) {
158
+ r = w(e.slice(7));
159
+ continue;
160
+ }
161
+ i.push(e);
162
+ }
163
+ return {
164
+ ...i.length > 0 ? { comment: i.join("\n") } : {},
165
+ ...n ? { customId: n } : {},
166
+ ...r ? { sourceMessage: r } : {}
167
+ };
168
+ }
169
+ function w(e) {
170
+ let t = [], n = 0;
171
+ return e.replace(/<\/?([a-zA-Z][\w-]*)>/g, (e, r) => {
172
+ let i = r;
173
+ if (e.startsWith("</")) {
174
+ for (let e = t.length - 1; e >= 0; e--) {
175
+ let n = t[e];
176
+ if (n?.tag === i) return t = t.filter((t, n) => n !== e), `</${n.index}>`;
177
+ }
178
+ return e;
179
+ }
180
+ let a = n++;
181
+ return t.push({
182
+ tag: i,
183
+ index: a
184
+ }), `<${a}>`;
185
+ });
186
+ }
187
+ function T(t, n, r, i) {
188
+ let a = [];
189
+ return i && a.push(i), t !== e(n, r) && a.push(`${b} ${t}`), a.length > 0 ? a.join("\n") : void 0;
190
+ }
191
+ //#endregion
192
+ //#region src/parallel-compile.ts
193
+ function E() {
194
+ return l(typeof __dirname < "u" ? __dirname : c(f(import.meta.url)), "compile-worker.js");
195
+ }
196
+ async function D(e, t) {
197
+ if (e.length === 0) return [];
198
+ if (e.length === 1) {
199
+ let { compileCatalog: t } = await import("./compile-jumIhf8m.js").then((e) => e.a), n = e[0], { code: r, stats: i } = t(n.catalog, n.locale, n.allIds, n.sourceLocale, n.options);
200
+ return [{
201
+ locale: n.locale,
202
+ code: r,
203
+ stats: i
204
+ }];
205
+ }
206
+ let n = E();
207
+ if (!r(n)) return O(e);
208
+ let i = t ?? Math.min(e.length, d()), a = [], o = [...e], s = !1;
209
+ return new Promise((e, t) => {
210
+ let r = 0;
211
+ function c() {
212
+ if (s) return;
213
+ let i = o.shift();
214
+ if (!i) {
215
+ r === 0 && e(a);
216
+ return;
217
+ }
218
+ r++;
219
+ let l = new u(n);
220
+ l.on("message", (e) => {
221
+ a.push({
222
+ locale: e.locale,
223
+ code: e.code,
224
+ stats: e.stats
225
+ }), r--, l.terminate(), c();
226
+ }), l.on("error", (e) => {
227
+ s || (s = !0, l.terminate(), t(/* @__PURE__ */ Error(`Worker error compiling locale "${i.locale}": ${e.message}`)));
228
+ });
229
+ let d = {
230
+ locale: i.locale,
231
+ catalog: i.catalog,
232
+ allIds: i.allIds,
233
+ sourceLocale: i.sourceLocale,
234
+ options: i.options
235
+ };
236
+ l.postMessage(d);
237
+ }
238
+ let l = Math.min(i, o.length);
239
+ for (let e = 0; e < l; e++) c();
240
+ });
241
+ }
242
+ async function O(e) {
243
+ let { compileCatalog: t } = await import("./compile-jumIhf8m.js").then((e) => e.a);
244
+ return Promise.all(e.map((e) => {
245
+ let { code: n, stats: r } = t(e.catalog, e.locale, e.allIds, e.sourceLocale, e.options);
246
+ return {
247
+ locale: e.locale,
248
+ code: n,
249
+ stats: r
250
+ };
251
+ }));
252
+ }
253
+ //#endregion
254
+ //#region src/extract-cache.ts
255
+ var k = "1", A = class {
256
+ data;
257
+ cachePath;
258
+ dirty = !1;
259
+ constructor(e, t) {
260
+ this.cachePath = l(t ? l(e, ".cache", t) : l(e, ".cache"), "extract-cache.json"), this.data = this.load();
261
+ }
262
+ get(e) {
263
+ let t = this.data.entries[e];
264
+ if (t) try {
265
+ let n = o(e);
266
+ if (n.mtimeMs === t.mtime && n.size === t.size) return t.messages;
267
+ } catch {}
268
+ }
269
+ set(e, t) {
270
+ try {
271
+ let n = o(e);
272
+ this.data.entries[e] = {
273
+ mtime: n.mtimeMs,
274
+ size: n.size,
275
+ messages: t
276
+ }, this.dirty = !0;
277
+ } catch {}
278
+ }
279
+ prune(e) {
280
+ for (let t of Object.keys(this.data.entries)) e.has(t) || (delete this.data.entries[t], this.dirty = !0);
281
+ }
282
+ save() {
283
+ this.dirty &&= (i(c(this.cachePath), { recursive: !0 }), s(this.cachePath, JSON.stringify(this.data), "utf-8"), !1);
284
+ }
285
+ get size() {
286
+ return Object.keys(this.data.entries).length;
287
+ }
288
+ load() {
289
+ try {
290
+ if (r(this.cachePath)) {
291
+ let e = a(this.cachePath, "utf-8"), t = JSON.parse(e);
292
+ if (t.version === k) return t;
293
+ }
294
+ } catch {}
295
+ return {
296
+ version: k,
297
+ entries: {}
298
+ };
299
+ }
300
+ };
301
+ //#endregion
302
+ export { S as a, p as c, x as i, D as n, v as o, n as r, y as s, A as t };
303
+
304
+ //# sourceMappingURL=extract-cache-CmnwPMdA.js.map