@let-value/translate-extract 1.0.13 → 1.0.14

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 CHANGED
@@ -1,25 +1,31 @@
1
1
  #!/usr/bin/env node
2
- const require_run = require('../run-BFehT9l8.cjs');
2
+ const require_run = require('../run-DpRfSHSy.cjs');
3
3
  let node_util = require("node:util");
4
4
  node_util = require_run.__toESM(node_util);
5
5
  let cosmiconfig = require("cosmiconfig");
6
6
  cosmiconfig = require_run.__toESM(cosmiconfig);
7
- let pino = require("pino");
8
- pino = require_run.__toESM(pino);
7
+ let chalk = require("chalk");
8
+ chalk = require_run.__toESM(chalk);
9
+ let loglevel = require("loglevel");
10
+ loglevel = require_run.__toESM(loglevel);
11
+ let loglevel_plugin_prefix = require("loglevel-plugin-prefix");
12
+ loglevel_plugin_prefix = require_run.__toESM(loglevel_plugin_prefix);
9
13
 
10
14
  //#region src/logger.ts
11
- function createLogger(level = "info") {
12
- return (0, pino.default)({
13
- level,
14
- transport: {
15
- target: "pino-pretty",
16
- options: {
17
- colorize: true,
18
- ignore: "time,pid,hostname"
19
- }
20
- }
21
- });
22
- }
15
+ const colors = {
16
+ trace: chalk.default.magenta,
17
+ debug: chalk.default.cyan,
18
+ info: chalk.default.blue,
19
+ warn: chalk.default.yellow,
20
+ error: chalk.default.red
21
+ };
22
+ loglevel_plugin_prefix.default.reg(loglevel.default);
23
+ loglevel_plugin_prefix.default.apply(loglevel.default, { format(level, name) {
24
+ const color = colors[level] ?? ((value) => value);
25
+ const scope = name ? ` ${chalk.default.green(`${name}:`)}` : "";
26
+ return `${color(level)}${scope}`;
27
+ } });
28
+ const logger = loglevel.default;
23
29
 
24
30
  //#endregion
25
31
  //#region bin/cli.ts
@@ -32,7 +38,6 @@ async function main() {
32
38
  short: "l"
33
39
  } }
34
40
  });
