Repository navigation
feat: @dcmjs-org/dcmjs - #595
Merged
Merged
Conversation
The package manifest (publishable under the @dcmjs-org scope, main at src/index.js, repository directory set), a short README, and the lockfile entry linking the one dependency, @dcmjs-org/core. Co-Authored-By: Claude Fable 5 <[email protected]>
A verbatim port of src/encapsulated/encapsulatedPdf.js from the v2 branch
HEAD (including the { InlineBinary } unwrap that postdates the PR #512
review), with its core import rebased onto @dcmjs-org/core and the PDF half
of the encapsulated index as the package surface. The video half stays on
the v2 branch for the media wave.
The eight-test v2 suite comes along, reworked for this branch's engine: the
legacy datasetToBuffer / DicomMessage.readFile round-trip becomes
denaturalize -> fromDataSet -> Part10Writer -> fromPart10 ->
NaturalizedListener, and the last test's read of test/sample-dicom.dcm
(provenance still being traced) is replaced by a synthetic MR instance
round-tripped through the same pipeline, so neither the package nor its
suite touches @dcmjs-org/legacy or the fixture.
Co-Authored-By: Claude Fable 5 <[email protected]>
…ding 16) The pad-trim heuristic strips a real zero byte: the Part 10 writer pads only an odd-length OB value, so a stored even length is ambiguous — the old code trimmed a trailing 0x00 anyway, corrupting an even-length original that genuinely ends in a zero byte (a 10-byte payload ending 0x00 came back as 9 bytes). encapsulatePdf now records EncapsulatedDocumentLength (0042,0015) with the exact original length, and extractEncapsulatedPdf slices to the declared length when present, keeping the trailing-NUL heuristic only as the fallback for files written before the element existed. The four new tests were written first and observed failing against the ported-unfixed code: the even-length zero-tail round-trip (9 bytes back, red), the recorded length element, and the declared-length odd slice; the heuristic-fallback test passed before and after, pinning that files without 0042,0015 still extract exactly. Co-Authored-By: Claude Fable 5 <[email protected]>
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]>
Co-Authored-By: Claude Fable 5 <[email protected]>
…elopment helpers.js, patient.js and patientToDataset.js come over verbatim from the v2 packages/fhir sources (prettier-normalized to this repo's config). The test imports are rewired to the concrete modules because the package index lands in a later slice. Co-Authored-By: Claude Fable 5 <[email protected]>
…exist A text-only HumanName used to map to null, and patientToDataset's deterministic overwrite then erased the patient's name entirely (review finding 19 on PR #512). When family/given/prefix/suffix are all absent, the free-text form now survives as a single-component PN. Co-Authored-By: Claude Fable 5 <[email protected]>
feat(pdfs): the @dcmjs-org/pdfs package — encapsulated PDF wrap and unwrap
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]>
feat: port the DICOMDIR builder into packages/dicomdir
The package shell for the video wave: name, entry point, MIT license, repository directory, and the @dcmjs-org/core workspace dependency. The image-module index exports only the header parsers for now; the dataset builder joins it in the next slice. Co-Authored-By: Claude Fable 5 <[email protected]>
Verbatim from v2.0-development: src/image/jpegInfo.js (SOF geometry and the JPEG transfer syntax mapping), src/image/mp4Info.js (the ISO BMFF box walk over a random-access reader), the makeTinyMp4 synthesized-fixture helper, and the ported mp4Info suite. Only the test import paths moved with the files; no behavior changed in this commit — review findings 9 and 15 are fixed on top, each with its regression observed red first. Co-Authored-By: Claude Fable 5 <[email protected]>
Review finding 9 (HIGH): the marker-walk guard only required four readable bytes, but the SOF fields span bytes[offset+4 .. offset+9]. Out-of-range reads coerce to 0 in the bitwise math, so the review map's vector — a 480x640 JPEG cut one byte into the width field — returned columns 512 instead of throwing, and a file cut right after the length field returned rows 0, columns 0. The reader now validates that the declared SOF segment fits inside the input (and is at least 8 bytes) before reading any field. The new jpegInfo suite is hand-written (v2 carried no suite for this file): the exact review vector, the cut-after-length shape, and valid SOF0/SOF1/SOF2/SOF3 paths. Both finding tests were observed red against the ported-unfixed reader before this fix. Co-Authored-By: Claude Fable 5 <[email protected]>
Review finding 15 (MED): the stts fallback loop trusted the raw uint32 entry_count. With stsz sample_count 0 and stts entry_count 0x00FFFFFF the parser spun 16.7 million iterations over zero-coerced reads past the box and fabricated numberOfFrames/frameRate from unrelated moov bytes; at 0xFFFFFFFF that is roughly 40 seconds of blocked thread. The loop now requires 16 + entryCount * 8 to fit inside the stts box and throws on the mismatch. The regression corrupts a synthesized MP4 exactly that way and asserts the parse rejects in under two seconds — observed red (the unfixed parser resolved with fabricated values) before this fix. Co-Authored-By: Claude Fable 5 <[email protected]>
feat(fhir): scaffold @dcmjs-org/fhir and port the Patient mappers (finding 19)
feat(video): scaffold @dcmjs-org/video with the JPEG and MP4 header parsers
Verbatim from v2.0-development src/image/buildImageDataset.js and its 21-test suite, with two mechanical adjustments for the package boundary: DicomMetaDictionary and validationLog now come from @dcmjs-org/core, and the test imports the builder from the package's image index (which now exports it alongside the header parsers). No behavior changed in this commit — review finding 10 is fixed on top with its regressions observed red first. Co-Authored-By: Claude Fable 5 <[email protected]>
…2.0-development imagingStudy.js comes over verbatim. The index keeps toFhir/toBundle unchanged but swaps the documentReference import for a null-returning placeholder until the DocumentReference mapper lands in the next slice (v2's index has no fromFhir re-export; the event-stream integration is a deferred slice of its own). The ported toFhir suite reads the sample-dicom.dcm fixture from packages/fixtures/dicom and naturalizes it through @dcmjs-org/parser instead of the umbrella, and the two umbrella-namespace tests are deferred with the facade slice. Co-Authored-By: Claude Fable 5 <[email protected]>
…riesInstanceUID Review findings 17 and 18 on PR #512. A missing (0008,0016) used to fabricate the CT Image Storage UID, asserting an unknown instance was a CT image; a missing (0020,000E) produced series.uid: null — invalid against R4B's 1..1 cardinality — and merged every such dataset under one "unknown" key. Both inputs are now skipped with a validationLog warning rather than emitted invalid, since instance.sopClass and series.uid are required elements a server would reject anyway. Co-Authored-By: Claude Fable 5 <[email protected]>
Review finding 10 (HIGH): numberOfFrames came only from decodedImage.numberOfFrames || 1 and was never derived from or checked against options.encapsulated.frames.length, and the attribute was only written when above 1. Three encapsulated fragments therefore produced an instance with no NumberOfFrames — a conformant reader showed frame 1 and the rest were unreachable — while an explicit numberOfFrames 7 over 2 fragments emitted the bogus claim unchecked. In encapsulated mode the fragment list is now the ground truth: the count defaults to frames.length and an explicit mismatch throws. Both regressions were observed red against the ported-unfixed builder before this fix; two companion tests pin that a matching explicit count is accepted and that a single fragment still omits the attribute. Co-Authored-By: Claude Fable 5 <[email protected]>
Writing a DICOMDIR from @dcmjs-org/dicomdir alone threw: core's SequenceOfItems.writeBytes serialized each item through the late-bound DicomMessage, which only @dcmjs-org/legacy (or the dcmjs wrapper) registers — so the package's hard no-legacy rule held in its imports but not at runtime. The committed suite never saw it because its readback oracle imports legacy, wiring the seam as a side effect. core/writeCore.js now registers writeDataSet into ValueRepresentation at load (a direct import between the two files is a module-level CJS cycle that breaks Tag's registration, hence the seam), and the sequence writer calls that instead of DicomMessage.write — the exact function DicomMessage.write delegates to, so bytes are unchanged either way. The new packages/dicomdir/test/standalone.test.js imports nothing from legacy (jest's per-file module registry guarantees the seam stays unwired) and proves a full DICOMDIR write: DICM magic, four undefined-length item headers for PATIENT/STUDY/SERIES/IMAGE, deterministic bytes. Full suite: 861 passed, 12 skipped, 873 total. Co-Authored-By: Claude Fable 5 <[email protected]>
feat(video): port buildImageDataset with the encapsulated frame-count fix
feat(fhir): port the ImagingStudy mapper and toFhir/toBundle surface (findings 17, 18)
Verbatim from v2.0-development src/encapsulated/encapsulatedVideo.js and its 8-test suite, with one mechanical adjustment for the package boundary: DicomMetaDictionary and isVideoTransferSyntax now come from @dcmjs-org/core instead of relative paths. buildVideoDataset shapes the Supplement 225 Video Photographic Image shell (XC modality, cine timing, the (7FE0,0003) uint64 total length as a BigInt), encapsulateVideo splits the MP4 into fragment-sized exact ArrayBuffer slices, and extractEncapsulatedVideo concatenates fragments and truncates to the declared length so the odd-fragment pad byte drops on extraction. Co-Authored-By: Claude Fable 5 <[email protected]>
The video half of v2's encapsulated index only — the PDF half (encapsulatedPdf) belongs to the media wave. Co-Authored-By: Claude Fable 5 <[email protected]>
documentReference.js comes over verbatim, and the package index swaps the slice-two placeholder for the real import and re-export, completing the toFhir three-key surface. The ported test builds its Encapsulated PDF datasets synthetically (v2 built them with dcmjs.encapsulated, which belongs to the pdfs wave and is not on this branch yet), keeps the Part 10 round trip through @dcmjs-org/legacy as a test-only devDependency, and naturalizes the image fixture through @dcmjs-org/parser like the toFhir suite. Co-Authored-By: Claude Fable 5 <[email protected]>
…tLength Review findings 8 and 16 on PR #512. The event-stream naturalizer wraps binary elements as { InlineBinary } (base64 string, ArrayBuffer, or view); payloadBytes never unwrapped that shape, and new Uint8Array of a plain object is empty, so every naturalized encapsulated document silently mapped to { size: 0, data: "" }. The unwrap block mirrors the one in v2's extractEncapsulatedPdf, kept as a local copy because this package must not depend on the pdfs package. The even-length pad-trim heuristic also stripped real trailing zero bytes, since an even stored length never carries a writer pad. When EncapsulatedDocumentLength (0042,0015) is present it now wins over the heuristic; the write side that emits it lands with the pdfs wave. Co-Authored-By: Claude Fable 5 <[email protected]>
fix: let core's sequence writer run with no eager engine loaded
feat(video): port the buffered video encapsulation layer
…dcmjs # Conflicts: # packages/core/src/ValueRepresentation.js # packages/core/src/core/writeCore.js # pnpm-lock.yaml
awatson1978
marked this pull request as ready for review
October 19, 2026 07:02
…dcmjs # Conflicts: # packages/dicomdir/README.md # packages/dicomdir/package.json # packages/dicomdir/test/standalone.test.js # pnpm-lock.yaml
Take the 1.0-beta design for every package that the assemblies #577, #585, #588 and #584 merged: @dcmjs-org/encapsulated replaces @dcmjs-org/pdfs, @dcmjs-org/imaging holds buildImageDataset and parseJpegInfo, and @dcmjs-org/media and @dcmjs-org/fhir come from 1.0-beta unchanged. Keep only the wrapper on top: the @dcmjs-org/dcmjs rename without "private", the media/encapsulated/image/fhir namespaces in src/index.js, the root dependency on @dcmjs-org/media, test/bundle-size.test.js, and the pnpm 12.9.1 pin. The dcmjs.fhir namespace tests move from packages/fhir/test to test/fhirNamespace.test.js, so the package tests stay off the root wrapper. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The default export of @dcmjs-org/dcmjs now has exactly the dcmjs 0.52 names. The new engines move to subpath entries, so the default bundles stay within x1.05 of 0.52: - @dcmjs-org/dcmjs/eventStream (moved from the default export) - @dcmjs-org/dcmjs/media, /encapsulated, /image (the v2 namespaces) - @dcmjs-org/dcmjs/fhir (the FHIR sink plus fromPart10) Build: one ESM build with six entries keeps the @dcmjs-org/* imports external (they stay in dependencies); the shared code goes in one dcmjs.shared-<hash>.js chunk, so each entry exports only its public names. The UMD builds inline everything and have the default entry only. Tests: the bundle-size suite builds only the bundles it measures, rebuilds a stale build/, spawns rollup through node (works on Windows), measures an entry with its chunks, and checks the export names. A new 0.52-compatibility test pins the 0.52 export names. Release tooling: the trusted-publishing bootstrap also prepares the root package; the publish workflow builds before it tests. RELEASE_PLAN.md gets the wrapper requirements (WRAP-USR-n, WRAP-IMP-n), the size policy and the measurements. The pnpm-workspace.yaml comments name pnpm 12. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Both naturalizers (DicomMetaDictionary.naturalizeDataset and
NaturalizedListener) now give the same object, and the spec in
docs/specs/naturalized-dataset.md defines it.
- A private creator (gggg,00xx) and its reserved block naturalize to one
`${gggg}:${creator}` key: { creator, reservedBlock, xEE... }, with the
VRs in _vrMap[blockKey][xEE]. The hex tags, registerTag() keywords and
private dictionary keywords stay as non-enumerable aliases.
- denaturalizeDataset accepts the block form and the hex-tag form. A block
keeps its reservedBlock when it is free, and moves to the first free xx
when it is not.
- fromNaturalized / DicomEventStream.fromNaturalized() streams a
naturalized dataset to any sink, for example Part10Writer.
- NaturalizedListener outputs _vrMap, and gives binary values as a list
of ArrayBuffer in place of { InlineBinary }.
- Both naturalizers take { binaryAs: "Uint8Array" } for no-copy views.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
An implicit-VR file, or a gateway that converts unknown VRs, can give a private creator as UN bytes. The block key was then "7FDD:[object ArrayBuffer]". The creator bytes now decode as LO text without the trailing padding (NAT-I-PLACE-3). Co-Authored-By: Claude Opus 5.5 <[email protected]>
- A delete of a hex alias (or a registerTag() keyword alias) removes the
element from the denaturalized output again, and a delete of a creator
alias removes the block. De-identification code that deletes private
tags by hex key keeps working (NAT-U-HIST-7).
- An alias reads the block through its key, also after the user replaces
the block (NAT-U-HIST-8).
- A creator for two blocks of one group gives a warning (NAT-U-PRIV-9).
- A creator from DICOM JSON InlineBinary decodes like a UN creator, and a
creator decodes with the chunked latin1 decoder, from at most 64 bytes.
Creator padding is removed for every source (NAT-U-PRIV-10).
- A flat element in the range of a block joins the block, and a flat
registerTag() keyword holds its block number (NAT-U-RT-1, NAT-I-RT-1).
- isPrivateTag uses the Tag methods; one recordVr and one
registeredTagEntry helper serve both naturalizers.
- Outdated comments about { InlineBinary } and the draft section 18.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
- The packages published as source (dicomdir, encapsulated, fhir, imaging, media, video) get a files list. Without it, pnpm applied the root .npmignore, which excludes src/, and every subpath failed after an install (WRAP-IMP-6). - The src/ shims import @dcmjs-org/core and @dcmjs-org/parser in place of files in packages/<name>/src. The ESM shared chunk held a second copy of core: the consumer bundle was x1.49 of 0.52, and it is now x1.027 (WRAP-IMP-2). - The size check bundles build/dcmjs.es.js with its packages, as an application bundler does (WRAP-USR-2, WRAP-IMP-5). - core and parser get an exports map with a "source" condition, so Node runs the ESM entries in a built checkout (EXAMPLES.md, pnpm bench), and core lists its side-effect modules (WRAP-IMP-7). - The subpaths are import-only, so require() cannot load a second copy (WRAP-USR-3). - The UMD output has a fixed indent, and pnpm run build deletes build/. - bench/worker.mjs imports the eventStream subpath. - test/package-layout.test.js checks the files lists, the import-only subpaths, the sideEffects list and the source maps of build/. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Private blocks:
- fromNaturalized denaturalizes the dataset itself, not a rest-spread
copy, so a delete of a private alias also reaches Part10Writer and the
other sinks (NAT-U-HIST-7).
- A deleted alias stays deleted: definePrivateAliases does not define it
again, and a plain value set on the deleted name is a new flat element
that replaces the deleted one in its block.
- A write to an element alias after the block is deleted makes a flat
element.
- A creator that is not text or bytes ({ BulkDataURI }, an object) is no
creator; a SharedArrayBuffer creator decodes as bytes.
- A binary-VR element with non-buffer values (UN with a string Value) is
a list in both naturalizers, and hex keys are uppercase in both.
- naturalBinaryFragment copies a SharedArrayBuffer to an ArrayBuffer in
the default mode.
Wrapper:
- core reads process.env.LOG_LEVEL only when process exists. The ESM
entry now imports core's dist/, where nothing replaced the expression,
so a browser bundle threw "process is not defined" (WRAP-USR-6). The
bundle-size suite runs the consumer bundle in a vm with no process.
- The ESM build removes the shared chunks of earlier builds.
- RELEASE_PLAN: WRAP-USR-3 records the CommonJS and jest limits and the
two-copy case of require() plus import; the four test-only shims,
the source-based size check and the jest resolution are stated exactly.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
- A binary element with no value is null in both naturalizers (it was [] from NaturalizedListener after 86f998c), and NAT-U-BIN-1 records the binary list rule as a user requirement, without the conflict with NAT-U-VAL-4. - An alias delete removes the element while the block still holds the value that the alias last saw. The source value never survives a delete, also in a copied block object, and a different value written into the block after the delete is kept (it was lost). - A write to an element alias after the block key is deleted makes a flat element with the VR of the block element (it was skipped with no VR). - A number in a creator slot is no creator. - core reads process.env.LOG_LEVEL in a try block, so the UMD build applies the build-time level in a browser again. - One isBinaryData helper in core replaces four local byte checks. - The doc comment of creatorText, and the WRAP-USR-6 test reference (moved to WRAP-IMP-8). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ties Naturalized values: - An attribute with no dictionary VM (a private or unknown element) is a list, also for one value, as for VM > 1 (NAT-U-VAL-4). A private or unknown sequence with one item is the array-like item object, as for a standard sequence (NAT-U-SQ-1). - A PN attribute of a dataset or item has a converting setter: an assigned PN string, object or list is stored in the component form, one object for VM 1 and a list otherwise (NAT-U-VAL-5). - A binary value whose fragments all have zero bytes (a Part 10 reader gives one empty fragment for an empty element) is null (NAT-U-BIN-1). Utilities in @dcmjs-org/core (NAT-U-UPS): - upsertAttribute(dataset, key, value, { vr, length }), upsertPersonName(dataset, key, value, length), and setVr(dataset, key, vr[, elementKey]), which creates _vrMap when it is missing. A private alias key stores into its block. Private aliases: - A delete of an alias always wins at the write, with no value check (the review's value-tracking rule had a new edge case in each round). - A write to an element alias after its creator alias is deleted makes a flat element, as after a delete of the block key. - A flat element that joins a block takes the VR of the block element when _vrMap has none for it. Also: DicomWebJsonWriter accepts a SharedArrayBuffer fragment, and the log.js comment no longer holds the text that the replace plugin rewrites. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…1.06 dcmjs.data now also gives setVr, upsertAttribute, upsertPersonName and definePrivateAliases. With them the UMD bundle is x1.051 of 0.52, so the ceiling of WRAP-USR-2 rises from x1.05 to x1.06 (a maintainer decision). The ESM consumer bundle is x1.036. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- upsertAttribute and upsertPersonName are now setAttribute and setPersonName (NAT-U-SET); setVr keeps its name. - Without a length, the set utilities take the value count from the dictionary VM (setAttribute(ds, "PatientID", "X") stores "X"), and a hex key is uppercase, or the keyword for a standard tag. A VR other than PN replaces an earlier PN setter with plain data. - A private PN element converts a later string through its alias, when _vrMap gives PN for it. - Both producers store a PN value through setPersonName, so a value is converted once. - A present element with no Value is [] for a list VM and null for a scalar VM in naturalizeDataset too, as in the listener. - NaturalizedListener looks up a tag with the dictionary proxy, so the repeating groups (60xx OverlayRows ...) and registerTag() entries get their keywords, as in naturalizeDataset. - valueLength(entry) is the one value-count rule for both producers and the set utilities; a registerTag() entry with no VM is a list. - The isMultiVM and privateBlocks doc comments, a nested PN list, and the tests of the round-5 items that had none. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Should fix: - An invalid LOG_LEVEL (another library's level, such as "verbose" or "fatal") no longer stops the import: core uses the variable only when loglevel knows the level, else "warn". The proper fix is proposed upstream in pimterry/loglevel#210 (log.parseLevel and a tolerant setDefaultLevel). - setAttribute stores a sequence by NAT-U-SQ: [] with no item, the array-like item object for one item. - A hex key of a flat registerTag() private element sets its keyword, so the value is no longer lost on write. - A private PN element with no creator gets the converting setter. - The source-map guard in test/package-layout.test.js builds build/ when it is absent or stale, so it runs in PR CI. The build helper is shared with test/bundle-size.test.js and takes a lock for parallel workers. Reuse: naturalValues.js holds the sequence, binary and simple value rules for both producers and setAttribute; isHexTag is the one hex-key test. Nits: setVr ignores a creator alias, setAttribute on a creator alias throws a clear TypeError, the PN setter rules are in NAT-U-VAL-5, MIGRATION (PN, the wrapper, ESM-only subpaths, LOG_LEVEL) and RELEASE_PLAN (legacy and generator inlined, LOG_LEVEL, the size table, test references out of the user requirements) are current, the README gives the @beta install, and stale test names and comments are fixed. Tests: LOG_LEVEL values, the sequence, registerTag and flat PN cases, naturalizeDataset(readFile) in the cross-source matrix, and a private round trip on a real fixture. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Should fix: - After a delete of a private hex alias, setAttribute on that hex name makes a new flat element, also when a registerTag() keyword names the same block element (the ceaf1b3 key mapping lost the value). - setAttribute treats the dictionary code "ox" (PixelData) as binary: a list of ArrayBuffer, and no "ox" in _vrMap. A binary value set through setAttribute is a list of ArrayBuffer, or Uint8Array with binaryAs. - The jest advice is a moduleNameMapper to build/<name>.es.js; jest resolves with the CommonJS conditions, so a transform alone does not find the import-only subpaths (WRAP-USR-3, MIGRATION, README). Also: - denaturalizeDataset keeps a null value entry, as a reader gives for an empty DS of VM 1-n (Value: [null]); it threw before (sample-op.dcm). - LOG_LEVEL accepts 0 to 5 as a string; WRAP-USR-7 records the run-time read of the ESM entries. - setPersonName on a creator alias throws the clear TypeError. - The listener converts binary fragments in one binaryValue call. - The PN delimiter text, MIGRATION intro, spec line wrap, a misleading comment, the source-map regex, and the real-file test parse once. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- A null entry of a text VR (LO, LT, SH, ST, UC, UT) denaturalizes to an empty value. Since 7b8c26e accepted null entries, the writers wrote it as the text "null" (NAT-U-RT-7, recorded in MIGRATION). - The jest config maps the default entry to build/dcmjs.es.js too, so the default entry and the subpaths share one reader state in jest (WRAP-USR-3, MIGRATION, README). - setAttribute checks binaryAs (NAT-I-BIN-2), and isVrCode is the one VR-code test. - MIGRATION gives the 0 to 5 LOG_LEVEL values; the null-entry comment sits at the code it describes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- BufferStream.writeUTF8String writes null as empty text, as writeAsciiString does, so LO, SH, ST, LT, UC and UT no longer write the text "null" on any write path (DICOM JSON dicts and fromDicomWebJson included). The TEXT_VRS step in denaturalizeDataset is gone. - PN: a null name is an empty name that keeps its position (pnObjectToString, toPersonNameValue): [null, "C^D"] writes "\C^D". - A binary number VR (US, SS, UL, SL, FL, FD, UV, SV) writes null as 0 with a warning, because it has no empty value. - NAT-U-RT-7 and MIGRATION state these rules; NAT-I-NULL-1 places them. - isVrCode is no longer a public @dcmjs-org/core export; the jest docs name the babel.config.js that the ESM build files need; the size table is current. - test/core/nullEntries.test.js writes the bytes on three paths. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- The warning for a null binary number is in one method, ValueRepresentation.warnNullEntries, which uses isBinary() in place of a separate VR list (so AT is covered too). - It warns only for a null entry of a list. A null value that is not a list is an element with no value, which is written with zero length; the false "written as 0" warning for it is gone. - The UV writer calls warnNullEntries before it turns null into 0n, so a UV null now warns. - NAT-U-RT-7, NAT-I-NULL-1 and MIGRATION give the right VR list (SV is not a core VR; AT is in) and the no-value rule. - Tests: an element with no value is written with zero length and no warning, on the dict and naturalized paths; a UV null warns. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- @dcmjs-org/dcmjs no longer has the /fhir subpath (src/fhir.js and its test file are gone). FHIR is preliminary: a user imports the separate @dcmjs-org/fhir package. It stays a runtime dependency, because the preliminary DicomEventStream.fromFhir() and toFhir() use it. README, MIGRATION and WRAP-USR-3 say so (a maintainer decision). - The code and test comments of this wave no longer point to RELEASE_PLAN requirement IDs (WRAP-*); they keep the plain explanation. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The wrapper no longer depends on @dcmjs-org/fhir. DicomEventStream drops fromFhir() and toFhir(); toFhir(await events.toNaturalized()) of @dcmjs-org/fhir replaces events.toFhir(). The fhir README withdraws the fromFhir requirements, and the PDF facade tests move to pdfEventStream.test.js. Co-Authored-By: Claude Opus 5.5 <[email protected]>
wayfarer3130
approved these changes
Oct 23, 2026
|
🎉 This PR is included in version 1.0.0-beta.4 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
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 is the assembly PR for the wrapper wave. It is the seventh and last package assembly. It merges
release/1.0-beta-dcmjsinto1.0-beta. Do not merge it yet: the assemblies must go in a deliberate order (see "What the branch carries").What this PR does
This PR gives a 0.52 user the package that they install. A project changes one thing, the import name
dcmjs→@dcmjs-org/dcmjs, and its 0.52 code continues to work. A project that does nothing continues to get 0.52 from npm.data,sr,adapters,derivations,normalizers,utilities,anonymizer,async,DICOMWEB,log.@dcmjs-org/dcmjs/eventStream: the streaming readers and writers, and theDicomEventStreamfacade.@dcmjs-org/dcmjs/media(DICOMDIR),/encapsulated(PDF and video),/image(image builders without codecs).@dcmjs-org/fhir. The wrapper does not depend on that package, andDicomEventStreamhas no FHIR methods.The root
package.jsonchanges its name fromdcmjsto@dcmjs-org/dcmjsand removes"private": truein the same commit. Section 9 of RELEASE_PLAN.md gives this pair. The flag existed only to stop a recursive publish of the unscoped name before the wrapper existed.Commits in this wave
"private", the root workspace dependencies (@dcmjs-org/dicomdir,@dcmjs-org/mediaand@dcmjs-org/generatorin addition to core, fhir, parser, pdfs and video), and the umbrella-namespace tests that PR feat(fhir): port the ImagingStudy mapper and toFhir/toBundle surface (findings 17, 18) #579 deferred, restored inpackages/fhir/test/toFhir.test.js.2fce372: the 0.52 default export and the subpath entries.@dcmjs-org/*imports stay external (they stay independencies). The shared code goes in onedcmjs.shared-<hash>.jschunk, so each entry exports only its public names. The UMD builds inline all code and have the default entry only.test/compat-052.test.jspins the 0.52 export names.e4bf91d: one naturalized form for private blocks and binary values.(gggg,00xx)and its reserved block naturalize to one key${gggg}:${creator}, with the value{ creator, reservedBlock, xEE... }. The VRs go in_vrMap[blockKey][xEE].registerTag()keywords and the private dictionary keywords stay readable as non-enumerable aliases.denaturalizeDatasetaccepts the block form and the hex-tag form. A block keeps itsreservedBlockwhen that number is free in the group. If not, the block moves to the first free number.DicomEventStream.fromNaturalized()sends a naturalized dataset to any sink, for examplePart10Writer.NaturalizedListener(toNaturalized()) now gives the same object asnaturalizeDataset. It adds_vrMap, and it gives a binary value as a list ofArrayBuffer, in place of{ InlineBinary }.{ binaryAs: "Uint8Array" }. With this option, each binary fragment is aUint8Arrayview, and the naturalizer copies no bytes. The default staysArrayBuffer.f801254: a fix for a private creator that the reader gives as UN bytes. An implicit-VR fixture gave the block key"7FDD:[object ArrayBuffer]". The creator bytes now decode as LO text.eb225ce: the review findings on the private blocks.deleteof a hex alias removes the element from the written output again. Adeleteof a creator alias removes the block. So code that deletes private tags by hex key (de-identification) continues to work.InlineBinarydecodes like a UN creator. The decoder reads at most 64 bytes, so a malformed large value cannot stop the naturalizer.registerTag()keyword holds its block number.5e7efdb: the published subpaths, and one copy of core in the ESM bundle.fileslist. Without it, pnpm applied the root.npmignore, which excludessrc/. Every subpath then failed after an install.src/shims now import@dcmjs-org/coreand@dcmjs-org/parser, not files inpackages/<name>/src. Before, the ESM shared chunk held a second copy of core, and the consumer bundle was ×1.49 of 0.52.build/dcmjs.es.jswith its packages, as an application bundler does.exportsmap with asourcecondition. Node can now run the ESM entries in a built checkout (EXAMPLES.md,pnpm bench). Core lists its modules with side effects insideEffects.require()cannot load a second copy of dcmjs.pnpm run builddeletesbuild/first.test/package-layout.test.jschecks thefileslists, the import-only subpaths, thesideEffectslist, and the source maps ofbuild/.86f998c: the third review round.fromNaturalizeddenaturalizes the dataset itself, not a copy. So adeleteof a private alias also reachesPart10Writerand the other sinks.definePrivateAliases. A value that the user sets on the deleted name replaces the deleted element.process.env.LOG_LEVELonly whenprocessexists. Before this fix, a browser bundle of the ESM entry threw "process is not defined" on load. The bundle-size suite now runs the consumer bundle with noprocessglobal.1cb14f3: the fourth review round.nullin both naturalizers. NAT-U-BIN-1 records the binary rules as user requirements.LOG_LEVELin a browser again.isBinaryDatahelper in core replaces four local byte checks.83ab6c0: one value rule for unknown VMs, PN setters, and the upsert utilities.dataset.PatientName = "Doe^John"stores{ Alphabetic: "Doe^John" }. The result is one object for VM 1, and a list otherwise.@dcmjs-org/coreexportssetAttribute(dataset, key, value, { vr, length }),setPersonName(dataset, key, value, length)andsetVr(dataset, key, vr).lengthis the value count.setVrcreates_vrMapwhen it is missing.null.dc221d3: the utilities ondcmjs.data, and a size ceiling of ×1.06.dcmjs.dataalso givessetVr,setAttribute,setPersonNameanddefinePrivateAliases.227dffb:setAttributeandsetPersonName, and the sixth review round.setAttributeandsetPersonName(earlierupsertAttributeandupsertPersonName).length, the dictionary VM decides:setAttribute(ds, "PatientID", "X")stores"X". A hex key is uppercase, and a standard hex tag is its keyword.setPersonName, so each value is converted once.Value(as DICOMweb JSON gives) is[]for a list VM andnullfor a scalar VM, in both naturalizers.NaturalizedListenergives the repeating groups (for exampleOverlayRowsin group 60xx) their keywords, asnaturalizeDatasetdoes.ceaf1b3: the final review findings.LOG_LEVELno longer stops the import. Examples areverbose(winston) andfatal(pino). Core uses the variable only when loglevel knows the level, and useswarnotherwise. The proper fix is in loglevel: Make setDefaultLevel() tolerate invalid levels, and add parseLevel() pimterry/loglevel#210 addslog.parseLevel()and asetDefaultLevel()that does not throw.setAttributestores a sequence in the naturalized form. A hex key of aregisterTag()private element sets that element. A private PN element with no creator gets the converting setter.build/when it is absent or stale, so it runs in PR CI.setAttributeuse it.LOG_LEVELvaluesnaturalizeDataset(readFile)in the cross-source matrix@betainstall.7b8c26e: the round-8 review findings, and an empty DS value.setAttributeon that name makes a new element. This holds also when aregisterTag()keyword names the same element.setAttributeonPixelData(dictionary codeox) stores a list ofArrayBuffer.moduleNameMapper, because jest does not resolve the import-only subpaths.denaturalizeDatasetkeeps an empty DS value (Value: [null]). Before this fix, it threw onsample-op.dcm.LOG_LEVELaccepts0to5as a string, and WRAP-USR-7 records the run-time read.1563971: the round-9 review findings.nullentry of a text VR (LO, LT, SH, ST, UC, UT) is written as an empty value. Before this fix,[null, "A"]was written as"nullA".build/dcmjs.es.jstoo, so the default entry and the subpaths share one copy of the reader state in jest.9a54affandf93e380:nullentries in the writer layer.[null, "C^D"]writesC^D)0with a warning, because it has no empty valuenull.57aea5b: no/fhirsubpath, and no plan IDs in code./fhirsubpath. FHIR is preliminary, and the README and MIGRATION say to import@dcmjs-org/fhirdirectly.setAttributechecks itsbinaryAsoption.1dc7824: no FHIR methods onDicomEventStream.fromFhir()andtoFhir(), and the wrapper no longer depends on@dcmjs-org/fhir.toFhir(await events.toNaturalized())of@dcmjs-org/fhirgives the same result as the oldevents.toFhir().packages/fhir/README.mdwithdraws FHIR-USR-7 to FHIR-USR-9, FHIR-IMP-3 and FHIR-IMP-4, which held thefromFhirrequirements. The git history keeps the old code.fhirPdfEventStream.test.jsmoved totest/eventStream/pdfEventStream.test.js.build/eventStream.es.jsdrops from 57,179 to 41,885 bytes.Worked example
We ran this code on the branch tip (
57aea5b). Each comment shows the printed output. The input ispackages/fixtures/testImages/CT1_UNC.explicit_little_endian.dcm, a GE CT file with 9 private blocks.Bundle size
The baseline comes from the published
[email protected]npm tarball.test/bundle-size.test.jsmeasured the branch tip:build/dcmjs.js(UMD)build/dcmjs.es.js(ESM), bundled with its@dcmjs-org/*packagesThe test enforces a ceiling of ×1.06 for both. The ceiling was ×1.05 until the naturalized-dataset utilities joined
dcmjs.data. The earlier ×1.35 provisional ceiling is gone, because the new engines are now subpath entries and are not in the default bundles.The ESM number is the size of the bundle that an application bundler gives. An earlier version of the test counted only the files in
build/(×1.025). That count missed the second copy of core that a consumer got (×1.49). WRAP-USR-2 now states the consumer bundle.Test evidence
1dc7824gave 1172 tests passed and 12 skipped, in 113 suites. No test of the branch failed. (The count fell from 1191 because thefromFhirandtoFhirtests are gone.)test/core/privateBlocks.test.js(12 tests)test/core/naturalizedAttributes.test.js(11 tests)test/core/logLevel.test.js(2 tests)test/core/nullEntries.test.js(1 test, three write paths)test/core/binaryValues.test.js(3 tests)test/package-layout.test.js(11 tests)test/compat-052.test.jstest/eventStream/NaturalizedListener.test.jsandtest/issues/issue388-private-tags.test.js1dc7824. The CI results are on the Checks tab.To run the tests of this wave from the repository root:
What the branch carries
release/1.0-beta-dcmjsstarts fromrelease/1.0-beta-fhir. That branch already contains the core engine trunk, the three bulk-data branches, the media bundle, and the FHIR slices. The branch then merges the newest commits of the core branch (#570, #590–#593), and then adds the commits of this wave.So the diff against
1.0-betaincludes all of that content. The earlier assemblies (#542, #575, #577, #584, #585, #588) each cover their part, with their own worked examples. When those assemblies merge first, this diff becomes only the wrapper wave.The only merge conflict was
pnpm-lock.yaml. We took one side, ranpnpm install --no-frozen-lockfile, and committed the result as an ordinary merge commit.Breaking changes
@dcmjs-org/dcmjs. The unscopeddcmjsname continues to serve 0.52 until the team decides that GA is ready.2fce372, this branch puteventStream,media,encapsulated,imageandfhiron the default export. Code that used them there must change to the subpath entries; FHIR has no subpath and comes from@dcmjs-org/fhir. 0.52 did not have these names.DicomEventStream. An earlier beta hadDicomEventStream.fromFhir()andevents.toFhir(). The 1.0 facade does not. UsetoFhir(await events.toNaturalized())of@dcmjs-org/fhir. The FHIR-to-DICOM source (an inline PDF or JPEG in a DocumentReference or Media) has no replacement in this PR.require()of a subpath fails withERR_PACKAGE_PATH_NOT_EXPORTED. Arequire()of the default entry still gives the UMD build.node_modules/@dcmjs-orgto CommonJS cannot load a subpath.require()and a subpath withimporthas two copies of the reader state (the log level, theregisterTag()entries). Such code must useimportfor both.defaultcondition, so thatrequire()and jest work, butrequire()then loads a second copy on Node 22.12 and later.Object.keysof a naturalized dataset now lists one${group}:${creator}key for each private block. It no longer lists the 8-digit hex keys. A read, a write and adeleteof a hex key still work through the alias. A private or unknown value is now a list, also for one value (["a"], not"a"). A write to a creator alias (for exampledataset["00290010"] = "X") throws aTypeErrorin strict-mode code, and has no effect in other code. docs/MIGRATION.md change 6 describes all of this.Valueis now[]for a list VM (for exampleImageType) fromnaturalizeDataset. Before, it wasnull.dataset.PatientName = "Doe^John"now stores{ Alphabetic: "Doe^John" }at once. Code that compares the attribute with a string after an assignment must useString(dataset.PatientName).LOG_LEVELin the ESM build. The ESM entries readLOG_LEVELwhen they load. A loglevel level (a name, or0to5) applies, and any other value giveswarn. The UMD builds use the level that the build fixed.toNaturalized()now gives the private blocks above,_vrMap, and binary values as a list ofArrayBufferin place of{ InlineBinary }. The earlier draft keys ("10:ACME",originalTagOffset) are gone.The specification lists four open differences between the two naturalizers:
InlineBinaryinputEach difference is older than this wave, and this PR does not change them.
🤖 Generated with Claude Code