@fast-down/fast-down 1.0.1
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/LICENSE +21 -0
- package/README.md +18 -0
- package/index.d.ts +144 -0
- package/index.js +564 -0
- package/package.json +112 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 fast-down
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# @fast-down/fast-down
|
|
2
|
+
|
|
3
|
+
[](https://github.com/fast-down/fast-down-js/commits/main)
|
|
4
|
+
[](https://github.com/fast-down/fast-down-js/actions)
|
|
5
|
+
[](https://github.com/fast-down/fast-down-js/blob/main/LICENSE)
|
|
6
|
+
|
|
7
|
+
`@fast-down/fast-down` 是一个特别快下载器,封装自 [fast-down-ffi](https://github.com/fast-down/ffi),由 Rust 驱动,简洁易用。
|
|
8
|
+
|
|
9
|
+
## 示例
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { prefetch } from '@fast-down/fast-down'
|
|
13
|
+
|
|
14
|
+
const task = await prefetch('https://example.com/test.zip')
|
|
15
|
+
await task.start(task.info.filename())
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
[查看更多示例](https://github.com/fast-down/fast-down-js/blob/main/example)
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/* auto-generated by NAPI-RS */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export declare class CancellationToken {
|
|
4
|
+
constructor()
|
|
5
|
+
cancel(): void
|
|
6
|
+
isCancelled(): boolean
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export declare class DownloadTask {
|
|
10
|
+
cancel(): void
|
|
11
|
+
get info(): UrlInfo
|
|
12
|
+
/**
|
|
13
|
+
* 开始下载任务
|
|
14
|
+
* @param `save_path` 存储路径
|
|
15
|
+
* @param `callback` 进度与事件回调函数
|
|
16
|
+
*/
|
|
17
|
+
start(savePath: string, callback?: (event: Event) => void): Promise<void>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export declare class UrlInfo {
|
|
21
|
+
size: number
|
|
22
|
+
/**
|
|
23
|
+
* 服务器返回的原始文件名,必须清洗掉不合法字符才能安全使用
|
|
24
|
+
*
|
|
25
|
+
* 使用 `UrlInfo.filename()` 可用直接获取安全的文件名
|
|
26
|
+
*/
|
|
27
|
+
rawName: string
|
|
28
|
+
supportsRange: boolean
|
|
29
|
+
fastDownload: boolean
|
|
30
|
+
finalUrl: string
|
|
31
|
+
etag?: string
|
|
32
|
+
lastModified?: string
|
|
33
|
+
/** 返回清洗后的安全文件名 */
|
|
34
|
+
filename(): string
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface Config {
|
|
38
|
+
/** 线程数量,默认值 `32`。线程越多不意味着越快 */
|
|
39
|
+
threads?: number
|
|
40
|
+
/**
|
|
41
|
+
* 设置代理,默认值 `system`。支持 https、http、socks5 代理
|
|
42
|
+
*
|
|
43
|
+
* - `"no"` => `Proxy::No`
|
|
44
|
+
* - `"system"` => `Proxy::System`
|
|
45
|
+
* - `proxy_str` => `Proxy::Custom(proxy_str)`
|
|
46
|
+
*/
|
|
47
|
+
proxy?: 'no' | 'system' | (string & {})
|
|
48
|
+
/** 自定义请求头 */
|
|
49
|
+
headers?: Record<string, string>
|
|
50
|
+
/**
|
|
51
|
+
* 最小分块大小,单位为字节,默认值 `8 * 1024 * 1024`
|
|
52
|
+
*
|
|
53
|
+
* - 分块太小容易造成强烈竞争
|
|
54
|
+
* - 当无法分块的时候会进入冗余竞争模式
|
|
55
|
+
*/
|
|
56
|
+
minChunkSize?: number
|
|
57
|
+
/**
|
|
58
|
+
* 写入缓冲区大小,单位为字节,默认值 `16 * 1024 * 1024`
|
|
59
|
+
*
|
|
60
|
+
* - 只对 [`WriteMethod::Std`] 写入方法有效,有利于将随机写入转换为顺序写入,提高写入速度
|
|
61
|
+
* - 对于 [`WriteMethod::Mmap`] 写入方法无效,因为写入缓冲区由系统决定
|
|
62
|
+
*/
|
|
63
|
+
writeBufferSize?: number
|
|
64
|
+
/**
|
|
65
|
+
* 写入队列容量,默认值 `10240`
|
|
66
|
+
*
|
|
67
|
+
* 如果下载线程太快,填满了写入队列,会触发压背,降低下载速度,防止内存占用过大
|
|
68
|
+
*/
|
|
69
|
+
writeQueueCap?: number
|
|
70
|
+
/**
|
|
71
|
+
* 请求失败后的默认重试间隔,默认值 `500ms`
|
|
72
|
+
*
|
|
73
|
+
* 如果服务器返回中有 `Retry-After` 头,则遵循服务器返回的设定
|
|
74
|
+
*/
|
|
75
|
+
retryGapMs?: number
|
|
76
|
+
/**
|
|
77
|
+
* 拉取超时时间,默认值 `5000ms`
|
|
78
|
+
*
|
|
79
|
+
* 请求发出后,接收字节中,如果在 `pull_timeout` 这一段时间内一个字节也没收到,则中断连接,重新请求。
|
|
80
|
+
* 有利于触发 TCP 重新检测拥塞状态,提高下载速度
|
|
81
|
+
*/
|
|
82
|
+
pullTimeoutMs?: number
|
|
83
|
+
/** 是否接受无效证书(危险),默认值 `false` */
|
|
84
|
+
acceptInvalidCerts?: boolean
|
|
85
|
+
/** 是否接受无效主机名(危险),默认值 `false` */
|
|
86
|
+
acceptInvalidHostnames?: boolean
|
|
87
|
+
/**
|
|
88
|
+
* 写入磁盘方式,默认值 [`WriteMethod::Mmap`]
|
|
89
|
+
*
|
|
90
|
+
* - [`WriteMethod::Mmap`] 写入方式速度最快,将写入交给操作系统执行,但是:
|
|
91
|
+
* 1. 在 32 位系统上最大只能映射 4GB 的文件,所以在 32 位系统上,会自动回退到 [`WriteMethod::Std`]
|
|
92
|
+
* 2. 必须知道文件大小,否则会自动回退到 [`WriteMethod::Std`]
|
|
93
|
+
* 3. 特殊情况下会出现系统把所有数据全部缓存在内存中,下载完成后一次性写入磁盘,造成下载完成后长时间卡顿
|
|
94
|
+
* - [`WriteMethod::Std`] 写入方式兼容性最好,会在 `write_buffer_size` 内对片段进行排序,尽量转换为顺序写入
|
|
95
|
+
*/
|
|
96
|
+
writeMethod?: WriteMethod
|
|
97
|
+
/** 设置获取元数据的重试次数,默认值 `10`。注意,这不是下载中的重试次数 */
|
|
98
|
+
retryTimes?: number
|
|
99
|
+
/**
|
|
100
|
+
* 使用哪些地址来发送请求,默认值 `Vec::new()`
|
|
101
|
+
*
|
|
102
|
+
* 如果你有多个网卡可用,可以填写他们的对外 IP 地址,请求会在这些 IP 地址上轮换,下载不一定会更快
|
|
103
|
+
*/
|
|
104
|
+
localAddress?: Array<string>
|
|
105
|
+
/**
|
|
106
|
+
* 冗余线程数,默认值 `3`
|
|
107
|
+
*
|
|
108
|
+
* 当块大小小于 `min_chunk_size` 后无法分块,进入冗余竞争模式。
|
|
109
|
+
* 最多有 `max_speculative` 个线程在同一分块上竞争下载,以解决下载卡进度 99% 的问题
|
|
110
|
+
*/
|
|
111
|
+
maxSpeculative?: number
|
|
112
|
+
/** 已经下载过的部分,如果你想下载整个文件,就传 `Vec::new()` */
|
|
113
|
+
downloadedChunk?: Array<Range>
|
|
114
|
+
/**
|
|
115
|
+
* 已下载分块的平滑窗口,单位为字节,默认值 `8 * 1024`
|
|
116
|
+
*
|
|
117
|
+
* 它会过滤掉 `downloaded_chunk` 中小于 `chunk_window` 的小空洞,以减小 HTTP 请求数量
|
|
118
|
+
*/
|
|
119
|
+
chunkWindow?: number
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface Event {
|
|
123
|
+
/** 事件类型 */
|
|
124
|
+
type: 'PrefetchError' | 'Pulling' | 'PullError' | 'PullTimeout' | 'PullProgress' | 'PushError' | 'PushProgress' | 'FlushError' | 'Finished'
|
|
125
|
+
/** 关联的线程 ID */
|
|
126
|
+
id?: number
|
|
127
|
+
/** 错误消息或描述 */
|
|
128
|
+
message?: string
|
|
129
|
+
/** 进度范围数据 */
|
|
130
|
+
range?: Range
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export declare function prefetch(url: string, config?: Config | undefined | null, token?: CancellationToken | undefined | null): Promise<DownloadTask>
|
|
134
|
+
|
|
135
|
+
/** 左闭右开 */
|
|
136
|
+
export interface Range {
|
|
137
|
+
start: number
|
|
138
|
+
end: number
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export declare const enum WriteMethod {
|
|
142
|
+
Mmap = 0,
|
|
143
|
+
Std = 1
|
|
144
|
+
}
|
package/index.js
ADDED
|
@@ -0,0 +1,564 @@
|
|
|
1
|
+
// prettier-ignore
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
/* auto-generated by NAPI-RS */
|
|
5
|
+
|
|
6
|
+
const { createRequire } = require('node:module')
|
|
7
|
+
require = createRequire(__filename)
|
|
8
|
+
|
|
9
|
+
const { readFileSync } = require('node:fs')
|
|
10
|
+
let nativeBinding = null
|
|
11
|
+
const loadErrors = []
|
|
12
|
+
|
|
13
|
+
const isMusl = () => {
|
|
14
|
+
let musl = false
|
|
15
|
+
if (process.platform === 'linux') {
|
|
16
|
+
musl = isMuslFromFilesystem()
|
|
17
|
+
if (musl === null) {
|
|
18
|
+
musl = isMuslFromReport()
|
|
19
|
+
}
|
|
20
|
+
if (musl === null) {
|
|
21
|
+
musl = isMuslFromChildProcess()
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return musl
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
|
|
28
|
+
|
|
29
|
+
const isMuslFromFilesystem = () => {
|
|
30
|
+
try {
|
|
31
|
+
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
|
|
32
|
+
} catch {
|
|
33
|
+
return null
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const isMuslFromReport = () => {
|
|
38
|
+
let report = null
|
|
39
|
+
if (typeof process.report?.getReport === 'function') {
|
|
40
|
+
process.report.excludeNetwork = true
|
|
41
|
+
report = process.report.getReport()
|
|
42
|
+
}
|
|
43
|
+
if (!report) {
|
|
44
|
+
return null
|
|
45
|
+
}
|
|
46
|
+
if (report.header && report.header.glibcVersionRuntime) {
|
|
47
|
+
return false
|
|
48
|
+
}
|
|
49
|
+
if (Array.isArray(report.sharedObjects)) {
|
|
50
|
+
if (report.sharedObjects.some(isFileMusl)) {
|
|
51
|
+
return true
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return false
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const isMuslFromChildProcess = () => {
|
|
58
|
+
try {
|
|
59
|
+
return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
|
|
60
|
+
} catch (e) {
|
|
61
|
+
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
|
|
62
|
+
return false
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function requireNative() {
|
|
67
|
+
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
|
|
68
|
+
try {
|
|
69
|
+
return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
|
|
70
|
+
} catch (err) {
|
|
71
|
+
loadErrors.push(err)
|
|
72
|
+
}
|
|
73
|
+
} else if (process.platform === 'android') {
|
|
74
|
+
if (process.arch === 'arm64') {
|
|
75
|
+
try {
|
|
76
|
+
return require('./fast-down.android-arm64.node')
|
|
77
|
+
} catch (e) {
|
|
78
|
+
loadErrors.push(e)
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
const binding = require('@fast-down/fast-down-android-arm64')
|
|
82
|
+
const bindingPackageVersion = require('@fast-down/fast-down-android-arm64/package.json').version
|
|
83
|
+
if (bindingPackageVersion !== '1.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
84
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
85
|
+
}
|
|
86
|
+
return binding
|
|
87
|
+
} catch (e) {
|
|
88
|
+
loadErrors.push(e)
|
|
89
|
+
}
|
|
90
|
+
} else if (process.arch === 'arm') {
|
|
91
|
+
try {
|
|
92
|
+
return require('./fast-down.android-arm-eabi.node')
|
|
93
|
+
} catch (e) {
|
|
94
|
+
loadErrors.push(e)
|
|
95
|
+
}
|
|
96
|
+
try {
|
|
97
|
+
const binding = require('@fast-down/fast-down-android-arm-eabi')
|
|
98
|
+
const bindingPackageVersion = require('@fast-down/fast-down-android-arm-eabi/package.json').version
|
|
99
|
+
if (bindingPackageVersion !== '1.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
100
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
101
|
+
}
|
|
102
|
+
return binding
|
|
103
|
+
} catch (e) {
|
|
104
|
+
loadErrors.push(e)
|
|
105
|
+
}
|
|
106
|
+
} else {
|
|
107
|
+
loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
|
|
108
|
+
}
|
|
109
|
+
} else if (process.platform === 'win32') {
|
|
110
|
+
if (process.arch === 'x64') {
|
|
111
|
+
try {
|
|
112
|
+
return require('./fast-down.win32-x64-msvc.node')
|
|
113
|
+
} catch (e) {
|
|
114
|
+
loadErrors.push(e)
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
const binding = require('@fast-down/fast-down-win32-x64-msvc')
|
|
118
|
+
const bindingPackageVersion = require('@fast-down/fast-down-win32-x64-msvc/package.json').version
|
|
119
|
+
if (bindingPackageVersion !== '1.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
120
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
121
|
+
}
|
|
122
|
+
return binding
|
|
123
|
+
} catch (e) {
|
|
124
|
+
loadErrors.push(e)
|
|
125
|
+
}
|
|
126
|
+
} else if (process.arch === 'ia32') {
|
|
127
|
+
try {
|
|
128
|
+
return require('./fast-down.win32-ia32-msvc.node')
|
|
129
|
+
} catch (e) {
|
|
130
|
+
loadErrors.push(e)
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
const binding = require('@fast-down/fast-down-win32-ia32-msvc')
|
|
134
|
+
const bindingPackageVersion = require('@fast-down/fast-down-win32-ia32-msvc/package.json').version
|
|
135
|
+
if (bindingPackageVersion !== '1.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
136
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
137
|
+
}
|
|
138
|
+
return binding
|
|
139
|
+
} catch (e) {
|
|
140
|
+
loadErrors.push(e)
|
|
141
|
+
}
|
|
142
|
+
} else if (process.arch === 'arm64') {
|
|
143
|
+
try {
|
|
144
|
+
return require('./fast-down.win32-arm64-msvc.node')
|
|
145
|
+
} catch (e) {
|
|
146
|
+
loadErrors.push(e)
|
|
147
|
+
}
|
|
148
|
+
try {
|
|
149
|
+
const binding = require('@fast-down/fast-down-win32-arm64-msvc')
|
|
150
|
+
const bindingPackageVersion = require('@fast-down/fast-down-win32-arm64-msvc/package.json').version
|
|
151
|
+
if (bindingPackageVersion !== '1.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
152
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
153
|
+
}
|
|
154
|
+
return binding
|
|
155
|
+
} catch (e) {
|
|
156
|
+
loadErrors.push(e)
|
|
157
|
+
}
|
|
158
|
+
} else {
|
|
159
|
+
loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
|
|
160
|
+
}
|
|
161
|
+
} else if (process.platform === 'darwin') {
|
|
162
|
+
try {
|
|
163
|
+
return require('./fast-down.darwin-universal.node')
|
|
164
|
+
} catch (e) {
|
|
165
|
+
loadErrors.push(e)
|
|
166
|
+
}
|
|
167
|
+
try {
|
|
168
|
+
const binding = require('@fast-down/fast-down-darwin-universal')
|
|
169
|
+
const bindingPackageVersion = require('@fast-down/fast-down-darwin-universal/package.json').version
|
|
170
|
+
if (bindingPackageVersion !== '1.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
171
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
172
|
+
}
|
|
173
|
+
return binding
|
|
174
|
+
} catch (e) {
|
|
175
|
+
loadErrors.push(e)
|
|
176
|
+
}
|
|
177
|
+
if (process.arch === 'x64') {
|
|
178
|
+
try {
|
|
179
|
+
return require('./fast-down.darwin-x64.node')
|
|
180
|
+
} catch (e) {
|
|
181
|
+
loadErrors.push(e)
|
|
182
|
+
}
|
|
183
|
+
try {
|
|
184
|
+
const binding = require('@fast-down/fast-down-darwin-x64')
|
|
185
|
+
const bindingPackageVersion = require('@fast-down/fast-down-darwin-x64/package.json').version
|
|
186
|
+
if (bindingPackageVersion !== '1.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
187
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
188
|
+
}
|
|
189
|
+
return binding
|
|
190
|
+
} catch (e) {
|
|
191
|
+
loadErrors.push(e)
|
|
192
|
+
}
|
|
193
|
+
} else if (process.arch === 'arm64') {
|
|
194
|
+
try {
|
|
195
|
+
return require('./fast-down.darwin-arm64.node')
|
|
196
|
+
} catch (e) {
|
|
197
|
+
loadErrors.push(e)
|
|
198
|
+
}
|
|
199
|
+
try {
|
|
200
|
+
const binding = require('@fast-down/fast-down-darwin-arm64')
|
|
201
|
+
const bindingPackageVersion = require('@fast-down/fast-down-darwin-arm64/package.json').version
|
|
202
|
+
if (bindingPackageVersion !== '1.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
203
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
204
|
+
}
|
|
205
|
+
return binding
|
|
206
|
+
} catch (e) {
|
|
207
|
+
loadErrors.push(e)
|
|
208
|
+
}
|
|
209
|
+
} else {
|
|
210
|
+
loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
|
|
211
|
+
}
|
|
212
|
+
} else if (process.platform === 'freebsd') {
|
|
213
|
+
if (process.arch === 'x64') {
|
|
214
|
+
try {
|
|
215
|
+
return require('./fast-down.freebsd-x64.node')
|
|
216
|
+
} catch (e) {
|
|
217
|
+
loadErrors.push(e)
|
|
218
|
+
}
|
|
219
|
+
try {
|
|
220
|
+
const binding = require('@fast-down/fast-down-freebsd-x64')
|
|
221
|
+
const bindingPackageVersion = require('@fast-down/fast-down-freebsd-x64/package.json').version
|
|
222
|
+
if (bindingPackageVersion !== '1.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
223
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
224
|
+
}
|
|
225
|
+
return binding
|
|
226
|
+
} catch (e) {
|
|
227
|
+
loadErrors.push(e)
|
|
228
|
+
}
|
|
229
|
+
} else if (process.arch === 'arm64') {
|
|
230
|
+
try {
|
|
231
|
+
return require('./fast-down.freebsd-arm64.node')
|
|
232
|
+
} catch (e) {
|
|
233
|
+
loadErrors.push(e)
|
|
234
|
+
}
|
|
235
|
+
try {
|
|
236
|
+
const binding = require('@fast-down/fast-down-freebsd-arm64')
|
|
237
|
+
const bindingPackageVersion = require('@fast-down/fast-down-freebsd-arm64/package.json').version
|
|
238
|
+
if (bindingPackageVersion !== '1.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
239
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
240
|
+
}
|
|
241
|
+
return binding
|
|
242
|
+
} catch (e) {
|
|
243
|
+
loadErrors.push(e)
|
|
244
|
+
}
|
|
245
|
+
} else {
|
|
246
|
+
loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
|
|
247
|
+
}
|
|
248
|
+
} else if (process.platform === 'linux') {
|
|
249
|
+
if (process.arch === 'x64') {
|
|
250
|
+
if (isMusl()) {
|
|
251
|
+
try {
|
|
252
|
+
return require('./fast-down.linux-x64-musl.node')
|
|
253
|
+
} catch (e) {
|
|
254
|
+
loadErrors.push(e)
|
|
255
|
+
}
|
|
256
|
+
try {
|
|
257
|
+
const binding = require('@fast-down/fast-down-linux-x64-musl')
|
|
258
|
+
const bindingPackageVersion = require('@fast-down/fast-down-linux-x64-musl/package.json').version
|
|
259
|
+
if (bindingPackageVersion !== '1.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
260
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
261
|
+
}
|
|
262
|
+
return binding
|
|
263
|
+
} catch (e) {
|
|
264
|
+
loadErrors.push(e)
|
|
265
|
+
}
|
|
266
|
+
} else {
|
|
267
|
+
try {
|
|
268
|
+
return require('./fast-down.linux-x64-gnu.node')
|
|
269
|
+
} catch (e) {
|
|
270
|
+
loadErrors.push(e)
|
|
271
|
+
}
|
|
272
|
+
try {
|
|
273
|
+
const binding = require('@fast-down/fast-down-linux-x64-gnu')
|
|
274
|
+
const bindingPackageVersion = require('@fast-down/fast-down-linux-x64-gnu/package.json').version
|
|
275
|
+
if (bindingPackageVersion !== '1.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
276
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
277
|
+
}
|
|
278
|
+
return binding
|
|
279
|
+
} catch (e) {
|
|
280
|
+
loadErrors.push(e)
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
} else if (process.arch === 'arm64') {
|
|
284
|
+
if (isMusl()) {
|
|
285
|
+
try {
|
|
286
|
+
return require('./fast-down.linux-arm64-musl.node')
|
|
287
|
+
} catch (e) {
|
|
288
|
+
loadErrors.push(e)
|
|
289
|
+
}
|
|
290
|
+
try {
|
|
291
|
+
const binding = require('@fast-down/fast-down-linux-arm64-musl')
|
|
292
|
+
const bindingPackageVersion = require('@fast-down/fast-down-linux-arm64-musl/package.json').version
|
|
293
|
+
if (bindingPackageVersion !== '1.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
294
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
295
|
+
}
|
|
296
|
+
return binding
|
|
297
|
+
} catch (e) {
|
|
298
|
+
loadErrors.push(e)
|
|
299
|
+
}
|
|
300
|
+
} else {
|
|
301
|
+
try {
|
|
302
|
+
return require('./fast-down.linux-arm64-gnu.node')
|
|
303
|
+
} catch (e) {
|
|
304
|
+
loadErrors.push(e)
|
|
305
|
+
}
|
|
306
|
+
try {
|
|
307
|
+
const binding = require('@fast-down/fast-down-linux-arm64-gnu')
|
|
308
|
+
const bindingPackageVersion = require('@fast-down/fast-down-linux-arm64-gnu/package.json').version
|
|
309
|
+
if (bindingPackageVersion !== '1.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
310
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
311
|
+
}
|
|
312
|
+
return binding
|
|
313
|
+
} catch (e) {
|
|
314
|
+
loadErrors.push(e)
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
} else if (process.arch === 'arm') {
|
|
318
|
+
if (isMusl()) {
|
|
319
|
+
try {
|
|
320
|
+
return require('./fast-down.linux-arm-musleabihf.node')
|
|
321
|
+
} catch (e) {
|
|
322
|
+
loadErrors.push(e)
|
|
323
|
+
}
|
|
324
|
+
try {
|
|
325
|
+
const binding = require('@fast-down/fast-down-linux-arm-musleabihf')
|
|
326
|
+
const bindingPackageVersion = require('@fast-down/fast-down-linux-arm-musleabihf/package.json').version
|
|
327
|
+
if (bindingPackageVersion !== '1.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
328
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
329
|
+
}
|
|
330
|
+
return binding
|
|
331
|
+
} catch (e) {
|
|
332
|
+
loadErrors.push(e)
|
|
333
|
+
}
|
|
334
|
+
} else {
|
|
335
|
+
try {
|
|
336
|
+
return require('./fast-down.linux-arm-gnueabihf.node')
|
|
337
|
+
} catch (e) {
|
|
338
|
+
loadErrors.push(e)
|
|
339
|
+
}
|
|
340
|
+
try {
|
|
341
|
+
const binding = require('@fast-down/fast-down-linux-arm-gnueabihf')
|
|
342
|
+
const bindingPackageVersion = require('@fast-down/fast-down-linux-arm-gnueabihf/package.json').version
|
|
343
|
+
if (bindingPackageVersion !== '1.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
344
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
345
|
+
}
|
|
346
|
+
return binding
|
|
347
|
+
} catch (e) {
|
|
348
|
+
loadErrors.push(e)
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
} else if (process.arch === 'loong64') {
|
|
352
|
+
if (isMusl()) {
|
|
353
|
+
try {
|
|
354
|
+
return require('./fast-down.linux-loong64-musl.node')
|
|
355
|
+
} catch (e) {
|
|
356
|
+
loadErrors.push(e)
|
|
357
|
+
}
|
|
358
|
+
try {
|
|
359
|
+
const binding = require('@fast-down/fast-down-linux-loong64-musl')
|
|
360
|
+
const bindingPackageVersion = require('@fast-down/fast-down-linux-loong64-musl/package.json').version
|
|
361
|
+
if (bindingPackageVersion !== '1.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
362
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
363
|
+
}
|
|
364
|
+
return binding
|
|
365
|
+
} catch (e) {
|
|
366
|
+
loadErrors.push(e)
|
|
367
|
+
}
|
|
368
|
+
} else {
|
|
369
|
+
try {
|
|
370
|
+
return require('./fast-down.linux-loong64-gnu.node')
|
|
371
|
+
} catch (e) {
|
|
372
|
+
loadErrors.push(e)
|
|
373
|
+
}
|
|
374
|
+
try {
|
|
375
|
+
const binding = require('@fast-down/fast-down-linux-loong64-gnu')
|
|
376
|
+
const bindingPackageVersion = require('@fast-down/fast-down-linux-loong64-gnu/package.json').version
|
|
377
|
+
if (bindingPackageVersion !== '1.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
378
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
379
|
+
}
|
|
380
|
+
return binding
|
|
381
|
+
} catch (e) {
|
|
382
|
+
loadErrors.push(e)
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
} else if (process.arch === 'riscv64') {
|
|
386
|
+
if (isMusl()) {
|
|
387
|
+
try {
|
|
388
|
+
return require('./fast-down.linux-riscv64-musl.node')
|
|
389
|
+
} catch (e) {
|
|
390
|
+
loadErrors.push(e)
|
|
391
|
+
}
|
|
392
|
+
try {
|
|
393
|
+
const binding = require('@fast-down/fast-down-linux-riscv64-musl')
|
|
394
|
+
const bindingPackageVersion = require('@fast-down/fast-down-linux-riscv64-musl/package.json').version
|
|
395
|
+
if (bindingPackageVersion !== '1.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
396
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
397
|
+
}
|
|
398
|
+
return binding
|
|
399
|
+
} catch (e) {
|
|
400
|
+
loadErrors.push(e)
|
|
401
|
+
}
|
|
402
|
+
} else {
|
|
403
|
+
try {
|
|
404
|
+
return require('./fast-down.linux-riscv64-gnu.node')
|
|
405
|
+
} catch (e) {
|
|
406
|
+
loadErrors.push(e)
|
|
407
|
+
}
|
|
408
|
+
try {
|
|
409
|
+
const binding = require('@fast-down/fast-down-linux-riscv64-gnu')
|
|
410
|
+
const bindingPackageVersion = require('@fast-down/fast-down-linux-riscv64-gnu/package.json').version
|
|
411
|
+
if (bindingPackageVersion !== '1.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
412
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
413
|
+
}
|
|
414
|
+
return binding
|
|
415
|
+
} catch (e) {
|
|
416
|
+
loadErrors.push(e)
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
} else if (process.arch === 'ppc64') {
|
|
420
|
+
try {
|
|
421
|
+
return require('./fast-down.linux-ppc64-gnu.node')
|
|
422
|
+
} catch (e) {
|
|
423
|
+
loadErrors.push(e)
|
|
424
|
+
}
|
|
425
|
+
try {
|
|
426
|
+
const binding = require('@fast-down/fast-down-linux-ppc64-gnu')
|
|
427
|
+
const bindingPackageVersion = require('@fast-down/fast-down-linux-ppc64-gnu/package.json').version
|
|
428
|
+
if (bindingPackageVersion !== '1.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
429
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
430
|
+
}
|
|
431
|
+
return binding
|
|
432
|
+
} catch (e) {
|
|
433
|
+
loadErrors.push(e)
|
|
434
|
+
}
|
|
435
|
+
} else if (process.arch === 's390x') {
|
|
436
|
+
try {
|
|
437
|
+
return require('./fast-down.linux-s390x-gnu.node')
|
|
438
|
+
} catch (e) {
|
|
439
|
+
loadErrors.push(e)
|
|
440
|
+
}
|
|
441
|
+
try {
|
|
442
|
+
const binding = require('@fast-down/fast-down-linux-s390x-gnu')
|
|
443
|
+
const bindingPackageVersion = require('@fast-down/fast-down-linux-s390x-gnu/package.json').version
|
|
444
|
+
if (bindingPackageVersion !== '1.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
445
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
446
|
+
}
|
|
447
|
+
return binding
|
|
448
|
+
} catch (e) {
|
|
449
|
+
loadErrors.push(e)
|
|
450
|
+
}
|
|
451
|
+
} else {
|
|
452
|
+
loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
|
|
453
|
+
}
|
|
454
|
+
} else if (process.platform === 'openharmony') {
|
|
455
|
+
if (process.arch === 'arm64') {
|
|
456
|
+
try {
|
|
457
|
+
return require('./fast-down.openharmony-arm64.node')
|
|
458
|
+
} catch (e) {
|
|
459
|
+
loadErrors.push(e)
|
|
460
|
+
}
|
|
461
|
+
try {
|
|
462
|
+
const binding = require('@fast-down/fast-down-openharmony-arm64')
|
|
463
|
+
const bindingPackageVersion = require('@fast-down/fast-down-openharmony-arm64/package.json').version
|
|
464
|
+
if (bindingPackageVersion !== '1.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
465
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
466
|
+
}
|
|
467
|
+
return binding
|
|
468
|
+
} catch (e) {
|
|
469
|
+
loadErrors.push(e)
|
|
470
|
+
}
|
|
471
|
+
} else if (process.arch === 'x64') {
|
|
472
|
+
try {
|
|
473
|
+
return require('./fast-down.openharmony-x64.node')
|
|
474
|
+
} catch (e) {
|
|
475
|
+
loadErrors.push(e)
|
|
476
|
+
}
|
|
477
|
+
try {
|
|
478
|
+
const binding = require('@fast-down/fast-down-openharmony-x64')
|
|
479
|
+
const bindingPackageVersion = require('@fast-down/fast-down-openharmony-x64/package.json').version
|
|
480
|
+
if (bindingPackageVersion !== '1.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
481
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
482
|
+
}
|
|
483
|
+
return binding
|
|
484
|
+
} catch (e) {
|
|
485
|
+
loadErrors.push(e)
|
|
486
|
+
}
|
|
487
|
+
} else if (process.arch === 'arm') {
|
|
488
|
+
try {
|
|
489
|
+
return require('./fast-down.openharmony-arm.node')
|
|
490
|
+
} catch (e) {
|
|
491
|
+
loadErrors.push(e)
|
|
492
|
+
}
|
|
493
|
+
try {
|
|
494
|
+
const binding = require('@fast-down/fast-down-openharmony-arm')
|
|
495
|
+
const bindingPackageVersion = require('@fast-down/fast-down-openharmony-arm/package.json').version
|
|
496
|
+
if (bindingPackageVersion !== '1.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
497
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
498
|
+
}
|
|
499
|
+
return binding
|
|
500
|
+
} catch (e) {
|
|
501
|
+
loadErrors.push(e)
|
|
502
|
+
}
|
|
503
|
+
} else {
|
|
504
|
+
loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`))
|
|
505
|
+
}
|
|
506
|
+
} else {
|
|
507
|
+
loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
nativeBinding = requireNative()
|
|
512
|
+
|
|
513
|
+
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
514
|
+
let wasiBinding = null
|
|
515
|
+
let wasiBindingError = null
|
|
516
|
+
try {
|
|
517
|
+
wasiBinding = require('./fast-down.wasi.cjs')
|
|
518
|
+
nativeBinding = wasiBinding
|
|
519
|
+
} catch (err) {
|
|
520
|
+
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
521
|
+
wasiBindingError = err
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
if (!nativeBinding) {
|
|
525
|
+
try {
|
|
526
|
+
wasiBinding = require('@fast-down/fast-down-wasm32-wasi')
|
|
527
|
+
nativeBinding = wasiBinding
|
|
528
|
+
} catch (err) {
|
|
529
|
+
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
530
|
+
wasiBindingError.cause = err
|
|
531
|
+
loadErrors.push(err)
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) {
|
|
536
|
+
const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error')
|
|
537
|
+
error.cause = wasiBindingError
|
|
538
|
+
throw error
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
if (!nativeBinding) {
|
|
543
|
+
if (loadErrors.length > 0) {
|
|
544
|
+
throw new Error(
|
|
545
|
+
`Cannot find native binding. ` +
|
|
546
|
+
`npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
|
|
547
|
+
'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
|
|
548
|
+
{
|
|
549
|
+
cause: loadErrors.reduce((err, cur) => {
|
|
550
|
+
cur.cause = err
|
|
551
|
+
return cur
|
|
552
|
+
}),
|
|
553
|
+
},
|
|
554
|
+
)
|
|
555
|
+
}
|
|
556
|
+
throw new Error(`Failed to load native binding`)
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
module.exports = nativeBinding
|
|
560
|
+
module.exports.CancellationToken = nativeBinding.CancellationToken
|
|
561
|
+
module.exports.DownloadTask = nativeBinding.DownloadTask
|
|
562
|
+
module.exports.UrlInfo = nativeBinding.UrlInfo
|
|
563
|
+
module.exports.prefetch = nativeBinding.prefetch
|
|
564
|
+
module.exports.WriteMethod = nativeBinding.WriteMethod
|
package/package.json
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fast-down/fast-down",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "fast-down 的 js 接口",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+ssh://git@github.com/fast-down/fast-down-js.git"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"download",
|
|
13
|
+
"Rust",
|
|
14
|
+
"node-addon"
|
|
15
|
+
],
|
|
16
|
+
"files": [
|
|
17
|
+
"index.d.ts",
|
|
18
|
+
"index.js"
|
|
19
|
+
],
|
|
20
|
+
"napi": {
|
|
21
|
+
"binaryName": "fast-down",
|
|
22
|
+
"targets": [
|
|
23
|
+
"x86_64-pc-windows-msvc",
|
|
24
|
+
"x86_64-apple-darwin",
|
|
25
|
+
"x86_64-unknown-linux-musl",
|
|
26
|
+
"aarch64-apple-darwin",
|
|
27
|
+
"aarch64-unknown-linux-musl",
|
|
28
|
+
"aarch64-pc-windows-msvc"
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">= 12.22.0 < 13 || >= 14.17.0 < 15 || >= 15.12.0 < 16 || >= 16.0.0"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"registry": "https://registry.npmjs.org/",
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"artifacts": "napi artifacts",
|
|
40
|
+
"build": "napi build --platform --release",
|
|
41
|
+
"build:debug": "napi build --platform",
|
|
42
|
+
"format": "run-p format:prettier format:rs format:toml",
|
|
43
|
+
"format:prettier": "prettier . -w",
|
|
44
|
+
"format:toml": "taplo format",
|
|
45
|
+
"format:rs": "cargo fmt",
|
|
46
|
+
"lint": "oxlint .",
|
|
47
|
+
"prepublishOnly": "napi prepublish -t npm",
|
|
48
|
+
"test": "ava",
|
|
49
|
+
"preversion": "napi build --platform && git add .",
|
|
50
|
+
"version": "napi version",
|
|
51
|
+
"prepare": "husky"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@emnapi/core": "^1.5.0",
|
|
55
|
+
"@emnapi/runtime": "^1.5.0",
|
|
56
|
+
"@napi-rs/cli": "^3.2.0",
|
|
57
|
+
"@oxc-node/core": "^0.0.35",
|
|
58
|
+
"@taplo/cli": "^0.7.0",
|
|
59
|
+
"@tybys/wasm-util": "^0.10.0",
|
|
60
|
+
"@types/node": "^25.3.2",
|
|
61
|
+
"ava": "^6.4.1",
|
|
62
|
+
"chalk": "^5.6.2",
|
|
63
|
+
"husky": "^9.1.7",
|
|
64
|
+
"lint-staged": "^16.1.6",
|
|
65
|
+
"npm-run-all2": "^8.0.4",
|
|
66
|
+
"oxlint": "^1.14.0",
|
|
67
|
+
"prettier": "^3.6.2",
|
|
68
|
+
"tinybench": "^6.0.0",
|
|
69
|
+
"typescript": "^5.9.2"
|
|
70
|
+
},
|
|
71
|
+
"lint-staged": {
|
|
72
|
+
"*.@(js|ts|tsx)": [
|
|
73
|
+
"oxlint --fix"
|
|
74
|
+
],
|
|
75
|
+
"*.@(js|ts|tsx|yml|yaml|md|json)": [
|
|
76
|
+
"prettier --write"
|
|
77
|
+
],
|
|
78
|
+
"*.toml": [
|
|
79
|
+
"taplo format"
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
"ava": {
|
|
83
|
+
"extensions": {
|
|
84
|
+
"ts": "module"
|
|
85
|
+
},
|
|
86
|
+
"timeout": "2m",
|
|
87
|
+
"workerThreads": false,
|
|
88
|
+
"environmentVariables": {
|
|
89
|
+
"OXC_TSCONFIG_PATH": "./__test__/tsconfig.json"
|
|
90
|
+
},
|
|
91
|
+
"nodeArguments": [
|
|
92
|
+
"--import",
|
|
93
|
+
"@oxc-node/core/register"
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
"prettier": {
|
|
97
|
+
"printWidth": 120,
|
|
98
|
+
"semi": false,
|
|
99
|
+
"trailingComma": "all",
|
|
100
|
+
"singleQuote": true,
|
|
101
|
+
"arrowParens": "always"
|
|
102
|
+
},
|
|
103
|
+
"packageManager": "yarn@4.12.0",
|
|
104
|
+
"optionalDependencies": {
|
|
105
|
+
"@fast-down/fast-down-win32-x64-msvc": "1.0.1",
|
|
106
|
+
"@fast-down/fast-down-darwin-x64": "1.0.1",
|
|
107
|
+
"@fast-down/fast-down-linux-x64-musl": "1.0.1",
|
|
108
|
+
"@fast-down/fast-down-darwin-arm64": "1.0.1",
|
|
109
|
+
"@fast-down/fast-down-linux-arm64-musl": "1.0.1",
|
|
110
|
+
"@fast-down/fast-down-win32-arm64-msvc": "1.0.1"
|
|
111
|
+
}
|
|
112
|
+
}
|