@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.
- package/README.md +27 -0
- package/dist/bridge.js +3 -0
- package/dist/host.d.ts +41 -0
- package/dist/host.js +1 -0
- package/dist/index.d.ts +1 -9
- package/dist/index.js +1 -2
- package/dist/proto-reader.d.ts +1 -9
- package/dist/proto-types.js +1 -1
- package/dist/surface.d.ts +17 -0
- package/dist/wasm.d.ts +26 -0
- package/dist/whatsapp_rust_bridge.d.ts +5 -5
- package/dist/whatsapp_rust_bridge_bg.wasm +0 -0
- package/package.json +10 -2
package/README.md
CHANGED
|
@@ -47,3 +47,30 @@ What it is not is a release. Preview builds carry the version
|
|
|
47
47
|
`0.0.0-preview-<sha>`, which no range written for a real release can match — an
|
|
48
48
|
install is a deliberate pin, and it stays on that commit until you change it.
|
|
49
49
|
They are for trying a change, not for running one.
|
|
50
|
+
|
|
51
|
+
## Host-loaded runtimes
|
|
52
|
+
|
|
53
|
+
On Node and Bun the default entrypoint finds and loads the wasm itself:
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import { createWhatsAppClient } from "@oxidezap/whatsapp-rust-bridge";
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Hosts without filesystem access (Cloudflare Workers, workerd, Deno,
|
|
60
|
+
browsers) supply the wasm instead. Import the asset through the `./wasm`
|
|
61
|
+
subpath — a static import, which workerd/wrangler compile to a
|
|
62
|
+
`WebAssembly.Module` — and pass it to `initSync` from `./host`:
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
import wasm from "@oxidezap/whatsapp-rust-bridge/wasm";
|
|
66
|
+
import {
|
|
67
|
+
initSync,
|
|
68
|
+
createWhatsAppClient,
|
|
69
|
+
} from "@oxidezap/whatsapp-rust-bridge/host";
|
|
70
|
+
|
|
71
|
+
initSync({ module: wasm });
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Call `initSync` once per isolate, and on workerd create clients inside a
|
|
75
|
+
request handler rather than at global scope (`crypto.getRandomValues` is
|
|
76
|
+
unavailable during global-scope evaluation).
|