@let-value/translate-extract 1.0.30 → 1.0.31
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 +7 -6
- package/dist/bin/cli.js +1 -1
- package/dist/chunk-CUT6urMc.cjs +30 -0
- package/dist/configuration-CFa8J7EM.d.ts +240 -0
- package/dist/configuration-CFa8J7EM.d.ts.map +1 -0
- package/dist/configuration-nsGqA5N9.d.cts +239 -0
- package/dist/configuration-nsGqA5N9.d.cts.map +1 -0
- package/dist/core-ACuLoi2B.d.ts +1 -0
- package/dist/core-CHb_Xdzl.cjs +65 -0
- package/dist/core-CPg6_re5.d.cts +1 -0
- package/dist/core-DR3oxhSq.js +59 -0
- package/dist/core-DR3oxhSq.js.map +1 -0
- package/dist/run-BacOPd9p.cjs +1479 -0
- package/dist/run-DcO6U79B.js +1439 -0
- package/dist/run-DcO6U79B.js.map +1 -0
- package/dist/src/core.cjs +4 -0
- package/dist/src/core.d.cts +3 -0
- package/dist/src/core.d.ts +3 -0
- package/dist/src/core.js +4 -0
- package/dist/src/index.cjs +9 -1320
- package/dist/src/index.d.cts +3 -209
- package/dist/src/index.d.cts.map +1 -1
- package/dist/src/index.d.ts +3 -210
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -1306
- package/dist/src/static.cjs +6 -0
- package/dist/src/static.d.cts +2 -0
- package/dist/src/static.d.ts +2 -0
- package/dist/src/static.js +3 -0
- package/dist/static-CNiWpXhx.cjs +52 -0
- package/dist/static-DQHT7uqP.js +29 -0
- package/dist/static-DQHT7uqP.js.map +1 -0
- package/package.json +12 -2
- package/dist/run-BonabcP6.cjs +0 -209
- package/dist/run-C_bYec-q.js +0 -175
- package/dist/run-C_bYec-q.js.map +0 -1
- package/dist/src/index.js.map +0 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/static.ts
|
|
3
|
+
function core(...props) {
|
|
4
|
+
return { static: {
|
|
5
|
+
name: "core",
|
|
6
|
+
props
|
|
7
|
+
} };
|
|
8
|
+
}
|
|
9
|
+
function react(...props) {
|
|
10
|
+
return { static: {
|
|
11
|
+
name: "react",
|
|
12
|
+
props
|
|
13
|
+
} };
|
|
14
|
+
}
|
|
15
|
+
function po(...props) {
|
|
16
|
+
return { static: {
|
|
17
|
+
name: "po",
|
|
18
|
+
props
|
|
19
|
+
} };
|
|
20
|
+
}
|
|
21
|
+
function cleanup(...props) {
|
|
22
|
+
return { static: {
|
|
23
|
+
name: "cleanup",
|
|
24
|
+
props
|
|
25
|
+
} };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
Object.defineProperty(exports, 'cleanup', {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function () {
|
|
32
|
+
return cleanup;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
Object.defineProperty(exports, 'core', {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
get: function () {
|
|
38
|
+
return core;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
Object.defineProperty(exports, 'po', {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
get: function () {
|
|
44
|
+
return po;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
Object.defineProperty(exports, 'react', {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
get: function () {
|
|
50
|
+
return react;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region src/static.ts
|
|
2
|
+
function core(...props) {
|
|
3
|
+
return { static: {
|
|
4
|
+
name: "core",
|
|
5
|
+
props
|
|
6
|
+
} };
|
|
7
|
+
}
|
|
8
|
+
function react(...props) {
|
|
9
|
+
return { static: {
|
|
10
|
+
name: "react",
|
|
11
|
+
props
|
|
12
|
+
} };
|
|
13
|
+
}
|
|
14
|
+
function po(...props) {
|
|
15
|
+
return { static: {
|
|
16
|
+
name: "po",
|
|
17
|
+
props
|
|
18
|
+
} };
|
|
19
|
+
}
|
|
20
|
+
function cleanup(...props) {
|
|
21
|
+
return { static: {
|
|
22
|
+
name: "cleanup",
|
|
23
|
+
props
|
|
24
|
+
} };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { cleanup, core, po, react };
|
|
29
|
+
//# sourceMappingURL=static-DQHT7uqP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"static-DQHT7uqP.js","names":[],"sources":["../src/static.ts"],"sourcesContent":["import type { cleanup as cleanupPlugin } from \"./plugins/cleanup/cleanup.ts\";\nimport type { core as corePlugin } from \"./plugins/core/core.ts\";\nimport type { po as poPlugin } from \"./plugins/po/po.ts\";\nimport type { react as reactPlugin } from \"./plugins/react/react.ts\";\n\nexport function core(...props: Parameters<typeof corePlugin>) {\n return {\n static: {\n name: \"core\",\n props,\n },\n } as const;\n}\n\nexport function react(...props: Parameters<typeof reactPlugin>) {\n return {\n static: {\n name: \"react\",\n props,\n },\n } as const;\n}\nexport function po(...props: Parameters<typeof poPlugin>) {\n return {\n static: {\n name: \"po\",\n props,\n },\n } as const;\n}\n\nexport function cleanup(...props: Parameters<typeof cleanupPlugin>) {\n return {\n static: {\n name: \"cleanup\",\n props,\n },\n } as const;\n}\n\nexport type StaticPlugin =\n | ReturnType<typeof core>\n | ReturnType<typeof react>\n | ReturnType<typeof po>\n | ReturnType<typeof cleanup>;\n"],"mappings":";AAKA,SAAgB,KAAK,GAAG,OAAsC;AAC1D,QAAO,EACH,QAAQ;EACJ,MAAM;EACN;EACH,EACJ;;AAGL,SAAgB,MAAM,GAAG,OAAuC;AAC5D,QAAO,EACH,QAAQ;EACJ,MAAM;EACN;EACH,EACJ;;AAEL,SAAgB,GAAG,GAAG,OAAoC;AACtD,QAAO,EACH,QAAQ;EACJ,MAAM;EACN;EACH,EACJ;;AAGL,SAAgB,QAAQ,GAAG,OAAyC;AAChE,QAAO,EACH,QAAQ;EACJ,MAAM;EACN;EACH,EACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@let-value/translate-extract",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.31",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -14,13 +14,23 @@
|
|
|
14
14
|
"import": "./dist/src/index.js",
|
|
15
15
|
"require": "./dist/src/index.cjs"
|
|
16
16
|
},
|
|
17
|
+
"./core": {
|
|
18
|
+
"types": "./dist/src/core.d.ts",
|
|
19
|
+
"import": "./dist/src/core.js",
|
|
20
|
+
"require": "./dist/src/core.cjs"
|
|
21
|
+
},
|
|
22
|
+
"./static": {
|
|
23
|
+
"types": "./dist/src/static.d.ts",
|
|
24
|
+
"import": "./dist/src/static.js",
|
|
25
|
+
"require": "./dist/src/static.cjs"
|
|
26
|
+
},
|
|
17
27
|
"./package.json": "./package.json"
|
|
18
28
|
},
|
|
19
29
|
"files": [
|
|
20
30
|
"dist"
|
|
21
31
|
],
|
|
22
32
|
"dependencies": {
|
|
23
|
-
"@let-value/translate": "1.0.
|
|
33
|
+
"@let-value/translate": "1.0.31",
|
|
24
34
|
"chalk": "5.3.0",
|
|
25
35
|
"cosmiconfig": "9.0.0",
|
|
26
36
|
"fast-glob": "3.3.2",
|
package/dist/run-BonabcP6.cjs
DELETED
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
//#region rolldown:runtime
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
-
key = keys[i];
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
-
get: ((k) => from[k]).bind(null, key),
|
|
13
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
-
value: mod,
|
|
20
|
-
enumerable: true
|
|
21
|
-
}) : target, mod));
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
let fast_glob = require("fast-glob");
|
|
25
|
-
fast_glob = __toESM(fast_glob);
|
|
26
|
-
|
|
27
|
-
//#region src/defer.ts
|
|
28
|
-
var Defer = class {
|
|
29
|
-
pending = 0;
|
|
30
|
-
promise = Promise.resolve();
|
|
31
|
-
resolve;
|
|
32
|
-
enqueue() {
|
|
33
|
-
if (this.pending++ === 0) this.promise = new Promise((res) => {
|
|
34
|
-
this.resolve = res;
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
dequeue() {
|
|
38
|
-
if (this.pending > 0 && --this.pending === 0) this.resolve?.();
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
//#endregion
|
|
43
|
-
//#region src/run.ts
|
|
44
|
-
async function run(entrypoint, { config, logger }) {
|
|
45
|
-
const destination = entrypoint.destination ?? config.destination;
|
|
46
|
-
const obsolete = entrypoint.obsolete ?? config.obsolete;
|
|
47
|
-
const exclude = entrypoint.exclude ?? config.exclude;
|
|
48
|
-
const walk = entrypoint.walk ?? config.walk;
|
|
49
|
-
const context = {
|
|
50
|
-
config: {
|
|
51
|
-
...config,
|
|
52
|
-
destination,
|
|
53
|
-
obsolete,
|
|
54
|
-
exclude,
|
|
55
|
-
walk
|
|
56
|
-
},
|
|
57
|
-
generatedAt: /* @__PURE__ */ new Date(),
|
|
58
|
-
logger
|
|
59
|
-
};
|
|
60
|
-
logger?.info(entrypoint, "starting extraction");
|
|
61
|
-
const resolvers = [];
|
|
62
|
-
const loaders = [];
|
|
63
|
-
const processors = [];
|
|
64
|
-
const hooks = {
|
|
65
|
-
resolve: resolvers,
|
|
66
|
-
load: loaders,
|
|
67
|
-
process: processors
|
|
68
|
-
};
|
|
69
|
-
const pending = /* @__PURE__ */ new Map();
|
|
70
|
-
const queue = [];
|
|
71
|
-
function getDeferred(namespace) {
|
|
72
|
-
let defer$1 = pending.get(namespace);
|
|
73
|
-
if (defer$1 === void 0) {
|
|
74
|
-
defer$1 = new Defer();
|
|
75
|
-
pending.set(namespace, defer$1);
|
|
76
|
-
}
|
|
77
|
-
return defer$1;
|
|
78
|
-
}
|
|
79
|
-
function defer(namespace) {
|
|
80
|
-
return getDeferred(namespace).promise;
|
|
81
|
-
}
|
|
82
|
-
function resolve(args) {
|
|
83
|
-
const { entrypoint: entrypoint$1, path, namespace } = args;
|
|
84
|
-
const skipped = 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;
|
|
92
|
-
queue.push({
|
|
93
|
-
type: "resolve",
|
|
94
|
-
args
|
|
95
|
-
});
|
|
96
|
-
getDeferred(namespace).enqueue();
|
|
97
|
-
}
|
|
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");
|
|
105
|
-
queue.push({
|
|
106
|
-
type: "load",
|
|
107
|
-
args
|
|
108
|
-
});
|
|
109
|
-
getDeferred(namespace).enqueue();
|
|
110
|
-
}
|
|
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");
|
|
118
|
-
queue.push({
|
|
119
|
-
type: "process",
|
|
120
|
-
args
|
|
121
|
-
});
|
|
122
|
-
getDeferred(namespace).enqueue();
|
|
123
|
-
}
|
|
124
|
-
const build = {
|
|
125
|
-
context,
|
|
126
|
-
resolve,
|
|
127
|
-
load,
|
|
128
|
-
process,
|
|
129
|
-
defer,
|
|
130
|
-
onResolve(filter, hook) {
|
|
131
|
-
resolvers.push({
|
|
132
|
-
filter,
|
|
133
|
-
hook
|
|
134
|
-
});
|
|
135
|
-
},
|
|
136
|
-
onLoad(filter, hook) {
|
|
137
|
-
loaders.push({
|
|
138
|
-
filter,
|
|
139
|
-
hook
|
|
140
|
-
});
|
|
141
|
-
},
|
|
142
|
-
onProcess(filter, hook) {
|
|
143
|
-
processors.push({
|
|
144
|
-
filter,
|
|
145
|
-
hook
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
for (const plugin of config.plugins) {
|
|
150
|
-
logger?.debug({ plugin: plugin.name }, "setting up plugin");
|
|
151
|
-
plugin.setup(build);
|
|
152
|
-
}
|
|
153
|
-
const paths = fast_glob.default.isDynamicPattern(entrypoint.entrypoint) ? await (0, fast_glob.default)(entrypoint.entrypoint, { onlyFiles: true }) : [entrypoint.entrypoint];
|
|
154
|
-
logger?.debug({
|
|
155
|
-
entrypoint: entrypoint.entrypoint,
|
|
156
|
-
paths
|
|
157
|
-
}, "resolved paths");
|
|
158
|
-
for (const path of paths) resolve({
|
|
159
|
-
entrypoint: path,
|
|
160
|
-
path,
|
|
161
|
-
namespace: "source"
|
|
162
|
-
});
|
|
163
|
-
async function processTask(task) {
|
|
164
|
-
const { type } = task;
|
|
165
|
-
let args = task.args;
|
|
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;
|
|
176
|
-
const result = await hook(args);
|
|
177
|
-
if (result !== void 0) args = result;
|
|
178
|
-
}
|
|
179
|
-
if (args !== void 0) {
|
|
180
|
-
if (type === "resolve") load(args);
|
|
181
|
-
else if (type === "load") process(args);
|
|
182
|
-
}
|
|
183
|
-
getDeferred(namespace).dequeue();
|
|
184
|
-
}
|
|
185
|
-
while (queue.length || Array.from(pending.values()).some((d) => d.pending > 0)) {
|
|
186
|
-
while (queue.length) {
|
|
187
|
-
const task = queue.shift();
|
|
188
|
-
if (!task) break;
|
|
189
|
-
await processTask(task);
|
|
190
|
-
}
|
|
191
|
-
await Promise.all(Array.from(pending.values()).map((d) => d.promise));
|
|
192
|
-
await Promise.resolve();
|
|
193
|
-
}
|
|
194
|
-
logger?.info(entrypoint, "extraction completed");
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
//#endregion
|
|
198
|
-
Object.defineProperty(exports, '__toESM', {
|
|
199
|
-
enumerable: true,
|
|
200
|
-
get: function () {
|
|
201
|
-
return __toESM;
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
Object.defineProperty(exports, 'run', {
|
|
205
|
-
enumerable: true,
|
|
206
|
-
get: function () {
|
|
207
|
-
return run;
|
|
208
|
-
}
|
|
209
|
-
});
|
package/dist/run-C_bYec-q.js
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import glob from "fast-glob";
|
|
2
|
-
|
|
3
|
-
//#region src/defer.ts
|
|
4
|
-
var Defer = class {
|
|
5
|
-
pending = 0;
|
|
6
|
-
promise = Promise.resolve();
|
|
7
|
-
resolve;
|
|
8
|
-
enqueue() {
|
|
9
|
-
if (this.pending++ === 0) this.promise = new Promise((res) => {
|
|
10
|
-
this.resolve = res;
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
dequeue() {
|
|
14
|
-
if (this.pending > 0 && --this.pending === 0) this.resolve?.();
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
|
-
//#region src/run.ts
|
|
20
|
-
async function run(entrypoint, { config, logger }) {
|
|
21
|
-
const destination = entrypoint.destination ?? config.destination;
|
|
22
|
-
const obsolete = entrypoint.obsolete ?? config.obsolete;
|
|
23
|
-
const exclude = entrypoint.exclude ?? config.exclude;
|
|
24
|
-
const walk = entrypoint.walk ?? config.walk;
|
|
25
|
-
const context = {
|
|
26
|
-
config: {
|
|
27
|
-
...config,
|
|
28
|
-
destination,
|
|
29
|
-
obsolete,
|
|
30
|
-
exclude,
|
|
31
|
-
walk
|
|
32
|
-
},
|
|
33
|
-
generatedAt: /* @__PURE__ */ new Date(),
|
|
34
|
-
logger
|
|
35
|
-
};
|
|
36
|
-
logger?.info(entrypoint, "starting extraction");
|
|
37
|
-
const resolvers = [];
|
|
38
|
-
const loaders = [];
|
|
39
|
-
const processors = [];
|
|
40
|
-
const hooks = {
|
|
41
|
-
resolve: resolvers,
|
|
42
|
-
load: loaders,
|
|
43
|
-
process: processors
|
|
44
|
-
};
|
|
45
|
-
const pending = /* @__PURE__ */ new Map();
|
|
46
|
-
const queue = [];
|
|
47
|
-
function getDeferred(namespace) {
|
|
48
|
-
let defer$1 = pending.get(namespace);
|
|
49
|
-
if (defer$1 === void 0) {
|
|
50
|
-
defer$1 = new Defer();
|
|
51
|
-
pending.set(namespace, defer$1);
|
|
52
|
-
}
|
|
53
|
-
return defer$1;
|
|
54
|
-
}
|
|
55
|
-
function defer(namespace) {
|
|
56
|
-
return getDeferred(namespace).promise;
|
|
57
|
-
}
|
|
58
|
-
function resolve(args) {
|
|
59
|
-
const { entrypoint: entrypoint$1, path, namespace } = args;
|
|
60
|
-
const skipped = 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;
|
|
68
|
-
queue.push({
|
|
69
|
-
type: "resolve",
|
|
70
|
-
args
|
|
71
|
-
});
|
|
72
|
-
getDeferred(namespace).enqueue();
|
|
73
|
-
}
|
|
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");
|
|
81
|
-
queue.push({
|
|
82
|
-
type: "load",
|
|
83
|
-
args
|
|
84
|
-
});
|
|
85
|
-
getDeferred(namespace).enqueue();
|
|
86
|
-
}
|
|
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");
|
|
94
|
-
queue.push({
|
|
95
|
-
type: "process",
|
|
96
|
-
args
|
|
97
|
-
});
|
|
98
|
-
getDeferred(namespace).enqueue();
|
|
99
|
-
}
|
|
100
|
-
const build = {
|
|
101
|
-
context,
|
|
102
|
-
resolve,
|
|
103
|
-
load,
|
|
104
|
-
process,
|
|
105
|
-
defer,
|
|
106
|
-
onResolve(filter, hook) {
|
|
107
|
-
resolvers.push({
|
|
108
|
-
filter,
|
|
109
|
-
hook
|
|
110
|
-
});
|
|
111
|
-
},
|
|
112
|
-
onLoad(filter, hook) {
|
|
113
|
-
loaders.push({
|
|
114
|
-
filter,
|
|
115
|
-
hook
|
|
116
|
-
});
|
|
117
|
-
},
|
|
118
|
-
onProcess(filter, hook) {
|
|
119
|
-
processors.push({
|
|
120
|
-
filter,
|
|
121
|
-
hook
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
for (const plugin of config.plugins) {
|
|
126
|
-
logger?.debug({ plugin: plugin.name }, "setting up plugin");
|
|
127
|
-
plugin.setup(build);
|
|
128
|
-
}
|
|
129
|
-
const paths = glob.isDynamicPattern(entrypoint.entrypoint) ? await glob(entrypoint.entrypoint, { onlyFiles: true }) : [entrypoint.entrypoint];
|
|
130
|
-
logger?.debug({
|
|
131
|
-
entrypoint: entrypoint.entrypoint,
|
|
132
|
-
paths
|
|
133
|
-
}, "resolved paths");
|
|
134
|
-
for (const path of paths) resolve({
|
|
135
|
-
entrypoint: path,
|
|
136
|
-
path,
|
|
137
|
-
namespace: "source"
|
|
138
|
-
});
|
|
139
|
-
async function processTask(task) {
|
|
140
|
-
const { type } = task;
|
|
141
|
-
let args = task.args;
|
|
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;
|
|
152
|
-
const result = await hook(args);
|
|
153
|
-
if (result !== void 0) args = result;
|
|
154
|
-
}
|
|
155
|
-
if (args !== void 0) {
|
|
156
|
-
if (type === "resolve") load(args);
|
|
157
|
-
else if (type === "load") process(args);
|
|
158
|
-
}
|
|
159
|
-
getDeferred(namespace).dequeue();
|
|
160
|
-
}
|
|
161
|
-
while (queue.length || Array.from(pending.values()).some((d) => d.pending > 0)) {
|
|
162
|
-
while (queue.length) {
|
|
163
|
-
const task = queue.shift();
|
|
164
|
-
if (!task) break;
|
|
165
|
-
await processTask(task);
|
|
166
|
-
}
|
|
167
|
-
await Promise.all(Array.from(pending.values()).map((d) => d.promise));
|
|
168
|
-
await Promise.resolve();
|
|
169
|
-
}
|
|
170
|
-
logger?.info(entrypoint, "extraction completed");
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
//#endregion
|
|
174
|
-
export { run };
|
|
175
|
-
//# sourceMappingURL=run-C_bYec-q.js.map
|
package/dist/run-C_bYec-q.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-C_bYec-q.js","names":["context: Context","resolvers: { filter: Filter; hook: ResolveHook }[]","loaders: { filter: Filter; hook: LoadHook }[]","processors: { filter: Filter; hook: ProcessHook }[]","queue: Task[]","defer","build: Build"],"sources":["../src/defer.ts","../src/run.ts"],"sourcesContent":["export class Defer {\n pending = 0;\n promise: Promise<void> = Promise.resolve();\n resolve?: () => void;\n\n enqueue() {\n if (this.pending++ === 0) {\n this.promise = new Promise<void>((res) => {\n this.resolve = res;\n });\n }\n }\n dequeue() {\n if (this.pending > 0 && --this.pending === 0) {\n this.resolve?.();\n }\n }\n}\n","import glob from \"fast-glob\";\nimport type { ResolvedConfig, ResolvedEntrypoint } from \"./configuration.ts\";\nimport { Defer } from \"./defer.ts\";\nimport type { Logger } from \"./logger.ts\";\nimport type {\n Build,\n Context,\n Filter,\n LoadArgs,\n LoadHook,\n ProcessArgs,\n ProcessHook,\n ResolveArgs,\n ResolveHook,\n} from \"./plugin.ts\";\n\nexport type Task =\n | {\n type: \"resolve\";\n args: ResolveArgs;\n }\n | {\n type: \"load\";\n args: LoadArgs;\n }\n | {\n type: \"process\";\n args: ProcessArgs;\n };\n\nexport async function run(\n entrypoint: ResolvedEntrypoint,\n { config, logger }: { config: ResolvedConfig; logger?: Logger },\n) {\n const destination = entrypoint.destination ?? config.destination;\n const obsolete = entrypoint.obsolete ?? config.obsolete;\n const exclude = entrypoint.exclude ?? config.exclude;\n const walk = entrypoint.walk ?? config.walk;\n\n const context: Context = {\n config: { ...config, destination, obsolete, exclude, walk },\n generatedAt: new Date(),\n logger,\n };\n\n logger?.info(entrypoint, \"starting extraction\");\n\n const resolvers: { filter: Filter; hook: ResolveHook }[] = [];\n const loaders: { filter: Filter; hook: LoadHook }[] = [];\n const processors: { filter: Filter; hook: ProcessHook }[] = [];\n const hooks = {\n resolve: resolvers,\n load: loaders,\n process: processors,\n };\n\n const pending = new Map<string, Defer>();\n const queue: Task[] = [];\n\n function getDeferred(namespace: string) {\n let defer = pending.get(namespace);\n if (defer === undefined) {\n defer = new Defer();\n pending.set(namespace, defer);\n }\n return defer;\n }\n\n function defer(namespace: string) {\n const defer = getDeferred(namespace);\n return defer.promise;\n }\n\n function resolve(args: ResolveArgs) {\n const { entrypoint, path, namespace } = args;\n const skipped = context.config.exclude.some((ex) => (typeof ex === \"function\" ? ex(args) : ex.test(args.path)));\n logger?.debug({ entrypoint, path, namespace, skipped }, \"resolve\");\n\n if (skipped) {\n return;\n }\n\n queue.push({ type: \"resolve\", args });\n getDeferred(namespace).enqueue();\n }\n\n function load(args: LoadArgs) {\n const { entrypoint, path, namespace } = args;\n logger?.debug({ entrypoint, path, namespace }, \"load\");\n\n queue.push({ type: \"load\", args });\n getDeferred(namespace).enqueue();\n }\n\n function process(args: ProcessArgs) {\n const { entrypoint, path, namespace } = args;\n logger?.debug({ entrypoint, path, namespace }, \"process\");\n\n queue.push({ type: \"process\", args });\n getDeferred(namespace).enqueue();\n }\n\n const build: Build = {\n context,\n resolve,\n load,\n process,\n defer,\n onResolve(filter, hook) {\n resolvers.push({ filter, hook });\n },\n onLoad(filter, hook) {\n loaders.push({ filter, hook });\n },\n onProcess(filter, hook) {\n processors.push({ filter, hook });\n },\n };\n\n for (const plugin of config.plugins) {\n logger?.debug({ plugin: plugin.name }, \"setting up plugin\");\n plugin.setup(build);\n }\n\n const paths = glob.isDynamicPattern(entrypoint.entrypoint)\n ? await glob(entrypoint.entrypoint, { onlyFiles: true })\n : [entrypoint.entrypoint];\n logger?.debug({ entrypoint: entrypoint.entrypoint, paths }, \"resolved paths\");\n\n for (const path of paths) {\n resolve({ entrypoint: path, path, namespace: \"source\" });\n }\n\n async function processTask(task: Task) {\n const { type } = task;\n let args = task.args;\n const { entrypoint, path, namespace } = args;\n logger?.trace({ type, entrypoint, path, namespace }, \"processing task\");\n\n for (const { filter, hook } of hooks[type]) {\n if (filter.namespace !== namespace) continue;\n if (filter.filter && !filter.filter.test(path)) continue;\n\n const result = await hook(args as never);\n if (result !== undefined) {\n args = result as never;\n }\n }\n\n if (args !== undefined) {\n if (type === \"resolve\") {\n load(args as never);\n } else if (type === \"load\") {\n process(args as never);\n }\n }\n\n getDeferred(namespace).dequeue();\n }\n\n while (queue.length || Array.from(pending.values()).some((d) => d.pending > 0)) {\n while (queue.length) {\n const task = queue.shift();\n if (!task) {\n break;\n }\n\n await processTask(task);\n }\n\n await Promise.all(Array.from(pending.values()).map((d) => d.promise));\n await Promise.resolve();\n }\n\n logger?.info(entrypoint, \"extraction completed\");\n}\n"],"mappings":";;;AAAA,IAAa,QAAb,MAAmB;CACf,UAAU;CACV,UAAyB,QAAQ,SAAS;CAC1C;CAEA,UAAU;AACN,MAAI,KAAK,cAAc,EACnB,MAAK,UAAU,IAAI,SAAe,QAAQ;AACtC,QAAK,UAAU;IACjB;;CAGV,UAAU;AACN,MAAI,KAAK,UAAU,KAAK,EAAE,KAAK,YAAY,EACvC,MAAK,WAAW;;;;;;ACgB5B,eAAsB,IAClB,YACA,EAAE,QAAQ,UACZ;CACE,MAAM,cAAc,WAAW,eAAe,OAAO;CACrD,MAAM,WAAW,WAAW,YAAY,OAAO;CAC/C,MAAM,UAAU,WAAW,WAAW,OAAO;CAC7C,MAAM,OAAO,WAAW,QAAQ,OAAO;CAEvC,MAAMA,UAAmB;EACrB,QAAQ;GAAE,GAAG;GA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