@fluenti/cli 0.3.3 → 0.4.0-rc.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/dist/ai-provider.d.ts +4 -3
- package/dist/ai-provider.d.ts.map +1 -1
- package/dist/cli.cjs +13 -12
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +486 -289
- package/dist/cli.js.map +1 -1
- package/dist/{compile-B4y2UPsX.js → compile-CdA4EZ-p.js} +36 -33
- package/dist/compile-CdA4EZ-p.js.map +1 -0
- package/dist/compile-cache.d.ts.map +1 -1
- package/dist/compile-kXClO6q4.cjs +8 -0
- package/dist/compile-kXClO6q4.cjs.map +1 -0
- package/dist/compile-worker.cjs +1 -1
- package/dist/compile-worker.cjs.map +1 -1
- package/dist/compile-worker.d.ts +1 -0
- package/dist/compile-worker.d.ts.map +1 -1
- package/dist/compile-worker.js +19 -7
- package/dist/compile-worker.js.map +1 -1
- package/dist/compile.d.ts.map +1 -1
- package/dist/{extract-cache-idNfsd7n.cjs → extract-cache-BioSaoFo.cjs} +5 -5
- package/dist/extract-cache-BioSaoFo.cjs.map +1 -0
- package/dist/{extract-cache-DYoHe5P-.js → extract-cache-C-MI1_ll.js} +57 -44
- package/dist/extract-cache-C-MI1_ll.js.map +1 -0
- package/dist/extract-cache.d.ts.map +1 -1
- package/dist/extract-runner.d.ts.map +1 -1
- package/dist/glossary.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/dist/lint.d.ts.map +1 -1
- package/dist/migrate.d.ts.map +1 -1
- package/dist/parallel-compile.d.ts.map +1 -1
- package/dist/po-format.d.ts.map +1 -1
- package/dist/translate-parse.d.ts +10 -0
- package/dist/translate-parse.d.ts.map +1 -0
- package/dist/translate-prompt.d.ts +9 -0
- package/dist/translate-prompt.d.ts.map +1 -0
- package/dist/translate.d.ts +11 -9
- package/dist/translate.d.ts.map +1 -1
- package/dist/{tsx-extractor-C-9_TnCW.cjs → tsx-extractor-B0vFXziu.cjs} +2 -2
- package/dist/tsx-extractor-B0vFXziu.cjs.map +1 -0
- package/dist/{tsx-extractor-CjQIMvKo.js → tsx-extractor-C-HZNobu.js} +2 -2
- package/dist/tsx-extractor-C-HZNobu.js.map +1 -0
- package/dist/tsx-extractor.d.ts.map +1 -1
- package/dist/validation.d.ts +4 -1
- package/dist/validation.d.ts.map +1 -1
- package/dist/vue-extractor.cjs +2 -2
- package/dist/vue-extractor.cjs.map +1 -1
- package/dist/vue-extractor.d.ts.map +1 -1
- package/dist/vue-extractor.js +3 -3
- package/dist/vue-extractor.js.map +1 -1
- package/package.json +2 -2
- package/dist/compile-B4y2UPsX.js.map +0 -1
- package/dist/compile-Brygn0bn.cjs +0 -8
- package/dist/compile-Brygn0bn.cjs.map +0 -1
- package/dist/extract-cache-DYoHe5P-.js.map +0 -1
- package/dist/extract-cache-idNfsd7n.cjs.map +0 -1
- package/dist/tsx-extractor-C-9_TnCW.cjs.map +0 -1
- package/dist/tsx-extractor-CjQIMvKo.js.map +0 -1
|
@@ -22,13 +22,16 @@ function s(e) {
|
|
|
22
22
|
return e.replace(/\\/g, "\\\\").replace(/'/g, "\\'").replace(/\n/g, "\\n").replace(/\r/g, "\\r");
|
|
23
23
|
}
|
|
24
24
|
function c(e, t) {
|
|
25
|
-
return /^\d/.test(t) ? `${e}[${t}]` : `${e}.${t}`;
|
|
25
|
+
return /^\d/.test(t) ? `${e}['${t}']` : `${e}.${t}`;
|
|
26
26
|
}
|
|
27
27
|
function l(e) {
|
|
28
28
|
return e.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$\{/g, "\\${").replace(/\n/g, "\\n").replace(/\r/g, "\\r");
|
|
29
29
|
}
|
|
30
30
|
function u(e) {
|
|
31
|
-
|
|
31
|
+
i.lastIndex = 0;
|
|
32
|
+
let t = [], n = 0, r;
|
|
33
|
+
for (; (r = i.exec(e)) !== null;) t.push(l(e.slice(n, r.index))), t.push(`\${${c("v", r[1])}}`), n = i.lastIndex;
|
|
34
|
+
return t.push(l(e.slice(n))), t.join("");
|
|
32
35
|
}
|
|
33
36
|
var d = /\{(\w+),\s*(plural|select|selectordinal)\s*,/;
|
|
34
37
|
function f(e) {
|
|
@@ -62,7 +65,7 @@ function h(e, t) {
|
|
|
62
65
|
for (let n of l) {
|
|
63
66
|
if (n === "other") continue;
|
|
64
67
|
let r = p(e.options[n], t);
|
|
65
|
-
a.push(`if (__cat === '${n}') return ${r}; `);
|
|
68
|
+
a.push(`if (__cat === '${s(n)}') return ${r}; `);
|
|
66
69
|
}
|
|
67
70
|
}
|
|
68
71
|
let u = e.options.other ? p(e.options.other, t) : "''";
|
|
@@ -80,51 +83,51 @@ function g(e, t) {
|
|
|
80
83
|
return n.push(`return ${i}; `), n.push(`})(String(${c("v", e.variable)} ?? ''))`), n.join("");
|
|
81
84
|
}
|
|
82
85
|
function _(n, r, i, a, c) {
|
|
83
|
-
let
|
|
84
|
-
|
|
85
|
-
let
|
|
86
|
-
for (let
|
|
87
|
-
let i = e(
|
|
88
|
-
if (
|
|
89
|
-
|
|
90
|
-
let
|
|
91
|
-
if (
|
|
92
|
-
else if (f(
|
|
86
|
+
let l = [];
|
|
87
|
+
l.push("// @fluenti/compiled v1"), l.push("// @ts-nocheck");
|
|
88
|
+
let d = [], m = 0, h = [], g = /* @__PURE__ */ new Map();
|
|
89
|
+
for (let _ of i) {
|
|
90
|
+
let i = e(_), y = g.get(i);
|
|
91
|
+
if (y !== void 0 && y !== _) throw Error(`Hash collision detected: messages "${y}" and "${_}" produce the same hash "${i}"`);
|
|
92
|
+
g.set(i, _);
|
|
93
|
+
let b = `_${i}`, x = n[_], S = v(x, _, r, a, c?.skipFuzzy);
|
|
94
|
+
if (S === void 0) l.push(`export const ${b} = undefined`), h.push(_);
|
|
95
|
+
else if (f(S)) {
|
|
93
96
|
let e;
|
|
94
97
|
try {
|
|
95
|
-
e = t(
|
|
98
|
+
e = t(S);
|
|
96
99
|
} catch (e) {
|
|
97
|
-
console.warn(`[fluenti] Skipping malformed ICU translation for "${
|
|
98
|
-
id:
|
|
99
|
-
exportName:
|
|
100
|
+
console.warn(`[fluenti] Skipping malformed ICU translation for "${_}" (${r}): ${e.message}`), l.push(`export const ${b} = undefined`), h.push(_), d.push({
|
|
101
|
+
id: _,
|
|
102
|
+
exportName: b
|
|
100
103
|
});
|
|
101
104
|
continue;
|
|
102
105
|
}
|
|
103
106
|
let n = p(e, r);
|
|
104
|
-
|
|
105
|
-
} else if (o(
|
|
106
|
-
let e = u(
|
|
107
|
-
|
|
108
|
-
} else
|
|
109
|
-
|
|
110
|
-
id:
|
|
111
|
-
exportName:
|
|
107
|
+
l.push(`export const ${b} = (v) => ${n}`), m++;
|
|
108
|
+
} else if (o(S)) {
|
|
109
|
+
let e = u(S);
|
|
110
|
+
l.push(`export const ${b} = (v) => \`${e}\``), m++;
|
|
111
|
+
} else l.push(`export const ${b} = '${s(S)}'`), m++;
|
|
112
|
+
d.push({
|
|
113
|
+
id: _,
|
|
114
|
+
exportName: b
|
|
112
115
|
});
|
|
113
116
|
}
|
|
114
|
-
if (
|
|
117
|
+
if (d.length === 0) return {
|
|
115
118
|
code: "// @fluenti/compiled v1\n// empty catalog\nexport default {}\n",
|
|
116
119
|
stats: {
|
|
117
120
|
compiled: 0,
|
|
118
121
|
missing: []
|
|
119
122
|
}
|
|
120
123
|
};
|
|
121
|
-
|
|
122
|
-
for (let { id: e, exportName: t } of
|
|
123
|
-
return
|
|
124
|
-
code:
|
|
124
|
+
l.push(""), l.push("export default {");
|
|
125
|
+
for (let { id: e, exportName: t } of d) l.push(` '${s(e)}': ${t},`);
|
|
126
|
+
return l.push("}"), l.push(""), {
|
|
127
|
+
code: l.join("\n"),
|
|
125
128
|
stats: {
|
|
126
|
-
compiled:
|
|
127
|
-
missing:
|
|
129
|
+
compiled: m,
|
|
130
|
+
missing: h
|
|
128
131
|
}
|
|
129
132
|
};
|
|
130
133
|
}
|
|
@@ -199,4 +202,4 @@ function C(e, t, n) {
|
|
|
199
202
|
//#endregion
|
|
200
203
|
export { r as a, C as i, _ as n, y as r, b as t };
|
|
201
204
|
|
|
202
|
-
//# sourceMappingURL=compile-
|
|
205
|
+
//# sourceMappingURL=compile-CdA4EZ-p.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile-CdA4EZ-p.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 valid identifiers, `v['name']` for others */\nfunction propAccess(obj: string, name: string): string {\n // Names starting with a digit are not valid JS identifiers; use quoted bracket notation.\n // e.g. {0} → v['0'], {1st} → v['1st']. Pure integers (v['0']) work the same as v[0].\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\n/**\n * Convert a simple ICU message (only `{varName}` placeholders) into a JS template literal body.\n * Static segments are escaped independently so literal `${`, backticks, etc. are preserved\n * without interfering with the ICU variable interpolations that are inserted afterwards.\n */\nfunction messageToTemplateString(message: string): string {\n ICU_VAR_REGEX.lastIndex = 0\n const parts: string[] = []\n let lastIndex = 0\n let m: RegExpExecArray | null\n while ((m = ICU_VAR_REGEX.exec(message)) !== null) {\n parts.push(escapeTemplateLiteral(message.slice(lastIndex, m.index)))\n parts.push(`\\${${propAccess('v', m[1]!)}}`)\n lastIndex = ICU_VAR_REGEX.lastIndex\n }\n parts.push(escapeTemplateLiteral(message.slice(lastIndex)))\n return parts.join('')\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 === '${escapeStringLiteral(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 let ast\n try {\n ast = parse(translated)\n } catch (err) {\n console.warn(\n `[fluenti] Skipping malformed ICU translation for \"${id}\" (${locale}): ${(err as Error).message}`,\n )\n lines.push(`export const ${exportName} = undefined`)\n missing.push(id)\n exportNames.push({ id, exportName })\n continue\n }\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(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;AAGrD,QAAO,MAAM,KAAK,EAAK,GAAG,GAAG,EAAI,IAAI,EAAK,MAAM,GAAG,EAAI,GAAG;;AAG5D,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;;AAQ1B,SAAS,EAAwB,GAAyB;AACxD,GAAc,YAAY;CAC1B,IAAM,IAAkB,EAAE,EACtB,IAAY,GACZ;AACJ,SAAQ,IAAI,EAAc,KAAK,EAAQ,MAAM,MAG3C,CAFA,EAAM,KAAK,EAAsB,EAAQ,MAAM,GAAW,EAAE,MAAM,CAAC,CAAC,EACpE,EAAM,KAAK,MAAM,EAAW,KAAK,EAAE,GAAI,CAAC,GAAG,EAC3C,IAAY,EAAc;AAG5B,QADA,EAAM,KAAK,EAAsB,EAAQ,MAAM,EAAU,CAAC,CAAC,EACpD,EAAM,KAAK,GAAG;;AAMvB,IAAM,IAA0B;AAGhC,SAAS,EAAqB,GAA0B;AACtD,QAAO,EAAwB,KAAK,EAAQ;;AAO9C,SAAS,EAAk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AG;AACzC,MAAI,EAAK,WAAW,EAClB,GAAM,KAAK,MAAM,EAAU,0BAA0B;OAChD;GACL,IAAM,IAAS,EAAK,KAAK,MAAM,GAAG,EAAE,KAAK,IAAI,EAAE,OAAO,CAAC,KAAK,KAAK;AACjE,KAAM,KAAK,MAAM,EAAU,OAAO,EAAO,IAAI;;;AAIjD,CADA,EAAM,KAAK,IAAI,EACf,EAAM,KAAK,GAAG;CAId,IAAM,IAAa,OAAO,KAAK,EAAS,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile-cache.d.ts","sourceRoot":"","sources":["../src/compile-cache.ts"],"names":[],"mappings":"AAgBA;;;;GAIG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,IAAI,CAAkB;IAC9B,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,KAAK,CAAQ;gBAET,UAAU,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;IAQlD;;;OAGG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO;IAQ3D;;OAEG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,IAAI;IAOjD;;OAEG;IACH,IAAI,IAAI,IAAI;
|
|
1
|
+
{"version":3,"file":"compile-cache.d.ts","sourceRoot":"","sources":["../src/compile-cache.ts"],"names":[],"mappings":"AAgBA;;;;GAIG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,IAAI,CAAkB;IAC9B,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,KAAK,CAAQ;gBAET,UAAU,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;IAQlD;;;OAGG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO;IAQ3D;;OAEG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,IAAI;IAOjD;;OAEG;IACH,IAAI,IAAI,IAAI;IAYZ,OAAO,CAAC,IAAI;CAeb"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const e=require(`./extract-cache-BioSaoFo.cjs`);let t=require(`@fluenti/core/internal`);var n=e.c({CATALOG_VERSION:()=>1,collectAllIds:()=>y,compileCatalog:()=>g,compileIndex:()=>v,compileTypeDeclaration:()=>S,extractMessageVariables:()=>b}),r=/\{(\w+)\}/g,i=/\{(\w+)\}/;function a(e){return i.test(e)}function o(e){return e.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`).replace(/\n/g,`\\n`).replace(/\r/g,`\\r`)}function s(e,t){return/^\d/.test(t)?`${e}['${t}']`:`${e}.${t}`}function c(e){return e.replace(/\\/g,`\\\\`).replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\n/g,`\\n`).replace(/\r/g,`\\r`)}function l(e){r.lastIndex=0;let t=[],n=0,i;for(;(i=r.exec(e))!==null;)t.push(c(e.slice(n,i.index))),t.push(`\${${s(`v`,i[1])}}`),n=r.lastIndex;return t.push(c(e.slice(n))),t.join(``)}var u=/\{(\w+),\s*(plural|select|selectordinal)\s*,/;function d(e){return u.test(e)}function f(e,t){if(e.length===0)return`''`;let n=e.map(e=>p(e,t));return n.length===1?n[0]:n.join(` + `)}function p(e,t){switch(e.type){case`text`:return`'${o(e.value)}'`;case`variable`:return e.name===`#`?`String(__c)`:`String(${s(`v`,e.name)} ?? '{${e.name}}')`;case`plural`:return m(e,t);case`select`:return h(e,t);case`function`:return`String(${s(`v`,e.variable)} ?? '')`}}function m(e,t){let n=e.offset??0,r=s(`v`,e.variable),i=n?`(${r} - ${n})`:r,a=[];a.push(`((c) => { const __c = c; `);let c=Object.keys(e.options).filter(e=>e.startsWith(`=`));if(c.length>0)for(let n of c){let r=n.slice(1),i=f(e.options[n],t);a.push(`if (c === ${r}) return ${i}; `)}let l=Object.keys(e.options).filter(e=>!e.startsWith(`=`));if(l.length>1||l.length===1&&l[0]!==`other`){a.push(`const __cat = new Intl.PluralRules('${o(t)}').select(c); `);for(let n of l){if(n===`other`)continue;let r=f(e.options[n],t);a.push(`if (__cat === '${o(n)}') return ${r}; `)}}let u=e.options.other?f(e.options.other,t):`''`;return a.push(`return ${u}; `),a.push(`})(${i})`),a.join(``)}function h(e,t){let n=[];n.push(`((s) => { `);let r=Object.keys(e.options).filter(e=>e!==`other`);for(let i of r){let r=f(e.options[i],t);n.push(`if (s === '${o(i)}') return ${r}; `)}let i=e.options.other?f(e.options.other,t):`''`;return n.push(`return ${i}; `),n.push(`})(String(${s(`v`,e.variable)} ?? ''))`),n.join(``)}function g(e,n,r,i,s){let c=[];c.push(`// @fluenti/compiled v1`),c.push(`// @ts-nocheck`);let u=[],p=0,m=[],h=new Map;for(let g of r){let r=(0,t.hashMessage)(g),v=h.get(r);if(v!==void 0&&v!==g)throw Error(`Hash collision detected: messages "${v}" and "${g}" produce the same hash "${r}"`);h.set(r,g);let y=`_${r}`,b=e[g],x=_(b,g,n,i,s?.skipFuzzy);if(x===void 0)c.push(`export const ${y} = undefined`),m.push(g);else if(d(x)){let e;try{e=(0,t.parse)(x)}catch(e){console.warn(`[fluenti] Skipping malformed ICU translation for "${g}" (${n}): ${e.message}`),c.push(`export const ${y} = undefined`),m.push(g),u.push({id:g,exportName:y});continue}let r=f(e,n);c.push(`export const ${y} = (v) => ${r}`),p++}else if(a(x)){let e=l(x);c.push(`export const ${y} = (v) => \`${e}\``),p++}else c.push(`export const ${y} = '${o(x)}'`),p++;u.push({id:g,exportName:y})}if(u.length===0)return{code:`// @fluenti/compiled v1
|
|
2
|
+
// empty catalog
|
|
3
|
+
export default {}
|
|
4
|
+
`,stats:{compiled:0,missing:[]}};c.push(``),c.push(`export default {`);for(let{id:e,exportName:t}of u)c.push(` '${o(e)}': ${t},`);return c.push(`}`),c.push(``),{code:c.join(`
|
|
5
|
+
`),stats:{compiled:p,missing:m}}}function _(e,t,n,r,i){let a=r??n;if(e&&!(i&&e.fuzzy)){if(e.translation!==void 0&&e.translation.length>0)return e.translation;if(n===a)return e.message??t}}function v(e,t){let n=[];n.push(`export const locales = ${JSON.stringify(e)}`),n.push(``),n.push(`export const loaders = {`);for(let t of e)n.push(` '${o(t)}': () => import('./${o(t)}.js'),`);return n.push(`}`),n.push(``),n.join(`
|
|
6
|
+
`)}function y(e){let t=new Set;for(let n of Object.values(e))for(let[e,r]of Object.entries(n))r.obsolete||t.add(e);return[...t].sort()}function b(e){let n=(0,t.parse)(e),r=new Map;return x(n,r),[...r.entries()].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({name:e,type:t}))}function x(e,t){for(let n of e)switch(n.type){case`variable`:n.name!==`#`&&!t.has(n.name)&&t.set(n.name,`string | number`);break;case`plural`:{let e=n;t.set(e.variable,`number`);for(let n of Object.values(e.options))x(n,t);break}case`select`:{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`;t.set(e.variable,o);for(let n of Object.values(e.options))x(n,t);break}case`function`:t.has(n.variable)||t.set(n.variable,`string | number`);break;case`text`:break}}function S(e,t,n){let r=[];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`);else{r.push(`export type MessageId =`);for(let t of e)r.push(` | '${o(t)}'`)}r.push(``),r.push(`export interface MessageValues {`);for(let i of e){let e=b(t[n]?.[i]?.message??i),a=o(i);if(e.length===0)r.push(` '${a}': Record<string, never>`);else{let t=e.map(e=>`${e.name}: ${e.type}`).join(`; `);r.push(` '${a}': { ${t} }`)}}r.push(`}`),r.push(``);let i=Object.keys(t).map(e=>`'${o(e)}'`).join(` | `);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(`
|
|
7
|
+
`)}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return y}});
|
|
8
|
+
//# sourceMappingURL=compile-kXClO6q4.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile-kXClO6q4.cjs","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 valid identifiers, `v['name']` for others */\nfunction propAccess(obj: string, name: string): string {\n // Names starting with a digit are not valid JS identifiers; use quoted bracket notation.\n // e.g. {0} → v['0'], {1st} → v['1st']. Pure integers (v['0']) work the same as v[0].\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\n/**\n * Convert a simple ICU message (only `{varName}` placeholders) into a JS template literal body.\n * Static segments are escaped independently so literal `${`, backticks, etc. are preserved\n * without interfering with the ICU variable interpolations that are inserted afterwards.\n */\nfunction messageToTemplateString(message: string): string {\n ICU_VAR_REGEX.lastIndex = 0\n const parts: string[] = []\n let lastIndex = 0\n let m: RegExpExecArray | null\n while ((m = ICU_VAR_REGEX.exec(message)) !== null) {\n parts.push(escapeTemplateLiteral(message.slice(lastIndex, m.index)))\n parts.push(`\\${${propAccess('v', m[1]!)}}`)\n lastIndex = ICU_VAR_REGEX.lastIndex\n }\n parts.push(escapeTemplateLiteral(message.slice(lastIndex)))\n return parts.join('')\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 === '${escapeStringLiteral(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 let ast\n try {\n ast = parse(translated)\n } catch (err) {\n console.warn(\n `[fluenti] Skipping malformed ICU translation for \"${id}\" (${locale}): ${(err as Error).message}`,\n )\n lines.push(`export const ${exportName} = undefined`)\n missing.push(id)\n exportNames.push({ id, exportName })\n continue\n }\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(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":"kPAIM,EAAgB,aAChB,EAAe,YAErB,SAAS,EAAa,EAA0B,CAC9C,OAAO,EAAa,KAAK,EAAQ,CAInC,SAAS,EAAoB,EAAqB,CAChD,OAAO,EACJ,QAAQ,MAAO,OAAO,CACtB,QAAQ,KAAM,MAAM,CACpB,QAAQ,MAAO,MAAM,CACrB,QAAQ,MAAO,MAAM,CAI1B,SAAS,EAAW,EAAa,EAAsB,CAGrD,MAAO,MAAM,KAAK,EAAK,CAAG,GAAG,EAAI,IAAI,EAAK,IAAM,GAAG,EAAI,GAAG,IAG5D,SAAS,EAAsB,EAAqB,CAClD,OAAO,EACJ,QAAQ,MAAO,OAAO,CACtB,QAAQ,KAAM,MAAM,CACpB,QAAQ,QAAS,OAAO,CACxB,QAAQ,MAAO,MAAM,CACrB,QAAQ,MAAO,MAAM,C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AkD,CAC7D,EAAM,KAAK,GAAG,CACd,EAAM,KAAK,uDAAyD,CACpE,EAAM,KAAK,GAAG,CAGV,EAAO,SAAW,EACpB,EAAM,KAAK,gCAAgC,KACtC,CACL,EAAM,KAAK,0BAA0B,CACrC,IAAK,IAAM,KAAM,EACf,EAAM,KAAK,QAAQ,EAAoB,EAAG,CAAC,GAAG,CAIlD,EAAM,KAAK,GAAG,CAGd,EAAM,KAAK,mCAAmC,CAC9C,IAAK,IAAM,KAAM,EAAQ,CAKvB,IAAM,EAAO,EAHS,EAAS,KACD,IACP,SAAW,EACW,CAEvC,EAAY,EAAoB,EAAG,CACzC,GAAI,EAAK,SAAW,EAClB,EAAM,KAAK,MAAM,EAAU,0BAA0B,KAChD,CACL,IAAM,EAAS,EAAK,IAAK,GAAM,GAAG,EAAE,KAAK,IAAI,EAAE,OAAO,CAAC,KAAK,KAAK,CACjE,EAAM,KAAK,MAAM,EAAU,OAAO,EAAO,IAAI,EAGjD,EAAM,KAAK,IAAI,CACf,EAAM,KAAK,GAAG,CAId,IAAM,EAAa,OAAO,KAAK,EAAS,CAAC,IAAK,GAAM,IAAI,EAAoB,EAAE,CAAC,GAAG,CAAC,KAAK,MAAM,CAY9F,OAVA,EAAM,KAAK,gEAAgE,CAC3E,EAAM,KAAK,mCAAmC,CAC9C,EAAM,KAAK,kCAAkC,CAC7C,EAAM,KAAK,eAAe,GAAc,WAAW,CACnD,EAAM,KAAK,4BAA4B,CACvC,EAAM,KAAK,mCAAmC,CAC9C,EAAM,KAAK,MAAM,CACjB,EAAM,KAAK,IAAI,CACf,EAAM,KAAK,GAAG,CAEP,EAAM,KAAK;EAAK"}
|
package/dist/compile-worker.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
require(`./extract-cache-
|
|
1
|
+
require(`./extract-cache-BioSaoFo.cjs`);const e=require(`./compile-kXClO6q4.cjs`);let t=require(`node:worker_threads`);t.parentPort.on(`message`,n=>{try{let{code:r,stats:i}=e.n(n.catalog,n.locale,n.allIds,n.sourceLocale,n.options);t.parentPort.postMessage({locale:n.locale,code:r,stats:i})}catch(e){t.parentPort.postMessage({locale:n.locale,code:``,stats:{compiled:0,missing:[]},error:e instanceof Error?e.message:String(e)})}});
|
|
2
2
|
//# sourceMappingURL=compile-worker.cjs.map
|
|
@@ -1 +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
|
|
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 error?: string\n}\n\nparentPort!.on('message', (req: CompileWorkerRequest) => {\n try {\n const { code, stats } = compileCatalog(req.catalog, req.locale, req.allIds, req.sourceLocale, req.options)\n parentPort!.postMessage({ locale: req.locale, code, stats } satisfies CompileWorkerResponse)\n } catch (err) {\n parentPort!.postMessage({\n locale: req.locale,\n code: '',\n stats: { compiled: 0, missing: [] },\n error: err instanceof Error ? err.message : String(err),\n } satisfies CompileWorkerResponse)\n }\n})\n"],"mappings":"uHAoBA,EAAA,WAAY,GAAG,UAAY,GAA8B,CACvD,GAAI,CACF,GAAM,CAAE,OAAM,SAAU,EAAA,EAAe,EAAI,QAAS,EAAI,OAAQ,EAAI,OAAQ,EAAI,aAAc,EAAI,QAAQ,CAC1G,EAAA,WAAY,YAAY,CAAE,OAAQ,EAAI,OAAQ,OAAM,QAAO,CAAiC,OACrF,EAAK,CACZ,EAAA,WAAY,YAAY,CACtB,OAAQ,EAAI,OACZ,KAAM,GACN,MAAO,CAAE,SAAU,EAAG,QAAS,EAAE,CAAE,CACnC,MAAO,aAAe,MAAQ,EAAI,QAAU,OAAO,EAAI,CACxD,CAAiC,GAEpC"}
|
package/dist/compile-worker.d.ts
CHANGED
|
@@ -1 +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;
|
|
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;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAA;CACf"}
|
package/dist/compile-worker.js
CHANGED
|
@@ -1,13 +1,25 @@
|
|
|
1
|
-
import { n as e } from "./compile-
|
|
1
|
+
import { n as e } from "./compile-CdA4EZ-p.js";
|
|
2
2
|
import { parentPort as t } from "node:worker_threads";
|
|
3
3
|
//#region src/compile-worker.ts
|
|
4
4
|
t.on("message", (n) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
try {
|
|
6
|
+
let { code: r, stats: i } = e(n.catalog, n.locale, n.allIds, n.sourceLocale, n.options);
|
|
7
|
+
t.postMessage({
|
|
8
|
+
locale: n.locale,
|
|
9
|
+
code: r,
|
|
10
|
+
stats: i
|
|
11
|
+
});
|
|
12
|
+
} catch (e) {
|
|
13
|
+
t.postMessage({
|
|
14
|
+
locale: n.locale,
|
|
15
|
+
code: "",
|
|
16
|
+
stats: {
|
|
17
|
+
compiled: 0,
|
|
18
|
+
missing: []
|
|
19
|
+
},
|
|
20
|
+
error: e instanceof Error ? e.message : String(e)
|
|
21
|
+
});
|
|
22
|
+
}
|
|
11
23
|
});
|
|
12
24
|
//#endregion
|
|
13
25
|
|
|
@@ -1 +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
|
|
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 error?: string\n}\n\nparentPort!.on('message', (req: CompileWorkerRequest) => {\n try {\n const { code, stats } = compileCatalog(req.catalog, req.locale, req.allIds, req.sourceLocale, req.options)\n parentPort!.postMessage({ locale: req.locale, code, stats } satisfies CompileWorkerResponse)\n } catch (err) {\n parentPort!.postMessage({\n locale: req.locale,\n code: '',\n stats: { compiled: 0, missing: [] },\n error: err instanceof Error ? err.message : String(err),\n } satisfies CompileWorkerResponse)\n }\n})\n"],"mappings":";;;AAoBA,EAAY,GAAG,YAAY,MAA8B;AACvD,KAAI;EACF,IAAM,EAAE,SAAM,aAAU,EAAe,EAAI,SAAS,EAAI,QAAQ,EAAI,QAAQ,EAAI,cAAc,EAAI,QAAQ;AAC1G,IAAY,YAAY;GAAE,QAAQ,EAAI;GAAQ;GAAM;GAAO,CAAiC;UACrF,GAAK;AACZ,IAAY,YAAY;GACtB,QAAQ,EAAI;GACZ,MAAM;GACN,OAAO;IAAE,UAAU;IAAG,SAAS,EAAE;IAAE;GACnC,OAAO,aAAe,QAAQ,EAAI,UAAU,OAAO,EAAI;GACxD,CAAiC;;EAEpC"}
|
package/dist/compile.d.ts.map
CHANGED
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../src/compile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AA4J5C;;;;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,CA0EvC;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,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,EAAE,CAO1E;AA8CD;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EAAE,EAChB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EACrC,YAAY,EAAE,MAAM,GACnB,MAAM,CAsDR"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let l=require(`@fluenti/core/internal`),u=require(`gettext-parser`);u=c(u),require(`@fluenti/core/config`);let d=require(`node:fs`),f=require(`node:path`),p=require(`node:worker_threads`),m=require(`node:os`),h=require(`node:url`);function g(e,t,n){let r=new Set(t.map(e=>e.id)),i=new Set,a={},o=0,s=0,c=0;for(let r of t){let t=e[r.id],c=t?void 0:v(e,r,i),l=`${r.origin.file}:${r.origin.line}`,u=t??c?.entry;if(c&&i.add(c.id),u)a[r.id]={...u,message:r.message??u.message,context:r.context,comment:r.comment,origin:l,obsolete:!1},s++;else if(a[r.id]){let e=a[r.id];a[r.id]={...e,origin:_(e.origin,l)}}else a[r.id]={message:r.message,context:r.context,comment:r.comment,origin:l},o++;if(n?.stripFuzzy){let{fuzzy:e,...t}=a[r.id];a[r.id]=t}}for(let[t,i]of Object.entries(e))if(!r.has(t)){let{fuzzy:e,...r}=i;a[t]=n?.stripFuzzy?{...r,obsolete:!0}:{...i,obsolete:!0},c++}return{catalog:a,result:{added:o,unchanged:s,obsolete:c}}}function _(e,t){if(!e)return t;let n=[...new Set([...Array.isArray(e)?e:[e],t])];return n.length===1?n[0]:n}function v(e,t,n){if(!t.context)return;let r=`${t.origin.file}:${t.origin.line}`;for(let[i,a]of Object.entries(e))if(!n.has(i)&&a.context===void 0&&a.message===t.message&&y(a.origin,r))return{id:i,entry:a}}function y(e,t){return e?(Array.isArray(e)?e:[e]).some(e=>e===t||b(e)===b(t)):!1}function b(e){return e.match(/^(.*):\d+$/)?.[1]??e}function x(e){let t=JSON.parse(e),n={};for(let[e,r]of Object.entries(t))if(typeof r==`object`&&r){let t=r;n[e]={message:typeof t.message==`string`?t.message:void 0,context:typeof t.context==`string`?t.context:void 0,comment:typeof t.comment==`string`?t.comment:void 0,translation:typeof t.translation==`string`?t.translation:void 0,origin:typeof t.origin==`string`||Array.isArray(t.origin)&&t.origin.every(e=>typeof e==`string`)?t.origin:void 0,obsolete:typeof t.obsolete==`boolean`?t.obsolete:void 0,fuzzy:typeof t.fuzzy==`boolean`?t.fuzzy:void 0}}return n}function S(e){let t={};for(let[n,r]of Object.entries(e)){let e={};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}return JSON.stringify(t,null,2)+`
|
|
2
2
|
`}var C=`fluenti-id:`;function w(e,t,n){for(let[r,i]of Object.entries(e))for(let[e,a]of Object.entries(i)){if(!e)continue;let i=r||a.msgctxt||void 0,o=a.msgstr?.[0]??void 0,s=a.comments?.reference??void 0,c=s?.includes(`
|
|
3
3
|
`)?s.split(`
|
|
4
|
-
`).map(e=>e.trim()).filter(Boolean):s?.includes(` `)?s.split(/\s+/).filter(Boolean):s,u=Array.isArray(c)&&c.length===1?c[0]:c,d=!n&&(a.comments?.flag?.includes(`fuzzy`)??!1),{comment:f,customId:p,sourceMessage:m}=D(a.comments?.extracted),h=m&&(0,l.hashMessage)(m,i)===e?m:void 0,g=p??(h?e:(0,l.hashMessage)(e,i));t[g]={message:h??e,...i===void 0?{}:{context:i},...f===void 0?{}:{comment:f},...o?{translation:o}:{},...u===void 0?{}:{origin:u},...d?{fuzzy:!0}:{},...n?{obsolete:!0}:{}}}}function T(e){let t=u.po.parse(e),n={};return w(t.translations??{},n,!1),t.obsolete&&w(t.obsolete,n,!0),n}function E(e){let t={"":{"":{msgid:``,msgstr:[`Content-Type: text/plain; charset=UTF-8
|
|
5
|
-
`]}}},n={};for(let[r,i]of Object.entries(e)){let e={msgid:i.message??r,...i.context===void 0?{}:{msgctxt:i.context},msgstr:[i.translation??``]},a={};i.origin&&!i.obsolete&&(a.reference=Array.isArray(i.origin)?i.origin.join(`
|
|
4
|
+
`).map(e=>e.trim()).filter(Boolean):s?.includes(` `)?s.split(/\s+/).filter(Boolean):s,u=Array.isArray(c)&&c.length===1?c[0]:c,d=!n&&(a.comments?.flag?.includes(`fuzzy`)??!1),{comment:f,customId:p,sourceMessage:m}=D(a.comments?.extracted),h=m&&(p!==void 0||(0,l.hashMessage)(m,i)===e)?m:void 0,g=p??(h?e:(0,l.hashMessage)(e,i));t[g]={message:h??e,...i===void 0?{}:{context:i},...f===void 0?{}:{comment:f},...o?{translation:o}:{},...u===void 0?{}:{origin:u},...d?{fuzzy:!0}:{},...n?{obsolete:!0}:{}}}}function T(e){let t=u.po.parse(e),n={};return w(t.translations??{},n,!1),t.obsolete&&w(t.obsolete,n,!0),n}function E(e){let t={"":{"":{msgid:``,msgstr:[`Content-Type: text/plain; charset=UTF-8
|
|
5
|
+
`]}}},n={};for(let[r,i]of Object.entries(e)){let e={msgid:i.message!==void 0&&(0,l.hashMessage)(i.message,i.context)===r?i.message??r:r,...i.context===void 0?{}:{msgctxt:i.context},msgstr:[i.translation??``]},a={};i.origin&&!i.obsolete&&(a.reference=Array.isArray(i.origin)?i.origin.join(`
|
|
6
6
|
`):i.origin);let o=k(r,i.message??r,i.context,i.comment);if(o&&(a.extracted=o),i.fuzzy&&!i.obsolete&&(a.flag=`fuzzy`),(a.reference||a.extracted||a.flag)&&(e.comments=a),i.obsolete){let t=i.context??``;n[t]??={},n[t][e.msgid]=e}else{let n=i.context??``;t[n]??={},t[n][e.msgid]=e}}let r={headers:{"Content-Type":`text/plain; charset=UTF-8`},translations:t,...Object.keys(n).length>0?{obsolete:n}:{}};return u.po.compile(r).toString()}function D(e){if(!e)return{};let t=e.split(`
|
|
7
7
|
`).map(e=>e.trim()).filter(Boolean),n,r,i=[];for(let e of t){if(e.startsWith(C)){n=e.slice(11).trim()||void 0;continue}if(e.startsWith("msg`")&&e.endsWith("`")){r=e.slice(4,-1);continue}if(e.startsWith(`Trans: `)){r=O(e.slice(7));continue}i.push(e)}return{...i.length>0?{comment:i.join(`
|
|
8
|
-
`)}:{},...n?{customId:n}:{},...r?{sourceMessage:r}:{}}}function O(e){let t=[],n=0;return e.replace(/<\/?([a-zA-Z][\w-]*)>/g,(e,r)=>{let i=r;if(e.startsWith(`</`)){for(let e=t.length-1;e>=0;e--){let n=t[e];if(n?.tag===i)return t=t.filter((t,n)=>n!==e),`</${n.index}>`}return e}let a=n++;return t.push({tag:i,index:a}),`<${a}>`})}function k(e,t,n,r){let i=[];return r&&i.push(r),e!==(0,l.hashMessage)(t,n)&&i.push(`${C} ${e}`),i.length>0?i.join(`
|
|
9
|
-
`):void 0}function
|
|
10
|
-
//# sourceMappingURL=extract-cache-
|
|
8
|
+
`)}:{},...n?{customId:n}:{},...r?{sourceMessage:r}:{}}}function O(e){let t=[],n=0;return e.replace(/<\/?([a-zA-Z][\w-]*)>/g,(e,r)=>{let i=r;if(e.startsWith(`</`)){for(let e=t.length-1;e>=0;e--){let n=t[e];if(n?.tag===i)return t=t.filter((t,n)=>n!==e),`</${n.index}>`}return e}let a=n++;return t.push({tag:i,index:a}),`<${a}>`})}function k(e,t,n,r){let i=[];return r&&i.push(r),e!==(0,l.hashMessage)(t,n)&&(i.push(`${C} ${e}`),i.push(`msg\`${t}\``)),i.length>0?i.join(`
|
|
9
|
+
`):void 0}var A=3e4;function j(){return(0,f.resolve)(typeof __dirname<`u`?__dirname:(0,f.dirname)((0,h.fileURLToPath)({}.url)),`compile-worker.js`)}async function M(e,t){if(e.length===0)return[];if(e.length===1){let{compileCatalog:t}=await Promise.resolve().then(()=>require(`./compile-kXClO6q4.cjs`)).then(e=>e.a),n=e[0],{code:r,stats:i}=t(n.catalog,n.locale,n.allIds,n.sourceLocale,n.options);return[{locale:n.locale,code:r,stats:i}]}let n=j();if(!(0,d.existsSync)(n))return N(e);let r=t??Math.min(e.length,(0,m.availableParallelism)()),i=[],a=[...e],o=!1;return new Promise((e,t)=>{let s=0;function c(){if(o)return;let r=a.shift();if(!r){s===0&&e(i);return}s++;let l=new p.Worker(n),u=setTimeout(()=>{o||(o=!0,s--,l.terminate(),t(Error(`Worker timed out after ${A}ms compiling locale "${r.locale}"`)))},A);l.on(`message`,e=>{if(clearTimeout(u),!o){if(e.error){o=!0,s--,l.terminate(),t(Error(`Failed to compile locale "${e.locale}": ${e.error}`));return}i.push({locale:e.locale,code:e.code,stats:e.stats}),s--,l.terminate(),c()}}),l.on(`error`,e=>{clearTimeout(u),o||(o=!0,l.terminate(),t(Error(`Worker error compiling locale "${r.locale}": ${e.message}`)))}),l.on(`exit`,e=>{clearTimeout(u),e!==0&&!o&&(o=!0,t(Error(`Worker exited with code ${e} while compiling locale "${r.locale}"`)))});let d={locale:r.locale,catalog:r.catalog,allIds:r.allIds,sourceLocale:r.sourceLocale,options:r.options};l.postMessage(d)}let l=Math.min(r,a.length);for(let e=0;e<l;e++)c()})}async function N(e){let{compileCatalog:t}=await Promise.resolve().then(()=>require(`./compile-kXClO6q4.cjs`)).then(e=>e.a);return Promise.all(e.map(e=>{let{code:n,stats:r}=t(e.catalog,e.locale,e.allIds,e.sourceLocale,e.options);return{locale:e.locale,code:n,stats:r}}))}var P=`1`,F=class{data;cachePath;dirty=!1;constructor(e,t){this.cachePath=(0,f.resolve)(t?(0,f.resolve)(e,`.cache`,t):(0,f.resolve)(e,`.cache`),`extract-cache.json`),this.data=this.load()}get(e){let t=this.data.entries[e];if(t)try{let n=(0,d.statSync)(e);if(n.mtimeMs===t.mtime&&n.size===t.size)return t.messages}catch{}}set(e,t){try{let n=(0,d.statSync)(e);this.data.entries[e]={mtime:n.mtimeMs,size:n.size,messages:t},this.dirty=!0}catch{}}prune(e){for(let t of Object.keys(this.data.entries))e.has(t)||(delete this.data.entries[t],this.dirty=!0)}save(){if(this.dirty)try{(0,d.mkdirSync)((0,f.dirname)(this.cachePath),{recursive:!0}),(0,d.writeFileSync)(this.cachePath,JSON.stringify(this.data),`utf-8`),this.dirty=!1}catch{}}get size(){return Object.keys(this.data.entries).length}load(){try{if((0,d.existsSync)(this.cachePath)){let e=(0,d.readFileSync)(this.cachePath,`utf-8`),t=JSON.parse(e);if(t.version===P)return t}}catch{}return{version:P,entries:{}}}};Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return F}});
|
|
10
|
+
//# sourceMappingURL=extract-cache-BioSaoFo.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-cache-BioSaoFo.cjs","names":[],"sources":["../src/catalog.ts","../src/json-format.ts","../src/po-format.ts","../src/parallel-compile.ts","../src/extract-cache.ts"],"sourcesContent":["import type { ExtractedMessage } from '@fluenti/core/internal'\n\nexport interface CatalogEntry {\n message?: string | undefined\n context?: string | undefined\n comment?: string | undefined\n translation?: string | undefined\n origin?: string | string[] | undefined\n obsolete?: boolean | undefined\n fuzzy?: boolean | undefined\n}\n\nexport type CatalogData = Record<string, CatalogEntry>\n\nexport interface UpdateResult {\n added: number\n unchanged: number\n obsolete: number\n}\n\nexport interface UpdateCatalogOptions {\n stripFuzzy?: boolean\n}\n\n/** Update catalog with newly extracted messages */\nexport function updateCatalog(\n existing: CatalogData,\n extracted: ExtractedMessage[],\n options?: UpdateCatalogOptions,\n): { catalog: CatalogData; result: UpdateResult } {\n const extractedIds = new Set(extracted.map((m) => m.id))\n const consumedCarryForwardIds = new Set<string>()\n const catalog: CatalogData = {}\n let added = 0\n let unchanged = 0\n let obsolete = 0\n\n for (const msg of extracted) {\n const existingEntry = existing[msg.id]\n const carried = existingEntry\n ? undefined\n : findCarryForwardEntry(existing, msg, consumedCarryForwardIds)\n const origin = `${msg.origin.file}:${msg.origin.line}`\n const baseEntry = existingEntry ?? carried?.entry\n\n if (carried) {\n consumedCarryForwardIds.add(carried.id)\n }\n\n if (baseEntry) {\n catalog[msg.id] = {\n ...baseEntry,\n message: msg.message ?? baseEntry.message,\n context: msg.context,\n comment: msg.comment,\n origin,\n obsolete: false,\n }\n unchanged++\n } else if (catalog[msg.id]) {\n // Same ID already seen in this extraction batch — merge origin\n const existing = catalog[msg.id]!\n catalog[msg.id] = {\n ...existing,\n origin: mergeOrigins(existing.origin, origin),\n }\n } else {\n catalog[msg.id] = {\n message: msg.message,\n context: msg.context,\n comment: msg.comment,\n origin,\n }\n added++\n }\n\n if (options?.stripFuzzy) {\n const { fuzzy: _fuzzy, ...rest } = catalog[msg.id]!\n catalog[msg.id] = rest\n }\n }\n\n for (const [id, entry] of Object.entries(existing)) {\n if (!extractedIds.has(id)) {\n const { fuzzy: _fuzzy, ...rest } = entry\n const obsoleteEntry = options?.stripFuzzy\n ? { ...rest, obsolete: true }\n : { ...entry, obsolete: true }\n catalog[id] = obsoleteEntry\n obsolete++\n }\n }\n\n return { catalog, result: { added, unchanged, obsolete } }\n}\n\nfunction mergeOrigins(\n existing: string | string[] | undefined,\n newOrigin: string,\n): string | string[] {\n if (!existing) return newOrigin\n const existingArray = Array.isArray(existing) ? existing : [existing]\n const merged = [...new Set([...existingArray, newOrigin])]\n return merged.length === 1 ? merged[0]! : merged\n}\n\nfunction findCarryForwardEntry(\n existing: CatalogData,\n extracted: ExtractedMessage,\n consumedCarryForwardIds: Set<string>,\n): { id: string; entry: CatalogEntry } | undefined {\n if (!extracted.context) {\n return undefined\n }\n\n const extractedOrigin = `${extracted.origin.file}:${extracted.origin.line}`\n for (const [id, entry] of Object.entries(existing)) {\n if (consumedCarryForwardIds.has(id)) continue\n if (entry.context !== undefined) continue\n if (entry.message !== extracted.message) continue\n if (!sameOrigin(entry.origin, extractedOrigin)) continue\n return { id, entry }\n }\n\n return undefined\n}\n\nfunction sameOrigin(previous: string | string[] | undefined, next: string): boolean {\n if (!previous) return false\n const origins = Array.isArray(previous) ? previous : [previous]\n return origins.some((o) => o === next || originFile(o) === originFile(next))\n}\n\nfunction originFile(origin: string): string {\n const match = origin.match(/^(.*):\\d+$/)\n return match?.[1] ?? origin\n}\n","import type { CatalogData } from './catalog'\n\n/** Read a JSON catalog file */\nexport function readJsonCatalog(content: string): CatalogData {\n const raw = JSON.parse(content) as Record<string, unknown>\n const catalog: CatalogData = {}\n\n for (const [id, entry] of Object.entries(raw)) {\n if (typeof entry === 'object' && entry !== null) {\n const e = entry as Record<string, unknown>\n catalog[id] = {\n message: typeof e['message'] === 'string' ? e['message'] : undefined,\n context: typeof e['context'] === 'string' ? e['context'] : undefined,\n comment: typeof e['comment'] === 'string' ? e['comment'] : undefined,\n translation: typeof e['translation'] === 'string' ? e['translation'] : undefined,\n origin: typeof e['origin'] === 'string'\n ? e['origin']\n : Array.isArray(e['origin']) && (e['origin'] as unknown[]).every((v) => typeof v === 'string')\n ? (e['origin'] as string[])\n : undefined,\n obsolete: typeof e['obsolete'] === 'boolean' ? e['obsolete'] : undefined,\n fuzzy: typeof e['fuzzy'] === 'boolean' ? e['fuzzy'] : undefined,\n }\n }\n }\n\n return catalog\n}\n\n/** Write a catalog to JSON format */\nexport function writeJsonCatalog(catalog: CatalogData): string {\n const output: Record<string, Record<string, unknown>> = {}\n\n for (const [id, entry] of Object.entries(catalog)) {\n const obj: Record<string, unknown> = {}\n if (entry.message !== undefined) obj['message'] = entry.message\n if (entry.context !== undefined) obj['context'] = entry.context\n if (entry.comment !== undefined) obj['comment'] = entry.comment\n if (entry.translation !== undefined) obj['translation'] = entry.translation\n if (entry.origin !== undefined) obj['origin'] = entry.origin\n if (entry.obsolete) obj['obsolete'] = true\n if (entry.fuzzy) obj['fuzzy'] = true\n output[id] = obj\n }\n\n return JSON.stringify(output, null, 2) + '\\n'\n}\n","import type { CatalogData } from './catalog'\nimport { hashMessage } from '@fluenti/core/internal'\nimport * as gettextParser from 'gettext-parser'\n\nconst CUSTOM_ID_MARKER = 'fluenti-id:'\n\ninterface POTranslation {\n msgid: string\n msgctxt?: string\n msgstr: string[]\n comments?: {\n reference?: string\n extracted?: string\n flag?: string\n translator?: string\n previous?: string\n }\n}\n\ninterface POData {\n headers?: Record<string, string>\n translations: Record<string, Record<string, POTranslation>>\n obsolete?: Record<string, Record<string, POTranslation>>\n}\n\ninterface ParsedExtractedComment {\n comment?: string\n customId?: string\n sourceMessage?: string\n}\n\nfunction processPoEntries(\n contextMap: Record<string, Record<string, POTranslation>>,\n catalog: CatalogData,\n isObsolete: boolean,\n): void {\n for (const [contextKey, entries] of Object.entries(contextMap)) {\n for (const [msgid, entry] of Object.entries(entries)) {\n if (!msgid) continue\n\n const context = contextKey || entry.msgctxt || undefined\n const translation = entry.msgstr?.[0] ?? undefined\n const rawReference = entry.comments?.reference ?? undefined\n const origin = rawReference?.includes('\\n')\n ? rawReference.split('\\n').map((r: string) => r.trim()).filter(Boolean)\n : rawReference?.includes(' ')\n ? rawReference.split(/\\s+/).filter(Boolean)\n : rawReference\n const normalizedOrigin = Array.isArray(origin) && origin.length === 1 ? origin[0] : origin\n const isFuzzy = !isObsolete && (entry.comments?.flag?.includes('fuzzy') ?? false)\n const { comment, customId, sourceMessage } = parseExtractedComment(entry.comments?.extracted)\n // When a custom ID is present, the msgid may be the custom key (not source text),\n // so accept sourceMessage directly without requiring a hash match.\n // For hash-ID entries (no customId), verify the hash to prevent double-hashing.\n const resolvedSourceMessage = sourceMessage\n && (customId !== undefined || hashMessage(sourceMessage, context) === msgid)\n ? sourceMessage\n : undefined\n const id = customId\n ?? (resolvedSourceMessage ? msgid : hashMessage(msgid, context))\n\n catalog[id] = {\n message: resolvedSourceMessage ?? msgid,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n ...(translation ? { translation } : {}),\n ...(normalizedOrigin !== undefined ? { origin: normalizedOrigin } : {}),\n ...(isFuzzy ? { fuzzy: true } : {}),\n ...(isObsolete ? { obsolete: true } : {}),\n }\n }\n }\n}\n\n/** Read a PO catalog file */\nexport function readPoCatalog(content: string): CatalogData {\n const po = gettextParser.po.parse(content) as POData\n const catalog: CatalogData = {}\n\n processPoEntries(po.translations ?? {}, catalog, false)\n if (po.obsolete) {\n processPoEntries(po.obsolete, catalog, true)\n }\n\n return catalog\n}\n\n/** Write a catalog to PO format */\nexport function writePoCatalog(catalog: CatalogData): string {\n const translations: POData['translations'] = {\n '': {\n '': {\n msgid: '',\n msgstr: ['Content-Type: text/plain; charset=UTF-8\\n'],\n },\n },\n }\n const obsolete: POData['obsolete'] = {}\n\n for (const [id, entry] of Object.entries(catalog)) {\n // Use custom ID as msgid for non-hash entries to prevent collision when two\n // entries share the same source message but have different custom IDs.\n // Hash-ID entries keep source message as msgid (PO-friendly for translators).\n const isHashId = entry.message !== undefined && hashMessage(entry.message, entry.context) === id\n const msgid = isHashId ? (entry.message ?? id) : id\n const poEntry: POTranslation = {\n msgid,\n ...(entry.context !== undefined ? { msgctxt: entry.context } : {}),\n msgstr: [entry.translation ?? ''],\n }\n\n const comments: POTranslation['comments'] = {}\n if (entry.origin && !entry.obsolete) {\n comments.reference = Array.isArray(entry.origin)\n ? entry.origin.join('\\n')\n : entry.origin\n }\n const extractedComment = buildExtractedComment(id, entry.message ?? id, entry.context, entry.comment)\n if (extractedComment) {\n comments.extracted = extractedComment\n }\n if (entry.fuzzy && !entry.obsolete) {\n comments.flag = 'fuzzy'\n }\n if (comments.reference || comments.extracted || comments.flag) {\n poEntry.comments = comments\n }\n\n if (entry.obsolete) {\n const contextKey = entry.context ?? ''\n obsolete[contextKey] ??= {}\n obsolete[contextKey]![poEntry.msgid] = poEntry\n } else {\n const contextKey = entry.context ?? ''\n translations[contextKey] ??= {}\n translations[contextKey]![poEntry.msgid] = poEntry\n }\n }\n\n const poData: POData = {\n headers: {\n 'Content-Type': 'text/plain; charset=UTF-8',\n },\n translations,\n ...(Object.keys(obsolete).length > 0 ? { obsolete } : {}),\n }\n\n const buffer = gettextParser.po.compile(poData as Parameters<typeof gettextParser.po.compile>[0])\n return buffer.toString()\n}\n\nfunction parseExtractedComment(\n extracted: string | undefined,\n): ParsedExtractedComment {\n if (!extracted) {\n return {}\n }\n\n const lines = extracted.split('\\n').map((line) => line.trim()).filter(Boolean)\n let customId: string | undefined\n let sourceMessage: string | undefined\n const commentLines: string[] = []\n\n for (const line of lines) {\n if (line.startsWith(CUSTOM_ID_MARKER)) {\n customId = line.slice(CUSTOM_ID_MARKER.length).trim() || undefined\n continue\n }\n if (line.startsWith('msg`') && line.endsWith('`')) {\n sourceMessage = line.slice(4, -1)\n continue\n }\n if (line.startsWith('Trans: ')) {\n sourceMessage = normalizeRichTextComment(line.slice('Trans: '.length))\n continue\n }\n commentLines.push(line)\n }\n\n return {\n ...(commentLines.length > 0 ? { comment: commentLines.join('\\n') } : {}),\n ...(customId ? { customId } : {}),\n ...(sourceMessage ? { sourceMessage } : {}),\n }\n}\n\nfunction normalizeRichTextComment(comment: string): string {\n let stack: Array<{ tag: string; index: number }> = []\n let nextIndex = 0\n\n return comment.replace(/<\\/?([a-zA-Z][\\w-]*)>/g, (match, rawTag: string) => {\n const tag = rawTag\n if (match.startsWith('</')) {\n for (let index = stack.length - 1; index >= 0; index--) {\n const entry = stack[index]\n if (entry?.tag !== tag) continue\n stack = stack.filter((_, i) => i !== index)\n return `</${entry.index}>`\n }\n return match\n }\n\n const index = nextIndex++\n stack.push({ tag, index })\n return `<${index}>`\n })\n}\n\nfunction buildExtractedComment(\n id: string,\n message: string,\n context: string | undefined,\n comment: string | undefined,\n): string | undefined {\n const lines: string[] = []\n\n if (comment) {\n lines.push(comment)\n }\n\n if (id !== hashMessage(message, context)) {\n lines.push(`${CUSTOM_ID_MARKER} ${id}`)\n // Preserve source message so round-trip works when msgid is the custom ID (not source text)\n lines.push(`msg\\`${message}\\``)\n }\n\n return lines.length > 0 ? lines.join('\\n') : undefined\n}\n","import { Worker } from 'node:worker_threads'\nimport { availableParallelism } from 'node:os'\nimport { existsSync } from 'node:fs'\nimport { resolve, dirname } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport type { CatalogData } from './catalog'\nimport type { CompileOptions, CompileStats } from './compile'\nimport type { CompileWorkerRequest, CompileWorkerResponse } from './compile-worker'\n\nexport interface ParallelCompileTask {\n locale: string\n catalog: CatalogData\n allIds: string[]\n sourceLocale: string\n options?: CompileOptions\n}\n\nexport interface ParallelCompileResult {\n locale: string\n code: string\n stats: CompileStats\n}\n\n/** Default timeout per worker in milliseconds (30 seconds) */\nconst WORKER_TIMEOUT_MS = 30_000\n\nfunction getWorkerPath(): string {\n const thisDir = typeof __dirname !== 'undefined'\n ? __dirname\n : dirname(fileURLToPath(import.meta.url))\n return resolve(thisDir, 'compile-worker.js')\n}\n\n/**\n * Compile multiple locales in parallel using worker threads.\n *\n * - Single task → returns result directly (no worker overhead)\n * - Multiple tasks → spawns min(tasks, availableParallelism()) workers\n * - Workers are created per-call and destroyed after completion\n *\n * Falls back to in-process compilation when the compiled worker is unavailable\n * (e.g. when running from TypeScript source in development/tests).\n */\nexport async function parallelCompile(\n tasks: ParallelCompileTask[],\n concurrency?: number,\n): Promise<ParallelCompileResult[]> {\n if (tasks.length === 0) return []\n\n // Single task: compile in-process, no worker overhead\n if (tasks.length === 1) {\n const { compileCatalog } = await import('./compile')\n const task = tasks[0]!\n const { code, stats } = compileCatalog(task.catalog, task.locale, task.allIds, task.sourceLocale, task.options)\n return [{ locale: task.locale, code, stats }]\n }\n\n const workerPath = getWorkerPath()\n\n // If compiled worker doesn't exist (dev/test), fall back to concurrent in-process compilation\n if (!existsSync(workerPath)) {\n return inProcessParallelCompile(tasks)\n }\n\n const maxWorkers = concurrency ?? Math.min(tasks.length, availableParallelism())\n const results: ParallelCompileResult[] = []\n const queue = [...tasks]\n let rejected = false\n\n return new Promise<ParallelCompileResult[]>((resolveAll, rejectAll) => {\n let activeWorkers = 0\n\n function spawnNext(): void {\n if (rejected) return\n const task = queue.shift()\n if (!task) {\n if (activeWorkers === 0) {\n resolveAll(results)\n }\n return\n }\n\n activeWorkers++\n const worker = new Worker(workerPath)\n\n const timer = setTimeout(() => {\n if (!rejected) {\n rejected = true\n activeWorkers--\n worker.terminate()\n rejectAll(new Error(`Worker timed out after ${WORKER_TIMEOUT_MS}ms compiling locale \"${task.locale}\"`))\n }\n }, WORKER_TIMEOUT_MS)\n\n worker.on('message', (response: CompileWorkerResponse) => {\n clearTimeout(timer)\n if (rejected) return\n if (response.error) {\n rejected = true\n activeWorkers--\n worker.terminate()\n rejectAll(new Error(`Failed to compile locale \"${response.locale}\": ${response.error}`))\n return\n }\n results.push({\n locale: response.locale,\n code: response.code,\n stats: response.stats,\n })\n activeWorkers--\n worker.terminate()\n spawnNext()\n })\n\n worker.on('error', (err: Error) => {\n clearTimeout(timer)\n if (!rejected) {\n rejected = true\n worker.terminate()\n rejectAll(new Error(`Worker error compiling locale \"${task.locale}\": ${err.message}`))\n }\n })\n\n worker.on('exit', (code) => {\n clearTimeout(timer)\n if (code !== 0 && !rejected) {\n rejected = true\n rejectAll(new Error(`Worker exited with code ${code} while compiling locale \"${task.locale}\"`))\n }\n })\n\n const request: CompileWorkerRequest = {\n locale: task.locale,\n catalog: task.catalog,\n allIds: task.allIds,\n sourceLocale: task.sourceLocale,\n options: task.options,\n }\n worker.postMessage(request)\n }\n\n // Start initial batch of workers\n const initialBatch = Math.min(maxWorkers, queue.length)\n for (let i = 0; i < initialBatch; i++) {\n spawnNext()\n }\n })\n}\n\n/**\n * In-process fallback for parallel compilation.\n * Uses Promise.all for concurrency when workers are unavailable.\n */\nasync function inProcessParallelCompile(\n tasks: ParallelCompileTask[],\n): Promise<ParallelCompileResult[]> {\n const { compileCatalog } = await import('./compile')\n return Promise.all(\n tasks.map((task) => {\n const { code, stats } = compileCatalog(task.catalog, task.locale, task.allIds, task.sourceLocale, task.options)\n return { locale: task.locale, code, stats }\n }),\n )\n}\n","import { readFileSync, writeFileSync, existsSync, mkdirSync, statSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\nimport type { ExtractedMessage } from '@fluenti/core/internal'\n\n/** Cache format version — bump when the structure changes */\nconst CACHE_VERSION = '1'\n\ninterface ExtractCacheEntry {\n mtime: number\n size: number\n messages: ExtractedMessage[]\n}\n\ninterface ExtractCacheData {\n version: string\n entries: Record<string, ExtractCacheEntry>\n}\n\n/**\n * File-level extract cache that skips re-extraction for unchanged files.\n *\n * Cache is keyed by file path, with mtime + size as change detection.\n */\nexport class ExtractCache {\n private data: ExtractCacheData\n private cachePath: string\n private dirty = false\n\n constructor(catalogDir: string, projectId?: string) {\n const cacheDir = projectId\n ? resolve(catalogDir, '.cache', projectId)\n : resolve(catalogDir, '.cache')\n this.cachePath = resolve(cacheDir, 'extract-cache.json')\n this.data = this.load()\n }\n\n /**\n * Check if a file has changed since the last extraction.\n * Returns cached messages if unchanged, undefined if re-extraction needed.\n */\n get(filePath: string): ExtractedMessage[] | undefined {\n const entry = this.data.entries[filePath]\n if (!entry) return undefined\n\n try {\n const stat = statSync(filePath)\n if (stat.mtimeMs === entry.mtime && stat.size === entry.size) {\n return entry.messages\n }\n } catch {\n // File no longer exists or can't be stat'd — cache miss\n }\n\n return undefined\n }\n\n /**\n * Update the cache for a file after extraction.\n */\n set(filePath: string, messages: ExtractedMessage[]): void {\n try {\n const stat = statSync(filePath)\n this.data.entries[filePath] = {\n mtime: stat.mtimeMs,\n size: stat.size,\n messages,\n }\n this.dirty = true\n } catch {\n // File doesn't exist — skip caching\n }\n }\n\n /**\n * Remove entries for files that no longer exist in the file list.\n */\n prune(currentFiles: Set<string>): void {\n for (const filePath of Object.keys(this.data.entries)) {\n if (!currentFiles.has(filePath)) {\n delete this.data.entries[filePath]\n this.dirty = true\n }\n }\n }\n\n /**\n * Write the cache to disk if any changes were made.\n */\n save(): void {\n if (!this.dirty) return\n\n try {\n mkdirSync(dirname(this.cachePath), { recursive: true })\n writeFileSync(this.cachePath, JSON.stringify(this.data), 'utf-8')\n this.dirty = false\n } catch {\n // Cache write failure is non-fatal — next run will re-extract\n }\n }\n\n /** Number of cached entries */\n get size(): number {\n return Object.keys(this.data.entries).length\n }\n\n private load(): ExtractCacheData {\n try {\n if (existsSync(this.cachePath)) {\n const raw = readFileSync(this.cachePath, 'utf-8')\n const parsed = JSON.parse(raw) as ExtractCacheData\n if (parsed.version === CACHE_VERSION) {\n return parsed\n }\n }\n } catch {\n // Corrupt or unreadable cache — start fresh\n }\n\n return { version: CACHE_VERSION, entries: {} }\n }\n}\n"],"mappings":"6zBAyBA,SAAgB,EACd,EACA,EACA,EACgD,CAChD,IAAM,EAAe,IAAI,IAAI,EAAU,IAAK,GAAM,EAAE,GAAG,CAAC,CAClD,EAA0B,IAAI,IAC9B,EAAuB,EAAE,CAC3B,EAAQ,EACR,EAAY,EACZ,EAAW,EAEf,IAAK,IAAM,KAAO,EAAW,CAC3B,IAAM,EAAgB,EAAS,EAAI,IAC7B,EAAU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