@let-value/translate-extract 1.1.2-beta.1 → 1.1.2-beta.2
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/bin/cli.cjs +3 -5
- package/dist/bin/cli.js +3 -5
- package/dist/bin/cli.js.map +1 -1
- package/dist/{run-Dc4eZUPV.js → run-BLCu6sdK.js} +11 -10
- package/dist/run-BLCu6sdK.js.map +1 -0
- package/dist/{run-BvhgGiZE.cjs → run-DOVU7XA7.cjs} +11 -10
- package/dist/src/index.cjs +1 -1
- package/dist/src/index.d.cts.map +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -1
- package/package.json +2 -2
- package/dist/run-Dc4eZUPV.js.map +0 -1
package/dist/bin/cli.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
const require_chunk = require('../chunk-CUT6urMc.cjs');
|
|
3
|
-
const require_run = require('../run-
|
|
3
|
+
const require_run = require('../run-DOVU7XA7.cjs');
|
|
4
4
|
let node_util = require("node:util");
|
|
5
5
|
node_util = require_chunk.__toESM(node_util);
|
|
6
6
|
let cosmiconfig = require("cosmiconfig");
|
|
@@ -74,12 +74,10 @@ async function main() {
|
|
|
74
74
|
logLevel: effectiveLogLevel
|
|
75
75
|
};
|
|
76
76
|
logger.setLevel(effectiveLogLevel);
|
|
77
|
-
const
|
|
78
|
-
for (const entrypoint of config.entrypoints) tasks.push(require_run.run(entrypoint, {
|
|
77
|
+
for (const entrypoint of config.entrypoints) await require_run.run(entrypoint, {
|
|
79
78
|
config,
|
|
80
79
|
logger
|
|
81
|
-
})
|
|
82
|
-
await Promise.all(tasks);
|
|
80
|
+
});
|
|
83
81
|
}
|
|
84
82
|
main().catch((err) => {
|
|
85
83
|
logger.error(err);
|
package/dist/bin/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { run } from "../run-
|
|
2
|
+
import { run } from "../run-BLCu6sdK.js";
|
|
3
3
|
import { parseArgs } from "node:util";
|
|
4
4
|
import { cosmiconfig } from "cosmiconfig";
|
|
5
5
|
import chalk from "chalk";
|
|
@@ -68,12 +68,10 @@ async function main() {
|
|
|
68
68
|
logLevel: effectiveLogLevel
|
|
69
69
|
};
|
|
70
70
|
logger.setLevel(effectiveLogLevel);
|
|
71
|
-
const
|
|
72
|
-
for (const entrypoint of config.entrypoints) tasks.push(run(entrypoint, {
|
|
71
|
+
for (const entrypoint of config.entrypoints) await run(entrypoint, {
|
|
73
72
|
config,
|
|
74
73
|
logger
|
|
75
|
-
})
|
|
76
|
-
await Promise.all(tasks);
|
|
74
|
+
});
|
|
77
75
|
}
|
|
78
76
|
main().catch((err) => {
|
|
79
77
|
logger.error(err);
|
package/dist/bin/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","names":["colors: Record<LogLevel, ChalkInstance>","defaultLogLevel: LogLevel","config: ResolvedConfig"
|
|
1
|
+
{"version":3,"file":"cli.js","names":["colors: Record<LogLevel, ChalkInstance>","defaultLogLevel: LogLevel","config: ResolvedConfig"],"sources":["../../src/logger.ts","../../bin/cli.ts"],"sourcesContent":["import chalk, { type ChalkInstance } from \"chalk\";\nimport log from \"loglevel\";\nimport prefix from \"loglevel-plugin-prefix\";\n\nexport type Logger = log.Logger;\nexport type LogLevelNames = log.LogLevelNames;\nexport type LogLevel = LogLevelNames;\n\nconst colors: Record<LogLevel, ChalkInstance> = {\n trace: chalk.magenta,\n debug: chalk.cyan,\n info: chalk.blue,\n warn: chalk.yellow,\n error: chalk.red,\n};\n\nprefix.reg(log);\nprefix.apply(log, {\n format(level, name) {\n const color = colors[level as LogLevelNames] ?? ((value: string) => value);\n const scope = name ? ` ${chalk.green(`${name}:`)}` : \"\";\n\n return `${color(level)}${scope}`;\n },\n});\n\nexport const logger = log;\n","#!/usr/bin/env node\n\nimport { parseArgs } from \"node:util\";\nimport { cosmiconfig } from \"cosmiconfig\";\nimport type { ResolvedConfig } from \"../src/configuration.ts\";\nimport { type LogLevel, logger } from \"../src/logger.ts\";\nimport { run } from \"../src/run.ts\";\n\nconst moduleName = \"translate\";\nconst defaultLogLevel: LogLevel = \"info\";\n\nfunction unwrapConfig(\n config: ResolvedConfig | { default: ResolvedConfig } | { translateConfig: ResolvedConfig } | undefined,\n) {\n if (config && typeof config === \"object\" && \"default\" in config) {\n return config.default;\n }\n\n if (config && typeof config === \"object\" && \"translateConfig\" in config) {\n return config.translateConfig;\n }\n\n return config;\n}\n\nasync function main() {\n const {\n values: { logLevel },\n } = parseArgs({\n args: process.argv.slice(2),\n options: {\n logLevel: { type: \"string\", short: \"l\" },\n },\n });\n\n const explorer = cosmiconfig(moduleName, {\n searchPlaces: [\n `.${moduleName}rc.js`,\n `.${moduleName}rc.ts`,\n `.${moduleName}rc.mjs`,\n `.${moduleName}rc.cjs`,\n `.config/${moduleName}rc.js`,\n `.config/${moduleName}rc.ts`,\n `.config/${moduleName}rc.mjs`,\n `.config/${moduleName}rc.cjs`,\n `${moduleName}.config.js`,\n `${moduleName}.config.ts`,\n `${moduleName}.config.mjs`,\n `${moduleName}.config.cjs`,\n ],\n });\n\n const result = await explorer.search();\n if (!result || !result.config) {\n logger.error(\"No configuration file found\");\n process.exit(1);\n }\n\n const resolvedConfig = unwrapConfig(result.config);\n if (!resolvedConfig) {\n logger.error(\"Invalid configuration file\");\n process.exit(1);\n }\n\n const effectiveLogLevel = (logLevel as LogLevel | undefined) ?? resolvedConfig.logLevel ?? defaultLogLevel;\n const config: ResolvedConfig = {\n ...resolvedConfig,\n logLevel: effectiveLogLevel,\n };\n logger.setLevel(effectiveLogLevel);\n\n for (const entrypoint of config.entrypoints) {\n await run(entrypoint, { config, logger });\n }\n}\n\nvoid main().catch((err) => {\n logger.error(err);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;AAQA,MAAMA,SAA0C;CAC5C,OAAO,MAAM;CAC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,YAAY;CAC3F,MAAMC,SAAyB;EAC3B,GAAG;EACH,UAAU;EACb;AACD,QAAO,SAAS,kBAAkB;AAElC,MAAK,MAAM,cAAc,OAAO,YAC5B,OAAM,IAAI,YAAY;EAAE;EAAQ;EAAQ,CAAC;;AAI5C,MAAM,CAAC,OAAO,QAAQ;AACvB,QAAO,MAAM,IAAI;AACjB,SAAQ,KAAK,EAAE;EACjB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isDeepStrictEqual } from "node:util";
|
|
2
|
+
import path, { dirname, extname, join, relative, resolve } from "node:path";
|
|
2
3
|
import glob from "fast-glob";
|
|
3
4
|
import fs, { readFile } from "node:fs/promises";
|
|
4
|
-
import path, { dirname, extname, join, relative, resolve } from "node:path";
|
|
5
5
|
import * as gettextParser from "gettext-parser";
|
|
6
6
|
import fs$1 from "node:fs";
|
|
7
7
|
import Parser from "@keqingmoe/tree-sitter";
|
|
@@ -699,7 +699,7 @@ function core() {
|
|
|
699
699
|
//#region src/plugins/po/collect.ts
|
|
700
700
|
function collect(source, locale) {
|
|
701
701
|
const translations = { "": {} };
|
|
702
|
-
const nplurals = locale ? getNPlurals(locale) : void 0;
|
|
702
|
+
const nplurals = locale ? Number(getNPlurals(locale)) : void 0;
|
|
703
703
|
for (const { context, id, message, comments, obsolete, plural } of source) {
|
|
704
704
|
const ctx = context || "";
|
|
705
705
|
if (!translations[ctx]) translations[ctx] = {};
|
|
@@ -788,7 +788,7 @@ function merge(sources, existing, obsolete, locale, generatedAt) {
|
|
|
788
788
|
let headers = {};
|
|
789
789
|
let translations = { "": {} };
|
|
790
790
|
let obsoleteTranslations = {};
|
|
791
|
-
const nplurals = getNPlurals(locale);
|
|
791
|
+
const nplurals = Number(getNPlurals(locale));
|
|
792
792
|
if (existing) {
|
|
793
793
|
headers = existing.headers ? structuredClone(existing.headers) : {};
|
|
794
794
|
translations = existing.translations ? structuredClone(existing.translations) : { "": {} };
|
|
@@ -1302,7 +1302,7 @@ function resolveStaticPlugin(item) {
|
|
|
1302
1302
|
async function getPaths(entrypoint) {
|
|
1303
1303
|
const pattern = entrypoint.entrypoint.replace(/\\/g, "/");
|
|
1304
1304
|
const paths = glob.isDynamicPattern(pattern) ? await glob(pattern, { onlyFiles: true }) : [entrypoint.entrypoint];
|
|
1305
|
-
return new Set(paths);
|
|
1305
|
+
return new Set(paths.map((path$1) => resolve(path$1)));
|
|
1306
1306
|
}
|
|
1307
1307
|
async function run(entrypoint, { config, logger }) {
|
|
1308
1308
|
const destination = entrypoint.destination ?? config.destination;
|
|
@@ -1345,15 +1345,16 @@ async function run(entrypoint, { config, logger }) {
|
|
|
1345
1345
|
return getDeferred(namespace$3).promise;
|
|
1346
1346
|
}
|
|
1347
1347
|
function source(path$1) {
|
|
1348
|
-
|
|
1348
|
+
const resolvedPath = resolve(path$1);
|
|
1349
|
+
if (paths.has(resolvedPath)) return;
|
|
1349
1350
|
logger?.debug({
|
|
1350
1351
|
entrypoint: entrypoint.entrypoint,
|
|
1351
|
-
path:
|
|
1352
|
+
path: resolvedPath
|
|
1352
1353
|
}, "resolved path");
|
|
1353
|
-
paths.add(
|
|
1354
|
+
paths.add(resolvedPath);
|
|
1354
1355
|
resolve$1({
|
|
1355
|
-
entrypoint:
|
|
1356
|
-
path:
|
|
1356
|
+
entrypoint: resolvedPath,
|
|
1357
|
+
path: resolvedPath,
|
|
1357
1358
|
namespace: "source"
|
|
1358
1359
|
});
|
|
1359
1360
|
}
|
|
@@ -1467,4 +1468,4 @@ async function run(entrypoint, { config, logger }) {
|
|
|
1467
1468
|
|
|
1468
1469
|
//#endregion
|
|
1469
1470
|
export { cleanup, core, po, react, run };
|
|
1470
|
-
//# sourceMappingURL=run-
|
|
1471
|
+
//# sourceMappingURL=run-BLCu6sdK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-BLCu6sdK.js","names":["namespace","path","path","entrypointQuery: EntrypointSpec","importQuery: ImportQuerySpec","current: Parser.SyntaxNode | null","messageQuery: QuerySpec","allowed","messageInvalidQuery: QuerySpec","ids: string[]","strs: string[]","subMatch: Parser.QueryMatch","translation: Translation","contextMsgQuery: QuerySpec","msgCall","contextPluralQuery: QuerySpec","contextInvalidQuery: QuerySpec","gettextQuery: QuerySpec","gettextInvalidQuery: QuerySpec","msgCall","plainMsg","msgArg","ngettextQuery: QuerySpec","msgCall","npgettextQuery: QuerySpec","pgettextQuery: QuerySpec","pluralQuery: QuerySpec","queries: QuerySpec[]","messageQuery","pluralQuery","path","parseSource","context: Context","translations: Translation[]","warnings: Warning[]","imports: string[]","queries","fs","resolved: string[]","filter","namespace","path","parseSource","translations: GetTextTranslationRecord","value","normalizedHeaders: Record<string, string>","headers: Record<string, string>","translations: GetTextTranslationRecord","obsoleteTranslations: GetTextTranslationRecord","collected: GetTextTranslationRecord","translations","existing","path","parts: Part[]","text","strings: string[]","values: string[]","messageQuery: QuerySpec","attrs: Parser.SyntaxNode[]","msgctxt: string | undefined","childValue: Parser.SyntaxNode | undefined","error: string | undefined","translation: Translation","forms: string[]","pluralQuery: QuerySpec","attrs: Parser.SyntaxNode[]","msgctxt: string | undefined","formsNode: Parser.SyntaxNode | null | undefined","translation: Translation","queries: QuerySpec[]","context: Context","path","translations: Translation[]","warnings: Warning[]","path","resolvePath","path","context: Context","resolvers: { filter: Filter; hook: ResolveHook }[]","loaders: { filter: Filter; hook: LoadHook }[]","processors: { filter: Filter; hook: ProcessHook }[]","queue: Task[]","defer","namespace","resolve","process","build: Build","filter"],"sources":["../src/defer.ts","../src/plugins/cleanup/cleanup.ts","../src/plugins/core/queries/comment.ts","../src/plugins/core/queries/entrypoint.ts","../src/plugins/core/queries/import.ts","../src/plugins/core/queries/utils.ts","../src/plugins/core/queries/message.ts","../src/plugins/core/queries/plural-utils.ts","../src/plugins/core/queries/context.ts","../src/plugins/core/queries/gettext.ts","../src/plugins/core/queries/ngettext.ts","../src/plugins/core/queries/npgettext.ts","../src/plugins/core/queries/pgettext.ts","../src/plugins/core/queries/plural.ts","../src/plugins/core/queries/index.ts","../src/plugins/core/parse.ts","../src/plugins/core/resolve.ts","../src/plugins/core/core.ts","../src/plugins/po/collect.ts","../src/plugins/po/hasChanges.ts","../src/plugins/po/merge.ts","../src/plugins/po/po.ts","../src/plugins/react/queries/utils.ts","../src/plugins/react/queries/message.ts","../src/plugins/react/queries/plural.ts","../src/plugins/react/queries/index.ts","../src/plugins/react/parse.ts","../src/plugins/react/react.ts","../src/plugins/static.ts","../src/run.ts"],"sourcesContent":["export class Defer {\n pending = 0;\n promise: Promise<void> = Promise.resolve();\n resolve?: () => void;\n\n enqueue() {\n if (this.pending++ === 0) {\n this.promise = new Promise<void>((res) => {\n this.resolve = res;\n });\n }\n }\n dequeue() {\n if (this.pending > 0 && --this.pending === 0) {\n this.resolve?.();\n }\n }\n}\n","import fs from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\n\nimport * as gettextParser from \"gettext-parser\";\n\nimport type { Plugin } from \"../../plugin.ts\";\n\nconst namespace = \"cleanup\";\n\nexport function cleanup(): Plugin {\n return {\n name: \"cleanup\",\n setup(build) {\n build.context.logger?.debug(\"cleanup plugin initialized\");\n const processed = new Set<string>();\n const generated = new Set<string>();\n const dirs = new Set<string>();\n let dispatched = false;\n\n build.onResolve({ namespace, filter: /.*/ }, ({ path }) => {\n generated.add(path);\n dirs.add(dirname(path));\n\n Promise.all([build.defer(\"source\"), build.defer(\"translate\"), build.defer(namespace)]).then(() => {\n if (dispatched) {\n return;\n }\n dispatched = true;\n\n for (const path of dirs.values()) {\n build.process({ entrypoint: path, path, namespace, data: undefined });\n }\n });\n\n return undefined;\n });\n\n build.onProcess({ namespace, filter: /.*/ }, async ({ path }) => {\n if (processed.has(path)) {\n return undefined;\n }\n processed.add(path);\n const files = await fs.readdir(path).catch(() => []);\n for (const f of files.filter((p) => p.endsWith(\".po\"))) {\n const full = join(path, f);\n const contents = await fs.readFile(full).catch(() => undefined);\n if (!contents) {\n continue;\n }\n const parsed = gettextParser.po.parse(contents);\n const hasTranslations = Object.entries(parsed.translations || {}).some(([ctx, msgs]) =>\n Object.keys(msgs).some((id) => !(ctx === \"\" && id === \"\")),\n );\n if (!hasTranslations && generated.has(full)) {\n await fs.unlink(full);\n }\n if (hasTranslations && !generated.has(full)) {\n build.context.logger?.warn({ path: full }, \"stray translation file\");\n }\n }\n return undefined;\n });\n },\n };\n}\n","import { relative } from \"node:path\";\nimport type Parser from \"@keqingmoe/tree-sitter\";\n\nimport type { Context, QuerySpec } from \"./types.ts\";\n\nexport function getReference(node: Parser.SyntaxNode, { path }: Context) {\n const line = node.startPosition.row + 1;\n const rel = relative(process.cwd(), path).replace(/\\\\+/g, \"/\");\n return `${rel}:${line}`;\n}\n\nexport function getComment(node: Parser.SyntaxNode): string {\n const text = node.text;\n if (text.startsWith(\"/*\")) {\n return text\n .slice(2, -2)\n .replace(/^\\s*\\*?\\s*/gm, \"\")\n .trim();\n }\n return text.replace(/^\\/\\/\\s?/, \"\").trim();\n}\n\nexport const withComment = (query: QuerySpec): QuerySpec => ({\n pattern: `(\n\t((comment) @comment)?\n .\n\t(_ ${query.pattern})\n)`,\n extract(match) {\n const result = query.extract(match);\n if (!result?.translation) {\n return result;\n }\n\n const comment = match.captures.find((c) => c.name === \"comment\")?.node;\n if (!comment) {\n return result;\n }\n\n if (comment) {\n result.translation.comments = {\n ...result.translation.comments,\n extracted: getComment(comment),\n };\n }\n\n return result;\n },\n});\n","import type Parser from \"@keqingmoe/tree-sitter\";\nimport { getComment } from \"./comment.ts\";\nimport type { EntrypointSpec } from \"./types.ts\";\n\nconst entrypointCommentPattern = /(?:^|\\s)@?translate-entrypoint(?:\\s|$)/;\n\nexport const entrypointQuery: EntrypointSpec = {\n pattern: `(comment) @comment`,\n extract(match: Parser.QueryMatch): boolean | undefined {\n return match.captures\n .filter((capture) => capture.name === \"comment\")\n .some((capture) => entrypointCommentPattern.test(getComment(capture.node)));\n },\n};\n","import type Parser from \"@keqingmoe/tree-sitter\";\nimport type { ImportQuerySpec } from \"./types.ts\";\n\nexport const importQuery: ImportQuerySpec = {\n pattern: `\n [\n (import_statement\n source: (string (string_fragment) @import))\n (export_statement\n source: (string (string_fragment) @import))\n (call_expression\n function: (identifier) @func\n arguments: (arguments (string (string_fragment) @import))\n (#eq? @func \"require\"))\n (call_expression\n function: (member_expression\n object: (identifier) @obj\n property: (property_identifier) @method)\n arguments: (arguments (string (string_fragment) @import))\n (#eq? @obj \"require\")\n (#eq? @method \"resolve\"))\n (call_expression\n function: (import)\n arguments: (arguments (string (string_fragment) @import)))\n ]\n `,\n extract(match: Parser.QueryMatch): string | undefined {\n const node = match.captures.find((c) => c.name === \"import\")?.node;\n return node?.text;\n },\n};\n","import type Parser from \"@keqingmoe/tree-sitter\";\n\nexport const callPattern = (fnName: string, args: string, allowMember = true): string => `(\n (call_expression\n function: ${\n allowMember\n ? `[\n (identifier) @func\n (member_expression property: (property_identifier) @func)\n ]`\n : `(identifier) @func`\n }\n arguments: ${args}\n ) @call\n (#eq? @func \"${fnName}\")\n)`;\n\nexport function isDescendant(node: Parser.SyntaxNode, ancestor: Parser.SyntaxNode): boolean {\n let current: Parser.SyntaxNode | null = node;\n while (current) {\n if (current.id === ancestor.id) return true;\n current = current.parent;\n }\n return false;\n}\n","import type Parser from \"@keqingmoe/tree-sitter\";\nimport { withComment } from \"./comment.ts\";\nimport type { MessageMatch, QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nconst notInPlural = (query: QuerySpec): QuerySpec => ({\n pattern: query.pattern,\n extract(match) {\n const result = query.extract(match);\n if (!result?.node) {\n return result;\n }\n\n let parent = result.node.parent;\n\n if (parent && parent.type === \"arguments\") {\n parent = parent.parent;\n }\n\n if (parent && parent.type === \"call_expression\") {\n const fn = parent.childForFieldName(\"function\");\n if (fn) {\n if (\n (fn.type === \"identifier\" &&\n (fn.text === \"plural\" ||\n fn.text === \"ngettext\" ||\n fn.text === \"pgettext\" ||\n fn.text === \"npgettext\")) ||\n (fn.type === \"member_expression\" &&\n [\"plural\", \"ngettext\", \"pgettext\", \"npgettext\"].includes(\n fn.childForFieldName(\"property\")?.text ?? \"\",\n ))\n ) {\n return undefined;\n }\n }\n }\n\n return result;\n },\n});\n\nexport const messageArg = `[\n (string (string_fragment) @msgid)\n (object\n (_)*\n (pair\n key: (property_identifier) @id_key\n value: (string (string_fragment) @id)\n (#eq? @id_key \"id\")\n )?\n (_)*\n (pair\n key: (property_identifier) @msg_key\n value: (string (string_fragment) @message)\n (#eq? @msg_key \"message\")\n )?\n (_)*\n )\n (template_string) @tpl\n]`;\n\nexport const messageArgs = `[ (arguments ${messageArg}) (template_string) @tpl ]`;\n\nexport const extractMessage =\n (name: string) =>\n (match: Parser.QueryMatch): MessageMatch | undefined => {\n const node = match.captures.find((c) => c.name === \"call\")?.node;\n if (!node) {\n return undefined;\n }\n\n const msgid = match.captures.find((c) => c.name === \"msgid\")?.node.text;\n if (msgid) {\n return {\n node,\n translation: {\n id: msgid,\n message: [msgid],\n },\n };\n }\n\n const tpl = match.captures.find((c) => c.name === \"tpl\")?.node;\n if (tpl) {\n for (const child of tpl.children) {\n if (child.type !== \"template_substitution\") {\n continue;\n }\n\n const expr = child.namedChildren[0];\n if (!expr || expr.type !== \"identifier\") {\n return {\n node,\n error: `${name}() template expressions must be simple identifiers`,\n };\n }\n }\n\n const text = tpl.text.slice(1, -1);\n\n return {\n node,\n translation: { id: text, message: [text] },\n };\n }\n\n const id = match.captures.find((c) => c.name === \"id\")?.node.text;\n const message = match.captures.find((c) => c.name === \"message\")?.node.text;\n const msgId = id ?? message;\n if (!msgId) {\n return undefined;\n }\n\n const msgstr = message ?? id ?? \"\";\n\n return {\n node,\n translation: {\n id: msgId,\n message: [msgstr],\n },\n };\n };\n\nexport const messageQuery: QuerySpec = notInPlural(\n withComment({\n pattern: callPattern(\"message\", messageArgs),\n extract: extractMessage(\"message\"),\n }),\n);\n\nconst allowed = new Set([\"string\", \"object\", \"template_string\"]);\n\nexport const messageInvalidQuery: QuerySpec = notInPlural({\n pattern: callPattern(\"message\", \"(arguments (_) @arg)\"),\n extract(match) {\n const call = match.captures.find((c) => c.name === \"call\")?.node;\n const node = match.captures.find((c) => c.name === \"arg\")?.node;\n\n if (!call || !node) {\n return undefined;\n }\n\n if (allowed.has(node.type)) {\n return undefined;\n }\n\n return {\n node,\n error: \"message() argument must be a string literal, object literal, or template literal\",\n };\n },\n});\n","import type Parser from \"@keqingmoe/tree-sitter\";\nimport { extractMessage } from \"./message.ts\";\nimport type { MessageMatch, Translation } from \"./types.ts\";\nimport { isDescendant } from \"./utils.ts\";\n\nexport const extractPluralForms =\n (name: string) =>\n (match: Parser.QueryMatch): MessageMatch | undefined => {\n const call = match.captures.find((c) => c.name === \"call\")?.node;\n const n = match.captures.find((c) => c.name === \"n\")?.node;\n if (!call || !n || n.nextNamedSibling) {\n return undefined;\n }\n\n const msgctxt = match.captures.find((c) => c.name === \"msgctxt\")?.node?.text;\n const msgNodes = match.captures.filter((c) => c.name === \"msg\").map((c) => c.node);\n\n const ids: string[] = [];\n const strs: string[] = [];\n\n for (const node of msgNodes) {\n const relevant = match.captures.filter(\n (c) => [\"msgid\", \"id\", \"message\", \"tpl\"].includes(c.name) && isDescendant(c.node, node),\n );\n\n const subMatch: Parser.QueryMatch = {\n pattern: 0,\n captures: [{ name: \"call\", node }, ...relevant],\n };\n\n const result = extractMessage(name)(subMatch);\n if (!result) continue;\n if (result.error) {\n return { node: call, error: result.error };\n }\n if (result.translation) {\n ids.push(result.translation.id);\n strs.push(result.translation.message[0] ?? \"\");\n }\n }\n\n if (ids.length === 0) {\n return undefined;\n }\n\n const translation: Translation = {\n id: ids[0],\n plural: ids[1],\n message: strs,\n };\n if (msgctxt) translation.context = msgctxt;\n\n return { node: call, translation };\n };\n","import { withComment } from \"./comment.ts\";\nimport { extractMessage, messageArgs } from \"./message.ts\";\nimport { extractPluralForms } from \"./plural-utils.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nconst ctxCall = callPattern(\n \"context\",\n `[\n (arguments (string (string_fragment) @msgctxt))\n (template_string) @msgctxt\n]`,\n)\n .replace(/@call/g, \"@ctx\")\n .replace(/@func/g, \"@ctxfn\");\n\nexport const contextMsgQuery: QuerySpec = withComment({\n pattern: `(\n (call_expression\n function: (member_expression\n object: ${ctxCall}\n property: (property_identifier) @func\n )\n arguments: ${messageArgs}\n ) @call\n (#eq? @func \"message\")\n)`,\n extract(match) {\n const result = extractMessage(\"context.message\")(match);\n const contextNode = match.captures.find((c) => c.name === \"msgctxt\")?.node;\n if (!result || !result.translation || !contextNode) {\n return result;\n }\n\n if (contextNode.type === \"template_string\") {\n for (const child of contextNode.children) {\n if (child.type !== \"template_substitution\") {\n continue;\n }\n\n const expr = child.namedChildren[0];\n if (!expr || expr.type !== \"identifier\") {\n return {\n node: contextNode,\n error: \"context() template expressions must be simple identifiers\",\n };\n }\n }\n }\n\n const contextText = contextNode.type === \"template_string\" ? contextNode.text.slice(1, -1) : contextNode.text;\n return {\n node: result.node,\n translation: {\n ...result.translation,\n context: contextText,\n },\n };\n },\n});\n\nconst msgCall = callPattern(\"message\", messageArgs, false).replace(/@call/g, \"@msg\").replace(/@func/g, \"@msgfn\");\n\nexport const contextPluralQuery: QuerySpec = withComment({\n pattern: `(\n (call_expression\n function: (member_expression\n object: ${ctxCall}\n property: (property_identifier) @func\n )\n arguments: (arguments (\n (${msgCall} (\",\" )?)+\n (number) @n\n ))\n ) @call\n (#eq? @func \"plural\")\n)`,\n extract: extractPluralForms(\"context.plural\"),\n});\n\nexport const contextInvalidQuery: QuerySpec = withComment({\n pattern: ctxCall,\n extract(match) {\n const call = match.captures.find((c) => c.name === \"ctx\")?.node;\n if (!call) {\n return undefined;\n }\n\n const parent = call.parent;\n if (parent && parent.type === \"member_expression\" && parent.childForFieldName(\"object\")?.id === call.id) {\n const property = parent.childForFieldName(\"property\")?.text;\n const grandparent = parent.parent;\n if (\n grandparent &&\n grandparent.type === \"call_expression\" &&\n grandparent.childForFieldName(\"function\")?.id === parent.id &&\n (property === \"message\" || property === \"plural\")\n ) {\n return undefined;\n }\n }\n\n return {\n node: call,\n error: \"context() must be used with message() or plural() in the same expression\",\n };\n },\n});\n","import { withComment } from \"./comment.ts\";\nimport { extractMessage, messageArgs } from \"./message.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nexport const gettextQuery: QuerySpec = withComment({\n pattern: callPattern(\"gettext\", messageArgs),\n extract: extractMessage(\"gettext\"),\n});\n\nconst allowed = new Set([\"string\", \"object\", \"template_string\", \"identifier\", \"call_expression\"]);\n\nexport const gettextInvalidQuery: QuerySpec = {\n pattern: callPattern(\"gettext\", \"(arguments (_) @arg)\"),\n extract(match) {\n const call = match.captures.find((c) => c.name === \"call\")?.node;\n const node = match.captures.find((c) => c.name === \"arg\")?.node;\n\n if (!call || !node) {\n return undefined;\n }\n\n if (allowed.has(node.type)) {\n return undefined;\n }\n\n return {\n node,\n error: \"gettext() argument must be a string literal, object literal, or template literal\",\n };\n },\n};\n","import { withComment } from \"./comment.ts\";\nimport { messageArg, messageArgs } from \"./message.ts\";\nimport { extractPluralForms } from \"./plural-utils.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nconst msgCall = callPattern(\"message\", messageArgs).replace(/@call/g, \"@msg\").replace(/@func/g, \"@msgfn\");\nconst plainMsg = `(${messageArg}) @msg`;\nconst msgArg = `[${msgCall} ${plainMsg}]`;\n\nexport const ngettextQuery: QuerySpec = withComment({\n pattern: callPattern(\"ngettext\", `(arguments ${msgArg} \",\" ${msgArg} (\",\" ${msgArg})* \",\" (_) @n)`),\n extract: extractPluralForms(\"ngettext\"),\n});\n","import { withComment } from \"./comment.ts\";\nimport { messageArg, messageArgs } from \"./message.ts\";\nimport { extractPluralForms } from \"./plural-utils.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nconst msgCall = callPattern(\"message\", messageArgs).replace(/@call/g, \"@msg\").replace(/@func/g, \"@msgfn\");\nconst plainMsg = `(${messageArg}) @msg`;\nconst msgArg = `[${msgCall} ${plainMsg}]`;\n\nexport const npgettextQuery: QuerySpec = withComment({\n pattern: callPattern(\n \"npgettext\",\n `(arguments (string (string_fragment) @msgctxt) \",\" ${msgArg} \",\" ${msgArg} (\",\" ${msgArg})* \",\" (_) @n)`,\n ),\n extract: extractPluralForms(\"npgettext\"),\n});\n","import { withComment } from \"./comment.ts\";\nimport { extractMessage, messageArg } from \"./message.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nexport const pgettextQuery: QuerySpec = withComment({\n pattern: callPattern(\"pgettext\", `(arguments (string (string_fragment) @msgctxt) \",\" ${messageArg})`),\n extract(match) {\n const result = extractMessage(\"pgettext\")(match);\n const contextNode = match.captures.find((c) => c.name === \"msgctxt\")?.node;\n if (!result || !contextNode || !result.translation) {\n return result;\n }\n return {\n node: result.node,\n translation: {\n ...result.translation,\n context: contextNode.text,\n },\n };\n },\n});\n","import { withComment } from \"./comment.ts\";\nimport { messageArgs } from \"./message.ts\";\nimport { extractPluralForms } from \"./plural-utils.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nconst msgCall = callPattern(\"message\", messageArgs, false).replace(/@call/g, \"@msg\").replace(/@func/g, \"@msgfn\");\n\nexport const pluralQuery: QuerySpec = withComment({\n pattern: callPattern(\n \"plural\",\n `(arguments (\n (${msgCall} (\",\" )?)+\n (number) @n\n ))`,\n false,\n ),\n extract: extractPluralForms(\"plural\"),\n});\n","import { contextInvalidQuery, contextMsgQuery, contextPluralQuery } from \"./context.ts\";\nimport { gettextInvalidQuery, gettextQuery } from \"./gettext.ts\";\nimport { messageInvalidQuery, messageQuery } from \"./message.ts\";\nimport { ngettextQuery } from \"./ngettext.ts\";\nimport { npgettextQuery } from \"./npgettext.ts\";\nimport { pgettextQuery } from \"./pgettext.ts\";\nimport { pluralQuery } from \"./plural.ts\";\nimport type { QuerySpec } from \"./types.ts\";\n\nexport type { MessageMatch, QuerySpec } from \"./types.ts\";\n\nexport const queries: QuerySpec[] = [\n contextMsgQuery,\n contextPluralQuery,\n contextInvalidQuery,\n messageQuery,\n messageInvalidQuery,\n gettextQuery,\n gettextInvalidQuery,\n pluralQuery,\n ngettextQuery,\n pgettextQuery,\n npgettextQuery,\n];\n","import fs from \"node:fs\";\nimport { extname, resolve } from \"node:path\";\n\nimport Parser from \"@keqingmoe/tree-sitter\";\nimport JavaScript from \"tree-sitter-javascript\";\nimport TS from \"tree-sitter-typescript\";\n\nimport { getReference } from \"./queries/comment.ts\";\nimport { entrypointQuery } from \"./queries/entrypoint.ts\";\nimport { importQuery } from \"./queries/import.ts\";\nimport { queries } from \"./queries/index.ts\";\nimport type { Context, Translation, Warning } from \"./queries/types.ts\";\n\nexport interface ParseResult {\n translations: Translation[];\n imports: string[];\n warnings: Warning[];\n entrypoint: boolean;\n}\n\nfunction getLanguage(ext: string) {\n switch (ext) {\n case \".ts\":\n return TS.typescript;\n case \".tsx\":\n return TS.tsx;\n default:\n return JavaScript;\n }\n}\n\nconst parserCache = new Map<string, { parser: Parser; language: Parser.Language }>();\nconst queryCache = new WeakMap<Parser.Language, Map<string, Parser.Query>>();\n\nfunction getCachedParser(ext: string) {\n let cached = parserCache.get(ext);\n if (!cached) {\n const parser = new Parser();\n const language = getLanguage(ext) as Parser.Language;\n parser.setLanguage(language);\n cached = { parser, language };\n parserCache.set(ext, cached);\n }\n return cached;\n}\n\nfunction getCachedQuery(language: Parser.Language, pattern: string) {\n let cache = queryCache.get(language);\n if (!cache) {\n cache = new Map();\n queryCache.set(language, cache);\n }\n\n let query = cache.get(pattern);\n if (!query) {\n query = new Parser.Query(language, pattern);\n cache.set(pattern, query);\n }\n\n return query;\n}\n\nexport function getParser(path: string) {\n const ext = extname(path);\n return getCachedParser(ext);\n}\n\nexport function getQuery(language: Parser.Language, pattern: string) {\n return getCachedQuery(language, pattern);\n}\n\nexport function parseFile(filePath: string): ParseResult {\n const path = resolve(filePath);\n const source = fs.readFileSync(path, \"utf8\");\n return parseSource(source, path);\n}\n\nexport function parseSource(source: string, path: string): ParseResult {\n const context: Context = {\n path,\n };\n\n const { parser, language } = getParser(path);\n const tree = parser.parse(source);\n\n const commentQuery = getCachedQuery(language, entrypointQuery.pattern);\n const entrypoint = commentQuery.matches(tree.rootNode).some(entrypointQuery.extract);\n\n const translations: Translation[] = [];\n const warnings: Warning[] = [];\n const imports: string[] = [];\n\n const seen = new Set<number>();\n\n for (const spec of queries) {\n const query = getCachedQuery(language, spec.pattern);\n for (const match of query.matches(tree.rootNode)) {\n const message = spec.extract(match);\n if (!message) {\n continue;\n }\n\n const { node, translation, error } = message;\n if (seen.has(node.id)) {\n continue;\n }\n seen.add(node.id);\n const reference = getReference(node, context);\n\n if (translation) {\n translations.push({\n ...translation,\n comments: {\n ...translation.comments,\n reference,\n },\n });\n }\n\n if (error) {\n warnings.push({\n error,\n reference,\n });\n }\n }\n }\n\n const importTreeQuery = getCachedQuery(language, importQuery.pattern);\n for (const match of importTreeQuery.matches(tree.rootNode)) {\n const imp = importQuery.extract(match);\n if (imp) {\n imports.push(imp);\n }\n }\n\n return { translations, imports, warnings, entrypoint };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { ResolverFactory } from \"oxc-resolver\";\n\nfunction findTsconfig(dir: string): string | undefined {\n let current = dir;\n while (true) {\n const config = path.join(current, \"tsconfig.json\");\n if (fs.existsSync(config)) {\n return config;\n }\n const parent = path.dirname(current);\n if (parent === current) {\n return undefined;\n }\n current = parent;\n }\n}\n\nconst resolverCache = new Map<string, ResolverFactory>();\n\nfunction getResolver(dir: string) {\n const tsconfig = findTsconfig(dir);\n const key = tsconfig ?? \"__default__\";\n let resolver = resolverCache.get(key);\n if (!resolver) {\n resolver = new ResolverFactory({\n extensions: [\".ts\", \".tsx\", \".js\", \".jsx\", \".mjs\", \".cjs\", \".json\"],\n conditionNames: [\"import\", \"require\", \"node\"],\n ...(tsconfig ? { tsconfig: { configFile: tsconfig } } : {}),\n });\n resolverCache.set(key, resolver);\n }\n return resolver;\n}\n\nfunction resolveFromDir(dir: string, spec: string): string | undefined {\n const resolver = getResolver(dir);\n const res = resolver.sync(dir, spec) as { path?: string };\n return res.path;\n}\n\nexport function resolveImport(file: string, spec: string): string | undefined {\n const dir = path.dirname(path.resolve(file));\n return resolveFromDir(dir, spec);\n}\n\nexport function resolveImports(file: string, imports: string[]): string[] {\n const dir = path.dirname(path.resolve(file));\n const resolver = getResolver(dir);\n const resolved: string[] = [];\n for (const spec of imports) {\n const res = resolver.sync(dir, spec) as { path?: string };\n if (res.path) {\n resolved.push(res.path);\n }\n }\n return resolved;\n}\n","import { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\n\nimport type { Plugin } from \"../../plugin.ts\";\nimport { parseSource } from \"./parse.ts\";\nimport type { Translation } from \"./queries/types.ts\";\nimport { resolveImports } from \"./resolve.ts\";\n\nconst filter = /\\.([cm]?tsx?|jsx?)$/;\nconst namespace = \"source\";\n\nexport function core(): Plugin<string, Translation[]> {\n return {\n name: \"core\",\n setup(build) {\n build.context.logger?.debug(\"core plugin initialized\");\n build.onResolve({ filter, namespace }, ({ entrypoint, path }) => {\n return {\n entrypoint,\n namespace,\n path: resolve(path),\n };\n });\n\n build.onLoad({ filter, namespace }, async ({ entrypoint, path }) => {\n const data = await readFile(path, \"utf8\");\n return {\n entrypoint,\n path,\n namespace,\n data,\n };\n });\n\n build.onProcess({ filter, namespace }, ({ entrypoint, path, data }) => {\n const result = parseSource(data, path);\n\n if (result.entrypoint && entrypoint !== path) {\n build.source(path);\n return;\n }\n\n const { translations, imports, warnings } = result;\n\n if (build.context.config.walk) {\n const paths = resolveImports(path, imports);\n for (const path of paths) {\n if (build.context.paths.has(path)) {\n continue;\n }\n\n build.resolve({ entrypoint, path, namespace });\n }\n }\n\n for (const warning of warnings) {\n build.context.logger?.warn(`${warning.error} at ${warning.reference}`);\n }\n\n build.resolve({\n entrypoint,\n path,\n namespace: \"translate\",\n data: translations,\n });\n\n return undefined;\n });\n },\n };\n}\n","import type { GetTextTranslationRecord } from \"gettext-parser\";\nimport { getNPlurals } from \"plural-forms\";\n\nimport type { Translation } from \"../core/queries/types.ts\";\n\nexport function collect(source: Translation[], locale?: string): GetTextTranslationRecord {\n const translations: GetTextTranslationRecord = { \"\": {} };\n const nplurals = locale ? Number(getNPlurals(locale)) : undefined;\n\n for (const { context, id, message, comments, obsolete, plural } of source) {\n const ctx = context || \"\";\n if (!translations[ctx]) {\n translations[ctx] = {};\n }\n\n const length = plural ? (nplurals ?? message.length) : 1;\n\n const existing = translations[ctx][id];\n const refs = new Set<string>();\n if (existing?.comments?.reference) {\n existing.comments.reference.split(/\\r?\\n|\\r/).forEach((r) => {\n refs.add(r);\n });\n }\n if (comments?.reference) {\n comments.reference.split(/\\r?\\n|\\r/).forEach((r) => {\n refs.add(r);\n });\n }\n\n const msgstr = existing?.msgstr ? existing.msgstr.slice(0, length) : Array.from({ length }, () => \"\");\n while (msgstr.length < length) msgstr.push(\"\");\n\n translations[ctx][id] = {\n msgctxt: context || undefined,\n msgid: id,\n msgid_plural: plural,\n msgstr,\n comments: {\n ...existing?.comments,\n ...comments,\n reference: refs.size ? Array.from(refs).join(\"\\n\") : undefined,\n },\n obsolete: existing?.obsolete ?? obsolete,\n };\n }\n\n return translations;\n}\n","import { isDeepStrictEqual } from \"node:util\";\nimport type { GetTextTranslations } from \"gettext-parser\";\nimport * as gettextParser from \"gettext-parser\";\n\nconst IGNORED_HEADER_KEYS = new Set([\"pot-creation-date\", \"po-revision-date\"]);\nconst IGNORED_HEADER_LINE_PREFIXES = [\"pot-creation-date:\", \"po-revision-date:\"];\n\nfunction normalizeHeaderString(value: string): string {\n const lines = value.split(\"\\n\");\n const hadTrailingNewline = value.endsWith(\"\\n\");\n\n const filtered = lines\n .filter((line) => {\n const trimmed = line.trimStart().toLowerCase();\n return !IGNORED_HEADER_LINE_PREFIXES.some((prefix) => trimmed.startsWith(prefix));\n })\n .map((line) => {\n const separatorIndex = line.indexOf(\":\");\n if (separatorIndex === -1) {\n return line;\n }\n\n const key = line.slice(0, separatorIndex).trim().toLowerCase();\n const value = line.slice(separatorIndex + 1);\n return `${key}:${value}`;\n });\n\n if (hadTrailingNewline && filtered[filtered.length - 1] !== \"\") {\n filtered.push(\"\");\n }\n\n return filtered.join(\"\\n\");\n}\n\nfunction normalize(translations: GetTextTranslations): GetTextTranslations {\n const compiled = gettextParser.po.compile(translations);\n const parsed = gettextParser.po.parse(compiled);\n\n if (parsed.headers) {\n const normalizedHeaders: Record<string, string> = {};\n for (const [key, value] of Object.entries(parsed.headers)) {\n if (!IGNORED_HEADER_KEYS.has(key.toLowerCase())) {\n normalizedHeaders[key.toLowerCase()] = value as string;\n }\n }\n parsed.headers = normalizedHeaders;\n }\n\n const headerMessage = parsed.translations?.[\"\"]?.[\"\"];\n if (headerMessage?.msgstr) {\n headerMessage.msgstr = headerMessage.msgstr.map((item) => normalizeHeaderString(item));\n }\n\n return parsed;\n}\n\nexport function hasChanges(left: GetTextTranslations, right?: GetTextTranslations): boolean {\n if (!right) {\n return true;\n }\n\n const normalizedLeft = normalize(left);\n const normalizedRight = normalize(right);\n\n return !isDeepStrictEqual(normalizedLeft, normalizedRight);\n}\n","import type { GetTextTranslationRecord, GetTextTranslations } from \"gettext-parser\";\nimport { getFormula, getNPlurals } from \"plural-forms\";\n\nimport type { ObsoleteStrategy } from \"../../configuration.ts\";\n\nexport interface Collected {\n translations: GetTextTranslationRecord;\n}\n\nexport function formatDate(date: Date): string {\n const pad = (n: number) => n.toString().padStart(2, \"0\");\n const year = date.getFullYear();\n const month = pad(date.getMonth() + 1);\n const day = pad(date.getDate());\n const hours = pad(date.getHours());\n const minutes = pad(date.getMinutes());\n const tzo = -date.getTimezoneOffset();\n const sign = tzo >= 0 ? \"+\" : \"-\";\n const offsetHours = pad(Math.floor(Math.abs(tzo) / 60));\n const offsetMinutes = pad(Math.abs(tzo) % 60);\n return `${year}-${month}-${day} ${hours}:${minutes}${sign}${offsetHours}${offsetMinutes}`;\n}\n\nexport function merge(\n sources: Collected[],\n existing: GetTextTranslations | undefined,\n obsolete: ObsoleteStrategy,\n locale: string,\n generatedAt: Date,\n): GetTextTranslations {\n let headers: Record<string, string> = {};\n let translations: GetTextTranslationRecord = { \"\": {} };\n let obsoleteTranslations: GetTextTranslationRecord = {};\n const nplurals = Number(getNPlurals(locale));\n\n if (existing) {\n headers = existing.headers ? structuredClone(existing.headers) : {};\n translations = existing.translations ? structuredClone(existing.translations) : { \"\": {} };\n obsoleteTranslations = existing.obsolete ? structuredClone(existing.obsolete) : {};\n for (const ctx of Object.keys(translations)) {\n for (const id of Object.keys(translations[ctx])) {\n if (ctx === \"\" && id === \"\") continue;\n translations[ctx][id].obsolete = true;\n }\n }\n }\n\n const collected: GetTextTranslationRecord = { \"\": {} };\n for (const { translations } of sources) {\n for (const [ctx, msgs] of Object.entries(translations)) {\n if (!collected[ctx]) collected[ctx] = {};\n for (const [id, entry] of Object.entries(msgs)) {\n const existing = collected[ctx][id];\n const refs = new Set<string>();\n if (existing?.comments?.reference) {\n existing.comments.reference.split(/\\r?\\n|\\r/).forEach((r) => {\n refs.add(r);\n });\n }\n if (entry.comments?.reference) {\n entry.comments.reference.split(/\\r?\\n|\\r/).forEach((r) => {\n refs.add(r);\n });\n }\n collected[ctx][id] = {\n ...existing,\n ...entry,\n comments: {\n ...existing?.comments,\n ...entry.comments,\n reference: refs.size ? Array.from(refs).join(\"\\n\") : undefined,\n },\n };\n }\n }\n }\n\n for (const [ctx, msgs] of Object.entries(collected)) {\n if (!translations[ctx]) translations[ctx] = {};\n for (const [id, entry] of Object.entries(msgs)) {\n const existingEntry = translations[ctx][id] ?? obsoleteTranslations[ctx]?.[id];\n if (existingEntry) {\n entry.msgstr = existingEntry.msgstr;\n entry.comments = {\n ...entry.comments,\n translator: existingEntry.comments?.translator,\n };\n }\n delete entry.obsolete;\n entry.msgstr = entry.msgstr.slice(0, nplurals);\n while (entry.msgstr.length < nplurals) {\n entry.msgstr.push(\"\");\n }\n translations[ctx][id] = entry;\n if (obsoleteTranslations[ctx]) {\n delete obsoleteTranslations[ctx][id];\n }\n }\n }\n\n for (const ctx of Object.keys(translations)) {\n for (const id of Object.keys(translations[ctx])) {\n if (ctx === \"\" && id === \"\") {\n continue;\n }\n const entry = translations[ctx][id];\n if (entry.obsolete) {\n if (!obsoleteTranslations[ctx]) {\n obsoleteTranslations[ctx] = {};\n }\n obsoleteTranslations[ctx][id] = entry;\n delete translations[ctx][id];\n }\n }\n }\n\n headers = {\n ...headers,\n \"Content-Type\": headers[\"Content-Type\"] || \"text/plain; charset=UTF-8\",\n \"Plural-Forms\": `nplurals=${nplurals}; plural=${getFormula(locale)};`,\n language: locale,\n \"MIME-Version\": \"1.0\",\n \"Content-Transfer-Encoding\": \"8bit\",\n \"POT-Creation-Date\": formatDate(generatedAt),\n \"x-generator\": \"@let-value/translate-extract\",\n };\n\n return {\n charset: \"utf-8\",\n headers,\n translations,\n ...(obsolete === \"mark\" && Object.keys(obsoleteTranslations).length ? { obsolete: obsoleteTranslations } : {}),\n };\n}\n","import fs from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\nimport * as gettextParser from \"gettext-parser\";\n\nimport type { Plugin } from \"../../plugin.ts\";\nimport type { Translation } from \"../core/queries/types.ts\";\nimport { collect } from \"./collect.ts\";\nimport { hasChanges } from \"./hasChanges.ts\";\nimport { merge } from \"./merge.ts\";\n\nconst namespace = \"translate\";\n\nexport function po(): Plugin {\n return {\n name: \"po\",\n setup(build) {\n build.context.logger?.debug(\"po plugin initialized\");\n const collections = new Map<\n string,\n {\n locale: string;\n translations: Translation[];\n }\n >();\n let dispatched = false;\n\n build.onResolve({ filter: /.*/, namespace }, async ({ entrypoint, path, data }) => {\n if (!data || !Array.isArray(data)) {\n return undefined;\n }\n\n for (const locale of build.context.config.locales) {\n const destination = build.context.config.destination({ entrypoint, locale, path });\n if (!collections.has(destination)) {\n collections.set(destination, { locale, translations: [] });\n }\n\n collections.get(destination)?.translations.push(...data);\n }\n\n Promise.all([build.defer(\"source\"), build.defer(namespace)]).then(() => {\n if (dispatched) {\n return;\n }\n dispatched = true;\n\n for (const path of collections.keys()) {\n build.load({ entrypoint, path, namespace });\n }\n });\n\n return undefined;\n });\n\n build.onLoad({ filter: /.*\\.po$/, namespace }, async ({ entrypoint, path }) => {\n const contents = await fs.readFile(path).catch(() => undefined);\n const data = contents ? gettextParser.po.parse(contents) : undefined;\n return {\n entrypoint,\n path,\n namespace,\n data,\n };\n });\n\n build.onProcess({ filter: /.*\\.po$/, namespace }, async ({ entrypoint, path, data }) => {\n const collected = collections.get(path);\n if (!collected) {\n build.context.logger?.warn({ path }, \"no translations collected for this path\");\n return undefined;\n }\n\n const { locale, translations } = collected;\n\n const record = collect(translations, locale);\n\n const out = merge(\n [{ translations: record }],\n data as never,\n build.context.config.obsolete,\n locale,\n build.context.generatedAt,\n );\n\n if (hasChanges(out, data as never)) {\n await fs.mkdir(dirname(path), { recursive: true });\n await fs.writeFile(path, gettextParser.po.compile(out));\n }\n\n build.resolve({\n entrypoint,\n path,\n namespace: \"cleanup\",\n data: translations,\n });\n });\n },\n };\n}\n","import type Parser from \"@keqingmoe/tree-sitter\";\n\nexport function buildTemplate(node: Parser.SyntaxNode): { text: string; error?: string } {\n const source = node.tree.rootNode.text;\n const open = node.childForFieldName(\"open_tag\");\n const close = node.childForFieldName(\"close_tag\");\n const contentStart = open?.endIndex ?? node.startIndex;\n const contentEnd = close?.startIndex ?? node.endIndex;\n\n type Part = { kind: \"text\"; text: string; raw: boolean } | { kind: \"expr\"; value: string };\n\n const parts: Part[] = [];\n let segmentStart = contentStart;\n\n const pushRawText = (endIndex: number) => {\n if (endIndex <= segmentStart) {\n segmentStart = Math.max(segmentStart, endIndex);\n return;\n }\n const text = source.slice(segmentStart, endIndex);\n if (text) {\n parts.push({ kind: \"text\", text, raw: true });\n }\n segmentStart = endIndex;\n };\n\n const children = node.namedChildren.slice(1, -1);\n for (const child of children) {\n if (child.type === \"jsx_expression\") {\n pushRawText(child.startIndex);\n const expr = child.namedChildren[0];\n if (!expr) {\n return { text: \"\", error: \"Empty JSX expression\" };\n }\n\n if (expr.type === \"identifier\") {\n parts.push({ kind: \"expr\", value: expr.text });\n } else if (expr.type === \"string\") {\n parts.push({ kind: \"text\", text: expr.text.slice(1, -1), raw: false });\n } else if (expr.type === \"template_string\") {\n const hasSubstitutions = expr.children.some((c) => c.type === \"template_substitution\");\n if (hasSubstitutions) {\n return { text: \"\", error: \"JSX expressions with template substitutions are not supported\" };\n }\n parts.push({ kind: \"text\", text: expr.text.slice(1, -1), raw: false });\n } else {\n return { text: \"\", error: \"JSX expressions must be simple identifiers, strings, or template literals\" };\n }\n segmentStart = child.endIndex;\n } else if (child.type === \"string\") {\n pushRawText(child.startIndex);\n parts.push({ kind: \"text\", text: child.text.slice(1, -1), raw: false });\n segmentStart = child.endIndex;\n } else if (child.type === \"jsx_text\" || child.type === \"html_character_reference\" || child.isError) {\n } else {\n return { text: \"\", error: \"Unsupported JSX child\" };\n }\n }\n\n pushRawText(contentEnd);\n\n const firstRawIndex = parts.findIndex((part) => part.kind === \"text\" && part.raw);\n if (firstRawIndex === 0) {\n const part = parts[firstRawIndex] as Extract<Part, { kind: \"text\" }>;\n part.text = part.text.replace(/^\\s+/, \"\");\n }\n\n let lastRawIndex = -1;\n for (let i = parts.length - 1; i >= 0; i--) {\n const part = parts[i];\n if (part.kind === \"text\" && part.raw) {\n lastRawIndex = i;\n break;\n }\n }\n if (lastRawIndex !== -1 && lastRawIndex === parts.length - 1) {\n const part = parts[lastRawIndex] as Extract<Part, { kind: \"text\" }>;\n part.text = part.text.replace(/\\s+$/, \"\");\n }\n\n const strings: string[] = [\"\"];\n const values: string[] = [];\n for (const part of parts) {\n if (part.kind === \"text\") {\n if (part.text) {\n strings[strings.length - 1] += part.text;\n }\n } else {\n values.push(part.value);\n strings.push(\"\");\n }\n }\n\n let text = \"\";\n for (let i = 0; i < strings.length; i++) {\n text += strings[i];\n if (values[i]) {\n text += `\\${${values[i]}}`;\n }\n }\n return { text };\n}\n\nexport function buildAttrValue(node: Parser.SyntaxNode): { text: string; error?: string } {\n if (node.type === \"string\") {\n return { text: node.text.slice(1, -1) };\n }\n if (node.type === \"jsx_expression\") {\n const expr = node.namedChildren[0];\n if (!expr) {\n return { text: \"\", error: \"Empty JSX expression\" };\n }\n\n if (expr.type === \"identifier\") {\n return { text: `\\${${expr.text}}` };\n } else if (expr.type === \"string\") {\n return { text: expr.text.slice(1, -1) };\n } else if (expr.type === \"template_string\") {\n // Check if it's a simple template string with no substitutions\n const hasSubstitutions = expr.children.some((c) => c.type === \"template_substitution\");\n if (hasSubstitutions) {\n return { text: \"\", error: \"JSX expressions with template substitutions are not supported\" };\n }\n // Extract the text content from the template string\n const content = expr.text.slice(1, -1); // Remove backticks\n return { text: content };\n } else {\n return { text: \"\", error: \"JSX expressions must be simple identifiers, strings, or template literals\" };\n }\n }\n return { text: \"\", error: \"Unsupported JSX child\" };\n}\n","import type Parser from \"@keqingmoe/tree-sitter\";\n\nimport { withComment } from \"../../core/queries/comment.ts\";\nimport type { MessageMatch, QuerySpec, Translation } from \"../../core/queries/types.ts\";\nimport { buildAttrValue, buildTemplate } from \"./utils.ts\";\n\nexport const messageQuery: QuerySpec = withComment({\n pattern: `(\n [\n (jsx_element (jsx_opening_element name: (identifier) @name)) @call\n (jsx_self_closing_element name: (identifier) @name) @call\n (lexical_declaration \n (variable_declarator \n value: [\n (jsx_element (jsx_opening_element name: (identifier) @name)) @call\n (jsx_self_closing_element name: (identifier) @name) @call\n ]\n )\n )\n ]\n (#eq? @name \"Message\")\n )`,\n extract(match: Parser.QueryMatch): MessageMatch | undefined {\n const node = match.captures.find((c) => c.name === \"call\")?.node;\n if (!node) return undefined;\n let attrs: Parser.SyntaxNode[] = [];\n if (node.type === \"jsx_element\") {\n const open = node.childForFieldName(\"open_tag\");\n if (open) attrs = open.namedChildren;\n } else if (node.type === \"jsx_self_closing_element\") {\n attrs = node.namedChildren.slice(1);\n }\n let msgctxt: string | undefined;\n let childValue: Parser.SyntaxNode | undefined;\n for (const child of attrs) {\n if (child.type !== \"jsx_attribute\") continue;\n const name = child.child(0);\n const value = child.child(child.childCount - 1);\n if (name?.text === \"context\" && value?.type === \"string\") {\n msgctxt = value.text.slice(1, -1);\n } else if (name?.text === \"children\" && value) {\n childValue = value;\n }\n }\n let text = \"\";\n let error: string | undefined;\n if (node.type === \"jsx_element\") {\n ({ text, error } = buildTemplate(node));\n } else if (childValue) {\n ({ text, error } = buildAttrValue(childValue));\n }\n if (error) {\n return { node, error };\n }\n if (!text) return undefined;\n const translation: Translation = {\n id: text,\n message: [text],\n };\n if (msgctxt) translation.context = msgctxt;\n return { node, translation };\n },\n});\n","import type Parser from \"@keqingmoe/tree-sitter\";\n\nimport { withComment } from \"../../core/queries/comment.ts\";\nimport type { MessageMatch, QuerySpec, Translation } from \"../../core/queries/types.ts\";\nimport { buildTemplate } from \"./utils.ts\";\n\nfunction parseForms(node: Parser.SyntaxNode): { forms: string[]; error?: string } {\n const forms: string[] = [];\n if (node.type === \"jsx_expression\") {\n const arr = node.namedChildren[0];\n if (!arr || arr.type !== \"array\") {\n return { forms: [], error: \"Plural forms must be an array\" };\n }\n for (const el of arr.namedChildren) {\n if (el.type === \"jsx_element\" || el.type === \"jsx_fragment\") {\n const { text, error } = buildTemplate(el);\n if (error) return { forms: [], error };\n forms.push(text);\n } else if (el.type === \"string\") {\n forms.push(el.text.slice(1, -1));\n } else {\n return { forms: [], error: \"Unsupported plural form\" };\n }\n }\n }\n return { forms };\n}\n\nexport const pluralQuery: QuerySpec = withComment({\n pattern: `(\n [\n (jsx_element (jsx_opening_element name: (identifier) @name))\n (jsx_self_closing_element name: (identifier) @name)\n ] @call\n (#eq? @name \"Plural\")\n )`,\n extract(match: Parser.QueryMatch): MessageMatch | undefined {\n const node = match.captures.find((c) => c.name === \"call\")?.node;\n if (!node) return undefined;\n let attrs: Parser.SyntaxNode[] = [];\n if (node.type === \"jsx_element\") {\n const open = node.childForFieldName(\"open_tag\");\n if (open) attrs = open.namedChildren;\n } else if (node.type === \"jsx_self_closing_element\") {\n attrs = node.namedChildren.slice(1);\n }\n let msgctxt: string | undefined;\n let formsNode: Parser.SyntaxNode | null | undefined;\n for (const child of attrs) {\n if (child.type !== \"jsx_attribute\") continue;\n const name = child.child(0);\n const value = child.child(child.childCount - 1);\n if (name?.text === \"context\" && value?.type === \"string\") {\n msgctxt = value.text.slice(1, -1);\n } else if (name?.text === \"forms\" && value) {\n formsNode = value;\n }\n }\n if (!formsNode) return undefined;\n const { forms, error } = parseForms(formsNode);\n if (error) {\n return { node, error };\n }\n if (forms.length === 0) return undefined;\n const translation: Translation = {\n id: forms[0],\n plural: forms[1],\n message: forms,\n };\n if (msgctxt) translation.context = msgctxt;\n return { node, translation };\n },\n});\n","import type { QuerySpec } from \"../../core/queries/types.ts\";\nimport { messageQuery } from \"./message.ts\";\nimport { pluralQuery } from \"./plural.ts\";\n\nexport const queries: QuerySpec[] = [messageQuery, pluralQuery];\n","import fs from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { getParser, getQuery } from \"../core/parse.ts\";\nimport { getReference } from \"../core/queries/comment.ts\";\n\nimport type { Context, Translation, Warning } from \"../core/queries/types.ts\";\nimport { queries } from \"./queries/index.ts\";\n\nexport interface ParseResult {\n translations: Translation[];\n warnings: Warning[];\n}\n\nexport function parseFile(filePath: string): ParseResult {\n const path = resolve(filePath);\n const source = fs.readFileSync(path, \"utf8\");\n return parseSource(source, path);\n}\n\nexport function parseSource(source: string, path: string): ParseResult {\n const context: Context = { path };\n const { parser, language } = getParser(path);\n const tree = parser.parse(source);\n\n const translations: Translation[] = [];\n const warnings: Warning[] = [];\n const seen = new Set<number>();\n\n for (const spec of queries) {\n const query = getQuery(language, spec.pattern);\n for (const match of query.matches(tree.rootNode)) {\n const message = spec.extract(match);\n if (!message) continue;\n const { node, translation, error } = message;\n if (seen.has(node.id)) continue;\n seen.add(node.id);\n const reference = getReference(node, context);\n if (translation) {\n translations.push({\n ...translation,\n comments: {\n ...translation.comments,\n reference,\n },\n });\n }\n if (error) {\n warnings.push({\n error,\n reference,\n });\n }\n }\n }\n\n return { translations, warnings };\n}\n","import { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\n\nimport type { Plugin } from \"../../plugin.ts\";\nimport type { Translation } from \"../core/queries/types.ts\";\nimport { parseSource } from \"./parse.ts\";\n\nconst filter = /\\.[cm]?[jt]sx$/;\n\nexport function react(): Plugin<string, Translation[]> {\n return {\n name: \"react\",\n setup(build) {\n build.context.logger?.debug(\"react plugin initialized\");\n build.onResolve({ filter: /.*/, namespace: \"source\" }, ({ entrypoint, path, namespace }) => {\n return {\n entrypoint,\n namespace,\n path: resolve(path),\n };\n });\n build.onLoad({ filter, namespace: \"source\" }, async ({ entrypoint, path, namespace }) => {\n const data = await readFile(path, \"utf8\");\n return {\n entrypoint,\n path,\n namespace,\n data,\n };\n });\n build.onProcess({ filter, namespace: \"source\" }, ({ entrypoint, path, data }) => {\n const { translations, warnings } = parseSource(data, path);\n\n for (const warning of warnings) {\n build.context.logger?.warn(`${warning.error} at ${warning.reference}`);\n }\n\n build.resolve({\n entrypoint,\n path,\n namespace: \"translate\",\n data: translations,\n });\n\n return undefined;\n });\n },\n };\n}\n","import type { Plugin, UniversalPlugin } from \"../plugin.ts\";\n\nimport { cleanup, core, po, react } from \"./index.ts\";\n\nconst original = {\n cleanup,\n core,\n po,\n react,\n} as const;\n\nexport function resolveStaticPlugin(item: UniversalPlugin): Plugin {\n if (\"static\" in item) {\n return original[item.static.name](...item.static.props);\n }\n\n return item;\n}\n","import { resolve as resolvePath } from \"node:path\";\nimport glob from \"fast-glob\";\nimport type { ResolvedConfig, ResolvedEntrypoint } from \"./configuration.ts\";\nimport { Defer } from \"./defer.ts\";\nimport type { Logger } from \"./logger.ts\";\nimport type {\n Build,\n Context,\n Filter,\n LoadArgs,\n LoadHook,\n ProcessArgs,\n ProcessHook,\n ResolveArgs,\n ResolveHook,\n} from \"./plugin.ts\";\nimport { resolveStaticPlugin } from \"./plugins/static.ts\";\n\nexport type Task =\n | {\n type: \"resolve\";\n args: ResolveArgs;\n }\n | {\n type: \"load\";\n args: LoadArgs;\n }\n | {\n type: \"process\";\n args: ProcessArgs;\n };\n\nasync function getPaths(entrypoint: ResolvedEntrypoint) {\n const pattern = entrypoint.entrypoint.replace(/\\\\/g, \"/\");\n const paths = glob.isDynamicPattern(pattern) ? await glob(pattern, { onlyFiles: true }) : [entrypoint.entrypoint];\n return new Set(paths.map((path) => resolvePath(path)));\n}\n\nexport async function run(\n entrypoint: ResolvedEntrypoint,\n { config, logger }: { config: ResolvedConfig; logger?: Logger },\n) {\n const destination = entrypoint.destination ?? config.destination;\n const obsolete = entrypoint.obsolete ?? config.obsolete;\n const exclude = entrypoint.exclude ?? config.exclude;\n const walk = entrypoint.walk ?? config.walk;\n const paths = new Set<string>();\n\n const context: Context = {\n config: { ...config, destination, obsolete, exclude, walk },\n generatedAt: new Date(),\n paths,\n logger,\n };\n\n logger?.info(entrypoint, \"starting extraction\");\n\n const resolvers: { filter: Filter; hook: ResolveHook }[] = [];\n const loaders: { filter: Filter; hook: LoadHook }[] = [];\n const processors: { filter: Filter; hook: ProcessHook }[] = [];\n const hooks = {\n resolve: resolvers,\n load: loaders,\n process: processors,\n };\n\n const pending = new Map<string, Defer>();\n const queue: Task[] = [];\n\n function getDeferred(namespace: string) {\n let defer = pending.get(namespace);\n if (defer === undefined) {\n defer = new Defer();\n pending.set(namespace, defer);\n }\n return defer;\n }\n\n function defer(namespace: string) {\n const defer = getDeferred(namespace);\n return defer.promise;\n }\n\n function source(path: string) {\n const resolvedPath = resolvePath(path);\n\n if (paths.has(resolvedPath)) {\n return;\n }\n\n logger?.debug({ entrypoint: entrypoint.entrypoint, path: resolvedPath }, \"resolved path\");\n\n paths.add(resolvedPath);\n resolve({ entrypoint: resolvedPath, path: resolvedPath, namespace: \"source\" });\n }\n\n function resolve(args: ResolveArgs) {\n const { entrypoint, path, namespace } = args;\n const skipped = context.config.exclude.some((ex) => (typeof ex === \"function\" ? ex(args) : ex.test(args.path)));\n logger?.debug({ entrypoint, path, namespace, skipped }, \"resolve\");\n\n if (skipped) {\n return;\n }\n\n queue.push({ type: \"resolve\", args });\n getDeferred(namespace).enqueue();\n }\n\n function load(args: LoadArgs) {\n const { entrypoint, path, namespace } = args;\n logger?.debug({ entrypoint, path, namespace }, \"load\");\n\n queue.push({ type: \"load\", args });\n getDeferred(namespace).enqueue();\n }\n\n function process(args: ProcessArgs) {\n const { entrypoint, path, namespace } = args;\n logger?.debug({ entrypoint, path, namespace }, \"process\");\n\n queue.push({ type: \"process\", args });\n getDeferred(namespace).enqueue();\n }\n\n const build: Build = {\n context,\n source,\n resolve,\n load,\n process,\n defer,\n onResolve(filter, hook) {\n resolvers.push({ filter, hook });\n },\n onLoad(filter, hook) {\n loaders.push({ filter, hook });\n },\n onProcess(filter, hook) {\n processors.push({ filter, hook });\n },\n };\n\n for (const item of config.plugins) {\n const plugin = resolveStaticPlugin(item);\n logger?.debug({ plugin: plugin.name }, \"setting up plugin\");\n plugin.setup(build);\n }\n\n for (const path of await getPaths(entrypoint)) {\n source(path);\n }\n\n async function processTask(task: Task) {\n const { type } = task;\n let args = task.args;\n const { entrypoint, path, namespace } = args;\n logger?.trace({ type, entrypoint, path, namespace }, \"processing task\");\n\n for (const { filter, hook } of hooks[type]) {\n if (filter.namespace !== namespace) continue;\n if (filter.filter && !filter.filter.test(path)) continue;\n\n const result = await hook(args as never);\n if (result !== undefined) {\n args = result as never;\n }\n }\n\n if (args !== undefined) {\n if (type === \"resolve\") {\n load(args as never);\n } else if (type === \"load\") {\n process(args as never);\n }\n }\n\n getDeferred(namespace).dequeue();\n }\n\n while (queue.length || Array.from(pending.values()).some((d) => d.pending > 0)) {\n while (queue.length) {\n const task = queue.shift();\n if (!task) {\n break;\n }\n\n await processTask(task);\n }\n\n await Promise.all(Array.from(pending.values()).map((d) => d.promise));\n await Promise.resolve();\n }\n\n logger?.info(entrypoint, \"extraction completed\");\n}\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAa,QAAb,MAAmB;CACf,UAAU;CACV,UAAyB,QAAQ,SAAS;CAC1C;CAEA,UAAU;AACN,MAAI,KAAK,cAAc,EACnB,MAAK,UAAU,IAAI,SAAe,QAAQ;AACtC,QAAK,UAAU;IACjB;;CAGV,UAAU;AACN,MAAI,KAAK,UAAU,KAAK,EAAE,KAAK,YAAY,EACvC,MAAK,WAAW;;;;;;ACP5B,MAAMA,cAAY;AAElB,SAAgB,UAAkB;AAC9B,QAAO;EACH,MAAM;EACN,MAAM,OAAO;AACT,SAAM,QAAQ,QAAQ,MAAM,6BAA6B;GACzD,MAAM,4BAAY,IAAI,KAAa;GACnC,MAAM,4BAAY,IAAI,KAAa;GACnC,MAAM,uBAAO,IAAI,KAAa;GAC9B,IAAI,aAAa;AAEjB,SAAM,UAAU;IAAE;IAAW,QAAQ;IAAM,GAAG,EAAE,mBAAW;AACvD,cAAU,IAAIC,OAAK;AACnB,SAAK,IAAI,QAAQA,OAAK,CAAC;AAEvB,YAAQ,IAAI;KAAC,MAAM,MAAM,SAAS;KAAE,MAAM,MAAM,YAAY;KAAE,MAAM,MAAMD,YAAU;KAAC,CAAC,CAAC,WAAW;AAC9F,SAAI,WACA;AAEJ,kBAAa;AAEb,UAAK,MAAMC,UAAQ,KAAK,QAAQ,CAC5B,OAAM,QAAQ;MAAE,YAAYA;MAAM;MAAM;MAAW,MAAM;MAAW,CAAC;MAE3E;KAGJ;AAEF,SAAM,UAAU;IAAE;IAAW,QAAQ;IAAM,EAAE,OAAO,EAAE,mBAAW;AAC7D,QAAI,UAAU,IAAIA,OAAK,CACnB;AAEJ,cAAU,IAAIA,OAAK;IACnB,MAAM,QAAQ,MAAM,GAAG,QAAQA,OAAK,CA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T,MAAK,KAAc;YACZ,SAAS,OAChB,WAAQ,KAAc;;AAI9B,cAAYO,YAAU,CAAC,SAAS;;AAGpC,QAAO,MAAM,UAAU,MAAM,KAAK,QAAQ,QAAQ,CAAC,CAAC,MAAM,MAAM,EAAE,UAAU,EAAE,EAAE;AAC5E,SAAO,MAAM,QAAQ;GACjB,MAAM,OAAO,MAAM,OAAO;AAC1B,OAAI,CAAC,KACD;AAGJ,SAAM,YAAY,KAAK;;AAG3B,QAAM,QAAQ,IAAI,MAAM,KAAK,QAAQ,QAAQ,CAAC,CAAC,KAAK,MAAM,EAAE,QAAQ,CAAC;AACrE,QAAM,QAAQ,SAAS;;AAG3B,SAAQ,KAAK,YAAY,uBAAuB"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
2
|
let node_util = require("node:util");
|
|
3
3
|
node_util = require_chunk.__toESM(node_util);
|
|
4
|
+
let node_path = require("node:path");
|
|
5
|
+
node_path = require_chunk.__toESM(node_path);
|
|
4
6
|
let fast_glob = require("fast-glob");
|
|
5
7
|
fast_glob = require_chunk.__toESM(fast_glob);
|
|
6
8
|
let node_fs_promises = require("node:fs/promises");
|
|
7
9
|
node_fs_promises = require_chunk.__toESM(node_fs_promises);
|
|
8
|
-
let node_path = require("node:path");
|
|
9
|
-
node_path = require_chunk.__toESM(node_path);
|
|
10
10
|
let gettext_parser = require("gettext-parser");
|
|
11
11
|
gettext_parser = require_chunk.__toESM(gettext_parser);
|
|
12
12
|
let node_fs = require("node:fs");
|
|
@@ -711,7 +711,7 @@ function core() {
|
|
|
711
711
|
//#region src/plugins/po/collect.ts
|
|
712
712
|
function collect(source, locale) {
|
|
713
713
|
const translations = { "": {} };
|
|
714
|
-
const nplurals = locale ? (0, plural_forms.getNPlurals)(locale) : void 0;
|
|
714
|
+
const nplurals = locale ? Number((0, plural_forms.getNPlurals)(locale)) : void 0;
|
|
715
715
|
for (const { context, id, message, comments, obsolete, plural } of source) {
|
|
716
716
|
const ctx = context || "";
|
|
717
717
|
if (!translations[ctx]) translations[ctx] = {};
|
|
@@ -800,7 +800,7 @@ function merge(sources, existing, obsolete, locale, generatedAt) {
|
|
|
800
800
|
let headers = {};
|
|
801
801
|
let translations = { "": {} };
|
|
802
802
|
let obsoleteTranslations = {};
|
|
803
|
-
const nplurals = (0, plural_forms.getNPlurals)(locale);
|
|
803
|
+
const nplurals = Number((0, plural_forms.getNPlurals)(locale));
|
|
804
804
|
if (existing) {
|
|
805
805
|
headers = existing.headers ? structuredClone(existing.headers) : {};
|
|
806
806
|
translations = existing.translations ? structuredClone(existing.translations) : { "": {} };
|
|
@@ -1314,7 +1314,7 @@ function resolveStaticPlugin(item) {
|
|
|
1314
1314
|
async function getPaths(entrypoint) {
|
|
1315
1315
|
const pattern = entrypoint.entrypoint.replace(/\\/g, "/");
|
|
1316
1316
|
const paths = fast_glob.default.isDynamicPattern(pattern) ? await (0, fast_glob.default)(pattern, { onlyFiles: true }) : [entrypoint.entrypoint];
|
|
1317
|
-
return new Set(paths);
|
|
1317
|
+
return new Set(paths.map((path$1) => (0, node_path.resolve)(path$1)));
|
|
1318
1318
|
}
|
|
1319
1319
|
async function run(entrypoint, { config, logger }) {
|
|
1320
1320
|
const destination = entrypoint.destination ?? config.destination;
|
|
@@ -1357,15 +1357,16 @@ async function run(entrypoint, { config, logger }) {
|
|
|
1357
1357
|
return getDeferred(namespace$3).promise;
|
|
1358
1358
|
}
|
|
1359
1359
|
function source(path$1) {
|
|
1360
|
-
|
|
1360
|
+
const resolvedPath = (0, node_path.resolve)(path$1);
|
|
1361
|
+
if (paths.has(resolvedPath)) return;
|
|
1361
1362
|
logger?.debug({
|
|
1362
1363
|
entrypoint: entrypoint.entrypoint,
|
|
1363
|
-
path:
|
|
1364
|
+
path: resolvedPath
|
|
1364
1365
|
}, "resolved path");
|
|
1365
|
-
paths.add(
|
|
1366
|
+
paths.add(resolvedPath);
|
|
1366
1367
|
resolve$4({
|
|
1367
|
-
entrypoint:
|
|
1368
|
-
path:
|
|
1368
|
+
entrypoint: resolvedPath,
|
|
1369
|
+
path: resolvedPath,
|
|
1369
1370
|
namespace: "source"
|
|
1370
1371
|
});
|
|
1371
1372
|
}
|
package/dist/src/index.cjs
CHANGED
package/dist/src/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/run.ts"],"sourcesContent":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/run.ts"],"sourcesContent":[],"mappings":";;;;KAkBY,IAAA;EAAA,IAAA,EAAA,SAAI;EAAA,IAAA,EAGA,WAHA;;MAOA,EAAA,MAAA;MAIA,EAJA,QAIA;CAAW,GAAA;EASL,IAAA,EAAG,SAAA;EAAA,IAAA,EATT,WASS;;AAEnB,iBAFgB,GAAA,CAEhB,UAAA,EADU,kBACV,EAAA;EAAA,MAAA;EAAA;CAAA,EAAA;QAAQ,EAAoB,cAApB;QAAoB,CAAA,EAAyB,MAAzB;IAAiC,OAAR,CAAA,IAAA,CAAA"}
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/run.ts"],"sourcesContent":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/run.ts"],"sourcesContent":[],"mappings":";;;;KAkBY,IAAA;EAAA,IAAA,EAAA,SAAI;EAAA,IAAA,EAGA,WAHA;;MAOA,EAAA,MAAA;MAIA,EAJA,QAIA;CAAW,GAAA;EASL,IAAA,EAAG,SAAA;EAAA,IAAA,EATT,WASS;;AAEnB,iBAFgB,GAAA,CAEhB,UAAA,EADU,kBACV,EAAA;EAAA,MAAA;EAAA;CAAA,EAAA;QAAQ,EAAoB,cAApB;QAAoB,CAAA,EAAyB,MAAzB;IAAiC,OAAR,CAAA,IAAA,CAAA"}
|
package/dist/src/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@let-value/translate-extract",
|
|
3
|
-
"version": "1.1.2-beta.
|
|
3
|
+
"version": "1.1.2-beta.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"dist"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@let-value/translate": "1.1.2-beta.
|
|
37
|
+
"@let-value/translate": "1.1.2-beta.2",
|
|
38
38
|
"chalk": "5.3.0",
|
|
39
39
|
"cosmiconfig": "9.0.0",
|
|
40
40
|
"fast-glob": "3.3.2",
|
package/dist/run-Dc4eZUPV.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-Dc4eZUPV.js","names":["namespace","path","path","entrypointQuery: EntrypointSpec","importQuery: ImportQuerySpec","current: Parser.SyntaxNode | null","messageQuery: QuerySpec","allowed","messageInvalidQuery: QuerySpec","ids: string[]","strs: string[]","subMatch: Parser.QueryMatch","translation: Translation","contextMsgQuery: QuerySpec","msgCall","contextPluralQuery: QuerySpec","contextInvalidQuery: QuerySpec","gettextQuery: QuerySpec","gettextInvalidQuery: QuerySpec","msgCall","plainMsg","msgArg","ngettextQuery: QuerySpec","msgCall","npgettextQuery: QuerySpec","pgettextQuery: QuerySpec","pluralQuery: QuerySpec","queries: QuerySpec[]","messageQuery","pluralQuery","path","parseSource","context: Context","translations: Translation[]","warnings: Warning[]","imports: string[]","queries","fs","resolved: string[]","filter","namespace","path","parseSource","translations: GetTextTranslationRecord","value","normalizedHeaders: Record<string, string>","headers: Record<string, string>","translations: GetTextTranslationRecord","obsoleteTranslations: GetTextTranslationRecord","collected: GetTextTranslationRecord","translations","existing","path","parts: Part[]","text","strings: string[]","values: string[]","messageQuery: QuerySpec","attrs: Parser.SyntaxNode[]","msgctxt: string | undefined","childValue: Parser.SyntaxNode | undefined","error: string | undefined","translation: Translation","forms: string[]","pluralQuery: QuerySpec","attrs: Parser.SyntaxNode[]","msgctxt: string | undefined","formsNode: Parser.SyntaxNode | null | undefined","translation: Translation","queries: QuerySpec[]","context: Context","path","translations: Translation[]","warnings: Warning[]","path","context: Context","resolvers: { filter: Filter; hook: ResolveHook }[]","loaders: { filter: Filter; hook: LoadHook }[]","processors: { filter: Filter; hook: ProcessHook }[]","queue: Task[]","defer","namespace","path","resolve","process","build: Build","filter"],"sources":["../src/defer.ts","../src/plugins/cleanup/cleanup.ts","../src/plugins/core/queries/comment.ts","../src/plugins/core/queries/entrypoint.ts","../src/plugins/core/queries/import.ts","../src/plugins/core/queries/utils.ts","../src/plugins/core/queries/message.ts","../src/plugins/core/queries/plural-utils.ts","../src/plugins/core/queries/context.ts","../src/plugins/core/queries/gettext.ts","../src/plugins/core/queries/ngettext.ts","../src/plugins/core/queries/npgettext.ts","../src/plugins/core/queries/pgettext.ts","../src/plugins/core/queries/plural.ts","../src/plugins/core/queries/index.ts","../src/plugins/core/parse.ts","../src/plugins/core/resolve.ts","../src/plugins/core/core.ts","../src/plugins/po/collect.ts","../src/plugins/po/hasChanges.ts","../src/plugins/po/merge.ts","../src/plugins/po/po.ts","../src/plugins/react/queries/utils.ts","../src/plugins/react/queries/message.ts","../src/plugins/react/queries/plural.ts","../src/plugins/react/queries/index.ts","../src/plugins/react/parse.ts","../src/plugins/react/react.ts","../src/plugins/static.ts","../src/run.ts"],"sourcesContent":["export class Defer {\n pending = 0;\n promise: Promise<void> = Promise.resolve();\n resolve?: () => void;\n\n enqueue() {\n if (this.pending++ === 0) {\n this.promise = new Promise<void>((res) => {\n this.resolve = res;\n });\n }\n }\n dequeue() {\n if (this.pending > 0 && --this.pending === 0) {\n this.resolve?.();\n }\n }\n}\n","import fs from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\n\nimport * as gettextParser from \"gettext-parser\";\n\nimport type { Plugin } from \"../../plugin.ts\";\n\nconst namespace = \"cleanup\";\n\nexport function cleanup(): Plugin {\n return {\n name: \"cleanup\",\n setup(build) {\n build.context.logger?.debug(\"cleanup plugin initialized\");\n const processed = new Set<string>();\n const generated = new Set<string>();\n const dirs = new Set<string>();\n let dispatched = false;\n\n build.onResolve({ namespace, filter: /.*/ }, ({ path }) => {\n generated.add(path);\n dirs.add(dirname(path));\n\n Promise.all([build.defer(\"source\"), build.defer(\"translate\"), build.defer(namespace)]).then(() => {\n if (dispatched) {\n return;\n }\n dispatched = true;\n\n for (const path of dirs.values()) {\n build.process({ entrypoint: path, path, namespace, data: undefined });\n }\n });\n\n return undefined;\n });\n\n build.onProcess({ namespace, filter: /.*/ }, async ({ path }) => {\n if (processed.has(path)) {\n return undefined;\n }\n processed.add(path);\n const files = await fs.readdir(path).catch(() => []);\n for (const f of files.filter((p) => p.endsWith(\".po\"))) {\n const full = join(path, f);\n const contents = await fs.readFile(full).catch(() => undefined);\n if (!contents) {\n continue;\n }\n const parsed = gettextParser.po.parse(contents);\n const hasTranslations = Object.entries(parsed.translations || {}).some(([ctx, msgs]) =>\n Object.keys(msgs).some((id) => !(ctx === \"\" && id === \"\")),\n );\n if (!hasTranslations && generated.has(full)) {\n await fs.unlink(full);\n }\n if (hasTranslations && !generated.has(full)) {\n build.context.logger?.warn({ path: full }, \"stray translation file\");\n }\n }\n return undefined;\n });\n },\n };\n}\n","import { relative } from \"node:path\";\nimport type Parser from \"@keqingmoe/tree-sitter\";\n\nimport type { Context, QuerySpec } from \"./types.ts\";\n\nexport function getReference(node: Parser.SyntaxNode, { path }: Context) {\n const line = node.startPosition.row + 1;\n const rel = relative(process.cwd(), path).replace(/\\\\+/g, \"/\");\n return `${rel}:${line}`;\n}\n\nexport function getComment(node: Parser.SyntaxNode): string {\n const text = node.text;\n if (text.startsWith(\"/*\")) {\n return text\n .slice(2, -2)\n .replace(/^\\s*\\*?\\s*/gm, \"\")\n .trim();\n }\n return text.replace(/^\\/\\/\\s?/, \"\").trim();\n}\n\nexport const withComment = (query: QuerySpec): QuerySpec => ({\n pattern: `(\n\t((comment) @comment)?\n .\n\t(_ ${query.pattern})\n)`,\n extract(match) {\n const result = query.extract(match);\n if (!result?.translation) {\n return result;\n }\n\n const comment = match.captures.find((c) => c.name === \"comment\")?.node;\n if (!comment) {\n return result;\n }\n\n if (comment) {\n result.translation.comments = {\n ...result.translation.comments,\n extracted: getComment(comment),\n };\n }\n\n return result;\n },\n});\n","import type Parser from \"@keqingmoe/tree-sitter\";\nimport { getComment } from \"./comment.ts\";\nimport type { EntrypointSpec } from \"./types.ts\";\n\nconst entrypointCommentPattern = /(?:^|\\s)@?translate-entrypoint(?:\\s|$)/;\n\nexport const entrypointQuery: EntrypointSpec = {\n pattern: `(comment) @comment`,\n extract(match: Parser.QueryMatch): boolean | undefined {\n return match.captures\n .filter((capture) => capture.name === \"comment\")\n .some((capture) => entrypointCommentPattern.test(getComment(capture.node)));\n },\n};\n","import type Parser from \"@keqingmoe/tree-sitter\";\nimport type { ImportQuerySpec } from \"./types.ts\";\n\nexport const importQuery: ImportQuerySpec = {\n pattern: `\n [\n (import_statement\n source: (string (string_fragment) @import))\n (export_statement\n source: (string (string_fragment) @import))\n (call_expression\n function: (identifier) @func\n arguments: (arguments (string (string_fragment) @import))\n (#eq? @func \"require\"))\n (call_expression\n function: (member_expression\n object: (identifier) @obj\n property: (property_identifier) @method)\n arguments: (arguments (string (string_fragment) @import))\n (#eq? @obj \"require\")\n (#eq? @method \"resolve\"))\n (call_expression\n function: (import)\n arguments: (arguments (string (string_fragment) @import)))\n ]\n `,\n extract(match: Parser.QueryMatch): string | undefined {\n const node = match.captures.find((c) => c.name === \"import\")?.node;\n return node?.text;\n },\n};\n","import type Parser from \"@keqingmoe/tree-sitter\";\n\nexport const callPattern = (fnName: string, args: string, allowMember = true): string => `(\n (call_expression\n function: ${\n allowMember\n ? `[\n (identifier) @func\n (member_expression property: (property_identifier) @func)\n ]`\n : `(identifier) @func`\n }\n arguments: ${args}\n ) @call\n (#eq? @func \"${fnName}\")\n)`;\n\nexport function isDescendant(node: Parser.SyntaxNode, ancestor: Parser.SyntaxNode): boolean {\n let current: Parser.SyntaxNode | null = node;\n while (current) {\n if (current.id === ancestor.id) return true;\n current = current.parent;\n }\n return false;\n}\n","import type Parser from \"@keqingmoe/tree-sitter\";\nimport { withComment } from \"./comment.ts\";\nimport type { MessageMatch, QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nconst notInPlural = (query: QuerySpec): QuerySpec => ({\n pattern: query.pattern,\n extract(match) {\n const result = query.extract(match);\n if (!result?.node) {\n return result;\n }\n\n let parent = result.node.parent;\n\n if (parent && parent.type === \"arguments\") {\n parent = parent.parent;\n }\n\n if (parent && parent.type === \"call_expression\") {\n const fn = parent.childForFieldName(\"function\");\n if (fn) {\n if (\n (fn.type === \"identifier\" &&\n (fn.text === \"plural\" ||\n fn.text === \"ngettext\" ||\n fn.text === \"pgettext\" ||\n fn.text === \"npgettext\")) ||\n (fn.type === \"member_expression\" &&\n [\"plural\", \"ngettext\", \"pgettext\", \"npgettext\"].includes(\n fn.childForFieldName(\"property\")?.text ?? \"\",\n ))\n ) {\n return undefined;\n }\n }\n }\n\n return result;\n },\n});\n\nexport const messageArg = `[\n (string (string_fragment) @msgid)\n (object\n (_)*\n (pair\n key: (property_identifier) @id_key\n value: (string (string_fragment) @id)\n (#eq? @id_key \"id\")\n )?\n (_)*\n (pair\n key: (property_identifier) @msg_key\n value: (string (string_fragment) @message)\n (#eq? @msg_key \"message\")\n )?\n (_)*\n )\n (template_string) @tpl\n]`;\n\nexport const messageArgs = `[ (arguments ${messageArg}) (template_string) @tpl ]`;\n\nexport const extractMessage =\n (name: string) =>\n (match: Parser.QueryMatch): MessageMatch | undefined => {\n const node = match.captures.find((c) => c.name === \"call\")?.node;\n if (!node) {\n return undefined;\n }\n\n const msgid = match.captures.find((c) => c.name === \"msgid\")?.node.text;\n if (msgid) {\n return {\n node,\n translation: {\n id: msgid,\n message: [msgid],\n },\n };\n }\n\n const tpl = match.captures.find((c) => c.name === \"tpl\")?.node;\n if (tpl) {\n for (const child of tpl.children) {\n if (child.type !== \"template_substitution\") {\n continue;\n }\n\n const expr = child.namedChildren[0];\n if (!expr || expr.type !== \"identifier\") {\n return {\n node,\n error: `${name}() template expressions must be simple identifiers`,\n };\n }\n }\n\n const text = tpl.text.slice(1, -1);\n\n return {\n node,\n translation: { id: text, message: [text] },\n };\n }\n\n const id = match.captures.find((c) => c.name === \"id\")?.node.text;\n const message = match.captures.find((c) => c.name === \"message\")?.node.text;\n const msgId = id ?? message;\n if (!msgId) {\n return undefined;\n }\n\n const msgstr = message ?? id ?? \"\";\n\n return {\n node,\n translation: {\n id: msgId,\n message: [msgstr],\n },\n };\n };\n\nexport const messageQuery: QuerySpec = notInPlural(\n withComment({\n pattern: callPattern(\"message\", messageArgs),\n extract: extractMessage(\"message\"),\n }),\n);\n\nconst allowed = new Set([\"string\", \"object\", \"template_string\"]);\n\nexport const messageInvalidQuery: QuerySpec = notInPlural({\n pattern: callPattern(\"message\", \"(arguments (_) @arg)\"),\n extract(match) {\n const call = match.captures.find((c) => c.name === \"call\")?.node;\n const node = match.captures.find((c) => c.name === \"arg\")?.node;\n\n if (!call || !node) {\n return undefined;\n }\n\n if (allowed.has(node.type)) {\n return undefined;\n }\n\n return {\n node,\n error: \"message() argument must be a string literal, object literal, or template literal\",\n };\n },\n});\n","import type Parser from \"@keqingmoe/tree-sitter\";\nimport { extractMessage } from \"./message.ts\";\nimport type { MessageMatch, Translation } from \"./types.ts\";\nimport { isDescendant } from \"./utils.ts\";\n\nexport const extractPluralForms =\n (name: string) =>\n (match: Parser.QueryMatch): MessageMatch | undefined => {\n const call = match.captures.find((c) => c.name === \"call\")?.node;\n const n = match.captures.find((c) => c.name === \"n\")?.node;\n if (!call || !n || n.nextNamedSibling) {\n return undefined;\n }\n\n const msgctxt = match.captures.find((c) => c.name === \"msgctxt\")?.node?.text;\n const msgNodes = match.captures.filter((c) => c.name === \"msg\").map((c) => c.node);\n\n const ids: string[] = [];\n const strs: string[] = [];\n\n for (const node of msgNodes) {\n const relevant = match.captures.filter(\n (c) => [\"msgid\", \"id\", \"message\", \"tpl\"].includes(c.name) && isDescendant(c.node, node),\n );\n\n const subMatch: Parser.QueryMatch = {\n pattern: 0,\n captures: [{ name: \"call\", node }, ...relevant],\n };\n\n const result = extractMessage(name)(subMatch);\n if (!result) continue;\n if (result.error) {\n return { node: call, error: result.error };\n }\n if (result.translation) {\n ids.push(result.translation.id);\n strs.push(result.translation.message[0] ?? \"\");\n }\n }\n\n if (ids.length === 0) {\n return undefined;\n }\n\n const translation: Translation = {\n id: ids[0],\n plural: ids[1],\n message: strs,\n };\n if (msgctxt) translation.context = msgctxt;\n\n return { node: call, translation };\n };\n","import { withComment } from \"./comment.ts\";\nimport { extractMessage, messageArgs } from \"./message.ts\";\nimport { extractPluralForms } from \"./plural-utils.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nconst ctxCall = callPattern(\n \"context\",\n `[\n (arguments (string (string_fragment) @msgctxt))\n (template_string) @msgctxt\n]`,\n)\n .replace(/@call/g, \"@ctx\")\n .replace(/@func/g, \"@ctxfn\");\n\nexport const contextMsgQuery: QuerySpec = withComment({\n pattern: `(\n (call_expression\n function: (member_expression\n object: ${ctxCall}\n property: (property_identifier) @func\n )\n arguments: ${messageArgs}\n ) @call\n (#eq? @func \"message\")\n)`,\n extract(match) {\n const result = extractMessage(\"context.message\")(match);\n const contextNode = match.captures.find((c) => c.name === \"msgctxt\")?.node;\n if (!result || !result.translation || !contextNode) {\n return result;\n }\n\n if (contextNode.type === \"template_string\") {\n for (const child of contextNode.children) {\n if (child.type !== \"template_substitution\") {\n continue;\n }\n\n const expr = child.namedChildren[0];\n if (!expr || expr.type !== \"identifier\") {\n return {\n node: contextNode,\n error: \"context() template expressions must be simple identifiers\",\n };\n }\n }\n }\n\n const contextText = contextNode.type === \"template_string\" ? contextNode.text.slice(1, -1) : contextNode.text;\n return {\n node: result.node,\n translation: {\n ...result.translation,\n context: contextText,\n },\n };\n },\n});\n\nconst msgCall = callPattern(\"message\", messageArgs, false).replace(/@call/g, \"@msg\").replace(/@func/g, \"@msgfn\");\n\nexport const contextPluralQuery: QuerySpec = withComment({\n pattern: `(\n (call_expression\n function: (member_expression\n object: ${ctxCall}\n property: (property_identifier) @func\n )\n arguments: (arguments (\n (${msgCall} (\",\" )?)+\n (number) @n\n ))\n ) @call\n (#eq? @func \"plural\")\n)`,\n extract: extractPluralForms(\"context.plural\"),\n});\n\nexport const contextInvalidQuery: QuerySpec = withComment({\n pattern: ctxCall,\n extract(match) {\n const call = match.captures.find((c) => c.name === \"ctx\")?.node;\n if (!call) {\n return undefined;\n }\n\n const parent = call.parent;\n if (parent && parent.type === \"member_expression\" && parent.childForFieldName(\"object\")?.id === call.id) {\n const property = parent.childForFieldName(\"property\")?.text;\n const grandparent = parent.parent;\n if (\n grandparent &&\n grandparent.type === \"call_expression\" &&\n grandparent.childForFieldName(\"function\")?.id === parent.id &&\n (property === \"message\" || property === \"plural\")\n ) {\n return undefined;\n }\n }\n\n return {\n node: call,\n error: \"context() must be used with message() or plural() in the same expression\",\n };\n },\n});\n","import { withComment } from \"./comment.ts\";\nimport { extractMessage, messageArgs } from \"./message.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nexport const gettextQuery: QuerySpec = withComment({\n pattern: callPattern(\"gettext\", messageArgs),\n extract: extractMessage(\"gettext\"),\n});\n\nconst allowed = new Set([\"string\", \"object\", \"template_string\", \"identifier\", \"call_expression\"]);\n\nexport const gettextInvalidQuery: QuerySpec = {\n pattern: callPattern(\"gettext\", \"(arguments (_) @arg)\"),\n extract(match) {\n const call = match.captures.find((c) => c.name === \"call\")?.node;\n const node = match.captures.find((c) => c.name === \"arg\")?.node;\n\n if (!call || !node) {\n return undefined;\n }\n\n if (allowed.has(node.type)) {\n return undefined;\n }\n\n return {\n node,\n error: \"gettext() argument must be a string literal, object literal, or template literal\",\n };\n },\n};\n","import { withComment } from \"./comment.ts\";\nimport { messageArg, messageArgs } from \"./message.ts\";\nimport { extractPluralForms } from \"./plural-utils.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nconst msgCall = callPattern(\"message\", messageArgs).replace(/@call/g, \"@msg\").replace(/@func/g, \"@msgfn\");\nconst plainMsg = `(${messageArg}) @msg`;\nconst msgArg = `[${msgCall} ${plainMsg}]`;\n\nexport const ngettextQuery: QuerySpec = withComment({\n pattern: callPattern(\"ngettext\", `(arguments ${msgArg} \",\" ${msgArg} (\",\" ${msgArg})* \",\" (_) @n)`),\n extract: extractPluralForms(\"ngettext\"),\n});\n","import { withComment } from \"./comment.ts\";\nimport { messageArg, messageArgs } from \"./message.ts\";\nimport { extractPluralForms } from \"./plural-utils.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nconst msgCall = callPattern(\"message\", messageArgs).replace(/@call/g, \"@msg\").replace(/@func/g, \"@msgfn\");\nconst plainMsg = `(${messageArg}) @msg`;\nconst msgArg = `[${msgCall} ${plainMsg}]`;\n\nexport const npgettextQuery: QuerySpec = withComment({\n pattern: callPattern(\n \"npgettext\",\n `(arguments (string (string_fragment) @msgctxt) \",\" ${msgArg} \",\" ${msgArg} (\",\" ${msgArg})* \",\" (_) @n)`,\n ),\n extract: extractPluralForms(\"npgettext\"),\n});\n","import { withComment } from \"./comment.ts\";\nimport { extractMessage, messageArg } from \"./message.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nexport const pgettextQuery: QuerySpec = withComment({\n pattern: callPattern(\"pgettext\", `(arguments (string (string_fragment) @msgctxt) \",\" ${messageArg})`),\n extract(match) {\n const result = extractMessage(\"pgettext\")(match);\n const contextNode = match.captures.find((c) => c.name === \"msgctxt\")?.node;\n if (!result || !contextNode || !result.translation) {\n return result;\n }\n return {\n node: result.node,\n translation: {\n ...result.translation,\n context: contextNode.text,\n },\n };\n },\n});\n","import { withComment } from \"./comment.ts\";\nimport { messageArgs } from \"./message.ts\";\nimport { extractPluralForms } from \"./plural-utils.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nconst msgCall = callPattern(\"message\", messageArgs, false).replace(/@call/g, \"@msg\").replace(/@func/g, \"@msgfn\");\n\nexport const pluralQuery: QuerySpec = withComment({\n pattern: callPattern(\n \"plural\",\n `(arguments (\n (${msgCall} (\",\" )?)+\n (number) @n\n ))`,\n false,\n ),\n extract: extractPluralForms(\"plural\"),\n});\n","import { contextInvalidQuery, contextMsgQuery, contextPluralQuery } from \"./context.ts\";\nimport { gettextInvalidQuery, gettextQuery } from \"./gettext.ts\";\nimport { messageInvalidQuery, messageQuery } from \"./message.ts\";\nimport { ngettextQuery } from \"./ngettext.ts\";\nimport { npgettextQuery } from \"./npgettext.ts\";\nimport { pgettextQuery } from \"./pgettext.ts\";\nimport { pluralQuery } from \"./plural.ts\";\nimport type { QuerySpec } from \"./types.ts\";\n\nexport type { MessageMatch, QuerySpec } from \"./types.ts\";\n\nexport const queries: QuerySpec[] = [\n contextMsgQuery,\n contextPluralQuery,\n contextInvalidQuery,\n messageQuery,\n messageInvalidQuery,\n gettextQuery,\n gettextInvalidQuery,\n pluralQuery,\n ngettextQuery,\n pgettextQuery,\n npgettextQuery,\n];\n","import fs from \"node:fs\";\nimport { extname, resolve } from \"node:path\";\n\nimport Parser from \"@keqingmoe/tree-sitter\";\nimport JavaScript from \"tree-sitter-javascript\";\nimport TS from \"tree-sitter-typescript\";\n\nimport { getReference } from \"./queries/comment.ts\";\nimport { entrypointQuery } from \"./queries/entrypoint.ts\";\nimport { importQuery } from \"./queries/import.ts\";\nimport { queries } from \"./queries/index.ts\";\nimport type { Context, Translation, Warning } from \"./queries/types.ts\";\n\nexport interface ParseResult {\n translations: Translation[];\n imports: string[];\n warnings: Warning[];\n entrypoint: boolean;\n}\n\nfunction getLanguage(ext: string) {\n switch (ext) {\n case \".ts\":\n return TS.typescript;\n case \".tsx\":\n return TS.tsx;\n default:\n return JavaScript;\n }\n}\n\nconst parserCache = new Map<string, { parser: Parser; language: Parser.Language }>();\nconst queryCache = new WeakMap<Parser.Language, Map<string, Parser.Query>>();\n\nfunction getCachedParser(ext: string) {\n let cached = parserCache.get(ext);\n if (!cached) {\n const parser = new Parser();\n const language = getLanguage(ext) as Parser.Language;\n parser.setLanguage(language);\n cached = { parser, language };\n parserCache.set(ext, cached);\n }\n return cached;\n}\n\nfunction getCachedQuery(language: Parser.Language, pattern: string) {\n let cache = queryCache.get(language);\n if (!cache) {\n cache = new Map();\n queryCache.set(language, cache);\n }\n\n let query = cache.get(pattern);\n if (!query) {\n query = new Parser.Query(language, pattern);\n cache.set(pattern, query);\n }\n\n return query;\n}\n\nexport function getParser(path: string) {\n const ext = extname(path);\n return getCachedParser(ext);\n}\n\nexport function getQuery(language: Parser.Language, pattern: string) {\n return getCachedQuery(language, pattern);\n}\n\nexport function parseFile(filePath: string): ParseResult {\n const path = resolve(filePath);\n const source = fs.readFileSync(path, \"utf8\");\n return parseSource(source, path);\n}\n\nexport function parseSource(source: string, path: string): ParseResult {\n const context: Context = {\n path,\n };\n\n const { parser, language } = getParser(path);\n const tree = parser.parse(source);\n\n const commentQuery = getCachedQuery(language, entrypointQuery.pattern);\n const entrypoint = commentQuery.matches(tree.rootNode).some(entrypointQuery.extract);\n\n const translations: Translation[] = [];\n const warnings: Warning[] = [];\n const imports: string[] = [];\n\n const seen = new Set<number>();\n\n for (const spec of queries) {\n const query = getCachedQuery(language, spec.pattern);\n for (const match of query.matches(tree.rootNode)) {\n const message = spec.extract(match);\n if (!message) {\n continue;\n }\n\n const { node, translation, error } = message;\n if (seen.has(node.id)) {\n continue;\n }\n seen.add(node.id);\n const reference = getReference(node, context);\n\n if (translation) {\n translations.push({\n ...translation,\n comments: {\n ...translation.comments,\n reference,\n },\n });\n }\n\n if (error) {\n warnings.push({\n error,\n reference,\n });\n }\n }\n }\n\n const importTreeQuery = getCachedQuery(language, importQuery.pattern);\n for (const match of importTreeQuery.matches(tree.rootNode)) {\n const imp = importQuery.extract(match);\n if (imp) {\n imports.push(imp);\n }\n }\n\n return { translations, imports, warnings, entrypoint };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { ResolverFactory } from \"oxc-resolver\";\n\nfunction findTsconfig(dir: string): string | undefined {\n let current = dir;\n while (true) {\n const config = path.join(current, \"tsconfig.json\");\n if (fs.existsSync(config)) {\n return config;\n }\n const parent = path.dirname(current);\n if (parent === current) {\n return undefined;\n }\n current = parent;\n }\n}\n\nconst resolverCache = new Map<string, ResolverFactory>();\n\nfunction getResolver(dir: string) {\n const tsconfig = findTsconfig(dir);\n const key = tsconfig ?? \"__default__\";\n let resolver = resolverCache.get(key);\n if (!resolver) {\n resolver = new ResolverFactory({\n extensions: [\".ts\", \".tsx\", \".js\", \".jsx\", \".mjs\", \".cjs\", \".json\"],\n conditionNames: [\"import\", \"require\", \"node\"],\n ...(tsconfig ? { tsconfig: { configFile: tsconfig } } : {}),\n });\n resolverCache.set(key, resolver);\n }\n return resolver;\n}\n\nfunction resolveFromDir(dir: string, spec: string): string | undefined {\n const resolver = getResolver(dir);\n const res = resolver.sync(dir, spec) as { path?: string };\n return res.path;\n}\n\nexport function resolveImport(file: string, spec: string): string | undefined {\n const dir = path.dirname(path.resolve(file));\n return resolveFromDir(dir, spec);\n}\n\nexport function resolveImports(file: string, imports: string[]): string[] {\n const dir = path.dirname(path.resolve(file));\n const resolver = getResolver(dir);\n const resolved: string[] = [];\n for (const spec of imports) {\n const res = resolver.sync(dir, spec) as { path?: string };\n if (res.path) {\n resolved.push(res.path);\n }\n }\n return resolved;\n}\n","import { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\n\nimport type { Plugin } from \"../../plugin.ts\";\nimport { parseSource } from \"./parse.ts\";\nimport type { Translation } from \"./queries/types.ts\";\nimport { resolveImports } from \"./resolve.ts\";\n\nconst filter = /\\.([cm]?tsx?|jsx?)$/;\nconst namespace = \"source\";\n\nexport function core(): Plugin<string, Translation[]> {\n return {\n name: \"core\",\n setup(build) {\n build.context.logger?.debug(\"core plugin initialized\");\n build.onResolve({ filter, namespace }, ({ entrypoint, path }) => {\n return {\n entrypoint,\n namespace,\n path: resolve(path),\n };\n });\n\n build.onLoad({ filter, namespace }, async ({ entrypoint, path }) => {\n const data = await readFile(path, \"utf8\");\n return {\n entrypoint,\n path,\n namespace,\n data,\n };\n });\n\n build.onProcess({ filter, namespace }, ({ entrypoint, path, data }) => {\n const result = parseSource(data, path);\n\n if (result.entrypoint && entrypoint !== path) {\n build.source(path);\n return;\n }\n\n const { translations, imports, warnings } = result;\n\n if (build.context.config.walk) {\n const paths = resolveImports(path, imports);\n for (const path of paths) {\n if (build.context.paths.has(path)) {\n continue;\n }\n\n build.resolve({ entrypoint, path, namespace });\n }\n }\n\n for (const warning of warnings) {\n build.context.logger?.warn(`${warning.error} at ${warning.reference}`);\n }\n\n build.resolve({\n entrypoint,\n path,\n namespace: \"translate\",\n data: translations,\n });\n\n return undefined;\n });\n },\n };\n}\n","import type { GetTextTranslationRecord } from \"gettext-parser\";\nimport { getNPlurals } from \"plural-forms\";\n\nimport type { Translation } from \"../core/queries/types.ts\";\n\nexport function collect(source: Translation[], locale?: string): GetTextTranslationRecord {\n const translations: GetTextTranslationRecord = { \"\": {} };\n const nplurals = locale ? getNPlurals(locale) : undefined;\n\n for (const { context, id, message, comments, obsolete, plural } of source) {\n const ctx = context || \"\";\n if (!translations[ctx]) {\n translations[ctx] = {};\n }\n\n const length = plural ? (nplurals ?? message.length) : 1;\n\n const existing = translations[ctx][id];\n const refs = new Set<string>();\n if (existing?.comments?.reference) {\n existing.comments.reference.split(/\\r?\\n|\\r/).forEach((r) => {\n refs.add(r);\n });\n }\n if (comments?.reference) {\n comments.reference.split(/\\r?\\n|\\r/).forEach((r) => {\n refs.add(r);\n });\n }\n\n const msgstr = existing?.msgstr ? existing.msgstr.slice(0, length) : Array.from({ length }, () => \"\");\n while (msgstr.length < length) msgstr.push(\"\");\n\n translations[ctx][id] = {\n msgctxt: context || undefined,\n msgid: id,\n msgid_plural: plural,\n msgstr,\n comments: {\n ...existing?.comments,\n ...comments,\n reference: refs.size ? Array.from(refs).join(\"\\n\") : undefined,\n },\n obsolete: existing?.obsolete ?? obsolete,\n };\n }\n\n return translations;\n}\n","import { isDeepStrictEqual } from \"node:util\";\nimport type { GetTextTranslations } from \"gettext-parser\";\nimport * as gettextParser from \"gettext-parser\";\n\nconst IGNORED_HEADER_KEYS = new Set([\"pot-creation-date\", \"po-revision-date\"]);\nconst IGNORED_HEADER_LINE_PREFIXES = [\"pot-creation-date:\", \"po-revision-date:\"];\n\nfunction normalizeHeaderString(value: string): string {\n const lines = value.split(\"\\n\");\n const hadTrailingNewline = value.endsWith(\"\\n\");\n\n const filtered = lines\n .filter((line) => {\n const trimmed = line.trimStart().toLowerCase();\n return !IGNORED_HEADER_LINE_PREFIXES.some((prefix) => trimmed.startsWith(prefix));\n })\n .map((line) => {\n const separatorIndex = line.indexOf(\":\");\n if (separatorIndex === -1) {\n return line;\n }\n\n const key = line.slice(0, separatorIndex).trim().toLowerCase();\n const value = line.slice(separatorIndex + 1);\n return `${key}:${value}`;\n });\n\n if (hadTrailingNewline && filtered[filtered.length - 1] !== \"\") {\n filtered.push(\"\");\n }\n\n return filtered.join(\"\\n\");\n}\n\nfunction normalize(translations: GetTextTranslations): GetTextTranslations {\n const compiled = gettextParser.po.compile(translations);\n const parsed = gettextParser.po.parse(compiled);\n\n if (parsed.headers) {\n const normalizedHeaders: Record<string, string> = {};\n for (const [key, value] of Object.entries(parsed.headers)) {\n if (!IGNORED_HEADER_KEYS.has(key.toLowerCase())) {\n normalizedHeaders[key.toLowerCase()] = value as string;\n }\n }\n parsed.headers = normalizedHeaders;\n }\n\n const headerMessage = parsed.translations?.[\"\"]?.[\"\"];\n if (headerMessage?.msgstr) {\n headerMessage.msgstr = headerMessage.msgstr.map((item) => normalizeHeaderString(item));\n }\n\n return parsed;\n}\n\nexport function hasChanges(left: GetTextTranslations, right?: GetTextTranslations): boolean {\n if (!right) {\n return true;\n }\n\n const normalizedLeft = normalize(left);\n const normalizedRight = normalize(right);\n\n return !isDeepStrictEqual(normalizedLeft, normalizedRight);\n}\n","import type { GetTextTranslationRecord, GetTextTranslations } from \"gettext-parser\";\nimport { getFormula, getNPlurals } from \"plural-forms\";\n\nimport type { ObsoleteStrategy } from \"../../configuration.ts\";\n\nexport interface Collected {\n translations: GetTextTranslationRecord;\n}\n\nexport function formatDate(date: Date): string {\n const pad = (n: number) => n.toString().padStart(2, \"0\");\n const year = date.getFullYear();\n const month = pad(date.getMonth() + 1);\n const day = pad(date.getDate());\n const hours = pad(date.getHours());\n const minutes = pad(date.getMinutes());\n const tzo = -date.getTimezoneOffset();\n const sign = tzo >= 0 ? \"+\" : \"-\";\n const offsetHours = pad(Math.floor(Math.abs(tzo) / 60));\n const offsetMinutes = pad(Math.abs(tzo) % 60);\n return `${year}-${month}-${day} ${hours}:${minutes}${sign}${offsetHours}${offsetMinutes}`;\n}\n\nexport function merge(\n sources: Collected[],\n existing: GetTextTranslations | undefined,\n obsolete: ObsoleteStrategy,\n locale: string,\n generatedAt: Date,\n): GetTextTranslations {\n let headers: Record<string, string> = {};\n let translations: GetTextTranslationRecord = { \"\": {} };\n let obsoleteTranslations: GetTextTranslationRecord = {};\n const nplurals = getNPlurals(locale);\n\n if (existing) {\n headers = existing.headers ? structuredClone(existing.headers) : {};\n translations = existing.translations ? structuredClone(existing.translations) : { \"\": {} };\n obsoleteTranslations = existing.obsolete ? structuredClone(existing.obsolete) : {};\n for (const ctx of Object.keys(translations)) {\n for (const id of Object.keys(translations[ctx])) {\n if (ctx === \"\" && id === \"\") continue;\n translations[ctx][id].obsolete = true;\n }\n }\n }\n\n const collected: GetTextTranslationRecord = { \"\": {} };\n for (const { translations } of sources) {\n for (const [ctx, msgs] of Object.entries(translations)) {\n if (!collected[ctx]) collected[ctx] = {};\n for (const [id, entry] of Object.entries(msgs)) {\n const existing = collected[ctx][id];\n const refs = new Set<string>();\n if (existing?.comments?.reference) {\n existing.comments.reference.split(/\\r?\\n|\\r/).forEach((r) => {\n refs.add(r);\n });\n }\n if (entry.comments?.reference) {\n entry.comments.reference.split(/\\r?\\n|\\r/).forEach((r) => {\n refs.add(r);\n });\n }\n collected[ctx][id] = {\n ...existing,\n ...entry,\n comments: {\n ...existing?.comments,\n ...entry.comments,\n reference: refs.size ? Array.from(refs).join(\"\\n\") : undefined,\n },\n };\n }\n }\n }\n\n for (const [ctx, msgs] of Object.entries(collected)) {\n if (!translations[ctx]) translations[ctx] = {};\n for (const [id, entry] of Object.entries(msgs)) {\n const existingEntry = translations[ctx][id] ?? obsoleteTranslations[ctx]?.[id];\n if (existingEntry) {\n entry.msgstr = existingEntry.msgstr;\n entry.comments = {\n ...entry.comments,\n translator: existingEntry.comments?.translator,\n };\n }\n delete entry.obsolete;\n entry.msgstr = entry.msgstr.slice(0, nplurals);\n while (entry.msgstr.length < nplurals) {\n entry.msgstr.push(\"\");\n }\n translations[ctx][id] = entry;\n if (obsoleteTranslations[ctx]) {\n delete obsoleteTranslations[ctx][id];\n }\n }\n }\n\n for (const ctx of Object.keys(translations)) {\n for (const id of Object.keys(translations[ctx])) {\n if (ctx === \"\" && id === \"\") {\n continue;\n }\n const entry = translations[ctx][id];\n if (entry.obsolete) {\n if (!obsoleteTranslations[ctx]) {\n obsoleteTranslations[ctx] = {};\n }\n obsoleteTranslations[ctx][id] = entry;\n delete translations[ctx][id];\n }\n }\n }\n\n headers = {\n ...headers,\n \"Content-Type\": headers[\"Content-Type\"] || \"text/plain; charset=UTF-8\",\n \"Plural-Forms\": `nplurals=${nplurals}; plural=${getFormula(locale)};`,\n language: locale,\n \"MIME-Version\": \"1.0\",\n \"Content-Transfer-Encoding\": \"8bit\",\n \"POT-Creation-Date\": formatDate(generatedAt),\n \"x-generator\": \"@let-value/translate-extract\",\n };\n\n return {\n charset: \"utf-8\",\n headers,\n translations,\n ...(obsolete === \"mark\" && Object.keys(obsoleteTranslations).length ? { obsolete: obsoleteTranslations } : {}),\n };\n}\n","import fs from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\nimport * as gettextParser from \"gettext-parser\";\n\nimport type { Plugin } from \"../../plugin.ts\";\nimport type { Translation } from \"../core/queries/types.ts\";\nimport { collect } from \"./collect.ts\";\nimport { hasChanges } from \"./hasChanges.ts\";\nimport { merge } from \"./merge.ts\";\n\nconst namespace = \"translate\";\n\nexport function po(): Plugin {\n return {\n name: \"po\",\n setup(build) {\n build.context.logger?.debug(\"po plugin initialized\");\n const collections = new Map<\n string,\n {\n locale: string;\n translations: Translation[];\n }\n >();\n let dispatched = false;\n\n build.onResolve({ filter: /.*/, namespace }, async ({ entrypoint, path, data }) => {\n if (!data || !Array.isArray(data)) {\n return undefined;\n }\n\n for (const locale of build.context.config.locales) {\n const destination = build.context.config.destination({ entrypoint, locale, path });\n if (!collections.has(destination)) {\n collections.set(destination, { locale, translations: [] });\n }\n\n collections.get(destination)?.translations.push(...data);\n }\n\n Promise.all([build.defer(\"source\"), build.defer(namespace)]).then(() => {\n if (dispatched) {\n return;\n }\n dispatched = true;\n\n for (const path of collections.keys()) {\n build.load({ entrypoint, path, namespace });\n }\n });\n\n return undefined;\n });\n\n build.onLoad({ filter: /.*\\.po$/, namespace }, async ({ entrypoint, path }) => {\n const contents = await fs.readFile(path).catch(() => undefined);\n const data = contents ? gettextParser.po.parse(contents) : undefined;\n return {\n entrypoint,\n path,\n namespace,\n data,\n };\n });\n\n build.onProcess({ filter: /.*\\.po$/, namespace }, async ({ entrypoint, path, data }) => {\n const collected = collections.get(path);\n if (!collected) {\n build.context.logger?.warn({ path }, \"no translations collected for this path\");\n return undefined;\n }\n\n const { locale, translations } = collected;\n\n const record = collect(translations, locale);\n\n const out = merge(\n [{ translations: record }],\n data as never,\n build.context.config.obsolete,\n locale,\n build.context.generatedAt,\n );\n\n if (hasChanges(out, data as never)) {\n await fs.mkdir(dirname(path), { recursive: true });\n await fs.writeFile(path, gettextParser.po.compile(out));\n }\n\n build.resolve({\n entrypoint,\n path,\n namespace: \"cleanup\",\n data: translations,\n });\n });\n },\n };\n}\n","import type Parser from \"@keqingmoe/tree-sitter\";\n\nexport function buildTemplate(node: Parser.SyntaxNode): { text: string; error?: string } {\n const source = node.tree.rootNode.text;\n const open = node.childForFieldName(\"open_tag\");\n const close = node.childForFieldName(\"close_tag\");\n const contentStart = open?.endIndex ?? node.startIndex;\n const contentEnd = close?.startIndex ?? node.endIndex;\n\n type Part = { kind: \"text\"; text: string; raw: boolean } | { kind: \"expr\"; value: string };\n\n const parts: Part[] = [];\n let segmentStart = contentStart;\n\n const pushRawText = (endIndex: number) => {\n if (endIndex <= segmentStart) {\n segmentStart = Math.max(segmentStart, endIndex);\n return;\n }\n const text = source.slice(segmentStart, endIndex);\n if (text) {\n parts.push({ kind: \"text\", text, raw: true });\n }\n segmentStart = endIndex;\n };\n\n const children = node.namedChildren.slice(1, -1);\n for (const child of children) {\n if (child.type === \"jsx_expression\") {\n pushRawText(child.startIndex);\n const expr = child.namedChildren[0];\n if (!expr) {\n return { text: \"\", error: \"Empty JSX expression\" };\n }\n\n if (expr.type === \"identifier\") {\n parts.push({ kind: \"expr\", value: expr.text });\n } else if (expr.type === \"string\") {\n parts.push({ kind: \"text\", text: expr.text.slice(1, -1), raw: false });\n } else if (expr.type === \"template_string\") {\n const hasSubstitutions = expr.children.some((c) => c.type === \"template_substitution\");\n if (hasSubstitutions) {\n return { text: \"\", error: \"JSX expressions with template substitutions are not supported\" };\n }\n parts.push({ kind: \"text\", text: expr.text.slice(1, -1), raw: false });\n } else {\n return { text: \"\", error: \"JSX expressions must be simple identifiers, strings, or template literals\" };\n }\n segmentStart = child.endIndex;\n } else if (child.type === \"string\") {\n pushRawText(child.startIndex);\n parts.push({ kind: \"text\", text: child.text.slice(1, -1), raw: false });\n segmentStart = child.endIndex;\n } else if (child.type === \"jsx_text\" || child.type === \"html_character_reference\" || child.isError) {\n } else {\n return { text: \"\", error: \"Unsupported JSX child\" };\n }\n }\n\n pushRawText(contentEnd);\n\n const firstRawIndex = parts.findIndex((part) => part.kind === \"text\" && part.raw);\n if (firstRawIndex === 0) {\n const part = parts[firstRawIndex] as Extract<Part, { kind: \"text\" }>;\n part.text = part.text.replace(/^\\s+/, \"\");\n }\n\n let lastRawIndex = -1;\n for (let i = parts.length - 1; i >= 0; i--) {\n const part = parts[i];\n if (part.kind === \"text\" && part.raw) {\n lastRawIndex = i;\n break;\n }\n }\n if (lastRawIndex !== -1 && lastRawIndex === parts.length - 1) {\n const part = parts[lastRawIndex] as Extract<Part, { kind: \"text\" }>;\n part.text = part.text.replace(/\\s+$/, \"\");\n }\n\n const strings: string[] = [\"\"];\n const values: string[] = [];\n for (const part of parts) {\n if (part.kind === \"text\") {\n if (part.text) {\n strings[strings.length - 1] += part.text;\n }\n } else {\n values.push(part.value);\n strings.push(\"\");\n }\n }\n\n let text = \"\";\n for (let i = 0; i < strings.length; i++) {\n text += strings[i];\n if (values[i]) {\n text += `\\${${values[i]}}`;\n }\n }\n return { text };\n}\n\nexport function buildAttrValue(node: Parser.SyntaxNode): { text: string; error?: string } {\n if (node.type === \"string\") {\n return { text: node.text.slice(1, -1) };\n }\n if (node.type === \"jsx_expression\") {\n const expr = node.namedChildren[0];\n if (!expr) {\n return { text: \"\", error: \"Empty JSX expression\" };\n }\n\n if (expr.type === \"identifier\") {\n return { text: `\\${${expr.text}}` };\n } else if (expr.type === \"string\") {\n return { text: expr.text.slice(1, -1) };\n } else if (expr.type === \"template_string\") {\n // Check if it's a simple template string with no substitutions\n const hasSubstitutions = expr.children.some((c) => c.type === \"template_substitution\");\n if (hasSubstitutions) {\n return { text: \"\", error: \"JSX expressions with template substitutions are not supported\" };\n }\n // Extract the text content from the template string\n const content = expr.text.slice(1, -1); // Remove backticks\n return { text: content };\n } else {\n return { text: \"\", error: \"JSX expressions must be simple identifiers, strings, or template literals\" };\n }\n }\n return { text: \"\", error: \"Unsupported JSX child\" };\n}\n","import type Parser from \"@keqingmoe/tree-sitter\";\n\nimport { withComment } from \"../../core/queries/comment.ts\";\nimport type { MessageMatch, QuerySpec, Translation } from \"../../core/queries/types.ts\";\nimport { buildAttrValue, buildTemplate } from \"./utils.ts\";\n\nexport const messageQuery: QuerySpec = withComment({\n pattern: `(\n [\n (jsx_element (jsx_opening_element name: (identifier) @name)) @call\n (jsx_self_closing_element name: (identifier) @name) @call\n (lexical_declaration \n (variable_declarator \n value: [\n (jsx_element (jsx_opening_element name: (identifier) @name)) @call\n (jsx_self_closing_element name: (identifier) @name) @call\n ]\n )\n )\n ]\n (#eq? @name \"Message\")\n )`,\n extract(match: Parser.QueryMatch): MessageMatch | undefined {\n const node = match.captures.find((c) => c.name === \"call\")?.node;\n if (!node) return undefined;\n let attrs: Parser.SyntaxNode[] = [];\n if (node.type === \"jsx_element\") {\n const open = node.childForFieldName(\"open_tag\");\n if (open) attrs = open.namedChildren;\n } else if (node.type === \"jsx_self_closing_element\") {\n attrs = node.namedChildren.slice(1);\n }\n let msgctxt: string | undefined;\n let childValue: Parser.SyntaxNode | undefined;\n for (const child of attrs) {\n if (child.type !== \"jsx_attribute\") continue;\n const name = child.child(0);\n const value = child.child(child.childCount - 1);\n if (name?.text === \"context\" && value?.type === \"string\") {\n msgctxt = value.text.slice(1, -1);\n } else if (name?.text === \"children\" && value) {\n childValue = value;\n }\n }\n let text = \"\";\n let error: string | undefined;\n if (node.type === \"jsx_element\") {\n ({ text, error } = buildTemplate(node));\n } else if (childValue) {\n ({ text, error } = buildAttrValue(childValue));\n }\n if (error) {\n return { node, error };\n }\n if (!text) return undefined;\n const translation: Translation = {\n id: text,\n message: [text],\n };\n if (msgctxt) translation.context = msgctxt;\n return { node, translation };\n },\n});\n","import type Parser from \"@keqingmoe/tree-sitter\";\n\nimport { withComment } from \"../../core/queries/comment.ts\";\nimport type { MessageMatch, QuerySpec, Translation } from \"../../core/queries/types.ts\";\nimport { buildTemplate } from \"./utils.ts\";\n\nfunction parseForms(node: Parser.SyntaxNode): { forms: string[]; error?: string } {\n const forms: string[] = [];\n if (node.type === \"jsx_expression\") {\n const arr = node.namedChildren[0];\n if (!arr || arr.type !== \"array\") {\n return { forms: [], error: \"Plural forms must be an array\" };\n }\n for (const el of arr.namedChildren) {\n if (el.type === \"jsx_element\" || el.type === \"jsx_fragment\") {\n const { text, error } = buildTemplate(el);\n if (error) return { forms: [], error };\n forms.push(text);\n } else if (el.type === \"string\") {\n forms.push(el.text.slice(1, -1));\n } else {\n return { forms: [], error: \"Unsupported plural form\" };\n }\n }\n }\n return { forms };\n}\n\nexport const pluralQuery: QuerySpec = withComment({\n pattern: `(\n [\n (jsx_element (jsx_opening_element name: (identifier) @name))\n (jsx_self_closing_element name: (identifier) @name)\n ] @call\n (#eq? @name \"Plural\")\n )`,\n extract(match: Parser.QueryMatch): MessageMatch | undefined {\n const node = match.captures.find((c) => c.name === \"call\")?.node;\n if (!node) return undefined;\n let attrs: Parser.SyntaxNode[] = [];\n if (node.type === \"jsx_element\") {\n const open = node.childForFieldName(\"open_tag\");\n if (open) attrs = open.namedChildren;\n } else if (node.type === \"jsx_self_closing_element\") {\n attrs = node.namedChildren.slice(1);\n }\n let msgctxt: string | undefined;\n let formsNode: Parser.SyntaxNode | null | undefined;\n for (const child of attrs) {\n if (child.type !== \"jsx_attribute\") continue;\n const name = child.child(0);\n const value = child.child(child.childCount - 1);\n if (name?.text === \"context\" && value?.type === \"string\") {\n msgctxt = value.text.slice(1, -1);\n } else if (name?.text === \"forms\" && value) {\n formsNode = value;\n }\n }\n if (!formsNode) return undefined;\n const { forms, error } = parseForms(formsNode);\n if (error) {\n return { node, error };\n }\n if (forms.length === 0) return undefined;\n const translation: Translation = {\n id: forms[0],\n plural: forms[1],\n message: forms,\n };\n if (msgctxt) translation.context = msgctxt;\n return { node, translation };\n },\n});\n","import type { QuerySpec } from \"../../core/queries/types.ts\";\nimport { messageQuery } from \"./message.ts\";\nimport { pluralQuery } from \"./plural.ts\";\n\nexport const queries: QuerySpec[] = [messageQuery, pluralQuery];\n","import fs from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { getParser, getQuery } from \"../core/parse.ts\";\nimport { getReference } from \"../core/queries/comment.ts\";\n\nimport type { Context, Translation, Warning } from \"../core/queries/types.ts\";\nimport { queries } from \"./queries/index.ts\";\n\nexport interface ParseResult {\n translations: Translation[];\n warnings: Warning[];\n}\n\nexport function parseFile(filePath: string): ParseResult {\n const path = resolve(filePath);\n const source = fs.readFileSync(path, \"utf8\");\n return parseSource(source, path);\n}\n\nexport function parseSource(source: string, path: string): ParseResult {\n const context: Context = { path };\n const { parser, language } = getParser(path);\n const tree = parser.parse(source);\n\n const translations: Translation[] = [];\n const warnings: Warning[] = [];\n const seen = new Set<number>();\n\n for (const spec of queries) {\n const query = getQuery(language, spec.pattern);\n for (const match of query.matches(tree.rootNode)) {\n const message = spec.extract(match);\n if (!message) continue;\n const { node, translation, error } = message;\n if (seen.has(node.id)) continue;\n seen.add(node.id);\n const reference = getReference(node, context);\n if (translation) {\n translations.push({\n ...translation,\n comments: {\n ...translation.comments,\n reference,\n },\n });\n }\n if (error) {\n warnings.push({\n error,\n reference,\n });\n }\n }\n }\n\n return { translations, warnings };\n}\n","import { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\n\nimport type { Plugin } from \"../../plugin.ts\";\nimport type { Translation } from \"../core/queries/types.ts\";\nimport { parseSource } from \"./parse.ts\";\n\nconst filter = /\\.[cm]?[jt]sx$/;\n\nexport function react(): Plugin<string, Translation[]> {\n return {\n name: \"react\",\n setup(build) {\n build.context.logger?.debug(\"react plugin initialized\");\n build.onResolve({ filter: /.*/, namespace: \"source\" }, ({ entrypoint, path, namespace }) => {\n return {\n entrypoint,\n namespace,\n path: resolve(path),\n };\n });\n build.onLoad({ filter, namespace: \"source\" }, async ({ entrypoint, path, namespace }) => {\n const data = await readFile(path, \"utf8\");\n return {\n entrypoint,\n path,\n namespace,\n data,\n };\n });\n build.onProcess({ filter, namespace: \"source\" }, ({ entrypoint, path, data }) => {\n const { translations, warnings } = parseSource(data, path);\n\n for (const warning of warnings) {\n build.context.logger?.warn(`${warning.error} at ${warning.reference}`);\n }\n\n build.resolve({\n entrypoint,\n path,\n namespace: \"translate\",\n data: translations,\n });\n\n return undefined;\n });\n },\n };\n}\n","import type { Plugin, UniversalPlugin } from \"../plugin.ts\";\n\nimport { cleanup, core, po, react } from \"./index.ts\";\n\nconst original = {\n cleanup,\n core,\n po,\n react,\n} as const;\n\nexport function resolveStaticPlugin(item: UniversalPlugin): Plugin {\n if (\"static\" in item) {\n return original[item.static.name](...item.static.props);\n }\n\n return item;\n}\n","import glob from \"fast-glob\";\nimport type { ResolvedConfig, ResolvedEntrypoint } from \"./configuration.ts\";\nimport { Defer } from \"./defer.ts\";\nimport type { Logger } from \"./logger.ts\";\nimport type {\n Build,\n Context,\n Filter,\n LoadArgs,\n LoadHook,\n ProcessArgs,\n ProcessHook,\n ResolveArgs,\n ResolveHook,\n} from \"./plugin.ts\";\nimport { resolveStaticPlugin } from \"./plugins/static.ts\";\n\nexport type Task =\n | {\n type: \"resolve\";\n args: ResolveArgs;\n }\n | {\n type: \"load\";\n args: LoadArgs;\n }\n | {\n type: \"process\";\n args: ProcessArgs;\n };\n\nasync function getPaths(entrypoint: ResolvedEntrypoint) {\n const pattern = entrypoint.entrypoint.replace(/\\\\/g, \"/\");\n const paths = glob.isDynamicPattern(pattern) ? await glob(pattern, { onlyFiles: true }) : [entrypoint.entrypoint];\n return new Set(paths);\n}\n\nexport async function run(\n entrypoint: ResolvedEntrypoint,\n { config, logger }: { config: ResolvedConfig; logger?: Logger },\n) {\n const destination = entrypoint.destination ?? config.destination;\n const obsolete = entrypoint.obsolete ?? config.obsolete;\n const exclude = entrypoint.exclude ?? config.exclude;\n const walk = entrypoint.walk ?? config.walk;\n const paths = new Set<string>();\n\n const context: Context = {\n config: { ...config, destination, obsolete, exclude, walk },\n generatedAt: new Date(),\n paths,\n logger,\n };\n\n logger?.info(entrypoint, \"starting extraction\");\n\n const resolvers: { filter: Filter; hook: ResolveHook }[] = [];\n const loaders: { filter: Filter; hook: LoadHook }[] = [];\n const processors: { filter: Filter; hook: ProcessHook }[] = [];\n const hooks = {\n resolve: resolvers,\n load: loaders,\n process: processors,\n };\n\n const pending = new Map<string, Defer>();\n const queue: Task[] = [];\n\n function getDeferred(namespace: string) {\n let defer = pending.get(namespace);\n if (defer === undefined) {\n defer = new Defer();\n pending.set(namespace, defer);\n }\n return defer;\n }\n\n function defer(namespace: string) {\n const defer = getDeferred(namespace);\n return defer.promise;\n }\n\n function source(path: string) {\n if (paths.has(path)) {\n return;\n }\n\n logger?.debug({ entrypoint: entrypoint.entrypoint, path }, \"resolved path\");\n\n paths.add(path);\n resolve({ entrypoint: path, path, namespace: \"source\" });\n }\n\n function resolve(args: ResolveArgs) {\n const { entrypoint, path, namespace } = args;\n const skipped = context.config.exclude.some((ex) => (typeof ex === \"function\" ? ex(args) : ex.test(args.path)));\n logger?.debug({ entrypoint, path, namespace, skipped }, \"resolve\");\n\n if (skipped) {\n return;\n }\n\n queue.push({ type: \"resolve\", args });\n getDeferred(namespace).enqueue();\n }\n\n function load(args: LoadArgs) {\n const { entrypoint, path, namespace } = args;\n logger?.debug({ entrypoint, path, namespace }, \"load\");\n\n queue.push({ type: \"load\", args });\n getDeferred(namespace).enqueue();\n }\n\n function process(args: ProcessArgs) {\n const { entrypoint, path, namespace } = args;\n logger?.debug({ entrypoint, path, namespace }, \"process\");\n\n queue.push({ type: \"process\", args });\n getDeferred(namespace).enqueue();\n }\n\n const build: Build = {\n context,\n source,\n resolve,\n load,\n process,\n defer,\n onResolve(filter, hook) {\n resolvers.push({ filter, hook });\n },\n onLoad(filter, hook) {\n loaders.push({ filter, hook });\n },\n onProcess(filter, hook) {\n processors.push({ filter, hook });\n },\n };\n\n for (const item of config.plugins) {\n const plugin = resolveStaticPlugin(item);\n logger?.debug({ plugin: plugin.name }, \"setting up plugin\");\n plugin.setup(build);\n }\n\n for (const path of await getPaths(entrypoint)) {\n source(path);\n }\n\n async function processTask(task: Task) {\n const { type } = task;\n let args = task.args;\n const { entrypoint, path, namespace } = args;\n logger?.trace({ type, entrypoint, path, namespace }, \"processing task\");\n\n for (const { filter, hook } of hooks[type]) {\n if (filter.namespace !== namespace) continue;\n if (filter.filter && !filter.filter.test(path)) continue;\n\n const result = await hook(args as never);\n if (result !== undefined) {\n args = result as never;\n }\n }\n\n if (args !== undefined) {\n if (type === \"resolve\") {\n load(args as never);\n } else if (type === \"load\") {\n process(args as never);\n }\n }\n\n getDeferred(namespace).dequeue();\n }\n\n while (queue.length || Array.from(pending.values()).some((d) => d.pending > 0)) {\n while (queue.length) {\n const task = queue.shift();\n if (!task) {\n break;\n }\n\n await processTask(task);\n }\n\n await Promise.all(Array.from(pending.values()).map((d) => d.promise));\n await Promise.resolve();\n }\n\n logger?.info(entrypoint, \"extraction completed\");\n}\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAa,QAAb,MAAmB;CACf,UAAU;CACV,UAAyB,QAAQ,SAAS;CAC1C;CAEA,UAAU;AACN,MAAI,KAAK,cAAc,EACnB,MAAK,UAAU,IAAI,SAAe,QAAQ;AACtC,QAAK,UAAU;IACjB;;CAGV,UAAU;AACN,MAAI,KAAK,UAAU,KAAK,EAAE,KAAK,YAAY,EACvC,MAAK,WAAW;;;;;;ACP5B,MAAMA,cAAY;AAElB,SAAgB,UAAkB;AAC9B,QAAO;EACH,MAAM;EACN,MAAM,OAAO;AACT,SAAM,QAAQ,QAAQ,MAAM,6BAA6B;GACzD,MAAM,4BAAY,IAAI,KAAa;GACnC,MAAM,4BAAY,IAAI,KAAa;GACnC,MAAM,uBAAO,IAAI,KAAa;GAC9B,IAAI,aAAa;AAEjB,SAAM,UAAU;IAAE;IAAW,QAAQ;IAAM,GAAG,EAAE,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