@sitrozyi/repomix-semantic-compressor 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +105 -0
- package/bin/cli.mjs +16 -0
- package/bin/mcp-server.mjs +8 -0
- package/package.json +65 -0
- package/src/ast.mjs +489 -0
- package/src/core.mjs +502 -0
- package/src/extractor.mjs +89 -0
- package/src/imports.mjs +228 -0
- package/src/mcp.mjs +223 -0
- package/src/optimizers.mjs +870 -0
- package/src/worker.mjs +28 -0
package/src/worker.mjs
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { workerData, parentPort } from 'node:worker_threads';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { transformFileContent } from './core.mjs';
|
|
4
|
+
|
|
5
|
+
if (parentPort && workerData) {
|
|
6
|
+
const { items, maxPreserveLines } = workerData;
|
|
7
|
+
const results = items.map((item) => {
|
|
8
|
+
try {
|
|
9
|
+
const transformed = transformFileContent(item.path, item.content, maxPreserveLines);
|
|
10
|
+
return {
|
|
11
|
+
index: item.index,
|
|
12
|
+
path: item.path,
|
|
13
|
+
ext: transformed.ext,
|
|
14
|
+
code: transformed.code
|
|
15
|
+
};
|
|
16
|
+
} catch (err) {
|
|
17
|
+
|
|
18
|
+
const ext = path.extname(item.path || '').toLowerCase();
|
|
19
|
+
return {
|
|
20
|
+
index: item.index,
|
|
21
|
+
path: item.path,
|
|
22
|
+
ext,
|
|
23
|
+
code: typeof item.content === 'string' ? item.content : ''
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
parentPort.postMessage(results);
|
|
28
|
+
}
|