Repository navigation
refactor: split the event-stream writer sinks into packages/generator - #567
Merged
Merged
Conversation
Adds packages/generator/package.json and README.md, following the same scaffold precedent as the core, legacy, and parser packages (private, version 0.0.0 until the publish switch flips). The package depends on @dcmjs/parser (the contract and the collector), @dcmjs/core (the write primitives), and — temporarily, for Part10Writer's delegation to the canonical DicomDict.write encoder only — @dcmjs/legacy; the README spells that edge out. The lockfile picks up the new project and links. Co-Authored-By: Claude Fable 5 <[email protected]>
Preparation for moving the writer sinks into packages/generator, so the streaming writer needs no edge to @dcmjs/legacy: - DicomMessage.write, writeTagObject, and _getTagWriteValues move verbatim into core's core/writeCore.js (as writeDataSet, writeTagObject, getTagWriteValues) — everything they touch is core's: Tag.write drives the element encoding through ValueRepresentation, deepEqual backs the _rawValue fidelity check. The DicomMessage statics delegate, so every existing caller (DicomDict, the tests, external users) is unaffected - DicomMessage.isEncapsulated's body moves to isEncapsulatedSyntax in core's constants/dicom.js, next to the syntax table it reads, and DicomMessage._normalizeSyntax now delegates to core's existing normalizeSyntax instead of duplicating it; both statics remain as delegating surfaces - Tag.write resolves those two helpers directly instead of through its late-binding DicomMessage slot, which now has no readers inside Tag (the setter stays for API compatibility) - ValueRepresentation's sequence-item writer keeps calling the late-bound DicomMessage.write slot rather than importing writeCore: Tag.js wires ValueRepresentation.setTagClass at module-evaluation time, so a static ValueRepresentation -> writeCore -> Tag edge would recreate exactly the cycle the slots exist to avoid Co-Authored-By: Claude Fable 5 <[email protected]>
…(pure git mv) Pure file moves, zero edits: Part10Writer, StreamingPart10Writer, and DicomWebJsonWriter record as R100 renames into packages/generator/src/eventStream/. The rewiring commit in this PR repoints their imports at @dcmjs/parser, @dcmjs/core, and (for Part10Writer's DicomDict delegation only) @dcmjs/legacy, and adds shims at the old paths. Co-Authored-By: Claude Fable 5 <[email protected]>
Hand-written rewiring for the pure-move commit before it: - the writers import the contract from @dcmjs/parser (EventStreamListener, CollectorListener) and the write machinery from @dcmjs/core (WriteBufferStream, the syntax constants, writeDataSet, writeTagObject); StreamingPart10Writer and DicomWebJsonWriter carry no other edges - Part10Writer keeps its by-design delegation to the canonical DicomDict.write encoder, now as an explicit — and TEMPORARY — @dcmjs/legacy import, flagged in the package README and the PR - a shim at each old path under src/eventStream/ re-exports from the new packages/generator location, so every existing import in src/, test/, and the barrel keeps working unchanged - packages/generator/src/index.js exports the three sinks; the eventStream barrel and the DicomEventStream facade stay in root src/ as wrapper-level glue, unchanged Co-Authored-By: Claude Fable 5 <[email protected]>
This was referenced Oct 2, 2026
|
🎉 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/generatorpackage — the writing half of the event-stream engine, closing the four-package split that #564 (@dcmjs/core), #565 (@dcmjs/legacy), and #566 (@dcmjs/parser) built up to. The three writer sinks —Part10Writer,StreamingPart10Writer,DicomWebJsonWriter— move intopackages/generator.Same commit shape as #566:
packages/generator/package.jsonand a README (private, version 0.0.0), plus the lockfile pickup. Its dependencies are the honest news and the README spells them out:@dcmjs/parserfor the contract and the collector,@dcmjs/corefor the write primitives, and — temporarily —@dcmjs/legacy, about which more below.DicomMessage.write,writeTagObject, and_getTagWriteValuesmove verbatim into core'score/writeCore.js(aswriteDataSet/writeTagObject/getTagWriteValues— everything they touch was already core's:Tag.write,ValueRepresentation,deepEqual),isEncapsulated's one-liner moves toisEncapsulatedSyntaxnext to the syntax table it reads, and_normalizeSyntaxnow delegates to core's existingnormalizeSyntaxinstead of duplicating it. EveryDicomMessagestatic stays as a delegating surface, soDicomDict, the tests, and external callers are untouched.Tag.writealso stops reaching those two helpers through its late-bindingDicomMessageslot and imports them directly — the slot and its setter stay for API compatibility, now readerless insideTag.git mv, zero edits — all three writers record as R100 renames intopackages/generator/src/eventStream/.@dcmjs/parserand the primitives from@dcmjs/core, a two-line shim at each old path keeps every existing import working unchanged, andpackages/generator/src/index.jsexports the three sinks. TheeventStreambarrel and theDicomEventStreamfacade stay in rootsrc/as wrapper-level glue, zero edits — with this PR, every module they re-export now lives in a package.The declared temporary edge:
@dcmjs/generator→@dcmjs/legacy, forPart10Writeronly. That writer is by design a thin layer over the canonical encoder — it collects events into a{ meta, dict }tree and delegates serialization toDicomDict.write(), which owns deflate, padding, Big16, and the group-length recomputation. Cutting that edge today would mean either movingDicomDict(the legacy surface type) into core or growing a second meta-group serializer — a real redesign, not a move. So the edge stays, confined to one import in one module and flagged in the package README. The one-line removal plan: when the collect-then-serialize path is reimplemented overStreamingPart10Writer(or the canonical encoder moves out of the legacy surface type), theDicomDictdelegation and the workspace dependency go with it.StreamingPart10Writercomes out legacy-free as promised: after commit 2 its only imports are the parser contract and core (WriteBufferStream, the syntax constants,writeDataSet,writeTagObject); it self-builds every sequence/item/fragment header. One honest footnote: an element whose value is a sequence written throughwriteTagObjectstill routes throughValueRepresentation's late-boundDicomMessage.writeslot — I tried pointing that slot's one write call atwriteCoredirectly, and it recreates exactly the evaluation-order cycle the slots exist to avoid (Tag.jscallsValueRepresentation.setTagClassat module-evaluation time, and a staticValueRepresentation → writeCore → Tagedge turns that into a crash). Event sources emit sequences structurally, so that path is not reachable from the contract; it matters only to directwriteTagObjectcallers, who have legacy loaded today anyway.The hand-written total is about 185 changed lines (scaffold 53, the writeCore relocation commit 119 gross — of which ~77 are the verbatim relocated bodies — and rewiring ~35 across the three import blocks, three shims, and the package index), 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,eventStreamkeys identical), and lint and format pass over the existingpackages/*/srcglobs.🤖 Generated with Claude Code