diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2023-11-05 17:23:37 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2023-11-05 17:23:37 +0800 |
| commit | 2cdf0cb352ab6a2d0f8cb25120e4ebc92c5316e3 (patch) | |
| tree | 6b088c99810bd013f17b80522c936ca6dfc09858 /node_modules/source-map/README.md | |
| parent | f8ee6ef722e6c560c4a1c879e04dbdf0b01f0316 (diff) | |
removed autoprefix hover as it will have a high chance of making hover stopped working
Diffstat (limited to 'node_modules/source-map/README.md')
| -rw-r--r-- | node_modules/source-map/README.md | 185 |
1 files changed, 46 insertions, 139 deletions
diff --git a/node_modules/source-map/README.md b/node_modules/source-map/README.md index 56e5ac3e..32813394 100644 --- a/node_modules/source-map/README.md +++ b/node_modules/source-map/README.md @@ -2,8 +2,6 @@ [](https://travis-ci.org/mozilla/source-map) -[](https://coveralls.io/github/mozilla/source-map) - [](https://www.npmjs.com/package/source-map) This is a library to generate and consume the source map format @@ -17,12 +15,7 @@ This is a library to generate and consume the source map format ## Use on the Web - <script src="https://unpkg.com/source-map@0.7.3/dist/source-map.js"></script> - <script> - sourceMap.SourceMapConsumer.initialize({ - "lib/mappings.wasm": "https://unpkg.com/source-map@0.7.3/lib/mappings.wasm" - }); - </script> + <script src="https://raw.githubusercontent.com/mozilla/source-map/master/dist/source-map.min.js" defer></script> -------------------------------------------------------------------------------- @@ -39,10 +32,7 @@ This is a library to generate and consume the source map format - [With SourceMapGenerator (low level API)](#with-sourcemapgenerator-low-level-api) - [API](#api) - [SourceMapConsumer](#sourcemapconsumer) - - [SourceMapConsumer.initialize(options)](#sourcemapconsumerinitializeoptions) - [new SourceMapConsumer(rawSourceMap)](#new-sourcemapconsumerrawsourcemap) - - [SourceMapConsumer.with](#sourcemapconsumerwith) - - [SourceMapConsumer.prototype.destroy()](#sourcemapconsumerprototypedestroy) - [SourceMapConsumer.prototype.computeColumnSpans()](#sourcemapconsumerprototypecomputecolumnspans) - [SourceMapConsumer.prototype.originalPositionFor(generatedPosition)](#sourcemapconsumerprototypeoriginalpositionforgeneratedposition) - [SourceMapConsumer.prototype.generatedPositionFor(originalPosition)](#sourcemapconsumerprototypegeneratedpositionfororiginalposition) @@ -77,7 +67,7 @@ This is a library to generate and consume the source map format ### Consuming a source map ```js -const rawSourceMap = { +var rawSourceMap = { version: 3, file: 'min.js', names: ['bar', 'baz', 'n'], @@ -86,33 +76,30 @@ const rawSourceMap = { mappings: 'CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA' }; -const whatever = await SourceMapConsumer.with(rawSourceMap, null, consumer => { - - console.log(consumer.sources); - // [ 'http://example.com/www/js/one.js', - // 'http://example.com/www/js/two.js' ] - - console.log(consumer.originalPositionFor({ - line: 2, - column: 28 - })); - // { source: 'http://example.com/www/js/two.js', - // line: 2, - // column: 10, - // name: 'n' } - - console.log(consumer.generatedPositionFor({ - source: 'http://example.com/www/js/two.js', - line: 2, - column: 10 - })); - // { line: 2, column: 28 } - - consumer.eachMapping(function (m) { - // ... - }); - - return computeWhatever(); +var smc = new SourceMapConsumer(rawSourceMap); + +console.log(smc.sources); +// [ 'http://example.com/www/js/one.js', +// 'http://example.com/www/js/two.js' ] + +console.log(smc.originalPositionFor({ + line: 2, + column: 28 +})); +// { source: 'http://example.com/www/js/two.js', +// line: 2, +// column: 10, +// name: 'n' } + +console.log(smc.generatedPositionFor({ + source: 'http://example.com/www/js/two.js', + line: 2, + column: 10 +})); +// { line: 2, column: 28 } + +smc.eachMapping(function (m) { + // ... }); ``` @@ -195,27 +182,10 @@ const sourceMap = require("devtools/toolkit/sourcemap/source-map.js"); ### SourceMapConsumer -A `SourceMapConsumer` instance represents a parsed source map which we can query +A SourceMapConsumer instance represents a parsed source map which we can query for information about the original file positions by giving it a file position in the generated source. -#### SourceMapConsumer.initialize(options) - -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 `SourceMapConsumer`s. - -The options object has the following properties: - -* `"lib/mappings.wasm"`: A `String` containing the URL of the - `lib/mappings.wasm` file, or an `ArrayBuffer` with the contents of `lib/mappings.wasm`. - -```js -sourceMap.SourceMapConsumer.initialize({ - "lib/mappings.wasm": "https://example.com/source-map/lib/mappings.wasm" -}); -``` - #### new SourceMapConsumer(rawSourceMap) The only parameter is the raw source map (either as a string which can be @@ -237,62 +207,10 @@ following attributes: * `file`: Optional. The generated filename this source map is associated with. -The promise of the constructed souce map consumer is returned. - -When the `SourceMapConsumer` will no longer be used anymore, you must call its -`destroy` method. - -```js -const consumer = await new sourceMap.SourceMapConsumer(rawSourceMapJsonData); -doStuffWith(consumer); -consumer.destroy(); -``` - -Alternatively, you can use `SourceMapConsumer.with` to avoid needing to remember -to call `destroy`. - -#### SourceMapConsumer.with - -Construct a new `SourceMapConsumer` from `rawSourceMap` and `sourceMapUrl` -(see the `SourceMapConsumer` constructor for details. Then, invoke the `async -function f(SourceMapConsumer) -> T` with the newly constructed consumer, wait -for `f` to complete, call `destroy` on the consumer, and return `f`'s return -value. - -You must not use the consumer after `f` completes! - -By using `with`, you do not have to remember to manually call `destroy` on -the consumer, since it will be called automatically once `f` completes. - ```js -const xSquared = await SourceMapConsumer.with( - myRawSourceMap, - null, - async function (consumer) { - // Use `consumer` inside here and don't worry about remembering - // to call `destroy`. - - const x = await whatever(consumer); - return x * x; - } -); - -// You may not use that `consumer` anymore out here; it has -// been destroyed. But you can use `xSquared`. -console.log(xSquared); +var consumer = new sourceMap.SourceMapConsumer(rawSourceMapJsonData); ``` -#### SourceMapConsumer.prototype.destroy() - -Free this source map consumer's associated wasm data that is manually-managed. - -```js -consumer.destroy(); -``` - -Alternatively, you can use `SourceMapConsumer.with` to avoid needing to remember -to call `destroy`. - #### SourceMapConsumer.prototype.computeColumnSpans() Compute the last column for each generated mapping. The last column is @@ -321,6 +239,7 @@ consumer.allGeneratedPositionsFor({ line: 2, source: "foo.coffee" }) // { line: 2, // column: 20, // lastColumn: Infinity } ] + ``` #### SourceMapConsumer.prototype.originalPositionFor(generatedPosition) @@ -329,13 +248,9 @@ Returns the original source, line, and column information for the generated source's line and column positions provided. The only argument is an object with the following properties: -* `line`: The line number in the generated source. Line numbers in - this library are 1-based (note that the underlying source map - specification uses 0-based line numbers -- this library handles the - translation). +* `line`: The line number in the generated source. -* `column`: The column number in the generated source. Column numbers - in this library are 0-based. +* `column`: The column number in the generated source. * `bias`: Either `SourceMapConsumer.GREATEST_LOWER_BOUND` or `SourceMapConsumer.LEAST_UPPER_BOUND`. Specifies whether to return the closest @@ -349,10 +264,10 @@ and an object is returned with the following properties: available. * `line`: The line number in the original source, or null if this information is - not available. The line number is 1-based. + not available. * `column`: The column number in the original source, or null if this - information is not available. The column number is 0-based. + information is not available. * `name`: The original identifier, or null if this information is not available. @@ -378,19 +293,15 @@ the following properties: * `source`: The filename of the original source. -* `line`: The line number in the original source. The line number is - 1-based. +* `line`: The line number in the original source. -* `column`: The column number in the original source. The column - number is 0-based. +* `column`: The column number in the original source. and an object is returned with the following properties: -* `line`: The line number in the generated source, or null. The line - number is 1-based. +* `line`: The line number in the generated source, or null. -* `column`: The column number in the generated source, or null. The - column number is 0-based. +* `column`: The column number in the generated source, or null. ```js consumer.generatedPositionFor({ source: "example.js", line: 2, column: 10 }) @@ -411,19 +322,15 @@ The only argument is an object with the following properties: * `source`: The filename of the original source. -* `line`: The line number in the original source. The line number is - 1-based. +* `line`: The line number in the original source. -* `column`: Optional. The column number in the original source. The - column number is 0-based. +* `column`: Optional. The column number in the original source. and an array of objects is returned, each with the following properties: -* `line`: The line number in the generated source, or null. The line - number is 1-based. +* `line`: The line number in the generated source, or null. -* `column`: The column number in the generated source, or null. The - column number is 0-based. +* `column`: The column number in the generated source, or null. ```js consumer.allGeneratedpositionsfor({ line: 2, source: "foo.coffee" }) @@ -627,11 +534,10 @@ use before outputting the generated JS and source map. #### new SourceNode([line, column, source[, chunk[, name]]]) * `line`: The original line number associated with this source node, or null if - it isn't associated with an original line. The line number is 1-based. + it isn't associated with an original line. * `column`: The original column number associated with this source node, or null - if it isn't associated with an original column. The column number - is 0-based. + if it isn't associated with an original column. * `source`: The original source's filename; null if no filename is provided. @@ -660,8 +566,9 @@ Creates a SourceNode from generated code and a SourceMapConsumer. should be relative to. ```js -const consumer = await new SourceMapConsumer(fs.readFileSync("path/to/my-file.js.map", "utf8")); -const node = SourceNode.fromStringWithSourceMap(fs.readFileSync("path/to/my-file.js"), consumer); +var consumer = new SourceMapConsumer(fs.readFileSync("path/to/my-file.js.map", "utf8")); +var node = SourceNode.fromStringWithSourceMap(fs.readFileSync("path/to/my-file.js"), + consumer); ``` #### SourceNode.prototype.add(chunk) |
