@fast-down/fast-down 1.0.2 → 1.0.5
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/dist/index.d.ts +7 -0
- package/dist/index.js +11 -0
- package/dist/merge.d.ts +2 -0
- package/dist/merge.js +37 -0
- package/dist/task.d.ts +40 -0
- package/dist/task.js +19 -0
- package/index.js +62 -80
- package/package.json +29 -19
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Config, Event, Range, UrlInfo, WriteMethod } from '../index.js';
|
|
2
|
+
import { DownloadTask } from './task.js';
|
|
3
|
+
export declare function prefetch(url: string, config?: Config & {
|
|
4
|
+
signal?: AbortSignal;
|
|
5
|
+
}): Promise<DownloadTask>;
|
|
6
|
+
export { Config, DownloadTask, Event, Range, UrlInfo, WriteMethod };
|
|
7
|
+
export * from './merge.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CancellationToken, UrlInfo, prefetch as rawPrefetch } from '../index.js';
|
|
2
|
+
import { DownloadTask } from './task.js';
|
|
3
|
+
export async function prefetch(url, config) {
|
|
4
|
+
if (!config?.signal)
|
|
5
|
+
return new DownloadTask(await rawPrefetch(url, config));
|
|
6
|
+
const token = new CancellationToken();
|
|
7
|
+
config.signal.addEventListener('abort', () => token.cancel());
|
|
8
|
+
return new DownloadTask(await rawPrefetch(url, config, token));
|
|
9
|
+
}
|
|
10
|
+
export { DownloadTask, UrlInfo };
|
|
11
|
+
export * from './merge.js';
|
package/dist/merge.d.ts
ADDED
package/dist/merge.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export function mergeProgress(arr, range) {
|
|
2
|
+
let { start: cStart, end: cEnd } = range;
|
|
3
|
+
let left = 0;
|
|
4
|
+
let right = arr.length;
|
|
5
|
+
while (left < right) {
|
|
6
|
+
const mid = Math.floor((left + right) / 2);
|
|
7
|
+
if (arr[mid].end < cStart)
|
|
8
|
+
left = mid + 1;
|
|
9
|
+
else
|
|
10
|
+
right = mid;
|
|
11
|
+
}
|
|
12
|
+
const i = left;
|
|
13
|
+
if (i === arr.length) {
|
|
14
|
+
arr.push({ start: cStart, end: cEnd });
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (arr[i].start <= cStart && arr[i].end >= cEnd)
|
|
18
|
+
return;
|
|
19
|
+
let j = i;
|
|
20
|
+
while (j < arr.length) {
|
|
21
|
+
let entry = arr[j];
|
|
22
|
+
if (entry.start > cEnd)
|
|
23
|
+
break;
|
|
24
|
+
if (entry.start < cStart)
|
|
25
|
+
cStart = entry.start;
|
|
26
|
+
if (entry.end > cEnd)
|
|
27
|
+
cEnd = entry.end;
|
|
28
|
+
j++;
|
|
29
|
+
}
|
|
30
|
+
let deleteCount = j - i;
|
|
31
|
+
if (deleteCount === 1) {
|
|
32
|
+
arr[i].start = cStart;
|
|
33
|
+
arr[i].end = cEnd;
|
|
34
|
+
}
|
|
35
|
+
else
|
|
36
|
+
arr.splice(i, deleteCount, { start: cStart, end: cEnd });
|
|
37
|
+
}
|
package/dist/task.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { DownloadTask as RawDownloadTask, Range } from '../index.js';
|
|
2
|
+
export type Event = {
|
|
3
|
+
type: 'PrefetchError';
|
|
4
|
+
message: string;
|
|
5
|
+
} | {
|
|
6
|
+
type: 'Pulling';
|
|
7
|
+
id: number;
|
|
8
|
+
} | {
|
|
9
|
+
type: 'PullError';
|
|
10
|
+
id: number;
|
|
11
|
+
message: string;
|
|
12
|
+
} | {
|
|
13
|
+
type: 'PullTimeout';
|
|
14
|
+
id: number;
|
|
15
|
+
} | {
|
|
16
|
+
type: 'PullProgress';
|
|
17
|
+
id: number;
|
|
18
|
+
range: Range;
|
|
19
|
+
} | {
|
|
20
|
+
type: 'PushError';
|
|
21
|
+
id: number;
|
|
22
|
+
message: string;
|
|
23
|
+
} | {
|
|
24
|
+
type: 'PushProgress';
|
|
25
|
+
id: number;
|
|
26
|
+
range: Range;
|
|
27
|
+
} | {
|
|
28
|
+
type: 'FlushError';
|
|
29
|
+
message: string;
|
|
30
|
+
} | {
|
|
31
|
+
type: 'Finished';
|
|
32
|
+
id: number;
|
|
33
|
+
};
|
|
34
|
+
export declare class DownloadTask {
|
|
35
|
+
private _rawTask;
|
|
36
|
+
constructor(_rawTask: RawDownloadTask);
|
|
37
|
+
get info(): import("./index.js").UrlInfo;
|
|
38
|
+
cancel(): void;
|
|
39
|
+
start(savePath: string, callback?: (event: Event) => void): Promise<void>;
|
|
40
|
+
}
|
package/dist/task.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export class DownloadTask {
|
|
2
|
+
_rawTask;
|
|
3
|
+
constructor(_rawTask) {
|
|
4
|
+
this._rawTask = _rawTask;
|
|
5
|
+
}
|
|
6
|
+
get info() {
|
|
7
|
+
return this._rawTask.info;
|
|
8
|
+
}
|
|
9
|
+
cancel() {
|
|
10
|
+
this._rawTask.cancel();
|
|
11
|
+
}
|
|
12
|
+
async start(savePath, callback) {
|
|
13
|
+
if (!callback)
|
|
14
|
+
return this._rawTask.start(savePath);
|
|
15
|
+
return this._rawTask.start(savePath, (rawEvent) => {
|
|
16
|
+
callback(rawEvent);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
package/index.js
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
/* auto-generated by NAPI-RS */
|
|
5
5
|
|
|
6
|
+
import { createRequire } from 'node:module'
|
|
7
|
+
const require = createRequire(import.meta.url)
|
|
8
|
+
const __dirname = new URL('.', import.meta.url).pathname
|
|
9
|
+
|
|
6
10
|
const { readFileSync } = require('node:fs')
|
|
7
11
|
let nativeBinding = null
|
|
8
12
|
const loadErrors = []
|
|
@@ -77,8 +81,8 @@ function requireNative() {
|
|
|
77
81
|
try {
|
|
78
82
|
const binding = require('@fast-down/fast-down-android-arm64')
|
|
79
83
|
const bindingPackageVersion = require('@fast-down/fast-down-android-arm64/package.json').version
|
|
80
|
-
if (bindingPackageVersion !== '1.0.
|
|
81
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.
|
|
84
|
+
if (bindingPackageVersion !== '1.0.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
85
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
82
86
|
}
|
|
83
87
|
return binding
|
|
84
88
|
} catch (e) {
|
|
@@ -93,8 +97,8 @@ function requireNative() {
|
|
|
93
97
|
try {
|
|
94
98
|
const binding = require('@fast-down/fast-down-android-arm-eabi')
|
|
95
99
|
const bindingPackageVersion = require('@fast-down/fast-down-android-arm-eabi/package.json').version
|
|
96
|
-
if (bindingPackageVersion !== '1.0.
|
|
97
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.
|
|
100
|
+
if (bindingPackageVersion !== '1.0.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
101
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
98
102
|
}
|
|
99
103
|
return binding
|
|
100
104
|
} catch (e) {
|
|
@@ -105,24 +109,7 @@ function requireNative() {
|
|
|
105
109
|
}
|
|
106
110
|
} else if (process.platform === 'win32') {
|
|
107
111
|
if (process.arch === 'x64') {
|
|
108
|
-
if (process.config?.variables?.shlib_suffix === 'dll.a' || process.config?.variables?.node_target_type === 'shared_library') {
|
|
109
|
-
try {
|
|
110
|
-
return require('./fast-down.win32-x64-gnu.node')
|
|
111
|
-
} catch (e) {
|
|
112
|
-
loadErrors.push(e)
|
|
113
|
-
}
|
|
114
112
|
try {
|
|
115
|
-
const binding = require('@fast-down/fast-down-win32-x64-gnu')
|
|
116
|
-
const bindingPackageVersion = require('@fast-down/fast-down-win32-x64-gnu/package.json').version
|
|
117
|
-
if (bindingPackageVersion !== '1.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
118
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
119
|
-
}
|
|
120
|
-
return binding
|
|
121
|
-
} catch (e) {
|
|
122
|
-
loadErrors.push(e)
|
|
123
|
-
}
|
|
124
|
-
} else {
|
|
125
|
-
try {
|
|
126
113
|
return require('./fast-down.win32-x64-msvc.node')
|
|
127
114
|
} catch (e) {
|
|
128
115
|
loadErrors.push(e)
|
|
@@ -130,14 +117,13 @@ function requireNative() {
|
|
|
130
117
|
try {
|
|
131
118
|
const binding = require('@fast-down/fast-down-win32-x64-msvc')
|
|
132
119
|
const bindingPackageVersion = require('@fast-down/fast-down-win32-x64-msvc/package.json').version
|
|
133
|
-
if (bindingPackageVersion !== '1.0.
|
|
134
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.
|
|
120
|
+
if (bindingPackageVersion !== '1.0.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
121
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
135
122
|
}
|
|
136
123
|
return binding
|
|
137
124
|
} catch (e) {
|
|
138
125
|
loadErrors.push(e)
|
|
139
126
|
}
|
|
140
|
-
}
|
|
141
127
|
} else if (process.arch === 'ia32') {
|
|
142
128
|
try {
|
|
143
129
|
return require('./fast-down.win32-ia32-msvc.node')
|
|
@@ -147,8 +133,8 @@ function requireNative() {
|
|
|
147
133
|
try {
|
|
148
134
|
const binding = require('@fast-down/fast-down-win32-ia32-msvc')
|
|
149
135
|
const bindingPackageVersion = require('@fast-down/fast-down-win32-ia32-msvc/package.json').version
|
|
150
|
-
if (bindingPackageVersion !== '1.0.
|
|
151
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.
|
|
136
|
+
if (bindingPackageVersion !== '1.0.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
137
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
152
138
|
}
|
|
153
139
|
return binding
|
|
154
140
|
} catch (e) {
|
|
@@ -163,8 +149,8 @@ function requireNative() {
|
|
|
163
149
|
try {
|
|
164
150
|
const binding = require('@fast-down/fast-down-win32-arm64-msvc')
|
|
165
151
|
const bindingPackageVersion = require('@fast-down/fast-down-win32-arm64-msvc/package.json').version
|
|
166
|
-
if (bindingPackageVersion !== '1.0.
|
|
167
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.
|
|
152
|
+
if (bindingPackageVersion !== '1.0.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
153
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
168
154
|
}
|
|
169
155
|
return binding
|
|
170
156
|
} catch (e) {
|
|
@@ -182,8 +168,8 @@ function requireNative() {
|
|
|
182
168
|
try {
|
|
183
169
|
const binding = require('@fast-down/fast-down-darwin-universal')
|
|
184
170
|
const bindingPackageVersion = require('@fast-down/fast-down-darwin-universal/package.json').version
|
|
185
|
-
if (bindingPackageVersion !== '1.0.
|
|
186
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.
|
|
171
|
+
if (bindingPackageVersion !== '1.0.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
172
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
187
173
|
}
|
|
188
174
|
return binding
|
|
189
175
|
} catch (e) {
|
|
@@ -198,8 +184,8 @@ function requireNative() {
|
|
|
198
184
|
try {
|
|
199
185
|
const binding = require('@fast-down/fast-down-darwin-x64')
|
|
200
186
|
const bindingPackageVersion = require('@fast-down/fast-down-darwin-x64/package.json').version
|
|
201
|
-
if (bindingPackageVersion !== '1.0.
|
|
202
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.
|
|
187
|
+
if (bindingPackageVersion !== '1.0.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
188
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
203
189
|
}
|
|
204
190
|
return binding
|
|
205
191
|
} catch (e) {
|
|
@@ -214,8 +200,8 @@ function requireNative() {
|
|
|
214
200
|
try {
|
|
215
201
|
const binding = require('@fast-down/fast-down-darwin-arm64')
|
|
216
202
|
const bindingPackageVersion = require('@fast-down/fast-down-darwin-arm64/package.json').version
|
|
217
|
-
if (bindingPackageVersion !== '1.0.
|
|
218
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.
|
|
203
|
+
if (bindingPackageVersion !== '1.0.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
204
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
219
205
|
}
|
|
220
206
|
return binding
|
|
221
207
|
} catch (e) {
|
|
@@ -234,8 +220,8 @@ function requireNative() {
|
|
|
234
220
|
try {
|
|
235
221
|
const binding = require('@fast-down/fast-down-freebsd-x64')
|
|
236
222
|
const bindingPackageVersion = require('@fast-down/fast-down-freebsd-x64/package.json').version
|
|
237
|
-
if (bindingPackageVersion !== '1.0.
|
|
238
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.
|
|
223
|
+
if (bindingPackageVersion !== '1.0.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
224
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
239
225
|
}
|
|
240
226
|
return binding
|
|
241
227
|
} catch (e) {
|
|
@@ -250,8 +236,8 @@ function requireNative() {
|
|
|
250
236
|
try {
|
|
251
237
|
const binding = require('@fast-down/fast-down-freebsd-arm64')
|
|
252
238
|
const bindingPackageVersion = require('@fast-down/fast-down-freebsd-arm64/package.json').version
|
|
253
|
-
if (bindingPackageVersion !== '1.0.
|
|
254
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.
|
|
239
|
+
if (bindingPackageVersion !== '1.0.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
240
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
255
241
|
}
|
|
256
242
|
return binding
|
|
257
243
|
} catch (e) {
|
|
@@ -271,8 +257,8 @@ function requireNative() {
|
|
|
271
257
|
try {
|
|
272
258
|
const binding = require('@fast-down/fast-down-linux-x64-musl')
|
|
273
259
|
const bindingPackageVersion = require('@fast-down/fast-down-linux-x64-musl/package.json').version
|
|
274
|
-
if (bindingPackageVersion !== '1.0.
|
|
275
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.
|
|
260
|
+
if (bindingPackageVersion !== '1.0.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
261
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
276
262
|
}
|
|
277
263
|
return binding
|
|
278
264
|
} catch (e) {
|
|
@@ -287,8 +273,8 @@ function requireNative() {
|
|
|
287
273
|
try {
|
|
288
274
|
const binding = require('@fast-down/fast-down-linux-x64-gnu')
|
|
289
275
|
const bindingPackageVersion = require('@fast-down/fast-down-linux-x64-gnu/package.json').version
|
|
290
|
-
if (bindingPackageVersion !== '1.0.
|
|
291
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.
|
|
276
|
+
if (bindingPackageVersion !== '1.0.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
277
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
292
278
|
}
|
|
293
279
|
return binding
|
|
294
280
|
} catch (e) {
|
|
@@ -305,8 +291,8 @@ function requireNative() {
|
|
|
305
291
|
try {
|
|
306
292
|
const binding = require('@fast-down/fast-down-linux-arm64-musl')
|
|
307
293
|
const bindingPackageVersion = require('@fast-down/fast-down-linux-arm64-musl/package.json').version
|
|
308
|
-
if (bindingPackageVersion !== '1.0.
|
|
309
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.
|
|
294
|
+
if (bindingPackageVersion !== '1.0.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
295
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
310
296
|
}
|
|
311
297
|
return binding
|
|
312
298
|
} catch (e) {
|
|
@@ -321,8 +307,8 @@ function requireNative() {
|
|
|
321
307
|
try {
|
|
322
308
|
const binding = require('@fast-down/fast-down-linux-arm64-gnu')
|
|
323
309
|
const bindingPackageVersion = require('@fast-down/fast-down-linux-arm64-gnu/package.json').version
|
|
324
|
-
if (bindingPackageVersion !== '1.0.
|
|
325
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.
|
|
310
|
+
if (bindingPackageVersion !== '1.0.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
311
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
326
312
|
}
|
|
327
313
|
return binding
|
|
328
314
|
} catch (e) {
|
|
@@ -339,8 +325,8 @@ function requireNative() {
|
|
|
339
325
|
try {
|
|
340
326
|
const binding = require('@fast-down/fast-down-linux-arm-musleabihf')
|
|
341
327
|
const bindingPackageVersion = require('@fast-down/fast-down-linux-arm-musleabihf/package.json').version
|
|
342
|
-
if (bindingPackageVersion !== '1.0.
|
|
343
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.
|
|
328
|
+
if (bindingPackageVersion !== '1.0.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
329
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
344
330
|
}
|
|
345
331
|
return binding
|
|
346
332
|
} catch (e) {
|
|
@@ -355,8 +341,8 @@ function requireNative() {
|
|
|
355
341
|
try {
|
|
356
342
|
const binding = require('@fast-down/fast-down-linux-arm-gnueabihf')
|
|
357
343
|
const bindingPackageVersion = require('@fast-down/fast-down-linux-arm-gnueabihf/package.json').version
|
|
358
|
-
if (bindingPackageVersion !== '1.0.
|
|
359
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.
|
|
344
|
+
if (bindingPackageVersion !== '1.0.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
345
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
360
346
|
}
|
|
361
347
|
return binding
|
|
362
348
|
} catch (e) {
|
|
@@ -373,8 +359,8 @@ function requireNative() {
|
|
|
373
359
|
try {
|
|
374
360
|
const binding = require('@fast-down/fast-down-linux-loong64-musl')
|
|
375
361
|
const bindingPackageVersion = require('@fast-down/fast-down-linux-loong64-musl/package.json').version
|
|
376
|
-
if (bindingPackageVersion !== '1.0.
|
|
377
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.
|
|
362
|
+
if (bindingPackageVersion !== '1.0.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
363
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
378
364
|
}
|
|
379
365
|
return binding
|
|
380
366
|
} catch (e) {
|
|
@@ -389,8 +375,8 @@ function requireNative() {
|
|
|
389
375
|
try {
|
|
390
376
|
const binding = require('@fast-down/fast-down-linux-loong64-gnu')
|
|
391
377
|
const bindingPackageVersion = require('@fast-down/fast-down-linux-loong64-gnu/package.json').version
|
|
392
|
-
if (bindingPackageVersion !== '1.0.
|
|
393
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.
|
|
378
|
+
if (bindingPackageVersion !== '1.0.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
379
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
394
380
|
}
|
|
395
381
|
return binding
|
|
396
382
|
} catch (e) {
|
|
@@ -407,8 +393,8 @@ function requireNative() {
|
|
|
407
393
|
try {
|
|
408
394
|
const binding = require('@fast-down/fast-down-linux-riscv64-musl')
|
|
409
395
|
const bindingPackageVersion = require('@fast-down/fast-down-linux-riscv64-musl/package.json').version
|
|
410
|
-
if (bindingPackageVersion !== '1.0.
|
|
411
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.
|
|
396
|
+
if (bindingPackageVersion !== '1.0.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
397
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
412
398
|
}
|
|
413
399
|
return binding
|
|
414
400
|
} catch (e) {
|
|
@@ -423,8 +409,8 @@ function requireNative() {
|
|
|
423
409
|
try {
|
|
424
410
|
const binding = require('@fast-down/fast-down-linux-riscv64-gnu')
|
|
425
411
|
const bindingPackageVersion = require('@fast-down/fast-down-linux-riscv64-gnu/package.json').version
|
|
426
|
-
if (bindingPackageVersion !== '1.0.
|
|
427
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.
|
|
412
|
+
if (bindingPackageVersion !== '1.0.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
413
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
428
414
|
}
|
|
429
415
|
return binding
|
|
430
416
|
} catch (e) {
|
|
@@ -440,8 +426,8 @@ function requireNative() {
|
|
|
440
426
|
try {
|
|
441
427
|
const binding = require('@fast-down/fast-down-linux-ppc64-gnu')
|
|
442
428
|
const bindingPackageVersion = require('@fast-down/fast-down-linux-ppc64-gnu/package.json').version
|
|
443
|
-
if (bindingPackageVersion !== '1.0.
|
|
444
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.
|
|
429
|
+
if (bindingPackageVersion !== '1.0.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
430
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
445
431
|
}
|
|
446
432
|
return binding
|
|
447
433
|
} catch (e) {
|
|
@@ -456,8 +442,8 @@ function requireNative() {
|
|
|
456
442
|
try {
|
|
457
443
|
const binding = require('@fast-down/fast-down-linux-s390x-gnu')
|
|
458
444
|
const bindingPackageVersion = require('@fast-down/fast-down-linux-s390x-gnu/package.json').version
|
|
459
|
-
if (bindingPackageVersion !== '1.0.
|
|
460
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.
|
|
445
|
+
if (bindingPackageVersion !== '1.0.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
446
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
461
447
|
}
|
|
462
448
|
return binding
|
|
463
449
|
} catch (e) {
|
|
@@ -476,8 +462,8 @@ function requireNative() {
|
|
|
476
462
|
try {
|
|
477
463
|
const binding = require('@fast-down/fast-down-openharmony-arm64')
|
|
478
464
|
const bindingPackageVersion = require('@fast-down/fast-down-openharmony-arm64/package.json').version
|
|
479
|
-
if (bindingPackageVersion !== '1.0.
|
|
480
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.
|
|
465
|
+
if (bindingPackageVersion !== '1.0.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
466
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
481
467
|
}
|
|
482
468
|
return binding
|
|
483
469
|
} catch (e) {
|
|
@@ -492,8 +478,8 @@ function requireNative() {
|
|
|
492
478
|
try {
|
|
493
479
|
const binding = require('@fast-down/fast-down-openharmony-x64')
|
|
494
480
|
const bindingPackageVersion = require('@fast-down/fast-down-openharmony-x64/package.json').version
|
|
495
|
-
if (bindingPackageVersion !== '1.0.
|
|
496
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.
|
|
481
|
+
if (bindingPackageVersion !== '1.0.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
482
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
497
483
|
}
|
|
498
484
|
return binding
|
|
499
485
|
} catch (e) {
|
|
@@ -508,8 +494,8 @@ function requireNative() {
|
|
|
508
494
|
try {
|
|
509
495
|
const binding = require('@fast-down/fast-down-openharmony-arm')
|
|
510
496
|
const bindingPackageVersion = require('@fast-down/fast-down-openharmony-arm/package.json').version
|
|
511
|
-
if (bindingPackageVersion !== '1.0.
|
|
512
|
-
throw new Error(`Native binding package version mismatch, expected 1.0.
|
|
497
|
+
if (bindingPackageVersion !== '1.0.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
498
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
513
499
|
}
|
|
514
500
|
return binding
|
|
515
501
|
} catch (e) {
|
|
@@ -536,17 +522,13 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
|
536
522
|
wasiBindingError = err
|
|
537
523
|
}
|
|
538
524
|
}
|
|
539
|
-
if (!nativeBinding
|
|
525
|
+
if (!nativeBinding) {
|
|
540
526
|
try {
|
|
541
527
|
wasiBinding = require('@fast-down/fast-down-wasm32-wasi')
|
|
542
528
|
nativeBinding = wasiBinding
|
|
543
529
|
} catch (err) {
|
|
544
530
|
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
545
|
-
|
|
546
|
-
wasiBindingError = err
|
|
547
|
-
} else {
|
|
548
|
-
wasiBindingError.cause = err
|
|
549
|
-
}
|
|
531
|
+
wasiBindingError.cause = err
|
|
550
532
|
loadErrors.push(err)
|
|
551
533
|
}
|
|
552
534
|
}
|
|
@@ -575,9 +557,9 @@ if (!nativeBinding) {
|
|
|
575
557
|
throw new Error(`Failed to load native binding`)
|
|
576
558
|
}
|
|
577
559
|
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
560
|
+
const { CancellationToken, DownloadTask, UrlInfo, prefetch, WriteMethod } = nativeBinding
|
|
561
|
+
export { CancellationToken }
|
|
562
|
+
export { DownloadTask }
|
|
563
|
+
export { UrlInfo }
|
|
564
|
+
export { prefetch }
|
|
565
|
+
export { WriteMethod }
|
package/package.json
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fast-down/fast-down",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "fast-down 的 js 接口",
|
|
5
|
-
"main": "index.js",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
6
14
|
"repository": {
|
|
7
15
|
"type": "git",
|
|
8
16
|
"url": "git+ssh://git@github.com/fast-down/fast-down-js.git"
|
|
@@ -14,6 +22,7 @@
|
|
|
14
22
|
"node-addon"
|
|
15
23
|
],
|
|
16
24
|
"files": [
|
|
25
|
+
"dist",
|
|
17
26
|
"index.d.ts",
|
|
18
27
|
"index.js"
|
|
19
28
|
],
|
|
@@ -44,16 +53,17 @@
|
|
|
44
53
|
},
|
|
45
54
|
"scripts": {
|
|
46
55
|
"artifacts": "napi artifacts",
|
|
47
|
-
"build": "napi build --platform --release",
|
|
48
|
-
"build:debug": "napi build --platform",
|
|
56
|
+
"build": "napi build --platform --release --esm",
|
|
57
|
+
"build:debug": "napi build --platform --esm",
|
|
58
|
+
"build:ts": "tsc",
|
|
49
59
|
"format": "run-p format:prettier format:rs format:toml",
|
|
50
60
|
"format:prettier": "prettier . -w",
|
|
51
61
|
"format:toml": "taplo format",
|
|
52
62
|
"format:rs": "cargo fmt",
|
|
53
63
|
"lint": "oxlint .",
|
|
54
|
-
"prepublishOnly": "napi prepublish -t npm",
|
|
64
|
+
"prepublishOnly": "yarn build:ts && napi prepublish -t npm",
|
|
55
65
|
"test": "ava",
|
|
56
|
-
"preversion": "
|
|
66
|
+
"preversion": "yarn build && yarn build:ts && git add .",
|
|
57
67
|
"version": "napi version",
|
|
58
68
|
"prepare": "husky"
|
|
59
69
|
},
|
|
@@ -109,18 +119,18 @@
|
|
|
109
119
|
},
|
|
110
120
|
"packageManager": "yarn@4.12.0",
|
|
111
121
|
"optionalDependencies": {
|
|
112
|
-
"@fast-down/fast-down-win32-x64-msvc": "1.0.
|
|
113
|
-
"@fast-down/fast-down-darwin-x64": "1.0.
|
|
114
|
-
"@fast-down/fast-down-linux-x64-gnu": "1.0.
|
|
115
|
-
"@fast-down/fast-down-linux-x64-musl": "1.0.
|
|
116
|
-
"@fast-down/fast-down-linux-arm64-gnu": "1.0.
|
|
117
|
-
"@fast-down/fast-down-win32-ia32-msvc": "1.0.
|
|
118
|
-
"@fast-down/fast-down-linux-arm-gnueabihf": "1.0.
|
|
119
|
-
"@fast-down/fast-down-darwin-arm64": "1.0.
|
|
120
|
-
"@fast-down/fast-down-android-arm64": "1.0.
|
|
121
|
-
"@fast-down/fast-down-freebsd-x64": "1.0.
|
|
122
|
-
"@fast-down/fast-down-linux-arm64-musl": "1.0.
|
|
123
|
-
"@fast-down/fast-down-win32-arm64-msvc": "1.0.
|
|
124
|
-
"@fast-down/fast-down-android-arm-eabi": "1.0.
|
|
122
|
+
"@fast-down/fast-down-win32-x64-msvc": "1.0.5",
|
|
123
|
+
"@fast-down/fast-down-darwin-x64": "1.0.5",
|
|
124
|
+
"@fast-down/fast-down-linux-x64-gnu": "1.0.5",
|
|
125
|
+
"@fast-down/fast-down-linux-x64-musl": "1.0.5",
|
|
126
|
+
"@fast-down/fast-down-linux-arm64-gnu": "1.0.5",
|
|
127
|
+
"@fast-down/fast-down-win32-ia32-msvc": "1.0.5",
|
|
128
|
+
"@fast-down/fast-down-linux-arm-gnueabihf": "1.0.5",
|
|
129
|
+
"@fast-down/fast-down-darwin-arm64": "1.0.5",
|
|
130
|
+
"@fast-down/fast-down-android-arm64": "1.0.5",
|
|
131
|
+
"@fast-down/fast-down-freebsd-x64": "1.0.5",
|
|
132
|
+
"@fast-down/fast-down-linux-arm64-musl": "1.0.5",
|
|
133
|
+
"@fast-down/fast-down-win32-arm64-msvc": "1.0.5",
|
|
134
|
+
"@fast-down/fast-down-android-arm-eabi": "1.0.5"
|
|
125
135
|
}
|
|
126
136
|
}
|