@oxidezap/whatsapp-rust-bridge 0.7.2 → 0.8.1
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 +2 -2
- package/dist/index.js +2 -2
- package/dist/proto-reader.d.ts +98 -10
- package/dist/proto-types.d.ts +428 -425
- package/dist/proto.d.ts +25 -2
- package/package.json +2 -1
package/dist/proto-reader.d.ts
CHANGED
|
@@ -1,20 +1,108 @@
|
|
|
1
|
-
import { BinaryReader as BaseBinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
2
|
-
|
|
3
|
-
/**
|
|
1
|
+
import { BinaryReader as BaseBinaryReader, BinaryWriter as BaseBinaryWriter } from "@bufbuild/protobuf/wire";
|
|
2
|
+
import { Buffer } from "node:buffer";
|
|
3
|
+
/** Index of the first UTF-16 code unit with no partner, or -1 when well-formed. */
|
|
4
|
+
export declare function unpairedSurrogateIndex(value: string): number;
|
|
5
|
+
/**
|
|
6
|
+
* A `string` field is UTF-8 on the wire and an unpaired UTF-16 surrogate has no
|
|
7
|
+
* UTF-8 form, so there is nothing faithful to write. `path` is filled in by
|
|
8
|
+
* `encodeProto`, which is the only layer that knows the field names.
|
|
9
|
+
*/
|
|
10
|
+
export declare class UnpairedSurrogateError extends RangeError {
|
|
11
|
+
readonly index: number;
|
|
12
|
+
readonly codeUnit: number;
|
|
13
|
+
readonly path?: string | undefined;
|
|
14
|
+
constructor(index: number, codeUnit: number, path?: string | undefined);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* protobufjs-style 64-bit value, `high * 2^32 + low`, with `low` unsigned and
|
|
18
|
+
* `high` the signed 32-bit field protobufjs uses. Same shape `camel_serializer.rs`
|
|
19
|
+
* emits on the event path, and `JSON.stringify`-safe where a BigInt is not.
|
|
20
|
+
*/
|
|
21
|
+
export interface Long {
|
|
22
|
+
low: number;
|
|
23
|
+
high: number;
|
|
24
|
+
unsigned: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* What a 64-bit field crosses as: a plain `number` while the value is exact as
|
|
28
|
+
* a double, a `Long` beyond that. Rejecting the wide value instead — which is
|
|
29
|
+
* what ts-proto's generated `longToNumber()` does — fails the whole message
|
|
30
|
+
* over one field, and truncating it to a double would lose the value silently.
|
|
31
|
+
*/
|
|
32
|
+
export type Int64 = number | Long;
|
|
33
|
+
/** Everything a numeric field accepts. `Int64` is the decode-side subset. */
|
|
34
|
+
export type NumericInput = number | bigint | string | Long;
|
|
35
|
+
export declare const longToBigInt: (value: Long) => bigint;
|
|
36
|
+
/**
|
|
37
|
+
* `unsigned` (a boolean) is the discriminant: it short-circuits virtually every
|
|
38
|
+
* non-Long object in one comparison, and matches the guard in
|
|
39
|
+
* `camel_serializer.rs`. A plain `{ low, high }` data object is NOT a Long, and
|
|
40
|
+
* neither is one whose words are not words — `longToBigInt` would truncate
|
|
41
|
+
* `low: 1.5` to `1` and write a value nobody sent.
|
|
42
|
+
*/
|
|
43
|
+
export declare const isLong: (value: unknown) => value is Long;
|
|
44
|
+
/**
|
|
45
|
+
* BinaryWriter that accepts back what the reader below produces — Buf's own
|
|
46
|
+
* 64-bit setters take `number | bigint | string`, so a decoded `Long` would
|
|
47
|
+
* reach `BigInt(object)` and throw — and that holds every numeric field to the
|
|
48
|
+
* input contract above.
|
|
49
|
+
*
|
|
50
|
+
* It also refuses an unpaired surrogate rather than letting `TextEncoder`
|
|
51
|
+
* substitute U+FFFD for it, which would send the server text the caller never
|
|
52
|
+
* wrote. The value came from the caller, so the caller is the one who can fix it.
|
|
53
|
+
*/
|
|
54
|
+
export declare class BinaryWriter extends BaseBinaryWriter {
|
|
55
|
+
string(value: string): this;
|
|
56
|
+
uint32(value: NumericInput): this;
|
|
57
|
+
int32(value: NumericInput): this;
|
|
58
|
+
sint32(value: NumericInput): this;
|
|
59
|
+
fixed32(value: NumericInput): this;
|
|
60
|
+
sfixed32(value: NumericInput): this;
|
|
61
|
+
float(value: NumericInput): this;
|
|
62
|
+
double(value: NumericInput): this;
|
|
63
|
+
int64(value: NumericInput): this;
|
|
64
|
+
uint64(value: NumericInput): this;
|
|
65
|
+
sint64(value: NumericInput): this;
|
|
66
|
+
fixed64(value: NumericInput): this;
|
|
67
|
+
sfixed64(value: NumericInput): this;
|
|
68
|
+
}
|
|
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
|
+
*/
|
|
4
75
|
export declare class BinaryReader extends BaseBinaryReader {
|
|
5
|
-
|
|
76
|
+
protected readonly utf8Buffer: Buffer;
|
|
6
77
|
constructor(buf: Uint8Array);
|
|
78
|
+
/**
|
|
79
|
+
* Bytes come from a peer this side does not control, so a malformed one
|
|
80
|
+
* substitutes U+FFFD rather than costing the whole message. `strict` reaches
|
|
81
|
+
* Buf's throwing decoder; the generated codecs never pass it.
|
|
82
|
+
*/
|
|
7
83
|
string(strict?: boolean): string;
|
|
8
84
|
bool(): boolean;
|
|
9
85
|
/**
|
|
10
86
|
* Decode the overwhelmingly common positive/safe varint without allocating
|
|
11
87
|
* Buf's `[low, high]` tuple. Returning `undefined` rewinds for the full signed
|
|
12
|
-
* two-word path (negative int64 values always use ten wire bytes
|
|
88
|
+
* two-word path (negative int64 values always use ten wire bytes, and eight
|
|
89
|
+
* data bytes can carry more than a double holds exactly).
|
|
13
90
|
*/
|
|
14
91
|
private positiveSafeVarint;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
92
|
+
uint64Value(): Int64;
|
|
93
|
+
int64Value(): Int64;
|
|
94
|
+
sint64Value(): Int64;
|
|
95
|
+
fixed64Value(): Int64;
|
|
96
|
+
sfixed64Value(): Int64;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Counts the substitutions `BinaryReader` makes silently. It is a separate
|
|
100
|
+
* class so the ordinary decode path carries neither the flag nor the branch:
|
|
101
|
+
* a consumer who never asks for the count pays nothing for it existing.
|
|
102
|
+
*/
|
|
103
|
+
export declare class InvalidUtf8CountingReader extends BinaryReader {
|
|
104
|
+
invalidUtf8Fields: number;
|
|
105
|
+
string(strict?: boolean): string;
|
|
106
|
+
/** A U+FFFD the peer actually sent re-encodes to the bytes it arrived as; a substituted one does not. */
|
|
107
|
+
private decodedExactly;
|
|
20
108
|
}
|