Repository navigation
feat: @dcmjs-org/media — the bulk-data bundle and the DicomEventStream media factories - #588
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]>
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(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]>
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
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]>
fix: let core's sequence writer run with no eager engine loaded
feat(video): port the buffered video encapsulation layer
@dcmjs-org/parser joins the dependencies — the video event source imports fromDataSet and EVENT_STREAM_VOCABULARY — and @dcmjs-org/generator the devDependencies (StreamingPart10Writer, tests only). Deliberately NOT @dcmjs-org/legacy: this package stays off the legacy surface. Co-Authored-By: Claude Fable 5 <[email protected]>
createVideoEventSource — MP4 → contract events with the Supplement 225
dataset shell replayed first and the stream emitted as encapsulated
PixelData fragments, one in memory at a time, backpressure between
fragments via awaitDrain().
The run loop, exactFragment, withoutEndDataSet and sortDict are verbatim
from v2.0-development src/eventStream/fromVideo.js. One seam is reworked
and hand-written: v2 imported datasetToDict from what is now
@dcmjs-org/legacy, which this package must not depend on, so a local
datasetToMetaDict helper mints the same file meta group (element list and
implementation UID copied from legacy's datasetToDict) and denaturalizes
both halves via core's DicomMetaDictionary — returning the plain
{ meta, dict } shape, which is all parser's fromDataSet reads.
The suite is the v2 fromVideo suite reworked off the DicomEventStream
facade (media wave): the source drives StreamingPart10Writer directly
and reads back through fromPart10/fromPart10Stream + NaturalizedListener
+ extractEncapsulatedVideo. All load-bearing assertions carried over:
byte-identical round trips (buffered and streaming reader), the
(7FE0,0003) UV uint64 pinned on the wire, the Sup 225 fragment layout,
single-endDataSet ordering, per-fragment backpressure, and the ffmpeg
corrective error. The facade-specific toVideo/fromPdf case stays with
the media wave, as does fromImage.test.js.
Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
feat(video): port the video event source, legacy-free
…ase/1.0-beta-media
…ease/1.0-beta-media # Conflicts: # pnpm-lock.yaml
Co-Authored-By: Claude Fable 5 <[email protected]>
feat(media): the @dcmjs-org/media bundle
Port fromImage, fromPdf, fromVideo, fromVideoStream, toPdf, and toVideo from v2's src/eventStream/api.js, importing from @dcmjs-org/pdfs and @dcmjs-org/video. The video factories create their event source lazily on first consumption (cached across re-runs) instead of eagerly at factory time, so a bad input can no longer raise an unhandled promise rejection before anyone calls .process() — review finding 14. Co-Authored-By: Claude Fable 5 <[email protected]>
feat(media): the DicomEventStream media factories (review finding 14)
…ented GHSA-vfj7-8cjw-p6xm was published 2026-10-02 with a claimed fix range of >=3.0.4, but no such braces release exists on the registry, so there is nothing to override to. Every path is dev tooling; braces never reaches the published packages. Same entry the fhir staging branch already carries (#589) — remove it the moment a patched braces ships. Co-Authored-By: Claude Fable 5 <[email protected]> (cherry picked from commit 7261970)
Per review on #542: the guide existed to hold the staged-landing PR descriptions to one standard, and every description is now written. Removed rather than kept stale; git history preserves it if the team wants it back later. The PR template keeps the one-line spirit of it. Co-Authored-By: Claude Fable 5 <[email protected]> (cherry picked from commit 2a5935e)
…media # Conflicts: # packages/core/src/ValueRepresentation.js # packages/core/src/core/writeCore.js # pnpm-lock.yaml # pnpm-workspace.yaml
…media # Conflicts: # packages/dicomdir/README.md # packages/dicomdir/package.json # packages/dicomdir/test/standalone.test.js # pnpm-lock.yaml
PR #588 review (conversation with Bill): split the lightweight, codec-free image building out of video so a consumer that only needs to build image instances doesn't pull the heavy MP4/video machinery, and SOP-specific image info stays out of core. New @dcmjs-org/imaging (depends on core only): - buildImageDataset + SECONDARY_CAPTURE_SOP_CLASS_UID (moved from video/src/image) - parseJpegInfo (moved) - h264TransferSyntaxUID (extracted from video/src/image/mp4Info.js into src/h264.js) @dcmjs-org/video now depends on @dcmjs-org/imaging: - parseMp4Info stays (MP4 container parsing is video-domain) and imports h264TransferSyntaxUID from imaging - src/image/ and the public surface trimmed to parseMp4Info + the video encapsulation/streaming; descriptions/comments updated Tests moved with their code (buildImageDataset, jpegInfo); the h264TransferSyntaxUID describe block moved to packages/imaging/test/h264.test.js. RELEASE_PLAN gains an imaging row and notes the landing order (imaging with/before video). Full suite 954 passed / 11 skipped / 0 failed. Follow-ons (separate branches): media exports an imaging namespace and sources the image builders from imaging; fhir->imaging deferred until fhir builds images. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Imaging split — outcome from our chat. Rather than rename That package landed in the video PR (#585), since the code is carved out of video and video is first:
Follow-on for this PR (#588): once #585 lands, Deferred: |
* feat(video): scaffold the @dcmjs-org/video package 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]> * feat(video): port the JPEG and MP4 header parsers from v2 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]> * fix(video): throw on a truncated SOF segment in parseJpegInfo 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]> * fix(video): bound the stts entry count by its box size in parseMp4Info 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(video): port buildImageDataset from v2 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]> * fix(video): derive NumberOfFrames from the encapsulated fragment list 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]> * feat(video): port the buffered video encapsulation layer from v2 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]> * feat(video): export the encapsulated module from the package index 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]> * feat(video): declare the parser and generator dependencies @dcmjs-org/parser joins the dependencies — the video event source imports fromDataSet and EVENT_STREAM_VOCABULARY — and @dcmjs-org/generator the devDependencies (StreamingPart10Writer, tests only). Deliberately NOT @dcmjs-org/legacy: this package stays off the legacy surface. Co-Authored-By: Claude Fable 5 <[email protected]> * feat(video): port the video event source from v2 createVideoEventSource — MP4 → contract events with the Supplement 225 dataset shell replayed first and the stream emitted as encapsulated PixelData fragments, one in memory at a time, backpressure between fragments via awaitDrain(). The run loop, exactFragment, withoutEndDataSet and sortDict are verbatim from v2.0-development src/eventStream/fromVideo.js. One seam is reworked and hand-written: v2 imported datasetToDict from what is now @dcmjs-org/legacy, which this package must not depend on, so a local datasetToMetaDict helper mints the same file meta group (element list and implementation UID copied from legacy's datasetToDict) and denaturalizes both halves via core's DicomMetaDictionary — returning the plain { meta, dict } shape, which is all parser's fromDataSet reads. The suite is the v2 fromVideo suite reworked off the DicomEventStream facade (media wave): the source drives StreamingPart10Writer directly and reads back through fromPart10/fromPart10Stream + NaturalizedListener + extractEncapsulatedVideo. All load-bearing assertions carried over: byte-identical round trips (buffered and streaming reader), the (7FE0,0003) UV uint64 pinned on the wire, the Sup 225 fragment layout, single-endDataSet ordering, per-fragment backpressure, and the ffmpeg corrective error. The facade-specific toVideo/fromPdf case stays with the media wave, as does fromImage.test.js. Co-Authored-By: Claude Fable 5 <[email protected]> * feat(video): export createVideoEventSource from the package index Co-Authored-By: Claude Fable 5 <[email protected]> * ci: ignore the unpatchable braces advisory in audit, scoped and documented GHSA-vfj7-8cjw-p6xm was published 2026-10-02 with a claimed fix range of >=3.0.4, but no such braces release exists on the registry, so there is nothing to override to. Every path is dev tooling; braces never reaches the published packages. Same entry the fhir staging branch already carries (#589) — remove it the moment a patched braces ships. Co-Authored-By: Claude Fable 5 <[email protected]> (cherry picked from commit 7261970) * docs: retire the writing style guide now that authoring is done Per review on #542: the guide existed to hold the staged-landing PR descriptions to one standard, and every description is now written. Removed rather than kept stale; git history preserves it if the team wants it back later. The PR template keeps the one-line spirit of it. Co-Authored-By: Claude Fable 5 <[email protected]> (cherry picked from commit 2a5935e) * feat(imaging): extract @dcmjs-org/imaging from @dcmjs-org/video PR #588 review (conversation with Bill): split the lightweight, codec-free image building out of video so a consumer that only needs to build image instances doesn't pull the heavy MP4/video machinery, and SOP-specific image info stays out of core. New @dcmjs-org/imaging (depends on core only): - buildImageDataset + SECONDARY_CAPTURE_SOP_CLASS_UID (moved from video/src/image) - parseJpegInfo (moved) - h264TransferSyntaxUID (extracted from video/src/image/mp4Info.js into src/h264.js) @dcmjs-org/video now depends on @dcmjs-org/imaging: - parseMp4Info stays (MP4 container parsing is video-domain) and imports h264TransferSyntaxUID from imaging - src/image/ and the public surface trimmed to parseMp4Info + the video encapsulation/streaming; descriptions/comments updated Tests moved with their code (buildImageDataset, jpegInfo); the h264TransferSyntaxUID describe block moved to packages/imaging/test/h264.test.js. RELEASE_PLAN gains an imaging row and notes the landing order (imaging with/before video). Full suite 954 passed / 11 skipped / 0 failed. Follow-ons (separate branches): media exports an imaging namespace and sources the image builders from imaging; fhir->imaging deferred until fhir builds images. Co-Authored-By: Claude Fable 5 <[email protected]> * feat(imaging,video): build image and video instances with createInstance buildImageDataset and buildVideoDataset now use createInstance from @dcmjs-org/core, the same creator pattern as @dcmjs-org/encapsulated: - New base blocks: imageBase / secondaryCaptureImageBase and videoBase / videoPhotographicBase, each with predecessorBase. - The instance, dataLevel, levels, predecessor and baseDicom options pass through to createInstance. Payload attributes (geometry, stream values, transfer syntax) are set after it. - createInstance writes only DICOM attributes (keywords, tags, _meta/_vrMap) from the overrides; other keys are dropped with a warning. Each builder removes its own control keys first. - The video base no longer sets StudyID 1; a new study gets the Type 2 empty StudyID from studyBase. - buildImageDataset reuses the core EXPLICIT_LITTLE_ENDIAN and merges _vrMap. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(core): createInstance keeps keywords added with registerTag The attribute filter now accepts a keyword that lookupRegisteredTagByName finds, as denaturalizeDataset does. Before this fix, such an override was dropped with a warning. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(core,imaging,video): one instance-creation model for all builders All builders (encapsulate, buildVideoDataset, buildImageDataset) take the same options: createInstance options, attribute overrides, and their own payload control keys. packages/core/README.md documents the shared model (CORE-USR/CORE-IMP); the package READMEs refer to it. core createInstance: - never copies the identity of `instance` (SOPInstanceUID, SOPClassUID, InstanceNumber, media storage UIDs), also with a custom `levels` - InstanceNumber at series level is the largest prior number + 1 - Type 2 empty StudyDate/StudyTime/SeriesNumber for an inherited level - skips undefined overrides; rejects a DICOM JSON `instance` - nextSeriesNumberBase counts only IS integers imaging: - remove the `metadata` option and the old `derivedFrom` shapes - new derivedImageAttributes / derivedImageBase: derivation from one or more naturalized instances, as a base block; lossy history is kept - ImageType ORIGINAL\PRIMARY is a base value video: README with VID requirements; control keys removed before the call. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(core,encapsulated,imaging,video): overrides provider and postProcess All builders take one option shape: the createInstance controls (baseDicom, instance, dataLevel, levels, predecessor, postProcess), their own control keys, and `overrides`. `overrides` is a naturalized DICOM provider with the same forms as baseDicom; its attributes go only into the result. An extra option key has no effect. core createInstance: - baseDicom resolves, then overrides; merge base < inherited < overrides, with a key merge of _meta; then postProcess (default removeUndefinedAttributes, top level only), so an undefined override removes the attribute - `instance` gives the attributes that `levels` lists; at dataLevel series the new InstanceNumber is the sample (first) instance's + 1 - Modality warning uses a presence check of the override - validation is part of the usage flow (CORE-IMP-11); pure type checks removed encapsulated: export PDF_MIME_TYPE; a builder sets only _meta.TransferSyntaxUID on a copy of _meta. imaging: geometry, HighBit and PixelRepresentation are written only when the decoded image gives them; ConversionType is a base value; a float pixel array throws. video: no attribute for a missing mp4Info field; createVideoEventSource keeps the returned _meta and the caller's file meta keys; normalizeFragmentBytes is no longer exported. eslint: no-unused-vars ignoreRestSiblings. Co-Authored-By: Claude Opus 5.5 <[email protected]> * refactor(imaging,video): predecessorBase only in the encapsulated bases predecessorBase is an optional base block in core, one more way to add default attributes. The encapsulated document bases include it. imageBase and videoBase no longer include it, so `predecessor: true` has no effect with those default bases. A caller can add the block, for example combineBases(imageBase, predecessorBase). Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Fable 5 <[email protected]> Co-authored-by: Bill Wallace <[email protected]>
…media 1.0-beta now has #577 (@dcmjs-org/encapsulated) and #585 (@dcmjs-org/video and @dcmjs-org/imaging, built on createInstance). The merge takes the video package from 1.0-beta and moves the media wave onto the new packages: - remove packages/pdfs; @dcmjs-org/encapsulated replaces it - the media bundle and the DicomEventStream factories import from @dcmjs-org/encapsulated, @dcmjs-org/imaging, and @dcmjs-org/video - the bundle re-exports the base blocks and the generic encapsulate, and drops normalizeFragmentBytes, which the video package no longer exports - the factories pass the createInstance options to the builders; the DICOM attributes go in `overrides`, and the tests use that form - a new test checks that fromPdf passes instance and dataLevel through Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>
|
🎉 This PR is included in version 1.0.0-beta.3 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
This is the assembly PR for the media wave. It brings
release/1.0-beta-mediainto1.0-beta, and it carries PRs #586 and #587. The PR is a draft on purpose. Do not merge it yet. The assemblies must go in one at a time, in a deliberate order.What this PR adds. The PR adds two things:
@dcmjs-org/media, the bundle package. It is one dependency that re-exports the bulk-data packages under the namespace shapes that dcmjs v2 consumers know (media,encapsulated,image). The bundle adds no behavior.DicomEventStreamfacade:fromImage,fromPdf,fromVideo,fromVideoStream,toPdf,toVideo. With these factories, an MP4, a PDF, or decoded pixels go through the event-stream engine to Part 10 bytes, and back out again. The facade calls the workspace packages, and does not copy their code.The update after #577 and #585.
1.0-betanow has@dcmjs-org/encapsulated(#577), and@dcmjs-org/videoand@dcmjs-org/imaging(#585). Both PRs build each instance withcreateInstanceof@dcmjs-org/core. Merge commit1d1db28moves this PR to that model:packages/pdfs.@dcmjs-org/encapsulatedreplaces it.packages/videoandpnpm-lock.yamlfrom1.0-beta. This branch did not change the video package.src/eventStream/api.jsimport from@dcmjs-org/encapsulated,@dcmjs-org/imaging, and@dcmjs-org/video.optionsunchanged to their builder. The builder takes thecreateInstanceoptions:instance,dataLevel,levels,predecessor,postProcess,baseDicom, andoverrides.encapsulate,PDF_MIME_TYPE, and the base blocks for a custombaseDicom:encapsulatedBase,encapsulatedPdfBase,videoBase,imageBase,derivedImageBase.Change to a user expectation. The DICOM attributes now go in
overrides. A top-level attribute key has no effect (CORE-USR-7):The same rule applies to
fromImage,fromVideo, andfromVideoStream. The old form came from v2. The new form agrees with the builders of #577 and #585. The bundle also removesnormalizeFragmentBytes, because #585 removed it from the public exports of@dcmjs-org/video.A worked example in both directions. I ran these examples on the branch tip
1d1db28. Each commented value is the printed output of that run. An MP4 becomes a Video Photographic Image.dcmfile. The read gives back the MP4, byte for byte:The PDF pair has the same shape:
The PRs in this assembly, in the order that they merged:
@dcmjs-org/mediabundle. It has apackage.json, an index of import and export lists, a README, and a smoke test. The test asserts identity (toBe) between each re-exported name and the export of the package. The test also does one real PDF round trip through the bundle.test/eventStream/fromImage.test.jsis the v2 file. ThemediaFactoriessuite is new: the two finding-14 regression tests, and round trips through the facade for PDF and video.Finding 14, the test before and after the fix. In v2,
fromVideoandfromVideoStreamcalledcreateVideoEventSource(...)at factory time. The onlyawaitwas inside the run thunk. ThusDicomEventStream.fromVideo(bytesThatAreNotAnMp4), followed by an unrelatedawait, caused an unhandled promise rejection. Under the Node default--unhandled-rejections=throw, that rejection stops the process before the caller can call.process().I added the regression tests first, against the verbatim port. Each test listens on
process.on("unhandledRejection"), builds the stream from bad bytes, and does an unrelatedawait. Each test then asserts that no rejection leaked, and that the error rejects the sink call. Against the verbatim port, both tests failed with the leaked errorparseMp4Info: input is not an MP4 file (missing ftyp box):The fix creates the source promise inside the run thunk, at the first consumption. The fix keeps that promise, so the minted UIDs stay the same when the stream runs again. The error now comes from
.process(), or from the first sink that runs. After the fix, all the tests pass.Tests. From the repository root:
Expected result: 3 suites and 17 tests pass. The count is 5 bundle tests, 8 factory tests, and 4
fromImagetests. One factory test is new in1d1db28: it checks thatfromPdfgivesinstance,dataLevel: "series", andoverridesto the builder. The result inherits the study and the series, andInstanceNumbergoes from 3 to 4.A local run of the full suite on Node 24 gave 1047 tests: 1032 pass, 12 skip (the skips were there before), and 3 fail. The 3 failures are in
test/data.test.js(test_multiframe_1,test_oneslice_seg,test_deflated). These tests use a downloaded fixture file that is not in the local cache. This PR does not changetest/data.test.jsor the code that it tests. CI for1d1db28: tests, lint/format, audit.What the diff contains. After the merge of #575, #577, and #585 into
1.0-beta, the diff contains only the media wave:packages/media/src/eventStream/api.jspackage.json, and thepnpm-lock.yamlentries for themtest/eventStream/fromImage.test.jsandtest/eventStream/mediaFactories.test.jsBreaking changes.
@dcmjs-org/mediais a new package, and the facade methods are new. No currentsrc/surface changes behavior. Against v2, two things change:overrides, as shown above.Next. The FHIR wave (#584) adds
fromFhirandtoFhirto the same facade file. The FHIR wave comes after this PR, because it uses the packages of this PR. The FHIR wave must also move its attributes intooverrides.🤖 Generated with Claude Code