@let-value/translate-extract 1.0.12 → 1.0.13

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,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- const require_run = require('../run-XkKxn8kJ.cjs');
2
+ const require_run = require('../run-BFehT9l8.cjs');
3
3
  let node_util = require("node:util");
4
4
  node_util = require_run.__toESM(node_util);
5
5
  let cosmiconfig = require("cosmiconfig");
@@ -13,7 +13,10 @@ function createLogger(level = "info") {
13
13
  level,
14
14
  transport: {
15
15
  target: "pino-pretty",
16
- options: { colorize: true }
16
+ options: {
17
+ colorize: true,
18
+ ignore: "time,pid,hostname"
19
+ }
17
20
  }
18
21
  });
19
22
  }
@@ -30,7 +33,7 @@ async function main() {
30
33
  } }
31
34
  });
32
35
  const logger = createLogger(logLevel);
33
- const explorer = (0, cosmiconfig.cosmiconfig)(moduleName, { searchPlaces: [
36
+ const result = await (0, cosmiconfig.cosmiconfig)(moduleName, { searchPlaces: [
34
37
  `.${moduleName}rc.js`,
35
38
  `.${moduleName}rc.ts`,
36
39
  `.${moduleName}rc.mjs`,
@@ -43,8 +46,7 @@ async function main() {
43
46
  `${moduleName}.config.ts`,
44
47
  `${moduleName}.config.mjs`,
45
48
  `${moduleName}.config.cjs`
46
- ] });
47
- const result = await explorer.search();
49
+ ] }).search();
48
50
  if (!result || !result.config) {
49
51
  logger.error("No configuration file found");
50
52
  process.exit(1);
@@ -60,8 +62,7 @@ async function main() {
60
62
  await Promise.all(tasks);
61
63
  }
62
64
  main().catch((err) => {
63
- const logger = createLogger();
64
- logger.error(err);
65
+ createLogger().error(err);
65
66
  process.exit(1);
66
67
  });
67
68
 
@@ -1,2 +1 @@
1
- #!/usr/bin/env node
2
- export {};
1
+ export { };
package/dist/bin/cli.d.ts CHANGED
@@ -1,2 +1 @@
1
- #!/usr/bin/env node
2
- export {};
1
+ export { };
package/dist/bin/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { run } from "../run-Dl-tr2kf.js";
2
+ import { run } from "../run-CQoAsNNE.js";
3
3
  import { parseArgs } from "node:util";
4
4
  import { cosmiconfig } from "cosmiconfig";
5
5
  import pino from "pino";
@@ -10,7 +10,10 @@ function createLogger(level = "info") {
10
10
  level,
11
11
  transport: {
12
12
  target: "pino-pretty",
13
- options: { colorize: true }
13
+ options: {
14
+ colorize: true,
15
+ ignore: "time,pid,hostname"
16
+ }
14
17
  }
15
18
  });
16
19
  }
@@ -27,7 +30,7 @@ async function main() {
27
30
  } }
28
31
  });
29
32
  const logger = createLogger(logLevel);
