@parcel/hash
Advanced tools
Comparing version 2.8.3 to 2.8.4-nightly.0
269
index.js
@@ -1,22 +0,259 @@ | ||
let parts = [process.platform, process.arch]; | ||
if (process.platform === 'linux') { | ||
const {MUSL, family} = require('detect-libc'); | ||
if (family === MUSL) { | ||
parts.push('musl'); | ||
} else if (process.arch === 'arm') { | ||
parts.push('gnueabihf'); | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
/* prettier-ignore */ | ||
/* auto-generated by NAPI-RS */ | ||
const { existsSync, readFileSync } = require('fs') | ||
const { join } = require('path') | ||
const { platform, arch } = process | ||
let nativeBinding = null | ||
let localFileExisted = false | ||
let loadError = null | ||
function isMusl() { | ||
// For Node 10 | ||
if (!process.report || typeof process.report.getReport !== 'function') { | ||
try { | ||
const lddPath = require('child_process').execSync('which ldd').toString().trim(); | ||
return readFileSync(lddPath, 'utf8').includes('musl') | ||
} catch (e) { | ||
return true | ||
} | ||
} else { | ||
parts.push('gnu'); | ||
const { glibcVersionRuntime } = process.report.getReport().header | ||
return !glibcVersionRuntime | ||
} | ||
} else if (process.platform === 'win32') { | ||
parts.push('msvc'); | ||
} | ||
let name = `./parcel-hash.${parts.join('-')}.node`; | ||
if (process.env.PARCEL_BUILD_ENV === 'production') { | ||
module.exports = require(name); | ||
} else if (require('fs').existsSync(require('path').join(__dirname, name))) { | ||
module.exports = require(name); | ||
switch (platform) { | ||
case 'android': | ||
switch (arch) { | ||
case 'arm64': | ||
localFileExisted = existsSync(join(__dirname, 'parcel-hash.android-arm64.node')) | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./parcel-hash.android-arm64.node') | ||
} else { | ||
nativeBinding = require('@parcel/hash-android-arm64') | ||
} | ||
} catch (e) { | ||
loadError = e | ||
} | ||
break | ||
case 'arm': | ||
localFileExisted = existsSync(join(__dirname, 'parcel-hash.android-arm-eabi.node')) | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./parcel-hash.android-arm-eabi.node') | ||
} else { | ||
nativeBinding = require('@parcel/hash-android-arm-eabi') | ||
} | ||
} catch (e) { | ||
loadError = e | ||
} | ||
break | ||
default: | ||
throw new Error(`Unsupported architecture on Android ${arch}`) | ||
} | ||
break | ||
case 'win32': | ||
switch (arch) { | ||
case 'x64': | ||
localFileExisted = existsSync( | ||
join(__dirname, 'parcel-hash.win32-x64-msvc.node') | ||
) | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./parcel-hash.win32-x64-msvc.node') | ||
} else { | ||
nativeBinding = require('@parcel/hash-win32-x64-msvc') | ||
} | ||
} catch (e) { | ||
loadError = e | ||
} | ||
break | ||
case 'ia32': | ||
localFileExisted = existsSync( | ||
join(__dirname, 'parcel-hash.win32-ia32-msvc.node') | ||
) | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./parcel-hash.win32-ia32-msvc.node') | ||
} else { | ||
nativeBinding = require('@parcel/hash-win32-ia32-msvc') | ||
} | ||
} catch (e) { | ||
loadError = e | ||
} | ||
break | ||
case 'arm64': | ||
localFileExisted = existsSync( | ||
join(__dirname, 'parcel-hash.win32-arm64-msvc.node') | ||
) | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./parcel-hash.win32-arm64-msvc.node') | ||
} else { | ||
nativeBinding = require('@parcel/hash-win32-arm64-msvc') | ||
} | ||
} catch (e) { | ||
loadError = e | ||
} | ||
break | ||
default: | ||
throw new Error(`Unsupported architecture on Windows: ${arch}`) | ||
} | ||
break | ||
case 'darwin': | ||
localFileExisted = existsSync(join(__dirname, 'parcel-hash.darwin-universal.node')) | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./parcel-hash.darwin-universal.node') | ||
} else { | ||
nativeBinding = require('@parcel/hash-darwin-universal') | ||
} | ||
break | ||
} catch {} | ||
switch (arch) { | ||
case 'x64': | ||
localFileExisted = existsSync(join(__dirname, 'parcel-hash.darwin-x64.node')) | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./parcel-hash.darwin-x64.node') | ||
} else { | ||
nativeBinding = require('@parcel/hash-darwin-x64') | ||
} | ||
} catch (e) { | ||
loadError = e | ||
} | ||
break | ||
case 'arm64': | ||
localFileExisted = existsSync( | ||
join(__dirname, 'parcel-hash.darwin-arm64.node') | ||
) | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./parcel-hash.darwin-arm64.node') | ||
} else { | ||
nativeBinding = require('@parcel/hash-darwin-arm64') | ||
} | ||
} catch (e) { | ||
loadError = e | ||
} | ||
break | ||
default: | ||
throw new Error(`Unsupported architecture on macOS: ${arch}`) | ||
} | ||
break | ||
case 'freebsd': | ||
if (arch !== 'x64') { | ||
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`) | ||
} | ||
localFileExisted = existsSync(join(__dirname, 'parcel-hash.freebsd-x64.node')) | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./parcel-hash.freebsd-x64.node') | ||
} else { | ||
nativeBinding = require('@parcel/hash-freebsd-x64') | ||
} | ||
} catch (e) { | ||
loadError = e | ||
} | ||
break | ||
case 'linux': | ||
switch (arch) { | ||
case 'x64': | ||
if (isMusl()) { | ||
localFileExisted = existsSync( | ||
join(__dirname, 'parcel-hash.linux-x64-musl.node') | ||
) | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./parcel-hash.linux-x64-musl.node') | ||
} else { | ||
nativeBinding = require('@parcel/hash-linux-x64-musl') | ||
} | ||
} catch (e) { | ||
loadError = e | ||
} | ||
} else { | ||
localFileExisted = existsSync( | ||
join(__dirname, 'parcel-hash.linux-x64-gnu.node') | ||
) | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./parcel-hash.linux-x64-gnu.node') | ||
} else { | ||
nativeBinding = require('@parcel/hash-linux-x64-gnu') | ||
} | ||
} catch (e) { | ||
loadError = e | ||
} | ||
} | ||
break | ||
case 'arm64': | ||
if (isMusl()) { | ||
localFileExisted = existsSync( | ||
join(__dirname, 'parcel-hash.linux-arm64-musl.node') | ||
) | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./parcel-hash.linux-arm64-musl.node') | ||
} else { | ||
nativeBinding = require('@parcel/hash-linux-arm64-musl') | ||
} | ||
} catch (e) { | ||
loadError = e | ||
} | ||
} else { | ||
localFileExisted = existsSync( | ||
join(__dirname, 'parcel-hash.linux-arm64-gnu.node') | ||
) | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./parcel-hash.linux-arm64-gnu.node') | ||
} else { | ||
nativeBinding = require('@parcel/hash-linux-arm64-gnu') | ||
} | ||
} catch (e) { | ||
loadError = e | ||
} | ||
} | ||
break | ||
case 'arm': | ||
localFileExisted = existsSync( | ||
join(__dirname, 'parcel-hash.linux-arm-gnueabihf.node') | ||
) | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./parcel-hash.linux-arm-gnueabihf.node') | ||
} else { | ||
nativeBinding = require('@parcel/hash-linux-arm-gnueabihf') | ||
} | ||
} catch (e) { | ||
loadError = e | ||
} | ||
break | ||
default: | ||
throw new Error(`Unsupported architecture on Linux: ${arch}`) | ||
} | ||
break | ||
default: | ||
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`) | ||
} | ||
module.exports.init = Promise.resolve(); | ||
if (!nativeBinding) { | ||
if (loadError) { | ||
throw loadError | ||
} | ||
throw new Error(`Failed to load native binding`) | ||
} | ||
const { hashString, hashBuffer, Hash } = nativeBinding | ||
module.exports.hashString = hashString | ||
module.exports.hashBuffer = hashBuffer | ||
module.exports.Hash = Hash |
{ | ||
"name": "@parcel/hash", | ||
"version": "2.8.3", | ||
"version": "2.8.4-nightly.0+7b79c6d", | ||
"license": "MIT", | ||
@@ -35,10 +35,9 @@ "main": "index.js", | ||
"dependencies": { | ||
"detect-libc": "^1.0.3", | ||
"xxhash-wasm": "^0.4.2" | ||
}, | ||
"devDependencies": { | ||
"@napi-rs/cli": "^2.6.2", | ||
"@napi-rs/cli": "^2.15.2", | ||
"tiny-benchy": "^1.0.2" | ||
}, | ||
"gitHead": "349a6caf40ec8abb6a49fcae0765f8f8deb2073d" | ||
"gitHead": "7b79c6d69ffabef89810a8db61e9abdeb70d6990" | ||
} |
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
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
3011539
1
301
1
2
3
- Removeddetect-libc@^1.0.3
- Removeddetect-libc@1.0.3(transitive)