@bufbuild/protobuf 0.0.1-alpha.1 → 0.0.2-alpha.2

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.
Files changed (138) hide show
  1. package/dist/cjs/binary-encoding.js +414 -409
  2. package/dist/cjs/binary-format.js +13 -0
  3. package/dist/cjs/descriptor-registry.js +420 -449
  4. package/dist/cjs/descriptor-set.js +429 -513
  5. package/dist/cjs/enum.js +13 -0
  6. package/dist/cjs/field-list.js +13 -0
  7. package/dist/cjs/field.js +43 -30
  8. package/dist/cjs/google/protobuf/any_pb.js +122 -140
  9. package/dist/cjs/google/protobuf/api_pb.js +177 -224
  10. package/dist/cjs/google/protobuf/compiler/plugin_pb.js +125 -227
  11. package/dist/cjs/google/protobuf/descriptor_pb.js +1029 -1888
  12. package/dist/cjs/google/protobuf/duration_pb.js +72 -88
  13. package/dist/cjs/google/protobuf/empty_pb.js +17 -17
  14. package/dist/cjs/google/protobuf/field_mask_pb.js +77 -94
  15. package/dist/cjs/google/protobuf/source_context_pb.js +25 -25
  16. package/dist/cjs/google/protobuf/struct_pb.js +144 -181
  17. package/dist/cjs/google/protobuf/timestamp_pb.js +86 -123
  18. package/dist/cjs/google/protobuf/type_pb.js +406 -462
  19. package/dist/cjs/google/protobuf/wrappers_pb.js +407 -470
  20. package/dist/cjs/google/varint.js +166 -171
  21. package/dist/cjs/index.js +41 -122
  22. package/dist/cjs/json-format.js +13 -0
  23. package/dist/cjs/message-type.js +13 -0
  24. package/dist/cjs/message.js +89 -85
  25. package/dist/cjs/private/assert.js +33 -26
  26. package/dist/cjs/private/base64.js +93 -79
  27. package/dist/cjs/private/binary-format-common.js +208 -208
  28. package/dist/cjs/private/binary-format-proto2.js +88 -109
  29. package/dist/cjs/private/binary-format-proto3.js +70 -90
  30. package/dist/cjs/private/enum.js +77 -44
  31. package/dist/cjs/private/field-list.js +64 -50
  32. package/dist/cjs/private/field-wrapper.js +21 -10
  33. package/dist/cjs/private/field.js +35 -25
  34. package/dist/cjs/private/json-format-common.js +427 -440
  35. package/dist/cjs/private/json-format-proto2.js +91 -89
  36. package/dist/cjs/private/json-format-proto3.js +82 -93
  37. package/dist/cjs/private/message-type.js +39 -27
  38. package/dist/cjs/private/names.js +71 -62
  39. package/dist/cjs/private/options-map.js +13 -0
  40. package/dist/cjs/private/proto-runtime.js +25 -16
  41. package/dist/cjs/private/scalars.js +113 -103
  42. package/dist/cjs/private/util-common.js +193 -210
  43. package/dist/cjs/private/util.js +13 -0
  44. package/dist/cjs/proto-int64.js +123 -111
  45. package/dist/cjs/proto2.js +63 -63
  46. package/dist/cjs/proto3.js +74 -74
  47. package/dist/cjs/service-type.js +27 -17
  48. package/dist/cjs/type-registry.js +46 -31
  49. package/dist/esm/binary-encoding.js +414 -414
  50. package/dist/esm/binary-format.js +13 -0
  51. package/dist/esm/descriptor-registry.js +422 -458
  52. package/dist/esm/descriptor-set.js +430 -478
  53. package/dist/esm/enum.js +13 -0
  54. package/dist/esm/field-list.js +13 -0
  55. package/dist/esm/field.js +42 -29
  56. package/dist/esm/google/protobuf/any_pb.js +122 -140
  57. package/dist/esm/google/protobuf/api_pb.js +177 -197
  58. package/dist/esm/google/protobuf/compiler/plugin_pb.js +123 -216
  59. package/dist/esm/google/protobuf/descriptor_pb.js +1013 -1804
  60. package/dist/esm/google/protobuf/duration_pb.js +72 -88
  61. package/dist/esm/google/protobuf/empty_pb.js +17 -17
  62. package/dist/esm/google/protobuf/field_mask_pb.js +77 -94
  63. package/dist/esm/google/protobuf/source_context_pb.js +25 -25
  64. package/dist/esm/google/protobuf/struct_pb.js +143 -180
  65. package/dist/esm/google/protobuf/timestamp_pb.js +86 -123
  66. package/dist/esm/google/protobuf/type_pb.js +401 -421
  67. package/dist/esm/google/protobuf/wrappers_pb.js +406 -397
  68. package/dist/esm/google/varint.js +165 -164
  69. package/dist/esm/index.js +14 -1
  70. package/dist/esm/json-format.js +13 -0
  71. package/dist/esm/message-type.js +13 -0
  72. package/dist/esm/message.js +89 -85
  73. package/dist/esm/private/assert.js +32 -21
  74. package/dist/esm/private/base64.js +92 -78
  75. package/dist/esm/private/binary-format-common.js +209 -207
  76. package/dist/esm/private/binary-format-proto2.js +89 -81
  77. package/dist/esm/private/binary-format-proto3.js +71 -67
  78. package/dist/esm/private/enum.js +75 -43
  79. package/dist/esm/private/field-list.js +64 -50
  80. package/dist/esm/private/field-wrapper.js +21 -10
  81. package/dist/esm/private/field.js +35 -22
  82. package/dist/esm/private/json-format-common.js +427 -435
  83. package/dist/esm/private/json-format-proto2.js +89 -81
  84. package/dist/esm/private/json-format-proto3.js +79 -80
  85. package/dist/esm/private/message-type.js +40 -28
  86. package/dist/esm/private/names.js +70 -57
  87. package/dist/esm/private/options-map.js +13 -0
  88. package/dist/esm/private/proto-runtime.js +26 -12
  89. package/dist/esm/private/scalars.js +112 -99
  90. package/dist/esm/private/util-common.js +193 -192
  91. package/dist/esm/private/util.js +13 -0
  92. package/dist/esm/proto-int64.js +123 -111
  93. package/dist/esm/proto2.js +63 -57
  94. package/dist/esm/proto3.js +74 -68
  95. package/dist/esm/service-type.js +25 -12
  96. package/dist/esm/type-registry.js +46 -31
  97. package/dist/types/binary-encoding.d.ts +398 -398
  98. package/dist/types/binary-format.d.ts +69 -91
  99. package/dist/types/descriptor-registry.d.ts +23 -29
  100. package/dist/types/descriptor-set.d.ts +107 -128
  101. package/dist/types/enum.d.ts +21 -21
  102. package/dist/types/field-list.d.ts +21 -21
  103. package/dist/types/field.d.ts +191 -231
  104. package/dist/types/google/protobuf/any_pb.d.ts +56 -77
  105. package/dist/types/google/protobuf/api_pb.d.ts +144 -187
  106. package/dist/types/google/protobuf/compiler/plugin_pb.d.ts +195 -257
  107. package/dist/types/google/protobuf/descriptor_pb.d.ts +1360 -1737
  108. package/dist/types/google/protobuf/duration_pb.d.ts +30 -50
  109. package/dist/types/google/protobuf/empty_pb.d.ts +9 -28
  110. package/dist/types/google/protobuf/field_mask_pb.d.ts +17 -37
  111. package/dist/types/google/protobuf/source_context_pb.d.ts +16 -35
  112. package/dist/types/google/protobuf/struct_pb.d.ts +64 -115
  113. package/dist/types/google/protobuf/timestamp_pb.d.ts +31 -51
  114. package/dist/types/google/protobuf/type_pb.d.ts +355 -422
  115. package/dist/types/google/protobuf/wrappers_pb.d.ts +181 -297
  116. package/dist/types/google/varint.d.ts +6 -13
  117. package/dist/types/index.d.ts +4 -27
  118. package/dist/types/json-format.d.ts +70 -89
  119. package/dist/types/message-type.d.ts +37 -45
  120. package/dist/types/message.d.ts +62 -87
  121. package/dist/types/private/assert.d.ts +1 -4
  122. package/dist/types/private/binary-format-common.d.ts +6 -32
  123. package/dist/types/private/enum.d.ts +13 -11
  124. package/dist/types/private/field-list.d.ts +14 -21
  125. package/dist/types/private/field-wrapper.d.ts +4 -10
  126. package/dist/types/private/field.d.ts +12 -12
  127. package/dist/types/private/json-format-common.d.ts +5 -27
  128. package/dist/types/private/message-type.d.ts +12 -7
  129. package/dist/types/private/names.d.ts +1 -4
  130. package/dist/types/private/options-map.d.ts +1 -1
  131. package/dist/types/private/proto-runtime.d.ts +34 -42
  132. package/dist/types/private/scalars.d.ts +5 -12
  133. package/dist/types/private/util-common.d.ts +1 -4
  134. package/dist/types/private/util.d.ts +29 -41
  135. package/dist/types/proto-int64.d.ts +42 -42
  136. package/dist/types/service-type.d.ts +36 -56
  137. package/dist/types/type-registry.d.ts +13 -15
  138. package/package.json +2 -3
