@nice2dev/templates 1.1.10 → 1.2.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.
Files changed (2) hide show
  1. package/dist/index.d.ts +14 -102
  2. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { default as default_2 } from 'react';
2
- import { EventEmitter } from 'events';
3
2
 
4
3
  export declare type AccountId = string;
5
4
 
@@ -532,68 +531,24 @@ export declare interface NiceTaskManagerProps {
532
531
  style?: default_2.CSSProperties;
533
532
  }
534
533
 
535
- declare class NiceTorrentClient extends EventEmitter {
536
- private config;
537
- private peerId;
538
- private torrents;
539
- private dht?;
540
- private pex;
541
- private utp;
542
- private isRunning;
543
- constructor(config: TorrentClientConfig);
544
- private generatePeerId;
545
- private setupEventHandlers;
546
- /** Start the client */
547
- start(): Promise<void>;
548
- /** Stop the client */
549
- stop(): Promise<void>;
550
- /** Add torrent from magnet URI or .torrent file */
551
- addTorrent(source: string | Buffer, options?: {
534
+ /** What the torrent UI calls on the client the host passes in. */
535
+ declare interface NiceTorrentClient {
536
+ /** Every torrent the client manages. */
537
+ getAllTorrents(): TorrentInstance[];
538
+ /** One torrent, or `undefined` if the client does not have it. */
539
+ getTorrent(infoHash: InfoHash): TorrentInstance | undefined;
540
+ /** Add a torrent from a magnet URI or a path the client can read. */
541
+ addTorrent(source: string, options?: {
552
542
  path?: string;
553
543
  paused?: boolean;
554
- }): Promise<TorrentInstance>;
555
- private parseMagnetURI;
556
- private parseTorrentFile;
557
- /** Start downloading a torrent */
558
- startTorrent(infoHash: InfoHash): Promise<void>;
559
- /** Pause a torrent */
560
- pauseTorrent(infoHash: InfoHash): Promise<void>;
561
- /** Remove a torrent */
562
- removeTorrent(infoHash: InfoHash, options?: {
563
- deleteFiles?: boolean;
564
- }): Promise<void>;
565
- private announceToTrackers;
566
- private httpAnnounce;
567
- private addPeer;
568
- private connectToPeer;
569
- private disconnectPeer;
570
- private handlePeerData;
571
- /** Get torrent by info hash */
572
- getTorrent(infoHash: InfoHash): TorrentInstance | undefined;
573
- /** Get all torrents */
574
- getAllTorrents(): TorrentInstance[];
575
- /** Get client statistics */
576
- getStats(): {
577
- activeTorrents: number;
578
- totalDownloadSpeed: number;
579
- totalUploadSpeed: number;
580
- dhtNodes: number;
581
- globalPeers: number;
582
- };
583
- /** Set global download speed limit */
584
- setDownloadLimit(bytesPerSecond: number): void;
585
- /** Set global upload speed limit */
586
- setUploadLimit(bytesPerSecond: number): void;
587
- /** Generate .torrent file from directory */
588
- createTorrent(sourcePath: string, options?: {
589
- name?: string;
590
- trackers?: string[][];
591
- comment?: string;
592
- isPrivate?: boolean;
593
- pieceLength?: number;
594
- }): Promise<Buffer>;
544
+ }): Promise<TorrentInstance> | TorrentInstance | void;
545
+ on(event: NiceTorrentClientEvent, listener: () => void): unknown;
546
+ off(event: NiceTorrentClientEvent, listener: () => void): unknown;
595
547
  }
596
548
 
549
+ /** Client events the UI refreshes on. */
550
+ declare type NiceTorrentClientEvent = 'torrent_added' | 'torrent_removed';
551
+
597
552
  export declare function NiceTorrentUI({ client, config, className, style, }: NiceTorrentUIProps): default_2.ReactElement;
598
553
 
599
554
  export declare interface NiceTorrentUIProps {
@@ -932,49 +887,6 @@ export declare interface TimeBlock {
932
887
  isBlocked: boolean;
933
888
  }
934
889
 
935
- declare interface TorrentClientConfig {
936
- /** Client identifier */
937
- peerId?: PeerId;
938
- /** Download directory */
939
- downloadPath: string;
940
- /** Maximum download speed (bytes/sec, 0 = unlimited) */
941
- maxDownloadSpeed?: number;
942
- /** Maximum upload speed (bytes/sec, 0 = unlimited) */
943
- maxUploadSpeed?: number;
944
- /** Maximum concurrent torrents */
945
- maxConcurrentTorrents?: number;
946
- /** Maximum peers per torrent */
947
- maxPeersPerTorrent?: number;
948
- /** Maximum global connections */
949
- maxGlobalConnections?: number;
950
- /** Enable DHT (Distributed Hash Table) */
951
- enableDHT?: boolean;
952
- /** Enable PEX (Peer Exchange) */
953
- enablePEX?: boolean;
954
- /** Enable µTP (Micro Transport Protocol) */
955
- enableUTP?: boolean;
956
- /** Enable LSD (Local Service Discovery) */
957
- enableLSD?: boolean;
958
- /** Listen port range */
959
- portRange?: [number, number];
960
- /** Enable encryption */
961
- enableEncryption?: boolean;
962
- /** Require encryption */
963
- requireEncryption?: boolean;
964
- /** Seed ratio limit (0 = unlimited) */
965
- seedRatioLimit?: number;
966
- /** Seed time limit (seconds, 0 = unlimited) */
967
- seedTimeLimit?: number;
968
- /** Enable web seeds */
969
- enableWebSeeds?: boolean;
970
- /** Temporary directory for incomplete files */
971
- tempPath?: string;
972
- /** Pre-allocate files */
973
- preAllocateFiles?: boolean;
974
- /** Verify on completion */
975
- verifyOnComplete?: boolean;
976
- }
977
-
978
890
  export declare interface TorrentColumnConfig {
979
891
  id: string;
980
892
  label: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nice2dev/templates",
3
- "version": "1.1.10",
3
+ "version": "1.2.0",
4
4
  "description": "Nice2Dev Templates - Ready-to-use application templates (Health, PersonalFinance, TaskManager, LifeDashboard, TorrentUI)",
5
5
  "type": "module",
6
6
  "sideEffects": [