@parcel/source-map
Advanced tools
+41
-58
@@ -0,8 +1,17 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports.generateEmptyMap = generateEmptyMap; | ||
| exports.default = void 0; | ||
| var _path = _interopRequireDefault(require("path")); | ||
| function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
| const bindings = require("node-gyp-build")(__dirname); | ||
| const path = require("path"); | ||
| function generateInlineMap(map) { | ||
| return `data:application/json;charset=utf-8;base64,${Buffer.from( | ||
| map | ||
| ).toString("base64")}`; | ||
| return `data:application/json;charset=utf-8;base64,${Buffer.from(map).toString("base64")}`; | ||
| } | ||
@@ -13,44 +22,26 @@ | ||
| this.sourceMapInstance = new bindings.SourceMap(); | ||
| } | ||
| } // addEmptyMap(sourceName: string, sourceContent: string, lineOffset: number = 0): SourceMap | ||
| // addEmptyMap(sourceName: string, sourceContent: string, lineOffset: number = 0): SourceMap | ||
| addEmptyMap(sourceName, sourceContent, lineOffset = 0) { | ||
| this.sourceMapInstance.addEmptyMap( | ||
| sourceName, | ||
| sourceContent, | ||
| lineOffset | ||
| ); | ||
| this.sourceMapInstance.addEmptyMap(sourceName, sourceContent, lineOffset); | ||
| return this; | ||
| } | ||
| // addRawMappings(mappings: string, sources: Array<string>, names: Array<string>, lineOffset: number = 0, columnOffset: number = 0): SourceMap | ||
| addRawMappings(mappings, sources, names, lineOffset = 0, columnOffset = 0) { | ||
| this.sourceMapInstance.addRawMappings( | ||
| mappings, | ||
| sources, | ||
| names, | ||
| lineOffset, | ||
| columnOffset | ||
| ); | ||
| this.sourceMapInstance.addRawMappings(mappings, sources, names, lineOffset, columnOffset); | ||
| return this; | ||
| } | ||
| // addBufferMappings(buffer: Buffer, lineOffset: number = 0, columnOffset: number = 0): SourceMap | ||
| addBufferMappings(buffer, lineOffset = 0, columnOffset = 0) { | ||
| this.sourceMapInstance.addBufferMappings(buffer, lineOffset, columnOffset); | ||
| return this; | ||
| } | ||
| } // line numbers start at 1 so we have the same api as `source-map` by mozilla | ||
| // line numbers start at 1 so we have the same api as `source-map` by mozilla | ||
| // addIndexedMappings(mappings: Array<{source: Position, original: Position, name: string | number, source: string | number}>, lineOffset: number = 0, columnOffset: number = 0): SourceMap | ||
| addIndexedMappings(mappings, lineOffset = 0, columnOffset = 0) { | ||
| this.sourceMapInstance.addIndexedMappings( | ||
| mappings, | ||
| lineOffset, | ||
| columnOffset | ||
| ); | ||
| this.sourceMapInstance.addIndexedMappings(mappings, lineOffset, columnOffset); | ||
| return this; | ||
| } | ||
| // addNames(names: Array<string>): Array<number> | ||
| addNames(names) { | ||
@@ -60,3 +51,2 @@ return this.sourceMapInstance.addNames(names); | ||
| // addSources(sources: Array<string>): Array<number> | ||
| addSources(sources) { | ||
@@ -66,3 +56,2 @@ return this.sourceMapInstance.addSources(sources); | ||
| // getSourceIndex(source: string): number | ||
| getSourceIndex(source) { | ||
@@ -72,3 +61,2 @@ return this.sourceMapInstance.getSourceIndex(source); | ||
| // getNameIndex(name: string): number | ||
| getNameIndex(name) { | ||
@@ -78,9 +66,7 @@ return this.sourceMapInstance.getNameIndex(name); | ||
| // findClosestMapping(line: number, column: number): {source: Position, original: Position, name: number, source: number} | ||
| findClosestMapping(line, column) { | ||
| return this.sourceMapInstance.findClosestMapping(line, column); | ||
| } | ||
| } // Remaps original positions from this map to the ones in the provided map | ||
| // Remaps original positions from this map to the ones in the provided map | ||
| // extends(buffer: Buffer): SourceMap | ||
| extends(buffer) { | ||
@@ -91,3 +77,2 @@ this.sourceMapInstance.extends(buffer); | ||
| // getMap(): {sources: Array<string>, names: Array<string>, mappings: Array<{source: Position, original: Position, name: number, source: number}>}} | ||
| getMap() { | ||
@@ -97,3 +82,2 @@ return this.sourceMapInstance.getMap(); | ||
| // toBuffer(): Buffer | ||
| toBuffer() { | ||
@@ -103,3 +87,2 @@ return this.sourceMapInstance.toBuffer(); | ||
| // toVLQ(): {sources: Array<string>, names: Array<string>, mappings: string} | ||
| toVLQ() { | ||
@@ -109,3 +92,10 @@ return this.sourceMapInstance.stringify(); | ||
| async stringify({ file, sourceRoot, rootDir, inlineSources, inlineMap, fs }) { | ||
| async stringify({ | ||
| file, | ||
| sourceRoot, | ||
| rootDir, | ||
| inlineSources, | ||
| inlineMap, | ||
| fs | ||
| }) { | ||
| let map = this.sourceMapInstance.stringify(); | ||
@@ -116,15 +106,10 @@ map.version = 3; | ||
| if (inlineSources) { | ||
| map.sourcesContent = await Promise.all( | ||
| map.sources.map(async sourceName => { | ||
| try { | ||
| return await fs.readFile( | ||
| path.join(rootDir || "", sourceName), | ||
| "utf-8" | ||
| ); | ||
| } catch (e) { | ||
| return null; | ||
| } | ||
| }) | ||
| ); | ||
| if (inlineSources && fs) { | ||
| map.sourcesContent = await Promise.all(map.sources.map(async sourceName => { | ||
| try { | ||
| return await fs.readFile(_path.default.join(rootDir || "", sourceName), "utf-8"); | ||
| } catch (e) { | ||
| return null; | ||
| } | ||
| })); | ||
| } | ||
@@ -135,5 +120,7 @@ | ||
| } | ||
| } | ||
| // generateEmptyMap(sourceName: string, sourceContent: string, lineOffset: number = 0): SourceMap | ||
| exports.default = SourceMap; | ||
| function generateEmptyMap(sourceName, sourceContent, lineOffset = 0) { | ||
@@ -144,5 +131,1 @@ let map = new SourceMap(); | ||
| } | ||
| SourceMap.generateEmptyMap = generateEmptyMap; | ||
| SourceMap.default = SourceMap; | ||
| module.exports = SourceMap; |
+8
-2
| { | ||
| "name": "@parcel/source-map", | ||
| "version": "2.0.0-alpha.4.1", | ||
| "version": "2.0.0-alpha.4.2", | ||
| "main": "index.js", | ||
@@ -9,6 +9,8 @@ "license": "MIT", | ||
| "benchmark": "node ./bench/run", | ||
| "compile": "babel index.js.flow --out-file index.js", | ||
| "prebuild": "prebuildify --napi --strip --tag-libc", | ||
| "build:dev": "node-gyp rebuild --debug", | ||
| "rebuild": "rm -rf build && yarn build:dev", | ||
| "postinstall": "node-gyp-build" | ||
| "postinstall": "node-gyp-build", | ||
| "typecheck": "flow" | ||
| }, | ||
@@ -34,2 +36,6 @@ "files": [ | ||
| "devDependencies": { | ||
| "@babel/preset-env": "^7.9.0", | ||
| "@babel/cli": "^7.8.4", | ||
| "@babel/core": "^7.9.0", | ||
| "@babel/preset-flow": "^7.9.0", | ||
| "flow-bin": "^0.121.0", | ||
@@ -36,0 +42,0 @@ "mocha": "^7.1.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
1693855
0.09%8
100%91
-21.55%2
100%