@oxidezap/whatsapp-rust-bridge 0.16.0 → 0.17.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.
@@ -2655,7 +2655,7 @@ export type PresenceStatus = "available" | "unavailable";
2655
2655
  * `From` impls below by walking the source chain. This keeps the JS object
2656
2656
  * shape predictable and the codegen / `Tsify` output simple.
2657
2657
  */
2658
- export type BridgeError = { kind: "server"; serverCode: number; serverText: string; errorType?: string; backoffSeconds?: number } | { kind: "timeout" } | { kind: "not-connected" } | { kind: "disconnected"; reason: string } | { kind: "invalid-argument"; field: string; reason: string } | { kind: "protocol-violation"; reason: string } | { kind: "crypto"; operation: string } | { kind: "storage"; operation: string } | { kind: "no-recipient-device"; attempted: number } | { kind: "internal"; message: string };
2658
+ export type BridgeError = { kind: "server"; serverCode: number; serverText: string; errorType?: string; backoffSeconds?: number } | { kind: "timeout" } | { kind: "not-connected" } | { kind: "withdrawn" } | { kind: "disconnected"; reason: string } | { kind: "invalid-argument"; field: string; reason: string } | { kind: "protocol-violation"; reason: string } | { kind: "crypto"; operation: string } | { kind: "storage"; operation: string } | { kind: "no-recipient-device"; attempted: number } | { kind: "internal"; message: string };
2659
2659
 
