@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/servers.cjs CHANGED
@@ -2267,6 +2267,7 @@ var Dcm2jsonOptionsSchema = zod.z.object({
2267
2267
  timeoutMs: zod.z.number().int().positive().optional(),
2268
2268
  signal: zod.z.instanceof(AbortSignal).optional(),
2269
2269
  directOnly: zod.z.boolean().optional(),
2270
+ charsetAssume: zod.z.string().min(1).optional(),
2270
2271
  verbosity: zod.z.enum(["verbose", "debug"]).optional()
2271
2272
  }).strict().optional();
2272
2273
  var VERBOSITY_FLAGS = { verbose: "-v", debug: "-d" };
@@ -2276,12 +2277,19 @@ function buildVerbosityArgs(verbosity) {
2276
2277
  }
2277
2278
  return [];
2278
2279
  }
2279
- async function tryXmlPath(inputPath, timeoutMs, signal, verbosity) {
2280
+ function buildXmlOpts(options) {
2281
+ const result = {};
2282
+ if (options?.verbosity !== void 0) result["verbosity"] = options.verbosity;
2283
+ if (options?.charsetAssume !== void 0) result["charsetAssume"] = options.charsetAssume;
2284
+ return result;
2285
+ }
2286
+ async function tryXmlPath(inputPath, timeoutMs, signal, opts) {
2280
2287
  const xmlBinary = resolveBinary("dcm2xml");
2281
2288
  if (!xmlBinary.ok) {
2282
2289
  return err(xmlBinary.error);
2283
2290
  }
2284
- const xmlArgs = [...buildVerbosityArgs(verbosity), "-nat", inputPath];
2291
+ const charsetArgs = opts?.charsetAssume !== void 0 ? ["+Ca", opts.charsetAssume] : [];
2292
+ const xmlArgs = [...buildVerbosityArgs(opts?.verbosity), ...charsetArgs, "-nat", inputPath];
2285
2293
  const xmlResult = await execCommand(xmlBinary.value, xmlArgs, { timeoutMs, signal });
2286
2294
  if (!xmlResult.ok) {
2287
2295
  return err(xmlResult.error);
@@ -2327,7 +2335,7 @@ async function dcm2json(inputPath, options) {
2327
2335
  if (options?.directOnly === true) {
2328
2336
  return tryDirectPath(inputPath, timeoutMs, signal, verbosity);
2329
2337
  }
2330
- const xmlResult = await tryXmlPath(inputPath, timeoutMs, signal, verbosity);
2338
+ const xmlResult = await tryXmlPath(inputPath, timeoutMs, signal, buildXmlOpts(options));
2331
2339
  if (xmlResult.ok) {
2332
2340
  return xmlResult;
2333
2341
  }
@@ -2456,7 +2464,7 @@ var DicomInstance = class _DicomInstance {
2456
2464
  * Opens a DICOM file and creates a DicomInstance.
2457
2465
  *
2458
2466
  * @param path - Filesystem path to the DICOM file
2459
- * @param options - Timeout and abort options
2467
+ * @param options - Timeout, abort, and charset options
2460
2468
  * @returns A Result containing the DicomInstance or an error
2461
2469
  */
2462
2470
  static async open(path2, options) {
@@ -2464,7 +2472,8 @@ var DicomInstance = class _DicomInstance {
2464
2472
  if (!filePathResult.ok) return err(filePathResult.error);
2465
2473
  const jsonResult = await dcm2json(path2, {
2466
2474
  timeoutMs: options?.timeoutMs ?? DEFAULT_TIMEOUT_MS,
2467
- signal: options?.signal
2475
+ signal: options?.signal,
2476
+ charsetAssume: options?.charsetAssume
2468
2477
  });
2469
2478
  if (!jsonResult.ok) return err(jsonResult.error);
2470
2479
  const datasetResult = DicomDataset.fromJson(jsonResult.value.data);