@dcmjs-org/dcmjs 1.0.0-beta.15 → 1.0.0-beta.16
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 +1826 -1529
- 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-CP8p6SfT.js → dcmjs.shared-B2D8KPlB.js} +6 -4
- package/build/dcmjs.shared-B2D8KPlB.js.map +1 -0
- package/build/{dcmjs.shared-DI53lI_H.cjs → dcmjs.shared-D1MD8zKQ.cjs} +6 -4
- package/build/dcmjs.shared-D1MD8zKQ.cjs.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 +7 -7
- 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");
|
|
@@ -8108,1353 +8135,234 @@
|
|
|
8108
8135
|
return val;
|
|
8109
8136
|
}
|
|
8110
8137
|
|
|
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
|
-
}
|
|
8138
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
8134
8139
|
|
|
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
|
-
}
|
|
8140
|
+
function getDefaultExportFromCjs (x) {
|
|
8141
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
8142
|
+
}
|
|
8146
8143
|
|
|
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
|
-
}
|
|
8144
|
+
var loglevel$1 = {exports: {}};
|
|
8160
8145
|
|
|
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
|
-
}
|
|
8146
|
+
/*
|
|
8147
|
+
* loglevel - https://github.com/pimterry/loglevel
|
|
8148
|
+
*
|
|
8149
|
+
* Copyright (c) 2013 Tim Perry
|
|
8150
|
+
* Licensed under the MIT license.
|
|
8151
|
+
*/
|
|
8152
|
+
var loglevel = loglevel$1.exports;
|
|
8187
8153
|
|
|
8188
|
-
|
|
8189
|
-
}, {
|
|
8190
|
-
key: "hasPendingDemand",
|
|
8191
|
-
value: function hasPendingDemand() {
|
|
8192
|
-
return this.availableListeners.length > 0;
|
|
8193
|
-
}
|
|
8154
|
+
var hasRequiredLoglevel;
|
|
8194
8155
|
|
|
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
|
-
}
|
|
8156
|
+
function requireLoglevel () {
|
|
8157
|
+
if (hasRequiredLoglevel) return loglevel$1.exports;
|
|
8158
|
+
hasRequiredLoglevel = 1;
|
|
8159
|
+
(function (module) {
|
|
8160
|
+
(function (root, definition) {
|
|
8161
|
+
if (module.exports) {
|
|
8162
|
+
module.exports = definition();
|
|
8163
|
+
} else {
|
|
8164
|
+
root.log = definition();
|
|
8165
|
+
}
|
|
8166
|
+
}(loglevel, function () {
|
|
8225
8167
|
|
|
8226
|
-
|
|
8227
|
-
|
|
8228
|
-
|
|
8229
|
-
|
|
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
|
-
}
|
|
8168
|
+
// Slightly dubious tricks to cut down minimized file size
|
|
8169
|
+
var noop = function() {};
|
|
8170
|
+
var undefinedType = "undefined";
|
|
8171
|
+
var isIE = (typeof window !== undefinedType) && (typeof window.navigator !== undefinedType) && (
|
|
8172
|
+
/Trident\/|MSIE /.test(window.navigator.userAgent)
|
|
8173
|
+
);
|
|
8357
8174
|
|
|
8358
|
-
|
|
8359
|
-
|
|
8360
|
-
|
|
8361
|
-
|
|
8362
|
-
|
|
8363
|
-
|
|
8364
|
-
|
|
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
|
-
}
|
|
8175
|
+
var logMethods = [
|
|
8176
|
+
"trace",
|
|
8177
|
+
"debug",
|
|
8178
|
+
"info",
|
|
8179
|
+
"warn",
|
|
8180
|
+
"error"
|
|
8181
|
+
];
|
|
8515
8182
|
|
|
8516
|
-
|
|
8517
|
-
|
|
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
|
-
}
|
|
8183
|
+
var _loggersByName = {};
|
|
8184
|
+
var defaultLogger = null;
|
|
8540
8185
|
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8544
|
-
|
|
8545
|
-
|
|
8546
|
-
|
|
8547
|
-
|
|
8548
|
-
|
|
8549
|
-
|
|
8550
|
-
|
|
8551
|
-
|
|
8552
|
-
|
|
8553
|
-
|
|
8554
|
-
|
|
8555
|
-
|
|
8556
|
-
|
|
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
|
-
}
|
|
8186
|
+
// Cross-browser bind equivalent that works at least back to IE6
|
|
8187
|
+
function bindMethod(obj, methodName) {
|
|
8188
|
+
var method = obj[methodName];
|
|
8189
|
+
if (typeof method.bind === 'function') {
|
|
8190
|
+
return method.bind(obj);
|
|
8191
|
+
} else {
|
|
8192
|
+
try {
|
|
8193
|
+
return Function.prototype.bind.call(method, obj);
|
|
8194
|
+
} catch (e) {
|
|
8195
|
+
// Missing bind shim or IE8 + Modernizr, fallback to wrapping
|
|
8196
|
+
return function() {
|
|
8197
|
+
return Function.prototype.apply.apply(method, [obj, arguments]);
|
|
8198
|
+
};
|
|
8199
|
+
}
|
|
8200
|
+
}
|
|
8201
|
+
}
|
|
8657
8202
|
|
|
8658
|
-
|
|
8659
|
-
|
|
8660
|
-
|
|
8661
|
-
|
|
8662
|
-
|
|
8663
|
-
|
|
8664
|
-
|
|
8665
|
-
|
|
8666
|
-
|
|
8667
|
-
|
|
8668
|
-
|
|
8669
|
-
|
|
8670
|
-
}
|
|
8671
|
-
this.view.consume(offset);
|
|
8672
|
-
this.notifyRelayListeners();
|
|
8673
|
-
}
|
|
8203
|
+
// Trace() doesn't print the message in IE, so for that case we need to wrap it
|
|
8204
|
+
function traceForIE() {
|
|
8205
|
+
if (console.log) {
|
|
8206
|
+
if (console.log.apply) {
|
|
8207
|
+
console.log.apply(console, arguments);
|
|
8208
|
+
} else {
|
|
8209
|
+
// In old IE, native console methods themselves don't have apply().
|
|
8210
|
+
Function.prototype.apply.apply(console.log, [console, arguments]);
|
|
8211
|
+
}
|
|
8212
|
+
}
|
|
8213
|
+
if (console.trace) console.trace();
|
|
8214
|
+
}
|
|
8674
8215
|
|
|
8675
|
-
|
|
8676
|
-
|
|
8677
|
-
|
|
8678
|
-
|
|
8679
|
-
|
|
8680
|
-
|
|
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
|
-
}
|
|
8216
|
+
// Build the best logging method possible for this env
|
|
8217
|
+
// Wherever possible we want to bind, not wrap, to preserve stack traces
|
|
8218
|
+
function realMethod(methodName) {
|
|
8219
|
+
if (methodName === 'debug') {
|
|
8220
|
+
methodName = 'log';
|
|
8221
|
+
}
|
|
8690
8222
|
|
|
8691
|
-
|
|
8692
|
-
|
|
8693
|
-
|
|
8694
|
-
|
|
8695
|
-
|
|
8696
|
-
|
|
8697
|
-
|
|
8698
|
-
|
|
8699
|
-
|
|
8700
|
-
|
|
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
|
-
}
|
|
8223
|
+
if (typeof console === undefinedType) {
|
|
8224
|
+
return false; // No method possible, for now - fixed later by enableLoggingWhenConsoleArrives
|
|
8225
|
+
} else if (methodName === 'trace' && isIE) {
|
|
8226
|
+
return traceForIE;
|
|
8227
|
+
} else if (console[methodName] !== undefined) {
|
|
8228
|
+
return bindMethod(console, methodName);
|
|
8229
|
+
} else if (console.log !== undefined) {
|
|
8230
|
+
return bindMethod(console, 'log');
|
|
8231
|
+
} else {
|
|
8232
|
+
return noop;
|
|
8233
|
+
}
|
|
8234
|
+
}
|
|
8718
8235
|
|
|
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
|
-
}();
|
|
8236
|
+
// These private functions always need `this` to be set properly
|
|
8735
8237
|
|
|
8736
|
-
|
|
8737
|
-
|
|
8738
|
-
|
|
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);
|
|
8238
|
+
function replaceLoggingMethods() {
|
|
8239
|
+
/*jshint validthis:true */
|
|
8240
|
+
var level = this.getLevel();
|
|
8899
8241
|
|
|
8900
|
-
|
|
8901
|
-
|
|
8902
|
-
|
|
8903
|
-
|
|
8904
|
-
|
|
8242
|
+
// Replace the actual methods.
|
|
8243
|
+
for (var i = 0; i < logMethods.length; i++) {
|
|
8244
|
+
var methodName = logMethods[i];
|
|
8245
|
+
this[methodName] = (i < level) ?
|
|
8246
|
+
noop :
|
|
8247
|
+
this.methodFactory(methodName, level, this.name);
|
|
8248
|
+
}
|
|
8905
8249
|
|
|
8906
|
-
|
|
8907
|
-
|
|
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;
|
|
8250
|
+
// Define log.log as an alias for log.debug
|
|
8251
|
+
this.log = this.debug;
|
|
8918
8252
|
|
|
8919
|
-
|
|
8920
|
-
|
|
8253
|
+
// Return any important warnings.
|
|
8254
|
+
if (typeof console === undefinedType && level < this.levels.SILENT) {
|
|
8255
|
+
return "No console available for logging";
|
|
8256
|
+
}
|
|
8257
|
+
}
|
|
8921
8258
|
|
|
8922
|
-
|
|
8923
|
-
|
|
8924
|
-
|
|
8925
|
-
|
|
8259
|
+
// In old IE versions, the console isn't present until you first open it.
|
|
8260
|
+
// We build realMethod() replacements here that regenerate logging methods
|
|
8261
|
+
function enableLoggingWhenConsoleArrives(methodName) {
|
|
8262
|
+
return function () {
|
|
8263
|
+
if (typeof console !== undefinedType) {
|
|
8264
|
+
replaceLoggingMethods.call(this);
|
|
8265
|
+
this[methodName].apply(this, arguments);
|
|
8266
|
+
}
|
|
8267
|
+
};
|
|
8268
|
+
}
|
|
8926
8269
|
|
|
8927
|
-
|
|
8928
|
-
|
|
8929
|
-
|
|
8930
|
-
|
|
8270
|
+
// By default, we use closely bound real methods wherever possible, and
|
|
8271
|
+
// otherwise we wait for a console to appear, and then try again.
|
|
8272
|
+
function defaultMethodFactory(methodName, _level, _loggerName) {
|
|
8273
|
+
/*jshint validthis:true */
|
|
8274
|
+
return realMethod(methodName) ||
|
|
8275
|
+
enableLoggingWhenConsoleArrives.apply(this, arguments);
|
|
8276
|
+
}
|
|
8931
8277
|
|
|
8932
|
-
|
|
8933
|
-
|
|
8934
|
-
|
|
8935
|
-
|
|
8936
|
-
|
|
8937
|
-
|
|
8278
|
+
function Logger(name, factory) {
|
|
8279
|
+
// Private instance variables.
|
|
8280
|
+
var self = this;
|
|
8281
|
+
/**
|
|
8282
|
+
* The level inherited from a parent logger (or a global default). We
|
|
8283
|
+
* cache this here rather than delegating to the parent so that it stays
|
|
8284
|
+
* in sync with the actual logging methods that we have installed (the
|
|
8285
|
+
* parent could change levels but we might not have rebuilt the loggers
|
|
8286
|
+
* in this child yet).
|
|
8287
|
+
* @type {number}
|
|
8288
|
+
*/
|
|
8289
|
+
var inheritedLevel;
|
|
8290
|
+
/**
|
|
8291
|
+
* The default level for this logger, if any. If set, this overrides
|
|
8292
|
+
* `inheritedLevel`.
|
|
8293
|
+
* @type {number|null}
|
|
8294
|
+
*/
|
|
8295
|
+
var defaultLevel;
|
|
8296
|
+
/**
|
|
8297
|
+
* A user-specific level for this logger. If set, this overrides
|
|
8298
|
+
* `defaultLevel`.
|
|
8299
|
+
* @type {number|null}
|
|
8300
|
+
*/
|
|
8301
|
+
var userLevel;
|
|
8938
8302
|
|
|
8939
|
-
|
|
8940
|
-
|
|
8941
|
-
|
|
8303
|
+
var storageKey = "loglevel";
|
|
8304
|
+
if (typeof name === "string") {
|
|
8305
|
+
storageKey += ":" + name;
|
|
8306
|
+
} else if (typeof name === "symbol") {
|
|
8307
|
+
storageKey = undefined;
|
|
8308
|
+
}
|
|
8942
8309
|
|
|
8943
|
-
|
|
8944
|
-
|
|
8945
|
-
// late-binding DicomMessage slot.
|
|
8946
|
-
function isEncapsulatedSyntax(syntax) {
|
|
8947
|
-
return !unencapsulatedTransferSyntaxes[syntax];
|
|
8948
|
-
}
|
|
8310
|
+
function persistLevelIfPossible(levelNum) {
|
|
8311
|
+
var levelName = (logMethods[levelNum] || 'silent').toUpperCase();
|
|
8949
8312
|
|
|
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
|
-
]);
|
|
8313
|
+
if (typeof window === undefinedType || !storageKey) return;
|
|
8987
8314
|
|
|
8988
|
-
|
|
8989
|
-
|
|
8990
|
-
|
|
8991
|
-
|
|
8992
|
-
|
|
8993
|
-
function isVideoTransferSyntax(uid) {
|
|
8994
|
-
return uid && videoTransferSyntaxUIDs.has(uid);
|
|
8995
|
-
}
|
|
8315
|
+
// Use localStorage if available
|
|
8316
|
+
try {
|
|
8317
|
+
window.localStorage[storageKey] = levelName;
|
|
8318
|
+
return;
|
|
8319
|
+
} catch (ignore) {}
|
|
8996
8320
|
|
|
8997
|
-
|
|
8998
|
-
|
|
8999
|
-
|
|
9000
|
-
|
|
9001
|
-
|
|
9002
|
-
|
|
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
|
-
};
|
|
8321
|
+
// Use session cookie as fallback
|
|
8322
|
+
try {
|
|
8323
|
+
window.document.cookie =
|
|
8324
|
+
encodeURIComponent(storageKey) + "=" + levelName + ";";
|
|
8325
|
+
} catch (ignore) {}
|
|
8326
|
+
}
|
|
9080
8327
|
|
|
9081
|
-
|
|
9082
|
-
|
|
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
|
-
]);
|
|
8328
|
+
function getPersistedLevel() {
|
|
8329
|
+
var storedLevel;
|
|
9110
8330
|
|
|
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
|
-
]);
|
|
8331
|
+
if (typeof window === undefinedType || !storageKey) return;
|
|
9182
8332
|
|
|
9183
|
-
|
|
9184
|
-
|
|
9185
|
-
|
|
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
|
-
]);
|
|
8333
|
+
try {
|
|
8334
|
+
storedLevel = window.localStorage[storageKey];
|
|
8335
|
+
} catch (ignore) {}
|
|
9229
8336
|
|
|
9230
|
-
|
|
8337
|
+
// Fallback to cookies if local storage gives us nothing
|
|
8338
|
+
if (typeof storedLevel === undefinedType) {
|
|
8339
|
+
try {
|
|
8340
|
+
var cookie = window.document.cookie;
|
|
8341
|
+
var cookieName = encodeURIComponent(storageKey);
|
|
8342
|
+
var location = cookie.indexOf(cookieName + "=");
|
|
8343
|
+
if (location !== -1) {
|
|
8344
|
+
storedLevel = /^([^;]+)/.exec(
|
|
8345
|
+
cookie.slice(location + cookieName.length + 1)
|
|
8346
|
+
)[1];
|
|
8347
|
+
}
|
|
8348
|
+
} catch (ignore) {}
|
|
8349
|
+
}
|
|
9231
8350
|
|
|
9232
|
-
|
|
9233
|
-
|
|
9234
|
-
|
|
8351
|
+
// If the stored level is not valid, treat it as if nothing was stored.
|
|
8352
|
+
if (self.levels[storedLevel] === undefined) {
|
|
8353
|
+
storedLevel = undefined;
|
|
8354
|
+
}
|
|
9235
8355
|
|
|
9236
|
-
|
|
8356
|
+
return storedLevel;
|
|
8357
|
+
}
|
|
9237
8358
|
|
|
9238
|
-
|
|
9239
|
-
|
|
9240
|
-
*
|
|
9241
|
-
* Copyright (c) 2013 Tim Perry
|
|
9242
|
-
* Licensed under the MIT license.
|
|
9243
|
-
*/
|
|
9244
|
-
var loglevel = loglevel$1.exports;
|
|
8359
|
+
function clearPersistedLevel() {
|
|
8360
|
+
if (typeof window === undefinedType || !storageKey) return;
|
|
9245
8361
|
|
|
9246
|
-
|
|
9247
|
-
|
|
9248
|
-
|
|
9249
|
-
|
|
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 () {
|
|
9259
|
-
|
|
9260
|
-
// Slightly dubious tricks to cut down minimized file size
|
|
9261
|
-
var noop = function() {};
|
|
9262
|
-
var undefinedType = "undefined";
|
|
9263
|
-
var isIE = (typeof window !== undefinedType) && (typeof window.navigator !== undefinedType) && (
|
|
9264
|
-
/Trident\/|MSIE /.test(window.navigator.userAgent)
|
|
9265
|
-
);
|
|
9266
|
-
|
|
9267
|
-
var logMethods = [
|
|
9268
|
-
"trace",
|
|
9269
|
-
"debug",
|
|
9270
|
-
"info",
|
|
9271
|
-
"warn",
|
|
9272
|
-
"error"
|
|
9273
|
-
];
|
|
9274
|
-
|
|
9275
|
-
var _loggersByName = {};
|
|
9276
|
-
var defaultLogger = null;
|
|
9277
|
-
|
|
9278
|
-
// Cross-browser bind equivalent that works at least back to IE6
|
|
9279
|
-
function bindMethod(obj, methodName) {
|
|
9280
|
-
var method = obj[methodName];
|
|
9281
|
-
if (typeof method.bind === 'function') {
|
|
9282
|
-
return method.bind(obj);
|
|
9283
|
-
} else {
|
|
9284
|
-
try {
|
|
9285
|
-
return Function.prototype.bind.call(method, obj);
|
|
9286
|
-
} catch (e) {
|
|
9287
|
-
// Missing bind shim or IE8 + Modernizr, fallback to wrapping
|
|
9288
|
-
return function() {
|
|
9289
|
-
return Function.prototype.apply.apply(method, [obj, arguments]);
|
|
9290
|
-
};
|
|
9291
|
-
}
|
|
9292
|
-
}
|
|
9293
|
-
}
|
|
9294
|
-
|
|
9295
|
-
// Trace() doesn't print the message in IE, so for that case we need to wrap it
|
|
9296
|
-
function traceForIE() {
|
|
9297
|
-
if (console.log) {
|
|
9298
|
-
if (console.log.apply) {
|
|
9299
|
-
console.log.apply(console, arguments);
|
|
9300
|
-
} else {
|
|
9301
|
-
// In old IE, native console methods themselves don't have apply().
|
|
9302
|
-
Function.prototype.apply.apply(console.log, [console, arguments]);
|
|
9303
|
-
}
|
|
9304
|
-
}
|
|
9305
|
-
if (console.trace) console.trace();
|
|
9306
|
-
}
|
|
9307
|
-
|
|
9308
|
-
// Build the best logging method possible for this env
|
|
9309
|
-
// Wherever possible we want to bind, not wrap, to preserve stack traces
|
|
9310
|
-
function realMethod(methodName) {
|
|
9311
|
-
if (methodName === 'debug') {
|
|
9312
|
-
methodName = 'log';
|
|
9313
|
-
}
|
|
9314
|
-
|
|
9315
|
-
if (typeof console === undefinedType) {
|
|
9316
|
-
return false; // No method possible, for now - fixed later by enableLoggingWhenConsoleArrives
|
|
9317
|
-
} else if (methodName === 'trace' && isIE) {
|
|
9318
|
-
return traceForIE;
|
|
9319
|
-
} else if (console[methodName] !== undefined) {
|
|
9320
|
-
return bindMethod(console, methodName);
|
|
9321
|
-
} else if (console.log !== undefined) {
|
|
9322
|
-
return bindMethod(console, 'log');
|
|
9323
|
-
} else {
|
|
9324
|
-
return noop;
|
|
9325
|
-
}
|
|
9326
|
-
}
|
|
9327
|
-
|
|
9328
|
-
// These private functions always need `this` to be set properly
|
|
9329
|
-
|
|
9330
|
-
function replaceLoggingMethods() {
|
|
9331
|
-
/*jshint validthis:true */
|
|
9332
|
-
var level = this.getLevel();
|
|
9333
|
-
|
|
9334
|
-
// Replace the actual methods.
|
|
9335
|
-
for (var i = 0; i < logMethods.length; i++) {
|
|
9336
|
-
var methodName = logMethods[i];
|
|
9337
|
-
this[methodName] = (i < level) ?
|
|
9338
|
-
noop :
|
|
9339
|
-
this.methodFactory(methodName, level, this.name);
|
|
9340
|
-
}
|
|
9341
|
-
|
|
9342
|
-
// Define log.log as an alias for log.debug
|
|
9343
|
-
this.log = this.debug;
|
|
9344
|
-
|
|
9345
|
-
// Return any important warnings.
|
|
9346
|
-
if (typeof console === undefinedType && level < this.levels.SILENT) {
|
|
9347
|
-
return "No console available for logging";
|
|
9348
|
-
}
|
|
9349
|
-
}
|
|
9350
|
-
|
|
9351
|
-
// In old IE versions, the console isn't present until you first open it.
|
|
9352
|
-
// We build realMethod() replacements here that regenerate logging methods
|
|
9353
|
-
function enableLoggingWhenConsoleArrives(methodName) {
|
|
9354
|
-
return function () {
|
|
9355
|
-
if (typeof console !== undefinedType) {
|
|
9356
|
-
replaceLoggingMethods.call(this);
|
|
9357
|
-
this[methodName].apply(this, arguments);
|
|
9358
|
-
}
|
|
9359
|
-
};
|
|
9360
|
-
}
|
|
9361
|
-
|
|
9362
|
-
// By default, we use closely bound real methods wherever possible, and
|
|
9363
|
-
// otherwise we wait for a console to appear, and then try again.
|
|
9364
|
-
function defaultMethodFactory(methodName, _level, _loggerName) {
|
|
9365
|
-
/*jshint validthis:true */
|
|
9366
|
-
return realMethod(methodName) ||
|
|
9367
|
-
enableLoggingWhenConsoleArrives.apply(this, arguments);
|
|
9368
|
-
}
|
|
9369
|
-
|
|
9370
|
-
function Logger(name, factory) {
|
|
9371
|
-
// Private instance variables.
|
|
9372
|
-
var self = this;
|
|
9373
|
-
/**
|
|
9374
|
-
* The level inherited from a parent logger (or a global default). We
|
|
9375
|
-
* cache this here rather than delegating to the parent so that it stays
|
|
9376
|
-
* in sync with the actual logging methods that we have installed (the
|
|
9377
|
-
* parent could change levels but we might not have rebuilt the loggers
|
|
9378
|
-
* in this child yet).
|
|
9379
|
-
* @type {number}
|
|
9380
|
-
*/
|
|
9381
|
-
var inheritedLevel;
|
|
9382
|
-
/**
|
|
9383
|
-
* The default level for this logger, if any. If set, this overrides
|
|
9384
|
-
* `inheritedLevel`.
|
|
9385
|
-
* @type {number|null}
|
|
9386
|
-
*/
|
|
9387
|
-
var defaultLevel;
|
|
9388
|
-
/**
|
|
9389
|
-
* A user-specific level for this logger. If set, this overrides
|
|
9390
|
-
* `defaultLevel`.
|
|
9391
|
-
* @type {number|null}
|
|
9392
|
-
*/
|
|
9393
|
-
var userLevel;
|
|
9394
|
-
|
|
9395
|
-
var storageKey = "loglevel";
|
|
9396
|
-
if (typeof name === "string") {
|
|
9397
|
-
storageKey += ":" + name;
|
|
9398
|
-
} else if (typeof name === "symbol") {
|
|
9399
|
-
storageKey = undefined;
|
|
9400
|
-
}
|
|
9401
|
-
|
|
9402
|
-
function persistLevelIfPossible(levelNum) {
|
|
9403
|
-
var levelName = (logMethods[levelNum] || 'silent').toUpperCase();
|
|
9404
|
-
|
|
9405
|
-
if (typeof window === undefinedType || !storageKey) return;
|
|
9406
|
-
|
|
9407
|
-
// Use localStorage if available
|
|
9408
|
-
try {
|
|
9409
|
-
window.localStorage[storageKey] = levelName;
|
|
9410
|
-
return;
|
|
9411
|
-
} catch (ignore) {}
|
|
9412
|
-
|
|
9413
|
-
// Use session cookie as fallback
|
|
9414
|
-
try {
|
|
9415
|
-
window.document.cookie =
|
|
9416
|
-
encodeURIComponent(storageKey) + "=" + levelName + ";";
|
|
9417
|
-
} catch (ignore) {}
|
|
9418
|
-
}
|
|
9419
|
-
|
|
9420
|
-
function getPersistedLevel() {
|
|
9421
|
-
var storedLevel;
|
|
9422
|
-
|
|
9423
|
-
if (typeof window === undefinedType || !storageKey) return;
|
|
9424
|
-
|
|
9425
|
-
try {
|
|
9426
|
-
storedLevel = window.localStorage[storageKey];
|
|
9427
|
-
} catch (ignore) {}
|
|
9428
|
-
|
|
9429
|
-
// Fallback to cookies if local storage gives us nothing
|
|
9430
|
-
if (typeof storedLevel === undefinedType) {
|
|
9431
|
-
try {
|
|
9432
|
-
var cookie = window.document.cookie;
|
|
9433
|
-
var cookieName = encodeURIComponent(storageKey);
|
|
9434
|
-
var location = cookie.indexOf(cookieName + "=");
|
|
9435
|
-
if (location !== -1) {
|
|
9436
|
-
storedLevel = /^([^;]+)/.exec(
|
|
9437
|
-
cookie.slice(location + cookieName.length + 1)
|
|
9438
|
-
)[1];
|
|
9439
|
-
}
|
|
9440
|
-
} catch (ignore) {}
|
|
9441
|
-
}
|
|
9442
|
-
|
|
9443
|
-
// If the stored level is not valid, treat it as if nothing was stored.
|
|
9444
|
-
if (self.levels[storedLevel] === undefined) {
|
|
9445
|
-
storedLevel = undefined;
|
|
9446
|
-
}
|
|
9447
|
-
|
|
9448
|
-
return storedLevel;
|
|
9449
|
-
}
|
|
9450
|
-
|
|
9451
|
-
function clearPersistedLevel() {
|
|
9452
|
-
if (typeof window === undefinedType || !storageKey) return;
|
|
9453
|
-
|
|
9454
|
-
// Use localStorage if available
|
|
9455
|
-
try {
|
|
9456
|
-
window.localStorage.removeItem(storageKey);
|
|
9457
|
-
} catch (ignore) {}
|
|
8362
|
+
// Use localStorage if available
|
|
8363
|
+
try {
|
|
8364
|
+
window.localStorage.removeItem(storageKey);
|
|
8365
|
+
} catch (ignore) {}
|
|
9458
8366
|
|
|
9459
8367
|
// Use session cookie as fallback
|
|
9460
8368
|
try {
|
|
@@ -9488,151 +8396,1368 @@
|
|
|
9488
8396
|
|
|
9489
8397
|
self.methodFactory = factory || defaultMethodFactory;
|
|
9490
8398
|
|
|
9491
|
-
self.getLevel = function () {
|
|
9492
|
-
if (userLevel != null) {
|
|
9493
|
-
return userLevel;
|
|
9494
|
-
} else if (defaultLevel != null) {
|
|
9495
|
-
return defaultLevel;
|
|
9496
|
-
} else {
|
|
9497
|
-
return inheritedLevel;
|
|
9498
|
-
}
|
|
9499
|
-
};
|
|
8399
|
+
self.getLevel = function () {
|
|
8400
|
+
if (userLevel != null) {
|
|
8401
|
+
return userLevel;
|
|
8402
|
+
} else if (defaultLevel != null) {
|
|
8403
|
+
return defaultLevel;
|
|
8404
|
+
} else {
|
|
8405
|
+
return inheritedLevel;
|
|
8406
|
+
}
|
|
8407
|
+
};
|
|
8408
|
+
|
|
8409
|
+
self.setLevel = function (level, persist) {
|
|
8410
|
+
userLevel = normalizeLevel(level);
|
|
8411
|
+
if (persist !== false) { // defaults to true
|
|
8412
|
+
persistLevelIfPossible(userLevel);
|
|
8413
|
+
}
|
|
8414
|
+
|
|
8415
|
+
// NOTE: in v2, this should call rebuild(), which updates children.
|
|
8416
|
+
return replaceLoggingMethods.call(self);
|
|
8417
|
+
};
|
|
8418
|
+
|
|
8419
|
+
self.setDefaultLevel = function (level) {
|
|
8420
|
+
defaultLevel = normalizeLevel(level);
|
|
8421
|
+
if (!getPersistedLevel()) {
|
|
8422
|
+
self.setLevel(level, false);
|
|
8423
|
+
}
|
|
8424
|
+
};
|
|
8425
|
+
|
|
8426
|
+
self.resetLevel = function () {
|
|
8427
|
+
userLevel = null;
|
|
8428
|
+
clearPersistedLevel();
|
|
8429
|
+
replaceLoggingMethods.call(self);
|
|
8430
|
+
};
|
|
8431
|
+
|
|
8432
|
+
self.enableAll = function(persist) {
|
|
8433
|
+
self.setLevel(self.levels.TRACE, persist);
|
|
8434
|
+
};
|
|
8435
|
+
|
|
8436
|
+
self.disableAll = function(persist) {
|
|
8437
|
+
self.setLevel(self.levels.SILENT, persist);
|
|
8438
|
+
};
|
|
8439
|
+
|
|
8440
|
+
self.rebuild = function () {
|
|
8441
|
+
if (defaultLogger !== self) {
|
|
8442
|
+
inheritedLevel = normalizeLevel(defaultLogger.getLevel());
|
|
8443
|
+
}
|
|
8444
|
+
replaceLoggingMethods.call(self);
|
|
8445
|
+
|
|
8446
|
+
if (defaultLogger === self) {
|
|
8447
|
+
for (var childName in _loggersByName) {
|
|
8448
|
+
_loggersByName[childName].rebuild();
|
|
8449
|
+
}
|
|
8450
|
+
}
|
|
8451
|
+
};
|
|
8452
|
+
|
|
8453
|
+
// Initialize all the internal levels.
|
|
8454
|
+
inheritedLevel = normalizeLevel(
|
|
8455
|
+
defaultLogger ? defaultLogger.getLevel() : "WARN"
|
|
8456
|
+
);
|
|
8457
|
+
var initialLevel = getPersistedLevel();
|
|
8458
|
+
if (initialLevel != null) {
|
|
8459
|
+
userLevel = normalizeLevel(initialLevel);
|
|
8460
|
+
}
|
|
8461
|
+
replaceLoggingMethods.call(self);
|
|
8462
|
+
}
|
|
8463
|
+
|
|
8464
|
+
/*
|
|
8465
|
+
*
|
|
8466
|
+
* Top-level API
|
|
8467
|
+
*
|
|
8468
|
+
*/
|
|
8469
|
+
|
|
8470
|
+
defaultLogger = new Logger();
|
|
8471
|
+
|
|
8472
|
+
defaultLogger.getLogger = function getLogger(name) {
|
|
8473
|
+
if ((typeof name !== "symbol" && typeof name !== "string") || name === "") {
|
|
8474
|
+
throw new TypeError("You must supply a name when creating a logger.");
|
|
8475
|
+
}
|
|
8476
|
+
|
|
8477
|
+
var logger = _loggersByName[name];
|
|
8478
|
+
if (!logger) {
|
|
8479
|
+
logger = _loggersByName[name] = new Logger(
|
|
8480
|
+
name,
|
|
8481
|
+
defaultLogger.methodFactory
|
|
8482
|
+
);
|
|
8483
|
+
}
|
|
8484
|
+
return logger;
|
|
8485
|
+
};
|
|
8486
|
+
|
|
8487
|
+
// Grab the current global log variable in case of overwrite
|
|
8488
|
+
var _log = (typeof window !== undefinedType) ? window.log : undefined;
|
|
8489
|
+
defaultLogger.noConflict = function() {
|
|
8490
|
+
if (typeof window !== undefinedType &&
|
|
8491
|
+
window.log === defaultLogger) {
|
|
8492
|
+
window.log = _log;
|
|
8493
|
+
}
|
|
8494
|
+
|
|
8495
|
+
return defaultLogger;
|
|
8496
|
+
};
|
|
8497
|
+
|
|
8498
|
+
defaultLogger.getLoggers = function getLoggers() {
|
|
8499
|
+
return _loggersByName;
|
|
8500
|
+
};
|
|
8501
|
+
|
|
8502
|
+
// ES6 default export, for compatibility
|
|
8503
|
+
defaultLogger['default'] = defaultLogger;
|
|
8504
|
+
|
|
8505
|
+
return defaultLogger;
|
|
8506
|
+
}));
|
|
8507
|
+
} (loglevel$1));
|
|
8508
|
+
return loglevel$1.exports;
|
|
8509
|
+
}
|
|
8510
|
+
|
|
8511
|
+
var loglevelExports = requireLoglevel();
|
|
8512
|
+
var log = /*@__PURE__*/getDefaultExportFromCjs(loglevelExports);
|
|
8513
|
+
|
|
8514
|
+
var _toLogLevel;
|
|
8515
|
+
|
|
8516
|
+
// The root rollup build replaces the read below with the build-time level;
|
|
8517
|
+
// elsewhere a browser has no `process`, so the read can throw.
|
|
8518
|
+
var level;
|
|
8519
|
+
try {
|
|
8520
|
+
level = "warn";
|
|
8521
|
+
} catch (_unused) {
|
|
8522
|
+
level = undefined;
|
|
8523
|
+
}
|
|
8524
|
+
log.setLevel((_toLogLevel = toLogLevel(level)) !== null && _toLogLevel !== void 0 ? _toLogLevel : "warn");
|
|
8525
|
+
|
|
8526
|
+
/**
|
|
8527
|
+
* The loglevel level of a value: a level name (case-insensitive), or a
|
|
8528
|
+
* number from 0 to 5, also as a string ("1"), because an environment
|
|
8529
|
+
* variable is a string. Undefined for any other value, for example
|
|
8530
|
+
* "verbose" (winston) or "fatal" (pino), for which loglevel 1.9 throws
|
|
8531
|
+
* (pimterry/loglevel#210 proposes log.parseLevel for this check).
|
|
8532
|
+
*/
|
|
8533
|
+
function toLogLevel(value) {
|
|
8534
|
+
if (typeof value === "string" && /^[0-5]$/.test(value)) {
|
|
8535
|
+
return Number(value);
|
|
8536
|
+
}
|
|
8537
|
+
if (typeof value === "string") {
|
|
8538
|
+
var _log$levels;
|
|
8539
|
+
return ((_log$levels = log.levels) === null || _log$levels === void 0 ? void 0 : _log$levels[value.toUpperCase()]) !== undefined ? value : undefined;
|
|
8540
|
+
}
|
|
8541
|
+
return typeof value === "number" && value >= 0 && value <= 5 ? value : undefined;
|
|
8542
|
+
}
|
|
8543
|
+
var validationLog = log.getLogger("validation.dcmjs");
|
|
8544
|
+
|
|
8545
|
+
var _excluded = ["littleEndian", "start", "stop", "noCopy", "clearBuffers"];
|
|
8546
|
+
var legacyWarned = new Set();
|
|
8547
|
+
|
|
8548
|
+
/** Warns once per class that a positional (0.x) constructor form was used. */
|
|
8549
|
+
function warnLegacyConstructor(className, newForm) {
|
|
8550
|
+
if (!legacyWarned.has(className)) {
|
|
8551
|
+
legacyWarned.add(className);
|
|
8552
|
+
log.warn("".concat(className, ": the positional constructor arguments are deprecated; use ").concat(newForm));
|
|
8553
|
+
}
|
|
8554
|
+
}
|
|
8555
|
+
var BufferStream = /*#__PURE__*/function () {
|
|
8556
|
+
/** @param {{littleEndian?: boolean, defaultSize?: number, clearBuffers?: boolean}} [options] */
|
|
8557
|
+
function BufferStream() {
|
|
8558
|
+
var _options$littleEndian, _options$defaultSize;
|
|
8559
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
8560
|
+
_classCallCheck(this, BufferStream);
|
|
8561
|
+
_defineProperty(this, "offset", 0);
|
|
8562
|
+
_defineProperty(this, "startOffset", 0);
|
|
8563
|
+
_defineProperty(this, "isLittleEndian", true);
|
|
8564
|
+
_defineProperty(this, "size", 0);
|
|
8565
|
+
_defineProperty(this, "view", new SplitDataView());
|
|
8566
|
+
/** The available listeners are those waiting for a query response */
|
|
8567
|
+
_defineProperty(this, "availableListeners", []);
|
|
8568
|
+
/** Producers throttled until the consumer consumes or shows new demand */
|
|
8569
|
+
_defineProperty(this, "relayListeners", []);
|
|
8570
|
+
/** Indicates if this buffer stream is complete/has finished being created */
|
|
8571
|
+
_defineProperty(this, "isComplete", false);
|
|
8572
|
+
/** A flag to set to indicate to clear buffers as they get consumed */
|
|
8573
|
+
_defineProperty(this, "clearBuffers", false);
|
|
8574
|
+
_defineProperty(this, "encoder", new TextEncoder("utf-8"));
|
|
8575
|
+
this.isLittleEndian = (_options$littleEndian = options === null || options === void 0 ? void 0 : options.littleEndian) !== null && _options$littleEndian !== void 0 ? _options$littleEndian : this.isLittleEndian;
|
|
8576
|
+
this.view.defaultSize = (_options$defaultSize = options === null || options === void 0 ? void 0 : options.defaultSize) !== null && _options$defaultSize !== void 0 ? _options$defaultSize : this.view.defaultSize;
|
|
8577
|
+
this.clearBuffers = (options === null || options === void 0 ? void 0 : options.clearBuffers) || false;
|
|
8578
|
+
}
|
|
8579
|
+
|
|
8580
|
+
/**
|
|
8581
|
+
* Mark this stream as having finished being written or read from
|
|
8582
|
+
*/
|
|
8583
|
+
return _createClass(BufferStream, [{
|
|
8584
|
+
key: "setComplete",
|
|
8585
|
+
value: function setComplete() {
|
|
8586
|
+
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
8587
|
+
this.isComplete = value;
|
|
8588
|
+
this.notifyAvailableListeners();
|
|
8589
|
+
this.notifyRelayListeners();
|
|
8590
|
+
}
|
|
8591
|
+
|
|
8592
|
+
/**
|
|
8593
|
+
* Indicates if the value length is currently available in the already
|
|
8594
|
+
* read/defined portion of the stream.
|
|
8595
|
+
*
|
|
8596
|
+
* By default this will test if the buffer is complete as well,
|
|
8597
|
+
* but this can be changed with orComplete=false.
|
|
8598
|
+
*/
|
|
8599
|
+
}, {
|
|
8600
|
+
key: "isAvailable",
|
|
8601
|
+
value: function isAvailable(length) {
|
|
8602
|
+
var orComplete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
8603
|
+
return this.offset + length <= this.endOffset || orComplete && this.isComplete;
|
|
8604
|
+
}
|
|
8605
|
+
|
|
8606
|
+
/**
|
|
8607
|
+
* Ensures that the specified number of bytes are available OR that it is
|
|
8608
|
+
* EOF. By default waits for at least 1k to be available.
|
|
8609
|
+
*/
|
|
8610
|
+
}, {
|
|
8611
|
+
key: "ensureAvailable",
|
|
8612
|
+
value: function ensureAvailable() {
|
|
8613
|
+
var _this = this;
|
|
8614
|
+
var bytes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1024;
|
|
8615
|
+
if (!this.isAvailable(bytes)) {
|
|
8616
|
+
return new Promise(function (resolve) {
|
|
8617
|
+
var _recheckAvailable = function recheckAvailable() {
|
|
8618
|
+
if (_this.isAvailable(bytes)) {
|
|
8619
|
+
resolve(true);
|
|
8620
|
+
return;
|
|
8621
|
+
}
|
|
8622
|
+
_this.availableListeners.push(_recheckAvailable);
|
|
8623
|
+
// Demand appeared — wake any throttled producer so a
|
|
8624
|
+
// starved consumer can never deadlock against it.
|
|
8625
|
+
_this.notifyRelayListeners();
|
|
8626
|
+
};
|
|
8627
|
+
_recheckAvailable();
|
|
8628
|
+
});
|
|
8629
|
+
}
|
|
8630
|
+
return true;
|
|
8631
|
+
}
|
|
8632
|
+
|
|
8633
|
+
/** True when a consumer is blocked waiting for more bytes. */
|
|
8634
|
+
}, {
|
|
8635
|
+
key: "hasPendingDemand",
|
|
8636
|
+
value: function hasPendingDemand() {
|
|
8637
|
+
return this.availableListeners.length > 0;
|
|
8638
|
+
}
|
|
8639
|
+
|
|
8640
|
+
/** Resolves on the next consumer activity (consume or new demand). */
|
|
8641
|
+
}, {
|
|
8642
|
+
key: "awaitConsumerActivity",
|
|
8643
|
+
value: function awaitConsumerActivity() {
|
|
8644
|
+
var _this2 = this;
|
|
8645
|
+
return new Promise(function (resolve) {
|
|
8646
|
+
return _this2.relayListeners.push(resolve);
|
|
8647
|
+
});
|
|
8648
|
+
}
|
|
8649
|
+
}, {
|
|
8650
|
+
key: "notifyRelayListeners",
|
|
8651
|
+
value: function notifyRelayListeners() {
|
|
8652
|
+
var existingListeners = _toConsumableArray(this.relayListeners);
|
|
8653
|
+
this.relayListeners.splice(0, this.relayListeners.length);
|
|
8654
|
+
existingListeners.forEach(function (listener) {
|
|
8655
|
+
return listener();
|
|
8656
|
+
});
|
|
8657
|
+
}
|
|
8658
|
+
}, {
|
|
8659
|
+
key: "setEndian",
|
|
8660
|
+
value: function setEndian(isLittle) {
|
|
8661
|
+
this.isLittleEndian = isLittle;
|
|
8662
|
+
}
|
|
8663
|
+
}, {
|
|
8664
|
+
key: "slice",
|
|
8665
|
+
value: function slice() {
|
|
8666
|
+
var start = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.startOffset;
|
|
8667
|
+
var end = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.endOffset;
|
|
8668
|
+
return this.view.slice(start, end);
|
|
8669
|
+
}
|
|
8670
|
+
|
|
8671
|
+
/**
|
|
8672
|
+
* @deprecated Gets the entire buffer at once. Suggest using the
|
|
8673
|
+
* view instead, and writing an iterator over the parts to finish
|
|
8674
|
+
* writing it.
|
|
8675
|
+
*/
|
|
8676
|
+
}, {
|
|
8677
|
+
key: "getBuffer",
|
|
8678
|
+
value: function getBuffer() {
|
|
8679
|
+
var start = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
8680
|
+
var end = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.size;
|
|
8681
|
+
if (this.noCopy) {
|
|
8682
|
+
return new Uint8Array(this.slice(start, end));
|
|
8683
|
+
}
|
|
8684
|
+
return this.slice(start, end);
|
|
8685
|
+
}
|
|
8686
|
+
}, {
|
|
8687
|
+
key: "buffer",
|
|
8688
|
+
get: function get() {
|
|
8689
|
+
// console.warn("Deprecated buffer get");
|
|
8690
|
+
return this.getBuffer();
|
|
8691
|
+
}
|
|
8692
|
+
}, {
|
|
8693
|
+
key: "available",
|
|
8694
|
+
get: function get() {
|
|
8695
|
+
return this.endOffset - this.offset;
|
|
8696
|
+
}
|
|
8697
|
+
}, {
|
|
8698
|
+
key: "writeUint8",
|
|
8699
|
+
value: function writeUint8(value) {
|
|
8700
|
+
this.checkSize(1);
|
|
8701
|
+
this.view.setUint8(this.offset, toInt(value));
|
|
8702
|
+
return this.increment(1);
|
|
8703
|
+
}
|
|
8704
|
+
}, {
|
|
8705
|
+
key: "writeUint8Repeat",
|
|
8706
|
+
value: function writeUint8Repeat(value, count) {
|
|
8707
|
+
var v = toInt(value);
|
|
8708
|
+
this.checkSize(count);
|
|
8709
|
+
for (var i = 0; i < count; i++) {
|
|
8710
|
+
this.view.setUint8(this.offset + i, v);
|
|
8711
|
+
}
|
|
8712
|
+
return this.increment(count);
|
|
8713
|
+
}
|
|
8714
|
+
}, {
|
|
8715
|
+
key: "writeInt8",
|
|
8716
|
+
value: function writeInt8(value) {
|
|
8717
|
+
this.checkSize(1);
|
|
8718
|
+
this.view.setInt8(this.offset, toInt(value));
|
|
8719
|
+
return this.increment(1);
|
|
8720
|
+
}
|
|
8721
|
+
}, {
|
|
8722
|
+
key: "writeUint16",
|
|
8723
|
+
value: function writeUint16(value) {
|
|
8724
|
+
this.checkSize(2);
|
|
8725
|
+
this.view.setUint16(this.offset, toInt(value), this.isLittleEndian);
|
|
8726
|
+
return this.increment(2);
|
|
8727
|
+
}
|
|
8728
|
+
}, {
|
|
8729
|
+
key: "writeTwoUint16s",
|
|
8730
|
+
value: function writeTwoUint16s(value) {
|
|
8731
|
+
this.checkSize(4);
|
|
8732
|
+
var first = value >> 16;
|
|
8733
|
+
var second = value & 0xffff;
|
|
8734
|
+
this.view.setUint16(this.offset, toInt(first), this.isLittleEndian);
|
|
8735
|
+
this.view.setUint16(this.offset + 2, toInt(second), this.isLittleEndian);
|
|
8736
|
+
return this.increment(4);
|
|
8737
|
+
}
|
|
8738
|
+
}, {
|
|
8739
|
+
key: "writeInt16",
|
|
8740
|
+
value: function writeInt16(value) {
|
|
8741
|
+
this.checkSize(2);
|
|
8742
|
+
this.view.setInt16(this.offset, toInt(value), this.isLittleEndian);
|
|
8743
|
+
return this.increment(2);
|
|
8744
|
+
}
|
|
8745
|
+
}, {
|
|
8746
|
+
key: "writeUint32",
|
|
8747
|
+
value: function writeUint32(value) {
|
|
8748
|
+
this.checkSize(4);
|
|
8749
|
+
this.view.setUint32(this.offset, toInt(value), this.isLittleEndian);
|
|
8750
|
+
return this.increment(4);
|
|
8751
|
+
}
|
|
8752
|
+
}, {
|
|
8753
|
+
key: "writeInt32",
|
|
8754
|
+
value: function writeInt32(value) {
|
|
8755
|
+
this.checkSize(4);
|
|
8756
|
+
this.view.setInt32(this.offset, toInt(value), this.isLittleEndian);
|
|
8757
|
+
return this.increment(4);
|
|
8758
|
+
}
|
|
8759
|
+
}, {
|
|
8760
|
+
key: "writeBigUint64",
|
|
8761
|
+
value: function writeBigUint64(value) {
|
|
8762
|
+
this.checkSize(8);
|
|
8763
|
+
this.view.setBigUint64(this.offset, value, this.isLittleEndian);
|
|
8764
|
+
return this.increment(8);
|
|
8765
|
+
}
|
|
8766
|
+
}, {
|
|
8767
|
+
key: "writeFloat",
|
|
8768
|
+
value: function writeFloat(value) {
|
|
8769
|
+
this.checkSize(4);
|
|
8770
|
+
this.view.setFloat32(this.offset, toFloat(value), this.isLittleEndian);
|
|
8771
|
+
return this.increment(4);
|
|
8772
|
+
}
|
|
8773
|
+
}, {
|
|
8774
|
+
key: "writeDouble",
|
|
8775
|
+
value: function writeDouble(value) {
|
|
8776
|
+
this.checkSize(8);
|
|
8777
|
+
this.view.setFloat64(this.offset, toFloat(value), this.isLittleEndian);
|
|
8778
|
+
return this.increment(8);
|
|
8779
|
+
}
|
|
8780
|
+
}, {
|
|
8781
|
+
key: "writeUTF8String",
|
|
8782
|
+
value: function writeUTF8String(value) {
|
|
8783
|
+
// an empty (null) value is empty text, as in writeAsciiString; a
|
|
8784
|
+
// number in a text VR is written as its text
|
|
8785
|
+
var encodedString = this.encoder.encode(String(value !== null && value !== void 0 ? value : ""));
|
|
8786
|
+
this.checkSize(encodedString.byteLength);
|
|
8787
|
+
this.view.writeBuffer(encodedString, this.offset);
|
|
8788
|
+
return this.increment(encodedString.byteLength);
|
|
8789
|
+
}
|
|
8790
|
+
}, {
|
|
8791
|
+
key: "writeAsciiString",
|
|
8792
|
+
value: function writeAsciiString(value) {
|
|
8793
|
+
value = value || "";
|
|
8794
|
+
var len = value.length;
|
|
8795
|
+
this.checkSize(len);
|
|
8796
|
+
var startOffset = this.offset;
|
|
8797
|
+
for (var i = 0; i < len; i++) {
|
|
8798
|
+
var charCode = value.charCodeAt(i);
|
|
8799
|
+
this.view.setUint8(startOffset + i, charCode);
|
|
8800
|
+
}
|
|
8801
|
+
return this.increment(len);
|
|
8802
|
+
}
|
|
8803
|
+
|
|
8804
|
+
/**
|
|
8805
|
+
* Appends raw, already-encoded bytes (e.g. a deflated body) at the
|
|
8806
|
+
* current write position and returns the number of bytes written.
|
|
8807
|
+
*/
|
|
8808
|
+
}, {
|
|
8809
|
+
key: "writeRawBytes",
|
|
8810
|
+
value: function writeRawBytes(bytes) {
|
|
8811
|
+
var length = bytes.byteLength;
|
|
8812
|
+
if (length === 0) {
|
|
8813
|
+
return 0;
|
|
8814
|
+
}
|
|
8815
|
+
this.checkSize(length);
|
|
8816
|
+
this.view.writeBuffer(bytes, this.offset);
|
|
8817
|
+
return this.increment(length);
|
|
8818
|
+
}
|
|
8819
|
+
}, {
|
|
8820
|
+
key: "readBigUint64",
|
|
8821
|
+
value: function readBigUint64() {
|
|
8822
|
+
var val = this.view.getBigUint64(this.offset, this.isLittleEndian);
|
|
8823
|
+
this.increment(8);
|
|
8824
|
+
return val;
|
|
8825
|
+
}
|
|
8826
|
+
}, {
|
|
8827
|
+
key: "readUint32",
|
|
8828
|
+
value: function readUint32() {
|
|
8829
|
+
var val = this.view.getUint32(this.offset, this.isLittleEndian);
|
|
8830
|
+
this.increment(4);
|
|
8831
|
+
return val;
|
|
8832
|
+
}
|
|
8833
|
+
}, {
|
|
8834
|
+
key: "readUint16",
|
|
8835
|
+
value: function readUint16() {
|
|
8836
|
+
var val = this.view.getUint16(this.offset, this.isLittleEndian);
|
|
8837
|
+
this.increment(2);
|
|
8838
|
+
return val;
|
|
8839
|
+
}
|
|
8840
|
+
}, {
|
|
8841
|
+
key: "readUint8",
|
|
8842
|
+
value: function readUint8() {
|
|
8843
|
+
var val = this.view.getUint8(this.offset);
|
|
8844
|
+
this.increment(1);
|
|
8845
|
+
return val;
|
|
8846
|
+
}
|
|
8847
|
+
}, {
|
|
8848
|
+
key: "peekUint8",
|
|
8849
|
+
value: function peekUint8(offset) {
|
|
8850
|
+
return this.view.getUint8(this.offset + offset);
|
|
8851
|
+
}
|
|
8852
|
+
}, {
|
|
8853
|
+
key: "readUint8Array",
|
|
8854
|
+
value: function readUint8Array(length) {
|
|
8855
|
+
if (this.offset + length > this.endOffset) {
|
|
8856
|
+
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, ")"));
|
|
8857
|
+
}
|
|
8858
|
+
var arr = new Uint8Array(this.view.slice(this.offset, this.offset + length));
|
|
8859
|
+
this.increment(length);
|
|
8860
|
+
return arr;
|
|
8861
|
+
}
|
|
8862
|
+
}, {
|
|
8863
|
+
key: "readArrayBuffer",
|
|
8864
|
+
value: function readArrayBuffer(length) {
|
|
8865
|
+
return this.readUint8Array(length).buffer;
|
|
8866
|
+
}
|
|
8867
|
+
}, {
|
|
8868
|
+
key: "readUint16Array",
|
|
8869
|
+
value: function readUint16Array(length) {
|
|
8870
|
+
var sixlen = length / 2,
|
|
8871
|
+
arr = new Uint16Array(sixlen),
|
|
8872
|
+
i = 0;
|
|
8873
|
+
while (i++ < sixlen) {
|
|
8874
|
+
arr[i] = this.view.getUint16(this.offset, this.isLittleEndian);
|
|
8875
|
+
this.offset += 2;
|
|
8876
|
+
}
|
|
8877
|
+
return arr;
|
|
8878
|
+
}
|
|
8879
|
+
}, {
|
|
8880
|
+
key: "readInt8",
|
|
8881
|
+
value: function readInt8() {
|
|
8882
|
+
var val = this.view.getInt8(this.offset, this.isLittleEndian);
|
|
8883
|
+
this.increment(1);
|
|
8884
|
+
return val;
|
|
8885
|
+
}
|
|
8886
|
+
}, {
|
|
8887
|
+
key: "readInt16",
|
|
8888
|
+
value: function readInt16() {
|
|
8889
|
+
var val = this.view.getInt16(this.offset, this.isLittleEndian);
|
|
8890
|
+
this.increment(2);
|
|
8891
|
+
return val;
|
|
8892
|
+
}
|
|
8893
|
+
}, {
|
|
8894
|
+
key: "readInt32",
|
|
8895
|
+
value: function readInt32() {
|
|
8896
|
+
var val = this.view.getInt32(this.offset, this.isLittleEndian);
|
|
8897
|
+
this.increment(4);
|
|
8898
|
+
return val;
|
|
8899
|
+
}
|
|
8900
|
+
}, {
|
|
8901
|
+
key: "readFloat",
|
|
8902
|
+
value: function readFloat() {
|
|
8903
|
+
var val = this.view.getFloat32(this.offset, this.isLittleEndian);
|
|
8904
|
+
this.increment(4);
|
|
8905
|
+
return val;
|
|
8906
|
+
}
|
|
8907
|
+
}, {
|
|
8908
|
+
key: "readDouble",
|
|
8909
|
+
value: function readDouble() {
|
|
8910
|
+
var val = this.view.getFloat64(this.offset, this.isLittleEndian);
|
|
8911
|
+
this.increment(8);
|
|
8912
|
+
return val;
|
|
8913
|
+
}
|
|
8914
|
+
}, {
|
|
8915
|
+
key: "readAsciiString",
|
|
8916
|
+
value: function readAsciiString(length) {
|
|
8917
|
+
var result = "";
|
|
8918
|
+
var start = this.offset;
|
|
8919
|
+
var end = this.offset + length;
|
|
8920
|
+
if (end >= this.view.byteLength) {
|
|
8921
|
+
end = this.view.byteLength;
|
|
8922
|
+
}
|
|
8923
|
+
for (var i = start; i < end; ++i) {
|
|
8924
|
+
result += String.fromCharCode(this.view.getUint8(i));
|
|
8925
|
+
}
|
|
8926
|
+
this.increment(end - start);
|
|
8927
|
+
return result;
|
|
8928
|
+
}
|
|
8929
|
+
}, {
|
|
8930
|
+
key: "readVR",
|
|
8931
|
+
value: function readVR() {
|
|
8932
|
+
var vr = String.fromCharCode(this.view.getUint8(this.offset)) + String.fromCharCode(this.view.getUint8(this.offset + 1));
|
|
8933
|
+
this.increment(2);
|
|
8934
|
+
return vr;
|
|
8935
|
+
}
|
|
8936
|
+
}, {
|
|
8937
|
+
key: "readEncodedString",
|
|
8938
|
+
value: function readEncodedString(length) {
|
|
8939
|
+
if (this.offset + length >= this.view.byteLength) {
|
|
8940
|
+
length = this.view.byteLength - this.offset;
|
|
8941
|
+
}
|
|
8942
|
+
var view = new DataView(this.slice(this.offset, this.offset + length));
|
|
8943
|
+
var result = this.decoder.decode(view);
|
|
8944
|
+
this.increment(length);
|
|
8945
|
+
return result;
|
|
8946
|
+
}
|
|
8947
|
+
}, {
|
|
8948
|
+
key: "readHex",
|
|
8949
|
+
value: function readHex(length) {
|
|
8950
|
+
var hexString = "";
|
|
8951
|
+
for (var i = 0; i < length; i++) {
|
|
8952
|
+
hexString += this.readUint8().toString(16);
|
|
8953
|
+
}
|
|
8954
|
+
return hexString;
|
|
8955
|
+
}
|
|
8956
|
+
}, {
|
|
8957
|
+
key: "checkSize",
|
|
8958
|
+
value: function checkSize(step) {
|
|
8959
|
+
this.view.checkSize(this.offset + step);
|
|
8960
|
+
}
|
|
8961
|
+
|
|
8962
|
+
/**
|
|
8963
|
+
* Concatenates the stream, starting from the startOffset (to allow concat
|
|
8964
|
+
* on an existing output from the beginning)
|
|
8965
|
+
*/
|
|
8966
|
+
}, {
|
|
8967
|
+
key: "concat",
|
|
8968
|
+
value: function concat(stream) {
|
|
8969
|
+
var length = stream.size - stream.startOffset;
|
|
8970
|
+
this.view.checkSize(this.size + length);
|
|
8971
|
+
this.view.writeBuffer(new Uint8Array(stream.slice(stream.startOffset, stream.size)), this.offset);
|
|
8972
|
+
this.offset += length;
|
|
8973
|
+
this.size = this.offset;
|
|
8974
|
+
this.endOffset = this.size;
|
|
8975
|
+
return this.view.availableSize;
|
|
8976
|
+
}
|
|
8977
|
+
}, {
|
|
8978
|
+
key: "increment",
|
|
8979
|
+
value: function increment(step) {
|
|
8980
|
+
this.offset += step;
|
|
8981
|
+
if (this.offset > this.size) {
|
|
8982
|
+
this.size = this.offset;
|
|
8983
|
+
}
|
|
8984
|
+
return step;
|
|
8985
|
+
}
|
|
8986
|
+
|
|
8987
|
+
/**
|
|
8988
|
+
* Reads from an async stream delivering to addBuffer. Each chunk is
|
|
8989
|
+
* copied, also a plain ArrayBuffer, so the producer may reuse it.
|
|
8990
|
+
*/
|
|
8991
|
+
}, {
|
|
8992
|
+
key: "fromAsyncStream",
|
|
8993
|
+
value: (function () {
|
|
8994
|
+
var _fromAsyncStream = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(stream) {
|
|
8995
|
+
var _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, chunk, _t;
|
|
8996
|
+
return _regeneratorRuntime().wrap(function (_context) {
|
|
8997
|
+
while (1) switch (_context.prev = _context.next) {
|
|
8998
|
+
case 0:
|
|
8999
|
+
_iteratorAbruptCompletion = false;
|
|
9000
|
+
_didIteratorError = false;
|
|
9001
|
+
_context.prev = 1;
|
|
9002
|
+
_iterator = _asyncIterator(stream);
|
|
9003
|
+
case 2:
|
|
9004
|
+
_context.next = 3;
|
|
9005
|
+
return _iterator.next();
|
|
9006
|
+
case 3:
|
|
9007
|
+
if (!(_iteratorAbruptCompletion = !(_step = _context.sent).done)) {
|
|
9008
|
+
_context.next = 5;
|
|
9009
|
+
break;
|
|
9010
|
+
}
|
|
9011
|
+
chunk = _step.value;
|
|
9012
|
+
this.addBuffer(chunk, {
|
|
9013
|
+
transfer: false
|
|
9014
|
+
});
|
|
9015
|
+
case 4:
|
|
9016
|
+
_iteratorAbruptCompletion = false;
|
|
9017
|
+
_context.next = 2;
|
|
9018
|
+
break;
|
|
9019
|
+
case 5:
|
|
9020
|
+
_context.next = 7;
|
|
9021
|
+
break;
|
|
9022
|
+
case 6:
|
|
9023
|
+
_context.prev = 6;
|
|
9024
|
+
_t = _context["catch"](1);
|
|
9025
|
+
_didIteratorError = true;
|
|
9026
|
+
_iteratorError = _t;
|
|
9027
|
+
case 7:
|
|
9028
|
+
_context.prev = 7;
|
|
9029
|
+
_context.prev = 8;
|
|
9030
|
+
if (!(_iteratorAbruptCompletion && _iterator.return != null)) {
|
|
9031
|
+
_context.next = 9;
|
|
9032
|
+
break;
|
|
9033
|
+
}
|
|
9034
|
+
_context.next = 9;
|
|
9035
|
+
return _iterator.return();
|
|
9036
|
+
case 9:
|
|
9037
|
+
_context.prev = 9;
|
|
9038
|
+
if (!_didIteratorError) {
|
|
9039
|
+
_context.next = 10;
|
|
9040
|
+
break;
|
|
9041
|
+
}
|
|
9042
|
+
throw _iteratorError;
|
|
9043
|
+
case 10:
|
|
9044
|
+
return _context.finish(9);
|
|
9045
|
+
case 11:
|
|
9046
|
+
return _context.finish(7);
|
|
9047
|
+
case 12:
|
|
9048
|
+
this.setComplete();
|
|
9049
|
+
case 13:
|
|
9050
|
+
case "end":
|
|
9051
|
+
return _context.stop();
|
|
9052
|
+
}
|
|
9053
|
+
}, _callee, this, [[1, 6, 7, 12], [8,, 9, 11]]);
|
|
9054
|
+
}));
|
|
9055
|
+
function fromAsyncStream(_x) {
|
|
9056
|
+
return _fromAsyncStream.apply(this, arguments);
|
|
9057
|
+
}
|
|
9058
|
+
return fromAsyncStream;
|
|
9059
|
+
}()
|
|
9060
|
+
/**
|
|
9061
|
+
* Adds the buffer to the end of the current buffers list,
|
|
9062
|
+
* updating the size etc.
|
|
9063
|
+
*
|
|
9064
|
+
* A typed array or DataView (for example a Node.js Buffer) adds only
|
|
9065
|
+
* the bytes of the view, and not the full underlying ArrayBuffer.
|
|
9066
|
+
*
|
|
9067
|
+
* @param {*} buffer an ArrayBuffer, or a typed array or DataView
|
|
9068
|
+
* @param {*} options.start byte offset for the start of the new buffer
|
|
9069
|
+
* to use, relative to the start of the view, clamped to the view
|
|
9070
|
+
* @param {*} options.end byte offset for the end of the buffer to use,
|
|
9071
|
+
* relative to the start of the view, clamped to the view
|
|
9072
|
+
* @param {*} options.transfer keeps a reference to the ArrayBuffer
|
|
9073
|
+
* instead of a copy, and the caller must not change the buffer
|
|
9074
|
+
* afterwards. It does not detach the buffer. It applies only when
|
|
9075
|
+
* the range covers the whole ArrayBuffer, so a partial view or range
|
|
9076
|
+
* is always copied. The default is true for an ArrayBuffer, and
|
|
9077
|
+
* false for a view. Set it to false to force a copy.
|
|
9078
|
+
*/
|
|
9079
|
+
)
|
|
9080
|
+
}, {
|
|
9081
|
+
key: "addBuffer",
|
|
9082
|
+
value: function addBuffer(buffer) {
|
|
9083
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
9084
|
+
if (!buffer) {
|
|
9085
|
+
// Silently ignore null buffers.
|
|
9086
|
+
return;
|
|
9087
|
+
}
|
|
9088
|
+
this.view.addBuffer(buffer, options);
|
|
9089
|
+
this.size = this.view.size;
|
|
9090
|
+
this.endOffset = this.size;
|
|
9091
|
+
this.notifyAvailableListeners();
|
|
9092
|
+
return this.size;
|
|
9093
|
+
}
|
|
9094
|
+
}, {
|
|
9095
|
+
key: "notifyAvailableListeners",
|
|
9096
|
+
value: function notifyAvailableListeners() {
|
|
9097
|
+
var existingListeners = _toConsumableArray(this.availableListeners);
|
|
9098
|
+
this.availableListeners.splice(0, this.availableListeners.length);
|
|
9099
|
+
existingListeners.forEach(function (listener) {
|
|
9100
|
+
return listener();
|
|
9101
|
+
});
|
|
9102
|
+
}
|
|
9103
|
+
|
|
9104
|
+
/**
|
|
9105
|
+
* Consumes the data up to the given offset.
|
|
9106
|
+
* This will clear the references to the data buffers, and will
|
|
9107
|
+
* cause resets etc to fail.
|
|
9108
|
+
* The default offset is the current position, so everything already read.
|
|
9109
|
+
*/
|
|
9110
|
+
}, {
|
|
9111
|
+
key: "consume",
|
|
9112
|
+
value: function consume() {
|
|
9113
|
+
var offset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.offset;
|
|
9114
|
+
if (!this.clearBuffers) {
|
|
9115
|
+
return;
|
|
9116
|
+
}
|
|
9117
|
+
this.view.consume(offset);
|
|
9118
|
+
this.notifyRelayListeners();
|
|
9119
|
+
}
|
|
9500
9120
|
|
|
9501
|
-
|
|
9502
|
-
|
|
9503
|
-
|
|
9504
|
-
|
|
9505
|
-
|
|
9121
|
+
/**
|
|
9122
|
+
* Returns true if the stream has data in the given range.
|
|
9123
|
+
*/
|
|
9124
|
+
}, {
|
|
9125
|
+
key: "hasData",
|
|
9126
|
+
value: function hasData(start) {
|
|
9127
|
+
var end = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : start + 1;
|
|
9128
|
+
return this.view.hasData(start, end);
|
|
9129
|
+
}
|
|
9130
|
+
}, {
|
|
9131
|
+
key: "more",
|
|
9132
|
+
value: function more(length) {
|
|
9133
|
+
if (this.offset + length > this.endOffset) {
|
|
9134
|
+
throw new Error("Request more than currently allocated buffer");
|
|
9135
|
+
}
|
|
9506
9136
|
|
|
9507
|
-
|
|
9508
|
-
|
|
9509
|
-
|
|
9137
|
+
// Optimize the more implementation to choose between a slice and
|
|
9138
|
+
// a sub-string reference to the original set of views.
|
|
9139
|
+
// const newBuf = new ReadBufferStream(this.buffer, {
|
|
9140
|
+
// start: this.offset,
|
|
9141
|
+
// stop: this.offset + length
|
|
9142
|
+
// });
|
|
9143
|
+
var newBuf = new ReadBufferStream(this.slice(this.offset, this.offset + length));
|
|
9144
|
+
this.increment(length);
|
|
9145
|
+
newBuf.setComplete();
|
|
9146
|
+
return newBuf;
|
|
9147
|
+
}
|
|
9148
|
+
}, {
|
|
9149
|
+
key: "reset",
|
|
9150
|
+
value: function reset() {
|
|
9151
|
+
this.offset = 0;
|
|
9152
|
+
return this;
|
|
9153
|
+
}
|
|
9154
|
+
}, {
|
|
9155
|
+
key: "end",
|
|
9156
|
+
value: function end() {
|
|
9157
|
+
return this.isComplete && this.offset >= this.end;
|
|
9158
|
+
}
|
|
9159
|
+
}, {
|
|
9160
|
+
key: "toEnd",
|
|
9161
|
+
value: function toEnd() {
|
|
9162
|
+
this.offset = this.view.byteLength;
|
|
9163
|
+
}
|
|
9510
9164
|
|
|
9511
|
-
|
|
9512
|
-
|
|
9513
|
-
|
|
9514
|
-
|
|
9515
|
-
|
|
9516
|
-
|
|
9165
|
+
/**
|
|
9166
|
+
* Reports on the amount of memory held by the buffers in the view.
|
|
9167
|
+
* @returns {Object} An object containing:
|
|
9168
|
+
* - bufferCount: Number of buffers still held (not null)
|
|
9169
|
+
* - totalSize: Total logical span of all buffers in bytes (each
|
|
9170
|
+
* buffer counts its own view span, not its backing ArrayBuffer)
|
|
9171
|
+
* - consumeOffset: The current consume offset
|
|
9172
|
+
* - buffersBeforeOffset: Number of buffers before the consume offset
|
|
9173
|
+
*/
|
|
9174
|
+
}, {
|
|
9175
|
+
key: "getBufferMemoryInfo",
|
|
9176
|
+
value: function getBufferMemoryInfo() {
|
|
9177
|
+
return this.view.getBufferMemoryInfo(this.offset);
|
|
9178
|
+
}
|
|
9179
|
+
}]);
|
|
9180
|
+
}();
|
|
9517
9181
|
|
|
9518
|
-
|
|
9519
|
-
|
|
9520
|
-
|
|
9521
|
-
|
|
9522
|
-
|
|
9182
|
+
/**
|
|
9183
|
+
* A read stream over an ArrayBuffer, a typed array or Node Buffer, or a
|
|
9184
|
+
* range of another BufferStream.
|
|
9185
|
+
*
|
|
9186
|
+
* A typed array or Node Buffer is a view into a backing ArrayBuffer that
|
|
9187
|
+
* Node often pools and shares. The stream adopts exactly the viewed byte
|
|
9188
|
+
* range, at logical offset 0. If the stream adopted buffer.buffer whole, it
|
|
9189
|
+
* would alias the other data in the pool. The Node-only Buffer.offset
|
|
9190
|
+
* property (its byteOffset) does not set the read offset.
|
|
9191
|
+
*
|
|
9192
|
+
* The 0.x form `(buffer, littleEndian, options)` still works, as in 0.x,
|
|
9193
|
+
* with a one-time warning.
|
|
9194
|
+
*/
|
|
9195
|
+
var ReadBufferStream = /*#__PURE__*/function (_BufferStream2) {
|
|
9196
|
+
/**
|
|
9197
|
+
* @param {ArrayBuffer|ArrayBufferView|BufferStream|null} buffer
|
|
9198
|
+
* @param {{littleEndian?: boolean, start?: number, stop?: number, noCopy?: boolean, clearBuffers?: boolean}} [options]
|
|
9199
|
+
*/
|
|
9200
|
+
function ReadBufferStream(buffer, options, legacyOptions) {
|
|
9201
|
+
var _this3;
|
|
9202
|
+
_classCallCheck(this, ReadBufferStream);
|
|
9203
|
+
// any explicit non-object 2nd argument is the 0.x byte order
|
|
9204
|
+
if (arguments.length >= 2 && (options === null || _typeof(options) !== "object")) {
|
|
9205
|
+
warnLegacyConstructor("ReadBufferStream", "new ReadBufferStream(buffer, { littleEndian, start, stop, noCopy, clearBuffers })");
|
|
9206
|
+
options = _objectSpread2(_objectSpread2({}, legacyOptions), {}, {
|
|
9207
|
+
littleEndian: !!options
|
|
9208
|
+
});
|
|
9209
|
+
}
|
|
9210
|
+
options = options !== null && options !== void 0 ? options : {};
|
|
9211
|
+
var _options = options,
|
|
9212
|
+
_options$littleEndian2 = _options.littleEndian,
|
|
9213
|
+
littleEndian = _options$littleEndian2 === void 0 ? true : _options$littleEndian2,
|
|
9214
|
+
start = _options.start,
|
|
9215
|
+
stop = _options.stop,
|
|
9216
|
+
_options$noCopy = _options.noCopy,
|
|
9217
|
+
noCopy = _options$noCopy === void 0 ? false : _options$noCopy,
|
|
9218
|
+
_options$clearBuffers = _options.clearBuffers,
|
|
9219
|
+
clearBuffers = _options$clearBuffers === void 0 ? false : _options$clearBuffers,
|
|
9220
|
+
rest = _objectWithoutProperties(_options, _excluded);
|
|
9221
|
+
_this3 = _callSuper(this, ReadBufferStream, [_objectSpread2(_objectSpread2({}, rest), {}, {
|
|
9222
|
+
littleEndian: littleEndian,
|
|
9223
|
+
clearBuffers: clearBuffers
|
|
9224
|
+
})]);
|
|
9225
|
+
_this3.noCopy = noCopy;
|
|
9226
|
+
_this3.decoder = new TextDecoder("latin1");
|
|
9227
|
+
if (buffer instanceof BufferStream) {
|
|
9228
|
+
_this3.view.from(buffer.view, options);
|
|
9229
|
+
_this3.isComplete = true;
|
|
9230
|
+
} else if (buffer) {
|
|
9231
|
+
// a view adds only its viewed byte range (SplitDataView.addBuffer)
|
|
9232
|
+
_this3.view.addBuffer(buffer);
|
|
9233
|
+
_this3.isComplete = true;
|
|
9234
|
+
}
|
|
9235
|
+
// a source BufferStream's offset is the sub-stream start; a Node
|
|
9236
|
+
// Buffer's own `offset` property is ignored (see class doc comment)
|
|
9237
|
+
_this3.offset = start !== null && start !== void 0 ? start : buffer instanceof BufferStream ? buffer.offset : 0;
|
|
9238
|
+
_this3.size = stop || (buffer === null || buffer === void 0 ? void 0 : buffer.size) || (buffer === null || buffer === void 0 ? void 0 : buffer.byteLength) || 0;
|
|
9239
|
+
_this3.startOffset = _this3.offset;
|
|
9240
|
+
_this3.endOffset = _this3.size;
|
|
9241
|
+
return _this3;
|
|
9242
|
+
}
|
|
9243
|
+
_inherits(ReadBufferStream, _BufferStream2);
|
|
9244
|
+
return _createClass(ReadBufferStream, [{
|
|
9245
|
+
key: "setDecoder",
|
|
9246
|
+
value: function setDecoder(decoder) {
|
|
9247
|
+
this.decoder = decoder;
|
|
9248
|
+
}
|
|
9249
|
+
}, {
|
|
9250
|
+
key: "reset",
|
|
9251
|
+
value: function reset() {
|
|
9252
|
+
this.offset = this.startOffset;
|
|
9253
|
+
return this;
|
|
9254
|
+
}
|
|
9255
|
+
}, {
|
|
9256
|
+
key: "end",
|
|
9257
|
+
value: function end() {
|
|
9258
|
+
return this.isComplete && this.offset >= this.endOffset;
|
|
9259
|
+
}
|
|
9260
|
+
}, {
|
|
9261
|
+
key: "toEnd",
|
|
9262
|
+
value: function toEnd() {
|
|
9263
|
+
this.offset = this.endOffset;
|
|
9264
|
+
}
|
|
9265
|
+
}, {
|
|
9266
|
+
key: "writeUint8",
|
|
9267
|
+
value: function writeUint8(value) {
|
|
9268
|
+
throw new Error(value, "writeUint8 not implemented");
|
|
9269
|
+
}
|
|
9270
|
+
}, {
|
|
9271
|
+
key: "writeUint8Repeat",
|
|
9272
|
+
value: function writeUint8Repeat(value, count) {
|
|
9273
|
+
throw new Error("writeUint8Repeat not implemented (value: ".concat(value, ", count: ").concat(count, ")"));
|
|
9274
|
+
}
|
|
9275
|
+
}, {
|
|
9276
|
+
key: "writeInt8",
|
|
9277
|
+
value: function writeInt8(value) {
|
|
9278
|
+
throw new Error(value, "writeInt8 not implemented");
|
|
9279
|
+
}
|
|
9280
|
+
}, {
|
|
9281
|
+
key: "writeUint16",
|
|
9282
|
+
value: function writeUint16(value) {
|
|
9283
|
+
throw new Error(value, "writeUint16 not implemented");
|
|
9284
|
+
}
|
|
9285
|
+
}, {
|
|
9286
|
+
key: "writeTwoUint16s",
|
|
9287
|
+
value: function writeTwoUint16s(value) {
|
|
9288
|
+
throw new Error(value, "writeTwoUint16s not implemented");
|
|
9289
|
+
}
|
|
9290
|
+
}, {
|
|
9291
|
+
key: "writeInt16",
|
|
9292
|
+
value: function writeInt16(value) {
|
|
9293
|
+
throw new Error(value, "writeInt16 not implemented");
|
|
9294
|
+
}
|
|
9295
|
+
}, {
|
|
9296
|
+
key: "writeUint32",
|
|
9297
|
+
value: function writeUint32(value) {
|
|
9298
|
+
throw new Error(value, "writeUint32 not implemented");
|
|
9299
|
+
}
|
|
9300
|
+
}, {
|
|
9301
|
+
key: "writeInt32",
|
|
9302
|
+
value: function writeInt32(value) {
|
|
9303
|
+
throw new Error(value, "writeInt32 not implemented");
|
|
9304
|
+
}
|
|
9305
|
+
}, {
|
|
9306
|
+
key: "writeFloat",
|
|
9307
|
+
value: function writeFloat(value) {
|
|
9308
|
+
throw new Error(value, "writeFloat not implemented");
|
|
9309
|
+
}
|
|
9310
|
+
}, {
|
|
9311
|
+
key: "writeDouble",
|
|
9312
|
+
value: function writeDouble(value) {
|
|
9313
|
+
throw new Error(value, "writeDouble not implemented");
|
|
9314
|
+
}
|
|
9315
|
+
}, {
|
|
9316
|
+
key: "writeAsciiString",
|
|
9317
|
+
value: function writeAsciiString(value) {
|
|
9318
|
+
throw new Error(value, "writeAsciiString not implemented");
|
|
9319
|
+
}
|
|
9320
|
+
}, {
|
|
9321
|
+
key: "writeUTF8String",
|
|
9322
|
+
value: function writeUTF8String(value) {
|
|
9323
|
+
throw new Error(value, "writeUTF8String not implemented");
|
|
9324
|
+
}
|
|
9325
|
+
}, {
|
|
9326
|
+
key: "writeRawBytes",
|
|
9327
|
+
value: function writeRawBytes(bytes) {
|
|
9328
|
+
throw new Error(bytes, "writeRawBytes not implemented");
|
|
9329
|
+
}
|
|
9330
|
+
}, {
|
|
9331
|
+
key: "checkSize",
|
|
9332
|
+
value: function checkSize(step) {
|
|
9333
|
+
throw new Error(step, "checkSize not implemented");
|
|
9334
|
+
}
|
|
9335
|
+
}, {
|
|
9336
|
+
key: "concat",
|
|
9337
|
+
value: function concat(stream) {
|
|
9338
|
+
throw new Error(stream, "concat not implemented");
|
|
9339
|
+
}
|
|
9340
|
+
}]);
|
|
9341
|
+
}(BufferStream);
|
|
9342
|
+
var DeflatedReadBufferStream = /*#__PURE__*/function (_ReadBufferStream) {
|
|
9343
|
+
function DeflatedReadBufferStream(stream, options) {
|
|
9344
|
+
_classCallCheck(this, DeflatedReadBufferStream);
|
|
9345
|
+
var inflatedBuffer = pako.inflateRaw(stream.getBuffer(stream.offset, stream.size));
|
|
9346
|
+
return _callSuper(this, DeflatedReadBufferStream, [inflatedBuffer.buffer, options !== null && options !== void 0 ? options : {}]);
|
|
9347
|
+
}
|
|
9348
|
+
_inherits(DeflatedReadBufferStream, _ReadBufferStream);
|
|
9349
|
+
return _createClass(DeflatedReadBufferStream);
|
|
9350
|
+
}(ReadBufferStream);
|
|
9523
9351
|
|
|
9524
|
-
|
|
9525
|
-
|
|
9526
|
-
|
|
9352
|
+
/**
|
|
9353
|
+
* A growable write stream. The 0.x form `(defaultSize, littleEndian)` still
|
|
9354
|
+
* works, as in 0.x, with a one-time warning.
|
|
9355
|
+
*/
|
|
9356
|
+
var WriteBufferStream = /*#__PURE__*/function (_BufferStream3) {
|
|
9357
|
+
/** @param {{defaultSize?: number, littleEndian?: boolean}} [options] */
|
|
9358
|
+
function WriteBufferStream(options, legacyLittleEndian) {
|
|
9359
|
+
var _this4;
|
|
9360
|
+
_classCallCheck(this, WriteBufferStream);
|
|
9361
|
+
// any explicit non-object argument is the 0.x size hint
|
|
9362
|
+
if (arguments.length >= 1 && (options === null || _typeof(options) !== "object")) {
|
|
9363
|
+
warnLegacyConstructor("WriteBufferStream", "new WriteBufferStream({ defaultSize, littleEndian })");
|
|
9364
|
+
options = {
|
|
9365
|
+
defaultSize: options !== null && options !== void 0 ? options : undefined,
|
|
9366
|
+
littleEndian: !!legacyLittleEndian
|
|
9367
|
+
};
|
|
9368
|
+
}
|
|
9369
|
+
var _ref = options !== null && options !== void 0 ? options : {},
|
|
9370
|
+
defaultSize = _ref.defaultSize,
|
|
9371
|
+
_ref$littleEndian = _ref.littleEndian,
|
|
9372
|
+
littleEndian = _ref$littleEndian === void 0 ? true : _ref$littleEndian;
|
|
9373
|
+
_this4 = _callSuper(this, WriteBufferStream, [{
|
|
9374
|
+
defaultSize: defaultSize,
|
|
9375
|
+
littleEndian: littleEndian
|
|
9376
|
+
}]);
|
|
9377
|
+
_this4.size = 0;
|
|
9378
|
+
return _this4;
|
|
9379
|
+
}
|
|
9380
|
+
_inherits(WriteBufferStream, _BufferStream3);
|
|
9381
|
+
return _createClass(WriteBufferStream);
|
|
9382
|
+
}(BufferStream);
|
|
9527
9383
|
|
|
9528
|
-
|
|
9529
|
-
|
|
9530
|
-
|
|
9384
|
+
/**
|
|
9385
|
+
* The classification of each VR, stored once. ValueRepresentation copies
|
|
9386
|
+
* the flags to each instance; singleVRs and BINARY_VRS are computed here.
|
|
9387
|
+
* OL/OV have flags but no VR class in 1.0.
|
|
9388
|
+
* @typedef {Object} VrFlags
|
|
9389
|
+
* @property {boolean} [binary] binary number or tag: isBinary()
|
|
9390
|
+
* @property {boolean} [length32] 32-bit explicit VR length: isLength32()
|
|
9391
|
+
* @property {boolean} [single] never joined on write: !allowMultiple()
|
|
9392
|
+
* @property {boolean} [readSingle] never split on read: singleVRs
|
|
9393
|
+
* @property {boolean} [byteStream] frames/fragments, not a VM: BINARY_VRS
|
|
9394
|
+
*/
|
|
9395
|
+
var SEED = {
|
|
9396
|
+
AT: "binary",
|
|
9397
|
+
FD: "binary",
|
|
9398
|
+
FL: "binary",
|
|
9399
|
+
LT: "readSingle",
|
|
9400
|
+
OB: "length32 single readSingle byteStream",
|
|
9401
|
+
OD: "length32 byteStream",
|
|
9402
|
+
OF: "length32 single readSingle byteStream",
|
|
9403
|
+
OL: "byteStream",
|
|
9404
|
+
OV: "byteStream",
|
|
9405
|
+
OW: "length32 single readSingle byteStream",
|
|
9406
|
+
SL: "binary",
|
|
9407
|
+
SQ: "length32 single readSingle",
|
|
9408
|
+
SS: "binary",
|
|
9409
|
+
UC: "length32",
|
|
9410
|
+
UL: "binary",
|
|
9411
|
+
UN: "length32 single readSingle byteStream",
|
|
9412
|
+
UR: "length32",
|
|
9413
|
+
US: "binary",
|
|
9414
|
+
UT: "length32",
|
|
9415
|
+
UV: "binary length32"
|
|
9416
|
+
};
|
|
9531
9417
|
|
|
9532
|
-
|
|
9533
|
-
|
|
9534
|
-
|
|
9535
|
-
|
|
9536
|
-
|
|
9418
|
+
/** @type {Object<string, VrFlags>} */
|
|
9419
|
+
var vrFlags = Object.fromEntries(Object.entries(SEED).map(function (_ref) {
|
|
9420
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
9421
|
+
code = _ref2[0],
|
|
9422
|
+
names = _ref2[1];
|
|
9423
|
+
return [code, Object.fromEntries(names.split(" ").map(function (name) {
|
|
9424
|
+
return [name, true];
|
|
9425
|
+
}))];
|
|
9426
|
+
}));
|
|
9427
|
+
function codesWith(flag) {
|
|
9428
|
+
return Object.keys(vrFlags).filter(function (code) {
|
|
9429
|
+
return vrFlags[code][flag];
|
|
9430
|
+
});
|
|
9431
|
+
}
|
|
9537
9432
|
|
|
9538
|
-
|
|
9539
|
-
|
|
9540
|
-
_loggersByName[childName].rebuild();
|
|
9541
|
-
}
|
|
9542
|
-
}
|
|
9543
|
-
};
|
|
9433
|
+
/** VRs whose read value is never VM-split on backslashes. */
|
|
9434
|
+
var singleVRs = codesWith("readSingle");
|
|
9544
9435
|
|
|
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
|
-
}
|
|
9436
|
+
/** Byte-stream VRs: a naturalized value stays a list of frames/fragments. */
|
|
9437
|
+
var BINARY_VRS = new Set(codesWith("byteStream"));
|
|
9555
9438
|
|
|
9556
|
-
|
|
9557
|
-
|
|
9558
|
-
|
|
9559
|
-
|
|
9560
|
-
|
|
9439
|
+
// TransferSyntaxUIDs
|
|
9440
|
+
var IMPLICIT_LITTLE_ENDIAN = "1.2.840.10008.1.2";
|
|
9441
|
+
var EXPLICIT_LITTLE_ENDIAN = "1.2.840.10008.1.2.1";
|
|
9442
|
+
var DEFLATED_EXPLICIT_LITTLE_ENDIAN = "1.2.840.10008.1.2.1.99";
|
|
9443
|
+
var EXPLICIT_BIG_ENDIAN = "1.2.840.10008.1.2.2";
|
|
9561
9444
|
|
|
9562
|
-
|
|
9445
|
+
/**
|
|
9446
|
+
* The raw hex value is the maximum 32 bit unsigned integer,
|
|
9447
|
+
* but this is a potential length value, so suggest using the
|
|
9448
|
+
* canonical UNDEFINED_LENGTH_FIX value of -1 instead
|
|
9449
|
+
*/
|
|
9450
|
+
var UNDEFINED_LENGTH = 0xffffffff;
|
|
9451
|
+
/**
|
|
9452
|
+
* Use a -1 value for the undefined length being fixed as this is consistent
|
|
9453
|
+
* with other usage and can't be confused with a real length.
|
|
9454
|
+
*/
|
|
9455
|
+
var UNDEFINED_LENGTH_FIX = -1;
|
|
9456
|
+
var ITEM_DELIMITATION_LENGTH = 0x00000000;
|
|
9563
9457
|
|
|
9564
|
-
|
|
9565
|
-
|
|
9566
|
-
throw new TypeError("You must supply a name when creating a logger.");
|
|
9567
|
-
}
|
|
9458
|
+
// Delimitation Value
|
|
9459
|
+
var SEQUENCE_DELIMITATION_VALUE = 0x00000000;
|
|
9568
9460
|
|
|
9569
|
-
|
|
9570
|
-
|
|
9571
|
-
|
|
9572
|
-
|
|
9573
|
-
defaultLogger.methodFactory
|
|
9574
|
-
);
|
|
9575
|
-
}
|
|
9576
|
-
return logger;
|
|
9577
|
-
};
|
|
9461
|
+
// Value multiplicity and padding
|
|
9462
|
+
var VM_DELIMITER = 0x5c;
|
|
9463
|
+
var PADDING_NULL = 0x00;
|
|
9464
|
+
var PADDING_SPACE = 0x20;
|
|
9578
9465
|
|
|
9579
|
-
|
|
9580
|
-
|
|
9581
|
-
|
|
9582
|
-
|
|
9583
|
-
window.log === defaultLogger) {
|
|
9584
|
-
window.log = _log;
|
|
9585
|
-
}
|
|
9466
|
+
// PersonName delimeters
|
|
9467
|
+
var PN_COMPONENT_DELIMITER = 0x3d;
|
|
9468
|
+
var SEQUENCE_ITEM_TAG = 0xfffee000;
|
|
9469
|
+
var SEQUENCE_DELIMITER_TAG = 0xfffee0dd;
|
|
9586
9470
|
|
|
9587
|
-
|
|
9588
|
-
|
|
9471
|
+
// Nearly all transfer syntaxes are encapsulated, so record those which are
|
|
9472
|
+
// unencapsulated as the exceptions.
|
|
9473
|
+
var unencapsulatedTransferSyntaxes = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, IMPLICIT_LITTLE_ENDIAN, true), EXPLICIT_BIG_ENDIAN, true), DEFLATED_EXPLICIT_LITTLE_ENDIAN, true), EXPLICIT_LITTLE_ENDIAN, true);
|
|
9589
9474
|
|
|
9590
|
-
|
|
9591
|
-
|
|
9592
|
-
|
|
9475
|
+
// Relocated from DicomMessage.isEncapsulated (which now delegates here) so
|
|
9476
|
+
// Tag.write resolves it over the table above instead of through the
|
|
9477
|
+
// late-binding DicomMessage slot.
|
|
9478
|
+
function isEncapsulatedSyntax(syntax) {
|
|
9479
|
+
return !unencapsulatedTransferSyntaxes[syntax];
|
|
9480
|
+
}
|
|
9593
9481
|
|
|
9594
|
-
|
|
9595
|
-
|
|
9482
|
+
/**
|
|
9483
|
+
* Video transfer syntax UIDs (MPEG2, H.264, H.265)
|
|
9484
|
+
* These transfer syntaxes treat the entire pixel data stream as a single frame
|
|
9485
|
+
* regardless of the number of fragments.
|
|
9486
|
+
*/
|
|
9487
|
+
var videoTransferSyntaxUIDs = new Set(["1.2.840.10008.1.2.4.100",
|
|
9488
|
+
// MPEG2 Main Profile @ Main Level
|
|
9489
|
+
"1.2.840.10008.1.2.4.100.1",
|
|
9490
|
+
// MPEG2 Main Profile @ Main Level (retired)
|
|
9491
|
+
"1.2.840.10008.1.2.4.101",
|
|
9492
|
+
// MPEG2 Main Profile @ High Level
|
|
9493
|
+
"1.2.840.10008.1.2.4.101.1",
|
|
9494
|
+
// MPEG2 Main Profile @ High Level (retired)
|
|
9495
|
+
"1.2.840.10008.1.2.4.102",
|
|
9496
|
+
// MPEG-4 AVC/H.264 High Profile / Level 4.1
|
|
9497
|
+
"1.2.840.10008.1.2.4.102.1",
|
|
9498
|
+
// MPEG-4 AVC/H.264 High Profile / Level 4.1 (retired)
|
|
9499
|
+
"1.2.840.10008.1.2.4.103",
|
|
9500
|
+
// MPEG-4 AVC/H.264 BD-compatible High Profile / Level 4.1
|
|
9501
|
+
"1.2.840.10008.1.2.4.103.1",
|
|
9502
|
+
// MPEG-4 AVC/H.264 BD-compatible High Profile / Level 4.1 (retired)
|
|
9503
|
+
"1.2.840.10008.1.2.4.104",
|
|
9504
|
+
// MPEG-4 AVC/H.264 High Profile / Level 4.2 For 2D Video
|
|
9505
|
+
"1.2.840.10008.1.2.4.104.1",
|
|
9506
|
+
// MPEG-4 AVC/H.264 High Profile / Level 4.2 For 2D Video (retired)
|
|
9507
|
+
"1.2.840.10008.1.2.4.105",
|
|
9508
|
+
// MPEG-4 AVC/H.264 High Profile / Level 4.2 For 3D Video
|
|
9509
|
+
"1.2.840.10008.1.2.4.105.1",
|
|
9510
|
+
// MPEG-4 AVC/H.264 High Profile / Level 4.2 For 3D Video (retired)
|
|
9511
|
+
"1.2.840.10008.1.2.4.106",
|
|
9512
|
+
// MPEG-4 AVC/H.264 Stereo High Profile / Level 4.2
|
|
9513
|
+
"1.2.840.10008.1.2.4.106.1",
|
|
9514
|
+
// MPEG-4 AVC/H.264 Stereo High Profile / Level 4.2 (retired)
|
|
9515
|
+
"1.2.840.10008.1.2.4.107",
|
|
9516
|
+
// HEVC/H.265 Main Profile / Level 5.1
|
|
9517
|
+
"1.2.840.10008.1.2.4.108" // HEVC/H.265 Main 10 Profile / Level 5.1
|
|
9518
|
+
]);
|
|
9596
9519
|
|
|
9597
|
-
|
|
9598
|
-
|
|
9599
|
-
|
|
9600
|
-
|
|
9520
|
+
/**
|
|
9521
|
+
* Checks if a transfer syntax UID is a video transfer syntax
|
|
9522
|
+
* @param {string} uid - Transfer syntax UID to check
|
|
9523
|
+
* @returns {boolean} - True if the UID is a video transfer syntax
|
|
9524
|
+
*/
|
|
9525
|
+
function isVideoTransferSyntax(uid) {
|
|
9526
|
+
return uid && videoTransferSyntaxUIDs.has(uid);
|
|
9601
9527
|
}
|
|
9602
9528
|
|
|
9603
|
-
|
|
9604
|
-
|
|
9529
|
+
/**
|
|
9530
|
+
* This is an enumeration of some HEX values for the tag strings, used to replace
|
|
9531
|
+
* constants in a few places.
|
|
9532
|
+
*/
|
|
9533
|
+
var TagHex = {
|
|
9534
|
+
Item: "FFFEE000",
|
|
9535
|
+
ItemDelimitationEnd: "FFFEE00D",
|
|
9536
|
+
SequenceDelimitationEnd: "FFFEE0DD",
|
|
9537
|
+
PixelData: "7FE00010",
|
|
9538
|
+
FileMetaInformationGroupLength: "00020000",
|
|
9539
|
+
TransferSyntaxUID: "00020010",
|
|
9540
|
+
Rows: "00280010",
|
|
9541
|
+
Columns: "00280011",
|
|
9542
|
+
SamplesPerPixel: "00280002",
|
|
9543
|
+
BitsAllocated: "00280100",
|
|
9544
|
+
NumberOfFrames: "00280008",
|
|
9545
|
+
SpecificCharacterSet: "00080005",
|
|
9546
|
+
PixelRepresentation: "00280103",
|
|
9547
|
+
DataSetTrailingPadding: "FFFCFFFC",
|
|
9548
|
+
StudyInstanceUID: "0020000D",
|
|
9549
|
+
SeriesInstanceUID: "0020000E",
|
|
9550
|
+
SOPInstanceUID: "00080018",
|
|
9551
|
+
TimezoneOffsetFromUTC: "00080201",
|
|
9552
|
+
AvailableTransferSyntaxUID: "00083002",
|
|
9553
|
+
MediaStorageSOPInstanceUID: "00020003",
|
|
9554
|
+
MediaStorageSOPClassUID: "00020002"
|
|
9555
|
+
};
|
|
9556
|
+
var encodingMapping = {
|
|
9557
|
+
"": "iso-8859-1",
|
|
9558
|
+
"iso-ir-6": "iso-8859-1",
|
|
9559
|
+
"iso-ir-13": "shift-jis",
|
|
9560
|
+
"iso-ir-100": "latin1",
|
|
9561
|
+
"iso-ir-101": "iso-8859-2",
|
|
9562
|
+
"iso-ir-109": "iso-8859-3",
|
|
9563
|
+
"iso-ir-110": "iso-8859-4",
|
|
9564
|
+
"iso-ir-126": "iso-ir-126",
|
|
9565
|
+
"iso-ir-127": "iso-ir-127",
|
|
9566
|
+
"iso-ir-138": "iso-ir-138",
|
|
9567
|
+
"iso-ir-144": "iso-ir-144",
|
|
9568
|
+
"iso-ir-148": "iso-ir-148",
|
|
9569
|
+
"iso-ir-166": "tis-620",
|
|
9570
|
+
"iso-2022-ir-6": "iso-8859-1",
|
|
9571
|
+
"iso-2022-ir-13": "shift-jis",
|
|
9572
|
+
"iso-2022-ir-87": "iso-2022-jp",
|
|
9573
|
+
"iso-2022-ir-100": "latin1",
|
|
9574
|
+
"iso-2022-ir-101": "iso-8859-2",
|
|
9575
|
+
"iso-2022-ir-109": "iso-8859-3",
|
|
9576
|
+
"iso-2022-ir-110": "iso-8859-4",
|
|
9577
|
+
"iso-2022-ir-126": "iso-ir-126",
|
|
9578
|
+
"iso-2022-ir-127": "iso-ir-127",
|
|
9579
|
+
"iso-2022-ir-138": "iso-ir-138",
|
|
9580
|
+
"iso-2022-ir-144": "iso-ir-144",
|
|
9581
|
+
"iso-2022-ir-148": "iso-ir-148",
|
|
9582
|
+
"iso-2022-ir-149": "euc-kr",
|
|
9583
|
+
"iso-2022-ir-159": "iso-2022-jp",
|
|
9584
|
+
"iso-2022-ir-166": "tis-620",
|
|
9585
|
+
"iso-2022-ir-58": "iso-ir-58",
|
|
9586
|
+
"iso-ir-192": "utf-8",
|
|
9587
|
+
gb18030: "gb18030",
|
|
9588
|
+
"iso-2022-gbk": "gbk",
|
|
9589
|
+
"iso-2022-58": "gb2312",
|
|
9590
|
+
gbk: "gbk"
|
|
9591
|
+
};
|
|
9592
|
+
|
|
9593
|
+
/**
|
|
9594
|
+
* Maps DICOM tag hex strings to their normalized lower camelCase names
|
|
9595
|
+
* for use in listener.information tracking
|
|
9596
|
+
*/
|
|
9597
|
+
var TAG_NAME_MAP = {
|
|
9598
|
+
"0020000D": "studyInstanceUid",
|
|
9599
|
+
"0020000E": "seriesInstanceUid",
|
|
9600
|
+
"00080018": "sopInstanceUid",
|
|
9601
|
+
"00020010": "transferSyntaxUid",
|
|
9602
|
+
"00083002": "availableTransferSyntaxUid",
|
|
9603
|
+
"00080201": "timezoneOffsetFromUtc",
|
|
9604
|
+
"00080005": "specificCharacterSet",
|
|
9605
|
+
"00280008": "numberOfFrames",
|
|
9606
|
+
"00280010": "rows",
|
|
9607
|
+
"00280011": "columns",
|
|
9608
|
+
"00280002": "samplesPerPixel",
|
|
9609
|
+
"00280100": "bitsAllocated",
|
|
9610
|
+
"00280103": "pixelRepresentation"
|
|
9611
|
+
};
|
|
9605
9612
|
|
|
9606
|
-
|
|
9613
|
+
/**
|
|
9614
|
+
* Default tags to track in listener.information
|
|
9615
|
+
*/
|
|
9616
|
+
var DEFAULT_INFORMATION_TAGS = new Set(["0020000D",
|
|
9617
|
+
// StudyInstanceUID
|
|
9618
|
+
"0020000E",
|
|
9619
|
+
// SeriesInstanceUID
|
|
9620
|
+
"00080018",
|
|
9621
|
+
// SOPInstanceUID
|
|
9622
|
+
"00020010",
|
|
9623
|
+
// TransferSyntaxUID
|
|
9624
|
+
"00083002",
|
|
9625
|
+
// AvailableTransferSyntaxUID
|
|
9626
|
+
"00080201",
|
|
9627
|
+
// TimezoneOffsetFromUTC
|
|
9628
|
+
"00080005",
|
|
9629
|
+
// SpecificCharacterSet
|
|
9630
|
+
"00280008",
|
|
9631
|
+
// NumberOfFrames
|
|
9632
|
+
"00280010",
|
|
9633
|
+
// Rows
|
|
9634
|
+
"00280011",
|
|
9635
|
+
// Columns
|
|
9636
|
+
"00280002",
|
|
9637
|
+
// SamplesPerPixel
|
|
9638
|
+
"00280100",
|
|
9639
|
+
// BitsAllocated
|
|
9640
|
+
"00280103" // PixelRepresentation
|
|
9641
|
+
]);
|
|
9607
9642
|
|
|
9608
|
-
|
|
9609
|
-
|
|
9610
|
-
|
|
9611
|
-
|
|
9612
|
-
|
|
9613
|
-
|
|
9614
|
-
|
|
9615
|
-
|
|
9616
|
-
|
|
9643
|
+
/**
|
|
9644
|
+
* All valid DICOM VR (Value Representation) codes
|
|
9645
|
+
*/
|
|
9646
|
+
var VALID_VRS = new Set(["AE",
|
|
9647
|
+
// Application Entity
|
|
9648
|
+
"AS",
|
|
9649
|
+
// Age String
|
|
9650
|
+
"AT",
|
|
9651
|
+
// Attribute Tag
|
|
9652
|
+
"CS",
|
|
9653
|
+
// Code String
|
|
9654
|
+
"DA",
|
|
9655
|
+
// Date
|
|
9656
|
+
"DS",
|
|
9657
|
+
// Decimal String
|
|
9658
|
+
"DT",
|
|
9659
|
+
// Date Time
|
|
9660
|
+
"FL",
|
|
9661
|
+
// Floating Point Single
|
|
9662
|
+
"FD",
|
|
9663
|
+
// Floating Point Double
|
|
9664
|
+
"IS",
|
|
9665
|
+
// Integer String
|
|
9666
|
+
"LO",
|
|
9667
|
+
// Long String
|
|
9668
|
+
"LT",
|
|
9669
|
+
// Long Text
|
|
9670
|
+
"OB",
|
|
9671
|
+
// Other Byte
|
|
9672
|
+
"OD",
|
|
9673
|
+
// Other Double
|
|
9674
|
+
"OF",
|
|
9675
|
+
// Other Float
|
|
9676
|
+
"OL",
|
|
9677
|
+
// Other Long
|
|
9678
|
+
"OV",
|
|
9679
|
+
// Other 64-bit Very Long
|
|
9680
|
+
"OW",
|
|
9681
|
+
// Other Word
|
|
9682
|
+
"PN",
|
|
9683
|
+
// Person Name
|
|
9684
|
+
"SH",
|
|
9685
|
+
// Short String
|
|
9686
|
+
"SL",
|
|
9687
|
+
// Signed Long
|
|
9688
|
+
"SQ",
|
|
9689
|
+
// Sequence of Items
|
|
9690
|
+
"SS",
|
|
9691
|
+
// Signed Short
|
|
9692
|
+
"ST",
|
|
9693
|
+
// Short Text
|
|
9694
|
+
"SV",
|
|
9695
|
+
// Signed 64-bit Very Long
|
|
9696
|
+
"TM",
|
|
9697
|
+
// Time
|
|
9698
|
+
"UC",
|
|
9699
|
+
// Unlimited Characters
|
|
9700
|
+
"UI",
|
|
9701
|
+
// Unique Identifier
|
|
9702
|
+
"UL",
|
|
9703
|
+
// Unsigned Long
|
|
9704
|
+
"UN",
|
|
9705
|
+
// Unknown
|
|
9706
|
+
"UR",
|
|
9707
|
+
// Universal Resource
|
|
9708
|
+
"US",
|
|
9709
|
+
// Unsigned Short
|
|
9710
|
+
"UT",
|
|
9711
|
+
// Unlimited Text
|
|
9712
|
+
"UV" // Unsigned 64-bit Very Long
|
|
9713
|
+
]);
|
|
9617
9714
|
|
|
9618
9715
|
/**
|
|
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).
|
|
9716
|
+
* DICOM VR (Value Representation) types that are allowed for bulkdata encoding
|
|
9717
|
+
* According to DICOMweb specification
|
|
9624
9718
|
*/
|
|
9625
|
-
|
|
9626
|
-
|
|
9627
|
-
|
|
9628
|
-
|
|
9629
|
-
|
|
9630
|
-
|
|
9631
|
-
|
|
9632
|
-
|
|
9633
|
-
|
|
9634
|
-
|
|
9635
|
-
|
|
9719
|
+
var BULKDATA_VRS = new Set(["DS",
|
|
9720
|
+
// Decimal String
|
|
9721
|
+
"FL",
|
|
9722
|
+
// Floating Point Single
|
|
9723
|
+
"FD",
|
|
9724
|
+
// Floating Point Double
|
|
9725
|
+
"IS",
|
|
9726
|
+
// Integer String
|
|
9727
|
+
"LT",
|
|
9728
|
+
// Long Text
|
|
9729
|
+
"OB",
|
|
9730
|
+
// Other Byte
|
|
9731
|
+
"OD",
|
|
9732
|
+
// Other Double
|
|
9733
|
+
"OF",
|
|
9734
|
+
// Other Float
|
|
9735
|
+
"OL",
|
|
9736
|
+
// Other Long
|
|
9737
|
+
"OV",
|
|
9738
|
+
// Other 64-bit Very Long
|
|
9739
|
+
"OW",
|
|
9740
|
+
// Other Word
|
|
9741
|
+
"SL",
|
|
9742
|
+
// Signed Long
|
|
9743
|
+
"SS",
|
|
9744
|
+
// Signed Short
|
|
9745
|
+
"ST",
|
|
9746
|
+
// Short Text
|
|
9747
|
+
"SV",
|
|
9748
|
+
// Signed 64-bit Very Long
|
|
9749
|
+
"UC",
|
|
9750
|
+
// Unlimited Characters
|
|
9751
|
+
"UL",
|
|
9752
|
+
// Unsigned Long
|
|
9753
|
+
"UN",
|
|
9754
|
+
// Unknown
|
|
9755
|
+
"US",
|
|
9756
|
+
// Unsigned Short
|
|
9757
|
+
"UT",
|
|
9758
|
+
// Unlimited Text
|
|
9759
|
+
"UV" // Unsigned 64-bit Very Long
|
|
9760
|
+
]);
|
|
9636
9761
|
|
|
9637
9762
|
/**
|
|
9638
9763
|
* Converts a PN string to the dicom+json equivalent, or returns the
|
|
@@ -9767,9 +9892,14 @@
|
|
|
9767
9892
|
// since the tag Proxy left core.
|
|
9768
9893
|
// eslint-disable-next-line no-unused-vars
|
|
9769
9894
|
var Tag$1, writeDataSet$1;
|
|
9770
|
-
|
|
9771
|
-
|
|
9772
|
-
|
|
9895
|
+
|
|
9896
|
+
/** Copies the VR flags (constants/vrs.js) to the instance properties. */
|
|
9897
|
+
function applyVrFlags(vr) {
|
|
9898
|
+
var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
9899
|
+
vr._isBinary = !!flags.binary;
|
|
9900
|
+
vr._allowMultiple = !flags.binary && !flags.single;
|
|
9901
|
+
vr._isLength32 = !!flags.length32;
|
|
9902
|
+
}
|
|
9773
9903
|
|
|
9774
9904
|
// Unknown VR types already warned about by createByTypeString — the UN
|
|
9775
9905
|
// fallback warns at most once per type (issue #457).
|
|
@@ -9779,9 +9909,7 @@
|
|
|
9779
9909
|
_classCallCheck(this, ValueRepresentation);
|
|
9780
9910
|
this.type = type;
|
|
9781
9911
|
this.multi = false;
|
|
9782
|
-
this
|
|
9783
|
-
this._allowMultiple = !this._isBinary && singleVRs.indexOf(this.type) == -1;
|
|
9784
|
-
this._isLength32 = length32VRs.indexOf(this.type) != -1;
|
|
9912
|
+
applyVrFlags(this, vrFlags[type]);
|
|
9785
9913
|
this._storeRaw = true;
|
|
9786
9914
|
}
|
|
9787
9915
|
return _createClass(ValueRepresentation, [{
|
|
@@ -10080,8 +10208,8 @@
|
|
|
10080
10208
|
}, {
|
|
10081
10209
|
key: "hasValueAccessors",
|
|
10082
10210
|
value: function hasValueAccessors(type) {
|
|
10083
|
-
if (type
|
|
10084
|
-
return
|
|
10211
|
+
if (Object.prototype.hasOwnProperty.call(Vrs, type)) {
|
|
10212
|
+
return Vrs[type].addValueAccessors !== ValueRepresentation.prototype.addValueAccessors;
|
|
10085
10213
|
}
|
|
10086
10214
|
// Given undefined, assume the representation need to add value accessors
|
|
10087
10215
|
return type === undefined;
|
|
@@ -10089,16 +10217,16 @@
|
|
|
10089
10217
|
}, {
|
|
10090
10218
|
key: "createByTypeString",
|
|
10091
10219
|
value: function createByTypeString(type) {
|
|
10092
|
-
var vr =
|
|
10220
|
+
var vr = Object.prototype.hasOwnProperty.call(Vrs, type) ? Vrs[type] : undefined;
|
|
10093
10221
|
if (vr === undefined) {
|
|
10094
10222
|
if (type == "ox") {
|
|
10095
10223
|
// TODO: determine VR based on context (could be 1 byte pixel data)
|
|
10096
10224
|
// https://github.com/dgobbi/vtk-dicom/issues/38
|
|
10097
10225
|
validationLog.debug("Invalid vr type", type, "- using OW");
|
|
10098
|
-
vr =
|
|
10226
|
+
vr = Vrs.OW;
|
|
10099
10227
|
} else if (type == "xs") {
|
|
10100
10228
|
validationLog.debug("Invalid vr type", type, "- using US");
|
|
10101
|
-
vr =
|
|
10229
|
+
vr = Vrs.US;
|
|
10102
10230
|
} else {
|
|
10103
10231
|
// Warn at most once per unknown type (issue #457): files can
|
|
10104
10232
|
// carry many elements of the same unregistered VR (OL/OV/SV),
|
|
@@ -10107,7 +10235,7 @@
|
|
|
10107
10235
|
unknownVrTypesWarned.add(type);
|
|
10108
10236
|
validationLog.warn("Invalid vr type", type, "- using UN");
|
|
10109
10237
|
}
|
|
10110
|
-
vr =
|
|
10238
|
+
vr = Vrs.UN;
|
|
10111
10239
|
}
|
|
10112
10240
|
}
|
|
10113
10241
|
return vr;
|
|
@@ -10202,7 +10330,10 @@
|
|
|
10202
10330
|
// 8 bytes per fragment are needed to store 0xffff (2 bytes), 0xe000 (2 bytes), and frageStream size (4 bytes)
|
|
10203
10331
|
bufferLength += _fragmentsLength * 8;
|
|
10204
10332
|
}
|
|
10205
|
-
binaryStream = new WriteBufferStream(
|
|
10333
|
+
binaryStream = new WriteBufferStream({
|
|
10334
|
+
defaultSize: bufferLength,
|
|
10335
|
+
littleEndian: stream.isLittleEndian
|
|
10336
|
+
});
|
|
10206
10337
|
for (i = 0; i < frames; i++) {
|
|
10207
10338
|
var _needsPadding = Boolean(value[i].byteLength & 1);
|
|
10208
10339
|
startOffset.push(binaryStream.size);
|
|
@@ -10305,7 +10436,8 @@
|
|
|
10305
10436
|
start = _range[0],
|
|
10306
10437
|
stop = _range[1];
|
|
10307
10438
|
// create a new readable stream based on the range
|
|
10308
|
-
var rangeStream = new ReadBufferStream(stream.buffer,
|
|
10439
|
+
var rangeStream = new ReadBufferStream(stream.buffer, {
|
|
10440
|
+
littleEndian: stream.isLittleEndian,
|
|
10309
10441
|
start: start,
|
|
10310
10442
|
stop: stop,
|
|
10311
10443
|
noCopy: stream.noCopy
|
|
@@ -11350,7 +11482,7 @@
|
|
|
11350
11482
|
key: "read",
|
|
11351
11483
|
value: function read(stream, length, syntax, readOptions) {
|
|
11352
11484
|
var arrayBuffer = this.readBytes(stream, length, syntax)[0];
|
|
11353
|
-
var streamFromBuffer = new ReadBufferStream(arrayBuffer
|
|
11485
|
+
var streamFromBuffer = new ReadBufferStream(arrayBuffer);
|
|
11354
11486
|
var vr = ValueRepresentation$1.createByTypeString(this.type);
|
|
11355
11487
|
if (vr.isBinary() && length > vr.maxLength && !vr.noMultiple) {
|
|
11356
11488
|
var values = [];
|
|
@@ -11425,8 +11557,13 @@
|
|
|
11425
11557
|
}
|
|
11426
11558
|
_inherits(OtherFloatString, _BinaryRepresentation6);
|
|
11427
11559
|
return _createClass(OtherFloatString);
|
|
11428
|
-
}(BinaryRepresentation);
|
|
11429
|
-
|
|
11560
|
+
}(BinaryRepresentation);
|
|
11561
|
+
/**
|
|
11562
|
+
* The shared VR instances by code (`Vrs.DS`); `registerVr` extends it.
|
|
11563
|
+
* @typedef {Object<string, ValueRepresentation>} VrRegistry
|
|
11564
|
+
* @type {VrRegistry}
|
|
11565
|
+
*/
|
|
11566
|
+
var Vrs = {
|
|
11430
11567
|
AE: new ApplicationEntity(),
|
|
11431
11568
|
AS: new AgeString(),
|
|
11432
11569
|
AT: new AttributeTag(),
|
|
@@ -11460,6 +11597,62 @@
|
|
|
11460
11597
|
UV: new Unsigned64BitVeryLong()
|
|
11461
11598
|
};
|
|
11462
11599
|
|
|
11600
|
+
/**
|
|
11601
|
+
* SOP Class UIDs by name (a subset of PS3.4 B.5): `SopClasses.CTImage`.
|
|
11602
|
+
* It is also `DicomMetaDictionary.sopClassUIDsByName`.
|
|
11603
|
+
* @typedef {typeof SopClasses} SopClassRegistry
|
|
11604
|
+
* @type {Object<string, string>}
|
|
11605
|
+
*/
|
|
11606
|
+
var SopClasses = {
|
|
11607
|
+
NMImage: "1.2.840.10008.5.1.4.1.1.20",
|
|
11608
|
+
CTImage: "1.2.840.10008.5.1.4.1.1.2",
|
|
11609
|
+
EnhancedCTImage: "1.2.840.10008.5.1.4.1.1.2.1",
|
|
11610
|
+
LegacyConvertedEnhancedCTImage: "1.2.840.10008.5.1.4.1.1.2.2",
|
|
11611
|
+
USMultiframeImage: "1.2.840.10008.5.1.4.1.1.3.1",
|
|
11612
|
+
MRImage: "1.2.840.10008.5.1.4.1.1.4",
|
|
11613
|
+
EnhancedMRImage: "1.2.840.10008.5.1.4.1.1.4.1",
|
|
11614
|
+
MRSpectroscopy: "1.2.840.10008.5.1.4.1.1.4.2",
|
|
11615
|
+
EnhancedMRColorImage: "1.2.840.10008.5.1.4.1.1.4.3",
|
|
11616
|
+
LegacyConvertedEnhancedMRImage: "1.2.840.10008.5.1.4.1.1.4.4",
|
|
11617
|
+
USImage: "1.2.840.10008.5.1.4.1.1.6.1",
|
|
11618
|
+
EnhancedUSVolume: "1.2.840.10008.5.1.4.1.1.6.2",
|
|
11619
|
+
SecondaryCaptureImage: "1.2.840.10008.5.1.4.1.1.7",
|
|
11620
|
+
ParametricMapStorage: "1.2.840.10008.5.1.4.1.1.30",
|
|
11621
|
+
RawData: "1.2.840.10008.5.1.4.1.1.66",
|
|
11622
|
+
SpatialRegistration: "1.2.840.10008.5.1.4.1.1.66.1",
|
|
11623
|
+
SpatialFiducials: "1.2.840.10008.5.1.4.1.1.66.2",
|
|
11624
|
+
DeformableSpatialRegistration: "1.2.840.10008.5.1.4.1.1.66.3",
|
|
11625
|
+
Segmentation: "1.2.840.10008.5.1.4.1.1.66.4",
|
|
11626
|
+
LabelmapSegmentation: "1.2.840.10008.5.1.4.1.1.66.7",
|
|
11627
|
+
RealWorldValueMapping: "1.2.840.10008.5.1.4.1.1.67",
|
|
11628
|
+
BasicTextSR: "1.2.840.10008.5.1.4.1.1.88.11",
|
|
11629
|
+
EnhancedSR: "1.2.840.10008.5.1.4.1.1.88.22",
|
|
11630
|
+
ComprehensiveSR: "1.2.840.10008.5.1.4.1.1.88.33",
|
|
11631
|
+
Comprehensive3DSR: "1.2.840.10008.5.1.4.1.1.88.34",
|
|
11632
|
+
PETImage: "1.2.840.10008.5.1.4.1.1.128",
|
|
11633
|
+
EnhancedPETImage: "1.2.840.10008.5.1.4.1.1.130",
|
|
11634
|
+
LegacyConvertedEnhancedPETImage: "1.2.840.10008.5.1.4.1.1.128.1",
|
|
11635
|
+
OphthalmicPhotography8BitImage: "1.2.840.10008.5.1.4.1.1.77.1.5.1",
|
|
11636
|
+
OphthalmicTomographyImage: "1.2.840.10008.5.1.4.1.1.77.1.5.4"
|
|
11637
|
+
};
|
|
11638
|
+
|
|
11639
|
+
/** UID -> name; also `DicomMetaDictionary.sopClassNamesByUID`. */
|
|
11640
|
+
var sopClassNamesByUID = Object.fromEntries(Object.entries(SopClasses).map(function (_ref) {
|
|
11641
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
11642
|
+
name = _ref2[0],
|
|
11643
|
+
uid = _ref2[1];
|
|
11644
|
+
return [uid, name];
|
|
11645
|
+
}));
|
|
11646
|
+
|
|
11647
|
+
/** Adds or replaces a SOP class name and UID. */
|
|
11648
|
+
function registerSopClass(name, uid) {
|
|
11649
|
+
if (sopClassNamesByUID[SopClasses[name]] === name) {
|
|
11650
|
+
delete sopClassNamesByUID[SopClasses[name]];
|
|
11651
|
+
}
|
|
11652
|
+
SopClasses[name] = uid;
|
|
11653
|
+
sopClassNamesByUID[uid] = name;
|
|
11654
|
+
}
|
|
11655
|
+
|
|
11463
11656
|
// src/core/normalizeSyntax.js
|
|
11464
11657
|
|
|
11465
11658
|
/**
|
|
@@ -11575,9 +11768,13 @@
|
|
|
11575
11768
|
stream.setEndian(isLittleEndian);
|
|
11576
11769
|
stream.writeUint16(this.group());
|
|
11577
11770
|
stream.writeUint16(this.element());
|
|
11578
|
-
var tagStream = new WriteBufferStream(
|
|
11771
|
+
var tagStream = new WriteBufferStream({
|
|
11772
|
+
defaultSize: 256
|
|
11773
|
+
}),
|
|
11579
11774
|
valueLength;
|
|
11580
11775
|
tagStream.setEndian(isLittleEndian);
|
|
11776
|
+
// sequence items are written through tagStream: keep the charset
|
|
11777
|
+
tagStream.encoder = stream.encoder;
|
|
11581
11778
|
if (vrType == "OW" || vrType == "OB" || vrType == "UN") {
|
|
11582
11779
|
valueLength = vr.writeBytes(tagStream, values, useSyntax, isEncapsulated, writeOptions);
|
|
11583
11780
|
} else if (vrType == "SQ") {
|
|
@@ -12478,13 +12675,6 @@
|
|
|
12478
12675
|
return entry !== null && entry !== void 0 && entry.vm && !isMultiVM(entry.vm) ? 1 : undefined;
|
|
12479
12676
|
}
|
|
12480
12677
|
|
|
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
12678
|
var BINARY_AS = new Set(["ArrayBuffer", "Uint8Array"]);
|
|
12489
12679
|
var isSharedBuffer = function isSharedBuffer(v) {
|
|
12490
12680
|
return typeof SharedArrayBuffer !== "undefined" && v instanceof SharedArrayBuffer;
|
|
@@ -14062,59 +14252,32 @@
|
|
|
14062
14252
|
});
|
|
14063
14253
|
return nameMap;
|
|
14064
14254
|
}
|
|
14255
|
+
|
|
14256
|
+
/**
|
|
14257
|
+
* Registers each entry of `sopClassNamesByUID` (constants/sopClasses.js
|
|
14258
|
+
* `registerSopClass`), for 0.x code that edits that map directly. It
|
|
14259
|
+
* adds entries; `sopClassUIDsByName` stays the `SopClasses` object.
|
|
14260
|
+
*/
|
|
14065
14261
|
}, {
|
|
14066
14262
|
key: "_generateUIDMap",
|
|
14067
14263
|
value: function _generateUIDMap() {
|
|
14068
|
-
|
|
14069
|
-
Object.keys(
|
|
14070
|
-
|
|
14071
|
-
DicomMetaDictionary.sopClassUIDsByName[name] = uid;
|
|
14264
|
+
var namesByUid = DicomMetaDictionary.sopClassNamesByUID;
|
|
14265
|
+
Object.keys(namesByUid).forEach(function (uid) {
|
|
14266
|
+
return registerSopClass(namesByUid[uid], uid);
|
|
14072
14267
|
});
|
|
14073
14268
|
}
|
|
14074
14269
|
}]);
|
|
14075
14270
|
}();
|
|
14076
14271
|
|
|
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
|
-
};
|
|
14272
|
+
// The SOP class registry (constants/sopClasses.js); both are the registry's
|
|
14273
|
+
// own objects, so registerSopClass shows in them.
|
|
14274
|
+
DicomMetaDictionary.sopClassNamesByUID = sopClassNamesByUID;
|
|
14275
|
+
DicomMetaDictionary.sopClassUIDsByName = SopClasses;
|
|
14112
14276
|
|
|
14113
14277
|
// Avoid loops in imports
|
|
14114
14278
|
ValueRepresentation$1.setDicomMetaDictionary(DicomMetaDictionary);
|
|
14115
14279
|
DicomMetaDictionary.dictionary = dictionary;
|
|
14116
14280
|
DicomMetaDictionary._generateNameMap();
|
|
14117
|
-
DicomMetaDictionary._generateUIDMap();
|
|
14118
14281
|
|
|
14119
14282
|
// AUTO-GENERATED from dictionary.mjs by generate/pack_private.mjs
|
|
14120
14283
|
// Private tags only (creator strings). Decoded on first use; use ensurePrivateLoaded() if needed.
|
|
@@ -14195,6 +14358,128 @@
|
|
|
14195
14358
|
return undefined;
|
|
14196
14359
|
}
|
|
14197
14360
|
|
|
14361
|
+
/**
|
|
14362
|
+
* One SpecificCharacterSet defined term. Give `label` (a WHATWG Encoding
|
|
14363
|
+
* label) and/or `createDecoder`; a label builds the decoder and, for UTF-8
|
|
14364
|
+
* and single-byte encodings, the encoder. `encode` null means no encoder.
|
|
14365
|
+
* @typedef {Object} CharacterSet
|
|
14366
|
+
* @property {string} [label]
|
|
14367
|
+
* @property {() => {decode(input: BufferSource): string}} [createDecoder]
|
|
14368
|
+
* @property {((text: string, options?: {ignoreErrors?: boolean}) => Uint8Array)|null} [encode]
|
|
14369
|
+
*/
|
|
14370
|
+
|
|
14371
|
+
var MULTI_BYTE = /^(shift_jis|euc-jp|iso-2022-jp|euc-kr|gbk|gb18030|big5|utf-16(le|be)|replacement)$/;
|
|
14372
|
+
var registered = {};
|
|
14373
|
+
var byLabel = {};
|
|
14374
|
+
var warned = new Set();
|
|
14375
|
+
var utf8Encoder = new TextEncoder();
|
|
14376
|
+
|
|
14377
|
+
/**
|
|
14378
|
+
* Normalizes a (0008,0005) value to the `encodingMapping` key form
|
|
14379
|
+
* ("ISO_IR 100" gives "iso-ir-100"); strips the NUL padding of old modalities.
|
|
14380
|
+
*/
|
|
14381
|
+
function normalizeCharacterSetTerm(value) {
|
|
14382
|
+
return String(value !== null && value !== void 0 ? value : "").replace(/\0/g, "").trim().replace(/[_ ]/g, "-").toLowerCase();
|
|
14383
|
+
}
|
|
14384
|
+
|
|
14385
|
+
/**
|
|
14386
|
+
* The encoder of a label: TextEncoder for UTF-8, a reverse table of the
|
|
14387
|
+
* decoder over 0x00-0xFF for a single-byte encoding, null otherwise. A
|
|
14388
|
+
* single-byte encoder throws on a character it cannot hold, or writes `?`
|
|
14389
|
+
* with `options.ignoreErrors`.
|
|
14390
|
+
*/
|
|
14391
|
+
function encoderForLabel(label) {
|
|
14392
|
+
var decoder;
|
|
14393
|
+
try {
|
|
14394
|
+
decoder = createDecoder(label);
|
|
14395
|
+
} catch (_unused) {
|
|
14396
|
+
return null;
|
|
14397
|
+
}
|
|
14398
|
+
if (decoder.encoding === "utf-8") {
|
|
14399
|
+
return function (text) {
|
|
14400
|
+
return utf8Encoder.encode(text);
|
|
14401
|
+
};
|
|
14402
|
+
}
|
|
14403
|
+
if (MULTI_BYTE.test(decoder.encoding)) {
|
|
14404
|
+
return null;
|
|
14405
|
+
}
|
|
14406
|
+
var table = new Map();
|
|
14407
|
+
for (var byte = 255; byte >= 0; byte--) {
|
|
14408
|
+
var char = decoder.decode(Uint8Array.of(byte));
|
|
14409
|
+
if (char !== "�") table.set(char, byte);
|
|
14410
|
+
}
|
|
14411
|
+
return function (text) {
|
|
14412
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
14413
|
+
var out = [];
|
|
14414
|
+
var _iterator = _createForOfIteratorHelper(text),
|
|
14415
|
+
_step;
|
|
14416
|
+
try {
|
|
14417
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
14418
|
+
var _char = _step.value;
|
|
14419
|
+
var _byte = table.get(_char);
|
|
14420
|
+
if (_byte === undefined) {
|
|
14421
|
+
if (!options.ignoreErrors) {
|
|
14422
|
+
throw new Error("\"".concat(_char, "\" (U+").concat(_char.codePointAt(0).toString(16).toUpperCase(), ") is not in the character set ").concat(label));
|
|
14423
|
+
}
|
|
14424
|
+
_byte = 0x3f;
|
|
14425
|
+
}
|
|
14426
|
+
out.push(_byte);
|
|
14427
|
+
}
|
|
14428
|
+
} catch (err) {
|
|
14429
|
+
_iterator.e(err);
|
|
14430
|
+
} finally {
|
|
14431
|
+
_iterator.f();
|
|
14432
|
+
}
|
|
14433
|
+
return Uint8Array.from(out);
|
|
14434
|
+
};
|
|
14435
|
+
}
|
|
14436
|
+
function characterSetForLabel(label) {
|
|
14437
|
+
var _byLabel$label;
|
|
14438
|
+
return (_byLabel$label = byLabel[label]) !== null && _byLabel$label !== void 0 ? _byLabel$label : byLabel[label] = {
|
|
14439
|
+
label: label,
|
|
14440
|
+
createDecoder: function createDecoder$1() {
|
|
14441
|
+
return createDecoder(label);
|
|
14442
|
+
},
|
|
14443
|
+
encode: encoderForLabel(label)
|
|
14444
|
+
};
|
|
14445
|
+
}
|
|
14446
|
+
|
|
14447
|
+
/** The CharacterSet of a normalized term, or undefined. */
|
|
14448
|
+
function lookupCharacterSet(code) {
|
|
14449
|
+
if (registered[code]) return registered[code];
|
|
14450
|
+
var label = Object.hasOwn(encodingMapping, code) && encodingMapping[code];
|
|
14451
|
+
return label ? characterSetForLabel(label) : undefined;
|
|
14452
|
+
}
|
|
14453
|
+
|
|
14454
|
+
/**
|
|
14455
|
+
* The text encoder (`{ encode(text) }`) for a dataset or item that declares
|
|
14456
|
+
* `values` in (0008,0005). No encoder (multi-byte, ISO 2022, multi-valued,
|
|
14457
|
+
* unknown) gives UTF-8 bytes, as before, with one warning per term.
|
|
14458
|
+
* @param {string[]|string} values
|
|
14459
|
+
* @param {{ignoreErrors?: boolean}} [writeOptions]
|
|
14460
|
+
*/
|
|
14461
|
+
function createCharacterSetEncoder(values, writeOptions) {
|
|
14462
|
+
var _lookupCharacterSet;
|
|
14463
|
+
var list = [].concat(values !== null && values !== void 0 ? values : []);
|
|
14464
|
+
var key = list.map(normalizeCharacterSetTerm).join("\\");
|
|
14465
|
+
var _encode = list.length < 2 && ((_lookupCharacterSet = lookupCharacterSet(normalizeCharacterSetTerm(list[0]))) === null || _lookupCharacterSet === void 0 ? void 0 : _lookupCharacterSet.encode);
|
|
14466
|
+
if (!_encode) {
|
|
14467
|
+
if (!warned.has(key)) {
|
|
14468
|
+
warned.add(key);
|
|
14469
|
+
log.warn("No encoder for the character set \"".concat(key, "\"; writing UTF-8 bytes"));
|
|
14470
|
+
}
|
|
14471
|
+
return utf8Encoder;
|
|
14472
|
+
}
|
|
14473
|
+
var options = {
|
|
14474
|
+
ignoreErrors: writeOptions === null || writeOptions === void 0 ? void 0 : writeOptions.ignoreErrors
|
|
14475
|
+
};
|
|
14476
|
+
return {
|
|
14477
|
+
encode: function encode(text) {
|
|
14478
|
+
return _encode(text, options);
|
|
14479
|
+
}
|
|
14480
|
+
};
|
|
14481
|
+
}
|
|
14482
|
+
|
|
14198
14483
|
var ESC = 0x1b;
|
|
14199
14484
|
|
|
14200
14485
|
// G0 designations with dedicated decode strategies.
|
|
@@ -14498,15 +14783,6 @@
|
|
|
14498
14783
|
return decodeWith("latin1", runBytes);
|
|
14499
14784
|
}
|
|
14500
14785
|
|
|
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
14786
|
/**
|
|
14511
14787
|
* Resolves the decoder for a SpecificCharacterSet (0008,0005) value list.
|
|
14512
14788
|
*
|
|
@@ -14522,11 +14798,12 @@
|
|
|
14522
14798
|
if (!values || values.length === 0) {
|
|
14523
14799
|
return null;
|
|
14524
14800
|
}
|
|
14525
|
-
var codes = values.map(
|
|
14801
|
+
var codes = values.map(normalizeCharacterSetTerm);
|
|
14526
14802
|
if (values.length === 1) {
|
|
14527
14803
|
var coding = codes[0];
|
|
14528
|
-
|
|
14529
|
-
|
|
14804
|
+
var characterSet = lookupCharacterSet(coding);
|
|
14805
|
+
if (characterSet) {
|
|
14806
|
+
return characterSet.createDecoder();
|
|
14530
14807
|
}
|
|
14531
14808
|
if (ignoreErrors) {
|
|
14532
14809
|
log.warn("Unsupported character set: ".concat(coding, ", using default character set"));
|
|
@@ -14553,7 +14830,7 @@
|
|
|
14553
14830
|
try {
|
|
14554
14831
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
14555
14832
|
var code = _step.value;
|
|
14556
|
-
if (code !== "" && !(code
|
|
14833
|
+
if (code !== "" && !lookupCharacterSet(code)) {
|
|
14557
14834
|
if (ignoreErrors) {
|
|
14558
14835
|
log.warn("Unsupported character set: ".concat(code, ", using default character set"));
|
|
14559
14836
|
} else {
|
|
@@ -14652,17 +14929,29 @@
|
|
|
14652
14929
|
tag.write(stream, vr, values, syntax, writeOptions);
|
|
14653
14930
|
}
|
|
14654
14931
|
|
|
14655
|
-
/**
|
|
14932
|
+
/**
|
|
14933
|
+
* Relocated from DicomMessage.write: one tag-keyed object, sorted tag order.
|
|
14934
|
+
* A written (0008,0005) sets the stream's text encoder until the end of
|
|
14935
|
+
* this dataset or item; the caller's encoder is then restored.
|
|
14936
|
+
*/
|
|
14656
14937
|
function writeDataSet(jsonObjects, useStream, syntax, writeOptions) {
|
|
14657
14938
|
var written = 0;
|
|
14939
|
+
var outerEncoder = useStream.encoder;
|
|
14658
14940
|
var sortedTags = Object.keys(jsonObjects).sort();
|
|
14659
|
-
|
|
14660
|
-
|
|
14661
|
-
|
|
14662
|
-
|
|
14663
|
-
|
|
14664
|
-
|
|
14665
|
-
|
|
14941
|
+
try {
|
|
14942
|
+
sortedTags.forEach(function (tagString) {
|
|
14943
|
+
var tag = Tag.fromString(tagString),
|
|
14944
|
+
tagObject = jsonObjects[tagString],
|
|
14945
|
+
vrType = tagObject.vr;
|
|
14946
|
+
var values = getTagWriteValues(vrType, tagObject);
|
|
14947
|
+
written += tag.write(useStream, vrType, values, syntax, writeOptions);
|
|
14948
|
+
if (tagString === TagHex.SpecificCharacterSet) {
|
|
14949
|
+
useStream.encoder = createCharacterSetEncoder(values, writeOptions);
|
|
14950
|
+
}
|
|
14951
|
+
});
|
|
14952
|
+
} finally {
|
|
14953
|
+
useStream.encoder = outerEncoder;
|
|
14954
|
+
}
|
|
14666
14955
|
return written;
|
|
14667
14956
|
}
|
|
14668
14957
|
|
|
@@ -14695,10 +14984,14 @@
|
|
|
14695
14984
|
allowInvalidVRLength: false
|
|
14696
14985
|
};
|
|
14697
14986
|
var metaSyntax = EXPLICIT_LITTLE_ENDIAN;
|
|
14698
|
-
var fileStream = new WriteBufferStream(
|
|
14987
|
+
var fileStream = new WriteBufferStream({
|
|
14988
|
+
defaultSize: 4096
|
|
14989
|
+
});
|
|
14699
14990
|
fileStream.writeUint8Repeat(0, 128);
|
|
14700
14991
|
fileStream.writeAsciiString("DICM");
|
|
14701
|
-
var metaStream = new WriteBufferStream(
|
|
14992
|
+
var metaStream = new WriteBufferStream({
|
|
14993
|
+
defaultSize: 1024
|
|
14994
|
+
});
|
|
14702
14995
|
if (!meta[TagHex.TransferSyntaxUID]) {
|
|
14703
14996
|
meta[TagHex.TransferSyntaxUID] = {
|
|
14704
14997
|
vr: "UI",
|
|
@@ -14731,7 +15024,9 @@
|
|
|
14731
15024
|
* @param {Object} writeOptions
|
|
14732
15025
|
*/
|
|
14733
15026
|
function writeDeflatedDataSet(dict, fileStream, writeOptions) {
|
|
14734
|
-
var bodyStream = new WriteBufferStream(
|
|
15027
|
+
var bodyStream = new WriteBufferStream({
|
|
15028
|
+
defaultSize: 4096
|
|
15029
|
+
});
|
|
14735
15030
|
writeDataSet(dict, bodyStream, EXPLICIT_LITTLE_ENDIAN, writeOptions);
|
|
14736
15031
|
fileStream.writeRawBytes(pako.deflateRaw(new Uint8Array(bodyStream.getBuffer())));
|
|
14737
15032
|
}
|
|
@@ -15696,7 +15991,7 @@
|
|
|
15696
15991
|
// issue #93 opt-in: accept preamble-less / meta-less inputs
|
|
15697
15992
|
allowMissingHeader: false
|
|
15698
15993
|
};
|
|
15699
|
-
var stream = new ReadBufferStream(buffer,
|
|
15994
|
+
var stream = new ReadBufferStream(buffer, {
|
|
15700
15995
|
noCopy: options.noCopy
|
|
15701
15996
|
}),
|
|
15702
15997
|
useSyntax = EXPLICIT_LITTLE_ENDIAN;
|
|
@@ -15903,7 +16198,7 @@
|
|
|
15903
16198
|
var _ref = vr.read(stream, length, syntax, readOptions) || {},
|
|
15904
16199
|
_rawValue = _ref.rawValue,
|
|
15905
16200
|
_value = _ref.value;
|
|
15906
|
-
if (!vr.isBinary() && singleVRs
|
|
16201
|
+
if (!vr.isBinary() && singleVRs.indexOf(vr.type) == -1) {
|
|
15907
16202
|
rawValues = _rawValue;
|
|
15908
16203
|
values = _value;
|
|
15909
16204
|
if (typeof _value === "string") {
|
|
@@ -16281,9 +16576,11 @@
|
|
|
16281
16576
|
this.isLittleEndian = options === null || options === void 0 ? void 0 : options.isLittleEndian;
|
|
16282
16577
|
// Default maxFragmentSize is 128 MB (128 * 1024 * 1024 bytes)
|
|
16283
16578
|
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,
|
|
16579
|
+
this.stream = new ReadBufferStream(null, _objectSpread2(_objectSpread2({
|
|
16285
16580
|
clearBuffers: true
|
|
16286
|
-
}, options)
|
|
16581
|
+
}, options), {}, {
|
|
16582
|
+
littleEndian: this.isLittleEndian
|
|
16583
|
+
}));
|
|
16287
16584
|
}
|
|
16288
16585
|
|
|
16289
16586
|
/** Sentinel returned when stream is Part 10 but has no preamble (starts with meta). */
|
|
@@ -17333,7 +17630,7 @@
|
|
|
17333
17630
|
}
|
|
17334
17631
|
} else {
|
|
17335
17632
|
_value = (_vr$read2 = vr.read(stream, length, syntax)) === null || _vr$read2 === void 0 ? void 0 : _vr$read2.value;
|
|
17336
|
-
if (!vr.isBinary() && singleVRs
|
|
17633
|
+
if (!vr.isBinary() && singleVRs.indexOf(vr.type) == -1) {
|
|
17337
17634
|
values = _value;
|
|
17338
17635
|
if (typeof _value === "string") {
|
|
17339
17636
|
delimiterChar = String.fromCharCode(VM_DELIMITER);
|
|
@@ -30451,7 +30748,7 @@
|
|
|
30451
30748
|
encodingMapping: encodingMapping,
|
|
30452
30749
|
isEncapsulatedSyntax: isEncapsulatedSyntax,
|
|
30453
30750
|
isVideoTransferSyntax: isVideoTransferSyntax,
|
|
30454
|
-
singleVRs: singleVRs
|
|
30751
|
+
singleVRs: singleVRs,
|
|
30455
30752
|
unencapsulatedTransferSyntaxes: unencapsulatedTransferSyntaxes,
|
|
30456
30753
|
videoTransferSyntaxUIDs: videoTransferSyntaxUIDs
|
|
30457
30754
|
});
|