@oxidezap/whatsapp-rust-bridge 0.22.1 → 0.23.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.
@@ -1,5 +1,4 @@
1
1
  import { BinaryReader as BaseBinaryReader, BinaryWriter as BaseBinaryWriter } from "@bufbuild/protobuf/wire";
2
- import { Buffer } from "node:buffer";
3
2
  /** Index of the first UTF-16 code unit with no partner, or -1 when well-formed. */
4
3
  export declare function unpairedSurrogateIndex(value: string): number;
5
4
  /**
@@ -66,15 +65,8 @@ export declare class BinaryWriter extends BaseBinaryWriter {
66
65
  fixed64(value: NumericInput): this;
67
66
  sfixed64(value: NumericInput): this;
68
67
  }
69
- /**
70
- * BinaryReader specialized for ts-proto's 64-bit output contract. Buf's own
71
- * 64-bit methods materialize a BigInt and then a decimal string; the `*Value()`
72
- * methods below avoid both intermediates, while the inherited methods retain
73
- * Buf's public BigInt/string behavior for direct users.
74
- */
75
68
  export declare class BinaryReader extends BaseBinaryReader {
76
- protected readonly utf8Buffer: Buffer;
77
- private readonly wireBytes;
69
+ protected readonly wireBytes: Uint8Array;
78
70
  constructor(buf: Uint8Array);
79
71
  protected checkBounds(): void;
80
72
  private readVarintWords;
@@ -1 +1 @@
1
- export { proto } from "./index.js";
1
+ export { proto } from "./host.js";
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The one JS surface every entrypoint publishes.
3
+ *
4
+ * `ts/index.ts` (default: finds and loads the wasm itself) and `ts/host.ts`
5
+ * (host-supplied wasm bytes) both re-export this module, so the API exists in
6
+ * exactly one source. A method added here reaches both entrypoints; a typo in
7
+ * one entrypoint cannot drift the other's client signature.
8
+ */
9
+ export * from "./whatsapp_rust_bridge.js";
10
+ export { encodeProto, decodeProto, decodeProtoBatch, UnpairedSurrogateError, type ProtoDecodeReport, } from "./proto.js";
11
+ export { BinaryReader, InvalidUtf8CountingReader, longToBigInt, type Int64, type Long, } from "./proto-reader.js";
12
+ export { decodeEventWireEnvelope, decodeMessageWireBatch, decodeReceiptWireBatch, decodeServerAckWireBatch, encodeEventWireEnvelope, encodeMessageWireBatch, encodeReceiptWireBatch, encodeServerAckWireBatch, EVENT_SEGMENT_KIND_MESSAGE, EVENT_SEGMENT_KIND_RECEIPT, EVENT_SEGMENT_KIND_SERVER_ACK, MESSAGE_WIRE_INFO_RECORD_WIDTH, type EventWireSegment, type MessageWireBatchView, type MessageWireEntry, type MessageWireInfo, type PackedWireBatch, type ReceiptWireData, type ServerAckWireData, type WireJid, } from "./wire-info.js";
13
+ export { proto } from "./proto-namespace.js";
14
+ import type { WhatsAppEventHandler, JsTransportCallbacks, JsHttpClientConfig, JsStoreCallbacks, CacheConfig, ClientPolicies } from "./whatsapp_rust_bridge.js";
15
+ import type { WasmWhatsAppClient } from "./whatsapp_rust_bridge.js";
16
+ export declare const initWasmEngine: (logger?: any, crypto?: any) => void;
17
+ export declare const createWhatsAppClient: (transport: JsTransportCallbacks, httpClient: JsHttpClientConfig, onEvent?: WhatsAppEventHandler | null, store?: JsStoreCallbacks | null, cache?: CacheConfig | null, version?: readonly [number, number, number] | null, wantedPreKeyCount?: number | null, dangerSkipCertChainVerify?: boolean | null, policies?: ClientPolicies | null) => Promise<WasmWhatsAppClient>;
package/dist/wasm.d.ts ADDED
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Type declaration for the `./wasm` export subpath
3
+ * (`dist/whatsapp_rust_bridge_bg.wasm`).
4
+ *
5
+ * A `.wasm` binary has no per-host type story — workerd delivers a compiled
6
+ * `WebAssembly.Module`, other hosts deliver bytes — so this declares the one
7
+ * thing every host's value has in common: it is exactly wasm-bindgen's
8
+ * `SyncInitInput`, the input `initSync` from
9
+ * `@oxidezap/whatsapp-rust-bridge/host` already takes. No platform is named
10
+ * in the contract:
11
+ *
12
+ * ```ts
13
+ * import wasm from "@oxidezap/whatsapp-rust-bridge/wasm";
14
+ * import { initSync } from "@oxidezap/whatsapp-rust-bridge/host";
15
+ * initSync({ module: wasm });
16
+ * ```
17
+ *
18
+ * Hand-written rather than emitted: tsc's emitDeclarationOnly pass does not
19
+ * copy a lone `.d.ts` source, and the content is one declaration.
20
+ */
21
+
22
+ import type { SyncInitInput } from "./whatsapp_rust_bridge.js";
23
+
24
+ declare const wasm: SyncInitInput;
25
+
26
+ export default wasm;
@@ -5005,12 +5005,12 @@ export interface InitOutput {
5005
5005
  readonly intounderlyingsink_write: (a: number, b: number) => number;
5006
5006
  readonly intounderlyingsource_cancel: (a: number) => void;
5007
5007
  readonly intounderlyingsource_pull: (a: number, b: number) => number;
5008
+ readonly __wasm_bindgen_func_elem_4671: (a: number, b: number, c: number) => void;
5009
+ readonly __wasm_bindgen_func_elem_28645: (a: number, b: number, c: number, d: number) => void;
5010
+ readonly __wasm_bindgen_func_elem_28647: (a: number, b: number, c: number, d: number) => void;
5011
+ readonly __wasm_bindgen_func_elem_9915: (a: number, b: number, c: number) => void;
5008
5012
  readonly __wasm_bindgen_func_elem_4670: (a: number, b: number, c: number) => void;
5009
- readonly __wasm_bindgen_func_elem_28628: (a: number, b: number, c: number, d: number) => void;
5010
- readonly __wasm_bindgen_func_elem_28630: (a: number, b: number, c: number, d: number) => void;
5011
- readonly __wasm_bindgen_func_elem_9914: (a: number, b: number, c: number) => void;
5012
- readonly __wasm_bindgen_func_elem_4669: (a: number, b: number, c: number) => void;
5013
- readonly __wasm_bindgen_func_elem_4668: (a: number, b: number) => void;
5013
+ readonly __wasm_bindgen_func_elem_4669: (a: number, b: number) => void;
5014
5014
  readonly __wbindgen_export: (a: number, b: number) => number;
5015
5015
  readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
5016
5016
  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.22.1",
3
+ "version": "0.23.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",
@@ -22,6 +22,14 @@
22
22
  "import": "./dist/index.js",
23
23
  "types": "./dist/index.d.ts"
24
24
  },
25
+ "./host": {
26
+ "import": "./dist/host.js",
27
+ "types": "./dist/host.d.ts"
28
+ },
29
+ "./wasm": {
30
+ "types": "./dist/wasm.d.ts",
31
+ "default": "./dist/whatsapp_rust_bridge_bg.wasm"
32
+ },
25
33
  "./proto-types": {
26
34
  "import": "./dist/proto-types.js",
27
35
  "types": "./dist/proto-types.d.ts"
@@ -43,7 +51,7 @@
43
51
  "gen": "bun run gen:proto-codec && bun run gen:proto-types && bun run gen:bridge-types",
44
52
  "build:wasm": "wasm-pack build --target web --out-dir pkg --no-pack",
45
53
  "build:wasm:dev": "wasm-pack build --target web --out-dir pkg --no-pack --dev",
46
- "build:ts": "bun build ts/index.ts --minify --outfile dist/index.js --target node && cp pkg/whatsapp_rust_bridge_bg.wasm dist/ && cp ts/proto-types.d.ts dist/proto-types.d.ts && cp ts/proto-types.d.ts pkg/proto-types.d.ts && printf 'export { proto } from \"./index.js\";\\n' > dist/proto-types.js",
54
+ "build:ts": "bun run scripts/build-shared-entrypoints.ts && cp pkg/whatsapp_rust_bridge_bg.wasm dist/ && cp ts/wasm.d.ts dist/wasm.d.ts && cp ts/proto-types.d.ts dist/proto-types.d.ts && cp ts/proto-types.d.ts pkg/proto-types.d.ts && printf 'export { proto } from \"./host.js\";\\n' > dist/proto-types.js",
47
55
  "build:finalize": "tsc -p tsconfig.json --outDir dist && rm -f dist/macro.d.ts && rm -rf dist/generated && bun run scripts/finalize-dist.ts",
48
56
  "build": "bun run gen && bun run build:wasm && bun run build:ts && bun run build:finalize",
49
57
  "build:dev": "bun run gen && bun run build:wasm:dev && bun run build:ts && bun run build:finalize",