source-map-generator
Advanced tools
Comparing version 0.8.0 to 1.0.0
@@ -8,5 +8,4 @@ /* -*- Mode: js; js-indent-level: 2; -*- */ | ||
const intToCharMap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split( | ||
"" | ||
); | ||
const intToCharMap = | ||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""); | ||
@@ -16,3 +15,3 @@ /** | ||
*/ | ||
exports.encode = function(number) { | ||
exports.encode = function (number) { | ||
if (0 <= number && number < intToCharMap.length) { | ||
@@ -19,0 +18,0 @@ return intToCharMap[number]; |
@@ -44,10 +44,10 @@ /* -*- Mode: js; js-indent-level: 2; -*- */ | ||
file: aSourceMapConsumer.file, | ||
sourceRoot | ||
sourceRoot, | ||
}); | ||
aSourceMapConsumer.eachMapping(function(mapping) { | ||
aSourceMapConsumer.eachMapping(function (mapping) { | ||
const newMapping = { | ||
generated: { | ||
line: mapping.generatedLine, | ||
column: mapping.generatedColumn | ||
} | ||
column: mapping.generatedColumn, | ||
}, | ||
}; | ||
@@ -63,3 +63,3 @@ | ||
line: mapping.originalLine, | ||
column: mapping.originalColumn | ||
column: mapping.originalColumn, | ||
}; | ||
@@ -74,3 +74,3 @@ | ||
}); | ||
aSourceMapConsumer.sources.forEach(function(sourceFile) { | ||
aSourceMapConsumer.sources.forEach(function (sourceFile) { | ||
let sourceRelative = sourceFile; | ||
@@ -133,3 +133,3 @@ if (sourceRoot != null) { | ||
source, | ||
name | ||
name, | ||
}); | ||
@@ -204,3 +204,3 @@ } | ||
// Find mappings for the "sourceFile" | ||
this._mappings.unsortedForEach(function(mapping) { | ||
this._mappings.unsortedForEach(function (mapping) { | ||
if (mapping.source === sourceFile && mapping.originalLine != null) { | ||
@@ -210,3 +210,3 @@ // Check if it can be mapped by the source map, then update the mapping. | ||
line: mapping.originalLine, | ||
column: mapping.originalColumn | ||
column: mapping.originalColumn, | ||
}); | ||
@@ -244,3 +244,3 @@ if (original.source != null) { | ||
// Copy sourcesContents of applied map. | ||
aSourceMapConsumer.sources.forEach(function(srcFile) { | ||
aSourceMapConsumer.sources.forEach(function (srcFile) { | ||
const content = aSourceMapConsumer.sourceContentFor(srcFile); | ||
@@ -319,3 +319,3 @@ if (content != null) { | ||
original: aOriginal, | ||
name: aName | ||
name: aName, | ||
}) | ||
@@ -398,3 +398,3 @@ ); | ||
_generateSourcesContent(aSources, aSourceRoot) { | ||
return aSources.map(function(source) { | ||
return aSources.map(function (source) { | ||
if (!this._sourcesContents) { | ||
@@ -421,3 +421,3 @@ return null; | ||
names: this._names.toArray(), | ||
mappings: this._serializeMappings() | ||
mappings: this._serializeMappings(), | ||
}; | ||
@@ -424,0 +424,0 @@ if (this._file != null) { |
@@ -70,3 +70,3 @@ /* -*- Mode: js; js-indent-level: 2; -*- */ | ||
let remainingLinesIndex = 0; | ||
const shiftNextLine = function() { | ||
const shiftNextLine = function () { | ||
const lineContents = getNextLine(); | ||
@@ -94,3 +94,3 @@ // The last line of a file might not have a newline. | ||
aSourceMapConsumer.eachMapping(function(mapping) { | ||
aSourceMapConsumer.eachMapping(function (mapping) { | ||
if (lastMapping !== null) { | ||
@@ -152,3 +152,3 @@ // We add the code from "lastMapping" to "mapping": | ||
// Copy sourcesContent into SourceNode | ||
aSourceMapConsumer.sources.forEach(function(sourceFile) { | ||
aSourceMapConsumer.sources.forEach(function (sourceFile) { | ||
const content = aSourceMapConsumer.sourceContentFor(sourceFile); | ||
@@ -193,3 +193,3 @@ if (content != null) { | ||
if (Array.isArray(aChunk)) { | ||
aChunk.forEach(function(chunk) { | ||
aChunk.forEach(function (chunk) { | ||
this.add(chunk); | ||
@@ -250,3 +250,3 @@ }, this); | ||
column: this.column, | ||
name: this.name | ||
name: this.name, | ||
}); | ||
@@ -337,3 +337,3 @@ } | ||
let str = ""; | ||
this.walk(function(chunk) { | ||
this.walk(function (chunk) { | ||
str += chunk; | ||
@@ -352,3 +352,3 @@ }); | ||
line: 1, | ||
column: 0 | ||
column: 0, | ||
}; | ||
@@ -361,3 +361,3 @@ const map = new SourceMapGenerator(aArgs); | ||
let lastOriginalName = null; | ||
this.walk(function(chunk, original) { | ||
this.walk(function (chunk, original) { | ||
generated.code += chunk; | ||
@@ -379,9 +379,9 @@ if ( | ||
line: original.line, | ||
column: original.column | ||
column: original.column, | ||
}, | ||
generated: { | ||
line: generated.line, | ||
column: generated.column | ||
column: generated.column, | ||
}, | ||
name: original.name | ||
name: original.name, | ||
}); | ||
@@ -398,4 +398,4 @@ } | ||
line: generated.line, | ||
column: generated.column | ||
} | ||
column: generated.column, | ||
}, | ||
}); | ||
@@ -418,9 +418,9 @@ lastOriginalSource = null; | ||
line: original.line, | ||
column: original.column | ||
column: original.column, | ||
}, | ||
generated: { | ||
line: generated.line, | ||
column: generated.column | ||
column: generated.column, | ||
}, | ||
name: original.name | ||
name: original.name, | ||
}); | ||
@@ -433,3 +433,3 @@ } | ||
}); | ||
this.walkSourceContents(function(sourceFile, sourceContent) { | ||
this.walkSourceContents(function (sourceFile, sourceContent) { | ||
map.setSourceContent(sourceFile, sourceContent); | ||
@@ -436,0 +436,0 @@ }); |
@@ -28,3 +28,3 @@ /* -*- Mode: js; js-indent-level: 2; -*- */ | ||
const supportsNullProto = (function() { | ||
const supportsNullProto = (function () { | ||
const obj = Object.create(null); | ||
@@ -153,3 +153,4 @@ return !("__proto__" in obj); | ||
} | ||
exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated; | ||
exports.compareByGeneratedPositionsInflated = | ||
compareByGeneratedPositionsInflated; | ||
@@ -156,0 +157,0 @@ // We use 'http' as the base here because we want URLs processed relative |
{ | ||
"name": "source-map-generator", | ||
"description": "Generates source maps", | ||
"version": "0.8.0", | ||
"version": "1.0.0", | ||
"homepage": "https://github.com/hildjj/source-map-generator", | ||
@@ -61,3 +61,3 @@ "author": "Nick Fitzgerald <nfitzgerald@mozilla.com>", | ||
"engines": { | ||
"node": ">= 10" | ||
"node": ">= 12" | ||
}, | ||
@@ -67,30 +67,29 @@ "license": "BSD-3-Clause", | ||
"lint": "eslint --fix *.js lib/ test/", | ||
"prebuild": "npm run lint", | ||
"test": "node test/run-tests.js", | ||
"coverage": "nyc node test/run-tests.js", | ||
"setup": "mkdir -p coverage && cp -n .waiting.html coverage/index.html || true", | ||
"dev:live": "live-server --port=4103 --ignorePattern='(js|css|png)$' coverage", | ||
"dev:watch": "watch 'npm run coverage' lib/ test/", | ||
"predev": "npm run setup", | ||
"dev": "npm-run-all -p --silent dev:*", | ||
"prettier": "prettier --write --print-width=120 *.{js,ts,json,md} lib/*.js test/*.js bench/bench*", | ||
"clean": "rm -rf coverage .nyc_output", | ||
"toc": "doctoc --title '## Table of Contents' README.md && doctoc --title '## Table of Contents' CONTRIBUTING.md" | ||
"coverage": "c8 --reporter=text --reporter=html npm test", | ||
"prettier": "prettier --write .", | ||
"clean": "rm -rf coverage", | ||
"toc": "doctoc --github --notitle README.md CONTRIBUTING.md" | ||
}, | ||
"devDependencies": { | ||
"doctoc": "^2.0.1", | ||
"eslint": "^7.32.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-prettier": "^3.4.1", | ||
"live-server": "^1.2.1", | ||
"npm-run-all": "^4.1.5", | ||
"nyc": "^15.1.0", | ||
"prettier": "2.3.2", | ||
"source-map": "0.8.0-beta.0", | ||
"watch": "^1.0.2" | ||
"c8": "^8.0.0", | ||
"doctoc": "^2.2.1", | ||
"eslint": "^8.43.0", | ||
"eslint-config-prettier": "^8.8.0", | ||
"prettier": "^2.8.8", | ||
"source-map": "0.7.4" | ||
}, | ||
"nyc": { | ||
"reporter": "html" | ||
"pnpm": { | ||
"overrides": { | ||
"semver": ">=7.5.3", | ||
"word-wrap": "npm:@aashutoshrathi/word-wrap" | ||
} | ||
}, | ||
"typings": "source-map" | ||
"overrides": { | ||
"semver": ">=7.5.3", | ||
"word-wrap": "npm:@aashutoshrathi/word-wrap" | ||
}, | ||
"engine": { | ||
"node": ">=16" | ||
} | ||
} |
# Source Map | ||
<!-- | ||
[![Build Status](https://travis-ci.org/mozilla/source-map.svg?branch=master)](https://travis-ci.org/mozilla/source-map) | ||
[![Tests](https://github.com/hildjj/source-map-generator/actions/workflows/node.js.yml/badge.svg)](https://github.com/hildjj/source-map-generator/actions/workflows/node.js.yml) | ||
[![Coverage Status](https://coveralls.io/repos/github/mozilla/source-map/badge.svg)](https://coveralls.io/github/mozilla/source-map) | ||
--> | ||
[![codecov](https://codecov.io/gh/hildjj/source-map-generator/branch/main/graph/badge.svg?token=M80IXLBBLD)](https://codecov.io/gh/hildjj/source-map-generator) | ||
@@ -12,3 +10,3 @@ [![NPM](https://nodei.co/npm/source-map-generator.png?downloads=true&downloadRank=true)](https://www.npmjs.com/package/source-map-generator) | ||
This is a library to generate the source map format | ||
[described here][format]. It is a close fork of [source-map](https://github.com/mozilla/source-map), which also provides a source map consumer. | ||
[described here][format]. It is a close fork of [source-map](https://github.com/mozilla/source-map), which also provides a source map consumer. | ||
@@ -27,6 +25,7 @@ [format]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit | ||
const map = new SourceMapGenerator({ | ||
file: "source-mapped.js" | ||
file: "source-mapped.js", | ||
}); | ||
</script> | ||
``` | ||
--- | ||
@@ -38,3 +37,2 @@ | ||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> | ||
## Table of Contents | ||
@@ -78,9 +76,15 @@ - [Examples](#examples) | ||
case "BinaryExpression": | ||
return new SourceNode(ast.location.line, ast.location.column, ast.location.source, [ | ||
compile(ast.left), | ||
" + ", | ||
compile(ast.right) | ||
]); | ||
return new SourceNode( | ||
ast.location.line, | ||
ast.location.column, | ||
ast.location.source, | ||
[compile(ast.left), " + ", compile(ast.right)] | ||
); | ||
case "Literal": | ||
return new SourceNode(ast.location.line, ast.location.column, ast.location.source, String(ast.value)); | ||
return new SourceNode( | ||
ast.location.line, | ||
ast.location.column, | ||
ast.location.source, | ||
String(ast.value) | ||
); | ||
// ... | ||
@@ -95,3 +99,3 @@ default: | ||
compile(ast).toStringWithSourceMap({ | ||
file: "add.js" | ||
file: "add.js", | ||
}) | ||
@@ -107,3 +111,3 @@ ); | ||
var map = new SourceMapGenerator({ | ||
file: "source-mapped.js" | ||
file: "source-mapped.js", | ||
}); | ||
@@ -114,3 +118,3 @@ | ||
line: 10, | ||
column: 35 | ||
column: 35, | ||
}, | ||
@@ -120,5 +124,5 @@ source: "foo.js", | ||
line: 33, | ||
column: 2 | ||
column: 2, | ||
}, | ||
name: "christopher" | ||
name: "christopher", | ||
}); | ||
@@ -136,3 +140,3 @@ | ||
// Node.js | ||
var sourceMap = require("source-map"); | ||
var sourceMap = require("source-map-generator"); | ||
@@ -168,3 +172,3 @@ // Browser builds | ||
file: "my-generated-javascript-file.js", | ||
sourceRoot: "http://example.com/app/js/" | ||
sourceRoot: "http://example.com/app/js/", | ||
}); | ||
@@ -191,3 +195,3 @@ ``` | ||
original: { line: 128, column: 0 }, | ||
generated: { line: 3, column: 456 } | ||
generated: { line: 3, column: 456 }, | ||
}); | ||
@@ -205,3 +209,6 @@ ``` | ||
```js | ||
generator.setSourceContent("module-one.scm", fs.readFileSync("path/to/module-one.scm")); | ||
generator.setSourceContent( | ||
"module-one.scm", | ||
fs.readFileSync("path/to/module-one.scm") | ||
); | ||
``` | ||
@@ -246,3 +253,3 @@ | ||
new SourceNode(5, 6, "c.cpp", "std::string* make_string(size_t n);\n"), | ||
new SourceNode(7, 8, "d.cpp", "int main(int argc, char** argv) {}\n") | ||
new SourceNode(7, 8, "d.cpp", "int main(int argc, char** argv) {}\n"), | ||
]); | ||
@@ -285,3 +292,6 @@ ``` | ||
```js | ||
node.setSourceContent("module-one.scm", fs.readFileSync("path/to/module-one.scm")); | ||
node.setSourceContent( | ||
"module-one.scm", | ||
fs.readFileSync("path/to/module-one.scm") | ||
); | ||
``` | ||
@@ -301,6 +311,6 @@ | ||
"dos", | ||
["tres", new SourceNode(5, 6, "c.js", "quatro")] | ||
["tres", new SourceNode(5, 6, "c.js", "quatro")], | ||
]); | ||
node.walk(function(code, loc) { | ||
node.walk(function (code, loc) { | ||
console.log("WALK:", code, loc); | ||
@@ -330,3 +340,3 @@ }); | ||
var node = new SourceNode(null, null, null, [a, b, c]); | ||
node.walkSourceContents(function(source, contents) { | ||
node.walkSourceContents(function (source, contents) { | ||
console.log("WALK:", source, ":", contents); | ||
@@ -378,3 +388,3 @@ }); | ||
"dos", | ||
["tres", new SourceNode(5, 6, "c.js", "quatro")] | ||
["tres", new SourceNode(5, 6, "c.js", "quatro")], | ||
]); | ||
@@ -398,3 +408,3 @@ | ||
"dos", | ||
["tres", new SourceNode(5, 6, "c.js", "quatro")] | ||
["tres", new SourceNode(5, 6, "c.js", "quatro")], | ||
]); | ||
@@ -406,2 +416,1 @@ | ||
``` | ||
@@ -6,3 +6,4 @@ /* | ||
*/ | ||
exports.SourceMapGenerator = require("./lib/source-map-generator").SourceMapGenerator; | ||
exports.SourceMapGenerator = | ||
require("./lib/source-map-generator").SourceMapGenerator; | ||
exports.SourceNode = require("./lib/source-node").SourceNode; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
6
1626
0
398
71073