UrgentcareCLI 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -0
- data/Gemfile.lock +60 -25
- data/Notes +1 -1
- data/README.md +5 -5
- data/Rakefile +2 -0
- data/UrgentCare.gemspec +3 -3
- data/background.jpg +0 -0
- data/lib/UrgentCare.rb +3 -0
- data/lib/UrgentCare/CLI.rb +6 -2
- data/lib/UrgentCare/version.rb +1 -1
- data/lib/Urgentcare/Scraper.rb +65 -23
- data/node_modules/.bin/rimraf +1 -0
- data/node_modules/.package-lock.json +250 -0
- data/node_modules/balanced-match/.github/FUNDING.yml +2 -0
- data/node_modules/balanced-match/LICENSE.md +21 -0
- data/node_modules/balanced-match/README.md +97 -0
- data/node_modules/balanced-match/index.js +62 -0
- data/node_modules/balanced-match/package.json +48 -0
- data/node_modules/brace-expansion/LICENSE +21 -0
- data/node_modules/brace-expansion/README.md +129 -0
- data/node_modules/brace-expansion/index.js +201 -0
- data/node_modules/brace-expansion/package.json +47 -0
- data/node_modules/concat-map/.travis.yml +4 -0
- data/node_modules/concat-map/LICENSE +18 -0
- data/node_modules/concat-map/README.markdown +62 -0
- data/node_modules/concat-map/example/map.js +6 -0
- data/node_modules/concat-map/index.js +13 -0
- data/node_modules/concat-map/package.json +43 -0
- data/node_modules/concat-map/test/map.js +39 -0
- data/node_modules/core-util-is/LICENSE +19 -0
- data/node_modules/core-util-is/README.md +3 -0
- data/node_modules/core-util-is/float.patch +604 -0
- data/node_modules/core-util-is/lib/util.js +107 -0
- data/node_modules/core-util-is/package.json +32 -0
- data/node_modules/core-util-is/test.js +68 -0
- data/node_modules/fs.realpath/LICENSE +43 -0
- data/node_modules/fs.realpath/README.md +33 -0
- data/node_modules/fs.realpath/index.js +66 -0
- data/node_modules/fs.realpath/old.js +303 -0
- data/node_modules/fs.realpath/package.json +26 -0
- data/node_modules/glob/LICENSE +21 -0
- data/node_modules/glob/README.md +375 -0
- data/node_modules/glob/changelog.md +67 -0
- data/node_modules/glob/common.js +234 -0
- data/node_modules/glob/glob.js +788 -0
- data/node_modules/glob/package.json +51 -0
- data/node_modules/glob/sync.js +484 -0
- data/node_modules/immediate/LICENSE.txt +20 -0
- data/node_modules/immediate/README.md +93 -0
- data/node_modules/immediate/dist/immediate.js +75 -0
- data/node_modules/immediate/dist/immediate.min.js +1 -0
- data/node_modules/immediate/lib/browser.js +69 -0
- data/node_modules/immediate/lib/index.js +73 -0
- data/node_modules/immediate/package.json +42 -0
- data/node_modules/inflight/LICENSE +15 -0
- data/node_modules/inflight/README.md +37 -0
- data/node_modules/inflight/inflight.js +54 -0
- data/node_modules/inflight/package.json +29 -0
- data/node_modules/inherits/LICENSE +16 -0
- data/node_modules/inherits/README.md +42 -0
- data/node_modules/inherits/inherits.js +9 -0
- data/node_modules/inherits/inherits_browser.js +27 -0
- data/node_modules/inherits/package.json +29 -0
- data/node_modules/isarray/.npmignore +1 -0
- data/node_modules/isarray/.travis.yml +4 -0
- data/node_modules/isarray/Makefile +6 -0
- data/node_modules/isarray/README.md +60 -0
- data/node_modules/isarray/component.json +19 -0
- data/node_modules/isarray/index.js +5 -0
- data/node_modules/isarray/package.json +45 -0
- data/node_modules/isarray/test.js +20 -0
- data/node_modules/jszip/.codeclimate.yml +16 -0
- data/node_modules/jszip/.editorconfig +8 -0
- data/node_modules/jszip/.jshintignore +1 -0
- data/node_modules/jszip/.jshintrc +21 -0
- data/node_modules/jszip/.travis.yml +17 -0
- data/node_modules/jszip/CHANGES.md +163 -0
- data/node_modules/jszip/LICENSE.markdown +651 -0
- data/node_modules/jszip/README.markdown +35 -0
- data/node_modules/jszip/dist/jszip.js +30 -0
- data/node_modules/jszip/dist/jszip.min.js +13 -0
- data/node_modules/jszip/index.d.ts +270 -0
- data/node_modules/jszip/lib/base64.js +106 -0
- data/node_modules/jszip/lib/compressedObject.js +74 -0
- data/node_modules/jszip/lib/compressions.js +14 -0
- data/node_modules/jszip/lib/crc32.js +77 -0
- data/node_modules/jszip/lib/defaults.js +11 -0
- data/node_modules/jszip/lib/external.js +19 -0
- data/node_modules/jszip/lib/flate.js +85 -0
- data/node_modules/jszip/lib/generate/ZipFileWorker.js +540 -0
- data/node_modules/jszip/lib/generate/index.js +57 -0
- data/node_modules/jszip/lib/index.js +52 -0
- data/node_modules/jszip/lib/license_header.js +11 -0
- data/node_modules/jszip/lib/load.js +81 -0
- data/node_modules/jszip/lib/nodejs/NodejsStreamInputAdapter.js +74 -0
- data/node_modules/jszip/lib/nodejs/NodejsStreamOutputAdapter.js +42 -0
- data/node_modules/jszip/lib/nodejsUtils.js +57 -0
- data/node_modules/jszip/lib/object.js +389 -0
- data/node_modules/jszip/lib/readable-stream-browser.js +9 -0
- data/node_modules/jszip/lib/reader/ArrayReader.js +57 -0
- data/node_modules/jszip/lib/reader/DataReader.js +116 -0
- data/node_modules/jszip/lib/reader/NodeBufferReader.js +19 -0
- data/node_modules/jszip/lib/reader/StringReader.js +38 -0
- data/node_modules/jszip/lib/reader/Uint8ArrayReader.js +22 -0
- data/node_modules/jszip/lib/reader/readerFor.js +28 -0
- data/node_modules/jszip/lib/signature.js +7 -0
- data/node_modules/jszip/lib/stream/ConvertWorker.js +26 -0
- data/node_modules/jszip/lib/stream/Crc32Probe.js +24 -0
- data/node_modules/jszip/lib/stream/DataLengthProbe.js +29 -0
- data/node_modules/jszip/lib/stream/DataWorker.js +116 -0
- data/node_modules/jszip/lib/stream/GenericWorker.js +263 -0
- data/node_modules/jszip/lib/stream/StreamHelper.js +212 -0
- data/node_modules/jszip/lib/support.js +38 -0
- data/node_modules/jszip/lib/utf8.js +275 -0
- data/node_modules/jszip/lib/utils.js +476 -0
- data/node_modules/jszip/lib/zipEntries.js +262 -0
- data/node_modules/jszip/lib/zipEntry.js +294 -0
- data/node_modules/jszip/lib/zipObject.js +133 -0
- data/node_modules/jszip/package.json +63 -0
- data/node_modules/jszip/vendor/FileSaver.js +247 -0
- data/node_modules/lie/README.md +62 -0
- data/node_modules/lie/dist/lie.js +350 -0
- data/node_modules/lie/dist/lie.min.js +1 -0
- data/node_modules/lie/dist/lie.polyfill.js +358 -0
- data/node_modules/lie/dist/lie.polyfill.min.js +1 -0
- data/node_modules/lie/lib/browser.js +273 -0
- data/node_modules/lie/lib/index.js +298 -0
- data/node_modules/lie/license.md +7 -0
- data/node_modules/lie/lie.d.ts +244 -0
- data/node_modules/lie/package.json +69 -0
- data/node_modules/lie/polyfill.js +4 -0
- data/node_modules/minimatch/LICENSE +15 -0
- data/node_modules/minimatch/README.md +209 -0
- data/node_modules/minimatch/minimatch.js +923 -0
- data/node_modules/minimatch/package.json +30 -0
- data/node_modules/once/LICENSE +15 -0
- data/node_modules/once/README.md +79 -0
- data/node_modules/once/once.js +42 -0
- data/node_modules/once/package.json +33 -0
- data/node_modules/pako/CHANGELOG.md +164 -0
- data/node_modules/pako/LICENSE +21 -0
- data/node_modules/pako/README.md +191 -0
- data/node_modules/pako/dist/pako.js +6818 -0
- data/node_modules/pako/dist/pako.min.js +1 -0
- data/node_modules/pako/dist/pako_deflate.js +3997 -0
- data/node_modules/pako/dist/pako_deflate.min.js +1 -0
- data/node_modules/pako/dist/pako_inflate.js +3300 -0
- data/node_modules/pako/dist/pako_inflate.min.js +1 -0
- data/node_modules/pako/index.js +14 -0
- data/node_modules/pako/lib/deflate.js +400 -0
- data/node_modules/pako/lib/inflate.js +423 -0
- data/node_modules/pako/lib/utils/common.js +105 -0
- data/node_modules/pako/lib/utils/strings.js +187 -0
- data/node_modules/pako/lib/zlib/README +59 -0
- data/node_modules/pako/lib/zlib/adler32.js +51 -0
- data/node_modules/pako/lib/zlib/constants.js +68 -0
- data/node_modules/pako/lib/zlib/crc32.js +59 -0
- data/node_modules/pako/lib/zlib/deflate.js +1874 -0
- data/node_modules/pako/lib/zlib/gzheader.js +58 -0
- data/node_modules/pako/lib/zlib/inffast.js +345 -0
- data/node_modules/pako/lib/zlib/inflate.js +1556 -0
- data/node_modules/pako/lib/zlib/inftrees.js +343 -0
- data/node_modules/pako/lib/zlib/messages.js +32 -0
- data/node_modules/pako/lib/zlib/trees.js +1222 -0
- data/node_modules/pako/lib/zlib/zstream.js +47 -0
- data/node_modules/pako/package.json +44 -0
- data/node_modules/path-is-absolute/index.js +20 -0
- data/node_modules/path-is-absolute/license +21 -0
- data/node_modules/path-is-absolute/package.json +43 -0
- data/node_modules/path-is-absolute/readme.md +59 -0
- data/node_modules/process-nextick-args/index.js +45 -0
- data/node_modules/process-nextick-args/license.md +19 -0
- data/node_modules/process-nextick-args/package.json +25 -0
- data/node_modules/process-nextick-args/readme.md +18 -0
- data/node_modules/readable-stream/.travis.yml +34 -0
- data/node_modules/readable-stream/CONTRIBUTING.md +38 -0
- data/node_modules/readable-stream/GOVERNANCE.md +136 -0
- data/node_modules/readable-stream/LICENSE +47 -0
- data/node_modules/readable-stream/README.md +58 -0
- data/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +60 -0
- data/node_modules/readable-stream/duplex-browser.js +1 -0
- data/node_modules/readable-stream/duplex.js +1 -0
- data/node_modules/readable-stream/lib/_stream_duplex.js +131 -0
- data/node_modules/readable-stream/lib/_stream_passthrough.js +47 -0
- data/node_modules/readable-stream/lib/_stream_readable.js +1019 -0
- data/node_modules/readable-stream/lib/_stream_transform.js +214 -0
- data/node_modules/readable-stream/lib/_stream_writable.js +687 -0
- data/node_modules/readable-stream/lib/internal/streams/BufferList.js +79 -0
- data/node_modules/readable-stream/lib/internal/streams/destroy.js +74 -0
- data/node_modules/readable-stream/lib/internal/streams/stream-browser.js +1 -0
- data/node_modules/readable-stream/lib/internal/streams/stream.js +1 -0
- data/node_modules/readable-stream/package.json +52 -0
- data/node_modules/readable-stream/passthrough.js +1 -0
- data/node_modules/readable-stream/readable-browser.js +7 -0
- data/node_modules/readable-stream/readable.js +19 -0
- data/node_modules/readable-stream/transform.js +1 -0
- data/node_modules/readable-stream/writable-browser.js +1 -0
- data/node_modules/readable-stream/writable.js +8 -0
- data/node_modules/rimraf/LICENSE +15 -0
- data/node_modules/rimraf/README.md +101 -0
- data/node_modules/rimraf/bin.js +50 -0
- data/node_modules/rimraf/package.json +29 -0
- data/node_modules/rimraf/rimraf.js +372 -0
- data/node_modules/safe-buffer/LICENSE +21 -0
- data/node_modules/safe-buffer/README.md +584 -0
- data/node_modules/safe-buffer/index.d.ts +187 -0
- data/node_modules/safe-buffer/index.js +62 -0
- data/node_modules/safe-buffer/package.json +37 -0
- data/node_modules/selenium-webdriver/CHANGES.md +1114 -0
- data/node_modules/selenium-webdriver/LICENSE +202 -0
- data/node_modules/selenium-webdriver/NOTICE +2 -0
- data/node_modules/selenium-webdriver/README.md +229 -0
- data/node_modules/selenium-webdriver/chrome.js +295 -0
- data/node_modules/selenium-webdriver/chromium.js +829 -0
- data/node_modules/selenium-webdriver/devtools/CDPConnection.js +35 -0
- data/node_modules/selenium-webdriver/edge.js +224 -0
- data/node_modules/selenium-webdriver/example/chrome_android.js +45 -0
- data/node_modules/selenium-webdriver/example/chrome_mobile_emulation.js +46 -0
- data/node_modules/selenium-webdriver/example/firefox_channels.js +84 -0
- data/node_modules/selenium-webdriver/example/google_search.js +50 -0
- data/node_modules/selenium-webdriver/example/google_search_test.js +70 -0
- data/node_modules/selenium-webdriver/example/headless.js +63 -0
- data/node_modules/selenium-webdriver/example/logging.js +64 -0
- data/node_modules/selenium-webdriver/firefox.js +789 -0
- data/node_modules/selenium-webdriver/http/index.js +324 -0
- data/node_modules/selenium-webdriver/http/util.js +172 -0
- data/node_modules/selenium-webdriver/ie.js +503 -0
- data/node_modules/selenium-webdriver/index.js +825 -0
- data/node_modules/selenium-webdriver/io/exec.js +162 -0
- data/node_modules/selenium-webdriver/io/index.js +348 -0
- data/node_modules/selenium-webdriver/io/zip.js +223 -0
- data/node_modules/selenium-webdriver/lib/atoms/find-elements.js +123 -0
- data/node_modules/selenium-webdriver/lib/atoms/get-attribute.js +101 -0
- data/node_modules/selenium-webdriver/lib/atoms/is-displayed.js +101 -0
- data/node_modules/selenium-webdriver/lib/atoms/mutation-listener.js +55 -0
- data/node_modules/selenium-webdriver/lib/by.js +415 -0
- data/node_modules/selenium-webdriver/lib/capabilities.js +553 -0
- data/node_modules/selenium-webdriver/lib/command.js +206 -0
- data/node_modules/selenium-webdriver/lib/error.js +605 -0
- data/node_modules/selenium-webdriver/lib/http.js +704 -0
- data/node_modules/selenium-webdriver/lib/input.js +946 -0
- data/node_modules/selenium-webdriver/lib/logging.js +661 -0
- data/node_modules/selenium-webdriver/lib/promise.js +285 -0
- data/node_modules/selenium-webdriver/lib/proxy.js +212 -0
- data/node_modules/selenium-webdriver/lib/session.js +77 -0
- data/node_modules/selenium-webdriver/lib/symbols.js +37 -0
- data/node_modules/selenium-webdriver/lib/until.js +429 -0
- data/node_modules/selenium-webdriver/lib/webdriver.js +2919 -0
- data/node_modules/selenium-webdriver/net/index.js +107 -0
- data/node_modules/selenium-webdriver/net/portprober.js +75 -0
- data/node_modules/selenium-webdriver/opera.js +406 -0
- data/node_modules/selenium-webdriver/package.json +54 -0
- data/node_modules/selenium-webdriver/proxy.js +32 -0
- data/node_modules/selenium-webdriver/remote/index.js +624 -0
- data/node_modules/selenium-webdriver/safari.js +168 -0
- data/node_modules/selenium-webdriver/testing/index.js +504 -0
- data/node_modules/set-immediate-shim/index.js +7 -0
- data/node_modules/set-immediate-shim/package.json +34 -0
- data/node_modules/set-immediate-shim/readme.md +31 -0
- data/node_modules/string_decoder/.travis.yml +50 -0
- data/node_modules/string_decoder/LICENSE +48 -0
- data/node_modules/string_decoder/README.md +47 -0
- data/node_modules/string_decoder/lib/string_decoder.js +296 -0
- data/node_modules/string_decoder/package.json +31 -0
- data/node_modules/tmp/CHANGELOG.md +288 -0
- data/node_modules/tmp/LICENSE +21 -0
- data/node_modules/tmp/README.md +365 -0
- data/node_modules/tmp/lib/tmp.js +780 -0
- data/node_modules/tmp/node_modules/.bin/rimraf +1 -0
- data/node_modules/tmp/node_modules/rimraf/CHANGELOG.md +65 -0
- data/node_modules/tmp/node_modules/rimraf/LICENSE +15 -0
- data/node_modules/tmp/node_modules/rimraf/README.md +101 -0
- data/node_modules/tmp/node_modules/rimraf/bin.js +68 -0
- data/node_modules/tmp/node_modules/rimraf/package.json +32 -0
- data/node_modules/tmp/node_modules/rimraf/rimraf.js +360 -0
- data/node_modules/tmp/package.json +58 -0
- data/node_modules/util-deprecate/History.md +16 -0
- data/node_modules/util-deprecate/LICENSE +24 -0
- data/node_modules/util-deprecate/README.md +53 -0
- data/node_modules/util-deprecate/browser.js +67 -0
- data/node_modules/util-deprecate/node.js +6 -0
- data/node_modules/util-deprecate/package.json +27 -0
- data/node_modules/wrappy/LICENSE +15 -0
- data/node_modules/wrappy/README.md +36 -0
- data/node_modules/wrappy/package.json +29 -0
- data/node_modules/wrappy/wrappy.js +33 -0
- data/node_modules/ws/LICENSE +21 -0
- data/node_modules/ws/README.md +496 -0
- data/node_modules/ws/browser.js +8 -0
- data/node_modules/ws/index.js +10 -0
- data/node_modules/ws/lib/buffer-util.js +129 -0
- data/node_modules/ws/lib/constants.js +10 -0
- data/node_modules/ws/lib/event-target.js +184 -0
- data/node_modules/ws/lib/extension.js +223 -0
- data/node_modules/ws/lib/limiter.js +55 -0
- data/node_modules/ws/lib/permessage-deflate.js +517 -0
- data/node_modules/ws/lib/receiver.js +507 -0
- data/node_modules/ws/lib/sender.js +405 -0
- data/node_modules/ws/lib/stream.js +165 -0
- data/node_modules/ws/lib/validation.js +104 -0
- data/node_modules/ws/lib/websocket-server.js +418 -0
- data/node_modules/ws/lib/websocket.js +942 -0
- data/node_modules/ws/package.json +56 -0
- data/package-lock.json +458 -0
- data/package.json +5 -0
- data/selenium.log +1 -0
- metadata +314 -19
@@ -0,0 +1 @@
|
|
1
|
+
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).pako=e()}}(function(){return function r(o,s,f){function l(t,e){if(!s[t]){if(!o[t]){var i="function"==typeof require&&require;if(!e&&i)return i(t,!0);if(d)return d(t,!0);var n=new Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}var a=s[t]={exports:{}};o[t][0].call(a.exports,function(e){return l(o[t][1][e]||e)},a,a.exports,r,o,s,f)}return s[t].exports}for(var d="function"==typeof require&&require,e=0;e<f.length;e++)l(f[e]);return l}({1:[function(e,t,i){"use strict";var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;i.assign=function(e){for(var t,i,n=Array.prototype.slice.call(arguments,1);n.length;){var a=n.shift();if(a){if("object"!=typeof a)throw new TypeError(a+"must be non-object");for(var r in a)t=a,i=r,Object.prototype.hasOwnProperty.call(t,i)&&(e[r]=a[r])}}return e},i.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var a={arraySet:function(e,t,i,n,a){if(t.subarray&&e.subarray)e.set(t.subarray(i,i+n),a);else for(var r=0;r<n;r++)e[a+r]=t[i+r]},flattenChunks:function(e){var t,i,n,a,r,o;for(t=n=0,i=e.length;t<i;t++)n+=e[t].length;for(o=new Uint8Array(n),t=a=0,i=e.length;t<i;t++)r=e[t],o.set(r,a),a+=r.length;return o}},r={arraySet:function(e,t,i,n,a){for(var r=0;r<n;r++)e[a+r]=t[i+r]},flattenChunks:function(e){return[].concat.apply([],e)}};i.setTyped=function(e){e?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,a)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,r))},i.setTyped(n)},{}],2:[function(e,t,i){"use strict";var f=e("./common"),a=!0,r=!0;try{String.fromCharCode.apply(null,[0])}catch(e){a=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){r=!1}for(var l=new f.Buf8(256),n=0;n<256;n++)l[n]=252<=n?6:248<=n?5:240<=n?4:224<=n?3:192<=n?2:1;function d(e,t){if(t<65534&&(e.subarray&&r||!e.subarray&&a))return String.fromCharCode.apply(null,f.shrinkBuf(e,t));for(var i="",n=0;n<t;n++)i+=String.fromCharCode(e[n]);return i}l[254]=l[254]=1,i.string2buf=function(e){var t,i,n,a,r,o=e.length,s=0;for(a=0;a<o;a++)55296==(64512&(i=e.charCodeAt(a)))&&a+1<o&&56320==(64512&(n=e.charCodeAt(a+1)))&&(i=65536+(i-55296<<10)+(n-56320),a++),s+=i<128?1:i<2048?2:i<65536?3:4;for(t=new f.Buf8(s),a=r=0;r<s;a++)55296==(64512&(i=e.charCodeAt(a)))&&a+1<o&&56320==(64512&(n=e.charCodeAt(a+1)))&&(i=65536+(i-55296<<10)+(n-56320),a++),i<128?t[r++]=i:(i<2048?t[r++]=192|i>>>6:(i<65536?t[r++]=224|i>>>12:(t[r++]=240|i>>>18,t[r++]=128|i>>>12&63),t[r++]=128|i>>>6&63),t[r++]=128|63&i);return t},i.buf2binstring=function(e){return d(e,e.length)},i.binstring2buf=function(e){for(var t=new f.Buf8(e.length),i=0,n=t.length;i<n;i++)t[i]=e.charCodeAt(i);return t},i.buf2string=function(e,t){var i,n,a,r,o=t||e.length,s=new Array(2*o);for(i=n=0;i<o;)if((a=e[i++])<128)s[n++]=a;else if(4<(r=l[a]))s[n++]=65533,i+=r-1;else{for(a&=2===r?31:3===r?15:7;1<r&&i<o;)a=a<<6|63&e[i++],r--;1<r?s[n++]=65533:a<65536?s[n++]=a:(a-=65536,s[n++]=55296|a>>10&1023,s[n++]=56320|1023&a)}return d(s,n)},i.utf8border=function(e,t){var i;for((t=t||e.length)>e.length&&(t=e.length),i=t-1;0<=i&&128==(192&e[i]);)i--;return i<0?t:0===i?t:i+l[e[i]]>t?i:t}},{"./common":1}],3:[function(e,t,i){"use strict";t.exports=function(e,t,i,n){for(var a=65535&e|0,r=e>>>16&65535|0,o=0;0!==i;){for(i-=o=2e3<i?2e3:i;r=r+(a=a+t[n++]|0)|0,--o;);a%=65521,r%=65521}return a|r<<16|0}},{}],4:[function(e,t,i){"use strict";t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],5:[function(e,t,i){"use strict";var s=function(){for(var e,t=[],i=0;i<256;i++){e=i;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t}();t.exports=function(e,t,i,n){var a=s,r=n+i;e^=-1;for(var o=n;o<r;o++)e=e>>>8^a[255&(e^t[o])];return-1^e}},{}],6:[function(e,t,i){"use strict";t.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],7:[function(e,t,i){"use strict";t.exports=function(e,t){var i,n,a,r,o,s,f,l,d,c,u,h,b,m,w,k,_,g,v,p,x,y,S,E,Z;i=e.state,n=e.next_in,E=e.input,a=n+(e.avail_in-5),r=e.next_out,Z=e.output,o=r-(t-e.avail_out),s=r+(e.avail_out-257),f=i.dmax,l=i.wsize,d=i.whave,c=i.wnext,u=i.window,h=i.hold,b=i.bits,m=i.lencode,w=i.distcode,k=(1<<i.lenbits)-1,_=(1<<i.distbits)-1;e:do{b<15&&(h+=E[n++]<<b,b+=8,h+=E[n++]<<b,b+=8),g=m[h&k];t:for(;;){if(h>>>=v=g>>>24,b-=v,0===(v=g>>>16&255))Z[r++]=65535&g;else{if(!(16&v)){if(0==(64&v)){g=m[(65535&g)+(h&(1<<v)-1)];continue t}if(32&v){i.mode=12;break e}e.msg="invalid literal/length code",i.mode=30;break e}p=65535&g,(v&=15)&&(b<v&&(h+=E[n++]<<b,b+=8),p+=h&(1<<v)-1,h>>>=v,b-=v),b<15&&(h+=E[n++]<<b,b+=8,h+=E[n++]<<b,b+=8),g=w[h&_];i:for(;;){if(h>>>=v=g>>>24,b-=v,!(16&(v=g>>>16&255))){if(0==(64&v)){g=w[(65535&g)+(h&(1<<v)-1)];continue i}e.msg="invalid distance code",i.mode=30;break e}if(x=65535&g,b<(v&=15)&&(h+=E[n++]<<b,(b+=8)<v&&(h+=E[n++]<<b,b+=8)),f<(x+=h&(1<<v)-1)){e.msg="invalid distance too far back",i.mode=30;break e}if(h>>>=v,b-=v,(v=r-o)<x){if(d<(v=x-v)&&i.sane){e.msg="invalid distance too far back",i.mode=30;break e}if(S=u,(y=0)===c){if(y+=l-v,v<p){for(p-=v;Z[r++]=u[y++],--v;);y=r-x,S=Z}}else if(c<v){if(y+=l+c-v,(v-=c)<p){for(p-=v;Z[r++]=u[y++],--v;);if(y=0,c<p){for(p-=v=c;Z[r++]=u[y++],--v;);y=r-x,S=Z}}}else if(y+=c-v,v<p){for(p-=v;Z[r++]=u[y++],--v;);y=r-x,S=Z}for(;2<p;)Z[r++]=S[y++],Z[r++]=S[y++],Z[r++]=S[y++],p-=3;p&&(Z[r++]=S[y++],1<p&&(Z[r++]=S[y++]))}else{for(y=r-x;Z[r++]=Z[y++],Z[r++]=Z[y++],Z[r++]=Z[y++],2<(p-=3););p&&(Z[r++]=Z[y++],1<p&&(Z[r++]=Z[y++]))}break}}break}}while(n<a&&r<s);n-=p=b>>3,h&=(1<<(b-=p<<3))-1,e.next_in=n,e.next_out=r,e.avail_in=n<a?a-n+5:5-(n-a),e.avail_out=r<s?s-r+257:257-(r-s),i.hold=h,i.bits=b}},{}],8:[function(e,t,i){"use strict";var z=e("../utils/common"),R=e("./adler32"),N=e("./crc32"),O=e("./inffast"),C=e("./inftrees"),I=1,D=2,T=0,U=-2,F=1,n=852,a=592;function L(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function r(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new z.Buf16(320),this.work=new z.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function o(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=F,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new z.Buf32(n),t.distcode=t.distdyn=new z.Buf32(a),t.sane=1,t.back=-1,T):U}function s(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,o(e)):U}function f(e,t){var i,n;return e&&e.state?(n=e.state,t<0?(i=0,t=-t):(i=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15<t)?U:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=i,n.wbits=t,s(e))):U}function l(e,t){var i,n;return e?(n=new r,(e.state=n).window=null,(i=f(e,t))!==T&&(e.state=null),i):U}var d,c,u=!0;function H(e){if(u){var t;for(d=new z.Buf32(512),c=new z.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(C(I,e.lens,0,288,d,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;C(D,e.lens,0,32,c,0,e.work,{bits:5}),u=!1}e.lencode=d,e.lenbits=9,e.distcode=c,e.distbits=5}function j(e,t,i,n){var a,r=e.state;return null===r.window&&(r.wsize=1<<r.wbits,r.wnext=0,r.whave=0,r.window=new z.Buf8(r.wsize)),n>=r.wsize?(z.arraySet(r.window,t,i-r.wsize,r.wsize,0),r.wnext=0,r.whave=r.wsize):(n<(a=r.wsize-r.wnext)&&(a=n),z.arraySet(r.window,t,i-n,a,r.wnext),(n-=a)?(z.arraySet(r.window,t,i-n,n,0),r.wnext=n,r.whave=r.wsize):(r.wnext+=a,r.wnext===r.wsize&&(r.wnext=0),r.whave<r.wsize&&(r.whave+=a))),0}i.inflateReset=s,i.inflateReset2=f,i.inflateResetKeep=o,i.inflateInit=function(e){return l(e,15)},i.inflateInit2=l,i.inflate=function(e,t){var i,n,a,r,o,s,f,l,d,c,u,h,b,m,w,k,_,g,v,p,x,y,S,E,Z=0,B=new z.Buf8(4),A=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return U;12===(i=e.state).mode&&(i.mode=13),o=e.next_out,a=e.output,f=e.avail_out,r=e.next_in,n=e.input,s=e.avail_in,l=i.hold,d=i.bits,c=s,u=f,y=T;e:for(;;)switch(i.mode){case F:if(0===i.wrap){i.mode=13;break}for(;d<16;){if(0===s)break e;s--,l+=n[r++]<<d,d+=8}if(2&i.wrap&&35615===l){B[i.check=0]=255&l,B[1]=l>>>8&255,i.check=N(i.check,B,2,0),d=l=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&l)<<8)+(l>>8))%31){e.msg="incorrect header check",i.mode=30;break}if(8!=(15&l)){e.msg="unknown compression method",i.mode=30;break}if(d-=4,x=8+(15&(l>>>=4)),0===i.wbits)i.wbits=x;else if(x>i.wbits){e.msg="invalid window size",i.mode=30;break}i.dmax=1<<x,e.adler=i.check=1,i.mode=512&l?10:12,d=l=0;break;case 2:for(;d<16;){if(0===s)break e;s--,l+=n[r++]<<d,d+=8}if(i.flags=l,8!=(255&i.flags)){e.msg="unknown compression method",i.mode=30;break}if(57344&i.flags){e.msg="unknown header flags set",i.mode=30;break}i.head&&(i.head.text=l>>8&1),512&i.flags&&(B[0]=255&l,B[1]=l>>>8&255,i.check=N(i.check,B,2,0)),d=l=0,i.mode=3;case 3:for(;d<32;){if(0===s)break e;s--,l+=n[r++]<<d,d+=8}i.head&&(i.head.time=l),512&i.flags&&(B[0]=255&l,B[1]=l>>>8&255,B[2]=l>>>16&255,B[3]=l>>>24&255,i.check=N(i.check,B,4,0)),d=l=0,i.mode=4;case 4:for(;d<16;){if(0===s)break e;s--,l+=n[r++]<<d,d+=8}i.head&&(i.head.xflags=255&l,i.head.os=l>>8),512&i.flags&&(B[0]=255&l,B[1]=l>>>8&255,i.check=N(i.check,B,2,0)),d=l=0,i.mode=5;case 5:if(1024&i.flags){for(;d<16;){if(0===s)break e;s--,l+=n[r++]<<d,d+=8}i.length=l,i.head&&(i.head.extra_len=l),512&i.flags&&(B[0]=255&l,B[1]=l>>>8&255,i.check=N(i.check,B,2,0)),d=l=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&(s<(h=i.length)&&(h=s),h&&(i.head&&(x=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),z.arraySet(i.head.extra,n,r,h,x)),512&i.flags&&(i.check=N(i.check,n,h,r)),s-=h,r+=h,i.length-=h),i.length))break e;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===s)break e;for(h=0;x=n[r+h++],i.head&&x&&i.length<65536&&(i.head.name+=String.fromCharCode(x)),x&&h<s;);if(512&i.flags&&(i.check=N(i.check,n,h,r)),s-=h,r+=h,x)break e}else i.head&&(i.head.name=null);i.length=0,i.mode=8;case 8:if(4096&i.flags){if(0===s)break e;for(h=0;x=n[r+h++],i.head&&x&&i.length<65536&&(i.head.comment+=String.fromCharCode(x)),x&&h<s;);if(512&i.flags&&(i.check=N(i.check,n,h,r)),s-=h,r+=h,x)break e}else i.head&&(i.head.comment=null);i.mode=9;case 9:if(512&i.flags){for(;d<16;){if(0===s)break e;s--,l+=n[r++]<<d,d+=8}if(l!==(65535&i.check)){e.msg="header crc mismatch",i.mode=30;break}d=l=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=12;break;case 10:for(;d<32;){if(0===s)break e;s--,l+=n[r++]<<d,d+=8}e.adler=i.check=L(l),d=l=0,i.mode=11;case 11:if(0===i.havedict)return e.next_out=o,e.avail_out=f,e.next_in=r,e.avail_in=s,i.hold=l,i.bits=d,2;e.adler=i.check=1,i.mode=12;case 12:if(5===t||6===t)break e;case 13:if(i.last){l>>>=7&d,d-=7&d,i.mode=27;break}for(;d<3;){if(0===s)break e;s--,l+=n[r++]<<d,d+=8}switch(i.last=1&l,d-=1,3&(l>>>=1)){case 0:i.mode=14;break;case 1:if(H(i),i.mode=20,6!==t)break;l>>>=2,d-=2;break e;case 2:i.mode=17;break;case 3:e.msg="invalid block type",i.mode=30}l>>>=2,d-=2;break;case 14:for(l>>>=7&d,d-=7&d;d<32;){if(0===s)break e;s--,l+=n[r++]<<d,d+=8}if((65535&l)!=(l>>>16^65535)){e.msg="invalid stored block lengths",i.mode=30;break}if(i.length=65535&l,d=l=0,i.mode=15,6===t)break e;case 15:i.mode=16;case 16:if(h=i.length){if(s<h&&(h=s),f<h&&(h=f),0===h)break e;z.arraySet(a,n,r,h,o),s-=h,r+=h,f-=h,o+=h,i.length-=h;break}i.mode=12;break;case 17:for(;d<14;){if(0===s)break e;s--,l+=n[r++]<<d,d+=8}if(i.nlen=257+(31&l),l>>>=5,d-=5,i.ndist=1+(31&l),l>>>=5,d-=5,i.ncode=4+(15&l),l>>>=4,d-=4,286<i.nlen||30<i.ndist){e.msg="too many length or distance symbols",i.mode=30;break}i.have=0,i.mode=18;case 18:for(;i.have<i.ncode;){for(;d<3;){if(0===s)break e;s--,l+=n[r++]<<d,d+=8}i.lens[A[i.have++]]=7&l,l>>>=3,d-=3}for(;i.have<19;)i.lens[A[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,S={bits:i.lenbits},y=C(0,i.lens,0,19,i.lencode,0,i.work,S),i.lenbits=S.bits,y){e.msg="invalid code lengths set",i.mode=30;break}i.have=0,i.mode=19;case 19:for(;i.have<i.nlen+i.ndist;){for(;k=(Z=i.lencode[l&(1<<i.lenbits)-1])>>>16&255,_=65535&Z,!((w=Z>>>24)<=d);){if(0===s)break e;s--,l+=n[r++]<<d,d+=8}if(_<16)l>>>=w,d-=w,i.lens[i.have++]=_;else{if(16===_){for(E=w+2;d<E;){if(0===s)break e;s--,l+=n[r++]<<d,d+=8}if(l>>>=w,d-=w,0===i.have){e.msg="invalid bit length repeat",i.mode=30;break}x=i.lens[i.have-1],h=3+(3&l),l>>>=2,d-=2}else if(17===_){for(E=w+3;d<E;){if(0===s)break e;s--,l+=n[r++]<<d,d+=8}d-=w,x=0,h=3+(7&(l>>>=w)),l>>>=3,d-=3}else{for(E=w+7;d<E;){if(0===s)break e;s--,l+=n[r++]<<d,d+=8}d-=w,x=0,h=11+(127&(l>>>=w)),l>>>=7,d-=7}if(i.have+h>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=30;break}for(;h--;)i.lens[i.have++]=x}}if(30===i.mode)break;if(0===i.lens[256]){e.msg="invalid code -- missing end-of-block",i.mode=30;break}if(i.lenbits=9,S={bits:i.lenbits},y=C(I,i.lens,0,i.nlen,i.lencode,0,i.work,S),i.lenbits=S.bits,y){e.msg="invalid literal/lengths set",i.mode=30;break}if(i.distbits=6,i.distcode=i.distdyn,S={bits:i.distbits},y=C(D,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,S),i.distbits=S.bits,y){e.msg="invalid distances set",i.mode=30;break}if(i.mode=20,6===t)break e;case 20:i.mode=21;case 21:if(6<=s&&258<=f){e.next_out=o,e.avail_out=f,e.next_in=r,e.avail_in=s,i.hold=l,i.bits=d,O(e,u),o=e.next_out,a=e.output,f=e.avail_out,r=e.next_in,n=e.input,s=e.avail_in,l=i.hold,d=i.bits,12===i.mode&&(i.back=-1);break}for(i.back=0;k=(Z=i.lencode[l&(1<<i.lenbits)-1])>>>16&255,_=65535&Z,!((w=Z>>>24)<=d);){if(0===s)break e;s--,l+=n[r++]<<d,d+=8}if(k&&0==(240&k)){for(g=w,v=k,p=_;k=(Z=i.lencode[p+((l&(1<<g+v)-1)>>g)])>>>16&255,_=65535&Z,!(g+(w=Z>>>24)<=d);){if(0===s)break e;s--,l+=n[r++]<<d,d+=8}l>>>=g,d-=g,i.back+=g}if(l>>>=w,d-=w,i.back+=w,i.length=_,0===k){i.mode=26;break}if(32&k){i.back=-1,i.mode=12;break}if(64&k){e.msg="invalid literal/length code",i.mode=30;break}i.extra=15&k,i.mode=22;case 22:if(i.extra){for(E=i.extra;d<E;){if(0===s)break e;s--,l+=n[r++]<<d,d+=8}i.length+=l&(1<<i.extra)-1,l>>>=i.extra,d-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;k=(Z=i.distcode[l&(1<<i.distbits)-1])>>>16&255,_=65535&Z,!((w=Z>>>24)<=d);){if(0===s)break e;s--,l+=n[r++]<<d,d+=8}if(0==(240&k)){for(g=w,v=k,p=_;k=(Z=i.distcode[p+((l&(1<<g+v)-1)>>g)])>>>16&255,_=65535&Z,!(g+(w=Z>>>24)<=d);){if(0===s)break e;s--,l+=n[r++]<<d,d+=8}l>>>=g,d-=g,i.back+=g}if(l>>>=w,d-=w,i.back+=w,64&k){e.msg="invalid distance code",i.mode=30;break}i.offset=_,i.extra=15&k,i.mode=24;case 24:if(i.extra){for(E=i.extra;d<E;){if(0===s)break e;s--,l+=n[r++]<<d,d+=8}i.offset+=l&(1<<i.extra)-1,l>>>=i.extra,d-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=30;break}i.mode=25;case 25:if(0===f)break e;if(h=u-f,i.offset>h){if((h=i.offset-h)>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=30;break}h>i.wnext?(h-=i.wnext,b=i.wsize-h):b=i.wnext-h,h>i.length&&(h=i.length),m=i.window}else m=a,b=o-i.offset,h=i.length;for(f<h&&(h=f),f-=h,i.length-=h;a[o++]=m[b++],--h;);0===i.length&&(i.mode=21);break;case 26:if(0===f)break e;a[o++]=i.length,f--,i.mode=21;break;case 27:if(i.wrap){for(;d<32;){if(0===s)break e;s--,l|=n[r++]<<d,d+=8}if(u-=f,e.total_out+=u,i.total+=u,u&&(e.adler=i.check=i.flags?N(i.check,a,u,o-u):R(i.check,a,u,o-u)),u=f,(i.flags?l:L(l))!==i.check){e.msg="incorrect data check",i.mode=30;break}d=l=0}i.mode=28;case 28:if(i.wrap&&i.flags){for(;d<32;){if(0===s)break e;s--,l+=n[r++]<<d,d+=8}if(l!==(4294967295&i.total)){e.msg="incorrect length check",i.mode=30;break}d=l=0}i.mode=29;case 29:y=1;break e;case 30:y=-3;break e;case 31:return-4;case 32:default:return U}return e.next_out=o,e.avail_out=f,e.next_in=r,e.avail_in=s,i.hold=l,i.bits=d,(i.wsize||u!==e.avail_out&&i.mode<30&&(i.mode<27||4!==t))&&j(e,e.output,e.next_out,u-e.avail_out)?(i.mode=31,-4):(c-=e.avail_in,u-=e.avail_out,e.total_in+=c,e.total_out+=u,i.total+=u,i.wrap&&u&&(e.adler=i.check=i.flags?N(i.check,a,u,e.next_out-u):R(i.check,a,u,e.next_out-u)),e.data_type=i.bits+(i.last?64:0)+(12===i.mode?128:0)+(20===i.mode||15===i.mode?256:0),(0===c&&0===u||4===t)&&y===T&&(y=-5),y)},i.inflateEnd=function(e){if(!e||!e.state)return U;var t=e.state;return t.window&&(t.window=null),e.state=null,T},i.inflateGetHeader=function(e,t){var i;return e&&e.state?0==(2&(i=e.state).wrap)?U:((i.head=t).done=!1,T):U},i.inflateSetDictionary=function(e,t){var i,n=t.length;return e&&e.state?0!==(i=e.state).wrap&&11!==i.mode?U:11===i.mode&&R(1,t,n,0)!==i.check?-3:j(e,t,n,n)?(i.mode=31,-4):(i.havedict=1,T):U},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":1,"./adler32":3,"./crc32":5,"./inffast":7,"./inftrees":9}],9:[function(e,t,i){"use strict";var I=e("../utils/common"),D=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],T=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],U=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],F=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];t.exports=function(e,t,i,n,a,r,o,s){var f,l,d,c,u,h,b,m,w,k=s.bits,_=0,g=0,v=0,p=0,x=0,y=0,S=0,E=0,Z=0,B=0,A=null,z=0,R=new I.Buf16(16),N=new I.Buf16(16),O=null,C=0;for(_=0;_<=15;_++)R[_]=0;for(g=0;g<n;g++)R[t[i+g]]++;for(x=k,p=15;1<=p&&0===R[p];p--);if(p<x&&(x=p),0===p)return a[r++]=20971520,a[r++]=20971520,s.bits=1,0;for(v=1;v<p&&0===R[v];v++);for(x<v&&(x=v),_=E=1;_<=15;_++)if(E<<=1,(E-=R[_])<0)return-1;if(0<E&&(0===e||1!==p))return-1;for(N[1]=0,_=1;_<15;_++)N[_+1]=N[_]+R[_];for(g=0;g<n;g++)0!==t[i+g]&&(o[N[t[i+g]]++]=g);if(0===e?(A=O=o,h=19):1===e?(A=D,z-=257,O=T,C-=257,h=256):(A=U,O=F,h=-1),_=v,u=r,S=g=B=0,d=-1,c=(Z=1<<(y=x))-1,1===e&&852<Z||2===e&&592<Z)return 1;for(;;){for(b=_-S,o[g]<h?(m=0,w=o[g]):o[g]>h?(m=O[C+o[g]],w=A[z+o[g]]):(m=96,w=0),f=1<<_-S,v=l=1<<y;a[u+(B>>S)+(l-=f)]=b<<24|m<<16|w|0,0!==l;);for(f=1<<_-1;B&f;)f>>=1;if(0!==f?(B&=f-1,B+=f):B=0,g++,0==--R[_]){if(_===p)break;_=t[i+o[g]]}if(x<_&&(B&c)!==d){for(0===S&&(S=x),u+=v,E=1<<(y=_-S);y+S<p&&!((E-=R[y+S])<=0);)y++,E<<=1;if(Z+=1<<y,1===e&&852<Z||2===e&&592<Z)return 1;a[d=B&c]=x<<24|y<<16|u-r|0}}return 0!==B&&(a[u+B]=_-S<<24|64<<16|0),s.bits=x,0}},{"../utils/common":1}],10:[function(e,t,i){"use strict";t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],11:[function(e,t,i){"use strict";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],"/lib/inflate.js":[function(e,t,i){"use strict";var c=e("./zlib/inflate"),u=e("./utils/common"),h=e("./utils/strings"),b=e("./zlib/constants"),n=e("./zlib/messages"),a=e("./zlib/zstream"),r=e("./zlib/gzheader"),m=Object.prototype.toString;function o(e){if(!(this instanceof o))return new o(e);this.options=u.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&0<=t.windowBits&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(0<=t.windowBits&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),15<t.windowBits&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new a,this.strm.avail_out=0;var i=c.inflateInit2(this.strm,t.windowBits);if(i!==b.Z_OK)throw new Error(n[i]);if(this.header=new r,c.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=h.string2buf(t.dictionary):"[object ArrayBuffer]"===m.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=c.inflateSetDictionary(this.strm,t.dictionary))!==b.Z_OK))throw new Error(n[i])}function s(e,t){var i=new o(t);if(i.push(e,!0),i.err)throw i.msg||n[i.err];return i.result}o.prototype.push=function(e,t){var i,n,a,r,o,s=this.strm,f=this.options.chunkSize,l=this.options.dictionary,d=!1;if(this.ended)return!1;n=t===~~t?t:!0===t?b.Z_FINISH:b.Z_NO_FLUSH,"string"==typeof e?s.input=h.binstring2buf(e):"[object ArrayBuffer]"===m.call(e)?s.input=new Uint8Array(e):s.input=e,s.next_in=0,s.avail_in=s.input.length;do{if(0===s.avail_out&&(s.output=new u.Buf8(f),s.next_out=0,s.avail_out=f),(i=c.inflate(s,b.Z_NO_FLUSH))===b.Z_NEED_DICT&&l&&(i=c.inflateSetDictionary(this.strm,l)),i===b.Z_BUF_ERROR&&!0===d&&(i=b.Z_OK,d=!1),i!==b.Z_STREAM_END&&i!==b.Z_OK)return this.onEnd(i),!(this.ended=!0);s.next_out&&(0!==s.avail_out&&i!==b.Z_STREAM_END&&(0!==s.avail_in||n!==b.Z_FINISH&&n!==b.Z_SYNC_FLUSH)||("string"===this.options.to?(a=h.utf8border(s.output,s.next_out),r=s.next_out-a,o=h.buf2string(s.output,a),s.next_out=r,s.avail_out=f-r,r&&u.arraySet(s.output,s.output,a,r,0),this.onData(o)):this.onData(u.shrinkBuf(s.output,s.next_out)))),0===s.avail_in&&0===s.avail_out&&(d=!0)}while((0<s.avail_in||0===s.avail_out)&&i!==b.Z_STREAM_END);return i===b.Z_STREAM_END&&(n=b.Z_FINISH),n===b.Z_FINISH?(i=c.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===b.Z_OK):n!==b.Z_SYNC_FLUSH||(this.onEnd(b.Z_OK),!(s.avail_out=0))},o.prototype.onData=function(e){this.chunks.push(e)},o.prototype.onEnd=function(e){e===b.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=u.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},i.Inflate=o,i.inflate=s,i.inflateRaw=function(e,t){return(t=t||{}).raw=!0,s(e,t)},i.ungzip=s},{"./utils/common":1,"./utils/strings":2,"./zlib/constants":4,"./zlib/gzheader":6,"./zlib/inflate":8,"./zlib/messages":10,"./zlib/zstream":11}]},{},[])("/lib/inflate.js")});
|
@@ -0,0 +1,14 @@
|
|
1
|
+
// Top level file is just a mixin of submodules & constants
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
var assign = require('./lib/utils/common').assign;
|
5
|
+
|
6
|
+
var deflate = require('./lib/deflate');
|
7
|
+
var inflate = require('./lib/inflate');
|
8
|
+
var constants = require('./lib/zlib/constants');
|
9
|
+
|
10
|
+
var pako = {};
|
11
|
+
|
12
|
+
assign(pako, deflate, inflate, constants);
|
13
|
+
|
14
|
+
module.exports = pako;
|
@@ -0,0 +1,400 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
|
4
|
+
var zlib_deflate = require('./zlib/deflate');
|
5
|
+
var utils = require('./utils/common');
|
6
|
+
var strings = require('./utils/strings');
|
7
|
+
var msg = require('./zlib/messages');
|
8
|
+
var ZStream = require('./zlib/zstream');
|
9
|
+
|
10
|
+
var toString = Object.prototype.toString;
|
11
|
+
|
12
|
+
/* Public constants ==========================================================*/
|
13
|
+
/* ===========================================================================*/
|
14
|
+
|
15
|
+
var Z_NO_FLUSH = 0;
|
16
|
+
var Z_FINISH = 4;
|
17
|
+
|
18
|
+
var Z_OK = 0;
|
19
|
+
var Z_STREAM_END = 1;
|
20
|
+
var Z_SYNC_FLUSH = 2;
|
21
|
+
|
22
|
+
var Z_DEFAULT_COMPRESSION = -1;
|
23
|
+
|
24
|
+
var Z_DEFAULT_STRATEGY = 0;
|
25
|
+
|
26
|
+
var Z_DEFLATED = 8;
|
27
|
+
|
28
|
+
/* ===========================================================================*/
|
29
|
+
|
30
|
+
|
31
|
+
/**
|
32
|
+
* class Deflate
|
33
|
+
*
|
34
|
+
* Generic JS-style wrapper for zlib calls. If you don't need
|
35
|
+
* streaming behaviour - use more simple functions: [[deflate]],
|
36
|
+
* [[deflateRaw]] and [[gzip]].
|
37
|
+
**/
|
38
|
+
|
39
|
+
/* internal
|
40
|
+
* Deflate.chunks -> Array
|
41
|
+
*
|
42
|
+
* Chunks of output data, if [[Deflate#onData]] not overridden.
|
43
|
+
**/
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Deflate.result -> Uint8Array|Array
|
47
|
+
*
|
48
|
+
* Compressed result, generated by default [[Deflate#onData]]
|
49
|
+
* and [[Deflate#onEnd]] handlers. Filled after you push last chunk
|
50
|
+
* (call [[Deflate#push]] with `Z_FINISH` / `true` param) or if you
|
51
|
+
* push a chunk with explicit flush (call [[Deflate#push]] with
|
52
|
+
* `Z_SYNC_FLUSH` param).
|
53
|
+
**/
|
54
|
+
|
55
|
+
/**
|
56
|
+
* Deflate.err -> Number
|
57
|
+
*
|
58
|
+
* Error code after deflate finished. 0 (Z_OK) on success.
|
59
|
+
* You will not need it in real life, because deflate errors
|
60
|
+
* are possible only on wrong options or bad `onData` / `onEnd`
|
61
|
+
* custom handlers.
|
62
|
+
**/
|
63
|
+
|
64
|
+
/**
|
65
|
+
* Deflate.msg -> String
|
66
|
+
*
|
67
|
+
* Error message, if [[Deflate.err]] != 0
|
68
|
+
**/
|
69
|
+
|
70
|
+
|
71
|
+
/**
|
72
|
+
* new Deflate(options)
|
73
|
+
* - options (Object): zlib deflate options.
|
74
|
+
*
|
75
|
+
* Creates new deflator instance with specified params. Throws exception
|
76
|
+
* on bad params. Supported options:
|
77
|
+
*
|
78
|
+
* - `level`
|
79
|
+
* - `windowBits`
|
80
|
+
* - `memLevel`
|
81
|
+
* - `strategy`
|
82
|
+
* - `dictionary`
|
83
|
+
*
|
84
|
+
* [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)
|
85
|
+
* for more information on these.
|
86
|
+
*
|
87
|
+
* Additional options, for internal needs:
|
88
|
+
*
|
89
|
+
* - `chunkSize` - size of generated data chunks (16K by default)
|
90
|
+
* - `raw` (Boolean) - do raw deflate
|
91
|
+
* - `gzip` (Boolean) - create gzip wrapper
|
92
|
+
* - `to` (String) - if equal to 'string', then result will be "binary string"
|
93
|
+
* (each char code [0..255])
|
94
|
+
* - `header` (Object) - custom header for gzip
|
95
|
+
* - `text` (Boolean) - true if compressed data believed to be text
|
96
|
+
* - `time` (Number) - modification time, unix timestamp
|
97
|
+
* - `os` (Number) - operation system code
|
98
|
+
* - `extra` (Array) - array of bytes with extra data (max 65536)
|
99
|
+
* - `name` (String) - file name (binary string)
|
100
|
+
* - `comment` (String) - comment (binary string)
|
101
|
+
* - `hcrc` (Boolean) - true if header crc should be added
|
102
|
+
*
|
103
|
+
* ##### Example:
|
104
|
+
*
|
105
|
+
* ```javascript
|
106
|
+
* var pako = require('pako')
|
107
|
+
* , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])
|
108
|
+
* , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);
|
109
|
+
*
|
110
|
+
* var deflate = new pako.Deflate({ level: 3});
|
111
|
+
*
|
112
|
+
* deflate.push(chunk1, false);
|
113
|
+
* deflate.push(chunk2, true); // true -> last chunk
|
114
|
+
*
|
115
|
+
* if (deflate.err) { throw new Error(deflate.err); }
|
116
|
+
*
|
117
|
+
* console.log(deflate.result);
|
118
|
+
* ```
|
119
|
+
**/
|
120
|
+
function Deflate(options) {
|
121
|
+
if (!(this instanceof Deflate)) return new Deflate(options);
|
122
|
+
|
123
|
+
this.options = utils.assign({
|
124
|
+
level: Z_DEFAULT_COMPRESSION,
|
125
|
+
method: Z_DEFLATED,
|
126
|
+
chunkSize: 16384,
|
127
|
+
windowBits: 15,
|
128
|
+
memLevel: 8,
|
129
|
+
strategy: Z_DEFAULT_STRATEGY,
|
130
|
+
to: ''
|
131
|
+
}, options || {});
|
132
|
+
|
133
|
+
var opt = this.options;
|
134
|
+
|
135
|
+
if (opt.raw && (opt.windowBits > 0)) {
|
136
|
+
opt.windowBits = -opt.windowBits;
|
137
|
+
}
|
138
|
+
|
139
|
+
else if (opt.gzip && (opt.windowBits > 0) && (opt.windowBits < 16)) {
|
140
|
+
opt.windowBits += 16;
|
141
|
+
}
|
142
|
+
|
143
|
+
this.err = 0; // error code, if happens (0 = Z_OK)
|
144
|
+
this.msg = ''; // error message
|
145
|
+
this.ended = false; // used to avoid multiple onEnd() calls
|
146
|
+
this.chunks = []; // chunks of compressed data
|
147
|
+
|
148
|
+
this.strm = new ZStream();
|
149
|
+
this.strm.avail_out = 0;
|
150
|
+
|
151
|
+
var status = zlib_deflate.deflateInit2(
|
152
|
+
this.strm,
|
153
|
+
opt.level,
|
154
|
+
opt.method,
|
155
|
+
opt.windowBits,
|
156
|
+
opt.memLevel,
|
157
|
+
opt.strategy
|
158
|
+
);
|
159
|
+
|
160
|
+
if (status !== Z_OK) {
|
161
|
+
throw new Error(msg[status]);
|
162
|
+
}
|
163
|
+
|
164
|
+
if (opt.header) {
|
165
|
+
zlib_deflate.deflateSetHeader(this.strm, opt.header);
|
166
|
+
}
|
167
|
+
|
168
|
+
if (opt.dictionary) {
|
169
|
+
var dict;
|
170
|
+
// Convert data if needed
|
171
|
+
if (typeof opt.dictionary === 'string') {
|
172
|
+
// If we need to compress text, change encoding to utf8.
|
173
|
+
dict = strings.string2buf(opt.dictionary);
|
174
|
+
} else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') {
|
175
|
+
dict = new Uint8Array(opt.dictionary);
|
176
|
+
} else {
|
177
|
+
dict = opt.dictionary;
|
178
|
+
}
|
179
|
+
|
180
|
+
status = zlib_deflate.deflateSetDictionary(this.strm, dict);
|
181
|
+
|
182
|
+
if (status !== Z_OK) {
|
183
|
+
throw new Error(msg[status]);
|
184
|
+
}
|
185
|
+
|
186
|
+
this._dict_set = true;
|
187
|
+
}
|
188
|
+
}
|
189
|
+
|
190
|
+
/**
|
191
|
+
* Deflate#push(data[, mode]) -> Boolean
|
192
|
+
* - data (Uint8Array|Array|ArrayBuffer|String): input data. Strings will be
|
193
|
+
* converted to utf8 byte sequence.
|
194
|
+
* - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.
|
195
|
+
* See constants. Skipped or `false` means Z_NO_FLUSH, `true` means Z_FINISH.
|
196
|
+
*
|
197
|
+
* Sends input data to deflate pipe, generating [[Deflate#onData]] calls with
|
198
|
+
* new compressed chunks. Returns `true` on success. The last data block must have
|
199
|
+
* mode Z_FINISH (or `true`). That will flush internal pending buffers and call
|
200
|
+
* [[Deflate#onEnd]]. For interim explicit flushes (without ending the stream) you
|
201
|
+
* can use mode Z_SYNC_FLUSH, keeping the compression context.
|
202
|
+
*
|
203
|
+
* On fail call [[Deflate#onEnd]] with error code and return false.
|
204
|
+
*
|
205
|
+
* We strongly recommend to use `Uint8Array` on input for best speed (output
|
206
|
+
* array format is detected automatically). Also, don't skip last param and always
|
207
|
+
* use the same type in your code (boolean or number). That will improve JS speed.
|
208
|
+
*
|
209
|
+
* For regular `Array`-s make sure all elements are [0..255].
|
210
|
+
*
|
211
|
+
* ##### Example
|
212
|
+
*
|
213
|
+
* ```javascript
|
214
|
+
* push(chunk, false); // push one of data chunks
|
215
|
+
* ...
|
216
|
+
* push(chunk, true); // push last chunk
|
217
|
+
* ```
|
218
|
+
**/
|
219
|
+
Deflate.prototype.push = function (data, mode) {
|
220
|
+
var strm = this.strm;
|
221
|
+
var chunkSize = this.options.chunkSize;
|
222
|
+
var status, _mode;
|
223
|
+
|
224
|
+
if (this.ended) { return false; }
|
225
|
+
|
226
|
+
_mode = (mode === ~~mode) ? mode : ((mode === true) ? Z_FINISH : Z_NO_FLUSH);
|
227
|
+
|
228
|
+
// Convert data if needed
|
229
|
+
if (typeof data === 'string') {
|
230
|
+
// If we need to compress text, change encoding to utf8.
|
231
|
+
strm.input = strings.string2buf(data);
|
232
|
+
} else if (toString.call(data) === '[object ArrayBuffer]') {
|
233
|
+
strm.input = new Uint8Array(data);
|
234
|
+
} else {
|
235
|
+
strm.input = data;
|
236
|
+
}
|
237
|
+
|
238
|
+
strm.next_in = 0;
|
239
|
+
strm.avail_in = strm.input.length;
|
240
|
+
|
241
|
+
do {
|
242
|
+
if (strm.avail_out === 0) {
|
243
|
+
strm.output = new utils.Buf8(chunkSize);
|
244
|
+
strm.next_out = 0;
|
245
|
+
strm.avail_out = chunkSize;
|
246
|
+
}
|
247
|
+
status = zlib_deflate.deflate(strm, _mode); /* no bad return value */
|
248
|
+
|
249
|
+
if (status !== Z_STREAM_END && status !== Z_OK) {
|
250
|
+
this.onEnd(status);
|
251
|
+
this.ended = true;
|
252
|
+
return false;
|
253
|
+
}
|
254
|
+
if (strm.avail_out === 0 || (strm.avail_in === 0 && (_mode === Z_FINISH || _mode === Z_SYNC_FLUSH))) {
|
255
|
+
if (this.options.to === 'string') {
|
256
|
+
this.onData(strings.buf2binstring(utils.shrinkBuf(strm.output, strm.next_out)));
|
257
|
+
} else {
|
258
|
+
this.onData(utils.shrinkBuf(strm.output, strm.next_out));
|
259
|
+
}
|
260
|
+
}
|
261
|
+
} while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== Z_STREAM_END);
|
262
|
+
|
263
|
+
// Finalize on the last chunk.
|
264
|
+
if (_mode === Z_FINISH) {
|
265
|
+
status = zlib_deflate.deflateEnd(this.strm);
|
266
|
+
this.onEnd(status);
|
267
|
+
this.ended = true;
|
268
|
+
return status === Z_OK;
|
269
|
+
}
|
270
|
+
|
271
|
+
// callback interim results if Z_SYNC_FLUSH.
|
272
|
+
if (_mode === Z_SYNC_FLUSH) {
|
273
|
+
this.onEnd(Z_OK);
|
274
|
+
strm.avail_out = 0;
|
275
|
+
return true;
|
276
|
+
}
|
277
|
+
|
278
|
+
return true;
|
279
|
+
};
|
280
|
+
|
281
|
+
|
282
|
+
/**
|
283
|
+
* Deflate#onData(chunk) -> Void
|
284
|
+
* - chunk (Uint8Array|Array|String): output data. Type of array depends
|
285
|
+
* on js engine support. When string output requested, each chunk
|
286
|
+
* will be string.
|
287
|
+
*
|
288
|
+
* By default, stores data blocks in `chunks[]` property and glue
|
289
|
+
* those in `onEnd`. Override this handler, if you need another behaviour.
|
290
|
+
**/
|
291
|
+
Deflate.prototype.onData = function (chunk) {
|
292
|
+
this.chunks.push(chunk);
|
293
|
+
};
|
294
|
+
|
295
|
+
|
296
|
+
/**
|
297
|
+
* Deflate#onEnd(status) -> Void
|
298
|
+
* - status (Number): deflate status. 0 (Z_OK) on success,
|
299
|
+
* other if not.
|
300
|
+
*
|
301
|
+
* Called once after you tell deflate that the input stream is
|
302
|
+
* complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)
|
303
|
+
* or if an error happened. By default - join collected chunks,
|
304
|
+
* free memory and fill `results` / `err` properties.
|
305
|
+
**/
|
306
|
+
Deflate.prototype.onEnd = function (status) {
|
307
|
+
// On success - join
|
308
|
+
if (status === Z_OK) {
|
309
|
+
if (this.options.to === 'string') {
|
310
|
+
this.result = this.chunks.join('');
|
311
|
+
} else {
|
312
|
+
this.result = utils.flattenChunks(this.chunks);
|
313
|
+
}
|
314
|
+
}
|
315
|
+
this.chunks = [];
|
316
|
+
this.err = status;
|
317
|
+
this.msg = this.strm.msg;
|
318
|
+
};
|
319
|
+
|
320
|
+
|
321
|
+
/**
|
322
|
+
* deflate(data[, options]) -> Uint8Array|Array|String
|
323
|
+
* - data (Uint8Array|Array|String): input data to compress.
|
324
|
+
* - options (Object): zlib deflate options.
|
325
|
+
*
|
326
|
+
* Compress `data` with deflate algorithm and `options`.
|
327
|
+
*
|
328
|
+
* Supported options are:
|
329
|
+
*
|
330
|
+
* - level
|
331
|
+
* - windowBits
|
332
|
+
* - memLevel
|
333
|
+
* - strategy
|
334
|
+
* - dictionary
|
335
|
+
*
|
336
|
+
* [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)
|
337
|
+
* for more information on these.
|
338
|
+
*
|
339
|
+
* Sugar (options):
|
340
|
+
*
|
341
|
+
* - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify
|
342
|
+
* negative windowBits implicitly.
|
343
|
+
* - `to` (String) - if equal to 'string', then result will be "binary string"
|
344
|
+
* (each char code [0..255])
|
345
|
+
*
|
346
|
+
* ##### Example:
|
347
|
+
*
|
348
|
+
* ```javascript
|
349
|
+
* var pako = require('pako')
|
350
|
+
* , data = Uint8Array([1,2,3,4,5,6,7,8,9]);
|
351
|
+
*
|
352
|
+
* console.log(pako.deflate(data));
|
353
|
+
* ```
|
354
|
+
**/
|
355
|
+
function deflate(input, options) {
|
356
|
+
var deflator = new Deflate(options);
|
357
|
+
|
358
|
+
deflator.push(input, true);
|
359
|
+
|
360
|
+
// That will never happens, if you don't cheat with options :)
|
361
|
+
if (deflator.err) { throw deflator.msg || msg[deflator.err]; }
|
362
|
+
|
363
|
+
return deflator.result;
|
364
|
+
}
|
365
|
+
|
366
|
+
|
367
|
+
/**
|
368
|
+
* deflateRaw(data[, options]) -> Uint8Array|Array|String
|
369
|
+
* - data (Uint8Array|Array|String): input data to compress.
|
370
|
+
* - options (Object): zlib deflate options.
|
371
|
+
*
|
372
|
+
* The same as [[deflate]], but creates raw data, without wrapper
|
373
|
+
* (header and adler32 crc).
|
374
|
+
**/
|
375
|
+
function deflateRaw(input, options) {
|
376
|
+
options = options || {};
|
377
|
+
options.raw = true;
|
378
|
+
return deflate(input, options);
|
379
|
+
}
|
380
|
+
|
381
|
+
|
382
|
+
/**
|
383
|
+
* gzip(data[, options]) -> Uint8Array|Array|String
|
384
|
+
* - data (Uint8Array|Array|String): input data to compress.
|
385
|
+
* - options (Object): zlib deflate options.
|
386
|
+
*
|
387
|
+
* The same as [[deflate]], but create gzip wrapper instead of
|
388
|
+
* deflate one.
|
389
|
+
**/
|
390
|
+
function gzip(input, options) {
|
391
|
+
options = options || {};
|
392
|
+
options.gzip = true;
|
393
|
+
return deflate(input, options);
|
394
|
+
}
|
395
|
+
|
396
|
+
|
397
|
+
exports.Deflate = Deflate;
|
398
|
+
exports.deflate = deflate;
|
399
|
+
exports.deflateRaw = deflateRaw;
|
400
|
+
exports.gzip = gzip;
|
@@ -0,0 +1,423 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
|
4
|
+
var zlib_inflate = require('./zlib/inflate');
|
5
|
+
var utils = require('./utils/common');
|
6
|
+
var strings = require('./utils/strings');
|
7
|
+
var c = require('./zlib/constants');
|
8
|
+
var msg = require('./zlib/messages');
|
9
|
+
var ZStream = require('./zlib/zstream');
|
10
|
+
var GZheader = require('./zlib/gzheader');
|
11
|
+
|
12
|
+
var toString = Object.prototype.toString;
|
13
|
+
|
14
|
+
/**
|
15
|
+
* class Inflate
|
16
|
+
*
|
17
|
+
* Generic JS-style wrapper for zlib calls. If you don't need
|
18
|
+
* streaming behaviour - use more simple functions: [[inflate]]
|
19
|
+
* and [[inflateRaw]].
|
20
|
+
**/
|
21
|
+
|
22
|
+
/* internal
|
23
|
+
* inflate.chunks -> Array
|
24
|
+
*
|
25
|
+
* Chunks of output data, if [[Inflate#onData]] not overridden.
|
26
|
+
**/
|
27
|
+
|
28
|
+
/**
|
29
|
+
* Inflate.result -> Uint8Array|Array|String
|
30
|
+
*
|
31
|
+
* Uncompressed result, generated by default [[Inflate#onData]]
|
32
|
+
* and [[Inflate#onEnd]] handlers. Filled after you push last chunk
|
33
|
+
* (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you
|
34
|
+
* push a chunk with explicit flush (call [[Inflate#push]] with
|
35
|
+
* `Z_SYNC_FLUSH` param).
|
36
|
+
**/
|
37
|
+
|
38
|
+
/**
|
39
|
+
* Inflate.err -> Number
|
40
|
+
*
|
41
|
+
* Error code after inflate finished. 0 (Z_OK) on success.
|
42
|
+
* Should be checked if broken data possible.
|
43
|
+
**/
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Inflate.msg -> String
|
47
|
+
*
|
48
|
+
* Error message, if [[Inflate.err]] != 0
|
49
|
+
**/
|
50
|
+
|
51
|
+
|
52
|
+
/**
|
53
|
+
* new Inflate(options)
|
54
|
+
* - options (Object): zlib inflate options.
|
55
|
+
*
|
56
|
+
* Creates new inflator instance with specified params. Throws exception
|
57
|
+
* on bad params. Supported options:
|
58
|
+
*
|
59
|
+
* - `windowBits`
|
60
|
+
* - `dictionary`
|
61
|
+
*
|
62
|
+
* [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)
|
63
|
+
* for more information on these.
|
64
|
+
*
|
65
|
+
* Additional options, for internal needs:
|
66
|
+
*
|
67
|
+
* - `chunkSize` - size of generated data chunks (16K by default)
|
68
|
+
* - `raw` (Boolean) - do raw inflate
|
69
|
+
* - `to` (String) - if equal to 'string', then result will be converted
|
70
|
+
* from utf8 to utf16 (javascript) string. When string output requested,
|
71
|
+
* chunk length can differ from `chunkSize`, depending on content.
|
72
|
+
*
|
73
|
+
* By default, when no options set, autodetect deflate/gzip data format via
|
74
|
+
* wrapper header.
|
75
|
+
*
|
76
|
+
* ##### Example:
|
77
|
+
*
|
78
|
+
* ```javascript
|
79
|
+
* var pako = require('pako')
|
80
|
+
* , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])
|
81
|
+
* , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);
|
82
|
+
*
|
83
|
+
* var inflate = new pako.Inflate({ level: 3});
|
84
|
+
*
|
85
|
+
* inflate.push(chunk1, false);
|
86
|
+
* inflate.push(chunk2, true); // true -> last chunk
|
87
|
+
*
|
88
|
+
* if (inflate.err) { throw new Error(inflate.err); }
|
89
|
+
*
|
90
|
+
* console.log(inflate.result);
|
91
|
+
* ```
|
92
|
+
**/
|
93
|
+
function Inflate(options) {
|
94
|
+
if (!(this instanceof Inflate)) return new Inflate(options);
|
95
|
+
|
96
|
+
this.options = utils.assign({
|
97
|
+
chunkSize: 16384,
|
98
|
+
windowBits: 0,
|
99
|
+
to: ''
|
100
|
+
}, options || {});
|
101
|
+
|
102
|
+
var opt = this.options;
|
103
|
+
|
104
|
+
// Force window size for `raw` data, if not set directly,
|
105
|
+
// because we have no header for autodetect.
|
106
|
+
if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {
|
107
|
+
opt.windowBits = -opt.windowBits;
|
108
|
+
if (opt.windowBits === 0) { opt.windowBits = -15; }
|
109
|
+
}
|
110
|
+
|
111
|
+
// If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate
|
112
|
+
if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&
|
113
|
+
!(options && options.windowBits)) {
|
114
|
+
opt.windowBits += 32;
|
115
|
+
}
|
116
|
+
|
117
|
+
// Gzip header has no info about windows size, we can do autodetect only
|
118
|
+
// for deflate. So, if window size not set, force it to max when gzip possible
|
119
|
+
if ((opt.windowBits > 15) && (opt.windowBits < 48)) {
|
120
|
+
// bit 3 (16) -> gzipped data
|
121
|
+
// bit 4 (32) -> autodetect gzip/deflate
|
122
|
+
if ((opt.windowBits & 15) === 0) {
|
123
|
+
opt.windowBits |= 15;
|
124
|
+
}
|
125
|
+
}
|
126
|
+
|
127
|
+
this.err = 0; // error code, if happens (0 = Z_OK)
|
128
|
+
this.msg = ''; // error message
|
129
|
+
this.ended = false; // used to avoid multiple onEnd() calls
|
130
|
+
this.chunks = []; // chunks of compressed data
|
131
|
+
|
132
|
+
this.strm = new ZStream();
|
133
|
+
this.strm.avail_out = 0;
|
134
|
+
|
135
|
+
var status = zlib_inflate.inflateInit2(
|
136
|
+
this.strm,
|
137
|
+
opt.windowBits
|
138
|
+
);
|
139
|
+
|
140
|
+
if (status !== c.Z_OK) {
|
141
|
+
throw new Error(msg[status]);
|
142
|
+
}
|
143
|
+
|
144
|
+
this.header = new GZheader();
|
145
|
+
|
146
|
+
zlib_inflate.inflateGetHeader(this.strm, this.header);
|
147
|
+
|
148
|
+
// Setup dictionary
|
149
|
+
if (opt.dictionary) {
|
150
|
+
// Convert data if needed
|
151
|
+
if (typeof opt.dictionary === 'string') {
|
152
|
+
opt.dictionary = strings.string2buf(opt.dictionary);
|
153
|
+
} else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') {
|
154
|
+
opt.dictionary = new Uint8Array(opt.dictionary);
|
155
|
+
}
|
156
|
+
if (opt.raw) { //In raw mode we need to set the dictionary early
|
157
|
+
status = zlib_inflate.inflateSetDictionary(this.strm, opt.dictionary);
|
158
|
+
if (status !== c.Z_OK) {
|
159
|
+
throw new Error(msg[status]);
|
160
|
+
}
|
161
|
+
}
|
162
|
+
}
|
163
|
+
}
|
164
|
+
|
165
|
+
/**
|
166
|
+
* Inflate#push(data[, mode]) -> Boolean
|
167
|
+
* - data (Uint8Array|Array|ArrayBuffer|String): input data
|
168
|
+
* - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.
|
169
|
+
* See constants. Skipped or `false` means Z_NO_FLUSH, `true` means Z_FINISH.
|
170
|
+
*
|
171
|
+
* Sends input data to inflate pipe, generating [[Inflate#onData]] calls with
|
172
|
+
* new output chunks. Returns `true` on success. The last data block must have
|
173
|
+
* mode Z_FINISH (or `true`). That will flush internal pending buffers and call
|
174
|
+
* [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you
|
175
|
+
* can use mode Z_SYNC_FLUSH, keeping the decompression context.
|
176
|
+
*
|
177
|
+
* On fail call [[Inflate#onEnd]] with error code and return false.
|
178
|
+
*
|
179
|
+
* We strongly recommend to use `Uint8Array` on input for best speed (output
|
180
|
+
* format is detected automatically). Also, don't skip last param and always
|
181
|
+
* use the same type in your code (boolean or number). That will improve JS speed.
|
182
|
+
*
|
183
|
+
* For regular `Array`-s make sure all elements are [0..255].
|
184
|
+
*
|
185
|
+
* ##### Example
|
186
|
+
*
|
187
|
+
* ```javascript
|
188
|
+
* push(chunk, false); // push one of data chunks
|
189
|
+
* ...
|
190
|
+
* push(chunk, true); // push last chunk
|
191
|
+
* ```
|
192
|
+
**/
|
193
|
+
Inflate.prototype.push = function (data, mode) {
|
194
|
+
var strm = this.strm;
|
195
|
+
var chunkSize = this.options.chunkSize;
|
196
|
+
var dictionary = this.options.dictionary;
|
197
|
+
var status, _mode;
|
198
|
+
var next_out_utf8, tail, utf8str;
|
199
|
+
|
200
|
+
// Flag to properly process Z_BUF_ERROR on testing inflate call
|
201
|
+
// when we check that all output data was flushed.
|
202
|
+
var allowBufError = false;
|
203
|
+
|
204
|
+
if (this.ended) { return false; }
|
205
|
+
_mode = (mode === ~~mode) ? mode : ((mode === true) ? c.Z_FINISH : c.Z_NO_FLUSH);
|
206
|
+
|
207
|
+
// Convert data if needed
|
208
|
+
if (typeof data === 'string') {
|
209
|
+
// Only binary strings can be decompressed on practice
|
210
|
+
strm.input = strings.binstring2buf(data);
|
211
|
+
} else if (toString.call(data) === '[object ArrayBuffer]') {
|
212
|
+
strm.input = new Uint8Array(data);
|
213
|
+
} else {
|
214
|
+
strm.input = data;
|
215
|
+
}
|
216
|
+
|
217
|
+
strm.next_in = 0;
|
218
|
+
strm.avail_in = strm.input.length;
|
219
|
+
|
220
|
+
do {
|
221
|
+
if (strm.avail_out === 0) {
|
222
|
+
strm.output = new utils.Buf8(chunkSize);
|
223
|
+
strm.next_out = 0;
|
224
|
+
strm.avail_out = chunkSize;
|
225
|
+
}
|
226
|
+
|
227
|
+
status = zlib_inflate.inflate(strm, c.Z_NO_FLUSH); /* no bad return value */
|
228
|
+
|
229
|
+
if (status === c.Z_NEED_DICT && dictionary) {
|
230
|
+
status = zlib_inflate.inflateSetDictionary(this.strm, dictionary);
|
231
|
+
}
|
232
|
+
|
233
|
+
if (status === c.Z_BUF_ERROR && allowBufError === true) {
|
234
|
+
status = c.Z_OK;
|
235
|
+
allowBufError = false;
|
236
|
+
}
|
237
|
+
|
238
|
+
if (status !== c.Z_STREAM_END && status !== c.Z_OK) {
|
239
|
+
this.onEnd(status);
|
240
|
+
this.ended = true;
|
241
|
+
return false;
|
242
|
+
}
|
243
|
+
|
244
|
+
if (strm.next_out) {
|
245
|
+
if (strm.avail_out === 0 || status === c.Z_STREAM_END || (strm.avail_in === 0 && (_mode === c.Z_FINISH || _mode === c.Z_SYNC_FLUSH))) {
|
246
|
+
|
247
|
+
if (this.options.to === 'string') {
|
248
|
+
|
249
|
+
next_out_utf8 = strings.utf8border(strm.output, strm.next_out);
|
250
|
+
|
251
|
+
tail = strm.next_out - next_out_utf8;
|
252
|
+
utf8str = strings.buf2string(strm.output, next_out_utf8);
|
253
|
+
|
254
|
+
// move tail
|
255
|
+
strm.next_out = tail;
|
256
|
+
strm.avail_out = chunkSize - tail;
|
257
|
+
if (tail) { utils.arraySet(strm.output, strm.output, next_out_utf8, tail, 0); }
|
258
|
+
|
259
|
+
this.onData(utf8str);
|
260
|
+
|
261
|
+
} else {
|
262
|
+
this.onData(utils.shrinkBuf(strm.output, strm.next_out));
|
263
|
+
}
|
264
|
+
}
|
265
|
+
}
|
266
|
+
|
267
|
+
// When no more input data, we should check that internal inflate buffers
|
268
|
+
// are flushed. The only way to do it when avail_out = 0 - run one more
|
269
|
+
// inflate pass. But if output data not exists, inflate return Z_BUF_ERROR.
|
270
|
+
// Here we set flag to process this error properly.
|
271
|
+
//
|
272
|
+
// NOTE. Deflate does not return error in this case and does not needs such
|
273
|
+
// logic.
|
274
|
+
if (strm.avail_in === 0 && strm.avail_out === 0) {
|
275
|
+
allowBufError = true;
|
276
|
+
}
|
277
|
+
|
278
|
+
} while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== c.Z_STREAM_END);
|
279
|
+
|
280
|
+
if (status === c.Z_STREAM_END) {
|
281
|
+
_mode = c.Z_FINISH;
|
282
|
+
}
|
283
|
+
|
284
|
+
// Finalize on the last chunk.
|
285
|
+
if (_mode === c.Z_FINISH) {
|
286
|
+
status = zlib_inflate.inflateEnd(this.strm);
|
287
|
+
this.onEnd(status);
|
288
|
+
this.ended = true;
|
289
|
+
return status === c.Z_OK;
|
290
|
+
}
|
291
|
+
|
292
|
+
// callback interim results if Z_SYNC_FLUSH.
|
293
|
+
if (_mode === c.Z_SYNC_FLUSH) {
|
294
|
+
this.onEnd(c.Z_OK);
|
295
|
+
strm.avail_out = 0;
|
296
|
+
return true;
|
297
|
+
}
|
298
|
+
|
299
|
+
return true;
|
300
|
+
};
|
301
|
+
|
302
|
+
|
303
|
+
/**
|
304
|
+
* Inflate#onData(chunk) -> Void
|
305
|
+
* - chunk (Uint8Array|Array|String): output data. Type of array depends
|
306
|
+
* on js engine support. When string output requested, each chunk
|
307
|
+
* will be string.
|
308
|
+
*
|
309
|
+
* By default, stores data blocks in `chunks[]` property and glue
|
310
|
+
* those in `onEnd`. Override this handler, if you need another behaviour.
|
311
|
+
**/
|
312
|
+
Inflate.prototype.onData = function (chunk) {
|
313
|
+
this.chunks.push(chunk);
|
314
|
+
};
|
315
|
+
|
316
|
+
|
317
|
+
/**
|
318
|
+
* Inflate#onEnd(status) -> Void
|
319
|
+
* - status (Number): inflate status. 0 (Z_OK) on success,
|
320
|
+
* other if not.
|
321
|
+
*
|
322
|
+
* Called either after you tell inflate that the input stream is
|
323
|
+
* complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)
|
324
|
+
* or if an error happened. By default - join collected chunks,
|
325
|
+
* free memory and fill `results` / `err` properties.
|
326
|
+
**/
|
327
|
+
Inflate.prototype.onEnd = function (status) {
|
328
|
+
// On success - join
|
329
|
+
if (status === c.Z_OK) {
|
330
|
+
if (this.options.to === 'string') {
|
331
|
+
// Glue & convert here, until we teach pako to send
|
332
|
+
// utf8 aligned strings to onData
|
333
|
+
this.result = this.chunks.join('');
|
334
|
+
} else {
|
335
|
+
this.result = utils.flattenChunks(this.chunks);
|
336
|
+
}
|
337
|
+
}
|
338
|
+
this.chunks = [];
|
339
|
+
this.err = status;
|
340
|
+
this.msg = this.strm.msg;
|
341
|
+
};
|
342
|
+
|
343
|
+
|
344
|
+
/**
|
345
|
+
* inflate(data[, options]) -> Uint8Array|Array|String
|
346
|
+
* - data (Uint8Array|Array|String): input data to decompress.
|
347
|
+
* - options (Object): zlib inflate options.
|
348
|
+
*
|
349
|
+
* Decompress `data` with inflate/ungzip and `options`. Autodetect
|
350
|
+
* format via wrapper header by default. That's why we don't provide
|
351
|
+
* separate `ungzip` method.
|
352
|
+
*
|
353
|
+
* Supported options are:
|
354
|
+
*
|
355
|
+
* - windowBits
|
356
|
+
*
|
357
|
+
* [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)
|
358
|
+
* for more information.
|
359
|
+
*
|
360
|
+
* Sugar (options):
|
361
|
+
*
|
362
|
+
* - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify
|
363
|
+
* negative windowBits implicitly.
|
364
|
+
* - `to` (String) - if equal to 'string', then result will be converted
|
365
|
+
* from utf8 to utf16 (javascript) string. When string output requested,
|
366
|
+
* chunk length can differ from `chunkSize`, depending on content.
|
367
|
+
*
|
368
|
+
*
|
369
|
+
* ##### Example:
|
370
|
+
*
|
371
|
+
* ```javascript
|
372
|
+
* var pako = require('pako')
|
373
|
+
* , input = pako.deflate([1,2,3,4,5,6,7,8,9])
|
374
|
+
* , output;
|
375
|
+
*
|
376
|
+
* try {
|
377
|
+
* output = pako.inflate(input);
|
378
|
+
* } catch (err)
|
379
|
+
* console.log(err);
|
380
|
+
* }
|
381
|
+
* ```
|
382
|
+
**/
|
383
|
+
function inflate(input, options) {
|
384
|
+
var inflator = new Inflate(options);
|
385
|
+
|
386
|
+
inflator.push(input, true);
|
387
|
+
|
388
|
+
// That will never happens, if you don't cheat with options :)
|
389
|
+
if (inflator.err) { throw inflator.msg || msg[inflator.err]; }
|
390
|
+
|
391
|
+
return inflator.result;
|
392
|
+
}
|
393
|
+
|
394
|
+
|
395
|
+
/**
|
396
|
+
* inflateRaw(data[, options]) -> Uint8Array|Array|String
|
397
|
+
* - data (Uint8Array|Array|String): input data to decompress.
|
398
|
+
* - options (Object): zlib inflate options.
|
399
|
+
*
|
400
|
+
* The same as [[inflate]], but creates raw data, without wrapper
|
401
|
+
* (header and adler32 crc).
|
402
|
+
**/
|
403
|
+
function inflateRaw(input, options) {
|
404
|
+
options = options || {};
|
405
|
+
options.raw = true;
|
406
|
+
return inflate(input, options);
|
407
|
+
}
|
408
|
+
|
409
|
+
|
410
|
+
/**
|
411
|
+
* ungzip(data[, options]) -> Uint8Array|Array|String
|
412
|
+
* - data (Uint8Array|Array|String): input data to decompress.
|
413
|
+
* - options (Object): zlib inflate options.
|
414
|
+
*
|
415
|
+
* Just shortcut to [[inflate]], because it autodetects format
|
416
|
+
* by header.content. Done for convenience.
|
417
|
+
**/
|
418
|
+
|
419
|
+
|
420
|
+
exports.Inflate = Inflate;
|
421
|
+
exports.inflate = inflate;
|
422
|
+
exports.inflateRaw = inflateRaw;
|
423
|
+
exports.ungzip = inflate;
|