Repository navigation
feat(dicomdir): the @dcmjs-org/dicomdir package — DICOMDIR reading and writing - #573
Merged
Merged
Conversation
package.json modeled on @dcmjs-org/core's (version 0.0.0, publishable, MIT, main ./src/index.js, repository directory), depending on @dcmjs-org/core at runtime and on @dcmjs-org/legacy only as a devDependency for test readback. Plus a short README with a usage sample. Co-Authored-By: Claude Fable 5 <[email protected]>
src/media/dicomdir.js, src/media/directoryOffsets.js, and
src/media/index.js from the v2.0-development branch land as
packages/dicomdir/src/{dicomdir,directoryOffsets,index}.js, and
test/dicomdir.test.js as packages/dicomdir/test/dicomdir.test.js —
byte-for-byte v2 content. Imports still point at the v2 tree; the next
commit rewires them onto @dcmjs-org/core and replaces the DicomDict
dependency.
Co-Authored-By: Claude Fable 5 <[email protected]>
The two legacy imports the v2 code carried are gone, keeping the hard
rule that this package never depends on @dcmjs-org/legacy:
- directoryOffsets.js measured element sizes through DicomMessage.write
and DicomMessage.writeTagObject; it now calls core's writeDataSet and
writeTagObject directly — the exact functions those statics are
one-line delegates to, so measured sizes are unchanged.
- dicomdir.js built a DicomDict and called dicomDict.write(); the Part
10 envelope (preamble + DICM, meta group behind its group length,
then the body) is now inlined as writePart10 on the same core
primitives, minus the deflate branch a DICOMDIR can never take.
Verified byte-identical against legacy DicomDict.write on the same
denaturalized { meta, dict }.
The test readback oracle rewires from the root dcmjs facade to
DicomMessage from @dcmjs-org/legacy (devDependency) plus
DicomMetaDictionary and validationLog from @dcmjs-org/core, and the
local EXPLICIT_LITTLE_ENDIAN constant gives way to core's export.
Full suite: 860 passed, 12 skipped, 872 total.
Co-Authored-By: Claude Fable 5 <[email protected]>
This was referenced Oct 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR ports the DICOMDIR builder from
v2.0-developmentinto a newpackages/dicomdir— the first (and only) wave for the@dcmjs-org/dicomdirpackage. The three source files (dicomdir.js,directoryOffsets.js,index.js) and the 16-test suite come over from the v2 branch'ssrc/media/, and the package depends on@dcmjs-org/coreand nothing else at runtime.Same commit shape as the split-wave PRs (#564–#567):
packages/dicomdir/package.json(version 0.0.0, publishable,"@dcmjs-org/core": "workspace:*"as the only runtime dependency) plus a README, and the lockfile picking up the new workspace project.v2.0-development.@dcmjs-org/legacyin two places, and the hard rule for this package is that it never does.directoryOffsets.jsmeasured element sizes throughDicomMessage.write/DicomMessage.writeTagObject; those statics are one-line delegates to core'swriteDataSet/writeTagObject, so the measurement calls core directly and the measured sizes can't change.dicomdir.jsbuilt aDicomDictand calleddicomDict.write(); that envelope (128-byte preamble + "DICM", meta group behind its group-length element, then the body) is now a ~35-linewritePart10on the same core primitives, minus the deflate branch a DICOMDIR can never take.Byte-exactness is the property that matters here — the directory offsets are measured against the exact layout the final write produces — so I checked it two ways. The ported suite itself proves the offsets: every nonzero offset value in the written file must land exactly on an
FFFE,E000item tag in the actual bytes, the next/lower chains must address every record exactly once, and the write must be deterministic. And I ran a scratch test (not committed) feeding the identical denaturalized{ meta, dict }through both the inlinedwritePart10and legacyDicomDict.write— the outputs are byte-identical, same length, same content.Using it looks like this:
The tests live in
packages/dicomdir/test/(jest's default testMatch picks the directory up — verified), fully synthetic, no fixtures. The readback oracle isDicomMessage.readFilefrom@dcmjs-org/legacy, declared as a devDependency only — it never appears insrc/.The ported lines are exempt per the budget convention; the hand-written total is about 120 lines (scaffold 55: package.json 18 + README 37; rewiring commit ~68 of its 93 inserted lines — the envelope, the import blocks, and comment-path updates — the rest being prettier rewraps of ported lines). Full suite after the port: 860 passed / 12 skipped / 872 total (the baseline 844 plus the 16 new),
pnpm run buildgreen, lint and format clean.🤖 Generated with Claude Code