@let-value/translate-extract 1.1.1 → 1.1.2-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin/cli.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  const require_chunk = require('../chunk-CUT6urMc.cjs');
3
- const require_run = require('../run-MHj974iT.cjs');
3
+ const require_run = require('../run-DOVU7XA7.cjs');
4
4
  let node_util = require("node:util");
5
5
  node_util = require_chunk.__toESM(node_util);
6
6
  let cosmiconfig = require("cosmiconfig");
@@ -74,12 +74,10 @@ async function main() {
74
74
  logLevel: effectiveLogLevel
75
75
  };
76
76
  logger.setLevel(effectiveLogLevel);
77
- const tasks = [];
78
- for (const entrypoint of config.entrypoints) tasks.push(require_run.run(entrypoint, {
77
+ for (const entrypoint of config.entrypoints) await require_run.run(entrypoint, {
79
78
  config,
80
79
  logger
81
- }));
82
- await Promise.all(tasks);
80
+ });
83
81
  }
84
82
  main().catch((err) => {
85
83
  logger.error(err);
package/dist/bin/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { run } from "../run-DbV8QpUz.js";
2
+ import { run } from "../run-BLCu6sdK.js";
3
3
  import { parseArgs } from "node:util";
4
4
  import { cosmiconfig } from "cosmiconfig";
5
5
  import chalk from "chalk";
@@ -68,12 +68,10 @@ async function main() {
68
68
  logLevel: effectiveLogLevel
69
69
  };
70
70
  logger.setLevel(effectiveLogLevel);
71
- const tasks = [];
72
- for (const entrypoint of config.entrypoints) tasks.push(run(entrypoint, {
71
+ for (const entrypoint of config.entrypoints) await run(entrypoint, {
73
72
  config,
74
73
  logger
75
- }));
76
- await Promise.all(tasks);
74
+ });
77
75
  }
78
76
  main().catch((err) => {
79
77
  logger.error(err);
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","names":["colors: Record<LogLevel, ChalkInstance>","defaultLogLevel: LogLevel","config: ResolvedConfig","tasks: Promise<unknown>[]"],"sources":["../../src/logger.ts","../../bin/cli.ts"],"sourcesContent":["import chalk, { type ChalkInstance } from \"chalk\";\nimport log from \"loglevel\";\nimport prefix from \"loglevel-plugin-prefix\";\n\nexport type Logger = log.Logger;\nexport type LogLevelNames = log.LogLevelNames;\nexport type LogLevel = LogLevelNames;\n\nconst colors: Record<LogLevel, ChalkInstance> = {\n trace: chalk.magenta,\n debug: chalk.cyan,\n info: chalk.blue,\n warn: chalk.yellow,\n error: chalk.red,\n};\n\nprefix.reg(log);\nprefix.apply(log, {\n format(level, name) {\n const color = colors[level as LogLevelNames] ?? ((value: string) => value);\n const scope = name ? ` ${chalk.green(`${name}:`)}` : \"\";\n\n return `${color(level)}${scope}`;\n },\n});\n\nexport const logger = log;\n","#!/usr/bin/env node\n\nimport { parseArgs } from \"node:util\";\nimport { cosmiconfig } from \"cosmiconfig\";\nimport type { ResolvedConfig } from \"../src/configuration.ts\";\nimport { type LogLevel, logger } from \"../src/logger.ts\";\nimport { run } from \"../src/run.ts\";\n\nconst moduleName = \"translate\";\nconst defaultLogLevel: LogLevel = \"info\";\n\nfunction unwrapConfig(\n config: ResolvedConfig | { default: ResolvedConfig } | { translateConfig: ResolvedConfig } | undefined,\n) {\n if (config && typeof config === \"object\" && \"default\" in config) {\n return config.default;\n }\n\n if (config && typeof config === \"object\" && \"translateConfig\" in config) {\n return config.translateConfig;\n }\n\n return config;\n}\n\nasync function main() {\n const {\n values: { logLevel },\n } = parseArgs({\n args: process.argv.slice(2),\n options: {\n logLevel: { type: \"string\", short: \"l\" },\n },\n });\n\n const explorer = cosmiconfig(moduleName, {\n searchPlaces: [\n `.${moduleName}rc.js`,\n `.${moduleName}rc.ts`,\n `.${moduleName}rc.mjs`,\n `.${moduleName}rc.cjs`,\n `.config/${moduleName}rc.js`,\n `.config/${moduleName}rc.ts`,\n `.config/${moduleName}rc.mjs`,\n `.config/${moduleName}rc.cjs`,\n `${moduleName}.config.js`,\n `${moduleName}.config.ts`,\n `${moduleName}.config.mjs`,\n `${moduleName}.config.cjs`,\n ],\n });\n\n const result = await explorer.search();\n if (!result || !result.config) {\n logger.error(\"No configuration file found\");\n process.exit(1);\n }\n\n const resolvedConfig = unwrapConfig(result.config);\n if (!resolvedConfig) {\n logger.error(\"Invalid configuration file\");\n process.exit(1);\n }\n\n const effectiveLogLevel = (logLevel as LogLevel | undefined) ?? resolvedConfig.logLevel ?? defaultLogLevel;\n const config: ResolvedConfig = {\n ...resolvedConfig,\n logLevel: effectiveLogLevel,\n };\n logger.setLevel(effectiveLogLevel);\n\n 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":";;;;;;;;;AAQA,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;;;;AClBtB,MAAM,aAAa;AACnB,MAAMC,kBAA4B;AAElC,SAAS,aACL,QACF;AACE,KAAI,UAAU,OAAO,WAAW,YAAY,aAAa,OACrD,QAAO,OAAO;AAGlB,KAAI,UAAU,OAAO,WAAW,YAAY,qBAAqB,OAC7D,QAAO,OAAO;AAGlB,QAAO;;AAGX,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,iBAAiB,aAAa,OAAO,OAAO;AAClD,KAAI,CAAC,gBAAgB;AACjB,SAAO,MAAM,6BAA6B;AAC1C,UAAQ,KAAK,EAAE;;CAGnB,MAAM,oBAAqB,YAAqC,eAAe,YAAY;CAC3F,MAAMC,SAAyB;EAC3B,GAAG;EACH,UAAU;EACb;AACD,QAAO,SAAS,kBAAkB;CAElC,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
+ {"version":3,"file":"cli.js","names":["colors: Record<LogLevel, ChalkInstance>","defaultLogLevel: LogLevel","config: ResolvedConfig"],"sources":["../../src/logger.ts","../../bin/cli.ts"],"sourcesContent":["import chalk, { type ChalkInstance } from \"chalk\";\nimport log from \"loglevel\";\nimport prefix from \"loglevel-plugin-prefix\";\n\nexport type Logger = log.Logger;\nexport type LogLevelNames = log.LogLevelNames;\nexport type LogLevel = LogLevelNames;\n\nconst colors: Record<LogLevel, ChalkInstance> = {\n trace: chalk.magenta,\n debug: chalk.cyan,\n info: chalk.blue,\n warn: chalk.yellow,\n error: chalk.red,\n};\n\nprefix.reg(log);\nprefix.apply(log, {\n format(level, name) {\n const color = colors[level as LogLevelNames] ?? ((value: string) => value);\n const scope = name ? ` ${chalk.green(`${name}:`)}` : \"\";\n\n return `${color(level)}${scope}`;\n },\n});\n\nexport const logger = log;\n","#!/usr/bin/env node\n\nimport { parseArgs } from \"node:util\";\nimport { cosmiconfig } from \"cosmiconfig\";\nimport type { ResolvedConfig } from \"../src/configuration.ts\";\nimport { type LogLevel, logger } from \"../src/logger.ts\";\nimport { run } from \"../src/run.ts\";\n\nconst moduleName = \"translate\";\nconst defaultLogLevel: LogLevel = \"info\";\n\nfunction unwrapConfig(\n config: ResolvedConfig | { default: ResolvedConfig } | { translateConfig: ResolvedConfig } | undefined,\n) {\n if (config && typeof config === \"object\" && \"default\" in config) {\n return config.default;\n }\n\n if (config && typeof config === \"object\" && \"translateConfig\" in config) {\n return config.translateConfig;\n }\n\n return config;\n}\n\nasync function main() {\n const {\n values: { logLevel },\n } = parseArgs({\n args: process.argv.slice(2),\n options: {\n logLevel: { type: \"string\", short: \"l\" },\n },\n });\n\n const explorer = cosmiconfig(moduleName, {\n searchPlaces: [\n `.${moduleName}rc.js`,\n `.${moduleName}rc.ts`,\n `.${moduleName}rc.mjs`,\n `.${moduleName}rc.cjs`,\n `.config/${moduleName}rc.js`,\n `.config/${moduleName}rc.ts`,\n `.config/${moduleName}rc.mjs`,\n `.config/${moduleName}rc.cjs`,\n `${moduleName}.config.js`,\n `${moduleName}.config.ts`,\n `${moduleName}.config.mjs`,\n `${moduleName}.config.cjs`,\n ],\n });\n\n const result = await explorer.search();\n if (!result || !result.config) {\n logger.error(\"No configuration file found\");\n process.exit(1);\n }\n\n const resolvedConfig = unwrapConfig(result.config);\n if (!resolvedConfig) {\n logger.error(\"Invalid configuration file\");\n process.exit(1);\n }\n\n const effectiveLogLevel = (logLevel as LogLevel | undefined) ?? resolvedConfig.logLevel ?? defaultLogLevel;\n const config: ResolvedConfig = {\n ...resolvedConfig,\n logLevel: effectiveLogLevel,\n };\n logger.setLevel(effectiveLogLevel);\n\n for (const entrypoint of config.entrypoints) {\n await run(entrypoint, { config, logger });\n }\n}\n\nvoid main().catch((err) => {\n logger.error(err);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;AAQA,MAAMA,SAA0C;CAC5C,OAAO,MAAM;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;;;;AClBtB,MAAM,aAAa;AACnB,MAAMC,kBAA4B;AAElC,SAAS,aACL,QACF;AACE,KAAI,UAAU,OAAO,WAAW,YAAY,aAAa,OACrD,QAAO,OAAO;AAGlB,KAAI,UAAU,OAAO,WAAW,YAAY,qBAAqB,OAC7D,QAAO,OAAO;AAGlB,QAAO;;AAGX,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,iBAAiB,aAAa,OAAO,OAAO;AAClD,KAAI,CAAC,gBAAgB;AACjB,SAAO,MAAM,6BAA6B;AAC1C,UAAQ,KAAK,EAAE;;CAGnB,MAAM,oBAAqB,YAAqC,eAAe,YAAY;CAC3F,MAAMC,SAAyB;EAC3B,GAAG;EACH,UAAU;EACb;AACD,QAAO,SAAS,kBAAkB;AAElC,MAAK,MAAM,cAAc,OAAO,YAC5B,OAAM,IAAI,YAAY;EAAE;EAAQ;EAAQ,CAAC;;AAI5C,MAAM,CAAC,OAAO,QAAQ;AACvB,QAAO,MAAM,IAAI;AACjB,SAAQ,KAAK,EAAE;EACjB"}
@@ -67,6 +67,7 @@ type MaybePromise<T> = T | Promise<T>;
67
67
  interface Context {
68
68
  config: ResolvedConfig;
69
69
  generatedAt: Date;
70
+ paths: Set<string>;
70
71
  logger?: Logger;
71
72
  }
72
73
  interface ResolveArgs<TInput = unknown> {
@@ -114,6 +115,7 @@ type LoadHook<TInput = unknown> = (args: LoadArgs<TInput>) => MaybePromise<LoadR
114
115
  type ProcessHook<TInput = unknown, TOutput = unknown> = (args: ProcessArgs<TInput>) => MaybePromise<ProcessResult<TOutput> | undefined>;
115
116
  interface Build<TInput = unknown, TOutput = unknown> {
116
117
  context: Context;
118
+ source(path: string): void;
117
119
  resolve(args: ResolveArgs<unknown>): void;
118
120
  load(args: LoadArgs<unknown>): void;
119
121
  process(args: ProcessArgs<unknown>): void;
@@ -238,4 +240,4 @@ interface ResolvedConfig {
238
240
  declare function defineConfig(config: UserConfig): ResolvedConfig;
239
241
  //#endregion
240
242
  export { Build, Context, DestinationFn, EntrypointConfig, Exclude, ExcludeFn, Filter, LoadArgs, LoadHook, LoadResult, Logger, ObsoleteStrategy, Plugin, ProcessArgs, ProcessHook, ProcessResult, ResolveArgs, ResolveHook, ResolveResult, ResolvedConfig, ResolvedEntrypoint, StaticPlugin, UniversalPlugin, UserConfig, cleanup, cleanup$1, core, core$1, defineConfig, po, po$1, react$1 as react, react as react$1 };
241
- //# sourceMappingURL=configuration-Bd6mIjFe.d.cts.map
243
+ //# sourceMappingURL=configuration-CTy0NMkD.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration-CTy0NMkD.d.cts","names":[],"sources":["../src/logger.ts","../src/plugins/cleanup/cleanup.ts","../src/plugins/core/queries/types.ts","../src/plugins/core/core.ts","../src/plugins/po/po.ts","../src/plugins/react/react.ts","../src/static.ts","../src/plugin.ts","../src/configuration.ts"],"sourcesContent":[],"mappings":";;;;KAIY,MAAA,GAAS,GAAA,CAAI;KACb,aAAA,GAAgB,GAAA,CAAI;KACpB,QAAA,GAAW;;;iBCGP,SAAA,CAAA,GAAW;;;UCPV,QAAA;;;EFEL,SAAM,CAAA,EAAA,MAAA;EACN,IAAA,CAAA,EAAA,MAAA;EACA,QAAA,CAAA,EAAQ,MAAA;;UEIH,WAAA;;EDDD,EAAA,EAAA,MAAA;;;aCMD;EAbE,QAAA,CAAA,EAAQ,OAAA;AAQzB;;;iBCCgB,MAAA,CAAA,GAAQ,eAAe;;;iBCCvB,IAAA,CAAA,GAAM;;;iBCHN,KAAA,CAAA,GAAS,eAAe;;;ALL5B,iBMCI,IAAA,CNDS,GAAA,KAAM,EMCA,UNDA,CAAA,OMCkB,MNDlB,CAAA,CAAA,EAAA;EACnB,SAAA,MAAA,EAAa;IACb,SAAQ,IAAA,EAAA,MAAG;;;;ACGP,iBKKA,OAAA,CLLW,GAAA,KAAM,EKKD,ULLC,CAAA,OKKiB,KLLjB,CAAA,CAAA,EAAA;;;;ECPhB,CAAA;AAQjB,CAAA;iBIYgB,EAAA,WAAa,kBAAkB;;;IHX/B,SAAI,KAAA,EAAA,EAAA;EAAA,CAAA;;AAAI,iBGoBR,OAAA,CHpBQ,GAAA,KAAA,EGoBU,UHpBV,CAAA,OGoB4B,SHpB5B,CAAA,CAAA,EAAA;EAA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AAA,IAAA,EAAA,OAAA;UAAqC,EC0C3C,QD1C2C;SAAT,EC2CnC,OD3CmC,EAAA;;;;;AAChD;AAAuB,iBCiFP,YAAA,CDjFO,MAAA,ECiFc,UDjFd,CAAA,ECiF2B,cDjF3B"}
@@ -68,6 +68,7 @@ type MaybePromise<T> = T | Promise<T>;
68
68
  interface Context {
69
69
  config: ResolvedConfig;
70
70
  generatedAt: Date;
71
+ paths: Set<string>;
71
72
  logger?: Logger;
72
73
  }
73
74
  interface ResolveArgs<TInput = unknown> {
@@ -115,6 +116,7 @@ type LoadHook<TInput = unknown> = (args: LoadArgs<TInput>) => MaybePromise<LoadR
115
116
  type ProcessHook<TInput = unknown, TOutput = unknown> = (args: ProcessArgs<TInput>) => MaybePromise<ProcessResult<TOutput> | undefined>;
116
117
  interface Build<TInput = unknown, TOutput = unknown> {
117
118
  context: Context;
119
+ source(path: string): void;
118
120
  resolve(args: ResolveArgs<unknown>): void;
119
121
  load(args: LoadArgs<unknown>): void;
120
122
  process(args: ProcessArgs<unknown>): void;
@@ -239,4 +241,4 @@ interface ResolvedConfig {
239
241
  declare function defineConfig(config: UserConfig): ResolvedConfig;
240
242
  //#endregion
241
243
  export { Build, Context, DestinationFn, EntrypointConfig, Exclude, ExcludeFn, Filter, LoadArgs, LoadHook, LoadResult, Logger, ObsoleteStrategy, Plugin, ProcessArgs, ProcessHook, ProcessResult, ResolveArgs, ResolveHook, ResolveResult, ResolvedConfig, ResolvedEntrypoint, StaticPlugin, UniversalPlugin, UserConfig, cleanup, cleanup$1, core, core$1, defineConfig, po, po$1, react$1 as react, react as react$1 };
242
- //# sourceMappingURL=configuration-xNU7-De0.d.ts.map
244
+ //# sourceMappingURL=configuration-fs9HmV_j.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration-fs9HmV_j.d.ts","names":[],"sources":["../src/logger.ts","../src/plugins/cleanup/cleanup.ts","../src/plugins/core/queries/types.ts","../src/plugins/core/core.ts","../src/plugins/po/po.ts","../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EJTD,WAAE,CAAA,EIWA,aJXU;aIYb;;YAED,UAAU;AHjBxB;AAAqB,UGoBJ,UAAA,CHpBI;;;;;;kBG0BD;EF9BJ;;;;;EASA,OAAA,CAAA,EE2BF,iBF3BO,EAAA;EAAA;;;;AAQrB;EAAkB,OAAA,CAAA,EEyBJ,eFzBI,EAAA,GAAA,CAAA,CAAA,cAAA,EEyBkC,cFzBlC,EAAA,GEyBqD,eFzBrD,EAAA,CAAA;;;;AASlB;;;;EAA4C,WAAA,EAAA,MAAA,GEwBlB,gBFxBkB,GEwBC,KFxBD,CAAA,MAAA,GEwBgB,gBFxBhB,CAAA;EAShC;;;;;;aAGY,CAAA,EEmBN,aFnBM;;;;;;;aE0BT;EDjEV;;;;;EAA6B,IAAA,CAAA,EAAA,OAAA;EAEjB;;;;;SAIJ,CAAA,ECuEC,ODvED,GCuEW,ODvEX,EAAA;EAAM;AAGnB;AAOA;AAOA;EAOiB,QAAA,CAAA,ECoDF,QDpDY;AAO3B;AAOiB,UCyCA,kBAAA,SAA2B,IDrC3B,CCqCgC,gBDrChC,EAAA,SAAA,CAAA,CAAA;EAGL,OAAA,CAAA,ECmCE,ODnCI,EAAA;AAClB;AAAuB,UCqCN,cAAA,CDrCM;SACD,ECqCT,eDrCS,EAAA;aAAZ,ECsCO,kBDtCP,EAAA;eACsB,EAAA,MAAA;SAAd,EAAA,MAAA,EAAA;aAAb,ECwCY,aDxCZ;EAAY,QAAA,ECyCH,gBDzCG;EACL,IAAA,EAAA,OAAQ;EAAA,QAAA,EC0CN,QD1CM;SAAqC,EC2C5C,OD3C4C,EAAA;;;;;;AAC7C,iBCiFI,YAAA,CDjFO,MAAA,ECiFc,UDjFd,CAAA,ECiF2B,cDjF3B"}
@@ -1,7 +1,7 @@
1
1
  import { isDeepStrictEqual } from "node:util";
2
+ import path, { dirname, extname, join, relative, resolve } from "node:path";
2
3
  import glob from "fast-glob";
3
4
  import fs, { readFile } from "node:fs/promises";
4
- import path, { dirname, extname, join, relative, resolve } from "node:path";
5
5
  import * as gettextParser from "gettext-parser";
6
6
  import fs$1 from "node:fs";
7
7
  import Parser from "@keqingmoe/tree-sitter";
@@ -109,6 +109,16 @@ const withComment = (query) => ({
109
109
  }
110
110
  });
111
111
 
112
+ //#endregion
113
+ //#region src/plugins/core/queries/entrypoint.ts
114
+ const entrypointCommentPattern = /(?:^|\s)@?translate-entrypoint(?:\s|$)/;
115
+ const entrypointQuery = {
116
+ pattern: `(comment) @comment`,
117
+ extract(match) {
118
+ return match.captures.filter((capture) => capture.name === "comment").some((capture) => entrypointCommentPattern.test(getComment(capture.node)));
119
+ }
120
+ };
121
+
112
122
  //#endregion
113
123
  //#region src/plugins/core/queries/import.ts
114
124
  const importQuery = {
@@ -531,6 +541,7 @@ function parseSource$1(source, path$1) {
531
541
  const context = { path: path$1 };
532
542
  const { parser, language } = getParser(path$1);
533
543
  const tree = parser.parse(source);
544
+ const entrypoint = getCachedQuery(language, entrypointQuery.pattern).matches(tree.rootNode).some(entrypointQuery.extract);
534
545
  const translations = [];
535
546
  const warnings = [];
536
547
  const imports = [];
@@ -565,7 +576,8 @@ function parseSource$1(source, path$1) {
565
576
  return {
566
577
  translations,
567
578
  imports,
568
- warnings
579
+ warnings,
580
+ entrypoint
569
581
  };
570
582
  }
571
583
 
@@ -654,14 +666,22 @@ function core() {
654
666
  filter: filter$1,
655
667
  namespace: namespace$1
656
668
  }, ({ entrypoint, path: path$1, data }) => {
657
- const { translations, imports, warnings } = parseSource$1(data, path$1);
669
+ const result = parseSource$1(data, path$1);
670
+ if (result.entrypoint && entrypoint !== path$1) {
671
+ build.source(path$1);
672
+ return;
673
+ }
674
+ const { translations, imports, warnings } = result;
658
675
  if (build.context.config.walk) {
659
676
  const paths = resolveImports(path$1, imports);
660
- for (const path$2 of paths) build.resolve({
661
- entrypoint,
662
- path: path$2,
663
- namespace: namespace$1
664
- });
677
+ for (const path$2 of paths) {
678
+ if (build.context.paths.has(path$2)) continue;
679
+ build.resolve({
680
+ entrypoint,
681
+ path: path$2,
682
+ namespace: namespace$1
683
+ });
684
+ }
665
685
  }
666
686
  for (const warning of warnings) build.context.logger?.warn(`${warning.error} at ${warning.reference}`);
667
687
  build.resolve({
@@ -679,7 +699,7 @@ function core() {
679
699
  //#region src/plugins/po/collect.ts
680
700
  function collect(source, locale) {
681
701
  const translations = { "": {} };
682
- const nplurals = locale ? getNPlurals(locale) : void 0;
702
+ const nplurals = locale ? Number(getNPlurals(locale)) : void 0;
683
703
  for (const { context, id, message, comments, obsolete, plural } of source) {
684
704
  const ctx = context || "";
685
705
  if (!translations[ctx]) translations[ctx] = {};
@@ -768,7 +788,7 @@ function merge(sources, existing, obsolete, locale, generatedAt) {
768
788
  let headers = {};
769
789
  let translations = { "": {} };
770
790
  let obsoleteTranslations = {};
771
- const nplurals = getNPlurals(locale);
791
+ const nplurals = Number(getNPlurals(locale));
772
792
  if (existing) {
773
793
  headers = existing.headers ? structuredClone(existing.headers) : {};
774
794
  translations = existing.translations ? structuredClone(existing.translations) : { "": {} };
@@ -1279,11 +1299,17 @@ function resolveStaticPlugin(item) {
1279
1299
 
1280
1300
  //#endregion
1281
1301
  //#region src/run.ts
1302
+ async function getPaths(entrypoint) {
1303
+ const pattern = entrypoint.entrypoint.replace(/\\/g, "/");
1304
+ const paths = glob.isDynamicPattern(pattern) ? await glob(pattern, { onlyFiles: true }) : [entrypoint.entrypoint];
1305
+ return new Set(paths.map((path$1) => resolve(path$1)));
1306
+ }
1282
1307
  async function run(entrypoint, { config, logger }) {
1283
1308
  const destination = entrypoint.destination ?? config.destination;
1284
1309
  const obsolete = entrypoint.obsolete ?? config.obsolete;
1285
1310
  const exclude = entrypoint.exclude ?? config.exclude;
1286
1311
  const walk = entrypoint.walk ?? config.walk;
1312
+ const paths = /* @__PURE__ */ new Set();
1287
1313
  const context = {
1288
1314
  config: {
1289
1315
  ...config,
@@ -1293,6 +1319,7 @@ async function run(entrypoint, { config, logger }) {
1293
1319
  walk
1294
1320
  },
1295
1321
  generatedAt: /* @__PURE__ */ new Date(),
1322
+ paths,
1296
1323
  logger
1297
1324
  };
1298
1325
  logger?.info(entrypoint, "starting extraction");
@@ -1317,6 +1344,20 @@ async function run(entrypoint, { config, logger }) {
1317
1344
  function defer(namespace$3) {
1318
1345
  return getDeferred(namespace$3).promise;
1319
1346
  }
1347
+ function source(path$1) {
1348
+ const resolvedPath = resolve(path$1);
1349
+ if (paths.has(resolvedPath)) return;
1350
+ logger?.debug({
1351
+ entrypoint: entrypoint.entrypoint,
1352
+ path: resolvedPath
1353
+ }, "resolved path");
1354
+ paths.add(resolvedPath);
1355
+ resolve$1({
1356
+ entrypoint: resolvedPath,
1357
+ path: resolvedPath,
1358
+ namespace: "source"
1359
+ });
1360
+ }
1320
1361
  function resolve$1(args) {
1321
1362
  const { entrypoint: entrypoint$1, path: path$1, namespace: namespace$3 } = args;
1322
1363
  const skipped = context.config.exclude.some((ex) => typeof ex === "function" ? ex(args) : ex.test(args.path));
@@ -1361,6 +1402,7 @@ async function run(entrypoint, { config, logger }) {
1361
1402
  }
1362
1403
  const build = {
1363
1404
  context,
1405
+ source,
1364
1406
  resolve: resolve$1,
1365
1407
  load,
1366
1408
  process: process$1,
@@ -1389,17 +1431,7 @@ async function run(entrypoint, { config, logger }) {
1389
1431
  logger?.debug({ plugin: plugin.name }, "setting up plugin");
1390
1432
  plugin.setup(build);
1391
1433
  }
1392
- const pattern = entrypoint.entrypoint.replace(/\\/g, "/");
1393
- const paths = glob.isDynamicPattern(pattern) ? await glob(pattern, { onlyFiles: true }) : [entrypoint.entrypoint];
1394
- logger?.debug({
1395
- entrypoint: entrypoint.entrypoint,
1396
- paths
1397
- }, "resolved paths");
1398
- for (const path$1 of paths) resolve$1({
1399
- entrypoint: path$1,
1400
- path: path$1,
1401
- namespace: "source"
1402
- });
1434
+ for (const path$1 of await getPaths(entrypoint)) source(path$1);
1403
1435
  async function processTask(task) {
1404
1436
  const { type } = task;
1405
1437
  let args = task.args;
@@ -1436,4 +1468,4 @@ async function run(entrypoint, { config, logger }) {
1436
1468
 
1437
1469
  //#endregion
1438
1470
  export { cleanup, core, po, react, run };
1439
- //# sourceMappingURL=run-DbV8QpUz.js.map
1471
+ //# sourceMappingURL=run-BLCu6sdK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-BLCu6sdK.js","names":["namespace","path","path","entrypointQuery: EntrypointSpec","importQuery: ImportQuerySpec","current: Parser.SyntaxNode | null","messageQuery: QuerySpec","allowed","messageInvalidQuery: QuerySpec","ids: string[]","strs: string[]","subMatch: Parser.QueryMatch","translation: Translation","contextMsgQuery: QuerySpec","msgCall","contextPluralQuery: QuerySpec","contextInvalidQuery: QuerySpec","gettextQuery: QuerySpec","gettextInvalidQuery: QuerySpec","msgCall","plainMsg","msgArg","ngettextQuery: QuerySpec","msgCall","npgettextQuery: QuerySpec","pgettextQuery: QuerySpec","pluralQuery: QuerySpec","queries: QuerySpec[]","messageQuery","pluralQuery","path","parseSource","context: Context","translations: Translation[]","warnings: Warning[]","imports: string[]","queries","fs","resolved: string[]","filter","namespace","path","parseSource","translations: GetTextTranslationRecord","value","normalizedHeaders: Record<string, string>","headers: Record<string, string>","translations: GetTextTranslationRecord","obsoleteTranslations: GetTextTranslationRecord","collected: GetTextTranslationRecord","translations","existing","path","parts: Part[]","text","strings: string[]","values: string[]","messageQuery: QuerySpec","attrs: Parser.SyntaxNode[]","msgctxt: string | undefined","childValue: Parser.SyntaxNode | undefined","error: string | undefined","translation: Translation","forms: string[]","pluralQuery: QuerySpec","attrs: Parser.SyntaxNode[]","msgctxt: string | undefined","formsNode: Parser.SyntaxNode | null | undefined","translation: Translation","queries: QuerySpec[]","context: Context","path","translations: Translation[]","warnings: Warning[]","path","resolvePath","path","context: Context","resolvers: { filter: Filter; hook: ResolveHook }[]","loaders: { filter: Filter; hook: LoadHook }[]","processors: { filter: Filter; hook: ProcessHook }[]","queue: Task[]","defer","namespace","resolve","process","build: Build","filter"],"sources":["../src/defer.ts","../src/plugins/cleanup/cleanup.ts","../src/plugins/core/queries/comment.ts","../src/plugins/core/queries/entrypoint.ts","../src/plugins/core/queries/import.ts","../src/plugins/core/queries/utils.ts","../src/plugins/core/queries/message.ts","../src/plugins/core/queries/plural-utils.ts","../src/plugins/core/queries/context.ts","../src/plugins/core/queries/gettext.ts","../src/plugins/core/queries/ngettext.ts","../src/plugins/core/queries/npgettext.ts","../src/plugins/core/queries/pgettext.ts","../src/plugins/core/queries/plural.ts","../src/plugins/core/queries/index.ts","../src/plugins/core/parse.ts","../src/plugins/core/resolve.ts","../src/plugins/core/core.ts","../src/plugins/po/collect.ts","../src/plugins/po/hasChanges.ts","../src/plugins/po/merge.ts","../src/plugins/po/po.ts","../src/plugins/react/queries/utils.ts","../src/plugins/react/queries/message.ts","../src/plugins/react/queries/plural.ts","../src/plugins/react/queries/index.ts","../src/plugins/react/parse.ts","../src/plugins/react/react.ts","../src/plugins/static.ts","../src/run.ts"],"sourcesContent":["export class Defer {\n pending = 0;\n promise: Promise<void> = Promise.resolve();\n resolve?: () => void;\n\n enqueue() {\n if (this.pending++ === 0) {\n this.promise = new Promise<void>((res) => {\n this.resolve = res;\n });\n }\n }\n dequeue() {\n if (this.pending > 0 && --this.pending === 0) {\n this.resolve?.();\n }\n }\n}\n","import fs from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\n\nimport * as gettextParser from \"gettext-parser\";\n\nimport type { Plugin } from \"../../plugin.ts\";\n\nconst namespace = \"cleanup\";\n\nexport function cleanup(): Plugin {\n return {\n name: \"cleanup\",\n setup(build) {\n build.context.logger?.debug(\"cleanup plugin initialized\");\n const processed = new Set<string>();\n const generated = new Set<string>();\n const dirs = new Set<string>();\n let dispatched = false;\n\n build.onResolve({ namespace, filter: /.*/ }, ({ path }) => {\n generated.add(path);\n dirs.add(dirname(path));\n\n Promise.all([build.defer(\"source\"), build.defer(\"translate\"), build.defer(namespace)]).then(() => {\n if (dispatched) {\n return;\n }\n dispatched = true;\n\n for (const path of dirs.values()) {\n build.process({ entrypoint: path, path, namespace, data: undefined });\n }\n });\n\n return undefined;\n });\n\n build.onProcess({ namespace, filter: /.*/ }, async ({ path }) => {\n if (processed.has(path)) {\n return undefined;\n }\n processed.add(path);\n const files = await fs.readdir(path).catch(() => []);\n for (const f of files.filter((p) => p.endsWith(\".po\"))) {\n const full = join(path, f);\n const contents = await fs.readFile(full).catch(() => undefined);\n if (!contents) {\n continue;\n }\n const parsed = gettextParser.po.parse(contents);\n const hasTranslations = Object.entries(parsed.translations || {}).some(([ctx, msgs]) =>\n Object.keys(msgs).some((id) => !(ctx === \"\" && id === \"\")),\n );\n if (!hasTranslations && generated.has(full)) {\n await fs.unlink(full);\n }\n if (hasTranslations && !generated.has(full)) {\n build.context.logger?.warn({ path: full }, \"stray translation file\");\n }\n }\n return undefined;\n });\n },\n };\n}\n","import { relative } from \"node:path\";\nimport type Parser from \"@keqingmoe/tree-sitter\";\n\nimport type { Context, QuerySpec } from \"./types.ts\";\n\nexport function getReference(node: Parser.SyntaxNode, { path }: Context) {\n const line = node.startPosition.row + 1;\n const rel = relative(process.cwd(), path).replace(/\\\\+/g, \"/\");\n return `${rel}:${line}`;\n}\n\nexport function getComment(node: Parser.SyntaxNode): string {\n const text = node.text;\n if (text.startsWith(\"/*\")) {\n return text\n .slice(2, -2)\n .replace(/^\\s*\\*?\\s*/gm, \"\")\n .trim();\n }\n return text.replace(/^\\/\\/\\s?/, \"\").trim();\n}\n\nexport const withComment = (query: QuerySpec): QuerySpec => ({\n pattern: `(\n\t((comment) @comment)?\n .\n\t(_ ${query.pattern})\n)`,\n extract(match) {\n const result = query.extract(match);\n if (!result?.translation) {\n return result;\n }\n\n const comment = match.captures.find((c) => c.name === \"comment\")?.node;\n if (!comment) {\n return result;\n }\n\n if (comment) {\n result.translation.comments = {\n ...result.translation.comments,\n extracted: getComment(comment),\n };\n }\n\n return result;\n },\n});\n","import type Parser from \"@keqingmoe/tree-sitter\";\nimport { getComment } from \"./comment.ts\";\nimport type { EntrypointSpec } from \"./types.ts\";\n\nconst entrypointCommentPattern = /(?:^|\\s)@?translate-entrypoint(?:\\s|$)/;\n\nexport const entrypointQuery: EntrypointSpec = {\n pattern: `(comment) @comment`,\n extract(match: Parser.QueryMatch): boolean | undefined {\n return match.captures\n .filter((capture) => capture.name === \"comment\")\n .some((capture) => entrypointCommentPattern.test(getComment(capture.node)));\n },\n};\n","import type Parser from \"@keqingmoe/tree-sitter\";\nimport type { ImportQuerySpec } from \"./types.ts\";\n\nexport const importQuery: ImportQuerySpec = {\n pattern: `\n [\n (import_statement\n source: (string (string_fragment) @import))\n (export_statement\n source: (string (string_fragment) @import))\n (call_expression\n function: (identifier) @func\n arguments: (arguments (string (string_fragment) @import))\n (#eq? @func \"require\"))\n (call_expression\n function: (member_expression\n object: (identifier) @obj\n property: (property_identifier) @method)\n arguments: (arguments (string (string_fragment) @import))\n (#eq? @obj \"require\")\n (#eq? @method \"resolve\"))\n (call_expression\n function: (import)\n arguments: (arguments (string (string_fragment) @import)))\n ]\n `,\n extract(match: Parser.QueryMatch): string | undefined {\n const node = match.captures.find((c) => c.name === \"import\")?.node;\n return node?.text;\n },\n};\n","import type Parser from \"@keqingmoe/tree-sitter\";\n\nexport const callPattern = (fnName: string, args: string, allowMember = true): string => `(\n (call_expression\n function: ${\n allowMember\n ? `[\n (identifier) @func\n (member_expression property: (property_identifier) @func)\n ]`\n : `(identifier) @func`\n }\n arguments: ${args}\n ) @call\n (#eq? @func \"${fnName}\")\n)`;\n\nexport function isDescendant(node: Parser.SyntaxNode, ancestor: Parser.SyntaxNode): boolean {\n let current: Parser.SyntaxNode | null = node;\n while (current) {\n if (current.id === ancestor.id) return true;\n current = current.parent;\n }\n return false;\n}\n","import type Parser from \"@keqingmoe/tree-sitter\";\nimport { withComment } from \"./comment.ts\";\nimport type { MessageMatch, QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nconst notInPlural = (query: QuerySpec): QuerySpec => ({\n pattern: query.pattern,\n extract(match) {\n const result = query.extract(match);\n if (!result?.node) {\n return result;\n }\n\n let parent = result.node.parent;\n\n if (parent && parent.type === \"arguments\") {\n parent = parent.parent;\n }\n\n if (parent && parent.type === \"call_expression\") {\n const fn = parent.childForFieldName(\"function\");\n if (fn) {\n if (\n (fn.type === \"identifier\" &&\n (fn.text === \"plural\" ||\n fn.text === \"ngettext\" ||\n fn.text === \"pgettext\" ||\n fn.text === \"npgettext\")) ||\n (fn.type === \"member_expression\" &&\n [\"plural\", \"ngettext\", \"pgettext\", \"npgettext\"].includes(\n fn.childForFieldName(\"property\")?.text ?? \"\",\n ))\n ) {\n return undefined;\n }\n }\n }\n\n return result;\n },\n});\n\nexport const messageArg = `[\n (string (string_fragment) @msgid)\n (object\n (_)*\n (pair\n key: (property_identifier) @id_key\n value: (string (string_fragment) @id)\n (#eq? @id_key \"id\")\n )?\n (_)*\n (pair\n key: (property_identifier) @msg_key\n value: (string (string_fragment) @message)\n (#eq? @msg_key \"message\")\n )?\n (_)*\n )\n (template_string) @tpl\n]`;\n\nexport const messageArgs = `[ (arguments ${messageArg}) (template_string) @tpl ]`;\n\nexport const extractMessage =\n (name: string) =>\n (match: Parser.QueryMatch): MessageMatch | undefined => {\n const node = match.captures.find((c) => c.name === \"call\")?.node;\n if (!node) {\n return undefined;\n }\n\n const msgid = match.captures.find((c) => c.name === \"msgid\")?.node.text;\n if (msgid) {\n return {\n node,\n translation: {\n id: msgid,\n message: [msgid],\n },\n };\n }\n\n const tpl = match.captures.find((c) => c.name === \"tpl\")?.node;\n if (tpl) {\n for (const child of tpl.children) {\n if (child.type !== \"template_substitution\") {\n continue;\n }\n\n const expr = child.namedChildren[0];\n if (!expr || expr.type !== \"identifier\") {\n return {\n node,\n error: `${name}() template expressions must be simple identifiers`,\n };\n }\n }\n\n const text = tpl.text.slice(1, -1);\n\n return {\n node,\n translation: { id: text, message: [text] },\n };\n }\n\n const id = match.captures.find((c) => c.name === \"id\")?.node.text;\n const message = match.captures.find((c) => c.name === \"message\")?.node.text;\n const msgId = id ?? message;\n if (!msgId) {\n return undefined;\n }\n\n const msgstr = message ?? id ?? \"\";\n\n return {\n node,\n translation: {\n id: msgId,\n message: [msgstr],\n },\n };\n };\n\nexport const messageQuery: QuerySpec = notInPlural(\n withComment({\n pattern: callPattern(\"message\", messageArgs),\n extract: extractMessage(\"message\"),\n }),\n);\n\nconst allowed = new Set([\"string\", \"object\", \"template_string\"]);\n\nexport const messageInvalidQuery: QuerySpec = notInPlural({\n pattern: callPattern(\"message\", \"(arguments (_) @arg)\"),\n extract(match) {\n const call = match.captures.find((c) => c.name === \"call\")?.node;\n const node = match.captures.find((c) => c.name === \"arg\")?.node;\n\n if (!call || !node) {\n return undefined;\n }\n\n if (allowed.has(node.type)) {\n return undefined;\n }\n\n return {\n node,\n error: \"message() argument must be a string literal, object literal, or template literal\",\n };\n },\n});\n","import type Parser from \"@keqingmoe/tree-sitter\";\nimport { extractMessage } from \"./message.ts\";\nimport type { MessageMatch, Translation } from \"./types.ts\";\nimport { isDescendant } from \"./utils.ts\";\n\nexport const extractPluralForms =\n (name: string) =>\n (match: Parser.QueryMatch): MessageMatch | undefined => {\n const call = match.captures.find((c) => c.name === \"call\")?.node;\n const n = match.captures.find((c) => c.name === \"n\")?.node;\n if (!call || !n || n.nextNamedSibling) {\n return undefined;\n }\n\n const msgctxt = match.captures.find((c) => c.name === \"msgctxt\")?.node?.text;\n const msgNodes = match.captures.filter((c) => c.name === \"msg\").map((c) => c.node);\n\n const ids: string[] = [];\n const strs: string[] = [];\n\n for (const node of msgNodes) {\n const relevant = match.captures.filter(\n (c) => [\"msgid\", \"id\", \"message\", \"tpl\"].includes(c.name) && isDescendant(c.node, node),\n );\n\n const subMatch: Parser.QueryMatch = {\n pattern: 0,\n captures: [{ name: \"call\", node }, ...relevant],\n };\n\n const result = extractMessage(name)(subMatch);\n if (!result) continue;\n if (result.error) {\n return { node: call, error: result.error };\n }\n if (result.translation) {\n ids.push(result.translation.id);\n strs.push(result.translation.message[0] ?? \"\");\n }\n }\n\n if (ids.length === 0) {\n return undefined;\n }\n\n const translation: Translation = {\n id: ids[0],\n plural: ids[1],\n message: strs,\n };\n if (msgctxt) translation.context = msgctxt;\n\n return { node: call, translation };\n };\n","import { withComment } from \"./comment.ts\";\nimport { extractMessage, messageArgs } from \"./message.ts\";\nimport { extractPluralForms } from \"./plural-utils.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nconst ctxCall = callPattern(\n \"context\",\n `[\n (arguments (string (string_fragment) @msgctxt))\n (template_string) @msgctxt\n]`,\n)\n .replace(/@call/g, \"@ctx\")\n .replace(/@func/g, \"@ctxfn\");\n\nexport const contextMsgQuery: QuerySpec = withComment({\n pattern: `(\n (call_expression\n function: (member_expression\n object: ${ctxCall}\n property: (property_identifier) @func\n )\n arguments: ${messageArgs}\n ) @call\n (#eq? @func \"message\")\n)`,\n extract(match) {\n const result = extractMessage(\"context.message\")(match);\n const contextNode = match.captures.find((c) => c.name === \"msgctxt\")?.node;\n if (!result || !result.translation || !contextNode) {\n return result;\n }\n\n if (contextNode.type === \"template_string\") {\n for (const child of contextNode.children) {\n if (child.type !== \"template_substitution\") {\n continue;\n }\n\n const expr = child.namedChildren[0];\n if (!expr || expr.type !== \"identifier\") {\n return {\n node: contextNode,\n error: \"context() template expressions must be simple identifiers\",\n };\n }\n }\n }\n\n const contextText = contextNode.type === \"template_string\" ? contextNode.text.slice(1, -1) : contextNode.text;\n return {\n node: result.node,\n translation: {\n ...result.translation,\n context: contextText,\n },\n };\n },\n});\n\nconst msgCall = callPattern(\"message\", messageArgs, false).replace(/@call/g, \"@msg\").replace(/@func/g, \"@msgfn\");\n\nexport const contextPluralQuery: QuerySpec = withComment({\n pattern: `(\n (call_expression\n function: (member_expression\n object: ${ctxCall}\n property: (property_identifier) @func\n )\n arguments: (arguments (\n (${msgCall} (\",\" )?)+\n (number) @n\n ))\n ) @call\n (#eq? @func \"plural\")\n)`,\n extract: extractPluralForms(\"context.plural\"),\n});\n\nexport const contextInvalidQuery: QuerySpec = withComment({\n pattern: ctxCall,\n extract(match) {\n const call = match.captures.find((c) => c.name === \"ctx\")?.node;\n if (!call) {\n return undefined;\n }\n\n const parent = call.parent;\n if (parent && parent.type === \"member_expression\" && parent.childForFieldName(\"object\")?.id === call.id) {\n const property = parent.childForFieldName(\"property\")?.text;\n const grandparent = parent.parent;\n if (\n grandparent &&\n grandparent.type === \"call_expression\" &&\n grandparent.childForFieldName(\"function\")?.id === parent.id &&\n (property === \"message\" || property === \"plural\")\n ) {\n return undefined;\n }\n }\n\n return {\n node: call,\n error: \"context() must be used with message() or plural() in the same expression\",\n };\n },\n});\n","import { withComment } from \"./comment.ts\";\nimport { extractMessage, messageArgs } from \"./message.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nexport const gettextQuery: QuerySpec = withComment({\n pattern: callPattern(\"gettext\", messageArgs),\n extract: extractMessage(\"gettext\"),\n});\n\nconst allowed = new Set([\"string\", \"object\", \"template_string\", \"identifier\", \"call_expression\"]);\n\nexport const gettextInvalidQuery: QuerySpec = {\n pattern: callPattern(\"gettext\", \"(arguments (_) @arg)\"),\n extract(match) {\n const call = match.captures.find((c) => c.name === \"call\")?.node;\n const node = match.captures.find((c) => c.name === \"arg\")?.node;\n\n if (!call || !node) {\n return undefined;\n }\n\n if (allowed.has(node.type)) {\n return undefined;\n }\n\n return {\n node,\n error: \"gettext() argument must be a string literal, object literal, or template literal\",\n };\n },\n};\n","import { withComment } from \"./comment.ts\";\nimport { messageArg, messageArgs } from \"./message.ts\";\nimport { extractPluralForms } from \"./plural-utils.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nconst msgCall = callPattern(\"message\", messageArgs).replace(/@call/g, \"@msg\").replace(/@func/g, \"@msgfn\");\nconst plainMsg = `(${messageArg}) @msg`;\nconst msgArg = `[${msgCall} ${plainMsg}]`;\n\nexport const ngettextQuery: QuerySpec = withComment({\n pattern: callPattern(\"ngettext\", `(arguments ${msgArg} \",\" ${msgArg} (\",\" ${msgArg})* \",\" (_) @n)`),\n extract: extractPluralForms(\"ngettext\"),\n});\n","import { withComment } from \"./comment.ts\";\nimport { messageArg, messageArgs } from \"./message.ts\";\nimport { extractPluralForms } from \"./plural-utils.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nconst msgCall = callPattern(\"message\", messageArgs).replace(/@call/g, \"@msg\").replace(/@func/g, \"@msgfn\");\nconst plainMsg = `(${messageArg}) @msg`;\nconst msgArg = `[${msgCall} ${plainMsg}]`;\n\nexport const npgettextQuery: QuerySpec = withComment({\n pattern: callPattern(\n \"npgettext\",\n `(arguments (string (string_fragment) @msgctxt) \",\" ${msgArg} \",\" ${msgArg} (\",\" ${msgArg})* \",\" (_) @n)`,\n ),\n extract: extractPluralForms(\"npgettext\"),\n});\n","import { withComment } from \"./comment.ts\";\nimport { extractMessage, messageArg } from \"./message.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nexport const pgettextQuery: QuerySpec = withComment({\n pattern: callPattern(\"pgettext\", `(arguments (string (string_fragment) @msgctxt) \",\" ${messageArg})`),\n extract(match) {\n const result = extractMessage(\"pgettext\")(match);\n const contextNode = match.captures.find((c) => c.name === \"msgctxt\")?.node;\n if (!result || !contextNode || !result.translation) {\n return result;\n }\n return {\n node: result.node,\n translation: {\n ...result.translation,\n context: contextNode.text,\n },\n };\n },\n});\n","import { withComment } from \"./comment.ts\";\nimport { messageArgs } from \"./message.ts\";\nimport { extractPluralForms } from \"./plural-utils.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nconst msgCall = callPattern(\"message\", messageArgs, false).replace(/@call/g, \"@msg\").replace(/@func/g, \"@msgfn\");\n\nexport const pluralQuery: QuerySpec = withComment({\n pattern: callPattern(\n \"plural\",\n `(arguments (\n (${msgCall} (\",\" )?)+\n (number) @n\n ))`,\n false,\n ),\n extract: extractPluralForms(\"plural\"),\n});\n","import { contextInvalidQuery, contextMsgQuery, contextPluralQuery } from \"./context.ts\";\nimport { gettextInvalidQuery, gettextQuery } from \"./gettext.ts\";\nimport { messageInvalidQuery, messageQuery } from \"./message.ts\";\nimport { ngettextQuery } from \"./ngettext.ts\";\nimport { npgettextQuery } from \"./npgettext.ts\";\nimport { pgettextQuery } from \"./pgettext.ts\";\nimport { pluralQuery } from \"./plural.ts\";\nimport type { QuerySpec } from \"./types.ts\";\n\nexport type { MessageMatch, QuerySpec } from \"./types.ts\";\n\nexport const queries: QuerySpec[] = [\n contextMsgQuery,\n contextPluralQuery,\n contextInvalidQuery,\n messageQuery,\n messageInvalidQuery,\n gettextQuery,\n gettextInvalidQuery,\n pluralQuery,\n ngettextQuery,\n pgettextQuery,\n npgettextQuery,\n];\n","import fs from \"node:fs\";\nimport { extname, resolve } from \"node:path\";\n\nimport Parser from \"@keqingmoe/tree-sitter\";\nimport JavaScript from \"tree-sitter-javascript\";\nimport TS from \"tree-sitter-typescript\";\n\nimport { getReference } from \"./queries/comment.ts\";\nimport { entrypointQuery } from \"./queries/entrypoint.ts\";\nimport { importQuery } from \"./queries/import.ts\";\nimport { queries } from \"./queries/index.ts\";\nimport type { Context, Translation, Warning } from \"./queries/types.ts\";\n\nexport interface ParseResult {\n translations: Translation[];\n imports: string[];\n warnings: Warning[];\n entrypoint: boolean;\n}\n\nfunction getLanguage(ext: string) {\n switch (ext) {\n case \".ts\":\n return TS.typescript;\n case \".tsx\":\n return TS.tsx;\n default:\n return JavaScript;\n }\n}\n\nconst parserCache = new Map<string, { parser: Parser; language: Parser.Language }>();\nconst queryCache = new WeakMap<Parser.Language, Map<string, Parser.Query>>();\n\nfunction getCachedParser(ext: string) {\n let cached = parserCache.get(ext);\n if (!cached) {\n const parser = new Parser();\n const language = getLanguage(ext) as Parser.Language;\n parser.setLanguage(language);\n cached = { parser, language };\n parserCache.set(ext, cached);\n }\n return cached;\n}\n\nfunction getCachedQuery(language: Parser.Language, pattern: string) {\n let cache = queryCache.get(language);\n if (!cache) {\n cache = new Map();\n queryCache.set(language, cache);\n }\n\n let query = cache.get(pattern);\n if (!query) {\n query = new Parser.Query(language, pattern);\n cache.set(pattern, query);\n }\n\n return query;\n}\n\nexport function getParser(path: string) {\n const ext = extname(path);\n return getCachedParser(ext);\n}\n\nexport function getQuery(language: Parser.Language, pattern: string) {\n return getCachedQuery(language, pattern);\n}\n\nexport function parseFile(filePath: string): ParseResult {\n const path = resolve(filePath);\n const source = fs.readFileSync(path, \"utf8\");\n return parseSource(source, path);\n}\n\nexport function parseSource(source: string, path: string): ParseResult {\n const context: Context = {\n path,\n };\n\n const { parser, language } = getParser(path);\n const tree = parser.parse(source);\n\n const commentQuery = getCachedQuery(language, entrypointQuery.pattern);\n const entrypoint = commentQuery.matches(tree.rootNode).some(entrypointQuery.extract);\n\n const translations: Translation[] = [];\n const warnings: Warning[] = [];\n const imports: string[] = [];\n\n const seen = new Set<number>();\n\n for (const spec of queries) {\n const query = getCachedQuery(language, spec.pattern);\n for (const match of query.matches(tree.rootNode)) {\n const message = spec.extract(match);\n if (!message) {\n continue;\n }\n\n const { node, translation, error } = message;\n if (seen.has(node.id)) {\n continue;\n }\n seen.add(node.id);\n const reference = getReference(node, context);\n\n if (translation) {\n translations.push({\n ...translation,\n comments: {\n ...translation.comments,\n reference,\n },\n });\n }\n\n if (error) {\n warnings.push({\n error,\n reference,\n });\n }\n }\n }\n\n const importTreeQuery = getCachedQuery(language, importQuery.pattern);\n for (const match of importTreeQuery.matches(tree.rootNode)) {\n const imp = importQuery.extract(match);\n if (imp) {\n imports.push(imp);\n }\n }\n\n return { translations, imports, warnings, entrypoint };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { ResolverFactory } from \"oxc-resolver\";\n\nfunction findTsconfig(dir: string): string | undefined {\n let current = dir;\n while (true) {\n const config = path.join(current, \"tsconfig.json\");\n if (fs.existsSync(config)) {\n return config;\n }\n const parent = path.dirname(current);\n if (parent === current) {\n return undefined;\n }\n current = parent;\n }\n}\n\nconst resolverCache = new Map<string, ResolverFactory>();\n\nfunction getResolver(dir: string) {\n const tsconfig = findTsconfig(dir);\n const key = tsconfig ?? \"__default__\";\n let resolver = resolverCache.get(key);\n if (!resolver) {\n resolver = new ResolverFactory({\n extensions: [\".ts\", \".tsx\", \".js\", \".jsx\", \".mjs\", \".cjs\", \".json\"],\n conditionNames: [\"import\", \"require\", \"node\"],\n ...(tsconfig ? { tsconfig: { configFile: tsconfig } } : {}),\n });\n resolverCache.set(key, resolver);\n }\n return resolver;\n}\n\nfunction resolveFromDir(dir: string, spec: string): string | undefined {\n const resolver = getResolver(dir);\n const res = resolver.sync(dir, spec) as { path?: string };\n return res.path;\n}\n\nexport function resolveImport(file: string, spec: string): string | undefined {\n const dir = path.dirname(path.resolve(file));\n return resolveFromDir(dir, spec);\n}\n\nexport function resolveImports(file: string, imports: string[]): string[] {\n const dir = path.dirname(path.resolve(file));\n const resolver = getResolver(dir);\n const resolved: string[] = [];\n for (const spec of imports) {\n const res = resolver.sync(dir, spec) as { path?: string };\n if (res.path) {\n resolved.push(res.path);\n }\n }\n return resolved;\n}\n","import { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\n\nimport type { Plugin } from \"../../plugin.ts\";\nimport { parseSource } from \"./parse.ts\";\nimport type { Translation } from \"./queries/types.ts\";\nimport { resolveImports } from \"./resolve.ts\";\n\nconst filter = /\\.([cm]?tsx?|jsx?)$/;\nconst namespace = \"source\";\n\nexport function core(): Plugin<string, Translation[]> {\n return {\n name: \"core\",\n setup(build) {\n build.context.logger?.debug(\"core plugin initialized\");\n build.onResolve({ filter, namespace }, ({ entrypoint, path }) => {\n return {\n entrypoint,\n namespace,\n path: resolve(path),\n };\n });\n\n build.onLoad({ filter, namespace }, async ({ entrypoint, path }) => {\n const data = await readFile(path, \"utf8\");\n return {\n entrypoint,\n path,\n namespace,\n data,\n };\n });\n\n build.onProcess({ filter, namespace }, ({ entrypoint, path, data }) => {\n const result = parseSource(data, path);\n\n if (result.entrypoint && entrypoint !== path) {\n build.source(path);\n return;\n }\n\n const { translations, imports, warnings } = result;\n\n if (build.context.config.walk) {\n const paths = resolveImports(path, imports);\n for (const path of paths) {\n if (build.context.paths.has(path)) {\n continue;\n }\n\n build.resolve({ entrypoint, path, namespace });\n }\n }\n\n for (const warning of warnings) {\n build.context.logger?.warn(`${warning.error} at ${warning.reference}`);\n }\n\n build.resolve({\n entrypoint,\n path,\n namespace: \"translate\",\n data: translations,\n });\n\n return undefined;\n });\n },\n };\n}\n","import type { GetTextTranslationRecord } from \"gettext-parser\";\nimport { getNPlurals } from \"plural-forms\";\n\nimport type { Translation } from \"../core/queries/types.ts\";\n\nexport function collect(source: Translation[], locale?: string): GetTextTranslationRecord {\n const translations: GetTextTranslationRecord = { \"\": {} };\n const nplurals = locale ? Number(getNPlurals(locale)) : undefined;\n\n for (const { context, id, message, comments, obsolete, plural } of source) {\n const ctx = context || \"\";\n if (!translations[ctx]) {\n translations[ctx] = {};\n }\n\n const length = plural ? (nplurals ?? message.length) : 1;\n\n const existing = translations[ctx][id];\n const refs = new Set<string>();\n if (existing?.comments?.reference) {\n existing.comments.reference.split(/\\r?\\n|\\r/).forEach((r) => {\n refs.add(r);\n });\n }\n if (comments?.reference) {\n comments.reference.split(/\\r?\\n|\\r/).forEach((r) => {\n refs.add(r);\n });\n }\n\n const msgstr = existing?.msgstr ? existing.msgstr.slice(0, length) : Array.from({ length }, () => \"\");\n while (msgstr.length < length) msgstr.push(\"\");\n\n translations[ctx][id] = {\n msgctxt: context || undefined,\n msgid: id,\n msgid_plural: plural,\n msgstr,\n comments: {\n ...existing?.comments,\n ...comments,\n reference: refs.size ? Array.from(refs).join(\"\\n\") : undefined,\n },\n obsolete: existing?.obsolete ?? obsolete,\n };\n }\n\n return translations;\n}\n","import { isDeepStrictEqual } from \"node:util\";\nimport type { GetTextTranslations } from \"gettext-parser\";\nimport * as gettextParser from \"gettext-parser\";\n\nconst IGNORED_HEADER_KEYS = new Set([\"pot-creation-date\", \"po-revision-date\"]);\nconst IGNORED_HEADER_LINE_PREFIXES = [\"pot-creation-date:\", \"po-revision-date:\"];\n\nfunction normalizeHeaderString(value: string): string {\n const lines = value.split(\"\\n\");\n const hadTrailingNewline = value.endsWith(\"\\n\");\n\n const filtered = lines\n .filter((line) => {\n const trimmed = line.trimStart().toLowerCase();\n return !IGNORED_HEADER_LINE_PREFIXES.some((prefix) => trimmed.startsWith(prefix));\n })\n .map((line) => {\n const separatorIndex = line.indexOf(\":\");\n if (separatorIndex === -1) {\n return line;\n }\n\n const key = line.slice(0, separatorIndex).trim().toLowerCase();\n const value = line.slice(separatorIndex + 1);\n return `${key}:${value}`;\n });\n\n if (hadTrailingNewline && filtered[filtered.length - 1] !== \"\") {\n filtered.push(\"\");\n }\n\n return filtered.join(\"\\n\");\n}\n\nfunction normalize(translations: GetTextTranslations): GetTextTranslations {\n const compiled = gettextParser.po.compile(translations);\n const parsed = gettextParser.po.parse(compiled);\n\n if (parsed.headers) {\n const normalizedHeaders: Record<string, string> = {};\n for (const [key, value] of Object.entries(parsed.headers)) {\n if (!IGNORED_HEADER_KEYS.has(key.toLowerCase())) {\n normalizedHeaders[key.toLowerCase()] = value as string;\n }\n }\n parsed.headers = normalizedHeaders;\n }\n\n const headerMessage = parsed.translations?.[\"\"]?.[\"\"];\n if (headerMessage?.msgstr) {\n headerMessage.msgstr = headerMessage.msgstr.map((item) => normalizeHeaderString(item));\n }\n\n return parsed;\n}\n\nexport function hasChanges(left: GetTextTranslations, right?: GetTextTranslations): boolean {\n if (!right) {\n return true;\n }\n\n const normalizedLeft = normalize(left);\n const normalizedRight = normalize(right);\n\n return !isDeepStrictEqual(normalizedLeft, normalizedRight);\n}\n","import type { GetTextTranslationRecord, GetTextTranslations } from \"gettext-parser\";\nimport { getFormula, getNPlurals } from \"plural-forms\";\n\nimport type { ObsoleteStrategy } from \"../../configuration.ts\";\n\nexport interface Collected {\n translations: GetTextTranslationRecord;\n}\n\nexport function formatDate(date: Date): string {\n const pad = (n: number) => n.toString().padStart(2, \"0\");\n const year = date.getFullYear();\n const month = pad(date.getMonth() + 1);\n const day = pad(date.getDate());\n const hours = pad(date.getHours());\n const minutes = pad(date.getMinutes());\n const tzo = -date.getTimezoneOffset();\n const sign = tzo >= 0 ? \"+\" : \"-\";\n const offsetHours = pad(Math.floor(Math.abs(tzo) / 60));\n const offsetMinutes = pad(Math.abs(tzo) % 60);\n return `${year}-${month}-${day} ${hours}:${minutes}${sign}${offsetHours}${offsetMinutes}`;\n}\n\nexport function merge(\n sources: Collected[],\n existing: GetTextTranslations | undefined,\n obsolete: ObsoleteStrategy,\n locale: string,\n generatedAt: Date,\n): GetTextTranslations {\n let headers: Record<string, string> = {};\n let translations: GetTextTranslationRecord = { \"\": {} };\n let obsoleteTranslations: GetTextTranslationRecord = {};\n const nplurals = Number(getNPlurals(locale));\n\n if (existing) {\n headers = existing.headers ? structuredClone(existing.headers) : {};\n translations = existing.translations ? structuredClone(existing.translations) : { \"\": {} };\n obsoleteTranslations = existing.obsolete ? structuredClone(existing.obsolete) : {};\n for (const ctx of Object.keys(translations)) {\n for (const id of Object.keys(translations[ctx])) {\n if (ctx === \"\" && id === \"\") continue;\n translations[ctx][id].obsolete = true;\n }\n }\n }\n\n const collected: GetTextTranslationRecord = { \"\": {} };\n for (const { translations } of sources) {\n for (const [ctx, msgs] of Object.entries(translations)) {\n if (!collected[ctx]) collected[ctx] = {};\n for (const [id, entry] of Object.entries(msgs)) {\n const existing = collected[ctx][id];\n const refs = new Set<string>();\n if (existing?.comments?.reference) {\n existing.comments.reference.split(/\\r?\\n|\\r/).forEach((r) => {\n refs.add(r);\n });\n }\n if (entry.comments?.reference) {\n entry.comments.reference.split(/\\r?\\n|\\r/).forEach((r) => {\n refs.add(r);\n });\n }\n collected[ctx][id] = {\n ...existing,\n ...entry,\n comments: {\n ...existing?.comments,\n ...entry.comments,\n reference: refs.size ? Array.from(refs).join(\"\\n\") : undefined,\n },\n };\n }\n }\n }\n\n for (const [ctx, msgs] of Object.entries(collected)) {\n if (!translations[ctx]) translations[ctx] = {};\n for (const [id, entry] of Object.entries(msgs)) {\n const existingEntry = translations[ctx][id] ?? obsoleteTranslations[ctx]?.[id];\n if (existingEntry) {\n entry.msgstr = existingEntry.msgstr;\n entry.comments = {\n ...entry.comments,\n translator: existingEntry.comments?.translator,\n };\n }\n delete entry.obsolete;\n entry.msgstr = entry.msgstr.slice(0, nplurals);\n while (entry.msgstr.length < nplurals) {\n entry.msgstr.push(\"\");\n }\n translations[ctx][id] = entry;\n if (obsoleteTranslations[ctx]) {\n delete obsoleteTranslations[ctx][id];\n }\n }\n }\n\n for (const ctx of Object.keys(translations)) {\n for (const id of Object.keys(translations[ctx])) {\n if (ctx === \"\" && id === \"\") {\n continue;\n }\n const entry = translations[ctx][id];\n if (entry.obsolete) {\n if (!obsoleteTranslations[ctx]) {\n obsoleteTranslations[ctx] = {};\n }\n obsoleteTranslations[ctx][id] = entry;\n delete translations[ctx][id];\n }\n }\n }\n\n headers = {\n ...headers,\n \"Content-Type\": headers[\"Content-Type\"] || \"text/plain; charset=UTF-8\",\n \"Plural-Forms\": `nplurals=${nplurals}; plural=${getFormula(locale)};`,\n language: locale,\n \"MIME-Version\": \"1.0\",\n \"Content-Transfer-Encoding\": \"8bit\",\n \"POT-Creation-Date\": formatDate(generatedAt),\n \"x-generator\": \"@let-value/translate-extract\",\n };\n\n return {\n charset: \"utf-8\",\n headers,\n translations,\n ...(obsolete === \"mark\" && Object.keys(obsoleteTranslations).length ? { obsolete: obsoleteTranslations } : {}),\n };\n}\n","import fs from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\nimport * as gettextParser from \"gettext-parser\";\n\nimport type { Plugin } from \"../../plugin.ts\";\nimport type { Translation } from \"../core/queries/types.ts\";\nimport { collect } from \"./collect.ts\";\nimport { hasChanges } from \"./hasChanges.ts\";\nimport { merge } from \"./merge.ts\";\n\nconst namespace = \"translate\";\n\nexport function po(): Plugin {\n return {\n name: \"po\",\n setup(build) {\n build.context.logger?.debug(\"po plugin initialized\");\n const collections = new Map<\n string,\n {\n locale: string;\n translations: Translation[];\n }\n >();\n let dispatched = false;\n\n build.onResolve({ filter: /.*/, namespace }, async ({ entrypoint, path, data }) => {\n if (!data || !Array.isArray(data)) {\n return undefined;\n }\n\n for (const locale of build.context.config.locales) {\n const destination = build.context.config.destination({ entrypoint, locale, path });\n if (!collections.has(destination)) {\n collections.set(destination, { locale, translations: [] });\n }\n\n collections.get(destination)?.translations.push(...data);\n }\n\n Promise.all([build.defer(\"source\"), build.defer(namespace)]).then(() => {\n if (dispatched) {\n return;\n }\n dispatched = true;\n\n for (const path of collections.keys()) {\n build.load({ entrypoint, path, namespace });\n }\n });\n\n return undefined;\n });\n\n build.onLoad({ filter: /.*\\.po$/, namespace }, async ({ entrypoint, path }) => {\n const contents = await fs.readFile(path).catch(() => undefined);\n const data = contents ? gettextParser.po.parse(contents) : undefined;\n return {\n entrypoint,\n path,\n namespace,\n data,\n };\n });\n\n build.onProcess({ filter: /.*\\.po$/, namespace }, async ({ entrypoint, path, data }) => {\n const collected = collections.get(path);\n if (!collected) {\n build.context.logger?.warn({ path }, \"no translations collected for this path\");\n return undefined;\n }\n\n const { locale, translations } = collected;\n\n const record = collect(translations, locale);\n\n const out = merge(\n [{ translations: record }],\n data as never,\n build.context.config.obsolete,\n locale,\n build.context.generatedAt,\n );\n\n if (hasChanges(out, data as never)) {\n await fs.mkdir(dirname(path), { recursive: true });\n await fs.writeFile(path, gettextParser.po.compile(out));\n }\n\n build.resolve({\n entrypoint,\n path,\n namespace: \"cleanup\",\n data: translations,\n });\n });\n },\n };\n}\n","import type Parser from \"@keqingmoe/tree-sitter\";\n\nexport function buildTemplate(node: Parser.SyntaxNode): { text: string; error?: string } {\n const source = node.tree.rootNode.text;\n const open = node.childForFieldName(\"open_tag\");\n const close = node.childForFieldName(\"close_tag\");\n const contentStart = open?.endIndex ?? node.startIndex;\n const contentEnd = close?.startIndex ?? node.endIndex;\n\n type Part = { kind: \"text\"; text: string; raw: boolean } | { kind: \"expr\"; value: string };\n\n const parts: Part[] = [];\n let segmentStart = contentStart;\n\n const pushRawText = (endIndex: number) => {\n if (endIndex <= segmentStart) {\n segmentStart = Math.max(segmentStart, endIndex);\n return;\n }\n const text = source.slice(segmentStart, endIndex);\n if (text) {\n parts.push({ kind: \"text\", text, raw: true });\n }\n segmentStart = endIndex;\n };\n\n const children = node.namedChildren.slice(1, -1);\n for (const child of children) {\n if (child.type === \"jsx_expression\") {\n pushRawText(child.startIndex);\n const expr = child.namedChildren[0];\n if (!expr) {\n return { text: \"\", error: \"Empty JSX expression\" };\n }\n\n if (expr.type === \"identifier\") {\n parts.push({ kind: \"expr\", value: expr.text });\n } else if (expr.type === \"string\") {\n parts.push({ kind: \"text\", text: expr.text.slice(1, -1), raw: false });\n } else if (expr.type === \"template_string\") {\n const hasSubstitutions = expr.children.some((c) => c.type === \"template_substitution\");\n if (hasSubstitutions) {\n return { text: \"\", error: \"JSX expressions with template substitutions are not supported\" };\n }\n parts.push({ kind: \"text\", text: expr.text.slice(1, -1), raw: false });\n } else {\n return { text: \"\", error: \"JSX expressions must be simple identifiers, strings, or template literals\" };\n }\n segmentStart = child.endIndex;\n } else if (child.type === \"string\") {\n pushRawText(child.startIndex);\n parts.push({ kind: \"text\", text: child.text.slice(1, -1), raw: false });\n segmentStart = child.endIndex;\n } else if (child.type === \"jsx_text\" || child.type === \"html_character_reference\" || child.isError) {\n } else {\n return { text: \"\", error: \"Unsupported JSX child\" };\n }\n }\n\n pushRawText(contentEnd);\n\n const firstRawIndex = parts.findIndex((part) => part.kind === \"text\" && part.raw);\n if (firstRawIndex === 0) {\n const part = parts[firstRawIndex] as Extract<Part, { kind: \"text\" }>;\n part.text = part.text.replace(/^\\s+/, \"\");\n }\n\n let lastRawIndex = -1;\n for (let i = parts.length - 1; i >= 0; i--) {\n const part = parts[i];\n if (part.kind === \"text\" && part.raw) {\n lastRawIndex = i;\n break;\n }\n }\n if (lastRawIndex !== -1 && lastRawIndex === parts.length - 1) {\n const part = parts[lastRawIndex] as Extract<Part, { kind: \"text\" }>;\n part.text = part.text.replace(/\\s+$/, \"\");\n }\n\n const strings: string[] = [\"\"];\n const values: string[] = [];\n for (const part of parts) {\n if (part.kind === \"text\") {\n if (part.text) {\n strings[strings.length - 1] += part.text;\n }\n } else {\n values.push(part.value);\n strings.push(\"\");\n }\n }\n\n let text = \"\";\n for (let i = 0; i < strings.length; i++) {\n text += strings[i];\n if (values[i]) {\n text += `\\${${values[i]}}`;\n }\n }\n return { text };\n}\n\nexport function buildAttrValue(node: Parser.SyntaxNode): { text: string; error?: string } {\n if (node.type === \"string\") {\n return { text: node.text.slice(1, -1) };\n }\n if (node.type === \"jsx_expression\") {\n const expr = node.namedChildren[0];\n if (!expr) {\n return { text: \"\", error: \"Empty JSX expression\" };\n }\n\n if (expr.type === \"identifier\") {\n return { text: `\\${${expr.text}}` };\n } else if (expr.type === \"string\") {\n return { text: expr.text.slice(1, -1) };\n } else if (expr.type === \"template_string\") {\n // Check if it's a simple template string with no substitutions\n const hasSubstitutions = expr.children.some((c) => c.type === \"template_substitution\");\n if (hasSubstitutions) {\n return { text: \"\", error: \"JSX expressions with template substitutions are not supported\" };\n }\n // Extract the text content from the template string\n const content = expr.text.slice(1, -1); // Remove backticks\n return { text: content };\n } else {\n return { text: \"\", error: \"JSX expressions must be simple identifiers, strings, or template literals\" };\n }\n }\n return { text: \"\", error: \"Unsupported JSX child\" };\n}\n","import type Parser from \"@keqingmoe/tree-sitter\";\n\nimport { withComment } from \"../../core/queries/comment.ts\";\nimport type { MessageMatch, QuerySpec, Translation } from \"../../core/queries/types.ts\";\nimport { buildAttrValue, buildTemplate } from \"./utils.ts\";\n\nexport const messageQuery: QuerySpec = withComment({\n pattern: `(\n [\n (jsx_element (jsx_opening_element name: (identifier) @name)) @call\n (jsx_self_closing_element name: (identifier) @name) @call\n (lexical_declaration \n (variable_declarator \n value: [\n (jsx_element (jsx_opening_element name: (identifier) @name)) @call\n (jsx_self_closing_element name: (identifier) @name) @call\n ]\n )\n )\n ]\n (#eq? @name \"Message\")\n )`,\n extract(match: Parser.QueryMatch): MessageMatch | undefined {\n const node = match.captures.find((c) => c.name === \"call\")?.node;\n if (!node) return undefined;\n let attrs: Parser.SyntaxNode[] = [];\n if (node.type === \"jsx_element\") {\n const open = node.childForFieldName(\"open_tag\");\n if (open) attrs = open.namedChildren;\n } else if (node.type === \"jsx_self_closing_element\") {\n attrs = node.namedChildren.slice(1);\n }\n let msgctxt: string | undefined;\n let childValue: Parser.SyntaxNode | undefined;\n for (const child of attrs) {\n if (child.type !== \"jsx_attribute\") continue;\n const name = child.child(0);\n const value = child.child(child.childCount - 1);\n if (name?.text === \"context\" && value?.type === \"string\") {\n msgctxt = value.text.slice(1, -1);\n } else if (name?.text === \"children\" && value) {\n childValue = value;\n }\n }\n let text = \"\";\n let error: string | undefined;\n if (node.type === \"jsx_element\") {\n ({ text, error } = buildTemplate(node));\n } else if (childValue) {\n ({ text, error } = buildAttrValue(childValue));\n }\n if (error) {\n return { node, error };\n }\n if (!text) return undefined;\n const translation: Translation = {\n id: text,\n message: [text],\n };\n if (msgctxt) translation.context = msgctxt;\n return { node, translation };\n },\n});\n","import type Parser from \"@keqingmoe/tree-sitter\";\n\nimport { withComment } from \"../../core/queries/comment.ts\";\nimport type { MessageMatch, QuerySpec, Translation } from \"../../core/queries/types.ts\";\nimport { buildTemplate } from \"./utils.ts\";\n\nfunction parseForms(node: Parser.SyntaxNode): { forms: string[]; error?: string } {\n const forms: string[] = [];\n if (node.type === \"jsx_expression\") {\n const arr = node.namedChildren[0];\n if (!arr || arr.type !== \"array\") {\n return { forms: [], error: \"Plural forms must be an array\" };\n }\n for (const el of arr.namedChildren) {\n if (el.type === \"jsx_element\" || el.type === \"jsx_fragment\") {\n const { text, error } = buildTemplate(el);\n if (error) return { forms: [], error };\n forms.push(text);\n } else if (el.type === \"string\") {\n forms.push(el.text.slice(1, -1));\n } else {\n return { forms: [], error: \"Unsupported plural form\" };\n }\n }\n }\n return { forms };\n}\n\nexport const pluralQuery: QuerySpec = withComment({\n pattern: `(\n [\n (jsx_element (jsx_opening_element name: (identifier) @name))\n (jsx_self_closing_element name: (identifier) @name)\n ] @call\n (#eq? @name \"Plural\")\n )`,\n extract(match: Parser.QueryMatch): MessageMatch | undefined {\n const node = match.captures.find((c) => c.name === \"call\")?.node;\n if (!node) return undefined;\n let attrs: Parser.SyntaxNode[] = [];\n if (node.type === \"jsx_element\") {\n const open = node.childForFieldName(\"open_tag\");\n if (open) attrs = open.namedChildren;\n } else if (node.type === \"jsx_self_closing_element\") {\n attrs = node.namedChildren.slice(1);\n }\n let msgctxt: string | undefined;\n let formsNode: Parser.SyntaxNode | null | undefined;\n for (const child of attrs) {\n if (child.type !== \"jsx_attribute\") continue;\n const name = child.child(0);\n const value = child.child(child.childCount - 1);\n if (name?.text === \"context\" && value?.type === \"string\") {\n msgctxt = value.text.slice(1, -1);\n } else if (name?.text === \"forms\" && value) {\n formsNode = value;\n }\n }\n if (!formsNode) return undefined;\n const { forms, error } = parseForms(formsNode);\n if (error) {\n return { node, error };\n }\n if (forms.length === 0) return undefined;\n const translation: Translation = {\n id: forms[0],\n plural: forms[1],\n message: forms,\n };\n if (msgctxt) translation.context = msgctxt;\n return { node, translation };\n },\n});\n","import type { QuerySpec } from \"../../core/queries/types.ts\";\nimport { messageQuery } from \"./message.ts\";\nimport { pluralQuery } from \"./plural.ts\";\n\nexport const queries: QuerySpec[] = [messageQuery, pluralQuery];\n","import fs from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { getParser, getQuery } from \"../core/parse.ts\";\nimport { getReference } from \"../core/queries/comment.ts\";\n\nimport type { Context, Translation, Warning } from \"../core/queries/types.ts\";\nimport { queries } from \"./queries/index.ts\";\n\nexport interface ParseResult {\n translations: Translation[];\n warnings: Warning[];\n}\n\nexport function parseFile(filePath: string): ParseResult {\n const path = resolve(filePath);\n const source = fs.readFileSync(path, \"utf8\");\n return parseSource(source, path);\n}\n\nexport function parseSource(source: string, path: string): ParseResult {\n const context: Context = { path };\n const { parser, language } = getParser(path);\n const tree = parser.parse(source);\n\n const translations: Translation[] = [];\n const warnings: Warning[] = [];\n const seen = new Set<number>();\n\n for (const spec of queries) {\n const query = getQuery(language, spec.pattern);\n for (const match of query.matches(tree.rootNode)) {\n const message = spec.extract(match);\n if (!message) continue;\n const { node, translation, error } = message;\n if (seen.has(node.id)) continue;\n seen.add(node.id);\n const reference = getReference(node, context);\n if (translation) {\n translations.push({\n ...translation,\n comments: {\n ...translation.comments,\n reference,\n },\n });\n }\n if (error) {\n warnings.push({\n error,\n reference,\n });\n }\n }\n }\n\n return { translations, warnings };\n}\n","import { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\n\nimport type { Plugin } from \"../../plugin.ts\";\nimport type { Translation } from \"../core/queries/types.ts\";\nimport { parseSource } from \"./parse.ts\";\n\nconst filter = /\\.[cm]?[jt]sx$/;\n\nexport function react(): Plugin<string, Translation[]> {\n return {\n name: \"react\",\n setup(build) {\n build.context.logger?.debug(\"react plugin initialized\");\n build.onResolve({ filter: /.*/, namespace: \"source\" }, ({ entrypoint, path, namespace }) => {\n return {\n entrypoint,\n namespace,\n path: resolve(path),\n };\n });\n build.onLoad({ filter, namespace: \"source\" }, async ({ entrypoint, path, namespace }) => {\n const data = await readFile(path, \"utf8\");\n return {\n entrypoint,\n path,\n namespace,\n data,\n };\n });\n build.onProcess({ filter, namespace: \"source\" }, ({ entrypoint, path, data }) => {\n const { translations, warnings } = parseSource(data, path);\n\n for (const warning of warnings) {\n build.context.logger?.warn(`${warning.error} at ${warning.reference}`);\n }\n\n build.resolve({\n entrypoint,\n path,\n namespace: \"translate\",\n data: translations,\n });\n\n return undefined;\n });\n },\n };\n}\n","import type { Plugin, UniversalPlugin } from \"../plugin.ts\";\n\nimport { cleanup, core, po, react } from \"./index.ts\";\n\nconst original = {\n cleanup,\n core,\n po,\n react,\n} as const;\n\nexport function resolveStaticPlugin(item: UniversalPlugin): Plugin {\n if (\"static\" in item) {\n return original[item.static.name](...item.static.props);\n }\n\n return item;\n}\n","import { resolve as resolvePath } from \"node:path\";\nimport glob from \"fast-glob\";\nimport type { ResolvedConfig, ResolvedEntrypoint } from \"./configuration.ts\";\nimport { Defer } from \"./defer.ts\";\nimport type { Logger } from \"./logger.ts\";\nimport type {\n Build,\n Context,\n Filter,\n LoadArgs,\n LoadHook,\n ProcessArgs,\n ProcessHook,\n ResolveArgs,\n ResolveHook,\n} from \"./plugin.ts\";\nimport { resolveStaticPlugin } from \"./plugins/static.ts\";\n\nexport type Task =\n | {\n type: \"resolve\";\n args: ResolveArgs;\n }\n | {\n type: \"load\";\n args: LoadArgs;\n }\n | {\n type: \"process\";\n args: ProcessArgs;\n };\n\nasync function getPaths(entrypoint: ResolvedEntrypoint) {\n const pattern = entrypoint.entrypoint.replace(/\\\\/g, \"/\");\n const paths = glob.isDynamicPattern(pattern) ? await glob(pattern, { onlyFiles: true }) : [entrypoint.entrypoint];\n return new Set(paths.map((path) => resolvePath(path)));\n}\n\nexport async function run(\n entrypoint: ResolvedEntrypoint,\n { config, logger }: { config: ResolvedConfig; logger?: Logger },\n) {\n const destination = entrypoint.destination ?? config.destination;\n const obsolete = entrypoint.obsolete ?? config.obsolete;\n const exclude = entrypoint.exclude ?? config.exclude;\n const walk = entrypoint.walk ?? config.walk;\n const paths = new Set<string>();\n\n const context: Context = {\n config: { ...config, destination, obsolete, exclude, walk },\n generatedAt: new Date(),\n paths,\n logger,\n };\n\n logger?.info(entrypoint, \"starting extraction\");\n\n const resolvers: { filter: Filter; hook: ResolveHook }[] = [];\n const loaders: { filter: Filter; hook: LoadHook }[] = [];\n const processors: { filter: Filter; hook: ProcessHook }[] = [];\n const hooks = {\n resolve: resolvers,\n load: loaders,\n process: processors,\n };\n\n const pending = new Map<string, Defer>();\n const queue: Task[] = [];\n\n function getDeferred(namespace: string) {\n let defer = pending.get(namespace);\n if (defer === undefined) {\n defer = new Defer();\n pending.set(namespace, defer);\n }\n return defer;\n }\n\n function defer(namespace: string) {\n const defer = getDeferred(namespace);\n return defer.promise;\n }\n\n function source(path: string) {\n const resolvedPath = resolvePath(path);\n\n if (paths.has(resolvedPath)) {\n return;\n }\n\n logger?.debug({ entrypoint: entrypoint.entrypoint, path: resolvedPath }, \"resolved path\");\n\n paths.add(resolvedPath);\n resolve({ entrypoint: resolvedPath, path: resolvedPath, namespace: \"source\" });\n }\n\n function resolve(args: ResolveArgs) {\n const { entrypoint, path, namespace } = args;\n const skipped = context.config.exclude.some((ex) => (typeof ex === \"function\" ? ex(args) : ex.test(args.path)));\n logger?.debug({ entrypoint, path, namespace, skipped }, \"resolve\");\n\n if (skipped) {\n return;\n }\n\n queue.push({ type: \"resolve\", args });\n getDeferred(namespace).enqueue();\n }\n\n function load(args: LoadArgs) {\n const { entrypoint, path, namespace } = args;\n logger?.debug({ entrypoint, path, namespace }, \"load\");\n\n queue.push({ type: \"load\", args });\n getDeferred(namespace).enqueue();\n }\n\n function process(args: ProcessArgs) {\n const { entrypoint, path, namespace } = args;\n logger?.debug({ entrypoint, path, namespace }, \"process\");\n\n queue.push({ type: \"process\", args });\n getDeferred(namespace).enqueue();\n }\n\n const build: Build = {\n context,\n source,\n resolve,\n load,\n process,\n defer,\n onResolve(filter, hook) {\n resolvers.push({ filter, hook });\n },\n onLoad(filter, hook) {\n loaders.push({ filter, hook });\n },\n onProcess(filter, hook) {\n processors.push({ filter, hook });\n },\n };\n\n for (const item of config.plugins) {\n const plugin = resolveStaticPlugin(item);\n logger?.debug({ plugin: plugin.name }, \"setting up plugin\");\n plugin.setup(build);\n }\n\n for (const path of await getPaths(entrypoint)) {\n source(path);\n }\n\n async function processTask(task: Task) {\n const { type } = task;\n let args = task.args;\n const { entrypoint, path, namespace } = args;\n logger?.trace({ type, entrypoint, path, namespace }, \"processing task\");\n\n for (const { filter, hook } of hooks[type]) {\n if (filter.namespace !== namespace) continue;\n if (filter.filter && !filter.filter.test(path)) continue;\n\n const result = await hook(args as never);\n if (result !== undefined) {\n args = result as never;\n }\n }\n\n if (args !== undefined) {\n if (type === \"resolve\") {\n load(args as never);\n } else if (type === \"load\") {\n process(args as never);\n }\n }\n\n getDeferred(namespace).dequeue();\n }\n\n while (queue.length || Array.from(pending.values()).some((d) => d.pending > 0)) {\n while (queue.length) {\n const task = queue.shift();\n if (!task) {\n break;\n }\n\n await processTask(task);\n }\n\n await Promise.all(Array.from(pending.values()).map((d) => d.promise));\n await Promise.resolve();\n }\n\n logger?.info(entrypoint, \"extraction completed\");\n}\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAa,QAAb,MAAmB;CACf,UAAU;CACV,UAAyB,QAAQ,SAAS;CAC1C;CAEA,UAAU;AACN,MAAI,KAAK,cAAc,EACnB,MAAK,UAAU,IAAI,SAAe,QAAQ;AACtC,QAAK,UAAU;IACjB;;CAGV,UAAU;AACN,MAAI,KAAK,UAAU,KAAK,EAAE,KAAK,YAAY,EACvC,MAAK,WAAW;;;;;;ACP5B,MAAMA,cAAY;AAElB,SAAgB,UAAkB;AAC9B,QAAO;EACH,MAAM;EACN,MAAM,OAAO;AACT,SAAM,QAAQ,QAAQ,MAAM,6BAA6B;GACzD,MAAM,4BAAY,IAAI,KAAa;GACnC,MAAM,4BAAY,IAAI,KAAa;GACnC,MAAM,uBAAO,IAAI,KAAa;GAC9B,IAAI,aAAa;AAEjB,SAAM,UAAU;IAAE;IAAW,QAAQ;IAAM,GAAG,EAAE,mBAAW;AACvD,cAAU,IAAIC,OAAK;AACnB,SAAK,IAAI,QAAQA,OAAK,CAAC;AAEvB,YAAQ,IAAI;KAAC,MAAM,MAAM,SAAS;KAAE,MAAM,MAAM,YAAY;KAAE,MAAM,MAAMD,YAAU;KAAC,CAAC,CAAC,WAAW;AAC9F,SAAI,WACA;AAEJ,kBAAa;AAEb,UAAK,MAAMC,UAAQ,KAAK,Q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AAW,EAAE,kBAAkB;AAEvE,OAAK,MAAM,EAAE,kBAAQ,UAAU,MAAM,OAAO;AACxC,OAAIW,SAAO,cAAcJ,YAAW;AACpC,OAAII,SAAO,UAAU,CAACA,SAAO,OAAO,KAAKX,OAAK,CAAE;GAEhD,MAAM,SAAS,MAAM,KAAK,KAAc;AACxC,OAAI,WAAW,OACX,QAAO;;AAIf,MAAI,SAAS,QACT;OAAI,SAAS,UACT,MAAK,KAAc;YACZ,SAAS,OAChB,WAAQ,KAAc;;AAI9B,cAAYO,YAAU,CAAC,SAAS;;AAGpC,QAAO,MAAM,UAAU,MAAM,KAAK,QAAQ,QAAQ,CAAC,CAAC,MAAM,MAAM,EAAE,UAAU,EAAE,EAAE;AAC5E,SAAO,MAAM,QAAQ;GACjB,MAAM,OAAO,MAAM,OAAO;AAC1B,OAAI,CAAC,KACD;AAGJ,SAAM,YAAY,KAAK;;AAG3B,QAAM,QAAQ,IAAI,MAAM,KAAK,QAAQ,QAAQ,CAAC,CAAC,KAAK,MAAM,EAAE,QAAQ,CAAC;AACrE,QAAM,QAAQ,SAAS;;AAG3B,SAAQ,KAAK,YAAY,uBAAuB"}
@@ -1,12 +1,12 @@
1
1
  const require_chunk = require('./chunk-CUT6urMc.cjs');
2
2
  let node_util = require("node:util");
3
3
  node_util = require_chunk.__toESM(node_util);
4
+ let node_path = require("node:path");
5
+ node_path = require_chunk.__toESM(node_path);
4
6
  let fast_glob = require("fast-glob");
5
7
  fast_glob = require_chunk.__toESM(fast_glob);
6
8
  let node_fs_promises = require("node:fs/promises");
7
9
  node_fs_promises = require_chunk.__toESM(node_fs_promises);
8
- let node_path = require("node:path");
9
- node_path = require_chunk.__toESM(node_path);
10
10
  let gettext_parser = require("gettext-parser");
11
11
  gettext_parser = require_chunk.__toESM(gettext_parser);
12
12
  let node_fs = require("node:fs");
@@ -121,6 +121,16 @@ const withComment = (query) => ({
121
121
  }
122
122
  });
123
123
 
124
+ //#endregion
125
+ //#region src/plugins/core/queries/entrypoint.ts
126
+ const entrypointCommentPattern = /(?:^|\s)@?translate-entrypoint(?:\s|$)/;
127
+ const entrypointQuery = {
128
+ pattern: `(comment) @comment`,
129
+ extract(match) {
130
+ return match.captures.filter((capture) => capture.name === "comment").some((capture) => entrypointCommentPattern.test(getComment(capture.node)));
131
+ }
132
+ };
133
+
124
134
  //#endregion
125
135
  //#region src/plugins/core/queries/import.ts
126
136
  const importQuery = {
@@ -543,6 +553,7 @@ function parseSource$1(source, path$1) {
543
553
  const context = { path: path$1 };
544
554
  const { parser, language } = getParser(path$1);
545
555
  const tree = parser.parse(source);
556
+ const entrypoint = getCachedQuery(language, entrypointQuery.pattern).matches(tree.rootNode).some(entrypointQuery.extract);
546
557
  const translations = [];
547
558
  const warnings = [];
548
559
  const imports = [];
@@ -577,7 +588,8 @@ function parseSource$1(source, path$1) {
577
588
  return {
578
589
  translations,
579
590
  imports,
580
- warnings
591
+ warnings,
592
+ entrypoint
581
593
  };
582
594
  }
583
595
 
@@ -666,14 +678,22 @@ function core() {
666
678
  filter: filter$1,
667
679
  namespace: namespace$1
668
680
  }, ({ entrypoint, path: path$1, data }) => {
669
- const { translations, imports, warnings } = parseSource$1(data, path$1);
681
+ const result = parseSource$1(data, path$1);
682
+ if (result.entrypoint && entrypoint !== path$1) {
683
+ build.source(path$1);
684
+ return;
685
+ }
686
+ const { translations, imports, warnings } = result;
670
687
  if (build.context.config.walk) {
671
688
  const paths = resolveImports(path$1, imports);
672
- for (const path$2 of paths) build.resolve({
673
- entrypoint,
674
- path: path$2,
675
- namespace: namespace$1
676
- });
689
+ for (const path$2 of paths) {
690
+ if (build.context.paths.has(path$2)) continue;
691
+ build.resolve({
692
+ entrypoint,
693
+ path: path$2,
694
+ namespace: namespace$1
695
+ });
696
+ }
677
697
  }
678
698
  for (const warning of warnings) build.context.logger?.warn(`${warning.error} at ${warning.reference}`);
679
699
  build.resolve({
@@ -691,7 +711,7 @@ function core() {
691
711
  //#region src/plugins/po/collect.ts
692
712
  function collect(source, locale) {
693
713
  const translations = { "": {} };
694
- const nplurals = locale ? (0, plural_forms.getNPlurals)(locale) : void 0;
714
+ const nplurals = locale ? Number((0, plural_forms.getNPlurals)(locale)) : void 0;
695
715
  for (const { context, id, message, comments, obsolete, plural } of source) {
696
716
  const ctx = context || "";
697
717
  if (!translations[ctx]) translations[ctx] = {};
@@ -780,7 +800,7 @@ function merge(sources, existing, obsolete, locale, generatedAt) {
780
800
  let headers = {};
781
801
  let translations = { "": {} };
782
802
  let obsoleteTranslations = {};
783
- const nplurals = (0, plural_forms.getNPlurals)(locale);
803
+ const nplurals = Number((0, plural_forms.getNPlurals)(locale));
784
804
  if (existing) {
785
805
  headers = existing.headers ? structuredClone(existing.headers) : {};
786
806
  translations = existing.translations ? structuredClone(existing.translations) : { "": {} };
@@ -1291,11 +1311,17 @@ function resolveStaticPlugin(item) {
1291
1311
 
1292
1312
  //#endregion
1293
1313
  //#region src/run.ts
1314
+ async function getPaths(entrypoint) {
1315
+ const pattern = entrypoint.entrypoint.replace(/\\/g, "/");
1316
+ const paths = fast_glob.default.isDynamicPattern(pattern) ? await (0, fast_glob.default)(pattern, { onlyFiles: true }) : [entrypoint.entrypoint];
1317
+ return new Set(paths.map((path$1) => (0, node_path.resolve)(path$1)));
1318
+ }
1294
1319
  async function run(entrypoint, { config, logger }) {
1295
1320
  const destination = entrypoint.destination ?? config.destination;
1296
1321
  const obsolete = entrypoint.obsolete ?? config.obsolete;
1297
1322
  const exclude = entrypoint.exclude ?? config.exclude;
1298
1323
  const walk = entrypoint.walk ?? config.walk;
1324
+ const paths = /* @__PURE__ */ new Set();
1299
1325
  const context = {
1300
1326
  config: {
1301
1327
  ...config,
@@ -1305,6 +1331,7 @@ async function run(entrypoint, { config, logger }) {
1305
1331
  walk
1306
1332
  },
1307
1333
  generatedAt: /* @__PURE__ */ new Date(),
1334
+ paths,
1308
1335
  logger
1309
1336
  };
1310
1337
  logger?.info(entrypoint, "starting extraction");
@@ -1329,6 +1356,20 @@ async function run(entrypoint, { config, logger }) {
1329
1356
  function defer(namespace$3) {
1330
1357
  return getDeferred(namespace$3).promise;
1331
1358
  }
1359
+ function source(path$1) {
1360
+ const resolvedPath = (0, node_path.resolve)(path$1);
1361
+ if (paths.has(resolvedPath)) return;
1362
+ logger?.debug({
1363
+ entrypoint: entrypoint.entrypoint,
1364
+ path: resolvedPath
1365
+ }, "resolved path");
1366
+ paths.add(resolvedPath);
1367
+ resolve$4({
1368
+ entrypoint: resolvedPath,
1369
+ path: resolvedPath,
1370
+ namespace: "source"
1371
+ });
1372
+ }
1332
1373
  function resolve$4(args) {
1333
1374
  const { entrypoint: entrypoint$1, path: path$1, namespace: namespace$3 } = args;
1334
1375
  const skipped = context.config.exclude.some((ex) => typeof ex === "function" ? ex(args) : ex.test(args.path));
@@ -1373,6 +1414,7 @@ async function run(entrypoint, { config, logger }) {
1373
1414
  }
1374
1415
  const build = {
1375
1416
  context,
1417
+ source,
1376
1418
  resolve: resolve$4,
1377
1419
  load,
1378
1420
  process: process$1,
@@ -1401,17 +1443,7 @@ async function run(entrypoint, { config, logger }) {
1401
1443
  logger?.debug({ plugin: plugin.name }, "setting up plugin");
1402
1444
  plugin.setup(build);
1403
1445
  }
1404
- const pattern = entrypoint.entrypoint.replace(/\\/g, "/");
1405
- const paths = fast_glob.default.isDynamicPattern(pattern) ? await (0, fast_glob.default)(pattern, { onlyFiles: true }) : [entrypoint.entrypoint];
1406
- logger?.debug({
1407
- entrypoint: entrypoint.entrypoint,
1408
- paths
1409
- }, "resolved paths");
1410
- for (const path$1 of paths) resolve$4({
1411
- entrypoint: path$1,
1412
- path: path$1,
1413
- namespace: "source"
1414
- });
1446
+ for (const path$1 of await getPaths(entrypoint)) source(path$1);
1415
1447
  async function processTask(task) {
1416
1448
  const { type } = task;
1417
1449
  let args = task.args;
@@ -1,3 +1,3 @@
1
- import { Build, Context, DestinationFn, EntrypointConfig, Exclude, ExcludeFn, Filter, LoadArgs, LoadHook, LoadResult, ObsoleteStrategy, Plugin, ProcessArgs, ProcessHook, ProcessResult, ResolveArgs, ResolveHook, ResolveResult, ResolvedConfig, ResolvedEntrypoint, UniversalPlugin, UserConfig, defineConfig } from "../configuration-Bd6mIjFe.cjs";
1
+ import { Build, Context, DestinationFn, EntrypointConfig, Exclude, ExcludeFn, Filter, LoadArgs, LoadHook, LoadResult, ObsoleteStrategy, Plugin, ProcessArgs, ProcessHook, ProcessResult, ResolveArgs, ResolveHook, ResolveResult, ResolvedConfig, ResolvedEntrypoint, UniversalPlugin, UserConfig, defineConfig } from "../configuration-CTy0NMkD.cjs";
2
2
  import "../core-CPg6_re5.cjs";
3
3
  export { Build, Context, DestinationFn, EntrypointConfig, Exclude, ExcludeFn, Filter, LoadArgs, LoadHook, LoadResult, ObsoleteStrategy, Plugin, ProcessArgs, ProcessHook, ProcessResult, ResolveArgs, ResolveHook, ResolveResult, ResolvedConfig, ResolvedEntrypoint, UniversalPlugin, UserConfig, defineConfig };
@@ -1,3 +1,3 @@
1
- import { Build, Context, DestinationFn, EntrypointConfig, Exclude, ExcludeFn, Filter, LoadArgs, LoadHook, LoadResult, ObsoleteStrategy, Plugin, ProcessArgs, ProcessHook, ProcessResult, ResolveArgs, ResolveHook, ResolveResult, ResolvedConfig, ResolvedEntrypoint, UniversalPlugin, UserConfig, defineConfig } from "../configuration-xNU7-De0.js";
1
+ import { Build, Context, DestinationFn, EntrypointConfig, Exclude, ExcludeFn, Filter, LoadArgs, LoadHook, LoadResult, ObsoleteStrategy, Plugin, ProcessArgs, ProcessHook, ProcessResult, ResolveArgs, ResolveHook, ResolveResult, ResolvedConfig, ResolvedEntrypoint, UniversalPlugin, UserConfig, defineConfig } from "../configuration-fs9HmV_j.js";
2
2
  import "../core-ACuLoi2B.js";
3
3
  export { Build, Context, DestinationFn, EntrypointConfig, Exclude, ExcludeFn, Filter, LoadArgs, LoadHook, LoadResult, ObsoleteStrategy, Plugin, ProcessArgs, ProcessHook, ProcessResult, ResolveArgs, ResolveHook, ResolveResult, ResolvedConfig, ResolvedEntrypoint, UniversalPlugin, UserConfig, defineConfig };
@@ -1,4 +1,4 @@
1
- const require_run = require('../run-MHj974iT.cjs');
1
+ const require_run = require('../run-DOVU7XA7.cjs');
2
2
  require('../static-CNiWpXhx.cjs');
3
3
  const require_core = require('../core-CHb_Xdzl.cjs');
4
4
 
@@ -1,4 +1,4 @@
1
- import { Build, Context, DestinationFn, EntrypointConfig, Exclude, ExcludeFn, Filter, LoadArgs, LoadHook, LoadResult, Logger, ObsoleteStrategy, Plugin, ProcessArgs, ProcessHook, ProcessResult, ResolveArgs, ResolveHook, ResolveResult, ResolvedConfig, ResolvedEntrypoint, UniversalPlugin, UserConfig, cleanup$1 as cleanup, core$1 as core, defineConfig, po$1 as po, react$1 as react } from "../configuration-Bd6mIjFe.cjs";
1
+ import { Build, Context, DestinationFn, EntrypointConfig, Exclude, ExcludeFn, Filter, LoadArgs, LoadHook, LoadResult, Logger, ObsoleteStrategy, Plugin, ProcessArgs, ProcessHook, ProcessResult, ResolveArgs, ResolveHook, ResolveResult, ResolvedConfig, ResolvedEntrypoint, UniversalPlugin, UserConfig, cleanup$1 as cleanup, core$1 as core, defineConfig, po$1 as po, react$1 as react } from "../configuration-CTy0NMkD.cjs";
2
2
  import "../core-CPg6_re5.cjs";
3
3
 
4
4
  //#region src/run.d.ts
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/run.ts"],"sourcesContent":[],"mappings":";;;;KAiBY,IAAA;EAAA,IAAA,EAAA,SAAI;EAAA,IAAA,EAGA,WAHA;;MAOA,EAAA,MAAA;MAIA,EAJA,QAIA;CAAW,GAAA;EAGL,IAAA,EAAG,SAAA;EAAA,IAAA,EAHT,WAGS;;AAEnB,iBAFgB,GAAA,CAEhB,UAAA,EADU,kBACV,EAAA;EAAA,MAAA;EAAA;CAAA,EAAA;QAAQ,EAAoB,cAApB;QAAoB,CAAA,EAAyB,MAAzB;IAAiC,OAAR,CAAA,IAAA,CAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/run.ts"],"sourcesContent":[],"mappings":";;;;KAkBY,IAAA;EAAA,IAAA,EAAA,SAAI;EAAA,IAAA,EAGA,WAHA;;MAOA,EAAA,MAAA;MAIA,EAJA,QAIA;CAAW,GAAA;EASL,IAAA,EAAG,SAAA;EAAA,IAAA,EATT,WASS;;AAEnB,iBAFgB,GAAA,CAEhB,UAAA,EADU,kBACV,EAAA;EAAA,MAAA;EAAA;CAAA,EAAA;QAAQ,EAAoB,cAApB;QAAoB,CAAA,EAAyB,MAAzB;IAAiC,OAAR,CAAA,IAAA,CAAA"}
@@ -1,4 +1,4 @@
1
- import { Build, Context, DestinationFn, EntrypointConfig, Exclude, ExcludeFn, Filter, LoadArgs, LoadHook, LoadResult, Logger, ObsoleteStrategy, Plugin, ProcessArgs, ProcessHook, ProcessResult, ResolveArgs, ResolveHook, ResolveResult, ResolvedConfig, ResolvedEntrypoint, UniversalPlugin, UserConfig, cleanup$1 as cleanup, core$1 as core, defineConfig, po$1 as po, react$1 as react } from "../configuration-xNU7-De0.js";
1
+ import { Build, Context, DestinationFn, EntrypointConfig, Exclude, ExcludeFn, Filter, LoadArgs, LoadHook, LoadResult, Logger, ObsoleteStrategy, Plugin, ProcessArgs, ProcessHook, ProcessResult, ResolveArgs, ResolveHook, ResolveResult, ResolvedConfig, ResolvedEntrypoint, UniversalPlugin, UserConfig, cleanup$1 as cleanup, core$1 as core, defineConfig, po$1 as po, react$1 as react } from "../configuration-fs9HmV_j.js";
2
2
  import "../core-ACuLoi2B.js";
3
3
 
4
4
  //#region src/run.d.ts
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/run.ts"],"sourcesContent":[],"mappings":";;;;KAiBY,IAAA;EAAA,IAAA,EAAA,SAAI;EAAA,IAAA,EAGA,WAHA;;MAOA,EAAA,MAAA;MAIA,EAJA,QAIA;CAAW,GAAA;EAGL,IAAA,EAAG,SAAA;EAAA,IAAA,EAHT,WAGS;;AAEnB,iBAFgB,GAAA,CAEhB,UAAA,EADU,kBACV,EAAA;EAAA,MAAA;EAAA;CAAA,EAAA;QAAQ,EAAoB,cAApB;QAAoB,CAAA,EAAyB,MAAzB;IAAiC,OAAR,CAAA,IAAA,CAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/run.ts"],"sourcesContent":[],"mappings":";;;;KAkBY,IAAA;EAAA,IAAA,EAAA,SAAI;EAAA,IAAA,EAGA,WAHA;;MAOA,EAAA,MAAA;MAIA,EAJA,QAIA;CAAW,GAAA;EASL,IAAA,EAAG,SAAA;EAAA,IAAA,EATT,WASS;;AAEnB,iBAFgB,GAAA,CAEhB,UAAA,EADU,kBACV,EAAA;EAAA,MAAA;EAAA;CAAA,EAAA;QAAQ,EAAoB,cAApB;QAAoB,CAAA,EAAyB,MAAzB;IAAiC,OAAR,CAAA,IAAA,CAAA"}
package/dist/src/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { cleanup, core, po, react, run } from "../run-DbV8QpUz.js";
1
+ import { cleanup, core, po, react, run } from "../run-BLCu6sdK.js";
2
2
  import "../static-DQHT7uqP.js";
3
3
  import { defineConfig } from "../core-DR3oxhSq.js";
4
4
 
@@ -1,2 +1,2 @@
1
- import { StaticPlugin, cleanup, core, po, react } from "../configuration-Bd6mIjFe.cjs";
1
+ import { StaticPlugin, cleanup, core, po, react } from "../configuration-CTy0NMkD.cjs";
2
2
  export { StaticPlugin, cleanup, core, po, react };
@@ -1,2 +1,2 @@
1
- import { StaticPlugin, cleanup, core, po, react } from "../configuration-xNU7-De0.js";
1
+ import { StaticPlugin, cleanup, core, po, react } from "../configuration-fs9HmV_j.js";
2
2
  export { StaticPlugin, cleanup, core, po, react };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@let-value/translate-extract",
3
- "version": "1.1.1",
3
+ "version": "1.1.2-beta.2",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -34,7 +34,7 @@
34
34
  "dist"
35
35
  ],
36
36
  "dependencies": {
37
- "@let-value/translate": "1.1.1",
37
+ "@let-value/translate": "1.1.2-beta.2",
38
38
  "chalk": "5.3.0",
39
39
  "cosmiconfig": "9.0.0",
40
40
  "fast-glob": "3.3.2",
@@ -1 +0,0 @@
1
- {"version":3,"file":"configuration-Bd6mIjFe.d.cts","names":[],"sources":["../src/logger.ts","../src/plugins/cleanup/cleanup.ts","../src/plugins/core/queries/types.ts","../src/plugins/core/core.ts","../src/plugins/po/po.ts","../src/plugins/react/react.ts","../src/static.ts","../src/plugin.ts","../src/configuration.ts"],"sourcesContent":[],"mappings":";;;;KAIY,MAAA,GAAS,GAAA,CAAI;KACb,aAAA,GAAgB,GAAA,CAAI;KACpB,QAAA,GAAW;;;iBCGP,SAAA,CAAA,GAAW;;;UCPV,QAAA;;;EFEL,SAAM,CAAA,EAAA,MAAA;EACN,IAAA,CAAA,EAAA,MAAA;EACA,QAAA,CAAA,EAAQ,MAAA;;UEIH,WAAA;;EDDD,EAAA,EAAA,MAAA;;;aCMD;EAbE,QAAA,CAAA,EAAQ,OAAA;AAQzB;;;iBCCgB,MAAA,CAAA,GAAQ,eAAe;;;iBCCvB,IAAA,CAAA,GAAM;;;iBCHN,KAAA,CAAA,GAAS,eAAe;;;ALL5B,iBMCI,IAAA,CNDS,GAAA,KAAM,EMCA,UNDA,CAAA,OMCkB,MNDlB,CAAA,CAAA,EAAA;EACnB,SAAA,MAAA,EAAa;IACb,SAAQ,IAAA,EAAA,MAAG;;;;ACGP,iBKKA,OAAA,CLLW,GAAA,KAAM,EKKD,ULLC,CAAA,OKKiB,KLLjB,CAAA,CAAA,EAAA;;;;ECPhB,CAAA;AAQjB,CAAA;iBIYgB,EAAA,WAAa,kBAAkB;;;IHX/B,SAAI,KAAA,EAAA,EAAA;EAAA,CAAA;;AAAI,iBGoBR,OAAA,CHpBQ,GAAA,KAAA,EGoBU,UHpBV,CAAA,OGoB4B,SHpB5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M;MAAqC,EAAA,OAAA;UAAT,EC2ClC,QD3CkC;SAA6C,EC4ChF,OD5CgF,EAAA;;;;AAC7F;;AACsB,iBCiFN,YAAA,CDjFM,MAAA,ECiFe,UDjFf,CAAA,ECiF4B,cDjF5B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"configuration-xNU7-De0.d.ts","names":[],"sources":["../src/logger.ts","../src/plugins/cleanup/cleanup.ts","../src/plugins/core/queries/types.ts","../src/plugins/core/core.ts","../src/plugins/po/po.ts","../src/plugins/react/react.ts","../src/static.ts","../src/plugin.ts","../src/configuration.ts"],"sourcesContent":[],"mappings":";;;;;KAIY,MAAA,GAAS,GAAA,CAAI;KACb,aAAA,GAAgB,GAAA,CAAI;KACpB,QAAA,GAAW;;;iBCGP,SAAA,CAAA,GAAW;;;UCPV,QAAA;;;;EFEL,IAAA,CAAA,EAAA,MAAM;EACN,QAAA,CAAA,EAAA,MAAa;AACzB;UEIiB,WAAA;;;EDDD,MAAA,CAAA,EAAA,MAAO;;aCMR;;AAbf;;;iBCSgB,MAAA,CAAA,GAAQ,eAAe;;;iBCCvB,IAAA,CAAA,GAAM;;;iBCHN,KAAA,CAAA,GAAS,eAAe;;;iBCJxB,IAAA,WAAe,kBAAkB;ENDrC,SAAM,MAAA,EAAA;IACN,SAAA,IAAa,EAAA,MAAA;IACb,SAAQ,KAAA,EAAA,EAAG;;;iBMQP,OAAA,WAAgB,kBAAkB;ELLlC,SAAA,MAAO,EAAA;;;;ACPvB,CAAA;AAQiB,iBIYD,EAAA,CJZY,GAKb,KAAA,EIOc,UJPN,CAAA,OIOwB,IJPxB,CAAA,CAAA,EAAA;;;;ECJP,CAAA;CAAI;AAAmB,iBGoBvB,OAAA,CHpBuB,GAAA,KAAA,EGoBL,UHpBK,CAAA,OGoBa,SHpBb,CAAA,CAAA,EAAA;WAAf,MAAA,EAAA;IAAM,SAAA,IAAA,EAAA,SAAA;;;;ACCd,KE4BJ,YAAA,GACN,UF7BsB,CAAA,OE6BJ,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,CAAA,ECkF2B,cDlF3B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-DbV8QpUz.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","value","normalizedHeaders: Record<string, string>","headers: Record<string, string>","translations: GetTextTranslationRecord","obsoleteTranslations: GetTextTranslationRecord","collected: GetTextTranslationRecord","translations","existing","path","parts: Part[]","text","strings: string[]","values: string[]","messageQuery: QuerySpec","attrs: Parser.SyntaxNode[]","msgctxt: string | undefined","childValue: Parser.SyntaxNode | undefined","error: string | undefined","translation: Translation","forms: string[]","pluralQuery: QuerySpec","attrs: Parser.SyntaxNode[]","msgctxt: string | undefined","formsNode: Parser.SyntaxNode | null | undefined","translation: Translation","queries: QuerySpec[]","context: Context","path","translations: Translation[]","warnings: Warning[]","path","context: Context","resolvers: { filter: Filter; hook: ResolveHook }[]","loaders: { filter: Filter; hook: LoadHook }[]","processors: { filter: Filter; hook: ProcessHook }[]","queue: Task[]","defer","namespace","resolve","process","build: Build","path","filter"],"sources":["../src/defer.ts","../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/collect.ts","../src/plugins/po/hasChanges.ts","../src/plugins/po/merge.ts","../src/plugins/po/po.ts","../src/plugins/react/queries/utils.ts","../src/plugins/react/queries/message.ts","../src/plugins/react/queries/plural.ts","../src/plugins/react/queries/index.ts","../src/plugins/react/parse.ts","../src/plugins/react/react.ts","../src/plugins/static.ts","../src/run.ts"],"sourcesContent":["export class Defer {\n pending = 0;\n promise: Promise<void> = Promise.resolve();\n resolve?: () => void;\n\n enqueue() {\n if (this.pending++ === 0) {\n this.promise = new Promise<void>((res) => {\n this.resolve = res;\n });\n }\n }\n dequeue() {\n if (this.pending > 0 && --this.pending === 0) {\n this.resolve?.();\n }\n }\n}\n","import fs from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\n\nimport * as gettextParser from \"gettext-parser\";\n\nimport type { Plugin } from \"../../plugin.ts\";\n\nconst namespace = \"cleanup\";\n\nexport function cleanup(): Plugin {\n return {\n name: \"cleanup\",\n setup(build) {\n build.context.logger?.debug(\"cleanup plugin initialized\");\n const processed = new Set<string>();\n const generated = new Set<string>();\n const dirs = new Set<string>();\n let dispatched = false;\n\n build.onResolve({ namespace, filter: /.*/ }, ({ path }) => {\n generated.add(path);\n dirs.add(dirname(path));\n\n Promise.all([build.defer(\"source\"), build.defer(\"translate\"), build.defer(namespace)]).then(() => {\n if (dispatched) {\n return;\n }\n dispatched = true;\n\n for (const path of dirs.values()) {\n build.process({ entrypoint: path, path, namespace, data: undefined });\n }\n });\n\n return undefined;\n });\n\n build.onProcess({ namespace, filter: /.*/ }, async ({ path }) => {\n if (processed.has(path)) {\n return undefined;\n }\n processed.add(path);\n const files = await fs.readdir(path).catch(() => []);\n for (const f of files.filter((p) => p.endsWith(\".po\"))) {\n const full = join(path, f);\n const contents = await fs.readFile(full).catch(() => undefined);\n if (!contents) {\n continue;\n }\n const parsed = gettextParser.po.parse(contents);\n const hasTranslations = Object.entries(parsed.translations || {}).some(([ctx, msgs]) =>\n Object.keys(msgs).some((id) => !(ctx === \"\" && id === \"\")),\n );\n if (!hasTranslations && generated.has(full)) {\n await fs.unlink(full);\n }\n if (hasTranslations && !generated.has(full)) {\n build.context.logger?.warn({ path: full }, \"stray translation file\");\n }\n }\n return undefined;\n });\n },\n };\n}\n","import { relative } from \"node:path\";\nimport type Parser from \"@keqingmoe/tree-sitter\";\n\nimport type { Context, QuerySpec } from \"./types.ts\";\n\nexport function getReference(node: Parser.SyntaxNode, { path }: Context) {\n const line = node.startPosition.row + 1;\n const rel = relative(process.cwd(), path).replace(/\\\\+/g, \"/\");\n return `${rel}:${line}`;\n}\n\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 \"@keqingmoe/tree-sitter\";\nimport type { ImportQuerySpec } from \"./types.ts\";\n\nexport const importQuery: ImportQuerySpec = {\n pattern: `\n [\n (import_statement\n source: (string (string_fragment) @import))\n (export_statement\n source: (string (string_fragment) @import))\n (call_expression\n function: (identifier) @func\n arguments: (arguments (string (string_fragment) @import))\n (#eq? @func \"require\"))\n (call_expression\n function: (member_expression\n object: (identifier) @obj\n property: (property_identifier) @method)\n arguments: (arguments (string (string_fragment) @import))\n (#eq? @obj \"require\")\n (#eq? @method \"resolve\"))\n (call_expression\n function: (import)\n arguments: (arguments (string (string_fragment) @import)))\n ]\n `,\n extract(match: Parser.QueryMatch): string | undefined {\n const node = match.captures.find((c) => c.name === \"import\")?.node;\n return node?.text;\n },\n};\n","import type Parser from \"@keqingmoe/tree-sitter\";\n\nexport const callPattern = (fnName: string, args: string, allowMember = true): string => `(\n (call_expression\n function: ${\n allowMember\n ? `[\n (identifier) @func\n (member_expression property: (property_identifier) @func)\n ]`\n : `(identifier) @func`\n }\n arguments: ${args}\n ) @call\n (#eq? @func \"${fnName}\")\n)`;\n\nexport function isDescendant(node: Parser.SyntaxNode, ancestor: Parser.SyntaxNode): boolean {\n let current: Parser.SyntaxNode | null = node;\n while (current) {\n if (current.id === ancestor.id) return true;\n current = current.parent;\n }\n return false;\n}\n","import type Parser from \"@keqingmoe/tree-sitter\";\nimport { withComment } from \"./comment.ts\";\nimport type { MessageMatch, QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nconst notInPlural = (query: QuerySpec): QuerySpec => ({\n pattern: query.pattern,\n extract(match) {\n const result = query.extract(match);\n if (!result?.node) {\n return result;\n }\n\n let parent = result.node.parent;\n\n if (parent && parent.type === \"arguments\") {\n parent = parent.parent;\n }\n\n if (parent && parent.type === \"call_expression\") {\n const fn = parent.childForFieldName(\"function\");\n if (fn) {\n if (\n (fn.type === \"identifier\" &&\n (fn.text === \"plural\" ||\n fn.text === \"ngettext\" ||\n fn.text === \"pgettext\" ||\n fn.text === \"npgettext\")) ||\n (fn.type === \"member_expression\" &&\n [\"plural\", \"ngettext\", \"pgettext\", \"npgettext\"].includes(\n fn.childForFieldName(\"property\")?.text ?? \"\",\n ))\n ) {\n return undefined;\n }\n }\n }\n\n return result;\n },\n});\n\nexport const messageArg = `[\n (string (string_fragment) @msgid)\n (object\n (_)*\n (pair\n key: (property_identifier) @id_key\n value: (string (string_fragment) @id)\n (#eq? @id_key \"id\")\n )?\n (_)*\n (pair\n key: (property_identifier) @msg_key\n value: (string (string_fragment) @message)\n (#eq? @msg_key \"message\")\n )?\n (_)*\n )\n (template_string) @tpl\n]`;\n\nexport const messageArgs = `[ (arguments ${messageArg}) (template_string) @tpl ]`;\n\nexport const extractMessage =\n (name: string) =>\n (match: Parser.QueryMatch): MessageMatch | undefined => {\n const node = match.captures.find((c) => c.name === \"call\")?.node;\n if (!node) {\n return undefined;\n }\n\n const msgid = match.captures.find((c) => c.name === \"msgid\")?.node.text;\n if (msgid) {\n return {\n node,\n translation: {\n id: msgid,\n message: [msgid],\n },\n };\n }\n\n const tpl = match.captures.find((c) => c.name === \"tpl\")?.node;\n if (tpl) {\n for (const child of tpl.children) {\n if (child.type !== \"template_substitution\") {\n continue;\n }\n\n const expr = child.namedChildren[0];\n if (!expr || expr.type !== \"identifier\") {\n return {\n node,\n error: `${name}() template expressions must be simple identifiers`,\n };\n }\n }\n\n const text = tpl.text.slice(1, -1);\n\n return {\n node,\n translation: { id: text, message: [text] },\n };\n }\n\n const id = match.captures.find((c) => c.name === \"id\")?.node.text;\n const message = match.captures.find((c) => c.name === \"message\")?.node.text;\n const msgId = id ?? message;\n if (!msgId) {\n return undefined;\n }\n\n const msgstr = message ?? id ?? \"\";\n\n return {\n node,\n translation: {\n id: msgId,\n message: [msgstr],\n },\n };\n };\n\nexport const messageQuery: QuerySpec = notInPlural(\n withComment({\n pattern: callPattern(\"message\", messageArgs),\n extract: extractMessage(\"message\"),\n }),\n);\n\nconst allowed = new Set([\"string\", \"object\", \"template_string\"]);\n\nexport const messageInvalidQuery: QuerySpec = notInPlural({\n pattern: callPattern(\"message\", \"(arguments (_) @arg)\"),\n extract(match) {\n const call = match.captures.find((c) => c.name === \"call\")?.node;\n const node = match.captures.find((c) => c.name === \"arg\")?.node;\n\n if (!call || !node) {\n return undefined;\n }\n\n if (allowed.has(node.type)) {\n return undefined;\n }\n\n return {\n node,\n error: \"message() argument must be a string literal, object literal, or template literal\",\n };\n },\n});\n","import type Parser from \"@keqingmoe/tree-sitter\";\nimport { extractMessage } from \"./message.ts\";\nimport type { MessageMatch, Translation } from \"./types.ts\";\nimport { isDescendant } from \"./utils.ts\";\n\nexport const extractPluralForms =\n (name: string) =>\n (match: Parser.QueryMatch): MessageMatch | undefined => {\n const call = match.captures.find((c) => c.name === \"call\")?.node;\n const n = match.captures.find((c) => c.name === \"n\")?.node;\n if (!call || !n || n.nextNamedSibling) {\n return undefined;\n }\n\n const msgctxt = match.captures.find((c) => c.name === \"msgctxt\")?.node?.text;\n const msgNodes = match.captures.filter((c) => c.name === \"msg\").map((c) => c.node);\n\n const ids: string[] = [];\n const strs: string[] = [];\n\n for (const node of msgNodes) {\n const relevant = match.captures.filter(\n (c) => [\"msgid\", \"id\", \"message\", \"tpl\"].includes(c.name) && isDescendant(c.node, node),\n );\n\n const subMatch: Parser.QueryMatch = {\n pattern: 0,\n captures: [{ name: \"call\", node }, ...relevant],\n };\n\n const result = extractMessage(name)(subMatch);\n if (!result) continue;\n if (result.error) {\n return { node: call, error: result.error };\n }\n if (result.translation) {\n ids.push(result.translation.id);\n strs.push(result.translation.message[0] ?? \"\");\n }\n }\n\n if (ids.length === 0) {\n return undefined;\n }\n\n const translation: Translation = {\n id: ids[0],\n plural: ids[1],\n message: strs,\n };\n if (msgctxt) translation.context = msgctxt;\n\n return { node: call, translation };\n };\n","import { withComment } from \"./comment.ts\";\nimport { extractMessage, messageArgs } from \"./message.ts\";\nimport { extractPluralForms } from \"./plural-utils.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nconst ctxCall = callPattern(\n \"context\",\n `[\n (arguments (string (string_fragment) @msgctxt))\n (template_string) @msgctxt\n]`,\n)\n .replace(/@call/g, \"@ctx\")\n .replace(/@func/g, \"@ctxfn\");\n\nexport const contextMsgQuery: QuerySpec = withComment({\n pattern: `(\n (call_expression\n function: (member_expression\n object: ${ctxCall}\n property: (property_identifier) @func\n )\n arguments: ${messageArgs}\n ) @call\n (#eq? @func \"message\")\n)`,\n extract(match) {\n const result = extractMessage(\"context.message\")(match);\n const contextNode = match.captures.find((c) => c.name === \"msgctxt\")?.node;\n if (!result || !result.translation || !contextNode) {\n return result;\n }\n\n if (contextNode.type === \"template_string\") {\n for (const child of contextNode.children) {\n if (child.type !== \"template_substitution\") {\n continue;\n }\n\n const expr = child.namedChildren[0];\n if (!expr || expr.type !== \"identifier\") {\n return {\n node: contextNode,\n error: \"context() template expressions must be simple identifiers\",\n };\n }\n }\n }\n\n const contextText =\n contextNode.type === \"template_string\" ? contextNode.text.slice(1, -1) : contextNode.text;\n return {\n node: result.node,\n translation: {\n ...result.translation,\n context: contextText,\n },\n };\n },\n});\n\nconst msgCall = callPattern(\"message\", messageArgs, false).replace(/@call/g, \"@msg\").replace(/@func/g, \"@msgfn\");\n\nexport const contextPluralQuery: QuerySpec = withComment({\n pattern: `(\n (call_expression\n function: (member_expression\n object: ${ctxCall}\n property: (property_identifier) @func\n )\n arguments: (arguments (\n (${msgCall} (\",\" )?)+\n (number) @n\n ))\n ) @call\n (#eq? @func \"plural\")\n)`,\n extract: extractPluralForms(\"context.plural\"),\n});\n\nexport const contextInvalidQuery: QuerySpec = withComment({\n pattern: ctxCall,\n extract(match) {\n const call = match.captures.find((c) => c.name === \"ctx\")?.node;\n if (!call) {\n return undefined;\n }\n\n const parent = call.parent;\n if (parent && parent.type === \"member_expression\" && parent.childForFieldName(\"object\")?.id === call.id) {\n const property = parent.childForFieldName(\"property\")?.text;\n const grandparent = parent.parent;\n if (\n grandparent &&\n grandparent.type === \"call_expression\" &&\n grandparent.childForFieldName(\"function\")?.id === parent.id &&\n (property === \"message\" || property === \"plural\")\n ) {\n return undefined;\n }\n }\n\n return {\n node: call,\n error: \"context() must be used with message() or plural() in the same expression\",\n };\n },\n});\n","import { withComment } from \"./comment.ts\";\nimport { extractMessage, messageArgs } from \"./message.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nexport const gettextQuery: QuerySpec = withComment({\n pattern: callPattern(\"gettext\", messageArgs),\n extract: extractMessage(\"gettext\"),\n});\n\nconst allowed = new Set([\"string\", \"object\", \"template_string\", \"identifier\", \"call_expression\"]);\n\nexport const gettextInvalidQuery: QuerySpec = {\n pattern: callPattern(\"gettext\", \"(arguments (_) @arg)\"),\n extract(match) {\n const call = match.captures.find((c) => c.name === \"call\")?.node;\n const node = match.captures.find((c) => c.name === \"arg\")?.node;\n\n if (!call || !node) {\n return undefined;\n }\n\n if (allowed.has(node.type)) {\n return undefined;\n }\n\n return {\n node,\n error: \"gettext() argument must be a string literal, object literal, or template literal\",\n };\n },\n};\n","import { withComment } from \"./comment.ts\";\nimport { messageArg, messageArgs } from \"./message.ts\";\nimport { extractPluralForms } from \"./plural-utils.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nconst msgCall = callPattern(\"message\", messageArgs).replace(/@call/g, \"@msg\").replace(/@func/g, \"@msgfn\");\nconst plainMsg = `(${messageArg}) @msg`;\nconst msgArg = `[${msgCall} ${plainMsg}]`;\n\nexport const ngettextQuery: QuerySpec = withComment({\n pattern: callPattern(\"ngettext\", `(arguments ${msgArg} \",\" ${msgArg} (\",\" ${msgArg})* \",\" (_) @n)`),\n extract: extractPluralForms(\"ngettext\"),\n});\n","import { withComment } from \"./comment.ts\";\nimport { messageArg, messageArgs } from \"./message.ts\";\nimport { extractPluralForms } from \"./plural-utils.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nconst msgCall = callPattern(\"message\", messageArgs).replace(/@call/g, \"@msg\").replace(/@func/g, \"@msgfn\");\nconst plainMsg = `(${messageArg}) @msg`;\nconst msgArg = `[${msgCall} ${plainMsg}]`;\n\nexport const npgettextQuery: QuerySpec = withComment({\n pattern: callPattern(\n \"npgettext\",\n `(arguments (string (string_fragment) @msgctxt) \",\" ${msgArg} \",\" ${msgArg} (\",\" ${msgArg})* \",\" (_) @n)`,\n ),\n extract: extractPluralForms(\"npgettext\"),\n});\n","import { withComment } from \"./comment.ts\";\nimport { extractMessage, messageArg } from \"./message.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nexport const pgettextQuery: QuerySpec = withComment({\n pattern: callPattern(\"pgettext\", `(arguments (string (string_fragment) @msgctxt) \",\" ${messageArg})`),\n extract(match) {\n const result = extractMessage(\"pgettext\")(match);\n const contextNode = match.captures.find((c) => c.name === \"msgctxt\")?.node;\n if (!result || !contextNode || !result.translation) {\n return result;\n }\n return {\n node: result.node,\n translation: {\n ...result.translation,\n context: contextNode.text,\n },\n };\n },\n});\n","import { withComment } from \"./comment.ts\";\nimport { messageArgs } from \"./message.ts\";\nimport { extractPluralForms } from \"./plural-utils.ts\";\nimport type { QuerySpec } from \"./types.ts\";\nimport { callPattern } from \"./utils.ts\";\n\nconst msgCall = callPattern(\"message\", messageArgs, false).replace(/@call/g, \"@msg\").replace(/@func/g, \"@msgfn\");\n\nexport const pluralQuery: QuerySpec = withComment({\n pattern: callPattern(\n \"plural\",\n `(arguments (\n (${msgCall} (\",\" )?)+\n (number) @n\n ))`,\n false,\n ),\n extract: extractPluralForms(\"plural\"),\n});\n","import { contextInvalidQuery, contextMsgQuery, contextPluralQuery } from \"./context.ts\";\nimport { gettextInvalidQuery, gettextQuery } from \"./gettext.ts\";\nimport { messageInvalidQuery, messageQuery } from \"./message.ts\";\nimport { ngettextQuery } from \"./ngettext.ts\";\nimport { npgettextQuery } from \"./npgettext.ts\";\nimport { pgettextQuery } from \"./pgettext.ts\";\nimport { pluralQuery } from \"./plural.ts\";\nimport type { QuerySpec } from \"./types.ts\";\n\nexport type { MessageMatch, QuerySpec } from \"./types.ts\";\n\nexport const queries: QuerySpec[] = [\n contextMsgQuery,\n contextPluralQuery,\n contextInvalidQuery,\n messageQuery,\n messageInvalidQuery,\n gettextQuery,\n gettextInvalidQuery,\n pluralQuery,\n ngettextQuery,\n pgettextQuery,\n npgettextQuery,\n];\n","import fs from \"node:fs\";\nimport { extname, resolve } from \"node:path\";\n\nimport Parser from \"@keqingmoe/tree-sitter\";\nimport JavaScript from \"tree-sitter-javascript\";\nimport TS from \"tree-sitter-typescript\";\n\nimport { getReference } from \"./queries/comment.ts\";\nimport { 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 type { GetTextTranslationRecord } from \"gettext-parser\";\nimport { getNPlurals } from \"plural-forms\";\n\nimport type { Translation } from \"../core/queries/types.ts\";\n\nexport function collect(source: Translation[], locale?: string): GetTextTranslationRecord {\n const translations: GetTextTranslationRecord = { \"\": {} };\n const nplurals = locale ? getNPlurals(locale) : undefined;\n\n for (const { context, id, message, comments, obsolete, plural } of source) {\n const ctx = context || \"\";\n if (!translations[ctx]) {\n translations[ctx] = {};\n }\n\n const length = plural ? (nplurals ?? message.length) : 1;\n\n const existing = translations[ctx][id];\n const refs = new Set<string>();\n if (existing?.comments?.reference) {\n existing.comments.reference.split(/\\r?\\n|\\r/).forEach((r) => {\n refs.add(r);\n });\n }\n if (comments?.reference) {\n comments.reference.split(/\\r?\\n|\\r/).forEach((r) => {\n refs.add(r);\n });\n }\n\n const msgstr = existing?.msgstr ? existing.msgstr.slice(0, length) : Array.from({ length }, () => \"\");\n while (msgstr.length < length) msgstr.push(\"\");\n\n translations[ctx][id] = {\n msgctxt: context || undefined,\n msgid: id,\n msgid_plural: plural,\n msgstr,\n comments: {\n ...existing?.comments,\n ...comments,\n reference: refs.size ? Array.from(refs).join(\"\\n\") : undefined,\n },\n obsolete: existing?.obsolete ?? obsolete,\n };\n }\n\n return translations;\n}\n","import { isDeepStrictEqual } from \"node:util\";\nimport type { GetTextTranslations } from \"gettext-parser\";\nimport * as gettextParser from \"gettext-parser\";\n\nconst IGNORED_HEADER_KEYS = new Set([\"pot-creation-date\", \"po-revision-date\"]);\nconst IGNORED_HEADER_LINE_PREFIXES = [\"pot-creation-date:\", \"po-revision-date:\"];\n\nfunction normalizeHeaderString(value: string): string {\n const lines = value.split(\"\\n\");\n const hadTrailingNewline = value.endsWith(\"\\n\");\n\n const filtered = lines\n .filter((line) => {\n const trimmed = line.trimStart().toLowerCase();\n return !IGNORED_HEADER_LINE_PREFIXES.some((prefix) => trimmed.startsWith(prefix));\n })\n .map((line) => {\n const separatorIndex = line.indexOf(\":\");\n if (separatorIndex === -1) {\n return line;\n }\n\n const key = line.slice(0, separatorIndex).trim().toLowerCase();\n const value = line.slice(separatorIndex + 1);\n return `${key}:${value}`;\n });\n\n if (hadTrailingNewline && filtered[filtered.length - 1] !== \"\") {\n filtered.push(\"\");\n }\n\n return filtered.join(\"\\n\");\n}\n\nfunction normalize(translations: GetTextTranslations): GetTextTranslations {\n const compiled = gettextParser.po.compile(translations);\n const parsed = gettextParser.po.parse(compiled);\n\n if (parsed.headers) {\n const normalizedHeaders: Record<string, string> = {};\n for (const [key, value] of Object.entries(parsed.headers)) {\n if (!IGNORED_HEADER_KEYS.has(key.toLowerCase())) {\n normalizedHeaders[key.toLowerCase()] = value as string;\n }\n }\n parsed.headers = normalizedHeaders;\n }\n\n const headerMessage = parsed.translations?.[\"\"]?.[\"\"];\n if (headerMessage?.msgstr) {\n headerMessage.msgstr = headerMessage.msgstr.map((item) => normalizeHeaderString(item));\n }\n\n return parsed;\n}\n\nexport function hasChanges(left: GetTextTranslations, right?: GetTextTranslations): boolean {\n if (!right) {\n return true;\n }\n\n const normalizedLeft = normalize(left);\n const normalizedRight = normalize(right);\n\n return !isDeepStrictEqual(normalizedLeft, normalizedRight);\n}\n","import type { GetTextTranslationRecord, GetTextTranslations } from \"gettext-parser\";\nimport { getFormula, getNPlurals } from \"plural-forms\";\n\nimport type { ObsoleteStrategy } from \"../../configuration.ts\";\n\nexport interface Collected {\n translations: GetTextTranslationRecord;\n}\n\nexport function formatDate(date: Date): string {\n const pad = (n: number) => n.toString().padStart(2, \"0\");\n const year = date.getFullYear();\n const month = pad(date.getMonth() + 1);\n const day = pad(date.getDate());\n const hours = pad(date.getHours());\n const minutes = pad(date.getMinutes());\n const tzo = -date.getTimezoneOffset();\n const sign = tzo >= 0 ? \"+\" : \"-\";\n const offsetHours = pad(Math.floor(Math.abs(tzo) / 60));\n const offsetMinutes = pad(Math.abs(tzo) % 60);\n return `${year}-${month}-${day} ${hours}:${minutes}${sign}${offsetHours}${offsetMinutes}`;\n}\n\nexport function merge(\n sources: Collected[],\n existing: GetTextTranslations | undefined,\n obsolete: ObsoleteStrategy,\n locale: string,\n generatedAt: Date,\n): GetTextTranslations {\n let headers: Record<string, string> = {};\n let translations: GetTextTranslationRecord = { \"\": {} };\n let obsoleteTranslations: GetTextTranslationRecord = {};\n const nplurals = getNPlurals(locale);\n\n if (existing) {\n headers = existing.headers ? structuredClone(existing.headers) : {};\n translations = existing.translations ? structuredClone(existing.translations) : { \"\": {} };\n obsoleteTranslations = existing.obsolete ? structuredClone(existing.obsolete) : {};\n for (const ctx of Object.keys(translations)) {\n for (const id of Object.keys(translations[ctx])) {\n if (ctx === \"\" && id === \"\") continue;\n translations[ctx][id].obsolete = true;\n }\n }\n }\n\n const collected: GetTextTranslationRecord = { \"\": {} };\n for (const { translations } of sources) {\n for (const [ctx, msgs] of Object.entries(translations)) {\n if (!collected[ctx]) collected[ctx] = {};\n for (const [id, entry] of Object.entries(msgs)) {\n const existing = collected[ctx][id];\n const refs = new Set<string>();\n if (existing?.comments?.reference) {\n existing.comments.reference.split(/\\r?\\n|\\r/).forEach((r) => {\n refs.add(r);\n });\n }\n if (entry.comments?.reference) {\n entry.comments.reference.split(/\\r?\\n|\\r/).forEach((r) => {\n refs.add(r);\n });\n }\n collected[ctx][id] = {\n ...existing,\n ...entry,\n comments: {\n ...existing?.comments,\n ...entry.comments,\n reference: refs.size ? Array.from(refs).join(\"\\n\") : undefined,\n },\n };\n }\n }\n }\n\n for (const [ctx, msgs] of Object.entries(collected)) {\n if (!translations[ctx]) translations[ctx] = {};\n for (const [id, entry] of Object.entries(msgs)) {\n const existingEntry = translations[ctx][id] ?? obsoleteTranslations[ctx]?.[id];\n if (existingEntry) {\n entry.msgstr = existingEntry.msgstr;\n entry.comments = {\n ...entry.comments,\n translator: existingEntry.comments?.translator,\n };\n }\n delete entry.obsolete;\n entry.msgstr = entry.msgstr.slice(0, nplurals);\n while (entry.msgstr.length < nplurals) {\n entry.msgstr.push(\"\");\n }\n translations[ctx][id] = entry;\n if (obsoleteTranslations[ctx]) {\n delete obsoleteTranslations[ctx][id];\n }\n }\n }\n\n for (const ctx of Object.keys(translations)) {\n for (const id of Object.keys(translations[ctx])) {\n if (ctx === \"\" && id === \"\") {\n continue;\n }\n const entry = translations[ctx][id];\n if (entry.obsolete) {\n if (!obsoleteTranslations[ctx]) {\n obsoleteTranslations[ctx] = {};\n }\n obsoleteTranslations[ctx][id] = entry;\n delete translations[ctx][id];\n }\n }\n }\n\n headers = {\n ...headers,\n \"Content-Type\": headers[\"Content-Type\"] || \"text/plain; charset=UTF-8\",\n \"Plural-Forms\": `nplurals=${nplurals}; plural=${getFormula(locale)};`,\n language: locale,\n \"MIME-Version\": \"1.0\",\n \"Content-Transfer-Encoding\": \"8bit\",\n \"POT-Creation-Date\": formatDate(generatedAt),\n \"x-generator\": \"@let-value/translate-extract\",\n };\n\n return {\n charset: \"utf-8\",\n headers,\n translations,\n ...(obsolete === \"mark\" && Object.keys(obsoleteTranslations).length ? { obsolete: obsoleteTranslations } : {}),\n };\n}\n","import fs from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\nimport * as gettextParser from \"gettext-parser\";\n\nimport type { Plugin } from \"../../plugin.ts\";\nimport type { Translation } from \"../core/queries/types.ts\";\nimport { collect } from \"./collect.ts\";\nimport { hasChanges } from \"./hasChanges.ts\";\nimport { merge } from \"./merge.ts\";\n\nconst namespace = \"translate\";\n\nexport function po(): Plugin {\n return {\n name: \"po\",\n setup(build) {\n build.context.logger?.debug(\"po plugin initialized\");\n const collections = new Map<\n string,\n {\n locale: string;\n translations: Translation[];\n }\n >();\n let dispatched = false;\n\n build.onResolve({ filter: /.*/, namespace }, async ({ entrypoint, path, data }) => {\n if (!data || !Array.isArray(data)) {\n return undefined;\n }\n\n for (const locale of build.context.config.locales) {\n const destination = build.context.config.destination({ entrypoint, locale, path });\n if (!collections.has(destination)) {\n collections.set(destination, { locale, translations: [] });\n }\n\n collections.get(destination)?.translations.push(...data);\n }\n\n Promise.all([build.defer(\"source\"), build.defer(namespace)]).then(() => {\n if (dispatched) {\n return;\n }\n dispatched = true;\n\n for (const path of collections.keys()) {\n build.load({ entrypoint, path, namespace });\n }\n });\n\n return undefined;\n });\n\n build.onLoad({ filter: /.*\\.po$/, namespace }, async ({ entrypoint, path }) => {\n const contents = await fs.readFile(path).catch(() => undefined);\n const data = contents ? gettextParser.po.parse(contents) : undefined;\n return {\n entrypoint,\n path,\n namespace,\n data,\n };\n });\n\n build.onProcess({ filter: /.*\\.po$/, namespace }, async ({ entrypoint, path, data }) => {\n const collected = collections.get(path);\n if (!collected) {\n build.context.logger?.warn({ path }, \"no translations collected for this path\");\n return undefined;\n }\n\n const { locale, translations } = collected;\n\n const record = collect(translations, locale);\n\n const out = merge(\n [{ translations: record }],\n data as never,\n build.context.config.obsolete,\n locale,\n build.context.generatedAt,\n );\n\n if (hasChanges(out, data as never)) {\n await fs.mkdir(dirname(path), { recursive: true });\n await fs.writeFile(path, gettextParser.po.compile(out));\n }\n\n build.resolve({\n entrypoint,\n path,\n namespace: \"cleanup\",\n data: translations,\n });\n });\n },\n };\n}\n","import type Parser from \"@keqingmoe/tree-sitter\";\n\nexport function buildTemplate(node: Parser.SyntaxNode): { text: string; error?: string } {\n const source = node.tree.rootNode.text;\n const open = node.childForFieldName(\"open_tag\");\n const close = node.childForFieldName(\"close_tag\");\n const contentStart = open?.endIndex ?? node.startIndex;\n const contentEnd = close?.startIndex ?? node.endIndex;\n\n type Part = { kind: \"text\"; text: string; raw: boolean } | { kind: \"expr\"; value: string };\n\n const parts: Part[] = [];\n let segmentStart = contentStart;\n\n const pushRawText = (endIndex: number) => {\n if (endIndex <= segmentStart) {\n segmentStart = Math.max(segmentStart, endIndex);\n return;\n }\n const text = source.slice(segmentStart, endIndex);\n if (text) {\n parts.push({ kind: \"text\", text, raw: true });\n }\n segmentStart = endIndex;\n };\n\n const children = node.namedChildren.slice(1, -1);\n for (const child of children) {\n if (child.type === \"jsx_expression\") {\n pushRawText(child.startIndex);\n const expr = child.namedChildren[0];\n if (!expr) {\n return { text: \"\", error: \"Empty JSX expression\" };\n }\n\n if (expr.type === \"identifier\") {\n parts.push({ kind: \"expr\", value: expr.text });\n } else if (expr.type === \"string\") {\n parts.push({ kind: \"text\", text: expr.text.slice(1, -1), raw: false });\n } else if (expr.type === \"template_string\") {\n const hasSubstitutions = expr.children.some((c) => c.type === \"template_substitution\");\n if (hasSubstitutions) {\n return { text: \"\", error: \"JSX expressions with template substitutions are not supported\" };\n }\n parts.push({ kind: \"text\", text: expr.text.slice(1, -1), raw: false });\n } else {\n return { text: \"\", error: \"JSX expressions must be simple identifiers, strings, or template literals\" };\n }\n segmentStart = child.endIndex;\n } else if (child.type === \"string\") {\n pushRawText(child.startIndex);\n parts.push({ kind: \"text\", text: child.text.slice(1, -1), raw: false });\n segmentStart = child.endIndex;\n } else if (child.type === \"jsx_text\" || child.type === \"html_character_reference\" || child.isError) {\n } else {\n return { text: \"\", error: \"Unsupported JSX child\" };\n }\n }\n\n pushRawText(contentEnd);\n\n const firstRawIndex = parts.findIndex((part) => part.kind === \"text\" && part.raw);\n if (firstRawIndex === 0) {\n const part = parts[firstRawIndex] as Extract<Part, { kind: \"text\" }>;\n part.text = part.text.replace(/^\\s+/, \"\");\n }\n\n let lastRawIndex = -1;\n for (let i = parts.length - 1; i >= 0; i--) {\n const part = parts[i];\n if (part.kind === \"text\" && part.raw) {\n lastRawIndex = i;\n break;\n }\n }\n if (lastRawIndex !== -1 && lastRawIndex === parts.length - 1) {\n const part = parts[lastRawIndex] as Extract<Part, { kind: \"text\" }>;\n part.text = part.text.replace(/\\s+$/, \"\");\n }\n\n const strings: string[] = [\"\"];\n const values: string[] = [];\n for (const part of parts) {\n if (part.kind === \"text\") {\n if (part.text) {\n strings[strings.length - 1] += part.text;\n }\n } else {\n values.push(part.value);\n strings.push(\"\");\n }\n }\n\n let text = \"\";\n for (let i = 0; i < strings.length; i++) {\n text += strings[i];\n if (values[i]) {\n text += `\\${${values[i]}}`;\n }\n }\n return { text };\n}\n\nexport function buildAttrValue(node: Parser.SyntaxNode): { text: string; error?: string } {\n if (node.type === \"string\") {\n return { text: node.text.slice(1, -1) };\n }\n if (node.type === \"jsx_expression\") {\n const expr = node.namedChildren[0];\n if (!expr) {\n return { text: \"\", error: \"Empty JSX expression\" };\n }\n\n if (expr.type === \"identifier\") {\n return { text: `\\${${expr.text}}` };\n } else if (expr.type === \"string\") {\n return { text: expr.text.slice(1, -1) };\n } else if (expr.type === \"template_string\") {\n // Check if it's a simple template string with no substitutions\n const hasSubstitutions = expr.children.some((c) => c.type === \"template_substitution\");\n if (hasSubstitutions) {\n return { text: \"\", error: \"JSX expressions with template substitutions are not supported\" };\n }\n // Extract the text content from the template string\n const content = expr.text.slice(1, -1); // Remove backticks\n return { text: content };\n } else {\n return { text: \"\", error: \"JSX expressions must be simple identifiers, strings, or template literals\" };\n }\n }\n return { text: \"\", error: \"Unsupported JSX child\" };\n}\n","import type Parser from \"@keqingmoe/tree-sitter\";\n\nimport { withComment } from \"../../core/queries/comment.ts\";\nimport type { MessageMatch, QuerySpec, Translation } from \"../../core/queries/types.ts\";\nimport { buildAttrValue, buildTemplate } from \"./utils.ts\";\n\nexport const messageQuery: QuerySpec = withComment({\n pattern: `(\n [\n (jsx_element (jsx_opening_element name: (identifier) @name)) @call\n (jsx_self_closing_element name: (identifier) @name) @call\n (lexical_declaration \n (variable_declarator \n value: [\n (jsx_element (jsx_opening_element name: (identifier) @name)) @call\n (jsx_self_closing_element name: (identifier) @name) @call\n ]\n )\n )\n ]\n (#eq? @name \"Message\")\n )`,\n extract(match: Parser.QueryMatch): MessageMatch | undefined {\n const node = match.captures.find((c) => c.name === \"call\")?.node;\n if (!node) return undefined;\n let attrs: Parser.SyntaxNode[] = [];\n if (node.type === \"jsx_element\") {\n const open = node.childForFieldName(\"open_tag\");\n if (open) attrs = open.namedChildren;\n } else if (node.type === \"jsx_self_closing_element\") {\n attrs = node.namedChildren.slice(1);\n }\n let msgctxt: string | undefined;\n let childValue: Parser.SyntaxNode | undefined;\n for (const child of attrs) {\n if (child.type !== \"jsx_attribute\") continue;\n const name = child.child(0);\n const value = child.child(child.childCount - 1);\n if (name?.text === \"context\" && value?.type === \"string\") {\n msgctxt = value.text.slice(1, -1);\n } else if (name?.text === \"children\" && value) {\n childValue = value;\n }\n }\n let text = \"\";\n let error: string | undefined;\n if (node.type === \"jsx_element\") {\n ({ text, error } = buildTemplate(node));\n } else if (childValue) {\n ({ text, error } = buildAttrValue(childValue));\n }\n if (error) {\n return { node, error };\n }\n if (!text) return undefined;\n const translation: Translation = {\n id: text,\n message: [text],\n };\n if (msgctxt) translation.context = msgctxt;\n return { node, translation };\n },\n});\n","import type Parser from \"@keqingmoe/tree-sitter\";\n\nimport { withComment } from \"../../core/queries/comment.ts\";\nimport type { MessageMatch, QuerySpec, Translation } from \"../../core/queries/types.ts\";\nimport { buildTemplate } from \"./utils.ts\";\n\nfunction parseForms(node: Parser.SyntaxNode): { forms: string[]; error?: string } {\n const forms: string[] = [];\n if (node.type === \"jsx_expression\") {\n const arr = node.namedChildren[0];\n if (!arr || arr.type !== \"array\") {\n return { forms: [], error: \"Plural forms must be an array\" };\n }\n for (const el of arr.namedChildren) {\n if (el.type === \"jsx_element\" || el.type === \"jsx_fragment\") {\n const { text, error } = buildTemplate(el);\n if (error) return { forms: [], error };\n forms.push(text);\n } else if (el.type === \"string\") {\n forms.push(el.text.slice(1, -1));\n } else {\n return { forms: [], error: \"Unsupported plural form\" };\n }\n }\n }\n return { forms };\n}\n\nexport const pluralQuery: QuerySpec = withComment({\n pattern: `(\n [\n (jsx_element (jsx_opening_element name: (identifier) @name))\n (jsx_self_closing_element name: (identifier) @name)\n ] @call\n (#eq? @name \"Plural\")\n )`,\n extract(match: Parser.QueryMatch): MessageMatch | undefined {\n const node = match.captures.find((c) => c.name === \"call\")?.node;\n if (!node) return undefined;\n let attrs: Parser.SyntaxNode[] = [];\n if (node.type === \"jsx_element\") {\n const open = node.childForFieldName(\"open_tag\");\n if (open) attrs = open.namedChildren;\n } else if (node.type === \"jsx_self_closing_element\") {\n attrs = node.namedChildren.slice(1);\n }\n let msgctxt: string | undefined;\n let formsNode: Parser.SyntaxNode | null | undefined;\n for (const child of attrs) {\n if (child.type !== \"jsx_attribute\") continue;\n const name = child.child(0);\n const value = child.child(child.childCount - 1);\n if (name?.text === \"context\" && value?.type === \"string\") {\n msgctxt = value.text.slice(1, -1);\n } else if (name?.text === \"forms\" && value) {\n formsNode = value;\n }\n }\n if (!formsNode) return undefined;\n const { forms, error } = parseForms(formsNode);\n if (error) {\n return { node, error };\n }\n if (forms.length === 0) return undefined;\n const translation: Translation = {\n id: forms[0],\n plural: forms[1],\n message: forms,\n };\n if (msgctxt) translation.context = msgctxt;\n return { node, translation };\n },\n});\n","import type { QuerySpec } from \"../../core/queries/types.ts\";\nimport { messageQuery } from \"./message.ts\";\nimport { pluralQuery } from \"./plural.ts\";\n\nexport const queries: QuerySpec[] = [messageQuery, pluralQuery];\n","import fs from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { getParser, getQuery } from \"../core/parse.ts\";\nimport { getReference } from \"../core/queries/comment.ts\";\n\nimport type { Context, Translation, Warning } from \"../core/queries/types.ts\";\nimport { queries } from \"./queries/index.ts\";\n\nexport interface ParseResult {\n translations: Translation[];\n warnings: Warning[];\n}\n\nexport function parseFile(filePath: string): ParseResult {\n const path = resolve(filePath);\n const source = fs.readFileSync(path, \"utf8\");\n return parseSource(source, path);\n}\n\nexport function parseSource(source: string, path: string): ParseResult {\n const context: Context = { path };\n const { parser, language } = getParser(path);\n const tree = parser.parse(source);\n\n const translations: Translation[] = [];\n const warnings: Warning[] = [];\n const seen = new Set<number>();\n\n for (const spec of queries) {\n const query = getQuery(language, spec.pattern);\n for (const match of query.matches(tree.rootNode)) {\n const message = spec.extract(match);\n if (!message) continue;\n const { node, translation, error } = message;\n if (seen.has(node.id)) continue;\n seen.add(node.id);\n const reference = getReference(node, context);\n if (translation) {\n translations.push({\n ...translation,\n comments: {\n ...translation.comments,\n reference,\n },\n });\n }\n if (error) {\n warnings.push({\n error,\n reference,\n });\n }\n }\n }\n\n return { translations, warnings };\n}\n","import { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\n\nimport type { Plugin } from \"../../plugin.ts\";\nimport type { Translation } from \"../core/queries/types.ts\";\nimport { parseSource } from \"./parse.ts\";\n\nconst filter = /\\.[cm]?[jt]sx$/;\n\nexport function react(): Plugin<string, Translation[]> {\n return {\n name: \"react\",\n setup(build) {\n build.context.logger?.debug(\"react plugin initialized\");\n build.onResolve({ filter: /.*/, namespace: \"source\" }, ({ entrypoint, path, namespace }) => {\n return {\n entrypoint,\n namespace,\n path: resolve(path),\n };\n });\n build.onLoad({ filter, namespace: \"source\" }, async ({ entrypoint, path, namespace }) => {\n const data = await readFile(path, \"utf8\");\n return {\n entrypoint,\n path,\n namespace,\n data,\n };\n });\n build.onProcess({ filter, namespace: \"source\" }, ({ entrypoint, path, data }) => {\n const { translations, warnings } = parseSource(data, path);\n\n for (const warning of warnings) {\n build.context.logger?.warn(`${warning.error} at ${warning.reference}`);\n }\n\n build.resolve({\n entrypoint,\n path,\n namespace: \"translate\",\n data: translations,\n });\n\n return undefined;\n });\n },\n };\n}\n","import type { Plugin, UniversalPlugin } from \"../plugin.ts\";\n\nimport { cleanup, core, po, react } from \"./index.ts\";\n\nconst original = {\n cleanup,\n core,\n po,\n react,\n} as const;\n\nexport function resolveStaticPlugin(item: UniversalPlugin): Plugin {\n if (\"static\" in item) {\n return original[item.static.name](...item.static.props);\n }\n\n return item;\n}\n","import glob from \"fast-glob\";\nimport type { ResolvedConfig, ResolvedEntrypoint } from \"./configuration.ts\";\nimport { Defer } from \"./defer.ts\";\nimport type { Logger } from \"./logger.ts\";\nimport type {\n Build,\n Context,\n Filter,\n LoadArgs,\n LoadHook,\n ProcessArgs,\n ProcessHook,\n ResolveArgs,\n ResolveHook,\n} from \"./plugin.ts\";\nimport { resolveStaticPlugin } from \"./plugins/static.ts\";\n\nexport type Task =\n | {\n type: \"resolve\";\n args: ResolveArgs;\n }\n | {\n type: \"load\";\n args: LoadArgs;\n }\n | {\n type: \"process\";\n args: ProcessArgs;\n };\n\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 = 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 item of config.plugins) {\n const plugin = resolveStaticPlugin(item);\n logger?.debug({ plugin: plugin.name }, \"setting up plugin\");\n plugin.setup(build);\n }\n\n const pattern = entrypoint.entrypoint.replace(/\\\\/g, \"/\");\n const paths = glob.isDynamicPattern(pattern) ? await glob(pattern, { onlyFiles: true }) : [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;;;;;;ACP5B,MAAMA,cAAY;AAElB,SAAgB,UAAkB;AAC9B,QAAO;EACH,MAAM;EACN,MAAM,OAAO;AACT,SAAM,QAAQ,QAAQ,MAAM,6BAA6B;GACzD,MAAM,4BAAY,IAAI,KAAa;GACnC,MAAM,4BAAY,IAAI,KAAa;GACnC,MAAM,uBAAO,IAAI,KAAa;GAC9B,IAAI,aAAa;AAEjB,SAAM,UAAU;IAAE;IAAW,QAAQ;IAAM,GAAG,EAAE,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