dcmjs 0.49.1 → 0.49.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/build/dcmjs.es.js CHANGED
@@ -9194,12 +9194,7 @@ var SEQUENCE_DELIMITER_TAG = 0xfffee0dd;
9194
9194
 
9195
9195
  // Nearly all transfer syntaxes are encapsulated, so record those which are
9196
9196
  // unencapsulated as the exceptions.
9197
- var unencapsulatedTransferSyntaxes = {
9198
- IMPLICIT_LITTLE_ENDIAN: true,
9199
- EXPLICIT_BIG_ENDIAN: true,
9200
- DEFLATED_EXPLICIT_LITTLE_ENDIAN: true,
9201
- EXPLICIT_LITTLE_ENDIAN: true
9202
- };
9197
+ var unencapsulatedTransferSyntaxes = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, IMPLICIT_LITTLE_ENDIAN, true), EXPLICIT_BIG_ENDIAN, true), DEFLATED_EXPLICIT_LITTLE_ENDIAN, true), EXPLICIT_LITTLE_ENDIAN$1, true);
9203
9198
 
9204
9199
  /**
9205
9200
  * Video transfer syntax UIDs (MPEG2, H.264, H.265)
@@ -10011,7 +10006,7 @@ var BinaryRepresentation = /*#__PURE__*/function (_ValueRepresentation3) {
10011
10006
  }
10012
10007
  _createClass(BinaryRepresentation, [{
10013
10008
  key: "writeBytes",
10014
- value: function writeBytes(stream, value, syntax, isEncapsulated) {
10009
+ value: function writeBytes(stream, value, _syntax, isEncapsulated) {
10015
10010
  var writeOptions = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
10016
10011
  var i;
10017
10012
  var binaryStream;
@@ -11815,8 +11810,8 @@ var Tag = /*#__PURE__*/function () {
11815
11810
  value: function write(stream, vrType, values, syntax, writeOptions) {
11816
11811
  var vr = ValueRepresentation.createByTypeString(vrType);
11817
11812
  var useSyntax = DicomMessage$1._normalizeSyntax(syntax);
11818
- var implicit = useSyntax == IMPLICIT_LITTLE_ENDIAN ? true : false;
11819
- var isLittleEndian = useSyntax == IMPLICIT_LITTLE_ENDIAN || useSyntax == EXPLICIT_LITTLE_ENDIAN$1 ? true : false;
11813
+ var implicit = useSyntax === IMPLICIT_LITTLE_ENDIAN;
11814
+ var isLittleEndian = useSyntax === IMPLICIT_LITTLE_ENDIAN || useSyntax === EXPLICIT_LITTLE_ENDIAN$1;
11820
11815
  var isEncapsulated = this.isPixelDataTag() && DicomMessage$1.isEncapsulated(syntax);
11821
11816
  var oldEndian = stream.isLittleEndian;
11822
11817
  stream.setEndian(isLittleEndian);
@@ -12677,6 +12672,14 @@ var DicomMetadataListener = /*#__PURE__*/function () {
12677
12672
  _defineProperty(this, "dict", null);
12678
12673
  _defineProperty(this, "filters", []);
12679
12674
  _defineProperty(this, "information", null);
12675
+ /**
12676
+ * Optional backpressure (drain) function. When set, the reader will await
12677
+ * the returned promise before emitting more fragment values, to avoid
12678
+ * having too many open streams or overwhelming the consumer.
12679
+ */
12680
+ _defineProperty(this, "_drain", function () {
12681
+ return Promise.resolve();
12682
+ });
12680
12683
  // Handle legacy constructor format where first arg might be a filter
12681
12684
  if (typeof options.addTag === "function" || typeof options.startObject === "function" || typeof options.pop === "function" || typeof options.value === "function") {
12682
12685
  // Legacy format: all arguments are filters
@@ -12701,6 +12704,33 @@ var DicomMetadataListener = /*#__PURE__*/function () {
12701
12704
  * @returns {void}
12702
12705
  */
12703
12706
  _createClass(DicomMetadataListener, [{
12707
+ key: "setDrain",
12708
+ value:
12709
+ /**
12710
+ * Set the drain (pushback) function for backpressure. The function should
12711
+ * return a Promise that resolves when it is safe to emit more data (e.g.
12712
+ * when unsettled stream write count is below a limit). Node.js streams use
12713
+ * the term "drain" for this (see Writable 'drain' event).
12714
+ *
12715
+ * @param {(() => Promise<void>) | null} fn - Function that returns a Promise, or null to clear
12716
+ */
12717
+ function setDrain(fn) {
12718
+ this._drain = typeof fn === "function" ? fn : null;
12719
+ }
12720
+
12721
+ /**
12722
+ * Returns a Promise that resolves when the drain condition is met (or
12723
+ * immediately if no drain is set). Call this before emitting values to
12724
+ * apply backpressure.
12725
+ *
12726
+ * @returns {Promise<void>}
12727
+ */
12728
+ }, {
12729
+ key: "awaitDrain",
12730
+ value: function awaitDrain() {
12731
+ return this._drain() || Promise.resolve();
12732
+ }
12733
+ }, {
12704
12734
  key: "init",
12705
12735
  value: function init() {
12706
12736
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
@@ -13369,29 +13399,33 @@ var AsyncDicomReader = /*#__PURE__*/function () {
13369
13399
  key: "_emitSplitValues",
13370
13400
  value: (function () {
13371
13401
  var _emitSplitValues2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(length) {
13402
+ var _listener$awaitDrain;
13372
13403
  var stream, listener, maxFragmentSize, offset, chunkSize, buffer;
13373
13404
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
13374
13405
  while (1) switch (_context7.prev = _context7.next) {
13375
13406
  case 0:
13376
13407
  stream = this.stream, listener = this.listener;
13408
+ _context7.next = 3;
13409
+ return (_listener$awaitDrain = listener.awaitDrain) === null || _listener$awaitDrain === void 0 ? void 0 : _listener$awaitDrain.call(listener);
13410
+ case 3:
13377
13411
  maxFragmentSize = this.maxFragmentSize;
13378
13412
  offset = 0;
13379
- case 3:
13413
+ case 5:
13380
13414
  if (!(offset < length)) {
13381
- _context7.next = 13;
13415
+ _context7.next = 15;
13382
13416
  break;
13383
13417
  }
13384
13418
  chunkSize = Math.min(maxFragmentSize, length - offset);
13385
- _context7.next = 7;
13419
+ _context7.next = 9;
13386
13420
  return stream.ensureAvailable(chunkSize);
13387
- case 7:
13421
+ case 9:
13388
13422
  buffer = stream.readArrayBuffer(chunkSize);
13389
13423
  listener.value(buffer);
13390
13424
  offset += chunkSize;
13391
13425
  stream.consume();
13392
- _context7.next = 3;
13426
+ _context7.next = 5;
13393
13427
  break;
13394
- case 13:
13428
+ case 15:
13395
13429
  case "end":
13396
13430
  return _context7.stop();
13397
13431
  }