Repository navigation
refactor: split the event-stream reading side into packages/parser - #566
Merged
Merged
Conversation
Adds packages/parser/package.json and README.md, following the same scaffold precedent as @dcmjs/core and @dcmjs/legacy (private, version 0.0.0 until the publish switch flips). The package depends on @dcmjs/core via workspace:* plus pako (the streaming reader inflates deflated transfer syntaxes); the lockfile picks up the new project. Co-Authored-By: Claude Fable 5 <[email protected]>
…ader seam Preparation for moving the streaming reader into packages/parser, where it must carry no static edge to @dcmjs/legacy: - singleVRs (the canonical element-shaping list, the one with LT) moves from DicomMessage to core's constants/dicom.js; DicomMessage imports and re-exports it, so its historic surface is unchanged - DicomMessage.lookupTag's body moves to DicomMetaDictionary.lookupTag (it was a one-line read of DicomMetaDictionary.dictionary, which is core's); the DicomMessage static delegates to it - ValueRepresentation gains getDicomMessageClass(), the read side of the late-binding slot it already carries, so the streaming reader's narrow eager-delegation fallbacks can resolve the eager reader at call time instead of importing it - legacy's DicomMessage module wires the ValueRepresentation / Tag / DicomDict seams at load, not only via the dcmjs wrapper index, so direct module consumers keep exactly the reach they had when the streaming modules imported DicomMessage statically (the wrapper's identical calls stay; the setters are idempotent) Co-Authored-By: Claude Fable 5 <[email protected]>
…re git mv) The contract (EventStreamListener, the vocabulary, CONTRACT_VERSION, mergeFragmentsPerBotWindow), the collecting and naturalizing listeners, the shared emit helpers, the async-iterator adapter, the four event generators (fromPart10, fromPart10Stream, fromDicomWebJson, fromDataSet), and the element-decode core move under packages/parser/src/ with their relative structure preserved. Zero edits; git records every file as an R100 rename. The wrapper-level glue (src/eventStream/api.js and index.js) and the writers stay put for the follow-up rewiring and generator-package commits. Co-Authored-By: Claude Fable 5 <[email protected]>
Hand-written rewiring for the pure-move commit before it: - the moved modules import their building blocks from @dcmjs/core by name instead of relative paths; sibling imports inside the package stay relative and needed no edits - the two deliberate eager-reader delegations — decodeCore's decodeWithEagerReadTag (DicomMessage._readTag over rare element shapes) and fromPart10Stream's bare-dataset fallback (DicomMessage.readFile) — now resolve the eager reader at call time through core's late-binding slot (requireEagerReader over ValueRepresentation.getDicomMessageClass), with a clear error when no eager reader is loaded, so this package carries no static edge to @dcmjs/legacy - a shim at each old path under src/ re-exports from the new packages/parser location; the fromPart10, fromPart10Stream, and decodeCore shims also side-effect import ../DicomMessage.js so direct consumers of the old paths keep exactly the reach the static import gave them - packages/parser/src/index.js exports the package surface (the contract, the listeners, the sources, and the emit helpers); the eventStream barrel and the DicomEventStream facade stay in root src/ as wrapper-level glue, unchanged - core's index additionally exports lookupPrivateTag, the packed private dictionary's one by-name function, for the naturalized listener Co-Authored-By: Claude Fable 5 <[email protected]>
|
🎉 This PR is included in version 1.0.0-beta.1 🎉 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 starts the
@dcmjs/parserpackage — the reading half of the event-stream engine, following@dcmjs/core(#564) and@dcmjs/legacy(#565). The contract (EventStreamListener, the vocabulary,CONTRACT_VERSION,mergeFragmentsPerBotWindow), the collecting and naturalizing listeners, the four event generators (fromPart10,fromPart10Stream,fromDicomWebJson,fromDataSet), the shared emit helpers, the async-iterator adapter, and the element-decode core all move intopackages/parser, depending on@dcmjs/coreandpako— and NOT on@dcmjs/legacy. A second PR forpackages/generator(the writer sinks) follows right behind it.Same commit shape as the last two, with one extra commit up front:
packages/parser/package.jsonand a README (private, version 0.0.0 until the publish switch flips), plus the lockfile pickup.decodeCore's edge into the legacy reader before anything moves. Three small relocations plus a seam, all hand-written and suite-green on their own:singleVRs(the canonical element-shaping list, the one with LT) moves fromDicomMessageto core'sconstants/dicom.js;DicomMessage.lookupTag's one-line body moves toDicomMetaDictionary.lookupTag(it only ever readDicomMetaDictionary.dictionary, which is core's); andValueRepresentationgainsgetDicomMessageClass()— the read side of the late-binding slot it has carried all along for sequence reads. In each case theDicomMessagesurface keeps its name as a re-export or delegating static, so nothing visible changes.git mv, zero edits — all ten files record as R100 renames intopackages/parser/src/, relative structure preserved (eventStream/siblings keep importing each other unchanged;decodeCorekeeps itscore/spot).@dcmjs/coreby name, a two-line shim at each old path keeps every existing import in src/, test/, and the wrapper working unchanged, andpackages/parser/src/index.jsexports the package surface. One line was added to core's index for it:lookupPrivateTag, the single by-name function of the packed private dictionary (the data blobs around it stay module-path imports, per core's existing note).How the legacy edge was actually broken.
decodeCoredidn't just uselookupTag/singleVRs— its narrow fallbackdecodeWithEagerReadTagrunsDicomMessage._readTagover rare element shapes, andfromPart10Streamforce-reads bare (meta-less, DIMSE-style) datasets throughDicomMessage.readFile. Both delegations are deliberate (byte-parity with the eager reader is the point), so reimplementing them was off the table for a move PR, and moving_readTag/readFileinto core would have planted the eager engine in the one package it must never touch. Instead both call sites resolve the eager reader at call time through core's existing late-binding slot (ValueRepresentation.getDicomMessageClass()), with a clear error when nothing wired it. Legacy'sDicomMessagemodule now wires the slots itself at load (the wrapper index's identical calls stay and are idempotent), and the shims forfromPart10,fromPart10Stream, anddecodeCorecarry a one-line side-effect import of../DicomMessage.js— so every existing entry point keeps exactly the reach the static import gave it. The only behavior that differs anywhere is@dcmjs/parserloaded truly standalone: the two fallbacks throw a descriptive "import @dcmjs/legacy first" error instead of being silently available, which is the deprecability rule working as intended.What stays put, on purpose:
src/eventStream/api.jsandindex.js(theDicomEventStreamfacade and the barrel) are wrapper-level glue spanning the reading and writing sides — they stay in rootsrc/for the wrapper package, importing through the shims with zero edits. The writer sinks (Part10Writer,StreamingPart10Writer,DicomWebJsonWriter) stay for the generator-package PR next.The hand-written total is about 240 changed lines (scaffold 42, seam commit 51, rewiring ~145 across import blocks, the seam guard, the parser index, core's one-line export, and ten shims), well under the 500 budget; the pure moves are exempt and declared above. After the full commit group: the suite is 844 passed / 12 skipped / 856,
pnpm run buildproduces the same bundle surface (UMD export names checked against the previous build), and lint and format pass over the existingpackages/*/srcglobs.🤖 Generated with Claude Code