@bufbuild/protobuf 2.12.0 → 2.13.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 +5 -5
- package/dist/commonjs/codegenv1/boot.d.ts +1 -0
- package/dist/{cjs/codegenv1/types.js → commonjs/codegenv1/boot.js} +3 -7
- package/dist/{cjs → commonjs}/codegenv1/symbols.d.ts +5 -0
- package/dist/{cjs → commonjs}/codegenv1/types.d.ts +9 -5
- package/dist/commonjs/codegenv2/enum.d.ts +29 -0
- package/dist/{cjs → commonjs}/codegenv2/enum.js +18 -0
- package/dist/{cjs → commonjs}/codegenv2/symbols.d.ts +10 -0
- package/dist/{cjs → commonjs}/codegenv2/symbols.js +2 -0
- package/dist/{cjs → commonjs}/codegenv2/types.d.ts +9 -5
- package/dist/{cjs → commonjs}/create.js +3 -3
- package/dist/{cjs → commonjs}/descriptors.d.ts +2 -2
- package/dist/{cjs → commonjs}/equals.d.ts +8 -3
- package/dist/{cjs → commonjs}/equals.js +8 -3
- package/dist/{cjs → commonjs}/extensions.d.ts +2 -1
- package/dist/{cjs → commonjs}/extensions.js +3 -4
- package/dist/{cjs → commonjs}/from-binary.d.ts +16 -2
- package/dist/{cjs → commonjs}/from-binary.js +30 -24
- package/dist/{cjs → commonjs}/from-json.d.ts +19 -2
- package/dist/{cjs → commonjs}/from-json.js +174 -54
- package/dist/{cjs → commonjs}/index.d.ts +1 -0
- package/dist/{cjs → commonjs}/index.js +1 -0
- package/dist/commonjs/json-value.js +15 -0
- package/dist/commonjs/package.json +4 -0
- package/dist/{cjs → commonjs}/proto-int64.js +1 -0
- package/dist/{cjs → commonjs}/reflect/reflect-check.js +3 -1
- package/dist/{cjs → commonjs}/reflect/reflect.js +3 -2
- package/dist/commonjs/reflect/scalar.d.ts +43 -0
- package/dist/{cjs → commonjs}/reflect/scalar.js +33 -6
- package/dist/{cjs → commonjs}/reflect/unsafe.js +1 -1
- package/dist/{cjs → commonjs}/registry.js +20 -20
- package/dist/{cjs → commonjs}/to-binary.js +1 -1
- package/dist/{cjs → commonjs}/to-json.js +2 -2
- package/dist/commonjs/txtpb/from-text.d.ts +35 -0
- package/dist/commonjs/txtpb/from-text.js +684 -0
- package/dist/commonjs/txtpb/index.d.ts +4 -0
- package/dist/commonjs/txtpb/index.js +21 -0
- package/dist/commonjs/txtpb/is-group-like.d.ts +19 -0
- package/dist/commonjs/txtpb/is-group-like.js +47 -0
- package/dist/commonjs/txtpb/reader.d.ts +91 -0
- package/dist/commonjs/txtpb/reader.js +481 -0
- package/dist/commonjs/txtpb/to-text.d.ts +34 -0
- package/dist/commonjs/txtpb/to-text.js +358 -0
- package/dist/commonjs/txtpb/writer.d.ts +76 -0
- package/dist/commonjs/txtpb/writer.js +220 -0
- package/dist/{cjs → commonjs}/types.d.ts +7 -0
- package/dist/{cjs/codegenv2 → commonjs}/types.js +0 -7
- package/dist/commonjs/unknown-enum.d.ts +10 -0
- package/dist/commonjs/unknown-enum.js +26 -0
- package/dist/{cjs → commonjs}/wire/binary-encoding.d.ts +4 -2
- package/dist/{cjs → commonjs}/wire/binary-encoding.js +8 -3
- package/dist/{cjs → commonjs}/wire/size-delimited.d.ts +19 -1
- package/dist/{cjs → commonjs}/wire/size-delimited.js +54 -16
- package/dist/esm/codegenv1/boot.d.ts +1 -0
- package/dist/esm/codegenv1/boot.js +14 -0
- package/dist/esm/codegenv1/symbols.d.ts +5 -0
- package/dist/esm/codegenv1/types.d.ts +9 -5
- package/dist/esm/codegenv1/types.js +0 -7
- package/dist/esm/codegenv2/enum.d.ts +15 -4
- package/dist/esm/codegenv2/enum.js +17 -0
- package/dist/esm/codegenv2/symbols.d.ts +10 -0
- package/dist/esm/codegenv2/symbols.js +2 -0
- package/dist/esm/codegenv2/types.d.ts +9 -5
- package/dist/esm/codegenv2/types.js +0 -7
- package/dist/esm/create.js +3 -3
- package/dist/esm/descriptors.d.ts +2 -2
- package/dist/esm/equals.d.ts +8 -3
- package/dist/esm/equals.js +8 -3
- package/dist/esm/extensions.d.ts +2 -1
- package/dist/esm/extensions.js +4 -5
- package/dist/esm/from-binary.d.ts +16 -2
- package/dist/esm/from-binary.js +29 -24
- package/dist/esm/from-json.d.ts +19 -2
- package/dist/esm/from-json.js +174 -54
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/package.json +4 -0
- package/dist/esm/proto-int64.js +1 -0
- package/dist/esm/reflect/reflect-check.js +3 -1
- package/dist/esm/reflect/reflect.js +3 -2
- package/dist/esm/reflect/scalar.d.ts +27 -5
- package/dist/esm/reflect/scalar.js +33 -6
- package/dist/esm/reflect/unsafe.js +1 -1
- package/dist/esm/registry.js +20 -20
- package/dist/esm/to-binary.js +1 -1
- package/dist/esm/to-json.js +2 -2
- package/dist/esm/txtpb/from-text.d.ts +35 -0
- package/dist/esm/txtpb/from-text.js +680 -0
- package/dist/esm/txtpb/index.d.ts +4 -0
- package/dist/esm/txtpb/index.js +15 -0
- package/dist/esm/txtpb/is-group-like.d.ts +19 -0
- package/dist/esm/txtpb/is-group-like.js +44 -0
- package/dist/esm/txtpb/reader.d.ts +91 -0
- package/dist/esm/txtpb/reader.js +477 -0
- package/dist/esm/txtpb/to-text.d.ts +34 -0
- package/dist/esm/txtpb/to-text.js +355 -0
- package/dist/esm/txtpb/writer.d.ts +76 -0
- package/dist/esm/txtpb/writer.js +214 -0
- package/dist/esm/types.d.ts +7 -0
- package/dist/esm/unknown-enum.d.ts +10 -0
- package/dist/esm/unknown-enum.js +23 -0
- package/dist/esm/wire/binary-encoding.d.ts +4 -2
- package/dist/esm/wire/binary-encoding.js +8 -3
- package/dist/esm/wire/size-delimited.d.ts +19 -1
- package/dist/esm/wire/size-delimited.js +54 -16
- package/package.json +109 -30
- package/dist/cjs/codegenv2/enum.d.ts +0 -18
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/reflect/scalar.d.ts +0 -21
- /package/dist/{cjs → commonjs}/clone.d.ts +0 -0
- /package/dist/{cjs → commonjs}/clone.js +0 -0
- /package/dist/{cjs → commonjs}/codegenv1/enum.d.ts +0 -0
- /package/dist/{cjs → commonjs}/codegenv1/enum.js +0 -0
- /package/dist/{cjs → commonjs}/codegenv1/extension.d.ts +0 -0
- /package/dist/{cjs → commonjs}/codegenv1/extension.js +0 -0
- /package/dist/{cjs → commonjs}/codegenv1/file.d.ts +0 -0
- /package/dist/{cjs → commonjs}/codegenv1/file.js +0 -0
- /package/dist/{cjs → commonjs}/codegenv1/index.d.ts +0 -0
- /package/dist/{cjs → commonjs}/codegenv1/index.js +0 -0
- /package/dist/{cjs → commonjs}/codegenv1/message.d.ts +0 -0
- /package/dist/{cjs → commonjs}/codegenv1/message.js +0 -0
- /package/dist/{cjs → commonjs}/codegenv1/service.d.ts +0 -0
- /package/dist/{cjs → commonjs}/codegenv1/service.js +0 -0
- /package/dist/{cjs → commonjs}/codegenv1/symbols.js +0 -0
- /package/dist/{cjs → commonjs/codegenv1}/types.js +0 -0
- /package/dist/{cjs → commonjs}/codegenv2/boot.d.ts +0 -0
- /package/dist/{cjs → commonjs}/codegenv2/boot.js +0 -0
- /package/dist/{cjs → commonjs}/codegenv2/embed.d.ts +0 -0
- /package/dist/{cjs → commonjs}/codegenv2/embed.js +0 -0
- /package/dist/{cjs → commonjs}/codegenv2/extension.d.ts +0 -0
- /package/dist/{cjs → commonjs}/codegenv2/extension.js +0 -0
- /package/dist/{cjs → commonjs}/codegenv2/file.d.ts +0 -0
- /package/dist/{cjs → commonjs}/codegenv2/file.js +0 -0
- /package/dist/{cjs → commonjs}/codegenv2/index.d.ts +0 -0
- /package/dist/{cjs → commonjs}/codegenv2/index.js +0 -0
- /package/dist/{cjs → commonjs}/codegenv2/message.d.ts +0 -0
- /package/dist/{cjs → commonjs}/codegenv2/message.js +0 -0
- /package/dist/{cjs → commonjs}/codegenv2/restore-json-names.d.ts +0 -0
- /package/dist/{cjs → commonjs}/codegenv2/restore-json-names.js +0 -0
- /package/dist/{cjs → commonjs}/codegenv2/scalar.d.ts +0 -0
- /package/dist/{cjs → commonjs}/codegenv2/scalar.js +0 -0
- /package/dist/{cjs → commonjs}/codegenv2/service.d.ts +0 -0
- /package/dist/{cjs → commonjs}/codegenv2/service.js +0 -0
- /package/dist/{cjs/json-value.js → commonjs/codegenv2/types.js} +0 -0
- /package/dist/{cjs → commonjs}/create.d.ts +0 -0
- /package/dist/{cjs → commonjs}/descriptors.js +0 -0
- /package/dist/{cjs → commonjs}/fields.d.ts +0 -0
- /package/dist/{cjs → commonjs}/fields.js +0 -0
- /package/dist/{cjs → commonjs}/is-message.d.ts +0 -0
- /package/dist/{cjs → commonjs}/is-message.js +0 -0
- /package/dist/{cjs → commonjs}/json-value.d.ts +0 -0
- /package/dist/{cjs → commonjs}/merge.d.ts +0 -0
- /package/dist/{cjs → commonjs}/merge.js +0 -0
- /package/dist/{cjs → commonjs}/proto-int64.d.ts +0 -0
- /package/dist/{cjs → commonjs}/reflect/error.d.ts +0 -0
- /package/dist/{cjs → commonjs}/reflect/error.js +0 -0
- /package/dist/{cjs → commonjs}/reflect/guard.d.ts +0 -0
- /package/dist/{cjs → commonjs}/reflect/guard.js +0 -0
- /package/dist/{cjs → commonjs}/reflect/index.d.ts +0 -0
- /package/dist/{cjs → commonjs}/reflect/index.js +0 -0
- /package/dist/{cjs → commonjs}/reflect/names.d.ts +0 -0
- /package/dist/{cjs → commonjs}/reflect/names.js +0 -0
- /package/dist/{cjs → commonjs}/reflect/nested-types.d.ts +0 -0
- /package/dist/{cjs → commonjs}/reflect/nested-types.js +0 -0
- /package/dist/{cjs → commonjs}/reflect/path.d.ts +0 -0
- /package/dist/{cjs → commonjs}/reflect/path.js +0 -0
- /package/dist/{cjs → commonjs}/reflect/reflect-check.d.ts +0 -0
- /package/dist/{cjs → commonjs}/reflect/reflect-types.d.ts +0 -0
- /package/dist/{cjs → commonjs}/reflect/reflect-types.js +0 -0
- /package/dist/{cjs → commonjs}/reflect/reflect.d.ts +0 -0
- /package/dist/{cjs → commonjs}/reflect/unsafe.d.ts +0 -0
- /package/dist/{cjs → commonjs}/registry.d.ts +0 -0
- /package/dist/{cjs → commonjs}/to-binary.d.ts +0 -0
- /package/dist/{cjs → commonjs}/to-json.d.ts +0 -0
- /package/dist/{cjs → commonjs}/wire/base64-encoding.d.ts +0 -0
- /package/dist/{cjs → commonjs}/wire/base64-encoding.js +0 -0
- /package/dist/{cjs → commonjs}/wire/index.d.ts +0 -0
- /package/dist/{cjs → commonjs}/wire/index.js +0 -0
- /package/dist/{cjs → commonjs}/wire/text-encoding.d.ts +0 -0
- /package/dist/{cjs → commonjs}/wire/text-encoding.js +0 -0
- /package/dist/{cjs → commonjs}/wire/text-format.d.ts +0 -0
- /package/dist/{cjs → commonjs}/wire/text-format.js +0 -0
- /package/dist/{cjs → commonjs}/wire/varint.d.ts +0 -0
- /package/dist/{cjs → commonjs}/wire/varint.js +0 -0
- /package/dist/{cjs → commonjs}/wkt/any.d.ts +0 -0
- /package/dist/{cjs → commonjs}/wkt/any.js +0 -0
- /package/dist/{cjs → commonjs}/wkt/duration.d.ts +0 -0
- /package/dist/{cjs → commonjs}/wkt/duration.js +0 -0
- /package/dist/{cjs → commonjs}/wkt/gen/google/protobuf/any_pb.d.ts +0 -0
- /package/dist/{cjs → commonjs}/wkt/gen/google/protobuf/any_pb.js +0 -0
- /package/dist/{cjs → commonjs}/wkt/gen/google/protobuf/api_pb.d.ts +0 -0
- /package/dist/{cjs → commonjs}/wkt/gen/google/protobuf/api_pb.js +0 -0
- /package/dist/{cjs → commonjs}/wkt/gen/google/protobuf/compiler/plugin_pb.d.ts +0 -0
- /package/dist/{cjs → commonjs}/wkt/gen/google/protobuf/compiler/plugin_pb.js +0 -0
- /package/dist/{cjs → commonjs}/wkt/gen/google/protobuf/cpp_features_pb.d.ts +0 -0
- /package/dist/{cjs → commonjs}/wkt/gen/google/protobuf/cpp_features_pb.js +0 -0
- /package/dist/{cjs → commonjs}/wkt/gen/google/protobuf/descriptor_pb.d.ts +0 -0
- /package/dist/{cjs → commonjs}/wkt/gen/google/protobuf/descriptor_pb.js +0 -0
- /package/dist/{cjs → commonjs}/wkt/gen/google/protobuf/duration_pb.d.ts +0 -0
- /package/dist/{cjs → commonjs}/wkt/gen/google/protobuf/duration_pb.js +0 -0
- /package/dist/{cjs → commonjs}/wkt/gen/google/protobuf/empty_pb.d.ts +0 -0
- /package/dist/{cjs → commonjs}/wkt/gen/google/protobuf/empty_pb.js +0 -0
- /package/dist/{cjs → commonjs}/wkt/gen/google/protobuf/field_mask_pb.d.ts +0 -0
- /package/dist/{cjs → commonjs}/wkt/gen/google/protobuf/field_mask_pb.js +0 -0
- /package/dist/{cjs → commonjs}/wkt/gen/google/protobuf/go_features_pb.d.ts +0 -0
- /package/dist/{cjs → commonjs}/wkt/gen/google/protobuf/go_features_pb.js +0 -0
- /package/dist/{cjs → commonjs}/wkt/gen/google/protobuf/java_features_pb.d.ts +0 -0
- /package/dist/{cjs → commonjs}/wkt/gen/google/protobuf/java_features_pb.js +0 -0
- /package/dist/{cjs → commonjs}/wkt/gen/google/protobuf/source_context_pb.d.ts +0 -0
- /package/dist/{cjs → commonjs}/wkt/gen/google/protobuf/source_context_pb.js +0 -0
- /package/dist/{cjs → commonjs}/wkt/gen/google/protobuf/struct_pb.d.ts +0 -0
- /package/dist/{cjs → commonjs}/wkt/gen/google/protobuf/struct_pb.js +0 -0
- /package/dist/{cjs → commonjs}/wkt/gen/google/protobuf/timestamp_pb.d.ts +0 -0
- /package/dist/{cjs → commonjs}/wkt/gen/google/protobuf/timestamp_pb.js +0 -0
- /package/dist/{cjs → commonjs}/wkt/gen/google/protobuf/type_pb.d.ts +0 -0
- /package/dist/{cjs → commonjs}/wkt/gen/google/protobuf/type_pb.js +0 -0
- /package/dist/{cjs → commonjs}/wkt/gen/google/protobuf/wrappers_pb.d.ts +0 -0
- /package/dist/{cjs → commonjs}/wkt/gen/google/protobuf/wrappers_pb.js +0 -0
- /package/dist/{cjs → commonjs}/wkt/index.d.ts +0 -0
- /package/dist/{cjs → commonjs}/wkt/index.js +0 -0
- /package/dist/{cjs → commonjs}/wkt/timestamp.d.ts +0 -0
- /package/dist/{cjs → commonjs}/wkt/timestamp.js +0 -0
- /package/dist/{cjs → commonjs}/wkt/wrappers.d.ts +0 -0
- /package/dist/{cjs → commonjs}/wkt/wrappers.js +0 -0
|
@@ -194,9 +194,11 @@ export declare class BinaryReader {
|
|
|
194
194
|
* Skip one element and return the skipped data.
|
|
195
195
|
*
|
|
196
196
|
* When skipping StartGroup, provide the tags field number to check for
|
|
197
|
-
* matching field number in the EndGroup tag.
|
|
197
|
+
* matching field number in the EndGroup tag. Recursion into nested groups
|
|
198
|
+
* is guarded by the `recursionLimit` argument: When the limit is reached,
|
|
199
|
+
* this method throws.
|
|
198
200
|
*/
|
|
199
|
-
skip(wireType: WireType, fieldNo?: number): Uint8Array;
|
|
201
|
+
skip(wireType: WireType, fieldNo?: number, recursionLimit?: number): Uint8Array;
|
|
200
202
|
protected varint64: () => [number, number];
|
|
201
203
|
/**
|
|
202
204
|
* Throws error if position in byte array is out of range.
|
|
@@ -324,9 +324,11 @@ export class BinaryReader {
|
|
|
324
324
|
* Skip one element and return the skipped data.
|
|
325
325
|
*
|
|
326
326
|
* When skipping StartGroup, provide the tags field number to check for
|
|
327
|
-
* matching field number in the EndGroup tag.
|
|
327
|
+
* matching field number in the EndGroup tag. Recursion into nested groups
|
|
328
|
+
* is guarded by the `recursionLimit` argument: When the limit is reached,
|
|
329
|
+
* this method throws.
|
|
328
330
|
*/
|
|
329
|
-
skip(wireType, fieldNo) {
|
|
331
|
+
skip(wireType, fieldNo, recursionLimit = 100) {
|
|
330
332
|
let start = this.pos;
|
|
331
333
|
switch (wireType) {
|
|
332
334
|
case WireType.Varint:
|
|
@@ -345,6 +347,9 @@ export class BinaryReader {
|
|
|
345
347
|
this.pos += len;
|
|
346
348
|
break;
|
|
347
349
|
case WireType.StartGroup:
|
|
350
|
+
if (recursionLimit <= 0) {
|
|
351
|
+
throw new Error("maximum recursion depth reached");
|
|
352
|
+
}
|
|
348
353
|
for (;;) {
|
|
349
354
|
const [fn, wt] = this.tag();
|
|
350
355
|
if (wt === WireType.EndGroup) {
|
|
@@ -353,7 +358,7 @@ export class BinaryReader {
|
|
|
353
358
|
}
|
|
354
359
|
break;
|
|
355
360
|
}
|
|
356
|
-
this.skip(wt, fn);
|
|
361
|
+
this.skip(wt, fn, recursionLimit - 1);
|
|
357
362
|
}
|
|
358
363
|
break;
|
|
359
364
|
default:
|
|
@@ -12,6 +12,20 @@ import type { BinaryReadOptions } from "../from-binary.js";
|
|
|
12
12
|
* For details, see https://github.com/protocolbuffers/protobuf/issues/10229
|
|
13
13
|
*/
|
|
14
14
|
export declare function sizeDelimitedEncode<Desc extends DescMessage>(messageDesc: Desc, message: MessageShape<Desc>, options?: BinaryWriteOptions): Uint8Array;
|
|
15
|
+
/**
|
|
16
|
+
* Options for parsing size-delimited messages from a stream.
|
|
17
|
+
*/
|
|
18
|
+
export interface SizeDelimitedDecodeOptions extends BinaryReadOptions {
|
|
19
|
+
/**
|
|
20
|
+
* Limit the size of a single message in the stream, in bytes.
|
|
21
|
+
*
|
|
22
|
+
* If a message in the stream declares a size exceeding this limit, an
|
|
23
|
+
* error is raised before the message is buffered.
|
|
24
|
+
*
|
|
25
|
+
* The default limit is 64 MiB.
|
|
26
|
+
*/
|
|
27
|
+
readMaxBytes: number;
|
|
28
|
+
}
|
|
15
29
|
/**
|
|
16
30
|
* Parse a stream of size-delimited messages.
|
|
17
31
|
*
|
|
@@ -20,8 +34,12 @@ export declare function sizeDelimitedEncode<Desc extends DescMessage>(messageDes
|
|
|
20
34
|
*
|
|
21
35
|
* This size-delimited format is compatible with other implementations.
|
|
22
36
|
* For details, see https://github.com/protocolbuffers/protobuf/issues/10229
|
|
37
|
+
*
|
|
38
|
+
* Messages exceeding the limit given with the option readMaxBytes raise an
|
|
39
|
+
* error. The limit is 64 MiB by default. All other options are the
|
|
40
|
+
* standard binary read options, passed through to decode each message.
|
|
23
41
|
*/
|
|
24
|
-
export declare function sizeDelimitedDecodeStream<Desc extends DescMessage>(messageDesc: Desc, iterable: AsyncIterable<Uint8Array>, options?:
|
|
42
|
+
export declare function sizeDelimitedDecodeStream<Desc extends DescMessage>(messageDesc: Desc, iterable: AsyncIterable<Uint8Array>, options?: Partial<SizeDelimitedDecodeOptions>): AsyncIterableIterator<MessageShape<Desc>>;
|
|
25
43
|
/**
|
|
26
44
|
* Decodes the size from the given size-delimited message, which may be
|
|
27
45
|
* incomplete.
|
|
@@ -48,6 +48,34 @@ export function sizeDelimitedEncode(messageDesc, message, options) {
|
|
|
48
48
|
writer.bytes(toBinary(messageDesc, message, options));
|
|
49
49
|
return writer.finish();
|
|
50
50
|
}
|
|
51
|
+
// Default for SizeDelimitedDecodeOptions.readMaxBytes.
|
|
52
|
+
const defaultReadMaxBytes = 64 * 1024 * 1024; // 64 MiB
|
|
53
|
+
/**
|
|
54
|
+
* A growable byte buffer. Used in place of a resizable ArrayBuffer, which is
|
|
55
|
+
* not widely available.
|
|
56
|
+
*/
|
|
57
|
+
class ByteBuffer {
|
|
58
|
+
constructor() {
|
|
59
|
+
this.buffer = new Uint8Array(0);
|
|
60
|
+
this.length = 0;
|
|
61
|
+
}
|
|
62
|
+
get byteLength() {
|
|
63
|
+
return this.length;
|
|
64
|
+
}
|
|
65
|
+
bytes() {
|
|
66
|
+
return this.buffer.subarray(0, this.length);
|
|
67
|
+
}
|
|
68
|
+
append(chunk) {
|
|
69
|
+
const newByteLength = this.length + chunk.byteLength;
|
|
70
|
+
if (newByteLength > this.buffer.byteLength) {
|
|
71
|
+
const grown = new Uint8Array(Math.max(this.buffer.byteLength * 2, newByteLength));
|
|
72
|
+
grown.set(this.buffer.subarray(0, this.length));
|
|
73
|
+
this.buffer = grown;
|
|
74
|
+
}
|
|
75
|
+
this.buffer.set(chunk, this.length);
|
|
76
|
+
this.length += chunk.byteLength;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
51
79
|
/**
|
|
52
80
|
* Parse a stream of size-delimited messages.
|
|
53
81
|
*
|
|
@@ -56,43 +84,53 @@ export function sizeDelimitedEncode(messageDesc, message, options) {
|
|
|
56
84
|
*
|
|
57
85
|
* This size-delimited format is compatible with other implementations.
|
|
58
86
|
* For details, see https://github.com/protocolbuffers/protobuf/issues/10229
|
|
87
|
+
*
|
|
88
|
+
* Messages exceeding the limit given with the option readMaxBytes raise an
|
|
89
|
+
* error. The limit is 64 MiB by default. All other options are the
|
|
90
|
+
* standard binary read options, passed through to decode each message.
|
|
59
91
|
*/
|
|
60
92
|
export function sizeDelimitedDecodeStream(messageDesc, iterable, options) {
|
|
61
93
|
return __asyncGenerator(this, arguments, function* sizeDelimitedDecodeStream_1() {
|
|
62
94
|
var _a, e_1, _b, _c;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
n.set(buffer);
|
|
67
|
-
n.set(chunk, buffer.length);
|
|
68
|
-
return n;
|
|
69
|
-
}
|
|
70
|
-
let buffer = new Uint8Array(0);
|
|
95
|
+
var _d;
|
|
96
|
+
const readMaxBytes = (_d = options === null || options === void 0 ? void 0 : options.readMaxBytes) !== null && _d !== void 0 ? _d : defaultReadMaxBytes;
|
|
97
|
+
let buffer = new ByteBuffer();
|
|
71
98
|
try {
|
|
72
|
-
for (var
|
|
99
|
+
for (var _e = true, iterable_1 = __asyncValues(iterable), iterable_1_1; iterable_1_1 = yield __await(iterable_1.next()), _a = iterable_1_1.done, !_a; _e = true) {
|
|
73
100
|
_c = iterable_1_1.value;
|
|
74
|
-
|
|
101
|
+
_e = false;
|
|
75
102
|
const chunk = _c;
|
|
76
|
-
buffer
|
|
103
|
+
buffer.append(chunk);
|
|
104
|
+
const bytes = buffer.bytes();
|
|
105
|
+
let offset = 0;
|
|
77
106
|
for (;;) {
|
|
78
|
-
const size = sizeDelimitedPeek(
|
|
107
|
+
const size = sizeDelimitedPeek(bytes.subarray(offset));
|
|
79
108
|
if (size.eof) {
|
|
80
109
|
// size is incomplete, buffer more data
|
|
81
110
|
break;
|
|
82
111
|
}
|
|
83
|
-
if (size.
|
|
112
|
+
if (size.size > readMaxBytes) {
|
|
113
|
+
throw new Error(`message size ${size.size} is larger than configured readMaxBytes ${readMaxBytes}`);
|
|
114
|
+
}
|
|
115
|
+
const messageStart = offset + size.offset;
|
|
116
|
+
const messageEnd = messageStart + size.size;
|
|
117
|
+
if (messageEnd > bytes.byteLength) {
|
|
84
118
|
// message is incomplete, buffer more data
|
|
85
119
|
break;
|
|
86
120
|
}
|
|
87
|
-
yield yield __await(fromBinary(messageDesc,
|
|
88
|
-
|
|
121
|
+
yield yield __await(fromBinary(messageDesc, bytes.subarray(messageStart, messageEnd), options));
|
|
122
|
+
offset = messageEnd;
|
|
123
|
+
}
|
|
124
|
+
if (offset > 0) {
|
|
125
|
+
buffer = new ByteBuffer();
|
|
126
|
+
buffer.append(bytes.subarray(offset));
|
|
89
127
|
}
|
|
90
128
|
}
|
|
91
129
|
}
|
|
92
130
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
93
131
|
finally {
|
|
94
132
|
try {
|
|
95
|
-
if (!
|
|
133
|
+
if (!_e && !_a && (_b = iterable_1.return)) yield __await(_b.call(iterable_1));
|
|
96
134
|
}
|
|
97
135
|
finally { if (e_1) throw e_1.error; }
|
|
98
136
|
}
|
package/package.json
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bufbuild/protobuf",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.13.0",
|
|
4
4
|
"license": "(Apache-2.0 AND BSD-3-Clause)",
|
|
5
|
-
"description": "
|
|
6
|
-
"keywords": [
|
|
5
|
+
"description": "Protocol Buffers for ECMAScript. The only JavaScript Protobuf library that is fully-compliant with Protobuf conformance tests.",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"protobuf",
|
|
8
|
+
"schema",
|
|
9
|
+
"typescript",
|
|
10
|
+
"ecmascript"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://protobufes.com/",
|
|
7
13
|
"repository": {
|
|
8
14
|
"type": "git",
|
|
9
15
|
"url": "https://github.com/bufbuild/protobuf-es.git",
|
|
10
16
|
"directory": "packages/protobuf"
|
|
11
17
|
},
|
|
12
18
|
"scripts": {
|
|
13
|
-
"
|
|
14
|
-
"build": "npm run build:cjs && npm run build:esm",
|
|
15
|
-
"build:cjs": "../../node_modules/typescript/bin/tsc --project tsconfig.json --module commonjs --verbatimModuleSyntax false --moduleResolution node10 --outDir ./dist/cjs && echo >./dist/cjs/package.json '{\"type\":\"commonjs\"}'",
|
|
16
|
-
"build:esm": "../../node_modules/typescript/bin/tsc --project tsconfig.json --outDir ./dist/esm",
|
|
19
|
+
"build": "tshy",
|
|
17
20
|
"bootstrap": "npm run bootstrap:inject && npm run bootstrap:wkt",
|
|
18
21
|
"bootstrap:inject": "node scripts/bootstrap-inject.mjs src",
|
|
19
22
|
"bootstrap:wkt": "protoc --es_out=src/wkt/gen --es_opt=bootstrap_wkt=true,target=ts,import_extension=js,json_types=true --proto_path $(upstream-include wkt) $(upstream-files wkt)",
|
|
@@ -25,44 +28,120 @@
|
|
|
25
28
|
},
|
|
26
29
|
"type": "module",
|
|
27
30
|
"sideEffects": false,
|
|
28
|
-
"
|
|
31
|
+
"tshy": {
|
|
32
|
+
"selfLink": false,
|
|
33
|
+
"exports": {
|
|
34
|
+
".": "./src/index.ts",
|
|
35
|
+
"./codegenv1": "./src/codegenv1/index.ts",
|
|
36
|
+
"./codegenv2": "./src/codegenv2/index.ts",
|
|
37
|
+
"./reflect": "./src/reflect/index.ts",
|
|
38
|
+
"./wkt": "./src/wkt/index.ts",
|
|
39
|
+
"./wire": "./src/wire/index.ts",
|
|
40
|
+
"./txtpb": "./src/txtpb/index.ts"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"tshy": "^4.1.3",
|
|
45
|
+
"upstream-protobuf": "*"
|
|
46
|
+
},
|
|
47
|
+
"files": [
|
|
48
|
+
"dist/**"
|
|
49
|
+
],
|
|
29
50
|
"exports": {
|
|
30
51
|
".": {
|
|
31
|
-
"import":
|
|
32
|
-
|
|
52
|
+
"import": {
|
|
53
|
+
"types": "./dist/esm/index.d.ts",
|
|
54
|
+
"default": "./dist/esm/index.js"
|
|
55
|
+
},
|
|
56
|
+
"require": {
|
|
57
|
+
"types": "./dist/commonjs/index.d.ts",
|
|
58
|
+
"default": "./dist/commonjs/index.js"
|
|
59
|
+
}
|
|
33
60
|
},
|
|
34
61
|
"./codegenv1": {
|
|
35
|
-
"import":
|
|
36
|
-
|
|
62
|
+
"import": {
|
|
63
|
+
"types": "./dist/esm/codegenv1/index.d.ts",
|
|
64
|
+
"default": "./dist/esm/codegenv1/index.js"
|
|
65
|
+
},
|
|
66
|
+
"require": {
|
|
67
|
+
"types": "./dist/commonjs/codegenv1/index.d.ts",
|
|
68
|
+
"default": "./dist/commonjs/codegenv1/index.js"
|
|
69
|
+
}
|
|
37
70
|
},
|
|
38
71
|
"./codegenv2": {
|
|
39
|
-
"import":
|
|
40
|
-
|
|
72
|
+
"import": {
|
|
73
|
+
"types": "./dist/esm/codegenv2/index.d.ts",
|
|
74
|
+
"default": "./dist/esm/codegenv2/index.js"
|
|
75
|
+
},
|
|
76
|
+
"require": {
|
|
77
|
+
"types": "./dist/commonjs/codegenv2/index.d.ts",
|
|
78
|
+
"default": "./dist/commonjs/codegenv2/index.js"
|
|
79
|
+
}
|
|
41
80
|
},
|
|
42
81
|
"./reflect": {
|
|
43
|
-
"import":
|
|
44
|
-
|
|
82
|
+
"import": {
|
|
83
|
+
"types": "./dist/esm/reflect/index.d.ts",
|
|
84
|
+
"default": "./dist/esm/reflect/index.js"
|
|
85
|
+
},
|
|
86
|
+
"require": {
|
|
87
|
+
"types": "./dist/commonjs/reflect/index.d.ts",
|
|
88
|
+
"default": "./dist/commonjs/reflect/index.js"
|
|
89
|
+
}
|
|
45
90
|
},
|
|
46
91
|
"./wkt": {
|
|
47
|
-
"import":
|
|
48
|
-
|
|
92
|
+
"import": {
|
|
93
|
+
"types": "./dist/esm/wkt/index.d.ts",
|
|
94
|
+
"default": "./dist/esm/wkt/index.js"
|
|
95
|
+
},
|
|
96
|
+
"require": {
|
|
97
|
+
"types": "./dist/commonjs/wkt/index.d.ts",
|
|
98
|
+
"default": "./dist/commonjs/wkt/index.js"
|
|
99
|
+
}
|
|
49
100
|
},
|
|
50
101
|
"./wire": {
|
|
51
|
-
"import":
|
|
52
|
-
|
|
102
|
+
"import": {
|
|
103
|
+
"types": "./dist/esm/wire/index.d.ts",
|
|
104
|
+
"default": "./dist/esm/wire/index.js"
|
|
105
|
+
},
|
|
106
|
+
"require": {
|
|
107
|
+
"types": "./dist/commonjs/wire/index.d.ts",
|
|
108
|
+
"default": "./dist/commonjs/wire/index.js"
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
"./txtpb": {
|
|
112
|
+
"import": {
|
|
113
|
+
"types": "./dist/esm/txtpb/index.d.ts",
|
|
114
|
+
"default": "./dist/esm/txtpb/index.js"
|
|
115
|
+
},
|
|
116
|
+
"require": {
|
|
117
|
+
"types": "./dist/commonjs/txtpb/index.d.ts",
|
|
118
|
+
"default": "./dist/commonjs/txtpb/index.js"
|
|
119
|
+
}
|
|
53
120
|
}
|
|
54
121
|
},
|
|
122
|
+
"main": "./dist/commonjs/index.js",
|
|
123
|
+
"types": "./dist/commonjs/index.d.ts",
|
|
124
|
+
"module": "./dist/esm/index.js",
|
|
55
125
|
"typesVersions": {
|
|
56
126
|
"*": {
|
|
57
|
-
"codegenv1": [
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"
|
|
61
|
-
|
|
127
|
+
"codegenv1": [
|
|
128
|
+
"./dist/commonjs/codegenv1/index.d.ts"
|
|
129
|
+
],
|
|
130
|
+
"codegenv2": [
|
|
131
|
+
"./dist/commonjs/codegenv2/index.d.ts"
|
|
132
|
+
],
|
|
133
|
+
"reflect": [
|
|
134
|
+
"./dist/commonjs/reflect/index.d.ts"
|
|
135
|
+
],
|
|
136
|
+
"wkt": [
|
|
137
|
+
"./dist/commonjs/wkt/index.d.ts"
|
|
138
|
+
],
|
|
139
|
+
"wire": [
|
|
140
|
+
"./dist/commonjs/wire/index.d.ts"
|
|
141
|
+
],
|
|
142
|
+
"txtpb": [
|
|
143
|
+
"./dist/commonjs/txtpb/index.d.ts"
|
|
144
|
+
]
|
|
62
145
|
}
|
|
63
|
-
}
|
|
64
|
-
"devDependencies": {
|
|
65
|
-
"upstream-protobuf": "*"
|
|
66
|
-
},
|
|
67
|
-
"files": ["dist/**"]
|
|
146
|
+
}
|
|
68
147
|
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { DescEnum, DescFile } from "../descriptors.js";
|
|
2
|
-
import type { GenEnum } from "./types.js";
|
|
3
|
-
import type { JsonValue } from "../json-value.js";
|
|
4
|
-
/**
|
|
5
|
-
* Hydrate an enum descriptor.
|
|
6
|
-
*
|
|
7
|
-
* @private
|
|
8
|
-
*/
|
|
9
|
-
export declare function enumDesc<Shape extends number, JsonType extends JsonValue = JsonValue>(file: DescFile, path: number, ...paths: number[]): GenEnum<Shape, JsonType>;
|
|
10
|
-
/**
|
|
11
|
-
* Construct a TypeScript enum object at runtime from a descriptor.
|
|
12
|
-
*/
|
|
13
|
-
export declare function tsEnum(desc: DescEnum): enumObject;
|
|
14
|
-
type enumObject = {
|
|
15
|
-
[key: number]: string;
|
|
16
|
-
[k: string]: number | string;
|
|
17
|
-
};
|
|
18
|
-
export {};
|
package/dist/cjs/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"commonjs"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ScalarType } from "../descriptors.js";
|
|
2
|
-
/**
|
|
3
|
-
* ScalarValue maps from a scalar field type to a TypeScript value type.
|
|
4
|
-
*/
|
|
5
|
-
export type ScalarValue<T = ScalarType, LongAsString extends boolean = false> = T extends ScalarType.STRING ? string : T extends ScalarType.INT32 ? number : T extends ScalarType.UINT32 ? number : T extends ScalarType.SINT32 ? number : T extends ScalarType.FIXED32 ? number : T extends ScalarType.SFIXED32 ? number : T extends ScalarType.FLOAT ? number : T extends ScalarType.DOUBLE ? number : T extends ScalarType.INT64 ? LongAsString extends true ? string : bigint : T extends ScalarType.SINT64 ? LongAsString extends true ? string : bigint : T extends ScalarType.SFIXED64 ? LongAsString extends true ? string : bigint : T extends ScalarType.UINT64 ? LongAsString extends true ? string : bigint : T extends ScalarType.FIXED64 ? LongAsString extends true ? string : bigint : T extends ScalarType.BOOL ? boolean : T extends ScalarType.BYTES ? Uint8Array : never;
|
|
6
|
-
/**
|
|
7
|
-
* Returns true if both scalar values are equal.
|
|
8
|
-
*/
|
|
9
|
-
export declare function scalarEquals(type: ScalarType, a: ScalarValue | undefined, b: ScalarValue | undefined): boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Returns the zero value for the given scalar type.
|
|
12
|
-
*/
|
|
13
|
-
export declare function scalarZeroValue<T extends ScalarType, LongAsString extends boolean>(type: T, longAsString: LongAsString): ScalarValue<T, LongAsString>;
|
|
14
|
-
/**
|
|
15
|
-
* Returns true for a zero-value. For example, an integer has the zero-value `0`,
|
|
16
|
-
* a boolean is `false`, a string is `""`, and bytes is an empty Uint8Array.
|
|
17
|
-
*
|
|
18
|
-
* In proto3, zero-values are not written to the wire, unless the field is
|
|
19
|
-
* optional or repeated.
|
|
20
|
-
*/
|
|
21
|
-
export declare function isScalarZeroValue(type: ScalarType, value: unknown): boolean;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|