From cb198d02ec083c05d2e630ee51b1bd0299d99296 Mon Sep 17 00:00:00 2001 From: Kevin Ushey Date: Thu, 16 Apr 2020 15:00:25 -0700 Subject: [PATCH 1/5] support Uint8Array sub-array --- suite.js | 6 ++++++ text.js | 8 +++++--- text.min.js | 7 ++----- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/suite.js b/suite.js index 7830e5a..9351051 100644 --- a/suite.js +++ b/suite.js @@ -38,6 +38,12 @@ function tests(isNative, TextEncoder, TextDecoder) { } }); + test('subarray', () => { + const buffer = new Uint8Array([104, 101, 108, 108, 111]); + const array = buffer.subarray(0, 4); + assert.equal(dec.decode(array), 'hell'); + }); + test('null in middle', () => { const s = 'pad\x00pad'; const buffer = new Uint8Array([112, 97, 100, 0, 112, 97, 100]); diff --git a/text.js b/text.js index c0b3e54..0b5fef8 100644 --- a/text.js +++ b/text.js @@ -140,14 +140,16 @@ FastTextDecoder.prototype.decode = function(buffer, options={stream: false}) { throw new Error(`Failed to decode: the 'stream' option is unsupported.`); } + // Accept Uint8Array's as-is. + let bytes = buffer; + // Look for ArrayBufferView, which isn't a real type, but basically represents // all the valid TypedArray types plus DataView. They all have ".buffer" as // an instance of ArrayBuffer. - if (buffer.buffer instanceof ArrayBuffer) { - buffer = buffer.buffer; + if (!(bytes instanceof Uint8Array) && bytes.buffer instanceof ArrayBuffer) { + bytes = new Uint8Array(buffer.buffer); } - let bytes = new Uint8Array(buffer); let pos = 0; let pending = []; const chunks = []; diff --git a/text.min.js b/text.min.js index a17e39a..ad6ce8f 100644 --- a/text.min.js +++ b/text.min.js @@ -1,5 +1,2 @@ -(function(l){function m(){}function k(b,a){b=void 0===b?"utf-8":b;a=void 0===a?{fatal:!1}:a;if(-1==n.indexOf(b.toLowerCase()))throw new RangeError("Failed to construct 'TextDecoder': The encoding label provided ('"+b+"') is invalid.");if(a.fatal)throw Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported.");}if(l.TextEncoder&&l.TextDecoder)return!1;var n=["utf-8","utf8","unicode-1-1-utf-8"];Object.defineProperty(m.prototype,"encoding",{value:"utf-8"});m.prototype.encode=function(b, -a){a=void 0===a?{stream:!1}:a;if(a.stream)throw Error("Failed to encode: the 'stream' option is unsupported.");a=0;for(var g=b.length,f=0,c=Math.max(32,g+(g>>1)+7),e=new Uint8Array(c>>3<<3);a=d){if(a=d)continue}f+4>e.length&&(c+=8,c*=1+a/b.length*2,c=c>>3<<3,h=new Uint8Array(c),h.set(e),e=h);if(0===(d&4294967168))e[f++]=d;else{if(0===(d&4294965248))e[f++]= -d>>6&31|192;else if(0===(d&4294901760))e[f++]=d>>12&15|224,e[f++]=d>>6&63|128;else if(0===(d&4292870144))e[f++]=d>>18&7|240,e[f++]=d>>12&63|128,e[f++]=d>>6&63|128;else continue;e[f++]=d&63|128}}return e.slice?e.slice(0,f):e.subarray(0,f)};Object.defineProperty(k.prototype,"encoding",{value:"utf-8"});Object.defineProperty(k.prototype,"fatal",{value:!1});Object.defineProperty(k.prototype,"ignoreBOM",{value:!1});k.prototype.decode=function(b,a){a=void 0===a?{stream:!1}:a;if(a.stream)throw Error("Failed to decode: the 'stream' option is unsupported."); -b.buffer instanceof ArrayBuffer&&(b=b.buffer);b=new Uint8Array(b);a=0;for(var g=[],f=[];;){var c=a>>10&1023|55296),c=56320|c&1023);g.push(c)}}};l.TextEncoder=m;l.TextDecoder=k})("undefined"!==typeof window?window:"undefined"!==typeof global?global:this); +(function(b){function e(){}function c(a,d){a=void 0===a?"utf-8":a;d=void 0===d?{fatal:!1}:d;if(-1===f.indexOf(a.toLowerCase()))throw new RangeError("Failed to construct 'TextDecoder': The encoding label provided ('"+a+"') is invalid.");if(d.fatal)throw Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported.");}if(b.TextEncoder&&b.TextDecoder)return!1;var f=["utf-8","utf8","unicode-1-1-utf-8"];Object.defineProperty(e.prototype,"encoding",{value:"utf-8"});Object.defineProperty(c.prototype, +"encoding",{value:"utf-8"});Object.defineProperty(c.prototype,"fatal",{value:!1});Object.defineProperty(c.prototype,"ignoreBOM",{value:!1});b.TextEncoder=e;b.TextDecoder=c})("undefined"!==typeof window?window:"undefined"!==typeof global?global:this); From 30b237a3db0a95312144d70429caa150307d740b Mon Sep 17 00:00:00 2001 From: Kevin Ushey Date: Thu, 16 Apr 2020 15:10:40 -0700 Subject: [PATCH 2/5] add compile helper; create sourcemaps --- compile.sh | 9 +++++++++ text.min.js.map | 8 ++++++++ 2 files changed, 17 insertions(+) create mode 100755 compile.sh create mode 100644 text.min.js.map diff --git a/compile.sh b/compile.sh new file mode 100755 index 0000000..16a66ca --- /dev/null +++ b/compile.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env sh + +closure-compiler \ + --compilation_level ADVANCED \ + --js_output_file text.min.js \ + --language_out ECMASCRIPT5 \ + --warning_level VERBOSE \ + --create_source_map %outname%.map \ + text.js diff --git a/text.min.js.map b/text.min.js.map new file mode 100644 index 0000000..efb1f7d --- /dev/null +++ b/text.min.js.map @@ -0,0 +1,8 @@ +{ +"version":3, +"file":"text.min.js", +"lineCount":2, +"mappings":"AAsBC,SAAQ,CAACA,CAAD,CAAQ,CAcjBC,QAASA,EAAe,EAAG,EAgF3BC,QAASA,EAAe,CAACC,CAAD,CAAmBC,CAAnB,CAA2C,CAA1CD,CAAA,CAAA,IAAA,EAAA,GAAAA,CAAA,CAAS,OAAT,CAAAA,CAAkBC,EAAA,CAAA,IAAA,EAAA,GAAAA,CAAA,CAAQ,CAACC,MAAO,CAAA,CAAR,CAAR,CAAAD,CACzC,IAAuD,EAAvD,GAAIE,CAAAC,QAAA,CAAuBJ,CAAAK,YAAA,EAAvB,CAAJ,CACE,KAAM,KAAIC,UAAJ,CACJ,mEADI,CACgEN,CADhE,CACJ,gBADI,CAAN,CAGF,GAAIC,CAAAC,MAAJ,CACE,KAAUK,MAAJ,CAAU,uEAAV,CAAN,CAN+D,CA1FnE,GAAIV,CAAA,YAAJ,EAA4BA,CAAA,YAA5B,CACE,MAAO,CAAA,CAIT,KAAMM,EAAiB,CAAC,OAAD,CAAU,MAAV,CAAkB,mBAAlB,CAUvBK,OAAAC,eAAA,CAAsBX,CAAAY,UAAtB,CAAiD,UAAjD,CAA6D,CAACC,MAAO,OAAR,CAA7D,CAqFAH,OAAAC,eAAA,CAAsBV,CAAAW,UAAtB;AAAiD,UAAjD,CAA6D,CAACC,MAAO,OAAR,CAA7D,CAEAH,OAAAC,eAAA,CAAsBV,CAAAW,UAAtB,CAAiD,OAAjD,CAA0D,CAACC,MAAO,CAAA,CAAR,CAA1D,CAEAH,OAAAC,eAAA,CAAsBV,CAAAW,UAAtB,CAAiD,WAAjD,CAA8D,CAACC,MAAO,CAAA,CAAR,CAA9D,CAiFAd,EAAA,YAAA,CAAuBC,CACvBD,EAAA,YAAA,CAAuBE,CA9LN,CAAhB,CAAA,CAgMmB,WAAlB,GAAA,MAAOa,OAAP,CAAgCA,MAAhC,CAA4D,WAAlB,GAAA,MAAOC,OAAP,CAAgCA,MAAhC,CAAyC,IAhMpF;", +"sources":["text.js"], +"names":["scope","FastTextEncoder","FastTextDecoder","utfLabel","options","fatal","validUtfLabels","indexOf","toLowerCase","RangeError","Error","Object","defineProperty","prototype","value","window","global"] +} From 3dbe34be6facafd195a76498d2f5da18046d2510 Mon Sep 17 00:00:00 2001 From: Kevin Ushey Date: Thu, 16 Apr 2020 15:14:05 -0700 Subject: [PATCH 3/5] add build command --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 2c7d0c1..7db5192 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "mocha": "^7.1.0" }, "scripts": { + "build": "./compile.sh", "test": "mocha" } } From f3e84bc9cee4c54da77a1e3575a0788511ea0954 Mon Sep 17 00:00:00 2001 From: Kevin Ushey Date: Thu, 16 Apr 2020 15:36:31 -0700 Subject: [PATCH 4/5] indicate that encode, decode are exports --- text.js | 4 ++-- text.min.js | 7 +++++-- text.min.js.map | 6 +++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/text.js b/text.js index 0b5fef8..e1fdc68 100644 --- a/text.js +++ b/text.js @@ -46,7 +46,7 @@ Object.defineProperty(FastTextEncoder.prototype, 'encoding', {value: 'utf-8'}); * @param {{stream: boolean}=} options * @return {!Uint8Array} */ -FastTextEncoder.prototype.encode = function(string, options={stream: false}) { +FastTextEncoder.prototype['encode'] = function(string, options={stream: false}) { if (options.stream) { throw new Error(`Failed to encode: the 'stream' option is unsupported.`); } @@ -135,7 +135,7 @@ Object.defineProperty(FastTextDecoder.prototype, 'ignoreBOM', {value: false}); * @param {{stream: boolean}=} options * @return {string} */ -FastTextDecoder.prototype.decode = function(buffer, options={stream: false}) { +FastTextDecoder.prototype['decode'] = function(buffer, options={stream: false}) { if (options['stream']) { throw new Error(`Failed to decode: the 'stream' option is unsupported.`); } diff --git a/text.min.js b/text.min.js index ad6ce8f..9627738 100644 --- a/text.min.js +++ b/text.min.js @@ -1,2 +1,5 @@ -(function(b){function e(){}function c(a,d){a=void 0===a?"utf-8":a;d=void 0===d?{fatal:!1}:d;if(-1===f.indexOf(a.toLowerCase()))throw new RangeError("Failed to construct 'TextDecoder': The encoding label provided ('"+a+"') is invalid.");if(d.fatal)throw Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported.");}if(b.TextEncoder&&b.TextDecoder)return!1;var f=["utf-8","utf8","unicode-1-1-utf-8"];Object.defineProperty(e.prototype,"encoding",{value:"utf-8"});Object.defineProperty(c.prototype, -"encoding",{value:"utf-8"});Object.defineProperty(c.prototype,"fatal",{value:!1});Object.defineProperty(c.prototype,"ignoreBOM",{value:!1});b.TextEncoder=e;b.TextDecoder=c})("undefined"!==typeof window?window:"undefined"!==typeof global?global:this); +(function(l){function m(){}function k(c,a){c=void 0===c?"utf-8":c;a=void 0===a?{fatal:!1}:a;if(-1===n.indexOf(c.toLowerCase()))throw new RangeError("Failed to construct 'TextDecoder': The encoding label provided ('"+c+"') is invalid.");if(a.fatal)throw Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported.");}if(l.TextEncoder&&l.TextDecoder)return!1;var n=["utf-8","utf8","unicode-1-1-utf-8"];Object.defineProperty(m.prototype,"encoding",{value:"utf-8"});m.prototype.encode=function(c, +a){a=void 0===a?{stream:!1}:a;if(a.stream)throw Error("Failed to encode: the 'stream' option is unsupported.");a=0;for(var g=c.length,f=0,b=Math.max(32,g+(g>>1)+7),e=new Uint8Array(b>>3<<3);a=d){if(a=d)continue}f+4>e.length&&(b+=8,b*=1+a/c.length*2,b=b>>3<<3,h=new Uint8Array(b),h.set(e),e=h);if(0===(d&4294967168))e[f++]=d;else{if(0===(d&4294965248))e[f++]= +d>>6&31|192;else if(0===(d&4294901760))e[f++]=d>>12&15|224,e[f++]=d>>6&63|128;else if(0===(d&4292870144))e[f++]=d>>18&7|240,e[f++]=d>>12&63|128,e[f++]=d>>6&63|128;else continue;e[f++]=d&63|128}}return e.slice?e.slice(0,f):e.subarray(0,f)};Object.defineProperty(k.prototype,"encoding",{value:"utf-8"});Object.defineProperty(k.prototype,"fatal",{value:!1});Object.defineProperty(k.prototype,"ignoreBOM",{value:!1});k.prototype.decode=function(c,a){a=void 0===a?{stream:!1}:a;if(a.stream)throw Error("Failed to decode: the 'stream' option is unsupported."); +a=c;!(a instanceof Uint8Array)&&a.buffer instanceof ArrayBuffer&&(a=new Uint8Array(c.buffer));c=0;for(var g=[],f=[];;){var b=c>>10&1023|55296),b=56320|b&1023);g.push(b)}}};l.TextEncoder=m;l.TextDecoder=k})("undefined"!==typeof window?window:"undefined"!==typeof global?global:this); diff --git a/text.min.js.map b/text.min.js.map index efb1f7d..7d96d5d 100644 --- a/text.min.js.map +++ b/text.min.js.map @@ -1,8 +1,8 @@ { "version":3, "file":"text.min.js", -"lineCount":2, -"mappings":"AAsBC,SAAQ,CAACA,CAAD,CAAQ,CAcjBC,QAASA,EAAe,EAAG,EAgF3BC,QAASA,EAAe,CAACC,CAAD,CAAmBC,CAAnB,CAA2C,CAA1CD,CAAA,CAAA,IA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CAAA,CAAMhB,CAAA,EAAN,CAAR6B,CAAuB,EAGzBC,EAAAA;CAAcJ,CAAdI,CAAsB,CAAtBA,GAA+B,EAA/BA,CAAwCH,CAAxCG,EAAiD,EAAjDA,CAA0DF,CAA1DE,EAAmE,CAAnEA,CAA2ED,CAC/D,MAAhB,CAAIC,CAAJ,GAEEA,CAEA,EAFa,KAEb,CADAZ,CAAAG,KAAA,CAAcS,CAAd,GAA4B,EAA5B,CAAkC,IAAlC,CAA0C,KAA1C,CACA,CAAAA,CAAA,CAAY,KAAZ,CAAqBA,CAArB,CAAiC,IAJnC,CAMAZ,EAAAG,KAAA,CAAaS,CAAb,CAbkC,CAnC7B,CAnBqE,CA0EhF/C,EAAA,YAAA,CAAuBC,CACvBD,EAAA,YAAA,CAAuBE,CA9LN,CAAhB,CAAA,CAgMmB,WAAlB,GAAA,MAAO8C,OAAP,CAAgCA,MAAhC,CAA4D,WAAlB,GAAA,MAAOC,OAAP,CAAgCA,MAAhC,CAAyC,IAhMpF;", "sources":["text.js"], -"names":["scope","FastTextEncoder","FastTextDecoder","utfLabel","options","fatal","validUtfLabels","indexOf","toLowerCase","RangeError","Error","Object","defineProperty","prototype","value","window","global"] +"names":["scope","FastTextEncoder","FastTextDecoder","utfLabel","options","fatal","validUtfLabels","indexOf","toLowerCase","RangeError","Error","Object","defineProperty","prototype","value","string","stream","pos","len","length","at","tlen","Math","max","target","Uint8Array","charCodeAt","extra","update","set","slice","subarray","buffer","bytes","ArrayBuffer","pending","chunks","more","push","String","fromCharCode","apply","join","byte1","byte2","byte3","byte4","codepoint","window","global"] } From 8d340155b7160f3f7bf102458c94cbeb83fdd3c7 Mon Sep 17 00:00:00 2001 From: Kevin Ushey Date: Thu, 16 Apr 2020 15:58:08 -0700 Subject: [PATCH 5/5] depend on + use google-closure-compiler --- compile.sh | 2 +- package.json | 3 +- yarn.lock | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 154 insertions(+), 4 deletions(-) diff --git a/compile.sh b/compile.sh index 16a66ca..4f81758 100755 --- a/compile.sh +++ b/compile.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -closure-compiler \ +google-closure-compiler \ --compilation_level ADVANCED \ --js_output_file text.min.js \ --language_out ECMASCRIPT5 \ diff --git a/package.json b/package.json index 7db5192..0798a5d 100644 --- a/package.json +++ b/package.json @@ -8,10 +8,11 @@ "license": "Apache-2.0", "devDependencies": { "chai": "^4.2.0", + "google-closure-compiler": "^20200406.0.0", "mocha": "^7.1.0" }, "scripts": { - "build": "./compile.sh", + "compile": "./compile.sh", "test": "mocha" } } diff --git a/yarn.lock b/yarn.lock index 288ca5a..3fa0bd6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -91,7 +91,7 @@ chai@^4.2.0: pathval "^1.1.0" type-detect "^4.0.5" -chalk@^2.4.2: +chalk@2.x, chalk@^2.4.2: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== @@ -129,6 +129,30 @@ cliui@^5.0.0: strip-ansi "^5.2.0" wrap-ansi "^5.1.0" +clone-buffer@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/clone-buffer/-/clone-buffer-1.0.0.tgz#e3e25b207ac4e701af721e2cb5a16792cac3dc58" + integrity sha1-4+JbIHrE5wGvch4staFnksrD3Fg= + +clone-stats@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/clone-stats/-/clone-stats-1.0.0.tgz#b3782dff8bb5474e18b9b6bf0fdfe782f8777680" + integrity sha1-s3gt/4u1R04Yuba/D9/ngvh3doA= + +clone@^2.1.1: + version "2.1.2" + resolved "https://registry.yarnpkg.com/clone/-/clone-2.1.2.tgz#1b7f4b9f591f1e8f83670401600345a02887435f" + integrity sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18= + +cloneable-readable@^1.0.0: + version "1.1.3" + resolved "https://registry.yarnpkg.com/cloneable-readable/-/cloneable-readable-1.1.3.tgz#120a00cb053bfb63a222e709f9683ea2e11d8cec" + integrity sha512-2EF8zTQOxYq70Y4XKtorQupqF0m49MBz2/yf5Bj+MHjvpG3Hy7sImifnqD6UA+TKYxeSV+u6qqQPawN5UvnpKQ== + dependencies: + inherits "^2.0.1" + process-nextick-args "^2.0.0" + readable-stream "^2.3.5" + color-convert@^1.9.0: version "1.9.3" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" @@ -146,6 +170,11 @@ concat-map@0.0.1: resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= +core-util-is@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" + integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= + debug@3.2.6: version "3.2.6" resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b" @@ -283,6 +312,47 @@ glob@7.1.3: once "^1.3.0" path-is-absolute "^1.0.0" +google-closure-compiler-java@^20200406.0.0: + version "20200406.0.0" + resolved "https://registry.yarnpkg.com/google-closure-compiler-java/-/google-closure-compiler-java-20200406.0.0.tgz#89c640b89a91e9a693ab8119e3839d3e79b158ab" + integrity sha512-07WM/06CgQ0T2ZtSitfl+jmpeXW+c+spZgEgekJxEauzZztruYSkkBAHK8bZQ0N0+ZGfIUyQFNhLu//vxb5EJg== + +google-closure-compiler-js@^20200406.0.0: + version "20200406.0.0" + resolved "https://registry.yarnpkg.com/google-closure-compiler-js/-/google-closure-compiler-js-20200406.0.0.tgz#e73f498b1ab56a0580c0f945463252f7562f6f98" + integrity sha512-4qsr9VwjpSfoGt84bRAwDAcUlyYodZ9iywVMQwWzCu+SziCNXLFhUWkfLqTXbOYRSwO94UadwERSBdoPZY/GrA== + +google-closure-compiler-linux@^20200406.0.0: + version "20200406.0.0" + resolved "https://registry.yarnpkg.com/google-closure-compiler-linux/-/google-closure-compiler-linux-20200406.0.0.tgz#af2d5e6041a8a8ac4a5f0ec5015d328e18b66121" + integrity sha512-5NiU/jAjeMVJ7xm1KBDttE863lF7ItEqxg5Z1Vg/QMabTZz6Rr5S0Qy4hP+wjMfBnmqcL10BjXKJP5/m+doSbA== + +google-closure-compiler-osx@^20200406.0.0: + version "20200406.0.0" + resolved "https://registry.yarnpkg.com/google-closure-compiler-osx/-/google-closure-compiler-osx-20200406.0.0.tgz#bcab837e654dd74828030eafb95acadc49d974c6" + integrity sha512-XSF1l7GANVHnp2w8AGhhGDL3gw+XV3RaJvA7GsOJUmplPHguwlNvcLMEnSit7AEDa0JYdaQ50dfATwIKm6k8BQ== + +google-closure-compiler-windows@^20200406.0.0: + version "20200406.0.0" + resolved "https://registry.yarnpkg.com/google-closure-compiler-windows/-/google-closure-compiler-windows-20200406.0.0.tgz#ddb785df271026dd3a97da37710771480b6d2341" + integrity sha512-F7mSN06PrjWYrD9cTkCcNwJXyoYmcwAMrJGgFvmm04Nb7TDQRK6yVqXwrEkncGMuiymD+B1vsoCzUJ/GlQVf0Q== + +google-closure-compiler@^20200406.0.0: + version "20200406.0.0" + resolved "https://registry.yarnpkg.com/google-closure-compiler/-/google-closure-compiler-20200406.0.0.tgz#ae77582160fb286e161249f7e1c3806396beb251" + integrity sha512-CBfXKVeZASKrgWRDJoYKxbZ546Pphld1SP6mN/KXVW4LbtV1wvXauM9wq1X/Y0Cez4Qh8MlU8VHCtLtNZfq17A== + dependencies: + chalk "2.x" + google-closure-compiler-java "^20200406.0.0" + google-closure-compiler-js "^20200406.0.0" + minimist "1.x" + vinyl "2.x" + vinyl-sourcemaps-apply "^0.2.0" + optionalDependencies: + google-closure-compiler-linux "^20200406.0.0" + google-closure-compiler-osx "^20200406.0.0" + google-closure-compiler-windows "^20200406.0.0" + growl@1.10.5: version "1.10.5" resolved "https://registry.yarnpkg.com/growl/-/growl-1.10.5.tgz#f2735dc2283674fa67478b10181059355c369e5e" @@ -318,7 +388,7 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2: +inherits@2, inherits@^2.0.1, inherits@~2.0.3: version "2.0.4" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== @@ -381,6 +451,11 @@ is-symbol@^1.0.2: dependencies: has-symbols "^1.0.1" +isarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE= + isexe@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" @@ -426,6 +501,11 @@ minimist@0.0.8: resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" integrity sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0= +minimist@1.x: + version "1.2.5" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" + integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== + mkdirp@0.5.1: version "0.5.1" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" @@ -560,6 +640,24 @@ picomatch@^2.0.4: resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.1.tgz#21bac888b6ed8601f831ce7816e335bc779f0a4a" integrity sha512-ISBaA8xQNmwELC7eOjqFKMESB2VIqt4PPDD0nsS95b/9dZXvVKOlz9keMSnoGGKcOHXfTvDD6WMaRoSc9UuhRA== +process-nextick-args@^2.0.0, process-nextick-args@~2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" + integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag== + +readable-stream@^2.3.5: + version "2.3.7" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" + integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.3" + isarray "~1.0.0" + process-nextick-args "~2.0.0" + safe-buffer "~5.1.1" + string_decoder "~1.1.1" + util-deprecate "~1.0.1" + readdirp@~3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.2.0.tgz#c30c33352b12c96dfb4b895421a49fd5a9593839" @@ -567,6 +665,16 @@ readdirp@~3.2.0: dependencies: picomatch "^2.0.4" +remove-trailing-separator@^1.0.1: + version "1.1.0" + resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef" + integrity sha1-wkvOKig62tW8P1jg1IJJuSN52O8= + +replace-ext@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/replace-ext/-/replace-ext-1.0.0.tgz#de63128373fcbf7c3ccfa4de5a480c45a67958eb" + integrity sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs= + require-directory@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" @@ -577,6 +685,11 @@ require-main-filename@^2.0.0: resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b" integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg== +safe-buffer@~5.1.0, safe-buffer@~5.1.1: + version "5.1.2" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" + integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== + semver@^5.7.0: version "5.7.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" @@ -587,6 +700,11 @@ set-blocking@^2.0.0: resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc= +source-map@^0.5.1: + version "0.5.7" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" + integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= + sprintf-js@~1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" @@ -625,6 +743,13 @@ string.prototype.trimright@^2.1.1: define-properties "^1.1.3" function-bind "^1.1.1" +string_decoder@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" + integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg== + dependencies: + safe-buffer "~5.1.0" + strip-ansi@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f" @@ -670,6 +795,30 @@ type-detect@^4.0.0, type-detect@^4.0.5: resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g== +util-deprecate@~1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= + +vinyl-sourcemaps-apply@^0.2.0: + version "0.2.1" + resolved "https://registry.yarnpkg.com/vinyl-sourcemaps-apply/-/vinyl-sourcemaps-apply-0.2.1.tgz#ab6549d61d172c2b1b87be5c508d239c8ef87705" + integrity sha1-q2VJ1h0XLCsbh75cUI0jnI74dwU= + dependencies: + source-map "^0.5.1" + +vinyl@2.x: + version "2.2.0" + resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-2.2.0.tgz#d85b07da96e458d25b2ffe19fece9f2caa13ed86" + integrity sha512-MBH+yP0kC/GQ5GwBqrTPTzEfiiLjta7hTtvQtbxBgTeSXsmKQRQecjibMbxIXzVT3Y9KJK+drOz1/k+vsu8Nkg== + dependencies: + clone "^2.1.1" + clone-buffer "^1.0.0" + clone-stats "^1.0.0" + cloneable-readable "^1.0.0" + remove-trailing-separator "^1.0.1" + replace-ext "^1.0.0" + which-module@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a"