@ubercode/dcmtk 0.5.0 → 0.6.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-CGBr3a-C.d.ts → DicomInstance-BjrSIEGN.d.ts} +50 -2
- package/dist/{DicomInstance-DWOjhccQ.d.cts → DicomInstance-zsmyd7fs.d.cts} +50 -2
- package/dist/{dcmodify-BvaIeyJg.d.ts → dcmodify-CHvwChFu.d.ts} +1 -1
- package/dist/{dcmodify-B9js5K1f.d.cts → dcmodify-Cf-RPHF3.d.cts} +1 -1
- package/dist/dicom.cjs +72 -7
- package/dist/dicom.cjs.map +1 -1
- package/dist/dicom.d.cts +3 -3
- package/dist/dicom.d.ts +3 -3
- package/dist/dicom.js +72 -7
- package/dist/dicom.js.map +1 -1
- package/dist/{index-DbUfqT7o.d.cts → index-BuGhfFlQ.d.cts} +1 -1
- package/dist/{index-CsYd7SMF.d.ts → index-DylL4aB-.d.ts} +1 -1
- package/dist/index.cjs +73 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +73 -8
- package/dist/index.js.map +1 -1
- package/dist/servers.cjs +72 -7
- package/dist/servers.cjs.map +1 -1
- package/dist/servers.d.cts +3 -3
- package/dist/servers.d.ts +3 -3
- package/dist/servers.js +72 -7
- package/dist/servers.js.map +1 -1
- package/dist/tools.cjs +24 -7
- package/dist/tools.cjs.map +1 -1
- package/dist/tools.d.cts +2 -2
- package/dist/tools.d.ts +2 -2
- package/dist/tools.js +24 -7
- package/dist/tools.js.map +1 -1
- package/package.json +1 -1
package/dist/dicom.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { D as DicomTag, a as DicomTagPath } from './DicomInstance-
|
|
2
|
-
export { C as ChangeSet, b as DicomDataset, d as DicomInstance } from './DicomInstance-
|
|
3
|
-
export { x as xmlToJson } from './dcmodify-
|
|
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';
|
|
3
|
+
export { x as xmlToJson } from './dcmodify-Cf-RPHF3.cjs';
|
|
4
4
|
import './types-Cgumy1N4.cjs';
|
|
5
5
|
|
|
6
6
|
/**
|
package/dist/dicom.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { D as DicomTag, a as DicomTagPath } from './DicomInstance-
|
|
2
|
-
export { C as ChangeSet, b as DicomDataset, d as DicomInstance } from './DicomInstance-
|
|
3
|
-
export { x as xmlToJson } from './dcmodify-
|
|
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';
|
|
3
|
+
export { x as xmlToJson } from './dcmodify-CHvwChFu.js';
|
|
4
4
|
import './types-Cgumy1N4.js';
|
|
5
5
|
|
|
6
6
|
/**
|
package/dist/dicom.js
CHANGED
|
@@ -29719,6 +29719,45 @@ function segmentsToModifyPath(segments) {
|
|
|
29719
29719
|
function segmentsToString(segments) {
|
|
29720
29720
|
return segmentsToModifyPath(segments);
|
|
29721
29721
|
}
|
|
29722
|
+
|
|
29723
|
+
// src/dicom/walkTags.ts
|
|
29724
|
+
var DEFAULT_MAX_DEPTH = 16;
|
|
29725
|
+
function walkTags(data, options) {
|
|
29726
|
+
const ctx = {
|
|
29727
|
+
maxDepth: options?.maxDepth ?? DEFAULT_MAX_DEPTH,
|
|
29728
|
+
vrSet: options?.vrFilter !== void 0 ? new Set(options.vrFilter) : void 0,
|
|
29729
|
+
results: []
|
|
29730
|
+
};
|
|
29731
|
+
walkLevel(data, 0, "", ctx);
|
|
29732
|
+
return ctx.results;
|
|
29733
|
+
}
|
|
29734
|
+
function walkLevel(data, depth, pathPrefix, ctx) {
|
|
29735
|
+
const keys = Object.keys(data);
|
|
29736
|
+
for (let i = 0; i < keys.length; i++) {
|
|
29737
|
+
const tag = keys[i];
|
|
29738
|
+
if (tag === void 0) continue;
|
|
29739
|
+
const element = data[tag];
|
|
29740
|
+
if (element === void 0) continue;
|
|
29741
|
+
const vr = element.vr;
|
|
29742
|
+
const path = pathPrefix.length > 0 ? `${pathPrefix}.${tag}` : tag;
|
|
29743
|
+
if (ctx.vrSet === void 0 || ctx.vrSet.has(vr)) {
|
|
29744
|
+
ctx.results.push({ tag, element, vr, depth, path });
|
|
29745
|
+
}
|
|
29746
|
+
if (vr === "SQ" && element.Value !== void 0 && depth < ctx.maxDepth) {
|
|
29747
|
+
walkSequenceItems(element.Value, depth, path, ctx);
|
|
29748
|
+
}
|
|
29749
|
+
}
|
|
29750
|
+
}
|
|
29751
|
+
function walkSequenceItems(items, depth, parentPath, ctx) {
|
|
29752
|
+
for (let idx = 0; idx < items.length; idx++) {
|
|
29753
|
+
const item = items[idx];
|
|
29754
|
+
if (typeof item !== "object" || item === null) continue;
|
|
29755
|
+
const itemPath = `${parentPath}[${idx}]`;
|
|
29756
|
+
walkLevel(item, depth + 1, itemPath, ctx);
|
|
29757
|
+
}
|
|
29758
|
+
}
|
|
29759
|
+
|
|
29760
|
+
// src/dicom/DicomDataset.ts
|
|
29722
29761
|
var HEX_TAG_KEY = /^[0-9A-Fa-f]{8}$/;
|
|
29723
29762
|
function isDicomJsonElement(value) {
|
|
29724
29763
|
return typeof value === "object" && value !== null && "vr" in value && typeof value["vr"] === "string";
|
|
@@ -30047,6 +30086,15 @@ var DicomDataset = class _DicomDataset {
|
|
|
30047
30086
|
const result = collectWildcard(this.data, segments);
|
|
30048
30087
|
return result.values;
|
|
30049
30088
|
}
|
|
30089
|
+
/**
|
|
30090
|
+
* Walks all tags in this dataset, optionally filtering by VR and recursing into sequences.
|
|
30091
|
+
*
|
|
30092
|
+
* @param options - Optional VR filter and max depth
|
|
30093
|
+
* @returns A readonly array of all matching tag entries
|
|
30094
|
+
*/
|
|
30095
|
+
walkTags(options) {
|
|
30096
|
+
return walkTags(this.data, options);
|
|
30097
|
+
}
|
|
30050
30098
|
// -----------------------------------------------------------------------
|
|
30051
30099
|
// Convenience readonly getters
|
|
30052
30100
|
// -----------------------------------------------------------------------
|
|
@@ -30608,15 +30656,32 @@ function convertSequence(attr, element) {
|
|
|
30608
30656
|
}
|
|
30609
30657
|
if (values.length > 0) element.Value = values;
|
|
30610
30658
|
}
|
|
30611
|
-
|
|
30659
|
+
var NUMERIC_JSON_VRS = /* @__PURE__ */ new Set(["DS", "FL", "FD", "IS", "SL", "SS", "SV", "UL", "US", "UV"]);
|
|
30660
|
+
function unwrapValue(v) {
|
|
30661
|
+
if (typeof v !== "object" || v === null) return v;
|
|
30662
|
+
const obj = v;
|
|
30663
|
+
if ("#text" in obj) return obj["#text"];
|
|
30664
|
+
const keys = Object.keys(obj);
|
|
30665
|
+
if (keys.length === 1 && keys[0] !== void 0 && keys[0].startsWith("@_")) {
|
|
30666
|
+
return obj[keys[0]];
|
|
30667
|
+
}
|
|
30668
|
+
return v;
|
|
30669
|
+
}
|
|
30670
|
+
function coerceNumeric(value) {
|
|
30671
|
+
if (typeof value === "number") return value;
|
|
30672
|
+
if (typeof value !== "string") return value;
|
|
30673
|
+
const trimmed = value.trim();
|
|
30674
|
+
if (trimmed.length === 0) return value;
|
|
30675
|
+
const num = Number(trimmed);
|
|
30676
|
+
return Number.isNaN(num) ? value : num;
|
|
30677
|
+
}
|
|
30678
|
+
function convertRegularValue(attr, element, vr) {
|
|
30612
30679
|
const valArray = toArray(attr.Value);
|
|
30613
30680
|
const values = [];
|
|
30681
|
+
const isNumeric = NUMERIC_JSON_VRS.has(vr);
|
|
30614
30682
|
for (const v of valArray) {
|
|
30615
|
-
|
|
30616
|
-
|
|
30617
|
-
} else {
|
|
30618
|
-
values.push(v);
|
|
30619
|
-
}
|
|
30683
|
+
const unwrapped = unwrapValue(v);
|
|
30684
|
+
values.push(isNumeric ? coerceNumeric(unwrapped) : unwrapped);
|
|
30620
30685
|
}
|
|
30621
30686
|
if (values.length > 0) element.Value = values;
|
|
30622
30687
|
}
|
|
@@ -30633,7 +30698,7 @@ function convertElement(attr) {
|
|
|
30633
30698
|
} else if (element.vr === "SQ" && attr.Item !== void 0) {
|
|
30634
30699
|
convertSequence(attr, element);
|
|
30635
30700
|
} else if (attr.Value !== void 0) {
|
|
30636
|
-
convertRegularValue(attr, element);
|
|
30701
|
+
convertRegularValue(attr, element, vr);
|
|
30637
30702
|
}
|
|
30638
30703
|
return Object.freeze(element);
|
|
30639
30704
|
}
|