@@ -7,415 +7,415 @@
7
7
  * See https://developers.google.com/protocol-buffers/docs/encoding#structure
8
8
  */
9
9
  export declare enum WireType {
10
- /**
11
- * Used for int32, int64, uint32, uint64, sint32, sint64, bool, enum
12
- */
13
- Varint = 0,
14
- /**
15
- * Used for fixed64, sfixed64, double.
16
- * Always 8 bytes with little-endian byte order.
17
- */
18
- Bit64 = 1,
19
- /**
20
- * Used for string, bytes, embedded messages, packed repeated fields
21
- *
22
- * Only repeated numeric types (types which use the varint, 32-bit,
23
- * or 64-bit wire types) can be packed. In proto3, such fields are
24
- * packed by default.
25
- */
26
- LengthDelimited = 2,
27
- /**
28
- * Used for groups
29
- * @deprecated
30
- */
31
- StartGroup = 3,
32
- /**
33
- * Used for groups
34
- * @deprecated
35
- */
36
- EndGroup = 4,
37
- /**
38
- * Used for fixed32, sfixed32, float.
39
- * Always 4 bytes with little-endian byte order.
40
- */
41
- Bit32 = 5,
10
+ /**
11
+ * Used for int32, int64, uint32, uint64, sint32, sint64, bool, enum
12
+ */
13
+ Varint = 0,
14
+ /**
15
+ * Used for fixed64, sfixed64, double.
16
+ * Always 8 bytes with little-endian byte order.
17
+ */
18
+ Bit64 = 1,
19
+ /**
20
+ * Used for string, bytes, embedded messages, packed repeated fields
21
+ *
22
+ * Only repeated numeric types (types which use the varint, 32-bit,
23
+ * or 64-bit wire types) can be packed. In proto3, such fields are
24
+ * packed by default.
25
+ */
26
+ LengthDelimited = 2,
27
+ /**
28
+ * Used for groups
29
+ * @deprecated
30
+ */
31
+ StartGroup = 3,
32
+ /**
33
+ * Used for groups
34
+ * @deprecated
35
+ */
36
+ EndGroup = 4,
37
+ /**
38
+ * Used for fixed32, sfixed32, float.
39
+ * Always 4 bytes with little-endian byte order.
40
+ */
41
+ Bit32 = 5
42
42
  }
