@ubercode/dcmtk 0.8.0 → 0.8.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/dist/dicom.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { D as DicomTag, a as DicomTagPath } from './DicomInstance-zsmyd7fs.cjs';
2
- export { C as ChangeSet, b as DicomDataset, d as DicomInstance } from './DicomInstance-zsmyd7fs.cjs';
1
+ import { D as DicomTag, a as DicomTagPath } from './DicomInstance-CxLKC-oM.cjs';
2
+ export { C as ChangeSet, b as DicomDataset, d as DicomInstance, e as DicomOpenOptions } from './DicomInstance-CxLKC-oM.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-BjrSIEGN.js';
2
- export { C as ChangeSet, b as DicomDataset, d as DicomInstance } from './DicomInstance-BjrSIEGN.js';
1
+ import { D as DicomTag, a as DicomTagPath } from './DicomInstance-BKUiir0G.js';
2
+ export { C as ChangeSet, b as DicomDataset, d as DicomInstance, e as DicomOpenOptions } from './DicomInstance-BKUiir0G.js';
3
3
  export { x as xmlToJson } from './dcmodify-CHvwChFu.js';
4
4
  import './types-Cgumy1N4.js';
5
5
 
package/dist/dicom.js CHANGED
@@ -30778,6 +30778,7 @@ var Dcm2jsonOptionsSchema = z.object({
30778
30778
  timeoutMs: z.number().int().positive().optional(),
30779
30779
  signal: z.instanceof(AbortSignal).optional(),
30780
30780
  directOnly: z.boolean().optional(),
30781
+ charsetAssume: z.string().min(1).optional(),
30781
30782
  verbosity: z.enum(["verbose", "debug"]).optional()
30782
30783
  }).strict().optional();
30783
30784
  var VERBOSITY_FLAGS = { verbose: "-v", debug: "-d" };
@@ -30787,12 +30788,19 @@ function buildVerbosityArgs(verbosity) {
30787
30788
  }
30788
30789
  return [];
30789
30790
  }
30790
- async function tryXmlPath(inputPath, timeoutMs, signal, verbosity) {
30791
+ function buildXmlOpts(options) {
30792
+ const result = {};
30793
+ if (options?.verbosity !== void 0) result["verbosity"] = options.verbosity;
30794
+ if (options?.charsetAssume !== void 0) result["charsetAssume"] = options.charsetAssume;
30795
+ return result;
30796
+ }
30797
+ async function tryXmlPath(inputPath, timeoutMs, signal, opts) {
30791
30798
  const xmlBinary = resolveBinary("dcm2xml");
30792
30799
  if (!xmlBinary.ok) {
30793
30800
  return err(xmlBinary.error);
30794
30801
  }
30795
- const xmlArgs = [...buildVerbosityArgs(verbosity), "-nat", inputPath];
30802
+ const charsetArgs = opts?.charsetAssume !== void 0 ? ["+Ca", opts.charsetAssume] : [];
30803
+ const xmlArgs = [...buildVerbosityArgs(opts?.verbosity), ...charsetArgs, "-nat", inputPath];
30796
30804
  const xmlResult = await execCommand(xmlBinary.value, xmlArgs, { timeoutMs, signal });
30797
30805
  if (!xmlResult.ok) {
30798
30806
  return err(xmlResult.error);
@@ -30811,7 +30819,7 @@ async function tryDirectPath(inputPath, timeoutMs, signal, verbosity) {
30811
30819
  if (!jsonBinary.ok) {
30812
30820
  return err(jsonBinary.error);
30813
30821
  }
30814
- const directArgs = [...buildVerbosityArgs(verbosity), inputPath];
30822
+ const directArgs = [...buildVerbosityArgs(verbosity), "+b", inputPath];
30815
30823
  const result = await execCommand(jsonBinary.value, directArgs, { timeoutMs, signal });
30816
30824
  if (!result.ok) {
30817
30825
  return err(result.error);
@@ -30838,7 +30846,7 @@ async function dcm2json(inputPath, options) {
30838
30846
  if (options?.directOnly === true) {
30839
30847
  return tryDirectPath(inputPath, timeoutMs, signal, verbosity);
30840
30848
  }
30841
- const xmlResult = await tryXmlPath(inputPath, timeoutMs, signal, verbosity);
30849
+ const xmlResult = await tryXmlPath(inputPath, timeoutMs, signal, buildXmlOpts(options));
30842
30850
  if (xmlResult.ok) {
30843
30851
  return xmlResult;
30844
30852
  }
@@ -30967,7 +30975,7 @@ var DicomInstance = class _DicomInstance {
30967
30975
  * Opens a DICOM file and creates a DicomInstance.
30968
30976
  *
30969
30977
  * @param path - Filesystem path to the DICOM file
30970
- * @param options - Timeout and abort options
30978
+ * @param options - Timeout, abort, and charset options
30971
30979
  * @returns A Result containing the DicomInstance or an error
30972
30980
  */
30973
30981
  static async open(path, options) {
@@ -30975,7 +30983,8 @@ var DicomInstance = class _DicomInstance {
30975
30983
  if (!filePathResult.ok) return err(filePathResult.error);
30976
30984
  const jsonResult = await dcm2json(path, {
30977
30985
  timeoutMs: options?.timeoutMs ?? DEFAULT_TIMEOUT_MS,
30978
- signal: options?.signal
30986
+ signal: options?.signal,
30987
+ charsetAssume: options?.charsetAssume
30979
30988
  });
30980
30989
  if (!jsonResult.ok) return err(jsonResult.error);
30981
30990
  const datasetResult = DicomDataset.fromJson(jsonResult.value.data);