@minip2p/web 0.13.1 → 0.14.0

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 CHANGED
@@ -43,7 +43,7 @@ Other limits:
43
43
 
44
44
  - Only WebTransport addresses dial; a `/quic-v1` or `/tcp` candidate fails as a candidate. An address with certhashes pins the node's self-signed certificates. One without, such as `/dns/relay.example.com/udp/443/quic-v1/webtransport/p2p/12D3KooW…`, expects a CA-signed certificate for that domain, which the browser verifies as it would for any HTTPS page.
45
45
  - `listenAddrs()` is always empty (a reservation is `circuitAddress`), `knownPeers()` is empty and `reachability()` stays `unknown`.
46
- - `close()` closes every session at once with WebTransport's close capsule, without flushing accepted writes first; its timeout is ignored. `setActive()` is ignored as well: the page's own timers drive the endpoint.
46
+ - `close()` closes every session at once with WebTransport's close capsule, without flushing accepted writes first; its timeout is ignored. Call `resume()` when the page becomes visible again, so a relay reservation lost while the tab was throttled recovers at once.
47
47
  - A page on a public origin that dials a private address may trigger Chrome's Local Network Access prompt.
48
48
  - A trapped wasm module (a Rust panic) fails the endpoint with `DriverFailedError`; its WebTransport sessions are closed from TypeScript, `close()` still resolves (`Failed`), and later calls throw `ClosedError`. Create a new endpoint to carry on.
49
49
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minip2p/web",
3
- "version": "0.13.1",
3
+ "version": "0.14.0",
4
4
  "description": "Browser SDK for minip2p over libp2p WebTransport",
5
5
  "keywords": [
6
6
  "browser",
@@ -56,10 +56,10 @@
56
56
  "registry": "https://registry.npmjs.org/"
57
57
  },
58
58
  "dependencies": {
59
- "@minip2p/core": "0.13.1"
59
+ "@minip2p/core": "0.14.0"
60
60
  },
