@ubercode/dcmtk 0.7.3 → 0.8.1
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-BjrSIEGN.d.ts → DicomInstance-BKUiir0G.d.ts} +8 -3
- package/dist/{DicomInstance-zsmyd7fs.d.cts → DicomInstance-CxLKC-oM.d.cts} +8 -3
- package/dist/dicom.cjs +14 -5
- 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 +14 -5
- package/dist/dicom.js.map +1 -1
- package/dist/{index-AYvUunlI.d.cts → index-B13DmBRs.d.cts} +1 -1
- package/dist/{index-C20fLU5U.d.ts → index-CCgNgve7.d.ts} +1 -1
- package/dist/index.cjs +614 -295
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +201 -60
- package/dist/index.d.ts +201 -60
- package/dist/index.js +614 -296
- package/dist/index.js.map +1 -1
- package/dist/servers.cjs +14 -5
- 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 +14 -5
- package/dist/servers.js.map +1 -1
- package/dist/tools.cjs +53 -3
- package/dist/tools.cjs.map +1 -1
- package/dist/tools.d.cts +18 -0
- package/dist/tools.d.ts +18 -0
- package/dist/tools.js +53 -3
- package/dist/tools.js.map +1 -1
- package/package.json +2 -2
|
@@ -458,6 +458,11 @@ interface FileIOOptions {
|
|
|
458
458
|
/** AbortSignal for external cancellation. */
|
|
459
459
|
readonly signal?: AbortSignal | undefined;
|
|
460
460
|
}
|
|
461
|
+
/** Options for opening a DICOM file. Extends FileIOOptions with read-specific settings. */
|
|
462
|
+
interface DicomOpenOptions extends FileIOOptions {
|
|
463
|
+
/** Assume the specified character set when SpecificCharacterSet (0008,0005) is absent. Maps to dcm2xml `+Ca`. */
|
|
464
|
+
readonly charsetAssume?: string | undefined;
|
|
465
|
+
}
|
|
461
466
|
|
|
462
467
|
/**
|
|
463
468
|
* Unified DICOM object composing DicomDataset + ChangeSet + file I/O.
|
|
@@ -497,10 +502,10 @@ declare class DicomInstance {
|
|
|
497
502
|
* Opens a DICOM file and creates a DicomInstance.
|
|
498
503
|
*
|
|
499
504
|
* @param path - Filesystem path to the DICOM file
|
|
500
|
-
* @param options - Timeout and
|
|
505
|
+
* @param options - Timeout, abort, and charset options
|
|
501
506
|
* @returns A Result containing the DicomInstance or an error
|
|
502
507
|
*/
|
|
503
|
-
static open(path: string, options?:
|
|
508
|
+
static open(path: string, options?: DicomOpenOptions): Promise<Result<DicomInstance>>;
|
|
504
509
|
/**
|
|
505
510
|
* Creates a DicomInstance from an existing DicomDataset.
|
|
506
511
|
*
|
|
@@ -670,4 +675,4 @@ declare class DicomInstance {
|
|
|
670
675
|
getMetadata(key: string): unknown;
|
|
671
676
|
}
|
|
672
677
|
|
|
673
|
-
export { type AETitle as A, type Brand as B, ChangeSet as C, type DicomTag as D, type Port as P, type SOPClassUID as S, type TransferSyntaxUID as T, type WalkTagEntry as W, type DicomTagPath as a, DicomDataset as b, type DicomFilePath as c, DicomInstance as d, type
|
|
678
|
+
export { type AETitle as A, type Brand as B, ChangeSet as C, type DicomTag as D, type Port as P, type SOPClassUID as S, type TransferSyntaxUID as T, type WalkTagEntry as W, type DicomTagPath as a, DicomDataset as b, type DicomFilePath as c, DicomInstance as d, type DicomOpenOptions as e, type WalkTagsOptions as f, createAETitle as g, createDicomFilePath as h, createDicomTag as i, createDicomTagPath as j, createPort as k, createSOPClassUID as l, createTransferSyntaxUID as m, tag as t, walkTags as w };
|
|
@@ -458,6 +458,11 @@ interface FileIOOptions {
|
|
|
458
458
|
/** AbortSignal for external cancellation. */
|
|
459
459
|
readonly signal?: AbortSignal | undefined;
|
|
460
460
|
}
|
|
461
|
+
/** Options for opening a DICOM file. Extends FileIOOptions with read-specific settings. */
|
|
462
|
+
interface DicomOpenOptions extends FileIOOptions {
|
|
463
|
+
/** Assume the specified character set when SpecificCharacterSet (0008,0005) is absent. Maps to dcm2xml `+Ca`. */
|
|
464
|
+
readonly charsetAssume?: string | undefined;
|
|
465
|
+
}
|
|
461
466
|
|
|
462
467
|
/**
|
|
463
468
|
* Unified DICOM object composing DicomDataset + ChangeSet + file I/O.
|
|
@@ -497,10 +502,10 @@ declare class DicomInstance {
|
|
|
497
502
|
* Opens a DICOM file and creates a DicomInstance.
|
|
498
503
|
*
|
|
499
504
|
* @param path - Filesystem path to the DICOM file
|
|
500
|
-
* @param options - Timeout and
|
|
505
|
+
* @param options - Timeout, abort, and charset options
|
|
501
506
|
* @returns A Result containing the DicomInstance or an error
|
|
502
507
|
*/
|
|
503
|
-
static open(path: string, options?:
|
|
508
|
+
static open(path: string, options?: DicomOpenOptions): Promise<Result<DicomInstance>>;
|
|
504
509
|
/**
|
|
505
510
|
* Creates a DicomInstance from an existing DicomDataset.
|
|
506
511
|
*
|
|
@@ -670,4 +675,4 @@ declare class DicomInstance {
|
|
|
670
675
|
getMetadata(key: string): unknown;
|
|
671
676
|
}
|
|
672
677
|
|
|
673
|
-
export { type AETitle as A, type Brand as B, ChangeSet as C, type DicomTag as D, type Port as P, type SOPClassUID as S, type TransferSyntaxUID as T, type WalkTagEntry as W, type DicomTagPath as a, DicomDataset as b, type DicomFilePath as c, DicomInstance as d, type
|
|
678
|
+
export { type AETitle as A, type Brand as B, ChangeSet as C, type DicomTag as D, type Port as P, type SOPClassUID as S, type TransferSyntaxUID as T, type WalkTagEntry as W, type DicomTagPath as a, DicomDataset as b, type DicomFilePath as c, DicomInstance as d, type DicomOpenOptions as e, type WalkTagsOptions as f, createAETitle as g, createDicomFilePath as h, createDicomTag as i, createDicomTagPath as j, createPort as k, createSOPClassUID as l, createTransferSyntaxUID as m, tag as t, walkTags as w };
|
package/dist/dicom.cjs
CHANGED
|
@@ -30784,6 +30784,7 @@ var Dcm2jsonOptionsSchema = zod.z.object({
|
|
|
30784
30784
|
timeoutMs: zod.z.number().int().positive().optional(),
|
|
30785
30785
|
signal: zod.z.instanceof(AbortSignal).optional(),
|
|
30786
30786
|
directOnly: zod.z.boolean().optional(),
|
|
30787
|
+
charsetAssume: zod.z.string().min(1).optional(),
|
|
30787
30788
|
verbosity: zod.z.enum(["verbose", "debug"]).optional()
|
|
30788
30789
|
}).strict().optional();
|
|
30789
30790
|
var VERBOSITY_FLAGS = { verbose: "-v", debug: "-d" };
|
|
@@ -30793,12 +30794,19 @@ function buildVerbosityArgs(verbosity) {
|
|
|
30793
30794
|
}
|
|
30794
30795
|
return [];
|
|
30795
30796
|
}
|
|
30796
|
-
|
|
30797
|
+
function buildXmlOpts(options) {
|
|
30798
|
+
const result = {};
|
|
30799
|
+
if (options?.verbosity !== void 0) result["verbosity"] = options.verbosity;
|
|
30800
|
+
if (options?.charsetAssume !== void 0) result["charsetAssume"] = options.charsetAssume;
|
|
30801
|
+
return result;
|
|
30802
|
+
}
|
|
30803
|
+
async function tryXmlPath(inputPath, timeoutMs, signal, opts) {
|
|
30797
30804
|
const xmlBinary = resolveBinary("dcm2xml");
|
|
30798
30805
|
if (!xmlBinary.ok) {
|
|
30799
30806
|
return err(xmlBinary.error);
|
|
30800
30807
|
}
|
|
30801
|
-
const
|
|
30808
|
+
const charsetArgs = opts?.charsetAssume !== void 0 ? ["+Ca", opts.charsetAssume] : [];
|
|
30809
|
+
const xmlArgs = [...buildVerbosityArgs(opts?.verbosity), ...charsetArgs, "-nat", inputPath];
|
|
30802
30810
|
const xmlResult = await execCommand(xmlBinary.value, xmlArgs, { timeoutMs, signal });
|
|
30803
30811
|
if (!xmlResult.ok) {
|
|
30804
30812
|
return err(xmlResult.error);
|
|
@@ -30844,7 +30852,7 @@ async function dcm2json(inputPath, options) {
|
|
|
30844
30852
|
if (options?.directOnly === true) {
|
|
30845
30853
|
return tryDirectPath(inputPath, timeoutMs, signal, verbosity);
|
|
30846
30854
|
}
|
|
30847
|
-
const xmlResult = await tryXmlPath(inputPath, timeoutMs, signal,
|
|
30855
|
+
const xmlResult = await tryXmlPath(inputPath, timeoutMs, signal, buildXmlOpts(options));
|
|
30848
30856
|
if (xmlResult.ok) {
|
|
30849
30857
|
return xmlResult;
|
|
30850
30858
|
}
|
|
@@ -30973,7 +30981,7 @@ var DicomInstance = class _DicomInstance {
|
|
|
30973
30981
|
* Opens a DICOM file and creates a DicomInstance.
|
|
30974
30982
|
*
|
|
30975
30983
|
* @param path - Filesystem path to the DICOM file
|
|
30976
|
-
* @param options - Timeout and
|
|
30984
|
+
* @param options - Timeout, abort, and charset options
|
|
30977
30985
|
* @returns A Result containing the DicomInstance or an error
|
|
30978
30986
|
*/
|
|
30979
30987
|
static async open(path, options) {
|
|
@@ -30981,7 +30989,8 @@ var DicomInstance = class _DicomInstance {
|
|
|
30981
30989
|
if (!filePathResult.ok) return err(filePathResult.error);
|
|
30982
30990
|
const jsonResult = await dcm2json(path, {
|
|
30983
30991
|
timeoutMs: options?.timeoutMs ?? DEFAULT_TIMEOUT_MS,
|
|
30984
|
-
signal: options?.signal
|
|
30992
|
+
signal: options?.signal,
|
|
30993
|
+
charsetAssume: options?.charsetAssume
|
|
30985
30994
|
});
|
|
30986
30995
|
if (!jsonResult.ok) return err(jsonResult.error);
|
|
30987
30996
|
const datasetResult = DicomDataset.fromJson(jsonResult.value.data);
|