@minip2p/react-native 0.10.1 → 0.10.3
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/android/src/main/jniLibs/arm64-v8a/libminip2p_ffi.so +0 -0
- package/android/src/main/jniLibs/x86_64/libminip2p_ffi.so +0 -0
- package/build/Minip2pFfi.xcframework/ios-arm64/libminip2p_ffi.a +2 -2
- package/build/Minip2pFfi.xcframework/ios-arm64-simulator/libminip2p_ffi.a +2 -2
- package/lib/module/adapter.js +44 -2
- package/lib/module/adapter.js.map +1 -1
- package/lib/module/generated/minip2p_ffi_core.js +507 -6
- package/lib/module/generated/minip2p_ffi_core.js.map +1 -1
- package/lib/typescript/src/adapter.d.ts.map +1 -1
- package/lib/typescript/src/generated/minip2p_ffi_core.d.ts +382 -2
- package/lib/typescript/src/generated/minip2p_ffi_core.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/adapter.ts +55 -1
- package/src/generated/minip2p_ffi_core.ts +703 -6
package/src/adapter.ts
CHANGED
|
@@ -33,6 +33,8 @@ import type {
|
|
|
33
33
|
BackendClosed,
|
|
34
34
|
BackendConnectionInfo,
|
|
35
35
|
BackendConnectTarget,
|
|
36
|
+
BackendEndpointConfig,
|
|
37
|
+
BackendLimits,
|
|
36
38
|
Minip2pBackend,
|
|
37
39
|
Minip2pBackendFactory,
|
|
38
40
|
BackendOpenStream,
|
|
@@ -52,13 +54,17 @@ import {
|
|
|
52
54
|
NatErrorKind as NativeNatErrorKind,
|
|
53
55
|
P2pEndpoint,
|
|
54
56
|
Reachability as NativeReachability,
|
|
57
|
+
TimeoutLimit,
|
|
58
|
+
WindowLimit,
|
|
55
59
|
circuitAddress as nativeCircuitAddress,
|
|
56
60
|
generateSecretKey as nativeGenerateSecretKey,
|
|
57
61
|
peerIdFromSecretKey as nativePeerIdFromSecretKey,
|
|
58
62
|
} from "./native";
|
|
59
63
|
import type {
|
|
64
|
+
EndpointConfig as NativeEndpointConfig,
|
|
60
65
|
IdentifyInfo as NativeIdentifyInfo,
|
|
61
66
|
KnownPeerInfo as NativeKnownPeerInfo,
|
|
67
|
+
LimitsOptions as NativeLimitsOptions,
|
|
62
68
|
P2pEvent as NativeP2pEvent,
|
|
63
69
|
P2pEventDoorbell,
|
|
64
70
|
RelayReservationInfo as NativeRelayReservationInfo,
|
|
@@ -86,7 +92,7 @@ class ReactNativeBackend implements Minip2pBackend {
|
|
|
86
92
|
() =>
|
|
87
93
|
new P2pEndpoint(
|
|
88
94
|
toArrayBuffer(config.secretKey),
|
|
89
|
-
resolveEndpointConfig(config)
|
|
95
|
+
nativeEndpointConfig(resolveEndpointConfig(config))
|
|
90
96
|
)
|
|
91
97
|
);
|
|
92
98
|
} catch (error) {
|
|
@@ -636,6 +642,54 @@ function normalizeBigInts(
|
|
|
636
642
|
return value;
|
|
637
643
|
}
|
|
638
644
|
|
|
645
|
+
/** The resolved config with its limit literals as UniFFI enums. */
|
|
646
|
+
function nativeEndpointConfig(
|
|
647
|
+
config: BackendEndpointConfig
|
|
648
|
+
): NativeEndpointConfig {
|
|
649
|
+
return { ...config, limits: config.limits && nativeLimits(config.limits) };
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
function nativeLimits({
|
|
653
|
+
quic,
|
|
654
|
+
tcp,
|
|
655
|
+
...rest
|
|
656
|
+
}: BackendLimits): NativeLimitsOptions {
|
|
657
|
+
return {
|
|
658
|
+
...rest,
|
|
659
|
+
quic: quic && {
|
|
660
|
+
...quic,
|
|
661
|
+
connectionReceiveWindow: nativeWindow(quic.connectionReceiveWindow),
|
|
662
|
+
},
|
|
663
|
+
tcp: tcp && {
|
|
664
|
+
...tcp,
|
|
665
|
+
handshakeTimeoutMs: nativeTimeout(tcp.handshakeTimeoutMs),
|
|
666
|
+
sendStallTimeoutMs: nativeTimeout(tcp.sendStallTimeoutMs),
|
|
667
|
+
},
|
|
668
|
+
};
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
function nativeWindow(
|
|
672
|
+
window: bigint | "unlimited" | undefined
|
|
673
|
+
): WindowLimit | undefined {
|
|
674
|
+
if (window === undefined) {
|
|
675
|
+
return undefined;
|
|
676
|
+
}
|
|
677
|
+
return window === "unlimited"
|
|
678
|
+
? WindowLimit.Unlimited.new()
|
|
679
|
+
: WindowLimit.Bounded.new({ bytes: window });
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
function nativeTimeout(
|
|
683
|
+
timeout: bigint | "never" | undefined
|
|
684
|
+
): TimeoutLimit | undefined {
|
|
685
|
+
if (timeout === undefined) {
|
|
686
|
+
return undefined;
|
|
687
|
+
}
|
|
688
|
+
return timeout === "never"
|
|
689
|
+
? TimeoutLimit.Never.new()
|
|
690
|
+
: TimeoutLimit.AfterMs.new({ ms: timeout });
|
|
691
|
+
}
|
|
692
|
+
|
|
639
693
|
/**
|
|
640
694
|
* The `ArrayBuffer` UniFFI lowers. Lowering copies the bytes into a Rust
|
|
641
695
|
* buffer before the call returns, so a view covering its whole
|