dcmjs 0.43.0 → 0.43.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/dcmjs.es.js +432 -85
- package/build/dcmjs.es.js.map +1 -1
- package/build/dcmjs.js +432 -85
- package/build/dcmjs.js.map +1 -1
- package/build/dcmjs.min.js +1 -1
- package/build/dcmjs.min.js.map +1 -1
- package/eslint.config.mjs +30 -0
- package/netlify.toml +2 -2
- package/package.json +80 -79
- package/test/adapters.test.js +0 -1
- package/test/data-encoding.test.js +1 -3
- package/test/data-options.test.js +0 -2
- package/test/data.test.js +3 -5
- package/test/lossless-read-write.test.js +0 -2
- package/test/normalizers.test.js +0 -2
- package/test/readBufferStream.test.js +97 -0
- package/test/writeBufferStream.test.js +149 -0
- package/.eslintrc.json +0 -22
package/build/dcmjs.es.js
CHANGED
|
@@ -7614,6 +7614,331 @@ var pako = {
|
|
|
7614
7614
|
constants: constants_1
|
|
7615
7615
|
};
|
|
7616
7616
|
|
|
7617
|
+
/**
|
|
7618
|
+
* This is a data view which is split across multiple pieces, and maintains
|
|
7619
|
+
* a running size, with nullable chunks.
|
|
7620
|
+
*/
|
|
7621
|
+
var SplitDataView = /*#__PURE__*/function () {
|
|
7622
|
+
function SplitDataView() {
|
|
7623
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
7624
|
+
defaultSize: 256 * 1024
|
|
7625
|
+
};
|
|
7626
|
+
_classCallCheck(this, SplitDataView);
|
|
7627
|
+
_defineProperty(this, "buffers", []);
|
|
7628
|
+
_defineProperty(this, "views", []);
|
|
7629
|
+
_defineProperty(this, "offsets", []);
|
|
7630
|
+
_defineProperty(this, "size", 0);
|
|
7631
|
+
_defineProperty(this, "byteLength", 0);
|
|
7632
|
+
/** The default size is 256k */
|
|
7633
|
+
_defineProperty(this, "defaultSize", 256 * 1024);
|
|
7634
|
+
this.defaultSize = options.defaultSize || this.defaultSize;
|
|
7635
|
+
}
|
|
7636
|
+
_createClass(SplitDataView, [{
|
|
7637
|
+
key: "checkSize",
|
|
7638
|
+
value: function checkSize(end) {
|
|
7639
|
+
while (end > this.byteLength) {
|
|
7640
|
+
var buffer = new ArrayBuffer(this.defaultSize);
|
|
7641
|
+
this.buffers.push(buffer);
|
|
7642
|
+
this.views.push(new DataView(buffer));
|
|
7643
|
+
this.offsets.push(this.byteLength);
|
|
7644
|
+
this.byteLength += buffer.byteLength;
|
|
7645
|
+
}
|
|
7646
|
+
}
|
|
7647
|
+
|
|
7648
|
+
/**
|
|
7649
|
+
* Adds the buffer to the end of the current buffers list,
|
|
7650
|
+
* updating the size etc.
|
|
7651
|
+
*
|
|
7652
|
+
* @param {*} buffer
|
|
7653
|
+
* @param {*} options.start for the start of the new buffer to use
|
|
7654
|
+
* @param {*} options.end for the end of the buffer to use
|
|
7655
|
+
* @param {*} options.transfer to transfer the buffer to be owned
|
|
7656
|
+
*/
|
|
7657
|
+
}, {
|
|
7658
|
+
key: "addBuffer",
|
|
7659
|
+
value: function addBuffer(buffer) {
|
|
7660
|
+
var _this$buffers;
|
|
7661
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
7662
|
+
buffer = buffer.buffer || buffer;
|
|
7663
|
+
var start = (options === null || options === void 0 ? void 0 : options.start) || 0;
|
|
7664
|
+
var end = (options === null || options === void 0 ? void 0 : options.end) || buffer.byteLength;
|
|
7665
|
+
var transfer = options === null || options === void 0 ? void 0 : options.transfer;
|
|
7666
|
+
if (start === end) {
|
|
7667
|
+
return;
|
|
7668
|
+
}
|
|
7669
|
+
var addBuffer = transfer ? buffer : buffer.slice(start, end);
|
|
7670
|
+
var lastOffset = this.offsets.length ? this.offsets[this.offsets.length - 1] : 0;
|
|
7671
|
+
var lastLength = this.buffers.length ? (_this$buffers = this.buffers[this.buffers.length - 1]) === null || _this$buffers === void 0 ? void 0 : _this$buffers.byteLength : 0;
|
|
7672
|
+
this.buffers.push(addBuffer);
|
|
7673
|
+
this.views.push(new DataView(addBuffer));
|
|
7674
|
+
this.offsets.push(lastOffset + lastLength);
|
|
7675
|
+
this.size += addBuffer.byteLength;
|
|
7676
|
+
this.byteLength += addBuffer.byteLength;
|
|
7677
|
+
}
|
|
7678
|
+
|
|
7679
|
+
/** Copies one view contents into this one as a mirror */
|
|
7680
|
+
}, {
|
|
7681
|
+
key: "from",
|
|
7682
|
+
value: function from(view, _options) {
|
|
7683
|
+
var _this$offsets, _this$buffers2, _this$views;
|
|
7684
|
+
this.size = view.size;
|
|
7685
|
+
this.byteLength = view.byteLength;
|
|
7686
|
+
(_this$offsets = this.offsets).push.apply(_this$offsets, _toConsumableArray(view.offsets));
|
|
7687
|
+
(_this$buffers2 = this.buffers).push.apply(_this$buffers2, _toConsumableArray(view.buffers));
|
|
7688
|
+
(_this$views = this.views).push.apply(_this$views, _toConsumableArray(view.views));
|
|
7689
|
+
// TODO - use the options to skip copying irrelevant data
|
|
7690
|
+
}
|
|
7691
|
+
}, {
|
|
7692
|
+
key: "slice",
|
|
7693
|
+
value: function slice() {
|
|
7694
|
+
var start = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
7695
|
+
var end = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.size;
|
|
7696
|
+
if (start === end) {
|
|
7697
|
+
return new Uint8Array(0).buffer;
|
|
7698
|
+
}
|
|
7699
|
+
var index = this.findStart(start);
|
|
7700
|
+
if (index === undefined) {
|
|
7701
|
+
throw new Error("Start ".concat(start, " out of range of 0...").concat(this.byteLength));
|
|
7702
|
+
}
|
|
7703
|
+
var buffer = this.buffers[index];
|
|
7704
|
+
if (!buffer) {
|
|
7705
|
+
console.error("Buffer should be defined here");
|
|
7706
|
+
return;
|
|
7707
|
+
}
|
|
7708
|
+
var offset = this.offsets[index];
|
|
7709
|
+
var length = buffer.byteLength;
|
|
7710
|
+
if (end < offset + length) {
|
|
7711
|
+
return buffer.slice(start - offset, end - offset);
|
|
7712
|
+
}
|
|
7713
|
+
var createBuffer = new Uint8Array(end - start);
|
|
7714
|
+
var offsetStart = 0;
|
|
7715
|
+
while (start + offsetStart < end && index < this.buffers.length) {
|
|
7716
|
+
buffer = this.buffers[index];
|
|
7717
|
+
length = buffer.byteLength;
|
|
7718
|
+
offset = this.offsets[index];
|
|
7719
|
+
var bufStart = start + offsetStart - offset;
|
|
7720
|
+
var addLength = Math.min(end - start - offsetStart, length - bufStart);
|
|
7721
|
+
createBuffer.set(new Uint8Array(buffer, bufStart, addLength), offsetStart);
|
|
7722
|
+
offsetStart += addLength;
|
|
7723
|
+
index++;
|
|
7724
|
+
}
|
|
7725
|
+
return createBuffer.buffer;
|
|
7726
|
+
}
|
|
7727
|
+
}, {
|
|
7728
|
+
key: "findStart",
|
|
7729
|
+
value: function findStart() {
|
|
7730
|
+
var start = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
7731
|
+
for (var index = 0; index < this.buffers.length; index++) {
|
|
7732
|
+
if (start >= this.offsets[index] && start < this.offsets[index] + this.buffers[index].byteLength) {
|
|
7733
|
+
return index;
|
|
7734
|
+
}
|
|
7735
|
+
}
|
|
7736
|
+
}
|
|
7737
|
+
}, {
|
|
7738
|
+
key: "findView",
|
|
7739
|
+
value: function findView(start) {
|
|
7740
|
+
var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
7741
|
+
var index = this.findStart(start);
|
|
7742
|
+
var buffer = this.buffers[index];
|
|
7743
|
+
var viewOffset = this.offsets[index];
|
|
7744
|
+
var viewLength = buffer.byteLength;
|
|
7745
|
+
if (start + length - viewOffset <= viewLength) {
|
|
7746
|
+
return {
|
|
7747
|
+
view: this.views[index],
|
|
7748
|
+
viewOffset: viewOffset,
|
|
7749
|
+
index: index
|
|
7750
|
+
};
|
|
7751
|
+
}
|
|
7752
|
+
var newBuffer = this.slice(start, start + length);
|
|
7753
|
+
return {
|
|
7754
|
+
view: new DataView(newBuffer),
|
|
7755
|
+
viewOffset: start,
|
|
7756
|
+
writeCommit: true
|
|
7757
|
+
};
|
|
7758
|
+
}
|
|
7759
|
+
}, {
|
|
7760
|
+
key: "writeCommit",
|
|
7761
|
+
value: function writeCommit(view, start) {
|
|
7762
|
+
this.writeBuffer(view.buffer, start);
|
|
7763
|
+
}
|
|
7764
|
+
}, {
|
|
7765
|
+
key: "writeBuffer",
|
|
7766
|
+
value: function writeBuffer(data, start) {
|
|
7767
|
+
var index = this.findStart(start);
|
|
7768
|
+
var offset = 0;
|
|
7769
|
+
while (offset < data.byteLength) {
|
|
7770
|
+
var buffer = this.buffers[index];
|
|
7771
|
+
if (!buffer) {
|
|
7772
|
+
throw new Error("Not enough space to write ".concat(data.byteLength));
|
|
7773
|
+
}
|
|
7774
|
+
var bufferOffset = this.offsets[index];
|
|
7775
|
+
var startWrite = start + offset - bufferOffset;
|
|
7776
|
+
var writeLen = Math.min(buffer.byteLength - startWrite, data.byteLength - offset);
|
|
7777
|
+
var byteBuffer = new Uint8Array(buffer, startWrite, writeLen);
|
|
7778
|
+
var setData = new Uint8Array(data.buffer || data, offset, writeLen);
|
|
7779
|
+
byteBuffer.set(setData);
|
|
7780
|
+
offset += writeLen;
|
|
7781
|
+
index++;
|
|
7782
|
+
}
|
|
7783
|
+
}
|
|
7784
|
+
}, {
|
|
7785
|
+
key: "getUint8",
|
|
7786
|
+
value: function getUint8(offset) {
|
|
7787
|
+
var _this$findView = this.findView(offset, 1),
|
|
7788
|
+
view = _this$findView.view,
|
|
7789
|
+
viewOffset = _this$findView.viewOffset;
|
|
7790
|
+
return view.getUint8(offset - viewOffset);
|
|
7791
|
+
}
|
|
7792
|
+
}, {
|
|
7793
|
+
key: "getUint16",
|
|
7794
|
+
value: function getUint16(offset, isLittleEndian) {
|
|
7795
|
+
var _this$findView2 = this.findView(offset, 2),
|
|
7796
|
+
view = _this$findView2.view,
|
|
7797
|
+
viewOffset = _this$findView2.viewOffset;
|
|
7798
|
+
return view.getUint16(offset - viewOffset, isLittleEndian);
|
|
7799
|
+
}
|
|
7800
|
+
}, {
|
|
7801
|
+
key: "getUint32",
|
|
7802
|
+
value: function getUint32(offset, isLittleEndian) {
|
|
7803
|
+
var _this$findView3 = this.findView(offset, 4),
|
|
7804
|
+
view = _this$findView3.view,
|
|
7805
|
+
viewOffset = _this$findView3.viewOffset;
|
|
7806
|
+
return view.getUint32(offset - viewOffset, isLittleEndian);
|
|
7807
|
+
}
|
|
7808
|
+
}, {
|
|
7809
|
+
key: "getFloat32",
|
|
7810
|
+
value: function getFloat32(offset, isLittleEndian) {
|
|
7811
|
+
var _this$findView4 = this.findView(offset, 4),
|
|
7812
|
+
view = _this$findView4.view,
|
|
7813
|
+
viewOffset = _this$findView4.viewOffset;
|
|
7814
|
+
return view.getFloat32(offset - viewOffset, isLittleEndian);
|
|
7815
|
+
}
|
|
7816
|
+
}, {
|
|
7817
|
+
key: "getFloat64",
|
|
7818
|
+
value: function getFloat64(offset, isLittleEndian) {
|
|
7819
|
+
var _this$findView5 = this.findView(offset, 8),
|
|
7820
|
+
view = _this$findView5.view,
|
|
7821
|
+
viewOffset = _this$findView5.viewOffset;
|
|
7822
|
+
return view.getFloat64(offset - viewOffset, isLittleEndian);
|
|
7823
|
+
}
|
|
7824
|
+
}, {
|
|
7825
|
+
key: "getInt8",
|
|
7826
|
+
value: function getInt8(offset) {
|
|
7827
|
+
var _this$findView6 = this.findView(offset, 1),
|
|
7828
|
+
view = _this$findView6.view,
|
|
7829
|
+
viewOffset = _this$findView6.viewOffset;
|
|
7830
|
+
return view.getInt8(offset - viewOffset);
|
|
7831
|
+
}
|
|
7832
|
+
}, {
|
|
7833
|
+
key: "getInt16",
|
|
7834
|
+
value: function getInt16(offset, isLittleEndian) {
|
|
7835
|
+
var _this$findView7 = this.findView(offset, 2),
|
|
7836
|
+
view = _this$findView7.view,
|
|
7837
|
+
viewOffset = _this$findView7.viewOffset;
|
|
7838
|
+
return view.getInt16(offset - viewOffset, isLittleEndian);
|
|
7839
|
+
}
|
|
7840
|
+
}, {
|
|
7841
|
+
key: "getInt32",
|
|
7842
|
+
value: function getInt32(offset, isLittleEndian) {
|
|
7843
|
+
var _this$findView8 = this.findView(offset, 4),
|
|
7844
|
+
view = _this$findView8.view,
|
|
7845
|
+
viewOffset = _this$findView8.viewOffset;
|
|
7846
|
+
return view.getInt32(offset - viewOffset, isLittleEndian);
|
|
7847
|
+
}
|
|
7848
|
+
}, {
|
|
7849
|
+
key: "setUint8",
|
|
7850
|
+
value: function setUint8(offset, value) {
|
|
7851
|
+
var _this$findView9 = this.findView(offset, 1),
|
|
7852
|
+
view = _this$findView9.view,
|
|
7853
|
+
viewOffset = _this$findView9.viewOffset;
|
|
7854
|
+
view.setUint8(offset - viewOffset, value);
|
|
7855
|
+
// Commit is unneeded since 1 byte will always be available
|
|
7856
|
+
}
|
|
7857
|
+
}, {
|
|
7858
|
+
key: "setUint16",
|
|
7859
|
+
value: function setUint16(offset, value, isLittleEndian) {
|
|
7860
|
+
var _this$findView0 = this.findView(offset, 2),
|
|
7861
|
+
view = _this$findView0.view,
|
|
7862
|
+
viewOffset = _this$findView0.viewOffset,
|
|
7863
|
+
writeCommit = _this$findView0.writeCommit;
|
|
7864
|
+
view.setUint16(offset - viewOffset, value, isLittleEndian);
|
|
7865
|
+
if (writeCommit) {
|
|
7866
|
+
this.writeCommit(view, offset);
|
|
7867
|
+
}
|
|
7868
|
+
}
|
|
7869
|
+
}, {
|
|
7870
|
+
key: "setUint32",
|
|
7871
|
+
value: function setUint32(offset, value, isLittleEndian) {
|
|
7872
|
+
var _this$findView1 = this.findView(offset, 4),
|
|
7873
|
+
view = _this$findView1.view,
|
|
7874
|
+
viewOffset = _this$findView1.viewOffset,
|
|
7875
|
+
writeCommit = _this$findView1.writeCommit;
|
|
7876
|
+
view.setUint32(offset - viewOffset, value, isLittleEndian);
|
|
7877
|
+
if (writeCommit) {
|
|
7878
|
+
this.writeCommit(view, offset);
|
|
7879
|
+
}
|
|
7880
|
+
}
|
|
7881
|
+
}, {
|
|
7882
|
+
key: "setFloat32",
|
|
7883
|
+
value: function setFloat32(offset, value, isLittleEndian) {
|
|
7884
|
+
var _this$findView10 = this.findView(offset, 4),
|
|
7885
|
+
view = _this$findView10.view,
|
|
7886
|
+
viewOffset = _this$findView10.viewOffset,
|
|
7887
|
+
writeCommit = _this$findView10.writeCommit;
|
|
7888
|
+
view.setFloat32(offset - viewOffset, value, isLittleEndian);
|
|
7889
|
+
if (writeCommit) {
|
|
7890
|
+
this.writeCommit(view, offset);
|
|
7891
|
+
}
|
|
7892
|
+
}
|
|
7893
|
+
}, {
|
|
7894
|
+
key: "setFloat64",
|
|
7895
|
+
value: function setFloat64(offset, value, isLittleEndian) {
|
|
7896
|
+
var _this$findView11 = this.findView(offset, 8),
|
|
7897
|
+
view = _this$findView11.view,
|
|
7898
|
+
viewOffset = _this$findView11.viewOffset,
|
|
7899
|
+
writeCommit = _this$findView11.writeCommit;
|
|
7900
|
+
view.setFloat64(offset - viewOffset, value, isLittleEndian);
|
|
7901
|
+
if (writeCommit) {
|
|
7902
|
+
this.writeCommit(view, offset);
|
|
7903
|
+
}
|
|
7904
|
+
}
|
|
7905
|
+
}, {
|
|
7906
|
+
key: "setInt8",
|
|
7907
|
+
value: function setInt8(offset, value) {
|
|
7908
|
+
var _this$findView12 = this.findView(offset, 1),
|
|
7909
|
+
view = _this$findView12.view,
|
|
7910
|
+
viewOffset = _this$findView12.viewOffset;
|
|
7911
|
+
view.setInt8(offset - viewOffset, value);
|
|
7912
|
+
// Commit is unneeded since 1 byte will always be available
|
|
7913
|
+
}
|
|
7914
|
+
}, {
|
|
7915
|
+
key: "setInt16",
|
|
7916
|
+
value: function setInt16(offset, value, isLittleEndian) {
|
|
7917
|
+
var _this$findView13 = this.findView(offset, 2),
|
|
7918
|
+
view = _this$findView13.view,
|
|
7919
|
+
viewOffset = _this$findView13.viewOffset,
|
|
7920
|
+
writeCommit = _this$findView13.writeCommit;
|
|
7921
|
+
view.setInt16(offset - viewOffset, value, isLittleEndian);
|
|
7922
|
+
if (writeCommit) {
|
|
7923
|
+
this.writeCommit(view, offset);
|
|
7924
|
+
}
|
|
7925
|
+
}
|
|
7926
|
+
}, {
|
|
7927
|
+
key: "setInt32",
|
|
7928
|
+
value: function setInt32(offset, value, isLittleEndian) {
|
|
7929
|
+
var _this$findView14 = this.findView(offset, 4),
|
|
7930
|
+
view = _this$findView14.view,
|
|
7931
|
+
viewOffset = _this$findView14.viewOffset,
|
|
7932
|
+
writeCommit = _this$findView14.writeCommit;
|
|
7933
|
+
view.setInt32(offset - viewOffset, value, isLittleEndian);
|
|
7934
|
+
if (writeCommit) {
|
|
7935
|
+
this.writeCommit(view, offset);
|
|
7936
|
+
}
|
|
7937
|
+
}
|
|
7938
|
+
}]);
|
|
7939
|
+
return SplitDataView;
|
|
7940
|
+
}();
|
|
7941
|
+
|
|
7617
7942
|
function toInt(val) {
|
|
7618
7943
|
if (isNaN(val)) {
|
|
7619
7944
|
throw new Error("Not a number: " + val);
|
|
@@ -7627,23 +7952,52 @@ function toFloat(val) {
|
|
|
7627
7952
|
} else return val;
|
|
7628
7953
|
}
|
|
7629
7954
|
var BufferStream = /*#__PURE__*/function () {
|
|
7630
|
-
function BufferStream(
|
|
7955
|
+
function BufferStream() {
|
|
7956
|
+
var _options$defaultSize;
|
|
7957
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
7631
7958
|
_classCallCheck(this, BufferStream);
|
|
7632
|
-
this
|
|
7633
|
-
|
|
7634
|
-
|
|
7635
|
-
|
|
7636
|
-
this
|
|
7637
|
-
this
|
|
7638
|
-
this.isLittleEndian = littleEndian ||
|
|
7639
|
-
this.
|
|
7640
|
-
this.encoder = new TextEncoder("utf-8");
|
|
7959
|
+
_defineProperty(this, "offset", 0);
|
|
7960
|
+
_defineProperty(this, "startOffset", 0);
|
|
7961
|
+
_defineProperty(this, "isLittleEndian", false);
|
|
7962
|
+
_defineProperty(this, "size", 0);
|
|
7963
|
+
_defineProperty(this, "view", new SplitDataView());
|
|
7964
|
+
_defineProperty(this, "encoder", new TextEncoder("utf-8"));
|
|
7965
|
+
this.isLittleEndian = (options === null || options === void 0 ? void 0 : options.littleEndian) || this.isLittleEndian;
|
|
7966
|
+
this.view.defaultSize = (_options$defaultSize = options === null || options === void 0 ? void 0 : options.defaultSize) !== null && _options$defaultSize !== void 0 ? _options$defaultSize : this.view.defaultSize;
|
|
7641
7967
|
}
|
|
7642
7968
|
_createClass(BufferStream, [{
|
|
7643
7969
|
key: "setEndian",
|
|
7644
7970
|
value: function setEndian(isLittle) {
|
|
7645
7971
|
this.isLittleEndian = isLittle;
|
|
7646
7972
|
}
|
|
7973
|
+
}, {
|
|
7974
|
+
key: "slice",
|
|
7975
|
+
value: function slice() {
|
|
7976
|
+
var start = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.startOffset;
|
|
7977
|
+
var end = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.endOffset;
|
|
7978
|
+
return this.view.slice(start, end);
|
|
7979
|
+
}
|
|
7980
|
+
}, {
|
|
7981
|
+
key: "getBuffer",
|
|
7982
|
+
value: function getBuffer() {
|
|
7983
|
+
var start = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
7984
|
+
var end = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.size;
|
|
7985
|
+
if (this.noCopy) {
|
|
7986
|
+
return new Uint8Array(this.slice(start, end));
|
|
7987
|
+
}
|
|
7988
|
+
return this.slice(start, end);
|
|
7989
|
+
}
|
|
7990
|
+
}, {
|
|
7991
|
+
key: "buffer",
|
|
7992
|
+
get: function get() {
|
|
7993
|
+
// console.warn("Deprecated buffer get");
|
|
7994
|
+
return this.getBuffer();
|
|
7995
|
+
}
|
|
7996
|
+
}, {
|
|
7997
|
+
key: "available",
|
|
7998
|
+
get: function get() {
|
|
7999
|
+
return this.endOffset - this.offset;
|
|
8000
|
+
}
|
|
7647
8001
|
}, {
|
|
7648
8002
|
key: "writeUint8",
|
|
7649
8003
|
value: function writeUint8(value) {
|
|
@@ -7725,7 +8079,7 @@ var BufferStream = /*#__PURE__*/function () {
|
|
|
7725
8079
|
value: function writeUTF8String(value) {
|
|
7726
8080
|
var encodedString = this.encoder.encode(value);
|
|
7727
8081
|
this.checkSize(encodedString.byteLength);
|
|
7728
|
-
|
|
8082
|
+
this.view.writeBuffer(encodedString, this.offset);
|
|
7729
8083
|
return this.increment(encodedString.byteLength);
|
|
7730
8084
|
}
|
|
7731
8085
|
}, {
|
|
@@ -7736,8 +8090,8 @@ var BufferStream = /*#__PURE__*/function () {
|
|
|
7736
8090
|
this.checkSize(len);
|
|
7737
8091
|
var startOffset = this.offset;
|
|
7738
8092
|
for (var i = 0; i < len; i++) {
|
|
7739
|
-
var
|
|
7740
|
-
this.view.setUint8(startOffset + i,
|
|
8093
|
+
var charCode = value.charCodeAt(i);
|
|
8094
|
+
this.view.setUint8(startOffset + i, charCode);
|
|
7741
8095
|
}
|
|
7742
8096
|
return this.increment(len);
|
|
7743
8097
|
}
|
|
@@ -7770,7 +8124,7 @@ var BufferStream = /*#__PURE__*/function () {
|
|
|
7770
8124
|
}, {
|
|
7771
8125
|
key: "readUint8Array",
|
|
7772
8126
|
value: function readUint8Array(length) {
|
|
7773
|
-
var arr = new Uint8Array(this.
|
|
8127
|
+
var arr = new Uint8Array(this.view.slice(this.offset, this.offset + length));
|
|
7774
8128
|
this.increment(length);
|
|
7775
8129
|
return arr;
|
|
7776
8130
|
}
|
|
@@ -7786,6 +8140,13 @@ var BufferStream = /*#__PURE__*/function () {
|
|
|
7786
8140
|
}
|
|
7787
8141
|
return arr;
|
|
7788
8142
|
}
|
|
8143
|
+
}, {
|
|
8144
|
+
key: "readInt8",
|
|
8145
|
+
value: function readInt8() {
|
|
8146
|
+
var val = this.view.getInt8(this.offset, this.isLittleEndian);
|
|
8147
|
+
this.increment(1);
|
|
8148
|
+
return val;
|
|
8149
|
+
}
|
|
7789
8150
|
}, {
|
|
7790
8151
|
key: "readInt16",
|
|
7791
8152
|
value: function readInt16() {
|
|
@@ -7820,8 +8181,8 @@ var BufferStream = /*#__PURE__*/function () {
|
|
|
7820
8181
|
var result = "";
|
|
7821
8182
|
var start = this.offset;
|
|
7822
8183
|
var end = this.offset + length;
|
|
7823
|
-
if (end >= this.
|
|
7824
|
-
end = this.
|
|
8184
|
+
if (end >= this.view.byteLength) {
|
|
8185
|
+
end = this.view.byteLength;
|
|
7825
8186
|
}
|
|
7826
8187
|
for (var i = start; i < end; ++i) {
|
|
7827
8188
|
result += String.fromCharCode(this.view.getUint8(i));
|
|
@@ -7839,10 +8200,10 @@ var BufferStream = /*#__PURE__*/function () {
|
|
|
7839
8200
|
}, {
|
|
7840
8201
|
key: "readEncodedString",
|
|
7841
8202
|
value: function readEncodedString(length) {
|
|
7842
|
-
if (this.offset + length >= this.
|
|
7843
|
-
length = this.
|
|
8203
|
+
if (this.offset + length >= this.view.byteLength) {
|
|
8204
|
+
length = this.view.byteLength - this.offset;
|
|
7844
8205
|
}
|
|
7845
|
-
var view = new DataView(this.
|
|
8206
|
+
var view = new DataView(this.slice(this.offset, this.offset + length));
|
|
7846
8207
|
var result = this.decoder.decode(view);
|
|
7847
8208
|
this.increment(length);
|
|
7848
8209
|
return result;
|
|
@@ -7859,45 +8220,21 @@ var BufferStream = /*#__PURE__*/function () {
|
|
|
7859
8220
|
}, {
|
|
7860
8221
|
key: "checkSize",
|
|
7861
8222
|
value: function checkSize(step) {
|
|
7862
|
-
|
|
7863
|
-
//throw new Error("Writing exceeded the size of buffer");
|
|
7864
|
-
//
|
|
7865
|
-
// Resize the buffer.
|
|
7866
|
-
// The idea is that when it is necessary to increase the buffer size,
|
|
7867
|
-
// there will likely be more bytes which need to be written to the
|
|
7868
|
-
// buffer in the future. Buffer allocation is costly.
|
|
7869
|
-
// So we increase the buffer size right now
|
|
7870
|
-
// by a larger amount than necessary, to reserve space for later
|
|
7871
|
-
// writes which then can be done much faster. The current size of
|
|
7872
|
-
// the buffer is the best estimate of the scale by which the size
|
|
7873
|
-
// should increase.
|
|
7874
|
-
// So approximately doubling the size of the buffer
|
|
7875
|
-
// (while ensuring it fits the new data) is a simple but effective strategy.
|
|
7876
|
-
var dstSize = this.offset + step + this.buffer.byteLength;
|
|
7877
|
-
var dst = new ArrayBuffer(dstSize);
|
|
7878
|
-
new Uint8Array(dst).set(new Uint8Array(this.buffer));
|
|
7879
|
-
this.buffer = dst;
|
|
7880
|
-
this.view = new DataView(this.buffer);
|
|
7881
|
-
}
|
|
8223
|
+
this.view.checkSize(this.offset + step);
|
|
7882
8224
|
}
|
|
8225
|
+
|
|
8226
|
+
/**
|
|
8227
|
+
* Concatenates the stream, starting from the startOffset (to allow concat
|
|
8228
|
+
* on an existing output from the beginning)
|
|
8229
|
+
*/
|
|
7883
8230
|
}, {
|
|
7884
8231
|
key: "concat",
|
|
7885
8232
|
value: function concat(stream) {
|
|
7886
|
-
|
|
7887
|
-
|
|
7888
|
-
var newbuf = new ArrayBuffer(this.offset + stream.size);
|
|
7889
|
-
var int8 = new Uint8Array(newbuf);
|
|
7890
|
-
int8.set(new Uint8Array(this.getBuffer(0, this.offset)));
|
|
7891
|
-
int8.set(new Uint8Array(stream.getBuffer(0, stream.size)), this.offset);
|
|
7892
|
-
this.buffer = newbuf;
|
|
7893
|
-
this.view = new DataView(this.buffer);
|
|
7894
|
-
} else {
|
|
7895
|
-
var _int = new Uint8Array(this.buffer);
|
|
7896
|
-
_int.set(new Uint8Array(stream.getBuffer(0, stream.size)), this.offset);
|
|
7897
|
-
}
|
|
8233
|
+
this.view.checkSize(this.size + stream.size - stream.startOffset);
|
|
8234
|
+
this.view.writeBuffer(new Uint8Array(stream.slice(stream.startOffset, stream.size)), this.offset);
|
|
7898
8235
|
this.offset += stream.size;
|
|
7899
8236
|
this.size = this.offset;
|
|
7900
|
-
return this.
|
|
8237
|
+
return this.view.availableSize;
|
|
7901
8238
|
}
|
|
7902
8239
|
}, {
|
|
7903
8240
|
key: "increment",
|
|
@@ -7908,14 +8245,23 @@ var BufferStream = /*#__PURE__*/function () {
|
|
|
7908
8245
|
}
|
|
7909
8246
|
return step;
|
|
7910
8247
|
}
|
|
8248
|
+
|
|
8249
|
+
/**
|
|
8250
|
+
* Adds the buffer to the end of the current buffers list,
|
|
8251
|
+
* updating the size etc.
|
|
8252
|
+
*
|
|
8253
|
+
* @param {*} buffer
|
|
8254
|
+
* @param {*} options.start for the start of the new buffer to use
|
|
8255
|
+
* @param {*} options.end for the end of the buffer to use
|
|
8256
|
+
* @param {*} options.transfer to transfer the buffer to be owned
|
|
8257
|
+
*/
|
|
7911
8258
|
}, {
|
|
7912
|
-
key: "
|
|
7913
|
-
value: function
|
|
7914
|
-
|
|
7915
|
-
|
|
7916
|
-
|
|
7917
|
-
|
|
7918
|
-
return this.buffer.slice(start, end);
|
|
8259
|
+
key: "addBuffer",
|
|
8260
|
+
value: function addBuffer(buffer) {
|
|
8261
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
8262
|
+
this.view.addBuffer(buffer, options);
|
|
8263
|
+
this.size = this.view.size;
|
|
8264
|
+
return this.size;
|
|
7919
8265
|
}
|
|
7920
8266
|
}, {
|
|
7921
8267
|
key: "more",
|
|
@@ -7923,10 +8269,14 @@ var BufferStream = /*#__PURE__*/function () {
|
|
|
7923
8269
|
if (this.offset + length > this.endOffset) {
|
|
7924
8270
|
throw new Error("Request more than currently allocated buffer");
|
|
7925
8271
|
}
|
|
7926
|
-
|
|
7927
|
-
|
|
7928
|
-
|
|
7929
|
-
|
|
8272
|
+
|
|
8273
|
+
// Optimize the more implementation to choose between a slice and
|
|
8274
|
+
// a sub-string reference to the original set of views.
|
|
8275
|
+
// const newBuf = new ReadBufferStream(this.buffer, null, {
|
|
8276
|
+
// start: this.offset,
|
|
8277
|
+
// stop: this.offset + length
|
|
8278
|
+
// });
|
|
8279
|
+
var newBuf = new ReadBufferStream(this.slice(this.offset, this.offset + length));
|
|
7930
8280
|
this.increment(length);
|
|
7931
8281
|
return newBuf;
|
|
7932
8282
|
}
|
|
@@ -7939,12 +8289,12 @@ var BufferStream = /*#__PURE__*/function () {
|
|
|
7939
8289
|
}, {
|
|
7940
8290
|
key: "end",
|
|
7941
8291
|
value: function end() {
|
|
7942
|
-
return this.offset >= this.
|
|
8292
|
+
return this.offset >= this.view.byteLength;
|
|
7943
8293
|
}
|
|
7944
8294
|
}, {
|
|
7945
8295
|
key: "toEnd",
|
|
7946
8296
|
value: function toEnd() {
|
|
7947
|
-
this.offset = this.
|
|
8297
|
+
this.offset = this.view.byteLength;
|
|
7948
8298
|
}
|
|
7949
8299
|
}]);
|
|
7950
8300
|
return BufferStream;
|
|
@@ -7952,6 +8302,7 @@ var BufferStream = /*#__PURE__*/function () {
|
|
|
7952
8302
|
var ReadBufferStream = /*#__PURE__*/function (_BufferStream) {
|
|
7953
8303
|
_inherits(ReadBufferStream, _BufferStream);
|
|
7954
8304
|
function ReadBufferStream(buffer, littleEndian) {
|
|
8305
|
+
var _ref, _options$start;
|
|
7955
8306
|
var _this;
|
|
7956
8307
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
7957
8308
|
start: null,
|
|
@@ -7959,13 +8310,20 @@ var ReadBufferStream = /*#__PURE__*/function (_BufferStream) {
|
|
|
7959
8310
|
noCopy: false
|
|
7960
8311
|
};
|
|
7961
8312
|
_classCallCheck(this, ReadBufferStream);
|
|
7962
|
-
_this = _callSuper(this, ReadBufferStream, [
|
|
7963
|
-
|
|
7964
|
-
|
|
8313
|
+
_this = _callSuper(this, ReadBufferStream, [{
|
|
8314
|
+
littleEndian: littleEndian
|
|
8315
|
+
}]);
|
|
7965
8316
|
_this.noCopy = options.noCopy;
|
|
8317
|
+
_this.decoder = new TextDecoder("latin1");
|
|
8318
|
+
if (buffer instanceof BufferStream) {
|
|
8319
|
+
_this.view.from(buffer.view, options);
|
|
8320
|
+
} else if (buffer) {
|
|
8321
|
+
_this.view.addBuffer(buffer);
|
|
8322
|
+
}
|
|
8323
|
+
_this.offset = (_ref = (_options$start = options.start) !== null && _options$start !== void 0 ? _options$start : buffer === null || buffer === void 0 ? void 0 : buffer.offset) !== null && _ref !== void 0 ? _ref : 0;
|
|
8324
|
+
_this.size = options.stop || (buffer === null || buffer === void 0 ? void 0 : buffer.size) || (buffer === null || buffer === void 0 ? void 0 : buffer.byteLength) || 0;
|
|
7966
8325
|
_this.startOffset = _this.offset;
|
|
7967
8326
|
_this.endOffset = _this.size;
|
|
7968
|
-
_this.decoder = new TextDecoder("latin1");
|
|
7969
8327
|
return _this;
|
|
7970
8328
|
}
|
|
7971
8329
|
_createClass(ReadBufferStream, [{
|
|
@@ -7973,18 +8331,6 @@ var ReadBufferStream = /*#__PURE__*/function (_BufferStream) {
|
|
|
7973
8331
|
value: function setDecoder(decoder) {
|
|
7974
8332
|
this.decoder = decoder;
|
|
7975
8333
|
}
|
|
7976
|
-
}, {
|
|
7977
|
-
key: "getBuffer",
|
|
7978
|
-
value: function getBuffer(start, end) {
|
|
7979
|
-
if (this.noCopy) {
|
|
7980
|
-
return new Uint8Array(this.buffer, start, end - start);
|
|
7981
|
-
}
|
|
7982
|
-
if (!start && !end) {
|
|
7983
|
-
start = 0;
|
|
7984
|
-
end = this.size;
|
|
7985
|
-
}
|
|
7986
|
-
return this.buffer.slice(start, end);
|
|
7987
|
-
}
|
|
7988
8334
|
}, {
|
|
7989
8335
|
key: "reset",
|
|
7990
8336
|
value: function reset() {
|
|
@@ -8085,10 +8431,13 @@ var DeflatedReadBufferStream = /*#__PURE__*/function (_ReadBufferStream) {
|
|
|
8085
8431
|
}(ReadBufferStream);
|
|
8086
8432
|
var WriteBufferStream = /*#__PURE__*/function (_BufferStream2) {
|
|
8087
8433
|
_inherits(WriteBufferStream, _BufferStream2);
|
|
8088
|
-
function WriteBufferStream(
|
|
8434
|
+
function WriteBufferStream(defaultSize, littleEndian) {
|
|
8089
8435
|
var _this2;
|
|
8090
8436
|
_classCallCheck(this, WriteBufferStream);
|
|
8091
|
-
_this2 = _callSuper(this, WriteBufferStream, [
|
|
8437
|
+
_this2 = _callSuper(this, WriteBufferStream, [{
|
|
8438
|
+
defaultSize: defaultSize,
|
|
8439
|
+
littleEndian: littleEndian
|
|
8440
|
+
}]);
|
|
8092
8441
|
_this2.size = 0;
|
|
8093
8442
|
return _this2;
|
|
8094
8443
|
}
|
|
@@ -9762,8 +10111,6 @@ var SequenceOfItems = /*#__PURE__*/function (_ValueRepresentation8) {
|
|
|
9762
10111
|
var undefLength = sqlength == 0xffffffff,
|
|
9763
10112
|
elements = [],
|
|
9764
10113
|
read = 0;
|
|
9765
|
-
|
|
9766
|
-
/* eslint-disable-next-line no-constant-condition */
|
|
9767
10114
|
while (true) {
|
|
9768
10115
|
var tag = Tag$1.readTag(stream),
|
|
9769
10116
|
length = null;
|