@minip2p/react-native 0.11.1 → 0.11.2

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.
@@ -6,7 +6,7 @@
6
6
  import nativeModule from "./minip2p_ffi_core-ffi";
7
7
  import { type UniffiRustFutureContinuationCallback, type UniffiForeignFutureDroppedCallback, type UniffiForeignFutureDroppedCallbackStruct,
8
8
  } from "./minip2p_ffi_core-ffi";
9
- import { type UniffiByteArray, AbstractFfiConverterByteArray, Cursor, FfiConverterArray, FfiConverterArrayBuffer, FfiConverterBool, FfiConverterOptional, FfiConverterUInt32, FfiConverterUInt64, FfiConverterUInt8, RustBuffer, UniffiEnum, UniffiError, UniffiInternalError, UniffiRustCaller, uniffiCreateFfiConverterString, uniffiCreateRecord, uniffiTypeNameSymbol, variantOrdinalSymbol,
9
+ import { type UniffiByteArray, AbstractFfiConverterByteArray, Cursor, FfiConverterArray, FfiConverterArrayBuffer, FfiConverterBool, FfiConverterFloat32, FfiConverterOptional, FfiConverterUInt32, FfiConverterUInt64, FfiConverterUInt8, RustBuffer, UniffiEnum, UniffiError, UniffiInternalError, UniffiRustCaller, uniffiCreateFfiConverterString, uniffiCreateRecord, uniffiTypeNameSymbol, variantOrdinalSymbol,
10
10
  } from "@ubjs/core";
11
11
  const uniffiCaller = new UniffiRustCaller(() => ({ code: 0 }));
12
12
 
@@ -611,6 +611,49 @@ const FfiConverterTypeWindowLimit = (() => {
611
611
  return new FFIConverter();
612
612
  })();
613
613
 
614
+ /**
615
+ * A QUIC congestion controller; mirrors `minip2p::CongestionController`.
616
+ */
617
+ export enum CongestionController {
618
+ /**
619
+ * CUBIC, the default.
620
+ */
621
+ Cubic,
622
+ /**
623
+ * NewReno.
624
+ */
625
+ NewReno,
626
+ /**
627
+ * BBR (experimental in quinn).
628
+ */
629
+ Bbr
630
+ }
631
+
632
+ const FfiConverterTypeCongestionController = (() => {
633
+ type TypeName = CongestionController;
634
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
635
+ readFromCursor(c: Cursor): TypeName {
636
+ switch (c.readI32()) {
637
+ case 1: return CongestionController.Cubic;
638
+ case 2: return CongestionController.NewReno;
639
+ case 3: return CongestionController.Bbr;
640
+ default: throw new UniffiInternalError.UnexpectedEnumCase();
641
+ }
642
+ }
643
+ writeIntoCursor(value: TypeName, c: Cursor): void {
644
+ switch (value) {
645
+ case CongestionController.Cubic: return c.writeI32(1);
646
+ case CongestionController.NewReno: return c.writeI32(2);
647
+ case CongestionController.Bbr: return c.writeI32(3);
648
+ }
649
+ }
650
+ allocationSize(value: TypeName): number {
651
+ return 4;
652
+ }
653
+ }
654
+ return new FFIConverter();
655
+ })();
656
+
614
657
  /**
615
658
  * QUIC overrides; each field mirrors `minip2p::QuicLimits`.
616
659
  */
@@ -664,7 +707,21 @@ export type QuicLimitsOptions = {
664
707
  * Time an `h3` connection has to complete Noise, in milliseconds;
665
708
  * non-zero.
666
709
  */
667
- webtransportHandshakeTimeoutMs?: bigint
710
+ webtransportHandshakeTimeoutMs?: bigint,
711
+ /**
712
+ * Congestion controller each connection runs (Cubic by default).
713
+ */
714
+ congestionController?: CongestionController,
715
+ /**
716
+ * Packets acknowledged past a missing one before it is declared lost;
717
+ * at least 3.
718
+ */
719
+ packetThreshold?: number,
720
+ /**
721
+ * Multiple of the RTT a missing packet may wait before it is declared
722
+ * lost; between 1.0 and 10.0.
723
+ */
724
+ timeThreshold?: number
668
725
  }
669
726
 
