├── .babelrc ├── .editorconfig ├── .eslintignore ├── .eslintrc ├── .gitignore ├── .npmignore ├── .nycrc ├── .travis.yml ├── LICENSE ├── README.md ├── dist ├── browser │ ├── json-url-lzstring.js │ ├── json-url-lzw.js │ ├── json-url-msgpack.js │ ├── json-url-safe64.js │ ├── json-url-safe64.js.LICENSE.txt │ ├── json-url-single.js │ ├── json-url-single.js.LICENSE.txt │ ├── json-url-vendors~lzma.js │ ├── json-url-vendors~msgpack.js │ ├── json-url-vendors~msgpack.js.LICENSE.txt │ ├── json-url.js │ └── json-url.js.LICENSE.txt └── node │ ├── browser-index.js │ ├── codecs │ ├── index.js │ ├── lzma.js │ ├── lzstring.js │ ├── lzw.js │ └── pack.js │ ├── index.js │ ├── loaders.js │ └── main │ ├── browser-index.js │ ├── codecs │ ├── index.js │ ├── lzma.js │ ├── lzstring.js │ ├── lzw.js │ └── pack.js │ ├── index.js │ └── loaders.js ├── examples └── browser │ └── test.html ├── karma.conf.js ├── package-lock.json ├── package.json ├── src └── main │ ├── browser-index.js │ ├── codecs │ ├── index.js │ ├── lzma.js │ ├── lzstring.js │ ├── lzw.js │ └── pack.js │ ├── index.js │ └── loaders.js ├── test ├── index.js ├── perf.js └── samples.json ├── webpack.config.js └── webpack.config.single.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "@babel/preset-env" 4 | ], 5 | "plugins": [ 6 | [ 7 | "module-resolver", 8 | { 9 | "root": [ 10 | "src" 11 | ], 12 | "transformFunctions": [ 13 | "require", 14 | "require.resolve", 15 | "import" 16 | ] 17 | } 18 | ], 19 | "dynamic-import-node", 20 | "@babel/plugin-syntax-dynamic-import", 21 | "@babel/plugin-syntax-import-meta", 22 | "@babel/plugin-proposal-class-properties", 23 | "@babel/plugin-proposal-json-strings", 24 | [ 25 | "@babel/plugin-proposal-decorators", 26 | { 27 | "legacy": true 28 | } 29 | ], 30 | "@babel/plugin-proposal-function-sent", 31 | "@babel/plugin-proposal-export-namespace-from", 32 | "@babel/plugin-proposal-numeric-separator", 33 | "@babel/plugin-proposal-throw-expressions", 34 | "@babel/plugin-proposal-export-default-from", 35 | "@babel/plugin-proposal-logical-assignment-operators", 36 | "@babel/plugin-proposal-optional-chaining", 37 | [ 38 | "@babel/plugin-proposal-pipeline-operator", 39 | { 40 | "proposal": "minimal" 41 | } 42 | ], 43 | "@babel/plugin-proposal-nullish-coalescing-operator", 44 | "@babel/plugin-proposal-do-expressions", 45 | "@babel/plugin-proposal-function-bind" 46 | ], 47 | "env": { 48 | "test": { 49 | "plugins": [ 50 | "istanbul" 51 | ] 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # top-most EditorConfig file 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | indent_style = tab 8 | indent_size = 2 9 | trim_trailing_whitespace = true -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | dist/**/* -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "babel-eslint", 3 | "plugins": [ "import" ], 4 | "extends": [ "eslint:recommended", "plugin:import/recommended" ], 5 | "settings": { 6 | "import/resolver": { 7 | "babel-module": {} 8 | } 9 | }, 10 | "rules": { 11 | "no-undef": 2, 12 | "no-unused-vars": 2, 13 | "no-console": 0 14 | }, 15 | "env": { 16 | "node": true, 17 | "es6": true 18 | }, 19 | "parserOptions": { 20 | "ecmaVersion": 2015, 21 | "sourceType": "module", 22 | "ecmaFeatures": { 23 | "jsx": true, 24 | "experimentalObjectRestSpread": true, 25 | "forOf": true 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.log 3 | .DS_Store 4 | coverage/ 5 | .nyc_output/ 6 | stats.json 7 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | *.log 2 | test/ 3 | examples/ 4 | .DS_Store 5 | coverage/ 6 | .nyc_output/ -------------------------------------------------------------------------------- /.nycrc: -------------------------------------------------------------------------------- 1 | { 2 | "include": [ "src/**/*.js" ], 3 | "require": [ "@babel/register", "@babel/polyfill" ], 4 | "sourceMap": false, 5 | "instrument": false, 6 | "reporter": [ "text", "lcov" ] 7 | } -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "node" 4 | - "14" 5 | - "12" 6 | - "10" 7 | after_success: npm run coverage 8 | install: npm install -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Facebook, Inc. and its affiliates. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # json-url 2 | 3 | [![npm downloads][downloads-image]][downloads-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage Status][coverage-image]][coverage-url] 4 | 5 | Generate URL-safe representations of some arbtirary JSON data in as small a space as possible that can be shared in a bookmark / link. 6 | 7 | Although designed to work in Node, a standalone client-side library is provided that can be used directly on the browser. 8 | 9 | ## Usage 10 | 11 | ### Compress 12 | 13 | ``` 14 | var codec = require('json-url')('lzw'); 15 | var obj = { one: 1, two: 2, three: [1,2,3], four: 'red pineapples' }; 16 | codec.compress(obj).then(result => console.log(result)); 17 | /* Result: woTCo29uZQHCo3R3bwLCpXRocmVlwpMBAgPCpGZvdXLCrsSOZCBwacSDYXBwbGVz */ 18 | ``` 19 | 20 | ### Decompress 21 | 22 | ``` 23 | var codec = require('json-url')('lzma'); 24 | codec.decompress(someCompressedString).then(json => { /* operate on json */ }) 25 | ``` 26 | 27 | ### Stats 28 | 29 | ``` 30 | var codec = require('json-url')('lzstring'); 31 | codec.stats(obj).then( 32 | ({ rawencoded, compressedencoded, compression }) => { 33 | console.log(`Raw URI-encoded JSON string length: ${rawencoded}`); 34 | console.log(`Compressed URI-encoded JSON string length: ${compressedencoded}`); 35 | console.log(`Compression ratio (raw / compressed): ${compression}`); 36 | } 37 | ); 38 | ``` 39 | 40 | ### Standalone Browser Bundle 41 | 42 | ``` 43 | 44 | 48 | ``` 49 | 50 | To see it in action, download the source code and run `npm run example`, or simply visit [this link](http://jsbin.com/cayuhox). 51 | 52 | * The browser bundle is generated using Webpack and consists of multiple chunks, with the main chunk entry point located at `dist/browser/json-url.js`. Chunks must be located in the same folder as the main module itself. 53 | * I've tried my best to reduce the bundle sizes, but the module (at least the entry) is still surprisingly large on the browser (56kb minified, 20kb gzipped). Most of it is due to the buffer.js shim, and partly due to the regenerator-runtime - I may revisit this later to try and improve efficiency. 54 | 55 | ## Usage Notes 56 | 57 | * Although not all algorithms are asynchronous, all functions return Promises to ensure compatibility. 58 | * Instantiate an instance with appropriate compression codec before using. 59 | * Valid codecs: 60 | * lzw 61 | * lzma 62 | * lzstring - runs lzstring against a stringified JSON instead of using MessagePack on JSON 63 | * pack - this just uses MessagePack and converts the binary buffer into a Base64 URL-safe representation, without any other compression 64 | 65 | ## Motivation 66 | 67 | Typically when you want to shorten a long URL with large amounts of data parameters, the approach is to generate a "short URL" where compression is achieved by using a third-party service which stores the true URL and redirects the user (e.g. bit.ly or goo.gl). 68 | 69 | However, if you want to: 70 | 71 | * share bookmarks with virtually unlimited combinations of state and/or 72 | * want to avoid the third-party dependency 73 | 74 | you would encode the data structure (typically JSON) in your URL, but this often results in very large URLs. 75 | 76 | This approach differs by removing that third-party dependency and encodes it using common compression algorithms such as LZW or LZMA. 77 | 78 | Note: It is arguable that a custom dictionary / domain specific encoding would ultimately provide better compression, but here we want to 79 | * avoid maintaining such a dictionary and/or 80 | * retain cross-application compatibility (otherwise you need a shared dictionary) 81 | 82 | ## Approach 83 | 84 | I explored several options, the most popular one being [MessagePack][1]. However, I noticed that it did not give the best possible compression as compared to [LZMA][2] and [LZW][3]. 85 | 86 | At first I tried to apply the binary compression directly on a stringified JSON, then I realised that packing it first resulted in better compression. 87 | 88 | For small JS objects, LZW largely outperformed LZMA, but for the most part you'd probably be looking to compress large JSON data rather than small amounts (otherwise a simple stringify + base64 is sufficient). You can choose to use whatever codec suits you best. 89 | 90 | In addition, there is now support for [LZSTRING][5], although the URI encoding still uses urlsafe-base64 because LZSTRING still uses unsafe characters via their `compressToURIEncodedString` method - notably the [`+` character][6] 91 | 92 | Finally, I went with [urlsafe-base64][4] to encode it in a URL-friendly format. 93 | 94 | ## TODO 95 | 96 | Find a way to improve bundle sizes for browser usage. 97 | 98 | [1]: http://msgpack.org/index.html 99 | [2]: https://www.npmjs.com/package/lzma 100 | [3]: https://www.npmjs.com/package/node-lzw 101 | [4]: https://www.npmjs.com/package/urlsafe-base64 102 | [5]: http://pieroxy.net/blog/pages/lz-string/index.html 103 | [6]: https://github.com/pieroxy/lz-string/blob/master/libs/lz-string.js#L15 104 | 105 | [downloads-image]: https://img.shields.io/npm/dm/json-url.svg?style=flat-square 106 | [downloads-url]: https://www.npmjs.com/package/json-url 107 | [travis-image]: https://travis-ci.org/masotime/json-url.svg?bxeranch=master 108 | [travis-url]: https://travis-ci.org/masotime/json-url 109 | [daviddm-image]: https://david-dm.org/masotime/json-url.svg?theme=shields.io 110 | [daviddm-url]: https://david-dm.org/masotime/json-url 111 | [coverage-image]: https://coveralls.io/repos/github/masotime/json-url/badge.svg?branch=master 112 | [coverage-url]: https://coveralls.io/github/masotime/json-url?branch=master 113 | -------------------------------------------------------------------------------- /dist/browser/json-url-lzstring.js: -------------------------------------------------------------------------------- 1 | (window.webpackJsonpJsonUrl=window.webpackJsonpJsonUrl||[]).push([[0],{17:function(o,r,n){var e,t=function(){var o=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",e={};function t(o,r){if(!e[o]){e[o]={};for(var n=0;n>>8,n[2*e+1]=i%256}return n},decompressFromUint8Array:function(r){if(null==r)return s.decompress(r);for(var n=new Array(r.length/2),e=0,t=n.length;e>=1}else{for(t=1,e=0;e>=1}0==--l&&(l=Math.pow(2,h),h++),delete p[u]}else for(t=i[u],e=0;e>=1;0==--l&&(l=Math.pow(2,h),h++),i[a]=f++,u=String(c)}if(""!==u){if(Object.prototype.hasOwnProperty.call(p,u)){if(u.charCodeAt(0)<256){for(e=0;e>=1}else{for(t=1,e=0;e>=1}0==--l&&(l=Math.pow(2,h),h++),delete p[u]}else for(t=i[u],e=0;e>=1;0==--l&&(l=Math.pow(2,h),h++)}for(t=2,e=0;e>=1;for(;;){if(m<<=1,w==r-1){d.push(n(m));break}w++}return d.join("")},decompress:function(o){return null==o?"":""==o?null:s._decompress(o.length,32768,(function(r){return o.charCodeAt(r)}))},_decompress:function(r,n,e){var t,s,i,p,c,a,u,l=[],f=4,h=4,d=3,m="",w=[],v={val:e(0),position:n,index:1};for(t=0;t<3;t+=1)l[t]=t;for(i=0,c=Math.pow(2,2),a=1;a!=c;)p=v.val&v.position,v.position>>=1,0==v.position&&(v.position=n,v.val=e(v.index++)),i|=(p>0?1:0)*a,a<<=1;switch(i){case 0:for(i=0,c=Math.pow(2,8),a=1;a!=c;)p=v.val&v.position,v.position>>=1,0==v.position&&(v.position=n,v.val=e(v.index++)),i|=(p>0?1:0)*a,a<<=1;u=o(i);break;case 1:for(i=0,c=Math.pow(2,16),a=1;a!=c;)p=v.val&v.position,v.position>>=1,0==v.position&&(v.position=n,v.val=e(v.index++)),i|=(p>0?1:0)*a,a<<=1;u=o(i);break;case 2:return""}for(l[3]=u,s=u,w.push(u);;){if(v.index>r)return"";for(i=0,c=Math.pow(2,d),a=1;a!=c;)p=v.val&v.position,v.position>>=1,0==v.position&&(v.position=n,v.val=e(v.index++)),i|=(p>0?1:0)*a,a<<=1;switch(u=i){case 0:for(i=0,c=Math.pow(2,8),a=1;a!=c;)p=v.val&v.position,v.position>>=1,0==v.position&&(v.position=n,v.val=e(v.index++)),i|=(p>0?1:0)*a,a<<=1;l[h++]=o(i),u=h-1,f--;break;case 1:for(i=0,c=Math.pow(2,16),a=1;a!=c;)p=v.val&v.position,v.position>>=1,0==v.position&&(v.position=n,v.val=e(v.index++)),i|=(p>0?1:0)*a,a<<=1;l[h++]=o(i),u=h-1,f--;break;case 2:return w.join("")}if(0==f&&(f=Math.pow(2,d),d++),l[u])m=l[u];else{if(u!==h)return null;m=s+s.charAt(0)}w.push(m),l[h++]=s+m.charAt(0),s=m,0==--f&&(f=Math.pow(2,d),d++)}}};return s}();void 0===(e=function(){return t}.call(r,n,r,o))||(o.exports=e)}}]); -------------------------------------------------------------------------------- /dist/browser/json-url-lzw.js: -------------------------------------------------------------------------------- 1 | (window.webpackJsonpJsonUrl=window.webpackJsonpJsonUrl||[]).push([[1],{18:function(n,o,t){"use strict";var r=function(){};r.prototype.encode=function(n){for(var o,t={},r=(n+"").split(""),e=[],p=r[0],h=256,c=1;c1?t[p]:p.charCodeAt(0)),t[p+o]=h,h++,p=o);e.push(p.length>1?t[p]:p.charCodeAt(0));for(c=0;c 11 | * @license MIT 12 | */ 13 | 14 | /*! 15 | * The buffer module from node.js, for the browser. 16 | * 17 | * @author Feross Aboukhadijeh 18 | * @license MIT 19 | */ 20 | 21 | /*! 22 | * urlsafe-base64 23 | */ 24 | 25 | /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ 26 | 27 | /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ 28 | 29 | /*! safe-buffer. MIT License. Feross Aboukhadijeh */ 30 | -------------------------------------------------------------------------------- /dist/browser/json-url-vendors~lzma.js: -------------------------------------------------------------------------------- 1 | (window.webpackJsonpJsonUrl=window.webpackJsonpJsonUrl||[]).push([[5],{16:function(n,r,t){(function(n){var r=function(){"use strict";function t(n,r){postMessage({action:Nn,cbn:r,result:n})}function c(n){var r=[];return r[n-1]=void 0,r}function e(n,r){return f(n[0]+r[0],n[1]+r[1])}function o(n,r){return function(n,r){var t,c;return t=n*Zn,c=r,0>r&&(c+=Zn),[c,t]}(~~Math.max(Math.min(n[1]/Zn,2147483647),-2147483648)&~~Math.max(Math.min(r[1]/Zn,2147483647),-2147483648),a(n)&a(r))}function i(n,r){var t,c;return n[0]==r[0]&&n[1]==r[1]?0:(t=0>n[1],c=0>r[1],t&&!c?-1:!t&&c?1:v(n,r)[1]<0?-1:1)}function f(n,r){var t,c;for(n%=0x10000000000000000,r=(r%=0x10000000000000000)-(t=r%Zn)+(c=Math.floor(n/Zn)*Zn),n=n-c+t;0>n;)n+=Zn,r-=Zn;for(;n>4294967295;)n-=Zn,r+=Zn;for(r%=0x10000000000000000;r>0x7fffffff00000000;)r-=0x10000000000000000;for(;-0x8000000000000000>r;)r+=0x10000000000000000;return[n,r]}function u(n,r){return n[0]==r[0]&&n[1]==r[1]}function b(n){return n>=0?[n,0]:[n+Zn,-Zn]}function a(n){return n[0]>=2147483648?~~Math.max(Math.min(n[0]-Zn,2147483647),-2147483648):~~Math.max(Math.min(n[0],2147483647),-2147483648)}function l(n){return 30>=n?1<n[1])throw Error("Neg");return o=l(r),c=n[1]*o%0x10000000000000000,(c+=t=(e=n[0]*o)-e%Zn)>=0x8000000000000000&&(c-=0x10000000000000000),[e-=t,c]}function d(n,r){var t;return t=l(r&=63),f(Math.floor(n[0]/t),n[1]/t)}function v(n,r){return f(n[0]-r[0],n[1]-r[1])}function m(n,r){return n.Mc=r,n.Lc=0,n.Yb=r.length,n}function h(n){return n.Lc>=n.Yb?-1:255&n.Mc[n.Lc++]}function g(n,r,t,c){return n.Lc>=n.Yb?-1:(c=Math.min(c,n.Yb-n.Lc),T(n.Mc,n.Lc,r,t,c),n.Lc+=c,c)}function p(n){return n.Mc=c(32),n.Yb=0,n}function x(n){var r=n.Mc;return r.length=n.Yb,r}function y(n,r){n.Mc[n.Yb++]=r<<24>>24}function w(n,r,t,c){T(r,t,n.Mc,n.Yb,c),n.Yb+=c}function T(n,r,t,c,e){for(var o=0;e>o;++o)t[c+o]=n[r+o]}function E(n,t,c,e,o){var f,u;if(i(e,Kn)<0)throw Error("invalid length "+e);for(n.Tb=e,function(n,r){(function(n,r){n.ab=r;for(var t=0;r>1<>24;for(var t=0;4>t;++t)n.fc[1+t]=n.ab>>8*t<<24>>24;w(r,n.fc,0,5)}(f,c),u=0;64>u;u+=8)y(c,255&a(d(e,u)));n.yb=(f.W=0,f.oc=t,f.pc=0,function(n){var r,t;n.b||(r={},t=4,n.X||(t=2),function(n,r){n.qb=r>2,n.qb?(n.w=0,n.xb=4,n.R=66560):(n.w=2,n.xb=3,n.R=0)}(r,t),n.b=r),vn(n.A,n.eb,n.fb),(n.ab!=n.wb||n.Hb!=n.n)&&(B(n.b,n.ab,4096,n.n,274),n.wb=n.ab,n.Hb=n.n)}(f),f.d.Ab=c,function(n){(function(n){n.l=0,n.J=0;for(var r=0;4>r;++r)n.v[r]=0})(n),function(n){n.mc=Yn,n.xc=Yn,n.E=-1,n.Jb=1,n.Oc=0}(n.d),Cn(n.C),Cn(n._),Cn(n.bb),Cn(n.hb),Cn(n.Ub),Cn(n.vc),Cn(n.Sb),function(n){var r,t=1<r;++r)Cn(n.V[r].tb)}(n.A);for(var r=0;4>r;++r)Cn(n.K[r].G);un(n.$,1<e;++e){if(-1==(o=h(r)))throw Error("truncated input");u[e]=o<<24>>24}if(!function(n,r){var t,c,e,o,i,f,u;if(5>r.length)return 0;for(u=255&r[0],e=u%9,o=(f=~~(u/9))%5,i=~~(f/5),t=0,c=0;4>c;++c)t+=(255&r[1+c])<<8*c;return t>99999999||!function(n,r,t,c){if(r>8||t>4||c>4)return 0;Y(n.gb,t,r);var e=1<r?0:(n.Ob!=r&&(n.Ob=r,n.nb=Math.max(n.Ob,1),G(n.B,Math.max(n.nb,4096))),1)}(n,t)}(c=N({}),u))throw Error("corrupted input");for(e=0;64>e;e+=8){if(-1==(o=h(r)))throw Error("truncated input");1==(o=o.toString(16)).length&&(o="0"+o),f=o+""+f}/^0+$|^f+$/i.test(f)?n.Tb=Kn:(i=parseInt(f,16),n.Tb=i>4294967295?Kn:b(i)),n.yb=function(n,r,t,c){return n.e.Ab=r,F(n.B),n.B.cc=t,function(n){n.B.h=0,n.B.o=0,Cn(n.Gb),Cn(n.pb),Cn(n.Zb),Cn(n.Cb),Cn(n.Db),Cn(n.Eb),Cn(n.kc),function(n){var r,t;for(t=1<r;++r)Cn(n.V[r].Ib)}(n.gb);for(var r=0;4>r;++r)Cn(n.kb[r].G);V(n.Rb),V(n.sb),Cn(n.Fb.G),function(n){n.Bb=0,n.E=-1;for(var r=0;5>r;++r)n.Bb=n.Bb<<8|h(n.Ab)}(n.e)}(n),n.U=0,n.ib=0,n.Jc=0,n.Ic=0,n.Qc=0,n.Nc=c,n.g=Yn,n.jc=0,function(n,r){return n.Z=r,n.cb=null,n.zc=1,n}({},n)}(c,r,t,n.Tb)}function I(n,r){return n.Nb=p({}),L(n,m({},r),n.Nb),n}function j(n,r){return n.c[n.f+n.o+r]}function z(n,r,t,c){var e,o;for(n.T&&n.o+r+c>n.h&&(c=n.h-(n.o+r)),++t,o=n.f+n.o+r,e=0;c>e&&n.c[o+e]==n.c[o+e-t];++e);return e}function k(n){return n.h-n.o}function A(n){var r,t;if(!n.T)for(;;){if(!(t=-n.f+n.Kb-n.h))return;if(-1==(r=g(n.cc,n.c,n.f+n.h,t)))return n.zb=n.h,n.f+n.zb>n.H&&(n.zb=n.H-n.f),void(n.T=1);n.h+=r,n.h>=n.o+n._b&&(n.zb=n.h-n._b)}}function C(n,r){n.f+=r,n.zb-=r,n.o-=r,n.h-=r}function B(n,r,t,e,o){var i,f;1073741567>r&&(n.Fc=16+(e>>1),function(n,r,t,e){var o;n.Bc=r,n._b=t,o=r+t+e,(null==n.c||n.Kb!=o)&&(n.c=null,n.Kb=o,n.c=c(n.Kb)),n.H=n.Kb-t}(n,r+t,e+o,256+~~((r+t+e+o)/2)),n.ob=e,i=r+1,n.p!=i&&(n.L=c(2*(n.p=i))),f=65536,n.qb&&(f=r-1,f|=f>>1,f|=f>>2,f|=f>>4,f|=f>>8,f>>=1,(f|=65535)>16777216&&(f>>=1),n.Ec=f,++f,f+=n.R),f!=n.rc&&(n.ub=c(n.rc=f)))}function U(n){var r;++n.k>=n.p&&(n.k=0),function(n){++n.o,n.o>n.zb&&(n.f+n.o>n.H&&function(n){var r,t,c;for((c=n.f+n.o-n.Bc)>0&&--c,t=n.f+n.h-c,r=0;t>r;++r)n.c[r]=n.c[c+r];n.f-=c}(n),A(n))}(n),1073741823==n.o&&(r=n.o-n.p,_(n.L,2*n.p,r),_(n.ub,n.rc,r),C(n,r))}function _(n,r,t){var c,e;for(c=0;r>c;++c)t>=(e=n[c]||0)?e=0:e-=t,n[c]=e}function G(n,r){(null==n.Lb||n.M!=r)&&(n.Lb=c(r)),n.M=r,n.o=0,n.h=0}function J(n){var r=n.o-n.h;r&&(w(n.cc,n.Lb,n.h,r),n.o>=n.M&&(n.o=0),n.h=n.o)}function q(n,r){var t=n.o-r-1;return 0>t&&(t+=n.M),n.Lb[t]}function F(n){J(n),n.cc=null}function O(n){return 4>(n-=2)?n:3}function Q(n){return 4>n?0:10>n?n-3:n-6}function D(n){if(!n.zc)throw Error("bad state");return n.cb?function(n){(function(n,r,t,c){var o,f,l,s,d,m,h,g,p,x,y,w,T,E,M;if(r[0]=Yn,t[0]=Yn,c[0]=1,n.oc&&(n.b.cc=n.oc,function(n){n.f=0,n.o=0,n.h=0,n.T=0,A(n),n.k=0,C(n,-1)}(n.b),n.W=1,n.oc=null),!n.pc){if(n.pc=1,E=n.g,u(n.g,Yn)){if(!k(n.b))return void X(n,a(n.g));en(n),T=a(n.g)&n.y,Bn(n.d,n.C,(n.l<<4)+T,0),n.l=Q(n.l),l=j(n.b,-n.s),hn(mn(n.A,a(n.g),n.J),n.d,l),n.J=l,--n.s,n.g=e(n.g,Rn)}if(!k(n.b))return void X(n,a(n.g));for(;;){if(h=nn(n,a(n.g)),x=n.mb,T=a(n.g)&n.y,f=(n.l<<4)+T,1==h&&-1==x)Bn(n.d,n.C,f,0),l=j(n.b,-n.s),M=mn(n.A,a(n.g),n.J),7>n.l?hn(M,n.d,l):(p=j(n.b,-n.v[0]-1-n.s),gn(M,n.d,p,l)),n.J=l,n.l=Q(n.l);else{if(Bn(n.d,n.C,f,1),4>x){if(Bn(n.d,n.bb,n.l,1),x?(Bn(n.d,n.hb,n.l,1),1==x?Bn(n.d,n.Ub,n.l,0):(Bn(n.d,n.Ub,n.l,1),Bn(n.d,n.vc,n.l,x-2))):(Bn(n.d,n.hb,n.l,0),Bn(n.d,n._,f,1==h?0:1)),1==h?n.l=7>n.l?9:11:(an(n.i,n.d,h-2,T),n.l=7>n.l?8:11),s=n.v[x],0!=x){for(m=x;m>=1;--m)n.v[m]=n.v[m-1];n.v[0]=s}}else{for(Bn(n.d,n.bb,n.l,0),n.l=7>n.l?7:10,an(n.$,n.d,h-2,T),w=fn(x-=4),g=O(h),Mn(n.K[g],n.d,w),w>=4&&(y=x-(o=(2|1&w)<<(d=(w>>1)-1)),14>w?zn(n.Sb,o-w-1,n.d,d,y):(Un(n.d,y>>4,d-4),In(n.S,n.d,15&y),++n.Qb)),s=x,m=3;m>=1;--m)n.v[m]=n.v[m-1];n.v[0]=s,++n.Mb}n.J=j(n.b,h-1-n.s)}if(n.s-=h,n.g=e(n.g,b(h)),!n.s){if(n.Mb>=128&&W(n),n.Qb>=16&&P(n),r[0]=n.g,t[0]=_n(n.d),!k(n.b))return void X(n,a(n.g));if(i(v(n.g,E),[4096,0])>=0)return n.pc=0,void(c[0]=0)}}}})(n.cb,n.cb.Xb,n.cb.uc,n.cb.Kc),n.Pb=n.cb.Xb[0],n.cb.Kc[0]&&(function(n){on(n),n.d.Ab=null}(n.cb),n.zc=0)}(n):function(n){var r=function(n){var r,t,c,o,f,u;if(u=a(n.g)&n.Dc,An(n.e,n.Gb,(n.U<<4)+u)){if(An(n.e,n.Zb,n.U))c=0,An(n.e,n.Cb,n.U)?(An(n.e,n.Db,n.U)?(An(n.e,n.Eb,n.U)?(t=n.Qc,n.Qc=n.Ic):t=n.Ic,n.Ic=n.Jc):t=n.Jc,n.Jc=n.ib,n.ib=t):An(n.e,n.pb,(n.U<<4)+u)||(n.U=7>n.U?9:11,c=1),c||(c=Z(n.sb,n.e,u)+2,n.U=7>n.U?8:11);else if(n.Qc=n.Ic,n.Ic=n.Jc,n.Jc=n.ib,c=2+Z(n.Rb,n.e,u),n.U=7>n.U?7:10,(f=Tn(n.kb[O(c)],n.e))>=4){if(o=(f>>1)-1,n.ib=(2|1&f)<f)n.ib+=function(n,r,t,c){var e,o,i=1,f=0;for(o=0;c>o;++o)e=An(t,n,r+i),i<<=1,i+=e,f|=e<>>=1,c=n.Bb-n.E>>>31,n.Bb-=n.E&c-1,e=e<<1|1-c,-16777216&n.E||(n.Bb=n.Bb<<8|h(n.Ab),n.E<<=8);return e}(n.e,o-4)<<4,n.ib+=function(n,r){var t,c,e=1,o=0;for(c=0;n.F>c;++c)t=An(r,n.G,e),e<<=1,e+=t,o|=t<n.ib)return-1==n.ib?1:-1}else n.ib=f;if(i(b(n.ib),n.g)>=0||n.ib>=n.nb)return-1;(function(n,r,t){var c=n.o-r-1;for(0>c&&(c+=n.M);0!=t;--t)c>=n.M&&(c=0),n.Lb[n.o++]=n.Lb[c++],n.o>=n.M&&J(n)})(n.B,n.ib,c),n.g=e(n.g,b(c)),n.jc=q(n.B,0)}else r=function(n,r,t){return n.V[((r&n.qc)<>>8-n.u)]}(n.gb,a(n.g),n.jc),n.jc=7>n.U?function(n,r){var t=1;do{t=t<<1|An(r,n.Ib,t)}while(256>t);return t<<24>>24}(r,n.e):function(n,r,t){var c,e,o=1;do{if(e=t>>7&1,t<<=1,c=An(r,n.Ib,(1+e<<8)+o),o=o<<1|c,e!=c){for(;256>o;)o=o<<1|An(r,n.Ib,o);break}}while(256>o);return o<<24>>24}(r,n.e,q(n.B,n.ib)),function(n,r){n.Lb[n.o++]=r,n.o>=n.M&&J(n)}(n.B,n.jc),n.U=Q(n.U),n.g=e(n.g,Rn);return 0}(n.Z);if(-1==r)throw Error("corrupted input");n.Pb=Kn,n.Pc=n.Z.g,(r||i(n.Z.Nc,Yn)>=0&&i(n.Z.g,n.Z.Nc)>=0)&&(J(n.Z.B),F(n.Z.B),n.Z.e.Ab=null,n.zc=0)}(n),n.zc}function N(n){n.B={},n.e={},n.Gb=c(192),n.Zb=c(12),n.Cb=c(12),n.Db=c(12),n.Eb=c(12),n.pb=c(192),n.kb=c(4),n.kc=c(114),n.Fb=wn({},4),n.Rb=K({}),n.sb=K({}),n.gb={};for(var r=0;4>r;++r)n.kb[r]=wn({},6);return n}function S(n,r){for(;r>n.O;++n.O)n.ec[n.O]=wn({},3),n.hc[n.O]=wn({},3)}function Z(n,r,t){return An(r,n.wc,0)?8+(An(r,n.wc,1)?8+Tn(n.tc,r):Tn(n.hc[t],r)):Tn(n.ec[t],r)}function K(n){return n.wc=c(2),n.ec=c(16),n.hc=c(16),n.tc=wn({},8),n.O=0,n}function V(n){Cn(n.wc);for(var r=0;n.O>r;++r)Cn(n.ec[r].G),Cn(n.hc[r].G);Cn(n.tc.G)}function Y(n,r,t){var e,o;if(null==n.V||n.u!=t||n.I!=r)for(n.I=r,n.qc=(1<e;++e)n.V[e]=R({})}function R(n){return n.Ib=c(768),n}function $(n,r){var t,c,e,o;n.jb=r,e=n.a[r].r,c=n.a[r].j;do{n.a[r].t&&(yn(n.a[e]),n.a[e].r=e-1,n.a[r].Ac&&(n.a[e-1].t=0,n.a[e-1].r=n.a[r].r2,n.a[e-1].j=n.a[r].j2)),o=e,t=c,c=n.a[o].j,e=n.a[o].r,n.a[o].j=t,n.a[o].r=r,r=o}while(r>0);return n.mb=n.a[0].j,n.q=n.a[0].r}function H(n){var r;for(n.v=c(4),n.a=[],n.d={},n.C=c(192),n.bb=c(12),n.hb=c(12),n.Ub=c(12),n.vc=c(12),n._=c(192),n.K=[],n.Sb=c(114),n.S=En({},4),n.$=ln({}),n.i=ln({}),n.A={},n.m=[],n.P=[],n.lb=[],n.nc=c(16),n.x=c(4),n.Q=c(4),n.Xb=[Yn],n.uc=[Yn],n.Kc=[0],n.fc=c(5),n.yc=c(128),n.vb=0,n.X=1,n.D=0,n.Hb=-1,n.mb=0,r=0;4096>r;++r)n.a[r]={};for(r=0;4>r;++r)n.K[r]=En({},6);return n}function P(n){for(var r=0;16>r;++r)n.nc[r]=jn(n.S,r);n.Qb=0}function W(n){var r,t,c,e,o,i,f,u;for(e=4;128>e;++e)r=(2|1&(i=fn(e)))<<(c=(i>>1)-1),n.yc[e]=kn(n.Sb,r-i-1,c,e-r);for(o=0;4>o;++o){for(t=n.K[o],f=o<<6,i=0;n.$b>i;++i)n.P[f+i]=Ln(t,i);for(i=14;n.$b>i;++i)n.P[f+i]+=(i>>1)-1-4<<6;for(u=128*o,e=0;4>e;++e)n.lb[u+e]=n.P[f+e];for(;128>e;++e)n.lb[u+e]=n.P[f+fn(e)]+n.yc[e]}n.Mb=0}function X(n,r){on(n),function(n,r){if(n.Gc){Bn(n.d,n.C,(n.l<<4)+r,1),Bn(n.d,n.bb,n.l,0),n.l=7>n.l?7:10,an(n.$,n.d,0,r);var t=O(2);Mn(n.K[t],n.d,63),Un(n.d,67108863,26),In(n.S,n.d,15)}}(n,r&n.y);for(var t=0;5>t;++t)Gn(n.d)}function nn(n,r){var t,c,e,o,i,f,u,b,a,l,s,d,v,m,h,g,p,x,y,w,T,E,M,L,I,A,C,B,U,_,G,J,q,F,O,D,N,S,Z,K,V,Y,R,H;if(n.jb!=n.q)return v=n.a[n.q].r-n.q,n.mb=n.a[n.q].j,n.q=n.a[n.q].r,v;if(n.q=n.jb=0,n.N?(d=n.vb,n.N=0):d=en(n),A=n.D,2>(L=k(n.b)+1))return n.mb=-1,1;for(L>273&&(L=273),Z=0,a=0;4>a;++a)n.x[a]=n.v[a],n.Q[a]=z(n.b,-1,n.x[a],273),n.Q[a]>n.Q[Z]&&(Z=a);if(n.Q[Z]>=n.n)return n.mb=Z,cn(n,(v=n.Q[Z])-1),v;if(d>=n.n)return n.mb=n.m[A-1]+4,cn(n,d-1),d;if(u=j(n.b,-1),p=j(n.b,-n.v[0]-1-1),2>d&&u!=p&&2>n.Q[Z])return n.mb=-1,1;if(n.a[0].Hc=n.l,q=r&n.y,n.a[1].z=Pn[n.C[(n.l<<4)+q]>>>2]+xn(mn(n.A,r,n.J),n.l>=7,p,u),yn(n.a[1]),S=(x=Pn[2048-n.C[(n.l<<4)+q]>>>2])+Pn[2048-n.bb[n.l]>>>2],p==u&&(K=S+function(n,r,t){return Pn[n.hb[r]>>>2]+Pn[n._[(r<<4)+t]>>>2]}(n,n.l,q),n.a[1].z>K&&(n.a[1].z=K,function(n){n.j=0,n.t=0}(n.a[1]))),2>(s=d>=n.Q[Z]?d:n.Q[Z]))return n.mb=n.a[1].j,1;n.a[1].r=0,n.a[0].bc=n.x[0],n.a[0].ac=n.x[1],n.a[0].dc=n.x[2],n.a[0].lc=n.x[3],l=s;do{n.a[l--].z=268435455}while(l>=2);for(a=0;4>a;++a)if(!(2>(N=n.Q[a]))){O=S+tn(n,a,n.l,q);do{o=O+sn(n.i,N-2,q),(_=n.a[N]).z>o&&(_.z=o,_.r=0,_.j=a,_.t=0)}while(--N>=2)}if(M=x+Pn[n.bb[n.l]>>>2],d>=(l=n.Q[0]>=2?n.Q[0]+1:2)){for(C=0;l>n.m[C];)C+=2;for(;o=M+rn(n,b=n.m[C+1],l,q),(_=n.a[l]).z>o&&(_.z=o,_.r=0,_.j=b+4,_.t=0),l!=n.m[C]||(C+=2)!=A;++l);}for(t=0;;){if(++t==s)return $(n,t);if(y=en(n),A=n.D,y>=n.n)return n.vb=y,n.N=1,$(n,t);if(++r,J=n.a[t].r,n.a[t].t?(--J,n.a[t].Ac?(Y=n.a[n.a[t].r2].Hc,Y=4>n.a[t].j2?7>Y?8:11:7>Y?7:10):Y=n.a[J].Hc,Y=Q(Y)):Y=n.a[J].Hc,J==t-1?Y=n.a[t].j?Q(Y):7>Y?9:11:(n.a[t].t&&n.a[t].Ac?(J=n.a[t].r2,G=n.a[t].j2,Y=7>Y?8:11):Y=4>(G=n.a[t].j)?7>Y?8:11:7>Y?7:10,U=n.a[J],4>G?G?1==G?(n.x[0]=U.ac,n.x[1]=U.bc,n.x[2]=U.dc,n.x[3]=U.lc):2==G?(n.x[0]=U.dc,n.x[1]=U.bc,n.x[2]=U.ac,n.x[3]=U.lc):(n.x[0]=U.lc,n.x[1]=U.bc,n.x[2]=U.ac,n.x[3]=U.dc):(n.x[0]=U.bc,n.x[1]=U.ac,n.x[2]=U.dc,n.x[3]=U.lc):(n.x[0]=G-4,n.x[1]=U.bc,n.x[2]=U.ac,n.x[3]=U.dc)),n.a[t].Hc=Y,n.a[t].bc=n.x[0],n.a[t].ac=n.x[1],n.a[t].dc=n.x[2],n.a[t].lc=n.x[3],f=n.a[t].z,u=j(n.b,-1),p=j(n.b,-n.x[0]-1-1),q=r&n.y,c=f+Pn[n.C[(Y<<4)+q]>>>2]+xn(mn(n.A,r,j(n.b,-2)),Y>=7,p,u),w=0,(T=n.a[t+1]).z>c&&(T.z=c,T.r=t,T.j=-1,T.t=0,w=1),S=(x=f+Pn[2048-n.C[(Y<<4)+q]>>>2])+Pn[2048-n.bb[Y]>>>2],p!=u||t>T.r&&!T.j||(K=S+(Pn[n.hb[Y]>>>2]+Pn[n._[(Y<<4)+q]>>>2]),T.z>=K&&(T.z=K,T.r=t,T.j=0,T.t=0,w=1)),!(2>(L=I=(I=k(n.b)+1)>4095-t?4095-t:I))){if(L>n.n&&(L=n.n),!w&&p!=u&&(H=Math.min(I-1,n.n),(h=z(n.b,0,n.x[0],H))>=2)){for(R=Q(Y),F=r+1&n.y,E=c+Pn[2048-n.C[(R<<4)+F]>>>2]+Pn[2048-n.bb[R]>>>2],B=t+1+h;B>s;)n.a[++s].z=268435455;o=E+(sn(n.i,h-2,F)+tn(n,0,R,F)),(_=n.a[B]).z>o&&(_.z=o,_.r=t+1,_.j=0,_.t=1,_.Ac=0)}for(V=2,D=0;4>D;++D)if(!(2>(m=z(n.b,-1,n.x[D],L)))){g=m;do{for(;t+m>s;)n.a[++s].z=268435455;o=S+(sn(n.i,m-2,q)+tn(n,D,Y,q)),(_=n.a[t+m]).z>o&&(_.z=o,_.r=t,_.j=D,_.t=0)}while(--m>=2);if(m=g,D||(V=m+1),I>m&&(H=Math.min(I-1-m,n.n),(h=z(n.b,m,n.x[D],H))>=2)){for(R=7>Y?8:11,F=r+m&n.y,e=S+(sn(n.i,m-2,q)+tn(n,D,Y,q))+Pn[n.C[(R<<4)+F]>>>2]+xn(mn(n.A,r+m,j(n.b,m-1-1)),1,j(n.b,m-1-(n.x[D]+1)),j(n.b,m-1)),R=Q(R),F=r+m+1&n.y,E=e+Pn[2048-n.C[(R<<4)+F]>>>2]+Pn[2048-n.bb[R]>>>2],B=m+1+h;t+B>s;)n.a[++s].z=268435455;o=E+(sn(n.i,h-2,F)+tn(n,0,R,F)),(_=n.a[t+B]).z>o&&(_.z=o,_.r=t+m+1,_.j=0,_.t=1,_.Ac=1,_.r2=t,_.j2=D)}}if(y>L){for(y=L,A=0;y>n.m[A];A+=2);n.m[A]=y,A+=2}if(y>=V){for(M=x+Pn[n.bb[Y]>>>2];t+y>s;)n.a[++s].z=268435455;for(C=0;V>n.m[C];)C+=2;for(m=V;;++m)if(o=M+rn(n,i=n.m[C+1],m,q),(_=n.a[t+m]).z>o&&(_.z=o,_.r=t,_.j=i+4,_.t=0),m==n.m[C]){if(I>m&&(H=Math.min(I-1-m,n.n),(h=z(n.b,m,i,H))>=2)){for(R=7>Y?7:10,F=r+m&n.y,e=o+Pn[n.C[(R<<4)+F]>>>2]+xn(mn(n.A,r+m,j(n.b,m-1-1)),1,j(n.b,m-(i+1)-1),j(n.b,m-1)),R=Q(R),F=r+m+1&n.y,E=e+Pn[2048-n.C[(R<<4)+F]>>>2]+Pn[2048-n.bb[R]>>>2],B=m+1+h;t+B>s;)n.a[++s].z=268435455;o=E+(sn(n.i,h-2,F)+tn(n,0,R,F)),(_=n.a[t+B]).z>o&&(_.z=o,_.r=t+m+1,_.j=0,_.t=1,_.Ac=1,_.r2=t,_.j2=i+4)}if((C+=2)==A)break}}}}}function rn(n,r,t,c){var e=O(t);return(128>r?n.lb[128*e+r]:n.P[(e<<6)+function(n){return 131072>n?Hn[n>>6]+12:134217728>n?Hn[n>>16]+32:Hn[n>>26]+52}(r)]+n.nc[15&r])+sn(n.$,t-2,c)}function tn(n,r,t,c){var e;return r?(e=Pn[2048-n.hb[t]>>>2],1==r?e+=Pn[n.Ub[t]>>>2]:(e+=Pn[2048-n.Ub[t]>>>2],e+=Jn(n.vc[t],r-2))):(e=Pn[n.hb[t]>>>2],e+=Pn[2048-n._[(t<<4)+c]>>>2]),e}function cn(n,r){r>0&&(function(n,r){var t,c,e,o,i,f,u,b,a,l,s,d,v,m,h,g,p;do{if(n.h>=n.o+n.ob)d=n.ob;else if(d=n.h-n.o,n.xb>d){U(n);continue}for(v=n.o>n.p?n.o-n.p:0,c=n.f+n.o,n.qb?(f=1023&(p=$n[255&n.c[c]]^255&n.c[c+1]),n.ub[f]=n.o,u=65535&(p^=(255&n.c[c+2])<<8),n.ub[1024+u]=n.o,b=(p^$n[255&n.c[c+3]]<<5)&n.Ec):b=255&n.c[c]^(255&n.c[c+1])<<8,e=n.ub[n.R+b],n.ub[n.R+b]=n.o,h=1+(n.k<<1),g=n.k<<1,l=s=n.w,t=n.Fc;;){if(v>=e||0==t--){n.L[h]=n.L[g]=0;break}if(i=n.o-e,o=(n.k>=i?n.k-i:n.k-i+n.p)<<1,m=n.f+e,a=s>l?l:s,n.c[m+a]==n.c[c+a]){for(;++a!=d&&n.c[m+a]==n.c[c+a];);if(a==d){n.L[g]=n.L[o],n.L[h]=n.L[o+1];break}}(255&n.c[c+a])>(255&n.c[m+a])?(n.L[g]=e,g=o+1,e=n.L[g],s=a):(n.L[h]=e,h=o,e=n.L[h],l=a)}U(n)}while(0!=--r)}(n.b,r),n.s+=r)}function en(n){var r=0;return n.D=function(n,r){var t,c,e,o,i,f,u,b,a,l,s,d,v,m,h,g,p,x,y,w,T;if(n.h>=n.o+n.ob)m=n.ob;else if(m=n.h-n.o,n.xb>m)return U(n),0;for(p=0,h=n.o>n.p?n.o-n.p:0,c=n.f+n.o,g=1,b=0,a=0,n.qb?(b=1023&(T=$n[255&n.c[c]]^255&n.c[c+1]),a=65535&(T^=(255&n.c[c+2])<<8),l=(T^$n[255&n.c[c+3]]<<5)&n.Ec):l=255&n.c[c]^(255&n.c[c+1])<<8,e=n.ub[n.R+l]||0,n.qb&&(o=n.ub[b]||0,i=n.ub[1024+a]||0,n.ub[b]=n.o,n.ub[1024+a]=n.o,o>h&&n.c[n.f+o]==n.c[c]&&(r[p++]=g=2,r[p++]=n.o-o-1),i>h&&n.c[n.f+i]==n.c[c]&&(i==o&&(p-=2),r[p++]=g=3,r[p++]=n.o-i-1,o=i),0!=p&&o==e&&(p-=2,g=1)),n.ub[n.R+l]=n.o,y=1+(n.k<<1),w=n.k<<1,d=v=n.w,0!=n.w&&e>h&&n.c[n.f+e+n.w]!=n.c[c+n.w]&&(r[p++]=g=n.w,r[p++]=n.o-e-1),t=n.Fc;;){if(h>=e||0==t--){n.L[y]=n.L[w]=0;break}if(u=n.o-e,f=(n.k>=u?n.k-u:n.k-u+n.p)<<1,x=n.f+e,s=v>d?d:v,n.c[x+s]==n.c[c+s]){for(;++s!=m&&n.c[x+s]==n.c[c+s];);if(s>g&&(r[p++]=g=s,r[p++]=u-1,s==m)){n.L[w]=n.L[f],n.L[y]=n.L[f+1];break}}(255&n.c[c+s])>(255&n.c[x+s])?(n.L[w]=e,w=f+1,e=n.L[w],v=s):(n.L[y]=e,y=f,e=n.L[y],d=s)}return U(n),p}(n.b,n.m),n.D>0&&((r=n.m[n.D-2])==n.n&&(r+=z(n.b,r-1,n.m[n.D-1],273-r))),++n.s,r}function on(n){n.b&&n.W&&(n.b.cc=null,n.W=0)}function fn(n){return 2048>n?Hn[n]:2097152>n?Hn[n>>10]+20:Hn[n>>20]+40}function un(n,r){Cn(n.db);for(var t=0;r>t;++t)Cn(n.Vb[t].G),Cn(n.Wb[t].G);Cn(n.ic.G)}function bn(n,r,t,c,e){var o,i,f,u,b;for(o=Pn[n.db[0]>>>2],f=(i=Pn[2048-n.db[0]>>>2])+Pn[n.db[1]>>>2],u=i+Pn[2048-n.db[1]>>>2],b=0,b=0;8>b;++b){if(b>=t)return;c[e+b]=o+Ln(n.Vb[r],b)}for(;16>b;++b){if(b>=t)return;c[e+b]=f+Ln(n.Wb[r],b-8)}for(;t>b;++b)c[e+b]=u+Ln(n.ic,b-8-8)}function an(n,r,t,c){(function(n,r,t,c){8>t?(Bn(r,n.db,0,0),Mn(n.Vb[c],r,t)):(t-=8,Bn(r,n.db,0,1),8>t?(Bn(r,n.db,1,0),Mn(n.Wb[c],r,t)):(Bn(r,n.db,1,1),Mn(n.ic,r,t-8)))})(n,r,t,c),0==--n.sc[c]&&(bn(n,c,n.rb,n.Cc,272*c),n.sc[c]=n.rb)}function ln(n){return function(n){n.db=c(2),n.Vb=c(16),n.Wb=c(16),n.ic=En({},8);for(var r=0;16>r;++r)n.Vb[r]=En({},3),n.Wb[r]=En({},3)}(n),n.Cc=[],n.sc=[],n}function sn(n,r,t){return n.Cc[272*t+r]}function dn(n,r){for(var t=0;r>t;++t)bn(n,t,n.rb,n.Cc,272*t),n.sc[t]=n.rb}function vn(n,r,t){var e,o;if(null==n.V||n.u!=t||n.I!=r)for(n.I=r,n.qc=(1<e;++e)n.V[e]=pn({})}function mn(n,r,t){return n.V[((r&n.qc)<>>8-n.u)]}function hn(n,r,t){var c,e,o=1;for(e=7;e>=0;--e)c=t>>e&1,Bn(r,n.tb,o,c),o=o<<1|c}function gn(n,r,t,c){var e,o,i,f,u=1,b=1;for(o=7;o>=0;--o)e=c>>o&1,f=b,u&&(f+=1+(i=t>>o&1)<<8,u=i==e),Bn(r,n.tb,f,e),b=b<<1|e}function pn(n){return n.tb=c(768),n}function xn(n,r,t,c){var e,o,i=1,f=7,u=0;if(r)for(;f>=0;--f)if(o=t>>f&1,e=c>>f&1,u+=Jn(n.tb[(1+o<<8)+i],e),i=i<<1|e,o!=e){--f;break}for(;f>=0;--f)e=c>>f&1,u+=Jn(n.tb[i],e),i=i<<1|e;return u}function yn(n){n.j=-1,n.t=0}function wn(n,r){return n.F=r,n.G=c(1<>>--e&1,Bn(r,n.G,o,c),o=o<<1|c}function Ln(n,r){var t,c,e=1,o=0;for(c=n.F;0!=c;)t=r>>>--c&1,o+=Jn(n.G[e],t),e=(e<<1)+t;return o}function In(n,r,t){var c,e,o=1;for(e=0;n.F>e;++e)c=1&t,Bn(r,n.G,o,c),o=o<<1|c,t>>=1}function jn(n,r){var t,c,e=1,o=0;for(c=n.F;0!=c;--c)t=1&r,r>>>=1,o+=Jn(n.G[e],t),e=e<<1|t;return o}function zn(n,r,t,c,e){var o,i,f=1;for(i=0;c>i;++i)Bn(t,n,r+f,o=1&e),f=f<<1|o,e>>=1}function kn(n,r,t,c){var e,o,i=1,f=0;for(o=t;0!=o;--o)e=1&c,c>>>=1,f+=Pn[(2047&(n[r+i]-e^-e))>>>2],i=i<<1|e;return f}function An(n,r,t){var c,e=r[t];return(-2147483648^(c=(n.E>>>11)*e))>(-2147483648^n.Bb)?(n.E=c,r[t]=e+(2048-e>>>5)<<16>>16,-16777216&n.E||(n.Bb=n.Bb<<8|h(n.Ab),n.E<<=8),0):(n.E-=c,n.Bb-=c,r[t]=e-(e>>>5)<<16>>16,-16777216&n.E||(n.Bb=n.Bb<<8|h(n.Ab),n.E<<=8),1)}function Cn(n){for(var r=n.length-1;r>=0;--r)n[r]=1024}function Bn(n,r,t,c){var i,f=r[t];i=(n.E>>>11)*f,c?(n.xc=e(n.xc,o(b(i),[4294967295,0])),n.E-=i,r[t]=f-(f>>>5)<<16>>16):(n.E=i,r[t]=f+(2048-f>>>5)<<16>>16),-16777216&n.E||(n.E<<=8,Gn(n))}function Un(n,r,t){for(var c=t-1;c>=0;--c)n.E>>>=1,1==(r>>>c&1)&&(n.xc=e(n.xc,b(n.E))),-16777216&n.E||(n.E<<=8,Gn(n))}function _n(n){return e(e(b(n.Jb),n.mc),[4,0])}function Gn(n){var r,t=a(function(n,r){var t;return t=d(n,r&=63),0>n[1]&&(t=e(t,s([2,0],63-r))),t}(n.xc,32));if(0!=t||i(n.xc,[4278190080,0])<0){n.mc=e(n.mc,b(n.Jb)),r=n.Oc;do{y(n.Ab,r+t),r=255}while(0!=--n.Jb);n.Oc=a(n.xc)>>>24}++n.Jb,n.xc=s(o(n.xc,[16777215,0]),8)}function Jn(n,r){return Pn[(2047&(n-r^-r))>>>2]}function qn(n){for(var r,t,c,e=0,o=0,i=n.length,f=[],u=[];i>e;++e,++o){if(128&(r=255&n[e]))if(192==(224&r)){if(e+1>=i)return n;if(128!=(192&(t=255&n[++e])))return n;u[o]=(31&r)<<6|63&t}else{if(224!=(240&r))return n;if(e+2>=i)return n;if(128!=(192&(t=255&n[++e])))return n;if(128!=(192&(c=255&n[++e])))return n;u[o]=(15&r)<<12|(63&t)<<6|63&c}else{if(!r)return n;u[o]=r}16383==o&&(f.push(String.fromCharCode.apply(String,u)),o=-1)}return o>0&&(u.length=o,f.push(String.fromCharCode.apply(String,u))),f.join("")}function Fn(n){var r,t,c,e=[],o=0,i=n.length;if("object"==typeof n)return n;for(function(n,r,t,c,e){var o;for(o=r;t>o;++o)c[e++]=n.charCodeAt(o)}(n,0,i,e,0),c=0;i>c;++c)(r=e[c])>=1&&127>=r?++o:o+=!r||r>=128&&2047>=r?2:3;for(t=[],o=0,c=0;i>c;++c)(r=e[c])>=1&&127>=r?t[o++]=r<<24>>24:!r||r>=128&&2047>=r?(t[o++]=(192|r>>6&31)<<24>>24,t[o++]=(128|63&r)<<24>>24):(t[o++]=(224|r>>12&15)<<24>>24,t[o++]=(128|r>>6&63)<<24>>24,t[o++]=(128|63&r)<<24>>24);return t}function On(n){return n[1]+n[0]}var Qn=1,Dn=2,Nn=3,Sn="function"==typeof n?n:setTimeout,Zn=4294967296,Kn=[4294967295,-Zn],Vn=[0,-0x8000000000000000],Yn=[0,0],Rn=[1,0],$n=function(){var n,r,t,c=[];for(n=0;256>n;++n){for(t=n,r=0;8>r;++r)0!=(1&t)?t=t>>>1^-306674912:t>>>=1;c[n]=t}return c}(),Hn=function(){var n,r,t,c=2,e=[0,1];for(t=2;22>t;++t)for(r=1<<(t>>1)-1,n=0;r>n;++n,++c)e[c]=t<<24>>24;return e}(),Pn=function(){var n,r,t,c=[];for(r=8;r>=0;--r)for(n=1<<9-r,t=1<<9-r-1;n>t;++t)c[t]=(r<<6)+(n-t<<6>>>9-r-1);return c}(),Wn=function(){var n=[{s:16,f:64,m:0},{s:20,f:64,m:0},{s:19,f:64,m:1},{s:20,f:64,m:1},{s:21,f:128,m:1},{s:22,f:128,m:1},{s:23,f:128,m:1},{s:24,f:255,m:1},{s:25,f:255,m:1}];return function(r){return n[r-1]||n[6]}}();return"undefined"==typeof onmessage||"undefined"!=typeof window&&void 0!==window.document||(onmessage=function(n){n&&n.gc&&(n.gc.action==Dn?r.decompress(n.gc.gc,n.gc.cbn):n.gc.action==Qn&&r.compress(n.gc.gc,n.gc.Rc,n.gc.cbn))}),{compress:function(n,r,c,e){var o,i,f={},u=void 0===c&&void 0===e;if("function"!=typeof c&&(i=c,c=e=0),e=e||function(n){return void 0!==i?t(n,i):void 0},c=c||function(n,r){return void 0!==i?postMessage({action:Qn,cbn:i,result:n,error:r}):void 0},u){for(f.c=M({},Fn(n),Wn(r));D(f.c.yb););return x(f.c.Nb)}try{f.c=M({},Fn(n),Wn(r)),e(0)}catch(n){return c(null,n)}Sn((function n(){try{for(var r,t=(new Date).getTime();D(f.c.yb);)if(o=On(f.c.yb.Pb)/On(f.c.Tb),(new Date).getTime()-t>200)return e(o),Sn(n,0),0;e(1),r=x(f.c.Nb),Sn(c.bind(null,r),0)}catch(n){c(null,n)}}),0)},decompress:function(n,r,c){var e,o,i,f,u={},b=void 0===r&&void 0===c;if("function"!=typeof r&&(o=r,r=c=0),c=c||function(n){return void 0!==o?t(i?n:-1,o):void 0},r=r||function(n,r){return void 0!==o?postMessage({action:Dn,cbn:o,result:n,error:r}):void 0},b){for(u.d=I({},n);D(u.d.yb););return qn(x(u.d.Nb))}try{u.d=I({},n),f=On(u.d.Tb),i=f>-1,c(0)}catch(n){return r(null,n)}Sn((function n(){try{for(var t,o=0,b=(new Date).getTime();D(u.d.yb);)if(++o%1e3==0&&(new Date).getTime()-b>200)return i&&(e=On(u.d.yb.Z.g)/f,c(e)),Sn(n,0),0;c(1),t=qn(x(u.d.Nb)),Sn(r.bind(null,t),0)}catch(n){r(null,n)}}),0)}}}();this.LZMA=this.LZMA_WORKER=r}).call(this,t(28).setImmediate)},19:function(n,r){var t,c,e=n.exports={};function o(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function f(n){if(t===setTimeout)return setTimeout(n,0);if((t===o||!t)&&setTimeout)return t=setTimeout,setTimeout(n,0);try{return t(n,0)}catch(r){try{return t.call(null,n,0)}catch(r){return t.call(this,n,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:o}catch(n){t=o}try{c="function"==typeof clearTimeout?clearTimeout:i}catch(n){c=i}}();var u,b=[],a=!1,l=-1;function s(){a&&u&&(a=!1,u.length?b=u.concat(b):l=-1,b.length&&d())}function d(){if(!a){var n=f(s);a=!0;for(var r=b.length;r;){for(u=b,b=[];++l1)for(var t=1;t=0&&(n._idleTimeoutId=setTimeout((function(){n._onTimeout&&n._onTimeout()}),r))},t(29),r.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==n&&n.setImmediate||this&&this.setImmediate,r.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==n&&n.clearImmediate||this&&this.clearImmediate}).call(this,t(7))},29:function(n,r,t){(function(n,r){!function(n,t){"use strict";if(!n.setImmediate){var c,e,o,i,f,u=1,b={},a=!1,l=n.document,s=Object.getPrototypeOf&&Object.getPrototypeOf(n);s=s&&s.setTimeout?s:n,"[object process]"==={}.toString.call(n.process)?c=function(n){r.nextTick((function(){v(n)}))}:!function(){if(n.postMessage&&!n.importScripts){var r=!0,t=n.onmessage;return n.onmessage=function(){r=!1},n.postMessage("","*"),n.onmessage=t,r}}()?n.MessageChannel?((o=new MessageChannel).port1.onmessage=function(n){v(n.data)},c=function(n){o.port2.postMessage(n)}):l&&"onreadystatechange"in l.createElement("script")?(e=l.documentElement,c=function(n){var r=l.createElement("script");r.onreadystatechange=function(){v(n),r.onreadystatechange=null,e.removeChild(r),r=null},e.appendChild(r)}):c=function(n){setTimeout(v,0,n)}:(i="setImmediate$"+Math.random()+"$",f=function(r){r.source===n&&"string"==typeof r.data&&0===r.data.indexOf(i)&&v(+r.data.slice(i.length))},n.addEventListener?n.addEventListener("message",f,!1):n.attachEvent("onmessage",f),c=function(r){n.postMessage(i+r,"*")}),s.setImmediate=function(n){"function"!=typeof n&&(n=new Function(""+n));for(var r=new Array(arguments.length-1),t=0;t=0,"must have a non-negative type"),i(a,"must have a decode function"),this.registerEncoder((function(e){return e instanceof t}),(function(t){var i=o(),a=r.allocUnsafe(1);return a.writeInt8(e,0),i.append(a),i.append(n(t)),i})),this.registerDecoder(e,a),this},registerEncoder:function(e,n){return i(e,"must have an encode function"),i(n,"must have an encode function"),t.push({check:e,encode:n}),this},registerDecoder:function(e,t){return i(e>=0,"must have a non-negative type"),i(t,"must have a decode function"),n.push({type:e,decode:t}),this},encoder:a.encoder,decoder:a.decoder,buffer:!0,type:"msgpack5",IncompleteBufferError:s.IncompleteBufferError}}},,,,,function(e,t){var n,r,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function s(e){if(n===setTimeout)return setTimeout(e,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(e){n=o}try{r="function"==typeof clearTimeout?clearTimeout:a}catch(e){r=a}}();var u,f=[],c=!1,l=-1;function h(){c&&u&&(c=!1,u.length?f=u.concat(f):l=-1,f.length&&d())}function d(){if(!c){var e=s(h);c=!0;for(var t=f.length;t;){for(u=f,f=[];++l1)for(var n=1;nthis.length||e<0)){var t=this._offset(e);return this._bufs[t[0]][t[1]]}},a.prototype.slice=function(e,t){return"number"==typeof e&&e<0&&(e+=this.length),"number"==typeof t&&t<0&&(t+=this.length),this.copy(null,0,e,t)},a.prototype.copy=function(e,t,n,r){if(("number"!=typeof n||n<0)&&(n=0),("number"!=typeof r||r>this.length)&&(r=this.length),n>=this.length)return e||o.alloc(0);if(r<=0)return e||o.alloc(0);var i,a,s=!!e,u=this._offset(n),f=r-n,c=f,l=s&&t||0,h=u[1];if(0===n&&r==this.length){if(!s)return 1===this._bufs.length?this._bufs[0]:o.concat(this._bufs,this.length);for(a=0;a(i=this._bufs[a].length-h))){this._bufs[a].copy(e,l,h,h+c),l+=i;break}this._bufs[a].copy(e,l,h),l+=i,c-=i,h&&(h=0)}return e.length>l?e.slice(0,l):e},a.prototype.shallowSlice=function(e,t){if(e=e||0,t="number"!=typeof t?this.length:t,e<0&&(e+=this.length),t<0&&(t+=this.length),e===t)return new a;var n=this._offset(e),r=this._offset(t),i=this._bufs.slice(n[0],r[0]+1);return 0==r[1]?i.pop():i[i.length-1]=i[i.length-1].slice(0,r[1]),0!=n[1]&&(i[0]=i[0].slice(n[1])),new a(i)},a.prototype.toString=function(e,t,n){return this.slice(t,n).toString(e)},a.prototype.consume=function(e){if(e=Math.trunc(e),Number.isNaN(e)||e<=0)return this;for(;this._bufs.length;){if(!(e>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(e),this.length-=e;break}e-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},a.prototype.duplicate=function(){for(var e=0,t=new a;ethis.length?this.length:t;for(var r=this._offset(t),i=r[0],s=r[1];i=e.length){var f=u.indexOf(e,s);if(-1!==f)return this._reverseOffset([i,f]);s=u.length-e.length+1}else{var c=this._reverseOffset([i,s]);if(this._match(c,e))return c;s++}}s=0}return-1},a.prototype._match=function(e,t){if(this.length-e=o)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}})),u=r[n];n=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),p(n)?r.showHidden=n:n&&t._extend(r,n),m(r.showHidden)&&(r.showHidden=!1),m(r.depth)&&(r.depth=2),m(r.colors)&&(r.colors=!1),m(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=u),c(r,e,r.depth)}function u(e,t){var n=s.styles[t];return n?"["+s.colors[n][0]+"m"+e+"["+s.colors[n][1]+"m":e}function f(e,t){return e}function c(e,n,r){if(e.customInspect&&n&&S(n.inspect)&&n.inspect!==t.inspect&&(!n.constructor||n.constructor.prototype!==n)){var i=n.inspect(r,e);return b(i)||(i=c(e,i,r)),i}var o=function(e,t){if(m(t))return e.stylize("undefined","undefined");if(b(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}if(y(t))return e.stylize(""+t,"number");if(p(t))return e.stylize(""+t,"boolean");if(g(t))return e.stylize("null","null")}(e,n);if(o)return o;var a=Object.keys(n),s=function(e){var t={};return e.forEach((function(e,n){t[e]=!0})),t}(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(n)),E(n)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return l(n);if(0===a.length){if(S(n)){var u=n.name?": "+n.name:"";return e.stylize("[Function"+u+"]","special")}if(v(n))return e.stylize(RegExp.prototype.toString.call(n),"regexp");if(_(n))return e.stylize(Date.prototype.toString.call(n),"date");if(E(n))return l(n)}var f,w="",k=!1,x=["{","}"];(d(n)&&(k=!0,x=["[","]"]),S(n))&&(w=" [Function"+(n.name?": "+n.name:"")+"]");return v(n)&&(w=" "+RegExp.prototype.toString.call(n)),_(n)&&(w=" "+Date.prototype.toUTCString.call(n)),E(n)&&(w=" "+l(n)),0!==a.length||k&&0!=n.length?r<0?v(n)?e.stylize(RegExp.prototype.toString.call(n),"regexp"):e.stylize("[Object]","special"):(e.seen.push(n),f=k?function(e,t,n,r,i){for(var o=[],a=0,s=t.length;a=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0);if(r>60)return n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1];return n[0]+t+" "+e.join(", ")+" "+n[1]}(f,w,x)):x[0]+w+x[1]}function l(e){return"["+Error.prototype.toString.call(e)+"]"}function h(e,t,n,r,i,o){var a,s,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?s=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(s=e.stylize("[Setter]","special")),O(r,i)||(a="["+i+"]"),s||(e.seen.indexOf(u.value)<0?(s=g(n)?c(e,u.value,null):c(e,u.value,n-1)).indexOf("\n")>-1&&(s=o?s.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+s.split("\n").map((function(e){return" "+e})).join("\n")):s=e.stylize("[Circular]","special")),m(a)){if(o&&i.match(/^\d+$/))return s;(a=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+s}function d(e){return Array.isArray(e)}function p(e){return"boolean"==typeof e}function g(e){return null===e}function y(e){return"number"==typeof e}function b(e){return"string"==typeof e}function m(e){return void 0===e}function v(e){return w(e)&&"[object RegExp]"===k(e)}function w(e){return"object"==typeof e&&null!==e}function _(e){return w(e)&&"[object Date]"===k(e)}function E(e){return w(e)&&("[object Error]"===k(e)||e instanceof Error)}function S(e){return"function"==typeof e}function k(e){return Object.prototype.toString.call(e)}function x(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(n){if(m(o)&&(o=e.env.NODE_DEBUG||""),n=n.toUpperCase(),!a[n])if(new RegExp("\\b"+n+"\\b","i").test(o)){var r=e.pid;a[n]=function(){var e=t.format.apply(t,arguments);console.error("%s %d: %s",n,r,e)}}else a[n]=function(){};return a[n]},t.inspect=s,s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.isArray=d,t.isBoolean=p,t.isNull=g,t.isNullOrUndefined=function(e){return null==e},t.isNumber=y,t.isString=b,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=m,t.isRegExp=v,t.isObject=w,t.isDate=_,t.isError=E,t.isFunction=S,t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=n(40);var j=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function O(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){var e,n;console.log("%s - %s",(e=new Date,n=[x(e.getHours()),x(e.getMinutes()),x(e.getSeconds())].join(":"),[e.getDate(),j[e.getMonth()],n].join(" ")),t.format.apply(t,arguments))},t.inherits=n(41),t._extend=function(e,t){if(!t||!w(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e};var T="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function U(e,t){if(!e){var n=new Error("Promise was rejected with a falsy value");n.reason=e,e=n}return t(e)}t.promisify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(T&&e[T]){var t;if("function"!=typeof(t=e[T]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(t,T,{value:t,enumerable:!1,writable:!1,configurable:!0}),t}function t(){for(var t,n,r=new Promise((function(e,r){t=e,n=r})),i=[],o=0;o=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},n(29),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,n(7))},function(e,t,n){(function(e,t){!function(e,n){"use strict";if(!e.setImmediate){var r,i,o,a,s,u=1,f={},c=!1,l=e.document,h=Object.getPrototypeOf&&Object.getPrototypeOf(e);h=h&&h.setTimeout?h:e,"[object process]"==={}.toString.call(e.process)?r=function(e){t.nextTick((function(){p(e)}))}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}}()?e.MessageChannel?((o=new MessageChannel).port1.onmessage=function(e){p(e.data)},r=function(e){o.port2.postMessage(e)}):l&&"onreadystatechange"in l.createElement("script")?(i=l.documentElement,r=function(e){var t=l.createElement("script");t.onreadystatechange=function(){p(e),t.onreadystatechange=null,i.removeChild(t),t=null},i.appendChild(t)}):r=function(e){setTimeout(p,0,e)}:(a="setImmediate$"+Math.random()+"$",s=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(a)&&p(+t.data.slice(a.length))},e.addEventListener?e.addEventListener("message",s,!1):e.attachEvent("onmessage",s),r=function(t){e.postMessage(a+t,"*")}),h.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;n0?("string"==typeof t||a.objectMode||Object.getPrototypeOf(t)===f.prototype||(t=function(e){return f.from(e)}(t)),r?a.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):_(e,a,t,!0):a.ended?e.emit("error",new Error("stream.push() after EOF")):(a.reading=!1,a.decoder&&!n?(t=a.decoder.write(t),a.objectMode||0!==t.length?_(e,a,t,!1):j(e,a)):_(e,a,t,!1))):r||(a.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=E?e=E:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function k(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(d("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?i.nextTick(x,e):x(e))}function x(e){d("emit readable"),e.emit("readable"),B(e)}function j(e,t){t.readingMore||(t.readingMore=!0,i.nextTick(O,e,t))}function O(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):n=function(e,t,n){var r;eo.length?o.length:e;if(a===o.length?i+=o:i+=o.slice(0,e),0===(e-=a)){a===o.length?(++r,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(a));break}++r}return t.length-=r,i}(e,t):function(e,t){var n=f.allocUnsafe(e),r=t.head,i=1;r.data.copy(n),e-=r.data.length;for(;r=r.next;){var o=r.data,a=e>o.length?o.length:e;if(o.copy(n,n.length-e,0,a),0===(e-=a)){a===o.length?(++i,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(a));break}++i}return t.length-=i,n}(e,t);return r}(e,t.buffer,t.decoder),n);var n}function M(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,i.nextTick(L,t,e))}function L(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function C(e,t){for(var n=0,r=e.length;n=t.highWaterMark||t.ended))return d("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?M(this):k(this),null;if(0===(e=S(e,t))&&t.ended)return 0===t.length&&M(this),null;var r,i=t.needReadable;return d("need readable",i),(0===t.length||t.length-e0?I(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&M(this)),null!==r&&this.emit("data",r),r},v.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},v.prototype.pipe=function(e,t){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,d("pipe count=%d opts=%j",o.pipesCount,t);var u=(!t||!1!==t.end)&&e!==r.stdout&&e!==r.stderr?c:v;function f(t,r){d("onunpipe"),t===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,d("cleanup"),e.removeListener("close",b),e.removeListener("finish",m),e.removeListener("drain",l),e.removeListener("error",y),e.removeListener("unpipe",f),n.removeListener("end",c),n.removeListener("end",v),n.removeListener("data",g),h=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||l())}function c(){d("onend"),e.end()}o.endEmitted?i.nextTick(u):n.once("end",u),e.on("unpipe",f);var l=function(e){return function(){var t=e._readableState;d("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&s(e,"data")&&(t.flowing=!0,B(e))}}(n);e.on("drain",l);var h=!1;var p=!1;function g(t){d("ondata"),p=!1,!1!==e.write(t)||p||((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==C(o.pipes,e))&&!h&&(d("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,p=!0),n.pause())}function y(t){d("onerror",t),v(),e.removeListener("error",y),0===s(e,"error")&&e.emit("error",t)}function b(){e.removeListener("finish",m),v()}function m(){d("onfinish"),e.removeListener("close",b),v()}function v(){d("unpipe"),n.unpipe(e)}return n.on("data",g),function(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?a(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}(e,"error",y),e.once("close",b),e.once("finish",m),e.emit("pipe",n),o.flowing||(d("pipe resume"),n.resume()),e},v.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,n)),this;if(!e){var r=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o0&&a.length>i&&!a.warned){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=a.length,s=u,console&&console.warn&&console.warn(s)}return e}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=h.bind(r);return i.listener=n,r.wrapFn=i,i}function p(e,t,n){var r=e._events;if(void 0===r)return[];var i=r[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n0&&(a=t[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var u=i[e];if(void 0===u)return!1;if("function"==typeof u)o(u,this,t);else{var f=u.length,c=y(u,f);for(n=0;n=0;o--)if(n[o]===t||n[o].listener===t){a=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1=0;r--)this.removeListener(e,t[r]);return this},s.prototype.listeners=function(e){return p(this,e,!0)},s.prototype.rawListeners=function(e){return p(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):g.call(e,t)},s.prototype.listenerCount=g,s.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}},function(e,t,n){e.exports=n(32).EventEmitter},function(e,t,n){"use strict";var r=n(24);function i(e,t){e.emit("error",t)}e.exports={destroy:function(e,t){var n=this,o=this._readableState&&this._readableState.destroyed,a=this._writableState&&this._writableState.destroyed;return o||a?(t?t(e):!e||this._writableState&&this._writableState.errorEmitted||r.nextTick(i,this,e),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,(function(e){!t&&e?(r.nextTick(i,n,e),n._writableState&&(n._writableState.errorEmitted=!0)):t&&t(e)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},function(e,t,n){"use strict";(function(t,r,i){var o=n(24);function a(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,n){var r=e.entry;e.entry=null;for(;r;){var i=r.callback;t.pendingcb--,i(n),r=r.next}t.corkedRequestsFree?t.corkedRequestsFree.next=e:t.corkedRequestsFree=e}(t,e)}}e.exports=m;var s,u=!t.browser&&["v0.10","v0.9."].indexOf(t.version.slice(0,5))>-1?r:o.nextTick;m.WritableState=b;var f=Object.create(n(22));f.inherits=n(20);var c={deprecate:n(45)},l=n(33),h=n(27).Buffer,d=i.Uint8Array||function(){};var p,g=n(34);function y(){}function b(e,t){s=s||n(21),e=e||{};var r=t instanceof s;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,f=e.writableHighWaterMark,c=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r&&(f||0===f)?f:c,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var l=!1===e.decodeStrings;this.decodeStrings=!l,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var n=e._writableState,r=n.sync,i=n.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(n),t)!function(e,t,n,r,i){--t.pendingcb,n?(o.nextTick(i,r),o.nextTick(k,e,t),e._writableState.errorEmitted=!0,e.emit("error",r)):(i(r),e._writableState.errorEmitted=!0,e.emit("error",r),k(e,t))}(e,n,r,t,i);else{var a=E(n);a||n.corked||n.bufferProcessing||!n.bufferedRequest||_(e,n),r?u(w,e,n,a,i):w(e,n,a,i)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new a(this)}function m(e){if(s=s||n(21),!(p.call(m,this)||this instanceof s))return new m(e);this._writableState=new b(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),l.call(this)}function v(e,t,n,r,i,o,a){t.writelen=r,t.writecb=a,t.writing=!0,t.sync=!0,n?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function w(e,t,n,r){n||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,r(),k(e,t)}function _(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var r=t.bufferedRequestCount,i=new Array(r),o=t.corkedRequestsFree;o.entry=n;for(var s=0,u=!0;n;)i[s]=n,n.isBuf||(u=!1),n=n.next,s+=1;i.allBuffers=u,v(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new a(t),t.bufferedRequestCount=0}else{for(;n;){var f=n.chunk,c=n.encoding,l=n.callback;if(v(e,t,!1,t.objectMode?1:f.length,f,c,l),n=n.next,t.bufferedRequestCount--,t.writing)break}null===n&&(t.lastBufferedRequest=null)}t.bufferedRequest=n,t.bufferProcessing=!1}function E(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function S(e,t){e._final((function(n){t.pendingcb--,n&&e.emit("error",n),t.prefinished=!0,e.emit("prefinish"),k(e,t)}))}function k(e,t){var n=E(t);return n&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,o.nextTick(S,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),n}f.inherits(m,l),b.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(b.prototype,"buffer",{get:c.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(p=Function.prototype[Symbol.hasInstance],Object.defineProperty(m,Symbol.hasInstance,{value:function(e){return!!p.call(this,e)||this===m&&(e&&e._writableState instanceof b)}})):p=function(e){return e instanceof this},m.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},m.prototype.write=function(e,t,n){var r,i=this._writableState,a=!1,s=!i.objectMode&&(r=e,h.isBuffer(r)||r instanceof d);return s&&!h.isBuffer(e)&&(e=function(e){return h.from(e)}(e)),"function"==typeof t&&(n=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof n&&(n=y),i.ended?function(e,t){var n=new Error("write after end");e.emit("error",n),o.nextTick(t,n)}(this,n):(s||function(e,t,n,r){var i=!0,a=!1;return null===n?a=new TypeError("May not write null values to stream"):"string"==typeof n||void 0===n||t.objectMode||(a=new TypeError("Invalid non-string/buffer chunk")),a&&(e.emit("error",a),o.nextTick(r,a),i=!1),i}(this,i,e,n))&&(i.pendingcb++,a=function(e,t,n,r,i,o){if(!n){var a=function(e,t,n){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=h.from(t,n));return t}(t,r,i);r!==a&&(n=!0,i="buffer",r=a)}var s=t.objectMode?1:r.length;t.length+=s;var u=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(m.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),m.prototype._write=function(e,t,n){n(new Error("_write() is not implemented"))},m.prototype._writev=null,m.prototype.end=function(e,t,n){var r=this._writableState;"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!=e&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||r.finished||function(e,t,n){t.ending=!0,k(e,t),n&&(t.finished?o.nextTick(n):e.once("finish",n));t.ended=!0,e.writable=!1}(this,r,n)},Object.defineProperty(m.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),m.prototype.destroy=g.destroy,m.prototype._undestroy=g.undestroy,m.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,n(19),n(28).setImmediate,n(7))},function(e,t,n){"use strict";var r=n(46).Buffer,i=r.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(r.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=u,this.end=f,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=c,this.end=l,t=3;break;default:return this.write=h,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=r.allocUnsafe(t)}function a(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function s(e){var t=this.lastTotal-this.lastNeed,n=function(e,t,n){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==n?n:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function u(e,t){if((e.length-t)%2==0){var n=e.toString("utf16le",t);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function f(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function c(e,t){var n=(e.length-t)%3;return 0===n?e.toString("base64",t):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-n))}function l(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function h(e){return e.toString(this.encoding)}function d(e){return e&&e.length?this.write(e):""}t.StringDecoder=o,o.prototype.write=function(e){if(0===e.length)return"";var t,n;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n=0)return i>0&&(e.lastNeed=i-1),i;if(--r=0)return i>0&&(e.lastNeed=i-2),i;if(--r=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=n;var r=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,r),e.toString("utf8",t,r)},o.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},function(e,t,n){"use strict";e.exports=a;var r=n(21),i=Object.create(n(22));function o(e,t){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(!r)return this.emit("error",new Error("write callback called multiple times"));n.writechunk=null,n.writecb=null,null!=t&&this.push(t),r(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length=0;f--)if(c[f]!==l[f])return!1;for(f=c.length-1;f>=0;f--)if(!v(e[s=c[f]],t[s],n,r))return!1;return!0}(e,t,n,r))}return n?e===t:e==t}function w(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function _(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function E(e,t,n,r){var i;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof n&&(r=n,n=null),i=function(e){var t;try{e()}catch(e){t=e}return t}(t),r=(n&&n.name?" ("+n.name+").":".")+(r?" "+r:"."),e&&!i&&b(i,n,"Missing expected exception"+r);var o="string"==typeof r,s=!e&&i&&!n;if((!e&&a.isError(i)&&o&&_(i,n)||s)&&b(i,n,"Got unwanted exception"+r),e&&i&&n&&!_(i,n)||!e&&i)throw i}h.AssertionError=function(e){this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=function(e){return g(y(e.actual),128)+" "+e.operator+" "+g(y(e.expected),128)}(this),this.generatedMessage=!0);var t=e.stackStartFunction||b;if(Error.captureStackTrace)Error.captureStackTrace(this,t);else{var n=new Error;if(n.stack){var r=n.stack,i=p(t),o=r.indexOf("\n"+i);if(o>=0){var a=r.indexOf("\n",o+1);r=r.substring(a+1)}this.stack=r}}},a.inherits(h.AssertionError,Error),h.fail=b,h.ok=m,h.equal=function(e,t,n){e!=t&&b(e,t,n,"==",h.equal)},h.notEqual=function(e,t,n){e==t&&b(e,t,n,"!=",h.notEqual)},h.deepEqual=function(e,t,n){v(e,t,!1)||b(e,t,n,"deepEqual",h.deepEqual)},h.deepStrictEqual=function(e,t,n){v(e,t,!0)||b(e,t,n,"deepStrictEqual",h.deepStrictEqual)},h.notDeepEqual=function(e,t,n){v(e,t,!1)&&b(e,t,n,"notDeepEqual",h.notDeepEqual)},h.notDeepStrictEqual=function e(t,n,r){v(t,n,!0)&&b(t,n,r,"notDeepStrictEqual",e)},h.strictEqual=function(e,t,n){e!==t&&b(e,t,n,"===",h.strictEqual)},h.notStrictEqual=function(e,t,n){e===t&&b(e,t,n,"!==",h.notStrictEqual)},h.throws=function(e,t,n){E(!0,e,t,n)},h.doesNotThrow=function(e,t,n){E(!1,e,t,n)},h.ifError=function(e){if(e)throw e},h.strict=r((function e(t,n){t||b(t,!0,n,"==",e)}),h,{equal:h.strictEqual,deepEqual:h.deepStrictEqual,notEqual:h.notStrictEqual,notDeepEqual:h.notDeepStrictEqual}),h.strict.strict=h.strict;var S=Object.keys||function(e){var t=[];for(var n in e)s.call(e,n)&&t.push(n);return t}}).call(this,n(7))},function(e,t,n){"use strict";var r=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach((function(e){r[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var n,a,s=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),u=1;u0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n},e.prototype.concat=function(e){if(0===this.length)return r.alloc(0);if(1===this.length)return this.head.data;for(var t,n,i,o=r.allocUnsafe(e>>>0),a=this.head,s=0;a;)t=a.data,n=o,i=s,t.copy(n,i),s+=a.data.length,a=a.next;return o},e}(),i&&i.inspect&&i.inspect.custom&&(e.exports.prototype[i.inspect.custom]=function(){var e=i.inspect({length:this.length});return this.constructor.name+" "+e})},,function(e,t,n){(function(t){function n(e){try{if(!t.localStorage)return!1}catch(e){return!1}var n=t.localStorage[e];return null!=n&&"true"===String(n).toLowerCase()}e.exports=function(e,t){if(n("noDeprecation"))return e;var r=!1;return function(){if(!r){if(n("throwDeprecation"))throw new Error(t);n("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}}}).call(this,n(7))},function(e,t,n){var r=n(3),i=r.Buffer;function o(e,t){for(var n in e)t[n]=e[n]}function a(e,t,n){return i(e,t,n)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=r:(o(r,t),t.Buffer=a),o(i,a),a.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,n)},a.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=i(e);return void 0!==t?"string"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r},a.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},a.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},function(e,t,n){"use strict";e.exports=o;var r=n(37),i=Object.create(n(22));function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}i.inherits=n(20),i.inherits(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},function(e,t,n){"use strict";var r=n(30).Transform,i=n(20),o=n(23);function a(e){(e=e||{}).objectMode=!0,e.highWaterMark=16,r.call(this,e),this._msgpack=e.msgpack}function s(e){if(!(this instanceof s))return(e=e||{}).msgpack=this,new s(e);a.call(this,e),this._wrap="wrap"in e&&e.wrap}function u(e){if(!(this instanceof u))return(e=e||{}).msgpack=this,new u(e);a.call(this,e),this._chunks=o(),this._wrap="wrap"in e&&e.wrap}i(a,r),i(s,a),s.prototype._transform=function(e,t,n){var r=null;try{r=this._msgpack.encode(this._wrap?e.value:e).slice(0)}catch(e){return this.emit("error",e),n()}this.push(r),n()},i(u,a),u.prototype._transform=function(e,t,n){e&&this._chunks.append(e);try{var r=this._msgpack.decode(this._chunks);this._wrap&&(r={value:r}),this.push(r)}catch(e){return void(e instanceof this._msgpack.IncompleteBufferError?n():this.emit("error",e))}this._chunks.length>0?this._transform(null,t,n):n()},e.exports.decoder=u,e.exports.encoder=s},function(e,t,n){"use strict";var r=n(23);function i(e){Error.call(this),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.message=e||"unable to decode"}n(26).inherits(i,Error),e.exports=function(e,t){return function(e){e instanceof r||(e=r().append(e));var t=a(e);if(t)return e.consume(t.bytesConsumed),t.value;throw new i};function n(e,t,n){return t>=n+e}function o(e,t){return{value:e,bytesConsumed:t}}function a(e,t){t=void 0===t?0:t;var r=e.length-t;if(r<=0)return null;var i,a,l,h=e.readUInt8(t),d=0;if(!function(e,t){var n=function(e){switch(e){case 196:case 204:case 208:case 217:return 2;case 197:case 199:case 205:case 209:case 212:case 218:case 222:return 3;case 198:case 202:case 206:case 210:case 219:return 5;case 200:case 213:return 4;case 201:case 214:return 6;case 203:case 207:case 211:return 9;case 215:return 10;case 216:return 18;default:return-1}}(e);return!(-1!==n&&t=0;l--)d+=e.readUInt8(t+l+1)*Math.pow(2,8*(7-l));return o(d,9);case 208:return o(d=e.readInt8(t+1),2);case 209:return o(d=e.readInt16BE(t+1),3);case 210:return o(d=e.readInt32BE(t+1),5);case 211:return d=function(e,t){var n=128==(128&e[t]);if(n)for(var r=1,i=t+7;i>=t;i--){var o=(255^e[i])+r;e[i]=255&o,r=o>>8}var a=e.readUInt32BE(t+0),s=e.readUInt32BE(t+4);return(4294967296*a+s)*(n?-1:1)}(e.slice(t+1,t+9),0),o(d,9);case 202:return o(d=e.readFloatBE(t+1),5);case 203:return o(d=e.readDoubleBE(t+1),9);case 217:return n(i=e.readUInt8(t+1),r,2)?o(d=e.toString("utf8",t+2,t+2+i),2+i):null;case 218:return n(i=e.readUInt16BE(t+1),r,3)?o(d=e.toString("utf8",t+3,t+3+i),3+i):null;case 219:return n(i=e.readUInt32BE(t+1),r,5)?o(d=e.toString("utf8",t+5,t+5+i),5+i):null;case 196:return n(i=e.readUInt8(t+1),r,2)?o(d=e.slice(t+2,t+2+i),2+i):null;case 197:return n(i=e.readUInt16BE(t+1),r,3)?o(d=e.slice(t+3,t+3+i),3+i):null;case 198:return n(i=e.readUInt32BE(t+1),r,5)?o(d=e.slice(t+5,t+5+i),5+i):null;case 220:return r<3?null:(i=e.readUInt16BE(t+1),s(e,t,i,3));case 221:return r<5?null:(i=e.readUInt32BE(t+1),s(e,t,i,5));case 222:return i=e.readUInt16BE(t+1),u(e,t,i,3);case 223:return i=e.readUInt32BE(t+1),u(e,t,i,5);case 212:return f(e,t,1);case 213:return f(e,t,2);case 214:return f(e,t,4);case 215:return f(e,t,8);case 216:return f(e,t,16);case 199:return i=e.readUInt8(t+1),a=e.readUInt8(t+2),n(i,r,3)?c(e,t,a,i,3):null;case 200:return i=e.readUInt16BE(t+1),a=e.readUInt8(t+3),n(i,r,4)?c(e,t,a,i,4):null;case 201:return i=e.readUInt32BE(t+1),a=e.readUInt8(t+5),n(i,r,6)?c(e,t,a,i,6):null}if(144==(240&h))return s(e,t,i=15&h,1);if(128==(240&h))return u(e,t,i=15&h,1);if(160==(224&h))return n(i=31&h,r,1)?o(d=e.toString("utf8",t+1,t+i+1),i+1):null;if(h>=224)return o(d=h-256,1);if(h<128)return o(h,1);throw new Error("not implemented yet")}function s(e,t,n,r){var i,s=[],u=0;for(t+=r,i=0;i0&&c.write(u,1)):l<=255&&!n?((c=r.allocUnsafe(2+l))[0]=217,c[1]=l,c.write(u,2)):l<=65535?((c=r.allocUnsafe(3+l))[0]=218,c.writeUInt16BE(l,1),c.write(u,3)):((c=r.allocUnsafe(5+l))[0]=219,c.writeUInt32BE(l,1),c.write(u,5));else if(u&&(u.readUInt32LE||u instanceof Uint8Array))u instanceof Uint8Array&&(u=r.from(u)),u.length<=255?((c=r.allocUnsafe(2))[0]=196,c[1]=u.length):u.length<=65535?((c=r.allocUnsafe(3))[0]=197,c.writeUInt16BE(u.length,1)):((c=r.allocUnsafe(5))[0]=198,c.writeUInt32BE(u.length,1)),c=i([c,u]);else if(Array.isArray(u))u.length<16?(c=r.allocUnsafe(1))[0]=144|u.length:u.length<65536?((c=r.allocUnsafe(3))[0]=220,c.writeUInt16BE(u.length,1)):((c=r.allocUnsafe(5))[0]=221,c.writeUInt32BE(u.length,1)),c=u.reduce((function(e,t){return e.append(s(t,!0)),e}),i().append(c));else{if(!a&&"function"==typeof u.getDate)return function(e){var t,n=1*e,o=Math.floor(n/1e3),a=1e6*(n-1e3*o);if(a||o>4294967295){(t=r.allocUnsafe(10))[0]=215,t[1]=-1;var s=4*a+o/Math.pow(2,32)&4294967295,u=4294967295&o;t.writeInt32BE(s,2),t.writeInt32BE(u,6)}else(t=r.allocUnsafe(6))[0]=214,t[1]=-1,t.writeUInt32BE(Math.floor(n/1e3),2);return i().append(t)}(u);if("object"==typeof u)c=function(t){var n,o,a=-1,s=[];for(n=0;n>8),s.push(255&a)):(s.push(201),s.push(a>>24),s.push(a>>16&255),s.push(a>>8&255),s.push(255&a));return i().append(r.from(s)).append(o)}(u)||function(e){var t,n,o=[],a=0;for(t in e)e.hasOwnProperty(t)&&void 0!==e[t]&&"function"!=typeof e[t]&&(++a,o.push(s(t,!0)),o.push(s(e[t],!0)));a<16?(n=r.allocUnsafe(1))[0]=128|a:a<65535?((n=r.allocUnsafe(3))[0]=222,n.writeUInt16BE(a,1)):((n=r.allocUnsafe(5))[0]=223,n.writeUInt32BE(a,1));o.unshift(n);var u=o.reduce((function(e,t){return e.append(t)}),i());return u}(u);else if("number"==typeof u){if(function(e){return e%1!=0}(u))return o(u,t);if(u>=0)if(u<128)(c=r.allocUnsafe(1))[0]=u;else if(u<256)(c=r.allocUnsafe(2))[0]=204,c[1]=u;else if(u<65536)(c=r.allocUnsafe(3))[0]=205,c.writeUInt16BE(u,1);else if(u<=4294967295)(c=r.allocUnsafe(5))[0]=206,c.writeUInt32BE(u,1);else{if(!(u<=9007199254740991))return o(u,!0);(c=r.allocUnsafe(9))[0]=207,function(e,t){for(var n=7;n>=0;n--)e[n+1]=255&t,t/=256}(c,u)}else if(u>=-32)(c=r.allocUnsafe(1))[0]=256+u;else if(u>=-128)(c=r.allocUnsafe(2))[0]=208,c.writeInt8(u,1);else if(u>=-32768)(c=r.allocUnsafe(3))[0]=209,c.writeInt16BE(u,1);else if(u>-214748365)(c=r.allocUnsafe(5))[0]=210,c.writeInt32BE(u,1);else{if(!(u>=-9007199254740991))return o(u,!0);(c=r.allocUnsafe(9))[0]=211,function(e,t,n){var r=n<0;r&&(n=Math.abs(n));var i=n%4294967296,o=n/4294967296;if(e.writeUInt32BE(Math.floor(o),t+0),e.writeUInt32BE(i,t+4),r)for(var a=1,s=t+7;s>=t;s--){var u=(255^e[s])+a;e[s]=255&u,a=u>>8}}(c,1,u)}}}if(!c)throw new Error("not implemented yet");return f?c:c.slice()}return s}}]]); -------------------------------------------------------------------------------- /dist/browser/json-url-vendors~msgpack.js.LICENSE.txt: -------------------------------------------------------------------------------- 1 | /* 2 | object-assign 3 | (c) Sindre Sorhus 4 | @license MIT 5 | */ 6 | 7 | /*! 8 | * The buffer module from node.js, for the browser. 9 | * 10 | * @author Feross Aboukhadijeh 11 | * @license MIT 12 | */ 13 | 14 | /*! safe-buffer. MIT License. Feross Aboukhadijeh */ 15 | -------------------------------------------------------------------------------- /dist/browser/json-url.js: -------------------------------------------------------------------------------- 1 | /*! For license information please see json-url.js.LICENSE.txt */ 2 | !function(t,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.JsonUrl=r():t.JsonUrl=r()}(window,(function(){return function(t){function r(r){for(var e,o,i=r[0],u=r[1],a=0,f=[];a=u())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u().toString(16)+" bytes");return 0|t}function y(t,r){if(s.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var e=t.length;if(0===e)return 0;for(var n=!1;;)switch(r){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return z(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*e;case"hex":return e>>>1;case"base64":return F(t).length;default:if(n)return z(t).length;r=(""+r).toLowerCase(),n=!0}}function g(t,r,e){var n=!1;if((void 0===r||r<0)&&(r=0),r>this.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return U(this,r,e);case"utf8":case"utf-8":return R(this,r,e);case"ascii":return S(this,r,e);case"latin1":case"binary":return B(this,r,e);case"base64":return P(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function d(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function v(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=o?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=s.from(r,n)),s.isBuffer(r))return 0===r.length?-1:w(t,r,e,n,o);if("number"==typeof r)return r&=255,s.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):w(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function w(t,r,e,n,o){var i,u=1,a=t.length,s=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;u=2,a/=2,s/=2,e/=2}function f(t,r){return 1===u?t[r]:t.readUInt16BE(r*u)}if(o){var c=-1;for(i=e;ia&&(e=a-s),i=e;i>=0;i--){for(var h=!0,p=0;po&&(n=o):n=o;var i=r.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var u=0;u>8,o=e%256,i.push(o),i.push(n);return i}(r,t.length-e),t,e,n)}function P(t,r,e){return 0===r&&e===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(r,e))}function R(t,r,e){e=Math.min(t.length,e);for(var n=[],o=r;o239?4:f>223?3:f>191?2:1;if(o+h<=e)switch(h){case 1:f<128&&(c=f);break;case 2:128==(192&(i=t[o+1]))&&(s=(31&f)<<6|63&i)>127&&(c=s);break;case 3:i=t[o+1],u=t[o+2],128==(192&i)&&128==(192&u)&&(s=(15&f)<<12|(63&i)<<6|63&u)>2047&&(s<55296||s>57343)&&(c=s);break;case 4:i=t[o+1],u=t[o+2],a=t[o+3],128==(192&i)&&128==(192&u)&&128==(192&a)&&(s=(15&f)<<18|(63&i)<<12|(63&u)<<6|63&a)>65535&&s<1114112&&(c=s)}null===c?(c=65533,h=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=h}return function(t){var r=t.length;if(r<=T)return String.fromCharCode.apply(String,t);var e="",n=0;for(;n0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),""},s.prototype.compare=function(t,r,e,n,o){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&r>=e)return 0;if(n>=o)return-1;if(r>=e)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),u=(e>>>=0)-(r>>>=0),a=Math.min(i,u),f=this.slice(n,o),c=t.slice(r,e),h=0;ho)&&(e=o),t.length>0&&(e<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return m(this,t,r,e);case"utf8":case"utf-8":return b(this,t,r,e);case"ascii":return E(this,t,r,e);case"latin1":case"binary":return x(this,t,r,e);case"base64":return _(this,t,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,r,e);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var T=4096;function S(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;on)&&(e=n);for(var o="",i=r;ie)throw new RangeError("Trying to access beyond buffer length")}function L(t,r,e,n,o,i){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>o||rt.length)throw new RangeError("Index out of range")}function Y(t,r,e,n){r<0&&(r=65535+r+1);for(var o=0,i=Math.min(t.length-e,2);o>>8*(n?o:1-o)}function I(t,r,e,n){r<0&&(r=4294967295+r+1);for(var o=0,i=Math.min(t.length-e,4);o>>8*(n?o:3-o)&255}function M(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function j(t,r,e,n,i){return i||M(t,0,e,4),o.write(t,r,e,n,23,4),e+4}function C(t,r,e,n,i){return i||M(t,0,e,8),o.write(t,r,e,n,52,8),e+8}s.prototype.slice=function(t,r){var e,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(r=void 0===r?n:~~r)<0?(r+=n)<0&&(r=0):r>n&&(r=n),r0&&(o*=256);)n+=this[t+--r]*o;return n},s.prototype.readUInt8=function(t,r){return r||k(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,r){return r||k(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,r){return r||k(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,r){return r||k(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,r){return r||k(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,r,e){t|=0,r|=0,e||k(t,r,this.length);for(var n=this[t],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*r)),n},s.prototype.readIntBE=function(t,r,e){t|=0,r|=0,e||k(t,r,this.length);for(var n=r,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*r)),i},s.prototype.readInt8=function(t,r){return r||k(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,r){r||k(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},s.prototype.readInt16BE=function(t,r){r||k(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},s.prototype.readInt32LE=function(t,r){return r||k(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,r){return r||k(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,r){return r||k(t,4,this.length),o.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,r){return r||k(t,4,this.length),o.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,r){return r||k(t,8,this.length),o.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,r){return r||k(t,8,this.length),o.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r|=0,e|=0,n)||L(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i=0&&(i*=256);)this[r+o]=t/i&255;return r+e},s.prototype.writeUInt8=function(t,r,e){return t=+t,r|=0,e||L(this,t,r,1,255,0),s.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=255&t,r+1},s.prototype.writeUInt16LE=function(t,r,e){return t=+t,r|=0,e||L(this,t,r,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):Y(this,t,r,!0),r+2},s.prototype.writeUInt16BE=function(t,r,e){return t=+t,r|=0,e||L(this,t,r,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):Y(this,t,r,!1),r+2},s.prototype.writeUInt32LE=function(t,r,e){return t=+t,r|=0,e||L(this,t,r,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t):I(this,t,r,!0),r+4},s.prototype.writeUInt32BE=function(t,r,e){return t=+t,r|=0,e||L(this,t,r,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):I(this,t,r,!1),r+4},s.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r|=0,!n){var o=Math.pow(2,8*e-1);L(this,t,r,e,o-1,-o)}var i=0,u=1,a=0;for(this[r]=255&t;++i>0)-a&255;return r+e},s.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r|=0,!n){var o=Math.pow(2,8*e-1);L(this,t,r,e,o-1,-o)}var i=e-1,u=1,a=0;for(this[r+i]=255&t;--i>=0&&(u*=256);)t<0&&0===a&&0!==this[r+i+1]&&(a=1),this[r+i]=(t/u>>0)-a&255;return r+e},s.prototype.writeInt8=function(t,r,e){return t=+t,r|=0,e||L(this,t,r,1,127,-128),s.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[r]=255&t,r+1},s.prototype.writeInt16LE=function(t,r,e){return t=+t,r|=0,e||L(this,t,r,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):Y(this,t,r,!0),r+2},s.prototype.writeInt16BE=function(t,r,e){return t=+t,r|=0,e||L(this,t,r,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):Y(this,t,r,!1),r+2},s.prototype.writeInt32LE=function(t,r,e){return t=+t,r|=0,e||L(this,t,r,4,2147483647,-2147483648),s.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24):I(this,t,r,!0),r+4},s.prototype.writeInt32BE=function(t,r,e){return t=+t,r|=0,e||L(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),s.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):I(this,t,r,!1),r+4},s.prototype.writeFloatLE=function(t,r,e){return j(this,t,r,!0,e)},s.prototype.writeFloatBE=function(t,r,e){return j(this,t,r,!1,e)},s.prototype.writeDoubleLE=function(t,r,e){return C(this,t,r,!0,e)},s.prototype.writeDoubleBE=function(t,r,e){return C(this,t,r,!1,e)},s.prototype.copy=function(t,r,e,n){if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r=0;--o)t[o+r]=this[o+e];else if(i<1e3||!s.TYPED_ARRAY_SUPPORT)for(o=0;o>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(i=r;i55295&&e<57344){if(!o){if(e>56319){(r-=3)>-1&&i.push(239,191,189);continue}if(u+1===n){(r-=3)>-1&&i.push(239,191,189);continue}o=e;continue}if(e<56320){(r-=3)>-1&&i.push(239,191,189),o=e;continue}e=65536+(o-55296<<10|e-56320)}else o&&(r-=3)>-1&&i.push(239,191,189);if(o=null,e<128){if((r-=1)<0)break;i.push(e)}else if(e<2048){if((r-=2)<0)break;i.push(e>>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function F(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(N,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function J(t,r,e,n){for(var o=0;o=r.length||o>=t.length);++o)r[o+e]=t[o];return o}}).call(this,e(7))},function(t,r,e){"use strict";(function(t){var n,o,i=e(1),u=e.n(i),a=e(0),s=e.n(a),f=e(2);r.a={pack:!0,encode:!0,compress:(o=u()(s.a.mark((function r(e){var n;return s.a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,f.a.lzma();case 2:return n=r.sent,r.abrupt("return",new Promise((function(r,o){return n.compress(e,9,(function(e,n){return n?o(n):r(t.from(e))}))})));case 4:case"end":return r.stop()}}),r)}))),function(t){return o.apply(this,arguments)}),decompress:(n=u()(s.a.mark((function r(e){var n;return s.a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,f.a.lzma();case 2:return n=r.sent,r.abrupt("return",new Promise((function(r,o){return n.decompress(e,(function(e,n){return n?o(n):r(t.from(e))}))})));case 4:case"end":return r.stop()}}),r)}))),function(t){return n.apply(this,arguments)})}}).call(this,e(3).Buffer)},function(t,r,e){"use strict";(function(t){var n,o,i=e(1),u=e.n(i),a=e(0),s=e.n(a),f=e(2);r.a={pack:!1,encode:!0,compress:(o=u()(s.a.mark((function r(e){return s.a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.t0=t,r.next=3,f.a.lzstring();case 3:return r.t1=r.sent.compressToUint8Array(e),r.abrupt("return",r.t0.from.call(r.t0,r.t1));case 5:case"end":return r.stop()}}),r)}))),function(t){return o.apply(this,arguments)}),decompress:(n=u()(s.a.mark((function t(r){return s.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,f.a.lzstring();case 2:return t.abrupt("return",t.sent.decompressFromUint8Array(r));case 3:case"end":return t.stop()}}),t)}))),function(t){return n.apply(this,arguments)})}}).call(this,e(3).Buffer)},function(t,r,e){"use strict";(function(t){var n,o,i=e(1),u=e.n(i),a=e(0),s=e.n(a),f=e(2);r.a={pack:!0,encode:!0,compress:(o=u()(s.a.mark((function r(e){return s.a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.t0=t,r.next=3,f.a.lzw();case 3:return r.t1=r.sent.encode(e.toString("binary")),r.abrupt("return",r.t0.from.call(r.t0,r.t1));case 5:case"end":return r.stop()}}),r)}))),function(t){return o.apply(this,arguments)}),decompress:(n=u()(s.a.mark((function r(e){return s.a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.t0=t,r.next=3,f.a.lzw();case 3:return r.t1=r.sent.decode(e),r.abrupt("return",r.t0.from.call(r.t0,r.t1,"binary"));case 5:case"end":return r.stop()}}),r)}))),function(t){return n.apply(this,arguments)})}}).call(this,e(3).Buffer)},function(t,r){var e;e=function(){return this}();try{e=e||new Function("return this")()}catch(t){"object"==typeof window&&(e=window)}t.exports=e},function(t,r){var e={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==e.call(t)}},function(t,r,e){var n=e(10).default;function o(){"use strict";t.exports=o=function(){return r},t.exports.__esModule=!0,t.exports.default=t.exports;var r={},e=Object.prototype,i=e.hasOwnProperty,u=Object.defineProperty||function(t,r,e){t[r]=e.value},a="function"==typeof Symbol?Symbol:{},s=a.iterator||"@@iterator",f=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function h(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{h({},"")}catch(t){h=function(t,r,e){return t[r]=e}}function p(t,r,e,n){var o=r&&r.prototype instanceof g?r:g,i=Object.create(o.prototype),a=new S(n||[]);return u(i,"_invoke",{value:A(t,e,a)}),i}function l(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}r.wrap=p;var y={};function g(){}function d(){}function v(){}var w={};h(w,s,(function(){return this}));var m=Object.getPrototypeOf,b=m&&m(m(B([])));b&&b!==e&&i.call(b,s)&&(w=b);var E=v.prototype=g.prototype=Object.create(w);function x(t){["next","throw","return"].forEach((function(r){h(t,r,(function(t){return this._invoke(r,t)}))}))}function _(t,r){function e(o,u,a,s){var f=l(t[o],t,u);if("throw"!==f.type){var c=f.arg,h=c.value;return h&&"object"==n(h)&&i.call(h,"__await")?r.resolve(h.__await).then((function(t){e("next",t,a,s)}),(function(t){e("throw",t,a,s)})):r.resolve(h).then((function(t){c.value=t,a(c)}),(function(t){return e("throw",t,a,s)}))}s(f.arg)}var o;u(this,"_invoke",{value:function(t,n){function i(){return new r((function(r,o){e(t,n,r,o)}))}return o=o?o.then(i,i):i()}})}function A(t,r,e){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return U()}for(e.method=o,e.arg=i;;){var u=e.delegate;if(u){var a=P(u,e);if(a){if(a===y)continue;return a}}if("next"===e.method)e.sent=e._sent=e.arg;else if("throw"===e.method){if("suspendedStart"===n)throw n="completed",e.arg;e.dispatchException(e.arg)}else"return"===e.method&&e.abrupt("return",e.arg);n="executing";var s=l(t,r,e);if("normal"===s.type){if(n=e.done?"completed":"suspendedYield",s.arg===y)continue;return{value:s.arg,done:e.done}}"throw"===s.type&&(n="completed",e.method="throw",e.arg=s.arg)}}}function P(t,r){var e=r.method,n=t.iterator[e];if(void 0===n)return r.delegate=null,"throw"===e&&t.iterator.return&&(r.method="return",r.arg=void 0,P(t,r),"throw"===r.method)||"return"!==e&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+e+"' method")),y;var o=l(n,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,y;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,y):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function R(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function T(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(R,this),this.reset(!0)}function B(t){if(t){var r=t[s];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var e=-1,n=function r(){for(;++e=0;--n){var o=this.tryEntries[n],u=o.completion;if("root"===o.tryLoc)return e("end");if(o.tryLoc<=this.prev){var a=i.call(o,"catchLoc"),s=i.call(o,"finallyLoc");if(a&&s){if(this.prev=0;--e){var n=this.tryEntries[e];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),T(e),y}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;T(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,e){return this.delegate={iterator:B(t),resultName:r,nextLoc:e},"next"===this.method&&(this.arg=void 0),y}},r}t.exports=o,t.exports.__esModule=!0,t.exports.default=t.exports},function(t,r){function e(r){return t.exports=e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports},function(t,r,e){"use strict";r.byteLength=function(t){var r=s(t),e=r[0],n=r[1];return 3*(e+n)/4-n},r.toByteArray=function(t){var r,e,n=s(t),u=n[0],a=n[1],f=new i(function(t,r,e){return 3*(r+e)/4-e}(0,u,a)),c=0,h=a>0?u-4:u;for(e=0;e>16&255,f[c++]=r>>8&255,f[c++]=255&r;2===a&&(r=o[t.charCodeAt(e)]<<2|o[t.charCodeAt(e+1)]>>4,f[c++]=255&r);1===a&&(r=o[t.charCodeAt(e)]<<10|o[t.charCodeAt(e+1)]<<4|o[t.charCodeAt(e+2)]>>2,f[c++]=r>>8&255,f[c++]=255&r);return f},r.fromByteArray=function(t){for(var r,e=t.length,o=e%3,i=[],u=16383,a=0,s=e-o;as?s:a+u));1===o?(r=t[e-1],i.push(n[r>>2]+n[r<<4&63]+"==")):2===o&&(r=(t[e-2]<<8)+t[e-1],i.push(n[r>>10]+n[r>>4&63]+n[r<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0;a<64;++a)n[a]=u[a],o[u.charCodeAt(a)]=a;function s(t){var r=t.length;if(r%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=t.indexOf("=");return-1===e&&(e=r),[e,e===r?0:4-e%4]}function f(t,r,e){for(var o,i,u=[],a=r;a>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return u.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},function(t,r){r.read=function(t,r,e,n,o){var i,u,a=8*o-n-1,s=(1<>1,c=-7,h=e?o-1:0,p=e?-1:1,l=t[r+h];for(h+=p,i=l&(1<<-c)-1,l>>=-c,c+=a;c>0;i=256*i+t[r+h],h+=p,c-=8);for(u=i&(1<<-c)-1,i>>=-c,c+=n;c>0;u=256*u+t[r+h],h+=p,c-=8);if(0===i)i=1-f;else{if(i===s)return u?NaN:1/0*(l?-1:1);u+=Math.pow(2,n),i-=f}return(l?-1:1)*u*Math.pow(2,i-n)},r.write=function(t,r,e,n,o,i){var u,a,s,f=8*i-o-1,c=(1<>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,l=n?0:i-1,y=n?1:-1,g=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(a=isNaN(r)?1:0,u=c):(u=Math.floor(Math.log(r)/Math.LN2),r*(s=Math.pow(2,-u))<1&&(u--,s*=2),(r+=u+h>=1?p/s:p*Math.pow(2,1-h))*s>=2&&(u++,s/=2),u+h>=c?(a=0,u=c):u+h>=1?(a=(r*s-1)*Math.pow(2,o),u+=h):(a=r*Math.pow(2,h-1)*Math.pow(2,o),u=0));o>=8;t[e+l]=255&a,l+=y,a/=256,o-=8);for(u=u<0;t[e+l]=255&u,l+=y,u/=256,f-=8);t[e+l-y]|=128*g}},function(t,r,e){"use strict";e.r(r);var n,o,i,u=e(1),a=e.n(u),s=e(0),f=e.n(s),c=e(4),h=e(5),p=e(6),l={pack:!0,encode:!0,compress:(o=a()(f.a.mark((function t(r){return f.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",r);case 1:case"end":return t.stop()}}),t)}))),function(t){return o.apply(this,arguments)}),decompress:(n=a()(f.a.mark((function t(r){return f.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",r);case 1:case"end":return t.stop()}}),t)}))),function(t){return n.apply(this,arguments)})},y={lzma:c.a,lzstring:h.a,lzw:p.a,pack:l},g=e(2);e.p=(i=function(){if(document.currentScript)return document.currentScript.src;var t=document.getElementsByTagName("script");return t[t.length-1].src}()).substring(0,i.lastIndexOf("/"))+"/";r.default=function(t){if(!Object.prototype.hasOwnProperty.call(y,t))throw new Error("No such algorithm ".concat(t));var r=y[t],e=r.pack,n=r.encode;function o(t){return i.apply(this,arguments)}function i(){return(i=a()(f.a.mark((function r(o){var i,u,a;return f.a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!e){r.next=6;break}return r.next=3,g.a.msgpack();case 3:r.t0=r.sent.encode(o),r.next=7;break;case 6:r.t0=JSON.stringify(o);case 7:return i=r.t0,r.next=10,y[t].compress(i);case 10:if(u=r.sent,!n){r.next=17;break}return r.next=14,g.a.safe64();case 14:r.t1=r.sent.encode(u),r.next=18;break;case 17:r.t1=u;case 18:return a=r.t1,r.abrupt("return",a);case 20:case"end":return r.stop()}}),r)})))).apply(this,arguments)}function u(){return(u=a()(f.a.mark((function r(o){var i,u,a;return f.a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!n){r.next=6;break}return r.next=3,g.a.safe64();case 3:r.t0=r.sent.decode(o),r.next=7;break;case 6:r.t0=o;case 7:return i=r.t0,r.next=10,y[t].decompress(i);case 10:if(u=r.sent,!e){r.next=17;break}return r.next=14,g.a.msgpack();case 14:r.t1=r.sent.decode(u),r.next=18;break;case 17:r.t1=JSON.parse(u);case 18:return a=r.t1,r.abrupt("return",a);case 20:case"end":return r.stop()}}),r)})))).apply(this,arguments)}function s(){return(s=a()(f.a.mark((function t(r){var e,n,i;return f.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=JSON.stringify(r),n=encodeURIComponent(e),t.next=4,o(r);case 4:return i=t.sent,t.abrupt("return",{raw:e.length,rawencoded:n.length,compressedencoded:i.length,compression:(u=n.length/i.length,Math.floor(1e4*u)/1e4)});case 6:case"end":return t.stop()}var u}),t)})))).apply(this,arguments)}return{compress:o,decompress:function(t){return u.apply(this,arguments)},stats:function(t){return s.apply(this,arguments)}}}}]).default})); -------------------------------------------------------------------------------- /dist/browser/json-url.js.LICENSE.txt: -------------------------------------------------------------------------------- 1 | /*! 2 | * The buffer module from node.js, for the browser. 3 | * 4 | * @author Feross Aboukhadijeh 5 | * @license MIT 6 | */ 7 | 8 | /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ 9 | 10 | /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ 11 | -------------------------------------------------------------------------------- /dist/node/browser-index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); 4 | Object.defineProperty(exports, "__esModule", { 5 | value: true 6 | }); 7 | exports["default"] = void 0; 8 | var _index = _interopRequireDefault(require("./index.js")); 9 | /* global document */ 10 | 11 | // adapted from https://github.com/webpack/webpack/issues/595 12 | function getCurrentScriptSrc() { 13 | if (document.currentScript) return document.currentScript.src; 14 | 15 | // this is unreliable if the script is loaded asynchronously 16 | var scripts = document.getElementsByTagName('script'); 17 | return scripts[scripts.length - 1].src; 18 | } 19 | function derivePath(scriptSrc) { 20 | return scriptSrc.substring(0, scriptSrc.lastIndexOf('/')); 21 | } 22 | 23 | // allows webpack to dynamically load chunks on the same path as where the index script is loaded. 24 | __webpack_public_path__ = derivePath(getCurrentScriptSrc()) + '/'; // eslint-disable-line 25 | var _default = _index["default"]; 26 | exports["default"] = _default; 27 | module.exports = exports.default; -------------------------------------------------------------------------------- /dist/node/codecs/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); 4 | Object.defineProperty(exports, "__esModule", { 5 | value: true 6 | }); 7 | exports["default"] = void 0; 8 | var _lzma = _interopRequireDefault(require("./lzma")); 9 | var _lzstring = _interopRequireDefault(require("./lzstring")); 10 | var _lzw = _interopRequireDefault(require("./lzw")); 11 | var _pack = _interopRequireDefault(require("./pack")); 12 | var _default = { 13 | lzma: _lzma["default"], 14 | lzstring: _lzstring["default"], 15 | lzw: _lzw["default"], 16 | pack: _pack["default"] 17 | }; 18 | exports["default"] = _default; 19 | module.exports = exports.default; -------------------------------------------------------------------------------- /dist/node/codecs/lzma.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); 4 | Object.defineProperty(exports, "__esModule", { 5 | value: true 6 | }); 7 | exports["default"] = void 0; 8 | var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); 9 | var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); 10 | var _loaders = _interopRequireDefault(require("../loaders")); 11 | var _default = { 12 | pack: true, 13 | encode: true, 14 | compress: function () { 15 | var _compress = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(input) { 16 | var lzma; 17 | return _regenerator["default"].wrap(function _callee$(_context) { 18 | while (1) switch (_context.prev = _context.next) { 19 | case 0: 20 | _context.next = 2; 21 | return _loaders["default"].lzma(); 22 | case 2: 23 | lzma = _context.sent; 24 | return _context.abrupt("return", new Promise(function (ok, fail) { 25 | return lzma.compress(input, 9, function (byteArray, err) { 26 | if (err) return fail(err); 27 | return ok(Buffer.from(byteArray)); 28 | }); 29 | })); 30 | case 4: 31 | case "end": 32 | return _context.stop(); 33 | } 34 | }, _callee); 35 | })); 36 | function compress(_x) { 37 | return _compress.apply(this, arguments); 38 | } 39 | return compress; 40 | }(), 41 | decompress: function () { 42 | var _decompress = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(input) { 43 | var lzma; 44 | return _regenerator["default"].wrap(function _callee2$(_context2) { 45 | while (1) switch (_context2.prev = _context2.next) { 46 | case 0: 47 | _context2.next = 2; 48 | return _loaders["default"].lzma(); 49 | case 2: 50 | lzma = _context2.sent; 51 | return _context2.abrupt("return", new Promise(function (ok, fail) { 52 | return lzma.decompress(input, function (byteArray, err) { 53 | if (err) return fail(err); 54 | return ok(Buffer.from(byteArray)); 55 | }); 56 | })); 57 | case 4: 58 | case "end": 59 | return _context2.stop(); 60 | } 61 | }, _callee2); 62 | })); 63 | function decompress(_x2) { 64 | return _decompress.apply(this, arguments); 65 | } 66 | return decompress; 67 | }() 68 | }; 69 | exports["default"] = _default; 70 | module.exports = exports.default; -------------------------------------------------------------------------------- /dist/node/codecs/lzstring.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); 4 | Object.defineProperty(exports, "__esModule", { 5 | value: true 6 | }); 7 | exports["default"] = void 0; 8 | var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); 9 | var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); 10 | var _loaders = _interopRequireDefault(require("../loaders")); 11 | var _default = { 12 | pack: false, 13 | encode: true, 14 | compress: function () { 15 | var _compress = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(string) { 16 | return _regenerator["default"].wrap(function _callee$(_context) { 17 | while (1) switch (_context.prev = _context.next) { 18 | case 0: 19 | _context.t0 = Buffer; 20 | _context.next = 3; 21 | return _loaders["default"].lzstring(); 22 | case 3: 23 | _context.t1 = _context.sent.compressToUint8Array(string); 24 | return _context.abrupt("return", _context.t0.from.call(_context.t0, _context.t1)); 25 | case 5: 26 | case "end": 27 | return _context.stop(); 28 | } 29 | }, _callee); 30 | })); 31 | function compress(_x) { 32 | return _compress.apply(this, arguments); 33 | } 34 | return compress; 35 | }(), 36 | decompress: function () { 37 | var _decompress = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(buffer) { 38 | return _regenerator["default"].wrap(function _callee2$(_context2) { 39 | while (1) switch (_context2.prev = _context2.next) { 40 | case 0: 41 | _context2.next = 2; 42 | return _loaders["default"].lzstring(); 43 | case 2: 44 | return _context2.abrupt("return", _context2.sent.decompressFromUint8Array(buffer)); 45 | case 3: 46 | case "end": 47 | return _context2.stop(); 48 | } 49 | }, _callee2); 50 | })); 51 | function decompress(_x2) { 52 | return _decompress.apply(this, arguments); 53 | } 54 | return decompress; 55 | }() 56 | }; 57 | exports["default"] = _default; 58 | module.exports = exports.default; -------------------------------------------------------------------------------- /dist/node/codecs/lzw.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); 4 | Object.defineProperty(exports, "__esModule", { 5 | value: true 6 | }); 7 | exports["default"] = void 0; 8 | var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); 9 | var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); 10 | var _loaders = _interopRequireDefault(require("../loaders")); 11 | var _default = { 12 | pack: true, 13 | encode: true, 14 | compress: function () { 15 | var _compress = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(input) { 16 | return _regenerator["default"].wrap(function _callee$(_context) { 17 | while (1) switch (_context.prev = _context.next) { 18 | case 0: 19 | _context.t0 = Buffer; 20 | _context.next = 3; 21 | return _loaders["default"].lzw(); 22 | case 3: 23 | _context.t1 = _context.sent.encode(input.toString('binary')); 24 | return _context.abrupt("return", _context.t0.from.call(_context.t0, _context.t1)); 25 | case 5: 26 | case "end": 27 | return _context.stop(); 28 | } 29 | }, _callee); 30 | })); 31 | function compress(_x) { 32 | return _compress.apply(this, arguments); 33 | } 34 | return compress; 35 | }(), 36 | decompress: function () { 37 | var _decompress = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(input) { 38 | return _regenerator["default"].wrap(function _callee2$(_context2) { 39 | while (1) switch (_context2.prev = _context2.next) { 40 | case 0: 41 | _context2.t0 = Buffer; 42 | _context2.next = 3; 43 | return _loaders["default"].lzw(); 44 | case 3: 45 | _context2.t1 = _context2.sent.decode(input); 46 | return _context2.abrupt("return", _context2.t0.from.call(_context2.t0, _context2.t1, 'binary')); 47 | case 5: 48 | case "end": 49 | return _context2.stop(); 50 | } 51 | }, _callee2); 52 | })); 53 | function decompress(_x2) { 54 | return _decompress.apply(this, arguments); 55 | } 56 | return decompress; 57 | }() 58 | }; 59 | exports["default"] = _default; 60 | module.exports = exports.default; -------------------------------------------------------------------------------- /dist/node/codecs/pack.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); 4 | Object.defineProperty(exports, "__esModule", { 5 | value: true 6 | }); 7 | exports["default"] = void 0; 8 | var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); 9 | var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); 10 | var _default = { 11 | pack: true, 12 | encode: true, 13 | compress: function () { 14 | var _compress = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(_) { 15 | return _regenerator["default"].wrap(function _callee$(_context) { 16 | while (1) switch (_context.prev = _context.next) { 17 | case 0: 18 | return _context.abrupt("return", _); 19 | case 1: 20 | case "end": 21 | return _context.stop(); 22 | } 23 | }, _callee); 24 | })); 25 | function compress(_x) { 26 | return _compress.apply(this, arguments); 27 | } 28 | return compress; 29 | }(), 30 | decompress: function () { 31 | var _decompress = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(_) { 32 | return _regenerator["default"].wrap(function _callee2$(_context2) { 33 | while (1) switch (_context2.prev = _context2.next) { 34 | case 0: 35 | return _context2.abrupt("return", _); 36 | case 1: 37 | case "end": 38 | return _context2.stop(); 39 | } 40 | }, _callee2); 41 | })); 42 | function decompress(_x2) { 43 | return _decompress.apply(this, arguments); 44 | } 45 | return decompress; 46 | }() 47 | }; 48 | exports["default"] = _default; 49 | module.exports = exports.default; -------------------------------------------------------------------------------- /dist/node/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); 4 | Object.defineProperty(exports, "__esModule", { 5 | value: true 6 | }); 7 | exports["default"] = createClient; 8 | var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); 9 | var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); 10 | var _codecs = _interopRequireDefault(require("./codecs")); 11 | var _loaders = _interopRequireDefault(require("./loaders")); 12 | var twoDigitPercentage = function twoDigitPercentage(val) { 13 | return Math.floor(val * 10000) / 10000; 14 | }; 15 | function createClient(algorithm) { 16 | if (!Object.prototype.hasOwnProperty.call(_codecs["default"], algorithm)) throw new Error("No such algorithm ".concat(algorithm)); 17 | var _ALGORITHMS$algorithm = _codecs["default"][algorithm], 18 | pack = _ALGORITHMS$algorithm.pack, 19 | encode = _ALGORITHMS$algorithm.encode; 20 | function compress(_x) { 21 | return _compress.apply(this, arguments); 22 | } 23 | function _compress() { 24 | _compress = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(json) { 25 | var packed, compressed, encoded; 26 | return _regenerator["default"].wrap(function _callee$(_context) { 27 | while (1) switch (_context.prev = _context.next) { 28 | case 0: 29 | if (!pack) { 30 | _context.next = 6; 31 | break; 32 | } 33 | _context.next = 3; 34 | return _loaders["default"].msgpack(); 35 | case 3: 36 | _context.t0 = _context.sent.encode(json); 37 | _context.next = 7; 38 | break; 39 | case 6: 40 | _context.t0 = JSON.stringify(json); 41 | case 7: 42 | packed = _context.t0; 43 | _context.next = 10; 44 | return _codecs["default"][algorithm].compress(packed); 45 | case 10: 46 | compressed = _context.sent; 47 | if (!encode) { 48 | _context.next = 17; 49 | break; 50 | } 51 | _context.next = 14; 52 | return _loaders["default"].safe64(); 53 | case 14: 54 | _context.t1 = _context.sent.encode(compressed); 55 | _context.next = 18; 56 | break; 57 | case 17: 58 | _context.t1 = compressed; 59 | case 18: 60 | encoded = _context.t1; 61 | return _context.abrupt("return", encoded); 62 | case 20: 63 | case "end": 64 | return _context.stop(); 65 | } 66 | }, _callee); 67 | })); 68 | return _compress.apply(this, arguments); 69 | } 70 | function decompress(_x2) { 71 | return _decompress.apply(this, arguments); 72 | } 73 | function _decompress() { 74 | _decompress = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(string) { 75 | var decoded, decompressed, unpacked; 76 | return _regenerator["default"].wrap(function _callee2$(_context2) { 77 | while (1) switch (_context2.prev = _context2.next) { 78 | case 0: 79 | if (!encode) { 80 | _context2.next = 6; 81 | break; 82 | } 83 | _context2.next = 3; 84 | return _loaders["default"].safe64(); 85 | case 3: 86 | _context2.t0 = _context2.sent.decode(string); 87 | _context2.next = 7; 88 | break; 89 | case 6: 90 | _context2.t0 = string; 91 | case 7: 92 | decoded = _context2.t0; 93 | _context2.next = 10; 94 | return _codecs["default"][algorithm].decompress(decoded); 95 | case 10: 96 | decompressed = _context2.sent; 97 | if (!pack) { 98 | _context2.next = 17; 99 | break; 100 | } 101 | _context2.next = 14; 102 | return _loaders["default"].msgpack(); 103 | case 14: 104 | _context2.t1 = _context2.sent.decode(decompressed); 105 | _context2.next = 18; 106 | break; 107 | case 17: 108 | _context2.t1 = JSON.parse(decompressed); 109 | case 18: 110 | unpacked = _context2.t1; 111 | return _context2.abrupt("return", unpacked); 112 | case 20: 113 | case "end": 114 | return _context2.stop(); 115 | } 116 | }, _callee2); 117 | })); 118 | return _decompress.apply(this, arguments); 119 | } 120 | function stats(_x3) { 121 | return _stats.apply(this, arguments); 122 | } 123 | function _stats() { 124 | _stats = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(json) { 125 | var raw, rawencoded, compressed; 126 | return _regenerator["default"].wrap(function _callee3$(_context3) { 127 | while (1) switch (_context3.prev = _context3.next) { 128 | case 0: 129 | raw = JSON.stringify(json); 130 | rawencoded = encodeURIComponent(raw); 131 | _context3.next = 4; 132 | return compress(json); 133 | case 4: 134 | compressed = _context3.sent; 135 | return _context3.abrupt("return", { 136 | raw: raw.length, 137 | rawencoded: rawencoded.length, 138 | compressedencoded: compressed.length, 139 | compression: twoDigitPercentage(rawencoded.length / compressed.length) 140 | }); 141 | case 6: 142 | case "end": 143 | return _context3.stop(); 144 | } 145 | }, _callee3); 146 | })); 147 | return _stats.apply(this, arguments); 148 | } 149 | return { 150 | compress: compress, 151 | decompress: decompress, 152 | stats: stats 153 | }; 154 | } 155 | module.exports = exports.default; -------------------------------------------------------------------------------- /dist/node/loaders.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); 4 | var _typeof = require("@babel/runtime/helpers/typeof"); 5 | Object.defineProperty(exports, "__esModule", { 6 | value: true 7 | }); 8 | exports["default"] = void 0; 9 | var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); 10 | var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); 11 | function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } 12 | function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } 13 | // centralize all chunks in one file 14 | var _default = { 15 | msgpack: function msgpack() { 16 | return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() { 17 | var module, factory; 18 | return _regenerator["default"].wrap(function _callee$(_context) { 19 | while (1) switch (_context.prev = _context.next) { 20 | case 0: 21 | _context.next = 2; 22 | return Promise.resolve().then(function () { 23 | return _interopRequireWildcard(require( /* webpackChunkName: "msgpack" */'msgpack5')); 24 | }); 25 | case 2: 26 | module = _context.sent; 27 | factory = module["default"] || module; 28 | return _context.abrupt("return", factory()); 29 | case 5: 30 | case "end": 31 | return _context.stop(); 32 | } 33 | }, _callee); 34 | }))(); 35 | }, 36 | safe64: function safe64() { 37 | return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() { 38 | return _regenerator["default"].wrap(function _callee2$(_context2) { 39 | while (1) switch (_context2.prev = _context2.next) { 40 | case 0: 41 | _context2.next = 2; 42 | return Promise.resolve().then(function () { 43 | return _interopRequireWildcard(require( /* webpackChunkName: "safe64" */'urlsafe-base64')); 44 | }); 45 | case 2: 46 | return _context2.abrupt("return", _context2.sent); 47 | case 3: 48 | case "end": 49 | return _context2.stop(); 50 | } 51 | }, _callee2); 52 | }))(); 53 | }, 54 | lzma: function lzma() { 55 | return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() { 56 | var lzma; 57 | return _regenerator["default"].wrap(function _callee3$(_context3) { 58 | while (1) switch (_context3.prev = _context3.next) { 59 | case 0: 60 | _context3.next = 2; 61 | return Promise.resolve().then(function () { 62 | return _interopRequireWildcard(require( /* webpackChunkName: "lzma" */'lzma')); 63 | }); 64 | case 2: 65 | lzma = _context3.sent; 66 | return _context3.abrupt("return", lzma.compress ? lzma : lzma.LZMA); 67 | case 4: 68 | case "end": 69 | return _context3.stop(); 70 | } 71 | }, _callee3); 72 | }))(); 73 | }, 74 | lzstring: function lzstring() { 75 | return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4() { 76 | return _regenerator["default"].wrap(function _callee4$(_context4) { 77 | while (1) switch (_context4.prev = _context4.next) { 78 | case 0: 79 | _context4.next = 2; 80 | return Promise.resolve().then(function () { 81 | return _interopRequireWildcard(require( /* webpackChunkName: "lzstring" */'lz-string')); 82 | }); 83 | case 2: 84 | return _context4.abrupt("return", _context4.sent); 85 | case 3: 86 | case "end": 87 | return _context4.stop(); 88 | } 89 | }, _callee4); 90 | }))(); 91 | }, 92 | lzw: function lzw() { 93 | return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5() { 94 | var module, lzw; 95 | return _regenerator["default"].wrap(function _callee5$(_context5) { 96 | while (1) switch (_context5.prev = _context5.next) { 97 | case 0: 98 | _context5.next = 2; 99 | return Promise.resolve().then(function () { 100 | return _interopRequireWildcard(require( /* webpackChunkName: "lzw" */'node-lzw')); 101 | }); 102 | case 2: 103 | module = _context5.sent; 104 | lzw = module["default"] || module; 105 | return _context5.abrupt("return", lzw); 106 | case 5: 107 | case "end": 108 | return _context5.stop(); 109 | } 110 | }, _callee5); 111 | }))(); 112 | } 113 | }; 114 | exports["default"] = _default; 115 | module.exports = exports.default; -------------------------------------------------------------------------------- /dist/node/main/browser-index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); 4 | Object.defineProperty(exports, "__esModule", { 5 | value: true 6 | }); 7 | exports["default"] = void 0; 8 | var _index = _interopRequireDefault(require("./index.js")); 9 | /* global document */ 10 | 11 | // adapted from https://github.com/webpack/webpack/issues/595 12 | function getCurrentScriptSrc() { 13 | if (document.currentScript) return document.currentScript.src; 14 | 15 | // this is unreliable if the script is loaded asynchronously 16 | var scripts = document.getElementsByTagName('script'); 17 | return scripts[scripts.length - 1].src; 18 | } 19 | function derivePath(scriptSrc) { 20 | return scriptSrc.substring(0, scriptSrc.lastIndexOf('/')); 21 | } 22 | 23 | // allows webpack to dynamically load chunks on the same path as where the index script is loaded. 24 | __webpack_public_path__ = derivePath(getCurrentScriptSrc()) + '/'; // eslint-disable-line 25 | var _default = _index["default"]; 26 | exports["default"] = _default; 27 | module.exports = exports.default; -------------------------------------------------------------------------------- /dist/node/main/codecs/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); 4 | Object.defineProperty(exports, "__esModule", { 5 | value: true 6 | }); 7 | exports["default"] = void 0; 8 | var _lzma = _interopRequireDefault(require("./lzma")); 9 | var _lzstring = _interopRequireDefault(require("./lzstring")); 10 | var _lzw = _interopRequireDefault(require("./lzw")); 11 | var _pack = _interopRequireDefault(require("./pack")); 12 | var _default = { 13 | lzma: _lzma["default"], 14 | lzstring: _lzstring["default"], 15 | lzw: _lzw["default"], 16 | pack: _pack["default"] 17 | }; 18 | exports["default"] = _default; 19 | module.exports = exports.default; -------------------------------------------------------------------------------- /dist/node/main/codecs/lzma.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); 4 | Object.defineProperty(exports, "__esModule", { 5 | value: true 6 | }); 7 | exports["default"] = void 0; 8 | var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); 9 | var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); 10 | var _loaders = _interopRequireDefault(require("../loaders")); 11 | var _default = { 12 | pack: true, 13 | encode: true, 14 | compress: function () { 15 | var _compress = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(input) { 16 | var lzma; 17 | return _regenerator["default"].wrap(function _callee$(_context) { 18 | while (1) switch (_context.prev = _context.next) { 19 | case 0: 20 | _context.next = 2; 21 | return _loaders["default"].lzma(); 22 | case 2: 23 | lzma = _context.sent; 24 | return _context.abrupt("return", new Promise(function (ok, fail) { 25 | return lzma.compress(input, 9, function (byteArray, err) { 26 | if (err) return fail(err); 27 | return ok(Buffer.from(byteArray)); 28 | }); 29 | })); 30 | case 4: 31 | case "end": 32 | return _context.stop(); 33 | } 34 | }, _callee); 35 | })); 36 | function compress(_x) { 37 | return _compress.apply(this, arguments); 38 | } 39 | return compress; 40 | }(), 41 | decompress: function () { 42 | var _decompress = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(input) { 43 | var lzma; 44 | return _regenerator["default"].wrap(function _callee2$(_context2) { 45 | while (1) switch (_context2.prev = _context2.next) { 46 | case 0: 47 | _context2.next = 2; 48 | return _loaders["default"].lzma(); 49 | case 2: 50 | lzma = _context2.sent; 51 | return _context2.abrupt("return", new Promise(function (ok, fail) { 52 | return lzma.decompress(input, function (byteArray, err) { 53 | if (err) return fail(err); 54 | return ok(Buffer.from(byteArray)); 55 | }); 56 | })); 57 | case 4: 58 | case "end": 59 | return _context2.stop(); 60 | } 61 | }, _callee2); 62 | })); 63 | function decompress(_x2) { 64 | return _decompress.apply(this, arguments); 65 | } 66 | return decompress; 67 | }() 68 | }; 69 | exports["default"] = _default; 70 | module.exports = exports.default; -------------------------------------------------------------------------------- /dist/node/main/codecs/lzstring.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); 4 | Object.defineProperty(exports, "__esModule", { 5 | value: true 6 | }); 7 | exports["default"] = void 0; 8 | var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); 9 | var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); 10 | var _loaders = _interopRequireDefault(require("../loaders")); 11 | var _default = { 12 | pack: false, 13 | encode: true, 14 | compress: function () { 15 | var _compress = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(string) { 16 | return _regenerator["default"].wrap(function _callee$(_context) { 17 | while (1) switch (_context.prev = _context.next) { 18 | case 0: 19 | _context.t0 = Buffer; 20 | _context.next = 3; 21 | return _loaders["default"].lzstring(); 22 | case 3: 23 | _context.t1 = _context.sent.compressToUint8Array(string); 24 | return _context.abrupt("return", _context.t0.from.call(_context.t0, _context.t1)); 25 | case 5: 26 | case "end": 27 | return _context.stop(); 28 | } 29 | }, _callee); 30 | })); 31 | function compress(_x) { 32 | return _compress.apply(this, arguments); 33 | } 34 | return compress; 35 | }(), 36 | decompress: function () { 37 | var _decompress = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(buffer) { 38 | return _regenerator["default"].wrap(function _callee2$(_context2) { 39 | while (1) switch (_context2.prev = _context2.next) { 40 | case 0: 41 | _context2.next = 2; 42 | return _loaders["default"].lzstring(); 43 | case 2: 44 | return _context2.abrupt("return", _context2.sent.decompressFromUint8Array(buffer)); 45 | case 3: 46 | case "end": 47 | return _context2.stop(); 48 | } 49 | }, _callee2); 50 | })); 51 | function decompress(_x2) { 52 | return _decompress.apply(this, arguments); 53 | } 54 | return decompress; 55 | }() 56 | }; 57 | exports["default"] = _default; 58 | module.exports = exports.default; -------------------------------------------------------------------------------- /dist/node/main/codecs/lzw.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); 4 | Object.defineProperty(exports, "__esModule", { 5 | value: true 6 | }); 7 | exports["default"] = void 0; 8 | var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); 9 | var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); 10 | var _loaders = _interopRequireDefault(require("../loaders")); 11 | var _default = { 12 | pack: true, 13 | encode: true, 14 | compress: function () { 15 | var _compress = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(input) { 16 | return _regenerator["default"].wrap(function _callee$(_context) { 17 | while (1) switch (_context.prev = _context.next) { 18 | case 0: 19 | _context.t0 = Buffer; 20 | _context.next = 3; 21 | return _loaders["default"].lzw(); 22 | case 3: 23 | _context.t1 = _context.sent.encode(input.toString('binary')); 24 | return _context.abrupt("return", _context.t0.from.call(_context.t0, _context.t1)); 25 | case 5: 26 | case "end": 27 | return _context.stop(); 28 | } 29 | }, _callee); 30 | })); 31 | function compress(_x) { 32 | return _compress.apply(this, arguments); 33 | } 34 | return compress; 35 | }(), 36 | decompress: function () { 37 | var _decompress = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(input) { 38 | return _regenerator["default"].wrap(function _callee2$(_context2) { 39 | while (1) switch (_context2.prev = _context2.next) { 40 | case 0: 41 | _context2.t0 = Buffer; 42 | _context2.next = 3; 43 | return _loaders["default"].lzw(); 44 | case 3: 45 | _context2.t1 = _context2.sent.decode(input); 46 | return _context2.abrupt("return", _context2.t0.from.call(_context2.t0, _context2.t1, 'binary')); 47 | case 5: 48 | case "end": 49 | return _context2.stop(); 50 | } 51 | }, _callee2); 52 | })); 53 | function decompress(_x2) { 54 | return _decompress.apply(this, arguments); 55 | } 56 | return decompress; 57 | }() 58 | }; 59 | exports["default"] = _default; 60 | module.exports = exports.default; -------------------------------------------------------------------------------- /dist/node/main/codecs/pack.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); 4 | Object.defineProperty(exports, "__esModule", { 5 | value: true 6 | }); 7 | exports["default"] = void 0; 8 | var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); 9 | var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); 10 | var _default = { 11 | pack: true, 12 | encode: true, 13 | compress: function () { 14 | var _compress = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(_) { 15 | return _regenerator["default"].wrap(function _callee$(_context) { 16 | while (1) switch (_context.prev = _context.next) { 17 | case 0: 18 | return _context.abrupt("return", _); 19 | case 1: 20 | case "end": 21 | return _context.stop(); 22 | } 23 | }, _callee); 24 | })); 25 | function compress(_x) { 26 | return _compress.apply(this, arguments); 27 | } 28 | return compress; 29 | }(), 30 | decompress: function () { 31 | var _decompress = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(_) { 32 | return _regenerator["default"].wrap(function _callee2$(_context2) { 33 | while (1) switch (_context2.prev = _context2.next) { 34 | case 0: 35 | return _context2.abrupt("return", _); 36 | case 1: 37 | case "end": 38 | return _context2.stop(); 39 | } 40 | }, _callee2); 41 | })); 42 | function decompress(_x2) { 43 | return _decompress.apply(this, arguments); 44 | } 45 | return decompress; 46 | }() 47 | }; 48 | exports["default"] = _default; 49 | module.exports = exports.default; -------------------------------------------------------------------------------- /dist/node/main/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); 4 | Object.defineProperty(exports, "__esModule", { 5 | value: true 6 | }); 7 | exports["default"] = createClient; 8 | var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); 9 | var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); 10 | var _codecs = _interopRequireDefault(require("./codecs")); 11 | var _loaders = _interopRequireDefault(require("./loaders")); 12 | var twoDigitPercentage = function twoDigitPercentage(val) { 13 | return Math.floor(val * 10000) / 10000; 14 | }; 15 | function createClient(algorithm) { 16 | if (!Object.prototype.hasOwnProperty.call(_codecs["default"], algorithm)) throw new Error("No such algorithm ".concat(algorithm)); 17 | var _ALGORITHMS$algorithm = _codecs["default"][algorithm], 18 | pack = _ALGORITHMS$algorithm.pack, 19 | encode = _ALGORITHMS$algorithm.encode; 20 | function compress(_x) { 21 | return _compress.apply(this, arguments); 22 | } 23 | function _compress() { 24 | _compress = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(json) { 25 | var packed, compressed, encoded; 26 | return _regenerator["default"].wrap(function _callee$(_context) { 27 | while (1) switch (_context.prev = _context.next) { 28 | case 0: 29 | if (!pack) { 30 | _context.next = 6; 31 | break; 32 | } 33 | _context.next = 3; 34 | return _loaders["default"].msgpack(); 35 | case 3: 36 | _context.t0 = _context.sent.encode(json); 37 | _context.next = 7; 38 | break; 39 | case 6: 40 | _context.t0 = JSON.stringify(json); 41 | case 7: 42 | packed = _context.t0; 43 | _context.next = 10; 44 | return _codecs["default"][algorithm].compress(packed); 45 | case 10: 46 | compressed = _context.sent; 47 | if (!encode) { 48 | _context.next = 17; 49 | break; 50 | } 51 | _context.next = 14; 52 | return _loaders["default"].safe64(); 53 | case 14: 54 | _context.t1 = _context.sent.encode(compressed); 55 | _context.next = 18; 56 | break; 57 | case 17: 58 | _context.t1 = compressed; 59 | case 18: 60 | encoded = _context.t1; 61 | return _context.abrupt("return", encoded); 62 | case 20: 63 | case "end": 64 | return _context.stop(); 65 | } 66 | }, _callee); 67 | })); 68 | return _compress.apply(this, arguments); 69 | } 70 | function decompress(_x2) { 71 | return _decompress.apply(this, arguments); 72 | } 73 | function _decompress() { 74 | _decompress = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(string) { 75 | var decoded, decompressed, unpacked; 76 | return _regenerator["default"].wrap(function _callee2$(_context2) { 77 | while (1) switch (_context2.prev = _context2.next) { 78 | case 0: 79 | if (!encode) { 80 | _context2.next = 6; 81 | break; 82 | } 83 | _context2.next = 3; 84 | return _loaders["default"].safe64(); 85 | case 3: 86 | _context2.t0 = _context2.sent.decode(string); 87 | _context2.next = 7; 88 | break; 89 | case 6: 90 | _context2.t0 = string; 91 | case 7: 92 | decoded = _context2.t0; 93 | _context2.next = 10; 94 | return _codecs["default"][algorithm].decompress(decoded); 95 | case 10: 96 | decompressed = _context2.sent; 97 | if (!pack) { 98 | _context2.next = 17; 99 | break; 100 | } 101 | _context2.next = 14; 102 | return _loaders["default"].msgpack(); 103 | case 14: 104 | _context2.t1 = _context2.sent.decode(decompressed); 105 | _context2.next = 18; 106 | break; 107 | case 17: 108 | _context2.t1 = JSON.parse(decompressed); 109 | case 18: 110 | unpacked = _context2.t1; 111 | return _context2.abrupt("return", unpacked); 112 | case 20: 113 | case "end": 114 | return _context2.stop(); 115 | } 116 | }, _callee2); 117 | })); 118 | return _decompress.apply(this, arguments); 119 | } 120 | function stats(_x3) { 121 | return _stats.apply(this, arguments); 122 | } 123 | function _stats() { 124 | _stats = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(json) { 125 | var raw, rawencoded, compressed; 126 | return _regenerator["default"].wrap(function _callee3$(_context3) { 127 | while (1) switch (_context3.prev = _context3.next) { 128 | case 0: 129 | raw = JSON.stringify(json); 130 | rawencoded = encodeURIComponent(raw); 131 | _context3.next = 4; 132 | return compress(json); 133 | case 4: 134 | compressed = _context3.sent; 135 | return _context3.abrupt("return", { 136 | raw: raw.length, 137 | rawencoded: rawencoded.length, 138 | compressedencoded: compressed.length, 139 | compression: twoDigitPercentage(rawencoded.length / compressed.length) 140 | }); 141 | case 6: 142 | case "end": 143 | return _context3.stop(); 144 | } 145 | }, _callee3); 146 | })); 147 | return _stats.apply(this, arguments); 148 | } 149 | return { 150 | compress: compress, 151 | decompress: decompress, 152 | stats: stats 153 | }; 154 | } 155 | module.exports = exports.default; -------------------------------------------------------------------------------- /dist/node/main/loaders.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); 4 | var _typeof = require("@babel/runtime/helpers/typeof"); 5 | Object.defineProperty(exports, "__esModule", { 6 | value: true 7 | }); 8 | exports["default"] = void 0; 9 | var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); 10 | var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); 11 | function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } 12 | function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } 13 | // centralize all chunks in one file 14 | var _default = { 15 | msgpack: function msgpack() { 16 | return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() { 17 | var module, factory; 18 | return _regenerator["default"].wrap(function _callee$(_context) { 19 | while (1) switch (_context.prev = _context.next) { 20 | case 0: 21 | _context.next = 2; 22 | return Promise.resolve().then(function () { 23 | return _interopRequireWildcard(require( /* webpackChunkName: "msgpack" */'msgpack5')); 24 | }); 25 | case 2: 26 | module = _context.sent; 27 | factory = module["default"] || module; 28 | return _context.abrupt("return", factory()); 29 | case 5: 30 | case "end": 31 | return _context.stop(); 32 | } 33 | }, _callee); 34 | }))(); 35 | }, 36 | safe64: function safe64() { 37 | return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() { 38 | return _regenerator["default"].wrap(function _callee2$(_context2) { 39 | while (1) switch (_context2.prev = _context2.next) { 40 | case 0: 41 | _context2.next = 2; 42 | return Promise.resolve().then(function () { 43 | return _interopRequireWildcard(require( /* webpackChunkName: "safe64" */'urlsafe-base64')); 44 | }); 45 | case 2: 46 | return _context2.abrupt("return", _context2.sent); 47 | case 3: 48 | case "end": 49 | return _context2.stop(); 50 | } 51 | }, _callee2); 52 | }))(); 53 | }, 54 | lzma: function lzma() { 55 | return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() { 56 | var lzma; 57 | return _regenerator["default"].wrap(function _callee3$(_context3) { 58 | while (1) switch (_context3.prev = _context3.next) { 59 | case 0: 60 | _context3.next = 2; 61 | return Promise.resolve().then(function () { 62 | return _interopRequireWildcard(require( /* webpackChunkName: "lzma" */'lzma')); 63 | }); 64 | case 2: 65 | lzma = _context3.sent; 66 | return _context3.abrupt("return", lzma.compress ? lzma : lzma.LZMA); 67 | case 4: 68 | case "end": 69 | return _context3.stop(); 70 | } 71 | }, _callee3); 72 | }))(); 73 | }, 74 | lzstring: function lzstring() { 75 | return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4() { 76 | return _regenerator["default"].wrap(function _callee4$(_context4) { 77 | while (1) switch (_context4.prev = _context4.next) { 78 | case 0: 79 | _context4.next = 2; 80 | return Promise.resolve().then(function () { 81 | return _interopRequireWildcard(require( /* webpackChunkName: "lzstring" */'lz-string')); 82 | }); 83 | case 2: 84 | return _context4.abrupt("return", _context4.sent); 85 | case 3: 86 | case "end": 87 | return _context4.stop(); 88 | } 89 | }, _callee4); 90 | }))(); 91 | }, 92 | lzw: function lzw() { 93 | return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5() { 94 | var module, lzw; 95 | return _regenerator["default"].wrap(function _callee5$(_context5) { 96 | while (1) switch (_context5.prev = _context5.next) { 97 | case 0: 98 | _context5.next = 2; 99 | return Promise.resolve().then(function () { 100 | return _interopRequireWildcard(require( /* webpackChunkName: "lzw" */'node-lzw')); 101 | }); 102 | case 2: 103 | module = _context5.sent; 104 | lzw = module["default"] || module; 105 | return _context5.abrupt("return", lzw); 106 | case 5: 107 | case "end": 108 | return _context5.stop(); 109 | } 110 | }, _callee5); 111 | }))(); 112 | } 113 | }; 114 | exports["default"] = _default; 115 | module.exports = exports.default; -------------------------------------------------------------------------------- /examples/browser/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | json-url demo page 5 | 89 | 90 | 91 |
92 |

json-url demo

93 | Proudly written in vanilla.js™ 94 |
95 |
96 |
97 | 98 | 104 |
105 |
106 | 107 | 108 |
109 | 110 |
111 |

Result

112 | 114 |
115 | 116 |
117 |

Decompression

118 | 120 |
121 |
122 | 123 | 124 | 155 | -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/unambiguous */ 2 | const webpackConfig = require('./webpack.config.js'); 3 | 4 | // karma-webpack 2.x breaking fix 5 | delete webpackConfig.entry; 6 | 7 | // note: these mods mutate the original config 8 | const MODS = { // eslint-disable-line no-unused-vars 9 | dontAliasLzma(config) { 10 | config.module.rules 11 | .filter(rule => rule.use && rule.use.loader === 'babel-loader') 12 | .forEach(rule => rule.use.options.plugins 13 | .filter(plugin => plugin[0] === 'module-resolver') 14 | .forEach(plugin => plugin[1].alias && delete plugin[1].alias.lzma) 15 | ); 16 | return config; 17 | }, 18 | dontUglify(config) { 19 | config.plugins = []; 20 | return config; 21 | } 22 | } 23 | 24 | module.exports = config => { 25 | config.set({ 26 | frameworks: ['mocha'], 27 | files: ['test/index.js'], 28 | reporters: ['progress'], 29 | port: 9876, 30 | colors: true, 31 | logLevel: config.LOG_DEBUG, 32 | browsers: ['ChromeHeadless'], 33 | autoWatch: false, // if true, Karma will not exit after the tests 34 | concurrency: Infinity, 35 | preprocessors: { 36 | // add webpack as preprocessor 37 | 'test/index.js': ['webpack'], 38 | }, 39 | webpack: webpackConfig 40 | }); 41 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "json-url", 3 | "version": "3.1.0", 4 | "description": "Compress JSON into compact base64 URI-friendly notation", 5 | "main": "dist/node/index.js", 6 | "browser": "dist/browser/json-url-single.js", 7 | "scripts": { 8 | "lint": "eslint src/*", 9 | "compile": "rm -rf dist/; mkdir dist & wait & npm run compile:node & npm run compile:webpack & npm run compile:webpack:single", 10 | "compile:node": "babel --plugins @babel/plugin-transform-runtime,add-module-exports -d dist/node src src/main", 11 | "compile:webpack": "webpack", 12 | "compile:webpack:single": "webpack --config webpack.config.single.js", 13 | "prepublish": "npm test && npm run compile", 14 | "test": "npm run lint && npm run test:node && npm run test:karma", 15 | "test:node": "BABEL_ENV=test nyc mocha test/index.js --timeout 120000", 16 | "test:karma": "karma start --single-run", 17 | "perf": "babel-node test/perf.js", 18 | "coverage": "nyc report --reporter=text-lcov | coveralls", 19 | "example": "open http://localhost:8000/examples/browser/test.html & static-server --port 8000" 20 | }, 21 | "repository": { 22 | "type": "git", 23 | "url": "https://github.com/masotime/json-url" 24 | }, 25 | "author": "Benjamin Goh ", 26 | "license": "ISC", 27 | "dependencies": { 28 | "@babel/runtime-corejs2": "^7.0.0", 29 | "bluebird": "^3.0.6", 30 | "lz-string": "^1.4.4", 31 | "lzma": "^2.3.2", 32 | "msgpack5": "^4.2.1", 33 | "node-lzw": "^0.3.1", 34 | "urlsafe-base64": "^1.0.0" 35 | }, 36 | "devDependencies": { 37 | "@babel/cli": "^7.0.0", 38 | "@babel/core": "^7.0.0", 39 | "@babel/node": "^7.0.0", 40 | "@babel/plugin-proposal-class-properties": "^7.0.0", 41 | "@babel/plugin-proposal-decorators": "^7.0.0", 42 | "@babel/plugin-proposal-do-expressions": "^7.0.0", 43 | "@babel/plugin-proposal-export-default-from": "^7.0.0", 44 | "@babel/plugin-proposal-export-namespace-from": "^7.0.0", 45 | "@babel/plugin-proposal-function-bind": "^7.0.0", 46 | "@babel/plugin-proposal-function-sent": "^7.0.0", 47 | "@babel/plugin-proposal-json-strings": "^7.0.0", 48 | "@babel/plugin-proposal-logical-assignment-operators": "^7.0.0", 49 | "@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0", 50 | "@babel/plugin-proposal-numeric-separator": "^7.0.0", 51 | "@babel/plugin-proposal-optional-chaining": "^7.0.0", 52 | "@babel/plugin-proposal-pipeline-operator": "^7.0.0", 53 | "@babel/plugin-proposal-throw-expressions": "^7.0.0", 54 | "@babel/plugin-syntax-dynamic-import": "^7.0.0", 55 | "@babel/plugin-syntax-import-meta": "^7.0.0", 56 | "@babel/plugin-transform-runtime": "^7.0.0", 57 | "@babel/polyfill": "^7.0.0", 58 | "@babel/preset-env": "^7.0.0", 59 | "@babel/register": "^7.6.2", 60 | "@babel/runtime": "^7.6.3", 61 | "babel-eslint": "^9.0.0", 62 | "babel-loader": "^8.0.0", 63 | "babel-plugin-add-module-exports": "^1.0.4", 64 | "babel-plugin-dynamic-import-node": "^1.1.0", 65 | "babel-plugin-istanbul": "^5.2.0", 66 | "babel-plugin-module-resolver": "^5.0.0", 67 | "coveralls": "^3.1.1", 68 | "eslint": "^6.6.0", 69 | "eslint-import-resolver-babel-module": "^5.1.0", 70 | "eslint-plugin-import": "^2.18.2", 71 | "karma": "^6.3.2", 72 | "karma-chrome-launcher": "^2.2.0", 73 | "karma-mocha": "^2.0.0", 74 | "karma-webpack": "^4.0.2", 75 | "mocha": "^10.2.0", 76 | "nyc": "^14.1.1", 77 | "static-server": "^2.0.5", 78 | "terser-webpack-plugin": "^4.2.3", 79 | "webpack": "^4.42.1", 80 | "webpack-cli": "^3.3.11" 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/browser-index.js: -------------------------------------------------------------------------------- 1 | /* global document */ 2 | import createClient from './index.js'; 3 | 4 | // adapted from https://github.com/webpack/webpack/issues/595 5 | function getCurrentScriptSrc() { 6 | if (document.currentScript) return document.currentScript.src; 7 | 8 | // this is unreliable if the script is loaded asynchronously 9 | const scripts = document.getElementsByTagName('script'); 10 | return scripts[scripts.length-1].src; 11 | } 12 | 13 | function derivePath(scriptSrc) { 14 | return scriptSrc.substring(0, scriptSrc.lastIndexOf('/')); 15 | } 16 | 17 | // allows webpack to dynamically load chunks on the same path as where the index script is loaded. 18 | __webpack_public_path__ = derivePath(getCurrentScriptSrc()) + '/'; // eslint-disable-line 19 | 20 | export default createClient; -------------------------------------------------------------------------------- /src/main/codecs/index.js: -------------------------------------------------------------------------------- 1 | import lzma from 'main/codecs/lzma'; 2 | import lzstring from 'main/codecs/lzstring'; 3 | import lzw from 'main/codecs/lzw'; 4 | import pack from 'main/codecs/pack'; 5 | 6 | export default { 7 | lzma, lzstring, lzw, pack 8 | }; -------------------------------------------------------------------------------- /src/main/codecs/lzma.js: -------------------------------------------------------------------------------- 1 | import LOADERS from 'main/loaders'; 2 | 3 | export default { 4 | pack: true, 5 | encode: true, 6 | compress: async input => { 7 | const lzma = await LOADERS.lzma(); 8 | return new Promise((ok, fail) => 9 | lzma.compress(input, 9, (byteArray, err) => { 10 | if (err) return fail(err); 11 | return ok(Buffer.from(byteArray)); 12 | }) 13 | ) 14 | }, 15 | decompress: async input => { 16 | const lzma = await LOADERS.lzma(); 17 | return new Promise((ok, fail) => 18 | lzma.decompress(input, (byteArray, err) => { 19 | if (err) return fail(err); 20 | return ok(Buffer.from(byteArray)); 21 | }) 22 | ) 23 | } 24 | }; -------------------------------------------------------------------------------- /src/main/codecs/lzstring.js: -------------------------------------------------------------------------------- 1 | import LOADERS from 'main/loaders'; 2 | 3 | export default { 4 | pack: false, 5 | encode: true, 6 | compress: async string => Buffer.from((await LOADERS.lzstring()).compressToUint8Array(string)), 7 | decompress: async buffer => (await LOADERS.lzstring()).decompressFromUint8Array(buffer) 8 | }; -------------------------------------------------------------------------------- /src/main/codecs/lzw.js: -------------------------------------------------------------------------------- 1 | import LOADERS from 'main/loaders'; 2 | 3 | export default { 4 | pack: true, 5 | encode: true, 6 | compress: async input => Buffer.from((await LOADERS.lzw()).encode(input.toString('binary'))), 7 | decompress: async input => Buffer.from((await LOADERS.lzw()).decode(input), 'binary') 8 | }; -------------------------------------------------------------------------------- /src/main/codecs/pack.js: -------------------------------------------------------------------------------- 1 | export default { 2 | pack: true, 3 | encode: true, 4 | compress: async _ => _, 5 | decompress: async _ => _ 6 | }; -------------------------------------------------------------------------------- /src/main/index.js: -------------------------------------------------------------------------------- 1 | import ALGORITHMS from 'main/codecs'; 2 | import LOADERS from 'main/loaders'; 3 | 4 | const twoDigitPercentage = val => Math.floor(val * 10000) / 10000; 5 | 6 | export default function createClient(algorithm) { 7 | if (!Object.prototype.hasOwnProperty.call(ALGORITHMS, algorithm)) throw new Error(`No such algorithm ${algorithm}`); 8 | 9 | const { pack, encode } = ALGORITHMS[algorithm]; 10 | 11 | async function compress(json) { 12 | const packed = pack ? (await LOADERS.msgpack()).encode(json) : JSON.stringify(json); 13 | const compressed = await ALGORITHMS[algorithm].compress(packed); 14 | const encoded = encode ? (await LOADERS.safe64()).encode(compressed) : compressed; 15 | return encoded; 16 | } 17 | 18 | async function decompress(string) { 19 | const decoded = encode ? (await LOADERS.safe64()).decode(string) : string; 20 | const decompressed = await ALGORITHMS[algorithm].decompress(decoded); 21 | const unpacked = pack ? (await LOADERS.msgpack()).decode(decompressed) : JSON.parse(decompressed); 22 | return unpacked; 23 | } 24 | 25 | async function stats(json) { 26 | const raw = JSON.stringify(json); 27 | const rawencoded = encodeURIComponent(raw); 28 | const compressed = await compress(json); 29 | 30 | return { 31 | raw: raw.length, 32 | rawencoded: rawencoded.length, 33 | compressedencoded: compressed.length, 34 | compression: twoDigitPercentage(rawencoded.length / compressed.length) 35 | }; 36 | } 37 | 38 | return { compress, decompress, stats }; 39 | } 40 | -------------------------------------------------------------------------------- /src/main/loaders.js: -------------------------------------------------------------------------------- 1 | // centralize all chunks in one file 2 | export default { 3 | async msgpack() { 4 | const module = await import(/* webpackChunkName: "msgpack" */ 'msgpack5'); 5 | const factory = module.default || module; 6 | return factory(); 7 | }, 8 | async safe64() { 9 | return await import(/* webpackChunkName: "safe64" */ 'urlsafe-base64'); 10 | }, 11 | async lzma() { 12 | const lzma = await import(/* webpackChunkName: "lzma" */ 'lzma'); 13 | 14 | // this special condition is present because the web minified version has a slightly different export 15 | return lzma.compress ? lzma : lzma.LZMA; 16 | }, 17 | async lzstring() { 18 | return await import(/* webpackChunkName: "lzstring" */ 'lz-string'); 19 | }, 20 | async lzw() { 21 | const module = await import(/* webpackChunkName: "lzw" */ 'node-lzw'); 22 | const lzw = module.default || module; 23 | return lzw; 24 | } 25 | }; 26 | -------------------------------------------------------------------------------- /test/index.js: -------------------------------------------------------------------------------- 1 | /* global describe, it */ 2 | import assert from 'assert'; 3 | import createClient from 'main'; 4 | import { validate } from 'urlsafe-base64'; 5 | import samples from './samples.json' 6 | 7 | describe('json-url', () => { 8 | samples.forEach(sample => { 9 | describe(`When attempting to compress ${JSON.stringify(sample).slice(0, 50)}...`, () => { 10 | ['pack', 'lzw', 'lzma', 'lzstring'].forEach(algorithm => { 11 | describe(`using the ${algorithm} algorithm`, () => { 12 | const client = createClient(algorithm); 13 | 14 | it('compresses JSON via #compress to base64 format', async () => { 15 | const compressed = await client.compress(sample); 16 | assert.ok(validate(compressed), `${compressed} is not valid base64`); 17 | }); 18 | 19 | it('can decompress JSON compressed via #compress using #decompress', async () => { 20 | const compressed = await client.compress(sample); 21 | const decompressed = await client.decompress(compressed); 22 | assert.equal(JSON.stringify(decompressed), JSON.stringify(sample)); 23 | }); 24 | 25 | it('returns stats { rawencoded, compressedencoded, compression } via #stats', async () => { 26 | const result = await client.stats(sample); 27 | assert.ok(result['rawencoded']); 28 | assert.ok(result['compressedencoded']); 29 | assert.ok(result['compression']); 30 | }); 31 | }); // each algorithm 32 | }); 33 | }); // each sample 34 | }); 35 | }); 36 | -------------------------------------------------------------------------------- /test/perf.js: -------------------------------------------------------------------------------- 1 | import jsonUrl from 'main/index.js'; 2 | import samples from './samples.json'; 3 | import ALGORITHMS from 'main/compress'; 4 | 5 | const algorithms = Object.keys(ALGORITHMS); 6 | 7 | async function main() { 8 | 9 | const results = new Array(samples.length); 10 | 11 | for (const algorithm of algorithms) { 12 | const lib = jsonUrl(algorithm); 13 | let counter = 0; 14 | for (const datum of samples) { 15 | const { raw, rawencoded, compressedencoded, compression } = await lib.stats(datum); 16 | results[counter] = results[counter] || {}; 17 | results[counter].raw = raw; 18 | results[counter].rawencoded = rawencoded; 19 | results[counter][algorithm] = { 20 | ratio: compression, 21 | compressed: compressedencoded 22 | }; 23 | counter += 1; 24 | } 25 | } 26 | 27 | console.log(JSON.stringify(results, null, 2)); 28 | } 29 | 30 | main(); -------------------------------------------------------------------------------- /test/samples.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "filters": { 4 | "amenities": [4, 55, 23], 5 | "budget_max": 80000, 6 | "budget_min": 50000, 7 | "event_types": [1, 2, 3], 8 | "neighborhoods": [4, 55, 502] 9 | }, 10 | "page": 1, 11 | "search_fields": { 12 | "end_time": "11:00pm", 13 | "guests": "50", 14 | "region": 8, 15 | "start_date": "11-23-2015", 16 | "start_time": "8:00pm" 17 | }, 18 | "search_for_name": "Name Search Test" 19 | }, 20 | { 21 | "setup": { 22 | "protocol": "NVP" 23 | }, 24 | "use": { 25 | "master": { 26 | "stage": "NO" 27 | } 28 | }, 29 | "common_request_params": { 30 | "version": "123", 31 | "method": "SetExpressCheckout" 32 | }, 33 | "NVP": { 34 | "SetExpressCheckout": { 35 | "AMT": "16", 36 | "CANCELURL": "http://xotoolslvs01.qa.paypal.com/ectest/cancel.html", 37 | "L_AMT0": "8", 38 | "L_NAME0": "Test Item fewarwerwerw", 39 | "L_QTY0": "2", 40 | "PAYMENTACTION": "Sale", 41 | "RETURNURL": "http://xotoolslvs01.qa.paypal.com/ectest/return.html", 42 | "_custom0__name": "L_DESC0", 43 | "_custom0": "hello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello world" 44 | } 45 | } 46 | }, 47 | { 48 | "zh": { 49 | "name": "China", 50 | "continent": "Asia", 51 | "flagColors": [ 52 | "red", 53 | "yellow" 54 | ], 55 | "leader": { 56 | "name": "习 近平-习", 57 | "title": "President", 58 | "term": 137 59 | }, 60 | "population": 1370000000 61 | }, 62 | "in": { 63 | "name": "India", 64 | "continent": "", 65 | "a": true, 66 | "b": false, 67 | "c": null, 68 | "emptyArray": [], 69 | "emptyObject": {}, 70 | "flagColors": [ 71 | "orange", 72 | "white", 73 | "green" 74 | ], 75 | "leader": { 76 | "name": "Narendra\nModi.", 77 | "title": "Prime Minister", 78 | "term": 119 79 | }, 80 | "population": 1190000000 81 | }, 82 | "array": [ 83 | "asdf", 84 | [ 85 | 3, 86 | 4 87 | ] 88 | ] 89 | }, 90 | { 91 | "one": 1 92 | }, 93 | { 94 | "one": 1, 95 | "two": 2, 96 | "three": 3 97 | }, 98 | { 99 | "_id": "55d54e11bf8bf51e99245818", 100 | "index": 0, 101 | "guid": "f1205498-83a2-4f9d-ba60-ded5585c0e67", 102 | "isActive": false, 103 | "balance": "$2,370.15", 104 | "picture": "http://placehold.it/32x32", 105 | "age": 28, 106 | "eyeColor": "green", 107 | "name": { 108 | "first": "Jill", 109 | "last": "Pennington" 110 | }, 111 | "company": "GAZAK", 112 | "email": "jill.pennington@gazak.co.uk", 113 | "phone": "+1 (998) 584-3321", 114 | "address": "517 Coles Street, Skyland, Montana, 7661", 115 | "about": "Pariatur tempor consequat amet do incididunt aute nulla. Pariatur reprehenderit nostrud quis mollit duis ipsum ut consequat mollit qui. Ullamco reprehenderit nostrud nulla nisi ipsum adipisicing esse. Et ullamco in reprehenderit fugiat consectetur sunt laborum est. Magna sit consectetur commodo tempor dolore sint id dolor Lorem Lorem. Ex nisi ea occaecat nisi. Voluptate enim in aliquip laborum consectetur eu commodo enim excepteur ex.", 116 | "registered": "Saturday, July 26, 2014 3:55 PM", 117 | "latitude": "74.180645", 118 | "longitude": "-80.748226", 119 | "tags": [ 120 | "anim", 121 | "est", 122 | "excepteur", 123 | "esse", 124 | "voluptate", 125 | "nulla", 126 | "anim", 127 | "custom_tag" 128 | ], 129 | "range": [ 130 | 0, 131 | 1, 132 | 2, 133 | 3, 134 | 4, 135 | 5, 136 | 6, 137 | 7, 138 | 8, 139 | 9 140 | ], 141 | "friends": [ 142 | { 143 | "id": 0, 144 | "name": "Frazier Schwartz" 145 | }, 146 | { 147 | "id": 1, 148 | "name": "Ellis Fuller" 149 | }, 150 | { 151 | "id": 2, 152 | "name": "Laurel Hill" 153 | } 154 | ], 155 | "greeting": "Hello, Jill! You have 9 unread messages.", 156 | "favoriteFruit": "apple" 157 | }, 158 | { 159 | "_id": "55d54e11e47640367e1e8a29", 160 | "index": 1, 161 | "guid": "edb46838-ba45-4de1-8a8a-71a7503d5a2d", 162 | "isActive": true, 163 | "balance": "$3,282.70", 164 | "picture": "http://placehold.it/32x32", 165 | "age": 35, 166 | "eyeColor": "brown", 167 | "name": { 168 | "first": "Eliza", 169 | "last": "Mcdaniel" 170 | }, 171 | "company": "GENMOM", 172 | "email": "eliza.mcdaniel@genmom.name", 173 | "phone": "+1 (991) 496-2864", 174 | "address": "532 Jewel Street, Outlook, Utah, 2237", 175 | "about": "Aliquip ea et mollit in excepteur anim duis adipisicing laboris esse occaecat. Mollit tempor et duis sit tempor irure sint sit id enim eiusmod. Amet consectetur esse commodo nostrud dolore excepteur in laboris aliqua cillum elit velit adipisicing deserunt. Ut excepteur ad quis ea velit aliqua tempor consectetur.", 176 | "registered": "Sunday, August 17, 2014 1:04 AM", 177 | "latitude": "-39.904477", 178 | "longitude": "71.117407", 179 | "tags": [ 180 | "anim", 181 | "est", 182 | "excepteur", 183 | "esse", 184 | "voluptate", 185 | "nulla", 186 | "anim", 187 | "custom_tag" 188 | ], 189 | "range": [ 190 | 0, 191 | 1, 192 | 2, 193 | 3, 194 | 4, 195 | 5, 196 | 6, 197 | 7, 198 | 8, 199 | 9 200 | ], 201 | "friends": [ 202 | { 203 | "id": 0, 204 | "name": "Frazier Schwartz" 205 | }, 206 | { 207 | "id": 1, 208 | "name": "Ellis Fuller" 209 | }, 210 | { 211 | "id": 2, 212 | "name": "Laurel Hill" 213 | } 214 | ], 215 | "greeting": "Hello, Eliza! You have 9 unread messages.", 216 | "favoriteFruit": "banana" 217 | }, 218 | { 219 | "_id": "55d54e118f4a1f5c6749e9fa", 220 | "index": 2, 221 | "guid": "854040fa-6f9d-481b-990e-d2877dbee2d4", 222 | "isActive": false, 223 | "balance": "$3,010.47", 224 | "picture": "http://placehold.it/32x32", 225 | "age": 40, 226 | "eyeColor": "brown", 227 | "name": { 228 | "first": "Robert", 229 | "last": "Burch" 230 | }, 231 | "company": "ACRODANCE", 232 | "email": "robert.burch@acrodance.biz", 233 | "phone": "+1 (876) 431-2360", 234 | "address": "139 Cornelia Street, Collins, Oklahoma, 671", 235 | "about": "Voluptate anim est velit reprehenderit sit ut magna non commodo. Commodo veniam sit non commodo nisi enim. Sint adipisicing culpa cillum exercitation irure consequat laboris laborum.", 236 | "registered": "Wednesday, September 17, 2014 9:16 AM", 237 | "latitude": "-18.778534", 238 | "longitude": "-77.0815", 239 | "tags": [ 240 | "anim", 241 | "est", 242 | "excepteur", 243 | "esse", 244 | "voluptate", 245 | "nulla", 246 | "anim", 247 | "custom_tag" 248 | ], 249 | "range": [ 250 | 0, 251 | 1, 252 | 2, 253 | 3, 254 | 4, 255 | 5, 256 | 6, 257 | 7, 258 | 8, 259 | 9 260 | ], 261 | "friends": [ 262 | { 263 | "id": 0, 264 | "name": "Frazier Schwartz" 265 | }, 266 | { 267 | "id": 1, 268 | "name": "Ellis Fuller" 269 | }, 270 | { 271 | "id": 2, 272 | "name": "Laurel Hill" 273 | } 274 | ], 275 | "greeting": "Hello, Robert! You have 6 unread messages.", 276 | "favoriteFruit": "strawberry" 277 | }, 278 | { 279 | "_id": "55d54e1161c743c696e550b9", 280 | "index": 3, 281 | "guid": "a9bc9cc1-f159-44c0-af72-0832a4a05ed6", 282 | "isActive": false, 283 | "balance": "$2,632.61", 284 | "picture": "http://placehold.it/32x32", 285 | "age": 32, 286 | "eyeColor": "green", 287 | "name": { 288 | "first": "Mae", 289 | "last": "Fowler" 290 | }, 291 | "company": "JUNIPOOR", 292 | "email": "mae.fowler@junipoor.org", 293 | "phone": "+1 (825) 426-2682", 294 | "address": "316 Pineapple Street, Hegins, New York, 5565", 295 | "about": "Voluptate elit non magna excepteur velit voluptate. Eu aliqua Lorem eiusmod ut quis amet cillum consequat. Do magna ex laborum incididunt est proident dolore tempor in ullamco. Commodo irure labore nulla voluptate in voluptate minim mollit enim aliqua minim excepteur ad esse.", 296 | "registered": "Thursday, June 18, 2015 10:05 PM", 297 | "latitude": "-62.526412", 298 | "longitude": "-54.420474", 299 | "tags": [ 300 | "anim", 301 | "est", 302 | "excepteur", 303 | "esse", 304 | "voluptate", 305 | "nulla", 306 | "anim", 307 | "custom_tag" 308 | ], 309 | "range": [ 310 | 0, 311 | 1, 312 | 2, 313 | 3, 314 | 4, 315 | 5, 316 | 6, 317 | 7, 318 | 8, 319 | 9 320 | ], 321 | "friends": [ 322 | { 323 | "id": 0, 324 | "name": "Frazier Schwartz" 325 | }, 326 | { 327 | "id": 1, 328 | "name": "Ellis Fuller" 329 | }, 330 | { 331 | "id": 2, 332 | "name": "Laurel Hill" 333 | } 334 | ], 335 | "greeting": "Hello, Mae! You have 9 unread messages.", 336 | "favoriteFruit": "banana" 337 | }, 338 | { 339 | "_id": "55d54e1134a6c7726d4311b7", 340 | "index": 4, 341 | "guid": "7b5cbc42-3c27-41fd-bec4-08e34581ce26", 342 | "isActive": false, 343 | "balance": "$2,232.78", 344 | "picture": "http://placehold.it/32x32", 345 | "age": 39, 346 | "eyeColor": "blue", 347 | "name": { 348 | "first": "Casey", 349 | "last": "Evans" 350 | }, 351 | "company": "NETERIA", 352 | "email": "casey.evans@neteria.ca", 353 | "phone": "+1 (989) 576-2758", 354 | "address": "940 Norfolk Street, Keller, Iowa, 6578", 355 | "about": "Do Lorem ullamco laborum ex qui qui ea ullamco deserunt aliquip reprehenderit sint dolore. Amet est dolor minim officia. Non irure sint mollit aute sunt ad enim id ullamco amet excepteur minim. Deserunt cillum esse do cupidatat cupidatat dolor nostrud proident pariatur laborum minim incididunt. Adipisicing eiusmod nulla aliquip in ea commodo anim irure ex qui culpa sint. Cupidatat fugiat est laboris culpa occaecat veniam qui eiusmod. Laborum qui dolore est ipsum anim.", 356 | "registered": "Monday, August 25, 2014 11:26 PM", 357 | "latitude": "52.117994", 358 | "longitude": "-9.442317", 359 | "tags": [ 360 | "anim", 361 | "est", 362 | "excepteur", 363 | "esse", 364 | "voluptate", 365 | "nulla", 366 | "anim", 367 | "custom_tag" 368 | ], 369 | "range": [ 370 | 0, 371 | 1, 372 | 2, 373 | 3, 374 | 4, 375 | 5, 376 | 6, 377 | 7, 378 | 8, 379 | 9 380 | ], 381 | "friends": [ 382 | { 383 | "id": 0, 384 | "name": "Frazier Schwartz" 385 | }, 386 | { 387 | "id": 1, 388 | "name": "Ellis Fuller" 389 | }, 390 | { 391 | "id": 2, 392 | "name": "Laurel Hill" 393 | } 394 | ], 395 | "greeting": "Hello, Casey! You have 5 unread messages.", 396 | "favoriteFruit": "apple" 397 | } 398 | ] -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/unambiguous */ 2 | const TerserPlugin = require('terser-webpack-plugin'); 3 | 4 | module.exports = { 5 | entry: './src/main/browser-index.js', 6 | output: { 7 | library: 'JsonUrl', 8 | libraryTarget: 'umd', 9 | libraryExport: 'default', 10 | filename: 'json-url.js', 11 | chunkFilename: 'json-url-[name].js', 12 | path: __dirname + '/dist/browser' 13 | }, 14 | module: { 15 | rules: [ 16 | { 17 | test: /\.js$/, 18 | exclude: /(node_modules|bower_components)/, 19 | use: { 20 | loader: 'babel-loader', 21 | options: { 22 | babelrc: false, 23 | presets: ['@babel/preset-env'], 24 | plugins: [ 25 | '@babel/plugin-syntax-dynamic-import', 26 | ['module-resolver', 27 | { 28 | root: ["src"], 29 | alias: { 30 | lzma: require.resolve('lzma/src/lzma_worker-min'), 31 | bluebird: require.resolve('bluebird/js/browser/bluebird.core.min.js') 32 | } 33 | } 34 | ], 35 | '@babel/plugin-transform-runtime', 36 | ] 37 | } 38 | } 39 | } 40 | ], 41 | }, 42 | mode: 'production', 43 | optimization: { 44 | minimize: true, 45 | minimizer: [new TerserPlugin()] 46 | } 47 | }; -------------------------------------------------------------------------------- /webpack.config.single.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/unambiguous */ 2 | const webpack = require('webpack'); 3 | const TerserPlugin = require('terser-webpack-plugin'); 4 | 5 | module.exports = { 6 | entry: './src/main/browser-index.js', 7 | output: { 8 | library: 'JsonUrl', 9 | libraryTarget: 'umd', 10 | libraryExport: 'default', 11 | filename: 'json-url-single.js', 12 | path: __dirname + '/dist/browser' 13 | }, 14 | module: { 15 | rules: [ 16 | { 17 | test: /\.js$/, 18 | exclude: /(node_modules|bower_components)/, 19 | use: { 20 | loader: 'babel-loader', 21 | options: { 22 | babelrc: false, 23 | presets: ['@babel/preset-env'], 24 | plugins: [ 25 | '@babel/plugin-syntax-dynamic-import', 26 | ['module-resolver', 27 | { 28 | root: ["src"], 29 | alias: { 30 | lzma: require.resolve('lzma/src/lzma_worker-min'), 31 | bluebird: require.resolve('bluebird/js/browser/bluebird.core.min.js') 32 | } 33 | } 34 | ], 35 | '@babel/plugin-transform-runtime', 36 | ] 37 | } 38 | } 39 | } 40 | ], 41 | }, 42 | node: { 43 | global: false 44 | }, 45 | plugins: [ 46 | new webpack.optimize.LimitChunkCountPlugin({ 47 | maxChunks: 1 48 | }), 49 | new webpack.DefinePlugin({ 50 | global: 'window' 51 | }) 52 | ], 53 | mode: 'production', 54 | optimization: { 55 | minimize: true, 56 | minimizer: [new TerserPlugin()] 57 | } 58 | }; 59 | --------------------------------------------------------------------------------