43
43
  declare type TextEncoderLike = {
44
- encode(input?: string): Uint8Array;
44
+ encode(input?: string): Uint8Array;
45
45
  };
46
46
  declare type TextDecoderLike = {
47
- decode(input?: Uint8Array): string;
47
+ decode(input?: Uint8Array): string;
48
48
  };
49
49
  export interface IBinaryReader {
50
- /**
51
- * Current position.
52
- */
53
- readonly pos: number;
54
- /**
55
- * Number of bytes available in this reader.
56
- */
57
- readonly len: number;
58
- /**
59
- * Reads a tag - field number and wire type.
60
- */
61
- tag(): [number, WireType];
62
- /**
63
- * Skip one element on the wire and return the skipped data.
64
- */
65
- skip(wireType: WireType): Uint8Array;
66
- /**
67
- * Read a `int32` field, a signed 32 bit varint.
68
- */
69
- uint32(): number;
70
- /**
71
- * Read a `sint32` field, a signed, zigzag-encoded 32-bit varint.
72
- */
73
- int32(): number;
74
- /**
75
- * Read a `sint32` field, a signed, zigzag-encoded 32-bit varint.
76
- */
77
- sint32(): number;
78
- /**
79
- * Read a `int64` field, a signed 64-bit varint.
80
- */
81
- int64(): bigint | string;
82
- /**
83
- * Read a `sint64` field, a signed, zig-zag-encoded 64-bit varint.
84
- */
85
- sint64(): bigint | string;
86
- /**
87
- * Read a `fixed64` field, a signed, fixed-length 64-bit integer.
88
- */
89
- sfixed64(): bigint | string;
90
- /**
91
- * Read a `uint64` field, an unsigned 64-bit varint.
92
- */
93
- uint64(): bigint | string;
94
- /**
95
- * Read a `fixed64` field, an unsigned, fixed-length 64 bit integer.
96
- */
97
- fixed64(): bigint | string;
98
- /**
99
- * Read a `bool` field, a variant.
100
- */
101
- bool(): boolean;
102
- /**
103
- * Read a `fixed32` field, an unsigned, fixed-length 32-bit integer.
104
- */
105
- fixed32(): number;
106
- /**
107
- * Read a `sfixed32` field, a signed, fixed-length 32-bit integer.
108
- */
109
- sfixed32(): number;
110
- /**
111
- * Read a `float` field, 32-bit floating point number.
112
- */
113
- float(): number;
114
- /**
115
- * Read a `double` field, a 64-bit floating point number.
116
- */
117
- double(): number;
118
- /**
119
- * Read a `bytes` field, length-delimited arbitrary data.
120
- */
121
- bytes(): Uint8Array;
122
- /**
123
- * Read a `string` field, length-delimited data converted to UTF-8 text.
124
- */
125
- string(): string;
50
+ /**
51
+ * Current position.
52
+ */
53
+ readonly pos: number;
54
+ /**
55
+ * Number of bytes available in this reader.
56
+ */
57
+ readonly len: number;
58
+ /**
59
+ * Reads a tag - field number and wire type.
60
+ */
61
+ tag(): [number, WireType];
62
+ /**
63
+ * Skip one element on the wire and return the skipped data.
64
+ */
65
+ skip(wireType: WireType): Uint8Array;
66
+ /**
67
+ * Read a `int32` field, a signed 32 bit varint.
68
+ */
69
+ uint32(): number;
70
+ /**
71
+ * Read a `sint32` field, a signed, zigzag-encoded 32-bit varint.
72
+ */
73
+ int32(): number;
74
+ /**
75
+ * Read a `sint32` field, a signed, zigzag-encoded 32-bit varint.
76
+ */
77
+ sint32(): number;
78
+ /**
79
+ * Read a `int64` field, a signed 64-bit varint.
80
+ */
81
+ int64(): bigint | string;
82
+ /**
83
+ * Read a `sint64` field, a signed, zig-zag-encoded 64-bit varint.
84
+ */
85
+ sint64(): bigint | string;
86
+ /**
87
+ * Read a `fixed64` field, a signed, fixed-length 64-bit integer.
88
+ */
89
+ sfixed64(): bigint | string;
90
+ /**
91
+ * Read a `uint64` field, an unsigned 64-bit varint.
92
+ */
93
+ uint64(): bigint | string;
94
+ /**
95
+ * Read a `fixed64` field, an unsigned, fixed-length 64 bit integer.
96
+ */
97
+ fixed64(): bigint | string;
98
+ /**
99
+ * Read a `bool` field, a variant.
100
+ */
101
+ bool(): boolean;
102
+ /**
103
+ * Read a `fixed32` field, an unsigned, fixed-length 32-bit integer.
104
+ */
105
+ fixed32(): number;
106
+ /**
107
+ * Read a `sfixed32` field, a signed, fixed-length 32-bit integer.
108
+ */
109
+ sfixed32(): number;
110
+ /**
111
+ * Read a `float` field, 32-bit floating point number.
112
+ */
113
+ float(): number;
114
+ /**
115
+ * Read a `double` field, a 64-bit floating point number.
116
+ */
117
+ double(): number;
118
+ /**
119
+ * Read a `bytes` field, length-delimited arbitrary data.
120
+ */
121
+ bytes(): Uint8Array;
122
+ /**
123
+ * Read a `string` field, length-delimited data converted to UTF-8 text.
124
+ */
125
+ string(): string;
126
126
  }
