npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@xunlei-open/dlsdk

v1.0.2

Published

迅雷 XL Download Node SDK。

Readme

迅雷下载 Node.js SDK 指南

XL Download Node.js SDK 适用于在 Node.js 桌面工具(例如 Electron 应用)中接入迅雷下载能力,支持 TypeScript 和 JavaScript 调用。

支持平台

| Windows x64 | Windows x86 | macOS Universal | Linux x64 | | --- | --- | --- | --- | | ✅ | ✅ | ✅ | ✅ |

环境要求

  • Node.js 18 或更高版本。

包说明

  • @xunlei-open/dlsdk:主 API 包。
  • @xunlei-open/dlsdk-native-windows-x64
  • @xunlei-open/dlsdk-native-windows-x86
  • @xunlei-open/dlsdk-native-macos-universal
  • @xunlei-open/dlsdk-native-linux-x64

npm 安装

在应用项目中安装主包,并按应用要支持的平台安装对应 native 包。跨平台应用可以同时安装多个 native 包,运行时会加载当前平台对应的动态库。

| 目标平台 | 安装命令 | | --- | --- | | Windows x64 | npm install @xunlei-open/dlsdk @xunlei-open/dlsdk-native-windows-x64 | | Windows x86 | npm install @xunlei-open/dlsdk @xunlei-open/dlsdk-native-windows-x86 | | macOS Universal | npm install @xunlei-open/dlsdk @xunlei-open/dlsdk-native-macos-universal | | Linux x64 | npm install @xunlei-open/dlsdk @xunlei-open/dlsdk-native-linux-x64 |

例如接入 Windows x64:

npm install @xunlei-open/dlsdk @xunlei-open/dlsdk-native-windows-x64

最小示例

import fs from "node:fs";
import { XLDownloadAPI, ERROR_ALREADY_INIT, ERROR_SUCCESS, TASK_STATUS_SUCCEEDED, TASK_STATUS_FAILED } from "@xunlei-open/dlsdk";

const appId = "your-app-id";
const apiKey = "your-api-key";
const configPath = "/tmp/xl_dl_sdk_conf";
const savePath = "/tmp/ThunderDownload";

fs.mkdirSync(configPath, { recursive: true });
fs.mkdirSync(savePath, { recursive: true });

const sdk = new XLDownloadAPI();

let initialized = false;
try {
  const initResult = sdk.init({
    appId,
    appVersion: "1.0",
    configPath,
    saveTasks: true
  });
  if (initResult !== ERROR_SUCCESS && initResult !== ERROR_ALREADY_INIT) {
    throw new Error(`init failed: ${initResult}`);
  }
  initialized = true;

  const token = await sdk.getLoginToken(apiKey);
  const login = sdk.login(token.token);
  if (login.result !== ERROR_SUCCESS) {
    throw new Error(`login failed: ${login.result}`);
  }

  const task = sdk.createP2spTask({
    url: "https://example.com/file.zip",
    savePath,
    saveName: "file.zip"
  });

  if (task.result !== ERROR_SUCCESS) {
    throw new Error(`create task failed: ${task.result}`);
  }

  const startResult = sdk.startTask(task.taskId);
  if (startResult !== ERROR_SUCCESS) {
    throw new Error(`start task failed: ${startResult}`);
  }

  while (true) {
    const state = sdk.getTaskState(task.taskId);
    process.stdout.write(`\rstate:${state.state.stateCode} downloaded:${state.state.downloadedSize}/${state.state.totalSize} speed:${state.state.speed}`);
    if (
      state.result !== ERROR_SUCCESS ||
      state.state.stateCode === TASK_STATUS_SUCCEEDED ||
      state.state.stateCode === TASK_STATUS_FAILED
    ) {
      console.log();
      break;
    }
    await new Promise(resolve => setTimeout(resolve, 1000));
  }
} finally {
  if (initialized) {
    sdk.uninit();
  }
}

完整可运行示例见 示例代码

相关文档