ag-psd 28.5.1 → 29.0.0

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/dist/bundle.js CHANGED
@@ -376,7 +376,7 @@ function readAbr(buffer, options) {
376
376
  }
377
377
  exports.readAbr = readAbr;
378
378
 
379
- },{"./descriptor":4,"./psdReader":12,"util":54}],2:[function(require,module,exports){
379
+ },{"./descriptor":4,"./psdReader":13,"util":55}],2:[function(require,module,exports){
380
380
  "use strict";
381
381
  var __assign = (this && this.__assign) || function () {
382
382
  __assign = Object.assign || function(t) {
@@ -3894,7 +3894,7 @@ addHandler('tsly', hasKey('transparencyShapesLayer'), function (reader, target)
3894
3894
  (0, psdWriter_1.writeZeros)(writer, 3);
3895
3895
  });
3896
3896
 
3897
- },{"./descriptor":4,"./effectsHelpers":5,"./engineData":6,"./engineData2":7,"./helpers":8,"./psdReader":12,"./psdWriter":13,"./text":14,"base64-js":18,"util":54}],3:[function(require,module,exports){
3897
+ },{"./descriptor":4,"./effectsHelpers":5,"./engineData":6,"./engineData2":7,"./helpers":8,"./psdReader":13,"./psdWriter":14,"./text":15,"base64-js":19,"util":55}],3:[function(require,module,exports){
3898
3898
  "use strict";
3899
3899
  var __assign = (this && this.__assign) || function () {
3900
3900
  __assign = Object.assign || function(t) {
@@ -3943,7 +3943,7 @@ function readCsh(buffer) {
3943
3943
  }
3944
3944
  exports.readCsh = readCsh;
3945
3945
 
3946
- },{"./additionalInfo":2,"./psdReader":12}],4:[function(require,module,exports){
3946
+ },{"./additionalInfo":2,"./psdReader":13}],4:[function(require,module,exports){
3947
3947
  "use strict";
3948
3948
  var __assign = (this && this.__assign) || function () {
3949
3949
  __assign = Object.assign || function(t) {
@@ -5983,7 +5983,7 @@ exports.presetKindType = (0, helpers_1.createEnum)('presetKindType', 'presetKind
5983
5983
  default: 'presetKindDefault',
5984
5984
  });
5985
5985
 
5986
- },{"./helpers":8,"./psdReader":12,"./psdWriter":13}],5:[function(require,module,exports){
5986
+ },{"./helpers":8,"./psdReader":13,"./psdWriter":14}],5:[function(require,module,exports){
5987
5987
  "use strict";
5988
5988
  Object.defineProperty(exports, "__esModule", { value: true });
5989
5989
  exports.writeEffects = exports.readEffects = void 0;
@@ -6293,7 +6293,7 @@ function writeEffects(writer, effects) {
6293
6293
  }
6294
6294
  exports.writeEffects = writeEffects;
6295
6295
 
6296
- },{"./helpers":8,"./psdReader":12,"./psdWriter":13}],6:[function(require,module,exports){
6296
+ },{"./helpers":8,"./psdReader":13,"./psdWriter":14}],6:[function(require,module,exports){
6297
6297
  "use strict";
6298
6298
  Object.defineProperty(exports, "__esModule", { value: true });
6299
6299
  exports.serializeEngineData = exports.parseEngineData = void 0;
@@ -7052,9 +7052,9 @@ exports.decodeEngineData2 = decodeEngineData2;
7052
7052
  },{}],8:[function(require,module,exports){
7053
7053
  "use strict";
7054
7054
  Object.defineProperty(exports, "__esModule", { value: true });
7055
- exports.initializeCanvas = exports.createImageData = exports.createCanvasFromData = exports.createCanvas = exports.writeDataZipWithoutPrediction = exports.writeDataRLE = exports.writeDataRaw = exports.decodeBitmap = exports.imageDataToCanvas = exports.resetImageData = exports.hasAlpha = exports.clamp = exports.offsetForChannel = exports.Compression = exports.ChannelID = exports.MaskParams = exports.LayerMaskFlags = exports.ColorSpace = exports.createEnum = exports.revMap = exports.largeAdditionalInfoKeys = exports.layerColors = exports.toBlendMode = exports.fromBlendMode = exports.RAW_IMAGE_DATA = exports.MOCK_HANDLERS = void 0;
7056
- var base64_js_1 = require("base64-js");
7055
+ exports.initializeCanvas = exports.createImageData = exports.createCanvas = exports.createCanvasFromData = exports.writeDataZipWithoutPrediction = exports.writeDataRLE = exports.writeDataRaw = exports.decodeBitmap = exports.imageDataToCanvas = exports.resetImageData = exports.hasAlpha = exports.clamp = exports.offsetForChannel = exports.Compression = exports.ChannelID = exports.MaskParams = exports.LayerMaskFlags = exports.ColorSpace = exports.createEnum = exports.revMap = exports.largeAdditionalInfoKeys = exports.layerColors = exports.toBlendMode = exports.fromBlendMode = exports.RAW_IMAGE_DATA = exports.MOCK_HANDLERS = void 0;
7057
7056
  var pako_1 = require("pako");
7057
+ var jpeg_1 = require("./jpeg");
7058
7058
  exports.MOCK_HANDLERS = false;
7059
7059
  exports.RAW_IMAGE_DATA = false;
7060
7060
  exports.fromBlendMode = {};
@@ -7376,14 +7376,25 @@ function writeDataZipWithoutPrediction(_a, offsets) {
7376
7376
  }
7377
7377
  }
7378
7378
  exports.writeDataZipWithoutPrediction = writeDataZipWithoutPrediction;
7379
+ function createCanvasFromData(data) {
7380
+ var canvas = (0, exports.createCanvas)(100, 100);
7381
+ try {
7382
+ var context_1 = canvas.getContext('2d');
7383
+ var imageData = (0, jpeg_1.decodeJpeg)(data, function (w, h) { return context_1.createImageData(w, h); });
7384
+ canvas.width = imageData.width;
7385
+ canvas.height = imageData.height;
7386
+ context_1.putImageData(imageData, 0, 0);
7387
+ }
7388
+ catch (e) {
7389
+ console.error('JPEG decompression error', e.message);
7390
+ }
7391
+ return canvas;
7392
+ }
7393
+ exports.createCanvasFromData = createCanvasFromData;
7379
7394
  var createCanvas = function () {
7380
7395
  throw new Error('Canvas not initialized, use initializeCanvas method to set up createCanvas method');
7381
7396
  };
7382
7397
  exports.createCanvas = createCanvas;
7383
- var createCanvasFromData = function () {
7384
- throw new Error('Canvas not initialized, use initializeCanvas method to set up createCanvasFromData method');
7385
- };
7386
- exports.createCanvasFromData = createCanvasFromData;
7387
7398
  var tempCanvas = undefined;
7388
7399
  var createImageData = function (width, height) {
7389
7400
  if (!tempCanvas)
@@ -7398,24 +7409,14 @@ if (typeof document !== 'undefined') {
7398
7409
  canvas.height = height;
7399
7410
  return canvas;
7400
7411
  };
7401
- exports.createCanvasFromData = function (data) {
7402
- var image = new Image();
7403
- image.src = 'data:image/jpeg;base64,' + (0, base64_js_1.fromByteArray)(data);
7404
- var canvas = document.createElement('canvas');
7405
- canvas.width = image.width;
7406
- canvas.height = image.height;
7407
- canvas.getContext('2d').drawImage(image, 0, 0);
7408
- return canvas;
7409
- };
7410
7412
  }
7411
- function initializeCanvas(createCanvasMethod, createCanvasFromDataMethod, createImageDataMethod) {
7413
+ function initializeCanvas(createCanvasMethod, createImageDataMethod) {
7412
7414
  exports.createCanvas = createCanvasMethod;
7413
- exports.createCanvasFromData = createCanvasFromDataMethod || exports.createCanvasFromData;
7414
7415
  exports.createImageData = createImageDataMethod || exports.createImageData;
7415
7416
  }
7416
7417
  exports.initializeCanvas = initializeCanvas;
7417
7418
 
7418
- },{"base64-js":18,"pako":35}],9:[function(require,module,exports){
7419
+ },{"./jpeg":11,"pako":36}],9:[function(require,module,exports){
7419
7420
  "use strict";
7420
7421
  var __assign = (this && this.__assign) || function () {
7421
7422
  __assign = Object.assign || function(t) {
@@ -8496,7 +8497,7 @@ target) { return target._ir4002 !== undefined; }, function (reader, target, left
8496
8497
  (0, psdWriter_1.writeBytes)(writer, target._ir4002);
8497
8498
  });
8498
8499
 
8499
- },{"./descriptor":4,"./helpers":8,"./psdReader":12,"./psdWriter":13,"./utf8":15,"base64-js":18}],10:[function(require,module,exports){
8500
+ },{"./descriptor":4,"./helpers":8,"./psdReader":13,"./psdWriter":14,"./utf8":16,"base64-js":19}],10:[function(require,module,exports){
8500
8501
  (function (Buffer){(function (){
8501
8502
  "use strict";
8502
8503
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
@@ -8552,7 +8553,1030 @@ function writePsdBuffer(psd, options) {
8552
8553
  exports.writePsdBuffer = writePsdBuffer;
8553
8554
 
8554
8555
  }).call(this)}).call(this,require("buffer").Buffer)
8555
- },{"./abr":1,"./csh":3,"./helpers":8,"./psd":11,"./psdReader":12,"./psdWriter":13,"base64-js":18,"buffer":19}],11:[function(require,module,exports){
8556
+ },{"./abr":1,"./csh":3,"./helpers":8,"./psd":12,"./psdReader":13,"./psdWriter":14,"base64-js":19,"buffer":20}],11:[function(require,module,exports){
8557
+ "use strict";
8558
+ // based on https://github.com/jpeg-js/jpeg-js
8559
+ /*
8560
+ Copyright 2011 notmasteryet
8561
+
8562
+ Licensed under the Apache License, Version 2.0 (the "License");
8563
+ you may not use this file except in compliance with the License.
8564
+ You may obtain a copy of the License at
8565
+
8566
+ http://www.apache.org/licenses/LICENSE-2.0
8567
+
8568
+ Unless required by applicable law or agreed to in writing, software
8569
+ distributed under the License is distributed on an "AS IS" BASIS,
8570
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8571
+ See the License for the specific language governing permissions and
8572
+ limitations under the License.
8573
+ */
8574
+ Object.defineProperty(exports, "__esModule", { value: true });
8575
+ exports.decodeJpeg = void 0;
8576
+ var dctZigZag = new Int32Array([
8577
+ 0,
8578
+ 1, 8,
8579
+ 16, 9, 2,
8580
+ 3, 10, 17, 24,
8581
+ 32, 25, 18, 11, 4,
8582
+ 5, 12, 19, 26, 33, 40,
8583
+ 48, 41, 34, 27, 20, 13, 6,
8584
+ 7, 14, 21, 28, 35, 42, 49, 56,
8585
+ 57, 50, 43, 36, 29, 22, 15,
8586
+ 23, 30, 37, 44, 51, 58,
8587
+ 59, 52, 45, 38, 31,
8588
+ 39, 46, 53, 60,
8589
+ 61, 54, 47,
8590
+ 55, 62,
8591
+ 63
8592
+ ]);
8593
+ var dctCos1 = 4017; // cos(pi/16)
8594
+ var dctSin1 = 799; // sin(pi/16)
8595
+ var dctCos3 = 3406; // cos(3*pi/16)
8596
+ var dctSin3 = 2276; // sin(3*pi/16)
8597
+ var dctCos6 = 1567; // cos(6*pi/16)
8598
+ var dctSin6 = 3784; // sin(6*pi/16)
8599
+ var dctSqrt2 = 5793; // sqrt(2)
8600
+ var dctSqrt1d2 = 2896; // sqrt(2) / 2
8601
+ var maxResolutionInMP = 100; // Don't decode more than 100 megapixels
8602
+ var maxMemoryUsageBytes = 64 * 1024 * 1024; // Don't decode if memory footprint is more than 64MB
8603
+ var totalBytesAllocated = 0; // avoid unexpected OOMs from untrusted content.
8604
+ function requestMemoryAllocation(increaseAmount) {
8605
+ var totalMemoryImpactBytes = totalBytesAllocated + increaseAmount;
8606
+ if (totalMemoryImpactBytes > maxMemoryUsageBytes) {
8607
+ var exceededAmount = Math.ceil((totalMemoryImpactBytes - maxMemoryUsageBytes) / 1024 / 1024);
8608
+ throw new Error("Max memory limit exceeded by at least ".concat(exceededAmount, "MB"));
8609
+ }
8610
+ totalBytesAllocated = totalMemoryImpactBytes;
8611
+ }
8612
+ function buildHuffmanTable(codeLengths, values) {
8613
+ var length = 16;
8614
+ while (length > 0 && !codeLengths[length - 1])
8615
+ length--;
8616
+ var code = [{ children: [], index: 0 }];
8617
+ var k = 0;
8618
+ var p = code[0];
8619
+ for (var i = 0; i < length; i++) {
8620
+ for (var j = 0; j < codeLengths[i]; j++) {
8621
+ p = code.pop();
8622
+ p.children[p.index] = values[k];
8623
+ while (p.index > 0) {
8624
+ if (code.length === 0)
8625
+ throw new Error('Could not recreate Huffman Table');
8626
+ p = code.pop();
8627
+ }
8628
+ p.index++;
8629
+ code.push(p);
8630
+ while (code.length <= i) {
8631
+ var q = { children: [], index: 0 };
8632
+ code.push(q);
8633
+ p.children[p.index] = q.children;
8634
+ p = q;
8635
+ }
8636
+ k++;
8637
+ }
8638
+ if (i + 1 < length) {
8639
+ // p here points to last code
8640
+ var q = { children: [], index: 0 };
8641
+ code.push(q);
8642
+ p.children[p.index] = q.children;
8643
+ p = q;
8644
+ }
8645
+ }
8646
+ return code[0].children;
8647
+ }
8648
+ function decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successivePrev, successive) {
8649
+ var mcusPerLine = frame.mcusPerLine;
8650
+ var progressive = frame.progressive;
8651
+ var startOffset = offset;
8652
+ var bitsData = 0;
8653
+ var bitsCount = 0;
8654
+ function readBit() {
8655
+ if (bitsCount > 0) {
8656
+ bitsCount--;
8657
+ return (bitsData >> bitsCount) & 1;
8658
+ }
8659
+ bitsData = data[offset++];
8660
+ if (bitsData == 0xFF) {
8661
+ var nextByte = data[offset++];
8662
+ if (nextByte)
8663
+ throw new Error("unexpected marker: ".concat(((bitsData << 8) | nextByte).toString(16)));
8664
+ // unstuff 0
8665
+ }
8666
+ bitsCount = 7;
8667
+ return bitsData >>> 7;
8668
+ }
8669
+ function decodeHuffman(tree) {
8670
+ var node = tree;
8671
+ while (true) {
8672
+ node = node[readBit()];
8673
+ if (typeof node === 'number')
8674
+ return node;
8675
+ if (node === undefined)
8676
+ throw new Error('invalid huffman sequence');
8677
+ }
8678
+ }
8679
+ function receive(length) {
8680
+ var n = 0;
8681
+ while (length > 0) {
8682
+ n = (n << 1) | readBit();
8683
+ length--;
8684
+ }
8685
+ return n;
8686
+ }
8687
+ function receiveAndExtend(length) {
8688
+ var n = receive(length);
8689
+ if (n >= 1 << (length - 1))
8690
+ return n;
8691
+ return n + (-1 << length) + 1;
8692
+ }
8693
+ function decodeBaseline(component, zz) {
8694
+ var t = decodeHuffman(component.huffmanTableDC);
8695
+ var diff = t === 0 ? 0 : receiveAndExtend(t);
8696
+ zz[0] = (component.pred += diff);
8697
+ var k = 1;
8698
+ while (k < 64) {
8699
+ var rs = decodeHuffman(component.huffmanTableAC);
8700
+ var s = rs & 15;
8701
+ var r = rs >> 4;
8702
+ if (s === 0) {
8703
+ if (r < 15)
8704
+ break;
8705
+ k += 16;
8706
+ continue;
8707
+ }
8708
+ k += r;
8709
+ var z = dctZigZag[k];
8710
+ zz[z] = receiveAndExtend(s);
8711
+ k++;
8712
+ }
8713
+ }
8714
+ function decodeDCFirst(component, zz) {
8715
+ var t = decodeHuffman(component.huffmanTableDC);
8716
+ var diff = t === 0 ? 0 : (receiveAndExtend(t) << successive);
8717
+ zz[0] = (component.pred += diff);
8718
+ }
8719
+ function decodeDCSuccessive(_component, zz) {
8720
+ zz[0] |= readBit() << successive;
8721
+ }
8722
+ var eobrun = 0;
8723
+ function decodeACFirst(component, zz) {
8724
+ if (eobrun > 0) {
8725
+ eobrun--;
8726
+ return;
8727
+ }
8728
+ var k = spectralStart, e = spectralEnd;
8729
+ while (k <= e) {
8730
+ var rs = decodeHuffman(component.huffmanTableAC);
8731
+ var s = rs & 15;
8732
+ var r = rs >> 4;
8733
+ if (s === 0) {
8734
+ if (r < 15) {
8735
+ eobrun = receive(r) + (1 << r) - 1;
8736
+ break;
8737
+ }
8738
+ k += 16;
8739
+ continue;
8740
+ }
8741
+ k += r;
8742
+ var z = dctZigZag[k];
8743
+ zz[z] = receiveAndExtend(s) * (1 << successive);
8744
+ k++;
8745
+ }
8746
+ }
8747
+ var successiveACState = 0;
8748
+ var successiveACNextValue = 0;
8749
+ function decodeACSuccessive(component, zz) {
8750
+ var k = spectralStart;
8751
+ var e = spectralEnd;
8752
+ var r = 0;
8753
+ while (k <= e) {
8754
+ var z = dctZigZag[k];
8755
+ var direction = zz[z] < 0 ? -1 : 1;
8756
+ switch (successiveACState) {
8757
+ case 0: // initial state
8758
+ var rs = decodeHuffman(component.huffmanTableAC);
8759
+ var s = rs & 15;
8760
+ r = rs >> 4; // this was new variable in old code
8761
+ if (s === 0) {
8762
+ if (r < 15) {
8763
+ eobrun = receive(r) + (1 << r);
8764
+ successiveACState = 4;
8765
+ }
8766
+ else {
8767
+ r = 16;
8768
+ successiveACState = 1;
8769
+ }
8770
+ }
8771
+ else {
8772
+ if (s !== 1)
8773
+ throw new Error('invalid ACn encoding');
8774
+ successiveACNextValue = receiveAndExtend(s);
8775
+ successiveACState = r ? 2 : 3;
8776
+ }
8777
+ continue;
8778
+ case 1: // skipping r zero items
8779
+ case 2:
8780
+ if (zz[z]) {
8781
+ zz[z] += (readBit() << successive) * direction;
8782
+ }
8783
+ else {
8784
+ r--;
8785
+ if (r === 0)
8786
+ successiveACState = successiveACState == 2 ? 3 : 0;
8787
+ }
8788
+ break;
8789
+ case 3: // set value for a zero item
8790
+ if (zz[z]) {
8791
+ zz[z] += (readBit() << successive) * direction;
8792
+ }
8793
+ else {
8794
+ zz[z] = successiveACNextValue << successive;
8795
+ successiveACState = 0;
8796
+ }
8797
+ break;
8798
+ case 4: // eob
8799
+ if (zz[z]) {
8800
+ zz[z] += (readBit() << successive) * direction;
8801
+ }
8802
+ break;
8803
+ }
8804
+ k++;
8805
+ }
8806
+ if (successiveACState === 4) {
8807
+ eobrun--;
8808
+ if (eobrun === 0)
8809
+ successiveACState = 0;
8810
+ }
8811
+ }
8812
+ function decodeMcu(component, decode, mcu, row, col) {
8813
+ var mcuRow = (mcu / mcusPerLine) | 0;
8814
+ var mcuCol = mcu % mcusPerLine;
8815
+ var blockRow = mcuRow * component.v + row;
8816
+ var blockCol = mcuCol * component.h + col;
8817
+ // If the block is missing, just skip it.
8818
+ if (component.blocks[blockRow] === undefined)
8819
+ return;
8820
+ decode(component, component.blocks[blockRow][blockCol]);
8821
+ }
8822
+ function decodeBlock(component, decode, mcu) {
8823
+ var blockRow = (mcu / component.blocksPerLine) | 0;
8824
+ var blockCol = mcu % component.blocksPerLine;
8825
+ // If the block is missing, just skip it.
8826
+ if (component.blocks[blockRow] === undefined)
8827
+ return;
8828
+ decode(component, component.blocks[blockRow][blockCol]);
8829
+ }
8830
+ var componentsLength = components.length;
8831
+ var component;
8832
+ var decodeFn;
8833
+ if (progressive) {
8834
+ if (spectralStart === 0) {
8835
+ decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
8836
+ }
8837
+ else {
8838
+ decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
8839
+ }
8840
+ }
8841
+ else {
8842
+ decodeFn = decodeBaseline;
8843
+ }
8844
+ var mcu = 0;
8845
+ var mcuExpected;
8846
+ if (componentsLength == 1) {
8847
+ mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn;
8848
+ }
8849
+ else {
8850
+ mcuExpected = mcusPerLine * frame.mcusPerColumn;
8851
+ }
8852
+ if (!resetInterval)
8853
+ resetInterval = mcuExpected;
8854
+ var h;
8855
+ var v;
8856
+ var marker;
8857
+ while (mcu < mcuExpected) {
8858
+ // reset interval stuff
8859
+ for (var i = 0; i < componentsLength; i++)
8860
+ components[i].pred = 0;
8861
+ eobrun = 0;
8862
+ if (componentsLength == 1) {
8863
+ component = components[0];
8864
+ for (var n = 0; n < resetInterval; n++) {
8865
+ decodeBlock(component, decodeFn, mcu);
8866
+ mcu++;
8867
+ }
8868
+ }
8869
+ else {
8870
+ for (var n = 0; n < resetInterval; n++) {
8871
+ for (var i = 0; i < componentsLength; i++) {
8872
+ component = components[i];
8873
+ h = component.h;
8874
+ v = component.v;
8875
+ for (var j = 0; j < v; j++) {
8876
+ for (var k = 0; k < h; k++) {
8877
+ decodeMcu(component, decodeFn, mcu, j, k);
8878
+ }
8879
+ }
8880
+ }
8881
+ mcu++;
8882
+ // If we've reached our expected MCU's, stop decoding
8883
+ if (mcu === mcuExpected)
8884
+ break;
8885
+ }
8886
+ }
8887
+ if (mcu === mcuExpected) {
8888
+ // Skip trailing bytes at the end of the scan - until we reach the next marker
8889
+ do {
8890
+ if (data[offset] === 0xFF) {
8891
+ if (data[offset + 1] !== 0x00) {
8892
+ break;
8893
+ }
8894
+ }
8895
+ offset += 1;
8896
+ } while (offset < data.length - 2);
8897
+ }
8898
+ // find marker
8899
+ bitsCount = 0;
8900
+ marker = (data[offset] << 8) | data[offset + 1];
8901
+ if (marker < 0xFF00)
8902
+ throw new Error('marker was not found');
8903
+ if (marker >= 0xFFD0 && marker <= 0xFFD7) { // RSTx
8904
+ offset += 2;
8905
+ }
8906
+ else {
8907
+ break;
8908
+ }
8909
+ }
8910
+ return offset - startOffset;
8911
+ }
8912
+ function buildComponentData(component) {
8913
+ var lines = [];
8914
+ var blocksPerLine = component.blocksPerLine;
8915
+ var blocksPerColumn = component.blocksPerColumn;
8916
+ var samplesPerLine = blocksPerLine << 3;
8917
+ // Only 1 used per invocation of this function and garbage collected after invocation, so no need to account for its memory footprint.
8918
+ var R = new Int32Array(64);
8919
+ var r = new Uint8Array(64);
8920
+ // A port of poppler's IDCT method which in turn is taken from:
8921
+ // Christoph Loeffler, Adriaan Ligtenberg, George S. Moschytz,
8922
+ // "Practical Fast 1-D DCT Algorithms with 11 Multiplications",
8923
+ // IEEE Intl. Conf. on Acoustics, Speech & Signal Processing, 1989,
8924
+ // 988-991.
8925
+ function quantizeAndInverse(zz, dataOut, dataIn) {
8926
+ var qt = component.quantizationTable;
8927
+ var p = dataIn;
8928
+ // dequant
8929
+ for (var i = 0; i < 64; i++) {
8930
+ p[i] = zz[i] * qt[i];
8931
+ }
8932
+ // inverse DCT on rows
8933
+ for (var i = 0; i < 8; ++i) {
8934
+ var row = 8 * i;
8935
+ // check for all-zero AC coefficients
8936
+ if (p[1 + row] == 0 && p[2 + row] == 0 && p[3 + row] == 0 &&
8937
+ p[4 + row] == 0 && p[5 + row] == 0 && p[6 + row] == 0 &&
8938
+ p[7 + row] == 0) {
8939
+ var t_1 = (dctSqrt2 * p[0 + row] + 512) >> 10;
8940
+ p[0 + row] = t_1;
8941
+ p[1 + row] = t_1;
8942
+ p[2 + row] = t_1;
8943
+ p[3 + row] = t_1;
8944
+ p[4 + row] = t_1;
8945
+ p[5 + row] = t_1;
8946
+ p[6 + row] = t_1;
8947
+ p[7 + row] = t_1;
8948
+ continue;
8949
+ }
8950
+ // stage 4
8951
+ var v0 = (dctSqrt2 * p[0 + row] + 128) >> 8;
8952
+ var v1 = (dctSqrt2 * p[4 + row] + 128) >> 8;
8953
+ var v2 = p[2 + row];
8954
+ var v3 = p[6 + row];
8955
+ var v4 = (dctSqrt1d2 * (p[1 + row] - p[7 + row]) + 128) >> 8;
8956
+ var v7 = (dctSqrt1d2 * (p[1 + row] + p[7 + row]) + 128) >> 8;
8957
+ var v5 = p[3 + row] << 4;
8958
+ var v6 = p[5 + row] << 4;
8959
+ // stage 3
8960
+ var t = (v0 - v1 + 1) >> 1;
8961
+ v0 = (v0 + v1 + 1) >> 1;
8962
+ v1 = t;
8963
+ t = (v2 * dctSin6 + v3 * dctCos6 + 128) >> 8;
8964
+ v2 = (v2 * dctCos6 - v3 * dctSin6 + 128) >> 8;
8965
+ v3 = t;
8966
+ t = (v4 - v6 + 1) >> 1;
8967
+ v4 = (v4 + v6 + 1) >> 1;
8968
+ v6 = t;
8969
+ t = (v7 + v5 + 1) >> 1;
8970
+ v5 = (v7 - v5 + 1) >> 1;
8971
+ v7 = t;
8972
+ // stage 2
8973
+ t = (v0 - v3 + 1) >> 1;
8974
+ v0 = (v0 + v3 + 1) >> 1;
8975
+ v3 = t;
8976
+ t = (v1 - v2 + 1) >> 1;
8977
+ v1 = (v1 + v2 + 1) >> 1;
8978
+ v2 = t;
8979
+ t = (v4 * dctSin3 + v7 * dctCos3 + 2048) >> 12;
8980
+ v4 = (v4 * dctCos3 - v7 * dctSin3 + 2048) >> 12;
8981
+ v7 = t;
8982
+ t = (v5 * dctSin1 + v6 * dctCos1 + 2048) >> 12;
8983
+ v5 = (v5 * dctCos1 - v6 * dctSin1 + 2048) >> 12;
8984
+ v6 = t;
8985
+ // stage 1
8986
+ p[0 + row] = v0 + v7;
8987
+ p[7 + row] = v0 - v7;
8988
+ p[1 + row] = v1 + v6;
8989
+ p[6 + row] = v1 - v6;
8990
+ p[2 + row] = v2 + v5;
8991
+ p[5 + row] = v2 - v5;
8992
+ p[3 + row] = v3 + v4;
8993
+ p[4 + row] = v3 - v4;
8994
+ }
8995
+ // inverse DCT on columns
8996
+ for (var i = 0; i < 8; ++i) {
8997
+ var col = i;
8998
+ // check for all-zero AC coefficients
8999
+ if (p[1 * 8 + col] == 0 && p[2 * 8 + col] == 0 && p[3 * 8 + col] == 0 &&
9000
+ p[4 * 8 + col] == 0 && p[5 * 8 + col] == 0 && p[6 * 8 + col] == 0 &&
9001
+ p[7 * 8 + col] == 0) {
9002
+ var t_2 = (dctSqrt2 * dataIn[i + 0] + 8192) >> 14;
9003
+ p[0 * 8 + col] = t_2;
9004
+ p[1 * 8 + col] = t_2;
9005
+ p[2 * 8 + col] = t_2;
9006
+ p[3 * 8 + col] = t_2;
9007
+ p[4 * 8 + col] = t_2;
9008
+ p[5 * 8 + col] = t_2;
9009
+ p[6 * 8 + col] = t_2;
9010
+ p[7 * 8 + col] = t_2;
9011
+ continue;
9012
+ }
9013
+ // stage 4
9014
+ var v0 = (dctSqrt2 * p[0 * 8 + col] + 2048) >> 12;
9015
+ var v1 = (dctSqrt2 * p[4 * 8 + col] + 2048) >> 12;
9016
+ var v2 = p[2 * 8 + col];
9017
+ var v3 = p[6 * 8 + col];
9018
+ var v4 = (dctSqrt1d2 * (p[1 * 8 + col] - p[7 * 8 + col]) + 2048) >> 12;
9019
+ var v7 = (dctSqrt1d2 * (p[1 * 8 + col] + p[7 * 8 + col]) + 2048) >> 12;
9020
+ var v5 = p[3 * 8 + col];
9021
+ var v6 = p[5 * 8 + col];
9022
+ // stage 3
9023
+ var t = (v0 - v1 + 1) >> 1;
9024
+ v0 = (v0 + v1 + 1) >> 1;
9025
+ v1 = t;
9026
+ t = (v2 * dctSin6 + v3 * dctCos6 + 2048) >> 12;
9027
+ v2 = (v2 * dctCos6 - v3 * dctSin6 + 2048) >> 12;
9028
+ v3 = t;
9029
+ t = (v4 - v6 + 1) >> 1;
9030
+ v4 = (v4 + v6 + 1) >> 1;
9031
+ v6 = t;
9032
+ t = (v7 + v5 + 1) >> 1;
9033
+ v5 = (v7 - v5 + 1) >> 1;
9034
+ v7 = t;
9035
+ // stage 2
9036
+ t = (v0 - v3 + 1) >> 1;
9037
+ v0 = (v0 + v3 + 1) >> 1;
9038
+ v3 = t;
9039
+ t = (v1 - v2 + 1) >> 1;
9040
+ v1 = (v1 + v2 + 1) >> 1;
9041
+ v2 = t;
9042
+ t = (v4 * dctSin3 + v7 * dctCos3 + 2048) >> 12;
9043
+ v4 = (v4 * dctCos3 - v7 * dctSin3 + 2048) >> 12;
9044
+ v7 = t;
9045
+ t = (v5 * dctSin1 + v6 * dctCos1 + 2048) >> 12;
9046
+ v5 = (v5 * dctCos1 - v6 * dctSin1 + 2048) >> 12;
9047
+ v6 = t;
9048
+ // stage 1
9049
+ p[0 * 8 + col] = v0 + v7;
9050
+ p[7 * 8 + col] = v0 - v7;
9051
+ p[1 * 8 + col] = v1 + v6;
9052
+ p[6 * 8 + col] = v1 - v6;
9053
+ p[2 * 8 + col] = v2 + v5;
9054
+ p[5 * 8 + col] = v2 - v5;
9055
+ p[3 * 8 + col] = v3 + v4;
9056
+ p[4 * 8 + col] = v3 - v4;
9057
+ }
9058
+ // convert to 8-bit integers
9059
+ for (var i = 0; i < 64; ++i) {
9060
+ var sample = 128 + ((p[i] + 8) >> 4);
9061
+ dataOut[i] = sample < 0 ? 0 : sample > 0xFF ? 0xFF : sample;
9062
+ }
9063
+ }
9064
+ requestMemoryAllocation(samplesPerLine * blocksPerColumn * 8);
9065
+ for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
9066
+ var scanLine = blockRow << 3;
9067
+ for (var i = 0; i < 8; i++)
9068
+ lines.push(new Uint8Array(samplesPerLine));
9069
+ for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {
9070
+ quantizeAndInverse(component.blocks[blockRow][blockCol], r, R);
9071
+ var offset = 0;
9072
+ var sample = blockCol << 3;
9073
+ for (var j = 0; j < 8; j++) {
9074
+ var line = lines[scanLine + j];
9075
+ for (var i = 0; i < 8; i++)
9076
+ line[sample + i] = r[offset++];
9077
+ }
9078
+ }
9079
+ }
9080
+ return lines;
9081
+ }
9082
+ function clampTo8bit(a) {
9083
+ return a < 0 ? 0 : a > 255 ? 255 : a;
9084
+ }
9085
+ function parse(data) {
9086
+ var self = {
9087
+ width: 0,
9088
+ height: 0,
9089
+ comments: [],
9090
+ adobe: undefined,
9091
+ components: [],
9092
+ exifBuffer: undefined,
9093
+ jfif: undefined,
9094
+ };
9095
+ var maxResolutionInPixels = maxResolutionInMP * 1000 * 1000;
9096
+ var offset = 0;
9097
+ function readUint16() {
9098
+ var value = (data[offset] << 8) | data[offset + 1];
9099
+ offset += 2;
9100
+ return value;
9101
+ }
9102
+ function readDataBlock() {
9103
+ var length = readUint16();
9104
+ var array = data.subarray(offset, offset + length - 2);
9105
+ offset += array.length;
9106
+ return array;
9107
+ }
9108
+ function prepareComponents(frame) {
9109
+ var maxH = 0, maxV = 0;
9110
+ for (var componentId in frame.components) {
9111
+ if (frame.components.hasOwnProperty(componentId)) {
9112
+ var component = frame.components[componentId];
9113
+ if (maxH < component.h)
9114
+ maxH = component.h;
9115
+ if (maxV < component.v)
9116
+ maxV = component.v;
9117
+ }
9118
+ }
9119
+ var mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / maxH);
9120
+ var mcusPerColumn = Math.ceil(frame.scanLines / 8 / maxV);
9121
+ for (var componentId in frame.components) {
9122
+ if (frame.components.hasOwnProperty(componentId)) {
9123
+ var component = frame.components[componentId];
9124
+ var blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / maxH);
9125
+ var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / maxV);
9126
+ var blocksPerLineForMcu = mcusPerLine * component.h;
9127
+ var blocksPerColumnForMcu = mcusPerColumn * component.v;
9128
+ var blocksToAllocate = blocksPerColumnForMcu * blocksPerLineForMcu;
9129
+ var blocks = [];
9130
+ // Each block is a Int32Array of length 64 (4 x 64 = 256 bytes)
9131
+ requestMemoryAllocation(blocksToAllocate * 256);
9132
+ for (var i = 0; i < blocksPerColumnForMcu; i++) {
9133
+ var row = [];
9134
+ for (var j = 0; j < blocksPerLineForMcu; j++) {
9135
+ row.push(new Int32Array(64));
9136
+ }
9137
+ blocks.push(row);
9138
+ }
9139
+ component.blocksPerLine = blocksPerLine;
9140
+ component.blocksPerColumn = blocksPerColumn;
9141
+ component.blocks = blocks;
9142
+ }
9143
+ }
9144
+ frame.maxH = maxH;
9145
+ frame.maxV = maxV;
9146
+ frame.mcusPerLine = mcusPerLine;
9147
+ frame.mcusPerColumn = mcusPerColumn;
9148
+ }
9149
+ var jfif = null;
9150
+ var adobe = null;
9151
+ var frame = undefined;
9152
+ var resetInterval = 0;
9153
+ var quantizationTables = [];
9154
+ var frames = [];
9155
+ var huffmanTablesAC = [];
9156
+ var huffmanTablesDC = [];
9157
+ var fileMarker = readUint16();
9158
+ var malformedDataOffset = -1;
9159
+ if (fileMarker != 0xFFD8) { // SOI (Start of Image)
9160
+ throw new Error('SOI not found');
9161
+ }
9162
+ fileMarker = readUint16();
9163
+ while (fileMarker != 0xFFD9) { // EOI (End of image)
9164
+ switch (fileMarker) {
9165
+ case 0xFF00: break;
9166
+ case 0xFFE0: // APP0 (Application Specific)
9167
+ case 0xFFE1: // APP1
9168
+ case 0xFFE2: // APP2
9169
+ case 0xFFE3: // APP3
9170
+ case 0xFFE4: // APP4
9171
+ case 0xFFE5: // APP5
9172
+ case 0xFFE6: // APP6
9173
+ case 0xFFE7: // APP7
9174
+ case 0xFFE8: // APP8
9175
+ case 0xFFE9: // APP9
9176
+ case 0xFFEA: // APP10
9177
+ case 0xFFEB: // APP11
9178
+ case 0xFFEC: // APP12
9179
+ case 0xFFED: // APP13
9180
+ case 0xFFEE: // APP14
9181
+ case 0xFFEF: // APP15
9182
+ case 0xFFFE: { // COM (Comment)
9183
+ var appData = readDataBlock();
9184
+ if (fileMarker === 0xFFFE) {
9185
+ var comment = '';
9186
+ for (var ii = 0; ii < appData.byteLength; ii++) {
9187
+ comment += String.fromCharCode(appData[ii]);
9188
+ }
9189
+ self.comments.push(comment);
9190
+ }
9191
+ if (fileMarker === 0xFFE0) {
9192
+ if (appData[0] === 0x4A && appData[1] === 0x46 && appData[2] === 0x49 &&
9193
+ appData[3] === 0x46 && appData[4] === 0) { // 'JFIF\x00'
9194
+ jfif = {
9195
+ version: { major: appData[5], minor: appData[6] },
9196
+ densityUnits: appData[7],
9197
+ xDensity: (appData[8] << 8) | appData[9],
9198
+ yDensity: (appData[10] << 8) | appData[11],
9199
+ thumbWidth: appData[12],
9200
+ thumbHeight: appData[13],
9201
+ thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])
9202
+ };
9203
+ }
9204
+ }
9205
+ // TODO APP1 - Exif
9206
+ if (fileMarker === 0xFFE1) {
9207
+ if (appData[0] === 0x45 &&
9208
+ appData[1] === 0x78 &&
9209
+ appData[2] === 0x69 &&
9210
+ appData[3] === 0x66 &&
9211
+ appData[4] === 0) { // 'EXIF\x00'
9212
+ self.exifBuffer = appData.subarray(5, appData.length);
9213
+ }
9214
+ }
9215
+ if (fileMarker === 0xFFEE) {
9216
+ if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6F &&
9217
+ appData[3] === 0x62 && appData[4] === 0x65 && appData[5] === 0) { // 'Adobe\x00'
9218
+ adobe = {
9219
+ version: appData[6],
9220
+ flags0: (appData[7] << 8) | appData[8],
9221
+ flags1: (appData[9] << 8) | appData[10],
9222
+ transformCode: appData[11]
9223
+ };
9224
+ }
9225
+ }
9226
+ break;
9227
+ }
9228
+ case 0xFFDB: { // DQT (Define Quantization Tables)
9229
+ var quantizationTablesLength = readUint16();
9230
+ var quantizationTablesEnd = quantizationTablesLength + offset - 2;
9231
+ while (offset < quantizationTablesEnd) {
9232
+ var quantizationTableSpec = data[offset++];
9233
+ requestMemoryAllocation(64 * 4);
9234
+ var tableData = new Int32Array(64);
9235
+ if ((quantizationTableSpec >> 4) === 0) { // 8 bit values
9236
+ for (var j = 0; j < 64; j++) {
9237
+ var z = dctZigZag[j];
9238
+ tableData[z] = data[offset++];
9239
+ }
9240
+ }
9241
+ else if ((quantizationTableSpec >> 4) === 1) { //16 bit
9242
+ for (var j = 0; j < 64; j++) {
9243
+ var z = dctZigZag[j];
9244
+ tableData[z] = readUint16();
9245
+ }
9246
+ }
9247
+ else
9248
+ throw new Error('DQT: invalid table spec');
9249
+ quantizationTables[quantizationTableSpec & 15] = tableData;
9250
+ }
9251
+ break;
9252
+ }
9253
+ case 0xFFC0: // SOF0 (Start of Frame, Baseline DCT)
9254
+ case 0xFFC1: // SOF1 (Start of Frame, Extended DCT)
9255
+ case 0xFFC2: { // SOF2 (Start of Frame, Progressive DCT)
9256
+ readUint16(); // skip data length
9257
+ frame = {
9258
+ extended: (fileMarker === 0xFFC1),
9259
+ progressive: (fileMarker === 0xFFC2),
9260
+ precision: data[offset++],
9261
+ scanLines: readUint16(),
9262
+ samplesPerLine: readUint16(),
9263
+ components: {},
9264
+ componentsOrder: [],
9265
+ maxH: 0,
9266
+ maxV: 0,
9267
+ mcusPerLine: 0,
9268
+ mcusPerColumn: 0,
9269
+ };
9270
+ var pixelsInFrame = frame.scanLines * frame.samplesPerLine;
9271
+ if (pixelsInFrame > maxResolutionInPixels) {
9272
+ var exceededAmount = Math.ceil((pixelsInFrame - maxResolutionInPixels) / 1e6);
9273
+ throw new Error("maxResolutionInMP limit exceeded by ".concat(exceededAmount, "MP"));
9274
+ }
9275
+ var componentsCount = data[offset++];
9276
+ for (var i = 0; i < componentsCount; i++) {
9277
+ var componentId = data[offset];
9278
+ var h = data[offset + 1] >> 4;
9279
+ var v = data[offset + 1] & 15;
9280
+ var qId = data[offset + 2];
9281
+ frame.componentsOrder.push(componentId);
9282
+ frame.components[componentId] = {
9283
+ h: h,
9284
+ v: v,
9285
+ quantizationIdx: qId,
9286
+ blocksPerColumn: 0,
9287
+ blocksPerLine: 0,
9288
+ blocks: [],
9289
+ pred: 0,
9290
+ };
9291
+ offset += 3;
9292
+ }
9293
+ prepareComponents(frame);
9294
+ frames.push(frame);
9295
+ break;
9296
+ }
9297
+ case 0xFFC4: { // DHT (Define Huffman Tables)
9298
+ var huffmanLength = readUint16();
9299
+ for (var i = 2; i < huffmanLength;) {
9300
+ var huffmanTableSpec = data[offset++];
9301
+ var codeLengths = new Uint8Array(16);
9302
+ var codeLengthSum = 0;
9303
+ for (var j = 0; j < 16; j++, offset++) {
9304
+ codeLengthSum += (codeLengths[j] = data[offset]);
9305
+ }
9306
+ requestMemoryAllocation(16 + codeLengthSum);
9307
+ var huffmanValues = new Uint8Array(codeLengthSum);
9308
+ for (var j = 0; j < codeLengthSum; j++, offset++) {
9309
+ huffmanValues[j] = data[offset];
9310
+ }
9311
+ i += 17 + codeLengthSum;
9312
+ var index = huffmanTableSpec & 15;
9313
+ var table = (huffmanTableSpec >> 4) === 0 ? huffmanTablesDC : huffmanTablesAC;
9314
+ table[index] = buildHuffmanTable(codeLengths, huffmanValues);
9315
+ }
9316
+ break;
9317
+ }
9318
+ case 0xFFDD: // DRI (Define Restart Interval)
9319
+ readUint16(); // skip data length
9320
+ resetInterval = readUint16();
9321
+ break;
9322
+ case 0xFFDC: // Number of Lines marker
9323
+ readUint16(); // skip data length
9324
+ readUint16(); // Ignore this data since it represents the image height
9325
+ break;
9326
+ case 0xFFDA: { // SOS (Start of Scan)
9327
+ readUint16(); // skip data length
9328
+ var selectorsCount = data[offset++];
9329
+ var components = [];
9330
+ for (var i = 0; i < selectorsCount; i++) {
9331
+ var component = frame.components[data[offset++]];
9332
+ var tableSpec = data[offset++];
9333
+ component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
9334
+ component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
9335
+ components.push(component);
9336
+ }
9337
+ var spectralStart = data[offset++];
9338
+ var spectralEnd = data[offset++];
9339
+ var successiveApproximation = data[offset++];
9340
+ var processed = decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15);
9341
+ offset += processed;
9342
+ break;
9343
+ }
9344
+ case 0xFFFF: // Fill bytes
9345
+ if (data[offset] !== 0xFF) { // Avoid skipping a valid marker.
9346
+ offset--;
9347
+ }
9348
+ break;
9349
+ default: {
9350
+ if (data[offset - 3] == 0xFF && data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) {
9351
+ // could be incorrect encoding -- last 0xFF byte of the previous
9352
+ // block was eaten by the encoder
9353
+ offset -= 3;
9354
+ break;
9355
+ }
9356
+ else if (fileMarker === 0xE0 || fileMarker == 0xE1) {
9357
+ // Recover from malformed APP1 markers popular in some phone models.
9358
+ // See https://github.com/eugeneware/jpeg-js/issues/82
9359
+ if (malformedDataOffset !== -1) {
9360
+ throw new Error("first unknown JPEG marker at offset ".concat(malformedDataOffset.toString(16), ", second unknown JPEG marker ").concat(fileMarker.toString(16), " at offset ").concat((offset - 1).toString(16)));
9361
+ }
9362
+ malformedDataOffset = offset - 1;
9363
+ var nextOffset = readUint16();
9364
+ if (data[offset + nextOffset - 2] === 0xFF) {
9365
+ offset += nextOffset - 2;
9366
+ break;
9367
+ }
9368
+ }
9369
+ throw new Error('unknown JPEG marker ' + fileMarker.toString(16));
9370
+ }
9371
+ }
9372
+ fileMarker = readUint16();
9373
+ }
9374
+ if (frames.length != 1)
9375
+ throw new Error('only single frame JPEGs supported');
9376
+ // set each frame's components quantization table
9377
+ for (var i = 0; i < frames.length; i++) {
9378
+ var cp = frames[i].components;
9379
+ for (var j in cp) { // TODO: don't use `in`
9380
+ cp[j].quantizationTable = quantizationTables[cp[j].quantizationIdx];
9381
+ delete cp[j].quantizationIdx; // TODO: why ???
9382
+ }
9383
+ }
9384
+ self.width = frame.samplesPerLine;
9385
+ self.height = frame.scanLines;
9386
+ self.jfif = jfif;
9387
+ self.adobe = adobe;
9388
+ self.components = [];
9389
+ for (var i = 0; i < frame.componentsOrder.length; i++) {
9390
+ var component = frame.components[frame.componentsOrder[i]];
9391
+ self.components.push({
9392
+ lines: buildComponentData(component),
9393
+ scaleX: component.h / frame.maxH,
9394
+ scaleY: component.v / frame.maxV
9395
+ });
9396
+ }
9397
+ return self;
9398
+ }
9399
+ function getData(decoded) {
9400
+ var offset = 0;
9401
+ var colorTransform = false;
9402
+ var width = decoded.width;
9403
+ var height = decoded.height;
9404
+ var dataLength = width * height * decoded.components.length;
9405
+ requestMemoryAllocation(dataLength);
9406
+ var data = new Uint8Array(dataLength);
9407
+ switch (decoded.components.length) {
9408
+ case 1: {
9409
+ var component1 = decoded.components[0];
9410
+ for (var y = 0; y < height; y++) {
9411
+ var component1Line = component1.lines[0 | (y * component1.scaleY)];
9412
+ for (var x = 0; x < width; x++) {
9413
+ var Y = component1Line[0 | (x * component1.scaleX)];
9414
+ data[offset++] = Y;
9415
+ }
9416
+ }
9417
+ break;
9418
+ }
9419
+ case 2: {
9420
+ // PDF might compress two component data in custom colorspace
9421
+ var component1 = decoded.components[0];
9422
+ var component2 = decoded.components[1];
9423
+ for (var y = 0; y < height; y++) {
9424
+ var component1Line = component1.lines[0 | (y * component1.scaleY)];
9425
+ var component2Line = component2.lines[0 | (y * component2.scaleY)];
9426
+ for (var x = 0; x < width; x++) {
9427
+ var Y1 = component1Line[0 | (x * component1.scaleX)];
9428
+ data[offset++] = Y1;
9429
+ var Y2 = component2Line[0 | (x * component2.scaleX)];
9430
+ data[offset++] = Y2;
9431
+ }
9432
+ }
9433
+ break;
9434
+ }
9435
+ case 3: {
9436
+ // The default transform for three components is true
9437
+ colorTransform = true;
9438
+ // The adobe transform marker overrides any previous setting
9439
+ if (decoded.adobe && decoded.adobe.transformCode)
9440
+ colorTransform = true;
9441
+ var component1 = decoded.components[0];
9442
+ var component2 = decoded.components[1];
9443
+ var component3 = decoded.components[2];
9444
+ for (var y = 0; y < height; y++) {
9445
+ var component1Line = component1.lines[0 | (y * component1.scaleY)];
9446
+ var component2Line = component2.lines[0 | (y * component2.scaleY)];
9447
+ var component3Line = component3.lines[0 | (y * component3.scaleY)];
9448
+ for (var x = 0; x < width; x++) {
9449
+ var Y = void 0, Cb = void 0, Cr = void 0, R = void 0, G = void 0, B = void 0;
9450
+ if (!colorTransform) {
9451
+ R = component1Line[0 | (x * component1.scaleX)];
9452
+ G = component2Line[0 | (x * component2.scaleX)];
9453
+ B = component3Line[0 | (x * component3.scaleX)];
9454
+ }
9455
+ else {
9456
+ Y = component1Line[0 | (x * component1.scaleX)];
9457
+ Cb = component2Line[0 | (x * component2.scaleX)];
9458
+ Cr = component3Line[0 | (x * component3.scaleX)];
9459
+ R = clampTo8bit(Y + 1.402 * (Cr - 128));
9460
+ G = clampTo8bit(Y - 0.3441363 * (Cb - 128) - 0.71413636 * (Cr - 128));
9461
+ B = clampTo8bit(Y + 1.772 * (Cb - 128));
9462
+ }
9463
+ data[offset++] = R;
9464
+ data[offset++] = G;
9465
+ data[offset++] = B;
9466
+ }
9467
+ }
9468
+ break;
9469
+ }
9470
+ case 4: {
9471
+ if (!decoded.adobe)
9472
+ throw new Error('Unsupported color mode (4 components)');
9473
+ // The default transform for four components is false
9474
+ colorTransform = false;
9475
+ // The adobe transform marker overrides any previous setting
9476
+ if (decoded.adobe && decoded.adobe.transformCode)
9477
+ colorTransform = true;
9478
+ var component1 = decoded.components[0];
9479
+ var component2 = decoded.components[1];
9480
+ var component3 = decoded.components[2];
9481
+ var component4 = decoded.components[3];
9482
+ for (var y = 0; y < height; y++) {
9483
+ var component1Line = component1.lines[0 | (y * component1.scaleY)];
9484
+ var component2Line = component2.lines[0 | (y * component2.scaleY)];
9485
+ var component3Line = component3.lines[0 | (y * component3.scaleY)];
9486
+ var component4Line = component4.lines[0 | (y * component4.scaleY)];
9487
+ for (var x = 0; x < width; x++) {
9488
+ var Y = void 0, Cb = void 0, Cr = void 0, K = void 0, C = void 0, M = void 0, Ye = void 0;
9489
+ if (!colorTransform) {
9490
+ C = component1Line[0 | (x * component1.scaleX)];
9491
+ M = component2Line[0 | (x * component2.scaleX)];
9492
+ Ye = component3Line[0 | (x * component3.scaleX)];
9493
+ K = component4Line[0 | (x * component4.scaleX)];
9494
+ }
9495
+ else {
9496
+ Y = component1Line[0 | (x * component1.scaleX)];
9497
+ Cb = component2Line[0 | (x * component2.scaleX)];
9498
+ Cr = component3Line[0 | (x * component3.scaleX)];
9499
+ K = component4Line[0 | (x * component4.scaleX)];
9500
+ C = 255 - clampTo8bit(Y + 1.402 * (Cr - 128));
9501
+ M = 255 - clampTo8bit(Y - 0.3441363 * (Cb - 128) - 0.71413636 * (Cr - 128));
9502
+ Ye = 255 - clampTo8bit(Y + 1.772 * (Cb - 128));
9503
+ }
9504
+ data[offset++] = 255 - C;
9505
+ data[offset++] = 255 - M;
9506
+ data[offset++] = 255 - Ye;
9507
+ data[offset++] = 255 - K;
9508
+ }
9509
+ }
9510
+ break;
9511
+ }
9512
+ default:
9513
+ throw new Error('Unsupported color mode');
9514
+ }
9515
+ return data;
9516
+ }
9517
+ function decodeJpeg(encoded, createImageData) {
9518
+ totalBytesAllocated = 0;
9519
+ if (encoded.length === 0)
9520
+ throw new Error('Empty jpeg buffer');
9521
+ var decoded = parse(encoded);
9522
+ requestMemoryAllocation(decoded.width * decoded.height * 4);
9523
+ var data = getData(decoded);
9524
+ var imageData = createImageData(decoded.width, decoded.height);
9525
+ var width = imageData.width;
9526
+ var height = imageData.height;
9527
+ var imageDataArray = imageData.data;
9528
+ var i = 0;
9529
+ var j = 0;
9530
+ switch (decoded.components.length) {
9531
+ case 1:
9532
+ for (var y = 0; y < height; y++) {
9533
+ for (var x = 0; x < width; x++) {
9534
+ var Y = data[i++];
9535
+ imageDataArray[j++] = Y;
9536
+ imageDataArray[j++] = Y;
9537
+ imageDataArray[j++] = Y;
9538
+ imageDataArray[j++] = 255;
9539
+ }
9540
+ }
9541
+ break;
9542
+ case 3:
9543
+ for (var y = 0; y < height; y++) {
9544
+ for (var x = 0; x < width; x++) {
9545
+ var R = data[i++];
9546
+ var G = data[i++];
9547
+ var B = data[i++];
9548
+ imageDataArray[j++] = R;
9549
+ imageDataArray[j++] = G;
9550
+ imageDataArray[j++] = B;
9551
+ imageDataArray[j++] = 255;
9552
+ }
9553
+ }
9554
+ break;
9555
+ case 4:
9556
+ for (var y = 0; y < height; y++) {
9557
+ for (var x = 0; x < width; x++) {
9558
+ var C = data[i++];
9559
+ var M = data[i++];
9560
+ var Y = data[i++];
9561
+ var K = data[i++];
9562
+ var R = 255 - clampTo8bit(C * (1 - K / 255) + K);
9563
+ var G = 255 - clampTo8bit(M * (1 - K / 255) + K);
9564
+ var B = 255 - clampTo8bit(Y * (1 - K / 255) + K);
9565
+ imageDataArray[j++] = R;
9566
+ imageDataArray[j++] = G;
9567
+ imageDataArray[j++] = B;
9568
+ imageDataArray[j++] = 255;
9569
+ }
9570
+ }
9571
+ break;
9572
+ default:
9573
+ throw new Error('Unsupported color mode');
9574
+ }
9575
+ return imageData;
9576
+ }
9577
+ exports.decodeJpeg = decodeJpeg;
9578
+
9579
+ },{}],12:[function(require,module,exports){
8556
9580
  "use strict";
8557
9581
  Object.defineProperty(exports, "__esModule", { value: true });
8558
9582
  exports.LayerCompCapturedInfo = exports.SectionDividerType = exports.ColorMode = void 0;
@@ -8582,7 +9606,7 @@ var LayerCompCapturedInfo;
8582
9606
  LayerCompCapturedInfo[LayerCompCapturedInfo["Appearance"] = 4] = "Appearance";
8583
9607
  })(LayerCompCapturedInfo = exports.LayerCompCapturedInfo || (exports.LayerCompCapturedInfo = {}));
