@dcmjs-org/dcmjs 1.0.0-beta.18 → 1.0.0-beta.20

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.js CHANGED
@@ -7914,61 +7914,69 @@
7914
7914
  return view.getBigUint64(offset - viewOffset, isLittleEndian);
7915
7915
  }
7916
7916
  }, {
7917
- key: "getFloat32",
7918
- value: function getFloat32(offset, isLittleEndian) {
7919
- var _this$findView5 = this.findView(offset, 4),
7917
+ key: "getBigInt64",
7918
+ value: function getBigInt64(offset, isLittleEndian) {
7919
+ var _this$findView5 = this.findView(offset, 8),
7920
7920
  view = _this$findView5.view,
7921
7921
  viewOffset = _this$findView5.viewOffset;
7922
+ return view.getBigInt64(offset - viewOffset, isLittleEndian);
7923
+ }
7924
+ }, {
7925
+ key: "getFloat32",
7926
+ value: function getFloat32(offset, isLittleEndian) {
7927
+ var _this$findView6 = this.findView(offset, 4),
7928
+ view = _this$findView6.view,
7929
+ viewOffset = _this$findView6.viewOffset;
7922
7930
  return view.getFloat32(offset - viewOffset, isLittleEndian);
7923
7931
  }
7924
7932
  }, {
7925
7933
  key: "getFloat64",
7926
7934
  value: function getFloat64(offset, isLittleEndian) {
7927
- var _this$findView6 = this.findView(offset, 8),
7928
- view = _this$findView6.view,
7929
- viewOffset = _this$findView6.viewOffset;
7935
+ var _this$findView7 = this.findView(offset, 8),
7936
+ view = _this$findView7.view,
7937
+ viewOffset = _this$findView7.viewOffset;
7930
7938
  return view.getFloat64(offset - viewOffset, isLittleEndian);
7931
7939
  }
7932
7940
  }, {
7933
7941
  key: "getInt8",
7934
7942
  value: function getInt8(offset) {
7935
- var _this$findView7 = this.findView(offset, 1),
7936
- view = _this$findView7.view,
7937
- viewOffset = _this$findView7.viewOffset;
7943
+ var _this$findView8 = this.findView(offset, 1),
7944
+ view = _this$findView8.view,
7945
+ viewOffset = _this$findView8.viewOffset;
7938
7946
  return view.getInt8(offset - viewOffset);
7939
7947
  }
7940
7948
  }, {
7941
7949
  key: "getInt16",
7942
7950
  value: function getInt16(offset, isLittleEndian) {
7943
- var _this$findView8 = this.findView(offset, 2),
7944
- view = _this$findView8.view,
7945
- viewOffset = _this$findView8.viewOffset;
7951
+ var _this$findView9 = this.findView(offset, 2),
7952
+ view = _this$findView9.view,
7953
+ viewOffset = _this$findView9.viewOffset;
7946
7954
  return view.getInt16(offset - viewOffset, isLittleEndian);
7947
7955
  }
7948
7956
  }, {
7949
7957
  key: "getInt32",
7950
7958
  value: function getInt32(offset, isLittleEndian) {
7951
- var _this$findView9 = this.findView(offset, 4),
7952
- view = _this$findView9.view,
7953
- viewOffset = _this$findView9.viewOffset;
7959
+ var _this$findView0 = this.findView(offset, 4),
7960
+ view = _this$findView0.view,
7961
+ viewOffset = _this$findView0.viewOffset;
7954
7962
  return view.getInt32(offset - viewOffset, isLittleEndian);
7955
7963
  }
7956
7964
  }, {
7957
7965
  key: "setUint8",
7958
7966
  value: function setUint8(offset, value) {
7959
- var _this$findView0 = this.findView(offset, 1),
7960
- view = _this$findView0.view,
7961
- viewOffset = _this$findView0.viewOffset;
7967
+ var _this$findView1 = this.findView(offset, 1),
7968
+ view = _this$findView1.view,
7969
+ viewOffset = _this$findView1.viewOffset;
7962
7970
  view.setUint8(offset - viewOffset, value);
7963
7971
  // Commit is unneeded since 1 byte will always be available
7964
7972
  }
7965
7973
  }, {
7966
7974
  key: "setUint16",
7967
7975
  value: function setUint16(offset, value, isLittleEndian) {
7968
- var _this$findView1 = this.findView(offset, 2),
7969
- view = _this$findView1.view,
7970
- viewOffset = _this$findView1.viewOffset,
7971
- writeCommit = _this$findView1.writeCommit;
7976
+ var _this$findView10 = this.findView(offset, 2),
7977
+ view = _this$findView10.view,
7978
+ viewOffset = _this$findView10.viewOffset,
7979
+ writeCommit = _this$findView10.writeCommit;
7972
7980
  view.setUint16(offset - viewOffset, value, isLittleEndian);
7973
7981
  if (writeCommit) {
7974
7982
  this.writeCommit(view, offset);
@@ -7977,10 +7985,10 @@
7977
7985
  }, {
7978
7986
  key: "setUint32",
7979
7987
  value: function setUint32(offset, value, isLittleEndian) {
7980
- var _this$findView10 = this.findView(offset, 4),
7981
- view = _this$findView10.view,
7982
- viewOffset = _this$findView10.viewOffset,
7983
- writeCommit = _this$findView10.writeCommit;
7988
+ var _this$findView11 = this.findView(offset, 4),
7989
+ view = _this$findView11.view,
7990
+ viewOffset = _this$findView11.viewOffset,
7991
+ writeCommit = _this$findView11.writeCommit;
7984
7992
  view.setUint32(offset - viewOffset, value, isLittleEndian);
7985
7993
  if (writeCommit) {
7986
7994
  this.writeCommit(view, offset);
@@ -7989,22 +7997,34 @@
7989
7997
  }, {
7990
7998
  key: "setBigUint64",
7991
7999
  value: function setBigUint64(offset, value, isLittleEndian) {
7992
- var _this$findView11 = this.findView(offset, 8),
7993
- view = _this$findView11.view,
7994
- viewOffset = _this$findView11.viewOffset,
7995
- writeCommit = _this$findView11.writeCommit;
8000
+ var _this$findView12 = this.findView(offset, 8),
8001
+ view = _this$findView12.view,
8002
+ viewOffset = _this$findView12.viewOffset,
8003
+ writeCommit = _this$findView12.writeCommit;
7996
8004
  view.setBigUint64(offset - viewOffset, value, isLittleEndian);
7997
8005
  if (writeCommit) {
7998
8006
  this.writeCommit(view, offset);
7999
8007
  }
8000
8008
  }
8009
+ }, {
8010
+ key: "setBigInt64",
8011
+ value: function setBigInt64(offset, value, isLittleEndian) {
8012
+ var _this$findView13 = this.findView(offset, 8),
8013
+ view = _this$findView13.view,
8014
+ viewOffset = _this$findView13.viewOffset,
8015
+ writeCommit = _this$findView13.writeCommit;
8016
+ view.setBigInt64(offset - viewOffset, value, isLittleEndian);
8017
+ if (writeCommit) {
8018
+ this.writeCommit(view, offset);
8019
+ }
8020
+ }
8001
8021
  }, {
8002
8022
  key: "setFloat32",
8003
8023
  value: function setFloat32(offset, value, isLittleEndian) {
8004
- var _this$findView12 = this.findView(offset, 4),
8005
- view = _this$findView12.view,
8006
- viewOffset = _this$findView12.viewOffset,
8007
- writeCommit = _this$findView12.writeCommit;
8024
+ var _this$findView14 = this.findView(offset, 4),
8025
+ view = _this$findView14.view,
8026
+ viewOffset = _this$findView14.viewOffset,
8027
+ writeCommit = _this$findView14.writeCommit;
8008
8028
  view.setFloat32(offset - viewOffset, value, isLittleEndian);
8009
8029
  if (writeCommit) {
8010
8030
  this.writeCommit(view, offset);
@@ -8013,10 +8033,10 @@
8013
8033
  }, {
8014
8034
  key: "setFloat64",
8015
8035
  value: function setFloat64(offset, value, isLittleEndian) {
8016
- var _this$findView13 = this.findView(offset, 8),
8017
- view = _this$findView13.view,
8018
- viewOffset = _this$findView13.viewOffset,
8019
- writeCommit = _this$findView13.writeCommit;
8036
+ var _this$findView15 = this.findView(offset, 8),
8037
+ view = _this$findView15.view,
8038
+ viewOffset = _this$findView15.viewOffset,
8039
+ writeCommit = _this$findView15.writeCommit;
8020
8040
  view.setFloat64(offset - viewOffset, value, isLittleEndian);
8021
8041
  if (writeCommit) {
8022
8042
  this.writeCommit(view, offset);
@@ -8025,19 +8045,19 @@
8025
8045
  }, {
8026
8046
  key: "setInt8",
8027
8047
  value: function setInt8(offset, value) {
8028
- var _this$findView14 = this.findView(offset, 1),
8029
- view = _this$findView14.view,
8030
- viewOffset = _this$findView14.viewOffset;
8048
+ var _this$findView16 = this.findView(offset, 1),
8049
+ view = _this$findView16.view,
8050
+ viewOffset = _this$findView16.viewOffset;
8031
8051
  view.setInt8(offset - viewOffset, value);
8032
8052
  // Commit is unneeded since 1 byte will always be available
8033
8053
  }
8034
8054
  }, {
8035
8055
  key: "setInt16",
8036
8056
  value: function setInt16(offset, value, isLittleEndian) {
8037
- var _this$findView15 = this.findView(offset, 2),
8038
- view = _this$findView15.view,
8039
- viewOffset = _this$findView15.viewOffset,
8040
- writeCommit = _this$findView15.writeCommit;
8057
+ var _this$findView17 = this.findView(offset, 2),
8058
+ view = _this$findView17.view,
8059
+ viewOffset = _this$findView17.viewOffset,
8060
+ writeCommit = _this$findView17.writeCommit;
8041
8061
  view.setInt16(offset - viewOffset, value, isLittleEndian);
8042
8062
  if (writeCommit) {
8043
8063
  this.writeCommit(view, offset);
@@ -8046,10 +8066,10 @@
8046
8066
  }, {
8047
8067
  key: "setInt32",
8048
8068
  value: function setInt32(offset, value, isLittleEndian) {
8049
- var _this$findView16 = this.findView(offset, 4),
8050
- view = _this$findView16.view,
8051
- viewOffset = _this$findView16.viewOffset,
8052
- writeCommit = _this$findView16.writeCommit;
8069
+ var _this$findView18 = this.findView(offset, 4),
8070
+ view = _this$findView18.view,
8071
+ viewOffset = _this$findView18.viewOffset,
8072
+ writeCommit = _this$findView18.writeCommit;
8053
8073
  view.setInt32(offset - viewOffset, value, isLittleEndian);
8054
8074
  if (writeCommit) {
8055
8075
  this.writeCommit(view, offset);
@@ -8547,7 +8567,7 @@
8547
8567
  }
8548
8568
  var validationLog = log.getLogger("validation.dcmjs");
8549
8569
 
8550
- var _excluded = ["littleEndian", "start", "stop", "noCopy", "clearBuffers"];
8570
+ var _excluded = ["littleEndian", "start", "stop", "noCopy", "clearBuffers", "decoder"];
8551
8571
  var legacyWarned = new Set();
8552
8572
 
8553
8573
  /** Warns once per class that a positional (0.x) constructor form was used. */
@@ -8768,6 +8788,13 @@
8768
8788
  this.view.setBigUint64(this.offset, value, this.isLittleEndian);
8769
8789
  return this.increment(8);
8770
8790
  }
8791
+ }, {
8792
+ key: "writeBigInt64",
8793
+ value: function writeBigInt64(value) {
8794
+ this.checkSize(8);
8795
+ this.view.setBigInt64(this.offset, value, this.isLittleEndian);
8796
+ return this.increment(8);
8797
+ }
8771
8798
  }, {
8772
8799
  key: "writeFloat",
8773
8800
  value: function writeFloat(value) {
@@ -8828,6 +8855,13 @@
8828
8855
  this.increment(8);
8829
8856
  return val;
8830
8857
  }
8858
+ }, {
8859
+ key: "readBigInt64",
8860
+ value: function readBigInt64() {
8861
+ var val = this.view.getBigInt64(this.offset, this.isLittleEndian);
8862
+ this.increment(8);
8863
+ return val;
8864
+ }
8831
8865
  }, {
8832
8866
  key: "readUint32",
8833
8867
  value: function readUint32() {
@@ -9132,6 +9166,12 @@
9132
9166
  var end = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : start + 1;
9133
9167
  return this.view.hasData(start, end);
9134
9168
  }
9169
+
9170
+ /**
9171
+ * Returns a read stream over the next `length` bytes and moves past them.
9172
+ * The new stream decodes text with this stream's decoder, so sequence items
9173
+ * use the dataset's SpecificCharacterSet (PS3.5 7.5.3).
9174
+ */
9135
9175
  }, {
9136
9176
  key: "more",
9137
9177
  value: function more(length) {
@@ -9145,7 +9185,9 @@
9145
9185
  // start: this.offset,
9146
9186
  // stop: this.offset + length
9147
9187
  // });
9148
- var newBuf = new ReadBufferStream(this.slice(this.offset, this.offset + length));
9188
+ var newBuf = new ReadBufferStream(this.slice(this.offset, this.offset + length), {
9189
+ decoder: this.decoder
9190
+ });
9149
9191
  this.increment(length);
9150
9192
  newBuf.setComplete();
9151
9193
  return newBuf;
@@ -9200,7 +9242,8 @@
9200
9242
  var ReadBufferStream = /*#__PURE__*/function (_BufferStream2) {
9201
9243
  /**
9202
9244
  * @param {ArrayBuffer|ArrayBufferView|BufferStream|null} buffer
9203
- * @param {{littleEndian?: boolean, start?: number, stop?: number, noCopy?: boolean, clearBuffers?: boolean}} [options]
9245
+ * @param {{littleEndian?: boolean, start?: number, stop?: number, noCopy?: boolean, clearBuffers?: boolean, decoder?: TextDecoder}} [options]
9246
+ * `decoder` decodes text; the default is latin1.
9204
9247
  */
9205
9248
  function ReadBufferStream(buffer, options, legacyOptions) {
9206
9249
  var _this3;
@@ -9222,13 +9265,15 @@
9222
9265
  noCopy = _options$noCopy === void 0 ? false : _options$noCopy,
9223
9266
  _options$clearBuffers = _options.clearBuffers,
9224
9267
  clearBuffers = _options$clearBuffers === void 0 ? false : _options$clearBuffers,
9268
+ decoder = _options.decoder,
9225
9269
  rest = _objectWithoutProperties(_options, _excluded);
9226
9270
  _this3 = _callSuper(this, ReadBufferStream, [_objectSpread2(_objectSpread2({}, rest), {}, {
9227
9271
  littleEndian: littleEndian,
9228
9272
  clearBuffers: clearBuffers
9229
9273
  })]);
9230
9274
  _this3.noCopy = noCopy;
9231
- _this3.decoder = new TextDecoder("latin1");
9275
+ // a stream over part of a dataset gets the dataset's decoder
9276
+ _this3.decoder = decoder !== null && decoder !== void 0 ? decoder : new TextDecoder("latin1");
9232
9277
  if (buffer instanceof BufferStream) {
9233
9278
  _this3.view.from(buffer.view, options);
9234
9279
  _this3.isComplete = true;
@@ -9389,7 +9434,6 @@
9389
9434
  /**
9390
9435
  * The classification of each VR, stored once. ValueRepresentation copies
9391
9436
  * the flags to each instance; singleVRs and BINARY_VRS are computed here.
9392
- * OL/OV have flags but no VR class in 1.0.
9393
9437
  * @typedef {Object} VrFlags
9394
9438
  * @property {boolean} [binary] binary number or tag: isBinary()
9395
9439
  * @property {boolean} [length32] 32-bit explicit VR length: isLength32()
@@ -9405,12 +9449,13 @@
9405
9449
  OB: "length32 single readSingle byteStream",
9406
9450
  OD: "length32 byteStream",
9407
9451
  OF: "length32 single readSingle byteStream",
9408
- OL: "byteStream",
9409
- OV: "byteStream",
9452
+ OL: "length32 single byteStream",
9453
+ OV: "length32 single byteStream",
9410
9454
  OW: "length32 single readSingle byteStream",
9411
9455
  SL: "binary",
9412
9456
  SQ: "length32 single readSingle",
9413
9457
  SS: "binary",
9458
+ SV: "binary length32",
9414
9459
  UC: "length32",
9415
9460
  UL: "binary",
9416
9461
  UN: "length32 single readSingle byteStream",
@@ -10234,7 +10279,7 @@
10234
10279
  vr = Vrs.US;
10235
10280
  } else {
10236
10281
  // Warn at most once per unknown type (issue #457): files can
10237
- // carry many elements of the same unregistered VR (OL/OV/SV),
10282
+ // carry many elements of the same unregistered VR,
10238
10283
  // and a per-element warning is pure log spam.
10239
10284
  if (!unknownVrTypesWarned.has(type)) {
10240
10285
  unknownVrTypesWarned.add(type);
@@ -11362,11 +11407,19 @@
11362
11407
  }
11363
11408
  }]);
11364
11409
  }(ValueRepresentation$1);
11410
+ /**
11411
+ * UV, Unsigned 64-bit Very Long, and the base of SV (PS3.5 Section 6.2,
11412
+ * Table 6.2-1,
11413
+ * https://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_6.2.html).
11414
+ */
11365
11415
  var Unsigned64BitVeryLong = /*#__PURE__*/function (_ValueRepresentation10) {
11366
11416
  function Unsigned64BitVeryLong() {
11367
11417
  var _this26;
11418
+ var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "UV";
11419
+ var accessor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "BigUint64";
11368
11420
  _classCallCheck(this, Unsigned64BitVeryLong);
11369
- _this26 = _callSuper(this, Unsigned64BitVeryLong, ["UV"]);
11421
+ _this26 = _callSuper(this, Unsigned64BitVeryLong, [type]);
11422
+ _this26.accessor = accessor;
11370
11423
  _this26.maxLength = 8;
11371
11424
  _this26.padByte = PADDING_NULL;
11372
11425
  _this26.fixed = true;
@@ -11377,13 +11430,13 @@
11377
11430
  return _createClass(Unsigned64BitVeryLong, [{
11378
11431
  key: "readBytes",
11379
11432
  value: function readBytes(stream) {
11380
- return stream.readBigUint64();
11433
+ return stream["read".concat(this.accessor)]();
11381
11434
  }
11382
11435
 
11383
11436
  /**
11384
- * DataView.setBigUint64 only accepts BigInt values, so this method
11385
- * coerces Numbers and numeric strings, as the other numeric VRs do with
11386
- * toInt/toFloat. A null or undefined entry becomes 0, as US/UL write null
11437
+ * DataView.setBigUint64 and setBigInt64 only accept BigInt values, so
11438
+ * this method coerces Numbers and numeric strings, as the other numeric
11439
+ * VRs do with toInt/toFloat. A null or undefined entry becomes 0, as US/UL write null
11387
11440
  * entries. A null, undefined or empty scalar stays as it is, so the base
11388
11441
  * write() writes a zero-length element (PS3.5 7.4, Type 2).
11389
11442
  */
@@ -11401,10 +11454,23 @@
11401
11454
  } else if (value !== null && value !== undefined && value !== "") {
11402
11455
  coercedValue = coerce(value);
11403
11456
  }
11404
- return _get(_getPrototypeOf(Unsigned64BitVeryLong.prototype), "writeBytes", this).call(this, stream, coercedValue, _get(_getPrototypeOf(Unsigned64BitVeryLong.prototype), "write", this).call(this, stream, "BigUint64", coercedValue), writeOptions);
11457
+ return _get(_getPrototypeOf(Unsigned64BitVeryLong.prototype), "writeBytes", this).call(this, stream, coercedValue, _get(_getPrototypeOf(Unsigned64BitVeryLong.prototype), "write", this).call(this, stream, this.accessor, coercedValue), writeOptions);
11405
11458
  }
11406
11459
  }]);
11407
11460
  }(ValueRepresentation$1);
11461
+ /**
11462
+ * SV, Signed 64-bit Very Long (PS3.5 Section 6.2, Table 6.2-1,
11463
+ * https://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_6.2.html).
11464
+ * Reads give BigInt values; writes take a BigInt, a Number or a numeric string.
11465
+ */
11466
+ var Signed64BitVeryLong = /*#__PURE__*/function (_Unsigned64BitVeryLon) {
11467
+ function Signed64BitVeryLong() {
11468
+ _classCallCheck(this, Signed64BitVeryLong);
11469
+ return _callSuper(this, Signed64BitVeryLong, ["SV", "BigInt64"]);
11470
+ }
11471
+ _inherits(Signed64BitVeryLong, _Unsigned64BitVeryLon);
11472
+ return _createClass(Signed64BitVeryLong);
11473
+ }(Unsigned64BitVeryLong);
11408
11474
  var UniqueIdentifier = /*#__PURE__*/function (_AsciiStringRepresent8) {
11409
11475
  function UniqueIdentifier() {
11410
11476
  var _this27;
@@ -11497,7 +11563,9 @@
11497
11563
  key: "read",
11498
11564
  value: function read(stream, length, syntax, readOptions) {
11499
11565
  var arrayBuffer = this.readBytes(stream, length, syntax)[0];
11500
- var streamFromBuffer = new ReadBufferStream(arrayBuffer);
11566
+ var streamFromBuffer = new ReadBufferStream(arrayBuffer, {
11567
+ decoder: stream.decoder
11568
+ });
11501
11569
  var vr = ValueRepresentation$1.createByTypeString(this.type);
11502
11570
  if (vr.isBinary() && length > vr.maxLength && !vr.noMultiple) {
11503
11571
  var values = [];
@@ -11572,6 +11640,38 @@
11572
11640
  }
11573
11641
  _inherits(OtherFloatString, _BinaryRepresentation6);
11574
11642
  return _createClass(OtherFloatString);
11643
+ }(BinaryRepresentation); // A stream of 32 bit words, for example Long Triangle Point Index List
11644
+ // (0066,0041), where the 16 bit OW form caps a surface at 65535 points.
11645
+ var OtherLongString = /*#__PURE__*/function (_BinaryRepresentation7) {
11646
+ function OtherLongString() {
11647
+ var _this35;
11648
+ _classCallCheck(this, OtherLongString);
11649
+ _this35 = _callSuper(this, OtherLongString, ["OL"]);
11650
+ _this35.maxLength = null;
11651
+ _this35.padByte = PADDING_NULL;
11652
+ _this35.noMultiple = true;
11653
+ return _this35;
11654
+ }
11655
+ _inherits(OtherLongString, _BinaryRepresentation7);
11656
+ return _createClass(OtherLongString);
11657
+ }(BinaryRepresentation);
11658
+ /**
11659
+ * OV, Other 64-bit Very Long: a stream of 64 bit words, read and written as
11660
+ * raw bytes (PS3.5 Section 6.2, Table 6.2-1,
11661
+ * https://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_6.2.html).
11662
+ */
11663
+ var OtherVeryLongString = /*#__PURE__*/function (_BinaryRepresentation8) {
11664
+ function OtherVeryLongString() {
11665
+ var _this36;
11666
+ _classCallCheck(this, OtherVeryLongString);
11667
+ _this36 = _callSuper(this, OtherVeryLongString, ["OV"]);
11668
+ _this36.maxLength = null;
11669
+ _this36.padByte = PADDING_NULL;
11670
+ _this36.noMultiple = true;
11671
+ return _this36;
11672
+ }
11673
+ _inherits(OtherVeryLongString, _BinaryRepresentation8);
11674
+ return _createClass(OtherVeryLongString);
11575
11675
  }(BinaryRepresentation);
11576
11676
  /**
11577
11677
  * The shared VR instances by code (`Vrs.DS`); `registerVr` extends it.
@@ -11594,12 +11694,15 @@
11594
11694
  OB: new OtherByteString(),
11595
11695
  OD: new OtherDoubleString(),
11596
11696
  OF: new OtherFloatString(),
11697
+ OL: new OtherLongString(),
11698
+ OV: new OtherVeryLongString(),
11597
11699
  OW: new OtherWordString(),
11598
11700
  PN: new PersonName(),
11599
11701
  SH: new ShortString(),
11600
11702
  SL: new SignedLong(),
11601
11703
  SQ: new SequenceOfItems(),
11602
11704
  SS: new SignedShort(),
11705
+ SV: new Signed64BitVeryLong(),
11603
11706
  ST: new ShortText(),
11604
11707
  TM: new TimeValue(),
11605
11708
  UC: new UnlimitedCharacters(),
@@ -11685,6 +11788,107 @@
11685
11788
  return EXPLICIT_LITTLE_ENDIAN;
11686
11789
  }
11687
11790
 
11791
+ var BINARY_AS = new Set(["ArrayBuffer", "Uint8Array"]);
11792
+ var isSharedBuffer = function isSharedBuffer(v) {
11793
+ return typeof SharedArrayBuffer !== "undefined" && v instanceof SharedArrayBuffer;
11794
+ };
11795
+
11796
+ /**
11797
+ * True when a binary value holds no bytes: no fragment, or only fragments of
11798
+ * zero length (a Part 10 reader gives one empty fragment for an empty
11799
+ * element). Such a value naturalizes to null (NAT-U-BIN-1).
11800
+ */
11801
+ function isEmptyBinary(fragments) {
11802
+ return fragments.every(function (f) {
11803
+ return isBinaryData(f) && f.byteLength === 0;
11804
+ });
11805
+ }
11806
+
11807
+ /** True for bytes: an ArrayBuffer, a SharedArrayBuffer, or a view. */
11808
+ function isBinaryData(v) {
11809
+ return v instanceof ArrayBuffer || ArrayBuffer.isView(v) || isSharedBuffer(v);
11810
+ }
11811
+
11812
+ /**
11813
+ * Checks the `binaryAs` naturalize option and gives its value.
11814
+ *
11815
+ * @param {string} [binaryAs="ArrayBuffer"]
11816
+ * @returns {"ArrayBuffer"|"Uint8Array"}
11817
+ */
11818
+ function checkBinaryAs() {
11819
+ var binaryAs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "ArrayBuffer";
11820
+ if (!BINARY_AS.has(binaryAs)) {
11821
+ throw new TypeError("binaryAs must be \"ArrayBuffer\" or \"Uint8Array\", not \"".concat(binaryAs, "\""));
11822
+ }
11823
+ return binaryAs;
11824
+ }
11825
+
11826
+ /**
11827
+ * One fragment or frame of a binary value in the naturalized form
11828
+ * (NAT-U-BIN in docs/specs/naturalized-dataset.md).
11829
+ *
11830
+ * - "ArrayBuffer" (the default): an ArrayBuffer. A view that covers its whole
11831
+ * buffer gives that buffer; any other view is copied to its own buffer.
11832
+ * - "Uint8Array": a Uint8Array over the same bytes, never a copy.
11833
+ *
11834
+ * Anything that is not an ArrayBuffer or a view, for example a
11835
+ * `{ BulkDataURI }` reference, is returned unchanged.
11836
+ */
11837
+ function naturalBinaryFragment(fragment) {
11838
+ var binaryAs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "ArrayBuffer";
11839
+ if (fragment instanceof ArrayBuffer) {
11840
+ return binaryAs === "Uint8Array" ? new Uint8Array(fragment) : fragment;
11841
+ }
11842
+ if (isSharedBuffer(fragment)) {
11843
+ // a shared buffer is not an ArrayBuffer: the default mode copies it
11844
+ var view = new Uint8Array(fragment);
11845
+ return binaryAs === "Uint8Array" ? view : view.slice().buffer;
11846
+ }
11847
+ if (!ArrayBuffer.isView(fragment)) {
11848
+ return fragment;
11849
+ }
11850
+ var buffer = fragment.buffer,
11851
+ byteOffset = fragment.byteOffset,
11852
+ byteLength = fragment.byteLength;
11853
+ if (binaryAs === "Uint8Array") {
11854
+ return new Uint8Array(buffer, byteOffset, byteLength);
11855
+ }
11856
+ if (!(buffer instanceof ArrayBuffer)) {
11857
+ // a view over a shared buffer
11858
+ return new Uint8Array(buffer, byteOffset, byteLength).slice().buffer;
11859
+ }
11860
+ return byteOffset === 0 && byteLength === buffer.byteLength ? buffer : buffer.slice(byteOffset, byteOffset + byteLength);
11861
+ }
11862
+
11863
+ /**
11864
+ * PS3.5 §6.2.2: true when an explicit-VR UN value holds a sequence, encoded
11865
+ * as Implicit VR Little Endian. The rule applies only when the dictionary VR
11866
+ * `vr` is SQ, or is UN because the tag has no dictionary entry. The value
11867
+ * must start with the item tag (FFFE,E000), and the first item length must
11868
+ * be undefined or fit in the value. Any other value stays UN bytes.
11869
+ *
11870
+ * @param {DataView|SplitDataView} view - the bytes, with absolute offsets
11871
+ * @param {number} offset - the start of the value
11872
+ * @param {number} length - the value length
11873
+ * @param {string} vr - the VR after the dictionary lookup
11874
+ */
11875
+ function isUnSequenceValue(view, offset, length, vr) {
11876
+ if (vr !== "UN" && vr !== "SQ") return false;
11877
+ if (length === UNDEFINED_LENGTH || length < 8) return false;
11878
+ if (offset + 8 > view.byteLength) return false;
11879
+ var tag = (view.getUint16(offset, true) << 16 | view.getUint16(offset + 2, true)) >>> 0;
11880
+ if (tag !== SEQUENCE_ITEM_TAG) return false;
11881
+ var itemLength = view.getUint32(offset + 4, true);
11882
+ return itemLength === UNDEFINED_LENGTH || itemLength <= length - 8;
11883
+ }
11884
+
11885
+ /** True for an item dataset: an object whose keys are all tags ("00100010"). */
11886
+ function isItemDictLike(v) {
11887
+ return v && _typeof(v) === "object" && !isBinaryData(v) && Object.keys(v).every(function (k) {
11888
+ return /^[0-9A-Fx]{8,9}$/i.test(k);
11889
+ });
11890
+ }
11891
+
11688
11892
  function paddingLeft(paddingValue, string) {
11689
11893
  return String(paddingValue + string).slice(-paddingValue.length);
11690
11894
  }
@@ -11763,6 +11967,10 @@
11763
11967
  }, {
11764
11968
  key: "write",
11765
11969
  value: function write(stream, vrType, values, syntax, writeOptions) {
11970
+ // A UN whose values are item datasets is a sequence (PS3.5 §6.2.2).
11971
+ if (vrType === "UN" && Array.isArray(values) && values.length > 0 && values.every(isItemDictLike)) {
11972
+ vrType = "SQ";
11973
+ }
11766
11974
  var vr = ValueRepresentation$1.createByTypeString(vrType);
11767
11975
  var useSyntax = normalizeSyntax(syntax);
11768
11976
  // No value (NAT-U-RT-7): absent, null, "" or only undefined entries is
@@ -12690,78 +12898,6 @@
12690
12898
  return entry !== null && entry !== void 0 && entry.vm && !isMultiVM(entry.vm) ? 1 : undefined;
12691
12899
  }
12692
12900
 
12693
- var BINARY_AS = new Set(["ArrayBuffer", "Uint8Array"]);
12694
- var isSharedBuffer = function isSharedBuffer(v) {
12695
- return typeof SharedArrayBuffer !== "undefined" && v instanceof SharedArrayBuffer;
12696
- };
12697
-
12698
- /**
12699
- * True when a binary value holds no bytes: no fragment, or only fragments of
12700
- * zero length (a Part 10 reader gives one empty fragment for an empty
12701
- * element). Such a value naturalizes to null (NAT-U-BIN-1).
12702
- */
12703
- function isEmptyBinary(fragments) {
12704
- return fragments.every(function (f) {
12705
- return isBinaryData(f) && f.byteLength === 0;
12706
- });
12707
- }
12708
-
12709
- /** True for bytes: an ArrayBuffer, a SharedArrayBuffer, or a view. */
12710
- function isBinaryData(v) {
12711
- return v instanceof ArrayBuffer || ArrayBuffer.isView(v) || isSharedBuffer(v);
12712
- }
12713
-
12714
- /**
12715
- * Checks the `binaryAs` naturalize option and gives its value.
12716
- *
12717
- * @param {string} [binaryAs="ArrayBuffer"]
12718
- * @returns {"ArrayBuffer"|"Uint8Array"}
12719
- */
12720
- function checkBinaryAs() {
12721
- var binaryAs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "ArrayBuffer";
12722
- if (!BINARY_AS.has(binaryAs)) {
12723
- throw new TypeError("binaryAs must be \"ArrayBuffer\" or \"Uint8Array\", not \"".concat(binaryAs, "\""));
12724
- }
12725
- return binaryAs;
12726
- }
12727
-
12728
- /**
12729
- * One fragment or frame of a binary value in the naturalized form
12730
- * (NAT-U-BIN in docs/specs/naturalized-dataset.md).
12731
- *
12732
- * - "ArrayBuffer" (the default): an ArrayBuffer. A view that covers its whole
12733
- * buffer gives that buffer; any other view is copied to its own buffer.
12734
- * - "Uint8Array": a Uint8Array over the same bytes, never a copy.
12735
- *
12736
- * Anything that is not an ArrayBuffer or a view, for example a
12737
- * `{ BulkDataURI }` reference, is returned unchanged.
12738
- */
12739
- function naturalBinaryFragment(fragment) {
12740
- var binaryAs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "ArrayBuffer";
12741
- if (fragment instanceof ArrayBuffer) {
12742
- return binaryAs === "Uint8Array" ? new Uint8Array(fragment) : fragment;
12743
- }
12744
- if (isSharedBuffer(fragment)) {
12745
- // a shared buffer is not an ArrayBuffer: the default mode copies it
12746
- var view = new Uint8Array(fragment);
12747
- return binaryAs === "Uint8Array" ? view : view.slice().buffer;
12748
- }
12749
- if (!ArrayBuffer.isView(fragment)) {
12750
- return fragment;
12751
- }
12752
- var buffer = fragment.buffer,
12753
- byteOffset = fragment.byteOffset,
12754
- byteLength = fragment.byteLength;
12755
- if (binaryAs === "Uint8Array") {
12756
- return new Uint8Array(buffer, byteOffset, byteLength);
12757
- }
12758
- if (!(buffer instanceof ArrayBuffer)) {
12759
- // a view over a shared buffer
12760
- return new Uint8Array(buffer, byteOffset, byteLength).slice().buffer;
12761
- }
12762
- return byteOffset === 0 && byteLength === buffer.byteLength ? buffer : buffer.slice(byteOffset, byteOffset + byteLength);
12763
- }
12764
-
12765
12901
  /**
12766
12902
  * Exposes a single-item sequence as its item object, which also behaves like
12767
12903
  * a one-element list. This is the 1.0 naturalized shape (no Proxy):
@@ -14070,7 +14206,12 @@
14070
14206
  return value;
14071
14207
  }
14072
14208
 
14073
- // keep the static function to support previous calls to the class
14209
+ /**
14210
+ * Converts a naturalized dataset to a DICOM JSON style dict. A DS
14211
+ * number is formatted to 16 characters or less (PS3.5 Table 6.2-1,
14212
+ * https://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_6.2.html).
14213
+ * Kept static to support previous calls to the class.
14214
+ */
14074
14215
  }, {
14075
14216
  key: "denaturalizeDataset",
14076
14217
  value: function denaturalizeDataset(dataset) {
@@ -14123,6 +14264,13 @@
14123
14264
  }
14124
14265
  }
14125
14266
  var _vr = ValueRepresentation$1.createByTypeString(dataItem.vr);
14267
+ if (dataItem.vr === "DS") {
14268
+ // Fit numbers to 16 characters; String(number) is cut below
14269
+ var formatDs = function formatDs(value) {
14270
+ return typeof value === "number" || value instanceof Number ? _vr.convertToString(Number(value)) : value;
14271
+ };
14272
+ dataItem.Value = Array.isArray(dataItem.Value) ? dataItem.Value.map(formatDs) : formatDs(dataItem.Value);
14273
+ }
14126
14274
  dataItem.Value = DicomMetaDictionary.denaturalizeValue(dataItem.Value);
14127
14275
  if (entry.vr == "SQ") {
14128
14276
  var unnaturalValues = [];
@@ -16147,7 +16295,8 @@
16147
16295
  }
16148
16296
  var length = null,
16149
16297
  vr = null,
16150
- vrType;
16298
+ vrType,
16299
+ wireVrType = null;
16151
16300
  if (implicit) {
16152
16301
  length = stream.readUint32();
16153
16302
  var elementData = DicomMessage.lookupTag(tag);
@@ -16175,6 +16324,7 @@
16175
16324
  vr = ValueRepresentation$1.createByTypeString(vrType);
16176
16325
  } else {
16177
16326
  vrType = stream.readVR();
16327
+ wireVrType = vrType;
16178
16328
  if (vrType === "UN" && DicomMessage.lookupTag(tag) && DicomMessage.lookupTag(tag).vr) {
16179
16329
  vrType = DicomMessage.lookupTag(tag).vr;
16180
16330
  if (vrType === "xs") {
@@ -16193,13 +16343,19 @@
16193
16343
  length = stream.readUint16();
16194
16344
  }
16195
16345
  }
16346
+ var readSyntax = syntax;
16347
+ if (!implicit && wireVrType === "UN" && isUnSequenceValue(stream.view, stream.offset, length, vr.type)) {
16348
+ vr = ValueRepresentation$1.createByTypeString("SQ");
16349
+ readSyntax = IMPLICIT_LITTLE_ENDIAN;
16350
+ stream.setEndian(true); // the items are LE in a BE body too
16351
+ }
16196
16352
  var values = [];
16197
16353
  var rawValues = [];
16198
16354
  if (vr.isBinary() && length > vr.maxLength && !vr.noMultiple) {
16199
16355
  var times = length / vr.maxLength,
16200
16356
  i = 0;
16201
16357
  while (i++ < times) {
16202
- var _vr$read = vr.read(stream, vr.maxLength, syntax, options),
16358
+ var _vr$read = vr.read(stream, vr.maxLength, readSyntax, options),
16203
16359
  rawValue = _vr$read.rawValue,
16204
16360
  value = _vr$read.value;
16205
16361
  rawValues.push(rawValue);
@@ -16210,7 +16366,7 @@
16210
16366
  var readOptions = vr.type === "SQ" ? _objectSpread2(_objectSpread2({}, options), {}, {
16211
16367
  readItem: readItem
16212
16368
  }) : options;
16213
- var _ref = vr.read(stream, length, syntax, readOptions) || {},
16369
+ var _ref = vr.read(stream, length, readSyntax, readOptions) || {},
16214
16370
  _rawValue = _ref.rawValue,
16215
16371
  _value = _ref.value;
16216
16372
  if (!vr.isBinary() && singleVRs.indexOf(vr.type) == -1) {
@@ -16670,6 +16826,8 @@
16670
16826
  _classCallCheck(this, AsyncDicomReader);
16671
16827
  _defineProperty(this, "syntax", EXPLICIT_LITTLE_ENDIAN);
16672
16828
  this.isLittleEndian = options === null || options === void 0 ? void 0 : options.isLittleEndian;
16829
+ // Number of sequence items being read, 0 at the top level
16830
+ this.sequenceDepth = 0;
16673
16831
  // Default maxFragmentSize is 128 MB (128 * 1024 * 1024 bytes)
16674
16832
  this.maxFragmentSize = (_options$maxFragmentS = options === null || options === void 0 ? void 0 : options.maxFragmentSize) !== null && _options$maxFragmentS !== void 0 ? _options$maxFragmentS : 128 * 1024 * 1024;
16675
16833
  this.stream = new ReadBufferStream(null, _objectSpread2(_objectSpread2({
@@ -17131,17 +17289,27 @@
17131
17289
  * item boundary and returns control here for the next item. Without that
17132
17290
  * offset, read() skips the later Item tags as instructions, and all items
17133
17291
  * of a defined-length sequence merge into the first item.
17292
+ *
17293
+ * untilTag and includeUntilTagValue apply to the top-level data set only,
17294
+ * so the items are read without them: an Icon Image Sequence item has its
17295
+ * own Pixel Data, which must not stop a read with untilTag 7FE00010.
17134
17296
  */
17135
17297
  }, {
17136
17298
  key: "readSequence",
17137
17299
  value: (function () {
17138
17300
  var _readSequence = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(listener, sqTagInfo, options) {
17139
- var length, stream, syntax, endOffset, tagInfo, tag, itemLength, itemUntilOffset, _t;
17301
+ var _ref, _sqTagInfo$sequenceRe;
17302
+ var itemOptions, length, stream, readSyntax, endOffset, tagInfo, tag, itemLength, itemUntilOffset, decoder, _t;
17140
17303
  return _regeneratorRuntime().wrap(function (_context6) {
17141
17304
  while (1) switch (_context6.prev = _context6.next) {
17142
17305
  case 0:
17306
+ itemOptions = _objectSpread2(_objectSpread2({}, options), {}, {
17307
+ untilTag: null,
17308
+ includeUntilTagValue: false
17309
+ });
17143
17310
  length = sqTagInfo.length;
17144
- stream = this.stream, syntax = this.syntax;
17311
+ stream = this.stream;
17312
+ readSyntax = (_ref = (_sqTagInfo$sequenceRe = sqTagInfo.sequenceReadSyntax) !== null && _sqTagInfo$sequenceRe !== void 0 ? _sqTagInfo$sequenceRe : options === null || options === void 0 ? void 0 : options.readSyntax) !== null && _ref !== void 0 ? _ref : this.syntax;
17145
17313
  endOffset = length === UNDEFINED_LENGTH_FIX ? Number.MAX_SAFE_INTEGER : stream.offset + length;
17146
17314
  case 1:
17147
17315
  _t = stream.offset < endOffset;
@@ -17155,50 +17323,78 @@
17155
17323
  _t = _context6.sent;
17156
17324
  case 3:
17157
17325
  if (!_t) {
17158
- _context6.next = 8;
17326
+ _context6.next = 10;
17159
17327
  break;
17160
17328
  }
17161
17329
  readLog.debug("readSequence loop", stream.offset, endOffset);
17162
- tagInfo = this.readTagHeader(syntax, options);
17330
+ tagInfo = this.readTagHeader(_objectSpread2(_objectSpread2({}, itemOptions), {}, {
17331
+ readSyntax: readSyntax
17332
+ }));
17163
17333
  tag = tagInfo.tag;
17164
17334
  if (!(tag === TagHex.Item)) {
17165
- _context6.next = 5;
17335
+ _context6.next = 7;
17166
17336
  break;
17167
17337
  }
17168
17338
  listener.startObject();
17169
17339
  // defined-length item: stop at its own end (see doc comment)
17170
17340
  itemLength = tagInfo.length;
17171
- itemUntilOffset = itemLength === UNDEFINED_LENGTH_FIX ? endOffset : Math.min(stream.offset + itemLength, endOffset);
17172
- _context6.next = 4;
17173
- return this.read(listener, _objectSpread2(_objectSpread2({}, options), {}, {
17174
- untilOffset: itemUntilOffset
17341
+ itemUntilOffset = itemLength === UNDEFINED_LENGTH_FIX ? endOffset : Math.min(stream.offset + itemLength, endOffset); // A SpecificCharacterSet in the item applies only to that
17342
+ // item (PS3.5 7.5.3), but the item is read on this stream:
17343
+ // put back the decoder the item started with.
17344
+ decoder = stream.decoder;
17345
+ this.sequenceDepth++;
17346
+ _context6.prev = 4;
17347
+ _context6.next = 5;
17348
+ return this.read(listener, _objectSpread2(_objectSpread2({}, itemOptions), {}, {
17349
+ untilOffset: itemUntilOffset,
17350
+ readSyntax: readSyntax
17175
17351
  }));
17176
- case 4:
17177
- _context6.next = 7;
17178
- break;
17179
17352
  case 5:
17353
+ _context6.prev = 5;
17354
+ this.sequenceDepth--;
17355
+ return _context6.finish(5);
17356
+ case 6:
17357
+ stream.setDecoder(decoder);
17358
+ _context6.next = 9;
17359
+ break;
17360
+ case 7:
17180
17361
  if (!(tag === TagHex.SequenceDelimitationEnd)) {
17181
- _context6.next = 6;
17362
+ _context6.next = 8;
17182
17363
  break;
17183
17364
  }
17184
17365
  return _context6.abrupt("return");
17185
- case 6:
17366
+ case 8:
17186
17367
  console.warn("Unknown tag info", length, tagInfo);
17187
- throw new Error();
17188
- case 7:
17368
+ throw new Error("Expected an item or a sequence delimitation item in a sequence, found tag ".concat(tag));
17369
+ case 9:
17189
17370
  _context6.next = 1;
17190
17371
  break;
17191
- case 8:
17372
+ case 10:
17192
17373
  case "end":
17193
17374
  return _context6.stop();
17194
17375
  }
17195
- }, _callee6, this);
17376
+ }, _callee6, this, [[4,, 5, 6]]);
17196
17377
  }));
17197
17378
  function readSequence(_x3, _x4, _x5) {
17198
17379
  return _readSequence.apply(this, arguments);
17199
17380
  }
17200
17381
  return readSequence;
17201
- }())
17382
+ }()
17383
+ /**
17384
+ * The number of frames of the Pixel Data being read. NumberOfFrames is
17385
+ * tracked for the top-level data set only, so Pixel Data inside a sequence
17386
+ * item (an Icon Image Sequence item, for example) is a single frame.
17387
+ */
17388
+ )
17389
+ }, {
17390
+ key: "getNumberOfFrames",
17391
+ value: function getNumberOfFrames() {
17392
+ var _this$listener;
17393
+ if (this.sequenceDepth > 0) {
17394
+ return 1;
17395
+ }
17396
+ return parseInt(((_this$listener = this.listener) === null || _this$listener === void 0 || (_this$listener = _this$listener.information) === null || _this$listener === void 0 ? void 0 : _this$listener.numberOfFrames) || 1);
17397
+ }
17202
17398
  }, {
17203
17399
  key: "readPixelData",
17204
17400
  value: function readPixelData(tagInfo) {
@@ -17268,8 +17464,7 @@
17268
17464
  key: "readCompressed",
17269
17465
  value: (function () {
17270
17466
  var _readCompressed = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(_tagInfo) {
17271
- var _listener$information;
17272
- var stream, listener, transferSyntaxUid, isVideo, numberOfFrames, isSingleFrame, offsets, singleArray, startOffset, frameNumber, lastFrame, frameTag, length;
17467
+ var stream, listener, transferSyntaxUid, isVideo, isSingleFrame, offsets, singleArray, startOffset, frameNumber, lastFrame, frameTag, length;
17273
17468
  return _regeneratorRuntime().wrap(function (_context8) {
17274
17469
  while (1) switch (_context8.prev = _context8.next) {
17275
17470
  case 0:
@@ -17280,8 +17475,7 @@
17280
17475
  case 1:
17281
17476
  // Check if this is a video transfer syntax
17282
17477
  isVideo = isVideoTransferSyntax(transferSyntaxUid); // Check number of frames - only use video logic for single frame (or undefined)
17283
- numberOfFrames = (_listener$information = listener.information) === null || _listener$information === void 0 ? void 0 : _listener$information.numberOfFrames;
17284
- isSingleFrame = !numberOfFrames || parseInt(numberOfFrames) <= 1;
17478
+ isSingleFrame = this.getNumberOfFrames() <= 1;
17285
17479
  _context8.next = 2;
17286
17480
  return this.readOffsets();
17287
17481
  case 2:
@@ -17395,23 +17589,22 @@
17395
17589
  key: "readUncompressed",
17396
17590
  value: (function () {
17397
17591
  var _readUncompressed = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee0(tagInfo) {
17398
- var _listener$information2;
17399
- var length, listener, numberOfFrames, frameLength, _listener$information3, _listener$information4, _listener$information5, _listener$information6, rows, cols, samplesPerPixel, bitsAllocated, bitsPerFrame, frameNumber;
17592
+ var length, listener, numberOfFrames, frameLength, _listener$information, _listener$information2, _listener$information3, _listener$information4, rows, cols, samplesPerPixel, bitsAllocated, bitsPerFrame, frameNumber;
17400
17593
  return _regeneratorRuntime().wrap(function (_context0) {
17401
17594
  while (1) switch (_context0.prev = _context0.next) {
17402
17595
  case 0:
17403
17596
  length = tagInfo.length;
17404
17597
  listener = this.listener;
17405
- numberOfFrames = parseInt(((_listener$information2 = listener.information) === null || _listener$information2 === void 0 ? void 0 : _listener$information2.numberOfFrames) || 1);
17598
+ numberOfFrames = this.getNumberOfFrames();
17406
17599
  frameLength = Math.floor(length / numberOfFrames);
17407
17600
  if (!(numberOfFrames > 1)) {
17408
17601
  _context0.next = 4;
17409
17602
  break;
17410
17603
  }
17411
- rows = (_listener$information3 = listener.information) === null || _listener$information3 === void 0 ? void 0 : _listener$information3.rows;
17412
- cols = (_listener$information4 = listener.information) === null || _listener$information4 === void 0 ? void 0 : _listener$information4.columns;
17413
- samplesPerPixel = (_listener$information5 = listener.information) === null || _listener$information5 === void 0 ? void 0 : _listener$information5.samplesPerPixel;
17414
- bitsAllocated = (_listener$information6 = listener.information) === null || _listener$information6 === void 0 ? void 0 : _listener$information6.bitsAllocated;
17604
+ rows = (_listener$information = listener.information) === null || _listener$information === void 0 ? void 0 : _listener$information.rows;
17605
+ cols = (_listener$information2 = listener.information) === null || _listener$information2 === void 0 ? void 0 : _listener$information2.columns;
17606
+ samplesPerPixel = (_listener$information3 = listener.information) === null || _listener$information3 === void 0 ? void 0 : _listener$information3.samplesPerPixel;
17607
+ bitsAllocated = (_listener$information4 = listener.information) === null || _listener$information4 === void 0 ? void 0 : _listener$information4.bitsAllocated;
17415
17608
  bitsPerFrame = rows * cols * samplesPerPixel * bitsAllocated;
17416
17609
  if (!(bitsPerFrame % 8 !== 0)) {
17417
17610
  _context0.next = 3;
@@ -17480,18 +17673,18 @@
17480
17673
  key: "readUncompressedBitFrame",
17481
17674
  value: (function () {
17482
17675
  var _readUncompressedBitFrame = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee1(tagInfo) {
17483
- var _listener$information7, _listener$information8, _listener$information9, _listener$information0, _listener$information1;
17676
+ var _listener$information5, _listener$information6, _listener$information7, _listener$information8;
17484
17677
  var length, listener, stream, numberOfFrames, rows, cols, samplesPerPixel, bitsAllocated, bitsPerFrame, bytesPerFrame, totalBits, totalBytes, allPixelData, frameNumber, bitOffset, frameBuffer, frameView, sourceView, bitIndex, globalBitIndex, sourceByteIndex, sourceBitIndex, targetByteIndex, targetBitIndex, sourceByte, bitValue;
17485
17678
  return _regeneratorRuntime().wrap(function (_context1) {
17486
17679
  while (1) switch (_context1.prev = _context1.next) {
17487
17680
  case 0:
17488
17681
  length = tagInfo.length;
17489
17682
  listener = this.listener, stream = this.stream;
17490
- numberOfFrames = parseInt(((_listener$information7 = listener.information) === null || _listener$information7 === void 0 ? void 0 : _listener$information7.numberOfFrames) || 1);
17491
- rows = (_listener$information8 = listener.information) === null || _listener$information8 === void 0 ? void 0 : _listener$information8.rows;
17492
- cols = (_listener$information9 = listener.information) === null || _listener$information9 === void 0 ? void 0 : _listener$information9.columns;
17493
- samplesPerPixel = ((_listener$information0 = listener.information) === null || _listener$information0 === void 0 ? void 0 : _listener$information0.samplesPerPixel) || 1;
17494
- bitsAllocated = (_listener$information1 = listener.information) === null || _listener$information1 === void 0 ? void 0 : _listener$information1.bitsAllocated;
17683
+ numberOfFrames = this.getNumberOfFrames();
17684
+ rows = (_listener$information5 = listener.information) === null || _listener$information5 === void 0 ? void 0 : _listener$information5.rows;
17685
+ cols = (_listener$information6 = listener.information) === null || _listener$information6 === void 0 ? void 0 : _listener$information6.columns;
17686
+ samplesPerPixel = ((_listener$information7 = listener.information) === null || _listener$information7 === void 0 ? void 0 : _listener$information7.samplesPerPixel) || 1;
17687
+ bitsAllocated = (_listener$information8 = listener.information) === null || _listener$information8 === void 0 ? void 0 : _listener$information8.bitsAllocated;
17495
17688
  if (!(!rows || !cols || !bitsAllocated)) {
17496
17689
  _context1.next = 1;
17497
17690
  break;
@@ -17599,14 +17792,15 @@
17599
17792
  }, {
17600
17793
  key: "readTagHeader",
17601
17794
  value: function readTagHeader() {
17795
+ var _options$readSyntax;
17602
17796
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
17603
17797
  untilTag: null,
17604
17798
  includeUntilTagValue: false
17605
17799
  };
17606
- var stream = this.stream,
17607
- syntax = this.syntax;
17800
+ var stream = this.stream;
17608
17801
  var untilTag = options.untilTag,
17609
17802
  includeUntilTagValue = options.includeUntilTagValue;
17803
+ var syntax = (_options$readSyntax = options.readSyntax) !== null && _options$readSyntax !== void 0 ? _options$readSyntax : this.syntax;
17610
17804
  var implicit = syntax == IMPLICIT_LITTLE_ENDIAN;
17611
17805
  var isLittleEndian = syntax !== EXPLICIT_BIG_ENDIAN;
17612
17806
  stream.setEndian(isLittleEndian);
@@ -17626,6 +17820,7 @@
17626
17820
  var length = null;
17627
17821
  var vr = null;
17628
17822
  var vrType;
17823
+ var wireVrType = null;
17629
17824
  var isCommand = tagObj.group() === 0;
17630
17825
  if (tagObj.isInstruction()) {
17631
17826
  length = stream.readUint32();
@@ -17636,13 +17831,13 @@
17636
17831
  if (elementData) {
17637
17832
  vrType = elementData.vr;
17638
17833
  if (vrType === "xs") {
17639
- var _this$listener;
17834
+ var _this$listener2;
17640
17835
  // The dictionary meta-VR "xs" ("US or SS") resolves via
17641
17836
  // PixelRepresentation (PS3.5), exactly like the sync
17642
17837
  // reader (DicomMessage._readTag). The listener's
17643
17838
  // information filter tracks (0028,0103), which precedes
17644
17839
  // every xs tag in tag order.
17645
- vrType = DicomMessage.resolveXsVrType((_this$listener = this.listener) === null || _this$listener === void 0 || (_this$listener = _this$listener.information) === null || _this$listener === void 0 ? void 0 : _this$listener.pixelRepresentation);
17840
+ vrType = DicomMessage.resolveXsVrType((_this$listener2 = this.listener) === null || _this$listener2 === void 0 || (_this$listener2 = _this$listener2.information) === null || _this$listener2 === void 0 ? void 0 : _this$listener2.pixelRepresentation);
17646
17841
  }
17647
17842
  } else {
17648
17843
  //unknown tag
@@ -17660,13 +17855,14 @@
17660
17855
  } else {
17661
17856
  var _DicomMessage$lookupT;
17662
17857
  vrType = stream.readVR();
17858
+ wireVrType = vrType;
17663
17859
  if (vrType === "UN" && (_DicomMessage$lookupT = DicomMessage.lookupTag(tagObj)) !== null && _DicomMessage$lookupT !== void 0 && _DicomMessage$lookupT.vr) {
17664
17860
  vrType = DicomMessage.lookupTag(tagObj).vr;
17665
17861
  if (vrType === "xs") {
17666
- var _this$listener2;
17862
+ var _this$listener3;
17667
17863
  // Same PixelRepresentation-driven US/SS resolution for
17668
17864
  // explicit-VR UN elements whose dictionary VR is "xs".
17669
- vrType = DicomMessage.resolveXsVrType((_this$listener2 = this.listener) === null || _this$listener2 === void 0 || (_this$listener2 = _this$listener2.information) === null || _this$listener2 === void 0 ? void 0 : _this$listener2.pixelRepresentation);
17865
+ vrType = DicomMessage.resolveXsVrType((_this$listener3 = this.listener) === null || _this$listener3 === void 0 || (_this$listener3 = _this$listener3.information) === null || _this$listener3 === void 0 ? void 0 : _this$listener3.pixelRepresentation);
17670
17866
  }
17671
17867
  vr = ValueRepresentation$1.parseUnknownVr(vrType);
17672
17868
  } else {
@@ -17679,11 +17875,16 @@
17679
17875
  length = stream.readUint16();
17680
17876
  }
17681
17877
  }
17878
+ var sequenceReadSyntax;
17879
+ if (!implicit && wireVrType === "UN" && isUnSequenceValue(stream.view, stream.offset, length, vr.type)) {
17880
+ vr = ValueRepresentation$1.createByTypeString("SQ");
17881
+ sequenceReadSyntax = IMPLICIT_LITTLE_ENDIAN;
17882
+ }
17682
17883
  var punctuatedTag = DicomMetaDictionary.punctuateTag(tag);
17683
17884
  var entry = DicomMetaDictionary.dictionary[punctuatedTag];
17684
17885
 
17685
17886
  // Include both the string and object values for vr and tag
17686
- var header = {
17887
+ var header = _objectSpread2({
17687
17888
  vrObj: vr,
17688
17889
  vr: vr.type,
17689
17890
  tag: tag,
@@ -17691,7 +17892,9 @@
17691
17892
  vm: entry === null || entry === void 0 ? void 0 : entry.vm,
17692
17893
  name: entry === null || entry === void 0 ? void 0 : entry.name,
17693
17894
  length: length === UNDEFINED_LENGTH ? -1 : length
17694
- };
17895
+ }, sequenceReadSyntax && {
17896
+ sequenceReadSyntax: sequenceReadSyntax
17897
+ });
17695
17898
  return header;
17696
17899
  }
17697
17900
 
@@ -17705,12 +17908,14 @@
17705
17908
  key: "readSingle",
17706
17909
  value: (function () {
17707
17910
  var _readSingle = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(tagInfo, listener, options) {
17911
+ var _options$readSyntax2;
17708
17912
  var length, stream, syntax, vr, values, times, i, _vr$read, value, _vr$read2, _value, delimiterChar, decoder, valuesForListener;
17709
17913
  return _regeneratorRuntime().wrap(function (_context11) {
17710
17914
  while (1) switch (_context11.prev = _context11.next) {
17711
17915
  case 0:
17712
17916
  length = tagInfo.length;
17713
- stream = this.stream, syntax = this.syntax;
17917
+ stream = this.stream;
17918
+ syntax = (_options$readSyntax2 = options === null || options === void 0 ? void 0 : options.readSyntax) !== null && _options$readSyntax2 !== void 0 ? _options$readSyntax2 : this.syntax;
17714
17919
  _context11.next = 1;
17715
17920
  return this.stream.ensureAvailable(length);
17716
17921
  case 1:
@@ -27822,6 +28027,11 @@
27822
28027
  MeasurementReport: MeasurementReport$1
27823
28028
  };
27824
28029
 
28030
+ /**
28031
+ * @deprecated The adapters moved to `@cornerstonejs/adapters`. Import them
28032
+ * from that package. `@dcmjs-org/dcmjs` keeps this export only for
28033
+ * compatibility with 0.x, and a later major release removes it.
28034
+ */
27825
28035
  var adapters = {
27826
28036
  Cornerstone: Cornerstone,
27827
28037
  Cornerstone3D: Cornerstone3D,