@ubercode/dcmtk 0.8.2 → 0.9.0
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/dicom.cjs +18 -4
- package/dist/dicom.cjs.map +1 -1
- package/dist/dicom.js +18 -4
- package/dist/dicom.js.map +1 -1
- package/dist/index.cjs +359 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +229 -2
- package/dist/index.d.ts +229 -2
- package/dist/index.js +358 -9
- package/dist/index.js.map +1 -1
- package/dist/servers.cjs +16 -3
- package/dist/servers.cjs.map +1 -1
- package/dist/servers.js +18 -4
- package/dist/servers.js.map +1 -1
- package/dist/tools.cjs +18 -3
- package/dist/tools.cjs.map +1 -1
- package/dist/tools.js +18 -3
- package/dist/tools.js.map +1 -1
- package/package.json +1 -1
package/dist/tools.js
CHANGED
|
@@ -3,6 +3,8 @@ import { spawn, execSync } from 'child_process';
|
|
|
3
3
|
import kill from 'tree-kill';
|
|
4
4
|
import { join } from 'path';
|
|
5
5
|
import { existsSync } from 'fs';
|
|
6
|
+
import { rm, mkdtemp } from 'fs/promises';
|
|
7
|
+
import { tmpdir } from 'os';
|
|
6
8
|
import { stderr } from 'stderr-lib';
|
|
7
9
|
import { XMLParser } from 'fast-xml-parser';
|
|
8
10
|
|
|
@@ -568,13 +570,26 @@ async function tryDirectPath(inputPath, timeoutMs, signal, verbosity) {
|
|
|
568
570
|
if (!jsonBinary.ok) {
|
|
569
571
|
return err(jsonBinary.error);
|
|
570
572
|
}
|
|
571
|
-
const
|
|
572
|
-
const
|
|
573
|
+
const bulkDir = await createBulkTempDir();
|
|
574
|
+
const directArgs = [...buildVerbosityArgs(verbosity), "+b", "+bd", bulkDir, inputPath];
|
|
575
|
+
try {
|
|
576
|
+
const execOpts = signal !== void 0 ? { timeoutMs, signal } : { timeoutMs };
|
|
577
|
+
return await execAndParse(jsonBinary.value, directArgs, inputPath, execOpts);
|
|
578
|
+
} finally {
|
|
579
|
+
rm(bulkDir, { recursive: true, force: true }).catch(() => {
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
async function createBulkTempDir() {
|
|
584
|
+
return mkdtemp(join(tmpdir(), "dcm2json-bulk-"));
|
|
585
|
+
}
|
|
586
|
+
async function execAndParse(binary, args, inputPath, execOpts) {
|
|
587
|
+
const result = await execCommand(binary, args, execOpts);
|
|
573
588
|
if (!result.ok) {
|
|
574
589
|
return err(result.error);
|
|
575
590
|
}
|
|
576
591
|
if (result.value.exitCode !== 0) {
|
|
577
|
-
return err(createToolError("dcm2json",
|
|
592
|
+
return err(createToolError("dcm2json", args, result.value.exitCode, result.value.stderr));
|
|
578
593
|
}
|
|
579
594
|
try {
|
|
580
595
|
const repaired = repairJson(result.value.stdout);
|