@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
|
@@ -13,10 +13,3 @@
|
|
|
13
13
|
// See the License for the specific language governing permissions and
|
|
14
14
|
// limitations under the License.
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
class brandv2 {
|
|
17
|
-
constructor() {
|
|
18
|
-
this.v = "codegenv2";
|
|
19
|
-
this.a = false;
|
|
20
|
-
this.b = false;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DescEnum } from "./descriptors.js";
|
|
2
|
+
import type { UnknownEnum } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Open enums can contain numeric values that are not in the set of values
|
|
5
|
+
* defined by the enum.
|
|
6
|
+
*
|
|
7
|
+
* This function returns true for those values, and narrows the type to
|
|
8
|
+
* `UnknownEnum`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function isUnknownEnum(desc: DescEnum, value: number): value is UnknownEnum;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2021-2026 Buf Technologies, Inc.
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// you may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
//
|
|
8
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.isUnknownEnum = isUnknownEnum;
|
|
17
|
+
/**
|
|
18
|
+
* Open enums can contain numeric values that are not in the set of values
|
|
19
|
+
* defined by the enum.
|
|
20
|
+
*
|
|
21
|
+
* This function returns true for those values, and narrows the type to
|
|
22
|
+
* `UnknownEnum`.
|
|
23
|
+
*/
|
|
24
|
+
function isUnknownEnum(desc, value) {
|
|
25
|
+
return desc.value[value] === undefined;
|
|
26
|
+
}
|
|
@@ -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.
|
|
@@ -328,9 +328,11 @@ class BinaryReader {
|
|
|
328
328
|
* Skip one element and return the skipped data.
|
|
329
329
|
*
|
|
330
330
|
* When skipping StartGroup, provide the tags field number to check for
|
|
331
|
-
* matching field number in the EndGroup tag.
|
|
331
|
+
* matching field number in the EndGroup tag. Recursion into nested groups
|
|
332
|
+
* is guarded by the `recursionLimit` argument: When the limit is reached,
|
|
333
|
+
* this method throws.
|
|
332
334
|
*/
|
|
333
|
-
skip(wireType, fieldNo) {
|
|
335
|
+
skip(wireType, fieldNo, recursionLimit = 100) {
|
|
334
336
|
let start = this.pos;
|
|
335
337
|
switch (wireType) {
|
|
336
338
|
case WireType.Varint:
|
|
@@ -349,6 +351,9 @@ class BinaryReader {
|
|
|
349
351
|
this.pos += len;
|
|
350
352
|
break;
|
|
351
353
|
case WireType.StartGroup:
|
|
354
|
+
if (recursionLimit <= 0) {
|
|
355
|
+
throw new Error("maximum recursion depth reached");
|
|
356
|
+
}
|
|
352
357
|
for (;;) {
|
|
353
358
|
const [fn, wt] = this.tag();
|
|
354
359
|
if (wt === WireType.EndGroup) {
|
|
@@ -357,7 +362,7 @@ class BinaryReader {
|
|
|
357
362
|
}
|
|
358
363
|
break;
|
|
359
364
|
}
|
|
360
|
-
this.skip(wt, fn);
|
|
365
|
+
this.skip(wt, fn, recursionLimit - 1);
|
|
361
366
|
}
|
|
362
367
|
break;
|
|
363
368
|
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.
|
|
@@ -53,6 +53,34 @@ function sizeDelimitedEncode(messageDesc, message, options) {
|
|
|
53
53
|
writer.bytes((0, to_binary_js_1.toBinary)(messageDesc, message, options));
|
|
54
54
|
return writer.finish();
|
|
55
55
|
}
|
|
56
|
+
// Default for SizeDelimitedDecodeOptions.readMaxBytes.
|
|
57
|
+
const defaultReadMaxBytes = 64 * 1024 * 1024; // 64 MiB
|
|
58
|
+
/**
|
|
59
|
+
* A growable byte buffer. Used in place of a resizable ArrayBuffer, which is
|
|
60
|
+
* not widely available.
|
|
61
|
+
*/
|
|
62
|
+
class ByteBuffer {
|
|
63
|
+
constructor() {
|
|
64
|
+
this.buffer = new Uint8Array(0);
|
|
65
|
+
this.length = 0;
|
|
66
|
+
}
|
|
67
|
+
get byteLength() {
|
|
68
|
+
return this.length;
|
|
69
|
+
}
|
|
70
|
+
bytes() {
|
|
71
|
+
return this.buffer.subarray(0, this.length);
|
|
72
|
+
}
|
|
73
|
+
append(chunk) {
|
|
74
|
+
const newByteLength = this.length + chunk.byteLength;
|
|
75
|
+
if (newByteLength > this.buffer.byteLength) {
|
|
76
|
+
const grown = new Uint8Array(Math.max(this.buffer.byteLength * 2, newByteLength));
|
|
77
|
+
grown.set(this.buffer.subarray(0, this.length));
|
|
78
|
+
this.buffer = grown;
|
|
79
|
+
}
|
|
80
|
+
this.buffer.set(chunk, this.length);
|
|
81
|
+
this.length += chunk.byteLength;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
56
84
|
/**
|
|
57
85
|
* Parse a stream of size-delimited messages.
|
|
58
86
|
*
|
|
@@ -61,43 +89,53 @@ function sizeDelimitedEncode(messageDesc, message, options) {
|
|
|
61
89
|
*
|
|
62
90
|
* This size-delimited format is compatible with other implementations.
|
|
63
91
|
* For details, see https://github.com/protocolbuffers/protobuf/issues/10229
|
|
92
|
+
*
|
|
93
|
+
* Messages exceeding the limit given with the option readMaxBytes raise an
|
|
94
|
+
* error. The limit is 64 MiB by default. All other options are the
|
|
95
|
+
* standard binary read options, passed through to decode each message.
|
|
64
96
|
*/
|
|
65
97
|
function sizeDelimitedDecodeStream(messageDesc, iterable, options) {
|
|
66
98
|
return __asyncGenerator(this, arguments, function* sizeDelimitedDecodeStream_1() {
|
|
67
99
|
var _a, e_1, _b, _c;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
n.set(buffer);
|
|
72
|
-
n.set(chunk, buffer.length);
|
|
73
|
-
return n;
|
|
74
|
-
}
|
|
75
|
-
let buffer = new Uint8Array(0);
|
|
100
|
+
var _d;
|
|
101
|
+
const readMaxBytes = (_d = options === null || options === void 0 ? void 0 : options.readMaxBytes) !== null && _d !== void 0 ? _d : defaultReadMaxBytes;
|
|
102
|
+
let buffer = new ByteBuffer();
|
|
76
103
|
try {
|
|
77
|
-
for (var
|
|
104
|
+
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) {
|
|
78
105
|
_c = iterable_1_1.value;
|
|
79
|
-
|
|
106
|
+
_e = false;
|
|
80
107
|
const chunk = _c;
|
|
81
|
-
buffer
|
|
108
|
+
buffer.append(chunk);
|
|
109
|
+
const bytes = buffer.bytes();
|
|
110
|
+
let offset = 0;
|
|
82
111
|
for (;;) {
|
|
83
|
-
const size = sizeDelimitedPeek(
|
|
112
|
+
const size = sizeDelimitedPeek(bytes.subarray(offset));
|
|
84
113
|
if (size.eof) {
|
|
85
114
|
// size is incomplete, buffer more data
|
|
86
115
|
break;
|
|
87
116
|
}
|
|
88
|
-
if (size.
|
|
117
|
+
if (size.size > readMaxBytes) {
|
|
118
|
+
throw new Error(`message size ${size.size} is larger than configured readMaxBytes ${readMaxBytes}`);
|
|
119
|
+
}
|
|
120
|
+
const messageStart = offset + size.offset;
|
|
121
|
+
const messageEnd = messageStart + size.size;
|
|
122
|
+
if (messageEnd > bytes.byteLength) {
|
|
89
123
|
// message is incomplete, buffer more data
|
|
90
124
|
break;
|
|
91
125
|
}
|
|
92
|
-
yield yield __await((0, from_binary_js_1.fromBinary)(messageDesc,
|
|
93
|
-
|
|
126
|
+
yield yield __await((0, from_binary_js_1.fromBinary)(messageDesc, bytes.subarray(messageStart, messageEnd), options));
|
|
127
|
+
offset = messageEnd;
|
|
128
|
+
}
|
|
129
|
+
if (offset > 0) {
|
|
130
|
+
buffer = new ByteBuffer();
|
|
131
|
+
buffer.append(bytes.subarray(offset));
|
|
94
132
|
}
|
|
95
133
|
}
|
|
96
134
|
}
|
|
97
135
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
98
136
|
finally {
|
|
99
137
|
try {
|
|
100
|
-
if (!
|
|
138
|
+
if (!_e && !_a && (_b = iterable_1.return)) yield __await(_b.call(iterable_1));
|
|
101
139
|
}
|
|
102
140
|
finally { if (e_1) throw e_1.error; }
|
|
103
141
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { boot } from "../codegenv2/boot.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Copyright 2021-2026 Buf Technologies, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
export { boot } from "../codegenv2/boot.js";
|
|
@@ -132,4 +132,9 @@ export declare const symbols: {
|
|
|
132
132
|
readonly bootstrapWktFrom: "../../json-value.js";
|
|
133
133
|
readonly from: "@bufbuild/protobuf";
|
|
134
134
|
};
|
|
135
|
+
readonly UnknownEnum: {
|
|
136
|
+
readonly typeOnly: true;
|
|
137
|
+
readonly bootstrapWktFrom: "../../types.js";
|
|
138
|
+
readonly from: "@bufbuild/protobuf";
|
|
139
|
+
};
|
|
135
140
|
};
|
|
@@ -56,11 +56,15 @@ export type GenService<RuntimeShape extends GenServiceMethods> = Omit<DescServic
|
|
|
56
56
|
* @private
|
|
57
57
|
*/
|
|
58
58
|
export type GenServiceMethods = Record<string, Pick<DescMethod, "input" | "output" | "methodKind">>;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
type brandv1<A, B = unknown> = {
|
|
60
|
+
/**
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
readonly $codegenv1: {
|
|
64
|
+
a: A;
|
|
65
|
+
b: B;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
64
68
|
/**
|
|
65
69
|
* Union of the property names of all fields, including oneof members.
|
|
66
70
|
* For an anonymous message (no generated message shape), it's simply a string.
|
|
@@ -11,11 +11,4 @@
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
-
class brandv1 {
|
|
15
|
-
constructor() {
|
|
16
|
-
this.v = "codegenv1";
|
|
17
|
-
this.a = false;
|
|
18
|
-
this.b = false;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
14
|
export {};
|
|
@@ -9,10 +9,21 @@ import type { JsonValue } from "../json-value.js";
|
|
|
9
9
|
export declare function enumDesc<Shape extends number, JsonType extends JsonValue = JsonValue>(file: DescFile, path: number, ...paths: number[]): GenEnum<Shape, JsonType>;
|
|
10
10
|
/**
|
|
11
11
|
* Construct a TypeScript enum object at runtime from a descriptor.
|
|
12
|
+
*
|
|
13
|
+
* The returned object is identical to a transpiled TS enum and includes the
|
|
14
|
+
* reverse mapping, see https://www.typescriptlang.org/docs/handbook/enums.html#reverse-mappings
|
|
12
15
|
*/
|
|
13
|
-
export declare function tsEnum(desc: DescEnum):
|
|
14
|
-
type enumObject = {
|
|
16
|
+
export declare function tsEnum(desc: DescEnum): {
|
|
15
17
|
[key: number]: string;
|
|
16
|
-
[k: string]:
|
|
18
|
+
[k: string]: string | number;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Construct an object enum at runtime from a descriptor.
|
|
22
|
+
*
|
|
23
|
+
* The returned object is a record of enum value name to integer value. It's
|
|
24
|
+
* a subset of transpiled TS enums - it does not include the reverse mapping,
|
|
25
|
+
* and only supports lookup by value name.
|
|
26
|
+
*/
|
|
27
|
+
export declare function objEnum(desc: DescEnum): {
|
|
28
|
+
[key: string]: number;
|
|
17
29
|
};
|
|
18
|
-
export {};
|
|
@@ -25,6 +25,9 @@ export function enumDesc(file, path, ...paths) {
|
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* Construct a TypeScript enum object at runtime from a descriptor.
|
|
28
|
+
*
|
|
29
|
+
* The returned object is identical to a transpiled TS enum and includes the
|
|
30
|
+
* reverse mapping, see https://www.typescriptlang.org/docs/handbook/enums.html#reverse-mappings
|
|
28
31
|
*/
|
|
29
32
|
export function tsEnum(desc) {
|
|
30
33
|
const enumObject = {};
|
|
@@ -34,3 +37,17 @@ export function tsEnum(desc) {
|
|
|
34
37
|
}
|
|
35
38
|
return enumObject;
|
|
36
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Construct an object enum at runtime from a descriptor.
|
|
42
|
+
*
|
|
43
|
+
* The returned object is a record of enum value name to integer value. It's
|
|
44
|
+
* a subset of transpiled TS enums - it does not include the reverse mapping,
|
|
45
|
+
* and only supports lookup by value name.
|
|
46
|
+
*/
|
|
47
|
+
export function objEnum(desc) {
|
|
48
|
+
const enumObject = {};
|
|
49
|
+
for (const value of desc.values) {
|
|
50
|
+
enumObject[value.localName] = value.number;
|
|
51
|
+
}
|
|
52
|
+
return enumObject;
|
|
53
|
+
}
|
|
@@ -70,6 +70,11 @@ export declare const symbols: {
|
|
|
70
70
|
readonly bootstrapWktFrom: "../../json-value.js";
|
|
71
71
|
readonly from: "@bufbuild/protobuf";
|
|
72
72
|
};
|
|
73
|
+
readonly UnknownEnum: {
|
|
74
|
+
readonly typeOnly: true;
|
|
75
|
+
readonly bootstrapWktFrom: "../../types.js";
|
|
76
|
+
readonly from: "@bufbuild/protobuf";
|
|
77
|
+
};
|
|
73
78
|
readonly codegen: {
|
|
74
79
|
readonly boot: {
|
|
75
80
|
readonly typeOnly: false;
|
|
@@ -106,6 +111,11 @@ export declare const symbols: {
|
|
|
106
111
|
readonly bootstrapWktFrom: "../../codegenv2/enum.js";
|
|
107
112
|
readonly from: string;
|
|
108
113
|
};
|
|
114
|
+
readonly objEnum: {
|
|
115
|
+
readonly typeOnly: false;
|
|
116
|
+
readonly bootstrapWktFrom: "../../codegenv2/enum.js";
|
|
117
|
+
readonly from: string;
|
|
118
|
+
};
|
|
109
119
|
readonly GenFile: {
|
|
110
120
|
readonly typeOnly: true;
|
|
111
121
|
readonly bootstrapWktFrom: "../../codegenv2/types.js";
|
|
@@ -52,6 +52,7 @@ export const symbols = {
|
|
|
52
52
|
protoInt64: { typeOnly: false, bootstrapWktFrom: "../../proto-int64.js", from: packageName },
|
|
53
53
|
JsonValue: { typeOnly: true, bootstrapWktFrom: "../../json-value.js", from: packageName },
|
|
54
54
|
JsonObject: { typeOnly: true, bootstrapWktFrom: "../../json-value.js", from: packageName },
|
|
55
|
+
UnknownEnum: { typeOnly: true, bootstrapWktFrom: "../../types.js", from: packageName },
|
|
55
56
|
codegen: {
|
|
56
57
|
boot: { typeOnly: false, bootstrapWktFrom: "../../codegenv2/boot.js", from: packageName + "/codegenv2" },
|
|
57
58
|
fileDesc: { typeOnly: false, bootstrapWktFrom: "../../codegenv2/file.js", from: packageName + "/codegenv2" },
|
|
@@ -60,6 +61,7 @@ export const symbols = {
|
|
|
60
61
|
messageDesc: { typeOnly: false, bootstrapWktFrom: "../../codegenv2/message.js", from: packageName + "/codegenv2" },
|
|
61
62
|
serviceDesc: { typeOnly: false, bootstrapWktFrom: "../../codegenv2/service.js", from: packageName + "/codegenv2" },
|
|
62
63
|
tsEnum: { typeOnly: false, bootstrapWktFrom: "../../codegenv2/enum.js", from: packageName + "/codegenv2" },
|
|
64
|
+
objEnum: { typeOnly: false, bootstrapWktFrom: "../../codegenv2/enum.js", from: packageName + "/codegenv2" },
|
|
63
65
|
GenFile: { typeOnly: true, bootstrapWktFrom: "../../codegenv2/types.js", from: packageName + "/codegenv2" },
|
|
64
66
|
GenEnum: { typeOnly: true, bootstrapWktFrom: "../../codegenv2/types.js", from: packageName + "/codegenv2" },
|
|
65
67
|
GenExtension: { typeOnly: true, bootstrapWktFrom: "../../codegenv2/types.js", from: packageName + "/codegenv2" },
|
|
@@ -62,11 +62,15 @@ export type GenService<RuntimeShape extends GenServiceMethods> = Omit<DescServic
|
|
|
62
62
|
* @private
|
|
63
63
|
*/
|
|
64
64
|
export type GenServiceMethods = Record<string, Pick<DescMethod, "input" | "output" | "methodKind">>;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
type brandv2<A, B = unknown> = {
|
|
66
|
+
/**
|
|
67
|
+
* @internal
|
|
68
|
+
*/
|
|
69
|
+
readonly $codegenv2: {
|
|
70
|
+
a: A;
|
|
71
|
+
b: B;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
70
74
|
/**
|
|
71
75
|
* Union of the property names of all fields, including oneof members.
|
|
72
76
|
* For an anonymous message (no generated message shape), it's simply a string.
|
|
@@ -11,11 +11,4 @@
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
-
class brandv2 {
|
|
15
|
-
constructor() {
|
|
16
|
-
this.v = "codegenv2";
|
|
17
|
-
this.a = false;
|
|
18
|
-
this.b = false;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
14
|
export {};
|
package/dist/esm/create.js
CHANGED
|
@@ -17,11 +17,11 @@ import { scalarZeroValue } from "./reflect/scalar.js";
|
|
|
17
17
|
import { isObject } from "./reflect/guard.js";
|
|
18
18
|
import { unsafeGet, unsafeOneofCase, unsafeSet } from "./reflect/unsafe.js";
|
|
19
19
|
import { isWrapperDesc } from "./wkt/wrappers.js";
|
|
20
|
-
// bootstrap-inject google.protobuf.Edition.EDITION_PROTO3: const $name
|
|
20
|
+
// bootstrap-inject google.protobuf.Edition.EDITION_PROTO3: const $name = $number;
|
|
21
21
|
const EDITION_PROTO3 = 999;
|
|
22
|
-
// bootstrap-inject google.protobuf.Edition.EDITION_PROTO2: const $name
|
|
22
|
+
// bootstrap-inject google.protobuf.Edition.EDITION_PROTO2: const $name = $number;
|
|
23
23
|
const EDITION_PROTO2 = 998;
|
|
24
|
-
// bootstrap-inject google.protobuf.FeatureSet.FieldPresence.IMPLICIT: const $name
|
|
24
|
+
// bootstrap-inject google.protobuf.FeatureSet.FieldPresence.IMPLICIT: const $name = $number;
|
|
25
25
|
const IMPLICIT = 2;
|
|
26
26
|
/**
|
|
27
27
|
* Create a new message instance.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DescriptorProto, Edition, EnumDescriptorProto, EnumValueDescriptorProto, FeatureSet_FieldPresence, FieldDescriptorProto, FileDescriptorProto, MethodDescriptorProto, MethodOptions_IdempotencyLevel, OneofDescriptorProto, ServiceDescriptorProto } from "./wkt/gen/google/protobuf/descriptor_pb.js";
|
|
2
2
|
import type { ScalarValue } from "./reflect/scalar.js";
|
|
3
|
-
export type SupportedEdition = Extract<Edition, Edition.EDITION_PROTO2 | Edition.EDITION_PROTO3 | Edition.EDITION_2023 | Edition.EDITION_2024>;
|
|
4
|
-
type SupportedFieldPresence = Extract<FeatureSet_FieldPresence, FeatureSet_FieldPresence.EXPLICIT | FeatureSet_FieldPresence.IMPLICIT | FeatureSet_FieldPresence.LEGACY_REQUIRED>;
|
|
3
|
+
export type SupportedEdition = Extract<Edition, typeof Edition.EDITION_PROTO2 | typeof Edition.EDITION_PROTO3 | typeof Edition.EDITION_2023 | typeof Edition.EDITION_2024>;
|
|
4
|
+
type SupportedFieldPresence = Extract<FeatureSet_FieldPresence, typeof FeatureSet_FieldPresence.EXPLICIT | typeof FeatureSet_FieldPresence.IMPLICIT | typeof FeatureSet_FieldPresence.LEGACY_REQUIRED>;
|
|
5
5
|
/**
|
|
6
6
|
* Scalar value types. This is a subset of field types declared by protobuf
|
|
7
7
|
* enum google.protobuf.FieldDescriptorProto.Type The types GROUP and MESSAGE
|
package/dist/esm/equals.d.ts
CHANGED
|
@@ -32,10 +32,15 @@ interface EqualsOptions {
|
|
|
32
32
|
unknown?: boolean;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
|
-
* Compare two messages of the same type.
|
|
35
|
+
* Compare two messages of the same type for equality.
|
|
36
36
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
37
|
+
* Fields are compared one by one, but only when set: a field set in one message
|
|
38
|
+
* but not the other makes them unequal, while fields set in both are compared
|
|
39
|
+
* by value. Extensions and unknown fields are disregarded by default.
|
|
40
|
+
*
|
|
41
|
+
* Float and double values are compared with IEEE semantics: NaN does not equal
|
|
42
|
+
* NaN, and -0 equals 0 (with the exception for singular fields with implicit
|
|
43
|
+
* presence: -0 is set, +0 is unset).
|
|
39
44
|
*/
|
|
40
45
|
export declare function equals<Desc extends DescMessage>(schema: Desc, a: MessageShape<Desc>, b: MessageShape<Desc>, options?: EqualsOptions): boolean;
|
|
41
46
|
export {};
|
package/dist/esm/equals.js
CHANGED
|
@@ -17,10 +17,15 @@ import { ScalarType, } from "./descriptors.js";
|
|
|
17
17
|
import { anyUnpack } from "./wkt/index.js";
|
|
18
18
|
import { createExtensionContainer, getExtension } from "./extensions.js";
|
|
19
19
|
/**
|
|
20
|
-
* Compare two messages of the same type.
|
|
20
|
+
* Compare two messages of the same type for equality.
|
|
21
21
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
22
|
+
* Fields are compared one by one, but only when set: a field set in one message
|
|
23
|
+
* but not the other makes them unequal, while fields set in both are compared
|
|
24
|
+
* by value. Extensions and unknown fields are disregarded by default.
|
|
25
|
+
*
|
|
26
|
+
* Float and double values are compared with IEEE semantics: NaN does not equal
|
|
27
|
+
* NaN, and -0 equals 0 (with the exception for singular fields with implicit
|
|
28
|
+
* presence: -0 is set, +0 is unset).
|
|
24
29
|
*/
|
|
25
30
|
export function equals(schema, a, b, options) {
|
|
26
31
|
if (a.$typeName != schema.typeName || b.$typeName != schema.typeName) {
|
package/dist/esm/extensions.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AnyDesc, DescEnum, DescEnumValue, DescExtension, DescField, DescFile, DescMessage, DescMethod, DescOneof, DescService } from "./descriptors.js";
|
|
2
|
+
import type { BinaryReadOptions } from "./from-binary.js";
|
|
2
3
|
import type { ReflectMessage } from "./reflect/reflect-types.js";
|
|
3
4
|
import type { Extendee, ExtensionValueShape } from "./types.js";
|
|
4
5
|
import type { EnumOptions, EnumValueOptions, FieldOptions, FileOptions, MessageOptions, MethodOptions, OneofOptions, ServiceOptions } from "./wkt/gen/google/protobuf/descriptor_pb.js";
|
|
@@ -16,7 +17,7 @@ import type { EnumOptions, EnumValueOptions, FieldOptions, FileOptions, MessageO
|
|
|
16
17
|
*
|
|
17
18
|
* If the extension does not extend the given message, an error is raised.
|
|
18
19
|
*/
|
|
19
|
-
export declare function getExtension<Desc extends DescExtension>(message: Extendee<Desc>, extension: Desc): ExtensionValueShape<Desc>;
|
|
20
|
+
export declare function getExtension<Desc extends DescExtension>(message: Extendee<Desc>, extension: Desc, options?: Partial<BinaryReadOptions>): ExtensionValueShape<Desc>;
|
|
20
21
|
/**
|
|
21
22
|
* Set an extension value on a message. If the message already has a value for
|
|
22
23
|
* this extension, the value is replaced.
|
package/dist/esm/extensions.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
import { create } from "./create.js";
|
|
15
|
-
import { readField } from "./from-binary.js";
|
|
15
|
+
import { makeReadContext, readField } from "./from-binary.js";
|
|
16
16
|
import { reflect } from "./reflect/reflect.js";
|
|
17
17
|
import { scalarZeroValue } from "./reflect/scalar.js";
|
|
18
18
|
import { writeField } from "./to-binary.js";
|
|
@@ -32,14 +32,13 @@ import { isWrapperDesc } from "./wkt/wrappers.js";
|
|
|
32
32
|
*
|
|
33
33
|
* If the extension does not extend the given message, an error is raised.
|
|
34
34
|
*/
|
|
35
|
-
export function getExtension(message, extension) {
|
|
35
|
+
export function getExtension(message, extension, options) {
|
|
36
36
|
assertExtendee(extension, message);
|
|
37
37
|
const ufs = filterUnknownFields(message.$unknown, extension);
|
|
38
38
|
const [container, field, get] = createExtensionContainer(extension);
|
|
39
|
+
const ctx = makeReadContext(options);
|
|
39
40
|
for (const uf of ufs) {
|
|
40
|
-
readField(container, new BinaryReader(uf.data), field, uf.wireType,
|
|
41
|
-
readUnknownFields: true,
|
|
42
|
-
});
|
|
41
|
+
readField(container, new BinaryReader(uf.data), field, uf.wireType, ctx);
|
|
43
42
|
}
|
|
44
43
|
return get();
|
|
45
44
|
}
|
|
@@ -13,7 +13,20 @@ export interface BinaryReadOptions {
|
|
|
13
13
|
* For more details see https://developers.google.com/protocol-buffers/docs/proto3#unknowns
|
|
14
14
|
*/
|
|
15
15
|
readUnknownFields: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* The maximum depth of nested messages to parse. If a message nests deeper
|
|
18
|
+
* than this limit, parsing fails with an error instead of exhausting the
|
|
19
|
+
* call stack. Defaults to 100.
|
|
20
|
+
*/
|
|
21
|
+
recursionLimit: number;
|
|
22
|
+
}
|
|
23
|
+
interface BinaryReadContext extends BinaryReadOptions {
|
|
24
|
+
depth: number;
|
|
16
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* @private Only exported for getExtension()
|
|
28
|
+
*/
|
|
29
|
+
export declare function makeReadContext(options?: Partial<BinaryReadOptions>): BinaryReadContext;
|
|
17
30
|
/**
|
|
18
31
|
* Parse serialized binary data.
|
|
19
32
|
*/
|
|
@@ -29,6 +42,7 @@ export declare function fromBinary<Desc extends DescMessage>(schema: Desc, bytes
|
|
|
29
42
|
*/
|
|
30
43
|
export declare function mergeFromBinary<Desc extends DescMessage>(schema: Desc, target: MessageShape<Desc>, bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MessageShape<Desc>;
|
|
31
44
|
/**
|
|
32
|
-
* @private
|
|
45
|
+
* @private Only exported for getExtension()
|
|
33
46
|
*/
|
|
34
|
-
export declare function readField(message: ReflectMessage, reader: BinaryReader, field: DescField, wireType: WireType,
|
|
47
|
+
export declare function readField(message: ReflectMessage, reader: BinaryReader, field: DescField, wireType: WireType, ctx: BinaryReadContext): void;
|
|
48
|
+
export {};
|