rar-stream 5.7.0 → 5.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -319
- package/package.json +3 -103
- package/LICENSE +0 -21
- package/README.md +0 -283
- package/browser.d.ts +0 -126
- package/browser.js +0 -22
- package/index.d.ts +0 -60
- package/lib/browser.d.ts +0 -114
- package/lib/browser.mjs +0 -214
- package/lib/index.d.ts +0 -119
- package/lib/index.mjs +0 -376
- package/scripts/postinstall.js +0 -88
package/scripts/postinstall.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
'use strict'
|
|
3
|
-
|
|
4
|
-
const { existsSync, readFileSync, createWriteStream, unlinkSync } = require('fs')
|
|
5
|
-
const { join } = require('path')
|
|
6
|
-
const https = require('https')
|
|
7
|
-
const http = require('http')
|
|
8
|
-
|
|
9
|
-
const REPO = 'doom-fish/rar-stream'
|
|
10
|
-
const PKG_DIR = join(__dirname, '..')
|
|
11
|
-
|
|
12
|
-
function isMusl() {
|
|
13
|
-
if (!process.report || typeof process.report.getReport !== 'function') {
|
|
14
|
-
try {
|
|
15
|
-
const lddPath = require('child_process').execSync('which ldd').toString().trim()
|
|
16
|
-
return readFileSync(lddPath, 'utf8').includes('musl')
|
|
17
|
-
} catch {
|
|
18
|
-
return true
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
const { glibcVersionRuntime } = process.report.getReport().header
|
|
22
|
-
return !glibcVersionRuntime
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function getBinaryName() {
|
|
26
|
-
const { platform, arch } = process
|
|
27
|
-
switch (platform) {
|
|
28
|
-
case 'win32':
|
|
29
|
-
if (arch === 'x64') return 'rar-stream.win32-x64-msvc.node'
|
|
30
|
-
break
|
|
31
|
-
case 'darwin':
|
|
32
|
-
if (arch === 'x64') return 'rar-stream.darwin-x64.node'
|
|
33
|
-
if (arch === 'arm64') return 'rar-stream.darwin-arm64.node'
|
|
34
|
-
break
|
|
35
|
-
case 'linux':
|
|
36
|
-
if (arch === 'x64') return isMusl() ? 'rar-stream.linux-x64-musl.node' : 'rar-stream.linux-x64-gnu.node'
|
|
37
|
-
if (arch === 'arm64') return isMusl() ? 'rar-stream.linux-arm64-musl.node' : 'rar-stream.linux-arm64-gnu.node'
|
|
38
|
-
break
|
|
39
|
-
}
|
|
40
|
-
return null
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function download(url) {
|
|
44
|
-
return new Promise((resolve, reject) => {
|
|
45
|
-
const client = url.startsWith('https') ? https : http
|
|
46
|
-
client.get(url, { headers: { 'User-Agent': 'rar-stream-postinstall' } }, (res) => {
|
|
47
|
-
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
48
|
-
return download(res.headers.location).then(resolve, reject)
|
|
49
|
-
}
|
|
50
|
-
if (res.statusCode !== 200) {
|
|
51
|
-
res.resume()
|
|
52
|
-
return reject(new Error(`HTTP ${res.statusCode} for ${url}`))
|
|
53
|
-
}
|
|
54
|
-
resolve(res)
|
|
55
|
-
}).on('error', reject)
|
|
56
|
-
})
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
async function main() {
|
|
60
|
-
const binaryName = getBinaryName()
|
|
61
|
-
if (!binaryName) {
|
|
62
|
-
console.log(`rar-stream: no prebuilt binary for ${process.platform}-${process.arch}, skipping download`)
|
|
63
|
-
return
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const dest = join(PKG_DIR, binaryName)
|
|
67
|
-
if (existsSync(dest)) return // already present (local build or cached)
|
|
68
|
-
|
|
69
|
-
const version = require(join(PKG_DIR, 'package.json')).version
|
|
70
|
-
const url = `https://github.com/${REPO}/releases/download/v${version}/${binaryName}`
|
|
71
|
-
|
|
72
|
-
console.log(`rar-stream: downloading ${binaryName} from GitHub Release v${version}...`)
|
|
73
|
-
|
|
74
|
-
try {
|
|
75
|
-
const res = await download(url)
|
|
76
|
-
const file = createWriteStream(dest)
|
|
77
|
-
await new Promise((resolve, reject) => {
|
|
78
|
-
res.pipe(file)
|
|
79
|
-
file.on('finish', resolve)
|
|
80
|
-
file.on('error', (err) => { unlinkSync(dest); reject(err) })
|
|
81
|
-
})
|
|
82
|
-
console.log(`rar-stream: installed ${binaryName}`)
|
|
83
|
-
} catch (err) {
|
|
84
|
-
console.warn(`rar-stream: failed to download binary (${err.message}). You may need to build from source.`)
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
main()
|