From f0313fe998779d9de4955ab43b5be9099c6c804b Mon Sep 17 00:00:00 2001 From: Hubert B Manilla Date: Sat, 1 Apr 2023 00:24:48 +0100 Subject: [PATCH 1/4] Add support for the sourcemaps ignorelist Add support for the x_google_ignoreList to the SourceMapConsumer. --- .DS_Store | Bin 0 -> 10244 bytes lib/source-map-consumer.js | 18 ++++++++++++++++++ test/test-source-map-consumer.js | 10 ++++++++++ test/util.js | 12 ++++++++++++ wasm-mappings/.DS_Store | Bin 0 -> 6148 bytes 5 files changed, 40 insertions(+) create mode 100644 .DS_Store create mode 100644 wasm-mappings/.DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..bf67d3d6f84d12e4bccf6ea15fd53d4c63941ed1 GIT binary patch literal 10244 zcmeHMzmF3~6n<-)+@8719S8vuLRktT3b4*6ghYX4d^T`W0w{Ju0qF2A*$eirWv?-C z9C8m0B_L5mN6fj`~fIU3YwIWQlz0E;d`@ld$a4cl>(#_nvrJS?9TgU-upan z_TC&38TmmyOJos|iOOU*m4d97va>%0|)rjBeq8ZQ(Xa+O`ngPwg z_G19wY%b~Vbux0k)U9SfGce8o=jn6E z)*IBPb|`giu4U#fXq;b>JhtNKv&&IyMenv z1z^@7&!FY!^LX<;dgZt|QeQ>pSdf@9eMhU52eJ&wmc&>fqV%Z}rAZOjksVANqcK_` zZWCXxK}+IQUjN!_Z1Nh6ZgDz38sak{Vsi!@uEMV({3uZ|%%X@!)w*5SnHB7k8)%!@ zF~{JOE1olia|(SYG6P4bI>TIKhDkV%3KcgC&Wqr*K;J^f@GT-iMJxz=28f=Tu(Si4 zyFk`az390kB0@#aPe6~I#v(#gWXeC+qNj0^cVw(yb=dF96Zf}jw{7>mrKR7EL^8GG ziy6~Qo9X%V)l$nHmb{8L=;tfF%lve);Uv}Mg(63Z~up7g*#XT#o<5g^@(Gy_1 z-hj%LOSV&Yhk1A4)cazdl0RUYv*zsD;{NsZ?9%d4>*VsrQENSW{P+p(FK=wjn)?oC zPpw|-+`hAZcjMk8ID=xyzXEB&e-7Hm=mkWCH*@(9bxhsPy?eoS4zTLyCT={urGI4u z0_@FF&uP03ACYY5JPol0`Zz3(q4H+viVtlwx*0^^t3TBgr0QGp!NY&1ucLaKJ`{Xh zr_8VV|NjswBgtof!ysKW1DXNNfM!55pc&YH3?zM%EWZCQPX7P@_A^{tq#4i*d^84( zRH0PJW4g_(DmpXYwOgpyP`R+)$d>|whE@2zxQ@pIU&kMj@5Ggq?B}E$`BK1v6L3iX eHvg0VGoXQ7JpSH5=l?qYN3QOv`R`|$|9=2GqW2a6 literal 0 HcmV?d00001 diff --git a/lib/source-map-consumer.js b/lib/source-map-consumer.js index b2db4d55..7f6c2197 100644 --- a/lib/source-map-consumer.js +++ b/lib/source-map-consumer.js @@ -187,6 +187,7 @@ class BasicSourceMapConsumer extends SourceMapConsumer { const sourcesContent = util.getArg(sourceMap, "sourcesContent", null); const mappings = util.getArg(sourceMap, "mappings"); const file = util.getArg(sourceMap, "file", null); + const x_google_ignoreList = util.getArg(sourceMap, "x_google_ignoreList", null); // Once again, Sass deviates from the spec and supplies the version as a // string rather than a number, so we use loose equality checking here. @@ -215,6 +216,7 @@ class BasicSourceMapConsumer extends SourceMapConsumer { that._mappings = mappings; that._sourceMapURL = aSourceMapURL; that.file = file; + that.x_google_ignoreList = x_google_ignoreList; that._computedColumnSpans = false; that._mappingsPtr = 0; @@ -799,6 +801,22 @@ class IndexedSourceMapConsumer extends SourceMapConsumer { return sources; } + /* + * + */ + get x_google_ignoreList() { + const x_google_ignoreList = []; + for (let i = 0; i < this._sections.length; i++) { + const ignoreList = this._sections[i].consumer.x_google_ignoreList; + if (ignoreList) { + for (let j = 0; j < ignoreList.length; j++) { + x_google_ignoreList.push(ignoreList[j]); + } + } + } + return x_google_ignoreList; + } + /** * Returns the original source, line, and column information for the generated * source's line and column positions provided. The only argument is an object diff --git a/test/test-source-map-consumer.js b/test/test-source-map-consumer.js index 23b2a34f..33267d4f 100644 --- a/test/test-source-map-consumer.js +++ b/test/test-source-map-consumer.js @@ -88,6 +88,16 @@ exports["test that the `sources` field has the original sources"] = map.destroy(); }; +exports["test that the SourceMapConsumer supports the ignoreList"] = async function (assert) { + const map = await new SourceMapConsumer(util.testMapWithIgnoreList); + const sources = map.sources; + const ignoreList = map.x_google_ignoreList; + assert.equal(ignoreList[0], 0); + assert.equal(sources[ignoreList[0]], "/the/root/one.js"); + assert.equal(ignoreList.length, 1); + map.destroy(); +} + exports["test that the source root is reflected in a mapping's source field"] = async function (assert) { let map; diff --git a/test/util.js b/test/util.js index fe2fc641..d99669c3 100644 --- a/test/util.js +++ b/test/util.js @@ -37,6 +37,18 @@ exports.testMap = { mappings: "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA", }; + +exports.testMapWithIgnoreList = { + version: 3, + file: "min.js", + names: ["bar", "baz", "n"], + sources: ["one.js", "two.js"], + sourceRoot: "/the/root", + mappings: + "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA", + x_google_ignoreList: [0], +}; + exports.testMapNoSourceRoot = { version: 3, file: "min.js", diff --git a/wasm-mappings/.DS_Store b/wasm-mappings/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..b30e622b75370a0dc98b86f2be0d40b16b45b6b6 GIT binary patch literal 6148 zcmeHLy-EW?5T5m-hNxg^p>nN7ioC%ov9S_-0nHCdF!4g7SO{{3Soj8FF9-RE>S2A7SM3vC-6o$F!)V(abPAcY^eJNW6x zis^`Yh*zf~b!d;eDR!v^P8#qj(lIQ3*o)%f=5{_mhupqAm%X0T+rrjBbNP+=MjZUa zd=76HTqh_17vRj@q1xHVVy~$`NcYH$vv(d+=ATx9b-h0@KIvv_kgWTHwxZRF@ z|Fjw!KAk!23_kL)^9WXC-P6be^$oqLal@zcWC2-NRy&8cmvsG($7q)(d)V=b5(M~h zLCt2#^YiP)GvFEU4A>0t`4FNpMg|j&a&(}RPXJ&JY7tz^SqThT0gMbL8lizGJrt;i zD)Wh<^l<1y;};oBH0t4`Br@hPk(K#EQ4$^cP~1sH8h!5>@C>*N1p0Q7>;LA*-~a9) zf9DzS4E!qwRIa>J-oTPfZOtr>Yi)?Oi^jr!iAEWM&Xi-h;8M*0D~P}r@&zz5m}rCs P;(rJT4ZiaX{3-+QX_n&` literal 0 HcmV?d00001 From 6e207bfcf2d46e29f711878b9b87f96131101632 Mon Sep 17 00:00:00 2001 From: Hubert B Manilla Date: Sat, 1 Apr 2023 00:33:11 +0100 Subject: [PATCH 2/4] Remove useless code --- lib/source-map-consumer.js | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/lib/source-map-consumer.js b/lib/source-map-consumer.js index 7f6c2197..d2cf451d 100644 --- a/lib/source-map-consumer.js +++ b/lib/source-map-consumer.js @@ -801,22 +801,6 @@ class IndexedSourceMapConsumer extends SourceMapConsumer { return sources; } - /* - * - */ - get x_google_ignoreList() { - const x_google_ignoreList = []; - for (let i = 0; i < this._sections.length; i++) { - const ignoreList = this._sections[i].consumer.x_google_ignoreList; - if (ignoreList) { - for (let j = 0; j < ignoreList.length; j++) { - x_google_ignoreList.push(ignoreList[j]); - } - } - } - return x_google_ignoreList; - } - /** * Returns the original source, line, and column information for the generated * source's line and column positions provided. The only argument is an object From 9beca30b67248da659ffc8fa0dca4477e06a82ed Mon Sep 17 00:00:00 2001 From: Hubert B Manilla Date: Tue, 4 Apr 2023 12:50:00 +0100 Subject: [PATCH 3/4] Fix prettier issues and update read me --- README.md | 4 ++++ lib/source-map-consumer.js | 6 +++++- test/test-source-map-consumer.js | 7 ++++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1d2741df..312177c5 100644 --- a/README.md +++ b/README.md @@ -240,6 +240,10 @@ following attributes: - `file`: Optional. The generated filename this source map is associated with. +- `x_google_ignoreList`: Optional. An additional extension field which is an array +of indices refering to urls in the sources array. This is used to identify third-party +sources, that the developer might want to avoid when debugging. + The promise of the constructed souce map consumer is returned. When the `SourceMapConsumer` will no longer be used anymore, you must call its diff --git a/lib/source-map-consumer.js b/lib/source-map-consumer.js index d2cf451d..be1289d9 100644 --- a/lib/source-map-consumer.js +++ b/lib/source-map-consumer.js @@ -187,7 +187,11 @@ class BasicSourceMapConsumer extends SourceMapConsumer { const sourcesContent = util.getArg(sourceMap, "sourcesContent", null); const mappings = util.getArg(sourceMap, "mappings"); const file = util.getArg(sourceMap, "file", null); - const x_google_ignoreList = util.getArg(sourceMap, "x_google_ignoreList", null); + const x_google_ignoreList = util.getArg( + sourceMap, + "x_google_ignoreList", + null + ); // Once again, Sass deviates from the spec and supplies the version as a // string rather than a number, so we use loose equality checking here. diff --git a/test/test-source-map-consumer.js b/test/test-source-map-consumer.js index 33267d4f..1bc09b85 100644 --- a/test/test-source-map-consumer.js +++ b/test/test-source-map-consumer.js @@ -88,15 +88,16 @@ exports["test that the `sources` field has the original sources"] = map.destroy(); }; -exports["test that the SourceMapConsumer supports the ignoreList"] = async function (assert) { +exports["test that the SourceMapConsumer supports the ignoreList"] = + async function (assert) { const map = await new SourceMapConsumer(util.testMapWithIgnoreList); const sources = map.sources; const ignoreList = map.x_google_ignoreList; + assert.equal(ignoreList.length, 1); assert.equal(ignoreList[0], 0); assert.equal(sources[ignoreList[0]], "/the/root/one.js"); - assert.equal(ignoreList.length, 1); map.destroy(); -} + }; exports["test that the source root is reflected in a mapping's source field"] = async function (assert) { From b2ddafebdb7f069fee7e24d76846242fdd840fd5 Mon Sep 17 00:00:00 2001 From: Hubert B Manilla Date: Tue, 4 Apr 2023 13:32:37 +0100 Subject: [PATCH 4/4] Add read more link --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 312177c5..72402e35 100644 --- a/README.md +++ b/README.md @@ -240,9 +240,9 @@ following attributes: - `file`: Optional. The generated filename this source map is associated with. -- `x_google_ignoreList`: Optional. An additional extension field which is an array -of indices refering to urls in the sources array. This is used to identify third-party -sources, that the developer might want to avoid when debugging. +- `x_google_ignoreList`: Optional. An additional extension field which is an array + of indices refering to urls in the sources array. This is used to identify third-party + sources, that the developer might want to avoid when debugging. [Read more](https://developer.chrome.com/articles/x-google-ignore-list/) The promise of the constructed souce map consumer is returned.