35
- const logger = createLogger(logLevel);
36
41
  const result = await (0, cosmiconfig.cosmiconfig)(moduleName, { searchPlaces: [
37
42
  `.${moduleName}rc.js`,
38
43
  `.${moduleName}rc.ts`,
@@ -53,7 +58,7 @@ async function main() {
53
58
  }
54
59
  const config = result.config;
55
60
  config.logLevel = logLevel ?? config.logLevel;
56
- logger.level = config.logLevel;
61
+ logger.setLevel(config.logLevel);
57
62
  const tasks = [];
58
63
  for (const entrypoint of config.entrypoints) tasks.push(require_run.run(entrypoint, {
59
64
  config,
@@ -62,7 +67,7 @@ async function main() {
62
67
  await Promise.all(tasks);
63
68
  }
64
69
  main().catch((err) => {
65
- createLogger().error(err);
70
+ logger.error(err);
66
71
  process.exit(1);
67
72
  });
68
73
 
package/dist/bin/cli.js CHANGED
@@ -1,22 +1,26 @@
1
1
  #!/usr/bin/env node
2
- import { run } from "../run-CQoAsNNE.js";
2
+ import { run } from "../run-C_k3ujlk.js";
3
3
  import { parseArgs } from "node:util";
4
4
  import { cosmiconfig } from "cosmiconfig";
5
- import pino from "pino";
5
+ import chalk from "chalk";
6
+ import log from "loglevel";
7
+ import prefix from "loglevel-plugin-prefix";
6
8
 
7
9
  //#region src/logger.ts
8
- function createLogger(level = "info") {
9
- return pino({
10
- level,
11
- transport: {
12
- target: "pino-pretty",
13
- options: {
14
- colorize: true,
15
- ignore: "time,pid,hostname"
16
- }
17
- }
18
- });
19
- }
10
+ const colors = {
11
+ trace: chalk.magenta,
12
+ debug: chalk.cyan,
13
+ info: chalk.blue,
14
+ warn: chalk.yellow,
15
+ error: chalk.red
16
+ };
17
+ prefix.reg(log);
18
+ prefix.apply(log, { format(level, name) {
19
+ const color = colors[level] ?? ((value) => value);
20
+ const scope = name ? ` ${chalk.green(`${name}:`)}` : "";
21
+ return `${color(level)}${scope}`;
22
+ } });
23
+ const logger = log;
20
24
 
21
25
  //#endregion
22
26
  //#region bin/cli.ts
@@ -29,7 +33,6 @@ async function main() {
29
33
  short: "l"
30
34
  } }
31
35
  });
32
- const logger = createLogger(logLevel);
33
36
  const result = await cosmiconfig(moduleName, { searchPlaces: [
34
37
  `.${moduleName}rc.js`,
35
38
  `.${moduleName}rc.ts`,
@@ -50,7 +53,7 @@ async function main() {
50
53
  }
51
54
  const config = result.config;
52
55
  config.logLevel = logLevel ?? config.logLevel;
53
- logger.level = config.logLevel;
56
+ logger.setLevel(config.logLevel);
54
57
  const tasks = [];
55
58
  for (const entrypoint of config.entrypoints) tasks.push(run(entrypoint, {
56
59
  config,
@@ -59,7 +62,7 @@ async function main() {
59
62
  await Promise.all(tasks);
60
63
  }
61
64
  main().catch((err) => {
62
- createLogger().error(err);
65
+ logger.error(err);
63
66
  process.exit(1);
64
67
  });
65
68
 
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","names":["tasks: Promise<unknown>[]"],"sources":["../../src/logger.ts","../../bin/cli.ts"],"sourcesContent":["import pino, { type LevelWithSilent, type Logger } from \"pino\";\n\nexport function createLogger(level: LevelWithSilent = \"info\"): Logger {\n return pino({\n level,\n transport: {\n target: \"pino-pretty\",\n options: {\n colorize: true,\n ignore: \"time,pid,hostname\",\n },\n },\n });\n}\n\nexport type { Logger, LevelWithSilent };\n","#!/usr/bin/env node\nimport { parseArgs } from \"node:util\";\nimport { cosmiconfig } from \"cosmiconfig\";\nimport type { ResolvedConfig } from \"../src/configuration.ts\";\nimport { createLogger, type LevelWithSilent } from \"../src/logger.ts\";\nimport { run } from \"../src/run.ts\";\n\nconst moduleName = \"translate\";\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 logger = createLogger(logLevel as LevelWithSilent | undefined);\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 config = result.config as ResolvedConfig;\n config.logLevel = (logLevel as LevelWithSilent) ?? config.logLevel;\n logger.level = config.logLevel;\n\n const tasks: Promise<unknown>[] = [];\n for (const entrypoint of config.entrypoints) {\n tasks.push(run(entrypoint, { config, logger }));\n }\n\n await Promise.all(tasks);\n}\n\nvoid main().catch((err) => {\n const logger = createLogger();\n logger.error(err);\n process.exit(1);\n});\n"],"mappings":";;;;;;;AAEA,SAAgB,aAAa,QAAyB,QAAgB;AAClE,QAAO,KAAK;EACR;EACA,WAAW;GACP,QAAQ;GACR,SAAS;IACL,UAAU;IACV,QAAQ;IACX;GACJ;EACJ,CAAC;;;;;ACLN,MAAM,aAAa;AAEnB,eAAe,OAAO;CAClB,MAAM,EACF,QAAQ,EAAE,eACV,UAAU;EACV,MAAM,QAAQ,KAAK,MAAM,EAAE;EAC3B,SAAS,EACL,UAAU;GAAE,MAAM;GAAU,OAAO;GAAK,EAC3C;EACJ,CAAC;CAEF,MAAM,SAAS,aAAa,SAAwC;CAmBpE,MAAM,SAAS,MAjBE,YAAY,YAAY,EACrC,cAAc;EACV,IAAI,WAAW;EACf,IAAI,WAAW;EACf,IAAI,WAAW;EACf,IAAI,WAAW;EACf,WAAW,WAAW;EACtB,WAAW,WAAW;EACtB,WAAW,WAAW;EACtB,WAAW,WAAW;EACtB,GAAG,WAAW;EACd,GAAG,WAAW;EACd,GAAG,WAAW;EACd,GAAG,WAAW;EACjB,EACJ,CAAC,CAE4B,QAAQ;AACtC,KAAI,CAAC,UAAU,CAAC,OAAO,QAAQ;AAC3B,SAAO,MAAM,8BAA8B;AAC3C,UAAQ,KAAK,EAAE;;CAGnB,MAAM,SAAS,OAAO;AACtB,QAAO,WAAY,YAAgC,OAAO;AAC1D,QAAO,QAAQ,OAAO;CAEtB,MAAMA,QAA4B,EAAE;AACpC,MAAK,MAAM,cAAc,OAAO,YAC5B,OAAM,KAAK,IAAI,YAAY;EAAE;EAAQ;EAAQ,CAAC,CAAC;AAGnD,OAAM,QAAQ,IAAI,MAAM;;AAGvB,MAAM,CAAC,OAAO,QAAQ;AAEvB,CADe,cAAc,CACtB,MAAM,IAAI;AACjB,SAAQ,KAAK,EAAE;EACjB"}
1
+ {"version":3,"file":"cli.js","names":["colors: Record<LogLevel, ChalkInstance>","tasks: Promise<unknown>[]"],"sources":["../../src/logger.ts","../../bin/cli.ts"],"sourcesContent":["import chalk, { type ChalkInstance } from \"chalk\";\nimport log, { type Logger, type LogLevelNames } from \"loglevel\";\nimport prefix from \"loglevel-plugin-prefix\";\n\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;\nexport type { Logger };\n","#!/usr/bin/env node\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\";\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 config = result.config as ResolvedConfig;\n config.logLevel = (logLevel as LogLevel) ?? config.logLevel;\n logger.setLevel(config.logLevel);\n\n const tasks: Promise<unknown>[] = [];\n for (const entrypoint of config.entrypoints) {\n tasks.push(run(entrypoint, { config, logger }));\n }\n\n await Promise.all(tasks);\n}\n\nvoid main().catch((err) => {\n logger.error(err);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;AAMA,MAAMA,SAA0C;CAC5C,OAAO,MAAM;CACb,OAAO,MAAM;CACb,MAAM,MAAM;CACZ,MAAM,MAAM;CACZ,OAAO,MAAM;CAChB;AAED,OAAO,IAAI,IAAI;AACf,OAAO,MAAM,KAAK,EACd,OAAO,OAAO,MAAM;CAChB,MAAM,QAAQ,OAAO,YAA6B,UAAkB;CACpE,MAAM,QAAQ,OAAO,IAAI,MAAM,MAAM,GAAG,KAAK,GAAG,KAAK;AAErD,QAAO,GAAG,MAAM,MAAM,GAAG;GAEhC,CAAC;AAEF,MAAa,SAAS;;;;ACjBtB,MAAM,aAAa;AAEnB,eAAe,OAAO;CAClB,MAAM,EACF,QAAQ,EAAE,eACV,UAAU;EACV,MAAM,QAAQ,KAAK,MAAM,EAAE;EAC3B,SAAS,EACL,UAAU;GAAE,MAAM;GAAU,OAAO;GAAK,EAC3C;EACJ,CAAC;CAmBF,MAAM,SAAS,MAjBE,YAAY,YAAY,EACrC,cAAc;EACV,IAAI,WAAW;EACf,IAAI,WAAW;EACf,IAAI,WAAW;EACf,IAAI,WAAW;EACf,WAAW,WAAW;EACtB,WAAW,WAAW;EACtB,WAAW,WAAW;EACtB,WAAW,WAAW;EACtB,GAAG,WAAW;EACd,GAAG,WAAW;EACd,GAAG,WAAW;EACd,GAAG,WAAW;EACjB,EACJ,CAAC,CAE4B,QAAQ;AACtC,KAAI,CAAC,UAAU,CAAC,OAAO,QAAQ;AAC3B,SAAO,MAAM,8BAA8B;AAC3C,UAAQ,KAAK,EAAE;;CAGnB,MAAM,SAAS,OAAO;AACtB,QAAO,WAAY,YAAyB,OAAO;AACnD,QAAO,SAAS,OAAO,SAAS;CAEhC,MAAMC,QAA4B,EAAE;AACpC,MAAK,MAAM,cAAc,OAAO,YAC5B,OAAM,KAAK,IAAI,YAAY;EAAE;EAAQ;EAAQ,CAAC,CAAC;AAGnD,OAAM,QAAQ,IAAI,MAAM;;AAGvB,MAAM,CAAC,OAAO,QAAQ;AACvB,QAAO,MAAM,IAAI;AACjB,SAAQ,KAAK,EAAE;EACjB"}
@@ -1,4 +1,4 @@
1
- import { glob, hasMagic } from "glob";
1
+ import glob from "fast-glob";
2
2
 
3
3
  //#region src/defer.ts
4
4
  var Defer = class {
@@ -126,7 +126,7 @@ async function run(entrypoint, { config, logger }) {
126
126
  logger?.debug({ plugin: plugin.name }, "setting up plugin");
127
127
  plugin.setup(build);
128
128
  }
129
- const paths = hasMagic(entrypoint.entrypoint) ? await glob(entrypoint.entrypoint, { nodir: true }) : [entrypoint.entrypoint];
129
+ const paths = glob.isDynamicPattern(entrypoint.entrypoint) ? await glob(entrypoint.entrypoint, { onlyFiles: true }) : [entrypoint.entrypoint];
130
130
  logger?.debug({
131
131
  entrypoint: entrypoint.entrypoint,
132
132
  paths
@@ -172,4 +172,4 @@ async function run(entrypoint, { config, logger }) {
172
172
 
173
173
  //#endregion
174
174
  export { run };
175
- //# sourceMappingURL=run-CQoAsNNE.js.map
175
+ //# sourceMappingURL=run-C_k3ujlk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-C_k3ujlk.js","names":["context: Context","resolvers: { filter: Filter; hook: ResolveHook }[]","loaders: { filter: Filter; hook: LoadHook }[]","processors: { filter: Filter; hook: ProcessHook }[]","queue: Task[]","defer","build: Build"],"sources":["../src/defer.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 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\";\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\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\n const context: Context = {\n config: { ...config, destination, obsolete, exclude, walk },\n generatedAt: new Date(),\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 resolve(args: ResolveArgs) {\n const { entrypoint, path, namespace } = args;\n const skipped =\n (args.path !== args.entrypoint && !context.config.walk) ||\n 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 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 plugin of config.plugins) {\n logger?.debug({ plugin: plugin.name }, \"setting up plugin\");\n plugin.setup(build);\n }\n\n const paths = glob.isDynamicPattern(entrypoint.entrypoint)\n ? await glob(entrypoint.entrypoint, { onlyFiles: true })\n : [entrypoint.entrypoint];\n logger?.debug({ entrypoint: entrypoint.entrypoint, paths }, \"resolved paths\");\n\n for (const path of paths) {\n resolve({ entrypoint: path, path, namespace: \"source\" });\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;;;;;;ACgB5B,eAAsB,IAClB,YACA,EAAE,QAAQ,UACZ;CACE,MAAM,cAAc,YAAY,eAAe,OAAO;CACtD,MAAM,WAAW,YAAY,YAAY,OAAO;CAChD,MAAM,UAAU,YAAY,WAAW,OAAO;CAC9C,MAAM,OAAO,YAAY,QAAQ,OAAO;CAExC,MAAMA,UAAmB;EACrB,QAAQ;GAAE,GAAG;GAAQ;GAAa;GAAU;GAAS;GAAM;EAC3D,6BAAa,IAAI,MAAM;EACvB;EACH;AAED,SAAQ,KAAK,YAAY,sBAAsB;CAE/C,MAAMC,YAAqD,EAAE;CAC7D,MAAMC,UAAgD,EAAE;CACxD,MAAMC,aAAsD,EAAE;CAC9D,MAAM,QAAQ;EACV,SAAS;EACT,MAAM;EACN,SAAS;EACZ;CAED,MAAM,0BAAU,IAAI,KAAoB;CACxC,MAAMC,QAAgB,EAAE;CAExB,SAAS,YAAY,WAAmB;EACpC,IAAIC,UAAQ,QAAQ,IAAI,UAAU;AAClC,MAAIA,YAAU,QAAW;AACrB,aAAQ,IAAI,OAAO;AACnB,WAAQ,IAAI,WAAWA,QAAM;;AAEjC,SAAOA;;CAGX,SAAS,MAAM,WAAmB;AAE9B,SADc,YAAY,UAAU,CACvB;;CAGjB,SAAS,QAA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AY,EAAE,WAAW,MAAM,CAAC,GACtD,CAAC,WAAW,WAAW;AAC7B,SAAQ,MAAM;EAAE,YAAY,WAAW;EAAY;EAAO,EAAE,iBAAiB;AAE7E,MAAK,MAAM,QAAQ,MACf,SAAQ;EAAE,YAAY;EAAM;EAAM,WAAW;EAAU,CAAC;CAG5D,eAAe,YAAY,MAAY;EACnC,MAAM,EAAE,SAAS;EACjB,IAAI,OAAO,KAAK;EAChB,MAAM,EAAE,0BAAY,MAAM,cAAc;AACxC,UAAQ,MAAM;GAAE;GAAM;GAAY;GAAM;GAAW,EAAE,kBAAkB;AAEvE,OAAK,MAAM,EAAE,QAAQ,UAAU,MAAM,OAAO;AACxC,OAAI,OAAO,cAAc,UAAW;AACpC,OAAI,OAAO,UAAU,CAAC,OAAO,OAAO,KAAK,KAAK,CAAE;GAEhD,MAAM,SAAS,MAAM,KAAK,KAAc;AACxC,OAAI,WAAW,OACX,QAAO;;AAIf,MAAI,SAAS,QACT;OAAI,SAAS,UACT,MAAK,KAAc;YACZ,SAAS,OAChB,SAAQ,KAAc;;AAI9B,cAAY,UAAU,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"}
@@ -21,8 +21,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
21
21
  }) : target, mod));
22
22
 
23
23
  //#endregion
24
- let glob = require("glob");
25
- glob = __toESM(glob);
24
+ let fast_glob = require("fast-glob");
25
+ fast_glob = __toESM(fast_glob);
26
26
 
27
27
  //#region src/defer.ts
28
28
  var Defer = class {
@@ -150,7 +150,7 @@ async function run(entrypoint, { config, logger }) {
150
150
  logger?.debug({ plugin: plugin.name }, "setting up plugin");
151
151
  plugin.setup(build);
152
152
  }
153
- const paths = (0, glob.hasMagic)(entrypoint.entrypoint) ? await (0, glob.glob)(entrypoint.entrypoint, { nodir: true }) : [entrypoint.entrypoint];
153
+ const paths = fast_glob.default.isDynamicPattern(entrypoint.entrypoint) ? await (0, fast_glob.default)(entrypoint.entrypoint, { onlyFiles: true }) : [entrypoint.entrypoint];
154
154
  logger?.debug({
155
155
  entrypoint: entrypoint.entrypoint,
156
156
  paths
@@ -1,4 +1,4 @@
1
- const require_run = require('../run-BFehT9l8.cjs');
1
+ const require_run = require('../run-DpRfSHSy.cjs');
2
2
  let node_path = require("node:path");
3
3
  node_path = require_run.__toESM(node_path);
4
4
  let node_fs_promises = require("node:fs/promises");
@@ -25,26 +25,36 @@ function cleanup() {
25
25
  name: "cleanup",
26
26
  setup(build) {
27
27
  build.context.logger?.debug("cleanup plugin initialized");
28
- const processedDirs = /* @__PURE__ */ new Set();
28
+ const processed = /* @__PURE__ */ new Set();
29
29
  const generated = /* @__PURE__ */ new Set();
30
+ const dirs = /* @__PURE__ */ new Set();
31
+ let dispatched = false;
30
32
  build.onResolve({
31
33
  namespace: namespace$2,
32
34
  filter: /.*/
33
- }, (args) => {
34
- generated.add(args.path);
35
- return args;
35
+ }, ({ path: path$1 }) => {
36
+ generated.add(path$1);
37
+ dirs.add((0, node_path.dirname)(path$1));
38
+ Promise.all([build.defer("source"), build.defer("translate")]).then(() => {
39
+ if (dispatched) return;
40
+ dispatched = true;
41
+ for (const path$2 of dirs.values()) build.process({
42
+ entrypoint: path$2,
43
+ path: path$2,
44
+ namespace: namespace$2,
45
+ data: void 0
46
+ });
47
+ });
36
48
  });
37
49
  build.onProcess({
38
50
  namespace: namespace$2,
39
51
  filter: /.*/
40
52
  }, async ({ path: path$1 }) => {
41
- await build.defer("translate");
42
- const dir = (0, node_path.dirname)(path$1);
43
- if (processedDirs.has(dir)) return void 0;
44
- processedDirs.add(dir);
45
- const files = await node_fs_promises.default.readdir(dir).catch(() => []);
53
+ if (processed.has(path$1)) return;
54
+ processed.add(path$1);
55
+ const files = await node_fs_promises.default.readdir(path$1).catch(() => []);
46
56
  for (const f of files.filter((p) => p.endsWith(".po"))) {
47
- const full = (0, node_path.join)(dir, f);
57
+ const full = (0, node_path.join)(path$1, f);
48
58
  if (generated.has(full)) continue;
49
59
  const contents = await node_fs_promises.default.readFile(full).catch(() => void 0);
50
60
  if (!contents) continue;
@@ -960,8 +970,7 @@ function buildTemplate(node) {
960
970
  raw: false
961
971
  });
962
972
  segmentStart = child.endIndex;
963
- } else if (child.type === "jsx_text" || child.type === "html_character_reference" || child.isError) continue;
964
- else return {
973
+ } else if (child.type === "jsx_text" || child.type === "html_character_reference" || child.isError) {} else return {
965
974
  text: "",
966
975
  error: "Unsupported JSX child"
967
976
  };
@@ -1,7 +1,10 @@
1
- import { Locale } from "@let-value/translate";
2
- import { LevelWithSilent, Logger } from "pino";
1
+ import { PluralFormsLocale } from "@let-value/translate";
2
+ import { LogLevelNames, Logger } from "loglevel";
3
3
  import { GetTextTranslationRecord } from "gettext-parser";
4
4
 
5
+ //#region src/logger.d.ts
6
+ type LogLevel = LogLevelNames;
7
+ //#endregion
5
8
  //#region src/plugin.d.ts
6
9
  type MaybePromise<T> = T | Promise<T>;
7
10
  interface Context {
@@ -133,15 +136,15 @@ interface UserConfig {
133
136
  /**
134
137
  * Default locale to use as the base for extraction
135
138
  * @default "en"
136
- * @see {@link Locale} for available locales
139
+ * @see {@link PluralFormsLocale} for available locales
137
140
  */
138
- defaultLocale?: Locale;
141
+ defaultLocale?: PluralFormsLocale;
139
142
  /**
140
143
  * Array of locales to extract translations for
141
144
  * @default [defaultLocale]
142
- * @see {@link Locale} for available locales
145
+ * @see {@link PluralFormsLocale} for available locales
143
146
  */
144
- locales?: Locale[];
147
+ locales?: PluralFormsLocale[];
145
148
  /**
146
149
  * Array of plugins to use or a function to override the default plugins
147
150
  * @default DefaultPlugins
@@ -186,7 +189,7 @@ interface UserConfig {
186
189
  * Log level for the extraction process
187
190
  * @default "info"
188
191
  */
189
- logLevel?: LevelWithSilent;
192
+ logLevel?: LogLevel;
190
193
  }
191
194
  interface ResolvedEntrypoint extends Omit<EntrypointConfig, "exclude"> {
192
195
  exclude?: Exclude[];
@@ -199,7 +202,7 @@ interface ResolvedConfig {
199
202
  destination: DestinationFn;
200
203
  obsolete: ObsoleteStrategy;
201
204
  walk: boolean;
202
- logLevel: LevelWithSilent;
205
+ logLevel: LogLevel;
203
206
  exclude: Exclude[];
204
207
  }
205
208
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/plugin.ts","../../src/plugins/cleanup/cleanup.ts","../../src/plugins/core/queries/types.ts","../../src/plugins/core/core.ts","../../src/plugins/po/po.ts","../../src/configuration.ts","../../src/plugins/react/react.ts","../../src/run.ts"],"sourcesContent":[],"mappings":";;;;;KAGK,kBAAkB,IAAI,QAAQ;UAElB,OAAA;UACL;EAHP,WAAA,EAIY,IAJA;EAAA,MAAA,CAAA,EAKJ,MALI;;AAAkB,UAQlB,WARkB,CAAA,SAAA,OAAA,CAAA,CAAA;YAAR,EAAA,MAAA;EAAO,IAAA,EAAA,MAAA;EAEjB,SAAA,EAAO,MAAA;EAAA,IAAA,CAAA,EAUb,MAVa;;AAEP,UAWA,aAXA,CAAA,SAAA,OAAA,CAAA,CAAA;YACJ,EAAA,MAAA;EAAM,IAAA,EAAA,MAAA;EAGF,SAAA,EAAA,MAAW;EAOX,IAAA,CAAA,EAIN,MAJM;AAOjB;AAOiB,UAPA,QAOU,CAAA,SAIX,OAAA,CAAA,CAAA;EAGC,UAAA,EAAA,MAAW;EAOX,IAAA,EAAA,MAAA;EAOL,SAAM,EAAA,MAAA;EACN,IAAA,CAAA,EAzBD,MAyBC;;AACU,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,OFxEA,EAAA;EAAM;;;;ECAb,QAAA,CAAA,EC6EF,eD5EG;AAGlB;AAcgB,UC8DC,kBAAA,SAA2B,ID9DrB,CC8D0B,gBD9D1B,EAAA,SAAA,CAAA,CAAA;EAAA,OAAA,CAAA,EC+DT,OD/DS,EAAA;;AAA0C,UCkEhD,cAAA,CDlEgD;EAAwB,OAAA,ECmE5E,MDnE4E,EAAA;EA6CzE,WAAK,ECuBJ,kBDvBI,EAAA;EAAA,aAAA,EAAA,MAAA;SACR,EAAA,MAAA,EAAA;aACU,ECwBN,aDxBM;UACT,ECwBA,gBDxBA;MAEG,EAAA,OAAA;EAAI,QAAA,ECwBP,eDxBO;EAsGL,OAAE,EC7EL,OD6ES,EAAA;;;;AC5KtB;AACA;AACY,iBAoII,YAAA,CApIG,MAAA,EAoIkB,UApIlB,CAAA,EAoI+B,cApI/B;;;iBCFH,KAAA,CAAA,GAAS,eAAe;;;KCO5B,IAAA;;EPbP,IAAA,EOgBW,WPhBC;CAAA,GAAA;MAAM,EAAA,MAAA;MAAY,EOoBnB,QPpBmB;;EAAD,IAAA,EAAA,SAAA;EAEjB,IAAA,EOsBD,WPtBQ;CAAA;AACZ,iBOwBU,GAAA,CPxBV,UAAA,EOyBI,kBPzBJ,EAAA;EAAA,MAAA;EAAA;CAAA,EAAA;QACK,EOyBiB,cPzBjB;QACJ,CAAA,EOwB8C,MPxB9C;CAAM,CAAA,EOwBgD,OPxBhD,CAAA,IAAA,CAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/logger.ts","../../src/plugin.ts","../../src/plugins/cleanup/cleanup.ts","../../src/plugins/core/queries/types.ts","../../src/plugins/core/core.ts","../../src/plugins/po/po.ts","../../src/configuration.ts","../../src/plugins/react/react.ts","../../src/run.ts"],"sourcesContent":[],"mappings":";;;;;KAIY,QAAA,GAAW;;;KCDlB,kBAAkB,IAAI,QAAQ;UAElB,OAAA;UACL;EDFA,WAAQ,ECGH,IDHG;WCIP;;UAGI;EARZ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WR,CAAA,MAAA,GKXuB,gBLWvB,CAAA;;;;;;;aAEA,CAAA,EKNnB,aLMmB;EAAW;AAGhD;;;;;EAEsB,QAAA,CAAA,EKJP,gBLIO;;;;AClEtB;;;;ACPA;AAQA;;;YGyEc,UAAU;EFxER;;;;EAAc,QAAA,CAAA,EE6Ef,QF7Ee;;UEgFb,kBAAA,SAA2B,KAAK;YACnC;ADjFd;AAIgB,UCgFC,cAAA,CDhFgB;EAcjB,OAAA,ECmEH,MDnEU,EAAA;EAAA,WAAA,ECoEN,kBDpEM,EAAA;eAAS,EAAA,MAAA;SAAiC,EAAA,MAAA,EAAA;EAAwB,WAAA,ECuExE,aDvEwE;EA6CzE,QAAK,EC2BP,gBD3BO;EAAA,IAAA,EAAA,OAAA;UACR,EC4BC,QD5BD;SACU,EC4BV,OD5BU,EAAA;;;;AAyGvB;;iBCtCgB,YAAA,SAAqB,aAAa;;;iBCtIlC,KAAA,CAAA,GAAS,eAAe;;;KCO5B,IAAA;;ERZA,IAAA,EQeI,WRfI;;;QQmBJ;APtB0B,CAAA,GAErC;EAAY,IAAA,EAAA,SAAA;MAAM,EOwBP,WPxBO;;AAAI,iBO2BL,GAAA,CP3BK,UAAA,EO4BX,kBP5BW,EAAA;EAAA,MAAA;EAAA;CAAA,EAAA;EAAO,MAAA,EO6BA,cP7BA;EAEjB,MAAA,CAAA,EO2B0C,MP3BnC;CAAA,CAAA,EO2B2C,OP3B3C,CAAA,IAAA,CAAA"}
@@ -1,8 +1,11 @@
1
- import { LevelWithSilent, Logger } from "pino";
1
+ import log, { LogLevelNames, Logger } from "loglevel";
2
2
  import { GetTextTranslationRecord } from "gettext-parser";
3
3
  import Parser from "tree-sitter";
4
- import { Locale } from "@let-value/translate";
4
+ import { PluralFormsLocale } from "@let-value/translate";
5
5
 
6
+ //#region src/logger.d.ts
7
+ type LogLevel = LogLevelNames;
8
+ //#endregion
6
9
  //#region src/plugin.d.ts
7
10
  type MaybePromise<T> = T | Promise<T>;
8
11
  interface Context {
@@ -134,15 +137,15 @@ interface UserConfig {
134
137
  /**
135
138
  * Default locale to use as the base for extraction
136
139
  * @default "en"
137
- * @see {@link Locale} for available locales
140
+ * @see {@link PluralFormsLocale} for available locales
138
141
  */
139
- defaultLocale?: Locale;
142
+ defaultLocale?: PluralFormsLocale;
140
143
  /**
141
144
  * Array of locales to extract translations for
142
145
  * @default [defaultLocale]
143
- * @see {@link Locale} for available locales
146
+ * @see {@link PluralFormsLocale} for available locales
144
147
  */
145
- locales?: Locale[];
148
+ locales?: PluralFormsLocale[];
146
149
  /**
147
150
  * Array of plugins to use or a function to override the default plugins
148
151
  * @default DefaultPlugins
@@ -187,7 +190,7 @@ interface UserConfig {
187
190
  * Log level for the extraction process
188
191
  * @default "info"
189
192
  */
190
- logLevel?: LevelWithSilent;
193
+ logLevel?: LogLevel;
191
194
  }
192
195
  interface ResolvedEntrypoint extends Omit<EntrypointConfig, "exclude"> {
193
196
  exclude?: Exclude[];
@@ -200,7 +203,7 @@ interface ResolvedConfig {
200
203
  destination: DestinationFn;
201
204
  obsolete: ObsoleteStrategy;
202
205
  walk: boolean;
203
- logLevel: LevelWithSilent;
206
+ logLevel: LogLevel;
204
207
  exclude: Exclude[];
205
208
  }
206
209
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/plugin.ts","../../src/plugins/cleanup/cleanup.ts","../../src/plugins/core/queries/types.ts","../../src/plugins/core/core.ts","../../src/plugins/po/po.ts","../../src/configuration.ts","../../src/plugins/react/react.ts","../../src/run.ts"],"sourcesContent":[],"mappings":";;;;;;KAGK,kBAAkB,IAAI,QAAQ;UAElB,OAAA;UACL;eACK;EAJZ,MAAA,CAAA,EAKQ,MALI;;AAAM,UAQN,WARM,CAAA,SAAA,OAAA,CAAA,CAAA;YAAY,EAAA,MAAA;MAAR,EAAA,MAAA;EAAO,SAAA,EAAA,MAAA;EAEjB,IAAA,CAAA,EAUN,MAVa;;AACZ,UAYK,aAZL,CAAA,SAA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aAImB,EAAA,MAAA,GKZR,gBLYQ,GKZW,KLYX,CAAA,MAAA,GKZ0B,gBLY1B,CAAA;;;;;;AAIlC;EAAuB,WAAA,CAAA,EKTL,aLSK;;;;;;;aKFR;EJ9DC;;;;ACPhB;EAQiB,IAAA,CAAA,EAAA,OAAW;;;;ACC5B;;SAAuC,CAAA,EEwEzB,OFxEyB,GEwEf,OFxEe,EAAA;;;;;aE6ExB;AD7Ef;AAIgB,UC4EC,kBAAA,SAA2B,ID5EP,CC4EY,gBD5EZ,EAAA,SAAA,CAAA,CAAA;EAcrB,OAAA,CAAA,EC+DF,OD/DS,EAAA;;AAAS,UCkEf,cAAA,CDlEe;SAAiC,ECmEpD,MDnEoD,EAAA;EAAwB,WAAA,ECoExE,kBDpEwE,EAAA;EA6CzE,aAAK,EAAA,MAAA;EAAA,OAAA,EAAA,MAAA,EAAA;aACR,ECyBI,aDzBJ;UACU,ECyBT,gBDzBS;MACT,EAAA,OAAA;UAEG,ECwBH,eDxBG;EAAI,OAAA,ECyBR,ODzBQ,EAAA;AAsGrB;;;;AC5KA;AACY,iBAqII,YAAA,CArIK,MAAA,EAqIgB,UArIhB,CAAA,EAqI6B,cArI7B;;;iBCDL,KAAA,CAAA,GAAS,eAAe;;;KCO5B,IAAA;;QAGI;APlB0B,CAAA,GAErC;EAAY,IAAA,EAAA,MAAA;MAAM,EOoBP,QPpBO;;MAAI,EAAA,SAAA;EAAO,IAAA,EOwBlB,WPxBkB;AAElC,CAAA;AAAwB,iBOyBF,GAAA,CPzBE,UAAA,EO0BR,kBP1BQ,EAAA;EAAA,MAAA;EAAA;CAAA,EAAA;QACZ,EO0BsB,cP1BtB;QACK,CAAA,EOyB0C,MPzB1C;IOyBkD,OPxBtD,CAAA,IAAA,CAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/logger.ts","../../src/plugin.ts","../../src/plugins/cleanup/cleanup.ts","../../src/plugins/core/queries/types.ts","../../src/plugins/core/core.ts","../../src/plugins/po/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J,KLWI,CAAA,MAAA,GKXW,gBLWX,CAAA;;;;;;;aAEQ,CAAA,EKNvC,aLMuC;;;AAGzD;;;;UAEiB,CAAA,EKJF,gBLIE;EAAK;;;;AClEtB;;;;ACPA;AAQA;;YGyEc,UAAU;;AFxExB;;;UAAwB,CAAA,EE6ET,QF7ES;;UEgFP,kBAAA,SAA2B,KAAK;YACnC;;ADjFG,UCoFA,cAAA,CDnFC;EAGF,OAAA,ECiFH,MDjFa,EAAA;EAcV,WAAO,ECoEN,kBDpEM,EAAA;EAAA,aAAA,EAAA,MAAA;SAAS,EAAA,MAAA,EAAA;aAAiC,ECuEhD,aDvEgD;EAAwB,QAAA,ECwE3E,gBDxE2E;EA6CzE,IAAA,EAAA,OAAK;EAAA,QAAA,EC6BP,QD7BO;SACR,EC6BA,OD7BA,EAAA;;;;;AA0Gb;iBCtCgB,YAAA,SAAqB,aAAa;;;iBCtIlC,KAAA,CAAA,GAAS,eAAe;;;KCO5B,IAAA;;QAGI;ARfhB,CAAA,GAAY;;QQmBI;;EPpBX,IAAA,EAAA,SAAY;EAAA,IAAA,EOwBD,WPxBC;;AAAkB,iBO2Bb,GAAA,CP3Ba,UAAA,EO4BnB,kBP5BmB,EAAA;EAAA,MAAA;EAAA;AAEnC,CAFmC,EAAA;QAAR,EO6BO,cP7BP;EAAO,MAAA,CAAA,EO6ByB,MP7BzB;AAElC,CAAA,CAAA,EO2BmE,OP3BlD,CAAA,IAAO,CAAA"}
package/dist/src/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { run } from "../run-CQoAsNNE.js";
1
+ import { run } from "../run-C_k3ujlk.js";
2
2
  import path, { basename, dirname, extname, join, relative, resolve } from "node:path";
3
3
  import fs, { readFile } from "node:fs/promises";
4
4
  import * as gettextParser from "gettext-parser";
@@ -16,26 +16,36 @@ function cleanup() {
16
16
  name: "cleanup",
17
17
  setup(build) {
18
18
  build.context.logger?.debug("cleanup plugin initialized");
19
- const processedDirs = /* @__PURE__ */ new Set();
19
+ const processed = /* @__PURE__ */ new Set();
20
20
  const generated = /* @__PURE__ */ new Set();
21
+ const dirs = /* @__PURE__ */ new Set();
22
+ let dispatched = false;
21
23
  build.onResolve({
22
24
  namespace: namespace$2,
23
25
  filter: /.*/
24
- }, (args) => {
25
- generated.add(args.path);
26
- return args;
26
+ }, ({ path: path$1 }) => {
27
+ generated.add(path$1);
28
+ dirs.add(dirname(path$1));
29
+ Promise.all([build.defer("source"), build.defer("translate")]).then(() => {
30
+ if (dispatched) return;
31
+ dispatched = true;
32
+ for (const path$2 of dirs.values()) build.process({
33
+ entrypoint: path$2,
34
+ path: path$2,
35
+ namespace: namespace$2,
36
+ data: void 0
37
+ });
38
+ });
27
39
  });
28
40
  build.onProcess({
29
41
  namespace: namespace$2,
30
42
  filter: /.*/
31
43
  }, async ({ path: path$1 }) => {
32
- await build.defer("translate");
33
- const dir = dirname(path$1);
34
- if (processedDirs.has(dir)) return void 0;
35
- processedDirs.add(dir);
36
- const files = await fs.readdir(dir).catch(() => []);
44
+ if (processed.has(path$1)) return;
45
+ processed.add(path$1);
46
+ const files = await fs.readdir(path$1).catch(() => []);
37
47
  for (const f of files.filter((p) => p.endsWith(".po"))) {
38
- const full = join(dir, f);
48
+ const full = join(path$1, f);
39
49
  if (generated.has(full)) continue;
40
50
  const contents = await fs.readFile(full).catch(() => void 0);
41
51
  if (!contents) continue;
@@ -951,8 +961,7 @@ function buildTemplate(node) {
951
961
  raw: false
952
962
  });
953
963
  segmentStart = child.endIndex;
954
- } else if (child.type === "jsx_text" || child.type === "html_character_reference" || child.isError) continue;
955
- else return {
964
+ } else if (child.type === "jsx_text" || child.type === "html_character_reference" || child.isError) {} else return {
956
965
  text: "",
957
966
  error: "Unsupported JSX child"
958
967
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["namespace","path","path","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","headers: Record<string, string>","obsoleteTranslations: GetTextTranslationRecord","collected: GetTextTranslationRecord","existing","poObj: GetTextTranslations","path","defaultDestination: DestinationFn","defaultExclude: Exclude[]","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"],"sources":["../../src/plugins/cleanup/cleanup.ts","../../src/plugins/core/queries/comment.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/po.ts","../../src/configuration.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"],"sourcesContent":["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 processedDirs = new Set<string>();\n const generated = new Set<string>();\n\n build.onResolve({ namespace, filter: /.*/ }, (args) => {\n generated.add(args.path);\n return args;\n });\n\n build.onProcess({ namespace, filter: /.*/ }, async ({ path }) => {\n await build.defer(\"translate\");\n const dir = dirname(path);\n if (processedDirs.has(dir)) return undefined;\n processedDirs.add(dir);\n const files = await fs.readdir(dir).catch(() => []);\n for (const f of files.filter((p) => p.endsWith(\".po\"))) {\n const full = join(dir, f);\n if (generated.has(full)) continue;\n const contents = await fs.readFile(full).catch(() => undefined);\n if (!contents) continue;\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) {\n build.context.logger?.warn({ path: full }, \"stray translation file\");\n } else {\n await fs.unlink(full);\n build.context.logger?.info({ path: full }, \"removed empty translation file\");\n }\n }\n return undefined;\n });\n },\n };\n}\n","import { relative } from \"node:path\";\nimport type Parser from \"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\nfunction 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 \"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 \"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 \"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 \"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(\"context\", `(arguments (string (string_fragment) @msgctxt))`)\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 return {\n node: result.node,\n translation: {\n ...result.translation,\n context: contextNode.text,\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 messageQuery,\n messageInvalidQuery,\n gettextQuery,\n gettextInvalidQuery,\n pluralQuery,\n ngettextQuery,\n pgettextQuery,\n npgettextQuery,\n contextMsgQuery,\n contextPluralQuery,\n contextInvalidQuery,\n];\n","import fs from \"node:fs\";\nimport { extname, resolve } from \"node:path\";\n\nimport Parser from \"tree-sitter\";\nimport JavaScript from \"tree-sitter-javascript\";\nimport TS from \"tree-sitter-typescript\";\n\nimport { getReference } from \"./queries/comment.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}\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 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 };\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 { translations, imports, warnings } = parseSource(data, path);\n\n if (build.context.config.walk) {\n const paths = resolveImports(path, imports);\n for (const path of paths) {\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 fs from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\n\nimport type { GetTextTranslationRecord, GetTextTranslations } from \"gettext-parser\";\nimport * as gettextParser from \"gettext-parser\";\nimport { getFormula, getNPlurals } from \"plural-forms\";\n\nimport type { ObsoleteStrategy } from \"../../configuration.ts\";\nimport type { Plugin } from \"../../plugin.ts\";\nimport type { Translation } from \"../core/queries/types.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 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\nexport function merge(\n sources: Collected[],\n existing: string | Buffer | undefined,\n obsolete: ObsoleteStrategy,\n locale: string,\n generatedAt: Date,\n): string {\n let headers: Record<string, string> = {};\n let translations: GetTextTranslationRecord = { \"\": {} };\n let obsoleteTranslations: GetTextTranslationRecord = {};\n const nplurals = getNPlurals(locale);\n\n if (existing) {\n const parsed = gettextParser.po.parse(existing);\n headers = parsed.headers || {};\n translations = parsed.translations || { \"\": {} };\n obsoleteTranslations = parsed.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: record } of sources) {\n for (const [ctx, msgs] of Object.entries(record)) {\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 entry.obsolete = false;\n entry.msgstr = entry.msgstr.slice(0, nplurals);\n while (entry.msgstr.length < nplurals) entry.msgstr.push(\"\");\n translations[ctx][id] = entry;\n if (obsoleteTranslations[ctx]) delete obsoleteTranslations[ctx][id];\n }\n }\n\n for (const ctx of Object.keys(translations)) {\n for (const id of Object.keys(translations[ctx])) {\n if (ctx === \"\" && id === \"\") continue;\n const entry = translations[ctx][id];\n if (entry.obsolete) {\n if (!obsoleteTranslations[ctx]) obsoleteTranslations[ctx] = {};\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 \"pot-creation-date\": formatDate(generatedAt),\n \"x-generator\": \"@let-value/translate-extract\",\n };\n\n const poObj: GetTextTranslations = {\n charset: \"utf-8\",\n headers,\n translations,\n ...(obsolete === \"mark\" && Object.keys(obsoleteTranslations).length ? { obsolete: obsoleteTranslations } : {}),\n };\n\n return gettextParser.po.compile(poObj).toString();\n}\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 build.defer(\"source\").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 data = await fs.readFile(path).catch(() => 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 await fs.mkdir(dirname(path), { recursive: true });\n await fs.writeFile(path, out);\n\n build.resolve({\n entrypoint,\n path,\n namespace: \"cleanup\",\n data: translations,\n });\n });\n },\n };\n}\n","import { basename, dirname, extname, join } from \"node:path\";\nimport type { Locale } from \"@let-value/translate\";\nimport type { LevelWithSilent } from \"pino\";\n\nimport type { Plugin } from \"./plugin.ts\";\nimport { cleanup } from \"./plugins/cleanup/cleanup.ts\";\nimport { core } from \"./plugins/core/core.ts\";\nimport { po } from \"./plugins/po/po.ts\";\n\nexport type DestinationFn = (args: { locale: string; entrypoint: string; path: string }) => string;\nexport type ExcludeFn = (args: { entrypoint: string; path: string }) => boolean;\nexport type Exclude = RegExp | ExcludeFn;\n\nconst defaultPlugins = { core, po, cleanup };\ntype DefaultPlugins = typeof defaultPlugins;\n\n/**\n * Strategy to handle obsolete translations in existing locale files:\n * - \"mark\": keep obsolete entries in the locale file but mark them as obsolete\n * - \"remove\": remove obsolete entries from the locale file\n */\nexport type ObsoleteStrategy = \"mark\" | \"remove\";\n\nexport interface EntrypointConfig {\n entrypoint: string;\n destination?: DestinationFn;\n obsolete?: ObsoleteStrategy;\n walk?: boolean;\n exclude?: Exclude | Exclude[];\n}\n\nexport interface UserConfig {\n /**\n * Default locale to use as the base for extraction\n * @default \"en\"\n * @see {@link Locale} for available locales\n */\n defaultLocale?: Locale;\n /**\n * Array of locales to extract translations for\n * @default [defaultLocale]\n * @see {@link Locale} for available locales\n */\n locales?: Locale[];\n /**\n * Array of plugins to use or a function to override the default plugins\n * @default DefaultPlugins\n * @see {@link DefaultPlugins} for available plugins\n */\n plugins?: Plugin[] | ((defaultPlugins: DefaultPlugins) => Plugin[]);\n /**\n * One or more entrypoints to extract translations from, could be:\n * - file path, will be treated as a single file entrypoint\n * - glob pattern will be expanded to match files, each treated as a separate entrypoint\n * - configuration object with options for the entrypoint\n * @see {@link EntrypointConfig} for configuration options\n */\n entrypoints: string | EntrypointConfig | Array<string | EntrypointConfig>;\n /**\n * Function to determine the destination path for each extracted locale file\n * @default `./translations/entrypoint.locale.po`\n * @see {@link DestinationFn}\n * @see Can be overridden per entrypoint via `destination` in {@link EntrypointConfig\n */\n destination?: DestinationFn;\n /**\n * Strategy to handle obsolete translations in existing locale files\n * @default \"mark\"\n * @see {@link ObsoleteStrategy} for available strategies\n * @see Can be overridden per entrypoint via `obsolete` in {@link EntrypointConfig\n */\n obsolete?: ObsoleteStrategy;\n /**\n * Whether to recursively walk dependencies of the entrypoints\n * @default true\n * @see Can be overridden per entrypoint via `walk` in {@link EntrypointConfig}.\n */\n walk?: boolean;\n /**\n * Paths or patterns to exclude from extraction, applied to all entrypoints\n * @default [/node_modules/, /dist/, /build/]\n * @see Can be overridden per entrypoint via `exclude` in {@link EntrypointConfig}.\n */\n exclude?: Exclude | Exclude[];\n /**\n * Log level for the extraction process\n * @default \"info\"\n */\n logLevel?: LevelWithSilent;\n}\n\nexport interface ResolvedEntrypoint extends Omit<EntrypointConfig, \"exclude\"> {\n exclude?: Exclude[];\n}\n\nexport interface ResolvedConfig {\n plugins: Plugin[];\n entrypoints: ResolvedEntrypoint[];\n defaultLocale: string;\n locales: string[];\n destination: DestinationFn;\n obsolete: ObsoleteStrategy;\n walk: boolean;\n logLevel: LevelWithSilent;\n exclude: Exclude[];\n}\n\nconst defaultDestination: DestinationFn = ({ entrypoint, locale }) =>\n join(dirname(entrypoint), \"translations\", `${basename(entrypoint, extname(entrypoint))}.${locale}.po`);\n\nconst defaultExclude: Exclude[] = [\n /(?:^|[\\\\/])node_modules(?:[\\\\/]|$)/,\n /(?:^|[\\\\/])dist(?:[\\\\/]|$)/,\n /(?:^|[\\\\/])build(?:[\\\\/]|$)/,\n];\n\nfunction normalizeExclude(exclude?: Exclude | Exclude[]): Exclude[] {\n if (!exclude) return [];\n return Array.isArray(exclude) ? exclude : [exclude];\n}\n\nfunction resolveEntrypoint(ep: string | EntrypointConfig): ResolvedEntrypoint {\n if (typeof ep === \"string\") {\n return { entrypoint: ep };\n }\n const { entrypoint, destination, obsolete, exclude } = ep;\n return { entrypoint, destination, obsolete, exclude: exclude ? normalizeExclude(exclude) : undefined };\n}\n\nfunction resolvePlugins(user?: UserConfig[\"plugins\"]): Plugin[] {\n if (typeof user === \"function\") {\n return user(defaultPlugins);\n }\n if (Array.isArray(user)) {\n return [...Object.values(defaultPlugins).map((plugin) => plugin()), ...user];\n }\n return Object.values(defaultPlugins).map((plugin) => plugin());\n}\n\n/**\n * Type helper to make it easier to use translate.config.ts\n * @param config - {@link UserConfig}.\n */\nexport function defineConfig(config: UserConfig): ResolvedConfig {\n const defaultLocale = config.defaultLocale ?? \"en\";\n\n const plugins = resolvePlugins(config.plugins);\n\n const raw = Array.isArray(config.entrypoints) ? config.entrypoints : [config.entrypoints];\n const entrypoints = raw.map(resolveEntrypoint);\n\n return {\n plugins,\n entrypoints,\n defaultLocale,\n locales: config.locales ?? [defaultLocale],\n destination: config.destination ?? defaultDestination,\n obsolete: config.obsolete ?? \"mark\",\n walk: config.walk ?? true,\n logLevel: config.logLevel ?? \"info\",\n exclude: config.exclude ? normalizeExclude(config.exclude) : defaultExclude,\n };\n}\n","import type Parser from \"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 =\n | { kind: \"text\"; text: string; raw: boolean }\n | { 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 continue;\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 \"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 \"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"],"mappings":";;;;;;;;;;;;AAOA,MAAMA,cAAY;AAElB,SAAgB,UAAkB;AAC9B,QAAO;EACH,MAAM;EACN,MAAM,OAAO;AACT,SAAM,QAAQ,QAAQ,MAAM,6BAA6B;GACzD,MAAM,gCAAgB,IAAI,KAAa;GACvC,MAAM,4BAAY,IAAI,KAAa;AAEnC,SAAM,UAAU;IAAE;IAAW,QAAQ;IAAM,GAAG,SAAS;AACnD,cAAU,IAAI,KAAK,KAAK;AACxB,WAAO;KACT;AAEF,SAAM,UAAU;IAAE;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CAAE;AACvB,QAAK,IAAI,KAAK,GAAG;GACjB,MAAM,YAAY,aAAa,MAAM,QAAQ;AAC7C,OAAI,YACA,cAAa,KAAK;IACd,GAAG;IACH,UAAU;KACN,GAAG,YAAY;KACf;KACH;IACJ,CAAC;AAEN,OAAI,MACA,UAAS,KAAK;IACV;IACA;IACH,CAAC;;;AAKd,QAAO;EAAE;EAAc;EAAU;;;;;AChDrC,MAAM,SAAS;AAEf,SAAgB,QAAuC;AACnD,QAAO;EACH,MAAM;EACN,MAAM,OAAO;AACT,SAAM,QAAQ,QAAQ,MAAM,2BAA2B;AACvD,SAAM,UAAU;IAAE,QAAQ;IAAM,WAAW;IAAU,GAAG,EAAE,YAAY,cAAM,6BAAgB;AACxF,WAAO;KACH;KACA;KACA,MAAM,QAAQC,OAAK;KACtB;KACH;AACF,SAAM,OAAO;IAAE;IAAQ,WAAW;IAAU,EAAE,OAAO,EAAE,YAAY,cAAM,6BAAgB;IACrF,MAAM,OAAO,MAAM,SAASA,QAAM,OAAO;AACzC,WAAO;KACH;KACA;KACA;KACA;KACH;KACH;AACF,SAAM,UAAU;IAAE;IAAQ,WAAW;IAAU,GAAG,EAAE,YAAY,cAAM,WAAW;IAC7E,MAAM,EAAE,cAAc,aAAa,YAAY,MAAMA,OAAK;AAE1D,SAAK,MAAM,WAAW,SAClB,OAAM,QAAQ,QAAQ,KAAK,GAAG,QAAQ,MAAM,MAAM,QAAQ,YAAY;AAG1E,UAAM,QAAQ;KACV;KACA;KACA,WAAW;KACX,MAAM;KACT,CAAC;KAGJ;;EAET"}
1
+ {"version":3,"file":"index.js","names":["namespace","path","path","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","headers: Record<string, string>","obsoleteTranslations: GetTextTranslationRecord","collected: GetTextTranslationRecord","existing","poObj: GetTextTranslations","path","defaultDestination: DestinationFn","defaultExclude: Exclude[]","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"],"sources":["../../src/plugins/cleanup/cleanup.ts","../../src/plugins/core/queries/comment.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/po.ts","../../src/configuration.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"],"sourcesContent":["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\")]).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 if (generated.has(full)) {\n continue;\n }\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) {\n build.context.logger?.warn({ path: full }, \"stray translation file\");\n } else {\n await fs.unlink(full);\n build.context.logger?.info({ path: full }, \"removed empty translation file\");\n }\n }\n return undefined;\n });\n },\n };\n}\n","import { relative } from \"node:path\";\nimport type Parser from \"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\nfunction 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 \"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 \"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 \"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 \"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(\"context\", `(arguments (string (string_fragment) @msgctxt))`)\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 return {\n node: result.node,\n translation: {\n ...result.translation,\n context: contextNode.text,\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 messageQuery,\n messageInvalidQuery,\n gettextQuery,\n gettextInvalidQuery,\n pluralQuery,\n ngettextQuery,\n pgettextQuery,\n npgettextQuery,\n contextMsgQuery,\n contextPluralQuery,\n contextInvalidQuery,\n];\n","import fs from \"node:fs\";\nimport { extname, resolve } from \"node:path\";\n\nimport Parser from \"tree-sitter\";\nimport JavaScript from \"tree-sitter-javascript\";\nimport TS from \"tree-sitter-typescript\";\n\nimport { getReference } from \"./queries/comment.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}\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 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 };\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 { translations, imports, warnings } = parseSource(data, path);\n\n if (build.context.config.walk) {\n const paths = resolveImports(path, imports);\n for (const path of paths) {\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 fs from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\n\nimport type { GetTextTranslationRecord, GetTextTranslations } from \"gettext-parser\";\nimport * as gettextParser from \"gettext-parser\";\nimport { getFormula, getNPlurals } from \"plural-forms\";\n\nimport type { ObsoleteStrategy } from \"../../configuration.ts\";\nimport type { Plugin } from \"../../plugin.ts\";\nimport type { Translation } from \"../core/queries/types.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 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\nexport function merge(\n sources: Collected[],\n existing: string | Buffer | undefined,\n obsolete: ObsoleteStrategy,\n locale: string,\n generatedAt: Date,\n): string {\n let headers: Record<string, string> = {};\n let translations: GetTextTranslationRecord = { \"\": {} };\n let obsoleteTranslations: GetTextTranslationRecord = {};\n const nplurals = getNPlurals(locale);\n\n if (existing) {\n const parsed = gettextParser.po.parse(existing);\n headers = parsed.headers || {};\n translations = parsed.translations || { \"\": {} };\n obsoleteTranslations = parsed.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: record } of sources) {\n for (const [ctx, msgs] of Object.entries(record)) {\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 entry.obsolete = false;\n entry.msgstr = entry.msgstr.slice(0, nplurals);\n while (entry.msgstr.length < nplurals) entry.msgstr.push(\"\");\n translations[ctx][id] = entry;\n if (obsoleteTranslations[ctx]) delete obsoleteTranslations[ctx][id];\n }\n }\n\n for (const ctx of Object.keys(translations)) {\n for (const id of Object.keys(translations[ctx])) {\n if (ctx === \"\" && id === \"\") continue;\n const entry = translations[ctx][id];\n if (entry.obsolete) {\n if (!obsoleteTranslations[ctx]) obsoleteTranslations[ctx] = {};\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 \"pot-creation-date\": formatDate(generatedAt),\n \"x-generator\": \"@let-value/translate-extract\",\n };\n\n const poObj: GetTextTranslations = {\n charset: \"utf-8\",\n headers,\n translations,\n ...(obsolete === \"mark\" && Object.keys(obsoleteTranslations).length ? { obsolete: obsoleteTranslations } : {}),\n };\n\n return gettextParser.po.compile(poObj).toString();\n}\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 build.defer(\"source\").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 data = await fs.readFile(path).catch(() => 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 await fs.mkdir(dirname(path), { recursive: true });\n await fs.writeFile(path, out);\n\n build.resolve({\n entrypoint,\n path,\n namespace: \"cleanup\",\n data: translations,\n });\n });\n },\n };\n}\n","import { basename, dirname, extname, join } from \"node:path\";\nimport type { PluralFormsLocale } from \"@let-value/translate\";\nimport type { LogLevel } from \"./logger.ts\";\n\nimport type { Plugin } from \"./plugin.ts\";\nimport { cleanup } from \"./plugins/cleanup/cleanup.ts\";\nimport { core } from \"./plugins/core/core.ts\";\nimport { po } from \"./plugins/po/po.ts\";\n\nexport type DestinationFn = (args: { locale: string; entrypoint: string; path: string }) => string;\nexport type ExcludeFn = (args: { entrypoint: string; path: string }) => boolean;\nexport type Exclude = RegExp | ExcludeFn;\n\nconst defaultPlugins = { core, po, cleanup };\ntype DefaultPlugins = typeof defaultPlugins;\n\n/**\n * Strategy to handle obsolete translations in existing locale files:\n * - \"mark\": keep obsolete entries in the locale file but mark them as obsolete\n * - \"remove\": remove obsolete entries from the locale file\n */\nexport type ObsoleteStrategy = \"mark\" | \"remove\";\n\nexport interface EntrypointConfig {\n entrypoint: string;\n destination?: DestinationFn;\n obsolete?: ObsoleteStrategy;\n walk?: boolean;\n exclude?: Exclude | Exclude[];\n}\n\nexport interface UserConfig {\n /**\n * Default locale to use as the base for extraction\n * @default \"en\"\n * @see {@link PluralFormsLocale} for available locales\n */\n defaultLocale?: PluralFormsLocale;\n /**\n * Array of locales to extract translations for\n * @default [defaultLocale]\n * @see {@link PluralFormsLocale} for available locales\n */\n locales?: PluralFormsLocale[];\n /**\n * Array of plugins to use or a function to override the default plugins\n * @default DefaultPlugins\n * @see {@link DefaultPlugins} for available plugins\n */\n plugins?: Plugin[] | ((defaultPlugins: DefaultPlugins) => Plugin[]);\n /**\n * One or more entrypoints to extract translations from, could be:\n * - file path, will be treated as a single file entrypoint\n * - glob pattern will be expanded to match files, each treated as a separate entrypoint\n * - configuration object with options for the entrypoint\n * @see {@link EntrypointConfig} for configuration options\n */\n entrypoints: string | EntrypointConfig | Array<string | EntrypointConfig>;\n /**\n * Function to determine the destination path for each extracted locale file\n * @default `./translations/entrypoint.locale.po`\n * @see {@link DestinationFn}\n * @see Can be overridden per entrypoint via `destination` in {@link EntrypointConfig\n */\n destination?: DestinationFn;\n /**\n * Strategy to handle obsolete translations in existing locale files\n * @default \"mark\"\n * @see {@link ObsoleteStrategy} for available strategies\n * @see Can be overridden per entrypoint via `obsolete` in {@link EntrypointConfig\n */\n obsolete?: ObsoleteStrategy;\n /**\n * Whether to recursively walk dependencies of the entrypoints\n * @default true\n * @see Can be overridden per entrypoint via `walk` in {@link EntrypointConfig}.\n */\n walk?: boolean;\n /**\n * Paths or patterns to exclude from extraction, applied to all entrypoints\n * @default [/node_modules/, /dist/, /build/]\n * @see Can be overridden per entrypoint via `exclude` in {@link EntrypointConfig}.\n */\n exclude?: Exclude | Exclude[];\n /**\n * Log level for the extraction process\n * @default \"info\"\n */\n logLevel?: LogLevel;\n}\n\nexport interface ResolvedEntrypoint extends Omit<EntrypointConfig, \"exclude\"> {\n exclude?: Exclude[];\n}\n\nexport interface ResolvedConfig {\n plugins: Plugin[];\n entrypoints: ResolvedEntrypoint[];\n defaultLocale: string;\n locales: string[];\n destination: DestinationFn;\n obsolete: ObsoleteStrategy;\n walk: boolean;\n logLevel: LogLevel;\n exclude: Exclude[];\n}\n\nconst defaultDestination: DestinationFn = ({ entrypoint, locale }) =>\n join(dirname(entrypoint), \"translations\", `${basename(entrypoint, extname(entrypoint))}.${locale}.po`);\n\nconst defaultExclude: Exclude[] = [\n /(?:^|[\\\\/])node_modules(?:[\\\\/]|$)/,\n /(?:^|[\\\\/])dist(?:[\\\\/]|$)/,\n /(?:^|[\\\\/])build(?:[\\\\/]|$)/,\n];\n\nfunction normalizeExclude(exclude?: Exclude | Exclude[]): Exclude[] {\n if (!exclude) return [];\n return Array.isArray(exclude) ? exclude : [exclude];\n}\n\nfunction resolveEntrypoint(ep: string | EntrypointConfig): ResolvedEntrypoint {\n if (typeof ep === \"string\") {\n return { entrypoint: ep };\n }\n const { entrypoint, destination, obsolete, exclude } = ep;\n return { entrypoint, destination, obsolete, exclude: exclude ? normalizeExclude(exclude) : undefined };\n}\n\nfunction resolvePlugins(user?: UserConfig[\"plugins\"]): Plugin[] {\n if (typeof user === \"function\") {\n return user(defaultPlugins);\n }\n if (Array.isArray(user)) {\n return [...Object.values(defaultPlugins).map((plugin) => plugin()), ...user];\n }\n return Object.values(defaultPlugins).map((plugin) => plugin());\n}\n\n/**\n * Type helper to make it easier to use translate.config.ts\n * @param config - {@link UserConfig}.\n */\nexport function defineConfig(config: UserConfig): ResolvedConfig {\n const defaultLocale = config.defaultLocale ?? \"en\";\n\n const plugins = resolvePlugins(config.plugins);\n\n const raw = Array.isArray(config.entrypoints) ? config.entrypoints : [config.entrypoints];\n const entrypoints = raw.map(resolveEntrypoint);\n\n return {\n plugins,\n entrypoints,\n defaultLocale,\n locales: config.locales ?? [defaultLocale],\n destination: config.destination ?? defaultDestination,\n obsolete: config.obsolete ?? \"mark\",\n walk: config.walk ?? true,\n logLevel: config.logLevel ?? \"info\",\n exclude: config.exclude ? normalizeExclude(config.exclude) : defaultExclude,\n };\n}\n","import type Parser from \"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 \"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 \"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"],"mappings":";;;;;;;;;;;;AAOA,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,UA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;KACA;KACA,WAAW;KACX,MAAM;KACT,CAAC;KAGJ;;EAET"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@let-value/translate-extract",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -20,18 +20,19 @@
20
20
  "dist"
21
21
  ],
22
22
  "dependencies": {
23
- "@let-value/translate": "1.0.13",
23
+ "@let-value/translate": "1.0.14",
24
+ "chalk": "5.3.0",
25
+ "cosmiconfig": "9.0.0",
24
26
  "gettext-parser": "8.0.0",
27
+ "loglevel": "1.9.1",
28
+ "loglevel-plugin-prefix": "0.8.4",
25
29
  "oxc-resolver": "11.8.0",
26
30
  "plural-forms": "0.5.5",
27
31
  "radash": "12.1.1",
28
32
  "tree-sitter": "0.25.0",
29
33
  "tree-sitter-javascript": "0.25.0",
30
34
  "tree-sitter-typescript": "0.23.2",
31
- "glob": "11.0.3",
32
- "cosmiconfig": "9.0.0",
33
- "pino": "9.9.5",
34
- "pino-pretty": "13.1.1"
35
+ "fast-glob": "3.3.2"
35
36
  },
36
37
  "devDependencies": {
37
38
  "@types/gettext-parser": "8.0.0",
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-CQoAsNNE.js","names":["context: Context","resolvers: { filter: Filter; hook: ResolveHook }[]","loaders: { filter: Filter; hook: LoadHook }[]","processors: { filter: Filter; hook: ProcessHook }[]","queue: Task[]","defer","build: Build"],"sources":["../src/defer.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 { glob, hasMagic } from \"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\";\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\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\n const context: Context = {\n config: { ...config, destination, obsolete, exclude, walk },\n generatedAt: new Date(),\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 resolve(args: ResolveArgs) {\n const { entrypoint, path, namespace } = args;\n const skipped =\n (args.path !== args.entrypoint && !context.config.walk) ||\n 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 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 plugin of config.plugins) {\n logger?.debug({ plugin: plugin.name }, \"setting up plugin\");\n plugin.setup(build);\n }\n\n const paths = hasMagic(entrypoint.entrypoint)\n ? await glob(entrypoint.entrypoint, { nodir: true })\n : [entrypoint.entrypoint];\n logger?.debug({ entrypoint: entrypoint.entrypoint, paths }, \"resolved paths\");\n\n for (const path of paths) {\n resolve({ entrypoint: path, path, namespace: \"source\" });\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,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