Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@parcel/source-map

Package Overview
Dependencies
Maintainers
1
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@parcel/source-map - npm Package Compare versions

Comparing version 2.0.0-alpha.3.1 to 2.0.0-alpha.4

binding.gyp

138

index.js

@@ -1,2 +0,136 @@

// @flow
export * from './src/SourceMap.js';
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")}`;
}
class SourceMap {
constructor() {
this.sourceMapInstance = new bindings.SourceMap();
}
// addEmptyMap(sourceName: string, sourceContent: string, lineOffset: number = 0): SourceMap
addEmptyMap(sourceName, sourceContent, lineOffset = 0) {
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
);
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
// 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
);
return this;
}
// addNames(names: Array<string>): Array<number>
addNames(names) {
return this.sourceMapInstance.addNames(names);
}
// addSources(sources: Array<string>): Array<number>
addSources(sources) {
return this.sourceMapInstance.addSources(sources);
}
// getSourceIndex(source: string): number
getSourceIndex(source) {
return this.sourceMapInstance.getSourceIndex(source);
}
// getNameIndex(name: string): number
getNameIndex(name) {
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
// extends(buffer: Buffer): SourceMap
extends(buffer) {
this.sourceMapInstance.extends(buffer);
return this;
}
// getMap(): {sources: Array<string>, names: Array<string>, mappings: Array<{source: Position, original: Position, name: number, source: number}>}}
getMap() {
return this.sourceMapInstance.getMap();
}
// toBuffer(): Buffer
toBuffer() {
return this.sourceMapInstance.toBuffer();
}
// toVLQ(): {sources: Array<string>, names: Array<string>, mappings: string}
toVLQ() {
return this.sourceMapInstance.stringify();
}
async stringify({ file, sourceRoot, rootDir, inlineSources, inlineMap, fs }) {
let map = this.sourceMapInstance.stringify();
map.version = 3;
map.file = file;
map.sourceRoot = sourceRoot;
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;
}
})
);
}
let stringifiedMap = JSON.stringify(map);
return inlineMap ? generateInlineMap(stringifiedMap) : stringifiedMap;
}
}
// generateEmptyMap(sourceName: string, sourceContent: string, lineOffset: number = 0): SourceMap
function generateEmptyMap(sourceName, sourceContent, lineOffset = 0) {
let map = new SourceMap();
map.addEmptyMap(sourceName, sourceContent, lineOffset);
return map;
}
SourceMap.generateEmptyMap = generateEmptyMap;
SourceMap.default = SourceMap;
module.exports = SourceMap;

45

package.json
{
"name": "@parcel/source-map",
"version": "2.0.0-alpha.3.1",
"version": "2.0.0-alpha.4",
"main": "index.js",
"license": "MIT",
"publishConfig": {
"access": "public"
"scripts": {
"test": "mocha ./test/*.test.js",
"benchmark": "node ./bench/run",
"prebuild": "prebuildify --napi --strip --tag-libc",
"build:dev": "node-gyp rebuild --debug",
"rebuild": "rm -rf build && yarn build:dev",
"postinstall": "node-gyp-build"
},
"repository": {
"type": "git",
"url": "https://github.com/parcel-bundler/parcel.git"
"files": [
"src",
"prebuilds",
"index.js",
"package.json",
"binding.gyp",
"README.md"
],
"binary": {
"napi_versions": [
3
]
},
"main": "lib/SourceMap.js",
"source": "src/SourceMap.js",
"scripts": {},
"engines": {
"node": ">= 10.0.0"
},
"dependencies": {
"@parcel/utils": "^2.0.0-alpha.3.1",
"nullthrows": "^1.1.1",
"source-map": "^0.7.3"
"node-addon-api": "^2.0.0",
"node-gyp-build": "^4.2.1"
},
"devDependencies": {
"clone": "^2.1.1"
},
"gitHead": "291f3e6815a1a857a6165fafb1691ceeb878b8f6"
"mocha": "^7.1.0",
"prebuildify": "^3.0.4",
"tiny-benchy": "^1.0.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc