@oxidezap/whatsapp-rust-bridge 0.6.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 +17 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +2 -0
- package/dist/proto-namespace.d.ts +34 -0
- package/dist/proto-reader.d.ts +20 -0
- package/dist/proto-types.d.ts +16917 -0
- package/dist/proto-types.js +1 -0
- package/dist/proto.d.ts +8 -0
- package/dist/whatsapp_rust_bridge.d.ts +3804 -0
- package/dist/whatsapp_rust_bridge_bg.wasm +0 -0
- package/dist/wire-info.d.ts +107 -0
- package/package.json +59 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-assembled `proto` namespace, protobufjs-API-compatible.
|
|
3
|
+
*
|
|
4
|
+
* Walks values exported by `./generated/whatsapp` (the ts-proto output), maps
|
|
5
|
+
* the flat `Parent_Child_GrandChild` naming into a nested namespace, and wraps
|
|
6
|
+
* each `MessageFns` into the `{ encode, decode,
|
|
7
|
+
* fromObject, create, toObject }` surface that protobufjs-style consumers
|
|
8
|
+
* expect from `WAProto.X.encode(obj).finish()` and friends.
|
|
9
|
+
*
|
|
10
|
+
* Why: there used to be a hand-maintained shim covering ~90 of the 1,352
|
|
11
|
+
* generated types. Bots that touched anything outside the manual list
|
|
12
|
+
* type-checked against `WAProto/index.d.ts` but crashed at runtime. Generating
|
|
13
|
+
* the runtime here from the same ts-proto output the bridge already builds
|
|
14
|
+
* eliminates that drift entirely.
|
|
15
|
+
*
|
|
16
|
+
* Conventions matched:
|
|
17
|
+
* - `encode(obj).finish()` returns `Uint8Array` (ts-proto's `BinaryWriter`
|
|
18
|
+
* already exposes `.finish()`, so we reuse it directly).
|
|
19
|
+
* - `decode(bytes)` returns the typed object with a no-op `toJSON` so
|
|
20
|
+
* `JSON.stringify` round-trips cleanly without protobufjs's bytes→base64
|
|
21
|
+
* conversion (matches baileyrs' previous shim behavior).
|
|
22
|
+
* - `fromObject(obj)` / `create(obj)` accept partial input and return the same
|
|
23
|
+
* shape (no normalization — ts-proto's runtime accepts plain objects).
|
|
24
|
+
* - Enums are flattened into the namespace as plain `{ NAME: value }` objects.
|
|
25
|
+
* - Each top-level message is wrapped in a `Proxy` so unknown capitalized
|
|
26
|
+
* sub-properties (`proto.Message.SomeUnreleasedThing.fromObject({...})`)
|
|
27
|
+
* synthesize a passthrough at access time, preventing TypeError on bot code
|
|
28
|
+
* that compiled against an updated `.d.ts` but runs against an older runtime.
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* Protobufjs-shaped namespace covering every type the bridge knows about.
|
|
32
|
+
* Stable surface; safe to import as `proto`.
|
|
33
|
+
*/
|
|
34
|
+
export declare const proto: Record<string, any>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BinaryReader as BaseBinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
2
|
+
export { BinaryWriter };
|
|
3
|
+
/** BinaryReader specialized for ts-proto's safe-number output contract. */
|
|
4
|
+
export declare class BinaryReader extends BaseBinaryReader {
|
|
5
|
+
private readonly utf8Buffer;
|
|
6
|
+
constructor(buf: Uint8Array);
|
|
7
|
+
string(strict?: boolean): string;
|
|
8
|
+
bool(): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Decode the overwhelmingly common positive/safe varint without allocating
|
|
11
|
+
* Buf's `[low, high]` tuple. Returning `undefined` rewinds for the full signed
|
|
12
|
+
* two-word path (negative int64 values always use ten wire bytes).
|
|
13
|
+
*/
|
|
14
|
+
private positiveSafeVarint;
|
|
15
|
+
uint64Number(): number;
|
|
16
|
+
int64Number(): number;
|
|
17
|
+
sint64Number(): number;
|
|
18
|
+
fixed64Number(): number;
|
|
19
|
+
sfixed64Number(): number;
|
|
20
|
+
}
|