30
- const explorer = cosmiconfig(moduleName, { searchPlaces: [
33
+ const result = await cosmiconfig(moduleName, { searchPlaces: [
31
34
  `.${moduleName}rc.js`,
32
35
  `.${moduleName}rc.ts`,
33
36
  `.${moduleName}rc.mjs`,
@@ -40,8 +43,7 @@ async function main() {
40
43
  `${moduleName}.config.ts`,
41
44
  `${moduleName}.config.mjs`,
42
45
  `${moduleName}.config.cjs`
43
- ] });
44
- const result = await explorer.search();
46
+ ] }).search();
45
47
  if (!result || !result.config) {
46
48
  logger.error("No configuration file found");
47
49
  process.exit(1);
@@ -57,8 +59,7 @@ async function main() {
57
59
  await Promise.all(tasks);
58
60
  }
59
61
  main().catch((err) => {
60
- const logger = createLogger();
61
- logger.error(err);
62
+ createLogger().error(err);
62
63
  process.exit(1);
63
64
  });
64
65
 
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","names":["tasks: Promise<unknown>[]"],"sources":["../../src/logger.ts","../../bin/cli.ts"],"sourcesContent":["import pino, { type LevelWithSilent, type Logger } from \"pino\";\n\nexport function createLogger(level: LevelWithSilent = \"info\"): Logger {\n return pino({\n level,\n transport: {\n target: \"pino-pretty\",\n options: {\n colorize: true,\n },\n },\n });\n}\n\nexport type { Logger, LevelWithSilent };\n","#!/usr/bin/env node\nimport { parseArgs } from \"node:util\";\nimport { cosmiconfig } from \"cosmiconfig\";\nimport type { ResolvedConfig } from \"../src/configuration.ts\";\nimport { createLogger, type LevelWithSilent } from \"../src/logger.ts\";\nimport { run } from \"../src/run.ts\";\n\nconst moduleName = \"translate\";\n\nasync function main() {\n const {\n values: { logLevel },\n } = parseArgs({\n args: process.argv.slice(2),\n options: {\n logLevel: { type: \"string\", short: \"l\" },\n },\n });\n\n const logger = createLogger(logLevel as LevelWithSilent | undefined);\n\n const explorer = cosmiconfig(moduleName, {\n searchPlaces: [\n `.${moduleName}rc.js`,\n `.${moduleName}rc.ts`,\n `.${moduleName}rc.mjs`,\n `.${moduleName}rc.cjs`,\n `.config/${moduleName}rc.js`,\n `.config/${moduleName}rc.ts`,\n `.config/${moduleName}rc.mjs`,\n `.config/${moduleName}rc.cjs`,\n `${moduleName}.config.js`,\n `${moduleName}.config.ts`,\n `${moduleName}.config.mjs`,\n `${moduleName}.config.cjs`,\n ],\n });\n\n const result = await explorer.search();\n if (!result || !result.config) {\n logger.error(\"No configuration file found\");\n process.exit(1);\n }\n\n const config = result.config as ResolvedConfig;\n config.logLevel = (logLevel as LevelWithSilent) ?? config.logLevel;\n logger.level = config.logLevel;\n\n const tasks: Promise<unknown>[] = [];\n for (const entrypoint of config.entrypoints) {\n tasks.push(run(entrypoint, { config, logger }));\n }\n\n await Promise.all(tasks);\n}\n\nvoid main().catch((err) => {\n const logger = createLogger();\n logger.error(err);\n process.exit(1);\n});\n"],"mappings":";;;;;;;AAEA,SAAgB,aAAa,QAAyB,QAAgB;AAClE,QAAO,KAAK;EACR;EACA,WAAW;GACP,QAAQ;GACR,SAAS,EACL,UAAU;;;;;;;ACD1B,MAAM,aAAa;AAEnB,eAAe,OAAO;CAClB,MAAM,EACF,QAAQ,EAAE,eACV,UAAU;EACV,MAAM,QAAQ,KAAK,MAAM;EACzB,SAAS,EACL,UAAU;GAAE,MAAM;GAAU,OAAO;;;CAI3C,MAAM,SAAS,aAAa;CAE5B,MAAM,WAAW,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;;CAItB,MAAM,SAAS,MAAM,SAAS;AAC9B,KAAI,CAAC,UAAU,CAAC,OAAO,QAAQ;AAC3B,SAAO,MAAM;AACb,UAAQ,KAAK;;CAGjB,MAAM,SAAS,OAAO;AACtB,QAAO,WAAY,YAAgC,OAAO;AAC1D,QAAO,QAAQ,OAAO;CAEtB,MAAMA,QAA4B;AAClC,MAAK,MAAM,cAAc,OAAO,YAC5B,OAAM,KAAK,IAAI,YAAY;EAAE;EAAQ;;AAGzC,OAAM,QAAQ,IAAI;;AAGjB,OAAO,OAAO,QAAQ;CACvB,MAAM,SAAS;AACf,QAAO,MAAM;AACb,SAAQ,KAAK"}
1
+ {"version":3,"file":"cli.js","names":["tasks: Promise<unknown>[]"],"sources":["../../src/logger.ts","../../bin/cli.ts"],"sourcesContent":["import pino, { type LevelWithSilent, type Logger } from \"pino\";\n\nexport function createLogger(level: LevelWithSilent = \"info\"): Logger {\n return pino({\n level,\n transport: {\n target: \"pino-pretty\",\n options: {\n colorize: true,\n ignore: \"time,pid,hostname\",\n },\n },\n });\n}\n\nexport type { Logger, LevelWithSilent };\n","#!/usr/bin/env node\nimport { parseArgs } from \"node:util\";\nimport { cosmiconfig } from \"cosmiconfig\";\nimport type { ResolvedConfig } from \"../src/configuration.ts\";\nimport { createLogger, type LevelWithSilent } from \"../src/logger.ts\";\nimport { run } from \"../src/run.ts\";\n\nconst moduleName = \"translate\";\n\nasync function main() {\n const {\n values: { logLevel },\n } = parseArgs({\n args: process.argv.slice(2),\n options: {\n logLevel: { type: \"string\", short: \"l\" },\n },\n });\n\n const logger = createLogger(logLevel as LevelWithSilent | undefined);\n\n const explorer = cosmiconfig(moduleName, {\n searchPlaces: [\n `.${moduleName}rc.js`,\n `.${moduleName}rc.ts`,\n `.${moduleName}rc.mjs`,\n `.${moduleName}rc.cjs`,\n `.config/${moduleName}rc.js`,\n `.config/${moduleName}rc.ts`,\n `.config/${moduleName}rc.mjs`,\n `.config/${moduleName}rc.cjs`,\n `${moduleName}.config.js`,\n `${moduleName}.config.ts`,\n `${moduleName}.config.mjs`,\n `${moduleName}.config.cjs`,\n ],\n });\n\n const result = await explorer.search();\n if (!result || !result.config) {\n logger.error(\"No configuration file found\");\n process.exit(1);\n }\n\n const config = result.config as ResolvedConfig;\n config.logLevel = (logLevel as LevelWithSilent) ?? config.logLevel;\n logger.level = config.logLevel;\n\n const tasks: Promise<unknown>[] = [];\n for (const entrypoint of config.entrypoints) {\n tasks.push(run(entrypoint, { config, logger }));\n }\n\n await Promise.all(tasks);\n}\n\nvoid main().catch((err) => {\n const logger = createLogger();\n logger.error(err);\n process.exit(1);\n});\n"],"mappings":";;;;;;;AAEA,SAAgB,aAAa,QAAyB,QAAgB;AAClE,QAAO,KAAK;EACR;EACA,WAAW;GACP,QAAQ;GACR,SAAS;IACL,UAAU;IACV,QAAQ;IACX;GACJ;EACJ,CAAC;;;;;ACLN,MAAM,aAAa;AAEnB,eAAe,OAAO;CAClB,MAAM,EACF,QAAQ,EAAE,eACV,UAAU;EACV,MAAM,QAAQ,KAAK,MAAM,EAAE;EAC3B,SAAS,EACL,UAAU;GAAE,MAAM;GAAU,OAAO;GAAK,EAC3C;EACJ,CAAC;CAEF,MAAM,SAAS,aAAa,SAAwC;CAmBpE,MAAM,SAAS,MAjBE,YAAY,YAAY,EACrC,cAAc;EACV,IAAI,WAAW;EACf,IAAI,WAAW;EACf,IAAI,WAAW;EACf,IAAI,WAAW;EACf,WAAW,WAAW;EACtB,WAAW,WAAW;EACtB,WAAW,WAAW;EACtB,WAAW,WAAW;EACtB,GAAG,WAAW;EACd,GAAG,WAAW;EACd,GAAG,WAAW;EACd,GAAG,WAAW;EACjB,EACJ,CAAC,CAE4B,QAAQ;AACtC,KAAI,CAAC,UAAU,CAAC,OAAO,QAAQ;AAC3B,SAAO,MAAM,8BAA8B;AAC3C,UAAQ,KAAK,EAAE;;CAGnB,MAAM,SAAS,OAAO;AACtB,QAAO,WAAY,YAAgC,OAAO;AAC1D,QAAO,QAAQ,OAAO;CAEtB,MAAMA,QAA4B,EAAE;AACpC,MAAK,MAAM,cAAc,OAAO,YAC5B,OAAM,KAAK,IAAI,YAAY;EAAE;EAAQ;EAAQ,CAAC,CAAC;AAGnD,OAAM,QAAQ,IAAI,MAAM;;AAGvB,MAAM,CAAC,OAAO,QAAQ;AAEvB,CADe,cAAc,CACtB,MAAM,IAAI;AACjB,SAAQ,KAAK,EAAE;EACjB"}
@@ -57,7 +57,7 @@ async function run(entrypoint, { config, logger }) {
57
57
  generatedAt: /* @__PURE__ */ new Date(),
58
58
  logger
59
59
  };