127
127
  export interface IBinaryWriter {
128
- /**
129
- * Return all bytes written and reset this writer.
130
- */
131
- finish(): Uint8Array;
132
- /**
133
- * Start a new fork for length-delimited data like a message
134
- * or a packed repeated field.
135
- *
136
- * Must be joined later with `join()`.
137
- */
138
- fork(): IBinaryWriter;
139
- /**
140
- * Join the last fork. Write its length and bytes, then
141
- * return to the previous state.
142
- */
143
- join(): IBinaryWriter;
144
- /**
145
- * Writes a tag (field number and wire type).
146
- *
147
- * Equivalent to `uint32( (fieldNo << 3 | type) >>> 0 )`
148
- *
149
- * Generated code should compute the tag ahead of time and call `uint32()`.
150
- */
151
- tag(fieldNo: number, type: WireType): IBinaryWriter;
152
- /**
153
- * Write a chunk of raw bytes.
154
- */
155
- raw(chunk: Uint8Array): IBinaryWriter;
156
- /**
157
- * Write a `uint32` value, an unsigned 32 bit varint.
158
- */
159
- uint32(value: number): IBinaryWriter;
160
- /**
161
- * Write a `int32` value, a signed 32 bit varint.
162
- */
163
- int32(value: number): IBinaryWriter;
164
- /**
165
- * Write a `sint32` value, a signed, zigzag-encoded 32-bit varint.
166
- */
167
- sint32(value: number): IBinaryWriter;
168
- /**
169
- * Write a `int64` value, a signed 64-bit varint.
170
- */
171
- int64(value: string | number | bigint): IBinaryWriter;
172
- /**
173
- * Write a `uint64` value, an unsigned 64-bit varint.
174
- */
175
- uint64(value: string | number | bigint): IBinaryWriter;
176
- /**
177
- * Write a `sint64` value, a signed, zig-zag-encoded 64-bit varint.
178
- */
179
- sint64(value: string | number | bigint): IBinaryWriter;
180
- /**
181
- * Write a `fixed64` value, an unsigned, fixed-length 64 bit integer.
182
- */
183
- fixed64(value: string | number | bigint): IBinaryWriter;
184
- /**
185
- * Write a `fixed64` value, a signed, fixed-length 64-bit integer.
186
- */
187
- sfixed64(value: string | number | bigint): IBinaryWriter;
188
- /**
189
- * Write a `bool` value, a variant.
190
- */
191
- bool(value: boolean): IBinaryWriter;
192
- /**
193
- * Write a `fixed32` value, an unsigned, fixed-length 32-bit integer.
194
- */
195
- fixed32(value: number): IBinaryWriter;
196
- /**
197
- * Write a `sfixed32` value, a signed, fixed-length 32-bit integer.
198
- */
199
- sfixed32(value: number): IBinaryWriter;
200
- /**
201
- * Write a `float` value, 32-bit floating point number.
202
- */
203
- float(value: number): IBinaryWriter;
204
- /**
205
- * Write a `double` value, a 64-bit floating point number.
206
- */
207
- double(value: number): IBinaryWriter;
208
- /**
209
- * Write a `bytes` value, length-delimited arbitrary data.
210
- */
211
- bytes(value: Uint8Array): IBinaryWriter;
212
- /**
213
- * Write a `string` value, length-delimited data converted to UTF-8 text.
214
- */
215
- string(value: string): IBinaryWriter;
128
+ /**
129
+ * Return all bytes written and reset this writer.
130
+ */
131
+ finish(): Uint8Array;
132
+ /**
133
+ * Start a new fork for length-delimited data like a message
134
+ * or a packed repeated field.
135
+ *
136
+ * Must be joined later with `join()`.
137
+ */
138
+ fork(): IBinaryWriter;
139
+ /**
140
+ * Join the last fork. Write its length and bytes, then
141
+ * return to the previous state.
142
+ */
143
+ join(): IBinaryWriter;
144
+ /**
145
+ * Writes a tag (field number and wire type).
146
+ *
147
+ * Equivalent to `uint32( (fieldNo << 3 | type) >>> 0 )`
148
+ *
149
+ * Generated code should compute the tag ahead of time and call `uint32()`.
150
+ */
151
+ tag(fieldNo: number, type: WireType): IBinaryWriter;
152
+ /**
153
+ * Write a chunk of raw bytes.
154
+ */
155
+ raw(chunk: Uint8Array): IBinaryWriter;
156
+ /**
157
+ * Write a `uint32` value, an unsigned 32 bit varint.
158
+ */
159
+ uint32(value: number): IBinaryWriter;
160
+ /**
161
+ * Write a `int32` value, a signed 32 bit varint.
162
+ */
163
+ int32(value: number): IBinaryWriter;
164
+ /**
165
+ * Write a `sint32` value, a signed, zigzag-encoded 32-bit varint.
166
+ */
167
+ sint32(value: number): IBinaryWriter;
168
+ /**
169
+ * Write a `int64` value, a signed 64-bit varint.
170
+ */
171
+ int64(value: string | number | bigint): IBinaryWriter;
172
+ /**
173
+ * Write a `uint64` value, an unsigned 64-bit varint.
174
+ */
175
+ uint64(value: string | number | bigint): IBinaryWriter;
176
+ /**
177
+ * Write a `sint64` value, a signed, zig-zag-encoded 64-bit varint.
178
+ */
179
+ sint64(value: string | number | bigint): IBinaryWriter;
180
+ /**
181
+ * Write a `fixed64` value, an unsigned, fixed-length 64 bit integer.
182
+ */
183
+ fixed64(value: string | number | bigint): IBinaryWriter;
184
+ /**
185
+ * Write a `fixed64` value, a signed, fixed-length 64-bit integer.
186
+ */
187
+ sfixed64(value: string | number | bigint): IBinaryWriter;
188
+ /**
189
+ * Write a `bool` value, a variant.
190
+ */
191
+ bool(value: boolean): IBinaryWriter;
192
+ /**
193
+ * Write a `fixed32` value, an unsigned, fixed-length 32-bit integer.
194
+ */
195
+ fixed32(value: number): IBinaryWriter;
196
+ /**
197
+ * Write a `sfixed32` value, a signed, fixed-length 32-bit integer.
198
+ */
199
+ sfixed32(value: number): IBinaryWriter;
200
+ /**
201
+ * Write a `float` value, 32-bit floating point number.
202
+ */
203
+ float(value: number): IBinaryWriter;
204
+ /**
205
+ * Write a `double` value, a 64-bit floating point number.
206
+ */
207
+ double(value: number): IBinaryWriter;
208
+ /**
209
+ * Write a `bytes` value, length-delimited arbitrary data.
210
+ */
211
+ bytes(value: Uint8Array): IBinaryWriter;
212
+ /**
213
+ * Write a `string` value, length-delimited data converted to UTF-8 text.
214
+ */
215
+ string(value: string): IBinaryWriter;
216
216
  }
