Full Code of feross/webtorrent-hybrid for AI

master 3475297bf3be cached
15 files
11.5 KB
3.7k tokens
1 requests
Download .txt
Repository: feross/webtorrent-hybrid
Branch: master
Commit: 3475297bf3be
Files: 15
Total size: 11.5 KB

Directory structure:
gitextract_qg6rh9s6/

├── .github/
│   └── workflows/
│       ├── ci.yml
│       ├── release.yml
│       └── stale.yml
├── .gitignore
├── .npmignore
├── CHANGELOG.md
├── Dockerfile
├── LICENSE
├── README.md
├── bin/
│   └── cmd.js
├── examples/
│   ├── node-download.js
│   └── node-seed.js
├── index.js
├── lib/
│   └── global.js
└── package.json

================================================
FILE CONTENTS
================================================

================================================
FILE: .github/workflows/ci.yml
================================================
name: ci

on: [push, pull_request]

jobs:
  test:
    name: Node ${{ matrix.node }} / ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os:
          - ubuntu-latest
        node:
          - '16'
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node }}
      - run: npm install
      - run: npm run build --if-present
      - run: npm test


================================================
FILE: .github/workflows/release.yml
================================================
name: Release

on:
  push:
    branches:
      - master

jobs:
  release:
    name: Release
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          persist-credentials: false
      - name: Setup Node.js
        uses: actions/setup-node@v3
        with:
          node-version: 18
      - name: Cache
        uses: actions/cache@v3
        with:
          path: ~/.npm
          key: ${{ runner.os }}-npm-${{ hashFiles('**/package.json') }}
          restore-keys: |
            ${{ runner.os }}-npm-
      - name: Install dependencies
        env:
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
        run: npm i
      - name: Release
        env:
          GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
        run: npx semantic-release


================================================
FILE: .github/workflows/stale.yml
================================================
name: Mark stale issues and pull requests

on:
  schedule:
  - cron: '0 12 * * *'

jobs:
  stale:
    runs-on: ubuntu-latest
    permissions:
      issues: write
      pull-requests: write

    steps:
    - uses: actions/stale@v8
      with:
        repo-token: ${{ secrets.GITHUB_TOKEN }}
        stale-issue-message: 'Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?'
        stale-pr-message: 'Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?'
        exempt-issue-labels: accepted,blocked,bug,security,meta
        exempt-pr-labels: accepted,blocked,bug,'help wanted',security,meta
        stale-issue-label: 'stale'
        stale-pr-label: 'stale'


================================================
FILE: .gitignore
================================================
node_modules/
package-lock.json


================================================
FILE: .npmignore
================================================
examples/
.github/


================================================
FILE: CHANGELOG.md
================================================
# [6.0.0](https://github.com/webtorrent/webtorrent-hybrid/compare/v5.0.2...v6.0.0) (2024-06-02)


