@minip2p/core 0.8.3 → 0.9.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 +8 -2
- package/dist/backend.d.ts +24 -7
- package/dist/backend.d.ts.map +1 -1
- package/dist/backend.js +15 -5
- package/dist/backend.js.map +1 -1
- package/dist/errors.d.ts +13 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +17 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +147 -7
- package/dist/sdk.js.map +1 -1
- package/dist/settle-handles.d.ts +30 -0
- package/dist/settle-handles.d.ts.map +1 -0
- package/dist/settle-handles.js +69 -0
- package/dist/settle-handles.js.map +1 -0
- package/dist/types.d.ts +51 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +35 -0
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/src/backend.ts +40 -10
- package/src/errors.ts +20 -0
- package/src/index.ts +3 -0
- package/src/sdk.ts +157 -9
- package/src/settle-handles.ts +78 -0
- package/src/types.ts +55 -0
package/README.md
CHANGED
|
@@ -17,7 +17,9 @@ await stream.write(new Uint8Array([1, 2, 3]));
|
|
|
17
17
|
stream.closeWrite();
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
Reading applies backpressure: a chunk counts as consumed when `read()` returns it or every `data` handler has returned from it, and each stream delivers at most one receive window that has not been consumed, so a reader that stops reading stalls its sender instead of losing data. An `async` `data` handler is consumed when it returns its Promise, not when the Promise settles; use `read()` to hold the sender back while asynchronous work runs.
|
|
20
|
+
Reading applies backpressure: a chunk counts as consumed when `read()` returns it or every `data` handler has returned from it, and each stream delivers at most one receive window that has not been consumed, so a reader that stops reading stalls its sender instead of losing data. An `async` `data` handler is consumed when it returns its Promise, not when the Promise settles; use `read()` to hold the sender back while asynchronous work runs. Unconsumed bytes keep holding native resources after their connection ends (ADR 0012): native keeps the ended connection's slot until they are consumed or the stream is abandoned, so the SDK still acknowledges bytes it discards or reads after a close. An endpoint whose application never consumes what it received can have native refuse new connections.
|
|
21
|
+
|
|
22
|
+
The endpoint's event queue keeps stream and connection-end events. A peer-opened stream, or a connection, that ends without carrying data before any of its events was dispatched leaves the queue whole, so peer churn cannot grow it; an unseen connection that is replaced folds into its successor.
|
|
21
23
|
|
|
22
24
|
Streams are async iterables. Iteration preserves chunk order, drains bytes buffered before a remote write half-close, and then ends quietly. Local shutdown, reset, peer disconnect, connection replacement, or driver failure rejects the iterator with its terminal error:
|
|
23
25
|
|
|
@@ -43,4 +45,8 @@ A peer holds one connection at a time. `connectionEstablished` and `connectionCl
|
|
|
43
45
|
|
|
44
46
|
Use `endpoint.on("stream", handler)` to claim inbound streams. Operations accept `{ timeoutMs, signal }`; the default timeout is 65 seconds and `timeoutMs: 0` disables it. Both endpoints and streams implement `Symbol.dispose`, including the fallback used by `await using`; neither implements `Symbol.asyncDispose`.
|
|
45
47
|
|
|
46
|
-
|
|
48
|
+
`create` throws `InvalidConfigError` when native rejects the configuration. Its `capability` (`Gossipsub`, `Mdns`, `Discovery`, `Transport`, or `Options`, from `ConfigCapability`) names the part to change, and `detail` carries the native diagnostic. A malformed listen address and a socket the platform refused are not config errors; they keep their native error codes.
|
|
49
|
+
|
|
50
|
+
With mDNS enabled, `mdnsFailed` (`{ kind, detail }`, `kind` from `MdnsFailureKind`) reports a hard mDNS failure once per change in failure state. mDNS keeps running and retries, and `mdnsRecovered` follows once a retry succeeds; a goodbye that failed during shutdown is final.
|
|
51
|
+
|
|
52
|
+
Raw native unions, the `Minip2pBackend` adapter contract, `resolveEndpointConfig` (shared config defaults and validation), and `typedFfiError` (native `FfiError` variant to typed SDK error) are available from `@minip2p/core/backend`.
|
package/dist/backend.d.ts
CHANGED
|
@@ -26,7 +26,10 @@ export type BackendConnectTarget = {
|
|
|
26
26
|
export interface Minip2pBackend {
|
|
27
27
|
/** Starts native event delivery exactly once. */
|
|
28
28
|
start: (listener: (event: P2pEvent) => void) => void;
|
|
29
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Releases adapter state retained until an event has been dispatched,
|
|
31
|
+
* elided, dropped, or coalesced into an earlier one.
|
|
32
|
+
*/
|
|
30
33
|
eventHandled?: (event: P2pEvent) => void;
|
|
31
34
|
/** Idempotently releases the native endpoint. */
|
|
32
35
|
close: () => void;
|
|
@@ -87,8 +90,10 @@ export interface Minip2pBackend {
|
|
|
87
90
|
*
|
|
88
91
|
* Called once, when the stream becomes ready; the returned function keeps
|
|
89
92
|
* naming that stream after its terminal event retires the public IDs. It
|
|
90
|
-
* throws on an over-acknowledgement and is a no-op once the stream
|
|
91
|
-
* connection
|
|
93
|
+
* throws on an over-acknowledgement and is a no-op once the stream is
|
|
94
|
+
* settled. Unacknowledged bytes hold their ended connection's native slot,
|
|
95
|
+
* so this, and `abandonStream`, must still reach native for a stream whose
|
|
96
|
+
* connection ended while its events were in flight (see `SettleHandles`).
|
|
92
97
|
*/
|
|
93
98
|
streamConsumer: (connId: number, streamId: number) => (bytes: number) => void;
|
|
94
99
|
/** Half-closes the local stream write side, after any pending write. */
|
|
@@ -107,13 +112,25 @@ export interface Minip2pBackend {
|
|
|
107
112
|
export { resolveEndpointConfig, type BackendEndpointConfig } from "./config.js";
|
|
108
113
|
export { EventDrain } from "./event-drain.js";
|
|
109
114
|
export { ConnectionIdMap, u64ToNumber } from "./native-ids.js";
|
|
115
|
+
export { SettleHandles, eventStream } from "./settle-handles.js";
|
|
110
116
|
export { P2pEvent_Tags, PathKind_Tags, type P2pEvent, type P2pEventByTag, type PathKind, } from "./types.js";
|
|
111
117
|
/**
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
118
|
+
* The parts of a native `FfiError` an adapter reads off its toolchain's error
|
|
119
|
+
* value: the variant name, its detail field, and an `InvalidConfig`'s
|
|
120
|
+
* capability as its Rust variant name.
|
|
121
|
+
*/
|
|
122
|
+
export interface NativeErrorFields {
|
|
123
|
+
readonly tag?: string | undefined;
|
|
124
|
+
readonly detail?: string | undefined;
|
|
125
|
+
readonly capability?: string | undefined;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Returns the typed SDK error for a native `FfiError`, or `undefined` for
|
|
129
|
+
* variants that adapters rethrow unchanged. An `InvalidConfig` whose
|
|
130
|
+
* capability is missing or unknown (native and SDK versions out of step)
|
|
131
|
+
* is rethrown unchanged too, rather than given a capability it did not name.
|
|
115
132
|
*/
|
|
116
|
-
export declare const typedFfiError: (
|
|
133
|
+
export declare const typedFfiError: ({ capability, detail, tag, }: NativeErrorFields) => Error | undefined;
|
|
117
134
|
/** Platform implementation used to construct endpoints and identity helpers. */
|
|
118
135
|
export interface Minip2pBackendFactory {
|
|
119
136
|
create: (config: Minip2pConfig) => Minip2pBackend;
|
package/dist/backend.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../src/backend.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../src/backend.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,KAAK,EACL,cAAc,EACd,YAAY,EACZ,aAAa,EACb,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAEpB,6DAA6D;AAC7D,MAAM,WAAW,iBAAiB;IAChC,qDAAqD;IACrD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,kDAAkD;IAClD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAC5B;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAClD;IAAE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|
1
|
-
import { BackpressureError, MessageTooLargeError, NotPermittedError, } from "./errors.js";
|
|
1
|
+
import { BackpressureError, InvalidConfigError, MessageTooLargeError, NotPermittedError, } from "./errors.js";
|
|
2
|
+
import { ConfigCapability } from "./types.js";
|
|
2
3
|
export { resolveEndpointConfig } from "./config.js";
|
|
3
4
|
export { EventDrain } from "./event-drain.js";
|
|
4
5
|
export { ConnectionIdMap, u64ToNumber } from "./native-ids.js";
|
|
6
|
+
export { SettleHandles, eventStream } from "./settle-handles.js";
|
|
5
7
|
export { P2pEvent_Tags, PathKind_Tags, } from "./types.js";
|
|
8
|
+
// Each capability's name is its value, so an own key is a capability.
|
|
9
|
+
const isConfigCapability = (name) => Object.hasOwn(ConfigCapability, name);
|
|
6
10
|
/**
|
|
7
|
-
* Returns the typed SDK error for a native `FfiError
|
|
8
|
-
*
|
|
9
|
-
*
|
|
11
|
+
* Returns the typed SDK error for a native `FfiError`, or `undefined` for
|
|
12
|
+
* variants that adapters rethrow unchanged. An `InvalidConfig` whose
|
|
13
|
+
* capability is missing or unknown (native and SDK versions out of step)
|
|
14
|
+
* is rethrown unchanged too, rather than given a capability it did not name.
|
|
10
15
|
*/
|
|
11
|
-
export const typedFfiError = (tag,
|
|
16
|
+
export const typedFfiError = ({ capability, detail, tag, }) => {
|
|
12
17
|
switch (tag) {
|
|
13
18
|
case "Backpressure": {
|
|
14
19
|
return new BackpressureError();
|
|
@@ -19,6 +24,11 @@ export const typedFfiError = (tag, detail) => {
|
|
|
19
24
|
case "NotPermitted": {
|
|
20
25
|
return new NotPermittedError(detail);
|
|
21
26
|
}
|
|
27
|
+
case "InvalidConfig": {
|
|
28
|
+
return capability !== undefined && isConfigCapability(capability)
|
|
29
|
+
? new InvalidConfigError(capability, detail ?? "")
|
|
30
|
+
: undefined;
|
|
31
|
+
}
|
|
22
32
|
default: {
|
|
23
33
|
return undefined;
|
|
24
34
|
}
|
package/dist/backend.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backend.js","sourceRoot":"","sources":["../src/backend.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"backend.js","sourceRoot":"","sources":["../src/backend.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AA0H9C,OAAO,EAAE,qBAAqB,EAA8B,MAAM,aAAa,CAAC;AAChF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EACL,aAAa,EACb,aAAa,GAId,MAAM,YAAY,CAAC;AAapB,sEAAsE;AACtE,MAAM,kBAAkB,GAAG,CAAC,IAAY,EAA4B,EAAE,CACpE,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;AAExC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAC5B,UAAU,EACV,MAAM,EACN,GAAG,GACe,EAAqB,EAAE;IACzC,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,cAAc,EAAE,CAAC;YACpB,OAAO,IAAI,iBAAiB,EAAE,CAAC;QACjC,CAAC;QACD,KAAK,iBAAiB,EAAE,CAAC;YACvB,OAAO,IAAI,oBAAoB,EAAE,CAAC;QACpC,CAAC;QACD,KAAK,cAAc,EAAE,CAAC;YACpB,OAAO,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAAC;QACvC,CAAC;QACD,KAAK,eAAe,EAAE,CAAC;YACrB,OAAO,UAAU,KAAK,SAAS,IAAI,kBAAkB,CAAC,UAAU,CAAC;gBAC/D,CAAC,CAAC,IAAI,kBAAkB,CAAC,UAAU,EAAE,MAAM,IAAI,EAAE,CAAC;gBAClD,CAAC,CAAC,SAAS,CAAC;QAChB,CAAC;QACD,SAAS,CAAC;YACR,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;AACH,CAAC,CAAC"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DriverFailureKind, EndpointErrorKind, NatErrorKind } from "./types.js";
|
|
1
|
+
import type { ConfigCapability, DriverFailureKind, EndpointErrorKind, NatErrorKind } from "./types.js";
|
|
2
2
|
/** Pubsub rejected a publish because its bounded native queue is full. */
|
|
3
3
|
export declare class BackpressureError extends Error {
|
|
4
4
|
constructor();
|
|
@@ -11,6 +11,18 @@ export declare class MessageTooLargeError extends Error {
|
|
|
11
11
|
export declare class NotPermittedError extends Error {
|
|
12
12
|
constructor(message?: string);
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* The endpoint configuration was invalid. `capability` names the part of the
|
|
16
|
+
* configuration to change; a socket the platform refused is a transport
|
|
17
|
+
* failure instead, and a malformed listen address an invalid-address one.
|
|
18
|
+
*/
|
|
19
|
+
export declare class InvalidConfigError extends Error {
|
|
20
|
+
/** The part of the configuration that was invalid. */
|
|
21
|
+
readonly capability: ConfigCapability;
|
|
22
|
+
/** Human-readable native diagnostic. */
|
|
23
|
+
readonly detail: string;
|
|
24
|
+
constructor(capability: ConfigCapability, detail: string);
|
|
25
|
+
}
|
|
14
26
|
/** Platform-neutral operation cancellation error. */
|
|
15
27
|
export declare class AbortError extends Error {
|
|
16
28
|
constructor(message?: string);
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,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AED,8DAA8D;AAC9D,qBAAa,eAAgB,SAAQ,KAAK;IACxC,8EAA8E;IAC9E,QAAQ,CAAC,IAAI,EAAE,iBAAiB,GAAG,aAAa,CAAC;IACjD,sBAAsB;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,gEAAgE;IAChE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,gDAAgD;IAChD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,mDAAmD;IACnD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,YAAY,OAAO,EAAE;QACnB,IAAI,EAAE,iBAAiB,GAAG,aAAa,CAAC;QACxC,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;KAChB,EAQA;CACF;AAED,6DAA6D;AAC7D,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,YAAY,OAAO,SAA6C,EAG/D;CACF;AAED;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,yEAAyE;IACzE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,yCAAyC;IACzC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAE/B,YAAY,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAOlD;CACF;AAED,yEAAyE;AACzE,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,cAGC;CACF"}
|
package/dist/errors.js
CHANGED
|
@@ -20,6 +20,23 @@ export class NotPermittedError extends Error {
|
|
|
20
20
|
this.name = "NotPermittedError";
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* The endpoint configuration was invalid. `capability` names the part of the
|
|
25
|
+
* configuration to change; a socket the platform refused is a transport
|
|
26
|
+
* failure instead, and a malformed listen address an invalid-address one.
|
|
27
|
+
*/
|
|
28
|
+
export class InvalidConfigError extends Error {
|
|
29
|
+
/** The part of the configuration that was invalid. */
|
|
30
|
+
capability;
|
|
31
|
+
/** Human-readable native diagnostic. */
|
|
32
|
+
detail;
|
|
33
|
+
constructor(capability, detail) {
|
|
34
|
+
super(detail.length > 0 ? detail : `Invalid ${capability} configuration`);
|
|
35
|
+
this.name = "InvalidConfigError";
|
|
36
|
+
this.capability = capability;
|
|
37
|
+
this.detail = detail;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
23
40
|
/** Platform-neutral operation cancellation error. */
|
|
24
41
|
export class AbortError extends Error {
|
|
25
42
|
constructor(message = "The operation was aborted") {
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,4FAA4F;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAS5F,0EAA0E;AAC1E,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1C;QACE,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACzC,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AAED,wDAAwD;AACxD,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C;QACE,KAAK,CAAC,kDAAkD,CAAC,CAAC;QAC1D,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAED,2DAA2D;AAC3D,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1C,YAAY,OAAO,GAAG,gCAAgC;QACpD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,sDAAsD;IAC7C,UAAU,CAAmB;IACtC,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QACjC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAC/B,CAAC;CACF;AAED,6DAA6D;AAC7D,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1C,YAAY,OAAO,GAAG,0CAA0C;QAC9D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C,yEAAyE;IAChE,QAAQ,CAAS;IAC1B,yCAAyC;IAChC,aAAa,CAAS;IAE/B,YAAY,QAAgB,EAAE,aAAqB;QACjD,KAAK,CACH,qCAAqC,QAAQ,6CAA6C,aAAa,GAAG,CAC3G,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;CACF;AAED,yEAAyE;AACzE,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAChD;QACE,KAAK,CAAC,kEAAkE,CAAC,CAAC;QAC1E,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACxC,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { AbortError, BackpressureError, ClosedError, ConnectCancelledError, ConnectFailedError, ConnectResultLostError, ConnectResultUnavailableError, DriverFailedError, EventQueueOverflowError, MessageTooLargeError, NotPermittedError, OpenStreamError, PeerDisconnectedError, StreamClosedError, TimeoutError, WriteBufferFullError, } from "./errors.js";
|
|
1
|
+
export { AbortError, BackpressureError, ClosedError, ConnectCancelledError, ConnectFailedError, ConnectResultLostError, ConnectResultUnavailableError, DriverFailedError, EventQueueOverflowError, InvalidConfigError, MessageTooLargeError, NotPermittedError, OpenStreamError, PeerDisconnectedError, StreamClosedError, TimeoutError, WriteBufferFullError, } from "./errors.js";
|
|
2
2
|
export { Minip2pBase, Stream, type StreamEventMap } from "./sdk.js";
|
|
3
|
-
export { DiscoverySource, DriverFailureKind, EndpointErrorKind, NatErrorKind, Reachability, type Bytes, type CloseReason, type ConnectionInfo, type ConnectOptions, type ConnectResult, type ConnectTarget, type EventsOptions, type IdentifyInfo, type InboundStreamMeta, type KnownPeerInfo, type Minip2pCatchAllEventMap, type Minip2pConfig, type Minip2pDiscoveryOptions, type Minip2pEvent, type Minip2pMdnsOptions, type Minip2pNamedEventMap, type OnceOptions, type OpOptions, type Path, type RelayReservationInfo, type Unsubscribe, type WaitForOptions, } from "./types.js";
|
|
3
|
+
export { ConfigCapability, DiscoverySource, DriverFailureKind, EndpointErrorKind, MdnsFailureKind, NatErrorKind, Reachability, type Bytes, type CloseReason, type ConnectionInfo, type ConnectOptions, type ConnectResult, type ConnectTarget, type EventsOptions, type IdentifyInfo, type InboundStreamMeta, type KnownPeerInfo, type Minip2pCatchAllEventMap, type Minip2pConfig, type Minip2pDiscoveryOptions, type Minip2pEvent, type Minip2pMdnsOptions, type Minip2pNamedEventMap, type OnceOptions, type OpOptions, type Path, type RelayReservationInfo, type Unsubscribe, type WaitForOptions, } from "./types.js";
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,EACtB,6BAA6B,EAC7B,iBAAiB,EACjB,uBAAuB,EACvB,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AACpE,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,KAAK,KAAK,EACV,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EAClB,KAAK,uBAAuB,EAC5B,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,IAAI,EACT,KAAK,oBAAoB,EACzB,KAAK,WAAW,EAChB,KAAK,cAAc,GACpB,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,EACtB,6BAA6B,EAC7B,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AACpE,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,KAAK,KAAK,EACV,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EAClB,KAAK,uBAAuB,EAC5B,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,IAAI,EACT,KAAK,oBAAoB,EACzB,KAAK,WAAW,EAChB,KAAK,cAAc,GACpB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { AbortError, BackpressureError, ClosedError, ConnectCancelledError, ConnectFailedError, ConnectResultLostError, ConnectResultUnavailableError, DriverFailedError, EventQueueOverflowError, MessageTooLargeError, NotPermittedError, OpenStreamError, PeerDisconnectedError, StreamClosedError, TimeoutError, WriteBufferFullError, } from "./errors.js";
|
|
1
|
+
export { AbortError, BackpressureError, ClosedError, ConnectCancelledError, ConnectFailedError, ConnectResultLostError, ConnectResultUnavailableError, DriverFailedError, EventQueueOverflowError, InvalidConfigError, MessageTooLargeError, NotPermittedError, OpenStreamError, PeerDisconnectedError, StreamClosedError, TimeoutError, WriteBufferFullError, } from "./errors.js";
|
|
2
2
|
export { Minip2pBase, Stream } from "./sdk.js";
|
|
3
|
-
export { DiscoverySource, DriverFailureKind, EndpointErrorKind, NatErrorKind, Reachability, } from "./types.js";
|
|
3
|
+
export { ConfigCapability, DiscoverySource, DriverFailureKind, EndpointErrorKind, MdnsFailureKind, NatErrorKind, Reachability, } from "./types.js";
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,EACtB,6BAA6B,EAC7B,iBAAiB,EACjB,uBAAuB,EACvB,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,MAAM,EAAuB,MAAM,UAAU,CAAC;AACpE,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,YAAY,GAuBb,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,EACtB,6BAA6B,EAC7B,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,MAAM,EAAuB,MAAM,UAAU,CAAC;AACpE,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,YAAY,GAuBb,MAAM,YAAY,CAAC"}
|
package/dist/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAwB,cAAc,EAAE,MAAM,cAAc,CAAC;AAiBzE,OAAO,KAAK,EACV,KAAK,EACL,WAAW,EACX,cAAc,EACd,cAAc,EACd,aAAa,EACb,aAAa,EACb,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,aAAa,EAEb,YAAY,EACZ,oBAAoB,EACpB,WAAW,EACX,SAAS,EAGT,IAAI,EAEJ,YAAY,EACZ,oBAAoB,EACpB,WAAW,EACX,cAAc,EACf,MAAM,YAAY,CAAC;AAkCpB,KAAK,SAAS,GAAG,MAAM,oB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;OAMG;IACH,aAAa,CACX,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,SAAc,GACtB,OAAO,CAAC;QACT,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;KACvC,CAAC,CAoCD;IAED,gFAAgF;IAChF,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,SAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAsB7D;IAED,2DAA2D;IAC3D,UAAU,CACR,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,SAAc,GACtB,OAAO,CAAC,MAAM,CAAC,CAwDjB;IAED;;;;;;;;;OASG;IACH,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAK1C;IAED;;;;OAIG;IACH,OAAO,CACL,MAAM,EAAE,aAAa,EACrB,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,aAAa,CAAC,CAQxB;IAED;;;;;;;;;;;OAWG;IACH,iBAAiB,CACf,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,aAAa,CAAC,CAoDxB;IAED;;;;;;;OAOG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAIrC;IAED,gDAAgD;IAChD,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAG/B;CAglBF"}
|
package/dist/sdk.js
CHANGED
|
@@ -164,6 +164,31 @@ class StreamTable {
|
|
|
164
164
|
return values;
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
|
+
/** Every connection a native event names. */
|
|
168
|
+
const connectionsOf = (event) => {
|
|
169
|
+
if (!("inner" in event)) {
|
|
170
|
+
return [];
|
|
171
|
+
}
|
|
172
|
+
const { inner } = event;
|
|
173
|
+
return [
|
|
174
|
+
"connId" in inner ? inner.connId : undefined,
|
|
175
|
+
"oldConnId" in inner ? inner.oldConnId : undefined,
|
|
176
|
+
"newConnId" in inner ? inner.newConnId : undefined,
|
|
177
|
+
].filter((id) => typeof id === "number");
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* Native events that leave a connection unseen. Anything else naming it is
|
|
181
|
+
* something the application acts on or must hear about, so it keeps the
|
|
182
|
+
* connection's events.
|
|
183
|
+
*/
|
|
184
|
+
const UNSEEN_CONNECTION_TAGS = new Set([
|
|
185
|
+
P2pEvent_Tags.PeerReady,
|
|
186
|
+
P2pEvent_Tags.IdentifyReceived,
|
|
187
|
+
P2pEvent_Tags.EndpointError,
|
|
188
|
+
P2pEvent_Tags.StreamRemoteWriteClosed,
|
|
189
|
+
P2pEvent_Tags.StreamWriteStopped,
|
|
190
|
+
P2pEvent_Tags.StreamClosed,
|
|
191
|
+
]);
|
|
167
192
|
/** The native per-stream event an item carries, if any. */
|
|
168
193
|
const streamEventOf = (item) => item.source === "native" &&
|
|
169
194
|
(item.event.tag === P2pEvent_Tags.StreamReady || isStreamEvent(item.event))
|
|
@@ -180,6 +205,15 @@ const streamEventOf = (item) => item.source === "native" &&
|
|
|
180
205
|
* A peer-opened stream that closes without data before its `StreamReady`
|
|
181
206
|
* is dispatched leaves the queue whole, so a peer opening and closing
|
|
182
207
|
* streams cannot grow it; its events still reach `release`.
|
|
208
|
+
*
|
|
209
|
+
* Connections follow the same rule (ADR 0012): one that ends without data
|
|
210
|
+
* before any of its events was dispatched, whichever side dialed it, leaves
|
|
211
|
+
* with every event naming it. One replaced instead folds into its
|
|
212
|
+
* successor: its queued `ConnectionEstablished` is renamed to the successor
|
|
213
|
+
* and the `ConnectionReplaced` goes (as it does when the capacity already
|
|
214
|
+
* dropped that `ConnectionEstablished`). A connection the application knows
|
|
215
|
+
* otherwise -- a stream it opened, a ping result, an attempt or path event
|
|
216
|
+
* naming it -- is kept.
|
|
183
217
|
*/
|
|
184
218
|
class EventQueue {
|
|
185
219
|
#items = new Map();
|
|
@@ -191,6 +225,14 @@ class EventQueue {
|
|
|
191
225
|
* queued item ids; `undefined` once one carried data.
|
|
192
226
|
*/
|
|
193
227
|
#unseen = new StreamTable();
|
|
228
|
+
/** Connections whose `ConnectionEstablished` is queued and unseen. */
|
|
229
|
+
#unseenConnections = new Set();
|
|
230
|
+
/**
|
|
231
|
+
* Live connections the application learned of outside the queue, so a
|
|
232
|
+
* later replacement fold must not make them unseen; each leaves with its
|
|
233
|
+
* end.
|
|
234
|
+
*/
|
|
235
|
+
#knownConnections = new Set();
|
|
194
236
|
#capacity;
|
|
195
237
|
#release;
|
|
196
238
|
#next = 0;
|
|
@@ -207,14 +249,14 @@ class EventQueue {
|
|
|
207
249
|
const newest = this.#newest === undefined ? undefined : this.#items.get(this.#newest);
|
|
208
250
|
const merged = newest === undefined ? undefined : coalesceData(newest, item);
|
|
209
251
|
if (merged !== undefined && this.#newest !== undefined) {
|
|
210
|
-
// A data event retires no adapter IDs, so the absorbed one needs no
|
|
211
|
-
// `eventHandled`.
|
|
212
252
|
this.#items.set(this.#newest, merged);
|
|
253
|
+
// The absorbed event is handled: its adapter state goes now.
|
|
254
|
+
this.#release(item);
|
|
213
255
|
return undefined;
|
|
214
256
|
}
|
|
215
257
|
const id = this.#next;
|
|
216
258
|
this.#next += 1;
|
|
217
|
-
if (this.#elideUnseen(item, id)) {
|
|
259
|
+
if (this.#elideUnseen(item, id) || this.#elideConnection(item)) {
|
|
218
260
|
return undefined;
|
|
219
261
|
}
|
|
220
262
|
this.#items.set(id, item);
|
|
@@ -237,12 +279,105 @@ class EventQueue {
|
|
|
237
279
|
return undefined;
|
|
238
280
|
}
|
|
239
281
|
const item = this.#remove(oldest);
|
|
240
|
-
if (item?.source === "native"
|
|
241
|
-
item.event.tag === P2pEvent_Tags.StreamReady) {
|
|
242
|
-
|
|
282
|
+
if (item?.source === "native") {
|
|
283
|
+
if (item.event.tag === P2pEvent_Tags.StreamReady) {
|
|
284
|
+
this.#unseen.delete(item.event.inner.connId, item.event.inner.streamId);
|
|
285
|
+
}
|
|
286
|
+
for (const connId of connectionsOf(item.event)) {
|
|
287
|
+
this.#unseenConnections.delete(connId);
|
|
288
|
+
}
|
|
243
289
|
}
|
|
244
290
|
return item;
|
|
245
291
|
}
|
|
292
|
+
/** The application learned of `connId` outside the queue. */
|
|
293
|
+
markConnectionSeen(connId) {
|
|
294
|
+
this.#unseenConnections.delete(connId);
|
|
295
|
+
this.#knownConnections.add(connId);
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Records `item` against the unseen connections it names. Returns whether
|
|
299
|
+
* it ended or replaced one that carried no data, which leaves the queue
|
|
300
|
+
* with that connection's items instead.
|
|
301
|
+
*/
|
|
302
|
+
#elideConnection(item) {
|
|
303
|
+
if (item.source !== "native") {
|
|
304
|
+
return false;
|
|
305
|
+
}
|
|
306
|
+
const { event } = item;
|
|
307
|
+
switch (event.tag) {
|
|
308
|
+
case P2pEvent_Tags.ConnectionEstablished: {
|
|
309
|
+
if (!this.#knownConnections.has(event.inner.connId)) {
|
|
310
|
+
this.#unseenConnections.add(event.inner.connId);
|
|
311
|
+
}
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
314
|
+
case P2pEvent_Tags.ConnectionClosed: {
|
|
315
|
+
this.#knownConnections.delete(event.inner.connId);
|
|
316
|
+
if (!this.#unseenConnections.delete(event.inner.connId)) {
|
|
317
|
+
return false;
|
|
318
|
+
}
|
|
319
|
+
this.#removeConnection(event.inner.connId);
|
|
320
|
+
this.#release(item);
|
|
321
|
+
return true;
|
|
322
|
+
}
|
|
323
|
+
case P2pEvent_Tags.ConnectionReplaced: {
|
|
324
|
+
const { newConnId, oldConnId } = event.inner;
|
|
325
|
+
this.#knownConnections.delete(oldConnId);
|
|
326
|
+
if (!this.#unseenConnections.delete(oldConnId)) {
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
this.#renameOpening(oldConnId, newConnId);
|
|
330
|
+
this.#removeConnection(oldConnId);
|
|
331
|
+
if (!this.#knownConnections.has(newConnId)) {
|
|
332
|
+
this.#unseenConnections.add(newConnId);
|
|
333
|
+
}
|
|
334
|
+
this.#release(item);
|
|
335
|
+
return true;
|
|
336
|
+
}
|
|
337
|
+
case P2pEvent_Tags.StreamReady: {
|
|
338
|
+
if (event.inner.initiatedLocally) {
|
|
339
|
+
this.#unseenConnections.delete(event.inner.connId);
|
|
340
|
+
}
|
|
341
|
+
return false;
|
|
342
|
+
}
|
|
343
|
+
default: {
|
|
344
|
+
if (!UNSEEN_CONNECTION_TAGS.has(event.tag)) {
|
|
345
|
+
for (const connId of connectionsOf(event)) {
|
|
346
|
+
this.#unseenConnections.delete(connId);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
return false;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
/** Renames the queued `ConnectionEstablished` of `from` to `to`. */
|
|
354
|
+
#renameOpening(from, to) {
|
|
355
|
+
for (const [id, queued] of this.#items) {
|
|
356
|
+
if (queued.source === "native" &&
|
|
357
|
+
queued.event.tag === P2pEvent_Tags.ConnectionEstablished &&
|
|
358
|
+
queued.event.inner.connId === from) {
|
|
359
|
+
this.#items.set(id, {
|
|
360
|
+
event: {
|
|
361
|
+
...queued.event,
|
|
362
|
+
inner: { ...queued.event.inner, connId: to },
|
|
363
|
+
},
|
|
364
|
+
source: "native",
|
|
365
|
+
});
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
/** Removes every queued item naming `connId`, releasing each. */
|
|
371
|
+
#removeConnection(connId) {
|
|
372
|
+
for (const [id, queued] of [...this.#items]) {
|
|
373
|
+
if (queued.source === "native" &&
|
|
374
|
+
connectionsOf(queued.event).includes(connId)) {
|
|
375
|
+
this.#remove(id);
|
|
376
|
+
this.#release(queued);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
this.#unseen.takeConnection(connId);
|
|
380
|
+
}
|
|
246
381
|
/**
|
|
247
382
|
* Records `item` (as `id`) against an unseen peer stream. Returns whether
|
|
248
383
|
* it closed one that carried no data, which leaves the queue whole.
|
|
@@ -1055,6 +1190,8 @@ export class Minip2pBase {
|
|
|
1055
1190
|
let identity;
|
|
1056
1191
|
try {
|
|
1057
1192
|
identity = this.#backend.openStream(peerId, protocolId);
|
|
1193
|
+
// The application now knows the connection: its end must reach it.
|
|
1194
|
+
this.#queue.markConnectionSeen(identity.connId);
|
|
1058
1195
|
}
|
|
1059
1196
|
catch (error) {
|
|
1060
1197
|
return Promise.reject(new OpenStreamError({
|
|
@@ -1777,11 +1914,14 @@ const SDK_EVENT_NAMES = {
|
|
|
1777
1914
|
[P2pEvent_Tags.PeerUpdated]: "peerUpdated",
|
|
1778
1915
|
[P2pEvent_Tags.PeerExpired]: "peerExpired",
|
|
1779
1916
|
[P2pEvent_Tags.DiscoveryDialFailed]: "discoveryDialFailed",
|
|
1917
|
+
[P2pEvent_Tags.MdnsFailed]: "mdnsFailed",
|
|
1918
|
+
[P2pEvent_Tags.MdnsRecovered]: "mdnsRecovered",
|
|
1780
1919
|
[P2pEvent_Tags.DiscoveryProtocolViolation]: "discoveryProtocolViolation",
|
|
1781
1920
|
};
|
|
1782
1921
|
function normalizeEvent(event) {
|
|
1783
1922
|
const type = SDK_EVENT_NAMES[event.tag];
|
|
1784
|
-
|
|
1923
|
+
// A native variant without fields arrives without `inner`.
|
|
1924
|
+
let payload = "inner" in event ? event.inner : {};
|
|
1785
1925
|
if (event.tag === P2pEvent_Tags.PathEstablished) {
|
|
1786
1926
|
payload = { ...event.inner, path: normalizePath(event.inner.path) };
|
|
1787
1927
|
}
|