@ubercode/dcmtk 0.8.0 → 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.
@@ -1,7 +1,7 @@
1
1
  import { L as LineSource, R as Result } from './types-Cgumy1N4.cjs';
2
2
  import { EventEmitter } from 'node:events';
3
3
  import * as net from 'node:net';
4
- import { d as DicomInstance } from './DicomInstance-zsmyd7fs.cjs';
4
+ import { d as DicomInstance } from './DicomInstance-CxLKC-oM.cjs';
5
5
 
6
6
  /**
7
7
  * Base class for long-lived DCMTK processes (servers).
@@ -1,7 +1,7 @@
1
1
  import { L as LineSource, R as Result } from './types-Cgumy1N4.js';
2
2
  import { EventEmitter } from 'node:events';
3
3
  import * as net from 'node:net';
4
- import { d as DicomInstance } from './DicomInstance-BjrSIEGN.js';
4
+ import { d as DicomInstance } from './DicomInstance-BKUiir0G.js';
5
5
 
6
6
  /**
7
7
  * Base class for long-lived DCMTK processes (servers).
package/dist/index.cjs CHANGED
@@ -31184,6 +31184,7 @@ var Dcm2xmlOptionsSchema = zod.z.object({
31184
31184
  charset: zod.z.enum(["utf8", "latin1", "ascii"]).optional(),
31185
31185
  writeBinaryData: zod.z.boolean().optional(),
31186
31186
  encodeBinaryBase64: zod.z.boolean().optional(),
31187
+ charsetAssume: zod.z.string().min(1).optional(),
31187
31188
  verbosity: zod.z.enum(["verbose", "debug"]).optional()
31188
31189
  }).strict().optional();
31189
31190
  function pushEncodingArgs(args, options) {
@@ -31207,6 +31208,9 @@ function buildArgs(inputPath, options) {
31207
31208
  if (options?.namespace === true) {
31208
31209
  args.push("+Xn");
31209
31210
  }
31211
+ if (options?.charsetAssume !== void 0) {
31212
+ args.push("+Ca", options.charsetAssume);
31213
+ }
31210
31214
  pushEncodingArgs(args, options);
31211
31215
  args.push(inputPath);
31212
31216
  return args;
@@ -31456,6 +31460,7 @@ var Dcm2jsonOptionsSchema = zod.z.object({
31456
31460
  timeoutMs: zod.z.number().int().positive().optional(),
31457
31461
  signal: zod.z.instanceof(AbortSignal).optional(),
31458
31462
  directOnly: zod.z.boolean().optional(),
31463
+ charsetAssume: zod.z.string().min(1).optional(),
31459
31464
  verbosity: zod.z.enum(["verbose", "debug"]).optional()
31460
31465
  }).strict().optional();
31461
31466
  var VERBOSITY_FLAGS2 = { verbose: "-v", debug: "-d" };
@@ -31465,12 +31470,19 @@ function buildVerbosityArgs(verbosity) {
31465
31470
  }
31466
31471
  return [];
31467
31472
  }
31468
- async function tryXmlPath(inputPath, timeoutMs, signal, verbosity) {
31473
+ function buildXmlOpts(options) {
31474
+ const result = {};
31475
+ if (options?.verbosity !== void 0) result["verbosity"] = options.verbosity;
31476
+ if (options?.charsetAssume !== void 0) result["charsetAssume"] = options.charsetAssume;
31477
+ return result;
31478
+ }
31479
+ async function tryXmlPath(inputPath, timeoutMs, signal, opts) {
31469
31480
  const xmlBinary = resolveBinary("dcm2xml");
31470
31481
  if (!xmlBinary.ok) {
31471
31482
  return err(xmlBinary.error);
31472
31483
  }
31473
- const xmlArgs = [...buildVerbosityArgs(verbosity), "-nat", inputPath];
31484
+ const charsetArgs = opts?.charsetAssume !== void 0 ? ["+Ca", opts.charsetAssume] : [];
31485
+ const xmlArgs = [...buildVerbosityArgs(opts?.verbosity), ...charsetArgs, "-nat", inputPath];
31474
31486
  const xmlResult = await execCommand(xmlBinary.value, xmlArgs, { timeoutMs, signal });
31475
31487
  if (!xmlResult.ok) {
31476
31488
  return err(xmlResult.error);
@@ -31516,7 +31528,7 @@ async function dcm2json(inputPath, options) {
31516
31528
  if (options?.directOnly === true) {
31517
31529
  return tryDirectPath(inputPath, timeoutMs, signal, verbosity);
31518
31530
  }
31519
- const xmlResult = await tryXmlPath(inputPath, timeoutMs, signal, verbosity);
31531
+ const xmlResult = await tryXmlPath(inputPath, timeoutMs, signal, buildXmlOpts(options));
31520
31532
  if (xmlResult.ok) {
31521
31533
  return xmlResult;
31522
31534
  }
@@ -34351,7 +34363,7 @@ var DicomInstance = class _DicomInstance {
34351
34363
  * Opens a DICOM file and creates a DicomInstance.
34352
34364
  *
34353
34365
  * @param path - Filesystem path to the DICOM file
34354
- * @param options - Timeout and abort options
34366
+ * @param options - Timeout, abort, and charset options
34355
34367
  * @returns A Result containing the DicomInstance or an error
34356
34368
  */
34357
34369
  static async open(path2, options) {
@@ -34359,7 +34371,8 @@ var DicomInstance = class _DicomInstance {
34359
34371
  if (!filePathResult.ok) return err(filePathResult.error);
34360
34372
  const jsonResult = await dcm2json(path2, {
34361
34373
  timeoutMs: options?.timeoutMs ?? DEFAULT_TIMEOUT_MS,
34362
- signal: options?.signal
34374
+ signal: options?.signal,
34375
+ charsetAssume: options?.charsetAssume
34363
34376
  });
34364
34377
  if (!jsonResult.ok) return err(jsonResult.error);
34365
34378
  const datasetResult = DicomDataset.fromJson(jsonResult.value.data);