217
217
  export declare class BinaryWriter implements IBinaryWriter {
218
- /**
219
- * We cannot allocate a buffer for the entire output
220
- * because we don't know it's size.
221
- *
222
- * So we collect smaller chunks of known size and
223
- * concat them later.
224
- *
225
- * Use `raw()` to push data to this array. It will flush
226
- * `buf` first.
227
- */
228
- private chunks;
229
- /**
230
- * A growing buffer for byte values. If you don't know
231
- * the size of the data you are writing, push to this
232
- * array.
233
- */
234
- protected buf: number[];
235
- /**
236
- * Previous fork states.
237
- */
238
- private stack;
239
- /**
240
- * Text encoder instance to convert UTF-8 to bytes.
241
- */
242
- private readonly textEncoder;
243
- constructor(textEncoder?: TextEncoderLike);
244
- /**
245
- * Return all bytes written and reset this writer.
246
- */
247
- finish(): Uint8Array;
248
- /**
249
- * Start a new fork for length-delimited data like a message
250
- * or a packed repeated field.
251
- *
252
- * Must be joined later with `join()`.
253
- */
254
- fork(): IBinaryWriter;
255
- /**
256
- * Join the last fork. Write its length and bytes, then
257
- * return to the previous state.
258
- */
259
- join(): IBinaryWriter;
260
- /**
261
- * Writes a tag (field number and wire type).
262
- *
263
- * Equivalent to `uint32( (fieldNo << 3 | type) >>> 0 )`.
264
- *
265
- * Generated code should compute the tag ahead of time and call `uint32()`.
266
- */
267
- tag(fieldNo: number, type: WireType): IBinaryWriter;
268
- /**
269
- * Write a chunk of raw bytes.
270
- */
271
- raw(chunk: Uint8Array): IBinaryWriter;
272
- /**
273
- * Write a `uint32` value, an unsigned 32 bit varint.
274
- */
275
- uint32(value: number): IBinaryWriter;
276
- /**
277
- * Write a `int32` value, a signed 32 bit varint.
278
- */
279
- int32(value: number): IBinaryWriter;
280
- /**
281
- * Write a `bool` value, a variant.
282
- */
283
- bool(value: boolean): IBinaryWriter;
284
- /**
285
- * Write a `bytes` value, length-delimited arbitrary data.
286
- */
287
- bytes(value: Uint8Array): IBinaryWriter;
288
- /**
289
- * Write a `string` value, length-delimited data converted to UTF-8 text.
290
- */
291
- string(value: string): IBinaryWriter;
292
- /**
293
- * Write a `float` value, 32-bit floating point number.
294
- */
295
- float(value: number): IBinaryWriter;
296
- /**
297
- * Write a `double` value, a 64-bit floating point number.
298
- */
299
- double(value: number): IBinaryWriter;
300
- /**
301
- * Write a `fixed32` value, an unsigned, fixed-length 32-bit integer.
302
- */
303
- fixed32(value: number): IBinaryWriter;
304
- /**
305
- * Write a `sfixed32` value, a signed, fixed-length 32-bit integer.
306
- */
307
- sfixed32(value: number): IBinaryWriter;
308
- /**
309
- * Write a `sint32` value, a signed, zigzag-encoded 32-bit varint.
310
- */
311
- sint32(value: number): IBinaryWriter;
312
- /**
313
- * Write a `fixed64` value, a signed, fixed-length 64-bit integer.
314
- */
315
- sfixed64(value: string | number | bigint): IBinaryWriter;
316
- /**
317
- * Write a `fixed64` value, an unsigned, fixed-length 64 bit integer.
318
- */
319
- fixed64(value: string | number | bigint): IBinaryWriter;
320
- /**
321
- * Write a `int64` value, a signed 64-bit varint.
322
- */
323
- int64(value: string | number | bigint): IBinaryWriter;
324
- /**
325
- * Write a `sint64` value, a signed, zig-zag-encoded 64-bit varint.
326
- */
327
- sint64(value: string | number | bigint): IBinaryWriter;
328
- /**
329
- * Write a `uint64` value, an unsigned 64-bit varint.
330
- */
331
- uint64(value: string | number | bigint): IBinaryWriter;
218
+ /**
219
+ * We cannot allocate a buffer for the entire output
220
+ * because we don't know it's size.
221
+ *
222
+ * So we collect smaller chunks of known size and
223
+ * concat them later.
224
+ *
225
+ * Use `raw()` to push data to this array. It will flush
226
+ * `buf` first.
227
+ */
228
+ private chunks;
229
+ /**
230
+ * A growing buffer for byte values. If you don't know
231
+ * the size of the data you are writing, push to this
232
+ * array.
233
+ */
234
+ protected buf: number[];
235
+ /**
236
+ * Previous fork states.
237
+ */
238
+ private stack;
239
+ /**
240
+ * Text encoder instance to convert UTF-8 to bytes.
241
+ */
242
+ private readonly textEncoder;
243
+ constructor(textEncoder?: TextEncoderLike);
244
+ /**
245
+ * Return all bytes written and reset this writer.
246
+ */
247
+ finish(): Uint8Array;
248
+ /**
249
+ * Start a new fork for length-delimited data like a message
250
+ * or a packed repeated field.
251
+ *
252
+ * Must be joined later with `join()`.
253
+ */
254
+ fork(): IBinaryWriter;
255
+ /**
256
+ * Join the last fork. Write its length and bytes, then
257
+ * return to the previous state.
258
+ */
259
+ join(): IBinaryWriter;
260
+ /**
261
+ * Writes a tag (field number and wire type).
262
+ *
263
+ * Equivalent to `uint32( (fieldNo << 3 | type) >>> 0 )`.
264
+ *
265
+ * Generated code should compute the tag ahead of time and call `uint32()`.
266
+ */
267
+ tag(fieldNo: number, type: WireType): IBinaryWriter;
268
+ /**
269
+ * Write a chunk of raw bytes.
270
+ */
271
+ raw(chunk: Uint8Array): IBinaryWriter;
272
+ /**
273
+ * Write a `uint32` value, an unsigned 32 bit varint.
274
+ */
275
+ uint32(value: number): IBinaryWriter;
276
+ /**
277
+ * Write a `int32` value, a signed 32 bit varint.
278
+ */
279
+ int32(value: number): IBinaryWriter;
280
+ /**
281
+ * Write a `bool` value, a variant.
282
+ */
283
+ bool(value: boolean): IBinaryWriter;
284
+ /**
285
+ * Write a `bytes` value, length-delimited arbitrary data.
286
+ */
287
+ bytes(value: Uint8Array): IBinaryWriter;
288
+ /**
289
+ * Write a `string` value, length-delimited data converted to UTF-8 text.
290
+ */
291
+ string(value: string): IBinaryWriter;
292
+ /**
293
+ * Write a `float` value, 32-bit floating point number.
294
+ */
295
+ float(value: number): IBinaryWriter;
296
+ /**
297
+ * Write a `double` value, a 64-bit floating point number.
298
+ */
299
+ double(value: number): IBinaryWriter;
300
+ /**
301
+ * Write a `fixed32` value, an unsigned, fixed-length 32-bit integer.
302
+ */
303
+ fixed32(value: number): IBinaryWriter;
304
+ /**
305
+ * Write a `sfixed32` value, a signed, fixed-length 32-bit integer.
306
+ */
307
+ sfixed32(value: number): IBinaryWriter;
308
+ /**
309
+ * Write a `sint32` value, a signed, zigzag-encoded 32-bit varint.
310
+ */
311
+ sint32(value: number): IBinaryWriter;
312
+ /**
313
+ * Write a `fixed64` value, a signed, fixed-length 64-bit integer.
314
+ */
315
+ sfixed64(value: string | number | bigint): IBinaryWriter;
316
+ /**
317
+ * Write a `fixed64` value, an unsigned, fixed-length 64 bit integer.
318
+ */
319
+ fixed64(value: string | number | bigint): IBinaryWriter;
320
+ /**
321
+ * Write a `int64` value, a signed 64-bit varint.
322
+ */
323
+ int64(value: string | number | bigint): IBinaryWriter;
324
+ /**
325
+ * Write a `sint64` value, a signed, zig-zag-encoded 64-bit varint.
326
+ */
327
+ sint64(value: string | number | bigint): IBinaryWriter;
328
+ /**
329
+ * Write a `uint64` value, an unsigned 64-bit varint.
330
+ */
331
+ uint64(value: string | number | bigint): IBinaryWriter;
332
332
  }