670
727
  /**
@@ -683,7 +740,10 @@ export const QuicLimitsOptions = (() => {
683
740
  streamReceiveWindow: undefined,
684
741
  connectionReceiveWindow: undefined,
685
742
  sendWindow: undefined,
686
- webtransportHandshakeTimeoutMs: undefined
743
+ webtransportHandshakeTimeoutMs: undefined,
744
+ congestionController: undefined,
745
+ packetThreshold: undefined,
746
+ timeThreshold: undefined
687
747
  });
688
748
  const create = (() => {
689
749
  return uniffiCreateRecord<QuicLimitsOptions, ReturnType<typeof defaults>>(defaults);
@@ -711,7 +771,10 @@ const FfiConverterTypeQuicLimitsOptions = (() => {
711
771
  streamReceiveWindow: FfiConverterOptionalUInt64.readFromCursor(c),
712
772
  connectionReceiveWindow: FfiConverterOptionalTypeWindowLimit.readFromCursor(c),
713
773
  sendWindow: FfiConverterOptionalUInt64.readFromCursor(c),
714
- webtransportHandshakeTimeoutMs: FfiConverterOptionalUInt64.readFromCursor(c)
774
+ webtransportHandshakeTimeoutMs: FfiConverterOptionalUInt64.readFromCursor(c),
775
+ congestionController: FfiConverterOptionalTypeCongestionController.readFromCursor(c),
776
+ packetThreshold: FfiConverterOptionalUInt32.readFromCursor(c),
777
+ timeThreshold: FfiConverterOptionalFloat32.readFromCursor(c)
715
778
  };
716
779
  }
717
780
  writeIntoCursor(value: TypeName, c: Cursor): void {
@@ -727,6 +790,9 @@ const FfiConverterTypeQuicLimitsOptions = (() => {
727
790
  FfiConverterOptionalTypeWindowLimit.writeIntoCursor(value.connectionReceiveWindow, c);
728
791
  FfiConverterOptionalUInt64.writeIntoCursor(value.sendWindow, c);
729
792
  FfiConverterOptionalUInt64.writeIntoCursor(value.webtransportHandshakeTimeoutMs, c);
793
+ FfiConverterOptionalTypeCongestionController.writeIntoCursor(value.congestionController, c);
794
+ FfiConverterOptionalUInt32.writeIntoCursor(value.packetThreshold, c);
795
+ FfiConverterOptionalFloat32.writeIntoCursor(value.timeThreshold, c);
730
796
  }
731
797
  allocationSize(value: TypeName): number {
732
798
  return FfiConverterOptionalUInt64.allocationSize(value.maxConnections) +
@@ -740,7 +806,10 @@ const FfiConverterTypeQuicLimitsOptions = (() => {
740
806
  FfiConverterOptionalUInt64.allocationSize(value.streamReceiveWindow) +
741
807
  FfiConverterOptionalTypeWindowLimit.allocationSize(value.connectionReceiveWindow) +
742
808
  FfiConverterOptionalUInt64.allocationSize(value.sendWindow) +
743
- FfiConverterOptionalUInt64.allocationSize(value.webtransportHandshakeTimeoutMs);
809
+ FfiConverterOptionalUInt64.allocationSize(value.webtransportHandshakeTimeoutMs) +
810
+ FfiConverterOptionalTypeCongestionController.allocationSize(value.congestionController) +
811
+ FfiConverterOptionalUInt32.allocationSize(value.packetThreshold) +
812
+ FfiConverterOptionalFloat32.allocationSize(value.timeThreshold);
744
813
 
745
814
  }
746
815
  };
@@ -1135,6 +1204,75 @@ const FfiConverterTypeLimitsOptions = (() => {
1135
1204
  return new FFIConverter();
1136
1205
  })();
1137
1206
 
1207
+ /**
1208
+ * Protocol deadline overrides, in milliseconds; each mirrors a
1209
+ * `minip2p::SwarmTimeouts` field.
1210
+ *
1211
+ * An absent record or field keeps the native default (10 s each). A zero
1212
+ * fails construction with `InvalidConfig { capability: Options }`. Keep
1213
+ * `identify_ms` at least `negotiation_ms`: the first Identify includes a
1214
+ * negotiation.
1215
+ */
1216
+ export type TimeoutsOptions = {
1217
+ /**
1218
+ * How long an outbound stream may negotiate its protocol.
1219
+ */
1220
+ negotiationMs?: bigint,
1221
+ /**
1222
+ * How long a connection's first Identify may take before the
1223
+ * connection is closed.
1224
+ */
1225
+ identifyMs?: bigint,
1226
+ /**
1227
+ * How long a ping waits for its echo.
1228
+ */
1229
+ pingMs?: bigint
1230
+ }
1231
+
1232
+ /**
1233
+ * Generated factory for {@link TimeoutsOptions} record objects.
1234
+ */
1235
+ export const TimeoutsOptions = (() => {
1236
+ const defaults = () => ({
1237
+ negotiationMs: undefined,
1238
+ identifyMs: undefined,
1239
+ pingMs: undefined
1240
+ });
1241
+ const create = (() => {
1242
+ return uniffiCreateRecord<TimeoutsOptions, ReturnType<typeof defaults>>(defaults);
1243
+ })();
1244
+ return Object.freeze({
1245
+ create,
1246
+ new: create,
1247
+ defaults: () => Object.freeze(defaults()) as Partial<TimeoutsOptions>,
1248
+ });
1249
+ })();
1250
+
1251
+ const FfiConverterTypeTimeoutsOptions = (() => {
1252
+ type TypeName = TimeoutsOptions;
1253
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
1254
+ readFromCursor(c: Cursor): TypeName {
1255
+ return {
1256
+ negotiationMs: FfiConverterOptionalUInt64.readFromCursor(c),
1257
+ identifyMs: FfiConverterOptionalUInt64.readFromCursor(c),
1258
+ pingMs: FfiConverterOptionalUInt64.readFromCursor(c)
1259
+ };
1260
+ }
1261
+ writeIntoCursor(value: TypeName, c: Cursor): void {
1262
+ FfiConverterOptionalUInt64.writeIntoCursor(value.negotiationMs, c);
1263
+ FfiConverterOptionalUInt64.writeIntoCursor(value.identifyMs, c);
1264
+ FfiConverterOptionalUInt64.writeIntoCursor(value.pingMs, c);
1265
+ }
1266
+ allocationSize(value: TypeName): number {
1267
+ return FfiConverterOptionalUInt64.allocationSize(value.negotiationMs) +
1268
+ FfiConverterOptionalUInt64.allocationSize(value.identifyMs) +
1269
+ FfiConverterOptionalUInt64.allocationSize(value.pingMs);
1270
+
1271
+ }
1272
+ };
1273
+ return new FFIConverter();
1274
+ })();
1275
+
1138
1276
  /**
1139
1277
  * Configuration used to construct an FFI endpoint.
1140
1278
  */
