@dcmjs-org/dcmjs 1.0.0-beta.15 → 1.0.0-beta.17
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.cjs +1 -1
- package/build/dcmjs.es.js +1 -1
- package/build/dcmjs.js +1811 -1424
- package/build/dcmjs.js.map +1 -1
- package/build/dcmjs.min.js +2 -2
- package/build/dcmjs.min.js.map +1 -1
- package/build/{dcmjs.shared-DI53lI_H.cjs → dcmjs.shared---E7clvy.cjs} +122 -43
- package/build/dcmjs.shared---E7clvy.cjs.map +1 -0
- package/build/{dcmjs.shared-CP8p6SfT.js → dcmjs.shared-Cy_BdC0f.js} +122 -43
- package/build/dcmjs.shared-Cy_BdC0f.js.map +1 -0
- package/build/eventStream.cjs +40 -12
- package/build/eventStream.cjs.map +1 -1
- package/build/eventStream.es.js +41 -13
- package/build/eventStream.es.js.map +1 -1
- package/package.json +8 -8
- package/build/dcmjs.shared-CP8p6SfT.js.map +0 -1
- package/build/dcmjs.shared-DI53lI_H.cjs.map +0 -1
package/build/dcmjs.js
CHANGED
|
@@ -566,6 +566,33 @@
|
|
|
566
566
|
};
|
|
567
567
|
return _wrapNativeSuper(Class);
|
|
568
568
|
}
|
|
569
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
570
|
+
if (source == null) return {};
|
|
571
|
+
var target = {};
|
|
572
|
+
var sourceKeys = Object.keys(source);
|
|
573
|
+
var key, i;
|
|
574
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
575
|
+
key = sourceKeys[i];
|
|
576
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
577
|
+
target[key] = source[key];
|
|
578
|
+
}
|
|
579
|
+
return target;
|
|
580
|
+
}
|
|
581
|
+
function _objectWithoutProperties(source, excluded) {
|
|
582
|
+
if (source == null) return {};
|
|
583
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
584
|
+
var key, i;
|
|
585
|
+
if (Object.getOwnPropertySymbols) {
|
|
586
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
587
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
588
|
+
key = sourceSymbolKeys[i];
|
|
589
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
590
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
591
|
+
target[key] = source[key];
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
return target;
|
|
595
|
+
}
|
|
569
596
|
function _assertThisInitialized(self) {
|
|
570
597
|
if (self === void 0) {
|
|
571
598
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
@@ -7732,7 +7759,12 @@
|
|
|
7732
7759
|
value: function slice() {
|
|
7733
7760
|
var start = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
7734
7761
|
var end = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.size;
|
|
7735
|
-
|
|
7762
|
+
// Clamp to the data held, as ArrayBuffer.prototype.slice does.
|
|
7763
|
+
// https://github.com/dcmjs-org/dcmjs/security/advisories/GHSA-xwvm-687g-rm36
|
|
7764
|
+
if (end > this.byteLength) {
|
|
7765
|
+
end = this.byteLength;
|
|
7766
|
+
}
|
|
7767
|
+
if (end <= start) {
|
|
7736
7768
|
return new Uint8Array(0).buffer;
|
|
7737
7769
|
}
|
|
7738
7770
|
var index = this.findStart(start);
|
|
@@ -8108,1154 +8140,35 @@
|
|
|
8108
8140
|
return val;
|
|
8109
8141
|
}
|
|
8110
8142
|
|
|
8111
|
-
var
|
|
8112
|
-
function BufferStream() {
|
|
8113
|
-
var _options$defaultSize;
|
|
8114
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
8115
|
-
_classCallCheck(this, BufferStream);
|
|
8116
|
-
_defineProperty(this, "offset", 0);
|
|
8117
|
-
_defineProperty(this, "startOffset", 0);
|
|
8118
|
-
_defineProperty(this, "isLittleEndian", false);
|
|
8119
|
-
_defineProperty(this, "size", 0);
|
|
8120
|
-
_defineProperty(this, "view", new SplitDataView());
|
|
8121
|
-
/** The available listeners are those waiting for a query response */
|
|
8122
|
-
_defineProperty(this, "availableListeners", []);
|
|
8123
|
-
/** Producers throttled until the consumer consumes or shows new demand */
|
|
8124
|
-
_defineProperty(this, "relayListeners", []);
|
|
8125
|
-
/** Indicates if this buffer stream is complete/has finished being created */
|
|
8126
|
-
_defineProperty(this, "isComplete", false);
|
|
8127
|
-
/** A flag to set to indicate to clear buffers as they get consumed */
|
|
8128
|
-
_defineProperty(this, "clearBuffers", false);
|
|
8129
|
-
_defineProperty(this, "encoder", new TextEncoder("utf-8"));
|
|
8130
|
-
this.isLittleEndian = (options === null || options === void 0 ? void 0 : options.littleEndian) || this.isLittleEndian;
|
|
8131
|
-
this.view.defaultSize = (_options$defaultSize = options === null || options === void 0 ? void 0 : options.defaultSize) !== null && _options$defaultSize !== void 0 ? _options$defaultSize : this.view.defaultSize;
|
|
8132
|
-
this.clearBuffers = options.clearBuffers || false;
|
|
8133
|
-
}
|
|
8143
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
8134
8144
|
|
|
8135
|
-
|
|
8136
|
-
|
|
8137
|
-
|
|
8138
|
-
return _createClass(BufferStream, [{
|
|
8139
|
-
key: "setComplete",
|
|
8140
|
-
value: function setComplete() {
|
|
8141
|
-
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
8142
|
-
this.isComplete = value;
|
|
8143
|
-
this.notifyAvailableListeners();
|
|
8144
|
-
this.notifyRelayListeners();
|
|
8145
|
-
}
|
|
8145
|
+
function getDefaultExportFromCjs (x) {
|
|
8146
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
8147
|
+
}
|
|
8146
8148
|
|
|
8147
|
-
|
|
8148
|
-
* Indicates if the value length is currently available in the already
|
|
8149
|
-
* read/defined portion of the stream.
|
|
8150
|
-
*
|
|
8151
|
-
* By default this will test if the buffer is complete as well,
|
|
8152
|
-
* but this can be changed with orComplete=false.
|
|
8153
|
-
*/
|
|
8154
|
-
}, {
|
|
8155
|
-
key: "isAvailable",
|
|
8156
|
-
value: function isAvailable(length) {
|
|
8157
|
-
var orComplete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
8158
|
-
return this.offset + length <= this.endOffset || orComplete && this.isComplete;
|
|
8159
|
-
}
|
|
8149
|
+
var loglevel$1 = {exports: {}};
|
|
8160
8150
|
|
|
8161
|
-
|
|
8162
|
-
|
|
8163
|
-
|
|
8164
|
-
|
|
8165
|
-
|
|
8166
|
-
|
|
8167
|
-
|
|
8168
|
-
var _this = this;
|
|
8169
|
-
var bytes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1024;
|
|
8170
|
-
if (!this.isAvailable(bytes)) {
|
|
8171
|
-
return new Promise(function (resolve) {
|
|
8172
|
-
var _recheckAvailable = function recheckAvailable() {
|
|
8173
|
-
if (_this.isAvailable(bytes)) {
|
|
8174
|
-
resolve(true);
|
|
8175
|
-
return;
|
|
8176
|
-
}
|
|
8177
|
-
_this.availableListeners.push(_recheckAvailable);
|
|
8178
|
-
// Demand appeared — wake any throttled producer so a
|
|
8179
|
-
// starved consumer can never deadlock against it.
|
|
8180
|
-
_this.notifyRelayListeners();
|
|
8181
|
-
};
|
|
8182
|
-
_recheckAvailable();
|
|
8183
|
-
});
|
|
8184
|
-
}
|
|
8185
|
-
return true;
|
|
8186
|
-
}
|
|
8151
|
+
/*
|
|
8152
|
+
* loglevel - https://github.com/pimterry/loglevel
|
|
8153
|
+
*
|
|
8154
|
+
* Copyright (c) 2013 Tim Perry
|
|
8155
|
+
* Licensed under the MIT license.
|
|
8156
|
+
*/
|
|
8157
|
+
var loglevel = loglevel$1.exports;
|
|
8187
8158
|
|
|
8188
|
-
|
|
8189
|
-
}, {
|
|
8190
|
-
key: "hasPendingDemand",
|
|
8191
|
-
value: function hasPendingDemand() {
|
|
8192
|
-
return this.availableListeners.length > 0;
|
|
8193
|
-
}
|
|
8159
|
+
var hasRequiredLoglevel;
|
|
8194
8160
|
|
|
8195
|
-
|
|
8196
|
-
|
|
8197
|
-
|
|
8198
|
-
|
|
8199
|
-
|
|
8200
|
-
|
|
8201
|
-
|
|
8202
|
-
|
|
8203
|
-
|
|
8204
|
-
|
|
8205
|
-
|
|
8206
|
-
value: function notifyRelayListeners() {
|
|
8207
|
-
var existingListeners = _toConsumableArray(this.relayListeners);
|
|
8208
|
-
this.relayListeners.splice(0, this.relayListeners.length);
|
|
8209
|
-
existingListeners.forEach(function (listener) {
|
|
8210
|
-
return listener();
|
|
8211
|
-
});
|
|
8212
|
-
}
|
|
8213
|
-
}, {
|
|
8214
|
-
key: "setEndian",
|
|
8215
|
-
value: function setEndian(isLittle) {
|
|
8216
|
-
this.isLittleEndian = isLittle;
|
|
8217
|
-
}
|
|
8218
|
-
}, {
|
|
8219
|
-
key: "slice",
|
|
8220
|
-
value: function slice() {
|
|
8221
|
-
var start = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.startOffset;
|
|
8222
|
-
var end = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.endOffset;
|
|
8223
|
-
return this.view.slice(start, end);
|
|
8224
|
-
}
|
|
8225
|
-
|
|
8226
|
-
/**
|
|
8227
|
-
* @deprecated Gets the entire buffer at once. Suggest using the
|
|
8228
|
-
* view instead, and writing an iterator over the parts to finish
|
|
8229
|
-
* writing it.
|
|
8230
|
-
*/
|
|
8231
|
-
}, {
|
|
8232
|
-
key: "getBuffer",
|
|
8233
|
-
value: function getBuffer() {
|
|
8234
|
-
var start = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
8235
|
-
var end = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.size;
|
|
8236
|
-
if (this.noCopy) {
|
|
8237
|
-
return new Uint8Array(this.slice(start, end));
|
|
8238
|
-
}
|
|
8239
|
-
return this.slice(start, end);
|
|
8240
|
-
}
|
|
8241
|
-
}, {
|
|
8242
|
-
key: "buffer",
|
|
8243
|
-
get: function get() {
|
|
8244
|
-
// console.warn("Deprecated buffer get");
|
|
8245
|
-
return this.getBuffer();
|
|
8246
|
-
}
|
|
8247
|
-
}, {
|
|
8248
|
-
key: "available",
|
|
8249
|
-
get: function get() {
|
|
8250
|
-
return this.endOffset - this.offset;
|
|
8251
|
-
}
|
|
8252
|
-
}, {
|
|
8253
|
-
key: "writeUint8",
|
|
8254
|
-
value: function writeUint8(value) {
|
|
8255
|
-
this.checkSize(1);
|
|
8256
|
-
this.view.setUint8(this.offset, toInt(value));
|
|
8257
|
-
return this.increment(1);
|
|
8258
|
-
}
|
|
8259
|
-
}, {
|
|
8260
|
-
key: "writeUint8Repeat",
|
|
8261
|
-
value: function writeUint8Repeat(value, count) {
|
|
8262
|
-
var v = toInt(value);
|
|
8263
|
-
this.checkSize(count);
|
|
8264
|
-
for (var i = 0; i < count; i++) {
|
|
8265
|
-
this.view.setUint8(this.offset + i, v);
|
|
8266
|
-
}
|
|
8267
|
-
return this.increment(count);
|
|
8268
|
-
}
|
|
8269
|
-
}, {
|
|
8270
|
-
key: "writeInt8",
|
|
8271
|
-
value: function writeInt8(value) {
|
|
8272
|
-
this.checkSize(1);
|
|
8273
|
-
this.view.setInt8(this.offset, toInt(value));
|
|
8274
|
-
return this.increment(1);
|
|
8275
|
-
}
|
|
8276
|
-
}, {
|
|
8277
|
-
key: "writeUint16",
|
|
8278
|
-
value: function writeUint16(value) {
|
|
8279
|
-
this.checkSize(2);
|
|
8280
|
-
this.view.setUint16(this.offset, toInt(value), this.isLittleEndian);
|
|
8281
|
-
return this.increment(2);
|
|
8282
|
-
}
|
|
8283
|
-
}, {
|
|
8284
|
-
key: "writeTwoUint16s",
|
|
8285
|
-
value: function writeTwoUint16s(value) {
|
|
8286
|
-
this.checkSize(4);
|
|
8287
|
-
var first = value >> 16;
|
|
8288
|
-
var second = value & 0xffff;
|
|
8289
|
-
this.view.setUint16(this.offset, toInt(first), this.isLittleEndian);
|
|
8290
|
-
this.view.setUint16(this.offset + 2, toInt(second), this.isLittleEndian);
|
|
8291
|
-
return this.increment(4);
|
|
8292
|
-
}
|
|
8293
|
-
}, {
|
|
8294
|
-
key: "writeInt16",
|
|
8295
|
-
value: function writeInt16(value) {
|
|
8296
|
-
this.checkSize(2);
|
|
8297
|
-
this.view.setInt16(this.offset, toInt(value), this.isLittleEndian);
|
|
8298
|
-
return this.increment(2);
|
|
8299
|
-
}
|
|
8300
|
-
}, {
|
|
8301
|
-
key: "writeUint32",
|
|
8302
|
-
value: function writeUint32(value) {
|
|
8303
|
-
this.checkSize(4);
|
|
8304
|
-
this.view.setUint32(this.offset, toInt(value), this.isLittleEndian);
|
|
8305
|
-
return this.increment(4);
|
|
8306
|
-
}
|
|
8307
|
-
}, {
|
|
8308
|
-
key: "writeInt32",
|
|
8309
|
-
value: function writeInt32(value) {
|
|
8310
|
-
this.checkSize(4);
|
|
8311
|
-
this.view.setInt32(this.offset, toInt(value), this.isLittleEndian);
|
|
8312
|
-
return this.increment(4);
|
|
8313
|
-
}
|
|
8314
|
-
}, {
|
|
8315
|
-
key: "writeBigUint64",
|
|
8316
|
-
value: function writeBigUint64(value) {
|
|
8317
|
-
this.checkSize(8);
|
|
8318
|
-
this.view.setBigUint64(this.offset, value, this.isLittleEndian);
|
|
8319
|
-
return this.increment(8);
|
|
8320
|
-
}
|
|
8321
|
-
}, {
|
|
8322
|
-
key: "writeFloat",
|
|
8323
|
-
value: function writeFloat(value) {
|
|
8324
|
-
this.checkSize(4);
|
|
8325
|
-
this.view.setFloat32(this.offset, toFloat(value), this.isLittleEndian);
|
|
8326
|
-
return this.increment(4);
|
|
8327
|
-
}
|
|
8328
|
-
}, {
|
|
8329
|
-
key: "writeDouble",
|
|
8330
|
-
value: function writeDouble(value) {
|
|
8331
|
-
this.checkSize(8);
|
|
8332
|
-
this.view.setFloat64(this.offset, toFloat(value), this.isLittleEndian);
|
|
8333
|
-
return this.increment(8);
|
|
8334
|
-
}
|
|
8335
|
-
}, {
|
|
8336
|
-
key: "writeUTF8String",
|
|
8337
|
-
value: function writeUTF8String(value) {
|
|
8338
|
-
// an empty (null) value is empty text, as in writeAsciiString
|
|
8339
|
-
var encodedString = this.encoder.encode(value !== null && value !== void 0 ? value : "");
|
|
8340
|
-
this.checkSize(encodedString.byteLength);
|
|
8341
|
-
this.view.writeBuffer(encodedString, this.offset);
|
|
8342
|
-
return this.increment(encodedString.byteLength);
|
|
8343
|
-
}
|
|
8344
|
-
}, {
|
|
8345
|
-
key: "writeAsciiString",
|
|
8346
|
-
value: function writeAsciiString(value) {
|
|
8347
|
-
value = value || "";
|
|
8348
|
-
var len = value.length;
|
|
8349
|
-
this.checkSize(len);
|
|
8350
|
-
var startOffset = this.offset;
|
|
8351
|
-
for (var i = 0; i < len; i++) {
|
|
8352
|
-
var charCode = value.charCodeAt(i);
|
|
8353
|
-
this.view.setUint8(startOffset + i, charCode);
|
|
8354
|
-
}
|
|
8355
|
-
return this.increment(len);
|
|
8356
|
-
}
|
|
8357
|
-
|
|
8358
|
-
/**
|
|
8359
|
-
* Appends raw, already-encoded bytes (e.g. a deflated body) at the
|
|
8360
|
-
* current write position and returns the number of bytes written.
|
|
8361
|
-
*/
|
|
8362
|
-
}, {
|
|
8363
|
-
key: "writeRawBytes",
|
|
8364
|
-
value: function writeRawBytes(bytes) {
|
|
8365
|
-
var length = bytes.byteLength;
|
|
8366
|
-
if (length === 0) {
|
|
8367
|
-
return 0;
|
|
8368
|
-
}
|
|
8369
|
-
this.checkSize(length);
|
|
8370
|
-
this.view.writeBuffer(bytes, this.offset);
|
|
8371
|
-
return this.increment(length);
|
|
8372
|
-
}
|
|
8373
|
-
}, {
|
|
8374
|
-
key: "readBigUint64",
|
|
8375
|
-
value: function readBigUint64() {
|
|
8376
|
-
var val = this.view.getBigUint64(this.offset, this.isLittleEndian);
|
|
8377
|
-
this.increment(8);
|
|
8378
|
-
return val;
|
|
8379
|
-
}
|
|
8380
|
-
}, {
|
|
8381
|
-
key: "readUint32",
|
|
8382
|
-
value: function readUint32() {
|
|
8383
|
-
var val = this.view.getUint32(this.offset, this.isLittleEndian);
|
|
8384
|
-
this.increment(4);
|
|
8385
|
-
return val;
|
|
8386
|
-
}
|
|
8387
|
-
}, {
|
|
8388
|
-
key: "readUint16",
|
|
8389
|
-
value: function readUint16() {
|
|
8390
|
-
var val = this.view.getUint16(this.offset, this.isLittleEndian);
|
|
8391
|
-
this.increment(2);
|
|
8392
|
-
return val;
|
|
8393
|
-
}
|
|
8394
|
-
}, {
|
|
8395
|
-
key: "readUint8",
|
|
8396
|
-
value: function readUint8() {
|
|
8397
|
-
var val = this.view.getUint8(this.offset);
|
|
8398
|
-
this.increment(1);
|
|
8399
|
-
return val;
|
|
8400
|
-
}
|
|
8401
|
-
}, {
|
|
8402
|
-
key: "peekUint8",
|
|
8403
|
-
value: function peekUint8(offset) {
|
|
8404
|
-
return this.view.getUint8(this.offset + offset);
|
|
8405
|
-
}
|
|
8406
|
-
}, {
|
|
8407
|
-
key: "readUint8Array",
|
|
8408
|
-
value: function readUint8Array(length) {
|
|
8409
|
-
if (this.offset + length > this.endOffset) {
|
|
8410
|
-
throw new Error("Stream has insufficient data: requested ".concat(length, " bytes at offset ").concat(this.offset, ", but only ").concat(this.endOffset - this.offset, " bytes available (endOffset ").concat(this.endOffset, ")"));
|
|
8411
|
-
}
|
|
8412
|
-
var arr = new Uint8Array(this.view.slice(this.offset, this.offset + length));
|
|
8413
|
-
this.increment(length);
|
|
8414
|
-
return arr;
|
|
8415
|
-
}
|
|
8416
|
-
}, {
|
|
8417
|
-
key: "readArrayBuffer",
|
|
8418
|
-
value: function readArrayBuffer(length) {
|
|
8419
|
-
return this.readUint8Array(length).buffer;
|
|
8420
|
-
}
|
|
8421
|
-
}, {
|
|
8422
|
-
key: "readUint16Array",
|
|
8423
|
-
value: function readUint16Array(length) {
|
|
8424
|
-
var sixlen = length / 2,
|
|
8425
|
-
arr = new Uint16Array(sixlen),
|
|
8426
|
-
i = 0;
|
|
8427
|
-
while (i++ < sixlen) {
|
|
8428
|
-
arr[i] = this.view.getUint16(this.offset, this.isLittleEndian);
|
|
8429
|
-
this.offset += 2;
|
|
8430
|
-
}
|
|
8431
|
-
return arr;
|
|
8432
|
-
}
|
|
8433
|
-
}, {
|
|
8434
|
-
key: "readInt8",
|
|
8435
|
-
value: function readInt8() {
|
|
8436
|
-
var val = this.view.getInt8(this.offset, this.isLittleEndian);
|
|
8437
|
-
this.increment(1);
|
|
8438
|
-
return val;
|
|
8439
|
-
}
|
|
8440
|
-
}, {
|
|
8441
|
-
key: "readInt16",
|
|
8442
|
-
value: function readInt16() {
|
|
8443
|
-
var val = this.view.getInt16(this.offset, this.isLittleEndian);
|
|
8444
|
-
this.increment(2);
|
|
8445
|
-
return val;
|
|
8446
|
-
}
|
|
8447
|
-
}, {
|
|
8448
|
-
key: "readInt32",
|
|
8449
|
-
value: function readInt32() {
|
|
8450
|
-
var val = this.view.getInt32(this.offset, this.isLittleEndian);
|
|
8451
|
-
this.increment(4);
|
|
8452
|
-
return val;
|
|
8453
|
-
}
|
|
8454
|
-
}, {
|
|
8455
|
-
key: "readFloat",
|
|
8456
|
-
value: function readFloat() {
|
|
8457
|
-
var val = this.view.getFloat32(this.offset, this.isLittleEndian);
|
|
8458
|
-
this.increment(4);
|
|
8459
|
-
return val;
|
|
8460
|
-
}
|
|
8461
|
-
}, {
|
|
8462
|
-
key: "readDouble",
|
|
8463
|
-
value: function readDouble() {
|
|
8464
|
-
var val = this.view.getFloat64(this.offset, this.isLittleEndian);
|
|
8465
|
-
this.increment(8);
|
|
8466
|
-
return val;
|
|
8467
|
-
}
|
|
8468
|
-
}, {
|
|
8469
|
-
key: "readAsciiString",
|
|
8470
|
-
value: function readAsciiString(length) {
|
|
8471
|
-
var result = "";
|
|
8472
|
-
var start = this.offset;
|
|
8473
|
-
var end = this.offset + length;
|
|
8474
|
-
if (end >= this.view.byteLength) {
|
|
8475
|
-
end = this.view.byteLength;
|
|
8476
|
-
}
|
|
8477
|
-
for (var i = start; i < end; ++i) {
|
|
8478
|
-
result += String.fromCharCode(this.view.getUint8(i));
|
|
8479
|
-
}
|
|
8480
|
-
this.increment(end - start);
|
|
8481
|
-
return result;
|
|
8482
|
-
}
|
|
8483
|
-
}, {
|
|
8484
|
-
key: "readVR",
|
|
8485
|
-
value: function readVR() {
|
|
8486
|
-
var vr = String.fromCharCode(this.view.getUint8(this.offset)) + String.fromCharCode(this.view.getUint8(this.offset + 1));
|
|
8487
|
-
this.increment(2);
|
|
8488
|
-
return vr;
|
|
8489
|
-
}
|
|
8490
|
-
}, {
|
|
8491
|
-
key: "readEncodedString",
|
|
8492
|
-
value: function readEncodedString(length) {
|
|
8493
|
-
if (this.offset + length >= this.view.byteLength) {
|
|
8494
|
-
length = this.view.byteLength - this.offset;
|
|
8495
|
-
}
|
|
8496
|
-
var view = new DataView(this.slice(this.offset, this.offset + length));
|
|
8497
|
-
var result = this.decoder.decode(view);
|
|
8498
|
-
this.increment(length);
|
|
8499
|
-
return result;
|
|
8500
|
-
}
|
|
8501
|
-
}, {
|
|
8502
|
-
key: "readHex",
|
|
8503
|
-
value: function readHex(length) {
|
|
8504
|
-
var hexString = "";
|
|
8505
|
-
for (var i = 0; i < length; i++) {
|
|
8506
|
-
hexString += this.readUint8().toString(16);
|
|
8507
|
-
}
|
|
8508
|
-
return hexString;
|
|
8509
|
-
}
|
|
8510
|
-
}, {
|
|
8511
|
-
key: "checkSize",
|
|
8512
|
-
value: function checkSize(step) {
|
|
8513
|
-
this.view.checkSize(this.offset + step);
|
|
8514
|
-
}
|
|
8515
|
-
|
|
8516
|
-
/**
|
|
8517
|
-
* Concatenates the stream, starting from the startOffset (to allow concat
|
|
8518
|
-
* on an existing output from the beginning)
|
|
8519
|
-
*/
|
|
8520
|
-
}, {
|
|
8521
|
-
key: "concat",
|
|
8522
|
-
value: function concat(stream) {
|
|
8523
|
-
var length = stream.size - stream.startOffset;
|
|
8524
|
-
this.view.checkSize(this.size + length);
|
|
8525
|
-
this.view.writeBuffer(new Uint8Array(stream.slice(stream.startOffset, stream.size)), this.offset);
|
|
8526
|
-
this.offset += length;
|
|
8527
|
-
this.size = this.offset;
|
|
8528
|
-
this.endOffset = this.size;
|
|
8529
|
-
return this.view.availableSize;
|
|
8530
|
-
}
|
|
8531
|
-
}, {
|
|
8532
|
-
key: "increment",
|
|
8533
|
-
value: function increment(step) {
|
|
8534
|
-
this.offset += step;
|
|
8535
|
-
if (this.offset > this.size) {
|
|
8536
|
-
this.size = this.offset;
|
|
8537
|
-
}
|
|
8538
|
-
return step;
|
|
8539
|
-
}
|
|
8540
|
-
|
|
8541
|
-
/**
|
|
8542
|
-
* Reads from an async stream delivering to addBuffer. Each chunk is
|
|
8543
|
-
* copied, also a plain ArrayBuffer, so the producer may reuse it.
|
|
8544
|
-
*/
|
|
8545
|
-
}, {
|
|
8546
|
-
key: "fromAsyncStream",
|
|
8547
|
-
value: (function () {
|
|
8548
|
-
var _fromAsyncStream = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(stream) {
|
|
8549
|
-
var _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, chunk, _t;
|
|
8550
|
-
return _regeneratorRuntime().wrap(function (_context) {
|
|
8551
|
-
while (1) switch (_context.prev = _context.next) {
|
|
8552
|
-
case 0:
|
|
8553
|
-
_iteratorAbruptCompletion = false;
|
|
8554
|
-
_didIteratorError = false;
|
|
8555
|
-
_context.prev = 1;
|
|
8556
|
-
_iterator = _asyncIterator(stream);
|
|
8557
|
-
case 2:
|
|
8558
|
-
_context.next = 3;
|
|
8559
|
-
return _iterator.next();
|
|
8560
|
-
case 3:
|
|
8561
|
-
if (!(_iteratorAbruptCompletion = !(_step = _context.sent).done)) {
|
|
8562
|
-
_context.next = 5;
|
|
8563
|
-
break;
|
|
8564
|
-
}
|
|
8565
|
-
chunk = _step.value;
|
|
8566
|
-
this.addBuffer(chunk, {
|
|
8567
|
-
transfer: false
|
|
8568
|
-
});
|
|
8569
|
-
case 4:
|
|
8570
|
-
_iteratorAbruptCompletion = false;
|
|
8571
|
-
_context.next = 2;
|
|
8572
|
-
break;
|
|
8573
|
-
case 5:
|
|
8574
|
-
_context.next = 7;
|
|
8575
|
-
break;
|
|
8576
|
-
case 6:
|
|
8577
|
-
_context.prev = 6;
|
|
8578
|
-
_t = _context["catch"](1);
|
|
8579
|
-
_didIteratorError = true;
|
|
8580
|
-
_iteratorError = _t;
|
|
8581
|
-
case 7:
|
|
8582
|
-
_context.prev = 7;
|
|
8583
|
-
_context.prev = 8;
|
|
8584
|
-
if (!(_iteratorAbruptCompletion && _iterator.return != null)) {
|
|
8585
|
-
_context.next = 9;
|
|
8586
|
-
break;
|
|
8587
|
-
}
|
|
8588
|
-
_context.next = 9;
|
|
8589
|
-
return _iterator.return();
|
|
8590
|
-
case 9:
|
|
8591
|
-
_context.prev = 9;
|
|
8592
|
-
if (!_didIteratorError) {
|
|
8593
|
-
_context.next = 10;
|
|
8594
|
-
break;
|
|
8595
|
-
}
|
|
8596
|
-
throw _iteratorError;
|
|
8597
|
-
case 10:
|
|
8598
|
-
return _context.finish(9);
|
|
8599
|
-
case 11:
|
|
8600
|
-
return _context.finish(7);
|
|
8601
|
-
case 12:
|
|
8602
|
-
this.setComplete();
|
|
8603
|
-
case 13:
|
|
8604
|
-
case "end":
|
|
8605
|
-
return _context.stop();
|
|
8606
|
-
}
|
|
8607
|
-
}, _callee, this, [[1, 6, 7, 12], [8,, 9, 11]]);
|
|
8608
|
-
}));
|
|
8609
|
-
function fromAsyncStream(_x) {
|
|
8610
|
-
return _fromAsyncStream.apply(this, arguments);
|
|
8611
|
-
}
|
|
8612
|
-
return fromAsyncStream;
|
|
8613
|
-
}()
|
|
8614
|
-
/**
|
|
8615
|
-
* Adds the buffer to the end of the current buffers list,
|
|
8616
|
-
* updating the size etc.
|
|
8617
|
-
*
|
|
8618
|
-
* A typed array or DataView (for example a Node.js Buffer) adds only
|
|
8619
|
-
* the bytes of the view, and not the full underlying ArrayBuffer.
|
|
8620
|
-
*
|
|
8621
|
-
* @param {*} buffer an ArrayBuffer, or a typed array or DataView
|
|
8622
|
-
* @param {*} options.start byte offset for the start of the new buffer
|
|
8623
|
-
* to use, relative to the start of the view, clamped to the view
|
|
8624
|
-
* @param {*} options.end byte offset for the end of the buffer to use,
|
|
8625
|
-
* relative to the start of the view, clamped to the view
|
|
8626
|
-
* @param {*} options.transfer keeps a reference to the ArrayBuffer
|
|
8627
|
-
* instead of a copy, and the caller must not change the buffer
|
|
8628
|
-
* afterwards. It does not detach the buffer. It applies only when
|
|
8629
|
-
* the range covers the whole ArrayBuffer, so a partial view or range
|
|
8630
|
-
* is always copied. The default is true for an ArrayBuffer, and
|
|
8631
|
-
* false for a view. Set it to false to force a copy.
|
|
8632
|
-
*/
|
|
8633
|
-
)
|
|
8634
|
-
}, {
|
|
8635
|
-
key: "addBuffer",
|
|
8636
|
-
value: function addBuffer(buffer) {
|
|
8637
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
8638
|
-
if (!buffer) {
|
|
8639
|
-
// Silently ignore null buffers.
|
|
8640
|
-
return;
|
|
8641
|
-
}
|
|
8642
|
-
this.view.addBuffer(buffer, options);
|
|
8643
|
-
this.size = this.view.size;
|
|
8644
|
-
this.endOffset = this.size;
|
|
8645
|
-
this.notifyAvailableListeners();
|
|
8646
|
-
return this.size;
|
|
8647
|
-
}
|
|
8648
|
-
}, {
|
|
8649
|
-
key: "notifyAvailableListeners",
|
|
8650
|
-
value: function notifyAvailableListeners() {
|
|
8651
|
-
var existingListeners = _toConsumableArray(this.availableListeners);
|
|
8652
|
-
this.availableListeners.splice(0, this.availableListeners.length);
|
|
8653
|
-
existingListeners.forEach(function (listener) {
|
|
8654
|
-
return listener();
|
|
8655
|
-
});
|
|
8656
|
-
}
|
|
8657
|
-
|
|
8658
|
-
/**
|
|
8659
|
-
* Consumes the data up to the given offset.
|
|
8660
|
-
* This will clear the references to the data buffers, and will
|
|
8661
|
-
* cause resets etc to fail.
|
|
8662
|
-
* The default offset is the current position, so everything already read.
|
|
8663
|
-
*/
|
|
8664
|
-
}, {
|
|
8665
|
-
key: "consume",
|
|
8666
|
-
value: function consume() {
|
|
8667
|
-
var offset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.offset;
|
|
8668
|
-
if (!this.clearBuffers) {
|
|
8669
|
-
return;
|
|
8670
|
-
}
|
|
8671
|
-
this.view.consume(offset);
|
|
8672
|
-
this.notifyRelayListeners();
|
|
8673
|
-
}
|
|
8674
|
-
|
|
8675
|
-
/**
|
|
8676
|
-
* Returns true if the stream has data in the given range.
|
|
8677
|
-
*/
|
|
8678
|
-
}, {
|
|
8679
|
-
key: "hasData",
|
|
8680
|
-
value: function hasData(start) {
|
|
8681
|
-
var end = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : start + 1;
|
|
8682
|
-
return this.view.hasData(start, end);
|
|
8683
|
-
}
|
|
8684
|
-
}, {
|
|
8685
|
-
key: "more",
|
|
8686
|
-
value: function more(length) {
|
|
8687
|
-
if (this.offset + length > this.endOffset) {
|
|
8688
|
-
throw new Error("Request more than currently allocated buffer");
|
|
8689
|
-
}
|
|
8690
|
-
|
|
8691
|
-
// Optimize the more implementation to choose between a slice and
|
|
8692
|
-
// a sub-string reference to the original set of views.
|
|
8693
|
-
// const newBuf = new ReadBufferStream(this.buffer, null, {
|
|
8694
|
-
// start: this.offset,
|
|
8695
|
-
// stop: this.offset + length
|
|
8696
|
-
// });
|
|
8697
|
-
var newBuf = new ReadBufferStream(this.slice(this.offset, this.offset + length));
|
|
8698
|
-
this.increment(length);
|
|
8699
|
-
newBuf.setComplete();
|
|
8700
|
-
return newBuf;
|
|
8701
|
-
}
|
|
8702
|
-
}, {
|
|
8703
|
-
key: "reset",
|
|
8704
|
-
value: function reset() {
|
|
8705
|
-
this.offset = 0;
|
|
8706
|
-
return this;
|
|
8707
|
-
}
|
|
8708
|
-
}, {
|
|
8709
|
-
key: "end",
|
|
8710
|
-
value: function end() {
|
|
8711
|
-
return this.isComplete && this.offset >= this.end;
|
|
8712
|
-
}
|
|
8713
|
-
}, {
|
|
8714
|
-
key: "toEnd",
|
|
8715
|
-
value: function toEnd() {
|
|
8716
|
-
this.offset = this.view.byteLength;
|
|
8717
|
-
}
|
|
8718
|
-
|
|
8719
|
-
/**
|
|
8720
|
-
* Reports on the amount of memory held by the buffers in the view.
|
|
8721
|
-
* @returns {Object} An object containing:
|
|
8722
|
-
* - bufferCount: Number of buffers still held (not null)
|
|
8723
|
-
* - totalSize: Total logical span of all buffers in bytes (each
|
|
8724
|
-
* buffer counts its own view span, not its backing ArrayBuffer)
|
|
8725
|
-
* - consumeOffset: The current consume offset
|
|
8726
|
-
* - buffersBeforeOffset: Number of buffers before the consume offset
|
|
8727
|
-
*/
|
|
8728
|
-
}, {
|
|
8729
|
-
key: "getBufferMemoryInfo",
|
|
8730
|
-
value: function getBufferMemoryInfo() {
|
|
8731
|
-
return this.view.getBufferMemoryInfo(this.offset);
|
|
8732
|
-
}
|
|
8733
|
-
}]);
|
|
8734
|
-
}();
|
|
8735
|
-
|
|
8736
|
-
/**
|
|
8737
|
-
* A read stream over an ArrayBuffer, a typed array or Node Buffer, or a
|
|
8738
|
-
* range of another BufferStream.
|
|
8739
|
-
*
|
|
8740
|
-
* A typed array or Node Buffer is a view into a backing ArrayBuffer that
|
|
8741
|
-
* Node often pools and shares. The stream adopts exactly the viewed byte
|
|
8742
|
-
* range, at logical offset 0. If the stream adopted buffer.buffer whole, it
|
|
8743
|
-
* would alias the other data in the pool. The Node-only Buffer.offset
|
|
8744
|
-
* property (its byteOffset) does not set the read offset.
|
|
8745
|
-
*/
|
|
8746
|
-
var ReadBufferStream = /*#__PURE__*/function (_BufferStream2) {
|
|
8747
|
-
function ReadBufferStream(buffer, littleEndian) {
|
|
8748
|
-
var _options$start;
|
|
8749
|
-
var _this3;
|
|
8750
|
-
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
8751
|
-
start: null,
|
|
8752
|
-
stop: null,
|
|
8753
|
-
noCopy: false
|
|
8754
|
-
};
|
|
8755
|
-
_classCallCheck(this, ReadBufferStream);
|
|
8756
|
-
_this3 = _callSuper(this, ReadBufferStream, [_objectSpread2(_objectSpread2({}, options), {}, {
|
|
8757
|
-
littleEndian: littleEndian
|
|
8758
|
-
})]);
|
|
8759
|
-
_this3.noCopy = options.noCopy;
|
|
8760
|
-
_this3.decoder = new TextDecoder("latin1");
|
|
8761
|
-
if (buffer instanceof BufferStream) {
|
|
8762
|
-
_this3.view.from(buffer.view, options);
|
|
8763
|
-
_this3.isComplete = true;
|
|
8764
|
-
} else if (buffer) {
|
|
8765
|
-
// a view adds only its viewed byte range (SplitDataView.addBuffer)
|
|
8766
|
-
_this3.view.addBuffer(buffer);
|
|
8767
|
-
_this3.isComplete = true;
|
|
8768
|
-
}
|
|
8769
|
-
// a source BufferStream's offset is the sub-stream start; a Node
|
|
8770
|
-
// Buffer's own `offset` property is ignored (see class doc comment)
|
|
8771
|
-
_this3.offset = (_options$start = options.start) !== null && _options$start !== void 0 ? _options$start : buffer instanceof BufferStream ? buffer.offset : 0;
|
|
8772
|
-
_this3.size = options.stop || (buffer === null || buffer === void 0 ? void 0 : buffer.size) || (buffer === null || buffer === void 0 ? void 0 : buffer.byteLength) || 0;
|
|
8773
|
-
_this3.startOffset = _this3.offset;
|
|
8774
|
-
_this3.endOffset = _this3.size;
|
|
8775
|
-
return _this3;
|
|
8776
|
-
}
|
|
8777
|
-
_inherits(ReadBufferStream, _BufferStream2);
|
|
8778
|
-
return _createClass(ReadBufferStream, [{
|
|
8779
|
-
key: "setDecoder",
|
|
8780
|
-
value: function setDecoder(decoder) {
|
|
8781
|
-
this.decoder = decoder;
|
|
8782
|
-
}
|
|
8783
|
-
}, {
|
|
8784
|
-
key: "reset",
|
|
8785
|
-
value: function reset() {
|
|
8786
|
-
this.offset = this.startOffset;
|
|
8787
|
-
return this;
|
|
8788
|
-
}
|
|
8789
|
-
}, {
|
|
8790
|
-
key: "end",
|
|
8791
|
-
value: function end() {
|
|
8792
|
-
return this.isComplete && this.offset >= this.endOffset;
|
|
8793
|
-
}
|
|
8794
|
-
}, {
|
|
8795
|
-
key: "toEnd",
|
|
8796
|
-
value: function toEnd() {
|
|
8797
|
-
this.offset = this.endOffset;
|
|
8798
|
-
}
|
|
8799
|
-
}, {
|
|
8800
|
-
key: "writeUint8",
|
|
8801
|
-
value: function writeUint8(value) {
|
|
8802
|
-
throw new Error(value, "writeUint8 not implemented");
|
|
8803
|
-
}
|
|
8804
|
-
}, {
|
|
8805
|
-
key: "writeUint8Repeat",
|
|
8806
|
-
value: function writeUint8Repeat(value, count) {
|
|
8807
|
-
throw new Error("writeUint8Repeat not implemented (value: ".concat(value, ", count: ").concat(count, ")"));
|
|
8808
|
-
}
|
|
8809
|
-
}, {
|
|
8810
|
-
key: "writeInt8",
|
|
8811
|
-
value: function writeInt8(value) {
|
|
8812
|
-
throw new Error(value, "writeInt8 not implemented");
|
|
8813
|
-
}
|
|
8814
|
-
}, {
|
|
8815
|
-
key: "writeUint16",
|
|
8816
|
-
value: function writeUint16(value) {
|
|
8817
|
-
throw new Error(value, "writeUint16 not implemented");
|
|
8818
|
-
}
|
|
8819
|
-
}, {
|
|
8820
|
-
key: "writeTwoUint16s",
|
|
8821
|
-
value: function writeTwoUint16s(value) {
|
|
8822
|
-
throw new Error(value, "writeTwoUint16s not implemented");
|
|
8823
|
-
}
|
|
8824
|
-
}, {
|
|
8825
|
-
key: "writeInt16",
|
|
8826
|
-
value: function writeInt16(value) {
|
|
8827
|
-
throw new Error(value, "writeInt16 not implemented");
|
|
8828
|
-
}
|
|
8829
|
-
}, {
|
|
8830
|
-
key: "writeUint32",
|
|
8831
|
-
value: function writeUint32(value) {
|
|
8832
|
-
throw new Error(value, "writeUint32 not implemented");
|
|
8833
|
-
}
|
|
8834
|
-
}, {
|
|
8835
|
-
key: "writeInt32",
|
|
8836
|
-
value: function writeInt32(value) {
|
|
8837
|
-
throw new Error(value, "writeInt32 not implemented");
|
|
8838
|
-
}
|
|
8839
|
-
}, {
|
|
8840
|
-
key: "writeFloat",
|
|
8841
|
-
value: function writeFloat(value) {
|
|
8842
|
-
throw new Error(value, "writeFloat not implemented");
|
|
8843
|
-
}
|
|
8844
|
-
}, {
|
|
8845
|
-
key: "writeDouble",
|
|
8846
|
-
value: function writeDouble(value) {
|
|
8847
|
-
throw new Error(value, "writeDouble not implemented");
|
|
8848
|
-
}
|
|
8849
|
-
}, {
|
|
8850
|
-
key: "writeAsciiString",
|
|
8851
|
-
value: function writeAsciiString(value) {
|
|
8852
|
-
throw new Error(value, "writeAsciiString not implemented");
|
|
8853
|
-
}
|
|
8854
|
-
}, {
|
|
8855
|
-
key: "writeUTF8String",
|
|
8856
|
-
value: function writeUTF8String(value) {
|
|
8857
|
-
throw new Error(value, "writeUTF8String not implemented");
|
|
8858
|
-
}
|
|
8859
|
-
}, {
|
|
8860
|
-
key: "writeRawBytes",
|
|
8861
|
-
value: function writeRawBytes(bytes) {
|
|
8862
|
-
throw new Error(bytes, "writeRawBytes not implemented");
|
|
8863
|
-
}
|
|
8864
|
-
}, {
|
|
8865
|
-
key: "checkSize",
|
|
8866
|
-
value: function checkSize(step) {
|
|
8867
|
-
throw new Error(step, "checkSize not implemented");
|
|
8868
|
-
}
|
|
8869
|
-
}, {
|
|
8870
|
-
key: "concat",
|
|
8871
|
-
value: function concat(stream) {
|
|
8872
|
-
throw new Error(stream, "concat not implemented");
|
|
8873
|
-
}
|
|
8874
|
-
}]);
|
|
8875
|
-
}(BufferStream);
|
|
8876
|
-
var DeflatedReadBufferStream = /*#__PURE__*/function (_ReadBufferStream) {
|
|
8877
|
-
function DeflatedReadBufferStream(stream, options) {
|
|
8878
|
-
_classCallCheck(this, DeflatedReadBufferStream);
|
|
8879
|
-
var inflatedBuffer = pako.inflateRaw(stream.getBuffer(stream.offset, stream.size));
|
|
8880
|
-
return _callSuper(this, DeflatedReadBufferStream, [inflatedBuffer.buffer, stream.littleEndian, options]);
|
|
8881
|
-
}
|
|
8882
|
-
_inherits(DeflatedReadBufferStream, _ReadBufferStream);
|
|
8883
|
-
return _createClass(DeflatedReadBufferStream);
|
|
8884
|
-
}(ReadBufferStream);
|
|
8885
|
-
var WriteBufferStream = /*#__PURE__*/function (_BufferStream3) {
|
|
8886
|
-
function WriteBufferStream(defaultSize, littleEndian) {
|
|
8887
|
-
var _this4;
|
|
8888
|
-
_classCallCheck(this, WriteBufferStream);
|
|
8889
|
-
_this4 = _callSuper(this, WriteBufferStream, [{
|
|
8890
|
-
defaultSize: defaultSize,
|
|
8891
|
-
littleEndian: littleEndian
|
|
8892
|
-
}]);
|
|
8893
|
-
_this4.size = 0;
|
|
8894
|
-
return _this4;
|
|
8895
|
-
}
|
|
8896
|
-
_inherits(WriteBufferStream, _BufferStream3);
|
|
8897
|
-
return _createClass(WriteBufferStream);
|
|
8898
|
-
}(BufferStream);
|
|
8899
|
-
|
|
8900
|
-
// TransferSyntaxUIDs
|
|
8901
|
-
var IMPLICIT_LITTLE_ENDIAN = "1.2.840.10008.1.2";
|
|
8902
|
-
var EXPLICIT_LITTLE_ENDIAN = "1.2.840.10008.1.2.1";
|
|
8903
|
-
var DEFLATED_EXPLICIT_LITTLE_ENDIAN = "1.2.840.10008.1.2.1.99";
|
|
8904
|
-
var EXPLICIT_BIG_ENDIAN = "1.2.840.10008.1.2.2";
|
|
8905
|
-
|
|
8906
|
-
/**
|
|
8907
|
-
* The raw hex value is the maximum 32 bit unsigned integer,
|
|
8908
|
-
* but this is a potential length value, so suggest using the
|
|
8909
|
-
* canonical UNDEFINED_LENGTH_FIX value of -1 instead
|
|
8910
|
-
*/
|
|
8911
|
-
var UNDEFINED_LENGTH = 0xffffffff;
|
|
8912
|
-
/**
|
|
8913
|
-
* Use a -1 value for the undefined length being fixed as this is consistent
|
|
8914
|
-
* with other usage and can't be confused with a real length.
|
|
8915
|
-
*/
|
|
8916
|
-
var UNDEFINED_LENGTH_FIX = -1;
|
|
8917
|
-
var ITEM_DELIMITATION_LENGTH = 0x00000000;
|
|
8918
|
-
|
|
8919
|
-
// Delimitation Value
|
|
8920
|
-
var SEQUENCE_DELIMITATION_VALUE = 0x00000000;
|
|
8921
|
-
|
|
8922
|
-
// Value multiplicity and padding
|
|
8923
|
-
var VM_DELIMITER = 0x5c;
|
|
8924
|
-
var PADDING_NULL = 0x00;
|
|
8925
|
-
var PADDING_SPACE = 0x20;
|
|
8926
|
-
|
|
8927
|
-
// PersonName delimeters
|
|
8928
|
-
var PN_COMPONENT_DELIMITER = 0x3d;
|
|
8929
|
-
var SEQUENCE_ITEM_TAG = 0xfffee000;
|
|
8930
|
-
var SEQUENCE_DELIMITER_TAG = 0xfffee0dd;
|
|
8931
|
-
|
|
8932
|
-
// VR types whose read value is kept single (never VM-split on backslashes).
|
|
8933
|
-
// The canonical list every element-shaping path shares — relocated from
|
|
8934
|
-
// DicomMessage so the streaming decode core does not need the legacy reader
|
|
8935
|
-
// for it. (ValueRepresentation keeps a private, narrower list of the same
|
|
8936
|
-
// name for its multiplicity flag; this one additionally carries LT.)
|
|
8937
|
-
var singleVRs$1 = ["SQ", "OF", "OW", "OB", "UN", "LT"];
|
|
8938
|
-
|
|
8939
|
-
// Nearly all transfer syntaxes are encapsulated, so record those which are
|
|
8940
|
-
// unencapsulated as the exceptions.
|
|
8941
|
-
var unencapsulatedTransferSyntaxes = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, IMPLICIT_LITTLE_ENDIAN, true), EXPLICIT_BIG_ENDIAN, true), DEFLATED_EXPLICIT_LITTLE_ENDIAN, true), EXPLICIT_LITTLE_ENDIAN, true);
|
|
8942
|
-
|
|
8943
|
-
// Relocated from DicomMessage.isEncapsulated (which now delegates here) so
|
|
8944
|
-
// Tag.write resolves it over the table above instead of through the
|
|
8945
|
-
// late-binding DicomMessage slot.
|
|
8946
|
-
function isEncapsulatedSyntax(syntax) {
|
|
8947
|
-
return !unencapsulatedTransferSyntaxes[syntax];
|
|
8948
|
-
}
|
|
8949
|
-
|
|
8950
|
-
/**
|
|
8951
|
-
* Video transfer syntax UIDs (MPEG2, H.264, H.265)
|
|
8952
|
-
* These transfer syntaxes treat the entire pixel data stream as a single frame
|
|
8953
|
-
* regardless of the number of fragments.
|
|
8954
|
-
*/
|
|
8955
|
-
var videoTransferSyntaxUIDs = new Set(["1.2.840.10008.1.2.4.100",
|
|
8956
|
-
// MPEG2 Main Profile @ Main Level
|
|
8957
|
-
"1.2.840.10008.1.2.4.100.1",
|
|
8958
|
-
// MPEG2 Main Profile @ Main Level (retired)
|
|
8959
|
-
"1.2.840.10008.1.2.4.101",
|
|
8960
|
-
// MPEG2 Main Profile @ High Level
|
|
8961
|
-
"1.2.840.10008.1.2.4.101.1",
|
|
8962
|
-
// MPEG2 Main Profile @ High Level (retired)
|
|
8963
|
-
"1.2.840.10008.1.2.4.102",
|
|
8964
|
-
// MPEG-4 AVC/H.264 High Profile / Level 4.1
|
|
8965
|
-
"1.2.840.10008.1.2.4.102.1",
|
|
8966
|
-
// MPEG-4 AVC/H.264 High Profile / Level 4.1 (retired)
|
|
8967
|
-
"1.2.840.10008.1.2.4.103",
|
|
8968
|
-
// MPEG-4 AVC/H.264 BD-compatible High Profile / Level 4.1
|
|
8969
|
-
"1.2.840.10008.1.2.4.103.1",
|
|
8970
|
-
// MPEG-4 AVC/H.264 BD-compatible High Profile / Level 4.1 (retired)
|
|
8971
|
-
"1.2.840.10008.1.2.4.104",
|
|
8972
|
-
// MPEG-4 AVC/H.264 High Profile / Level 4.2 For 2D Video
|
|
8973
|
-
"1.2.840.10008.1.2.4.104.1",
|
|
8974
|
-
// MPEG-4 AVC/H.264 High Profile / Level 4.2 For 2D Video (retired)
|
|
8975
|
-
"1.2.840.10008.1.2.4.105",
|
|
8976
|
-
// MPEG-4 AVC/H.264 High Profile / Level 4.2 For 3D Video
|
|
8977
|
-
"1.2.840.10008.1.2.4.105.1",
|
|
8978
|
-
// MPEG-4 AVC/H.264 High Profile / Level 4.2 For 3D Video (retired)
|
|
8979
|
-
"1.2.840.10008.1.2.4.106",
|
|
8980
|
-
// MPEG-4 AVC/H.264 Stereo High Profile / Level 4.2
|
|
8981
|
-
"1.2.840.10008.1.2.4.106.1",
|
|
8982
|
-
// MPEG-4 AVC/H.264 Stereo High Profile / Level 4.2 (retired)
|
|
8983
|
-
"1.2.840.10008.1.2.4.107",
|
|
8984
|
-
// HEVC/H.265 Main Profile / Level 5.1
|
|
8985
|
-
"1.2.840.10008.1.2.4.108" // HEVC/H.265 Main 10 Profile / Level 5.1
|
|
8986
|
-
]);
|
|
8987
|
-
|
|
8988
|
-
/**
|
|
8989
|
-
* Checks if a transfer syntax UID is a video transfer syntax
|
|
8990
|
-
* @param {string} uid - Transfer syntax UID to check
|
|
8991
|
-
* @returns {boolean} - True if the UID is a video transfer syntax
|
|
8992
|
-
*/
|
|
8993
|
-
function isVideoTransferSyntax(uid) {
|
|
8994
|
-
return uid && videoTransferSyntaxUIDs.has(uid);
|
|
8995
|
-
}
|
|
8996
|
-
|
|
8997
|
-
/**
|
|
8998
|
-
* This is an enumeration of some HEX values for the tag strings, used to replace
|
|
8999
|
-
* constants in a few places.
|
|
9000
|
-
*/
|
|
9001
|
-
var TagHex = {
|
|
9002
|
-
Item: "FFFEE000",
|
|
9003
|
-
ItemDelimitationEnd: "FFFEE00D",
|
|
9004
|
-
SequenceDelimitationEnd: "FFFEE0DD",
|
|
9005
|
-
PixelData: "7FE00010",
|
|
9006
|
-
FileMetaInformationGroupLength: "00020000",
|
|
9007
|
-
TransferSyntaxUID: "00020010",
|
|
9008
|
-
Rows: "00280010",
|
|
9009
|
-
Columns: "00280011",
|
|
9010
|
-
SamplesPerPixel: "00280002",
|
|
9011
|
-
BitsAllocated: "00280100",
|
|
9012
|
-
NumberOfFrames: "00280008",
|
|
9013
|
-
SpecificCharacterSet: "00080005",
|
|
9014
|
-
PixelRepresentation: "00280103",
|
|
9015
|
-
DataSetTrailingPadding: "FFFCFFFC",
|
|
9016
|
-
StudyInstanceUID: "0020000D",
|
|
9017
|
-
SeriesInstanceUID: "0020000E",
|
|
9018
|
-
SOPInstanceUID: "00080018",
|
|
9019
|
-
TimezoneOffsetFromUTC: "00080201",
|
|
9020
|
-
AvailableTransferSyntaxUID: "00083002",
|
|
9021
|
-
MediaStorageSOPInstanceUID: "00020003",
|
|
9022
|
-
MediaStorageSOPClassUID: "00020002"
|
|
9023
|
-
};
|
|
9024
|
-
var encodingMapping = {
|
|
9025
|
-
"": "iso-8859-1",
|
|
9026
|
-
"iso-ir-6": "iso-8859-1",
|
|
9027
|
-
"iso-ir-13": "shift-jis",
|
|
9028
|
-
"iso-ir-100": "latin1",
|
|
9029
|
-
"iso-ir-101": "iso-8859-2",
|
|
9030
|
-
"iso-ir-109": "iso-8859-3",
|
|
9031
|
-
"iso-ir-110": "iso-8859-4",
|
|
9032
|
-
"iso-ir-126": "iso-ir-126",
|
|
9033
|
-
"iso-ir-127": "iso-ir-127",
|
|
9034
|
-
"iso-ir-138": "iso-ir-138",
|
|
9035
|
-
"iso-ir-144": "iso-ir-144",
|
|
9036
|
-
"iso-ir-148": "iso-ir-148",
|
|
9037
|
-
"iso-ir-166": "tis-620",
|
|
9038
|
-
"iso-2022-ir-6": "iso-8859-1",
|
|
9039
|
-
"iso-2022-ir-13": "shift-jis",
|
|
9040
|
-
"iso-2022-ir-87": "iso-2022-jp",
|
|
9041
|
-
"iso-2022-ir-100": "latin1",
|
|
9042
|
-
"iso-2022-ir-101": "iso-8859-2",
|
|
9043
|
-
"iso-2022-ir-109": "iso-8859-3",
|
|
9044
|
-
"iso-2022-ir-110": "iso-8859-4",
|
|
9045
|
-
"iso-2022-ir-126": "iso-ir-126",
|
|
9046
|
-
"iso-2022-ir-127": "iso-ir-127",
|
|
9047
|
-
"iso-2022-ir-138": "iso-ir-138",
|
|
9048
|
-
"iso-2022-ir-144": "iso-ir-144",
|
|
9049
|
-
"iso-2022-ir-148": "iso-ir-148",
|
|
9050
|
-
"iso-2022-ir-149": "euc-kr",
|
|
9051
|
-
"iso-2022-ir-159": "iso-2022-jp",
|
|
9052
|
-
"iso-2022-ir-166": "tis-620",
|
|
9053
|
-
"iso-2022-ir-58": "iso-ir-58",
|
|
9054
|
-
"iso-ir-192": "utf-8",
|
|
9055
|
-
gb18030: "gb18030",
|
|
9056
|
-
"iso-2022-gbk": "gbk",
|
|
9057
|
-
"iso-2022-58": "gb2312",
|
|
9058
|
-
gbk: "gbk"
|
|
9059
|
-
};
|
|
9060
|
-
|
|
9061
|
-
/**
|
|
9062
|
-
* Maps DICOM tag hex strings to their normalized lower camelCase names
|
|
9063
|
-
* for use in listener.information tracking
|
|
9064
|
-
*/
|
|
9065
|
-
var TAG_NAME_MAP = {
|
|
9066
|
-
"0020000D": "studyInstanceUid",
|
|
9067
|
-
"0020000E": "seriesInstanceUid",
|
|
9068
|
-
"00080018": "sopInstanceUid",
|
|
9069
|
-
"00020010": "transferSyntaxUid",
|
|
9070
|
-
"00083002": "availableTransferSyntaxUid",
|
|
9071
|
-
"00080201": "timezoneOffsetFromUtc",
|
|
9072
|
-
"00080005": "specificCharacterSet",
|
|
9073
|
-
"00280008": "numberOfFrames",
|
|
9074
|
-
"00280010": "rows",
|
|
9075
|
-
"00280011": "columns",
|
|
9076
|
-
"00280002": "samplesPerPixel",
|
|
9077
|
-
"00280100": "bitsAllocated",
|
|
9078
|
-
"00280103": "pixelRepresentation"
|
|
9079
|
-
};
|
|
9080
|
-
|
|
9081
|
-
/**
|
|
9082
|
-
* Default tags to track in listener.information
|
|
9083
|
-
*/
|
|
9084
|
-
var DEFAULT_INFORMATION_TAGS = new Set(["0020000D",
|
|
9085
|
-
// StudyInstanceUID
|
|
9086
|
-
"0020000E",
|
|
9087
|
-
// SeriesInstanceUID
|
|
9088
|
-
"00080018",
|
|
9089
|
-
// SOPInstanceUID
|
|
9090
|
-
"00020010",
|
|
9091
|
-
// TransferSyntaxUID
|
|
9092
|
-
"00083002",
|
|
9093
|
-
// AvailableTransferSyntaxUID
|
|
9094
|
-
"00080201",
|
|
9095
|
-
// TimezoneOffsetFromUTC
|
|
9096
|
-
"00080005",
|
|
9097
|
-
// SpecificCharacterSet
|
|
9098
|
-
"00280008",
|
|
9099
|
-
// NumberOfFrames
|
|
9100
|
-
"00280010",
|
|
9101
|
-
// Rows
|
|
9102
|
-
"00280011",
|
|
9103
|
-
// Columns
|
|
9104
|
-
"00280002",
|
|
9105
|
-
// SamplesPerPixel
|
|
9106
|
-
"00280100",
|
|
9107
|
-
// BitsAllocated
|
|
9108
|
-
"00280103" // PixelRepresentation
|
|
9109
|
-
]);
|
|
9110
|
-
|
|
9111
|
-
/**
|
|
9112
|
-
* All valid DICOM VR (Value Representation) codes
|
|
9113
|
-
*/
|
|
9114
|
-
var VALID_VRS = new Set(["AE",
|
|
9115
|
-
// Application Entity
|
|
9116
|
-
"AS",
|
|
9117
|
-
// Age String
|
|
9118
|
-
"AT",
|
|
9119
|
-
// Attribute Tag
|
|
9120
|
-
"CS",
|
|
9121
|
-
// Code String
|
|
9122
|
-
"DA",
|
|
9123
|
-
// Date
|
|
9124
|
-
"DS",
|
|
9125
|
-
// Decimal String
|
|
9126
|
-
"DT",
|
|
9127
|
-
// Date Time
|
|
9128
|
-
"FL",
|
|
9129
|
-
// Floating Point Single
|
|
9130
|
-
"FD",
|
|
9131
|
-
// Floating Point Double
|
|
9132
|
-
"IS",
|
|
9133
|
-
// Integer String
|
|
9134
|
-
"LO",
|
|
9135
|
-
// Long String
|
|
9136
|
-
"LT",
|
|
9137
|
-
// Long Text
|
|
9138
|
-
"OB",
|
|
9139
|
-
// Other Byte
|
|
9140
|
-
"OD",
|
|
9141
|
-
// Other Double
|
|
9142
|
-
"OF",
|
|
9143
|
-
// Other Float
|
|
9144
|
-
"OL",
|
|
9145
|
-
// Other Long
|
|
9146
|
-
"OV",
|
|
9147
|
-
// Other 64-bit Very Long
|
|
9148
|
-
"OW",
|
|
9149
|
-
// Other Word
|
|
9150
|
-
"PN",
|
|
9151
|
-
// Person Name
|
|
9152
|
-
"SH",
|
|
9153
|
-
// Short String
|
|
9154
|
-
"SL",
|
|
9155
|
-
// Signed Long
|
|
9156
|
-
"SQ",
|
|
9157
|
-
// Sequence of Items
|
|
9158
|
-
"SS",
|
|
9159
|
-
// Signed Short
|
|
9160
|
-
"ST",
|
|
9161
|
-
// Short Text
|
|
9162
|
-
"SV",
|
|
9163
|
-
// Signed 64-bit Very Long
|
|
9164
|
-
"TM",
|
|
9165
|
-
// Time
|
|
9166
|
-
"UC",
|
|
9167
|
-
// Unlimited Characters
|
|
9168
|
-
"UI",
|
|
9169
|
-
// Unique Identifier
|
|
9170
|
-
"UL",
|
|
9171
|
-
// Unsigned Long
|
|
9172
|
-
"UN",
|
|
9173
|
-
// Unknown
|
|
9174
|
-
"UR",
|
|
9175
|
-
// Universal Resource
|
|
9176
|
-
"US",
|
|
9177
|
-
// Unsigned Short
|
|
9178
|
-
"UT",
|
|
9179
|
-
// Unlimited Text
|
|
9180
|
-
"UV" // Unsigned 64-bit Very Long
|
|
9181
|
-
]);
|
|
9182
|
-
|
|
9183
|
-
/**
|
|
9184
|
-
* DICOM VR (Value Representation) types that are allowed for bulkdata encoding
|
|
9185
|
-
* According to DICOMweb specification
|
|
9186
|
-
*/
|
|
9187
|
-
var BULKDATA_VRS = new Set(["DS",
|
|
9188
|
-
// Decimal String
|
|
9189
|
-
"FL",
|
|
9190
|
-
// Floating Point Single
|
|
9191
|
-
"FD",
|
|
9192
|
-
// Floating Point Double
|
|
9193
|
-
"IS",
|
|
9194
|
-
// Integer String
|
|
9195
|
-
"LT",
|
|
9196
|
-
// Long Text
|
|
9197
|
-
"OB",
|
|
9198
|
-
// Other Byte
|
|
9199
|
-
"OD",
|
|
9200
|
-
// Other Double
|
|
9201
|
-
"OF",
|
|
9202
|
-
// Other Float
|
|
9203
|
-
"OL",
|
|
9204
|
-
// Other Long
|
|
9205
|
-
"OV",
|
|
9206
|
-
// Other 64-bit Very Long
|
|
9207
|
-
"OW",
|
|
9208
|
-
// Other Word
|
|
9209
|
-
"SL",
|
|
9210
|
-
// Signed Long
|
|
9211
|
-
"SS",
|
|
9212
|
-
// Signed Short
|
|
9213
|
-
"ST",
|
|
9214
|
-
// Short Text
|
|
9215
|
-
"SV",
|
|
9216
|
-
// Signed 64-bit Very Long
|
|
9217
|
-
"UC",
|
|
9218
|
-
// Unlimited Characters
|
|
9219
|
-
"UL",
|
|
9220
|
-
// Unsigned Long
|
|
9221
|
-
"UN",
|
|
9222
|
-
// Unknown
|
|
9223
|
-
"US",
|
|
9224
|
-
// Unsigned Short
|
|
9225
|
-
"UT",
|
|
9226
|
-
// Unlimited Text
|
|
9227
|
-
"UV" // Unsigned 64-bit Very Long
|
|
9228
|
-
]);
|
|
9229
|
-
|
|
9230
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
9231
|
-
|
|
9232
|
-
function getDefaultExportFromCjs (x) {
|
|
9233
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
9234
|
-
}
|
|
9235
|
-
|
|
9236
|
-
var loglevel$1 = {exports: {}};
|
|
9237
|
-
|
|
9238
|
-
/*
|
|
9239
|
-
* loglevel - https://github.com/pimterry/loglevel
|
|
9240
|
-
*
|
|
9241
|
-
* Copyright (c) 2013 Tim Perry
|
|
9242
|
-
* Licensed under the MIT license.
|
|
9243
|
-
*/
|
|
9244
|
-
var loglevel = loglevel$1.exports;
|
|
9245
|
-
|
|
9246
|
-
var hasRequiredLoglevel;
|
|
9247
|
-
|
|
9248
|
-
function requireLoglevel () {
|
|
9249
|
-
if (hasRequiredLoglevel) return loglevel$1.exports;
|
|
9250
|
-
hasRequiredLoglevel = 1;
|
|
9251
|
-
(function (module) {
|
|
9252
|
-
(function (root, definition) {
|
|
9253
|
-
if (module.exports) {
|
|
9254
|
-
module.exports = definition();
|
|
9255
|
-
} else {
|
|
9256
|
-
root.log = definition();
|
|
9257
|
-
}
|
|
9258
|
-
}(loglevel, function () {
|
|
8161
|
+
function requireLoglevel () {
|
|
8162
|
+
if (hasRequiredLoglevel) return loglevel$1.exports;
|
|
8163
|
+
hasRequiredLoglevel = 1;
|
|
8164
|
+
(function (module) {
|
|
8165
|
+
(function (root, definition) {
|
|
8166
|
+
if (module.exports) {
|
|
8167
|
+
module.exports = definition();
|
|
8168
|
+
} else {
|
|
8169
|
+
root.log = definition();
|
|
8170
|
+
}
|
|
8171
|
+
}(loglevel, function () {
|
|
9259
8172
|
|
|
9260
8173
|
// Slightly dubious tricks to cut down minimized file size
|
|
9261
8174
|
var noop = function() {};
|
|
@@ -9456,183 +8369,1400 @@
|
|
|
9456
8369
|
window.localStorage.removeItem(storageKey);
|
|
9457
8370
|
} catch (ignore) {}
|
|
9458
8371
|
|
|
9459
|
-
// Use session cookie as fallback
|
|
9460
|
-
try {
|
|
9461
|
-
window.document.cookie =
|
|
9462
|
-
encodeURIComponent(storageKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
|
|
9463
|
-
} catch (ignore) {}
|
|
9464
|
-
}
|
|
8372
|
+
// Use session cookie as fallback
|
|
8373
|
+
try {
|
|
8374
|
+
window.document.cookie =
|
|
8375
|
+
encodeURIComponent(storageKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
|
|
8376
|
+
} catch (ignore) {}
|
|
8377
|
+
}
|
|
8378
|
+
|
|
8379
|
+
function normalizeLevel(input) {
|
|
8380
|
+
var level = input;
|
|
8381
|
+
if (typeof level === "string" && self.levels[level.toUpperCase()] !== undefined) {
|
|
8382
|
+
level = self.levels[level.toUpperCase()];
|
|
8383
|
+
}
|
|
8384
|
+
if (typeof level === "number" && level >= 0 && level <= self.levels.SILENT) {
|
|
8385
|
+
return level;
|
|
8386
|
+
} else {
|
|
8387
|
+
throw new TypeError("log.setLevel() called with invalid level: " + input);
|
|
8388
|
+
}
|
|
8389
|
+
}
|
|
8390
|
+
|
|
8391
|
+
/*
|
|
8392
|
+
*
|
|
8393
|
+
* Public logger API - see https://github.com/pimterry/loglevel for details
|
|
8394
|
+
*
|
|
8395
|
+
*/
|
|
8396
|
+
|
|
8397
|
+
self.name = name;
|
|
8398
|
+
|
|
8399
|
+
self.levels = { "TRACE": 0, "DEBUG": 1, "INFO": 2, "WARN": 3,
|
|
8400
|
+
"ERROR": 4, "SILENT": 5};
|
|
8401
|
+
|
|
8402
|
+
self.methodFactory = factory || defaultMethodFactory;
|
|
8403
|
+
|
|
8404
|
+
self.getLevel = function () {
|
|
8405
|
+
if (userLevel != null) {
|
|
8406
|
+
return userLevel;
|
|
8407
|
+
} else if (defaultLevel != null) {
|
|
8408
|
+
return defaultLevel;
|
|
8409
|
+
} else {
|
|
8410
|
+
return inheritedLevel;
|
|
8411
|
+
}
|
|
8412
|
+
};
|
|
8413
|
+
|
|
8414
|
+
self.setLevel = function (level, persist) {
|
|
8415
|
+
userLevel = normalizeLevel(level);
|
|
8416
|
+
if (persist !== false) { // defaults to true
|
|
8417
|
+
persistLevelIfPossible(userLevel);
|
|
8418
|
+
}
|
|
8419
|
+
|
|
8420
|
+
// NOTE: in v2, this should call rebuild(), which updates children.
|
|
8421
|
+
return replaceLoggingMethods.call(self);
|
|
8422
|
+
};
|
|
8423
|
+
|
|
8424
|
+
self.setDefaultLevel = function (level) {
|
|
8425
|
+
defaultLevel = normalizeLevel(level);
|
|
8426
|
+
if (!getPersistedLevel()) {
|
|
8427
|
+
self.setLevel(level, false);
|
|
8428
|
+
}
|
|
8429
|
+
};
|
|
8430
|
+
|
|
8431
|
+
self.resetLevel = function () {
|
|
8432
|
+
userLevel = null;
|
|
8433
|
+
clearPersistedLevel();
|
|
8434
|
+
replaceLoggingMethods.call(self);
|
|
8435
|
+
};
|
|
8436
|
+
|
|
8437
|
+
self.enableAll = function(persist) {
|
|
8438
|
+
self.setLevel(self.levels.TRACE, persist);
|
|
8439
|
+
};
|
|
8440
|
+
|
|
8441
|
+
self.disableAll = function(persist) {
|
|
8442
|
+
self.setLevel(self.levels.SILENT, persist);
|
|
8443
|
+
};
|
|
8444
|
+
|
|
8445
|
+
self.rebuild = function () {
|
|
8446
|
+
if (defaultLogger !== self) {
|
|
8447
|
+
inheritedLevel = normalizeLevel(defaultLogger.getLevel());
|
|
8448
|
+
}
|
|
8449
|
+
replaceLoggingMethods.call(self);
|
|
8450
|
+
|
|
8451
|
+
if (defaultLogger === self) {
|
|
8452
|
+
for (var childName in _loggersByName) {
|
|
8453
|
+
_loggersByName[childName].rebuild();
|
|
8454
|
+
}
|
|
8455
|
+
}
|
|
8456
|
+
};
|
|
8457
|
+
|
|
8458
|
+
// Initialize all the internal levels.
|
|
8459
|
+
inheritedLevel = normalizeLevel(
|
|
8460
|
+
defaultLogger ? defaultLogger.getLevel() : "WARN"
|
|
8461
|
+
);
|
|
8462
|
+
var initialLevel = getPersistedLevel();
|
|
8463
|
+
if (initialLevel != null) {
|
|
8464
|
+
userLevel = normalizeLevel(initialLevel);
|
|
8465
|
+
}
|
|
8466
|
+
replaceLoggingMethods.call(self);
|
|
8467
|
+
}
|
|
8468
|
+
|
|
8469
|
+
/*
|
|
8470
|
+
*
|
|
8471
|
+
* Top-level API
|
|
8472
|
+
*
|
|
8473
|
+
*/
|
|
8474
|
+
|
|
8475
|
+
defaultLogger = new Logger();
|
|
8476
|
+
|
|
8477
|
+
defaultLogger.getLogger = function getLogger(name) {
|
|
8478
|
+
if ((typeof name !== "symbol" && typeof name !== "string") || name === "") {
|
|
8479
|
+
throw new TypeError("You must supply a name when creating a logger.");
|
|
8480
|
+
}
|
|
8481
|
+
|
|
8482
|
+
var logger = _loggersByName[name];
|
|
8483
|
+
if (!logger) {
|
|
8484
|
+
logger = _loggersByName[name] = new Logger(
|
|
8485
|
+
name,
|
|
8486
|
+
defaultLogger.methodFactory
|
|
8487
|
+
);
|
|
8488
|
+
}
|
|
8489
|
+
return logger;
|
|
8490
|
+
};
|
|
8491
|
+
|
|
8492
|
+
// Grab the current global log variable in case of overwrite
|
|
8493
|
+
var _log = (typeof window !== undefinedType) ? window.log : undefined;
|
|
8494
|
+
defaultLogger.noConflict = function() {
|
|
8495
|
+
if (typeof window !== undefinedType &&
|
|
8496
|
+
window.log === defaultLogger) {
|
|
8497
|
+
window.log = _log;
|
|
8498
|
+
}
|
|
8499
|
+
|
|
8500
|
+
return defaultLogger;
|
|
8501
|
+
};
|
|
8502
|
+
|
|
8503
|
+
defaultLogger.getLoggers = function getLoggers() {
|
|
8504
|
+
return _loggersByName;
|
|
8505
|
+
};
|
|
8506
|
+
|
|
8507
|
+
// ES6 default export, for compatibility
|
|
8508
|
+
defaultLogger['default'] = defaultLogger;
|
|
8509
|
+
|
|
8510
|
+
return defaultLogger;
|
|
8511
|
+
}));
|
|
8512
|
+
} (loglevel$1));
|
|
8513
|
+
return loglevel$1.exports;
|
|
8514
|
+
}
|
|
8515
|
+
|
|
8516
|
+
var loglevelExports = requireLoglevel();
|
|
8517
|
+
var log = /*@__PURE__*/getDefaultExportFromCjs(loglevelExports);
|
|
8518
|
+
|
|
8519
|
+
var _toLogLevel;
|
|
8520
|
+
|
|
8521
|
+
// The root rollup build replaces the read below with the build-time level;
|
|
8522
|
+
// elsewhere a browser has no `process`, so the read can throw.
|
|
8523
|
+
var level;
|
|
8524
|
+
try {
|
|
8525
|
+
level = "warn";
|
|
8526
|
+
} catch (_unused) {
|
|
8527
|
+
level = undefined;
|
|
8528
|
+
}
|
|
8529
|
+
log.setLevel((_toLogLevel = toLogLevel(level)) !== null && _toLogLevel !== void 0 ? _toLogLevel : "warn");
|
|
8530
|
+
|
|
8531
|
+
/**
|
|
8532
|
+
* The loglevel level of a value: a level name (case-insensitive), or a
|
|
8533
|
+
* number from 0 to 5, also as a string ("1"), because an environment
|
|
8534
|
+
* variable is a string. Undefined for any other value, for example
|
|
8535
|
+
* "verbose" (winston) or "fatal" (pino), for which loglevel 1.9 throws
|
|
8536
|
+
* (pimterry/loglevel#210 proposes log.parseLevel for this check).
|
|
8537
|
+
*/
|
|
8538
|
+
function toLogLevel(value) {
|
|
8539
|
+
if (typeof value === "string" && /^[0-5]$/.test(value)) {
|
|
8540
|
+
return Number(value);
|
|
8541
|
+
}
|
|
8542
|
+
if (typeof value === "string") {
|
|
8543
|
+
var _log$levels;
|
|
8544
|
+
return ((_log$levels = log.levels) === null || _log$levels === void 0 ? void 0 : _log$levels[value.toUpperCase()]) !== undefined ? value : undefined;
|
|
8545
|
+
}
|
|
8546
|
+
return typeof value === "number" && value >= 0 && value <= 5 ? value : undefined;
|
|
8547
|
+
}
|
|
8548
|
+
var validationLog = log.getLogger("validation.dcmjs");
|
|
8549
|
+
|
|
8550
|
+
var _excluded = ["littleEndian", "start", "stop", "noCopy", "clearBuffers"];
|
|
8551
|
+
var legacyWarned = new Set();
|
|
8552
|
+
|
|
8553
|
+
/** Warns once per class that a positional (0.x) constructor form was used. */
|
|
8554
|
+
function warnLegacyConstructor(className, newForm) {
|
|
8555
|
+
if (!legacyWarned.has(className)) {
|
|
8556
|
+
legacyWarned.add(className);
|
|
8557
|
+
log.warn("".concat(className, ": the positional constructor arguments are deprecated; use ").concat(newForm));
|
|
8558
|
+
}
|
|
8559
|
+
}
|
|
8560
|
+
var BufferStream = /*#__PURE__*/function () {
|
|
8561
|
+
/** @param {{littleEndian?: boolean, defaultSize?: number, clearBuffers?: boolean}} [options] */
|
|
8562
|
+
function BufferStream() {
|
|
8563
|
+
var _options$littleEndian, _options$defaultSize;
|
|
8564
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
8565
|
+
_classCallCheck(this, BufferStream);
|
|
8566
|
+
_defineProperty(this, "offset", 0);
|
|
8567
|
+
_defineProperty(this, "startOffset", 0);
|
|
8568
|
+
_defineProperty(this, "isLittleEndian", true);
|
|
8569
|
+
_defineProperty(this, "size", 0);
|
|
8570
|
+
_defineProperty(this, "view", new SplitDataView());
|
|
8571
|
+
/** The available listeners are those waiting for a query response */
|
|
8572
|
+
_defineProperty(this, "availableListeners", []);
|
|
8573
|
+
/** Producers throttled until the consumer consumes or shows new demand */
|
|
8574
|
+
_defineProperty(this, "relayListeners", []);
|
|
8575
|
+
/** Indicates if this buffer stream is complete/has finished being created */
|
|
8576
|
+
_defineProperty(this, "isComplete", false);
|
|
8577
|
+
/** A flag to set to indicate to clear buffers as they get consumed */
|
|
8578
|
+
_defineProperty(this, "clearBuffers", false);
|
|
8579
|
+
_defineProperty(this, "encoder", new TextEncoder("utf-8"));
|
|
8580
|
+
this.isLittleEndian = (_options$littleEndian = options === null || options === void 0 ? void 0 : options.littleEndian) !== null && _options$littleEndian !== void 0 ? _options$littleEndian : this.isLittleEndian;
|
|
8581
|
+
this.view.defaultSize = (_options$defaultSize = options === null || options === void 0 ? void 0 : options.defaultSize) !== null && _options$defaultSize !== void 0 ? _options$defaultSize : this.view.defaultSize;
|
|
8582
|
+
this.clearBuffers = (options === null || options === void 0 ? void 0 : options.clearBuffers) || false;
|
|
8583
|
+
}
|
|
8584
|
+
|
|
8585
|
+
/**
|
|
8586
|
+
* Mark this stream as having finished being written or read from
|
|
8587
|
+
*/
|
|
8588
|
+
return _createClass(BufferStream, [{
|
|
8589
|
+
key: "setComplete",
|
|
8590
|
+
value: function setComplete() {
|
|
8591
|
+
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
8592
|
+
this.isComplete = value;
|
|
8593
|
+
this.notifyAvailableListeners();
|
|
8594
|
+
this.notifyRelayListeners();
|
|
8595
|
+
}
|
|
8596
|
+
|
|
8597
|
+
/**
|
|
8598
|
+
* Indicates if the value length is currently available in the already
|
|
8599
|
+
* read/defined portion of the stream.
|
|
8600
|
+
*
|
|
8601
|
+
* By default this will test if the buffer is complete as well,
|
|
8602
|
+
* but this can be changed with orComplete=false.
|
|
8603
|
+
*/
|
|
8604
|
+
}, {
|
|
8605
|
+
key: "isAvailable",
|
|
8606
|
+
value: function isAvailable(length) {
|
|
8607
|
+
var orComplete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
8608
|
+
return this.offset + length <= this.endOffset || orComplete && this.isComplete;
|
|
8609
|
+
}
|
|
8610
|
+
|
|
8611
|
+
/**
|
|
8612
|
+
* Ensures that the specified number of bytes are available OR that it is
|
|
8613
|
+
* EOF. By default waits for at least 1k to be available.
|
|
8614
|
+
*/
|
|
8615
|
+
}, {
|
|
8616
|
+
key: "ensureAvailable",
|
|
8617
|
+
value: function ensureAvailable() {
|
|
8618
|
+
var _this = this;
|
|
8619
|
+
var bytes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1024;
|
|
8620
|
+
if (!this.isAvailable(bytes)) {
|
|
8621
|
+
return new Promise(function (resolve) {
|
|
8622
|
+
var _recheckAvailable = function recheckAvailable() {
|
|
8623
|
+
if (_this.isAvailable(bytes)) {
|
|
8624
|
+
resolve(true);
|
|
8625
|
+
return;
|
|
8626
|
+
}
|
|
8627
|
+
_this.availableListeners.push(_recheckAvailable);
|
|
8628
|
+
// Demand appeared — wake any throttled producer so a
|
|
8629
|
+
// starved consumer can never deadlock against it.
|
|
8630
|
+
_this.notifyRelayListeners();
|
|
8631
|
+
};
|
|
8632
|
+
_recheckAvailable();
|
|
8633
|
+
});
|
|
8634
|
+
}
|
|
8635
|
+
return true;
|
|
8636
|
+
}
|
|
8637
|
+
|
|
8638
|
+
/** True when a consumer is blocked waiting for more bytes. */
|
|
8639
|
+
}, {
|
|
8640
|
+
key: "hasPendingDemand",
|
|
8641
|
+
value: function hasPendingDemand() {
|
|
8642
|
+
return this.availableListeners.length > 0;
|
|
8643
|
+
}
|
|
9465
8644
|
|
|
9466
|
-
|
|
9467
|
-
|
|
9468
|
-
|
|
9469
|
-
|
|
9470
|
-
|
|
9471
|
-
|
|
9472
|
-
|
|
9473
|
-
|
|
9474
|
-
|
|
9475
|
-
|
|
9476
|
-
|
|
8645
|
+
/** Resolves on the next consumer activity (consume or new demand). */
|
|
8646
|
+
}, {
|
|
8647
|
+
key: "awaitConsumerActivity",
|
|
8648
|
+
value: function awaitConsumerActivity() {
|
|
8649
|
+
var _this2 = this;
|
|
8650
|
+
return new Promise(function (resolve) {
|
|
8651
|
+
return _this2.relayListeners.push(resolve);
|
|
8652
|
+
});
|
|
8653
|
+
}
|
|
8654
|
+
}, {
|
|
8655
|
+
key: "notifyRelayListeners",
|
|
8656
|
+
value: function notifyRelayListeners() {
|
|
8657
|
+
var existingListeners = _toConsumableArray(this.relayListeners);
|
|
8658
|
+
this.relayListeners.splice(0, this.relayListeners.length);
|
|
8659
|
+
existingListeners.forEach(function (listener) {
|
|
8660
|
+
return listener();
|
|
8661
|
+
});
|
|
8662
|
+
}
|
|
8663
|
+
}, {
|
|
8664
|
+
key: "setEndian",
|
|
8665
|
+
value: function setEndian(isLittle) {
|
|
8666
|
+
this.isLittleEndian = isLittle;
|
|
8667
|
+
}
|
|
8668
|
+
}, {
|
|
8669
|
+
key: "slice",
|
|
8670
|
+
value: function slice() {
|
|
8671
|
+
var start = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.startOffset;
|
|
8672
|
+
var end = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.endOffset;
|
|
8673
|
+
return this.view.slice(start, end);
|
|
8674
|
+
}
|
|
9477
8675
|
|
|
9478
|
-
|
|
9479
|
-
|
|
9480
|
-
|
|
9481
|
-
|
|
9482
|
-
|
|
8676
|
+
/**
|
|
8677
|
+
* @deprecated Gets the entire buffer at once. Suggest using the
|
|
8678
|
+
* view instead, and writing an iterator over the parts to finish
|
|
8679
|
+
* writing it.
|
|
8680
|
+
*/
|
|
8681
|
+
}, {
|
|
8682
|
+
key: "getBuffer",
|
|
8683
|
+
value: function getBuffer() {
|
|
8684
|
+
var start = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
8685
|
+
var end = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.size;
|
|
8686
|
+
if (this.noCopy) {
|
|
8687
|
+
return new Uint8Array(this.slice(start, end));
|
|
8688
|
+
}
|
|
8689
|
+
return this.slice(start, end);
|
|
8690
|
+
}
|
|
8691
|
+
}, {
|
|
8692
|
+
key: "buffer",
|
|
8693
|
+
get: function get() {
|
|
8694
|
+
// console.warn("Deprecated buffer get");
|
|
8695
|
+
return this.getBuffer();
|
|
8696
|
+
}
|
|
8697
|
+
}, {
|
|
8698
|
+
key: "available",
|
|
8699
|
+
get: function get() {
|
|
8700
|
+
return this.endOffset - this.offset;
|
|
8701
|
+
}
|
|
8702
|
+
}, {
|
|
8703
|
+
key: "writeUint8",
|
|
8704
|
+
value: function writeUint8(value) {
|
|
8705
|
+
this.checkSize(1);
|
|
8706
|
+
this.view.setUint8(this.offset, toInt(value));
|
|
8707
|
+
return this.increment(1);
|
|
8708
|
+
}
|
|
8709
|
+
}, {
|
|
8710
|
+
key: "writeUint8Repeat",
|
|
8711
|
+
value: function writeUint8Repeat(value, count) {
|
|
8712
|
+
var v = toInt(value);
|
|
8713
|
+
this.checkSize(count);
|
|
8714
|
+
for (var i = 0; i < count; i++) {
|
|
8715
|
+
this.view.setUint8(this.offset + i, v);
|
|
8716
|
+
}
|
|
8717
|
+
return this.increment(count);
|
|
8718
|
+
}
|
|
8719
|
+
}, {
|
|
8720
|
+
key: "writeInt8",
|
|
8721
|
+
value: function writeInt8(value) {
|
|
8722
|
+
this.checkSize(1);
|
|
8723
|
+
this.view.setInt8(this.offset, toInt(value));
|
|
8724
|
+
return this.increment(1);
|
|
8725
|
+
}
|
|
8726
|
+
}, {
|
|
8727
|
+
key: "writeUint16",
|
|
8728
|
+
value: function writeUint16(value) {
|
|
8729
|
+
this.checkSize(2);
|
|
8730
|
+
this.view.setUint16(this.offset, toInt(value), this.isLittleEndian);
|
|
8731
|
+
return this.increment(2);
|
|
8732
|
+
}
|
|
8733
|
+
}, {
|
|
8734
|
+
key: "writeTwoUint16s",
|
|
8735
|
+
value: function writeTwoUint16s(value) {
|
|
8736
|
+
this.checkSize(4);
|
|
8737
|
+
var first = value >> 16;
|
|
8738
|
+
var second = value & 0xffff;
|
|
8739
|
+
this.view.setUint16(this.offset, toInt(first), this.isLittleEndian);
|
|
8740
|
+
this.view.setUint16(this.offset + 2, toInt(second), this.isLittleEndian);
|
|
8741
|
+
return this.increment(4);
|
|
8742
|
+
}
|
|
8743
|
+
}, {
|
|
8744
|
+
key: "writeInt16",
|
|
8745
|
+
value: function writeInt16(value) {
|
|
8746
|
+
this.checkSize(2);
|
|
8747
|
+
this.view.setInt16(this.offset, toInt(value), this.isLittleEndian);
|
|
8748
|
+
return this.increment(2);
|
|
8749
|
+
}
|
|
8750
|
+
}, {
|
|
8751
|
+
key: "writeUint32",
|
|
8752
|
+
value: function writeUint32(value) {
|
|
8753
|
+
this.checkSize(4);
|
|
8754
|
+
this.view.setUint32(this.offset, toInt(value), this.isLittleEndian);
|
|
8755
|
+
return this.increment(4);
|
|
8756
|
+
}
|
|
8757
|
+
}, {
|
|
8758
|
+
key: "writeInt32",
|
|
8759
|
+
value: function writeInt32(value) {
|
|
8760
|
+
this.checkSize(4);
|
|
8761
|
+
this.view.setInt32(this.offset, toInt(value), this.isLittleEndian);
|
|
8762
|
+
return this.increment(4);
|
|
8763
|
+
}
|
|
8764
|
+
}, {
|
|
8765
|
+
key: "writeBigUint64",
|
|
8766
|
+
value: function writeBigUint64(value) {
|
|
8767
|
+
this.checkSize(8);
|
|
8768
|
+
this.view.setBigUint64(this.offset, value, this.isLittleEndian);
|
|
8769
|
+
return this.increment(8);
|
|
8770
|
+
}
|
|
8771
|
+
}, {
|
|
8772
|
+
key: "writeFloat",
|
|
8773
|
+
value: function writeFloat(value) {
|
|
8774
|
+
this.checkSize(4);
|
|
8775
|
+
this.view.setFloat32(this.offset, toFloat(value), this.isLittleEndian);
|
|
8776
|
+
return this.increment(4);
|
|
8777
|
+
}
|
|
8778
|
+
}, {
|
|
8779
|
+
key: "writeDouble",
|
|
8780
|
+
value: function writeDouble(value) {
|
|
8781
|
+
this.checkSize(8);
|
|
8782
|
+
this.view.setFloat64(this.offset, toFloat(value), this.isLittleEndian);
|
|
8783
|
+
return this.increment(8);
|
|
8784
|
+
}
|
|
8785
|
+
}, {
|
|
8786
|
+
key: "writeUTF8String",
|
|
8787
|
+
value: function writeUTF8String(value) {
|
|
8788
|
+
// an empty (null) value is empty text, as in writeAsciiString; a
|
|
8789
|
+
// number in a text VR is written as its text
|
|
8790
|
+
var encodedString = this.encoder.encode(String(value !== null && value !== void 0 ? value : ""));
|
|
8791
|
+
this.checkSize(encodedString.byteLength);
|
|
8792
|
+
this.view.writeBuffer(encodedString, this.offset);
|
|
8793
|
+
return this.increment(encodedString.byteLength);
|
|
8794
|
+
}
|
|
8795
|
+
}, {
|
|
8796
|
+
key: "writeAsciiString",
|
|
8797
|
+
value: function writeAsciiString(value) {
|
|
8798
|
+
value = value || "";
|
|
8799
|
+
var len = value.length;
|
|
8800
|
+
this.checkSize(len);
|
|
8801
|
+
var startOffset = this.offset;
|
|
8802
|
+
for (var i = 0; i < len; i++) {
|
|
8803
|
+
var charCode = value.charCodeAt(i);
|
|
8804
|
+
this.view.setUint8(startOffset + i, charCode);
|
|
8805
|
+
}
|
|
8806
|
+
return this.increment(len);
|
|
8807
|
+
}
|
|
9483
8808
|
|
|
9484
|
-
|
|
8809
|
+
/**
|
|
8810
|
+
* Appends raw, already-encoded bytes (e.g. a deflated body) at the
|
|
8811
|
+
* current write position and returns the number of bytes written.
|
|
8812
|
+
*/
|
|
8813
|
+
}, {
|
|
8814
|
+
key: "writeRawBytes",
|
|
8815
|
+
value: function writeRawBytes(bytes) {
|
|
8816
|
+
var length = bytes.byteLength;
|
|
8817
|
+
if (length === 0) {
|
|
8818
|
+
return 0;
|
|
8819
|
+
}
|
|
8820
|
+
this.checkSize(length);
|
|
8821
|
+
this.view.writeBuffer(bytes, this.offset);
|
|
8822
|
+
return this.increment(length);
|
|
8823
|
+
}
|
|
8824
|
+
}, {
|
|
8825
|
+
key: "readBigUint64",
|
|
8826
|
+
value: function readBigUint64() {
|
|
8827
|
+
var val = this.view.getBigUint64(this.offset, this.isLittleEndian);
|
|
8828
|
+
this.increment(8);
|
|
8829
|
+
return val;
|
|
8830
|
+
}
|
|
8831
|
+
}, {
|
|
8832
|
+
key: "readUint32",
|
|
8833
|
+
value: function readUint32() {
|
|
8834
|
+
var val = this.view.getUint32(this.offset, this.isLittleEndian);
|
|
8835
|
+
this.increment(4);
|
|
8836
|
+
return val;
|
|
8837
|
+
}
|
|
8838
|
+
}, {
|
|
8839
|
+
key: "readUint16",
|
|
8840
|
+
value: function readUint16() {
|
|
8841
|
+
var val = this.view.getUint16(this.offset, this.isLittleEndian);
|
|
8842
|
+
this.increment(2);
|
|
8843
|
+
return val;
|
|
8844
|
+
}
|
|
8845
|
+
}, {
|
|
8846
|
+
key: "readUint8",
|
|
8847
|
+
value: function readUint8() {
|
|
8848
|
+
var val = this.view.getUint8(this.offset);
|
|
8849
|
+
this.increment(1);
|
|
8850
|
+
return val;
|
|
8851
|
+
}
|
|
8852
|
+
}, {
|
|
8853
|
+
key: "peekUint8",
|
|
8854
|
+
value: function peekUint8(offset) {
|
|
8855
|
+
return this.view.getUint8(this.offset + offset);
|
|
8856
|
+
}
|
|
8857
|
+
}, {
|
|
8858
|
+
key: "readUint8Array",
|
|
8859
|
+
value: function readUint8Array(length) {
|
|
8860
|
+
if (this.offset + length > this.endOffset) {
|
|
8861
|
+
throw new Error("Stream has insufficient data: requested ".concat(length, " bytes at offset ").concat(this.offset, ", but only ").concat(this.endOffset - this.offset, " bytes available (endOffset ").concat(this.endOffset, ")"));
|
|
8862
|
+
}
|
|
8863
|
+
var arr = new Uint8Array(this.view.slice(this.offset, this.offset + length));
|
|
8864
|
+
this.increment(length);
|
|
8865
|
+
return arr;
|
|
8866
|
+
}
|
|
8867
|
+
}, {
|
|
8868
|
+
key: "readArrayBuffer",
|
|
8869
|
+
value: function readArrayBuffer(length) {
|
|
8870
|
+
return this.readUint8Array(length).buffer;
|
|
8871
|
+
}
|
|
8872
|
+
}, {
|
|
8873
|
+
key: "readUint16Array",
|
|
8874
|
+
value: function readUint16Array(length) {
|
|
8875
|
+
var sixlen = length / 2,
|
|
8876
|
+
arr = new Uint16Array(sixlen),
|
|
8877
|
+
i = 0;
|
|
8878
|
+
while (i++ < sixlen) {
|
|
8879
|
+
arr[i] = this.view.getUint16(this.offset, this.isLittleEndian);
|
|
8880
|
+
this.offset += 2;
|
|
8881
|
+
}
|
|
8882
|
+
return arr;
|
|
8883
|
+
}
|
|
8884
|
+
}, {
|
|
8885
|
+
key: "readInt8",
|
|
8886
|
+
value: function readInt8() {
|
|
8887
|
+
var val = this.view.getInt8(this.offset, this.isLittleEndian);
|
|
8888
|
+
this.increment(1);
|
|
8889
|
+
return val;
|
|
8890
|
+
}
|
|
8891
|
+
}, {
|
|
8892
|
+
key: "readInt16",
|
|
8893
|
+
value: function readInt16() {
|
|
8894
|
+
var val = this.view.getInt16(this.offset, this.isLittleEndian);
|
|
8895
|
+
this.increment(2);
|
|
8896
|
+
return val;
|
|
8897
|
+
}
|
|
8898
|
+
}, {
|
|
8899
|
+
key: "readInt32",
|
|
8900
|
+
value: function readInt32() {
|
|
8901
|
+
var val = this.view.getInt32(this.offset, this.isLittleEndian);
|
|
8902
|
+
this.increment(4);
|
|
8903
|
+
return val;
|
|
8904
|
+
}
|
|
8905
|
+
}, {
|
|
8906
|
+
key: "readFloat",
|
|
8907
|
+
value: function readFloat() {
|
|
8908
|
+
var val = this.view.getFloat32(this.offset, this.isLittleEndian);
|
|
8909
|
+
this.increment(4);
|
|
8910
|
+
return val;
|
|
8911
|
+
}
|
|
8912
|
+
}, {
|
|
8913
|
+
key: "readDouble",
|
|
8914
|
+
value: function readDouble() {
|
|
8915
|
+
var val = this.view.getFloat64(this.offset, this.isLittleEndian);
|
|
8916
|
+
this.increment(8);
|
|
8917
|
+
return val;
|
|
8918
|
+
}
|
|
8919
|
+
}, {
|
|
8920
|
+
key: "readAsciiString",
|
|
8921
|
+
value: function readAsciiString(length) {
|
|
8922
|
+
var result = "";
|
|
8923
|
+
var start = this.offset;
|
|
8924
|
+
var end = this.offset + length;
|
|
8925
|
+
if (end >= this.view.byteLength) {
|
|
8926
|
+
end = this.view.byteLength;
|
|
8927
|
+
}
|
|
8928
|
+
for (var i = start; i < end; ++i) {
|
|
8929
|
+
result += String.fromCharCode(this.view.getUint8(i));
|
|
8930
|
+
}
|
|
8931
|
+
this.increment(end - start);
|
|
8932
|
+
return result;
|
|
8933
|
+
}
|
|
8934
|
+
}, {
|
|
8935
|
+
key: "readVR",
|
|
8936
|
+
value: function readVR() {
|
|
8937
|
+
var vr = String.fromCharCode(this.view.getUint8(this.offset)) + String.fromCharCode(this.view.getUint8(this.offset + 1));
|
|
8938
|
+
this.increment(2);
|
|
8939
|
+
return vr;
|
|
8940
|
+
}
|
|
8941
|
+
}, {
|
|
8942
|
+
key: "readEncodedString",
|
|
8943
|
+
value: function readEncodedString(length) {
|
|
8944
|
+
if (this.offset + length >= this.view.byteLength) {
|
|
8945
|
+
length = this.view.byteLength - this.offset;
|
|
8946
|
+
}
|
|
8947
|
+
var view = new DataView(this.slice(this.offset, this.offset + length));
|
|
8948
|
+
var result = this.decoder.decode(view);
|
|
8949
|
+
this.increment(length);
|
|
8950
|
+
return result;
|
|
8951
|
+
}
|
|
8952
|
+
}, {
|
|
8953
|
+
key: "readHex",
|
|
8954
|
+
value: function readHex(length) {
|
|
8955
|
+
var hexString = "";
|
|
8956
|
+
for (var i = 0; i < length; i++) {
|
|
8957
|
+
hexString += this.readUint8().toString(16);
|
|
8958
|
+
}
|
|
8959
|
+
return hexString;
|
|
8960
|
+
}
|
|
8961
|
+
}, {
|
|
8962
|
+
key: "checkSize",
|
|
8963
|
+
value: function checkSize(step) {
|
|
8964
|
+
this.view.checkSize(this.offset + step);
|
|
8965
|
+
}
|
|
9485
8966
|
|
|
9486
|
-
|
|
9487
|
-
|
|
8967
|
+
/**
|
|
8968
|
+
* Concatenates the stream, starting from the startOffset (to allow concat
|
|
8969
|
+
* on an existing output from the beginning)
|
|
8970
|
+
*/
|
|
8971
|
+
}, {
|
|
8972
|
+
key: "concat",
|
|
8973
|
+
value: function concat(stream) {
|
|
8974
|
+
var length = stream.size - stream.startOffset;
|
|
8975
|
+
this.view.checkSize(this.size + length);
|
|
8976
|
+
this.view.writeBuffer(new Uint8Array(stream.slice(stream.startOffset, stream.size)), this.offset);
|
|
8977
|
+
this.offset += length;
|
|
8978
|
+
this.size = this.offset;
|
|
8979
|
+
this.endOffset = this.size;
|
|
8980
|
+
return this.view.availableSize;
|
|
8981
|
+
}
|
|
8982
|
+
}, {
|
|
8983
|
+
key: "increment",
|
|
8984
|
+
value: function increment(step) {
|
|
8985
|
+
this.offset += step;
|
|
8986
|
+
if (this.offset > this.size) {
|
|
8987
|
+
this.size = this.offset;
|
|
8988
|
+
}
|
|
8989
|
+
return step;
|
|
8990
|
+
}
|
|
9488
8991
|
|
|
9489
|
-
|
|
8992
|
+
/**
|
|
8993
|
+
* Reads from an async stream delivering to addBuffer. Each chunk is
|
|
8994
|
+
* copied, also a plain ArrayBuffer, so the producer may reuse it.
|
|
8995
|
+
*/
|
|
8996
|
+
}, {
|
|
8997
|
+
key: "fromAsyncStream",
|
|
8998
|
+
value: (function () {
|
|
8999
|
+
var _fromAsyncStream = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(stream) {
|
|
9000
|
+
var _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, chunk, _t;
|
|
9001
|
+
return _regeneratorRuntime().wrap(function (_context) {
|
|
9002
|
+
while (1) switch (_context.prev = _context.next) {
|
|
9003
|
+
case 0:
|
|
9004
|
+
_iteratorAbruptCompletion = false;
|
|
9005
|
+
_didIteratorError = false;
|
|
9006
|
+
_context.prev = 1;
|
|
9007
|
+
_iterator = _asyncIterator(stream);
|
|
9008
|
+
case 2:
|
|
9009
|
+
_context.next = 3;
|
|
9010
|
+
return _iterator.next();
|
|
9011
|
+
case 3:
|
|
9012
|
+
if (!(_iteratorAbruptCompletion = !(_step = _context.sent).done)) {
|
|
9013
|
+
_context.next = 5;
|
|
9014
|
+
break;
|
|
9015
|
+
}
|
|
9016
|
+
chunk = _step.value;
|
|
9017
|
+
this.addBuffer(chunk, {
|
|
9018
|
+
transfer: false
|
|
9019
|
+
});
|
|
9020
|
+
case 4:
|
|
9021
|
+
_iteratorAbruptCompletion = false;
|
|
9022
|
+
_context.next = 2;
|
|
9023
|
+
break;
|
|
9024
|
+
case 5:
|
|
9025
|
+
_context.next = 7;
|
|
9026
|
+
break;
|
|
9027
|
+
case 6:
|
|
9028
|
+
_context.prev = 6;
|
|
9029
|
+
_t = _context["catch"](1);
|
|
9030
|
+
_didIteratorError = true;
|
|
9031
|
+
_iteratorError = _t;
|
|
9032
|
+
case 7:
|
|
9033
|
+
_context.prev = 7;
|
|
9034
|
+
_context.prev = 8;
|
|
9035
|
+
if (!(_iteratorAbruptCompletion && _iterator.return != null)) {
|
|
9036
|
+
_context.next = 9;
|
|
9037
|
+
break;
|
|
9038
|
+
}
|
|
9039
|
+
_context.next = 9;
|
|
9040
|
+
return _iterator.return();
|
|
9041
|
+
case 9:
|
|
9042
|
+
_context.prev = 9;
|
|
9043
|
+
if (!_didIteratorError) {
|
|
9044
|
+
_context.next = 10;
|
|
9045
|
+
break;
|
|
9046
|
+
}
|
|
9047
|
+
throw _iteratorError;
|
|
9048
|
+
case 10:
|
|
9049
|
+
return _context.finish(9);
|
|
9050
|
+
case 11:
|
|
9051
|
+
return _context.finish(7);
|
|
9052
|
+
case 12:
|
|
9053
|
+
this.setComplete();
|
|
9054
|
+
case 13:
|
|
9055
|
+
case "end":
|
|
9056
|
+
return _context.stop();
|
|
9057
|
+
}
|
|
9058
|
+
}, _callee, this, [[1, 6, 7, 12], [8,, 9, 11]]);
|
|
9059
|
+
}));
|
|
9060
|
+
function fromAsyncStream(_x) {
|
|
9061
|
+
return _fromAsyncStream.apply(this, arguments);
|
|
9062
|
+
}
|
|
9063
|
+
return fromAsyncStream;
|
|
9064
|
+
}()
|
|
9065
|
+
/**
|
|
9066
|
+
* Adds the buffer to the end of the current buffers list,
|
|
9067
|
+
* updating the size etc.
|
|
9068
|
+
*
|
|
9069
|
+
* A typed array or DataView (for example a Node.js Buffer) adds only
|
|
9070
|
+
* the bytes of the view, and not the full underlying ArrayBuffer.
|
|
9071
|
+
*
|
|
9072
|
+
* @param {*} buffer an ArrayBuffer, or a typed array or DataView
|
|
9073
|
+
* @param {*} options.start byte offset for the start of the new buffer
|
|
9074
|
+
* to use, relative to the start of the view, clamped to the view
|
|
9075
|
+
* @param {*} options.end byte offset for the end of the buffer to use,
|
|
9076
|
+
* relative to the start of the view, clamped to the view
|
|
9077
|
+
* @param {*} options.transfer keeps a reference to the ArrayBuffer
|
|
9078
|
+
* instead of a copy, and the caller must not change the buffer
|
|
9079
|
+
* afterwards. It does not detach the buffer. It applies only when
|
|
9080
|
+
* the range covers the whole ArrayBuffer, so a partial view or range
|
|
9081
|
+
* is always copied. The default is true for an ArrayBuffer, and
|
|
9082
|
+
* false for a view. Set it to false to force a copy.
|
|
9083
|
+
*/
|
|
9084
|
+
)
|
|
9085
|
+
}, {
|
|
9086
|
+
key: "addBuffer",
|
|
9087
|
+
value: function addBuffer(buffer) {
|
|
9088
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
9089
|
+
if (!buffer) {
|
|
9090
|
+
// Silently ignore null buffers.
|
|
9091
|
+
return;
|
|
9092
|
+
}
|
|
9093
|
+
this.view.addBuffer(buffer, options);
|
|
9094
|
+
this.size = this.view.size;
|
|
9095
|
+
this.endOffset = this.size;
|
|
9096
|
+
this.notifyAvailableListeners();
|
|
9097
|
+
return this.size;
|
|
9098
|
+
}
|
|
9099
|
+
}, {
|
|
9100
|
+
key: "notifyAvailableListeners",
|
|
9101
|
+
value: function notifyAvailableListeners() {
|
|
9102
|
+
var existingListeners = _toConsumableArray(this.availableListeners);
|
|
9103
|
+
this.availableListeners.splice(0, this.availableListeners.length);
|
|
9104
|
+
existingListeners.forEach(function (listener) {
|
|
9105
|
+
return listener();
|
|
9106
|
+
});
|
|
9107
|
+
}
|
|
9490
9108
|
|
|
9491
|
-
|
|
9492
|
-
|
|
9493
|
-
|
|
9494
|
-
|
|
9495
|
-
|
|
9496
|
-
|
|
9497
|
-
|
|
9498
|
-
|
|
9499
|
-
|
|
9109
|
+
/**
|
|
9110
|
+
* Consumes the data up to the given offset.
|
|
9111
|
+
* This will clear the references to the data buffers, and will
|
|
9112
|
+
* cause resets etc to fail.
|
|
9113
|
+
* The default offset is the current position, so everything already read.
|
|
9114
|
+
*/
|
|
9115
|
+
}, {
|
|
9116
|
+
key: "consume",
|
|
9117
|
+
value: function consume() {
|
|
9118
|
+
var offset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.offset;
|
|
9119
|
+
if (!this.clearBuffers) {
|
|
9120
|
+
return;
|
|
9121
|
+
}
|
|
9122
|
+
this.view.consume(offset);
|
|
9123
|
+
this.notifyRelayListeners();
|
|
9124
|
+
}
|
|
9500
9125
|
|
|
9501
|
-
|
|
9502
|
-
|
|
9503
|
-
|
|
9504
|
-
|
|
9505
|
-
|
|
9126
|
+
/**
|
|
9127
|
+
* Returns true if the stream has data in the given range.
|
|
9128
|
+
*/
|
|
9129
|
+
}, {
|
|
9130
|
+
key: "hasData",
|
|
9131
|
+
value: function hasData(start) {
|
|
9132
|
+
var end = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : start + 1;
|
|
9133
|
+
return this.view.hasData(start, end);
|
|
9134
|
+
}
|
|
9135
|
+
}, {
|
|
9136
|
+
key: "more",
|
|
9137
|
+
value: function more(length) {
|
|
9138
|
+
if (this.offset + length > this.endOffset) {
|
|
9139
|
+
throw new Error("Request more than currently allocated buffer");
|
|
9140
|
+
}
|
|
9506
9141
|
|
|
9507
|
-
|
|
9508
|
-
|
|
9509
|
-
|
|
9142
|
+
// Optimize the more implementation to choose between a slice and
|
|
9143
|
+
// a sub-string reference to the original set of views.
|
|
9144
|
+
// const newBuf = new ReadBufferStream(this.buffer, {
|
|
9145
|
+
// start: this.offset,
|
|
9146
|
+
// stop: this.offset + length
|
|
9147
|
+
// });
|
|
9148
|
+
var newBuf = new ReadBufferStream(this.slice(this.offset, this.offset + length));
|
|
9149
|
+
this.increment(length);
|
|
9150
|
+
newBuf.setComplete();
|
|
9151
|
+
return newBuf;
|
|
9152
|
+
}
|
|
9153
|
+
}, {
|
|
9154
|
+
key: "reset",
|
|
9155
|
+
value: function reset() {
|
|
9156
|
+
this.offset = 0;
|
|
9157
|
+
return this;
|
|
9158
|
+
}
|
|
9159
|
+
}, {
|
|
9160
|
+
key: "end",
|
|
9161
|
+
value: function end() {
|
|
9162
|
+
return this.isComplete && this.offset >= this.end;
|
|
9163
|
+
}
|
|
9164
|
+
}, {
|
|
9165
|
+
key: "toEnd",
|
|
9166
|
+
value: function toEnd() {
|
|
9167
|
+
this.offset = this.view.byteLength;
|
|
9168
|
+
}
|
|
9510
9169
|
|
|
9511
|
-
|
|
9512
|
-
|
|
9513
|
-
|
|
9514
|
-
|
|
9515
|
-
|
|
9516
|
-
|
|
9170
|
+
/**
|
|
9171
|
+
* Reports on the amount of memory held by the buffers in the view.
|
|
9172
|
+
* @returns {Object} An object containing:
|
|
9173
|
+
* - bufferCount: Number of buffers still held (not null)
|
|
9174
|
+
* - totalSize: Total logical span of all buffers in bytes (each
|
|
9175
|
+
* buffer counts its own view span, not its backing ArrayBuffer)
|
|
9176
|
+
* - consumeOffset: The current consume offset
|
|
9177
|
+
* - buffersBeforeOffset: Number of buffers before the consume offset
|
|
9178
|
+
*/
|
|
9179
|
+
}, {
|
|
9180
|
+
key: "getBufferMemoryInfo",
|
|
9181
|
+
value: function getBufferMemoryInfo() {
|
|
9182
|
+
return this.view.getBufferMemoryInfo(this.offset);
|
|
9183
|
+
}
|
|
9184
|
+
}]);
|
|
9185
|
+
}();
|
|
9517
9186
|
|
|
9518
|
-
|
|
9519
|
-
|
|
9520
|
-
|
|
9521
|
-
|
|
9522
|
-
|
|
9187
|
+
/**
|
|
9188
|
+
* A read stream over an ArrayBuffer, a typed array or Node Buffer, or a
|
|
9189
|
+
* range of another BufferStream.
|
|
9190
|
+
*
|
|
9191
|
+
* A typed array or Node Buffer is a view into a backing ArrayBuffer that
|
|
9192
|
+
* Node often pools and shares. The stream adopts exactly the viewed byte
|
|
9193
|
+
* range, at logical offset 0. If the stream adopted buffer.buffer whole, it
|
|
9194
|
+
* would alias the other data in the pool. The Node-only Buffer.offset
|
|
9195
|
+
* property (its byteOffset) does not set the read offset.
|
|
9196
|
+
*
|
|
9197
|
+
* The 0.x form `(buffer, littleEndian, options)` still works, as in 0.x,
|
|
9198
|
+
* with a one-time warning.
|
|
9199
|
+
*/
|
|
9200
|
+
var ReadBufferStream = /*#__PURE__*/function (_BufferStream2) {
|
|
9201
|
+
/**
|
|
9202
|
+
* @param {ArrayBuffer|ArrayBufferView|BufferStream|null} buffer
|
|
9203
|
+
* @param {{littleEndian?: boolean, start?: number, stop?: number, noCopy?: boolean, clearBuffers?: boolean}} [options]
|
|
9204
|
+
*/
|
|
9205
|
+
function ReadBufferStream(buffer, options, legacyOptions) {
|
|
9206
|
+
var _this3;
|
|
9207
|
+
_classCallCheck(this, ReadBufferStream);
|
|
9208
|
+
// any explicit non-object 2nd argument is the 0.x byte order
|
|
9209
|
+
if (arguments.length >= 2 && (options === null || _typeof(options) !== "object")) {
|
|
9210
|
+
warnLegacyConstructor("ReadBufferStream", "new ReadBufferStream(buffer, { littleEndian, start, stop, noCopy, clearBuffers })");
|
|
9211
|
+
options = _objectSpread2(_objectSpread2({}, legacyOptions), {}, {
|
|
9212
|
+
littleEndian: !!options
|
|
9213
|
+
});
|
|
9214
|
+
}
|
|
9215
|
+
options = options !== null && options !== void 0 ? options : {};
|
|
9216
|
+
var _options = options,
|
|
9217
|
+
_options$littleEndian2 = _options.littleEndian,
|
|
9218
|
+
littleEndian = _options$littleEndian2 === void 0 ? true : _options$littleEndian2,
|
|
9219
|
+
start = _options.start,
|
|
9220
|
+
stop = _options.stop,
|
|
9221
|
+
_options$noCopy = _options.noCopy,
|
|
9222
|
+
noCopy = _options$noCopy === void 0 ? false : _options$noCopy,
|
|
9223
|
+
_options$clearBuffers = _options.clearBuffers,
|
|
9224
|
+
clearBuffers = _options$clearBuffers === void 0 ? false : _options$clearBuffers,
|
|
9225
|
+
rest = _objectWithoutProperties(_options, _excluded);
|
|
9226
|
+
_this3 = _callSuper(this, ReadBufferStream, [_objectSpread2(_objectSpread2({}, rest), {}, {
|
|
9227
|
+
littleEndian: littleEndian,
|
|
9228
|
+
clearBuffers: clearBuffers
|
|
9229
|
+
})]);
|
|
9230
|
+
_this3.noCopy = noCopy;
|
|
9231
|
+
_this3.decoder = new TextDecoder("latin1");
|
|
9232
|
+
if (buffer instanceof BufferStream) {
|
|
9233
|
+
_this3.view.from(buffer.view, options);
|
|
9234
|
+
_this3.isComplete = true;
|
|
9235
|
+
} else if (buffer) {
|
|
9236
|
+
// a view adds only its viewed byte range (SplitDataView.addBuffer)
|
|
9237
|
+
_this3.view.addBuffer(buffer);
|
|
9238
|
+
_this3.isComplete = true;
|
|
9239
|
+
}
|
|
9240
|
+
// a source BufferStream's offset is the sub-stream start; a Node
|
|
9241
|
+
// Buffer's own `offset` property is ignored (see class doc comment)
|
|
9242
|
+
_this3.offset = start !== null && start !== void 0 ? start : buffer instanceof BufferStream ? buffer.offset : 0;
|
|
9243
|
+
_this3.size = stop || (buffer === null || buffer === void 0 ? void 0 : buffer.size) || (buffer === null || buffer === void 0 ? void 0 : buffer.byteLength) || 0;
|
|
9244
|
+
_this3.startOffset = _this3.offset;
|
|
9245
|
+
_this3.endOffset = _this3.size;
|
|
9246
|
+
return _this3;
|
|
9247
|
+
}
|
|
9248
|
+
_inherits(ReadBufferStream, _BufferStream2);
|
|
9249
|
+
return _createClass(ReadBufferStream, [{
|
|
9250
|
+
key: "setDecoder",
|
|
9251
|
+
value: function setDecoder(decoder) {
|
|
9252
|
+
this.decoder = decoder;
|
|
9253
|
+
}
|
|
9254
|
+
}, {
|
|
9255
|
+
key: "reset",
|
|
9256
|
+
value: function reset() {
|
|
9257
|
+
this.offset = this.startOffset;
|
|
9258
|
+
return this;
|
|
9259
|
+
}
|
|
9260
|
+
}, {
|
|
9261
|
+
key: "end",
|
|
9262
|
+
value: function end() {
|
|
9263
|
+
return this.isComplete && this.offset >= this.endOffset;
|
|
9264
|
+
}
|
|
9265
|
+
}, {
|
|
9266
|
+
key: "toEnd",
|
|
9267
|
+
value: function toEnd() {
|
|
9268
|
+
this.offset = this.endOffset;
|
|
9269
|
+
}
|
|
9270
|
+
}, {
|
|
9271
|
+
key: "writeUint8",
|
|
9272
|
+
value: function writeUint8(value) {
|
|
9273
|
+
throw new Error(value, "writeUint8 not implemented");
|
|
9274
|
+
}
|
|
9275
|
+
}, {
|
|
9276
|
+
key: "writeUint8Repeat",
|
|
9277
|
+
value: function writeUint8Repeat(value, count) {
|
|
9278
|
+
throw new Error("writeUint8Repeat not implemented (value: ".concat(value, ", count: ").concat(count, ")"));
|
|
9279
|
+
}
|
|
9280
|
+
}, {
|
|
9281
|
+
key: "writeInt8",
|
|
9282
|
+
value: function writeInt8(value) {
|
|
9283
|
+
throw new Error(value, "writeInt8 not implemented");
|
|
9284
|
+
}
|
|
9285
|
+
}, {
|
|
9286
|
+
key: "writeUint16",
|
|
9287
|
+
value: function writeUint16(value) {
|
|
9288
|
+
throw new Error(value, "writeUint16 not implemented");
|
|
9289
|
+
}
|
|
9290
|
+
}, {
|
|
9291
|
+
key: "writeTwoUint16s",
|
|
9292
|
+
value: function writeTwoUint16s(value) {
|
|
9293
|
+
throw new Error(value, "writeTwoUint16s not implemented");
|
|
9294
|
+
}
|
|
9295
|
+
}, {
|
|
9296
|
+
key: "writeInt16",
|
|
9297
|
+
value: function writeInt16(value) {
|
|
9298
|
+
throw new Error(value, "writeInt16 not implemented");
|
|
9299
|
+
}
|
|
9300
|
+
}, {
|
|
9301
|
+
key: "writeUint32",
|
|
9302
|
+
value: function writeUint32(value) {
|
|
9303
|
+
throw new Error(value, "writeUint32 not implemented");
|
|
9304
|
+
}
|
|
9305
|
+
}, {
|
|
9306
|
+
key: "writeInt32",
|
|
9307
|
+
value: function writeInt32(value) {
|
|
9308
|
+
throw new Error(value, "writeInt32 not implemented");
|
|
9309
|
+
}
|
|
9310
|
+
}, {
|
|
9311
|
+
key: "writeFloat",
|
|
9312
|
+
value: function writeFloat(value) {
|
|
9313
|
+
throw new Error(value, "writeFloat not implemented");
|
|
9314
|
+
}
|
|
9315
|
+
}, {
|
|
9316
|
+
key: "writeDouble",
|
|
9317
|
+
value: function writeDouble(value) {
|
|
9318
|
+
throw new Error(value, "writeDouble not implemented");
|
|
9319
|
+
}
|
|
9320
|
+
}, {
|
|
9321
|
+
key: "writeAsciiString",
|
|
9322
|
+
value: function writeAsciiString(value) {
|
|
9323
|
+
throw new Error(value, "writeAsciiString not implemented");
|
|
9324
|
+
}
|
|
9325
|
+
}, {
|
|
9326
|
+
key: "writeUTF8String",
|
|
9327
|
+
value: function writeUTF8String(value) {
|
|
9328
|
+
throw new Error(value, "writeUTF8String not implemented");
|
|
9329
|
+
}
|
|
9330
|
+
}, {
|
|
9331
|
+
key: "writeRawBytes",
|
|
9332
|
+
value: function writeRawBytes(bytes) {
|
|
9333
|
+
throw new Error(bytes, "writeRawBytes not implemented");
|
|
9334
|
+
}
|
|
9335
|
+
}, {
|
|
9336
|
+
key: "checkSize",
|
|
9337
|
+
value: function checkSize(step) {
|
|
9338
|
+
throw new Error(step, "checkSize not implemented");
|
|
9339
|
+
}
|
|
9340
|
+
}, {
|
|
9341
|
+
key: "concat",
|
|
9342
|
+
value: function concat(stream) {
|
|
9343
|
+
throw new Error(stream, "concat not implemented");
|
|
9344
|
+
}
|
|
9345
|
+
}]);
|
|
9346
|
+
}(BufferStream);
|
|
9347
|
+
var DeflatedReadBufferStream = /*#__PURE__*/function (_ReadBufferStream) {
|
|
9348
|
+
function DeflatedReadBufferStream(stream, options) {
|
|
9349
|
+
_classCallCheck(this, DeflatedReadBufferStream);
|
|
9350
|
+
var inflatedBuffer = pako.inflateRaw(stream.getBuffer(stream.offset, stream.size));
|
|
9351
|
+
return _callSuper(this, DeflatedReadBufferStream, [inflatedBuffer.buffer, options !== null && options !== void 0 ? options : {}]);
|
|
9352
|
+
}
|
|
9353
|
+
_inherits(DeflatedReadBufferStream, _ReadBufferStream);
|
|
9354
|
+
return _createClass(DeflatedReadBufferStream);
|
|
9355
|
+
}(ReadBufferStream);
|
|
9523
9356
|
|
|
9524
|
-
|
|
9525
|
-
|
|
9526
|
-
|
|
9357
|
+
/**
|
|
9358
|
+
* A growable write stream. The 0.x form `(defaultSize, littleEndian)` still
|
|
9359
|
+
* works, as in 0.x, with a one-time warning.
|
|
9360
|
+
*/
|
|
9361
|
+
var WriteBufferStream = /*#__PURE__*/function (_BufferStream3) {
|
|
9362
|
+
/** @param {{defaultSize?: number, littleEndian?: boolean}} [options] */
|
|
9363
|
+
function WriteBufferStream(options, legacyLittleEndian) {
|
|
9364
|
+
var _this4;
|
|
9365
|
+
_classCallCheck(this, WriteBufferStream);
|
|
9366
|
+
// any explicit non-object argument is the 0.x size hint
|
|
9367
|
+
if (arguments.length >= 1 && (options === null || _typeof(options) !== "object")) {
|
|
9368
|
+
warnLegacyConstructor("WriteBufferStream", "new WriteBufferStream({ defaultSize, littleEndian })");
|
|
9369
|
+
options = {
|
|
9370
|
+
defaultSize: options !== null && options !== void 0 ? options : undefined,
|
|
9371
|
+
littleEndian: !!legacyLittleEndian
|
|
9372
|
+
};
|
|
9373
|
+
}
|
|
9374
|
+
var _ref = options !== null && options !== void 0 ? options : {},
|
|
9375
|
+
defaultSize = _ref.defaultSize,
|
|
9376
|
+
_ref$littleEndian = _ref.littleEndian,
|
|
9377
|
+
littleEndian = _ref$littleEndian === void 0 ? true : _ref$littleEndian;
|
|
9378
|
+
_this4 = _callSuper(this, WriteBufferStream, [{
|
|
9379
|
+
defaultSize: defaultSize,
|
|
9380
|
+
littleEndian: littleEndian
|
|
9381
|
+
}]);
|
|
9382
|
+
_this4.size = 0;
|
|
9383
|
+
return _this4;
|
|
9384
|
+
}
|
|
9385
|
+
_inherits(WriteBufferStream, _BufferStream3);
|
|
9386
|
+
return _createClass(WriteBufferStream);
|
|
9387
|
+
}(BufferStream);
|
|
9527
9388
|
|
|
9528
|
-
|
|
9529
|
-
|
|
9530
|
-
|
|
9389
|
+
/**
|
|
9390
|
+
* The classification of each VR, stored once. ValueRepresentation copies
|
|
9391
|
+
* 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
|
+
* @typedef {Object} VrFlags
|
|
9394
|
+
* @property {boolean} [binary] binary number or tag: isBinary()
|
|
9395
|
+
* @property {boolean} [length32] 32-bit explicit VR length: isLength32()
|
|
9396
|
+
* @property {boolean} [single] never joined on write: !allowMultiple()
|
|
9397
|
+
* @property {boolean} [readSingle] never split on read: singleVRs
|
|
9398
|
+
* @property {boolean} [byteStream] frames/fragments, not a VM: BINARY_VRS
|
|
9399
|
+
*/
|
|
9400
|
+
var SEED = {
|
|
9401
|
+
AT: "binary",
|
|
9402
|
+
FD: "binary",
|
|
9403
|
+
FL: "binary",
|
|
9404
|
+
LT: "readSingle",
|
|
9405
|
+
OB: "length32 single readSingle byteStream",
|
|
9406
|
+
OD: "length32 byteStream",
|
|
9407
|
+
OF: "length32 single readSingle byteStream",
|
|
9408
|
+
OL: "byteStream",
|
|
9409
|
+
OV: "byteStream",
|
|
9410
|
+
OW: "length32 single readSingle byteStream",
|
|
9411
|
+
SL: "binary",
|
|
9412
|
+
SQ: "length32 single readSingle",
|
|
9413
|
+
SS: "binary",
|
|
9414
|
+
UC: "length32",
|
|
9415
|
+
UL: "binary",
|
|
9416
|
+
UN: "length32 single readSingle byteStream",
|
|
9417
|
+
UR: "length32",
|
|
9418
|
+
US: "binary",
|
|
9419
|
+
UT: "length32",
|
|
9420
|
+
UV: "binary length32"
|
|
9421
|
+
};
|
|
9531
9422
|
|
|
9532
|
-
|
|
9533
|
-
|
|
9534
|
-
|
|
9535
|
-
|
|
9536
|
-
|
|
9423
|
+
/** @type {Object<string, VrFlags>} */
|
|
9424
|
+
var vrFlags = Object.fromEntries(Object.entries(SEED).map(function (_ref) {
|
|
9425
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
9426
|
+
code = _ref2[0],
|
|
9427
|
+
names = _ref2[1];
|
|
9428
|
+
return [code, Object.fromEntries(names.split(" ").map(function (name) {
|
|
9429
|
+
return [name, true];
|
|
9430
|
+
}))];
|
|
9431
|
+
}));
|
|
9432
|
+
function codesWith(flag) {
|
|
9433
|
+
return Object.keys(vrFlags).filter(function (code) {
|
|
9434
|
+
return vrFlags[code][flag];
|
|
9435
|
+
});
|
|
9436
|
+
}
|
|
9537
9437
|
|
|
9538
|
-
|
|
9539
|
-
|
|
9540
|
-
_loggersByName[childName].rebuild();
|
|
9541
|
-
}
|
|
9542
|
-
}
|
|
9543
|
-
};
|
|
9438
|
+
/** VRs whose read value is never VM-split on backslashes. */
|
|
9439
|
+
var singleVRs = codesWith("readSingle");
|
|
9544
9440
|
|
|
9545
|
-
|
|
9546
|
-
|
|
9547
|
-
defaultLogger ? defaultLogger.getLevel() : "WARN"
|
|
9548
|
-
);
|
|
9549
|
-
var initialLevel = getPersistedLevel();
|
|
9550
|
-
if (initialLevel != null) {
|
|
9551
|
-
userLevel = normalizeLevel(initialLevel);
|
|
9552
|
-
}
|
|
9553
|
-
replaceLoggingMethods.call(self);
|
|
9554
|
-
}
|
|
9441
|
+
/** Byte-stream VRs: a naturalized value stays a list of frames/fragments. */
|
|
9442
|
+
var BINARY_VRS = new Set(codesWith("byteStream"));
|
|
9555
9443
|
|
|
9556
|
-
|
|
9557
|
-
|
|
9558
|
-
|
|
9559
|
-
|
|
9560
|
-
|
|
9444
|
+
// TransferSyntaxUIDs
|
|
9445
|
+
var IMPLICIT_LITTLE_ENDIAN = "1.2.840.10008.1.2";
|
|
9446
|
+
var EXPLICIT_LITTLE_ENDIAN = "1.2.840.10008.1.2.1";
|
|
9447
|
+
var DEFLATED_EXPLICIT_LITTLE_ENDIAN = "1.2.840.10008.1.2.1.99";
|
|
9448
|
+
var EXPLICIT_BIG_ENDIAN = "1.2.840.10008.1.2.2";
|
|
9561
9449
|
|
|
9562
|
-
|
|
9450
|
+
/**
|
|
9451
|
+
* The raw hex value is the maximum 32 bit unsigned integer,
|
|
9452
|
+
* but this is a potential length value, so suggest using the
|
|
9453
|
+
* canonical UNDEFINED_LENGTH_FIX value of -1 instead
|
|
9454
|
+
*/
|
|
9455
|
+
var UNDEFINED_LENGTH = 0xffffffff;
|
|
9456
|
+
/**
|
|
9457
|
+
* Use a -1 value for the undefined length being fixed as this is consistent
|
|
9458
|
+
* with other usage and can't be confused with a real length.
|
|
9459
|
+
*/
|
|
9460
|
+
var UNDEFINED_LENGTH_FIX = -1;
|
|
9461
|
+
var ITEM_DELIMITATION_LENGTH = 0x00000000;
|
|
9563
9462
|
|
|
9564
|
-
|
|
9565
|
-
|
|
9566
|
-
throw new TypeError("You must supply a name when creating a logger.");
|
|
9567
|
-
}
|
|
9463
|
+
// Delimitation Value
|
|
9464
|
+
var SEQUENCE_DELIMITATION_VALUE = 0x00000000;
|
|
9568
9465
|
|
|
9569
|
-
|
|
9570
|
-
|
|
9571
|
-
|
|
9572
|
-
|
|
9573
|
-
defaultLogger.methodFactory
|
|
9574
|
-
);
|
|
9575
|
-
}
|
|
9576
|
-
return logger;
|
|
9577
|
-
};
|
|
9466
|
+
// Value multiplicity and padding
|
|
9467
|
+
var VM_DELIMITER = 0x5c;
|
|
9468
|
+
var PADDING_NULL = 0x00;
|
|
9469
|
+
var PADDING_SPACE = 0x20;
|
|
9578
9470
|
|
|
9579
|
-
|
|
9580
|
-
|
|
9581
|
-
|
|
9582
|
-
|
|
9583
|
-
window.log === defaultLogger) {
|
|
9584
|
-
window.log = _log;
|
|
9585
|
-
}
|
|
9471
|
+
// PersonName delimeters
|
|
9472
|
+
var PN_COMPONENT_DELIMITER = 0x3d;
|
|
9473
|
+
var SEQUENCE_ITEM_TAG = 0xfffee000;
|
|
9474
|
+
var SEQUENCE_DELIMITER_TAG = 0xfffee0dd;
|
|
9586
9475
|
|
|
9587
|
-
|
|
9588
|
-
|
|
9476
|
+
// Nearly all transfer syntaxes are encapsulated, so record those which are
|
|
9477
|
+
// unencapsulated as the exceptions.
|
|
9478
|
+
var unencapsulatedTransferSyntaxes = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, IMPLICIT_LITTLE_ENDIAN, true), EXPLICIT_BIG_ENDIAN, true), DEFLATED_EXPLICIT_LITTLE_ENDIAN, true), EXPLICIT_LITTLE_ENDIAN, true);
|
|
9589
9479
|
|
|
9590
|
-
|
|
9591
|
-
|
|
9592
|
-
|
|
9480
|
+
// Relocated from DicomMessage.isEncapsulated (which now delegates here) so
|
|
9481
|
+
// Tag.write resolves it over the table above instead of through the
|
|
9482
|
+
// late-binding DicomMessage slot.
|
|
9483
|
+
function isEncapsulatedSyntax(syntax) {
|
|
9484
|
+
return !unencapsulatedTransferSyntaxes[syntax];
|
|
9485
|
+
}
|
|
9593
9486
|
|
|
9594
|
-
|
|
9595
|
-
|
|
9487
|
+
/**
|
|
9488
|
+
* Video transfer syntax UIDs (MPEG2, H.264, H.265)
|
|
9489
|
+
* These transfer syntaxes treat the entire pixel data stream as a single frame
|
|
9490
|
+
* regardless of the number of fragments.
|
|
9491
|
+
*/
|
|
9492
|
+
var videoTransferSyntaxUIDs = new Set(["1.2.840.10008.1.2.4.100",
|
|
9493
|
+
// MPEG2 Main Profile @ Main Level
|
|
9494
|
+
"1.2.840.10008.1.2.4.100.1",
|
|
9495
|
+
// MPEG2 Main Profile @ Main Level (retired)
|
|
9496
|
+
"1.2.840.10008.1.2.4.101",
|
|
9497
|
+
// MPEG2 Main Profile @ High Level
|
|
9498
|
+
"1.2.840.10008.1.2.4.101.1",
|
|
9499
|
+
// MPEG2 Main Profile @ High Level (retired)
|
|
9500
|
+
"1.2.840.10008.1.2.4.102",
|
|
9501
|
+
// MPEG-4 AVC/H.264 High Profile / Level 4.1
|
|
9502
|
+
"1.2.840.10008.1.2.4.102.1",
|
|
9503
|
+
// MPEG-4 AVC/H.264 High Profile / Level 4.1 (retired)
|
|
9504
|
+
"1.2.840.10008.1.2.4.103",
|
|
9505
|
+
// MPEG-4 AVC/H.264 BD-compatible High Profile / Level 4.1
|
|
9506
|
+
"1.2.840.10008.1.2.4.103.1",
|
|
9507
|
+
// MPEG-4 AVC/H.264 BD-compatible High Profile / Level 4.1 (retired)
|
|
9508
|
+
"1.2.840.10008.1.2.4.104",
|
|
9509
|
+
// MPEG-4 AVC/H.264 High Profile / Level 4.2 For 2D Video
|
|
9510
|
+
"1.2.840.10008.1.2.4.104.1",
|
|
9511
|
+
// MPEG-4 AVC/H.264 High Profile / Level 4.2 For 2D Video (retired)
|
|
9512
|
+
"1.2.840.10008.1.2.4.105",
|
|
9513
|
+
// MPEG-4 AVC/H.264 High Profile / Level 4.2 For 3D Video
|
|
9514
|
+
"1.2.840.10008.1.2.4.105.1",
|
|
9515
|
+
// MPEG-4 AVC/H.264 High Profile / Level 4.2 For 3D Video (retired)
|
|
9516
|
+
"1.2.840.10008.1.2.4.106",
|
|
9517
|
+
// MPEG-4 AVC/H.264 Stereo High Profile / Level 4.2
|
|
9518
|
+
"1.2.840.10008.1.2.4.106.1",
|
|
9519
|
+
// MPEG-4 AVC/H.264 Stereo High Profile / Level 4.2 (retired)
|
|
9520
|
+
"1.2.840.10008.1.2.4.107",
|
|
9521
|
+
// HEVC/H.265 Main Profile / Level 5.1
|
|
9522
|
+
"1.2.840.10008.1.2.4.108" // HEVC/H.265 Main 10 Profile / Level 5.1
|
|
9523
|
+
]);
|
|
9596
9524
|
|
|
9597
|
-
|
|
9598
|
-
|
|
9599
|
-
|
|
9600
|
-
|
|
9525
|
+
/**
|
|
9526
|
+
* Checks if a transfer syntax UID is a video transfer syntax
|
|
9527
|
+
* @param {string} uid - Transfer syntax UID to check
|
|
9528
|
+
* @returns {boolean} - True if the UID is a video transfer syntax
|
|
9529
|
+
*/
|
|
9530
|
+
function isVideoTransferSyntax(uid) {
|
|
9531
|
+
return uid && videoTransferSyntaxUIDs.has(uid);
|
|
9601
9532
|
}
|
|
9602
9533
|
|
|
9603
|
-
|
|
9604
|
-
|
|
9534
|
+
/**
|
|
9535
|
+
* This is an enumeration of some HEX values for the tag strings, used to replace
|
|
9536
|
+
* constants in a few places.
|
|
9537
|
+
*/
|
|
9538
|
+
var TagHex = {
|
|
9539
|
+
Item: "FFFEE000",
|
|
9540
|
+
ItemDelimitationEnd: "FFFEE00D",
|
|
9541
|
+
SequenceDelimitationEnd: "FFFEE0DD",
|
|
9542
|
+
PixelData: "7FE00010",
|
|
9543
|
+
FileMetaInformationGroupLength: "00020000",
|
|
9544
|
+
TransferSyntaxUID: "00020010",
|
|
9545
|
+
Rows: "00280010",
|
|
9546
|
+
Columns: "00280011",
|
|
9547
|
+
SamplesPerPixel: "00280002",
|
|
9548
|
+
BitsAllocated: "00280100",
|
|
9549
|
+
NumberOfFrames: "00280008",
|
|
9550
|
+
SpecificCharacterSet: "00080005",
|
|
9551
|
+
PixelRepresentation: "00280103",
|
|
9552
|
+
DataSetTrailingPadding: "FFFCFFFC",
|
|
9553
|
+
StudyInstanceUID: "0020000D",
|
|
9554
|
+
SeriesInstanceUID: "0020000E",
|
|
9555
|
+
SOPInstanceUID: "00080018",
|
|
9556
|
+
TimezoneOffsetFromUTC: "00080201",
|
|
9557
|
+
AvailableTransferSyntaxUID: "00083002",
|
|
9558
|
+
MediaStorageSOPInstanceUID: "00020003",
|
|
9559
|
+
MediaStorageSOPClassUID: "00020002"
|
|
9560
|
+
};
|
|
9561
|
+
var encodingMapping = {
|
|
9562
|
+
"": "iso-8859-1",
|
|
9563
|
+
"iso-ir-6": "iso-8859-1",
|
|
9564
|
+
"iso-ir-13": "shift-jis",
|
|
9565
|
+
"iso-ir-100": "latin1",
|
|
9566
|
+
"iso-ir-101": "iso-8859-2",
|
|
9567
|
+
"iso-ir-109": "iso-8859-3",
|
|
9568
|
+
"iso-ir-110": "iso-8859-4",
|
|
9569
|
+
"iso-ir-126": "iso-ir-126",
|
|
9570
|
+
"iso-ir-127": "iso-ir-127",
|
|
9571
|
+
"iso-ir-138": "iso-ir-138",
|
|
9572
|
+
"iso-ir-144": "iso-ir-144",
|
|
9573
|
+
"iso-ir-148": "iso-ir-148",
|
|
9574
|
+
"iso-ir-166": "tis-620",
|
|
9575
|
+
"iso-2022-ir-6": "iso-8859-1",
|
|
9576
|
+
"iso-2022-ir-13": "shift-jis",
|
|
9577
|
+
"iso-2022-ir-87": "iso-2022-jp",
|
|
9578
|
+
"iso-2022-ir-100": "latin1",
|
|
9579
|
+
"iso-2022-ir-101": "iso-8859-2",
|
|
9580
|
+
"iso-2022-ir-109": "iso-8859-3",
|
|
9581
|
+
"iso-2022-ir-110": "iso-8859-4",
|
|
9582
|
+
"iso-2022-ir-126": "iso-ir-126",
|
|
9583
|
+
"iso-2022-ir-127": "iso-ir-127",
|
|
9584
|
+
"iso-2022-ir-138": "iso-ir-138",
|
|
9585
|
+
"iso-2022-ir-144": "iso-ir-144",
|
|
9586
|
+
"iso-2022-ir-148": "iso-ir-148",
|
|
9587
|
+
"iso-2022-ir-149": "euc-kr",
|
|
9588
|
+
"iso-2022-ir-159": "iso-2022-jp",
|
|
9589
|
+
"iso-2022-ir-166": "tis-620",
|
|
9590
|
+
"iso-2022-ir-58": "iso-ir-58",
|
|
9591
|
+
"iso-ir-192": "utf-8",
|
|
9592
|
+
gb18030: "gb18030",
|
|
9593
|
+
"iso-2022-gbk": "gbk",
|
|
9594
|
+
"iso-2022-58": "gb2312",
|
|
9595
|
+
gbk: "gbk"
|
|
9596
|
+
};
|
|
9605
9597
|
|
|
9606
|
-
|
|
9598
|
+
/**
|
|
9599
|
+
* Maps DICOM tag hex strings to their normalized lower camelCase names
|
|
9600
|
+
* for use in listener.information tracking
|
|
9601
|
+
*/
|
|
9602
|
+
var TAG_NAME_MAP = {
|
|
9603
|
+
"0020000D": "studyInstanceUid",
|
|
9604
|
+
"0020000E": "seriesInstanceUid",
|
|
9605
|
+
"00080018": "sopInstanceUid",
|
|
9606
|
+
"00020010": "transferSyntaxUid",
|
|
9607
|
+
"00083002": "availableTransferSyntaxUid",
|
|
9608
|
+
"00080201": "timezoneOffsetFromUtc",
|
|
9609
|
+
"00080005": "specificCharacterSet",
|
|
9610
|
+
"00280008": "numberOfFrames",
|
|
9611
|
+
"00280010": "rows",
|
|
9612
|
+
"00280011": "columns",
|
|
9613
|
+
"00280002": "samplesPerPixel",
|
|
9614
|
+
"00280100": "bitsAllocated",
|
|
9615
|
+
"00280103": "pixelRepresentation"
|
|
9616
|
+
};
|
|
9617
|
+
|
|
9618
|
+
/**
|
|
9619
|
+
* Default tags to track in listener.information
|
|
9620
|
+
*/
|
|
9621
|
+
var DEFAULT_INFORMATION_TAGS = new Set(["0020000D",
|
|
9622
|
+
// StudyInstanceUID
|
|
9623
|
+
"0020000E",
|
|
9624
|
+
// SeriesInstanceUID
|
|
9625
|
+
"00080018",
|
|
9626
|
+
// SOPInstanceUID
|
|
9627
|
+
"00020010",
|
|
9628
|
+
// TransferSyntaxUID
|
|
9629
|
+
"00083002",
|
|
9630
|
+
// AvailableTransferSyntaxUID
|
|
9631
|
+
"00080201",
|
|
9632
|
+
// TimezoneOffsetFromUTC
|
|
9633
|
+
"00080005",
|
|
9634
|
+
// SpecificCharacterSet
|
|
9635
|
+
"00280008",
|
|
9636
|
+
// NumberOfFrames
|
|
9637
|
+
"00280010",
|
|
9638
|
+
// Rows
|
|
9639
|
+
"00280011",
|
|
9640
|
+
// Columns
|
|
9641
|
+
"00280002",
|
|
9642
|
+
// SamplesPerPixel
|
|
9643
|
+
"00280100",
|
|
9644
|
+
// BitsAllocated
|
|
9645
|
+
"00280103" // PixelRepresentation
|
|
9646
|
+
]);
|
|
9607
9647
|
|
|
9608
|
-
|
|
9609
|
-
|
|
9610
|
-
|
|
9611
|
-
|
|
9612
|
-
|
|
9613
|
-
|
|
9614
|
-
|
|
9615
|
-
|
|
9616
|
-
|
|
9648
|
+
/**
|
|
9649
|
+
* All valid DICOM VR (Value Representation) codes
|
|
9650
|
+
*/
|
|
9651
|
+
var VALID_VRS = new Set(["AE",
|
|
9652
|
+
// Application Entity
|
|
9653
|
+
"AS",
|
|
9654
|
+
// Age String
|
|
9655
|
+
"AT",
|
|
9656
|
+
// Attribute Tag
|
|
9657
|
+
"CS",
|
|
9658
|
+
// Code String
|
|
9659
|
+
"DA",
|
|
9660
|
+
// Date
|
|
9661
|
+
"DS",
|
|
9662
|
+
// Decimal String
|
|
9663
|
+
"DT",
|
|
9664
|
+
// Date Time
|
|
9665
|
+
"FL",
|
|
9666
|
+
// Floating Point Single
|
|
9667
|
+
"FD",
|
|
9668
|
+
// Floating Point Double
|
|
9669
|
+
"IS",
|
|
9670
|
+
// Integer String
|
|
9671
|
+
"LO",
|
|
9672
|
+
// Long String
|
|
9673
|
+
"LT",
|
|
9674
|
+
// Long Text
|
|
9675
|
+
"OB",
|
|
9676
|
+
// Other Byte
|
|
9677
|
+
"OD",
|
|
9678
|
+
// Other Double
|
|
9679
|
+
"OF",
|
|
9680
|
+
// Other Float
|
|
9681
|
+
"OL",
|
|
9682
|
+
// Other Long
|
|
9683
|
+
"OV",
|
|
9684
|
+
// Other 64-bit Very Long
|
|
9685
|
+
"OW",
|
|
9686
|
+
// Other Word
|
|
9687
|
+
"PN",
|
|
9688
|
+
// Person Name
|
|
9689
|
+
"SH",
|
|
9690
|
+
// Short String
|
|
9691
|
+
"SL",
|
|
9692
|
+
// Signed Long
|
|
9693
|
+
"SQ",
|
|
9694
|
+
// Sequence of Items
|
|
9695
|
+
"SS",
|
|
9696
|
+
// Signed Short
|
|
9697
|
+
"ST",
|
|
9698
|
+
// Short Text
|
|
9699
|
+
"SV",
|
|
9700
|
+
// Signed 64-bit Very Long
|
|
9701
|
+
"TM",
|
|
9702
|
+
// Time
|
|
9703
|
+
"UC",
|
|
9704
|
+
// Unlimited Characters
|
|
9705
|
+
"UI",
|
|
9706
|
+
// Unique Identifier
|
|
9707
|
+
"UL",
|
|
9708
|
+
// Unsigned Long
|
|
9709
|
+
"UN",
|
|
9710
|
+
// Unknown
|
|
9711
|
+
"UR",
|
|
9712
|
+
// Universal Resource
|
|
9713
|
+
"US",
|
|
9714
|
+
// Unsigned Short
|
|
9715
|
+
"UT",
|
|
9716
|
+
// Unlimited Text
|
|
9717
|
+
"UV" // Unsigned 64-bit Very Long
|
|
9718
|
+
]);
|
|
9617
9719
|
|
|
9618
9720
|
/**
|
|
9619
|
-
*
|
|
9620
|
-
*
|
|
9621
|
-
* variable is a string. Undefined for any other value, for example
|
|
9622
|
-
* "verbose" (winston) or "fatal" (pino), for which loglevel 1.9 throws
|
|
9623
|
-
* (pimterry/loglevel#210 proposes log.parseLevel for this check).
|
|
9721
|
+
* DICOM VR (Value Representation) types that are allowed for bulkdata encoding
|
|
9722
|
+
* According to DICOMweb specification
|
|
9624
9723
|
*/
|
|
9625
|
-
|
|
9626
|
-
|
|
9627
|
-
|
|
9628
|
-
|
|
9629
|
-
|
|
9630
|
-
|
|
9631
|
-
|
|
9632
|
-
|
|
9633
|
-
|
|
9634
|
-
|
|
9635
|
-
|
|
9724
|
+
var BULKDATA_VRS = new Set(["DS",
|
|
9725
|
+
// Decimal String
|
|
9726
|
+
"FL",
|
|
9727
|
+
// Floating Point Single
|
|
9728
|
+
"FD",
|
|
9729
|
+
// Floating Point Double
|
|
9730
|
+
"IS",
|
|
9731
|
+
// Integer String
|
|
9732
|
+
"LT",
|
|
9733
|
+
// Long Text
|
|
9734
|
+
"OB",
|
|
9735
|
+
// Other Byte
|
|
9736
|
+
"OD",
|
|
9737
|
+
// Other Double
|
|
9738
|
+
"OF",
|
|
9739
|
+
// Other Float
|
|
9740
|
+
"OL",
|
|
9741
|
+
// Other Long
|
|
9742
|
+
"OV",
|
|
9743
|
+
// Other 64-bit Very Long
|
|
9744
|
+
"OW",
|
|
9745
|
+
// Other Word
|
|
9746
|
+
"SL",
|
|
9747
|
+
// Signed Long
|
|
9748
|
+
"SS",
|
|
9749
|
+
// Signed Short
|
|
9750
|
+
"ST",
|
|
9751
|
+
// Short Text
|
|
9752
|
+
"SV",
|
|
9753
|
+
// Signed 64-bit Very Long
|
|
9754
|
+
"UC",
|
|
9755
|
+
// Unlimited Characters
|
|
9756
|
+
"UL",
|
|
9757
|
+
// Unsigned Long
|
|
9758
|
+
"UN",
|
|
9759
|
+
// Unknown
|
|
9760
|
+
"US",
|
|
9761
|
+
// Unsigned Short
|
|
9762
|
+
"UT",
|
|
9763
|
+
// Unlimited Text
|
|
9764
|
+
"UV" // Unsigned 64-bit Very Long
|
|
9765
|
+
]);
|
|
9636
9766
|
|
|
9637
9767
|
/**
|
|
9638
9768
|
* Converts a PN string to the dicom+json equivalent, or returns the
|
|
@@ -9767,9 +9897,14 @@
|
|
|
9767
9897
|
// since the tag Proxy left core.
|
|
9768
9898
|
// eslint-disable-next-line no-unused-vars
|
|
9769
9899
|
var Tag$1, writeDataSet$1;
|
|
9770
|
-
|
|
9771
|
-
|
|
9772
|
-
|
|
9900
|
+
|
|
9901
|
+
/** Copies the VR flags (constants/vrs.js) to the instance properties. */
|
|
9902
|
+
function applyVrFlags(vr) {
|
|
9903
|
+
var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
9904
|
+
vr._isBinary = !!flags.binary;
|
|
9905
|
+
vr._allowMultiple = !flags.binary && !flags.single;
|
|
9906
|
+
vr._isLength32 = !!flags.length32;
|
|
9907
|
+
}
|
|
9773
9908
|
|
|
9774
9909
|
// Unknown VR types already warned about by createByTypeString — the UN
|
|
9775
9910
|
// fallback warns at most once per type (issue #457).
|
|
@@ -9779,9 +9914,7 @@
|
|
|
9779
9914
|
_classCallCheck(this, ValueRepresentation);
|
|
9780
9915
|
this.type = type;
|
|
9781
9916
|
this.multi = false;
|
|
9782
|
-
this
|
|
9783
|
-
this._allowMultiple = !this._isBinary && singleVRs.indexOf(this.type) == -1;
|
|
9784
|
-
this._isLength32 = length32VRs.indexOf(this.type) != -1;
|
|
9917
|
+
applyVrFlags(this, vrFlags[type]);
|
|
9785
9918
|
this._storeRaw = true;
|
|
9786
9919
|
}
|
|
9787
9920
|
return _createClass(ValueRepresentation, [{
|
|
@@ -10080,8 +10213,8 @@
|
|
|
10080
10213
|
}, {
|
|
10081
10214
|
key: "hasValueAccessors",
|
|
10082
10215
|
value: function hasValueAccessors(type) {
|
|
10083
|
-
if (type
|
|
10084
|
-
return
|
|
10216
|
+
if (Object.prototype.hasOwnProperty.call(Vrs, type)) {
|
|
10217
|
+
return Vrs[type].addValueAccessors !== ValueRepresentation.prototype.addValueAccessors;
|
|
10085
10218
|
}
|
|
10086
10219
|
// Given undefined, assume the representation need to add value accessors
|
|
10087
10220
|
return type === undefined;
|
|
@@ -10089,16 +10222,16 @@
|
|
|
10089
10222
|
}, {
|
|
10090
10223
|
key: "createByTypeString",
|
|
10091
10224
|
value: function createByTypeString(type) {
|
|
10092
|
-
var vr =
|
|
10225
|
+
var vr = Object.prototype.hasOwnProperty.call(Vrs, type) ? Vrs[type] : undefined;
|
|
10093
10226
|
if (vr === undefined) {
|
|
10094
10227
|
if (type == "ox") {
|
|
10095
10228
|
// TODO: determine VR based on context (could be 1 byte pixel data)
|
|
10096
10229
|
// https://github.com/dgobbi/vtk-dicom/issues/38
|
|
10097
10230
|
validationLog.debug("Invalid vr type", type, "- using OW");
|
|
10098
|
-
vr =
|
|
10231
|
+
vr = Vrs.OW;
|
|
10099
10232
|
} else if (type == "xs") {
|
|
10100
10233
|
validationLog.debug("Invalid vr type", type, "- using US");
|
|
10101
|
-
vr =
|
|
10234
|
+
vr = Vrs.US;
|
|
10102
10235
|
} else {
|
|
10103
10236
|
// Warn at most once per unknown type (issue #457): files can
|
|
10104
10237
|
// carry many elements of the same unregistered VR (OL/OV/SV),
|
|
@@ -10107,7 +10240,7 @@
|
|
|
10107
10240
|
unknownVrTypesWarned.add(type);
|
|
10108
10241
|
validationLog.warn("Invalid vr type", type, "- using UN");
|
|
10109
10242
|
}
|
|
10110
|
-
vr =
|
|
10243
|
+
vr = Vrs.UN;
|
|
10111
10244
|
}
|
|
10112
10245
|
}
|
|
10113
10246
|
return vr;
|
|
@@ -10202,7 +10335,10 @@
|
|
|
10202
10335
|
// 8 bytes per fragment are needed to store 0xffff (2 bytes), 0xe000 (2 bytes), and frageStream size (4 bytes)
|
|
10203
10336
|
bufferLength += _fragmentsLength * 8;
|
|
10204
10337
|
}
|
|
10205
|
-
binaryStream = new WriteBufferStream(
|
|
10338
|
+
binaryStream = new WriteBufferStream({
|
|
10339
|
+
defaultSize: bufferLength,
|
|
10340
|
+
littleEndian: stream.isLittleEndian
|
|
10341
|
+
});
|
|
10206
10342
|
for (i = 0; i < frames; i++) {
|
|
10207
10343
|
var _needsPadding = Boolean(value[i].byteLength & 1);
|
|
10208
10344
|
startOffset.push(binaryStream.size);
|
|
@@ -10305,7 +10441,8 @@
|
|
|
10305
10441
|
start = _range[0],
|
|
10306
10442
|
stop = _range[1];
|
|
10307
10443
|
// create a new readable stream based on the range
|
|
10308
|
-
var rangeStream = new ReadBufferStream(stream.buffer,
|
|
10444
|
+
var rangeStream = new ReadBufferStream(stream.buffer, {
|
|
10445
|
+
littleEndian: stream.isLittleEndian,
|
|
10309
10446
|
start: start,
|
|
10310
10447
|
stop: stop,
|
|
10311
10448
|
noCopy: stream.noCopy
|
|
@@ -10363,6 +10500,14 @@
|
|
|
10363
10500
|
} else if (this.type == 'OB') {
|
|
10364
10501
|
bytes = stream.readUint8Array(length);
|
|
10365
10502
|
}*/
|
|
10503
|
+
// A declared length longer than the data present means a
|
|
10504
|
+
// truncated or malformed file: read the bytes that are present.
|
|
10505
|
+
// https://github.com/dcmjs-org/dcmjs/security/advisories/GHSA-xwvm-687g-rm36
|
|
10506
|
+
var available = stream.endOffset - stream.offset;
|
|
10507
|
+
if (length > available) {
|
|
10508
|
+
validationLog.warn("".concat(this.type, " value declares ").concat(length, " bytes but only ").concat(available, " are available - reading the available bytes"));
|
|
10509
|
+
length = available;
|
|
10510
|
+
}
|
|
10366
10511
|
bytes = stream.getBuffer(stream.offset, stream.offset + length);
|
|
10367
10512
|
stream.increment(length);
|
|
10368
10513
|
return [bytes];
|
|
@@ -11350,7 +11495,7 @@
|
|
|
11350
11495
|
key: "read",
|
|
11351
11496
|
value: function read(stream, length, syntax, readOptions) {
|
|
11352
11497
|
var arrayBuffer = this.readBytes(stream, length, syntax)[0];
|
|
11353
|
-
var streamFromBuffer = new ReadBufferStream(arrayBuffer
|
|
11498
|
+
var streamFromBuffer = new ReadBufferStream(arrayBuffer);
|
|
11354
11499
|
var vr = ValueRepresentation$1.createByTypeString(this.type);
|
|
11355
11500
|
if (vr.isBinary() && length > vr.maxLength && !vr.noMultiple) {
|
|
11356
11501
|
var values = [];
|
|
@@ -11425,8 +11570,13 @@
|
|
|
11425
11570
|
}
|
|
11426
11571
|
_inherits(OtherFloatString, _BinaryRepresentation6);
|
|
11427
11572
|
return _createClass(OtherFloatString);
|
|
11428
|
-
}(BinaryRepresentation);
|
|
11429
|
-
|
|
11573
|
+
}(BinaryRepresentation);
|
|
11574
|
+
/**
|
|
11575
|
+
* The shared VR instances by code (`Vrs.DS`); `registerVr` extends it.
|
|
11576
|
+
* @typedef {Object<string, ValueRepresentation>} VrRegistry
|
|
11577
|
+
* @type {VrRegistry}
|
|
11578
|
+
*/
|
|
11579
|
+
var Vrs = {
|
|
11430
11580
|
AE: new ApplicationEntity(),
|
|
11431
11581
|
AS: new AgeString(),
|
|
11432
11582
|
AT: new AttributeTag(),
|
|
@@ -11460,6 +11610,62 @@
|
|
|
11460
11610
|
UV: new Unsigned64BitVeryLong()
|
|
11461
11611
|
};
|
|
11462
11612
|
|
|
11613
|
+
/**
|
|
11614
|
+
* SOP Class UIDs by name (a subset of PS3.4 B.5): `SopClasses.CTImage`.
|
|
11615
|
+
* It is also `DicomMetaDictionary.sopClassUIDsByName`.
|
|
11616
|
+
* @typedef {typeof SopClasses} SopClassRegistry
|
|
11617
|
+
* @type {Object<string, string>}
|
|
11618
|
+
*/
|
|
11619
|
+
var SopClasses = {
|
|
11620
|
+
NMImage: "1.2.840.10008.5.1.4.1.1.20",
|
|
11621
|
+
CTImage: "1.2.840.10008.5.1.4.1.1.2",
|
|
11622
|
+
EnhancedCTImage: "1.2.840.10008.5.1.4.1.1.2.1",
|
|
11623
|
+
LegacyConvertedEnhancedCTImage: "1.2.840.10008.5.1.4.1.1.2.2",
|
|
11624
|
+
USMultiframeImage: "1.2.840.10008.5.1.4.1.1.3.1",
|
|
11625
|
+
MRImage: "1.2.840.10008.5.1.4.1.1.4",
|
|
11626
|
+
EnhancedMRImage: "1.2.840.10008.5.1.4.1.1.4.1",
|
|
11627
|
+
MRSpectroscopy: "1.2.840.10008.5.1.4.1.1.4.2",
|
|
11628
|
+
EnhancedMRColorImage: "1.2.840.10008.5.1.4.1.1.4.3",
|
|
11629
|
+
LegacyConvertedEnhancedMRImage: "1.2.840.10008.5.1.4.1.1.4.4",
|
|
11630
|
+
USImage: "1.2.840.10008.5.1.4.1.1.6.1",
|
|
11631
|
+
EnhancedUSVolume: "1.2.840.10008.5.1.4.1.1.6.2",
|
|
11632
|
+
SecondaryCaptureImage: "1.2.840.10008.5.1.4.1.1.7",
|
|
11633
|
+
ParametricMapStorage: "1.2.840.10008.5.1.4.1.1.30",
|
|
11634
|
+
RawData: "1.2.840.10008.5.1.4.1.1.66",
|
|
11635
|
+
SpatialRegistration: "1.2.840.10008.5.1.4.1.1.66.1",
|
|
11636
|
+
SpatialFiducials: "1.2.840.10008.5.1.4.1.1.66.2",
|
|
11637
|
+
DeformableSpatialRegistration: "1.2.840.10008.5.1.4.1.1.66.3",
|
|
11638
|
+
Segmentation: "1.2.840.10008.5.1.4.1.1.66.4",
|
|
11639
|
+
LabelmapSegmentation: "1.2.840.10008.5.1.4.1.1.66.7",
|
|
11640
|
+
RealWorldValueMapping: "1.2.840.10008.5.1.4.1.1.67",
|
|
11641
|
+
BasicTextSR: "1.2.840.10008.5.1.4.1.1.88.11",
|
|
11642
|
+
EnhancedSR: "1.2.840.10008.5.1.4.1.1.88.22",
|
|
11643
|
+
ComprehensiveSR: "1.2.840.10008.5.1.4.1.1.88.33",
|
|
11644
|
+
Comprehensive3DSR: "1.2.840.10008.5.1.4.1.1.88.34",
|
|
11645
|
+
PETImage: "1.2.840.10008.5.1.4.1.1.128",
|
|
11646
|
+
EnhancedPETImage: "1.2.840.10008.5.1.4.1.1.130",
|
|
11647
|
+
LegacyConvertedEnhancedPETImage: "1.2.840.10008.5.1.4.1.1.128.1",
|
|
11648
|
+
OphthalmicPhotography8BitImage: "1.2.840.10008.5.1.4.1.1.77.1.5.1",
|
|
11649
|
+
OphthalmicTomographyImage: "1.2.840.10008.5.1.4.1.1.77.1.5.4"
|
|
11650
|
+
};
|
|
11651
|
+
|
|
11652
|
+
/** UID -> name; also `DicomMetaDictionary.sopClassNamesByUID`. */
|
|
11653
|
+
var sopClassNamesByUID = Object.fromEntries(Object.entries(SopClasses).map(function (_ref) {
|
|
11654
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
11655
|
+
name = _ref2[0],
|
|
11656
|
+
uid = _ref2[1];
|
|
11657
|
+
return [uid, name];
|
|
11658
|
+
}));
|
|
11659
|
+
|
|
11660
|
+
/** Adds or replaces a SOP class name and UID. */
|
|
11661
|
+
function registerSopClass(name, uid) {
|
|
11662
|
+
if (sopClassNamesByUID[SopClasses[name]] === name) {
|
|
11663
|
+
delete sopClassNamesByUID[SopClasses[name]];
|
|
11664
|
+
}
|
|
11665
|
+
SopClasses[name] = uid;
|
|
11666
|
+
sopClassNamesByUID[uid] = name;
|
|
11667
|
+
}
|
|
11668
|
+
|
|
11463
11669
|
// src/core/normalizeSyntax.js
|
|
11464
11670
|
|
|
11465
11671
|
/**
|
|
@@ -11575,9 +11781,13 @@
|
|
|
11575
11781
|
stream.setEndian(isLittleEndian);
|
|
11576
11782
|
stream.writeUint16(this.group());
|
|
11577
11783
|
stream.writeUint16(this.element());
|
|
11578
|
-
var tagStream = new WriteBufferStream(
|
|
11784
|
+
var tagStream = new WriteBufferStream({
|
|
11785
|
+
defaultSize: 256
|
|
11786
|
+
}),
|
|
11579
11787
|
valueLength;
|
|
11580
11788
|
tagStream.setEndian(isLittleEndian);
|
|
11789
|
+
// sequence items are written through tagStream: keep the charset
|
|
11790
|
+
tagStream.encoder = stream.encoder;
|
|
11581
11791
|
if (vrType == "OW" || vrType == "OB" || vrType == "UN") {
|
|
11582
11792
|
valueLength = vr.writeBytes(tagStream, values, useSyntax, isEncapsulated, writeOptions);
|
|
11583
11793
|
} else if (vrType == "SQ") {
|
|
@@ -12478,13 +12688,6 @@
|
|
|
12478
12688
|
return entry !== null && entry !== void 0 && entry.vm && !isMultiVM(entry.vm) ? 1 : undefined;
|
|
12479
12689
|
}
|
|
12480
12690
|
|
|
12481
|
-
/**
|
|
12482
|
-
* The binary (byte-stream) VRs. A binary Value lists frames or fragments,
|
|
12483
|
-
* not a VM, so a naturalized binary value stays a list regardless of the
|
|
12484
|
-
* dictionary VM.
|
|
12485
|
-
*/
|
|
12486
|
-
var BINARY_VRS = new Set(["OB", "OD", "OF", "OL", "OV", "OW", "UN"]);
|
|
12487
|
-
|
|
12488
12691
|
var BINARY_AS = new Set(["ArrayBuffer", "Uint8Array"]);
|
|
12489
12692
|
var isSharedBuffer = function isSharedBuffer(v) {
|
|
12490
12693
|
return typeof SharedArrayBuffer !== "undefined" && v instanceof SharedArrayBuffer;
|
|
@@ -14062,59 +14265,32 @@
|
|
|
14062
14265
|
});
|
|
14063
14266
|
return nameMap;
|
|
14064
14267
|
}
|
|
14268
|
+
|
|
14269
|
+
/**
|
|
14270
|
+
* Registers each entry of `sopClassNamesByUID` (constants/sopClasses.js
|
|
14271
|
+
* `registerSopClass`), for 0.x code that edits that map directly. It
|
|
14272
|
+
* adds entries; `sopClassUIDsByName` stays the `SopClasses` object.
|
|
14273
|
+
*/
|
|
14065
14274
|
}, {
|
|
14066
14275
|
key: "_generateUIDMap",
|
|
14067
14276
|
value: function _generateUIDMap() {
|
|
14068
|
-
|
|
14069
|
-
Object.keys(
|
|
14070
|
-
|
|
14071
|
-
DicomMetaDictionary.sopClassUIDsByName[name] = uid;
|
|
14277
|
+
var namesByUid = DicomMetaDictionary.sopClassNamesByUID;
|
|
14278
|
+
Object.keys(namesByUid).forEach(function (uid) {
|
|
14279
|
+
return registerSopClass(namesByUid[uid], uid);
|
|
14072
14280
|
});
|
|
14073
14281
|
}
|
|
14074
14282
|
}]);
|
|
14075
14283
|
}();
|
|
14076
14284
|
|
|
14077
|
-
//
|
|
14078
|
-
//
|
|
14079
|
-
DicomMetaDictionary.sopClassNamesByUID =
|
|
14080
|
-
|
|
14081
|
-
"1.2.840.10008.5.1.4.1.1.2": "CTImage",
|
|
14082
|
-
"1.2.840.10008.5.1.4.1.1.2.1": "EnhancedCTImage",
|
|
14083
|
-
"1.2.840.10008.5.1.4.1.1.2.2": "LegacyConvertedEnhancedCTImage",
|
|
14084
|
-
"1.2.840.10008.5.1.4.1.1.3.1": "USMultiframeImage",
|
|
14085
|
-
"1.2.840.10008.5.1.4.1.1.4": "MRImage",
|
|
14086
|
-
"1.2.840.10008.5.1.4.1.1.4.1": "EnhancedMRImage",
|
|
14087
|
-
"1.2.840.10008.5.1.4.1.1.4.2": "MRSpectroscopy",
|
|
14088
|
-
"1.2.840.10008.5.1.4.1.1.4.3": "EnhancedMRColorImage",
|
|
14089
|
-
"1.2.840.10008.5.1.4.1.1.4.4": "LegacyConvertedEnhancedMRImage",
|
|
14090
|
-
"1.2.840.10008.5.1.4.1.1.6.1": "USImage",
|
|
14091
|
-
"1.2.840.10008.5.1.4.1.1.6.2": "EnhancedUSVolume",
|
|
14092
|
-
"1.2.840.10008.5.1.4.1.1.7": "SecondaryCaptureImage",
|
|
14093
|
-
"1.2.840.10008.5.1.4.1.1.30": "ParametricMapStorage",
|
|
14094
|
-
"1.2.840.10008.5.1.4.1.1.66": "RawData",
|
|
14095
|
-
"1.2.840.10008.5.1.4.1.1.66.1": "SpatialRegistration",
|
|
14096
|
-
"1.2.840.10008.5.1.4.1.1.66.2": "SpatialFiducials",
|
|
14097
|
-
"1.2.840.10008.5.1.4.1.1.66.3": "DeformableSpatialRegistration",
|
|
14098
|
-
"1.2.840.10008.5.1.4.1.1.66.4": "Segmentation",
|
|
14099
|
-
"1.2.840.10008.5.1.4.1.1.66.7": "LabelmapSegmentation",
|
|
14100
|
-
// Labelmap Segmentation SOP Class UID
|
|
14101
|
-
"1.2.840.10008.5.1.4.1.1.67": "RealWorldValueMapping",
|
|
14102
|
-
"1.2.840.10008.5.1.4.1.1.88.11": "BasicTextSR",
|
|
14103
|
-
"1.2.840.10008.5.1.4.1.1.88.22": "EnhancedSR",
|
|
14104
|
-
"1.2.840.10008.5.1.4.1.1.88.33": "ComprehensiveSR",
|
|
14105
|
-
"1.2.840.10008.5.1.4.1.1.88.34": "Comprehensive3DSR",
|
|
14106
|
-
"1.2.840.10008.5.1.4.1.1.128": "PETImage",
|
|
14107
|
-
"1.2.840.10008.5.1.4.1.1.130": "EnhancedPETImage",
|
|
14108
|
-
"1.2.840.10008.5.1.4.1.1.128.1": "LegacyConvertedEnhancedPETImage",
|
|
14109
|
-
"1.2.840.10008.5.1.4.1.1.77.1.5.1": "OphthalmicPhotography8BitImage",
|
|
14110
|
-
"1.2.840.10008.5.1.4.1.1.77.1.5.4": "OphthalmicTomographyImage"
|
|
14111
|
-
};
|
|
14285
|
+
// The SOP class registry (constants/sopClasses.js); both are the registry's
|
|
14286
|
+
// own objects, so registerSopClass shows in them.
|
|
14287
|
+
DicomMetaDictionary.sopClassNamesByUID = sopClassNamesByUID;
|
|
14288
|
+
DicomMetaDictionary.sopClassUIDsByName = SopClasses;
|
|
14112
14289
|
|
|
14113
14290
|
// Avoid loops in imports
|
|
14114
14291
|
ValueRepresentation$1.setDicomMetaDictionary(DicomMetaDictionary);
|
|
14115
14292
|
DicomMetaDictionary.dictionary = dictionary;
|
|
14116
14293
|
DicomMetaDictionary._generateNameMap();
|
|
14117
|
-
DicomMetaDictionary._generateUIDMap();
|
|
14118
14294
|
|
|
14119
14295
|
// AUTO-GENERATED from dictionary.mjs by generate/pack_private.mjs
|
|
14120
14296
|
// Private tags only (creator strings). Decoded on first use; use ensurePrivateLoaded() if needed.
|
|
@@ -14195,6 +14371,128 @@
|
|
|
14195
14371
|
return undefined;
|
|
14196
14372
|
}
|
|
14197
14373
|
|
|
14374
|
+
/**
|
|
14375
|
+
* One SpecificCharacterSet defined term. Give `label` (a WHATWG Encoding
|
|
14376
|
+
* label) and/or `createDecoder`; a label builds the decoder and, for UTF-8
|
|
14377
|
+
* and single-byte encodings, the encoder. `encode` null means no encoder.
|
|
14378
|
+
* @typedef {Object} CharacterSet
|
|
14379
|
+
* @property {string} [label]
|
|
14380
|
+
* @property {() => {decode(input: BufferSource): string}} [createDecoder]
|
|
14381
|
+
* @property {((text: string, options?: {ignoreErrors?: boolean}) => Uint8Array)|null} [encode]
|
|
14382
|
+
*/
|
|
14383
|
+
|
|
14384
|
+
var MULTI_BYTE = /^(shift_jis|euc-jp|iso-2022-jp|euc-kr|gbk|gb18030|big5|utf-16(le|be)|replacement)$/;
|
|
14385
|
+
var registered = {};
|
|
14386
|
+
var byLabel = {};
|
|
14387
|
+
var warned = new Set();
|
|
14388
|
+
var utf8Encoder = new TextEncoder();
|
|
14389
|
+
|
|
14390
|
+
/**
|
|
14391
|
+
* Normalizes a (0008,0005) value to the `encodingMapping` key form
|
|
14392
|
+
* ("ISO_IR 100" gives "iso-ir-100"); strips the NUL padding of old modalities.
|
|
14393
|
+
*/
|
|
14394
|
+
function normalizeCharacterSetTerm(value) {
|
|
14395
|
+
return String(value !== null && value !== void 0 ? value : "").replace(/\0/g, "").trim().replace(/[_ ]/g, "-").toLowerCase();
|
|
14396
|
+
}
|
|
14397
|
+
|
|
14398
|
+
/**
|
|
14399
|
+
* The encoder of a label: TextEncoder for UTF-8, a reverse table of the
|
|
14400
|
+
* decoder over 0x00-0xFF for a single-byte encoding, null otherwise. A
|
|
14401
|
+
* single-byte encoder throws on a character it cannot hold, or writes `?`
|
|
14402
|
+
* with `options.ignoreErrors`.
|
|
14403
|
+
*/
|
|
14404
|
+
function encoderForLabel(label) {
|
|
14405
|
+
var decoder;
|
|
14406
|
+
try {
|
|
14407
|
+
decoder = createDecoder(label);
|
|
14408
|
+
} catch (_unused) {
|
|
14409
|
+
return null;
|
|
14410
|
+
}
|
|
14411
|
+
if (decoder.encoding === "utf-8") {
|
|
14412
|
+
return function (text) {
|
|
14413
|
+
return utf8Encoder.encode(text);
|
|
14414
|
+
};
|
|
14415
|
+
}
|
|
14416
|
+
if (MULTI_BYTE.test(decoder.encoding)) {
|
|
14417
|
+
return null;
|
|
14418
|
+
}
|
|
14419
|
+
var table = new Map();
|
|
14420
|
+
for (var byte = 255; byte >= 0; byte--) {
|
|
14421
|
+
var char = decoder.decode(Uint8Array.of(byte));
|
|
14422
|
+
if (char !== "�") table.set(char, byte);
|
|
14423
|
+
}
|
|
14424
|
+
return function (text) {
|
|
14425
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
14426
|
+
var out = [];
|
|
14427
|
+
var _iterator = _createForOfIteratorHelper(text),
|
|
14428
|
+
_step;
|
|
14429
|
+
try {
|
|
14430
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
14431
|
+
var _char = _step.value;
|
|
14432
|
+
var _byte = table.get(_char);
|
|
14433
|
+
if (_byte === undefined) {
|
|
14434
|
+
if (!options.ignoreErrors) {
|
|
14435
|
+
throw new Error("\"".concat(_char, "\" (U+").concat(_char.codePointAt(0).toString(16).toUpperCase(), ") is not in the character set ").concat(label));
|
|
14436
|
+
}
|
|
14437
|
+
_byte = 0x3f;
|
|
14438
|
+
}
|
|
14439
|
+
out.push(_byte);
|
|
14440
|
+
}
|
|
14441
|
+
} catch (err) {
|
|
14442
|
+
_iterator.e(err);
|
|
14443
|
+
} finally {
|
|
14444
|
+
_iterator.f();
|
|
14445
|
+
}
|
|
14446
|
+
return Uint8Array.from(out);
|
|
14447
|
+
};
|
|
14448
|
+
}
|
|
14449
|
+
function characterSetForLabel(label) {
|
|
14450
|
+
var _byLabel$label;
|
|
14451
|
+
return (_byLabel$label = byLabel[label]) !== null && _byLabel$label !== void 0 ? _byLabel$label : byLabel[label] = {
|
|
14452
|
+
label: label,
|
|
14453
|
+
createDecoder: function createDecoder$1() {
|
|
14454
|
+
return createDecoder(label);
|
|
14455
|
+
},
|
|
14456
|
+
encode: encoderForLabel(label)
|
|
14457
|
+
};
|
|
14458
|
+
}
|
|
14459
|
+
|
|
14460
|
+
/** The CharacterSet of a normalized term, or undefined. */
|
|
14461
|
+
function lookupCharacterSet(code) {
|
|
14462
|
+
if (registered[code]) return registered[code];
|
|
14463
|
+
var label = Object.hasOwn(encodingMapping, code) && encodingMapping[code];
|
|
14464
|
+
return label ? characterSetForLabel(label) : undefined;
|
|
14465
|
+
}
|
|
14466
|
+
|
|
14467
|
+
/**
|
|
14468
|
+
* The text encoder (`{ encode(text) }`) for a dataset or item that declares
|
|
14469
|
+
* `values` in (0008,0005). No encoder (multi-byte, ISO 2022, multi-valued,
|
|
14470
|
+
* unknown) gives UTF-8 bytes, as before, with one warning per term.
|
|
14471
|
+
* @param {string[]|string} values
|
|
14472
|
+
* @param {{ignoreErrors?: boolean}} [writeOptions]
|
|
14473
|
+
*/
|
|
14474
|
+
function createCharacterSetEncoder(values, writeOptions) {
|
|
14475
|
+
var _lookupCharacterSet;
|
|
14476
|
+
var list = [].concat(values !== null && values !== void 0 ? values : []);
|
|
14477
|
+
var key = list.map(normalizeCharacterSetTerm).join("\\");
|
|
14478
|
+
var _encode = list.length < 2 && ((_lookupCharacterSet = lookupCharacterSet(normalizeCharacterSetTerm(list[0]))) === null || _lookupCharacterSet === void 0 ? void 0 : _lookupCharacterSet.encode);
|
|
14479
|
+
if (!_encode) {
|
|
14480
|
+
if (!warned.has(key)) {
|
|
14481
|
+
warned.add(key);
|
|
14482
|
+
log.warn("No encoder for the character set \"".concat(key, "\"; writing UTF-8 bytes"));
|
|
14483
|
+
}
|
|
14484
|
+
return utf8Encoder;
|
|
14485
|
+
}
|
|
14486
|
+
var options = {
|
|
14487
|
+
ignoreErrors: writeOptions === null || writeOptions === void 0 ? void 0 : writeOptions.ignoreErrors
|
|
14488
|
+
};
|
|
14489
|
+
return {
|
|
14490
|
+
encode: function encode(text) {
|
|
14491
|
+
return _encode(text, options);
|
|
14492
|
+
}
|
|
14493
|
+
};
|
|
14494
|
+
}
|
|
14495
|
+
|
|
14198
14496
|
var ESC = 0x1b;
|
|
14199
14497
|
|
|
14200
14498
|
// G0 designations with dedicated decode strategies.
|
|
@@ -14498,15 +14796,6 @@
|
|
|
14498
14796
|
return decodeWith("latin1", runBytes);
|
|
14499
14797
|
}
|
|
14500
14798
|
|
|
14501
|
-
/**
|
|
14502
|
-
* Normalizes one (0008,0005) value to the encodingMapping key form.
|
|
14503
|
-
* NULs are stripped first: some older modalities illegally pad odd-length
|
|
14504
|
-
* values to even length with \0 instead of the space the standard requires.
|
|
14505
|
-
*/
|
|
14506
|
-
function normalizeCode(value) {
|
|
14507
|
-
return String(value !== null && value !== void 0 ? value : "").replace(/\0/g, "").trim().replace(/[_ ]/g, "-").toLowerCase();
|
|
14508
|
-
}
|
|
14509
|
-
|
|
14510
14799
|
/**
|
|
14511
14800
|
* Resolves the decoder for a SpecificCharacterSet (0008,0005) value list.
|
|
14512
14801
|
*
|
|
@@ -14522,11 +14811,12 @@
|
|
|
14522
14811
|
if (!values || values.length === 0) {
|
|
14523
14812
|
return null;
|
|
14524
14813
|
}
|
|
14525
|
-
var codes = values.map(
|
|
14814
|
+
var codes = values.map(normalizeCharacterSetTerm);
|
|
14526
14815
|
if (values.length === 1) {
|
|
14527
14816
|
var coding = codes[0];
|
|
14528
|
-
|
|
14529
|
-
|
|
14817
|
+
var characterSet = lookupCharacterSet(coding);
|
|
14818
|
+
if (characterSet) {
|
|
14819
|
+
return characterSet.createDecoder();
|
|
14530
14820
|
}
|
|
14531
14821
|
if (ignoreErrors) {
|
|
14532
14822
|
log.warn("Unsupported character set: ".concat(coding, ", using default character set"));
|
|
@@ -14553,7 +14843,7 @@
|
|
|
14553
14843
|
try {
|
|
14554
14844
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
14555
14845
|
var code = _step.value;
|
|
14556
|
-
if (code !== "" && !(code
|
|
14846
|
+
if (code !== "" && !lookupCharacterSet(code)) {
|
|
14557
14847
|
if (ignoreErrors) {
|
|
14558
14848
|
log.warn("Unsupported character set: ".concat(code, ", using default character set"));
|
|
14559
14849
|
} else {
|
|
@@ -14652,17 +14942,29 @@
|
|
|
14652
14942
|
tag.write(stream, vr, values, syntax, writeOptions);
|
|
14653
14943
|
}
|
|
14654
14944
|
|
|
14655
|
-
/**
|
|
14945
|
+
/**
|
|
14946
|
+
* Relocated from DicomMessage.write: one tag-keyed object, sorted tag order.
|
|
14947
|
+
* A written (0008,0005) sets the stream's text encoder until the end of
|
|
14948
|
+
* this dataset or item; the caller's encoder is then restored.
|
|
14949
|
+
*/
|
|
14656
14950
|
function writeDataSet(jsonObjects, useStream, syntax, writeOptions) {
|
|
14657
14951
|
var written = 0;
|
|
14952
|
+
var outerEncoder = useStream.encoder;
|
|
14658
14953
|
var sortedTags = Object.keys(jsonObjects).sort();
|
|
14659
|
-
|
|
14660
|
-
|
|
14661
|
-
|
|
14662
|
-
|
|
14663
|
-
|
|
14664
|
-
|
|
14665
|
-
|
|
14954
|
+
try {
|
|
14955
|
+
sortedTags.forEach(function (tagString) {
|
|
14956
|
+
var tag = Tag.fromString(tagString),
|
|
14957
|
+
tagObject = jsonObjects[tagString],
|
|
14958
|
+
vrType = tagObject.vr;
|
|
14959
|
+
var values = getTagWriteValues(vrType, tagObject);
|
|
14960
|
+
written += tag.write(useStream, vrType, values, syntax, writeOptions);
|
|
14961
|
+
if (tagString === TagHex.SpecificCharacterSet) {
|
|
14962
|
+
useStream.encoder = createCharacterSetEncoder(values, writeOptions);
|
|
14963
|
+
}
|
|
14964
|
+
});
|
|
14965
|
+
} finally {
|
|
14966
|
+
useStream.encoder = outerEncoder;
|
|
14967
|
+
}
|
|
14666
14968
|
return written;
|
|
14667
14969
|
}
|
|
14668
14970
|
|
|
@@ -14695,10 +14997,14 @@
|
|
|
14695
14997
|
allowInvalidVRLength: false
|
|
14696
14998
|
};
|
|
14697
14999
|
var metaSyntax = EXPLICIT_LITTLE_ENDIAN;
|
|
14698
|
-
var fileStream = new WriteBufferStream(
|
|
15000
|
+
var fileStream = new WriteBufferStream({
|
|
15001
|
+
defaultSize: 4096
|
|
15002
|
+
});
|
|
14699
15003
|
fileStream.writeUint8Repeat(0, 128);
|
|
14700
15004
|
fileStream.writeAsciiString("DICM");
|
|
14701
|
-
var metaStream = new WriteBufferStream(
|
|
15005
|
+
var metaStream = new WriteBufferStream({
|
|
15006
|
+
defaultSize: 1024
|
|
15007
|
+
});
|
|
14702
15008
|
if (!meta[TagHex.TransferSyntaxUID]) {
|
|
14703
15009
|
meta[TagHex.TransferSyntaxUID] = {
|
|
14704
15010
|
vr: "UI",
|
|
@@ -14731,7 +15037,9 @@
|
|
|
14731
15037
|
* @param {Object} writeOptions
|
|
14732
15038
|
*/
|
|
14733
15039
|
function writeDeflatedDataSet(dict, fileStream, writeOptions) {
|
|
14734
|
-
var bodyStream = new WriteBufferStream(
|
|
15040
|
+
var bodyStream = new WriteBufferStream({
|
|
15041
|
+
defaultSize: 4096
|
|
15042
|
+
});
|
|
14735
15043
|
writeDataSet(dict, bodyStream, EXPLICIT_LITTLE_ENDIAN, writeOptions);
|
|
14736
15044
|
fileStream.writeRawBytes(pako.deflateRaw(new Uint8Array(bodyStream.getBuffer())));
|
|
14737
15045
|
}
|
|
@@ -15696,7 +16004,7 @@
|
|
|
15696
16004
|
// issue #93 opt-in: accept preamble-less / meta-less inputs
|
|
15697
16005
|
allowMissingHeader: false
|
|
15698
16006
|
};
|
|
15699
|
-
var stream = new ReadBufferStream(buffer,
|
|
16007
|
+
var stream = new ReadBufferStream(buffer, {
|
|
15700
16008
|
noCopy: options.noCopy
|
|
15701
16009
|
}),
|
|
15702
16010
|
useSyntax = EXPLICIT_LITTLE_ENDIAN;
|
|
@@ -15903,7 +16211,7 @@
|
|
|
15903
16211
|
var _ref = vr.read(stream, length, syntax, readOptions) || {},
|
|
15904
16212
|
_rawValue = _ref.rawValue,
|
|
15905
16213
|
_value = _ref.value;
|
|
15906
|
-
if (!vr.isBinary() && singleVRs
|
|
16214
|
+
if (!vr.isBinary() && singleVRs.indexOf(vr.type) == -1) {
|
|
15907
16215
|
rawValues = _rawValue;
|
|
15908
16216
|
values = _value;
|
|
15909
16217
|
if (typeof _value === "string") {
|
|
@@ -16115,25 +16423,65 @@
|
|
|
16115
16423
|
//
|
|
16116
16424
|
// Handle DICOM and CIELAB colors
|
|
16117
16425
|
// based on:
|
|
16118
|
-
// https://github.com/
|
|
16426
|
+
// https://github.com/DCMTK/dcmtk/blob/88105877c3b610e23fc9422ba6a84af85552f5dd/dcmiod/libsrc/cielabutil.cc
|
|
16119
16427
|
//
|
|
16120
16428
|
// RGB here refers to sRGB 0-1 per component.
|
|
16121
16429
|
// dicomlab is CIELAB values as defined in the dicom standard
|
|
16122
|
-
// XYZ is CIEXYZ convention
|
|
16123
|
-
//
|
|
16124
|
-
// TODO: needs a test suite
|
|
16125
|
-
// TODO: only dicomlab2RGB tested on real data
|
|
16430
|
+
// XYZ is CIEXYZ convention, relative to the D50 white point (ICC PCS)
|
|
16126
16431
|
//
|
|
16432
|
+
// DICOM encodes CIELab values in the same way as the ICC Profile Connection
|
|
16433
|
+
// Space (PCS, see PS3.3 C.10.7.1.1), i.e. relative to the D50 illuminant,
|
|
16434
|
+
// whereas the native white point of sRGB is D65. The conversions below
|
|
16435
|
+
// therefore chromatically adapt between the two using the linear Bradford
|
|
16436
|
+
// transform. Matrices and constants are those of the CSS Color Module Level 4
|
|
16437
|
+
// sample code (https://www.w3.org/TR/css-color-4/#color-conversion-code).
|
|
16127
16438
|
//
|
|
16439
|
+
|
|
16440
|
+
// White points, defined by their 4-figure CIE x,y chromaticities.
|
|
16441
|
+
// D50 is intentionally [0.96430, 1, 0.82510] and not the ICC.1 PCS illuminant
|
|
16442
|
+
// [0.9642, 1, 0.8249]: this matches DCMTK, highdicom and CSS Color 4, and
|
|
16443
|
+
// encodes sRGB white as exactly 0x8080 in a* and b*.
|
|
16444
|
+
var D50_WHITEPOINT_XYZ = [0.3457 / 0.3585, 1.0, (1.0 - 0.3457 - 0.3585) / 0.3585];
|
|
16445
|
+
var D65_WHITEPOINT_XYZ = [0.3127 / 0.329, 1.0, (1.0 - 0.3127 - 0.329) / 0.329];
|
|
16446
|
+
function clamp01(n) {
|
|
16447
|
+
return Math.min(1.0, Math.max(0.0, n));
|
|
16448
|
+
}
|
|
16449
|
+
|
|
16450
|
+
// Rounds to the nearest integer in [0, max]; NaN (invalid input) gives 0
|
|
16451
|
+
function roundClamp(n, max) {
|
|
16452
|
+
if (!(n >= 0.0)) {
|
|
16453
|
+
return 0;
|
|
16454
|
+
}
|
|
16455
|
+
if (n > max) {
|
|
16456
|
+
return max;
|
|
16457
|
+
}
|
|
16458
|
+
return Math.floor(n + 0.5);
|
|
16459
|
+
}
|
|
16128
16460
|
var Colors = /*#__PURE__*/function () {
|
|
16129
16461
|
function Colors() {
|
|
16130
16462
|
_classCallCheck(this, Colors);
|
|
16131
16463
|
}
|
|
16132
16464
|
return _createClass(Colors, null, [{
|
|
16465
|
+
key: "d50WhitePointXYZ",
|
|
16466
|
+
value:
|
|
16467
|
+
/**
|
|
16468
|
+
* White point of the D50 illuminant (ICC PCS), the reference white of
|
|
16469
|
+
* DICOM CIELab. Use this white with the XYZ values of rgb2XYZ, xyz2RGB,
|
|
16470
|
+
* lab2XYZ and xyz2LAB.
|
|
16471
|
+
*/
|
|
16472
|
+
function d50WhitePointXYZ() {
|
|
16473
|
+
return [].concat(D50_WHITEPOINT_XYZ);
|
|
16474
|
+
}
|
|
16475
|
+
|
|
16476
|
+
/**
|
|
16477
|
+
* White point of the D65 illuminant, the native white of sRGB. No
|
|
16478
|
+
* conversion in this class uses it. Do not combine it with the XYZ
|
|
16479
|
+
* values of this class, which are relative to D50.
|
|
16480
|
+
*/
|
|
16481
|
+
}, {
|
|
16133
16482
|
key: "d65WhitePointXYZ",
|
|
16134
16483
|
value: function d65WhitePointXYZ() {
|
|
16135
|
-
|
|
16136
|
-
return [0.950456, 1.0, 1.088754];
|
|
16484
|
+
return [].concat(D65_WHITEPOINT_XYZ);
|
|
16137
16485
|
}
|
|
16138
16486
|
}, {
|
|
16139
16487
|
key: "dicomlab2RGB",
|
|
@@ -16145,6 +16493,26 @@
|
|
|
16145
16493
|
value: function rgb2DICOMLAB(rgb) {
|
|
16146
16494
|
return Colors.lab2DICOMLAB(Colors.rgb2LAB(rgb));
|
|
16147
16495
|
}
|
|
16496
|
+
|
|
16497
|
+
// 16 bit DICOM CIELab -> 8 bit sRGB, rounded and clamped
|
|
16498
|
+
}, {
|
|
16499
|
+
key: "dicomlab2RGB8",
|
|
16500
|
+
value: function dicomlab2RGB8(dicomlab) {
|
|
16501
|
+
return Colors.dicomlab2RGB(dicomlab).map(function (n) {
|
|
16502
|
+
return roundClamp(n * 255.0, 255);
|
|
16503
|
+
});
|
|
16504
|
+
}
|
|
16505
|
+
|
|
16506
|
+
// 8 bit sRGB (array or typed array) -> 16 bit DICOM CIELab, rounded and clamped
|
|
16507
|
+
}, {
|
|
16508
|
+
key: "rgb82DICOMLAB",
|
|
16509
|
+
value: function rgb82DICOMLAB(rgb) {
|
|
16510
|
+
return Colors.rgb2DICOMLAB(Array.from(rgb, function (n) {
|
|
16511
|
+
return n / 255.0;
|
|
16512
|
+
})).map(function (n) {
|
|
16513
|
+
return roundClamp(n, 65535);
|
|
16514
|
+
});
|
|
16515
|
+
}
|
|
16148
16516
|
}, {
|
|
16149
16517
|
key: "dicomlab2LAB",
|
|
16150
16518
|
value: function dicomlab2LAB(dicomlab) {
|
|
@@ -16173,7 +16541,8 @@
|
|
|
16173
16541
|
}, {
|
|
16174
16542
|
key: "gammaCorrection",
|
|
16175
16543
|
value: function gammaCorrection(n) {
|
|
16176
|
-
|
|
16544
|
+
// sRGB transfer function (IEC 61966-2-1), linear to gamma-encoded
|
|
16545
|
+
if (n <= 0.0031308) {
|
|
16177
16546
|
return 12.92 * n;
|
|
16178
16547
|
} else {
|
|
16179
16548
|
return 1.055 * Math.pow(n, 1 / 2.4) - 0.055;
|
|
@@ -16182,27 +16551,39 @@
|
|
|
16182
16551
|
}, {
|
|
16183
16552
|
key: "invGammaCorrection",
|
|
16184
16553
|
value: function invGammaCorrection(n) {
|
|
16185
|
-
|
|
16554
|
+
// sRGB transfer function (IEC 61966-2-1), gamma-encoded to linear
|
|
16555
|
+
if (n <= 0.04045) {
|
|
16186
16556
|
return n / 12.92;
|
|
16187
16557
|
} else {
|
|
16188
16558
|
return Math.pow((n + 0.055) / 1.055, 2.4);
|
|
16189
16559
|
}
|
|
16190
16560
|
}
|
|
16561
|
+
|
|
16562
|
+
// sRGB -> CIE XYZ relative to D50, as DICOM CIELab requires (not D65)
|
|
16191
16563
|
}, {
|
|
16192
16564
|
key: "rgb2XYZ",
|
|
16193
16565
|
value: function rgb2XYZ(rgb) {
|
|
16566
|
+
// sRGB to linear RGB
|
|
16194
16567
|
var R = Colors.invGammaCorrection(rgb[0]);
|
|
16195
16568
|
var G = Colors.invGammaCorrection(rgb[1]);
|
|
16196
16569
|
var B = Colors.invGammaCorrection(rgb[2]);
|
|
16197
|
-
|
|
16570
|
+
|
|
16571
|
+
// linear RGB to CIE XYZ (D65)
|
|
16572
|
+
var X65 = 506752.0 / 1228815.0 * R + 87881.0 / 245763.0 * G + 12673.0 / 70218.0 * B;
|
|
16573
|
+
var Y65 = 87098.0 / 409605.0 * R + 175762.0 / 245763.0 * G + 12673.0 / 175545.0 * B;
|
|
16574
|
+
var Z65 = 7918.0 / 409605.0 * R + 87881.0 / 737289.0 * G + 1001167.0 / 1053270.0 * B;
|
|
16575
|
+
|
|
16576
|
+
// chromatic adaptation D65 to D50 (linear Bradford)
|
|
16577
|
+
return [1.0479297925449969 * X65 + 0.022946870601609652 * Y65 - 0.05019226628920524 * Z65, 0.02962780877005599 * X65 + 0.9904344267538799 * Y65 - 0.017073799063418826 * Z65, -0.009243040646204504 * X65 + 0.015055191490298152 * Y65 + 0.7518742814281371 * Z65];
|
|
16198
16578
|
}
|
|
16579
|
+
|
|
16580
|
+
// CIE XYZ relative to D50 -> CIELab
|
|
16199
16581
|
}, {
|
|
16200
16582
|
key: "xyz2LAB",
|
|
16201
16583
|
value: function xyz2LAB(xyz) {
|
|
16202
|
-
var
|
|
16203
|
-
var
|
|
16204
|
-
var
|
|
16205
|
-
var Z = xyz[2] / whitePoint[2];
|
|
16584
|
+
var X = xyz[0] / D50_WHITEPOINT_XYZ[0];
|
|
16585
|
+
var Y = xyz[1] / D50_WHITEPOINT_XYZ[1];
|
|
16586
|
+
var Z = xyz[2] / D50_WHITEPOINT_XYZ[2];
|
|
16206
16587
|
X = Colors.labf(X);
|
|
16207
16588
|
Y = Colors.labf(Y);
|
|
16208
16589
|
Z = Colors.labf(Z);
|
|
@@ -16213,50 +16594,58 @@
|
|
|
16213
16594
|
value: function lab2RGB(lab) {
|
|
16214
16595
|
return Colors.xyz2RGB(Colors.lab2XYZ(lab));
|
|
16215
16596
|
}
|
|
16597
|
+
|
|
16598
|
+
// CIELab -> CIE XYZ relative to D50
|
|
16216
16599
|
}, {
|
|
16217
16600
|
key: "lab2XYZ",
|
|
16218
16601
|
value: function lab2XYZ(lab) {
|
|
16219
16602
|
var L = (lab[0] + 16) / 116;
|
|
16220
16603
|
var a = L + lab[1] / 500;
|
|
16221
16604
|
var b = L - lab[2] / 200;
|
|
16222
|
-
|
|
16223
|
-
return [whitePoint[0] * Colors.labfInv(a), whitePoint[1] * Colors.labfInv(L), whitePoint[2] * Colors.labfInv(b)];
|
|
16605
|
+
return [D50_WHITEPOINT_XYZ[0] * Colors.labfInv(a), D50_WHITEPOINT_XYZ[1] * Colors.labfInv(L), D50_WHITEPOINT_XYZ[2] * Colors.labfInv(b)];
|
|
16224
16606
|
}
|
|
16607
|
+
|
|
16608
|
+
// CIE XYZ relative to D50 -> sRGB, clipped per channel to [0, 1]
|
|
16225
16609
|
}, {
|
|
16226
16610
|
key: "xyz2RGB",
|
|
16227
16611
|
value: function xyz2RGB(xyz) {
|
|
16228
|
-
var
|
|
16229
|
-
|
|
16230
|
-
|
|
16612
|
+
var _xyz = _slicedToArray(xyz, 3),
|
|
16613
|
+
X = _xyz[0],
|
|
16614
|
+
Y = _xyz[1],
|
|
16615
|
+
Z = _xyz[2];
|
|
16231
16616
|
|
|
16232
|
-
|
|
16233
|
-
var
|
|
16234
|
-
|
|
16235
|
-
|
|
16236
|
-
R1 -= minimumComponent;
|
|
16237
|
-
G1 -= minimumComponent;
|
|
16238
|
-
B1 -= minimumComponent;
|
|
16239
|
-
}
|
|
16617
|
+
// chromatic adaptation D50 to D65 (linear Bradford)
|
|
16618
|
+
var X65 = 0.955473421488075 * X - 0.02309845494876471 * Y + 0.06325924320057072 * Z;
|
|
16619
|
+
var Y65 = -0.0283697093338637 * X + 1.0099953980813041 * Y + 0.021041441191917323 * Z;
|
|
16620
|
+
var Z65 = 0.012314014864481998 * X - 0.020507649298898964 * Y + 1.330365926242124 * Z;
|
|
16240
16621
|
|
|
16241
|
-
|
|
16242
|
-
|
|
16622
|
+
// CIE XYZ (D65) to linear RGB
|
|
16623
|
+
var R1 = 12831.0 / 3959.0 * X65 - 329.0 / 214.0 * Y65 - 1974.0 / 3959.0 * Z65;
|
|
16624
|
+
var G1 = -851781 / 878810.0 * X65 + 1648619.0 / 878810.0 * Y65 + 36519.0 / 878810.0 * Z65;
|
|
16625
|
+
var B1 = 705.0 / 12673.0 * X65 - 2585.0 / 12673.0 * Y65 + 705.0 / 667.0 * Z65;
|
|
16626
|
+
|
|
16627
|
+
// Clip to the sRGB gamut (also makes sure that gamma encoding is
|
|
16628
|
+
// well-defined), then transform from linear RGB to sRGB
|
|
16629
|
+
return [Colors.gammaCorrection(clamp01(R1)), Colors.gammaCorrection(clamp01(G1)), Colors.gammaCorrection(clamp01(B1))];
|
|
16243
16630
|
}
|
|
16244
16631
|
}, {
|
|
16245
16632
|
key: "labf",
|
|
16246
16633
|
value: function labf(n) {
|
|
16247
|
-
|
|
16248
|
-
|
|
16634
|
+
// epsilon = (6/29)^3 = 216/24389, kappa = (29/3)^3 = 24389/27
|
|
16635
|
+
if (n > 216.0 / 24389.0) {
|
|
16636
|
+
return Math.cbrt(n);
|
|
16249
16637
|
} else {
|
|
16250
|
-
return
|
|
16638
|
+
return (24389.0 / 27.0 * n + 16.0) / 116.0;
|
|
16251
16639
|
}
|
|
16252
16640
|
}
|
|
16253
16641
|
}, {
|
|
16254
16642
|
key: "labfInv",
|
|
16255
16643
|
value: function labfInv(n) {
|
|
16256
|
-
|
|
16644
|
+
// n > 6/29 <=> n^3 > epsilon
|
|
16645
|
+
if (n > 6.0 / 29.0) {
|
|
16257
16646
|
return n * n * n;
|
|
16258
16647
|
} else {
|
|
16259
|
-
return
|
|
16648
|
+
return (116.0 * n - 16.0) / (24389.0 / 27.0);
|
|
16260
16649
|
}
|
|
16261
16650
|
}
|
|
16262
16651
|
}]);
|
|
@@ -16281,9 +16670,11 @@
|
|
|
16281
16670
|
this.isLittleEndian = options === null || options === void 0 ? void 0 : options.isLittleEndian;
|
|
16282
16671
|
// Default maxFragmentSize is 128 MB (128 * 1024 * 1024 bytes)
|
|
16283
16672
|
this.maxFragmentSize = (_options$maxFragmentS = options === null || options === void 0 ? void 0 : options.maxFragmentSize) !== null && _options$maxFragmentS !== void 0 ? _options$maxFragmentS : 128 * 1024 * 1024;
|
|
16284
|
-
this.stream = new ReadBufferStream(null,
|
|
16673
|
+
this.stream = new ReadBufferStream(null, _objectSpread2(_objectSpread2({
|
|
16285
16674
|
clearBuffers: true
|
|
16286
|
-
}, options)
|
|
16675
|
+
}, options), {}, {
|
|
16676
|
+
littleEndian: this.isLittleEndian
|
|
16677
|
+
}));
|
|
16287
16678
|
}
|
|
16288
16679
|
|
|
16289
16680
|
/** Sentinel returned when stream is Part 10 but has no preamble (starts with meta). */
|
|
@@ -17333,7 +17724,7 @@
|
|
|
17333
17724
|
}
|
|
17334
17725
|
} else {
|
|
17335
17726
|
_value = (_vr$read2 = vr.read(stream, length, syntax)) === null || _vr$read2 === void 0 ? void 0 : _vr$read2.value;
|
|
17336
|
-
if (!vr.isBinary() && singleVRs
|
|
17727
|
+
if (!vr.isBinary() && singleVRs.indexOf(vr.type) == -1) {
|
|
17337
17728
|
values = _value;
|
|
17338
17729
|
if (typeof _value === "string") {
|
|
17339
17730
|
delimiterChar = String.fromCharCode(VM_DELIMITER);
|
|
@@ -26756,12 +27147,8 @@
|
|
|
26756
27147
|
CORNERSTONE_3D_TAG: CORNERSTONE_3D_TAG
|
|
26757
27148
|
};
|
|
26758
27149
|
|
|
26759
|
-
// TODO: Is there a better name for this? RGBAInt?
|
|
26760
|
-
// Should we move it to Colors.js
|
|
26761
27150
|
function dicomlab2RGBA(cielab) {
|
|
26762
|
-
var rgba = Colors.
|
|
26763
|
-
return Math.round(x * 255);
|
|
26764
|
-
});
|
|
27151
|
+
var rgba = Colors.dicomlab2RGB8(cielab);
|
|
26765
27152
|
rgba.push(255);
|
|
26766
27153
|
return rgba;
|
|
26767
27154
|
}
|
|
@@ -30451,7 +30838,7 @@
|
|
|
30451
30838
|
encodingMapping: encodingMapping,
|
|
30452
30839
|
isEncapsulatedSyntax: isEncapsulatedSyntax,
|
|
30453
30840
|
isVideoTransferSyntax: isVideoTransferSyntax,
|
|
30454
|
-
singleVRs: singleVRs
|
|
30841
|
+
singleVRs: singleVRs,
|
|
30455
30842
|
unencapsulatedTransferSyntaxes: unencapsulatedTransferSyntaxes,
|
|
30456
30843
|
videoTransferSyntaxUIDs: videoTransferSyntaxUIDs
|
|
30457
30844
|
});
|