60
- logger?.info({ entrypoint }, "starting extraction");
60
+ logger?.info(entrypoint, "starting extraction");
61
61
  const resolvers = [];
62
62
  const loaders = [];
63
63
  const processors = [];
@@ -77,30 +77,49 @@ async function run(entrypoint, { config, logger }) {
77
77
  return defer$1;
78
78
  }
79
79
  function defer(namespace) {
80
- const defer$1 = getDeferred(namespace);
81
- return defer$1.promise;
80
+ return getDeferred(namespace).promise;
82
81
  }
83
82
  function resolve(args) {
84
- if (args.path !== args.entrypoint && (!context.config.walk || context.config.exclude.some((ex) => typeof ex === "function" ? ex(args) : ex.test(args.path)))) return;
83
+ const { entrypoint: entrypoint$1, path, namespace } = args;
84
+ const skipped = args.path !== args.entrypoint && !context.config.walk || context.config.exclude.some((ex) => typeof ex === "function" ? ex(args) : ex.test(args.path));
85
+ logger?.debug({
86
+ entrypoint: entrypoint$1,
87
+ path,
88
+ namespace,
89
+ skipped
90
+ }, "resolve");
91
+ if (skipped) return;
85
92
  queue.push({
86
93
  type: "resolve",
87
94
  args
88
95
  });
89
- getDeferred(args.namespace).enqueue();
96
+ getDeferred(namespace).enqueue();
90
97
  }
91
98
  function load(args) {
99
+ const { entrypoint: entrypoint$1, path, namespace } = args;
100
+ logger?.debug({
101
+ entrypoint: entrypoint$1,
102
+ path,
103
+ namespace
104
+ }, "load");
92
105
  queue.push({
93
106
  type: "load",
94
107
  args
95
108
  });
96
- getDeferred(args.namespace).enqueue();
109
+ getDeferred(namespace).enqueue();
97
110
  }
98
111
  function process(args) {
112
+ const { entrypoint: entrypoint$1, path, namespace } = args;
113
+ logger?.debug({
114
+ entrypoint: entrypoint$1,
115
+ path,
116
+ namespace
117
+ }, "process");
99
118
  queue.push({
100
119
  type: "process",
101
120
  args
102
121
  });
103
- getDeferred(args.namespace).enqueue();
122
+ getDeferred(namespace).enqueue();
104
123
  }
