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
@@ -389,6 +389,14 @@ let ECSearchType = /* @__PURE__ */ function(ECSearchType) {
389
389
  ECSearchType[ECSearchType["EC_SEARCH_WEB"] = 3] = "EC_SEARCH_WEB";
390
390
  return ECSearchType;
391
391
  }({});
392
+ let ECSearchFileDownloadStatus = /* @__PURE__ */ function(ECSearchFileDownloadStatus) {
393
+ ECSearchFileDownloadStatus[ECSearchFileDownloadStatus["NEW"] = 0] = "NEW";
394
+ ECSearchFileDownloadStatus[ECSearchFileDownloadStatus["DOWNLOADED"] = 1] = "DOWNLOADED";
395
+ ECSearchFileDownloadStatus[ECSearchFileDownloadStatus["QUEUED"] = 2] = "QUEUED";
396
+ ECSearchFileDownloadStatus[ECSearchFileDownloadStatus["CANCELED"] = 3] = "CANCELED";
397
+ ECSearchFileDownloadStatus[ECSearchFileDownloadStatus["QUEUEDCANCELED"] = 4] = "QUEUEDCANCELED";
398
+ return ECSearchFileDownloadStatus;
399
+ }({});
392
400
  let EcPrefs = /* @__PURE__ */ function(EcPrefs) {
393
401
  EcPrefs[EcPrefs["EC_PREFS_CATEGORIES"] = 1] = "EC_PREFS_CATEGORIES";
394
402
  EcPrefs[EcPrefs["EC_PREFS_GENERAL"] = 2] = "EC_PREFS_GENERAL";
@@ -406,4 +414,275 @@ let EcPrefs = /* @__PURE__ */ function(EcPrefs) {
406
414
  return EcPrefs;
407
415
  }({});
408
416
  //#endregion
409
- export { EcPrefs as a, ECTagName as i, ECOpCode as n, ProtocolVersion as o, ECSearchType as r, ECDetailLevel as t };
417
+ //#region src/ec/tag/Tag.ts
418
+ var Tag = class {
419
+ name;
420
+ type;
421
+ nameValue;
422
+ value;
423
+ nestedTags;
424
+ constructor(name, type, nestedTags = [], nameValue = name) {
425
+ this.name = name;
426
+ this.type = type;
427
+ this.nameValue = nameValue;
428
+ if (nestedTags.length > 0) this.nestedTags = nestedTags;
429
+ }
430
+ getValue() {
431
+ return this.value;
432
+ }
433
+ setValue(value) {
434
+ this.value = value;
435
+ }
436
+ };
437
+ var CustomTag = class extends Tag {
438
+ constructor(name, value, subtags = [], nameValue = name) {
439
+ super(name, 1, subtags, nameValue);
440
+ if (value !== void 0) this.setValue(value);
441
+ }
442
+ parseValue(value) {
443
+ this.setValue(value);
444
+ }
445
+ encodeValue() {
446
+ return this.getValue();
447
+ }
448
+ };
449
+ var UByteTag = class UByteTag extends Tag {
450
+ constructor(name, value, subtags = [], nameValue = name) {
451
+ super(name, 2, subtags, nameValue);
452
+ if (value !== void 0) this.setValue(value);
453
+ }
454
+ static withValue(name, value, subtags = []) {
455
+ return new UByteTag(name, value, subtags);
456
+ }
457
+ parseValue(value) {
458
+ if (value.length === 0) this.setValue(0);
459
+ else if (value.length === 1) this.setValue(value[0]);
460
+ else throw new Error("UInt8Tag value must be 1 byte long");
461
+ }
462
+ encodeValue() {
463
+ const buf = Buffer.allocUnsafe(1);
464
+ buf.writeUInt8(this.getValue());
465
+ return buf;
466
+ }
467
+ getShort() {
468
+ return this.getValue();
469
+ }
470
+ getInt() {
471
+ return this.getValue();
472
+ }
473
+ getLong() {
474
+ return BigInt(this.getValue());
475
+ }
476
+ };
477
+ var UShortTag = class UShortTag extends Tag {
478
+ constructor(name, value, subtags = [], nameValue = name) {
479
+ super(name, 3, subtags, nameValue);
480
+ if (value !== void 0) this.setValue(value);
481
+ }
482
+ static withValue(name, value, subtags = []) {
483
+ return new UShortTag(name, value, subtags);
484
+ }
485
+ parseValue(value) {
486
+ if (value.length === 0) this.setValue(0);
487
+ else if (value.length === 2) this.setValue(value.readUInt16BE(0));
488
+ else throw new Error("UInt16Tag value must be 2 bytes long");
489
+ }
490
+ encodeValue() {
491
+ const buf = Buffer.allocUnsafe(2);
492
+ buf.writeUInt16BE(this.getValue());
493
+ return buf;
494
+ }
495
+ getShort() {
496
+ return this.getValue();
497
+ }
498
+ getInt() {
499
+ return this.getValue();
500
+ }
501
+ getLong() {
502
+ return BigInt(this.getValue());
503
+ }
504
+ };
505
+ var UIntTag = class UIntTag extends Tag {
506
+ constructor(name, value, subtags = [], nameValue = name) {
507
+ super(name, 4, subtags, nameValue);
508
+ if (value !== void 0) this.setValue(value);
509
+ }
510
+ static withValue(name, value, subtags = []) {
511
+ return new UIntTag(name, value, subtags);
512
+ }
513
+ parseValue(value) {
514
+ if (value.length === 0) this.setValue(0);
515
+ else if (value.length === 4) this.setValue(value.readUInt32BE(0));
516
+ else throw new Error("UInt32Tag value must be 4 bytes long");
517
+ }
518
+ encodeValue() {
519
+ const buf = Buffer.allocUnsafe(4);
520
+ buf.writeUInt32BE(this.getValue());
521
+ return buf;
522
+ }
523
+ getShort() {
524
+ throw new Error("Unsigned Integer cannot be cast to short");
525
+ }
526
+ getInt() {
527
+ return this.getValue();
528
+ }
529
+ getLong() {
530
+ return BigInt(this.getValue());
531
+ }
532
+ };
533
+ var ULongTag = class ULongTag extends Tag {
534
+ constructor(name, value, subtags = [], nameValue = name) {
535
+ super(name, 5, subtags, nameValue);
536
+ if (value !== void 0) this.setValue(value);
537
+ }
538
+ static withValue(name, value, subtags = []) {
539
+ return new ULongTag(name, value, subtags);
540
+ }
541
+ parseValue(value) {
542
+ if (value.length === 0) this.setValue(0n);
543
+ else if (value.length === 8) this.setValue(value.readBigUInt64BE(0));
544
+ else throw new Error("UInt64Tag value must be 8 bytes long");
545
+ }
546
+ encodeValue() {
547
+ const buf = Buffer.allocUnsafe(8);
548
+ buf.writeBigUInt64BE(this.getValue());
549
+ return buf;
550
+ }
551
+ getShort() {
552
+ throw new Error("Unsigned Long cannot be cast to short");
553
+ }
554
+ getInt() {
555
+ throw new Error("Unsigned Long cannot be cast to int");
556
+ }
557
+ getLong() {
558
+ return this.getValue();
559
+ }
560
+ };
561
+ var UInt128Tag = class UInt128Tag extends Tag {
562
+ constructor(name, value, subtags = [], nameValue = name) {
563
+ super(name, 10, subtags, nameValue);
564
+ if (value !== void 0) this.setValue(value);
565
+ }
566
+ static withValue(name, value, subtags = []) {
567
+ return new UInt128Tag(name, value, subtags);
568
+ }
569
+ parseValue(value) {
570
+ if (value.length === 0) this.setValue(0n);
571
+ else {
572
+ let result = 0n;
573
+ for (let i = 0; i < value.length; i++) result = result << 8n | BigInt(value[i]);
574
+ this.setValue(result);
575
+ }
576
+ }
577
+ encodeValue() {
578
+ const val = this.getValue();
579
+ const bytes = [];
580
+ let remaining = val;
581
+ while (remaining > 0n) {
582
+ bytes.unshift(Number(remaining & 255n));
583
+ remaining >>= 8n;
584
+ }
585
+ while (bytes.length < 16) bytes.unshift(0);
586
+ return Buffer.from(bytes);
587
+ }
588
+ };
589
+ var StringTag = class StringTag extends Tag {
590
+ constructor(name, value, subtags = [], nameValue = name) {
591
+ super(name, 6, subtags, nameValue);
592
+ if (value !== void 0) this.setValue(value);
593
+ }
594
+ static withValue(name, value, subtags = []) {
595
+ return new StringTag(name, value, subtags);
596
+ }
597
+ parseValue(value) {
598
+ if (value[value.length - 1] !== 0) throw new Error("StringTag value must be null terminated");
599
+ this.setValue(value.toString("utf8", 0, value.length - 1));
600
+ }
601
+ encodeValue() {
602
+ return Buffer.concat([Buffer.from(this.getValue(), "utf8"), Buffer.from([0])]);
603
+ }
604
+ };
605
+ /**
606
+ * EC_TAGTYPE_DOUBLE tags are transmitted as a null-terminated ASCII decimal string,
607
+ * not as a binary double (see CECTag(ec_tagname_t, double) in aMule's ECTag.cpp).
608
+ */
609
+ var DoubleTag = class DoubleTag extends Tag {
610
+ constructor(name, value, subtags = [], nameValue = name) {
611
+ super(name, 7, subtags, nameValue);
612
+ if (value !== void 0) this.setValue(value);
613
+ }
614
+ static withValue(name, value, subtags = []) {
615
+ return new DoubleTag(name, value, subtags);
616
+ }
617
+ parseValue(value) {
618
+ const end = value.length > 0 && value[value.length - 1] === 0 ? value.length - 1 : value.length;
619
+ const numValue = Number.parseFloat(value.toString("utf8", 0, end));
620
+ this.setValue(Number.isNaN(numValue) ? 0 : numValue);
621
+ }
622
+ encodeValue() {
623
+ return Buffer.concat([Buffer.from(this.getValue().toString(), "utf8"), Buffer.from([0])]);
624
+ }
625
+ getShort() {
626
+ return this.getValue();
627
+ }
628
+ getInt() {
629
+ return this.getValue();
630
+ }
631
+ getLong() {
632
+ return BigInt(Math.round(this.getValue()));
633
+ }
634
+ };
635
+ var Ipv4Tag = class Ipv4Tag extends Tag {
636
+ constructor(name, value, subtags = [], nameValue = name) {
637
+ super(name, 8, subtags, nameValue);
638
+ if (value !== void 0) this.setValue(value);
639
+ }
640
+ static withValue(name, value, subtags = []) {
641
+ return new Ipv4Tag(name, value, subtags);
642
+ }
643
+ parseValue(value) {
644
+ if (value.length !== 6) throw new Error("Ipv4Tag value must be 6 bytes long");
645
+ const address = `${value[0]}.${value[1]}.${value[2]}.${value[3]}`;
646
+ const port = value.readUInt16BE(4);
647
+ this.setValue({
648
+ address,
649
+ port
650
+ });
651
+ }
652
+ encodeValue() {
653
+ const val = this.getValue();
654
+ const parts = val.address.split(".").map(Number);
655
+ const buf = Buffer.allocUnsafe(6);
656
+ buf[0] = parts[0];
657
+ buf[1] = parts[1];
658
+ buf[2] = parts[2];
659
+ buf[3] = parts[3];
660
+ buf.writeUInt16BE(val.port, 4);
661
+ return buf;
662
+ }
663
+ };
664
+ var Hash16Tag = class Hash16Tag extends Tag {
665
+ constructor(name, value, subtags = [], nameValue = name) {
666
+ super(name, 9, subtags, nameValue);
667
+ if (value !== void 0) this.setValue(value);
668
+ }
669
+ static withValue(name, value, subtags = []) {
670
+ return new Hash16Tag(name, value, subtags);
671
+ }
672
+ parseValue(value) {
673
+ if (value.length === 16) this.setValue(value);
674
+ else throw new Error("Hash16Tag value must be 16 bytes long");
675
+ }
676
+ encodeValue() {
677
+ return this.getValue();
678
+ }
679
+ };
680
+ function findTag(tags, name) {
681
+ return tags.find((tag) => tag.name === name);
682
+ }
683
+ function findNumericTag(tags, name) {
684
+ const tag = tags.find((tag) => tag.name === name);
685
+ if (tag && "getInt" in tag && "getShort" in tag && "getLong" in tag) return tag;
686
+ }
687
+ //#endregion
688
+ export { ECSearchType as _, StringTag as a, ProtocolVersion as b, UInt128Tag as c, UShortTag as d, findNumericTag as f, ECSearchFileDownloadStatus as g, ECOpCode as h, Ipv4Tag as i, UIntTag as l, ECDetailLevel as m, DoubleTag as n, Tag as o, findTag as p, Hash16Tag as r, UByteTag as s, CustomTag as t, ULongTag as u, ECTagName as v, EcPrefs as y };
@@ -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/UpdateCategoryRequest.ts
5
4
  /**
6
5
  * Update Category Request - Update an existing category
@@ -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/UpdateRequest.ts
5
4
  /**
6
5
  * Update Request - Get incremental updates for files, clients, and servers