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

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) {
@@ -17136,12 +17292,14 @@
17136
17292
  key: "readSequence",
17137
17293
  value: (function () {
17138
17294
  var _readSequence = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(listener, sqTagInfo, options) {
17139
- var length, stream, syntax, endOffset, tagInfo, tag, itemLength, itemUntilOffset, _t;
17295
+ var _ref, _sqTagInfo$sequenceRe;
17296
+ var length, stream, readSyntax, endOffset, tagInfo, tag, itemLength, itemUntilOffset, decoder, _t;
17140
17297
  return _regeneratorRuntime().wrap(function (_context6) {
17141
17298
  while (1) switch (_context6.prev = _context6.next) {
17142
17299
  case 0:
17143
17300
  length = sqTagInfo.length;
17144
- stream = this.stream, syntax = this.syntax;
17301
+ stream = this.stream;
17302
+ 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
17303
  endOffset = length === UNDEFINED_LENGTH_FIX ? Number.MAX_SAFE_INTEGER : stream.offset + length;
17146
17304
  case 1:
17147
17305
  _t = stream.offset < endOffset;
@@ -17159,7 +17317,9 @@
17159
17317
  break;
17160
17318
  }
17161
17319
  readLog.debug("readSequence loop", stream.offset, endOffset);
17162
- tagInfo = this.readTagHeader(syntax, options);
17320
+ tagInfo = this.readTagHeader(_objectSpread2(_objectSpread2({}, options), {}, {
17321
+ readSyntax: readSyntax
17322
+ }));
17163
17323
  tag = tagInfo.tag;
17164
17324
  if (!(tag === TagHex.Item)) {
17165
17325
  _context6.next = 5;
@@ -17168,12 +17328,17 @@
17168
17328
  listener.startObject();
17169
17329
  // defined-length item: stop at its own end (see doc comment)
17170
17330
  itemLength = tagInfo.length;
17171
- itemUntilOffset = itemLength === UNDEFINED_LENGTH_FIX ? endOffset : Math.min(stream.offset + itemLength, endOffset);
17331
+ itemUntilOffset = itemLength === UNDEFINED_LENGTH_FIX ? endOffset : Math.min(stream.offset + itemLength, endOffset); // A SpecificCharacterSet in the item applies only to that
17332
+ // item (PS3.5 7.5.3), but the item is read on this stream:
17333
+ // put back the decoder the item started with.
17334
+ decoder = stream.decoder;
17172
17335
  _context6.next = 4;
17173
17336
  return this.read(listener, _objectSpread2(_objectSpread2({}, options), {}, {
17174
- untilOffset: itemUntilOffset
17337
+ untilOffset: itemUntilOffset,
17338
+ readSyntax: readSyntax
17175
17339
  }));
17176
17340
  case 4:
17341
+ stream.setDecoder(decoder);
17177
17342
  _context6.next = 7;
17178
17343
  break;
17179
17344
  case 5:
@@ -17599,14 +17764,15 @@
17599
17764
  }, {
17600
17765
  key: "readTagHeader",
17601
17766
  value: function readTagHeader() {
17767
+ var _options$readSyntax;
17602
17768
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
17603
17769
  untilTag: null,
17604
17770
  includeUntilTagValue: false
17605
17771
  };
17606
- var stream = this.stream,
17607
- syntax = this.syntax;
17772
+ var stream = this.stream;
17608
17773
  var untilTag = options.untilTag,
17609
17774
  includeUntilTagValue = options.includeUntilTagValue;
17775
+ var syntax = (_options$readSyntax = options.readSyntax) !== null && _options$readSyntax !== void 0 ? _options$readSyntax : this.syntax;
17610
17776
  var implicit = syntax == IMPLICIT_LITTLE_ENDIAN;
17611
17777
  var isLittleEndian = syntax !== EXPLICIT_BIG_ENDIAN;
17612
17778
  stream.setEndian(isLittleEndian);
@@ -17626,6 +17792,7 @@
17626
17792
  var length = null;
17627
17793
  var vr = null;
17628
17794
  var vrType;
17795
+ var wireVrType = null;
17629
17796
  var isCommand = tagObj.group() === 0;
17630
17797
  if (tagObj.isInstruction()) {
17631
17798
  length = stream.readUint32();
@@ -17660,6 +17827,7 @@
17660
17827
  } else {
17661
17828
  var _DicomMessage$lookupT;
17662
17829
  vrType = stream.readVR();
17830
+ wireVrType = vrType;
17663
17831
  if (vrType === "UN" && (_DicomMessage$lookupT = DicomMessage.lookupTag(tagObj)) !== null && _DicomMessage$lookupT !== void 0 && _DicomMessage$lookupT.vr) {
17664
17832
  vrType = DicomMessage.lookupTag(tagObj).vr;
17665
17833
  if (vrType === "xs") {
@@ -17679,11 +17847,16 @@
17679
17847
  length = stream.readUint16();
17680
17848
  }
17681
17849
  }
17850
+ var sequenceReadSyntax;
17851
+ if (!implicit && wireVrType === "UN" && isUnSequenceValue(stream.view, stream.offset, length, vr.type)) {
17852
+ vr = ValueRepresentation$1.createByTypeString("SQ");
17853
+ sequenceReadSyntax = IMPLICIT_LITTLE_ENDIAN;
17854
+ }
17682
17855
  var punctuatedTag = DicomMetaDictionary.punctuateTag(tag);
17683
17856
  var entry = DicomMetaDictionary.dictionary[punctuatedTag];
17684
17857
 
17685
17858
  // Include both the string and object values for vr and tag
17686
- var header = {
17859
+ var header = _objectSpread2({
17687
17860
  vrObj: vr,
17688
17861
  vr: vr.type,
17689
17862
  tag: tag,
@@ -17691,7 +17864,9 @@
17691
17864
  vm: entry === null || entry === void 0 ? void 0 : entry.vm,
17692
17865
  name: entry === null || entry === void 0 ? void 0 : entry.name,
17693
17866
  length: length === UNDEFINED_LENGTH ? -1 : length
17694
- };
17867
+ }, sequenceReadSyntax && {
17868
+ sequenceReadSyntax: sequenceReadSyntax
17869
+ });
17695
17870
  return header;
17696
17871
  }
17697
17872
 
@@ -17705,12 +17880,14 @@
17705
17880
  key: "readSingle",
17706
17881
  value: (function () {
17707
17882
  var _readSingle = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(tagInfo, listener, options) {
17883
+ var _options$readSyntax2;
17708
17884
  var length, stream, syntax, vr, values, times, i, _vr$read, value, _vr$read2, _value, delimiterChar, decoder, valuesForListener;
17709
17885
  return _regeneratorRuntime().wrap(function (_context11) {
17710
17886
  while (1) switch (_context11.prev = _context11.next) {
17711
17887
  case 0:
17712
17888
  length = tagInfo.length;
17713
- stream = this.stream, syntax = this.syntax;
17889
+ stream = this.stream;
17890
+ syntax = (_options$readSyntax2 = options === null || options === void 0 ? void 0 : options.readSyntax) !== null && _options$readSyntax2 !== void 0 ? _options$readSyntax2 : this.syntax;
17714
17891
  _context11.next = 1;
17715
17892
  return this.stream.ensureAvailable(length);
17716
17893
  case 1:
@@ -27822,6 +27999,11 @@
27822
27999
  MeasurementReport: MeasurementReport$1
27823
28000
  };
27824
28001
 
28002
+ /**
28003
+ * @deprecated The adapters moved to `@cornerstonejs/adapters`. Import them
28004
+ * from that package. `@dcmjs-org/dcmjs` keeps this export only for
28005
+ * compatibility with 0.x, and a later major release removes it.
28006
+ */
27825
28007
  var adapters = {
27826
28008
  Cornerstone: Cornerstone,
27827
28009
  Cornerstone3D: Cornerstone3D,