8584
9608
 
8585
- },{}],12:[function(require,module,exports){
9609
+ },{}],13:[function(require,module,exports){
8586
9610
  "use strict";
8587
9611
  var __rest = (this && this.__rest) || function (s, e) {
8588
9612
  var t = {};
@@ -9826,7 +10850,7 @@ function copyChannelToRGBA(srcData, dstData, ox, oy, offset) {
9826
10850
  }
9827
10851
  }
9828
10852
 
9829
- },{"./additionalInfo":2,"./helpers":8,"./imageResources":9,"pako":35}],13:[function(require,module,exports){
10853
+ },{"./additionalInfo":2,"./helpers":8,"./imageResources":9,"pako":36}],14:[function(require,module,exports){
9830
10854
  "use strict";
9831
10855
  var __assign = (this && this.__assign) || function () {
9832
10856
  __assign = Object.assign || function(t) {
@@ -10633,7 +11657,7 @@ function writeColor(writer, color) {
10633
11657
  }
10634
11658
  exports.writeColor = writeColor;
10635
11659
 
10636
- },{"./additionalInfo":2,"./helpers":8,"./imageResources":9}],14:[function(require,module,exports){
11660
+ },{"./additionalInfo":2,"./helpers":8,"./imageResources":9}],15:[function(require,module,exports){
10637
11661
  "use strict";
10638
11662
  var __assign = (this && this.__assign) || function () {
10639
11663
  __assign = Object.assign || function(t) {
@@ -11212,7 +12236,7 @@ function encodeEngineData(data) {
11212
12236
  }
11213
12237
  exports.encodeEngineData = encodeEngineData;
11214
12238
 
11215
- },{}],15:[function(require,module,exports){
12239
+ },{}],16:[function(require,module,exports){
11216
12240
  "use strict";
11217
12241
  Object.defineProperty(exports, "__esModule", { value: true });
11218
12242
  exports.decodeString = exports.encodeString = exports.encodeStringTo = exports.stringLengthInBytes = void 0;
@@ -11371,7 +12395,7 @@ function decodeString(value) {
11371
12395
  }
11372
12396
  exports.decodeString = decodeString;
11373
12397
 
11374
- },{}],16:[function(require,module,exports){
12398
+ },{}],17:[function(require,module,exports){
11375
12399
 
11376
12400
  /**
11377
12401
  * Array#filter.
@@ -11398,7 +12422,7 @@ module.exports = function (arr, fn, self) {
11398
12422
 
11399
12423
  var hasOwn = Object.prototype.hasOwnProperty;
11400
12424
 
11401
- },{}],17:[function(require,module,exports){
12425
+ },{}],18:[function(require,module,exports){
11402
12426
  (function (global){(function (){
11403
12427
  'use strict';
11404
12428
 
@@ -11423,7 +12447,7 @@ module.exports = function availableTypedArrays() {
11423
12447
  };
11424
12448
 
11425
12449
  }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
11426
- },{"array-filter":16}],18:[function(require,module,exports){
12450
+ },{"array-filter":17}],19:[function(require,module,exports){
11427
12451
  'use strict'
11428
12452
 
11429
12453
  exports.byteLength = byteLength
@@ -11575,7 +12599,7 @@ function fromByteArray (uint8) {
11575
12599
  return parts.join('')
11576
12600
  }
11577
12601
 
11578
- },{}],19:[function(require,module,exports){
12602
+ },{}],20:[function(require,module,exports){
11579
12603
  (function (Buffer){(function (){
11580
12604
  /*!
11581
12605
  * The buffer module from node.js, for the browser.
@@ -13356,7 +14380,7 @@ function numberIsNaN (obj) {
13356
14380
  }
13357
14381
 
13358
14382
  }).call(this)}).call(this,require("buffer").Buffer)
13359
- },{"base64-js":18,"buffer":19,"ieee754":30}],20:[function(require,module,exports){
14383
+ },{"base64-js":19,"buffer":20,"ieee754":31}],21:[function(require,module,exports){
13360
14384
  'use strict';
13361
14385
 
13362
14386
  var GetIntrinsic = require('get-intrinsic');
@@ -13373,7 +14397,7 @@ module.exports = function callBoundIntrinsic(name, allowMissing) {
13373
14397
  return intrinsic;
13374
14398
  };
13375
14399
 
13376
- },{"./":21,"get-intrinsic":26}],21:[function(require,module,exports){
14400
+ },{"./":22,"get-intrinsic":27}],22:[function(require,module,exports){
13377
14401
  'use strict';
13378
14402
 
13379
14403
  var bind = require('function-bind');
@@ -13422,7 +14446,7 @@ if ($defineProperty) {
13422
14446
  module.exports.apply = applyBind;
13423
14447
  }
13424
14448
 
13425
- },{"function-bind":25,"get-intrinsic":26}],22:[function(require,module,exports){
14449
+ },{"function-bind":26,"get-intrinsic":27}],23:[function(require,module,exports){
13426
14450
  'use strict';
13427
14451
 
13428
14452
  var GetIntrinsic = require('get-intrinsic');
@@ -13439,7 +14463,7 @@ if ($gOPD) {
13439
14463
 
13440
14464
  module.exports = $gOPD;
13441
14465
 
13442
- },{"get-intrinsic":26}],23:[function(require,module,exports){
14466
+ },{"get-intrinsic":27}],24:[function(require,module,exports){
13443
14467
 
13444
14468
  var hasOwn = Object.prototype.hasOwnProperty;
13445
14469
  var toString = Object.prototype.toString;
@@ -13463,7 +14487,7 @@ module.exports = function forEach (obj, fn, ctx) {
13463
14487
  };
13464
14488
 
13465
14489
 
13466
- },{}],24:[function(require,module,exports){
14490
+ },{}],25:[function(require,module,exports){
13467
14491
  'use strict';
13468
14492
 
13469
14493
  /* eslint no-invalid-this: 1 */
@@ -13549,14 +14573,14 @@ module.exports = function bind(that) {
13549
14573
  return bound;
13550
14574
  };
13551
14575
 
13552
- },{}],25:[function(require,module,exports){
14576
+ },{}],26:[function(require,module,exports){
13553
14577
  'use strict';
13554
14578
 
13555
14579
  var implementation = require('./implementation');
13556
14580
 
13557
14581
  module.exports = Function.prototype.bind || implementation;
13558
14582
 
13559
- },{"./implementation":24}],26:[function(require,module,exports){
14583
+ },{"./implementation":25}],27:[function(require,module,exports){
13560
14584
  'use strict';
13561
14585
 
13562
14586
  var undefined;
@@ -13892,7 +14916,7 @@ module.exports = function GetIntrinsic(name, allowMissing) {
13892
14916
  return value;
13893
14917
  };
13894
14918
 
13895
- },{"function-bind":25,"has":29,"has-symbols":27}],27:[function(require,module,exports){
14919
+ },{"function-bind":26,"has":30,"has-symbols":28}],28:[function(require,module,exports){
13896
14920
  'use strict';
13897
14921
 
13898
14922
  var origSymbol = typeof Symbol !== 'undefined' && Symbol;
@@ -13907,7 +14931,7 @@ module.exports = function hasNativeSymbols() {
13907
14931
  return hasSymbolSham();
13908
14932
  };
13909
14933
 
13910
- },{"./shams":28}],28:[function(require,module,exports){
14934
+ },{"./shams":29}],29:[function(require,module,exports){
13911
14935
  'use strict';
13912
14936
 
13913
14937
  /* eslint complexity: [2, 18], max-statements: [2, 33] */
@@ -13951,14 +14975,14 @@ module.exports = function hasSymbols() {
13951
14975
  return true;
13952
14976
  };
13953
14977
 
13954
- },{}],29:[function(require,module,exports){
14978
+ },{}],30:[function(require,module,exports){
13955
14979
  'use strict';
13956
14980
 
13957
14981
  var bind = require('function-bind');
13958
14982
 
13959
14983
  module.exports = bind.call(Function.call, Object.prototype.hasOwnProperty);
13960
14984
 
13961
- },{"function-bind":25}],30:[function(require,module,exports){
14985
+ },{"function-bind":26}],31:[function(require,module,exports){
13962
14986
  /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
13963
14987
  exports.read = function (buffer, offset, isLE, mLen, nBytes) {
13964
14988
  var e, m
@@ -14045,7 +15069,7 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
14045
15069
  buffer[offset + i - d] |= s * 128
14046
15070
  }
14047
15071
 
14048
- },{}],31:[function(require,module,exports){
15072
+ },{}],32:[function(require,module,exports){
14049
15073
  if (typeof Object.create === 'function') {
14050
15074
  // implementation from standard node.js 'util' module
14051
15075
  module.exports = function inherits(ctor, superCtor) {
@@ -14074,7 +15098,7 @@ if (typeof Object.create === 'function') {
14074
15098
  }
14075
15099
  }
14076
15100
 
14077
- },{}],32:[function(require,module,exports){
15101
+ },{}],33:[function(require,module,exports){
14078
15102
  'use strict';
14079
15103
 
14080
15104
  var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
@@ -14109,7 +15133,7 @@ isStandardArguments.isLegacyArguments = isLegacyArguments; // for tests
14109
15133
 
14110
15134
  module.exports = supportsStandardArguments ? isStandardArguments : isLegacyArguments;
14111
15135
 
14112
- },{"call-bind/callBound":20}],33:[function(require,module,exports){
15136
+ },{"call-bind/callBound":21}],34:[function(require,module,exports){
14113
15137
  'use strict';
14114
15138
 
14115
15139
  var toStr = Object.prototype.toString;
@@ -14143,7 +15167,7 @@ module.exports = function isGeneratorFunction(fn) {
14143
15167
  return getProto && getProto(fn) === GeneratorFunction;
14144
15168
  };
14145
15169
 
14146
- },{}],34:[function(require,module,exports){
15170
+ },{}],35:[function(require,module,exports){
14147
15171
  (function (global){(function (){
14148
15172
  'use strict';
14149
15173
 
@@ -14208,7 +15232,7 @@ module.exports = function isTypedArray(value) {
14208
15232
  };
14209
15233
 
14210
15234
  }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
14211
- },{"available-typed-arrays":17,"call-bind/callBound":20,"es-abstract/helpers/getOwnPropertyDescriptor":22,"foreach":23,"has-symbols":27}],35:[function(require,module,exports){
15235
+ },{"available-typed-arrays":18,"call-bind/callBound":21,"es-abstract/helpers/getOwnPropertyDescriptor":23,"foreach":24,"has-symbols":28}],36:[function(require,module,exports){
14212
15236
  // Top level file is just a mixin of submodules & constants
14213
15237
  'use strict';
14214
15238
 
@@ -14228,7 +15252,7 @@ module.exports.inflateRaw = inflateRaw;
14228
15252
  module.exports.ungzip = ungzip;
14229
15253
  module.exports.constants = constants;
14230
15254
 
14231
- },{"./lib/deflate":36,"./lib/inflate":37,"./lib/zlib/constants":41}],36:[function(require,module,exports){
15255
+ },{"./lib/deflate":37,"./lib/inflate":38,"./lib/zlib/constants":42}],37:[function(require,module,exports){
14232
15256
  'use strict';
14233
15257
 
14234
15258
 
@@ -14610,7 +15634,7 @@ module.exports.deflateRaw = deflateRaw;
14610
15634
  module.exports.gzip = gzip;
14611
15635
  module.exports.constants = require('./zlib/constants');
14612
15636
 
14613
- },{"./utils/common":38,"./utils/strings":39,"./zlib/constants":41,"./zlib/deflate":43,"./zlib/messages":48,"./zlib/zstream":50}],37:[function(require,module,exports){
15637
+ },{"./utils/common":39,"./utils/strings":40,"./zlib/constants":42,"./zlib/deflate":44,"./zlib/messages":49,"./zlib/zstream":51}],38:[function(require,module,exports){
14614
15638
  'use strict';
14615
15639
 
14616
15640
 
@@ -15031,7 +16055,7 @@ module.exports.inflateRaw = inflateRaw;
15031
16055
  module.exports.ungzip = inflate;
15032
16056
  module.exports.constants = require('./zlib/constants');
15033
16057
 
15034
- },{"./utils/common":38,"./utils/strings":39,"./zlib/constants":41,"./zlib/gzheader":44,"./zlib/inflate":46,"./zlib/messages":48,"./zlib/zstream":50}],38:[function(require,module,exports){
16058
+ },{"./utils/common":39,"./utils/strings":40,"./zlib/constants":42,"./zlib/gzheader":45,"./zlib/inflate":47,"./zlib/messages":49,"./zlib/zstream":51}],39:[function(require,module,exports){
15035
16059
  'use strict';
15036
16060
 
15037
16061
 
@@ -15081,7 +16105,7 @@ module.exports.flattenChunks = (chunks) => {
15081
16105
  return result;
15082
16106
  };
15083
16107
 
15084
- },{}],39:[function(require,module,exports){
16108
+ },{}],40:[function(require,module,exports){
15085
16109
  // String encode/decode helpers
15086
16110
  'use strict';
15087
16111
 
@@ -15257,7 +16281,7 @@ module.exports.utf8border = (buf, max) => {
15257
16281
  return (pos + _utf8len[buf[pos]] > max) ? pos : max;
15258
16282
  };
15259
16283
 
15260
- },{}],40:[function(require,module,exports){
16284
+ },{}],41:[function(require,module,exports){
15261
16285
  'use strict';
15262
16286
 
15263
16287
  // Note: adler32 takes 12% for level 0 and 2% for level 6.
@@ -15310,7 +16334,7 @@ const adler32 = (adler, buf, len, pos) => {
15310
16334
 
15311
16335
  module.exports = adler32;
15312
16336
 
15313
- },{}],41:[function(require,module,exports){
16337
+ },{}],42:[function(require,module,exports){
15314
16338
  'use strict';
15315
16339
 
15316
16340
  // (C) 1995-2013 Jean-loup Gailly and Mark Adler
@@ -15380,7 +16404,7 @@ module.exports = {
15380
16404
  //Z_NULL: null // Use -1 or null inline, depending on var type
15381
16405
  };
15382
16406
 
15383
- },{}],42:[function(require,module,exports){
16407
+ },{}],43:[function(require,module,exports){
15384
16408
  'use strict';
15385
16409
 
15386
16410
  // Note: we can't get significant speed boost here.
@@ -15441,7 +16465,7 @@ const crc32 = (crc, buf, len, pos) => {
15441
16465
 
15442
16466
  module.exports = crc32;
15443
16467
 
15444
- },{}],43:[function(require,module,exports){
16468
+ },{}],44:[function(require,module,exports){
15445
16469
  'use strict';
15446
16470
 
15447
16471
  // (C) 1995-2013 Jean-loup Gailly and Mark Adler
@@ -17491,7 +18515,7 @@ module.exports.deflatePrime = deflatePrime;
17491
18515
  module.exports.deflateTune = deflateTune;
17492
18516
  */
17493
18517
 
17494
- },{"./adler32":40,"./constants":41,"./crc32":42,"./messages":48,"./trees":49}],44:[function(require,module,exports){
18518
+ },{"./adler32":41,"./constants":42,"./crc32":43,"./messages":49,"./trees":50}],45:[function(require,module,exports){
17495
18519
  'use strict';
17496
18520
 
17497
18521
  // (C) 1995-2013 Jean-loup Gailly and Mark Adler
@@ -17551,7 +18575,7 @@ function GZheader() {
17551
18575
 
17552
18576
  module.exports = GZheader;
17553
18577
 
17554
- },{}],45:[function(require,module,exports){
18578
+ },{}],46:[function(require,module,exports){
17555
18579
  'use strict';
17556
18580
 
17557
18581
  // (C) 1995-2013 Jean-loup Gailly and Mark Adler
@@ -17897,7 +18921,7 @@ module.exports = function inflate_fast(strm, start) {
17897
18921
  return;
17898
18922
  };
17899
18923
 
17900
- },{}],46:[function(require,module,exports){
18924
+ },{}],47:[function(require,module,exports){
17901
18925
  'use strict';
17902
18926
 
17903
18927
  // (C) 1995-2013 Jean-loup Gailly and Mark Adler
@@ -19471,7 +20495,7 @@ module.exports.inflateUndermine = inflateUndermine;
19471
20495
  module.exports.inflateValidate = inflateValidate;
19472
20496
  */
19473
20497
 
19474
- },{"./adler32":40,"./constants":41,"./crc32":42,"./inffast":45,"./inftrees":47}],47:[function(require,module,exports){
20498
+ },{"./adler32":41,"./constants":42,"./crc32":43,"./inffast":46,"./inftrees":48}],48:[function(require,module,exports){
19475
20499
  'use strict';
19476
20500
 
19477
20501
  // (C) 1995-2013 Jean-loup Gailly and Mark Adler
@@ -19813,7 +20837,7 @@ const inflate_table = (type, lens, lens_index, codes, table, table_index, work,
19813
20837
 
19814
20838
  module.exports = inflate_table;
19815
20839
 
19816
- },{}],48:[function(require,module,exports){
20840
+ },{}],49:[function(require,module,exports){
19817
20841
  'use strict';
19818
20842
 
19819
20843
  // (C) 1995-2013 Jean-loup Gailly and Mark Adler
@@ -19847,7 +20871,7 @@ module.exports = {
19847
20871
  '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */
19848
20872
  };
19849
20873
 
19850
- },{}],49:[function(require,module,exports){
20874
+ },{}],50:[function(require,module,exports){
19851
20875
  'use strict';
19852
20876
 
19853
20877
  // (C) 1995-2013 Jean-loup Gailly and Mark Adler
@@ -21028,7 +22052,7 @@ module.exports._tr_flush_block = _tr_flush_block;
21028
22052
  module.exports._tr_tally = _tr_tally;
21029
22053
  module.exports._tr_align = _tr_align;
21030
22054
 
21031
- },{}],50:[function(require,module,exports){
22055
+ },{}],51:[function(require,module,exports){
21032
22056
  'use strict';
21033
22057
 
21034
22058
  // (C) 1995-2013 Jean-loup Gailly and Mark Adler
@@ -21077,7 +22101,7 @@ function ZStream() {
21077
22101
 
21078
22102
  module.exports = ZStream;
21079
22103
 
21080
- },{}],51:[function(require,module,exports){
22104
+ },{}],52:[function(require,module,exports){
21081
22105
  // shim for using process in browser
21082
22106
  var process = module.exports = {};
21083
22107
 
@@ -21263,14 +22287,14 @@ process.chdir = function (dir) {
21263
22287
  };
21264
22288
  process.umask = function() { return 0; };
21265
22289
 
21266
- },{}],52:[function(require,module,exports){
22290
+ },{}],53:[function(require,module,exports){
21267
22291
  module.exports = function isBuffer(arg) {
21268
22292
  return arg && typeof arg === 'object'
21269
22293
  && typeof arg.copy === 'function'
21270
22294
  && typeof arg.fill === 'function'
21271
22295
  && typeof arg.readUInt8 === 'function';
21272
22296
  }
21273
- },{}],53:[function(require,module,exports){
22297
+ },{}],54:[function(require,module,exports){
21274
22298
  // Currently in sync with Node.js lib/internal/util/types.js
21275
22299
  // https://github.com/nodejs/node/commit/112cc7c27551254aa2b17098fb774867f05ed0d9
21276
22300
 
@@ -21604,7 +22628,7 @@ exports.isAnyArrayBuffer = isAnyArrayBuffer;
21604
22628
  });
21605
22629
  });
21606
22630
 
21607
- },{"is-arguments":32,"is-generator-function":33,"is-typed-array":34,"which-typed-array":55}],54:[function(require,module,exports){
22631
+ },{"is-arguments":33,"is-generator-function":34,"is-typed-array":35,"which-typed-array":56}],55:[function(require,module,exports){
21608
22632
  (function (process){(function (){
21609
22633
  // Copyright Joyent, Inc. and other Node contributors.
21610
22634
  //
@@ -22323,7 +23347,7 @@ function callbackify(original) {
22323
23347
  exports.callbackify = callbackify;
22324
23348
 
22325
23349
  }).call(this)}).call(this,require('_process'))
22326
- },{"./support/isBuffer":52,"./support/types":53,"_process":51,"inherits":31}],55:[function(require,module,exports){
23350
+ },{"./support/isBuffer":53,"./support/types":54,"_process":52,"inherits":32}],56:[function(require,module,exports){
22327
23351
  (function (global){(function (){
22328
23352
  'use strict';
22329
23353
 
@@ -22383,5 +23407,5 @@ module.exports = function whichTypedArray(value) {
22383
23407
  };
22384
23408
 
22385
23409
  }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
22386
- },{"available-typed-arrays":17,"call-bind/callBound":20,"es-abstract/helpers/getOwnPropertyDescriptor":22,"foreach":23,"has-symbols":27,"is-typed-array":34}]},{},[10])(10)
23410
+ },{"available-typed-arrays":18,"call-bind/callBound":21,"es-abstract/helpers/getOwnPropertyDescriptor":23,"foreach":24,"has-symbols":28,"is-typed-array":35}]},{},[10])(10)
22387
23411
  });