2660
2660
  /**
2661
2661
  * Public portion of one pre-key in a supplied pairwise session bundle.
@@ -3031,6 +3031,21 @@ export interface CoverPhotoUploadInput {
3031
3031
  timestamp: string;
3032
3032
  }
3033
3033
 
3034
+ /**
3035
+ * What the client\'s connection state means for work handed to it now.
3036
+ *
3037
+ * The core\'s `Reachability`, carried across unflattened. A refused call says
3038
+ * what happened to that attempt; this says what the client is, which is the
3039
+ * only thing that answers whether asking again is worth it — so it is read
3040
+ * when the question comes up rather than stamped onto an error that is a fact
3041
+ * about one instant.
3042
+ *
3043
+ * `unknown` is not one of the core\'s: the enum is `#[non_exhaustive]`, and a
3044
+ * state added upstream has no name here yet. Naming the gap beats reporting it
3045
+ * as one of its neighbours.
3046
+ */
3047
+ export type Reachability = "reachable" | "reconnecting" | "paused" | "unsupervised" | "finished" | "unknown";
3048
+
3034
3049
  export interface AllocationBucketSnapshot {
3035
3050
  allocatedBytes: number;
3036
3051
  allocations: number;
@@ -4023,8 +4038,27 @@ export class WasmWhatsAppClient {
4023
4038
  * neither constructs protocol nodes nor translates consumer-facing names.
4024
4039
  */
4025
4040
  queryUsync(query: UsyncQuery): Promise<UsyncResponse>;
4041
+ /**
4042
+ * What work handed to the client right now can expect.
4043
+ *
4044
+ * `isConnected()` and `isLoggedIn()` each answer half of it; this answers
4045
+ * the question a refused caller actually has, which is whether asking
4046
+ * again is worth it. `reconnecting` comes back on its own, `paused` comes
4047
+ * back on `resume`, `unsupervised` needs a `run()`, and `finished` needs a
4048
+ * new client.
4049
+ *
4050
+ * Read when the question comes up rather than carried on the error: a
4051
+ * refusal is a fact about one instant, and a connection can be lost right
4052
+ * after a call was admitted or restored right after one was refused.
4053
+ */
4054
+ reachability(): Reachability;
4026
4055
  /**
4027
4056
  * Mark messages as read by sending read receipts.
4057
+ *
4058
+ * Held per chat rather than once for the batch: the core stamps the
4059
+ * receipt's timestamp inside `mark_as_read`, so each one is sampled after
4060
+ * its own wait rather than at the call the host made. Only the first of
4061
+ * them can be withdrawn — after that the call has already sent something.
4028
4062
  */
4029
4063
  readMessages(keys: ReadMessageKey[]): Promise<void>;
4030
4064
  /**
@@ -4410,6 +4444,45 @@ export class WasmWhatsAppClient {
4410
4444
  * `kind === 'timeout'`.
4411
4445
  */
4412
4446
  waitForSocket(timeout_ms: number): Promise<void>;
4447
+ /**
4448
+ * Wait until the client can reach the server again, and report what ended
4449
+ * the wait.
4450
+ *
4451
+ * Never resolves to `reconnecting` — that is the one state it waits out.
4452
+ * Bounded by the client's lifetime rather than a duration, because the
4453
+ * reconnect backoff is jittered and followed by a handshake; a caller that
4454
+ * wants a deadline races this against one of its own.
4455
+ *
4456
+ * The calls that hold themselves need none of this. It is for the ones
4457
+ * that do not — `sendNode`, `queryNode`, `sendRawMessage` — where only the
4458
+ * caller knows whether the node it is holding survives a new socket.
4459
+ *
4460
+ * It is also how a caller bounds work rather than waiting. Racing a
4461
+ * parked call against a timer abandons the promise but not the call, so a
4462
+ * send still goes out when the reconnect lands; racing this instead
4463
+ * leaves the decision to issue it with the caller.
4464
+ *
4465
+ * Not from an event handler: the core dispatches on its read loop, so a
4466
+ * handler that waits here waits on the connection it is blocking.
4467
+ */
4468
+ waitUntilReachable(): Promise<Reachability>;
4469
+ /**
4470
+ * Let go of every call waiting out a reconnect right now, and return how
4471
+ * many were let go.
4472
+ *
4473
+ * A held call cannot be taken back by dropping its promise: wasm-bindgen
4474
+ * drives the method to completion either way, so racing it against a
4475
+ * deadline bounds the waiting and not the call — it still goes out when
4476
+ * the reconnect lands, and asking again sends the same thing twice. This
4477
+ * is how giving up is said instead: each released call rejects with
4478
+ * `kind: 'withdrawn'` without reaching the core, so nothing it was about
4479
+ * to do happened and re-issuing it is not a repeat.
4480
+ *
4481
+ * Releases what is waiting at the moment of the call and nothing else. It
4482
+ * is not a mode — the next call waits like any other — and it does not
4483
+ * touch the calls that never wait.
4484
+ */
4485
+ withdrawParkedCalls(): number;
4413
4486
  }
4414
4487
 
4415
4488
  /**
@@ -4624,6 +4697,7 @@ export interface InitOutput {
4624
4697
  readonly wasmwhatsappclient_profilePictureUrl: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
4625
4698
  readonly wasmwhatsappclient_queryNode: (a: number, b: number, c: number, d: number) => number;
4626
4699
  readonly wasmwhatsappclient_queryUsync: (a: number, b: number) => number;
4700
+ readonly wasmwhatsappclient_reachability: (a: number) => number;
4627
4701
  readonly wasmwhatsappclient_readMessages: (a: number, b: number) => number;
4628
4702
  readonly wasmwhatsappclient_reconnect: (a: number) => number;
4629
4703
  readonly wasmwhatsappclient_refreshPreKeys: (a: number, b: number) => number;
@@ -4693,6 +4767,8 @@ export interface InitOutput {
4693
4767
  readonly wasmwhatsappclient_votePoll: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => number;
4694
4768
  readonly wasmwhatsappclient_waitForConnected: (a: number, b: number) => number;
4695
4769
  readonly wasmwhatsappclient_waitForSocket: (a: number, b: number) => number;
4770
+ readonly wasmwhatsappclient_waitUntilReachable: (a: number) => number;
4771
+ readonly wasmwhatsappclient_withdrawParkedCalls: (a: number) => number;
4696
4772
  readonly getWasmMemoryBytes: () => number;
4697
4773
  readonly __wbg_intounderlyingbytesource_free: (a: number, b: number) => void;
4698
4774
  readonly __wbg_intounderlyingsink_free: (a: number, b: number) => void;
@@ -4707,12 +4783,12 @@ export interface InitOutput {
4707
4783
  readonly intounderlyingsink_write: (a: number, b: number) => number;
4708
4784
  readonly intounderlyingsource_cancel: (a: number) => void;
4709
4785
  readonly intounderlyingsource_pull: (a: number, b: number) => number;
4710
- readonly __wasm_bindgen_func_elem_4358: (a: number, b: number, c: number) => void;
4711
- readonly __wasm_bindgen_func_elem_26619: (a: number, b: number, c: number, d: number) => void;
4712
- readonly __wasm_bindgen_func_elem_26621: (a: number, b: number, c: number, d: number) => void;
4713
- readonly __wasm_bindgen_func_elem_9303: (a: number, b: number, c: number) => void;
4714
- readonly __wasm_bindgen_func_elem_4357: (a: number, b: number, c: number) => void;
4715
- readonly __wasm_bindgen_func_elem_4356: (a: number, b: number) => void;
4786
+ readonly __wasm_bindgen_func_elem_4419: (a: number, b: number, c: number) => void;
4787
+ readonly __wasm_bindgen_func_elem_26634: (a: number, b: number, c: number, d: number) => void;
4788
+ readonly __wasm_bindgen_func_elem_26636: (a: number, b: number, c: number, d: number) => void;
4789
+ readonly __wasm_bindgen_func_elem_9404: (a: number, b: number, c: number) => void;
4790
+ readonly __wasm_bindgen_func_elem_4418: (a: number, b: number, c: number) => void;
4791
+ readonly __wasm_bindgen_func_elem_4417: (a: number, b: number) => void;
4716
4792
  readonly __wbindgen_export: (a: number, b: number) => number;
4717
4793
  readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
4718
4794
  readonly __wbindgen_export3: (a: number) => void;
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxidezap/whatsapp-rust-bridge",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "description": "A high-performance utilities for WhatsApp, powered by Rust and WebAssembly.",
5
5
  "author": "João Lucas <jlucaso@hotmail.com>",
6
6
  "license": "MIT",