dcmjs 0.50.0 → 0.50.1

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
@@ -14258,7 +14258,7 @@ var AsyncDicomReader = /*#__PURE__*/function () {
14258
14258
  key: "readSequence",
14259
14259
  value: function () {
14260
14260
  var _readSequence = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(listener, sqTagInfo, options) {
14261
- var length, stream, syntax, endOffset, tagInfo, tag;
14261
+ var length, stream, syntax, endOffset, tagInfo, tag, itemLength, itemUntilOffset;
14262
14262
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
14263
14263
  while (1) switch (_context6.prev = _context6.next) {
14264
14264
  case 0:
@@ -14277,37 +14277,45 @@ var AsyncDicomReader = /*#__PURE__*/function () {
14277
14277
  _context6.t0 = _context6.sent;
14278
14278
  case 8:
14279
14279
  if (!_context6.t0) {
14280
- _context6.next = 26;
14280
+ _context6.next = 28;
14281
14281
  break;
14282
14282
  }
14283
14283
  readLog.debug("readSequence loop", stream.offset, endOffset);
14284
14284
  tagInfo = this.readTagHeader(syntax, options);
14285
14285
  tag = tagInfo.tag;
14286
14286
  if (!(tag === TagHex.Item)) {
14287
- _context6.next = 18;
14287
+ _context6.next = 20;
14288
14288
  break;
14289
14289
  }
14290
14290
  listener.startObject();
14291
- _context6.next = 16;
14291
+ // For defined-length items, use the item's own end offset
14292
+ // so read() stops at the item boundary and returns control
14293
+ // to readSequence for the next item. Without this, all
14294
+ // items in a defined-length sequence get merged into the
14295
+ // first item because read() treats subsequent Item tags
14296
+ // as instructions and skips them.
14297
+ itemLength = tagInfo.length;
14298
+ itemUntilOffset = itemLength === UNDEFINED_LENGTH_FIX ? endOffset : Math.min(stream.offset + itemLength, endOffset);
14299
+ _context6.next = 18;
14292
14300
  return this.read(listener, _objectSpread2(_objectSpread2({}, options), {}, {
14293
- untilOffset: endOffset
14301
+ untilOffset: itemUntilOffset
14294
14302
  }));
14295
- case 16:
14296
- _context6.next = 24;
14297
- break;
14298
14303
  case 18:
14304
+ _context6.next = 26;
14305
+ break;
14306
+ case 20:
14299
14307
  if (!(tag === TagHex.SequenceDelimitationEnd)) {
14300
- _context6.next = 22;
14308
+ _context6.next = 24;
14301
14309
  break;
14302
14310
  }
14303
14311
  return _context6.abrupt("return");
14304
- case 22:
14312
+ case 24:
14305
14313
  console.warn("Unknown tag info", length, tagInfo);
14306
14314
  throw new Error();
14307
- case 24:
14315
+ case 26:
14308
14316
  _context6.next = 3;
14309
14317
  break;
14310
- case 26:
14318
+ case 28:
14311
14319
  case "end":
14312
14320
  return _context6.stop();
14313
14321
  }