@ctrl/transmission 5.0.0 → 6.0.0

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # transmission [![npm](https://img.shields.io/npm/v/@ctrl/transmission.svg?maxAge=3600)](https://www.npmjs.com/package/@ctrl/transmission) [![coverage status](https://codecov.io/gh/scttcper/transmission/branch/master/graph/badge.svg)](https://codecov.io/gh/scttcper/transmission)
2
2
 
3
- > TypeScript api wrapper for [transmission](https://transmissionbt.com/) using [got](https://github.com/sindresorhus/got)
3
+ > TypeScript api wrapper for [transmission](https://transmissionbt.com/) using [ofetch](https://github.com/unjs/ofetch)
4
4
 
5
5
  ### Install
6
6
 
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import { FetchResponse } from 'ofetch';
3
2
  import type { AddTorrentOptions as NormalizedAddTorrentOptions, AllClientData, NormalizedTorrent, TorrentClient, TorrentSettings } from '@ctrl/shared-torrent';
4
3
  import type { AddTorrentOptions, AddTorrentResponse, DefaultResponse, FreeSpaceResponse, GetTorrentRepsonse, NormalizedTorrentIds, RenamePathOptions, SessionArguments, SessionResponse, SetTorrentOptions } from './types.js';
@@ -46,10 +45,10 @@ export declare class Transmission implements TorrentClient {
46
45
  addMagnet(url: string, options?: Partial<AddTorrentOptions>): Promise<AddTorrentResponse>;
47
46
  /**
48
47
  * Adding a torrent
49
- * @param torrent a string of file path or contents of the file as base64 string
48
+ * @param torrent a stream of file content or contents of the file as base64 string
50
49
  */
51
- addTorrent(torrent: string | Buffer, options?: Partial<AddTorrentOptions>): Promise<AddTorrentResponse>;
52
- normalizedAddTorrent(torrent: string | Buffer, options?: Partial<NormalizedAddTorrentOptions>): Promise<NormalizedTorrent>;
50
+ addTorrent(torrent: string | Uint8Array, options?: Partial<AddTorrentOptions>): Promise<AddTorrentResponse>;
51
+ normalizedAddTorrent(torrent: string | Uint8Array, options?: Partial<NormalizedAddTorrentOptions>): Promise<NormalizedTorrent>;
53
52
  getTorrent(id: NormalizedTorrentIds): Promise<NormalizedTorrent>;
54
53
  getAllData(): Promise<AllClientData>;
55
54
  listTorrents(id?: NormalizedTorrentIds, additionalFields?: string[]): Promise<GetTorrentRepsonse>;
@@ -1,5 +1,6 @@
1
1
  import { FetchError, ofetch } from 'ofetch';
2
2
  import { joinURL } from 'ufo';
3
+ import { uint8ArrayToBase64 } from 'uint8array-extras';
3
4
  import { magnetDecode } from '@ctrl/magnet-link';
4
5
  import { normalizeTorrentData } from './normalizeTorrentData.js';
5
6
  const defaults = {
@@ -132,7 +133,7 @@ export class Transmission {
132
133
  }
133
134
  /**
134
135
  * Adding a torrent
135
- * @param torrent a string of file path or contents of the file as base64 string
136
+ * @param torrent a stream of file content or contents of the file as base64 string
136
137
  */
137
138
  async addTorrent(torrent, options = {}) {
138
139
  const args = {
@@ -141,10 +142,10 @@ export class Transmission {
141
142
  ...options,
142
143
  };
143
144
  if (typeof torrent === 'string') {
144
- args.metainfo = Buffer.from(torrent, 'base64').toString('base64');
145
+ args.metainfo = torrent;
145
146
  }
146
147
  else {
147
- args.metainfo = torrent.toString('base64');
148
+ args.metainfo = uint8ArrayToBase64(torrent);
148
149
  }
149
150
  const res = await this.request('torrent-add', args);
150
151
  return res._data;
@@ -183,13 +184,13 @@ export class Transmission {
183
184
  }
184
185
  async getAllData() {
185
186
  const listTorrents = await this.listTorrents();
186
- const torrents = listTorrents.arguments.torrents.map((n) => normalizeTorrentData(n));
187
+ const torrents = listTorrents.arguments.torrents.map(n => normalizeTorrentData(n));
187
188
  const labels = [];
188
189
  for (const torrent of torrents) {
189
190
  if (!torrent.label) {
190
191
  continue;
191
192
  }
192
- const existing = labels.find((n) => n.id === torrent.label);
193
+ const existing = labels.find(n => n.id === torrent.label);
193
194
  if (existing) {
194
195
  existing.count += 1;
195
196
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctrl/transmission",
3
- "version": "5.0.0",
3
+ "version": "6.0.0",
4
4
  "description": "TypeScript api wrapper for transmission using got",
5
5
  "author": "Scott Cooper <scttcper@gmail.com>",
6
6
  "license": "MIT",
@@ -17,8 +17,12 @@
17
17
  ],
18
18
  "sideEffects": false,
19
19
  "scripts": {
20
- "lint": "eslint --ext .ts .",
21
- "lint:fix": "eslint --fix --ext .ts .",
20
+ "lint": "pnpm run '/^(lint:biome|lint:eslint)$/'",
21
+ "lint:biome": "biome check .",
22
+ "lint:eslint": "eslint --ext .ts,.tsx .",
23
+ "lint:fix": "pnpm run '/^(lint:biome|lint:eslint):fix$/'",
24
+ "lint:eslint:fix": "eslint --ext .ts,.tsx . --fix",
25
+ "lint:biome:fix": "biome check . --apply",
22
26
  "prepare": "npm run build",
23
27
  "build": "tsc",
24
28
  "build:docs": "typedoc",
@@ -27,20 +31,24 @@
27
31
  "test:ci": "vitest run --coverage --reporter=default --reporter=junit --outputFile=./junit.xml"
28
32
  },
29
33
  "dependencies": {
30
- "@ctrl/magnet-link": "^3.1.2",
31
- "@ctrl/shared-torrent": "^5.0.0",
34
+ "@ctrl/magnet-link": "^4.0.2",
35
+ "@ctrl/shared-torrent": "^6.0.0",
32
36
  "ofetch": "^1.3.3",
33
- "ufo": "^1.3.0"
37
+ "ufo": "^1.4.0",
38
+ "uint8array-extras": "^1.1.0"
34
39
  },
35
40
  "devDependencies": {
36
- "@ctrl/eslint-config": "4.0.7",
37
- "@sindresorhus/tsconfig": "4.0.0",
38
- "@types/node": "20.6.5",
39
- "@vitest/coverage-v8": "0.34.5",
41
+ "@biomejs/biome": "1.6.0",
42
+ "@ctrl/eslint-config-biome": "2.1.1",
43
+ "@ctrl/magnet-link": "^4.0.2",
44
+ "@ctrl/shared-torrent": "^6.0.0",
45
+ "@sindresorhus/tsconfig": "5.0.0",
46
+ "@types/node": "20.11.25",
47
+ "@vitest/coverage-v8": "1.3.1",
40
48
  "p-wait-for": "5.0.2",
41
- "typedoc": "0.25.1",
42
- "typescript": "5.2.2",
43
- "vitest": "0.34.5"
49
+ "typedoc": "0.25.12",
50
+ "typescript": "5.4.2",
51
+ "vitest": "1.3.1"
44
52
  },
45
53
  "publishConfig": {
46
54
  "access": "public",