@@ -1182,7 +1320,11 @@ export type EndpointConfig = {
1182
1320
  /**
1183
1321
  * Transport limit overrides, or every native default when absent.
1184
1322
  */
1185
- limits?: LimitsOptions
1323
+ limits?: LimitsOptions,
1324
+ /**
1325
+ * Protocol deadline overrides, or every native default when absent.
1326
+ */
1327
+ timeouts?: TimeoutsOptions
1186
1328
  }
1187
1329
 
1188
1330
  /**
@@ -1215,7 +1357,8 @@ const FfiConverterTypeEndpointConfig = (() => {
1215
1357
  protocols: FfiConverterSequenceString.readFromCursor(c),
1216
1358
  discovery: FfiConverterOptionalTypeDiscoveryOptions.readFromCursor(c),
1217
1359
  mdns: FfiConverterOptionalTypeMdnsOptions.readFromCursor(c),
1218
- limits: FfiConverterOptionalTypeLimitsOptions.readFromCursor(c)
1360
+ limits: FfiConverterOptionalTypeLimitsOptions.readFromCursor(c),
1361
+ timeouts: FfiConverterOptionalTypeTimeoutsOptions.readFromCursor(c)
1219
1362
  };
1220
1363
  }
1221
1364
  writeIntoCursor(value: TypeName, c: Cursor): void {
@@ -1229,6 +1372,7 @@ const FfiConverterTypeEndpointConfig = (() => {
1229
1372
  FfiConverterOptionalTypeDiscoveryOptions.writeIntoCursor(value.discovery, c);
1230
1373
  FfiConverterOptionalTypeMdnsOptions.writeIntoCursor(value.mdns, c);
1231
1374
  FfiConverterOptionalTypeLimitsOptions.writeIntoCursor(value.limits, c);
1375
+ FfiConverterOptionalTypeTimeoutsOptions.writeIntoCursor(value.timeouts, c);
1232
1376
  }
1233
1377
  allocationSize(value: TypeName): number {
1234
1378
  return FfiConverterOptionalString.allocationSize(value.agentVersion) +
@@ -1240,7 +1384,8 @@ const FfiConverterTypeEndpointConfig = (() => {
1240
1384
  FfiConverterSequenceString.allocationSize(value.protocols) +
1241
1385
  FfiConverterOptionalTypeDiscoveryOptions.allocationSize(value.discovery) +
1242
1386
  FfiConverterOptionalTypeMdnsOptions.allocationSize(value.mdns) +
1243
- FfiConverterOptionalTypeLimitsOptions.allocationSize(value.limits);
1387
+ FfiConverterOptionalTypeLimitsOptions.allocationSize(value.limits) +
1388
+ FfiConverterOptionalTypeTimeoutsOptions.allocationSize(value.timeouts);
1244
1389
 
1245
1390
  }
1246
1391
  };
@@ -5384,15 +5529,21 @@ const FfiConverterOptionalBoolean = new FfiConverterOptional(FfiConverterBool);
5384
5529
  // FfiConverter for WindowLimit | undefined
5385
5530
  const FfiConverterOptionalTypeWindowLimit = new FfiConverterOptional(FfiConverterTypeWindowLimit);
5386
5531
 
5532
+ // FfiConverter for CongestionController | undefined
5533
+ const FfiConverterOptionalTypeCongestionController = new FfiConverterOptional(FfiConverterTypeCongestionController);
5534
+
5535
+ // FfiConverter for number | undefined
5536
+ const FfiConverterOptionalUInt32 = new FfiConverterOptional(FfiConverterUInt32);
5537
+
5538
+ // FfiConverter for number | undefined
5539
+ const FfiConverterOptionalFloat32 = new FfiConverterOptional(FfiConverterFloat32);
5540
+
5387
5541
  // FfiConverter for QuicLimitsOptions | undefined
5388
5542
  const FfiConverterOptionalTypeQuicLimitsOptions = new FfiConverterOptional(FfiConverterTypeQuicLimitsOptions);
5389
5543
 
5390
5544
  // FfiConverter for TimeoutLimit | undefined
5391
5545
  const FfiConverterOptionalTypeTimeoutLimit = new FfiConverterOptional(FfiConverterTypeTimeoutLimit);
5392
5546
 
5393
- // FfiConverter for number | undefined
5394
- const FfiConverterOptionalUInt32 = new FfiConverterOptional(FfiConverterUInt32);
5395
-
5396
5547
  // FfiConverter for YamuxOptions | undefined
5397
5548
  const FfiConverterOptionalTypeYamuxOptions = new FfiConverterOptional(FfiConverterTypeYamuxOptions);
5398
5549
 
@@ -5402,6 +5553,9 @@ const FfiConverterOptionalTypeTcpLimitsOptions = new FfiConverterOptional(FfiCon
5402
5553
  // FfiConverter for LimitsOptions | undefined
5403
5554
  const FfiConverterOptionalTypeLimitsOptions = new FfiConverterOptional(FfiConverterTypeLimitsOptions);
5404
5555
 
5556
+ // FfiConverter for TimeoutsOptions | undefined
5557
+ const FfiConverterOptionalTypeTimeoutsOptions = new FfiConverterOptional(FfiConverterTypeTimeoutsOptions);
5558
+
5405
5559
  // FfiConverter for ArrayBuffer | undefined
5406
5560
  const FfiConverterOptionalBytes = new FfiConverterOptional(FfiConverterArrayBuffer);
5407
5561
 
@@ -5438,6 +5592,7 @@ export default Object.freeze({
5438
5592
  converters: {
5439
5593
  FfiConverterTypeCloseOutcome,
5440
5594
  FfiConverterTypeConfigCapability,
5595
+ FfiConverterTypeCongestionController,
5441
5596
  FfiConverterTypeConnectTarget,
5442
5597
  FfiConverterTypeConnectionCloseReason,
5443
5598
  FfiConverterTypeConnectionInfo,
@@ -5461,6 +5616,7 @@ export default Object.freeze({
5461
5616
  FfiConverterTypeRelayReservationInfo,
5462
5617
  FfiConverterTypeTcpLimitsOptions,
5463
5618
  FfiConverterTypeTimeoutLimit,
5619
+ FfiConverterTypeTimeoutsOptions,
5464
5620
  FfiConverterTypeUnfinishedConnection,
5465
5621
  FfiConverterTypeWindowLimit,
5466
5622
  FfiConverterTypeYamuxOptions,