333
333
  export declare class BinaryReader implements IBinaryReader {
334
- /**
335
- * Current position.
336
- */
337
- pos: number;
338
- /**
339
- * Number of bytes available in this reader.
340
- */
341
- readonly len: number;
342
- private readonly buf;
343
- private readonly view;
344
- private readonly textDecoder;
345
- constructor(buf: Uint8Array, textDecoder?: TextDecoderLike);
346
- /**
347
- * Reads a tag - field number and wire type.
348
- */
349
- tag(): [number, WireType];
350
- /**
351
- * Skip one element on the wire and return the skipped data.
352
- * Supports WireType.StartGroup since v2.0.0-alpha.23.
353
- */
354
- skip(wireType: WireType): Uint8Array;
355
- protected varint64: () => [number, number];
356
- /**
357
- * Throws error if position in byte array is out of range.
358
- */
359
- protected assertBounds(): void;
360
- /**
361
- * Read a `uint32` field, an unsigned 32 bit varint.
362
- */
363
- uint32: () => number;
364
- /**
365
- * Read a `int32` field, a signed 32 bit varint.
366
- */
367
- int32(): number;
368
- /**
369
- * Read a `sint32` field, a signed, zigzag-encoded 32-bit varint.
370
- */
371
- sint32(): number;
372
- /**
373
- * Read a `int64` field, a signed 64-bit varint.
374
- */
375
- int64(): bigint | string;
376
- /**
377
- * Read a `uint64` field, an unsigned 64-bit varint.
378
- */
379
- uint64(): bigint | string;
380
- /**
381
- * Read a `sint64` field, a signed, zig-zag-encoded 64-bit varint.
382
- */
383
- sint64(): bigint | string;
384
- /**
385
- * Read a `bool` field, a variant.
386
- */
387
- bool(): boolean;
388
- /**
389
- * Read a `fixed32` field, an unsigned, fixed-length 32-bit integer.
390
- */
391
- fixed32(): number;
392
- /**
393
- * Read a `sfixed32` field, a signed, fixed-length 32-bit integer.
394
- */
395
- sfixed32(): number;
396
- /**
397
- * Read a `fixed64` field, an unsigned, fixed-length 64 bit integer.
398
- */
399
- fixed64(): bigint | string;
400
- /**
401
- * Read a `fixed64` field, a signed, fixed-length 64-bit integer.
402
- */
403
- sfixed64(): bigint | string;
404
- /**
405
- * Read a `float` field, 32-bit floating point number.
406
- */
407
- float(): number;
408
- /**
409
- * Read a `double` field, a 64-bit floating point number.
410
- */
411
- double(): number;
412
- /**
413
- * Read a `bytes` field, length-delimited arbitrary data.
414
- */
415
- bytes(): Uint8Array;
416
- /**
417
- * Read a `string` field, length-delimited data converted to UTF-8 text.
418
- */
419
- string(): string;
334
+ /**
335
+ * Current position.
336
+ */
337
+ pos: number;
338
+ /**
339
+ * Number of bytes available in this reader.
340
+ */
341
+ readonly len: number;
342
+ private readonly buf;
343
+ private readonly view;
344
+ private readonly textDecoder;
345
+ constructor(buf: Uint8Array, textDecoder?: TextDecoderLike);
346
+ /**
347
+ * Reads a tag - field number and wire type.
348
+ */
349
+ tag(): [number, WireType];
350
+ /**
351
+ * Skip one element on the wire and return the skipped data.
352
+ * Supports WireType.StartGroup since v2.0.0-alpha.23.
353
+ */
354
+ skip(wireType: WireType): Uint8Array;
355
+ protected varint64: () => [number, number];
356
+ /**
357
+ * Throws error if position in byte array is out of range.
358
+ */
359
+ protected assertBounds(): void;
360
+ /**
361
+ * Read a `uint32` field, an unsigned 32 bit varint.
362
+ */
363
+ uint32: () => number;
364
+ /**
365
+ * Read a `int32` field, a signed 32 bit varint.
366
+ */
367
+ int32(): number;
368
+ /**
369
+ * Read a `sint32` field, a signed, zigzag-encoded 32-bit varint.
370
+ */
371
+ sint32(): number;
372
+ /**
373
+ * Read a `int64` field, a signed 64-bit varint.
374
+ */
375
+ int64(): bigint | string;
376
+ /**
377
+ * Read a `uint64` field, an unsigned 64-bit varint.
378
+ */
379
+ uint64(): bigint | string;
380
+ /**
381
+ * Read a `sint64` field, a signed, zig-zag-encoded 64-bit varint.
382
+ */
383
+ sint64(): bigint | string;
384
+ /**
385
+ * Read a `bool` field, a variant.
386
+ */
387
+ bool(): boolean;
388
+ /**
389
+ * Read a `fixed32` field, an unsigned, fixed-length 32-bit integer.
390
+ */
391
+ fixed32(): number;
392
+ /**
393
+ * Read a `sfixed32` field, a signed, fixed-length 32-bit integer.
394
+ */
395
+ sfixed32(): number;
396
+ /**
397
+ * Read a `fixed64` field, an unsigned, fixed-length 64 bit integer.
398
+ */
399
+ fixed64(): bigint | string;
400
+ /**
401
+ * Read a `fixed64` field, a signed, fixed-length 64-bit integer.
402
+ */
403
+ sfixed64(): bigint | string;
404
+ /**
405
+ * Read a `float` field, 32-bit floating point number.
406
+ */
407
+ float(): number;
408
+ /**
409
+ * Read a `double` field, a 64-bit floating point number.
410
+ */
411
+ double(): number;
412
+ /**
413
+ * Read a `bytes` field, length-delimited arbitrary data.
414
+ */
415
+ bytes(): Uint8Array;
416
+ /**
417
+ * Read a `string` field, length-delimited data converted to UTF-8 text.
418
+ */
419
+ string(): string;
420
420
  }
421
421
  export {};