@oxidezap/whatsapp-rust-bridge 0.6.4 → 0.6.5
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/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/whatsapp_rust_bridge.d.ts +54 -8
- package/dist/whatsapp_rust_bridge_bg.wasm +0 -0
- package/dist/wire-info.d.ts +18 -0
- package/package.json +1 -1
|
@@ -1557,20 +1557,66 @@ export interface WhatsAppEventCallbacks {
|
|
|
1557
1557
|
* with `decodeServerAckWireBatch`. Without it, acks use `onEvent`.
|
|
1558
1558
|
*/
|
|
1559
1559
|
onServerAckBatch?(batch: ServerAckWireBatch): void;
|
|
1560
|
+
/**
|
|
1561
|
+
* Borrowing form of `onReceiptBatch`, and the whole of the opt-in: declaring
|
|
1562
|
+
* it replaces `onReceiptBatch` as the receipt sink and lets the bridge hand
|
|
1563
|
+
* every batch out of one buffer it reuses.
|
|
1564
|
+
*
|
|
1565
|
+
* The batch is therefore a window on shared memory, valid ONLY for the
|
|
1566
|
+
* synchronous duration of the call: implementations MUST decode or copy it
|
|
1567
|
+
* before returning, and MUST NOT retain it, pass it to an async consumer, or
|
|
1568
|
+
* return a Promise. `decodeReceiptWireBatch` satisfies that on its own, since
|
|
1569
|
+
* it materializes every field and keeps no view over the buffer, so the usual
|
|
1570
|
+
* body is a decode plus whatever the host does with the result. A callback
|
|
1571
|
+
* caught handing back something promise-like, or letting an exception escape,
|
|
1572
|
+
* drops every borrowing callback of every packed kind back to a buffer per
|
|
1573
|
+
* batch for the rest of the session, before the buffer is reused, so the
|
|
1574
|
+
* window it kept stays intact.
|
|
1575
|
+
*
|
|
1576
|
+
* `onReceiptBatch` remains the copying path for every host that does not opt
|
|
1577
|
+
* in, and a batch too large for the shared buffer gets its own regardless.
|
|
1578
|
+
* There is no borrowing form of `onMessageBatch`: `decodeMessageWireBatch`
|
|
1579
|
+
* returns views over the batch, so reuse there would alias the decoded result
|
|
1580
|
+
* and not just the buffer.
|
|
1581
|
+
*/
|
|
1582
|
+
onReceiptBatchBorrowed?(batch: ReceiptWireBatch): void;
|
|
1583
|
+
/** Borrowing form of `onServerAckBatch`, under the contract above. */
|
|
1584
|
+
onServerAckBatchBorrowed?(batch: ServerAckWireBatch): void;
|
|
1585
|
+
/**
|
|
1586
|
+
* Optional coalescing path. A live message produces up to three batches (its
|
|
1587
|
+
* own, its receipt, its ack); with this method the ones the dispatch loop
|
|
1588
|
+
* already holds cross together as one envelope of tagged segments instead of
|
|
1589
|
+
* one crossing each. Split it with `decodeEventWireEnvelope` and hand each
|
|
1590
|
+
* segment to the codec its kind names, in order. Nothing is ever held back
|
|
1591
|
+
* waiting for a companion event, so a batch with no company still arrives
|
|
1592
|
+
* through its own callback above, in the buffer that callback negotiated.
|
|
1593
|
+
*
|
|
1594
|
+
* There is no borrowing form, for the reason `onMessageBatch` has none: an
|
|
1595
|
+
* envelope may carry a message segment, whose decode returns views over the
|
|
1596
|
+
* buffer.
|
|
1597
|
+
*/
|
|
1598
|
+
onEventBatch?(batch: EventWireEnvelope): void;
|
|
1560
1599
|
}
|
|
1561
1600
|
|
|
1562
1601
|
/**
|
|
1563
1602
|
* A packed batch is one flat buffer: header, records and string bytes. Decode it
|
|
1564
1603
|
* with the matching codec (`decodeMessageWireBatch`, `decodeReceiptWireBatch`,
|
|
1565
1604
|
* `decodeServerAckWireBatch`), which reads views over the buffer instead of
|
|
1566
|
-
* copying. The bare typed array crosses rather than a wrapper object:
|
|
1567
|
-
*
|
|
1605
|
+
* copying. The bare typed array crosses rather than a wrapper object: a message
|
|
1606
|
+
* produces up to three batches, so an object per batch is three constructions
|
|
1568
1607
|
* and three property writes of pure overhead.
|
|
1569
1608
|
*/
|
|
1570
1609
|
export type MessageWireBatch = Uint8Array;
|
|
1571
1610
|
export type ReceiptWireBatch = Uint8Array;
|
|
1572
1611
|
export type ServerAckWireBatch = Uint8Array;
|
|
1573
1612
|
|
|
1613
|
+
/**
|
|
1614
|
+
* Several packed batches in one buffer, each tagged with the kind that names
|
|
1615
|
+
* its codec. Split it with `decodeEventWireEnvelope`; every segment is byte for
|
|
1616
|
+
* byte the batch its own callback would have received.
|
|
1617
|
+
*/
|
|
1618
|
+
export type EventWireEnvelope = Uint8Array;
|
|
1619
|
+
|
|
1574
1620
|
export type HistorySyncWireBatch = {
|
|
1575
1621
|
/** Concatenated Conversation protobuf payloads for this bounded batch. */
|
|
1576
1622
|
conversationData: Uint8Array;
|
|
@@ -3767,12 +3813,12 @@ export interface InitOutput {
|
|
|
3767
3813
|
readonly intounderlyingsink_write: (a: number, b: number) => number;
|
|
3768
3814
|
readonly intounderlyingsource_cancel: (a: number) => void;
|
|
3769
3815
|
readonly intounderlyingsource_pull: (a: number, b: number) => number;
|
|
3770
|
-
readonly
|
|
3771
|
-
readonly
|
|
3772
|
-
readonly
|
|
3773
|
-
readonly
|
|
3774
|
-
readonly
|
|
3775
|
-
readonly
|
|
3816
|
+
readonly __wasm_bindgen_func_elem_3812: (a: number, b: number, c: number) => void;
|
|
3817
|
+
readonly __wasm_bindgen_func_elem_24668: (a: number, b: number, c: number, d: number) => void;
|
|
3818
|
+
readonly __wasm_bindgen_func_elem_24670: (a: number, b: number, c: number, d: number) => void;
|
|
3819
|
+
readonly __wasm_bindgen_func_elem_8238: (a: number, b: number, c: number) => void;
|
|
3820
|
+
readonly __wasm_bindgen_func_elem_3811: (a: number, b: number, c: number) => void;
|
|
3821
|
+
readonly __wasm_bindgen_func_elem_3810: (a: number, b: number) => void;
|
|
3776
3822
|
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
3777
3823
|
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
3778
3824
|
readonly __wbindgen_export3: (a: number) => void;
|
|
Binary file
|
package/dist/wire-info.d.ts
CHANGED
|
@@ -105,3 +105,21 @@ export declare function decodeServerAckWireBatch(batch: PackedWireBatch): Server
|
|
|
105
105
|
export declare function encodeReceiptWireBatch(receipts: readonly ReceiptWireData[]): PackedWireBatch;
|
|
106
106
|
/** Inverse of `decodeServerAckWireBatch`, for tests and replay tooling. */
|
|
107
107
|
export declare function encodeServerAckWireBatch(acks: readonly ServerAckWireData[]): PackedWireBatch;
|
|
108
|
+
/** Segment tags, mirroring the Rust writer in `src/wire_batch.rs`. */
|
|
109
|
+
export declare const EVENT_SEGMENT_KIND_MESSAGE = 1;
|
|
110
|
+
export declare const EVENT_SEGMENT_KIND_RECEIPT = 2;
|
|
111
|
+
export declare const EVENT_SEGMENT_KIND_SERVER_ACK = 3;
|
|
112
|
+
/** One packed batch inside an envelope. */
|
|
113
|
+
export interface EventWireSegment {
|
|
114
|
+
/** One of the `EVENT_SEGMENT_KIND_*` tags; names the codec for `batch`. */
|
|
115
|
+
kind: number;
|
|
116
|
+
/** Exactly the bytes the segment's own callback would have received. */
|
|
117
|
+
batch: PackedWireBatch;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Split an envelope into its segments, in the order the events arrived. Decode
|
|
121
|
+
* each with the codec its kind names and deliver them in that order.
|
|
122
|
+
*/
|
|
123
|
+
export declare function decodeEventWireEnvelope(envelope: Uint8Array): EventWireSegment[];
|
|
124
|
+
/** Inverse of `decodeEventWireEnvelope`, for tests and replay tooling. */
|
|
125
|
+
export declare function encodeEventWireEnvelope(segments: readonly EventWireSegment[]): Uint8Array;
|
package/package.json
CHANGED