61
61
  "devDependencies": {
62
- "@minip2p/node": "0.13.1",
62
+ "@minip2p/node": "0.14.0",
63
63
  "@minip2p/test-fixtures": "0.0.0",
64
64
  "@playwright/test": "1.64.1",
65
65
  "@types/node": "26.6.5",
@@ -123,17 +123,16 @@ export class WebEndpoint {
123
123
  * Resets a stream.
124
124
  */
125
125
  resetStream(conn_id: bigint, stream_id: bigint): void;
126
+ /**
127
+ * Tells the endpoint its page is visible again, so a relay
128
+ * reservation recovers at once. Does nothing once closed.
129
+ */
130
+ resume(): void;
126
131
  /**
127
132
  * Sends bytes on a stream: `true` once all are accepted, `false` while
128
133
  * the tail is held and `StreamWriteAccepted` is still to come.
129
134
  */
130
135
  sendStream(conn_id: bigint, stream_id: bigint, data: Uint8Array): boolean;
131
- /**
132
- * Ignored in the browser, kept for the shared SDK surface: there is no
133
- * background driver whose cadence it could change. The page's own
134
- * timers pump the endpoint.
135
- */
136
- setActive(_active: boolean): void;
137
136
  /**
138
137
  * Starts driving; `doorbell` is called when events become ready to drain.
139
138
  */
@@ -201,8 +200,8 @@ export interface InitOutput {
201
200
  readonly webendpoint_pump: (a: number) => [number, number];
202
201
  readonly webendpoint_reachability: (a: number) => [number, number, number];
203
202
  readonly webendpoint_resetStream: (a: number, b: bigint, c: bigint) => [number, number];
203
+ readonly webendpoint_resume: (a: number) => void;
204
204
  readonly webendpoint_sendStream: (a: number, b: bigint, c: bigint, d: number, e: number) => [number, number, number];
205
- readonly webendpoint_setActive: (a: number, b: number) => void;
206
205
  readonly webendpoint_start: (a: number, b: any) => [number, number];
207
206
  readonly webendpoint_streamConsumed: (a: number, b: bigint, c: bigint, d: number) => [number, number];
208
207
  readonly webendpoint_subscribe: (a: number, b: number, c: number) => [number, number, number];
@@ -340,6 +340,13 @@ export class WebEndpoint {
340
340
  throw takeFromExternrefTable0(ret[0]);
341
341
  }
342
342
  }
343
+ /**
344
+ * Tells the endpoint its page is visible again, so a relay
345
+ * reservation recovers at once. Does nothing once closed.
346
+ */
347
+ resume() {
348
+ wasm.webendpoint_resume(this.__wbg_ptr);
349
+ }
343
350
  /**
344
351
  * Sends bytes on a stream: `true` once all are accepted, `false` while
345
352
  * the tail is held and `StreamWriteAccepted` is still to come.
@@ -357,15 +364,6 @@ export class WebEndpoint {
357
364
  }
358
365
  return ret[0] !== 0;
359
366
  }
360
- /**
361
- * Ignored in the browser, kept for the shared SDK surface: there is no
362
- * background driver whose cadence it could change. The page's own
363
- * timers pump the endpoint.
364
- * @param {boolean} _active
365
- */
366
- setActive(_active) {
367
- wasm.webendpoint_setActive(this.__wbg_ptr, _active);
368
- }
369
367
  /**
370
368
  * Starts driving; `doorbell` is called when events become ready to drain.
371
369
  * @param {Function} doorbell
@@ -577,13 +575,13 @@ function __wbg_get_imports() {
577
575
  const ret = arg0.call(arg1);
578
576
  return ret;
579
577
  }, arguments); },
580
- __wbg_closeWrite_2746e5704c72dfb8: function(arg0, arg1) {
578
+ __wbg_closeWrite_0d4d9a8c25ef813c: function(arg0, arg1) {
581
579
  arg0.closeWrite(arg1 >>> 0);
582
580
  },
583
- __wbg_close_8a72f123947db9dd: function(arg0, arg1, arg2, arg3, arg4) {
581
+ __wbg_close_c7d1e1c6dbaaee98: function(arg0, arg1, arg2, arg3, arg4) {
584
582
  arg0.close(arg1 >>> 0, arg2 >>> 0, getStringFromWasm0(arg3, arg4));
585
583
  },
586
- __wbg_connect_e6c10e355f0ca570: function() { return handleError(function (arg0, arg1, arg2, arg3) {
584
+ __wbg_connect_5d585bfefc20d864: function() { return handleError(function (arg0, arg1, arg2, arg3) {
587
585
  const ret = arg0.connect(getStringFromWasm0(arg1, arg2), arg3);
588
586
  return ret;
589
587
  }, arguments); },
@@ -618,7 +616,7 @@ function __wbg_get_imports() {
618
616
  const ret = arg0[arg1];
619
617
  return ret;
620
618
  },
621
- __wbg_grantRead_019435f658c6e565: function(arg0, arg1, arg2) {
619
+ __wbg_grantRead_7a02a71500ef365e: function(arg0, arg1, arg2) {
622
620
  arg0.grantRead(arg1 >>> 0, arg2 >>> 0);
623
621
  },
624
622
  __wbg_instanceof_ArrayBuffer_d4ff01f8247925ae: function(arg0) {
@@ -713,7 +711,7 @@ function __wbg_get_imports() {
713
711
  const ret = arg0.next();
714
712
  return ret;
715
713
  }, arguments); },
716
- __wbg_now_57f1c784cc4bf3b6: function() {
714
+ __wbg_now_64c69b38b5df5c7f: function() {
717
715
  const ret = performance.now();
718
716
  return ret;
719
717
  },
@@ -721,11 +719,11 @@ function __wbg_get_imports() {
721
719
  const ret = Date.now();
722
720
  return ret;
723
721
  },
724
- __wbg_openStream_9cc0a43cb12f8370: function() { return handleError(function (arg0, arg1) {
722
+ __wbg_openStream_62f301e2f42fa267: function() { return handleError(function (arg0, arg1) {
725
723
  const ret = arg0.openStream(arg1 >>> 0);
726
724
  return ret;
727
725
  }, arguments); },
728
- __wbg_pollEvent_3d05589622e30807: function(arg0) {
726
+ __wbg_pollEvent_163f9cddc117f92a: function(arg0) {
729
727
  const ret = arg0.pollEvent();
730
728
  return ret;
731
729
  },
@@ -736,7 +734,7 @@ function __wbg_get_imports() {
736
734
  const ret = arg0.push(arg1);
737
735
  return ret;
738
736
  },
739
- __wbg_reset_c7cfc60d068ad4e7: function(arg0, arg1, arg2) {
737
+ __wbg_reset_ff9840e85ce4db30: function(arg0, arg1, arg2) {
740
738
  arg0.reset(arg1 >>> 0, arg2);
741
739
  },
742
740
  __wbg_set_13d25b81ab403f5e: function(arg0, arg1, arg2) {
@@ -753,7 +751,7 @@ function __wbg_get_imports() {
753
751
  const ret = arg0.value;
754
752
  return ret;
755
753
  },
756
- __wbg_write_3e34a1e1f74cef86: function() { return handleError(function (arg0, arg1, arg2, arg3) {
754
+ __wbg_write_44acf729302ce447: function() { return handleError(function (arg0, arg1, arg2, arg3) {
757
755
  const ret = arg0.write(arg1 >>> 0, getArrayU8FromWasm0(arg2, arg3));
758
756
  return ret;
759
757
  }, arguments); },
Binary file
@@ -31,8 +31,8 @@ export const webendpoint_publish: (a: number, b: number, c: number, d: number, e
31
31
  export const webendpoint_pump: (a: number) => [number, number];
32
32
  export const webendpoint_reachability: (a: number) => [number, number, number];
33
33
  export const webendpoint_resetStream: (a: number, b: bigint, c: bigint) => [number, number];
34
+ export const webendpoint_resume: (a: number) => void;
34
35
  export const webendpoint_sendStream: (a: number, b: bigint, c: bigint, d: number, e: number) => [number, number, number];
35
- export const webendpoint_setActive: (a: number, b: number) => void;
36
36
  export const webendpoint_start: (a: number, b: any) => [number, number];
37
37
  export const webendpoint_streamConsumed: (a: number, b: bigint, c: bigint, d: number) => [number, number];
38
38
  export const webendpoint_subscribe: (a: number, b: number, c: number) => [number, number, number];