* BREAKING CHANGE: Deprecate webtorrent-hybrid (#195) ([fe511bf](https://github.com/webtorrent/webtorrent-hybrid/commit/fe511bf98a109b5bc7967a2853345a0b23da7b11)), closes [#195](https://github.com/webtorrent/webtorrent-hybrid/issues/195)


### BREAKING CHANGES

* Deprecate webtorrent-hybrid

This package is deprecated as of WebTorrent >= 2.3.0 as native WebRTC support has been added to WebTorrent. Please switch to using the "webtorrent" package.

* fix: Update ci to use NodeJS 16 to match package.json

* Update README.md

Update `Deprecated Warning` to `Deprecation Warning`

Co-authored-by: Cas_ <6506529+ThaUnknown@users.noreply.github.com>

* fix: re-add WEBTORRENT_ANNOUNCE which is used for adding websocket trackers to magnetURIs which do not already have them.

* feat: update webtorrent-cli to v5

## [5.0.2](https://github.com/webtorrent/webtorrent-hybrid/compare/v5.0.1...v5.0.2) (2022-02-01)


### Bug Fixes

* **deps:** update dependency webtorrent-cli to v4 ([#145](https://github.com/webtorrent/webtorrent-hybrid/issues/145)) ([7da7ddf](https://github.com/webtorrent/webtorrent-hybrid/commit/7da7ddfcb1f163b331f248395319e5fd8ff48752))

## [5.0.1](https://github.com/webtorrent/webtorrent-hybrid/compare/v5.0.0...v5.0.1) (2021-09-14)


### Bug Fixes

* webrtc import ([#143](https://github.com/webtorrent/webtorrent-hybrid/issues/143)) ([3b5d9bb](https://github.com/webtorrent/webtorrent-hybrid/commit/3b5d9bb0a21fceef76f25a113ebede40fce73338))

# [5.0.0](https://github.com/webtorrent/webtorrent-hybrid/compare/v4.1.3...v5.0.0) (2021-08-26)


### chore

* switch to ESM ([#141](https://github.com/webtorrent/webtorrent-hybrid/issues/141)) ([cbe8c3b](https://github.com/webtorrent/webtorrent-hybrid/commit/cbe8c3b8fff52a6fe9c86e531967566c5a889b12))


### BREAKING CHANGES

* switch to ESM

## [4.1.3](https://github.com/webtorrent/webtorrent-hybrid/compare/v4.1.2...v4.1.3) (2021-08-18)


### Bug Fixes

* dockerfile missing dependency ([#137](https://github.com/webtorrent/webtorrent-hybrid/issues/137)) ([2523b48](https://github.com/webtorrent/webtorrent-hybrid/commit/2523b48e1efd580139f27951edb130f96111d8a0))

## [4.1.2](https://github.com/webtorrent/webtorrent-hybrid/compare/v4.1.1...v4.1.2) (2021-08-06)


### Bug Fixes

* **deps:** update dependency create-torrent to v5 ([#134](https://github.com/webtorrent/webtorrent-hybrid/issues/134)) ([012f3fd](https://github.com/webtorrent/webtorrent-hybrid/commit/012f3fd702f6cfd70bb6cc29762412f78010daf7))

## [4.1.1](https://github.com/webtorrent/webtorrent-hybrid/compare/v4.1.0...v4.1.1) (2021-07-23)


### Bug Fixes

* add semantic release, switch CI ([f48c8ca](https://github.com/webtorrent/webtorrent-hybrid/commit/f48c8ca1ae4daa7ebdf5f86e2a59ba29ee3c05e6))

# [4.1.0](https://github.com/webtorrent/webtorrent-hybrid/compare/v4.0.3...v4.1.0) (2021-05-31)


### Features

* renovate and semantic-release, webtorrent@1 ([f175996](https://github.com/webtorrent/webtorrent-hybrid/commit/f175996e4528d57f4c762046291eaf19aee29965))


================================================
FILE: Dockerfile
================================================
FROM node:slim

RUN apt-get update && \
	apt-get full-upgrade -y && \
	apt-get install -y libgtk2.0-0 libgconf-2-4 libasound2 libxtst6 libxss1 libnss3 xvfb git -y && \
	apt-get autoremove --purge -y && \
	rm -rf /var/lib/apt/lists/* && \
	npm i -g node-pre-gyp

RUN npm i -g webtorrent-hybrid && \
	mkdir -p /webtorrent

EXPOSE 8000
WORKDIR /webtorrent
ENTRYPOINT ["/usr/local/bin/webtorrent-hybrid"]


================================================
FILE: LICENSE
================================================
The MIT License (MIT)

Copyright (c) Feross Aboukhadijeh and WebTorrent, LLC

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


================================================
FILE: README.md
================================================
# Deprecation Warning
This package is deprecated as of WebTorrent >= 2.3.0 as native WebRTC support has been added to WebTorrent. Please switch to using the "webtorrent" package.

# webtorrent-hybrid [![ci][ci-image]][ci-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]

[ci-image]: https://github.com/webtorrent/webtorrent-hybrid/actions/workflows/ci.yml/badge.svg
[ci-url]: https://github.com/webtorrent/webtorrent-hybrid/actions/workflows/ci.yml
[npm-image]: https://img.shields.io/npm/v/webtorrent-hybrid.svg
[npm-url]: https://npmjs.org/package/webtorrent-hybrid
[downloads-image]: https://img.shields.io/npm/dm/webtorrent-hybrid.svg
[downloads-url]: https://npmjs.org/package/webtorrent-hybrid
[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
[standard-url]: https://standardjs.com

### Streaming torrent client (with WebRTC support in Node.js)

In node.js, the `webtorrent` package only connects to normal TCP/UDP peers, not WebRTC peers. If you want to connect to all types of peers, including WebRTC peers, from node.js, you need to use this package (`webtorrent-hybrid`).

## Install

To install WebTorrent:

```bash
npm install webtorrent-hybrid
```

To install a `webtorrent-hybrid` command line program, run:

```bash
npm install webtorrent-hybrid -g
```

## Usage

`webtorrent-hybrid` has the same command line interface (CLI) and module API as
[`webtorrent`](https://github.com/webtorrent/webtorrent). Just `import WebTorrent from 'webtorrent-hybrid'`
instead of `import WebTorrent from 'webtorrent'`.

See the [WebTorrent docs](https://webtorrent.io/docs).

## License

MIT. Copyright (c) [Feross Aboukhadijeh](https://feross.org) and [WebTorrent, LLC](https://webtorrent.io).


================================================
FILE: bin/cmd.js
================================================
#!/usr/bin/env node

import '../lib/global.js'
import 'webtorrent-cli/bin/cmd.js'


================================================
FILE: examples/node-download.js
================================================
import WebTorrent from '../index.js'
import fs from 'fs'

const client = new WebTorrent()

const torrentId = 'magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d'

console.log('torrentId:\t', torrentId)

client.add(torrentId, torrent => {
  const files = torrent.files
  let length = files.length
  // Stream each file to the disk
  files.forEach(file => {
    const source = file.createReadStream()
    const destination = fs.createWriteStream(file.name)
    source.on('end', () => {
      console.log('file:\t\t', file.name)
      // close after all files are saved
      length -= 1
      if (!length) process.exit()
    }).pipe(destination)
  })
})


================================================
FILE: examples/node-seed.js
================================================
import WebTorrent from '../index.js'

const client = new WebTorrent()
const filePath = __filename

console.log('filePath:', filePath)

client.seed(filePath, torrent => {
  console.log('torrentId (info hash):', torrent.infoHash)
  // console.log('torrentId (magnet link):', torrent.magnetURI)
})


================================================
FILE: index.js
================================================
/*! webtorrent-hybrid. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */
import './lib/global.js'
export { default } from 'webtorrent'


================================================
FILE: lib/global.js
================================================
import { announceList } from 'create-torrent'

globalThis.WEBTORRENT_ANNOUNCE = announceList
  .map(arr => arr[0])
  .filter(url => url.indexOf('wss://') === 0 || url.indexOf('ws://') === 0)

console.warn('webtorrent-hybrid: This package is deprecated as of WebTorrent >= 2.3.0 as native WebRTC support has been added to WebTorrent. Please switch to using the "webtorrent" package.')


================================================
FILE: package.json
================================================
{
  "name": "webtorrent-hybrid",
  "type": "module",
  "description": "Streaming torrent client",
  "version": "6.0.0",
  "author": {
    "name": "WebTorrent LLC",
    "email": "feross@webtorrent.io",
    "url": "https://webtorrent.io"
  },
  "bin": "./bin/cmd.js",
  "bugs": {
    "url": "https://github.com/webtorrent/webtorrent-hybrid/issues"
  },
  "deprecated": "This package is deprecated as of WebTorrent >= 2.3.0 as native WebRTC support has been added to WebTorrent. Please switch to using the \"webtorrent\" package.",
  "dependencies": {
    "create-torrent": "^6.0.17",
    "webtorrent": "^2.3.0",
    "webtorrent-cli": "^5.0.0"
  },
  "devDependencies": {
    "@webtorrent/semantic-release-config": "1.0.11",
    "semantic-release": "21.1.2",
    "standard": "*"
  },
  "engines": {
    "node": ">=16"
  },
  "homepage": "https://webtorrent.io",
  "keywords": [
    "bittorrent",
    "bittorrent client",
    "download",
    "mad science",
    "streaming",
    "torrent",
    "webrtc",
    "webrtc data",
    "webtorrent"
  ],
  "license": "MIT",
  "exports": "./index.js",
  "repository": {
    "type": "git",
    "url": "git://github.com/webtorrent/webtorrent-hybrid.git"
  },
  "scripts": {
    "test": "standard"
  },
  "funding": [
    {
      "type": "github",
      "url": "https://github.com/sponsors/feross"
    },
    {
      "type": "patreon",
      "url": "https://www.patreon.com/feross"
    },
    {
      "type": "consulting",
      "url": "https://feross.org/support"
    }
  ],
  "renovate": {
    "extends": [
      "github>webtorrent/renovate-config"
    ]
  },
  "release": {
    "extends": "@webtorrent/semantic-release-config"
  }
}
Download .txt
gitextract_qg6rh9s6/

├── .github/
│   └── workflows/
│       ├── ci.yml
│       ├── release.yml
│       └── stale.yml
├── .gitignore
├── .npmignore
├── CHANGELOG.md
├── Dockerfile
├── LICENSE
├── README.md
├── bin/
│   └── cmd.js
├── examples/
│   ├── node-download.js
│   └── node-seed.js
├── index.js
├── lib/
│   └── global.js
└── package.json
Condensed preview — 15 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (13K chars).
[
  {
    "path": ".github/workflows/ci.yml",
    "chars": 478,
    "preview": "name: ci\n\non: [push, pull_request]\n\njobs:\n  test:\n    name: Node ${{ matrix.node }} / ${{ matrix.os }}\n    runs-on: ${{ "
  },
  {
    "path": ".github/workflows/release.yml",
    "chars": 839,
    "preview": "name: Release\n\non:\n  push:\n    branches:\n      - master\n\njobs:\n  release:\n    name: Release\n    runs-on: ubuntu-latest\n "
  },
  {
    "path": ".github/workflows/stale.yml",
    "chars": 767,
    "preview": "name: Mark stale issues and pull requests\n\non:\n  schedule:\n  - cron: '0 12 * * *'\n\njobs:\n  stale:\n    runs-on: ubuntu-la"
  },
  {
    "path": ".gitignore",
    "chars": 32,
    "preview": "node_modules/\npackage-lock.json\n"
  },
  {
    "path": ".npmignore",
    "chars": 19,
    "preview": "examples/\n.github/\n"
  },
  {
    "path": "CHANGELOG.md",
    "chars": 3101,
    "preview": "# [6.0.0](https://github.com/webtorrent/webtorrent-hybrid/compare/v5.0.2...v6.0.0) (2024-06-02)\n\n\n* BREAKING CHANGE: Dep"
  },
  {
    "path": "Dockerfile",
    "chars": 401,
    "preview": "FROM node:slim\n\nRUN apt-get update && \\\n\tapt-get full-upgrade -y && \\\n\tapt-get install -y libgtk2.0-0 libgconf-2-4 libas"
  },
  {
    "path": "LICENSE",
    "chars": 1101,
    "preview": "The MIT License (MIT)\n\nCopyright (c) Feross Aboukhadijeh and WebTorrent, LLC\n\nPermission is hereby granted, free of char"
  },
  {
    "path": "README.md",
    "chars": 1817,
    "preview": "# Deprecation Warning\nThis package is deprecated as of WebTorrent >= 2.3.0 as native WebRTC support has been added to We"
  },
  {
    "path": "bin/cmd.js",
    "chars": 82,
    "preview": "#!/usr/bin/env node\n\nimport '../lib/global.js'\nimport 'webtorrent-cli/bin/cmd.js'\n"
  },
  {
    "path": "examples/node-download.js",
    "chars": 662,
    "preview": "import WebTorrent from '../index.js'\nimport fs from 'fs'\n\nconst client = new WebTorrent()\n\nconst torrentId = 'magnet:?xt"
  },
  {
    "path": "examples/node-seed.js",
    "chars": 295,
    "preview": "import WebTorrent from '../index.js'\n\nconst client = new WebTorrent()\nconst filePath = __filename\n\nconsole.log('filePath"
  },
  {
    "path": "index.js",
    "chars": 151,
    "preview": "/*! webtorrent-hybrid. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */\nimport './lib/global.js'\nexport"
  },
  {
    "path": "lib/global.js",
    "chars": 384,
    "preview": "import { announceList } from 'create-torrent'\n\nglobalThis.WEBTORRENT_ANNOUNCE = announceList\n  .map(arr => arr[0])\n  .fi"
  },
  {
    "path": "package.json",
    "chars": 1668,
    "preview": "{\n  \"name\": \"webtorrent-hybrid\",\n  \"type\": \"module\",\n  \"description\": \"Streaming torrent client\",\n  \"version\": \"6.0.0\",\n"
  }
]

About this extraction

This page contains the full source code of the feross/webtorrent-hybrid GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 15 files (11.5 KB), approximately 3.7k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!