@dcmjs-org/generator 1.0.0-beta.1 → 1.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -455,7 +455,7 @@ class DicomWebJsonWriter extends parser.EventStreamListener {
455
455
  }
456
456
 
457
457
  _baseEndBinary() {
458
- this._pending.attr.InlineBinary = encodeBase64(
458
+ this._pending.attr.InlineBinary = core.encodeBase64(
459
459
  concatFragments(this._pending.fragments)
460
460
  );
461
461
  }
@@ -508,21 +508,6 @@ function concatFragments(fragments) {
508
508
  return out;
509
509
  }
510
510
 
511
- function encodeBase64(uint8) {
512
- if (typeof Buffer !== "undefined") {
513
- return Buffer.from(
514
- uint8.buffer,
515
- uint8.byteOffset,
516
- uint8.byteLength
517
- ).toString("base64");
518
- }
519
- let binary = "";
520
- for (let i = 0; i < uint8.length; i++) {
521
- binary += String.fromCharCode(uint8[i]);
522
- }
523
- return btoa(binary);
524
- }
525
-
526
511
  exports.DicomWebJsonWriter = DicomWebJsonWriter;
527
512
  exports.Part10Writer = Part10Writer;
528
513
  exports.StreamingPart10Writer = StreamingPart10Writer;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/eventStream/Part10Writer.js","../src/eventStream/StreamingPart10Writer.js","../src/eventStream/DicomWebJsonWriter.js"],"sourcesContent":["import { CollectorListener } from \"@dcmjs-org/parser\";\nimport { writePart10 } from \"@dcmjs-org/core\";\n\n/**\n * Part10Writer — slice E2: an event-stream sink that produces DICOM Part 10\n * bytes.\n *\n * Architecture: this is a thin LAYER over the canonical encoder, not a second\n * encoder. It collects the event stream into a tag-keyed `{ meta, dict }` tree\n * (reusing CollectorListener) and delegates serialization to core's\n * `writePart10` (the proven Part 10 envelope, relocated from legacy\n * `DicomDict.write()`), which handles every VR, undefined-length sequences,\n * deflate, padding, Big16, and FileMetaInformationGroupLength recomputation.\n * This closed the one temporary `@dcmjs-org/legacy` edge this package had.\n *\n * Byte-IDENTICAL Part 10 round-tripping (incl. re-emitting compressed pixel data\n * verbatim) is intentionally NOT this path's job — that is a non-goal of the\n * naturalized/event layer (spec §4.5) and remains served by the lazy-read +\n * R4 passthrough-write path. This writer produces correct, semantically faithful\n * Part 10 output from any event source.\n */\nexport class Part10Writer extends CollectorListener {\n /**\n * Serialize the collected dataset to a Part 10 ArrayBuffer.\n * @param {Object} [writeOptions] forwarded to writePart10\n * @returns {ArrayBuffer}\n */\n write(writeOptions) {\n const meta = { ...this.result.meta };\n // writePart10 recomputes the group length; drop any collected one so\n // it is not double-counted.\n delete meta[\"00020000\"];\n\n const dataSet = { meta, dict: this.result.dict };\n return writeOptions\n ? writePart10(dataSet, writeOptions)\n : writePart10(dataSet);\n }\n}\n","import { EventStreamListener } from \"@dcmjs-org/parser\";\nimport {\n WriteBufferStream,\n EXPLICIT_BIG_ENDIAN,\n EXPLICIT_LITTLE_ENDIAN,\n IMPLICIT_LITTLE_ENDIAN,\n DEFLATED_EXPLICIT_LITTLE_ENDIAN,\n writeDataSet,\n writeTagObject\n} from \"@dcmjs-org/core\";\n\nconst FMI_GROUP_LENGTH = \"00020000\";\nconst TRANSFER_SYNTAX_UID = \"00020010\";\nconst UNDEFINED_LENGTH = 0xffffffff;\n\n/**\n * StreamingPart10Writer — plan-R2: an event-stream sink that emits DICOM\n * Part 10 bytes incrementally, as events arrive, instead of collecting the\n * whole dataset first like {@link Part10Writer}.\n *\n * Purpose: writing datasets whose Pixel Data does not fit in memory (the\n * R2 trigger — e.g. a Supplement 225 fragmentable video instance measured in\n * tens of GB). Peak memory is bounded by the largest single non-encapsulated\n * element plus the file meta group; encapsulated pixel-data fragments are\n * forwarded chunk-for-chunk and never accumulated.\n *\n * Output contract: `options.onChunk(Uint8Array)` is called zero or more times\n * per event, in file order. Absent `onChunk`, chunks accumulate on\n * `this.chunks` (testing convenience; that mode is NOT streaming). The caller\n * owns backpressure: wire the generator's `setDrain` to the sink that\n * consumes the chunks (e.g. a Node fs write stream's own drain).\n *\n * Encoding decisions (all legal Part 10, all chosen to avoid backpatching):\n * - the file meta group is buffered — it is small and its group length\n * (0002,0000) must be computed over the encoded elements, exactly as\n * DicomDict.write does;\n * - sequences and their items are written with undefined length and closed\n * with item/sequence delimitation items;\n * - encapsulated pixel data is written with undefined length, an empty\n * Basic Offset Table, one item per incoming fragment (odd fragments are\n * padded), and a sequence delimiter.\n *\n * Byte-identical round-tripping remains a non-goal (spec §4.5 / D15): output\n * is correct, semantically faithful Part 10, not a byte-for-byte copy of any\n * source.\n *\n * Not supported (throws): deflated transfer syntax, bulkDataReference events\n * (the bytes are elsewhere — materialize them first), sequences inside the\n * file meta group.\n */\nexport class StreamingPart10Writer extends EventStreamListener {\n /**\n * @param {Object} [options]\n * @param {(chunk: Uint8Array) => void} [options.onChunk] - Byte sink;\n * defaults to accumulating on `this.chunks`.\n * @param {Object} [options.writeOptions] - Forwarded to the element\n * encoders (e.g. { allowInvalidVRLength }).\n * @param {...Object} filters - Event-stream filters, as for any listener.\n */\n constructor(options = {}, ...filters) {\n super(...filters);\n this.chunks = [];\n this._onChunk = options.onChunk ?? (chunk => this.chunks.push(chunk));\n this._writeOptions = options.writeOptions ?? {\n allowInvalidVRLength: false\n };\n this.bytesWritten = 0;\n this._inMeta = false;\n this._meta = {};\n this._bodySyntax = EXPLICIT_LITTLE_ENDIAN;\n this._current = null;\n this._encapsulated = false;\n this.done = false;\n }\n\n /**\n * Endianness for every header the writer builds itself (sequence, item,\n * delimiter and encapsulated pixel-data headers). Review finding 5: these\n * were hardcoded little-endian while plain elements followed the body\n * syntax, so an Explicit VR Big Endian file disagreed with itself. File\n * Meta streams do NOT use this — the meta group is always explicit\n * little endian (PS3.10 §7.1).\n * @private\n */\n get _bodyLittleEndian() {\n return this._bodySyntax !== EXPLICIT_BIG_ENDIAN;\n }\n\n /** @param {ArrayBuffer|Uint8Array} bytes @private */\n _emit(bytes) {\n const chunk =\n bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);\n this.bytesWritten += chunk.byteLength;\n this._onChunk(chunk);\n }\n\n /** @private */\n _emitStream(stream) {\n this._emit(stream.getBuffer(0, stream.size));\n }\n\n /**\n * Writes a bare tag + 32-bit length, the form shared by item and\n * delimitation items (never a VR).\n * @private\n */\n _writeRawTag(stream, group, element, length) {\n stream.writeUint16(group);\n stream.writeUint16(element);\n stream.writeUint32(length);\n }\n\n /**\n * Writes an element header in the long (reserved + 32-bit length) form —\n * the only form needed for the headers this writer emits itself (SQ and\n * encapsulated OB/OW/UN); everything else goes through\n * core's writeTagObject.\n * @private\n */\n _writeLongHeader(stream, tag, vr, length) {\n stream.writeUint16(parseInt(tag.substring(0, 4), 16));\n stream.writeUint16(parseInt(tag.substring(4, 8), 16));\n if (this._bodySyntax !== IMPLICIT_LITTLE_ENDIAN) {\n stream.writeAsciiString(vr);\n stream.writeUint16(0);\n }\n stream.writeUint32(length);\n }\n\n _baseStartDataSet() {}\n\n _baseEndDataSet() {\n this.done = true;\n }\n\n _baseStartFileMetaInformation() {\n this._inMeta = true;\n const stream = new WriteBufferStream(160, true);\n stream.writeUint8Repeat(0, 128);\n stream.writeAsciiString(\"DICM\");\n this._emitStream(stream);\n }\n\n _baseEndFileMetaInformation() {\n this._inMeta = false;\n if (!this._meta[TRANSFER_SYNTAX_UID]) {\n this._meta[TRANSFER_SYNTAX_UID] = {\n vr: \"UI\",\n Value: [EXPLICIT_LITTLE_ENDIAN]\n };\n }\n this._bodySyntax = this._meta[TRANSFER_SYNTAX_UID].Value[0];\n if (this._bodySyntax === DEFLATED_EXPLICIT_LITTLE_ENDIAN) {\n throw new Error(\n \"StreamingPart10Writer does not support the deflated \" +\n \"transfer syntax; inflate the source or use Part10Writer\"\n );\n }\n // Group length must cover the encoded meta elements, so the group is\n // the one part of the file that cannot stream element-by-element.\n delete this._meta[FMI_GROUP_LENGTH];\n const metaStream = new WriteBufferStream(1024, true);\n writeDataSet(\n this._meta,\n metaStream,\n EXPLICIT_LITTLE_ENDIAN,\n this._writeOptions\n );\n const out = new WriteBufferStream(1024 + 16, true);\n writeTagObject(\n out,\n FMI_GROUP_LENGTH,\n \"UL\",\n metaStream.size,\n EXPLICIT_LITTLE_ENDIAN,\n this._writeOptions\n );\n out.concat(metaStream);\n this._emitStream(out);\n this._meta = {};\n }\n\n _baseStartElement(tag, info = {}) {\n this._current = { tag, vr: info.vr, values: [], emitted: false };\n }\n\n _baseValue(v) {\n this._current.values.push(v);\n }\n\n _baseEndElement() {\n const el = this._current;\n this._current = null;\n if (el.emitted) {\n return; // encapsulated path already streamed it\n }\n if (this._inMeta) {\n if (el.tag !== FMI_GROUP_LENGTH) {\n this._meta[el.tag] = { vr: el.vr, Value: el.values };\n }\n return;\n }\n const stream = new WriteBufferStream(256, this._bodyLittleEndian);\n writeTagObject(\n stream,\n el.tag,\n el.vr,\n el.values,\n this._bodySyntax,\n this._writeOptions\n );\n this._emitStream(stream);\n }\n\n _baseStartBinary(opts = {}) {\n if (opts.encapsulated && this._inMeta) {\n throw new Error(\n \"encapsulated binary is not legal in the file meta group\"\n );\n }\n if (!opts.encapsulated) {\n // Defined-length binary: fragments accumulate on the element and\n // endElement serializes it whole (bounded by that one element).\n this._encapsulated = false;\n return;\n }\n this._encapsulated = true;\n this._current.emitted = true;\n const stream = new WriteBufferStream(24, this._bodyLittleEndian);\n this._writeLongHeader(\n stream,\n this._current.tag,\n this._current.vr || \"OB\",\n UNDEFINED_LENGTH\n );\n // Empty Basic Offset Table: generators emit data fragments only (the\n // source table, if any, indexes source offsets that no longer hold).\n this._writeRawTag(stream, 0xfffe, 0xe000, 0);\n this._emitStream(stream);\n }\n\n _baseBinaryFragment(chunk) {\n const bytes =\n chunk instanceof Uint8Array\n ? chunk\n : chunk instanceof ArrayBuffer\n ? new Uint8Array(chunk)\n : new Uint8Array(\n chunk.buffer,\n chunk.byteOffset,\n chunk.byteLength\n );\n if (!this._encapsulated) {\n // Review finding 11: bytes.buffer is the WHOLE backing store, so\n // a subarray view would write (and retain) every byte of it.\n // Slice out the view's own window when they differ.\n this._current.values.push(\n bytes.byteOffset === 0 &&\n bytes.byteLength === bytes.buffer.byteLength\n ? bytes.buffer\n : bytes.buffer.slice(\n bytes.byteOffset,\n bytes.byteOffset + bytes.byteLength\n )\n );\n return;\n }\n const pad = bytes.byteLength % 2;\n const header = new WriteBufferStream(8, this._bodyLittleEndian);\n this._writeRawTag(header, 0xfffe, 0xe000, bytes.byteLength + pad);\n this._emitStream(header);\n this._emit(bytes);\n if (pad) {\n this._emit(new Uint8Array(1));\n }\n }\n\n _baseEndBinary() {\n if (this._encapsulated) {\n const stream = new WriteBufferStream(8, this._bodyLittleEndian);\n this._writeRawTag(stream, 0xfffe, 0xe0dd, 0);\n this._emitStream(stream);\n this._encapsulated = false;\n }\n }\n\n _baseStartSequence(tag, info = {}) {\n if (this._inMeta) {\n throw new Error(\"sequences are not legal in the file meta group\");\n }\n // Undefined length streams without backpatching; items and the\n // delimiters below close it out (PS3.5 §7.5).\n const stream = new WriteBufferStream(16, this._bodyLittleEndian);\n this._writeLongHeader(stream, tag, info.vr || \"SQ\", UNDEFINED_LENGTH);\n this._emitStream(stream);\n }\n\n _baseStartItem() {\n const stream = new WriteBufferStream(8, this._bodyLittleEndian);\n this._writeRawTag(stream, 0xfffe, 0xe000, UNDEFINED_LENGTH);\n this._emitStream(stream);\n }\n\n _baseEndItem() {\n const stream = new WriteBufferStream(8, this._bodyLittleEndian);\n this._writeRawTag(stream, 0xfffe, 0xe00d, 0);\n this._emitStream(stream);\n }\n\n _baseEndSequence() {\n const stream = new WriteBufferStream(8, this._bodyLittleEndian);\n this._writeRawTag(stream, 0xfffe, 0xe0dd, 0);\n this._emitStream(stream);\n }\n\n _baseBulkDataReference(ref = {}) {\n throw new Error(\n \"StreamingPart10Writer cannot serialize a bulkDataReference \" +\n `(${ref.uri ?? \"no uri\"}); materialize bulk data before writing`\n );\n }\n\n /**\n * Testing convenience for the accumulate mode: the collected chunks as\n * one ArrayBuffer. Meaningless when onChunk was provided.\n * @returns {ArrayBuffer}\n */\n toArrayBuffer() {\n const total = this.chunks.reduce((n, c) => n + c.byteLength, 0);\n const out = new Uint8Array(total);\n let offset = 0;\n for (const chunk of this.chunks) {\n out.set(chunk, offset);\n offset += chunk.byteLength;\n }\n return out.buffer;\n }\n}\n","import { EventStreamListener } from \"@dcmjs-org/parser\";\n\n/**\n * DicomWebJsonWriter — slice E1: an event-stream consumer that writes the\n * DICOM JSON model (DICOMweb metadata representation).\n *\n * The faithful inverse of `fromDicomWebJson`: it makes the contract a SINK as\n * well as a source, so the architecture round-trips\n * (DICOMweb JSON -> events -> DICOMweb JSON is identity) and any source can be\n * serialized to DICOMweb JSON (Part 10 -> events -> JSON).\n *\n * Output shape per tag: `{ vr, Value: [...] }`, or `{ vr, BulkDataURI }`, or\n * `{ vr, InlineBinary: base64 }`. Person Names pass through as the DICOMweb\n * `{ Alphabetic }` objects the contract carries. Binary source form is preserved\n * (§25): a `bulkDataReference` stays a `BulkDataURI`; assembled binary fragments\n * become base64 `InlineBinary`. Meta (group 0002) elements, when present, are\n * written flat alongside the dataset.\n */\nexport class DicomWebJsonWriter extends EventStreamListener {\n constructor(...filters) {\n super(...filters);\n this.result = {};\n // Stack of containers (the root object or a sequence item object) plus\n // the element/sequence currently being built.\n this._containers = [this.result];\n this._pending = null; // { tag, attr, fragments? }\n }\n\n _container() {\n return this._containers[this._containers.length - 1];\n }\n\n _baseStartDataSet() {\n this.result = {};\n this._containers = [this.result];\n this._pending = null;\n }\n\n _baseStartElement(tag, info = {}) {\n this._pending = { tag, attr: { vr: info.vr }, values: [] };\n }\n\n _baseValue(v, info) {\n this._pending.values.push(this._jsonModelValue(v, info));\n }\n\n /**\n * PS3.18 F.2.3.1: DS/IS may be encoded as JSON numbers OR strings.\n * Emit a number when the conversion is lossless (dcm4chee parity, #53);\n * fall back to the raw source string when Number() would silently lose\n * integer precision — e.g. DS/IS integers beyond 2^53 (#398). The raw\n * string is the standard's escape hatch; `_rawValue` itself never\n * appears in the JSON model (#404).\n */\n _jsonModelValue(v, info) {\n const vr = this._pending.attr.vr;\n if (\n (vr === \"DS\" || vr === \"IS\") &&\n info &&\n typeof info.rawValue === \"string\"\n ) {\n const raw = info.rawValue.trim();\n const parsed = Number(raw);\n if (\n /^[+-]?\\d+$/.test(raw) &&\n !Number.isSafeInteger(parsed) &&\n String(parsed) !== raw\n ) {\n return raw;\n }\n }\n return v;\n }\n\n _baseBulkDataReference(ref = {}) {\n this._pending.attr.BulkDataURI = ref.uri;\n this._pending.values = null; // bulk reference carries no Value\n }\n\n _baseStartBinary() {\n this._pending.fragments = [];\n this._pending.values = null;\n }\n\n _baseBinaryFragment(chunk) {\n this._pending.fragments.push(chunk);\n }\n\n _baseEndBinary() {\n this._pending.attr.InlineBinary = encodeBase64(\n concatFragments(this._pending.fragments)\n );\n }\n\n _baseEndElement() {\n const { tag, attr, values } = this._pending;\n if (values && values.length) {\n attr.Value = values;\n }\n this._container()[tag] = attr;\n this._pending = null;\n }\n\n _baseStartSequence(tag, info = {}) {\n const attr = { vr: info.vr, Value: [] };\n this._container()[tag] = attr;\n this._pending = null;\n // Items are pushed into attr.Value via a sequence marker on the stack.\n this._containers.push({ __seqValue: attr.Value });\n }\n\n _baseStartItem() {\n const item = {};\n this._container().__seqValue.push(item);\n this._containers.push(item);\n }\n\n _baseEndItem() {\n this._containers.pop();\n }\n\n _baseEndSequence() {\n this._containers.pop();\n }\n}\n\nfunction concatFragments(fragments) {\n const parts = fragments.map(f =>\n f instanceof ArrayBuffer\n ? new Uint8Array(f)\n : new Uint8Array(f.buffer, f.byteOffset, f.byteLength)\n );\n const total = parts.reduce((n, p) => n + p.length, 0);\n const out = new Uint8Array(total);\n let off = 0;\n for (const p of parts) {\n out.set(p, off);\n off += p.length;\n }\n return out;\n}\n\nfunction encodeBase64(uint8) {\n if (typeof Buffer !== \"undefined\") {\n return Buffer.from(\n uint8.buffer,\n uint8.byteOffset,\n uint8.byteLength\n ).toString(\"base64\");\n }\n let binary = \"\";\n for (let i = 0; i < uint8.length; i++) {\n binary += String.fromCharCode(uint8[i]);\n }\n return btoa(binary);\n}\n"],"names":["CollectorListener","writePart10","EventStreamListener","EXPLICIT_LITTLE_ENDIAN","EXPLICIT_BIG_ENDIAN","IMPLICIT_LITTLE_ENDIAN","WriteBufferStream","DEFLATED_EXPLICIT_LITTLE_ENDIAN","writeDataSet","writeTagObject"],"mappings":";;;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,YAAY,SAASA,wBAAiB,CAAC;AACpD;AACA;AACA;AACA;AACA;AACA,IAAI,KAAK,CAAC,YAAY,EAAE;AACxB,QAAQ,MAAM,IAAI,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;AAC5C;AACA;AACA,QAAQ,OAAO,IAAI,CAAC,UAAU,CAAC;;AAE/B,QAAQ,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;AACxD,QAAQ,OAAO;AACf,cAAcC,gBAAW,CAAC,OAAO,EAAE,YAAY;AAC/C,cAAcA,gBAAW,CAAC,OAAO,CAAC;AAClC,IAAI;AACJ;;AC3BA,MAAM,gBAAgB,GAAG,UAAU;AACnC,MAAM,mBAAmB,GAAG,UAAU;AACtC,MAAM,gBAAgB,GAAG,UAAU;;AAEnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,qBAAqB,SAASC,0BAAmB,CAAC;AAC/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,WAAW,CAAC,OAAO,GAAG,EAAE,EAAE,GAAG,OAAO,EAAE;AAC1C,QAAQ,KAAK,C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AAC,MAAM;AACvB,IAAI;AACJ,IAAI,OAAO,GAAG;AACd;;AAEA,SAAS,YAAY,CAAC,KAAK,EAAE;AAC7B,IAAI,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AACvC,QAAQ,OAAO,MAAM,CAAC,IAAI;AAC1B,YAAY,KAAK,CAAC,MAAM;AACxB,YAAY,KAAK,CAAC,UAAU;AAC5B,YAAY,KAAK,CAAC;AAClB,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC;AAC5B,IAAI;AACJ,IAAI,IAAI,MAAM,GAAG,EAAE;AACnB,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC3C,QAAQ,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC/C,IAAI;AACJ,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC;AACvB;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/eventStream/Part10Writer.js","../src/eventStream/StreamingPart10Writer.js","../src/eventStream/DicomWebJsonWriter.js"],"sourcesContent":["import { CollectorListener } from \"@dcmjs-org/parser\";\nimport { writePart10 } from \"@dcmjs-org/core\";\n\n/**\n * Part10Writer — slice E2: an event-stream sink that produces DICOM Part 10\n * bytes.\n *\n * Architecture: this is a thin LAYER over the canonical encoder, not a second\n * encoder. It collects the event stream into a tag-keyed `{ meta, dict }` tree\n * (reusing CollectorListener) and delegates serialization to core's\n * `writePart10` (the proven Part 10 envelope, relocated from legacy\n * `DicomDict.write()`), which handles every VR, undefined-length sequences,\n * deflate, padding, Big16, and FileMetaInformationGroupLength recomputation.\n * This closed the one temporary `@dcmjs-org/legacy` edge this package had.\n *\n * Byte-IDENTICAL Part 10 round-tripping (incl. re-emitting compressed pixel data\n * verbatim) is intentionally NOT this path's job — that is a non-goal of the\n * naturalized/event layer (spec §4.5) and remains served by the lazy-read +\n * R4 passthrough-write path. This writer produces correct, semantically faithful\n * Part 10 output from any event source.\n */\nexport class Part10Writer extends CollectorListener {\n /**\n * Serialize the collected dataset to a Part 10 ArrayBuffer.\n * @param {Object} [writeOptions] forwarded to writePart10\n * @returns {ArrayBuffer}\n */\n write(writeOptions) {\n const meta = { ...this.result.meta };\n // writePart10 recomputes the group length; drop any collected one so\n // it is not double-counted.\n delete meta[\"00020000\"];\n\n const dataSet = { meta, dict: this.result.dict };\n return writeOptions\n ? writePart10(dataSet, writeOptions)\n : writePart10(dataSet);\n }\n}\n","import { EventStreamListener } from \"@dcmjs-org/parser\";\nimport {\n WriteBufferStream,\n EXPLICIT_BIG_ENDIAN,\n EXPLICIT_LITTLE_ENDIAN,\n IMPLICIT_LITTLE_ENDIAN,\n DEFLATED_EXPLICIT_LITTLE_ENDIAN,\n writeDataSet,\n writeTagObject\n} from \"@dcmjs-org/core\";\n\nconst FMI_GROUP_LENGTH = \"00020000\";\nconst TRANSFER_SYNTAX_UID = \"00020010\";\nconst UNDEFINED_LENGTH = 0xffffffff;\n\n/**\n * StreamingPart10Writer — plan-R2: an event-stream sink that emits DICOM\n * Part 10 bytes incrementally, as events arrive, instead of collecting the\n * whole dataset first like {@link Part10Writer}.\n *\n * Purpose: writing datasets whose Pixel Data does not fit in memory (the\n * R2 trigger — e.g. a Supplement 225 fragmentable video instance measured in\n * tens of GB). Peak memory is bounded by the largest single non-encapsulated\n * element plus the file meta group; encapsulated pixel-data fragments are\n * forwarded chunk-for-chunk and never accumulated.\n *\n * Output contract: `options.onChunk(Uint8Array)` is called zero or more times\n * per event, in file order. Absent `onChunk`, chunks accumulate on\n * `this.chunks` (testing convenience; that mode is NOT streaming). The caller\n * owns backpressure: wire the generator's `setDrain` to the sink that\n * consumes the chunks (e.g. a Node fs write stream's own drain).\n *\n * Encoding decisions (all legal Part 10, all chosen to avoid backpatching):\n * - the file meta group is buffered — it is small and its group length\n * (0002,0000) must be computed over the encoded elements, exactly as\n * DicomDict.write does;\n * - sequences and their items are written with undefined length and closed\n * with item/sequence delimitation items;\n * - encapsulated pixel data is written with undefined length, an empty\n * Basic Offset Table, one item per incoming fragment (odd fragments are\n * padded), and a sequence delimiter.\n *\n * Byte-identical round-tripping remains a non-goal (spec §4.5 / D15): output\n * is correct, semantically faithful Part 10, not a byte-for-byte copy of any\n * source.\n *\n * Not supported (throws): deflated transfer syntax, bulkDataReference events\n * (the bytes are elsewhere — materialize them first), sequences inside the\n * file meta group.\n */\nexport class StreamingPart10Writer extends EventStreamListener {\n /**\n * @param {Object} [options]\n * @param {(chunk: Uint8Array) => void} [options.onChunk] - Byte sink;\n * defaults to accumulating on `this.chunks`.\n * @param {Object} [options.writeOptions] - Forwarded to the element\n * encoders (e.g. { allowInvalidVRLength }).\n * @param {...Object} filters - Event-stream filters, as for any listener.\n */\n constructor(options = {}, ...filters) {\n super(...filters);\n this.chunks = [];\n this._onChunk = options.onChunk ?? (chunk => this.chunks.push(chunk));\n this._writeOptions = options.writeOptions ?? {\n allowInvalidVRLength: false\n };\n this.bytesWritten = 0;\n this._inMeta = false;\n this._meta = {};\n this._bodySyntax = EXPLICIT_LITTLE_ENDIAN;\n this._current = null;\n this._encapsulated = false;\n this.done = false;\n }\n\n /**\n * Endianness for every header the writer builds itself (sequence, item,\n * delimiter and encapsulated pixel-data headers). Review finding 5: these\n * were hardcoded little-endian while plain elements followed the body\n * syntax, so an Explicit VR Big Endian file disagreed with itself. File\n * Meta streams do NOT use this — the meta group is always explicit\n * little endian (PS3.10 §7.1).\n * @private\n */\n get _bodyLittleEndian() {\n return this._bodySyntax !== EXPLICIT_BIG_ENDIAN;\n }\n\n /** @param {ArrayBuffer|Uint8Array} bytes @private */\n _emit(bytes) {\n const chunk =\n bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);\n this.bytesWritten += chunk.byteLength;\n this._onChunk(chunk);\n }\n\n /** @private */\n _emitStream(stream) {\n this._emit(stream.getBuffer(0, stream.size));\n }\n\n /**\n * Writes a bare tag + 32-bit length, the form shared by item and\n * delimitation items (never a VR).\n * @private\n */\n _writeRawTag(stream, group, element, length) {\n stream.writeUint16(group);\n stream.writeUint16(element);\n stream.writeUint32(length);\n }\n\n /**\n * Writes an element header in the long (reserved + 32-bit length) form —\n * the only form needed for the headers this writer emits itself (SQ and\n * encapsulated OB/OW/UN); everything else goes through\n * core's writeTagObject.\n * @private\n */\n _writeLongHeader(stream, tag, vr, length) {\n stream.writeUint16(parseInt(tag.substring(0, 4), 16));\n stream.writeUint16(parseInt(tag.substring(4, 8), 16));\n if (this._bodySyntax !== IMPLICIT_LITTLE_ENDIAN) {\n stream.writeAsciiString(vr);\n stream.writeUint16(0);\n }\n stream.writeUint32(length);\n }\n\n _baseStartDataSet() {}\n\n _baseEndDataSet() {\n this.done = true;\n }\n\n _baseStartFileMetaInformation() {\n this._inMeta = true;\n const stream = new WriteBufferStream(160, true);\n stream.writeUint8Repeat(0, 128);\n stream.writeAsciiString(\"DICM\");\n this._emitStream(stream);\n }\n\n _baseEndFileMetaInformation() {\n this._inMeta = false;\n if (!this._meta[TRANSFER_SYNTAX_UID]) {\n this._meta[TRANSFER_SYNTAX_UID] = {\n vr: \"UI\",\n Value: [EXPLICIT_LITTLE_ENDIAN]\n };\n }\n this._bodySyntax = this._meta[TRANSFER_SYNTAX_UID].Value[0];\n if (this._bodySyntax === DEFLATED_EXPLICIT_LITTLE_ENDIAN) {\n throw new Error(\n \"StreamingPart10Writer does not support the deflated \" +\n \"transfer syntax; inflate the source or use Part10Writer\"\n );\n }\n // Group length must cover the encoded meta elements, so the group is\n // the one part of the file that cannot stream element-by-element.\n delete this._meta[FMI_GROUP_LENGTH];\n const metaStream = new WriteBufferStream(1024, true);\n writeDataSet(\n this._meta,\n metaStream,\n EXPLICIT_LITTLE_ENDIAN,\n this._writeOptions\n );\n const out = new WriteBufferStream(1024 + 16, true);\n writeTagObject(\n out,\n FMI_GROUP_LENGTH,\n \"UL\",\n metaStream.size,\n EXPLICIT_LITTLE_ENDIAN,\n this._writeOptions\n );\n out.concat(metaStream);\n this._emitStream(out);\n this._meta = {};\n }\n\n _baseStartElement(tag, info = {}) {\n this._current = { tag, vr: info.vr, values: [], emitted: false };\n }\n\n _baseValue(v) {\n this._current.values.push(v);\n }\n\n _baseEndElement() {\n const el = this._current;\n this._current = null;\n if (el.emitted) {\n return; // encapsulated path already streamed it\n }\n if (this._inMeta) {\n if (el.tag !== FMI_GROUP_LENGTH) {\n this._meta[el.tag] = { vr: el.vr, Value: el.values };\n }\n return;\n }\n const stream = new WriteBufferStream(256, this._bodyLittleEndian);\n writeTagObject(\n stream,\n el.tag,\n el.vr,\n el.values,\n this._bodySyntax,\n this._writeOptions\n );\n this._emitStream(stream);\n }\n\n _baseStartBinary(opts = {}) {\n if (opts.encapsulated && this._inMeta) {\n throw new Error(\n \"encapsulated binary is not legal in the file meta group\"\n );\n }\n if (!opts.encapsulated) {\n // Defined-length binary: fragments accumulate on the element and\n // endElement serializes it whole (bounded by that one element).\n this._encapsulated = false;\n return;\n }\n this._encapsulated = true;\n this._current.emitted = true;\n const stream = new WriteBufferStream(24, this._bodyLittleEndian);\n this._writeLongHeader(\n stream,\n this._current.tag,\n this._current.vr || \"OB\",\n UNDEFINED_LENGTH\n );\n // Empty Basic Offset Table: generators emit data fragments only (the\n // source table, if any, indexes source offsets that no longer hold).\n this._writeRawTag(stream, 0xfffe, 0xe000, 0);\n this._emitStream(stream);\n }\n\n _baseBinaryFragment(chunk) {\n const bytes =\n chunk instanceof Uint8Array\n ? chunk\n : chunk instanceof ArrayBuffer\n ? new Uint8Array(chunk)\n : new Uint8Array(\n chunk.buffer,\n chunk.byteOffset,\n chunk.byteLength\n );\n if (!this._encapsulated) {\n // Review finding 11: bytes.buffer is the WHOLE backing store, so\n // a subarray view would write (and retain) every byte of it.\n // Slice out the view's own window when they differ.\n this._current.values.push(\n bytes.byteOffset === 0 &&\n bytes.byteLength === bytes.buffer.byteLength\n ? bytes.buffer\n : bytes.buffer.slice(\n bytes.byteOffset,\n bytes.byteOffset + bytes.byteLength\n )\n );\n return;\n }\n const pad = bytes.byteLength % 2;\n const header = new WriteBufferStream(8, this._bodyLittleEndian);\n this._writeRawTag(header, 0xfffe, 0xe000, bytes.byteLength + pad);\n this._emitStream(header);\n this._emit(bytes);\n if (pad) {\n this._emit(new Uint8Array(1));\n }\n }\n\n _baseEndBinary() {\n if (this._encapsulated) {\n const stream = new WriteBufferStream(8, this._bodyLittleEndian);\n this._writeRawTag(stream, 0xfffe, 0xe0dd, 0);\n this._emitStream(stream);\n this._encapsulated = false;\n }\n }\n\n _baseStartSequence(tag, info = {}) {\n if (this._inMeta) {\n throw new Error(\"sequences are not legal in the file meta group\");\n }\n // Undefined length streams without backpatching; items and the\n // delimiters below close it out (PS3.5 §7.5).\n const stream = new WriteBufferStream(16, this._bodyLittleEndian);\n this._writeLongHeader(stream, tag, info.vr || \"SQ\", UNDEFINED_LENGTH);\n this._emitStream(stream);\n }\n\n _baseStartItem() {\n const stream = new WriteBufferStream(8, this._bodyLittleEndian);\n this._writeRawTag(stream, 0xfffe, 0xe000, UNDEFINED_LENGTH);\n this._emitStream(stream);\n }\n\n _baseEndItem() {\n const stream = new WriteBufferStream(8, this._bodyLittleEndian);\n this._writeRawTag(stream, 0xfffe, 0xe00d, 0);\n this._emitStream(stream);\n }\n\n _baseEndSequence() {\n const stream = new WriteBufferStream(8, this._bodyLittleEndian);\n this._writeRawTag(stream, 0xfffe, 0xe0dd, 0);\n this._emitStream(stream);\n }\n\n _baseBulkDataReference(ref = {}) {\n throw new Error(\n \"StreamingPart10Writer cannot serialize a bulkDataReference \" +\n `(${ref.uri ?? \"no uri\"}); materialize bulk data before writing`\n );\n }\n\n /**\n * Testing convenience for the accumulate mode: the collected chunks as\n * one ArrayBuffer. Meaningless when onChunk was provided.\n * @returns {ArrayBuffer}\n */\n toArrayBuffer() {\n const total = this.chunks.reduce((n, c) => n + c.byteLength, 0);\n const out = new Uint8Array(total);\n let offset = 0;\n for (const chunk of this.chunks) {\n out.set(chunk, offset);\n offset += chunk.byteLength;\n }\n return out.buffer;\n }\n}\n","import { encodeBase64 } from \"@dcmjs-org/core\";\nimport { EventStreamListener } from \"@dcmjs-org/parser\";\n\n/**\n * DicomWebJsonWriter — slice E1: an event-stream consumer that writes the\n * DICOM JSON model (DICOMweb metadata representation).\n *\n * The faithful inverse of `fromDicomWebJson`: it makes the contract a SINK as\n * well as a source, so the architecture round-trips\n * (DICOMweb JSON -> events -> DICOMweb JSON is identity) and any source can be\n * serialized to DICOMweb JSON (Part 10 -> events -> JSON).\n *\n * Output shape per tag: `{ vr, Value: [...] }`, or `{ vr, BulkDataURI }`, or\n * `{ vr, InlineBinary: base64 }`. Person Names pass through as the DICOMweb\n * `{ Alphabetic }` objects the contract carries. Binary source form is preserved\n * (§25): a `bulkDataReference` stays a `BulkDataURI`; assembled binary fragments\n * become base64 `InlineBinary`. Meta (group 0002) elements, when present, are\n * written flat alongside the dataset.\n */\nexport class DicomWebJsonWriter extends EventStreamListener {\n constructor(...filters) {\n super(...filters);\n this.result = {};\n // Stack of containers (the root object or a sequence item object) plus\n // the element/sequence currently being built.\n this._containers = [this.result];\n this._pending = null; // { tag, attr, fragments? }\n }\n\n _container() {\n return this._containers[this._containers.length - 1];\n }\n\n _baseStartDataSet() {\n this.result = {};\n this._containers = [this.result];\n this._pending = null;\n }\n\n _baseStartElement(tag, info = {}) {\n this._pending = { tag, attr: { vr: info.vr }, values: [] };\n }\n\n _baseValue(v, info) {\n this._pending.values.push(this._jsonModelValue(v, info));\n }\n\n /**\n * PS3.18 F.2.3.1: DS/IS may be encoded as JSON numbers OR strings.\n * Emit a number when the conversion is lossless (dcm4chee parity, #53);\n * fall back to the raw source string when Number() would silently lose\n * integer precision — e.g. DS/IS integers beyond 2^53 (#398). The raw\n * string is the standard's escape hatch; `_rawValue` itself never\n * appears in the JSON model (#404).\n */\n _jsonModelValue(v, info) {\n const vr = this._pending.attr.vr;\n if (\n (vr === \"DS\" || vr === \"IS\") &&\n info &&\n typeof info.rawValue === \"string\"\n ) {\n const raw = info.rawValue.trim();\n const parsed = Number(raw);\n if (\n /^[+-]?\\d+$/.test(raw) &&\n !Number.isSafeInteger(parsed) &&\n String(parsed) !== raw\n ) {\n return raw;\n }\n }\n return v;\n }\n\n _baseBulkDataReference(ref = {}) {\n this._pending.attr.BulkDataURI = ref.uri;\n this._pending.values = null; // bulk reference carries no Value\n }\n\n _baseStartBinary() {\n this._pending.fragments = [];\n this._pending.values = null;\n }\n\n _baseBinaryFragment(chunk) {\n this._pending.fragments.push(chunk);\n }\n\n _baseEndBinary() {\n this._pending.attr.InlineBinary = encodeBase64(\n concatFragments(this._pending.fragments)\n );\n }\n\n _baseEndElement() {\n const { tag, attr, values } = this._pending;\n if (values && values.length) {\n attr.Value = values;\n }\n this._container()[tag] = attr;\n this._pending = null;\n }\n\n _baseStartSequence(tag, info = {}) {\n const attr = { vr: info.vr, Value: [] };\n this._container()[tag] = attr;\n this._pending = null;\n // Items are pushed into attr.Value via a sequence marker on the stack.\n this._containers.push({ __seqValue: attr.Value });\n }\n\n _baseStartItem() {\n const item = {};\n this._container().__seqValue.push(item);\n this._containers.push(item);\n }\n\n _baseEndItem() {\n this._containers.pop();\n }\n\n _baseEndSequence() {\n this._containers.pop();\n }\n}\n\nfunction concatFragments(fragments) {\n const parts = fragments.map(f =>\n f instanceof ArrayBuffer\n ? new Uint8Array(f)\n : new Uint8Array(f.buffer, f.byteOffset, f.byteLength)\n );\n const total = parts.reduce((n, p) => n + p.length, 0);\n const out = new Uint8Array(total);\n let off = 0;\n for (const p of parts) {\n out.set(p, off);\n off += p.length;\n }\n return out;\n}\n"],"names":["CollectorListener","writePart10","EventStreamListener","EXPLICIT_LITTLE_ENDIAN","EXPLICIT_BIG_ENDIAN","IMPLICIT_LITTLE_ENDIAN","WriteBufferStream","DEFLATED_EXPLICIT_LITTLE_ENDIAN","writeDataSet","writeTagObject","encodeBase64"],"mappings":";;;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;AAC/C,QAAQ,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC;AACnC,IAAI;;AAEJ,IAAI,YAAY,GAAG;AACnB,QAAQ,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE;AAC9B,IAAI;;AAEJ,IAAI,gBAAgB,GAAG;AACvB,QAAQ,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE;AAC9B,IAAI;AACJ;;AAEA,SAAS,eAAe,CAAC,SAAS,EAAE;AACpC,IAAI,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;AACjC,QAAQ,CAAC,YAAY;AACrB,cAAc,IAAI,UAAU,CAAC,CAAC;AAC9B,cAAc,IAAI,UAAU,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,UAAU;AACjE,KAAK;AACL,IAAI,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;AACzD,IAAI,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC;AACrC,IAAI,IAAI,GAAG,GAAG,CAAC;AACf,IAAI,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE;AAC3B,QAAQ,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC;AACvB,QAAQ,GAAG,IAAI,CAAC,CAAC,MAAM;AACvB,IAAI;AACJ,IAAI,OAAO,GAAG;AACd;;;;;;"}
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { CollectorListener, EventStreamListener } from '@dcmjs-org/parser';
2
- import { writePart10, EXPLICIT_LITTLE_ENDIAN, EXPLICIT_BIG_ENDIAN, IMPLICIT_LITTLE_ENDIAN, WriteBufferStream, DEFLATED_EXPLICIT_LITTLE_ENDIAN, writeDataSet, writeTagObject } from '@dcmjs-org/core';
2
+ import { writePart10, EXPLICIT_LITTLE_ENDIAN, EXPLICIT_BIG_ENDIAN, IMPLICIT_LITTLE_ENDIAN, WriteBufferStream, DEFLATED_EXPLICIT_LITTLE_ENDIAN, writeDataSet, writeTagObject, encodeBase64 } from '@dcmjs-org/core';
3
3
 
