@parcel/source-map
Advanced tools
Comparing version 2.0.0-alpha.3.1 to 2.0.0-alpha.4
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; |
{ | ||
"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" | ||
} | ||
} |
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 9 instances in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
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 README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
1690530
2
27
0
20
3
1
116
1
10
+ Addednode-addon-api@^2.0.0
+ Addednode-gyp-build@^4.2.1
+ Addednode-addon-api@2.0.2(transitive)
+ Addednode-gyp-build@4.8.4(transitive)
- Removed@parcel/utils@^2.0.0-alpha.3.1
- Removednullthrows@^1.1.1
- Removedsource-map@^0.7.3
- Removed@lezer/common@1.2.3(transitive)
- Removed@lezer/lr@1.4.2(transitive)
- Removed@mischnic/json-sourcemap@0.1.1(transitive)
- Removed@parcel/codeframe@2.13.2(transitive)
- Removed@parcel/diagnostic@2.13.2(transitive)
- Removed@parcel/events@2.13.2(transitive)
- Removed@parcel/logger@2.13.2(transitive)
- Removed@parcel/markdown-ansi@2.13.2(transitive)
- Removed@parcel/rust@2.13.2(transitive)
- Removed@parcel/source-map@2.1.1(transitive)
- Removed@parcel/utils@2.13.2(transitive)
- Removedansi-styles@4.3.0(transitive)
- Removedchalk@4.1.2(transitive)
- Removedcolor-convert@2.0.1(transitive)
- Removedcolor-name@1.1.4(transitive)
- Removeddetect-libc@1.0.3(transitive)
- Removedhas-flag@4.0.0(transitive)
- Removedjson5@2.2.3(transitive)
- Removednullthrows@1.1.1(transitive)
- Removedsource-map@0.7.4(transitive)
- Removedsupports-color@7.2.0(transitive)