@dcmjs-org/dicomdir 1.0.0-beta.15 → 1.0.0-beta.16

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/index.cjs CHANGED
@@ -36,7 +36,7 @@ const ITEM_DELIMITER_BYTES = 8; // FFFE,E00D + 4-byte zero length
36
36
 
37
37
  /** Bytes writeDataSet produces for one tag-keyed object. */
38
38
  function measure(jsonObject, writeOptions) {
39
- const stream = new core.WriteBufferStream(1024);
39
+ const stream = new core.WriteBufferStream({ defaultSize: 1024 });
40
40
  core.writeDataSet(jsonObject, stream, core.EXPLICIT_LITTLE_ENDIAN, writeOptions);
41
41
  return stream.size;
42
42
  }
@@ -60,7 +60,7 @@ function computeDirectoryOffsets(dicomDict, writeOptions) {
60
60
  // is measured with the real meta size as its value — UL again, so the
61
61
  // element size is value-independent, but measuring keeps zero assumptions.
62
62
  const metaSize = measure(dicomDict.meta, writeOptions);
63
- const groupLengthStream = new core.WriteBufferStream(64);
63
+ const groupLengthStream = new core.WriteBufferStream({ defaultSize: 64 });
64
64
  core.writeTagObject(
65
65
  groupLengthStream,
66
66
  core.TagHex.FileMetaInformationGroupLength,
@@ -416,11 +416,11 @@ function pinOffsetVRs(dict) {
416
416
  */
417
417
  function writePart10(meta, dict, writeOptions) {
418
418
  const metaSyntax = core.EXPLICIT_LITTLE_ENDIAN;
419
- const fileStream = new core.WriteBufferStream(4096, true);
419
+ const fileStream = new core.WriteBufferStream({ defaultSize: 4096 });
420
420
  fileStream.writeUint8Repeat(0, 128);
421
421
  fileStream.writeAsciiString("DICM");
422
422
 
423
- const metaStream = new core.WriteBufferStream(1024);
423
+ const metaStream = new core.WriteBufferStream({ defaultSize: 1024 });
424
424
  if (!meta[core.TagHex.TransferSyntaxUID]) {
425
425
  meta[core.TagHex.TransferSyntaxUID] = {
426
426
  vr: "UI",
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/directoryOffsets.js","../src/dicomdir.js","../src/index.js"],"sourcesContent":["// packages/dicomdir/src/directoryOffsets.js\n//\n// Byte-offset computation for DICOMDIR directory records.\n//\n// The load-bearing fact: every DICOMDIR offset attribute (0004,1200/1202/\n// 1400/1420) is VR UL — a fixed four-byte value — so the values NEVER affect\n// the byte layout. One measurement pass over the exact structures the final\n// write will serialize (same writer, same options, placeholder zeros)\n// therefore yields the exact offsets of the final file, and the file is\n// written once with the real values filled in.\n//\n// Layout being measured (mirrors the Part 10 envelope in dicomdir.js):\n// 128-byte preamble + \"DICM\"\n// FileMetaInformationGroupLength element\n// meta group (Explicit VR Little Endian)\n// body tags below (0004,1220), sorted ascending\n// (0004,1220) DirectoryRecordSequence: 12-byte SQ header (undefined\n// length), then per item: 8-byte item header (FFFE,E000, undefined\n// length) + item body + 8-byte item delimiter (FFFE,E00D) — see\n// SequenceOfItems.writeBytes — and a trailing 8-byte sequence delimiter.\n//\n// A directory-record offset points at the FFFE,E000 item tag of that record,\n// counted from byte 0 of the file (PS3.10 8.6).\n\nimport {\n WriteBufferStream,\n writeDataSet,\n writeTagObject,\n EXPLICIT_LITTLE_ENDIAN,\n TagHex\n} from \"@dcmjs-org/core\";\n\nconst DIRECTORY_RECORD_SEQUENCE = \"00041220\";\n\nconst ITEM_HEADER_BYTES = 8; // FFFE,E000 + 4-byte undefined length\nconst ITEM_DELIMITER_BYTES = 8; // FFFE,E00D + 4-byte zero length\n\n/** Bytes writeDataSet produces for one tag-keyed object. */\nfunction measure(jsonObject, writeOptions) {\n const stream = new WriteBufferStream(1024);\n writeDataSet(jsonObject, stream, EXPLICIT_LITTLE_ENDIAN, writeOptions);\n return stream.size;\n}\n\n/**\n * Compute the absolute byte offset of every directory record item in the\n * file the Part 10 envelope write will produce. Call with the offsets\n * still zero; patch the returned values in, then write — the layout is\n * guaranteed identical because offsets are fixed-width.\n *\n * @param {{ meta: Object, dict: Object }} dicomDict - denaturalized\n * DICOMDIR ({ meta, dict }) whose dict contains (0004,1220)\n * @param {Object} writeOptions - the SAME object later passed to write()\n * @returns {number[]} byte offset of each record's item tag, in item order\n */\nexport function computeDirectoryOffsets(dicomDict, writeOptions) {\n // Preamble + magic.\n let cursor = 128 + 4;\n\n // FileMetaInformationGroupLength + meta group. The group length element\n // is measured with the real meta size as its value — UL again, so the\n // element size is value-independent, but measuring keeps zero assumptions.\n const metaSize = measure(dicomDict.meta, writeOptions);\n const groupLengthStream = new WriteBufferStream(64);\n writeTagObject(\n groupLengthStream,\n TagHex.FileMetaInformationGroupLength,\n \"UL\",\n metaSize,\n EXPLICIT_LITTLE_ENDIAN,\n writeOptions\n );\n cursor += groupLengthStream.size + metaSize;\n\n // Body tags before the record sequence, in the writer's sorted order.\n const bodyTags = Object.keys(dicomDict.dict).sort();\n for (const tag of bodyTags) {\n if (tag >= DIRECTORY_RECORD_SEQUENCE) {\n break;\n }\n cursor += measure({ [tag]: dicomDict.dict[tag] }, writeOptions);\n }\n\n // SQ element header: measure an empty sequence (header + 8-byte\n // sequence delimiter) rather than assuming the 12-byte constant.\n const sequence = dicomDict.dict[DIRECTORY_RECORD_SEQUENCE];\n const emptySequenceSize = measure(\n { [DIRECTORY_RECORD_SEQUENCE]: { vr: \"SQ\", Value: [] } },\n writeOptions\n );\n cursor += emptySequenceSize - ITEM_DELIMITER_BYTES;\n\n const offsets = [];\n const items = (sequence && sequence.Value) || [];\n for (const item of items) {\n offsets.push(cursor);\n cursor +=\n ITEM_HEADER_BYTES +\n measure(item, writeOptions) +\n ITEM_DELIMITER_BYTES;\n }\n\n return offsets;\n}\n","// packages/dicomdir/src/dicomdir.js\n//\n// DICOMDIR (Media Storage Directory, PS3.10 / PS3.3 F) builder. Turns a flat\n// file-set description into the PATIENT -> STUDY -> SERIES -> leaf record\n// hierarchy and serializes it with real byte offsets in the three offset\n// attributes (OffsetOfTheNextDirectoryRecord, OffsetOfReferencedLowerLevel-\n// DirectoryEntity, and the root first/last record offsets).\n//\n// Offsets are computed by measure-then-write (see directoryOffsets.js): every\n// offset attribute is VR UL — fixed four bytes — so a measurement pass with\n// placeholder zeros produces the exact final layout, and the file is written\n// once. No patch-and-rewrite, no buffer scanning.\n\nimport {\n DicomMetaDictionary,\n WriteBufferStream,\n writeDataSet,\n writeTagObject,\n EXPLICIT_LITTLE_ENDIAN,\n TagHex\n} from \"@dcmjs-org/core\";\nimport { computeDirectoryOffsets } from \"./directoryOffsets.js\";\n\nconst MEDIA_STORAGE_DIRECTORY_SOP_CLASS_UID = \"1.2.840.10008.1.3.10\";\n\n// PS3.10 8.5: each File ID component is 1-8 characters from the ISO 9660\n// level 1 repertoire (A-Z, 0-9, underscore), at most 8 components deep.\nconst FILE_ID_COMPONENT = /^[A-Z0-9_]{1,8}$/;\n\nfunction assertEntry(entry, index) {\n const where = `buildDicomDirDataset: entries[${index}]`;\n if (!entry || typeof entry !== \"object\") {\n throw new Error(`${where} is not an object`);\n }\n if (\n !Array.isArray(entry.referencedFileID) ||\n !entry.referencedFileID.length\n ) {\n throw new Error(\n `${where}.referencedFileID must be a non-empty array of path components`\n );\n }\n for (const required of [\n \"sopClassUid\",\n \"sopInstanceUid\",\n \"transferSyntaxUid\"\n ]) {\n if (!entry[required]) {\n throw new Error(`${where}.${required} is required`);\n }\n }\n if (!entry.patient?.PatientID) {\n throw new Error(`${where}.patient.PatientID is required`);\n }\n if (!entry.study?.StudyInstanceUID) {\n throw new Error(`${where}.study.StudyInstanceUID is required`);\n }\n if (!entry.series?.SeriesInstanceUID) {\n throw new Error(`${where}.series.SeriesInstanceUID is required`);\n }\n}\n\nfunction assertFileID(components, index, allowNonConforming) {\n if (components.length > 8) {\n throw new Error(\n `buildDicomDirDataset: entries[${index}].referencedFileID has ` +\n `${components.length} components (max 8)`\n );\n }\n if (allowNonConforming) {\n return;\n }\n for (const component of components) {\n if (!FILE_ID_COMPONENT.test(component)) {\n throw new Error(\n `buildDicomDirDataset: entries[${index}].referencedFileID ` +\n `component \"${component}\" is not ISO 9660 level 1 ` +\n `conformant (A-Z 0-9 _, 1-8 chars) — rename the file or ` +\n `pass allowNonConformingFileIDs: true`\n );\n }\n }\n}\n\n/** The four keys every directory record starts with (PS3.3 F.3). */\nfunction recordCommon(recordType) {\n return {\n OffsetOfTheNextDirectoryRecord: 0,\n RecordInUseFlag: 0xffff,\n OffsetOfReferencedLowerLevelDirectoryEntity: 0,\n DirectoryRecordType: recordType\n };\n}\n\n/**\n * Group the flat entries into the PATIENT -> STUDY -> SERIES -> leaf tree,\n * preserving first-seen order at every level.\n */\nfunction groupEntries(entries, options) {\n const patients = new Map();\n entries.forEach((entry, index) => {\n assertEntry(entry, index);\n assertFileID(\n entry.referencedFileID,\n index,\n options.allowNonConformingFileIDs\n );\n\n const patientKey = entry.patient.PatientID;\n if (!patients.has(patientKey)) {\n patients.set(patientKey, {\n attributes: entry.patient,\n studies: new Map()\n });\n }\n const patient = patients.get(patientKey);\n\n const studyKey = entry.study.StudyInstanceUID;\n if (!patient.studies.has(studyKey)) {\n patient.studies.set(studyKey, {\n attributes: entry.study,\n series: new Map()\n });\n }\n const study = patient.studies.get(studyKey);\n\n const seriesKey = entry.series.SeriesInstanceUID;\n if (!study.series.has(seriesKey)) {\n study.series.set(seriesKey, {\n attributes: entry.series,\n leaves: []\n });\n }\n study.series.get(seriesKey).leaves.push(entry);\n });\n return patients;\n}\n\n/**\n * Flatten the tree depth-first into naturalized record objects, tracking the\n * flat index of each record's next sibling and first child so the offset\n * pass can wire the chains. Depth-first order means every link points\n * strictly forward in the file.\n *\n * @returns {{ records: Object[], links: Array<{next: number|null, child: number|null}> }}\n */\nfunction flattenRecords(patients) {\n const records = [];\n const links = [];\n\n const push = record => {\n records.push(record);\n links.push({ next: null, child: null });\n return records.length - 1;\n };\n\n const patientList = [...patients.values()];\n let previousPatientIndex = null;\n\n for (const patient of patientList) {\n const patientIndex = push({\n ...recordCommon(\"PATIENT\"),\n PatientName: patient.attributes.PatientName ?? \"\",\n PatientID: patient.attributes.PatientID\n });\n if (previousPatientIndex !== null) {\n links[previousPatientIndex].next = patientIndex;\n }\n previousPatientIndex = patientIndex;\n\n const studyList = [...patient.studies.values()];\n let previousStudyIndex = null;\n for (const study of studyList) {\n const studyIndex = push({\n ...recordCommon(\"STUDY\"),\n StudyDate: study.attributes.StudyDate ?? \"\",\n StudyTime: study.attributes.StudyTime ?? \"\",\n StudyDescription: study.attributes.StudyDescription ?? \"\",\n AccessionNumber: study.attributes.AccessionNumber ?? \"\",\n StudyInstanceUID: study.attributes.StudyInstanceUID,\n StudyID: study.attributes.StudyID ?? \"\"\n });\n if (previousStudyIndex === null) {\n links[patientIndex].child = studyIndex;\n } else {\n links[previousStudyIndex].next = studyIndex;\n }\n previousStudyIndex = studyIndex;\n\n const seriesList = [...study.series.values()];\n let previousSeriesIndex = null;\n for (const series of seriesList) {\n const seriesIndex = push({\n ...recordCommon(\"SERIES\"),\n Modality: series.attributes.Modality ?? \"OT\",\n SeriesInstanceUID: series.attributes.SeriesInstanceUID,\n SeriesNumber: series.attributes.SeriesNumber ?? 1\n });\n if (previousSeriesIndex === null) {\n links[studyIndex].child = seriesIndex;\n } else {\n links[previousSeriesIndex].next = seriesIndex;\n }\n previousSeriesIndex = seriesIndex;\n\n let previousLeafIndex = null;\n for (const entry of series.leaves) {\n const leafIndex = push({\n ...recordCommon(entry.recordType || \"IMAGE\"),\n ReferencedFileID: [...entry.referencedFileID],\n ReferencedSOPClassUIDInFile: entry.sopClassUid,\n ReferencedSOPInstanceUIDInFile: entry.sopInstanceUid,\n ReferencedTransferSyntaxUIDInFile:\n entry.transferSyntaxUid,\n InstanceNumber: entry.instance?.InstanceNumber ?? 1,\n ...entry.instance\n });\n if (previousLeafIndex === null) {\n links[seriesIndex].child = leafIndex;\n } else {\n links[previousLeafIndex].next = leafIndex;\n }\n previousLeafIndex = leafIndex;\n }\n }\n }\n }\n\n return { records, links };\n}\n\n/**\n * Build the naturalized DICOMDIR dataset (all offsets zero) plus the link\n * table the offset pass needs. Pure and inspectable — no serialization.\n *\n * @param {Array} entries - flat file-set entries; see module JSDoc/typedef\n * @param {Object} [options]\n * @param {string} [options.fileSetID=\"\"]\n * @param {boolean} [options.allowNonConformingFileIDs=false]\n * @returns {{ dataset: Object, links: Array, rootIndices: number[] }}\n */\nfunction buildDicomDirDataset(entries = [], options = {}) {\n const patients = groupEntries(entries, options);\n const { records, links } = flattenRecords(patients);\n\n const rootIndices = [];\n records.forEach((record, index) => {\n if (record.DirectoryRecordType === \"PATIENT\") {\n rootIndices.push(index);\n }\n });\n\n const dataset = {\n FileSetID: options.fileSetID ?? \"\",\n OffsetOfTheFirstDirectoryRecordOfTheRootDirectoryEntity: 0,\n OffsetOfTheLastDirectoryRecordOfTheRootDirectoryEntity: 0,\n FileSetConsistencyFlag: 0,\n DirectoryRecordSequence: records\n };\n\n return { dataset, links, rootIndices };\n}\n\n/** Mint the DICOMDIR file meta group (SOP identity lives here, not the body). */\nfunction buildDicomDirMeta(options = {}) {\n const fileMetaInformationVersion = new Uint8Array(2);\n fileMetaInformationVersion[1] = 1;\n return DicomMetaDictionary.denaturalizeDataset({\n FileMetaInformationVersion: fileMetaInformationVersion.buffer,\n MediaStorageSOPClassUID: MEDIA_STORAGE_DIRECTORY_SOP_CLASS_UID,\n MediaStorageSOPInstanceUID:\n options.fileSetUID || DicomMetaDictionary.uid(),\n TransferSyntaxUID: EXPLICIT_LITTLE_ENDIAN,\n ImplementationClassUID:\n \"2.25.80302813137786398554742050926734630921603366648225212145404\",\n ImplementationVersionName: \"dcmjs-0.0\"\n });\n}\n\n/**\n * Build and serialize a complete DICOMDIR: build the record tree,\n * denaturalize it, measure the layout, wire the offset chains, write once.\n *\n * @param {Array} entries - flat file-set entries\n * @param {Object} [options] - buildDicomDirDataset options plus\n * {string} [options.fileSetUID] fixed MediaStorageSOPInstanceUID\n * @returns {ArrayBuffer} the DICOMDIR file bytes\n */\n/**\n * The DICOM data dictionary gives the directory offset attributes the\n * special VR \"up\" (byte offset); the dcmjs writer has no \"up\" representation\n * and would fall back to UN. They are four-byte unsigned offsets — pin them\n * to UL so they serialize (and measure) as the fixed-width values the\n * offset algorithm depends on.\n */\nfunction pinOffsetVRs(dict) {\n for (const tag of [\"00041200\", \"00041202\"]) {\n if (dict[tag]) {\n dict[tag].vr = \"UL\";\n }\n }\n const items = dict[\"00041220\"]?.Value || [];\n for (const item of items) {\n for (const tag of [\"00041400\", \"00041420\"]) {\n if (item[tag]) {\n item[tag].vr = \"UL\";\n }\n }\n }\n}\n\n/**\n * Serialize { meta, dict } as a Part 10 file. This is the body of\n * DicomDict.write (packages/legacy) minus the deflate branch — a DICOMDIR\n * is always Explicit VR Little Endian, never deflated — rebuilt on core's\n * writeDataSet/writeTagObject so this package does not depend on\n * @dcmjs-org/legacy. DicomMessage.write and DicomMessage.writeTagObject\n * are one-line delegates to those same core functions, so the bytes this\n * produces are identical to DicomDict.write's, which is what keeps the\n * measured directory offsets valid.\n */\nfunction writePart10(meta, dict, writeOptions) {\n const metaSyntax = EXPLICIT_LITTLE_ENDIAN;\n const fileStream = new WriteBufferStream(4096, true);\n fileStream.writeUint8Repeat(0, 128);\n fileStream.writeAsciiString(\"DICM\");\n\n const metaStream = new WriteBufferStream(1024);\n if (!meta[TagHex.TransferSyntaxUID]) {\n meta[TagHex.TransferSyntaxUID] = {\n vr: \"UI\",\n Value: [EXPLICIT_LITTLE_ENDIAN]\n };\n }\n writeDataSet(meta, metaStream, metaSyntax, writeOptions);\n writeTagObject(\n fileStream,\n TagHex.FileMetaInformationGroupLength,\n \"UL\",\n metaStream.size,\n metaSyntax,\n writeOptions\n );\n fileStream.concat(metaStream);\n\n const useSyntax = meta[TagHex.TransferSyntaxUID].Value[0];\n writeDataSet(dict, fileStream, useSyntax, writeOptions);\n return fileStream.getBuffer();\n}\n\nfunction writeDicomDir(entries = [], options = {}) {\n const { dataset, links, rootIndices } = buildDicomDirDataset(\n entries,\n options\n );\n\n const meta = buildDicomDirMeta(options);\n const dict = DicomMetaDictionary.denaturalizeDataset(dataset);\n pinOffsetVRs(dict);\n\n const writeOptions = { allowInvalidVRLength: false };\n const recordOffsets = computeDirectoryOffsets({ meta, dict }, writeOptions);\n\n const sequence = dict[\"00041220\"];\n const items = (sequence && sequence.Value) || [];\n items.forEach((item, index) => {\n const { next, child } = links[index];\n item[\"00041400\"].Value = [next === null ? 0 : recordOffsets[next]];\n item[\"00041420\"].Value = [child === null ? 0 : recordOffsets[child]];\n });\n\n const first = rootIndices.length ? recordOffsets[rootIndices[0]] : 0;\n const last = rootIndices.length\n ? recordOffsets[rootIndices[rootIndices.length - 1]]\n : 0;\n dict[\"00041200\"].Value = [first];\n dict[\"00041202\"].Value = [last];\n\n return writePart10(meta, dict, writeOptions);\n}\n\nexport {\n buildDicomDirDataset,\n writeDicomDir,\n MEDIA_STORAGE_DIRECTORY_SOP_CLASS_UID\n};\n","import {\n buildDicomDirDataset,\n writeDicomDir,\n MEDIA_STORAGE_DIRECTORY_SOP_CLASS_UID\n} from \"./dicomdir.js\";\n\nexport {\n buildDicomDirDataset,\n writeDicomDir,\n MEDIA_STORAGE_DIRECTORY_SOP_CLASS_UID\n};\n\nexport default {\n buildDicomDirDataset,\n writeDicomDir,\n MEDIA_STORAGE_DIRECTORY_SOP_CLASS_UID\n};\n"],"names":["WriteBufferStream","writeDataSet","EXPLICIT_LITTLE_ENDIAN","writeTagObject","TagHex","DicomMetaDictionary"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAUA,MAAM,yBAAyB,GAAG,UAAU;;AAE5C,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,MAAM,oBAAoB,GAAG,CAAC,CAAC;;AAE/B;AACA,SAAS,OAAO,CAAC,UAAU,EAAE,YAAY,EAAE;AAC3C,IAAI,MAAM,MAAM,GAAG,IAAIA,sBAAiB,CAAC,IAAI,CAAC;AAC9C,IAAIC,iBAAY,CAAC,UAAU,EAAE,MAAM,EAAEC,2B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GAAG,CAAC,CAAC;AAC3D,UAAU,CAAC;AACX,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,KAAK,GAAG,CAAC,KAAK,CAAC;AACpC,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,KAAK,GAAG,CAAC,IAAI,CAAC;;AAEnC,IAAI,OAAO,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,YAAY,CAAC;AAChD;;AC/WA,YAAe;AACf,IAAI,oBAAoB;AACxB,IAAI,aAAa;AACjB,IAAI;AACJ,CAAC;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/directoryOffsets.js","../src/dicomdir.js","../src/index.js"],"sourcesContent":["// packages/dicomdir/src/directoryOffsets.js\n//\n// Byte-offset computation for DICOMDIR directory records.\n//\n// The load-bearing fact: every DICOMDIR offset attribute (0004,1200/1202/\n// 1400/1420) is VR UL — a fixed four-byte value — so the values NEVER affect\n// the byte layout. One measurement pass over the exact structures the final\n// write will serialize (same writer, same options, placeholder zeros)\n// therefore yields the exact offsets of the final file, and the file is\n// written once with the real values filled in.\n//\n// Layout being measured (mirrors the Part 10 envelope in dicomdir.js):\n// 128-byte preamble + \"DICM\"\n// FileMetaInformationGroupLength element\n// meta group (Explicit VR Little Endian)\n// body tags below (0004,1220), sorted ascending\n// (0004,1220) DirectoryRecordSequence: 12-byte SQ header (undefined\n// length), then per item: 8-byte item header (FFFE,E000, undefined\n// length) + item body + 8-byte item delimiter (FFFE,E00D) — see\n// SequenceOfItems.writeBytes — and a trailing 8-byte sequence delimiter.\n//\n// A directory-record offset points at the FFFE,E000 item tag of that record,\n// counted from byte 0 of the file (PS3.10 8.6).\n\nimport {\n WriteBufferStream,\n writeDataSet,\n writeTagObject,\n EXPLICIT_LITTLE_ENDIAN,\n TagHex\n} from \"@dcmjs-org/core\";\n\nconst DIRECTORY_RECORD_SEQUENCE = \"00041220\";\n\nconst ITEM_HEADER_BYTES = 8; // FFFE,E000 + 4-byte undefined length\nconst ITEM_DELIMITER_BYTES = 8; // FFFE,E00D + 4-byte zero length\n\n/** Bytes writeDataSet produces for one tag-keyed object. */\nfunction measure(jsonObject, writeOptions) {\n const stream = new WriteBufferStream({ defaultSize: 1024 });\n writeDataSet(jsonObject, stream, EXPLICIT_LITTLE_ENDIAN, writeOptions);\n return stream.size;\n}\n\n/**\n * Compute the absolute byte offset of every directory record item in the\n * file the Part 10 envelope write will produce. Call with the offsets\n * still zero; patch the returned values in, then write — the layout is\n * guaranteed identical because offsets are fixed-width.\n *\n * @param {{ meta: Object, dict: Object }} dicomDict - denaturalized\n * DICOMDIR ({ meta, dict }) whose dict contains (0004,1220)\n * @param {Object} writeOptions - the SAME object later passed to write()\n * @returns {number[]} byte offset of each record's item tag, in item order\n */\nexport function computeDirectoryOffsets(dicomDict, writeOptions) {\n // Preamble + magic.\n let cursor = 128 + 4;\n\n // FileMetaInformationGroupLength + meta group. The group length element\n // is measured with the real meta size as its value — UL again, so the\n // element size is value-independent, but measuring keeps zero assumptions.\n const metaSize = measure(dicomDict.meta, writeOptions);\n const groupLengthStream = new WriteBufferStream({ defaultSize: 64 });\n writeTagObject(\n groupLengthStream,\n TagHex.FileMetaInformationGroupLength,\n \"UL\",\n metaSize,\n EXPLICIT_LITTLE_ENDIAN,\n writeOptions\n );\n cursor += groupLengthStream.size + metaSize;\n\n // Body tags before the record sequence, in the writer's sorted order.\n const bodyTags = Object.keys(dicomDict.dict).sort();\n for (const tag of bodyTags) {\n if (tag >= DIRECTORY_RECORD_SEQUENCE) {\n break;\n }\n cursor += measure({ [tag]: dicomDict.dict[tag] }, writeOptions);\n }\n\n // SQ element header: measure an empty sequence (header + 8-byte\n // sequence delimiter) rather than assuming the 12-byte constant.\n const sequence = dicomDict.dict[DIRECTORY_RECORD_SEQUENCE];\n const emptySequenceSize = measure(\n { [DIRECTORY_RECORD_SEQUENCE]: { vr: \"SQ\", Value: [] } },\n writeOptions\n );\n cursor += emptySequenceSize - ITEM_DELIMITER_BYTES;\n\n const offsets = [];\n const items = (sequence && sequence.Value) || [];\n for (const item of items) {\n offsets.push(cursor);\n cursor +=\n ITEM_HEADER_BYTES +\n measure(item, writeOptions) +\n ITEM_DELIMITER_BYTES;\n }\n\n return offsets;\n}\n","// packages/dicomdir/src/dicomdir.js\n//\n// DICOMDIR (Media Storage Directory, PS3.10 / PS3.3 F) builder. Turns a flat\n// file-set description into the PATIENT -> STUDY -> SERIES -> leaf record\n// hierarchy and serializes it with real byte offsets in the three offset\n// attributes (OffsetOfTheNextDirectoryRecord, OffsetOfReferencedLowerLevel-\n// DirectoryEntity, and the root first/last record offsets).\n//\n// Offsets are computed by measure-then-write (see directoryOffsets.js): every\n// offset attribute is VR UL — fixed four bytes — so a measurement pass with\n// placeholder zeros produces the exact final layout, and the file is written\n// once. No patch-and-rewrite, no buffer scanning.\n\nimport {\n DicomMetaDictionary,\n WriteBufferStream,\n writeDataSet,\n writeTagObject,\n EXPLICIT_LITTLE_ENDIAN,\n TagHex\n} from \"@dcmjs-org/core\";\nimport { computeDirectoryOffsets } from \"./directoryOffsets.js\";\n\nconst MEDIA_STORAGE_DIRECTORY_SOP_CLASS_UID = \"1.2.840.10008.1.3.10\";\n\n// PS3.10 8.5: each File ID component is 1-8 characters from the ISO 9660\n// level 1 repertoire (A-Z, 0-9, underscore), at most 8 components deep.\nconst FILE_ID_COMPONENT = /^[A-Z0-9_]{1,8}$/;\n\nfunction assertEntry(entry, index) {\n const where = `buildDicomDirDataset: entries[${index}]`;\n if (!entry || typeof entry !== \"object\") {\n throw new Error(`${where} is not an object`);\n }\n if (\n !Array.isArray(entry.referencedFileID) ||\n !entry.referencedFileID.length\n ) {\n throw new Error(\n `${where}.referencedFileID must be a non-empty array of path components`\n );\n }\n for (const required of [\n \"sopClassUid\",\n \"sopInstanceUid\",\n \"transferSyntaxUid\"\n ]) {\n if (!entry[required]) {\n throw new Error(`${where}.${required} is required`);\n }\n }\n if (!entry.patient?.PatientID) {\n throw new Error(`${where}.patient.PatientID is required`);\n }\n if (!entry.study?.StudyInstanceUID) {\n throw new Error(`${where}.study.StudyInstanceUID is required`);\n }\n if (!entry.series?.SeriesInstanceUID) {\n throw new Error(`${where}.series.SeriesInstanceUID is required`);\n }\n}\n\nfunction assertFileID(components, index, allowNonConforming) {\n if (components.length > 8) {\n throw new Error(\n `buildDicomDirDataset: entries[${index}].referencedFileID has ` +\n `${components.length} components (max 8)`\n );\n }\n if (allowNonConforming) {\n return;\n }\n for (const component of components) {\n if (!FILE_ID_COMPONENT.test(component)) {\n throw new Error(\n `buildDicomDirDataset: entries[${index}].referencedFileID ` +\n `component \"${component}\" is not ISO 9660 level 1 ` +\n `conformant (A-Z 0-9 _, 1-8 chars) — rename the file or ` +\n `pass allowNonConformingFileIDs: true`\n );\n }\n }\n}\n\n/** The four keys every directory record starts with (PS3.3 F.3). */\nfunction recordCommon(recordType) {\n return {\n OffsetOfTheNextDirectoryRecord: 0,\n RecordInUseFlag: 0xffff,\n OffsetOfReferencedLowerLevelDirectoryEntity: 0,\n DirectoryRecordType: recordType\n };\n}\n\n/**\n * Group the flat entries into the PATIENT -> STUDY -> SERIES -> leaf tree,\n * preserving first-seen order at every level.\n */\nfunction groupEntries(entries, options) {\n const patients = new Map();\n entries.forEach((entry, index) => {\n assertEntry(entry, index);\n assertFileID(\n entry.referencedFileID,\n index,\n options.allowNonConformingFileIDs\n );\n\n const patientKey = entry.patient.PatientID;\n if (!patients.has(patientKey)) {\n patients.set(patientKey, {\n attributes: entry.patient,\n studies: new Map()\n });\n }\n const patient = patients.get(patientKey);\n\n const studyKey = entry.study.StudyInstanceUID;\n if (!patient.studies.has(studyKey)) {\n patient.studies.set(studyKey, {\n attributes: entry.study,\n series: new Map()\n });\n }\n const study = patient.studies.get(studyKey);\n\n const seriesKey = entry.series.SeriesInstanceUID;\n if (!study.series.has(seriesKey)) {\n study.series.set(seriesKey, {\n attributes: entry.series,\n leaves: []\n });\n }\n study.series.get(seriesKey).leaves.push(entry);\n });\n return patients;\n}\n\n/**\n * Flatten the tree depth-first into naturalized record objects, tracking the\n * flat index of each record's next sibling and first child so the offset\n * pass can wire the chains. Depth-first order means every link points\n * strictly forward in the file.\n *\n * @returns {{ records: Object[], links: Array<{next: number|null, child: number|null}> }}\n */\nfunction flattenRecords(patients) {\n const records = [];\n const links = [];\n\n const push = record => {\n records.push(record);\n links.push({ next: null, child: null });\n return records.length - 1;\n };\n\n const patientList = [...patients.values()];\n let previousPatientIndex = null;\n\n for (const patient of patientList) {\n const patientIndex = push({\n ...recordCommon(\"PATIENT\"),\n PatientName: patient.attributes.PatientName ?? \"\",\n PatientID: patient.attributes.PatientID\n });\n if (previousPatientIndex !== null) {\n links[previousPatientIndex].next = patientIndex;\n }\n previousPatientIndex = patientIndex;\n\n const studyList = [...patient.studies.values()];\n let previousStudyIndex = null;\n for (const study of studyList) {\n const studyIndex = push({\n ...recordCommon(\"STUDY\"),\n StudyDate: study.attributes.StudyDate ?? \"\",\n StudyTime: study.attributes.StudyTime ?? \"\",\n StudyDescription: study.attributes.StudyDescription ?? \"\",\n AccessionNumber: study.attributes.AccessionNumber ?? \"\",\n StudyInstanceUID: study.attributes.StudyInstanceUID,\n StudyID: study.attributes.StudyID ?? \"\"\n });\n if (previousStudyIndex === null) {\n links[patientIndex].child = studyIndex;\n } else {\n links[previousStudyIndex].next = studyIndex;\n }\n previousStudyIndex = studyIndex;\n\n const seriesList = [...study.series.values()];\n let previousSeriesIndex = null;\n for (const series of seriesList) {\n const seriesIndex = push({\n ...recordCommon(\"SERIES\"),\n Modality: series.attributes.Modality ?? \"OT\",\n SeriesInstanceUID: series.attributes.SeriesInstanceUID,\n SeriesNumber: series.attributes.SeriesNumber ?? 1\n });\n if (previousSeriesIndex === null) {\n links[studyIndex].child = seriesIndex;\n } else {\n links[previousSeriesIndex].next = seriesIndex;\n }\n previousSeriesIndex = seriesIndex;\n\n let previousLeafIndex = null;\n for (const entry of series.leaves) {\n const leafIndex = push({\n ...recordCommon(entry.recordType || \"IMAGE\"),\n ReferencedFileID: [...entry.referencedFileID],\n ReferencedSOPClassUIDInFile: entry.sopClassUid,\n ReferencedSOPInstanceUIDInFile: entry.sopInstanceUid,\n ReferencedTransferSyntaxUIDInFile:\n entry.transferSyntaxUid,\n InstanceNumber: entry.instance?.InstanceNumber ?? 1,\n ...entry.instance\n });\n if (previousLeafIndex === null) {\n links[seriesIndex].child = leafIndex;\n } else {\n links[previousLeafIndex].next = leafIndex;\n }\n previousLeafIndex = leafIndex;\n }\n }\n }\n }\n\n return { records, links };\n}\n\n/**\n * Build the naturalized DICOMDIR dataset (all offsets zero) plus the link\n * table the offset pass needs. Pure and inspectable — no serialization.\n *\n * @param {Array} entries - flat file-set entries; see module JSDoc/typedef\n * @param {Object} [options]\n * @param {string} [options.fileSetID=\"\"]\n * @param {boolean} [options.allowNonConformingFileIDs=false]\n * @returns {{ dataset: Object, links: Array, rootIndices: number[] }}\n */\nfunction buildDicomDirDataset(entries = [], options = {}) {\n const patients = groupEntries(entries, options);\n const { records, links } = flattenRecords(patients);\n\n const rootIndices = [];\n records.forEach((record, index) => {\n if (record.DirectoryRecordType === \"PATIENT\") {\n rootIndices.push(index);\n }\n });\n\n const dataset = {\n FileSetID: options.fileSetID ?? \"\",\n OffsetOfTheFirstDirectoryRecordOfTheRootDirectoryEntity: 0,\n OffsetOfTheLastDirectoryRecordOfTheRootDirectoryEntity: 0,\n FileSetConsistencyFlag: 0,\n DirectoryRecordSequence: records\n };\n\n return { dataset, links, rootIndices };\n}\n\n/** Mint the DICOMDIR file meta group (SOP identity lives here, not the body). */\nfunction buildDicomDirMeta(options = {}) {\n const fileMetaInformationVersion = new Uint8Array(2);\n fileMetaInformationVersion[1] = 1;\n return DicomMetaDictionary.denaturalizeDataset({\n FileMetaInformationVersion: fileMetaInformationVersion.buffer,\n MediaStorageSOPClassUID: MEDIA_STORAGE_DIRECTORY_SOP_CLASS_UID,\n MediaStorageSOPInstanceUID:\n options.fileSetUID || DicomMetaDictionary.uid(),\n TransferSyntaxUID: EXPLICIT_LITTLE_ENDIAN,\n ImplementationClassUID:\n \"2.25.80302813137786398554742050926734630921603366648225212145404\",\n ImplementationVersionName: \"dcmjs-0.0\"\n });\n}\n\n/**\n * Build and serialize a complete DICOMDIR: build the record tree,\n * denaturalize it, measure the layout, wire the offset chains, write once.\n *\n * @param {Array} entries - flat file-set entries\n * @param {Object} [options] - buildDicomDirDataset options plus\n * {string} [options.fileSetUID] fixed MediaStorageSOPInstanceUID\n * @returns {ArrayBuffer} the DICOMDIR file bytes\n */\n/**\n * The DICOM data dictionary gives the directory offset attributes the\n * special VR \"up\" (byte offset); the dcmjs writer has no \"up\" representation\n * and would fall back to UN. They are four-byte unsigned offsets — pin them\n * to UL so they serialize (and measure) as the fixed-width values the\n * offset algorithm depends on.\n */\nfunction pinOffsetVRs(dict) {\n for (const tag of [\"00041200\", \"00041202\"]) {\n if (dict[tag]) {\n dict[tag].vr = \"UL\";\n }\n }\n const items = dict[\"00041220\"]?.Value || [];\n for (const item of items) {\n for (const tag of [\"00041400\", \"00041420\"]) {\n if (item[tag]) {\n item[tag].vr = \"UL\";\n }\n }\n }\n}\n\n/**\n * Serialize { meta, dict } as a Part 10 file. This is the body of\n * DicomDict.write (packages/legacy) minus the deflate branch — a DICOMDIR\n * is always Explicit VR Little Endian, never deflated — rebuilt on core's\n * writeDataSet/writeTagObject so this package does not depend on\n * @dcmjs-org/legacy. DicomMessage.write and DicomMessage.writeTagObject\n * are one-line delegates to those same core functions, so the bytes this\n * produces are identical to DicomDict.write's, which is what keeps the\n * measured directory offsets valid.\n */\nfunction writePart10(meta, dict, writeOptions) {\n const metaSyntax = EXPLICIT_LITTLE_ENDIAN;\n const fileStream = new WriteBufferStream({ defaultSize: 4096 });\n fileStream.writeUint8Repeat(0, 128);\n fileStream.writeAsciiString(\"DICM\");\n\n const metaStream = new WriteBufferStream({ defaultSize: 1024 });\n if (!meta[TagHex.TransferSyntaxUID]) {\n meta[TagHex.TransferSyntaxUID] = {\n vr: \"UI\",\n Value: [EXPLICIT_LITTLE_ENDIAN]\n };\n }\n writeDataSet(meta, metaStream, metaSyntax, writeOptions);\n writeTagObject(\n fileStream,\n TagHex.FileMetaInformationGroupLength,\n \"UL\",\n metaStream.size,\n metaSyntax,\n writeOptions\n );\n fileStream.concat(metaStream);\n\n const useSyntax = meta[TagHex.TransferSyntaxUID].Value[0];\n writeDataSet(dict, fileStream, useSyntax, writeOptions);\n return fileStream.getBuffer();\n}\n\nfunction writeDicomDir(entries = [], options = {}) {\n const { dataset, links, rootIndices } = buildDicomDirDataset(\n entries,\n options\n );\n\n const meta = buildDicomDirMeta(options);\n const dict = DicomMetaDictionary.denaturalizeDataset(dataset);\n pinOffsetVRs(dict);\n\n const writeOptions = { allowInvalidVRLength: false };\n const recordOffsets = computeDirectoryOffsets({ meta, dict }, writeOptions);\n\n const sequence = dict[\"00041220\"];\n const items = (sequence && sequence.Value) || [];\n items.forEach((item, index) => {\n const { next, child } = links[index];\n item[\"00041400\"].Value = [next === null ? 0 : recordOffsets[next]];\n item[\"00041420\"].Value = [child === null ? 0 : recordOffsets[child]];\n });\n\n const first = rootIndices.length ? recordOffsets[rootIndices[0]] : 0;\n const last = rootIndices.length\n ? recordOffsets[rootIndices[rootIndices.length - 1]]\n : 0;\n dict[\"00041200\"].Value = [first];\n dict[\"00041202\"].Value = [last];\n\n return writePart10(meta, dict, writeOptions);\n}\n\nexport {\n buildDicomDirDataset,\n writeDicomDir,\n MEDIA_STORAGE_DIRECTORY_SOP_CLASS_UID\n};\n","import {\n buildDicomDirDataset,\n writeDicomDir,\n MEDIA_STORAGE_DIRECTORY_SOP_CLASS_UID\n} from \"./dicomdir.js\";\n\nexport {\n buildDicomDirDataset,\n writeDicomDir,\n MEDIA_STORAGE_DIRECTORY_SOP_CLASS_UID\n};\n\nexport default {\n buildDicomDirDataset,\n writeDicomDir,\n MEDIA_STORAGE_DIRECTORY_SOP_CLASS_UID\n};\n"],"names":["WriteBufferStream","writeDataSet","EXPLICIT_LITTLE_ENDIAN","writeTagObject","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,GAAG,KAAK,CAAC,KAAK,CAAC;AAC5C,QAAQ,IAAI,CAAC,UAAU,CAAC,CAAC,KAAK,GAAG,CAAC,IAAI,KAAK,IAAI,GAAG,CAAC,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;AAC1E,QAAQ,IAAI,CAAC,UAAU,CAAC,CAAC,KAAK,GAAG,CAAC,KAAK,KAAK,IAAI,GAAG,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;AAC5E,IAAI,CAAC,CAAC;;AAEN,IAAI,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AACxE,IAAI,MAAM,IAAI,GAAG,WAAW,CAAC;AAC7B,UAAU,aAAa,CAAC,WAAW,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC;AAC3D,UAAU,CAAC;AACX,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,KAAK,GAAG,CAAC,KAAK,CAAC;AACpC,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,KAAK,GAAG,CAAC,IAAI,CAAC;;AAEnC,IAAI,OAAO,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,YAAY,CAAC;AAChD;;AC/WA,YAAe;AACf,IAAI,oBAAoB;AACxB,IAAI,aAAa;AACjB,IAAI;AACJ,CAAC;;;;;;;"}
package/dist/index.mjs CHANGED
@@ -32,7 +32,7 @@ const ITEM_DELIMITER_BYTES = 8; // FFFE,E00D + 4-byte zero length
32
32
 
33
33
  /** Bytes writeDataSet produces for one tag-keyed object. */
34
34
  function measure(jsonObject, writeOptions) {
35
- const stream = new WriteBufferStream(1024);
35
+ const stream = new WriteBufferStream({ defaultSize: 1024 });
36
36
  writeDataSet(jsonObject, stream, EXPLICIT_LITTLE_ENDIAN, writeOptions);
37
37
  return stream.size;
38
38
  }
@@ -56,7 +56,7 @@ function computeDirectoryOffsets(dicomDict, writeOptions) {
56
56
  // is measured with the real meta size as its value — UL again, so the
57
57
  // element size is value-independent, but measuring keeps zero assumptions.
58
58
  const metaSize = measure(dicomDict.meta, writeOptions);
59
- const groupLengthStream = new WriteBufferStream(64);
59
+ const groupLengthStream = new WriteBufferStream({ defaultSize: 64 });
60
60
  writeTagObject(
61
61
  groupLengthStream,
62
62
  TagHex.FileMetaInformationGroupLength,
@@ -412,11 +412,11 @@ function pinOffsetVRs(dict) {
412
412
  */
413
413
  function writePart10(meta, dict, writeOptions) {
414
414
  const metaSyntax = EXPLICIT_LITTLE_ENDIAN;
415
- const fileStream = new WriteBufferStream(4096, true);
415
+ const fileStream = new WriteBufferStream({ defaultSize: 4096 });
416
416
  fileStream.writeUint8Repeat(0, 128);
417
417
  fileStream.writeAsciiString("DICM");
418
418
 
419
- const metaStream = new WriteBufferStream(1024);
419
+ const metaStream = new WriteBufferStream({ defaultSize: 1024 });
420
420
  if (!meta[TagHex.TransferSyntaxUID]) {
421
421
  meta[TagHex.TransferSyntaxUID] = {
422
422
  vr: "UI",
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../src/directoryOffsets.js","../src/dicomdir.js","../src/index.js"],"sourcesContent":["// packages/dicomdir/src/directoryOffsets.js\n//\n// Byte-offset computation for DICOMDIR directory records.\n//\n// The load-bearing fact: every DICOMDIR offset attribute (0004,1200/1202/\n// 1400/1420) is VR UL — a fixed four-byte value — so the values NEVER affect\n// the byte layout. One measurement pass over the exact structures the final\n// write will serialize (same writer, same options, placeholder zeros)\n// therefore yields the exact offsets of the final file, and the file is\n// written once with the real values filled in.\n//\n// Layout being measured (mirrors the Part 10 envelope in dicomdir.js):\n// 128-byte preamble + \"DICM\"\n// FileMetaInformationGroupLength element\n// meta group (Explicit VR Little Endian)\n// body tags below (0004,1220), sorted ascending\n// (0004,1220) DirectoryRecordSequence: 12-byte SQ header (undefined\n// length), then per item: 8-byte item header (FFFE,E000, undefined\n// length) + item body + 8-byte item delimiter (FFFE,E00D) — see\n// SequenceOfItems.writeBytes — and a trailing 8-byte sequence delimiter.\n//\n// A directory-record offset points at the FFFE,E000 item tag of that record,\n// counted from byte 0 of the file (PS3.10 8.6).\n\nimport {\n WriteBufferStream,\n writeDataSet,\n writeTagObject,\n EXPLICIT_LITTLE_ENDIAN,\n TagHex\n} from \"@dcmjs-org/core\";\n\nconst DIRECTORY_RECORD_SEQUENCE = \"00041220\";\n\nconst ITEM_HEADER_BYTES = 8; // FFFE,E000 + 4-byte undefined length\nconst ITEM_DELIMITER_BYTES = 8; // FFFE,E00D + 4-byte zero length\n\n/** Bytes writeDataSet produces for one tag-keyed object. */\nfunction measure(jsonObject, writeOptions) {\n const stream = new WriteBufferStream(1024);\n writeDataSet(jsonObject, stream, EXPLICIT_LITTLE_ENDIAN, writeOptions);\n return stream.size;\n}\n\n/**\n * Compute the absolute byte offset of every directory record item in the\n * file the Part 10 envelope write will produce. Call with the offsets\n * still zero; patch the returned values in, then write — the layout is\n * guaranteed identical because offsets are fixed-width.\n *\n * @param {{ meta: Object, dict: Object }} dicomDict - denaturalized\n * DICOMDIR ({ meta, dict }) whose dict contains (0004,1220)\n * @param {Object} writeOptions - the SAME object later passed to write()\n * @returns {number[]} byte offset of each record's item tag, in item order\n */\nexport function computeDirectoryOffsets(dicomDict, writeOptions) {\n // Preamble + magic.\n let cursor = 128 + 4;\n\n // FileMetaInformationGroupLength + meta group. The group length element\n // is measured with the real meta size as its value — UL again, so the\n // element size is value-independent, but measuring keeps zero assumptions.\n const metaSize = measure(dicomDict.meta, writeOptions);\n const groupLengthStream = new WriteBufferStream(64);\n writeTagObject(\n groupLengthStream,\n TagHex.FileMetaInformationGroupLength,\n \"UL\",\n metaSize,\n EXPLICIT_LITTLE_ENDIAN,\n writeOptions\n );\n cursor += groupLengthStream.size + metaSize;\n\n // Body tags before the record sequence, in the writer's sorted order.\n const bodyTags = Object.keys(dicomDict.dict).sort();\n for (const tag of bodyTags) {\n if (tag >= DIRECTORY_RECORD_SEQUENCE) {\n break;\n }\n cursor += measure({ [tag]: dicomDict.dict[tag] }, writeOptions);\n }\n\n // SQ element header: measure an empty sequence (header + 8-byte\n // sequence delimiter) rather than assuming the 12-byte constant.\n const sequence = dicomDict.dict[DIRECTORY_RECORD_SEQUENCE];\n const emptySequenceSize = measure(\n { [DIRECTORY_RECORD_SEQUENCE]: { vr: \"SQ\", Value: [] } },\n writeOptions\n );\n cursor += emptySequenceSize - ITEM_DELIMITER_BYTES;\n\n const offsets = [];\n const items = (sequence && sequence.Value) || [];\n for (const item of items) {\n offsets.push(cursor);\n cursor +=\n ITEM_HEADER_BYTES +\n measure(item, writeOptions) +\n ITEM_DELIMITER_BYTES;\n }\n\n return offsets;\n}\n","// packages/dicomdir/src/dicomdir.js\n//\n// DICOMDIR (Media Storage Directory, PS3.10 / PS3.3 F) builder. Turns a flat\n// file-set description into the PATIENT -> STUDY -> SERIES -> leaf record\n// hierarchy and serializes it with real byte offsets in the three offset\n// attributes (OffsetOfTheNextDirectoryRecord, OffsetOfReferencedLowerLevel-\n// DirectoryEntity, and the root first/last record offsets).\n//\n// Offsets are computed by measure-then-write (see directoryOffsets.js): every\n// offset attribute is VR UL — fixed four bytes — so a measurement pass with\n// placeholder zeros produces the exact final layout, and the file is written\n// once. No patch-and-rewrite, no buffer scanning.\n\nimport {\n DicomMetaDictionary,\n WriteBufferStream,\n writeDataSet,\n writeTagObject,\n EXPLICIT_LITTLE_ENDIAN,\n TagHex\n} from \"@dcmjs-org/core\";\nimport { computeDirectoryOffsets } from \"./directoryOffsets.js\";\n\nconst MEDIA_STORAGE_DIRECTORY_SOP_CLASS_UID = \"1.2.840.10008.1.3.10\";\n\n// PS3.10 8.5: each File ID component is 1-8 characters from the ISO 9660\n// level 1 repertoire (A-Z, 0-9, underscore), at most 8 components deep.\nconst FILE_ID_COMPONENT = /^[A-Z0-9_]{1,8}$/;\n\nfunction assertEntry(entry, index) {\n const where = `buildDicomDirDataset: entries[${index}]`;\n if (!entry || typeof entry !== \"object\") {\n throw new Error(`${where} is not an object`);\n }\n if (\n !Array.isArray(entry.referencedFileID) ||\n !entry.referencedFileID.length\n ) {\n throw new Error(\n `${where}.referencedFileID must be a non-empty array of path components`\n );\n }\n for (const required of [\n \"sopClassUid\",\n \"sopInstanceUid\",\n \"transferSyntaxUid\"\n ]) {\n if (!entry[required]) {\n throw new Error(`${where}.${required} is required`);\n }\n }\n if (!entry.patient?.PatientID) {\n throw new Error(`${where}.patient.PatientID is required`);\n }\n if (!entry.study?.StudyInstanceUID) {\n throw new Error(`${where}.study.StudyInstanceUID is required`);\n }\n if (!entry.series?.SeriesInstanceUID) {\n throw new Error(`${where}.series.SeriesInstanceUID is required`);\n }\n}\n\nfunction assertFileID(components, index, allowNonConforming) {\n if (components.length > 8) {\n throw new Error(\n `buildDicomDirDataset: entries[${index}].referencedFileID has ` +\n `${components.length} components (max 8)`\n );\n }\n if (allowNonConforming) {\n return;\n }\n for (const component of components) {\n if (!FILE_ID_COMPONENT.test(component)) {\n throw new Error(\n `buildDicomDirDataset: entries[${index}].referencedFileID ` +\n `component \"${component}\" is not ISO 9660 level 1 ` +\n `conformant (A-Z 0-9 _, 1-8 chars) — rename the file or ` +\n `pass allowNonConformingFileIDs: true`\n );\n }\n }\n}\n\n/** The four keys every directory record starts with (PS3.3 F.3). */\nfunction recordCommon(recordType) {\n return {\n OffsetOfTheNextDirectoryRecord: 0,\n RecordInUseFlag: 0xffff,\n OffsetOfReferencedLowerLevelDirectoryEntity: 0,\n DirectoryRecordType: recordType\n };\n}\n\n/**\n * Group the flat entries into the PATIENT -> STUDY -> SERIES -> leaf tree,\n * preserving first-seen order at every level.\n */\nfunction groupEntries(entries, options) {\n const patients = new Map();\n entries.forEach((entry, index) => {\n assertEntry(entry, index);\n assertFileID(\n entry.referencedFileID,\n index,\n options.allowNonConformingFileIDs\n );\n\n const patientKey = entry.patient.PatientID;\n if (!patients.has(patientKey)) {\n patients.set(patientKey, {\n attributes: entry.patient,\n studies: new Map()\n });\n }\n const patient = patients.get(patientKey);\n\n const studyKey = entry.study.StudyInstanceUID;\n if (!patient.studies.has(studyKey)) {\n patient.studies.set(studyKey, {\n attributes: entry.study,\n series: new Map()\n });\n }\n const study = patient.studies.get(studyKey);\n\n const seriesKey = entry.series.SeriesInstanceUID;\n if (!study.series.has(seriesKey)) {\n study.series.set(seriesKey, {\n attributes: entry.series,\n leaves: []\n });\n }\n study.series.get(seriesKey).leaves.push(entry);\n });\n return patients;\n}\n\n/**\n * Flatten the tree depth-first into naturalized record objects, tracking the\n * flat index of each record's next sibling and first child so the offset\n * pass can wire the chains. Depth-first order means every link points\n * strictly forward in the file.\n *\n * @returns {{ records: Object[], links: Array<{next: number|null, child: number|null}> }}\n */\nfunction flattenRecords(patients) {\n const records = [];\n const links = [];\n\n const push = record => {\n records.push(record);\n links.push({ next: null, child: null });\n return records.length - 1;\n };\n\n const patientList = [...patients.values()];\n let previousPatientIndex = null;\n\n for (const patient of patientList) {\n const patientIndex = push({\n ...recordCommon(\"PATIENT\"),\n PatientName: patient.attributes.PatientName ?? \"\",\n PatientID: patient.attributes.PatientID\n });\n if (previousPatientIndex !== null) {\n links[previousPatientIndex].next = patientIndex;\n }\n previousPatientIndex = patientIndex;\n\n const studyList = [...patient.studies.values()];\n let previousStudyIndex = null;\n for (const study of studyList) {\n const studyIndex = push({\n ...recordCommon(\"STUDY\"),\n StudyDate: study.attributes.StudyDate ?? \"\",\n StudyTime: study.attributes.StudyTime ?? \"\",\n StudyDescription: study.attributes.StudyDescription ?? \"\",\n AccessionNumber: study.attributes.AccessionNumber ?? \"\",\n StudyInstanceUID: study.attributes.StudyInstanceUID,\n StudyID: study.attributes.StudyID ?? \"\"\n });\n if (previousStudyIndex === null) {\n links[patientIndex].child = studyIndex;\n } else {\n links[previousStudyIndex].next = studyIndex;\n }\n previousStudyIndex = studyIndex;\n\n const seriesList = [...study.series.values()];\n let previousSeriesIndex = null;\n for (const series of seriesList) {\n const seriesIndex = push({\n ...recordCommon(\"SERIES\"),\n Modality: series.attributes.Modality ?? \"OT\",\n SeriesInstanceUID: series.attributes.SeriesInstanceUID,\n SeriesNumber: series.attributes.SeriesNumber ?? 1\n });\n if (previousSeriesIndex === null) {\n links[studyIndex].child = seriesIndex;\n } else {\n links[previousSeriesIndex].next = seriesIndex;\n }\n previousSeriesIndex = seriesIndex;\n\n let previousLeafIndex = null;\n for (const entry of series.leaves) {\n const leafIndex = push({\n ...recordCommon(entry.recordType || \"IMAGE\"),\n ReferencedFileID: [...entry.referencedFileID],\n ReferencedSOPClassUIDInFile: entry.sopClassUid,\n ReferencedSOPInstanceUIDInFile: entry.sopInstanceUid,\n ReferencedTransferSyntaxUIDInFile:\n entry.transferSyntaxUid,\n InstanceNumber: entry.instance?.InstanceNumber ?? 1,\n ...entry.instance\n });\n if (previousLeafIndex === null) {\n links[seriesIndex].child = leafIndex;\n } else {\n links[previousLeafIndex].next = leafIndex;\n }\n previousLeafIndex = leafIndex;\n }\n }\n }\n }\n\n return { records, links };\n}\n\n/**\n * Build the naturalized DICOMDIR dataset (all offsets zero) plus the link\n * table the offset pass needs. Pure and inspectable — no serialization.\n *\n * @param {Array} entries - flat file-set entries; see module JSDoc/typedef\n * @param {Object} [options]\n * @param {string} [options.fileSetID=\"\"]\n * @param {boolean} [options.allowNonConformingFileIDs=false]\n * @returns {{ dataset: Object, links: Array, rootIndices: number[] }}\n */\nfunction buildDicomDirDataset(entries = [], options = {}) {\n const patients = groupEntries(entries, options);\n const { records, links } = flattenRecords(patients);\n\n const rootIndices = [];\n records.forEach((record, index) => {\n if (record.DirectoryRecordType === \"PATIENT\") {\n rootIndices.push(index);\n }\n });\n\n const dataset = {\n FileSetID: options.fileSetID ?? \"\",\n OffsetOfTheFirstDirectoryRecordOfTheRootDirectoryEntity: 0,\n OffsetOfTheLastDirectoryRecordOfTheRootDirectoryEntity: 0,\n FileSetConsistencyFlag: 0,\n DirectoryRecordSequence: records\n };\n\n return { dataset, links, rootIndices };\n}\n\n/** Mint the DICOMDIR file meta group (SOP identity lives here, not the body). */\nfunction buildDicomDirMeta(options = {}) {\n const fileMetaInformationVersion = new Uint8Array(2);\n fileMetaInformationVersion[1] = 1;\n return DicomMetaDictionary.denaturalizeDataset({\n FileMetaInformationVersion: fileMetaInformationVersion.buffer,\n MediaStorageSOPClassUID: MEDIA_STORAGE_DIRECTORY_SOP_CLASS_UID,\n MediaStorageSOPInstanceUID:\n options.fileSetUID || DicomMetaDictionary.uid(),\n TransferSyntaxUID: EXPLICIT_LITTLE_ENDIAN,\n ImplementationClassUID:\n \"2.25.80302813137786398554742050926734630921603366648225212145404\",\n ImplementationVersionName: \"dcmjs-0.0\"\n });\n}\n\n/**\n * Build and serialize a complete DICOMDIR: build the record tree,\n * denaturalize it, measure the layout, wire the offset chains, write once.\n *\n * @param {Array} entries - flat file-set entries\n * @param {Object} [options] - buildDicomDirDataset options plus\n * {string} [options.fileSetUID] fixed MediaStorageSOPInstanceUID\n * @returns {ArrayBuffer} the DICOMDIR file bytes\n */\n/**\n * The DICOM data dictionary gives the directory offset attributes the\n * special VR \"up\" (byte offset); the dcmjs writer has no \"up\" representation\n * and would fall back to UN. They are four-byte unsigned offsets — pin them\n * to UL so they serialize (and measure) as the fixed-width values the\n * offset algorithm depends on.\n */\nfunction pinOffsetVRs(dict) {\n for (const tag of [\"00041200\", \"00041202\"]) {\n if (dict[tag]) {\n dict[tag].vr = \"UL\";\n }\n }\n const items = dict[\"00041220\"]?.Value || [];\n for (const item of items) {\n for (const tag of [\"00041400\", \"00041420\"]) {\n if (item[tag]) {\n item[tag].vr = \"UL\";\n }\n }\n }\n}\n\n/**\n * Serialize { meta, dict } as a Part 10 file. This is the body of\n * DicomDict.write (packages/legacy) minus the deflate branch — a DICOMDIR\n * is always Explicit VR Little Endian, never deflated — rebuilt on core's\n * writeDataSet/writeTagObject so this package does not depend on\n * @dcmjs-org/legacy. DicomMessage.write and DicomMessage.writeTagObject\n * are one-line delegates to those same core functions, so the bytes this\n * produces are identical to DicomDict.write's, which is what keeps the\n * measured directory offsets valid.\n */\nfunction writePart10(meta, dict, writeOptions) {\n const metaSyntax = EXPLICIT_LITTLE_ENDIAN;\n const fileStream = new WriteBufferStream(4096, true);\n fileStream.writeUint8Repeat(0, 128);\n fileStream.writeAsciiString(\"DICM\");\n\n const metaStream = new WriteBufferStream(1024);\n if (!meta[TagHex.TransferSyntaxUID]) {\n meta[TagHex.TransferSyntaxUID] = {\n vr: \"UI\",\n Value: [EXPLICIT_LITTLE_ENDIAN]\n };\n }\n writeDataSet(meta, metaStream, metaSyntax, writeOptions);\n writeTagObject(\n fileStream,\n TagHex.FileMetaInformationGroupLength,\n \"UL\",\n metaStream.size,\n metaSyntax,\n writeOptions\n );\n fileStream.concat(metaStream);\n\n const useSyntax = meta[TagHex.TransferSyntaxUID].Value[0];\n writeDataSet(dict, fileStream, useSyntax, writeOptions);\n return fileStream.getBuffer();\n}\n\nfunction writeDicomDir(entries = [], options = {}) {\n const { dataset, links, rootIndices } = buildDicomDirDataset(\n entries,\n options\n );\n\n const meta = buildDicomDirMeta(options);\n const dict = DicomMetaDictionary.denaturalizeDataset(dataset);\n pinOffsetVRs(dict);\n\n const writeOptions = { allowInvalidVRLength: false };\n const recordOffsets = computeDirectoryOffsets({ meta, dict }, writeOptions);\n\n const sequence = dict[\"00041220\"];\n const items = (sequence && sequence.Value) || [];\n items.forEach((item, index) => {\n const { next, child } = links[index];\n item[\"00041400\"].Value = [next === null ? 0 : recordOffsets[next]];\n item[\"00041420\"].Value = [child === null ? 0 : recordOffsets[child]];\n });\n\n const first = rootIndices.length ? recordOffsets[rootIndices[0]] : 0;\n const last = rootIndices.length\n ? recordOffsets[rootIndices[rootIndices.length - 1]]\n : 0;\n dict[\"00041200\"].Value = [first];\n dict[\"00041202\"].Value = [last];\n\n return writePart10(meta, dict, writeOptions);\n}\n\nexport {\n buildDicomDirDataset,\n writeDicomDir,\n MEDIA_STORAGE_DIRECTORY_SOP_CLASS_UID\n};\n","import {\n buildDicomDirDataset,\n writeDicomDir,\n MEDIA_STORAGE_DIRECTORY_SOP_CLASS_UID\n} from \"./dicomdir.js\";\n\nexport {\n buildDicomDirDataset,\n writeDicomDir,\n MEDIA_STORAGE_DIRECTORY_SOP_CLASS_UID\n};\n\nexport default {\n buildDicomDirDataset,\n writeDicomDir,\n MEDIA_STORAGE_DIRECTORY_SOP_CLASS_UID\n};\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAUA,MAAM,yBAAyB,GAAG,UAAU;;AAE5C,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,MAAM,oBAAoB,GAAG,CAAC,CAAC;;AAE/B;AACA,SAAS,OAAO,CAAC,UAAU,EAAE,YAAY,EAAE;AAC3C,IAAI,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC,IAAI,CAAC;AAC9C,IAAI,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,sBAAsB,EAAE,YAAY,CAAC;AAC1E,IAAI,OAAO,MAAM,CAAC,IAAI;AACtB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,uBAAuB,CAAC,SAAS,EAAE,YAAY,EAAE;AACjE;AACA,IAAI,IAAI,MAAM,GAAG,GAAG,GAAG,CAAC;;AAExB;AACA;AACA;AACA,IAAI,MAAM,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,YAAY,CAAC;AAC1D,IAAI,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,CAAC,EAAE,CAAC;AACvD,IAAI,cAAc;AAClB,QAAQ,iBAAiB;AACzB,QAAQ,MAAM,CAAC,8BAA8B;AAC7C,QAAQ,IAAI;AACZ,QAAQ,QAAQ;AAChB,QAAQ,sBAAsB;AAC9B,QAAQ;AACR,KAAK;AACL,IAAI,MAAM,IAAI,iBAAiB,CAAC,IAAI,GAAG,QAAQ;;AAE/C;AACA,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AC,IAAI,EAAE,KAAK,KAAK;AACnC,QAAQ,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC;AAC5C,QAAQ,IAAI,CAAC,UAAU,CAAC,CAAC,KAAK,GAAG,CAAC,IAAI,KAAK,IAAI,GAAG,CAAC,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;AAC1E,QAAQ,IAAI,CAAC,UAAU,CAAC,CAAC,KAAK,GAAG,CAAC,KAAK,KAAK,IAAI,GAAG,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;AAC5E,IAAI,CAAC,CAAC;;AAEN,IAAI,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AACxE,IAAI,MAAM,IAAI,GAAG,WAAW,CAAC;AAC7B,UAAU,aAAa,CAAC,WAAW,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC;AAC3D,UAAU,CAAC;AACX,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,KAAK,GAAG,CAAC,KAAK,CAAC;AACpC,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,KAAK,GAAG,CAAC,IAAI,CAAC;;AAEnC,IAAI,OAAO,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,YAAY,CAAC;AAChD;;AC/WA,YAAe;AACf,IAAI,oBAAoB;AACxB,IAAI,aAAa;AACjB,IAAI;AACJ,CAAC;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":["../src/directoryOffsets.js","../src/dicomdir.js","../src/index.js"],"sourcesContent":["// packages/dicomdir/src/directoryOffsets.js\n//\n// Byte-offset computation for DICOMDIR directory records.\n//\n// The load-bearing fact: every DICOMDIR offset attribute (0004,1200/1202/\n// 1400/1420) is VR UL — a fixed four-byte value — so the values NEVER affect\n// the byte layout. One measurement pass over the exact structures the final\n// write will serialize (same writer, same options, placeholder zeros)\n// therefore yields the exact offsets of the final file, and the file is\n// written once with the real values filled in.\n//\n// Layout being measured (mirrors the Part 10 envelope in dicomdir.js):\n// 128-byte preamble + \"DICM\"\n// FileMetaInformationGroupLength element\n// meta group (Explicit VR Little Endian)\n// body tags below (0004,1220), sorted ascending\n// (0004,1220) DirectoryRecordSequence: 12-byte SQ header (undefined\n// length), then per item: 8-byte item header (FFFE,E000, undefined\n// length) + item body + 8-byte item delimiter (FFFE,E00D) — see\n// SequenceOfItems.writeBytes — and a trailing 8-byte sequence delimiter.\n//\n// A directory-record offset points at the FFFE,E000 item tag of that record,\n// counted from byte 0 of the file (PS3.10 8.6).\n\nimport {\n WriteBufferStream,\n writeDataSet,\n writeTagObject,\n EXPLICIT_LITTLE_ENDIAN,\n TagHex\n} from \"@dcmjs-org/core\";\n\nconst DIRECTORY_RECORD_SEQUENCE = \"00041220\";\n\nconst ITEM_HEADER_BYTES = 8; // FFFE,E000 + 4-byte undefined length\nconst ITEM_DELIMITER_BYTES = 8; // FFFE,E00D + 4-byte zero length\n\n/** Bytes writeDataSet produces for one tag-keyed object. */\nfunction measure(jsonObject, writeOptions) {\n const stream = new WriteBufferStream({ defaultSize: 1024 });\n writeDataSet(jsonObject, stream, EXPLICIT_LITTLE_ENDIAN, writeOptions);\n return stream.size;\n}\n\n/**\n * Compute the absolute byte offset of every directory record item in the\n * file the Part 10 envelope write will produce. Call with the offsets\n * still zero; patch the returned values in, then write — the layout is\n * guaranteed identical because offsets are fixed-width.\n *\n * @param {{ meta: Object, dict: Object }} dicomDict - denaturalized\n * DICOMDIR ({ meta, dict }) whose dict contains (0004,1220)\n * @param {Object} writeOptions - the SAME object later passed to write()\n * @returns {number[]} byte offset of each record's item tag, in item order\n */\nexport function computeDirectoryOffsets(dicomDict, writeOptions) {\n // Preamble + magic.\n let cursor = 128 + 4;\n\n // FileMetaInformationGroupLength + meta group. The group length element\n // is measured with the real meta size as its value — UL again, so the\n // element size is value-independent, but measuring keeps zero assumptions.\n const metaSize = measure(dicomDict.meta, writeOptions);\n const groupLengthStream = new WriteBufferStream({ defaultSize: 64 });\n writeTagObject(\n groupLengthStream,\n TagHex.FileMetaInformationGroupLength,\n \"UL\",\n metaSize,\n EXPLICIT_LITTLE_ENDIAN,\n writeOptions\n );\n cursor += groupLengthStream.size + metaSize;\n\n // Body tags before the record sequence, in the writer's sorted order.\n const bodyTags = Object.keys(dicomDict.dict).sort();\n for (const tag of bodyTags) {\n if (tag >= DIRECTORY_RECORD_SEQUENCE) {\n break;\n }\n cursor += measure({ [tag]: dicomDict.dict[tag] }, writeOptions);\n }\n\n // SQ element header: measure an empty sequence (header + 8-byte\n // sequence delimiter) rather than assuming the 12-byte constant.\n const sequence = dicomDict.dict[DIRECTORY_RECORD_SEQUENCE];\n const emptySequenceSize = measure(\n { [DIRECTORY_RECORD_SEQUENCE]: { vr: \"SQ\", Value: [] } },\n writeOptions\n );\n cursor += emptySequenceSize - ITEM_DELIMITER_BYTES;\n\n const offsets = [];\n const items = (sequence && sequence.Value) || [];\n for (const item of items) {\n offsets.push(cursor);\n cursor +=\n ITEM_HEADER_BYTES +\n measure(item, writeOptions) +\n ITEM_DELIMITER_BYTES;\n }\n\n return offsets;\n}\n","// packages/dicomdir/src/dicomdir.js\n//\n// DICOMDIR (Media Storage Directory, PS3.10 / PS3.3 F) builder. Turns a flat\n// file-set description into the PATIENT -> STUDY -> SERIES -> leaf record\n// hierarchy and serializes it with real byte offsets in the three offset\n// attributes (OffsetOfTheNextDirectoryRecord, OffsetOfReferencedLowerLevel-\n// DirectoryEntity, and the root first/last record offsets).\n//\n// Offsets are computed by measure-then-write (see directoryOffsets.js): every\n// offset attribute is VR UL — fixed four bytes — so a measurement pass with\n// placeholder zeros produces the exact final layout, and the file is written\n// once. No patch-and-rewrite, no buffer scanning.\n\nimport {\n DicomMetaDictionary,\n WriteBufferStream,\n writeDataSet,\n writeTagObject,\n EXPLICIT_LITTLE_ENDIAN,\n TagHex\n} from \"@dcmjs-org/core\";\nimport { computeDirectoryOffsets } from \"./directoryOffsets.js\";\n\nconst MEDIA_STORAGE_DIRECTORY_SOP_CLASS_UID = \"1.2.840.10008.1.3.10\";\n\n// PS3.10 8.5: each File ID component is 1-8 characters from the ISO 9660\n// level 1 repertoire (A-Z, 0-9, underscore), at most 8 components deep.\nconst FILE_ID_COMPONENT = /^[A-Z0-9_]{1,8}$/;\n\nfunction assertEntry(entry, index) {\n const where = `buildDicomDirDataset: entries[${index}]`;\n if (!entry || typeof entry !== \"object\") {\n throw new Error(`${where} is not an object`);\n }\n if (\n !Array.isArray(entry.referencedFileID) ||\n !entry.referencedFileID.length\n ) {\n throw new Error(\n `${where}.referencedFileID must be a non-empty array of path components`\n );\n }\n for (const required of [\n \"sopClassUid\",\n \"sopInstanceUid\",\n \"transferSyntaxUid\"\n ]) {\n if (!entry[required]) {\n throw new Error(`${where}.${required} is required`);\n }\n }\n if (!entry.patient?.PatientID) {\n throw new Error(`${where}.patient.PatientID is required`);\n }\n if (!entry.study?.StudyInstanceUID) {\n throw new Error(`${where}.study.StudyInstanceUID is required`);\n }\n if (!entry.series?.SeriesInstanceUID) {\n throw new Error(`${where}.series.SeriesInstanceUID is required`);\n }\n}\n\nfunction assertFileID(components, index, allowNonConforming) {\n if (components.length > 8) {\n throw new Error(\n `buildDicomDirDataset: entries[${index}].referencedFileID has ` +\n `${components.length} components (max 8)`\n );\n }\n if (allowNonConforming) {\n return;\n }\n for (const component of components) {\n if (!FILE_ID_COMPONENT.test(component)) {\n throw new Error(\n `buildDicomDirDataset: entries[${index}].referencedFileID ` +\n `component \"${component}\" is not ISO 9660 level 1 ` +\n `conformant (A-Z 0-9 _, 1-8 chars) — rename the file or ` +\n `pass allowNonConformingFileIDs: true`\n );\n }\n }\n}\n\n/** The four keys every directory record starts with (PS3.3 F.3). */\nfunction recordCommon(recordType) {\n return {\n OffsetOfTheNextDirectoryRecord: 0,\n RecordInUseFlag: 0xffff,\n OffsetOfReferencedLowerLevelDirectoryEntity: 0,\n DirectoryRecordType: recordType\n };\n}\n\n/**\n * Group the flat entries into the PATIENT -> STUDY -> SERIES -> leaf tree,\n * preserving first-seen order at every level.\n */\nfunction groupEntries(entries, options) {\n const patients = new Map();\n entries.forEach((entry, index) => {\n assertEntry(entry, index);\n assertFileID(\n entry.referencedFileID,\n index,\n options.allowNonConformingFileIDs\n );\n\n const patientKey = entry.patient.PatientID;\n if (!patients.has(patientKey)) {\n patients.set(patientKey, {\n attributes: entry.patient,\n studies: new Map()\n });\n }\n const patient = patients.get(patientKey);\n\n const studyKey = entry.study.StudyInstanceUID;\n if (!patient.studies.has(studyKey)) {\n patient.studies.set(studyKey, {\n attributes: entry.study,\n series: new Map()\n });\n }\n const study = patient.studies.get(studyKey);\n\n const seriesKey = entry.series.SeriesInstanceUID;\n if (!study.series.has(seriesKey)) {\n study.series.set(seriesKey, {\n attributes: entry.series,\n leaves: []\n });\n }\n study.series.get(seriesKey).leaves.push(entry);\n });\n return patients;\n}\n\n/**\n * Flatten the tree depth-first into naturalized record objects, tracking the\n * flat index of each record's next sibling and first child so the offset\n * pass can wire the chains. Depth-first order means every link points\n * strictly forward in the file.\n *\n * @returns {{ records: Object[], links: Array<{next: number|null, child: number|null}> }}\n */\nfunction flattenRecords(patients) {\n const records = [];\n const links = [];\n\n const push = record => {\n records.push(record);\n links.push({ next: null, child: null });\n return records.length - 1;\n };\n\n const patientList = [...patients.values()];\n let previousPatientIndex = null;\n\n for (const patient of patientList) {\n const patientIndex = push({\n ...recordCommon(\"PATIENT\"),\n PatientName: patient.attributes.PatientName ?? \"\",\n PatientID: patient.attributes.PatientID\n });\n if (previousPatientIndex !== null) {\n links[previousPatientIndex].next = patientIndex;\n }\n previousPatientIndex = patientIndex;\n\n const studyList = [...patient.studies.values()];\n let previousStudyIndex = null;\n for (const study of studyList) {\n const studyIndex = push({\n ...recordCommon(\"STUDY\"),\n StudyDate: study.attributes.StudyDate ?? \"\",\n StudyTime: study.attributes.StudyTime ?? \"\",\n StudyDescription: study.attributes.StudyDescription ?? \"\",\n AccessionNumber: study.attributes.AccessionNumber ?? \"\",\n StudyInstanceUID: study.attributes.StudyInstanceUID,\n StudyID: study.attributes.StudyID ?? \"\"\n });\n if (previousStudyIndex === null) {\n links[patientIndex].child = studyIndex;\n } else {\n links[previousStudyIndex].next = studyIndex;\n }\n previousStudyIndex = studyIndex;\n\n const seriesList = [...study.series.values()];\n let previousSeriesIndex = null;\n for (const series of seriesList) {\n const seriesIndex = push({\n ...recordCommon(\"SERIES\"),\n Modality: series.attributes.Modality ?? \"OT\",\n SeriesInstanceUID: series.attributes.SeriesInstanceUID,\n SeriesNumber: series.attributes.SeriesNumber ?? 1\n });\n if (previousSeriesIndex === null) {\n links[studyIndex].child = seriesIndex;\n } else {\n links[previousSeriesIndex].next = seriesIndex;\n }\n previousSeriesIndex = seriesIndex;\n\n let previousLeafIndex = null;\n for (const entry of series.leaves) {\n const leafIndex = push({\n ...recordCommon(entry.recordType || \"IMAGE\"),\n ReferencedFileID: [...entry.referencedFileID],\n ReferencedSOPClassUIDInFile: entry.sopClassUid,\n ReferencedSOPInstanceUIDInFile: entry.sopInstanceUid,\n ReferencedTransferSyntaxUIDInFile:\n entry.transferSyntaxUid,\n InstanceNumber: entry.instance?.InstanceNumber ?? 1,\n ...entry.instance\n });\n if (previousLeafIndex === null) {\n links[seriesIndex].child = leafIndex;\n } else {\n links[previousLeafIndex].next = leafIndex;\n }\n previousLeafIndex = leafIndex;\n }\n }\n }\n }\n\n return { records, links };\n}\n\n/**\n * Build the naturalized DICOMDIR dataset (all offsets zero) plus the link\n * table the offset pass needs. Pure and inspectable — no serialization.\n *\n * @param {Array} entries - flat file-set entries; see module JSDoc/typedef\n * @param {Object} [options]\n * @param {string} [options.fileSetID=\"\"]\n * @param {boolean} [options.allowNonConformingFileIDs=false]\n * @returns {{ dataset: Object, links: Array, rootIndices: number[] }}\n */\nfunction buildDicomDirDataset(entries = [], options = {}) {\n const patients = groupEntries(entries, options);\n const { records, links } = flattenRecords(patients);\n\n const rootIndices = [];\n records.forEach((record, index) => {\n if (record.DirectoryRecordType === \"PATIENT\") {\n rootIndices.push(index);\n }\n });\n\n const dataset = {\n FileSetID: options.fileSetID ?? \"\",\n OffsetOfTheFirstDirectoryRecordOfTheRootDirectoryEntity: 0,\n OffsetOfTheLastDirectoryRecordOfTheRootDirectoryEntity: 0,\n FileSetConsistencyFlag: 0,\n DirectoryRecordSequence: records\n };\n\n return { dataset, links, rootIndices };\n}\n\n/** Mint the DICOMDIR file meta group (SOP identity lives here, not the body). */\nfunction buildDicomDirMeta(options = {}) {\n const fileMetaInformationVersion = new Uint8Array(2);\n fileMetaInformationVersion[1] = 1;\n return DicomMetaDictionary.denaturalizeDataset({\n FileMetaInformationVersion: fileMetaInformationVersion.buffer,\n MediaStorageSOPClassUID: MEDIA_STORAGE_DIRECTORY_SOP_CLASS_UID,\n MediaStorageSOPInstanceUID:\n options.fileSetUID || DicomMetaDictionary.uid(),\n TransferSyntaxUID: EXPLICIT_LITTLE_ENDIAN,\n ImplementationClassUID:\n \"2.25.80302813137786398554742050926734630921603366648225212145404\",\n ImplementationVersionName: \"dcmjs-0.0\"\n });\n}\n\n/**\n * Build and serialize a complete DICOMDIR: build the record tree,\n * denaturalize it, measure the layout, wire the offset chains, write once.\n *\n * @param {Array} entries - flat file-set entries\n * @param {Object} [options] - buildDicomDirDataset options plus\n * {string} [options.fileSetUID] fixed MediaStorageSOPInstanceUID\n * @returns {ArrayBuffer} the DICOMDIR file bytes\n */\n/**\n * The DICOM data dictionary gives the directory offset attributes the\n * special VR \"up\" (byte offset); the dcmjs writer has no \"up\" representation\n * and would fall back to UN. They are four-byte unsigned offsets — pin them\n * to UL so they serialize (and measure) as the fixed-width values the\n * offset algorithm depends on.\n */\nfunction pinOffsetVRs(dict) {\n for (const tag of [\"00041200\", \"00041202\"]) {\n if (dict[tag]) {\n dict[tag].vr = \"UL\";\n }\n }\n const items = dict[\"00041220\"]?.Value || [];\n for (const item of items) {\n for (const tag of [\"00041400\", \"00041420\"]) {\n if (item[tag]) {\n item[tag].vr = \"UL\";\n }\n }\n }\n}\n\n/**\n * Serialize { meta, dict } as a Part 10 file. This is the body of\n * DicomDict.write (packages/legacy) minus the deflate branch — a DICOMDIR\n * is always Explicit VR Little Endian, never deflated — rebuilt on core's\n * writeDataSet/writeTagObject so this package does not depend on\n * @dcmjs-org/legacy. DicomMessage.write and DicomMessage.writeTagObject\n * are one-line delegates to those same core functions, so the bytes this\n * produces are identical to DicomDict.write's, which is what keeps the\n * measured directory offsets valid.\n */\nfunction writePart10(meta, dict, writeOptions) {\n const metaSyntax = EXPLICIT_LITTLE_ENDIAN;\n const fileStream = new WriteBufferStream({ defaultSize: 4096 });\n fileStream.writeUint8Repeat(0, 128);\n fileStream.writeAsciiString(\"DICM\");\n\n const metaStream = new WriteBufferStream({ defaultSize: 1024 });\n if (!meta[TagHex.TransferSyntaxUID]) {\n meta[TagHex.TransferSyntaxUID] = {\n vr: \"UI\",\n Value: [EXPLICIT_LITTLE_ENDIAN]\n };\n }\n writeDataSet(meta, metaStream, metaSyntax, writeOptions);\n writeTagObject(\n fileStream,\n TagHex.FileMetaInformationGroupLength,\n \"UL\",\n metaStream.size,\n metaSyntax,\n writeOptions\n );\n fileStream.concat(metaStream);\n\n const useSyntax = meta[TagHex.TransferSyntaxUID].Value[0];\n writeDataSet(dict, fileStream, useSyntax, writeOptions);\n return fileStream.getBuffer();\n}\n\nfunction writeDicomDir(entries = [], options = {}) {\n const { dataset, links, rootIndices } = buildDicomDirDataset(\n entries,\n options\n );\n\n const meta = buildDicomDirMeta(options);\n const dict = DicomMetaDictionary.denaturalizeDataset(dataset);\n pinOffsetVRs(dict);\n\n const writeOptions = { allowInvalidVRLength: false };\n const recordOffsets = computeDirectoryOffsets({ meta, dict }, writeOptions);\n\n const sequence = dict[\"00041220\"];\n const items = (sequence && sequence.Value) || [];\n items.forEach((item, index) => {\n const { next, child } = links[index];\n item[\"00041400\"].Value = [next === null ? 0 : recordOffsets[next]];\n item[\"00041420\"].Value = [child === null ? 0 : recordOffsets[child]];\n });\n\n const first = rootIndices.length ? recordOffsets[rootIndices[0]] : 0;\n const last = rootIndices.length\n ? recordOffsets[rootIndices[rootIndices.length - 1]]\n : 0;\n dict[\"00041200\"].Value = [first];\n dict[\"00041202\"].Value = [last];\n\n return writePart10(meta, dict, writeOptions);\n}\n\nexport {\n buildDicomDirDataset,\n writeDicomDir,\n MEDIA_STORAGE_DIRECTORY_SOP_CLASS_UID\n};\n","import {\n buildDicomDirDataset,\n writeDicomDir,\n MEDIA_STORAGE_DIRECTORY_SOP_CLASS_UID\n} from \"./dicomdir.js\";\n\nexport {\n buildDicomDirDataset,\n writeDicomDir,\n MEDIA_STORAGE_DIRECTORY_SOP_CLASS_UID\n};\n\nexport default {\n buildDicomDirDataset,\n writeDicomDir,\n MEDIA_STORAGE_DIRECTORY_SOP_CLASS_UID\n};\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAUA,MAAM,yBAAyB,GAAG,UAAU;;AAE5C,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,MAAM,oBAAoB,GAAG,CAAC,CAAC;;AAE/B;AACA,SAAS,OAAO,CAAC,UAAU,EAAE,YAAY,EAAE;AAC3C,IAAI,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;AAC/D,IAAI,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,sBAAsB,EAAE,YAAY,CAAC;AAC1E,IAAI,OAAO,MAAM,CAAC,IAAI;AACtB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,uBAAuB,CAAC,SAAS,EAAE,YAAY,EAAE;AACjE;AACA,IAAI,IAAI,MAAM,GAAG,GAAG,GAAG,CAAC;;AAExB;AACA;AACA;AACA,IAAI,MAAM,Q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,EAAE,IAAI,EAAE,YAAY,CAAC;AAChD;;AC/WA,YAAe;AACf,IAAI,oBAAoB;AACxB,IAAI,aAAa;AACjB,IAAI;AACJ,CAAC;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcmjs-org/dicomdir",
3
- "version": "1.0.0-beta.15",
3
+ "version": "1.0.0-beta.16",
4
4
  "description": "DICOMDIR (Media Storage Directory, PS3.10) building and writing: turns a flat file-set description into the PATIENT/STUDY/SERIES/leaf record hierarchy with real byte offsets, serialized in one pass",
5
5
  "main": "./dist/index.cjs",
6
6
  "exports": {
@@ -21,11 +21,11 @@
21
21
  "directory": "packages/dicomdir"
22
22
  },
23
23
  "dependencies": {
24
- "@dcmjs-org/core": "1.0.0-beta.15"
24
+ "@dcmjs-org/core": "1.0.0-beta.16"
25
25
  },
26
26
  "devDependencies": {
27
- "@dcmjs-org/legacy": "1.0.0-beta.15",
28
- "@dcmjs-org/parser": "1.0.0-beta.15"
27
+ "@dcmjs-org/legacy": "1.0.0-beta.16",
28
+ "@dcmjs-org/parser": "1.0.0-beta.16"
29
29
  },
30
30
  "scripts": {
31
31
  "build": "rollup -c ../../rollup.packages.config.mjs"