@let-value/translate-extract 1.1.5-beta.3 → 1.1.6-beta.3
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 +40 -28
- package/dist/bin/{cli.js → cli.mjs} +39 -23
- package/dist/bin/cli.mjs.map +1 -0
- package/dist/{configuration-CTy0NMkD.d.cts → configuration-BVNh7M_I.d.cts} +33 -12
- package/dist/configuration-BVNh7M_I.d.cts.map +1 -0
- package/dist/{configuration-fs9HmV_j.d.ts → configuration-oHJyypq5.d.mts} +34 -12
- package/dist/configuration-oHJyypq5.d.mts.map +1 -0
- package/dist/exclude-CpTGSisK.mjs +21 -0
- package/dist/exclude-CpTGSisK.mjs.map +1 -0
- package/dist/exclude-CzNSDMG-.cjs +36 -0
- package/dist/{run-BosrCYRL.js → run-Bv3fv1N8.mjs} +227 -214
- package/dist/run-Bv3fv1N8.mjs.map +1 -0
- package/dist/{run-BZ-O4Oh0.cjs → run-oGs6tkeL.cjs} +291 -255
- package/dist/src/core.cjs +55 -4
- package/dist/src/core.d.cts +2 -3
- package/dist/src/core.d.mts +2 -0
- package/dist/{core-DR3oxhSq.js → src/core.mjs} +12 -15
- package/dist/src/core.mjs.map +1 -0
- package/dist/src/index.cjs +5 -6
- package/dist/src/index.d.cts +2 -4
- package/dist/src/index.d.cts.map +1 -1
- package/dist/src/index.d.mts +22 -0
- package/dist/src/index.d.mts.map +1 -0
- package/dist/src/index.mjs +3 -0
- package/dist/src/static.cjs +31 -6
- package/dist/src/static.d.cts +1 -1
- package/dist/src/static.d.mts +2 -0
- package/dist/{static-DQHT7uqP.js → src/static.mjs} +2 -2
- package/dist/src/static.mjs.map +1 -0
- package/package.json +62 -61
- package/dist/bin/cli.js.map +0 -1
- package/dist/chunk-CUT6urMc.cjs +0 -30
- package/dist/configuration-CTy0NMkD.d.cts.map +0 -1
- package/dist/configuration-fs9HmV_j.d.ts.map +0 -1
- package/dist/core-ACuLoi2B.d.ts +0 -1
- package/dist/core-CHb_Xdzl.cjs +0 -65
- package/dist/core-CPg6_re5.d.cts +0 -1
- package/dist/core-DR3oxhSq.js.map +0 -1
- package/dist/run-BosrCYRL.js.map +0 -1
- package/dist/src/core.d.ts +0 -3
- package/dist/src/core.js +0 -4
- package/dist/src/index.d.ts +0 -24
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -5
- package/dist/src/static.d.ts +0 -2
- package/dist/src/static.js +0 -3
- package/dist/static-CNiWpXhx.cjs +0 -52
- package/dist/static-DQHT7uqP.js.map +0 -1
- /package/dist/bin/{cli.d.ts → cli.d.mts} +0 -0
|
@@ -1,31 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { r as isExcluded } from "./exclude-CpTGSisK.mjs";
|
|
2
|
+
import { builtinModules } from "node:module";
|
|
2
3
|
import path, { dirname, extname, join, relative, resolve } from "node:path";
|
|
3
|
-
import glob from "fast-glob";
|
|
4
4
|
import fs, { readFile } from "node:fs/promises";
|
|
5
5
|
import * as gettextParser from "gettext-parser";
|
|
6
|
-
import fs$1 from "node:fs";
|
|
6
|
+
import fs$1, { realpathSync } from "node:fs";
|
|
7
7
|
import Parser from "@keqingmoe/tree-sitter";
|
|
8
8
|
import JavaScript from "tree-sitter-javascript";
|
|
9
9
|
import TS from "tree-sitter-typescript";
|
|
10
10
|
import { ResolverFactory } from "oxc-resolver";
|
|
11
11
|
import { getFormula, getNPlurals } from "plural-forms";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var Defer = class {
|
|
15
|
-
pending = 0;
|
|
16
|
-
promise = Promise.resolve();
|
|
17
|
-
resolve;
|
|
18
|
-
enqueue() {
|
|
19
|
-
if (this.pending++ === 0) this.promise = new Promise((res) => {
|
|
20
|
-
this.resolve = res;
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
dequeue() {
|
|
24
|
-
if (this.pending > 0 && --this.pending === 0) this.resolve?.();
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
//#endregion
|
|
12
|
+
import { isDeepStrictEqual } from "node:util";
|
|
13
|
+
import glob from "fast-glob";
|
|
29
14
|
//#region src/plugins/cleanup/cleanup.ts
|
|
30
15
|
const namespace$2 = "cleanup";
|
|
31
16
|
function cleanup() {
|
|
@@ -40,9 +25,9 @@ function cleanup() {
|
|
|
40
25
|
build.onResolve({
|
|
41
26
|
namespace: namespace$2,
|
|
42
27
|
filter: /.*/
|
|
43
|
-
}, ({ path
|
|
44
|
-
generated.add(path
|
|
45
|
-
dirs.add(dirname(path
|
|
28
|
+
}, ({ path }) => {
|
|
29
|
+
generated.add(path);
|
|
30
|
+
dirs.add(dirname(path));
|
|
46
31
|
Promise.all([
|
|
47
32
|
build.defer("source"),
|
|
48
33
|
build.defer("translate"),
|
|
@@ -50,9 +35,9 @@ function cleanup() {
|
|
|
50
35
|
]).then(() => {
|
|
51
36
|
if (dispatched) return;
|
|
52
37
|
dispatched = true;
|
|
53
|
-
for (const path
|
|
54
|
-
entrypoint: path
|
|
55
|
-
path
|
|
38
|
+
for (const path of dirs.values()) build.process({
|
|
39
|
+
entrypoint: path,
|
|
40
|
+
path,
|
|
56
41
|
namespace: namespace$2,
|
|
57
42
|
data: void 0
|
|
58
43
|
});
|
|
@@ -61,12 +46,12 @@ function cleanup() {
|
|
|
61
46
|
build.onProcess({
|
|
62
47
|
namespace: namespace$2,
|
|
63
48
|
filter: /.*/
|
|
64
|
-
}, async ({ path
|
|
65
|
-
if (processed.has(path
|
|
66
|
-
processed.add(path
|
|
67
|
-
const files = await fs.readdir(path
|
|
49
|
+
}, async ({ path }) => {
|
|
50
|
+
if (processed.has(path)) return;
|
|
51
|
+
processed.add(path);
|
|
52
|
+
const files = await fs.readdir(path).catch(() => []);
|
|
68
53
|
for (const f of files.filter((p) => p.endsWith(".po"))) {
|
|
69
|
-
const full = join(path
|
|
54
|
+
const full = join(path, f);
|
|
70
55
|
const contents = await fs.readFile(full).catch(() => void 0);
|
|
71
56
|
if (!contents) continue;
|
|
72
57
|
const parsed = gettextParser.po.parse(contents);
|
|
@@ -78,12 +63,11 @@ function cleanup() {
|
|
|
78
63
|
}
|
|
79
64
|
};
|
|
80
65
|
}
|
|
81
|
-
|
|
82
66
|
//#endregion
|
|
83
67
|
//#region src/plugins/core/queries/comment.ts
|
|
84
|
-
function getReference(node, { path
|
|
68
|
+
function getReference(node, { path }) {
|
|
85
69
|
const line = node.startPosition.row + 1;
|
|
86
|
-
return `${relative(process.cwd(), path
|
|
70
|
+
return `${relative(process.cwd(), path).replace(/\\+/g, "/")}:${line}`;
|
|
87
71
|
}
|
|
88
72
|
function getComment(node) {
|
|
89
73
|
const text = node.text;
|
|
@@ -108,7 +92,6 @@ const withComment = (query) => ({
|
|
|
108
92
|
return result;
|
|
109
93
|
}
|
|
110
94
|
});
|
|
111
|
-
|
|
112
95
|
//#endregion
|
|
113
96
|
//#region src/plugins/core/queries/entrypoint.ts
|
|
114
97
|
const entrypointCommentPattern = /(?:^|\s)@?translate-entrypoint(?:\s|$)/;
|
|
@@ -118,9 +101,20 @@ const entrypointQuery = {
|
|
|
118
101
|
return match.captures.filter((capture) => capture.name === "comment").some((capture) => entrypointCommentPattern.test(getComment(capture.node)));
|
|
119
102
|
}
|
|
120
103
|
};
|
|
121
|
-
|
|
122
104
|
//#endregion
|
|
123
105
|
//#region src/plugins/core/queries/import.ts
|
|
106
|
+
function findImportParent(node) {
|
|
107
|
+
let current = node;
|
|
108
|
+
while (current) {
|
|
109
|
+
if (current.type === "import_statement" || current.type === "export_statement" || current.type === "call_expression") return current;
|
|
110
|
+
current = current.parent;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function isTypeOnly(parent) {
|
|
114
|
+
if (!parent) return false;
|
|
115
|
+
const text = parent.text.trimStart();
|
|
116
|
+
return /^import\s+type\b/.test(text) || /^export\s+type\b/.test(text) || /^export\s*{\s*type\b[^}]*}\s*from\b/.test(text);
|
|
117
|
+
}
|
|
124
118
|
const importQuery = {
|
|
125
119
|
pattern: `
|
|
126
120
|
[
|
|
@@ -140,15 +134,21 @@ const importQuery = {
|
|
|
140
134
|
(#eq? @obj "require")
|
|
141
135
|
(#eq? @method "resolve"))
|
|
142
136
|
(call_expression
|
|
143
|
-
function: (import)
|
|
137
|
+
function: (import) @dynamic
|
|
144
138
|
arguments: (arguments (string (string_fragment) @import)))
|
|
145
139
|
]
|
|
146
140
|
`,
|
|
147
141
|
extract(match) {
|
|
148
|
-
|
|
142
|
+
const node = match.captures.find((c) => c.name === "import")?.node;
|
|
143
|
+
if (!node) return;
|
|
144
|
+
const parent = findImportParent(node);
|
|
145
|
+
return {
|
|
146
|
+
spec: node.text,
|
|
147
|
+
kind: match.captures.some((c) => c.name === "dynamic") ? "dynamic" : "static",
|
|
148
|
+
typeOnly: isTypeOnly(parent)
|
|
149
|
+
};
|
|
149
150
|
}
|
|
150
151
|
};
|
|
151
|
-
|
|
152
152
|
//#endregion
|
|
153
153
|
//#region src/plugins/core/queries/utils.ts
|
|
154
154
|
const callPattern = (fnName, args, allowMember = true) => `(
|
|
@@ -169,7 +169,6 @@ function isDescendant(node, ancestor) {
|
|
|
169
169
|
}
|
|
170
170
|
return false;
|
|
171
171
|
}
|
|
172
|
-
|
|
173
172
|
//#endregion
|
|
174
173
|
//#region src/plugins/core/queries/message.ts
|
|
175
174
|
const notInPlural = (query) => ({
|
|
@@ -277,7 +276,6 @@ const messageInvalidQuery = notInPlural({
|
|
|
277
276
|
};
|
|
278
277
|
}
|
|
279
278
|
});
|
|
280
|
-
|
|
281
279
|
//#endregion
|
|
282
280
|
//#region src/plugins/core/queries/plural-utils.ts
|
|
283
281
|
const extractPluralForms = (name) => (match) => {
|
|
@@ -325,7 +323,6 @@ const extractPluralForms = (name) => (match) => {
|
|
|
325
323
|
translation
|
|
326
324
|
};
|
|
327
325
|
};
|
|
328
|
-
|
|
329
326
|
//#endregion
|
|
330
327
|
//#region src/plugins/core/queries/context.ts
|
|
331
328
|
const ctxCall = callPattern("context", `[
|
|
@@ -365,7 +362,6 @@ const contextMsgQuery = withComment({
|
|
|
365
362
|
};
|
|
366
363
|
}
|
|
367
364
|
});
|
|
368
|
-
const msgCall$3 = callPattern("message", messageArgs, false).replace(/@call/g, "@msg").replace(/@func/g, "@msgfn");
|
|
369
365
|
const contextPluralQuery = withComment({
|
|
370
366
|
pattern: `(
|
|
371
367
|
(call_expression
|
|
@@ -374,7 +370,7 @@ const contextPluralQuery = withComment({
|
|
|
374
370
|
property: (property_identifier) @func
|
|
375
371
|
)
|
|
376
372
|
arguments: (arguments (
|
|
377
|
-
(${
|
|
373
|
+
(${callPattern("message", messageArgs, false).replace(/@call/g, "@msg").replace(/@func/g, "@msgfn")} ("," )?)+
|
|
378
374
|
(number) @n
|
|
379
375
|
))
|
|
380
376
|
) @call
|
|
@@ -399,7 +395,6 @@ const contextInvalidQuery = withComment({
|
|
|
399
395
|
};
|
|
400
396
|
}
|
|
401
397
|
});
|
|
402
|
-
|
|
403
398
|
//#endregion
|
|
404
399
|
//#region src/plugins/core/queries/gettext.ts
|
|
405
400
|
const gettextQuery = withComment({
|
|
@@ -426,27 +421,20 @@ const gettextInvalidQuery = {
|
|
|
426
421
|
};
|
|
427
422
|
}
|
|
428
423
|
};
|
|
429
|
-
|
|
430
424
|
//#endregion
|
|
431
425
|
//#region src/plugins/core/queries/ngettext.ts
|
|
432
|
-
const
|
|
433
|
-
const plainMsg$1 = `(${messageArg}) @msg`;
|
|
434
|
-
const msgArg$1 = `[${msgCall$2} ${plainMsg$1}]`;
|
|
426
|
+
const msgArg$1 = `[${callPattern("message", messageArgs).replace(/@call/g, "@msg").replace(/@func/g, "@msgfn")} ${`(${messageArg}) @msg`}]`;
|
|
435
427
|
const ngettextQuery = withComment({
|
|
436
428
|
pattern: callPattern("ngettext", `(arguments ${msgArg$1} "," ${msgArg$1} ("," ${msgArg$1})* "," (_) @n)`),
|
|
437
429
|
extract: extractPluralForms("ngettext")
|
|
438
430
|
});
|
|
439
|
-
|
|
440
431
|
//#endregion
|
|
441
432
|
//#region src/plugins/core/queries/npgettext.ts
|
|
442
|
-
const
|
|
443
|
-
const plainMsg = `(${messageArg}) @msg`;
|
|
444
|
-
const msgArg = `[${msgCall$1} ${plainMsg}]`;
|
|
433
|
+
const msgArg = `[${callPattern("message", messageArgs).replace(/@call/g, "@msg").replace(/@func/g, "@msgfn")} ${`(${messageArg}) @msg`}]`;
|
|
445
434
|
const npgettextQuery = withComment({
|
|
446
435
|
pattern: callPattern("npgettext", `(arguments (string (string_fragment) @msgctxt) "," ${msgArg} "," ${msgArg} ("," ${msgArg})* "," (_) @n)`),
|
|
447
436
|
extract: extractPluralForms("npgettext")
|
|
448
437
|
});
|
|
449
|
-
|
|
450
438
|
//#endregion
|
|
451
439
|
//#region src/plugins/core/queries/pgettext.ts
|
|
452
440
|
const pgettextQuery = withComment({
|
|
@@ -464,18 +452,6 @@ const pgettextQuery = withComment({
|
|
|
464
452
|
};
|
|
465
453
|
}
|
|
466
454
|
});
|
|
467
|
-
|
|
468
|
-
//#endregion
|
|
469
|
-
//#region src/plugins/core/queries/plural.ts
|
|
470
|
-
const msgCall = callPattern("message", messageArgs, false).replace(/@call/g, "@msg").replace(/@func/g, "@msgfn");
|
|
471
|
-
const pluralQuery$1 = withComment({
|
|
472
|
-
pattern: callPattern("plural", `(arguments (
|
|
473
|
-
(${msgCall} ("," )?)+
|
|
474
|
-
(number) @n
|
|
475
|
-
))`, false),
|
|
476
|
-
extract: extractPluralForms("plural")
|
|
477
|
-
});
|
|
478
|
-
|
|
479
455
|
//#endregion
|
|
480
456
|
//#region src/plugins/core/queries/index.ts
|
|
481
457
|
const queries$1 = [
|
|
@@ -486,12 +462,17 @@ const queries$1 = [
|
|
|
486
462
|
messageInvalidQuery,
|
|
487
463
|
gettextQuery,
|
|
488
464
|
gettextInvalidQuery,
|
|
489
|
-
|
|
465
|
+
withComment({
|
|
466
|
+
pattern: callPattern("plural", `(arguments (
|
|
467
|
+
(${callPattern("message", messageArgs, false).replace(/@call/g, "@msg").replace(/@func/g, "@msgfn")} ("," )?)+
|
|
468
|
+
(number) @n
|
|
469
|
+
))`, false),
|
|
470
|
+
extract: extractPluralForms("plural")
|
|
471
|
+
}),
|
|
490
472
|
ngettextQuery,
|
|
491
473
|
pgettextQuery,
|
|
492
474
|
npgettextQuery
|
|
493
475
|
];
|
|
494
|
-
|
|
495
476
|
//#endregion
|
|
496
477
|
//#region src/plugins/core/parse.ts
|
|
497
478
|
function getLanguage(ext) {
|
|
@@ -530,16 +511,15 @@ function getCachedQuery(language, pattern) {
|
|
|
530
511
|
}
|
|
531
512
|
return query;
|
|
532
513
|
}
|
|
533
|
-
function getParser(path
|
|
534
|
-
|
|
535
|
-
return getCachedParser(ext);
|
|
514
|
+
function getParser(path) {
|
|
515
|
+
return getCachedParser(extname(path));
|
|
536
516
|
}
|
|
537
517
|
function getQuery(language, pattern) {
|
|
538
518
|
return getCachedQuery(language, pattern);
|
|
539
519
|
}
|
|
540
|
-
function parseSource$1(source, path
|
|
541
|
-
const context = { path
|
|
542
|
-
const { parser, language } = getParser(path
|
|
520
|
+
function parseSource$1(source, path) {
|
|
521
|
+
const context = { path };
|
|
522
|
+
const { parser, language } = getParser(path);
|
|
543
523
|
const tree = parser.parse(source);
|
|
544
524
|
const entrypoint = getCachedQuery(language, entrypointQuery.pattern).matches(tree.rootNode).some(entrypointQuery.extract);
|
|
545
525
|
const translations = [];
|
|
@@ -580,7 +560,6 @@ function parseSource$1(source, path$1) {
|
|
|
580
560
|
entrypoint
|
|
581
561
|
};
|
|
582
562
|
}
|
|
583
|
-
|
|
584
563
|
//#endregion
|
|
585
564
|
//#region src/plugins/core/resolve.ts
|
|
586
565
|
function findTsconfig(dir) {
|
|
@@ -594,6 +573,12 @@ function findTsconfig(dir) {
|
|
|
594
573
|
}
|
|
595
574
|
}
|
|
596
575
|
const resolverCache = /* @__PURE__ */ new Map();
|
|
576
|
+
const builtins = new Set([...builtinModules, ...builtinModules.map((name) => `node:${name}`)]);
|
|
577
|
+
function isBuiltin(spec) {
|
|
578
|
+
if (builtins.has(spec)) return true;
|
|
579
|
+
const [base, subpath] = (spec.startsWith("node:") ? spec.slice(5) : spec).split("/", 2);
|
|
580
|
+
return subpath !== void 0 && builtins.has(base);
|
|
581
|
+
}
|
|
597
582
|
function getResolver(dir) {
|
|
598
583
|
const tsconfig = findTsconfig(dir);
|
|
599
584
|
const key = tsconfig ?? "__default__";
|
|
@@ -620,30 +605,48 @@ function getResolver(dir) {
|
|
|
620
605
|
}
|
|
621
606
|
return resolver;
|
|
622
607
|
}
|
|
608
|
+
function normalizeImportReference(imp) {
|
|
609
|
+
if (typeof imp === "string") return {
|
|
610
|
+
spec: imp,
|
|
611
|
+
kind: "static",
|
|
612
|
+
typeOnly: false
|
|
613
|
+
};
|
|
614
|
+
return imp;
|
|
615
|
+
}
|
|
623
616
|
function resolveImportResults(file, imports) {
|
|
624
617
|
const dir = path.dirname(path.resolve(file));
|
|
625
618
|
const resolver = getResolver(dir);
|
|
626
619
|
const resolved = [];
|
|
627
620
|
const unresolved = [];
|
|
628
|
-
for (const
|
|
629
|
-
const
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
621
|
+
for (const imp of imports) {
|
|
622
|
+
const ref = normalizeImportReference(imp);
|
|
623
|
+
const { spec } = ref;
|
|
624
|
+
if (isBuiltin(spec)) continue;
|
|
625
|
+
try {
|
|
626
|
+
const res = resolver.sync(dir, spec);
|
|
627
|
+
if (res.path) resolved.push({
|
|
628
|
+
path: res.path,
|
|
629
|
+
import: {
|
|
630
|
+
...ref,
|
|
631
|
+
spec: res.path
|
|
632
|
+
}
|
|
633
|
+
});
|
|
634
|
+
else unresolved.push({
|
|
635
|
+
spec,
|
|
636
|
+
error: res.error
|
|
637
|
+
});
|
|
638
|
+
} catch (error) {
|
|
639
|
+
unresolved.push({
|
|
640
|
+
spec,
|
|
641
|
+
error: error instanceof Error ? error.message : String(error)
|
|
642
|
+
});
|
|
643
|
+
}
|
|
640
644
|
}
|
|
641
645
|
return {
|
|
642
646
|
resolved,
|
|
643
647
|
unresolved
|
|
644
648
|
};
|
|
645
649
|
}
|
|
646
|
-
|
|
647
650
|
//#endregion
|
|
648
651
|
//#region src/plugins/core/core.ts
|
|
649
652
|
const filter$1 = /\.([cm]?tsx?|jsx?)$/;
|
|
@@ -656,56 +659,67 @@ function core() {
|
|
|
656
659
|
build.onResolve({
|
|
657
660
|
filter: filter$1,
|
|
658
661
|
namespace: namespace$1
|
|
659
|
-
}, ({ entrypoint, path:
|
|
662
|
+
}, ({ entrypoint, path, import: imp, data }) => {
|
|
660
663
|
return {
|
|
661
664
|
entrypoint,
|
|
662
665
|
namespace: namespace$1,
|
|
663
|
-
path: resolve(path
|
|
666
|
+
path: resolve(path),
|
|
667
|
+
import: imp,
|
|
668
|
+
data
|
|
664
669
|
};
|
|
665
670
|
});
|
|
666
671
|
build.onLoad({
|
|
667
672
|
filter: filter$1,
|
|
668
673
|
namespace: namespace$1
|
|
669
|
-
}, async ({ entrypoint, path
|
|
670
|
-
const data = await readFile(path$1, "utf8");
|
|
674
|
+
}, async ({ entrypoint, path }) => {
|
|
671
675
|
return {
|
|
672
676
|
entrypoint,
|
|
673
|
-
path
|
|
677
|
+
path,
|
|
674
678
|
namespace: namespace$1,
|
|
675
|
-
data
|
|
679
|
+
data: await readFile(path, "utf8")
|
|
676
680
|
};
|
|
677
681
|
});
|
|
678
682
|
build.onProcess({
|
|
679
683
|
filter: filter$1,
|
|
680
684
|
namespace: namespace$1
|
|
681
|
-
}, ({ entrypoint, path
|
|
682
|
-
const result = parseSource$1(data, path
|
|
683
|
-
if (result.entrypoint && entrypoint !== path
|
|
684
|
-
build.source(path
|
|
685
|
+
}, ({ entrypoint, path, data }) => {
|
|
686
|
+
const result = parseSource$1(data, path);
|
|
687
|
+
if (result.entrypoint && entrypoint !== path) {
|
|
688
|
+
build.source(path);
|
|
685
689
|
return {
|
|
686
690
|
entrypoint,
|
|
687
|
-
path
|
|
691
|
+
path,
|
|
688
692
|
namespace: namespace$1,
|
|
689
693
|
data: []
|
|
690
694
|
};
|
|
691
695
|
}
|
|
692
696
|
const { translations, imports, warnings } = result;
|
|
693
697
|
if (build.context.config.walk) {
|
|
694
|
-
const { resolved
|
|
695
|
-
for (const
|
|
696
|
-
if (build.context.paths.has(path
|
|
698
|
+
const { resolved, unresolved } = resolveImportResults(path, imports);
|
|
699
|
+
for (const result of resolved) {
|
|
700
|
+
if (build.context.paths.has(result.path)) continue;
|
|
697
701
|
build.resolve({
|
|
698
702
|
entrypoint,
|
|
699
|
-
path: path
|
|
700
|
-
namespace: namespace$1
|
|
703
|
+
path: result.path,
|
|
704
|
+
namespace: namespace$1,
|
|
705
|
+
import: result.import
|
|
701
706
|
});
|
|
702
707
|
}
|
|
703
|
-
for (const { spec, error } of unresolved)
|
|
708
|
+
for (const { spec, error } of unresolved) {
|
|
709
|
+
const imp = imports.find((imp) => imp.spec === spec);
|
|
710
|
+
if (imp && isExcluded({
|
|
711
|
+
entrypoint,
|
|
712
|
+
path: spec,
|
|
713
|
+
namespace: namespace$1,
|
|
714
|
+
import: imp
|
|
715
|
+
}, build.context.config.exclude)) continue;
|
|
716
|
+
build.context.logger?.warn(`Unable to resolve import "${spec}" from ${path}${error ? `: ${error}` : ""}`);
|
|
717
|
+
}
|
|
704
718
|
}
|
|
705
719
|
for (const warning of warnings) build.context.logger?.warn(`${warning.error} at ${warning.reference}`);
|
|
706
720
|
build.resolve({
|
|
707
721
|
entrypoint,
|
|
708
|
-
path
|
|
722
|
+
path,
|
|
709
723
|
namespace: "translate",
|
|
710
724
|
data: translations
|
|
711
725
|
});
|
|
@@ -713,7 +727,6 @@ function core() {
|
|
|
713
727
|
}
|
|
714
728
|
};
|
|
715
729
|
}
|
|
716
|
-
|
|
717
730
|
//#endregion
|
|
718
731
|
//#region src/plugins/po/collect.ts
|
|
719
732
|
function collect(source, locale) {
|
|
@@ -748,7 +761,6 @@ function collect(source, locale) {
|
|
|
748
761
|
}
|
|
749
762
|
return translations;
|
|
750
763
|
}
|
|
751
|
-
|
|
752
764
|
//#endregion
|
|
753
765
|
//#region src/plugins/po/hasChanges.ts
|
|
754
766
|
const IGNORED_HEADER_KEYS = new Set(["pot-creation-date", "po-revision-date"]);
|
|
@@ -762,9 +774,7 @@ function normalizeHeaderString(value) {
|
|
|
762
774
|
}).map((line) => {
|
|
763
775
|
const separatorIndex = line.indexOf(":");
|
|
764
776
|
if (separatorIndex === -1) return line;
|
|
765
|
-
|
|
766
|
-
const value$1 = line.slice(separatorIndex + 1);
|
|
767
|
-
return `${key}:${value$1}`;
|
|
777
|
+
return `${line.slice(0, separatorIndex).trim().toLowerCase()}:${line.slice(separatorIndex + 1)}`;
|
|
768
778
|
});
|
|
769
779
|
if (hadTrailingNewline && filtered[filtered.length - 1] !== "") filtered.push("");
|
|
770
780
|
return filtered.join("\n");
|
|
@@ -783,11 +793,8 @@ function normalize(translations) {
|
|
|
783
793
|
}
|
|
784
794
|
function hasChanges(left, right) {
|
|
785
795
|
if (!right) return true;
|
|
786
|
-
|
|
787
|
-
const normalizedRight = normalize(right);
|
|
788
|
-
return !isDeepStrictEqual(normalizedLeft, normalizedRight);
|
|
796
|
+
return !isDeepStrictEqual(normalize(left), normalize(right));
|
|
789
797
|
}
|
|
790
|
-
|
|
791
798
|
//#endregion
|
|
792
799
|
//#region src/plugins/po/merge.ts
|
|
793
800
|
function formatDate(date) {
|
|
@@ -798,10 +805,7 @@ function formatDate(date) {
|
|
|
798
805
|
const hours = pad(date.getHours());
|
|
799
806
|
const minutes = pad(date.getMinutes());
|
|
800
807
|
const tzo = -date.getTimezoneOffset();
|
|
801
|
-
|
|
802
|
-
const offsetHours = pad(Math.floor(Math.abs(tzo) / 60));
|
|
803
|
-
const offsetMinutes = pad(Math.abs(tzo) % 60);
|
|
804
|
-
return `${year}-${month}-${day} ${hours}:${minutes}${sign}${offsetHours}${offsetMinutes}`;
|
|
808
|
+
return `${year}-${month}-${day} ${hours}:${minutes}${tzo >= 0 ? "+" : "-"}${pad(Math.floor(Math.abs(tzo) / 60))}${pad(Math.abs(tzo) % 60)}`;
|
|
805
809
|
}
|
|
806
810
|
function merge(sources, existing, obsolete, locale, generatedAt) {
|
|
807
811
|
let headers = {};
|
|
@@ -818,22 +822,22 @@ function merge(sources, existing, obsolete, locale, generatedAt) {
|
|
|
818
822
|
}
|
|
819
823
|
}
|
|
820
824
|
const collected = { "": {} };
|
|
821
|
-
for (const { translations
|
|
825
|
+
for (const { translations } of sources) for (const [ctx, msgs] of Object.entries(translations)) {
|
|
822
826
|
if (!collected[ctx]) collected[ctx] = {};
|
|
823
827
|
for (const [id, entry] of Object.entries(msgs)) {
|
|
824
|
-
const existing
|
|
828
|
+
const existing = collected[ctx][id];
|
|
825
829
|
const refs = /* @__PURE__ */ new Set();
|
|
826
|
-
if (existing
|
|
830
|
+
if (existing?.comments?.reference) existing.comments.reference.split(/\r?\n|\r/).forEach((r) => {
|
|
827
831
|
refs.add(r);
|
|
828
832
|
});
|
|
829
833
|
if (entry.comments?.reference) entry.comments.reference.split(/\r?\n|\r/).forEach((r) => {
|
|
830
834
|
refs.add(r);
|
|
831
835
|
});
|
|
832
836
|
collected[ctx][id] = {
|
|
833
|
-
...existing
|
|
837
|
+
...existing,
|
|
834
838
|
...entry,
|
|
835
839
|
comments: {
|
|
836
|
-
...existing
|
|
840
|
+
...existing?.comments,
|
|
837
841
|
...entry.comments,
|
|
838
842
|
reference: refs.size ? Array.from(refs).join("\n") : void 0
|
|
839
843
|
}
|
|
@@ -884,7 +888,6 @@ function merge(sources, existing, obsolete, locale, generatedAt) {
|
|
|
884
888
|
...obsolete === "mark" && Object.keys(obsoleteTranslations).length ? { obsolete: obsoleteTranslations } : {}
|
|
885
889
|
};
|
|
886
890
|
}
|
|
887
|
-
|
|
888
891
|
//#endregion
|
|
889
892
|
//#region src/plugins/po/po.ts
|
|
890
893
|
const namespace = "translate";
|
|
@@ -898,13 +901,13 @@ function po() {
|
|
|
898
901
|
build.onResolve({
|
|
899
902
|
filter: /.*/,
|
|
900
903
|
namespace
|
|
901
|
-
}, async ({ entrypoint, path
|
|
904
|
+
}, async ({ entrypoint, path, data }) => {
|
|
902
905
|
if (!data || !Array.isArray(data)) return;
|
|
903
906
|
for (const locale of build.context.config.locales) {
|
|
904
907
|
const destination = build.context.config.destination({
|
|
905
908
|
entrypoint,
|
|
906
909
|
locale,
|
|
907
|
-
path
|
|
910
|
+
path
|
|
908
911
|
});
|
|
909
912
|
if (!collections.has(destination)) collections.set(destination, {
|
|
910
913
|
locale,
|
|
@@ -915,9 +918,9 @@ function po() {
|
|
|
915
918
|
Promise.all([build.defer("source"), build.defer(namespace)]).then(() => {
|
|
916
919
|
if (dispatched) return;
|
|
917
920
|
dispatched = true;
|
|
918
|
-
for (const path
|
|
921
|
+
for (const path of collections.keys()) build.load({
|
|
919
922
|
entrypoint,
|
|
920
|
-
path
|
|
923
|
+
path,
|
|
921
924
|
namespace
|
|
922
925
|
});
|
|
923
926
|
});
|
|
@@ -925,35 +928,33 @@ function po() {
|
|
|
925
928
|
build.onLoad({
|
|
926
929
|
filter: /.*\.po$/,
|
|
927
930
|
namespace
|
|
928
|
-
}, async ({ entrypoint, path
|
|
929
|
-
const contents = await fs.readFile(path
|
|
930
|
-
const data = contents ? gettextParser.po.parse(contents) : void 0;
|
|
931
|
+
}, async ({ entrypoint, path }) => {
|
|
932
|
+
const contents = await fs.readFile(path).catch(() => void 0);
|
|
931
933
|
return {
|
|
932
934
|
entrypoint,
|
|
933
|
-
path
|
|
935
|
+
path,
|
|
934
936
|
namespace,
|
|
935
|
-
data
|
|
937
|
+
data: contents ? gettextParser.po.parse(contents) : void 0
|
|
936
938
|
};
|
|
937
939
|
});
|
|
938
940
|
build.onProcess({
|
|
939
941
|
filter: /.*\.po$/,
|
|
940
942
|
namespace
|
|
941
|
-
}, async ({ entrypoint, path
|
|
942
|
-
const collected = collections.get(path
|
|
943
|
+
}, async ({ entrypoint, path, data }) => {
|
|
944
|
+
const collected = collections.get(path);
|
|
943
945
|
if (!collected) {
|
|
944
|
-
build.context.logger?.warn({ path
|
|
946
|
+
build.context.logger?.warn({ path }, "no translations collected for this path");
|
|
945
947
|
return;
|
|
946
948
|
}
|
|
947
949
|
const { locale, translations } = collected;
|
|
948
|
-
const
|
|
949
|
-
const out = merge([{ translations: record }], data, build.context.config.obsolete, locale, build.context.generatedAt);
|
|
950
|
+
const out = merge([{ translations: collect(translations, locale) }], data, build.context.config.obsolete, locale, build.context.generatedAt);
|
|
950
951
|
if (hasChanges(out, data)) {
|
|
951
|
-
await fs.mkdir(dirname(path
|
|
952
|
-
await fs.writeFile(path
|
|
952
|
+
await fs.mkdir(dirname(path), { recursive: true });
|
|
953
|
+
await fs.writeFile(path, gettextParser.po.compile(out));
|
|
953
954
|
}
|
|
954
955
|
build.resolve({
|
|
955
956
|
entrypoint,
|
|
956
|
-
path
|
|
957
|
+
path,
|
|
957
958
|
namespace: "cleanup",
|
|
958
959
|
data: translations
|
|
959
960
|
});
|
|
@@ -961,7 +962,6 @@ function po() {
|
|
|
961
962
|
}
|
|
962
963
|
};
|
|
963
964
|
}
|
|
964
|
-
|
|
965
965
|
//#endregion
|
|
966
966
|
//#region src/plugins/react/queries/utils.ts
|
|
967
967
|
function buildTemplate(node) {
|
|
@@ -977,10 +977,10 @@ function buildTemplate(node) {
|
|
|
977
977
|
segmentStart = Math.max(segmentStart, endIndex);
|
|
978
978
|
return;
|
|
979
979
|
}
|
|
980
|
-
const text
|
|
981
|
-
if (text
|
|
980
|
+
const text = source.slice(segmentStart, endIndex);
|
|
981
|
+
if (text) parts.push({
|
|
982
982
|
kind: "text",
|
|
983
|
-
text
|
|
983
|
+
text,
|
|
984
984
|
raw: true
|
|
985
985
|
});
|
|
986
986
|
segmentStart = endIndex;
|
|
@@ -1088,7 +1088,6 @@ function buildAttrValue(node) {
|
|
|
1088
1088
|
error: "Unsupported JSX child"
|
|
1089
1089
|
};
|
|
1090
1090
|
}
|
|
1091
|
-
|
|
1092
1091
|
//#endregion
|
|
1093
1092
|
//#region src/plugins/react/queries/message.ts
|
|
1094
1093
|
const messageQuery = withComment({
|
|
@@ -1144,7 +1143,6 @@ const messageQuery = withComment({
|
|
|
1144
1143
|
};
|
|
1145
1144
|
}
|
|
1146
1145
|
});
|
|
1147
|
-
|
|
1148
1146
|
//#endregion
|
|
1149
1147
|
//#region src/plugins/react/queries/plural.ts
|
|
1150
1148
|
function parseForms(node) {
|
|
@@ -1170,7 +1168,9 @@ function parseForms(node) {
|
|
|
1170
1168
|
}
|
|
1171
1169
|
return { forms };
|
|
1172
1170
|
}
|
|
1173
|
-
|
|
1171
|
+
//#endregion
|
|
1172
|
+
//#region src/plugins/react/queries/index.ts
|
|
1173
|
+
const queries = [messageQuery, withComment({
|
|
1174
1174
|
pattern: `(
|
|
1175
1175
|
[
|
|
1176
1176
|
(jsx_element (jsx_opening_element name: (identifier) @name))
|
|
@@ -1213,17 +1213,12 @@ const pluralQuery = withComment({
|
|
|
1213
1213
|
translation
|
|
1214
1214
|
};
|
|
1215
1215
|
}
|
|
1216
|
-
});
|
|
1217
|
-
|
|
1218
|
-
//#endregion
|
|
1219
|
-
//#region src/plugins/react/queries/index.ts
|
|
1220
|
-
const queries = [messageQuery, pluralQuery];
|
|
1221
|
-
|
|
1216
|
+
})];
|
|
1222
1217
|
//#endregion
|
|
1223
1218
|
//#region src/plugins/react/parse.ts
|
|
1224
|
-
function parseSource(source, path
|
|
1225
|
-
const context = { path
|
|
1226
|
-
const { parser, language } = getParser(path
|
|
1219
|
+
function parseSource(source, path) {
|
|
1220
|
+
const context = { path };
|
|
1221
|
+
const { parser, language } = getParser(path);
|
|
1227
1222
|
const tree = parser.parse(source);
|
|
1228
1223
|
const translations = [];
|
|
1229
1224
|
const warnings = [];
|
|
@@ -1255,7 +1250,6 @@ function parseSource(source, path$1) {
|
|
|
1255
1250
|
warnings
|
|
1256
1251
|
};
|
|
1257
1252
|
}
|
|
1258
|
-
|
|
1259
1253
|
//#endregion
|
|
1260
1254
|
//#region src/plugins/react/react.ts
|
|
1261
1255
|
const filter = /\.[cm]?[jt]sx$/;
|
|
@@ -1267,12 +1261,12 @@ function react() {
|
|
|
1267
1261
|
build.onProcess({
|
|
1268
1262
|
filter,
|
|
1269
1263
|
namespace: "source"
|
|
1270
|
-
}, ({ entrypoint, path
|
|
1271
|
-
const { translations, warnings } = parseSource(data, path
|
|
1264
|
+
}, ({ entrypoint, path, data }) => {
|
|
1265
|
+
const { translations, warnings } = parseSource(data, path);
|
|
1272
1266
|
for (const warning of warnings) build.context.logger?.warn(`${warning.error} at ${warning.reference}`);
|
|
1273
1267
|
build.resolve({
|
|
1274
1268
|
entrypoint,
|
|
1275
|
-
path
|
|
1269
|
+
path,
|
|
1276
1270
|
namespace: "translate",
|
|
1277
1271
|
data: translations
|
|
1278
1272
|
});
|
|
@@ -1280,7 +1274,21 @@ function react() {
|
|
|
1280
1274
|
}
|
|
1281
1275
|
};
|
|
1282
1276
|
}
|
|
1283
|
-
|
|
1277
|
+
//#endregion
|
|
1278
|
+
//#region src/defer.ts
|
|
1279
|
+
var Defer = class {
|
|
1280
|
+
pending = 0;
|
|
1281
|
+
promise = Promise.resolve();
|
|
1282
|
+
resolve;
|
|
1283
|
+
enqueue() {
|
|
1284
|
+
if (this.pending++ === 0) this.promise = new Promise((res) => {
|
|
1285
|
+
this.resolve = res;
|
|
1286
|
+
});
|
|
1287
|
+
}
|
|
1288
|
+
dequeue() {
|
|
1289
|
+
if (this.pending > 0 && --this.pending === 0) this.resolve?.();
|
|
1290
|
+
}
|
|
1291
|
+
};
|
|
1284
1292
|
//#endregion
|
|
1285
1293
|
//#region src/plugins/static.ts
|
|
1286
1294
|
const original = {
|
|
@@ -1293,13 +1301,12 @@ function resolveStaticPlugin(item) {
|
|
|
1293
1301
|
if ("static" in item) return original[item.static.name](...item.static.props);
|
|
1294
1302
|
return item;
|
|
1295
1303
|
}
|
|
1296
|
-
|
|
1297
1304
|
//#endregion
|
|
1298
1305
|
//#region src/run.ts
|
|
1299
1306
|
async function getPaths(entrypoint) {
|
|
1300
1307
|
const pattern = entrypoint.entrypoint.replace(/\\/g, "/");
|
|
1301
1308
|
const paths = glob.isDynamicPattern(pattern) ? await glob(pattern, { onlyFiles: true }) : [entrypoint.entrypoint];
|
|
1302
|
-
return new Set(paths.map((path
|
|
1309
|
+
return new Set(paths.map((path) => resolve(path)));
|
|
1303
1310
|
}
|
|
1304
1311
|
async function run(entrypoint, { config, logger }) {
|
|
1305
1312
|
const destination = entrypoint.destination ?? config.destination;
|
|
@@ -1331,19 +1338,25 @@ async function run(entrypoint, { config, logger }) {
|
|
|
1331
1338
|
};
|
|
1332
1339
|
const pending = /* @__PURE__ */ new Map();
|
|
1333
1340
|
const queue = [];
|
|
1334
|
-
function getDeferred(namespace
|
|
1335
|
-
let defer
|
|
1336
|
-
if (defer
|
|
1337
|
-
defer
|
|
1338
|
-
pending.set(namespace
|
|
1341
|
+
function getDeferred(namespace) {
|
|
1342
|
+
let defer = pending.get(namespace);
|
|
1343
|
+
if (defer === void 0) {
|
|
1344
|
+
defer = new Defer();
|
|
1345
|
+
pending.set(namespace, defer);
|
|
1339
1346
|
}
|
|
1340
|
-
return defer
|
|
1347
|
+
return defer;
|
|
1341
1348
|
}
|
|
1342
|
-
function defer(namespace
|
|
1343
|
-
return getDeferred(namespace
|
|
1349
|
+
function defer(namespace) {
|
|
1350
|
+
return getDeferred(namespace).promise;
|
|
1344
1351
|
}
|
|
1345
|
-
function source(path
|
|
1346
|
-
const
|
|
1352
|
+
function source(path) {
|
|
1353
|
+
const abs = resolve(path);
|
|
1354
|
+
let resolvedPath;
|
|
1355
|
+
try {
|
|
1356
|
+
resolvedPath = realpathSync(abs);
|
|
1357
|
+
} catch {
|
|
1358
|
+
resolvedPath = abs;
|
|
1359
|
+
}
|
|
1347
1360
|
if (paths.has(resolvedPath)) return;
|
|
1348
1361
|
logger?.debug({
|
|
1349
1362
|
entrypoint: entrypoint.entrypoint,
|
|
@@ -1357,74 +1370,74 @@ async function run(entrypoint, { config, logger }) {
|
|
|
1357
1370
|
});
|
|
1358
1371
|
}
|
|
1359
1372
|
function resolve$1(args) {
|
|
1360
|
-
const { entrypoint
|
|
1361
|
-
const key = `${entrypoint
|
|
1373
|
+
const { entrypoint, path, namespace } = args;
|
|
1374
|
+
const key = `${entrypoint}:${namespace}:${path}`;
|
|
1362
1375
|
const visited = resolved.has(key);
|
|
1363
|
-
const skipped = context.config.exclude
|
|
1376
|
+
const skipped = isExcluded(args, context.config.exclude);
|
|
1364
1377
|
logger?.debug({
|
|
1365
|
-
entrypoint
|
|
1366
|
-
path
|
|
1367
|
-
namespace
|
|
1378
|
+
entrypoint,
|
|
1379
|
+
path,
|
|
1380
|
+
namespace,
|
|
1368
1381
|
skipped,
|
|
1369
1382
|
visited
|
|
1370
1383
|
}, "resolve");
|
|
1371
|
-
if (namespace
|
|
1384
|
+
if (namespace === "source" && visited) return;
|
|
1372
1385
|
resolved.add(key);
|
|
1373
1386
|
if (skipped) return;
|
|
1374
1387
|
queue.push({
|
|
1375
1388
|
type: "resolve",
|
|
1376
1389
|
args
|
|
1377
1390
|
});
|
|
1378
|
-
getDeferred(namespace
|
|
1391
|
+
getDeferred(namespace).enqueue();
|
|
1379
1392
|
}
|
|
1380
1393
|
function load(args) {
|
|
1381
|
-
const { entrypoint
|
|
1394
|
+
const { entrypoint, path, namespace } = args;
|
|
1382
1395
|
logger?.debug({
|
|
1383
|
-
entrypoint
|
|
1384
|
-
path
|
|
1385
|
-
namespace
|
|
1396
|
+
entrypoint,
|
|
1397
|
+
path,
|
|
1398
|
+
namespace
|
|
1386
1399
|
}, "load");
|
|
1387
1400
|
queue.push({
|
|
1388
1401
|
type: "load",
|
|
1389
1402
|
args
|
|
1390
1403
|
});
|
|
1391
|
-
getDeferred(namespace
|
|
1404
|
+
getDeferred(namespace).enqueue();
|
|
1392
1405
|
}
|
|
1393
|
-
function process
|
|
1394
|
-
const { entrypoint
|
|
1406
|
+
function process(args) {
|
|
1407
|
+
const { entrypoint, path, namespace } = args;
|
|
1395
1408
|
logger?.debug({
|
|
1396
|
-
entrypoint
|
|
1397
|
-
path
|
|
1398
|
-
namespace
|
|
1409
|
+
entrypoint,
|
|
1410
|
+
path,
|
|
1411
|
+
namespace
|
|
1399
1412
|
}, "process");
|
|
1400
1413
|
queue.push({
|
|
1401
1414
|
type: "process",
|
|
1402
1415
|
args
|
|
1403
1416
|
});
|
|
1404
|
-
getDeferred(namespace
|
|
1417
|
+
getDeferred(namespace).enqueue();
|
|
1405
1418
|
}
|
|
1406
1419
|
const build = {
|
|
1407
1420
|
context,
|
|
1408
1421
|
source,
|
|
1409
1422
|
resolve: resolve$1,
|
|
1410
1423
|
load,
|
|
1411
|
-
process
|
|
1424
|
+
process,
|
|
1412
1425
|
defer,
|
|
1413
|
-
onResolve(filter
|
|
1426
|
+
onResolve(filter, hook) {
|
|
1414
1427
|
resolvers.push({
|
|
1415
|
-
filter
|
|
1428
|
+
filter,
|
|
1416
1429
|
hook
|
|
1417
1430
|
});
|
|
1418
1431
|
},
|
|
1419
|
-
onLoad(filter
|
|
1432
|
+
onLoad(filter, hook) {
|
|
1420
1433
|
loaders.push({
|
|
1421
|
-
filter
|
|
1434
|
+
filter,
|
|
1422
1435
|
hook
|
|
1423
1436
|
});
|
|
1424
1437
|
},
|
|
1425
|
-
onProcess(filter
|
|
1438
|
+
onProcess(filter, hook) {
|
|
1426
1439
|
processors.push({
|
|
1427
|
-
filter
|
|
1440
|
+
filter,
|
|
1428
1441
|
hook
|
|
1429
1442
|
});
|
|
1430
1443
|
}
|
|
@@ -1434,20 +1447,20 @@ async function run(entrypoint, { config, logger }) {
|
|
|
1434
1447
|
logger?.debug({ plugin: plugin.name }, "setting up plugin");
|
|
1435
1448
|
plugin.setup(build);
|
|
1436
1449
|
}
|
|
1437
|
-
for (const path
|
|
1450
|
+
for (const path of await getPaths(entrypoint)) source(path);
|
|
1438
1451
|
async function processTask(task) {
|
|
1439
1452
|
const { type } = task;
|
|
1440
1453
|
let args = task.args;
|
|
1441
|
-
const { entrypoint
|
|
1454
|
+
const { entrypoint, path, namespace } = args;
|
|
1442
1455
|
logger?.trace({
|
|
1443
1456
|
type,
|
|
1444
|
-
entrypoint
|
|
1445
|
-
path
|
|
1446
|
-
namespace
|
|
1457
|
+
entrypoint,
|
|
1458
|
+
path,
|
|
1459
|
+
namespace
|
|
1447
1460
|
}, "processing task");
|
|
1448
|
-
for (const { filter
|
|
1449
|
-
if (filter
|
|
1450
|
-
if (filter
|
|
1461
|
+
for (const { filter, hook } of hooks[type]) {
|
|
1462
|
+
if (filter.namespace !== namespace) continue;
|
|
1463
|
+
if (filter.filter && !filter.filter.test(path)) continue;
|
|
1451
1464
|
const result = await hook(args);
|
|
1452
1465
|
if (result !== void 0) {
|
|
1453
1466
|
args = result;
|
|
@@ -1456,9 +1469,9 @@ async function run(entrypoint, { config, logger }) {
|
|
|
1456
1469
|
}
|
|
1457
1470
|
if (args !== void 0) {
|
|
1458
1471
|
if (type === "resolve") load(args);
|
|
1459
|
-
else if (type === "load") process
|
|
1472
|
+
else if (type === "load") process(args);
|
|
1460
1473
|
}
|
|
1461
|
-
getDeferred(namespace
|
|
1474
|
+
getDeferred(namespace).dequeue();
|
|
1462
1475
|
}
|
|
1463
1476
|
while (queue.length || Array.from(pending.values()).some((d) => d.pending > 0)) {
|
|
1464
1477
|
while (queue.length) {
|
|
@@ -1471,7 +1484,7 @@ async function run(entrypoint, { config, logger }) {
|
|
|
1471
1484
|
}
|
|
1472
1485
|
logger?.info(entrypoint, "extraction completed");
|
|
1473
1486
|
}
|
|
1474
|
-
|
|
1475
1487
|
//#endregion
|
|
1476
|
-
export { cleanup, core
|
|
1477
|
-
|
|
1488
|
+
export { cleanup as a, core as i, react as n, po as r, run as t };
|
|
1489
|
+
|
|
1490
|
+
//# sourceMappingURL=run-Bv3fv1N8.mjs.map
|