@minip2p/node 0.10.0 → 0.10.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/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +14 -521
- package/dist/adapter.js.map +1 -1
- package/dist/native-shape.d.ts +4 -18
- package/dist/native-shape.d.ts.map +1 -1
- package/dist/native-shape.js +3 -5
- package/dist/native-shape.js.map +1 -1
- package/package.json +9 -9
- package/src/adapter.ts +25 -688
- package/src/native-shape.ts +12 -35
package/src/native-shape.ts
CHANGED
|
@@ -1,41 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Types of the values the native addon returns
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* SDK type with napi-rs's value encoding: `u64` arrives as `number`, or as a
|
|
6
|
-
* `bigint` above `u32::MAX`, and bytes arrive as a `Buffer`.
|
|
2
|
+
* Types of the values the native addon returns: `minip2p-ffi-core`'s serde
|
|
3
|
+
* shape, with napi-rs's value encoding (`u64` as `number`, or `bigint` above
|
|
4
|
+
* `u32::MAX`; bytes as a `Buffer`). The shared serde backend defines them.
|
|
7
5
|
*
|
|
8
6
|
* The generated `addon.d.ts` imports these names through its header.
|
|
9
7
|
*/
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
PathKind,
|
|
21
|
-
} from "@minip2p/core/backend";
|
|
22
|
-
|
|
23
|
-
/** One SDK backend value as the addon encodes it. */
|
|
24
|
-
export type NativeShape<Value> = Value extends ArrayBuffer
|
|
25
|
-
? Uint8Array
|
|
26
|
-
: Value extends number
|
|
27
|
-
? number | bigint
|
|
28
|
-
: Value extends string | boolean
|
|
29
|
-
? Value
|
|
30
|
-
: Value extends readonly (infer Item)[]
|
|
31
|
-
? readonly NativeShape<Item>[]
|
|
32
|
-
: { readonly [Key in keyof Value]: NativeShape<Value[Key]> };
|
|
33
|
-
|
|
34
|
-
export type NativeEvent = NativeShape<P2pEvent>;
|
|
35
|
-
export type NativeIdentifyInfo = NativeShape<IdentifyInfo>;
|
|
36
|
-
export type NativeKnownPeerInfo = NativeShape<KnownPeerInfo>;
|
|
37
|
-
export type NativeRelayReservationInfo = NativeShape<RelayReservationInfo>;
|
|
38
|
-
export type NativeConnectionInfo = NativeShape<BackendConnectionInfo>;
|
|
39
|
-
export type NativeOpenStream = NativeShape<BackendOpenStream>;
|
|
40
|
-
export type NativePathKind = NativeShape<PathKind>;
|
|
9
|
+
export type {
|
|
10
|
+
NativeConnectionInfo,
|
|
11
|
+
NativeEvent,
|
|
12
|
+
NativeIdentifyInfo,
|
|
13
|
+
NativeKnownPeerInfo,
|
|
14
|
+
NativeOpenStream,
|
|
15
|
+
NativePathKind,
|
|
16
|
+
NativeRelayReservationInfo,
|
|
17
|
+
} from "@minip2p/core/serde-backend";
|
|
41
18
|
export type { Reachability } from "@minip2p/core";
|