amule-ec-client 0.6.1 → 0.7.1

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 (45) hide show
  1. package/README.md +10 -2
  2. package/dist/{AddLinkRequest-D2IME4eb.js → AddLinkRequest-CGv1H3PC.js} +2 -3
  3. package/dist/{ClientQueueRequest-DFfCiNcz.js → ClientQueueRequest-mklt-KLi.js} +2 -3
  4. package/dist/{ClientQueueResponse-JTrBqrr1.js → ClientQueueResponse-RfXh2JGa.js} +8 -5
  5. package/dist/{CreateCategoryRequest-CRUMcPo5.js → CreateCategoryRequest-Cyp9G7jU.js} +2 -3
  6. package/dist/{DeleteCategoryRequest-C8v9oGZ-.js → DeleteCategoryRequest-DbLJ4mvi.js} +2 -3
  7. package/dist/{DownloadCommandRequest-B3KV_bvm.js → DownloadCommandRequest-DLU7RtYs.js} +2 -3
  8. package/dist/{DownloadFileRequest-BjrroO3h.js → DownloadFileRequest-Db7oijyu.js} +2 -3
  9. package/dist/{DownloadQueueRequest-Dil5hl3D.js → DownloadQueueRequest-DdHRjl4L.js} +2 -3
  10. package/dist/{GetPreferencesRequest-DsxlghqT.js → GetPreferencesRequest-BlWGYNCP.js} +2 -3
  11. package/dist/{PreferencesDetailsResponse-DapscVQi.js → PreferencesDetailsResponse-BX6qUoga.js} +1 -2
  12. package/dist/{PreferencesResponse-8n1STWUZ.js → PreferencesResponse-migFtIG7.js} +1 -2
  13. package/dist/{ReloadSharedFilesRequest-kt0Pxs8A.js → ReloadSharedFilesRequest-WD9iYLje.js} +2 -2
  14. package/dist/{Request-C0UUuQIX.js → Request-YQ0nIM6b.js} +3 -9
  15. package/dist/{SearchProgressResponse-C1CdzKnz.js → SearchProgressResponse-CkEgZGFE.js} +1 -2
  16. package/dist/{SearchRequest-DQnKfA5Z.js → SearchRequest-DaAKS4IO.js} +2 -3
  17. package/dist/{SearchResultsRequest-2ejFGQmQ.js → SearchResultsRequest-B53jwjRH.js} +2 -2
  18. package/dist/{SearchResultsResponse-DwmvbQop.js → SearchResultsResponse-C1l-bBja.js} +1 -2
  19. package/dist/{SearchStatusRequest-B_xr4-72.js → SearchStatusRequest-DuEa5ZYu.js} +2 -2
  20. package/dist/{SearchStopRequest-8hwXobty.js → SearchStopRequest-B5TZdMiB.js} +2 -2
  21. package/dist/{ServerConnectRequest-BhNpGiEJ.js → ServerConnectRequest-BeB8RSBN.js} +2 -3
  22. package/dist/{ServerDisconnectRequest-BjCitLtU.js → ServerDisconnectRequest-CSkUHETP.js} +2 -2
  23. package/dist/{ServerListRequest-BWXLGJib.js → ServerListRequest-B82686jD.js} +2 -2
  24. package/dist/{ServerListResponse-BUJ7sz5p.js → ServerListResponse-M3C2OcfZ.js} +5 -4
  25. package/dist/{ServerUpdateFromUrlRequest-K8C_d0UQ.js → ServerUpdateFromUrlRequest-BcvhRKgH.js} +2 -3
  26. package/dist/{SetFileCategoryRequest-VwroLBTV.js → SetFileCategoryRequest-C1jWsYO5.js} +2 -3
  27. package/dist/{SetPreferencesRequest-KZ23VaBY.js → SetPreferencesRequest-CNJVmeQl.js} +2 -3
  28. package/dist/{SharedFilePriorityRequest-7BriqAcr.js → SharedFilePriorityRequest-CBqkaXaK.js} +2 -3
  29. package/dist/{SharedFilesRequest-B72XyRcA.js → SharedFilesRequest-5mKKjzgt.js} +2 -3
  30. package/dist/SharedFilesResponse-CFl0NuO-.js +45 -0
  31. package/dist/{StatsRequest-CGGumOOx.js → StatsRequest-C9gBUvSq.js} +2 -3
  32. package/dist/{StatsResponse-DxQk686g.js → StatsResponse-KOk-xT6_.js} +25 -2
  33. package/dist/{Codes-CjiW7Pdl.js → Tag-D_Ybe5RQ.js} +280 -1
  34. package/dist/{UpdateCategoryRequest-CzKJa_rC.js → UpdateCategoryRequest-BOYfb6Vn.js} +2 -3
  35. package/dist/{UpdateRequest-g2ReOQ5m.js → UpdateRequest-csLQz7JO.js} +2 -3
  36. package/dist/UpdateState-LhdtiATk.js +443 -0
  37. package/dist/index.d.ts +381 -337
  38. package/dist/index.js +116 -55
  39. package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
  40. package/dist/{utils-DBnUQnZ-.js → utils-CNoUroOI.js} +11 -1
  41. package/package.json +1 -1
  42. package/dist/DownloadQueueResponse-DUam_zNf.js +0 -259
  43. package/dist/SharedFilesResponse-CkqvYd3N.js +0 -39
  44. package/dist/Tag-CZF6BRMY.js +0 -260
  45. package/dist/UpdateResponse-CGwVjn0Y.js +0 -45
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  A TypeScript client library for interacting with aMule's External Connection (EC) protocol.
7
7
 