4
4
  /**
5
5
  * Part10Writer — slice E2: an event-stream sink that produces DICOM Part 10
@@ -506,20 +506,5 @@ function concatFragments(fragments) {
506
506
  return out;
507
507
  }
508
508
 
509
- function encodeBase64(uint8) {
510
- if (typeof Buffer !== "undefined") {
511
- return Buffer.from(
512
- uint8.buffer,
513
- uint8.byteOffset,
514
- uint8.byteLength
515
- ).toString("base64");
516
- }
517
- let binary = "";
518
- for (let i = 0; i < uint8.length; i++) {
519
- binary += String.fromCharCode(uint8[i]);
520
- }
521
- return btoa(binary);
522
- }
523
-
524
509
  export { DicomWebJsonWriter, Part10Writer, StreamingPart10Writer };
525
510
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../src/eventStream/Part10Writer.js","../src/eventStream/StreamingPart10Writer.js","../src/eventStream/DicomWebJsonWriter.js"],"sourcesContent":["import { CollectorListener } from \"@dcmjs-org/parser\";\nimport { writePart10 } from \"@dcmjs-org/core\";\n\n/**\n * Part10Writer — slice E2: an event-stream sink that produces DICOM Part 10\n * bytes.\n *\n * Architecture: this is a thin LAYER over the canonical encoder, not a second\n * encoder. It collects the event stream into a tag-keyed `{ meta, dict }` tree\n * (reusing CollectorListener) and delegates serialization to core's\n * `writePart10` (the proven Part 10 envelope, relocated from legacy\n * `DicomDict.write()`), which handles every VR, undefined-length sequences,\n * deflate, padding, Big16, and FileMetaInformationGroupLength recomputation.\n * This closed the one temporary `@dcmjs-org/legacy` edge this package had.\n *\n * Byte-IDENTICAL Part 10 round-tripping (incl. re-emitting compressed pixel data\n * verbatim) is intentionally NOT this path's job — that is a non-goal of the\n * naturalized/event layer (spec §4.5) and remains served by the lazy-read +\n * R4 passthrough-write path. This writer produces correct, semantically faithful\n * Part 10 output from any event source.\n */\nexport class Part10Writer extends CollectorListener {\n /**\n * Serialize the collected dataset to a Part 10 ArrayBuffer.\n * @param {Object} [writeOptions] forwarded to writePart10\n * @returns {ArrayBuffer}\n */\n write(writeOptions) {\n const meta = { ...this.result.meta };\n // writePart10 recomputes the group length; drop any collected one so\n // it is not double-counted.\n delete meta[\"00020000\"];\n\n const dataSet = { meta, dict: this.result.dict };\n return writeOptions\n ? writePart10(dataSet, writeOptions)\n : writePart10(dataSet);\n }\n}\n","import { EventStreamListener } from \"@dcmjs-org/parser\";\nimport {\n WriteBufferStream,\n EXPLICIT_BIG_ENDIAN,\n EXPLICIT_LITTLE_ENDIAN,\n IMPLICIT_LITTLE_ENDIAN,\n DEFLATED_EXPLICIT_LITTLE_ENDIAN,\n writeDataSet,\n writeTagObject\n} from \"@dcmjs-org/core\";\n\nconst FMI_GROUP_LENGTH = \"00020000\";\nconst TRANSFER_SYNTAX_UID = \"00020010\";\nconst UNDEFINED_LENGTH = 0xffffffff;\n\n/**\n * StreamingPart10Writer — plan-R2: an event-stream sink that emits DICOM\n * Part 10 bytes incrementally, as events arrive, instead of collecting the\n * whole dataset first like {@link Part10Writer}.\n *\n * Purpose: writing datasets whose Pixel Data does not fit in memory (the\n * R2 trigger — e.g. a Supplement 225 fragmentable video instance measured in\n * tens of GB). Peak memory is bounded by the largest single non-encapsulated\n * element plus the file meta group; encapsulated pixel-data fragments are\n * forwarded chunk-for-chunk and never accumulated.\n *\n * Output contract: `options.onChunk(Uint8Array)` is called zero or more times\n * per event, in file order. Absent `onChunk`, chunks accumulate on\n * `this.chunks` (testing convenience; that mode is NOT streaming). The caller\n * owns backpressure: wire the generator's `setDrain` to the sink that\n * consumes the chunks (e.g. a Node fs write stream's own drain).\n *\n * Encoding decisions (all legal Part 10, all chosen to avoid backpatching):\n * - the file meta group is buffered — it is small and its group length\n * (0002,0000) must be computed over the encoded elements, exactly as\n * DicomDict.write does;\n * - sequences and their items are written with undefined length and closed\n * with item/sequence delimitation items;\n * - encapsulated pixel data is written with undefined length, an empty\n * Basic Offset Table, one item per incoming fragment (odd fragments are\n * padded), and a sequence delimiter.\n *\n * Byte-identical round-tripping remains a non-goal (spec §4.5 / D15): output\n * is correct, semantically faithful Part 10, not a byte-for-byte copy of any\n * source.\n *\n * Not supported (throws): deflated transfer syntax, bulkDataReference events\n * (the bytes are elsewhere — materialize them first), sequences inside the\n * file meta group.\n */\nexport class StreamingPart10Writer extends EventStreamListener {\n /**\n * @param {Object} [options]\n * @param {(chunk: Uint8Array) => void} [options.onChunk] - Byte sink;\n * defaults to accumulating on `this.chunks`.\n * @param {Object} [options.writeOptions] - Forwarded to the element\n * encoders (e.g. { allowInvalidVRLength }).\n * @param {...Object} filters - Event-stream filters, as for any listener.\n */\n constructor(options = {}, ...filters) {\n super(...filters);\n this.chunks = [];\n this._onChunk = options.onChunk ?? (chunk => this.chunks.push(chunk));\n this._writeOptions = options.writeOptions ?? {\n allowInvalidVRLength: false\n };\n this.bytesWritten = 0;\n this._inMeta = false;\n this._meta = {};\n this._bodySyntax = EXPLICIT_LITTLE_ENDIAN;\n this._current = null;\n this._encapsulated = false;\n this.done = false;\n }\n\n /**\n * Endianness for every header the writer builds itself (sequence, item,\n * delimiter and encapsulated pixel-data headers). Review finding 5: these\n * were hardcoded little-endian while plain elements followed the body\n * syntax, so an Explicit VR Big Endian file disagreed with itself. File\n * Meta streams do NOT use this — the meta group is always explicit\n * little endian (PS3.10 §7.1).\n * @private\n */\n get _bodyLittleEndian() {\n return this._bodySyntax !== EXPLICIT_BIG_ENDIAN;\n }\n\n /** @param {ArrayBuffer|Uint8Array} bytes @private */\n _emit(bytes) {\n const chunk =\n bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);\n this.bytesWritten += chunk.byteLength;\n this._onChunk(chunk);\n }\n\n /** @private */\n _emitStream(stream) {\n this._emit(stream.getBuffer(0, stream.size));\n }\n\n /**\n * Writes a bare tag + 32-bit length, the form shared by item and\n * delimitation items (never a VR).\n * @private\n */\n _writeRawTag(stream, group, element, length) {\n stream.writeUint16(group);\n stream.writeUint16(element);\n stream.writeUint32(length);\n }\n\n /**\n * Writes an element header in the long (reserved + 32-bit length) form —\n * the only form needed for the headers this writer emits itself (SQ and\n * encapsulated OB/OW/UN); everything else goes through\n * core's writeTagObject.\n * @private\n */\n _writeLongHeader(stream, tag, vr, length) {\n stream.writeUint16(parseInt(tag.substring(0, 4), 16));\n stream.writeUint16(parseInt(tag.substring(4, 8), 16));\n if (this._bodySyntax !== IMPLICIT_LITTLE_ENDIAN) {\n stream.writeAsciiString(vr);\n stream.writeUint16(0);\n }\n stream.writeUint32(length);\n }\n\n _baseStartDataSet() {}\n\n _baseEndDataSet() {\n this.done = true;\n }\n\n _baseStartFileMetaInformation() {\n this._inMeta = true;\n const stream = new WriteBufferStream(160, true);\n stream.writeUint8Repeat(0, 128);\n stream.writeAsciiString(\"DICM\");\n this._emitStream(stream);\n }\n\n _baseEndFileMetaInformation() {\n this._inMeta = false;\n if (!this._meta[TRANSFER_SYNTAX_UID]) {\n this._meta[TRANSFER_SYNTAX_UID] = {\n vr: \"UI\",\n Value: [EXPLICIT_LITTLE_ENDIAN]\n };\n }\n this._bodySyntax = this._meta[TRANSFER_SYNTAX_UID].Value[0];\n if (this._bodySyntax === DEFLATED_EXPLICIT_LITTLE_ENDIAN) {\n throw new Error(\n \"StreamingPart10Writer does not support the deflated \" +\n \"transfer syntax; inflate the source or use Part10Writer\"\n );\n }\n // Group length must cover the encoded meta elements, so the group is\n // the one part of the file that cannot stream element-by-element.\n delete this._meta[FMI_GROUP_LENGTH];\n const metaStream = new WriteBufferStream(1024, true);\n writeDataSet(\n this._meta,\n metaStream,\n EXPLICIT_LITTLE_ENDIAN,\n this._writeOptions\n );\n const out = new WriteBufferStream(1024 + 16, true);\n writeTagObject(\n out,\n FMI_GROUP_LENGTH,\n \"UL\",\n metaStream.size,\n EXPLICIT_LITTLE_ENDIAN,\n this._writeOptions\n );\n out.concat(metaStream);\n this._emitStream(out);\n this._meta = {};\n }\n\n _baseStartElement(tag, info = {}) {\n this._current = { tag, vr: info.vr, values: [], emitted: false };\n }\n\n _baseValue(v) {\n this._current.values.push(v);\n }\n\n _baseEndElement() {\n const el = this._current;\n this._current = null;\n if (el.emitted) {\n return; // encapsulated path already streamed it\n }\n if (this._inMeta) {\n if (el.tag !== FMI_GROUP_LENGTH) {\n this._meta[el.tag] = { vr: el.vr, Value: el.values };\n }\n return;\n }\n const stream = new WriteBufferStream(256, this._bodyLittleEndian);\n writeTagObject(\n stream,\n el.tag,\n el.vr,\n el.values,\n this._bodySyntax,\n this._writeOptions\n );\n this._emitStream(stream);\n }\n\n _baseStartBinary(opts = {}) {\n if (opts.encapsulated && this._inMeta) {\n throw new Error(\n \"encapsulated binary is not legal in the file meta group\"\n );\n }\n if (!opts.encapsulated) {\n // Defined-length binary: fragments accumulate on the element and\n // endElement serializes it whole (bounded by that one element).\n this._encapsulated = false;\n return;\n }\n this._encapsulated = true;\n this._current.emitted = true;\n const stream = new WriteBufferStream(24, this._bodyLittleEndian);\n this._writeLongHeader(\n stream,\n this._current.tag,\n this._current.vr || \"OB\",\n UNDEFINED_LENGTH\n );\n // Empty Basic Offset Table: generators emit data fragments only (the\n // source table, if any, indexes source offsets that no longer hold).\n this._writeRawTag(stream, 0xfffe, 0xe000, 0);\n this._emitStream(stream);\n }\n\n _baseBinaryFragment(chunk) {\n const bytes =\n chunk instanceof Uint8Array\n ? chunk\n : chunk instanceof ArrayBuffer\n ? new Uint8Array(chunk)\n : new Uint8Array(\n chunk.buffer,\n chunk.byteOffset,\n chunk.byteLength\n );\n if (!this._encapsulated) {\n // Review finding 11: bytes.buffer is the WHOLE backing store, so\n // a subarray view would write (and retain) every byte of it.\n // Slice out the view's own window when they differ.\n this._current.values.push(\n bytes.byteOffset === 0 &&\n bytes.byteLength === bytes.buffer.byteLength\n ? bytes.buffer\n : bytes.buffer.slice(\n bytes.byteOffset,\n bytes.byteOffset + bytes.byteLength\n )\n );\n return;\n }\n const pad = bytes.byteLength % 2;\n const header = new WriteBufferStream(8, this._bodyLittleEndian);\n this._writeRawTag(header, 0xfffe, 0xe000, bytes.byteLength + pad);\n this._emitStream(header);\n this._emit(bytes);\n if (pad) {\n this._emit(new Uint8Array(1));\n }\n }\n\n _baseEndBinary() {\n if (this._encapsulated) {\n const stream = new WriteBufferStream(8, this._bodyLittleEndian);\n this._writeRawTag(stream, 0xfffe, 0xe0dd, 0);\n this._emitStream(stream);\n this._encapsulated = false;\n }\n }\n\n _baseStartSequence(tag, info = {}) {\n if (this._inMeta) {\n throw new Error(\"sequences are not legal in the file meta group\");\n }\n // Undefined length streams without backpatching; items and the\n // delimiters below close it out (PS3.5 §7.5).\n const stream = new WriteBufferStream(16, this._bodyLittleEndian);\n this._writeLongHeader(stream, tag, info.vr || \"SQ\", UNDEFINED_LENGTH);\n this._emitStream(stream);\n }\n\n _baseStartItem() {\n const stream = new WriteBufferStream(8, this._bodyLittleEndian);\n this._writeRawTag(stream, 0xfffe, 0xe000, UNDEFINED_LENGTH);\n this._emitStream(stream);\n }\n\n _baseEndItem() {\n const stream = new WriteBufferStream(8, this._bodyLittleEndian);\n this._writeRawTag(stream, 0xfffe, 0xe00d, 0);\n this._emitStream(stream);\n }\n\n _baseEndSequence() {\n const stream = new WriteBufferStream(8, this._bodyLittleEndian);\n this._writeRawTag(stream, 0xfffe, 0xe0dd, 0);\n this._emitStream(stream);\n }\n\n _baseBulkDataReference(ref = {}) {\n throw new Error(\n \"StreamingPart10Writer cannot serialize a bulkDataReference \" +\n `(${ref.uri ?? \"no uri\"}); materialize bulk data before writing`\n );\n }\n\n /**\n * Testing convenience for the accumulate mode: the collected chunks as\n * one ArrayBuffer. Meaningless when onChunk was provided.\n * @returns {ArrayBuffer}\n */\n toArrayBuffer() {\n const total = this.chunks.reduce((n, c) => n + c.byteLength, 0);\n const out = new Uint8Array(total);\n let offset = 0;\n for (const chunk of this.chunks) {\n out.set(chunk, offset);\n offset += chunk.byteLength;\n }\n return out.buffer;\n }\n}\n","import { EventStreamListener } from \"@dcmjs-org/parser\";\n\n/**\n * DicomWebJsonWriter — slice E1: an event-stream consumer that writes the\n * DICOM JSON model (DICOMweb metadata representation).\n *\n * The faithful inverse of `fromDicomWebJson`: it makes the contract a SINK as\n * well as a source, so the architecture round-trips\n * (DICOMweb JSON -> events -> DICOMweb JSON is identity) and any source can be\n * serialized to DICOMweb JSON (Part 10 -> events -> JSON).\n *\n * Output shape per tag: `{ vr, Value: [...] }`, or `{ vr, BulkDataURI }`, or\n * `{ vr, InlineBinary: base64 }`. Person Names pass through as the DICOMweb\n * `{ Alphabetic }` objects the contract carries. Binary source form is preserved\n * (§25): a `bulkDataReference` stays a `BulkDataURI`; assembled binary fragments\n * become base64 `InlineBinary`. Meta (group 0002) elements, when present, are\n * written flat alongside the dataset.\n */\nexport class DicomWebJsonWriter extends EventStreamListener {\n constructor(...filters) {\n super(...filters);\n this.result = {};\n // Stack of containers (the root object or a sequence item object) plus\n // the element/sequence currently being built.\n this._containers = [this.result];\n this._pending = null; // { tag, attr, fragments? }\n }\n\n _container() {\n return this._containers[this._containers.length - 1];\n }\n\n _baseStartDataSet() {\n this.result = {};\n this._containers = [this.result];\n this._pending = null;\n }\n\n _baseStartElement(tag, info = {}) {\n this._pending = { tag, attr: { vr: info.vr }, values: [] };\n }\n\n _baseValue(v, info) {\n this._pending.values.push(this._jsonModelValue(v, info));\n }\n\n /**\n * PS3.18 F.2.3.1: DS/IS may be encoded as JSON numbers OR strings.\n * Emit a number when the conversion is lossless (dcm4chee parity, #53);\n * fall back to the raw source string when Number() would silently lose\n * integer precision — e.g. DS/IS integers beyond 2^53 (#398). The raw\n * string is the standard's escape hatch; `_rawValue` itself never\n * appears in the JSON model (#404).\n */\n _jsonModelValue(v, info) {\n const vr = this._pending.attr.vr;\n if (\n (vr === \"DS\" || vr === \"IS\") &&\n info &&\n typeof info.rawValue === \"string\"\n ) {\n const raw = info.rawValue.trim();\n const parsed = Number(raw);\n if (\n /^[+-]?\\d+$/.test(raw) &&\n !Number.isSafeInteger(parsed) &&\n String(parsed) !== raw\n ) {\n return raw;\n }\n }\n return v;\n }\n\n _baseBulkDataReference(ref = {}) {\n this._pending.attr.BulkDataURI = ref.uri;\n this._pending.values = null; // bulk reference carries no Value\n }\n\n _baseStartBinary() {\n this._pending.fragments = [];\n this._pending.values = null;\n }\n\n _baseBinaryFragment(chunk) {\n this._pending.fragments.push(chunk);\n }\n\n _baseEndBinary() {\n this._pending.attr.InlineBinary = encodeBase64(\n concatFragments(this._pending.fragments)\n );\n }\n\n _baseEndElement() {\n const { tag, attr, values } = this._pending;\n if (values && values.length) {\n attr.Value = values;\n }\n this._container()[tag] = attr;\n this._pending = null;\n }\n\n _baseStartSequence(tag, info = {}) {\n const attr = { vr: info.vr, Value: [] };\n this._container()[tag] = attr;\n this._pending = null;\n // Items are pushed into attr.Value via a sequence marker on the stack.\n this._containers.push({ __seqValue: attr.Value });\n }\n\n _baseStartItem() {\n const item = {};\n this._container().__seqValue.push(item);\n this._containers.push(item);\n }\n\n _baseEndItem() {\n this._containers.pop();\n }\n\n _baseEndSequence() {\n this._containers.pop();\n }\n}\n\nfunction concatFragments(fragments) {\n const parts = fragments.map(f =>\n f instanceof ArrayBuffer\n ? new Uint8Array(f)\n : new Uint8Array(f.buffer, f.byteOffset, f.byteLength)\n );\n const total = parts.reduce((n, p) => n + p.length, 0);\n const out = new Uint8Array(total);\n let off = 0;\n for (const p of parts) {\n out.set(p, off);\n off += p.length;\n }\n return out;\n}\n\nfunction encodeBase64(uint8) {\n if (typeof Buffer !== \"undefined\") {\n return Buffer.from(\n uint8.buffer,\n uint8.byteOffset,\n uint8.byteLength\n ).toString(\"base64\");\n }\n let binary = \"\";\n for (let i = 0; i < uint8.length; i++) {\n binary += String.fromCharCode(uint8[i]);\n }\n return btoa(binary);\n}\n"],"names":[],"mappings":";;;AAGA;AACA;AACA;AACA;AAC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;AAC5B,IAAI;AACJ,IAAI,IAAI,MAAM,GAAG,EAAE;AACnB,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC3C,QAAQ,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC/C,IAAI;AACJ,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC;AACvB;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":["../src/eventStream/Part10Writer.js","../src/eventStream/StreamingPart10Writer.js","../src/eventStream/DicomWebJsonWriter.js"],"sourcesContent":["import { CollectorListener } from \"@dcmjs-org/parser\";\nimport { writePart10 } from \"@dcmjs-org/core\";\n\n/**\n * Part10Writer — slice E2: an event-stream sink that produces DICOM Part 10\n * bytes.\n *\n * Architecture: this is a thin LAYER over the canonical encoder, not a second\n * encoder. It collects the event stream into a tag-keyed `{ meta, dict }` tree\n * (reusing CollectorListener) and delegates serialization to core's\n * `writePart10` (the proven Part 10 envelope, relocated from legacy\n * `DicomDict.write()`), which handles every VR, undefined-length sequences,\n * deflate, padding, Big16, and FileMetaInformationGroupLength recomputation.\n * This closed the one temporary `@dcmjs-org/legacy` edge this package had.\n *\n * Byte-IDENTICAL Part 10 round-tripping (incl. re-emitting compressed pixel data\n * verbatim) is intentionally NOT this path's job — that is a non-goal of the\n * naturalized/event layer (spec §4.5) and remains served by the lazy-read +\n * R4 passthrough-write path. This writer produces correct, semantically faithful\n * Part 10 output from any event source.\n */\nexport class Part10Writer extends CollectorListener {\n /**\n * Serialize the collected dataset to a Part 10 ArrayBuffer.\n * @param {Object} [writeOptions] forwarded to writePart10\n * @returns {ArrayBuffer}\n */\n write(writeOptions) {\n const meta = { ...this.result.meta };\n // writePart10 recomputes the group length; drop any collected one so\n // it is not double-counted.\n delete meta[\"00020000\"];\n\n const dataSet = { meta, dict: this.result.dict };\n return writeOptions\n ? writePart10(dataSet, writeOptions)\n : writePart10(dataSet);\n }\n}\n","import { EventStreamListener } from \"@dcmjs-org/parser\";\nimport {\n WriteBufferStream,\n EXPLICIT_BIG_ENDIAN,\n EXPLICIT_LITTLE_ENDIAN,\n IMPLICIT_LITTLE_ENDIAN,\n DEFLATED_EXPLICIT_LITTLE_ENDIAN,\n writeDataSet,\n writeTagObject\n} from \"@dcmjs-org/core\";\n\nconst FMI_GROUP_LENGTH = \"00020000\";\nconst TRANSFER_SYNTAX_UID = \"00020010\";\nconst UNDEFINED_LENGTH = 0xffffffff;\n\n/**\n * StreamingPart10Writer — plan-R2: an event-stream sink that emits DICOM\n * Part 10 bytes incrementally, as events arrive, instead of collecting the\n * whole dataset first like {@link Part10Writer}.\n *\n * Purpose: writing datasets whose Pixel Data does not fit in memory (the\n * R2 trigger — e.g. a Supplement 225 fragmentable video instance measured in\n * tens of GB). Peak memory is bounded by the largest single non-encapsulated\n * element plus the file meta group; encapsulated pixel-data fragments are\n * forwarded chunk-for-chunk and never accumulated.\n *\n * Output contract: `options.onChunk(Uint8Array)` is called zero or more times\n * per event, in file order. Absent `onChunk`, chunks accumulate on\n * `this.chunks` (testing convenience; that mode is NOT streaming). The caller\n * owns backpressure: wire the generator's `setDrain` to the sink that\n * consumes the chunks (e.g. a Node fs write stream's own drain).\n *\n * Encoding decisions (all legal Part 10, all chosen to avoid backpatching):\n * - the file meta group is buffered — it is small and its group length\n * (0002,0000) must be computed over the encoded elements, exactly as\n * DicomDict.write does;\n * - sequences and their items are written with undefined length and closed\n * with item/sequence delimitation items;\n * - encapsulated pixel data is written with undefined length, an empty\n * Basic Offset Table, one item per incoming fragment (odd fragments are\n * padded), and a sequence delimiter.\n *\n * Byte-identical round-tripping remains a non-goal (spec §4.5 / D15): output\n * is correct, semantically faithful Part 10, not a byte-for-byte copy of any\n * source.\n *\n * Not supported (throws): deflated transfer syntax, bulkDataReference events\n * (the bytes are elsewhere — materialize them first), sequences inside the\n * file meta group.\n */\nexport class StreamingPart10Writer extends EventStreamListener {\n /**\n * @param {Object} [options]\n * @param {(chunk: Uint8Array) => void} [options.onChunk] - Byte sink;\n * defaults to accumulating on `this.chunks`.\n * @param {Object} [options.writeOptions] - Forwarded to the element\n * encoders (e.g. { allowInvalidVRLength }).\n * @param {...Object} filters - Event-stream filters, as for any listener.\n */\n constructor(options = {}, ...filters) {\n super(...filters);\n this.chunks = [];\n this._onChunk = options.onChunk ?? (chunk => this.chunks.push(chunk));\n this._writeOptions = options.writeOptions ?? {\n allowInvalidVRLength: false\n };\n this.bytesWritten = 0;\n this._inMeta = false;\n this._meta = {};\n this._bodySyntax = EXPLICIT_LITTLE_ENDIAN;\n this._current = null;\n this._encapsulated = false;\n this.done = false;\n }\n\n /**\n * Endianness for every header the writer builds itself (sequence, item,\n * delimiter and encapsulated pixel-data headers). Review finding 5: these\n * were hardcoded little-endian while plain elements followed the body\n * syntax, so an Explicit VR Big Endian file disagreed with itself. File\n * Meta streams do NOT use this — the meta group is always explicit\n * little endian (PS3.10 §7.1).\n * @private\n */\n get _bodyLittleEndian() {\n return this._bodySyntax !== EXPLICIT_BIG_ENDIAN;\n }\n\n /** @param {ArrayBuffer|Uint8Array} bytes @private */\n _emit(bytes) {\n const chunk =\n bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);\n this.bytesWritten += chunk.byteLength;\n this._onChunk(chunk);\n }\n\n /** @private */\n _emitStream(stream) {\n this._emit(stream.getBuffer(0, stream.size));\n }\n\n /**\n * Writes a bare tag + 32-bit length, the form shared by item and\n * delimitation items (never a VR).\n * @private\n */\n _writeRawTag(stream, group, element, length) {\n stream.writeUint16(group);\n stream.writeUint16(element);\n stream.writeUint32(length);\n }\n\n /**\n * Writes an element header in the long (reserved + 32-bit length) form —\n * the only form needed for the headers this writer emits itself (SQ and\n * encapsulated OB/OW/UN); everything else goes through\n * core's writeTagObject.\n * @private\n */\n _writeLongHeader(stream, tag, vr, length) {\n stream.writeUint16(parseInt(tag.substring(0, 4), 16));\n stream.writeUint16(parseInt(tag.substring(4, 8), 16));\n if (this._bodySyntax !== IMPLICIT_LITTLE_ENDIAN) {\n stream.writeAsciiString(vr);\n stream.writeUint16(0);\n }\n stream.writeUint32(length);\n }\n\n _baseStartDataSet() {}\n\n _baseEndDataSet() {\n this.done = true;\n }\n\n _baseStartFileMetaInformation() {\n this._inMeta = true;\n const stream = new WriteBufferStream(160, true);\n stream.writeUint8Repeat(0, 128);\n stream.writeAsciiString(\"DICM\");\n this._emitStream(stream);\n }\n\n _baseEndFileMetaInformation() {\n this._inMeta = false;\n if (!this._meta[TRANSFER_SYNTAX_UID]) {\n this._meta[TRANSFER_SYNTAX_UID] = {\n vr: \"UI\",\n Value: [EXPLICIT_LITTLE_ENDIAN]\n };\n }\n this._bodySyntax = this._meta[TRANSFER_SYNTAX_UID].Value[0];\n if (this._bodySyntax === DEFLATED_EXPLICIT_LITTLE_ENDIAN) {\n throw new Error(\n \"StreamingPart10Writer does not support the deflated \" +\n \"transfer syntax; inflate the source or use Part10Writer\"\n );\n }\n // Group length must cover the encoded meta elements, so the group is\n // the one part of the file that cannot stream element-by-element.\n delete this._meta[FMI_GROUP_LENGTH];\n const metaStream = new WriteBufferStream(1024, true);\n writeDataSet(\n this._meta,\n metaStream,\n EXPLICIT_LITTLE_ENDIAN,\n this._writeOptions\n );\n const out = new WriteBufferStream(1024 + 16, true);\n writeTagObject(\n out,\n FMI_GROUP_LENGTH,\n \"UL\",\n metaStream.size,\n EXPLICIT_LITTLE_ENDIAN,\n this._writeOptions\n );\n out.concat(metaStream);\n this._emitStream(out);\n this._meta = {};\n }\n\n _baseStartElement(tag, info = {}) {\n this._current = { tag, vr: info.vr, values: [], emitted: false };\n }\n\n _baseValue(v) {\n this._current.values.push(v);\n }\n\n _baseEndElement() {\n const el = this._current;\n this._current = null;\n if (el.emitted) {\n return; // encapsulated path already streamed it\n }\n if (this._inMeta) {\n if (el.tag !== FMI_GROUP_LENGTH) {\n this._meta[el.tag] = { vr: el.vr, Value: el.values };\n }\n return;\n }\n const stream = new WriteBufferStream(256, this._bodyLittleEndian);\n writeTagObject(\n stream,\n el.tag,\n el.vr,\n el.values,\n this._bodySyntax,\n this._writeOptions\n );\n this._emitStream(stream);\n }\n\n _baseStartBinary(opts = {}) {\n if (opts.encapsulated && this._inMeta) {\n throw new Error(\n \"encapsulated binary is not legal in the file meta group\"\n );\n }\n if (!opts.encapsulated) {\n // Defined-length binary: fragments accumulate on the element and\n // endElement serializes it whole (bounded by that one element).\n this._encapsulated = false;\n return;\n }\n this._encapsulated = true;\n this._current.emitted = true;\n const stream = new WriteBufferStream(24, this._bodyLittleEndian);\n this._writeLongHeader(\n stream,\n this._current.tag,\n this._current.vr || \"OB\",\n UNDEFINED_LENGTH\n );\n // Empty Basic Offset Table: generators emit data fragments only (the\n // source table, if any, indexes source offsets that no longer hold).\n this._writeRawTag(stream, 0xfffe, 0xe000, 0);\n this._emitStream(stream);\n }\n\n _baseBinaryFragment(chunk) {\n const bytes =\n chunk instanceof Uint8Array\n ? chunk\n : chunk instanceof ArrayBuffer\n ? new Uint8Array(chunk)\n : new Uint8Array(\n chunk.buffer,\n chunk.byteOffset,\n chunk.byteLength\n );\n if (!this._encapsulated) {\n // Review finding 11: bytes.buffer is the WHOLE backing store, so\n // a subarray view would write (and retain) every byte of it.\n // Slice out the view's own window when they differ.\n this._current.values.push(\n bytes.byteOffset === 0 &&\n bytes.byteLength === bytes.buffer.byteLength\n ? bytes.buffer\n : bytes.buffer.slice(\n bytes.byteOffset,\n bytes.byteOffset + bytes.byteLength\n )\n );\n return;\n }\n const pad = bytes.byteLength % 2;\n const header = new WriteBufferStream(8, this._bodyLittleEndian);\n this._writeRawTag(header, 0xfffe, 0xe000, bytes.byteLength + pad);\n this._emitStream(header);\n this._emit(bytes);\n if (pad) {\n this._emit(new Uint8Array(1));\n }\n }\n\n _baseEndBinary() {\n if (this._encapsulated) {\n const stream = new WriteBufferStream(8, this._bodyLittleEndian);\n this._writeRawTag(stream, 0xfffe, 0xe0dd, 0);\n this._emitStream(stream);\n this._encapsulated = false;\n }\n }\n\n _baseStartSequence(tag, info = {}) {\n if (this._inMeta) {\n throw new Error(\"sequences are not legal in the file meta group\");\n }\n // Undefined length streams without backpatching; items and the\n // delimiters below close it out (PS3.5 §7.5).\n const stream = new WriteBufferStream(16, this._bodyLittleEndian);\n this._writeLongHeader(stream, tag, info.vr || \"SQ\", UNDEFINED_LENGTH);\n this._emitStream(stream);\n }\n\n _baseStartItem() {\n const stream = new WriteBufferStream(8, this._bodyLittleEndian);\n this._writeRawTag(stream, 0xfffe, 0xe000, UNDEFINED_LENGTH);\n this._emitStream(stream);\n }\n\n _baseEndItem() {\n const stream = new WriteBufferStream(8, this._bodyLittleEndian);\n this._writeRawTag(stream, 0xfffe, 0xe00d, 0);\n this._emitStream(stream);\n }\n\n _baseEndSequence() {\n const stream = new WriteBufferStream(8, this._bodyLittleEndian);\n this._writeRawTag(stream, 0xfffe, 0xe0dd, 0);\n this._emitStream(stream);\n }\n\n _baseBulkDataReference(ref = {}) {\n throw new Error(\n \"StreamingPart10Writer cannot serialize a bulkDataReference \" +\n `(${ref.uri ?? \"no uri\"}); materialize bulk data before writing`\n );\n }\n\n /**\n * Testing convenience for the accumulate mode: the collected chunks as\n * one ArrayBuffer. Meaningless when onChunk was provided.\n * @returns {ArrayBuffer}\n */\n toArrayBuffer() {\n const total = this.chunks.reduce((n, c) => n + c.byteLength, 0);\n const out = new Uint8Array(total);\n let offset = 0;\n for (const chunk of this.chunks) {\n out.set(chunk, offset);\n offset += chunk.byteLength;\n }\n return out.buffer;\n }\n}\n","import { encodeBase64 } from \"@dcmjs-org/core\";\nimport { EventStreamListener } from \"@dcmjs-org/parser\";\n\n/**\n * DicomWebJsonWriter — slice E1: an event-stream consumer that writes the\n * DICOM JSON model (DICOMweb metadata representation).\n *\n * The faithful inverse of `fromDicomWebJson`: it makes the contract a SINK as\n * well as a source, so the architecture round-trips\n * (DICOMweb JSON -> events -> DICOMweb JSON is identity) and any source can be\n * serialized to DICOMweb JSON (Part 10 -> events -> JSON).\n *\n * Output shape per tag: `{ vr, Value: [...] }`, or `{ vr, BulkDataURI }`, or\n * `{ vr, InlineBinary: base64 }`. Person Names pass through as the DICOMweb\n * `{ Alphabetic }` objects the contract carries. Binary source form is preserved\n * (§25): a `bulkDataReference` stays a `BulkDataURI`; assembled binary fragments\n * become base64 `InlineBinary`. Meta (group 0002) elements, when present, are\n * written flat alongside the dataset.\n */\nexport class DicomWebJsonWriter extends EventStreamListener {\n constructor(...filters) {\n super(...filters);\n this.result = {};\n // Stack of containers (the root object or a sequence item object) plus\n // the element/sequence currently being built.\n this._containers = [this.result];\n this._pending = null; // { tag, attr, fragments? }\n }\n\n _container() {\n return this._containers[this._containers.length - 1];\n }\n\n _baseStartDataSet() {\n this.result = {};\n this._containers = [this.result];\n this._pending = null;\n }\n\n _baseStartElement(tag, info = {}) {\n this._pending = { tag, attr: { vr: info.vr }, values: [] };\n }\n\n _baseValue(v, info) {\n this._pending.values.push(this._jsonModelValue(v, info));\n }\n\n /**\n * PS3.18 F.2.3.1: DS/IS may be encoded as JSON numbers OR strings.\n * Emit a number when the conversion is lossless (dcm4chee parity, #53);\n * fall back to the raw source string when Number() would silently lose\n * integer precision — e.g. DS/IS integers beyond 2^53 (#398). The raw\n * string is the standard's escape hatch; `_rawValue` itself never\n * appears in the JSON model (#404).\n */\n _jsonModelValue(v, info) {\n const vr = this._pending.attr.vr;\n if (\n (vr === \"DS\" || vr === \"IS\") &&\n info &&\n typeof info.rawValue === \"string\"\n ) {\n const raw = info.rawValue.trim();\n const parsed = Number(raw);\n if (\n /^[+-]?\\d+$/.test(raw) &&\n !Number.isSafeInteger(parsed) &&\n String(parsed) !== raw\n ) {\n return raw;\n }\n }\n return v;\n }\n\n _baseBulkDataReference(ref = {}) {\n this._pending.attr.BulkDataURI = ref.uri;\n this._pending.values = null; // bulk reference carries no Value\n }\n\n _baseStartBinary() {\n this._pending.fragments = [];\n this._pending.values = null;\n }\n\n _baseBinaryFragment(chunk) {\n this._pending.fragments.push(chunk);\n }\n\n _baseEndBinary() {\n this._pending.attr.InlineBinary = encodeBase64(\n concatFragments(this._pending.fragments)\n );\n }\n\n _baseEndElement() {\n const { tag, attr, values } = this._pending;\n if (values && values.length) {\n attr.Value = values;\n }\n this._container()[tag] = attr;\n this._pending = null;\n }\n\n _baseStartSequence(tag, info = {}) {\n const attr = { vr: info.vr, Value: [] };\n this._container()[tag] = attr;\n this._pending = null;\n // Items are pushed into attr.Value via a sequence marker on the stack.\n this._containers.push({ __seqValue: attr.Value });\n }\n\n _baseStartItem() {\n const item = {};\n this._container().__seqValue.push(item);\n this._containers.push(item);\n }\n\n _baseEndItem() {\n this._containers.pop();\n }\n\n _baseEndSequence() {\n this._containers.pop();\n }\n}\n\nfunction concatFragments(fragments) {\n const parts = fragments.map(f =>\n f instanceof ArrayBuffer\n ? new Uint8Array(f)\n : new Uint8Array(f.buffer, f.byteOffset, f.byteLength)\n );\n const total = parts.reduce((n, p) => n + p.length, 0);\n const out = new Uint8Array(total);\n let off = 0;\n for (const p of parts) {\n out.set(p, off);\n off += p.length;\n }\n return out;\n}\n"],"names":[],"mappings":";;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,YAAY,SAAS,iBAAiB,CAAC;AACpD;AACA;AACA;AACA;AACA;AACA,IAAI,KAAK,CAAC,YAAY,EAAE;AACxB,QAAQ,MAAM,IAAI,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;AAC5C;AACA;AACA,QAAQ,OAAO,IAAI,CAAC,UAAU,CAAC;;AAE/B,QAAQ,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;AACxD,QAAQ,OAAO;AACf,cAAc,WAAW,CAAC,OAAO,EAAE,YAAY;AAC/C,cAAc,WAAW,CAAC,OAAO,CAAC;A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M,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,UAAU;AACjE,KAAK;AACL,IAAI,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;AACzD,IAAI,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC;AACrC,IAAI,IAAI,GAAG,GAAG,CAAC;AACf,IAAI,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE;AAC3B,QAAQ,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC;AACvB,QAAQ,GAAG,IAAI,CAAC,CAAC,MAAM;AACvB,IAAI;AACJ,IAAI,OAAO,GAAG;AACd;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcmjs-org/generator",
3
- "version": "1.0.0-beta.1",
3
+ "version": "1.0.0-beta.3",
4
4
  "description": "The event-stream writing side of dcmjs: the sinks that turn contract events into DICOM Part 10 bytes (collected or streaming) and DICOMweb JSON",
5
5
  "main": "./dist/index.cjs",
6
6
  "files": [
@@ -14,8 +14,8 @@
14
14
  "directory": "packages/generator"
15
15
  },
16
16
  "dependencies": {
17
- "@dcmjs-org/core": "1.0.0-beta.1",
18
- "@dcmjs-org/parser": "1.0.0-beta.1"
17
+ "@dcmjs-org/core": "1.0.0-beta.3",
18
+ "@dcmjs-org/parser": "1.0.0-beta.3"
19
19
  },
20
20
  "scripts": {
21
21
  "build": "rollup -c ../../rollup.packages.config.mjs"