105
124
  const build = {
106
125
  context,
@@ -131,13 +150,12 @@ async function run(entrypoint, { config, logger }) {
131
150
  logger?.debug({ plugin: plugin.name }, "setting up plugin");
132
151
  plugin.setup(build);
133
152
  }
134
- const paths = (0, glob.globSync)(entrypoint.entrypoint, { nodir: true });
135
- if (paths.length === 0) resolve({
153
+ const paths = (0, glob.hasMagic)(entrypoint.entrypoint) ? await (0, glob.glob)(entrypoint.entrypoint, { nodir: true }) : [entrypoint.entrypoint];
154
+ logger?.debug({
136
155
  entrypoint: entrypoint.entrypoint,
137
- path: entrypoint.entrypoint,
138
- namespace: "source"
139
- });
140
- else for (const path of paths) resolve({
156
+ paths
157
+ }, "resolved paths");
158
+ for (const path of paths) resolve({
141
159
  entrypoint: path,
142
160
  path,
143
161
  namespace: "source"
@@ -145,9 +163,16 @@ async function run(entrypoint, { config, logger }) {
145
163
  async function processTask(task) {
146
164
  const { type } = task;
147
165
  let args = task.args;
148
- for (const { filter: { filter, namespace }, hook } of hooks[type]) {
149
- if (namespace !== args.namespace) continue;
150
- if (filter && !filter.test(args.path)) continue;
166
+ const { entrypoint: entrypoint$1, path, namespace } = args;
167
+ logger?.trace({
168
+ type,
169
+ entrypoint: entrypoint$1,
170
+ path,
171
+ namespace
172
+ }, "processing task");
173
+ for (const { filter, hook } of hooks[type]) {
174
+ if (filter.namespace !== namespace) continue;
175
+ if (filter.filter && !filter.filter.test(path)) continue;
151
176
  const result = await hook(args);
152
177
  if (result !== void 0) args = result;
153
178
  }
@@ -155,7 +180,7 @@ async function run(entrypoint, { config, logger }) {
155
180
  if (type === "resolve") load(args);
156
181
  else if (type === "load") process(args);
157
182
  }
158
- getDeferred(task.args.namespace).dequeue();
183
+ getDeferred(namespace).dequeue();
159
184
  }
160
185
  while (queue.length || Array.from(pending.values()).some((d) => d.pending > 0)) {
161
186
  while (queue.length) {
@@ -166,7 +191,7 @@ async function run(entrypoint, { config, logger }) {
166
191
  await Promise.all(Array.from(pending.values()).map((d) => d.promise));
167
192
  await Promise.resolve();
168
193
  }
169
- logger?.info({ entrypoint }, "extraction completed");
194
+ logger?.info(entrypoint, "extraction completed");
170
195
  }
171
196
 
172
197
  //#endregion
@@ -1,4 +1,4 @@
1
- import { globSync } from "glob";
1
+ import { glob, hasMagic } from "glob";
2
2
 
3
3
  //#region src/defer.ts
4
4
  var Defer = class {
@@ -33,7 +33,7 @@ async function run(entrypoint, { config, logger }) {
33
33
  generatedAt: /* @__PURE__ */ new Date(),
34
34
  logger
35
35
  };
36
- logger?.info({ entrypoint }, "starting extraction");
36
+ logger?.info(entrypoint, "starting extraction");
37
37
  const resolvers = [];
38
38
  const loaders = [];
39
39
  const processors = [];
@@ -53,30 +53,49 @@ async function run(entrypoint, { config, logger }) {
53
53
  return defer$1;
54
54
  }
55
55
  function defer(namespace) {
56
- const defer$1 = getDeferred(namespace);
57
- return defer$1.promise;
56
+ return getDeferred(namespace).promise;
58
57
  }
59
58
  function resolve(args) {
60
- if (args.path !== args.entrypoint && (!context.config.walk || context.config.exclude.some((ex) => typeof ex === "function" ? ex(args) : ex.test(args.path)))) return;
59
+ const { entrypoint: entrypoint$1, path, namespace } = args;
60
+ const skipped = args.path !== args.entrypoint && !context.config.walk || context.config.exclude.some((ex) => typeof ex === "function" ? ex(args) : ex.test(args.path));
61
+ logger?.debug({
62
+ entrypoint: entrypoint$1,
63
+ path,
64
+ namespace,
65
+ skipped
66
+ }, "resolve");
67
+ if (skipped) return;
61
68
  queue.push({
62
69
  type: "resolve",
63
70
  args
64
71
  });
65
- getDeferred(args.namespace).enqueue();
72
+ getDeferred(namespace).enqueue();
66
73
  }
67
74
  function load(args) {
75
+ const { entrypoint: entrypoint$1, path, namespace } = args;
76
+ logger?.debug({
77
+ entrypoint: entrypoint$1,
78
+ path,
79
+ namespace
80
+ }, "load");
68
81
  queue.push({
69
82
  type: "load",
70
83
  args
71
84
  });
72
- getDeferred(args.namespace).enqueue();
85
+ getDeferred(namespace).enqueue();
73
86
  }
74
87
  function process(args) {
88
+ const { entrypoint: entrypoint$1, path, namespace } = args;
89
+ logger?.debug({
90
+ entrypoint: entrypoint$1,
91
+ path,
92
+ namespace
93
+ }, "process");
75
94
  queue.push({
76
95
  type: "process",
77
96
  args
78
97
  });
79
- getDeferred(args.namespace).enqueue();
98
+ getDeferred(namespace).enqueue();
80
99
  }
81
100
  const build = {
82
101
  context,
@@ -107,13 +126,12 @@ async function run(entrypoint, { config, logger }) {
107
126
  logger?.debug({ plugin: plugin.name }, "setting up plugin");
108
127
  plugin.setup(build);
109
128
  }
110
- const paths = globSync(entrypoint.entrypoint, { nodir: true });
111
- if (paths.length === 0) resolve({
129
+ const paths = hasMagic(entrypoint.entrypoint) ? await glob(entrypoint.entrypoint, { nodir: true }) : [entrypoint.entrypoint];
130
+ logger?.debug({
112
131
  entrypoint: entrypoint.entrypoint,
113
- path: entrypoint.entrypoint,
114
- namespace: "source"
115
- });
116
- else for (const path of paths) resolve({
132
+ paths
133
+ }, "resolved paths");
134
+ for (const path of paths) resolve({
117
135
  entrypoint: path,
118
136
  path,
119
137
  namespace: "source"
@@ -121,9 +139,16 @@ async function run(entrypoint, { config, logger }) {
121
139
  async function processTask(task) {
122
140
  const { type } = task;
123
141
  let args = task.args;
124
- for (const { filter: { filter, namespace }, hook } of hooks[type]) {
125
- if (namespace !== args.namespace) continue;
126
- if (filter && !filter.test(args.path)) continue;
142
+ const { entrypoint: entrypoint$1, path, namespace } = args;
143
+ logger?.trace({
144
+ type,
145
+ entrypoint: entrypoint$1,
146
+ path,
147
+ namespace
148
+ }, "processing task");
149
+ for (const { filter, hook } of hooks[type]) {
150
+ if (filter.namespace !== namespace) continue;
151
+ if (filter.filter && !filter.filter.test(path)) continue;
127
152
  const result = await hook(args);
128
153
  if (result !== void 0) args = result;
129
154
  }
@@ -131,7 +156,7 @@ async function run(entrypoint, { config, logger }) {
131
156
  if (type === "resolve") load(args);
132
157
  else if (type === "load") process(args);
133
158
  }
134
- getDeferred(task.args.namespace).dequeue();
159
+ getDeferred(namespace).dequeue();
135
160
  }
136
161
  while (queue.length || Array.from(pending.values()).some((d) => d.pending > 0)) {
137
162
  while (queue.length) {
@@ -142,9 +167,9 @@ async function run(entrypoint, { config, logger }) {
142
167
  await Promise.all(Array.from(pending.values()).map((d) => d.promise));
143
168
  await Promise.resolve();
144
169
  }
145
- logger?.info({ entrypoint }, "extraction completed");
170
+ logger?.info(entrypoint, "extraction completed");
146
171
  }
147
172
 
148
173
  //#endregion
149
174
  export { run };
150
- //# sourceMappingURL=run-Dl-tr2kf.js.map
175
+ //# sourceMappingURL=run-CQoAsNNE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-CQoAsNNE.js","names":["context: Context","resolvers: { filter: Filter; hook: ResolveHook }[]","loaders: { filter: Filter; hook: LoadHook }[]","processors: { filter: Filter; hook: ProcessHook }[]","queue: Task[]","defer","build: Build"],"sources":["../src/defer.ts","../src/run.ts"],"sourcesContent":["export class Defer {\n pending = 0;\n promise: Promise<void> = Promise.resolve();\n resolve?: () => void;\n\n enqueue() {\n if (this.pending++ === 0) {\n this.promise = new Promise<void>((res) => {\n this.resolve = res;\n });\n }\n }\n dequeue() {\n if (this.pending > 0 && --this.pending === 0) {\n this.resolve?.();\n }\n }\n}\n","import { glob, hasMagic } from \"glob\";\nimport type { ResolvedConfig, ResolvedEntrypoint } from \"./configuration.ts\";\nimport { Defer } from \"./defer.ts\";\nimport type { Logger } from \"./logger.ts\";\nimport type {\n Build,\n Context,\n Filter,\n LoadArgs,\n LoadHook,\n ProcessArgs,\n ProcessHook,\n ResolveArgs,\n ResolveHook,\n} from \"./plugin.ts\";\n\nexport type Task =\n | {\n type: \"resolve\";\n args: ResolveArgs;\n }\n | {\n type: \"load\";\n args: LoadArgs;\n }\n | {\n type: \"process\";\n args: ProcessArgs;\n };\n\nexport async function run(\n entrypoint: ResolvedEntrypoint,\n { config, logger }: { config: ResolvedConfig; logger?: Logger },\n) {\n const destination = entrypoint?.destination ?? config.destination;\n const obsolete = entrypoint?.obsolete ?? config.obsolete;\n const exclude = entrypoint?.exclude ?? config.exclude;\n const walk = entrypoint?.walk ?? config.walk;\n\n const context: Context = {\n config: { ...config, destination, obsolete, exclude, walk },\n generatedAt: new Date(),\n logger,\n };\n\n logger?.info(entrypoint, \"starting extraction\");\n\n const resolvers: { filter: Filter; hook: ResolveHook }[] = [];\n const loaders: { filter: Filter; hook: LoadHook }[] = [];\n const processors: { filter: Filter; hook: ProcessHook }[] = [];\n const hooks = {\n resolve: resolvers,\n load: loaders,\n process: processors,\n };\n\n const pending = new Map<string, Defer>();\n const queue: Task[] = [];\n\n function getDeferred(namespace: string) {\n let defer = pending.get(namespace);\n if (defer === undefined) {\n defer = new Defer();\n pending.set(namespace, defer);\n }\n return defer;\n }\n\n function defer(namespace: string) {\n const defer = getDeferred(namespace);\n return defer.promise;\n }\n\n function resolve(args: ResolveArgs) {\n const { entrypoint, path, namespace } = args;\n const skipped =\n (args.path !== args.entrypoint && !context.config.walk) ||\n context.config.exclude.some((ex) => (typeof ex === \"function\" ? ex(args) : ex.test(args.path)));\n logger?.debug({ entrypoint, path, namespace, skipped }, \"resolve\");\n\n if (skipped) {\n return;\n }\n\n queue.push({ type: \"resolve\", args });\n getDeferred(namespace).enqueue();\n }\n\n function load(args: LoadArgs) {\n const { entrypoint, path, namespace } = args;\n logger?.debug({ entrypoint, path, namespace }, \"load\");\n\n queue.push({ type: \"load\", args });\n getDeferred(namespace).enqueue();\n }\n\n function process(args: ProcessArgs) {\n const { entrypoint, path, namespace } = args;\n logger?.debug({ entrypoint, path, namespace }, \"process\");\n\n queue.push({ type: \"process\", args });\n getDeferred(namespace).enqueue();\n }\n\n const build: Build = {\n context,\n resolve,\n load,\n process,\n defer,\n onResolve(filter, hook) {\n resolvers.push({ filter, hook });\n },\n onLoad(filter, hook) {\n loaders.push({ filter, hook });\n },\n onProcess(filter, hook) {\n processors.push({ filter, hook });\n },\n };\n\n for (const plugin of config.plugins) {\n logger?.debug({ plugin: plugin.name }, \"setting up plugin\");\n plugin.setup(build);\n }\n\n const paths = hasMagic(entrypoint.entrypoint)\n ? await glob(entrypoint.entrypoint, { nodir: true })\n : [entrypoint.entrypoint];\n logger?.debug({ entrypoint: entrypoint.entrypoint, paths }, \"resolved paths\");\n\n for (const path of paths) {\n resolve({ entrypoint: path, path, namespace: \"source\" });\n }\n\n async function processTask(task: Task) {\n const { type } = task;\n let args = task.args;\n const { entrypoint, path, namespace } = args;\n logger?.trace({ type, entrypoint, path, namespace }, \"processing task\");\n\n for (const { filter, hook } of hooks[type]) {\n if (filter.namespace !== namespace) continue;\n if (filter.filter && !filter.filter.test(path)) continue;\n\n const result = await hook(args as never);\n if (result !== undefined) {\n args = result as never;\n }\n }\n\n if (args !== undefined) {\n if (type === \"resolve\") {\n load(args as never);\n } else if (type === \"load\") {\n process(args as never);\n }\n }\n\n getDeferred(namespace).dequeue();\n }\n\n while (queue.length || Array.from(pending.values()).some((d) => d.pending > 0)) {\n while (queue.length) {\n const task = queue.shift();\n if (!task) {\n break;\n }\n\n await processTask(task);\n }\n\n await Promise.all(Array.from(pending.values()).map((d) => d.promise));\n await Promise.resolve();\n }\n\n logger?.info(entrypoint, \"extraction completed\");\n}\n"],"mappings":";;;AAAA,IAAa,QAAb,MAAmB;CACf,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EACjB,IAAI,OAAO,KAAK;EAChB,MAAM,EAAE,0BAAY,MAAM,cAAc;AACxC,UAAQ,MAAM;GAAE;GAAM;GAAY;GAAM;GAAW,EAAE,kBAAkB;AAEvE,OAAK,MAAM,EAAE,QAAQ,UAAU,MAAM,OAAO;AACxC,OAAI,OAAO,cAAc,UAAW;AACpC,OAAI,OAAO,UAAU,CAAC,OAAO,OAAO,KAAK,KAAK,CAAE;GAEhD,MAAM,SAAS,MAAM,KAAK,KAAc;AACxC,OAAI,WAAW,OACX,QAAO;;AAIf,MAAI,SAAS,QACT;OAAI,SAAS,UACT,MAAK,KAAc;YACZ,SAAS,OAChB,SAAQ,KAAc;;AAI9B,cAAY,UAAU,CAAC,SAAS;;AAGpC,QAAO,MAAM,UAAU,MAAM,KAAK,QAAQ,QAAQ,CAAC,CAAC,MAAM,MAAM,EAAE,UAAU,EAAE,EAAE;AAC5E,SAAO,MAAM,QAAQ;GACjB,MAAM,OAAO,MAAM,OAAO;AAC1B,OAAI,CAAC,KACD;AAGJ,SAAM,YAAY,KAAK;;AAG3B,QAAM,QAAQ,IAAI,MAAM,KAAK,QAAQ,QAAQ,CAAC,CAAC,KAAK,MAAM,EAAE,QAAQ,CAAC;AACrE,QAAM,QAAQ,SAAS;;AAG3B,SAAQ,KAAK,YAAY,uBAAuB"}
@@ -1,4 +1,4 @@
1
- const require_run = require('../run-XkKxn8kJ.cjs');
1
+ const require_run = require('../run-BFehT9l8.cjs');
2
2
  let node_path = require("node:path");
3
3
  node_path = require_run.__toESM(node_path);
4
4
  let node_fs_promises = require("node:fs/promises");
@@ -19,6 +19,7 @@ let plural_forms = require("plural-forms");
19
19
  plural_forms = require_run.__toESM(plural_forms);
20
20
 
21
21
  //#region src/plugins/cleanup/cleanup.ts
22
+ const namespace$2 = "cleanup";
22
23
  function cleanup() {
23
24
  return {
24
25
  name: "cleanup",
@@ -27,14 +28,14 @@ function cleanup() {
27
28
  const processedDirs = /* @__PURE__ */ new Set();
28
29
  const generated = /* @__PURE__ */ new Set();
29
30
  build.onResolve({
30
- namespace: "cleanup",
31
+ namespace: namespace$2,
31
32
  filter: /.*/
32
33
  }, (args) => {
33
34
  generated.add(args.path);
34
35
  return args;
35
36
  });
36
37
  build.onProcess({
37
- namespace: "cleanup",
38
+ namespace: namespace$2,
38
39
  filter: /.*/
39
40
  }, async ({ path: path$1 }) => {
40
41
  await build.defer("translate");
@@ -48,14 +49,12 @@ function cleanup() {
48
49
  const contents = await node_fs_promises.default.readFile(full).catch(() => void 0);
49
50
  if (!contents) continue;
50
51
  const parsed = gettext_parser.po.parse(contents);
51
- const hasTranslations = Object.entries(parsed.translations || {}).some(([ctx, msgs]) => Object.keys(msgs).some((id) => !(ctx === "" && id === "")));
52
- if (hasTranslations) build.context.logger?.warn({ path: full }, "stray translation file");
52
+ if (Object.entries(parsed.translations || {}).some(([ctx, msgs]) => Object.keys(msgs).some((id) => !(ctx === "" && id === "")))) build.context.logger?.warn({ path: full }, "stray translation file");
53
53
  else {
54
54
  await node_fs_promises.default.unlink(full);
55
55
  build.context.logger?.info({ path: full }, "removed empty translation file");
56
56
  }
57
57
  }
58
- return void 0;
59
58
  });
60
59
  }
61
60
  };
@@ -65,8 +64,7 @@ function cleanup() {
65
64
  //#region src/plugins/core/queries/comment.ts
66
65
  function getReference(node, { path: path$1 }) {
67
66
  const line = node.startPosition.row + 1;
68
- const rel = (0, node_path.relative)(process.cwd(), path$1).replace(/\\+/g, "/");
69
- return `${rel}:${line}`;
67
+ return `${(0, node_path.relative)(process.cwd(), path$1).replace(/\\+/g, "/")}:${line}`;
70
68
  }
71
69
  function getComment(node) {
72
70
  const text = node.text;
@@ -118,8 +116,7 @@ const importQuery = {
118
116
  ]
119
117
  `,
120
118
  extract(match) {
121
- const node = match.captures.find((c) => c.name === "import")?.node;
122
- return node?.text;
119
+ return (match.captures.find((c) => c.name === "import")?.node)?.text;
123
120
  }
124
121
  };
125
122
 
@@ -161,7 +158,7 @@ const notInPlural = (query) => ({
161
158
  "ngettext",
162
159
  "pgettext",
163
160
  "npgettext"
164
- ].includes(fn.childForFieldName("property")?.text ?? "")) return void 0;
161
+ ].includes(fn.childForFieldName("property")?.text ?? "")) return;
165
162
  }
166
163
  }
167
164
  return result;
@@ -189,7 +186,7 @@ const messageArg = `[
189
186
  const messageArgs = `[ (arguments ${messageArg}) (template_string) @tpl ]`;
190
187
  const extractMessage = (name) => (match) => {
191
188
  const node = match.captures.find((c) => c.name === "call")?.node;
192
- if (!node) return void 0;
189
+ if (!node) return;
193
190
  const msgid = match.captures.find((c) => c.name === "msgid")?.node.text;
194
191
  if (msgid) return {
195
192
  node,
@@ -220,13 +217,12 @@ const extractMessage = (name) => (match) => {
220
217
  const id = match.captures.find((c) => c.name === "id")?.node.text;
221
218
  const message = match.captures.find((c) => c.name === "message")?.node.text;
222
219
  const msgId = id ?? message;
223
- if (!msgId) return void 0;
224
- const msgstr = message ?? id ?? "";
220
+ if (!msgId) return;
225
221
  return {
226
222
  node,
227
223
  translation: {
228
224
  id: msgId,
229
- message: [msgstr]
225
+ message: [message ?? id ?? ""]
230
226
  }
231
227
  };
232
228
  };
@@ -244,8 +240,8 @@ const messageInvalidQuery = notInPlural({
244
240
  extract(match) {
245
241
  const call = match.captures.find((c) => c.name === "call")?.node;
246
242
  const node = match.captures.find((c) => c.name === "arg")?.node;
247
- if (!call || !node) return void 0;
248
- if (allowed$1.has(node.type)) return void 0;
243
+ if (!call || !node) return;
244
+ if (allowed$1.has(node.type)) return;
249
245
  return {
250
246
  node,
251
247
  error: "message() argument must be a string literal, object literal, or template literal"
@@ -258,7 +254,7 @@ const messageInvalidQuery = notInPlural({
258
254
  const extractPluralForms = (name) => (match) => {
259
255
  const call = match.captures.find((c) => c.name === "call")?.node;
260
256
  const n = match.captures.find((c) => c.name === "n")?.node;
261
- if (!call || !n || n.nextNamedSibling) return void 0;
257
+ if (!call || !n || n.nextNamedSibling) return;
262
258
  const msgctxt = match.captures.find((c) => c.name === "msgctxt")?.node?.text;
263
259
  const msgNodes = match.captures.filter((c) => c.name === "msg").map((c) => c.node);
264
260
  const ids = [];
@@ -288,7 +284,7 @@ const extractPluralForms = (name) => (match) => {
288
284
  strs.push(result.translation.message[0] ?? "");
289
285
  }
290
286
  }
291
- if (ids.length === 0) return void 0;
287
+ if (ids.length === 0) return;
292
288
  const translation = {
293
289
  id: ids[0],
294
290
  plural: ids[1],
@@ -349,12 +345,12 @@ const contextInvalidQuery = withComment({
349
345
  pattern: ctxCall,
350
346
  extract(match) {
351
347
  const call = match.captures.find((c) => c.name === "ctx")?.node;
352
- if (!call) return void 0;
348
+ if (!call) return;
353
349
  const parent = call.parent;
354
350
  if (parent && parent.type === "member_expression" && parent.childForFieldName("object")?.id === call.id) {
355
351
  const property = parent.childForFieldName("property")?.text;
356
352
  const grandparent = parent.parent;
357
- if (grandparent && grandparent.type === "call_expression" && grandparent.childForFieldName("function")?.id === parent.id && (property === "message" || property === "plural")) return void 0;
353
+ if (grandparent && grandparent.type === "call_expression" && grandparent.childForFieldName("function")?.id === parent.id && (property === "message" || property === "plural")) return;
358
354
  }
359
355
  return {
360
356
  node: call,
@@ -381,8 +377,8 @@ const gettextInvalidQuery = {
381
377
  extract(match) {
382
378
  const call = match.captures.find((c) => c.name === "call")?.node;
383
379
  const node = match.captures.find((c) => c.name === "arg")?.node;
384
- if (!call || !node) return void 0;
385
- if (allowed.has(node.type)) return void 0;
380
+ if (!call || !node) return;
381
+ if (allowed.has(node.type)) return;
386
382
  return {
387
383
  node,
388
384
  error: "gettext() argument must be a string literal, object literal, or template literal"
@@ -550,7 +546,7 @@ function findTsconfig(dir) {
550
546
  const config = node_path.default.join(current, "tsconfig.json");
551
547
  if (node_fs.default.existsSync(config)) return config;
552
548
  const parent = node_path.default.dirname(current);
553
- if (parent === current) return void 0;
549
+ if (parent === current) return;
554
550
  current = parent;
555
551
  }
556
552
  }
@@ -643,7 +639,6 @@ function core() {
643
639
  namespace: "translate",
644
640
  data: translations
645
641
  });
646
- return void 0;
647
642
  });
648
643
  }
649
644
  };
@@ -789,7 +784,7 @@ function po() {
789
784
  filter: /.*/,
790
785
  namespace
791
786
  }, async ({ entrypoint, path: path$1, data }) => {
792
- if (!data || !Array.isArray(data)) return void 0;
787
+ if (!data || !Array.isArray(data)) return;
793
788
  for (const locale of build.context.config.locales) {
794
789
  const destination = build.context.config.destination({
795
790
  entrypoint,
@@ -811,7 +806,6 @@ function po() {
811
806
  namespace
812
807
  });
813
808
  });
814
- return void 0;
815
809
  });
816
810
  build.onLoad({
817
811
  filter: /.*\.po$/,
@@ -832,7 +826,7 @@ function po() {
832
826
  const collected = collections.get(path$1);
833
827
  if (!collected) {
834
828
  build.context.logger?.warn({ path: path$1 }, "no translations collected for this path");
835
- return void 0;
829
+ return;
836
830
  }
837
831
  const { locale, translations } = collected;
838
832
  const record = collect(translations, locale);
@@ -889,8 +883,7 @@ function resolvePlugins(user) {
889
883
  function defineConfig(config) {
890
884
  const defaultLocale = config.defaultLocale ?? "en";
891
885
  const plugins = resolvePlugins(config.plugins);
892
- const raw = Array.isArray(config.entrypoints) ? config.entrypoints : [config.entrypoints];
893
- const entrypoints = raw.map(resolveEntrypoint);
886
+ const entrypoints = (Array.isArray(config.entrypoints) ? config.entrypoints : [config.entrypoints]).map(resolveEntrypoint);
894
887
  return {
895
888
  plugins,
896
889
  entrypoints,
@@ -945,8 +938,7 @@ function buildTemplate(node) {
945
938
  raw: false
946
939
  });
947
940
  else if (expr.type === "template_string") {
948
- const hasSubstitutions = expr.children.some((c) => c.type === "template_substitution");
949
- if (hasSubstitutions) return {
941
+ if (expr.children.some((c) => c.type === "template_substitution")) return {
950
942
  text: "",
951
943
  error: "JSX expressions with template substitutions are not supported"
952
944
  };
@@ -1017,13 +1009,11 @@ function buildAttrValue(node) {
1017
1009
  if (expr.type === "identifier") return { text: `\${${expr.text}}` };
1018
1010
  else if (expr.type === "string") return { text: expr.text.slice(1, -1) };
1019
1011
  else if (expr.type === "template_string") {
1020
- const hasSubstitutions = expr.children.some((c) => c.type === "template_substitution");
1021
- if (hasSubstitutions) return {
1012
+ if (expr.children.some((c) => c.type === "template_substitution")) return {
1022
1013
  text: "",
1023
1014
  error: "JSX expressions with template substitutions are not supported"
1024
1015
  };
1025
- const content = expr.text.slice(1, -1);
1026
- return { text: content };
1016
+ return { text: expr.text.slice(1, -1) };
1027
1017
  } else return {
1028
1018
  text: "",
1029
1019
  error: "JSX expressions must be simple identifiers, strings, or template literals"
@@ -1213,22 +1203,22 @@ function react() {
1213
1203
  build.onResolve({
1214
1204
  filter: /.*/,
1215
1205
  namespace: "source"
1216
- }, ({ entrypoint, path: path$1, namespace: namespace$2 }) => {
1206
+ }, ({ entrypoint, path: path$1, namespace: namespace$3 }) => {
1217
1207
  return {
1218
1208
  entrypoint,
1219
- namespace: namespace$2,
1209
+ namespace: namespace$3,
1220
1210
  path: (0, node_path.resolve)(path$1)
1221
1211
  };
1222
1212
  });
1223
1213
  build.onLoad({
1224
1214
  filter,
1225
1215
  namespace: "source"
1226
- }, async ({ entrypoint, path: path$1, namespace: namespace$2 }) => {
1216
+ }, async ({ entrypoint, path: path$1, namespace: namespace$3 }) => {
1227
1217
  const data = await (0, node_fs_promises.readFile)(path$1, "utf8");
1228
1218
  return {
1229
1219
  entrypoint,
1230
1220
  path: path$1,
1231
- namespace: namespace$2,
1221
+ namespace: namespace$3,
1232
1222
  data
1233
1223
  };
1234
1224
  });
@@ -1244,7 +1234,6 @@ function react() {
1244
1234
  namespace: "translate",
1245
1235
  data: translations
1246
1236
  });
1247
- return void 0;
1248
1237
  });
1249
1238
  }
1250
1239
  };