8
- Ported from [jamule](https://github.com/vexdev/jamule) (Java/Kotlin) to TypeScript.
8
+ This project started as a port from [jamule](https://github.com/vexdev/jamule) (Java/Kotlin) to TypeScript. But as of the date this readme was last updated, this project covers wider functionality.
9
9
 
10
10
  ## Features
11
11
 
@@ -14,6 +14,7 @@ Ported from [jamule](https://github.com/vexdev/jamule) (Java/Kotlin) to TypeScri
14
14
  - ✅ Server statistics
15
15
  - ✅ File searching (local, global, Kad, web)
16
16
  - ✅ Download management
17
+ - ✅ Per-peer source details for active downloads (via incremental updates)
17
18
  - ✅ Shared files listing
18
19
  - ✅ Category management
19
20
  - ✅ ED2K link parsing
@@ -101,7 +102,13 @@ Options:
101
102
  **Downloads**
102
103
 
103
104
  - `downloadSearchResult(hash, category?): Promise<void>` - Download from search results
104
- - `getDownloadQueue(): Promise<AmuleTransferringFile[]>` - Get download queue
105
+ - `getDownloadQueue(): Promise<AmuleTransferringFile[]>` - Get download queue (chunk info and source name buckets, but no per-peer details)
106
+ - `getDownloadQueueWithSources(): Promise<AmuleTransferringFile[]>` - Get download queue with `sources` filled with the connected peers of each download (name, IP, software, speeds, queue rank, ...)
107
+ - `getUpdate(): Promise<UpdateResponse>` - Incremental update snapshot: downloads (with `sources`), shared files and clients. The daemon sends per-connection diffs; the client merges them internally, so every call returns full objects
108
+
109
+ > **Note:** aMule only exposes per-peer info through the incremental update mechanism (`EC_OP_GET_UPDATE`), never nested inside `EC_OP_GET_DLOAD_QUEUE` responses. Peers are linked to downloads through `client.requestFileId === file.ecid`. The internal cache is per connection and resets automatically on reconnect.
110
+ >
111
+ > `sourceNames` (the filenames under which the sources share each file) is also sent by the daemon as a per-connection incremental map — even for full-detail `getDownloadQueue()` requests. `getDownloadQueue()` therefore returns complete name buckets only on the first call of a connection; the update-based methods merge the diffs and are always complete.
105
112
 
106
113
  **Shared Files**
107
114
 
@@ -115,6 +122,7 @@ This library implements the aMule External Connection protocol version 0x0204, c
115
122
  - aMule 2.3.2
116
123
  - aMule 2.3.3
117
124
  - aMule 3.0.0
125
+ - aMule 3.0.1
118
126
 
119
127
  ### Protocol Features
120
128
 
@@ -1,6 +1,5 @@
1
- import { t as Request } from "./Request-C0UUuQIX.js";
2
- import "./Codes-CjiW7Pdl.js";
3
- import { a as StringTag } from "./Tag-CZF6BRMY.js";
1
+ import { t as Request } from "./Request-YQ0nIM6b.js";
2
+ import { a as StringTag } from "./Tag-D_Ybe5RQ.js";
4
3
  //#region src/request/AddLinkRequest.ts
5
4
  /**
6
5
  * Add Link Request - Download from ED2K link
@@ -1,6 +1,5 @@
1
- import { t as Request } from "./Request-C0UUuQIX.js";
2
- import "./Codes-CjiW7Pdl.js";
3
- import { s as UByteTag } from "./Tag-CZF6BRMY.js";
1
+ import { t as Request } from "./Request-YQ0nIM6b.js";
2
+ import { s as UByteTag } from "./Tag-D_Ybe5RQ.js";
4
3
  //#region src/request/ClientQueueRequest.ts
5
4
  /**
6
5
  * Client Queue Request - Get client upload queue
@@ -1,7 +1,8 @@
1
- import "./Codes-CjiW7Pdl.js";
2
- import { f as findNumericTag, p as findTag } from "./Tag-CZF6BRMY.js";
3
- import { i as toOptionalNumber, n as toOptionalBool, r as toOptionalIp } from "./utils-DBnUQnZ-.js";
1
+ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
+ import { f as findNumericTag, p as findTag } from "./Tag-D_Ybe5RQ.js";
3
+ import { a as toOptionalNumber, i as toOptionalIp, n as tagOwnNumericValue, r as toOptionalBool } from "./utils-CNoUroOI.js";
4
4
  //#region src/response/ClientQueueResponse.ts
5
+ var ClientQueueResponse_exports = /* @__PURE__ */ __exportAll({ ClientQueueResponseParser: () => ClientQueueResponseParser });
5
6
  var ClientQueueResponseParser = class {
6
7
  static fromPacket(packet) {
7
8
  return this.fromTags(packet.tags);
@@ -11,7 +12,9 @@ var ClientQueueResponseParser = class {
11
12
  const clientTags = allTags.filter((tag) => tag.name === 1536);
12
13
  for (const clientTag of clientTags) {
13
14
  const tags = clientTag.nestedTags || [];
15
+ const downSpeedKBps = toOptionalNumber(findNumericTag(tags, 1550)?.getValue());
14
16
  const client = {
17
+ ecid: tagOwnNumericValue(clientTag),
15
18
  clientName: findTag(tags, 256)?.getValue(),
16
19
  userHashHexString: findTag(tags, 1539)?.getValue()?.toString("hex"),
17
20
  userID: findNumericTag(tags, 1566)?.getInt(),
@@ -25,7 +28,7 @@ var ClientQueueResponseParser = class {
25
28
  serverPort: findNumericTag(tags, 1555)?.getInt(),
26
29
  serverName: findTag(tags, 1556)?.getValue(),
27
30
  upSpeed: toOptionalNumber(findNumericTag(tags, 1549)?.getLong()),
28
- downSpeed: toOptionalNumber(findNumericTag(tags, 1550)?.getLong()),
31
+ downSpeed: downSpeedKBps === void 0 ? void 0 : Math.round(downSpeedKBps * 1024),
29
32
  uploadSession: toOptionalNumber(findNumericTag(tags, 1545)?.getLong()),
30
33
  transferredDown: toOptionalNumber(findNumericTag(tags, 772)?.getLong()),
31
34
  uploadedTotal: toOptionalNumber(findNumericTag(tags, 1546)?.getLong()),
@@ -60,4 +63,4 @@ var ClientQueueResponseParser = class {
60
63
  }
61
64
  };
62
65
  //#endregion
63
- export { ClientQueueResponseParser };
66
+ export { ClientQueueResponse_exports as n, ClientQueueResponseParser as t };
@@ -1,6 +1,5 @@
1
- import { t as Request } from "./Request-C0UUuQIX.js";
2
- import "./Codes-CjiW7Pdl.js";
3
- import { a as StringTag, l as UIntTag, s as UByteTag } from "./Tag-CZF6BRMY.js";
1
+ import { t as Request } from "./Request-YQ0nIM6b.js";
2
+ import { a as StringTag, l as UIntTag, s as UByteTag } from "./Tag-D_Ybe5RQ.js";
4
3
  //#region src/request/CreateCategoryRequest.ts
5
4
  /**
6
5
  * Create Category Request - Create a new category
@@ -1,6 +1,5 @@
1
- import { t as Request } from "./Request-C0UUuQIX.js";
2
- import "./Codes-CjiW7Pdl.js";
3
- import { l as UIntTag } from "./Tag-CZF6BRMY.js";
1
+ import { t as Request } from "./Request-YQ0nIM6b.js";
2
+ import { l as UIntTag } from "./Tag-D_Ybe5RQ.js";
4
3
  //#region src/request/DeleteCategoryRequest.ts
5
4
  /**
6
5
  * Delete Category Request - Delete an existing category
@@ -1,6 +1,5 @@
1
- import { t as Request } from "./Request-C0UUuQIX.js";
2
- import "./Codes-CjiW7Pdl.js";
3
- import { r as Hash16Tag } from "./Tag-CZF6BRMY.js";
1
+ import { t as Request } from "./Request-YQ0nIM6b.js";
2
+ import { r as Hash16Tag } from "./Tag-D_Ybe5RQ.js";
4
3
  import "./index.js";
5
4
  //#region src/request/DownloadCommandRequest.ts
6
5
  /**
@@ -1,6 +1,5 @@
1
- import { t as Request } from "./Request-C0UUuQIX.js";
2
- import "./Codes-CjiW7Pdl.js";
3
- import { r as Hash16Tag } from "./Tag-CZF6BRMY.js";
1
+ import { t as Request } from "./Request-YQ0nIM6b.js";
2
+ import { r as Hash16Tag } from "./Tag-D_Ybe5RQ.js";
4
3
  //#region src/request/DownloadFileRequest.ts
5
4
  /**
6
5
  * Download File Request - Download a file from search results
@@ -1,6 +1,5 @@
1
- import { t as Request } from "./Request-C0UUuQIX.js";
2
- import "./Codes-CjiW7Pdl.js";
3
- import { s as UByteTag } from "./Tag-CZF6BRMY.js";
1
+ import { t as Request } from "./Request-YQ0nIM6b.js";
2
+ import { s as UByteTag } from "./Tag-D_Ybe5RQ.js";
4
3
  //#region src/request/DownloadQueueRequest.ts
5
4
  /**
6
5
  * Download Queue Request - Get download queue
@@ -1,6 +1,5 @@
1
- import { t as Request } from "./Request-C0UUuQIX.js";
2
- import "./Codes-CjiW7Pdl.js";
3
- import { l as UIntTag, s as UByteTag } from "./Tag-CZF6BRMY.js";
1
+ import { t as Request } from "./Request-YQ0nIM6b.js";
2
+ import { l as UIntTag, s as UByteTag } from "./Tag-D_Ybe5RQ.js";
4
3
  //#region src/request/GetPreferencesRequest.ts
5
4
  /**
6
5
  * Preferences Request - Get preferences
@@ -1,5 +1,4 @@
1
- import "./Codes-CjiW7Pdl.js";
2
- import { f as findNumericTag, p as findTag } from "./Tag-CZF6BRMY.js";
1
+ import { f as findNumericTag, p as findTag } from "./Tag-D_Ybe5RQ.js";
3
2
  //#region src/response/PreferencesDetailsResponse.ts
4
3
  var PreferencesDetailsResponse = class {
5
4
  preferences;
@@ -1,5 +1,4 @@
1
- import "./Codes-CjiW7Pdl.js";
2
- import { f as findNumericTag, p as findTag } from "./Tag-CZF6BRMY.js";
1
+ import { f as findNumericTag, p as findTag } from "./Tag-D_Ybe5RQ.js";
3
2
  //#region src/response/PreferencesResponse.ts
4
3
  var PreferencesResponse = class {
5
4
  categories;
@@ -1,5 +1,5 @@
1
- import { t as Request } from "./Request-C0UUuQIX.js";
2
- import "./Codes-CjiW7Pdl.js";
1
+ import { t as Request } from "./Request-YQ0nIM6b.js";
2
+ import "./Tag-D_Ybe5RQ.js";
3
3
  //#region src/request/ReloadSharedFilesRequest.ts
4
4
  /**
5
5
  * Reload Shared Files Request - Reload shared files list
@@ -1,3 +1,4 @@
1
+ import { p as findTag } from "./Tag-D_Ybe5RQ.js";
1
2
  //#region src/ec/packet/Flags.ts
2
3
  /**
3
4
  * Packet flags for EC protocol
@@ -80,11 +81,10 @@ var Flags = class Flags {
80
81
  };
81
82
  //#endregion
82
83
  //#region src/ec/packet/Packet.ts
83
- var Packet = class Packet {
84
+ var Packet = class {
84
85
  opCode;
85
86
  flags;
86
87
  tags;
87
- static EC_CURRENT_PROTOCOL_VERSION = 516;
88
88
  constructor(opCode, flags = new Flags(), tags = []) {
89
89
  this.opCode = opCode;
90
90
  this.flags = flags;
@@ -105,16 +105,10 @@ var Packet = class Packet {
105
105
  return this;
106
106
  }
107
107
  /**
108
- * Get protocol version
109
- */
110
- static getProtocolVersion() {
111
- return Packet.EC_CURRENT_PROTOCOL_VERSION;
112
- }
113
- /**
114
108
  * Find a tag by name
115
109
  */
116
110
  findTag(tagName) {
117
- return this.tags.find((tag) => tag.name === tagName);
111
+ return findTag(this.tags, tagName);
118
112
  }
119
113
  /**
120
114
  * Get all tags with a specific name
@@ -1,5 +1,4 @@
1
- import "./Codes-CjiW7Pdl.js";
2
- import { f as findNumericTag } from "./Tag-CZF6BRMY.js";
1
+ import { f as findNumericTag } from "./Tag-D_Ybe5RQ.js";
3
2
  //#region src/response/SearchProgressResponse.ts
4
3
  var SearchProgressResponse = class SearchProgressResponse {
5
4
  progress;
@@ -1,6 +1,5 @@
1
- import { n as Packet, r as Flags, t as Request } from "./Request-C0UUuQIX.js";
2
- import "./Codes-CjiW7Pdl.js";
3
- import { a as StringTag, l as UIntTag, s as UByteTag, u as ULongTag } from "./Tag-CZF6BRMY.js";
1
+ import { n as Packet, r as Flags, t as Request } from "./Request-YQ0nIM6b.js";
2
+ import { a as StringTag, l as UIntTag, s as UByteTag, u as ULongTag } from "./Tag-D_Ybe5RQ.js";
4
3
  import "./index.js";
5
4
  //#region src/request/SearchRequest.ts
6
5
  /**
@@ -1,5 +1,5 @@
1
- import { t as Request } from "./Request-C0UUuQIX.js";
2
- import "./Codes-CjiW7Pdl.js";
1
+ import { t as Request } from "./Request-YQ0nIM6b.js";
2
+ import "./Tag-D_Ybe5RQ.js";
3
3
  //#region src/request/SearchResultsRequest.ts
4
4
  /**
5
5
  * Search Results Request - Get search results
@@ -1,5 +1,4 @@
1
- import "./Codes-CjiW7Pdl.js";
2
- import { f as findNumericTag, p as findTag } from "./Tag-CZF6BRMY.js";
1
+ import { f as findNumericTag, p as findTag } from "./Tag-D_Ybe5RQ.js";
3
2
  //#region src/response/SearchResultsResponse.ts
4
3
  var SearchResultsResponseParser = class {
5
4
  static fromPacket(packet) {
@@ -1,5 +1,5 @@
1
- import { t as Request } from "./Request-C0UUuQIX.js";
2
- import "./Codes-CjiW7Pdl.js";
1
+ import { t as Request } from "./Request-YQ0nIM6b.js";
2
+ import "./Tag-D_Ybe5RQ.js";
3
3
  //#region src/request/SearchStatusRequest.ts
4
4
  /**
5
5
  * Search Status Request - Get search progress
@@ -1,5 +1,5 @@
1
- import { t as Request } from "./Request-C0UUuQIX.js";
2
- import "./Codes-CjiW7Pdl.js";
1
+ import { t as Request } from "./Request-YQ0nIM6b.js";
2
+ import "./Tag-D_Ybe5RQ.js";
3
3
  //#region src/request/SearchStopRequest.ts
4
4
  /**
5
5
  * Search Stop Request - Stop current search
@@ -1,6 +1,5 @@
1
- import { t as Request } from "./Request-C0UUuQIX.js";
2
- import "./Codes-CjiW7Pdl.js";
3
- import { i as Ipv4Tag } from "./Tag-CZF6BRMY.js";
1
+ import { t as Request } from "./Request-YQ0nIM6b.js";
2
+ import { i as Ipv4Tag } from "./Tag-D_Ybe5RQ.js";
4
3
  //#region src/request/ServerConnectRequest.ts
5
4
  /**
6
5
  * Server Connect Request - Connect to a specific server
@@ -1,5 +1,5 @@
1
- import { t as Request } from "./Request-C0UUuQIX.js";
2
- import "./Codes-CjiW7Pdl.js";
1
+ import { t as Request } from "./Request-YQ0nIM6b.js";
2
+ import "./Tag-D_Ybe5RQ.js";
3
3
  //#region src/request/ServerDisconnectRequest.ts
4
4
  /**
5
5
  * Server Disconnect Request - Disconnect from the current server
@@ -1,5 +1,5 @@
1
- import { t as Request } from "./Request-C0UUuQIX.js";
2
- import "./Codes-CjiW7Pdl.js";
1
+ import { t as Request } from "./Request-YQ0nIM6b.js";
2
+ import "./Tag-D_Ybe5RQ.js";
3
3
  //#region src/request/ServerListRequest.ts
4
4
  /**
5
5
  * Server List Request - Request the list of servers
@@ -1,7 +1,8 @@
1
- import "./Codes-CjiW7Pdl.js";
2
- import { f as findNumericTag, p as findTag } from "./Tag-CZF6BRMY.js";
3
- import { n as toOptionalBool, t as formatIp } from "./utils-DBnUQnZ-.js";
1
+ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
+ import { f as findNumericTag, p as findTag } from "./Tag-D_Ybe5RQ.js";
3
+ import { r as toOptionalBool, t as formatIp } from "./utils-CNoUroOI.js";
4
4
  //#region src/response/ServerListResponse.ts
5
+ var ServerListResponse_exports = /* @__PURE__ */ __exportAll({ ServerListResponseParser: () => ServerListResponseParser });
5
6
  var ServerListResponseParser = class {
6
7
  static fromPacket(packet) {
7
8
  return this.fromTags(packet.tags);
@@ -47,4 +48,4 @@ var ServerListResponseParser = class {
47
48
  }
48
49
  };
49
50
  //#endregion
50
- export { ServerListResponseParser };
51
+ export { ServerListResponse_exports as n, ServerListResponseParser as t };
@@ -1,6 +1,5 @@
1
- import { t as Request } from "./Request-C0UUuQIX.js";
2
- import "./Codes-CjiW7Pdl.js";
3
- import { a as StringTag } from "./Tag-CZF6BRMY.js";
1
+ import { t as Request } from "./Request-YQ0nIM6b.js";
2
+ import { a as StringTag } from "./Tag-D_Ybe5RQ.js";
4
3
  //#region src/request/ServerUpdateFromUrlRequest.ts
5
4
  var ServerUpdateFromUrlRequest = class extends Request {
6
5
  constructor(url) {
@@ -1,6 +1,5 @@
1
- import { t as Request } from "./Request-C0UUuQIX.js";
2
- import "./Codes-CjiW7Pdl.js";
3
- import { r as Hash16Tag, s as UByteTag } from "./Tag-CZF6BRMY.js";
1
+ import { t as Request } from "./Request-YQ0nIM6b.js";
2
+ import { r as Hash16Tag, s as UByteTag } from "./Tag-D_Ybe5RQ.js";
4
3
  //#region src/request/SetFileCategoryRequest.ts
5
4
  /**
6
5
  * Set File Category Request - Change category of a file
@@ -1,6 +1,5 @@
1
- import { t as Request } from "./Request-C0UUuQIX.js";
2
- import "./Codes-CjiW7Pdl.js";
3
- import { a as StringTag, d as UShortTag, l as UIntTag, s as UByteTag } from "./Tag-CZF6BRMY.js";
1
+ import { t as Request } from "./Request-YQ0nIM6b.js";
2
+ import { a as StringTag, d as UShortTag, l as UIntTag, s as UByteTag } from "./Tag-D_Ybe5RQ.js";
4
3
  //#region src/request/SetPreferencesRequest.ts
5
4
  var SetPreferencesRequest = class SetPreferencesRequest extends Request {
6
5
  constructor(prefs) {
@@ -1,6 +1,5 @@
1
- import { t as Request } from "./Request-C0UUuQIX.js";
2
- import "./Codes-CjiW7Pdl.js";
3
- import { l as UIntTag, r as Hash16Tag } from "./Tag-CZF6BRMY.js";
1
+ import { t as Request } from "./Request-YQ0nIM6b.js";
2
+ import { l as UIntTag, r as Hash16Tag } from "./Tag-D_Ybe5RQ.js";
4
3
  //#region src/request/SharedFilePriorityRequest.ts
5
4
  var SharedFilePriorityRequest = class extends Request {
6
5
  constructor(hash, priority) {
@@ -1,6 +1,5 @@
1
- import { t as Request } from "./Request-C0UUuQIX.js";
2
- import "./Codes-CjiW7Pdl.js";
3
- import { s as UByteTag } from "./Tag-CZF6BRMY.js";
1
+ import { t as Request } from "./Request-YQ0nIM6b.js";
2
+ import { s as UByteTag } from "./Tag-D_Ybe5RQ.js";
4
3
  //#region src/request/SharedFilesRequest.ts
5
4
  /**
6
5
  * Shared Files Request - Get shared files list
@@ -0,0 +1,45 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
+ import { f as findNumericTag, p as findTag } from "./Tag-D_Ybe5RQ.js";
3
+ import { a as toOptionalNumber, n as tagOwnNumericValue } from "./utils-CNoUroOI.js";
4
+ //#region src/response/SharedFilesResponse.ts
5
+ var SharedFilesResponse_exports = /* @__PURE__ */ __exportAll({
6
+ SharedFilesResponseParser: () => SharedFilesResponseParser,
7
+ parseKnownFileFields: () => parseKnownFileFields
8
+ });
9
+ /**
10
+ * Parse the fields shared by every known-file shaped tag (EC_TAG_KNOWNFILE and
11
+ * EC_TAG_PARTFILE both carry them).
12
+ */
13
+ function parseKnownFileFields(fileTag) {
14
+ const tags = fileTag.nestedTags || [];
15
+ const hashTag = findTag(tags, 798);
16
+ const fileNameTag = findTag(tags, 769);
17
+ return {
18
+ ecid: tagOwnNumericValue(fileTag),
19
+ fileHashHexString: hashTag ? hashTag.getValue().toString("hex") : void 0,
20
+ fileName: fileNameTag ? fileNameTag.getValue() : void 0,
21
+ filePath: findTag(tags, 1032)?.getValue(),
22
+ sizeFull: toOptionalNumber(findNumericTag(tags, 771)?.getLong()),
23
+ fileEd2kLink: findTag(tags, 782)?.getValue(),
24
+ upPrio: findNumericTag(tags, 1035)?.getInt(),
25
+ getRequests: findNumericTag(tags, 1027)?.getShort(),
26
+ getAllRequests: findNumericTag(tags, 1028)?.getInt(),
27
+ getAccepts: findNumericTag(tags, 1029)?.getShort(),
28
+ getAllAccepts: findNumericTag(tags, 1030)?.getInt(),
29
+ getXferred: toOptionalNumber(findNumericTag(tags, 1025)?.getLong()),
30
+ getAllXferred: toOptionalNumber(findNumericTag(tags, 1026)?.getLong()),
31
+ getCompleteSourcesLow: findNumericTag(tags, 1033)?.getShort(),
32
+ getCompleteSourcesHigh: findNumericTag(tags, 1034)?.getShort(),
33
+ getCompleteSources: findNumericTag(tags, 1037)?.getShort(),
34
+ getOnQueue: findNumericTag(tags, 1036)?.getShort(),
35
+ getComment: findTag(tags, 1038)?.getValue(),
36
+ getRating: findNumericTag(tags, 1039)?.getInt()
37
+ };
38
+ }
39
+ var SharedFilesResponseParser = class {
40
+ static fromPacket(packet) {
41
+ return { files: packet.tags.filter((tag) => tag.name === 1024).map(parseKnownFileFields) };
42
+ }
43
+ };
44
+ //#endregion
45
+ export { SharedFilesResponse_exports as n, parseKnownFileFields as r, SharedFilesResponseParser as t };
@@ -1,6 +1,5 @@
1
- import { t as Request } from "./Request-C0UUuQIX.js";
2
- import "./Codes-CjiW7Pdl.js";
3
- import { s as UByteTag } from "./Tag-CZF6BRMY.js";
1
+ import { t as Request } from "./Request-YQ0nIM6b.js";
2
+ import { s as UByteTag } from "./Tag-D_Ybe5RQ.js";
4
3
  //#region src/request/StatsRequest.ts
5
4
  /**
6
5
  * Stats Request - Request server statistics
@@ -1,6 +1,11 @@
1
- import "./Codes-CjiW7Pdl.js";
2
- import { f as findNumericTag, p as findTag } from "./Tag-CZF6BRMY.js";
1
+ import { f as findNumericTag, p as findTag } from "./Tag-D_Ybe5RQ.js";
2
+ import { n as tagOwnNumericValue } from "./utils-CNoUroOI.js";
3
3
  //#region src/response/StatsResponse.ts
4
+ const CONNSTATE_ED2K_CONNECTED = 1;
5
+ const CONNSTATE_ED2K_CONNECTING = 2;
6
+ const CONNSTATE_KAD_CONNECTED = 4;
7
+ const CONNSTATE_KAD_FIREWALLED = 8;
8
+ const CONNSTATE_KAD_RUNNING = 16;
4
9
  var StatsResponseParser = class {
5
10
  static fromPacket(packet) {
6
11
  const uploadOverhead = findNumericTag(packet.tags, 516)?.getValue() || 0;
@@ -25,6 +30,7 @@ var StatsResponseParser = class {
25
30
  let clientId = 0;
26
31
  let kadId;
27
32
  let connectedServer;
33
+ let connectionState;
28
34
  if (connStateTag && connStateTag.nestedTags) {
29
35
  ed2kId = Number(findNumericTag(connStateTag.nestedTags, 6)?.getValue() || 0);
30
36
  clientId = Number(findNumericTag(connStateTag.nestedTags, 10)?.getValue() || 0);
@@ -44,6 +50,22 @@ var StatsResponseParser = class {
44
50
  description: findTag(serverTag.nestedTags || [], 1282)?.getValue()
45
51
  };
46
52
  }
53
+ const stateBits = tagOwnNumericValue(connStateTag) ?? 0;
54
+ connectionState = {
55
+ ed2kConnected: (stateBits & CONNSTATE_ED2K_CONNECTED) !== 0,
56
+ ed2kConnecting: (stateBits & CONNSTATE_ED2K_CONNECTING) !== 0,
57
+ kadConnected: (stateBits & CONNSTATE_KAD_CONNECTED) !== 0,
58
+ kadFirewalled: (stateBits & CONNSTATE_KAD_FIREWALLED) !== 0,
59
+ kadRunning: (stateBits & CONNSTATE_KAD_RUNNING) !== 0,
60
+ ed2kId: ed2kId || void 0,
61
+ clientId: clientId || void 0,
62
+ serverIpv4: connectedServer ? {
63
+ address: connectedServer.ip,
64
+ port: connectedServer.port
65
+ } : void 0,
66
+ serverName: connectedServer?.name,
67
+ serverDescription: connectedServer?.description
68
+ };
47
69
  }
48
70
  const id = clientId || Number(findNumericTag(packet.tags, 10)?.getValue() || 0);
49
71
  return {
@@ -51,6 +73,7 @@ var StatsResponseParser = class {
51
73
  ed2kId,
52
74
  kadId,
53
75
  connectedServer,
76
+ connectionState,
54
77
  uploadOverhead: Number(uploadOverhead),
55
78
  downloadOverhead: Number(downloadOverhead),
56
79
  bannedCount: Number(bannedCount),