@ubercode/dcmtk 0.12.0 → 0.13.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/{DicomInstance-CxLKC-oM.d.cts → DicomInstance-BGXtON9T.d.cts} +2 -0
- package/dist/{DicomInstance-BKUiir0G.d.ts → DicomInstance-DGWB2mfD.d.ts} +2 -0
- package/dist/dicom.cjs +30 -16
- package/dist/dicom.cjs.map +1 -1
- package/dist/dicom.d.cts +2 -2
- package/dist/dicom.d.ts +2 -2
- package/dist/dicom.js +30 -16
- package/dist/dicom.js.map +1 -1
- package/dist/{index-DV8HaHEX.d.cts → index-B1eynCVv.d.cts} +4 -1
- package/dist/{index-B5FQoIqM.d.ts → index-DM0yFtPO.d.ts} +4 -1
- package/dist/index.cjs +39 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +39 -17
- package/dist/index.js.map +1 -1
- package/dist/servers.cjs +39 -17
- package/dist/servers.cjs.map +1 -1
- package/dist/servers.d.cts +2 -2
- package/dist/servers.d.ts +2 -2
- package/dist/servers.js +39 -17
- package/dist/servers.js.map +1 -1
- package/dist/tools.cjs +28 -15
- package/dist/tools.cjs.map +1 -1
- package/dist/tools.d.cts +2 -0
- package/dist/tools.d.ts +2 -0
- package/dist/tools.js +28 -15
- package/dist/tools.js.map +1 -1
- package/package.json +1 -1
package/dist/dicom.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DicomTag, a as DicomTagPath } from './DicomInstance-
|
|
2
|
-
export { C as ChangeSet, b as DicomDataset, d as DicomInstance, e as DicomOpenOptions } from './DicomInstance-
|
|
1
|
+
import { D as DicomTag, a as DicomTagPath } from './DicomInstance-BGXtON9T.cjs';
|
|
2
|
+
export { C as ChangeSet, b as DicomDataset, d as DicomInstance, e as DicomOpenOptions } from './DicomInstance-BGXtON9T.cjs';
|
|
3
3
|
export { x as xmlToJson } from './dcmodify-Cf-RPHF3.cjs';
|
|
4
4
|
import './types-Cgumy1N4.cjs';
|
|
5
5
|
|
package/dist/dicom.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DicomTag, a as DicomTagPath } from './DicomInstance-
|
|
2
|
-
export { C as ChangeSet, b as DicomDataset, d as DicomInstance, e as DicomOpenOptions } from './DicomInstance-
|
|
1
|
+
import { D as DicomTag, a as DicomTagPath } from './DicomInstance-DGWB2mfD.js';
|
|
2
|
+
export { C as ChangeSet, b as DicomDataset, d as DicomInstance, e as DicomOpenOptions } from './DicomInstance-DGWB2mfD.js';
|
|
3
3
|
export { x as xmlToJson } from './dcmodify-CHvwChFu.js';
|
|
4
4
|
import './types-Cgumy1N4.js';
|
|
5
5
|
|
package/dist/dicom.js
CHANGED
|
@@ -30720,7 +30720,12 @@ var parser = new XMLParser({
|
|
|
30720
30720
|
ignoreAttributes: false,
|
|
30721
30721
|
attributeNamePrefix: "@_",
|
|
30722
30722
|
parseTagValue: false,
|
|
30723
|
-
isArray: (name) => ARRAY_TAG_NAMES.has(name)
|
|
30723
|
+
isArray: (name) => ARRAY_TAG_NAMES.has(name),
|
|
30724
|
+
// DICOM XML does not use XML entities. Disable entity processing to avoid
|
|
30725
|
+
// the default expansion limit (1000) which rejects files with >1000 tags.
|
|
30726
|
+
// Without this, large studies fall through to dcm2json which hangs on
|
|
30727
|
+
// compressed pixel data (DCMTK bug).
|
|
30728
|
+
processEntities: false
|
|
30724
30729
|
});
|
|
30725
30730
|
function xmlToJson(xml) {
|
|
30726
30731
|
try {
|
|
@@ -30781,6 +30786,7 @@ var Dcm2jsonOptionsSchema = z.object({
|
|
|
30781
30786
|
signal: z.instanceof(AbortSignal).optional(),
|
|
30782
30787
|
directOnly: z.boolean().optional(),
|
|
30783
30788
|
charsetAssume: z.string().min(1).optional(),
|
|
30789
|
+
charsetFallback: z.string().min(1).optional(),
|
|
30784
30790
|
verbosity: z.enum(["verbose", "debug"]).optional()
|
|
30785
30791
|
}).strict().optional();
|
|
30786
30792
|
var VERBOSITY_FLAGS = { verbose: "-v", debug: "-d" };
|
|
@@ -30794,27 +30800,34 @@ function buildXmlOpts(options) {
|
|
|
30794
30800
|
const result = {};
|
|
30795
30801
|
if (options?.verbosity !== void 0) result["verbosity"] = options.verbosity;
|
|
30796
30802
|
if (options?.charsetAssume !== void 0) result["charsetAssume"] = options.charsetAssume;
|
|
30803
|
+
if (options?.charsetFallback !== void 0) result["charsetFallback"] = options.charsetFallback;
|
|
30797
30804
|
return result;
|
|
30798
30805
|
}
|
|
30806
|
+
function isCharsetError(stderrOutput) {
|
|
30807
|
+
return stderrOutput.includes("convert character encoding") || stderrOutput.includes("Illegal byte sequence");
|
|
30808
|
+
}
|
|
30809
|
+
async function runXmlAndParse(binary, args, execOpts) {
|
|
30810
|
+
const xmlResult = await execCommand(binary, args, execOpts);
|
|
30811
|
+
if (!xmlResult.ok) return err(xmlResult.error);
|
|
30812
|
+
if (xmlResult.value.exitCode !== 0) {
|
|
30813
|
+
return err(createToolError("dcm2xml", args, xmlResult.value.exitCode, xmlResult.value.stderr));
|
|
30814
|
+
}
|
|
30815
|
+
const jsonResult = xmlToJson(xmlResult.value.stdout);
|
|
30816
|
+
if (!jsonResult.ok) return err(jsonResult.error);
|
|
30817
|
+
return ok({ data: jsonResult.value, source: "xml" });
|
|
30818
|
+
}
|
|
30799
30819
|
async function tryXmlPath(inputPath, timeoutMs, signal, opts) {
|
|
30800
30820
|
const xmlBinary = resolveBinary("dcm2xml");
|
|
30801
|
-
if (!xmlBinary.ok)
|
|
30802
|
-
return err(xmlBinary.error);
|
|
30803
|
-
}
|
|
30821
|
+
if (!xmlBinary.ok) return err(xmlBinary.error);
|
|
30804
30822
|
const charsetArgs = opts?.charsetAssume !== void 0 ? ["+Ca", opts.charsetAssume] : [];
|
|
30805
30823
|
const xmlArgs = [...buildVerbosityArgs(opts?.verbosity), ...charsetArgs, "-nat", inputPath];
|
|
30806
|
-
const
|
|
30807
|
-
|
|
30808
|
-
|
|
30824
|
+
const execOpts = signal !== void 0 ? { timeoutMs, signal } : { timeoutMs };
|
|
30825
|
+
const result = await runXmlAndParse(xmlBinary.value, xmlArgs, execOpts);
|
|
30826
|
+
if (!result.ok && opts?.charsetFallback !== void 0 && isCharsetError(result.error.message)) {
|
|
30827
|
+
const fallbackArgs = [...buildVerbosityArgs(opts.verbosity), "+Ca", opts.charsetFallback, "-nat", inputPath];
|
|
30828
|
+
return runXmlAndParse(xmlBinary.value, fallbackArgs, execOpts);
|
|
30809
30829
|
}
|
|
30810
|
-
|
|
30811
|
-
return err(createToolError("dcm2xml", xmlArgs, xmlResult.value.exitCode, xmlResult.value.stderr));
|
|
30812
|
-
}
|
|
30813
|
-
const jsonResult = xmlToJson(xmlResult.value.stdout);
|
|
30814
|
-
if (!jsonResult.ok) {
|
|
30815
|
-
return err(jsonResult.error);
|
|
30816
|
-
}
|
|
30817
|
-
return ok({ data: jsonResult.value, source: "xml" });
|
|
30830
|
+
return result;
|
|
30818
30831
|
}
|
|
30819
30832
|
async function tryDirectPath(inputPath, timeoutMs, signal, verbosity) {
|
|
30820
30833
|
const jsonBinary = resolveBinary("dcm2json");
|
|
@@ -30999,7 +31012,8 @@ var DicomInstance = class _DicomInstance {
|
|
|
30999
31012
|
const jsonResult = await dcm2json(path, {
|
|
31000
31013
|
timeoutMs: options?.timeoutMs ?? DEFAULT_TIMEOUT_MS,
|
|
31001
31014
|
signal: options?.signal,
|
|
31002
|
-
charsetAssume: options?.charsetAssume
|
|
31015
|
+
charsetAssume: options?.charsetAssume,
|
|
31016
|
+
charsetFallback: options?.charsetFallback
|
|
31003
31017
|
});
|
|
31004
31018
|
if (!jsonResult.ok) return err(jsonResult.error);
|
|
31005
31019
|
const datasetResult = DicomDataset.fromJson(jsonResult.value.data);
|