@syncfusion/ej2-compression
Advanced tools
Comparing version 16.1.32 to 16.1.37
/*! | ||
* filename: ej2-compression.umd.min.js | ||
* version : 16.1.37 | ||
* Copyright Syncfusion Inc. 2001 - 2018. All rights reserved. | ||
* Use of this code is subject to the terms of our license. | ||
* A copy of the current license can be obtained at any time by e-mailing | ||
* licensing@syncfusion.com. Any infringement will be prosecuted under | ||
* applicable laws. | ||
*/ | ||
/*! | ||
* filename: ej2-compression.umd.min.js | ||
* version : 16.1.32 | ||
* Copyright Syncfusion Inc. 2001 - 2017. All rights reserved. | ||
* Copyright Syncfusion Inc. 2001 - 2018. All rights reserved. | ||
* Use of this code is subject to the terms of our license. | ||
@@ -6,0 +15,0 @@ * A copy of the current license can be obtained at any time by e-mailing |
/*! | ||
* filename: ej2-compression.min.js | ||
* version : 16.1.26 | ||
* Copyright Syncfusion Inc. 2001 - 2017. All rights reserved. | ||
* version : 16.1.37 | ||
* Copyright Syncfusion Inc. 2001 - 2018. All rights reserved. | ||
* Use of this code is subject to the terms of our license. | ||
@@ -10,4 +10,13 @@ * A copy of the current license can be obtained at any time by e-mailing | ||
*/ | ||
/*! | ||
* filename: ej2-compression.min.js | ||
* version : 16.1.32 | ||
* Copyright Syncfusion Inc. 2001 - 2018. All rights reserved. | ||
* Use of this code is subject to the terms of our license. | ||
* A copy of the current license can be obtained at any time by e-mailing | ||
* licensing@syncfusion.com. Any infringement will be prosecuted under | ||
* applicable laws. | ||
*/ | ||
var ej=function(t){"use strict";function e(t,e){if(null===t||void 0===t)throw new Error("ArgumentException: "+e+" cannot be null or undefined")}var i=function(){function t(t){this.emitBOM=!0,this.encodingType="Ansi",this.initBOM(t)}return Object.defineProperty(t.prototype,"includeBom",{get:function(){return this.emitBOM},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"type",{get:function(){return this.encodingType},set:function(t){this.encodingType=t},enumerable:!0,configurable:!0}),t.prototype.initBOM=function(t){this.emitBOM=void 0===t||null===t||t},t.prototype.getByteCount=function(t){return e(t,"string"),""===t?this.utf8Len(t.charCodeAt(0)):(null!==this.type&&void 0!==this.type||(this.type="Ansi"),this.getByteCountInternal(t,0,t.length))},t.prototype.utf8Len=function(t){return t<=127?1:t<=2047?2:t<=65535?3:t<=2097151?4:0},t.prototype.isHighSurrogate=function(t){return t>=55296&&t<=56319},t.prototype.toCodepoint=function(t,e){return((t=(1023&t)<<10)|1023&e)+65536},t.prototype.getByteCountInternal=function(t,e,i){var n=0;if("Utf8"===this.encodingType||"Unicode"===this.encodingType){for(var r="Utf8"===this.encodingType,s=0;s<i;s++){var o=t.charCodeAt(r?e:e++);if(this.isHighSurrogate(o))if(r){var h=o,a=t.charCodeAt(++e);n+=this.utf8Len(this.toCodepoint(h,a))}else n+=4,++s;else n+=r?this.utf8Len(o):2;r&&e++}return n}return n=i},t.prototype.getBytes=function(t,i,n){if(e(t,"string"),e(i,"charIndex"),e(n,"charCount"),i<0||n<0)throw new RangeError("Argument Out Of Range Exception: charIndex or charCount is less than zero");if(t.length-i<n)throw new RangeError("Argument Out Of Range Exception: charIndex and charCount do not denote a valid range in string");if(""===t)return new ArrayBuffer(0);null!==this.type&&void 0!==this.type||(this.type="Ansi");var r=this.getByteCountInternal(t,i,n);switch(this.type){case"Utf8":return this.getBytesOfUtf8Encoding(r,t,i,n);case"Unicode":return this.getBytesOfUnicodeEncoding(r,t,i,n);default:return this.getBytesOfAnsiEncoding(r,t,i,n)}},t.prototype.getString=function(t,i,n){if(e(t,"bytes"),e(i,"index"),e(n,"count"),i<0||n<0)throw new RangeError("Argument Out Of Range Exception: index or count is less than zero");if(t.byteLength-i<n)throw new RangeError("Argument Out Of Range Exception: index and count do not denote a valid range in bytes");if(0===t.byteLength||0===n)return"";null!==this.type&&void 0!==this.type||(this.type="Ansi");var r="",s=new Uint8Array(t);switch(this.type){case"Utf8":return this.getStringOfUtf8Encoding(s,i,n);case"Unicode":var o=new Uint16Array(t);return r=this.getStringofUnicodeEncoding(o,i,n);default:for(var h=i,a=0;a<n;a++){var f=s[h];r+=String.fromCharCode(f),h++}return r}},t.prototype.getBytesOfAnsiEncoding=function(t,e,i,n){for(var r=new ArrayBuffer(t),s=new Uint8Array(r),o=0,h=0;h<n;h++){var a=e.charCodeAt(i++);s[o]=a<2048?a:63,o++}return r},t.prototype.getBytesOfUtf8Encoding=function(t,e,i,n){for(var r=new ArrayBuffer(t),s=new Uint8Array(r),o=i,h=0,a=0;a<n;a++){var f=e.charCodeAt(o);f<=127?s[h]=f:f<2048?(s[h]=192|f>>6,s[++h]=128|63&f):f<55296||f>=57344?(s[h]=224|f>>12,s[++h]=128|f>>6&63,s[++h]=128|63&f):(s[h]=239,s[++h]=191,s[++h]=189),++h,++o}return r},t.prototype.getBytesOfUnicodeEncoding=function(t,e,i,n){for(var r=new ArrayBuffer(t),s=new Uint16Array(r),o=0;o<n;o++){var h=e.charCodeAt(o);s[o]=h}return r},t.prototype.getStringOfUtf8Encoding=function(t,e,i){var n=0,r=e,s="";for(n;n<i;n++){for(var o=t[r++];r>t.length;)return s;o>127&&(o>191&&o<224&&r<i?o=(31&o)<<6|63&t[r]:o>223&&o<240&&r<t.byteLength?o=(15&o)<<12|(63&t[r])<<6|63&t[++r]:o>239&&o<248&&r<t.byteLength&&(o=(7&o)<<18|(63&t[r])<<12|(63&t[++r])<<6|63&t[++r]),++r),s+=String.fromCharCode(o)}return s},t.prototype.getStringofUnicodeEncoding=function(t,e,i){if(i>t.length)throw new RangeError("ArgumentOutOfRange_Count");for(var n=new Uint16Array(i),r=0;r<i&&r<t.length;r++)n[r]=t[e++];return String.fromCharCode.apply(null,n)},t.prototype.destroy=function(){this.emitBOM=void 0,this.encodingType=void 0},t}(),n=function(){function t(){}return t.save=function(t,e){if(null===t||void 0===t||""===t)throw new Error("ArgumentException: fileName cannot be undefined, null or empty");var i=t.substring(t.lastIndexOf(".")+1,t.length),n=this.getMimeType(i);if(""!==n&&(e=new Blob([e],{type:n})),this.isMicrosoftBrowser)navigator.msSaveBlob(e,t);else{var r=document.createElementNS("http://www.w3.org/1999/xhtml","a");this.saveInternal(t,i,e,r,"download"in r)}},t.saveInternal=function(t,e,i,n,r){if(r){n.download=t;var s=window.URL.createObjectURL(i);n.href=s;var o=document.createEvent("MouseEvent");o.initEvent("click",!0,!0),n.dispatchEvent(o),setTimeout(function(){window.URL.revokeObjectURL(s),s=void 0})}else if("docx"!==e&&"xlsx"!==e){var h=window.URL.createObjectURL(i);window.open(h,"_blank")||(window.location.href=h)}else{var a=new FileReader;a.onloadend=function(){window.open(a.result,"_blank")||(window.location.href=a.result)},a.readAsDataURL(i)}},t.getMimeType=function(t){var e="";switch(t){case"html":e="text/html";break;case"pdf":e="application/pdf";break;case"docx":e="application/vnd.openxmlformats-officedocument.wordprocessingml.document";break;case"xlsx":e="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";break;case"txt":e="text/plain"}return e},t}(),r=function(){function t(t){this.bufferBlob=new Blob([""]),this.bufferText="",this.init(t),n.isMicrosoftBrowser=!!navigator.msSaveBlob}return Object.defineProperty(t.prototype,"buffer",{get:function(){return this.flush(),this.bufferBlob},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"encoding",{get:function(){return this.enc},enumerable:!0,configurable:!0}),t.prototype.init=function(t){null===t||void 0===t?(this.enc=new i(!1),this.enc.type="Utf8"):(this.enc=t,this.setBomByte())},t.prototype.setBomByte=function(){if(this.encoding.includeBom)switch(this.encoding.type){case"Unicode":var t=new ArrayBuffer(2),e=new Uint8Array(t);e[0]=255,e[1]=254,this.bufferBlob=new Blob([t]);break;case"Utf8":var i=new ArrayBuffer(3),n=new Uint8Array(i);n[0]=239,n[1]=187,n[2]=191,this.bufferBlob=new Blob([i]);break;default:this.bufferBlob=new Blob([""])}},t.prototype.save=function(t){""!==this.bufferText&&this.flush(),n.save(t,this.buffer)},t.prototype.write=function(t){if(void 0===this.encoding)throw new Error("Object Disposed Exception: current writer is disposed");e(t,"string"),this.bufferText+=t,this.bufferText.length>=10240&&this.flush()},t.prototype.flush=function(){if(void 0!==this.bufferText&&null!==this.bufferText&&0!==this.bufferText.length){var t=this.encoding.getBytes(this.bufferText,0,this.bufferText.length);this.bufferText="",this.bufferBlob=new Blob([this.bufferBlob,t])}},t.prototype.writeLine=function(t){if(void 0===this.encoding)throw new Error("Object Disposed Exception: current writer is disposed");e(t,"string"),this.bufferText=this.bufferText+t+"\r\n",this.bufferText.length>=10240&&this.flush()},t.prototype.destroy=function(){this.bufferBlob=void 0,this.bufferText=void 0,this.enc instanceof i&&this.enc.destroy(),this.enc=void 0},t}(),s=Object.freeze({StreamWriter:r,Encoding:i,validateNullOrUndefined:e,Save:n}),o=new Int16Array(286),h=new Uint8Array(286),a=new Int16Array(30),f=new Uint8Array(30),u=function(){function t(t){this.pendingBuffer=new Uint8Array(65536),this.pendingBufLength=0,this.pendingBufCache=0,this.pendingBufBitsInCache=0,this.bufferPosition=0,this.extraBits=0,this.currentHash=0,this.matchStart=0,this.matchLength=0,this.matchPrevAvail=!1,this.blockStart=0,this.stringStart=0,this.lookAhead=0,this.totalBytesIn=0,this.inputOffset=0,this.inputEnd=0,this.windowSize=32768,this.windowMask=this.windowSize-1,this.hashSize=32768,this.hashMask=this.hashSize-1,this.hashShift=Math.floor(17/3),this.maxDist=this.windowSize-262,this.checkSum=1,this.noWrap=!1,this.treeLiteral=new c(this,286,257,15),this.treeDistances=new c(this,30,1,15),this.treeCodeLengths=new c(this,19,4,7),this.arrDistances=new Uint16Array(16384),this.arrLiterals=new Uint8Array(16384),this.stream=[],this.dataWindow=new Uint8Array(2*this.windowSize),this.hashHead=new Int16Array(this.hashSize),this.hashPrevious=new Int16Array(this.windowSize),this.blockStart=this.stringStart=1,this.noWrap=t,t||this.writeZLibHeader()}return Object.defineProperty(t.prototype,"compressedData",{get:function(){return this.stream},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"getCompressedString",{get:function(){var t="";if(void 0!==this.stream)for(var e=0;e<this.stream.length;e++)t+=String.fromCharCode.apply(null,this.stream[e]);return t},enumerable:!0,configurable:!0}),t.prototype.write=function(t,e,n){if(void 0===t||null===t)throw new Error("ArgumentException: data cannot null or undefined");var r=e+n;if(0>e||e>r||r>t.length)throw new Error("ArgumentOutOfRangeException: Offset or length is incorrect");if("string"==typeof t){var s=new i(!1);s.type="Utf8",r=e+(t=new Uint8Array(s.getBytes(t,0,t.length))).length}for(this.inputBuffer=t,this.inputOffset=e,this.inputEnd=r,this.noWrap||(this.checkSum=d.checksumUpdate(this.checkSum,this.inputBuffer,this.inputOffset,r));this.inputEnd!==this.inputOffset||0!==this.pendingBufLength;)this.pendingBufferFlush(),this.compressData(!1)},t.prototype.writeZLibHeader=function(){var t=30720;t|=64,t+=31-t%31,this.pendingBufferWriteShortBytes(t)},t.prototype.pendingBufferWriteShortBytes=function(t){this.pendingBuffer[this.pendingBufLength++]=t>>8,this.pendingBuffer[this.pendingBufLength++]=t},t.prototype.compressData=function(t){var e;do{this.fillWindow();var i=t&&this.inputEnd===this.inputOffset;e=this.compressSlow(i,t)}while(0===this.pendingBufLength&&e);return e},t.prototype.compressSlow=function(t,e){if(this.lookAhead<262&&!t)return!1;for(;this.lookAhead>=262||t;){if(0===this.lookAhead)return this.lookAheadCompleted(e);this.stringStart>=2*this.windowSize-262&&this.slideWindow();var i=this.matchStart,n=this.matchLength;if(this.lookAhead>=3&&this.discardMatch(),n>=3&&this.matchLength<=n?n=this.matchPreviousBest(i,n):this.matchPreviousAvailable(),this.bufferPosition>=16384)return this.huffmanIsFull(e)}return!0},t.prototype.discardMatch=function(){var t=this.insertString();0!==t&&this.stringStart-t<=this.maxDist&&this.findLongestMatch(t)&&this.matchLength<=5&&3===this.matchLength&&this.stringStart-this.matchStart>4096&&(this.matchLength=2)},t.prototype.matchPreviousAvailable=function(){this.matchPrevAvail&&this.huffmanTallyLit(255&this.dataWindow[this.stringStart-1]),this.matchPrevAvail=!0,this.stringStart++,this.lookAhead--},t.prototype.matchPreviousBest=function(t,e){this.huffmanTallyDist(this.stringStart-1-t,e),e-=2;do{this.stringStart++,--this.lookAhead>=3&&this.insertString()}while(--e>0);return this.stringStart++,this.lookAhead--,this.matchPrevAvail=!1,this.matchLength=2,e},t.prototype.lookAheadCompleted=function(t){return this.matchPrevAvail&&this.huffmanTallyLit(255&this.dataWindow[this.stringStart-1]),this.matchPrevAvail=!1,this.huffmanFlushBlock(this.dataWindow,this.blockStart,this.stringStart-this.blockStart,t),this.blockStart=this.stringStart,!1},t.prototype.huffmanIsFull=function(t){var e=this.stringStart-this.blockStart;this.matchPrevAvail&&e--;var i=t&&0===this.lookAhead&&!this.matchPrevAvail;return this.huffmanFlushBlock(this.dataWindow,this.blockStart,e,i),this.blockStart+=e,!i},t.prototype.fillWindow=function(){for(this.stringStart>=this.windowSize+this.maxDist&&this.slideWindow();this.lookAhead<262&&this.inputOffset<this.inputEnd;){var t=2*this.windowSize-this.lookAhead-this.stringStart;t>this.inputEnd-this.inputOffset&&(t=this.inputEnd-this.inputOffset),this.dataWindow.set(this.inputBuffer.subarray(this.inputOffset,this.inputOffset+t),this.stringStart+this.lookAhead),this.inputOffset+=t,this.totalBytesIn+=t,this.lookAhead+=t}this.lookAhead>=3&&this.updateHash()},t.prototype.slideWindow=function(){this.dataWindow.set(this.dataWindow.subarray(this.windowSize,this.windowSize+this.windowSize),0),this.matchStart-=this.windowSize,this.stringStart-=this.windowSize,this.blockStart-=this.windowSize;for(t=0;t<this.hashSize;++t){e=65535&this.hashHead[t];this.hashHead[t]=e>=this.windowSize?e-this.windowSize:0}for(var t=0;t<this.windowSize;t++){var e=65535&this.hashPrevious[t];this.hashPrevious[t]=e>=this.windowSize?e-this.windowSize:0}},t.prototype.insertString=function(){var t,e=(this.currentHash<<this.hashShift^this.dataWindow[this.stringStart+2])&this.hashMask;return this.hashPrevious[this.stringStart&this.windowMask]=t=this.hashHead[e],this.hashHead[e]=this.stringStart,this.currentHash=e,65535&t},t.prototype.findLongestMatch=function(t){var e,i=4096,n=258,r=this.stringStart,s=this.stringStart+this.matchLength,o=Math.max(this.matchLength,2),h=Math.max(this.stringStart-this.maxDist,0),a=this.stringStart+258-1,f=this.dataWindow[s-1],u=this.dataWindow[s],c=this.dataWindow;o>=32&&(i>>=2),n>this.lookAhead&&(n=this.lookAhead);do{if(c[t+o]===u&&c[t+o-1]===f&&c[t]===c[r]&&c[t+1]===c[r+1]){for(e=t+2,r+=2;c[++r]===c[++e]&&c[++r]===c[++e]&&c[++r]===c[++e]&&c[++r]===c[++e]&&c[++r]===c[++e]&&c[++r]===c[++e]&&c[++r]===c[++e]&&c[++r]===c[++e]&&r<a;);if(r>s){if(this.matchStart=t,s=r,(o=r-this.stringStart)>=n)break;f=c[s-1],u=c[s]}r=this.stringStart}}while((t=65535&this.hashPrevious[t&this.windowMask])>h&&0!=--i);return this.matchLength=Math.min(o,this.lookAhead),this.matchLength>=3},t.prototype.updateHash=function(){this.currentHash=this.dataWindow[this.stringStart]<<this.hashShift^this.dataWindow[this.stringStart+1]},t.prototype.huffmanTallyLit=function(t){return this.arrDistances[this.bufferPosition]=0,this.arrLiterals[this.bufferPosition++]=t,this.treeLiteral.codeFrequencies[t]++,this.bufferPosition>=16384},t.prototype.huffmanTallyDist=function(t,e){this.arrDistances[this.bufferPosition]=t,this.arrLiterals[this.bufferPosition++]=e-3;var i=this.huffmanLengthCode(e-3);this.treeLiteral.codeFrequencies[i]++,i>=265&&i<285&&(this.extraBits+=Math.floor((i-261)/4));var n=this.huffmanDistanceCode(t-1);return this.treeDistances.codeFrequencies[n]++,n>=4&&(this.extraBits+=Math.floor(n/2-1)),this.bufferPosition>=16384},t.prototype.huffmanFlushBlock=function(t,e,i,n){this.treeLiteral.codeFrequencies[256]++,this.treeLiteral.buildTree(),this.treeDistances.buildTree(),this.treeLiteral.calculateBLFreq(this.treeCodeLengths),this.treeDistances.calculateBLFreq(this.treeCodeLengths),this.treeCodeLengths.buildTree();for(var r=4,s=18;s>r;s--)this.treeCodeLengths.codeLengths[c.huffCodeLengthOrders[s]]>0&&(r=s+1);for(var u=14+3*r+this.treeCodeLengths.getEncodedLength()+this.treeLiteral.getEncodedLength()+this.treeDistances.getEncodedLength()+this.extraBits,d=this.extraBits,s=0;s<286;s++)d+=this.treeLiteral.codeFrequencies[s]*h[s];for(s=0;s<30;s++)d+=this.treeDistances.codeFrequencies[s]*f[s];u>=d&&(u=d),e>=0&&i+4<u>>3?this.huffmanFlushStoredBlock(t,e,i,n):u==d?(this.pendingBufferWriteBits(2+(n?1:0),3),this.treeLiteral.setStaticCodes(o,h),this.treeDistances.setStaticCodes(a,f),this.huffmanCompressBlock(),this.huffmanReset()):(this.pendingBufferWriteBits(4+(n?1:0),3),this.huffmanSendAllTrees(r),this.huffmanCompressBlock(),this.huffmanReset())},t.prototype.huffmanFlushStoredBlock=function(t,e,i,n){this.pendingBufferWriteBits(0+(n?1:0),3),this.pendingBufferAlignToByte(),this.pendingBufferWriteShort(i),this.pendingBufferWriteShort(~i),this.pendingBufferWriteByteBlock(t,e,i),this.huffmanReset()},t.prototype.huffmanLengthCode=function(t){if(255===t)return 285;for(var e=257;t>=8;)e+=4,t>>=1;return e+t},t.prototype.huffmanDistanceCode=function(t){for(var e=0;t>=4;)e+=2,t>>=1;return e+t},t.prototype.huffmanSendAllTrees=function(t){this.treeCodeLengths.buildCodes(),this.treeLiteral.buildCodes(),this.treeDistances.buildCodes(),this.pendingBufferWriteBits(this.treeLiteral.treeLength-257,5),this.pendingBufferWriteBits(this.treeDistances.treeLength-1,5),this.pendingBufferWriteBits(t-4,4);for(var e=0;e<t;e++)this.pendingBufferWriteBits(this.treeCodeLengths.codeLengths[c.huffCodeLengthOrders[e]],3);this.treeLiteral.writeTree(this.treeCodeLengths),this.treeDistances.writeTree(this.treeCodeLengths)},t.prototype.huffmanReset=function(){this.bufferPosition=0,this.extraBits=0,this.treeLiteral.reset(),this.treeDistances.reset(),this.treeCodeLengths.reset()},t.prototype.huffmanCompressBlock=function(){for(var t=0;t<this.bufferPosition;t++){var e=255&this.arrLiterals[t],i=this.arrDistances[t];if(0!=i--){var n=this.huffmanLengthCode(e);this.treeLiteral.writeCodeToStream(n);var r=Math.floor((n-261)/4);r>0&&r<=5&&this.pendingBufferWriteBits(e&(1<<r)-1,r);var s=this.huffmanDistanceCode(i);this.treeDistances.writeCodeToStream(s),(r=Math.floor(s/2-1))>0&&this.pendingBufferWriteBits(i&(1<<r)-1,r)}else this.treeLiteral.writeCodeToStream(e)}this.treeLiteral.writeCodeToStream(256)},t.prototype.pendingBufferWriteBits=function(t,e){var i=new Uint32Array(1);i[0]=this.pendingBufCache|t<<this.pendingBufBitsInCache,this.pendingBufCache=i[0],this.pendingBufBitsInCache+=e,this.pendingBufferFlushBits()},t.prototype.pendingBufferFlush=function(t){if(this.pendingBufferFlushBits(),this.pendingBufLength>0){var e=new Uint8Array(this.pendingBufLength);e.set(this.pendingBuffer.subarray(0,this.pendingBufLength),0),this.stream.push(e)}this.pendingBufLength=0},t.prototype.pendingBufferFlushBits=function(){for(var t=0;this.pendingBufBitsInCache>=8&&this.pendingBufLength<65536;)this.pendingBuffer[this.pendingBufLength++]=this.pendingBufCache,this.pendingBufCache>>=8,this.pendingBufBitsInCache-=8,t++;return t},t.prototype.pendingBufferWriteByteBlock=function(t,e,i){var n=t.subarray(e,e+i);this.pendingBuffer.set(n,this.pendingBufLength),this.pendingBufLength+=i},t.prototype.pendingBufferWriteShort=function(t){this.pendingBuffer[this.pendingBufLength++]=t,this.pendingBuffer[this.pendingBufLength++]=t>>8},t.prototype.pendingBufferAlignToByte=function(){this.pendingBufBitsInCache>0&&(this.pendingBuffer[this.pendingBufLength++]=this.pendingBufCache),this.pendingBufCache=0,this.pendingBufBitsInCache=0},t.prototype.close=function(){do{this.pendingBufferFlush(!0),this.compressData(!0)||(this.pendingBufferFlush(!0),this.pendingBufferAlignToByte(),this.noWrap||(this.pendingBufferWriteShortBytes(this.checkSum>>16),this.pendingBufferWriteShortBytes(65535&this.checkSum)),this.pendingBufferFlush(!0))}while(this.inputEnd!==this.inputOffset||0!==this.pendingBufLength)},t.prototype.destroy=function(){this.stream=[],this.stream=void 0,this.pendingBuffer=void 0,this.treeLiteral=void 0,this.treeDistances=void 0,this.treeCodeLengths=void 0,this.arrLiterals=void 0,this.arrDistances=void 0,this.hashHead=void 0,this.hashPrevious=void 0,this.dataWindow=void 0,this.inputBuffer=void 0,this.pendingBufLength=void 0,this.pendingBufCache=void 0,this.pendingBufBitsInCache=void 0,this.bufferPosition=void 0,this.extraBits=void 0,this.currentHash=void 0,this.matchStart=void 0,this.matchLength=void 0,this.matchPrevAvail=void 0,this.blockStart=void 0,this.stringStart=void 0,this.lookAhead=void 0,this.totalBytesIn=void 0,this.inputOffset=void 0,this.inputEnd=void 0,this.windowSize=void 0,this.windowMask=void 0,this.hashSize=void 0,this.hashMask=void 0,this.hashShift=void 0,this.maxDist=void 0,this.checkSum=void 0,this.noWrap=void 0},t}(),c=function(){function t(t,e,i,n){this.writer=t,this.codeMinCount=i,this.maxLength=n,this.codeFrequency=new Uint16Array(e),this.lengthCount=new Int32Array(n)}return Object.defineProperty(t.prototype,"treeLength",{get:function(){return this.codeCount},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"codeLengths",{get:function(){return this.codeLength},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"codeFrequencies",{get:function(){return this.codeFrequency},enumerable:!0,configurable:!0}),t.prototype.setStaticCodes=function(t,e){var i=new Int16Array(t.length);i.set(t,0),this.codes=i;var n=new Uint8Array(e.length);n.set(e,0),this.codeLength=n},t.prototype.reset=function(){for(var t=0;t<this.codeFrequency.length;t++)this.codeFrequency[t]=0;this.codes=void 0,this.codeLength=void 0},t.prototype.writeCodeToStream=function(t){this.writer.pendingBufferWriteBits(65535&this.codes[t],this.codeLength[t])},t.prototype.buildCodes=function(){var e=new Int32Array(this.maxLength);this.codes=new Int16Array(this.codeCount);for(var i=0,n=0;n<this.maxLength;n++)e[n]=i,i+=this.lengthCount[n]<<15-n;for(var r=0;r<this.codeCount;r++){var s=this.codeLength[r];s>0&&(this.codes[r]=t.bitReverse(e[s-1]),e[s-1]+=1<<16-s)}},t.bitReverse=function(e){return t.reverseBits[15&e]<<12|t.reverseBits[e>>4&15]<<8|t.reverseBits[e>>8&15]<<4|t.reverseBits[e>>12]},t.prototype.getEncodedLength=function(){for(var t=0,e=0;e<this.codeFrequency.length;e++)t+=this.codeFrequency[e]*this.codeLength[e];return t},t.prototype.calculateBLFreq=function(t){for(var e,i,n,r=-1,s=0;s<this.codeCount;){n=1;var o=this.codeLength[s];for(0===o?(e=138,i=3):(e=6,i=3,r!==o&&(t.codeFrequency[o]++,n=0)),r=o,s++;s<this.codeCount&&r===this.codeLength[s]&&(s++,!(++n>=e)););n<i?t.codeFrequency[r]+=n:0!==r?t.codeFrequency[16]++:n<=10?t.codeFrequency[17]++:t.codeFrequency[18]++}},t.prototype.writeTree=function(t){for(var e,i,n,r=-1,s=0;s<this.codeCount;){n=1;var o=this.codeLength[s];for(0===o?(e=138,i=3):(e=6,i=3,r!==o&&(t.writeCodeToStream(o),n=0)),r=o,s++;s<this.codeCount&&r===this.codeLength[s]&&(s++,!(++n>=e)););if(n<i)for(;n-- >0;)t.writeCodeToStream(r);else 0!==r?(t.writeCodeToStream(16),this.writer.pendingBufferWriteBits(n-3,2)):n<=10?(t.writeCodeToStream(17),this.writer.pendingBufferWriteBits(n-3,3)):(t.writeCodeToStream(18),this.writer.pendingBufferWriteBits(n-11,7))}},t.prototype.buildTree=function(){for(var t=this.codeFrequency.length,e=new Int32Array(t),i=0,n=0,r=0;r<t;r++){var s=this.codeFrequency[r];if(0!==s){for(var o=i++,h=0;o>0&&this.codeFrequency[e[h=Math.floor((o-1)/2)]]>s;)e[o]=e[h],o=h;e[o]=r,n=r}}for(;i<2;)e[i++]=n<2?++n:0;this.codeCount=Math.max(n+1,this.codeMinCount);for(var a=i,f=new Int32Array(4*i-2),u=new Int32Array(2*i-1),c=0;c<i;c++){var d=e[c],p=2*c;f[p]=d,f[p+1]=-1,u[c]=this.codeFrequency[d]<<8,e[c]=c}this.constructHuffmanTree(e,i,u,a,f),this.buildLength(f)},t.prototype.constructHuffmanTree=function(t,e,i,n,r){do{for(var s=t[0],o=t[--e],h=i[o],a=0,f=1;f<e;)f+1<e&&i[t[f]]>i[t[f+1]]&&f++,t[a]=t[f],f=2*(a=f)+1;for(;(f=a)>0&&i[t[a=Math.floor((f-1)/2)]]>h;)t[f]=t[a];t[f]=o;var u=t[0];r[2*(o=n++)]=s,r[2*o+1]=u;var c=Math.min(255&i[s],255&i[u]);for(i[o]=h=i[s]+i[u]-c+1,a=0,f=1;f<e;)f+1<e&&i[t[f]]>i[t[f+1]]&&f++,t[a]=t[f],f=2*(a=f)+1;for(;(f=a)>0&&i[t[a=Math.floor((f-1)/2)]]>h;)t[f]=t[a];t[f]=o}while(e>1)},t.prototype.buildLength=function(t){this.codeLength=new Uint8Array(this.codeFrequency.length);for(var e=Math.floor(t.length/2),i=Math.floor((e+1)/2),n=0,r=0;r<this.maxLength;r++)this.lengthCount[r]=0;if(0!==(n=this.calculateOptimalCodeLength(t,n,e))){var s=this.maxLength-1;do{for(;0===this.lengthCount[--s];);do{this.lengthCount[s]--,this.lengthCount[++s]++,n-=1<<this.maxLength-1-s}while(n>0&&s<this.maxLength-1)}while(n>0);this.recreateTree(t,n,i)}},t.prototype.recreateTree=function(t,e,i){this.lengthCount[this.maxLength-1]+=e,this.lengthCount[this.maxLength-2]-=e;for(var n=2*i,r=this.maxLength;0!==r;r--)for(var s=this.lengthCount[r-1];s>0;){var o=2*t[n++];-1===t[o+1]&&(this.codeLength[t[o]]=r,s--)}},t.prototype.calculateOptimalCodeLength=function(t,e,i){var n=new Int32Array(i);n[i-1]=0;for(var r=i-1;r>=0;r--){var s=2*r+1;if(-1!==t[s])(o=n[r]+1)>this.maxLength&&(o=this.maxLength,e++),n[t[s-1]]=n[t[s]]=o;else{var o=n[r];this.lengthCount[o-1]++,this.codeLength[t[s-1]]=n[r]}}return e},t.reverseBits=[0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15],t.huffCodeLengthOrders=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],t}(),d=function(){function t(){}return t.checksumUpdate=function(e,i,n,r){var s=new Uint32Array(1);s[0]=e;for(var o=s[0],h=s[0]=65535&o,a=s[0]=o>>t.checkSumBitOffset;r>0;){var f=Math.min(r,t.checksumIterationCount);for(r-=f;--f>=0;)a+=h+=s[0]=255&i[n++];h%=t.checksumBase,a%=t.checksumBase}return o=a<<t.checkSumBitOffset|h},t.checkSumBitOffset=16,t.checksumBase=65521,t.checksumIterationCount=3800,t}();!function(){for(var t=0;t<144;)o[t]=c.bitReverse(48+t<<8),h[t++]=8;for(;t<256;)o[t]=c.bitReverse(256+t<<7),h[t++]=9;for(;t<280;)o[t]=c.bitReverse(-256+t<<9),h[t++]=7;for(;t<286;)o[t]=c.bitReverse(-88+t<<8),h[t++]=8;for(t=0;t<30;t++)a[t]=c.bitReverse(t<<11),f[t]=5}();var p=[],l=function(){function t(){this.files=[],this.level="Normal",n.isMicrosoftBrowser=!!navigator.msSaveBlob}return Object.defineProperty(t.prototype,"compressionLevel",{get:function(){return this.level},set:function(t){this.level=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){return void 0===this.files?0:this.files.length},enumerable:!0,configurable:!0}),t.prototype.addItem=function(t){if(null===t||void 0===t)throw new Error("ArgumentException: item cannot be null or undefined");for(var e=0;e<this.files.length;e++){var i=this.files[e];if(i instanceof g&&i.name===t.name)throw new Error("item with same name already exist")}this.files.push(t)},t.prototype.addDirectory=function(t){if(null===t||void 0===t)throw new Error("ArgumentException: string cannot be null or undefined");if(0===t.length)throw new Error("ArgumentException: string cannot be empty");if("/"!==t.slice(-1)&&(t+="/"),-1!==this.files.indexOf(t))throw new Error("item with same name already exist");this.files.push(t)},t.prototype.getItem=function(t){if(t>=0&&t<this.files.length)return this.files[t]},t.prototype.contains=function(t){return-1!==this.files.indexOf(t)},t.prototype.save=function(t){if(null===t||void 0===t||0===t.length)throw new Error("ArgumentException: fileName cannot be null or undefined");if(0===this.files.length)throw new Error("InvalidOperation");var e=this;return new Promise(function(i,n){e.saveInternal(t,!1).then(function(){i(e)})})},t.prototype.saveAsBlob=function(){var t=this;return new Promise(function(e,i){t.saveInternal("",!0).then(function(t){e(t)})})},t.prototype.saveInternal=function(t,e){var i=this,n=this;return new Promise(function(r,s){for(var o=[],h=0,a=0;a<n.files.length;a++)i.getCompressedData(i.files[a]).then(function(i){if(h=n.constructZippedObject(o,i,h,i.isDirectory),o.length===n.files.length){var s=n.writeZippedContent(t,o,h,e);r(s)}})})},t.prototype.destroy=function(){if(void 0!==this.files&&this.files.length>0){for(var t=0;t<this.files.length;t++){var e=this.files[t];e instanceof g&&e.destroy(),e=void 0}this.files=[]}this.files=void 0,this.level=void 0},t.prototype.getCompressedData=function(t){var e=this;return new Promise(function(i,n){if(t instanceof g){var r=new FileReader;r.onload=function(){var n=new Uint8Array(r.result),s={fileName:t.name,crc32Value:0,compressedData:[],compressedSize:void 0,uncompressedDataSize:n.length,compressionType:void 0,isDirectory:!1};if("Normal"===e.level){e.compressData(n,s,p);for(var o=0,h=0;h<s.compressedData.length;h++)o+=s.compressedData[h].length;s.compressedSize=o,s.compressionType="\b\0"}else s.compressedSize=n.length,s.crc32Value=e.calculateCrc32Value(0,n,p),s.compressionType="\0\0",s.compressedData.push(n);i(s)},r.readAsArrayBuffer(t.data)}else i({fileName:t,crc32Value:0,compressedData:"",compressedSize:0,uncompressedDataSize:0,compressionType:"\0\0",isDirectory:!0})})},t.prototype.compressData=function(t,e,i){var n=new u(!0),r=0,s=0;do{if(r>=t.length){n.close();break}s=Math.min(t.length,r+16384);var o=t.subarray(r,s);e.crc32Value=this.calculateCrc32Value(e.crc32Value,o,i),n.write(o,0,s-r),r=s}while(r<=t.length);e.compressedData=n.compressedData,n.destroy()},t.prototype.constructZippedObject=function(t,e,i,n){var r=0,s=new Date;n&&(r|=16),r|=0;var o=this.writeHeader(e,s),h="PK"+o+e.fileName,a=this.writeCentralDirectory(e,o,i,r);return t.push({localHeader:h,centralDir:a,compressedData:e}),i+h.length+e.compressedSize},t.prototype.writeHeader=function(t,e){var i="";return i+="\n\0\0\0",i+=t.compressionType,i+=this.getBytes(this.getModifiedTime(e),2),i+=this.getBytes(this.getModifiedDate(e),2),i+=this.getBytes(t.crc32Value,4),i+=this.getBytes(t.compressedSize,4),i+=this.getBytes(t.uncompressedDataSize,4),i+=this.getBytes(t.fileName.length,2),i+=this.getBytes(0,2)},t.prototype.writeZippedContent=function(t,e,i,r){for(var s=0,o=[],h=0;h<e.length;h++){var a=e[h];for(s+=a.centralDir.length,o.push(this.getArrayBuffer(a.localHeader));a.compressedData.compressedData.length;)o.push(a.compressedData.compressedData.shift().buffer)}for(h=0;h<e.length;h++)o.push(this.getArrayBuffer(e[h].centralDir));o.push(this.getArrayBuffer(this.writeFooter(e,s,i)));var f=new Blob(o,{type:"application/zip"});return r||n.save(t,f),f},t.prototype.writeCentralDirectory=function(t,e,i,n){return"PK"+this.getBytes(20,2)+e+this.getBytes(0,2)+"\0\0\0\0"+this.getBytes(n,4)+this.getBytes(i,4)+t.fileName},t.prototype.writeFooter=function(t,e,i){return"PK\0\0\0\0"+this.getBytes(t.length,2)+this.getBytes(t.length,2)+this.getBytes(e,4)+this.getBytes(i,4)+this.getBytes(0,2)},t.prototype.getArrayBuffer=function(t){for(var e=new Uint8Array(t.length),i=0;i<t.length;++i)e[i]=255&t.charCodeAt(i);return e.buffer},t.prototype.getBytes=function(t,e){for(var i="",n=0;n<e;n++)i+=String.fromCharCode(255&t),t>>>=8;return i},t.prototype.getModifiedTime=function(t){var e=t.getHours();return e<<=6,e|=t.getMinutes(),e<<=5,e|=t.getSeconds()/2},t.prototype.getModifiedDate=function(t){var e=t.getFullYear()-1980;return e<<=4,e|=t.getMonth()+1,e<<=5,e|=t.getDate()},t.prototype.calculateCrc32Value=function(t,e,i){t^=-1;for(var n=0;n<e.length;n++)t=t>>>8^i[255&(t^e[n])];return-1^t},t}(),g=function(){function t(t,e){if(null===t||void 0===t)throw new Error("ArgumentException: data cannot be null or undefined");if(null===e||void 0===e)throw new Error("ArgumentException: string cannot be null or undefined");if(0===e.length)throw new Error("string cannot be empty");this.data=t,this.name=e}return Object.defineProperty(t.prototype,"name",{get:function(){return this.fileName},set:function(t){this.fileName=t},enumerable:!0,configurable:!0}),t.prototype.destroy=function(){this.fileName=void 0,this.data=void 0},t}();!function(){for(var t,e=0;e<256;e++){t=e;for(var i=0;i<8;i++)t=1&t?3988292384^t>>>1:t>>>1;p[e]=t}}();var y=Object.freeze({ZipArchive:l,ZipArchiveItem:g,CompressedStreamWriter:u,CompressorHuffmanTree:c,ChecksumCalculator:d});return t.compression=y,t.fileutils=s,t}({}); | ||
//# sourceMappingURL=ej2-compression.min.js.map |
/*! | ||
* filename: index.d.ts | ||
* version : 16.1.26 | ||
* Copyright Syncfusion Inc. 2001 - 2017. All rights reserved. | ||
* version : 16.1.37 | ||
* Copyright Syncfusion Inc. 2001 - 2018. All rights reserved. | ||
* Use of this code is subject to the terms of our license. | ||
@@ -10,2 +10,11 @@ * A copy of the current license can be obtained at any time by e-mailing | ||
*/ | ||
/*! | ||
* filename: index.d.ts | ||
* version : 16.1.32 | ||
* Copyright Syncfusion Inc. 2001 - 2018. All rights reserved. | ||
* Use of this code is subject to the terms of our license. | ||
* A copy of the current license can be obtained at any time by e-mailing | ||
* licensing@syncfusion.com. Any infringement will be prosecuted under | ||
* applicable laws. | ||
*/ | ||
@@ -12,0 +21,0 @@ import * as _compression from '@syncfusion/ej2-compression'; |
{ | ||
"name": "@syncfusion/ej2-compression", | ||
"version": "16.1.32", | ||
"version": "16.1.37", | ||
"description": "Essential JS 2 Compression library", | ||
@@ -8,3 +8,3 @@ "author": "Syncfusion Inc.", | ||
"dependencies": { | ||
"@syncfusion/ej2-file-utils": "~16.1.32" | ||
"@syncfusion/ej2-file-utils": "~16.1.37" | ||
}, | ||
@@ -11,0 +11,0 @@ "devDependencies": { |
@@ -1,5 +0,1 @@ | ||
A common package of Essential JS 2 compression libraries, methods and class definitions. | ||
## Changelog | ||
Check the changelog [here](https://github.com/syncfusion/ej2-compression/blob/master/CHANGELOG.md) | ||
A common package of Essential JS 2 compression libraries, methods and class definitions. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
631394
4572
1