From f0313fe998779d9de4955ab43b5be9099c6c804b Mon Sep 17 00:00:00 2001 From: Hubert B Manilla Date: Sat, 1 Apr 2023 00:24:48 +0100 Subject: [PATCH 01/22] 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 02/22] 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 03/22] 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 04/22] 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. From 07a5a3b797f91032d2d79a50fc64d83390438bda Mon Sep 17 00:00:00 2001 From: Denis LE Date: Sat, 20 May 2023 16:26:04 +0200 Subject: [PATCH 05/22] Remove .DS_Store (#485) * Remove .DS_Store * ignore .DS_Store * Remove wasm-mappings/.DS_Store --- .DS_Store | Bin 10244 -> 0 bytes .gitignore | 1 + wasm-mappings/.DS_Store | Bin 6148 -> 0 bytes 3 files changed, 1 insertion(+) delete mode 100644 .DS_Store delete mode 100644 wasm-mappings/.DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index bf67d3d6f84d12e4bccf6ea15fd53d4c63941ed1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 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 diff --git a/.gitignore b/.gitignore index d8e6bd5d..7abedbcf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.iml *.log .idea +.DS_Store node_modules/* build/ bench/*.svg diff --git a/wasm-mappings/.DS_Store b/wasm-mappings/.DS_Store deleted file mode 100644 index b30e622b75370a0dc98b86f2be0d40b16b45b6b6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 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&` From 60adcb064bf033702d954d6d3f9bc3635dcb744b Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Sat, 27 May 2023 12:44:02 +0530 Subject: [PATCH 06/22] Fix reference to LICENSE file (#488) --- source-map.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source-map.js b/source-map.js index 41531fbc..6c73fc02 100644 --- a/source-map.js +++ b/source-map.js @@ -1,6 +1,6 @@ /* * Copyright 2009-2011 Mozilla Foundation and contributors - * Licensed under the New BSD license. See LICENSE.txt or: + * Licensed under the New BSD license. See LICENSE or: * http://opensource.org/licenses/BSD-3-Clause */ exports.SourceMapGenerator = From 79aa958eb9c18f135fad86d85c62d25fdfd36165 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Tue, 7 May 2024 15:05:39 -0700 Subject: [PATCH 07/22] Fix an off-by-1 error in section lookup In an indexed map, the offset line & column are stored 1-based. However, the lookup for originalPositionFor was not incrementing the 0-based column from the API argument. --- lib/source-map-consumer.js | 5 ++++- test/test-source-map-consumer.js | 9 +++++++++ test/util.js | 25 +++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/lib/source-map-consumer.js b/lib/source-map-consumer.js index be1289d9..7381a668 100644 --- a/lib/source-map-consumer.js +++ b/lib/source-map-consumer.js @@ -842,8 +842,11 @@ class IndexedSourceMapConsumer extends SourceMapConsumer { return cmp; } + // The generated column is 0-based, but the section offset column is + // stored 1-based. return ( - aNeedle.generatedColumn - section.generatedOffset.generatedColumn + aNeedle.generatedColumn - + (section.generatedOffset.generatedColumn - 1) ); } ); diff --git a/test/test-source-map-consumer.js b/test/test-source-map-consumer.js index 1bc09b85..dc40ba28 100644 --- a/test/test-source-map-consumer.js +++ b/test/test-source-map-consumer.js @@ -2183,3 +2183,12 @@ exports["test SourceMapConsumer.with and exceptions"] = async function ( assert.equal(error, 6); assert.equal(consumer._mappingsPtr, 0); }; + +exports["test a mapping at the boundary of indexed source map offset"] = + async function (assert) { + const map = await new SourceMapConsumer( + util.indexedTestMapAtOffsetBoundary + ); + util.assertMapping(1, 0, "/the/root/one.js", 1, 0, null, null, map, assert); + map.destroy(); + }; diff --git a/test/util.js b/test/util.js index d99669c3..665e70e2 100644 --- a/test/util.js +++ b/test/util.js @@ -226,6 +226,31 @@ exports.indexedTestMapColumnOffset = { }, ], }; +// This mapping is for testing a case where the mapped position is at the +// section offset. +exports.indexedTestMapAtOffsetBoundary = { + version: 3, + file: "min.js", + sections: [ + { + offset: { + line: 0, + column: 0, + }, + map: { + version: 3, + sources: ["one.js"], + sourcesContent: [ + "ONE.foo = function (bar) {\n return baz(bar);\n };", + ], + names: ["bar", "baz"], + mappings: "AAAA", + file: "min.js", + sourceRoot: "/the/root", + }, + }, + ], +}; exports.testMapWithSourcesContent = { version: 3, file: "min.js", From 6fed3b24181ad9b07a78dc670ca30a775a763f11 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Tue, 16 Apr 2024 18:46:36 -0700 Subject: [PATCH 08/22] Add draft source map spec tests This commit adds a submodule for the draft source map spec test repo and adds a new test file that runs each of the test cases. Some test cases that have known failures are skipped, with a comment explaining why. --- .gitmodules | 3 ++ test/source-map-tests | 1 + test/test-spec-tests.js | 102 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 .gitmodules create mode 160000 test/source-map-tests create mode 100644 test/test-spec-tests.js diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..34cbd89f --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "test/source-map-tests"] + path = test/source-map-tests + url = https://github.com/takikawa/source-map-tests.git diff --git a/test/source-map-tests b/test/source-map-tests new file mode 160000 index 00000000..b2852261 --- /dev/null +++ b/test/source-map-tests @@ -0,0 +1 @@ +Subproject commit b2852261baf54df31ac33e2ccc5c8fe246c9a4bb diff --git a/test/test-spec-tests.js b/test/test-spec-tests.js new file mode 100644 index 00000000..bc169bbf --- /dev/null +++ b/test/test-spec-tests.js @@ -0,0 +1,102 @@ +/* -*- Mode: js; js-indent-level: 2; -*- */ +/* + * Copyright 2024 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ + +const fs = require('node:fs/promises'); +const SourceMapConsumer = + require("../lib/source-map-consumer").SourceMapConsumer; + +const sourceMapSpecTests = require("./source-map-tests/source-map-spec-tests.json"); + +async function readJSON(path) { + const file = await fs.open(require.resolve(path)); + const json = JSON.parse(await file.readFile()); + file.close(); + return json; +} + +// Known failures due to intentional implementation choices or due to bugs. +const skippedTests = [ + // Versions are explicitly checked a bit loosely. + "versionNumericString", + // Stricter sources array checking isn't implemented. + "sourcesNotStringOrNull", + "sourcesAndSourcesContentBothNull", + // Stricter names array checking isn't implemented. + "namesMissing", + "namesNotString", + // This check isn't as strict in this library. + "invalidMappingNotAString1", + // A mapping segment with no fields is technically invalid in the spec. + "invalidMappingSegmentWithZeroFields", + // These tests fail due to imprecision in the spec about the 32-bit limit. + "invalidMappingSegmentWithColumnExceeding32Bits", + "invalidMappingSegmentWithOriginalLineExceeding32Bits", + "invalidMappingSegmentWithOriginalColumnExceeding32Bits", + // A large VLQ that should parse, but currently does not. + "validMappingLargeVLQ", + // The library currently doesn't check the types of offset lines/columns. + "indexMapOffsetLineWrongType", + "indexMapOffsetColumnWrongType", + // The spec is not totally clear about this case. + "indexMapInvalidBaseMappings", + // The spec's definition of overlap can be refined + "indexMapInvalidOverlap", + // Not clear if this test makes sense, but spec isn't clear on behavior + "validMappingNullSources" +] + +async function testMappingAction(assert, rawSourceMap, action) { + return SourceMapConsumer.with(rawSourceMap, null, (consumer) => { + let mappedPosition = consumer.generatedPositionFor({ + source: action.originalSource, + line: action.originalLine + 1, + column: action.originalColumn + }); + + assert.equal(mappedPosition.line, action.generatedLine + 1, `generated line didn't match, expected ${action.generatedLine + 1} got ${mappedPosition.line}`); + assert.equal(mappedPosition.column, action.generatedColumn, `generated column didn't match, expected ${action.generatedColumn} got ${mappedPosition.column}`); + + mappedPosition = consumer.originalPositionFor({ + line: action.generatedLine + 1, + column: action.generatedColumn, + }); + + assert.equal(mappedPosition.line, action.originalLine + 1, `original line didn't match, expected ${action.originalLine + 1} got ${mappedPosition.line}`); + assert.equal(mappedPosition.column, action.originalColumn, `original column didn't match, expected ${action.originalColumn} got ${mappedPosition.column}`); + assert.equal(mappedPosition.source, action.originalSource, `original source didn't match, expected ${action.originalSource} got ${mappedPosition.source}`); + if (action.mappedName) + assert.equal(mappedPosition.name, action.mappedName, `mapped name didn't match, expected ${action.mappedName} got ${mappedPosition.name}`); + }); +} + +for (let testCase of sourceMapSpecTests.tests) { + if (skippedTests.includes(testCase.name)) + continue; + exports[`test from source map spec tests, name: ${testCase.name}`] = + async function (assert) { + const json = await readJSON(`./source-map-tests/resources/${testCase.sourceMapFile}`); + let sourceMapFailed = false; + try { + const map = await new SourceMapConsumer(json); + map.eachMapping(() => {}); + map.destroy(); + } catch (exn) { + if (testCase.sourceMapIsValid) + assert.fail("Expected valid source map but failed to load successfully: " + exn.message); + return; + } + if (!testCase.sourceMapIsValid) + assert.fail("Expected invalid source map but loaded successfully"); + if (testCase.testActions) { + for (let testAction of testCase.testActions) { + if (testAction.actionType == "checkMapping") { + await testMappingAction(assert, json, testAction); + } + } + } + }; +}; From d5cb02ce816470795be4adcd851508562705453c Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Thu, 9 May 2024 11:26:58 -0700 Subject: [PATCH 09/22] Add transitive mapping support in spec test harness --- test/source-map-tests | 2 +- test/test-spec-tests.js | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/test/source-map-tests b/test/source-map-tests index b2852261..ec5a471d 160000 --- a/test/source-map-tests +++ b/test/source-map-tests @@ -1 +1 @@ -Subproject commit b2852261baf54df31ac33e2ccc5c8fe246c9a4bb +Subproject commit ec5a471db6e3a736242e1e3d9a4aebea1472edf5 diff --git a/test/test-spec-tests.js b/test/test-spec-tests.js index bc169bbf..656da32c 100644 --- a/test/test-spec-tests.js +++ b/test/test-spec-tests.js @@ -73,6 +73,31 @@ async function testMappingAction(assert, rawSourceMap, action) { }); } +async function testTransitiveMappingAction(assert, rawSourceMap, action) { + return SourceMapConsumer.with(rawSourceMap, null, async (consumer) => { + assert.ok(Array.isArray(action.intermediateMaps), "transitive mapping case requires intermediate maps"); + + let mappedPosition = consumer.originalPositionFor({ + line: action.generatedLine + 1, + column: action.generatedColumn, + }); + + for (let intermediateMapPath of action.intermediateMaps) { + const intermediateMap = await readJSON(`./source-map-tests/resources/${intermediateMapPath}`); + await SourceMapConsumer.with(intermediateMap, null, (consumer) => { + mappedPosition = consumer.originalPositionFor({ + line: mappedPosition.line, + column: mappedPosition.column, + }); + }); + } + + assert.equal(mappedPosition.line, action.originalLine + 1, `original line didn't match, expected ${action.originalLine + 1} got ${mappedPosition.line}`); + assert.equal(mappedPosition.column, action.originalColumn, `original column didn't match, expected ${action.originalColumn} got ${mappedPosition.column}`); + assert.equal(mappedPosition.source, action.originalSource, `original source didn't match, expected ${action.originalSource} got ${mappedPosition.source}`); + }); +} + for (let testCase of sourceMapSpecTests.tests) { if (skippedTests.includes(testCase.name)) continue; @@ -95,6 +120,8 @@ for (let testCase of sourceMapSpecTests.tests) { for (let testAction of testCase.testActions) { if (testAction.actionType == "checkMapping") { await testMappingAction(assert, json, testAction); + } else if (testAction.actionType == "checkMappingTransitive") { + await testTransitiveMappingAction(assert, json, testAction); } } } From 6396a24aa3dcb37edf57783af50bc8b0eb576a88 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Tue, 21 May 2024 14:59:41 -0700 Subject: [PATCH 10/22] Refine handling of null in the test harness * Don't do reverse lookup test if source is null * Allow "null" in cases where null is expected --- test/test-spec-tests.js | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/test/test-spec-tests.js b/test/test-spec-tests.js index 656da32c..a966c552 100644 --- a/test/test-spec-tests.js +++ b/test/test-spec-tests.js @@ -45,21 +45,19 @@ const skippedTests = [ "indexMapInvalidBaseMappings", // The spec's definition of overlap can be refined "indexMapInvalidOverlap", - // Not clear if this test makes sense, but spec isn't clear on behavior - "validMappingNullSources" ] +// The source-map library converts null sources to the "null" URL in its +// sources list, so for equality checking we accept this as null. +function nullish(nullOrString) { + if (nullOrString === "null") { + return null; + } + return nullOrString; +} + async function testMappingAction(assert, rawSourceMap, action) { return SourceMapConsumer.with(rawSourceMap, null, (consumer) => { - let mappedPosition = consumer.generatedPositionFor({ - source: action.originalSource, - line: action.originalLine + 1, - column: action.originalColumn - }); - - assert.equal(mappedPosition.line, action.generatedLine + 1, `generated line didn't match, expected ${action.generatedLine + 1} got ${mappedPosition.line}`); - assert.equal(mappedPosition.column, action.generatedColumn, `generated column didn't match, expected ${action.generatedColumn} got ${mappedPosition.column}`); - mappedPosition = consumer.originalPositionFor({ line: action.generatedLine + 1, column: action.generatedColumn, @@ -67,9 +65,23 @@ async function testMappingAction(assert, rawSourceMap, action) { assert.equal(mappedPosition.line, action.originalLine + 1, `original line didn't match, expected ${action.originalLine + 1} got ${mappedPosition.line}`); assert.equal(mappedPosition.column, action.originalColumn, `original column didn't match, expected ${action.originalColumn} got ${mappedPosition.column}`); - assert.equal(mappedPosition.source, action.originalSource, `original source didn't match, expected ${action.originalSource} got ${mappedPosition.source}`); + assert.equal(nullish(mappedPosition.source), action.originalSource, `original source didn't match, expected ${action.originalSource} got ${mappedPosition.source}`); if (action.mappedName) assert.equal(mappedPosition.name, action.mappedName, `mapped name didn't match, expected ${action.mappedName} got ${mappedPosition.name}`); + + // When the source is null, a reverse lookup may not make sense + // because there isn't a unique way to look it up. + if (action.originalSource !== null) { + let mappedPosition = consumer.generatedPositionFor({ + source: action.originalSource, + line: action.originalLine + 1, + column: action.originalColumn + }); + + assert.equal(mappedPosition.line, action.generatedLine + 1, `generated line didn't match, expected ${action.generatedLine + 1} got ${mappedPosition.line}`); + assert.equal(mappedPosition.column, action.generatedColumn, `generated column didn't match, expected ${action.generatedColumn} got ${mappedPosition.column}`); + } + }); } From 2dea47e672f30ecda8dcb20cdd02e0345cbb91c1 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Thu, 6 Jun 2024 09:28:48 +0200 Subject: [PATCH 11/22] Update source map tests repo to official one --- .gitmodules | 2 +- test/source-map-tests | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 34cbd89f..163c0757 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "test/source-map-tests"] path = test/source-map-tests - url = https://github.com/takikawa/source-map-tests.git + url = https://github.com/tc39/source-map-tests.git diff --git a/test/source-map-tests b/test/source-map-tests index ec5a471d..14c89744 160000 --- a/test/source-map-tests +++ b/test/source-map-tests @@ -1 +1 @@ -Subproject commit ec5a471db6e3a736242e1e3d9a4aebea1472edf5 +Subproject commit 14c897444208365fc586a9c00c623bfb1955d731 From 3a33cd7037df9f768dec44f525d328820e725074 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Thu, 6 Jun 2024 09:56:18 +0200 Subject: [PATCH 12/22] Update skipped tests for ignoreList tests These aren't supported yet because the library doesn't support ignoreList yet and doesn't do any checking for it. --- test/test-spec-tests.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/test-spec-tests.js b/test/test-spec-tests.js index a966c552..dd1296ba 100644 --- a/test/test-spec-tests.js +++ b/test/test-spec-tests.js @@ -45,6 +45,11 @@ const skippedTests = [ "indexMapInvalidBaseMappings", // The spec's definition of overlap can be refined "indexMapInvalidOverlap", + // The library doesn't support the new ignoreList feature yet. + "ignoreListWrongType1", + "ignoreListWrongType2", + "ignoreListWrongType3", + "ignoreListOutOfBounds", ] // The source-map library converts null sources to the "null" URL in its From 8afce96252a35ed665d436f13372b6c92539c0b9 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Thu, 6 Jun 2024 10:02:50 +0200 Subject: [PATCH 13/22] Address PR feedback --- package.json | 2 +- test/test-spec-tests.js | 23 +++++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 00077059..3301cbdd 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "license": "BSD-3-Clause", "scripts": { "lint": "eslint --fix *.js lib/ test/", - "test": "node test/run-tests.js", + "test": "git submodule update --init --recursive; node test/run-tests.js", "coverage": "c8 --reporter=text --reporter=html npm test", "prettier": "prettier --write .", "clean": "rm -rf coverage", diff --git a/test/test-spec-tests.js b/test/test-spec-tests.js index dd1296ba..12fc2cea 100644 --- a/test/test-spec-tests.js +++ b/test/test-spec-tests.js @@ -61,14 +61,18 @@ function nullish(nullOrString) { return nullOrString; } +function mapLine(line) { + return line + 1; +} + async function testMappingAction(assert, rawSourceMap, action) { return SourceMapConsumer.with(rawSourceMap, null, (consumer) => { mappedPosition = consumer.originalPositionFor({ - line: action.generatedLine + 1, + line: mapLine(action.generatedLine), column: action.generatedColumn, }); - assert.equal(mappedPosition.line, action.originalLine + 1, `original line didn't match, expected ${action.originalLine + 1} got ${mappedPosition.line}`); + assert.equal(mappedPosition.line, mapLine(action.originalLine), `original line didn't match, expected ${mapLine(action.originalLine)} got ${mappedPosition.line}`); assert.equal(mappedPosition.column, action.originalColumn, `original column didn't match, expected ${action.originalColumn} got ${mappedPosition.column}`); assert.equal(nullish(mappedPosition.source), action.originalSource, `original source didn't match, expected ${action.originalSource} got ${mappedPosition.source}`); if (action.mappedName) @@ -79,11 +83,11 @@ async function testMappingAction(assert, rawSourceMap, action) { if (action.originalSource !== null) { let mappedPosition = consumer.generatedPositionFor({ source: action.originalSource, - line: action.originalLine + 1, + line: mapLine(action.originalLine), column: action.originalColumn }); - assert.equal(mappedPosition.line, action.generatedLine + 1, `generated line didn't match, expected ${action.generatedLine + 1} got ${mappedPosition.line}`); + assert.equal(mappedPosition.line, mapLine(action.generatedLine), `generated line didn't match, expected ${mapLine(action.generatedLine)} got ${mappedPosition.line}`); assert.equal(mappedPosition.column, action.generatedColumn, `generated column didn't match, expected ${action.generatedColumn} got ${mappedPosition.column}`); } @@ -95,11 +99,11 @@ async function testTransitiveMappingAction(assert, rawSourceMap, action) { assert.ok(Array.isArray(action.intermediateMaps), "transitive mapping case requires intermediate maps"); let mappedPosition = consumer.originalPositionFor({ - line: action.generatedLine + 1, + line: mapLine(action.generatedLine), column: action.generatedColumn, }); - for (let intermediateMapPath of action.intermediateMaps) { + for (const intermediateMapPath of action.intermediateMaps) { const intermediateMap = await readJSON(`./source-map-tests/resources/${intermediateMapPath}`); await SourceMapConsumer.with(intermediateMap, null, (consumer) => { mappedPosition = consumer.originalPositionFor({ @@ -109,19 +113,18 @@ async function testTransitiveMappingAction(assert, rawSourceMap, action) { }); } - assert.equal(mappedPosition.line, action.originalLine + 1, `original line didn't match, expected ${action.originalLine + 1} got ${mappedPosition.line}`); + assert.equal(mappedPosition.line, mapLine(action.originalLine), `original line didn't match, expected ${mapLine(action.originalLine)} got ${mappedPosition.line}`); assert.equal(mappedPosition.column, action.originalColumn, `original column didn't match, expected ${action.originalColumn} got ${mappedPosition.column}`); assert.equal(mappedPosition.source, action.originalSource, `original source didn't match, expected ${action.originalSource} got ${mappedPosition.source}`); }); } -for (let testCase of sourceMapSpecTests.tests) { +for (const testCase of sourceMapSpecTests.tests) { if (skippedTests.includes(testCase.name)) continue; exports[`test from source map spec tests, name: ${testCase.name}`] = async function (assert) { const json = await readJSON(`./source-map-tests/resources/${testCase.sourceMapFile}`); - let sourceMapFailed = false; try { const map = await new SourceMapConsumer(json); map.eachMapping(() => {}); @@ -134,7 +137,7 @@ for (let testCase of sourceMapSpecTests.tests) { if (!testCase.sourceMapIsValid) assert.fail("Expected invalid source map but loaded successfully"); if (testCase.testActions) { - for (let testAction of testCase.testActions) { + for (const testAction of testCase.testActions) { if (testAction.actionType == "checkMapping") { await testMappingAction(assert, json, testAction); } else if (testAction.actionType == "checkMappingTransitive") { From 64050e6a6345b171a35f81833367ba486ca13338 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Thu, 6 Jun 2024 10:09:55 +0200 Subject: [PATCH 14/22] Updates to satisfy linter Also makes the linter ignore the submodule --- package.json | 2 +- test/test-spec-tests.js | 123 +++++++++++++++++++++++++++++----------- 2 files changed, 92 insertions(+), 33 deletions(-) diff --git a/package.json b/package.json index 3301cbdd..ae0e6552 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ }, "license": "BSD-3-Clause", "scripts": { - "lint": "eslint --fix *.js lib/ test/", + "lint": "eslint --fix *.js lib/ test/ --ignore-pattern 'test/source-map-tests/**'", "test": "git submodule update --init --recursive; node test/run-tests.js", "coverage": "c8 --reporter=text --reporter=html npm test", "prettier": "prettier --write .", diff --git a/test/test-spec-tests.js b/test/test-spec-tests.js index 12fc2cea..fbe29117 100644 --- a/test/test-spec-tests.js +++ b/test/test-spec-tests.js @@ -5,7 +5,7 @@ * http://opensource.org/licenses/BSD-3-Clause */ -const fs = require('node:fs/promises'); +const fs = require("node:fs/promises"); const SourceMapConsumer = require("../lib/source-map-consumer").SourceMapConsumer; @@ -50,7 +50,7 @@ const skippedTests = [ "ignoreListWrongType2", "ignoreListWrongType3", "ignoreListOutOfBounds", -] +]; // The source-map library converts null sources to the "null" URL in its // sources list, so for equality checking we accept this as null. @@ -66,37 +66,68 @@ function mapLine(line) { } async function testMappingAction(assert, rawSourceMap, action) { - return SourceMapConsumer.with(rawSourceMap, null, (consumer) => { - mappedPosition = consumer.originalPositionFor({ + return SourceMapConsumer.with(rawSourceMap, null, consumer => { + let mappedPosition = consumer.originalPositionFor({ line: mapLine(action.generatedLine), column: action.generatedColumn, }); - assert.equal(mappedPosition.line, mapLine(action.originalLine), `original line didn't match, expected ${mapLine(action.originalLine)} got ${mappedPosition.line}`); - assert.equal(mappedPosition.column, action.originalColumn, `original column didn't match, expected ${action.originalColumn} got ${mappedPosition.column}`); - assert.equal(nullish(mappedPosition.source), action.originalSource, `original source didn't match, expected ${action.originalSource} got ${mappedPosition.source}`); - if (action.mappedName) - assert.equal(mappedPosition.name, action.mappedName, `mapped name didn't match, expected ${action.mappedName} got ${mappedPosition.name}`); + assert.equal( + mappedPosition.line, + mapLine(action.originalLine), + `original line didn't match, expected ${mapLine( + action.originalLine + )} got ${mappedPosition.line}` + ); + assert.equal( + mappedPosition.column, + action.originalColumn, + `original column didn't match, expected ${action.originalColumn} got ${mappedPosition.column}` + ); + assert.equal( + nullish(mappedPosition.source), + action.originalSource, + `original source didn't match, expected ${action.originalSource} got ${mappedPosition.source}` + ); + if (action.mappedName) { + assert.equal( + mappedPosition.name, + action.mappedName, + `mapped name didn't match, expected ${action.mappedName} got ${mappedPosition.name}` + ); + } // When the source is null, a reverse lookup may not make sense // because there isn't a unique way to look it up. if (action.originalSource !== null) { - let mappedPosition = consumer.generatedPositionFor({ + mappedPosition = consumer.generatedPositionFor({ source: action.originalSource, line: mapLine(action.originalLine), - column: action.originalColumn + column: action.originalColumn, }); - assert.equal(mappedPosition.line, mapLine(action.generatedLine), `generated line didn't match, expected ${mapLine(action.generatedLine)} got ${mappedPosition.line}`); - assert.equal(mappedPosition.column, action.generatedColumn, `generated column didn't match, expected ${action.generatedColumn} got ${mappedPosition.column}`); + assert.equal( + mappedPosition.line, + mapLine(action.generatedLine), + `generated line didn't match, expected ${mapLine( + action.generatedLine + )} got ${mappedPosition.line}` + ); + assert.equal( + mappedPosition.column, + action.generatedColumn, + `generated column didn't match, expected ${action.generatedColumn} got ${mappedPosition.column}` + ); } - }); } async function testTransitiveMappingAction(assert, rawSourceMap, action) { - return SourceMapConsumer.with(rawSourceMap, null, async (consumer) => { - assert.ok(Array.isArray(action.intermediateMaps), "transitive mapping case requires intermediate maps"); + return SourceMapConsumer.with(rawSourceMap, null, async consumer => { + assert.ok( + Array.isArray(action.intermediateMaps), + "transitive mapping case requires intermediate maps" + ); let mappedPosition = consumer.originalPositionFor({ line: mapLine(action.generatedLine), @@ -104,38 +135,66 @@ async function testTransitiveMappingAction(assert, rawSourceMap, action) { }); for (const intermediateMapPath of action.intermediateMaps) { - const intermediateMap = await readJSON(`./source-map-tests/resources/${intermediateMapPath}`); - await SourceMapConsumer.with(intermediateMap, null, (consumer) => { - mappedPosition = consumer.originalPositionFor({ - line: mappedPosition.line, - column: mappedPosition.column, - }); - }); + const intermediateMap = await readJSON( + `./source-map-tests/resources/${intermediateMapPath}` + ); + await SourceMapConsumer.with( + intermediateMap, + null, + consumerIntermediate => { + mappedPosition = consumerIntermediate.originalPositionFor({ + line: mappedPosition.line, + column: mappedPosition.column, + }); + } + ); } - assert.equal(mappedPosition.line, mapLine(action.originalLine), `original line didn't match, expected ${mapLine(action.originalLine)} got ${mappedPosition.line}`); - assert.equal(mappedPosition.column, action.originalColumn, `original column didn't match, expected ${action.originalColumn} got ${mappedPosition.column}`); - assert.equal(mappedPosition.source, action.originalSource, `original source didn't match, expected ${action.originalSource} got ${mappedPosition.source}`); + assert.equal( + mappedPosition.line, + mapLine(action.originalLine), + `original line didn't match, expected ${mapLine( + action.originalLine + )} got ${mappedPosition.line}` + ); + assert.equal( + mappedPosition.column, + action.originalColumn, + `original column didn't match, expected ${action.originalColumn} got ${mappedPosition.column}` + ); + assert.equal( + mappedPosition.source, + action.originalSource, + `original source didn't match, expected ${action.originalSource} got ${mappedPosition.source}` + ); }); } for (const testCase of sourceMapSpecTests.tests) { - if (skippedTests.includes(testCase.name)) + if (skippedTests.includes(testCase.name)) { continue; + } exports[`test from source map spec tests, name: ${testCase.name}`] = async function (assert) { - const json = await readJSON(`./source-map-tests/resources/${testCase.sourceMapFile}`); + const json = await readJSON( + `./source-map-tests/resources/${testCase.sourceMapFile}` + ); try { const map = await new SourceMapConsumer(json); map.eachMapping(() => {}); map.destroy(); } catch (exn) { - if (testCase.sourceMapIsValid) - assert.fail("Expected valid source map but failed to load successfully: " + exn.message); + if (testCase.sourceMapIsValid) { + assert.fail( + "Expected valid source map but failed to load successfully: " + + exn.message + ); + } return; } - if (!testCase.sourceMapIsValid) + if (!testCase.sourceMapIsValid) { assert.fail("Expected invalid source map but loaded successfully"); + } if (testCase.testActions) { for (const testAction of testCase.testActions) { if (testAction.actionType == "checkMapping") { @@ -146,4 +205,4 @@ for (const testCase of sourceMapSpecTests.tests) { } } }; -}; +} From d243a04ce31850f3f726332b790448b824df1a8c Mon Sep 17 00:00:00 2001 From: Hubert Boma Manilla Date: Sun, 9 Jun 2024 15:34:55 +0100 Subject: [PATCH 15/22] Update test/test-spec-tests.js Fix the require of the fs promises module --- test/test-spec-tests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-spec-tests.js b/test/test-spec-tests.js index fbe29117..8f113160 100644 --- a/test/test-spec-tests.js +++ b/test/test-spec-tests.js @@ -5,7 +5,7 @@ * http://opensource.org/licenses/BSD-3-Clause */ -const fs = require("node:fs/promises"); +const fs = require("fs").promises; const SourceMapConsumer = require("../lib/source-map-consumer").SourceMapConsumer; From 66d3424eeaea8933856e60e16d4889023fc6ac48 Mon Sep 17 00:00:00 2001 From: Nicolas Chevobbe Date: Tue, 8 Jul 2025 12:13:37 +0200 Subject: [PATCH 16/22] Remove whatwg-url module The native URL constructor does handle custom schemes just fine now, we don't need to have this module anymore. Fixes #400. --- lib/url-browser.js | 21 ---------------- package-lock.json | 63 +++------------------------------------------- package.json | 2 -- 3 files changed, 3 insertions(+), 83 deletions(-) delete mode 100644 lib/url-browser.js diff --git a/lib/url-browser.js b/lib/url-browser.js deleted file mode 100644 index c9da02a8..00000000 --- a/lib/url-browser.js +++ /dev/null @@ -1,21 +0,0 @@ -/* -*- Mode: js; js-indent-level: 2; -*- */ -/* - * Copyright 2011 Mozilla Foundation and contributors - * Licensed under the New BSD license. See LICENSE or: - * http://opensource.org/licenses/BSD-3-Clause - */ -"use strict"; - -/** - * Browser 'URL' implementations have been found to handle non-standard URL - * schemes poorly, and schemes like - * - * webpack:///src/folder/file.js - * - * are very common in source maps. For the time being we use a JS - * implementation in these contexts instead. See - * - * * https://bugzilla.mozilla.org/show_bug.cgi?id=1374505 - * * https://bugs.chromium.org/p/chromium/issues/detail?id=734880 - */ -module.exports = require("whatwg-url").URL; diff --git a/package-lock.json b/package-lock.json index cab5273b..6dd43d16 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,9 +8,6 @@ "name": "source-map", "version": "0.8.0-beta.0", "license": "BSD-3-Clause", - "dependencies": { - "whatwg-url": "^7.0.0" - }, "devDependencies": { "c8": "^7.12.0", "doctoc": "^2.2.1", @@ -1264,11 +1261,6 @@ "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", "dev": true }, - "node_modules/lodash.sortby": { - "version": "4.7.0", - "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", - "integrity": "sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==" - }, "node_modules/longest-streak": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/longest-streak/-/longest-streak-2.0.4.tgz", @@ -1766,6 +1758,7 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "dev": true, "engines": { "node": ">=6" } @@ -2044,14 +2037,6 @@ "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "dev": true }, - "node_modules/tr46": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-1.0.1.tgz", - "integrity": "sha512-dTpowEjclQ7Kgx5SdBkqRzVhERQXov8/l9Ft9dVM9fmg0W0KQSVaXX9T4i6twCPNtYiZM53lpSSUAwJbFPOHxA==", - "dependencies": { - "punycode": "^2.1.0" - } - }, "node_modules/traverse": { "version": "0.6.7", "resolved": "https://registry.npmjs.org/traverse/-/traverse-0.6.7.tgz", @@ -2215,21 +2200,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/webidl-conversions": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz", - "integrity": "sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==" - }, - "node_modules/whatwg-url": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-7.1.0.tgz", - "integrity": "sha512-WUu7Rg1DroM7oQvGWfOiAK21n74Gg+T4elXEQYkOhtyLeWiJFoOGLXPKI/9gzIie9CtwVLm8wtw6YJdKyxSjeg==", - "dependencies": { - "lodash.sortby": "^4.7.0", - "tr46": "^1.0.1", - "webidl-conversions": "^4.0.2" - } - }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -3259,11 +3229,6 @@ "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", "dev": true }, - "lodash.sortby": { - "version": "4.7.0", - "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", - "integrity": "sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==" - }, "longest-streak": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/longest-streak/-/longest-streak-2.0.4.tgz", @@ -3611,7 +3576,8 @@ "punycode": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "dev": true }, "queue-microtask": { "version": "1.2.3", @@ -3793,14 +3759,6 @@ "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "dev": true }, - "tr46": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-1.0.1.tgz", - "integrity": "sha512-dTpowEjclQ7Kgx5SdBkqRzVhERQXov8/l9Ft9dVM9fmg0W0KQSVaXX9T4i6twCPNtYiZM53lpSSUAwJbFPOHxA==", - "requires": { - "punycode": "^2.1.0" - } - }, "traverse": { "version": "0.6.7", "resolved": "https://registry.npmjs.org/traverse/-/traverse-0.6.7.tgz", @@ -3921,21 +3879,6 @@ "unist-util-stringify-position": "^2.0.0" } }, - "webidl-conversions": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz", - "integrity": "sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==" - }, - "whatwg-url": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-7.1.0.tgz", - "integrity": "sha512-WUu7Rg1DroM7oQvGWfOiAK21n74Gg+T4elXEQYkOhtyLeWiJFoOGLXPKI/9gzIie9CtwVLm8wtw6YJdKyxSjeg==", - "requires": { - "lodash.sortby": "^4.7.0", - "tr46": "^1.0.1", - "webidl-conversions": "^4.0.2" - } - }, "which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", diff --git a/package.json b/package.json index ae0e6552..3cb93281 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,6 @@ "main": "./source-map.js", "types": "./source-map.d.ts", "browser": { - "./lib/url.js": "./lib/url-browser.js", "./lib/read-wasm.js": "./lib/read-wasm-browser.js" }, "files": [ @@ -80,6 +79,5 @@ "prettier": "^2.7.1" }, "dependencies": { - "whatwg-url": "^7.0.0" } } From e034115354f1f83b76d594eb7755f7e5fcea7bd1 Mon Sep 17 00:00:00 2001 From: Nicolas Chevobbe Date: Tue, 8 Jul 2025 12:33:11 +0200 Subject: [PATCH 17/22] run prettier --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 3cb93281..874eb305 100644 --- a/package.json +++ b/package.json @@ -78,6 +78,5 @@ "eslint-config-prettier": "^8.5.0", "prettier": "^2.7.1" }, - "dependencies": { - } + "dependencies": {} } From f459a64a938d07c8b0bd6dc11dd81cb98d2db51d Mon Sep 17 00:00:00 2001 From: Nicolas Chevobbe Date: Thu, 24 Jul 2025 06:46:20 +0200 Subject: [PATCH 18/22] Bump package version to 0.7.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 874eb305..ed034578 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "source-map", "description": "Generates and consumes source maps", - "version": "0.8.0-beta.0", + "version": "0.7.5", "homepage": "https://github.com/mozilla/source-map", "author": "Nick Fitzgerald ", "contributors": [ From 801be934007c3ed0ef66c620641b1668e92c891d Mon Sep 17 00:00:00 2001 From: Nicolas Chevobbe Date: Thu, 24 Jul 2025 07:10:25 +0200 Subject: [PATCH 19/22] Bump package to 0.7.6 and remove publishConfig --- package.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/package.json b/package.json index ed034578..06d4f1a3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "source-map", "description": "Generates and consumes source maps", - "version": "0.7.5", + "version": "0.7.6", "homepage": "https://github.com/mozilla/source-map", "author": "Nick Fitzgerald ", "contributors": [ @@ -56,9 +56,6 @@ "source-map.d.ts", "lib/" ], - "publishConfig": { - "tag": "next" - }, "engines": { "node": ">= 12" }, From f9aa3710c5249dbca5b2eaf928462ba53599c545 Mon Sep 17 00:00:00 2001 From: Nicolas Chevobbe Date: Wed, 30 Jul 2025 16:01:09 +0200 Subject: [PATCH 20/22] Update CHANGELOG.md Add information for 0.7.4 , 0.7.5 and 0.7.6 --- CHANGELOG.md | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35f97a9e..56b01dc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,96 @@ # Change Log -## 0.8.0-beta.0 +## 0.7.6 + +- Bump package to 0.7.6 and remove `publishConfig` property in package.json ([801be934007c3ed0ef66c620641b1668e92c891d](https://github.com/mozilla/source-map/commit/801be934007c3ed0ef66c620641b1668e92c891d)) + +## 0.7.5 + +- [#364](https://github.com/mozilla/source-map/pull/364) - + Pass through the implementation of more index map operations. +- [#362](https://github.com/mozilla/source-map/pull/362) - + Remove the bundled dist/ directory? +- [#363](https://github.com/mozilla/source-map/pull/363) - + Split up wasm loading based on compilation target. +- [#371](https://github.com/mozilla/source-map/pull/371) - + Use WHATWG's URL to implement all of source-map's URL operations. +- [#378](https://github.com/mozilla/source-map/pull/378) - + Fix typo +- [#384](https://github.com/mozilla/source-map/pull/384) - + Add Mozilla Code of Conduct in +- [#402](https://github.com/mozilla/source-map/pull/402) - + Remove unused fromVLQSigned function +- [#374](https://github.com/mozilla/source-map/pull/374) - + Add lastGeneratedColumn to typing for MappingItem +- [#395](https://github.com/mozilla/source-map/pull/395) - + `addMapping()`: ensure that `originalLine` and `originalColumn` are `null` when `original` argument was undefined/`null` +- [#394](https://github.com/mozilla/source-map/pull/394) - + fix crash in url util function due to undefined root value +- [#393](https://github.com/mozilla/source-map/pull/393) - + minor binary-search code/comment fixes +- [#407](https://github.com/mozilla/source-map/pull/407) - + use Travis CI svg badge +- [#397](https://github.com/mozilla/source-map/pull/397) - + add `prettier` task for standardized code formatting => easier cross-branch/fork code comparison and merging +- [#415](https://github.com/mozilla/source-map/pull/415) - + Syntax highlight README HTML sample +- [#439](https://github.com/mozilla/source-map/pull/439) - + Add function to SourceMapConsumer TS interface +- [#448](https://github.com/mozilla/source-map/pull/448) - + Include types file extension in package.json +- [#464](https://github.com/mozilla/source-map/pull/464) - + Require Node.js 12 or later & switch CI to GitHub Actions +- [#466](https://github.com/mozilla/source-map/pull/466) - + Skip updating coveralls.io coverage +- [#465](https://github.com/mozilla/source-map/pull/465) - + Update WASM binary and Land WASM rust sources in this repository +- [#463](https://github.com/mozilla/source-map/pull/463) - + Update ESLint & Prettier to latest +- [#467](https://github.com/mozilla/source-map/pull/467) - + Adopt & enforce the mozilla-central Prettier config +- [#468](https://github.com/mozilla/source-map/pull/468) - + Simplify coverage tooling +- [#469](https://github.com/mozilla/source-map/pull/469) - + Update to doctoc v2 & simplify call pattern +- [#470](https://github.com/mozilla/source-map/pull/470) - + Filter out unnecessary rust tasks +- [#471](https://github.com/mozilla/source-map/pull/471) - + Improve coverage +- [#472](https://github.com/mozilla/source-map/pull/472) - + Include package-lock.json in repo +- [#473](https://github.com/mozilla/source-map/pull/473) - + fix: convert result of allocate_mappings from signed to unsigned +- [#481](https://github.com/mozilla/source-map/pull/481) - + Add support for the sourcemaps ignorelist +- [#485](https://github.com/mozilla/source-map/pull/485) - + Remove .DS_Store +- [#488](https://github.com/mozilla/source-map/pull/488) - + Fix reference to LICENSE file +- [#507](https://github.com/mozilla/source-map/pull/507) - + Fix an off-by-1 error in section lookup +- [#505](https://github.com/mozilla/source-map/pull/505) - + Add source map spec tests +- [#517](https://github.com/mozilla/source-map/pull/517) - + Remove whatwg-url module + +## 0.7.4 + +- [#341](https://github.com/mozilla/source-map/pull/341) - + Make async change. Fixes mozilla#337. +- [#339](https://github.com/mozilla/source-map/pull/339) - + Add option to initialize mappings wasm via ArrayBuffer +- [#347](https://github.com/mozilla/source-map/pull/347) - + Add expected arguments to assert.throws calls +- [#352](https://github.com/mozilla/source-map/pull/352) - + Update node version +- [#350](https://github.com/mozilla/source-map/pull/350) - + Use top level context to determine node vs browser environment +- [#361](https://github.com/mozilla/source-map/pull/361) - + Bump webpack-cli to v3.1 +- [#456](https://github.com/mozilla/source-map/pull/456) - + Regenerate dist due to running `npm test` + +## [DEPRECATED] 0.8.0-beta.0 ### Breaking changes From 0ccf5ec83ea5597441e42ce468814a0c7b723213 Mon Sep 17 00:00:00 2001 From: Nicolas Chevobbe Date: Wed, 30 Jul 2025 16:27:54 +0200 Subject: [PATCH 21/22] prettier --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56b01dc7..4ea0eafa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ - [#378](https://github.com/mozilla/source-map/pull/378) - Fix typo - [#384](https://github.com/mozilla/source-map/pull/384) - - Add Mozilla Code of Conduct in + Add Mozilla Code of Conduct in - [#402](https://github.com/mozilla/source-map/pull/402) - Remove unused fromVLQSigned function - [#374](https://github.com/mozilla/source-map/pull/374) - From 25ff939d4ecad96c2a56a6145d1a56ebba389f1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Nison?= Date: Wed, 13 Aug 2025 21:40:17 +0100 Subject: [PATCH 22/22] Update source-map.d.ts --- source-map.d.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/source-map.d.ts b/source-map.d.ts index 8bd5b6a1..45646052 100644 --- a/source-map.d.ts +++ b/source-map.d.ts @@ -84,18 +84,6 @@ export interface SourceMappings { } export interface SourceMapConsumer { - /** - * When using SourceMapConsumer outside of node.js, for example on the Web, it - * needs to know from what URL to load lib/mappings.wasm. You must inform it - * by calling initialize before constructing any SourceMapConsumers. - * - * @param mappings an object with the following property: - * - "lib/mappings.wasm": A String containing the URL of the - * lib/mappings.wasm file, or an ArrayBuffer with the contents of - * lib/mappings.wasm. - */ - initialize(mappings: SourceMappings): void; - /** * Compute the last column for each generated mapping. The last column is * inclusive. @@ -237,6 +225,18 @@ export interface SourceMapConsumerConstructor { sourceMapUrl?: SourceMapUrl ): Promise; + /** + * When using SourceMapConsumer outside of node.js, for example on the Web, it + * needs to know from what URL to load lib/mappings.wasm. You must inform it + * by calling initialize before constructing any SourceMapConsumers. + * + * @param mappings an object with the following property: + * - "lib/mappings.wasm": A String containing the URL of the + * lib/mappings.wasm file, or an ArrayBuffer with the contents of + * lib/mappings.wasm. + */ + initialize(mappings: SourceMappings): void; + /** * Create a BasicSourceMapConsumer from a SourceMapGenerator. *