@minip2p/react-native 0.1.1 → 0.3.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.
- package/README.md +25 -83
- 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 +0 -0
- package/build/Minip2pFfi.xcframework/ios-arm64-simulator/libminip2p_ffi.a +0 -0
- package/cpp/generated/minip2p_ffi.cpp +45 -2
- package/cpp/generated/minip2p_ffi.hpp +2 -0
- package/lib/module/adapter.js +16 -8
- package/lib/module/adapter.js.map +1 -1
- package/lib/module/generated/minip2p_ffi-ffi.js.map +1 -1
- package/lib/module/generated/minip2p_ffi.js +159 -46
- package/lib/module/generated/minip2p_ffi.js.map +1 -1
- package/lib/module/hook-lifecycle.js +116 -0
- package/lib/module/hook-lifecycle.js.map +1 -0
- package/lib/module/hooks.js +56 -0
- package/lib/module/hooks.js.map +1 -0
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/adapter.d.ts +4 -4
- package/lib/typescript/src/adapter.d.ts.map +1 -1
- package/lib/typescript/src/generated/minip2p_ffi-ffi.d.ts +3 -1
- package/lib/typescript/src/generated/minip2p_ffi-ffi.d.ts.map +1 -1
- package/lib/typescript/src/generated/minip2p_ffi.d.ts +89 -3
- package/lib/typescript/src/generated/minip2p_ffi.d.ts.map +1 -1
- package/lib/typescript/src/hook-lifecycle.d.ts +38 -0
- package/lib/typescript/src/hook-lifecycle.d.ts.map +1 -0
- package/lib/typescript/src/hooks.d.ts +49 -0
- package/lib/typescript/src/hooks.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +2 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/adapter.ts +40 -25
- package/src/generated/minip2p_ffi-ffi.ts +3 -1
- package/src/generated/minip2p_ffi.ts +199 -55
- package/src/hook-lifecycle.ts +152 -0
- package/src/hooks.ts +102 -0
- package/src/index.ts +8 -1
|
@@ -606,6 +606,58 @@ const FfiConverterTypeKnownPeerInfo = (() => {
|
|
|
606
606
|
return new FFIConverter();
|
|
607
607
|
})();
|
|
608
608
|
|
|
609
|
+
/**
|
|
610
|
+
* Full identity allocated for an outbound application stream.
|
|
611
|
+
*/
|
|
612
|
+
export type OpenStreamResult = {
|
|
613
|
+
/**
|
|
614
|
+
* Transport connection carrying the stream.
|
|
615
|
+
*/
|
|
616
|
+
connId: bigint,
|
|
617
|
+
/**
|
|
618
|
+
* Opaque stream id.
|
|
619
|
+
*/
|
|
620
|
+
streamId: bigint
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* Generated factory for {@link OpenStreamResult} record objects.
|
|
625
|
+
*/
|
|
626
|
+
export const OpenStreamResult = (() => {
|
|
627
|
+
const defaults = () => ({
|
|
628
|
+
});
|
|
629
|
+
const create = (() => {
|
|
630
|
+
return uniffiCreateRecord<OpenStreamResult, ReturnType<typeof defaults>>(defaults);
|
|
631
|
+
})();
|
|
632
|
+
return Object.freeze({
|
|
633
|
+
create,
|
|
634
|
+
new: create,
|
|
635
|
+
defaults: () => Object.freeze(defaults()) as Partial<OpenStreamResult>,
|
|
636
|
+
});
|
|
637
|
+
})();
|
|
638
|
+
|
|
639
|
+
const FfiConverterTypeOpenStreamResult = (() => {
|
|
640
|
+
type TypeName = OpenStreamResult;
|
|
641
|
+
class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
|
|
642
|
+
read(from: RustBuffer): TypeName {
|
|
643
|
+
return {
|
|
644
|
+
connId: FfiConverterUInt64.read(from),
|
|
645
|
+
streamId: FfiConverterUInt64.read(from)
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
write(value: TypeName, into: RustBuffer): void {
|
|
649
|
+
FfiConverterUInt64.write(value.connId, into);
|
|
650
|
+
FfiConverterUInt64.write(value.streamId, into);
|
|
651
|
+
}
|
|
652
|
+
allocationSize(value: TypeName): number {
|
|
653
|
+
return FfiConverterUInt64.allocationSize(value.connId) +
|
|
654
|
+
FfiConverterUInt64.allocationSize(value.streamId);
|
|
655
|
+
|
|
656
|
+
}
|
|
657
|
+
};
|
|
658
|
+
return new FFIConverter();
|
|
659
|
+
})();
|
|
660
|
+
|
|
609
661
|
/**
|
|
610
662
|
* Snapshot of the active inbound relay reservation.
|
|
611
663
|
*/
|
|
@@ -1839,6 +1891,7 @@ export enum P2pEvent_Tags {
|
|
|
1839
1891
|
RelayReserved = "RelayReserved",
|
|
1840
1892
|
RelayReservationLost = "RelayReservationLost",
|
|
1841
1893
|
PathEstablished = "PathEstablished",
|
|
1894
|
+
InboundPathEstablished = "InboundPathEstablished",
|
|
1842
1895
|
PathUpgraded = "PathUpgraded",
|
|
1843
1896
|
HolePunchFailed = "HolePunchFailed",
|
|
1844
1897
|
FellBackToRelay = "FellBackToRelay",
|
|
@@ -2271,7 +2324,7 @@ inner: {peerId: string; connId: bigint; streamId: bigint }): StreamClosed_ {
|
|
|
2271
2324
|
type EndpointError__interface = {
|
|
2272
2325
|
tag: P2pEvent_Tags.EndpointError;
|
|
2273
2326
|
inner:
|
|
2274
|
-
Readonly<{kind: EndpointErrorKind; peerId?: string; connId?: bigint; detail: string}>
|
|
2327
|
+
Readonly<{kind: EndpointErrorKind; peerId?: string; connId?: bigint; streamId?: bigint; detail: string}>
|
|
2275
2328
|
};
|
|
2276
2329
|
/**
|
|
2277
2330
|
* A non-fatal endpoint error occurred.
|
|
@@ -2284,15 +2337,15 @@ Readonly<{kind: EndpointErrorKind; peerId?: string; connId?: bigint; detail: str
|
|
|
2284
2337
|
readonly [uniffiTypeNameSymbol] = "P2pEvent";
|
|
2285
2338
|
readonly tag = P2pEvent_Tags.EndpointError;
|
|
2286
2339
|
readonly inner:
|
|
2287
|
-
Readonly<{kind: EndpointErrorKind; peerId?: string; connId?: bigint; detail: string}>;
|
|
2340
|
+
Readonly<{kind: EndpointErrorKind; peerId?: string; connId?: bigint; streamId?: bigint; detail: string}>;
|
|
2288
2341
|
constructor(
|
|
2289
|
-
inner: {kind: EndpointErrorKind; peerId?: string; connId?: bigint; detail: string }) {
|
|
2342
|
+
inner: {kind: EndpointErrorKind; peerId?: string; connId?: bigint; streamId?: bigint; detail: string }) {
|
|
2290
2343
|
super("P2pEvent", "EndpointError");
|
|
2291
2344
|
|
|
2292
2345
|
this.inner = Object.freeze(inner);
|
|
2293
2346
|
}
|
|
2294
2347
|
static new(
|
|
2295
|
-
inner: {kind: EndpointErrorKind; peerId?: string; connId?: bigint; detail: string }): EndpointError_ {
|
|
2348
|
+
inner: {kind: EndpointErrorKind; peerId?: string; connId?: bigint; streamId?: bigint; detail: string }): EndpointError_ {
|
|
2296
2349
|
return new EndpointError_(inner);
|
|
2297
2350
|
}
|
|
2298
2351
|
|
|
@@ -2472,6 +2525,40 @@ inner: {connectId: bigint; peerId: string; path: PathKind }): PathEstablished_ {
|
|
|
2472
2525
|
|
|
2473
2526
|
}
|
|
2474
2527
|
|
|
2528
|
+
type InboundPathEstablished__interface = {
|
|
2529
|
+
tag: P2pEvent_Tags.InboundPathEstablished;
|
|
2530
|
+
inner:
|
|
2531
|
+
Readonly<{peerId: string; path: PathKind}>
|
|
2532
|
+
};
|
|
2533
|
+
/**
|
|
2534
|
+
* An inbound relay circuit became a usable path.
|
|
2535
|
+
*/
|
|
2536
|
+
class InboundPathEstablished_ extends UniffiEnum implements InboundPathEstablished__interface {
|
|
2537
|
+
/**
|
|
2538
|
+
* @private
|
|
2539
|
+
* This field is private and should not be used, use `tag` instead.
|
|
2540
|
+
*/
|
|
2541
|
+
readonly [uniffiTypeNameSymbol] = "P2pEvent";
|
|
2542
|
+
readonly tag = P2pEvent_Tags.InboundPathEstablished;
|
|
2543
|
+
readonly inner:
|
|
2544
|
+
Readonly<{peerId: string; path: PathKind}>;
|
|
2545
|
+
constructor(
|
|
2546
|
+
inner: {peerId: string; path: PathKind }) {
|
|
2547
|
+
super("P2pEvent", "InboundPathEstablished");
|
|
2548
|
+
|
|
2549
|
+
this.inner = Object.freeze(inner);
|
|
2550
|
+
}
|
|
2551
|
+
static new(
|
|
2552
|
+
inner: {peerId: string; path: PathKind }): InboundPathEstablished_ {
|
|
2553
|
+
return new InboundPathEstablished_(inner);
|
|
2554
|
+
}
|
|
2555
|
+
|
|
2556
|
+
static instanceOf(obj: any): obj is InboundPathEstablished_ {
|
|
2557
|
+
return obj.tag === P2pEvent_Tags.InboundPathEstablished;
|
|
2558
|
+
}
|
|
2559
|
+
|
|
2560
|
+
}
|
|
2561
|
+
|
|
2475
2562
|
type PathUpgraded__interface = {
|
|
2476
2563
|
tag: P2pEvent_Tags.PathUpgraded;
|
|
2477
2564
|
inner:
|
|
@@ -3010,6 +3097,7 @@ inner: {peerId?: string; source: DiscoverySource; reason: string; suppressed: nu
|
|
|
3010
3097
|
RelayReserved: RelayReserved_,
|
|
3011
3098
|
RelayReservationLost: RelayReservationLost_,
|
|
3012
3099
|
PathEstablished: PathEstablished_,
|
|
3100
|
+
InboundPathEstablished: InboundPathEstablished_,
|
|
3013
3101
|
PathUpgraded: PathUpgraded_,
|
|
3014
3102
|
HolePunchFailed: HolePunchFailed_,
|
|
3015
3103
|
FellBackToRelay: FellBackToRelay_,
|
|
@@ -3032,7 +3120,7 @@ inner: {peerId?: string; source: DiscoverySource; reason: string; suppressed: nu
|
|
|
3032
3120
|
* Event delivered by the native endpoint driver.
|
|
3033
3121
|
*/
|
|
3034
3122
|
export type P2pEvent = InstanceType<
|
|
3035
|
-
typeof P2pEvent['EventsDropped' | 'DriverFailed' | 'ConnectionEstablished' | 'ConnectionClosed' | 'PeerReady' | 'IdentifyReceived' | 'PingRttMeasured' | 'PingTimeout' | 'StreamReady' | 'StreamData' | 'StreamRemoteWriteClosed' | 'StreamClosed' | 'EndpointError' | 'ReachabilityChanged' | 'PublicAddressesChanged' | 'RelayReserved' | 'RelayReservationLost' | 'PathEstablished' | 'PathUpgraded' | 'HolePunchFailed' | 'FellBackToRelay' | 'ConnectFailed' | 'InboundDirectUpgrade' | 'Message' | 'PeerSubscribed' | 'PeerUnsubscribed' | 'PubsubOutboundFailure' | 'PubsubProtocolViolation' | 'PeerDiscovered' | 'PeerUpdated' | 'PeerExpired' | 'DiscoveryDialFailed' | 'DiscoveryProtocolViolation']
|
|
3123
|
+
typeof P2pEvent['EventsDropped' | 'DriverFailed' | 'ConnectionEstablished' | 'ConnectionClosed' | 'PeerReady' | 'IdentifyReceived' | 'PingRttMeasured' | 'PingTimeout' | 'StreamReady' | 'StreamData' | 'StreamRemoteWriteClosed' | 'StreamClosed' | 'EndpointError' | 'ReachabilityChanged' | 'PublicAddressesChanged' | 'RelayReserved' | 'RelayReservationLost' | 'PathEstablished' | 'InboundPathEstablished' | 'PathUpgraded' | 'HolePunchFailed' | 'FellBackToRelay' | 'ConnectFailed' | 'InboundDirectUpgrade' | 'Message' | 'PeerSubscribed' | 'PeerUnsubscribed' | 'PubsubOutboundFailure' | 'PubsubProtocolViolation' | 'PeerDiscovered' | 'PeerUpdated' | 'PeerExpired' | 'DiscoveryDialFailed' | 'DiscoveryProtocolViolation']
|
|
3036
3124
|
>;
|
|
3037
3125
|
|
|
3038
3126
|
// FfiConverter for enum P2pEvent
|
|
@@ -3054,27 +3142,28 @@ const FfiConverterTypeP2pEvent = (() => {
|
|
|
3054
3142
|
case 10: return new P2pEvent.StreamData({peerId: FfiConverterString.read(from), connId: FfiConverterUInt64.read(from), streamId: FfiConverterUInt64.read(from), data: FfiConverterArrayBuffer.read(from) });
|
|
3055
3143
|
case 11: return new P2pEvent.StreamRemoteWriteClosed({peerId: FfiConverterString.read(from), connId: FfiConverterUInt64.read(from), streamId: FfiConverterUInt64.read(from) });
|
|
3056
3144
|
case 12: return new P2pEvent.StreamClosed({peerId: FfiConverterString.read(from), connId: FfiConverterUInt64.read(from), streamId: FfiConverterUInt64.read(from) });
|
|
3057
|
-
case 13: return new P2pEvent.EndpointError({kind: FfiConverterTypeEndpointErrorKind.read(from), peerId: FfiConverterOptionalString.read(from), connId: FfiConverterOptionalUInt64.read(from), detail: FfiConverterString.read(from) });
|
|
3145
|
+
case 13: return new P2pEvent.EndpointError({kind: FfiConverterTypeEndpointErrorKind.read(from), peerId: FfiConverterOptionalString.read(from), connId: FfiConverterOptionalUInt64.read(from), streamId: FfiConverterOptionalUInt64.read(from), detail: FfiConverterString.read(from) });
|
|
3058
3146
|
case 14: return new P2pEvent.ReachabilityChanged({previous: FfiConverterTypeReachability.read(from), current: FfiConverterTypeReachability.read(from), confirmedAddrs: FfiConverterSequenceString.read(from) });
|
|
3059
3147
|
case 15: return new P2pEvent.PublicAddressesChanged({addrs: FfiConverterSequenceString.read(from) });
|
|
3060
3148
|
case 16: return new P2pEvent.RelayReserved({relayPeerId: FfiConverterString.read(from), expiresUnixSecs: FfiConverterOptionalUInt64.read(from) });
|
|
3061
3149
|
case 17: return new P2pEvent.RelayReservationLost({relayPeerId: FfiConverterString.read(from) });
|
|
3062
3150
|
case 18: return new P2pEvent.PathEstablished({connectId: FfiConverterUInt64.read(from), peerId: FfiConverterString.read(from), path: FfiConverterTypePathKind.read(from) });
|
|
3063
|
-
case 19: return new P2pEvent.
|
|
3064
|
-
case 20: return new P2pEvent.
|
|
3065
|
-
case 21: return new P2pEvent.
|
|
3066
|
-
case 22: return new P2pEvent.
|
|
3067
|
-
case 23: return new P2pEvent.
|
|
3068
|
-
case 24: return new P2pEvent.
|
|
3069
|
-
case 25: return new P2pEvent.
|
|
3070
|
-
case 26: return new P2pEvent.
|
|
3071
|
-
case 27: return new P2pEvent.
|
|
3072
|
-
case 28: return new P2pEvent.
|
|
3073
|
-
case 29: return new P2pEvent.
|
|
3074
|
-
case 30: return new P2pEvent.
|
|
3075
|
-
case 31: return new P2pEvent.
|
|
3076
|
-
case 32: return new P2pEvent.
|
|
3077
|
-
case 33: return new P2pEvent.
|
|
3151
|
+
case 19: return new P2pEvent.InboundPathEstablished({peerId: FfiConverterString.read(from), path: FfiConverterTypePathKind.read(from) });
|
|
3152
|
+
case 20: return new P2pEvent.PathUpgraded({connectId: FfiConverterUInt64.read(from), peerId: FfiConverterString.read(from), from: FfiConverterTypePathKind.read(from), to: FfiConverterTypePathKind.read(from) });
|
|
3153
|
+
case 21: return new P2pEvent.HolePunchFailed({connectId: FfiConverterUInt64.read(from), attempt: FfiConverterUInt32.read(from), reason: FfiConverterString.read(from) });
|
|
3154
|
+
case 22: return new P2pEvent.FellBackToRelay({connectId: FfiConverterUInt64.read(from), peerId: FfiConverterString.read(from) });
|
|
3155
|
+
case 23: return new P2pEvent.ConnectFailed({connectId: FfiConverterUInt64.read(from), peerId: FfiConverterString.read(from), kind: FfiConverterTypeNatErrorKind.read(from), detail: FfiConverterString.read(from) });
|
|
3156
|
+
case 24: return new P2pEvent.InboundDirectUpgrade({peerId: FfiConverterString.read(from) });
|
|
3157
|
+
case 25: return new P2pEvent.Message({fromPeerId: FfiConverterString.read(from), topics: FfiConverterSequenceString.read(from), data: FfiConverterArrayBuffer.read(from), seqno: FfiConverterArrayBuffer.read(from), signed: FfiConverterBool.read(from) });
|
|
3158
|
+
case 26: return new P2pEvent.PeerSubscribed({peerId: FfiConverterString.read(from), topic: FfiConverterString.read(from) });
|
|
3159
|
+
case 27: return new P2pEvent.PeerUnsubscribed({peerId: FfiConverterString.read(from), topic: FfiConverterString.read(from) });
|
|
3160
|
+
case 28: return new P2pEvent.PubsubOutboundFailure({peerId: FfiConverterString.read(from), reason: FfiConverterString.read(from) });
|
|
3161
|
+
case 29: return new P2pEvent.PubsubProtocolViolation({peerId: FfiConverterString.read(from), reason: FfiConverterString.read(from) });
|
|
3162
|
+
case 30: return new P2pEvent.PeerDiscovered({peerId: FfiConverterString.read(from), addrs: FfiConverterSequenceString.read(from), source: FfiConverterTypeDiscoverySource.read(from) });
|
|
3163
|
+
case 31: return new P2pEvent.PeerUpdated({peerId: FfiConverterString.read(from), addrs: FfiConverterSequenceString.read(from), source: FfiConverterTypeDiscoverySource.read(from) });
|
|
3164
|
+
case 32: return new P2pEvent.PeerExpired({peerId: FfiConverterString.read(from) });
|
|
3165
|
+
case 33: return new P2pEvent.DiscoveryDialFailed({peerId: FfiConverterString.read(from), reason: FfiConverterString.read(from) });
|
|
3166
|
+
case 34: return new P2pEvent.DiscoveryProtocolViolation({peerId: FfiConverterOptionalString.read(from), source: FfiConverterTypeDiscoverySource.read(from), reason: FfiConverterString.read(from), suppressed: FfiConverterUInt32.read(from) });
|
|
3078
3167
|
default: throw new UniffiInternalError.UnexpectedEnumCase();
|
|
3079
3168
|
}
|
|
3080
3169
|
}
|
|
@@ -3176,6 +3265,7 @@ const FfiConverterTypeP2pEvent = (() => {
|
|
|
3176
3265
|
FfiConverterTypeEndpointErrorKind.write(inner.kind, into);
|
|
3177
3266
|
FfiConverterOptionalString.write(inner.peerId, into);
|
|
3178
3267
|
FfiConverterOptionalUInt64.write(inner.connId, into);
|
|
3268
|
+
FfiConverterOptionalUInt64.write(inner.streamId, into);
|
|
3179
3269
|
FfiConverterString.write(inner.detail, into);
|
|
3180
3270
|
return;
|
|
3181
3271
|
}
|
|
@@ -3214,9 +3304,16 @@ const FfiConverterTypeP2pEvent = (() => {
|
|
|
3214
3304
|
FfiConverterTypePathKind.write(inner.path, into);
|
|
3215
3305
|
return;
|
|
3216
3306
|
}
|
|
3217
|
-
case P2pEvent_Tags.
|
|
3307
|
+
case P2pEvent_Tags.InboundPathEstablished: {
|
|
3218
3308
|
ordinalConverter.write(19, into);
|
|
3219
3309
|
const inner = value.inner;
|
|
3310
|
+
FfiConverterString.write(inner.peerId, into);
|
|
3311
|
+
FfiConverterTypePathKind.write(inner.path, into);
|
|
3312
|
+
return;
|
|
3313
|
+
}
|
|
3314
|
+
case P2pEvent_Tags.PathUpgraded: {
|
|
3315
|
+
ordinalConverter.write(20, into);
|
|
3316
|
+
const inner = value.inner;
|
|
3220
3317
|
FfiConverterUInt64.write(inner.connectId, into);
|
|
3221
3318
|
FfiConverterString.write(inner.peerId, into);
|
|
3222
3319
|
FfiConverterTypePathKind.write(inner.from, into);
|
|
@@ -3224,7 +3321,7 @@ const FfiConverterTypeP2pEvent = (() => {
|
|
|
3224
3321
|
return;
|
|
3225
3322
|
}
|
|
3226
3323
|
case P2pEvent_Tags.HolePunchFailed: {
|
|
3227
|
-
ordinalConverter.write(
|
|
3324
|
+
ordinalConverter.write(21, into);
|
|
3228
3325
|
const inner = value.inner;
|
|
3229
3326
|
FfiConverterUInt64.write(inner.connectId, into);
|
|
3230
3327
|
FfiConverterUInt32.write(inner.attempt, into);
|
|
@@ -3232,14 +3329,14 @@ const FfiConverterTypeP2pEvent = (() => {
|
|
|
3232
3329
|
return;
|
|
3233
3330
|
}
|
|
3234
3331
|
case P2pEvent_Tags.FellBackToRelay: {
|
|
3235
|
-
ordinalConverter.write(
|
|
3332
|
+
ordinalConverter.write(22, into);
|
|
3236
3333
|
const inner = value.inner;
|
|
3237
3334
|
FfiConverterUInt64.write(inner.connectId, into);
|
|
3238
3335
|
FfiConverterString.write(inner.peerId, into);
|
|
3239
3336
|
return;
|
|
3240
3337
|
}
|
|
3241
3338
|
case P2pEvent_Tags.ConnectFailed: {
|
|
3242
|
-
ordinalConverter.write(
|
|
3339
|
+
ordinalConverter.write(23, into);
|
|
3243
3340
|
const inner = value.inner;
|
|
3244
3341
|
FfiConverterUInt64.write(inner.connectId, into);
|
|
3245
3342
|
FfiConverterString.write(inner.peerId, into);
|
|
@@ -3248,13 +3345,13 @@ const FfiConverterTypeP2pEvent = (() => {
|
|
|
3248
3345
|
return;
|
|
3249
3346
|
}
|
|
3250
3347
|
case P2pEvent_Tags.InboundDirectUpgrade: {
|
|
3251
|
-
ordinalConverter.write(
|
|
3348
|
+
ordinalConverter.write(24, into);
|
|
3252
3349
|
const inner = value.inner;
|
|
3253
3350
|
FfiConverterString.write(inner.peerId, into);
|
|
3254
3351
|
return;
|
|
3255
3352
|
}
|
|
3256
3353
|
case P2pEvent_Tags.Message: {
|
|
3257
|
-
ordinalConverter.write(
|
|
3354
|
+
ordinalConverter.write(25, into);
|
|
3258
3355
|
const inner = value.inner;
|
|
3259
3356
|
FfiConverterString.write(inner.fromPeerId, into);
|
|
3260
3357
|
FfiConverterSequenceString.write(inner.topics, into);
|
|
@@ -3264,35 +3361,35 @@ const FfiConverterTypeP2pEvent = (() => {
|
|
|
3264
3361
|
return;
|
|
3265
3362
|
}
|
|
3266
3363
|
case P2pEvent_Tags.PeerSubscribed: {
|
|
3267
|
-
ordinalConverter.write(
|
|
3364
|
+
ordinalConverter.write(26, into);
|
|
3268
3365
|
const inner = value.inner;
|
|
3269
3366
|
FfiConverterString.write(inner.peerId, into);
|
|
3270
3367
|
FfiConverterString.write(inner.topic, into);
|
|
3271
3368
|
return;
|
|
3272
3369
|
}
|
|
3273
3370
|
case P2pEvent_Tags.PeerUnsubscribed: {
|
|
3274
|
-
ordinalConverter.write(
|
|
3371
|
+
ordinalConverter.write(27, into);
|
|
3275
3372
|
const inner = value.inner;
|
|
3276
3373
|
FfiConverterString.write(inner.peerId, into);
|
|
3277
3374
|
FfiConverterString.write(inner.topic, into);
|
|
3278
3375
|
return;
|
|
3279
3376
|
}
|
|
3280
3377
|
case P2pEvent_Tags.PubsubOutboundFailure: {
|
|
3281
|
-
ordinalConverter.write(
|
|
3378
|
+
ordinalConverter.write(28, into);
|
|
3282
3379
|
const inner = value.inner;
|
|
3283
3380
|
FfiConverterString.write(inner.peerId, into);
|
|
3284
3381
|
FfiConverterString.write(inner.reason, into);
|
|
3285
3382
|
return;
|
|
3286
3383
|
}
|
|
3287
3384
|
case P2pEvent_Tags.PubsubProtocolViolation: {
|
|
3288
|
-
ordinalConverter.write(
|
|
3385
|
+
ordinalConverter.write(29, into);
|
|
3289
3386
|
const inner = value.inner;
|
|
3290
3387
|
FfiConverterString.write(inner.peerId, into);
|
|
3291
3388
|
FfiConverterString.write(inner.reason, into);
|
|
3292
3389
|
return;
|
|
3293
3390
|
}
|
|
3294
3391
|
case P2pEvent_Tags.PeerDiscovered: {
|
|
3295
|
-
ordinalConverter.write(
|
|
3392
|
+
ordinalConverter.write(30, into);
|
|
3296
3393
|
const inner = value.inner;
|
|
3297
3394
|
FfiConverterString.write(inner.peerId, into);
|
|
3298
3395
|
FfiConverterSequenceString.write(inner.addrs, into);
|
|
@@ -3300,7 +3397,7 @@ const FfiConverterTypeP2pEvent = (() => {
|
|
|
3300
3397
|
return;
|
|
3301
3398
|
}
|
|
3302
3399
|
case P2pEvent_Tags.PeerUpdated: {
|
|
3303
|
-
ordinalConverter.write(
|
|
3400
|
+
ordinalConverter.write(31, into);
|
|
3304
3401
|
const inner = value.inner;
|
|
3305
3402
|
FfiConverterString.write(inner.peerId, into);
|
|
3306
3403
|
FfiConverterSequenceString.write(inner.addrs, into);
|
|
@@ -3308,20 +3405,20 @@ const FfiConverterTypeP2pEvent = (() => {
|
|
|
3308
3405
|
return;
|
|
3309
3406
|
}
|
|
3310
3407
|
case P2pEvent_Tags.PeerExpired: {
|
|
3311
|
-
ordinalConverter.write(
|
|
3408
|
+
ordinalConverter.write(32, into);
|
|
3312
3409
|
const inner = value.inner;
|
|
3313
3410
|
FfiConverterString.write(inner.peerId, into);
|
|
3314
3411
|
return;
|
|
3315
3412
|
}
|
|
3316
3413
|
case P2pEvent_Tags.DiscoveryDialFailed: {
|
|
3317
|
-
ordinalConverter.write(
|
|
3414
|
+
ordinalConverter.write(33, into);
|
|
3318
3415
|
const inner = value.inner;
|
|
3319
3416
|
FfiConverterString.write(inner.peerId, into);
|
|
3320
3417
|
FfiConverterString.write(inner.reason, into);
|
|
3321
3418
|
return;
|
|
3322
3419
|
}
|
|
3323
3420
|
case P2pEvent_Tags.DiscoveryProtocolViolation: {
|
|
3324
|
-
ordinalConverter.write(
|
|
3421
|
+
ordinalConverter.write(34, into);
|
|
3325
3422
|
const inner = value.inner;
|
|
3326
3423
|
FfiConverterOptionalString.write(inner.peerId, into);
|
|
3327
3424
|
FfiConverterTypeDiscoverySource.write(inner.source, into);
|
|
@@ -3432,6 +3529,7 @@ const FfiConverterTypeP2pEvent = (() => {
|
|
|
3432
3529
|
size += FfiConverterTypeEndpointErrorKind.allocationSize(inner.kind);
|
|
3433
3530
|
size += FfiConverterOptionalString.allocationSize(inner.peerId);
|
|
3434
3531
|
size += FfiConverterOptionalUInt64.allocationSize(inner.connId);
|
|
3532
|
+
size += FfiConverterOptionalUInt64.allocationSize(inner.streamId);
|
|
3435
3533
|
size += FfiConverterString.allocationSize(inner.detail);
|
|
3436
3534
|
return size;
|
|
3437
3535
|
}
|
|
@@ -3470,9 +3568,16 @@ const FfiConverterTypeP2pEvent = (() => {
|
|
|
3470
3568
|
size += FfiConverterTypePathKind.allocationSize(inner.path);
|
|
3471
3569
|
return size;
|
|
3472
3570
|
}
|
|
3473
|
-
case P2pEvent_Tags.
|
|
3571
|
+
case P2pEvent_Tags.InboundPathEstablished: {
|
|
3474
3572
|
const inner = value.inner;
|
|
3475
3573
|
let size = ordinalConverter.allocationSize(19);
|
|
3574
|
+
size += FfiConverterString.allocationSize(inner.peerId);
|
|
3575
|
+
size += FfiConverterTypePathKind.allocationSize(inner.path);
|
|
3576
|
+
return size;
|
|
3577
|
+
}
|
|
3578
|
+
case P2pEvent_Tags.PathUpgraded: {
|
|
3579
|
+
const inner = value.inner;
|
|
3580
|
+
let size = ordinalConverter.allocationSize(20);
|
|
3476
3581
|
size += FfiConverterUInt64.allocationSize(inner.connectId);
|
|
3477
3582
|
size += FfiConverterString.allocationSize(inner.peerId);
|
|
3478
3583
|
size += FfiConverterTypePathKind.allocationSize(inner.from);
|
|
@@ -3481,7 +3586,7 @@ const FfiConverterTypeP2pEvent = (() => {
|
|
|
3481
3586
|
}
|
|
3482
3587
|
case P2pEvent_Tags.HolePunchFailed: {
|
|
3483
3588
|
const inner = value.inner;
|
|
3484
|
-
let size = ordinalConverter.allocationSize(
|
|
3589
|
+
let size = ordinalConverter.allocationSize(21);
|
|
3485
3590
|
size += FfiConverterUInt64.allocationSize(inner.connectId);
|
|
3486
3591
|
size += FfiConverterUInt32.allocationSize(inner.attempt);
|
|
3487
3592
|
size += FfiConverterString.allocationSize(inner.reason);
|
|
@@ -3489,14 +3594,14 @@ const FfiConverterTypeP2pEvent = (() => {
|
|
|
3489
3594
|
}
|
|
3490
3595
|
case P2pEvent_Tags.FellBackToRelay: {
|
|
3491
3596
|
const inner = value.inner;
|
|
3492
|
-
let size = ordinalConverter.allocationSize(
|
|
3597
|
+
let size = ordinalConverter.allocationSize(22);
|
|
3493
3598
|
size += FfiConverterUInt64.allocationSize(inner.connectId);
|
|
3494
3599
|
size += FfiConverterString.allocationSize(inner.peerId);
|
|
3495
3600
|
return size;
|
|
3496
3601
|
}
|
|
3497
3602
|
case P2pEvent_Tags.ConnectFailed: {
|
|
3498
3603
|
const inner = value.inner;
|
|
3499
|
-
let size = ordinalConverter.allocationSize(
|
|
3604
|
+
let size = ordinalConverter.allocationSize(23);
|
|
3500
3605
|
size += FfiConverterUInt64.allocationSize(inner.connectId);
|
|
3501
3606
|
size += FfiConverterString.allocationSize(inner.peerId);
|
|
3502
3607
|
size += FfiConverterTypeNatErrorKind.allocationSize(inner.kind);
|
|
@@ -3505,13 +3610,13 @@ const FfiConverterTypeP2pEvent = (() => {
|
|
|
3505
3610
|
}
|
|
3506
3611
|
case P2pEvent_Tags.InboundDirectUpgrade: {
|
|
3507
3612
|
const inner = value.inner;
|
|
3508
|
-
let size = ordinalConverter.allocationSize(
|
|
3613
|
+
let size = ordinalConverter.allocationSize(24);
|
|
3509
3614
|
size += FfiConverterString.allocationSize(inner.peerId);
|
|
3510
3615
|
return size;
|
|
3511
3616
|
}
|
|
3512
3617
|
case P2pEvent_Tags.Message: {
|
|
3513
3618
|
const inner = value.inner;
|
|
3514
|
-
let size = ordinalConverter.allocationSize(
|
|
3619
|
+
let size = ordinalConverter.allocationSize(25);
|
|
3515
3620
|
size += FfiConverterString.allocationSize(inner.fromPeerId);
|
|
3516
3621
|
size += FfiConverterSequenceString.allocationSize(inner.topics);
|
|
3517
3622
|
size += FfiConverterArrayBuffer.allocationSize(inner.data);
|
|
@@ -3521,35 +3626,35 @@ const FfiConverterTypeP2pEvent = (() => {
|
|
|
3521
3626
|
}
|
|
3522
3627
|
case P2pEvent_Tags.PeerSubscribed: {
|
|
3523
3628
|
const inner = value.inner;
|
|
3524
|
-
let size = ordinalConverter.allocationSize(
|
|
3629
|
+
let size = ordinalConverter.allocationSize(26);
|
|
3525
3630
|
size += FfiConverterString.allocationSize(inner.peerId);
|
|
3526
3631
|
size += FfiConverterString.allocationSize(inner.topic);
|
|
3527
3632
|
return size;
|
|
3528
3633
|
}
|
|
3529
3634
|
case P2pEvent_Tags.PeerUnsubscribed: {
|
|
3530
3635
|
const inner = value.inner;
|
|
3531
|
-
let size = ordinalConverter.allocationSize(
|
|
3636
|
+
let size = ordinalConverter.allocationSize(27);
|
|
3532
3637
|
size += FfiConverterString.allocationSize(inner.peerId);
|
|
3533
3638
|
size += FfiConverterString.allocationSize(inner.topic);
|
|
3534
3639
|
return size;
|
|
3535
3640
|
}
|
|
3536
3641
|
case P2pEvent_Tags.PubsubOutboundFailure: {
|
|
3537
3642
|
const inner = value.inner;
|
|
3538
|
-
let size = ordinalConverter.allocationSize(
|
|
3643
|
+
let size = ordinalConverter.allocationSize(28);
|
|
3539
3644
|
size += FfiConverterString.allocationSize(inner.peerId);
|
|
3540
3645
|
size += FfiConverterString.allocationSize(inner.reason);
|
|
3541
3646
|
return size;
|
|
3542
3647
|
}
|
|
3543
3648
|
case P2pEvent_Tags.PubsubProtocolViolation: {
|
|
3544
3649
|
const inner = value.inner;
|
|
3545
|
-
let size = ordinalConverter.allocationSize(
|
|
3650
|
+
let size = ordinalConverter.allocationSize(29);
|
|
3546
3651
|
size += FfiConverterString.allocationSize(inner.peerId);
|
|
3547
3652
|
size += FfiConverterString.allocationSize(inner.reason);
|
|
3548
3653
|
return size;
|
|
3549
3654
|
}
|
|
3550
3655
|
case P2pEvent_Tags.PeerDiscovered: {
|
|
3551
3656
|
const inner = value.inner;
|
|
3552
|
-
let size = ordinalConverter.allocationSize(
|
|
3657
|
+
let size = ordinalConverter.allocationSize(30);
|
|
3553
3658
|
size += FfiConverterString.allocationSize(inner.peerId);
|
|
3554
3659
|
size += FfiConverterSequenceString.allocationSize(inner.addrs);
|
|
3555
3660
|
size += FfiConverterTypeDiscoverySource.allocationSize(inner.source);
|
|
@@ -3557,7 +3662,7 @@ const FfiConverterTypeP2pEvent = (() => {
|
|
|
3557
3662
|
}
|
|
3558
3663
|
case P2pEvent_Tags.PeerUpdated: {
|
|
3559
3664
|
const inner = value.inner;
|
|
3560
|
-
let size = ordinalConverter.allocationSize(
|
|
3665
|
+
let size = ordinalConverter.allocationSize(31);
|
|
3561
3666
|
size += FfiConverterString.allocationSize(inner.peerId);
|
|
3562
3667
|
size += FfiConverterSequenceString.allocationSize(inner.addrs);
|
|
3563
3668
|
size += FfiConverterTypeDiscoverySource.allocationSize(inner.source);
|
|
@@ -3565,20 +3670,20 @@ const FfiConverterTypeP2pEvent = (() => {
|
|
|
3565
3670
|
}
|
|
3566
3671
|
case P2pEvent_Tags.PeerExpired: {
|
|
3567
3672
|
const inner = value.inner;
|
|
3568
|
-
let size = ordinalConverter.allocationSize(
|
|
3673
|
+
let size = ordinalConverter.allocationSize(32);
|
|
3569
3674
|
size += FfiConverterString.allocationSize(inner.peerId);
|
|
3570
3675
|
return size;
|
|
3571
3676
|
}
|
|
3572
3677
|
case P2pEvent_Tags.DiscoveryDialFailed: {
|
|
3573
3678
|
const inner = value.inner;
|
|
3574
|
-
let size = ordinalConverter.allocationSize(
|
|
3679
|
+
let size = ordinalConverter.allocationSize(33);
|
|
3575
3680
|
size += FfiConverterString.allocationSize(inner.peerId);
|
|
3576
3681
|
size += FfiConverterString.allocationSize(inner.reason);
|
|
3577
3682
|
return size;
|
|
3578
3683
|
}
|
|
3579
3684
|
case P2pEvent_Tags.DiscoveryProtocolViolation: {
|
|
3580
3685
|
const inner = value.inner;
|
|
3581
|
-
let size = ordinalConverter.allocationSize(
|
|
3686
|
+
let size = ordinalConverter.allocationSize(34);
|
|
3582
3687
|
size += FfiConverterOptionalString.allocationSize(inner.peerId);
|
|
3583
3688
|
size += FfiConverterTypeDiscoverySource.allocationSize(inner.source);
|
|
3584
3689
|
size += FfiConverterString.allocationSize(inner.reason);
|
|
@@ -3842,7 +3947,11 @@ export interface P2pEndpointLike {
|
|
|
3842
3947
|
/**
|
|
3843
3948
|
* Opens a negotiated application stream and returns its opaque id.
|
|
3844
3949
|
*/
|
|
3845
|
-
openStream(peerId: string, protocolId: string) /*throws*/:
|
|
3950
|
+
openStream(peerId: string, protocolId: string) /*throws*/: OpenStreamResult;
|
|
3951
|
+
/**
|
|
3952
|
+
* Returns the current usable NAT-orchestrated path to `peer_id`.
|
|
3953
|
+
*/
|
|
3954
|
+
path(peerId: string) /*throws*/: PathKind | undefined;
|
|
3846
3955
|
/**
|
|
3847
3956
|
* Returns the local peer ID as legacy base58 text.
|
|
3848
3957
|
*/
|
|
@@ -4266,8 +4375,14 @@ export class P2pEndpoint extends UniffiAbstractObject implements P2pEndpointLike
|
|
|
4266
4375
|
/**
|
|
4267
4376
|
* Opens a negotiated application stream and returns its opaque id.
|
|
4268
4377
|
*/
|
|
4269
|
-
openStream(peerId: string, protocolId: string):
|
|
4270
|
-
return
|
|
4378
|
+
openStream(peerId: string, protocolId: string): OpenStreamResult /*throws*/ {
|
|
4379
|
+
return ((__rb: Uint8Array) => {
|
|
4380
|
+
try {
|
|
4381
|
+
return FfiConverterTypeOpenStreamResult.lift(__rb);
|
|
4382
|
+
} finally {
|
|
4383
|
+
nativeModule().rustbuffer_free(__rb);
|
|
4384
|
+
}
|
|
4385
|
+
})(uniffiCaller.rustCallWithError(
|
|
4271
4386
|
/*liftError:*/ FfiConverterTypeFfiError.lift.bind(FfiConverterTypeFfiError),
|
|
4272
4387
|
/*caller:*/ (callStatus) => {
|
|
4273
4388
|
return nativeModule().ubrn_uniffi_minip2p_ffi_fn_method_p2pendpoint_open_stream(
|
|
@@ -4280,6 +4395,28 @@ export class P2pEndpoint extends UniffiAbstractObject implements P2pEndpointLike
|
|
|
4280
4395
|
));
|
|
4281
4396
|
}
|
|
4282
4397
|
|
|
4398
|
+
/**
|
|
4399
|
+
* Returns the current usable NAT-orchestrated path to `peer_id`.
|
|
4400
|
+
*/
|
|
4401
|
+
path(peerId: string): PathKind | undefined /*throws*/ {
|
|
4402
|
+
return ((__rb: Uint8Array) => {
|
|
4403
|
+
try {
|
|
4404
|
+
return FfiConverterOptionalTypePathKind.lift(__rb);
|
|
4405
|
+
} finally {
|
|
4406
|
+
nativeModule().rustbuffer_free(__rb);
|
|
4407
|
+
}
|
|
4408
|
+
})(uniffiCaller.rustCallWithError(
|
|
4409
|
+
/*liftError:*/ FfiConverterTypeFfiError.lift.bind(FfiConverterTypeFfiError),
|
|
4410
|
+
/*caller:*/ (callStatus) => {
|
|
4411
|
+
return nativeModule().ubrn_uniffi_minip2p_ffi_fn_method_p2pendpoint_path(
|
|
4412
|
+
uniffiTypeP2pEndpointObjectFactory.clonePointer(this),
|
|
4413
|
+
FfiConverterString.lower(peerId, nativeModule().rustbuffer_alloc),
|
|
4414
|
+
callStatus);
|
|
4415
|
+
},
|
|
4416
|
+
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
|
|
4417
|
+
));
|
|
4418
|
+
}
|
|
4419
|
+
|
|
4283
4420
|
/**
|
|
4284
4421
|
* Returns the local peer ID as legacy base58 text.
|
|
4285
4422
|
*/
|
|
@@ -4593,6 +4730,9 @@ const FfiConverterSequenceUInt64 = new FfiConverterArray(FfiConverterUInt64);
|
|
|
4593
4730
|
// FfiConverter for Array<KnownPeerInfo>
|
|
4594
4731
|
const FfiConverterSequenceTypeKnownPeerInfo = new FfiConverterArray(FfiConverterTypeKnownPeerInfo);
|
|
4595
4732
|
|
|
4733
|
+
// FfiConverter for PathKind | undefined
|
|
4734
|
+
const FfiConverterOptionalTypePathKind = new FfiConverterOptional(FfiConverterTypePathKind);
|
|
4735
|
+
|
|
4596
4736
|
// FfiConverter for IdentifyInfo | undefined
|
|
4597
4737
|
const FfiConverterOptionalTypeIdentifyInfo = new FfiConverterOptional(FfiConverterTypeIdentifyInfo);
|
|
4598
4738
|
|
|
@@ -4681,9 +4821,12 @@ function uniffiEnsureInitialized() {
|
|
|
4681
4821
|
if (nativeModule().ubrn_uniffi_minip2p_ffi_checksum_method_p2pendpoint_listen_addrs() !== 19812) {
|
|
4682
4822
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_minip2p_ffi_checksum_method_p2pendpoint_listen_addrs");
|
|
4683
4823
|
}
|
|
4684
|
-
if (nativeModule().ubrn_uniffi_minip2p_ffi_checksum_method_p2pendpoint_open_stream() !==
|
|
4824
|
+
if (nativeModule().ubrn_uniffi_minip2p_ffi_checksum_method_p2pendpoint_open_stream() !== 18245) {
|
|
4685
4825
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_minip2p_ffi_checksum_method_p2pendpoint_open_stream");
|
|
4686
4826
|
}
|
|
4827
|
+
if (nativeModule().ubrn_uniffi_minip2p_ffi_checksum_method_p2pendpoint_path() !== 58210) {
|
|
4828
|
+
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_minip2p_ffi_checksum_method_p2pendpoint_path");
|
|
4829
|
+
}
|
|
4687
4830
|
if (nativeModule().ubrn_uniffi_minip2p_ffi_checksum_method_p2pendpoint_peer_id() !== 34289) {
|
|
4688
4831
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_minip2p_ffi_checksum_method_p2pendpoint_peer_id");
|
|
4689
4832
|
}
|
|
@@ -4743,6 +4886,7 @@ export default Object.freeze({
|
|
|
4743
4886
|
FfiConverterTypeKnownPeerInfo,
|
|
4744
4887
|
FfiConverterTypeMdnsOptions,
|
|
4745
4888
|
FfiConverterTypeNatErrorKind,
|
|
4889
|
+
FfiConverterTypeOpenStreamResult,
|
|
4746
4890
|
FfiConverterTypeP2pEndpoint,
|
|
4747
4891
|
FfiConverterTypeP2pEvent,
|
|
4748
4892
|
FfiConverterTypeP2pEventListener,
|